markdown-text-editor 2.0.0-beta.1 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/markdown-text-editor.css +1 -1
- package/dist/markdown-text-editor.es.js +837 -785
- package/dist/markdown-text-editor.es.js.map +1 -1
- package/dist/markdown-text-editor.min.js +66 -66
- package/dist/markdown-text-editor.min.js.map +1 -1
- package/dist/markdown-text-editor.umd.js +66 -66
- package/dist/markdown-text-editor.umd.js.map +1 -1
- package/package.json +10 -7
|
@@ -1,51 +1,53 @@
|
|
|
1
|
-
var MarkdownEditor=(function(){function e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var t=e();function n(e){t=e}var r={exec:()=>null};function i(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function a(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(s.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var o=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),s={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,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,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}))
|
|
2
|
-
]`).replace(`lheading`,
|
|
1
|
+
var MarkdownEditor=(function(){function e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var t=e();function n(e){t=e}var r={exec:()=>null};function i(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function a(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(s.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var o=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),s={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,blockquoteMarkerWhitespace:/^( {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,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,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=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:i(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:i(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:i(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:i(e=>RegExp(`^ {0,${e}}#{1,6}(?:\\s|$)`)),pedanticHeadingBeginRegex:i(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:i(e=>RegExp(`^ {0,${e}}(?:</?(?:${y})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:i(e=>RegExp(`^ {0,${e}}>`))},c=/^(?:[ \t]*(?:\n|$))+/,l=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,u=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,d=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,f=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,p=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,m=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,h=a(m).replace(/bull/g,p).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),g=a(m).replace(/bull/g,p).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),_=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,v=/^[^\n]+/,ee=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,te=a(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,ee).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ne=a(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,p).getRegex(),y=`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`,b=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,re=a(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,b).replace(`tag`,y).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ie=e=>a(_).replace(`hr`,d).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,y).getRegex(),ae=ie(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),x=ie(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),S={blockquote:a(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/).replace(`paragraph`,x).getRegex(),code:l,def:te,fences:u,heading:f,hr:d,html:re,lheading:h,list:ne,newline:c,paragraph:ae,table:r,text:v},oe=a(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,d).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,y).getRegex(),se={...S,lheading:g,table:oe,paragraph:a(_).replace(`hr`,d).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,oe).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,y).getRegex()},ce={...S,html:a(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,b).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:r,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:a(_).replace(`hr`,d).replace(`heading`,` *#{1,6} *[^
|
|
2
|
+
]`).replace(`lheading`,h).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},le=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ue=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,de=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,fe=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,C=/[\p{P}\p{S}]/u,w=/[\s\p{P}\p{S}]/u,pe=/[^\s\p{P}\p{S}]/u,me=a(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,w).getRegex(),he=/[\p{Pi}\p{Ps}"']/u,ge=/(?!~)[\p{P}\p{S}]/u,T=/(?!~)[\s\p{P}\p{S}]/u,_e=/(?:[^\s\p{P}\p{S}]|~)/u,ve=a(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,o?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),ye=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,be=a(ye,`u`).replace(/punct/g,C).getRegex(),xe=a(ye,`u`).replace(/punct/g,ge).getRegex(),Se=a(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,he).replace(/punct/g,C).getRegex(),Ce=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,we=a(Ce,`gu`).replace(/notPunctSpace/g,pe).replace(/punctSpace/g,w).replace(/punct/g,C).getRegex(),Te=a(Ce,`gu`).replace(/notPunctSpace/g,_e).replace(/punctSpace/g,T).replace(/punct/g,ge).getRegex(),E=a(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,pe).replace(/punctSpace/g,w).replace(/punct/g,C).getRegex(),Ee=a(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,pe).replace(/punctSpace/g,w).replace(/punct/g,C).getRegex(),D=a(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,pe).replace(/punctSpace/g,w).replace(/punct/g,C).getRegex(),De=a(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,C).getRegex(),O=a(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,pe).replace(/punctSpace/g,w).replace(/punct/g,C).getRegex(),Oe=a(/\\(punct)/,`gu`).replace(/punct/g,C).getRegex(),ke=a(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,C).getRegex(),k=a(/^<(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(),Ae=a(b).replace(`(?:-->|$)`,`-->`).getRegex(),je=a(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Ae).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Me=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,Ne=a(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,Me).getRegex(),A=a(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,Ne).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Pe=a(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Ne).replace(`ref`,ee).getRegex(),Fe=a(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,ee).getRegex(),Ie=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,Le=a(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,Me).getRegex(),Re=a(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,a(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Le).replace(`ref`,Ie).getRegex()).replace(`nolink`,a(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Ie).getRegex()).getRegex(),ze=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Be=a(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),Ve={_backpedal:r,anyPunctuation:Oe,anyPunctuationOutsideCode:ke,autolink:k,blockSkip:ve,br:de,code:ue,del:r,delLDelim:r,delRDelim:r,emStrongLDelim:be,emStrongRDelimAst:we,emStrongRDelimUnd:Ee,escape:le,link:A,nolink:Fe,punctuation:me,reflink:Pe,reflinkSearch:Re,tag:je,text:fe,url:r},He={...Ve,emStrongLDelim:Se,emStrongRDelimAst:E,emStrongRDelimUnd:D,link:a(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Ne).getRegex(),reflink:a(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Ne).getRegex()},Ue={...Ve,emStrongRDelimAst:Te,emStrongLDelim:xe,delLDelim:De,delRDelim:O,url:a(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,Be).replace(`protocol`,ze).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:a(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,ze).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},We={...Ue,br:a(de).replace(`{2,}`,`*`).getRegex(),text:a(Ue.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Ge={normal:S,gfm:se,pedantic:ce},Ke={normal:Ve,gfm:Ue,breaks:We,pedantic:He},qe={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},j=e=>qe[e];function M(e,t){if(t){if(s.escapeTest.test(e))return e.replace(s.escapeReplace,j)}else if(s.escapeTestNoEncode.test(e))return e.replace(s.escapeReplaceNoEncode,j);return e}function Je(e){return s.numericCharacterReference.test(e)?e.replace(s.numericCharacterReferenceOrAmpersand,(e,t,n)=>{if(t===void 0&&n===void 0)return`&`;let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:r===38?`&`:String.fromCodePoint(r)}):e}function Ye(e){try{e=encodeURI(e).replace(s.percentDecode,`%`)}catch{return null}return e}function Xe(e,t){let n=e.replace(s.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(s.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(s.slashPipe,`|`);return n}function N(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Ze(e){let t=e.split(`
|
|
3
3
|
`),n=t.length-1;for(;n>=0&&s.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
4
|
-
`)}function
|
|
4
|
+
`)}function Qe(e){return e.trim().toLowerCase().toUpperCase().toLowerCase()}function $e(e,t){if(e.indexOf(t[0])===-1&&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 et(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function P(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`,l=r.state.inLink,u=r.state.linkEmitted,d=r.state.inRawBlock;r.state.inLink=!0,r.state.linkEmitted=!1;let f=r.inlineTokens(s),p=r.state.linkEmitted;if(r.state.linkEmitted=u,r.state.inLink=l,!c){if(p){r.state.inRawBlock=d;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:f}}function tt(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
5
5
|
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return e.slice(Math.min(r.length,i.length))}).join(`
|
|
6
|
-
`)}function
|
|
6
|
+
`)}function nt(e,t,n,r){if(!t.includes(`<`))return!1;for(let i=0;i<t.length;i++){if(t[i]===`\\`){i++;continue}if(t[i]==="`"){let e=r.inline.code.exec(t.slice(i));if(e){i+=e[0].length-1;continue}}if(t[i]!==`<`)continue;let a=e.slice(n+i),o=r.inline.tag.exec(a)||r.inline.autolink.exec(a);if(o){if(o[0].length>t.length-i)return!0;i+=o[0].length-1}}return!1}var F=class{options;rules;lexer;constructor(e){this.options=e||t}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 e=this.options.pedantic?t[0]:Ze(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=tt(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=N(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:N(t[0],`
|
|
7
7
|
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:N(t[0],`
|
|
8
8
|
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=N(t[0],`
|
|
9
9
|
`).split(`
|
|
10
10
|
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
11
|
-
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
11
|
+
`),c=s.replace(this.rules.other.blockquoteMarkerWhitespace,(e,t,n)=>t+et(n,t.length)).replace(this.rules.other.blockquoteSetextReplace,`
|
|
12
12
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
13
13
|
${s}`:s,r=r?`${r}
|
|
14
|
-
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=e.join(`
|
|
14
|
+
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`||u?.type===`heading`||u?.type===`hr`||u?.type===`html`)break;if(u?.type===`blockquote`){let t=u,a=e.join(`
|
|
15
15
|
`),o=t.raw+`
|
|
16
16
|
`+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s;let c=o.substring(s.raw.length).replace(/^\n/,``),l=c?c.split(`
|
|
17
17
|
`).length:0,d=l?e.slice(0,-l):e;d.length>0&&(n=`${n}
|
|
18
18
|
${d.join(`
|
|
19
19
|
`)}`),r=r.substring(0,r.length-t.text.length)+s.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
|
|
20
20
|
`+e.join(`
|
|
21
|
-
`),o=this.list(a);i[i.length-1]=o
|
|
22
|
-
`)
|
|
23
|
-
|
|
24
|
-
`,
|
|
25
|
-
|
|
26
|
-
`,1)[0],
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
`)
|
|
21
|
+
`),o=this.list(a);i[i.length-1]=o;let s=o.raw.length>t.raw.length?a.slice(t.raw.length+1,o.raw.length).split(`
|
|
22
|
+
`).length:0;if(s>0){let t=e.slice(0,s).join(`
|
|
23
|
+
`);n=`${n}
|
|
24
|
+
${t}`,r=`${r}
|
|
25
|
+
${t}`}e=e.slice(s)}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=e,r=()=>n.length-e.length,i=t[1].trim(),a=i.length>1,o={type:`list`,raw:``,ordered:a,start:a?+i.slice(0,-1):``,loose:!1,items:[]};i=a?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=a?i:`[*+-]`);let s=this.rules.other.listItemRegex(i),c=!1;for(;e;){let i=!1,a=``;if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;let l=r();e=e.substring(t[0].length);let u=t[2].split(`
|
|
26
|
+
`,1)[0],d=t[1].length,f=this.options.pedantic?et(u,d):u.replace(this.rules.other.leadingSpaceTab,e=>et(e,d)),p=e.split(`
|
|
27
|
+
`,1)[0],m=!f.trim(),h=0;if(this.options.pedantic?(h=2,a=f.trimStart()):m?h=d+1:(h=f.search(this.rules.other.nonSpaceChar),h=h>4?1:h,a=f.slice(h),h+=d),m&&this.rules.other.blankLine.test(p)&&(e=e.substring(p.length+1),i=!0),!i){let t=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),r=this.rules.other.fencesBeginRegex(h),i=this.options.pedantic?this.rules.other.pedanticHeadingBeginRegex(h):this.rules.other.headingBeginRegex(h),o=this.rules.other.htmlBeginRegex(h),s=this.rules.other.blockquoteBeginRegex(h);for(;e;){let c=e.split(`
|
|
28
|
+
`,1)[0],l;if(p=c,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting,` `),l=p):l=p.replace(this.rules.other.leadingSpaceTab,e=>et(e)),r.test(p)||i.test(p)||o.test(p)||s.test(p)||t.test(p)||n.test(p))break;if(l.search(this.rules.other.nonSpaceChar)>=h||!p.trim())a+=`
|
|
29
|
+
`+l.slice(h);else{if(m||f.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||r.test(f)||i.test(f)||n.test(f))break;let e=!this.options.pedantic&&/^ {0,3}(?:=+|-+) *$/.test(p)&&this.rules.block.lheading.test(`${f}
|
|
30
|
+
${p}`)?` ${l.replace(/^ {0,3}/,``)}`:p;a+=`
|
|
31
|
+
`+e}m=!p.trim(),e=e.substring(c.length+1),f=l.slice(h)}}let g=n.slice(l,r());o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(c=!0)),o.items.push({type:`list_item`,raw:g,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]})}let l=o.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;o.raw=n.slice(0,r()).trimEnd();for(let e of o.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!o.loose){let t=e.tokens.filter(e=>e.type===`space`);o.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of o.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,o.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(o.loose)for(let e of o.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Ze(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){if(!this.rules.other.startAngleBracket.test(t[2])&&$e(t[2],`()`)!==-1)return;let e=Qe(t[1]).replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:N(t[0],`
|
|
32
|
+
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Xe(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
31
33
|
`):[],a={type:`table`,raw:N(t[0],`
|
|
32
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(
|
|
34
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Xe(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:N(t[0],`
|
|
33
35
|
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
34
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}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){if(this.lexer.state.linkParenPossible===!1)return;let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic
|
|
35
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(s.tabCharGlobal,` `).replace(s.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
36
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}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){if(this.lexer.state.linkParenPossible===!1)return;let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&nt(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=N(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=$e(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let i=t[2],a=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(i);e&&(i=e[1],a=e[3])}else a=t[3]?t[3].slice(1,-1):``;return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(i=this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i.slice(1):i.slice(1,-1)),P(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,`$1`),title:a&&a.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[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&nt(e,n[1],r,this.rules))return;let i=t[Qe((n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `))];if(!i){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return P(n,i,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])return;let i=r[0][0],a=n===i,o=t.length-e.length,s=o;for(;!this.options.pedantic&&s>0&&t[s-1]===i;)s--;let c=[...t.slice(Math.max(0,s-2),s)].at(-1)??``,l=c===`*`||c===`_`||!!this.rules.inline.punctuation.exec(c);s<o&&(n=c);let u=s<o?l:!!this.rules.inline.punctuation.exec(n);if(r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))return;let d=r[1]||r[3]||``;if(!d||!n||u){let n=[...r[0]].length-1,u,f,p=n,m=0,h=o-s+n,g=!this.options.pedantic&&!!c.trim()&&(!!d||i===`*`&&!l),_=i===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(_.lastIndex=0,t=t.slice(-1*e.length+n);(r=_.exec(t))!==null;){if(u=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!u)continue;if(f=[...u].length,r[3]||r[4]){p+=f;continue}if(r[5]||r[6]||g){if(a&&(r[5]||r[6]))break;if(h%3&&!((h+f)%3)){m+=f;continue}}if(p-=f,p>0)continue;f=Math.min(f,f+p+m);let t=[...r[0]][0].length,i=e.slice(0,n+r.index+t+f);if(Math.min(n,f)%2){let e=i.slice(1,-1);return{type:`em`,raw:i,text:e,tokens:this.lexer.inlineTokens(e)}}let o=i.slice(2,-2);return{type:`strong`,raw:i,text:o,tokens:this.lexer.inlineTokens(o)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}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 n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:e?t[0]:Je(t[0]),escaped:e}}}},I=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||t,this.options.tokenizer=this.options.tokenizer||new F,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let n={other:s,block:Ge.normal,inline:Ke.normal};this.options.pedantic?(n.block=Ge.pedantic,n.inline=Ke.pedantic):this.options.gfm&&(n.block=Ge.gfm,n.inline=this.options.breaks?Ke.breaks:Ke.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ge,inline:Ke}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(s.carriageReturn,`
|
|
37
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.state.inRawBlock=!1,this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(s.tabCharGlobal,` `).replace(s.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
36
38
|
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
37
39
|
`)?``:`
|
|
38
40
|
`)+i.raw,n.text+=`
|
|
39
41
|
`+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if((i=this.tokenizer.fences(e))||(i=this.tokenizer.heading(e))||(i=this.tokenizer.hr(e))||(i=this.tokenizer.blockquote(e))||(i=this.tokenizer.list(e))||(i=this.tokenizer.html(e))){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
40
42
|
`)?``:`
|
|
41
43
|
`)+i.raw,n.text+=`
|
|
42
|
-
`+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if((i=this.tokenizer.table(e))||(i=this.tokenizer.lheading(e))){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
|
|
44
|
+
`+i.raw,this.inlineQueue.at(-1).src=n.text):(this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title}),t.push(i));continue}if((i=this.tokenizer.table(e))||(i=this.tokenizer.lheading(e))){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
|
|
43
45
|
`)?``:`
|
|
44
46
|
`)+i.raw,r.text+=`
|
|
45
47
|
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length)}else if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
46
48
|
`)?``:`
|
|
47
49
|
`)+i.raw,n.text+=`
|
|
48
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,
|
|
50
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,Qe(e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=this.state.linkParenPossible;this.state.linkParenPossible=n&&e.includes(`)`);try{return this.#e(e,t)}finally{this.state.linkParenPossible=n}}#e(e,t){let n=e.includes(`*`)||e.includes(`_`)||e.includes(`~`)||this.options.hooks?.emStrongMask||this.tokenizer.emStrong!==F.prototype.emStrong||this.tokenizer.del!==F.prototype.del?this.#t(e):e,r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if((o=this.tokenizer.escape(e))||(o=this.tokenizer.tag(e))||(o=this.tokenizer.link(e))){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if((o=this.tokenizer.emStrong(e,n,i))||(o=this.tokenizer.codespan(e))||(o=this.tokenizer.br(e))||(o=this.tokenizer.del(e,n,i))||(o=this.tokenizer.autolink(e))||!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}#t(e){let t=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,n=t=>{let r=t.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,Qe(t.slice(r+1,-1))))return t;if(r>1&&t.charAt(0)!==`!`){let i=t.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,n)+`][`+`a`.repeat(t.length-r-2)+`]`}return`[`+`a`.repeat(t.length-2)+`]`};t=t.replace(e,n)}return t=t.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(e,t,n)=>n?`+`.repeat(e.length):t?t+e.slice(t.length,-t.length).replace(/`/g,`+`)+t:e),t=t.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),t=this.options.hooks?.emStrongMask?.call({lexer:this},t)??t,t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},rt=class{options;parser;constructor(e){this.options=e||t}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(s.notSpaceStart)?.[0],i=e?e.replace(s.endingNewline,``)+`
|
|
49
51
|
`:``;return r?`<pre><code class="language-`+M(r)+`">`+(n?i:M(i,!0))+`</code></pre>
|
|
50
52
|
`:`<pre><code>`+(n?i:M(i,!0))+`</code></pre>
|
|
51
53
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
@@ -63,34 +65,34 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
63
65
|
`}tablerow({text:e}){return`<tr>
|
|
64
66
|
${e}</tr>
|
|
65
67
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
66
|
-
`}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>${M(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?M(n,!0):this.parser.parseInline(r),o=
|
|
67
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+M(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},
|
|
68
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ut(e,t){return st(e)||ct(e,t)||dt(e,t)||lt()}function dt(e,t){if(e){if(typeof e==`string`)return ot(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ot(e,t):void 0}}function ft(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof at;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}ft.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},ft.prototype.next=function(e){return this._invoke(`next`,e)},ft.prototype.throw=function(e){return this._invoke(`throw`,e)},ft.prototype.return=function(e){return this._invoke(`return`,e)};var pt=Object.entries,H=Object.setPrototypeOf,mt=Object.isFrozen,ht=Object.getPrototypeOf,gt=Object.getOwnPropertyDescriptor,U=Object.freeze,W=Object.seal,_t=Object.create,vt=typeof Reflect<`u`&&Reflect,yt=vt.apply,bt=vt.construct;U||=function(e){return e},W||=function(e){return e},yt||=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)},bt||=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)};var xt=q(Array.prototype.forEach);Array.prototype.indexOf;var St=q(Array.prototype.lastIndexOf),Ct=q(Array.prototype.pop),wt=q(Array.prototype.push);Array.prototype.slice;var Tt=q(Array.prototype.splice),Et=Array.isArray,Dt=q(String.prototype.toLowerCase),Ot=q(String.prototype.toString),kt=q(String.prototype.match),At=q(String.prototype.replace),jt=q(String.prototype.indexOf),Mt=q(String.prototype.trim),Nt=q(Number.prototype.toString),Pt=q(Boolean.prototype.toString),Ft=typeof BigInt>`u`?null:q(BigInt.prototype.toString),It=typeof Symbol>`u`?null:q(Symbol.prototype.toString),G=q(Object.prototype.hasOwnProperty),Lt=q(Object.prototype.toString),K=q(RegExp.prototype.test),Rt=zt(TypeError);function q(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return yt(e,t,r)}}function zt(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return bt(e,n)}}function J(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Dt;if(H&&H(e,null),!Et(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(mt(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Bt(e){for(let t=0;t<e.length;t++)G(e,t)||(e[t]=null);return e}function Y(e){let t=_t(null);for(let r of pt(e)){var n=ut(r,2);let i=n[0],a=n[1];G(e,i)&&(t[i]=Et(a)?Bt(a):a&&typeof a==`object`&&a.constructor===Object?Y(a):a)}return t}function Vt(e){switch(typeof e){case`string`:return e;case`number`:return Nt(e);case`boolean`:return Pt(e);case`bigint`:return Ft?Ft(e):`0`;case`symbol`:return It?It(e):`Symbol()`;case`undefined`:return Lt(e);case`function`:case`object`:{if(e===null)return Lt(e);let t=e,n=X(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Lt(e)}return Lt(e)}default:return Lt(e)}}function X(e,t){for(;e!==null;){let n=gt(e,t);if(n){if(n.get)return q(n.get);if(typeof n.value==`function`)return q(n.value)}e=ht(e)}function n(){return null}return n}function Ht(e){try{return K(e,``),!0}catch{return!1}}var Ut=U(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Wt=U(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Gt=U([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Kt=U([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),qt=U(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Jt=U([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Yt=U([`#text`]),Xt=U(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Zt=U(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Qt=U(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),$t=U([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),en=W(/{{[\w\W]*|^[\w\W]*}}/g),tn=W(/<%[\w\W]*|^[\w\W]*%>/g),nn=W(/\${[\w\W]*/g),rn=W(/^data-[\-\w.\u00B7-\uFFFF]+$/),an=W(/^aria-[\-\w]+$/),on=W(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),sn=W(/^(?:\w+script|data):/i),cn=W(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ln=W(/^html$/i),un=W(/^[a-z][.\w]*(-[.\w]+)+$/i),dn=W(/<[/\w!]/g),fn=W(/<[/\w]/g),pn=W(/<\/no(script|embed|frames)/i),mn=W(/\/>/i),Z={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Q=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],hn=U(J({},Q)),gn=function(){let e={};return xt(Q,t=>{e[t]=W(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),U(e)}(),_n=function(){return typeof window>`u`?null:window},vn=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},yn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},bn=function(e,t,n,r){return G(e,t)&&Et(e[t])?J(r.base?Y(r.base):{},e[t],r.transform):n},xn=function(e,t,n){let r=G(e,t)?e[t]:void 0;return r&&typeof r==`object`?Y(r):n()};function Sn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_n(),t=e=>Sn(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==Z.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=X(d,`cloneNode`),p=X(d,`remove`),m=X(d,`removeAttributeNode`),ee=X(d,`nextSibling`),h=X(d,`childNodes`),g=X(d,`parentNode`),_=X(d,`shadowRoot`),te=X(d,`attributes`),v=o&&o.prototype?X(o.prototype,`nodeType`):null,ne=o&&o.prototype?X(o.prototype,`nodeName`):null,y=o&&o.prototype?X(o.prototype,`ownerDocument`):null,re=function(e){return v?v(e):e.nodeType},ie=function(e){return ne?ne(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let b,ae=``,oe,se=!1,ce=0,le=function(){if(ce>0)throw Rt(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},ue=function(e){le(),ce++;try{return b.createHTML(e)}finally{ce--}},de=function(e){le(),ce++;try{return b.createScriptURL(e)}finally{ce--}},fe=function(){return se||=(oe=vn(u,i),!0),oe},pe=n,me=pe.implementation,x=pe.createNodeIterator,he=pe.createDocumentFragment,ge=pe.getElementsByTagName,_e=r.importNode,S=yn();t.isSupported=typeof pt==`function`&&typeof g==`function`&&me&&me.createHTMLDocument!==void 0;let ve=en,ye=tn,be=nn,xe=rn,Se=an,Ce=sn,we=cn,Te=un,Ee=on,C=null,De=J({},[...Ut,...Wt,...Gt,...qt,...Yt]),w=null,Oe=J({},[...Xt,...Zt,...Qt,...$t]),T=Object.seal(_t(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ke=null,Ae=null,E=Object.seal(_t(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),je=!0,Me=!0,Ne=!1,Pe=!0,D=!1,Fe=!0,O=!1,Ie=!1,Le=null,Re=null,ze=!1,k=!1,Be=!1,Ve=!1,He=!0,Ue=!1,We=`user-content-`,Ge=!0,A=!1,Ke={},j=null,M=J({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),qe=null,Je=J({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ye=null,N=J({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Xe=`http://www.w3.org/1998/Math/MathML`,P=`http://www.w3.org/2000/svg`,F=`http://www.w3.org/1999/xhtml`,I=F,Ze=!1,Qe=null,$e=J({},[Xe,P,F],Ot),et=U([`mi`,`mo`,`mn`,`ms`,`mtext`]),L=J({},et),tt=U([`annotation-xml`]),nt=J({},tt),R=J({},[`title`,`style`,`font`,`a`,`script`]),z=null,rt=[`application/xhtml+xml`,`text/html`],B=null,V=null,it=n.createElement(`form`),at=function(e){return e instanceof RegExp||e instanceof Function},ot=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(V&&V===e)return;(!e||typeof e!=`object`)&&(e={}),e=Y(e),z=rt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,B=z===`application/xhtml+xml`?Ot:Dt,C=bn(e,`ALLOWED_TAGS`,De,{transform:B}),w=bn(e,`ALLOWED_ATTR`,Oe,{transform:B}),Qe=bn(e,`ALLOWED_NAMESPACES`,$e,{transform:Ot}),Ye=bn(e,`ADD_URI_SAFE_ATTR`,N,{transform:B,base:N}),qe=bn(e,`ADD_DATA_URI_TAGS`,Je,{transform:B,base:Je}),j=bn(e,`FORBID_CONTENTS`,M,{transform:B}),ke=bn(e,`FORBID_TAGS`,Y({}),{transform:B}),Ae=bn(e,`FORBID_ATTR`,Y({}),{transform:B}),Ke=G(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Y(e.USE_PROFILES):e.USE_PROFILES:!1,je=e.ALLOW_ARIA_ATTR!==!1,Me=e.ALLOW_DATA_ATTR!==!1,Ne=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Pe=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,D=e.SAFE_FOR_TEMPLATES||!1,Fe=e.SAFE_FOR_XML!==!1,O=e.WHOLE_DOCUMENT||!1,k=e.RETURN_DOM||!1,Be=e.RETURN_DOM_FRAGMENT||!1,Ve=e.RETURN_TRUSTED_TYPE||!1,ze=e.FORCE_BODY||!1,He=e.SANITIZE_DOM!==!1,Ue=e.SANITIZE_NAMED_PROPS||!1,Ge=e.KEEP_CONTENT!==!1,A=e.IN_PLACE||!1,Ee=Ht(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:on,I=typeof e.NAMESPACE==`string`?e.NAMESPACE:F,L=xn(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>J({},et)),nt=xn(e,`HTML_INTEGRATION_POINTS`,()=>J({},tt));let t=xn(e,`CUSTOM_ELEMENT_HANDLING`,()=>_t(null));if(T=_t(null),G(t,`tagNameCheck`)&&at(t.tagNameCheck)&&(T.tagNameCheck=t.tagNameCheck),G(t,`attributeNameCheck`)&&at(t.attributeNameCheck)&&(T.attributeNameCheck=t.attributeNameCheck),G(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(T.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),W(T),D&&(Me=!1),Be&&(k=!0),Ke&&(C=J({},Yt),w=_t(null),Ke.html===!0&&(J(C,Ut),J(w,Xt)),Ke.svg===!0&&(J(C,Wt),J(w,Zt),J(w,$t)),Ke.svgFilters===!0&&(J(C,Gt),J(w,Zt),J(w,$t)),Ke.mathMl===!0&&(J(C,qt),J(w,Qt),J(w,$t))),E.tagCheck=null,E.attributeCheck=null,G(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?E.tagCheck=e.ADD_TAGS:Et(e.ADD_TAGS)&&(C===De&&(C=Y(C)),J(C,e.ADD_TAGS,B))),G(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?E.attributeCheck=e.ADD_ATTR:Et(e.ADD_ATTR)&&(w===Oe&&(w=Y(w)),J(w,e.ADD_ATTR,B))),G(e,`ADD_FORBID_CONTENTS`)&&Et(e.ADD_FORBID_CONTENTS)&&(j===M&&(j=Y(j)),J(j,e.ADD_FORBID_CONTENTS,B)),Ge&&(C[`#text`]=!0),O&&J(C,[`html`,`head`,`body`]),C.table&&(J(C,[`tbody`]),delete ke.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Rt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Rt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=b;b=e.TRUSTED_TYPES_POLICY;try{ae=ue(``)}catch(e){throw b=t,e}}else e.TRUSTED_TYPES_POLICY===null?(b=void 0,ae=``):(b===void 0&&(b=fe()),b&&typeof ae==`string`&&(ae=ue(``)));U&&U(e),V=e},st=J({},[...Wt,...Gt,...Kt]),ct=J({},[...qt,...Jt]),lt=function(e,t,n){return t.namespaceURI===F?e===`svg`:t.namespaceURI===Xe?e===`svg`&&(n===`annotation-xml`||L[n]):!!st[e]},ut=function(e,t,n){return t.namespaceURI===F?e===`math`:t.namespaceURI===P?e===`math`&&nt[n]:!!ct[e]},dt=function(e,t,n){return t.namespaceURI===P&&!nt[n]||t.namespaceURI===Xe&&!L[n]?!1:!ct[e]&&(R[e]||!st[e])},ft=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:I,tagName:`template`});let n=Dt(e.tagName),r=Dt(t.tagName);return Qe[e.namespaceURI]?e.namespaceURI===P?lt(n,t,r):e.namespaceURI===Xe?ut(n,t,r):e.namespaceURI===F?dt(n,t,r):!!(z===`application/xhtml+xml`&&Qe[e.namespaceURI]):!1},H=function(e){wt(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw Rt(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},mt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},ht=function(e){yt(e);let t=h(e);if(t){let e=[];xt(t,t=>{wt(e,t)}),xt(e,e=>{try{p(e)}catch{}})}let n=te(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&mt(e,r,i)}},gt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}wt(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(k||Be)try{H(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},vt=function(e){let t=te(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||w[B(i)]||mt(e,r,i)}},yt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();re(e)===Z.element&&vt(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},bt=function(e,t){return Fe?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Nt=function(e){if(!Fe)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=re(e);if(n===Z.processingInstruction||n===Z.comment&&K(fn,e.data)){try{p(e)}catch{}continue}if(n===Z.element){let t=e,n=B(ie(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&bt(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Pt=function(e){let t=null,r=null;if(ze)e=`<remove></remove>`+e;else{let t=kt(e,/^[\r\n\t ]+/);r=t&&t[0]}z===`application/xhtml+xml`&&I===F&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=b?ue(e):e;if(I===F)try{t=new l().parseFromString(i,z)}catch{}if(!t||!t.documentElement){t=me.createDocument(I,`template`,null);try{t.documentElement.innerHTML=Ze?ae:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),I===F?ge.call(t,O?`html`:`body`)[0]:O?t.documentElement:a},Ft=function(e){let t=y?y(e):e.ownerDocument;return x.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},It=function(e){return e=At(e,ve,` `),e=At(e,ye,` `),e=At(e,be,` `),e},Lt=function(e){e.normalize();let t=y?y(e):e.ownerDocument,n=x.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=It(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&xt(i,e=>{zt(e.content)&&Lt(e.content)})},q=function(e){let t=ne?ne(e):null;return typeof t!=`string`||B(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==te(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==v(e)||e.childNodes!==h(e)},zt=function(e){if(!v||typeof e!=`object`||!e)return!1;try{return v(e)===Z.documentFragment}catch{return!1}},Bt=function(e){if(!v||typeof e!=`object`||!e)return!1;try{return typeof v(e)==`number`}catch{return!1}};function Q(e,n,r){e.length!==0&&xt(e,e=>{e.call(t,n,r,V)})}let Cn=function(e,t){return!!(Fe&&e.hasChildNodes()&&!Bt(e.firstElementChild)&&K(dn,e.textContent)&&K(dn,e.innerHTML)||Fe&&e.namespaceURI===F&&hn[t]&&(Bt(e.firstElementChild)||typeof e.textContent==`string`&&K(gn[t],e.textContent))||e.nodeType===Z.processingInstruction||Fe&&e.nodeType===Z.comment&&K(fn,e.data))},$=function(e,t){if(e instanceof RegExp)return K(e,t);if(e instanceof Function){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return!!e(t,...r)}return!1},wn=function(e,t,n){if(!ke[t]&&An(t)&&$(T.tagNameCheck,t))return!1;if(Ge&&!j[t]){let t=g(e),r=h(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,ee(e))}}}return H(e),!0},Tn=function(e,t,n,r){return e.length===0?t:t===n||t===r?Y(t):t},En=function(e,t){return e===t||g(e)!==null?!1:(A&&yt(e),!0)},Dn=function(e,n){if(Q(S.beforeSanitizeElements,e,null),En(e,n))return!0;if(q(e))return H(e),!0;let r=B(ie(e));if(C=Tn(S.uponSanitizeElement,C,De,Le),Q(S.uponSanitizeElement,e,{tagName:r,allowedTags:C}),En(e,n))return!0;if(Cn(e,r))return H(e),!0;if(ke[r]||!(E.tagCheck instanceof Function&&E.tagCheck(r))&&!C[r]){let t=wn(e,r,n);return t===!1&&(Q(S.afterSanitizeElements,e,null),En(e,n))?!0:t}if(re(e)===Z.element&&!ft(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&K(pn,e.innerHTML))return H(e),!0;if(D&&e.nodeType===Z.text){let n=It(e.textContent);e.textContent!==n&&(wt(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Q(S.afterSanitizeElements,e,null),En(e,n)},On=function(e,t,r){if(Ae[t]||bt(t,e)||He&&(t===`id`||t===`name`)&&(r in n||r in it))return!1;let i=w[t]||E.attributeCheck instanceof Function&&E.attributeCheck(t,e);return Me&&K(xe,t)||je&&K(Se,t)?!0:i?Ye[t]||K(Ee,At(r,we,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&jt(r,`data:`)===0&&qe[e]||Ne&&!K(Ce,At(r,we,``))?!0:!r:An(e)&&$(T.tagNameCheck,e)&&$(T.attributeNameCheck,t,e)||t===`is`&&T.allowCustomizedBuiltInElements&&$(T.tagNameCheck,r)},kn=J({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),An=function(e){return!kn[Dt(e)]&&K(Te,e)},jn=function(e,t,n,r){if(b&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ue(r);case`TrustedScriptURL`:return de(r)}return r},Mn=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!q(e)||(H(e),!1)}catch{return gt(t,e),!1}},Nn=function(e,n){if(Q(S.beforeSanitizeAttributes,e,null),En(e,n))return;let r=e.attributes;if(!r||q(e))return;w=Tn(S.uponSanitizeAttribute,w,Oe,Re);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:w,forceKeepAttr:void 0},a=r.length,o=B(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=B(s),d=l,f=s===`value`?d:Mt(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Q(S.uponSanitizeAttribute,e,i),f=i.attrValue,Ue&&(u===`id`||u===`name`)&&jt(f,We)!==0&&(gt(s,e,n),f=We+f,p=!0),Fe&&K(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)||u===`attributename`&&kt(f,`href`)?gt(s,e,n):i.forceKeepAttr||(i.keepAttr?!Pe&&K(mn,f)?gt(s,e,n):(D&&(f=It(f)),On(o,u,f)?(f=jn(o,u,c,f),f!==d&&Mn(e,s,c,f)&&p&&Ct(t.removed)):gt(s,e,n)):gt(s,e,n))}Q(S.afterSanitizeAttributes,e,null),En(e,n)},Pn=function(e){let t=null,n=Ft(e);for(Q(S.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Q(S.uponSanitizeShadowNode,t,null),Dn(t,e),Nn(t,e),zt(t.content)&&Pn(t.content),re(t)===Z.element){let e=_(t);zt(e)&&(Fn(e),Pn(e))}Q(S.afterSanitizeShadowDOM,e,null)},Fn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Pn(e.shadow);continue}let n=e.node,r=re(n)===Z.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=ne?ne(n):null;if(typeof e==`string`&&B(e)===`template`){let e=n.content;zt(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);zt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Ze=!e,Ze&&(e=`<!-->`),typeof e!=`string`&&!Bt(e)&&(e=Vt(e),typeof e!=`string`))throw Rt(`dirty is not a string, aborting`);if(!t.isSupported)return e;Ie?(C=Le,w=Re):ot(n),(S.uponSanitizeElement.length>0||S.uponSanitizeAttribute.length>0)&&(C=Y(C)),S.uponSanitizeAttribute.length>0&&(w=Y(w)),t.removed=[];let c=A&&typeof e!=`string`&&Bt(e);if(c){Nt(e);let t=ie(e);if(typeof t==`string`){let n=B(t);if(!C[n]||ke[n])throw ht(e),Rt(`root node is forbidden and cannot be sanitized in-place`)}if(q(e))throw ht(e),Rt(`root node is clobbered and cannot be sanitized in-place`);try{Fn(e)}catch(t){throw ht(e),t}}else if(Bt(e))i=Pt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Z.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Fn(i);else{if(!k&&!D&&!O&&e.indexOf(`<`)===-1)return b&&Ve?ue(e):e;if(i=Pt(e),!i)return k?null:Ve?ae:``}i&&ze&&H(i.firstChild);let l=c?e:i;try{let e=Ft(l);for(;o=e.nextNode();)Dn(o,l),Nn(o,l),zt(o.content)&&Pn(o.content)}catch(n){throw c&&(ht(e),xt(t.removed,e=>{e.element&&yt(e.element)})),n}if(c){let n=!1;if(xt(t.removed,t=>{t.element&&(t.element===e&&(n=!0),yt(t.element))}),n)throw Rt(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return D&&Lt(e),e}if(k){if(D&&Lt(i),Be)for(s=he.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(w.shadowroot||w.shadowrootmode)&&(s=_e.call(r,s,!0)),s}let u=O?i.outerHTML:i.innerHTML;return O&&C[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&K(ln,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
69
|
-
`+
|
|
68
|
+
`}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>${M(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?M(n,!0):this.parser.parseInline(r),o=Ye(e);if(o===null)return a;e=M(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+M(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Ye(e);if(i===null)return M(n);e=i;let a=`<img src="${M(e)}" alt="${M(n)}"`;return t&&(a+=` title="${M(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:M(e.text)}},it=class{parser;strong({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}em({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}codespan({text:e}){return e}del({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}html({text:e}){return e}text({text:e}){return e}link({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}image({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}br(){return``}checkbox({raw:e}){return e}},L=class e{options;renderer;textRenderer;constructor(e){this.options=e||t,this.options.renderer=this.options.renderer||new rt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new it,this.textRenderer.parser=this}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},at=class{options;block;constructor(e){this.options=e||t}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?I.lex:I.lexInline}provideParser(e=this.block){return e?L.parse:L.parseInline}};function ot(e,t){if(Array.isArray(t))for(let n=0;n<t.length;n++)e.push(t[n]);else e.push(t)}var st=class{defaults=e();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=L;Renderer=rt;TextRenderer=it;Lexer=I;Tokenizer=F;Hooks=at;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(ot(n,t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)ot(n,this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)ot(n,this.walkTokens(e.tokens,t));break}case`list`:{let e=r;ot(n,this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);ot(n,this.walkTokens(i,t))}):e.tokens&&ot(n,this.walkTokens(e.tokens,t))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new rt(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new F(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new at;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=at.passThroughHooks.has(n)?e=>{if(t.options.async&&at.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(t.options.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&ot(n,t.call(this,e)),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return I.lex(e,t??this.defaults)}parser(e,t){return L.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(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 a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?I.lex:I.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?L.parse:L.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?I.lex:I.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?L.parse:L.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
69
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+M(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},ct=new st;function R(e,t){return ct.parse(e,t)}R.options=R.setOptions=function(e){return ct.setOptions(e),R.defaults=ct.defaults,n(R.defaults),R},R.getDefaults=e,R.defaults=t;function lt(...e){return ct.use(...e),R.defaults=ct.defaults,n(R.defaults),R}R.use=lt,R.walkTokens=function(e,t){return ct.walkTokens(e,t)},R.parseInline=ct.parseInline,R.Parser=L,R.parser=L.parse,R.Renderer=rt,R.TextRenderer=it,R.Lexer=I,R.lexer=I.lex,R.Tokenizer=F,R.Hooks=at,R.parse=R,R.options,R.setOptions,R.walkTokens,R.parseInline,L.parse,I.lex;function ut(e,t){this.v=e,this.k=t}function dt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ft(e){if(Array.isArray(e))return e}function pt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function mt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
70
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ht(e,t){return ft(e)||pt(e,t)||gt(e,t)||mt()}function gt(e,t){if(e){if(typeof e==`string`)return dt(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?dt(e,t):void 0}}function _t(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof ut;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}_t.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},_t.prototype.next=function(e){return this._invoke(`next`,e)},_t.prototype.throw=function(e){return this._invoke(`throw`,e)},_t.prototype.return=function(e){return this._invoke(`return`,e)};var vt=Object.entries,yt=Object.setPrototypeOf,bt=Object.isFrozen,xt=Object.getPrototypeOf,St=Object.getOwnPropertyDescriptor,z=Object.freeze,B=Object.seal,Ct=Object.create,wt=typeof Reflect<`u`&&Reflect,Tt=wt.apply,Et=wt.construct;z||=function(e){return e},B||=function(e){return e},Tt||=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)},Et||=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)};var V=G(Array.prototype.forEach);Array.prototype.indexOf;var Dt=G(Array.prototype.lastIndexOf),Ot=G(Array.prototype.pop),kt=G(Array.prototype.push),At=G(Array.prototype.slice),jt=G(Array.prototype.splice),Mt=Array.isArray,Nt=qt(Set),Pt=G(Set.prototype.add),Ft=G(Set.prototype.has),It=G(String.prototype.toLowerCase),Lt=G(String.prototype.toString),Rt=G(String.prototype.match),zt=G(String.prototype.replace),Bt=G(String.prototype.indexOf),Vt=G(String.prototype.trim),Ht=G(Number.prototype.toString),Ut=G(Boolean.prototype.toString),Wt=typeof BigInt>`u`?null:G(BigInt.prototype.toString),Gt=typeof Symbol>`u`?null:G(Symbol.prototype.toString),H=G(Object.prototype.hasOwnProperty),Kt=G(Object.prototype.toString),U=G(RegExp.prototype.test),W=qt(TypeError);function G(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Tt(e,t,r)}}function qt(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return Et(e,n)}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:It;if(yt&&yt(e,null),!Mt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(bt(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Jt(e){for(let t=0;t<e.length;t++)H(e,t)||(e[t]=null);return e}function q(e){let t=Ct(null);for(let r of vt(e)){var n=ht(r,2);let i=n[0],a=n[1];H(e,i)&&(t[i]=Mt(a)?Jt(a):a&&typeof a==`object`&&a.constructor===Object?q(a):a)}return t}function Yt(e){switch(typeof e){case`string`:return e;case`number`:return Ht(e);case`boolean`:return Ut(e);case`bigint`:return Wt?Wt(e):`0`;case`symbol`:return Gt?Gt(e):`Symbol()`;case`undefined`:return Kt(e);case`function`:case`object`:{if(e===null)return Kt(e);let t=e,n=J(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Kt(e)}return Kt(e)}default:return Kt(e)}}function J(e,t){for(;e!==null;){let n=St(e,t);if(n){if(n.get)return G(n.get);if(typeof n.value==`function`)return G(n.value)}e=xt(e)}function n(){return null}return n}function Xt(e,t){for(;e!==null;){let n=St(e,t);if(n)return n.get?G(n.get):null;e=xt(e)}return null}function Zt(e){try{return U(e,``),!0}catch{return!1}}var Qt=z(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),$t=z(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),en=z([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),tn=z([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),nn=z(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),rn=z([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),an=z([`#text`]),on=z(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),sn=z(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),cn=z(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),ln=z([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),un=B(/{{[\w\W]*|^[\w\W]*}}/g),dn=B(/<%[\w\W]*|^[\w\W]*%>/g),fn=B(/\${[\w\W]*/g),pn=B(/^data-[\-\w.\u00B7-\uFFFF]+$/),mn=B(/^aria-[\-\w]+$/),hn=B(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),gn=B(/^(?:\w+script|data):/i),_n=B(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),vn=B(/^html$/i),yn=B(/^[a-z][.\w]*(-[.\w]+)+$/i),bn=B(/<[/\w!]/g),xn=B(/<[/\w]/g),Sn=B(/<\/no(script|embed|frames)/i),Cn=B(/\/>/i),Y={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},wn=z(K({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),Tn=function(){return typeof window>`u`?null:window},En=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Dn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},On=function(e,t,n,r){return H(e,t)&&Mt(e[t])?K(r.base?q(r.base):{},e[t],r.transform):n},kn=function(e,t,n){let r=H(e,t)?e[t]:void 0;return r&&typeof r==`object`?q(r):n()};function An(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Tn(),t=e=>An(e);if(t.version=`3.4.17`,t.removed=[],!e||!e.document||e.document.nodeType!==Y.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=J(d,`cloneNode`),p=J(d,`remove`),m=J(d,`removeAttributeNode`),h=J(d,`nextSibling`),g=J(d,`childNodes`),_=J(d,`parentNode`),v=J(d,`shadowRoot`),ee=J(d,`attributes`),te=o&&o.prototype?J(o.prototype,`nodeType`):null,ne=o&&o.prototype?J(o.prototype,`nodeName`):null,y=o&&o.prototype?J(o.prototype,`ownerDocument`):null,b=function(e){return te?te(e):e.nodeType},re=function(e){return ne?ne(e):e.nodeName},ie=Xt(d,`namespaceURI`),ae=function(e){return ie?ie(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,oe,se=!1,ce=0,le=function(){if(ce>0)throw W(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},ue=function(e){le(),ce++;try{return x.createHTML(e)}finally{ce--}},de=function(e){le(),ce++;try{return x.createScriptURL(e)}finally{ce--}},fe=function(){return se||=(oe=En(u,i),!0),oe},C=n,w=C.implementation,pe=C.createNodeIterator,me=C.createDocumentFragment,he=C.getElementsByTagName,ge=r.importNode,T=Dn();t.isSupported=typeof vt==`function`&&typeof _==`function`&&w&&w.createHTMLDocument!==void 0;let _e=un,ve=dn,ye=fn,be=pn,xe=mn,Se=gn,Ce=_n,we=yn,Te=hn,E=null,Ee=K({},[...Qt,...$t,...en,...nn,...an]),D=null,De=K({},[...on,...sn,...cn,...ln]),O=Object.seal(Ct(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Oe=null,ke=null,k=Object.seal(Ct(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ae=!0,je=!0,Me=!1,Ne=!0,A=!1,Pe=!0,Fe=!1,Ie=!1,Le=null,Re=null,ze=!1,Be=!1,Ve=!1,He=!1,Ue=!0,We=!1,Ge=`user-content-`,Ke=!0,qe=!1,j=null,M={},Je=null,Ye=K({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Xe=null,N=K({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ze=null,Qe=K({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),$e=`http://www.w3.org/1998/Math/MathML`,et=`http://www.w3.org/2000/svg`,P=`http://www.w3.org/1999/xhtml`,tt=P,nt=!1,F=null,I=K({},[$e,et,P],Lt),rt=z([`mi`,`mo`,`mn`,`ms`,`mtext`]),it=K({},rt),L=z([`annotation-xml`]),at=K({},L),ot=K({},[`title`,`style`,`font`,`a`,`script`]),st=null,ct=[`application/xhtml+xml`,`text/html`],R=null,lt=null,ut=n.createElement(`form`),dt=function(e){return e instanceof RegExp||e instanceof Function},ft=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(lt&<===e)return;e&&typeof e==`object`||(e={}),e=q(e),st=ct.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,R=st===`application/xhtml+xml`?Lt:It,E=On(e,`ALLOWED_TAGS`,Ee,{transform:R}),D=On(e,`ALLOWED_ATTR`,De,{transform:R}),F=On(e,`ALLOWED_NAMESPACES`,I,{transform:Lt}),Ze=On(e,`ADD_URI_SAFE_ATTR`,Qe,{transform:R,base:Qe}),Xe=On(e,`ADD_DATA_URI_TAGS`,N,{transform:R,base:N}),Je=On(e,`FORBID_CONTENTS`,Ye,{transform:R}),Oe=On(e,`FORBID_TAGS`,q({}),{transform:R}),ke=On(e,`FORBID_ATTR`,q({}),{transform:R}),M=H(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?q(e.USE_PROFILES):e.USE_PROFILES:!1,Ae=e.ALLOW_ARIA_ATTR!==!1,je=e.ALLOW_DATA_ATTR!==!1,Me=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,A=e.SAFE_FOR_TEMPLATES||!1,Pe=e.SAFE_FOR_XML!==!1,Fe=e.WHOLE_DOCUMENT||!1,Be=e.RETURN_DOM||!1,Ve=e.RETURN_DOM_FRAGMENT||!1,He=e.RETURN_TRUSTED_TYPE||!1,ze=e.FORCE_BODY||!1,Ue=e.SANITIZE_DOM!==!1,We=e.SANITIZE_NAMED_PROPS||!1,Ke=e.KEEP_CONTENT!==!1,qe=e.IN_PLACE||!1,Te=Zt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:hn,tt=typeof e.NAMESPACE==`string`?e.NAMESPACE:P,it=kn(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>K({},rt)),at=kn(e,`HTML_INTEGRATION_POINTS`,()=>K({},L));let t=kn(e,`CUSTOM_ELEMENT_HANDLING`,()=>Ct(null));if(O=Ct(null),H(t,`tagNameCheck`)&&dt(t.tagNameCheck)&&(O.tagNameCheck=t.tagNameCheck),H(t,`attributeNameCheck`)&&dt(t.attributeNameCheck)&&(O.attributeNameCheck=t.attributeNameCheck),H(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(O.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),B(O),A&&(je=!1),Ve&&(Be=!0),M&&(E=K({},an),D=Ct(null),M.html===!0&&(K(E,Qt),K(D,on)),M.svg===!0&&(K(E,$t),K(D,sn),K(D,ln)),M.svgFilters===!0&&(K(E,en),K(D,sn),K(D,ln)),M.mathMl===!0&&(K(E,nn),K(D,cn),K(D,ln))),k.tagCheck=null,k.attributeCheck=null,H(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?k.tagCheck=e.ADD_TAGS:Mt(e.ADD_TAGS)&&(E===Ee&&(E=q(E)),K(E,e.ADD_TAGS,R))),H(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?k.attributeCheck=e.ADD_ATTR:Mt(e.ADD_ATTR)&&(D===De&&(D=q(D)),K(D,e.ADD_ATTR,R))),H(e,`ADD_FORBID_CONTENTS`)&&Mt(e.ADD_FORBID_CONTENTS)&&(Je===Ye&&(Je=q(Je)),K(Je,e.ADD_FORBID_CONTENTS,R)),Ke&&(E[`#text`]=!0),Fe&&K(E,[`html`,`head`,`body`]),E.table&&(K(E,[`tbody`]),delete Oe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw W(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw W(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=ue(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=fe()),x&&typeof S==`string`&&(S=ue(``)));z&&z(e),lt=e},pt=K({},[...$t,...en,...tn]),mt=K({},[...nn,...rn]),ht=function(e,t,n){return t.namespaceURI===P?e===`svg`:t.namespaceURI===$e?e===`svg`&&(n===`annotation-xml`||it[n]):!!pt[e]},gt=function(e,t,n){return t.namespaceURI===P?e===`math`:t.namespaceURI===et?e===`math`&&at[n]:!!mt[e]},_t=function(e,t,n){return t.namespaceURI===et&&!at[n]||t.namespaceURI===$e&&!it[n]?!1:!mt[e]&&(ot[e]||!pt[e])},yt=function(e){let t=ae(e),n=It(re(e)),r=_(e),i,a;return r&&b(r)===Y.element?(i={namespaceURI:ae(r)},a=It(re(r))):(i={namespaceURI:tt},a=`template`),F[t]?t===et?ht(n,i,a):t===$e?gt(n,i,a):t===P?_t(n,i,a):!!(st===`application/xhtml+xml`&&F[t]):!1},bt=function(e){kt(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw W(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},xt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},St=function(e){Ht(e);let t=g(e);t&&V(At(t),e=>{try{p(e)}catch{}});let n=b(e)===Y.element?ee(e):null;if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&xt(e,r,i)}},wt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}kt(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Be||Ve)try{bt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},Tt=function(e){let t=ee(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||D[R(i)]||xt(e,r,i)}},Et=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&b(e)===Y.element){let t=v(e);Z(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},Ht=function(e){Et(e,e=>{b(e)===Y.element&&Tt(e)})},Ut=function(e){let t=[];return Et(e,e=>{t.push(e)},!0),t},Wt=function(e,t){let n=Nt();V(Ut(e),e=>{b(e)===Y.element&&Pt(n,e)}),V(t,e=>{b(e)===Y.element&&!Ft(n,e)&&Tt(e)})},Gt=function(e,n){let r=!1;return V(t.removed,t=>{t.element&&(r||=t.element===e,Ht(t.element))}),Wt(e,n),r},Kt=function(e,t){let n=j,r=null,i=()=>(r||(r=Nt(),V(t,e=>{Pt(r,e)})),r);for(let t=0;;t++){let r=Ut(e),a=[e],o=!1;if(V(r,e=>{b(e)===Y.documentFragment?kt(a,e):!o&&!Ft(n,e)&&(o=Ft(i(),e))}),!o)return;if(t>=8)throw W(`the tree kept changing during in-place sanitization; refusing to return it`);V(a,(t,n)=>{G(t,n>0,e,i())})}},G=function(e,t,n,r){let i=Mn(e),a;for(;a=i.nextNode();)Ft(r,a)&&!Ft(j,a)&&(t&&Q(T.uponSanitizeShadowNode,a,null),Hn(a,n),Yn(a,n),Z(a.content)&&Xn(a.content))},qt=function(e){j&&Pt(j,e)},Jt=function(e,t){return Pe?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},jn=function(e){Pe&&Et(e,e=>{let t=b(e);if(t===Y.processingInstruction||t===Y.comment&&U(xn,e.data)){try{p(e)}catch{}return!1}if(t===Y.element){let t=e,n=R(re(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Jt(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},X=function(e){let t=null,r=null;if(ze)e=`<remove></remove>`+e;else{let t=Rt(e,/^[\r\n\t ]+/);r=t&&t[0]}st===`application/xhtml+xml`&&tt===P&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?ue(e):e;if(tt===P)try{t=new l().parseFromString(i,st)}catch{}if(!t||!t.documentElement){t=w.createDocument(tt,`template`,null);try{t.documentElement.innerHTML=nt?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),tt===P?he.call(t,Fe?`html`:`body`)[0]:Fe?t.documentElement:a},Mn=function(e){let t=y?y(e):e.ownerDocument;return pe.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Nn=function(e){return e=zt(e,_e,` `),e=zt(e,ve,` `),e=zt(e,ye,` `),e},Pn=function(e){Fn(e);let t=e.querySelectorAll?.call(e,`template`);t&&V(t,e=>{Z(e.content)&&Pn(e.content)})},Fn=function(e){e.normalize();let t=y?y(e):e.ownerDocument,n=pe.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=Nn(r.data),r=n.nextNode()},In=function(e){let t=ne?ne(e):null;return typeof t!=`string`||R(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==ee(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==te(e)||e.childNodes!==g(e)},Z=function(e){if(!te||typeof e!=`object`||!e)return!1;try{return te(e)===Y.documentFragment}catch{return!1}},Ln=function(e){if(!te||typeof e!=`object`||!e)return!1;try{return typeof te(e)==`number`}catch{return!1}};function Q(e,n,r){e.length!==0&&V(e,e=>{e.call(t,n,r,lt)})}let Rn=function(e,t){return!!(Pe&&e.hasChildNodes()&&!Ln(e.firstElementChild)&&U(bn,e.textContent)&&U(bn,e.innerHTML)||Pe&&wn[t]&&b(e)===Y.element&&ae(e)===P&&(Ln(e.firstElementChild)||typeof e.textContent==`string`&&U(bn,e.textContent))||e.nodeType===Y.processingInstruction||Pe&&e.nodeType===Y.comment&&U(xn,e.data))},zn=function(e,t){if(e instanceof RegExp)return U(e,t);if(e instanceof Function){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return!!e(t,...r)}return!1},Bn=function(e,t,n){if(!Oe[t]&&Gn(t)&&zn(O.tagNameCheck,t))return!1;if(Ke&&!Je[t]&&!Je[It(t)]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return bt(e),!0},Vn=function(e,t,n,r){return e.length===0?t:t===n||t===r?q(t):t},$=function(e,t){return e===t||_(e)!==null?!1:(qe&&Ht(e),!0)},Hn=function(e,n){if(qt(e),Q(T.beforeSanitizeElements,e,null),$(e,n))return!0;if(In(e))return bt(e),!0;let r=R(re(e));if(E=Vn(T.uponSanitizeElement,E,Ee,Le),Q(T.uponSanitizeElement,e,{tagName:r,allowedTags:E}),$(e,n))return!0;if(Rn(e,r))return bt(e),!0;if(Oe[r]||!(k.tagCheck instanceof Function&&k.tagCheck(r))&&!E[r]){let t=Bn(e,r,n);return t===!1&&(Q(T.afterSanitizeElements,e,null),$(e,n))?!0:t}if(b(e)===Y.element&&!yt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&U(Sn,e.innerHTML))return bt(e),!0;if(A&&e.nodeType===Y.text){let n=Nn(e.textContent);e.textContent!==n&&(kt(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Q(T.afterSanitizeElements,e,null),$(e,n)},Un=function(e,t,r){if(ke[t]||Jt(t,e)||Ue&&(t===`id`||t===`name`)&&(r in n||r in ut))return!1;let i=D[t]||k.attributeCheck instanceof Function&&k.attributeCheck(t,e);return je&&U(be,t)||Ae&&U(xe,t)?!0:i?Ze[t]||U(Te,zt(r,Ce,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Bt(r,`data:`)===0&&Xe[e]||Me&&!U(Se,zt(r,Ce,``))?!0:!r:Gn(e)&&zn(O.tagNameCheck,e)&&zn(O.attributeNameCheck,t,e)||t===`is`&&O.allowCustomizedBuiltInElements&&zn(O.tagNameCheck,r)},Wn=K({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Gn=function(e){return!Wn[It(e)]&&U(we,e)},Kn=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ue(r);case`TrustedScriptURL`:return de(r)}return r},qn=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!In(e)||(bt(e),!1)}catch{return wt(t,e),!1}},Jn=function(e,t){return Pe&&U(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,t)?!0:It(e)===`attributename`&&Rt(t,`href`)!==null},Yn=function(e,n){if(Q(T.beforeSanitizeAttributes,e,null),$(e,n))return;let r=e.attributes;if(!r||In(e))return;D=Vn(T.uponSanitizeAttribute,D,De,Re);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:D,forceKeepAttr:void 0},a=r.length,o=R(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=R(s),d=l,f=s===`value`?d:Vt(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Q(T.uponSanitizeAttribute,e,i),f=i.attrValue,We&&(u===`id`||u===`name`)&&Bt(f,Ge)!==0&&(wt(s,e,n),f=Ge+f,p=!0),Jn(s,f)?wt(s,e,n):i.forceKeepAttr||(i.keepAttr?!Ne&&U(Cn,f)?wt(s,e,n):(A&&(f=Nn(f)),Un(o,u,f)?(f=Kn(o,u,c,f),f!==d&&qn(e,s,c,f)&&p&&Ot(t.removed)):wt(s,e,n)):wt(s,e,n))}Q(T.afterSanitizeAttributes,e,null),$(e,n)},Xn=function(e){let t=null,n=Mn(e);for(Q(T.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Q(T.uponSanitizeShadowNode,t,null),Hn(t,e),Yn(t,e),Z(t.content)&&Xn(t.content),b(t)===Y.element){let e=v(t);Z(e)&&(Zn(e),Xn(e))}A&&Fn(e),Q(T.afterSanitizeShadowDOM,e,null)},Zn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Xn(e.shadow);continue}let n=e.node,r=b(n)===Y.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=ne?ne(n):null;if(typeof e==`string`&&R(e)===`template`){let e=n.content;Z(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);Z(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(nt=!e,nt&&(e=`<!-->`),typeof e!=`string`&&!Ln(e)&&(e=Yt(e),typeof e!=`string`))throw W(`dirty is not a string, aborting`);if(!t.isSupported)return e;Ie?(E=Le,D=Re):ft(n),(T.uponSanitizeElement.length>0||T.uponSanitizeAttribute.length>0)&&(E=q(E)),T.uponSanitizeAttribute.length>0&&(D=q(D)),t.removed=[];let c=qe&&typeof e!=`string`&&Ln(e),l=[],u=j;if(c){jn(e);let t=re(e);if(typeof t==`string`){let n=R(t);if(!E[n]||Oe[n])throw St(e),W(`root node is forbidden and cannot be sanitized in-place`)}if(In(e))throw St(e),W(`root node is clobbered and cannot be sanitized in-place`);l=Ut(e),j=Nt()}else if(Ln(e))i=X(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Y.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Zn(i);else{if(!Be&&!A&&!Fe&&e.indexOf(`<`)===-1)return x&&He?ue(e):e;if(i=X(e),!i)return Be?null:He?S:``}i&&ze&&bt(i.firstChild);let d=c?e:i;try{c&&Zn(e);let t=Mn(d);for(;o=t.nextNode();)Hn(o,d),Yn(o,d),Z(o.content)&&Xn(o.content);c&&Kt(e,l)}catch(t){throw c&&(St(e),Gt(e,l)),t}finally{j=u}if(c){if(Gt(e,l))throw W(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return A&&Pn(e),e}if(Be){if(A&&Pn(i),Ve)for(s=me.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(D.shadowroot||D.shadowrootmode)&&(s=ge.call(r,s,!0)),s}let f=Fe?i.outerHTML:i.innerHTML;return Fe&&E[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&U(vn,i.ownerDocument.doctype.name)&&(f=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
71
|
+
`+f),A&&(f=Nn(f)),x&&He?ue(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ft(e),Ie=!0,Le=E,Re=D},t.clearConfig=function(){lt=null,Ie=!1,Le=null,Re=null,x=oe,S=``},t.isValidAttribute=function(e,t,n){lt||ft({});let r=R(e),i=R(t);return typeof n==`string`&&(Jn(t,n)||!Ne&&U(Cn,n))?!1:Un(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&H(T,e)&&kt(T[e],t)},t.removeHook=function(e,t){if(H(T,e)){if(t!==void 0){let n=Dt(T[e],t);return n===-1?void 0:jt(T[e],n,1)[0]}return Ot(T[e])}},t.removeHooks=function(e){H(T,e)&&(T[e]=[])},t.removeAllHooks=function(){T=Dn()},t}var jn=An(),X=class{constructor(e,t){this.editor=e,this.defaultText=`${t} text`,this.button=this.createButton(),this.title=t}createButton(e){let t=document.createElement(`button`),n=this.title?`${this.title.replace(/ /g,`-`)}-btn`.toLowerCase():``;t.innerHTML=e;let r=t.querySelector(`svg`);if(r&&r.setAttribute(`aria-hidden`,`true`),t.type=`button`,t.title=this.title?this.editor.label(this.title):this.title,t.className=`markdown-btn ${n} fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost`,t.addEventListener(`click`,e=>this.applySyntax(e)),n==`preview-btn`){let e=document.createElement(`div`);return e.className=`fj:me-surface fj:me-surface-outline fj:border-base-soft fj:border-0 fj:border-l fj:sticky fj:-right-2 fj:px-1.5`,e.appendChild(t),e}return t}},Mn=class extends X{constructor(e){super(e,`Bold`),this.button=this.createButton(`
|
|
70
72
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 5h6a3.5 3.5 0 0 1 0 7h-6l0 -7" /><path d="M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7" /></svg>
|
|
71
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`***`)&&i.endsWith(`***`))a=`*`+i.slice(3,-3)+`*`;else if(i.startsWith(`**`)&&i.endsWith(`**`))a=i.slice(2,-2);else if(r.substring(t-3,t)===`***`&&r.substring(n,n+3)===`***`){e.setSelectionRange(t-3,n+3),this.editor.insertText(`*${i}*`,1,1);return}else if(r.substring(t-2,t)===`**`&&r.substring(n,n+2)===`**`&&r[t-3]!==`*`&&r[n+2]!==`*`){e.setSelectionRange(t-2,n+2),this.editor.insertText(i,0,0);return}else a=`**${i||`Bold text`}**`,i||(o=2);this.editor.insertText(a,o,o)}},
|
|
73
|
+
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`***`)&&i.endsWith(`***`))a=`*`+i.slice(3,-3)+`*`;else if(i.startsWith(`**`)&&i.endsWith(`**`))a=i.slice(2,-2);else if(r.substring(t-3,t)===`***`&&r.substring(n,n+3)===`***`){e.setSelectionRange(t-3,n+3),this.editor.insertText(`*${i}*`,1,1);return}else if(r.substring(t-2,t)===`**`&&r.substring(n,n+2)===`**`&&r[t-3]!==`*`&&r[n+2]!==`*`){e.setSelectionRange(t-2,n+2),this.editor.insertText(i,0,0);return}else a=`**${i||`Bold text`}**`,i||(o=2);this.editor.insertText(a,o,o)}},Nn=class extends X{constructor(e){super(e,`Italic`),this.button=this.createButton(`
|
|
72
74
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M11 5l6 0" /><path d="M7 19l6 0" /><path d="M14 5l-4 14" /></svg>
|
|
73
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`***`)&&i.endsWith(`***`))a=`**`+i.slice(3,-3)+`**`;else if(i.startsWith(`*`)&&i.endsWith(`*`)&&!i.startsWith(`**`))a=i.slice(1,-1);else if(r.substring(t-3,t)===`***`&&r.substring(n,n+3)===`***`){e.setSelectionRange(t-3,n+3),this.editor.insertText(`**${i}**`,2,2);return}else if(r[t-1]===`*`&&r[n]===`*`&&r[t-2]!==`*`&&r[n+1]!==`*`){e.setSelectionRange(t-1,n+1),this.editor.insertText(i,0,0);return}else a=`*${i||`Italic text`}*`,i||(o=1);this.editor.insertText(a,o,o)}},
|
|
75
|
+
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`***`)&&i.endsWith(`***`))a=`**`+i.slice(3,-3)+`**`;else if(i.startsWith(`*`)&&i.endsWith(`*`)&&!i.startsWith(`**`))a=i.slice(1,-1);else if(r.substring(t-3,t)===`***`&&r.substring(n,n+3)===`***`){e.setSelectionRange(t-3,n+3),this.editor.insertText(`**${i}**`,2,2);return}else if(r[t-1]===`*`&&r[n]===`*`&&r[t-2]!==`*`&&r[n+1]!==`*`){e.setSelectionRange(t-1,n+1),this.editor.insertText(i,0,0);return}else a=`*${i||`Italic text`}*`,i||(o=1);this.editor.insertText(a,o,o)}},Pn=class extends X{constructor(e){super(e,`Strikethrough`),this.button=this.createButton(`
|
|
74
76
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l14 0" /><path d="M16 6.5a4 2 0 0 0 -4 -1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1 -4 -1.5" /></svg>
|
|
75
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`~~`)&&i.endsWith(`~~`))a=i.slice(2,-2);else if(r.substring(t-2,t)===`~~`&&r.substring(n,n+2)===`~~`){e.setSelectionRange(t-2,n+2),this.editor.insertText(i,0,0);return}else a=`~~${i||`Strikethrough text`}~~`,o=2;this.editor.insertText(a,o,o)}},
|
|
77
|
+
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`~~`)&&i.endsWith(`~~`))a=i.slice(2,-2);else if(r.substring(t-2,t)===`~~`&&r.substring(n,n+2)===`~~`){e.setSelectionRange(t-2,n+2),this.editor.insertText(i,0,0);return}else a=`~~${i||`Strikethrough text`}~~`,o=2;this.editor.insertText(a,o,o)}},Fn=class extends X{constructor(e){super(e,`Unordered list`),this.button=this.createButton(`
|
|
76
78
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 6l11 0" /><path d="M9 12l11 0" /><path d="M9 18l11 0" /><path d="M5 6l0 .01" /><path d="M5 12l0 .01" /><path d="M5 18l0 .01" /></svg>
|
|
77
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`- `))a=i.slice(2);else if(r.substring(t-2,t)===`- `){e.setSelectionRange(t-2,n),this.editor.insertText(i,0,0);return}else a=`- ${i||`Unordered list`}`,o=2;this.editor.insertText(a,o)}},
|
|
79
|
+
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`- `))a=i.slice(2);else if(r.substring(t-2,t)===`- `){e.setSelectionRange(t-2,n),this.editor.insertText(i,0,0);return}else a=`- ${i||`Unordered list`}`,o=2;this.editor.insertText(a,o)}},In=class extends X{constructor(e){super(e,`Ordered list`),this.button=this.createButton(`
|
|
78
80
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M11 6h9" /><path d="M11 12h9" /><path d="M12 18h8" /><path d="M4 16a2 2 0 1 1 4 0c0 .591 -.5 1 -1 1.5l-3 2.5h4" /><path d="M6 10v-6l-2 2" /></svg>
|
|
79
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`1. `))a=i.slice(3);else if(r.substring(t-3,t)===`1. `){e.setSelectionRange(t-3,n),this.editor.insertText(i,0,0);return}else a=`1. ${i||`Ordered list`}`,o=3;this.editor.insertText(a,o)}},
|
|
81
|
+
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`1. `))a=i.slice(3);else if(r.substring(t-3,t)===`1. `){e.setSelectionRange(t-3,n),this.editor.insertText(i,0,0);return}else a=`1. ${i||`Ordered list`}`,o=3;this.editor.insertText(a,o)}},Z=class extends X{constructor(e){super(e,`Preview`),this.preview=!0,this.button=this.createButton(`
|
|
80
82
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 4v16" /><path d="M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14" /><path d="M12 13l7.5 -7.5" /><path d="M12 18l8 -8" /><path d="M15 20l5 -5" /><path d="M12 8l4 -4" /></svg>
|
|
81
|
-
`);let t=this.button.querySelector(`button`);t&&t.setAttribute(`aria-pressed`,`false`)}applySyntax(){let e=this.editor.previewContent?.parentNode,t=this.editor.markdownEditorDiv;e&&t&&(this.editor.preview&&this.preview?this.enablePreview(e,t):this.disablePreview(e,t))}disablePreview(e,t){this.preview=!0;let n=t.querySelector(`.textarea-wrapper`);t.parentNode.classList.remove(`is-fullscreen`),t.classList.remove(`fj:md:grid-cols-2`),e.classList.add(`fj:hidden`),n.classList.remove(`fj:hidden`,`fj:md:grid`),n.querySelector(`textarea`).classList.remove(`fj:h-full!`),n.querySelector(`.display-layer`)&&n.querySelector(`.display-layer`).classList.remove(`fj:h-full!`),e.classList.remove(`fj:min-h-0`),document.querySelector(`body`).classList.remove(`fj:overflow-hidden`),document.removeEventListener(`keydown`,this._escHandler),this.editor._autoGrow(),this.editor.editorContainer.querySelectorAll(`.markdown-btn`).forEach(e=>{e.classList.contains(`preview-btn`)?(e.classList.remove(`fj:me-btn-active`),e.setAttribute(`aria-pressed`,`false`)):(e.classList.remove(`fj:pointer-events-none`,`fj:md:pointer-events-auto`,`fj:opacity-25`,`fj:md:opacity-100`),e.removeAttribute(`aria-disabled`))})}enablePreview(e,t){this.preview=!1;let n=t.querySelector(`.textarea-wrapper`);t.parentNode.classList.add(`is-fullscreen`),t.classList.add(`fj:md:grid-cols-2`),e.classList.remove(`fj:hidden`),n.classList.add(`fj:hidden`,`fj:md:grid`),this.editor.editorContainer.style.height=``,n.querySelector(`textarea`).classList.add(`fj:h-full!`),n.querySelector(`.display-layer`)&&n.querySelector(`.display-layer`).classList.add(`fj:h-full!`),e.classList.add(`fj:min-h-0`),document.querySelector(`body`).classList.add(`fj:overflow-hidden`),this._escHandler=e=>{e.key===`Escape`&&this.applySyntax()},document.addEventListener(`keydown`,this._escHandler),this.editor.render();let r=window.matchMedia(`(max-width: 767px)`).matches;this.editor.editorContainer.querySelectorAll(`.markdown-btn`).forEach(e=>{e.classList.contains(`preview-btn`)?(e.classList.add(`fj:me-btn-active`),e.setAttribute(`aria-pressed`,`true`)):(e.classList.add(`fj:pointer-events-none`,`fj:md:pointer-events-auto`,`fj:opacity-25`,`fj:md:opacity-100`),e.setAttribute(`aria-disabled`,r?`true`:`false`))})}destroy(){this.preview||(document.removeEventListener(`keydown`,this._escHandler),document.querySelector(`body`)?.classList.remove(`fj:overflow-hidden`))}},
|
|
83
|
+
`);let t=this.button.querySelector(`button`);t&&t.setAttribute(`aria-pressed`,`false`)}applySyntax(){let e=this.editor.previewContent?.parentNode,t=this.editor.markdownEditorDiv;e&&t&&(this.editor.preview&&this.preview?this.enablePreview(e,t):this.disablePreview(e,t))}disablePreview(e,t){this.preview=!0;let n=t.querySelector(`.textarea-wrapper`);t.parentNode.classList.remove(`is-fullscreen`),t.classList.remove(`fj:md:grid-cols-2`),e.classList.add(`fj:hidden`),n.classList.remove(`fj:hidden`,`fj:md:grid`),n.querySelector(`textarea`).classList.remove(`fj:h-full!`),n.querySelector(`.display-layer`)&&n.querySelector(`.display-layer`).classList.remove(`fj:h-full!`),e.classList.remove(`fj:min-h-0`),document.querySelector(`body`).classList.remove(`fj:overflow-hidden`),document.removeEventListener(`keydown`,this._escHandler),this.editor._autoGrow(),this.editor.editorContainer.querySelectorAll(`.markdown-btn`).forEach(e=>{e.classList.contains(`preview-btn`)?(e.classList.remove(`fj:me-btn-active`),e.setAttribute(`aria-pressed`,`false`)):(e.classList.remove(`fj:pointer-events-none`,`fj:md:pointer-events-auto`,`fj:opacity-25`,`fj:md:opacity-100`),e.removeAttribute(`aria-disabled`))})}enablePreview(e,t){this.preview=!1;let n=t.querySelector(`.textarea-wrapper`);t.parentNode.classList.add(`is-fullscreen`),t.classList.add(`fj:md:grid-cols-2`),e.classList.remove(`fj:hidden`),n.classList.add(`fj:hidden`,`fj:md:grid`),this.editor.editorContainer.style.height=``,n.querySelector(`textarea`).classList.add(`fj:h-full!`),n.querySelector(`.display-layer`)&&n.querySelector(`.display-layer`).classList.add(`fj:h-full!`),e.classList.add(`fj:min-h-0`),document.querySelector(`body`).classList.add(`fj:overflow-hidden`),this._escHandler=e=>{e.key===`Escape`&&this.applySyntax()},document.addEventListener(`keydown`,this._escHandler),this.editor.render();let r=window.matchMedia(`(max-width: 767px)`).matches;this.editor.editorContainer.querySelectorAll(`.markdown-btn`).forEach(e=>{e.classList.contains(`preview-btn`)?(e.classList.add(`fj:me-btn-active`),e.setAttribute(`aria-pressed`,`true`)):(e.classList.add(`fj:pointer-events-none`,`fj:md:pointer-events-auto`,`fj:opacity-25`,`fj:md:opacity-100`),e.setAttribute(`aria-disabled`,r?`true`:`false`))})}destroy(){this.preview||(document.removeEventListener(`keydown`,this._escHandler),document.querySelector(`body`)?.classList.remove(`fj:overflow-hidden`))}},Ln=class extends X{constructor(e){super(e,`Check list`),this.button=this.createButton(`
|
|
82
84
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M3.5 5.5l1.5 1.5l2.5 -2.5" /><path d="M3.5 11.5l1.5 1.5l2.5 -2.5" /><path d="M3.5 17.5l1.5 1.5l2.5 -2.5" /><path d="M11 6l9 0" /><path d="M11 12l9 0" /><path d="M11 18l9 0" /></svg>
|
|
83
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=`- [x] `,o=`- [ ] `,s=``,c=0;if(i.startsWith(a)||i.startsWith(o))s=i.slice(6);else{let l=r.substring(t-6,t);if(l===a||l===o){e.setSelectionRange(t-6,n),this.editor.insertText(i,0,0);return}s=`${a}${i||`Check list`}`,c=6}this.editor.insertText(s,c)}},
|
|
85
|
+
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=`- [x] `,o=`- [ ] `,s=``,c=0;if(i.startsWith(a)||i.startsWith(o))s=i.slice(6);else{let l=r.substring(t-6,t);if(l===a||l===o){e.setSelectionRange(t-6,n),this.editor.insertText(i,0,0);return}s=`${a}${i||`Check list`}`,c=6}this.editor.insertText(s,c)}},Q=class extends X{constructor(e){super(e,`Blockquote`),this.button=this.createButton(`
|
|
84
86
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M10 11h-4a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1h3a1 1 0 0 1 1 1v6c0 2.667 -1.333 4.333 -4 5" /><path d="M19 11h-4a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1h3a1 1 0 0 1 1 1v6c0 2.667 -1.333 4.333 -4 5" /></svg>
|
|
85
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`>`))a=i.slice(1);else if(r.substring(t-1,t)===`>`){e.setSelectionRange(t-1,n),this.editor.insertText(i,0,0);return}else a=`>${i||`Blockquote text`}`,i||(o=1);this.editor.insertText(a,o)}};function
|
|
87
|
+
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`>`))a=i.slice(1);else if(r.substring(t-1,t)===`>`){e.setSelectionRange(t-1,n),this.editor.insertText(i,0,0);return}else a=`>${i||`Blockquote text`}`,i||(o=1);this.editor.insertText(a,o)}};function Rn(e,t,n,r=``){let i=e.target.closest(`.markdown-editor-wrapper`);i.querySelector(`.markdown-modal`)&&i.querySelector(`.markdown-modal`).remove();let a=`
|
|
86
88
|
<dialog class="markdown-modal fj:me-modal fj:me-modal-top fj:lg:me-modal-middle fj:me-modal-center" id="nezanuha_toggleModal" ${r?`aria-label="${r}"`:``}>
|
|
87
89
|
<div class="fj:me-modal-content ${t}">
|
|
88
90
|
${n}
|
|
89
91
|
</div>
|
|
90
92
|
</dialog>
|
|
91
|
-
`;i.querySelector(`.markdown-modal`)||i.insertAdjacentHTML(`beforeend`,a);let o=i.querySelector(`.markdown-modal`);return o.addEventListener(`close`,()=>o.remove()),o.showModal(),o}var
|
|
93
|
+
`;i.querySelector(`.markdown-modal`)||i.insertAdjacentHTML(`beforeend`,a);let o=i.querySelector(`.markdown-modal`);return o.addEventListener(`close`,()=>o.remove()),o.showModal(),o}var zn=class extends X{constructor(e){super(e,`Link`),this.button=this.createButton(`
|
|
92
94
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 15l6 -6" /><path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464" /><path d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463" /></svg>
|
|
93
|
-
`)}applySyntax(e){let t=this.editor,n=t.usertextarea,{selectionStart:r,selectionEnd:i}=n,a=n.value,o=a.substring(0,r),s=a.substring(i);if(o.endsWith(`[`)&&/^\]\([^)]+\)/.test(s)){let e=s.match(/^\]\(([^)]+)\)/);e&&(r=o.length-1,i+=e[0].length,n.setSelectionRange(r,i))}let c=a.substring(r,i),l=c&&c.match(/^\[([^\]]+)\]\(([^)]+)\)$/),u=l?l[1]:c,d=l?l[2]:``,f=
|
|
95
|
+
`)}applySyntax(e){let t=this.editor,n=t.usertextarea,{selectionStart:r,selectionEnd:i}=n,a=n.value,o=a.substring(0,r),s=a.substring(i);if(o.endsWith(`[`)&&/^\]\([^)]+\)/.test(s)){let e=s.match(/^\]\(([^)]+)\)/);e&&(r=o.length-1,i+=e[0].length,n.setSelectionRange(r,i))}let c=a.substring(r,i),l=c&&c.match(/^\[([^\]]+)\]\(([^)]+)\)$/),u=l?l[1]:c,d=l?l[2]:``,f=Rn(e,`fj:max-w-sm`,`
|
|
94
96
|
<div class="fj:flex fj:justify-between fj:items-center fj:gap-3">
|
|
95
97
|
<div class="fj:font-medium">${this.editor.label(`Link`)}</div>
|
|
96
98
|
<button type="button" class="modal-close-btn fj:me-btn fj:me-btn-ghost fj:me-btn-xs fj:me-btn-circle" aria-label="${this.editor.label(`Close`)}">
|
|
@@ -103,16 +105,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
103
105
|
<input type="text" placeholder="${this.editor.label(`Link text`)}" class="link-text-input fj:me-input fj:w-full" value="${u}" required>
|
|
104
106
|
<button type="submit" class="submit-link fj:me-btn fj:me-btn-sm fj:self-end">${this.editor.label(`Apply`)}</button>
|
|
105
107
|
</div>
|
|
106
|
-
</form>`,`Link`);f.querySelector(`.modal-close-btn`).addEventListener(`click`,()=>f.close()),f.querySelector(`.submit-link`).addEventListener(`click`,function(e){e.preventDefault();let n=f.querySelector(`.link-input`),r=f.querySelector(`.link-text-input`);if(!n.validity.valid)n.reportValidity();else if(!r.validity.valid)r.reportValidity();else{let e=n.value,i=r.value||`Link Text`;t.insertText(`[${i}](${e})`),f.close()}})}},
|
|
108
|
+
</form>`,`Link`);f.querySelector(`.modal-close-btn`).addEventListener(`click`,()=>f.close()),f.querySelector(`.submit-link`).addEventListener(`click`,function(e){e.preventDefault();let n=f.querySelector(`.link-input`),r=f.querySelector(`.link-text-input`);if(!n.validity.valid)n.reportValidity();else if(!r.validity.valid)r.reportValidity();else{let e=n.value,i=r.value||`Link Text`;t.insertText(`[${i}](${e})`),f.close()}})}},Bn=[1,2,3,4,5,6];function Vn(e){if(e===void 0)return Bn;if(!Array.isArray(e))return console.warn(`[MarkdownEditor] heading levels must be an array of numbers 1-6. Using all six.`,e),Bn;let t=[...new Set(e)].filter(e=>Number.isInteger(e)&&e>=1&&e<=6).sort((e,t)=>e-t);return t.length!==e.length&&console.warn(`[MarkdownEditor] Ignored heading levels outside 1-6, or repeated.`,e),t.length?t:(console.warn(`[MarkdownEditor] No usable heading levels. Using all six.`,e),Bn)}var $=class extends X{constructor(e,t={}){super(e,`Heading`),this.levels=Vn(t?.levels),this.button=this.createButton(`
|
|
107
109
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 12h10" /><path d="M7 5v14" /><path d="M17 5v14" /><path d="M15 19h4" /><path d="M15 5h4" /><path d="M5 19h4" /><path d="M5 5h4" /></svg>
|
|
108
|
-
`)}createButton(e){let t=`heading-popover-${Math.random().toString(36).slice(2,7)}`,n=document.createElement(`button`);n.innerHTML=e;let r=n.querySelector(`svg`);r&&r.setAttribute(`aria-hidden`,`true`),n.type=`button`,n.title=this.editor.label(`Heading`),n.setAttribute(`aria-label`,this.editor.label(`Heading`)),n.setAttribute(`aria-haspopup`,`menu`),n.className=`markdown-btn heading-btn fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost fj:me-popover-toggle`,n.setAttribute(`popovertarget`,t);let i=document.createElement(`div`);i.id=t,i.setAttribute(`role`,`menu`),i.setAttribute(`aria-label`,this.editor.label(`Heading level`)),i.className=`fj:me-popover-content`,i.setAttribute(`popover`,``);let a=document.createElement(`ul`);a.className=`fj:me-menu`,a.setAttribute(`role`,`presentation`);let o=[`fj:me-heading-xl`,`fj:me-heading-lg`,`fj:me-heading-md`,`fj:me-heading-sm`,`fj:me-heading-xs`,`fj:me-heading-xs`];for(let e of this.levels??
|
|
110
|
+
`)}createButton(e){let t=`heading-popover-${Math.random().toString(36).slice(2,7)}`,n=document.createElement(`button`);n.innerHTML=e;let r=n.querySelector(`svg`);r&&r.setAttribute(`aria-hidden`,`true`),n.type=`button`,n.title=this.editor.label(`Heading`),n.setAttribute(`aria-label`,this.editor.label(`Heading`)),n.setAttribute(`aria-haspopup`,`menu`),n.className=`markdown-btn heading-btn fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost fj:me-popover-toggle`,n.setAttribute(`popovertarget`,t);let i=document.createElement(`div`);i.id=t,i.setAttribute(`role`,`menu`),i.setAttribute(`aria-label`,this.editor.label(`Heading level`)),i.className=`fj:me-popover-content`,i.setAttribute(`popover`,``);let a=document.createElement(`ul`);a.className=`fj:me-menu`,a.setAttribute(`role`,`presentation`);let o=[`fj:me-heading-xl`,`fj:me-heading-lg`,`fj:me-heading-md`,`fj:me-heading-sm`,`fj:me-heading-xs`,`fj:me-heading-xs`];for(let e of this.levels??Bn){let t=document.createElement(`li`);t.setAttribute(`role`,`none`);let n=document.createElement(`button`);n.type=`button`,n.setAttribute(`role`,`menuitem`),n.className=`fj:me-menu-item ${o[e-1]}`,n.textContent=`${this.editor.label(`Heading`)} ${e}`,n.addEventListener(`click`,()=>{this.applyHeading(e),i.hidePopover()}),t.appendChild(n),a.appendChild(t)}i.appendChild(a);let s=document.createElement(`div`);return s.className=`fj:me-popover`,s.appendChild(n),s.appendChild(i),s}applyHeading(e){let t=this.editor.usertextarea,{selectionStart:n,selectionEnd:r}=t,i=t.value,a=i.lastIndexOf(`
|
|
109
111
|
`,n-1)+1,o=i.indexOf(`
|
|
110
|
-
`,r),s=o===-1?i.length:o,c=i.substring(a,s),l=(c.match(/^(#+)\s/)||[])[1],u=c.replace(/^#+\s*/,``),d=`${`#`.repeat(e)} `,f=l&&l.length===e?u||`Heading`:u?`${d}${u}`:`${d}Heading
|
|
112
|
+
`,r),s=o===-1?i.length:o,c=i.substring(a,s),l=(c.match(/^(#+)\s/)||[])[1],u=c.replace(/^#+\s*/,``),d=`${`#`.repeat(e)} `,f=l&&l.length===e?u||`Heading`:u?`${d}${u}`:`${d}Heading`,p=t.scrollTop;t.value=`${i.substring(0,a)}${f}${i.substring(s)}`,t.focus();let m=a+(f===u||f===`Heading`?0:d.length),h=a+f.length;t.setSelectionRange(m,h),this.editor.render(),this.editor.notifyChange(),this.editor.restoreScroll(p)}applySyntax(){}};async function Hn(e,{uploadUrl:t,params:n={},alt:r=``}={}){let i=new FormData;i.append(`image_file`,e),i.append(`image_alt`,r);for(let[e,t]of Object.entries(n))i.append(e,t);let a=await fetch(t,{method:`POST`,body:i});if(!a.ok)throw Error(`Upload failed: ${a.status}`);let o=await a.json();if(!o.success||!o.image_path)throw Error(o.error||o.message||`Image upload failed.`);return{path:o.image_path,alt:o.image_alt||``}}var Un=class extends X{constructor(e,t={}){super(e,`Image link`),this.config=t,this.fileInputConfig=t.fileInput||!1,this.altInputConfig=t.altInput===void 0?{required:!0}:t.altInput,this.button=this.createButton(`
|
|
111
113
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M15 8h.01" /><path d="M12.5 21h-6.5a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v6.5" /><path d="M3 16l5 -5c.928 -.893 2.072 -.893 3 0l4 4" /><path d="M14 14l1 -1c.67 -.644 1.45 -.824 2.182 -.54" /><path d="M16 19h6" /><path d="M19 16v6" /></svg>
|
|
112
|
-
`)}applySyntax(e){let t=this.editor,n=t.usertextarea,{selectionStart:r,selectionEnd:i}=n,a=n.value,o=a.substring(0,r),s=a.substring(i);if(o.endsWith(`![`)&&/^\]\([^)]+\)/.test(s)){let e=s.match(/^\]\(([^)]+)\)/);e&&(r=o.length-2,i+=e[0].length,n.setSelectionRange(r,i))}let c=a.substring(r,i),l=this.fileInputConfig.accept?this.fileInputConfig.accept.map(e=>`image/${e}`).join(`,`):`image/*`,u=typeof this.altInputConfig==`boolean`?this.altInputConfig:this.altInputConfig.required!==!1,d=this.fileInputConfig.uploadUrl||null,f=this.fileInputConfig.params||{},p=c&&c.match(/^!\[([^\]]*)\]\(([^)]+)\)$/),m=p?p[1]:c,
|
|
114
|
+
`)}applySyntax(e){let t=this.editor,n=t.usertextarea,{selectionStart:r,selectionEnd:i}=n,a=n.value,o=a.substring(0,r),s=a.substring(i);if(o.endsWith(`![`)&&/^\]\([^)]+\)/.test(s)){let e=s.match(/^\]\(([^)]+)\)/);e&&(r=o.length-2,i+=e[0].length,n.setSelectionRange(r,i))}let c=a.substring(r,i),l=this.fileInputConfig.accept?this.fileInputConfig.accept.map(e=>`image/${e}`).join(`,`):`image/*`,u=typeof this.altInputConfig==`boolean`?this.altInputConfig:this.altInputConfig.required!==!1,d=this.fileInputConfig.uploadUrl||null,f=this.fileInputConfig.params||{},p=c&&c.match(/^!\[([^\]]*)\]\(([^)]+)\)$/),m=p?p[1]:c,h=p?p[2]:``,g=``;this.fileInputConfig&&(g=`
|
|
113
115
|
<input type="file" accept="${l}" class="img-file-input fj:me-input fj:w-full">
|
|
114
116
|
<div class="fj:me-divider fj:my-1">OR</div>
|
|
115
|
-
`);let
|
|
117
|
+
`);let _=Rn(e,`fj:max-w-sm`,`
|
|
116
118
|
<div class="fj:flex fj:justify-between fj:items-center fj:gap-3">
|
|
117
119
|
<div class="fj:font-medium">${t.label(`Image`)}</div>
|
|
118
120
|
<button type="button" class="modal-close-btn fj:me-btn fj:me-btn-ghost fj:me-btn-xs fj:me-btn-circle" aria-label="${t.label(`Close`)}">
|
|
@@ -120,44 +122,44 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
120
122
|
</button>
|
|
121
123
|
</div>
|
|
122
124
|
<div class="fj:mt-4 fj:flex fj:flex-col fj:gap-y-4">
|
|
123
|
-
${
|
|
124
|
-
<input type="url" placeholder="${t.label(`URL`)}" class="img-link-input fj:me-input fj:w-full" value="${
|
|
125
|
+
${g}
|
|
126
|
+
<input type="url" placeholder="${t.label(`URL`)}" class="img-link-input fj:me-input fj:w-full" value="${h}" required>
|
|
125
127
|
<input type="text" placeholder="${t.label(`Alt text`)}" class="img-link-alt-input fj:me-input fj:w-full" value="${m}" ${u?`required`:``}>
|
|
126
128
|
<button type="button" class="submit-img-link fj:me-btn fj:me-btn-sm fj:self-end">${t.label(`Apply`)}</button>
|
|
127
|
-
</div>`,`Image`);
|
|
129
|
+
</div>`,`Image`);_.querySelector(`.modal-close-btn`).addEventListener(`click`,()=>_.close());let v=_.querySelector(`.submit-img-link`);v.addEventListener(`click`,async e=>{e.preventDefault();let n=_.querySelector(`.img-file-input`),r=_.querySelector(`.img-link-input`),i=_.querySelector(`.img-link-alt-input`),a=n?.files[0];if(a&&(r.required=!1),u&&!i.validity.valid){i.reportValidity(),a&&(r.required=!0);return}if(!a&&!r.validity.valid){r.reportValidity();return}if(a&&d){let e=n.files[0];v.disabled=!0,v.textContent=t.label(`Uploading...`);try{let{path:t,alt:n}=await Hn(e,{uploadUrl:d,params:f,alt:i.value});r.value=t,n&&!i.value.trim()&&(i.value=n)}catch(e){alert(e.message||`Upload failed.`),v.disabled=!1,v.textContent=t.label(`Apply`),r.required=!0;return}v.disabled=!1,v.textContent=t.label(`Apply`)}let o=r.value,s=``;t.insertText(s),_.close()})}},Wn=class extends X{constructor(e){super(e,`Undo`),this.button=this.createButton(`
|
|
128
130
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 14l-4 -4l4 -4" /><path d="M5 10h11a4 4 0 1 1 0 8h-1" /></svg>
|
|
129
|
-
`)}applySyntax(){let e=this.editor.undoRedoManager;e&&e.undo()}},
|
|
131
|
+
`)}applySyntax(){let e=this.editor.undoRedoManager;e&&e.undo()}},Gn=class extends X{constructor(e){super(e,`Redo`),this.button=this.createButton(`
|
|
130
132
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M15 14l4 -4l-4 -4" /><path d="M19 10h-11a4 4 0 1 0 0 8h1" /></svg>
|
|
131
|
-
`)}applySyntax(){let e=this.editor.undoRedoManager;e&&e.redo()}},
|
|
133
|
+
`)}applySyntax(){let e=this.editor.undoRedoManager;e&&e.redo()}},Kn=class extends X{constructor(e){super(e,`Indent`),this.button=this.createButton(`
|
|
132
134
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M20 6l-11 0" /><path d="M20 12l-7 0" /><path d="M20 18l-11 0" /><path d="M4 8l4 4l-4 4" /></svg>
|
|
133
|
-
`)}applySyntax(){let e=this.editor.indentManager;e&&(e.indent(),this.editor.render())}},
|
|
135
|
+
`)}applySyntax(){let e=this.editor.indentManager;e&&(e.indent(),this.editor.render())}},qn=class extends X{constructor(e){super(e,`Outdent`),this.button=this.createButton(`
|
|
134
136
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M20 6l-7 0" /><path d="M20 12l-9 0" /><path d="M20 18l-7 0" /><path d="M8 8l-4 4l4 4" /></svg>
|
|
135
|
-
`)}applySyntax(e){let t=this.editor.indentManager;t&&(t.outdent(),this.editor.render())}},
|
|
137
|
+
`)}applySyntax(e){let t=this.editor.indentManager;t&&(t.outdent(),this.editor.render())}},Jn=class extends X{constructor(e){super(e,`Code`),this.button=this.createButton(`
|
|
136
138
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 8l-4 4l4 4" /><path d="M17 8l4 4l-4 4" /><path d="M14 4l-4 16" /></svg>
|
|
137
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n);if(i.startsWith("`")&&i.endsWith("`")){this.editor.insertText(i.slice(1,-1),0,0);return}if(r[t-1]==="`"&&r[n]==="`"){e.setSelectionRange(t-1,n+1),this.editor.insertText(i,0,0);return}let a=`\`${i||`code`}\``;this.editor.insertText(a,1,1)}},
|
|
139
|
+
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n);if(i.startsWith("`")&&i.endsWith("`")){this.editor.insertText(i.slice(1,-1),0,0);return}if(r[t-1]==="`"&&r[n]==="`"){e.setSelectionRange(t-1,n+1),this.editor.insertText(i,0,0);return}let a=`\`${i||`code`}\``;this.editor.insertText(a,1,1)}},Yn=class extends X{constructor(e){super(e,`Code Block`),this.button=this.createButton(`
|
|
138
140
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M8 9l3 3l-3 3" /><path d="M13 15l3 0" /><rect x="3" y="4" width="18" height="16" rx="2" /></svg>
|
|
139
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value.substring(t,n);if(r.startsWith("```")&&r.endsWith("```")&&r.length>6){let e=r.replace(/^```\w*\n?/,``).replace(/\n?```$/,``);this.editor.insertText(e,0,0);return}let i=`\`\`\`\n${r||`code`}\n\`\`\``;this.editor.insertText(i,4,4)}},
|
|
141
|
+
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value.substring(t,n);if(r.startsWith("```")&&r.endsWith("```")&&r.length>6){let e=r.replace(/^```\w*\n?/,``).replace(/\n?```$/,``);this.editor.insertText(e,0,0);return}let i=`\`\`\`\n${r||`code`}\n\`\`\``;this.editor.insertText(i,4,4)}},Xn=class extends X{constructor(e){super(e,`Horizontal Rule`),this.button=this.createButton(`
|
|
140
142
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 12l16 0" stroke-width="3"/><path d="M4 7l6 0" /><path d="M4 17l6 0" /><path d="M14 7l6 0" /><path d="M14 17l6 0" /></svg>
|
|
141
143
|
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t}=e,n=e.value,r=t===0||n[t-1]===`
|
|
142
144
|
`?`---
|
|
143
145
|
`:`
|
|
144
146
|
|
|
145
147
|
---
|
|
146
|
-
`;this.editor.insertText(r,r.length,0)}},
|
|
148
|
+
`;this.editor.insertText(r,r.length,0)}},Zn=class extends X{constructor(e){super(e,`Table`),this.button=this.createButton(`
|
|
147
149
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z" /><path d="M3 10h18" /><path d="M10 3v18" /></svg>
|
|
148
150
|
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t}=e,n=e.value,r=`| Column 1 | Column 2 | Column 3 |
|
|
149
151
|
| --- | --- | --- |
|
|
150
152
|
| Cell | Cell | Cell |
|
|
151
153
|
| Cell | Cell | Cell |`,i=t===0||n[t-1]===`
|
|
152
|
-
`?r:`\n${r}`;this.editor.insertText(i,i.length,0)}};function
|
|
154
|
+
`?r:`\n${r}`;this.editor.insertText(i,i.length,0)}};function Qn(e){let t=e=>e&&e.label&&typeof e.value==`string`,n=[];for(let r of Array.isArray(e)?e:[])r&&(Array.isArray(r.items)?n.push(...r.items.filter(t)):t(r)&&n.push(r));return n}function $n(e,t){let n=Qn(t).filter(e=>typeof e.sample==`string`);return n.length?n.slice().sort((e,t)=>t.value.length-e.value.length).reduce((e,t)=>e.split(t.value).join(t.sample),e):e}var er=`
|
|
153
155
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 4a2 2 0 0 0 -2 2v3a2 2 0 0 1 -2 2a2 2 0 0 1 2 2v3a2 2 0 0 0 2 2" /><path d="M17 4a2 2 0 0 1 2 2v3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2v3a2 2 0 0 1 -2 2" /></svg>
|
|
154
|
-
`,
|
|
155
|
-
`),r=[];this.options.line&&r.push(this._count(`Ln {n}`,e.length)),this.options.col&&r.push(this._count(`Col {n}`,e[e.length-1].length+1)),this.positionEl.textContent=r.join(`, `)}if(this.options.chars&&(this.charsEl.textContent=this._count(`{n} chars`,t.length)),this.options.words){let e=t.trim()?t.trim().split(/\s+/).length:0;this.wordsEl.textContent=this._count(`{n} words`,e)}}_count(e,t){return this.label(e).replace(`{n}`,t.toLocaleString())}},
|
|
156
|
-
`)
|
|
157
|
-
`)
|
|
156
|
+
`,tr=class extends X{constructor(e){super(e,`Variables`)}createButton(){let e=this.editor.variables??[];if(!Qn(e).length)return null;let t=`variable-popover-${Math.random().toString(36).slice(2,7)}`,n=document.createElement(`button`);n.innerHTML=er,n.querySelector(`svg`)?.setAttribute(`aria-hidden`,`true`),n.type=`button`,n.title=this.editor.label(`Insert variable`),n.setAttribute(`aria-label`,this.editor.label(`Insert variable`)),n.setAttribute(`aria-haspopup`,`menu`),n.className=`markdown-btn variable-btn fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost fj:me-popover-toggle`,n.setAttribute(`popovertarget`,t);let r=document.createElement(`div`);r.id=t,r.setAttribute(`role`,`menu`),r.setAttribute(`aria-label`,this.editor.label(`Variables`)),r.className=`fj:me-popover-content`,r.setAttribute(`popover`,``);let i=document.createElement(`ul`);i.className=`fj:me-menu`,i.setAttribute(`role`,`presentation`);let a=e=>e&&e.label&&typeof e.value==`string`;for(let t of e)if(t){if(Array.isArray(t.items)){let e=t.items.filter(a);if(!e.length)continue;let n=document.createElement(`li`);n.className=`fj:me-menu-title`,n.setAttribute(`role`,`presentation`),n.textContent=t.label??``;let o=document.createElement(`ul`);o.setAttribute(`role`,`group`),t.label&&o.setAttribute(`aria-label`,t.label),e.forEach(e=>o.appendChild(this.createItem(e,r)));let s=document.createElement(`li`);s.setAttribute(`role`,`none`),s.appendChild(o),i.appendChild(n),i.appendChild(s)}else a(t)&&i.appendChild(this.createItem(t,r))}r.appendChild(i);let o=document.createElement(`div`);return o.className=`fj:me-popover`,o.appendChild(n),o.appendChild(r),o}createItem(e,t){let n=document.createElement(`li`);n.setAttribute(`role`,`none`);let r=document.createElement(`button`);return r.type=`button`,r.setAttribute(`role`,`menuitem`),r.className=`fj:me-menu-item`,r.textContent=e.label,r.title=e.value,r.addEventListener(`click`,()=>{this.editor.insertText(e.value,e.value.length,0),t.hidePopover()}),n.appendChild(r),n}applySyntax(){}},nr=class extends X{constructor(e,t={}){super(e,t.title||`Custom`),this.action=t.action,this.button=typeof this.action==`function`?this.createButton(t.icon||``):null,this.shortcut=this.button?t.shortcut:void 0,this.button||console.warn(`[MarkdownEditor] A custom tool needs an action function. Skipping it.`,t)}applySyntax(e){this.action(this.editor,e)}},rr=class{constructor(e,t,{standalone:n=!1}={}){this.editor=e,this.options=t,this.standalone=n,this.tools=[],this.toolbar=document.createElement(`div`),this.toolbar.className=n?`toolbar not-prose fj:flex fj:items-center fj:gap-x-1`:`toolbar not-prose fj:me-surface fj:me-surface-outline fj:border-base-soft fj:border-0 fj:border-b fj:flex fj:items-center fj:gap-x-1 fj:p-1.5 fj:overflow-x-auto`,this.toolbar.setAttribute(`role`,`toolbar`),this.toolbar.setAttribute(`aria-label`,e.label(`Editor toolbar`)),this.init()}destroy(){this.tools.forEach(e=>e.destroy?.())}init(){let e={heading:$,ul:Fn,ol:In,checklist:Ln,bold:Mn,italic:Nn,strikethrough:Pn,blockquote:Q,code:Jn,codeblock:Yn,hr:Xn,table:Zn,link:zn,image:Un,undo:Wn,redo:Gn,indent:Kn,outdent:qn,variables:tr};if(this.options.forEach(t=>{let n,r;if(typeof t==`string`)n=e[t];else if(typeof t==`function`)n=t;else if(t&&typeof t.tool==`function`)n=t.tool,r=t.config;else if(t&&t.custom)n=nr,r=t.custom;else if(typeof t==`object`){let i=Object.keys(t)[0];r=t[i],n=e[i]}if(n){let e=new n(this.editor,r);this.tools.push(e),e.button&&this.toolbar.appendChild(e.button)}}),!this.standalone){if(this.options.includes(`preview`)){let e=new Z(this.editor);this.editor.previewTool=e,this.toolbar.appendChild(e.button)}this.editor.editorContainer.insertBefore(this.toolbar,this.editor.markdownEditorDiv)}}},ir=class{constructor(e){this.previewContainer=document.createElement(`div`),this.previewContainer.className=`preview-wrapper fj:p-2 fj:hidden fj:me-surface fj:me-surface-outline fj:border-base-soft fj:border-0 fj:border-l`,this.previewContainer.setAttribute(`role`,`region`),this.previewContainer.setAttribute(`aria-label`,`Preview`),this.previewContent=document.createElement(`div`),this.previewContent.className=`preview-content fj:mte-prose fj:mte-prose-sm fj:md:mte-prose-base fj:me-prose-frutjam fj:p-1.5 fj:overflow-y-auto fj:h-full fj:max-w-full`,this.previewContainer.appendChild(this.previewContent),e.appendChild(this.previewContainer)}getPreviewContent(){return this.previewContent}},ar=class{constructor(e,t={},n=e=>e){this.options=t,this.label=n,this.footer=document.createElement(`div`),this.footer.className=`editor-footer not-prose fj:me-surface fj:me-surface-outline fj:border-base-soft fj:border-0 fj:border-t fj:flex fj:justify-between fj:items-center fj:px-3 fj:py-1 fj:text-xs fj:opacity-60 fj:select-none`,this.footer.setAttribute(`aria-hidden`,`true`),this.positionEl=document.createElement(`span`),this.charsEl=document.createElement(`span`),this.wordsEl=document.createElement(`span`),(this.options.line||this.options.col)&&this.footer.appendChild(this.positionEl),this.options.chars&&this.footer.appendChild(this.charsEl),this.options.words&&this.footer.appendChild(this.wordsEl),e.appendChild(this.footer)}update(e){let t=e.value,n=e.selectionStart??0;if(this.options.line||this.options.col){let e=t.substring(0,n).split(`
|
|
157
|
+
`),r=[];this.options.line&&r.push(this._count(`Ln {n}`,e.length)),this.options.col&&r.push(this._count(`Col {n}`,e[e.length-1].length+1)),this.positionEl.textContent=r.join(`, `)}if(this.options.chars&&(this.charsEl.textContent=this._count(`{n} chars`,t.length)),this.options.words){let e=t.trim()?t.trim().split(/\s+/).length:0;this.wordsEl.textContent=this._count(`{n} words`,e)}}_count(e,t){return this.label(e).replace(`{n}`,t.toLocaleString())}},or=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r)setTimeout(function(){r(e)},0);else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h)d[r]=void 0;else{if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},sr=new class extends or{};function cr(e,t,n){return sr.diff(e,t,n)}function lr(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function ur(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function dr(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function fr(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function pr(e,t){return dr(e,t,``)}function mr(e,t){return fr(e,t,``)}function hr(e,t){return t.slice(0,gr(e,t))}function gr(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function _r(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function vr(e,t){if(t)return br(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function yr(e,t){if(t)return br(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function br(e,t){if(!t)return[yr(e),vr(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=_r(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var xr=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,Sr=RegExp(`[${xr}]+|\\s+|[^${xr}]`,`ug`);new class extends or{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=_r(e,r)}else n=e.match(Sr)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&Cr(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&Cr(n,i,r,null,t.intlSegmenter),e}};function Cr(e,t,n,r,i){if(t&&n){let[a,o]=br(t.value,i),[s,c]=br(n.value,i);if(e){let r=lr(a,s);e.value=fr(e.value,s,r),t.value=pr(t.value,r),n.value=pr(n.value,r)}if(r){let e=ur(o,c);r.value=dr(r.value,c,e),t.value=mr(t.value,e),n.value=mr(n.value,e)}}else if(n){if(e){let e=yr(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=yr(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=yr(r.value,i),[a,o]=br(t.value,i),s=lr(n,a);t.value=pr(t.value,s);let c=ur(pr(n,s),o);t.value=mr(t.value,c),r.value=dr(r.value,n,c),e.value=fr(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=yr(r.value,i),n=hr(vr(t.value,i),e);t.value=mr(t.value,n)}else if(e){let n=hr(vr(e.value,i),yr(t.value,i));t.value=pr(t.value,n)}}new class extends or{tokenize(e){let t=RegExp(`(\\r?\\n)|[${xr}]+|[^\\S\\n\\r]+|[^${xr}]`,`ug`);return e.match(t)||[]}},new class extends or{constructor(){super(...arguments),this.tokenize=wr}equals(e,t,n){return n.ignoreWhitespace?(n.newlineIsToken&&e.includes(`
|
|
158
|
+
`)||(e=e.trim()),n.newlineIsToken&&t.includes(`
|
|
159
|
+
`)||(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
158
160
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
159
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function
|
|
160
|
-
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function
|
|
161
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function wr(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
162
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function Tr(e){return e==`.`||e==`!`||e==`?`}new class extends or{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(Tr(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends or{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends or{constructor(){super(...arguments),this.tokenize=wr}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(Er(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function Er(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a=0;for(;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Er(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=Er(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends or{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};var Dr=class{constructor(e){this.editor=e,this.textarea=e.usertextarea,this.undoStack=[],this.redoStack=[],this.lastValue=this.textarea.value,this.lastSelection={selectionStart:this.textarea.selectionStart,selectionEnd:this.textarea.selectionEnd},this.debounceDelay=1e3,this.maxStackSize=100,this._debounceTimer=null,this._bindEvents()}_bindEvents(){this._keydownHandler=e=>this._onKeyDown(e),this._selectHandler=()=>this._updateLastSelection(),this._mousedownHandler=()=>setTimeout(()=>this._updateLastSelection(),0),this._beforeinputHandler=e=>{e.inputType===`historyUndo`?(e.preventDefault(),this.undo()):e.inputType===`historyRedo`&&(e.preventDefault(),this.redo())},this._inputHandler=e=>this._onInput(e),this._pasteHandler=()=>this._saveState(),this._blurHandler=()=>this._saveState(),this.textarea.addEventListener(`keydown`,this._keydownHandler),this.textarea.addEventListener(`select`,this._selectHandler),this.textarea.addEventListener(`mousedown`,this._mousedownHandler),this.textarea.addEventListener(`beforeinput`,this._beforeinputHandler),this.textarea.addEventListener(`input`,this._inputHandler),this.textarea.addEventListener(`paste`,this._pasteHandler),this.textarea.addEventListener(`blur`,this._blurHandler)}destroy(){clearTimeout(this._debounceTimer),this.textarea.removeEventListener(`keydown`,this._keydownHandler),this.textarea.removeEventListener(`select`,this._selectHandler),this.textarea.removeEventListener(`mousedown`,this._mousedownHandler),this.textarea.removeEventListener(`beforeinput`,this._beforeinputHandler),this.textarea.removeEventListener(`input`,this._inputHandler),this.textarea.removeEventListener(`paste`,this._pasteHandler),this.textarea.removeEventListener(`blur`,this._blurHandler)}_updateLastSelection(){this.lastSelection={selectionStart:this.textarea.selectionStart,selectionEnd:this.textarea.selectionEnd}}_onKeyDown(e){let t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase()===`z`,r=e.key.toLowerCase()===`y`,i=e.shiftKey,a=this.textarea.selectionStart!==this.textarea.selectionEnd,o=e.key===`Backspace`||e.key===`Delete`||e.key===`Enter`;a&&(e.key.length===1||o)&&this._saveState(),(t||o)&&this._saveState(),t&&n&&!i?(e.preventDefault(),this.undo()):t&&(i&&n||!e.metaKey&&r)&&(e.preventDefault(),this.redo())}_onInput(e){clearTimeout(this._debounceTimer);let t=this.textarea.value[this.textarea.selectionStart-1];t&&/[\s.,;:!?()\[\]{}'"`~]/.test(t)?this._saveState():this._debounceTimer=setTimeout(()=>this._saveState(),this.debounceDelay)}_saveState(){let e=this.textarea.value||``;if(e===this.lastValue)return;clearTimeout(this._debounceTimer);let t=cr(this.lastValue,e);this.undoStack.push({diff:t,selection:{...this.lastSelection}}),this.undoStack.length>this.maxStackSize&&this.undoStack.shift(),this.lastValue=e,this._updateLastSelection(),this.redoStack=[]}undo(){if(this.undoStack.length===0)return;let e=this.undoStack.pop(),t=this._revertDiff(this.lastValue,e.diff);this.redoStack.push({diff:e.diff,selection:{selectionStart:this.textarea.selectionStart,selectionEnd:this.textarea.selectionEnd}}),this._restoreState(t,e.selection)}redo(){if(this.redoStack.length===0)return;let e=this.redoStack.pop(),t=this._applyDiff(this.lastValue,e.diff);this.undoStack.push({diff:e.diff,selection:{...this.lastSelection}}),this._restoreState(t,e.selection)}_applyDiff(e,t){let n=``;return t.forEach(e=>{e.removed||(n+=e.value)}),n}_revertDiff(e,t){let n=``;return t.forEach(e=>{e.added||(n+=e.value)}),n}_restoreState(e,t){this.textarea.value=e,this.textarea.setSelectionRange(t.selectionStart,t.selectionEnd),this.lastValue=e,this.lastSelection={...t},this.editor.render&&this.editor.render(),this.editor.notifyChange(),this.textarea.focus()}},Or=class{constructor(e,t){this.editor=e,this.textarea=e.usertextarea,this.renderCallback=t,this.pairs={"{":`}`,"[":`]`,"(":`)`,"<":`>`,'"':`"`,"'":`'`},this.init()}init(){this.textarea.addEventListener(`keydown`,e=>{switch(e.key){case`Tab`:e.preventDefault(),e.shiftKey?this.outdent():this.indent(),this._triggerUpdate();break;case`Enter`:this.autoIndent(e);break;case`Backspace`:this.handleBackspace(e);break;default:this.pairs[e.key]&&this.handlePairs(e)}})}handlePairs(e){let{textarea:t}=this,{selectionStart:n,selectionEnd:r,value:i}=t,a=e.key;if(n===r&&i[n]===a&&Object.values(this.pairs).includes(a)){e.preventDefault();let r=n+1;t.setSelectionRange(r,r);return}let o=a,s=this.pairs[o];if(s){if(n!==r){e.preventDefault();let a=i.substring(n,r);t.value=i.substring(0,n)+o+a+s+i.substring(r),t.setSelectionRange(n+1,r+1),this._triggerUpdate()}else{e.preventDefault();let a=i.substring(0,n),c=i.substring(r);t.value=a+o+s+c,t.setSelectionRange(n+1,n+1),this._triggerUpdate()}}}handleBackspace(e){let{textarea:t}=this,{selectionStart:n,selectionEnd:r,value:i}=t;if(n===r&&n>0){let r=i[n-1],a=i[n];this.pairs[r]===a&&(e.preventDefault(),t.value=i.substring(0,n-1)+i.substring(n+1),t.setSelectionRange(n-1,n-1),this._triggerUpdate())}}autoIndent(e){let{textarea:t}=this,{selectionStart:n,value:r}=t,i=r.lastIndexOf(`
|
|
161
163
|
`,n-1),a=r.substring(i+1,n);if(/^(\s*)([\-\*] |\d+\. )/.test(a))return;let o=(a.match(/^[ \t]*/)||[``])[0],s=r[n-1],c=r[n];if(s===`{`&&c===`}`){e.preventDefault();let i=`
|
|
162
164
|
`+o+`
|
|
163
165
|
`+o;t.value=r.substring(0,n)+i+r.substring(n);let a=n+o.length+1+1;t.setSelectionRange(a,a),this._triggerUpdate()}else if(o.length>0){e.preventDefault();let i=`
|
|
@@ -169,13 +171,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
169
171
|
`,t-1)+1,a=r.indexOf(`
|
|
170
172
|
`,n);a===-1&&(a=r.length);let o=r.substring(i,a).split(`
|
|
171
173
|
`),s=0,c=0,l=o.map((e,t)=>e.startsWith(` `)?(t===0&&(s=1),c++,e.substring(1)):e.startsWith(` `)?(t===0&&(s=4),c+=4,e.substring(4)):e).join(`
|
|
172
|
-
`);this._applyChange(r.substring(0,i)+l+r.substring(a),Math.max(i,t-s),Math.max(i,n-c))}_applyChange(e,t,n){this.textarea.value=e,this.textarea.setSelectionRange(t,n)}},
|
|
174
|
+
`);this._applyChange(r.substring(0,i)+l+r.substring(a),Math.max(i,t-s),Math.max(i,n-c))}_applyChange(e,t,n){this.textarea.value=e,this.textarea.setSelectionRange(t,n)}},kr=class{constructor(e){this.editor=e,this.textarea=e.usertextarea,this._keydownHandler=e=>{e.key===`Enter`&&this.handleEnter(e)},this.textarea.addEventListener(`keydown`,this._keydownHandler)}destroy(){this.textarea.removeEventListener(`keydown`,this._keydownHandler)}handleEnter(e){let{selectionStart:t,value:n}=this.textarea,r=n.lastIndexOf(`
|
|
173
175
|
`,t-1)+1,i=n.substring(r,t),a=i.match(/^(\s*)(\d+)\.\s/),o=i.match(/^(\s*)([\-\*] )\[[\s xX]\] /),s=i.match(/^(\s*)([\-\*] )\s*/);if(i.match(/^(\s*)(\d+\.\s|[\-\*] \[[\s xX]\] |[\-\*]\s)$/)){e.preventDefault();let i=n.substring(0,r),a=n.substring(t);this.textarea.value=i+`
|
|
174
|
-
`+a,this.textarea.setSelectionRange(r+1,r+1),this.editor.render(),this.editor.notifyChange();return}let c=null;if(a?c=`${a[1]}${parseInt(a[2])+1}. `:o?c=`${o[1]}${o[2]}[ ] `:s&&(c=`${s[1]}${s[2]}`),c){e.preventDefault();let r=`\n${c}`,i=n.substring(0,t),a=n.substring(t);this.textarea.value=i+r+a;let o=t+r.length;this.textarea.setSelectionRange(o,o),this.editor.render(),this.editor.notifyChange()}}},
|
|
176
|
+
`+a,this.textarea.setSelectionRange(r+1,r+1),this.editor.render(),this.editor.notifyChange();return}let c=null;if(a?c=`${a[1]}${parseInt(a[2])+1}. `:o?c=`${o[1]}${o[2]}[ ] `:s&&(c=`${s[1]}${s[2]}`),c){e.preventDefault();let r=`\n${c}`,i=n.substring(0,t),a=n.substring(t);this.textarea.value=i+r+a;let o=t+r.length;this.textarea.setSelectionRange(o,o),this.editor.render(),this.editor.notifyChange()}}},Ar=[{key:`b`,ctrl:!0,shift:!1,ToolClass:Mn,label:`Ctrl+B`,btnClass:`bold-btn`},{key:`i`,ctrl:!0,shift:!1,ToolClass:Nn,label:`Ctrl+I`,btnClass:`italic-btn`},{key:`k`,ctrl:!0,shift:!1,ToolClass:zn,label:`Ctrl+K`,btnClass:`link-btn`},{key:"`",ctrl:!0,shift:!1,ToolClass:Jn,label:"Ctrl+`",btnClass:`code-btn`},{key:`s`,ctrl:!0,shift:!0,ToolClass:Pn,label:`Ctrl+Shift+S`,btnClass:`strikethrough-btn`},{key:`l`,ctrl:!0,shift:!1,ToolClass:Fn,label:`Ctrl+L`,btnClass:`ul-btn`}];function jr(e){let t=String(e).split(`+`).map(e=>e.trim().toLowerCase()),n=t.pop();return n?{key:n,ctrl:t.includes(`ctrl`)||t.includes(`cmd`)||t.includes(`meta`),shift:t.includes(`shift`),alt:t.includes(`alt`)}:null}var Mr=class{constructor(e){this.editor=e,this.toolShortcuts=(e.toolbarInstance?.tools??[]).filter(e=>e.shortcut).map(e=>({tool:e,combo:jr(e.shortcut)})).filter(e=>e.combo);let t=(e.toolbarInstance?.tools??[]).find(e=>e instanceof $);this.headingLevels=t?.levels??[1,2,3,4,5,6],this._handler=this._onKeyDown.bind(this),this._docHandler=this._onDocKeyDown.bind(this),e.usertextarea.addEventListener(`keydown`,this._handler),document.addEventListener(`keydown`,this._docHandler),this._updateTooltips()}_onKeyDown(e){let t=e.ctrlKey||e.metaKey,n=e.shiftKey,r=e.key.toLowerCase();if(t&&n&&r===`f`)e.preventDefault(),this.editor.editorContainer.querySelector(`.preview-btn`)?.click();else if(t&&!n&&[`1`,`2`,`3`].includes(e.key)&&this.headingLevels.includes(parseInt(e.key)))e.preventDefault(),new $(this.editor).applyHeading(parseInt(e.key));else{for(let{tool:i,combo:a}of this.toolShortcuts)if(r===a.key&&t===a.ctrl&&n===a.shift&&e.altKey===a.alt){e.preventDefault(),i.applySyntax(e);return}for(let i of Ar)if(r===i.key&&t===i.ctrl&&n===i.shift){e.preventDefault(),new i.ToolClass(this.editor).applySyntax(e);return}}}_onDocKeyDown(e){if(e.key===`F11`){let t=this.editor.editorContainer.contains(document.activeElement),n=this.editor.editorContainer.classList.contains(`is-fullscreen`);(t||n)&&(e.preventDefault(),this.editor.editorContainer.querySelector(`.preview-btn`)?.click())}}_updateTooltips(){for(let{btnClass:e,label:t}of Ar){let n=this.editor.editorContainer.querySelector(`.${e}`);n&&(n.title+=` (${t})`)}let e=this.editor.editorContainer.querySelector(`.heading-btn`),t=this.headingLevels.filter(e=>e<=3);e&&t.length&&(e.title+=` (Ctrl+${t.join(`/`)})`);let n=this.editor.editorContainer.querySelector(`.preview-btn`);n&&(n.title+=` (F11)`);for(let{tool:e}of this.toolShortcuts)e.button&&(e.button.title+=` (${e.shortcut})`)}destroy(){this.editor.usertextarea.removeEventListener(`keydown`,this._handler),document.removeEventListener(`keydown`,this._docHandler)}},Nr=class{constructor(e){this.editor=e,this._matches=[],this._currentIndex=-1,this._caseSensitive=!1,this._panel=null,this._findInput=null,this._replaceInput=null,this._countEl=null,this._replaceRow=null,this._caseSensitiveBtn=null,this._highlightEl=null,this._scrollHandler=null,this._taHandler=this._onTextareaKeyDown.bind(this),e.usertextarea.addEventListener(`keydown`,this._taHandler)}_onTextareaKeyDown(e){let t=e.ctrlKey||e.metaKey;t&&e.key===`f`?(e.preventDefault(),this.open(!1)):t&&e.key===`h`&&(e.preventDefault(),this.open(!0))}open(e=!1){this._panel||this._buildPanel(),this._panel.hidden=!1,e&&(this._replaceRow.hidden=!1),this._findInput.focus(),this._findInput.select();let t=this.editor.usertextarea.value.substring(this.editor.usertextarea.selectionStart,this.editor.usertextarea.selectionEnd);t&&!t.includes(`
|
|
175
177
|
`)&&(this._findInput.value=t),this._scrollHandler||(this._scrollHandler=()=>this._showMatchHighlight(),this.editor.usertextarea.addEventListener(`scroll`,this._scrollHandler)),this._search()}close(){if(!this._panel)return;this._panel.hidden=!0,this._clearMatchHighlight(),this._scrollHandler&&=(this.editor.usertextarea.removeEventListener(`scroll`,this._scrollHandler),null);let e=this.editor.usertextarea;if(this._currentIndex!==-1&&this._matches.length){let{start:t,end:n}=this._matches[this._currentIndex];e.focus(),e.setSelectionRange(t,n)}else e.focus();this._matches=[],this._currentIndex=-1}_buildPanel(){let e=document.createElement(`div`);e.className=`find-replace-panel fj:absolute fj:top-1 fj:right-1 fj:z-20 fj:me-surface fj:me-surface-outline fj:me-surface-rounded fj:p-1.5 fj:flex fj:flex-col fj:gap-1 fj:shadow-lg`,e.setAttribute(`role`,`search`),e.setAttribute(`aria-label`,this.editor.label(`Find and replace`));let t=document.createElement(`div`);t.className=`fj:flex fj:items-center fj:gap-1`,this._findInput=document.createElement(`input`),this._findInput.type=`text`,this._findInput.placeholder=this.editor.label(`Find`),this._findInput.className=`fj:me-input fj:me-input-xs fj:w-36`,this._findInput.setAttribute(`aria-label`,this.editor.label(`Find`)),this._findInput.addEventListener(`input`,()=>this._search()),this._findInput.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.shiftKey?this._prev():this._next()),e.key===`Escape`&&(e.preventDefault(),this.close())}),this._countEl=document.createElement(`span`),this._countEl.className=`fj:text-xs fj:opacity-50 fj:whitespace-nowrap fj:min-w-[3.5rem] fj:text-center fj:select-none`,this._countEl.setAttribute(`aria-live`,`polite`);let n=this._iconBtn(`Previous match`,`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>`);n.addEventListener(`click`,()=>this._prev());let r=this._iconBtn(`Next match`,`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>`);r.addEventListener(`click`,()=>this._next()),this._caseSensitiveBtn=document.createElement(`button`),this._caseSensitiveBtn.type=`button`,this._caseSensitiveBtn.className=`fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost fj:text-xs fj:font-bold`,this._caseSensitiveBtn.textContent=`Aa`,this._caseSensitiveBtn.setAttribute(`aria-label`,this.editor.label(`Match case`)),this._caseSensitiveBtn.setAttribute(`aria-pressed`,`false`),this._caseSensitiveBtn.title=this.editor.label(`Match case`),this._caseSensitiveBtn.addEventListener(`click`,()=>{this._caseSensitive=!this._caseSensitive,this._caseSensitiveBtn.setAttribute(`aria-pressed`,String(this._caseSensitive)),this._caseSensitiveBtn.classList.toggle(`fj:me-btn-active`,this._caseSensitive),this._search()});let i=document.createElement(`button`);i.type=`button`,i.className=`fj:me-btn fj:me-btn-xs fj:me-btn-ghost fj:text-xs fj:px-1.5`,i.textContent=this.editor.label(`Replace`),i.setAttribute(`aria-label`,this.editor.label(`Toggle replace row`)),i.addEventListener(`click`,()=>{this._replaceRow.hidden=!this._replaceRow.hidden,this._replaceRow.hidden||this._replaceInput.focus()});let a=this._iconBtn(`Close`,`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`);a.addEventListener(`click`,()=>this.close()),t.append(this._findInput,this._countEl,n,r,this._caseSensitiveBtn,i,a),this._replaceRow=document.createElement(`div`),this._replaceRow.className=`fj:flex fj:items-center fj:gap-1`,this._replaceRow.hidden=!0,this._replaceInput=document.createElement(`input`),this._replaceInput.type=`text`,this._replaceInput.placeholder=this.editor.label(`Replace`),this._replaceInput.className=`fj:me-input fj:me-input-xs fj:w-36`,this._replaceInput.setAttribute(`aria-label`,this.editor.label(`Replace with`)),this._replaceInput.addEventListener(`keydown`,e=>{e.key===`Enter`&&this._replace(),e.key===`Escape`&&(e.preventDefault(),this.close())});let o=document.createElement(`button`);o.type=`button`,o.className=`fj:me-btn fj:me-btn-xs fj:me-btn-ghost fj:text-xs fj:px-1.5`,o.textContent=this.editor.label(`Replace`),o.addEventListener(`click`,()=>this._replace());let s=document.createElement(`button`);s.type=`button`,s.className=`fj:me-btn fj:me-btn-xs fj:me-btn-ghost fj:text-xs fj:px-1.5`,s.textContent=this.editor.label(`All`),s.setAttribute(`aria-label`,this.editor.label(`Replace all`)),s.addEventListener(`click`,()=>this._replaceAll()),this._replaceRow.append(this._replaceInput,o,s),e.append(t,this._replaceRow),this.editor.markdownEditorDiv.appendChild(e),this._panel=e}_iconBtn(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost`,n.setAttribute(`aria-label`,this.editor.label(e)),n.innerHTML=t;let r=n.querySelector(`svg`);return r&&r.setAttribute(`aria-hidden`,`true`),n}_search(){let e=this._findInput?.value??``,t=this.editor.usertextarea.value;if(!e){this._matches=[],this._currentIndex=-1,this._clearMatchHighlight(),this._updateCount();return}let n=this._caseSensitive?t:t.toLowerCase(),r=this._caseSensitive?e:e.toLowerCase();this._matches=[];let i=0;for(;i<=n.length-r.length;){let t=n.indexOf(r,i);if(t===-1)break;this._matches.push({start:t,end:t+e.length}),i=t+1}this._currentIndex=this._matches.length>0?Math.min(Math.max(this._currentIndex,0),this._matches.length-1):-1,this._selectCurrent(),this._updateCount()}_next(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex+1)%this._matches.length,this._selectCurrent(),this._updateCount())}_prev(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex-1+this._matches.length)%this._matches.length,this._selectCurrent(),this._updateCount())}_selectCurrent(){if(this._currentIndex===-1||this._matches.length===0){this._clearMatchHighlight();return}let{start:e}=this._matches[this._currentIndex];this._scrollToMatch(this.editor.usertextarea,e),this._showMatchHighlight()}_scrollToMatch(e,t){let n=parseInt(window.getComputedStyle(e).lineHeight)||20,r=e.value.substring(0,t).split(`
|
|
176
|
-
`).length-1,i=Math.floor(e.clientHeight/n);e.scrollTop=Math.max(0,(r-Math.floor(i/2))*n)}_showMatchHighlight(){if(this._clearMatchHighlight(),this._currentIndex===-1||!this._matches.length)return;let{start:e,end:t}=this._matches[this._currentIndex],n=this.editor.usertextarea,r=window.getComputedStyle(n),i=n.parentElement,a=document.createElement(`div`);Object.assign(a.style,{position:`absolute`,visibility:`hidden`,pointerEvents:`none`,top:`0`,left:`0`,right:`0`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,overflowWrap:`break-word`,font:r.font,lineHeight:r.lineHeight,paddingTop:r.paddingTop,paddingRight:r.paddingRight,paddingBottom:r.paddingBottom,paddingLeft:r.paddingLeft,boxSizing:`border-box`});let o=document.createElement(`span`);o.textContent=n.value.substring(e,t)||``,a.appendChild(document.createTextNode(n.value.substring(0,e))),a.appendChild(o),a.appendChild(document.createTextNode(n.value.substring(t))),i.appendChild(a);try{let e=i.getBoundingClientRect(),t=o.getBoundingClientRect(),r=document.createElement(`div`);Object.assign(r.style,{position:`absolute`,top:t.top-e.top-n.scrollTop+`px`,left:t.left-e.left+`px`,width:Math.max(t.width,2)+`px`,height:t.height+`px`,background:`color-mix(in oklch, var(--color-primary, oklch(0.6 0.2 250)), transparent 55%)`,borderRadius:`2px`,pointerEvents:`none`,zIndex:`2`}),i.appendChild(r),this._highlightEl=r}finally{i.removeChild(a)}}_clearMatchHighlight(){this._highlightEl?.remove(),this._highlightEl=null}_updateCount(){this._countEl&&(this._matches.length===0?this._countEl.textContent=this._findInput?.value?`No results`:``:this._countEl.textContent=`${this._currentIndex+1} of ${this._matches.length}`)}_replace(){if(this._currentIndex===-1)return;let{start:e,end:t}=this._matches[this._currentIndex],n=this.editor.usertextarea,r=this._replaceInput.value;n.value=n.value.substring(0,e)+r+n.value.substring(t),this.editor.render(),this.editor.notifyChange(),this._search()}_replaceAll(){let e=this._findInput?.value;if(!e)return;let t=this._replaceInput.value,n=this.editor.usertextarea,r=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=this._caseSensitive?`g`:`gi`;n.value=n.value.replace(new RegExp(r,i),t),this.editor.render(),this.editor.notifyChange(),this._currentIndex=0,this._search()}destroy(){this.editor.usertextarea.removeEventListener(`keydown`,this._taHandler),this._scrollHandler&&this.editor.usertextarea.removeEventListener(`scroll`,this._scrollHandler),this._clearMatchHighlight(),this._panel?.remove()}},
|
|
178
|
+
`).length-1,i=Math.floor(e.clientHeight/n);e.scrollTop=Math.max(0,(r-Math.floor(i/2))*n)}_showMatchHighlight(){if(this._clearMatchHighlight(),this._currentIndex===-1||!this._matches.length)return;let{start:e,end:t}=this._matches[this._currentIndex],n=this.editor.usertextarea,r=window.getComputedStyle(n),i=n.parentElement,a=document.createElement(`div`);Object.assign(a.style,{position:`absolute`,visibility:`hidden`,pointerEvents:`none`,top:`0`,left:`0`,right:`0`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,overflowWrap:`break-word`,font:r.font,lineHeight:r.lineHeight,paddingTop:r.paddingTop,paddingRight:r.paddingRight,paddingBottom:r.paddingBottom,paddingLeft:r.paddingLeft,boxSizing:`border-box`});let o=document.createElement(`span`);o.textContent=n.value.substring(e,t)||``,a.appendChild(document.createTextNode(n.value.substring(0,e))),a.appendChild(o),a.appendChild(document.createTextNode(n.value.substring(t))),i.appendChild(a);try{let e=i.getBoundingClientRect(),t=o.getBoundingClientRect(),r=document.createElement(`div`);Object.assign(r.style,{position:`absolute`,top:t.top-e.top-n.scrollTop+`px`,left:t.left-e.left+`px`,width:Math.max(t.width,2)+`px`,height:t.height+`px`,background:`color-mix(in oklch, var(--color-primary, oklch(0.6 0.2 250)), transparent 55%)`,borderRadius:`2px`,pointerEvents:`none`,zIndex:`2`}),i.appendChild(r),this._highlightEl=r}finally{i.removeChild(a)}}_clearMatchHighlight(){this._highlightEl?.remove(),this._highlightEl=null}_updateCount(){this._countEl&&(this._matches.length===0?this._countEl.textContent=this._findInput?.value?`No results`:``:this._countEl.textContent=`${this._currentIndex+1} of ${this._matches.length}`)}_replace(){if(this._currentIndex===-1)return;let{start:e,end:t}=this._matches[this._currentIndex],n=this.editor.usertextarea,r=this._replaceInput.value;n.value=n.value.substring(0,e)+r+n.value.substring(t),this.editor.render(),this.editor.notifyChange(),this._search()}_replaceAll(){let e=this._findInput?.value;if(!e)return;let t=this._replaceInput.value,n=this.editor.usertextarea,r=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=this._caseSensitive?`g`:`gi`;n.value=n.value.replace(new RegExp(r,i),t),this.editor.render(),this.editor.notifyChange(),this._currentIndex=0,this._search()}destroy(){this.editor.usertextarea.removeEventListener(`keydown`,this._taHandler),this._scrollHandler&&this.editor.usertextarea.removeEventListener(`scroll`,this._scrollHandler),this._clearMatchHighlight(),this._panel?.remove()}},Pr=/^https?:\/\/\S+$/i,Fr=class{constructor(e){this.editor=e,this.textarea=e.usertextarea,this._pasteHandler=e=>this._onPaste(e),this._dropHandler=e=>this._onDrop(e),this._dragOverHandler=e=>{this._carriesFiles(e.dataTransfer)&&e.preventDefault()},this.textarea.addEventListener(`paste`,this._pasteHandler),this.textarea.addEventListener(`drop`,this._dropHandler),this.textarea.addEventListener(`dragover`,this._dragOverHandler)}destroy(){this.textarea.removeEventListener(`paste`,this._pasteHandler),this.textarea.removeEventListener(`drop`,this._dropHandler),this.textarea.removeEventListener(`dragover`,this._dragOverHandler)}_carriesFiles(e){return Array.from(e?.types??[]).includes(`Files`)}_imageFiles(e){return Array.from(e?.files??[]).filter(e=>e.type?.startsWith(`image/`))}_onPaste(e){let t=this._imageFiles(e.clipboardData);if(t.length){if(!this.editor.imageUpload){console.warn(`[MarkdownEditor] An image was pasted but no upload endpoint is configured. Add { image: { fileInput: { uploadUrl: "..." } } } to the toolbar to enable it.`);return}e.preventDefault(),this._uploadAll(t);return}let n=e.clipboardData?.getData(`text/plain`)?.trim(),{selectionStart:r,selectionEnd:i}=this.textarea;if(n&&i>r&&Pr.test(n)){e.preventDefault();let t=`[${this.textarea.value.slice(r,i)}](${n})`;this.editor.insertText(t,t.length,0)}}_onDrop(e){if(!this._carriesFiles(e.dataTransfer))return;e.preventDefault();let t=this._imageFiles(e.dataTransfer);t.length&&(this.editor.imageUpload?this._uploadAll(t):console.warn(`[MarkdownEditor] An image was dropped but no upload endpoint is configured. Add { image: { fileInput: { uploadUrl: "..." } } } to the toolbar to enable it.`))}async _uploadAll(e){for(let t of e){let e=`![${this.editor.label(`Uploading...`)}]()`;this.editor.insertText(e,e.length,0);try{let{path:n,alt:r}=await Hn(t,this.editor.imageUpload);this._replace(e,``)}catch(t){this._replace(e,`![${this.editor.label(`Upload failed`)}]()`),console.error(`[MarkdownEditor] Image upload failed.`,t)}}}_replace(e,t){let n=this.textarea,r=n.value.indexOf(e);if(r===-1)return;n.value=n.value.slice(0,r)+t+n.value.slice(r+e.length);let i=r+t.length;n.setSelectionRange(i,i),this.editor.render(),this.editor.notifyChange()}},Ir=new st({breaks:!0}),Lr=class e{constructor(e,t={}){this.usertextarea=typeof e==`string`?document.querySelector(e):e,this.options=t,this.mode=t.mode||`plain`,this.preview=!this.options.toolbar||this.options.toolbar.includes(`preview`),this.footerOptions=this._parseFooterOptions(t.footer),this.variables=this._parseVariables(t.toolbar),this.imageUpload=this._parseImageUpload(t.toolbar),this.previewTimer=null,this.init(),this.undoRedoManager=new Dr(this),this.listManager=new kr(this),this.indentManager=new Or(this),this.shortcutManager=new Mr(this),this.findReplace=new Nr(this),this.pasteManager=new Fr(this),this._warnIfStylesheetMissing(),this._warnIfLocaleIsACode()}_warnIfLocaleIsACode(){let e=this.options.locale;typeof e==`string`&&console.error(`[MarkdownEditor] locale: '${e}' has no effect. It takes the strings, not a code:\n import ${/^[a-z]{2}$/i.test(e)?e:`strings`} from 'markdown-text-editor/locale/${e}.js'\n new MarkdownEditor(el, { locale: ${/^[a-z]{2}$/i.test(e)?e:`strings`} })`)}_warnIfStylesheetMissing(){e._cssWarned||this.editorContainer?.isConnected&&(getComputedStyle(this.editorContainer).getPropertyValue(`--mte-css`).trim()||(e._cssWarned=!0,console.error(`[MarkdownEditor] Stylesheet not loaded, so the editor will look unstyled.
|
|
177
179
|
Bundlers: import 'markdown-text-editor/style.css'
|
|
178
|
-
Browsers: <link rel="stylesheet" href=".../dist/markdown-text-editor.css">`)))}label(e){return(this.options.locale??this.options.labels)?.[e]??e}_parseImageUpload(e){let t=(Array.isArray(e)?e:[]).find(e=>e&&typeof e==`object`&&e.image)?.image?.fileInput;return t?.uploadUrl?t:null}_parseVariables(e){let t=(Array.isArray(e)?e:[]).find(e=>e&&typeof e==`object`&&Array.isArray(e.variables));return t?t.variables:[]}_parseFooterOptions(e){if(e===!1)return null;let t=e??{};return{line:t.line!==!1,col:t.col!==!1,chars:t.chars!==!1,words:t.words===!0}}init(){this.createEditor(),this.addToolbar(),this.addFooter(),this._toolbarH=this.editorContainer.querySelector(`.toolbar`)?.offsetHeight??0,this._footerH=this.editorContainer.querySelector(`.editor-footer`)?.offsetHeight??0,this._autoGrow()}createEditor(){this.isTextareaValid()&&(this.applyDefaultAttributes(),this.buildEditorLayout(),this.addInputListener(),this.render())}isTextareaValid(){return this.usertextarea.tagName===`TEXTAREA`}applyDefaultAttributes(){this.usertextarea.id&&document.querySelector(`label[for="${this.usertextarea.id}"]`)||this.usertextarea.getAttribute(`aria-label`)||this.usertextarea.getAttribute(`aria-labelledby`)||(this.usertextarea.setAttribute(`aria-label`,this.options.label||`Markdown editor`),this._addedAriaLabel=!0),this.usertextarea.classList.add(`editor-textarea`,`fj:focus:ring-0`,`fj:focus:outline-0`,`fj:border-0`,`fj:border-base-soft`,`fj:px-4`,`fj:py-2`,`fj:max-w-full`,`fj:w-full`,`fj:h-full`,`fj:bg-transparent`,`fj:outline-0`,`fj:appearance-none`,`fj:overflow-y-auto`),this.usertextarea.hasAttribute(`placeholder`)||(this.usertextarea.placeholder=this.options.placeholder||`Write your markdown...`)}buildEditorLayout(){this.editorContainer=document.createElement(`div`),this.editorContainer.className=`
|
|
180
|
+
Browsers: <link rel="stylesheet" href=".../dist/markdown-text-editor.css">`)))}label(e){return(this.options.locale??this.options.labels)?.[e]??e}_parseImageUpload(e){let t=(Array.isArray(e)?e:[]).find(e=>e&&typeof e==`object`&&e.image)?.image?.fileInput;return t?.uploadUrl?t:null}_parseVariables(e){let t=(Array.isArray(e)?e:[]).find(e=>e&&typeof e==`object`&&Array.isArray(e.variables));return t?t.variables:[]}_parseFooterOptions(e){if(e===!1)return null;let t=e??{};return{line:t.line!==!1,col:t.col!==!1,chars:t.chars!==!1,words:t.words===!0}}init(){this.createEditor(),this.addToolbar(),this.addFooter(),this._toolbarH=this.editorContainer.querySelector(`.toolbar`)?.offsetHeight??0,this._footerH=this.editorContainer.querySelector(`.editor-footer`)?.offsetHeight??0,this._autoGrow()}createEditor(){this.isTextareaValid()&&(this.applyDefaultAttributes(),this.buildEditorLayout(),this.addInputListener(),this.render())}isTextareaValid(){return this.usertextarea.tagName===`TEXTAREA`}applyDefaultAttributes(){this.usertextarea.id&&document.querySelector(`label[for="${this.usertextarea.id}"]`)||this.usertextarea.getAttribute(`aria-label`)||this.usertextarea.getAttribute(`aria-labelledby`)||(this.usertextarea.setAttribute(`aria-label`,this.options.label||`Markdown editor`),this._addedAriaLabel=!0),this.usertextarea.classList.add(`editor-textarea`,`fj:focus:ring-0`,`fj:focus:outline-0`,`fj:border-0`,`fj:border-base-soft`,`fj:px-4`,`fj:py-2`,`fj:max-w-full`,`fj:w-full`,`fj:h-full`,`fj:bg-transparent`,`fj:outline-0`,`fj:appearance-none`,`fj:overflow-y-auto`,`fj:resize-none`),this.usertextarea.hasAttribute(`placeholder`)||(this.usertextarea.placeholder=this.options.placeholder||`Write your markdown...`)}buildEditorLayout(){this.editorContainer=document.createElement(`div`),this.editorContainer.className=`
|
|
179
181
|
markdown-editor-wrapper
|
|
180
182
|
fj:me-surface
|
|
181
183
|
fj:me-surface-outline
|
|
@@ -213,18 +215,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
213
215
|
`,this.usertextarea.className+=`
|
|
214
216
|
fj:text-transparent
|
|
215
217
|
fj:caret-primary
|
|
216
|
-
fj:resize-none
|
|
217
218
|
fj:outline-none
|
|
218
219
|
fj:m-0
|
|
219
220
|
fj:box-border
|
|
220
221
|
fj:relative
|
|
221
222
|
fj:z-10
|
|
222
|
-
`,e.appendChild(this.displayLayer)),e.appendChild(this.usertextarea),this.markdownEditorDiv.appendChild(e)}addPreviewWrapper(){let e=new
|
|
223
|
+
`,e.appendChild(this.displayLayer)),e.appendChild(this.usertextarea),this.markdownEditorDiv.appendChild(e)}addPreviewWrapper(){let e=new ir(this.markdownEditorDiv);this.previewContent=e.getPreviewContent()}addInputListener(){this._inputHandler=()=>{this._autoGrow(),this.renderHybrid(),this.debouncedPreview(),this.notifyChange()},this._scrollHandler=()=>{this._scrollRaf||=requestAnimationFrame(()=>{if(this._scrollRaf=null,this.mode===`hybrid`&&(this.displayLayer.scrollTop=this.usertextarea.scrollTop,this.displayLayer.scrollLeft=this.usertextarea.scrollLeft),this.preview&&this.previewContent){let e=this.usertextarea,t=e.scrollTop/(e.scrollHeight-e.clientHeight);this.previewContent.scrollTop=t*(this.previewContent.scrollHeight-this.previewContent.clientHeight)}})},this.usertextarea.addEventListener(`input`,this._inputHandler),this.usertextarea.addEventListener(`scroll`,this._scrollHandler)}debouncedPreview(){this.preview&&(clearTimeout(this.previewTimer),this.previewTimer=setTimeout(()=>{this.previewContent.innerHTML=this._renderMarkdown(this.usertextarea.value),this.wirePreviewCheckboxes();let e=this.usertextarea,t=e.scrollTop/(e.scrollHeight-e.clientHeight);this.previewContent.scrollTop=t*(this.previewContent.scrollHeight-this.previewContent.clientHeight)},150))}renderMarkdown(e){return this._renderMarkdown(e)}createToolbar(e,t=[`bold`,`italic`,`strikethrough`]){let n=Object.create(this);return n.usertextarea=e,n.render=()=>{},n.notifyChange=()=>{},n.insertText=(t,n=0,r=0)=>{let{selectionStart:i,selectionEnd:a,value:o}=e,s=e.scrollTop;e.value=o.slice(0,i)+t+o.slice(a),e.focus(),e.setSelectionRange(i+n,i+t.length-r),e.scrollTop=s},new rr(n,t,{standalone:!0}).toolbar}_renderMarkdown(e){let t=this.options.renderer??(e=>Ir.parse(e)),n=this.options.sanitizer??(e=>jn.sanitize(e)),r=$n(e,this.variables),i=t(r);return this.options.renderer&&!this._taskListWarned&&/^\s*[-*] \[[ xX]\] /m.test(r)&&!/type=["']?checkbox/.test(i)&&(this._taskListWarned=!0,console.warn(`[MarkdownEditor] Task list syntax found, but the custom renderer emitted no checkboxes. Clickable checkboxes in the preview need a task-list plugin, e.g. markdown-it-task-lists.`)),n(i)}wirePreviewCheckboxes(){this.previewContent.querySelectorAll(`input[type="checkbox"]`).forEach((e,t)=>{e.removeAttribute(`disabled`),e.addEventListener(`click`,n=>{n.preventDefault();let r=this.usertextarea.value.split(`
|
|
223
224
|
`),i=0;for(let n=0;n<r.length;n++)if(/^(\s*)([-*] \[[ xX]\] )/.test(r[n])){if(i===t){e.checked?r[n]=r[n].replace(/\[ \]/,`[x]`):r[n]=r[n].replace(/\[[xX]\]/,`[ ]`);break}i++}this.usertextarea.value=r.join(`
|
|
224
|
-
`),this.render(),this.notifyChange()})})}addFooter(){if(!this.footerOptions)return;let{line:e,col:t,chars:n,words:r}=this.footerOptions;(e||t||n||r)&&(this.footer=new
|
|
225
|
-
`).length-1,i=Math.floor(e.clientHeight/n);e.scrollTop=(r-Math.floor(i/2))*n}_highlight(e){let t=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);return t=t.replace(/```(\w+)?\n([\s\S]*?)```/g,'<span class="fj:opacity-30">```$1</span>\n$2<span class="fj:opacity-30">```</span>').replace(/`([^`\n]+)`/g,'<span class="fj:opacity-40">`</span><span class="fj:text-accent">$1</span><span class="fj:opacity-40">`</span>').replace(/^(#+ )(.*)$/gm,`<span class="fj:text-primary"><span class="fj:opacity-40">$1</span><span class="faux-bold">$2</span></span>`).replace(/\*\*(.*?)\*\*/g,`<span class="fj:text-secondary"><span class="fj:opacity-40">**</span><span class="faux-bold">$1</span><span class="fj:opacity-40">**</span></span>`).replace(/^([\s]*)([\-\*] |[\d]+\. |\[[\s xX]\] )(.*)$/gm,`$1<span class="fj:text-primary">$2</span>$3`).replace(/(\*|_)(.*?)\1/g,`<span class="fj:text-accent"><span class="fj:opacity-40">$1</span>$2<span class="fj:opacity-40">$1</span></span>`).replace(/~~(.*?)~~/g,`<span class="fj:line-through fj:opacity-70"><span class="fj:opacity-40">~~</span>$1<span class="fj:opacity-40">~~</span></span>`).replace(/(?<!~)(~)([^~]+)\1(?!~)/g,`<span class="fj:line-through fj:opacity-70"><span class="fj:opacity-40">$1</span>$2<span class="fj:opacity-40">$1</span></span>`).replace(/(!?\[)(.*?)(\]\()(.*?)(\))/g,`<span class="fj:opacity-40">$1</span><span class="fj:text-primary">$2</span><span class="fj:opacity-40">$3</span><span class="fj:underline fj:opacity-50">$4</span><span class="fj:opacity-50">$5</span>`),e.endsWith(`
|
|
225
|
+
`),this.render(),this.notifyChange()})})}addFooter(){if(!this.footerOptions)return;let{line:e,col:t,chars:n,words:r}=this.footerOptions;(e||t||n||r)&&(this.footer=new ar(this.editorContainer,this.footerOptions,e=>this.label(e)),this.footer.update(this.usertextarea),this._footerUpdate=()=>this.footer.update(this.usertextarea),this.usertextarea.addEventListener(`input`,this._footerUpdate),this.usertextarea.addEventListener(`click`,this._footerUpdate),this.usertextarea.addEventListener(`keyup`,this._footerUpdate),this.usertextarea.addEventListener(`focus`,this._footerUpdate))}addToolbar(){this.toolbarInstance=new rr(this,this.options.toolbar||[`undo`,`redo`,`heading`,`blockquote`,`ul`,`ol`,`checklist`,`outdent`,`indent`,`bold`,`italic`,`strikethrough`,`code`,`codeblock`,`hr`,`table`,`link`,`image`,`preview`])}insertText(e,t=0,n=0){let{selectionStart:r,selectionEnd:i}=this.usertextarea,a=this.usertextarea.value,o=this.usertextarea.scrollTop;this.usertextarea.value=`${a.substring(0,r)}${e}${a.substring(i)}`,this.usertextarea.focus(),this.usertextarea.setSelectionRange(r+t,r+e.length-n),this.render(),this.notifyChange(),this.restoreScroll(o)}restoreScroll(e){this.usertextarea.scrollTop=e}scrollToView(){}_highlight(e){let t=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);return t=t.replace(/```(\w+)?\n([\s\S]*?)```/g,'<span class="fj:opacity-30">```$1</span>\n$2<span class="fj:opacity-30">```</span>').replace(/`([^`\n]+)`/g,'<span class="fj:opacity-40">`</span><span class="fj:text-accent">$1</span><span class="fj:opacity-40">`</span>').replace(/^(#+ )(.*)$/gm,`<span class="fj:text-primary"><span class="fj:opacity-40">$1</span><span class="faux-bold">$2</span></span>`).replace(/\*\*(.*?)\*\*/g,`<span class="fj:text-secondary"><span class="fj:opacity-40">**</span><span class="faux-bold">$1</span><span class="fj:opacity-40">**</span></span>`).replace(/^([\s]*)([\-\*] |[\d]+\. |\[[\s xX]\] )(.*)$/gm,`$1<span class="fj:text-primary">$2</span>$3`).replace(/(\*|_)(.*?)\1/g,`<span class="fj:text-accent"><span class="fj:opacity-40">$1</span>$2<span class="fj:opacity-40">$1</span></span>`).replace(/~~(.*?)~~/g,`<span class="fj:line-through fj:opacity-70"><span class="fj:opacity-40">~~</span>$1<span class="fj:opacity-40">~~</span></span>`).replace(/(?<!~)(~)([^~]+)\1(?!~)/g,`<span class="fj:line-through fj:opacity-70"><span class="fj:opacity-40">$1</span>$2<span class="fj:opacity-40">$1</span></span>`).replace(/(!?\[)(.*?)(\]\()(.*?)(\))/g,`<span class="fj:opacity-40">$1</span><span class="fj:text-primary">$2</span><span class="fj:opacity-40">$3</span><span class="fj:underline fj:opacity-50">$4</span><span class="fj:opacity-50">$5</span>`),e.endsWith(`
|
|
226
226
|
`)&&(t+=` `),t}renderHybrid(){if(this.mode!==`hybrid`)return;let e=this.usertextarea.value;if(e===this._lastRaw)return;this._lastRaw=e;let t=this._highlight(e).split(`
|
|
227
227
|
`),n=this._lastLines;if(!n||n.length!==t.length)this.displayLayer.innerHTML=``,this._lineNodes=t.map((e,n)=>{let r=document.createElement(`span`);return r.innerHTML=e+(n<t.length-1?`
|
|
228
228
|
`:``),this.displayLayer.appendChild(r),r}),this._lastLines=t.slice();else for(let e=0;e<t.length;e++)t[e]!==n[e]&&(this._lineNodes[e].innerHTML=t[e]+(e<t.length-1?`
|
|
229
|
-
`:``),n[e]=t[e])}_autoGrow(){if(this.editorContainer.classList.contains(`is-fullscreen`))return;let e=this.usertextarea;e.style.height=`1px`;let t=e.scrollHeight;e.style.height=``;let n=this.options.maxHeight??500
|
|
229
|
+
`:``),n[e]=t[e])}_autoGrow(){if(this.editorContainer.classList.contains(`is-fullscreen`)||(this._autoHeight!==void 0&&this.editorContainer.style.height!==this._autoHeight&&(this._userResized=!0),this._userResized))return;let e=this.usertextarea;e.style.height=`1px`;let t=e.scrollHeight;e.style.height=``;let n=this.options.maxHeight??500,r=Math.min(t,n)+this._toolbarH+this._footerH+1;Number.isFinite(r)&&(this._autoHeight=r+`px`,this.editorContainer.style.height=this._autoHeight)}notifyChange(){this.options.onChange&&this.options.onChange(this.usertextarea.value)}render(){this._autoGrow(),this.renderHybrid(),this.preview&&(this.previewContent.innerHTML=this._renderMarkdown(this.usertextarea.value),this.wirePreviewCheckboxes())}destroy(){this.shortcutManager?.destroy(),this.findReplace?.destroy(),this.previewTool?.destroy(),this.undoRedoManager?.destroy(),this.listManager?.destroy(),this.pasteManager?.destroy(),this.toolbarInstance?.destroy(),this._footerUpdate&&(this.usertextarea.removeEventListener(`input`,this._footerUpdate),this.usertextarea.removeEventListener(`click`,this._footerUpdate),this.usertextarea.removeEventListener(`keyup`,this._footerUpdate),this.usertextarea.removeEventListener(`focus`,this._footerUpdate)),this.usertextarea.removeEventListener(`input`,this._inputHandler),this.usertextarea.removeEventListener(`scroll`,this._scrollHandler);let e=this.editorContainer.parentNode;e&&([`editor-textarea`,`fj:focus:ring-0`,`fj:focus:outline-0`,`fj:border-0`,`fj:border-base-soft`,`fj:px-4`,`fj:py-2`,`fj:max-w-full`,`fj:w-full`,`fj:h-full`,`fj:bg-transparent`,`fj:outline-0`,`fj:appearance-none`,`fj:overflow-y-auto`,`fj:text-transparent`,`fj:caret-primary`,`fj:resize-none`,`fj:outline-none`,`fj:m-0`,`fj:box-border`,`fj:relative`,`fj:z-10`].forEach(e=>this.usertextarea.classList.remove(e)),this._addedAriaLabel&&this.usertextarea.removeAttribute(`aria-label`),this.usertextarea.style.height=``,e.insertBefore(this.usertextarea,this.editorContainer),this.editorContainer.remove())}};return Lr.Tool=X,Lr.modal=Rn,Lr})();
|
|
230
230
|
//# sourceMappingURL=markdown-text-editor.min.js.map
|