@voilabs/mark 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Editor.d.ts.map +1 -1
- package/dist/components/editor/StyleBar.d.ts.map +1 -1
- package/dist/components/editor/slash-command/suggestion.d.ts.map +1 -1
- package/dist/components/ui/DropdownMenu.d.ts +1 -1
- package/dist/components/ui/DropdownMenu.d.ts.map +1 -1
- package/dist/components/ui/Popover.d.ts.map +1 -1
- package/dist/components/ui/Tooltip.d.ts.map +1 -1
- package/dist/components/ui/usePortalContainer.d.ts +3 -0
- package/dist/components/ui/usePortalContainer.d.ts.map +1 -0
- package/dist/index.cjs.js +48 -48
- package/dist/index.es.js +2718 -2688
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),K=require("react"),
|
|
2
|
-
]`).replace("lheading",
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),K=require("react"),Th=require("@radix-ui/react-tooltip"),q=require("lucide-react"),Tr=require("@tiptap/react"),Ah=require("@tiptap/starter-kit"),Eh=require("@tiptap/extension-link"),P=require("@tiptap/core"),Mh=require("@tiptap/extension-placeholder"),Rh=require("@tiptap/extension-text-align"),Nh=require("@tiptap/extension-underline"),Xn=require("./translations/en-US.cjs.js"),Qi=require("react-dom"),Oh=require("react-easy-crop");function Zi(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const v=Zi(K),Fn=Zi(Th),su=Zi(Qi);function ea(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var En=ea();function iu(e){En=e}var gn={exec:()=>null};function ce(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,s)=>{let i=typeof s=="string"?s:s.source;return i=i.replace(He.caret,"$1"),n=n.replace(o,i),r},getRegex:()=>new RegExp(n,t)};return r}var Ih=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),He={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)}}>`)},Ph=/^(?:[ \t]*(?:\n|$))+/,Lh=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Dh=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,$r=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,jh=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ta=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,au=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,lu=ce(au).replace(/bull/g,ta).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(),zh=ce(au).replace(/bull/g,ta).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(),na=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,_h=/^[^\n]+/,ra=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,$h=ce(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ra).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Fh=ce(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ta).getRegex(),as="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",oa=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Bh=ce("^ {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[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",oa).replace("tag",as).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),cu=ce(na).replace("hr",$r).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",as).getRegex(),Hh=ce(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",cu).getRegex(),sa={blockquote:Hh,code:Lh,def:$h,fences:Dh,heading:jh,hr:$r,html:Bh,lheading:lu,list:Fh,newline:Ph,paragraph:cu,table:gn,text:_h},sl=ce("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",$r).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\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",as).getRegex(),Wh={...sa,lheading:zh,table:sl,paragraph:ce(na).replace("hr",$r).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",sl).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",as).getRegex()},Vh={...sa,html:ce(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",oa).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:gn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ce(na).replace("hr",$r).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",lu).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},qh=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Kh=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,uu=/^( {2,}|\\)\n(?!\s*$)/,Uh=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,or=/[\p{P}\p{S}]/u,ls=/[\s\p{P}\p{S}]/u,ia=/[^\s\p{P}\p{S}]/u,Gh=ce(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ls).getRegex(),du=/(?!~)[\p{P}\p{S}]/u,Xh=/(?!~)[\s\p{P}\p{S}]/u,Jh=/(?:[^\s\p{P}\p{S}]|~)/u,Yh=ce(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ih?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),fu=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Qh=ce(fu,"u").replace(/punct/g,or).getRegex(),Zh=ce(fu,"u").replace(/punct/g,du).getRegex(),pu="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",em=ce(pu,"gu").replace(/notPunctSpace/g,ia).replace(/punctSpace/g,ls).replace(/punct/g,or).getRegex(),tm=ce(pu,"gu").replace(/notPunctSpace/g,Jh).replace(/punctSpace/g,Xh).replace(/punct/g,du).getRegex(),nm=ce("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ia).replace(/punctSpace/g,ls).replace(/punct/g,or).getRegex(),rm=ce(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,or).getRegex(),om="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",sm=ce(om,"gu").replace(/notPunctSpace/g,ia).replace(/punctSpace/g,ls).replace(/punct/g,or).getRegex(),im=ce(/\\(punct)/,"gu").replace(/punct/g,or).getRegex(),am=ce(/^<(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(),lm=ce(oa).replace("(?:-->|$)","-->").getRegex(),cm=ce("^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",lm).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),zo=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,um=ce(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",zo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),hu=ce(/^!?\[(label)\]\[(ref)\]/).replace("label",zo).replace("ref",ra).getRegex(),mu=ce(/^!?\[(ref)\](?:\[\])?/).replace("ref",ra).getRegex(),dm=ce("reflink|nolink(?!\\()","g").replace("reflink",hu).replace("nolink",mu).getRegex(),il=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,aa={_backpedal:gn,anyPunctuation:im,autolink:am,blockSkip:Yh,br:uu,code:Kh,del:gn,delLDelim:gn,delRDelim:gn,emStrongLDelim:Qh,emStrongRDelimAst:em,emStrongRDelimUnd:nm,escape:qh,link:um,nolink:mu,punctuation:Gh,reflink:hu,reflinkSearch:dm,tag:cm,text:Uh,url:gn},fm={...aa,link:ce(/^!?\[(label)\]\((.*?)\)/).replace("label",zo).getRegex(),reflink:ce(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",zo).getRegex()},mi={...aa,emStrongRDelimAst:tm,emStrongLDelim:Zh,delLDelim:rm,delRDelim:sm,url:ce(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",il).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:ce(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",il).getRegex()},pm={...mi,br:ce(uu).replace("{2,}","*").getRegex(),text:ce(mi.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},so={normal:sa,gfm:Wh,pedantic:Vh},lr={normal:aa,gfm:mi,breaks:pm,pedantic:fm},hm={"&":"&","<":"<",">":">",'"':""","'":"'"},al=e=>hm[e];function wt(e,t){if(t){if(He.escapeTest.test(e))return e.replace(He.escapeReplace,al)}else if(He.escapeTestNoEncode.test(e))return e.replace(He.escapeReplaceNoEncode,al);return e}function ll(e){try{e=encodeURI(e).replace(He.percentDecode,"%")}catch{return null}return e}function cl(e,t){let n=e.replace(He.findPipe,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(He.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(He.slashPipe,"|");return r}function cr(e,t,n){let r=e.length;if(r===0)return"";let o=0;for(;o<r&&e.charAt(r-o-1)===t;)o++;return e.slice(0,r-o)}function mm(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function gm(e,t=0){let n=t,r="";for(let o of e)if(o===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=o,n++;return r}function ul(e,t,n,r,o){let s=t.href,i=t.title||null,a=e[1].replace(o.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:i,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function bm(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
|
|
3
3
|
`).map(s=>{let i=s.match(n.other.beginningSpace);if(i===null)return s;let[a]=i;return a.length>=o.length?s.slice(o.length):s}).join(`
|
|
4
|
-
`)}var
|
|
5
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=
|
|
4
|
+
`)}var _o=class{options;rules;lexer;constructor(e){this.options=e||En}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:cr(n,`
|
|
5
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=bm(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:r}}}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 r=cr(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.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:cr(t[0],`
|
|
6
6
|
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=cr(t[0],`
|
|
7
7
|
`).split(`
|
|
8
8
|
`),r="",o="",s=[];for(;n.length>0;){let i=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),i=!0;else if(!i)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
|
|
@@ -14,16 +14,16 @@ ${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
14
14
|
`),g=this.blockquote(m);s[s.length-1]=g,r=r.substring(0,r.length-p.raw.length)+g.raw,o=o.substring(0,o.length-p.text.length)+g.text;break}else if(f?.type==="list"){let p=f,m=p.raw+`
|
|
15
15
|
`+n.join(`
|
|
16
16
|
`),g=this.list(m);s[s.length-1]=g,r=r.substring(0,r.length-f.raw.length)+g.raw,o=o.substring(0,o.length-p.raw.length)+g.raw,n=m.substring(s.at(-1).raw.length).split(`
|
|
17
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),i=!1;for(;e;){let l=!1,c="",u="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let d=
|
|
17
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),i=!1;for(;e;){let l=!1,c="",u="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let d=gm(t[2].split(`
|
|
18
18
|
`,1)[0],t[1].length),f=e.split(`
|
|
19
19
|
`,1)[0],p=!d.trim(),m=0;if(this.options.pedantic?(m=2,u=d.trimStart()):p?m=t[1].length+1:(m=d.search(this.rules.other.nonSpaceChar),m=m>4?1:m,u=d.slice(m),m+=t[1].length),p&&this.rules.other.blankLine.test(f)&&(c+=f+`
|
|
20
|
-
`,e=e.substring(f.length+1),l=!0),!l){let g=this.rules.other.nextBulletRegex(m),b=this.rules.other.hrRegex(m),x=this.rules.other.fencesBeginRegex(m),S=this.rules.other.headingBeginRegex(m),k=this.rules.other.htmlBeginRegex(m),y=this.rules.other.blockquoteBeginRegex(m);for(;e;){let
|
|
21
|
-
`,1)[0],w;if(f=
|
|
20
|
+
`,e=e.substring(f.length+1),l=!0),!l){let g=this.rules.other.nextBulletRegex(m),b=this.rules.other.hrRegex(m),x=this.rules.other.fencesBeginRegex(m),S=this.rules.other.headingBeginRegex(m),k=this.rules.other.htmlBeginRegex(m),y=this.rules.other.blockquoteBeginRegex(m);for(;e;){let A=e.split(`
|
|
21
|
+
`,1)[0],w;if(f=A,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),w=f):w=f.replace(this.rules.other.tabCharGlobal," "),x.test(f)||S.test(f)||k.test(f)||y.test(f)||g.test(f)||b.test(f))break;if(w.search(this.rules.other.nonSpaceChar)>=m||!f.trim())u+=`
|
|
22
22
|
`+w.slice(m);else{if(p||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||x.test(d)||S.test(d)||b.test(d))break;u+=`
|
|
23
|
-
`+f}p=!f.trim(),c+=
|
|
24
|
-
`,e=e.substring(
|
|
25
|
-
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let i of r)this.rules.other.tableAlignRight.test(i)?s.align.push("right"):this.rules.other.tableAlignCenter.test(i)?s.align.push("center"):this.rules.other.tableAlignLeft.test(i)?s.align.push("left"):s.align.push(null);for(let i=0;i<n.length;i++)s.header.push({text:n[i],tokens:this.lexer.inline(n[i]),header:!0,align:s.align[i]});for(let i of o)s.rows.push(
|
|
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 s=cr(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=
|
|
23
|
+
`+f}p=!f.trim(),c+=A+`
|
|
24
|
+
`,e=e.substring(A.length+1),d=w.slice(m)}}o.loose||(i?o.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(i=!0)),o.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),o.raw+=c}let a=o.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let l of o.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(l.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};l.checked=u.checked,o.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=u.raw+l.tokens[0].raw,l.tokens[0].text=u.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(u)):l.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):l.tokens.unshift(u)}}if(!o.loose){let c=l.tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));o.loose=u}}if(o.loose)for(let l of o.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return o}}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," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=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:r,title:o}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=cl(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
25
|
+
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let i of r)this.rules.other.tableAlignRight.test(i)?s.align.push("right"):this.rules.other.tableAlignCenter.test(i)?s.align.push("center"):this.rules.other.tableAlignLeft.test(i)?s.align.push("left"):s.align.push(null);for(let i=0;i<n.length;i++)s.header.push({text:n[i],tokens:this.lexer.inline(n[i]),header:!0,align:s.align[i]});for(let i of o)s.rows.push(cl(i,s.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:s.align[l]})));return s}}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 s=cr(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=mm(t[2],"()");if(s===-2)return;if(s>-1){let i=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let r=t[2],o="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],o=s[3])}else o=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),ul(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.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 r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=t[r.toLowerCase()];if(!o){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return ul(n,o,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,i,a=o,l=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+o);(r=c.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(i=[...s].length,r[3]||r[4]){a+=i;continue}else if((r[5]||r[6])&&o%3&&!((o+i)%3)){l+=i;continue}if(a-=i,a>0)continue;i=Math.min(i,i+a+l);let u=[...r[0]][0].length,d=e.slice(0,o+r.index+u+i);if(Math.min(o,i)%2){let p=d.slice(1,-1);return{type:"em",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}let f=d.slice(2,-2);return{type:"strong",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(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 r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,i,a=o,l=this.rules.inline.delRDelim;for(l.lastIndex=0,t=t.slice(-1*e.length+o);(r=l.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(i=[...s].length,i!==o))continue;if(r[3]||r[4]){a+=i;continue}if(a-=i,a>0)continue;i=Math.min(i,i+a);let c=[...r[0]][0].length,u=e.slice(0,o+r.index+c+i),d=u.slice(o,-o);return{type:"del",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else{let o;do o=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(o!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:n,href:r,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}}}},pt=class gi{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||En,this.options.tokenizer=this.options.tokenizer||new _o,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:He,block:so.normal,inline:lr.normal};this.options.pedantic?(n.block=so.pedantic,n.inline=lr.pedantic):this.options.gfm&&(n.block=so.gfm,this.options.breaks?n.inline=lr.breaks:n.inline=lr.gfm),this.tokenizer.rules=n}static get rules(){return{block:so,inline:lr}}static lex(t,n){return new gi(n).lex(t)}static lexInline(t,n){return new gi(n).inlineTokens(t)}lex(t){t=t.replace(He.carriageReturn,`
|
|
27
27
|
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(He.tabCharGlobal," ").replace(He.spaceLine,""));t;){let o;if(this.options.extensions?.block?.some(i=>(o=i.call({lexer:this},t,n))?(t=t.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length);let i=n.at(-1);o.raw.length===1&&i!==void 0?i.raw+=`
|
|
28
28
|
`:n.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length);let i=n.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
29
29
|
`)?"":`
|
|
@@ -37,7 +37,7 @@ ${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
37
37
|
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):n.push(o),r=s.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length);let i=n.at(-1);i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
38
38
|
`)?"":`
|
|
39
39
|
`)+o.raw,i.text+=`
|
|
40
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):n.push(o);continue}if(t){let i="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}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 r=t,o=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(r))!==null;)l.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(r))!==null;)r=r.slice(0,o.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(o=this.tokenizer.rules.inline.blockSkip.exec(r))!==null;)s=o[2]?o[2].length:0,r=r.slice(0,o.index+s)+"["+"a".repeat(o[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,a="";for(;t;){i||(a=""),i=!1;let l;if(this.options.extensions?.inline?.some(u=>(l=u.call({lexer:this},t,n))?(t=t.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(l.raw.length);let u=n.at(-1);l.type==="text"&&u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(t,r,a)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(t,r,a)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(t)){t=t.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(t))){t=t.substring(l.raw.length),n.push(l);continue}let c=t;if(this.options.extensions?.startInline){let u=1/0,d=t.slice(1),f;this.options.extensions.startInline.forEach(p=>{f=p.call({lexer:this},d),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(c=t.substring(0,u+1))}if(l=this.tokenizer.inlineText(c)){t=t.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(a=l.raw.slice(-1)),i=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(t){let u="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return n}}
|
|
40
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):n.push(o);continue}if(t){let i="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}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 r=t,o=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(r))!==null;)l.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(r))!==null;)r=r.slice(0,o.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(o=this.tokenizer.rules.inline.blockSkip.exec(r))!==null;)s=o[2]?o[2].length:0,r=r.slice(0,o.index+s)+"["+"a".repeat(o[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,a="";for(;t;){i||(a=""),i=!1;let l;if(this.options.extensions?.inline?.some(u=>(l=u.call({lexer:this},t,n))?(t=t.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(l.raw.length);let u=n.at(-1);l.type==="text"&&u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(t,r,a)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(t,r,a)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(t)){t=t.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(t))){t=t.substring(l.raw.length),n.push(l);continue}let c=t;if(this.options.extensions?.startInline){let u=1/0,d=t.slice(1),f;this.options.extensions.startInline.forEach(p=>{f=p.call({lexer:this},d),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(c=t.substring(0,u+1))}if(l=this.tokenizer.inlineText(c)){t=t.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(a=l.raw.slice(-1)),i=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(t){let u="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return n}},$o=class{options;parser;constructor(e){this.options=e||En}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(He.notSpaceStart)?.[0],o=e.replace(He.endingNewline,"")+`
|
|
41
41
|
`;return r?'<pre><code class="language-'+wt(r)+'">'+(n?o:wt(o,!0))+`</code></pre>
|
|
42
42
|
`:"<pre><code>"+(n?o:wt(o,!0))+`</code></pre>
|
|
43
43
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
@@ -55,36 +55,36 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
55
55
|
`}tablerow({text:e}){return`<tr>
|
|
56
56
|
${e}</tr>
|
|
57
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>${wt(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 r=this.parser.parseInline(n),o=
|
|
59
|
-
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+wt(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},wn=new
|
|
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>${wt(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 r=this.parser.parseInline(n),o=ll(e);if(o===null)return r;e=o;let s='<a href="'+e+'"';return t&&(s+=' title="'+wt(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=ll(e);if(o===null)return wt(n);e=o;let s=`<img src="${e}" alt="${wt(n)}"`;return t&&(s+=` title="${wt(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:wt(e.text)}},la=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}},ht=class bi{options;renderer;textRenderer;constructor(t){this.options=t||En,this.options.renderer=this.options.renderer||new $o,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new la}static parse(t,n){return new bi(n).parse(t)}static parseInline(t,n){return new bi(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let r=0;r<t.length;r++){let o=t[r];if(this.options.extensions?.renderers?.[o.type]){let i=o,a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){n+=a||"";continue}}let s=o;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let i='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let r="";for(let o=0;o<t.length;o++){let s=t[o];if(this.options.extensions?.renderers?.[s.type]){let a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){r+=a||"";continue}}let i=s;switch(i.type){case"escape":{r+=n.text(i);break}case"html":{r+=n.html(i);break}case"link":{r+=n.link(i);break}case"image":{r+=n.image(i);break}case"checkbox":{r+=n.checkbox(i);break}case"strong":{r+=n.strong(i);break}case"em":{r+=n.em(i);break}case"codespan":{r+=n.codespan(i);break}case"br":{r+=n.br(i);break}case"del":{r+=n.del(i);break}case"text":{r+=n.text(i);break}default:{let a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},mr=class{options;block;constructor(e){this.options=e||En}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?pt.lex:pt.lexInline}provideParser(e=this.block){return e?ht.parse:ht.parseInline}},ym=class{defaults=ea();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ht;Renderer=$o;TextRenderer=la;Lexer=pt;Tokenizer=_o;Hooks=mr;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let o=r;for(let s of o.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of o.rows)for(let i of s)n=n.concat(this.walkTokens(i.tokens,t));break}case"list":{let o=r;n=n.concat(this.walkTokens(o.items,t));break}default:{let o=r;this.defaults.extensions?.childTokens?.[o.type]?this.defaults.extensions.childTokens[o.type].forEach(s=>{let i=o[s].flat(1/0);n=n.concat(this.walkTokens(i,t))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[o.level];s?s.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){let o=this.defaults.renderer||new $o(this.defaults);for(let s in n.renderer){if(!(s in o))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=s,a=n.renderer[i],l=o[i];o[i]=(...c)=>{let u=a.apply(o,c);return u===!1&&(u=l.apply(o,c)),u||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new _o(this.defaults);for(let s in n.tokenizer){if(!(s in o))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=s,a=n.tokenizer[i],l=o[i];o[i]=(...c)=>{let u=a.apply(o,c);return u===!1&&(u=l.apply(o,c)),u}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new mr;for(let s in n.hooks){if(!(s in o))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=s,a=n.hooks[i],l=o[i];mr.passThroughHooks.has(s)?o[i]=c=>{if(this.defaults.async&&mr.passThroughHooksRespectAsync.has(s))return(async()=>{let d=await a.call(o,c);return l.call(o,d)})();let u=a.call(o,c);return l.call(o,u)}:o[i]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await a.apply(o,c);return d===!1&&(d=await l.apply(o,c)),d})();let u=a.apply(o,c);return u===!1&&(u=l.apply(o,c)),u}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(i){let a=[];return a.push(s.call(this,i)),o&&(a=a.concat(o.call(this,i))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return pt.lex(e,t??this.defaults)}parser(e,t){return ht.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},s=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return s(new 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 s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=e),o.async)return(async()=>{let i=o.hooks?await o.hooks.preprocess(t):t,a=await(o.hooks?await o.hooks.provideLexer(e):e?pt.lex:pt.lexInline)(i,o),l=o.hooks?await o.hooks.processAllTokens(a):a;o.walkTokens&&await Promise.all(this.walkTokens(l,o.walkTokens));let c=await(o.hooks?await o.hooks.provideParser(e):e?ht.parse:ht.parseInline)(l,o);return o.hooks?await o.hooks.postprocess(c):c})().catch(s);try{o.hooks&&(t=o.hooks.preprocess(t));let i=(o.hooks?o.hooks.provideLexer(e):e?pt.lex:pt.lexInline)(t,o);o.hooks&&(i=o.hooks.processAllTokens(i)),o.walkTokens&&this.walkTokens(i,o.walkTokens);let a=(o.hooks?o.hooks.provideParser(e):e?ht.parse:ht.parseInline)(i,o);return o.hooks&&(a=o.hooks.postprocess(a)),a}catch(i){return s(i)}}}onError(e,t){return n=>{if(n.message+=`
|
|
59
|
+
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+wt(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},wn=new ym;function me(e,t){return wn.parse(e,t)}me.options=me.setOptions=function(e){return wn.setOptions(e),me.defaults=wn.defaults,iu(me.defaults),me};me.getDefaults=ea;me.defaults=En;me.use=function(...e){return wn.use(...e),me.defaults=wn.defaults,iu(me.defaults),me};me.walkTokens=function(e,t){return wn.walkTokens(e,t)};me.parseInline=wn.parseInline;me.Parser=ht;me.parser=ht.parse;me.Renderer=$o;me.TextRenderer=la;me.Lexer=pt;me.lexer=pt.lex;me.Tokenizer=_o;me.Hooks=mr;me.parse=me;me.options;me.setOptions;me.use;me.walkTokens;me.parseInline;ht.parse;pt.lex;function xm(e,t){const r=t.split(`
|
|
60
60
|
`).flatMap(o=>[o,""]).map(o=>`${e}${o}`).join(`
|
|
61
|
-
`);return r.slice(0,r.length-1)}function
|
|
62
|
-
`).match(/\n\n/g)||[]).length}parseToken(e,t=!1){if(!e.type)return null;if(e.type==="list")return this.parseListToken(e);const n=this.getHandlersForToken(e.type),r=this.createParseHelpers();if(n.find(s=>{if(!s.parseMarkdown)return!1;const i=s.parseMarkdown(e,r),a=this.normalizeParseResult(i);return a&&(!Array.isArray(a)||a.length>0)?(this.lastParseResult=a,!0):!1})&&this.lastParseResult){const s=this.lastParseResult;return this.lastParseResult=null,s}return this.parseFallbackToken(e,t)}parseListToken(e){if(!e.items||e.items.length===0)return this.parseTokenWithHandlers(e);const t=e.items.some(a=>
|
|
61
|
+
`);return r.slice(0,r.length-1)}function vm(e,t){const n=[];return Array.from(e.keys()).forEach(r=>{(!t||!t.marks||!t.marks.map(o=>o.type).includes(r))&&n.push(r)}),n}function wm(e,t){const n=[];return Array.from(t.entries()).forEach(([r,o])=>{e.has(r)||n.push({type:r,mark:o})}),n}function km(e,t,n,r){const o=!n,s=n&&n.type==="text"&&(!n.marks||n.marks.length===0),i=n&&n.type==="text"&&n.marks&&!r(t,new Map(n.marks.map(l=>[l.type,l]))),a=[];if(o||s||i)if(n&&n.type==="text"&&n.marks){const l=new Map(n.marks.map(c=>[c.type,c]));Array.from(e.keys()).reverse().forEach(c=>{l.has(c)||a.push(c)})}else(o||s)&&a.push(...Array.from(e.keys()).reverse());return a}function Cm(e,t){let n="";return Array.from(e.keys()).reverse().forEach(r=>{const o=e.get(r),s=t(r,o);s&&(n=s+n)}),e.clear(),n}function Sm(e,t,n){let r="";return Array.from(e.entries()).forEach(([o,s])=>{const i=n(o,s);i&&(r+=i),t.set(o,s)}),r}function Rs(e){const n=(e.raw||e.text||"").match(/^(\s*)[-+*]\s+\[([ xX])\]\s+/);return n?{isTask:!0,checked:n[2].toLowerCase()==="x",indentLevel:n[1].length}:{isTask:!1,indentLevel:0}}function io(e,t){return typeof e!="string"?"json":t}var Tm=class{constructor(e){this.activeParseLexer=null,this.extensionRanks=new Map,this.baseExtensions=[],this.extensions=[],this.codeTypes=new Set,this.lastParseResult=null;var t,n,r,o,s;this.markedInstance=(t=e?.marked)!=null?t:me,this.indentStyle=(r=(n=e?.indentation)==null?void 0:n.style)!=null?r:"space",this.indentSize=(s=(o=e?.indentation)==null?void 0:o.size)!=null?s:2,this.baseExtensions=e?.extensions||[],e?.markedOptions&&typeof this.markedInstance.setOptions=="function"&&this.markedInstance.setOptions(e.markedOptions),this.registry=new Map,this.nodeTypeRegistry=new Map,e?.extensions&&(this.baseExtensions=e.extensions,P.sortExtensions(P.flattenExtensions(e.extensions)).forEach(a=>this.registerExtension(a)))}get instance(){return this.markedInstance}get indentCharacter(){return this.indentStyle==="space"?" ":" "}get indentString(){return this.indentCharacter.repeat(this.indentSize)}hasMarked(){return!!this.markedInstance}registerExtension(e){var t,n;this.extensions.push(e);const r=P.callOrReturn(P.getExtensionField(e,"code")),o=e.name;r&&this.codeTypes.add(o),this.extensionRanks.has(o)||this.extensionRanks.set(o,this.extensionRanks.size);const s=P.getExtensionField(e,"markdownTokenName")||o,i=P.getExtensionField(e,"parseMarkdown"),a=P.getExtensionField(e,"renderMarkdown"),l=P.getExtensionField(e,"markdownTokenizer"),c=(t=P.getExtensionField(e,"markdownOptions"))!=null?t:null,u=(n=c?.indentsContent)!=null?n:!1,d=c?.htmlReopen,f={tokenName:s,nodeName:o,parseMarkdown:i,renderMarkdown:a,isIndenting:u,htmlReopen:d,tokenizer:l};if(s&&i){const p=this.registry.get(s)||[];p.push(f),this.registry.set(s,p)}if(a){const p=this.nodeTypeRegistry.get(o)||[];p.push(f),this.nodeTypeRegistry.set(o,p)}l&&this.hasMarked()&&this.registerTokenizer(l)}createLexer(){return new this.markedInstance.Lexer}createTokenizerHelpers(e){return{inlineTokens:t=>e.inlineTokens(t),blockTokens:t=>e.blockTokens(t)}}tokenizeInline(e){var t;return((t=this.activeParseLexer)!=null?t:this.createLexer()).inlineTokens(e)}registerTokenizer(e){if(!this.hasMarked())return;const{name:t,start:n,level:r="inline",tokenize:o}=e,s=this.createTokenizerHelpers.bind(this),i=this.createLexer.bind(this);let a;n?a=typeof n=="function"?n:c=>c.indexOf(n):a=c=>{const u=o(c,[],this.createTokenizerHelpers(this.createLexer()));return u&&u.raw?c.indexOf(u.raw):-1};const l={name:t,level:r,start:a,tokenizer(c,u){const d=this.lexer?s(this.lexer):s(i()),f=o(c,u,d);if(f&&f.type)return{...f,type:f.type||t,raw:f.raw||"",tokens:f.tokens||[]}},childTokens:[]};this.markedInstance.use({extensions:[l]})}getHandlersForToken(e){try{return this.registry.get(e)||[]}catch{return[]}}getHandlerForToken(e){const t=this.getHandlersForToken(e);if(t.length>0)return t[0];const n=this.getHandlersForNodeType(e);return n.length>0?n[0]:void 0}getHandlersForNodeType(e){try{return this.nodeTypeRegistry.get(e)||[]}catch{return[]}}serialize(e){if(!e)return"";const t=this.renderNodes(e,e);return this.isEmptyOutput(t)?"":t}isEmptyOutput(e){return!e||e.trim()===""?!0:e.replace(/ /g,"").replace(/\u00A0/g,"").trim()===""}parse(e){if(!this.hasMarked())throw new Error("No marked instance available for parsing");const t=this.activeParseLexer,n=this.createLexer();this.activeParseLexer=n;try{const r=n.lex(e);return{type:"doc",content:this.parseTokens(r,!0)}}finally{this.activeParseLexer=t}}parseTokens(e,t=!1){const n=e.reduce((s,i,a)=>(i.type!=="space"&&s.push(a),s),[]);let r=-1,o=0;return e.flatMap((s,i)=>{for(var a;o<n.length&&n[o]<i;)r=n[o],o+=1;if(t&&s.type==="space"){const c=(a=n[o])!=null?a:-1;return this.createImplicitEmptyParagraphsFromSpace(s,r,c)}const l=this.parseToken(s,t);return l===null?[]:Array.isArray(l)?l:[l]})}createImplicitEmptyParagraphsFromSpace(e,t,n){const r=this.countParagraphSeparators(e.raw||"");if(r===0)return[];const s=Math.max(r-(t===-1||n===-1?0:1),0);return Array.from({length:s},()=>({type:"paragraph",content:[]}))}countParagraphSeparators(e){return(e.replace(/\r\n/g,`
|
|
62
|
+
`).match(/\n\n/g)||[]).length}parseToken(e,t=!1){if(!e.type)return null;if(e.type==="list")return this.parseListToken(e);const n=this.getHandlersForToken(e.type),r=this.createParseHelpers();if(n.find(s=>{if(!s.parseMarkdown)return!1;const i=s.parseMarkdown(e,r),a=this.normalizeParseResult(i);return a&&(!Array.isArray(a)||a.length>0)?(this.lastParseResult=a,!0):!1})&&this.lastParseResult){const s=this.lastParseResult;return this.lastParseResult=null,s}return this.parseFallbackToken(e,t)}parseListToken(e){if(!e.items||e.items.length===0)return this.parseTokenWithHandlers(e);const t=e.items.some(a=>Rs(a).isTask),n=e.items.some(a=>!Rs(a).isTask);if(!t||!n||this.getHandlersForToken("taskList").length===0)return this.parseTokenWithHandlers(e);const r=[];let o=[],s=null;for(let a=0;a<e.items.length;a+=1){const l=e.items[a],{isTask:c,checked:u,indentLevel:d}=Rs(l);let f=l;if(c){const g=(l.raw||l.text||"").split(`
|
|
63
63
|
`),b=g[0].match(/^\s*[-+*]\s+\[([ xX])\]\s+(.*)$/),x=b?b[2]:"";let S=[];if(g.length>1&&g.slice(1).join(`
|
|
64
|
-
`).trim()){const y=g.slice(1),
|
|
65
|
-
`).trim();
|
|
66
|
-
`))}}f={type:"taskItem",raw:"",mainContent:x,indentLevel:d,checked:u??!1,text:x,tokens:this.tokenizeInline(x),nestedTokens:S}}const p=c?"taskList":"list";s!==p?(o.length>0&&r.push({type:s,items:o}),o=[f],s=p):o.push(f)}o.length>0&&r.push({type:s,items:o});const i=[];for(let a=0;a<r.length;a+=1){const l=r[a],c={...e,type:l.type,items:l.items},u=this.parseToken(c);u&&(Array.isArray(u)?i.push(...u):i.push(u))}return i.length>0?i:null}parseTokenWithHandlers(e){if(!e.type)return null;const t=this.getHandlersForToken(e.type),n=this.createParseHelpers();if(t.find(o=>{if(!o.parseMarkdown)return!1;const s=o.parseMarkdown(e,n),i=this.normalizeParseResult(s);return i&&(!Array.isArray(i)||i.length>0)?(this.lastParseResult=i,!0):!1})&&this.lastParseResult){const o=this.lastParseResult;return this.lastParseResult=null,o}return this.parseFallbackToken(e)}createParseHelpers(){return{parseInline:e=>this.parseInlineTokens(e),tokenizeInline:e=>this.tokenizeInline(e),parseChildren:e=>this.parseTokens(e),parseBlockChildren:e=>this.parseTokens(e,!0),createTextNode:(e,t)=>({type:"text",text:e,marks:t||void 0}),createNode:(e,t,n)=>{const r={type:e,attrs:t||void 0,content:n||void 0};return(!t||Object.keys(t).length===0)&&delete r.attrs,r},applyMark:(e,t,n)=>({mark:e,content:t,attrs:n&&Object.keys(n).length>0?n:void 0})}}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}parseInlineTokens(e){var t,n,r,o;const s=[];for(let i=0;i<e.length;i+=1){const a=e[i];if(a.type==="text")s.push({type:"text",text:P.decodeHtmlEntities(a.text||"")});else if(a.type==="html"){const l=((n=(t=a.raw)!=null?t:a.text)!=null?n:"").toString(),c=/^<\/[\s]*[\w-]+/i.test(l),u=l.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);if(!c&&u&&!/\/>$/.test(l)){const f=u[1],p=this.escapeRegex(f),m=new RegExp(`^<\\/\\s*${p}\\b`,"i");let g=-1;const b=[l];for(let x=i+1;x<e.length;x+=1){const S=e[x],k=((o=(r=S.raw)!=null?r:S.text)!=null?o:"").toString();if(b.push(k),S.type==="html"&&m.test(k)){g=x;break}}if(g!==-1){const x=b.join(""),S={type:"html",raw:x,text:x,block:!1},k=this.parseHTMLToken(S);if(k){const y=this.normalizeParseResult(k);Array.isArray(y)?s.push(...y):y&&s.push(y)}i=g;continue}}const d=this.parseHTMLToken(a);if(d){const f=this.normalizeParseResult(d);Array.isArray(f)?s.push(...f):f&&s.push(f)}}else if(a.type){const l=this.getHandlerForToken(a.type);if(l&&l.parseMarkdown){const c=this.createParseHelpers(),u=l.parseMarkdown(a,c);if(this.isMarkResult(u)){const d=this.applyMarkToContent(u.mark,u.content,u.attrs);s.push(...d)}else{const d=this.normalizeParseResult(u);Array.isArray(d)?s.push(...d):d&&s.push(d)}}else a.tokens&&s.push(...this.parseInlineTokens(a.tokens))}}return s}applyMarkToContent(e,t,n){return t.map(r=>{if(r.type==="text"){const o=r.marks||[],s=n?{type:e,attrs:n}:{type:e};return{...r,marks:[...o,s]}}return{...r,content:r.content?this.applyMarkToContent(e,r.content,n):void 0}})}isMarkResult(e){return e&&typeof e=="object"&&"mark"in e}normalizeParseResult(e){return e?this.isMarkResult(e)?e.content:e:null}parseFallbackToken(e,t=!1){switch(e.type){case"paragraph":return{type:"paragraph",content:e.tokens?this.parseInlineTokens(e.tokens):[]};case"heading":return{type:"heading",attrs:{level:e.depth||1},content:e.tokens?this.parseInlineTokens(e.tokens):[]};case"text":return{type:"text",text:P.decodeHtmlEntities(e.text||"")};case"html":return this.parseHTMLToken(e);case"space":return null;default:return e.tokens?this.parseTokens(e.tokens,t):null}}parseHTMLToken(e){const t=e.text||e.raw||"";if(!t.trim())return null;if(typeof window>"u")return e.block?{type:"paragraph",content:[{type:"text",text:t}]}:{type:"text",text:t};try{const n=P.generateJSON(t,this.baseExtensions);return n.type==="doc"&&n.content?e.block?n.content:n.content.length===1&&n.content[0].type==="paragraph"&&n.content[0].content?n.content[0].content:n.content:n}catch(n){throw new Error(`Failed to parse HTML in markdown: ${n}`)}}encodeTextForMarkdown(e,t,n){return n?.type!=null&&this.codeTypes.has(n.type)||(t.marks||[]).some(o=>this.codeTypes.has(typeof o=="string"?o:o.type))?e:P.encodeHtmlEntities(e)}renderNodeToMarkdown(e,t,n=0,r=0,o={}){var s;if(e.type==="text")return this.encodeTextForMarkdown(e.text||"",e,t);if(!e.type)return"";const i=this.getHandlerForToken(e.type);if(!i)return"";const a=Array.isArray(t?.content)&&n>0?t.content[n-1]:void 0,l={renderChildren:(d,f)=>{const p=i.isIndenting?r+1:r;return!Array.isArray(d)&&d.content?this.renderNodes(d.content,e,f||"",n,p):this.renderNodes(d,e,f||"",n,p)},renderChild:(d,f)=>{const p=i.isIndenting?r+1:r;return this.renderNodeToMarkdown(d,e,f,p)},indent:d=>this.indentString+d,wrapInBlock:bm},c={index:n,level:r,parentType:t?.type,previousNode:a,meta:{parentAttrs:t?.attrs,...o}};return((s=i.renderMarkdown)==null?void 0:s.call(i,e,l,c))||""}renderNodes(e,t,n="",r=0,o=0){return Array.isArray(e)?this.renderNodesWithMarkBoundaries(e,t,n,o):e.type?this.renderNodeToMarkdown(e,t,r,o):""}renderNodesWithMarkBoundaries(e,t,n="",r=0){const o=[],s=new Map,i=new Set,a=new Map;return e.forEach((l,c)=>{const u=c<e.length-1?e[c+1]:null;if(l.type)if(l.type==="text"){let d=this.encodeTextForMarkdown(l.text||"",l,t);const f=new Map((l.marks||[]).map(T=>[T.type,T])),p=this.getMarksToOpenForSerialization(s,f,u),m=ym(f,u),g=m.filter(T=>s.has(T)),b=g.length>0&&p.length>0;let x="";if(m.length>0&&!b){const T=d.match(/(\s+)$/);T&&(x=T[1],d=d.slice(0,-x.length))}b||m.slice().reverse().forEach(T=>{if(!s.has(T))return;const w=f.get(T),C=this.getMarkClosing(T,w,a.get(T));C&&(d+=C),s.has(T)&&(s.delete(T),a.delete(T))});let S="";if(p.length>0){const T=d.match(/^(\s+)/);T&&(S=T[1],d=d.slice(S.length))}p.forEach(({type:T,mark:w})=>{const C=i.has(T)?"html":"markdown",A=this.getMarkOpening(T,w,C);A&&(d=A+d),a.set(T,C),i.delete(T)}),b||p.slice().reverse().forEach(({type:T,mark:w})=>{s.set(T,w)}),d=S+d;let k;if(b){const T=new Set((u?.marks||[]).map(A=>A.type));p.forEach(({type:A})=>{T.has(A)&&this.getHtmlReopenTags(A)&&i.add(A)});const w=Array.from(s.keys()),C=g.slice().sort((A,I)=>w.indexOf(I)-w.indexOf(A));k=[...p.map(A=>A.type),...C]}else k=vm(s,f,u,this.markSetsEqual.bind(this));let y="";if(k.length>0){const T=d.match(/(\s+)$/);T&&(y=T[1],d=d.slice(0,-y.length))}k.forEach(T=>{var w;const C=(w=s.get(T))!=null?w:f.get(T),A=this.getMarkClosing(T,C,a.get(T));A&&(d+=A),s.delete(T),a.delete(T)}),d+=y,d+=x,o.push(d)}else{const d=new Map(s),f=new Map(a),p=wm(s,(b,x)=>this.getMarkClosing(b,x,a.get(b)));a.clear();const m=this.renderNodeToMarkdown(l,t,c,r),g=l.type==="hardBreak"?"":km(d,s,(b,x)=>{var S;const k=(S=f.get(b))!=null?S:"markdown";return a.set(b,k),this.getMarkOpening(b,x,k)});o.push(p+m+g)}}),o.join(n)}getMarkOpening(e,t,n="markdown"){var r;if(n==="html")return((r=this.getHtmlReopenTags(e))==null?void 0:r.open)||"";const o=this.getHandlersForNodeType(e),s=o.length>0?o[0]:void 0;if(!s||!s.renderMarkdown)return"";const i="__TIPTAP_MARKDOWN_PLACEHOLDER__",a={type:e,attrs:t.attrs||{},content:[{type:"text",text:i}]};try{const l=s.renderMarkdown(a,{renderChildren:()=>i,renderChild:()=>i,indent:u=>u,wrapInBlock:(u,d)=>u+d},{index:0,level:0,parentType:"text",meta:{}}),c=l.indexOf(i);return c>=0?l.substring(0,c):""}catch(l){throw new Error(`Failed to get mark opening for ${e}: ${l}`)}}getMarkClosing(e,t,n="markdown"){var r;if(n==="html")return((r=this.getHtmlReopenTags(e))==null?void 0:r.close)||"";const o=this.getHandlersForNodeType(e),s=o.length>0?o[0]:void 0;if(!s||!s.renderMarkdown)return"";const i="__TIPTAP_MARKDOWN_PLACEHOLDER__",a={type:e,attrs:t.attrs||{},content:[{type:"text",text:i}]};try{const l=s.renderMarkdown(a,{renderChildren:()=>i,renderChild:()=>i,indent:d=>d,wrapInBlock:(d,f)=>d+f},{index:0,level:0,parentType:"text",meta:{}}),c=l.indexOf(i),u=c+i.length;return c>=0?l.substring(u):""}catch(l){throw new Error(`Failed to get mark closing for ${e}: ${l}`)}}getHtmlReopenTags(e){const t=this.getHandlersForNodeType(e),n=t.length>0?t[0]:void 0;return n?.htmlReopen}markSetsEqual(e,t){return e.size!==t.size?!1:Array.from(e.keys()).every(n=>t.has(n))}getMarksToOpenForSerialization(e,t,n){const r=xm(e,t);if(r.length<=1)return r;const o=new Set((n?.marks||[]).map(l=>l.type)),s=(l,c)=>{var u,d;const f=(u=this.extensionRanks.get(l.type))!=null?u:Number.MAX_SAFE_INTEGER,p=(d=this.extensionRanks.get(c.type))!=null?d:Number.MAX_SAFE_INTEGER;return f!==p?p-f:l.type.localeCompare(c.type)},i=r.filter(l=>!o.has(l.type)).sort(s),a=r.filter(l=>o.has(l.type)).sort(s);return[...i,...a]}},cl=Cm,Sm=P.Extension.create({name:"markdown",addOptions(){return{indentation:{style:"space",size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(e,t)=>{if(!t?.contentType||so(e,t?.contentType)!=="markdown"||!this.editor.markdown)return P.commands.setContent(e,t);const r=this.editor.markdown.parse(e);return P.commands.setContent(r,t)},insertContent:(e,t)=>{if(!t?.contentType||so(e,t?.contentType)!=="markdown"||!this.editor.markdown)return P.commands.insertContent(e,t);const r=this.editor.markdown.parse(e);return P.commands.insertContent(r,t)},insertContentAt:(e,t,n)=>{if(!n?.contentType||so(t,n?.contentType)!=="markdown"||!this.editor.markdown)return P.commands.insertContentAt(e,t,n);const o=this.editor.markdown.parse(t);return P.commands.insertContentAt(e,o,n)}}},addStorage(){return{manager:new cl({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate(){var e;if(this.editor.markdown){console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");return}if(this.storage.manager=new cl({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions}),this.editor.markdown=this.storage.manager,this.editor.getMarkdown=()=>this.storage.manager.serialize(this.editor.getJSON()),!this.editor.options.contentType||so(this.editor.options.content,this.editor.options.contentType)!=="markdown")return;if(!this.editor.markdown)throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.');if(this.editor.options.content===void 0||typeof this.editor.options.content!="string")throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.');const n=this.editor.markdown.parse(this.editor.options.content);(e=n.content)!=null&&e.length&&(this.editor.options.content=n)}}),io=" ",Ms=" ",Tm=P.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",P.mergeAttributes(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{const n=e.tokens||[];if(n.length===1&&n[0].type==="image")return t.parseChildren([n[0]]);const r=t.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===io||n[0].text===io||n[0].raw===Ms||n[0].text===Ms)&&r.length===1&&r[0].type==="text"&&(r[0].text===io||r[0].text===Ms)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(e,t,n)=>{var r,o;if(!e)return"";const s=Array.isArray(e.content)?e.content:[];if(s.length===0){const i=Array.isArray((r=n?.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((o=n?.previousNode)==null?void 0:o.type)==="paragraph"&&i.length===0?io:""}return t.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Am=e=>P.textInputRule({find:/--$/,replace:e??"—"}),Em=e=>P.textInputRule({find:/\.\.\.$/,replace:e??"…"}),Rs=e=>P.textInputRule({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:e??"“"}),Ns=e=>P.textInputRule({find:/"$/,replace:e??"”"}),Os=e=>P.textInputRule({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:e??"‘"}),Is=e=>P.textInputRule({find:/'$/,replace:e??"’"}),Mm=e=>P.textInputRule({find:/<-$/,replace:e??"←"}),Rm=e=>P.textInputRule({find:/->$/,replace:e??"→"}),Nm=e=>P.textInputRule({find:/\(c\)$/,replace:e??"©"}),Om=e=>P.textInputRule({find:/\(tm\)$/,replace:e??"™"}),Im=e=>P.textInputRule({find:/\(sm\)$/,replace:e??"℠"}),Pm=e=>P.textInputRule({find:/\(r\)$/,replace:e??"®"}),Lm=e=>P.textInputRule({find:/(?:^|\s)(1\/2)\s$/,replace:e??"½"}),Dm=e=>P.textInputRule({find:/\+\/-$/,replace:e??"±"}),jm=e=>P.textInputRule({find:/!=$/,replace:e??"≠"}),zm=e=>P.textInputRule({find:/<<$/,replace:e??"«"}),_m=e=>P.textInputRule({find:/>>$/,replace:e??"»"}),$m=e=>P.textInputRule({find:/\d+\s?([*x])\s?\d+$/,replace:e??"×"}),Fm=e=>P.textInputRule({find:/\^2$/,replace:e??"²"}),Bm=e=>P.textInputRule({find:/\^3$/,replace:e??"³"}),Hm=e=>P.textInputRule({find:/(?:^|\s)(1\/4)\s$/,replace:e??"¼"}),Wm=e=>P.textInputRule({find:/(?:^|\s)(3\/4)\s$/,replace:e??"¾"}),Vm=P.Extension.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){var e,t;const n=[];this.options.emDash!==!1&&n.push(Am(this.options.emDash)),this.options.ellipsis!==!1&&n.push(Em(this.options.ellipsis));const r=this.editor.options.textDirection==="rtl";if((e=this.options.doubleQuotes)!=null&&e.rtl){const{open:o,close:s}=this.options.doubleQuotes.rtl;n.push(Rs(o)),n.push(Ns(s))}else r?(n.push(Rs("”")),n.push(Ns("“"))):(this.options.openDoubleQuote!==!1&&n.push(Rs(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&n.push(Ns(this.options.closeDoubleQuote)));if((t=this.options.singleQuotes)!=null&&t.rtl){const{open:o,close:s}=this.options.singleQuotes.rtl;n.push(Os(o)),n.push(Is(s))}else r?(n.push(Os("’")),n.push(Is("‘"))):(this.options.openSingleQuote!==!1&&n.push(Os(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&n.push(Is(this.options.closeSingleQuote)));return this.options.leftArrow!==!1&&n.push(Mm(this.options.leftArrow)),this.options.rightArrow!==!1&&n.push(Rm(this.options.rightArrow)),this.options.copyright!==!1&&n.push(Nm(this.options.copyright)),this.options.trademark!==!1&&n.push(Om(this.options.trademark)),this.options.servicemark!==!1&&n.push(Im(this.options.servicemark)),this.options.registeredTrademark!==!1&&n.push(Pm(this.options.registeredTrademark)),this.options.oneHalf!==!1&&n.push(Lm(this.options.oneHalf)),this.options.plusMinus!==!1&&n.push(Dm(this.options.plusMinus)),this.options.notEqual!==!1&&n.push(jm(this.options.notEqual)),this.options.laquo!==!1&&n.push(zm(this.options.laquo)),this.options.raquo!==!1&&n.push(_m(this.options.raquo)),this.options.multiplication!==!1&&n.push($m(this.options.multiplication)),this.options.superscriptTwo!==!1&&n.push(Fm(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&n.push(Bm(this.options.superscriptThree)),this.options.oneQuarter!==!1&&n.push(Hm(this.options.oneQuarter)),this.options.threeQuarters!==!1&&n.push(Wm(this.options.threeQuarters)),n}}),qm=Vm,Km=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Um=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Gm=P.Mark.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||P.getStyleProperty(e,"background-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",P.mergeAttributes(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark("highlight",t.parseInline(e.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:e=>e.indexOf("=="),tokenize(e,t,n){const o=/^(==)([^=]+)(==)/.exec(e);if(o){const s=o[2].trim(),i=n.inlineTokens(s);return{type:"highlight",raw:o[0],text:s,tokens:i}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[P.markInputRule({find:Km,type:this.type})]},addPasteRules(){return[P.markPasteRule({find:Um,type:this.type})]}}),Xm=Gm,Jm=P.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return e!=="super"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sup",P.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),Ym=Jm,Qm=P.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return e!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sub",P.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Zm=Qm,eg=Object.defineProperty,tg=(e,t)=>{for(var n in t)eg(e,n,{get:t[n],enumerable:!0})},ng="listItem",ul="textStyle",dl=/^\s*([-+*])\s$/,rg=P.Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",P.mergeAttributes(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>e.type!=="list"||e.ordered?[]:{type:"bulletList",content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
67
|
-
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
64
|
+
`).trim()){const y=g.slice(1),A=y.filter(w=>w.trim());if(A.length>0){const w=Math.min(...A.map(I=>I.length-I.trimStart().length)),T=y.map(I=>I.trim()?I.slice(w):"").join(`
|
|
65
|
+
`).trim();T&&(S=this.markedInstance.lexer(`${T}
|
|
66
|
+
`))}}f={type:"taskItem",raw:"",mainContent:x,indentLevel:d,checked:u??!1,text:x,tokens:this.tokenizeInline(x),nestedTokens:S}}const p=c?"taskList":"list";s!==p?(o.length>0&&r.push({type:s,items:o}),o=[f],s=p):o.push(f)}o.length>0&&r.push({type:s,items:o});const i=[];for(let a=0;a<r.length;a+=1){const l=r[a],c={...e,type:l.type,items:l.items},u=this.parseToken(c);u&&(Array.isArray(u)?i.push(...u):i.push(u))}return i.length>0?i:null}parseTokenWithHandlers(e){if(!e.type)return null;const t=this.getHandlersForToken(e.type),n=this.createParseHelpers();if(t.find(o=>{if(!o.parseMarkdown)return!1;const s=o.parseMarkdown(e,n),i=this.normalizeParseResult(s);return i&&(!Array.isArray(i)||i.length>0)?(this.lastParseResult=i,!0):!1})&&this.lastParseResult){const o=this.lastParseResult;return this.lastParseResult=null,o}return this.parseFallbackToken(e)}createParseHelpers(){return{parseInline:e=>this.parseInlineTokens(e),tokenizeInline:e=>this.tokenizeInline(e),parseChildren:e=>this.parseTokens(e),parseBlockChildren:e=>this.parseTokens(e,!0),createTextNode:(e,t)=>({type:"text",text:e,marks:t||void 0}),createNode:(e,t,n)=>{const r={type:e,attrs:t||void 0,content:n||void 0};return(!t||Object.keys(t).length===0)&&delete r.attrs,r},applyMark:(e,t,n)=>({mark:e,content:t,attrs:n&&Object.keys(n).length>0?n:void 0})}}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}parseInlineTokens(e){var t,n,r,o;const s=[];for(let i=0;i<e.length;i+=1){const a=e[i];if(a.type==="text")s.push({type:"text",text:P.decodeHtmlEntities(a.text||"")});else if(a.type==="html"){const l=((n=(t=a.raw)!=null?t:a.text)!=null?n:"").toString(),c=/^<\/[\s]*[\w-]+/i.test(l),u=l.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);if(!c&&u&&!/\/>$/.test(l)){const f=u[1],p=this.escapeRegex(f),m=new RegExp(`^<\\/\\s*${p}\\b`,"i");let g=-1;const b=[l];for(let x=i+1;x<e.length;x+=1){const S=e[x],k=((o=(r=S.raw)!=null?r:S.text)!=null?o:"").toString();if(b.push(k),S.type==="html"&&m.test(k)){g=x;break}}if(g!==-1){const x=b.join(""),S={type:"html",raw:x,text:x,block:!1},k=this.parseHTMLToken(S);if(k){const y=this.normalizeParseResult(k);Array.isArray(y)?s.push(...y):y&&s.push(y)}i=g;continue}}const d=this.parseHTMLToken(a);if(d){const f=this.normalizeParseResult(d);Array.isArray(f)?s.push(...f):f&&s.push(f)}}else if(a.type){const l=this.getHandlerForToken(a.type);if(l&&l.parseMarkdown){const c=this.createParseHelpers(),u=l.parseMarkdown(a,c);if(this.isMarkResult(u)){const d=this.applyMarkToContent(u.mark,u.content,u.attrs);s.push(...d)}else{const d=this.normalizeParseResult(u);Array.isArray(d)?s.push(...d):d&&s.push(d)}}else a.tokens&&s.push(...this.parseInlineTokens(a.tokens))}}return s}applyMarkToContent(e,t,n){return t.map(r=>{if(r.type==="text"){const o=r.marks||[],s=n?{type:e,attrs:n}:{type:e};return{...r,marks:[...o,s]}}return{...r,content:r.content?this.applyMarkToContent(e,r.content,n):void 0}})}isMarkResult(e){return e&&typeof e=="object"&&"mark"in e}normalizeParseResult(e){return e?this.isMarkResult(e)?e.content:e:null}parseFallbackToken(e,t=!1){switch(e.type){case"paragraph":return{type:"paragraph",content:e.tokens?this.parseInlineTokens(e.tokens):[]};case"heading":return{type:"heading",attrs:{level:e.depth||1},content:e.tokens?this.parseInlineTokens(e.tokens):[]};case"text":return{type:"text",text:P.decodeHtmlEntities(e.text||"")};case"html":return this.parseHTMLToken(e);case"space":return null;default:return e.tokens?this.parseTokens(e.tokens,t):null}}parseHTMLToken(e){const t=e.text||e.raw||"";if(!t.trim())return null;if(typeof window>"u")return e.block?{type:"paragraph",content:[{type:"text",text:t}]}:{type:"text",text:t};try{const n=P.generateJSON(t,this.baseExtensions);return n.type==="doc"&&n.content?e.block?n.content:n.content.length===1&&n.content[0].type==="paragraph"&&n.content[0].content?n.content[0].content:n.content:n}catch(n){throw new Error(`Failed to parse HTML in markdown: ${n}`)}}encodeTextForMarkdown(e,t,n){return n?.type!=null&&this.codeTypes.has(n.type)||(t.marks||[]).some(o=>this.codeTypes.has(typeof o=="string"?o:o.type))?e:P.encodeHtmlEntities(e)}renderNodeToMarkdown(e,t,n=0,r=0,o={}){var s;if(e.type==="text")return this.encodeTextForMarkdown(e.text||"",e,t);if(!e.type)return"";const i=this.getHandlerForToken(e.type);if(!i)return"";const a=Array.isArray(t?.content)&&n>0?t.content[n-1]:void 0,l={renderChildren:(d,f)=>{const p=i.isIndenting?r+1:r;return!Array.isArray(d)&&d.content?this.renderNodes(d.content,e,f||"",n,p):this.renderNodes(d,e,f||"",n,p)},renderChild:(d,f)=>{const p=i.isIndenting?r+1:r;return this.renderNodeToMarkdown(d,e,f,p)},indent:d=>this.indentString+d,wrapInBlock:xm},c={index:n,level:r,parentType:t?.type,previousNode:a,meta:{parentAttrs:t?.attrs,...o}};return((s=i.renderMarkdown)==null?void 0:s.call(i,e,l,c))||""}renderNodes(e,t,n="",r=0,o=0){return Array.isArray(e)?this.renderNodesWithMarkBoundaries(e,t,n,o):e.type?this.renderNodeToMarkdown(e,t,r,o):""}renderNodesWithMarkBoundaries(e,t,n="",r=0){const o=[],s=new Map,i=new Set,a=new Map;return e.forEach((l,c)=>{const u=c<e.length-1?e[c+1]:null;if(l.type)if(l.type==="text"){let d=this.encodeTextForMarkdown(l.text||"",l,t);const f=new Map((l.marks||[]).map(A=>[A.type,A])),p=this.getMarksToOpenForSerialization(s,f,u),m=vm(f,u),g=m.filter(A=>s.has(A)),b=g.length>0&&p.length>0;let x="";if(m.length>0&&!b){const A=d.match(/(\s+)$/);A&&(x=A[1],d=d.slice(0,-x.length))}b||m.slice().reverse().forEach(A=>{if(!s.has(A))return;const w=f.get(A),C=this.getMarkClosing(A,w,a.get(A));C&&(d+=C),s.has(A)&&(s.delete(A),a.delete(A))});let S="";if(p.length>0){const A=d.match(/^(\s+)/);A&&(S=A[1],d=d.slice(S.length))}p.forEach(({type:A,mark:w})=>{const C=i.has(A)?"html":"markdown",T=this.getMarkOpening(A,w,C);T&&(d=T+d),a.set(A,C),i.delete(A)}),b||p.slice().reverse().forEach(({type:A,mark:w})=>{s.set(A,w)}),d=S+d;let k;if(b){const A=new Set((u?.marks||[]).map(T=>T.type));p.forEach(({type:T})=>{A.has(T)&&this.getHtmlReopenTags(T)&&i.add(T)});const w=Array.from(s.keys()),C=g.slice().sort((T,I)=>w.indexOf(I)-w.indexOf(T));k=[...p.map(T=>T.type),...C]}else k=km(s,f,u,this.markSetsEqual.bind(this));let y="";if(k.length>0){const A=d.match(/(\s+)$/);A&&(y=A[1],d=d.slice(0,-y.length))}k.forEach(A=>{var w;const C=(w=s.get(A))!=null?w:f.get(A),T=this.getMarkClosing(A,C,a.get(A));T&&(d+=T),s.delete(A),a.delete(A)}),d+=y,d+=x,o.push(d)}else{const d=new Map(s),f=new Map(a),p=Cm(s,(b,x)=>this.getMarkClosing(b,x,a.get(b)));a.clear();const m=this.renderNodeToMarkdown(l,t,c,r),g=l.type==="hardBreak"?"":Sm(d,s,(b,x)=>{var S;const k=(S=f.get(b))!=null?S:"markdown";return a.set(b,k),this.getMarkOpening(b,x,k)});o.push(p+m+g)}}),o.join(n)}getMarkOpening(e,t,n="markdown"){var r;if(n==="html")return((r=this.getHtmlReopenTags(e))==null?void 0:r.open)||"";const o=this.getHandlersForNodeType(e),s=o.length>0?o[0]:void 0;if(!s||!s.renderMarkdown)return"";const i="__TIPTAP_MARKDOWN_PLACEHOLDER__",a={type:e,attrs:t.attrs||{},content:[{type:"text",text:i}]};try{const l=s.renderMarkdown(a,{renderChildren:()=>i,renderChild:()=>i,indent:u=>u,wrapInBlock:(u,d)=>u+d},{index:0,level:0,parentType:"text",meta:{}}),c=l.indexOf(i);return c>=0?l.substring(0,c):""}catch(l){throw new Error(`Failed to get mark opening for ${e}: ${l}`)}}getMarkClosing(e,t,n="markdown"){var r;if(n==="html")return((r=this.getHtmlReopenTags(e))==null?void 0:r.close)||"";const o=this.getHandlersForNodeType(e),s=o.length>0?o[0]:void 0;if(!s||!s.renderMarkdown)return"";const i="__TIPTAP_MARKDOWN_PLACEHOLDER__",a={type:e,attrs:t.attrs||{},content:[{type:"text",text:i}]};try{const l=s.renderMarkdown(a,{renderChildren:()=>i,renderChild:()=>i,indent:d=>d,wrapInBlock:(d,f)=>d+f},{index:0,level:0,parentType:"text",meta:{}}),c=l.indexOf(i),u=c+i.length;return c>=0?l.substring(u):""}catch(l){throw new Error(`Failed to get mark closing for ${e}: ${l}`)}}getHtmlReopenTags(e){const t=this.getHandlersForNodeType(e),n=t.length>0?t[0]:void 0;return n?.htmlReopen}markSetsEqual(e,t){return e.size!==t.size?!1:Array.from(e.keys()).every(n=>t.has(n))}getMarksToOpenForSerialization(e,t,n){const r=wm(e,t);if(r.length<=1)return r;const o=new Set((n?.marks||[]).map(l=>l.type)),s=(l,c)=>{var u,d;const f=(u=this.extensionRanks.get(l.type))!=null?u:Number.MAX_SAFE_INTEGER,p=(d=this.extensionRanks.get(c.type))!=null?d:Number.MAX_SAFE_INTEGER;return f!==p?p-f:l.type.localeCompare(c.type)},i=r.filter(l=>!o.has(l.type)).sort(s),a=r.filter(l=>o.has(l.type)).sort(s);return[...i,...a]}},dl=Tm,Am=P.Extension.create({name:"markdown",addOptions(){return{indentation:{style:"space",size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(e,t)=>{if(!t?.contentType||io(e,t?.contentType)!=="markdown"||!this.editor.markdown)return P.commands.setContent(e,t);const r=this.editor.markdown.parse(e);return P.commands.setContent(r,t)},insertContent:(e,t)=>{if(!t?.contentType||io(e,t?.contentType)!=="markdown"||!this.editor.markdown)return P.commands.insertContent(e,t);const r=this.editor.markdown.parse(e);return P.commands.insertContent(r,t)},insertContentAt:(e,t,n)=>{if(!n?.contentType||io(t,n?.contentType)!=="markdown"||!this.editor.markdown)return P.commands.insertContentAt(e,t,n);const o=this.editor.markdown.parse(t);return P.commands.insertContentAt(e,o,n)}}},addStorage(){return{manager:new dl({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate(){var e;if(this.editor.markdown){console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");return}if(this.storage.manager=new dl({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions}),this.editor.markdown=this.storage.manager,this.editor.getMarkdown=()=>this.storage.manager.serialize(this.editor.getJSON()),!this.editor.options.contentType||io(this.editor.options.content,this.editor.options.contentType)!=="markdown")return;if(!this.editor.markdown)throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.');if(this.editor.options.content===void 0||typeof this.editor.options.content!="string")throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.');const n=this.editor.markdown.parse(this.editor.options.content);(e=n.content)!=null&&e.length&&(this.editor.options.content=n)}}),ao=" ",Ns=" ",Em=P.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",P.mergeAttributes(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{const n=e.tokens||[];if(n.length===1&&n[0].type==="image")return t.parseChildren([n[0]]);const r=t.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===ao||n[0].text===ao||n[0].raw===Ns||n[0].text===Ns)&&r.length===1&&r[0].type==="text"&&(r[0].text===ao||r[0].text===Ns)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(e,t,n)=>{var r,o;if(!e)return"";const s=Array.isArray(e.content)?e.content:[];if(s.length===0){const i=Array.isArray((r=n?.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((o=n?.previousNode)==null?void 0:o.type)==="paragraph"&&i.length===0?ao:""}return t.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Mm=e=>P.textInputRule({find:/--$/,replace:e??"—"}),Rm=e=>P.textInputRule({find:/\.\.\.$/,replace:e??"…"}),Os=e=>P.textInputRule({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:e??"“"}),Is=e=>P.textInputRule({find:/"$/,replace:e??"”"}),Ps=e=>P.textInputRule({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:e??"‘"}),Ls=e=>P.textInputRule({find:/'$/,replace:e??"’"}),Nm=e=>P.textInputRule({find:/<-$/,replace:e??"←"}),Om=e=>P.textInputRule({find:/->$/,replace:e??"→"}),Im=e=>P.textInputRule({find:/\(c\)$/,replace:e??"©"}),Pm=e=>P.textInputRule({find:/\(tm\)$/,replace:e??"™"}),Lm=e=>P.textInputRule({find:/\(sm\)$/,replace:e??"℠"}),Dm=e=>P.textInputRule({find:/\(r\)$/,replace:e??"®"}),jm=e=>P.textInputRule({find:/(?:^|\s)(1\/2)\s$/,replace:e??"½"}),zm=e=>P.textInputRule({find:/\+\/-$/,replace:e??"±"}),_m=e=>P.textInputRule({find:/!=$/,replace:e??"≠"}),$m=e=>P.textInputRule({find:/<<$/,replace:e??"«"}),Fm=e=>P.textInputRule({find:/>>$/,replace:e??"»"}),Bm=e=>P.textInputRule({find:/\d+\s?([*x])\s?\d+$/,replace:e??"×"}),Hm=e=>P.textInputRule({find:/\^2$/,replace:e??"²"}),Wm=e=>P.textInputRule({find:/\^3$/,replace:e??"³"}),Vm=e=>P.textInputRule({find:/(?:^|\s)(1\/4)\s$/,replace:e??"¼"}),qm=e=>P.textInputRule({find:/(?:^|\s)(3\/4)\s$/,replace:e??"¾"}),Km=P.Extension.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){var e,t;const n=[];this.options.emDash!==!1&&n.push(Mm(this.options.emDash)),this.options.ellipsis!==!1&&n.push(Rm(this.options.ellipsis));const r=this.editor.options.textDirection==="rtl";if((e=this.options.doubleQuotes)!=null&&e.rtl){const{open:o,close:s}=this.options.doubleQuotes.rtl;n.push(Os(o)),n.push(Is(s))}else r?(n.push(Os("”")),n.push(Is("“"))):(this.options.openDoubleQuote!==!1&&n.push(Os(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&n.push(Is(this.options.closeDoubleQuote)));if((t=this.options.singleQuotes)!=null&&t.rtl){const{open:o,close:s}=this.options.singleQuotes.rtl;n.push(Ps(o)),n.push(Ls(s))}else r?(n.push(Ps("’")),n.push(Ls("‘"))):(this.options.openSingleQuote!==!1&&n.push(Ps(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&n.push(Ls(this.options.closeSingleQuote)));return this.options.leftArrow!==!1&&n.push(Nm(this.options.leftArrow)),this.options.rightArrow!==!1&&n.push(Om(this.options.rightArrow)),this.options.copyright!==!1&&n.push(Im(this.options.copyright)),this.options.trademark!==!1&&n.push(Pm(this.options.trademark)),this.options.servicemark!==!1&&n.push(Lm(this.options.servicemark)),this.options.registeredTrademark!==!1&&n.push(Dm(this.options.registeredTrademark)),this.options.oneHalf!==!1&&n.push(jm(this.options.oneHalf)),this.options.plusMinus!==!1&&n.push(zm(this.options.plusMinus)),this.options.notEqual!==!1&&n.push(_m(this.options.notEqual)),this.options.laquo!==!1&&n.push($m(this.options.laquo)),this.options.raquo!==!1&&n.push(Fm(this.options.raquo)),this.options.multiplication!==!1&&n.push(Bm(this.options.multiplication)),this.options.superscriptTwo!==!1&&n.push(Hm(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&n.push(Wm(this.options.superscriptThree)),this.options.oneQuarter!==!1&&n.push(Vm(this.options.oneQuarter)),this.options.threeQuarters!==!1&&n.push(qm(this.options.threeQuarters)),n}}),Um=Km,Gm=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Xm=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Jm=P.Mark.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||P.getStyleProperty(e,"background-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",P.mergeAttributes(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark("highlight",t.parseInline(e.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:e=>e.indexOf("=="),tokenize(e,t,n){const o=/^(==)([^=]+)(==)/.exec(e);if(o){const s=o[2].trim(),i=n.inlineTokens(s);return{type:"highlight",raw:o[0],text:s,tokens:i}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[P.markInputRule({find:Gm,type:this.type})]},addPasteRules(){return[P.markPasteRule({find:Xm,type:this.type})]}}),Ym=Jm,Qm=P.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return e!=="super"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sup",P.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),Zm=Qm,eg=P.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return e!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sub",P.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),tg=eg,ng=Object.defineProperty,rg=(e,t)=>{for(var n in t)ng(e,n,{get:t[n],enumerable:!0})},og="listItem",fl="textStyle",pl=/^\s*([-+*])\s$/,sg=P.Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",P.mergeAttributes(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>e.type!=="list"||e.ordered?[]:{type:"bulletList",content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
67
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(og,this.editor.getAttributes(fl)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=P.wrappingInputRule({find:pl,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=P.wrappingInputRule({find:pl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(fl),editor:this.editor})),[e]}});function ig(e){var t,n;const r=(t=e.tokens)==null?void 0:t[0];return!!(e.text&&((n=e.tokens)==null?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===e.text)}function ag(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:"text",raw:e,text:e}])}var lg=P.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",P.mergeAttributes(this.options.HTMLAttributes,e),0]},markdownTokenName:"list_item",parseMarkdown:(e,t)=>{var n;if(e.type!=="list_item")return[];const r=(n=t.parseBlockChildren)!=null?n:t.parseChildren;let o=[];if(e.tokens&&e.tokens.length>0){if(ig(e))return{type:"listItem",content:[{type:"paragraph",content:ag(e.text||"",t)}]};if(e.tokens.some(i=>i.type==="paragraph"))o=r(e.tokens);else{const i=e.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(o=[{type:"paragraph",content:t.parseInline(i.tokens)}],e.tokens.length>1){const l=e.tokens.slice(1),c=r(l);o.push(...c)}}else o=r(e.tokens)}}return o.length===0&&(o=[{type:"paragraph",content:[]}]),{type:"listItem",content:o}},renderMarkdown:(e,t,n)=>P.renderNestedMarkdownContent(e,t,r=>{var o,s;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((s=(o=r.meta)==null?void 0:o.parentAttrs)==null?void 0:s.start)||1)+r.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),cg={};rg(cg,{findListItemPos:()=>Fr,getNextListDepth:()=>ca,handleBackspace:()=>yi,handleDelete:()=>xi,hasListBefore:()=>gu,hasListItemAfter:()=>ug,hasListItemBefore:()=>bu,listItemHasSubList:()=>yu,nextListIsDeeper:()=>xu,nextListIsHigher:()=>vu});var Fr=(e,t)=>{const{$from:n}=t.selection,r=P.getNodeType(e,t.schema);let o=null,s=n.depth,i=n.pos,a=null;for(;s>0&&a===null;)o=n.node(s),o.type===r?a=s:(s-=1,i-=1);return a===null?null:{$pos:t.doc.resolve(i),depth:a}},ca=(e,t)=>{const n=Fr(e,t);if(!n)return!1;const[,r]=P.getNodeAtPosition(t,e,n.$pos.pos+4);return r},gu=(e,t,n)=>{const{$anchor:r}=e.selection,o=Math.max(0,r.pos-2),s=e.doc.resolve(o).node();return!(!s||!n.includes(s.type.name))},bu=(e,t)=>{var n;const{$anchor:r}=t.selection,o=t.doc.resolve(r.pos-2);return!(o.index()===0||((n=o.nodeBefore)==null?void 0:n.type.name)!==e)},yu=(e,t,n)=>{if(!n)return!1;const r=P.getNodeType(e,t.schema);let o=!1;return n.descendants(s=>{s.type===r&&(o=!0)}),o},yi=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!P.isNodeActive(e.state,t)&&gu(e.state,t,n)){const{$anchor:a}=e.state.selection,l=e.state.doc.resolve(a.before()-1),c=[];l.node().descendants((f,p)=>{f.type.name===t&&c.push({node:f,pos:p})});const u=c.at(-1);if(!u)return!1;const d=e.state.doc.resolve(l.start()+u.pos+1);return e.chain().cut({from:a.start()-1,to:a.end()+1},d.end()).joinForward().run()}if(!P.isNodeActive(e.state,t)||!P.isAtStartOfNode(e.state))return!1;const r=Fr(t,e.state);if(!r)return!1;const s=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=yu(t,e.state,s);return bu(t,e.state)&&!i?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},xu=(e,t)=>{const n=ca(e,t),r=Fr(e,t);return!r||!n?!1:n>r.depth},vu=(e,t)=>{const n=ca(e,t),r=Fr(e,t);return!r||!n?!1:n<r.depth},xi=(e,t)=>{if(!P.isNodeActive(e.state,t)||!P.isAtEndOfNode(e.state,t))return!1;const{selection:n}=e.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:xu(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():vu(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},ug=(e,t)=>{var n;const{$anchor:r}=t.selection,o=t.doc.resolve(r.pos-r.parentOffset-2);return!(o.index()===o.parent.childCount-1||((n=o.nodeAfter)==null?void 0:n.type.name)!==e)},dg=P.Extension.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&xi(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&xi(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&yi(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&yi(e,n,r)&&(t=!0)}),t}}}}),hl=/^(\s*)(\d+)\.\s+(.*)$/,fg=/^\s/;function pg(e){const t=e.trimStart();return/^[-+*]\s+/.test(t)||/^\d+\.\s+/.test(t)||/^>\s?/.test(t)||/^```/.test(t)||/^~~~/.test(t)}function hg(e){const t=[],n=[];let r=!1;return e.forEach(o=>{if(r){n.push(o);return}if(o.trim()===""){r=!0,n.push(o);return}if(t.length>0&&pg(o)){r=!0,n.push(o);return}t.push(o)}),{paragraphLines:t,blockLines:n}}function mg(e){const t=[];let n=0,r=0;for(;n<e.length;){const o=e[n],s=o.match(hl);if(!s)break;const[,i,a,l]=s,c=i.length,u=[l];let d=n+1;const f=[o];let p=!1;for(;d<e.length;){const m=e[d];if(m.match(hl))break;if(m.trim()==="")f.push(m),u.push(""),p=!0,d+=1;else if(m.match(fg))f.push(m),u.push(m.slice(c+2)),d+=1;else{if(p)break;f.push(m),u.push(m),d+=1}}t.push({indent:c,number:parseInt(a,10),content:u.join(`
|
|
68
68
|
`).trim(),contentLines:u,raw:f.join(`
|
|
69
|
-
`)}),r=d,n=d}return[t,r]}function
|
|
69
|
+
`)}),r=d,n=d}return[t,r]}function wu(e,t,n){const r=[];let o=0;for(;o<e.length;){const s=e[o];if(s.indent===t){const{paragraphLines:i,blockLines:a}=hg(s.contentLines),l=i.join(`
|
|
70
70
|
`).trim(),c=[];l&&c.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const u=a.join(`
|
|
71
|
-
`).trim();if(u){const p=n.blockTokens(u);c.push(...p)}let d=o+1;const f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){const p=Math.min(...f.map(g=>g.indent)),m=
|
|
72
|
-
`)})}r.push({type:"list_item",raw:s.raw,tokens:c}),o=d}else o+=1}return r}function
|
|
71
|
+
`).trim();if(u){const p=n.blockTokens(u);c.push(...p)}let d=o+1;const f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){const p=Math.min(...f.map(g=>g.indent)),m=wu(f,p,n);c.push({type:"list",ordered:!0,start:f[0].number,items:m,raw:f.map(g=>g.raw).join(`
|
|
72
|
+
`)})}r.push({type:"list_item",raw:s.raw,tokens:c}),o=d}else o+=1}return r}function gg(e,t){return e.map(n=>{if(n.type!=="list_item")return t.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...t.parseChildren([o]));else if(o.type==="text"&&o.tokens){const s=t.parseChildren([o]);r.push({type:"paragraph",content:s})}else{const s=t.parseChildren([o]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var bg="listItem",ml="textStyle",gl=/^(\d+)\.\s$/,yg=P.Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",P.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",P.mergeAttributes(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>{if(e.type!=="list"||!e.ordered)return[];const n=e.start||1,r=e.items?gg(e.items,t):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
73
73
|
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:e=>{const t=e.match(/^(\s*)(\d+)\.\s+/),n=t?.index;return n!==void 0?n:-1},tokenize:(e,t,n)=>{var r;const o=e.split(`
|
|
74
|
-
`),[s,i]=
|
|
75
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
76
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;const n=(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:t.index;return n!==void 0?n:-1},tokenize(e,t,n){const r=s=>{const i=P.parseIndentedBlocks(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},n);return i?[{type:"taskList",raw:i.raw,items:i.items}]:n.blockTokens(s)},o=P.parseIndentedBlocks(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,i)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:i}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});P.Extension.create({name:"listKit",addExtensions(){const e=[];return this.options.bulletList!==!1&&e.push(rg.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(ig.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(cg.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(gg.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(vu.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(wu.configure(this.options.taskList)),e}});function ku(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(r),s=t.child(r);if(o==s){n+=o.nodeSize;continue}if(!o.sameMarkup(s))return n;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)n++;return n}if(o.content.size||s.content.size){let i=ku(o.content,s.content,n+1);if(i!=null)return i}n+=o.nodeSize}}function Cu(e,t,n,r){for(let o=e.childCount,s=t.childCount;;){if(o==0||s==0)return o==s?null:{a:n,b:r};let i=e.child(--o),a=t.child(--s),l=i.nodeSize;if(i==a){n-=l,r-=l;continue}if(!i.sameMarkup(a))return{a:n,b:r};if(i.isText&&i.text!=a.text){let c=0,u=Math.min(i.text.length,a.text.length);for(;c<u&&i.text[i.text.length-c-1]==a.text[a.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(i.content.size||a.content.size){let c=Cu(i.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class X{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,n,r,o=0,s){for(let i=0,a=0;a<n;i++){let l=this.content[i],c=a+l.nodeSize;if(c>t&&r(l,o+a,s||null,i)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,t-u),Math.min(l.content.size,n-u),r,o+u)}a=c}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,r,o){let s="",i=!0;return this.nodesBetween(t,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(t,l)-l,n-l):a.isLeaf?o?typeof o=="function"?o(a):o:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,o=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),s=1);s<t.content.length;s++)o.push(t.content[s]);return new X(o,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],o=0;if(n>t)for(let s=0,i=0;i<n;s++){let a=this.content[s],l=i+a.nodeSize;l>t&&((i<t||l>n)&&(a.isText?a=a.cut(Math.max(0,t-i),Math.min(a.text.length,n-i)):a=a.cut(Math.max(0,t-i-1),Math.min(a.content.size,n-i-1))),r.push(a),o+=a.nodeSize),i=l}return new X(r,o)}cutByIndex(t,n){return t==n?X.empty:t==0&&n==this.content.length?this:new X(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let o=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return o[t]=n,new X(o,s)}addToStart(t){return new X([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new X(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,r=0;n<this.content.length;n++){let o=this.content[n];t(o,r,n),r+=o.nodeSize}}findDiffStart(t,n=0){return ku(this,t,n)}findDiffEnd(t,n=this.size,r=t.size){return Cu(this,t,n,r)}findIndex(t){if(t==0)return ao(0,t);if(t==this.size)return ao(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),s=r+o.nodeSize;if(s>=t)return s==t?ao(n+1,s):ao(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return X.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new X(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return X.empty;let n,r=0;for(let o=0;o<t.length;o++){let s=t[o];r+=s.nodeSize,o&&s.isText&&t[o-1].sameMarkup(s)?(n||(n=t.slice(0,o)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new X(n||t,r)}static from(t){if(!t)return X.empty;if(t instanceof X)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new X([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}X.empty=new X([],0);const Ps={index:0,offset:0};function ao(e,t){return Ps.index=e,Ps.offset=t,Ps}function yi(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!yi(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!yi(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}class Be{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let o=0;o<t.length;o++){let s=t[o];if(this.eq(s))return t;if(this.type.excludes(s.type))n||(n=t.slice(0,o));else{if(s.type.excludes(this.type))return t;!r&&s.type.rank>this.type.rank&&(n||(n=t.slice(0,o)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&yi(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let o=r.create(n.attrs);return r.checkAttrs(o.attrs),o}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Be.none;if(t instanceof Be)return[t];let n=t.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}}Be.none=[];class yg extends Error{}class Z{constructor(t,n,r){this.content=t,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Tu(this.content,t+this.openStart,n);return r&&new Z(r,this.openStart,this.openEnd)}removeBetween(t,n){return new Z(Su(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Z.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Z(X.fromJSON(t,n.content),r,o)}static maxOpen(t,n=!0){let r=0,o=0;for(let s=t.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=t.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)o++;return new Z(t,r,o)}}Z.empty=new Z(X.empty,0,0);function Su(e,t,n){let{index:r,offset:o}=e.findIndex(t),s=e.maybeChild(r),{index:i,offset:a}=e.findIndex(n);if(o==t||s.isText){if(a!=n&&!e.child(i).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return e.replaceChild(r,s.copy(Su(s.content,t-o-1,n-o-1)))}function Tu(e,t,n,r){let{index:o,offset:s}=e.findIndex(t),i=e.maybeChild(o);if(s==t||i.isText)return r&&!r.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=Tu(i.content,t-s-1,n,i);return a&&e.replaceChild(o,i.copy(a))}function xg(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function vg(e,t){let n=Object.create(null);for(let r in e){let o=t&&t[r];if(o===void 0){let s=e[r];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=o}return n}function wg(e,t,n,r){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let o in e){let s=e[o];s.validate&&s.validate(t[o])}}function kg(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Sg(e,r,t[r]);return n}function Cg(e,t,n){let r=n.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${s}`)}}class Sg{constructor(t,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Cg(t,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class la{constructor(t,n,r,o){this.name=t,this.rank=n,this.schema=r,this.spec=o,this.attrs=kg(t,o.attrs),this.excluded=null;let s=xg(this.attrs);this.instance=s?new Be(this,s):null}create(t=null){return!t&&this.instance?this.instance:new Be(this,vg(this.attrs,t))}static compile(t,n){let r=Object.create(null),o=0;return t.forEach((s,i)=>r[s]=new la(s,o++,n,i)),r}removeFromSet(t){for(var n=0;n<t.length;n++)t[n].type==this&&(t=t.slice(0,n).concat(t.slice(n+1)),n--);return t}isInSet(t){for(let n=0;n<t.length;n++)if(t[n].type==this)return t[n]}checkAttrs(t){wg(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}function Tg(e){return e.tag!=null}function Ag(e){return e.style!=null}class $o{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(Tg(o))this.tags.push(o);else if(Ag(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=t.nodes[o.node];return s.contentMatch.matchType(s)})}parse(t,n={}){let r=new gl(this,n,!1);return r.addAll(t,Be.none,n.from,n.to),r.finish()}parseSlice(t,n={}){let r=new gl(this,n,!0);return r.addAll(t,Be.none,n.from,n.to),Z.maxOpen(r.finish())}matchTag(t,n,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(Rg(t,s.tag)&&(s.namespace===void 0||t.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(t);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(t,n,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],a=i.style;if(!(a.indexOf(t)!=0||i.context&&!r.matchesContext(i.context)||a.length>t.length&&(a.charCodeAt(t.length)!=61||a.slice(t.length+1)!=n))){if(i.getAttrs){let l=i.getAttrs(n);if(l===!1)continue;i.attrs=l||void 0}return i}}}static schemaRules(t){let n=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<n.length;i++){let a=n[i];if((a.priority==null?50:a.priority)<s)break}n.splice(i,0,o)}for(let o in t.marks){let s=t.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=bl(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in t.nodes){let s=t.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=bl(i)),i.node||i.ignore||i.mark||(i.node=o)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new $o(t,$o.schemaRules(t)))}}const Au={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Eg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Eu={ol:!0,ul:!0},Ar=1,xi=2,vr=4;function ml(e,t,n){return t!=null?(t?Ar:0)|(t==="full"?xi:0):e&&e.whitespace=="pre"?Ar|xi:n&~vr}class lo{constructor(t,n,r,o,s,i){this.type=t,this.attrs=n,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=Be.none,this.match=s||(i&vr?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(X.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(t.type))?(this.match=r,o):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Ar)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let n=X.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(X.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Au.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class gl{constructor(t,n,r){this.parser=t,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,s,i=ml(null,n.preserveWhitespace,0)|(r?vr:0);o?s=new lo(o.type,o.attrs,Be.none,!0,n.topMatch||o.type.contentMatch,i):r?s=new lo(null,null,Be.none,!0,null,i):s=new lo(t.schema.topNodeType,null,Be.none,!0,null,i),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let r=t.nodeValue,o=this.top,s=o.options&xi?"full":this.localPreserveWS||(o.options&Ar)>0,{schema:i}=this.parser;if(s==="full"||o.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
|
|
77
|
-
`);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(i.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(i.text(a[l]),n,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=o.content[o.content.length-1],l=t.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),n,!/\S/.test(r)),this.findInText(t)}else this.findInside(t)}addElement(t,n,r){let o=this.localPreserveWS,s=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let i=t.nodeName.toLowerCase(),a;
|
|
78
|
-
`),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let r=t.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let a=void 0;;){let l=this.parser.matchStyle(s,i,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(t,n,r,o){let s,i;if(n.node)if(i=this.parser.schema.nodes[n.node],i.isLeaf)this.insertNode(i.create(n.attrs),r,t.nodeName=="BR")||this.leafFallback(t,r);else{let l=this.enter(i,n.attrs||null,r,n.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(i&&i.isLeaf)this.findInside(t);else if(o)this.addElement(t,r,o);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=t;typeof n.contentElement=="string"?l=t.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(t):n.contentElement&&(l=n.contentElement),this.findAround(t,l,!0),this.addAll(l,r),this.findAround(t,l,!1)}s&&this.sync(a)&&this.open--}addAll(t,n,r,o){let s=r||0;for(let i=r?t.childNodes[r]:t.firstChild,a=o==null?null:t.childNodes[o];i!=a;i=i.nextSibling,++s)this.findAtPoint(t,s),this.addDOM(i,n);this.findAtPoint(t,s)}findPlace(t,n,r){let o,s;for(let i=this.open,a=0;i>=0;i--){let l=this.nodes[i],c=l.findWrapping(t);if(c&&(!o||o.length>c.length+a)&&(o=c,s=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)n=this.enterInner(o[i],null,n,!1);return n}insertNode(t,n,r){if(t.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let o=this.findPlace(t,n,r);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(t.type));let i=Be.none;for(let a of o.concat(t.marks))(s.type?s.type.allowsMarkType(a.type):yl(a.type,t.type))&&(i=a.addToSet(i));return s.content.push(t.mark(i)),!0}return!1}enter(t,n,r,o){let s=this.findPlace(t.create(n),r,!1);return s&&(s=this.enterInner(t,n,r,!0,o)),s}enterInner(t,n,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(t);let a=ml(t,s,i.options);i.options&vr&&i.content.length==0&&(a|=vr);let l=Be.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):yl(c.type,t))?(l=c.addToSet(l),!1):!0),this.nodes.push(new lo(t,n,l,o,null,a)),this.open++,r}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Ar)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)t+=r[o].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,r){if(t!=n&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&t.nodeType==1&&t.contains(this.find[o].node)&&n.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(a,l)=>{for(;a>=0;a--){let c=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=s;l--)if(i(a-1,l))return!0;return!1}else{let u=l>0||l==0&&o?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return i(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function Mg(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&Eu.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):r=="li"?n=t:r&&(n=null)}}function Rg(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function bl(e){let t={};for(let n in e)t[n]=e[n];return t}function yl(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let s=[],i=a=>{s.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==t||s.indexOf(u)<0&&i(u))return!0}};if(i(o.contentMatch))return!0}}class as{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},r){r||(r=Ls(n).createDocumentFragment());let o=r,s=[];return t.forEach(i=>{if(s.length||i.marks.length){let a=0,l=0;for(;a<s.length&&l<i.marks.length;){let c=i.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(s[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<s.length;)o=s.pop()[1];for(;l<i.marks.length;){let c=i.marks[l++],u=this.serializeMark(c,i.isInline,n);u&&(s.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(i,n))}),r}serializeNodeInner(t,n){let{dom:r,contentDOM:o}=Ao(Ls(n),this.nodes[t.type.name](t),null,t.attrs);if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,o)}return r}serializeNode(t,n={}){let r=this.serializeNodeInner(t,n);for(let o=t.marks.length-1;o>=0;o--){let s=this.serializeMark(t.marks[o],t.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(t,n,r={}){let o=this.marks[t.type.name];return o&&Ao(Ls(r),o(t,n),null,t.attrs)}static renderSpec(t,n,r=null,o){return Ao(t,n,r,o)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new as(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=xl(t.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(t){return xl(t.marks)}}function xl(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Ls(e){return e.document||window.document}const vl=new WeakMap;function Ng(e){let t=vl.get(e);return t===void 0&&vl.set(e,t=Og(e)),t}function Og(e){let t=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")t||(t=[]),t.push(r);else for(let o=0;o<r.length;o++)n(r[o]);else for(let o in r)n(r[o])}return n(e),t}function Ao(e,t,n,r){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let o=t[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Ng(r))&&s.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(n=o.slice(0,i),o=o.slice(i+1));let a,l=n?e.createElementNS(n,o):e.createElement(o),c=t[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?l.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&l.style?l.style.cssText=c[d]:l.setAttribute(d,c[d])}}for(let d=u;d<t.length;d++){let f=t[d];if(f===0){if(d<t.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:m}=Ao(e,f,n,r);if(l.appendChild(p),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const Mu=65535,Ru=Math.pow(2,16);function Ig(e,t){return e+t*Ru}function wl(e){return e&Mu}function Pg(e){return(e-(e&Mu))/Ru}const Nu=1,Ou=2,Eo=4,Iu=8;class vi{constructor(t,n,r){this.pos=t,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Iu)>0}get deletedBefore(){return(this.delInfo&(Nu|Eo))>0}get deletedAfter(){return(this.delInfo&(Ou|Eo))>0}get deletedAcross(){return(this.delInfo&Eo)>0}}class Qe{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&Qe.empty)return Qe.empty}recover(t){let n=0,r=wl(t);if(!this.inverted)for(let o=0;o<r;o++)n+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+n+Pg(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?o:0);if(l>t)break;let c=this.ranges[a+s],u=this.ranges[a+i],d=l+c;if(t<=d){let f=c?t==l?-1:t==d?1:n:n,p=l+o+(f<0?0:u);if(r)return p;let m=t==(n<0?l:d)?null:Ig(a/3,t-l),g=t==l?Ou:t==d?Nu:Eo;return(n<0?t!=l:t!=d)&&(g|=Iu),new vi(p,g,m)}o+=u-c}return r?t+o:new vi(t+o,0,null)}touches(t,n){let r=0,o=wl(n),s=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>t)break;let c=this.ranges[a+s],u=l+c;if(t<=u&&a==o*3)return!0;r+=this.ranges[a+i]-c}return!1}forEach(t){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],a=i-(this.inverted?s:0),l=i+(this.inverted?0:s),c=this.ranges[o+n],u=this.ranges[o+r];t(a,a+c,l,l+u),s+=u-c}}invert(){return new Qe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Qe.empty:new Qe(t<0?[0,-t,0]:[0,0,t])}}Qe.empty=new Qe([]);class Fo{constructor(t,n,r=0,o=t?t.length:0){this.mirror=n,this.from=r,this.to=o,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new Fo(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,r=this._maps.length;n<t._maps.length;n++){let o=t.getMirror(n);this.appendMap(t._maps[n],o!=null&&o<n?r+o:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,r=this._maps.length+t._maps.length;n>=0;n--){let o=t.getMirror(n);this.appendMap(t._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let t=new Fo;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],a=i.mapResult(t,n);if(a.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,t=this._maps[l].recover(a.recover);continue}}o|=a.delInfo,t=a.pos}return r?t:new vi(t,o,null)}}const Ds=Object.create(null);class je{getMap(){return Qe.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ds[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in Ds)throw new RangeError("Duplicate use of step JSON ID "+t);return Ds[t]=n,n.prototype.jsonID=t,n}}class Ae{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new Ae(t,null)}static fail(t){return new Ae(null,t)}static fromReplace(t,n,r,o){try{return Ae.ok(t.replace(n,r,o))}catch(s){if(s instanceof yg)return Ae.fail(s.message);throw s}}}function ca(e,t,n){let r=[];for(let o=0;o<e.childCount;o++){let s=e.child(o);s.content.size&&(s=s.copy(ca(s.content,t,s))),s.isInline&&(s=t(s,n,o)),r.push(s)}return X.fromArray(r)}class Jt extends je{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=t.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new Z(ca(n.content,(i,a)=>!i.isAtom||!a.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),n.openStart,n.openEnd);return Ae.fromReplace(t,this.from,this.to,s)}invert(){return new Tt(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Jt(n.pos,r.pos,this.mark)}merge(t){return t instanceof Jt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Jt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Jt(n.from,n.to,t.markFromJSON(n.mark))}}je.jsonID("addMark",Jt);class Tt extends je{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=new Z(ca(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),t),n.openStart,n.openEnd);return Ae.fromReplace(t,this.from,this.to,r)}invert(){return new Jt(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Tt(n.pos,r.pos,this.mark)}merge(t){return t instanceof Tt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Tt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Tt(n.from,n.to,t.markFromJSON(n.mark))}}je.jsonID("removeMark",Tt);class Yt extends je{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ae.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ae.fromReplace(t,this.pos,this.pos+1,new Z(X.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new Yt(this.pos,n.marks[o]);return new Yt(this.pos,this.mark)}}return new kn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Yt(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Yt(n.pos,t.markFromJSON(n.mark))}}je.jsonID("addNodeMark",Yt);class kn extends je{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ae.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ae.fromReplace(t,this.pos,this.pos+1,new Z(X.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Yt(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new kn(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new kn(n.pos,t.markFromJSON(n.mark))}}je.jsonID("removeNodeMark",kn);class Ne extends je{constructor(t,n,r,o=!1){super(),this.from=t,this.to=n,this.slice=r,this.structure=o}apply(t){return this.structure&&wi(t,this.from,this.to)?Ae.fail("Structure replace would overwrite content"):Ae.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Qe([this.from,this.to-this.from,this.slice.size])}invert(t){return new Ne(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&Ne.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Ne(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof Ne)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Z.empty:new Z(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Ne(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Z.empty:new Z(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Ne(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ne(n.from,n.to,Z.fromJSON(t,n.slice),!!n.structure)}}Ne.MAP_BIAS=1;je.jsonID("replace",Ne);class mt extends je{constructor(t,n,r,o,s,i,a=!1){super(),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=a}apply(t){if(this.structure&&(wi(t,this.from,this.gapFrom)||wi(t,this.gapTo,this.to)))return Ae.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ae.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ae.fromReplace(t,this.from,this.to,r):Ae.fail("Content does not fit in gap")}getMap(){return new Qe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new mt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||s>r.pos?null:new mt(n.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new mt(n.from,n.to,n.gapFrom,n.gapTo,Z.fromJSON(t,n.slice),n.insert,!!n.structure)}}je.jsonID("replaceAround",mt);function wi(e,t,n){let r=e.resolve(t),o=n-t,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function Lg(e,t,n,r){let o=[],s=[],i,a;e.doc.nodesBetween(t,n,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,t),p=Math.min(c+l.nodeSize,n),m=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(m)||(i&&i.to==f&&i.mark.eq(d[g])?i.to=p:o.push(i=new Tt(f,p,d[g])));a&&a.to==f?a.to=p:s.push(a=new Jt(f,p,r))}}),o.forEach(l=>e.step(l)),s.forEach(l=>e.step(l))}function Dg(e,t,n,r){let o=[],s=0;e.doc.nodesBetween(t,n,(i,a)=>{if(!i.isInline)return;s++;let l=null;if(r instanceof la){let c=i.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(l=[r]):l=i.marks;if(l&&l.length){let c=Math.min(a+i.nodeSize,n);for(let u=0;u<l.length;u++){let d=l[u],f;for(let p=0;p<o.length;p++){let m=o[p];m.step==s-1&&d.eq(o[p].style)&&(f=m)}f?(f.to=c,f.step=s):o.push({style:d,from:Math.max(a,t),to:c,step:s})}}}),o.forEach(i=>e.step(new Tt(i.from,i.to,i.style)))}function ua(e,t,n,r=n.contentMatch,o=!0){let s=e.doc.nodeAt(t),i=[],a=t+1;for(let l=0;l<s.childCount;l++){let c=s.child(l),u=a+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new Ne(a,u,Z.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||e.step(new Tt(a,u,c.marks[f]));if(o&&c.isText&&n.whitespace!="pre"){let f,p=/\r?\n|\r/g,m;for(;f=p.exec(c.text);)m||(m=new Z(X.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),i.push(new Ne(a+f.index,a+f.index+f[0].length,m))}}a=u}if(!r.validEnd){let l=r.fillBefore(X.empty,!0);e.replace(a,a,new Z(l,0,0))}for(let l=i.length-1;l>=0;l--)e.step(i[l])}function jg(e,t,n){let{$from:r,$to:o,depth:s}=t,i=r.before(s+1),a=o.after(s+1),l=i,c=a,u=X.empty,d=0;for(let m=s,g=!1;m>n;m--)g||r.index(m)>0?(g=!0,u=X.from(r.node(m).copy(u)),d++):l--;let f=X.empty,p=0;for(let m=s,g=!1;m>n;m--)g||o.after(m+1)<o.end(m)?(g=!0,f=X.from(o.node(m).copy(f)),p++):c++;e.step(new mt(l,c,i,a,new Z(u.append(f),d,p),u.size-d,!0))}function zg(e,t,n){let r=X.empty;for(let i=n.length-1;i>=0;i--){if(r.size){let a=n[i].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=X.from(n[i].type.create(n[i].attrs,r))}let o=t.start,s=t.end;e.step(new mt(o,s,o,s,new Z(r,0,0),n.length,!0))}function _g(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,(i,a)=>{let l=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,l)&&$g(e.doc,e.mapping.slice(s).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!m?c=!1:!p&&m&&(c=!0)}c===!1&&Lu(e,i,a,s),ua(e,e.mapping.slice(s).map(a,1),r,void 0,c===null);let u=e.mapping.slice(s),d=u.map(a,1),f=u.map(a+i.nodeSize,1);return e.step(new mt(d,f,d+1,f-1,new Z(X.from(r.create(l,null,i.marks)),0,0),1,!0)),c===!0&&Pu(e,i,a,s),!1}})}function Pu(e,t,n,r){t.forEach((o,s)=>{if(o.isText){let i,a=/\r?\n|\r/g;for(;i=a.exec(o.text);){let l=e.mapping.slice(r).map(n+1+s+i.index);e.replaceWith(l,l+1,t.type.schema.linebreakReplacement.create())}}})}function Lu(e,t,n,r){t.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+s);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
79
|
-
`))}})}function $g(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function Fg(e,t,n,r,o){let s=e.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let i=n.create(r,null,o||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,i);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new mt(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new Z(X.from(i),0,0),1,!0))}function Bg(e,t,n=1,r){let o=e.doc.resolve(t),s=X.empty,i=X.empty;for(let a=o.depth,l=o.depth-n,c=n-1;a>l;a--,c--){s=X.from(o.node(a).copy(s));let u=r&&r[c];i=X.from(u?u.type.create(u.attrs,i):o.node(a).copy(i))}e.step(new Ne(t,t,new Z(s.append(i),n,n),!0))}function Hg(e,t,n){let r=null,{linebreakReplacement:o}=e.doc.type.schema,s=e.doc.resolve(t-n),i=s.node().type;if(o&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let a=e.steps.length;if(r===!1){let u=e.doc.resolve(t+n);Lu(e,u.node(),u.before(),a)}i.inlineContent&&ua(e,t+n-1,i,s.node().contentMatchAt(s.index()),r==null);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new Ne(c,l.map(t+n,-1),Z.empty,!0)),r===!0){let u=e.doc.resolve(c);Pu(e,u.node(),u.before(),e.steps.length)}return e}function Wg(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,n))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,n))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function Vg(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let s=0;s<n.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let i=r.depth;i>=0;i--){let a=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,l=r.index(i)+(a>0?1:0),c=r.node(i),u=!1;if(s==1)u=c.canReplace(l,l,o);else{let d=c.contentMatchAt(l).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?r.pos:a<0?r.before(i+1):r.after(i+1)}return null}function qg(e,t,n=t,r=Z.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),s=e.resolve(n);return Du(o,s,r)?new Ne(t,n,r):new Kg(o,s,r).fit()}function Du(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}class Kg{constructor(t,n,r){this.$from=t,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=X.empty;for(let o=0;o<=t.depth;o++){let s=t.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(t.indexAfter(o))})}for(let o=t.depth;o>0;o--)this.placed=X.from(t.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(t<0?this.$to:r.doc.resolve(t));if(!o)return null;let s=this.placed,i=r.depth,a=o.depth;for(;i&&a&&s.childCount==1;)s=s.firstChild.content,i--,a--;let l=new Z(s,i,a);return t>-1?new mt(r.pos,t,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Ne(r.pos,o.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<t;r++){let s=n.firstChild;if(n.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){t=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?t:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=js(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,d=null;if(n==1&&(i?c.matchType(i.type)||(d=c.fillBefore(X.from(i),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:d};if(n==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:t,openStart:n,openEnd:r}=this.unplaced,o=js(t,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new Z(t,n+1,Math.max(r,o.size+n>=t.size-r?n+1:0)),!0)}dropNode(){let{content:t,openStart:n,openEnd:r}=this.unplaced,o=js(t,n);if(o.childCount<=1&&n>0){let s=t.size-n<=n+o.size;this.unplaced=new Z(gr(t,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Z(gr(t,n,1),n,r)}placeNodes({sliceDepth:t,frontierDepth:n,parent:r,inject:o,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let g=0;g<s.length;g++)this.openFrontierNode(s[g]);let i=this.unplaced,a=r?r.content:i.content,l=i.openStart-t,c=0,u=[],{match:d,type:f}=this.frontier[n];if(o){for(let g=0;g<o.childCount;g++)u.push(o.child(g));d=d.matchFragment(o)}let p=a.size+t-(i.content.size-i.openEnd);for(;c<a.childCount;){let g=a.child(c),b=d.matchType(g.type);if(!b)break;c++,(c>1||l==0||g.content.size)&&(d=b,u.push(ju(g.mark(f.allowedMarks(g.marks)),c==1?l:0,c==a.childCount?p:-1)))}let m=c==a.childCount;m||(p=-1),this.placed=br(this.placed,n,X.from(u)),this.frontier[n].match=d,m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,b=a;g<p;g++){let x=b.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),b=x.content}this.unplaced=m?t==0?Z.empty:new Z(gr(i.content,t-1,1),t-1,p<0?i.openEnd:t-1):new Z(gr(i.content,t,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],n;if(!t.type.isTextblock||!zs(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(t){e:for(let n=Math.min(this.depth,t.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],s=n<t.depth&&t.end(n+1)==t.pos+(t.depth-(n+1)),i=zs(t,n,o,r,s);if(i){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=zs(t,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:i,move:s?t.doc.resolve(t.after(n+1)):t}}}}close(t){let n=this.findCloseLevel(t);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=br(this.placed,n.depth,n.fit)),t=n.move;for(let r=n.depth+1;r<=t.depth;r++){let o=t.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,t.index(r));this.openFrontierNode(o.type,o.attrs,s)}return t}openFrontierNode(t,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=br(this.placed,this.depth,X.from(t.create(n,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(X.empty,!0);n.childCount&&(this.placed=br(this.placed,this.frontier.length,n))}}function gr(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(gr(e.firstChild.content,t-1,n)))}function br(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(br(e.lastChild.content,t-1,n)))}function js(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function ju(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,ju(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(X.empty,!0)))),e.copy(r)}function zs(e,t,n,r,o){let s=e.node(t),i=o?e.indexAfter(t):e.index(t);if(i==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,i);return a&&!Ug(n,s.content,i)?a:null}function Ug(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Gg(e){return e.spec.defining||e.spec.definingForContent}function Xg(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),s=e.doc.resolve(n);if(Du(o,s,r))return e.step(new Ne(t,n,r));let i=_u(o,s);i[i.length-1]==0&&i.pop();let a=-(o.depth+1);i.unshift(a);for(let f=o.depth,p=o.pos-1;f>0;f--,p--){let m=o.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;i.indexOf(f)>-1?a=f:o.before(f)==p&&i.splice(1,0,-f)}let l=i.indexOf(a),c=[],u=r.openStart;for(let f=r.content,p=0;;p++){let m=f.firstChild;if(c.push(m),p==r.openStart)break;f=m.content}for(let f=u-1;f>=0;f--){let p=c[f],m=Gg(p.type);if(m&&!p.sameMarkup(o.node(Math.abs(a)-1)))u=f;else if(m||!p.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let p=(f+u+1)%(r.openStart+1),m=c[p];if(m)for(let g=0;g<i.length;g++){let b=i[(g+l)%i.length],x=!0;b<0&&(x=!1,b=-b);let S=o.node(b-1),k=o.index(b-1);if(S.canReplaceWith(k,k,m.type,m.marks))return e.replace(o.before(b),x?s.after(b):n,new Z(zu(r.content,0,r.openStart,p),p,r.openEnd))}}let d=e.steps.length;for(let f=i.length-1;f>=0&&(e.replace(t,n,r),!(e.steps.length>d));f--){let p=i[f];p<0||(t=o.before(p),n=s.after(p))}}function zu(e,t,n,r,o){if(t<n){let s=e.firstChild;e=e.replaceChild(0,s.copy(zu(s.content,t+1,n,r,s)))}if(t>r){let s=o.contentMatchAt(0),i=s.fillBefore(e).append(e);e=i.append(s.matchFragment(i).fillBefore(X.empty,!0))}return e}function Jg(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=Wg(e.doc,t,r.type);o!=null&&(t=n=o)}e.replaceRange(t,n,new Z(X.from(r),0,0))}function Yg(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let i=r.sharedDepth(n),a=!1;for(let l=r.depth;l>i;l--)r.node(l).type.spec.isolating&&(a=!0);for(let l=o.depth;l>i;l--)o.node(l).type.spec.isolating&&(a=!0);if(!a){for(let l=r.depth;l>0&&t==r.start(l);l--)t=r.before(l);for(let l=o.depth;l>0&&n==o.start(l);l--)n=o.before(l);r=e.doc.resolve(t),o=e.doc.resolve(n)}}let s=_u(r,o);for(let i=0;i<s.length;i++){let a=s[i],l=i==s.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return e.delete(r.start(a),o.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),o.indexAfter(a-1))))return e.delete(r.before(a),o.after(a))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}function _u(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let o=r;o>=0;o--){let s=e.start(o);if(s<e.pos-(e.depth-o)||t.end(o)>t.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(s==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==s-1)&&n.push(o)}return n}class Vn extends je{constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ae.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return Ae.fromReplace(t,this.pos,this.pos+1,new Z(X.from(o),0,n.isLeaf?0:1))}getMap(){return Qe.empty}invert(t){return new Vn(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Vn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Vn(n.pos,n.attr,n.value)}}je.jsonID("attr",Vn);class Er extends je{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let o in t.attrs)n[o]=t.attrs[o];n[this.attr]=this.value;let r=t.type.create(n,t.content,t.marks);return Ae.ok(r)}getMap(){return Qe.empty}invert(t){return new Er(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Er(n.attr,n.value)}}je.jsonID("docAttr",Er);let Jn=class extends Error{};Jn=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Jn.prototype=Object.create(Error.prototype);Jn.prototype.constructor=Jn;Jn.prototype.name="TransformError";class Qg{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Fo}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let n=this.maybeStep(t);if(n.failed)throw new Jn(n.failed);return this}maybeStep(t){let n=t.apply(this.doc);return n.failed||this.addStep(t,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let t=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(t=o.map(t,1),n=o.map(n,-1)),o.forEach((s,i,a,l)=>{t=Math.min(t,a),n=Math.max(n,l)})}return t==1e9?null:{from:t,to:n}}addStep(t,n){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=n}replace(t,n=t,r=Z.empty){let o=qg(this.doc,t,n,r);return o&&this.step(o),this}replaceWith(t,n,r){return this.replace(t,n,new Z(X.from(r),0,0))}delete(t,n){return this.replace(t,n,Z.empty)}insert(t,n){return this.replaceWith(t,t,n)}replaceRange(t,n,r){return Xg(this,t,n,r),this}replaceRangeWith(t,n,r){return Jg(this,t,n,r),this}deleteRange(t,n){return Yg(this,t,n),this}lift(t,n){return jg(this,t,n),this}join(t,n=1){return Hg(this,t,n),this}wrap(t,n){return zg(this,t,n),this}setBlockType(t,n=t,r,o=null){return _g(this,t,n,r,o),this}setNodeMarkup(t,n,r=null,o){return Fg(this,t,n,r,o),this}setNodeAttribute(t,n,r){return this.step(new Vn(t,n,r)),this}setDocAttribute(t,n){return this.step(new Er(t,n)),this}addNodeMark(t,n){return this.step(new Yt(t,n)),this}removeNodeMark(t,n){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(n instanceof Be)n.isInSet(r.marks)&&this.step(new kn(t,n));else{let o=r.marks,s,i=[];for(;s=n.isInSet(o);)i.push(new kn(t,s)),o=s.removeFromSet(o);for(let a=i.length-1;a>=0;a--)this.step(i[a])}return this}split(t,n=1,r){return Bg(this,t,n,r),this}addMark(t,n,r){return Lg(this,t,n,r),this}removeMark(t,n,r){return Dg(this,t,n,r),this}clearIncompatible(t,n,r){return ua(this,t,n,r),this}}const _s=Object.create(null);class pe{constructor(t,n,r){this.$anchor=t,this.$head=n,this.ranges=r||[new $u(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=Z.empty){let r=n.content.lastChild,o=null;for(let a=0;a<n.openEnd;a++)o=r,r=r.lastChild;let s=t.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:l,$to:c}=i[a],u=t.mapping.slice(s);t.replaceRange(u.map(l.pos),u.map(c.pos),a?Z.empty:n),a==0&&Sl(t,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(t,n){let r=t.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:a}=o[s],l=t.mapping.slice(r),c=l.map(i.pos),u=l.map(a.pos);s?t.deleteRange(c,u):(t.replaceRangeWith(c,u,n),Sl(t,r,n.isInline?-1:1))}}static findFrom(t,n,r=!1){let o=t.parent.inlineContent?new he(t):Bn(t.node(0),t.parent,t.pos,t.index(),n,r);if(o)return o;for(let s=t.depth-1;s>=0;s--){let i=n<0?Bn(t.node(0),t.node(s),t.before(s+1),t.index(s),n,r):Bn(t.node(0),t.node(s),t.after(s+1),t.index(s)+1,n,r);if(i)return i}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new Et(t.node(0))}static atStart(t){return Bn(t,t,0,0,1)||new Et(t)}static atEnd(t){return Bn(t,t,t.content.size,t.childCount,-1)||new Et(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=_s[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in _s)throw new RangeError("Duplicate use of selection JSON ID "+t);return _s[t]=n,n.prototype.jsonID=t,n}getBookmark(){return he.between(this.$anchor,this.$head).getBookmark()}}pe.prototype.visible=!0;class $u{constructor(t,n){this.$from=t,this.$to=n}}let kl=!1;function Cl(e){!kl&&!e.parent.inlineContent&&(kl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class he extends pe{constructor(t,n=t){Cl(t),Cl(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return pe.near(r);let o=t.resolve(n.map(this.anchor));return new he(o.parent.inlineContent?o:r,r)}replace(t,n=Z.empty){if(super.replace(t,n),n==Z.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof he&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ls(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new he(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){let o=t.resolve(n);return new this(o,r==n?o:t.resolve(r))}static between(t,n,r){let o=t.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let s=pe.findFrom(n,r,!0)||pe.findFrom(n,-r,!0);if(s)n=s.$head;else return pe.near(n,r)}return t.parent.inlineContent||(o==0?t=n:(t=(pe.findFrom(t,-r,!0)||pe.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=o<0&&(t=n))),new he(t,n)}}pe.jsonID("text",he);class ls{constructor(t,n){this.anchor=t,this.head=n}map(t){return new ls(t.map(this.anchor),t.map(this.head))}resolve(t){return he.between(t.resolve(this.anchor),t.resolve(this.head))}}class de extends pe{constructor(t){let n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);super(t,r),this.node=n}map(t,n){let{deleted:r,pos:o}=n.mapResult(this.anchor),s=t.resolve(o);return r?pe.near(s):new de(s)}content(){return new Z(X.from(this.node),0,0)}eq(t){return t instanceof de&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new da(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new de(t.resolve(n.anchor))}static create(t,n){return new de(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}de.prototype.visible=!1;pe.jsonID("node",de);class da{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new ls(r,r):new da(r)}resolve(t){let n=t.resolve(this.anchor),r=n.nodeAfter;return r&&de.isSelectable(r)?new de(n):pe.near(n)}}class Et extends pe{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=Z.empty){if(n==Z.empty){t.delete(0,t.doc.content.size);let r=pe.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new Et(t)}map(t){return new Et(t)}eq(t){return t instanceof Et}getBookmark(){return Zg}}pe.jsonID("all",Et);const Zg={map(){return this},resolve(e){return new Et(e)}};function Bn(e,t,n,r,o,s=!1){if(t.inlineContent)return he.create(e,n);for(let i=r-(o>0?0:1);o>0?i<t.childCount:i>=0;i+=o){let a=t.child(i);if(a.isAtom){if(!s&&de.isSelectable(a))return de.create(e,n-(o<0?a.nodeSize:0))}else{let l=Bn(e,a,n+o,o<0?a.childCount:0,o,s);if(l)return l}n+=a.nodeSize*o}return null}function Sl(e,t,n){let r=e.steps.length-1;if(r<t)return;let o=e.steps[r];if(!(o instanceof Ne||o instanceof mt))return;let s=e.mapping.maps[r],i;s.forEach((a,l,c,u)=>{i==null&&(i=u)}),e.setSelection(pe.near(e.doc.resolve(i),n))}function Tl(e,t){return!t||!e?e:e.bind(t)}class co{constructor(t,n,r){this.name=t,this.init=Tl(n.init,r),this.apply=Tl(n.apply,r)}}new co("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new co("selection",{init(e,t){return e.selection||pe.atStart(t.doc)},apply(e){return e.selection}}),new co("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new co("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});function Fu(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):r=="handleDOMEvents"&&(o=Fu(o,t,{})),n[r]=o}return n}class fa{constructor(t){this.spec=t,this.props={},t.props&&Fu(t.props,this,this.props),this.key=t.key?t.key.key:Bu("plugin")}getState(t){return t[this.key]}}const $s=Object.create(null);function Bu(e){return e in $s?e+"$"+ ++$s[e]:($s[e]=0,e+"$")}class cs{constructor(t="key"){this.key=Bu(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Mn=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Hu=function(e,t,n,r){return n&&(Al(e,t,n,r,-1)||Al(e,t,n,r,1))},eb=/^(img|br|input|textarea|hr)$/i;function Al(e,t,n,r,o){for(var s;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Bo(e))){let i=e.parentNode;if(!i||i.nodeType!=1||pa(e)||eb.test(e.nodeName)||e.contentEditable=="false")return!1;t=Mn(e)+(o<0?0:1),e=i}else if(e.nodeType==1){let i=e.childNodes[t+(o<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((s=i.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)t+=o;else return!1;else e=i,t=o<0?Bo(e):0}else return!1}}function Bo(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function tb(e,t,n){for(let r=t==0,o=t==Bo(e);r||o;){if(e==n)return!0;let s=Mn(e);if(e=e.parentNode,!e)return!1;r=r&&s==0,o=o&&s==Bo(e)}}function pa(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Wu=function(e){return e.focusNode&&Hu(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Vu(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const Nt=typeof navigator<"u"?navigator:null,El=typeof document<"u"?document:null,on=Nt&&Nt.userAgent||"",ki=/Edge\/(\d+)/.exec(on),qu=/MSIE \d/.exec(on),Ci=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(on),Br=!!(qu||Ci||ki),Ku=qu?document.documentMode:Ci?+Ci[1]:ki?+ki[1]:0,us=!Br&&/gecko\/(\d+)/i.test(on);us&&+(/Firefox\/(\d+)/.exec(on)||[0,0])[1];const Si=!Br&&/Chrome\/(\d+)/.exec(on),Ht=!!Si,Uu=Si?+Si[1]:0,Rn=!Br&&!!Nt&&/Apple Computer/.test(Nt.vendor),ha=Rn&&(/Mobile\/\w+/.test(on)||!!Nt&&Nt.maxTouchPoints>2),at=ha||(Nt?/Mac/.test(Nt.platform):!1),Gu=Nt?/Win/.test(Nt.platform):!1,Hr=/Android \d/.test(on),ma=!!El&&"webkitFontSmoothing"in El.documentElement.style,nb=ma?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function rb(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),s=o&&o.size==0,i=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let a=r.resolve(i),l,c;if(Wu(n)){for(l=i;o&&!o.node;)o=o.parent;let d=o.node;if(o&&d.isAtom&&de.isSelectable(d)&&o.parent&&!(d.isInline&&tb(n.focusNode,n.focusOffset,o.dom))){let f=o.posBefore;c=new de(i==f?a:r.resolve(f))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=i,f=i;for(let p=0;p<n.rangeCount;p++){let m=n.getRangeAt(p);d=Math.min(d,e.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,e.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[l,i]=f==e.state.selection.anchor?[f,d]:[d,f],a=r.resolve(i)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let d=t=="pointer"||e.state.selection.head<a.pos&&!s?1:-1;c=Ju(e,u,a,d)}return c}function Xu(e){return e.editable?e.hasFocus():ab(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function ga(e,t=!1){let n=e.state.selection;if(ib(e,n),!!Xu(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Ht){let r=e.domSelectionRange(),o=e.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Hu(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)sb(e);else{let{anchor:r,head:o}=n,s,i;Ml&&!(n instanceof he)&&(n.$from.parent.inlineContent||(s=Rl(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(i=Rl(e,n.to))),e.docView.setSelection(r,o,e,t),Ml&&(s&&Nl(s),i&&Nl(i)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ob(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Ml=Rn||Ht&&Uu<63;function Rl(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Rn&&o&&o.contentEditable=="false")return Fs(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return Fs(o);if(s)return Fs(s)}}function Fs(e){return e.contentEditable="true",Rn&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Nl(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function ob(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!Xu(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function sb(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,Mn(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&Br&&Ku<=11&&(n.disabled=!0,n.disabled=!1)}function ib(e,t){if(t instanceof de){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Ol(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Ol(e)}function Ol(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ju(e,t,n,r){return e.someProp("createSelectionBetween",o=>o(e,t,n))||he.between(t,n,r)}function ab(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Ti(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),s=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return s&&pe.findFrom(s,t)}function Gt(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Il(e,t,n){let r=e.state.selection;if(r instanceof he)if(n.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=e.state.doc.resolve(o.pos+s.nodeSize*(t<0?-1:1));return Gt(e,new he(r.$anchor,i))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let o=Ti(e.state,t);return o&&o instanceof de?Gt(e,o):!1}else if(!(at&&n.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let a=t<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=e.docView.descAt(a))&&!i.contentDOM?de.isSelectable(s)?Gt(e,new de(t<0?e.state.doc.resolve(o.pos-s.nodeSize):o)):ma?Gt(e,new he(e.state.doc.resolve(t<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof de&&r.node.isInline)return Gt(e,new he(t>0?r.$to:r.$from));{let o=Ti(e.state,t);return o?Gt(e,o):!1}}}function Ho(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function wr(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function Dn(e,t){return t<0?lb(e):cb(e)}function lb(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,s,i=!1;for(us&&n.nodeType==1&&r<Ho(n)&&wr(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(wr(a,-1))o=n,s=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(Yu(n))break;{let a=n.previousSibling;for(;a&&wr(a,-1);)o=n.parentNode,s=Mn(a),a=a.previousSibling;if(a)n=a,r=Ho(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}i?Ai(e,n,r):o&&Ai(e,o,s)}function cb(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o=Ho(n),s,i;for(;;)if(r<o){if(n.nodeType!=1)break;let a=n.childNodes[r];if(wr(a,1))s=n,i=++r;else break}else{if(Yu(n))break;{let a=n.nextSibling;for(;a&&wr(a,1);)s=a.parentNode,i=Mn(a)+1,a=a.nextSibling;if(a)n=a,r=0,o=Ho(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}s&&Ai(e,s,i)}function Yu(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function ub(e,t){for(;e&&t==e.childNodes.length&&!pa(e);)t=Mn(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=0}}function db(e,t){for(;e&&!t&&!pa(e);)t=Mn(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function Ai(e,t,n){if(t.nodeType!=3){let s,i;(i=ub(t,n))?(t=i,n=0):(s=db(t,n))&&(t=s,n=s.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Wu(r)){let s=document.createRange();s.setEnd(t,n),s.setStart(t,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&ga(e)},50)}function Pl(e,t){let n=e.state.doc.resolve(t);if(!(Ht||Gu)&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let s=e.coordsAtPos(t-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(t<n.end()){let s=e.coordsAtPos(t+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function Ll(e,t,n){let r=e.state.selection;if(r instanceof he&&!r.empty||n.indexOf("s")>-1||at&&n.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let i=Ti(e.state,t);if(i&&i instanceof de)return Gt(e,i)}if(!o.parent.inlineContent){let i=t<0?o:s,a=r instanceof Et?pe.near(i,t):pe.findFrom(i,t);return a?Gt(e,a):!1}return!1}function Dl(e,t){if(!(e.state.selection instanceof he))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let i=e.state.tr;return t<0?i.delete(n.pos-s.nodeSize,n.pos):i.delete(n.pos,n.pos+s.nodeSize),e.dispatch(i),!0}return!1}function jl(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function fb(e){if(!Rn||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let r=t.firstChild;jl(e,r,"true"),setTimeout(()=>jl(e,r,"false"),20)}return!1}function pb(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function hb(e,t){let n=t.keyCode,r=pb(t);if(n==8||at&&n==72&&r=="c")return Dl(e,-1)||Dn(e,-1);if(n==46&&!t.shiftKey||at&&n==68&&r=="c")return Dl(e,1)||Dn(e,1);if(n==13||n==27)return!0;if(n==37||at&&n==66&&r=="c"){let o=n==37?Pl(e,e.state.selection.from)=="ltr"?-1:1:-1;return Il(e,o,r)||Dn(e,o)}else if(n==39||at&&n==70&&r=="c"){let o=n==39?Pl(e,e.state.selection.from)=="ltr"?1:-1:1;return Il(e,o,r)||Dn(e,o)}else{if(n==38||at&&n==80&&r=="c")return Ll(e,-1,r)||Dn(e,-1);if(n==40||at&&n==78&&r=="c")return fb(e)||Ll(e,1,r)||Dn(e,1);if(r==(at?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Qu(e,t){e.someProp("transformCopied",p=>{t=p(t,e)});let n=[],{content:r,openStart:o,openEnd:s}=t;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=e.someProp("clipboardSerializer")||as.fromSchema(e.state.schema),a=od(),l=a.createElement("div");l.appendChild(i.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=rd[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let m=a.createElement(u[p]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=e.someProp("clipboardTextSerializer",p=>p(t,e))||t.content.textBetween(0,t.content.size,`
|
|
74
|
+
`),[s,i]=mg(o);if(s.length===0)return;const a=wu(s,0,n);return a.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:a,raw:o.slice(0,i).join(`
|
|
75
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(bg,this.editor.getAttributes(ml)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=P.wrappingInputRule({find:gl,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=P.wrappingInputRule({find:gl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(ml)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),xg=/^\s*(\[([( |x])?\])\s$/,ku=P.Node.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{const t=e.getAttribute("data-checked");return t===""||t==="true"},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return["li",P.mergeAttributes(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(e,t)=>{const n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode("paragraph",{},t.parseInline(e.tokens))):e.text?n.push(t.createNode("paragraph",{},[t.createNode("text",{text:e.text})])):n.push(t.createNode("paragraph",{},[])),e.nestedTokens&&e.nestedTokens.length>0){const r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode("taskItem",{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{var n;const o=`- [${(n=e.attrs)!=null&&n.checked?"x":" "}] `;return P.renderNestedMarkdownContent(e,t,o)},addKeyboardShortcuts(){const e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{const o=document.createElement("li"),s=document.createElement("label"),i=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=d=>{var f,p;a.ariaLabel=((p=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:p.call(f,d,a.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(e),s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",d=>d.preventDefault()),a.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const m=n();if(typeof m!="number")return!1;const g=p.doc.nodeAt(m);return p.setNodeMarkup(m,void 0,{...g?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,f)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{o.setAttribute(d,f)}),o.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,s.append(a,i),o.append(s,l),Object.entries(t).forEach(([d,f])=>{o.setAttribute(d,f)});let u=new Set(Object.keys(t));return{dom:o,contentDOM:l,update:d=>{if(d.type!==this.type)return!1;o.dataset.checked=d.attrs.checked,a.checked=d.attrs.checked,c(d);const f=r.extensionManager.attributes,p=P.getRenderedAttributes(d,f),m=new Set(Object.keys(p)),g=this.options.HTMLAttributes;return u.forEach(b=>{m.has(b)||(b in g?o.setAttribute(b,g[b]):o.removeAttribute(b))}),Object.entries(p).forEach(([b,x])=>{x==null?b in g?o.setAttribute(b,g[b]):o.removeAttribute(b):o.setAttribute(b,x)}),u=m,!0}}}},addInputRules(){return[P.wrappingInputRule({find:xg,type:this.type,getAttributes:e=>({checked:e[e.length-1]==="x"})})]}}),Cu=P.Node.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",P.mergeAttributes(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode("taskList",{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
76
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;const n=(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:t.index;return n!==void 0?n:-1},tokenize(e,t,n){const r=s=>{const i=P.parseIndentedBlocks(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},n);return i?[{type:"taskList",raw:i.raw,items:i.items}]:n.blockTokens(s)},o=P.parseIndentedBlocks(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,i)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:i}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});P.Extension.create({name:"listKit",addExtensions(){const e=[];return this.options.bulletList!==!1&&e.push(sg.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(lg.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(dg.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(yg.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(ku.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Cu.configure(this.options.taskList)),e}});function Su(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(r),s=t.child(r);if(o==s){n+=o.nodeSize;continue}if(!o.sameMarkup(s))return n;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)n++;return n}if(o.content.size||s.content.size){let i=Su(o.content,s.content,n+1);if(i!=null)return i}n+=o.nodeSize}}function Tu(e,t,n,r){for(let o=e.childCount,s=t.childCount;;){if(o==0||s==0)return o==s?null:{a:n,b:r};let i=e.child(--o),a=t.child(--s),l=i.nodeSize;if(i==a){n-=l,r-=l;continue}if(!i.sameMarkup(a))return{a:n,b:r};if(i.isText&&i.text!=a.text){let c=0,u=Math.min(i.text.length,a.text.length);for(;c<u&&i.text[i.text.length-c-1]==a.text[a.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(i.content.size||a.content.size){let c=Tu(i.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class X{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,n,r,o=0,s){for(let i=0,a=0;a<n;i++){let l=this.content[i],c=a+l.nodeSize;if(c>t&&r(l,o+a,s||null,i)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,t-u),Math.min(l.content.size,n-u),r,o+u)}a=c}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,r,o){let s="",i=!0;return this.nodesBetween(t,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(t,l)-l,n-l):a.isLeaf?o?typeof o=="function"?o(a):o:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,o=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),s=1);s<t.content.length;s++)o.push(t.content[s]);return new X(o,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],o=0;if(n>t)for(let s=0,i=0;i<n;s++){let a=this.content[s],l=i+a.nodeSize;l>t&&((i<t||l>n)&&(a.isText?a=a.cut(Math.max(0,t-i),Math.min(a.text.length,n-i)):a=a.cut(Math.max(0,t-i-1),Math.min(a.content.size,n-i-1))),r.push(a),o+=a.nodeSize),i=l}return new X(r,o)}cutByIndex(t,n){return t==n?X.empty:t==0&&n==this.content.length?this:new X(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let o=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return o[t]=n,new X(o,s)}addToStart(t){return new X([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new X(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,r=0;n<this.content.length;n++){let o=this.content[n];t(o,r,n),r+=o.nodeSize}}findDiffStart(t,n=0){return Su(this,t,n)}findDiffEnd(t,n=this.size,r=t.size){return Tu(this,t,n,r)}findIndex(t){if(t==0)return lo(0,t);if(t==this.size)return lo(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),s=r+o.nodeSize;if(s>=t)return s==t?lo(n+1,s):lo(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return X.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new X(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return X.empty;let n,r=0;for(let o=0;o<t.length;o++){let s=t[o];r+=s.nodeSize,o&&s.isText&&t[o-1].sameMarkup(s)?(n||(n=t.slice(0,o)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new X(n||t,r)}static from(t){if(!t)return X.empty;if(t instanceof X)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new X([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}X.empty=new X([],0);const Ds={index:0,offset:0};function lo(e,t){return Ds.index=e,Ds.offset=t,Ds}function vi(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!vi(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!vi(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}class Be{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let o=0;o<t.length;o++){let s=t[o];if(this.eq(s))return t;if(this.type.excludes(s.type))n||(n=t.slice(0,o));else{if(s.type.excludes(this.type))return t;!r&&s.type.rank>this.type.rank&&(n||(n=t.slice(0,o)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&vi(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let o=r.create(n.attrs);return r.checkAttrs(o.attrs),o}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Be.none;if(t instanceof Be)return[t];let n=t.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}}Be.none=[];class vg extends Error{}class Z{constructor(t,n,r){this.content=t,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Eu(this.content,t+this.openStart,n);return r&&new Z(r,this.openStart,this.openEnd)}removeBetween(t,n){return new Z(Au(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Z.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Z(X.fromJSON(t,n.content),r,o)}static maxOpen(t,n=!0){let r=0,o=0;for(let s=t.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=t.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)o++;return new Z(t,r,o)}}Z.empty=new Z(X.empty,0,0);function Au(e,t,n){let{index:r,offset:o}=e.findIndex(t),s=e.maybeChild(r),{index:i,offset:a}=e.findIndex(n);if(o==t||s.isText){if(a!=n&&!e.child(i).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return e.replaceChild(r,s.copy(Au(s.content,t-o-1,n-o-1)))}function Eu(e,t,n,r){let{index:o,offset:s}=e.findIndex(t),i=e.maybeChild(o);if(s==t||i.isText)return r&&!r.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=Eu(i.content,t-s-1,n,i);return a&&e.replaceChild(o,i.copy(a))}function wg(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function kg(e,t){let n=Object.create(null);for(let r in e){let o=t&&t[r];if(o===void 0){let s=e[r];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=o}return n}function Cg(e,t,n,r){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let o in e){let s=e[o];s.validate&&s.validate(t[o])}}function Sg(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Ag(e,r,t[r]);return n}function Tg(e,t,n){let r=n.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${s}`)}}class Ag{constructor(t,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Tg(t,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ua{constructor(t,n,r,o){this.name=t,this.rank=n,this.schema=r,this.spec=o,this.attrs=Sg(t,o.attrs),this.excluded=null;let s=wg(this.attrs);this.instance=s?new Be(this,s):null}create(t=null){return!t&&this.instance?this.instance:new Be(this,kg(this.attrs,t))}static compile(t,n){let r=Object.create(null),o=0;return t.forEach((s,i)=>r[s]=new ua(s,o++,n,i)),r}removeFromSet(t){for(var n=0;n<t.length;n++)t[n].type==this&&(t=t.slice(0,n).concat(t.slice(n+1)),n--);return t}isInSet(t){for(let n=0;n<t.length;n++)if(t[n].type==this)return t[n]}checkAttrs(t){Cg(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}function Eg(e){return e.tag!=null}function Mg(e){return e.style!=null}class Fo{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(Eg(o))this.tags.push(o);else if(Mg(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=t.nodes[o.node];return s.contentMatch.matchType(s)})}parse(t,n={}){let r=new yl(this,n,!1);return r.addAll(t,Be.none,n.from,n.to),r.finish()}parseSlice(t,n={}){let r=new yl(this,n,!0);return r.addAll(t,Be.none,n.from,n.to),Z.maxOpen(r.finish())}matchTag(t,n,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(Og(t,s.tag)&&(s.namespace===void 0||t.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(t);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(t,n,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],a=i.style;if(!(a.indexOf(t)!=0||i.context&&!r.matchesContext(i.context)||a.length>t.length&&(a.charCodeAt(t.length)!=61||a.slice(t.length+1)!=n))){if(i.getAttrs){let l=i.getAttrs(n);if(l===!1)continue;i.attrs=l||void 0}return i}}}static schemaRules(t){let n=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<n.length;i++){let a=n[i];if((a.priority==null?50:a.priority)<s)break}n.splice(i,0,o)}for(let o in t.marks){let s=t.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=xl(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in t.nodes){let s=t.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=xl(i)),i.node||i.ignore||i.mark||(i.node=o)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Fo(t,Fo.schemaRules(t)))}}const Mu={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Rg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ru={ol:!0,ul:!0},Ar=1,wi=2,vr=4;function bl(e,t,n){return t!=null?(t?Ar:0)|(t==="full"?wi:0):e&&e.whitespace=="pre"?Ar|wi:n&~vr}class co{constructor(t,n,r,o,s,i){this.type=t,this.attrs=n,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=Be.none,this.match=s||(i&vr?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(X.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(t.type))?(this.match=r,o):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Ar)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let n=X.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(X.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Mu.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class yl{constructor(t,n,r){this.parser=t,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,s,i=bl(null,n.preserveWhitespace,0)|(r?vr:0);o?s=new co(o.type,o.attrs,Be.none,!0,n.topMatch||o.type.contentMatch,i):r?s=new co(null,null,Be.none,!0,null,i):s=new co(t.schema.topNodeType,null,Be.none,!0,null,i),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let r=t.nodeValue,o=this.top,s=o.options&wi?"full":this.localPreserveWS||(o.options&Ar)>0,{schema:i}=this.parser;if(s==="full"||o.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
|
|
77
|
+
`);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(i.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(i.text(a[l]),n,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=o.content[o.content.length-1],l=t.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),n,!/\S/.test(r)),this.findInText(t)}else this.findInside(t)}addElement(t,n,r){let o=this.localPreserveWS,s=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let i=t.nodeName.toLowerCase(),a;Ru.hasOwnProperty(i)&&this.parser.normalizeLists&&Ng(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(a=this.parser.matchTag(t,this,r));e:if(l?l.ignore:Rg.hasOwnProperty(i))this.findInside(t),this.ignoreFallback(t,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(t=l.skip);let c,u=this.needsBlock;if(Mu.hasOwnProperty(i))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,n);break e}let d=l&&l.skip?n:this.readStyles(t,n);d&&this.addAll(t,d),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(t,n);c&&this.addElementByRule(t,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=o}leafFallback(t,n){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
78
|
+
`),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let r=t.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let a=void 0;;){let l=this.parser.matchStyle(s,i,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(t,n,r,o){let s,i;if(n.node)if(i=this.parser.schema.nodes[n.node],i.isLeaf)this.insertNode(i.create(n.attrs),r,t.nodeName=="BR")||this.leafFallback(t,r);else{let l=this.enter(i,n.attrs||null,r,n.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(i&&i.isLeaf)this.findInside(t);else if(o)this.addElement(t,r,o);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=t;typeof n.contentElement=="string"?l=t.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(t):n.contentElement&&(l=n.contentElement),this.findAround(t,l,!0),this.addAll(l,r),this.findAround(t,l,!1)}s&&this.sync(a)&&this.open--}addAll(t,n,r,o){let s=r||0;for(let i=r?t.childNodes[r]:t.firstChild,a=o==null?null:t.childNodes[o];i!=a;i=i.nextSibling,++s)this.findAtPoint(t,s),this.addDOM(i,n);this.findAtPoint(t,s)}findPlace(t,n,r){let o,s;for(let i=this.open,a=0;i>=0;i--){let l=this.nodes[i],c=l.findWrapping(t);if(c&&(!o||o.length>c.length+a)&&(o=c,s=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)n=this.enterInner(o[i],null,n,!1);return n}insertNode(t,n,r){if(t.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let o=this.findPlace(t,n,r);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(t.type));let i=Be.none;for(let a of o.concat(t.marks))(s.type?s.type.allowsMarkType(a.type):vl(a.type,t.type))&&(i=a.addToSet(i));return s.content.push(t.mark(i)),!0}return!1}enter(t,n,r,o){let s=this.findPlace(t.create(n),r,!1);return s&&(s=this.enterInner(t,n,r,!0,o)),s}enterInner(t,n,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(t);let a=bl(t,s,i.options);i.options&vr&&i.content.length==0&&(a|=vr);let l=Be.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):vl(c.type,t))?(l=c.addToSet(l),!1):!0),this.nodes.push(new co(t,n,l,o,null,a)),this.open++,r}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Ar)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)t+=r[o].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,r){if(t!=n&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&t.nodeType==1&&t.contains(this.find[o].node)&&n.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(a,l)=>{for(;a>=0;a--){let c=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=s;l--)if(i(a-1,l))return!0;return!1}else{let u=l>0||l==0&&o?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return i(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function Ng(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&Ru.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):r=="li"?n=t:r&&(n=null)}}function Og(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function xl(e){let t={};for(let n in e)t[n]=e[n];return t}function vl(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let s=[],i=a=>{s.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==t||s.indexOf(u)<0&&i(u))return!0}};if(i(o.contentMatch))return!0}}class cs{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},r){r||(r=js(n).createDocumentFragment());let o=r,s=[];return t.forEach(i=>{if(s.length||i.marks.length){let a=0,l=0;for(;a<s.length&&l<i.marks.length;){let c=i.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(s[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<s.length;)o=s.pop()[1];for(;l<i.marks.length;){let c=i.marks[l++],u=this.serializeMark(c,i.isInline,n);u&&(s.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(i,n))}),r}serializeNodeInner(t,n){let{dom:r,contentDOM:o}=Eo(js(n),this.nodes[t.type.name](t),null,t.attrs);if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,o)}return r}serializeNode(t,n={}){let r=this.serializeNodeInner(t,n);for(let o=t.marks.length-1;o>=0;o--){let s=this.serializeMark(t.marks[o],t.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(t,n,r={}){let o=this.marks[t.type.name];return o&&Eo(js(r),o(t,n),null,t.attrs)}static renderSpec(t,n,r=null,o){return Eo(t,n,r,o)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new cs(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=wl(t.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(t){return wl(t.marks)}}function wl(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function js(e){return e.document||window.document}const kl=new WeakMap;function Ig(e){let t=kl.get(e);return t===void 0&&kl.set(e,t=Pg(e)),t}function Pg(e){let t=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")t||(t=[]),t.push(r);else for(let o=0;o<r.length;o++)n(r[o]);else for(let o in r)n(r[o])}return n(e),t}function Eo(e,t,n,r){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let o=t[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Ig(r))&&s.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(n=o.slice(0,i),o=o.slice(i+1));let a,l=n?e.createElementNS(n,o):e.createElement(o),c=t[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?l.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&l.style?l.style.cssText=c[d]:l.setAttribute(d,c[d])}}for(let d=u;d<t.length;d++){let f=t[d];if(f===0){if(d<t.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:m}=Eo(e,f,n,r);if(l.appendChild(p),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const Nu=65535,Ou=Math.pow(2,16);function Lg(e,t){return e+t*Ou}function Cl(e){return e&Nu}function Dg(e){return(e-(e&Nu))/Ou}const Iu=1,Pu=2,Mo=4,Lu=8;class ki{constructor(t,n,r){this.pos=t,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Lu)>0}get deletedBefore(){return(this.delInfo&(Iu|Mo))>0}get deletedAfter(){return(this.delInfo&(Pu|Mo))>0}get deletedAcross(){return(this.delInfo&Mo)>0}}class Qe{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&Qe.empty)return Qe.empty}recover(t){let n=0,r=Cl(t);if(!this.inverted)for(let o=0;o<r;o++)n+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+n+Dg(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?o:0);if(l>t)break;let c=this.ranges[a+s],u=this.ranges[a+i],d=l+c;if(t<=d){let f=c?t==l?-1:t==d?1:n:n,p=l+o+(f<0?0:u);if(r)return p;let m=t==(n<0?l:d)?null:Lg(a/3,t-l),g=t==l?Pu:t==d?Iu:Mo;return(n<0?t!=l:t!=d)&&(g|=Lu),new ki(p,g,m)}o+=u-c}return r?t+o:new ki(t+o,0,null)}touches(t,n){let r=0,o=Cl(n),s=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>t)break;let c=this.ranges[a+s],u=l+c;if(t<=u&&a==o*3)return!0;r+=this.ranges[a+i]-c}return!1}forEach(t){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],a=i-(this.inverted?s:0),l=i+(this.inverted?0:s),c=this.ranges[o+n],u=this.ranges[o+r];t(a,a+c,l,l+u),s+=u-c}}invert(){return new Qe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Qe.empty:new Qe(t<0?[0,-t,0]:[0,0,t])}}Qe.empty=new Qe([]);class Bo{constructor(t,n,r=0,o=t?t.length:0){this.mirror=n,this.from=r,this.to=o,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new Bo(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,r=this._maps.length;n<t._maps.length;n++){let o=t.getMirror(n);this.appendMap(t._maps[n],o!=null&&o<n?r+o:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,r=this._maps.length+t._maps.length;n>=0;n--){let o=t.getMirror(n);this.appendMap(t._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let t=new Bo;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],a=i.mapResult(t,n);if(a.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,t=this._maps[l].recover(a.recover);continue}}o|=a.delInfo,t=a.pos}return r?t:new ki(t,o,null)}}const zs=Object.create(null);class je{getMap(){return Qe.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=zs[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in zs)throw new RangeError("Duplicate use of step JSON ID "+t);return zs[t]=n,n.prototype.jsonID=t,n}}class Ae{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new Ae(t,null)}static fail(t){return new Ae(null,t)}static fromReplace(t,n,r,o){try{return Ae.ok(t.replace(n,r,o))}catch(s){if(s instanceof vg)return Ae.fail(s.message);throw s}}}function da(e,t,n){let r=[];for(let o=0;o<e.childCount;o++){let s=e.child(o);s.content.size&&(s=s.copy(da(s.content,t,s))),s.isInline&&(s=t(s,n,o)),r.push(s)}return X.fromArray(r)}class Jt extends je{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=t.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new Z(da(n.content,(i,a)=>!i.isAtom||!a.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),n.openStart,n.openEnd);return Ae.fromReplace(t,this.from,this.to,s)}invert(){return new Tt(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Jt(n.pos,r.pos,this.mark)}merge(t){return t instanceof Jt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Jt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Jt(n.from,n.to,t.markFromJSON(n.mark))}}je.jsonID("addMark",Jt);class Tt extends je{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=new Z(da(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),t),n.openStart,n.openEnd);return Ae.fromReplace(t,this.from,this.to,r)}invert(){return new Jt(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Tt(n.pos,r.pos,this.mark)}merge(t){return t instanceof Tt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Tt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Tt(n.from,n.to,t.markFromJSON(n.mark))}}je.jsonID("removeMark",Tt);class Yt extends je{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ae.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ae.fromReplace(t,this.pos,this.pos+1,new Z(X.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new Yt(this.pos,n.marks[o]);return new Yt(this.pos,this.mark)}}return new kn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Yt(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Yt(n.pos,t.markFromJSON(n.mark))}}je.jsonID("addNodeMark",Yt);class kn extends je{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ae.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ae.fromReplace(t,this.pos,this.pos+1,new Z(X.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Yt(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new kn(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new kn(n.pos,t.markFromJSON(n.mark))}}je.jsonID("removeNodeMark",kn);class Ne extends je{constructor(t,n,r,o=!1){super(),this.from=t,this.to=n,this.slice=r,this.structure=o}apply(t){return this.structure&&Ci(t,this.from,this.to)?Ae.fail("Structure replace would overwrite content"):Ae.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Qe([this.from,this.to-this.from,this.slice.size])}invert(t){return new Ne(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&Ne.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Ne(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof Ne)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Z.empty:new Z(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Ne(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Z.empty:new Z(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Ne(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ne(n.from,n.to,Z.fromJSON(t,n.slice),!!n.structure)}}Ne.MAP_BIAS=1;je.jsonID("replace",Ne);class mt extends je{constructor(t,n,r,o,s,i,a=!1){super(),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=a}apply(t){if(this.structure&&(Ci(t,this.from,this.gapFrom)||Ci(t,this.gapTo,this.to)))return Ae.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ae.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ae.fromReplace(t,this.from,this.to,r):Ae.fail("Content does not fit in gap")}getMap(){return new Qe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new mt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||s>r.pos?null:new mt(n.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new mt(n.from,n.to,n.gapFrom,n.gapTo,Z.fromJSON(t,n.slice),n.insert,!!n.structure)}}je.jsonID("replaceAround",mt);function Ci(e,t,n){let r=e.resolve(t),o=n-t,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function jg(e,t,n,r){let o=[],s=[],i,a;e.doc.nodesBetween(t,n,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,t),p=Math.min(c+l.nodeSize,n),m=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(m)||(i&&i.to==f&&i.mark.eq(d[g])?i.to=p:o.push(i=new Tt(f,p,d[g])));a&&a.to==f?a.to=p:s.push(a=new Jt(f,p,r))}}),o.forEach(l=>e.step(l)),s.forEach(l=>e.step(l))}function zg(e,t,n,r){let o=[],s=0;e.doc.nodesBetween(t,n,(i,a)=>{if(!i.isInline)return;s++;let l=null;if(r instanceof ua){let c=i.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(l=[r]):l=i.marks;if(l&&l.length){let c=Math.min(a+i.nodeSize,n);for(let u=0;u<l.length;u++){let d=l[u],f;for(let p=0;p<o.length;p++){let m=o[p];m.step==s-1&&d.eq(o[p].style)&&(f=m)}f?(f.to=c,f.step=s):o.push({style:d,from:Math.max(a,t),to:c,step:s})}}}),o.forEach(i=>e.step(new Tt(i.from,i.to,i.style)))}function fa(e,t,n,r=n.contentMatch,o=!0){let s=e.doc.nodeAt(t),i=[],a=t+1;for(let l=0;l<s.childCount;l++){let c=s.child(l),u=a+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new Ne(a,u,Z.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||e.step(new Tt(a,u,c.marks[f]));if(o&&c.isText&&n.whitespace!="pre"){let f,p=/\r?\n|\r/g,m;for(;f=p.exec(c.text);)m||(m=new Z(X.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),i.push(new Ne(a+f.index,a+f.index+f[0].length,m))}}a=u}if(!r.validEnd){let l=r.fillBefore(X.empty,!0);e.replace(a,a,new Z(l,0,0))}for(let l=i.length-1;l>=0;l--)e.step(i[l])}function _g(e,t,n){let{$from:r,$to:o,depth:s}=t,i=r.before(s+1),a=o.after(s+1),l=i,c=a,u=X.empty,d=0;for(let m=s,g=!1;m>n;m--)g||r.index(m)>0?(g=!0,u=X.from(r.node(m).copy(u)),d++):l--;let f=X.empty,p=0;for(let m=s,g=!1;m>n;m--)g||o.after(m+1)<o.end(m)?(g=!0,f=X.from(o.node(m).copy(f)),p++):c++;e.step(new mt(l,c,i,a,new Z(u.append(f),d,p),u.size-d,!0))}function $g(e,t,n){let r=X.empty;for(let i=n.length-1;i>=0;i--){if(r.size){let a=n[i].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=X.from(n[i].type.create(n[i].attrs,r))}let o=t.start,s=t.end;e.step(new mt(o,s,o,s,new Z(r,0,0),n.length,!0))}function Fg(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,(i,a)=>{let l=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,l)&&Bg(e.doc,e.mapping.slice(s).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!m?c=!1:!p&&m&&(c=!0)}c===!1&&ju(e,i,a,s),fa(e,e.mapping.slice(s).map(a,1),r,void 0,c===null);let u=e.mapping.slice(s),d=u.map(a,1),f=u.map(a+i.nodeSize,1);return e.step(new mt(d,f,d+1,f-1,new Z(X.from(r.create(l,null,i.marks)),0,0),1,!0)),c===!0&&Du(e,i,a,s),!1}})}function Du(e,t,n,r){t.forEach((o,s)=>{if(o.isText){let i,a=/\r?\n|\r/g;for(;i=a.exec(o.text);){let l=e.mapping.slice(r).map(n+1+s+i.index);e.replaceWith(l,l+1,t.type.schema.linebreakReplacement.create())}}})}function ju(e,t,n,r){t.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+s);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
79
|
+
`))}})}function Bg(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function Hg(e,t,n,r,o){let s=e.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let i=n.create(r,null,o||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,i);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new mt(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new Z(X.from(i),0,0),1,!0))}function Wg(e,t,n=1,r){let o=e.doc.resolve(t),s=X.empty,i=X.empty;for(let a=o.depth,l=o.depth-n,c=n-1;a>l;a--,c--){s=X.from(o.node(a).copy(s));let u=r&&r[c];i=X.from(u?u.type.create(u.attrs,i):o.node(a).copy(i))}e.step(new Ne(t,t,new Z(s.append(i),n,n),!0))}function Vg(e,t,n){let r=null,{linebreakReplacement:o}=e.doc.type.schema,s=e.doc.resolve(t-n),i=s.node().type;if(o&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let a=e.steps.length;if(r===!1){let u=e.doc.resolve(t+n);ju(e,u.node(),u.before(),a)}i.inlineContent&&fa(e,t+n-1,i,s.node().contentMatchAt(s.index()),r==null);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new Ne(c,l.map(t+n,-1),Z.empty,!0)),r===!0){let u=e.doc.resolve(c);Du(e,u.node(),u.before(),e.steps.length)}return e}function qg(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,n))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,n))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function Kg(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let s=0;s<n.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let i=r.depth;i>=0;i--){let a=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,l=r.index(i)+(a>0?1:0),c=r.node(i),u=!1;if(s==1)u=c.canReplace(l,l,o);else{let d=c.contentMatchAt(l).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?r.pos:a<0?r.before(i+1):r.after(i+1)}return null}function Ug(e,t,n=t,r=Z.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),s=e.resolve(n);return zu(o,s,r)?new Ne(t,n,r):new Gg(o,s,r).fit()}function zu(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}class Gg{constructor(t,n,r){this.$from=t,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=X.empty;for(let o=0;o<=t.depth;o++){let s=t.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(t.indexAfter(o))})}for(let o=t.depth;o>0;o--)this.placed=X.from(t.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(t<0?this.$to:r.doc.resolve(t));if(!o)return null;let s=this.placed,i=r.depth,a=o.depth;for(;i&&a&&s.childCount==1;)s=s.firstChild.content,i--,a--;let l=new Z(s,i,a);return t>-1?new mt(r.pos,t,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Ne(r.pos,o.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<t;r++){let s=n.firstChild;if(n.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){t=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?t:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=_s(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,d=null;if(n==1&&(i?c.matchType(i.type)||(d=c.fillBefore(X.from(i),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:d};if(n==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:t,openStart:n,openEnd:r}=this.unplaced,o=_s(t,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new Z(t,n+1,Math.max(r,o.size+n>=t.size-r?n+1:0)),!0)}dropNode(){let{content:t,openStart:n,openEnd:r}=this.unplaced,o=_s(t,n);if(o.childCount<=1&&n>0){let s=t.size-n<=n+o.size;this.unplaced=new Z(gr(t,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Z(gr(t,n,1),n,r)}placeNodes({sliceDepth:t,frontierDepth:n,parent:r,inject:o,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let g=0;g<s.length;g++)this.openFrontierNode(s[g]);let i=this.unplaced,a=r?r.content:i.content,l=i.openStart-t,c=0,u=[],{match:d,type:f}=this.frontier[n];if(o){for(let g=0;g<o.childCount;g++)u.push(o.child(g));d=d.matchFragment(o)}let p=a.size+t-(i.content.size-i.openEnd);for(;c<a.childCount;){let g=a.child(c),b=d.matchType(g.type);if(!b)break;c++,(c>1||l==0||g.content.size)&&(d=b,u.push(_u(g.mark(f.allowedMarks(g.marks)),c==1?l:0,c==a.childCount?p:-1)))}let m=c==a.childCount;m||(p=-1),this.placed=br(this.placed,n,X.from(u)),this.frontier[n].match=d,m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,b=a;g<p;g++){let x=b.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),b=x.content}this.unplaced=m?t==0?Z.empty:new Z(gr(i.content,t-1,1),t-1,p<0?i.openEnd:t-1):new Z(gr(i.content,t,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],n;if(!t.type.isTextblock||!$s(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(t){e:for(let n=Math.min(this.depth,t.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],s=n<t.depth&&t.end(n+1)==t.pos+(t.depth-(n+1)),i=$s(t,n,o,r,s);if(i){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=$s(t,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:i,move:s?t.doc.resolve(t.after(n+1)):t}}}}close(t){let n=this.findCloseLevel(t);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=br(this.placed,n.depth,n.fit)),t=n.move;for(let r=n.depth+1;r<=t.depth;r++){let o=t.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,t.index(r));this.openFrontierNode(o.type,o.attrs,s)}return t}openFrontierNode(t,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=br(this.placed,this.depth,X.from(t.create(n,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(X.empty,!0);n.childCount&&(this.placed=br(this.placed,this.frontier.length,n))}}function gr(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(gr(e.firstChild.content,t-1,n)))}function br(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(br(e.lastChild.content,t-1,n)))}function _s(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function _u(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,_u(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(X.empty,!0)))),e.copy(r)}function $s(e,t,n,r,o){let s=e.node(t),i=o?e.indexAfter(t):e.index(t);if(i==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,i);return a&&!Xg(n,s.content,i)?a:null}function Xg(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Jg(e){return e.spec.defining||e.spec.definingForContent}function Yg(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),s=e.doc.resolve(n);if(zu(o,s,r))return e.step(new Ne(t,n,r));let i=Fu(o,s);i[i.length-1]==0&&i.pop();let a=-(o.depth+1);i.unshift(a);for(let f=o.depth,p=o.pos-1;f>0;f--,p--){let m=o.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;i.indexOf(f)>-1?a=f:o.before(f)==p&&i.splice(1,0,-f)}let l=i.indexOf(a),c=[],u=r.openStart;for(let f=r.content,p=0;;p++){let m=f.firstChild;if(c.push(m),p==r.openStart)break;f=m.content}for(let f=u-1;f>=0;f--){let p=c[f],m=Jg(p.type);if(m&&!p.sameMarkup(o.node(Math.abs(a)-1)))u=f;else if(m||!p.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let p=(f+u+1)%(r.openStart+1),m=c[p];if(m)for(let g=0;g<i.length;g++){let b=i[(g+l)%i.length],x=!0;b<0&&(x=!1,b=-b);let S=o.node(b-1),k=o.index(b-1);if(S.canReplaceWith(k,k,m.type,m.marks))return e.replace(o.before(b),x?s.after(b):n,new Z($u(r.content,0,r.openStart,p),p,r.openEnd))}}let d=e.steps.length;for(let f=i.length-1;f>=0&&(e.replace(t,n,r),!(e.steps.length>d));f--){let p=i[f];p<0||(t=o.before(p),n=s.after(p))}}function $u(e,t,n,r,o){if(t<n){let s=e.firstChild;e=e.replaceChild(0,s.copy($u(s.content,t+1,n,r,s)))}if(t>r){let s=o.contentMatchAt(0),i=s.fillBefore(e).append(e);e=i.append(s.matchFragment(i).fillBefore(X.empty,!0))}return e}function Qg(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=qg(e.doc,t,r.type);o!=null&&(t=n=o)}e.replaceRange(t,n,new Z(X.from(r),0,0))}function Zg(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let i=r.sharedDepth(n),a=!1;for(let l=r.depth;l>i;l--)r.node(l).type.spec.isolating&&(a=!0);for(let l=o.depth;l>i;l--)o.node(l).type.spec.isolating&&(a=!0);if(!a){for(let l=r.depth;l>0&&t==r.start(l);l--)t=r.before(l);for(let l=o.depth;l>0&&n==o.start(l);l--)n=o.before(l);r=e.doc.resolve(t),o=e.doc.resolve(n)}}let s=Fu(r,o);for(let i=0;i<s.length;i++){let a=s[i],l=i==s.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return e.delete(r.start(a),o.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),o.indexAfter(a-1))))return e.delete(r.before(a),o.after(a))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}function Fu(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let o=r;o>=0;o--){let s=e.start(o);if(s<e.pos-(e.depth-o)||t.end(o)>t.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(s==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==s-1)&&n.push(o)}return n}class Vn extends je{constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ae.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return Ae.fromReplace(t,this.pos,this.pos+1,new Z(X.from(o),0,n.isLeaf?0:1))}getMap(){return Qe.empty}invert(t){return new Vn(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Vn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Vn(n.pos,n.attr,n.value)}}je.jsonID("attr",Vn);class Er extends je{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let o in t.attrs)n[o]=t.attrs[o];n[this.attr]=this.value;let r=t.type.create(n,t.content,t.marks);return Ae.ok(r)}getMap(){return Qe.empty}invert(t){return new Er(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Er(n.attr,n.value)}}je.jsonID("docAttr",Er);let Jn=class extends Error{};Jn=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Jn.prototype=Object.create(Error.prototype);Jn.prototype.constructor=Jn;Jn.prototype.name="TransformError";class eb{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Bo}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let n=this.maybeStep(t);if(n.failed)throw new Jn(n.failed);return this}maybeStep(t){let n=t.apply(this.doc);return n.failed||this.addStep(t,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let t=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(t=o.map(t,1),n=o.map(n,-1)),o.forEach((s,i,a,l)=>{t=Math.min(t,a),n=Math.max(n,l)})}return t==1e9?null:{from:t,to:n}}addStep(t,n){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=n}replace(t,n=t,r=Z.empty){let o=Ug(this.doc,t,n,r);return o&&this.step(o),this}replaceWith(t,n,r){return this.replace(t,n,new Z(X.from(r),0,0))}delete(t,n){return this.replace(t,n,Z.empty)}insert(t,n){return this.replaceWith(t,t,n)}replaceRange(t,n,r){return Yg(this,t,n,r),this}replaceRangeWith(t,n,r){return Qg(this,t,n,r),this}deleteRange(t,n){return Zg(this,t,n),this}lift(t,n){return _g(this,t,n),this}join(t,n=1){return Vg(this,t,n),this}wrap(t,n){return $g(this,t,n),this}setBlockType(t,n=t,r,o=null){return Fg(this,t,n,r,o),this}setNodeMarkup(t,n,r=null,o){return Hg(this,t,n,r,o),this}setNodeAttribute(t,n,r){return this.step(new Vn(t,n,r)),this}setDocAttribute(t,n){return this.step(new Er(t,n)),this}addNodeMark(t,n){return this.step(new Yt(t,n)),this}removeNodeMark(t,n){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(n instanceof Be)n.isInSet(r.marks)&&this.step(new kn(t,n));else{let o=r.marks,s,i=[];for(;s=n.isInSet(o);)i.push(new kn(t,s)),o=s.removeFromSet(o);for(let a=i.length-1;a>=0;a--)this.step(i[a])}return this}split(t,n=1,r){return Wg(this,t,n,r),this}addMark(t,n,r){return jg(this,t,n,r),this}removeMark(t,n,r){return zg(this,t,n,r),this}clearIncompatible(t,n,r){return fa(this,t,n,r),this}}const Fs=Object.create(null);class pe{constructor(t,n,r){this.$anchor=t,this.$head=n,this.ranges=r||[new Bu(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=Z.empty){let r=n.content.lastChild,o=null;for(let a=0;a<n.openEnd;a++)o=r,r=r.lastChild;let s=t.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:l,$to:c}=i[a],u=t.mapping.slice(s);t.replaceRange(u.map(l.pos),u.map(c.pos),a?Z.empty:n),a==0&&Al(t,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(t,n){let r=t.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:a}=o[s],l=t.mapping.slice(r),c=l.map(i.pos),u=l.map(a.pos);s?t.deleteRange(c,u):(t.replaceRangeWith(c,u,n),Al(t,r,n.isInline?-1:1))}}static findFrom(t,n,r=!1){let o=t.parent.inlineContent?new he(t):Bn(t.node(0),t.parent,t.pos,t.index(),n,r);if(o)return o;for(let s=t.depth-1;s>=0;s--){let i=n<0?Bn(t.node(0),t.node(s),t.before(s+1),t.index(s),n,r):Bn(t.node(0),t.node(s),t.after(s+1),t.index(s)+1,n,r);if(i)return i}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new Et(t.node(0))}static atStart(t){return Bn(t,t,0,0,1)||new Et(t)}static atEnd(t){return Bn(t,t,t.content.size,t.childCount,-1)||new Et(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Fs[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in Fs)throw new RangeError("Duplicate use of selection JSON ID "+t);return Fs[t]=n,n.prototype.jsonID=t,n}getBookmark(){return he.between(this.$anchor,this.$head).getBookmark()}}pe.prototype.visible=!0;class Bu{constructor(t,n){this.$from=t,this.$to=n}}let Sl=!1;function Tl(e){!Sl&&!e.parent.inlineContent&&(Sl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class he extends pe{constructor(t,n=t){Tl(t),Tl(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return pe.near(r);let o=t.resolve(n.map(this.anchor));return new he(o.parent.inlineContent?o:r,r)}replace(t,n=Z.empty){if(super.replace(t,n),n==Z.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof he&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new us(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new he(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){let o=t.resolve(n);return new this(o,r==n?o:t.resolve(r))}static between(t,n,r){let o=t.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let s=pe.findFrom(n,r,!0)||pe.findFrom(n,-r,!0);if(s)n=s.$head;else return pe.near(n,r)}return t.parent.inlineContent||(o==0?t=n:(t=(pe.findFrom(t,-r,!0)||pe.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=o<0&&(t=n))),new he(t,n)}}pe.jsonID("text",he);class us{constructor(t,n){this.anchor=t,this.head=n}map(t){return new us(t.map(this.anchor),t.map(this.head))}resolve(t){return he.between(t.resolve(this.anchor),t.resolve(this.head))}}class de extends pe{constructor(t){let n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);super(t,r),this.node=n}map(t,n){let{deleted:r,pos:o}=n.mapResult(this.anchor),s=t.resolve(o);return r?pe.near(s):new de(s)}content(){return new Z(X.from(this.node),0,0)}eq(t){return t instanceof de&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new pa(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new de(t.resolve(n.anchor))}static create(t,n){return new de(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}de.prototype.visible=!1;pe.jsonID("node",de);class pa{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new us(r,r):new pa(r)}resolve(t){let n=t.resolve(this.anchor),r=n.nodeAfter;return r&&de.isSelectable(r)?new de(n):pe.near(n)}}class Et extends pe{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=Z.empty){if(n==Z.empty){t.delete(0,t.doc.content.size);let r=pe.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new Et(t)}map(t){return new Et(t)}eq(t){return t instanceof Et}getBookmark(){return tb}}pe.jsonID("all",Et);const tb={map(){return this},resolve(e){return new Et(e)}};function Bn(e,t,n,r,o,s=!1){if(t.inlineContent)return he.create(e,n);for(let i=r-(o>0?0:1);o>0?i<t.childCount:i>=0;i+=o){let a=t.child(i);if(a.isAtom){if(!s&&de.isSelectable(a))return de.create(e,n-(o<0?a.nodeSize:0))}else{let l=Bn(e,a,n+o,o<0?a.childCount:0,o,s);if(l)return l}n+=a.nodeSize*o}return null}function Al(e,t,n){let r=e.steps.length-1;if(r<t)return;let o=e.steps[r];if(!(o instanceof Ne||o instanceof mt))return;let s=e.mapping.maps[r],i;s.forEach((a,l,c,u)=>{i==null&&(i=u)}),e.setSelection(pe.near(e.doc.resolve(i),n))}function El(e,t){return!t||!e?e:e.bind(t)}class uo{constructor(t,n,r){this.name=t,this.init=El(n.init,r),this.apply=El(n.apply,r)}}new uo("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new uo("selection",{init(e,t){return e.selection||pe.atStart(t.doc)},apply(e){return e.selection}}),new uo("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new uo("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});function Hu(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):r=="handleDOMEvents"&&(o=Hu(o,t,{})),n[r]=o}return n}class ha{constructor(t){this.spec=t,this.props={},t.props&&Hu(t.props,this,this.props),this.key=t.key?t.key.key:Wu("plugin")}getState(t){return t[this.key]}}const Bs=Object.create(null);function Wu(e){return e in Bs?e+"$"+ ++Bs[e]:(Bs[e]=0,e+"$")}class ds{constructor(t="key"){this.key=Wu(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Mn=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Vu=function(e,t,n,r){return n&&(Ml(e,t,n,r,-1)||Ml(e,t,n,r,1))},nb=/^(img|br|input|textarea|hr)$/i;function Ml(e,t,n,r,o){for(var s;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Ho(e))){let i=e.parentNode;if(!i||i.nodeType!=1||ma(e)||nb.test(e.nodeName)||e.contentEditable=="false")return!1;t=Mn(e)+(o<0?0:1),e=i}else if(e.nodeType==1){let i=e.childNodes[t+(o<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((s=i.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)t+=o;else return!1;else e=i,t=o<0?Ho(e):0}else return!1}}function Ho(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function rb(e,t,n){for(let r=t==0,o=t==Ho(e);r||o;){if(e==n)return!0;let s=Mn(e);if(e=e.parentNode,!e)return!1;r=r&&s==0,o=o&&s==Ho(e)}}function ma(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const qu=function(e){return e.focusNode&&Vu(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Ku(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const Nt=typeof navigator<"u"?navigator:null,Rl=typeof document<"u"?document:null,on=Nt&&Nt.userAgent||"",Si=/Edge\/(\d+)/.exec(on),Uu=/MSIE \d/.exec(on),Ti=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(on),Br=!!(Uu||Ti||Si),Gu=Uu?document.documentMode:Ti?+Ti[1]:Si?+Si[1]:0,fs=!Br&&/gecko\/(\d+)/i.test(on);fs&&+(/Firefox\/(\d+)/.exec(on)||[0,0])[1];const Ai=!Br&&/Chrome\/(\d+)/.exec(on),Ht=!!Ai,Xu=Ai?+Ai[1]:0,Rn=!Br&&!!Nt&&/Apple Computer/.test(Nt.vendor),ga=Rn&&(/Mobile\/\w+/.test(on)||!!Nt&&Nt.maxTouchPoints>2),at=ga||(Nt?/Mac/.test(Nt.platform):!1),Ju=Nt?/Win/.test(Nt.platform):!1,Hr=/Android \d/.test(on),ba=!!Rl&&"webkitFontSmoothing"in Rl.documentElement.style,ob=ba?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function sb(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),s=o&&o.size==0,i=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let a=r.resolve(i),l,c;if(qu(n)){for(l=i;o&&!o.node;)o=o.parent;let d=o.node;if(o&&d.isAtom&&de.isSelectable(d)&&o.parent&&!(d.isInline&&rb(n.focusNode,n.focusOffset,o.dom))){let f=o.posBefore;c=new de(i==f?a:r.resolve(f))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=i,f=i;for(let p=0;p<n.rangeCount;p++){let m=n.getRangeAt(p);d=Math.min(d,e.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,e.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[l,i]=f==e.state.selection.anchor?[f,d]:[d,f],a=r.resolve(i)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let d=t=="pointer"||e.state.selection.head<a.pos&&!s?1:-1;c=Qu(e,u,a,d)}return c}function Yu(e){return e.editable?e.hasFocus():cb(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function ya(e,t=!1){let n=e.state.selection;if(lb(e,n),!!Yu(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Ht){let r=e.domSelectionRange(),o=e.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Vu(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)ab(e);else{let{anchor:r,head:o}=n,s,i;Nl&&!(n instanceof he)&&(n.$from.parent.inlineContent||(s=Ol(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(i=Ol(e,n.to))),e.docView.setSelection(r,o,e,t),Nl&&(s&&Il(s),i&&Il(i)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ib(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Nl=Rn||Ht&&Xu<63;function Ol(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Rn&&o&&o.contentEditable=="false")return Hs(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return Hs(o);if(s)return Hs(s)}}function Hs(e){return e.contentEditable="true",Rn&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Il(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function ib(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!Yu(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function ab(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,Mn(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&Br&&Gu<=11&&(n.disabled=!0,n.disabled=!1)}function lb(e,t){if(t instanceof de){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Pl(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Pl(e)}function Pl(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Qu(e,t,n,r){return e.someProp("createSelectionBetween",o=>o(e,t,n))||he.between(t,n,r)}function cb(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Ei(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),s=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return s&&pe.findFrom(s,t)}function Gt(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Ll(e,t,n){let r=e.state.selection;if(r instanceof he)if(n.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=e.state.doc.resolve(o.pos+s.nodeSize*(t<0?-1:1));return Gt(e,new he(r.$anchor,i))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let o=Ei(e.state,t);return o&&o instanceof de?Gt(e,o):!1}else if(!(at&&n.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let a=t<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=e.docView.descAt(a))&&!i.contentDOM?de.isSelectable(s)?Gt(e,new de(t<0?e.state.doc.resolve(o.pos-s.nodeSize):o)):ba?Gt(e,new he(e.state.doc.resolve(t<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof de&&r.node.isInline)return Gt(e,new he(t>0?r.$to:r.$from));{let o=Ei(e.state,t);return o?Gt(e,o):!1}}}function Wo(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function wr(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function Dn(e,t){return t<0?ub(e):db(e)}function ub(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,s,i=!1;for(fs&&n.nodeType==1&&r<Wo(n)&&wr(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(wr(a,-1))o=n,s=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(Zu(n))break;{let a=n.previousSibling;for(;a&&wr(a,-1);)o=n.parentNode,s=Mn(a),a=a.previousSibling;if(a)n=a,r=Wo(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}i?Mi(e,n,r):o&&Mi(e,o,s)}function db(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o=Wo(n),s,i;for(;;)if(r<o){if(n.nodeType!=1)break;let a=n.childNodes[r];if(wr(a,1))s=n,i=++r;else break}else{if(Zu(n))break;{let a=n.nextSibling;for(;a&&wr(a,1);)s=a.parentNode,i=Mn(a)+1,a=a.nextSibling;if(a)n=a,r=0,o=Wo(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}s&&Mi(e,s,i)}function Zu(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function fb(e,t){for(;e&&t==e.childNodes.length&&!ma(e);)t=Mn(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=0}}function pb(e,t){for(;e&&!t&&!ma(e);)t=Mn(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function Mi(e,t,n){if(t.nodeType!=3){let s,i;(i=fb(t,n))?(t=i,n=0):(s=pb(t,n))&&(t=s,n=s.nodeValue.length)}let r=e.domSelection();if(!r)return;if(qu(r)){let s=document.createRange();s.setEnd(t,n),s.setStart(t,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&ya(e)},50)}function Dl(e,t){let n=e.state.doc.resolve(t);if(!(Ht||Ju)&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let s=e.coordsAtPos(t-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(t<n.end()){let s=e.coordsAtPos(t+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function jl(e,t,n){let r=e.state.selection;if(r instanceof he&&!r.empty||n.indexOf("s")>-1||at&&n.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let i=Ei(e.state,t);if(i&&i instanceof de)return Gt(e,i)}if(!o.parent.inlineContent){let i=t<0?o:s,a=r instanceof Et?pe.near(i,t):pe.findFrom(i,t);return a?Gt(e,a):!1}return!1}function zl(e,t){if(!(e.state.selection instanceof he))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let i=e.state.tr;return t<0?i.delete(n.pos-s.nodeSize,n.pos):i.delete(n.pos,n.pos+s.nodeSize),e.dispatch(i),!0}return!1}function _l(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function hb(e){if(!Rn||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let r=t.firstChild;_l(e,r,"true"),setTimeout(()=>_l(e,r,"false"),20)}return!1}function mb(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function gb(e,t){let n=t.keyCode,r=mb(t);if(n==8||at&&n==72&&r=="c")return zl(e,-1)||Dn(e,-1);if(n==46&&!t.shiftKey||at&&n==68&&r=="c")return zl(e,1)||Dn(e,1);if(n==13||n==27)return!0;if(n==37||at&&n==66&&r=="c"){let o=n==37?Dl(e,e.state.selection.from)=="ltr"?-1:1:-1;return Ll(e,o,r)||Dn(e,o)}else if(n==39||at&&n==70&&r=="c"){let o=n==39?Dl(e,e.state.selection.from)=="ltr"?1:-1:1;return Ll(e,o,r)||Dn(e,o)}else{if(n==38||at&&n==80&&r=="c")return jl(e,-1,r)||Dn(e,-1);if(n==40||at&&n==78&&r=="c")return hb(e)||jl(e,1,r)||Dn(e,1);if(r==(at?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ed(e,t){e.someProp("transformCopied",p=>{t=p(t,e)});let n=[],{content:r,openStart:o,openEnd:s}=t;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=e.someProp("clipboardSerializer")||cs.fromSchema(e.state.schema),a=id(),l=a.createElement("div");l.appendChild(i.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=sd[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let m=a.createElement(u[p]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=e.someProp("clipboardTextSerializer",p=>p(t,e))||t.content.textBetween(0,t.content.size,`
|
|
80
80
|
|
|
81
|
-
`);return{dom:l,text:f,slice:t}}function
|
|
82
|
-
`))),0,0),e.someProp("transformPasted",f=>{a=f(a,e,!0)}),a;let d=e.someProp("clipboardTextParser",f=>f(t,o,r,e));if(d)a=d;else{let f=o.marks(),{schema:p}=e.state,m=as.fromSchema(p);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(g=>{let b=i.appendChild(document.createElement("p"));g&&b.appendChild(m.serializeNode(p.text(g,f)))})}}else e.someProp("transformPastedHTML",d=>{n=d(n,e)}),i=yb(n),ma&&xb(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(a||(a=(e.someProp("clipboardParser")||e.someProp("domParser")||$o.fromSchema(e.state.schema)).parseSlice(i,{preserveWhitespace:!!(l||u),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!mb.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=vb(zl(a,+u[1],+u[2]),u[4]);else if(a=Z.maxOpen(gb(a.content,o),!0),a.openStart||a.openEnd){let d=0,f=0;for(let p=a.content.firstChild;d<a.openStart&&!p.type.spec.isolating;d++,p=p.firstChild);for(let p=a.content.lastChild;f<a.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);a=zl(a,d,f)}return e.someProp("transformPasted",d=>{a=d(a,e,l)}),a}const mb=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function gb(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o=t.node(n).contentMatchAt(t.index(n)),s,i=[];if(e.forEach(a=>{if(!i)return;let l=o.findWrapping(a.type),c;if(!l)return i=null;if(c=i.length&&s.length&&td(l,s,a,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=nd(i[i.length-1],s.length));let u=ed(a,l);i.push(u),o=o.matchType(u.type),s=l}}),i)return X.from(i)}return e}function ed(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,X.from(e));return e}function td(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let s=td(e,t,n,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(X.from(ed(n,e,o+1))))}}function nd(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,nd(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(X.empty,!0);return e.copy(n.append(r))}function Ei(e,t,n,r,o,s){let i=t<0?e.firstChild:e.lastChild,a=i.content;return e.childCount>1&&(s=0),o<r-1&&(a=Ei(a,t,n,r,o+1,s)),o>=n&&(a=t<0?i.contentMatchAt(0).fillBefore(a,s<=o).append(a):a.append(i.contentMatchAt(i.childCount).fillBefore(X.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,i.copy(a))}function zl(e,t,n){return t<e.openStart&&(e=new Z(Ei(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Z(Ei(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const rd={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let _l=null;function od(){return _l||(_l=document.implementation.createHTMLDocument("title"))}let Bs=null;function bb(e){let t=window.trustedTypes;return t?(Bs||(Bs=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Bs.createHTML(e)):e}function yb(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=od().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e),o;if((o=r&&rd[r[1].toLowerCase()])&&(e=o.map(s=>"<"+s+">").join("")+e+o.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=bb(e),o)for(let s=0;s<o.length;s++)n=n.querySelector(o[s])||n;return n}function xb(e){let t=e.querySelectorAll(Ht?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function vb(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:o,openStart:s,openEnd:i}=e;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;o=X.from(l.create(r[a+1],o)),s++,i++}return new Z(o,s,i)}const yt={},rt={};function Qt(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}rt.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!id(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(Hr&&Ht&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),ha&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",o=>o(e,Vu(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||hb(e,n)?n.preventDefault():Qt(e,"key")};rt.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};rt.keypress=(e,t)=>{let n=t;if(id(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||at&&n.metaKey)return;if(e.someProp("handleKeyPress",o=>o(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof he)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),s=()=>e.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!e.someProp("handleTextInput",i=>i(e,r.$from.pos,r.$to.pos,o,s))&&e.dispatch(s()),n.preventDefault()}};function ds(e){return{left:e.clientX,top:e.clientY}}function wb(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function ba(e,t,n,r,o){if(r==-1)return!1;let s=e.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(e.someProp(t,a=>i>s.depth?a(e,n,s.nodeAfter,s.before(i),o,!0):a(e,n,s.node(i),s.before(i),o,!1)))return!0;return!1}function qn(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function kb(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&de.isSelectable(r)?(qn(e,new de(n)),!0):!1}function Cb(e,t){if(t==-1)return!1;let n=e.state.selection,r,o;n instanceof de&&(r=n.node);let s=e.state.doc.resolve(t);for(let i=s.depth+1;i>0;i--){let a=i>s.depth?s.nodeAfter:s.node(i);if(de.isSelectable(a)){r&&n.$from.depth>0&&i>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?o=s.before(n.$from.depth):o=s.before(i);break}}return o!=null?(qn(e,de.create(e.state.doc,o)),!0):!1}function Sb(e,t,n,r,o){return ba(e,"handleClickOn",t,n,r)||e.someProp("handleClick",s=>s(e,t,r))||(o?Cb(e,n):kb(e,n))}function Tb(e,t,n,r){return ba(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",o=>o(e,t,r))}function Ab(e,t,n,r){return ba(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",o=>o(e,t,r))||Eb(e,n,r)}function Eb(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(qn(e,he.create(r,0,r.content.size)),!0):!1;let o=r.resolve(t);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),a=o.before(s);if(i.inlineContent)qn(e,he.create(r,a+1,a+1+i.content.size));else if(de.isSelectable(i))qn(e,de.create(r,a));else continue;return!0}}function ya(e){return Wo(e)}const sd=at?"metaKey":"ctrlKey";yt.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=ya(e),o=Date.now(),s="singleClick";o-e.input.lastClick.time<500&&wb(n,e.input.lastClick)&&!n[sd]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?s="doubleClick":e.input.lastClick.type=="doubleClick"&&(s="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:s,button:n.button};let i=e.posAtCoords(ds(n));i&&(s=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Mb(e,i,n,!!r)):(s=="doubleClick"?Tb:Ab)(e,i.pos,i.inside,n)?n.preventDefault():Qt(e,"pointer"))};class Mb{constructor(t,n,r,o){this.view=t,this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[sd],this.allowDefault=r.shiftKey;let s,i;if(n.inside>-1)s=t.state.doc.nodeAt(n.inside),i=n.inside;else{let u=t.state.doc.resolve(n.pos);s=u.parent,i=u.depth?u.before():0}const a=o?null:r.target,l=a?t.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=t.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof de&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&us&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Qt(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ga(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(ds(t))),this.updateAllowDefault(t),this.allowDefault||!n?Qt(this.view,"pointer"):Sb(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||Rn&&this.mightDrag&&!this.mightDrag.node.isAtom||Ht&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(qn(this.view,pe.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):Qt(this.view,"pointer")}move(t){this.updateAllowDefault(t),Qt(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}yt.touchstart=e=>{e.input.lastTouch=Date.now(),ya(e),Qt(e,"pointer")};yt.touchmove=e=>{e.input.lastTouch=Date.now(),Qt(e,"pointer")};yt.contextmenu=e=>ya(e);function id(e,t){return e.composing?!0:Rn&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const Rb=Hr?5e3:-1;rt.compositionstart=rt.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof he&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ht&&Gu&&Nb(e)))e.markCursor=e.state.storedMarks||n.marks(),Wo(e,!0),e.markCursor=null;else if(Wo(e,!t.selection.empty),us&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let a=e.domSelection();a&&a.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}e.input.composing=!0}ad(e,Rb)};function Nb(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}rt.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,ad(e,20))};function ad(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Wo(e),t))}function Ob(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Ib());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Ib(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function Wo(e,t=!1){if(!(Hr&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Ob(e),t||e.docView&&e.docView.dirty){let n=rb(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Pb(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}const Mr=Br&&Ku<15||ha&&nb<604;yt.copy=rt.cut=(e,t)=>{let n=t,r=e.state.selection,o=n.type=="cut";if(r.empty)return;let s=Mr?null:n.clipboardData,i=r.content(),{dom:a,text:l}=Qu(e,i);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):Pb(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Lb(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Db(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Mi(e,r.value,null,o,t):Mi(e,r.textContent,r.innerHTML,o,t)},50)}function Mi(e,t,n,r,o){let s=Zu(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",l=>l(e,o,s||Z.empty)))return!0;if(!s)return!1;let i=Lb(s),a=i?e.state.tr.replaceSelectionWith(i,r):e.state.tr.replaceSelection(s);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ld(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}rt.paste=(e,t)=>{let n=t;if(e.composing&&!Hr)return;let r=Mr?null:n.clipboardData,o=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Mi(e,ld(r),r.getData("text/html"),o,n)?n.preventDefault():Db(e,n)};class jb{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}}const zb=at?"altKey":"ctrlKey";function cd(e,t){let n;return e.someProp("dragCopies",r=>{n=n||r(t)}),n!=null?!n:!t[zb]}yt.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=e.state.selection,s=o.empty?null:e.posAtCoords(ds(n)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof de?o.to-1:o.to))){if(r&&r.mightDrag)i=de.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=e.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=e.docView&&(i=de.create(e.state.doc,d.posBefore))}}let a=(i||e.state.selection).content(),{dom:l,text:c,slice:u}=Qu(e,a);(!n.dataTransfer.files.length||!Ht||Uu>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Mr?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",Mr||n.dataTransfer.setData("text/plain",c),e.dragging=new jb(u,cd(e,n),i)};yt.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};rt.dragover=rt.dragenter=(e,t)=>t.preventDefault();rt.drop=(e,t)=>{try{_b(e,t,e.dragging)}finally{e.dragging=null}};function _b(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(ds(t));if(!r)return;let o=e.state.doc.resolve(r.pos),s=n&&n.slice;s?e.someProp("transformPasted",p=>{s=p(s,e,!1)}):s=Zu(e,ld(t.dataTransfer),Mr?null:t.dataTransfer.getData("text/html"),!1,o);let i=!!(n&&cd(e,t));if(e.someProp("handleDrop",p=>p(e,t,s||Z.empty,i))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Vg(e.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let l=e.state.tr;if(i){let{node:p}=n;p?p.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,s.content.firstChild):l.replaceRange(c,c,s),l.doc.eq(d))return;let f=l.doc.resolve(c);if(u&&de.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))l.setSelection(new de(f));else{let p=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,g,b,x)=>p=x),l.setSelection(Ju(e,f,l.doc.resolve(p)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}yt.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ga(e)},20))};yt.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};yt.beforeinput=(e,t)=>{if(Ht&&Hr&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",s=>s(e,Vu(8,"Backspace")))))return;let{$cursor:o}=e.state.selection;o&&o.pos>0&&e.dispatch(e.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let e in rt)yt[e]=rt[e];function Rr(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class Vo{constructor(t,n){this.toDOM=t,this.spec=n||yn,this.side=this.spec.side||0}map(t,n,r,o){let{pos:s,deleted:i}=t.mapResult(n.from+o,this.side<0?-1:1);return i?null:new tt(s-r,s-r,this)}valid(){return!0}eq(t){return this==t||t instanceof Vo&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Rr(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class Zt{constructor(t,n){this.attrs=t,this.spec=n||yn}map(t,n,r,o){let s=t.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,i=t.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new tt(s,i,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof Zt&&Rr(this.attrs,t.attrs)&&Rr(this.spec,t.spec)}static is(t){return t.type instanceof Zt}destroy(){}}class xa{constructor(t,n){this.attrs=t,this.spec=n||yn}map(t,n,r,o){let s=t.mapResult(n.from+o,1);if(s.deleted)return null;let i=t.mapResult(n.to+o,-1);return i.deleted||i.pos<=s.pos?null:new tt(s.pos-r,i.pos-r,this)}valid(t,n){let{index:r,offset:o}=t.content.findIndex(n.from),s;return o==n.from&&!(s=t.child(r)).isText&&o+s.nodeSize==n.to}eq(t){return this==t||t instanceof xa&&Rr(this.attrs,t.attrs)&&Rr(this.spec,t.spec)}destroy(){}}class tt{constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new tt(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new tt(t,t,new Vo(n,r))}static inline(t,n,r,o){return new tt(t,n,new Zt(r,o))}static node(t,n,r,o){return new tt(t,n,new xa(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Zt}get widget(){return this.type instanceof Vo}}const Hn=[],yn={};class Se{constructor(t,n){this.local=t.length?t:Hn,this.children=n.length?n:Hn}static create(t,n){return n.length?qo(n,t,0,yn):Fe}find(t,n,r){let o=[];return this.findInner(t??0,n??1e9,o,0,r),o}findInner(t,n,r,o,s){for(let i=0;i<this.local.length;i++){let a=this.local[i];a.from<=n&&a.to>=t&&(!s||s(a.spec))&&r.push(a.copy(a.from+o,a.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<n&&this.children[i+1]>t){let a=this.children[i]+1;this.children[i+2].findInner(t-a,n-a,r,o+a,s)}}map(t,n,r){return this==Fe||t.maps.length==0?this:this.mapInner(t,n,0,0,r||yn)}mapInner(t,n,r,o,s){let i;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(t,r,o);l&&l.type.valid(n,l)?(i||(i=[])).push(l):s.onRemove&&s.onRemove(this.local[a].spec)}return this.children.length?$b(this.children,i||[],t,n,r,o,s):i?new Se(i.sort(xn),Hn):Fe}add(t,n){return n.length?this==Fe?Se.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let o,s=0;t.forEach((a,l)=>{let c=l+r,u;if(u=dd(n,a,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<l;)s+=3;o[s]==l?o[s+2]=o[s+2].addInner(a,u,c+1):o.splice(s,0,l,l+a.nodeSize,qo(u,a,c+1,yn)),s+=3}});let i=ud(s?fd(n):n,-r);for(let a=0;a<i.length;a++)i[a].type.valid(t,i[a])||i.splice(a--,1);return new Se(i.length?this.local.concat(i).sort(xn):this.local,o||this.children)}remove(t){return t.length==0||this==Fe?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,a=r[s]+n,l=r[s+1]+n;for(let u=0,d;u<t.length;u++)(d=t[u])&&d.from>a&&d.to<l&&(t[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,a+1);c!=Fe?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<t.length;s++)if(i=t[s])for(let a=0;a<o.length;a++)o[a].eq(i,n)&&(o==this.local&&(o=this.local.slice()),o.splice(a--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new Se(o,r):Fe}forChild(t,n){if(this==Fe)return this;if(n.isLeaf)return Se.empty;let r,o;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=t){this.children[a]==t&&(r=this.children[a+2]);break}let s=t+1,i=s+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<i&&l.to>s&&l.type instanceof Zt){let c=Math.max(s,l.from)-s,u=Math.min(i,l.to)-s;c<u&&(o||(o=[])).push(l.copy(c,u))}}if(o){let a=new Se(o.sort(xn),Hn);return r?new bn([a,r]):a}return r||Fe}eq(t){if(this==t)return!0;if(!(t instanceof Se)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return va(this.localsInner(t))}localsInner(t){if(this==Fe)return Hn;if(t.inlineContent||!this.local.some(Zt.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Zt||n.push(this.local[r]);return n}forEachSet(t){t(this)}}Se.empty=new Se([],[]);Se.removeOverlap=va;const Fe=Se.empty;class bn{constructor(t){this.members=t}map(t,n){const r=this.members.map(o=>o.map(t,n,yn));return bn.from(r)}forChild(t,n){if(n.isLeaf)return Se.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(t,n);s!=Fe&&(s instanceof bn?r=r.concat(s.members):r.push(s))}return bn.from(r)}eq(t){if(!(t instanceof bn)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(t);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let i=0;i<s.length;i++)n.push(s[i])}}return n?va(r?n:n.sort(xn)):Hn}static from(t){switch(t.length){case 0:return Fe;case 1:return t[0];default:return new bn(t.every(n=>n instanceof Se)?t:t.reduce((n,r)=>n.concat(r instanceof Se?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}}function $b(e,t,n,r,o,s,i){let a=e.slice();for(let c=0,u=s;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,p,m,g)=>{let b=g-m-(p-f);for(let x=0;x<a.length;x+=3){let S=a[x+1];if(S<0||f>S+u-d)continue;let k=a[x]+u-d;p>=k?a[x+1]=f<=k?-2:-1:f>=u&&b&&(a[x]+=b,a[x+1]+=b)}d+=b}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=n.map(e[c]+s),d=u-o;if(d<0||d>=r.content.size){l=!0;continue}let f=n.map(e[c+1]+s,-1),p=f-o,{index:m,offset:g}=r.content.findIndex(d),b=r.maybeChild(m);if(b&&g==d&&g+b.nodeSize==p){let x=a[c+2].mapInner(n,b,u+1,e[c]+s+1,i);x!=Fe?(a[c]=d,a[c+1]=p,a[c+2]=x):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Fb(a,e,t,n,o,s,i),u=qo(c,r,0,i);t=u.local;for(let d=0;d<a.length;d+=3)a[d+1]<0&&(a.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let p=u.children[d];for(;f<a.length&&a[f]<p;)f+=3;a.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new Se(t.sort(xn),a)}function ud(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new tt(o.from+t,o.to+t,o.type))}return n}function Fb(e,t,n,r,o,s,i){function a(l,c){for(let u=0;u<l.local.length;u++){let d=l.local[u].map(r,o,c);d?n.push(d):i.onRemove&&i.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<e.length;l+=3)e[l+1]==-1&&a(e[l+2],t[l]+s+1);return n}function dd(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let s=0,i;s<e.length;s++)(i=e[s])&&i.from>n&&i.to<r&&((o||(o=[])).push(i),e[s]=null);return o}function fd(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function qo(e,t,n,r){let o=[],s=!1;t.forEach((a,l)=>{let c=dd(e,a,l+n);if(c){s=!0;let u=qo(c,a,n+l+1,r);u!=Fe&&o.push(l,l+a.nodeSize,u)}});let i=ud(s?fd(e):e,-n).sort(xn);for(let a=0;a<i.length;a++)i[a].type.valid(t,i[a])||(r.onRemove&&r.onRemove(i[a].spec),i.splice(a--,1));return i.length||o.length?new Se(i,o):Fe}function xn(e,t){return e.from-t.from||e.to-t.to}function va(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let s=t[o];if(s.from==r.from){s.to!=r.to&&(t==e&&(t=e.slice()),t[o]=s.copy(s.from,r.to),$l(t,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,s.from),$l(t,o,r.copy(s.from,r.to)));break}}}return t}function $l(e,t,n){for(;t<e.length&&xn(n,e[t])>0;)t++;e.splice(t,0,n)}var en={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ko={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Bb=typeof navigator<"u"&&/Mac/.test(navigator.platform),Hb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Oe=0;Oe<10;Oe++)en[48+Oe]=en[96+Oe]=String(Oe);for(var Oe=1;Oe<=24;Oe++)en[Oe+111]="F"+Oe;for(var Oe=65;Oe<=90;Oe++)en[Oe]=String.fromCharCode(Oe+32),Ko[Oe]=String.fromCharCode(Oe);for(var Hs in en)Ko.hasOwnProperty(Hs)||(Ko[Hs]=en[Hs]);function Wb(e){var t=Bb&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Hb&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Ko:en)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Vb=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),qb=typeof navigator<"u"&&/Win/.test(navigator.platform);function Kb(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,o,s,i;for(let a=0;a<t.length-1;a++){let l=t[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))Vb?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),i&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function Ub(e){let t=Object.create(null);for(let n in e)t[Kb(n)]=e[n];return t}function Ws(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Gb(e){let t=Ub(e);return function(n,r){let o=Wb(r),s,i=t[Ws(o,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let a=t[Ws(o,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(qb&&r.ctrlKey&&r.altKey)&&(s=en[r.keyCode])&&s!=o){let a=t[Ws(s,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}let Ri,Ni;if(typeof WeakMap<"u"){let e=new WeakMap;Ri=t=>e.get(t),Ni=(t,n)=>(e.set(t,n),n)}else{const e=[];let n=0;Ri=r=>{for(let o=0;o<e.length;o+=2)if(e[o]==r)return e[o+1]},Ni=(r,o)=>(n==10&&(n=0),e[n++]=r,e[n++]=o)}var ke=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,o=t/this.width|0;let s=r+1,i=o+1;for(let a=1;s<this.width&&this.map[t+a]==n;a++)s++;for(let a=1;i<this.height&&this.map[t+this.width*a]==n;a++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:r,right:o,top:s,bottom:i}=this.findCell(e);return t=="horiz"?(n<0?r==0:o==this.width)?null:this.map[s*this.width+(n<0?r-1:o)]:(n<0?s==0:i==this.height)?null:this.map[r+this.width*(n<0?s-1:i)]}rectBetween(e,t){const{left:n,right:r,top:o,bottom:s}=this.findCell(e),{left:i,right:a,top:l,bottom:c}=this.findCell(t);return{left:Math.min(n,i),top:Math.min(o,l),right:Math.max(r,a),bottom:Math.max(s,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let o=e.left;o<e.right;o++){const s=r*this.width+o,i=this.map[s];n[i]||(n[i]=!0,!(o==e.left&&o&&this.map[s-1]==i||r==e.top&&r&&this.map[s-this.width]==i)&&t.push(i))}return t}positionAt(e,t,n){for(let r=0,o=0;;r++){const s=o+n.child(r).nodeSize;if(r==e){let i=t+e*this.width;const a=(e+1)*this.width;for(;i<a&&this.map[i]<o;)i++;return i==a?s-1:this.map[i]}o=s}}static get(e){return Ri(e)||Ni(e,Xb(e))}};function Xb(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);const t=Jb(e),n=e.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,u=t*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const d=e.child(c);u++;for(let m=0;;m++){for(;o<r.length&&r[o]!=0;)o++;if(m==d.childCount)break;const g=d.child(m),{colspan:b,rowspan:x,colwidth:S}=g.attrs;for(let k=0;k<x;k++){if(k+c>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:x-k});break}const y=o+k*t;for(let T=0;T<b;T++){r[y+T]==0?r[y+T]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:b-T});const w=S&&S[T];if(w){const C=(y+T)%t*2,A=i[C];A==null||A!=w&&i[C+1]==1?(i[C]=w,i[C+1]=1):A==w&&i[C+1]++}}}o+=b,u+=g.nodeSize}const f=(c+1)*t;let p=0;for(;o<f;)r[o++]==0&&p++;p&&(s||(s=[])).push({type:"missing",row:c,n:p}),u++}(t===0||n===0)&&(s||(s=[])).push({type:"zero_sized"});const a=new ke(t,n,r,s);let l=!1;for(let c=0;!l&&c<i.length;c+=2)i[c]!=null&&i[c+1]<n&&(l=!0);return l&&Yb(a,i,e),a}function Jb(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){const o=e.child(r);let s=0;if(n)for(let i=0;i<r;i++){const a=e.child(i);for(let l=0;l<a.childCount;l++){const c=a.child(l);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){const a=o.child(i);s+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}t==-1?t=s:t!=s&&(t=Math.max(t,s))}return t}function Yb(e,t,n){e.problems||(e.problems=[]);const r={};for(let o=0;o<e.map.length;o++){const s=e.map[o];if(r[s])continue;r[s]=!0;const i=n.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let a=null;const l=i.attrs;for(let c=0;c<l.colspan;c++){const u=t[(o+c)%e.width*2];u!=null&&(!l.colwidth||l.colwidth[c]!=u)&&((a||(a=Qb(l)))[c]=u)}a&&e.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:a})}}function Qb(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Le(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],o=r.spec.tableRole;o&&(t[o]=r)}}return t}const Xt=new cs("selectingCells");function Cn(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function Zb(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function xt(e){const t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function fs(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;const n=Cn(t.$head)||ey(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function ey(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function Oi(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function ty(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function wa(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function pd(e,t,n){const r=e.node(-1),o=ke.get(r),s=e.start(-1),i=o.nextCell(e.pos-s,t,n);return i==null?null:e.node(0).resolve(s+i)}function Sn(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function hd(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(t,0,0)}return r}function ny(e,t,n){const r=Le(t.type.schema).header_cell;for(let o=0;o<e.height;o++)if(t.nodeAt(e.map[n+o*e.width]).type!=r)return!1;return!0}var be=class zt extends pe{constructor(t,n=t){const r=t.node(-1),o=ke.get(r),s=t.start(-1),i=o.rectBetween(t.pos-s,n.pos-s),a=t.node(0),l=o.cellsInRect(i).filter(u=>u!=n.pos-s);l.unshift(n.pos-s);const c=l.map(u=>{const d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const f=s+u+1;return new $u(a.resolve(f),a.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=t,this.$headCell=n}map(t,n){const r=t.resolve(n.map(this.$anchorCell.pos)),o=t.resolve(n.map(this.$headCell.pos));if(Oi(r)&&Oi(o)&&wa(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?zt.rowSelection(r,o):s&&this.isColSelection()?zt.colSelection(r,o):new zt(r,o)}return he.between(r,o)}content(){const t=this.$anchorCell.node(-1),n=ke.get(t),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let l=o.top;l<o.bottom;l++){const c=[];for(let u=l*n.width+o.left,d=o.left;d<o.right;d++,u++){const f=n.map[u];if(s[f])continue;s[f]=!0;const p=n.findCell(f);let m=t.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const g=o.left-p.left,b=p.right-o.right;if(g>0||b>0){let x=m.attrs;if(g>0&&(x=Sn(x,0,g)),b>0&&(x=Sn(x,x.colspan-b,b)),p.left<o.left){if(m=m.type.createAndFill(x),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(x)}`)}else m=m.type.create(x,m.content)}if(p.top<o.top||p.bottom>o.bottom){const x={...m.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?m=m.type.createAndFill(x):m=m.type.create(x,m.content)}c.push(m)}i.push(t.child(l).copy(X.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?t:i;return new Z(X.from(a),1,1)}replace(t,n=Z.empty){const r=t.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){const{$from:a,$to:l}=o[i],c=t.mapping.slice(r);t.replace(c.map(a.pos),c.map(l.pos),i?Z.empty:n)}const s=pe.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);s&&t.setSelection(s)}replaceWith(t,n){this.replace(t,new Z(X.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),r=ke.get(n),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)t(n.nodeAt(s[i]),o+s[i])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const r=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const r=t.node(-1),o=ke.get(r),s=t.start(-1),i=o.findCell(t.pos-s),a=o.findCell(n.pos-s),l=t.node(0);return i.top<=a.top?(i.top>0&&(t=l.resolve(s+o.map[i.left])),a.bottom<o.height&&(n=l.resolve(s+o.map[o.width*(o.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(s+o.map[a.left])),i.bottom<o.height&&(t=l.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new zt(t,n)}isRowSelection(){const t=this.$anchorCell.node(-1),n=ke.get(t),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),s=n.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,a=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,a)==n.width}eq(t){return t instanceof zt&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const r=t.node(-1),o=ke.get(r),s=t.start(-1),i=o.findCell(t.pos-s),a=o.findCell(n.pos-s),l=t.node(0);return i.left<=a.left?(i.left>0&&(t=l.resolve(s+o.map[i.top*o.width])),a.right<o.width&&(n=l.resolve(s+o.map[o.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(s+o.map[a.top*o.width])),i.right<o.width&&(t=l.resolve(s+o.map[o.width*(i.top+1)-1]))),new zt(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new zt(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new zt(t.resolve(n),t.resolve(r))}getBookmark(){return new ry(this.$anchorCell.pos,this.$headCell.pos)}};be.prototype.visible=!1;pe.jsonID("cell",be);var ry=class md{constructor(t,n){this.anchor=t,this.head=n}map(t){return new md(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),r=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&wa(n,r)?new be(n,r):pe.near(r,1)}};function oy(e){if(!(e.selection instanceof be))return null;const t=[];return e.selection.forEachCell((n,r)=>{t.push(tt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Se.create(e.doc,t)}function sy({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,o=e.depth;for(;o>=0&&!(e.after(o+1)<e.end(o));o--,n++);for(let s=t.depth;s>=0&&!(t.before(s+1)>t.start(s));s--,r--);return n==r&&/row|table/.test(e.node(o).type.spec.tableRole)}function iy({$from:e,$to:t}){let n,r;for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let o=t.depth;o>0;o--){const s=t.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&t.parentOffset===0}function ay(e,t,n){const r=(t||e).selection,o=(t||e).doc;let s,i;if(r instanceof de&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=be.create(o,r.from);else if(i=="row"){const a=o.resolve(r.from+1);s=be.rowSelection(a,a)}else if(!n){const a=ke.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];s=be.create(o,l+1,c)}}else r instanceof he&&sy(r)?s=he.create(o,r.from):r instanceof he&&iy(r)&&(s=he.create(o,r.$from.start(),r.$from.end()));return s&&(t||(t=e.tr)).setSelection(s),t}const ly=new cs("fix-tables");function gd(e,t,n,r){const o=e.childCount,s=t.childCount;e:for(let i=0,a=0;i<s;i++){const l=t.child(i);for(let c=a,u=Math.min(o,i+3);c<u;c++)if(e.child(c)==l){a=c+1,n+=l.nodeSize;continue e}r(l,n),a<o&&e.child(a).sameMarkup(l)?gd(e.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function bd(e,t){let n;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(n=cy(e,o,s,n))};return t?t.doc!=e.doc&&gd(t.doc,e.doc,0,r):e.doc.descendants(r),n}function cy(e,t,n,r){const o=ke.get(t);if(!o.problems)return r;r||(r=e.tr);const s=[];for(let l=0;l<o.height;l++)s.push(0);for(let l=0;l<o.problems.length;l++){const c=o.problems[l];if(c.type=="collision"){const u=t.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)s[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Sn(d,d.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=t.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=t.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+t.nodeSize)}}let i,a;for(let l=0;l<s.length;l++)s[l]&&(i==null&&(i=l),a=l);for(let l=0,c=n+1;l<o.height;l++){const u=t.child(l),d=c+u.nodeSize,f=s[l];if(f>0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);const m=[];for(let b=0;b<f;b++){const x=Le(e.schema)[p].createAndFill();x&&m.push(x)}const g=(l==0||i==l-1)&&a==l?c+1:d-1;r.insert(r.mapping.map(g),m)}c=d}return r.setMeta(ly,{fixTables:!0})}function Pt(e){const t=e.selection,n=fs(e),r=n.node(-1),o=n.start(-1),s=ke.get(r);return{...t instanceof be?s.rectBetween(t.$anchorCell.pos-o,t.$headCell.pos-o):s.findCell(n.pos-o),tableStart:o,map:s,table:r}}function yd(e,{map:t,tableStart:n,table:r},o){let s=o>0?-1:0;ny(t,r,o+s)&&(s=o==0||o==t.width?null:0);for(let i=0;i<t.height;i++){const a=i*t.width+o;if(o>0&&o<t.width&&t.map[a-1]==t.map[a]){const l=t.map[a],c=r.nodeAt(l);e.setNodeMarkup(e.mapping.map(n+l),null,hd(c.attrs,o-t.colCount(l))),i+=c.attrs.rowspan-1}else{const l=s==null?Le(r.type.schema).cell:r.nodeAt(t.map[a+s]).type,c=t.positionAt(i,o,r);e.insert(e.mapping.map(n+c),l.createAndFill())}}return e}function uy(e,t){if(!xt(e))return!1;if(t){const n=Pt(e);t(yd(e.tr,n,n.left))}return!0}function dy(e,t){if(!xt(e))return!1;if(t){const n=Pt(e);t(yd(e.tr,n,n.right))}return!0}function fy(e,{map:t,table:n,tableStart:r},o){const s=e.mapping.maps.length;for(let i=0;i<t.height;){const a=i*t.width+o,l=t.map[a],c=n.nodeAt(l),u=c.attrs;if(o>0&&t.map[a-1]==l||o<t.width-1&&t.map[a+1]==l)e.setNodeMarkup(e.mapping.slice(s).map(r+l),null,Sn(u,o-t.colCount(l)));else{const d=e.mapping.slice(s).map(r+l);e.delete(d,d+c.nodeSize)}i+=u.rowspan}}function py(e,t){if(!xt(e))return!1;if(t){const n=Pt(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;fy(r,n,o),o!=n.left;o--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=ke.get(s)}t(r)}return!0}function hy(e,t,n){var r;const o=Le(t.type.schema).header_cell;for(let s=0;s<e.width;s++)if(((r=t.nodeAt(e.map[s+n*e.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function xd(e,{map:t,tableStart:n,table:r},o){let s=n;for(let c=0;c<o;c++)s+=r.child(c).nodeSize;const i=[];let a=o>0?-1:0;hy(t,r,o+a)&&(a=o==0||o==t.height?null:0);for(let c=0,u=t.width*o;c<t.width;c++,u++)if(o>0&&o<t.height&&t.map[u]==t.map[u-t.width]){const d=t.map[u],f=r.nodeAt(d).attrs;e.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var l;const d=a==null?Le(r.type.schema).cell:(l=r.nodeAt(t.map[u+a*t.width]))===null||l===void 0?void 0:l.type,f=d?.createAndFill();f&&i.push(f)}return e.insert(s,Le(r.type.schema).row.create(null,i)),e}function my(e,t){if(!xt(e))return!1;if(t){const n=Pt(e);t(xd(e.tr,n,n.top))}return!0}function gy(e,t){if(!xt(e))return!1;if(t){const n=Pt(e);t(xd(e.tr,n,n.bottom))}return!0}function by(e,{map:t,table:n,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=n.child(c).nodeSize;const i=s+n.child(o).nodeSize,a=e.mapping.maps.length;e.delete(s+r,i+r);const l=new Set;for(let c=0,u=o*t.width;c<t.width;c++,u++){const d=t.map[u];if(!l.has(d)){if(l.add(d),o>0&&d==t.map[u-t.width]){const f=n.nodeAt(d).attrs;e.setNodeMarkup(e.mapping.slice(a).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<t.height&&d==t.map[u+t.width]){const f=n.nodeAt(d),p=f.attrs,m=f.type.create({...p,rowspan:f.attrs.rowspan-1},f.content),g=t.positionAt(o+1,c,n);e.insert(e.mapping.slice(a).map(r+g),m),c+=p.colspan-1}}}}function yy(e,t){if(!xt(e))return!1;if(t){const n=Pt(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;by(r,n,o),o!=n.top;o--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=ke.get(n.table)}t(r)}return!0}function Fl(e){const t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function xy({width:e,height:t,map:n},r){let o=r.top*e+r.left,s=o,i=(r.bottom-1)*e+r.left,a=o+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[s]==n[s-1]||r.right<e&&n[a]==n[a+1])return!0;s+=e,a+=e}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[o]==n[o-e]||r.bottom<t&&n[i]==n[i+e])return!0;o++,i++}return!1}function Bl(e,t){const n=e.selection;if(!(n instanceof be)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Pt(e),{map:o}=r;if(xy(o,r))return!1;if(t){const s=e.tr,i={};let a=X.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const f=o.map[u*o.width+d],p=r.table.nodeAt(f);if(!(i[f]||!p))if(i[f]=!0,l==null)l=f,c=p;else{Fl(p)||(a=a.append(p.content));const m=s.mapping.map(f+r.tableStart);s.delete(m,m+p.nodeSize)}}if(l==null||c==null)return!0;if(s.setNodeMarkup(l+r.tableStart,null,{...hd(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const u=l+1+c.content.size,d=Fl(c)?l+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,a)}s.setSelection(new be(s.doc.resolve(l+r.tableStart))),t(s)}return!0}function Hl(e,t){const n=Le(e.schema);return vy(({node:r})=>n[r.type.spec.tableRole])(e,t)}function vy(e){return(t,n)=>{const r=t.selection;let o,s;if(r instanceof be){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{var i;if(o=Zb(r.$from),!o)return!1;s=(i=Cn(r.$from))===null||i===void 0?void 0:i.pos}if(o==null||s==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let a=o.attrs;const l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const u=Pt(t),d=t.tr;for(let p=0;p<u.right-u.left;p++)l.push(c?{...a,colwidth:c&&c[p]?[c[p]]:null}:a);let f;for(let p=u.top;p<u.bottom;p++){let m=u.map.positionAt(p,u.left,u.table);p==u.top&&(m+=o.nodeSize);for(let g=u.left,b=0;g<u.right;g++,b++)g==u.left&&p==u.top||d.insert(f=d.mapping.map(m+u.tableStart,1),e({node:o,row:p,col:g}).createAndFill(l[b]))}d.setNodeMarkup(s,e({node:o,row:u.top,col:u.left}),l[0]),r instanceof be&&d.setSelection(new be(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function wy(e,t){return function(n,r){if(!xt(n))return!1;const o=fs(n);if(o.nodeAfter.attrs[e]===t)return!1;if(r){const s=n.tr;n.selection instanceof be?n.selection.forEachCell((i,a)=>{i.attrs[e]!==t&&s.setNodeMarkup(a,null,{...i.attrs,[e]:t})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[e]:t}),r(s)}return!0}}function ky(e){return function(t,n){if(!xt(t))return!1;if(n){const r=Le(t.schema),o=Pt(t),s=t.tr,i=o.map.cellsInRect(e=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:e=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),a=i.map(l=>o.table.nodeAt(l));for(let l=0;l<i.length;l++)a[l].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[l],r.cell,a[l].attrs);if(s.steps.length===0)for(let l=0;l<i.length;l++)s.setNodeMarkup(o.tableStart+i[l],r.header_cell,a[l].attrs);n(s)}return!0}}function Wl(e,t,n){const r=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let o=0;o<r.length;o++){const s=t.table.nodeAt(r[o]);if(s&&s.type!==n.header_cell)return!1}return!0}function Nr(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?ky(e):function(n,r){if(!xt(n))return!1;if(r){const o=Le(n.schema),s=Pt(n),i=n.tr,a=Wl("row",s,o),l=Wl("column",s,o),c=(e==="column"?a:e==="row"&&l)?1:0,u=e=="column"?{left:0,top:c,right:1,bottom:s.map.height}:e=="row"?{left:c,top:0,right:s.map.width,bottom:1}:s,d=e=="column"?l?o.cell:o.header_cell:e=="row"?a?o.cell:o.header_cell:o.cell;s.map.cellsInRect(u).forEach(f=>{const p=f+s.tableStart,m=i.doc.nodeAt(p);m&&i.setNodeMarkup(p,d,m.attrs)}),r(i)}return!0}}Nr("row",{useDeprecatedLogic:!0});Nr("column",{useDeprecatedLogic:!0});const Cy=Nr("cell",{useDeprecatedLogic:!0});function Sy(e,t){if(t<0){const n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let r=e.index(-1)-1,o=e.before();r>=0;r--){const s=e.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const n=e.node(-1);for(let r=e.indexAfter(-1),o=e.after();r<n.childCount;r++){const s=n.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function Vl(e){return function(t,n){if(!xt(t))return!1;const r=Sy(fs(t),e);if(r==null)return!1;if(n){const o=t.doc.resolve(r);n(t.tr.setSelection(he.between(o,ty(o))).scrollIntoView())}return!0}}function Ty(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function uo(e,t){const n=e.selection;if(!(n instanceof be))return!1;if(t){const r=e.tr,o=Le(e.schema).cell.createAndFill().content;n.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new Z(o,0,0))}),r.docChanged&&t(r)}return!0}function Ay(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole=="table");)n--,r--,t=t.child(0).content;const o=t.child(0),s=o.type.spec.tableRole,i=o.type.schema,a=[];if(s=="row")for(let l=0;l<t.childCount;l++){let c=t.child(l).content;const u=l?0:Math.max(0,n-1),d=l<t.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Ii(Le(i).row,new Z(c,u,d)).content),a.push(c)}else if(s=="cell"||s=="header_cell")a.push(n||r?Ii(Le(i).row,new Z(t,n,r)).content:t);else return null;return Ey(i,a)}function Ey(e,t){const n=[];for(let o=0;o<t.length;o++){const s=t[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:a,colspan:l}=s.child(i).attrs;for(let c=o;c<o+a;c++)n[c]=(n[c]||0)+l}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=t.length&&t.push(X.empty),n[o]<r){const s=Le(e).cell.createAndFill(),i=[];for(let a=n[o];a<r;a++)i.push(s);t[o]=t[o].append(X.from(i))}return{height:t.length,width:r,rows:t}}function Ii(e,t){const n=e.createAndFill();return new Qg(n).replace(0,n.content.size,t).doc}function My({width:e,height:t,rows:n},r,o){if(e!=r){const s=[],i=[];for(let a=0;a<n.length;a++){const l=n[a],c=[];for(let u=s[a]||0,d=0;u<r;d++){let f=l.child(d%l.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(Sn(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let p=1;p<f.attrs.rowspan;p++)s[a+p]=(s[a+p]||0)+f.attrs.colspan}i.push(X.from(c))}n=i,e=r}if(t!=o){const s=[];for(let i=0,a=0;i<o;i++,a++){const l=[],c=n[a%t];for(let u=0;u<c.childCount;u++){let d=c.child(u);i+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),l.push(d)}s.push(X.from(l))}n=s,t=o}return{width:e,height:t,rows:n}}function Ry(e,t,n,r,o,s,i){const a=e.doc.type.schema,l=Le(a);let c,u;if(o>t.width)for(let d=0,f=0;d<t.height;d++){const p=n.child(d);f+=p.nodeSize;const m=[];let g;p.lastChild==null||p.lastChild.type==l.cell?g=c||(c=l.cell.createAndFill()):g=u||(u=l.header_cell.createAndFill());for(let b=t.width;b<o;b++)m.push(g);e.insert(e.mapping.slice(i).map(f-1+r),m)}if(s>t.height){const d=[];for(let m=0,g=(t.height-1)*t.width;m<Math.max(t.width,o);m++){const b=m>=t.width?!1:n.nodeAt(t.map[g+m]).type==l.header_cell;d.push(b?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const f=l.row.create(null,X.from(d)),p=[];for(let m=t.height;m<s;m++)p.push(f);e.insert(e.mapping.slice(i).map(r+n.nodeSize-2),p)}return!!(c||u)}function ql(e,t,n,r,o,s,i,a){if(i==0||i==t.height)return!1;let l=!1;for(let c=o;c<s;c++){const u=i*t.width+c,d=t.map[u];if(t.map[u-t.width]==d){l=!0;const f=n.nodeAt(d),{top:p,left:m}=t.findCell(d);e.setNodeMarkup(e.mapping.slice(a).map(d+r),null,{...f.attrs,rowspan:i-p}),e.insert(e.mapping.slice(a).map(t.positionAt(i,m,n)),f.type.createAndFill({...f.attrs,rowspan:p+f.attrs.rowspan-i})),c+=f.attrs.colspan-1}}return l}function Kl(e,t,n,r,o,s,i,a){if(i==0||i==t.width)return!1;let l=!1;for(let c=o;c<s;c++){const u=c*t.width+i,d=t.map[u];if(t.map[u-1]==d){l=!0;const f=n.nodeAt(d),p=t.colCount(d),m=e.mapping.slice(a).map(d+r);e.setNodeMarkup(m,null,Sn(f.attrs,i-p,f.attrs.colspan-(i-p))),e.insert(m+f.nodeSize,f.type.createAndFill(Sn(f.attrs,0,i-p))),c+=f.attrs.rowspan-1}}return l}function Ul(e,t,n,r,o){let s=n?e.doc.nodeAt(n-1):e.doc;if(!s)throw new Error("No table found");let i=ke.get(s);const{top:a,left:l}=r,c=l+o.width,u=a+o.height,d=e.tr;let f=0;function p(){if(s=n?d.doc.nodeAt(n-1):d.doc,!s)throw new Error("No table found");i=ke.get(s),f=d.mapping.maps.length}Ry(d,i,s,n,c,u,f)&&p(),ql(d,i,s,n,l,c,a,f)&&p(),ql(d,i,s,n,l,c,u,f)&&p(),Kl(d,i,s,n,a,u,l,f)&&p(),Kl(d,i,s,n,a,u,c,f)&&p();for(let m=a;m<u;m++){const g=i.positionAt(m,l,s),b=i.positionAt(m,c,s);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(b+n),new Z(o.rows[m-a],0,0))}p(),d.setSelection(new be(d.doc.resolve(n+i.positionAt(a,l,s)),d.doc.resolve(n+i.positionAt(u-1,c-1,s)))),t(d)}const Ny=Gb({ArrowLeft:fo("horiz",-1),ArrowRight:fo("horiz",1),ArrowUp:fo("vert",-1),ArrowDown:fo("vert",1),"Shift-ArrowLeft":po("horiz",-1),"Shift-ArrowRight":po("horiz",1),"Shift-ArrowUp":po("vert",-1),"Shift-ArrowDown":po("vert",1),Backspace:uo,"Mod-Backspace":uo,Delete:uo,"Mod-Delete":uo});function Mo(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function fo(e,t){return(n,r,o)=>{if(!o)return!1;const s=n.selection;if(s instanceof be)return Mo(n,r,pe.near(s.$headCell,t));if(e!="horiz"&&!s.empty)return!1;const i=vd(o,e,t);if(i==null)return!1;if(e=="horiz")return Mo(n,r,pe.near(n.doc.resolve(s.head+t),t));{const a=n.doc.resolve(i),l=pd(a,e,t);let c;return l?c=pe.near(l,1):t<0?c=pe.near(n.doc.resolve(a.before(-1)),-1):c=pe.near(n.doc.resolve(a.after(-1)),1),Mo(n,r,c)}}}function po(e,t){return(n,r,o)=>{if(!o)return!1;const s=n.selection;let i;if(s instanceof be)i=s;else{const l=vd(o,e,t);if(l==null)return!1;i=new be(n.doc.resolve(l))}const a=pd(i.$headCell,e,t);return a?Mo(n,r,new be(i.$anchorCell,a)):!1}}function Oy(e,t){const n=e.state.doc,r=Cn(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new be(r))),!0):!1}function Iy(e,t,n){if(!xt(e.state))return!1;let r=Ay(n);const o=e.state.selection;if(o instanceof be){r||(r={width:1,height:1,rows:[X.from(Ii(Le(e.state.schema).cell,n))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),a=ke.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=My(r,a.right-a.left,a.bottom-a.top),Ul(e.state,e.dispatch,i,a,r),!0}else if(r){const s=fs(e.state),i=s.start(-1);return Ul(e.state,e.dispatch,i,ke.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function Py(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;const r=Gl(e,t.target);let o;if(t.shiftKey&&e.state.selection instanceof be)s(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&(o=Cn(e.state.selection.$anchor))!=null&&((n=Vs(e,t))===null||n===void 0?void 0:n.pos)!=o.pos)s(o,t),t.preventDefault();else if(!r)return;function s(l,c){let u=Vs(e,c);const d=Xt.getState(e.state)==null;if(!u||!wa(l,u))if(d)u=l;else return;const f=new be(l,u);if(d||!e.state.selection.eq(f)){const p=e.state.tr.setSelection(f);d&&p.setMeta(Xt,l.pos),e.dispatch(p)}}function i(){e.root.removeEventListener("mouseup",i),e.root.removeEventListener("dragstart",i),e.root.removeEventListener("mousemove",a),Xt.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Xt,-1))}function a(l){const c=l,u=Xt.getState(e.state);let d;if(u!=null)d=e.state.doc.resolve(u);else if(Gl(e,c.target)!=r&&(d=Vs(e,t),!d))return i();d&&s(d,c)}e.root.addEventListener("mouseup",i),e.root.addEventListener("dragstart",i),e.root.addEventListener("mousemove",a)}function vd(e,t,n){if(!(e.state.selection instanceof he))return null;const{$head:r}=e.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const i=r.before(o),a=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(a)?i:null}}return null}function Gl(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function Vs(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&Cn(e.state.doc.resolve(r))||Cn(e.state.doc.resolve(o))}var Ly=class{constructor(t,n){this.node=t,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Pi(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Pi(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Pi(e,t,n,r,o,s){let i=0,a=!0,l=t.firstChild;const c=e.firstChild;if(c){for(let d=0,f=0;d<c.childCount;d++){const{colspan:p,colwidth:m}=c.child(d).attrs;for(let g=0;g<p;g++,f++){const b=o==f?s:m&&m[g],x=b?b+"px":"";if(i+=b||r,b||(a=!1),l)l.style.width!=x&&(l.style.width=x),l=l.nextSibling;else{const S=document.createElement("col");S.style.width=x,t.appendChild(S)}}}for(;l;){var u;const d=l.nextSibling;(u=l.parentNode)===null||u===void 0||u.removeChild(l),l=d}a?(n.style.width=i+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=i+"px")}}const Ze=new cs("tableColumnResizing");function Dy({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Ly,lastColumnResizable:o=!0}={}){const s=new fa({key:Ze,state:{init(i,a){var l;const c=(l=s.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,u=Le(a.schema).table.name;return r&&c&&(c[u]=(d,f)=>new r(d,n,f)),new jy(-1,!1)},apply(i,a){return a.apply(i)}},props:{attributes:i=>{const a=Ze.getState(i);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,a)=>{zy(i,a,e,o)},mouseleave:i=>{_y(i)},mousedown:(i,a)=>{$y(i,a,t,n)}},decorations:i=>{const a=Ze.getState(i);if(a&&a.activeHandle>-1)return Vy(i,a.activeHandle)},nodeViews:{}}});return s}var jy=class Ro{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){const n=this,r=t.getMeta(Ze);if(r&&r.setHandle!=null)return new Ro(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Ro(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let o=t.mapping.map(n.activeHandle,-1);return Oi(t.doc.resolve(o))||(o=-1),new Ro(o,n.dragging)}return n}};function zy(e,t,n,r){if(!e.editable)return;const o=Ze.getState(e.state);if(o&&!o.dragging){const s=By(t.target);let i=-1;if(s){const{left:a,right:l}=s.getBoundingClientRect();t.clientX-a<=n?i=Xl(e,t,"left",n):l-t.clientX<=n&&(i=Xl(e,t,"right",n))}if(i!=o.activeHandle){if(!r&&i!==-1){const a=e.state.doc.resolve(i),l=a.node(-1),c=ke.get(l),u=a.start(-1);if(c.colCount(a.pos-u)+a.nodeAfter.attrs.colspan-1==c.width-1)return}wd(e,i)}}}function _y(e){if(!e.editable)return;const t=Ze.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&wd(e,-1)}function $y(e,t,n,r){var o;if(!e.editable)return!1;const s=(o=e.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,i=Ze.getState(e.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const a=e.state.doc.nodeAt(i.activeHandle),l=Fy(e,i.activeHandle,a.attrs);e.dispatch(e.state.tr.setMeta(Ze,{setDragging:{startX:t.clientX,startWidth:l}}));function c(d){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",u);const f=Ze.getState(e.state);f?.dragging&&(Hy(e,f.activeHandle,Jl(f.dragging,d,n)),e.dispatch(e.state.tr.setMeta(Ze,{setDragging:null})))}function u(d){if(!d.which)return c(d);const f=Ze.getState(e.state);if(f&&f.dragging){const p=Jl(f.dragging,d,n);Yl(e,f.activeHandle,p,r)}}return Yl(e,i.activeHandle,l,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",u),t.preventDefault(),!0}function Fy(e,t,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const s=e.domAtPos(t);let i=s.node.childNodes[s.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(i-=r[l],a--);return i/a}function By(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function Xl(e,t,n,r){const o=n=="right"?-r:r,s=e.posAtCoords({left:t.clientX+o,top:t.clientY});if(!s)return-1;const{pos:i}=s,a=Cn(e.state.doc.resolve(i));if(!a)return-1;if(n=="right")return a.pos;const l=ke.get(a.node(-1)),c=a.start(-1),u=l.map.indexOf(a.pos-c);return u%l.width==0?-1:c+l.map[u-1]}function Jl(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function wd(e,t){e.dispatch(e.state.tr.setMeta(Ze,{setHandle:t}))}function Hy(e,t,n){const r=e.state.doc.resolve(t),o=r.node(-1),s=ke.get(o),i=r.start(-1),a=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let c=0;c<s.height;c++){const u=c*s.width+a;if(c&&s.map[u]==s.map[u-s.width])continue;const d=s.map[u],f=o.nodeAt(d).attrs,p=f.colspan==1?0:a-s.colCount(d);if(f.colwidth&&f.colwidth[p]==n)continue;const m=f.colwidth?f.colwidth.slice():Wy(f.colspan);m[p]=n,l.setNodeMarkup(i+d,null,{...f,colwidth:m})}l.docChanged&&e.dispatch(l)}function Yl(e,t,n,r){const o=e.state.doc.resolve(t),s=o.node(-1),i=o.start(-1),a=ke.get(s).colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1;let l=e.domAtPos(o.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Pi(s,l.firstChild,l,r,a,n)}function Wy(e){return Array(e).fill(0)}function Vy(e,t){const n=[],r=e.doc.resolve(t),o=r.node(-1);if(!o)return Se.empty;const s=ke.get(o),i=r.start(-1),a=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const u=a+c*s.width;if((a==s.width-1||s.map[u]!=s.map[u+1])&&(c==0||s.map[u]!=s.map[u-s.width])){var l;const d=s.map[u],f=i+d+o.nodeAt(d).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((l=Ze.getState(e))===null||l===void 0)&&l.dragging&&n.push(tt.node(i+d,i+d+o.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(tt.widget(f,p))}}return Se.create(e.doc,n)}function qy({allowTableNodeSelection:e=!1}={}){return new fa({key:Xt,state:{init(){return null},apply(t,n){const r=t.getMeta(Xt);if(r!=null)return r==-1?null:r;if(n==null||!t.docChanged)return n;const{deleted:o,pos:s}=t.mapping.mapResult(n);return o?null:s}},props:{decorations:oy,handleDOMEvents:{mousedown:Py},createSelectionBetween(t){return Xt.getState(t.state)!=null?t.state.selection:null},handleTripleClick:Oy,handleKeyDown:Ny,handlePaste:Iy},appendTransaction(t,n,r){return ay(r,bd(r,n),e)}})}function Uo(e){return e==="left"||e==="right"||e==="center"?e:null}function Ky(e){const t=(e.style.textAlign||"").trim().toLowerCase(),n=(e.getAttribute("align")||"").trim().toLowerCase();return Uo(t||n)}function Uy(e){return Uo(e?.align)}function kd(){return{default:null,parseHTML:e=>Ky(e),renderHTML:e=>e.align?{style:`text-align: ${e.align}`}:{}}}var Cd=P.Node.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{var t,n;const r=e.getAttribute("colwidth"),o=r?r.split(",").map(s=>parseInt(s,10)):null;if(!o){const s=(t=e.closest("table"))==null?void 0:t.querySelectorAll("colgroup > col"),i=Array.from(((n=e.parentElement)==null?void 0:n.children)||[]).indexOf(e);if(i&&i>-1&&s&&s[i]){const a=s[i].getAttribute("width");return a?[parseInt(a,10)]:null}}return o}},align:kd()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",P.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Sd=P.Node.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}},align:kd()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",P.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Td=P.Node.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",P.mergeAttributes(this.options.HTMLAttributes,e),0]}});function Li(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function Ql(e,t,n,r,o,s){var i;let a=0,l=!0,c=t.firstChild;const u=e.firstChild;if(u!==null)for(let f=0,p=0;f<u.childCount;f+=1){const{colspan:m,colwidth:g}=u.child(f).attrs;for(let b=0;b<m;b+=1,p+=1){const x=o===p?s:g&&g[b],S=x?`${x}px`:"";if(a+=x||r,x||(l=!1),c){if(c.style.width!==S){const[k,y]=Li(r,x);c.style.setProperty(k,y)}c=c.nextSibling}else{const k=document.createElement("col"),[y,T]=Li(r,x);k.style.setProperty(y,T),t.appendChild(k)}}}for(;c;){const f=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=f}const d=e.attrs.style&&typeof e.attrs.style=="string"&&/\bwidth\s*:/i.test(e.attrs.style);l&&!d?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}var Gy=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),e.attrs.style&&(this.table.style.cssText=e.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ql(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Ql(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){const t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!!(n&&!r&&(e.type==="attributes"||e.type==="childList"||e.type==="characterData"))}};function Xy(e,t,n,r){let o=0,s=!0;const i=[],a=e.firstChild;if(!a)return{};for(let d=0,f=0;d<a.childCount;d+=1){const{colspan:p,colwidth:m}=a.child(d).attrs;for(let g=0;g<p;g+=1,f+=1){const b=n===f?r:m&&m[g];o+=b||t,b||(s=!1);const[x,S]=Li(t,b);i.push(["col",{style:`${x}: ${S}`}])}}const l=s?`${o}px`:"",c=s?"":`${o}px`;return{colgroup:["colgroup",{},...i],tableWidth:l,tableMinWidth:c}}function Zl(e,t){return e.createAndFill()}function Jy(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function Yy(e,t,n,r,o){const s=Jy(e),i=[],a=[];for(let c=0;c<n;c+=1){const u=Zl(s.cell);if(u&&a.push(u),r){const d=Zl(s.header_cell);d&&i.push(d)}}const l=[];for(let c=0;c<t;c+=1)l.push(s.row.createChecked(null,r&&c===0?i:a));return s.table.createChecked(null,l)}function Qy(e){return e instanceof be}var ho=({editor:e})=>{const{selection:t}=e.state;if(!Qy(t))return!1;let n=0;const r=P.findParentNodeClosestToPos(t.ranges[0].$from,s=>s.type.name==="table");return r?.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},Zy="";function ex(e){return(e||"").replace(/\s+/g," ").trim()}function tx(e,t,n={}){var r;const o=(r=n.cellLineSeparator)!=null?r:Zy;if(!e||!e.content||e.content.length===0)return"";const s=[];e.content.forEach(g=>{const b=[];g.content&&g.content.forEach(x=>{let S="";x.content&&Array.isArray(x.content)&&x.content.length>1?S=x.content.map(C=>t.renderChildren(C)).join(o):S=x.content?t.renderChildren(x.content):"";const k=ex(S),y=x.type==="tableHeader",T=Uy(x.attrs);b.push({text:k,isHeader:y,align:T})}),s.push(b)});const i=s.reduce((g,b)=>Math.max(g,b.length),0);if(i===0)return"";const a=new Array(i).fill(0);s.forEach(g=>{var b;for(let x=0;x<i;x+=1){const k=(((b=g[x])==null?void 0:b.text)||"").length;k>a[x]&&(a[x]=k),a[x]<3&&(a[x]=3)}});const l=(g,b)=>g+" ".repeat(Math.max(0,b-g.length)),c=s[0],u=c.some(g=>g.isHeader),d=new Array(i).fill(null);s.forEach(g=>{var b;for(let x=0;x<i;x+=1)!d[x]&&((b=g[x])!=null&&b.align)&&(d[x]=g[x].align)});let f=`
|
|
81
|
+
`);return{dom:l,text:f,slice:t}}function td(e,t,n,r,o){let s=o.parent.type.spec.code,i,a;if(!n&&!t)return null;let l=!!t&&(r||s||!n);if(l){if(e.someProp("transformPastedText",f=>{t=f(t,s||r,e)}),s)return a=new Z(X.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
82
|
+
`))),0,0),e.someProp("transformPasted",f=>{a=f(a,e,!0)}),a;let d=e.someProp("clipboardTextParser",f=>f(t,o,r,e));if(d)a=d;else{let f=o.marks(),{schema:p}=e.state,m=cs.fromSchema(p);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(g=>{let b=i.appendChild(document.createElement("p"));g&&b.appendChild(m.serializeNode(p.text(g,f)))})}}else e.someProp("transformPastedHTML",d=>{n=d(n,e)}),i=vb(n),ba&&wb(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(a||(a=(e.someProp("clipboardParser")||e.someProp("domParser")||Fo.fromSchema(e.state.schema)).parseSlice(i,{preserveWhitespace:!!(l||u),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!bb.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=kb($l(a,+u[1],+u[2]),u[4]);else if(a=Z.maxOpen(yb(a.content,o),!0),a.openStart||a.openEnd){let d=0,f=0;for(let p=a.content.firstChild;d<a.openStart&&!p.type.spec.isolating;d++,p=p.firstChild);for(let p=a.content.lastChild;f<a.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);a=$l(a,d,f)}return e.someProp("transformPasted",d=>{a=d(a,e,l)}),a}const bb=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function yb(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o=t.node(n).contentMatchAt(t.index(n)),s,i=[];if(e.forEach(a=>{if(!i)return;let l=o.findWrapping(a.type),c;if(!l)return i=null;if(c=i.length&&s.length&&rd(l,s,a,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=od(i[i.length-1],s.length));let u=nd(a,l);i.push(u),o=o.matchType(u.type),s=l}}),i)return X.from(i)}return e}function nd(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,X.from(e));return e}function rd(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let s=rd(e,t,n,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(X.from(nd(n,e,o+1))))}}function od(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,od(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(X.empty,!0);return e.copy(n.append(r))}function Ri(e,t,n,r,o,s){let i=t<0?e.firstChild:e.lastChild,a=i.content;return e.childCount>1&&(s=0),o<r-1&&(a=Ri(a,t,n,r,o+1,s)),o>=n&&(a=t<0?i.contentMatchAt(0).fillBefore(a,s<=o).append(a):a.append(i.contentMatchAt(i.childCount).fillBefore(X.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,i.copy(a))}function $l(e,t,n){return t<e.openStart&&(e=new Z(Ri(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Z(Ri(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const sd={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Fl=null;function id(){return Fl||(Fl=document.implementation.createHTMLDocument("title"))}let Ws=null;function xb(e){let t=window.trustedTypes;return t?(Ws||(Ws=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Ws.createHTML(e)):e}function vb(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=id().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e),o;if((o=r&&sd[r[1].toLowerCase()])&&(e=o.map(s=>"<"+s+">").join("")+e+o.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=xb(e),o)for(let s=0;s<o.length;s++)n=n.querySelector(o[s])||n;return n}function wb(e){let t=e.querySelectorAll(Ht?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function kb(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:o,openStart:s,openEnd:i}=e;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;o=X.from(l.create(r[a+1],o)),s++,i++}return new Z(o,s,i)}const yt={},rt={};function Qt(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}rt.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!ld(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(Hr&&Ht&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),ga&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",o=>o(e,Ku(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||gb(e,n)?n.preventDefault():Qt(e,"key")};rt.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};rt.keypress=(e,t)=>{let n=t;if(ld(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||at&&n.metaKey)return;if(e.someProp("handleKeyPress",o=>o(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof he)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),s=()=>e.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!e.someProp("handleTextInput",i=>i(e,r.$from.pos,r.$to.pos,o,s))&&e.dispatch(s()),n.preventDefault()}};function ps(e){return{left:e.clientX,top:e.clientY}}function Cb(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function xa(e,t,n,r,o){if(r==-1)return!1;let s=e.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(e.someProp(t,a=>i>s.depth?a(e,n,s.nodeAfter,s.before(i),o,!0):a(e,n,s.node(i),s.before(i),o,!1)))return!0;return!1}function qn(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function Sb(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&de.isSelectable(r)?(qn(e,new de(n)),!0):!1}function Tb(e,t){if(t==-1)return!1;let n=e.state.selection,r,o;n instanceof de&&(r=n.node);let s=e.state.doc.resolve(t);for(let i=s.depth+1;i>0;i--){let a=i>s.depth?s.nodeAfter:s.node(i);if(de.isSelectable(a)){r&&n.$from.depth>0&&i>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?o=s.before(n.$from.depth):o=s.before(i);break}}return o!=null?(qn(e,de.create(e.state.doc,o)),!0):!1}function Ab(e,t,n,r,o){return xa(e,"handleClickOn",t,n,r)||e.someProp("handleClick",s=>s(e,t,r))||(o?Tb(e,n):Sb(e,n))}function Eb(e,t,n,r){return xa(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",o=>o(e,t,r))}function Mb(e,t,n,r){return xa(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",o=>o(e,t,r))||Rb(e,n,r)}function Rb(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(qn(e,he.create(r,0,r.content.size)),!0):!1;let o=r.resolve(t);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),a=o.before(s);if(i.inlineContent)qn(e,he.create(r,a+1,a+1+i.content.size));else if(de.isSelectable(i))qn(e,de.create(r,a));else continue;return!0}}function va(e){return Vo(e)}const ad=at?"metaKey":"ctrlKey";yt.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=va(e),o=Date.now(),s="singleClick";o-e.input.lastClick.time<500&&Cb(n,e.input.lastClick)&&!n[ad]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?s="doubleClick":e.input.lastClick.type=="doubleClick"&&(s="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:s,button:n.button};let i=e.posAtCoords(ps(n));i&&(s=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Nb(e,i,n,!!r)):(s=="doubleClick"?Eb:Mb)(e,i.pos,i.inside,n)?n.preventDefault():Qt(e,"pointer"))};class Nb{constructor(t,n,r,o){this.view=t,this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[ad],this.allowDefault=r.shiftKey;let s,i;if(n.inside>-1)s=t.state.doc.nodeAt(n.inside),i=n.inside;else{let u=t.state.doc.resolve(n.pos);s=u.parent,i=u.depth?u.before():0}const a=o?null:r.target,l=a?t.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=t.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof de&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&fs&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Qt(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ya(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(ps(t))),this.updateAllowDefault(t),this.allowDefault||!n?Qt(this.view,"pointer"):Ab(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||Rn&&this.mightDrag&&!this.mightDrag.node.isAtom||Ht&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(qn(this.view,pe.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):Qt(this.view,"pointer")}move(t){this.updateAllowDefault(t),Qt(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}yt.touchstart=e=>{e.input.lastTouch=Date.now(),va(e),Qt(e,"pointer")};yt.touchmove=e=>{e.input.lastTouch=Date.now(),Qt(e,"pointer")};yt.contextmenu=e=>va(e);function ld(e,t){return e.composing?!0:Rn&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const Ob=Hr?5e3:-1;rt.compositionstart=rt.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof he&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ht&&Ju&&Ib(e)))e.markCursor=e.state.storedMarks||n.marks(),Vo(e,!0),e.markCursor=null;else if(Vo(e,!t.selection.empty),fs&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let a=e.domSelection();a&&a.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}e.input.composing=!0}cd(e,Ob)};function Ib(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}rt.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,cd(e,20))};function cd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Vo(e),t))}function Pb(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Lb());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Lb(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function Vo(e,t=!1){if(!(Hr&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Pb(e),t||e.docView&&e.docView.dirty){let n=sb(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Db(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}const Mr=Br&&Gu<15||ga&&ob<604;yt.copy=rt.cut=(e,t)=>{let n=t,r=e.state.selection,o=n.type=="cut";if(r.empty)return;let s=Mr?null:n.clipboardData,i=r.content(),{dom:a,text:l}=ed(e,i);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):Db(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function jb(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function zb(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Ni(e,r.value,null,o,t):Ni(e,r.textContent,r.innerHTML,o,t)},50)}function Ni(e,t,n,r,o){let s=td(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",l=>l(e,o,s||Z.empty)))return!0;if(!s)return!1;let i=jb(s),a=i?e.state.tr.replaceSelectionWith(i,r):e.state.tr.replaceSelection(s);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ud(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}rt.paste=(e,t)=>{let n=t;if(e.composing&&!Hr)return;let r=Mr?null:n.clipboardData,o=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Ni(e,ud(r),r.getData("text/html"),o,n)?n.preventDefault():zb(e,n)};class _b{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}}const $b=at?"altKey":"ctrlKey";function dd(e,t){let n;return e.someProp("dragCopies",r=>{n=n||r(t)}),n!=null?!n:!t[$b]}yt.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=e.state.selection,s=o.empty?null:e.posAtCoords(ps(n)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof de?o.to-1:o.to))){if(r&&r.mightDrag)i=de.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=e.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=e.docView&&(i=de.create(e.state.doc,d.posBefore))}}let a=(i||e.state.selection).content(),{dom:l,text:c,slice:u}=ed(e,a);(!n.dataTransfer.files.length||!Ht||Xu>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Mr?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",Mr||n.dataTransfer.setData("text/plain",c),e.dragging=new _b(u,dd(e,n),i)};yt.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};rt.dragover=rt.dragenter=(e,t)=>t.preventDefault();rt.drop=(e,t)=>{try{Fb(e,t,e.dragging)}finally{e.dragging=null}};function Fb(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(ps(t));if(!r)return;let o=e.state.doc.resolve(r.pos),s=n&&n.slice;s?e.someProp("transformPasted",p=>{s=p(s,e,!1)}):s=td(e,ud(t.dataTransfer),Mr?null:t.dataTransfer.getData("text/html"),!1,o);let i=!!(n&&dd(e,t));if(e.someProp("handleDrop",p=>p(e,t,s||Z.empty,i))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Kg(e.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let l=e.state.tr;if(i){let{node:p}=n;p?p.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,s.content.firstChild):l.replaceRange(c,c,s),l.doc.eq(d))return;let f=l.doc.resolve(c);if(u&&de.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))l.setSelection(new de(f));else{let p=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,g,b,x)=>p=x),l.setSelection(Qu(e,f,l.doc.resolve(p)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}yt.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ya(e)},20))};yt.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};yt.beforeinput=(e,t)=>{if(Ht&&Hr&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",s=>s(e,Ku(8,"Backspace")))))return;let{$cursor:o}=e.state.selection;o&&o.pos>0&&e.dispatch(e.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let e in rt)yt[e]=rt[e];function Rr(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class qo{constructor(t,n){this.toDOM=t,this.spec=n||yn,this.side=this.spec.side||0}map(t,n,r,o){let{pos:s,deleted:i}=t.mapResult(n.from+o,this.side<0?-1:1);return i?null:new tt(s-r,s-r,this)}valid(){return!0}eq(t){return this==t||t instanceof qo&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Rr(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class Zt{constructor(t,n){this.attrs=t,this.spec=n||yn}map(t,n,r,o){let s=t.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,i=t.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new tt(s,i,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof Zt&&Rr(this.attrs,t.attrs)&&Rr(this.spec,t.spec)}static is(t){return t.type instanceof Zt}destroy(){}}class wa{constructor(t,n){this.attrs=t,this.spec=n||yn}map(t,n,r,o){let s=t.mapResult(n.from+o,1);if(s.deleted)return null;let i=t.mapResult(n.to+o,-1);return i.deleted||i.pos<=s.pos?null:new tt(s.pos-r,i.pos-r,this)}valid(t,n){let{index:r,offset:o}=t.content.findIndex(n.from),s;return o==n.from&&!(s=t.child(r)).isText&&o+s.nodeSize==n.to}eq(t){return this==t||t instanceof wa&&Rr(this.attrs,t.attrs)&&Rr(this.spec,t.spec)}destroy(){}}class tt{constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new tt(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new tt(t,t,new qo(n,r))}static inline(t,n,r,o){return new tt(t,n,new Zt(r,o))}static node(t,n,r,o){return new tt(t,n,new wa(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Zt}get widget(){return this.type instanceof qo}}const Hn=[],yn={};class Se{constructor(t,n){this.local=t.length?t:Hn,this.children=n.length?n:Hn}static create(t,n){return n.length?Ko(n,t,0,yn):Fe}find(t,n,r){let o=[];return this.findInner(t??0,n??1e9,o,0,r),o}findInner(t,n,r,o,s){for(let i=0;i<this.local.length;i++){let a=this.local[i];a.from<=n&&a.to>=t&&(!s||s(a.spec))&&r.push(a.copy(a.from+o,a.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<n&&this.children[i+1]>t){let a=this.children[i]+1;this.children[i+2].findInner(t-a,n-a,r,o+a,s)}}map(t,n,r){return this==Fe||t.maps.length==0?this:this.mapInner(t,n,0,0,r||yn)}mapInner(t,n,r,o,s){let i;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(t,r,o);l&&l.type.valid(n,l)?(i||(i=[])).push(l):s.onRemove&&s.onRemove(this.local[a].spec)}return this.children.length?Bb(this.children,i||[],t,n,r,o,s):i?new Se(i.sort(xn),Hn):Fe}add(t,n){return n.length?this==Fe?Se.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let o,s=0;t.forEach((a,l)=>{let c=l+r,u;if(u=pd(n,a,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<l;)s+=3;o[s]==l?o[s+2]=o[s+2].addInner(a,u,c+1):o.splice(s,0,l,l+a.nodeSize,Ko(u,a,c+1,yn)),s+=3}});let i=fd(s?hd(n):n,-r);for(let a=0;a<i.length;a++)i[a].type.valid(t,i[a])||i.splice(a--,1);return new Se(i.length?this.local.concat(i).sort(xn):this.local,o||this.children)}remove(t){return t.length==0||this==Fe?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,a=r[s]+n,l=r[s+1]+n;for(let u=0,d;u<t.length;u++)(d=t[u])&&d.from>a&&d.to<l&&(t[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,a+1);c!=Fe?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<t.length;s++)if(i=t[s])for(let a=0;a<o.length;a++)o[a].eq(i,n)&&(o==this.local&&(o=this.local.slice()),o.splice(a--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new Se(o,r):Fe}forChild(t,n){if(this==Fe)return this;if(n.isLeaf)return Se.empty;let r,o;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=t){this.children[a]==t&&(r=this.children[a+2]);break}let s=t+1,i=s+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<i&&l.to>s&&l.type instanceof Zt){let c=Math.max(s,l.from)-s,u=Math.min(i,l.to)-s;c<u&&(o||(o=[])).push(l.copy(c,u))}}if(o){let a=new Se(o.sort(xn),Hn);return r?new bn([a,r]):a}return r||Fe}eq(t){if(this==t)return!0;if(!(t instanceof Se)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return ka(this.localsInner(t))}localsInner(t){if(this==Fe)return Hn;if(t.inlineContent||!this.local.some(Zt.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Zt||n.push(this.local[r]);return n}forEachSet(t){t(this)}}Se.empty=new Se([],[]);Se.removeOverlap=ka;const Fe=Se.empty;class bn{constructor(t){this.members=t}map(t,n){const r=this.members.map(o=>o.map(t,n,yn));return bn.from(r)}forChild(t,n){if(n.isLeaf)return Se.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(t,n);s!=Fe&&(s instanceof bn?r=r.concat(s.members):r.push(s))}return bn.from(r)}eq(t){if(!(t instanceof bn)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(t);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let i=0;i<s.length;i++)n.push(s[i])}}return n?ka(r?n:n.sort(xn)):Hn}static from(t){switch(t.length){case 0:return Fe;case 1:return t[0];default:return new bn(t.every(n=>n instanceof Se)?t:t.reduce((n,r)=>n.concat(r instanceof Se?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}}function Bb(e,t,n,r,o,s,i){let a=e.slice();for(let c=0,u=s;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,p,m,g)=>{let b=g-m-(p-f);for(let x=0;x<a.length;x+=3){let S=a[x+1];if(S<0||f>S+u-d)continue;let k=a[x]+u-d;p>=k?a[x+1]=f<=k?-2:-1:f>=u&&b&&(a[x]+=b,a[x+1]+=b)}d+=b}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=n.map(e[c]+s),d=u-o;if(d<0||d>=r.content.size){l=!0;continue}let f=n.map(e[c+1]+s,-1),p=f-o,{index:m,offset:g}=r.content.findIndex(d),b=r.maybeChild(m);if(b&&g==d&&g+b.nodeSize==p){let x=a[c+2].mapInner(n,b,u+1,e[c]+s+1,i);x!=Fe?(a[c]=d,a[c+1]=p,a[c+2]=x):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Hb(a,e,t,n,o,s,i),u=Ko(c,r,0,i);t=u.local;for(let d=0;d<a.length;d+=3)a[d+1]<0&&(a.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let p=u.children[d];for(;f<a.length&&a[f]<p;)f+=3;a.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new Se(t.sort(xn),a)}function fd(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new tt(o.from+t,o.to+t,o.type))}return n}function Hb(e,t,n,r,o,s,i){function a(l,c){for(let u=0;u<l.local.length;u++){let d=l.local[u].map(r,o,c);d?n.push(d):i.onRemove&&i.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<e.length;l+=3)e[l+1]==-1&&a(e[l+2],t[l]+s+1);return n}function pd(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let s=0,i;s<e.length;s++)(i=e[s])&&i.from>n&&i.to<r&&((o||(o=[])).push(i),e[s]=null);return o}function hd(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function Ko(e,t,n,r){let o=[],s=!1;t.forEach((a,l)=>{let c=pd(e,a,l+n);if(c){s=!0;let u=Ko(c,a,n+l+1,r);u!=Fe&&o.push(l,l+a.nodeSize,u)}});let i=fd(s?hd(e):e,-n).sort(xn);for(let a=0;a<i.length;a++)i[a].type.valid(t,i[a])||(r.onRemove&&r.onRemove(i[a].spec),i.splice(a--,1));return i.length||o.length?new Se(i,o):Fe}function xn(e,t){return e.from-t.from||e.to-t.to}function ka(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let s=t[o];if(s.from==r.from){s.to!=r.to&&(t==e&&(t=e.slice()),t[o]=s.copy(s.from,r.to),Bl(t,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,s.from),Bl(t,o,r.copy(s.from,r.to)));break}}}return t}function Bl(e,t,n){for(;t<e.length&&xn(n,e[t])>0;)t++;e.splice(t,0,n)}var en={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Uo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Wb=typeof navigator<"u"&&/Mac/.test(navigator.platform),Vb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Oe=0;Oe<10;Oe++)en[48+Oe]=en[96+Oe]=String(Oe);for(var Oe=1;Oe<=24;Oe++)en[Oe+111]="F"+Oe;for(var Oe=65;Oe<=90;Oe++)en[Oe]=String.fromCharCode(Oe+32),Uo[Oe]=String.fromCharCode(Oe);for(var Vs in en)Uo.hasOwnProperty(Vs)||(Uo[Vs]=en[Vs]);function qb(e){var t=Wb&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Vb&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Uo:en)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Kb=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ub=typeof navigator<"u"&&/Win/.test(navigator.platform);function Gb(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,o,s,i;for(let a=0;a<t.length-1;a++){let l=t[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))Kb?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),i&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function Xb(e){let t=Object.create(null);for(let n in e)t[Gb(n)]=e[n];return t}function qs(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Jb(e){let t=Xb(e);return function(n,r){let o=qb(r),s,i=t[qs(o,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let a=t[qs(o,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Ub&&r.ctrlKey&&r.altKey)&&(s=en[r.keyCode])&&s!=o){let a=t[qs(s,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}let Oi,Ii;if(typeof WeakMap<"u"){let e=new WeakMap;Oi=t=>e.get(t),Ii=(t,n)=>(e.set(t,n),n)}else{const e=[];let n=0;Oi=r=>{for(let o=0;o<e.length;o+=2)if(e[o]==r)return e[o+1]},Ii=(r,o)=>(n==10&&(n=0),e[n++]=r,e[n++]=o)}var ke=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,o=t/this.width|0;let s=r+1,i=o+1;for(let a=1;s<this.width&&this.map[t+a]==n;a++)s++;for(let a=1;i<this.height&&this.map[t+this.width*a]==n;a++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:r,right:o,top:s,bottom:i}=this.findCell(e);return t=="horiz"?(n<0?r==0:o==this.width)?null:this.map[s*this.width+(n<0?r-1:o)]:(n<0?s==0:i==this.height)?null:this.map[r+this.width*(n<0?s-1:i)]}rectBetween(e,t){const{left:n,right:r,top:o,bottom:s}=this.findCell(e),{left:i,right:a,top:l,bottom:c}=this.findCell(t);return{left:Math.min(n,i),top:Math.min(o,l),right:Math.max(r,a),bottom:Math.max(s,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let o=e.left;o<e.right;o++){const s=r*this.width+o,i=this.map[s];n[i]||(n[i]=!0,!(o==e.left&&o&&this.map[s-1]==i||r==e.top&&r&&this.map[s-this.width]==i)&&t.push(i))}return t}positionAt(e,t,n){for(let r=0,o=0;;r++){const s=o+n.child(r).nodeSize;if(r==e){let i=t+e*this.width;const a=(e+1)*this.width;for(;i<a&&this.map[i]<o;)i++;return i==a?s-1:this.map[i]}o=s}}static get(e){return Oi(e)||Ii(e,Yb(e))}};function Yb(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);const t=Qb(e),n=e.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,u=t*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const d=e.child(c);u++;for(let m=0;;m++){for(;o<r.length&&r[o]!=0;)o++;if(m==d.childCount)break;const g=d.child(m),{colspan:b,rowspan:x,colwidth:S}=g.attrs;for(let k=0;k<x;k++){if(k+c>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:x-k});break}const y=o+k*t;for(let A=0;A<b;A++){r[y+A]==0?r[y+A]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:b-A});const w=S&&S[A];if(w){const C=(y+A)%t*2,T=i[C];T==null||T!=w&&i[C+1]==1?(i[C]=w,i[C+1]=1):T==w&&i[C+1]++}}}o+=b,u+=g.nodeSize}const f=(c+1)*t;let p=0;for(;o<f;)r[o++]==0&&p++;p&&(s||(s=[])).push({type:"missing",row:c,n:p}),u++}(t===0||n===0)&&(s||(s=[])).push({type:"zero_sized"});const a=new ke(t,n,r,s);let l=!1;for(let c=0;!l&&c<i.length;c+=2)i[c]!=null&&i[c+1]<n&&(l=!0);return l&&Zb(a,i,e),a}function Qb(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){const o=e.child(r);let s=0;if(n)for(let i=0;i<r;i++){const a=e.child(i);for(let l=0;l<a.childCount;l++){const c=a.child(l);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){const a=o.child(i);s+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}t==-1?t=s:t!=s&&(t=Math.max(t,s))}return t}function Zb(e,t,n){e.problems||(e.problems=[]);const r={};for(let o=0;o<e.map.length;o++){const s=e.map[o];if(r[s])continue;r[s]=!0;const i=n.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let a=null;const l=i.attrs;for(let c=0;c<l.colspan;c++){const u=t[(o+c)%e.width*2];u!=null&&(!l.colwidth||l.colwidth[c]!=u)&&((a||(a=ey(l)))[c]=u)}a&&e.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:a})}}function ey(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Le(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],o=r.spec.tableRole;o&&(t[o]=r)}}return t}const Xt=new ds("selectingCells");function Cn(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function ty(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function xt(e){const t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function hs(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;const n=Cn(t.$head)||ny(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function ny(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function Pi(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function ry(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Ca(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function md(e,t,n){const r=e.node(-1),o=ke.get(r),s=e.start(-1),i=o.nextCell(e.pos-s,t,n);return i==null?null:e.node(0).resolve(s+i)}function Sn(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function gd(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(t,0,0)}return r}function oy(e,t,n){const r=Le(t.type.schema).header_cell;for(let o=0;o<e.height;o++)if(t.nodeAt(e.map[n+o*e.width]).type!=r)return!1;return!0}var be=class zt extends pe{constructor(t,n=t){const r=t.node(-1),o=ke.get(r),s=t.start(-1),i=o.rectBetween(t.pos-s,n.pos-s),a=t.node(0),l=o.cellsInRect(i).filter(u=>u!=n.pos-s);l.unshift(n.pos-s);const c=l.map(u=>{const d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const f=s+u+1;return new Bu(a.resolve(f),a.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=t,this.$headCell=n}map(t,n){const r=t.resolve(n.map(this.$anchorCell.pos)),o=t.resolve(n.map(this.$headCell.pos));if(Pi(r)&&Pi(o)&&Ca(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?zt.rowSelection(r,o):s&&this.isColSelection()?zt.colSelection(r,o):new zt(r,o)}return he.between(r,o)}content(){const t=this.$anchorCell.node(-1),n=ke.get(t),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let l=o.top;l<o.bottom;l++){const c=[];for(let u=l*n.width+o.left,d=o.left;d<o.right;d++,u++){const f=n.map[u];if(s[f])continue;s[f]=!0;const p=n.findCell(f);let m=t.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const g=o.left-p.left,b=p.right-o.right;if(g>0||b>0){let x=m.attrs;if(g>0&&(x=Sn(x,0,g)),b>0&&(x=Sn(x,x.colspan-b,b)),p.left<o.left){if(m=m.type.createAndFill(x),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(x)}`)}else m=m.type.create(x,m.content)}if(p.top<o.top||p.bottom>o.bottom){const x={...m.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?m=m.type.createAndFill(x):m=m.type.create(x,m.content)}c.push(m)}i.push(t.child(l).copy(X.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?t:i;return new Z(X.from(a),1,1)}replace(t,n=Z.empty){const r=t.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){const{$from:a,$to:l}=o[i],c=t.mapping.slice(r);t.replace(c.map(a.pos),c.map(l.pos),i?Z.empty:n)}const s=pe.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);s&&t.setSelection(s)}replaceWith(t,n){this.replace(t,new Z(X.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),r=ke.get(n),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)t(n.nodeAt(s[i]),o+s[i])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const r=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const r=t.node(-1),o=ke.get(r),s=t.start(-1),i=o.findCell(t.pos-s),a=o.findCell(n.pos-s),l=t.node(0);return i.top<=a.top?(i.top>0&&(t=l.resolve(s+o.map[i.left])),a.bottom<o.height&&(n=l.resolve(s+o.map[o.width*(o.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(s+o.map[a.left])),i.bottom<o.height&&(t=l.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new zt(t,n)}isRowSelection(){const t=this.$anchorCell.node(-1),n=ke.get(t),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),s=n.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,a=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,a)==n.width}eq(t){return t instanceof zt&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const r=t.node(-1),o=ke.get(r),s=t.start(-1),i=o.findCell(t.pos-s),a=o.findCell(n.pos-s),l=t.node(0);return i.left<=a.left?(i.left>0&&(t=l.resolve(s+o.map[i.top*o.width])),a.right<o.width&&(n=l.resolve(s+o.map[o.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(s+o.map[a.top*o.width])),i.right<o.width&&(t=l.resolve(s+o.map[o.width*(i.top+1)-1]))),new zt(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new zt(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new zt(t.resolve(n),t.resolve(r))}getBookmark(){return new sy(this.$anchorCell.pos,this.$headCell.pos)}};be.prototype.visible=!1;pe.jsonID("cell",be);var sy=class bd{constructor(t,n){this.anchor=t,this.head=n}map(t){return new bd(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),r=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Ca(n,r)?new be(n,r):pe.near(r,1)}};function iy(e){if(!(e.selection instanceof be))return null;const t=[];return e.selection.forEachCell((n,r)=>{t.push(tt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Se.create(e.doc,t)}function ay({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,o=e.depth;for(;o>=0&&!(e.after(o+1)<e.end(o));o--,n++);for(let s=t.depth;s>=0&&!(t.before(s+1)>t.start(s));s--,r--);return n==r&&/row|table/.test(e.node(o).type.spec.tableRole)}function ly({$from:e,$to:t}){let n,r;for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let o=t.depth;o>0;o--){const s=t.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&t.parentOffset===0}function cy(e,t,n){const r=(t||e).selection,o=(t||e).doc;let s,i;if(r instanceof de&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=be.create(o,r.from);else if(i=="row"){const a=o.resolve(r.from+1);s=be.rowSelection(a,a)}else if(!n){const a=ke.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];s=be.create(o,l+1,c)}}else r instanceof he&&ay(r)?s=he.create(o,r.from):r instanceof he&&ly(r)&&(s=he.create(o,r.$from.start(),r.$from.end()));return s&&(t||(t=e.tr)).setSelection(s),t}const uy=new ds("fix-tables");function yd(e,t,n,r){const o=e.childCount,s=t.childCount;e:for(let i=0,a=0;i<s;i++){const l=t.child(i);for(let c=a,u=Math.min(o,i+3);c<u;c++)if(e.child(c)==l){a=c+1,n+=l.nodeSize;continue e}r(l,n),a<o&&e.child(a).sameMarkup(l)?yd(e.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function xd(e,t){let n;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(n=dy(e,o,s,n))};return t?t.doc!=e.doc&&yd(t.doc,e.doc,0,r):e.doc.descendants(r),n}function dy(e,t,n,r){const o=ke.get(t);if(!o.problems)return r;r||(r=e.tr);const s=[];for(let l=0;l<o.height;l++)s.push(0);for(let l=0;l<o.problems.length;l++){const c=o.problems[l];if(c.type=="collision"){const u=t.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)s[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Sn(d,d.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=t.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=t.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+t.nodeSize)}}let i,a;for(let l=0;l<s.length;l++)s[l]&&(i==null&&(i=l),a=l);for(let l=0,c=n+1;l<o.height;l++){const u=t.child(l),d=c+u.nodeSize,f=s[l];if(f>0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);const m=[];for(let b=0;b<f;b++){const x=Le(e.schema)[p].createAndFill();x&&m.push(x)}const g=(l==0||i==l-1)&&a==l?c+1:d-1;r.insert(r.mapping.map(g),m)}c=d}return r.setMeta(uy,{fixTables:!0})}function Pt(e){const t=e.selection,n=hs(e),r=n.node(-1),o=n.start(-1),s=ke.get(r);return{...t instanceof be?s.rectBetween(t.$anchorCell.pos-o,t.$headCell.pos-o):s.findCell(n.pos-o),tableStart:o,map:s,table:r}}function vd(e,{map:t,tableStart:n,table:r},o){let s=o>0?-1:0;oy(t,r,o+s)&&(s=o==0||o==t.width?null:0);for(let i=0;i<t.height;i++){const a=i*t.width+o;if(o>0&&o<t.width&&t.map[a-1]==t.map[a]){const l=t.map[a],c=r.nodeAt(l);e.setNodeMarkup(e.mapping.map(n+l),null,gd(c.attrs,o-t.colCount(l))),i+=c.attrs.rowspan-1}else{const l=s==null?Le(r.type.schema).cell:r.nodeAt(t.map[a+s]).type,c=t.positionAt(i,o,r);e.insert(e.mapping.map(n+c),l.createAndFill())}}return e}function fy(e,t){if(!xt(e))return!1;if(t){const n=Pt(e);t(vd(e.tr,n,n.left))}return!0}function py(e,t){if(!xt(e))return!1;if(t){const n=Pt(e);t(vd(e.tr,n,n.right))}return!0}function hy(e,{map:t,table:n,tableStart:r},o){const s=e.mapping.maps.length;for(let i=0;i<t.height;){const a=i*t.width+o,l=t.map[a],c=n.nodeAt(l),u=c.attrs;if(o>0&&t.map[a-1]==l||o<t.width-1&&t.map[a+1]==l)e.setNodeMarkup(e.mapping.slice(s).map(r+l),null,Sn(u,o-t.colCount(l)));else{const d=e.mapping.slice(s).map(r+l);e.delete(d,d+c.nodeSize)}i+=u.rowspan}}function my(e,t){if(!xt(e))return!1;if(t){const n=Pt(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;hy(r,n,o),o!=n.left;o--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=ke.get(s)}t(r)}return!0}function gy(e,t,n){var r;const o=Le(t.type.schema).header_cell;for(let s=0;s<e.width;s++)if(((r=t.nodeAt(e.map[s+n*e.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function wd(e,{map:t,tableStart:n,table:r},o){let s=n;for(let c=0;c<o;c++)s+=r.child(c).nodeSize;const i=[];let a=o>0?-1:0;gy(t,r,o+a)&&(a=o==0||o==t.height?null:0);for(let c=0,u=t.width*o;c<t.width;c++,u++)if(o>0&&o<t.height&&t.map[u]==t.map[u-t.width]){const d=t.map[u],f=r.nodeAt(d).attrs;e.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var l;const d=a==null?Le(r.type.schema).cell:(l=r.nodeAt(t.map[u+a*t.width]))===null||l===void 0?void 0:l.type,f=d?.createAndFill();f&&i.push(f)}return e.insert(s,Le(r.type.schema).row.create(null,i)),e}function by(e,t){if(!xt(e))return!1;if(t){const n=Pt(e);t(wd(e.tr,n,n.top))}return!0}function yy(e,t){if(!xt(e))return!1;if(t){const n=Pt(e);t(wd(e.tr,n,n.bottom))}return!0}function xy(e,{map:t,table:n,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=n.child(c).nodeSize;const i=s+n.child(o).nodeSize,a=e.mapping.maps.length;e.delete(s+r,i+r);const l=new Set;for(let c=0,u=o*t.width;c<t.width;c++,u++){const d=t.map[u];if(!l.has(d)){if(l.add(d),o>0&&d==t.map[u-t.width]){const f=n.nodeAt(d).attrs;e.setNodeMarkup(e.mapping.slice(a).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<t.height&&d==t.map[u+t.width]){const f=n.nodeAt(d),p=f.attrs,m=f.type.create({...p,rowspan:f.attrs.rowspan-1},f.content),g=t.positionAt(o+1,c,n);e.insert(e.mapping.slice(a).map(r+g),m),c+=p.colspan-1}}}}function vy(e,t){if(!xt(e))return!1;if(t){const n=Pt(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;xy(r,n,o),o!=n.top;o--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=ke.get(n.table)}t(r)}return!0}function Hl(e){const t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function wy({width:e,height:t,map:n},r){let o=r.top*e+r.left,s=o,i=(r.bottom-1)*e+r.left,a=o+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[s]==n[s-1]||r.right<e&&n[a]==n[a+1])return!0;s+=e,a+=e}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[o]==n[o-e]||r.bottom<t&&n[i]==n[i+e])return!0;o++,i++}return!1}function Wl(e,t){const n=e.selection;if(!(n instanceof be)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Pt(e),{map:o}=r;if(wy(o,r))return!1;if(t){const s=e.tr,i={};let a=X.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const f=o.map[u*o.width+d],p=r.table.nodeAt(f);if(!(i[f]||!p))if(i[f]=!0,l==null)l=f,c=p;else{Hl(p)||(a=a.append(p.content));const m=s.mapping.map(f+r.tableStart);s.delete(m,m+p.nodeSize)}}if(l==null||c==null)return!0;if(s.setNodeMarkup(l+r.tableStart,null,{...gd(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const u=l+1+c.content.size,d=Hl(c)?l+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,a)}s.setSelection(new be(s.doc.resolve(l+r.tableStart))),t(s)}return!0}function Vl(e,t){const n=Le(e.schema);return ky(({node:r})=>n[r.type.spec.tableRole])(e,t)}function ky(e){return(t,n)=>{const r=t.selection;let o,s;if(r instanceof be){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{var i;if(o=ty(r.$from),!o)return!1;s=(i=Cn(r.$from))===null||i===void 0?void 0:i.pos}if(o==null||s==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let a=o.attrs;const l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const u=Pt(t),d=t.tr;for(let p=0;p<u.right-u.left;p++)l.push(c?{...a,colwidth:c&&c[p]?[c[p]]:null}:a);let f;for(let p=u.top;p<u.bottom;p++){let m=u.map.positionAt(p,u.left,u.table);p==u.top&&(m+=o.nodeSize);for(let g=u.left,b=0;g<u.right;g++,b++)g==u.left&&p==u.top||d.insert(f=d.mapping.map(m+u.tableStart,1),e({node:o,row:p,col:g}).createAndFill(l[b]))}d.setNodeMarkup(s,e({node:o,row:u.top,col:u.left}),l[0]),r instanceof be&&d.setSelection(new be(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function Cy(e,t){return function(n,r){if(!xt(n))return!1;const o=hs(n);if(o.nodeAfter.attrs[e]===t)return!1;if(r){const s=n.tr;n.selection instanceof be?n.selection.forEachCell((i,a)=>{i.attrs[e]!==t&&s.setNodeMarkup(a,null,{...i.attrs,[e]:t})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[e]:t}),r(s)}return!0}}function Sy(e){return function(t,n){if(!xt(t))return!1;if(n){const r=Le(t.schema),o=Pt(t),s=t.tr,i=o.map.cellsInRect(e=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:e=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),a=i.map(l=>o.table.nodeAt(l));for(let l=0;l<i.length;l++)a[l].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[l],r.cell,a[l].attrs);if(s.steps.length===0)for(let l=0;l<i.length;l++)s.setNodeMarkup(o.tableStart+i[l],r.header_cell,a[l].attrs);n(s)}return!0}}function ql(e,t,n){const r=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let o=0;o<r.length;o++){const s=t.table.nodeAt(r[o]);if(s&&s.type!==n.header_cell)return!1}return!0}function Nr(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?Sy(e):function(n,r){if(!xt(n))return!1;if(r){const o=Le(n.schema),s=Pt(n),i=n.tr,a=ql("row",s,o),l=ql("column",s,o),c=(e==="column"?a:e==="row"&&l)?1:0,u=e=="column"?{left:0,top:c,right:1,bottom:s.map.height}:e=="row"?{left:c,top:0,right:s.map.width,bottom:1}:s,d=e=="column"?l?o.cell:o.header_cell:e=="row"?a?o.cell:o.header_cell:o.cell;s.map.cellsInRect(u).forEach(f=>{const p=f+s.tableStart,m=i.doc.nodeAt(p);m&&i.setNodeMarkup(p,d,m.attrs)}),r(i)}return!0}}Nr("row",{useDeprecatedLogic:!0});Nr("column",{useDeprecatedLogic:!0});const Ty=Nr("cell",{useDeprecatedLogic:!0});function Ay(e,t){if(t<0){const n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let r=e.index(-1)-1,o=e.before();r>=0;r--){const s=e.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const n=e.node(-1);for(let r=e.indexAfter(-1),o=e.after();r<n.childCount;r++){const s=n.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function Kl(e){return function(t,n){if(!xt(t))return!1;const r=Ay(hs(t),e);if(r==null)return!1;if(n){const o=t.doc.resolve(r);n(t.tr.setSelection(he.between(o,ry(o))).scrollIntoView())}return!0}}function Ey(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function fo(e,t){const n=e.selection;if(!(n instanceof be))return!1;if(t){const r=e.tr,o=Le(e.schema).cell.createAndFill().content;n.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new Z(o,0,0))}),r.docChanged&&t(r)}return!0}function My(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole=="table");)n--,r--,t=t.child(0).content;const o=t.child(0),s=o.type.spec.tableRole,i=o.type.schema,a=[];if(s=="row")for(let l=0;l<t.childCount;l++){let c=t.child(l).content;const u=l?0:Math.max(0,n-1),d=l<t.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Li(Le(i).row,new Z(c,u,d)).content),a.push(c)}else if(s=="cell"||s=="header_cell")a.push(n||r?Li(Le(i).row,new Z(t,n,r)).content:t);else return null;return Ry(i,a)}function Ry(e,t){const n=[];for(let o=0;o<t.length;o++){const s=t[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:a,colspan:l}=s.child(i).attrs;for(let c=o;c<o+a;c++)n[c]=(n[c]||0)+l}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=t.length&&t.push(X.empty),n[o]<r){const s=Le(e).cell.createAndFill(),i=[];for(let a=n[o];a<r;a++)i.push(s);t[o]=t[o].append(X.from(i))}return{height:t.length,width:r,rows:t}}function Li(e,t){const n=e.createAndFill();return new eb(n).replace(0,n.content.size,t).doc}function Ny({width:e,height:t,rows:n},r,o){if(e!=r){const s=[],i=[];for(let a=0;a<n.length;a++){const l=n[a],c=[];for(let u=s[a]||0,d=0;u<r;d++){let f=l.child(d%l.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(Sn(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let p=1;p<f.attrs.rowspan;p++)s[a+p]=(s[a+p]||0)+f.attrs.colspan}i.push(X.from(c))}n=i,e=r}if(t!=o){const s=[];for(let i=0,a=0;i<o;i++,a++){const l=[],c=n[a%t];for(let u=0;u<c.childCount;u++){let d=c.child(u);i+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),l.push(d)}s.push(X.from(l))}n=s,t=o}return{width:e,height:t,rows:n}}function Oy(e,t,n,r,o,s,i){const a=e.doc.type.schema,l=Le(a);let c,u;if(o>t.width)for(let d=0,f=0;d<t.height;d++){const p=n.child(d);f+=p.nodeSize;const m=[];let g;p.lastChild==null||p.lastChild.type==l.cell?g=c||(c=l.cell.createAndFill()):g=u||(u=l.header_cell.createAndFill());for(let b=t.width;b<o;b++)m.push(g);e.insert(e.mapping.slice(i).map(f-1+r),m)}if(s>t.height){const d=[];for(let m=0,g=(t.height-1)*t.width;m<Math.max(t.width,o);m++){const b=m>=t.width?!1:n.nodeAt(t.map[g+m]).type==l.header_cell;d.push(b?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const f=l.row.create(null,X.from(d)),p=[];for(let m=t.height;m<s;m++)p.push(f);e.insert(e.mapping.slice(i).map(r+n.nodeSize-2),p)}return!!(c||u)}function Ul(e,t,n,r,o,s,i,a){if(i==0||i==t.height)return!1;let l=!1;for(let c=o;c<s;c++){const u=i*t.width+c,d=t.map[u];if(t.map[u-t.width]==d){l=!0;const f=n.nodeAt(d),{top:p,left:m}=t.findCell(d);e.setNodeMarkup(e.mapping.slice(a).map(d+r),null,{...f.attrs,rowspan:i-p}),e.insert(e.mapping.slice(a).map(t.positionAt(i,m,n)),f.type.createAndFill({...f.attrs,rowspan:p+f.attrs.rowspan-i})),c+=f.attrs.colspan-1}}return l}function Gl(e,t,n,r,o,s,i,a){if(i==0||i==t.width)return!1;let l=!1;for(let c=o;c<s;c++){const u=c*t.width+i,d=t.map[u];if(t.map[u-1]==d){l=!0;const f=n.nodeAt(d),p=t.colCount(d),m=e.mapping.slice(a).map(d+r);e.setNodeMarkup(m,null,Sn(f.attrs,i-p,f.attrs.colspan-(i-p))),e.insert(m+f.nodeSize,f.type.createAndFill(Sn(f.attrs,0,i-p))),c+=f.attrs.rowspan-1}}return l}function Xl(e,t,n,r,o){let s=n?e.doc.nodeAt(n-1):e.doc;if(!s)throw new Error("No table found");let i=ke.get(s);const{top:a,left:l}=r,c=l+o.width,u=a+o.height,d=e.tr;let f=0;function p(){if(s=n?d.doc.nodeAt(n-1):d.doc,!s)throw new Error("No table found");i=ke.get(s),f=d.mapping.maps.length}Oy(d,i,s,n,c,u,f)&&p(),Ul(d,i,s,n,l,c,a,f)&&p(),Ul(d,i,s,n,l,c,u,f)&&p(),Gl(d,i,s,n,a,u,l,f)&&p(),Gl(d,i,s,n,a,u,c,f)&&p();for(let m=a;m<u;m++){const g=i.positionAt(m,l,s),b=i.positionAt(m,c,s);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(b+n),new Z(o.rows[m-a],0,0))}p(),d.setSelection(new be(d.doc.resolve(n+i.positionAt(a,l,s)),d.doc.resolve(n+i.positionAt(u-1,c-1,s)))),t(d)}const Iy=Jb({ArrowLeft:po("horiz",-1),ArrowRight:po("horiz",1),ArrowUp:po("vert",-1),ArrowDown:po("vert",1),"Shift-ArrowLeft":ho("horiz",-1),"Shift-ArrowRight":ho("horiz",1),"Shift-ArrowUp":ho("vert",-1),"Shift-ArrowDown":ho("vert",1),Backspace:fo,"Mod-Backspace":fo,Delete:fo,"Mod-Delete":fo});function Ro(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function po(e,t){return(n,r,o)=>{if(!o)return!1;const s=n.selection;if(s instanceof be)return Ro(n,r,pe.near(s.$headCell,t));if(e!="horiz"&&!s.empty)return!1;const i=kd(o,e,t);if(i==null)return!1;if(e=="horiz")return Ro(n,r,pe.near(n.doc.resolve(s.head+t),t));{const a=n.doc.resolve(i),l=md(a,e,t);let c;return l?c=pe.near(l,1):t<0?c=pe.near(n.doc.resolve(a.before(-1)),-1):c=pe.near(n.doc.resolve(a.after(-1)),1),Ro(n,r,c)}}}function ho(e,t){return(n,r,o)=>{if(!o)return!1;const s=n.selection;let i;if(s instanceof be)i=s;else{const l=kd(o,e,t);if(l==null)return!1;i=new be(n.doc.resolve(l))}const a=md(i.$headCell,e,t);return a?Ro(n,r,new be(i.$anchorCell,a)):!1}}function Py(e,t){const n=e.state.doc,r=Cn(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new be(r))),!0):!1}function Ly(e,t,n){if(!xt(e.state))return!1;let r=My(n);const o=e.state.selection;if(o instanceof be){r||(r={width:1,height:1,rows:[X.from(Li(Le(e.state.schema).cell,n))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),a=ke.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=Ny(r,a.right-a.left,a.bottom-a.top),Xl(e.state,e.dispatch,i,a,r),!0}else if(r){const s=hs(e.state),i=s.start(-1);return Xl(e.state,e.dispatch,i,ke.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function Dy(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;const r=Jl(e,t.target);let o;if(t.shiftKey&&e.state.selection instanceof be)s(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&(o=Cn(e.state.selection.$anchor))!=null&&((n=Ks(e,t))===null||n===void 0?void 0:n.pos)!=o.pos)s(o,t),t.preventDefault();else if(!r)return;function s(l,c){let u=Ks(e,c);const d=Xt.getState(e.state)==null;if(!u||!Ca(l,u))if(d)u=l;else return;const f=new be(l,u);if(d||!e.state.selection.eq(f)){const p=e.state.tr.setSelection(f);d&&p.setMeta(Xt,l.pos),e.dispatch(p)}}function i(){e.root.removeEventListener("mouseup",i),e.root.removeEventListener("dragstart",i),e.root.removeEventListener("mousemove",a),Xt.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Xt,-1))}function a(l){const c=l,u=Xt.getState(e.state);let d;if(u!=null)d=e.state.doc.resolve(u);else if(Jl(e,c.target)!=r&&(d=Ks(e,t),!d))return i();d&&s(d,c)}e.root.addEventListener("mouseup",i),e.root.addEventListener("dragstart",i),e.root.addEventListener("mousemove",a)}function kd(e,t,n){if(!(e.state.selection instanceof he))return null;const{$head:r}=e.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const i=r.before(o),a=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(a)?i:null}}return null}function Jl(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function Ks(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&Cn(e.state.doc.resolve(r))||Cn(e.state.doc.resolve(o))}var jy=class{constructor(t,n){this.node=t,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Di(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Di(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Di(e,t,n,r,o,s){let i=0,a=!0,l=t.firstChild;const c=e.firstChild;if(c){for(let d=0,f=0;d<c.childCount;d++){const{colspan:p,colwidth:m}=c.child(d).attrs;for(let g=0;g<p;g++,f++){const b=o==f?s:m&&m[g],x=b?b+"px":"";if(i+=b||r,b||(a=!1),l)l.style.width!=x&&(l.style.width=x),l=l.nextSibling;else{const S=document.createElement("col");S.style.width=x,t.appendChild(S)}}}for(;l;){var u;const d=l.nextSibling;(u=l.parentNode)===null||u===void 0||u.removeChild(l),l=d}a?(n.style.width=i+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=i+"px")}}const Ze=new ds("tableColumnResizing");function zy({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=jy,lastColumnResizable:o=!0}={}){const s=new ha({key:Ze,state:{init(i,a){var l;const c=(l=s.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,u=Le(a.schema).table.name;return r&&c&&(c[u]=(d,f)=>new r(d,n,f)),new _y(-1,!1)},apply(i,a){return a.apply(i)}},props:{attributes:i=>{const a=Ze.getState(i);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,a)=>{$y(i,a,e,o)},mouseleave:i=>{Fy(i)},mousedown:(i,a)=>{By(i,a,t,n)}},decorations:i=>{const a=Ze.getState(i);if(a&&a.activeHandle>-1)return Ky(i,a.activeHandle)},nodeViews:{}}});return s}var _y=class No{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){const n=this,r=t.getMeta(Ze);if(r&&r.setHandle!=null)return new No(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new No(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let o=t.mapping.map(n.activeHandle,-1);return Pi(t.doc.resolve(o))||(o=-1),new No(o,n.dragging)}return n}};function $y(e,t,n,r){if(!e.editable)return;const o=Ze.getState(e.state);if(o&&!o.dragging){const s=Wy(t.target);let i=-1;if(s){const{left:a,right:l}=s.getBoundingClientRect();t.clientX-a<=n?i=Yl(e,t,"left",n):l-t.clientX<=n&&(i=Yl(e,t,"right",n))}if(i!=o.activeHandle){if(!r&&i!==-1){const a=e.state.doc.resolve(i),l=a.node(-1),c=ke.get(l),u=a.start(-1);if(c.colCount(a.pos-u)+a.nodeAfter.attrs.colspan-1==c.width-1)return}Cd(e,i)}}}function Fy(e){if(!e.editable)return;const t=Ze.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Cd(e,-1)}function By(e,t,n,r){var o;if(!e.editable)return!1;const s=(o=e.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,i=Ze.getState(e.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const a=e.state.doc.nodeAt(i.activeHandle),l=Hy(e,i.activeHandle,a.attrs);e.dispatch(e.state.tr.setMeta(Ze,{setDragging:{startX:t.clientX,startWidth:l}}));function c(d){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",u);const f=Ze.getState(e.state);f?.dragging&&(Vy(e,f.activeHandle,Ql(f.dragging,d,n)),e.dispatch(e.state.tr.setMeta(Ze,{setDragging:null})))}function u(d){if(!d.which)return c(d);const f=Ze.getState(e.state);if(f&&f.dragging){const p=Ql(f.dragging,d,n);Zl(e,f.activeHandle,p,r)}}return Zl(e,i.activeHandle,l,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",u),t.preventDefault(),!0}function Hy(e,t,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const s=e.domAtPos(t);let i=s.node.childNodes[s.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(i-=r[l],a--);return i/a}function Wy(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function Yl(e,t,n,r){const o=n=="right"?-r:r,s=e.posAtCoords({left:t.clientX+o,top:t.clientY});if(!s)return-1;const{pos:i}=s,a=Cn(e.state.doc.resolve(i));if(!a)return-1;if(n=="right")return a.pos;const l=ke.get(a.node(-1)),c=a.start(-1),u=l.map.indexOf(a.pos-c);return u%l.width==0?-1:c+l.map[u-1]}function Ql(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Cd(e,t){e.dispatch(e.state.tr.setMeta(Ze,{setHandle:t}))}function Vy(e,t,n){const r=e.state.doc.resolve(t),o=r.node(-1),s=ke.get(o),i=r.start(-1),a=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let c=0;c<s.height;c++){const u=c*s.width+a;if(c&&s.map[u]==s.map[u-s.width])continue;const d=s.map[u],f=o.nodeAt(d).attrs,p=f.colspan==1?0:a-s.colCount(d);if(f.colwidth&&f.colwidth[p]==n)continue;const m=f.colwidth?f.colwidth.slice():qy(f.colspan);m[p]=n,l.setNodeMarkup(i+d,null,{...f,colwidth:m})}l.docChanged&&e.dispatch(l)}function Zl(e,t,n,r){const o=e.state.doc.resolve(t),s=o.node(-1),i=o.start(-1),a=ke.get(s).colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1;let l=e.domAtPos(o.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Di(s,l.firstChild,l,r,a,n)}function qy(e){return Array(e).fill(0)}function Ky(e,t){const n=[],r=e.doc.resolve(t),o=r.node(-1);if(!o)return Se.empty;const s=ke.get(o),i=r.start(-1),a=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const u=a+c*s.width;if((a==s.width-1||s.map[u]!=s.map[u+1])&&(c==0||s.map[u]!=s.map[u-s.width])){var l;const d=s.map[u],f=i+d+o.nodeAt(d).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((l=Ze.getState(e))===null||l===void 0)&&l.dragging&&n.push(tt.node(i+d,i+d+o.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(tt.widget(f,p))}}return Se.create(e.doc,n)}function Uy({allowTableNodeSelection:e=!1}={}){return new ha({key:Xt,state:{init(){return null},apply(t,n){const r=t.getMeta(Xt);if(r!=null)return r==-1?null:r;if(n==null||!t.docChanged)return n;const{deleted:o,pos:s}=t.mapping.mapResult(n);return o?null:s}},props:{decorations:iy,handleDOMEvents:{mousedown:Dy},createSelectionBetween(t){return Xt.getState(t.state)!=null?t.state.selection:null},handleTripleClick:Py,handleKeyDown:Iy,handlePaste:Ly},appendTransaction(t,n,r){return cy(r,xd(r,n),e)}})}function Go(e){return e==="left"||e==="right"||e==="center"?e:null}function Gy(e){const t=(e.style.textAlign||"").trim().toLowerCase(),n=(e.getAttribute("align")||"").trim().toLowerCase();return Go(t||n)}function Xy(e){return Go(e?.align)}function Sd(){return{default:null,parseHTML:e=>Gy(e),renderHTML:e=>e.align?{style:`text-align: ${e.align}`}:{}}}var Td=P.Node.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{var t,n;const r=e.getAttribute("colwidth"),o=r?r.split(",").map(s=>parseInt(s,10)):null;if(!o){const s=(t=e.closest("table"))==null?void 0:t.querySelectorAll("colgroup > col"),i=Array.from(((n=e.parentElement)==null?void 0:n.children)||[]).indexOf(e);if(i&&i>-1&&s&&s[i]){const a=s[i].getAttribute("width");return a?[parseInt(a,10)]:null}}return o}},align:Sd()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",P.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Ad=P.Node.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}},align:Sd()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",P.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Ed=P.Node.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",P.mergeAttributes(this.options.HTMLAttributes,e),0]}});function ji(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function ec(e,t,n,r,o,s){var i;let a=0,l=!0,c=t.firstChild;const u=e.firstChild;if(u!==null)for(let f=0,p=0;f<u.childCount;f+=1){const{colspan:m,colwidth:g}=u.child(f).attrs;for(let b=0;b<m;b+=1,p+=1){const x=o===p?s:g&&g[b],S=x?`${x}px`:"";if(a+=x||r,x||(l=!1),c){if(c.style.width!==S){const[k,y]=ji(r,x);c.style.setProperty(k,y)}c=c.nextSibling}else{const k=document.createElement("col"),[y,A]=ji(r,x);k.style.setProperty(y,A),t.appendChild(k)}}}for(;c;){const f=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=f}const d=e.attrs.style&&typeof e.attrs.style=="string"&&/\bwidth\s*:/i.test(e.attrs.style);l&&!d?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}var Jy=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),e.attrs.style&&(this.table.style.cssText=e.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ec(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,ec(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){const t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!!(n&&!r&&(e.type==="attributes"||e.type==="childList"||e.type==="characterData"))}};function Yy(e,t,n,r){let o=0,s=!0;const i=[],a=e.firstChild;if(!a)return{};for(let d=0,f=0;d<a.childCount;d+=1){const{colspan:p,colwidth:m}=a.child(d).attrs;for(let g=0;g<p;g+=1,f+=1){const b=n===f?r:m&&m[g];o+=b||t,b||(s=!1);const[x,S]=ji(t,b);i.push(["col",{style:`${x}: ${S}`}])}}const l=s?`${o}px`:"",c=s?"":`${o}px`;return{colgroup:["colgroup",{},...i],tableWidth:l,tableMinWidth:c}}function tc(e,t){return e.createAndFill()}function Qy(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function Zy(e,t,n,r,o){const s=Qy(e),i=[],a=[];for(let c=0;c<n;c+=1){const u=tc(s.cell);if(u&&a.push(u),r){const d=tc(s.header_cell);d&&i.push(d)}}const l=[];for(let c=0;c<t;c+=1)l.push(s.row.createChecked(null,r&&c===0?i:a));return s.table.createChecked(null,l)}function ex(e){return e instanceof be}var mo=({editor:e})=>{const{selection:t}=e.state;if(!ex(t))return!1;let n=0;const r=P.findParentNodeClosestToPos(t.ranges[0].$from,s=>s.type.name==="table");return r?.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},tx="";function nx(e){return(e||"").replace(/\s+/g," ").trim()}function rx(e,t,n={}){var r;const o=(r=n.cellLineSeparator)!=null?r:tx;if(!e||!e.content||e.content.length===0)return"";const s=[];e.content.forEach(g=>{const b=[];g.content&&g.content.forEach(x=>{let S="";x.content&&Array.isArray(x.content)&&x.content.length>1?S=x.content.map(C=>t.renderChildren(C)).join(o):S=x.content?t.renderChildren(x.content):"";const k=nx(S),y=x.type==="tableHeader",A=Xy(x.attrs);b.push({text:k,isHeader:y,align:A})}),s.push(b)});const i=s.reduce((g,b)=>Math.max(g,b.length),0);if(i===0)return"";const a=new Array(i).fill(0);s.forEach(g=>{var b;for(let x=0;x<i;x+=1){const k=(((b=g[x])==null?void 0:b.text)||"").length;k>a[x]&&(a[x]=k),a[x]<3&&(a[x]=3)}});const l=(g,b)=>g+" ".repeat(Math.max(0,b-g.length)),c=s[0],u=c.some(g=>g.isHeader),d=new Array(i).fill(null);s.forEach(g=>{var b;for(let x=0;x<i;x+=1)!d[x]&&((b=g[x])!=null&&b.align)&&(d[x]=g[x].align)});let f=`
|
|
83
83
|
`;const p=new Array(i).fill(0).map((g,b)=>u&&c[b]&&c[b].text||"");return f+=`| ${p.map((g,b)=>l(g,a[b])).join(" | ")} |
|
|
84
84
|
`,f+=`| ${a.map((g,b)=>{const x=Math.max(3,g),S=d[b];return S==="left"?`:${"-".repeat(x)}`:S==="right"?`${"-".repeat(x)}:`:S==="center"?`:${"-".repeat(x)}:`:"-".repeat(x)}).join(" | ")} |
|
|
85
85
|
`,(u?s.slice(1):s).forEach(g=>{f+=`| ${new Array(i).fill(0).map((b,x)=>l(g[x]&&g[x].text||"",a[x])).join(" | ")} |
|
|
86
|
-
`}),f}var nx=tx,Ad=P.Node.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Gy,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:o}=Xy(e,this.options.cellMinWidth),s=t.style;function i(){return s||(r?`width: ${r}`:`min-width: ${o}`)}const a=["table",P.mergeAttributes(this.options.HTMLAttributes,t,{style:i()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},a]:a},parseMarkdown:(e,t)=>{const n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){const o=[];e.header.forEach((s,i)=>{var a;const l=Uo((a=r[i])!=null?a:s.align),c=l?{align:l}:{};o.push(t.createNode("tableHeader",c,[{type:"paragraph",content:t.parseInline(s.tokens)}]))}),n.push(t.createNode("tableRow",{},o))}return e.rows&&e.rows.forEach(o=>{const s=[];o.forEach((i,a)=>{var l;const c=Uo((l=r[a])!=null?l:i.align),u=c?{align:c}:{};s.push(t.createNode("tableCell",u,[{type:"paragraph",content:t.parseInline(i.tokens)}]))}),n.push(t.createNode("tableRow",{},s))}),t.createNode("table",void 0,n)},renderMarkdown:(e,t)=>nx(e,t),addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:s})=>{const i=Yy(s.schema,e,t,n);if(o){const a=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(he.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>uy(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>dy(e,t),deleteColumn:()=>({state:e,dispatch:t})=>py(e,t),addRowBefore:()=>({state:e,dispatch:t})=>my(e,t),addRowAfter:()=>({state:e,dispatch:t})=>gy(e,t),deleteRow:()=>({state:e,dispatch:t})=>yy(e,t),deleteTable:()=>({state:e,dispatch:t})=>Ty(e,t),mergeCells:()=>({state:e,dispatch:t})=>Bl(e,t),splitCell:()=>({state:e,dispatch:t})=>Hl(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Nr("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Nr("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Cy(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>Bl(e,t)?!0:Hl(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>wy(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Vl(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Vl(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&bd(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const r=be.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ho,"Mod-Backspace":ho,Delete:ho,"Mod-Delete":ho}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Dy({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],qy({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const e=this.options.resizable&&this.editor.isEditable,t=this.options.View;return e||!t?null:({node:n,view:r})=>new t(n,this.options.cellMinWidth,r)},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:P.callOrReturn(P.getExtensionField(e,"tableRole",t))}}});P.Extension.create({name:"tableKit",addExtensions(){const e=[];return this.options.table!==!1&&e.push(Ad.configure(this.options.table)),this.options.tableCell!==!1&&e.push(Cd.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(Sd.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(Td.configure(this.options.tableRow)),e}});var rx=Cd,ox=Sd,sx=Td,ix=20,Ed=(e,t=0)=>{const n=[];return!e.children.length||t>ix||Array.from(e.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Ed(r,t+1))}),n},ax=e=>{if(!e.children.length)return;const t=Ed(e);t&&t.forEach(n=>{var r,o;const s=n.getAttribute("style"),i=(o=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");n.setAttribute("style",`${i};${s}`)})},Md=P.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&ax(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",P.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(s=>!!s))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),lx=P.Extension.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{var t;const n=(t=P.getStyleProperty(e,"background-color"))!=null?t:e.style.backgroundColor;return n?.replace(/['"]+/g,"")},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:e=>({chain:t})=>t().setMark("textStyle",{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Rd=P.Extension.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;const n=(t=P.getStyleProperty(e,"color"))!=null?t:e.style.color;return n?.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),cx=P.Extension.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>{var t;return(t=P.getStyleProperty(e,"font-family"))!=null?t:e.style.fontFamily},renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),ux=P.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>{var t;return(t=P.getStyleProperty(e,"font-size"))!=null?t:e.style.fontSize},renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),dx=P.Extension.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>{var t;return(t=P.getStyleProperty(e,"line-height"))!=null?t:e.style.lineHeight},renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:e=>({chain:t})=>t().setMark("textStyle",{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});P.Extension.create({name:"textStyleKit",addExtensions(){const e=[];return this.options.backgroundColor!==!1&&e.push(lx.configure(this.options.backgroundColor)),this.options.color!==!1&&e.push(Rd.configure(this.options.color)),this.options.fontFamily!==!1&&e.push(cx.configure(this.options.fontFamily)),this.options.fontSize!==!1&&e.push(ux.configure(this.options.fontSize)),this.options.lineHeight!==!1&&e.push(dx.configure(this.options.lineHeight)),this.options.textStyle!==!1&&e.push(Md.configure(this.options.textStyle)),e}});function Nd(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Nd(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function fx(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Nd(e))&&(r&&(r+=" "),r+=t);return r}const px=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},hx=(e,t)=>({classGroupId:e,validator:t}),Od=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Go="-",ec=[],mx="arbitrary..",gx=e=>{const t=yx(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return bx(i);const a=i.split(Go),l=a[0]===""&&a.length>1?1:0;return Id(a,l,t)},getConflictingClassGroupIds:(i,a)=>{if(a){const l=r[i],c=n[i];return l?c?px(c,l):l:c||ec}return n[i]||ec}}},Id=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],s=n.nextPart.get(o);if(s){const c=Id(e,t+1,s);if(c)return c}const i=n.validators;if(i===null)return;const a=t===0?e.join(Go):e.slice(t).join(Go),l=i.length;for(let c=0;c<l;c++){const u=i[c];if(u.validator(a))return u.classGroupId}},bx=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?mx+r:void 0})(),yx=e=>{const{theme:t,classGroups:n}=e;return xx(n,t)},xx=(e,t)=>{const n=Od();for(const r in e){const o=e[r];ka(o,n,r,t)}return n},ka=(e,t,n,r)=>{const o=e.length;for(let s=0;s<o;s++){const i=e[s];vx(i,t,n,r)}},vx=(e,t,n,r)=>{if(typeof e=="string"){wx(e,t,n);return}if(typeof e=="function"){kx(e,t,n,r);return}Cx(e,t,n,r)},wx=(e,t,n)=>{const r=e===""?t:Pd(t,e);r.classGroupId=n},kx=(e,t,n,r)=>{if(Sx(e)){ka(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(hx(n,e))},Cx=(e,t,n,r)=>{const o=Object.entries(e),s=o.length;for(let i=0;i<s;i++){const[a,l]=o[i];ka(l,Pd(t,a),n,r)}},Pd=(e,t)=>{let n=e;const r=t.split(Go),o=r.length;for(let s=0;s<o;s++){const i=r[s];let a=n.nextPart.get(i);a||(a=Od(),n.nextPart.set(i,a)),n=a}return n},Sx=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Tx=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(s,i)=>{n[s]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let i=n[s];if(i!==void 0)return i;if((i=r[s])!==void 0)return o(s,i),i},set(s,i){s in n?n[s]=i:o(s,i)}}},Di="!",tc=":",Ax=[],nc=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Ex=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const s=[];let i=0,a=0,l=0,c;const u=o.length;for(let g=0;g<u;g++){const b=o[g];if(i===0&&a===0){if(b===tc){s.push(o.slice(l,g)),l=g+1;continue}if(b==="/"){c=g;continue}}b==="["?i++:b==="]"?i--:b==="("?a++:b===")"&&a--}const d=s.length===0?o:o.slice(l);let f=d,p=!1;d.endsWith(Di)?(f=d.slice(0,-1),p=!0):d.startsWith(Di)&&(f=d.slice(1),p=!0);const m=c&&c>l?c-l:void 0;return nc(s,p,f,m)};if(t){const o=t+tc,s=r;r=i=>i.startsWith(o)?s(i.slice(o.length)):nc(Ax,!1,i,void 0,!0)}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},Mx=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let s=0;s<n.length;s++){const i=n[s],a=i[0]==="[",l=t.has(i);a||l?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(i)):o.push(i)}return o.length>0&&(o.sort(),r.push(...o)),r}},Rx=e=>({cache:Tx(e.cacheSize),parseClassName:Ex(e),sortModifiers:Mx(e),postfixLookupClassGroupIds:Nx(e),...gx(e)}),Nx=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},Ox=/\s+/,Ix=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:i}=t,a=[],l=e.trim().split(Ox);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:f,modifiers:p,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:b}=n(d);if(f){c=d+(c.length>0?" "+c:c);continue}let x=!!b,S;if(x){const C=g.substring(0,b);S=r(C);const A=S&&i[S]?r(g):void 0;A&&A!==S&&(S=A,x=!1)}else S=r(g);if(!S){if(!x){c=d+(c.length>0?" "+c:c);continue}if(S=r(g),!S){c=d+(c.length>0?" "+c:c);continue}x=!1}const k=p.length===0?"":p.length===1?p[0]:s(p).join(":"),y=m?k+Di:k,T=y+S;if(a.indexOf(T)>-1)continue;a.push(T);const w=o(S,x);for(let C=0;C<w.length;++C){const A=w[C];a.push(y+A)}c=d+(c.length>0?" "+c:c)}return c},Px=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=Ld(n))&&(o&&(o+=" "),o+=r);return o},Ld=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Ld(e[r]))&&(n&&(n+=" "),n+=t);return n},Lx=(e,...t)=>{let n,r,o,s;const i=l=>{const c=t.reduce((u,d)=>d(u),e());return n=Rx(c),r=n.cache.get,o=n.cache.set,s=a,a(l)},a=l=>{const c=r(l);if(c)return c;const u=Ix(l,n);return o(l,u),u};return s=i,(...l)=>s(Px(...l))},Dx=[],Me=e=>{const t=n=>n[e]||Dx;return t.isThemeGetter=!0,t},Dd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,jd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,jx=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,zx=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_x=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,$x=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Fx=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Bx=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Kt=e=>jx.test(e),ie=e=>!!e&&!Number.isNaN(Number(e)),vt=e=>!!e&&Number.isInteger(Number(e)),qs=e=>e.endsWith("%")&&ie(e.slice(0,-1)),jt=e=>zx.test(e),zd=()=>!0,Hx=e=>_x.test(e)&&!$x.test(e),Ca=()=>!1,Wx=e=>Fx.test(e),Vx=e=>Bx.test(e),qx=e=>!Y(e)&&!Q(e),Kx=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Ux=e=>sn(e,Fd,Ca),Y=e=>Dd.test(e),pn=e=>sn(e,Bd,Hx),rc=e=>sn(e,t0,ie),Gx=e=>sn(e,Wd,zd),Xx=e=>sn(e,Hd,Ca),oc=e=>sn(e,_d,Ca),Jx=e=>sn(e,$d,Vx),mo=e=>sn(e,Vd,Wx),Q=e=>jd.test(e),ur=e=>Nn(e,Bd),Yx=e=>Nn(e,Hd),sc=e=>Nn(e,_d),Qx=e=>Nn(e,Fd),Zx=e=>Nn(e,$d),go=e=>Nn(e,Vd,!0),e0=e=>Nn(e,Wd,!0),sn=(e,t,n)=>{const r=Dd.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Nn=(e,t,n=!1)=>{const r=jd.exec(e);return r?r[1]?t(r[1]):n:!1},_d=e=>e==="position"||e==="percentage",$d=e=>e==="image"||e==="url",Fd=e=>e==="length"||e==="size"||e==="bg-size",Bd=e=>e==="length",t0=e=>e==="number",Hd=e=>e==="family-name",Wd=e=>e==="number"||e==="weight",Vd=e=>e==="shadow",n0=()=>{const e=Me("color"),t=Me("font"),n=Me("text"),r=Me("font-weight"),o=Me("tracking"),s=Me("leading"),i=Me("breakpoint"),a=Me("container"),l=Me("spacing"),c=Me("radius"),u=Me("shadow"),d=Me("inset-shadow"),f=Me("text-shadow"),p=Me("drop-shadow"),m=Me("blur"),g=Me("perspective"),b=Me("aspect"),x=Me("ease"),S=Me("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],T=()=>[...y(),Q,Y],w=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],A=()=>[Q,Y,l],I=()=>[Kt,"full","auto",...A()],O=()=>[vt,"none","subgrid",Q,Y],j=()=>["auto",{span:["full",vt,Q,Y]},vt,Q,Y],D=()=>[vt,"auto",Q,Y],F=()=>["auto","min","max","fr",Q,Y],B=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],N=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...A()],V=()=>[Kt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],_=()=>[Kt,"screen","full","dvw","lvw","svw","min","max","fit",...A()],R=()=>[Kt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...A()],z=()=>[e,Q,Y],W=()=>[...y(),sc,oc,{position:[Q,Y]}],re=()=>["no-repeat",{repeat:["","x","y","space","round"]}],se=()=>["auto","cover","contain",Qx,Ux,{size:[Q,Y]}],le=()=>[qs,ur,pn],te=()=>["","none","full",c,Q,Y],G=()=>["",ie,ur,pn],H=()=>["solid","dashed","dotted","double"],J=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],oe=()=>[ie,qs,sc,oc],ge=()=>["","none",m,Q,Y],Ce=()=>["none",ie,Q,Y],ve=()=>["none",ie,Q,Y],we=()=>[ie,Q,Y],Ee=()=>[Kt,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[jt],breakpoint:[jt],color:[zd],container:[jt],"drop-shadow":[jt],ease:["in","out","in-out"],font:[qx],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[jt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[jt],shadow:[jt],spacing:["px",ie],text:[jt],"text-shadow":[jt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Kt,Y,Q,b]}],container:["container"],"container-type":[{"@container":["","normal","size",Q,Y]}],"container-named":[Kx],columns:[{columns:[ie,Y,Q,a]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:T()}],overflow:[{overflow:w()}],"overflow-x":[{"overflow-x":w()}],"overflow-y":[{"overflow-y":w()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{"inset-s":I(),start:I()}],end:[{"inset-e":I(),end:I()}],"inset-bs":[{"inset-bs":I()}],"inset-be":[{"inset-be":I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[vt,"auto",Q,Y]}],basis:[{basis:[Kt,"full","auto",a,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ie,Kt,"auto","initial","none",Y]}],grow:[{grow:["",ie,Q,Y]}],shrink:[{shrink:["",ie,Q,Y]}],order:[{order:[vt,"first","last","none",Q,Y]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:j()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:j()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":F()}],"auto-rows":[{"auto-rows":F()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...B(),"normal"]}],"justify-items":[{"justify-items":[...N(),"normal"]}],"justify-self":[{"justify-self":["auto",...N()]}],"align-content":[{content:["normal",...B()]}],"align-items":[{items:[...N(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...N(),{baseline:["","last"]}]}],"place-content":[{"place-content":B()}],"place-items":[{"place-items":[...N(),"baseline"]}],"place-self":[{"place-self":["auto",...N()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pbs:[{pbs:A()}],pbe:[{pbe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mbs:[{mbs:$()}],mbe:[{mbe:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:V()}],"inline-size":[{inline:["auto",..._()]}],"min-inline-size":[{"min-inline":["auto",..._()]}],"max-inline-size":[{"max-inline":["none",..._()]}],"block-size":[{block:["auto",...R()]}],"min-block-size":[{"min-block":["auto",...R()]}],"max-block-size":[{"max-block":["none",...R()]}],w:[{w:[a,"screen",...V()]}],"min-w":[{"min-w":[a,"screen","none",...V()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...V()]}],h:[{h:["screen","lh",...V()]}],"min-h":[{"min-h":["screen","lh","none",...V()]}],"max-h":[{"max-h":["screen","lh",...V()]}],"font-size":[{text:["base",n,ur,pn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,e0,Gx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",qs,Y]}],"font-family":[{font:[Yx,Xx,t]}],"font-features":[{"font-features":[Y]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Q,Y]}],"line-clamp":[{"line-clamp":[ie,"none",Q,rc]}],leading:[{leading:[s,...A()]}],"list-image":[{"list-image":["none",Q,Y]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Q,Y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:z()}],"text-color":[{text:z()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...H(),"wavy"]}],"text-decoration-thickness":[{decoration:[ie,"from-font","auto",Q,pn]}],"text-decoration-color":[{decoration:z()}],"underline-offset":[{"underline-offset":[ie,"auto",Q,Y]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"tab-size":[{tab:[vt,Q,Y]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Q,Y]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Q,Y]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:re()}],"bg-size":[{bg:se()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},vt,Q,Y],radial:["",Q,Y],conic:[vt,Q,Y]},Zx,Jx]}],"bg-color":[{bg:z()}],"gradient-from-pos":[{from:le()}],"gradient-via-pos":[{via:le()}],"gradient-to-pos":[{to:le()}],"gradient-from":[{from:z()}],"gradient-via":[{via:z()}],"gradient-to":[{to:z()}],rounded:[{rounded:te()}],"rounded-s":[{"rounded-s":te()}],"rounded-e":[{"rounded-e":te()}],"rounded-t":[{"rounded-t":te()}],"rounded-r":[{"rounded-r":te()}],"rounded-b":[{"rounded-b":te()}],"rounded-l":[{"rounded-l":te()}],"rounded-ss":[{"rounded-ss":te()}],"rounded-se":[{"rounded-se":te()}],"rounded-ee":[{"rounded-ee":te()}],"rounded-es":[{"rounded-es":te()}],"rounded-tl":[{"rounded-tl":te()}],"rounded-tr":[{"rounded-tr":te()}],"rounded-br":[{"rounded-br":te()}],"rounded-bl":[{"rounded-bl":te()}],"border-w":[{border:G()}],"border-w-x":[{"border-x":G()}],"border-w-y":[{"border-y":G()}],"border-w-s":[{"border-s":G()}],"border-w-e":[{"border-e":G()}],"border-w-bs":[{"border-bs":G()}],"border-w-be":[{"border-be":G()}],"border-w-t":[{"border-t":G()}],"border-w-r":[{"border-r":G()}],"border-w-b":[{"border-b":G()}],"border-w-l":[{"border-l":G()}],"divide-x":[{"divide-x":G()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":G()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...H(),"hidden","none"]}],"divide-style":[{divide:[...H(),"hidden","none"]}],"border-color":[{border:z()}],"border-color-x":[{"border-x":z()}],"border-color-y":[{"border-y":z()}],"border-color-s":[{"border-s":z()}],"border-color-e":[{"border-e":z()}],"border-color-bs":[{"border-bs":z()}],"border-color-be":[{"border-be":z()}],"border-color-t":[{"border-t":z()}],"border-color-r":[{"border-r":z()}],"border-color-b":[{"border-b":z()}],"border-color-l":[{"border-l":z()}],"divide-color":[{divide:z()}],"outline-style":[{outline:[...H(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ie,Q,Y]}],"outline-w":[{outline:["",ie,ur,pn]}],"outline-color":[{outline:z()}],shadow:[{shadow:["","none",u,go,mo]}],"shadow-color":[{shadow:z()}],"inset-shadow":[{"inset-shadow":["none",d,go,mo]}],"inset-shadow-color":[{"inset-shadow":z()}],"ring-w":[{ring:G()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:z()}],"ring-offset-w":[{"ring-offset":[ie,pn]}],"ring-offset-color":[{"ring-offset":z()}],"inset-ring-w":[{"inset-ring":G()}],"inset-ring-color":[{"inset-ring":z()}],"text-shadow":[{"text-shadow":["none",f,go,mo]}],"text-shadow-color":[{"text-shadow":z()}],opacity:[{opacity:[ie,Q,Y]}],"mix-blend":[{"mix-blend":[...J(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":J()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ie]}],"mask-image-linear-from-pos":[{"mask-linear-from":oe()}],"mask-image-linear-to-pos":[{"mask-linear-to":oe()}],"mask-image-linear-from-color":[{"mask-linear-from":z()}],"mask-image-linear-to-color":[{"mask-linear-to":z()}],"mask-image-t-from-pos":[{"mask-t-from":oe()}],"mask-image-t-to-pos":[{"mask-t-to":oe()}],"mask-image-t-from-color":[{"mask-t-from":z()}],"mask-image-t-to-color":[{"mask-t-to":z()}],"mask-image-r-from-pos":[{"mask-r-from":oe()}],"mask-image-r-to-pos":[{"mask-r-to":oe()}],"mask-image-r-from-color":[{"mask-r-from":z()}],"mask-image-r-to-color":[{"mask-r-to":z()}],"mask-image-b-from-pos":[{"mask-b-from":oe()}],"mask-image-b-to-pos":[{"mask-b-to":oe()}],"mask-image-b-from-color":[{"mask-b-from":z()}],"mask-image-b-to-color":[{"mask-b-to":z()}],"mask-image-l-from-pos":[{"mask-l-from":oe()}],"mask-image-l-to-pos":[{"mask-l-to":oe()}],"mask-image-l-from-color":[{"mask-l-from":z()}],"mask-image-l-to-color":[{"mask-l-to":z()}],"mask-image-x-from-pos":[{"mask-x-from":oe()}],"mask-image-x-to-pos":[{"mask-x-to":oe()}],"mask-image-x-from-color":[{"mask-x-from":z()}],"mask-image-x-to-color":[{"mask-x-to":z()}],"mask-image-y-from-pos":[{"mask-y-from":oe()}],"mask-image-y-to-pos":[{"mask-y-to":oe()}],"mask-image-y-from-color":[{"mask-y-from":z()}],"mask-image-y-to-color":[{"mask-y-to":z()}],"mask-image-radial":[{"mask-radial":[Q,Y]}],"mask-image-radial-from-pos":[{"mask-radial-from":oe()}],"mask-image-radial-to-pos":[{"mask-radial-to":oe()}],"mask-image-radial-from-color":[{"mask-radial-from":z()}],"mask-image-radial-to-color":[{"mask-radial-to":z()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":y()}],"mask-image-conic-pos":[{"mask-conic":[ie]}],"mask-image-conic-from-pos":[{"mask-conic-from":oe()}],"mask-image-conic-to-pos":[{"mask-conic-to":oe()}],"mask-image-conic-from-color":[{"mask-conic-from":z()}],"mask-image-conic-to-color":[{"mask-conic-to":z()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:W()}],"mask-repeat":[{mask:re()}],"mask-size":[{mask:se()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Q,Y]}],filter:[{filter:["","none",Q,Y]}],blur:[{blur:ge()}],brightness:[{brightness:[ie,Q,Y]}],contrast:[{contrast:[ie,Q,Y]}],"drop-shadow":[{"drop-shadow":["","none",p,go,mo]}],"drop-shadow-color":[{"drop-shadow":z()}],grayscale:[{grayscale:["",ie,Q,Y]}],"hue-rotate":[{"hue-rotate":[ie,Q,Y]}],invert:[{invert:["",ie,Q,Y]}],saturate:[{saturate:[ie,Q,Y]}],sepia:[{sepia:["",ie,Q,Y]}],"backdrop-filter":[{"backdrop-filter":["","none",Q,Y]}],"backdrop-blur":[{"backdrop-blur":ge()}],"backdrop-brightness":[{"backdrop-brightness":[ie,Q,Y]}],"backdrop-contrast":[{"backdrop-contrast":[ie,Q,Y]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ie,Q,Y]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ie,Q,Y]}],"backdrop-invert":[{"backdrop-invert":["",ie,Q,Y]}],"backdrop-opacity":[{"backdrop-opacity":[ie,Q,Y]}],"backdrop-saturate":[{"backdrop-saturate":[ie,Q,Y]}],"backdrop-sepia":[{"backdrop-sepia":["",ie,Q,Y]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Q,Y]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ie,"initial",Q,Y]}],ease:[{ease:["linear","initial",x,Q,Y]}],delay:[{delay:[ie,Q,Y]}],animate:[{animate:["none",S,Q,Y]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,Q,Y]}],"perspective-origin":[{"perspective-origin":T()}],rotate:[{rotate:Ce()}],"rotate-x":[{"rotate-x":Ce()}],"rotate-y":[{"rotate-y":Ce()}],"rotate-z":[{"rotate-z":Ce()}],scale:[{scale:ve()}],"scale-x":[{"scale-x":ve()}],"scale-y":[{"scale-y":ve()}],"scale-z":[{"scale-z":ve()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[Q,Y,"","none","gpu","cpu"]}],"transform-origin":[{origin:T()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ee()}],"translate-x":[{"translate-x":Ee()}],"translate-y":[{"translate-y":Ee()}],"translate-z":[{"translate-z":Ee()}],"translate-none":["translate-none"],zoom:[{zoom:[vt,Q,Y]}],accent:[{accent:z()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:z()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Q,Y]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":z()}],"scrollbar-track-color":[{"scrollbar-track":z()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mbs":[{"scroll-mbs":A()}],"scroll-mbe":[{"scroll-mbe":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pbs":[{"scroll-pbs":A()}],"scroll-pbe":[{"scroll-pbe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Q,Y]}],fill:[{fill:["none",...z()]}],"stroke-w":[{stroke:[ie,ur,pn,rc]}],stroke:[{stroke:["none",...z()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},r0=Lx(n0);function M(...e){return r0(fx(e))}const Wr=K.createContext({theme:"light",translations:Xn}),We=()=>K.useContext(Wr).theme,Vr=()=>K.useContext(Wr).translations,Ve=()=>K.useContext(Wr).classNames,o0=()=>K.useContext(Wr).styles,kt=({children:e,content:t})=>{const n=We(),r=Ve();return t?h.jsxs(Fn.Root,{delayDuration:500,children:[h.jsx(Fn.Trigger,{asChild:!0,children:e}),h.jsx(Fn.Portal,{children:h.jsxs(Fn.Content,{sideOffset:6,className:M("z-50 px-3 py-1.5 text-xs font-medium rounded-full shadow-lg select-none","animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",n==="dark"?"bg-neutral-100 text-neutral-900":"bg-neutral-900 text-neutral-100",r?.tooltipContent),children:[t,h.jsx(Fn.Arrow,{className:M(n==="dark"?"fill-neutral-100":"fill-neutral-900",r?.tooltipArrow)})]})})]}):h.jsx(h.Fragment,{children:e})};function ae(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function ic(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ps(...e){return t=>{let n=!1;const r=e.map(o=>{const s=ic(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():ic(e[o],null)}}}}function De(...e){return v.useCallback(ps(...e),e)}function sr(e,t=[]){let n=[];function r(s,i){const a=v.createContext(i),l=n.length;n=[...n,i];const c=d=>{const{scope:f,children:p,...m}=d,g=f?.[e]?.[l]||a,b=v.useMemo(()=>m,Object.values(m));return h.jsx(g.Provider,{value:b,children:p})};c.displayName=s+"Provider";function u(d,f){const p=f?.[e]?.[l]||a,m=v.useContext(p);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[c,u]}const o=()=>{const s=n.map(i=>v.createContext(i));return function(a){const l=a?.[e]||s;return v.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,s0(o,...t)]}function s0(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var tn=globalThis?.document?v.useLayoutEffect:()=>{},i0=v[" useInsertionEffect ".trim().toString()]||tn;function hs({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=a0({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const u=v.useRef(e!==void 0);v.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const c=v.useCallback(u=>{if(a){const d=l0(u)?u(e):u;d!==e&&i.current?.(d)}else s(u)},[a,e,s,i]);return[l,c]}function a0({defaultProp:e,onChange:t}){const[n,r]=v.useState(e),o=v.useRef(n),s=v.useRef(t);return i0(()=>{s.current=t},[t]),v.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}function l0(e){return typeof e=="function"}function Or(e){const t=c0(e),n=v.forwardRef((r,o)=>{const{children:s,...i}=r,a=v.Children.toArray(s),l=a.find(d0);if(l){const c=l.props.children,u=a.map(d=>d===l?v.Children.count(c)>1?v.Children.only(null):v.isValidElement(c)?c.props.children:null:d);return h.jsx(t,{...i,ref:o,children:v.isValidElement(c)?v.cloneElement(c,void 0,u):null})}return h.jsx(t,{...i,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}function c0(e){const t=v.forwardRef((n,r)=>{const{children:o,...s}=n;if(v.isValidElement(o)){const i=p0(o),a=f0(s,o.props);return o.type!==v.Fragment&&(a.ref=r?ps(r,i):i),v.cloneElement(o,a)}return v.Children.count(o)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var u0=Symbol("radix.slottable");function d0(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===u0}function f0(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const l=s(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function p0(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var h0=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=h0.reduce((e,t)=>{const n=Or(`Primitive.${t}`),r=v.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function qd(e,t){e&&ru.flushSync(()=>e.dispatchEvent(t))}function Kd(e){const t=e+"CollectionProvider",[n,r]=sr(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:b,children:x}=g,S=K.useRef(null),k=K.useRef(new Map).current;return h.jsx(o,{scope:b,itemMap:k,collectionRef:S,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=Or(a),c=K.forwardRef((g,b)=>{const{scope:x,children:S}=g,k=s(a,x),y=De(b,k.collectionRef);return h.jsx(l,{ref:y,children:S})});c.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",f=Or(u),p=K.forwardRef((g,b)=>{const{scope:x,children:S,...k}=g,y=K.useRef(null),T=De(b,y),w=s(u,x);return K.useEffect(()=>(w.itemMap.set(y,{ref:y,...k}),()=>{w.itemMap.delete(y)})),h.jsx(f,{[d]:"",ref:T,children:S})});p.displayName=u;function m(g){const b=s(e+"CollectionConsumer",g);return K.useCallback(()=>{const S=b.collectionRef.current;if(!S)return[];const k=Array.from(S.querySelectorAll(`[${d}]`));return Array.from(b.itemMap.values()).sort((w,C)=>k.indexOf(w.ref.current)-k.indexOf(C.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},m,r]}var m0=v.createContext(void 0);function Ud(e){const t=v.useContext(m0);return e||t||"ltr"}function Ot(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...n)=>t.current?.(...n),[])}function g0(e,t=globalThis?.document){const n=Ot(e);v.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var b0="DismissableLayer",ji="dismissableLayer.update",y0="dismissableLayer.pointerDownOutside",x0="dismissableLayer.focusOutside",ac,Gd=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Sa=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=v.useContext(Gd),[u,d]=v.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=v.useState({}),m=De(t,C=>d(C)),g=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),x=g.indexOf(b),S=u?g.indexOf(u):-1,k=c.layersWithOutsidePointerEventsDisabled.size>0,y=S>=x,T=k0(C=>{const A=C.target,I=[...c.branches].some(O=>O.contains(A));!y||I||(o?.(C),i?.(C),C.defaultPrevented||a?.())},f),w=C0(C=>{const A=C.target;[...c.branches].some(O=>O.contains(A))||(s?.(C),i?.(C),C.defaultPrevented||a?.())},f);return g0(C=>{S===c.layers.size-1&&(r?.(C),!C.defaultPrevented&&a&&(C.preventDefault(),a()))},f),v.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(ac=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),lc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=ac)}},[u,f,n,c]),v.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),lc())},[u,c]),v.useEffect(()=>{const C=()=>p({});return document.addEventListener(ji,C),()=>document.removeEventListener(ji,C)},[]),h.jsx(Ie.div,{...l,ref:m,style:{pointerEvents:k?y?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,w.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,T.onPointerDownCapture)})});Sa.displayName=b0;var v0="DismissableLayerBranch",w0=v.forwardRef((e,t)=>{const n=v.useContext(Gd),r=v.useRef(null),o=De(t,r);return v.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),h.jsx(Ie.div,{...e,ref:o})});w0.displayName=v0;function k0(e,t=globalThis?.document){const n=Ot(e),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Xd(y0,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function C0(e,t=globalThis?.document){const n=Ot(e),r=v.useRef(!1);return v.useEffect(()=>{const o=s=>{s.target&&!r.current&&Xd(x0,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function lc(){const e=new CustomEvent(ji);document.dispatchEvent(e)}function Xd(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?qd(o,s):o.dispatchEvent(s)}var Ks=0;function Jd(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??cc()),document.body.insertAdjacentElement("beforeend",e[1]??cc()),Ks++,()=>{Ks===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ks--}},[])}function cc(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Us="focusScope.autoFocusOnMount",Gs="focusScope.autoFocusOnUnmount",uc={bubbles:!1,cancelable:!0},S0="FocusScope",Ta=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=v.useState(null),c=Ot(o),u=Ot(s),d=v.useRef(null),f=De(t,g=>l(g)),p=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let g=function(k){if(p.paused||!a)return;const y=k.target;a.contains(y)?d.current=y:Ut(d.current,{select:!0})},b=function(k){if(p.paused||!a)return;const y=k.relatedTarget;y!==null&&(a.contains(y)||Ut(d.current,{select:!0}))},x=function(k){if(document.activeElement===document.body)for(const T of k)T.removedNodes.length>0&&Ut(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",b);const S=new MutationObserver(x);return a&&S.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",b),S.disconnect()}}},[r,a,p.paused]),v.useEffect(()=>{if(a){fc.add(p);const g=document.activeElement;if(!a.contains(g)){const x=new CustomEvent(Us,uc);a.addEventListener(Us,c),a.dispatchEvent(x),x.defaultPrevented||(T0(N0(Yd(a)),{select:!0}),document.activeElement===g&&Ut(a))}return()=>{a.removeEventListener(Us,c),setTimeout(()=>{const x=new CustomEvent(Gs,uc);a.addEventListener(Gs,u),a.dispatchEvent(x),x.defaultPrevented||Ut(g??document.body,{select:!0}),a.removeEventListener(Gs,u),fc.remove(p)},0)}}},[a,c,u,p]);const m=v.useCallback(g=>{if(!n&&!r||p.paused)return;const b=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,x=document.activeElement;if(b&&x){const S=g.currentTarget,[k,y]=A0(S);k&&y?!g.shiftKey&&x===y?(g.preventDefault(),n&&Ut(k,{select:!0})):g.shiftKey&&x===k&&(g.preventDefault(),n&&Ut(y,{select:!0})):x===S&&g.preventDefault()}},[n,r,p.paused]);return h.jsx(Ie.div,{tabIndex:-1,...i,ref:f,onKeyDown:m})});Ta.displayName=S0;function T0(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ut(r,{select:t}),document.activeElement!==n)return}function A0(e){const t=Yd(e),n=dc(t,e),r=dc(t.reverse(),e);return[n,r]}function Yd(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function dc(e,t){for(const n of e)if(!E0(n,{upTo:t}))return n}function E0(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function M0(e){return e instanceof HTMLInputElement&&"select"in e}function Ut(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&M0(e)&&t&&e.select()}}var fc=R0();function R0(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=pc(e,t),e.unshift(t)},remove(t){e=pc(e,t),e[0]?.resume()}}}function pc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function N0(e){return e.filter(t=>t.tagName!=="A")}var O0=v[" useId ".trim().toString()]||(()=>{}),I0=0;function Yn(e){const[t,n]=v.useState(O0());return tn(()=>{n(r=>r??String(I0++))},[e]),t?`radix-${t}`:""}const P0=["top","right","bottom","left"],nn=Math.min,Ye=Math.max,Xo=Math.round,bo=Math.floor,Mt=e=>({x:e,y:e}),L0={left:"right",right:"left",bottom:"top",top:"bottom"};function zi(e,t,n){return Ye(e,nn(t,n))}function $t(e,t){return typeof e=="function"?e(t):e}function Ft(e){return e.split("-")[0]}function ir(e){return e.split("-")[1]}function Aa(e){return e==="x"?"y":"x"}function Ea(e){return e==="y"?"height":"width"}function At(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Ma(e){return Aa(At(e))}function D0(e,t,n){n===void 0&&(n=!1);const r=ir(e),o=Ma(e),s=Ea(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Jo(i)),[i,Jo(i)]}function j0(e){const t=Jo(e);return[_i(e),t,_i(t)]}function _i(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const hc=["left","right"],mc=["right","left"],z0=["top","bottom"],_0=["bottom","top"];function $0(e,t,n){switch(e){case"top":case"bottom":return n?t?mc:hc:t?hc:mc;case"left":case"right":return t?z0:_0;default:return[]}}function F0(e,t,n,r){const o=ir(e);let s=$0(Ft(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(_i)))),s}function Jo(e){const t=Ft(e);return L0[t]+e.slice(t.length)}function B0(e){return{top:0,right:0,bottom:0,left:0,...e}}function Qd(e){return typeof e!="number"?B0(e):{top:e,right:e,bottom:e,left:e}}function Yo(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function gc(e,t,n){let{reference:r,floating:o}=e;const s=At(t),i=Ma(t),a=Ea(i),l=Ft(t),c=s==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,f=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-o.width,y:d};break;default:p={x:r.x,y:r.y}}switch(ir(t)){case"start":p[i]-=f*(n&&c?-1:1);break;case"end":p[i]+=f*(n&&c?-1:1);break}return p}async function H0(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=$t(t,e),m=Qd(p),b=a[f?d==="floating"?"reference":"floating":d],x=Yo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),S=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,k=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),y=await(s.isElement==null?void 0:s.isElement(k))?await(s.getScale==null?void 0:s.getScale(k))||{x:1,y:1}:{x:1,y:1},T=Yo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:S,offsetParent:k,strategy:l}):S);return{top:(x.top-T.top+m.top)/y.y,bottom:(T.bottom-x.bottom+m.bottom)/y.y,left:(x.left-T.left+m.left)/y.x,right:(T.right-x.right+m.right)/y.x}}const W0=50,V0=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=i.detectOverflow?i:{...i,detectOverflow:H0},l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=gc(c,r,l),f=r,p=0;const m={};for(let g=0;g<s.length;g++){const b=s[g];if(!b)continue;const{name:x,fn:S}=b,{x:k,y,data:T,reset:w}=await S({x:u,y:d,initialPlacement:r,placement:f,strategy:o,middlewareData:m,rects:c,platform:a,elements:{reference:e,floating:t}});u=k??u,d=y??d,m[x]={...m[x],...T},w&&p<W0&&(p++,typeof w=="object"&&(w.placement&&(f=w.placement),w.rects&&(c=w.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):w.rects),{x:u,y:d}=gc(c,f,l)),g=-1)}return{x:u,y:d,placement:f,strategy:o,middlewareData:m}},q0=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=$t(e,t)||{};if(c==null)return{};const d=Qd(u),f={x:n,y:r},p=Ma(o),m=Ea(p),g=await i.getDimensions(c),b=p==="y",x=b?"top":"left",S=b?"bottom":"right",k=b?"clientHeight":"clientWidth",y=s.reference[m]+s.reference[p]-f[p]-s.floating[m],T=f[p]-s.reference[p],w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let C=w?w[k]:0;(!C||!await(i.isElement==null?void 0:i.isElement(w)))&&(C=a.floating[k]||s.floating[m]);const A=y/2-T/2,I=C/2-g[m]/2-1,O=nn(d[x],I),j=nn(d[S],I),D=O,F=C-g[m]-j,B=C/2-g[m]/2+A,N=zi(D,B,F),$=!l.arrow&&ir(o)!=null&&B!==N&&s.reference[m]/2-(B<D?O:j)-g[m]/2<0,V=$?B<D?B-D:B-F:0;return{[p]:f[p]+V,data:{[p]:N,centerOffset:B-N-V,...$&&{alignmentOffset:V}},reset:$}}}),K0=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...b}=$t(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Ft(o),S=At(a),k=Ft(a)===a,y=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=f||(k||!g?[Jo(a)]:j0(a)),w=m!=="none";!f&&w&&T.push(...F0(a,g,m,y));const C=[a,...T],A=await l.detectOverflow(t,b),I=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&I.push(A[x]),d){const B=D0(o,i,y);I.push(A[B[0]],A[B[1]])}if(O=[...O,{placement:o,overflows:I}],!I.every(B=>B<=0)){var j,D;const B=(((j=s.flip)==null?void 0:j.index)||0)+1,N=C[B];if(N&&(!(d==="alignment"?S!==At(N):!1)||O.every(_=>At(_.placement)===S?_.overflows[0]>0:!0)))return{data:{index:B,overflows:O},reset:{placement:N}};let $=(D=O.filter(V=>V.overflows[0]<=0).sort((V,_)=>V.overflows[1]-_.overflows[1])[0])==null?void 0:D.placement;if(!$)switch(p){case"bestFit":{var F;const V=(F=O.filter(_=>{if(w){const R=At(_.placement);return R===S||R==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(R=>R>0).reduce((R,z)=>R+z,0)]).sort((_,R)=>_[1]-R[1])[0])==null?void 0:F[0];V&&($=V);break}case"initialPlacement":$=a;break}if(o!==$)return{reset:{placement:$}}}return{}}}};function bc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function yc(e){return P0.some(t=>e[t]>=0)}const U0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...s}=$t(e,t);switch(o){case"referenceHidden":{const i=await r.detectOverflow(t,{...s,elementContext:"reference"}),a=bc(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:yc(a)}}}case"escaped":{const i=await r.detectOverflow(t,{...s,altBoundary:!0}),a=bc(i,n.floating);return{data:{escapedOffsets:a,escaped:yc(a)}}}default:return{}}}}},Zd=new Set(["left","top"]);async function G0(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Ft(n),a=ir(n),l=At(n)==="y",c=Zd.has(i)?-1:1,u=s&&l?-1:1,d=$t(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}const X0=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await G0(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},J0=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:x=>{let{x:S,y:k}=x;return{x:S,y:k}}},...c}=$t(e,t),u={x:n,y:r},d=await s.detectOverflow(t,c),f=At(Ft(o)),p=Aa(f);let m=u[p],g=u[f];if(i){const x=p==="y"?"top":"left",S=p==="y"?"bottom":"right",k=m+d[x],y=m-d[S];m=zi(k,m,y)}if(a){const x=f==="y"?"top":"left",S=f==="y"?"bottom":"right",k=g+d[x],y=g-d[S];g=zi(k,g,y)}const b=l.fn({...t,[p]:m,[f]:g});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[p]:i,[f]:a}}}}}},Y0=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=$t(e,t),u={x:n,y:r},d=At(o),f=Aa(d);let p=u[f],m=u[d];const g=$t(a,t),b=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const k=f==="y"?"height":"width",y=s.reference[f]-s.floating[k]+b.mainAxis,T=s.reference[f]+s.reference[k]-b.mainAxis;p<y?p=y:p>T&&(p=T)}if(c){var x,S;const k=f==="y"?"width":"height",y=Zd.has(Ft(o)),T=s.reference[d]-s.floating[k]+(y&&((x=i.offset)==null?void 0:x[d])||0)+(y?0:b.crossAxis),w=s.reference[d]+s.reference[k]+(y?0:((S=i.offset)==null?void 0:S[d])||0)-(y?b.crossAxis:0);m<T?m=T:m>w&&(m=w)}return{[f]:p,[d]:m}}}},Q0=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=$t(e,t),u=await i.detectOverflow(t,c),d=Ft(o),f=ir(o),p=At(o)==="y",{width:m,height:g}=s.floating;let b,x;d==="top"||d==="bottom"?(b=d,x=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,b=f==="end"?"top":"bottom");const S=g-u.top-u.bottom,k=m-u.left-u.right,y=nn(g-u[b],S),T=nn(m-u[x],k),w=!t.middlewareData.shift;let C=y,A=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=k),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=S),w&&!f){const O=Ye(u.left,0),j=Ye(u.right,0),D=Ye(u.top,0),F=Ye(u.bottom,0);p?A=m-2*(O!==0||j!==0?O+j:Ye(u.left,u.right)):C=g-2*(D!==0||F!==0?D+F:Ye(u.top,u.bottom))}await l({...t,availableWidth:A,availableHeight:C});const I=await i.getDimensions(a.floating);return m!==I.width||g!==I.height?{reset:{rects:!0}}:{}}}};function ms(){return typeof window<"u"}function ar(e){return ef(e)?(e.nodeName||"").toLowerCase():"#document"}function nt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Lt(e){var t;return(t=(ef(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ef(e){return ms()?e instanceof Node||e instanceof nt(e).Node:!1}function gt(e){return ms()?e instanceof Element||e instanceof nt(e).Element:!1}function Wt(e){return ms()?e instanceof HTMLElement||e instanceof nt(e).HTMLElement:!1}function xc(e){return!ms()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof nt(e).ShadowRoot}function qr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=bt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function Z0(e){return/^(table|td|th)$/.test(ar(e))}function gs(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const ev=/transform|translate|scale|rotate|perspective|filter/,tv=/paint|layout|strict|content/,hn=e=>!!e&&e!=="none";let Xs;function Ra(e){const t=gt(e)?bt(e):e;return hn(t.transform)||hn(t.translate)||hn(t.scale)||hn(t.rotate)||hn(t.perspective)||!Na()&&(hn(t.backdropFilter)||hn(t.filter))||ev.test(t.willChange||"")||tv.test(t.contain||"")}function nv(e){let t=rn(e);for(;Wt(t)&&!Qn(t);){if(Ra(t))return t;if(gs(t))return null;t=rn(t)}return null}function Na(){return Xs==null&&(Xs=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Xs}function Qn(e){return/^(html|body|#document)$/.test(ar(e))}function bt(e){return nt(e).getComputedStyle(e)}function bs(e){return gt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function rn(e){if(ar(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xc(e)&&e.host||Lt(e);return xc(t)?t.host:t}function tf(e){const t=rn(e);return Qn(t)?e.ownerDocument?e.ownerDocument.body:e.body:Wt(t)&&qr(t)?t:tf(t)}function Ir(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=tf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=nt(o);if(s){const a=$i(i);return t.concat(i,i.visualViewport||[],qr(o)?o:[],a&&n?Ir(a):[])}else return t.concat(o,Ir(o,[],n))}function $i(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function nf(e){const t=bt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Wt(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Xo(n)!==s||Xo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Oa(e){return gt(e)?e:e.contextElement}function Kn(e){const t=Oa(e);if(!Wt(t))return Mt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=nf(t);let i=(s?Xo(n.width):n.width)/r,a=(s?Xo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const rv=Mt(0);function rf(e){const t=nt(e);return!Na()||!t.visualViewport?rv:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ov(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==nt(e)?!1:t}function Tn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Oa(e);let i=Mt(1);t&&(r?gt(r)&&(i=Kn(r)):i=Kn(e));const a=ov(s,n,r)?rf(s):Mt(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,d=o.height/i.y;if(s){const f=nt(s),p=r&>(r)?nt(r):r;let m=f,g=$i(m);for(;g&&r&&p!==m;){const b=Kn(g),x=g.getBoundingClientRect(),S=bt(g),k=x.left+(g.clientLeft+parseFloat(S.paddingLeft))*b.x,y=x.top+(g.clientTop+parseFloat(S.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=k,c+=y,m=nt(g),g=$i(m)}}return Yo({width:u,height:d,x:l,y:c})}function ys(e,t){const n=bs(e).scrollLeft;return t?t.left+n:Tn(Lt(e)).left+n}function of(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ys(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function sv(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Lt(r),a=t?gs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Mt(1);const u=Mt(0),d=Wt(r);if((d||!d&&!s)&&((ar(r)!=="body"||qr(i))&&(l=bs(r)),d)){const p=Tn(r);c=Kn(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const f=i&&!d&&!s?of(i,l):Mt(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function iv(e){return Array.from(e.getClientRects())}function av(e){const t=Lt(e),n=bs(e),r=e.ownerDocument.body,o=Ye(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ye(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ys(e);const a=-n.scrollTop;return bt(r).direction==="rtl"&&(i+=Ye(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const vc=25;function lv(e,t){const n=nt(e),r=Lt(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=Na();(!u||u&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ys(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(r.clientWidth-d.clientWidth-p);m<=vc&&(s-=m)}else c<=vc&&(s+=c);return{width:s,height:i,x:a,y:l}}function cv(e,t){const n=Tn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Wt(e)?Kn(e):Mt(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function wc(e,t,n){let r;if(t==="viewport")r=lv(e,n);else if(t==="document")r=av(Lt(e));else if(gt(t))r=cv(t,n);else{const o=rf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Yo(r)}function sf(e,t){const n=rn(e);return n===t||!gt(n)||Qn(n)?!1:bt(n).position==="fixed"||sf(n,t)}function uv(e,t){const n=t.get(e);if(n)return n;let r=Ir(e,[],!1).filter(a=>gt(a)&&ar(a)!=="body"),o=null;const s=bt(e).position==="fixed";let i=s?rn(e):e;for(;gt(i)&&!Qn(i);){const a=bt(i),l=Ra(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||qr(i)&&!l&&sf(e,i))?r=r.filter(u=>u!==i):o=a,i=rn(i)}return t.set(e,r),r}function dv(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?gs(t)?[]:uv(t,this._c):[].concat(n),r],a=wc(t,i[0],o);let l=a.top,c=a.right,u=a.bottom,d=a.left;for(let f=1;f<i.length;f++){const p=wc(t,i[f],o);l=Ye(p.top,l),c=nn(p.right,c),u=nn(p.bottom,u),d=Ye(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function fv(e){const{width:t,height:n}=nf(e);return{width:t,height:n}}function pv(e,t,n){const r=Wt(t),o=Lt(t),s=n==="fixed",i=Tn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Mt(0);function c(){l.x=ys(o)}if(r||!r&&!s)if((ar(t)!=="body"||qr(o))&&(a=bs(t)),r){const p=Tn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?of(o,a):Mt(0),d=i.left+a.scrollLeft-l.x-u.x,f=i.top+a.scrollTop-l.y-u.y;return{x:d,y:f,width:i.width,height:i.height}}function Js(e){return bt(e).position==="static"}function kc(e,t){if(!Wt(e)||bt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Lt(e)===n&&(n=n.ownerDocument.body),n}function af(e,t){const n=nt(e);if(gs(e))return n;if(!Wt(e)){let o=rn(e);for(;o&&!Qn(o);){if(gt(o)&&!Js(o))return o;o=rn(o)}return n}let r=kc(e,t);for(;r&&Z0(r)&&Js(r);)r=kc(r,t);return r&&Qn(r)&&Js(r)&&!Ra(r)?n:r||nv(e)||n}const hv=async function(e){const t=this.getOffsetParent||af,n=this.getDimensions,r=await n(e.floating);return{reference:pv(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function mv(e){return bt(e).direction==="rtl"}const gv={convertOffsetParentRelativeRectToViewportRelativeRect:sv,getDocumentElement:Lt,getClippingRect:dv,getOffsetParent:af,getElementRects:hv,getClientRects:iv,getDimensions:fv,getScale:Kn,isElement:gt,isRTL:mv};function lf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function bv(e,t){let n=null,r;const o=Lt(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(a||t(),!f||!p)return;const m=bo(d),g=bo(o.clientWidth-(u+f)),b=bo(o.clientHeight-(d+p)),x=bo(u),k={rootMargin:-m+"px "+-g+"px "+-b+"px "+-x+"px",threshold:Ye(0,nn(1,l))||1};let y=!0;function T(w){const C=w[0].intersectionRatio;if(C!==l){if(!y)return i();C?i(!1,C):r=setTimeout(()=>{i(!1,1e-7)},1e3)}C===1&&!lf(c,e.getBoundingClientRect())&&i(),y=!1}try{n=new IntersectionObserver(T,{...k,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,k)}n.observe(e)}return i(!0),s}function yv(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Oa(e),u=o||s?[...c?Ir(c):[],...t?Ir(t):[]]:[];u.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const d=c&&a?bv(c,n):null;let f=-1,p=null;i&&(p=new ResizeObserver(x=>{let[S]=x;S&&S.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var k;(k=p)==null||k.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let m,g=l?Tn(e):null;l&&b();function b(){const x=Tn(e);g&&!lf(g,x)&&n(),g=x,m=requestAnimationFrame(b)}return n(),()=>{var x;u.forEach(S=>{o&&S.removeEventListener("scroll",n),s&&S.removeEventListener("resize",n)}),d?.(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const xv=X0,vv=J0,wv=K0,kv=Q0,Cv=U0,Cc=q0,Sv=Y0,Tv=(e,t,n)=>{const r=new Map,o={platform:gv,...n},s={...o.platform,_c:r};return V0(e,t,{...o,platform:s})};var Av=typeof document<"u",Ev=function(){},No=Av?K.useLayoutEffect:Ev;function Qo(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Qo(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Qo(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function cf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Sc(e,t){const n=cf(e);return Math.round(t*n)/n}function Ys(e){const t=v.useRef(e);return No(()=>{t.current=e}),t}function Mv(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=v.useState(r);Qo(f,r)||p(r);const[m,g]=v.useState(null),[b,x]=v.useState(null),S=v.useCallback(_=>{_!==w.current&&(w.current=_,g(_))},[]),k=v.useCallback(_=>{_!==C.current&&(C.current=_,x(_))},[]),y=s||m,T=i||b,w=v.useRef(null),C=v.useRef(null),A=v.useRef(u),I=l!=null,O=Ys(l),j=Ys(o),D=Ys(c),F=v.useCallback(()=>{if(!w.current||!C.current)return;const _={placement:t,strategy:n,middleware:f};j.current&&(_.platform=j.current),Tv(w.current,C.current,_).then(R=>{const z={...R,isPositioned:D.current!==!1};B.current&&!Qo(A.current,z)&&(A.current=z,ru.flushSync(()=>{d(z)}))})},[f,t,n,j,D]);No(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,d(_=>({..._,isPositioned:!1})))},[c]);const B=v.useRef(!1);No(()=>(B.current=!0,()=>{B.current=!1}),[]),No(()=>{if(y&&(w.current=y),T&&(C.current=T),y&&T){if(O.current)return O.current(y,T,F);F()}},[y,T,F,O,I]);const N=v.useMemo(()=>({reference:w,floating:C,setReference:S,setFloating:k}),[S,k]),$=v.useMemo(()=>({reference:y,floating:T}),[y,T]),V=v.useMemo(()=>{const _={position:n,left:0,top:0};if(!$.floating)return _;const R=Sc($.floating,u.x),z=Sc($.floating,u.y);return a?{..._,transform:"translate("+R+"px, "+z+"px)",...cf($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:R,top:z}},[n,a,$.floating,u.x,u.y]);return v.useMemo(()=>({...u,update:F,refs:N,elements:$,floatingStyles:V}),[u,F,N,$,V])}const Rv=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Cc({element:r.current,padding:o}).fn(n):{}:r?Cc({element:r,padding:o}).fn(n):{}}}},Nv=(e,t)=>{const n=xv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ov=(e,t)=>{const n=vv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Iv=(e,t)=>({fn:Sv(e).fn,options:[e,t]}),Pv=(e,t)=>{const n=wv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Lv=(e,t)=>{const n=kv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dv=(e,t)=>{const n=Cv(e);return{name:n.name,fn:n.fn,options:[e,t]}},jv=(e,t)=>{const n=Rv(e);return{name:n.name,fn:n.fn,options:[e,t]}};var zv="Arrow",uf=v.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return h.jsx(Ie.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});uf.displayName=zv;var _v=uf;function $v(e){const[t,n]=v.useState(void 0);return tn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Ia="Popper",[df,xs]=sr(Ia),[Fv,ff]=df(Ia),pf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=v.useState(null);return h.jsx(Fv,{scope:t,anchor:r,onAnchorChange:o,children:n})};pf.displayName=Ia;var hf="PopperAnchor",mf=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=ff(hf,n),i=v.useRef(null),a=De(t,i),l=v.useRef(null);return v.useEffect(()=>{const c=l.current;l.current=r?.current||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:h.jsx(Ie.div,{...o,ref:a})});mf.displayName=hf;var Pa="PopperContent",[Bv,Hv]=df(Pa),gf=v.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:m,...g}=e,b=ff(Pa,n),[x,S]=v.useState(null),k=De(t,H=>S(H)),[y,T]=v.useState(null),w=$v(y),C=w?.width??0,A=w?.height??0,I=r+(s!=="center"?"-"+s:""),O=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},j=Array.isArray(c)?c:[c],D=j.length>0,F={padding:O,boundary:j.filter(Vv),altBoundary:D},{refs:B,floatingStyles:N,placement:$,isPositioned:V,middlewareData:_}=Mv({strategy:"fixed",placement:I,whileElementsMounted:(...H)=>yv(...H,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[Nv({mainAxis:o+A,alignmentAxis:i}),l&&Ov({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?Iv():void 0,...F}),l&&Pv({...F}),Lv({...F,apply:({elements:H,rects:J,availableWidth:oe,availableHeight:ge})=>{const{width:Ce,height:ve}=J.reference,we=H.floating.style;we.setProperty("--radix-popper-available-width",`${oe}px`),we.setProperty("--radix-popper-available-height",`${ge}px`),we.setProperty("--radix-popper-anchor-width",`${Ce}px`),we.setProperty("--radix-popper-anchor-height",`${ve}px`)}}),y&&jv({element:y,padding:a}),qv({arrowWidth:C,arrowHeight:A}),f&&Dv({strategy:"referenceHidden",...F})]}),[R,z]=xf($),W=Ot(m);tn(()=>{V&&W?.()},[V,W]);const re=_.arrow?.x,se=_.arrow?.y,le=_.arrow?.centerOffset!==0,[te,G]=v.useState();return tn(()=>{x&&G(window.getComputedStyle(x).zIndex)},[x]),h.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...N,transform:V?N.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:te,"--radix-popper-transform-origin":[_.transformOrigin?.x,_.transformOrigin?.y].join(" "),..._.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(Bv,{scope:n,placedSide:R,onArrowChange:T,arrowX:re,arrowY:se,shouldHideArrow:le,children:h.jsx(Ie.div,{"data-side":R,"data-align":z,...g,ref:k,style:{...g.style,animation:V?void 0:"none"}})})})});gf.displayName=Pa;var bf="PopperArrow",Wv={top:"bottom",right:"left",bottom:"top",left:"right"},yf=v.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Hv(bf,r),i=Wv[s.placedSide];return h.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:h.jsx(_v,{...o,ref:n,style:{...o.style,display:"block"}})})});yf.displayName=bf;function Vv(e){return e!==null}var qv=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,u]=xf(n),d={start:"0%",center:"50%",end:"100%"}[u],f=(o.arrow?.x??0)+a/2,p=(o.arrow?.y??0)+l/2;let m="",g="";return c==="bottom"?(m=i?d:`${f}px`,g=`${-l}px`):c==="top"?(m=i?d:`${f}px`,g=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,g=i?d:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,g=i?d:`${p}px`),{data:{x:m,y:g}}}});function xf(e){const[t,n="center"]=e.split("-");return[t,n]}var La=pf,Da=mf,vf=gf,wf=yf,Kv="Portal",ja=v.forwardRef((e,t)=>{const{container:n,...r}=e,[o,s]=v.useState(!1);tn(()=>s(!0),[]);const i=n||o&&globalThis?.document?.body;return i?Ji.createPortal(h.jsx(Ie.div,{...r,ref:t}),i):null});ja.displayName=Kv;function Uv(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var On=e=>{const{present:t,children:n}=e,r=Gv(t),o=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),s=De(r.ref,Xv(o));return typeof n=="function"||r.isPresent?v.cloneElement(o,{ref:s}):null};On.displayName="Presence";function Gv(e){const[t,n]=v.useState(),r=v.useRef(null),o=v.useRef(e),s=v.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Uv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const c=yo(r.current);s.current=a==="mounted"?c:"none"},[a]),tn(()=>{const c=r.current,u=o.current;if(u!==e){const f=s.current,p=yo(c);e?l("MOUNT"):p==="none"||c?.display==="none"?l("UNMOUNT"):l(u&&f!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),tn(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,d=p=>{const g=yo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(l("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=p=>{p.target===t&&(s.current=yo(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:v.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function yo(e){return e?.animationName||"none"}function Xv(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Qs="rovingFocusGroup.onEntryFocus",Jv={bubbles:!1,cancelable:!0},Kr="RovingFocusGroup",[Fi,kf,Yv]=Kd(Kr),[Qv,Cf]=sr(Kr,[Yv]),[Zv,ew]=Qv(Kr),Sf=v.forwardRef((e,t)=>h.jsx(Fi.Provider,{scope:e.__scopeRovingFocusGroup,children:h.jsx(Fi.Slot,{scope:e.__scopeRovingFocusGroup,children:h.jsx(tw,{...e,ref:t})})}));Sf.displayName=Kr;var tw=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,f=v.useRef(null),p=De(t,f),m=Ud(s),[g,b]=hs({prop:i,defaultProp:a??null,onChange:l,caller:Kr}),[x,S]=v.useState(!1),k=Ot(c),y=kf(n),T=v.useRef(!1),[w,C]=v.useState(0);return v.useEffect(()=>{const A=f.current;if(A)return A.addEventListener(Qs,k),()=>A.removeEventListener(Qs,k)},[k]),h.jsx(Zv,{scope:n,orientation:r,dir:m,loop:o,currentTabStopId:g,onItemFocus:v.useCallback(A=>b(A),[b]),onItemShiftTab:v.useCallback(()=>S(!0),[]),onFocusableItemAdd:v.useCallback(()=>C(A=>A+1),[]),onFocusableItemRemove:v.useCallback(()=>C(A=>A-1),[]),children:h.jsx(Ie.div,{tabIndex:x||w===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{T.current=!0}),onFocus:ae(e.onFocus,A=>{const I=!T.current;if(A.target===A.currentTarget&&I&&!x){const O=new CustomEvent(Qs,Jv);if(A.currentTarget.dispatchEvent(O),!O.defaultPrevented){const j=y().filter($=>$.focusable),D=j.find($=>$.active),F=j.find($=>$.id===g),N=[D,F,...j].filter(Boolean).map($=>$.ref.current);Ef(N,u)}}T.current=!1}),onBlur:ae(e.onBlur,()=>S(!1))})})}),Tf="RovingFocusGroupItem",Af=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Yn(),c=s||l,u=ew(Tf,n),d=u.currentTabStopId===c,f=kf(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:g}=u;return v.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),h.jsx(Fi.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:h.jsx(Ie.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,b=>{r?u.onItemFocus(c):b.preventDefault()}),onFocus:ae(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:ae(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){u.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const x=ow(b,u.orientation,u.dir);if(x!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let k=f().filter(y=>y.focusable).map(y=>y.ref.current);if(x==="last")k.reverse();else if(x==="prev"||x==="next"){x==="prev"&&k.reverse();const y=k.indexOf(b.currentTarget);k=u.loop?sw(k,y+1):k.slice(y+1)}setTimeout(()=>Ef(k))}}),children:typeof i=="function"?i({isCurrentTabStop:d,hasTabStop:g!=null}):i})})});Af.displayName=Tf;var nw={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function rw(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ow(e,t,n){const r=rw(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return nw[r]}function Ef(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function sw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var iw=Sf,aw=Af,lw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jn=new WeakMap,xo=new WeakMap,vo={},Zs=0,Mf=function(e){return e&&(e.host||Mf(e.parentNode))},cw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Mf(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},uw=function(e,t,n,r){var o=cw(t,Array.isArray(e)?e:[e]);vo[n]||(vo[n]=new WeakMap);var s=vo[n],i=[],a=new Set,l=new Set(o),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};o.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))u(f);else try{var p=f.getAttribute(r),m=p!==null&&p!=="false",g=(jn.get(f)||0)+1,b=(s.get(f)||0)+1;jn.set(f,g),s.set(f,b),i.push(f),g===1&&m&&xo.set(f,!0),b===1&&f.setAttribute(n,"true"),m||f.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",f,x)}})};return u(t),a.clear(),Zs++,function(){i.forEach(function(d){var f=jn.get(d)-1,p=s.get(d)-1;jn.set(d,f),s.set(d,p),f||(xo.has(d)||d.removeAttribute(r),xo.delete(d)),p||d.removeAttribute(n)}),Zs--,Zs||(jn=new WeakMap,jn=new WeakMap,xo=new WeakMap,vo={})}},Rf=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=lw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),uw(r,o,n,"aria-hidden")):function(){return null}},St=function(){return St=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},St.apply(this,arguments)};function Nf(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function dw(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var Oo="right-scroll-bar-position",Io="width-before-scroll-bar",fw="with-scroll-bars-hidden",pw="--removed-body-scroll-bar-size";function ei(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function hw(e,t){var n=K.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var mw=typeof window<"u"?v.useLayoutEffect:v.useEffect,Tc=new WeakMap;function gw(e,t){var n=hw(null,function(r){return e.forEach(function(o){return ei(o,r)})});return mw(function(){var r=Tc.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ei(a,null)}),s.forEach(function(a){o.has(a)||ei(a,i)})}Tc.set(n,e)},[e]),n}function bw(e){return e}function yw(e,t){t===void 0&&(t=bw);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var u=i;i=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){i.push(u),c()},filter:function(u){return i=i.filter(u),n}}}};return o}function xw(e){e===void 0&&(e={});var t=yw(null);return t.options=St({async:!0,ssr:!1},e),t}var Of=function(e){var t=e.sideCar,n=Nf(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return v.createElement(r,St({},n))};Of.isSideCarExport=!0;function vw(e,t){return e.useMedium(t),Of}var If=xw(),ti=function(){},vs=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:ti,onWheelCapture:ti,onTouchMoveCapture:ti}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,g=e.inert,b=e.allowPinchZoom,x=e.as,S=x===void 0?"div":x,k=e.gapMode,y=Nf(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=f,w=gw([n,t]),C=St(St({},y),o);return v.createElement(v.Fragment,null,u&&v.createElement(T,{sideCar:If,removeScrollBar:c,shards:d,noRelative:p,noIsolation:m,inert:g,setCallbacks:s,allowPinchZoom:!!b,lockRef:n,gapMode:k}),i?v.cloneElement(v.Children.only(a),St(St({},C),{ref:w})):v.createElement(S,St({},C,{className:l,ref:w}),a))});vs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};vs.classNames={fullWidth:Io,zeroRight:Oo};var ww=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function kw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=ww();return t&&e.setAttribute("nonce",t),e}function Cw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Sw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Tw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=kw())&&(Cw(t,n),Sw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Aw=function(){var e=Tw();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Pf=function(){var e=Aw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Ew={left:0,top:0,right:0,gap:0},ni=function(e){return parseInt(e||"",10)||0},Mw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ni(n),ni(r),ni(o)]},Rw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ew;var t=Mw(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Nw=Pf(),Un="data-scroll-locked",Ow=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
87
|
-
.`.concat(
|
|
86
|
+
`}),f}var ox=rx,Md=P.Node.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Jy,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:o}=Yy(e,this.options.cellMinWidth),s=t.style;function i(){return s||(r?`width: ${r}`:`min-width: ${o}`)}const a=["table",P.mergeAttributes(this.options.HTMLAttributes,t,{style:i()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},a]:a},parseMarkdown:(e,t)=>{const n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){const o=[];e.header.forEach((s,i)=>{var a;const l=Go((a=r[i])!=null?a:s.align),c=l?{align:l}:{};o.push(t.createNode("tableHeader",c,[{type:"paragraph",content:t.parseInline(s.tokens)}]))}),n.push(t.createNode("tableRow",{},o))}return e.rows&&e.rows.forEach(o=>{const s=[];o.forEach((i,a)=>{var l;const c=Go((l=r[a])!=null?l:i.align),u=c?{align:c}:{};s.push(t.createNode("tableCell",u,[{type:"paragraph",content:t.parseInline(i.tokens)}]))}),n.push(t.createNode("tableRow",{},s))}),t.createNode("table",void 0,n)},renderMarkdown:(e,t)=>ox(e,t),addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:s})=>{const i=Zy(s.schema,e,t,n);if(o){const a=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(he.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>fy(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>py(e,t),deleteColumn:()=>({state:e,dispatch:t})=>my(e,t),addRowBefore:()=>({state:e,dispatch:t})=>by(e,t),addRowAfter:()=>({state:e,dispatch:t})=>yy(e,t),deleteRow:()=>({state:e,dispatch:t})=>vy(e,t),deleteTable:()=>({state:e,dispatch:t})=>Ey(e,t),mergeCells:()=>({state:e,dispatch:t})=>Wl(e,t),splitCell:()=>({state:e,dispatch:t})=>Vl(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Nr("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Nr("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Ty(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>Wl(e,t)?!0:Vl(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>Cy(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Kl(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Kl(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&xd(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const r=be.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:mo,"Mod-Backspace":mo,Delete:mo,"Mod-Delete":mo}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[zy({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Uy({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const e=this.options.resizable&&this.editor.isEditable,t=this.options.View;return e||!t?null:({node:n,view:r})=>new t(n,this.options.cellMinWidth,r)},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:P.callOrReturn(P.getExtensionField(e,"tableRole",t))}}});P.Extension.create({name:"tableKit",addExtensions(){const e=[];return this.options.table!==!1&&e.push(Md.configure(this.options.table)),this.options.tableCell!==!1&&e.push(Td.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(Ad.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(Ed.configure(this.options.tableRow)),e}});var sx=Td,ix=Ad,ax=Ed,lx=20,Rd=(e,t=0)=>{const n=[];return!e.children.length||t>lx||Array.from(e.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Rd(r,t+1))}),n},cx=e=>{if(!e.children.length)return;const t=Rd(e);t&&t.forEach(n=>{var r,o;const s=n.getAttribute("style"),i=(o=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");n.setAttribute("style",`${i};${s}`)})},Nd=P.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&cx(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",P.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(s=>!!s))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),ux=P.Extension.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{var t;const n=(t=P.getStyleProperty(e,"background-color"))!=null?t:e.style.backgroundColor;return n?.replace(/['"]+/g,"")},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:e=>({chain:t})=>t().setMark("textStyle",{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Od=P.Extension.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;const n=(t=P.getStyleProperty(e,"color"))!=null?t:e.style.color;return n?.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),dx=P.Extension.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>{var t;return(t=P.getStyleProperty(e,"font-family"))!=null?t:e.style.fontFamily},renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),fx=P.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>{var t;return(t=P.getStyleProperty(e,"font-size"))!=null?t:e.style.fontSize},renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),px=P.Extension.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>{var t;return(t=P.getStyleProperty(e,"line-height"))!=null?t:e.style.lineHeight},renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:e=>({chain:t})=>t().setMark("textStyle",{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});P.Extension.create({name:"textStyleKit",addExtensions(){const e=[];return this.options.backgroundColor!==!1&&e.push(ux.configure(this.options.backgroundColor)),this.options.color!==!1&&e.push(Od.configure(this.options.color)),this.options.fontFamily!==!1&&e.push(dx.configure(this.options.fontFamily)),this.options.fontSize!==!1&&e.push(fx.configure(this.options.fontSize)),this.options.lineHeight!==!1&&e.push(px.configure(this.options.lineHeight)),this.options.textStyle!==!1&&e.push(Nd.configure(this.options.textStyle)),e}});function Id(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Id(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function hx(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Id(e))&&(r&&(r+=" "),r+=t);return r}const mx=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},gx=(e,t)=>({classGroupId:e,validator:t}),Pd=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Xo="-",nc=[],bx="arbitrary..",yx=e=>{const t=vx(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return xx(i);const a=i.split(Xo),l=a[0]===""&&a.length>1?1:0;return Ld(a,l,t)},getConflictingClassGroupIds:(i,a)=>{if(a){const l=r[i],c=n[i];return l?c?mx(c,l):l:c||nc}return n[i]||nc}}},Ld=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],s=n.nextPart.get(o);if(s){const c=Ld(e,t+1,s);if(c)return c}const i=n.validators;if(i===null)return;const a=t===0?e.join(Xo):e.slice(t).join(Xo),l=i.length;for(let c=0;c<l;c++){const u=i[c];if(u.validator(a))return u.classGroupId}},xx=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?bx+r:void 0})(),vx=e=>{const{theme:t,classGroups:n}=e;return wx(n,t)},wx=(e,t)=>{const n=Pd();for(const r in e){const o=e[r];Sa(o,n,r,t)}return n},Sa=(e,t,n,r)=>{const o=e.length;for(let s=0;s<o;s++){const i=e[s];kx(i,t,n,r)}},kx=(e,t,n,r)=>{if(typeof e=="string"){Cx(e,t,n);return}if(typeof e=="function"){Sx(e,t,n,r);return}Tx(e,t,n,r)},Cx=(e,t,n)=>{const r=e===""?t:Dd(t,e);r.classGroupId=n},Sx=(e,t,n,r)=>{if(Ax(e)){Sa(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(gx(n,e))},Tx=(e,t,n,r)=>{const o=Object.entries(e),s=o.length;for(let i=0;i<s;i++){const[a,l]=o[i];Sa(l,Dd(t,a),n,r)}},Dd=(e,t)=>{let n=e;const r=t.split(Xo),o=r.length;for(let s=0;s<o;s++){const i=r[s];let a=n.nextPart.get(i);a||(a=Pd(),n.nextPart.set(i,a)),n=a}return n},Ax=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Ex=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(s,i)=>{n[s]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let i=n[s];if(i!==void 0)return i;if((i=r[s])!==void 0)return o(s,i),i},set(s,i){s in n?n[s]=i:o(s,i)}}},zi="!",rc=":",Mx=[],oc=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Rx=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const s=[];let i=0,a=0,l=0,c;const u=o.length;for(let g=0;g<u;g++){const b=o[g];if(i===0&&a===0){if(b===rc){s.push(o.slice(l,g)),l=g+1;continue}if(b==="/"){c=g;continue}}b==="["?i++:b==="]"?i--:b==="("?a++:b===")"&&a--}const d=s.length===0?o:o.slice(l);let f=d,p=!1;d.endsWith(zi)?(f=d.slice(0,-1),p=!0):d.startsWith(zi)&&(f=d.slice(1),p=!0);const m=c&&c>l?c-l:void 0;return oc(s,p,f,m)};if(t){const o=t+rc,s=r;r=i=>i.startsWith(o)?s(i.slice(o.length)):oc(Mx,!1,i,void 0,!0)}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},Nx=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let s=0;s<n.length;s++){const i=n[s],a=i[0]==="[",l=t.has(i);a||l?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(i)):o.push(i)}return o.length>0&&(o.sort(),r.push(...o)),r}},Ox=e=>({cache:Ex(e.cacheSize),parseClassName:Rx(e),sortModifiers:Nx(e),postfixLookupClassGroupIds:Ix(e),...yx(e)}),Ix=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},Px=/\s+/,Lx=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:i}=t,a=[],l=e.trim().split(Px);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:f,modifiers:p,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:b}=n(d);if(f){c=d+(c.length>0?" "+c:c);continue}let x=!!b,S;if(x){const C=g.substring(0,b);S=r(C);const T=S&&i[S]?r(g):void 0;T&&T!==S&&(S=T,x=!1)}else S=r(g);if(!S){if(!x){c=d+(c.length>0?" "+c:c);continue}if(S=r(g),!S){c=d+(c.length>0?" "+c:c);continue}x=!1}const k=p.length===0?"":p.length===1?p[0]:s(p).join(":"),y=m?k+zi:k,A=y+S;if(a.indexOf(A)>-1)continue;a.push(A);const w=o(S,x);for(let C=0;C<w.length;++C){const T=w[C];a.push(y+T)}c=d+(c.length>0?" "+c:c)}return c},Dx=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=jd(n))&&(o&&(o+=" "),o+=r);return o},jd=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=jd(e[r]))&&(n&&(n+=" "),n+=t);return n},jx=(e,...t)=>{let n,r,o,s;const i=l=>{const c=t.reduce((u,d)=>d(u),e());return n=Ox(c),r=n.cache.get,o=n.cache.set,s=a,a(l)},a=l=>{const c=r(l);if(c)return c;const u=Lx(l,n);return o(l,u),u};return s=i,(...l)=>s(Dx(...l))},zx=[],Me=e=>{const t=n=>n[e]||zx;return t.isThemeGetter=!0,t},zd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,_d=/^\((?:(\w[\w-]*):)?(.+)\)$/i,_x=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,$x=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Fx=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Bx=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Hx=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Wx=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Kt=e=>_x.test(e),ie=e=>!!e&&!Number.isNaN(Number(e)),vt=e=>!!e&&Number.isInteger(Number(e)),Us=e=>e.endsWith("%")&&ie(e.slice(0,-1)),jt=e=>$x.test(e),$d=()=>!0,Vx=e=>Fx.test(e)&&!Bx.test(e),Ta=()=>!1,qx=e=>Hx.test(e),Kx=e=>Wx.test(e),Ux=e=>!Y(e)&&!Q(e),Gx=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Xx=e=>sn(e,Hd,Ta),Y=e=>zd.test(e),pn=e=>sn(e,Wd,Vx),sc=e=>sn(e,r0,ie),Jx=e=>sn(e,qd,$d),Yx=e=>sn(e,Vd,Ta),ic=e=>sn(e,Fd,Ta),Qx=e=>sn(e,Bd,Kx),go=e=>sn(e,Kd,qx),Q=e=>_d.test(e),ur=e=>Nn(e,Wd),Zx=e=>Nn(e,Vd),ac=e=>Nn(e,Fd),e0=e=>Nn(e,Hd),t0=e=>Nn(e,Bd),bo=e=>Nn(e,Kd,!0),n0=e=>Nn(e,qd,!0),sn=(e,t,n)=>{const r=zd.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Nn=(e,t,n=!1)=>{const r=_d.exec(e);return r?r[1]?t(r[1]):n:!1},Fd=e=>e==="position"||e==="percentage",Bd=e=>e==="image"||e==="url",Hd=e=>e==="length"||e==="size"||e==="bg-size",Wd=e=>e==="length",r0=e=>e==="number",Vd=e=>e==="family-name",qd=e=>e==="number"||e==="weight",Kd=e=>e==="shadow",o0=()=>{const e=Me("color"),t=Me("font"),n=Me("text"),r=Me("font-weight"),o=Me("tracking"),s=Me("leading"),i=Me("breakpoint"),a=Me("container"),l=Me("spacing"),c=Me("radius"),u=Me("shadow"),d=Me("inset-shadow"),f=Me("text-shadow"),p=Me("drop-shadow"),m=Me("blur"),g=Me("perspective"),b=Me("aspect"),x=Me("ease"),S=Me("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...y(),Q,Y],w=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],T=()=>[Q,Y,l],I=()=>[Kt,"full","auto",...T()],O=()=>[vt,"none","subgrid",Q,Y],j=()=>["auto",{span:["full",vt,Q,Y]},vt,Q,Y],D=()=>[vt,"auto",Q,Y],F=()=>["auto","min","max","fr",Q,Y],B=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],N=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...T()],V=()=>[Kt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],_=()=>[Kt,"screen","full","dvw","lvw","svw","min","max","fit",...T()],R=()=>[Kt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],z=()=>[e,Q,Y],W=()=>[...y(),ac,ic,{position:[Q,Y]}],re=()=>["no-repeat",{repeat:["","x","y","space","round"]}],se=()=>["auto","cover","contain",e0,Xx,{size:[Q,Y]}],le=()=>[Us,ur,pn],te=()=>["","none","full",c,Q,Y],G=()=>["",ie,ur,pn],H=()=>["solid","dashed","dotted","double"],J=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],oe=()=>[ie,Us,ac,ic],ge=()=>["","none",m,Q,Y],Ce=()=>["none",ie,Q,Y],ve=()=>["none",ie,Q,Y],we=()=>[ie,Q,Y],Ee=()=>[Kt,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[jt],breakpoint:[jt],color:[$d],container:[jt],"drop-shadow":[jt],ease:["in","out","in-out"],font:[Ux],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[jt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[jt],shadow:[jt],spacing:["px",ie],text:[jt],"text-shadow":[jt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Kt,Y,Q,b]}],container:["container"],"container-type":[{"@container":["","normal","size",Q,Y]}],"container-named":[Gx],columns:[{columns:[ie,Y,Q,a]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:w()}],"overflow-x":[{"overflow-x":w()}],"overflow-y":[{"overflow-y":w()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{"inset-s":I(),start:I()}],end:[{"inset-e":I(),end:I()}],"inset-bs":[{"inset-bs":I()}],"inset-be":[{"inset-be":I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[vt,"auto",Q,Y]}],basis:[{basis:[Kt,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ie,Kt,"auto","initial","none",Y]}],grow:[{grow:["",ie,Q,Y]}],shrink:[{shrink:["",ie,Q,Y]}],order:[{order:[vt,"first","last","none",Q,Y]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:j()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:j()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":F()}],"auto-rows":[{"auto-rows":F()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...B(),"normal"]}],"justify-items":[{"justify-items":[...N(),"normal"]}],"justify-self":[{"justify-self":["auto",...N()]}],"align-content":[{content:["normal",...B()]}],"align-items":[{items:[...N(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...N(),{baseline:["","last"]}]}],"place-content":[{"place-content":B()}],"place-items":[{"place-items":[...N(),"baseline"]}],"place-self":[{"place-self":["auto",...N()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mbs:[{mbs:$()}],mbe:[{mbe:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:V()}],"inline-size":[{inline:["auto",..._()]}],"min-inline-size":[{"min-inline":["auto",..._()]}],"max-inline-size":[{"max-inline":["none",..._()]}],"block-size":[{block:["auto",...R()]}],"min-block-size":[{"min-block":["auto",...R()]}],"max-block-size":[{"max-block":["none",...R()]}],w:[{w:[a,"screen",...V()]}],"min-w":[{"min-w":[a,"screen","none",...V()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...V()]}],h:[{h:["screen","lh",...V()]}],"min-h":[{"min-h":["screen","lh","none",...V()]}],"max-h":[{"max-h":["screen","lh",...V()]}],"font-size":[{text:["base",n,ur,pn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,n0,Jx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Us,Y]}],"font-family":[{font:[Zx,Yx,t]}],"font-features":[{"font-features":[Y]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Q,Y]}],"line-clamp":[{"line-clamp":[ie,"none",Q,sc]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",Q,Y]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Q,Y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:z()}],"text-color":[{text:z()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...H(),"wavy"]}],"text-decoration-thickness":[{decoration:[ie,"from-font","auto",Q,pn]}],"text-decoration-color":[{decoration:z()}],"underline-offset":[{"underline-offset":[ie,"auto",Q,Y]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"tab-size":[{tab:[vt,Q,Y]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Q,Y]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Q,Y]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:re()}],"bg-size":[{bg:se()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},vt,Q,Y],radial:["",Q,Y],conic:[vt,Q,Y]},t0,Qx]}],"bg-color":[{bg:z()}],"gradient-from-pos":[{from:le()}],"gradient-via-pos":[{via:le()}],"gradient-to-pos":[{to:le()}],"gradient-from":[{from:z()}],"gradient-via":[{via:z()}],"gradient-to":[{to:z()}],rounded:[{rounded:te()}],"rounded-s":[{"rounded-s":te()}],"rounded-e":[{"rounded-e":te()}],"rounded-t":[{"rounded-t":te()}],"rounded-r":[{"rounded-r":te()}],"rounded-b":[{"rounded-b":te()}],"rounded-l":[{"rounded-l":te()}],"rounded-ss":[{"rounded-ss":te()}],"rounded-se":[{"rounded-se":te()}],"rounded-ee":[{"rounded-ee":te()}],"rounded-es":[{"rounded-es":te()}],"rounded-tl":[{"rounded-tl":te()}],"rounded-tr":[{"rounded-tr":te()}],"rounded-br":[{"rounded-br":te()}],"rounded-bl":[{"rounded-bl":te()}],"border-w":[{border:G()}],"border-w-x":[{"border-x":G()}],"border-w-y":[{"border-y":G()}],"border-w-s":[{"border-s":G()}],"border-w-e":[{"border-e":G()}],"border-w-bs":[{"border-bs":G()}],"border-w-be":[{"border-be":G()}],"border-w-t":[{"border-t":G()}],"border-w-r":[{"border-r":G()}],"border-w-b":[{"border-b":G()}],"border-w-l":[{"border-l":G()}],"divide-x":[{"divide-x":G()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":G()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...H(),"hidden","none"]}],"divide-style":[{divide:[...H(),"hidden","none"]}],"border-color":[{border:z()}],"border-color-x":[{"border-x":z()}],"border-color-y":[{"border-y":z()}],"border-color-s":[{"border-s":z()}],"border-color-e":[{"border-e":z()}],"border-color-bs":[{"border-bs":z()}],"border-color-be":[{"border-be":z()}],"border-color-t":[{"border-t":z()}],"border-color-r":[{"border-r":z()}],"border-color-b":[{"border-b":z()}],"border-color-l":[{"border-l":z()}],"divide-color":[{divide:z()}],"outline-style":[{outline:[...H(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ie,Q,Y]}],"outline-w":[{outline:["",ie,ur,pn]}],"outline-color":[{outline:z()}],shadow:[{shadow:["","none",u,bo,go]}],"shadow-color":[{shadow:z()}],"inset-shadow":[{"inset-shadow":["none",d,bo,go]}],"inset-shadow-color":[{"inset-shadow":z()}],"ring-w":[{ring:G()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:z()}],"ring-offset-w":[{"ring-offset":[ie,pn]}],"ring-offset-color":[{"ring-offset":z()}],"inset-ring-w":[{"inset-ring":G()}],"inset-ring-color":[{"inset-ring":z()}],"text-shadow":[{"text-shadow":["none",f,bo,go]}],"text-shadow-color":[{"text-shadow":z()}],opacity:[{opacity:[ie,Q,Y]}],"mix-blend":[{"mix-blend":[...J(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":J()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ie]}],"mask-image-linear-from-pos":[{"mask-linear-from":oe()}],"mask-image-linear-to-pos":[{"mask-linear-to":oe()}],"mask-image-linear-from-color":[{"mask-linear-from":z()}],"mask-image-linear-to-color":[{"mask-linear-to":z()}],"mask-image-t-from-pos":[{"mask-t-from":oe()}],"mask-image-t-to-pos":[{"mask-t-to":oe()}],"mask-image-t-from-color":[{"mask-t-from":z()}],"mask-image-t-to-color":[{"mask-t-to":z()}],"mask-image-r-from-pos":[{"mask-r-from":oe()}],"mask-image-r-to-pos":[{"mask-r-to":oe()}],"mask-image-r-from-color":[{"mask-r-from":z()}],"mask-image-r-to-color":[{"mask-r-to":z()}],"mask-image-b-from-pos":[{"mask-b-from":oe()}],"mask-image-b-to-pos":[{"mask-b-to":oe()}],"mask-image-b-from-color":[{"mask-b-from":z()}],"mask-image-b-to-color":[{"mask-b-to":z()}],"mask-image-l-from-pos":[{"mask-l-from":oe()}],"mask-image-l-to-pos":[{"mask-l-to":oe()}],"mask-image-l-from-color":[{"mask-l-from":z()}],"mask-image-l-to-color":[{"mask-l-to":z()}],"mask-image-x-from-pos":[{"mask-x-from":oe()}],"mask-image-x-to-pos":[{"mask-x-to":oe()}],"mask-image-x-from-color":[{"mask-x-from":z()}],"mask-image-x-to-color":[{"mask-x-to":z()}],"mask-image-y-from-pos":[{"mask-y-from":oe()}],"mask-image-y-to-pos":[{"mask-y-to":oe()}],"mask-image-y-from-color":[{"mask-y-from":z()}],"mask-image-y-to-color":[{"mask-y-to":z()}],"mask-image-radial":[{"mask-radial":[Q,Y]}],"mask-image-radial-from-pos":[{"mask-radial-from":oe()}],"mask-image-radial-to-pos":[{"mask-radial-to":oe()}],"mask-image-radial-from-color":[{"mask-radial-from":z()}],"mask-image-radial-to-color":[{"mask-radial-to":z()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":y()}],"mask-image-conic-pos":[{"mask-conic":[ie]}],"mask-image-conic-from-pos":[{"mask-conic-from":oe()}],"mask-image-conic-to-pos":[{"mask-conic-to":oe()}],"mask-image-conic-from-color":[{"mask-conic-from":z()}],"mask-image-conic-to-color":[{"mask-conic-to":z()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:W()}],"mask-repeat":[{mask:re()}],"mask-size":[{mask:se()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Q,Y]}],filter:[{filter:["","none",Q,Y]}],blur:[{blur:ge()}],brightness:[{brightness:[ie,Q,Y]}],contrast:[{contrast:[ie,Q,Y]}],"drop-shadow":[{"drop-shadow":["","none",p,bo,go]}],"drop-shadow-color":[{"drop-shadow":z()}],grayscale:[{grayscale:["",ie,Q,Y]}],"hue-rotate":[{"hue-rotate":[ie,Q,Y]}],invert:[{invert:["",ie,Q,Y]}],saturate:[{saturate:[ie,Q,Y]}],sepia:[{sepia:["",ie,Q,Y]}],"backdrop-filter":[{"backdrop-filter":["","none",Q,Y]}],"backdrop-blur":[{"backdrop-blur":ge()}],"backdrop-brightness":[{"backdrop-brightness":[ie,Q,Y]}],"backdrop-contrast":[{"backdrop-contrast":[ie,Q,Y]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ie,Q,Y]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ie,Q,Y]}],"backdrop-invert":[{"backdrop-invert":["",ie,Q,Y]}],"backdrop-opacity":[{"backdrop-opacity":[ie,Q,Y]}],"backdrop-saturate":[{"backdrop-saturate":[ie,Q,Y]}],"backdrop-sepia":[{"backdrop-sepia":["",ie,Q,Y]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Q,Y]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ie,"initial",Q,Y]}],ease:[{ease:["linear","initial",x,Q,Y]}],delay:[{delay:[ie,Q,Y]}],animate:[{animate:["none",S,Q,Y]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,Q,Y]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:Ce()}],"rotate-x":[{"rotate-x":Ce()}],"rotate-y":[{"rotate-y":Ce()}],"rotate-z":[{"rotate-z":Ce()}],scale:[{scale:ve()}],"scale-x":[{"scale-x":ve()}],"scale-y":[{"scale-y":ve()}],"scale-z":[{"scale-z":ve()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[Q,Y,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ee()}],"translate-x":[{"translate-x":Ee()}],"translate-y":[{"translate-y":Ee()}],"translate-z":[{"translate-z":Ee()}],"translate-none":["translate-none"],zoom:[{zoom:[vt,Q,Y]}],accent:[{accent:z()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:z()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Q,Y]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":z()}],"scrollbar-track-color":[{"scrollbar-track":z()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Q,Y]}],fill:[{fill:["none",...z()]}],"stroke-w":[{stroke:[ie,ur,pn,sc]}],stroke:[{stroke:["none",...z()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},s0=jx(o0);function M(...e){return s0(hx(e))}const Wr=K.createContext({theme:"light",translations:Xn}),We=()=>K.useContext(Wr).theme,Vr=()=>K.useContext(Wr).translations,Ve=()=>K.useContext(Wr).classNames,i0=()=>K.useContext(Wr).styles,Jo=()=>{if(typeof document>"u")return null;const e=document.fullscreenElement;return e instanceof HTMLElement?e:document.body},qr=()=>{const[e,t]=K.useState(()=>Jo());return K.useEffect(()=>{const n=()=>{t(Jo())};return n(),document.addEventListener("fullscreenchange",n),()=>{document.removeEventListener("fullscreenchange",n)}},[]),e},kt=({children:e,content:t})=>{const n=We(),r=Ve(),o=qr();return t?h.jsxs(Fn.Root,{delayDuration:500,children:[h.jsx(Fn.Trigger,{asChild:!0,children:e}),h.jsx(Fn.Portal,{container:o??void 0,children:h.jsxs(Fn.Content,{sideOffset:6,className:M("z-50 px-3 py-1.5 text-xs font-medium rounded-full shadow-lg select-none","animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",n==="dark"?"bg-neutral-100 text-neutral-900":"bg-neutral-900 text-neutral-100",r?.tooltipContent),children:[t,h.jsx(Fn.Arrow,{className:M(n==="dark"?"fill-neutral-100":"fill-neutral-900",r?.tooltipArrow)})]})})]}):h.jsx(h.Fragment,{children:e})};function ae(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function lc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ms(...e){return t=>{let n=!1;const r=e.map(o=>{const s=lc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():lc(e[o],null)}}}}function De(...e){return v.useCallback(ms(...e),e)}function sr(e,t=[]){let n=[];function r(s,i){const a=v.createContext(i),l=n.length;n=[...n,i];const c=d=>{const{scope:f,children:p,...m}=d,g=f?.[e]?.[l]||a,b=v.useMemo(()=>m,Object.values(m));return h.jsx(g.Provider,{value:b,children:p})};c.displayName=s+"Provider";function u(d,f){const p=f?.[e]?.[l]||a,m=v.useContext(p);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[c,u]}const o=()=>{const s=n.map(i=>v.createContext(i));return function(a){const l=a?.[e]||s;return v.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,a0(o,...t)]}function a0(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var tn=globalThis?.document?v.useLayoutEffect:()=>{},l0=v[" useInsertionEffect ".trim().toString()]||tn;function gs({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=c0({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const u=v.useRef(e!==void 0);v.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const c=v.useCallback(u=>{if(a){const d=u0(u)?u(e):u;d!==e&&i.current?.(d)}else s(u)},[a,e,s,i]);return[l,c]}function c0({defaultProp:e,onChange:t}){const[n,r]=v.useState(e),o=v.useRef(n),s=v.useRef(t);return l0(()=>{s.current=t},[t]),v.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}function u0(e){return typeof e=="function"}function Or(e){const t=d0(e),n=v.forwardRef((r,o)=>{const{children:s,...i}=r,a=v.Children.toArray(s),l=a.find(p0);if(l){const c=l.props.children,u=a.map(d=>d===l?v.Children.count(c)>1?v.Children.only(null):v.isValidElement(c)?c.props.children:null:d);return h.jsx(t,{...i,ref:o,children:v.isValidElement(c)?v.cloneElement(c,void 0,u):null})}return h.jsx(t,{...i,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}function d0(e){const t=v.forwardRef((n,r)=>{const{children:o,...s}=n;if(v.isValidElement(o)){const i=m0(o),a=h0(s,o.props);return o.type!==v.Fragment&&(a.ref=r?ms(r,i):i),v.cloneElement(o,a)}return v.Children.count(o)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var f0=Symbol("radix.slottable");function p0(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===f0}function h0(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const l=s(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function m0(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var g0=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=g0.reduce((e,t)=>{const n=Or(`Primitive.${t}`),r=v.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ud(e,t){e&&su.flushSync(()=>e.dispatchEvent(t))}function Gd(e){const t=e+"CollectionProvider",[n,r]=sr(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:b,children:x}=g,S=K.useRef(null),k=K.useRef(new Map).current;return h.jsx(o,{scope:b,itemMap:k,collectionRef:S,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=Or(a),c=K.forwardRef((g,b)=>{const{scope:x,children:S}=g,k=s(a,x),y=De(b,k.collectionRef);return h.jsx(l,{ref:y,children:S})});c.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",f=Or(u),p=K.forwardRef((g,b)=>{const{scope:x,children:S,...k}=g,y=K.useRef(null),A=De(b,y),w=s(u,x);return K.useEffect(()=>(w.itemMap.set(y,{ref:y,...k}),()=>{w.itemMap.delete(y)})),h.jsx(f,{[d]:"",ref:A,children:S})});p.displayName=u;function m(g){const b=s(e+"CollectionConsumer",g);return K.useCallback(()=>{const S=b.collectionRef.current;if(!S)return[];const k=Array.from(S.querySelectorAll(`[${d}]`));return Array.from(b.itemMap.values()).sort((w,C)=>k.indexOf(w.ref.current)-k.indexOf(C.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},m,r]}var b0=v.createContext(void 0);function Xd(e){const t=v.useContext(b0);return e||t||"ltr"}function Ot(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...n)=>t.current?.(...n),[])}function y0(e,t=globalThis?.document){const n=Ot(e);v.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var x0="DismissableLayer",_i="dismissableLayer.update",v0="dismissableLayer.pointerDownOutside",w0="dismissableLayer.focusOutside",cc,Jd=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Aa=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=v.useContext(Jd),[u,d]=v.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=v.useState({}),m=De(t,C=>d(C)),g=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),x=g.indexOf(b),S=u?g.indexOf(u):-1,k=c.layersWithOutsidePointerEventsDisabled.size>0,y=S>=x,A=S0(C=>{const T=C.target,I=[...c.branches].some(O=>O.contains(T));!y||I||(o?.(C),i?.(C),C.defaultPrevented||a?.())},f),w=T0(C=>{const T=C.target;[...c.branches].some(O=>O.contains(T))||(s?.(C),i?.(C),C.defaultPrevented||a?.())},f);return y0(C=>{S===c.layers.size-1&&(r?.(C),!C.defaultPrevented&&a&&(C.preventDefault(),a()))},f),v.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(cc=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),uc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=cc)}},[u,f,n,c]),v.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),uc())},[u,c]),v.useEffect(()=>{const C=()=>p({});return document.addEventListener(_i,C),()=>document.removeEventListener(_i,C)},[]),h.jsx(Ie.div,{...l,ref:m,style:{pointerEvents:k?y?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,w.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,A.onPointerDownCapture)})});Aa.displayName=x0;var k0="DismissableLayerBranch",C0=v.forwardRef((e,t)=>{const n=v.useContext(Jd),r=v.useRef(null),o=De(t,r);return v.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),h.jsx(Ie.div,{...e,ref:o})});C0.displayName=k0;function S0(e,t=globalThis?.document){const n=Ot(e),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Yd(v0,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function T0(e,t=globalThis?.document){const n=Ot(e),r=v.useRef(!1);return v.useEffect(()=>{const o=s=>{s.target&&!r.current&&Yd(w0,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function uc(){const e=new CustomEvent(_i);document.dispatchEvent(e)}function Yd(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Ud(o,s):o.dispatchEvent(s)}var Gs=0;function Qd(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??dc()),document.body.insertAdjacentElement("beforeend",e[1]??dc()),Gs++,()=>{Gs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Gs--}},[])}function dc(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Xs="focusScope.autoFocusOnMount",Js="focusScope.autoFocusOnUnmount",fc={bubbles:!1,cancelable:!0},A0="FocusScope",Ea=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=v.useState(null),c=Ot(o),u=Ot(s),d=v.useRef(null),f=De(t,g=>l(g)),p=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let g=function(k){if(p.paused||!a)return;const y=k.target;a.contains(y)?d.current=y:Ut(d.current,{select:!0})},b=function(k){if(p.paused||!a)return;const y=k.relatedTarget;y!==null&&(a.contains(y)||Ut(d.current,{select:!0}))},x=function(k){if(document.activeElement===document.body)for(const A of k)A.removedNodes.length>0&&Ut(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",b);const S=new MutationObserver(x);return a&&S.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",b),S.disconnect()}}},[r,a,p.paused]),v.useEffect(()=>{if(a){hc.add(p);const g=document.activeElement;if(!a.contains(g)){const x=new CustomEvent(Xs,fc);a.addEventListener(Xs,c),a.dispatchEvent(x),x.defaultPrevented||(E0(I0(Zd(a)),{select:!0}),document.activeElement===g&&Ut(a))}return()=>{a.removeEventListener(Xs,c),setTimeout(()=>{const x=new CustomEvent(Js,fc);a.addEventListener(Js,u),a.dispatchEvent(x),x.defaultPrevented||Ut(g??document.body,{select:!0}),a.removeEventListener(Js,u),hc.remove(p)},0)}}},[a,c,u,p]);const m=v.useCallback(g=>{if(!n&&!r||p.paused)return;const b=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,x=document.activeElement;if(b&&x){const S=g.currentTarget,[k,y]=M0(S);k&&y?!g.shiftKey&&x===y?(g.preventDefault(),n&&Ut(k,{select:!0})):g.shiftKey&&x===k&&(g.preventDefault(),n&&Ut(y,{select:!0})):x===S&&g.preventDefault()}},[n,r,p.paused]);return h.jsx(Ie.div,{tabIndex:-1,...i,ref:f,onKeyDown:m})});Ea.displayName=A0;function E0(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ut(r,{select:t}),document.activeElement!==n)return}function M0(e){const t=Zd(e),n=pc(t,e),r=pc(t.reverse(),e);return[n,r]}function Zd(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function pc(e,t){for(const n of e)if(!R0(n,{upTo:t}))return n}function R0(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function N0(e){return e instanceof HTMLInputElement&&"select"in e}function Ut(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&N0(e)&&t&&e.select()}}var hc=O0();function O0(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=mc(e,t),e.unshift(t)},remove(t){e=mc(e,t),e[0]?.resume()}}}function mc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function I0(e){return e.filter(t=>t.tagName!=="A")}var P0=v[" useId ".trim().toString()]||(()=>{}),L0=0;function Yn(e){const[t,n]=v.useState(P0());return tn(()=>{n(r=>r??String(L0++))},[e]),t?`radix-${t}`:""}const D0=["top","right","bottom","left"],nn=Math.min,Ye=Math.max,Yo=Math.round,yo=Math.floor,Mt=e=>({x:e,y:e}),j0={left:"right",right:"left",bottom:"top",top:"bottom"};function $i(e,t,n){return Ye(e,nn(t,n))}function $t(e,t){return typeof e=="function"?e(t):e}function Ft(e){return e.split("-")[0]}function ir(e){return e.split("-")[1]}function Ma(e){return e==="x"?"y":"x"}function Ra(e){return e==="y"?"height":"width"}function At(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Na(e){return Ma(At(e))}function z0(e,t,n){n===void 0&&(n=!1);const r=ir(e),o=Na(e),s=Ra(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Qo(i)),[i,Qo(i)]}function _0(e){const t=Qo(e);return[Fi(e),t,Fi(t)]}function Fi(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const gc=["left","right"],bc=["right","left"],$0=["top","bottom"],F0=["bottom","top"];function B0(e,t,n){switch(e){case"top":case"bottom":return n?t?bc:gc:t?gc:bc;case"left":case"right":return t?$0:F0;default:return[]}}function H0(e,t,n,r){const o=ir(e);let s=B0(Ft(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Fi)))),s}function Qo(e){const t=Ft(e);return j0[t]+e.slice(t.length)}function W0(e){return{top:0,right:0,bottom:0,left:0,...e}}function ef(e){return typeof e!="number"?W0(e):{top:e,right:e,bottom:e,left:e}}function Zo(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function yc(e,t,n){let{reference:r,floating:o}=e;const s=At(t),i=Na(t),a=Ra(i),l=Ft(t),c=s==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,f=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-o.width,y:d};break;default:p={x:r.x,y:r.y}}switch(ir(t)){case"start":p[i]-=f*(n&&c?-1:1);break;case"end":p[i]+=f*(n&&c?-1:1);break}return p}async function V0(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=$t(t,e),m=ef(p),b=a[f?d==="floating"?"reference":"floating":d],x=Zo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),S=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,k=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),y=await(s.isElement==null?void 0:s.isElement(k))?await(s.getScale==null?void 0:s.getScale(k))||{x:1,y:1}:{x:1,y:1},A=Zo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:S,offsetParent:k,strategy:l}):S);return{top:(x.top-A.top+m.top)/y.y,bottom:(A.bottom-x.bottom+m.bottom)/y.y,left:(x.left-A.left+m.left)/y.x,right:(A.right-x.right+m.right)/y.x}}const q0=50,K0=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=i.detectOverflow?i:{...i,detectOverflow:V0},l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=yc(c,r,l),f=r,p=0;const m={};for(let g=0;g<s.length;g++){const b=s[g];if(!b)continue;const{name:x,fn:S}=b,{x:k,y,data:A,reset:w}=await S({x:u,y:d,initialPlacement:r,placement:f,strategy:o,middlewareData:m,rects:c,platform:a,elements:{reference:e,floating:t}});u=k??u,d=y??d,m[x]={...m[x],...A},w&&p<q0&&(p++,typeof w=="object"&&(w.placement&&(f=w.placement),w.rects&&(c=w.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):w.rects),{x:u,y:d}=yc(c,f,l)),g=-1)}return{x:u,y:d,placement:f,strategy:o,middlewareData:m}},U0=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=$t(e,t)||{};if(c==null)return{};const d=ef(u),f={x:n,y:r},p=Na(o),m=Ra(p),g=await i.getDimensions(c),b=p==="y",x=b?"top":"left",S=b?"bottom":"right",k=b?"clientHeight":"clientWidth",y=s.reference[m]+s.reference[p]-f[p]-s.floating[m],A=f[p]-s.reference[p],w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let C=w?w[k]:0;(!C||!await(i.isElement==null?void 0:i.isElement(w)))&&(C=a.floating[k]||s.floating[m]);const T=y/2-A/2,I=C/2-g[m]/2-1,O=nn(d[x],I),j=nn(d[S],I),D=O,F=C-g[m]-j,B=C/2-g[m]/2+T,N=$i(D,B,F),$=!l.arrow&&ir(o)!=null&&B!==N&&s.reference[m]/2-(B<D?O:j)-g[m]/2<0,V=$?B<D?B-D:B-F:0;return{[p]:f[p]+V,data:{[p]:N,centerOffset:B-N-V,...$&&{alignmentOffset:V}},reset:$}}}),G0=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...b}=$t(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Ft(o),S=At(a),k=Ft(a)===a,y=await(l.isRTL==null?void 0:l.isRTL(c.floating)),A=f||(k||!g?[Qo(a)]:_0(a)),w=m!=="none";!f&&w&&A.push(...H0(a,g,m,y));const C=[a,...A],T=await l.detectOverflow(t,b),I=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&I.push(T[x]),d){const B=z0(o,i,y);I.push(T[B[0]],T[B[1]])}if(O=[...O,{placement:o,overflows:I}],!I.every(B=>B<=0)){var j,D;const B=(((j=s.flip)==null?void 0:j.index)||0)+1,N=C[B];if(N&&(!(d==="alignment"?S!==At(N):!1)||O.every(_=>At(_.placement)===S?_.overflows[0]>0:!0)))return{data:{index:B,overflows:O},reset:{placement:N}};let $=(D=O.filter(V=>V.overflows[0]<=0).sort((V,_)=>V.overflows[1]-_.overflows[1])[0])==null?void 0:D.placement;if(!$)switch(p){case"bestFit":{var F;const V=(F=O.filter(_=>{if(w){const R=At(_.placement);return R===S||R==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(R=>R>0).reduce((R,z)=>R+z,0)]).sort((_,R)=>_[1]-R[1])[0])==null?void 0:F[0];V&&($=V);break}case"initialPlacement":$=a;break}if(o!==$)return{reset:{placement:$}}}return{}}}};function xc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function vc(e){return D0.some(t=>e[t]>=0)}const X0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...s}=$t(e,t);switch(o){case"referenceHidden":{const i=await r.detectOverflow(t,{...s,elementContext:"reference"}),a=xc(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:vc(a)}}}case"escaped":{const i=await r.detectOverflow(t,{...s,altBoundary:!0}),a=xc(i,n.floating);return{data:{escapedOffsets:a,escaped:vc(a)}}}default:return{}}}}},tf=new Set(["left","top"]);async function J0(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Ft(n),a=ir(n),l=At(n)==="y",c=tf.has(i)?-1:1,u=s&&l?-1:1,d=$t(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}const Y0=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await J0(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},Q0=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:x=>{let{x:S,y:k}=x;return{x:S,y:k}}},...c}=$t(e,t),u={x:n,y:r},d=await s.detectOverflow(t,c),f=At(Ft(o)),p=Ma(f);let m=u[p],g=u[f];if(i){const x=p==="y"?"top":"left",S=p==="y"?"bottom":"right",k=m+d[x],y=m-d[S];m=$i(k,m,y)}if(a){const x=f==="y"?"top":"left",S=f==="y"?"bottom":"right",k=g+d[x],y=g-d[S];g=$i(k,g,y)}const b=l.fn({...t,[p]:m,[f]:g});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[p]:i,[f]:a}}}}}},Z0=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=$t(e,t),u={x:n,y:r},d=At(o),f=Ma(d);let p=u[f],m=u[d];const g=$t(a,t),b=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const k=f==="y"?"height":"width",y=s.reference[f]-s.floating[k]+b.mainAxis,A=s.reference[f]+s.reference[k]-b.mainAxis;p<y?p=y:p>A&&(p=A)}if(c){var x,S;const k=f==="y"?"width":"height",y=tf.has(Ft(o)),A=s.reference[d]-s.floating[k]+(y&&((x=i.offset)==null?void 0:x[d])||0)+(y?0:b.crossAxis),w=s.reference[d]+s.reference[k]+(y?0:((S=i.offset)==null?void 0:S[d])||0)-(y?b.crossAxis:0);m<A?m=A:m>w&&(m=w)}return{[f]:p,[d]:m}}}},ev=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=$t(e,t),u=await i.detectOverflow(t,c),d=Ft(o),f=ir(o),p=At(o)==="y",{width:m,height:g}=s.floating;let b,x;d==="top"||d==="bottom"?(b=d,x=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,b=f==="end"?"top":"bottom");const S=g-u.top-u.bottom,k=m-u.left-u.right,y=nn(g-u[b],S),A=nn(m-u[x],k),w=!t.middlewareData.shift;let C=y,T=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=k),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=S),w&&!f){const O=Ye(u.left,0),j=Ye(u.right,0),D=Ye(u.top,0),F=Ye(u.bottom,0);p?T=m-2*(O!==0||j!==0?O+j:Ye(u.left,u.right)):C=g-2*(D!==0||F!==0?D+F:Ye(u.top,u.bottom))}await l({...t,availableWidth:T,availableHeight:C});const I=await i.getDimensions(a.floating);return m!==I.width||g!==I.height?{reset:{rects:!0}}:{}}}};function bs(){return typeof window<"u"}function ar(e){return nf(e)?(e.nodeName||"").toLowerCase():"#document"}function nt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Lt(e){var t;return(t=(nf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function nf(e){return bs()?e instanceof Node||e instanceof nt(e).Node:!1}function gt(e){return bs()?e instanceof Element||e instanceof nt(e).Element:!1}function Wt(e){return bs()?e instanceof HTMLElement||e instanceof nt(e).HTMLElement:!1}function wc(e){return!bs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof nt(e).ShadowRoot}function Kr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=bt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function tv(e){return/^(table|td|th)$/.test(ar(e))}function ys(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const nv=/transform|translate|scale|rotate|perspective|filter/,rv=/paint|layout|strict|content/,hn=e=>!!e&&e!=="none";let Ys;function Oa(e){const t=gt(e)?bt(e):e;return hn(t.transform)||hn(t.translate)||hn(t.scale)||hn(t.rotate)||hn(t.perspective)||!Ia()&&(hn(t.backdropFilter)||hn(t.filter))||nv.test(t.willChange||"")||rv.test(t.contain||"")}function ov(e){let t=rn(e);for(;Wt(t)&&!Qn(t);){if(Oa(t))return t;if(ys(t))return null;t=rn(t)}return null}function Ia(){return Ys==null&&(Ys=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ys}function Qn(e){return/^(html|body|#document)$/.test(ar(e))}function bt(e){return nt(e).getComputedStyle(e)}function xs(e){return gt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function rn(e){if(ar(e)==="html")return e;const t=e.assignedSlot||e.parentNode||wc(e)&&e.host||Lt(e);return wc(t)?t.host:t}function rf(e){const t=rn(e);return Qn(t)?e.ownerDocument?e.ownerDocument.body:e.body:Wt(t)&&Kr(t)?t:rf(t)}function Ir(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=rf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=nt(o);if(s){const a=Bi(i);return t.concat(i,i.visualViewport||[],Kr(o)?o:[],a&&n?Ir(a):[])}else return t.concat(o,Ir(o,[],n))}function Bi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function of(e){const t=bt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Wt(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Yo(n)!==s||Yo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Pa(e){return gt(e)?e:e.contextElement}function Kn(e){const t=Pa(e);if(!Wt(t))return Mt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=of(t);let i=(s?Yo(n.width):n.width)/r,a=(s?Yo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const sv=Mt(0);function sf(e){const t=nt(e);return!Ia()||!t.visualViewport?sv:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function iv(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==nt(e)?!1:t}function Tn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Pa(e);let i=Mt(1);t&&(r?gt(r)&&(i=Kn(r)):i=Kn(e));const a=iv(s,n,r)?sf(s):Mt(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,d=o.height/i.y;if(s){const f=nt(s),p=r&>(r)?nt(r):r;let m=f,g=Bi(m);for(;g&&r&&p!==m;){const b=Kn(g),x=g.getBoundingClientRect(),S=bt(g),k=x.left+(g.clientLeft+parseFloat(S.paddingLeft))*b.x,y=x.top+(g.clientTop+parseFloat(S.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=k,c+=y,m=nt(g),g=Bi(m)}}return Zo({width:u,height:d,x:l,y:c})}function vs(e,t){const n=xs(e).scrollLeft;return t?t.left+n:Tn(Lt(e)).left+n}function af(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-vs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function av(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Lt(r),a=t?ys(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Mt(1);const u=Mt(0),d=Wt(r);if((d||!d&&!s)&&((ar(r)!=="body"||Kr(i))&&(l=xs(r)),d)){const p=Tn(r);c=Kn(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const f=i&&!d&&!s?af(i,l):Mt(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function lv(e){return Array.from(e.getClientRects())}function cv(e){const t=Lt(e),n=xs(e),r=e.ownerDocument.body,o=Ye(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ye(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+vs(e);const a=-n.scrollTop;return bt(r).direction==="rtl"&&(i+=Ye(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const kc=25;function uv(e,t){const n=nt(e),r=Lt(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=Ia();(!u||u&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=vs(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(r.clientWidth-d.clientWidth-p);m<=kc&&(s-=m)}else c<=kc&&(s+=c);return{width:s,height:i,x:a,y:l}}function dv(e,t){const n=Tn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Wt(e)?Kn(e):Mt(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Cc(e,t,n){let r;if(t==="viewport")r=uv(e,n);else if(t==="document")r=cv(Lt(e));else if(gt(t))r=dv(t,n);else{const o=sf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Zo(r)}function lf(e,t){const n=rn(e);return n===t||!gt(n)||Qn(n)?!1:bt(n).position==="fixed"||lf(n,t)}function fv(e,t){const n=t.get(e);if(n)return n;let r=Ir(e,[],!1).filter(a=>gt(a)&&ar(a)!=="body"),o=null;const s=bt(e).position==="fixed";let i=s?rn(e):e;for(;gt(i)&&!Qn(i);){const a=bt(i),l=Oa(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Kr(i)&&!l&&lf(e,i))?r=r.filter(u=>u!==i):o=a,i=rn(i)}return t.set(e,r),r}function pv(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ys(t)?[]:fv(t,this._c):[].concat(n),r],a=Cc(t,i[0],o);let l=a.top,c=a.right,u=a.bottom,d=a.left;for(let f=1;f<i.length;f++){const p=Cc(t,i[f],o);l=Ye(p.top,l),c=nn(p.right,c),u=nn(p.bottom,u),d=Ye(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function hv(e){const{width:t,height:n}=of(e);return{width:t,height:n}}function mv(e,t,n){const r=Wt(t),o=Lt(t),s=n==="fixed",i=Tn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Mt(0);function c(){l.x=vs(o)}if(r||!r&&!s)if((ar(t)!=="body"||Kr(o))&&(a=xs(t)),r){const p=Tn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?af(o,a):Mt(0),d=i.left+a.scrollLeft-l.x-u.x,f=i.top+a.scrollTop-l.y-u.y;return{x:d,y:f,width:i.width,height:i.height}}function Qs(e){return bt(e).position==="static"}function Sc(e,t){if(!Wt(e)||bt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Lt(e)===n&&(n=n.ownerDocument.body),n}function cf(e,t){const n=nt(e);if(ys(e))return n;if(!Wt(e)){let o=rn(e);for(;o&&!Qn(o);){if(gt(o)&&!Qs(o))return o;o=rn(o)}return n}let r=Sc(e,t);for(;r&&tv(r)&&Qs(r);)r=Sc(r,t);return r&&Qn(r)&&Qs(r)&&!Oa(r)?n:r||ov(e)||n}const gv=async function(e){const t=this.getOffsetParent||cf,n=this.getDimensions,r=await n(e.floating);return{reference:mv(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function bv(e){return bt(e).direction==="rtl"}const yv={convertOffsetParentRelativeRectToViewportRelativeRect:av,getDocumentElement:Lt,getClippingRect:pv,getOffsetParent:cf,getElementRects:gv,getClientRects:lv,getDimensions:hv,getScale:Kn,isElement:gt,isRTL:bv};function uf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function xv(e,t){let n=null,r;const o=Lt(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(a||t(),!f||!p)return;const m=yo(d),g=yo(o.clientWidth-(u+f)),b=yo(o.clientHeight-(d+p)),x=yo(u),k={rootMargin:-m+"px "+-g+"px "+-b+"px "+-x+"px",threshold:Ye(0,nn(1,l))||1};let y=!0;function A(w){const C=w[0].intersectionRatio;if(C!==l){if(!y)return i();C?i(!1,C):r=setTimeout(()=>{i(!1,1e-7)},1e3)}C===1&&!uf(c,e.getBoundingClientRect())&&i(),y=!1}try{n=new IntersectionObserver(A,{...k,root:o.ownerDocument})}catch{n=new IntersectionObserver(A,k)}n.observe(e)}return i(!0),s}function vv(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Pa(e),u=o||s?[...c?Ir(c):[],...t?Ir(t):[]]:[];u.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const d=c&&a?xv(c,n):null;let f=-1,p=null;i&&(p=new ResizeObserver(x=>{let[S]=x;S&&S.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var k;(k=p)==null||k.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let m,g=l?Tn(e):null;l&&b();function b(){const x=Tn(e);g&&!uf(g,x)&&n(),g=x,m=requestAnimationFrame(b)}return n(),()=>{var x;u.forEach(S=>{o&&S.removeEventListener("scroll",n),s&&S.removeEventListener("resize",n)}),d?.(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const wv=Y0,kv=Q0,Cv=G0,Sv=ev,Tv=X0,Tc=U0,Av=Z0,Ev=(e,t,n)=>{const r=new Map,o={platform:yv,...n},s={...o.platform,_c:r};return K0(e,t,{...o,platform:s})};var Mv=typeof document<"u",Rv=function(){},Oo=Mv?K.useLayoutEffect:Rv;function es(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!es(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!es(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function df(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ac(e,t){const n=df(e);return Math.round(t*n)/n}function Zs(e){const t=v.useRef(e);return Oo(()=>{t.current=e}),t}function Nv(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=v.useState(r);es(f,r)||p(r);const[m,g]=v.useState(null),[b,x]=v.useState(null),S=v.useCallback(_=>{_!==w.current&&(w.current=_,g(_))},[]),k=v.useCallback(_=>{_!==C.current&&(C.current=_,x(_))},[]),y=s||m,A=i||b,w=v.useRef(null),C=v.useRef(null),T=v.useRef(u),I=l!=null,O=Zs(l),j=Zs(o),D=Zs(c),F=v.useCallback(()=>{if(!w.current||!C.current)return;const _={placement:t,strategy:n,middleware:f};j.current&&(_.platform=j.current),Ev(w.current,C.current,_).then(R=>{const z={...R,isPositioned:D.current!==!1};B.current&&!es(T.current,z)&&(T.current=z,su.flushSync(()=>{d(z)}))})},[f,t,n,j,D]);Oo(()=>{c===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(_=>({..._,isPositioned:!1})))},[c]);const B=v.useRef(!1);Oo(()=>(B.current=!0,()=>{B.current=!1}),[]),Oo(()=>{if(y&&(w.current=y),A&&(C.current=A),y&&A){if(O.current)return O.current(y,A,F);F()}},[y,A,F,O,I]);const N=v.useMemo(()=>({reference:w,floating:C,setReference:S,setFloating:k}),[S,k]),$=v.useMemo(()=>({reference:y,floating:A}),[y,A]),V=v.useMemo(()=>{const _={position:n,left:0,top:0};if(!$.floating)return _;const R=Ac($.floating,u.x),z=Ac($.floating,u.y);return a?{..._,transform:"translate("+R+"px, "+z+"px)",...df($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:R,top:z}},[n,a,$.floating,u.x,u.y]);return v.useMemo(()=>({...u,update:F,refs:N,elements:$,floatingStyles:V}),[u,F,N,$,V])}const Ov=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Tc({element:r.current,padding:o}).fn(n):{}:r?Tc({element:r,padding:o}).fn(n):{}}}},Iv=(e,t)=>{const n=wv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pv=(e,t)=>{const n=kv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Lv=(e,t)=>({fn:Av(e).fn,options:[e,t]}),Dv=(e,t)=>{const n=Cv(e);return{name:n.name,fn:n.fn,options:[e,t]}},jv=(e,t)=>{const n=Sv(e);return{name:n.name,fn:n.fn,options:[e,t]}},zv=(e,t)=>{const n=Tv(e);return{name:n.name,fn:n.fn,options:[e,t]}},_v=(e,t)=>{const n=Ov(e);return{name:n.name,fn:n.fn,options:[e,t]}};var $v="Arrow",ff=v.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return h.jsx(Ie.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});ff.displayName=$v;var Fv=ff;function Bv(e){const[t,n]=v.useState(void 0);return tn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var La="Popper",[pf,ws]=sr(La),[Hv,hf]=pf(La),mf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=v.useState(null);return h.jsx(Hv,{scope:t,anchor:r,onAnchorChange:o,children:n})};mf.displayName=La;var gf="PopperAnchor",bf=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=hf(gf,n),i=v.useRef(null),a=De(t,i),l=v.useRef(null);return v.useEffect(()=>{const c=l.current;l.current=r?.current||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:h.jsx(Ie.div,{...o,ref:a})});bf.displayName=gf;var Da="PopperContent",[Wv,Vv]=pf(Da),yf=v.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:m,...g}=e,b=hf(Da,n),[x,S]=v.useState(null),k=De(t,H=>S(H)),[y,A]=v.useState(null),w=Bv(y),C=w?.width??0,T=w?.height??0,I=r+(s!=="center"?"-"+s:""),O=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},j=Array.isArray(c)?c:[c],D=j.length>0,F={padding:O,boundary:j.filter(Kv),altBoundary:D},{refs:B,floatingStyles:N,placement:$,isPositioned:V,middlewareData:_}=Nv({strategy:"fixed",placement:I,whileElementsMounted:(...H)=>vv(...H,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[Iv({mainAxis:o+T,alignmentAxis:i}),l&&Pv({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?Lv():void 0,...F}),l&&Dv({...F}),jv({...F,apply:({elements:H,rects:J,availableWidth:oe,availableHeight:ge})=>{const{width:Ce,height:ve}=J.reference,we=H.floating.style;we.setProperty("--radix-popper-available-width",`${oe}px`),we.setProperty("--radix-popper-available-height",`${ge}px`),we.setProperty("--radix-popper-anchor-width",`${Ce}px`),we.setProperty("--radix-popper-anchor-height",`${ve}px`)}}),y&&_v({element:y,padding:a}),Uv({arrowWidth:C,arrowHeight:T}),f&&zv({strategy:"referenceHidden",...F})]}),[R,z]=wf($),W=Ot(m);tn(()=>{V&&W?.()},[V,W]);const re=_.arrow?.x,se=_.arrow?.y,le=_.arrow?.centerOffset!==0,[te,G]=v.useState();return tn(()=>{x&&G(window.getComputedStyle(x).zIndex)},[x]),h.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...N,transform:V?N.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:te,"--radix-popper-transform-origin":[_.transformOrigin?.x,_.transformOrigin?.y].join(" "),..._.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(Wv,{scope:n,placedSide:R,onArrowChange:A,arrowX:re,arrowY:se,shouldHideArrow:le,children:h.jsx(Ie.div,{"data-side":R,"data-align":z,...g,ref:k,style:{...g.style,animation:V?void 0:"none"}})})})});yf.displayName=Da;var xf="PopperArrow",qv={top:"bottom",right:"left",bottom:"top",left:"right"},vf=v.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Vv(xf,r),i=qv[s.placedSide];return h.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:h.jsx(Fv,{...o,ref:n,style:{...o.style,display:"block"}})})});vf.displayName=xf;function Kv(e){return e!==null}var Uv=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,u]=wf(n),d={start:"0%",center:"50%",end:"100%"}[u],f=(o.arrow?.x??0)+a/2,p=(o.arrow?.y??0)+l/2;let m="",g="";return c==="bottom"?(m=i?d:`${f}px`,g=`${-l}px`):c==="top"?(m=i?d:`${f}px`,g=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,g=i?d:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,g=i?d:`${p}px`),{data:{x:m,y:g}}}});function wf(e){const[t,n="center"]=e.split("-");return[t,n]}var ja=mf,za=bf,kf=yf,Cf=vf,Gv="Portal",_a=v.forwardRef((e,t)=>{const{container:n,...r}=e,[o,s]=v.useState(!1);tn(()=>s(!0),[]);const i=n||o&&globalThis?.document?.body;return i?Qi.createPortal(h.jsx(Ie.div,{...r,ref:t}),i):null});_a.displayName=Gv;function Xv(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var On=e=>{const{present:t,children:n}=e,r=Jv(t),o=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),s=De(r.ref,Yv(o));return typeof n=="function"||r.isPresent?v.cloneElement(o,{ref:s}):null};On.displayName="Presence";function Jv(e){const[t,n]=v.useState(),r=v.useRef(null),o=v.useRef(e),s=v.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Xv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const c=xo(r.current);s.current=a==="mounted"?c:"none"},[a]),tn(()=>{const c=r.current,u=o.current;if(u!==e){const f=s.current,p=xo(c);e?l("MOUNT"):p==="none"||c?.display==="none"?l("UNMOUNT"):l(u&&f!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),tn(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,d=p=>{const g=xo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(l("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=p=>{p.target===t&&(s.current=xo(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:v.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function xo(e){return e?.animationName||"none"}function Yv(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ei="rovingFocusGroup.onEntryFocus",Qv={bubbles:!1,cancelable:!0},Ur="RovingFocusGroup",[Hi,Sf,Zv]=Gd(Ur),[ew,Tf]=sr(Ur,[Zv]),[tw,nw]=ew(Ur),Af=v.forwardRef((e,t)=>h.jsx(Hi.Provider,{scope:e.__scopeRovingFocusGroup,children:h.jsx(Hi.Slot,{scope:e.__scopeRovingFocusGroup,children:h.jsx(rw,{...e,ref:t})})}));Af.displayName=Ur;var rw=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,f=v.useRef(null),p=De(t,f),m=Xd(s),[g,b]=gs({prop:i,defaultProp:a??null,onChange:l,caller:Ur}),[x,S]=v.useState(!1),k=Ot(c),y=Sf(n),A=v.useRef(!1),[w,C]=v.useState(0);return v.useEffect(()=>{const T=f.current;if(T)return T.addEventListener(ei,k),()=>T.removeEventListener(ei,k)},[k]),h.jsx(tw,{scope:n,orientation:r,dir:m,loop:o,currentTabStopId:g,onItemFocus:v.useCallback(T=>b(T),[b]),onItemShiftTab:v.useCallback(()=>S(!0),[]),onFocusableItemAdd:v.useCallback(()=>C(T=>T+1),[]),onFocusableItemRemove:v.useCallback(()=>C(T=>T-1),[]),children:h.jsx(Ie.div,{tabIndex:x||w===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{A.current=!0}),onFocus:ae(e.onFocus,T=>{const I=!A.current;if(T.target===T.currentTarget&&I&&!x){const O=new CustomEvent(ei,Qv);if(T.currentTarget.dispatchEvent(O),!O.defaultPrevented){const j=y().filter($=>$.focusable),D=j.find($=>$.active),F=j.find($=>$.id===g),N=[D,F,...j].filter(Boolean).map($=>$.ref.current);Rf(N,u)}}A.current=!1}),onBlur:ae(e.onBlur,()=>S(!1))})})}),Ef="RovingFocusGroupItem",Mf=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Yn(),c=s||l,u=nw(Ef,n),d=u.currentTabStopId===c,f=Sf(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:g}=u;return v.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),h.jsx(Hi.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:h.jsx(Ie.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,b=>{r?u.onItemFocus(c):b.preventDefault()}),onFocus:ae(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:ae(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){u.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const x=iw(b,u.orientation,u.dir);if(x!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let k=f().filter(y=>y.focusable).map(y=>y.ref.current);if(x==="last")k.reverse();else if(x==="prev"||x==="next"){x==="prev"&&k.reverse();const y=k.indexOf(b.currentTarget);k=u.loop?aw(k,y+1):k.slice(y+1)}setTimeout(()=>Rf(k))}}),children:typeof i=="function"?i({isCurrentTabStop:d,hasTabStop:g!=null}):i})})});Mf.displayName=Ef;var ow={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function sw(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function iw(e,t,n){const r=sw(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ow[r]}function Rf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function aw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var lw=Af,cw=Mf,uw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jn=new WeakMap,vo=new WeakMap,wo={},ti=0,Nf=function(e){return e&&(e.host||Nf(e.parentNode))},dw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Nf(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},fw=function(e,t,n,r){var o=dw(t,Array.isArray(e)?e:[e]);wo[n]||(wo[n]=new WeakMap);var s=wo[n],i=[],a=new Set,l=new Set(o),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};o.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))u(f);else try{var p=f.getAttribute(r),m=p!==null&&p!=="false",g=(jn.get(f)||0)+1,b=(s.get(f)||0)+1;jn.set(f,g),s.set(f,b),i.push(f),g===1&&m&&vo.set(f,!0),b===1&&f.setAttribute(n,"true"),m||f.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",f,x)}})};return u(t),a.clear(),ti++,function(){i.forEach(function(d){var f=jn.get(d)-1,p=s.get(d)-1;jn.set(d,f),s.set(d,p),f||(vo.has(d)||d.removeAttribute(r),vo.delete(d)),p||d.removeAttribute(n)}),ti--,ti||(jn=new WeakMap,jn=new WeakMap,vo=new WeakMap,wo={})}},Of=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=uw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),fw(r,o,n,"aria-hidden")):function(){return null}},St=function(){return St=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},St.apply(this,arguments)};function If(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function pw(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var Io="right-scroll-bar-position",Po="width-before-scroll-bar",hw="with-scroll-bars-hidden",mw="--removed-body-scroll-bar-size";function ni(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function gw(e,t){var n=K.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var bw=typeof window<"u"?v.useLayoutEffect:v.useEffect,Ec=new WeakMap;function yw(e,t){var n=gw(null,function(r){return e.forEach(function(o){return ni(o,r)})});return bw(function(){var r=Ec.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ni(a,null)}),s.forEach(function(a){o.has(a)||ni(a,i)})}Ec.set(n,e)},[e]),n}function xw(e){return e}function vw(e,t){t===void 0&&(t=xw);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var u=i;i=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){i.push(u),c()},filter:function(u){return i=i.filter(u),n}}}};return o}function ww(e){e===void 0&&(e={});var t=vw(null);return t.options=St({async:!0,ssr:!1},e),t}var Pf=function(e){var t=e.sideCar,n=If(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return v.createElement(r,St({},n))};Pf.isSideCarExport=!0;function kw(e,t){return e.useMedium(t),Pf}var Lf=ww(),ri=function(){},ks=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:ri,onWheelCapture:ri,onTouchMoveCapture:ri}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,g=e.inert,b=e.allowPinchZoom,x=e.as,S=x===void 0?"div":x,k=e.gapMode,y=If(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),A=f,w=yw([n,t]),C=St(St({},y),o);return v.createElement(v.Fragment,null,u&&v.createElement(A,{sideCar:Lf,removeScrollBar:c,shards:d,noRelative:p,noIsolation:m,inert:g,setCallbacks:s,allowPinchZoom:!!b,lockRef:n,gapMode:k}),i?v.cloneElement(v.Children.only(a),St(St({},C),{ref:w})):v.createElement(S,St({},C,{className:l,ref:w}),a))});ks.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ks.classNames={fullWidth:Po,zeroRight:Io};var Cw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Sw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Cw();return t&&e.setAttribute("nonce",t),e}function Tw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Aw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Ew=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Sw())&&(Tw(t,n),Aw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Mw=function(){var e=Ew();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Df=function(){var e=Mw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Rw={left:0,top:0,right:0,gap:0},oi=function(e){return parseInt(e||"",10)||0},Nw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[oi(n),oi(r),oi(o)]},Ow=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Rw;var t=Nw(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Iw=Df(),Un="data-scroll-locked",Pw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
87
|
+
.`.concat(hw,` {
|
|
88
88
|
overflow: hidden `).concat(r,`;
|
|
89
89
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
90
90
|
}
|
|
@@ -101,51 +101,51 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
|
|
|
101
101
|
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
.`).concat(
|
|
104
|
+
.`).concat(Io,` {
|
|
105
105
|
right: `).concat(a,"px ").concat(r,`;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
.`).concat(
|
|
108
|
+
.`).concat(Po,` {
|
|
109
109
|
margin-right: `).concat(a,"px ").concat(r,`;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
.`).concat(
|
|
112
|
+
.`).concat(Io," .").concat(Io,` {
|
|
113
113
|
right: 0 `).concat(r,`;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
.`).concat(
|
|
116
|
+
.`).concat(Po," .").concat(Po,` {
|
|
117
117
|
margin-right: 0 `).concat(r,`;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
body[`).concat(Un,`] {
|
|
121
|
-
`).concat(
|
|
121
|
+
`).concat(mw,": ").concat(a,`px;
|
|
122
122
|
}
|
|
123
|
-
`)},
|
|
123
|
+
`)},Mc=function(){var e=parseInt(document.body.getAttribute(Un)||"0",10);return isFinite(e)?e:0},Lw=function(){v.useEffect(function(){return document.body.setAttribute(Un,(Mc()+1).toString()),function(){var e=Mc()-1;e<=0?document.body.removeAttribute(Un):document.body.setAttribute(Un,e.toString())}},[])},Dw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Lw();var s=v.useMemo(function(){return Ow(o)},[o]);return v.createElement(Iw,{styles:Pw(s,!t,o,n?"":"!important")})},Wi=!1;if(typeof window<"u")try{var ko=Object.defineProperty({},"passive",{get:function(){return Wi=!0,!0}});window.addEventListener("test",ko,ko),window.removeEventListener("test",ko,ko)}catch{Wi=!1}var zn=Wi?{passive:!1}:!1,jw=function(e){return e.tagName==="TEXTAREA"},jf=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!jw(e)&&n[t]==="visible")},zw=function(e){return jf(e,"overflowY")},_w=function(e){return jf(e,"overflowX")},Rc=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=zf(e,r);if(o){var s=_f(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},$w=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Fw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},zf=function(e,t){return e==="v"?zw(t):_w(t)},_f=function(e,t){return e==="v"?$w(t):Fw(t)},Bw=function(e,t){return e==="h"&&t==="rtl"?-1:1},Hw=function(e,t,n,r,o){var s=Bw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,u=i>0,d=0,f=0;do{if(!a)break;var p=_f(e,a),m=p[0],g=p[1],b=p[2],x=g-b-s*m;(m||x)&&zf(e,a)&&(d+=x,f+=m);var S=a.parentNode;a=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&Math.abs(d)<1||!u&&Math.abs(f)<1)&&(c=!0),c},Co=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Nc=function(e){return[e.deltaX,e.deltaY]},Oc=function(e){return e&&"current"in e?e.current:e},Ww=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Vw=function(e){return`
|
|
124
124
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
125
125
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
126
|
-
`)},Ww=0,_n=[];function Vw(e){var t=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),o=v.useState(Ww++)[0],s=v.useState(Pf)[0],i=v.useRef(e);v.useEffect(function(){i.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=dw([e.lockRef.current],(e.shards||[]).map(Rc),!0).filter(Boolean);return g.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=v.useCallback(function(g,b){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var x=ko(g),S=n.current,k="deltaX"in g?g.deltaX:S[0]-x[0],y="deltaY"in g?g.deltaY:S[1]-x[1],T,w=g.target,C=Math.abs(k)>Math.abs(y)?"h":"v";if("touches"in g&&C==="h"&&w.type==="range")return!1;var A=window.getSelection(),I=A&&A.anchorNode,O=I?I===w||I.contains(w):!1;if(O)return!1;var j=Ec(C,w);if(!j)return!0;if(j?T=C:(T=C==="v"?"h":"v",j=Ec(C,w)),!j)return!1;if(!r.current&&"changedTouches"in g&&(k||y)&&(r.current=T),!T)return!0;var D=r.current||T;return Fw(D,b,g,D==="h"?k:y)},[]),l=v.useCallback(function(g){var b=g;if(!(!_n.length||_n[_n.length-1]!==s)){var x="deltaY"in b?Mc(b):ko(b),S=t.current.filter(function(T){return T.name===b.type&&(T.target===b.target||b.target===T.shadowParent)&&Bw(T.delta,x)})[0];if(S&&S.should){b.cancelable&&b.preventDefault();return}if(!S){var k=(i.current.shards||[]).map(Rc).filter(Boolean).filter(function(T){return T.contains(b.target)}),y=k.length>0?a(b,k[0]):!i.current.noIsolation;y&&b.cancelable&&b.preventDefault()}}},[]),c=v.useCallback(function(g,b,x,S){var k={name:g,delta:b,target:x,should:S,shadowParent:qw(x)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(y){return y!==k})},1)},[]),u=v.useCallback(function(g){n.current=ko(g),r.current=void 0},[]),d=v.useCallback(function(g){c(g.type,Mc(g),g.target,a(g,e.lockRef.current))},[]),f=v.useCallback(function(g){c(g.type,ko(g),g.target,a(g,e.lockRef.current))},[]);v.useEffect(function(){return _n.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,zn),document.addEventListener("touchmove",l,zn),document.addEventListener("touchstart",u,zn),function(){_n=_n.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,zn),document.removeEventListener("touchmove",l,zn),document.removeEventListener("touchstart",u,zn)}},[]);var p=e.removeScrollBar,m=e.inert;return v.createElement(v.Fragment,null,m?v.createElement(s,{styles:Hw(o)}):null,p?v.createElement(Pw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function qw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Kw=vw(If,Vw);var za=v.forwardRef(function(e,t){return v.createElement(vs,St({},e,{ref:t,sideCar:Kw}))});za.classNames=vs.classNames;var Hi=["Enter"," "],Uw=["ArrowDown","PageUp","Home"],zf=["ArrowUp","PageDown","End"],Gw=[...Uw,...zf],Xw={ltr:[...Hi,"ArrowRight"],rtl:[...Hi,"ArrowLeft"]},Jw={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ur="Menu",[Pr,Yw,Qw]=Kd(Ur),[In,_f]=sr(Ur,[Qw,xs,Cf]),Gr=xs(),$f=Cf(),[Ff,an]=In(Ur),[Zw,Xr]=In(Ur),Bf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Gr(t),[l,c]=v.useState(null),u=v.useRef(!1),d=Ot(s),f=Ud(o);return v.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(La,{...a,children:h.jsx(Ff,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(Zw,{scope:t,onClose:v.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:i,children:r})})})};Bf.displayName=Ur;var ek="MenuAnchor",_a=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Gr(n);return h.jsx(Da,{...o,...r,ref:t})});_a.displayName=ek;var $a="MenuPortal",[tk,Hf]=In($a,{forceMount:void 0}),Wf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=an($a,t);return h.jsx(tk,{scope:t,forceMount:n,children:h.jsx(On,{present:n||s.open,children:h.jsx(ja,{asChild:!0,container:o,children:r})})})};Wf.displayName=$a;var lt="MenuContent",[nk,Fa]=In(lt),Vf=v.forwardRef((e,t)=>{const n=Hf(lt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=an(lt,e.__scopeMenu),i=Xr(lt,e.__scopeMenu);return h.jsx(Pr.Provider,{scope:e.__scopeMenu,children:h.jsx(On,{present:r||s.open,children:h.jsx(Pr.Slot,{scope:e.__scopeMenu,children:i.modal?h.jsx(rk,{...o,ref:t}):h.jsx(ok,{...o,ref:t})})})})}),rk=v.forwardRef((e,t)=>{const n=an(lt,e.__scopeMenu),r=v.useRef(null),o=De(t,r);return v.useEffect(()=>{const s=r.current;if(s)return Rf(s)},[]),h.jsx(Ba,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),ok=v.forwardRef((e,t)=>{const n=an(lt,e.__scopeMenu);return h.jsx(Ba,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),sk=Or("MenuContent.ScrollLock"),Ba=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...g}=e,b=an(lt,n),x=Xr(lt,n),S=Gr(n),k=$f(n),y=Yw(n),[T,w]=v.useState(null),C=v.useRef(null),A=De(t,C,b.onContentChange),I=v.useRef(0),O=v.useRef(""),j=v.useRef(0),D=v.useRef(null),F=v.useRef("right"),B=v.useRef(0),N=m?za:v.Fragment,$=m?{as:sk,allowPinchZoom:!0}:void 0,V=R=>{const z=O.current+R,W=y().filter(H=>!H.disabled),re=document.activeElement,se=W.find(H=>H.ref.current===re)?.textValue,le=W.map(H=>H.textValue),te=bk(le,z,se),G=W.find(H=>H.textValue===te)?.ref.current;(function H(J){O.current=J,window.clearTimeout(I.current),J!==""&&(I.current=window.setTimeout(()=>H(""),1e3))})(z),G&&setTimeout(()=>G.focus())};v.useEffect(()=>()=>window.clearTimeout(I.current),[]),Jd();const _=v.useCallback(R=>F.current===D.current?.side&&xk(R,D.current?.area),[]);return h.jsx(nk,{scope:n,searchRef:O,onItemEnter:v.useCallback(R=>{_(R)&&R.preventDefault()},[_]),onItemLeave:v.useCallback(R=>{_(R)||(C.current?.focus(),w(null))},[_]),onTriggerLeave:v.useCallback(R=>{_(R)&&R.preventDefault()},[_]),pointerGraceTimerRef:j,onPointerGraceIntentChange:v.useCallback(R=>{D.current=R},[]),children:h.jsx(N,{...$,children:h.jsx(Ta,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,R=>{R.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:h.jsx(Sa,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(iw,{asChild:!0,...k,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:w,onEntryFocus:ae(l,R=>{x.isUsingKeyboardRef.current||R.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(vf,{role:"menu","aria-orientation":"vertical","data-state":ap(b.open),"data-radix-menu-content":"",dir:x.dir,...S,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,R=>{const W=R.target.closest("[data-radix-menu-content]")===R.currentTarget,re=R.ctrlKey||R.altKey||R.metaKey,se=R.key.length===1;W&&(R.key==="Tab"&&R.preventDefault(),!re&&se&&V(R.key));const le=C.current;if(R.target!==le||!Gw.includes(R.key))return;R.preventDefault();const G=y().filter(H=>!H.disabled).map(H=>H.ref.current);zf.includes(R.key)&&G.reverse(),mk(G)}),onBlur:ae(e.onBlur,R=>{R.currentTarget.contains(R.target)||(window.clearTimeout(I.current),O.current="")}),onPointerMove:ae(e.onPointerMove,Lr(R=>{const z=R.target,W=B.current!==R.clientX;if(R.currentTarget.contains(z)&&W){const re=R.clientX>B.current?"right":"left";F.current=re,B.current=R.clientX}}))})})})})})})});Vf.displayName=lt;var ik="MenuGroup",Ha=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Ie.div,{role:"group",...r,ref:t})});Ha.displayName=ik;var ak="MenuLabel",qf=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Ie.div,{...r,ref:t})});qf.displayName=ak;var Zo="MenuItem",Nc="menu.itemSelect",ws=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=v.useRef(null),i=Xr(Zo,e.__scopeMenu),a=Fa(Zo,e.__scopeMenu),l=De(t,s),c=v.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(Nc,{bubbles:!0,cancelable:!0});d.addEventListener(Nc,p=>r?.(p),{once:!0}),qd(d,f),f.defaultPrevented?c.current=!1:i.onClose()}};return h.jsx(Kf,{...o,ref:l,disabled:n,onClick:ae(e.onClick,u),onPointerDown:d=>{e.onPointerDown?.(d),c.current=!0},onPointerUp:ae(e.onPointerUp,d=>{c.current||d.currentTarget?.click()}),onKeyDown:ae(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||Hi.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});ws.displayName=Zo;var Kf=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Fa(Zo,n),a=$f(n),l=v.useRef(null),c=De(t,l),[u,d]=v.useState(!1),[f,p]=v.useState("");return v.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(Pr.ItemSlot,{scope:n,disabled:r,textValue:o??f,children:h.jsx(aw,{asChild:!0,...a,focusable:!r,children:h.jsx(Ie.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ae(e.onPointerMove,Lr(m=>{r?i.onItemLeave(m):(i.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,Lr(m=>i.onItemLeave(m))),onFocus:ae(e.onFocus,()=>d(!0)),onBlur:ae(e.onBlur,()=>d(!1))})})})}),lk="MenuCheckboxItem",Uf=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return h.jsx(Qf,{scope:e.__scopeMenu,checked:n,children:h.jsx(ws,{role:"menuitemcheckbox","aria-checked":es(n)?"mixed":n,...o,ref:t,"data-state":qa(n),onSelect:ae(o.onSelect,()=>r?.(es(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Uf.displayName=lk;var Gf="MenuRadioGroup",[ck,uk]=In(Gf,{value:void 0,onValueChange:()=>{}}),Xf=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Ot(r);return h.jsx(ck,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(Ha,{...o,ref:t})})});Xf.displayName=Gf;var Jf="MenuRadioItem",Yf=v.forwardRef((e,t)=>{const{value:n,...r}=e,o=uk(Jf,e.__scopeMenu),s=n===o.value;return h.jsx(Qf,{scope:e.__scopeMenu,checked:s,children:h.jsx(ws,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":qa(s),onSelect:ae(r.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Yf.displayName=Jf;var Wa="MenuItemIndicator",[Qf,dk]=In(Wa,{checked:!1}),Zf=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=dk(Wa,n);return h.jsx(On,{present:r||es(s.checked)||s.checked===!0,children:h.jsx(Ie.span,{...o,ref:t,"data-state":qa(s.checked)})})});Zf.displayName=Wa;var fk="MenuSeparator",ep=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Ie.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ep.displayName=fk;var pk="MenuArrow",tp=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Gr(n);return h.jsx(wf,{...o,...r,ref:t})});tp.displayName=pk;var Va="MenuSub",[hk,np]=In(Va),rp=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:o}=e,s=an(Va,t),i=Gr(t),[a,l]=v.useState(null),[c,u]=v.useState(null),d=Ot(o);return v.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(La,{...i,children:h.jsx(Ff,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(hk,{scope:t,contentId:Yn(),triggerId:Yn(),trigger:a,onTriggerChange:l,children:n})})})};rp.displayName=Va;var yr="MenuSubTrigger",op=v.forwardRef((e,t)=>{const n=an(yr,e.__scopeMenu),r=Xr(yr,e.__scopeMenu),o=np(yr,e.__scopeMenu),s=Fa(yr,e.__scopeMenu),i=v.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=v.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return v.useEffect(()=>u,[u]),v.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(_a,{asChild:!0,...c,children:h.jsx(Kf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":ap(n.open),...e,ref:ps(t,o.onTriggerChange),onClick:d=>{e.onClick?.(d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ae(e.onPointerMove,Lr(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:ae(e.onPointerLeave,Lr(d=>{u();const f=n.content?.getBoundingClientRect();if(f){const p=n.content?.dataset.side,m=p==="right",g=m?-5:5,b=f[m?"left":"right"],x=f[m?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+g,y:d.clientY},{x:b,y:f.top},{x,y:f.top},{x,y:f.bottom},{x:b,y:f.bottom}],side:p}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(e.onKeyDown,d=>{const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||Xw[r.dir].includes(d.key)&&(n.onOpenChange(!0),n.content?.focus(),d.preventDefault())})})})});op.displayName=yr;var sp="MenuSubContent",ip=v.forwardRef((e,t)=>{const n=Hf(lt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=an(lt,e.__scopeMenu),i=Xr(lt,e.__scopeMenu),a=np(sp,e.__scopeMenu),l=v.useRef(null),c=De(t,l);return h.jsx(Pr.Provider,{scope:e.__scopeMenu,children:h.jsx(On,{present:r||s.open,children:h.jsx(Pr.Slot,{scope:e.__scopeMenu,children:h.jsx(Ba,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{i.isUsingKeyboardRef.current&&l.current?.focus(),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ae(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:ae(e.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),f=Jw[i.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),a.trigger?.focus(),u.preventDefault())})})})})})});ip.displayName=sp;function ap(e){return e?"open":"closed"}function es(e){return e==="indeterminate"}function qa(e){return es(e)?"indeterminate":e?"checked":"unchecked"}function mk(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function gk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function bk(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=gk(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function yk(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(o=!o)}return o}function xk(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return yk(n,t)}function Lr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var vk=Bf,wk=_a,kk=Wf,Ck=Vf,Sk=Ha,Tk=qf,Ak=ws,Ek=Uf,Mk=Xf,Rk=Yf,Nk=Zf,Ok=ep,Ik=tp,Pk=rp,Lk=op,Dk=ip,ks="DropdownMenu",[jk]=sr(ks,[_f]),ze=_f(),[zk,lp]=jk(ks),cp=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=ze(t),c=v.useRef(null),[u,d]=hs({prop:o,defaultProp:s??!1,onChange:i,caller:ks});return h.jsx(zk,{scope:t,triggerId:Yn(),triggerRef:c,contentId:Yn(),open:u,onOpenChange:d,onOpenToggle:v.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(vk,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};cp.displayName=ks;var up="DropdownMenuTrigger",dp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=lp(up,n),i=ze(n);return h.jsx(wk,{asChild:!0,...i,children:h.jsx(Ie.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:ps(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});dp.displayName=up;var _k="DropdownMenuPortal",fp=e=>{const{__scopeDropdownMenu:t,...n}=e,r=ze(t);return h.jsx(kk,{...r,...n})};fp.displayName=_k;var pp="DropdownMenuContent",hp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=lp(pp,n),s=ze(n),i=v.useRef(!1);return h.jsx(Ck,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{i.current||o.triggerRef.current?.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!o.modal||u)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});hp.displayName=pp;var $k="DropdownMenuGroup",Fk=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Sk,{...o,...r,ref:t})});Fk.displayName=$k;var Bk="DropdownMenuLabel",mp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Tk,{...o,...r,ref:t})});mp.displayName=Bk;var Hk="DropdownMenuItem",gp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Ak,{...o,...r,ref:t})});gp.displayName=Hk;var Wk="DropdownMenuCheckboxItem",bp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Ek,{...o,...r,ref:t})});bp.displayName=Wk;var Vk="DropdownMenuRadioGroup",qk=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Mk,{...o,...r,ref:t})});qk.displayName=Vk;var Kk="DropdownMenuRadioItem",yp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Rk,{...o,...r,ref:t})});yp.displayName=Kk;var Uk="DropdownMenuItemIndicator",xp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Nk,{...o,...r,ref:t})});xp.displayName=Uk;var Gk="DropdownMenuSeparator",vp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Ok,{...o,...r,ref:t})});vp.displayName=Gk;var Xk="DropdownMenuArrow",Jk=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Ik,{...o,...r,ref:t})});Jk.displayName=Xk;var Yk=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:o,defaultOpen:s}=e,i=ze(t),[a,l]=hs({prop:r,defaultProp:s??!1,onChange:o,caller:"DropdownMenuSub"});return h.jsx(Pk,{...i,open:a,onOpenChange:l,children:n})},Qk="DropdownMenuSubTrigger",wp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Lk,{...o,...r,ref:t})});wp.displayName=Qk;var Zk="DropdownMenuSubContent",kp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Dk,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});kp.displayName=Zk;var eC=cp,tC=dp,Cp=fp,Sp=hp,Tp=mp,Ap=gp,Ep=bp,Mp=yp,Rp=xp,Np=vp,nC=Yk,Op=wp,Ip=kp;const Pp=eC,Lp=tC,Oc=Cp,Ic=nC,Wi=v.forwardRef(({className:e,inset:t,children:n,...r},o)=>{const s=We(),i=Ve();return h.jsxs(Op,{ref:o,className:M("flex cursor-default select-none items-center rounded-full px-2 py-1.5 text-sm outline-none transition-colors gap-2",s==="dark"?"focus:bg-neutral-800 data-[state=open]:bg-neutral-800 text-neutral-300":"focus:bg-neutral-100 data-[state=open]:bg-neutral-100 text-neutral-700",t&&"pl-8",i?.dropdownSubTrigger,e),...r,children:[n,h.jsx(q.ChevronRight,{className:M("ml-auto h-4 w-4",i?.dropdownSubTriggerChevron)})]})});Wi.displayName=Op.displayName;const Vi=v.forwardRef(({className:e,...t},n)=>{const r=We(),o=Ve();return h.jsx(Ip,{ref:n,className:M("z-[9999] min-w-[8rem] overflow-hidden rounded-3xl border p-1.5 shadow-lg backdrop-blur-xl animate-in fade-in zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out data-[state=closed]:zoom-out-95",r==="dark"?"bg-neutral-900/95 border-neutral-800 shadow-black/50 text-neutral-200":"bg-white/95 border-neutral-200/60 text-neutral-700",o?.dropdownSubContent,e),...t})});Vi.displayName=Ip.displayName;const Ka=v.forwardRef(({className:e,sideOffset:t=8,...n},r)=>{const o=We(),s=Ve();return h.jsx(Cp,{children:h.jsx(Sp,{ref:r,sideOffset:t,className:M("z-[9999] min-w-[12rem] overflow-hidden rounded-3xl border p-1.5 shadow-xl backdrop-blur-xl animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",o==="dark"?"bg-neutral-900/95 border-neutral-800 shadow-black/50 text-neutral-200":"bg-white/95 border-neutral-200/60 text-neutral-700",s?.dropdownContent,e),...n})})});Ka.displayName=Sp.displayName;const Ke=v.forwardRef(({className:e,inset:t,...n},r)=>{const o=We(),s=Ve();return h.jsx(Ap,{ref:r,className:M("relative flex cursor-pointer select-none items-center rounded-full px-3 py-2 text-sm outline-none transition-colors gap-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o==="dark"?"focus:bg-neutral-800 focus:text-neutral-100 text-neutral-300":"focus:bg-neutral-100 focus:text-neutral-900 text-neutral-600",t&&"pl-8",s?.dropdownItem,e),...n})});Ke.displayName=Ap.displayName;const rC=v.forwardRef(({className:e,children:t,checked:n,...r},o)=>{const s=We(),i=Ve();return h.jsxs(Ep,{ref:o,className:M("relative flex cursor-default select-none items-center rounded-xl py-2 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s==="dark"?"focus:bg-neutral-800 focus:text-neutral-100 text-neutral-300":"focus:bg-neutral-100 focus:text-neutral-900 text-neutral-600",i?.dropdownCheckboxItem,e),checked:n,...r,children:[h.jsx("span",{className:M("absolute left-2 flex h-3.5 w-3.5 items-center justify-center",i?.dropdownIndicator),children:h.jsx(Rp,{children:h.jsx(q.Check,{className:"h-4 w-4"})})}),t]})});rC.displayName=Ep.displayName;const oC=v.forwardRef(({className:e,children:t,...n},r)=>{const o=We(),s=Ve();return h.jsxs(Mp,{ref:r,className:M("relative flex cursor-default select-none items-center rounded-xl py-2 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o==="dark"?"focus:bg-neutral-800 focus:text-neutral-100 text-neutral-300":"focus:bg-neutral-100 focus:text-neutral-900 text-neutral-600",s?.dropdownRadioItem,e),...n,children:[h.jsx("span",{className:M("absolute left-2 flex h-3.5 w-3.5 items-center justify-center",s?.dropdownIndicator),children:h.jsx(Rp,{children:h.jsx(q.Circle,{className:"h-2 w-2 fill-current"})})}),t]})});oC.displayName=Mp.displayName;const sC=v.forwardRef(({className:e,inset:t,...n},r)=>{const o=Ve();return h.jsx(Tp,{ref:r,className:M("px-3 py-1.5 text-xs font-semibold text-neutral-500",t&&"pl-8",o?.dropdownLabel,e),...n})});sC.displayName=Tp.displayName;const xr=v.forwardRef(({className:e,...t},n)=>{const r=We(),o=Ve();return h.jsx(Np,{ref:n,className:M("-mx-1 my-1 h-px",r==="dark"?"bg-neutral-800":"bg-neutral-200/60",o?.dropdownSeparator,e),...t})});xr.displayName=Np.displayName;const Dp=({className:e,...t})=>{const n=Ve();return h.jsx("span",{className:M("ml-auto text-xs tracking-widest opacity-60",n?.dropdownShortcut,e),...t})};Dp.displayName="DropdownMenuShortcut";const Pc=({trigger:e,items:t,value:n,onSelect:r,align:o="start"})=>{const s=We(),i=Ve();return h.jsxs(Pp,{children:[h.jsx(Lp,{asChild:!0,children:e}),h.jsx(Ka,{align:o,children:t.map(a=>h.jsxs(Ke,{onSelect:()=>r(a.value),className:M("gap-2 px-3 py-2 rounded-full",n===a.value&&(s==="dark"?"bg-neutral-800 text-neutral-100":"bg-neutral-100 text-neutral-900"),n===a.value&&i?.dropdownItemActive,i?.dropdownItem),children:[a.icon&&h.jsx("span",{className:M("flex items-center justify-center w-5 h-5 shrink-0",i?.dropdownItemIcon),children:a.icon}),h.jsx("span",{className:M("flex-1 font-medium",i?.dropdownItemLabel),children:a.label}),a.shortcut&&h.jsx(Dp,{children:a.shortcut}),n===a.value&&h.jsx(q.Check,{className:M("ml-auto size-3.5 shrink-0",s==="dark"?"text-neutral-400":"text-neutral-500",i?.dropdownItemCheck)})]},a.value))})]})};var Cs="Popover",[jp]=sr(Cs,[xs]),Jr=xs(),[iC,ln]=jp(Cs),zp=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=Jr(t),l=v.useRef(null),[c,u]=v.useState(!1),[d,f]=hs({prop:r,defaultProp:o??!1,onChange:s,caller:Cs});return h.jsx(La,{...a,children:h.jsx(iC,{scope:t,contentId:Yn(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:c,onCustomAnchorAdd:v.useCallback(()=>u(!0),[]),onCustomAnchorRemove:v.useCallback(()=>u(!1),[]),modal:i,children:n})})};zp.displayName=Cs;var _p="PopoverAnchor",aC=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ln(_p,n),s=Jr(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return v.useEffect(()=>(i(),()=>a()),[i,a]),h.jsx(Da,{...s,...r,ref:t})});aC.displayName=_p;var $p="PopoverTrigger",Fp=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ln($p,n),s=Jr(n),i=De(t,o.triggerRef),a=h.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":qp(o.open),...r,ref:i,onClick:ae(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:h.jsx(Da,{asChild:!0,...s,children:a})});Fp.displayName=$p;var Ua="PopoverPortal",[lC,cC]=jp(Ua,{forceMount:void 0}),Bp=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=ln(Ua,t);return h.jsx(lC,{scope:t,forceMount:n,children:h.jsx(On,{present:n||s.open,children:h.jsx(ja,{asChild:!0,container:o,children:r})})})};Bp.displayName=Ua;var Zn="PopoverContent",Hp=v.forwardRef((e,t)=>{const n=cC(Zn,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=ln(Zn,e.__scopePopover);return h.jsx(On,{present:r||s.open,children:s.modal?h.jsx(dC,{...o,ref:t}):h.jsx(fC,{...o,ref:t})})});Hp.displayName=Zn;var uC=Or("PopoverContent.RemoveScroll"),dC=v.forwardRef((e,t)=>{const n=ln(Zn,e.__scopePopover),r=v.useRef(null),o=De(t,r),s=v.useRef(!1);return v.useEffect(()=>{const i=r.current;if(i)return Rf(i)},[]),h.jsx(za,{as:uC,allowPinchZoom:!0,children:h.jsx(Wp,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(e.onCloseAutoFocus,i=>{i.preventDefault(),s.current||n.triggerRef.current?.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:ae(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),fC=v.forwardRef((e,t)=>{const n=ln(Zn,e.__scopePopover),r=v.useRef(!1),o=v.useRef(!1);return h.jsx(Wp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(r.current||n.triggerRef.current?.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;n.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Wp=v.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,f=ln(Zn,n),p=Jr(n);return Jd(),h.jsx(Ta,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:h.jsx(Sa,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1),children:h.jsx(vf,{"data-state":qp(f.open),role:"dialog",id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Vp="PopoverClose",pC=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ln(Vp,n);return h.jsx(Ie.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});pC.displayName=Vp;var hC="PopoverArrow",mC=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Jr(n);return h.jsx(wf,{...o,...r,ref:t})});mC.displayName=hC;function qp(e){return e?"open":"closed"}var gC=zp,bC=Fp,yC=Bp,xC=Hp;const Po=({trigger:e,children:t,align:n="start",side:r="bottom",open:o,onOpenChange:s})=>{const i=We(),a=Ve();return h.jsxs(gC,{open:o,onOpenChange:s,children:[h.jsx(bC,{asChild:!0,children:e}),h.jsx(yC,{children:h.jsx(xC,{align:n,side:r,sideOffset:8,className:M("z-50 rounded-3xl border p-1.5 shadow-xl backdrop-blur-xl outline-none","animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",i==="dark"?"bg-neutral-900/95 border-neutral-800 shadow-black/50":"bg-white/95 border-neutral-200/60",a?.popoverContent),children:t})})]})},vC=[{label:"Thin (100)",value:"100"},{label:"Light (300)",value:"300"},{label:"Normal (400)",value:"400"},{label:"Medium (500)",value:"500"},{label:"Semi Bold (600)",value:"600"},{label:"Bold (700)",value:"700"},{label:"Extra Bold (800)",value:"800"},{label:"Black (900)",value:"900"}],wC=[{label:"Default",value:""},{label:"Inter",value:"Inter, sans-serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Times New Roman",value:"Times New Roman, Times, serif"},{label:"Courier New",value:"Courier New, Courier, monospace"},{label:"Trebuchet MS",value:"Trebuchet MS, sans-serif"},{label:"Arial",value:"Arial, Helvetica, sans-serif"},{label:"Verdana",value:"Verdana, Geneva, sans-serif"}],kC=({style:e,baseStyle:t,anchorX:n,anchorY:r,classNames:o,onSave:s,onReset:i,onClose:a})=>{const l=Vr(),u=We()==="dark",d=K.useRef(null),[f,p]=K.useState(e.label),[m,g]=K.useState(e.fontSize??""),[b,x]=K.useState(e.fontWeight??""),[S,k]=K.useState(e.fontStyle??"normal"),[y,T]=K.useState(e.fontFamily??""),[w,C]=K.useState(e.color??""),[A,I]=K.useState(e.letterSpacing??""),[O,j]=K.useState(e.lineHeight??""),[D,F]=K.useState(e.textTransform??"none");K.useEffect(()=>{const W=se=>{d.current&&!d.current.contains(se.target)&&a()},re=se=>{se.key==="Escape"&&a()};return document.addEventListener("mousedown",W),document.addEventListener("keydown",re),()=>{document.removeEventListener("mousedown",W),document.removeEventListener("keydown",re)}},[a]);const[B,N]=K.useState({x:n,y:r});K.useEffect(()=>{const W=d.current;if(!W)return;const re=W.getBoundingClientRect(),se=window.innerWidth,le=window.innerHeight;let te=n,G=r;te+re.width>se-12&&(te=se-re.width-12),G+re.height>le-12&&(G=le-re.height-12),te<12&&(te=12),G<12&&(G=12),N({x:te,y:G})},[n,r]);const $=()=>{const W={label:f||e.label,...m?{fontSize:m}:{},...b?{fontWeight:b}:{},fontStyle:S,...y?{fontFamily:y}:{},...w?{color:w}:{},...A?{letterSpacing:A}:{},...O?{lineHeight:O}:{},...D&&D!=="none"?{textTransform:D}:{}};s(e.id,W),a()},V=()=>{i(e.id),a()},_=M("w-full rounded-lg border px-2.5 py-1.5 text-sm outline-none transition-colors",u?"bg-neutral-800 border-neutral-700 text-neutral-100 placeholder:text-neutral-500 focus:border-sky-500":"bg-white border-neutral-200 text-neutral-900 placeholder:text-neutral-400 focus:border-sky-400"),R=M("block text-xs font-medium mb-1",u?"text-neutral-400":"text-neutral-500"),z={fontFamily:y||"inherit",fontSize:Math.min(parseInt(m||"14px"),20)+"px",fontWeight:b||"inherit",fontStyle:S,color:w||"inherit",letterSpacing:A||"inherit",lineHeight:O||"1.4",textTransform:D??"none"};return h.jsxs("div",{ref:d,style:{left:B.x,top:B.y,position:"fixed",zIndex:9999},className:M("w-72 rounded-2xl border shadow-2xl shadow-black/20 overflow-hidden",u?"bg-neutral-900 border-white/10 text-neutral-100":"bg-white border-neutral-200 text-neutral-900",o?.styleEditPopover),onContextMenu:W=>W.preventDefault(),children:[h.jsxs("div",{className:M("flex items-center justify-between px-4 py-3 border-b",u?"border-white/8 bg-white/[0.03]":"border-neutral-100 bg-neutral-50"),children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest opacity-40 mb-1",children:l.editStyle}),h.jsx("p",{className:"truncate text-sm font-medium",style:z,children:f||e.label})]}),h.jsx("button",{type:"button",onClick:a,className:M("ml-3 flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs transition-colors",u?"hover:bg-white/10 text-neutral-400":"hover:bg-neutral-200 text-neutral-500"),children:"✕"})]}),h.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleName}),h.jsx("input",{type:"text",value:f,onChange:W=>p(W.target.value),className:M(_,o?.styleEditInput),placeholder:e.label})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleFontSize}),h.jsx("input",{type:"text",value:m,onChange:W=>g(W.target.value),className:M(_,o?.styleEditInput),placeholder:"16px"})]}),h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleFontWeight}),h.jsxs("select",{value:b,onChange:W=>x(W.target.value),className:M(_,"cursor-pointer",o?.styleEditInput),children:[h.jsx("option",{value:"",children:"Default"}),vC.map(W=>h.jsx("option",{value:W.value,children:W.label},W.value))]})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleFontFamily}),h.jsx("select",{value:y,onChange:W=>T(W.target.value),className:M(_,"cursor-pointer",o?.styleEditInput),children:wC.map(W=>h.jsx("option",{value:W.value,children:W.label},W.value||"__default__"))})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleFontStyle}),h.jsxs("select",{value:S,onChange:W=>k(W.target.value),className:M(_,"cursor-pointer",o?.styleEditInput),children:[h.jsx("option",{value:"normal",children:"Normal"}),h.jsx("option",{value:"italic",children:"Italic"})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleTextTransform}),h.jsxs("select",{value:D??"none",onChange:W=>F(W.target.value),className:M(_,"cursor-pointer",o?.styleEditInput),children:[h.jsx("option",{value:"none",children:"None"}),h.jsx("option",{value:"uppercase",children:"UPPERCASE"}),h.jsx("option",{value:"capitalize",children:"Capitalize"}),h.jsx("option",{value:"lowercase",children:"lowercase"})]})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleColor}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"color",value:w||"#000000",onChange:W=>C(W.target.value),className:"h-8 w-8 shrink-0 cursor-pointer rounded-lg border-0 bg-transparent p-0"}),h.jsx("input",{type:"text",value:w,onChange:W=>C(W.target.value),placeholder:"#000000",className:M(_,"flex-1",o?.styleEditInput)})]})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleLetterSpacing}),h.jsx("input",{type:"text",value:A,onChange:W=>I(W.target.value),placeholder:"0.05em",className:M(_,o?.styleEditInput)})]}),h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleLineHeight}),h.jsx("input",{type:"text",value:O,onChange:W=>j(W.target.value),placeholder:"1.6",className:M(_,o?.styleEditInput)})]})]})]}),h.jsxs("div",{className:M("flex items-center gap-2 px-4 py-3 border-t",u?"border-white/8":"border-neutral-100"),children:[h.jsx("button",{type:"button",onClick:V,className:M("flex-1 rounded-xl py-1.5 text-sm transition-colors",u?"bg-white/[0.06] text-neutral-300 hover:bg-white/10":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200",o?.styleEditResetButton),children:l.resetStyle}),h.jsx("button",{type:"button",onClick:$,className:M("flex-1 rounded-xl py-1.5 text-sm font-medium transition-colors","bg-sky-500 text-white hover:bg-sky-400",o?.styleEditSaveButton),children:l.saveStyle})]})]})},CC=({styles:e,baseStyles:t,editor:n,theme:r,classNames:o,activeStyle:s,onApply:i,onSave:a,onReset:l,keepEditorSelection:c})=>{const u=r==="dark",[d,f]=K.useState(null),p=(m,g)=>{m.preventDefault(),m.stopPropagation(),f({style:g,x:m.clientX,y:m.clientY})};return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:M("flex items-stretch gap-0 overflow-x-auto [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",o?.styleBar),children:e.map((m,g)=>{const b=s?.id===m.id,x=m.preview??m.label,S=g===0,k=g===e.length-1,y=parseInt(m.fontSize??"13",10),T=Math.min(isNaN(y)?13:y,15),w={fontFamily:m.fontFamily??"inherit",fontSize:T+"px",fontWeight:m.fontWeight??"inherit",fontStyle:m.fontStyle??"normal",color:b?u?"#38bdf8":"#0369a1":m.color??(u?"#d4d4d4":"#404040"),letterSpacing:m.letterSpacing??"inherit",textTransform:m.textTransform??"none",lineHeight:"1",whiteSpace:"nowrap"};return h.jsxs("button",{type:"button",onMouseDown:c,onClick:()=>i(m),onContextMenu:C=>p(C,m),title:`${m.label} — Right-click to edit`,className:M("relative flex h-[52px] min-w-[88px] shrink-0 select-none flex-col items-center justify-center","cursor-pointer border-y border-r px-2 transition-all duration-100",S&&"border-l",S&&"rounded-l",k&&"rounded-r",u?"border-white/10":"border-neutral-200",u?"hover:bg-white/5":"hover:bg-sky-50/60",b?u?"bg-sky-500/10 border-b-sky-400/70":"bg-sky-50 border-b-sky-400":"",o?.styleBarItem,b&&o?.styleBarItemActive),children:[b&&h.jsx("span",{className:M("absolute bottom-0 left-0 right-0 h-0.5 rounded-b",u?"bg-sky-400":"bg-sky-500")}),h.jsx("span",{style:w,className:"max-w-full overflow-hidden px-1 text-center leading-none",children:x}),h.jsx("span",{className:M("mt-1.5 max-w-full truncate px-1 text-center text-[9px] leading-none",b?u?"text-sky-400/80":"text-sky-600/80":u?"text-neutral-500":"text-neutral-400"),children:m.label})]},m.id)})}),d&&Ji.createPortal(h.jsx(kC,{style:d.style,baseStyle:t.find(m=>m.id===d.style.id)??d.style,anchorX:d.x,anchorY:d.y,classNames:o,onSave:a,onReset:l,onClose:()=>f(null)}),document.body)]})},Kp="voilabs-editor-style-overrides";function SC(){try{const e=typeof localStorage<"u"?localStorage.getItem(Kp):null;return e?JSON.parse(e):{}}catch{return{}}}function Lc(e){try{typeof localStorage<"u"&&localStorage.setItem(Kp,JSON.stringify(e))}catch{}}function TC(e){const[t,n]=K.useState(SC),r=K.useCallback((i,a)=>{n(l=>{const c={...l,[i]:{...l[i]??{},...a}};return Lc(c),c})},[]),o=K.useCallback(i=>{n(a=>{const l={...a};return delete l[i],Lc(l),l})},[]);return{effectiveStyles:e.map(i=>({...i,...t[i.id]??{}})),overrides:t,saveOverride:r,resetOverride:o}}const AC=e=>[{label:e.heading1,value:"h1",icon:h.jsx(q.Heading1,{size:14})},{label:e.heading2,value:"h2",icon:h.jsx(q.Heading2,{size:14})},{label:e.heading3,value:"h3",icon:h.jsx(q.Heading3,{size:14})},{label:e.heading4,value:"h4",icon:h.jsx(q.Heading4,{size:14})},{label:e.heading5,value:"h5",icon:h.jsx(q.Heading5,{size:14})}],EC=e=>[{label:e.bulletList,value:"bullet",icon:h.jsx(q.List,{size:14})},{label:e.numberedList,value:"ordered",icon:h.jsx(q.ListOrdered,{size:14})},{label:e.slashTaskList,value:"task",icon:h.jsx(q.ListChecks,{size:14})}],ri=[{labelKey:"highlightYellow",backgroundColor:"#fef08a",textColor:"#713f12"},{labelKey:"highlightAmber",backgroundColor:"#fde68a",textColor:"#78350f"},{labelKey:"highlightOrange",backgroundColor:"#fed7aa",textColor:"#7c2d12"},{labelKey:"highlightRed",backgroundColor:"#fecaca",textColor:"#7f1d1d"},{labelKey:"highlightPink",backgroundColor:"#fbcfe8",textColor:"#831843"},{labelKey:"highlightPurple",backgroundColor:"#ddd6fe",textColor:"#4c1d95"},{labelKey:"highlightBlue",backgroundColor:"#bfdbfe",textColor:"#1e3a8a"},{labelKey:"highlightCyan",backgroundColor:"#a5f3fc",textColor:"#164e63"},{labelKey:"highlightTeal",backgroundColor:"#99f6e4",textColor:"#134e4a"},{labelKey:"highlightGreen",backgroundColor:"#bbf7d0",textColor:"#14532d"},{labelKey:"highlightLime",backgroundColor:"#d9f99d",textColor:"#365314"},{labelKey:"highlightSlate",backgroundColor:"#334155",textColor:"#f8fafc"}],Lo={px:{min:8,max:96,step:1,defaultValue:16},rem:{min:.5,max:6,step:.1,defaultValue:1}},Gn="16px",MC=e=>{if(!e)return null;const t=e.trim().match(/^(\d+(?:\.\d+)?)(px|rem)?$/i);if(!t)return null;const n=Number.parseFloat(t[1]);return Number.isFinite(n)?{value:n,unit:t[2]?.toLowerCase()??"px"}:null},ft=e=>{const t=MC(e);if(!t)return null;const n=Lo[t.unit],r=Math.min(n.max,Math.max(n.min,t.value));return{value:t.unit==="px"?Math.round(r):Math.round(r*100)/100,unit:t.unit}},ts=e=>`${e.unit==="px"?`${Math.round(e.value)}`:`${Number(e.value.toFixed(2))}`}${e.unit}`,RC=e=>{if(typeof window>"u")return Gn;const{from:t}=e.state.selection,{node:n}=e.view.domAtPos(t),r=n instanceof HTMLElement?n:n.parentElement,o=r?.closest("span,p,h1,h2,h3,h4,h5,h6,li,blockquote,code,pre")??r;if(!o)return Gn;const s=window.getComputedStyle(o).fontSize,i=ft(s);return i?ts(i):Gn},Dc=e=>{if(!e)return"";const t=e.getAttributes("textStyle").fontSize,n=ft(t);return n?ts(n):RC(e)},Co=/[\p{L}\p{N}_'-]/u,dr=e=>{if(!e)return"";const t=e.trim().toLowerCase();if(/^#[0-9a-f]{6}$/.test(t))return t;if(/^#[0-9a-f]{3}$/.test(t))return`#${t.slice(1).split("").map(r=>r+r).join("")}`;const n=t.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*[\d.]+)?\)$/);return n?`#${n.slice(1,4).map(r=>Number(r).toString(16).padStart(2,"0")).join("")}`:t},NC=e=>{const{selection:t}=e.state;if(!t.empty)return null;const{$from:n}=t;if(!n.parent.isTextblock)return null;const r=n.parent.textBetween(0,n.parent.content.size,`
|
|
126
|
+
`)},qw=0,_n=[];function Kw(e){var t=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),o=v.useState(qw++)[0],s=v.useState(Df)[0],i=v.useRef(e);v.useEffect(function(){i.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=pw([e.lockRef.current],(e.shards||[]).map(Oc),!0).filter(Boolean);return g.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=v.useCallback(function(g,b){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var x=Co(g),S=n.current,k="deltaX"in g?g.deltaX:S[0]-x[0],y="deltaY"in g?g.deltaY:S[1]-x[1],A,w=g.target,C=Math.abs(k)>Math.abs(y)?"h":"v";if("touches"in g&&C==="h"&&w.type==="range")return!1;var T=window.getSelection(),I=T&&T.anchorNode,O=I?I===w||I.contains(w):!1;if(O)return!1;var j=Rc(C,w);if(!j)return!0;if(j?A=C:(A=C==="v"?"h":"v",j=Rc(C,w)),!j)return!1;if(!r.current&&"changedTouches"in g&&(k||y)&&(r.current=A),!A)return!0;var D=r.current||A;return Hw(D,b,g,D==="h"?k:y)},[]),l=v.useCallback(function(g){var b=g;if(!(!_n.length||_n[_n.length-1]!==s)){var x="deltaY"in b?Nc(b):Co(b),S=t.current.filter(function(A){return A.name===b.type&&(A.target===b.target||b.target===A.shadowParent)&&Ww(A.delta,x)})[0];if(S&&S.should){b.cancelable&&b.preventDefault();return}if(!S){var k=(i.current.shards||[]).map(Oc).filter(Boolean).filter(function(A){return A.contains(b.target)}),y=k.length>0?a(b,k[0]):!i.current.noIsolation;y&&b.cancelable&&b.preventDefault()}}},[]),c=v.useCallback(function(g,b,x,S){var k={name:g,delta:b,target:x,should:S,shadowParent:Uw(x)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(y){return y!==k})},1)},[]),u=v.useCallback(function(g){n.current=Co(g),r.current=void 0},[]),d=v.useCallback(function(g){c(g.type,Nc(g),g.target,a(g,e.lockRef.current))},[]),f=v.useCallback(function(g){c(g.type,Co(g),g.target,a(g,e.lockRef.current))},[]);v.useEffect(function(){return _n.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,zn),document.addEventListener("touchmove",l,zn),document.addEventListener("touchstart",u,zn),function(){_n=_n.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,zn),document.removeEventListener("touchmove",l,zn),document.removeEventListener("touchstart",u,zn)}},[]);var p=e.removeScrollBar,m=e.inert;return v.createElement(v.Fragment,null,m?v.createElement(s,{styles:Vw(o)}):null,p?v.createElement(Dw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Uw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Gw=kw(Lf,Kw);var $a=v.forwardRef(function(e,t){return v.createElement(ks,St({},e,{ref:t,sideCar:Gw}))});$a.classNames=ks.classNames;var Vi=["Enter"," "],Xw=["ArrowDown","PageUp","Home"],$f=["ArrowUp","PageDown","End"],Jw=[...Xw,...$f],Yw={ltr:[...Vi,"ArrowRight"],rtl:[...Vi,"ArrowLeft"]},Qw={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Gr="Menu",[Pr,Zw,ek]=Gd(Gr),[In,Ff]=sr(Gr,[ek,ws,Tf]),Xr=ws(),Bf=Tf(),[Hf,an]=In(Gr),[tk,Jr]=In(Gr),Wf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Xr(t),[l,c]=v.useState(null),u=v.useRef(!1),d=Ot(s),f=Xd(o);return v.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(ja,{...a,children:h.jsx(Hf,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(tk,{scope:t,onClose:v.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:i,children:r})})})};Wf.displayName=Gr;var nk="MenuAnchor",Fa=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Xr(n);return h.jsx(za,{...o,...r,ref:t})});Fa.displayName=nk;var Ba="MenuPortal",[rk,Vf]=In(Ba,{forceMount:void 0}),qf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=an(Ba,t);return h.jsx(rk,{scope:t,forceMount:n,children:h.jsx(On,{present:n||s.open,children:h.jsx(_a,{asChild:!0,container:o,children:r})})})};qf.displayName=Ba;var lt="MenuContent",[ok,Ha]=In(lt),Kf=v.forwardRef((e,t)=>{const n=Vf(lt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=an(lt,e.__scopeMenu),i=Jr(lt,e.__scopeMenu);return h.jsx(Pr.Provider,{scope:e.__scopeMenu,children:h.jsx(On,{present:r||s.open,children:h.jsx(Pr.Slot,{scope:e.__scopeMenu,children:i.modal?h.jsx(sk,{...o,ref:t}):h.jsx(ik,{...o,ref:t})})})})}),sk=v.forwardRef((e,t)=>{const n=an(lt,e.__scopeMenu),r=v.useRef(null),o=De(t,r);return v.useEffect(()=>{const s=r.current;if(s)return Of(s)},[]),h.jsx(Wa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),ik=v.forwardRef((e,t)=>{const n=an(lt,e.__scopeMenu);return h.jsx(Wa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),ak=Or("MenuContent.ScrollLock"),Wa=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...g}=e,b=an(lt,n),x=Jr(lt,n),S=Xr(n),k=Bf(n),y=Zw(n),[A,w]=v.useState(null),C=v.useRef(null),T=De(t,C,b.onContentChange),I=v.useRef(0),O=v.useRef(""),j=v.useRef(0),D=v.useRef(null),F=v.useRef("right"),B=v.useRef(0),N=m?$a:v.Fragment,$=m?{as:ak,allowPinchZoom:!0}:void 0,V=R=>{const z=O.current+R,W=y().filter(H=>!H.disabled),re=document.activeElement,se=W.find(H=>H.ref.current===re)?.textValue,le=W.map(H=>H.textValue),te=xk(le,z,se),G=W.find(H=>H.textValue===te)?.ref.current;(function H(J){O.current=J,window.clearTimeout(I.current),J!==""&&(I.current=window.setTimeout(()=>H(""),1e3))})(z),G&&setTimeout(()=>G.focus())};v.useEffect(()=>()=>window.clearTimeout(I.current),[]),Qd();const _=v.useCallback(R=>F.current===D.current?.side&&wk(R,D.current?.area),[]);return h.jsx(ok,{scope:n,searchRef:O,onItemEnter:v.useCallback(R=>{_(R)&&R.preventDefault()},[_]),onItemLeave:v.useCallback(R=>{_(R)||(C.current?.focus(),w(null))},[_]),onTriggerLeave:v.useCallback(R=>{_(R)&&R.preventDefault()},[_]),pointerGraceTimerRef:j,onPointerGraceIntentChange:v.useCallback(R=>{D.current=R},[]),children:h.jsx(N,{...$,children:h.jsx(Ea,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,R=>{R.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:h.jsx(Aa,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(lw,{asChild:!0,...k,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:w,onEntryFocus:ae(l,R=>{x.isUsingKeyboardRef.current||R.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(kf,{role:"menu","aria-orientation":"vertical","data-state":cp(b.open),"data-radix-menu-content":"",dir:x.dir,...S,...g,ref:T,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,R=>{const W=R.target.closest("[data-radix-menu-content]")===R.currentTarget,re=R.ctrlKey||R.altKey||R.metaKey,se=R.key.length===1;W&&(R.key==="Tab"&&R.preventDefault(),!re&&se&&V(R.key));const le=C.current;if(R.target!==le||!Jw.includes(R.key))return;R.preventDefault();const G=y().filter(H=>!H.disabled).map(H=>H.ref.current);$f.includes(R.key)&&G.reverse(),bk(G)}),onBlur:ae(e.onBlur,R=>{R.currentTarget.contains(R.target)||(window.clearTimeout(I.current),O.current="")}),onPointerMove:ae(e.onPointerMove,Lr(R=>{const z=R.target,W=B.current!==R.clientX;if(R.currentTarget.contains(z)&&W){const re=R.clientX>B.current?"right":"left";F.current=re,B.current=R.clientX}}))})})})})})})});Kf.displayName=lt;var lk="MenuGroup",Va=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Ie.div,{role:"group",...r,ref:t})});Va.displayName=lk;var ck="MenuLabel",Uf=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Ie.div,{...r,ref:t})});Uf.displayName=ck;var ts="MenuItem",Ic="menu.itemSelect",Cs=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=v.useRef(null),i=Jr(ts,e.__scopeMenu),a=Ha(ts,e.__scopeMenu),l=De(t,s),c=v.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(Ic,{bubbles:!0,cancelable:!0});d.addEventListener(Ic,p=>r?.(p),{once:!0}),Ud(d,f),f.defaultPrevented?c.current=!1:i.onClose()}};return h.jsx(Gf,{...o,ref:l,disabled:n,onClick:ae(e.onClick,u),onPointerDown:d=>{e.onPointerDown?.(d),c.current=!0},onPointerUp:ae(e.onPointerUp,d=>{c.current||d.currentTarget?.click()}),onKeyDown:ae(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||Vi.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Cs.displayName=ts;var Gf=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Ha(ts,n),a=Bf(n),l=v.useRef(null),c=De(t,l),[u,d]=v.useState(!1),[f,p]=v.useState("");return v.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(Pr.ItemSlot,{scope:n,disabled:r,textValue:o??f,children:h.jsx(cw,{asChild:!0,...a,focusable:!r,children:h.jsx(Ie.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ae(e.onPointerMove,Lr(m=>{r?i.onItemLeave(m):(i.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,Lr(m=>i.onItemLeave(m))),onFocus:ae(e.onFocus,()=>d(!0)),onBlur:ae(e.onBlur,()=>d(!1))})})})}),uk="MenuCheckboxItem",Xf=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return h.jsx(ep,{scope:e.__scopeMenu,checked:n,children:h.jsx(Cs,{role:"menuitemcheckbox","aria-checked":ns(n)?"mixed":n,...o,ref:t,"data-state":Ua(n),onSelect:ae(o.onSelect,()=>r?.(ns(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Xf.displayName=uk;var Jf="MenuRadioGroup",[dk,fk]=In(Jf,{value:void 0,onValueChange:()=>{}}),Yf=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Ot(r);return h.jsx(dk,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(Va,{...o,ref:t})})});Yf.displayName=Jf;var Qf="MenuRadioItem",Zf=v.forwardRef((e,t)=>{const{value:n,...r}=e,o=fk(Qf,e.__scopeMenu),s=n===o.value;return h.jsx(ep,{scope:e.__scopeMenu,checked:s,children:h.jsx(Cs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ua(s),onSelect:ae(r.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Zf.displayName=Qf;var qa="MenuItemIndicator",[ep,pk]=In(qa,{checked:!1}),tp=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=pk(qa,n);return h.jsx(On,{present:r||ns(s.checked)||s.checked===!0,children:h.jsx(Ie.span,{...o,ref:t,"data-state":Ua(s.checked)})})});tp.displayName=qa;var hk="MenuSeparator",np=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Ie.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});np.displayName=hk;var mk="MenuArrow",rp=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Xr(n);return h.jsx(Cf,{...o,...r,ref:t})});rp.displayName=mk;var Ka="MenuSub",[gk,op]=In(Ka),sp=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:o}=e,s=an(Ka,t),i=Xr(t),[a,l]=v.useState(null),[c,u]=v.useState(null),d=Ot(o);return v.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(ja,{...i,children:h.jsx(Hf,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(gk,{scope:t,contentId:Yn(),triggerId:Yn(),trigger:a,onTriggerChange:l,children:n})})})};sp.displayName=Ka;var yr="MenuSubTrigger",ip=v.forwardRef((e,t)=>{const n=an(yr,e.__scopeMenu),r=Jr(yr,e.__scopeMenu),o=op(yr,e.__scopeMenu),s=Ha(yr,e.__scopeMenu),i=v.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=v.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return v.useEffect(()=>u,[u]),v.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(Fa,{asChild:!0,...c,children:h.jsx(Gf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":cp(n.open),...e,ref:ms(t,o.onTriggerChange),onClick:d=>{e.onClick?.(d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ae(e.onPointerMove,Lr(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:ae(e.onPointerLeave,Lr(d=>{u();const f=n.content?.getBoundingClientRect();if(f){const p=n.content?.dataset.side,m=p==="right",g=m?-5:5,b=f[m?"left":"right"],x=f[m?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+g,y:d.clientY},{x:b,y:f.top},{x,y:f.top},{x,y:f.bottom},{x:b,y:f.bottom}],side:p}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(e.onKeyDown,d=>{const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||Yw[r.dir].includes(d.key)&&(n.onOpenChange(!0),n.content?.focus(),d.preventDefault())})})})});ip.displayName=yr;var ap="MenuSubContent",lp=v.forwardRef((e,t)=>{const n=Vf(lt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=an(lt,e.__scopeMenu),i=Jr(lt,e.__scopeMenu),a=op(ap,e.__scopeMenu),l=v.useRef(null),c=De(t,l);return h.jsx(Pr.Provider,{scope:e.__scopeMenu,children:h.jsx(On,{present:r||s.open,children:h.jsx(Pr.Slot,{scope:e.__scopeMenu,children:h.jsx(Wa,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{i.isUsingKeyboardRef.current&&l.current?.focus(),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ae(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:ae(e.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),f=Qw[i.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),a.trigger?.focus(),u.preventDefault())})})})})})});lp.displayName=ap;function cp(e){return e?"open":"closed"}function ns(e){return e==="indeterminate"}function Ua(e){return ns(e)?"indeterminate":e?"checked":"unchecked"}function bk(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function yk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function xk(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=yk(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function vk(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(o=!o)}return o}function wk(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return vk(n,t)}function Lr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var kk=Wf,Ck=Fa,Sk=qf,Tk=Kf,Ak=Va,Ek=Uf,Mk=Cs,Rk=Xf,Nk=Yf,Ok=Zf,Ik=tp,Pk=np,Lk=rp,Dk=sp,jk=ip,zk=lp,Ss="DropdownMenu",[_k]=sr(Ss,[Ff]),ze=Ff(),[$k,up]=_k(Ss),dp=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=ze(t),c=v.useRef(null),[u,d]=gs({prop:o,defaultProp:s??!1,onChange:i,caller:Ss});return h.jsx($k,{scope:t,triggerId:Yn(),triggerRef:c,contentId:Yn(),open:u,onOpenChange:d,onOpenToggle:v.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(kk,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};dp.displayName=Ss;var fp="DropdownMenuTrigger",pp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=up(fp,n),i=ze(n);return h.jsx(Ck,{asChild:!0,...i,children:h.jsx(Ie.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:ms(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});pp.displayName=fp;var Fk="DropdownMenuPortal",hp=e=>{const{__scopeDropdownMenu:t,...n}=e,r=ze(t);return h.jsx(Sk,{...r,...n})};hp.displayName=Fk;var mp="DropdownMenuContent",gp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=up(mp,n),s=ze(n),i=v.useRef(!1);return h.jsx(Tk,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{i.current||o.triggerRef.current?.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!o.modal||u)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});gp.displayName=mp;var Bk="DropdownMenuGroup",Hk=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Ak,{...o,...r,ref:t})});Hk.displayName=Bk;var Wk="DropdownMenuLabel",bp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Ek,{...o,...r,ref:t})});bp.displayName=Wk;var Vk="DropdownMenuItem",yp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Mk,{...o,...r,ref:t})});yp.displayName=Vk;var qk="DropdownMenuCheckboxItem",xp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Rk,{...o,...r,ref:t})});xp.displayName=qk;var Kk="DropdownMenuRadioGroup",Uk=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Nk,{...o,...r,ref:t})});Uk.displayName=Kk;var Gk="DropdownMenuRadioItem",vp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Ok,{...o,...r,ref:t})});vp.displayName=Gk;var Xk="DropdownMenuItemIndicator",wp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Ik,{...o,...r,ref:t})});wp.displayName=Xk;var Jk="DropdownMenuSeparator",kp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Pk,{...o,...r,ref:t})});kp.displayName=Jk;var Yk="DropdownMenuArrow",Qk=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(Lk,{...o,...r,ref:t})});Qk.displayName=Yk;var Zk=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:o,defaultOpen:s}=e,i=ze(t),[a,l]=gs({prop:r,defaultProp:s??!1,onChange:o,caller:"DropdownMenuSub"});return h.jsx(Dk,{...i,open:a,onOpenChange:l,children:n})},eC="DropdownMenuSubTrigger",Cp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(jk,{...o,...r,ref:t})});Cp.displayName=eC;var tC="DropdownMenuSubContent",Sp=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ze(n);return h.jsx(zk,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Sp.displayName=tC;var nC=dp,rC=pp,Tp=hp,Ap=gp,Ep=bp,Mp=yp,Rp=xp,Np=vp,Op=wp,Ip=kp,oC=Zk,Pp=Cp,Lp=Sp;const Dp=nC,jp=rC,Pc=({children:e,...t})=>{const n=qr();return h.jsx(Tp,{container:n??void 0,...t,children:e})},Lc=oC,qi=v.forwardRef(({className:e,inset:t,children:n,...r},o)=>{const s=We(),i=Ve();return h.jsxs(Pp,{ref:o,className:M("flex cursor-default select-none items-center rounded-full px-2 py-1.5 text-sm outline-none transition-colors gap-2",s==="dark"?"focus:bg-neutral-800 data-[state=open]:bg-neutral-800 text-neutral-300":"focus:bg-neutral-100 data-[state=open]:bg-neutral-100 text-neutral-700",t&&"pl-8",i?.dropdownSubTrigger,e),...r,children:[n,h.jsx(q.ChevronRight,{className:M("ml-auto h-4 w-4",i?.dropdownSubTriggerChevron)})]})});qi.displayName=Pp.displayName;const Ki=v.forwardRef(({className:e,...t},n)=>{const r=We(),o=Ve();return h.jsx(Lp,{ref:n,className:M("z-[99999] min-w-[8rem] overflow-hidden rounded-3xl border p-1.5 shadow-lg backdrop-blur-xl animate-in fade-in zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out data-[state=closed]:zoom-out-95",r==="dark"?"bg-neutral-900/95 border-neutral-800 shadow-black/50 text-neutral-200":"bg-white/95 border-neutral-200/60 text-neutral-700",o?.dropdownSubContent,e),...t})});Ki.displayName=Lp.displayName;const Ga=v.forwardRef(({className:e,sideOffset:t=8,...n},r)=>{const o=We(),s=Ve(),i=qr();return h.jsx(Tp,{container:i??void 0,children:h.jsx(Ap,{ref:r,sideOffset:t,className:M("z-[99999] min-w-[12rem] overflow-hidden rounded-3xl border p-1.5 shadow-xl backdrop-blur-xl animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",o==="dark"?"bg-neutral-900/95 border-neutral-800 shadow-black/50 text-neutral-200":"bg-white/95 border-neutral-200/60 text-neutral-700",s?.dropdownContent,e),...n})})});Ga.displayName=Ap.displayName;const Ke=v.forwardRef(({className:e,inset:t,...n},r)=>{const o=We(),s=Ve();return h.jsx(Mp,{ref:r,className:M("relative flex cursor-pointer select-none items-center rounded-full px-3 py-2 text-sm outline-none transition-colors gap-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o==="dark"?"focus:bg-neutral-800 focus:text-neutral-100 text-neutral-300":"focus:bg-neutral-100 focus:text-neutral-900 text-neutral-600",t&&"pl-8",s?.dropdownItem,e),...n})});Ke.displayName=Mp.displayName;const sC=v.forwardRef(({className:e,children:t,checked:n,...r},o)=>{const s=We(),i=Ve();return h.jsxs(Rp,{ref:o,className:M("relative flex cursor-default select-none items-center rounded-xl py-2 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s==="dark"?"focus:bg-neutral-800 focus:text-neutral-100 text-neutral-300":"focus:bg-neutral-100 focus:text-neutral-900 text-neutral-600",i?.dropdownCheckboxItem,e),checked:n,...r,children:[h.jsx("span",{className:M("absolute left-2 flex h-3.5 w-3.5 items-center justify-center",i?.dropdownIndicator),children:h.jsx(Op,{children:h.jsx(q.Check,{className:"h-4 w-4"})})}),t]})});sC.displayName=Rp.displayName;const iC=v.forwardRef(({className:e,children:t,...n},r)=>{const o=We(),s=Ve();return h.jsxs(Np,{ref:r,className:M("relative flex cursor-default select-none items-center rounded-xl py-2 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o==="dark"?"focus:bg-neutral-800 focus:text-neutral-100 text-neutral-300":"focus:bg-neutral-100 focus:text-neutral-900 text-neutral-600",s?.dropdownRadioItem,e),...n,children:[h.jsx("span",{className:M("absolute left-2 flex h-3.5 w-3.5 items-center justify-center",s?.dropdownIndicator),children:h.jsx(Op,{children:h.jsx(q.Circle,{className:"h-2 w-2 fill-current"})})}),t]})});iC.displayName=Np.displayName;const aC=v.forwardRef(({className:e,inset:t,...n},r)=>{const o=Ve();return h.jsx(Ep,{ref:r,className:M("px-3 py-1.5 text-xs font-semibold text-neutral-500",t&&"pl-8",o?.dropdownLabel,e),...n})});aC.displayName=Ep.displayName;const xr=v.forwardRef(({className:e,...t},n)=>{const r=We(),o=Ve();return h.jsx(Ip,{ref:n,className:M("-mx-1 my-1 h-px",r==="dark"?"bg-neutral-800":"bg-neutral-200/60",o?.dropdownSeparator,e),...t})});xr.displayName=Ip.displayName;const zp=({className:e,...t})=>{const n=Ve();return h.jsx("span",{className:M("ml-auto text-xs tracking-widest opacity-60",n?.dropdownShortcut,e),...t})};zp.displayName="DropdownMenuShortcut";const Dc=({trigger:e,items:t,value:n,onSelect:r,align:o="start"})=>{const s=We(),i=Ve();return h.jsxs(Dp,{children:[h.jsx(jp,{asChild:!0,children:e}),h.jsx(Ga,{align:o,children:t.map(a=>h.jsxs(Ke,{onSelect:()=>r(a.value),className:M("gap-2 px-3 py-2 rounded-full",n===a.value&&(s==="dark"?"bg-neutral-800 text-neutral-100":"bg-neutral-100 text-neutral-900"),n===a.value&&i?.dropdownItemActive,i?.dropdownItem),children:[a.icon&&h.jsx("span",{className:M("flex items-center justify-center w-5 h-5 shrink-0",i?.dropdownItemIcon),children:a.icon}),h.jsx("span",{className:M("flex-1 font-medium",i?.dropdownItemLabel),children:a.label}),a.shortcut&&h.jsx(zp,{children:a.shortcut}),n===a.value&&h.jsx(q.Check,{className:M("ml-auto size-3.5 shrink-0",s==="dark"?"text-neutral-400":"text-neutral-500",i?.dropdownItemCheck)})]},a.value))})]})};var Ts="Popover",[_p]=sr(Ts,[ws]),Yr=ws(),[lC,ln]=_p(Ts),$p=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=Yr(t),l=v.useRef(null),[c,u]=v.useState(!1),[d,f]=gs({prop:r,defaultProp:o??!1,onChange:s,caller:Ts});return h.jsx(ja,{...a,children:h.jsx(lC,{scope:t,contentId:Yn(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:c,onCustomAnchorAdd:v.useCallback(()=>u(!0),[]),onCustomAnchorRemove:v.useCallback(()=>u(!1),[]),modal:i,children:n})})};$p.displayName=Ts;var Fp="PopoverAnchor",cC=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ln(Fp,n),s=Yr(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return v.useEffect(()=>(i(),()=>a()),[i,a]),h.jsx(za,{...s,...r,ref:t})});cC.displayName=Fp;var Bp="PopoverTrigger",Hp=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ln(Bp,n),s=Yr(n),i=De(t,o.triggerRef),a=h.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Up(o.open),...r,ref:i,onClick:ae(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:h.jsx(za,{asChild:!0,...s,children:a})});Hp.displayName=Bp;var Xa="PopoverPortal",[uC,dC]=_p(Xa,{forceMount:void 0}),Wp=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=ln(Xa,t);return h.jsx(uC,{scope:t,forceMount:n,children:h.jsx(On,{present:n||s.open,children:h.jsx(_a,{asChild:!0,container:o,children:r})})})};Wp.displayName=Xa;var Zn="PopoverContent",Vp=v.forwardRef((e,t)=>{const n=dC(Zn,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=ln(Zn,e.__scopePopover);return h.jsx(On,{present:r||s.open,children:s.modal?h.jsx(pC,{...o,ref:t}):h.jsx(hC,{...o,ref:t})})});Vp.displayName=Zn;var fC=Or("PopoverContent.RemoveScroll"),pC=v.forwardRef((e,t)=>{const n=ln(Zn,e.__scopePopover),r=v.useRef(null),o=De(t,r),s=v.useRef(!1);return v.useEffect(()=>{const i=r.current;if(i)return Of(i)},[]),h.jsx($a,{as:fC,allowPinchZoom:!0,children:h.jsx(qp,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(e.onCloseAutoFocus,i=>{i.preventDefault(),s.current||n.triggerRef.current?.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:ae(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),hC=v.forwardRef((e,t)=>{const n=ln(Zn,e.__scopePopover),r=v.useRef(!1),o=v.useRef(!1);return h.jsx(qp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(r.current||n.triggerRef.current?.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;n.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),qp=v.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,f=ln(Zn,n),p=Yr(n);return Qd(),h.jsx(Ea,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:h.jsx(Aa,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1),children:h.jsx(kf,{"data-state":Up(f.open),role:"dialog",id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Kp="PopoverClose",mC=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ln(Kp,n);return h.jsx(Ie.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});mC.displayName=Kp;var gC="PopoverArrow",bC=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Yr(n);return h.jsx(Cf,{...o,...r,ref:t})});bC.displayName=gC;function Up(e){return e?"open":"closed"}var yC=$p,xC=Hp,vC=Wp,wC=Vp;const Lo=({trigger:e,children:t,align:n="start",side:r="bottom",open:o,onOpenChange:s})=>{const i=We(),a=Ve(),l=qr();return h.jsxs(yC,{open:o,onOpenChange:s,children:[h.jsx(xC,{asChild:!0,children:e}),h.jsx(vC,{container:l??void 0,children:h.jsx(wC,{align:n,side:r,sideOffset:8,className:M("z-50 rounded-3xl border p-1.5 shadow-xl backdrop-blur-xl outline-none","animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",i==="dark"?"bg-neutral-900/95 border-neutral-800 shadow-black/50":"bg-white/95 border-neutral-200/60",a?.popoverContent),children:t})})]})},kC=[{label:"Thin (100)",value:"100"},{label:"Light (300)",value:"300"},{label:"Normal (400)",value:"400"},{label:"Medium (500)",value:"500"},{label:"Semi Bold (600)",value:"600"},{label:"Bold (700)",value:"700"},{label:"Extra Bold (800)",value:"800"},{label:"Black (900)",value:"900"}],CC=[{label:"Default",value:""},{label:"Inter",value:"Inter, sans-serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Times New Roman",value:"Times New Roman, Times, serif"},{label:"Courier New",value:"Courier New, Courier, monospace"},{label:"Trebuchet MS",value:"Trebuchet MS, sans-serif"},{label:"Arial",value:"Arial, Helvetica, sans-serif"},{label:"Verdana",value:"Verdana, Geneva, sans-serif"}],SC=({style:e,baseStyle:t,anchorX:n,anchorY:r,classNames:o,onSave:s,onReset:i,onClose:a})=>{const l=Vr(),u=We()==="dark",d=K.useRef(null),[f,p]=K.useState(e.label),[m,g]=K.useState(e.fontSize??""),[b,x]=K.useState(e.fontWeight??""),[S,k]=K.useState(e.fontStyle??"normal"),[y,A]=K.useState(e.fontFamily??""),[w,C]=K.useState(e.color??""),[T,I]=K.useState(e.letterSpacing??""),[O,j]=K.useState(e.lineHeight??""),[D,F]=K.useState(e.textTransform??"none");K.useEffect(()=>{const W=se=>{d.current&&!d.current.contains(se.target)&&a()},re=se=>{se.key==="Escape"&&a()};return document.addEventListener("mousedown",W),document.addEventListener("keydown",re),()=>{document.removeEventListener("mousedown",W),document.removeEventListener("keydown",re)}},[a]);const[B,N]=K.useState({x:n,y:r});K.useEffect(()=>{const W=d.current;if(!W)return;const re=W.getBoundingClientRect(),se=window.innerWidth,le=window.innerHeight;let te=n,G=r;te+re.width>se-12&&(te=se-re.width-12),G+re.height>le-12&&(G=le-re.height-12),te<12&&(te=12),G<12&&(G=12),N({x:te,y:G})},[n,r]);const $=()=>{const W={label:f||e.label,...m?{fontSize:m}:{},...b?{fontWeight:b}:{},fontStyle:S,...y?{fontFamily:y}:{},...w?{color:w}:{},...T?{letterSpacing:T}:{},...O?{lineHeight:O}:{},...D&&D!=="none"?{textTransform:D}:{}};s(e.id,W),a()},V=()=>{i(e.id),a()},_=M("w-full rounded-lg border px-2.5 py-1.5 text-sm outline-none transition-colors",u?"bg-neutral-800 border-neutral-700 text-neutral-100 placeholder:text-neutral-500 focus:border-sky-500":"bg-white border-neutral-200 text-neutral-900 placeholder:text-neutral-400 focus:border-sky-400"),R=M("block text-xs font-medium mb-1",u?"text-neutral-400":"text-neutral-500"),z={fontFamily:y||"inherit",fontSize:Math.min(parseInt(m||"14px"),20)+"px",fontWeight:b||"inherit",fontStyle:S,color:w||"inherit",letterSpacing:T||"inherit",lineHeight:O||"1.4",textTransform:D??"none"};return h.jsxs("div",{ref:d,style:{left:B.x,top:B.y,position:"fixed",zIndex:9999},className:M("w-72 rounded-2xl border shadow-2xl shadow-black/20 overflow-hidden",u?"bg-neutral-900 border-white/10 text-neutral-100":"bg-white border-neutral-200 text-neutral-900",o?.styleEditPopover),onContextMenu:W=>W.preventDefault(),children:[h.jsxs("div",{className:M("flex items-center justify-between px-4 py-3 border-b",u?"border-white/8 bg-white/[0.03]":"border-neutral-100 bg-neutral-50"),children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest opacity-40 mb-1",children:l.editStyle}),h.jsx("p",{className:"truncate text-sm font-medium",style:z,children:f||e.label})]}),h.jsx("button",{type:"button",onClick:a,className:M("ml-3 flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs transition-colors",u?"hover:bg-white/10 text-neutral-400":"hover:bg-neutral-200 text-neutral-500"),children:"✕"})]}),h.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleName}),h.jsx("input",{type:"text",value:f,onChange:W=>p(W.target.value),className:M(_,o?.styleEditInput),placeholder:e.label})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleFontSize}),h.jsx("input",{type:"text",value:m,onChange:W=>g(W.target.value),className:M(_,o?.styleEditInput),placeholder:"16px"})]}),h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleFontWeight}),h.jsxs("select",{value:b,onChange:W=>x(W.target.value),className:M(_,"cursor-pointer",o?.styleEditInput),children:[h.jsx("option",{value:"",children:"Default"}),kC.map(W=>h.jsx("option",{value:W.value,children:W.label},W.value))]})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleFontFamily}),h.jsx("select",{value:y,onChange:W=>A(W.target.value),className:M(_,"cursor-pointer",o?.styleEditInput),children:CC.map(W=>h.jsx("option",{value:W.value,children:W.label},W.value||"__default__"))})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleFontStyle}),h.jsxs("select",{value:S,onChange:W=>k(W.target.value),className:M(_,"cursor-pointer",o?.styleEditInput),children:[h.jsx("option",{value:"normal",children:"Normal"}),h.jsx("option",{value:"italic",children:"Italic"})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleTextTransform}),h.jsxs("select",{value:D??"none",onChange:W=>F(W.target.value),className:M(_,"cursor-pointer",o?.styleEditInput),children:[h.jsx("option",{value:"none",children:"None"}),h.jsx("option",{value:"uppercase",children:"UPPERCASE"}),h.jsx("option",{value:"capitalize",children:"Capitalize"}),h.jsx("option",{value:"lowercase",children:"lowercase"})]})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleColor}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"color",value:w||"#000000",onChange:W=>C(W.target.value),className:"h-8 w-8 shrink-0 cursor-pointer rounded-lg border-0 bg-transparent p-0"}),h.jsx("input",{type:"text",value:w,onChange:W=>C(W.target.value),placeholder:"#000000",className:M(_,"flex-1",o?.styleEditInput)})]})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleLetterSpacing}),h.jsx("input",{type:"text",value:T,onChange:W=>I(W.target.value),placeholder:"0.05em",className:M(_,o?.styleEditInput)})]}),h.jsxs("div",{children:[h.jsx("label",{className:R,children:l.styleLineHeight}),h.jsx("input",{type:"text",value:O,onChange:W=>j(W.target.value),placeholder:"1.6",className:M(_,o?.styleEditInput)})]})]})]}),h.jsxs("div",{className:M("flex items-center gap-2 px-4 py-3 border-t",u?"border-white/8":"border-neutral-100"),children:[h.jsx("button",{type:"button",onClick:V,className:M("flex-1 rounded-xl py-1.5 text-sm transition-colors",u?"bg-white/[0.06] text-neutral-300 hover:bg-white/10":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200",o?.styleEditResetButton),children:l.resetStyle}),h.jsx("button",{type:"button",onClick:$,className:M("flex-1 rounded-xl py-1.5 text-sm font-medium transition-colors","bg-sky-500 text-white hover:bg-sky-400",o?.styleEditSaveButton),children:l.saveStyle})]})]})},TC=({styles:e,baseStyles:t,editor:n,theme:r,classNames:o,activeStyle:s,onApply:i,onSave:a,onReset:l,keepEditorSelection:c})=>{const u=r==="dark",[d,f]=K.useState(null),p=qr(),m=(g,b)=>{g.preventDefault(),g.stopPropagation(),f({style:b,x:g.clientX,y:g.clientY})};return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:M("flex items-stretch gap-0 overflow-x-auto [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",o?.styleBar),children:e.map((g,b)=>{const x=s?.id===g.id,S=g.preview??g.label,k=b===0,y=b===e.length-1,A=parseInt(g.fontSize??"13",10),w=Math.min(isNaN(A)?13:A,15),C={fontFamily:g.fontFamily??"inherit",fontSize:w+"px",fontWeight:g.fontWeight??"inherit",fontStyle:g.fontStyle??"normal",color:x?u?"#38bdf8":"#0369a1":g.color??(u?"#d4d4d4":"#404040"),letterSpacing:g.letterSpacing??"inherit",textTransform:g.textTransform??"none",lineHeight:"1",whiteSpace:"nowrap"};return h.jsxs("button",{type:"button",onMouseDown:c,onClick:()=>i(g),onContextMenu:T=>m(T,g),title:`${g.label} — Right-click to edit`,className:M("relative flex h-[52px] min-w-[88px] shrink-0 select-none flex-col items-center justify-center","cursor-pointer border-y border-r px-2 transition-all duration-100",k&&"border-l",k&&"rounded-l",y&&"rounded-r",u?"border-white/10":"border-neutral-200",u?"hover:bg-white/5":"hover:bg-sky-50/60",x?u?"bg-sky-500/10 border-b-sky-400/70":"bg-sky-50 border-b-sky-400":"",o?.styleBarItem,x&&o?.styleBarItemActive),children:[x&&h.jsx("span",{className:M("absolute bottom-0 left-0 right-0 h-0.5 rounded-b",u?"bg-sky-400":"bg-sky-500")}),h.jsx("span",{style:C,className:"max-w-full overflow-hidden px-1 text-center leading-none",children:S}),h.jsx("span",{className:M("mt-1.5 max-w-full truncate px-1 text-center text-[9px] leading-none",x?u?"text-sky-400/80":"text-sky-600/80":u?"text-neutral-500":"text-neutral-400"),children:g.label})]},g.id)})}),d&&p&&Qi.createPortal(h.jsx(SC,{style:d.style,baseStyle:t.find(g=>g.id===d.style.id)??d.style,anchorX:d.x,anchorY:d.y,classNames:o,onSave:a,onReset:l,onClose:()=>f(null)}),p)]})},Gp="voilabs-editor-style-overrides";function AC(){try{const e=typeof localStorage<"u"?localStorage.getItem(Gp):null;return e?JSON.parse(e):{}}catch{return{}}}function jc(e){try{typeof localStorage<"u"&&localStorage.setItem(Gp,JSON.stringify(e))}catch{}}function EC(e){const[t,n]=K.useState(AC),r=K.useCallback((i,a)=>{n(l=>{const c={...l,[i]:{...l[i]??{},...a}};return jc(c),c})},[]),o=K.useCallback(i=>{n(a=>{const l={...a};return delete l[i],jc(l),l})},[]);return{effectiveStyles:e.map(i=>({...i,...t[i.id]??{}})),overrides:t,saveOverride:r,resetOverride:o}}const MC=e=>[{label:e.heading1,value:"h1",icon:h.jsx(q.Heading1,{size:14})},{label:e.heading2,value:"h2",icon:h.jsx(q.Heading2,{size:14})},{label:e.heading3,value:"h3",icon:h.jsx(q.Heading3,{size:14})},{label:e.heading4,value:"h4",icon:h.jsx(q.Heading4,{size:14})},{label:e.heading5,value:"h5",icon:h.jsx(q.Heading5,{size:14})}],RC=e=>[{label:e.bulletList,value:"bullet",icon:h.jsx(q.List,{size:14})},{label:e.numberedList,value:"ordered",icon:h.jsx(q.ListOrdered,{size:14})},{label:e.slashTaskList,value:"task",icon:h.jsx(q.ListChecks,{size:14})}],si=[{labelKey:"highlightYellow",backgroundColor:"#fef08a",textColor:"#713f12"},{labelKey:"highlightAmber",backgroundColor:"#fde68a",textColor:"#78350f"},{labelKey:"highlightOrange",backgroundColor:"#fed7aa",textColor:"#7c2d12"},{labelKey:"highlightRed",backgroundColor:"#fecaca",textColor:"#7f1d1d"},{labelKey:"highlightPink",backgroundColor:"#fbcfe8",textColor:"#831843"},{labelKey:"highlightPurple",backgroundColor:"#ddd6fe",textColor:"#4c1d95"},{labelKey:"highlightBlue",backgroundColor:"#bfdbfe",textColor:"#1e3a8a"},{labelKey:"highlightCyan",backgroundColor:"#a5f3fc",textColor:"#164e63"},{labelKey:"highlightTeal",backgroundColor:"#99f6e4",textColor:"#134e4a"},{labelKey:"highlightGreen",backgroundColor:"#bbf7d0",textColor:"#14532d"},{labelKey:"highlightLime",backgroundColor:"#d9f99d",textColor:"#365314"},{labelKey:"highlightSlate",backgroundColor:"#334155",textColor:"#f8fafc"}],Do={px:{min:8,max:96,step:1,defaultValue:16},rem:{min:.5,max:6,step:.1,defaultValue:1}},Gn="16px",NC=e=>{if(!e)return null;const t=e.trim().match(/^(\d+(?:\.\d+)?)(px|rem)?$/i);if(!t)return null;const n=Number.parseFloat(t[1]);return Number.isFinite(n)?{value:n,unit:t[2]?.toLowerCase()??"px"}:null},ft=e=>{const t=NC(e);if(!t)return null;const n=Do[t.unit],r=Math.min(n.max,Math.max(n.min,t.value));return{value:t.unit==="px"?Math.round(r):Math.round(r*100)/100,unit:t.unit}},rs=e=>`${e.unit==="px"?`${Math.round(e.value)}`:`${Number(e.value.toFixed(2))}`}${e.unit}`,OC=e=>{if(typeof window>"u")return Gn;const{from:t}=e.state.selection,{node:n}=e.view.domAtPos(t),r=n instanceof HTMLElement?n:n.parentElement,o=r?.closest("span,p,h1,h2,h3,h4,h5,h6,li,blockquote,code,pre")??r;if(!o)return Gn;const s=window.getComputedStyle(o).fontSize,i=ft(s);return i?rs(i):Gn},zc=e=>{if(!e)return"";const t=e.getAttributes("textStyle").fontSize,n=ft(t);return n?rs(n):OC(e)},So=/[\p{L}\p{N}_'-]/u,dr=e=>{if(!e)return"";const t=e.trim().toLowerCase();if(/^#[0-9a-f]{6}$/.test(t))return t;if(/^#[0-9a-f]{3}$/.test(t))return`#${t.slice(1).split("").map(r=>r+r).join("")}`;const n=t.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*[\d.]+)?\)$/);return n?`#${n.slice(1,4).map(r=>Number(r).toString(16).padStart(2,"0")).join("")}`:t},IC=e=>{const{selection:t}=e.state;if(!t.empty)return null;const{$from:n}=t;if(!n.parent.isTextblock)return null;const r=n.parent.textBetween(0,n.parent.content.size,`
|
|
127
127
|
`,`
|
|
128
|
-
`);if(!r)return null;const o=n.parentOffset,s=o>0&&Co.test(r[o-1]??"")?o-1:o;if(!Co.test(r[s]??""))return null;let i=s,a=s+1;for(;i>0&&Co.test(r[i-1]??"");)i-=1;for(;a<r.length&&Co.test(r[a]??"");)a+=1;return{from:n.start()+i,to:n.start()+a}},Up=({editor:e,onUpload:t,disableVideoUpload:n,disableImageUpload:r,classNames:o,styles:s,onThemeChange:i,showThemeToggle:a=!0})=>{const l=K.useRef(null),c=We(),u=Vr(),d=o0(),f=s??d??[],{effectiveStyles:p,saveOverride:m,resetOverride:g}=TC(f),[b,x]=K.useState(!1),[S,k]=K.useState(""),[y,T]=K.useState(!1),[w,C]=K.useState(""),[A,I]=K.useState(""),[O,j]=K.useState(""),[D,F]=K.useState(!1),[,B]=K.useState(0),N=AC(u),$=EC(u);if(K.useEffect(()=>{if(!e)return;const L=e.view.dom,ne=E=>{const ee=(E.target instanceof Element?E.target:null)?.closest("a[href]"),fe=ee&&L.contains(ee);fe&&(E.preventDefault(),E.stopPropagation()),setTimeout(()=>{e.isDestroyed||(fe||e.isActive("link"))&&(k(e.getAttributes("link").href??ee?.getAttribute("href")??""),x(!0))},0)};return L.addEventListener("click",ne),()=>L.removeEventListener("click",ne)},[e]),K.useEffect(()=>{if(!e)return;const L=()=>{B(E=>E+1),C(Dc(e));const ne=e.getAttributes("textStyle").fontFamily??"";I(ne)};return L(),e.on("selectionUpdate",L),e.on("transaction",L),e.on("update",L),()=>{e.off("selectionUpdate",L),e.off("transaction",L),e.off("update",L)}},[e]),!e)return null;const V=L=>{L.preventDefault()},_=()=>{for(let L=1;L<=5;L++)if(e.isActive("heading",{level:L}))return`h${L}`;return null},R=()=>e.isActive("bulletList")?"bullet":e.isActive("orderedList")?"ordered":e.isActive("taskList")?"task":null,z=L=>{const ne=parseInt(L.replace("h",""));e.chain().focus().toggleHeading({level:ne}).run()},W=L=>{L==="bullet"&&e.chain().focus().toggleBulletList().run(),L==="ordered"&&e.chain().focus().toggleOrderedList().run(),L==="task"&&e.chain().focus().toggleTaskList().run()},re=()=>{S.trim()?J().setLink({href:S}).run():J().unsetLink().run(),x(!1),k("")},se=L=>{J().setColor(L.textColor).setHighlight({color:L.backgroundColor}).run(),T(!1)},le=()=>{const L=dr(e.getAttributes("highlight").color),ne=ri.some(U=>dr(U.backgroundColor)===L),E=J().unsetHighlight();ne&&E.unsetColor(),E.run(),T(!1)},te=(L=w)=>{const ne=ft(L);if(!ne)return;const E=ts(ne);J().setFontSize(E).run(),C(E)},G=L=>{const ne=e.getAttributes("textStyle").fontSize,E=ft(w)??ft(ne)??ft(Gn);if(!E)return;const U=ft(`${E.value+L*Lo[E.unit].step}${E.unit}`);if(!U)return;const ee=ts(U);J().setFontSize(ee).run(),C(ee)},H=()=>{J().unsetFontSize().run(),C("")},J=()=>{const L=e.chain().focus(),ne=NC(e);return ne?L.setTextSelection(ne):L},oe=L=>{let ne=e.chain().focus();if(L.id==="normal"){ne.clearNodes().unsetAllMarks().setParagraph().run();return}L.type==="heading"&&L.level?ne=ne.setHeading({level:L.level}):L.type==="blockquote"?ne=ne.setBlockquote():ne=ne.setParagraph();const E={};L.fontFamily&&(E.fontFamily=L.fontFamily),L.fontSize&&(E.fontSize=L.fontSize),L.fontWeight&&(E.fontWeight=L.fontWeight),L.fontStyle&&(E.fontStyle=L.fontStyle),L.letterSpacing&&(E.letterSpacing=L.letterSpacing),L.lineHeight&&(E.lineHeight=L.lineHeight),L.textTransform&&(E.textTransform=L.textTransform),Object.keys(E).length>0&&(ne=ne.setMark("textStyle",E)),L.color&&(ne=ne.setColor(L.color)),ne.run()},ge=()=>{if(!p.length)return null;const{$from:L}=e.state.selection,ne=L.parent;return p.find(E=>E.type==="heading"&&E.level?ne.type.name==="heading"&&ne.attrs.level===E.level:E.type==="blockquote"?e.isActive("blockquote"):ne.type.name==="paragraph")??null},Ce=L=>{L?J().setFontFamily(L).run():J().unsetFontFamily().run(),I(L),F(!1),j("")},ve=[{label:"Default",value:""},{label:"Inter",value:"Inter, sans-serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Times New Roman",value:"Times New Roman, Times, serif"},{label:"Courier New",value:"Courier New, Courier, monospace"},{label:"Trebuchet MS",value:"Trebuchet MS, sans-serif"},{label:"Arial",value:"Arial, Helvetica, sans-serif"},{label:"Verdana",value:"Verdana, Geneva, sans-serif"},{label:"Impact",value:"Impact, fantasy"}],we=O.trim()?ve.filter(L=>L.label.toLowerCase().includes(O.toLowerCase())):ve,Ee=e.getAttributes("textStyle").fontFamily??"",st=ve.find(L=>L.value===Ee)?.label??(Ee?Ee.split(",")[0].trim():""),Xe=async L=>{const ne=L.target.files?.[0];if(!(!ne||!t)){try{const{url:E}=await t(ne);ne.type.startsWith("video/")?e.chain().focus().setNode("video",{src:E}).run():e.chain().focus().setAdvancedImage({src:E}).run()}catch(E){console.error("Upload failed:",E)}l.current&&(l.current.value="")}},qe=()=>{i?.(c==="dark"?"light":"dark")},ye=({isActive:L,onClick:ne,tooltip:E,disabled:U=!1,children:ee})=>h.jsx(kt,{content:E,children:h.jsx("button",{type:"button",onMouseDown:V,onClick:ne,disabled:U,"aria-label":E,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors duration-150",c==="dark"?"text-neutral-400":"text-neutral-500",!U&&(c==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900"),L&&(c==="dark"?"bg-white/15 text-neutral-100":"bg-black/8 text-neutral-900"),L&&o?.toolbarButtonActive,U&&"opacity-30 cursor-not-allowed",U&&o?.toolbarButtonDisabled,o?.toolbarButton),children:h.jsx("span",{className:M("flex items-center justify-center",o?.toolbarButtonIcon),children:ee})})}),Re=()=>h.jsx("span",{className:M("shrink-0 w-[1px] h-4 mx-1",c==="dark"?"bg-white/10":"bg-black/8",o?.toolbarSeparator)}),Pe=_(),Te=Pe?N.find(L=>L.value===Pe)?.label??u.heading:u.heading,_e=R(),Dt=_e?$.find(L=>L.value===_e)?.label??u.list:u.list,Vt=(L,ne,E)=>h.jsxs("button",{type:"button",onMouseDown:V,className:M("flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-full px-2.5 text-sm font-medium transition-colors",c==="dark"?"text-neutral-300 hover:bg-white/10 hover:text-neutral-100":"text-neutral-600 hover:bg-black/6 hover:text-neutral-900",E&&(c==="dark"?"bg-white/15 text-neutral-100":"bg-black/8 text-neutral-900"),E&&o?.toolbarTriggerActive,o?.toolbarTrigger),children:[h.jsx("span",{className:M("flex items-center justify-center",o?.toolbarTriggerIcon),children:ne}),h.jsx("span",{className:M("hidden sm:inline max-w-[72px] truncate",o?.toolbarTriggerLabel),children:L}),h.jsx(q.ChevronDown,{size:12,className:M("opacity-50 shrink-0",o?.toolbarTriggerChevron)})]}),un=e.getAttributes("textStyle").fontSize,xe=ft(w)??ft(un)??ft(Gn),Je=xe?Lo[xe.unit]:Lo.px,qt=!!ft(un),eo=dr(e.getAttributes("highlight").color),to=ri.find(L=>dr(L.backgroundColor)===eo),dn=e.isActive("highlight");return h.jsx("div",{className:M("relative z-20 shrink-0 border-b backdrop-blur-md transition-all",c==="dark"?"bg-neutral-900/95 border-white/8 text-neutral-400":"bg-white/95 border-black/6 text-neutral-500",o?.toolbar),children:h.jsxs("div",{className:M("flex w-full items-center gap-2 overflow-x-auto px-3 py-2 [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",o?.toolbarInner),children:[h.jsx(Po,{trigger:h.jsxs("button",{type:"button",onMouseDown:V,"aria-label":u.fontFamily,className:M("flex h-8 min-w-[100px] max-w-[140px] shrink-0 cursor-pointer items-center justify-between gap-1.5 rounded-full px-3 text-sm font-medium transition-colors",c==="dark"?"bg-white/[0.06] text-neutral-200 hover:bg-white/10":"bg-neutral-100 text-neutral-700 hover:bg-neutral-200",Ee&&(c==="dark"?"ring-1 ring-white/20":"ring-1 ring-black/10"),o?.toolbarFontFamilyTrigger),children:[h.jsx("span",{className:"truncate",style:{fontFamily:Ee||"inherit"},children:st||u.fontFamily}),h.jsx(q.ChevronDown,{size:12,className:"shrink-0 opacity-50"})]}),open:D,onOpenChange:L=>{F(L),L||j("")},align:"start",children:h.jsxs("div",{className:M("flex flex-col w-52",o?.toolbarFontFamilyPopover),children:[h.jsx("div",{className:"mb-1.5",children:h.jsx("input",{type:"text",placeholder:"Search fonts...",value:O,onChange:L=>j(L.target.value),autoFocus:!0,className:M("w-full rounded-full border px-3 py-1.5 text-sm outline-none transition-colors",c==="dark"?"bg-neutral-800 border-neutral-700 text-neutral-100 placeholder:text-neutral-500 focus:border-neutral-500":"bg-neutral-50 border-neutral-200 text-neutral-900 placeholder:text-neutral-400 focus:border-neutral-400",o?.toolbarFontFamilySearch)})}),h.jsxs("div",{className:M("flex flex-col gap-0.5 max-h-96 overflow-y-auto",o?.toolbarFontFamilyList),children:[we.map(L=>{const ne=(A||"")===L.value;return h.jsxs("button",{type:"button",onMouseDown:V,onClick:()=>Ce(L.value),className:M("flex w-full cursor-pointer items-center gap-2 rounded-full px-3 py-2 text-sm text-left transition-colors",c==="dark"?ne?"bg-white/15 text-neutral-100":"text-neutral-300 hover:bg-white/8 hover:text-neutral-100":ne?"bg-black/8 text-neutral-900":"text-neutral-700 hover:bg-neutral-100 hover:text-neutral-900",o?.toolbarFontFamilyItem,ne&&o?.toolbarFontFamilyItemActive),children:[h.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-[10px]",style:{opacity:ne?1:0},children:"✓"}),h.jsx("span",{style:{fontFamily:L.value||"inherit"},children:L.label})]},L.value||"__default__")}),we.length===0&&h.jsx("p",{className:M("px-3 py-2 text-sm",c==="dark"?"text-neutral-500":"text-neutral-400"),children:u.noResults})]})]})}),h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx(ye,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().undo(),tooltip:u.undo,children:h.jsx(q.Undo2,{size:16})}),h.jsx(ye,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().redo(),tooltip:u.redo,children:h.jsx(q.Redo2,{size:16})})]}),h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx(Pc,{trigger:Vt(Te,h.jsx(q.Type,{size:14}),!!Pe),items:N,value:_()??void 0,onSelect:z}),h.jsx(Pc,{trigger:Vt(Dt,h.jsx(q.List,{size:14}),!!_e),items:$,value:R()??void 0,onSelect:W}),h.jsx(ye,{isActive:e.isActive("blockquote"),onClick:()=>e.chain().focus().toggleBlockquote().run(),tooltip:u.quote,children:h.jsx(q.Quote,{size:16})}),h.jsx(ye,{isActive:e.isActive("codeBlock"),onClick:()=>e.chain().focus().toggleCodeBlock().run(),tooltip:u.codeBlock,children:h.jsx(q.Code2,{size:16})})]}),h.jsx(Re,{}),h.jsx("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:h.jsxs("div",{className:M("flex h-8 shrink-0 items-stretch overflow-hidden rounded-full text-sm font-medium transition-colors",c==="dark"?" text-neutral-200":" text-neutral-700",qt&&o?.toolbarFontSizeControlActive,o?.toolbarFontSizeControl),children:[h.jsx(kt,{content:u.decreaseFontSize,children:h.jsx("button",{type:"button",onMouseDown:V,onClick:()=>G(-1),disabled:!xe||xe.value<=Je.min,"aria-label":u.decreaseFontSize,className:M("flex w-8 shrink-0 cursor-pointer items-center justify-center rounded-full border transition-colors",c==="dark"?"border-white/5 text-neutral-400":"border-black/4 text-neutral-500",xe&&xe.value>Je.min&&(c==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900"),(!xe||xe.value<=Je.min)&&"cursor-not-allowed opacity-30",(!xe||xe.value<=Je.min)&&o?.toolbarButtonDisabled,o?.toolbarFontSizeStepButton),children:h.jsx(q.Minus,{size:14})})}),h.jsxs("label",{className:"flex items-center",children:[h.jsx("span",{className:"sr-only",children:u.fontSize}),h.jsx("input",{type:"text",inputMode:"decimal","aria-label":u.fontSize,value:w,placeholder:Gn,onChange:L=>C(L.target.value),onBlur:()=>{w.trim()?te():qt&&H()},onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),w.trim()?te():qt&&H()),L.key==="Escape"&&C(Dc(e))},className:M("h-full w-15 bg-transparent px-2 text-center outline-none",c==="dark"?"placeholder:text-neutral-500":"placeholder:text-neutral-400",o?.toolbarFontSizeInput)})]}),h.jsx(kt,{content:u.increaseFontSize,children:h.jsx("button",{type:"button",onMouseDown:V,onClick:()=>G(1),disabled:!xe||xe.value>=Je.max,"aria-label":u.increaseFontSize,className:M("flex w-8 shrink-0 cursor-pointer items-center justify-center rounded-full border transition-colors",c==="dark"?"border-white/5 text-neutral-400":"border-black/4 text-neutral-500",xe&&xe.value<Je.max&&(c==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900"),(!xe||xe.value>=Je.max)&&"cursor-not-allowed opacity-30",(!xe||xe.value>=Je.max)&&o?.toolbarButtonDisabled,o?.toolbarFontSizeStepButton),children:h.jsx(q.Plus,{size:14})})})]})}),h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx(ye,{isActive:e.isActive("bold"),onClick:()=>J().toggleBold().run(),tooltip:u.bold,children:h.jsx(q.Bold,{size:16})}),h.jsx(ye,{isActive:e.isActive("italic"),onClick:()=>J().toggleItalic().run(),tooltip:u.italic,children:h.jsx(q.Italic,{size:16})}),h.jsx(ye,{isActive:e.isActive("strike"),onClick:()=>J().toggleStrike().run(),tooltip:u.strikethrough,children:h.jsx(q.Strikethrough,{size:16})}),h.jsx(ye,{isActive:e.isActive("code"),onClick:()=>J().toggleCode().run(),tooltip:u.inlineCode,children:h.jsx(q.Code,{size:16})}),h.jsx(ye,{isActive:e.isActive("underline"),onClick:()=>J().toggleUnderline().run(),tooltip:u.underline,children:h.jsx(q.Underline,{size:16})}),h.jsx(Po,{trigger:h.jsxs("button",{type:"button",onMouseDown:V,"aria-label":u.highlight,className:M("relative flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors duration-150",c==="dark"?"text-neutral-400":"text-neutral-500",c==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900",dn&&(c==="dark"?"bg-white/15 text-neutral-100":"bg-black/8 text-neutral-900"),dn&&o?.toolbarButtonActive,o?.toolbarButton,o?.toolbarHighlightButton),children:[h.jsx("span",{className:M("flex items-center justify-center",o?.toolbarButtonIcon),children:h.jsx(q.Highlighter,{size:16})}),h.jsx("span",{className:M("absolute bottom-1 h-0.5 w-4 rounded-full",dn?"opacity-100":c==="dark"?"bg-neutral-600 opacity-70":"bg-neutral-300 opacity-80",o?.toolbarHighlightIndicator),style:to?{backgroundColor:to.backgroundColor}:void 0})]}),open:y,onOpenChange:T,align:"start",children:h.jsxs("div",{className:M("flex w-48 flex-col gap-2",o?.toolbarHighlightPopoverBody),children:[h.jsx("p",{className:M("text-xs font-semibold",c==="dark"?"text-neutral-400":"text-neutral-500",o?.toolbarHighlightPopoverLabel),children:u.highlightPalette}),h.jsx("div",{className:M("grid grid-cols-4 gap-1.5",o?.toolbarHighlightGrid),children:ri.map(L=>{const ne=dr(L.backgroundColor)===eo;return h.jsx(kt,{content:u[L.labelKey],children:h.jsx("button",{type:"button",onMouseDown:V,onClick:()=>se(L),"aria-label":`${u.highlight}: ${u[L.labelKey]}`,className:M("flex h-9 w-9 cursor-pointer items-center justify-center rounded-full border text-sm font-bold transition-transform duration-150","hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500",c==="dark"?"border-white/15":"border-black/10",ne&&(c==="dark"?"ring-2 ring-white/70":"ring-2 ring-neutral-900/70"),ne&&o?.toolbarHighlightSwatchActive,o?.toolbarHighlightSwatch),style:{backgroundColor:L.backgroundColor,color:L.textColor},children:"A"})},L.backgroundColor)})}),h.jsx("button",{type:"button",onMouseDown:V,onClick:le,disabled:!dn,className:M("h-8 rounded-full px-3 text-xs font-medium transition-colors",c==="dark"?"text-neutral-300 hover:bg-white/10 disabled:text-neutral-600":"text-neutral-600 hover:bg-black/6 disabled:text-neutral-300",!dn&&"cursor-not-allowed",o?.toolbarHighlightClearButton),children:u.clearHighlight})]})}),h.jsx(Po,{trigger:h.jsx("button",{type:"button",onMouseDown:V,"aria-label":u.link,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors duration-150",c==="dark"?"text-neutral-400":"text-neutral-500",c==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900",e.isActive("link")&&(c==="dark"?"bg-white/15 text-neutral-100":"bg-black/8 text-neutral-900"),e.isActive("link")&&o?.toolbarButtonActive,o?.toolbarButton,o?.toolbarLinkButton),children:h.jsx("span",{className:M("flex items-center justify-center",o?.toolbarButtonIcon),children:h.jsx(q.Link,{size:16})})}),open:b,onOpenChange:L=>{x(L),L&&k(e.getAttributes("link").href??"")},align:"start",children:h.jsxs("div",{className:M("flex flex-col gap-2 w-64",o?.toolbarLinkPopoverBody),children:[h.jsx("p",{className:M("text-xs font-semibold",c==="dark"?"text-neutral-400":"text-neutral-500",o?.toolbarLinkPopoverLabel),children:u.insertLink}),h.jsx("input",{type:"url",placeholder:u.linkPlaceholder,value:S,onChange:L=>k(L.target.value),onKeyDown:L=>L.key==="Enter"&&re(),autoFocus:!0,className:M("w-full px-3 py-2 text-sm rounded-xl border outline-none transition-colors",c==="dark"?"bg-neutral-800 border-neutral-700 text-neutral-100 placeholder:text-neutral-500 focus:border-neutral-500":"bg-neutral-50 border-neutral-200 text-neutral-900 placeholder:text-neutral-400 focus:border-neutral-400",o?.toolbarLinkInput)}),h.jsxs("div",{className:M("flex gap-2",o?.toolbarLinkActions),children:[h.jsx("button",{type:"button",onMouseDown:V,onClick:re,className:M("flex-1 py-1.5 text-sm font-medium rounded-full transition-colors",c==="dark"?"bg-neutral-700 hover:bg-neutral-600 text-neutral-100":"bg-neutral-900 hover:bg-neutral-700 text-white",o?.toolbarLinkApplyButton),children:u.apply}),e.isActive("link")&&h.jsx("button",{type:"button",onMouseDown:V,onClick:()=>{e.chain().focus().unsetLink().run(),x(!1)},className:M("px-3 py-1.5 text-sm rounded-full transition-colors",c==="dark"?"text-neutral-400 hover:bg-white/10":"text-neutral-500 hover:bg-black/6",o?.toolbarLinkUnlinkButton),children:h.jsx(q.Unlink,{size:14})})]})]})})]}),h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx(ye,{isActive:e.isActive("superscript"),onClick:()=>J().toggleSuperscript().run(),tooltip:u.superscript,children:h.jsx(q.Superscript,{size:16})}),h.jsx(ye,{isActive:e.isActive("subscript"),onClick:()=>J().toggleSubscript().run(),tooltip:u.subscript,children:h.jsx(q.Subscript,{size:16})})]}),h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx(ye,{isActive:e.isActive({textAlign:"left"}),onClick:()=>e.chain().focus().setTextAlign("left").run(),tooltip:u.alignLeft,children:h.jsx(q.AlignLeft,{size:16})}),h.jsx(ye,{isActive:e.isActive({textAlign:"center"}),onClick:()=>e.chain().focus().setTextAlign("center").run(),tooltip:u.alignCenter,children:h.jsx(q.AlignCenter,{size:16})}),h.jsx(ye,{isActive:e.isActive({textAlign:"right"}),onClick:()=>e.chain().focus().setTextAlign("right").run(),tooltip:u.alignRight,children:h.jsx(q.AlignRight,{size:16})}),h.jsx(ye,{isActive:e.isActive({textAlign:"justify"}),onClick:()=>e.chain().focus().setTextAlign("justify").run(),tooltip:u.alignJustify,children:h.jsx(q.AlignJustify,{size:16})})]}),(!r||!n)&&t&&h.jsxs(h.Fragment,{children:[h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx("input",{type:"file",ref:l,className:M("hidden",o?.toolbarFileInput),accept:!r&&!n?"image/*,video/*":r?"video/*":"image/*",onChange:Xe}),h.jsx(kt,{content:u.uploadMedia,children:h.jsxs("button",{type:"button",onMouseDown:V,onClick:()=>l.current?.click(),className:M("flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-full px-3 text-sm font-medium transition-colors",c==="dark"?"text-neutral-300 hover:bg-white/10 hover:text-neutral-100":"text-neutral-600 hover:bg-black/6 hover:text-neutral-900",o?.toolbarUploadButton),children:[h.jsx(q.Upload,{size:14,className:o?.toolbarUploadIcon}),h.jsx("span",{className:M("hidden sm:inline",o?.toolbarUploadLabel),children:u.upload})]})})]})]}),h.jsx(Re,{}),h.jsx(CC,{styles:p,baseStyles:f,editor:e,theme:c,classNames:o,activeStyle:ge(),onApply:oe,onSave:m,onReset:g,keepEditorSelection:V}),h.jsx("div",{className:"ml-auto shrink-0"}),a&&h.jsx("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-100",o?.toolbarGroup),children:h.jsx(kt,{content:c==="dark"?u.lightTheme:u.darkTheme,children:h.jsx("button",{type:"button",onMouseDown:V,onClick:qe,"aria-label":u.toggleTheme,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors duration-150",c==="dark"?"text-neutral-300 hover:bg-white/10 hover:text-neutral-100":"text-neutral-600 hover:bg-black/6 hover:text-neutral-900",o?.toolbarButton),children:c==="dark"?h.jsx(q.Sun,{size:16}):h.jsx(q.Moon,{size:16})})})})]})})};function OC(e){var t;const{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:a}=e,l=r&&!o,c=P.escapeForRegEx(n),u=new RegExp(`\\s${c}$`),d=i?"^":"",f=o?"":c,p=l?new RegExp(`${d}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${f}]*`,"gm"),m=((t=a.nodeBefore)==null?void 0:t.isText)&&a.nodeBefore.text;if(!m)return null;const g=a.pos-m.length,b=Array.from(m.matchAll(p)).pop();if(!b||b.input===void 0||b.index===void 0)return null;const x=b.input.slice(Math.max(0,b.index-1),b.index),S=new RegExp(`^[${s?.join("")}\0]?$`).test(x);if(s!==null&&!S)return null;const k=g+b.index;let y=k+b[0].length;return l&&u.test(m.slice(y-1,y+1))&&(b[0]+=" ",y+=1),k<a.pos&&y>=a.pos?{range:{from:k,to:y},query:b[0].slice(n.length),text:b[0]}:null}function IC(e){return e.docChanged?e.steps.some(t=>{const n=t.slice;if(!n?.content)return!1;const r=n.content.textBetween(0,n.content.size,`
|
|
129
|
-
`);return/\s/.test(r)}):!1}var PC=new cs("suggestion");function LC({pluginKey:e=PC,editor:t,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:s=[" "],startOfLine:i=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:g=OC,shouldShow:b,shouldResetDismissed:x}){let S;const k=p?.(),y=r&&!o,T=()=>{const O=t.state.selection.$anchor.pos,j=t.view.coordsAtPos(O),{top:D,right:F,bottom:B,left:N}=j;try{return new DOMRect(N,D,F-N,B-D)}catch{return null}},w=(O,j)=>j?()=>{const D=e.getState(t.state),F=D?.decorationId,B=O.dom.querySelector(`[data-decoration-id="${F}"]`);return B?.getBoundingClientRect()||null}:T,C=({match:O,dismissedRange:j,state:D,transaction:F})=>x?.({editor:t,state:D,range:j,match:O,transaction:F,allowSpaces:y})?!1:y?O.range.from===j.from:O.range.from===j.from&&!IC(F);function A(O,j){var D;try{const B=e.getState(O.state),N=B?.decorationId?O.dom.querySelector(`[data-decoration-id="${B.decorationId}"]`):null,$={editor:t,range:B?.range||{from:0,to:0},query:B?.query||null,text:B?.text||null,items:[],command:V=>d({editor:t,range:B?.range||{from:0,to:0},props:V}),decorationNode:N,clientRect:w(O,N)};(D=k?.onExit)==null||D.call(k,$)}catch{}const F=O.state.tr.setMeta(j,{exit:!0});O.dispatch(F)}const I=new fa({key:e,view(){return{update:async(O,j)=>{var D,F,B,N,$,V,_;const R=(D=this.key)==null?void 0:D.getState(j),z=(F=this.key)==null?void 0:F.getState(O.state),W=R.active&&z.active&&R.range.from!==z.range.from,re=!R.active&&z.active,se=R.active&&!z.active,le=!re&&!se&&R.query!==z.query,te=re||W&&le,G=le||W,H=se||W&≤if(!te&&!G&&!H)return;const J=H&&!te?R:z,oe=O.dom.querySelector(`[data-decoration-id="${J.decorationId}"]`);S={editor:t,range:J.range,query:J.query,text:J.text,items:[],command:ge=>d({editor:t,range:J.range,props:ge}),decorationNode:oe,clientRect:w(O,oe)},te&&((B=k?.onBeforeStart)==null||B.call(k,S)),G&&((N=k?.onBeforeUpdate)==null||N.call(k,S)),(G||te)&&(S.items=await f({editor:t,query:J.query})),H&&(($=k?.onExit)==null||$.call(k,S)),G&&((V=k?.onUpdate)==null||V.call(k,S)),te&&((_=k?.onStart)==null||_.call(k,S))},destroy:()=>{var O;S&&((O=k?.onExit)==null||O.call(k,S))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(O,j,D,F){const{isEditable:B}=t,{composing:N}=t.view,{selection:$}=O,{empty:V,from:_}=$,R={...j},z=O.getMeta(e);if(z&&z.exit)return R.active=!1,R.decorationId=null,R.range={from:0,to:0},R.query=null,R.text=null,R.dismissedRange=j.active?{...j.range}:j.dismissedRange,R;if(R.composing=N,O.docChanged&&R.dismissedRange!==null&&(R.dismissedRange={from:O.mapping.map(R.dismissedRange.from),to:O.mapping.map(R.dismissedRange.to)}),B&&(V||t.view.composing)){(_<j.range.from||_>j.range.to)&&!N&&!j.composing&&(R.active=!1);const W=g({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:$.$from}),re=`id_${Math.floor(Math.random()*4294967295)}`;W&&m({editor:t,state:F,range:W.range,isActive:j.active})&&(!b||b({editor:t,range:W.range,query:W.query,text:W.text,transaction:O}))?(R.dismissedRange!==null&&!C({match:W,dismissedRange:R.dismissedRange,state:F,transaction:O})&&(R.dismissedRange=null),R.dismissedRange===null?(R.active=!0,R.decorationId=j.decorationId?j.decorationId:re,R.range=W.range,R.query=W.query,R.text=W.text):R.active=!1):(W||(R.dismissedRange=null),R.active=!1)}else R.active=!1;return R.active||(R.decorationId=null,R.range={from:0,to:0},R.query=null,R.text=null),R}},props:{handleKeyDown(O,j){var D,F;const{active:B,range:N}=I.getState(O.state);if(!B)return!1;if(j.key==="Escape"||j.key==="Esc"){const V=I.getState(O.state);return(D=k?.onKeyDown)==null||D.call(k,{view:O,event:j,range:V.range}),A(O,e),!0}return((F=k?.onKeyDown)==null?void 0:F.call(k,{view:O,event:j,range:N}))||!1},decorations(O){const{active:j,range:D,decorationId:F,query:B}=I.getState(O);if(!j)return null;const N=!B?.length,$=[l];return N&&$.push(u),Se.create(O.doc,[tt.inline(D.from,D.to,{nodeName:a,class:$.join(" "),"data-decoration-id":F,"data-decoration-content":c})])}}});return I}var DC=LC,Ue="top",ut="bottom",dt="right",Ge="left",Ga="auto",Yr=[Ue,ut,dt,Ge],er="start",Dr="end",jC="clippingParents",Gp="viewport",fr="popper",zC="reference",jc=Yr.reduce(function(e,t){return e.concat([t+"-"+er,t+"-"+Dr])},[]),Xp=[].concat(Yr,[Ga]).reduce(function(e,t){return e.concat([t,t+"-"+er,t+"-"+Dr])},[]),_C="beforeRead",$C="read",FC="afterRead",BC="beforeMain",HC="main",WC="afterMain",VC="beforeWrite",qC="write",KC="afterWrite",UC=[_C,$C,FC,BC,HC,WC,VC,qC,KC];function It(e){return e?(e.nodeName||"").toLowerCase():null}function ot(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function An(e){var t=ot(e).Element;return e instanceof t||e instanceof Element}function ct(e){var t=ot(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function Xa(e){if(typeof ShadowRoot>"u")return!1;var t=ot(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function GC(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var r=t.styles[n]||{},o=t.attributes[n]||{},s=t.elements[n];!ct(s)||!It(s)||(Object.assign(s.style,r),Object.keys(o).forEach(function(i){var a=o[i];a===!1?s.removeAttribute(i):s.setAttribute(i,a===!0?"":a)}))})}function XC(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(r){var o=t.elements[r],s=t.attributes[r]||{},i=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:n[r]),a=i.reduce(function(l,c){return l[c]="",l},{});!ct(o)||!It(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const Jp={name:"applyStyles",enabled:!0,phase:"write",fn:GC,effect:XC,requires:["computeStyles"]};function Rt(e){return e.split("-")[0]}var vn=Math.max,ns=Math.min,tr=Math.round;function qi(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function Yp(){return!/^((?!chrome|android).)*safari/i.test(qi())}function nr(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),o=1,s=1;t&&ct(e)&&(o=e.offsetWidth>0&&tr(r.width)/e.offsetWidth||1,s=e.offsetHeight>0&&tr(r.height)/e.offsetHeight||1);var i=An(e)?ot(e):window,a=i.visualViewport,l=!Yp()&&n,c=(r.left+(l&&a?a.offsetLeft:0))/o,u=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/o,f=r.height/s;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c,x:c,y:u}}function Ja(e){var t=nr(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function Qp(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Xa(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Bt(e){return ot(e).getComputedStyle(e)}function JC(e){return["table","td","th"].indexOf(It(e))>=0}function cn(e){return((An(e)?e.ownerDocument:e.document)||window.document).documentElement}function Ss(e){return It(e)==="html"?e:e.assignedSlot||e.parentNode||(Xa(e)?e.host:null)||cn(e)}function zc(e){return!ct(e)||Bt(e).position==="fixed"?null:e.offsetParent}function YC(e){var t=/firefox/i.test(qi()),n=/Trident/i.test(qi());if(n&&ct(e)){var r=Bt(e);if(r.position==="fixed")return null}var o=Ss(e);for(Xa(o)&&(o=o.host);ct(o)&&["html","body"].indexOf(It(o))<0;){var s=Bt(o);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||t&&s.willChange==="filter"||t&&s.filter&&s.filter!=="none")return o;o=o.parentNode}return null}function Qr(e){for(var t=ot(e),n=zc(e);n&&JC(n)&&Bt(n).position==="static";)n=zc(n);return n&&(It(n)==="html"||It(n)==="body"&&Bt(n).position==="static")?t:n||YC(e)||t}function Ya(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function kr(e,t,n){return vn(e,ns(t,n))}function QC(e,t,n){var r=kr(e,t,n);return r>n?n:r}function Zp(){return{top:0,right:0,bottom:0,left:0}}function eh(e){return Object.assign({},Zp(),e)}function th(e,t){return t.reduce(function(n,r){return n[r]=e,n},{})}var ZC=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,eh(typeof t!="number"?t:th(t,Yr))};function eS(e){var t,n=e.state,r=e.name,o=e.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=Rt(n.placement),l=Ya(a),c=[Ge,dt].indexOf(a)>=0,u=c?"height":"width";if(!(!s||!i)){var d=ZC(o.padding,n),f=Ja(s),p=l==="y"?Ue:Ge,m=l==="y"?ut:dt,g=n.rects.reference[u]+n.rects.reference[l]-i[l]-n.rects.popper[u],b=i[l]-n.rects.reference[l],x=Qr(s),S=x?l==="y"?x.clientHeight||0:x.clientWidth||0:0,k=g/2-b/2,y=d[p],T=S-f[u]-d[m],w=S/2-f[u]/2+k,C=kr(y,w,T),A=l;n.modifiersData[r]=(t={},t[A]=C,t.centerOffset=C-w,t)}}function tS(e){var t=e.state,n=e.options,r=n.element,o=r===void 0?"[data-popper-arrow]":r;o!=null&&(typeof o=="string"&&(o=t.elements.popper.querySelector(o),!o)||Qp(t.elements.popper,o)&&(t.elements.arrow=o))}const nS={name:"arrow",enabled:!0,phase:"main",fn:eS,effect:tS,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function rr(e){return e.split("-")[1]}var rS={top:"auto",right:"auto",bottom:"auto",left:"auto"};function oS(e,t){var n=e.x,r=e.y,o=t.devicePixelRatio||1;return{x:tr(n*o)/o||0,y:tr(r*o)/o||0}}function _c(e){var t,n=e.popper,r=e.popperRect,o=e.placement,s=e.variation,i=e.offsets,a=e.position,l=e.gpuAcceleration,c=e.adaptive,u=e.roundOffsets,d=e.isFixed,f=i.x,p=f===void 0?0:f,m=i.y,g=m===void 0?0:m,b=typeof u=="function"?u({x:p,y:g}):{x:p,y:g};p=b.x,g=b.y;var x=i.hasOwnProperty("x"),S=i.hasOwnProperty("y"),k=Ge,y=Ue,T=window;if(c){var w=Qr(n),C="clientHeight",A="clientWidth";if(w===ot(n)&&(w=cn(n),Bt(w).position!=="static"&&a==="absolute"&&(C="scrollHeight",A="scrollWidth")),w=w,o===Ue||(o===Ge||o===dt)&&s===Dr){y=ut;var I=d&&w===T&&T.visualViewport?T.visualViewport.height:w[C];g-=I-r.height,g*=l?1:-1}if(o===Ge||(o===Ue||o===ut)&&s===Dr){k=dt;var O=d&&w===T&&T.visualViewport?T.visualViewport.width:w[A];p-=O-r.width,p*=l?1:-1}}var j=Object.assign({position:a},c&&rS),D=u===!0?oS({x:p,y:g},ot(n)):{x:p,y:g};if(p=D.x,g=D.y,l){var F;return Object.assign({},j,(F={},F[y]=S?"0":"",F[k]=x?"0":"",F.transform=(T.devicePixelRatio||1)<=1?"translate("+p+"px, "+g+"px)":"translate3d("+p+"px, "+g+"px, 0)",F))}return Object.assign({},j,(t={},t[y]=S?g+"px":"",t[k]=x?p+"px":"",t.transform="",t))}function sS(e){var t=e.state,n=e.options,r=n.gpuAcceleration,o=r===void 0?!0:r,s=n.adaptive,i=s===void 0?!0:s,a=n.roundOffsets,l=a===void 0?!0:a,c={placement:Rt(t.placement),variation:rr(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:o,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,_c(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:i,roundOffsets:l})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,_c(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const iS={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:sS,data:{}};var So={passive:!0};function aS(e){var t=e.state,n=e.instance,r=e.options,o=r.scroll,s=o===void 0?!0:o,i=r.resize,a=i===void 0?!0:i,l=ot(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return s&&c.forEach(function(u){u.addEventListener("scroll",n.update,So)}),a&&l.addEventListener("resize",n.update,So),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",n.update,So)}),a&&l.removeEventListener("resize",n.update,So)}}const lS={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:aS,data:{}};var cS={left:"right",right:"left",bottom:"top",top:"bottom"};function Do(e){return e.replace(/left|right|bottom|top/g,function(t){return cS[t]})}var uS={start:"end",end:"start"};function $c(e){return e.replace(/start|end/g,function(t){return uS[t]})}function Qa(e){var t=ot(e),n=t.pageXOffset,r=t.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Za(e){return nr(cn(e)).left+Qa(e).scrollLeft}function dS(e,t){var n=ot(e),r=cn(e),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var c=Yp();(c||!c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+Za(e),y:l}}function fS(e){var t,n=cn(e),r=Qa(e),o=(t=e.ownerDocument)==null?void 0:t.body,s=vn(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=vn(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+Za(e),l=-r.scrollTop;return Bt(o||n).direction==="rtl"&&(a+=vn(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function el(e){var t=Bt(e),n=t.overflow,r=t.overflowX,o=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function nh(e){return["html","body","#document"].indexOf(It(e))>=0?e.ownerDocument.body:ct(e)&&el(e)?e:nh(Ss(e))}function Cr(e,t){var n;t===void 0&&(t=[]);var r=nh(e),o=r===((n=e.ownerDocument)==null?void 0:n.body),s=ot(r),i=o?[s].concat(s.visualViewport||[],el(r)?r:[]):r,a=t.concat(i);return o?a:a.concat(Cr(Ss(i)))}function Ki(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function pS(e,t){var n=nr(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function Fc(e,t,n){return t===Gp?Ki(dS(e,n)):An(t)?pS(t,n):Ki(fS(cn(e)))}function hS(e){var t=Cr(Ss(e)),n=["absolute","fixed"].indexOf(Bt(e).position)>=0,r=n&&ct(e)?Qr(e):e;return An(r)?t.filter(function(o){return An(o)&&Qp(o,r)&&It(o)!=="body"}):[]}function mS(e,t,n,r){var o=t==="clippingParents"?hS(e):[].concat(t),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,c){var u=Fc(e,c,r);return l.top=vn(u.top,l.top),l.right=ns(u.right,l.right),l.bottom=ns(u.bottom,l.bottom),l.left=vn(u.left,l.left),l},Fc(e,i,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function rh(e){var t=e.reference,n=e.element,r=e.placement,o=r?Rt(r):null,s=r?rr(r):null,i=t.x+t.width/2-n.width/2,a=t.y+t.height/2-n.height/2,l;switch(o){case Ue:l={x:i,y:t.y-n.height};break;case ut:l={x:i,y:t.y+t.height};break;case dt:l={x:t.x+t.width,y:a};break;case Ge:l={x:t.x-n.width,y:a};break;default:l={x:t.x,y:t.y}}var c=o?Ya(o):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case er:l[c]=l[c]-(t[u]/2-n[u]/2);break;case Dr:l[c]=l[c]+(t[u]/2-n[u]/2);break}}return l}function jr(e,t){t===void 0&&(t={});var n=t,r=n.placement,o=r===void 0?e.placement:r,s=n.strategy,i=s===void 0?e.strategy:s,a=n.boundary,l=a===void 0?jC:a,c=n.rootBoundary,u=c===void 0?Gp:c,d=n.elementContext,f=d===void 0?fr:d,p=n.altBoundary,m=p===void 0?!1:p,g=n.padding,b=g===void 0?0:g,x=eh(typeof b!="number"?b:th(b,Yr)),S=f===fr?zC:fr,k=e.rects.popper,y=e.elements[m?S:f],T=mS(An(y)?y:y.contextElement||cn(e.elements.popper),l,u,i),w=nr(e.elements.reference),C=rh({reference:w,element:k,placement:o}),A=Ki(Object.assign({},k,C)),I=f===fr?A:w,O={top:T.top-I.top+x.top,bottom:I.bottom-T.bottom+x.bottom,left:T.left-I.left+x.left,right:I.right-T.right+x.right},j=e.modifiersData.offset;if(f===fr&&j){var D=j[o];Object.keys(O).forEach(function(F){var B=[dt,ut].indexOf(F)>=0?1:-1,N=[Ue,ut].indexOf(F)>=0?"y":"x";O[F]+=D[N]*B})}return O}function gS(e,t){t===void 0&&(t={});var n=t,r=n.placement,o=n.boundary,s=n.rootBoundary,i=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=l===void 0?Xp:l,u=rr(r),d=u?a?jc:jc.filter(function(m){return rr(m)===u}):Yr,f=d.filter(function(m){return c.indexOf(m)>=0});f.length===0&&(f=d);var p=f.reduce(function(m,g){return m[g]=jr(e,{placement:g,boundary:o,rootBoundary:s,padding:i})[Rt(g)],m},{});return Object.keys(p).sort(function(m,g){return p[m]-p[g]})}function bS(e){if(Rt(e)===Ga)return[];var t=Do(e);return[$c(e),t,$c(t)]}function yS(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!0:i,l=n.fallbackPlacements,c=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,m=p===void 0?!0:p,g=n.allowedAutoPlacements,b=t.options.placement,x=Rt(b),S=x===b,k=l||(S||!m?[Do(b)]:bS(b)),y=[b].concat(k).reduce(function(le,te){return le.concat(Rt(te)===Ga?gS(t,{placement:te,boundary:u,rootBoundary:d,padding:c,flipVariations:m,allowedAutoPlacements:g}):te)},[]),T=t.rects.reference,w=t.rects.popper,C=new Map,A=!0,I=y[0],O=0;O<y.length;O++){var j=y[O],D=Rt(j),F=rr(j)===er,B=[Ue,ut].indexOf(D)>=0,N=B?"width":"height",$=jr(t,{placement:j,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),V=B?F?dt:Ge:F?ut:Ue;T[N]>w[N]&&(V=Do(V));var _=Do(V),R=[];if(s&&R.push($[D]<=0),a&&R.push($[V]<=0,$[_]<=0),R.every(function(le){return le})){I=j,A=!1;break}C.set(j,R)}if(A)for(var z=m?3:1,W=function(te){var G=y.find(function(H){var J=C.get(H);if(J)return J.slice(0,te).every(function(oe){return oe})});if(G)return I=G,"break"},re=z;re>0;re--){var se=W(re);if(se==="break")break}t.placement!==I&&(t.modifiersData[r]._skip=!0,t.placement=I,t.reset=!0)}}const xS={name:"flip",enabled:!0,phase:"main",fn:yS,requiresIfExists:["offset"],data:{_skip:!1}};function Bc(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Hc(e){return[Ue,dt,ut,Ge].some(function(t){return e[t]>=0})}function vS(e){var t=e.state,n=e.name,r=t.rects.reference,o=t.rects.popper,s=t.modifiersData.preventOverflow,i=jr(t,{elementContext:"reference"}),a=jr(t,{altBoundary:!0}),l=Bc(i,r),c=Bc(a,o,s),u=Hc(l),d=Hc(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const wS={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:vS};function kS(e,t,n){var r=Rt(e),o=[Ge,Ue].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,i=s[0],a=s[1];return i=i||0,a=(a||0)*o,[Ge,dt].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function CS(e){var t=e.state,n=e.options,r=e.name,o=n.offset,s=o===void 0?[0,0]:o,i=Xp.reduce(function(u,d){return u[d]=kS(d,t.rects,s),u},{}),a=i[t.placement],l=a.x,c=a.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=i}const SS={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:CS};function TS(e){var t=e.state,n=e.name;t.modifiersData[n]=rh({reference:t.rects.reference,element:t.rects.popper,placement:t.placement})}const AS={name:"popperOffsets",enabled:!0,phase:"read",fn:TS,data:{}};function ES(e){return e==="x"?"y":"x"}function MS(e){var t=e.state,n=e.options,r=e.name,o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!1:i,l=n.boundary,c=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0?!0:f,m=n.tetherOffset,g=m===void 0?0:m,b=jr(t,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),x=Rt(t.placement),S=rr(t.placement),k=!S,y=Ya(x),T=ES(y),w=t.modifiersData.popperOffsets,C=t.rects.reference,A=t.rects.popper,I=typeof g=="function"?g(Object.assign({},t.rects,{placement:t.placement})):g,O=typeof I=="number"?{mainAxis:I,altAxis:I}:Object.assign({mainAxis:0,altAxis:0},I),j=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,D={x:0,y:0};if(w){if(s){var F,B=y==="y"?Ue:Ge,N=y==="y"?ut:dt,$=y==="y"?"height":"width",V=w[y],_=V+b[B],R=V-b[N],z=p?-A[$]/2:0,W=S===er?C[$]:A[$],re=S===er?-A[$]:-C[$],se=t.elements.arrow,le=p&&se?Ja(se):{width:0,height:0},te=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Zp(),G=te[B],H=te[N],J=kr(0,C[$],le[$]),oe=k?C[$]/2-z-J-G-O.mainAxis:W-J-G-O.mainAxis,ge=k?-C[$]/2+z+J+H+O.mainAxis:re+J+H+O.mainAxis,Ce=t.elements.arrow&&Qr(t.elements.arrow),ve=Ce?y==="y"?Ce.clientTop||0:Ce.clientLeft||0:0,we=(F=j?.[y])!=null?F:0,Ee=V+oe-we-ve,st=V+ge-we,Xe=kr(p?ns(_,Ee):_,V,p?vn(R,st):R);w[y]=Xe,D[y]=Xe-V}if(a){var qe,ye=y==="x"?Ue:Ge,Re=y==="x"?ut:dt,Pe=w[T],Te=T==="y"?"height":"width",_e=Pe+b[ye],Dt=Pe-b[Re],Vt=[Ue,Ge].indexOf(x)!==-1,un=(qe=j?.[T])!=null?qe:0,xe=Vt?_e:Pe-C[Te]-A[Te]-un+O.altAxis,Je=Vt?Pe+C[Te]+A[Te]-un-O.altAxis:Dt,qt=p&&Vt?QC(xe,Pe,Je):kr(p?xe:_e,Pe,p?Je:Dt);w[T]=qt,D[T]=qt-Pe}t.modifiersData[r]=D}}const RS={name:"preventOverflow",enabled:!0,phase:"main",fn:MS,requiresIfExists:["offset"]};function NS(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function OS(e){return e===ot(e)||!ct(e)?Qa(e):NS(e)}function IS(e){var t=e.getBoundingClientRect(),n=tr(t.width)/e.offsetWidth||1,r=tr(t.height)/e.offsetHeight||1;return n!==1||r!==1}function PS(e,t,n){n===void 0&&(n=!1);var r=ct(t),o=ct(t)&&IS(t),s=cn(t),i=nr(e,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((It(t)!=="body"||el(s))&&(a=OS(t)),ct(t)?(l=nr(t,!0),l.x+=t.clientLeft,l.y+=t.clientTop):s&&(l.x=Za(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function LS(e){var t=new Map,n=new Set,r=[];e.forEach(function(s){t.set(s.name,s)});function o(s){n.add(s.name);var i=[].concat(s.requires||[],s.requiresIfExists||[]);i.forEach(function(a){if(!n.has(a)){var l=t.get(a);l&&o(l)}}),r.push(s)}return e.forEach(function(s){n.has(s.name)||o(s)}),r}function DS(e){var t=LS(e);return UC.reduce(function(n,r){return n.concat(t.filter(function(o){return o.phase===r}))},[])}function jS(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function zS(e){var t=e.reduce(function(n,r){var o=n[r.name];return n[r.name]=o?Object.assign({},o,r,{options:Object.assign({},o.options,r.options),data:Object.assign({},o.data,r.data)}):r,n},{});return Object.keys(t).map(function(n){return t[n]})}var Wc={placement:"bottom",modifiers:[],strategy:"absolute"};function Vc(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function _S(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,o=t.defaultOptions,s=o===void 0?Wc:o;return function(a,l,c){c===void 0&&(c=s);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},Wc,s),modifiersData:{},elements:{reference:a,popper:l},attributes:{},styles:{}},d=[],f=!1,p={state:u,setOptions:function(x){var S=typeof x=="function"?x(u.options):x;g(),u.options=Object.assign({},s,u.options,S),u.scrollParents={reference:An(a)?Cr(a):a.contextElement?Cr(a.contextElement):[],popper:Cr(l)};var k=DS(zS([].concat(r,u.options.modifiers)));return u.orderedModifiers=k.filter(function(y){return y.enabled}),m(),p.update()},forceUpdate:function(){if(!f){var x=u.elements,S=x.reference,k=x.popper;if(Vc(S,k)){u.rects={reference:PS(S,Qr(k),u.options.strategy==="fixed"),popper:Ja(k)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach(function(O){return u.modifiersData[O.name]=Object.assign({},O.data)});for(var y=0;y<u.orderedModifiers.length;y++){if(u.reset===!0){u.reset=!1,y=-1;continue}var T=u.orderedModifiers[y],w=T.fn,C=T.options,A=C===void 0?{}:C,I=T.name;typeof w=="function"&&(u=w({state:u,options:A,name:I,instance:p})||u)}}}},update:jS(function(){return new Promise(function(b){p.forceUpdate(),b(u)})}),destroy:function(){g(),f=!0}};if(!Vc(a,l))return p;p.setOptions(c).then(function(b){!f&&c.onFirstUpdate&&c.onFirstUpdate(b)});function m(){u.orderedModifiers.forEach(function(b){var x=b.name,S=b.options,k=S===void 0?{}:S,y=b.effect;if(typeof y=="function"){var T=y({state:u,name:x,instance:p,options:k}),w=function(){};d.push(T||w)}})}function g(){d.forEach(function(b){return b()}),d=[]}return p}}var $S=[lS,AS,iS,Jp,SS,xS,RS,nS,wS],FS=_S({defaultModifiers:$S}),BS="tippy-box",oh="tippy-content",HS="tippy-backdrop",sh="tippy-arrow",ih="tippy-svg-arrow",mn={passive:!0,capture:!0},ah=function(){return document.body};function WS(e,t){return{}.hasOwnProperty.call(e,t)}function oi(e,t,n){if(Array.isArray(e)){var r=e[t];return r??(Array.isArray(n)?n[t]:n)}return e}function tl(e,t){var n={}.toString.call(e);return n.indexOf("[object")===0&&n.indexOf(t+"]")>-1}function lh(e,t){return typeof e=="function"?e.apply(void 0,t):e}function qc(e,t){if(t===0)return e;var n;return function(r){clearTimeout(n),n=setTimeout(function(){e(r)},t)}}function VS(e,t){var n=Object.assign({},e);return t.forEach(function(r){delete n[r]}),n}function qS(e){return e.split(/\s+/).filter(Boolean)}function Wn(e){return[].concat(e)}function Kc(e,t){e.indexOf(t)===-1&&e.push(t)}function KS(e){return e.filter(function(t,n){return e.indexOf(t)===n})}function US(e){return e.split("-")[0]}function rs(e){return[].slice.call(e)}function Uc(e){return Object.keys(e).reduce(function(t,n){return e[n]!==void 0&&(t[n]=e[n]),t},{})}function Sr(){return document.createElement("div")}function zr(e){return["Element","Fragment"].some(function(t){return tl(e,t)})}function GS(e){return tl(e,"NodeList")}function XS(e){return tl(e,"MouseEvent")}function JS(e){return!!(e&&e._tippy&&e._tippy.reference===e)}function YS(e){return zr(e)?[e]:GS(e)?rs(e):Array.isArray(e)?e:rs(document.querySelectorAll(e))}function si(e,t){e.forEach(function(n){n&&(n.style.transitionDuration=t+"ms")})}function Gc(e,t){e.forEach(function(n){n&&n.setAttribute("data-state",t)})}function QS(e){var t,n=Wn(e),r=n[0];return r!=null&&(t=r.ownerDocument)!=null&&t.body?r.ownerDocument:document}function ZS(e,t){var n=t.clientX,r=t.clientY;return e.every(function(o){var s=o.popperRect,i=o.popperState,a=o.props,l=a.interactiveBorder,c=US(i.placement),u=i.modifiersData.offset;if(!u)return!0;var d=c==="bottom"?u.top.y:0,f=c==="top"?u.bottom.y:0,p=c==="right"?u.left.x:0,m=c==="left"?u.right.x:0,g=s.top-r+d>l,b=r-s.bottom-f>l,x=s.left-n+p>l,S=n-s.right-m>l;return g||b||x||S})}function ii(e,t,n){var r=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(o){e[r](o,n)})}function Xc(e,t){for(var n=t;n;){var r;if(e.contains(n))return!0;n=n.getRootNode==null||(r=n.getRootNode())==null?void 0:r.host}return!1}var Ct={isTouch:!1},Jc=0;function e1(){Ct.isTouch||(Ct.isTouch=!0,window.performance&&document.addEventListener("mousemove",ch))}function ch(){var e=performance.now();e-Jc<20&&(Ct.isTouch=!1,document.removeEventListener("mousemove",ch)),Jc=e}function t1(){var e=document.activeElement;if(JS(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}function n1(){document.addEventListener("touchstart",e1,mn),window.addEventListener("blur",t1)}var r1=typeof window<"u"&&typeof document<"u",o1=r1?!!window.msCrypto:!1;function $n(e){var t=e==="destroy"?"n already-":" ";return[e+"() was called on a"+t+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function Yc(e){var t=/[ \t]{2,}/g,n=/^[ \t]*/gm;return e.replace(t," ").replace(n,"").trim()}function s1(e){return Yc(`
|
|
128
|
+
`);if(!r)return null;const o=n.parentOffset,s=o>0&&So.test(r[o-1]??"")?o-1:o;if(!So.test(r[s]??""))return null;let i=s,a=s+1;for(;i>0&&So.test(r[i-1]??"");)i-=1;for(;a<r.length&&So.test(r[a]??"");)a+=1;return{from:n.start()+i,to:n.start()+a}},Xp=({editor:e,onUpload:t,disableVideoUpload:n,disableImageUpload:r,classNames:o,styles:s,onThemeChange:i,showThemeToggle:a=!0})=>{const l=K.useRef(null),c=We(),u=Vr(),d=i0(),f=s??d??[],{effectiveStyles:p,saveOverride:m,resetOverride:g}=EC(f),[b,x]=K.useState(!1),[S,k]=K.useState(""),[y,A]=K.useState(!1),[w,C]=K.useState(""),[T,I]=K.useState(""),[O,j]=K.useState(""),[D,F]=K.useState(!1),[,B]=K.useState(0),N=MC(u),$=RC(u);if(K.useEffect(()=>{if(!e)return;const L=e.view.dom,ne=E=>{const ee=(E.target instanceof Element?E.target:null)?.closest("a[href]"),fe=ee&&L.contains(ee);fe&&(E.preventDefault(),E.stopPropagation()),setTimeout(()=>{e.isDestroyed||(fe||e.isActive("link"))&&(k(e.getAttributes("link").href??ee?.getAttribute("href")??""),x(!0))},0)};return L.addEventListener("click",ne),()=>L.removeEventListener("click",ne)},[e]),K.useEffect(()=>{if(!e)return;const L=()=>{B(E=>E+1),C(zc(e));const ne=e.getAttributes("textStyle").fontFamily??"";I(ne)};return L(),e.on("selectionUpdate",L),e.on("transaction",L),e.on("update",L),()=>{e.off("selectionUpdate",L),e.off("transaction",L),e.off("update",L)}},[e]),!e)return null;const V=L=>{L.preventDefault()},_=()=>{for(let L=1;L<=5;L++)if(e.isActive("heading",{level:L}))return`h${L}`;return null},R=()=>e.isActive("bulletList")?"bullet":e.isActive("orderedList")?"ordered":e.isActive("taskList")?"task":null,z=L=>{const ne=parseInt(L.replace("h",""));e.chain().focus().toggleHeading({level:ne}).run()},W=L=>{L==="bullet"&&e.chain().focus().toggleBulletList().run(),L==="ordered"&&e.chain().focus().toggleOrderedList().run(),L==="task"&&e.chain().focus().toggleTaskList().run()},re=()=>{S.trim()?J().setLink({href:S}).run():J().unsetLink().run(),x(!1),k("")},se=L=>{J().setColor(L.textColor).setHighlight({color:L.backgroundColor}).run(),A(!1)},le=()=>{const L=dr(e.getAttributes("highlight").color),ne=si.some(U=>dr(U.backgroundColor)===L),E=J().unsetHighlight();ne&&E.unsetColor(),E.run(),A(!1)},te=(L=w)=>{const ne=ft(L);if(!ne)return;const E=rs(ne);J().setFontSize(E).run(),C(E)},G=L=>{const ne=e.getAttributes("textStyle").fontSize,E=ft(w)??ft(ne)??ft(Gn);if(!E)return;const U=ft(`${E.value+L*Do[E.unit].step}${E.unit}`);if(!U)return;const ee=rs(U);J().setFontSize(ee).run(),C(ee)},H=()=>{J().unsetFontSize().run(),C("")},J=()=>{const L=e.chain().focus(),ne=IC(e);return ne?L.setTextSelection(ne):L},oe=L=>{let ne=e.chain().focus();if(L.id==="normal"){ne.clearNodes().unsetAllMarks().setParagraph().run();return}L.type==="heading"&&L.level?ne=ne.setHeading({level:L.level}):L.type==="blockquote"?ne=ne.setBlockquote():ne=ne.setParagraph();const E={};L.fontFamily&&(E.fontFamily=L.fontFamily),L.fontSize&&(E.fontSize=L.fontSize),L.fontWeight&&(E.fontWeight=L.fontWeight),L.fontStyle&&(E.fontStyle=L.fontStyle),L.letterSpacing&&(E.letterSpacing=L.letterSpacing),L.lineHeight&&(E.lineHeight=L.lineHeight),L.textTransform&&(E.textTransform=L.textTransform),Object.keys(E).length>0&&(ne=ne.setMark("textStyle",E)),L.color&&(ne=ne.setColor(L.color)),ne.run()},ge=()=>{if(!p.length)return null;const{$from:L}=e.state.selection,ne=L.parent;return p.find(E=>E.type==="heading"&&E.level?ne.type.name==="heading"&&ne.attrs.level===E.level:E.type==="blockquote"?e.isActive("blockquote"):ne.type.name==="paragraph")??null},Ce=L=>{L?J().setFontFamily(L).run():J().unsetFontFamily().run(),I(L),F(!1),j("")},ve=[{label:"Default",value:""},{label:"Inter",value:"Inter, sans-serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Times New Roman",value:"Times New Roman, Times, serif"},{label:"Courier New",value:"Courier New, Courier, monospace"},{label:"Trebuchet MS",value:"Trebuchet MS, sans-serif"},{label:"Arial",value:"Arial, Helvetica, sans-serif"},{label:"Verdana",value:"Verdana, Geneva, sans-serif"},{label:"Impact",value:"Impact, fantasy"}],we=O.trim()?ve.filter(L=>L.label.toLowerCase().includes(O.toLowerCase())):ve,Ee=e.getAttributes("textStyle").fontFamily??"",st=ve.find(L=>L.value===Ee)?.label??(Ee?Ee.split(",")[0].trim():""),Xe=async L=>{const ne=L.target.files?.[0];if(!(!ne||!t)){try{const{url:E}=await t(ne);ne.type.startsWith("video/")?e.chain().focus().setNode("video",{src:E}).run():e.chain().focus().setAdvancedImage({src:E}).run()}catch(E){console.error("Upload failed:",E)}l.current&&(l.current.value="")}},qe=()=>{i?.(c==="dark"?"light":"dark")},ye=({isActive:L,onClick:ne,tooltip:E,disabled:U=!1,children:ee})=>h.jsx(kt,{content:E,children:h.jsx("button",{type:"button",onMouseDown:V,onClick:ne,disabled:U,"aria-label":E,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors duration-150",c==="dark"?"text-neutral-400":"text-neutral-500",!U&&(c==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900"),L&&(c==="dark"?"bg-white/15 text-neutral-100":"bg-black/8 text-neutral-900"),L&&o?.toolbarButtonActive,U&&"opacity-30 cursor-not-allowed",U&&o?.toolbarButtonDisabled,o?.toolbarButton),children:h.jsx("span",{className:M("flex items-center justify-center",o?.toolbarButtonIcon),children:ee})})}),Re=()=>h.jsx("span",{className:M("shrink-0 w-[1px] h-4 mx-1",c==="dark"?"bg-white/10":"bg-black/8",o?.toolbarSeparator)}),Pe=_(),Te=Pe?N.find(L=>L.value===Pe)?.label??u.heading:u.heading,_e=R(),Dt=_e?$.find(L=>L.value===_e)?.label??u.list:u.list,Vt=(L,ne,E)=>h.jsxs("button",{type:"button",onMouseDown:V,className:M("flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-full px-2.5 text-sm font-medium transition-colors",c==="dark"?"text-neutral-300 hover:bg-white/10 hover:text-neutral-100":"text-neutral-600 hover:bg-black/6 hover:text-neutral-900",E&&(c==="dark"?"bg-white/15 text-neutral-100":"bg-black/8 text-neutral-900"),E&&o?.toolbarTriggerActive,o?.toolbarTrigger),children:[h.jsx("span",{className:M("flex items-center justify-center",o?.toolbarTriggerIcon),children:ne}),h.jsx("span",{className:M("hidden sm:inline max-w-[72px] truncate",o?.toolbarTriggerLabel),children:L}),h.jsx(q.ChevronDown,{size:12,className:M("opacity-50 shrink-0",o?.toolbarTriggerChevron)})]}),un=e.getAttributes("textStyle").fontSize,xe=ft(w)??ft(un)??ft(Gn),Je=xe?Do[xe.unit]:Do.px,qt=!!ft(un),to=dr(e.getAttributes("highlight").color),no=si.find(L=>dr(L.backgroundColor)===to),dn=e.isActive("highlight");return h.jsx("div",{className:M("relative z-20 shrink-0 border-b backdrop-blur-md transition-all",c==="dark"?"bg-neutral-900/95 border-white/8 text-neutral-400":"bg-white/95 border-black/6 text-neutral-500",o?.toolbar),children:h.jsxs("div",{className:M("flex w-full items-center gap-2 overflow-x-auto px-3 py-2 [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",o?.toolbarInner),children:[h.jsx(Lo,{trigger:h.jsxs("button",{type:"button",onMouseDown:V,"aria-label":u.fontFamily,className:M("flex h-8 min-w-[100px] max-w-[140px] shrink-0 cursor-pointer items-center justify-between gap-1.5 rounded-full px-3 text-sm font-medium transition-colors",c==="dark"?"bg-white/[0.06] text-neutral-200 hover:bg-white/10":"bg-neutral-100 text-neutral-700 hover:bg-neutral-200",Ee&&(c==="dark"?"ring-1 ring-white/20":"ring-1 ring-black/10"),o?.toolbarFontFamilyTrigger),children:[h.jsx("span",{className:"truncate",style:{fontFamily:Ee||"inherit"},children:st||u.fontFamily}),h.jsx(q.ChevronDown,{size:12,className:"shrink-0 opacity-50"})]}),open:D,onOpenChange:L=>{F(L),L||j("")},align:"start",children:h.jsxs("div",{className:M("flex flex-col w-52",o?.toolbarFontFamilyPopover),children:[h.jsx("div",{className:"mb-1.5",children:h.jsx("input",{type:"text",placeholder:"Search fonts...",value:O,onChange:L=>j(L.target.value),autoFocus:!0,className:M("w-full rounded-full border px-3 py-1.5 text-sm outline-none transition-colors",c==="dark"?"bg-neutral-800 border-neutral-700 text-neutral-100 placeholder:text-neutral-500 focus:border-neutral-500":"bg-neutral-50 border-neutral-200 text-neutral-900 placeholder:text-neutral-400 focus:border-neutral-400",o?.toolbarFontFamilySearch)})}),h.jsxs("div",{className:M("flex flex-col gap-0.5 max-h-96 overflow-y-auto",o?.toolbarFontFamilyList),children:[we.map(L=>{const ne=(T||"")===L.value;return h.jsxs("button",{type:"button",onMouseDown:V,onClick:()=>Ce(L.value),className:M("flex w-full cursor-pointer items-center gap-2 rounded-full px-3 py-2 text-sm text-left transition-colors",c==="dark"?ne?"bg-white/15 text-neutral-100":"text-neutral-300 hover:bg-white/8 hover:text-neutral-100":ne?"bg-black/8 text-neutral-900":"text-neutral-700 hover:bg-neutral-100 hover:text-neutral-900",o?.toolbarFontFamilyItem,ne&&o?.toolbarFontFamilyItemActive),children:[h.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-[10px]",style:{opacity:ne?1:0},children:"✓"}),h.jsx("span",{style:{fontFamily:L.value||"inherit"},children:L.label})]},L.value||"__default__")}),we.length===0&&h.jsx("p",{className:M("px-3 py-2 text-sm",c==="dark"?"text-neutral-500":"text-neutral-400"),children:u.noResults})]})]})}),h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx(ye,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().undo(),tooltip:u.undo,children:h.jsx(q.Undo2,{size:16})}),h.jsx(ye,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().redo(),tooltip:u.redo,children:h.jsx(q.Redo2,{size:16})})]}),h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx(Dc,{trigger:Vt(Te,h.jsx(q.Type,{size:14}),!!Pe),items:N,value:_()??void 0,onSelect:z}),h.jsx(Dc,{trigger:Vt(Dt,h.jsx(q.List,{size:14}),!!_e),items:$,value:R()??void 0,onSelect:W}),h.jsx(ye,{isActive:e.isActive("blockquote"),onClick:()=>e.chain().focus().toggleBlockquote().run(),tooltip:u.quote,children:h.jsx(q.Quote,{size:16})}),h.jsx(ye,{isActive:e.isActive("codeBlock"),onClick:()=>e.chain().focus().toggleCodeBlock().run(),tooltip:u.codeBlock,children:h.jsx(q.Code2,{size:16})})]}),h.jsx(Re,{}),h.jsx("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:h.jsxs("div",{className:M("flex h-8 shrink-0 items-stretch overflow-hidden rounded-full text-sm font-medium transition-colors",c==="dark"?" text-neutral-200":" text-neutral-700",qt&&o?.toolbarFontSizeControlActive,o?.toolbarFontSizeControl),children:[h.jsx(kt,{content:u.decreaseFontSize,children:h.jsx("button",{type:"button",onMouseDown:V,onClick:()=>G(-1),disabled:!xe||xe.value<=Je.min,"aria-label":u.decreaseFontSize,className:M("flex w-8 shrink-0 cursor-pointer items-center justify-center rounded-full border transition-colors",c==="dark"?"border-white/5 text-neutral-400":"border-black/4 text-neutral-500",xe&&xe.value>Je.min&&(c==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900"),(!xe||xe.value<=Je.min)&&"cursor-not-allowed opacity-30",(!xe||xe.value<=Je.min)&&o?.toolbarButtonDisabled,o?.toolbarFontSizeStepButton),children:h.jsx(q.Minus,{size:14})})}),h.jsxs("label",{className:"flex items-center",children:[h.jsx("span",{className:"sr-only",children:u.fontSize}),h.jsx("input",{type:"text",inputMode:"decimal","aria-label":u.fontSize,value:w,placeholder:Gn,onChange:L=>C(L.target.value),onBlur:()=>{w.trim()?te():qt&&H()},onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),w.trim()?te():qt&&H()),L.key==="Escape"&&C(zc(e))},className:M("h-full w-15 bg-transparent px-2 text-center outline-none",c==="dark"?"placeholder:text-neutral-500":"placeholder:text-neutral-400",o?.toolbarFontSizeInput)})]}),h.jsx(kt,{content:u.increaseFontSize,children:h.jsx("button",{type:"button",onMouseDown:V,onClick:()=>G(1),disabled:!xe||xe.value>=Je.max,"aria-label":u.increaseFontSize,className:M("flex w-8 shrink-0 cursor-pointer items-center justify-center rounded-full border transition-colors",c==="dark"?"border-white/5 text-neutral-400":"border-black/4 text-neutral-500",xe&&xe.value<Je.max&&(c==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900"),(!xe||xe.value>=Je.max)&&"cursor-not-allowed opacity-30",(!xe||xe.value>=Je.max)&&o?.toolbarButtonDisabled,o?.toolbarFontSizeStepButton),children:h.jsx(q.Plus,{size:14})})})]})}),h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx(ye,{isActive:e.isActive("bold"),onClick:()=>J().toggleBold().run(),tooltip:u.bold,children:h.jsx(q.Bold,{size:16})}),h.jsx(ye,{isActive:e.isActive("italic"),onClick:()=>J().toggleItalic().run(),tooltip:u.italic,children:h.jsx(q.Italic,{size:16})}),h.jsx(ye,{isActive:e.isActive("strike"),onClick:()=>J().toggleStrike().run(),tooltip:u.strikethrough,children:h.jsx(q.Strikethrough,{size:16})}),h.jsx(ye,{isActive:e.isActive("code"),onClick:()=>J().toggleCode().run(),tooltip:u.inlineCode,children:h.jsx(q.Code,{size:16})}),h.jsx(ye,{isActive:e.isActive("underline"),onClick:()=>J().toggleUnderline().run(),tooltip:u.underline,children:h.jsx(q.Underline,{size:16})}),h.jsx(Lo,{trigger:h.jsxs("button",{type:"button",onMouseDown:V,"aria-label":u.highlight,className:M("relative flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors duration-150",c==="dark"?"text-neutral-400":"text-neutral-500",c==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900",dn&&(c==="dark"?"bg-white/15 text-neutral-100":"bg-black/8 text-neutral-900"),dn&&o?.toolbarButtonActive,o?.toolbarButton,o?.toolbarHighlightButton),children:[h.jsx("span",{className:M("flex items-center justify-center",o?.toolbarButtonIcon),children:h.jsx(q.Highlighter,{size:16})}),h.jsx("span",{className:M("absolute bottom-1 h-0.5 w-4 rounded-full",dn?"opacity-100":c==="dark"?"bg-neutral-600 opacity-70":"bg-neutral-300 opacity-80",o?.toolbarHighlightIndicator),style:no?{backgroundColor:no.backgroundColor}:void 0})]}),open:y,onOpenChange:A,align:"start",children:h.jsxs("div",{className:M("flex w-48 flex-col gap-2",o?.toolbarHighlightPopoverBody),children:[h.jsx("p",{className:M("text-xs font-semibold",c==="dark"?"text-neutral-400":"text-neutral-500",o?.toolbarHighlightPopoverLabel),children:u.highlightPalette}),h.jsx("div",{className:M("grid grid-cols-4 gap-1.5",o?.toolbarHighlightGrid),children:si.map(L=>{const ne=dr(L.backgroundColor)===to;return h.jsx(kt,{content:u[L.labelKey],children:h.jsx("button",{type:"button",onMouseDown:V,onClick:()=>se(L),"aria-label":`${u.highlight}: ${u[L.labelKey]}`,className:M("flex h-9 w-9 cursor-pointer items-center justify-center rounded-full border text-sm font-bold transition-transform duration-150","hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500",c==="dark"?"border-white/15":"border-black/10",ne&&(c==="dark"?"ring-2 ring-white/70":"ring-2 ring-neutral-900/70"),ne&&o?.toolbarHighlightSwatchActive,o?.toolbarHighlightSwatch),style:{backgroundColor:L.backgroundColor,color:L.textColor},children:"A"})},L.backgroundColor)})}),h.jsx("button",{type:"button",onMouseDown:V,onClick:le,disabled:!dn,className:M("h-8 rounded-full px-3 text-xs font-medium transition-colors",c==="dark"?"text-neutral-300 hover:bg-white/10 disabled:text-neutral-600":"text-neutral-600 hover:bg-black/6 disabled:text-neutral-300",!dn&&"cursor-not-allowed",o?.toolbarHighlightClearButton),children:u.clearHighlight})]})}),h.jsx(Lo,{trigger:h.jsx("button",{type:"button",onMouseDown:V,"aria-label":u.link,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors duration-150",c==="dark"?"text-neutral-400":"text-neutral-500",c==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900",e.isActive("link")&&(c==="dark"?"bg-white/15 text-neutral-100":"bg-black/8 text-neutral-900"),e.isActive("link")&&o?.toolbarButtonActive,o?.toolbarButton,o?.toolbarLinkButton),children:h.jsx("span",{className:M("flex items-center justify-center",o?.toolbarButtonIcon),children:h.jsx(q.Link,{size:16})})}),open:b,onOpenChange:L=>{x(L),L&&k(e.getAttributes("link").href??"")},align:"start",children:h.jsxs("div",{className:M("flex flex-col gap-2 w-64",o?.toolbarLinkPopoverBody),children:[h.jsx("p",{className:M("text-xs font-semibold",c==="dark"?"text-neutral-400":"text-neutral-500",o?.toolbarLinkPopoverLabel),children:u.insertLink}),h.jsx("input",{type:"url",placeholder:u.linkPlaceholder,value:S,onChange:L=>k(L.target.value),onKeyDown:L=>L.key==="Enter"&&re(),autoFocus:!0,className:M("w-full px-3 py-2 text-sm rounded-xl border outline-none transition-colors",c==="dark"?"bg-neutral-800 border-neutral-700 text-neutral-100 placeholder:text-neutral-500 focus:border-neutral-500":"bg-neutral-50 border-neutral-200 text-neutral-900 placeholder:text-neutral-400 focus:border-neutral-400",o?.toolbarLinkInput)}),h.jsxs("div",{className:M("flex gap-2",o?.toolbarLinkActions),children:[h.jsx("button",{type:"button",onMouseDown:V,onClick:re,className:M("flex-1 py-1.5 text-sm font-medium rounded-full transition-colors",c==="dark"?"bg-neutral-700 hover:bg-neutral-600 text-neutral-100":"bg-neutral-900 hover:bg-neutral-700 text-white",o?.toolbarLinkApplyButton),children:u.apply}),e.isActive("link")&&h.jsx("button",{type:"button",onMouseDown:V,onClick:()=>{e.chain().focus().unsetLink().run(),x(!1)},className:M("px-3 py-1.5 text-sm rounded-full transition-colors",c==="dark"?"text-neutral-400 hover:bg-white/10":"text-neutral-500 hover:bg-black/6",o?.toolbarLinkUnlinkButton),children:h.jsx(q.Unlink,{size:14})})]})]})})]}),h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx(ye,{isActive:e.isActive("superscript"),onClick:()=>J().toggleSuperscript().run(),tooltip:u.superscript,children:h.jsx(q.Superscript,{size:16})}),h.jsx(ye,{isActive:e.isActive("subscript"),onClick:()=>J().toggleSubscript().run(),tooltip:u.subscript,children:h.jsx(q.Subscript,{size:16})})]}),h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx(ye,{isActive:e.isActive({textAlign:"left"}),onClick:()=>e.chain().focus().setTextAlign("left").run(),tooltip:u.alignLeft,children:h.jsx(q.AlignLeft,{size:16})}),h.jsx(ye,{isActive:e.isActive({textAlign:"center"}),onClick:()=>e.chain().focus().setTextAlign("center").run(),tooltip:u.alignCenter,children:h.jsx(q.AlignCenter,{size:16})}),h.jsx(ye,{isActive:e.isActive({textAlign:"right"}),onClick:()=>e.chain().focus().setTextAlign("right").run(),tooltip:u.alignRight,children:h.jsx(q.AlignRight,{size:16})}),h.jsx(ye,{isActive:e.isActive({textAlign:"justify"}),onClick:()=>e.chain().focus().setTextAlign("justify").run(),tooltip:u.alignJustify,children:h.jsx(q.AlignJustify,{size:16})})]}),(!r||!n)&&t&&h.jsxs(h.Fragment,{children:[h.jsx(Re,{}),h.jsxs("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-50",o?.toolbarGroup),children:[h.jsx("input",{type:"file",ref:l,className:M("hidden",o?.toolbarFileInput),accept:!r&&!n?"image/*,video/*":r?"video/*":"image/*",onChange:Xe}),h.jsx(kt,{content:u.uploadMedia,children:h.jsxs("button",{type:"button",onMouseDown:V,onClick:()=>l.current?.click(),className:M("flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-full px-3 text-sm font-medium transition-colors",c==="dark"?"text-neutral-300 hover:bg-white/10 hover:text-neutral-100":"text-neutral-600 hover:bg-black/6 hover:text-neutral-900",o?.toolbarUploadButton),children:[h.jsx(q.Upload,{size:14,className:o?.toolbarUploadIcon}),h.jsx("span",{className:M("hidden sm:inline",o?.toolbarUploadLabel),children:u.upload})]})})]})]}),h.jsx(Re,{}),h.jsx(TC,{styles:p,baseStyles:f,editor:e,theme:c,classNames:o,activeStyle:ge(),onApply:oe,onSave:m,onReset:g,keepEditorSelection:V}),h.jsx("div",{className:"ml-auto shrink-0"}),a&&h.jsx("div",{className:M("flex shrink-0 items-center gap-0.5 rounded-full p-0.5",c==="dark"?"bg-white/[0.06]":"bg-neutral-100",o?.toolbarGroup),children:h.jsx(kt,{content:c==="dark"?u.lightTheme:u.darkTheme,children:h.jsx("button",{type:"button",onMouseDown:V,onClick:qe,"aria-label":u.toggleTheme,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors duration-150",c==="dark"?"text-neutral-300 hover:bg-white/10 hover:text-neutral-100":"text-neutral-600 hover:bg-black/6 hover:text-neutral-900",o?.toolbarButton),children:c==="dark"?h.jsx(q.Sun,{size:16}):h.jsx(q.Moon,{size:16})})})})]})})};function PC(e){var t;const{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:a}=e,l=r&&!o,c=P.escapeForRegEx(n),u=new RegExp(`\\s${c}$`),d=i?"^":"",f=o?"":c,p=l?new RegExp(`${d}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${f}]*`,"gm"),m=((t=a.nodeBefore)==null?void 0:t.isText)&&a.nodeBefore.text;if(!m)return null;const g=a.pos-m.length,b=Array.from(m.matchAll(p)).pop();if(!b||b.input===void 0||b.index===void 0)return null;const x=b.input.slice(Math.max(0,b.index-1),b.index),S=new RegExp(`^[${s?.join("")}\0]?$`).test(x);if(s!==null&&!S)return null;const k=g+b.index;let y=k+b[0].length;return l&&u.test(m.slice(y-1,y+1))&&(b[0]+=" ",y+=1),k<a.pos&&y>=a.pos?{range:{from:k,to:y},query:b[0].slice(n.length),text:b[0]}:null}function LC(e){return e.docChanged?e.steps.some(t=>{const n=t.slice;if(!n?.content)return!1;const r=n.content.textBetween(0,n.content.size,`
|
|
129
|
+
`);return/\s/.test(r)}):!1}var DC=new ds("suggestion");function jC({pluginKey:e=DC,editor:t,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:s=[" "],startOfLine:i=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:g=PC,shouldShow:b,shouldResetDismissed:x}){let S;const k=p?.(),y=r&&!o,A=()=>{const O=t.state.selection.$anchor.pos,j=t.view.coordsAtPos(O),{top:D,right:F,bottom:B,left:N}=j;try{return new DOMRect(N,D,F-N,B-D)}catch{return null}},w=(O,j)=>j?()=>{const D=e.getState(t.state),F=D?.decorationId,B=O.dom.querySelector(`[data-decoration-id="${F}"]`);return B?.getBoundingClientRect()||null}:A,C=({match:O,dismissedRange:j,state:D,transaction:F})=>x?.({editor:t,state:D,range:j,match:O,transaction:F,allowSpaces:y})?!1:y?O.range.from===j.from:O.range.from===j.from&&!LC(F);function T(O,j){var D;try{const B=e.getState(O.state),N=B?.decorationId?O.dom.querySelector(`[data-decoration-id="${B.decorationId}"]`):null,$={editor:t,range:B?.range||{from:0,to:0},query:B?.query||null,text:B?.text||null,items:[],command:V=>d({editor:t,range:B?.range||{from:0,to:0},props:V}),decorationNode:N,clientRect:w(O,N)};(D=k?.onExit)==null||D.call(k,$)}catch{}const F=O.state.tr.setMeta(j,{exit:!0});O.dispatch(F)}const I=new ha({key:e,view(){return{update:async(O,j)=>{var D,F,B,N,$,V,_;const R=(D=this.key)==null?void 0:D.getState(j),z=(F=this.key)==null?void 0:F.getState(O.state),W=R.active&&z.active&&R.range.from!==z.range.from,re=!R.active&&z.active,se=R.active&&!z.active,le=!re&&!se&&R.query!==z.query,te=re||W&&le,G=le||W,H=se||W&≤if(!te&&!G&&!H)return;const J=H&&!te?R:z,oe=O.dom.querySelector(`[data-decoration-id="${J.decorationId}"]`);S={editor:t,range:J.range,query:J.query,text:J.text,items:[],command:ge=>d({editor:t,range:J.range,props:ge}),decorationNode:oe,clientRect:w(O,oe)},te&&((B=k?.onBeforeStart)==null||B.call(k,S)),G&&((N=k?.onBeforeUpdate)==null||N.call(k,S)),(G||te)&&(S.items=await f({editor:t,query:J.query})),H&&(($=k?.onExit)==null||$.call(k,S)),G&&((V=k?.onUpdate)==null||V.call(k,S)),te&&((_=k?.onStart)==null||_.call(k,S))},destroy:()=>{var O;S&&((O=k?.onExit)==null||O.call(k,S))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(O,j,D,F){const{isEditable:B}=t,{composing:N}=t.view,{selection:$}=O,{empty:V,from:_}=$,R={...j},z=O.getMeta(e);if(z&&z.exit)return R.active=!1,R.decorationId=null,R.range={from:0,to:0},R.query=null,R.text=null,R.dismissedRange=j.active?{...j.range}:j.dismissedRange,R;if(R.composing=N,O.docChanged&&R.dismissedRange!==null&&(R.dismissedRange={from:O.mapping.map(R.dismissedRange.from),to:O.mapping.map(R.dismissedRange.to)}),B&&(V||t.view.composing)){(_<j.range.from||_>j.range.to)&&!N&&!j.composing&&(R.active=!1);const W=g({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:$.$from}),re=`id_${Math.floor(Math.random()*4294967295)}`;W&&m({editor:t,state:F,range:W.range,isActive:j.active})&&(!b||b({editor:t,range:W.range,query:W.query,text:W.text,transaction:O}))?(R.dismissedRange!==null&&!C({match:W,dismissedRange:R.dismissedRange,state:F,transaction:O})&&(R.dismissedRange=null),R.dismissedRange===null?(R.active=!0,R.decorationId=j.decorationId?j.decorationId:re,R.range=W.range,R.query=W.query,R.text=W.text):R.active=!1):(W||(R.dismissedRange=null),R.active=!1)}else R.active=!1;return R.active||(R.decorationId=null,R.range={from:0,to:0},R.query=null,R.text=null),R}},props:{handleKeyDown(O,j){var D,F;const{active:B,range:N}=I.getState(O.state);if(!B)return!1;if(j.key==="Escape"||j.key==="Esc"){const V=I.getState(O.state);return(D=k?.onKeyDown)==null||D.call(k,{view:O,event:j,range:V.range}),T(O,e),!0}return((F=k?.onKeyDown)==null?void 0:F.call(k,{view:O,event:j,range:N}))||!1},decorations(O){const{active:j,range:D,decorationId:F,query:B}=I.getState(O);if(!j)return null;const N=!B?.length,$=[l];return N&&$.push(u),Se.create(O.doc,[tt.inline(D.from,D.to,{nodeName:a,class:$.join(" "),"data-decoration-id":F,"data-decoration-content":c})])}}});return I}var zC=jC,Ue="top",ut="bottom",dt="right",Ge="left",Ja="auto",Qr=[Ue,ut,dt,Ge],er="start",Dr="end",_C="clippingParents",Jp="viewport",fr="popper",$C="reference",_c=Qr.reduce(function(e,t){return e.concat([t+"-"+er,t+"-"+Dr])},[]),Yp=[].concat(Qr,[Ja]).reduce(function(e,t){return e.concat([t,t+"-"+er,t+"-"+Dr])},[]),FC="beforeRead",BC="read",HC="afterRead",WC="beforeMain",VC="main",qC="afterMain",KC="beforeWrite",UC="write",GC="afterWrite",XC=[FC,BC,HC,WC,VC,qC,KC,UC,GC];function It(e){return e?(e.nodeName||"").toLowerCase():null}function ot(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function An(e){var t=ot(e).Element;return e instanceof t||e instanceof Element}function ct(e){var t=ot(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function Ya(e){if(typeof ShadowRoot>"u")return!1;var t=ot(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function JC(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var r=t.styles[n]||{},o=t.attributes[n]||{},s=t.elements[n];!ct(s)||!It(s)||(Object.assign(s.style,r),Object.keys(o).forEach(function(i){var a=o[i];a===!1?s.removeAttribute(i):s.setAttribute(i,a===!0?"":a)}))})}function YC(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(r){var o=t.elements[r],s=t.attributes[r]||{},i=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:n[r]),a=i.reduce(function(l,c){return l[c]="",l},{});!ct(o)||!It(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const Qp={name:"applyStyles",enabled:!0,phase:"write",fn:JC,effect:YC,requires:["computeStyles"]};function Rt(e){return e.split("-")[0]}var vn=Math.max,os=Math.min,tr=Math.round;function Ui(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function Zp(){return!/^((?!chrome|android).)*safari/i.test(Ui())}function nr(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),o=1,s=1;t&&ct(e)&&(o=e.offsetWidth>0&&tr(r.width)/e.offsetWidth||1,s=e.offsetHeight>0&&tr(r.height)/e.offsetHeight||1);var i=An(e)?ot(e):window,a=i.visualViewport,l=!Zp()&&n,c=(r.left+(l&&a?a.offsetLeft:0))/o,u=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/o,f=r.height/s;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c,x:c,y:u}}function Qa(e){var t=nr(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function eh(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Ya(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Bt(e){return ot(e).getComputedStyle(e)}function QC(e){return["table","td","th"].indexOf(It(e))>=0}function cn(e){return((An(e)?e.ownerDocument:e.document)||window.document).documentElement}function As(e){return It(e)==="html"?e:e.assignedSlot||e.parentNode||(Ya(e)?e.host:null)||cn(e)}function $c(e){return!ct(e)||Bt(e).position==="fixed"?null:e.offsetParent}function ZC(e){var t=/firefox/i.test(Ui()),n=/Trident/i.test(Ui());if(n&&ct(e)){var r=Bt(e);if(r.position==="fixed")return null}var o=As(e);for(Ya(o)&&(o=o.host);ct(o)&&["html","body"].indexOf(It(o))<0;){var s=Bt(o);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||t&&s.willChange==="filter"||t&&s.filter&&s.filter!=="none")return o;o=o.parentNode}return null}function Zr(e){for(var t=ot(e),n=$c(e);n&&QC(n)&&Bt(n).position==="static";)n=$c(n);return n&&(It(n)==="html"||It(n)==="body"&&Bt(n).position==="static")?t:n||ZC(e)||t}function Za(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function kr(e,t,n){return vn(e,os(t,n))}function eS(e,t,n){var r=kr(e,t,n);return r>n?n:r}function th(){return{top:0,right:0,bottom:0,left:0}}function nh(e){return Object.assign({},th(),e)}function rh(e,t){return t.reduce(function(n,r){return n[r]=e,n},{})}var tS=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,nh(typeof t!="number"?t:rh(t,Qr))};function nS(e){var t,n=e.state,r=e.name,o=e.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=Rt(n.placement),l=Za(a),c=[Ge,dt].indexOf(a)>=0,u=c?"height":"width";if(!(!s||!i)){var d=tS(o.padding,n),f=Qa(s),p=l==="y"?Ue:Ge,m=l==="y"?ut:dt,g=n.rects.reference[u]+n.rects.reference[l]-i[l]-n.rects.popper[u],b=i[l]-n.rects.reference[l],x=Zr(s),S=x?l==="y"?x.clientHeight||0:x.clientWidth||0:0,k=g/2-b/2,y=d[p],A=S-f[u]-d[m],w=S/2-f[u]/2+k,C=kr(y,w,A),T=l;n.modifiersData[r]=(t={},t[T]=C,t.centerOffset=C-w,t)}}function rS(e){var t=e.state,n=e.options,r=n.element,o=r===void 0?"[data-popper-arrow]":r;o!=null&&(typeof o=="string"&&(o=t.elements.popper.querySelector(o),!o)||eh(t.elements.popper,o)&&(t.elements.arrow=o))}const oS={name:"arrow",enabled:!0,phase:"main",fn:nS,effect:rS,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function rr(e){return e.split("-")[1]}var sS={top:"auto",right:"auto",bottom:"auto",left:"auto"};function iS(e,t){var n=e.x,r=e.y,o=t.devicePixelRatio||1;return{x:tr(n*o)/o||0,y:tr(r*o)/o||0}}function Fc(e){var t,n=e.popper,r=e.popperRect,o=e.placement,s=e.variation,i=e.offsets,a=e.position,l=e.gpuAcceleration,c=e.adaptive,u=e.roundOffsets,d=e.isFixed,f=i.x,p=f===void 0?0:f,m=i.y,g=m===void 0?0:m,b=typeof u=="function"?u({x:p,y:g}):{x:p,y:g};p=b.x,g=b.y;var x=i.hasOwnProperty("x"),S=i.hasOwnProperty("y"),k=Ge,y=Ue,A=window;if(c){var w=Zr(n),C="clientHeight",T="clientWidth";if(w===ot(n)&&(w=cn(n),Bt(w).position!=="static"&&a==="absolute"&&(C="scrollHeight",T="scrollWidth")),w=w,o===Ue||(o===Ge||o===dt)&&s===Dr){y=ut;var I=d&&w===A&&A.visualViewport?A.visualViewport.height:w[C];g-=I-r.height,g*=l?1:-1}if(o===Ge||(o===Ue||o===ut)&&s===Dr){k=dt;var O=d&&w===A&&A.visualViewport?A.visualViewport.width:w[T];p-=O-r.width,p*=l?1:-1}}var j=Object.assign({position:a},c&&sS),D=u===!0?iS({x:p,y:g},ot(n)):{x:p,y:g};if(p=D.x,g=D.y,l){var F;return Object.assign({},j,(F={},F[y]=S?"0":"",F[k]=x?"0":"",F.transform=(A.devicePixelRatio||1)<=1?"translate("+p+"px, "+g+"px)":"translate3d("+p+"px, "+g+"px, 0)",F))}return Object.assign({},j,(t={},t[y]=S?g+"px":"",t[k]=x?p+"px":"",t.transform="",t))}function aS(e){var t=e.state,n=e.options,r=n.gpuAcceleration,o=r===void 0?!0:r,s=n.adaptive,i=s===void 0?!0:s,a=n.roundOffsets,l=a===void 0?!0:a,c={placement:Rt(t.placement),variation:rr(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:o,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Fc(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:i,roundOffsets:l})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Fc(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const lS={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:aS,data:{}};var To={passive:!0};function cS(e){var t=e.state,n=e.instance,r=e.options,o=r.scroll,s=o===void 0?!0:o,i=r.resize,a=i===void 0?!0:i,l=ot(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return s&&c.forEach(function(u){u.addEventListener("scroll",n.update,To)}),a&&l.addEventListener("resize",n.update,To),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",n.update,To)}),a&&l.removeEventListener("resize",n.update,To)}}const uS={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:cS,data:{}};var dS={left:"right",right:"left",bottom:"top",top:"bottom"};function jo(e){return e.replace(/left|right|bottom|top/g,function(t){return dS[t]})}var fS={start:"end",end:"start"};function Bc(e){return e.replace(/start|end/g,function(t){return fS[t]})}function el(e){var t=ot(e),n=t.pageXOffset,r=t.pageYOffset;return{scrollLeft:n,scrollTop:r}}function tl(e){return nr(cn(e)).left+el(e).scrollLeft}function pS(e,t){var n=ot(e),r=cn(e),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var c=Zp();(c||!c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+tl(e),y:l}}function hS(e){var t,n=cn(e),r=el(e),o=(t=e.ownerDocument)==null?void 0:t.body,s=vn(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=vn(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+tl(e),l=-r.scrollTop;return Bt(o||n).direction==="rtl"&&(a+=vn(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function nl(e){var t=Bt(e),n=t.overflow,r=t.overflowX,o=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function oh(e){return["html","body","#document"].indexOf(It(e))>=0?e.ownerDocument.body:ct(e)&&nl(e)?e:oh(As(e))}function Cr(e,t){var n;t===void 0&&(t=[]);var r=oh(e),o=r===((n=e.ownerDocument)==null?void 0:n.body),s=ot(r),i=o?[s].concat(s.visualViewport||[],nl(r)?r:[]):r,a=t.concat(i);return o?a:a.concat(Cr(As(i)))}function Gi(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function mS(e,t){var n=nr(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function Hc(e,t,n){return t===Jp?Gi(pS(e,n)):An(t)?mS(t,n):Gi(hS(cn(e)))}function gS(e){var t=Cr(As(e)),n=["absolute","fixed"].indexOf(Bt(e).position)>=0,r=n&&ct(e)?Zr(e):e;return An(r)?t.filter(function(o){return An(o)&&eh(o,r)&&It(o)!=="body"}):[]}function bS(e,t,n,r){var o=t==="clippingParents"?gS(e):[].concat(t),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,c){var u=Hc(e,c,r);return l.top=vn(u.top,l.top),l.right=os(u.right,l.right),l.bottom=os(u.bottom,l.bottom),l.left=vn(u.left,l.left),l},Hc(e,i,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function sh(e){var t=e.reference,n=e.element,r=e.placement,o=r?Rt(r):null,s=r?rr(r):null,i=t.x+t.width/2-n.width/2,a=t.y+t.height/2-n.height/2,l;switch(o){case Ue:l={x:i,y:t.y-n.height};break;case ut:l={x:i,y:t.y+t.height};break;case dt:l={x:t.x+t.width,y:a};break;case Ge:l={x:t.x-n.width,y:a};break;default:l={x:t.x,y:t.y}}var c=o?Za(o):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case er:l[c]=l[c]-(t[u]/2-n[u]/2);break;case Dr:l[c]=l[c]+(t[u]/2-n[u]/2);break}}return l}function jr(e,t){t===void 0&&(t={});var n=t,r=n.placement,o=r===void 0?e.placement:r,s=n.strategy,i=s===void 0?e.strategy:s,a=n.boundary,l=a===void 0?_C:a,c=n.rootBoundary,u=c===void 0?Jp:c,d=n.elementContext,f=d===void 0?fr:d,p=n.altBoundary,m=p===void 0?!1:p,g=n.padding,b=g===void 0?0:g,x=nh(typeof b!="number"?b:rh(b,Qr)),S=f===fr?$C:fr,k=e.rects.popper,y=e.elements[m?S:f],A=bS(An(y)?y:y.contextElement||cn(e.elements.popper),l,u,i),w=nr(e.elements.reference),C=sh({reference:w,element:k,placement:o}),T=Gi(Object.assign({},k,C)),I=f===fr?T:w,O={top:A.top-I.top+x.top,bottom:I.bottom-A.bottom+x.bottom,left:A.left-I.left+x.left,right:I.right-A.right+x.right},j=e.modifiersData.offset;if(f===fr&&j){var D=j[o];Object.keys(O).forEach(function(F){var B=[dt,ut].indexOf(F)>=0?1:-1,N=[Ue,ut].indexOf(F)>=0?"y":"x";O[F]+=D[N]*B})}return O}function yS(e,t){t===void 0&&(t={});var n=t,r=n.placement,o=n.boundary,s=n.rootBoundary,i=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=l===void 0?Yp:l,u=rr(r),d=u?a?_c:_c.filter(function(m){return rr(m)===u}):Qr,f=d.filter(function(m){return c.indexOf(m)>=0});f.length===0&&(f=d);var p=f.reduce(function(m,g){return m[g]=jr(e,{placement:g,boundary:o,rootBoundary:s,padding:i})[Rt(g)],m},{});return Object.keys(p).sort(function(m,g){return p[m]-p[g]})}function xS(e){if(Rt(e)===Ja)return[];var t=jo(e);return[Bc(e),t,Bc(t)]}function vS(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!0:i,l=n.fallbackPlacements,c=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,m=p===void 0?!0:p,g=n.allowedAutoPlacements,b=t.options.placement,x=Rt(b),S=x===b,k=l||(S||!m?[jo(b)]:xS(b)),y=[b].concat(k).reduce(function(le,te){return le.concat(Rt(te)===Ja?yS(t,{placement:te,boundary:u,rootBoundary:d,padding:c,flipVariations:m,allowedAutoPlacements:g}):te)},[]),A=t.rects.reference,w=t.rects.popper,C=new Map,T=!0,I=y[0],O=0;O<y.length;O++){var j=y[O],D=Rt(j),F=rr(j)===er,B=[Ue,ut].indexOf(D)>=0,N=B?"width":"height",$=jr(t,{placement:j,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),V=B?F?dt:Ge:F?ut:Ue;A[N]>w[N]&&(V=jo(V));var _=jo(V),R=[];if(s&&R.push($[D]<=0),a&&R.push($[V]<=0,$[_]<=0),R.every(function(le){return le})){I=j,T=!1;break}C.set(j,R)}if(T)for(var z=m?3:1,W=function(te){var G=y.find(function(H){var J=C.get(H);if(J)return J.slice(0,te).every(function(oe){return oe})});if(G)return I=G,"break"},re=z;re>0;re--){var se=W(re);if(se==="break")break}t.placement!==I&&(t.modifiersData[r]._skip=!0,t.placement=I,t.reset=!0)}}const wS={name:"flip",enabled:!0,phase:"main",fn:vS,requiresIfExists:["offset"],data:{_skip:!1}};function Wc(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Vc(e){return[Ue,dt,ut,Ge].some(function(t){return e[t]>=0})}function kS(e){var t=e.state,n=e.name,r=t.rects.reference,o=t.rects.popper,s=t.modifiersData.preventOverflow,i=jr(t,{elementContext:"reference"}),a=jr(t,{altBoundary:!0}),l=Wc(i,r),c=Wc(a,o,s),u=Vc(l),d=Vc(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const CS={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:kS};function SS(e,t,n){var r=Rt(e),o=[Ge,Ue].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,i=s[0],a=s[1];return i=i||0,a=(a||0)*o,[Ge,dt].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function TS(e){var t=e.state,n=e.options,r=e.name,o=n.offset,s=o===void 0?[0,0]:o,i=Yp.reduce(function(u,d){return u[d]=SS(d,t.rects,s),u},{}),a=i[t.placement],l=a.x,c=a.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=i}const AS={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:TS};function ES(e){var t=e.state,n=e.name;t.modifiersData[n]=sh({reference:t.rects.reference,element:t.rects.popper,placement:t.placement})}const MS={name:"popperOffsets",enabled:!0,phase:"read",fn:ES,data:{}};function RS(e){return e==="x"?"y":"x"}function NS(e){var t=e.state,n=e.options,r=e.name,o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!1:i,l=n.boundary,c=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0?!0:f,m=n.tetherOffset,g=m===void 0?0:m,b=jr(t,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),x=Rt(t.placement),S=rr(t.placement),k=!S,y=Za(x),A=RS(y),w=t.modifiersData.popperOffsets,C=t.rects.reference,T=t.rects.popper,I=typeof g=="function"?g(Object.assign({},t.rects,{placement:t.placement})):g,O=typeof I=="number"?{mainAxis:I,altAxis:I}:Object.assign({mainAxis:0,altAxis:0},I),j=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,D={x:0,y:0};if(w){if(s){var F,B=y==="y"?Ue:Ge,N=y==="y"?ut:dt,$=y==="y"?"height":"width",V=w[y],_=V+b[B],R=V-b[N],z=p?-T[$]/2:0,W=S===er?C[$]:T[$],re=S===er?-T[$]:-C[$],se=t.elements.arrow,le=p&&se?Qa(se):{width:0,height:0},te=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:th(),G=te[B],H=te[N],J=kr(0,C[$],le[$]),oe=k?C[$]/2-z-J-G-O.mainAxis:W-J-G-O.mainAxis,ge=k?-C[$]/2+z+J+H+O.mainAxis:re+J+H+O.mainAxis,Ce=t.elements.arrow&&Zr(t.elements.arrow),ve=Ce?y==="y"?Ce.clientTop||0:Ce.clientLeft||0:0,we=(F=j?.[y])!=null?F:0,Ee=V+oe-we-ve,st=V+ge-we,Xe=kr(p?os(_,Ee):_,V,p?vn(R,st):R);w[y]=Xe,D[y]=Xe-V}if(a){var qe,ye=y==="x"?Ue:Ge,Re=y==="x"?ut:dt,Pe=w[A],Te=A==="y"?"height":"width",_e=Pe+b[ye],Dt=Pe-b[Re],Vt=[Ue,Ge].indexOf(x)!==-1,un=(qe=j?.[A])!=null?qe:0,xe=Vt?_e:Pe-C[Te]-T[Te]-un+O.altAxis,Je=Vt?Pe+C[Te]+T[Te]-un-O.altAxis:Dt,qt=p&&Vt?eS(xe,Pe,Je):kr(p?xe:_e,Pe,p?Je:Dt);w[A]=qt,D[A]=qt-Pe}t.modifiersData[r]=D}}const OS={name:"preventOverflow",enabled:!0,phase:"main",fn:NS,requiresIfExists:["offset"]};function IS(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function PS(e){return e===ot(e)||!ct(e)?el(e):IS(e)}function LS(e){var t=e.getBoundingClientRect(),n=tr(t.width)/e.offsetWidth||1,r=tr(t.height)/e.offsetHeight||1;return n!==1||r!==1}function DS(e,t,n){n===void 0&&(n=!1);var r=ct(t),o=ct(t)&&LS(t),s=cn(t),i=nr(e,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((It(t)!=="body"||nl(s))&&(a=PS(t)),ct(t)?(l=nr(t,!0),l.x+=t.clientLeft,l.y+=t.clientTop):s&&(l.x=tl(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function jS(e){var t=new Map,n=new Set,r=[];e.forEach(function(s){t.set(s.name,s)});function o(s){n.add(s.name);var i=[].concat(s.requires||[],s.requiresIfExists||[]);i.forEach(function(a){if(!n.has(a)){var l=t.get(a);l&&o(l)}}),r.push(s)}return e.forEach(function(s){n.has(s.name)||o(s)}),r}function zS(e){var t=jS(e);return XC.reduce(function(n,r){return n.concat(t.filter(function(o){return o.phase===r}))},[])}function _S(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function $S(e){var t=e.reduce(function(n,r){var o=n[r.name];return n[r.name]=o?Object.assign({},o,r,{options:Object.assign({},o.options,r.options),data:Object.assign({},o.data,r.data)}):r,n},{});return Object.keys(t).map(function(n){return t[n]})}var qc={placement:"bottom",modifiers:[],strategy:"absolute"};function Kc(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function FS(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,o=t.defaultOptions,s=o===void 0?qc:o;return function(a,l,c){c===void 0&&(c=s);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},qc,s),modifiersData:{},elements:{reference:a,popper:l},attributes:{},styles:{}},d=[],f=!1,p={state:u,setOptions:function(x){var S=typeof x=="function"?x(u.options):x;g(),u.options=Object.assign({},s,u.options,S),u.scrollParents={reference:An(a)?Cr(a):a.contextElement?Cr(a.contextElement):[],popper:Cr(l)};var k=zS($S([].concat(r,u.options.modifiers)));return u.orderedModifiers=k.filter(function(y){return y.enabled}),m(),p.update()},forceUpdate:function(){if(!f){var x=u.elements,S=x.reference,k=x.popper;if(Kc(S,k)){u.rects={reference:DS(S,Zr(k),u.options.strategy==="fixed"),popper:Qa(k)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach(function(O){return u.modifiersData[O.name]=Object.assign({},O.data)});for(var y=0;y<u.orderedModifiers.length;y++){if(u.reset===!0){u.reset=!1,y=-1;continue}var A=u.orderedModifiers[y],w=A.fn,C=A.options,T=C===void 0?{}:C,I=A.name;typeof w=="function"&&(u=w({state:u,options:T,name:I,instance:p})||u)}}}},update:_S(function(){return new Promise(function(b){p.forceUpdate(),b(u)})}),destroy:function(){g(),f=!0}};if(!Kc(a,l))return p;p.setOptions(c).then(function(b){!f&&c.onFirstUpdate&&c.onFirstUpdate(b)});function m(){u.orderedModifiers.forEach(function(b){var x=b.name,S=b.options,k=S===void 0?{}:S,y=b.effect;if(typeof y=="function"){var A=y({state:u,name:x,instance:p,options:k}),w=function(){};d.push(A||w)}})}function g(){d.forEach(function(b){return b()}),d=[]}return p}}var BS=[uS,MS,lS,Qp,AS,wS,OS,oS,CS],HS=FS({defaultModifiers:BS}),WS="tippy-box",ih="tippy-content",VS="tippy-backdrop",ah="tippy-arrow",lh="tippy-svg-arrow",mn={passive:!0,capture:!0},ch=function(){return document.body};function qS(e,t){return{}.hasOwnProperty.call(e,t)}function ii(e,t,n){if(Array.isArray(e)){var r=e[t];return r??(Array.isArray(n)?n[t]:n)}return e}function rl(e,t){var n={}.toString.call(e);return n.indexOf("[object")===0&&n.indexOf(t+"]")>-1}function uh(e,t){return typeof e=="function"?e.apply(void 0,t):e}function Uc(e,t){if(t===0)return e;var n;return function(r){clearTimeout(n),n=setTimeout(function(){e(r)},t)}}function KS(e,t){var n=Object.assign({},e);return t.forEach(function(r){delete n[r]}),n}function US(e){return e.split(/\s+/).filter(Boolean)}function Wn(e){return[].concat(e)}function Gc(e,t){e.indexOf(t)===-1&&e.push(t)}function GS(e){return e.filter(function(t,n){return e.indexOf(t)===n})}function XS(e){return e.split("-")[0]}function ss(e){return[].slice.call(e)}function Xc(e){return Object.keys(e).reduce(function(t,n){return e[n]!==void 0&&(t[n]=e[n]),t},{})}function Sr(){return document.createElement("div")}function zr(e){return["Element","Fragment"].some(function(t){return rl(e,t)})}function JS(e){return rl(e,"NodeList")}function YS(e){return rl(e,"MouseEvent")}function QS(e){return!!(e&&e._tippy&&e._tippy.reference===e)}function ZS(e){return zr(e)?[e]:JS(e)?ss(e):Array.isArray(e)?e:ss(document.querySelectorAll(e))}function ai(e,t){e.forEach(function(n){n&&(n.style.transitionDuration=t+"ms")})}function Jc(e,t){e.forEach(function(n){n&&n.setAttribute("data-state",t)})}function e1(e){var t,n=Wn(e),r=n[0];return r!=null&&(t=r.ownerDocument)!=null&&t.body?r.ownerDocument:document}function t1(e,t){var n=t.clientX,r=t.clientY;return e.every(function(o){var s=o.popperRect,i=o.popperState,a=o.props,l=a.interactiveBorder,c=XS(i.placement),u=i.modifiersData.offset;if(!u)return!0;var d=c==="bottom"?u.top.y:0,f=c==="top"?u.bottom.y:0,p=c==="right"?u.left.x:0,m=c==="left"?u.right.x:0,g=s.top-r+d>l,b=r-s.bottom-f>l,x=s.left-n+p>l,S=n-s.right-m>l;return g||b||x||S})}function li(e,t,n){var r=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(o){e[r](o,n)})}function Yc(e,t){for(var n=t;n;){var r;if(e.contains(n))return!0;n=n.getRootNode==null||(r=n.getRootNode())==null?void 0:r.host}return!1}var Ct={isTouch:!1},Qc=0;function n1(){Ct.isTouch||(Ct.isTouch=!0,window.performance&&document.addEventListener("mousemove",dh))}function dh(){var e=performance.now();e-Qc<20&&(Ct.isTouch=!1,document.removeEventListener("mousemove",dh)),Qc=e}function r1(){var e=document.activeElement;if(QS(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}function o1(){document.addEventListener("touchstart",n1,mn),window.addEventListener("blur",r1)}var s1=typeof window<"u"&&typeof document<"u",i1=s1?!!window.msCrypto:!1;function $n(e){var t=e==="destroy"?"n already-":" ";return[e+"() was called on a"+t+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function Zc(e){var t=/[ \t]{2,}/g,n=/^[ \t]*/gm;return e.replace(t," ").replace(n,"").trim()}function a1(e){return Zc(`
|
|
130
130
|
%ctippy.js
|
|
131
131
|
|
|
132
|
-
%c`+
|
|
132
|
+
%c`+Zc(e)+`
|
|
133
133
|
|
|
134
134
|
%c👷 This is a development-only message. It will be removed in production.
|
|
135
|
-
`)}function
|
|
135
|
+
`)}function fh(e){return[a1(e),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var _r;process.env.NODE_ENV!=="production"&&l1();function l1(){_r=new Set}function _t(e,t){if(e&&!_r.has(t)){var n;_r.add(t),(n=console).warn.apply(n,fh(t))}}function Xi(e,t){if(e&&!_r.has(t)){var n;_r.add(t),(n=console).error.apply(n,fh(t))}}function c1(e){var t=!e,n=Object.prototype.toString.call(e)==="[object Object]"&&!e.addEventListener;Xi(t,["tippy() was passed","`"+String(e)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),Xi(n,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var ph={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},u1={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},et=Object.assign({appendTo:ch,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},ph,u1),d1=Object.keys(et),f1=function(t){process.env.NODE_ENV!=="production"&&mh(t,[]);var n=Object.keys(t);n.forEach(function(r){et[r]=t[r]})};function hh(e){var t=e.plugins||[],n=t.reduce(function(r,o){var s=o.name,i=o.defaultValue;if(s){var a;r[s]=e[s]!==void 0?e[s]:(a=et[s])!=null?a:i}return r},{});return Object.assign({},e,n)}function p1(e,t){var n=t?Object.keys(hh(Object.assign({},et,{plugins:t}))):d1,r=n.reduce(function(o,s){var i=(e.getAttribute("data-tippy-"+s)||"").trim();if(!i)return o;if(s==="content")o[s]=i;else try{o[s]=JSON.parse(i)}catch{o[s]=i}return o},{});return r}function eu(e,t){var n=Object.assign({},t,{content:uh(t.content,[e])},t.ignoreAttributes?{}:p1(e,t.plugins));return n.aria=Object.assign({},et.aria,n.aria),n.aria={expanded:n.aria.expanded==="auto"?t.interactive:n.aria.expanded,content:n.aria.content==="auto"?t.interactive?null:"describedby":n.aria.content},n}function mh(e,t){e===void 0&&(e={}),t===void 0&&(t=[]);var n=Object.keys(e);n.forEach(function(r){var o=KS(et,Object.keys(ph)),s=!qS(o,r);s&&(s=t.filter(function(i){return i.name===r}).length===0),_t(s,["`"+r+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.",`
|
|
136
136
|
|
|
137
137
|
`,`All props: https://atomiks.github.io/tippyjs/v6/all-props/
|
|
138
|
-
`,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var
|
|
138
|
+
`,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var h1=function(){return"innerHTML"};function Ji(e,t){e[h1()]=t}function tu(e){var t=Sr();return e===!0?t.className=ah:(t.className=lh,zr(e)?t.appendChild(e):Ji(t,e)),t}function nu(e,t){zr(t.content)?(Ji(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Ji(e,t.content):e.textContent=t.content)}function Yi(e){var t=e.firstElementChild,n=ss(t.children);return{box:t,content:n.find(function(r){return r.classList.contains(ih)}),arrow:n.find(function(r){return r.classList.contains(ah)||r.classList.contains(lh)}),backdrop:n.find(function(r){return r.classList.contains(VS)})}}function gh(e){var t=Sr(),n=Sr();n.className=WS,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var r=Sr();r.className=ih,r.setAttribute("data-state","hidden"),nu(r,e.props),t.appendChild(n),n.appendChild(r),o(e.props,e.props);function o(s,i){var a=Yi(t),l=a.box,c=a.content,u=a.arrow;i.theme?l.setAttribute("data-theme",i.theme):l.removeAttribute("data-theme"),typeof i.animation=="string"?l.setAttribute("data-animation",i.animation):l.removeAttribute("data-animation"),i.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof i.maxWidth=="number"?i.maxWidth+"px":i.maxWidth,i.role?l.setAttribute("role",i.role):l.removeAttribute("role"),(s.content!==i.content||s.allowHTML!==i.allowHTML)&&nu(c,e.props),i.arrow?u?s.arrow!==i.arrow&&(l.removeChild(u),l.appendChild(tu(i.arrow))):l.appendChild(tu(i.arrow)):u&&l.removeChild(u)}return{popper:t,onUpdate:o}}gh.$$tippy=!0;var m1=1,Ao=[],ci=[];function g1(e,t){var n=eu(e,Object.assign({},et,hh(Xc(t)))),r,o,s,i=!1,a=!1,l=!1,c=!1,u,d,f,p=[],m=Uc(Ee,n.interactiveDebounce),g,b=m1++,x=null,S=GS(n.plugins),k={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:b,reference:e,popper:Sr(),popperInstance:x,props:n,state:k,plugins:S,clearDelayTimeouts:xe,setProps:Je,setContent:qt,show:to,hide:no,hideWithInteractivity:dn,enable:Vt,disable:un,unmount:L,destroy:ne};if(!n.render)return process.env.NODE_ENV!=="production"&&Xi(!0,"render() function has not been supplied."),y;var A=n.render(y),w=A.popper,C=A.onUpdate;w.setAttribute("data-tippy-root",""),w.id="tippy-"+y.id,y.popper=w,e._tippy=y,w._tippy=y;var T=S.map(function(E){return E.fn(y)}),I=e.hasAttribute("aria-expanded");return Ce(),z(),V(),_("onCreate",[y]),n.showOnCreate&&_e(),w.addEventListener("mouseenter",function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()}),w.addEventListener("mouseleave",function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&B().addEventListener("mousemove",m)}),y;function O(){var E=y.props.touch;return Array.isArray(E)?E:[E,0]}function j(){return O()[0]==="hold"}function D(){var E;return!!((E=y.props.render)!=null&&E.$$tippy)}function F(){return g||e}function B(){var E=F().parentNode;return E?e1(E):document}function N(){return Yi(w)}function $(E){return y.state.isMounted&&!y.state.isVisible||Ct.isTouch||u&&u.type==="focus"?0:ii(y.props.delay,E?0:1,et.delay)}function V(E){E===void 0&&(E=!1),w.style.pointerEvents=y.props.interactive&&!E?"":"none",w.style.zIndex=""+y.props.zIndex}function _(E,U,ee){if(ee===void 0&&(ee=!0),T.forEach(function(ue){ue[E]&&ue[E].apply(ue,U)}),ee){var fe;(fe=y.props)[E].apply(fe,U)}}function R(){var E=y.props.aria;if(E.content){var U="aria-"+E.content,ee=w.id,fe=Wn(y.props.triggerTarget||e);fe.forEach(function(ue){var $e=ue.getAttribute(U);if(y.state.isVisible)ue.setAttribute(U,$e?$e+" "+ee:ee);else{var it=$e&&$e.replace(ee,"").trim();it?ue.setAttribute(U,it):ue.removeAttribute(U)}})}}function z(){if(!(I||!y.props.aria.expanded)){var E=Wn(y.props.triggerTarget||e);E.forEach(function(U){y.props.interactive?U.setAttribute("aria-expanded",y.state.isVisible&&U===F()?"true":"false"):U.removeAttribute("aria-expanded")})}}function W(){B().removeEventListener("mousemove",m),Ao=Ao.filter(function(E){return E!==m})}function re(E){if(!(Ct.isTouch&&(l||E.type==="mousedown"))){var U=E.composedPath&&E.composedPath()[0]||E.target;if(!(y.props.interactive&&Yc(w,U))){if(Wn(y.props.triggerTarget||e).some(function(ee){return Yc(ee,U)})){if(Ct.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else _("onClickOutside",[y,E]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),a=!0,setTimeout(function(){a=!1}),y.state.isMounted||G())}}}function se(){l=!0}function le(){l=!1}function te(){var E=B();E.addEventListener("mousedown",re,!0),E.addEventListener("touchend",re,mn),E.addEventListener("touchstart",le,mn),E.addEventListener("touchmove",se,mn)}function G(){var E=B();E.removeEventListener("mousedown",re,!0),E.removeEventListener("touchend",re,mn),E.removeEventListener("touchstart",le,mn),E.removeEventListener("touchmove",se,mn)}function H(E,U){oe(E,function(){!y.state.isVisible&&w.parentNode&&w.parentNode.contains(w)&&U()})}function J(E,U){oe(E,U)}function oe(E,U){var ee=N().box;function fe(ue){ue.target===ee&&(li(ee,"remove",fe),U())}if(E===0)return U();li(ee,"remove",d),li(ee,"add",fe),d=fe}function ge(E,U,ee){ee===void 0&&(ee=!1);var fe=Wn(y.props.triggerTarget||e);fe.forEach(function(ue){ue.addEventListener(E,U,ee),p.push({node:ue,eventType:E,handler:U,options:ee})})}function Ce(){j()&&(ge("touchstart",we,{passive:!0}),ge("touchend",st,{passive:!0})),US(y.props.trigger).forEach(function(E){if(E!=="manual")switch(ge(E,we),E){case"mouseenter":ge("mouseleave",st);break;case"focus":ge(i1?"focusout":"blur",Xe);break;case"focusin":ge("focusout",Xe);break}})}function ve(){p.forEach(function(E){var U=E.node,ee=E.eventType,fe=E.handler,ue=E.options;U.removeEventListener(ee,fe,ue)}),p=[]}function we(E){var U,ee=!1;if(!(!y.state.isEnabled||qe(E)||a)){var fe=((U=u)==null?void 0:U.type)==="focus";u=E,g=E.currentTarget,z(),!y.state.isVisible&&YS(E)&&Ao.forEach(function(ue){return ue(E)}),E.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||i)&&y.props.hideOnClick!==!1&&y.state.isVisible?ee=!0:_e(E),E.type==="click"&&(i=!ee),ee&&!fe&&Dt(E)}}function Ee(E){var U=E.target,ee=F().contains(U)||w.contains(U);if(!(E.type==="mousemove"&&ee)){var fe=Te().concat(w).map(function(ue){var $e,it=ue._tippy,Pn=($e=it.popperInstance)==null?void 0:$e.state;return Pn?{popperRect:ue.getBoundingClientRect(),popperState:Pn,props:n}:null}).filter(Boolean);t1(fe,E)&&(W(),Dt(E))}}function st(E){var U=qe(E)||y.props.trigger.indexOf("click")>=0&&i;if(!U){if(y.props.interactive){y.hideWithInteractivity(E);return}Dt(E)}}function Xe(E){y.props.trigger.indexOf("focusin")<0&&E.target!==F()||y.props.interactive&&E.relatedTarget&&w.contains(E.relatedTarget)||Dt(E)}function qe(E){return Ct.isTouch?j()!==E.type.indexOf("touch")>=0:!1}function ye(){Re();var E=y.props,U=E.popperOptions,ee=E.placement,fe=E.offset,ue=E.getReferenceClientRect,$e=E.moveTransition,it=D()?Yi(w).arrow:null,Pn=ue?{getBoundingClientRect:ue,contextElement:ue.contextElement||F()}:e,ol={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(ro){var Ln=ro.state;if(D()){var Sh=N(),Ms=Sh.box;["placement","reference-hidden","escaped"].forEach(function(oo){oo==="placement"?Ms.setAttribute("data-placement",Ln.placement):Ln.attributes.popper["data-popper-"+oo]?Ms.setAttribute("data-"+oo,""):Ms.removeAttribute("data-"+oo)}),Ln.attributes.popper={}}}},fn=[{name:"offset",options:{offset:fe}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!$e}},ol];D()&&it&&fn.push({name:"arrow",options:{element:it,padding:3}}),fn.push.apply(fn,U?.modifiers||[]),y.popperInstance=HS(Pn,w,Object.assign({},U,{placement:ee,onFirstUpdate:f,modifiers:fn}))}function Re(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function Pe(){var E=y.props.appendTo,U,ee=F();y.props.interactive&&E===ch||E==="parent"?U=ee.parentNode:U=uh(E,[ee]),U.contains(w)||U.appendChild(w),y.state.isMounted=!0,ye(),process.env.NODE_ENV!=="production"&&_t(y.props.interactive&&E===et.appendTo&&ee.nextElementSibling!==w,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",`
|
|
139
139
|
|
|
140
140
|
`,"Using a wrapper <div> or <span> tag around the reference element","solves this by creating a new parentNode context.",`
|
|
141
141
|
|
|
142
142
|
`,"Specifying `appendTo: document.body` silences this warning, but it","assumes you are using a focus management solution to handle","keyboard navigation.",`
|
|
143
143
|
|
|
144
|
-
`,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function Te(){return
|
|
144
|
+
`,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function Te(){return ss(w.querySelectorAll("[data-tippy-root]"))}function _e(E){y.clearDelayTimeouts(),E&&_("onTrigger",[y,E]),te();var U=$(!0),ee=O(),fe=ee[0],ue=ee[1];Ct.isTouch&&fe==="hold"&&ue&&(U=ue),U?r=setTimeout(function(){y.show()},U):y.show()}function Dt(E){if(y.clearDelayTimeouts(),_("onUntrigger",[y,E]),!y.state.isVisible){G();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(E.type)>=0&&i)){var U=$(!1);U?o=setTimeout(function(){y.state.isVisible&&y.hide()},U):s=requestAnimationFrame(function(){y.hide()})}}function Vt(){y.state.isEnabled=!0}function un(){y.hide(),y.state.isEnabled=!1}function xe(){clearTimeout(r),clearTimeout(o),cancelAnimationFrame(s)}function Je(E){if(process.env.NODE_ENV!=="production"&&_t(y.state.isDestroyed,$n("setProps")),!y.state.isDestroyed){_("onBeforeUpdate",[y,E]),ve();var U=y.props,ee=eu(e,Object.assign({},U,Xc(E),{ignoreAttributes:!0}));y.props=ee,Ce(),U.interactiveDebounce!==ee.interactiveDebounce&&(W(),m=Uc(Ee,ee.interactiveDebounce)),U.triggerTarget&&!ee.triggerTarget?Wn(U.triggerTarget).forEach(function(fe){fe.removeAttribute("aria-expanded")}):ee.triggerTarget&&e.removeAttribute("aria-expanded"),z(),V(),C&&C(U,ee),y.popperInstance&&(ye(),Te().forEach(function(fe){requestAnimationFrame(fe._tippy.popperInstance.forceUpdate)})),_("onAfterUpdate",[y,E])}}function qt(E){y.setProps({content:E})}function to(){process.env.NODE_ENV!=="production"&&_t(y.state.isDestroyed,$n("show"));var E=y.state.isVisible,U=y.state.isDestroyed,ee=!y.state.isEnabled,fe=Ct.isTouch&&!y.props.touch,ue=ii(y.props.duration,0,et.duration);if(!(E||U||ee||fe)&&!F().hasAttribute("disabled")&&(_("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,D()&&(w.style.visibility="visible"),V(),te(),y.state.isMounted||(w.style.transition="none"),D()){var $e=N(),it=$e.box,Pn=$e.content;ai([it,Pn],0)}f=function(){var fn;if(!(!y.state.isVisible||c)){if(c=!0,w.offsetHeight,w.style.transition=y.props.moveTransition,D()&&y.props.animation){var Es=N(),ro=Es.box,Ln=Es.content;ai([ro,Ln],ue),Jc([ro,Ln],"visible")}R(),z(),Gc(ci,y),(fn=y.popperInstance)==null||fn.forceUpdate(),_("onMount",[y]),y.props.animation&&D()&&J(ue,function(){y.state.isShown=!0,_("onShown",[y])})}},Pe()}}function no(){process.env.NODE_ENV!=="production"&&_t(y.state.isDestroyed,$n("hide"));var E=!y.state.isVisible,U=y.state.isDestroyed,ee=!y.state.isEnabled,fe=ii(y.props.duration,1,et.duration);if(!(E||U||ee)&&(_("onHide",[y],!1),y.props.onHide(y)!==!1)){if(y.state.isVisible=!1,y.state.isShown=!1,c=!1,i=!1,D()&&(w.style.visibility="hidden"),W(),G(),V(!0),D()){var ue=N(),$e=ue.box,it=ue.content;y.props.animation&&(ai([$e,it],fe),Jc([$e,it],"hidden"))}R(),z(),y.props.animation?D()&&H(fe,y.unmount):y.unmount()}}function dn(E){process.env.NODE_ENV!=="production"&&_t(y.state.isDestroyed,$n("hideWithInteractivity")),B().addEventListener("mousemove",m),Gc(Ao,m),m(E)}function L(){process.env.NODE_ENV!=="production"&&_t(y.state.isDestroyed,$n("unmount")),y.state.isVisible&&y.hide(),y.state.isMounted&&(Re(),Te().forEach(function(E){E._tippy.unmount()}),w.parentNode&&w.parentNode.removeChild(w),ci=ci.filter(function(E){return E!==y}),y.state.isMounted=!1,_("onHidden",[y]))}function ne(){process.env.NODE_ENV!=="production"&&_t(y.state.isDestroyed,$n("destroy")),!y.state.isDestroyed&&(y.clearDelayTimeouts(),y.unmount(),ve(),delete e._tippy,y.state.isDestroyed=!0,_("onDestroy",[y]))}}function eo(e,t){t===void 0&&(t={});var n=et.plugins.concat(t.plugins||[]);process.env.NODE_ENV!=="production"&&(c1(e),mh(t,n)),o1();var r=Object.assign({},t,{plugins:n}),o=ZS(e);if(process.env.NODE_ENV!=="production"){var s=zr(r.content),i=o.length>1;_t(s&&i,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.",`
|
|
145
145
|
|
|
146
146
|
`,"Instead, pass the .innerHTML of the element, or use a function that","returns a cloned version of the element instead.",`
|
|
147
147
|
|
|
148
148
|
`,`1) content: element.innerHTML
|
|
149
|
-
`,"2) content: () => element.cloneNode(true)"].join(" "))}var a=o.reduce(function(l,c){var u=c&&h1(c,r);return u&&l.push(u),l},[]);return zr(e)?a[0]:a}Zr.defaultProps=et;Zr.setDefaultProps=u1;Zr.currentInput=Ct;Object.assign({},Jp,{effect:function(t){var n=t.state,r={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,r.popper),n.styles=r,n.elements.arrow&&Object.assign(n.elements.arrow.style,r.arrow)}});Zr.setDefaultProps({render:hh});const mh=K.forwardRef(({items:e,command:t,classNames:n,noResults:r},o)=>{const[s,i]=K.useState(0),a=We(),l=Vr(),c=Ve(),u=n??c,d=r??l.noResults;K.useEffect(()=>{i(0)},[e]);const f=p=>{const m=e[p];m&&t(m)};return K.useImperativeHandle(o,()=>({onKeyDown:p=>e.length?p.key==="ArrowUp"?(p.preventDefault(),i(m=>(m+e.length-1)%e.length),!0):p.key==="ArrowDown"?(p.preventDefault(),i(m=>(m+1)%e.length),!0):p.key==="Enter"?(p.preventDefault(),f(s),!0):!1:!1})),h.jsx("div",{className:M("z-[9999] min-w-[14rem] overflow-hidden rounded-3xl border p-1.5 shadow-xl backdrop-blur-xl space-y-1 animate-in fade-in zoom-in-95",a==="dark"?"bg-neutral-900/95 border-neutral-800 shadow-black/50 text-neutral-200":"bg-white/95 border-neutral-200/60 text-neutral-700",u?.slashCommandMenu),children:e.length?e.map((p,m)=>h.jsxs("button",{type:"button",onClick:()=>f(m),"aria-selected":s===m,className:M("relative flex w-full cursor-pointer select-none items-center rounded-full px-3 py-2 text-sm outline-none transition-colors gap-2",s===m?a==="dark"?"bg-neutral-800 text-neutral-100":"bg-neutral-100 text-neutral-900":a==="dark"?"text-neutral-300 hover:bg-neutral-800 hover:text-neutral-100":"text-neutral-600 hover:bg-neutral-100 hover:text-neutral-900",s===m&&u?.slashCommandItemActive,u?.slashCommandItem),children:[h.jsx("div",{className:M("flex h-6 w-6 items-center justify-center rounded-sm mr-2",a==="dark"?"bg-neutral-800 border border-neutral-700":"bg-white border border-neutral-200 shadow-sm",u?.slashCommandIcon),children:h.jsx(p.icon,{className:"size-4"})}),h.jsx("span",{className:M("font-medium",u?.slashCommandTitle),children:p.title})]},p.title)):h.jsxs("div",{className:M("flex items-center px-2 py-1.5 text-sm text-neutral-500",u?.slashCommandEmpty),children:[h.jsx(q.Ban,{className:M("mr-2 size-4",u?.slashCommandEmptyIcon)}),d]})})});mh.displayName="CommandsList";const m1=async({editor:e,range:t,onRequestImage:n,onInsertLocalImageFile:r,imageSlashFallback:o="prompt-url",translations:s})=>{const i=s||Xn;let a=null;if(n)a=await n({editor:e,range:t});else if(o==="prompt-url"){const c=window.prompt(i.imageUrlPrompt)?.trim();a=c?{kind:"url",src:c}:null}if(!a)return;if(a.kind==="file"){if(!r)return;e.chain().focus().deleteRange(t).run();const c={editor:e,range:t,file:a.file,...a.alt?{alt:a.alt}:{},...a.title?{title:a.title}:{}};await r(c);return}const l={src:a.src,...a.alt?{alt:a.alt}:{},...a.title?{title:a.title}:{}};e.chain().focus().deleteRange(t).setNode("image",l).run()},g1=e=>{const t=e.translations||Xn;return[{title:t.text,icon:q.Pilcrow,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).setParagraph().run()},{title:t.heading1,icon:q.Heading1,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).setHeading({level:1}).run()},{title:t.heading2,icon:q.Heading2,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).setHeading({level:2}).run()},{title:t.heading3,icon:q.Heading3,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).setHeading({level:3}).run()},{title:t.bulletList,icon:q.List,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).toggleBulletList().run()},{title:t.numberedList,icon:q.ListOrdered,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).toggleOrderedList().run()},{title:t.image,icon:q.Image,command:({editor:n,range:r})=>{m1({editor:n,range:r,onRequestImage:e.onRequestImage??null,onInsertLocalImageFile:e.onInsertLocalImageFile??null,imageSlashFallback:e.imageSlashFallback??"prompt-url",translations:e.translations})}},{title:t.table,icon:q.Table,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:t.quote,icon:q.Quote,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).toggleBlockquote().run()},{title:t.code,icon:q.Code,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).toggleCodeBlock().run()}]},b1=(e={})=>({items:({query:t,editor:n})=>{const r=n.isActive("tableCell")||n.isActive("tableHeader"),o=e.translations||Xn;return g1(e).filter(s=>!r||s.title===o.image).filter(s=>e.enableImages!==!1||s.title!==o.image).filter(s=>s.title.toLowerCase().includes(t.toLowerCase())).slice(0,10)},render:()=>{let t=null,n=null,r=!1,o=0;const s=c=>({...c,classNames:e.classNames,noResults:(e.translations||Xn).noResults}),i=c=>{if(!c.clientRect||!n)return;const u=()=>c.clientRect?.()??new DOMRect(0,0,0,0);n.setProps({getReferenceClientRect:u})},a=c=>{if(!r){if(!t){if(t=new Tr.ReactRenderer(mh,{props:s(c),editor:c.editor}),!c.clientRect)return;const u=()=>c.clientRect?.()??new DOMRect(0,0,0,0);n=Zr(document.body,{getReferenceClientRect:u,appendTo:()=>document.body,content:t.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"});return}t.updateProps(s(c)),i(c)}},l=c=>{const u=++o;queueMicrotask(()=>{r||u!==o||a(c)})};return{onStart:c=>{l(c)},onUpdate:c=>{l(c)},onKeyDown:({event:c})=>c.key==="Escape"&&n?(n.hide(),!0):t?.ref?.onKeyDown(c)??!1,onExit:()=>{r=!0,o+=1,n&&n.destroy(),t?.destroy()}}}}),y1=P.Extension.create({name:"slash-commands",addOptions(){return{onRequestImage:null,onInsertLocalImageFile:null,enableImages:!0,imageSlashFallback:"prompt-url"}},addProseMirrorPlugins(){const e=b1({onRequestImage:this.options.onRequestImage,onInsertLocalImageFile:this.options.onInsertLocalImageFile,enableImages:this.options.enableImages,imageSlashFallback:this.options.imageSlashFallback,translations:this.options.translations,classNames:this.options.classNames});return[DC({editor:this.editor,char:"/",command:({editor:t,range:n,props:r})=>{r.command({editor:t,range:n})},...e})]}}),x1=e=>{const{node:t,updateAttributes:n,deleteNode:r,selected:o}=e,{src:s,width:i,height:a,rotation:l,objectFit:c="contain",objectPosition:u="50% 50%",isUploading:d}=t.attrs,f=We(),p=Ve(),m=Vr(),[g,b]=K.useState(!1),[x,S]=K.useState({x:0,y:0}),[k,y]=K.useState(1),[T,w]=K.useState(null),[C,A]=K.useState(!1),[I,O]=K.useState(!1),[j,D]=K.useState(""),F=K.useRef(null),B=K.useRef(null),N=K.useRef(null),$=typeof t.attrs.alt=="string"&&t.attrs.alt.trim()?t.attrs.alt:m.imageAlt,V=()=>{if(F.current&&N.current===null){const{naturalWidth:H,naturalHeight:J}=F.current;H>0&&J>0&&(N.current=H/J)}},_=()=>{D(typeof t.attrs.alt=="string"?t.attrs.alt:"")};K.useEffect(()=>{_()},[t.attrs.alt]),K.useEffect(()=>{!o&&I&&O(!1)},[o,I]);const R=(H,J)=>{H.preventDefault(),H.stopPropagation();const oe=H.clientX,ge=H.clientY,Ce=B.current?.offsetWidth??300,ve=B.current?.offsetHeight??200,we=N.current??Ce/ve,Ee=H.shiftKey,st=qe=>{const ye=qe.clientX-oe,Re=qe.clientY-ge;if(qe.shiftKey||Ee){let Te=Math.max(80,Ce+ye),_e=J==="right"?ve:Math.max(60,ve+Re);n({width:`${Te}px`,height:J==="right"?a:`${_e}px`,objectFit:"cover"})}else if(J==="bottom"){const Te=Math.max(60,ve+Re),_e=Te*we;n({width:`${Math.round(_e)}px`,height:`${Math.round(Te)}px`,objectFit:"contain"})}else{const Te=Math.max(80,Ce+ye),_e=Te/we;n({width:`${Math.round(Te)}px`,height:`${Math.round(_e)}px`,objectFit:"contain"})}},Xe=()=>{document.removeEventListener("mousemove",st),document.removeEventListener("mouseup",Xe)};document.addEventListener("mousemove",st),document.addEventListener("mouseup",Xe)},z=H=>{if(!H.ctrlKey||c!=="cover")return;H.preventDefault(),H.stopPropagation(),A(!0);const J=H.clientX,oe=H.clientY,ge=(u||"50% 50%").split(" "),Ce=parseFloat(ge[0])??50,ve=parseFloat(ge[1])??50,we=B.current?.offsetWidth??300,Ee=B.current?.offsetHeight??200,st=qe=>{const ye=qe.clientX-J,Re=qe.clientY-oe,Pe=Math.max(0,Math.min(100,Ce-ye/we*100)),Te=Math.max(0,Math.min(100,ve-Re/Ee*100));n({objectPosition:`${Pe.toFixed(1)}% ${Te.toFixed(1)}%`})},Xe=()=>{A(!1),document.removeEventListener("mousemove",st),document.removeEventListener("mouseup",Xe)};document.addEventListener("mousemove",st),document.addEventListener("mouseup",Xe)},W=K.useCallback((H,J)=>{w(J)},[]),re=async()=>{try{const H=await k1(s,T,l);n({src:H,rotation:0}),b(!1)}catch(H){console.error(H),b(!1)}},se=()=>{const H=((l||0)+90)%360;n({rotation:H})},le=()=>{const H=j.trim();n({alt:H||null}),O(!1)},te=()=>{n({alt:null}),D(""),O(!1)},G=c==="cover";return h.jsxs(Tr.NodeViewWrapper,{className:M("relative block max-w-full my-4",p?.imageNodeWrapper),"data-drag-handle":!0,children:[h.jsx("div",{ref:B,className:M("relative group ring-2 transition-all inline-block max-w-full",o?"ring-blue-500":"ring-transparent",g&&"ring-0",p?.imageContainer),style:{width:i,minWidth:80},children:g?h.jsxs("div",{className:M("relative",p?.imageCropArea),style:{width:"100%",height:"400px",backgroundColor:"#333"},children:[h.jsx(Rh,{image:s,crop:x,zoom:k,rotation:l,aspect:4/3,onCropChange:S,onRotationChange:H=>n({rotation:H}),onZoomChange:y,onCropComplete:W}),h.jsxs("div",{className:M("absolute bottom-4 left-1/2 -translate-x-1/2 flex items-center gap-2 p-2 rounded-xl shadow-lg z-10",f==="dark"?"bg-neutral-800":"bg-white",p?.imageCropToolbar),children:[h.jsx("button",{onClick:()=>b(!1),title:m.cancel,"aria-label":m.cancel,className:M("p-2 text-red-500 rounded-full",f==="dark"?"hover:bg-neutral-700":"hover:bg-neutral-100",p?.imageCropButton,p?.imageCropCancelButton),children:h.jsx(q.X,{size:16})}),h.jsx("button",{onClick:re,title:m.apply,"aria-label":m.apply,className:M("p-2 text-green-500 rounded-full",f==="dark"?"hover:bg-neutral-700":"hover:bg-neutral-100",p?.imageCropButton,p?.imageCropApplyButton),children:h.jsx(q.Check,{size:16})})]})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:M("relative w-full",G&&"overflow-hidden",p?.imageFrame),style:{height:a==="auto"?void 0:a},children:[h.jsx("img",{ref:F,src:s,alt:$,onLoad:V,onMouseDown:z,className:M("block max-w-full rounded select-none",G&&"w-full h-full",C&&"cursor-grabbing",!C&&G&&"cursor-grab",d&&"opacity-50 blur-[2px] grayscale-[0.5]",p?.imageElement),style:{width:G?"100%":i,height:G?"100%":a,objectFit:G?"cover":void 0,objectPosition:G?u:void 0,transform:l?`rotate(${l}deg)`:void 0,transition:o?"none":"transform 0.2s, filter 0.2s, opacity 0.2s"}}),d&&h.jsx("div",{className:M("absolute inset-0 flex items-center justify-center z-10 pointer-events-none",p?.imageLoadingOverlay),children:h.jsx("div",{className:M("flex items-center justify-center p-3 rounded-2xl shadow-xl backdrop-blur-md",f==="dark"?"bg-black/50":"bg-white/60",p?.imageLoadingBox),children:h.jsx(q.Loader2,{className:M("w-8 h-8 animate-spin",f==="dark"?"text-white":"text-neutral-800",p?.imageLoadingIcon)})})}),o&&G&&!d&&h.jsx("div",{className:M("absolute inset-0 flex items-end justify-center pb-2 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity",p?.imagePanHintOverlay),children:h.jsx("span",{className:M("text-[10px] px-2 py-0.5 rounded-full font-medium",f==="dark"?"bg-black/60 text-neutral-300":"bg-white/80 text-neutral-500",p?.imagePanHint),children:m.imagePanHint})})]}),o&&h.jsxs("div",{className:M("absolute top-2 right-2 flex items-center gap-1 backdrop-blur border p-1 rounded-xl shadow-sm opacity-0 group-hover:opacity-100 transition-opacity z-10",f==="dark"?"bg-neutral-800/90 border-neutral-700":"bg-white/90 border-neutral-200",p?.imageToolbar),children:[h.jsx("button",{type:"button",onClick:se,title:m.rotate,"aria-label":m.rotate,className:M("p-1.5 rounded-full",f==="dark"?"hover:bg-neutral-700 text-neutral-300":"hover:bg-neutral-100 text-neutral-600",p?.imageToolbarButton),children:h.jsx(q.RotateCw,{size:14})}),h.jsx("button",{type:"button",onClick:()=>b(!0),title:m.crop,"aria-label":m.crop,className:M("p-1.5 rounded-full",f==="dark"?"hover:bg-neutral-700 text-neutral-300":"hover:bg-neutral-100 text-neutral-600",p?.imageToolbarButton),children:h.jsx(q.Crop,{size:14})}),h.jsx(Po,{open:I,onOpenChange:H=>{O(H),H&&_()},align:"end",side:"bottom",trigger:h.jsx("button",{type:"button",title:m.altText,"aria-label":m.altText,className:M("p-1.5 rounded-full",f==="dark"?"hover:bg-neutral-700 text-neutral-300":"hover:bg-neutral-100 text-neutral-600",p?.imageToolbarButton,p?.imageAltButton),children:h.jsx(q.Type,{size:14})}),children:h.jsxs("div",{className:M("flex w-56 flex-col gap-2",p?.imageAltPopover),children:[h.jsx("label",{className:M("text-xs font-semibold",f==="dark"?"text-neutral-400":"text-neutral-500",p?.imageAltLabel),children:m.altText}),h.jsx("input",{type:"text",value:j,placeholder:m.altTextPlaceholder,onChange:H=>D(H.target.value),onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),le()),H.key==="Escape"&&(H.preventDefault(),_(),O(!1))},autoFocus:!0,className:M("w-full rounded-xl border px-3 py-2 text-sm outline-none transition-colors",f==="dark"?"bg-neutral-800 border-neutral-700 text-neutral-100 placeholder:text-neutral-500 focus:border-neutral-500":"bg-neutral-50 border-neutral-200 text-neutral-900 placeholder:text-neutral-400 focus:border-neutral-400",p?.imageAltInput)}),h.jsxs("div",{className:M("flex gap-2",p?.imageAltActions),children:[h.jsx("button",{type:"button",onClick:le,className:M("flex-1 rounded-full py-1.5 text-sm font-medium transition-colors",f==="dark"?"bg-neutral-700 hover:bg-neutral-600 text-neutral-100":"bg-neutral-900 hover:bg-neutral-700 text-white",p?.imageAltApplyButton),children:m.apply}),h.jsx("button",{type:"button",onClick:te,disabled:!j.trim(),className:M("rounded-full px-3 py-1.5 text-sm transition-colors",f==="dark"?"text-neutral-400 hover:bg-white/10 disabled:text-neutral-600":"text-neutral-500 hover:bg-black/6 disabled:text-neutral-300",!j.trim()&&"cursor-not-allowed",p?.imageAltClearButton),children:m.clearAltText})]})]})}),h.jsx("span",{className:M("w-[1px] h-3 mx-0.5",f==="dark"?"bg-neutral-600":"bg-neutral-300",p?.imageToolbarSeparator)}),h.jsx("button",{type:"button",onClick:r,title:m.delete,"aria-label":m.delete,className:M("p-1.5 rounded-full text-red-500",f==="dark"?"hover:bg-red-900/20":"hover:bg-red-50",p?.imageToolbarButton,p?.imageDeleteButton),children:h.jsx(q.Trash2,{size:14})})]}),o&&h.jsxs(h.Fragment,{children:[h.jsx("div",{onMouseDown:H=>R(H,"right"),className:M("absolute top-1/2 -right-2 w-3.5 h-3.5 bg-white border-2 border-blue-500 rounded-full cursor-e-resize -translate-y-1/2 shadow z-20",p?.imageResizeHandle,p?.imageResizeHandleRight)}),h.jsx("div",{onMouseDown:H=>R(H,"bottom"),className:M("absolute -bottom-2 left-1/2 w-3.5 h-3.5 bg-white border-2 border-blue-500 rounded-full cursor-s-resize -translate-x-1/2 shadow z-20",p?.imageResizeHandle,p?.imageResizeHandleBottom)}),h.jsx("div",{onMouseDown:H=>R(H,"bottom-right"),className:M("absolute -bottom-2 -right-2 w-3.5 h-3.5 bg-white border-2 border-blue-500 rounded-full cursor-se-resize shadow z-20",p?.imageResizeHandle,p?.imageResizeHandleBottomRight)})]})]})}),o&&!g&&h.jsx("div",{className:M("mt-1 flex items-center gap-2",p?.imageModeBadge),children:h.jsx("span",{className:M("text-[10px] font-medium",f==="dark"?"text-neutral-500":"text-neutral-400",p?.imageModeText),children:G?m.imageFrameModeHint:m.imageNaturalModeHint})})]})},v1=e=>new Promise((t,n)=>{const r=new Image;r.addEventListener("load",()=>t(r)),r.addEventListener("error",n),r.setAttribute("crossOrigin","anonymous"),r.src=e});function gh(e){return e*Math.PI/180}function w1(e,t,n){const r=gh(n);return{width:Math.abs(Math.cos(r)*e)+Math.abs(Math.sin(r)*t),height:Math.abs(Math.sin(r)*e)+Math.abs(Math.cos(r)*t)}}async function k1(e,t,n=0,r={horizontal:!1,vertical:!1}){const o=await v1(e),s=document.createElement("canvas"),i=s.getContext("2d");if(!i)return"";const a=gh(n),{width:l,height:c}=w1(o.width,o.height,n);s.width=l,s.height=c,i.translate(l/2,c/2),i.rotate(a),i.scale(r.horizontal?-1:1,r.vertical?-1:1),i.translate(-o.width/2,-o.height/2),i.drawImage(o,0,0);const u=document.createElement("canvas"),d=u.getContext("2d");return d?(u.width=t.width,u.height=t.height,d.drawImage(s,t.x,t.y,t.width,t.height,0,0,t.width,t.height),new Promise(f=>{u.toBlob(p=>{p&&f(URL.createObjectURL(p))},"image/png")})):""}const C1=e=>e?e.replace(/\\/g,"\\\\").replace(/\[/g,"\\[").replace(/\]/g,"\\]"):"",S1=e=>e?e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'):"",T1=e=>{if(!e)return"";const t=e.trim();return t?/[\s()]/.test(t)?`<${t}>`:t.replace(/\\/g,"\\\\").replace(/\)/g,"\\)"):""},bh=P.Node.create({name:"image",addOptions(){return{inline:!1,allowBase64:!0,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:"100%"},height:{default:"auto"},rotation:{default:0},objectFit:{default:"contain"},objectPosition:{default:"50% 50%"},isUploading:{default:!1}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",P.mergeAttributes(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>{const n=typeof e.href=="string"&&e.href||typeof e.src=="string"&&e.src||"";return t.createNode("image",{src:n,alt:typeof e.text=="string"&&e.text||typeof e.alt=="string"&&e.alt||null,title:typeof e.title=="string"?e.title:null})},renderMarkdown:e=>{const t=T1(typeof e.attrs?.src=="string"?e.attrs.src:null);if(!t)return"";const n=C1(typeof e.attrs?.alt=="string"?e.attrs.alt:null),r=S1(typeof e.attrs?.title=="string"?e.attrs.title:null);return r?``:``},addCommands(){return{setAdvancedImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addNodeView(){return Tr.ReactNodeViewRenderer(x1)}}),A1=e=>{const t=e.trim();return t?/^\d+(\.\d+)?$/.test(t)?`${t}px`:/^\d+(\.\d+)?px$/.test(t)?t:/^\d+(\.\d+)?rem$/i.test(t)?t.toLowerCase():null:null},yh=P.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize||null,renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>{const n=A1(e);return n?t().setMark("textStyle",{fontSize:n}).run():!1},unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),E1=P.Extension.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>e.style.fontFamily?.replace(/['"]/g,"").trim()||null,renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),M1=P.Extension.create({name:"textStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontWeight:{default:null,parseHTML:e=>e.style.fontWeight||null,renderHTML:e=>e.fontWeight?{style:`font-weight: ${e.fontWeight}`}:{}},fontStyle:{default:null,parseHTML:e=>e.style.fontStyle||null,renderHTML:e=>e.fontStyle?{style:`font-style: ${e.fontStyle}`}:{}},letterSpacing:{default:null,parseHTML:e=>e.style.letterSpacing||null,renderHTML:e=>e.letterSpacing?{style:`letter-spacing: ${e.letterSpacing}`}:{}},lineHeight:{default:null,parseHTML:e=>e.style.lineHeight||null,renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}},textTransform:{default:null,parseHTML:e=>e.style.textTransform||null,renderHTML:e=>e.textTransform?{style:`text-transform: ${e.textTransform}`}:{}}}}]}}),li=e=>e?e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"):"",xh=P.Node.create({name:"video",addOptions(){return{allowBase64:!1,HTMLAttributes:{}}},group:"block",draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},controls:{default:!0},width:{default:"100%"}}},parseHTML(){return[{tag:"video",getAttrs:e=>{if(!(e instanceof HTMLElement))return!1;const t=e.querySelector("source[src]"),n=e.getAttribute("src")??t?.getAttribute("src")??null;return n?{src:n,title:e.getAttribute("title"),width:e.getAttribute("width")??"100%",controls:e.hasAttribute("controls")}:!1}}]},renderHTML({HTMLAttributes:e}){return["video",P.mergeAttributes(this.options.HTMLAttributes,e,{controls:!0})]},renderMarkdown:e=>{const t=typeof e.attrs?.src=="string"?e.attrs.src.trim():"";if(!t)return"";const n=typeof e.attrs?.title=="string"?e.attrs.title.trim():"",r=typeof e.attrs?.width=="string"?e.attrs.width.trim():"";return`<video ${[`src="${li(t)}"`,"controls",n?`title="${li(n)}"`:"",r?`width="${li(r)}"`:""].filter(Boolean).join(" ")}></video>`},addCommands(){return{setVideo:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}}}),R1=({editor:e})=>{const t=We(),n=Vr(),r=Ve(),o=K.useRef(null),[s,i]=K.useState(null);K.useEffect(()=>{if(!e||!e.view||typeof document>"u")return;let w;const C=A=>{if(!e.isEditable)return;const I=o.current;if(!I||!I.parentElement||I.dataset.dropdownOpen==="true")return;if(I.contains(A.target)){clearTimeout(w);return}const D=e.view.dom.getBoundingClientRect();if(!(A.clientX>=D.left-60&&A.clientX<=D.right&&A.clientY>=D.top&&A.clientY<=D.bottom)){w=setTimeout(()=>{I.classList.add("opacity-0","pointer-events-none")},150);return}clearTimeout(w);const B=e.view.posAtCoords({left:A.clientX,top:A.clientY});if(!B)return;const N=e.state.doc.resolve(B.pos);let $=N.depth;for(;$>1;)$--;const V=$>0?N.before($):N.pos,_=e.view.nodeDOM(V);if(_ instanceof HTMLElement){const R=_.getBoundingClientRect(),z=I.parentElement.getBoundingClientRect(),W=48,re=8;I.style.left=`${R.left-z.left-W-re}px`;const se=R.top-z.top+Math.min(R.height/2-12,4);I.style.top=`${se}px`,I.classList.remove("opacity-0","pointer-events-none")}};return document.addEventListener("mousemove",C),()=>{document.removeEventListener("mousemove",C),clearTimeout(w)}},[e]);const a=()=>{if(!o.current||!o.current.parentElement)return null;const w=o.current.getBoundingClientRect(),C={left:w.left+80,top:w.top+w.height/2},A=e.view.posAtCoords(C);if(A){const I=e.state.doc.resolve(A.pos);let O=I.depth;for(;O>1;)O--;const j=O>0?I.before(O):I.pos,D=e.state.doc.nodeAt(j);if(D){const F=D.type.name==="paragraph"||D.type.name==="heading",B=D.type.name==="image"||D.type.name==="advancedImage",N={pos:j,node:D,isText:F,isImage:B};return i(N),N}}return i(null),null},l=w=>{w.stopPropagation(),w.preventDefault(),a();const C=o.current?.getBoundingClientRect();if(!C)return;const A={left:C.left+80,top:C.top+C.height/2},I=e.view.posAtCoords(A);if(I){const O=e.state.doc.resolve(I.pos);let j=O.depth;for(;j>1;)j--;const D=j>0?O.before(j):O.pos,F=e.state.doc.nodeAt(D);if(F){const B=D+F.nodeSize;e.chain().insertContentAt(B,{type:"paragraph"}).focus(B+1).insertContent("/").run();return}}e.chain().focus().insertContent("/").run()},c=()=>{if(!s)return;const{pos:w,node:C}=s;e.chain().insertContentAt(w+C.nodeSize,C.toJSON()).run()},u=()=>{if(!s)return;const{pos:w,node:C}=s;e.chain().deleteRange({from:w,to:w+C.nodeSize}).run()},d=()=>{if(!s)return;const{pos:w,node:C}=s,A=e.state.doc.slice(w,w+C.nodeSize),I=A.content.textBetween(0,A.content.size,`
|
|
149
|
+
`,"2) content: () => element.cloneNode(true)"].join(" "))}var a=o.reduce(function(l,c){var u=c&&g1(c,r);return u&&l.push(u),l},[]);return zr(e)?a[0]:a}eo.defaultProps=et;eo.setDefaultProps=f1;eo.currentInput=Ct;Object.assign({},Qp,{effect:function(t){var n=t.state,r={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,r.popper),n.styles=r,n.elements.arrow&&Object.assign(n.elements.arrow.style,r.arrow)}});eo.setDefaultProps({render:gh});const bh=K.forwardRef(({items:e,command:t,classNames:n,noResults:r},o)=>{const[s,i]=K.useState(0),a=We(),l=Vr(),c=Ve(),u=n??c,d=r??l.noResults;K.useEffect(()=>{i(0)},[e]);const f=p=>{const m=e[p];m&&t(m)};return K.useImperativeHandle(o,()=>({onKeyDown:p=>e.length?p.key==="ArrowUp"?(p.preventDefault(),i(m=>(m+e.length-1)%e.length),!0):p.key==="ArrowDown"?(p.preventDefault(),i(m=>(m+1)%e.length),!0):p.key==="Enter"?(p.preventDefault(),f(s),!0):!1:!1})),h.jsx("div",{className:M("z-[9999] min-w-[14rem] overflow-hidden rounded-3xl border p-1.5 shadow-xl backdrop-blur-xl space-y-1 animate-in fade-in zoom-in-95",a==="dark"?"bg-neutral-900/95 border-neutral-800 shadow-black/50 text-neutral-200":"bg-white/95 border-neutral-200/60 text-neutral-700",u?.slashCommandMenu),children:e.length?e.map((p,m)=>h.jsxs("button",{type:"button",onClick:()=>f(m),"aria-selected":s===m,className:M("relative flex w-full cursor-pointer select-none items-center rounded-full px-3 py-2 text-sm outline-none transition-colors gap-2",s===m?a==="dark"?"bg-neutral-800 text-neutral-100":"bg-neutral-100 text-neutral-900":a==="dark"?"text-neutral-300 hover:bg-neutral-800 hover:text-neutral-100":"text-neutral-600 hover:bg-neutral-100 hover:text-neutral-900",s===m&&u?.slashCommandItemActive,u?.slashCommandItem),children:[h.jsx("div",{className:M("flex h-6 w-6 items-center justify-center rounded-sm mr-2",a==="dark"?"bg-neutral-800 border border-neutral-700":"bg-white border border-neutral-200 shadow-sm",u?.slashCommandIcon),children:h.jsx(p.icon,{className:"size-4"})}),h.jsx("span",{className:M("font-medium",u?.slashCommandTitle),children:p.title})]},p.title)):h.jsxs("div",{className:M("flex items-center px-2 py-1.5 text-sm text-neutral-500",u?.slashCommandEmpty),children:[h.jsx(q.Ban,{className:M("mr-2 size-4",u?.slashCommandEmptyIcon)}),d]})})});bh.displayName="CommandsList";const b1=async({editor:e,range:t,onRequestImage:n,onInsertLocalImageFile:r,imageSlashFallback:o="prompt-url",translations:s})=>{const i=s||Xn;let a=null;if(n)a=await n({editor:e,range:t});else if(o==="prompt-url"){const c=window.prompt(i.imageUrlPrompt)?.trim();a=c?{kind:"url",src:c}:null}if(!a)return;if(a.kind==="file"){if(!r)return;e.chain().focus().deleteRange(t).run();const c={editor:e,range:t,file:a.file,...a.alt?{alt:a.alt}:{},...a.title?{title:a.title}:{}};await r(c);return}const l={src:a.src,...a.alt?{alt:a.alt}:{},...a.title?{title:a.title}:{}};e.chain().focus().deleteRange(t).setNode("image",l).run()},y1=e=>{const t=e.translations||Xn;return[{title:t.text,icon:q.Pilcrow,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).setParagraph().run()},{title:t.heading1,icon:q.Heading1,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).setHeading({level:1}).run()},{title:t.heading2,icon:q.Heading2,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).setHeading({level:2}).run()},{title:t.heading3,icon:q.Heading3,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).setHeading({level:3}).run()},{title:t.bulletList,icon:q.List,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).toggleBulletList().run()},{title:t.numberedList,icon:q.ListOrdered,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).toggleOrderedList().run()},{title:t.image,icon:q.Image,command:({editor:n,range:r})=>{b1({editor:n,range:r,onRequestImage:e.onRequestImage??null,onInsertLocalImageFile:e.onInsertLocalImageFile??null,imageSlashFallback:e.imageSlashFallback??"prompt-url",translations:e.translations})}},{title:t.table,icon:q.Table,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:t.quote,icon:q.Quote,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).toggleBlockquote().run()},{title:t.code,icon:q.Code,command:({editor:n,range:r})=>n.chain().focus().deleteRange(r).toggleCodeBlock().run()}]},x1=(e={})=>({items:({query:t,editor:n})=>{const r=n.isActive("tableCell")||n.isActive("tableHeader"),o=e.translations||Xn;return y1(e).filter(s=>!r||s.title===o.image).filter(s=>e.enableImages!==!1||s.title!==o.image).filter(s=>s.title.toLowerCase().includes(t.toLowerCase())).slice(0,10)},render:()=>{let t=null,n=null,r=!1,o=0;const s=c=>({...c,classNames:e.classNames,noResults:(e.translations||Xn).noResults}),i=c=>{if(!c.clientRect||!n)return;const u=()=>c.clientRect?.()??new DOMRect(0,0,0,0);n.setProps({getReferenceClientRect:u})},a=c=>{if(!r){if(!t){if(t=new Tr.ReactRenderer(bh,{props:s(c),editor:c.editor}),!c.clientRect)return;const u=()=>c.clientRect?.()??new DOMRect(0,0,0,0);n=eo(Jo()??document.body,{getReferenceClientRect:u,appendTo:()=>Jo()??document.body,content:t.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"});return}t.updateProps(s(c)),i(c)}},l=c=>{const u=++o;queueMicrotask(()=>{r||u!==o||a(c)})};return{onStart:c=>{l(c)},onUpdate:c=>{l(c)},onKeyDown:({event:c})=>c.key==="Escape"&&n?(n.hide(),!0):t?.ref?.onKeyDown(c)??!1,onExit:()=>{r=!0,o+=1,n&&n.destroy(),t?.destroy()}}}}),v1=P.Extension.create({name:"slash-commands",addOptions(){return{onRequestImage:null,onInsertLocalImageFile:null,enableImages:!0,imageSlashFallback:"prompt-url"}},addProseMirrorPlugins(){const e=x1({onRequestImage:this.options.onRequestImage,onInsertLocalImageFile:this.options.onInsertLocalImageFile,enableImages:this.options.enableImages,imageSlashFallback:this.options.imageSlashFallback,translations:this.options.translations,classNames:this.options.classNames});return[zC({editor:this.editor,char:"/",command:({editor:t,range:n,props:r})=>{r.command({editor:t,range:n})},...e})]}}),w1=e=>{const{node:t,updateAttributes:n,deleteNode:r,selected:o}=e,{src:s,width:i,height:a,rotation:l,objectFit:c="contain",objectPosition:u="50% 50%",isUploading:d}=t.attrs,f=We(),p=Ve(),m=Vr(),[g,b]=K.useState(!1),[x,S]=K.useState({x:0,y:0}),[k,y]=K.useState(1),[A,w]=K.useState(null),[C,T]=K.useState(!1),[I,O]=K.useState(!1),[j,D]=K.useState(""),F=K.useRef(null),B=K.useRef(null),N=K.useRef(null),$=typeof t.attrs.alt=="string"&&t.attrs.alt.trim()?t.attrs.alt:m.imageAlt,V=()=>{if(F.current&&N.current===null){const{naturalWidth:H,naturalHeight:J}=F.current;H>0&&J>0&&(N.current=H/J)}},_=()=>{D(typeof t.attrs.alt=="string"?t.attrs.alt:"")};K.useEffect(()=>{_()},[t.attrs.alt]),K.useEffect(()=>{!o&&I&&O(!1)},[o,I]);const R=(H,J)=>{H.preventDefault(),H.stopPropagation();const oe=H.clientX,ge=H.clientY,Ce=B.current?.offsetWidth??300,ve=B.current?.offsetHeight??200,we=N.current??Ce/ve,Ee=H.shiftKey,st=qe=>{const ye=qe.clientX-oe,Re=qe.clientY-ge;if(qe.shiftKey||Ee){let Te=Math.max(80,Ce+ye),_e=J==="right"?ve:Math.max(60,ve+Re);n({width:`${Te}px`,height:J==="right"?a:`${_e}px`,objectFit:"cover"})}else if(J==="bottom"){const Te=Math.max(60,ve+Re),_e=Te*we;n({width:`${Math.round(_e)}px`,height:`${Math.round(Te)}px`,objectFit:"contain"})}else{const Te=Math.max(80,Ce+ye),_e=Te/we;n({width:`${Math.round(Te)}px`,height:`${Math.round(_e)}px`,objectFit:"contain"})}},Xe=()=>{document.removeEventListener("mousemove",st),document.removeEventListener("mouseup",Xe)};document.addEventListener("mousemove",st),document.addEventListener("mouseup",Xe)},z=H=>{if(!H.ctrlKey||c!=="cover")return;H.preventDefault(),H.stopPropagation(),T(!0);const J=H.clientX,oe=H.clientY,ge=(u||"50% 50%").split(" "),Ce=parseFloat(ge[0])??50,ve=parseFloat(ge[1])??50,we=B.current?.offsetWidth??300,Ee=B.current?.offsetHeight??200,st=qe=>{const ye=qe.clientX-J,Re=qe.clientY-oe,Pe=Math.max(0,Math.min(100,Ce-ye/we*100)),Te=Math.max(0,Math.min(100,ve-Re/Ee*100));n({objectPosition:`${Pe.toFixed(1)}% ${Te.toFixed(1)}%`})},Xe=()=>{T(!1),document.removeEventListener("mousemove",st),document.removeEventListener("mouseup",Xe)};document.addEventListener("mousemove",st),document.addEventListener("mouseup",Xe)},W=K.useCallback((H,J)=>{w(J)},[]),re=async()=>{try{const H=await S1(s,A,l);n({src:H,rotation:0}),b(!1)}catch(H){console.error(H),b(!1)}},se=()=>{const H=((l||0)+90)%360;n({rotation:H})},le=()=>{const H=j.trim();n({alt:H||null}),O(!1)},te=()=>{n({alt:null}),D(""),O(!1)},G=c==="cover";return h.jsxs(Tr.NodeViewWrapper,{className:M("relative block max-w-full my-4",p?.imageNodeWrapper),"data-drag-handle":!0,children:[h.jsx("div",{ref:B,className:M("relative group ring-2 transition-all inline-block max-w-full",o?"ring-blue-500":"ring-transparent",g&&"ring-0",p?.imageContainer),style:{width:i,minWidth:80},children:g?h.jsxs("div",{className:M("relative",p?.imageCropArea),style:{width:"100%",height:"400px",backgroundColor:"#333"},children:[h.jsx(Oh,{image:s,crop:x,zoom:k,rotation:l,aspect:4/3,onCropChange:S,onRotationChange:H=>n({rotation:H}),onZoomChange:y,onCropComplete:W}),h.jsxs("div",{className:M("absolute bottom-4 left-1/2 -translate-x-1/2 flex items-center gap-2 p-2 rounded-xl shadow-lg z-10",f==="dark"?"bg-neutral-800":"bg-white",p?.imageCropToolbar),children:[h.jsx("button",{onClick:()=>b(!1),title:m.cancel,"aria-label":m.cancel,className:M("p-2 text-red-500 rounded-full",f==="dark"?"hover:bg-neutral-700":"hover:bg-neutral-100",p?.imageCropButton,p?.imageCropCancelButton),children:h.jsx(q.X,{size:16})}),h.jsx("button",{onClick:re,title:m.apply,"aria-label":m.apply,className:M("p-2 text-green-500 rounded-full",f==="dark"?"hover:bg-neutral-700":"hover:bg-neutral-100",p?.imageCropButton,p?.imageCropApplyButton),children:h.jsx(q.Check,{size:16})})]})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:M("relative w-full",G&&"overflow-hidden",p?.imageFrame),style:{height:a==="auto"?void 0:a},children:[h.jsx("img",{ref:F,src:s,alt:$,onLoad:V,onMouseDown:z,className:M("block max-w-full rounded select-none",G&&"w-full h-full",C&&"cursor-grabbing",!C&&G&&"cursor-grab",d&&"opacity-50 blur-[2px] grayscale-[0.5]",p?.imageElement),style:{width:G?"100%":i,height:G?"100%":a,objectFit:G?"cover":void 0,objectPosition:G?u:void 0,transform:l?`rotate(${l}deg)`:void 0,transition:o?"none":"transform 0.2s, filter 0.2s, opacity 0.2s"}}),d&&h.jsx("div",{className:M("absolute inset-0 flex items-center justify-center z-10 pointer-events-none",p?.imageLoadingOverlay),children:h.jsx("div",{className:M("flex items-center justify-center p-3 rounded-2xl shadow-xl backdrop-blur-md",f==="dark"?"bg-black/50":"bg-white/60",p?.imageLoadingBox),children:h.jsx(q.Loader2,{className:M("w-8 h-8 animate-spin",f==="dark"?"text-white":"text-neutral-800",p?.imageLoadingIcon)})})}),o&&G&&!d&&h.jsx("div",{className:M("absolute inset-0 flex items-end justify-center pb-2 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity",p?.imagePanHintOverlay),children:h.jsx("span",{className:M("text-[10px] px-2 py-0.5 rounded-full font-medium",f==="dark"?"bg-black/60 text-neutral-300":"bg-white/80 text-neutral-500",p?.imagePanHint),children:m.imagePanHint})})]}),o&&h.jsxs("div",{className:M("absolute top-2 right-2 flex items-center gap-1 backdrop-blur border p-1 rounded-xl shadow-sm opacity-0 group-hover:opacity-100 transition-opacity z-10",f==="dark"?"bg-neutral-800/90 border-neutral-700":"bg-white/90 border-neutral-200",p?.imageToolbar),children:[h.jsx("button",{type:"button",onClick:se,title:m.rotate,"aria-label":m.rotate,className:M("p-1.5 rounded-full",f==="dark"?"hover:bg-neutral-700 text-neutral-300":"hover:bg-neutral-100 text-neutral-600",p?.imageToolbarButton),children:h.jsx(q.RotateCw,{size:14})}),h.jsx("button",{type:"button",onClick:()=>b(!0),title:m.crop,"aria-label":m.crop,className:M("p-1.5 rounded-full",f==="dark"?"hover:bg-neutral-700 text-neutral-300":"hover:bg-neutral-100 text-neutral-600",p?.imageToolbarButton),children:h.jsx(q.Crop,{size:14})}),h.jsx(Lo,{open:I,onOpenChange:H=>{O(H),H&&_()},align:"end",side:"bottom",trigger:h.jsx("button",{type:"button",title:m.altText,"aria-label":m.altText,className:M("p-1.5 rounded-full",f==="dark"?"hover:bg-neutral-700 text-neutral-300":"hover:bg-neutral-100 text-neutral-600",p?.imageToolbarButton,p?.imageAltButton),children:h.jsx(q.Type,{size:14})}),children:h.jsxs("div",{className:M("flex w-56 flex-col gap-2",p?.imageAltPopover),children:[h.jsx("label",{className:M("text-xs font-semibold",f==="dark"?"text-neutral-400":"text-neutral-500",p?.imageAltLabel),children:m.altText}),h.jsx("input",{type:"text",value:j,placeholder:m.altTextPlaceholder,onChange:H=>D(H.target.value),onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),le()),H.key==="Escape"&&(H.preventDefault(),_(),O(!1))},autoFocus:!0,className:M("w-full rounded-xl border px-3 py-2 text-sm outline-none transition-colors",f==="dark"?"bg-neutral-800 border-neutral-700 text-neutral-100 placeholder:text-neutral-500 focus:border-neutral-500":"bg-neutral-50 border-neutral-200 text-neutral-900 placeholder:text-neutral-400 focus:border-neutral-400",p?.imageAltInput)}),h.jsxs("div",{className:M("flex gap-2",p?.imageAltActions),children:[h.jsx("button",{type:"button",onClick:le,className:M("flex-1 rounded-full py-1.5 text-sm font-medium transition-colors",f==="dark"?"bg-neutral-700 hover:bg-neutral-600 text-neutral-100":"bg-neutral-900 hover:bg-neutral-700 text-white",p?.imageAltApplyButton),children:m.apply}),h.jsx("button",{type:"button",onClick:te,disabled:!j.trim(),className:M("rounded-full px-3 py-1.5 text-sm transition-colors",f==="dark"?"text-neutral-400 hover:bg-white/10 disabled:text-neutral-600":"text-neutral-500 hover:bg-black/6 disabled:text-neutral-300",!j.trim()&&"cursor-not-allowed",p?.imageAltClearButton),children:m.clearAltText})]})]})}),h.jsx("span",{className:M("w-[1px] h-3 mx-0.5",f==="dark"?"bg-neutral-600":"bg-neutral-300",p?.imageToolbarSeparator)}),h.jsx("button",{type:"button",onClick:r,title:m.delete,"aria-label":m.delete,className:M("p-1.5 rounded-full text-red-500",f==="dark"?"hover:bg-red-900/20":"hover:bg-red-50",p?.imageToolbarButton,p?.imageDeleteButton),children:h.jsx(q.Trash2,{size:14})})]}),o&&h.jsxs(h.Fragment,{children:[h.jsx("div",{onMouseDown:H=>R(H,"right"),className:M("absolute top-1/2 -right-2 w-3.5 h-3.5 bg-white border-2 border-blue-500 rounded-full cursor-e-resize -translate-y-1/2 shadow z-20",p?.imageResizeHandle,p?.imageResizeHandleRight)}),h.jsx("div",{onMouseDown:H=>R(H,"bottom"),className:M("absolute -bottom-2 left-1/2 w-3.5 h-3.5 bg-white border-2 border-blue-500 rounded-full cursor-s-resize -translate-x-1/2 shadow z-20",p?.imageResizeHandle,p?.imageResizeHandleBottom)}),h.jsx("div",{onMouseDown:H=>R(H,"bottom-right"),className:M("absolute -bottom-2 -right-2 w-3.5 h-3.5 bg-white border-2 border-blue-500 rounded-full cursor-se-resize shadow z-20",p?.imageResizeHandle,p?.imageResizeHandleBottomRight)})]})]})}),o&&!g&&h.jsx("div",{className:M("mt-1 flex items-center gap-2",p?.imageModeBadge),children:h.jsx("span",{className:M("text-[10px] font-medium",f==="dark"?"text-neutral-500":"text-neutral-400",p?.imageModeText),children:G?m.imageFrameModeHint:m.imageNaturalModeHint})})]})},k1=e=>new Promise((t,n)=>{const r=new Image;r.addEventListener("load",()=>t(r)),r.addEventListener("error",n),r.setAttribute("crossOrigin","anonymous"),r.src=e});function yh(e){return e*Math.PI/180}function C1(e,t,n){const r=yh(n);return{width:Math.abs(Math.cos(r)*e)+Math.abs(Math.sin(r)*t),height:Math.abs(Math.sin(r)*e)+Math.abs(Math.cos(r)*t)}}async function S1(e,t,n=0,r={horizontal:!1,vertical:!1}){const o=await k1(e),s=document.createElement("canvas"),i=s.getContext("2d");if(!i)return"";const a=yh(n),{width:l,height:c}=C1(o.width,o.height,n);s.width=l,s.height=c,i.translate(l/2,c/2),i.rotate(a),i.scale(r.horizontal?-1:1,r.vertical?-1:1),i.translate(-o.width/2,-o.height/2),i.drawImage(o,0,0);const u=document.createElement("canvas"),d=u.getContext("2d");return d?(u.width=t.width,u.height=t.height,d.drawImage(s,t.x,t.y,t.width,t.height,0,0,t.width,t.height),new Promise(f=>{u.toBlob(p=>{p&&f(URL.createObjectURL(p))},"image/png")})):""}const T1=e=>e?e.replace(/\\/g,"\\\\").replace(/\[/g,"\\[").replace(/\]/g,"\\]"):"",A1=e=>e?e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'):"",E1=e=>{if(!e)return"";const t=e.trim();return t?/[\s()]/.test(t)?`<${t}>`:t.replace(/\\/g,"\\\\").replace(/\)/g,"\\)"):""},xh=P.Node.create({name:"image",addOptions(){return{inline:!1,allowBase64:!0,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:"100%"},height:{default:"auto"},rotation:{default:0},objectFit:{default:"contain"},objectPosition:{default:"50% 50%"},isUploading:{default:!1}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",P.mergeAttributes(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>{const n=typeof e.href=="string"&&e.href||typeof e.src=="string"&&e.src||"";return t.createNode("image",{src:n,alt:typeof e.text=="string"&&e.text||typeof e.alt=="string"&&e.alt||null,title:typeof e.title=="string"?e.title:null})},renderMarkdown:e=>{const t=E1(typeof e.attrs?.src=="string"?e.attrs.src:null);if(!t)return"";const n=T1(typeof e.attrs?.alt=="string"?e.attrs.alt:null),r=A1(typeof e.attrs?.title=="string"?e.attrs.title:null);return r?``:``},addCommands(){return{setAdvancedImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addNodeView(){return Tr.ReactNodeViewRenderer(w1)}}),M1=e=>{const t=e.trim();return t?/^\d+(\.\d+)?$/.test(t)?`${t}px`:/^\d+(\.\d+)?px$/.test(t)?t:/^\d+(\.\d+)?rem$/i.test(t)?t.toLowerCase():null:null},vh=P.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize||null,renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>{const n=M1(e);return n?t().setMark("textStyle",{fontSize:n}).run():!1},unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),R1=P.Extension.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>e.style.fontFamily?.replace(/['"]/g,"").trim()||null,renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),N1=P.Extension.create({name:"textStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontWeight:{default:null,parseHTML:e=>e.style.fontWeight||null,renderHTML:e=>e.fontWeight?{style:`font-weight: ${e.fontWeight}`}:{}},fontStyle:{default:null,parseHTML:e=>e.style.fontStyle||null,renderHTML:e=>e.fontStyle?{style:`font-style: ${e.fontStyle}`}:{}},letterSpacing:{default:null,parseHTML:e=>e.style.letterSpacing||null,renderHTML:e=>e.letterSpacing?{style:`letter-spacing: ${e.letterSpacing}`}:{}},lineHeight:{default:null,parseHTML:e=>e.style.lineHeight||null,renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}},textTransform:{default:null,parseHTML:e=>e.style.textTransform||null,renderHTML:e=>e.textTransform?{style:`text-transform: ${e.textTransform}`}:{}}}}]}}),ui=e=>e?e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"):"",wh=P.Node.create({name:"video",addOptions(){return{allowBase64:!1,HTMLAttributes:{}}},group:"block",draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},controls:{default:!0},width:{default:"100%"}}},parseHTML(){return[{tag:"video",getAttrs:e=>{if(!(e instanceof HTMLElement))return!1;const t=e.querySelector("source[src]"),n=e.getAttribute("src")??t?.getAttribute("src")??null;return n?{src:n,title:e.getAttribute("title"),width:e.getAttribute("width")??"100%",controls:e.hasAttribute("controls")}:!1}}]},renderHTML({HTMLAttributes:e}){return["video",P.mergeAttributes(this.options.HTMLAttributes,e,{controls:!0})]},renderMarkdown:e=>{const t=typeof e.attrs?.src=="string"?e.attrs.src.trim():"";if(!t)return"";const n=typeof e.attrs?.title=="string"?e.attrs.title.trim():"",r=typeof e.attrs?.width=="string"?e.attrs.width.trim():"";return`<video ${[`src="${ui(t)}"`,"controls",n?`title="${ui(n)}"`:"",r?`width="${ui(r)}"`:""].filter(Boolean).join(" ")}></video>`},addCommands(){return{setVideo:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}}}),O1=({editor:e})=>{const t=We(),n=Vr(),r=Ve(),o=K.useRef(null),[s,i]=K.useState(null);K.useEffect(()=>{if(!e||!e.view||typeof document>"u")return;let w;const C=T=>{if(!e.isEditable)return;const I=o.current;if(!I||!I.parentElement||I.dataset.dropdownOpen==="true")return;if(I.contains(T.target)){clearTimeout(w);return}const D=e.view.dom.getBoundingClientRect();if(!(T.clientX>=D.left-60&&T.clientX<=D.right&&T.clientY>=D.top&&T.clientY<=D.bottom)){w=setTimeout(()=>{I.classList.add("opacity-0","pointer-events-none")},150);return}clearTimeout(w);const B=e.view.posAtCoords({left:T.clientX,top:T.clientY});if(!B)return;const N=e.state.doc.resolve(B.pos);let $=N.depth;for(;$>1;)$--;const V=$>0?N.before($):N.pos,_=e.view.nodeDOM(V);if(_ instanceof HTMLElement){const R=_.getBoundingClientRect(),z=I.parentElement.getBoundingClientRect(),W=48,re=8;I.style.left=`${R.left-z.left-W-re}px`;const se=R.top-z.top+Math.min(R.height/2-12,4);I.style.top=`${se}px`,I.classList.remove("opacity-0","pointer-events-none")}};return document.addEventListener("mousemove",C),()=>{document.removeEventListener("mousemove",C),clearTimeout(w)}},[e]);const a=()=>{if(!o.current||!o.current.parentElement)return null;const w=o.current.getBoundingClientRect(),C={left:w.left+80,top:w.top+w.height/2},T=e.view.posAtCoords(C);if(T){const I=e.state.doc.resolve(T.pos);let O=I.depth;for(;O>1;)O--;const j=O>0?I.before(O):I.pos,D=e.state.doc.nodeAt(j);if(D){const F=D.type.name==="paragraph"||D.type.name==="heading",B=D.type.name==="image"||D.type.name==="advancedImage",N={pos:j,node:D,isText:F,isImage:B};return i(N),N}}return i(null),null},l=w=>{w.stopPropagation(),w.preventDefault(),a();const C=o.current?.getBoundingClientRect();if(!C)return;const T={left:C.left+80,top:C.top+C.height/2},I=e.view.posAtCoords(T);if(I){const O=e.state.doc.resolve(I.pos);let j=O.depth;for(;j>1;)j--;const D=j>0?O.before(j):O.pos,F=e.state.doc.nodeAt(D);if(F){const B=D+F.nodeSize;e.chain().insertContentAt(B,{type:"paragraph"}).focus(B+1).insertContent("/").run();return}}e.chain().focus().insertContent("/").run()},c=()=>{if(!s)return;const{pos:w,node:C}=s;e.chain().insertContentAt(w+C.nodeSize,C.toJSON()).run()},u=()=>{if(!s)return;const{pos:w,node:C}=s;e.chain().deleteRange({from:w,to:w+C.nodeSize}).run()},d=()=>{if(!s)return;const{pos:w,node:C}=s,T=e.state.doc.slice(w,w+C.nodeSize),I=T.content.textBetween(0,T.content.size,`
|
|
150
150
|
`,`
|
|
151
|
-
`);navigator.clipboard.writeText(I)},f=()=>{if(!s)return;const{node:w}=s;let C=w.attrs.id;C||(C=`block-${Math.random().toString(36).substr(2,9)}`,e.chain().setNodeSelection(s.pos).updateAttributes(w.type.name,{id:C}).run());const A=new URL(window.location.href);A.hash=C,navigator.clipboard.writeText(A.toString())},p=()=>{if(!s?.isImage)return;const w=s.node.attrs.src;if(!w)return;const C=document.createElement("a");C.href=w,C.download="image.png",document.body.appendChild(C),C.click(),document.body.removeChild(C)},m=(w,C)=>{s&&e.chain().setNodeSelection(s.pos).toggleNode(w,w,C?{level:C}:{}).run()},g=()=>{if(!s)return;const{pos:w,node:C}=s;e.chain().setTextSelection({from:w,to:w+C.nodeSize}).unsetAllMarks().run()},[b,x]=K.useState(!1),S=w=>{o.current&&(o.current.dataset.dropdownOpen=w?"true":"false"),w&&a(),x(w)},k=w=>{const C=a()||s;if(!C){w.preventDefault();return}const A=e.view;e.commands.setNodeSelection(C.pos);const I=A.state.selection.content();let O=null,j="";try{const F=typeof A.serializeForClipboard=="function"?A.serializeForClipboard(I):A.__serializeForClipboard?.(A,I);F&&(O=F.dom,j=F.text)}catch(F){console.error("Failed to serialize node for drag",F)}if(!O){w.preventDefault();return}w.dataTransfer.clearData(),w.dataTransfer.setData("text/html",O.innerHTML),w.dataTransfer.setData("text/plain",j),w.dataTransfer.effectAllowed="copyMove";const D=A.nodeDOM(C.pos);D instanceof HTMLElement&&w.dataTransfer.setDragImage(D,0,0),A.dragging={slice:I,move:!0}};let y="",T="";return s?.node&&s.node.descendants(w=>{w.isText&&w.marks&&w.marks.forEach(C=>{C.type.name==="textStyle"&&C.attrs.color&&!y&&(y=C.attrs.color),C.type.name==="highlight"&&C.attrs.color&&!T&&(T=C.attrs.color)})}),h.jsxs("div",{ref:o,className:M("absolute z-50 flex items-center transition-[opacity,top] duration-150 gap-1 opacity-0 pointer-events-none",r?.dragHandleRoot),children:[h.jsx("button",{className:M("p-1 rounded-md bg-transparent transition-colors pointer-events-auto",t==="dark"?"hover:bg-neutral-800 text-neutral-400 hover:text-neutral-100":"hover:bg-neutral-100 text-neutral-400 hover:text-neutral-900",r?.dragHandleAddButton),title:n.addBlockBelow,onClick:l,children:h.jsx(q.Plus,{className:"w-4 h-4"})}),h.jsxs(Pp,{open:b,onOpenChange:S,children:[h.jsxs("div",{className:"relative flex",children:[h.jsx(Lp,{asChild:!0,children:h.jsx("div",{className:"absolute inset-0 w-full h-full pointer-events-none opacity-0"})}),h.jsx("button",{className:M("p-1 rounded-md bg-transparent transition-colors cursor-grab active:cursor-grabbing pointer-events-auto",t==="dark"?"hover:bg-neutral-800 text-neutral-400 hover:text-neutral-100":"hover:bg-neutral-100 text-neutral-400 hover:text-neutral-900",r?.dragHandleMenuButton),title:n.options,draggable:!0,onDragStart:k,onClick:()=>S(!0),children:h.jsx(q.GripVertical,{className:"w-4 h-4"})})]}),h.jsxs(Ka,{className:M("w-56",r?.dragHandleMenuContent),align:"start",children:[s?.isText&&h.jsxs(h.Fragment,{children:[h.jsxs(Ic,{children:[h.jsxs(Wi,{children:[h.jsx(q.Type,{className:"w-4 h-4"}),n.turnInto]}),h.jsx(Oc,{children:h.jsxs(Vi,{className:M("w-48",r?.dragHandleSubContent),children:[h.jsxs(Ke,{onClick:()=>m("paragraph"),children:[h.jsx(q.Type,{className:"w-4 h-4"})," ",n.text,s.node.type.name==="paragraph"&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]}),h.jsxs(Ke,{onClick:()=>m("heading",1),children:[h.jsx(q.Heading1,{className:"w-4 h-4"})," ",n.heading1,s.node.type.name==="heading"&&s.node.attrs.level===1&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]}),h.jsxs(Ke,{onClick:()=>m("heading",2),children:[h.jsx(q.Heading2,{className:"w-4 h-4"})," ",n.heading2,s.node.type.name==="heading"&&s.node.attrs.level===2&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]}),h.jsxs(Ke,{onClick:()=>m("heading",3),children:[h.jsx(q.Heading3,{className:"w-4 h-4"})," ",n.heading3,s.node.type.name==="heading"&&s.node.attrs.level===3&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]})]})})]}),h.jsxs(Ic,{children:[h.jsxs(Wi,{children:[h.jsx(q.Palette,{className:"w-4 h-4"}),n.color]}),h.jsx(Oc,{children:h.jsxs(Vi,{className:M("w-64 max-h-80 overflow-y-auto",r?.dragHandleSubContent),children:[h.jsx("div",{className:M("px-2 py-1.5 text-xs font-semibold text-neutral-500 uppercase tracking-wider",r?.dragHandleColorSectionLabel),children:n.textColor}),[{label:n.defaultText,color:""},{label:n.grayText,color:"#6b7280"},{label:n.brownText,color:"#78350f"},{label:n.orangeText,color:"#f97316"},{label:n.yellowText,color:"#eab308"},{label:n.greenText,color:"#22c55e"},{label:n.blueText,color:"#3b82f6"},{label:n.purpleText,color:"#a855f7"},{label:n.pinkText,color:"#ec4899"},{label:n.redText,color:"#ef4444"}].map(w=>h.jsxs(Ke,{onClick:()=>{if(s){const C=e.chain().setNodeSelection(s.pos);w.color?C.setColor(w.color).run():C.unsetColor().run()}},children:[h.jsx("div",{className:M("font-bold flex items-center justify-center text-[14px]",r?.dragHandleColorTextPreview),style:{color:w.color||"inherit"},children:"A"}),w.label,y===w.color&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]},w.label)),h.jsx(xr,{}),h.jsx("div",{className:M("px-2 py-1.5 text-xs font-semibold text-neutral-500 uppercase tracking-wider",r?.dragHandleColorSectionLabel),children:n.background}),[{label:n.defaultBackground,color:""},{label:n.grayBackground,color:"#f3f4f6"},{label:n.brownBackground,color:"#fef3c7"},{label:n.orangeBackground,color:"#ffedd5"},{label:n.yellowBackground,color:"#fef08a"},{label:n.greenBackground,color:"#dcfce7"},{label:n.blueBackground,color:"#dbeafe"},{label:n.purpleBackground,color:"#f3e8ff"},{label:n.pinkBackground,color:"#fce7f3"},{label:n.redBackground,color:"#fee2e2"}].map(w=>h.jsxs(Ke,{onClick:()=>{if(s){const C=e.chain().setNodeSelection(s.pos);w.color?C.setHighlight({color:w.color}).run():C.unsetHighlight().run()}},children:[h.jsx("div",{className:M("w-4 h-4 rounded-full border",t==="dark"?"border-neutral-700/20":"border-neutral-200/20",r?.dragHandleColorSwatch),style:{backgroundColor:w.color||"transparent"}}),w.label,T===w.color&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]},w.label))]})})]}),h.jsxs(Ke,{onClick:g,children:[h.jsx(q.RotateCcw,{className:"w-4 h-4"}),n.resetFormatting]}),h.jsx(xr,{})]}),s?.isImage&&h.jsxs(h.Fragment,{children:[h.jsxs(Ke,{onClick:p,children:[h.jsx(q.Download,{className:"w-4 h-4"}),n.download]}),h.jsx(xr,{})]}),h.jsxs(Ke,{onClick:c,children:[h.jsx(q.Copy,{className:"w-4 h-4"}),n.duplicateNode]}),h.jsxs(Ke,{onClick:d,children:[h.jsx(q.Copy,{className:"w-4 h-4"}),n.copyToClipboard]}),h.jsxs(Ke,{onClick:f,children:[h.jsx(q.Link,{className:"w-4 h-4"}),n.copyAnchorLink]}),h.jsx(xr,{}),h.jsxs(Ke,{className:M(t==="dark"?"text-red-400 focus:bg-red-950/30":"text-red-600 focus:bg-red-50",r?.dragHandleDeleteItem),onClick:u,children:[h.jsx(q.Trash2,{className:"w-4 h-4"}),n.delete]})]})]})]})},vh=[{id:"normal",label:"Normal text",type:"paragraph"},{id:"title",label:"Title",preview:"Title",type:"heading",level:1,fontSize:"36px",fontWeight:"700",letterSpacing:"-0.025em"},{id:"subtitle",label:"Subtitle",preview:"Subtitle",type:"paragraph",fontSize:"18px",fontWeight:"400",fontStyle:"normal",color:"#737373"},{id:"heading1",label:"Heading 1",preview:"Heading 1",type:"heading",level:1,fontSize:"30px",fontWeight:"600"},{id:"heading2",label:"Heading 2",preview:"Heading 2",type:"heading",level:2,fontSize:"24px",fontWeight:"600"},{id:"heading3",label:"Heading 3",preview:"Heading 3",type:"heading",level:3,fontSize:"20px",fontWeight:"600"},{id:"quote",label:"Quote",preview:"Quote",type:"blockquote",fontSize:"18px",fontStyle:"italic",color:"#525252"},{id:"caption",label:"Caption",preview:"Caption",type:"paragraph",fontSize:"12px",fontWeight:"400",color:"#737373",letterSpacing:"0.025em"}],N1=/^(#{1,6}\s|[*_]{1,2}\S|^[-*+]\s|^\d+\.\s|^>\s|^```|^!\[|^\[)/m,ci=" ",ui=" ",pr=50,hr=200,tu=10,os="VOILABS_REACT_EDITOR_THEME",wh=e=>{if(!e)return null;const t=decodeURIComponent(e).trim().replace(/^["']|["']$/g,"").toLowerCase();return t==="dark"||t==="light"?t:null},O1=()=>typeof document>"u"?null:document.cookie.split(";").map(t=>t.trim()).filter(t=>t.startsWith(`${os}=`)).map(t=>{const[,...n]=t.split("=");return wh(n.join("="))}).filter(Boolean).at(-1)??null,I1=()=>{if(typeof window>"u")return null;try{return wh(window.localStorage.getItem(os))}catch{return null}},di=()=>O1()??I1(),P1=e=>{if(typeof document<"u"&&(document.cookie=`${os}=${encodeURIComponent(e)}; path=/; max-age=31536000; SameSite=Lax`),typeof window<"u")try{window.localStorage.setItem(os,e)}catch{}},L1=e=>e==="dark"?{backgroundColor:"#171717",color:"#f5f5f5",colorScheme:"dark"}:{backgroundColor:"#ffffff",color:"#171717",colorScheme:"light"},D1=e=>e==="dark"?{backgroundColor:"rgba(23, 23, 23, 0.95)",color:"#a3a3a3",colorScheme:"dark"}:{backgroundColor:"rgba(255, 255, 255, 0.95)",color:"#737373",colorScheme:"light"},j1=e=>{const t=e.trim();return t?t.split(/\s+/).length:0};function z1(e){if(!e)return!1;const t=e.trim();return t.startsWith("<")?!1:N1.test(t)}function _1(e,t){return e==="html"?"html":e==="markdown"||t&&z1(t)?"markdown":"html"}const fi=(e,t)=>{const n=t.parseInline(e);return e.length===1&&e[0].type==="text"&&(e[0].raw===ci||e[0].text===ci||e[0].raw===ui||e[0].text===ui)&&n.length===1&&n[0].type==="text"&&(n[0].text===ci||n[0].text===ui)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,n)},nu=(e,t)=>{if(t==="start"){let r=0;for(;r<e.length&&e[r]?.type==="br";)r+=1;return e.slice(r)}let n=e.length;for(;n>0&&e[n-1]?.type==="br";)n-=1;return e.slice(0,n)},$1=Tm.extend({parseMarkdown:(e,t)=>{const n=e.tokens||[];if(n.length===1&&n[0].type==="image")return t.parseChildren([n[0]]);if(!n.some(a=>a.type==="image"))return fi(n,t);const r=[];let o=[],s=0;const i=a=>{let l=nu(o,"start");a&&(l=nu(l,"end")),o=[],l.length!==0&&r.push(fi(l,t))};for(;s<n.length;){const a=n[s];if(a?.type==="image"){i(!0);const l=t.parseChildren([a]);for(Array.isArray(l)?r.push(...l):l&&r.push(l),s+=1;s<n.length&&n[s]?.type==="br";)s+=1;continue}o.push(a),s+=1}return i(!1),r.length>0?r:fi(n,t)}}),F1=({value:e,onChange:t,format:n,theme:r="auto",onUpload:o,disableVideoUpload:s,disableImageUpload:i,classNames:a,translations:l,styles:c})=>{const u={...Xn,...l},d=c??vh,f=K.useRef(null),p=r==="dark"||r==="light"?r:null,m=!p,[g,b]=K.useState(p??"auto"),[x,S]=K.useState(!1),[k,y]=K.useState(0),[T,w]=K.useState(100),[C,A]=K.useState(!1),I=Tr.useEditor({extensions:[Sh.configure({paragraph:!1,dropcursor:{color:"#0ea5e9",width:3,class:"rounded-full transition-all duration-100 ease-in-out"}}),Mh,$1,Eh.configure({types:["heading","paragraph"]}),Ah.configure({placeholder:({node:N})=>N.type.name==="heading"?`${u.placeholderHeading} ${N.attrs.level}`:N.type.name==="blockquote"?u.placeholderQuote:u.placeholder}),Th.configure({openOnClick:!1}),bh,xh,qm,Md,yh,E1,M1,Rd,Xm.configure({multicolor:!0}),Ym,Zm,wu,vu.configure({nested:!0,HTMLAttributes:{class:M("flex items-start gap-3 my-2 group","[&>div]:flex-auto [&>div]:min-w-0 [&>div>p]:m-0","data-[checked='true']:[&>div]:line-through data-[checked='true']:[&>div]:opacity-50 data-[checked='true']:[&>div]:transition-all data-[checked='true']:[&>div]:duration-300","[&>label]:flex-none [&>label]:pt-[5px] [&>label]:select-none [&>label]:cursor-pointer","[&_input[type='checkbox']]:appearance-none [&_input[type='checkbox']]:m-0","[&_input[type='checkbox']]:w-[18px] [&_input[type='checkbox']]:h-[18px]","[&_input[type='checkbox']]:border-2 [&_input[type='checkbox']]:rounded-[5px]","[&_input[type='checkbox']]:transition-all [&_input[type='checkbox']]:duration-200","[&_input[type='checkbox']]:flex [&_input[type='checkbox']]:items-center [&_input[type='checkbox']]:justify-center","[&_input[type='checkbox']]:border-neutral-300 dark:[&_input[type='checkbox']]:border-neutral-600","[&_input[type='checkbox']]:bg-white dark:[&_input[type='checkbox']]:bg-neutral-800","hover:[&_input[type='checkbox']]:border-sky-400 dark:hover:[&_input[type='checkbox']]:border-sky-500","[&_input[type='checkbox']:checked]:bg-sky-500 [&_input[type='checkbox']:checked]:border-sky-500","[&_input[type='checkbox']:checked:after]:content-['']","[&_input[type='checkbox']:checked:after]:block","[&_input[type='checkbox']:checked:after]:w-[4px]","[&_input[type='checkbox']:checked:after]:h-[8px]","[&_input[type='checkbox']:checked:after]:border-white","[&_input[type='checkbox']:checked:after]:border-r-2","[&_input[type='checkbox']:checked:after]:border-b-2","[&_input[type='checkbox']:checked:after]:rotate-45","[&_input[type='checkbox']:checked:after]:-mt-[2px]")}}),Ad,sx,ox,rx,Sm.configure({markedOptions:{breaks:!0,gfm:!0}}),y1.configure({enableImages:!i,translations:u,classNames:a,onRequestImage:o?async({editor:N,range:$})=>new Promise(V=>{const _=document.createElement("input");_.type="file",_.accept="image/*",_.onchange=async()=>{_.files?.length?V({kind:"file",file:_.files[0]}):V(null)},_.click()}):null,onInsertLocalImageFile:o?async({editor:N,range:$,file:V})=>{N.chain().focus().deleteRange($).run();const{url:_}=await o(V);N.chain().focus().setAdvancedImage({src:_}).run()}:null})],editorProps:{handleDrop:(N,$,V,_)=>{if(_||!o||i||!$.dataTransfer?.files?.length)return!1;const z=Array.from($.dataTransfer.files).filter(se=>se.type.startsWith("image/"));if(z.length===0)return!1;$.preventDefault();const W=N.posAtCoords({left:$.clientX,top:$.clientY}),re=W?W.pos:N.state.selection.from;return z.forEach(async se=>{const le=URL.createObjectURL(se),{tr:te}=N.state,G=N.state.schema.nodes.image.create({src:le,isUploading:!0});te.insert(re,G),N.dispatch(te);try{const{url:H}=await o(se);let J=null;N.state.doc.descendants((oe,ge)=>{if(oe.type.name==="image"&&oe.attrs.src===le)return J=ge,!1}),J!==null&&N.dispatch(N.state.tr.setNodeMarkup(J,void 0,{...N.state.doc.nodeAt(J)?.attrs,src:H,isUploading:!1}))}catch{let J=null;N.state.doc.descendants((oe,ge)=>{if(oe.type.name==="image"&&oe.attrs.src===le)return J=ge,!1}),J!==null&&N.dispatch(N.state.tr.delete(J,J+1))}}),!0},handlePaste:(N,$,V)=>{if(!o||i||!$.clipboardData?.files?.length)return!1;const R=Array.from($.clipboardData.files).filter(W=>W.type.startsWith("image/"));if(R.length===0)return!1;$.preventDefault();const z=N.state.selection.from;return R.forEach(async W=>{const re=URL.createObjectURL(W),{tr:se}=N.state,le=N.state.schema.nodes.image.create({src:re,isUploading:!0});se.insert(z,le),N.dispatch(se);try{const{url:te}=await o(W);let G=null;N.state.doc.descendants((H,J)=>{if(H.type.name==="image"&&H.attrs.src===re)return G=J,!1}),G!==null&&N.dispatch(N.state.tr.setNodeMarkup(G,void 0,{...N.state.doc.nodeAt(G)?.attrs,src:te,isUploading:!1}))}catch{let G=null;N.state.doc.descendants((H,J)=>{if(H.type.name==="image"&&H.attrs.src===re)return G=J,!1}),G!==null&&N.dispatch(N.state.tr.delete(G,G+1))}}),!0}},onUpdate:({editor:N})=>{t&&t(N.getMarkdown())}});K.useEffect(()=>{if(p){b(p);return}const N=di();N&&b(N)},[p]),K.useEffect(()=>{if(p||di()||typeof window>"u")return;const N=window.matchMedia?.("(prefers-color-scheme: dark)");if(!N)return;const $=V=>{di()||b(V.matches?"dark":"light")};return N.addEventListener("change",$),()=>{N.removeEventListener("change",$)}},[p]),K.useEffect(()=>{(async()=>{if(e&&I&&!x)try{const N=_1(n,e);await I.commands.setContent(e,{contentType:N}),S(!0)}catch(N){console.error(N)}})()},[e,I]),K.useEffect(()=>{if(!I)return;const N=()=>{y(j1(I.getText()))};return N(),I.on("update",N),I.on("transaction",N),()=>{I.off("update",N),I.off("transaction",N)}},[I]),K.useEffect(()=>{if(typeof document>"u")return;const N=()=>{if(!document.fullscreenElement){A(!1);return}document.fullscreenElement===f.current&&A(!0)};return document.addEventListener("fullscreenchange",N),()=>{document.removeEventListener("fullscreenchange",N)}},[]);const O=N=>{w($=>Math.min(hr,Math.max(pr,$+N)))},j=()=>{const N=!C;if(A(N),!(typeof document>"u")){if(N){f.current?.requestFullscreen?.().catch(()=>{});return}document.fullscreenElement&&document.exitFullscreen?.().catch(()=>{})}},D=N=>{p||(b(N),P1(N))},F=L1(g),B=D1(g);return h.jsx(Fn.Provider,{children:h.jsx(Wr.Provider,{value:{theme:g,translations:u,classNames:a,styles:d},children:h.jsxs("div",{ref:f,"data-theme":g,"data-voilabs-react-editor-theme":g,style:F,className:M("flex h-[100dvh] min-h-0 max-h-[100dvh] flex-col overflow-hidden relative antialiased transition-colors",a?.root,g==="dark"&&"dark",g==="dark"?"bg-neutral-900 text-neutral-100":"bg-white text-neutral-900",C&&"fixed inset-0 z-[9998] h-screen w-screen rounded-none"),children:[h.jsx(Up,{editor:I,onUpload:o,disableVideoUpload:s,disableImageUpload:i,classNames:a,translations:l,styles:d,onThemeChange:D,showThemeToggle:m}),h.jsx("div",{style:F,className:M("w-full min-h-0 flex-1 overflow-y-auto overflow-x-hidden",C&&"min-h-0",a?.content,a?.contentScroller,a?.editorContent,g==="dark"?"bg-neutral-900":"bg-white"),children:h.jsxs("div",{style:{...F,zoom:T/100},className:M("w-full max-w-4xl mx-auto px-4 py-8 relative",a?.contentInner,g==="dark"?"bg-neutral-900 text-neutral-100":"bg-white text-neutral-900"),children:[I&&h.jsx(R1,{editor:I}),h.jsx(Tr.EditorContent,{editor:I,className:M("w-full prose max-w-none p-0! m-0!","prose-p:my-1.5 prose-p:leading-7","prose-headings:font-semibold prose-headings:tracking-tight","prose-h1:text-3xl prose-h1:mt-8 prose-h1:mb-3","prose-h2:text-2xl prose-h2:mt-6 prose-h2:mb-2","prose-h3:text-xl prose-h3:mt-5 prose-h3:mb-2","prose-h4:text-lg prose-h4:mt-4 prose-h4:mb-1.5","prose-h5:text-base prose-h5:mt-3 prose-h5:mb-1","prose-input[type='checkbox']:w-5","prose-a:text-blue-500 prose-a:no-underline hover:prose-a:underline prose-a:font-normal","[&_ul]:px-4 [&_ol]:px-4","[&_ul]:m-[1.25rem_1rem_1.25rem_0.4rem] [&_ol]:m-[1.25rem_1rem_1.25rem_0.4rem]","[&_li_p]:my-[0.25em]","prose-blockquote:border-l-2 prose-blockquote:my-4 prose-blockquote:py-0.5 prose-blockquote:not-italic","prose-code:rounded prose-code:px-1 prose-code:py-0.5 prose-code:text-sm prose-code:before:content-none prose-code:after:content-none","prose-pre:rounded-xl prose-pre:my-4","prose-img:max-w-full prose-img:rounded-lg prose-img:my-3","[&_video]:max-w-full [&_video]:w-full [&_video]:rounded-lg [&_video]:my-3","[&>.tiptap]:outline-none [&>.tiptap]:min-h-[400px]","[&>.tiptap>*:first-child]:mt-0 [&>.tiptap>*:last-child]:mb-0","[&_mark]:rounded [&_mark]:px-0.5","[&_ul[data-type='taskList']]:list-none [&_ul[data-type='taskList']]:ml-0 [&_ul[data-type='taskList']]:p-0","[&_ul[data-type='taskList']_ul[data-type='taskList']]:m-0","[&_li[data-type='taskItem']]:flex [&_li[data-type='taskItem']]:items-start [&_li[data-type='taskItem']]:mb-2.5","[&_li[data-type='taskItem']>label]:flex [&_li[data-type='taskItem']>label]:items-center [&_li[data-type='taskItem']>label]:justify-center [&_li[data-type='taskItem']>label]:flex-none [&_li[data-type='taskItem']>label]:mr-2 [&_li[data-type='taskItem']>label]:select-none [&_li[data-type='taskItem']>label]:pt-[5px]","[&_li[data-type='taskItem']>label>input]:appearance-none [&_li[data-type='taskItem']>label>input]:m-0 [&_li[data-type='taskItem']>label>input]:w-[18px] [&_li[data-type='taskItem']>label>input]:h-[18px] [&_li[data-type='taskItem']>label>input]:rounded-[5px] [&_li[data-type='taskItem']>label>input]:border-2 [&_li[data-type='taskItem']>label>input]:transition-all [&_li[data-type='taskItem']>label>input]:cursor-pointer [&_li[data-type='taskItem']>label>input]:flex [&_li[data-type='taskItem']>label>input]:items-center [&_li[data-type='taskItem']>label>input]:justify-center",g==="dark"?"[&_li[data-type='taskItem']>label>input]:border-neutral-700 [&_li[data-type='taskItem']>label>input]:bg-neutral-800 hover:[&_li[data-type='taskItem']>label>input]:border-sky-500/50":"[&_li[data-type='taskItem']>label>input]:border-neutral-300 [&_li[data-type='taskItem']>label>input]:bg-white hover:[&_li[data-type='taskItem']>label>input]:border-sky-400","[&_li[data-type='taskItem'][data-checked='true']>label>input]:bg-sky-500 [&_li[data-type='taskItem'][data-checked='true']>label>input]:border-sky-500","[&_li[data-type='taskItem'][data-checked='true']>label>input]:after:content-[''] [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:block [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:w-[4px] [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:h-[8px] [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:border-white [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:border-r-2 [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:border-b-2 [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:rotate-45 [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:-mt-[2px]","[&_li[data-type='taskItem']>div]:flex-auto [&_li[data-type='taskItem']>div]:min-w-0 [&_li[data-type='taskItem']>div>p]:m-0","[&_li[data-type='taskItem'][data-checked='true']>div]:opacity-40 [&_li[data-type='taskItem'][data-checked='true']>div]:line-through [&_li[data-type='taskItem'][data-checked='true']>div]:transition-all [&_li[data-type='taskItem'][data-checked='true']>div]:duration-300","[&_.node-advancedImage]:block [&_.node-advancedImage]:max-w-full",a?.prose,g==="dark"?"prose-invert [&>.tiptap]:text-neutral-100 [&>.tiptap_*::selection]:bg-blue-500/30 [&_mark]:bg-yellow-400/20 [&_mark]:text-yellow-200":"[&>.tiptap]:text-neutral-900 [&>.tiptap_*::selection]:bg-blue-200/40 [&_mark]:bg-yellow-200 [&_mark]:text-yellow-900",g==="dark"?"[&_p.is-empty::before]:text-neutral-600":"[&_p.is-empty::before]:text-neutral-400","[&_p.is-empty::before]:content-[attr(data-placeholder)]","[&_p.is-empty::before]:float-left","[&_p.is-empty::before]:h-0","[&_p.is-empty::before]:pointer-events-none")})]})}),h.jsxs("div",{style:B,className:M("flex shrink-0 items-center justify-between gap-3 border-t px-4 py-2 text-xs font-medium backdrop-blur-md",a?.footer,g==="dark"?"border-white/8 bg-neutral-900/95 text-neutral-400":"border-black/6 bg-white/95 text-neutral-500"),children:[h.jsxs("div",{className:M("min-w-0 truncate",a?.footerWordCount),children:[k," ",k===1?u.word:u.words]}),h.jsxs("div",{className:M("flex items-center gap-1",a?.footerControls),children:[h.jsxs("div",{className:M("flex items-center gap-0.5",a?.footerZoomGroup),children:[h.jsx(kt,{content:u.zoomOut,children:h.jsx("button",{type:"button",onClick:()=>O(-tu),disabled:T<=pr,"aria-label":u.zoomOut,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors",g==="dark"?"text-neutral-400":"text-neutral-500",T>pr&&(g==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900"),T<=pr&&"cursor-not-allowed opacity-30",T<=pr&&a?.footerButtonDisabled,a?.footerButton,a?.footerZoomButton),children:h.jsx(q.Minus,{size:14})})}),h.jsx(kt,{content:u.resetZoom,children:h.jsxs("button",{type:"button",onClick:()=>w(100),"aria-label":u.resetZoom,className:M("h-8 min-w-14 rounded-full px-2 text-center tabular-nums transition-colors",g==="dark"?"text-neutral-300 hover:bg-white/10 hover:text-neutral-100":"text-neutral-600 hover:bg-black/6 hover:text-neutral-900",a?.footerButton,a?.footerZoomValue),children:[T,"%"]})}),h.jsx(kt,{content:u.zoomIn,children:h.jsx("button",{type:"button",onClick:()=>O(tu),disabled:T>=hr,"aria-label":u.zoomIn,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors",g==="dark"?"text-neutral-400":"text-neutral-500",T<hr&&(g==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900"),T>=hr&&"cursor-not-allowed opacity-30",T>=hr&&a?.footerButtonDisabled,a?.footerButton,a?.footerZoomButton),children:h.jsx(q.Plus,{size:14})})})]}),h.jsx(kt,{content:C?u.exitFullscreen:u.fullscreen,children:h.jsx("button",{type:"button",onClick:j,"aria-label":C?u.exitFullscreen:u.fullscreen,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors",g==="dark"?"text-neutral-400 hover:bg-white/10 hover:text-neutral-100":"text-neutral-500 hover:bg-black/6 hover:text-neutral-900",a?.footerButton,a?.footerFullscreenButton),children:C?h.jsx(q.Minimize2,{size:14}):h.jsx(q.Maximize2,{size:14})})})]})]})]})})})};exports.AdvancedImage=bh;exports.DEFAULT_PARAGRAPH_STYLES=vh;exports.Editor=F1;exports.FontSize=yh;exports.Toolbar=Up;exports.Video=xh;
|
|
151
|
+
`);navigator.clipboard.writeText(I)},f=()=>{if(!s)return;const{node:w}=s;let C=w.attrs.id;C||(C=`block-${Math.random().toString(36).substr(2,9)}`,e.chain().setNodeSelection(s.pos).updateAttributes(w.type.name,{id:C}).run());const T=new URL(window.location.href);T.hash=C,navigator.clipboard.writeText(T.toString())},p=()=>{if(!s?.isImage)return;const w=s.node.attrs.src;if(!w)return;const C=document.createElement("a");C.href=w,C.download="image.png",document.body.appendChild(C),C.click(),document.body.removeChild(C)},m=(w,C)=>{s&&e.chain().setNodeSelection(s.pos).toggleNode(w,w,C?{level:C}:{}).run()},g=()=>{if(!s)return;const{pos:w,node:C}=s;e.chain().setTextSelection({from:w,to:w+C.nodeSize}).unsetAllMarks().run()},[b,x]=K.useState(!1),S=w=>{o.current&&(o.current.dataset.dropdownOpen=w?"true":"false"),w&&a(),x(w)},k=w=>{const C=a()||s;if(!C){w.preventDefault();return}const T=e.view;e.commands.setNodeSelection(C.pos);const I=T.state.selection.content();let O=null,j="";try{const F=typeof T.serializeForClipboard=="function"?T.serializeForClipboard(I):T.__serializeForClipboard?.(T,I);F&&(O=F.dom,j=F.text)}catch(F){console.error("Failed to serialize node for drag",F)}if(!O){w.preventDefault();return}w.dataTransfer.clearData(),w.dataTransfer.setData("text/html",O.innerHTML),w.dataTransfer.setData("text/plain",j),w.dataTransfer.effectAllowed="copyMove";const D=T.nodeDOM(C.pos);D instanceof HTMLElement&&w.dataTransfer.setDragImage(D,0,0),T.dragging={slice:I,move:!0}};let y="",A="";return s?.node&&s.node.descendants(w=>{w.isText&&w.marks&&w.marks.forEach(C=>{C.type.name==="textStyle"&&C.attrs.color&&!y&&(y=C.attrs.color),C.type.name==="highlight"&&C.attrs.color&&!A&&(A=C.attrs.color)})}),h.jsxs("div",{ref:o,className:M("absolute z-50 flex items-center transition-[opacity,top] duration-150 gap-1 opacity-0 pointer-events-none",r?.dragHandleRoot),children:[h.jsx("button",{className:M("p-1 rounded-md bg-transparent transition-colors pointer-events-auto",t==="dark"?"hover:bg-neutral-800 text-neutral-400 hover:text-neutral-100":"hover:bg-neutral-100 text-neutral-400 hover:text-neutral-900",r?.dragHandleAddButton),title:n.addBlockBelow,onClick:l,children:h.jsx(q.Plus,{className:"w-4 h-4"})}),h.jsxs(Dp,{open:b,onOpenChange:S,children:[h.jsxs("div",{className:"relative flex",children:[h.jsx(jp,{asChild:!0,children:h.jsx("div",{className:"absolute inset-0 w-full h-full pointer-events-none opacity-0"})}),h.jsx("button",{className:M("p-1 rounded-md bg-transparent transition-colors cursor-grab active:cursor-grabbing pointer-events-auto",t==="dark"?"hover:bg-neutral-800 text-neutral-400 hover:text-neutral-100":"hover:bg-neutral-100 text-neutral-400 hover:text-neutral-900",r?.dragHandleMenuButton),title:n.options,draggable:!0,onDragStart:k,onClick:()=>S(!0),children:h.jsx(q.GripVertical,{className:"w-4 h-4"})})]}),h.jsxs(Ga,{className:M("w-56",r?.dragHandleMenuContent),align:"start",children:[s?.isText&&h.jsxs(h.Fragment,{children:[h.jsxs(Lc,{children:[h.jsxs(qi,{children:[h.jsx(q.Type,{className:"w-4 h-4"}),n.turnInto]}),h.jsx(Pc,{children:h.jsxs(Ki,{className:M("w-48",r?.dragHandleSubContent),children:[h.jsxs(Ke,{onClick:()=>m("paragraph"),children:[h.jsx(q.Type,{className:"w-4 h-4"})," ",n.text,s.node.type.name==="paragraph"&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]}),h.jsxs(Ke,{onClick:()=>m("heading",1),children:[h.jsx(q.Heading1,{className:"w-4 h-4"})," ",n.heading1,s.node.type.name==="heading"&&s.node.attrs.level===1&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]}),h.jsxs(Ke,{onClick:()=>m("heading",2),children:[h.jsx(q.Heading2,{className:"w-4 h-4"})," ",n.heading2,s.node.type.name==="heading"&&s.node.attrs.level===2&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]}),h.jsxs(Ke,{onClick:()=>m("heading",3),children:[h.jsx(q.Heading3,{className:"w-4 h-4"})," ",n.heading3,s.node.type.name==="heading"&&s.node.attrs.level===3&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]})]})})]}),h.jsxs(Lc,{children:[h.jsxs(qi,{children:[h.jsx(q.Palette,{className:"w-4 h-4"}),n.color]}),h.jsx(Pc,{children:h.jsxs(Ki,{className:M("w-64 max-h-80 overflow-y-auto",r?.dragHandleSubContent),children:[h.jsx("div",{className:M("px-2 py-1.5 text-xs font-semibold text-neutral-500 uppercase tracking-wider",r?.dragHandleColorSectionLabel),children:n.textColor}),[{label:n.defaultText,color:""},{label:n.grayText,color:"#6b7280"},{label:n.brownText,color:"#78350f"},{label:n.orangeText,color:"#f97316"},{label:n.yellowText,color:"#eab308"},{label:n.greenText,color:"#22c55e"},{label:n.blueText,color:"#3b82f6"},{label:n.purpleText,color:"#a855f7"},{label:n.pinkText,color:"#ec4899"},{label:n.redText,color:"#ef4444"}].map(w=>h.jsxs(Ke,{onClick:()=>{if(s){const C=e.chain().setNodeSelection(s.pos);w.color?C.setColor(w.color).run():C.unsetColor().run()}},children:[h.jsx("div",{className:M("font-bold flex items-center justify-center text-[14px]",r?.dragHandleColorTextPreview),style:{color:w.color||"inherit"},children:"A"}),w.label,y===w.color&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]},w.label)),h.jsx(xr,{}),h.jsx("div",{className:M("px-2 py-1.5 text-xs font-semibold text-neutral-500 uppercase tracking-wider",r?.dragHandleColorSectionLabel),children:n.background}),[{label:n.defaultBackground,color:""},{label:n.grayBackground,color:"#f3f4f6"},{label:n.brownBackground,color:"#fef3c7"},{label:n.orangeBackground,color:"#ffedd5"},{label:n.yellowBackground,color:"#fef08a"},{label:n.greenBackground,color:"#dcfce7"},{label:n.blueBackground,color:"#dbeafe"},{label:n.purpleBackground,color:"#f3e8ff"},{label:n.pinkBackground,color:"#fce7f3"},{label:n.redBackground,color:"#fee2e2"}].map(w=>h.jsxs(Ke,{onClick:()=>{if(s){const C=e.chain().setNodeSelection(s.pos);w.color?C.setHighlight({color:w.color}).run():C.unsetHighlight().run()}},children:[h.jsx("div",{className:M("w-4 h-4 rounded-full border",t==="dark"?"border-neutral-700/20":"border-neutral-200/20",r?.dragHandleColorSwatch),style:{backgroundColor:w.color||"transparent"}}),w.label,A===w.color&&h.jsx(q.Check,{className:M("ml-auto w-4 h-4",r?.dragHandleCheckIcon)})]},w.label))]})})]}),h.jsxs(Ke,{onClick:g,children:[h.jsx(q.RotateCcw,{className:"w-4 h-4"}),n.resetFormatting]}),h.jsx(xr,{})]}),s?.isImage&&h.jsxs(h.Fragment,{children:[h.jsxs(Ke,{onClick:p,children:[h.jsx(q.Download,{className:"w-4 h-4"}),n.download]}),h.jsx(xr,{})]}),h.jsxs(Ke,{onClick:c,children:[h.jsx(q.Copy,{className:"w-4 h-4"}),n.duplicateNode]}),h.jsxs(Ke,{onClick:d,children:[h.jsx(q.Copy,{className:"w-4 h-4"}),n.copyToClipboard]}),h.jsxs(Ke,{onClick:f,children:[h.jsx(q.Link,{className:"w-4 h-4"}),n.copyAnchorLink]}),h.jsx(xr,{}),h.jsxs(Ke,{className:M(t==="dark"?"text-red-400 focus:bg-red-950/30":"text-red-600 focus:bg-red-50",r?.dragHandleDeleteItem),onClick:u,children:[h.jsx(q.Trash2,{className:"w-4 h-4"}),n.delete]})]})]})]})},kh=[{id:"normal",label:"Normal text",type:"paragraph"},{id:"title",label:"Title",preview:"Title",type:"heading",level:1,fontSize:"36px",fontWeight:"700",letterSpacing:"-0.025em"},{id:"subtitle",label:"Subtitle",preview:"Subtitle",type:"paragraph",fontSize:"18px",fontWeight:"400",fontStyle:"normal",color:"#737373"},{id:"heading1",label:"Heading 1",preview:"Heading 1",type:"heading",level:1,fontSize:"30px",fontWeight:"600"},{id:"heading2",label:"Heading 2",preview:"Heading 2",type:"heading",level:2,fontSize:"24px",fontWeight:"600"},{id:"heading3",label:"Heading 3",preview:"Heading 3",type:"heading",level:3,fontSize:"20px",fontWeight:"600"},{id:"quote",label:"Quote",preview:"Quote",type:"blockquote",fontSize:"18px",fontStyle:"italic",color:"#525252"},{id:"caption",label:"Caption",preview:"Caption",type:"paragraph",fontSize:"12px",fontWeight:"400",color:"#737373",letterSpacing:"0.025em"}],I1=/^(#{1,6}\s|[*_]{1,2}\S|^[-*+]\s|^\d+\.\s|^>\s|^```|^!\[|^\[)/m,di=" ",fi=" ",pr=50,hr=200,ru=10,is="VOILABS_REACT_EDITOR_THEME",Ch=e=>{if(!e)return null;const t=decodeURIComponent(e).trim().replace(/^["']|["']$/g,"").toLowerCase();return t==="dark"||t==="light"?t:null},P1=()=>typeof document>"u"?null:document.cookie.split(";").map(t=>t.trim()).filter(t=>t.startsWith(`${is}=`)).map(t=>{const[,...n]=t.split("=");return Ch(n.join("="))}).filter(Boolean).at(-1)??null,L1=()=>{if(typeof window>"u")return null;try{return Ch(window.localStorage.getItem(is))}catch{return null}},pi=()=>P1()??L1(),D1=e=>{if(typeof document<"u"&&(document.cookie=`${is}=${encodeURIComponent(e)}; path=/; max-age=31536000; SameSite=Lax`),typeof window<"u")try{window.localStorage.setItem(is,e)}catch{}},j1=e=>e==="dark"?{backgroundColor:"#171717",color:"#f5f5f5",colorScheme:"dark"}:{backgroundColor:"#ffffff",color:"#171717",colorScheme:"light"},z1=e=>e==="dark"?{backgroundColor:"rgba(23, 23, 23, 0.95)",color:"#a3a3a3",colorScheme:"dark"}:{backgroundColor:"rgba(255, 255, 255, 0.95)",color:"#737373",colorScheme:"light"},_1=e=>{const t=e.trim();return t?t.split(/\s+/).length:0};function $1(e){if(!e)return!1;const t=e.trim();return t.startsWith("<")?!1:I1.test(t)}function F1(e,t){return e==="html"?"html":e==="markdown"||t&&$1(t)?"markdown":"html"}const hi=(e,t)=>{const n=t.parseInline(e);return e.length===1&&e[0].type==="text"&&(e[0].raw===di||e[0].text===di||e[0].raw===fi||e[0].text===fi)&&n.length===1&&n[0].type==="text"&&(n[0].text===di||n[0].text===fi)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,n)},ou=(e,t)=>{if(t==="start"){let r=0;for(;r<e.length&&e[r]?.type==="br";)r+=1;return e.slice(r)}let n=e.length;for(;n>0&&e[n-1]?.type==="br";)n-=1;return e.slice(0,n)},B1=Em.extend({parseMarkdown:(e,t)=>{const n=e.tokens||[];if(n.length===1&&n[0].type==="image")return t.parseChildren([n[0]]);if(!n.some(a=>a.type==="image"))return hi(n,t);const r=[];let o=[],s=0;const i=a=>{let l=ou(o,"start");a&&(l=ou(l,"end")),o=[],l.length!==0&&r.push(hi(l,t))};for(;s<n.length;){const a=n[s];if(a?.type==="image"){i(!0);const l=t.parseChildren([a]);for(Array.isArray(l)?r.push(...l):l&&r.push(l),s+=1;s<n.length&&n[s]?.type==="br";)s+=1;continue}o.push(a),s+=1}return i(!1),r.length>0?r:hi(n,t)}}),H1=({value:e,onChange:t,format:n,theme:r="auto",onUpload:o,disableVideoUpload:s,disableImageUpload:i,classNames:a,translations:l,styles:c})=>{const u={...Xn,...l},d=c??kh,f=K.useRef(null),p=r==="dark"||r==="light"?r:null,m=!p,[g,b]=K.useState(p??"auto"),[x,S]=K.useState(!1),[k,y]=K.useState(0),[A,w]=K.useState(100),[C,T]=K.useState(!1),I=Tr.useEditor({extensions:[Ah.configure({paragraph:!1,dropcursor:{color:"#0ea5e9",width:3,class:"rounded-full transition-all duration-100 ease-in-out"}}),Nh,B1,Rh.configure({types:["heading","paragraph"]}),Mh.configure({placeholder:({node:N})=>N.type.name==="heading"?`${u.placeholderHeading} ${N.attrs.level}`:N.type.name==="blockquote"?u.placeholderQuote:u.placeholder}),Eh.configure({openOnClick:!1}),xh,wh,Um,Nd,vh,R1,N1,Od,Ym.configure({multicolor:!0}),Zm,tg,Cu,ku.configure({nested:!0,HTMLAttributes:{class:M("flex items-start gap-3 my-2 group","[&>div]:flex-auto [&>div]:min-w-0 [&>div>p]:m-0","data-[checked='true']:[&>div]:line-through data-[checked='true']:[&>div]:opacity-50 data-[checked='true']:[&>div]:transition-all data-[checked='true']:[&>div]:duration-300","[&>label]:flex-none [&>label]:pt-[5px] [&>label]:select-none [&>label]:cursor-pointer","[&_input[type='checkbox']]:appearance-none [&_input[type='checkbox']]:m-0","[&_input[type='checkbox']]:w-[18px] [&_input[type='checkbox']]:h-[18px]","[&_input[type='checkbox']]:border-2 [&_input[type='checkbox']]:rounded-[5px]","[&_input[type='checkbox']]:transition-all [&_input[type='checkbox']]:duration-200","[&_input[type='checkbox']]:flex [&_input[type='checkbox']]:items-center [&_input[type='checkbox']]:justify-center","[&_input[type='checkbox']]:border-neutral-300 dark:[&_input[type='checkbox']]:border-neutral-600","[&_input[type='checkbox']]:bg-white dark:[&_input[type='checkbox']]:bg-neutral-800","hover:[&_input[type='checkbox']]:border-sky-400 dark:hover:[&_input[type='checkbox']]:border-sky-500","[&_input[type='checkbox']:checked]:bg-sky-500 [&_input[type='checkbox']:checked]:border-sky-500","[&_input[type='checkbox']:checked:after]:content-['']","[&_input[type='checkbox']:checked:after]:block","[&_input[type='checkbox']:checked:after]:w-[4px]","[&_input[type='checkbox']:checked:after]:h-[8px]","[&_input[type='checkbox']:checked:after]:border-white","[&_input[type='checkbox']:checked:after]:border-r-2","[&_input[type='checkbox']:checked:after]:border-b-2","[&_input[type='checkbox']:checked:after]:rotate-45","[&_input[type='checkbox']:checked:after]:-mt-[2px]")}}),Md,ax,ix,sx,Am.configure({markedOptions:{breaks:!0,gfm:!0}}),v1.configure({enableImages:!i,translations:u,classNames:a,onRequestImage:o?async({editor:N,range:$})=>new Promise(V=>{const _=document.createElement("input");_.type="file",_.accept="image/*",_.onchange=async()=>{_.files?.length?V({kind:"file",file:_.files[0]}):V(null)},_.click()}):null,onInsertLocalImageFile:o?async({editor:N,range:$,file:V})=>{N.chain().focus().deleteRange($).run();const{url:_}=await o(V);N.chain().focus().setAdvancedImage({src:_}).run()}:null})],editorProps:{handleDrop:(N,$,V,_)=>{if(_||!o||i||!$.dataTransfer?.files?.length)return!1;const z=Array.from($.dataTransfer.files).filter(se=>se.type.startsWith("image/"));if(z.length===0)return!1;$.preventDefault();const W=N.posAtCoords({left:$.clientX,top:$.clientY}),re=W?W.pos:N.state.selection.from;return z.forEach(async se=>{const le=URL.createObjectURL(se),{tr:te}=N.state,G=N.state.schema.nodes.image.create({src:le,isUploading:!0});te.insert(re,G),N.dispatch(te);try{const{url:H}=await o(se);let J=null;N.state.doc.descendants((oe,ge)=>{if(oe.type.name==="image"&&oe.attrs.src===le)return J=ge,!1}),J!==null&&N.dispatch(N.state.tr.setNodeMarkup(J,void 0,{...N.state.doc.nodeAt(J)?.attrs,src:H,isUploading:!1}))}catch{let J=null;N.state.doc.descendants((oe,ge)=>{if(oe.type.name==="image"&&oe.attrs.src===le)return J=ge,!1}),J!==null&&N.dispatch(N.state.tr.delete(J,J+1))}}),!0},handlePaste:(N,$,V)=>{if(!o||i||!$.clipboardData?.files?.length)return!1;const R=Array.from($.clipboardData.files).filter(W=>W.type.startsWith("image/"));if(R.length===0)return!1;$.preventDefault();const z=N.state.selection.from;return R.forEach(async W=>{const re=URL.createObjectURL(W),{tr:se}=N.state,le=N.state.schema.nodes.image.create({src:re,isUploading:!0});se.insert(z,le),N.dispatch(se);try{const{url:te}=await o(W);let G=null;N.state.doc.descendants((H,J)=>{if(H.type.name==="image"&&H.attrs.src===re)return G=J,!1}),G!==null&&N.dispatch(N.state.tr.setNodeMarkup(G,void 0,{...N.state.doc.nodeAt(G)?.attrs,src:te,isUploading:!1}))}catch{let G=null;N.state.doc.descendants((H,J)=>{if(H.type.name==="image"&&H.attrs.src===re)return G=J,!1}),G!==null&&N.dispatch(N.state.tr.delete(G,G+1))}}),!0}},onUpdate:({editor:N})=>{t&&t(N.getMarkdown())}});K.useEffect(()=>{if(p){b(p);return}const N=pi();N&&b(N)},[p]),K.useEffect(()=>{if(p||pi()||typeof window>"u")return;const N=window.matchMedia?.("(prefers-color-scheme: dark)");if(!N)return;const $=V=>{pi()||b(V.matches?"dark":"light")};return N.addEventListener("change",$),()=>{N.removeEventListener("change",$)}},[p]),K.useEffect(()=>{(async()=>{if(e&&I&&!x)try{const N=F1(n,e);await I.commands.setContent(e,{contentType:N}),S(!0)}catch(N){console.error(N)}})()},[e,I]),K.useEffect(()=>{if(!I)return;const N=()=>{y(_1(I.getText()))};return N(),I.on("update",N),I.on("transaction",N),()=>{I.off("update",N),I.off("transaction",N)}},[I]),K.useEffect(()=>{if(typeof document>"u")return;const N=()=>{if(!document.fullscreenElement){T(!1);return}document.fullscreenElement===f.current&&T(!0)};return document.addEventListener("fullscreenchange",N),()=>{document.removeEventListener("fullscreenchange",N)}},[]);const O=N=>{w($=>Math.min(hr,Math.max(pr,$+N)))},j=()=>{const N=!C;if(T(N),!(typeof document>"u")){if(N){f.current?.requestFullscreen?.().catch(()=>{});return}document.fullscreenElement&&document.exitFullscreen?.().catch(()=>{})}},D=N=>{p||(b(N),D1(N))},F=j1(g),B=z1(g);return h.jsx(Fn.Provider,{children:h.jsx(Wr.Provider,{value:{theme:g,translations:u,classNames:a,styles:d},children:h.jsxs("div",{ref:f,"data-theme":g,"data-voilabs-react-editor-theme":g,style:F,className:M("flex h-[100dvh] min-h-0 max-h-[100dvh] flex-col overflow-hidden relative antialiased transition-colors",a?.root,g==="dark"&&"dark",g==="dark"?"bg-neutral-900 text-neutral-100":"bg-white text-neutral-900",C&&"fixed inset-0 z-[9998] h-screen w-screen rounded-none"),children:[h.jsx(Xp,{editor:I,onUpload:o,disableVideoUpload:s,disableImageUpload:i,classNames:a,translations:l,styles:d,onThemeChange:D,showThemeToggle:m}),h.jsx("div",{style:F,className:M("w-full min-h-0 flex-1 overflow-y-auto overflow-x-hidden",C&&"min-h-0",a?.content,a?.contentScroller,a?.editorContent,g==="dark"?"bg-neutral-900":"bg-white"),children:h.jsxs("div",{style:{...F,zoom:A/100},className:M("w-full max-w-4xl mx-auto px-4 py-8 relative",a?.contentInner,g==="dark"?"bg-neutral-900 text-neutral-100":"bg-white text-neutral-900"),children:[I&&h.jsx(O1,{editor:I}),h.jsx(Tr.EditorContent,{editor:I,className:M("w-full prose max-w-none p-0! m-0!","prose-p:my-1.5 prose-p:leading-7","prose-headings:font-semibold prose-headings:tracking-tight","prose-h1:text-3xl prose-h1:mt-8 prose-h1:mb-3","prose-h2:text-2xl prose-h2:mt-6 prose-h2:mb-2","prose-h3:text-xl prose-h3:mt-5 prose-h3:mb-2","prose-h4:text-lg prose-h4:mt-4 prose-h4:mb-1.5","prose-h5:text-base prose-h5:mt-3 prose-h5:mb-1","prose-input[type='checkbox']:w-5","prose-a:text-blue-500 prose-a:no-underline hover:prose-a:underline prose-a:font-normal","[&_ul]:px-4 [&_ol]:px-4","[&_ul]:m-[1.25rem_1rem_1.25rem_0.4rem] [&_ol]:m-[1.25rem_1rem_1.25rem_0.4rem]","[&_li_p]:my-[0.25em]","prose-blockquote:border-l-2 prose-blockquote:my-4 prose-blockquote:py-0.5 prose-blockquote:not-italic","prose-code:rounded prose-code:px-1 prose-code:py-0.5 prose-code:text-sm prose-code:before:content-none prose-code:after:content-none","prose-pre:rounded-xl prose-pre:my-4","prose-img:max-w-full prose-img:rounded-lg prose-img:my-3","[&_video]:max-w-full [&_video]:w-full [&_video]:rounded-lg [&_video]:my-3","[&>.tiptap]:outline-none [&>.tiptap]:min-h-[400px]","[&>.tiptap>*:first-child]:mt-0 [&>.tiptap>*:last-child]:mb-0","[&_mark]:rounded [&_mark]:px-0.5","[&_ul[data-type='taskList']]:list-none [&_ul[data-type='taskList']]:ml-0 [&_ul[data-type='taskList']]:p-0","[&_ul[data-type='taskList']_ul[data-type='taskList']]:m-0","[&_li[data-type='taskItem']]:flex [&_li[data-type='taskItem']]:items-start [&_li[data-type='taskItem']]:mb-2.5","[&_li[data-type='taskItem']>label]:flex [&_li[data-type='taskItem']>label]:items-center [&_li[data-type='taskItem']>label]:justify-center [&_li[data-type='taskItem']>label]:flex-none [&_li[data-type='taskItem']>label]:mr-2 [&_li[data-type='taskItem']>label]:select-none [&_li[data-type='taskItem']>label]:pt-[5px]","[&_li[data-type='taskItem']>label>input]:appearance-none [&_li[data-type='taskItem']>label>input]:m-0 [&_li[data-type='taskItem']>label>input]:w-[18px] [&_li[data-type='taskItem']>label>input]:h-[18px] [&_li[data-type='taskItem']>label>input]:rounded-[5px] [&_li[data-type='taskItem']>label>input]:border-2 [&_li[data-type='taskItem']>label>input]:transition-all [&_li[data-type='taskItem']>label>input]:cursor-pointer [&_li[data-type='taskItem']>label>input]:flex [&_li[data-type='taskItem']>label>input]:items-center [&_li[data-type='taskItem']>label>input]:justify-center",g==="dark"?"[&_li[data-type='taskItem']>label>input]:border-neutral-700 [&_li[data-type='taskItem']>label>input]:bg-neutral-800 hover:[&_li[data-type='taskItem']>label>input]:border-sky-500/50":"[&_li[data-type='taskItem']>label>input]:border-neutral-300 [&_li[data-type='taskItem']>label>input]:bg-white hover:[&_li[data-type='taskItem']>label>input]:border-sky-400","[&_li[data-type='taskItem'][data-checked='true']>label>input]:bg-sky-500 [&_li[data-type='taskItem'][data-checked='true']>label>input]:border-sky-500","[&_li[data-type='taskItem'][data-checked='true']>label>input]:after:content-[''] [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:block [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:w-[4px] [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:h-[8px] [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:border-white [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:border-r-2 [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:border-b-2 [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:rotate-45 [&_li[data-type='taskItem'][data-checked='true']>label>input]:after:-mt-[2px]","[&_li[data-type='taskItem']>div]:flex-auto [&_li[data-type='taskItem']>div]:min-w-0 [&_li[data-type='taskItem']>div>p]:m-0","[&_li[data-type='taskItem'][data-checked='true']>div]:opacity-40 [&_li[data-type='taskItem'][data-checked='true']>div]:line-through [&_li[data-type='taskItem'][data-checked='true']>div]:transition-all [&_li[data-type='taskItem'][data-checked='true']>div]:duration-300","[&_.node-advancedImage]:block [&_.node-advancedImage]:max-w-full",a?.prose,g==="dark"?"prose-invert [&>.tiptap]:text-neutral-100 [&>.tiptap_*::selection]:bg-blue-500/30 [&_mark]:bg-yellow-400/20 [&_mark]:text-yellow-200":"[&>.tiptap]:text-neutral-900 [&>.tiptap_*::selection]:bg-blue-200/40 [&_mark]:bg-yellow-200 [&_mark]:text-yellow-900",g==="dark"?"[&_p.is-empty::before]:text-neutral-600":"[&_p.is-empty::before]:text-neutral-400","[&_p.is-empty::before]:content-[attr(data-placeholder)]","[&_p.is-empty::before]:float-left","[&_p.is-empty::before]:h-0","[&_p.is-empty::before]:pointer-events-none")})]})}),h.jsxs("div",{style:B,className:M("flex shrink-0 items-center justify-between gap-3 border-t px-4 py-2 text-xs font-medium backdrop-blur-md",a?.footer,g==="dark"?"border-white/8 bg-neutral-900/95 text-neutral-400":"border-black/6 bg-white/95 text-neutral-500"),children:[h.jsxs("div",{className:M("min-w-0 truncate",a?.footerWordCount),children:[k," ",k===1?u.word:u.words]}),h.jsxs("div",{className:M("flex items-center gap-1",a?.footerControls),children:[h.jsxs("div",{className:M("flex items-center gap-0.5",a?.footerZoomGroup),children:[h.jsx(kt,{content:u.zoomOut,children:h.jsx("button",{type:"button",onClick:()=>O(-ru),disabled:A<=pr,"aria-label":u.zoomOut,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors",g==="dark"?"text-neutral-400":"text-neutral-500",A>pr&&(g==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900"),A<=pr&&"cursor-not-allowed opacity-30",A<=pr&&a?.footerButtonDisabled,a?.footerButton,a?.footerZoomButton),children:h.jsx(q.Minus,{size:14})})}),h.jsx(kt,{content:u.resetZoom,children:h.jsxs("button",{type:"button",onClick:()=>w(100),"aria-label":u.resetZoom,className:M("h-8 min-w-14 rounded-full px-2 text-center tabular-nums transition-colors",g==="dark"?"text-neutral-300 hover:bg-white/10 hover:text-neutral-100":"text-neutral-600 hover:bg-black/6 hover:text-neutral-900",a?.footerButton,a?.footerZoomValue),children:[A,"%"]})}),h.jsx(kt,{content:u.zoomIn,children:h.jsx("button",{type:"button",onClick:()=>O(ru),disabled:A>=hr,"aria-label":u.zoomIn,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors",g==="dark"?"text-neutral-400":"text-neutral-500",A<hr&&(g==="dark"?"hover:bg-white/10 hover:text-neutral-100":"hover:bg-black/6 hover:text-neutral-900"),A>=hr&&"cursor-not-allowed opacity-30",A>=hr&&a?.footerButtonDisabled,a?.footerButton,a?.footerZoomButton),children:h.jsx(q.Plus,{size:14})})})]}),h.jsx(kt,{content:C?u.exitFullscreen:u.fullscreen,children:h.jsx("button",{type:"button",onClick:j,"aria-label":C?u.exitFullscreen:u.fullscreen,className:M("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors",g==="dark"?"text-neutral-400 hover:bg-white/10 hover:text-neutral-100":"text-neutral-500 hover:bg-black/6 hover:text-neutral-900",a?.footerButton,a?.footerFullscreenButton),children:C?h.jsx(q.Minimize2,{size:14}):h.jsx(q.Maximize2,{size:14})})})]})]})]})})})};exports.AdvancedImage=xh;exports.DEFAULT_PARAGRAPH_STYLES=kh;exports.Editor=H1;exports.FontSize=vh;exports.Toolbar=Xp;exports.Video=wh;
|