ai-client-kit
Version:
适用于任意前端框架的 AI 集成套件,支持多模型接入、聊天面板、Function Calling 等。
103 lines • 134 kB
JavaScript
(function(re,Ie){typeof exports=="object"&&typeof module<"u"?Ie(exports):typeof define=="function"&&define.amd?define(["exports"],Ie):(re=typeof globalThis<"u"?globalThis:re||self,Ie(re.AIClientKit={}))})(this,function(re){"use strict";const Ts=["button{outline:0;border:0;display:flex;justify-content:center;align-items:center;cursor:pointer}button.icon{padding:4px}button.text{padding:0 12px;height:28px}button.square{border-radius:6px}button.circle{border-radius:50%}button.primary{background-color:#0000000a}button.plain{background-color:transparent}button.error{background-color:#ff4d4f;color:#fff}button.primary:hover{background-color:#0000000f}button.plain:hover{background-color:#0000000a}button.error:hover{background-color:#ff7875}button[data-action=copy] .copied-text{display:none}button[data-action=copy].copied .copied-text{display:block}button[data-action=copy].copied svg{display:none}",".tooltip{position:relative}.tooltip .tooltip-text{visibility:hidden;opacity:0;background-color:#000000b3;color:#fff;border-radius:4px;padding:4px 8px;position:absolute;z-index:1;white-space:nowrap;font-size:12px;transition:opacity .3s}.tooltip .tooltip-text.top-left{bottom:115%;right:0}.tooltip .tooltip-text.top-right{bottom:115%;left:0}.tooltip .tooltip-text.bottom-left{top:115%;right:0}.tooltip .tooltip-text.bottom-right{top:115%;left:0}.tooltip:hover .tooltip-text{visibility:visible;opacity:1}",".popup{position:absolute;top:0;left:0;width:100%;height:100%;background-color:#00000080;display:none;align-items:flex-end;z-index:1000}.popup .popup-content-container{background-color:#fff;border-radius:8px 8px 0 0;width:100%;position:relative;transform:translateY(100%);transition:transform .3s ease-in-out}.popup.active .popup-content-container{transform:translateY(0)}.popup-header{display:flex;justify-content:space-between;align-items:center;padding:12px}.popup-header button{font-size:20px;width:20px;height:20px}.popup-title{font-size:14px;font-weight:700}.popup-content{height:300px;overflow-y:auto;padding:0 12px}",".alert{position:absolute;left:50%;transform:translate(-50%);background-color:#fff;border-radius:8px;box-shadow:0 6px 16px #00000014,0 3px 6px -4px #0000001f,0 9px 28px 8px #0000000d;z-index:1000;pointer-events:all;padding:9px 12px;animation:slide 3s ease-in-out forwards;font-size:12px;white-space:nowrap}@keyframes slide{0%{top:0;opacity:0}10%{top:50px;opacity:1}75%{top:50px;opacity:1}to{top:0;opacity:0}}","select{border:0;font-size:12px;cursor:pointer;width:100px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}",'.loading-dots{font-weight:700;margin-left:3px}.loading-dots:after{content:"";animation:typing 1.5s infinite}@keyframes typing{0%{content:"."}33%{content:".."}66%{content:"..."}to{content:"."}}',".app-container{height:100%;display:flex;flex-direction:column;background:#fff}.bottom-container{margin:12px}.action-bar{margin-bottom:12px;display:flex;align-items:center;gap:12px}.user-input-container{padding:12px;border-radius:16px;border:1px solid rgba(114,118,139,.16);box-shadow:0 10px 30px #0003}.user-input{border:0;resize:none;width:100%;font-size:14px;line-height:1.5}.button-wrap{display:flex;justify-content:flex-end;align-items:center;gap:12px}.messages-container{flex:1;padding:12px 12px calc(100% - 79px);overflow-x:hidden;overflow-y:auto}.message{max-width:80%;margin-bottom:12px;font-size:14px;line-height:1.5}.content-container{padding:0 14px;border-radius:8px;word-wrap:break-word;overflow-x:auto}.message.user{margin-left:auto}.message.user .content-container{background:#e3f2fd}.message.assistant{margin-right:auto}.message.assistant .content-container{background:#f1f1f1}.button-container{display:flex;margin-top:4px}.button-container button{height:26px;display:flex;align-items:center}.message.user .button-container{justify-content:flex-end}.message.assistant .button-container{justify-content:flex-start}.history-item{padding:10px;border-bottom:1px solid #eee;cursor:pointer;display:flex;justify-content:space-between;align-items:center}.history-item:last-child{border:0}.history-item button{display:none}.history-item:hover button{display:block}.history-item.active{background-color:#f0f0f0;border-left:4px solid #007bff;border-bottom:0}.history-item-container{width:calc(100% - 60px)}.history-time{font-size:12px;color:#666}.history-content{margin-top:5px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.submit-icon,.stop-icon{width:28px;height:28px;display:flex;justify-content:center;align-items:center;background-color:#000;border-radius:50%;color:#fff}.close-icon{transform:translateY(-1px)}","*{box-sizing:border-box}textarea{padding:0}textarea:focus-visible,select:focus-visible{outline:0}.flex{display:flex}.margin-left-auto{margin-left:auto}:host{position:relative}"].join(`
`),an=document.createElement("template");an.innerHTML=`
<style>${Ts}</style>
<div class="app-container">
<div class="messages-container" id="messages-container"></div>
<div class="bottom-container">
<div class="action-bar">
<select id="model-select"></select>
<button class="icon square plain tooltip margin-left-auto" id="create-button" type="button">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 1024 1024"><path d="M597.333 128v85.333H170.667v571.094l75.221-59.094h607.445V426.667h85.334V768A42.667 42.667 0 0 1 896 810.667H275.413L85.333 960V170.667A42.667 42.667 0 0 1 128 128h469.333zm213.334 0V0H896v128h128v85.333H896v128h-85.333v-128h-128V128h128z"/></svg>
<span class="tooltip-text bottom-left">新聊天</span>
</button>
<button class="icon square plain tooltip" id="history-button" type="button">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 1024 1024"><path d="M512 85.333c235.648 0 426.667 191.019 426.667 426.667S747.648 938.667 512 938.667a424.79 424.79 0 0 1-200.875-50.134L85.333 938.667 135.51 712.96A424.79 424.79 0 0 1 85.333 512C85.333 276.352 276.352 85.333 512 85.333zm0 85.334A341.333 341.333 0 0 0 170.667 512c0 56.96 13.909 111.701 40.106 160.683l14.934 27.904-27.99 125.696L323.5 798.379l27.861 14.89A339.413 339.413 0 0 0 512 853.333a341.333 341.333 0 1 0 0-682.666zm42.667 128V512h170.666v85.333h-256V298.667h85.334z"/></svg>
<span class="tooltip-text bottom-left">历史聊天</span>
</button>
</div>
<div class="user-input-container" id="user-input-container">
<textarea class="user-input" id="user-input" placeholder="和我聊天"></textarea>
<div class="button-wrap">
<button class="icon square plain tooltip" id="submit-icon" type="button">
<div class="submit-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"><path d="M9 16V6.414L5.707 9.707a1 1 0 1 1-1.414-1.414l5-5 .076-.068a1 1 0 0 1 1.338.068l5 5 .068.076a1 1 0 0 1-1.406 1.406l-.076-.068L11 6.414V16a1 1 0 1 1-2 0Z"/></svg>
</div>
<span class="tooltip-text top-left">发送 (↵)</span>
</button>
<button style="display: none;" class="icon square plain tooltip" id="stop-icon" type="button">
<div class="stop-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"><path d="M4.5 5.75c0-.69.56-1.25 1.25-1.25h8.5c.69 0 1.25.56 1.25 1.25v8.5c0 .69-.56 1.25-1.25 1.25h-8.5c-.69 0-1.25-.56-1.25-1.25v-8.5Z"/></svg>
</div>
<span class="tooltip-text top-left">停止</span>
</button>
</div>
</div>
</div>
</div>
<div class="popup" id="history-popup">
<div class="popup-content-container">
<div class="popup-header">
<div class="popup-title">历史聊天</div>
<button class="icon circle plain" id="history-popup-close" type="button">
<span class="close-icon">x</span>
</button>
</div>
<div class="popup-content" id="history-popup-content"></div>
</div>
</div>
`;function Pt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ue=Pt();function on(i){ue=i}var Pe={exec:()=>null};function S(i,e=""){let t=typeof i=="string"?i:i.source,s={replace:(n,r)=>{let a=typeof r=="string"?r:r.source;return a=a.replace(H.caret,"$1"),t=t.replace(n,a),s},getRegex:()=>new RegExp(t,e)};return s}var H={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:i=>new RegExp(`^( {0,3}${i})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}#`),htmlBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}<(?:[a-z].*>|!--)`,"i")},ks=/^(?:[ \t]*(?:\n|$))+/,bs=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Rs=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ee=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ss=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Et=/(?:[*+-]|\d{1,9}[.)])/,ln=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,cn=S(ln).replace(/bull/g,Et).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ps=S(ln).replace(/bull/g,Et).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),$t=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Es=/^[^\n]+/,Mt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,$s=S(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Mt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ms=S(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Et).getRegex(),Ue="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",At=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,As=S("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",At).replace("tag",Ue).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),un=S($t).replace("hr",Ee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ue).getRegex(),Os=S(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",un).getRegex(),Ot={blockquote:Os,code:bs,def:$s,fences:Rs,heading:Ss,hr:Ee,html:As,lheading:cn,list:Ms,newline:ks,paragraph:un,table:Pe,text:Es},dn=S("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ue).getRegex(),vs={...Ot,lheading:Ps,table:dn,paragraph:S($t).replace("hr",Ee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",dn).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ue).getRegex()},Ds={...Ot,html:S(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",At).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:Pe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:S($t).replace("hr",Ee).replace("heading",` *#{1,6} *[^
]`).replace("lheading",cn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ns=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,_s=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,fn=/^( {2,}|\\)\n(?!\s*$)/,Cs=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ze=/[\p{P}\p{S}]/u,vt=/[\s\p{P}\p{S}]/u,hn=/[^\s\p{P}\p{S}]/u,Is=S(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,vt).getRegex(),pn=/(?!~)[\p{P}\p{S}]/u,Us=/(?!~)[\s\p{P}\p{S}]/u,zs=/(?:[^\s\p{P}\p{S}]|~)/u,Ls=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,gn=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ys=S(gn,"u").replace(/punct/g,ze).getRegex(),Hs=S(gn,"u").replace(/punct/g,pn).getRegex(),mn="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Ws=S(mn,"gu").replace(/notPunctSpace/g,hn).replace(/punctSpace/g,vt).replace(/punct/g,ze).getRegex(),js=S(mn,"gu").replace(/notPunctSpace/g,zs).replace(/punctSpace/g,Us).replace(/punct/g,pn).getRegex(),Fs=S("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,hn).replace(/punctSpace/g,vt).replace(/punct/g,ze).getRegex(),Bs=S(/\\(punct)/,"gu").replace(/punct/g,ze).getRegex(),Gs=S(/^<(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(),qs=S(At).replace("(?:-->|$)","-->").getRegex(),Vs=S("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",qs).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Le=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Zs=S(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Le).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),yn=S(/^!?\[(label)\]\[(ref)\]/).replace("label",Le).replace("ref",Mt).getRegex(),xn=S(/^!?\[(ref)\](?:\[\])?/).replace("ref",Mt).getRegex(),Ks=S("reflink|nolink(?!\\()","g").replace("reflink",yn).replace("nolink",xn).getRegex(),Dt={_backpedal:Pe,anyPunctuation:Bs,autolink:Gs,blockSkip:Ls,br:fn,code:_s,del:Pe,emStrongLDelim:Ys,emStrongRDelimAst:Ws,emStrongRDelimUnd:Fs,escape:Ns,link:Zs,nolink:xn,punctuation:Is,reflink:yn,reflinkSearch:Ks,tag:Vs,text:Cs,url:Pe},Js={...Dt,link:S(/^!?\[(label)\]\((.*?)\)/).replace("label",Le).getRegex(),reflink:S(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Le).getRegex()},Nt={...Dt,emStrongRDelimAst:js,emStrongLDelim:Hs,url:S(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Qs={...Nt,br:S(fn).replace("{2,}","*").getRegex(),text:S(Nt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ye={normal:Ot,gfm:vs,pedantic:Ds},$e={normal:Dt,gfm:Nt,breaks:Qs,pedantic:Js},Xs={"&":"&","<":"<",">":">",'"':""","'":"'"},wn=i=>Xs[i];function J(i,e){if(e){if(H.escapeTest.test(i))return i.replace(H.escapeReplace,wn)}else if(H.escapeTestNoEncode.test(i))return i.replace(H.escapeReplaceNoEncode,wn);return i}function Tn(i){try{i=encodeURI(i).replace(H.percentDecode,"%")}catch{return null}return i}function kn(i,e){let t=i.replace(H.findPipe,(r,a,o)=>{let l=!1,c=a;for(;--c>=0&&o[c]==="\\";)l=!l;return l?"|":" |"}),s=t.split(H.splitPipe),n=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;n<s.length;n++)s[n]=s[n].trim().replace(H.slashPipe,"|");return s}function Me(i,e,t){let s=i.length;if(s===0)return"";let n=0;for(;n<s&&i.charAt(s-n-1)===e;)n++;return i.slice(0,s-n)}function ei(i,e){if(i.indexOf(e[1])===-1)return-1;let t=0;for(let s=0;s<i.length;s++)if(i[s]==="\\")s++;else if(i[s]===e[0])t++;else if(i[s]===e[1]&&(t--,t<0))return s;return t>0?-2:-1}function bn(i,e,t,s,n){let r=e.href,a=e.title||null,o=i[1].replace(n.other.outputLinkReplace,"$1");s.state.inLink=!0;let l={type:i[0].charAt(0)==="!"?"image":"link",raw:t,href:r,title:a,text:o,tokens:s.inlineTokens(o)};return s.state.inLink=!1,l}function ti(i,e,t){let s=i.match(t.other.indentCodeCompensation);if(s===null)return e;let n=s[1];return e.split(`
`).map(r=>{let a=r.match(t.other.beginningSpace);if(a===null)return r;let[o]=a;return o.length>=n.length?r.slice(n.length):r}).join(`
`)}var He=class{options;rules;lexer;constructor(i){this.options=i||ue}space(i){let e=this.rules.block.newline.exec(i);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(i){let e=this.rules.block.code.exec(i);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Me(t,`
`)}}}fences(i){let e=this.rules.block.fences.exec(i);if(e){let t=e[0],s=ti(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(i){let e=this.rules.block.heading.exec(i);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let s=Me(t,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(t=s.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(i){let e=this.rules.block.hr.exec(i);if(e)return{type:"hr",raw:Me(e[0],`
`)}}blockquote(i){let e=this.rules.block.blockquote.exec(i);if(e){let t=Me(e[0],`
`).split(`
`),s="",n="",r=[];for(;t.length>0;){let a=!1,o=[],l;for(l=0;l<t.length;l++)if(this.rules.other.blockquoteStart.test(t[l]))o.push(t[l]),a=!0;else if(!a)o.push(t[l]);else break;t=t.slice(l);let c=o.join(`
`),u=c.replace(this.rules.other.blockquoteSetextReplace,`
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
${c}`:c,n=n?`${n}
${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,r,!0),this.lexer.state.top=d,t.length===0)break;let g=r.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let y=g,x=y.raw+`
`+t.join(`
`),P=this.blockquote(x);r[r.length-1]=P,s=s.substring(0,s.length-y.raw.length)+P.raw,n=n.substring(0,n.length-y.text.length)+P.text;break}else if(g?.type==="list"){let y=g,x=y.raw+`
`+t.join(`
`),P=this.list(x);r[r.length-1]=P,s=s.substring(0,s.length-g.raw.length)+P.raw,n=n.substring(0,n.length-y.raw.length)+P.raw,t=x.substring(r.at(-1).raw.length).split(`
`);continue}}return{type:"blockquote",raw:s,tokens:r,text:n}}}list(i){let e=this.rules.block.list.exec(i);if(e){let t=e[1].trim(),s=t.length>1,n={type:"list",raw:"",ordered:s,start:s?+t.slice(0,-1):"",loose:!1,items:[]};t=s?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=s?t:"[*+-]");let r=this.rules.other.listItemRegex(t),a=!1;for(;i;){let l=!1,c="",u="";if(!(e=r.exec(i))||this.rules.block.hr.test(i))break;c=e[0],i=i.substring(c.length);let d=e[2].split(`
`,1)[0].replace(this.rules.other.listReplaceTabs,F=>" ".repeat(3*F.length)),g=i.split(`
`,1)[0],y=!d.trim(),x=0;if(this.options.pedantic?(x=2,u=d.trimStart()):y?x=e[1].length+1:(x=e[2].search(this.rules.other.nonSpaceChar),x=x>4?1:x,u=d.slice(x),x+=e[1].length),y&&this.rules.other.blankLine.test(g)&&(c+=g+`
`,i=i.substring(g.length+1),l=!0),!l){let F=this.rules.other.nextBulletRegex(x),C=this.rules.other.hrRegex(x),T=this.rules.other.fencesBeginRegex(x),Ne=this.rules.other.headingBeginRegex(x),he=this.rules.other.htmlBeginRegex(x);for(;i;){let K=i.split(`
`,1)[0],le;if(g=K,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),le=g):le=g.replace(this.rules.other.tabCharGlobal," "),T.test(g)||Ne.test(g)||he.test(g)||F.test(g)||C.test(g))break;if(le.search(this.rules.other.nonSpaceChar)>=x||!g.trim())u+=`
`+le.slice(x);else{if(y||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||T.test(d)||Ne.test(d)||C.test(d))break;u+=`
`+g}!y&&!g.trim()&&(y=!0),c+=K+`
`,i=i.substring(K.length+1),d=le.slice(x)}}n.loose||(a?n.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0));let P=null,A;this.options.gfm&&(P=this.rules.other.listIsTask.exec(u),P&&(A=P[0]!=="[ ] ",u=u.replace(this.rules.other.listReplaceTask,""))),n.items.push({type:"list_item",raw:c,task:!!P,checked:A,loose:!1,text:u,tokens:[]}),n.raw+=c}let o=n.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let l=0;l<n.items.length;l++)if(this.lexer.state.top=!1,n.items[l].tokens=this.lexer.blockTokens(n.items[l].text,[]),!n.loose){let c=n.items[l].tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));n.loose=u}if(n.loose)for(let l=0;l<n.items.length;l++)n.items[l].loose=!0;return n}}html(i){let e=this.rules.block.html.exec(i);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(i){let e=this.rules.block.def.exec(i);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:s,title:n}}}table(i){let e=this.rules.block.table.exec(i);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=kn(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
`):[],r={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?r.align.push("right"):this.rules.other.tableAlignCenter.test(a)?r.align.push("center"):this.rules.other.tableAlignLeft.test(a)?r.align.push("left"):r.align.push(null);for(let a=0;a<t.length;a++)r.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:r.align[a]});for(let a of n)r.rows.push(kn(a,r.header.length).map((o,l)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:r.align[l]})));return r}}lheading(i){let e=this.rules.block.lheading.exec(i);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(i){let e=this.rules.block.paragraph.exec(i);if(e){let t=e[1].charAt(e[1].length-1)===`
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(i){let e=this.rules.block.text.exec(i);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(i){let e=this.rules.inline.escape.exec(i);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(i){let e=this.rules.inline.tag.exec(i);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(i){let e=this.rules.inline.link.exec(i);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let r=Me(t.slice(0,-1),"\\");if((t.length-r.length)%2===0)return}else{let r=ei(e[2],"()");if(r===-2)return;if(r>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+r;e[2]=e[2].substring(0,r),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let s=e[2],n="";if(this.options.pedantic){let r=this.rules.other.pedanticHrefTitle.exec(s);r&&(s=r[1],n=r[3])}else n=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?s=s.slice(1):s=s.slice(1,-1)),bn(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(i,e){let t;if((t=this.rules.inline.reflink.exec(i))||(t=this.rules.inline.nolink.exec(i))){let s=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[s.toLowerCase()];if(!n){let r=t[0].charAt(0);return{type:"text",raw:r,text:r}}return bn(t,n,t[0],this.lexer,this.rules)}}emStrong(i,e,t=""){let s=this.rules.inline.emStrongLDelim.exec(i);if(!(!s||s[3]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!t||this.rules.inline.punctuation.exec(t))){let n=[...s[0]].length-1,r,a,o=n,l=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*i.length+n);(s=c.exec(e))!=null;){if(r=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!r)continue;if(a=[...r].length,s[3]||s[4]){o+=a;continue}else if((s[5]||s[6])&&n%3&&!((n+a)%3)){l+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+l);let u=[...s[0]][0].length,d=i.slice(0,n+s.index+u+a);if(Math.min(n,a)%2){let y=d.slice(1,-1);return{type:"em",raw:d,text:y,tokens:this.lexer.inlineTokens(y)}}let g=d.slice(2,-2);return{type:"strong",raw:d,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(i){let e=this.rules.inline.code.exec(i);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(t),n=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return s&&n&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(i){let e=this.rules.inline.br.exec(i);if(e)return{type:"br",raw:e[0]}}del(i){let e=this.rules.inline.del.exec(i);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(i){let e=this.rules.inline.autolink.exec(i);if(e){let t,s;return e[2]==="@"?(t=e[1],s="mailto:"+t):(t=e[1],s=t),{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}url(i){let e;if(e=this.rules.inline.url.exec(i)){let t,s;if(e[2]==="@")t=e[0],s="mailto:"+t;else{let n;do n=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(n!==e[0]);t=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(i){let e=this.rules.inline.text.exec(i);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},ee=class sn{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ue,this.options.tokenizer=this.options.tokenizer||new He,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:H,block:Ye.normal,inline:$e.normal};this.options.pedantic?(t.block=Ye.pedantic,t.inline=$e.pedantic):this.options.gfm&&(t.block=Ye.gfm,this.options.breaks?t.inline=$e.breaks:t.inline=$e.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ye,inline:$e}}static lex(e,t){return new sn(t).lex(e)}static lexInline(e,t){return new sn(t).inlineTokens(e)}lex(e){e=e.replace(H.carriageReturn,`
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let s=this.inlineQueue[t];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){for(this.options.pedantic&&(e=e.replace(H.tabCharGlobal," ").replace(H.spaceLine,""));e;){let n;if(this.options.extensions?.block?.some(a=>(n=a.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))continue;if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length);let a=t.at(-1);n.raw.length===1&&a!==void 0?a.raw+=`
`:t.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=`
`+n.raw,a.text+=`
`+n.text,this.inlineQueue.at(-1).src=a.text):t.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=`
`+n.raw,a.text+=`
`+n.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),t.push(n);continue}let r=e;if(this.options.extensions?.startBlock){let a=1/0,o=e.slice(1),l;this.options.extensions.startBlock.forEach(c=>{l=c.call({lexer:this},o),typeof l=="number"&&l>=0&&(a=Math.min(a,l))}),a<1/0&&a>=0&&(r=e.substring(0,a+1))}if(this.state.top&&(n=this.tokenizer.paragraph(r))){let a=t.at(-1);s&&a?.type==="paragraph"?(a.raw+=`
`+n.raw,a.text+=`
`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(n),s=r.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length);let a=t.at(-1);a?.type==="text"?(a.raw+=`
`+n.raw,a.text+=`
`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(n);continue}if(e){let a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let s=e,n=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)o.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,n.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(n=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let r=!1,a="";for(;e;){r||(a=""),r=!1;let o;if(this.options.extensions?.inline?.some(c=>(o=c.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(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 c=t.at(-1);o.type==="text"&&c?.type==="text"?(c.raw+=o.raw,c.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,s,a)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let l=e;if(this.options.extensions?.startInline){let c=1/0,u=e.slice(1),d;this.options.extensions.startInline.forEach(g=>{d=g.call({lexer:this},u),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(l=e.substring(0,c+1))}if(o=this.tokenizer.inlineText(l)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(a=o.raw.slice(-1)),r=!0;let c=t.at(-1);c?.type==="text"?(c.raw+=o.raw,c.text+=o.text):t.push(o);continue}if(e){let c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return t}},We=class{options;parser;constructor(i){this.options=i||ue}space(i){return""}code({text:i,lang:e,escaped:t}){let s=(e||"").match(H.notSpaceStart)?.[0],n=i.replace(H.endingNewline,"")+`
`;return s?'<pre><code class="language-'+J(s)+'">'+(t?n:J(n,!0))+`</code></pre>
`:"<pre><code>"+(t?n:J(n,!0))+`</code></pre>
`}blockquote({tokens:i}){return`<blockquote>
${this.parser.parse(i)}</blockquote>
`}html({text:i}){return i}heading({tokens:i,depth:e}){return`<h${e}>${this.parser.parseInline(i)}</h${e}>
`}hr(i){return`<hr>
`}list(i){let e=i.ordered,t=i.start,s="";for(let a=0;a<i.items.length;a++){let o=i.items[a];s+=this.listitem(o)}let n=e?"ol":"ul",r=e&&t!==1?' start="'+t+'"':"";return"<"+n+r+`>
`+s+"</"+n+`>
`}listitem(i){let e="";if(i.task){let t=this.checkbox({checked:!!i.checked});i.loose?i.tokens[0]?.type==="paragraph"?(i.tokens[0].text=t+" "+i.tokens[0].text,i.tokens[0].tokens&&i.tokens[0].tokens.length>0&&i.tokens[0].tokens[0].type==="text"&&(i.tokens[0].tokens[0].text=t+" "+J(i.tokens[0].tokens[0].text),i.tokens[0].tokens[0].escaped=!0)):i.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:!0}):e+=t+" "}return e+=this.parser.parse(i.tokens,!!i.loose),`<li>${e}</li>
`}checkbox({checked:i}){return"<input "+(i?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:i}){return`<p>${this.parser.parseInline(i)}</p>
`}table(i){let e="",t="";for(let n=0;n<i.header.length;n++)t+=this.tablecell(i.header[n]);e+=this.tablerow({text:t});let s="";for(let n=0;n<i.rows.length;n++){let r=i.rows[n];t="";for(let a=0;a<r.length;a++)t+=this.tablecell(r[a]);s+=this.tablerow({text:t})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
<thead>
`+e+`</thead>
`+s+`</table>
`}tablerow({text:i}){return`<tr>
${i}</tr>
`}tablecell(i){let e=this.parser.parseInline(i.tokens),t=i.header?"th":"td";return(i.align?`<${t} align="${i.align}">`:`<${t}>`)+e+`</${t}>
`}strong({tokens:i}){return`<strong>${this.parser.parseInline(i)}</strong>`}em({tokens:i}){return`<em>${this.parser.parseInline(i)}</em>`}codespan({text:i}){return`<code>${J(i,!0)}</code>`}br(i){return"<br>"}del({tokens:i}){return`<del>${this.parser.parseInline(i)}</del>`}link({href:i,title:e,tokens:t}){let s=this.parser.parseInline(t),n=Tn(i);if(n===null)return s;i=n;let r='<a href="'+i+'"';return e&&(r+=' title="'+J(e)+'"'),r+=">"+s+"</a>",r}image({href:i,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));let n=Tn(i);if(n===null)return J(t);i=n;let r=`<img src="${i}" alt="${t}"`;return e&&(r+=` title="${J(e)}"`),r+=">",r}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:J(i.text)}},_t=class{strong({text:i}){return i}em({text:i}){return i}codespan({text:i}){return i}del({text:i}){return i}html({text:i}){return i}text({text:i}){return i}link({text:i}){return""+i}image({text:i}){return""+i}br(){return""}},te=class rn{options;renderer;textRenderer;constructor(e){this.options=e||ue,this.options.renderer=this.options.renderer||new We,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new _t}static parse(e,t){return new rn(t).parse(e)}static parseInline(e,t){return new rn(t).parseInline(e)}parse(e,t=!0){let s="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let o=r,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){s+=l||"";continue}}let a=r;switch(a.type){case"space":{s+=this.renderer.space(a);continue}case"hr":{s+=this.renderer.hr(a);continue}case"heading":{s+=this.renderer.heading(a);continue}case"code":{s+=this.renderer.code(a);continue}case"table":{s+=this.renderer.table(a);continue}case"blockquote":{s+=this.renderer.blockquote(a);continue}case"list":{s+=this.renderer.list(a);continue}case"html":{s+=this.renderer.html(a);continue}case"paragraph":{s+=this.renderer.paragraph(a);continue}case"text":{let o=a,l=this.renderer.text(o);for(;n+1<e.length&&e[n+1].type==="text";)o=e[++n],l+=`
`+this.renderer.text(o);t?s+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l,escaped:!0}]}):s+=l;continue}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return s}parseInline(e,t=this.renderer){let s="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let o=this.options.extensions.renderers[r.type].call({parser:this},r);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){s+=o||"";continue}}let a=r;switch(a.type){case"escape":{s+=t.text(a);break}case"html":{s+=t.html(a);break}case"link":{s+=t.link(a);break}case"image":{s+=t.image(a);break}case"strong":{s+=t.strong(a);break}case"em":{s+=t.em(a);break}case"codespan":{s+=t.codespan(a);break}case"br":{s+=t.br(a);break}case"del":{s+=t.del(a);break}case"text":{s+=t.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return s}},je=class{options;block;constructor(i){this.options=i||ue}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(i){return i}postprocess(i){return i}processAllTokens(i){return i}provideLexer(){return this.block?ee.lex:ee.lexInline}provideParser(){return this.block?te.parse:te.parseInline}},ni=class{defaults=Pt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=te;Renderer=We;TextRenderer=_t;Lexer=ee;Tokenizer=He;Hooks=je;constructor(...i){this.use(...i)}walkTokens(i,e){let t=[];for(let s of i)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let n=s;for(let r of n.header)t=t.concat(this.walkTokens(r.tokens,e));for(let r of n.rows)for(let a of r)t=t.concat(this.walkTokens(a.tokens,e));break}case"list":{let n=s;t=t.concat(this.walkTokens(n.items,e));break}default:{let n=s;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(r=>{let a=n[r].flat(1/0);t=t.concat(this.walkTokens(a,e))}):n.tokens&&(t=t.concat(this.walkTokens(n.tokens,e)))}}return t}use(...i){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return i.forEach(t=>{let s={...t};if(s.async=this.defaults.async||s.async||!1,t.extensions&&(t.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let r=e.renderers[n.name];r?e.renderers[n.name]=function(...a){let o=n.renderer.apply(this,a);return o===!1&&(o=r.apply(this,a)),o}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let r=e[n.level];r?r.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),s.extensions=e),t.renderer){let n=this.defaults.renderer||new We(this.defaults);for(let r in t.renderer){if(!(r in n))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let a=r,o=t.renderer[a],l=n[a];n[a]=(...c)=>{let u=o.apply(n,c);return u===!1&&(u=l.apply(n,c)),u||""}}s.renderer=n}if(t.tokenizer){let n=this.defaults.tokenizer||new He(this.defaults);for(let r in t.tokenizer){if(!(r in n))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let a=r,o=t.tokenizer[a],l=n[a];n[a]=(...c)=>{let u=o.apply(n,c);return u===!1&&(u=l.apply(n,c)),u}}s.tokenizer=n}if(t.hooks){let n=this.defaults.hooks||new je;for(let r in t.hooks){if(!(r in n))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let a=r,o=t.hooks[a],l=n[a];je.passThroughHooks.has(r)?n[a]=c=>{if(this.defaults.async)return Promise.resolve(o.call(n,c)).then(d=>l.call(n,d));let u=o.call(n,c);return l.call(n,u)}:n[a]=(...c)=>{let u=o.apply(n,c);return u===!1&&(u=l.apply(n,c)),u}}s.hooks=n}if(t.walkTokens){let n=this.defaults.walkTokens,r=t.walkTokens;s.walkTokens=function(a){let o=[];return o.push(r.call(this,a)),n&&(o=o.concat(n.call(this,a))),o}}this.defaults={...this.defaults,...s}}),this}setOptions(i){return this.defaults={...this.defaults,...i},this}lexer(i,e){return ee.lex(i,e??this.defaults)}parser(i,e){return te.parse(i,e??this.defaults)}parseMarkdown(i){return(e,t)=>{let s={...t},n={...this.defaults,...s},r=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&s.async===!1)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return r(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));n.hooks&&(n.hooks.options=n,n.hooks.block=i);let a=n.hooks?n.hooks.provideLexer():i?ee.lex:ee.lexInline,o=n.hooks?n.hooks.provideParser():i?te.parse:te.parseInline;if(n.async)return Promise.resolve(n.hooks?n.hooks.preprocess(e):e).then(l=>a(l,n)).then(l=>n.hooks?n.hooks.processAllTokens(l):l).then(l=>n.walkTokens?Promise.all(this.walkTokens(l,n.walkTokens)).then(()=>l):l).then(l=>o(l,n)).then(l=>n.hooks?n.hooks.postprocess(l):l).catch(r);try{n.hooks&&(e=n.hooks.preprocess(e));let l=a(e,n);n.hooks&&(l=n.hooks.processAllTokens(l)),n.walkTokens&&this.walkTokens(l,n.walkTokens);let c=o(l,n);return n.hooks&&(c=n.hooks.postprocess(c)),c}catch(l){return r(l)}}}onError(i,e){return t=>{if(t.message+=`
Please report this to https://github.com/markedjs/marked.`,i){let s="<p>An error occurred:</p><pre>"+J(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},de=new ni;function E(i,e){return de.parse(i,e)}E.options=E.setOptions=function(i){return de.setOptions(i),E.defaults=de.defaults,on(E.defaults),E},E.getDefaults=Pt,E.defaults=ue,E.use=function(...i){return de.use(...i),E.defaults=de.defaults,on(E.defaults),E},E.walkTokens=function(i,e){return de.walkTokens(i,e)},E.parseInline=de.parseInline,E.Parser=te,E.parser=te.parse,E.Renderer=We,E.TextRenderer=_t,E.Lexer=ee,E.lexer=ee.lex,E.Tokenizer=He,E.Hooks=je,E.parse=E,E.options,E.setOptions,E.use,E.walkTokens,E.parseInline,te.parse,ee.lex;function Rn(i,e={}){const{content:t,model:s}=i,{showLoadingDots:n=!1}=e,r=ri(t),a=n?ii(r):r;return s?`<p>${s}</p>${a}`:a}const si='<p class="loading-dots"></p>';function ii(i){return i+si}function ri(i){return E.parse(i)}class ai{#t=null;#e=[];constructor(){const e=localStorage.getItem("activeOption");if(!e)return;const t=JSON.parse(e);this.#t=t}init(e){this.#e=e;const t=this.#t;t&&this.#e.some(s=>s.model===t.model)||(this.activeOption=this.#e[0])}get activeOption(){return this.#t}set activeOption(e){this.#t=e,localStorage.setItem("activeOption",JSON.stringify(e))}get options(){return this.#e}updateActiveOption(e){const t=this.#e.find(s=>s.model===e);t?this.activeOption=t:(Ge.show("未找到对应的选项,自动选择第一个"),this.activeOption=this.#e[0],Pn.select(this.activeOption))}}const me=new ai;function Ct(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Fe={exports:{}},oi=Fe.exports,Sn;function li(){return Sn||(Sn=1,function(i,e){(function(t,s){i.exports=s()})(oi,function(){var t=1e3,s=6e4,n=36e5,r="millisecond",a="second",o="minute",l="hour",c="day",u="week",d="month",g="quarter",y="year",x="date",P="Invalid Date",A=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,F=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,C={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(w){var p=["th","st","nd","rd"],f=w%100;return"["+w+(p[(f-20)%10]||p[f]||p[0])+"]"}},T=function(w,p,f){var m=String(w);return!m||m.length>=p?w:""+Array(p+1-m.length).join(f)+w},Ne={s:T,z:function(w){var p=-w.utcOffset(),f=Math.abs(p),m=Math.floor(f/60),h=f%60;return(p<=0?"+":"-")+T(m,2,"0")+":"+T(h,2,"0")},m:function w(p,f){if(p.date()<f.date())return-w(f,p);var m=12*(f.year()-p.year())+(f.month()-p.month()),h=p.clone().add(m,d),k=f-h<0,b=p.clone().add(m+(k?-1:1),d);return+(-(m+(f-h)/(k?h-b:b-h))||0)},a:function(w){return w<0?Math.ceil(w)||0:Math.floor(w)},p:function(w){return{M:d,y,w:u,d:c,D:x,h:l,m:o,s:a,ms:r,Q:g}[w]||String(w||"").toLowerCase().replace(/s$/,"")},u:function(w){return w===void 0}},he="en",K={};K[he]=C;var le="$isDayjsObject",nn=function(w){return w instanceof Rt||!(!w||!w[le])},bt=function w(p,f,m){var h;if(!p)return he;if(typeof p=="string"){var k=p.toLowerCase();K[k]&&(h=k),f&&(K[k]=f,h=k);var b=p.split("-");if(!h&&b.length>1)return w(b[0])}else{var v=p.name;K[v]=p,h=v}return!m&&h&&(he=h),h||!m&&he},U=function(w,p){if(nn(w))return w.clone();var f=typeof p=="object"?p:{};return f.date=w,f.args=arguments,new Rt(f)},M=Ne;M.l=bt,M.i=nn,M.w=function(w,p){return U(w,{locale:p.$L,utc:p.$u,x:p.$x,$offset:p.$offset})};var Rt=function(){function w(f){this.$L=bt(f.locale,null,!0),this.parse(f),this.$x=this.$x||f.x||{},this[le]=!0}var p=w.prototype;return p.parse=function(f){this.$d=function(m){var h=m.date,k=m.utc;if(h===null)return new Date(NaN);if(M.u(h))return new Date;if(h instanceof Date)return new Date(h);