!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Artalk=t()}(this,(function(){"use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(t,n,i)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,o=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&a(e,n,t[n]);if(i)for(var n of i(t))r.call(t,n)&&a(e,n,t[n]);return e},l=(e,i)=>t(e,n(i)),c=(e,t,n)=>(a(e,"symbol"!=typeof t?t+"":t,n),n),d=(e,t,n)=>new Promise(((i,s)=>{var r=e=>{try{o(n.next(e))}catch(t){s(t)}},a=e=>{try{o(n.throw(e))}catch(t){s(t)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(r,a);o((n=n.apply(e,t)).next())}));function h(e=""){const t=document.createElement("div");return t.innerHTML=e.trim(),t.firstElementChild||t}function u(e){return parseFloat(getComputedStyle(e,null).height.replace("px",""))}function p(e){const t=RegExp(`[?&]${e}=([^&]*)`).exec(window.location.search);return t&&decodeURIComponent(t[1].replace(/\+/g," "))}function g(e){const t=e.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX}}function m(e,t){let n=e.toString();for(;n.length=13?e.replace(/Windows NT 10.0/,"Windows NT 11.0"):"macOS"===t.platform&&i>=11?e.replace(/(Mac OS X \d+_\d+_\d+|Mac OS X)/,`Mac OS X ${n.platformVersion.replace(/\./g,"_")}`):e}))}function y(e){let t;try{t=new URL(e)}catch(n){return!1}return"http:"===t.protocol||"https:"===t.protocol}function $(e,t){return function(e,t){return`${e.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}(e.conf.server,t)}function x(e,t){const n=e=>e&&"object"==typeof e;return n(e)&&n(t)?(Object.keys(t).forEach((i=>{const s=e[i],r=t[i];Array.isArray(s)&&Array.isArray(r)?e[i]=s.concat(r):n(s)&&n(r)?e[i]=x(o({},s),r):e[i]=r})),e):t}class v{constructor(e){c(this,"$el"),c(this,"ctx"),c(this,"conf"),this.ctx=e,this.conf=e.conf}$t(e,t={}){return this.ctx.$t(e,t)}}function b(e,t){let n=e.querySelector(":scope > .atk-loading");n||(n=h(''),(null==t?void 0:t.transparentBg)&&(n.style.background="transparent"),e.appendChild(n)),n.style.display="";const i=n.querySelector(".atk-loading-spinner");i&&(i.style.display="none",window.setTimeout((()=>{i.style.display=""}),500))}function w(e){const t=e.querySelector(":scope > .atk-loading");t&&(t.style.display="none")}function C(e,t=!0){const n=g(e).top+u(e)/2-document.documentElement.clientHeight/2;t?window.scroll({top:n>0?n:0,left:0}):window.scroll(0,n>0?n:0)}function S(e,t,n){const i=h(`
`);i.querySelector(".atk-notify-content").innerHTML=function(e){const t=document.createElement("div");return t.innerText=e,t.innerHTML}(t).replace("\n","
"),e.appendChild(i);const s=()=>{i.classList.add("atk-fade-out"),setTimeout((()=>{i.remove()}),200)};let r;r=window.setTimeout((()=>{s()}),3e3),i.addEventListener("click",(()=>{s(),window.clearTimeout(r)}))}function T(e,t){!function(e,t,n="in"){e.classList.add(`atk-fade-${n}`);const i=()=>{e.classList.remove(`atk-fade-${n}`),e.removeEventListener("animationend",i),t&&t()};e.addEventListener("animationend",i)}(e,t,"in")}function E(e,t,n='Artalk Error'){let i=e.querySelector(".atk-error-layer");if(null===t)return void(null!==i&&i.remove());i||(i=h(`
${n}
`),e.appendChild(i));const s=i.querySelector(".atk-error-text");s.innerHTML="",null!==t&&(t instanceof HTMLElement?s.appendChild(t):s.innerText=t)}const L=class extends v{constructor(e,t,n){super(e),c(this,"name"),c(this,"$wrap"),c(this,"$mask"),c(this,"maskClickHideEnable",!0),c(this,"afterHide"),this.name=t;const{$wrap:i,$mask:s}=A();this.$wrap=i,this.$mask=s,this.$el=this.$wrap.querySelector(`[data-layer-name="${t}"].atk-layer-item`),null===this.$el&&(n?this.$el=n:(this.$el=h(),this.$el.classList.add("atk-layer-item"))),this.$el.setAttribute("data-layer-name",t),this.$el.style.display="none",this.$wrap.append(this.$el)}getName(){return this.name}getWrapEl(){return this.$wrap}getEl(){return this.$el}show(){this.fireAllActionTimer(),this.$wrap.style.display="block",this.$mask.style.display="block",this.$mask.classList.add("atk-fade-in"),this.$el.style.display="",this.$mask.onclick=()=>{this.maskClickHideEnable&&this.hide()},this.pageBodyScrollBarHide()}hide(){this.afterHide&&this.afterHide(),this.$wrap.classList.add("atk-fade-out"),this.$el.style.display="none",this.pageBodyScrollBarShow(),this.newActionTimer((()=>{this.$wrap.style.display="none",this.checkCleanLayer()}),450),this.newActionTimer((()=>{this.$wrap.style.display="none",this.$wrap.classList.remove("atk-fade-out")}),200)}setMaskClickHide(e){this.maskClickHideEnable=e}pageBodyScrollBarHide(){document.body.style.overflow="hidden";const e=parseInt(window.getComputedStyle(document.body,null).getPropertyValue("padding-right"),10);document.body.style.paddingRight=`${function(){const e=document.createElement("p");e.style.width="100%",e.style.height="200px";const t=document.createElement("div");t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.visibility="hidden",t.style.width="200px",t.style.height="150px",t.style.overflow="hidden",t.appendChild(e),document.body.appendChild(t);const n=e.offsetWidth;t.style.overflow="scroll";let i=e.offsetWidth;return n===i&&(i=t.clientWidth),document.body.removeChild(t),n-i}()+e||0}px`}pageBodyScrollBarShow(){document.body.style.overflow=L.BodyOrgOverflow,document.body.style.paddingRight=L.BodyOrgPaddingRight}newActionTimer(e,t){const n=()=>{e(),L.actionTimers=L.actionTimers.filter((e=>e.act!==n))},i=window.setTimeout((()=>n()),t);L.actionTimers.push({act:n,tid:i})}fireAllActionTimer(){L.actionTimers.forEach((e=>{clearTimeout(e.tid),e.act()}))}disposeNow(){this.$el.remove(),this.pageBodyScrollBarShow(),this.checkCleanLayer()}dispose(){this.hide(),this.$el.remove(),this.checkCleanLayer()}checkCleanLayer(){0===this.getWrapEl().querySelectorAll(".atk-layer-item").length&&(this.$wrap.style.display="none")}};let _=L;function A(){let e=document.querySelector(".atk-layer-wrap");e||(e=h(''),document.body.appendChild(e));const t=e.querySelector(".atk-layer-mask");return{$wrap:e,$mask:t}}c(_,"BodyOrgOverflow"),c(_,"BodyOrgPaddingRight"),c(_,"actionTimers",[]);const O=window.matchMedia("(prefers-color-scheme: dark)");let M;function R(e){B(e,e.conf.darkMode,!1)}function B(e,t,n=!0){const i=t=>{!function(e,t){t?e.$root.classList.add(I):e.$root.classList.remove(I);const{$wrap:n}=A();n&&(t?n.classList.add(I):n.classList.remove(I))}(e,t),n&&function(e,t){e.conf.darkMode=t}(e,t)};"auto"===t?(M||(M=e=>i(e.matches),O.addEventListener("change",M)),i(O.matches)):(M&&O.removeEventListener("change",M),i(t))}const I="atk-dark-mode";function P(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let U={async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1};const q=/[&<>"']/,D=new RegExp(q.source,"g"),z=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,W=new RegExp(z.source,"g"),F={"&":"&","<":"<",">":">",'"':""","'":"'"},j=e=>F[e];function N(e,t){if(t){if(q.test(e))return e.replace(D,j)}else if(z.test(e))return e.replace(W,j);return e}const H=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function Q(e){return e.replace(H,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const V=/(^|[^\[])\^/g;function Z(e,t){e="string"==typeof e?e:e.source,t=t||"";const n={replace:(t,i)=>(i=(i=i.source||i).replace(V,"$1"),e=e.replace(t,i),n),getRegex:()=>new RegExp(e,t)};return n}const G=/[^\w:]/g,K=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Y(e,t,n){if(e){let e;try{e=decodeURIComponent(Q(n)).replace(G,"").toLowerCase()}catch(i){return null}if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}t&&!K.test(n)&&(n=function(e,t){X[" "+e]||(J.test(e)?X[" "+e]=e+"/":X[" "+e]=re(e,"/",!0));e=X[" "+e];const n=-1===e.indexOf(":");return"//"===t.substring(0,2)?n?t:e.replace(ee,"$1")+t:"/"===t.charAt(0)?n?t:e.replace(te,"$1")+t:e+t}(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(i){return null}return n}const X={},J=/^[^:]+:\/*[^/]*$/,ee=/^([^:]+:)[\s\S]*$/,te=/^([^:]+:\/*[^/]*)[\s\S]*$/;const ne={exec:function(){}};function ie(e){let t,n,i=1;for(;i{let i=!1,s=t;for(;--s>=0&&"\\"===n[s];)i=!i;return i?"|":" |"})).split(/ \|/);let i=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>t)n.splice(t);else for(;n.length1;)1&t&&(n+=e),t>>=1,e+=e;return n+e}function le(e,t,n,i){const s=t.href,r=t.title?N(t.title):null,a=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){i.state.inLink=!0;const e={type:"link",raw:n,href:s,title:r,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,e}return{type:"image",raw:n,href:s,title:r,text:N(a)}}class ce{constructor(e){this.options=e||U}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:re(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const i=n[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=i.length?e.slice(i.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=re(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const e=t[0].replace(/^ *>[ \t]?/gm,""),n=this.lexer.state.top;this.lexer.state.top=!0;const i=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:i,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n,i,s,r,a,o,l,c,d,h,u,p,g=t[1].trim();const m=g.length>1,f={type:"list",raw:"",ordered:m,start:m?+g.slice(0,-1):"",loose:!1,items:[]};g=m?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=m?g:"[*+-]");const k=new RegExp(`^( {0,3}${g})((?:[\t ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,t=k.exec(e))&&!this.rules.block.hr.test(e);){if(n=t[0],e=e.substring(n.length),c=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),d=e.split("\n",1)[0],this.options.pedantic?(r=2,u=c.trimLeft()):(r=t[2].search(/[^ ]/),r=r>4?1:r,u=c.slice(r),r+=t[1].length),o=!1,!c&&/^ *$/.test(d)&&(n+=d+"\n",e=e.substring(d.length+1),p=!0),!p){const t=new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),i=new RegExp(`^ {0,${Math.min(3,r-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),s=new RegExp(`^ {0,${Math.min(3,r-1)}}(?:\`\`\`|~~~)`),a=new RegExp(`^ {0,${Math.min(3,r-1)}}#`);for(;e&&(h=e.split("\n",1)[0],d=h,this.options.pedantic&&(d=d.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!s.test(d))&&!a.test(d)&&!t.test(d)&&!i.test(e);){if(d.search(/[^ ]/)>=r||!d.trim())u+="\n"+d.slice(r);else{if(o)break;if(c.search(/[^ ]/)>=4)break;if(s.test(c))break;if(a.test(c))break;if(i.test(c))break;u+="\n"+d}o||d.trim()||(o=!0),n+=h+"\n",e=e.substring(h.length+1),c=d.slice(r)}}f.loose||(l?f.loose=!0:/\n *\n *$/.test(n)&&(l=!0)),this.options.gfm&&(i=/^\[[ xX]\] /.exec(u),i&&(s="[ ] "!==i[0],u=u.replace(/^\[[ xX]\] +/,""))),f.items.push({type:"list_item",raw:n,task:!!i,checked:s,loose:!1,text:u}),f.raw+=n}f.items[f.items.length-1].raw=n.trimRight(),f.items[f.items.length-1].text=u.trimRight(),f.raw=f.raw.trimRight();const y=f.items.length;for(a=0;a"space"===e.type)),t=e.length>0&&e.some((e=>/\n.*\n/.test(e.raw)));f.loose=t}if(f.loose)for(a=0;a$/,"$1").replace(this.rules.inline._escapes,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:i}}}table(e){const t=this.rules.block.table.exec(e);if(t){const e={type:"table",header:se(t[1]).map((e=>({text:e}))),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[]};if(e.header.length===e.align.length){e.raw=t[0];let n,i,s,r,a=e.align.length;for(n=0;n({text:e})));for(a=e.header.length,i=0;i/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):N(t[0]):t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^$/.test(e))return;const t=re(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;const n=e.length;let i=0,s=0;for(;s-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],i="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^$/.test(e)?n.slice(1):n.slice(1,-1)),le(t,{href:n?n.replace(this.rules.inline._escapes,"$1"):n,title:i?i.replace(this.rules.inline._escapes,"$1"):i},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=(n[2]||n[1]).replace(/\s+/g," ");if(e=t[e.toLowerCase()],!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return le(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrong.lDelim.exec(e);if(!i)return;if(i[3]&&n.match(/[\p{L}\p{N}]/u))return;const s=i[1]||i[2]||"";if(!s||s&&(""===n||this.rules.inline.punctuation.exec(n))){const n=i[0].length-1;let s,r,a=n,o=0;const l="*"===i[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+n);null!=(i=l.exec(t));){if(s=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!s)continue;if(r=s.length,i[3]||i[4]){a+=r;continue}if((i[5]||i[6])&&n%3&&!((n+r)%3)){o+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+o);const t=e.slice(0,n+i.index+(i[0].length-s.length)+r);if(Math.min(n,r)%2){const e=t.slice(1,-1);return{type:"em",raw:t,text:e,tokens:this.lexer.inlineTokens(e)}}const l=t.slice(2,-2);return{type:"strong",raw:t,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),i=/^ /.test(e)&&/ $/.test(e);return n&&i&&(e=e.substring(1,e.length-1)),e=N(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e,t){const n=this.rules.inline.autolink.exec(e);if(n){let e,i;return"@"===n[2]?(e=N(this.options.mangle?t(n[1]):n[1]),i="mailto:"+e):(e=N(n[1]),i=e),{type:"link",raw:n[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}url(e,t){let n;if(n=this.rules.inline.url.exec(e)){let e,i;if("@"===n[2])e=N(this.options.mangle?t(n[0]):n[0]),i="mailto:"+e;else{let t;do{t=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])[0]}while(t!==n[0]);e=N(n[0]),i="www."===n[1]?"http://"+n[0]:n[0]}return{type:"link",raw:n[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e,t){const n=this.rules.inline.text.exec(e);if(n){let e;return e=this.lexer.state.inRawBlock?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):N(n[0]):n[0]:N(this.options.smartypants?t(n[0]):n[0]),{type:"text",raw:n[0],text:e}}}}const de={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:ne,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\.|[^\[\]\\])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};de.def=Z(de.def).replace("label",de._label).replace("title",de._title).getRegex(),de.bullet=/(?:[*+-]|\d{1,9}[.)])/,de.listItemStart=Z(/^( *)(bull) */).replace("bull",de.bullet).getRegex(),de.list=Z(de.list).replace(/bull/g,de.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+de.def.source+")").getRegex(),de._tag="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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",de._comment=/|$)/,de.html=Z(de.html,"i").replace("comment",de._comment).replace("tag",de._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),de.paragraph=Z(de._paragraph).replace("hr",de.hr).replace("heading"," {0,3}#{1,6} ").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",")|<(?:script|pre|style|textarea|!--)").replace("tag",de._tag).getRegex(),de.blockquote=Z(de.blockquote).replace("paragraph",de.paragraph).getRegex(),de.normal=ie({},de),de.gfm=ie({},de.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),de.gfm.table=Z(de.gfm.table).replace("hr",de.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",de._tag).getRegex(),de.gfm.paragraph=Z(de._paragraph).replace("hr",de.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",de.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",de._tag).getRegex(),de.pedantic=ie({},de.normal,{html:Z("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",de._comment).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:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ne,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Z(de.normal._paragraph).replace("hr",de.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",de.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const he={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ne,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:ne,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\.5&&(n="x"+n.toString(16)),i+="&#"+n+";";return i}he._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",he.punctuation=Z(he.punctuation).replace(/punctuation/g,he._punctuation).getRegex(),he.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,he.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,he._comment=Z(de._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),he.emStrong.lDelim=Z(he.emStrong.lDelim).replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimAst=Z(he.emStrong.rDelimAst,"g").replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimUnd=Z(he.emStrong.rDelimUnd,"g").replace(/punct/g,he._punctuation).getRegex(),he._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,he._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,he._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])?)+(?![-_])/,he.autolink=Z(he.autolink).replace("scheme",he._scheme).replace("email",he._email).getRegex(),he._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,he.tag=Z(he.tag).replace("comment",he._comment).replace("attribute",he._attribute).getRegex(),he._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,he._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,he._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,he.link=Z(he.link).replace("label",he._label).replace("href",he._href).replace("title",he._title).getRegex(),he.reflink=Z(he.reflink).replace("label",he._label).replace("ref",de._label).getRegex(),he.nolink=Z(he.nolink).replace("ref",de._label).getRegex(),he.reflinkSearch=Z(he.reflinkSearch,"g").replace("reflink",he.reflink).replace("nolink",he.nolink).getRegex(),he.normal=ie({},he),he.pedantic=ie({},he.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Z(/^!?\[(label)\]\((.*?)\)/).replace("label",he._label).getRegex(),reflink:Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",he._label).getRegex()}),he.gfm=ie({},he.normal,{escape:Z(he.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\t+" ".repeat(n.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),1===n.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),i=t[t.length-1],!i||"paragraph"!==i.type&&"text"!==i.type?t.push(n):(i.raw+="\n"+n.raw,i.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),i=t[t.length-1],!i||"paragraph"!==i.type&&"text"!==i.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(i.raw+="\n"+n.raw,i.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text);else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(s=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const n=e.slice(1);let i;this.options.extensions.startBlock.forEach((function(e){i=e.call({lexer:this},n),"number"==typeof i&&i>=0&&(t=Math.min(t,i))})),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(s)))i=t[t.length-1],r&&"paragraph"===i.type?(i.raw+="\n"+n.raw,i.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(n),r=s.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),i=t[t.length-1],i&&"text"===i.type?(i.raw+="\n"+n.raw,i.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,i,s,r,a,o,l=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(l));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,r.index)+"["+oe("a",r[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(l));)l=l.slice(0,r.index)+"["+oe("a",r[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.escapedEmSt.exec(l));)l=l.slice(0,r.index+r[0].length-2)+"++"+l.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(a||(o=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),i=t[t.length-1],i&&"text"===n.type&&"text"===i.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),i=t[t.length-1],i&&"text"===n.type&&"text"===i.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,l,o))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e,pe))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e,pe))){if(s=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const n=e.slice(1);let i;this.options.extensions.startInline.forEach((function(e){i=e.call({lexer:this},n),"number"==typeof i&&i>=0&&(t=Math.min(t,i))})),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(s,ue))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),a=!0,i=t[t.length-1],i&&"text"===i.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(n.raw.length),t.push(n);return t}}class me{constructor(e){this.options=e||U}code(e,t,n){const i=(t||"").match(/\S*/)[0];if(this.options.highlight){const t=this.options.highlight(e,i);null!=t&&t!==e&&(n=!0,e=t)}return e=e.replace(/\n$/,"")+"\n",i?'
'+(n?e:N(e,!0))+"
\n":"
"+(n?e:N(e,!0))+"
\n"}blockquote(e){return`
\n${e}
\n`}html(e){return e}heading(e,t,n,i){if(this.options.headerIds){return`${e}\n`}return`${e}\n`}hr(){return this.options.xhtml?"
\n":"
\n"}list(e,t,n){const i=t?"ol":"ul";return"<"+i+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"\n"}listitem(e){return`
  • ${e}
  • \n`}checkbox(e){return" "}paragraph(e){return`

    ${e}

    \n`}table(e,t){return t&&(t=`${t}`),"\n\n"+e+"\n"+t+"
    \n"}tablerow(e){return`\n${e}\n`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`\n`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return this.options.xhtml?"
    ":"
    "}del(e){return`${e}`}link(e,t,n){if(null===(e=Y(this.options.sanitize,this.options.baseUrl,e)))return n;let i='",i}image(e,t,n){if(null===(e=Y(this.options.sanitize,this.options.baseUrl,e)))return n;let i=`${n}":">",i}text(e){return e}}class fe{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class ke{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,t){let n=e,i=0;if(this.seen.hasOwnProperty(n)){i=this.seen[e];do{i++,n=e+"-"+i}while(this.seen.hasOwnProperty(n))}return t||(this.seen[e]=i,this.seen[n]=0),n}slug(e,t={}){const n=this.serialize(e);return this.getNextSafeSlug(n,t.dryrun)}}class ye{constructor(e){this.options=e||U,this.options.renderer=this.options.renderer||new me,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new fe,this.slugger=new ke}static parse(e,t){return new ye(t).parse(e)}static parseInline(e,t){return new ye(t).parseInline(e)}parse(e,t=!0){let n,i,s,r,a,o,l,c,d,h,u,p,g,m,f,k,y,$,x,v="";const b=e.length;for(n=0;n0&&"paragraph"===f.tokens[0].type?(f.tokens[0].text=$+" "+f.tokens[0].text,f.tokens[0].tokens&&f.tokens[0].tokens.length>0&&"text"===f.tokens[0].tokens[0].type&&(f.tokens[0].tokens[0].text=$+" "+f.tokens[0].tokens[0].text)):f.tokens.unshift({type:"text",text:$}):m+=$),m+=this.parse(f.tokens,g),d+=this.renderer.listitem(m,y,k);v+=this.renderer.list(d,u,p);continue;case"html":v+=this.renderer.html(h.text);continue;case"paragraph":v+=this.renderer.paragraph(this.parseInline(h.tokens));continue;case"text":for(d=h.tokens?this.parseInline(h.tokens):h.text;n+1{i(e.text,e.lang,(function(t,n){if(t)return a(t);null!=n&&n!==e.text&&(e.text=n,e.escaped=!0),o--,0===o&&a()}))}),0))})),void(0===o&&a())}function i(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"

    An error occurred:

    "+N(e.message+"",!0)+"
    ";throw e}try{const n=ge.lex(e,t);if(t.walkTokens){if(t.async)return Promise.all($e.walkTokens(n,t.walkTokens)).then((()=>ye.parse(n,t))).catch(i);$e.walkTokens(n,t.walkTokens)}return ye.parse(n,t)}catch(s){i(s)}}$e.options=$e.setOptions=function(e){var t;return ie($e.defaults,e),t=$e.defaults,U=t,$e},$e.getDefaults=P,$e.defaults=U,$e.use=function(...e){const t=$e.defaults.extensions||{renderers:{},childTokens:{}};e.forEach((e=>{const n=ie({},e);if(n.async=$e.defaults.async||n.async,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if(e.renderer){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}:e.renderer}if(e.tokenizer){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");t[e.level]?t[e.level].unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){const t=$e.defaults.renderer||new me;for(const n in e.renderer){const i=t[n];t[n]=(...s)=>{let r=e.renderer[n].apply(t,s);return!1===r&&(r=i.apply(t,s)),r}}n.renderer=t}if(e.tokenizer){const t=$e.defaults.tokenizer||new ce;for(const n in e.tokenizer){const i=t[n];t[n]=(...s)=>{let r=e.tokenizer[n].apply(t,s);return!1===r&&(r=i.apply(t,s)),r}}n.tokenizer=t}if(e.walkTokens){const t=$e.defaults.walkTokens;n.walkTokens=function(n){let i=[];return i.push(e.walkTokens.call(this,n)),t&&(i=i.concat(t.call(this,n))),i}}$e.setOptions(n)}))},$e.walkTokens=function(e,t){let n=[];for(const i of e)switch(n=n.concat(t.call($e,i)),i.type){case"table":for(const e of i.header)n=n.concat($e.walkTokens(e.tokens,t));for(const e of i.rows)for(const i of e)n=n.concat($e.walkTokens(i.tokens,t));break;case"list":n=n.concat($e.walkTokens(i.items,t));break;default:$e.defaults.extensions&&$e.defaults.extensions.childTokens&&$e.defaults.extensions.childTokens[i.type]?$e.defaults.extensions.childTokens[i.type].forEach((function(e){n=n.concat($e.walkTokens(i[e],t))})):i.tokens&&(n=n.concat($e.walkTokens(i.tokens,t)))}return n},$e.parseInline=function(e,t){if(null==e)throw new Error("marked.parseInline(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");ae(t=ie({},$e.defaults,t||{}));try{const n=ge.lexInline(e,t);return t.walkTokens&&$e.walkTokens(n,t.walkTokens),ye.parseInline(n,t)}catch(n){if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"

    An error occurred:

    "+N(n.message+"",!0)+"
    ";throw n}},$e.Parser=ye,$e.parser=ye.parse,$e.Renderer=me,$e.TextRenderer=fe,$e.Lexer=ge,$e.lexer=ge.lex,$e.Tokenizer=ce,$e.Slugger=ke,$e.parse=$e,$e.options,$e.setOptions,$e.use,$e.walkTokens,$e.parseInline,ye.parse,ge.lex;var xe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},ve={"&":"&","<":"<",">":">",'"':""","'":"'"},be={"&":"&","<":"<",">":">",""":'"',"'":"'"},we=/(&|<|>|"|')/g,Ce=/[&<>"']/g;function Se(e){return ve[e]}function Te(e){return be[e]}function Ee(e){return null==e?"":String(e).replace(Ce,Se)}function Le(e){return null==e?"":String(e).replace(we,Te)}Ee.options=Le.options={};var _e={encode:Ee,escape:Ee,decode:Le,unescape:Le,version:"1.0.0-browser"};var Ae=function e(t){for(var n,i,s=Array.prototype.slice.call(arguments,1);s.length;)for(i in n=s.shift())n.hasOwnProperty(i)&&("[object Object]"===Object.prototype.toString.call(t[i])?t[i]=e(t[i],n[i]):t[i]=n[i]);return t},Oe=function(e){return"string"==typeof e?e.toLowerCase():e};function Me(e,t){return e[t]=!0,e}var Re=function(e){return e.reduce(Me,{})},Be={uris:Re(["background","base","cite","href","longdesc","src","usemap"])},Ie={voids:Re(["area","br","col","hr","img","wbr","input","base","basefont","link","meta"])},Pe=_e,Ue=Oe,qe=Ie,De=/^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/,ze=/^<\s*\/\s*([\w:-]+)[^>]*>/,We=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,Fe=/^=0&&(t.comment&&t.comment(e.substring(4,i)),e=e.substring(i+3),n=!1):je.test(e)?a(ze,l):Fe.test(e)&&a(De,o);var i;!function(){if(!n)return;var i,s=e.indexOf("<");s>=0?(i=e.substring(0,s),e=e.substring(s)):(i=e,e="");t.chars&&t.chars(i)}()}();var i=e===s;s=e,i&&(e="")}function a(t,i){var s=e.match(t);s&&(e=e.substring(s[0].length),s[0].replace(t,i),n=!1)}function o(e,n,s,r){var a={},o=Ue(n),l=qe.voids[o]||!!r;s.replace(We,(function(e,t,n,i,s){a[t]=void 0===n&&void 0===i&&void 0===s?void 0:Pe.decode(n||i||s||"")})),l||i.push(o),t.start&&t.start(o,a,l)}function l(e,n){var s,r=0,a=Ue(n);if(a)for(r=i.length-1;r>=0&&i[r]!==a;r--);if(r>=0){for(s=i.length-1;s>=r;s--)t.end&&t.end(i[s]);i.length=r}}l()},Ke=function(e,t){var n,i=t||{};return o(),{start:function(e,t,a){var o=He(e);if(n.ignoring)return void r(o);if(-1===(i.allowedTags||[]).indexOf(o))return void r(o);if(i.filter&&!i.filter({tag:o,attrs:t}))return void r(o);s("<"),s(o),Object.keys(t).forEach((function(e){var n=t[e],r=(i.allowedClasses||{})[o]||[],a=(i.allowedAttributes||{})[o]||[],l=He(e);("class"===l&&-1===a.indexOf(l)?(n=n.split(" ").filter((function(e){return r&&-1!==r.indexOf(e)})).join(" ").trim()).length:-1!==a.indexOf(l)&&(!0!==Qe.uris[l]||function(e){var t=e[0];if("#"===t||"/"===t)return!0;var n=e.indexOf(":");if(-1===n)return!0;var s=e.indexOf("?");if(-1!==s&&n>s)return!0;var r=e.indexOf("#");return-1!==r&&n>r||i.allowedSchemes.some(a);function a(t){return 0===e.indexOf(t+":")}}(n)))&&(s(" "),s(e),"string"==typeof n&&(s('="'),s(Ne.encode(n)),s('"')))})),s(a?"/>":">")},end:function(e){var t=He(e);-1!==(i.allowedTags||[]).indexOf(t)&&!1===n.ignoring?(s("")):a(t)},chars:function(e){!1===n.ignoring&&s(i.transformText?i.transformText(e):e)}};function s(t){e.push(t)}function r(e){Ve.voids[e]||(!1===n.ignoring?n={ignoring:e,depth:1}:n.ignoring===e&&n.depth++)}function a(e){n.ignoring===e&&--n.depth<=0&&o()}function o(){n={ignoring:!1,depth:0}}},Ye={allowedAttributes:{a:["href","name","target","title","aria-label"],iframe:["allowfullscreen","frameborder","src"],img:["src","alt","title","aria-label"]},allowedClasses:{},allowedSchemes:["http","https","mailto"],allowedTags:["a","abbr","article","b","blockquote","br","caption","code","del","details","div","em","h1","h2","h3","h4","h5","h6","hr","i","img","ins","kbd","li","main","mark","ol","p","pre","section","span","strike","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],filter:null};function Xe(e,t,n){var i=[],s=!0===n?t:Ze({},Ye,t),r=Ke(i,s);return Ge(e,r),i.join("")}Xe.defaults=Ye;var Je=Xe,et={};({get exports(){return et},set exports(e){et=e}}).exports=function(){function e(e,t){return e(t={exports:{}},t.exports),t.exports}var t=e((function(e){var t=e.exports=function(){return new RegExp("(?:"+t.line().source+")|(?:"+t.block().source+")","gm")};t.line=function(){return/(?:^|\s)\/\/(.+?)$/gm},t.block=function(){return/\/\*([\S\s]*?)\*\//gm}})),n=["23AC69","91C132","F19726","E8552D","1AAB8E","E1147F","2980C1","1BA1E6","9FA0A0","F19726","E30B20","E30B20","A3338B"];function i(e){return''+e+""}return function(e,s){void 0===s&&(s={});var r=s.colors;void 0===r&&(r=n);var a=0,o={},l=new RegExp("("+/[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/.source+"|"+/'+t+"";return a=++a%r.length,l}))}}();const tt=et;let nt;function it(){return nt}function st(e,t){var n;let i=null==(n=it())?void 0:n.parse(t);i||(i=t.replace(/```\s*([^]+?.*?[^]+?[^]+?)```/g,((e,t)=>`
    ${tt(t)}
    `)).replace(/!\[(.*?)\]\((.*?)\)/g,((e,t,n)=>`${t}`)).replace(/\[(.*?)\]\((.*?)\)/g,((e,t,n)=>`
    ${t}`)).replace(/\n/g,"
    "));let s=Je(i,{allowedClasses:{},allowedSchemes:["http","https","mailto","data"],allowedTags:["a","abbr","article","b","blockquote","br","caption","code","del","details","div","em","h1","h2","h3","h4","h5","h6","hr","i","img","ins","kbd","li","main","mark","ol","p","pre","section","span","strike","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],allowedAttributes:{"*":["title","accesskey"],a:["href","name","target","aria-label","rel"],img:["src","alt","title","atk-emoticon","aria-label"],code:["class"],span:["class","style"]},filter:e=>([["code",/^hljs\W+language-(.*)$/],["span",/^(hljs-.*)$/]].forEach((([t,n])=>{e.tag===t&&e.attrs.class&&!n.test(e.attrs.class)&&delete e.attrs.class})),"span"===e.tag&&e.attrs.style&&!/^color:(\W+)?#[0-9a-f]{3,6};?$/i.test(e.attrs.style)&&delete e.attrs.style,!0)});return e.markedReplacers.forEach((e=>{"function"==typeof e&&(s=e(s))})),s}const rt={placeholder:"Leave a comment",noComment:"No Comment",send:"Send",save:"Save",nick:"Nickname",email:"Email",link:"Website",emoticon:"Emoji",preview:"Preview",image:"Image",uploadFail:"Upload Failed",commentFail:"Failed to comment",restoredMsg:"Content has been restored",onlyAdminCanReply:"Only admin can reply",uploadLoginMsg:"Please fill in your name and email to upload",counter:"{count} Comments",sortLatest:"Latest",sortOldest:"Oldest",sortBest:"Best",sortAuthor:"Author",openComment:"Open Comment",closeComment:"Close Comment",listLoadFailMsg:"Failed to load comments",listRetry:"Click to retry",loadMore:"Load More",admin:"Admin",reply:"Reply",voteUp:"Up",voteDown:"Down",voteFail:"Vote Failed",readMore:"Read More",actionConfirm:"Confirm",collapse:"Collapse",collapsed:"Collapsed",collapsedMsg:"This comment has been collapsed",expand:"Expand",approved:"Approved",pending:"Pending",pendingMsg:"Pending, visible only to commenter.",edit:"Edit",editCancel:"Cancel Edit",delete:"Delete",deleteConfirm:"Confirm",pin:"Pin",unpin:"Unpin",seconds:"seconds ago",minutes:"minutes ago",hours:"hours ago",days:"days ago",now:"just now",adminCheck:"Enter admin password:",captchaCheck:"Enter the CAPTCHA to continue:",confirm:"Confirm",cancel:"Cancel",msgCenter:"Messages",ctrlCenter:"Admin",frontend:"Frontend",backend:"Backend",loading:"Loading",loadFail:"Load Failed",editing:"Editing",editFail:"Edit Failed",deleting:"Deleting",deleteFail:"Delete Failed",reqGot:"Request got",reqAborted:"Request timed out or terminated unexpectedly"},at="ArtalkI18n",ot={en:rt,"en-US":rt,"zh-CN":{placeholder:"键入内容...",noComment:"「此时无声胜有声」",send:"发送评论",save:"保存评论",nick:"昵称",email:"邮箱",link:"网址",emoticon:"表情",preview:"预览",image:"图片",uploadFail:"上传失败",commentFail:"评论失败",restoredMsg:"内容已自动恢复",onlyAdminCanReply:"仅管理员可评论",uploadLoginMsg:"填入你的名字邮箱才能上传哦",counter:"{count} 条评论",sortLatest:"最新",sortOldest:"最早",sortBest:"最热",sortAuthor:"作者",openComment:"打开评论",closeComment:"关闭评论",listLoadFailMsg:"无法获取评论列表数据",listRetry:"点击重新获取",loadMore:"加载更多",admin:"管理员",reply:"回复",voteUp:"赞同",voteDown:"反对",voteFail:"投票失败",readMore:"阅读更多",actionConfirm:"确认操作",collapse:"折叠",collapsed:"已折叠",collapsedMsg:"该评论已被系统或管理员折叠",expand:"展开",approved:"已审",pending:"待审",pendingMsg:"审核中,仅本人可见。",edit:"编辑",editCancel:"取消编辑",delete:"删除",deleteConfirm:"确认删除",pin:"置顶",unpin:"取消置顶",seconds:"秒前",minutes:"分钟前",hours:"小时前",days:"天前",now:"刚刚",adminCheck:"键入密码来验证管理员身份:",captchaCheck:"键入验证码继续:",confirm:"确认",cancel:"取消",msgCenter:"通知中心",ctrlCenter:"控制中心",frontend:"前端",backend:"后端",loading:"加载中",loadFail:"加载失败",editing:"修改中",editFail:"修改失败",deleting:"删除中",deleteFail:"删除失败",reqGot:"请求响应",reqAborted:"请求超时或意外终止"}};function lt(e){return e=e.replace(/^([a-zA-Z]+)(-[a-zA-Z]+)?$/,((e,t,n)=>t.toLowerCase()+(n||"").toUpperCase())),ot[e]?ot[e]:window[at]&&window[at][e]?window[at][e]:ot.en}let ct="en",dt=lt(ct);function ht(e){e!==ct&&(ct=e,dt="string"==typeof e?lt(e):e)}function ut(e,t={}){let n=(null==dt?void 0:dt[e])||e;return n=n.replace(/\{\s*(\w+?)\s*\}/g,((e,n)=>t[n]||"")),n}const pt="2.5.2";const gt=new class{constructor(){c(this,"ctx"),c(this,"data");const e=JSON.parse(window.localStorage.getItem("ArtalkUser")||"{}");this.data={nick:e.nick||"",email:e.email||"",link:e.link||"",token:e.token||"",isAdmin:e.isAdmin||!1}}setContext(e){this.ctx=e}update(e={}){var t;Object.entries(e).forEach((([e,t])=>{this.data[e]=t})),window.localStorage.setItem("ArtalkUser",JSON.stringify(this.data)),null==(t=this.ctx)||t.trigger("user-changed",this.data)}logout(){this.update({token:"",isAdmin:!1})}checkHasBasicUserInfo(){return!!this.data.nick&&!!this.data.email}},mt=window||{},ft=navigator||{};class kt{constructor(e){c(this,"comment"),c(this,"$el"),c(this,"$main"),c(this,"$header"),c(this,"$headerNick"),c(this,"$headerBadgeWrap"),c(this,"$body"),c(this,"$content"),c(this,"$childrenWrap"),c(this,"$actions"),c(this,"voteBtnUp"),c(this,"voteBtnDown"),c(this,"$replyTo"),c(this,"$replyAt"),this.comment=e}get ctx(){return this.comment.ctx}get data(){return this.comment.getData()}get conf(){return this.comment.conf}get cConf(){return this.comment.getConf()}}function yt(e){if(e.$headerNick=e.$el.querySelector(".atk-nick"),e.data.link){const t=h('');t.innerText=e.data.nick,t.href=y(e.data.link)?e.data.link:`https://${e.data.link}`,e.$headerNick.append(t)}else e.$headerNick.innerText=e.data.nick}function $t(e){e.$headerBadgeWrap=e.$el.querySelector(".atk-badge-wrap"),e.$headerBadgeWrap.innerHTML="";const t=e.data.badge_name,n=e.data.badge_color;if(t){const i=h('');i.innerText=t.replace("管理员",e.ctx.$t("admin")),i.style.backgroundColor=n||"",e.$headerBadgeWrap.append(i)}if(e.data.is_pinned){const t=h(`${e.ctx.$t("pin")}`);e.$headerBadgeWrap.append(t)}}function xt(e){const t=e.$el.querySelector(".atk-date");t.innerText=e.comment.getDateFormatted(),t.setAttribute("data-atk-comment-date",String(+new Date(e.data.date)))}function vt(e){if(!e.ctx.conf.uaBadge&&!e.data.ip_region)return;let t=e.$header.querySelector("atk-ua-wrap");if(t||(t=h(''),e.$header.append(t)),t.innerHTML="",e.data.ip_region){const n=h('');n.innerText=e.data.ip_region,t.append(n)}if(e.ctx.conf.uaBadge){const{browser:n,os:i}=e.comment.getUserUA();if(String(n).trim()){const e=h('');e.innerText=n,t.append(e)}if(String(i).trim()){const e=h('');e.innerText=i,t.append(e)}}}class bt{constructor(e,t){c(this,"ctx"),c(this,"conf"),c(this,"$el"),c(this,"isLoading",!1),c(this,"msgRecTimer"),c(this,"msgRecTimerFunc"),c(this,"isConfirming",!1),c(this,"confirmRecTimer"),this.ctx=e,this.$el=h(''),this.conf="object"!=typeof t?{text:t}:t,this.$el.innerText=this.getText(),this.conf.adminOnly&&this.$el.setAttribute("atk-only-admin-show","")}get isMessaging(){return!!this.msgRecTimer}appendTo(e){return e.append(this.$el),this}getText(){return"string"==typeof this.conf.text?this.conf.text:this.conf.text()}setClick(e){this.$el.onclick=t=>{if(t.stopPropagation(),!this.isLoading){if(this.conf.confirm&&!this.isMessaging){const e=()=>{this.isConfirming=!1,this.$el.classList.remove("atk-btn-confirm"),this.$el.innerText=this.getText()};if(!this.isConfirming)return this.isConfirming=!0,this.$el.classList.add("atk-btn-confirm"),this.$el.innerText=this.conf.confirmText||this.ctx.$t("actionConfirm"),void(this.confirmRecTimer=window.setTimeout((()=>e()),5e3));this.confirmRecTimer&&window.clearTimeout(this.confirmRecTimer),e()}if(this.msgRecTimer)return this.fireMsgRecTimer(),void this.clearMsgRecTimer();e()}}}updateText(e){e&&(this.conf.text=e),this.setLoading(!1),this.$el.innerText=this.getText()}setLoading(e,t){this.isLoading!==e&&(this.isLoading=e,e?(this.$el.classList.add("atk-btn-loading"),this.$el.innerText=t||`${this.ctx.$t("loading")}...`):(this.$el.classList.remove("atk-btn-loading"),this.$el.innerText=this.getText()))}setError(e){this.setMsg(e,"atk-btn-error")}setWarn(e){this.setMsg(e,"atk-btn-warn")}setSuccess(e){this.setMsg(e,"atk-btn-success")}setMsg(e,t,n,i){this.setLoading(!1),t&&this.$el.classList.add(t),this.$el.innerText=e,this.setMsgRecTimer((()=>{this.$el.innerText=this.getText(),t&&this.$el.classList.remove(t),i&&i()}),n||2500)}setMsgRecTimer(e,t){this.fireMsgRecTimer(),this.clearMsgRecTimer(),this.msgRecTimerFunc=e,this.msgRecTimer=window.setTimeout((()=>{e(),this.clearMsgRecTimer()}),t)}fireMsgRecTimer(){this.msgRecTimerFunc&&this.msgRecTimerFunc()}clearMsgRecTimer(){this.msgRecTimer&&window.clearTimeout(this.msgRecTimer),this.msgRecTimer=void 0,this.msgRecTimerFunc=void 0}}function wt(e){e.ctx.conf.vote&&(e.voteBtnUp=new bt(e.ctx,(()=>`${e.ctx.$t("voteUp")} (${e.data.vote_up||0})`)).appendTo(e.$actions),e.voteBtnUp.setClick((()=>{e.comment.getActions().vote("up")})),e.ctx.conf.voteDown&&(e.voteBtnDown=new bt(e.ctx,(()=>`${e.ctx.$t("voteDown")} (${e.data.vote_down||0})`)).appendTo(e.$actions),e.voteBtnDown.setClick((()=>{e.comment.getActions().vote("down")}))))}function Ct(e){if(!e.data.is_allow_reply)return;const t=h(`${e.ctx.$t("reply")}`);e.$actions.append(t),t.addEventListener("click",(t=>{t.stopPropagation(),e.cConf.onReplyBtnClick?e.cConf.onReplyBtnClick():e.ctx.replyComment(e.data,e.$el)}))}function St(e){const t=new bt(e.ctx,{text:()=>e.data.is_collapsed?e.ctx.$t("expand"):e.ctx.$t("collapse"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminEdit("collapsed",t)}))}function Tt(e){const t=new bt(e.ctx,{text:()=>e.data.is_pending?e.ctx.$t("pending"):e.ctx.$t("approved"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminEdit("pending",t)}))}function Et(e){const t=new bt(e.ctx,{text:()=>e.data.is_pinned?e.ctx.$t("unpin"):e.ctx.$t("pin"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminEdit("pinned",t)}))}function Lt(e){const t=new bt(e.ctx,{text:e.ctx.$t("edit"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.ctx.editComment(e.data,e.$el)}))}function _t(e){const t=new bt(e.ctx,{text:e.ctx.$t("delete"),confirm:!0,confirmText:e.ctx.$t("deleteConfirm"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminDelete(t)}))}const At={Avatar:function(e){const t=e.$el.querySelector(".atk-avatar"),n=h(""),i=e.conf.avatarURLBuilder;if(n.src=i?i(e.data):e.comment.getGravatarURL(),e.data.link){const i=h('');i.href=y(e.data.link)?e.data.link:`https://${e.data.link}`,i.append(n),t.append(i)}else t.append(n)},Header:function(e){Object.entries({renderNick:yt,renderVerifyBadge:$t,renderDate:xt,renderUABadge:vt}).forEach((([t,n])=>{n(e)}))},Content:function(e){if(!e.data.is_collapsed)return e.$content.innerHTML=e.comment.getContentMarked(),void e.$content.classList.remove("atk-hide","atk-collapsed");e.$content.classList.add("atk-hide","atk-type-collapsed");const t=h(`\n
    \n ${e.ctx.$t("collapsedMsg")}\n ${e.ctx.$t("expand")}\n
    `);e.$body.insertAdjacentElement("beforeend",t);const n=t.querySelector(".atk-show-btn");n.addEventListener("click",(t=>{t.stopPropagation(),e.$content.classList.contains("atk-hide")?(e.$content.innerHTML=e.comment.getContentMarked(),e.$content.classList.remove("atk-hide"),T(e.$content),n.innerHTML=e.ctx.$t("collapse")):(e.$content.innerHTML="",e.$content.classList.add("atk-hide"),n.innerHTML=e.ctx.$t("expand"))}))},ReplyAt:function(e){e.cConf.isFlatMode||0===e.data.rid||e.cConf.replyTo&&(e.$replyAt=h(''),e.$replyAt.querySelector(".atk-nick").innerText=`${e.cConf.replyTo.nick}`,e.$replyAt.onclick=()=>{e.comment.getActions().goToReplyComment()},e.$headerBadgeWrap.insertAdjacentElement("afterend",e.$replyAt))},ReplyTo:function(e){if(!e.cConf.isFlatMode)return;if(!e.cConf.replyTo)return;e.$replyTo=h(`\n
    \n
    ${e.ctx.$t("reply")} :
    \n
    \n
    `);const t=e.$replyTo.querySelector(".atk-nick");t.innerText=`@${e.cConf.replyTo.nick}`,t.onclick=()=>{e.comment.getActions().goToReplyComment()};let n=st(e.ctx,e.cConf.replyTo.content);e.cConf.replyTo.is_collapsed&&(n=`[${e.ctx.$t("collapsed")}]`),e.$replyTo.querySelector(".atk-content").innerHTML=n,e.$body.prepend(e.$replyTo)},Pending:function(e){if(!e.data.is_pending)return;const t=h(`
    ${e.ctx.$t("pendingMsg")}
    `);e.$body.prepend(t)},Actions:function(e){Object.entries({renderVote:wt,renderReply:Ct,renderCollapse:St,renderModerator:Tt,renderPin:Et,renderEdit:Lt,renderDel:_t}).forEach((([t,n])=>{n(e)}))}};function Ot(e,t){t.forEach((({el:t,max:n,imgContains:i})=>{const s=()=>{t&&(e.scrollable?function(e){if(!e.el)return;if(e.el.classList.contains(Bt))return;e.el.classList.add(Bt),e.el.style.height=`${e.maxHeight}px`}({el:t,maxHeight:n}):function(e){if(!e.el)return;if(!e.maxHeight)return;if(e.el.classList.contains(Mt))return;e.el.classList.add(Mt),e.el.style.height=`${e.maxHeight}px`,e.el.style.overflow="hidden";const t=h(`
    ${ut("readMore")}`);t.onclick=t=>{t.stopPropagation(),Rt(e.el),e.postBtnClick&&e.postBtnClick(t)},e.el.append(t)}({el:t,maxHeight:n,postBtnClick:e.postExpandBtnClick}))},r=()=>{t&&u(t)>n&&s()};r(),i&&t&&function(e,t){if(!e)return;const n=e.getElementsByTagName("img");if(!n.length)return;let i=n.length;for(let s=0;s{i--,0===i&&t()})),0===i&&t()}(t,(()=>r()))}))}const Mt="atk-height-limit";function Rt(e){e&&e.classList.contains(Mt)&&(e.classList.remove(Mt),Array.from(e.children).forEach((e=>{e.classList.contains("atk-height-limit-btn")&&e.remove()})),e.style.height="",e.style.overflow="")}const Bt="atk-height-limit-scroll";class It extends kt{constructor(e){super(e)}render(){var e;return this.$el=h('
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n'),this.$main=this.$el.querySelector(".atk-main"),this.$header=this.$el.querySelector(".atk-header"),this.$body=this.$el.querySelector(".atk-body"),this.$content=this.$body.querySelector(".atk-content"),this.$actions=this.$el.querySelector(".atk-actions"),this.$el.setAttribute("id",`atk-comment-${this.data.id}`),e=this,Object.entries(At).forEach((([t,n])=>{n(e)})),this.recoveryChildrenWrap(),this.$el}checkHeightLimit(){const e=this.ctx.conf.heightLimit;if(!e||!e.content||!e.children)return;const t=e.content,n=e.children;Ot({postExpandBtnClick:()=>{const e=this.comment.getChildren();1===e.length&&Rt(e[0].getRender().$content)},scrollable:e.scrollable},[{el:this.$content,max:t,imgContains:!0},{el:this.$replyTo,max:t,imgContains:!0},{el:this.$childrenWrap,max:n,imgContains:!1}])}heightLimitRemoveForChildren(){this.$childrenWrap&&Rt(this.$childrenWrap)}playFadeAnim(){T(this.comment.getRender().$el)}playFadeAnimForBody(){T(this.comment.getRender().$body)}getChildrenWrap(){return this.$childrenWrap}renderChildrenWrap(){return this.$childrenWrap||(this.$childrenWrap=h('
    '),this.$main.append(this.$childrenWrap)),this.$childrenWrap}recoveryChildrenWrap(){this.$childrenWrap&&this.$main.append(this.$childrenWrap)}setUnread(e){e?this.$el.classList.add("atk-unread"):this.$el.classList.remove("atk-unread")}setOpenable(e){e?this.$el.classList.add("atk-openable"):this.$el.classList.remove("atk-openable")}setOpenURL(e){this.setOpenable(!0),this.$el.onclick=t=>{t.preventDefault(),window.open(e),this.cConf.openEvt&&this.cConf.openEvt()}}setOpenAction(e){this.setOpenable(!0),this.$el.onclick=t=>{t.preventDefault(),e()}}}class Pt{constructor(e){c(this,"comment"),this.comment=e}get ctx(){return this.comment.ctx}get data(){return this.comment.getData()}get cConf(){return this.comment.getConf()}vote(e){const t="up"===e?this.comment.getRender().voteBtnUp:this.comment.getRender().voteBtnDown;this.ctx.getApi().comment.vote(this.data.id,`comment_${e}`).then((e=>{var t,n;this.data.vote_up=e.up,this.data.vote_down=e.down,null==(t=this.comment.getRender().voteBtnUp)||t.updateText(),null==(n=this.comment.getRender().voteBtnDown)||n.updateText()})).catch((e=>{null==t||t.setError(this.ctx.$t("voteFail")),console.log(e)}))}adminEdit(e,t){if(t.isLoading)return;t.setLoading(!0,`${this.ctx.$t("editing")}...`);const n=o({},this.data);"collapsed"===e?n.is_collapsed=!n.is_collapsed:"pending"===e?n.is_pending=!n.is_pending:"pinned"===e&&(n.is_pinned=!n.is_pinned),this.ctx.getApi().comment.commentEdit(n).then((e=>{t.setLoading(!1),this.comment.setData(e),this.ctx.listRefreshUI()})).catch((e=>{console.error(e),t.setError(this.ctx.$t("editFail"))}))}adminDelete(e){e.isLoading||(e.setLoading(!0,`${this.ctx.$t("deleting")}...`),this.ctx.getApi().comment.commentDel(this.data.id,this.data.site_name).then((()=>{e.setLoading(!1),this.cConf.onDelete&&this.cConf.onDelete(this.comment)})).catch((t=>{console.error(t),e.setError(this.ctx.$t("deleteFail"))})))}goToReplyComment(){const e=window.location.hash,t=`#atk-comment-${this.data.rid}`;window.location.hash=t,t===e&&window.dispatchEvent(new Event("hashchange"))}}class Ut extends v{constructor(e,t,n){super(e),c(this,"renderInstance"),c(this,"actionInstance"),c(this,"data"),c(this,"cConf"),c(this,"parent"),c(this,"children",[]),c(this,"nestCurt"),c(this,"nestMax"),this.nestMax=e.conf.nestMax||3,this.cConf=n,this.data=o({},t),this.data.date=this.data.date.replace(/-/g,"/"),this.parent=null,this.nestCurt=1,this.actionInstance=new Pt(this),this.renderInstance=new It(this)}render(){const e=this.renderInstance.render();this.$el&&this.$el.replaceWith(e),this.$el=e,this.cConf.afterRender&&this.cConf.afterRender()}getActions(){return this.actionInstance}getRender(){return this.renderInstance}getData(){return this.data}setData(e){this.data=e,this.render(),this.getRender().playFadeAnimForBody()}getParent(){return this.parent}getChildren(){return this.children}getNestCurt(){return this.nestCurt}getIsRoot(){return 0===this.data.rid}getID(){return this.data.id}putChild(e,t="append"){e.parent=this,e.nestCurt=this.nestCurt+1,this.children.push(e);const n=this.getChildrenEl();"append"===t?n.append(e.getEl()):"prepend"===t&&n.prepend(e.getEl()),e.getRender().playFadeAnim(),e.getRender().checkHeightLimit()}getChildrenEl(){let e=this.getRender().getChildrenWrap();return e||(e=this.nestCurt{n.parent&&(e.push(n.parent),t(n.parent))};return t(this),e}getEl(){return this.$el}getGravatarURL(){return e=this.ctx,t=this.data.email_encrypted,`${e.conf.gravatar.mirror.replace(/\/$/,"")}/${t}?d=${encodeURIComponent(e.conf.gravatar.default)}&s=80`;var e,t}getContentMarked(){return st(this.ctx,this.data.content)}getDateFormatted(){return f(new Date(this.data.date),this.ctx)}getUserUA(){const e=function(e){const t=String(e||ft.userAgent),n={os:"",osVersion:"",engine:"",browser:"",device:"",language:"",version:""},i={Trident:t.includes("Trident")||t.includes("NET CLR"),Presto:t.includes("Presto"),WebKit:t.includes("AppleWebKit"),Gecko:t.includes("Gecko/")},s={Safari:t.includes("Safari"),Chrome:t.includes("Chrome")||t.includes("CriOS"),IE:t.includes("MSIE")||t.includes("Trident"),Edge:t.includes("Edge")||t.includes("Edg"),Firefox:t.includes("Firefox")||t.includes("FxiOS"),"Firefox Focus":t.includes("Focus"),Chromium:t.includes("Chromium"),Opera:t.includes("Opera")||t.includes("OPR"),Vivaldi:t.includes("Vivaldi"),Yandex:t.includes("YaBrowser"),Kindle:t.includes("Kindle")||t.includes("Silk/"),360:t.includes("360EE")||t.includes("360SE"),UC:t.includes("UC")||t.includes(" UBrowser"),QQBrowser:t.includes("QQBrowser"),QQ:t.includes("QQ/"),Baidu:t.includes("Baidu")||t.includes("BIDUBrowser"),Maxthon:t.includes("Maxthon"),Sogou:t.includes("MetaSr")||t.includes("Sogou"),LBBROWSER:t.includes("LBBROWSER"),"2345Explorer":t.includes("2345Explorer"),TheWorld:t.includes("TheWorld"),MIUI:t.includes("MiuiBrowser"),Quark:t.includes("Quark"),Qiyu:t.includes("Qiyu"),Wechat:t.includes("MicroMessenger"),Taobao:t.includes("AliApp(TB"),Alipay:t.includes("AliApp(AP"),Weibo:t.includes("Weibo"),Douban:t.includes("com.douban.frodo"),Suning:t.includes("SNEBUY-APP"),iQiYi:t.includes("IqiyiApp")},r={Windows:t.includes("Windows"),Linux:t.includes("Linux")||t.includes("X11"),macOS:t.includes("Macintosh"),Android:t.includes("Android")||t.includes("Adr"),Ubuntu:t.includes("Ubuntu"),FreeBSD:t.includes("FreeBSD"),Debian:t.includes("Debian"),"Windows Phone":t.includes("IEMobile")||t.includes("Windows Phone"),BlackBerry:t.includes("BlackBerry")||t.includes("RIM"),MeeGo:t.includes("MeeGo"),Symbian:t.includes("Symbian"),iOS:t.includes("like Mac OS X"),"Chrome OS":t.includes("CrOS"),WebOS:t.includes("hpwOS")},a={Mobile:t.includes("Mobi")||t.includes("iPh")||t.includes("480"),Tablet:t.includes("Tablet")||t.includes("Pad")||t.includes("Nexus 7")};a.Mobile?a.Mobile=!t.includes("iPad"):s.Chrome&&t.includes("Edg")?(s.Chrome=!1,s.Edge=!0):mt.showModalDialog&&mt.chrome&&(s.Chrome=!1,s[360]=!0),n.device="PC",n.language=(()=>{const e=(ft.browserLanguage||ft.language).split("-");return e[1]&&(e[1]=e[1].toUpperCase()),e.join("_")})();const o={engine:i,browser:s,os:r,device:a};Object.entries(o).forEach((([e,t])=>{Object.entries(t).forEach((([t,i])=>{!0===i&&(n[e]=t)}))}));const l={Windows:()=>{const e=t.replace(/^.*Windows NT ([\d.]+);.*$/,"$1");return{6.4:"10",6.3:"8.1",6.2:"8",6.1:"7","6.0":"Vista",5.2:"XP",5.1:"XP","5.0":"2000","10.0":"10","11.0":"11"}[e]||e},Android:()=>t.replace(/^.*Android ([\d.]+);.*$/,"$1"),iOS:()=>t.replace(/^.*OS ([\d_]+) like.*$/,"$1").replace(/_/g,"."),Debian:()=>t.replace(/^.*Debian\/([\d.]+).*$/,"$1"),"Windows Phone":()=>t.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/,"$2"),macOS:()=>t.replace(/^.*Mac OS X ([\d_]+).*$/,"$1").replace(/_/g,"."),WebOS:()=>t.replace(/^.*hpwOS\/([\d.]+);.*$/,"$1")};n.osVersion="",l[n.os]&&(n.osVersion=l[n.os](),n.osVersion===t&&(n.osVersion=""));const c={Safari:()=>t.replace(/^.*Version\/([\d.]+).*$/,"$1"),Chrome:()=>t.replace(/^.*Chrome\/([\d.]+).*$/,"$1").replace(/^.*CriOS\/([\d.]+).*$/,"$1"),IE:()=>t.replace(/^.*MSIE ([\d.]+).*$/,"$1").replace(/^.*rv:([\d.]+).*$/,"$1"),Edge:()=>t.replace(/^.*(Edge|Edg|Edg[A-Z]{1})\/([\d.]+).*$/,"$2"),Firefox:()=>t.replace(/^.*Firefox\/([\d.]+).*$/,"$1").replace(/^.*FxiOS\/([\d.]+).*$/,"$1"),"Firefox Focus":()=>t.replace(/^.*Focus\/([\d.]+).*$/,"$1"),Chromium:()=>t.replace(/^.*Chromium\/([\d.]+).*$/,"$1"),Opera:()=>t.replace(/^.*Opera\/([\d.]+).*$/,"$1").replace(/^.*OPR\/([\d.]+).*$/,"$1"),Vivaldi:()=>t.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1"),Yandex:()=>t.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1"),Kindle:()=>t.replace(/^.*Version\/([\d.]+).*$/,"$1"),Maxthon:()=>t.replace(/^.*Maxthon\/([\d.]+).*$/,"$1"),QQBrowser:()=>t.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1"),QQ:()=>t.replace(/^.*QQ\/([\d.]+).*$/,"$1"),Baidu:()=>t.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/,"$1"),UC:()=>t.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1"),Sogou:()=>t.replace(/^.*SE ([\d.X]+).*$/,"$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1"),"2345Explorer":()=>t.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1"),TheWorld:()=>t.replace(/^.*TheWorld ([\d.]+).*$/,"$1"),MIUI:()=>t.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1"),Quark:()=>t.replace(/^.*Quark\/([\d.]+).*$/,"$1"),Qiyu:()=>t.replace(/^.*Qiyu\/([\d.]+).*$/,"$1"),Wechat:()=>t.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1"),Taobao:()=>t.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1"),Alipay:()=>t.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1"),Weibo:()=>t.replace(/^.*weibo__([\d.]+).*$/,"$1"),Douban:()=>t.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1"),Suning:()=>t.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1"),iQiYi:()=>t.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")};return n.version="",c[n.browser]&&(n.version=c[n.browser](),n.version===t&&(n.version="")),n.version.indexOf(".")&&(n.version=n.version.substring(0,n.version.indexOf("."))),"iOS"===n.os&&t.includes("iPad")?n.os="iPadOS":"Edge"!==n.browser||t.includes("Edg")?"MIUI"===n.browser?n.os="Android":"Chrome"===n.browser&&Number(n.version)>27||"Opera"===n.browser&&Number(n.version)>12||"Yandex"===n.browser?n.engine="Blink":void 0===n.browser&&(n.browser="Unknow App"):n.engine="EdgeHTML",n}(this.data.ua);return{browser:`${e.browser} ${e.version}`,os:`${e.os} ${e.osVersion}`}}getConf(){return this.cConf}}class qt{constructor(e,t){c(this,"conf"),c(this,"total"),c(this,"$el"),c(this,"$input"),c(this,"inputTimer"),c(this,"$prevBtn"),c(this,"$nextBtn"),c(this,"page",1),this.total=e,this.conf=t,this.$el=h('
    \n
    \n
    Prev
    \n \n
    Next
    \n
    \n
    '),this.$input=this.$el.querySelector(".atk-input"),this.$input.value=`${this.page}`,this.$input.oninput=()=>this.input(),this.$input.onkeydown=e=>this.keydown(e),this.$prevBtn=this.$el.querySelector(".atk-btn-prev"),this.$nextBtn=this.$el.querySelector(".atk-btn-next"),this.$prevBtn.onclick=()=>this.prev(),this.$nextBtn.onclick=()=>this.next(),this.checkDisabled()}get pageSize(){return this.conf.pageSize}get offset(){return this.pageSize*(this.page-1)}get maxPage(){return Math.ceil(this.total/this.pageSize)}update(e,t){this.page=Math.ceil(e/this.pageSize)+1,this.total=t,this.setInput(this.page),this.checkDisabled()}setInput(e){this.$input.value=`${e}`}input(e=!1){window.clearTimeout(this.inputTimer);const t=this.$input.value.trim(),n=()=>{if(""===t)return void this.setInput(this.page);let e=Number(t);Number.isNaN(e)||e<1?this.setInput(this.page):(e>this.maxPage&&(this.setInput(this.maxPage),e=this.maxPage),this.change(e))};e?n():this.inputTimer=window.setTimeout((()=>n()),800)}prev(){const e=this.page-1;e<1||this.change(e)}next(){const e=this.page+1;e>this.maxPage||this.change(e)}change(e){this.page=e,this.conf.onChange(this.offset),this.setInput(e),this.checkDisabled()}checkDisabled(){this.page+1>this.maxPage?this.$nextBtn.classList.add("atk-disabled"):this.$nextBtn.classList.remove("atk-disabled"),this.page-1<1?this.$prevBtn.classList.add("atk-disabled"):this.$prevBtn.classList.remove("atk-disabled")}keydown(e){const t=e.keyCode||e.which;if(38===t){const e=Number(this.$input.value)+1;if(e>this.maxPage)return;this.setInput(e),this.input()}else if(40===t){const e=Number(this.$input.value)-1;if(e<1)return;this.setInput(e),this.input()}else 13===t&&this.input(!0)}setLoading(e){e?b(this.$el):w(this.$el)}}const Dt={createInstance(e){const t=new qt(e.total,{pageSize:e.pageSize,onChange:t=>d(this,null,(function*(){if(!0===e.list.conf.editorTravel&&e.list.ctx.editorTravelBack(),yield e.list.fetchComments(t),e.list.repositionAt){(e.list.scrollListenerAt||window).scroll({top:e.list.repositionAt?g(e.list.repositionAt).top:0,left:0})}}))});return[t,t.$el]},setLoading(e){this.instance.setLoading(e)},update(e,t){this.instance.update(e,t)},next(){this.instance.next()}};class zt{constructor(e){c(this,"conf"),c(this,"$el"),c(this,"$loading"),c(this,"$text"),c(this,"offset",0),c(this,"total",0),c(this,"origText","Load More"),this.conf=e,this.origText=this.conf.text||this.origText,this.$el=h(``),this.$loading=this.$el.querySelector(".atk-loading-icon"),this.$text=this.$el.querySelector(".atk-text"),this.$el.onclick=()=>{this.click()}}get hasMore(){return this.total>this.offset+this.conf.pageSize}click(){this.hasMore&&this.conf.onClick(this.offset+this.conf.pageSize),this.checkDisabled()}show(){this.$el.style.display=""}hide(){this.$el.style.display="none"}setLoading(e){this.$loading.style.display=e?"":"none",this.$text.style.display=e?"none":""}showErr(e){this.setLoading(!1),this.$text.innerText=e,this.$el.classList.add("atk-err"),window.setTimeout((()=>{this.$text.innerText=this.origText,this.$el.classList.remove("atk-err")}),2e3)}update(e,t){this.offset=e,this.total=t,this.checkDisabled()}checkDisabled(){this.hasMore?this.show():this.hide()}}const Wt={pagination:Dt,"read-more":{createInstance(e){const t=new zt({pageSize:e.pageSize,onClick:t=>d(this,null,(function*(){yield e.list.fetchComments(t)})),text:ut("loadMore")});if(e.list.conf.pagination.autoLoad){const n=e.list.scrollListenerAt||document;this.autoLoadScrollEvent&&n.removeEventListener("scroll",this.autoLoadScrollEvent),this.autoLoadScrollEvent=()=>{if("read-more"!==e.mode||!(null==t?void 0:t.hasMore)||e.list.getLoading())return;const n=e.list.$el.querySelector(".atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)");n&&function(e,t=document.documentElement){const n=t.clientHeight,i=t.scrollTop,s=i+n,r=e.getBoundingClientRect();return r.top+i+r.height<=s}(n,e.list.scrollListenerAt)&&t.click()},n.addEventListener("scroll",this.autoLoadScrollEvent)}return[t,t.$el]},setLoading(e){this.instance.setLoading(e)},update(e,t){this.instance.update(e,t)},showErr(e){this.instance.showErr(e)},next(){this.instance.click()}}};class Ft{constructor(e){c(this,"conf"),this.conf=e,this.init()}getAdaptor(){return Wt[this.conf.mode]}init(){const e=this.getAdaptor(),[t,n]=e.createInstance(this.conf);e.instance=t,e.el=n,this.conf.list.$el.append(e.el)}setLoading(e){this.getAdaptor().setLoading(e)}update(e,t){this.getAdaptor().update(e,t)}getEl(){return this.getAdaptor().el}showErr(e){const t=this.getAdaptor(),n=t.showErr;n&&n.bind(t)(e)}setMode(e){e!==this.conf.mode&&(this.getEl().remove(),this.conf.mode=e,this.init())}next(){this.getAdaptor().next()}}function jt(e,t,n){const i=function(e,t){const n=e.split("."),i=t.split(".");for(let s=0;s<3;s++){const e=Number(n[s]),t=Number(i[s]);if(e>t)return 1;if(t>e)return-1;if(!Number.isNaN(e)&&Number.isNaN(t))return 1;if(Number.isNaN(e)&&!Number.isNaN(t))return-1}return 0}(t,n);if(0!==i){const s=h(`
    请更新 Artalk ${ut(i<0?"frontend":"backend")}以获得完整体验 (帮助文档)

    当前版本:${ut("frontend")} ${t} / ${ut("backend")} ${n}

    `),r=h('忽略');return r.onclick=()=>{E(e.$el.parentElement,null),e.ctx.conf.versionCheck=!1,e.fetchComments(0)},s.append(r),E(e.$el.parentElement,s,'Artalk Warn'),!0}return!1}function Nt(e){const{$dropdownWrap:t,dropdownList:n}=e;if(t.querySelector(".atk-dropdown"))return;t.classList.add("atk-dropdown-wrap"),t.append(h(''));let i=0;const s=h('
      ');n.forEach(((e,t)=>{const n=e[0],r=e[1],a=h('
    • '),o=a.querySelector("span");o.innerText=n,o.onclick=()=>{((e,t,n,r)=>{r(),i=e,s.querySelectorAll(".active").forEach((e=>{e.classList.remove("active")})),t.classList.add("active"),s.style.display="none",setTimeout((()=>{s.style.display=""}),80)})(t,a,0,r)},s.append(a),t===i&&a.classList.add("active")})),t.append(s)}const Ht={el:"",pageKey:"",pageTitle:"",server:"",site:"",placeholder:"",noComment:"",sendBtn:"",darkMode:!1,editorTravel:!0,flatMode:"auto",nestMax:2,nestSort:"DATE_ASC",emoticons:"https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json",vote:!0,voteDown:!1,uaBadge:!0,listSort:!0,preview:!0,countEl:"#ArtalkCount",pvEl:"#ArtalkPV",gravatar:{default:"mp",mirror:"https://cravatar.cn/avatar/"},pagination:{pageSize:20,readMore:!0,autoLoad:!0},heightLimit:{content:300,children:400,scrollable:!1},imgUpload:!0,reqTimeout:15e3,versionCheck:!0,useBackendConf:!0,locale:"zh-CN"};function Qt(e){const t=x(Ht,e);if("string"==typeof t.el&&t.el)try{const e=document.querySelector(t.el);if(!e)throw Error(`Target element "${t.el}" was not found.`);t.el=e}catch(n){throw console.error(n),new Error("Please check your Artalk `el` config.")}return t.server=t.server.replace(/\/$/,"").replace(/\/api\/?$/,""),t.pageKey||(t.pageKey=`${window.location.pathname}`),t.pageTitle||(t.pageTitle=`${document.title}`),"auto"===t.locale&&(t.locale=navigator.language),t}function Vt(e){const t=["el","pageKey","pageTitle","server","site","darkMode"];return Object.keys(e).forEach((n=>{t.includes(n)&&delete e[n]})),e.emoticons&&"string"==typeof e.emoticons&&(e.emoticons=e.emoticons.trim(),e.emoticons.startsWith("[")||e.emoticons.startsWith("{")?e.emoticons=JSON.parse(e.emoticons):"false"===e.emoticons&&(e.emoticons=!1)),e}class Zt extends v{constructor(e){super(e),c(this,"$commentsWrap"),c(this,"data"),c(this,"isLoading",!1),c(this,"confLoaded",!1),c(this,"noCommentText"),c(this,"_nestSortBy"),c(this,"_flatMode"),c(this,"_pageMode"),c(this,"pgHolder"),c(this,"_pageSize"),c(this,"scrollListenerAt"),c(this,"repositionAt"),c(this,"renderComment"),c(this,"paramsEditor"),c(this,"onAfterLoad"),c(this,"unread",[]),c(this,"unreadHighlight"),this.$el=h('
      \n
      \n
      '),this.$commentsWrap=this.$el.querySelector(".atk-list-comments-wrap"),window.setInterval((()=>{this.$el.querySelectorAll("[data-atk-comment-date]").forEach((e=>{const t=e.getAttribute("data-atk-comment-date");e.innerText=f(new Date(Number(t)),this.ctx)}))}),3e4),this.ctx.on("conf-loaded",(()=>{}))}get nestSortBy(){return this._nestSortBy||this.ctx.conf.nestSort||"DATE_ASC"}set nestSortBy(e){this._nestSortBy=e}get flatMode(){return void 0!==this._flatMode?this._flatMode:!0===this.ctx.conf.flatMode||Number(this.ctx.conf.nestMax)<=1||!("auto"!==this.ctx.conf.flatMode||!window.matchMedia("(max-width: 768px)").matches)}set flatMode(e){this._flatMode=e}get pageMode(){return this._pageMode||(this.conf.pagination.readMore?"read-more":"pagination")}set pageMode(e){var t;this._pageMode=e,null==(t=this.pgHolder)||t.setMode(this._pageMode)}get pageSize(){return this._pageSize||this.conf.pagination.pageSize}set pageSize(e){this._pageSize=e}getData(){return this.data}clearData(){this.data=void 0}getLoading(){return this.isLoading}getCommentsWrapEl(){return this.$commentsWrap}setLoading(e,t=!1){var n;this.isLoading=e,t?function(e,t){e?b(t):w(t)}(e,this.$el):null==(n=this.pgHolder)||n.setLoading(e)}fetchComments(e){return d(this,null,(function*(){if(this.isLoading)return;const t=0===e,n=e=>this.setLoading(e,t);let i;n(!0),this.ctx.trigger("list-load"),("read-more"===this.pageMode&&t||"pagination"===this.pageMode)&&this.ctx.clearAllComments();try{i=yield this.ctx.getApi().comment.get(e,this.pageSize,this.flatMode,this.paramsEditor)}catch(s){throw this.onError(s.msg||String(s),e,s.data),s}finally{n(!1)}E(this.$el,null);try{this.onLoad(i,e)}catch(s){throw this.onError(String(s),e),s}finally{n(!1)}}))}onLoad(e,t){if(this.data=e,!this.confLoaded){const t=Vt(e.conf.frontend_conf);this.conf.useBackendConf?this.ctx.updateConf(t):this.ctx.updateConf({}),this.confLoaded=!0}this.ctx.conf.versionCheck&&jt(this,pt,e.api_version.version)||(this.importComments(e.comments),this.refreshPagination(t,this.flatMode?e.total:e.total_roots),this.refreshUI(),this.ctx.updateNotifies(e.unread||[]),this.ctx.trigger("list-loaded"),this.onAfterLoad&&this.onAfterLoad(e))}refreshPagination(e,t){var n;this.pgHolder||(this.pgHolder=new Ft({list:this,mode:this.pageMode,pageSize:this.pageSize,total:t})),null==(n=this.pgHolder)||n.update(e,t)}onError(e,t,n){var i;this.confLoaded||this.ctx.updateConf({}),e=String(e),console.error(e),0===t||"read-more"!==this.pageMode?E(this.$el,function(e,t,n){const i=h(`${t},${ut("listLoadFailMsg")}
      `),s=h(`${ut("listRetry")}`);s.onclick=()=>e.fetchComments(0),i.appendChild(s);const r=h(' | 打开控制台');i.appendChild(r),gt.data.isAdmin||r.classList.add("atk-hide");let a="";if(null==n?void 0:n.err_no_site){const t={create_name:e.ctx.conf.site,create_urls:`${window.location.protocol}//${window.location.host}`};a=`sites|${JSON.stringify(t)}`}return r.onclick=()=>e.ctx.showSidebar({view:a}),i}(this,e,n)):null==(i=this.pgHolder)||i.showErr(this.$t("loadFail"))}refreshUI(){!function(e){const t=e.ctx.getCommentList().length<=0;let n=e.getCommentsWrapEl().querySelector(".atk-list-no-comment");t?n||(n=h('
      '),n.innerHTML=e.noCommentText||e.ctx.conf.noComment||e.ctx.$t("noComment"),e.getCommentsWrapEl().appendChild(n)):null==n||n.remove(),e.ctx.checkAdminShowEl()}(this)}reload(){this.fetchComments(0)}createComment(e,t){t||(t=this.ctx.getCommentDataList());const n=new Ut(this.ctx,e,{isFlatMode:this.flatMode,afterRender:()=>{this.renderComment&&this.renderComment(n)},onDelete:e=>{this.ctx.deleteComment(e),this.refreshUI()},replyTo:e.rid?t.find((t=>t.id===e.rid)):void 0});return n.render(),this.ctx.getCommentList().push(n),n}importComments(e){this.flatMode?e.forEach((t=>{this.putCommentFlatMode(t,e,"append")})):this.importCommentsNest(e)}importCommentsNest(e){const t=function(e,t="DATE_DESC",n=2){const i=[];e.filter((e=>0===e.rid)).forEach((t=>{const s={id:t.id,comment:t,children:[],level:1};s.parent=s,i.push(s),function t(i){const s=e.filter((e=>e.rid===i.id));0!==s.length&&(i.level>=n&&(i=i.parent),s.forEach((e=>{const n={id:e.id,comment:e,children:[],parent:i,level:i.level+1};i.children.push(n),t(n)})))}(s)}));const s=(n,i)=>{let s=n.id-i.id;return"DATE_ASC"===t?s=+new Date(n.comment.date)-+new Date(i.comment.date):"DATE_DESC"===t?s=+new Date(i.comment.date)-+new Date(n.comment.date):"SRC_INDEX"===t?s=e.indexOf(n.comment)-e.indexOf(i.comment):"VOTE_UP_DESC"===t&&(s=i.comment.vote_up-n.comment.vote_up),s};return function e(t){t.forEach((t=>{t.children=t.children.sort(s),e(t.children)}))}(i),i}(e,this.nestSortBy,this.conf.nestMax);t.forEach((t=>{const n=this.createComment(t.comment,e);this.$commentsWrap.appendChild(n.getEl()),n.getRender().playFadeAnim();const i=this;!function t(n,s){s.children.forEach((s=>{const r=s.comment,a=i.createComment(r,e);n.putChild(a),t(a,s)}))}(n,t),n.getRender().checkHeightLimit()}))}putCommentFlatMode(e,t,n){e.is_collapsed&&(e.is_allow_reply=!1);const i=this.createComment(e,t);return e.visible&&("append"===n&&this.$commentsWrap.append(i.getEl()),"prepend"===n&&this.$commentsWrap.prepend(i.getEl()),i.getRender().playFadeAnim()),i.getRender().checkHeightLimit(),i}insertComment(e){if(this.flatMode){C(this.putCommentFlatMode(e,this.ctx.getCommentDataList(),"prepend").getEl())}else{const t=this.createComment(e);if(0===e.rid)this.$commentsWrap.prepend(t.getEl());else{const n=this.ctx.findComment(e.rid);n&&(n.putChild(t,"DATE_ASC"===this.nestSortBy?"append":"prepend"),t.getParents().forEach((e=>{e.getRender().heightLimitRemoveForChildren()})))}t.getRender().checkHeightLimit(),C(t.getEl()),t.getRender().playFadeAnim()}this.data&&(this.data.total+=1),this.refreshUI(),this.ctx.trigger("list-loaded"),this.ctx.trigger("list-inserted",e)}updateComment(e){const t=this.ctx.findComment(e.id);t&&t.setData(e)}updateUnread(e){this.unread=e,!0===this.unreadHighlight&&this.ctx.getCommentList().forEach((e=>{const t=this.unread.find((t=>t.comment_id===e.getID()));t?(e.getRender().setUnread(!0),e.getRender().setOpenAction((()=>{window.open(t.read_link),this.unread=this.unread.filter((t=>t.comment_id!==e.getID())),this.ctx.updateNotifies(this.unread)}))):e.getRender().setUnread(!1)}))}}class Gt extends Zt{constructor(e){const t=h('
      \n
      \n
      \n
      \n
      \n
      \n \n \n \n
      \n
      \n
      \n
      \n
      \n \n
      \n');super(e),c(this,"$closeCommentBtn"),c(this,"$openSidebarBtn"),c(this,"$unreadBadge"),c(this,"$commentCount"),c(this,"$commentCountNum"),c(this,"$dropdownWrap"),c(this,"goToCommentFounded",!1),c(this,"goToCommentDelay",!0),t.querySelector(".atk-list-body").append(this.$el),this.$el=t,this.repositionAt=this.$el,this.initListActionBtn();this.$commentCount=this.$el.querySelector(".atk-comment-count");const n=()=>{this.$commentCount.innerHTML=this.$t("counter",{count:'0'}),this.$commentCountNum=this.$commentCount.querySelector(".atk-comment-count-num")};n(),this.$el.querySelector(".atk-copyright").innerHTML=`Powered By Artalk`,this.ctx.on("conf-loaded",(()=>{n(),this.refreshUI()}))}initListActionBtn(){this.$openSidebarBtn=this.$el.querySelector('[data-action="open-sidebar"]'),this.$closeCommentBtn=this.$el.querySelector('[data-action="admin-close-comment"]'),this.$unreadBadge=this.$el.querySelector(".atk-unread-badge"),this.$openSidebarBtn.addEventListener("click",(()=>{this.ctx.showSidebar()})),this.$closeCommentBtn.addEventListener("click",(()=>{this.data&&(this.data.page.admin_only=!this.data.page.admin_only,this.adminPageEditSave())}))}refreshUI(){var e;super.refreshUI(),this.$commentCountNum.innerText=String(Number(null==(e=this.data)?void 0:e.total)||0),gt.data.nick&>.data.email?this.$openSidebarBtn.classList.remove("atk-hide"):this.$openSidebarBtn.classList.add("atk-hide"),this.$openSidebarBtn.querySelector(".atk-text").innerText=gt.data.isAdmin?this.$t("ctrlCenter"):this.$t("msgCenter"),this.data&&this.data.page&&!0===this.data.page.admin_only?(this.ctx.editorClose(),this.$closeCommentBtn.innerHTML=this.$t("openComment")):(this.ctx.editorOpen(),this.$closeCommentBtn.innerHTML=this.$t("closeComment")),this.ctx.conf.listSort?this.initDropdown():function(e){var t,n;const{$dropdownWrap:i}=e;i.classList.remove("atk-dropdown-wrap"),null==(t=i.querySelector(".atk-arrow-down-icon"))||t.remove(),null==(n=i.querySelector(".atk-dropdown"))||n.remove()}({$dropdownWrap:this.$commentCount})}onLoad(e,t){super.onLoad(e,t),this.goToCommentFounded||this.checkGoToCommentByUrlHash(),!0===this.ctx.conf.editorTravel&&this.ctx.editorTravelBack()}checkGoToCommentByUrlHash(){var e;let t=Number(p("atk_comment"));if(!t){const e=window.location.hash.match(/#atk-comment-([0-9]+)/);if(!e||!e[1]||Number.isNaN(Number(e[1])))return;t=Number(e[1])}if(!t)return;const n=this.ctx.findComment(t);if(!n)return void(null==(e=this.pgHolder)||e.next());const i=p("atk_notify_key");i&&this.ctx.getApi().user.markRead(t,i).then((()=>{this.unread=this.unread.filter((e=>e.comment_id!==t)),this.updateUnread(this.unread)})),n.getParents().forEach((e=>{e.getRender().heightLimitRemoveForChildren()}));const s=()=>{C(n.getEl(),!1),n.getEl().classList.remove("atk-flash-once"),window.setTimeout((()=>{n.getEl().classList.add("atk-flash-once")}),150)};this.goToCommentDelay?window.setTimeout((()=>s()),350):s(),this.goToCommentFounded=!0,this.goToCommentDelay=!0}adminPageEditSave(){this.data&&this.data.page&&(this.ctx.editorShowLoading(),this.ctx.getApi().page.pageEdit(this.data.page).then((e=>{this.data&&(this.data.page=o({},e)),this.refreshUI()})).catch((e=>{this.ctx.editorShowNotify(`${this.$t("editFail")}: ${e.msg||String(e)}`,"e")})).finally((()=>{this.ctx.editorHideLoading()})))}showUnreadBadge(e){e>0?(this.$unreadBadge.innerText=`${Number(e||0)}`,this.$unreadBadge.style.display="block"):this.$unreadBadge.style.display="none"}initDropdown(){const e=e=>{this.paramsEditor=e,this.fetchComments(0)};Nt({$dropdownWrap:this.$commentCount,dropdownList:[[this.$t("sortLatest"),()=>{e((e=>{e.sort_by="date_desc"}))}],[this.$t("sortBest"),()=>{e((e=>{e.sort_by="vote"}))}],[this.$t("sortOldest"),()=>{e((e=>{e.sort_by="date_asc"}))}],[this.$t("sortAuthor"),()=>{e((e=>{e.view_only_admin=!0}))}]]})}updateUnread(e){super.updateUnread(e),this.showUnreadBadge((null==e?void 0:e.length)||0)}}class Kt{constructor(e,t){c(this,"conf"),c(this,"$root"),c(this,"markedReplacers",[]),c(this,"commentList",[]),c(this,"eventList",[]),this.conf=e,this.$root=t||document.createElement("div"),this.$root.classList.add("artalk"),this.$root.innerHTML=""}inject(e,t){this[e]=t}get(e){return this[e]}getApi(){return this.api}getCommentList(){return this.commentList}getCommentDataList(){return this.commentList.map((e=>e.getData()))}findComment(e){return this.commentList.find((t=>t.getData().id===e))}deleteComment(e){let t;if("number"==typeof e){const n=this.findComment(e);if(!n)throw Error(`Comment ${e} cannot be found`);t=n}else t=e;if(t.getEl().remove(),this.commentList.splice(this.commentList.indexOf(t),1),this.list){const e=this.list.getData();e&&(e.total-=1),this.list.refreshUI()}}clearAllComments(){this.list&&(this.list.getCommentsWrapEl().innerHTML="",this.list.clearData()),this.commentList=[]}insertComment(e){var t;null==(t=this.list)||t.insertComment(e)}updateComment(e){var t;null==(t=this.list)||t.updateComment(e)}replyComment(e,t,n){this.editor.setReply(e,t,n)}cancelReplyComment(){this.editor.cancelReply()}editComment(e,t){this.editor.setEditComment(e,t)}cancelEditComment(){this.editor.cancelEditComment()}updateNotifies(e){var t;null==(t=this.list)||t.updateUnread(e)}listReload(){var e;null==(e=this.list)||e.reload()}reload(){this.listReload()}listRefreshUI(){var e;null==(e=this.list)||e.refreshUI()}listHashGotoCheck(){if(!(this.list&&this.list instanceof Gt))return;const e=this.list;e.goToCommentDelay=!1,e.checkGoToCommentByUrlHash()}editorOpen(){this.editor.open()}editorClose(){this.editor.close()}editorShowLoading(){this.editor.showLoading()}editorHideLoading(){this.editor.hideLoading()}editorShowNotify(e,t){this.editor.showNotify(e,t)}editorTravel(e){this.editor.travel(e)}editorTravelBack(){this.editor.travelBack()}showSidebar(e){this.sidebarLayer.show(e)}hideSidebar(){this.sidebarLayer.hide()}checkAdmin(e){this.checkerLauncher.checkAdmin(e)}checkCaptcha(e){this.checkerLauncher.checkCaptcha(e)}checkAdminShowEl(){const e=[];this.$root.querySelectorAll("[atk-only-admin-show]").forEach((t=>e.push(t)));const{$wrap:t}=A();t&&t.querySelectorAll("[atk-only-admin-show]").forEach((t=>e.push(t)));const n=document.querySelector(".atk-sidebar");n&&n.querySelectorAll("[atk-only-admin-show]").forEach((t=>e.push(t))),e.forEach((e=>{this.user.data.isAdmin?e.classList.remove("atk-hide"):e.classList.add("atk-hide")}))}on(e,t,n="internal"){this.eventList.push({name:e,handler:t,scope:n})}off(e,t,n="internal"){this.eventList=this.eventList.filter((i=>t?!(i.name===e&&i.handler===t&&i.scope===n):!(i.name===e&&i.scope===n)))}trigger(e,t,n){this.eventList.filter((t=>t.name===e&&(!n||t.scope===n))).map((e=>e.handler)).forEach((e=>e(t)))}$t(e,t={}){return ut(e,t)}setDarkMode(e){B(this,e)}updateConf(e){this.conf=x(this.conf,e),this.trigger("conf-loaded")}getMarkedInstance(){return it()}}class Yt{constructor(e,t){return c(this,"ctx"),c(this,"$el"),c(this,"$content"),c(this,"$actions"),this.ctx=e,this.$el=h('
      \n
      \n
      \n
      \n
      \n
      '),this.$actions=this.$el.querySelector(".atk-layer-dialog-actions"),this.$content=this.$el.querySelector(".atk-layer-dialog-content"),this.$content.appendChild(t),this}setYes(e){const t=h(``);return t.onclick=this.onBtnClick(e),this.$actions.appendChild(t),this}setNo(e){const t=h(``);return t.onclick=this.onBtnClick(e),this.$actions.appendChild(t),this}onBtnClick(e){return t=>{const n=e(t.currentTarget,this);void 0!==n&&!0!==n||this.$el.remove()}}}function Xt(e){const t=h('
      '),n=h('');n.style.display="none",b(t,{transparentBg:!0}),n.src=`${e.getCtx().conf.server}/api/captcha/get?t=${+new Date}`,n.onload=()=>{n.style.display="",w(t)},t.append(n);const i=h('
      ');t.append(i),e.hideInteractInput();let s=!1;return function t(){return d(this,null,(function*(){var n;if(yield(n=1e3,new Promise((e=>{window.setTimeout((()=>{e(null)}),n)}))),s)return;let i=!1;try{i=(yield e.getCtx().getApi().captcha.captchaStatus()).is_pass}catch(r){i=!1}i?e.triggerSuccess():t()}))}(),i.onclick=()=>{s=!0,e.cancel()},t}const Jt={request:(e,t)=>e.getApi().captcha.captchaCheck(t),body:e=>e.get("iframe")?Xt(e):function(e){const t=h(`${e.getCtx().$t("captchaCheck")}`);return t.querySelector(".atk-captcha-img").onclick=()=>{const n=t.querySelector(".atk-captcha-img");e.getApi().captcha.captchaGet().then((e=>{n.setAttribute("src",e)})).catch((e=>{console.error("Failed to get captcha image ",e)}))},t}(e),onSuccess(e,t,n,i){e.set("val",n)},onError(e,t,n,i){i.querySelector(".atk-captcha-img").click(),i.querySelector('input[type="text"]').value=""}},en={inputType:"password",request(e,t){const n={name:gt.data.nick,email:gt.data.email,password:t};return(()=>d(this,null,(function*(){return(yield e.getApi().user.login(n.name,n.email,n.password)).token})))()},body:e=>h(`${e.getCtx().$t("adminCheck")}`),onSuccess(e,t,n,i){gt.update({isAdmin:!0,token:t}),e.getCtx().trigger("user-changed",gt.data),e.getCtx().listReload()},onError(e,t,n,i){}};class tn{constructor(e){c(this,"ctx"),c(this,"launched",[]),this.ctx=e}checkCaptcha(e){this.fire(Jt,e,(t=>{t.set("img_data",e.imgData),t.set("iframe",e.iframe)}))}checkAdmin(e){this.fire(en,e)}fire(e,t,n){if(this.launched.includes(e))return;this.launched.push(e);const i=new _(this.ctx,`checker-${(new Date).getTime()}`);i.setMaskClickHide(!1),i.show();const s={};let r=!1;const a={set:(e,t)=>{s[e]=t},get:e=>s[e],getCtx:()=>this.ctx,getApi:()=>this.ctx.getApi(),getLayer:()=>i,hideInteractInput:()=>{r=!0},triggerSuccess:()=>{this.close(e,i),e.onSuccess&&e.onSuccess(a,"","",o),t.onSuccess&&t.onSuccess("",d.$el)},cancel:()=>{this.close(e,i),t.onCancel&&t.onCancel()}};n&&n(a);const o=h();o.appendChild(e.body(a));const l=h(``);let c;o.appendChild(l),setTimeout((()=>l.focus()),80),l.onkeyup=e=>{"Enter"!==e.key&&13!==e.keyCode||(e.preventDefault(),i.getEl().querySelector('button[data-action="confirm"]').click())};const d=new Yt(this.ctx,o);d.setYes((n=>{const s=l.value.trim();c||(c=n.innerText);const r=()=>{n.innerText=c||"",n.classList.remove("error")};return n.innerText=`${this.ctx.$t("loading")}...`,e.request(a,s).then((n=>{this.close(e,i),e.onSuccess&&e.onSuccess(a,n,s,o),t.onSuccess&&t.onSuccess(s,d.$el)})).catch((t=>{var i;i=String(t.msg||String(t)),n.innerText=i,n.classList.add("error"),e.onError&&e.onError(a,t,s,o);const c=setTimeout((()=>r()),3e3);l.onfocus=()=>{r(),clearTimeout(c)}})),!1})),d.setNo((()=>(this.close(e,i),t.onCancel&&t.onCancel(),!1))),r&&(l.style.display="none",d.$el.querySelector(".atk-layer-dialog-actions").style.display="none"),i.getEl().append(d.$el),t.onMount&&t.onMount(d.$el)}close(e,t){t.disposeNow(),this.launched=this.launched.filter((t=>t!==e))}}function nn(e,t,n,i){return d(this,null,(function*(){var s,r;if(gt.data.token){const e=new Headers(n.headers);e.set("Authorization",`Bearer ${gt.data.token}`),n.headers=e}const a=yield function(e,t,n,i){var s;const r=new AbortController;null==(s=i.signal)||s.addEventListener("abort",(()=>r.abort()));let a=fetch(t,l(o({},i),{signal:r.signal}));if(n>0){const e=setTimeout((()=>r.abort()),n);a.finally((()=>{clearTimeout(e)}))}return a=a.catch((e=>{throw"AbortError"===(e||{}).name?new Error(ut("reqAborted")):e})),a}(0,t,i||e.conf.reqTimeout||15e3,n),c=a.status,d=[401,400].includes(c);if(!a.ok&&!d)throw new Error(`${ut("reqGot")} ${c}`);let h=yield a.json();const u=(i,s)=>{nn(e,t,n).then((e=>{i(e)})).catch((e=>{s(e)}))};if((null==(s=h.data)?void 0:s.need_captcha)?h=yield new Promise(((t,n)=>{e.checkCaptcha({imgData:h.data.img_data,iframe:h.data.iframe,onSuccess:()=>{u(t,n)},onCancel:()=>{n(h)}})})):((null==(r=h.data)?void 0:r.need_login)||d)&&(h=yield new Promise(((t,n)=>{e.checkAdmin({onSuccess:()=>{u(t,n)},onCancel:()=>{n(h)}})}))),!h.success)throw h;return h}))}function sn(e){const t=new FormData;return Object.keys(e).forEach((n=>t.append(n,String(e[n])))),t}!function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n({user:e.data.user,is_login:e.data.is_login,unread:e.data.unread||[],unread_count:e.data.unread_count||0}))),abort:()=>{n.abort()}}}loginStatus(){return d(this,null,(function*(){return(yield this.POST("/login-status",{name:gt.data.nick,email:gt.data.email}))||{is_login:!1,is_admin:!1}}))}logout(){return d(this,null,(function*(){return this.POST("/logout")}))}markRead(e,t,n=!1){const i={comment_id:e,notify_key:t};return n&&(delete i.comment_id,delete i.notify_key,i.read_all=!0,i.name=gt.data.nick,i.email=gt.data.email),this.POST("/mark-read",i)}userList(e,t,n){return d(this,null,(function*(){const i={offset:e||0,limit:t||15};n&&(i.type=n);return yield this.POST("/admin/user-get",i)}))}userAdd(e,t){return d(this,null,(function*(){const n={name:e.name||"",email:e.email||"",password:t||"",link:e.link||"",is_admin:e.is_admin||!1,site_names:e.site_names_raw||"",receive_email:e.receive_email||!0,badge_name:e.badge_name||"",badge_color:e.badge_color||""};return(yield this.POST("/admin/user-add",n)).user}))}userEdit(e,t){return d(this,null,(function*(){const n={id:e.id,name:e.name||"",email:e.email||"",password:t||"",link:e.link||"",is_admin:e.is_admin||!1,site_names:e.site_names_raw||"",receive_email:e.receive_email||!0,badge_name:e.badge_name||"",badge_color:e.badge_color||""};return(yield this.POST("/admin/user-edit",n)).user}))}userDel(e){return this.POST("/admin/user-del",{id:String(e)})}},system:class extends rn{conf(){return d(this,null,(function*(){return Vt((yield this.POST("/conf")).frontend_conf||{})}))}getSettings(){return d(this,null,(function*(){return yield this.POST("/admin/setting-get")}))}saveSettings(e){return d(this,null,(function*(){return yield this.POST("/admin/setting-save",{data:e})}))}version(){return d(this,null,(function*(){const e=yield fetch(`${this.api.baseURL}/version`,{method:"POST"});return yield e.json()}))}},captcha:class extends rn{captchaGet(){return d(this,null,(function*(){return(yield this.POST("/captcha/refresh")).img_data||""}))}captchaCheck(e){return d(this,null,(function*(){return(yield this.POST("/captcha/check",{value:e})).img_data||""}))}captchaStatus(){return d(this,null,(function*(){return(yield this.POST("/captcha/status"))||{is_pass:!1}}))}},admin:class extends rn{cacheFlushAll(){return this.POST("/admin/cache-flush",{flush_all:!0})}cacheWarmUp(){return this.POST("/admin/cache-warm",{})}},upload:class extends rn{imgUpload(e){return d(this,null,(function*(){const t=sn({name:gt.data.nick,email:gt.data.email,page_key:this.ctx.conf.pageKey});t.set("file",e);const n={method:"POST",body:t};return(yield this.Fetch("/img-upload",n)).data||{}}))}}};class on{constructor(e){c(this,"ctx"),this.ctx=e,Object.entries(an).forEach((([e,t])=>{this[e]=new t(this,this.ctx)}))}get baseURL(){return`${this.ctx.conf.server}/api`}}function ln(e){const t={editor:e,isMoved:!1,move:e=>function(e,t){if(e.isMoved)return;e.isMoved=!0;const n=e.editor.getUI().$el;n.after(h('
      '));const i=h("
      ");t.after(i),i.replaceWith(n),n.classList.add("atk-fade-in")}(t,e),back:()=>function(e){var t;if(!e.isMoved)return;e.isMoved=!1,null==(t=e.editor.ctx.$root.querySelector(".atk-editor-travel-placeholder"))||t.replaceWith(e.editor.getUI().$el),e.editor.cancelReply()}(t)};return t}class cn{constructor(e){c(this,"editor"),c(this,"$panel"),c(this,"$btn"),c(this,"onHeaderInput"),c(this,"contentTransformer"),c(this,"onContentUpdated"),this.editor=e}get ctx(){return this.editor.ctx}registerPanel(e="
      "){return this.$panel=h(e),this.$panel}registerBtn(e){return this.$btn=h(`${e}`),this.$btn}registerHeaderInputEvt(e){this.onHeaderInput=e}registerContentTransformer(e){this.contentTransformer=e}registerContentUpdatedEvt(e){this.onContentUpdated=e}getPanel(){return this.$panel}getBtn(){return this.$btn}}c(cn,"Name");class dn extends cn{constructor(e){super(e),c(this,"emoticons",[]),c(this,"loadingTask",null),c(this,"$grpWrap"),c(this,"$grpSwitcher"),c(this,"isListLoaded",!1),c(this,"isImgLoaded",!1),this.editor=e,this.registerPanel('
      '),this.registerBtn(this.ctx.$t("emoticon")),this.registerContentTransformer((e=>this.transEmoticonImageText(e))),window.setTimeout((()=>{this.loadEmoticonsData()}),1e3)}onPanelShow(){(()=>{d(this,null,(function*(){yield this.loadEmoticonsData(),this.isImgLoaded||(this.initEmoticonsList(),this.isImgLoaded=!0),setTimeout((()=>{this.changeListHeight()}),30)}))})()}onPanelHide(){this.$panel.parentElement.style.height=""}loadEmoticonsData(){return d(this,null,(function*(){this.isListLoaded||(null===this.loadingTask?(this.loadingTask=(()=>d(this,null,(function*(){b(this.$panel),this.emoticons=yield this.handleData(this.ctx.conf.emoticons),w(this.$panel),this.loadingTask=null,this.isListLoaded=!0})))(),yield this.loadingTask):yield this.loadingTask)}))}handleData(e){return d(this,null,(function*(){if(!Array.isArray(e)&&["object","string"].includes(typeof e)&&(e=[e]),!Array.isArray(e))return E(this.$panel,"表情包数据必须为 Array/Object/String 类型"),w(this.$panel),[];const t=t=>{"object"==typeof t&&(t.name&&e.find((e=>e.name===t.name))||e.push(t))},n=e=>d(this,null,(function*(){yield Promise.all(e.map(((e,i)=>d(this,null,(function*(){if("object"!=typeof e||Array.isArray(e)){if(Array.isArray(e))yield n(e);else if("string"==typeof e){const i=yield this.remoteLoad(e);Array.isArray(i)?yield n(i):"object"==typeof i&&t(i)}}else t(e)})))))}));return yield n(e),e.forEach((e=>{if(this.isOwOFormat(e)){this.convertOwO(e).forEach((e=>{t(e)}))}else Array.isArray(e)&&e.forEach((e=>{t(e)}))})),e=e.filter((e=>"object"==typeof e&&!Array.isArray(e)&&!!e&&!!e.name)),this.solveNullKey(e),this.solveSameKey(e),e}))}remoteLoad(e){return d(this,null,(function*(){if(!e)return[];try{const t=yield fetch(e);return yield t.json()}catch(t){return w(this.$panel),E(this.$panel,`表情加载失败 ${String(t)}`),[]}}))}solveNullKey(e){e.forEach((e=>{e.items.forEach(((t,n)=>{t.key||(t.key=`${e.name} ${n+1}`)}))}))}solveSameKey(e){const t={};e.forEach((e=>{e.items.forEach((e=>{e.key&&""!==String(e.key).trim()&&(t[e.key]?t[e.key]++:t[e.key]=1,t[e.key]>1&&(e.key=`${e.key} ${t[e.key]}`))}))}))}isOwOFormat(e){try{return"object"==typeof e&&!!Object.values(e).length&&Array.isArray(Object.keys(Object.values(e)[0].container))&&Object.keys(Object.values(e)[0].container[0]).includes("icon")}catch(t){return!1}}convertOwO(e){const t=[];return Object.entries(e).forEach((([e,n])=>{const i={name:e,type:n.type,items:[]};n.container.forEach(((t,n)=>{const s=t.icon;if(/<(img|IMG)/.test(s)){const e=/src=["'](.*?)["']/.exec(s);e&&e.length>1&&(t.icon=e[1])}i.items.push({key:t.text||`${e} ${n+1}`,val:t.icon})})),t.push(i)})),t}initEmoticonsList(){this.$grpWrap=h('
      '),this.$panel.append(this.$grpWrap),this.emoticons.forEach(((e,t)=>{const n=h('');this.$grpWrap.append(n),n.setAttribute("data-index",String(t)),n.setAttribute("data-grp-name",e.name),n.setAttribute("data-type",e.type),e.items.forEach((t=>{const i=h('');if(n.append(i),t.key&&!new RegExp(`^(${e.name})?\\s?[0-9]+$`).test(t.key)&&i.setAttribute("title",t.key),"image"===e.type){const e=document.createElement("img");e.src=t.val,e.alt=t.key,i.append(e)}else i.innerText=t.val;i.onclick=()=>{"image"===e.type?this.editor.insertContent(`:[${t.key}]`):this.editor.insertContent(t.val||"")}}))})),this.emoticons.length>1&&(this.$grpSwitcher=h('
      '),this.$panel.append(this.$grpSwitcher),this.emoticons.forEach(((e,t)=>{const n=h("");n.innerText=e.name,n.setAttribute("data-index",String(t)),n.onclick=()=>this.openGrp(t),this.$grpSwitcher.append(n)}))),this.emoticons.length>0&&this.openGrp(0)}openGrp(e){var t,n,i;Array.from(this.$grpWrap.children).forEach((t=>{const n=t;n.getAttribute("data-index")!==String(e)?n.style.display="none":n.style.display=""})),null==(t=this.$grpSwitcher)||t.querySelectorAll("span.active").forEach((e=>e.classList.remove("active"))),null==(i=null==(n=this.$grpSwitcher)?void 0:n.querySelector(`span[data-index="${e}"]`))||i.classList.add("active"),this.changeListHeight()}changeListHeight(){}transEmoticonImageText(e){return this.emoticons&&Array.isArray(this.emoticons)?(this.emoticons.forEach((t=>{"image"===t.type&&Object.entries(t.items).forEach((([t,n])=>{e=e.split(`:[${n.key}]`).join(``)}))})),e):e}}c(dn,"Name","emoticons");class hn extends cn{constructor(e){super(e),c(this,"$imgUploadInput"),c(this,"allowImgExts",["png","jpg","jpeg","gif","bmp","svg","webp"]),this.$imgUploadInput=document.createElement("input"),this.$imgUploadInput.type="file",this.$imgUploadInput.style.display="none",this.$imgUploadInput.accept=this.allowImgExts.map((e=>`.${e}`)).join(",");const t=this.registerBtn(`${this.ctx.$t("image")}`);t.after(this.$imgUploadInput),t.onclick=()=>{const e=this.$imgUploadInput;e.onchange=()=>{(()=>{d(this,null,(function*(){if(!e.files||0===e.files.length)return;const t=e.files[0];this.uploadImg(t)}))})()},e.click()},this.ctx.conf.imgUpload||this.getBtn().setAttribute("atk-only-admin-show","");const n=e=>{if(e)for(let t=0;t{e.stopPropagation(),e.preventDefault()})),this.editor.getUI().$textarea.addEventListener("drop",(e=>{var t;const i=null==(t=e.dataTransfer)?void 0:t.files;(null==i?void 0:i.length)&&(e.preventDefault(),n(i))})),this.editor.getUI().$textarea.addEventListener("paste",(e=>{var t;const i=null==(t=e.clipboardData)?void 0:t.files;(null==i?void 0:i.length)&&(e.preventDefault(),n(i))}))}uploadImg(e){return d(this,null,(function*(){const t=/[^.]+$/.exec(e.name);if(!t||!this.allowImgExts.includes(t[0]))return;if(!gt.checkHasBasicUserInfo())return void this.editor.showNotify(this.ctx.$t("uploadLoginMsg"),"w");let n="\n";""===this.editor.getUI().$textarea.value.trim()&&(n="");const i=`${n}![](Uploading ${e.name}...)`;let s;this.editor.insertContent(i);try{s=this.ctx.conf.imgUploader?{img_url:yield this.ctx.conf.imgUploader(e)}:yield this.ctx.getApi().upload.imgUpload(e)}catch(r){console.error(r),this.editor.showNotify(`${this.ctx.$t("uploadFail")},${r.msg}`,"e")}if(s&&s.img_url){let e=s.img_url;y(e)||(e=$(this.ctx,e)),this.editor.setContent(this.editor.getUI().$textarea.value.replace(i,`${n}![](${e})`))}else this.editor.setContent(this.editor.getUI().$textarea.value.replace(i,""))}))}}c(hn,"Name","upload");class un extends cn{constructor(e){super(e),c(this,"isBind",!1),this.registerPanel('
      ');let t=this.editor.$t("preview");this.ctx.getMarkedInstance()&&(t+=' '),this.registerBtn(t),this.registerContentUpdatedEvt((e=>{this.updateContent()}))}onPanelShow(){if(this.updateContent(),!this.isBind){const e=()=>{this.updateContent()};this.editor.getUI().$textarea.addEventListener("input",e),this.editor.getUI().$textarea.addEventListener("change",e),this.isBind=!0}}updateContent(){"none"!==this.$panel.style.display&&(this.$panel.innerHTML=this.editor.getContentMarked())}}c(un,"Name","preview");class pn extends cn{constructor(e){super(e),c(this,"queryUserInfo",{timeout:null,abortFunc:null}),this.registerHeaderInputEvt(((e,t)=>{"nick"!==e&&"email"!==e||this.fetchUserInfo()})),this.editor.getUI().$link.addEventListener("change",(()=>{const e=this.editor.getUI().$link.value.trim();e&&!/^(http|https):\/\//.test(e)&&(this.editor.getUI().$link.value=`https://${e}`,gt.update({link:this.editor.getUI().$link.value}))}))}fetchUserInfo(){gt.logout(),this.queryUserInfo.timeout&&window.clearTimeout(this.queryUserInfo.timeout),this.queryUserInfo.abortFunc&&this.queryUserInfo.abortFunc(),this.queryUserInfo.timeout=window.setTimeout((()=>{this.queryUserInfo.timeout=null;const{req:e,abort:t}=this.ctx.getApi().user.userGet(gt.data.nick,gt.data.email);this.queryUserInfo.abortFunc=t,e.then((e=>{var t;e.is_login||gt.logout(),this.ctx.updateNotifies(e.unread),gt.checkHasBasicUserInfo()&&!e.is_login&&(null==(t=e.user)?void 0:t.is_admin)&&this.showLoginDialog(),e.user&&e.user.link&&(this.editor.getUI().$link.value=e.user.link,gt.update({link:e.user.link}))})).catch((()=>{})).finally((()=>{this.queryUserInfo.abortFunc=null}))}),400)}showLoginDialog(){this.ctx.checkAdmin({onSuccess:()=>{}})}}c(pn,"Name","headerInput");const gn=[dn,hn,un,pn];function mn(e){const t={editor:e,plugList:{},openedPlugName:null,openPlugPanel:e=>fn(t,e),closePlugPanel:()=>kn(t),triggerHeaderInputEvt:(e,n)=>function(e,t,n){Object.entries(e.plugList).forEach((([e,i])=>{i.onHeaderInput&&i.onHeaderInput(t,n)}))}(t,e,n),triggerContentUpdatedEvt:e=>function(e,t){Object.entries(e.plugList).forEach((([e,n])=>{n.onContentUpdated&&n.onContentUpdated(t)}))}(t,e),getTransformedContent:e=>function(e,t){let n=t;return Object.entries(e.plugList).forEach((([e,t])=>{t.contentTransformer&&(n=t.contentTransformer(n))})),n}(t,e)};e.getUI().$plugPanelWrap.innerHTML="",e.getUI().$plugPanelWrap.style.display="none",e.getUI().$plugBtnWrap.innerHTML="";const n=[{k:"upload",v:(i=e.conf).imgUpload},{k:"emoticons",v:i.emoticons},{k:"preview",v:i.preview}].filter((e=>!e.v)).flatMap((e=>e.k));var i;return gn.filter((e=>!n.includes(e.name))).forEach((e=>{!function(e,t){const n=t.Name,i=new t(e.editor);e.plugList[n]=i,function(e,t,n){const i=n.getBtn();if(!i)return;e.editor.getUI().$plugBtnWrap.appendChild(i),i.onclick=i.onclick||(()=>{e.editor.getUI().$plugBtnWrap.querySelectorAll(".active").forEach((e=>e.classList.remove("active"))),t!==e.openedPlugName?(fn(e,t),i.classList.add("active")):kn(e)});const s=n.getPanel();s&&(s.setAttribute("data-plug-name",t),s.style.display="none",e.editor.getUI().$plugPanelWrap.appendChild(s))}(e,n,i)}(t,e)})),t}function fn(e,t){Object.entries(e.plugList).forEach((([e,n])=>{const i=n.getPanel();i&&(e===t?(i.style.display="",n.onPanelShow&&n.onPanelShow()):(i.style.display="none",n.onPanelHide&&n.onPanelHide()))})),e.editor.getUI().$plugPanelWrap.style.display="",e.openedPlugName=t}function kn(e){if(!e.openedPlugName)return;const t=e.plugList[e.openedPlugName];t&&(t.onPanelHide&&t.onPanelHide(),e.editor.getUI().$plugPanelWrap.style.display="none",e.openedPlugName=null)}function yn(e){const t={editor:e,comment:void 0,setReply:(e,n,i)=>function(e,t,n,i=!0){e.editor.cancelEditComment(),$n(e);const s=e.editor.getUI();s.$sendReply||(s.$sendReply=h(`
      ${e.editor.$t("reply")} ×
      `),s.$sendReply.querySelector(".atk-text").innerText=`@${t.nick}`,s.$sendReply.addEventListener("click",(()=>{e.editor.cancelReply()})),s.$textareaWrap.append(s.$sendReply));e.comment=t,e.editor.travel(n),i&&C(s.$el);s.$textarea.focus()}(t,e,n,i),cancelReply:()=>$n(t)};return t}function $n(e){if(!e.comment)return;const t=e.editor.getUI();t.$sendReply&&(t.$sendReply.remove(),t.$sendReply=void 0),e.comment=void 0,e.editor.travelBack()}function xn(e){const t={editor:e,comment:void 0,setEdit:(e,n)=>function(e,t,n){vn(e),e.editor.cancelReply();const i=e.editor.getUI();if(!i.$editCancelBtn){const t=h(`
      ${e.editor.$t("editCancel")} ×
      `);t.onclick=()=>{vn(e)},i.$textareaWrap.append(t),i.$editCancelBtn=t}e.comment=t,i.$header.style.display="none",e.editor.travel(n),i.$nick.value=t.nick||"",i.$email.value=t.email||"",i.$link.value=t.link||"",e.editor.setContent(t.content),i.$textarea.focus(),e.editor.refreshSendBtnText()}(t,e,n),cancelEdit:()=>vn(t)};return function(e){e.editor.getSubmitManager().registerCustom({activeCond:()=>!!e.comment,req:()=>d(this,null,(function*(){const t={content:e.editor.getFinalContent(),nick:e.editor.getUI().$nick.value,email:e.editor.getUI().$email.value,link:e.editor.getUI().$link.value};return yield e.editor.ctx.getApi().comment.commentEdit(o(o({},e.comment),t))})),post:t=>{e.editor.ctx.updateComment(t)}})}(t),t}function vn(e){if(!e.comment)return;const t=e.editor.getUI();t.$editCancelBtn&&(t.$editCancelBtn.remove(),t.$editCancelBtn=void 0),e.comment=void 0,e.editor.travelBack();const{nick:n,email:i,link:s}=gt.data;t.$nick.value=n,t.$email.value=i,t.$link.value=s,e.editor.setContent(""),e.editor.refreshSendBtnText(),t.$header.style.display=""}function bn(e){const t={editor:e,do:()=>function(e){return d(this,null,(function*(){if(""===e.editor.getFinalContent().trim())return void e.editor.focus();const t=e.customs.find((e=>e.activeCond()));e.editor.ctx.trigger("editor-submit"),e.editor.showLoading();try{let n;(null==t?void 0:t.pre)&&t.pre(),n=(null==t?void 0:t.req)?yield t.req():yield function(e){return d(this,null,(function*(){const t=yield e.editor.ctx.getApi().comment.add(o({},function(e){var t;const{nick:n,email:i,link:s}=gt.data,r=e.editor.ctx.conf,a=null==(t=e.editor.getReplyManager())?void 0:t.comment;return{content:e.editor.getFinalContent(),nick:n,email:i,link:s,rid:a?a.id:0,page_key:a?a.page_key:r.pageKey,page_title:a?void 0:r.pageTitle,site_name:a?a.site_name:r.site}}(e)));return t}))}(e),(null==t?void 0:t.post)?t.post(n):function(e,t){const n=e.editor.getReplyManager(),i=e.editor.ctx.conf;(null==n?void 0:n.comment)&&n.comment.page_key!==i.pageKey&&window.open(`${n.comment.page_url}#atk-comment-${t.id}`);e.editor.ctx.insertComment(t)}(e,n)}catch(n){console.error(n),e.editor.showNotify(`${e.editor.$t("commentFail")},${n.msg||String(n)}`,"e")}e.editor.reset(),e.editor.ctx.trigger("editor-submitted"),e.editor.hideLoading()}))}(t),customs:[],registerCustom:e=>{t.customs.push(e)}};return t}const wn={localStorage:function(e){const t=window.localStorage.getItem("ArtalkContent")||"";""!==t.trim()&&(e.showNotify(e.$t("restoredMsg"),"i"),e.setContent(t));e.getUI().$textarea.addEventListener("input",(()=>e.saveToLocalStorage()))},header:function(e){const t=e.getHeaderInputEls();Object.entries(t).forEach((([t,n])=>{n.value=gt.data[t]||"",n.addEventListener("input",(()=>function(e,t,n){var i;if(e.isEditMode)return;gt.update({[t]:n.value.trim()}),null==(i=e.getPlugs())||i.triggerHeaderInputEvt(t,n)}(e,t,n))),n.placeholder=`${e.$t(t)}`}))},textarea:function(e){e.getUI().$textarea.placeholder=e.ctx.conf.placeholder||e.$t("placeholder"),e.getUI().$textarea.addEventListener("keydown",(t=>{9===(t.keyCode||t.which)&&(t.preventDefault(),e.insertContent("\t"))})),e.getUI().$textarea.addEventListener("input",(()=>{e.adjustTextareaHeight()}))},submitBtn:function(e){e.refreshSendBtnText(),e.getUI().$submitBtn.addEventListener("click",(()=>e.submit()))},submitManager:function(e){e.setSubmitManager(bn(e))},plugs:function(e){e.setPlugs(mn(e))},mover:function(e){if(!e.conf.editorTravel)return;e.setMover(ln(e))},replyManager:function(e){e.setReplyManager(yn(e))},editModeManager:function(e){e.setEditModeManager(xn(e))}};const Cn='
      \n
      \n \n \n \n
      \n
      \n \n
      \n \n
      \n
      \n
      \n \n
      \n
      \n
      \n
      \n',Sn={$header:".atk-header",$nick:'.atk-header [name="nick"]',$email:'.atk-header [name="email"]',$link:'.atk-header [name="link"]',$textareaWrap:".atk-textarea-wrap",$textarea:".atk-textarea",$bottom:".atk-bottom",$submitBtn:".atk-send-btn",$notifyWrap:".atk-notify-wrap",$plugBtnWrap:".atk-plug-btn-wrap",$plugPanelWrap:".atk-plug-panel-wrap"};class Tn extends v{constructor(e){super(e),c(this,"ui"),c(this,"plugs"),c(this,"mover"),c(this,"reply"),c(this,"editMode"),c(this,"submitManager"),this.ui=function(){const e=h(Cn),t={$el:e};return Object.entries(Sn).forEach((([n,i])=>{t[n]=e.querySelector(i)})),t}(),this.$el=this.ui.$el,this.ctx.on("conf-loaded",(()=>{var e;e=this,Object.entries(wn).forEach((([t,n])=>{n(e)}))}))}getUI(){return this.ui}getPlugs(){return this.plugs}setPlugs(e){this.plugs=e}setMover(e){this.mover=e}setReplyManager(e){this.reply=e}getReplyManager(){return this.reply}get isReplyMode(){var e;return!!(null==(e=this.reply)?void 0:e.comment)}setEditModeManager(e){this.editMode=e}get isEditMode(){var e;return!!(null==(e=this.editMode)?void 0:e.comment)}setSubmitManager(e){this.submitManager=e}getSubmitManager(){return this.submitManager}getHeaderInputEls(){return{nick:this.ui.$nick,email:this.ui.$email,link:this.ui.$link}}saveToLocalStorage(){window.localStorage.setItem("ArtalkContent",this.getContentOriginal().trim())}refreshSendBtnText(){this.isEditMode?this.ui.$submitBtn.innerText=this.$t("save"):this.ui.$submitBtn.innerText=this.ctx.conf.sendBtn||this.$t("send")}getFinalContent(){let e=this.getContentOriginal();return this.plugs&&(e=this.plugs.getTransformedContent(e)),e}getContentOriginal(){return this.ui.$textarea.value||""}getContentMarked(){return st(this.ctx,this.getFinalContent())}setContent(e){this.ui.$textarea.value=e,this.saveToLocalStorage(),this.plugs&&this.plugs.triggerContentUpdatedEvt(e),window.setTimeout((()=>{this.adjustTextareaHeight()}),80)}insertContent(e){if(document.selection)this.ui.$textarea.focus(),document.selection.createRange().text=e,this.ui.$textarea.focus();else if(this.ui.$textarea.selectionStart||0===this.ui.$textarea.selectionStart){const t=this.ui.$textarea.selectionStart,n=this.ui.$textarea.selectionEnd,i=this.ui.$textarea.scrollTop;this.setContent(this.ui.$textarea.value.substring(0,t)+e+this.ui.$textarea.value.substring(n,this.ui.$textarea.value.length)),this.ui.$textarea.focus(),this.ui.$textarea.selectionStart=t+e.length,this.ui.$textarea.selectionEnd=t+e.length,this.ui.$textarea.scrollTop=i}else this.ui.$textarea.focus(),this.ui.$textarea.value+=e}adjustTextareaHeight(){const e=this.ui.$textarea.offsetHeight-this.ui.$textarea.clientHeight;this.ui.$textarea.style.height="0px",this.ui.$textarea.style.height=`${this.ui.$textarea.scrollHeight+e}px`}focus(){this.ui.$textarea.focus()}reset(){this.setContent(""),this.cancelReply(),this.cancelEditComment()}setReply(e,t,n=!0){var i;null==(i=this.reply)||i.setReply(e,t,n)}cancelReply(){var e;null==(e=this.reply)||e.cancelReply()}setEditComment(e,t){var n;null==(n=this.editMode)||n.setEdit(e,t)}cancelEditComment(){var e;null==(e=this.editMode)||e.cancelEdit()}showNotify(e,t){S(this.ui.$notifyWrap,e,t)}showLoading(){b(this.ui.$el)}hideLoading(){w(this.ui.$el)}submit(){return d(this,null,(function*(){this.submitManager&&(yield this.submitManager.do())}))}close(){this.ui.$textareaWrap.querySelector(".atk-comment-closed")||this.ui.$textareaWrap.prepend(h(`
      ${this.$t("onlyAdminCanReply")}
      `)),gt.data.isAdmin?(this.ui.$textarea.style.display="",this.ui.$bottom.style.display=""):(this.ui.$textarea.style.display="none",this.closePlugPanel(),this.ui.$bottom.style.display="none")}open(){var e;null==(e=this.ui.$textareaWrap.querySelector(".atk-comment-closed"))||e.remove(),this.ui.$textarea.style.display="",this.ui.$bottom.style.display=""}travel(e){var t;null==(t=this.mover)||t.move(e)}travelBack(){var e;null==(e=this.mover)||e.back()}openPlugPanel(e){var t;null==(t=this.plugs)||t.openPlugPanel(e)}closePlugPanel(){var e;null==(e=this.plugs)||e.closePlugPanel()}}class En extends v{constructor(e){super(e),c(this,"layer"),c(this,"$header"),c(this,"$closeBtn"),c(this,"$iframeWrap"),c(this,"$iframe"),c(this,"firstShow",!0),this.$el=h('
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n'),this.$header=this.$el.querySelector(".atk-sidebar-header"),this.$closeBtn=this.$header.querySelector(".atk-sidebar-close"),this.$iframeWrap=this.$el.querySelector(".atk-sidebar-iframe-wrap"),this.$closeBtn.onclick=()=>{this.hide()},this.ctx.on("user-changed",(()=>{this.firstShow=!0}))}show(){return d(this,arguments,(function*(e={}){if(this.$el.style.transform="",null==this.layer&&(this.layer=new _(this.ctx,"sidebar",this.$el),this.layer.afterHide=()=>{!0===this.ctx.conf.editorTravel&&this.ctx.editorTravelBack()}),this.layer.show(),(()=>{d(this,null,(function*(){var t;const n=yield this.ctx.getApi().user.loginStatus();n.is_admin&&!n.is_login&&(null==(t=this.layer)||t.hide(),this.firstShow=!0,this.ctx.checkAdmin({onSuccess:()=>{setTimeout((()=>{this.show(e)}),500)},onCancel:()=>{}}))}))})(),this.firstShow){this.$iframeWrap.innerHTML="",this.$iframe=h("");const t=$(this.ctx,"/sidebar/"),n={pageKey:this.conf.pageKey,site:this.conf.site||"",user:JSON.stringify(gt.data),time:+new Date};e.view&&(n.view=e.view),this.conf.darkMode&&(n.darkMode="1"),"string"==typeof this.conf.locale&&(n.locale=this.conf.locale);const i=new URLSearchParams(n);this.iframeLoad(`${t}?${i.toString()}`),this.$iframeWrap.append(this.$iframe),this.firstShow=!1}else{const e=this.$iframe.src.includes("darkMode=1");this.conf.darkMode&&!e&&this.iframeLoad(`${this.$iframe.src}&darkMode=1`),!this.conf.darkMode&&e&&this.iframeLoad(this.$iframe.src.replace("&darkMode=1",""))}setTimeout((()=>{this.$el.style.transform="translate(0, 0)"}),100),setTimeout((()=>{this.ctx.updateNotifies([])}),0),this.ctx.trigger("sidebar-show")}))}hide(){var e;this.$el.style.transform="",null==(e=this.layer)||e.hide(),this.ctx.trigger("sidebar-hide")}iframeLoad(e){this.$iframe&&(this.$iframe.src=e,b(this.$iframeWrap),this.$iframe.onload=()=>{w(this.$iframeWrap)})}}const Ln={i18n(e){ht(e.conf.locale),e.on("conf-loaded",(()=>{ht(e.conf.locale)}))},markdown(){!function(){try{if(!$e.name)return}catch(i){return}const e=new $e.Renderer,t=e.link;e.link=(n,i,s)=>{const r=null==n?void 0:n.startsWith(`${window.location.protocol}//${window.location.hostname}`);return t.call(e,n,i,s).replace(/^{const n=t||"plaintext";let i=e;return window.hljs?n&&window.hljs.getLanguage(n)&&(i=window.hljs.highlight(n,e).value):i=tt(e),`
      \n${i.replace(/&/g,"&")}\n
      `};const n=$e;$e.setOptions({renderer:e,pedantic:!1,gfm:!0,breaks:!0,smartLists:!0,smartypants:!0,xhtml:!1,sanitize:!1,silent:!0}),nt=n}()},user:e=>(gt.setContext(e),gt),api:e=>new on(e),checkerLauncher:e=>new tn(e),editor(e){const t=new Tn(e);return e.$root.appendChild(t.$el),t},list(e){const t=new Gt(e);return e.$root.appendChild(t.$el),t.fetchComments(0),t},layer(e){_.BodyOrgOverflow=document.body.style.overflow,_.BodyOrgPaddingRight=document.body.style.paddingRight},sidebarLayer:e=>new En(e),eventsDefault(e){window.addEventListener("hashchange",(()=>{e.listHashGotoCheck()})),e.on("user-changed",(()=>{e.checkAdminShowEl(),e.listRefreshUI()}))},darkMode(e){R(e),e.on("conf-loaded",(()=>{R(e)}))}};function _n(e){return d(this,null,(function*(){const t=e.ctx.conf.countEl;t&&document.querySelector(t)&&An(e,{api:"page_comment",countEl:t});const n=e.pvAdd?yield e.ctx.getApi().page.pv():void 0,i=e.ctx.conf.pvEl;i&&document.querySelector(i)&&An(e,{api:"page_pv",countEl:i,curtPageCount:n})}))}function An(e,t){return d(this,null,(function*(){let n={};const i=e.ctx.conf.pageKey;t.curtPageCount&&(n[i]=t.curtPageCount);let s=Array.from(document.querySelectorAll(t.countEl)).map((e=>e.getAttribute("data-page-key")||i)).filter((e=>void 0===n[e]));if(s=[...new Set(s)],s.length>0){const i=yield e.ctx.getApi().page.stat(t.api,s);n=o(o({},n),i)}document.querySelectorAll(t.countEl).forEach((e=>{const t=e.getAttribute("data-page-key")||i;e.innerHTML=`${Number(n[t]||0)}`}))}))}const On=class{constructor(e){c(this,"conf"),c(this,"ctx"),c(this,"$root"),On.instance&&On.destroy(),this.conf=Qt(e),this.conf.el instanceof HTMLElement&&(this.$root=this.conf.el),this.ctx=new Kt(this.conf,this.$root),Object.entries(Ln).forEach((([e,t])=>{if(On.DisabledComponents.includes(e))return;const n=t(this.ctx);n&&this.ctx.inject(e,n)})),On.plugins.forEach((e=>{"function"==typeof e&&e(this.ctx)}))}static init(e){return this.instance&&On.destroy(),this.instance=new On(e),this.instance}use(e){On.plugins.push(e),"function"==typeof e&&e(this.ctx)}update(e){if(!On.instance)throw Error("cannot call `update` function before call `load`");return On.instance.ctx.updateConf(e),On.instance}reload(){this.ctx.listReload()}destroy(){if(!On.instance)throw Error("cannot call `destroy` function before call `load`");On.instance.$root.remove(),delete On.instance}on(e,t){this.ctx.on(e,t,"external")}off(e,t){this.ctx.off(e,t,"external")}trigger(e,t){this.ctx.trigger(e,t,"external")}setDarkMode(e){this.ctx.setDarkMode(e)}static use(e){this.plugins.push(e),this.instance&&"function"==typeof e&&e(this.instance.ctx)}static update(e){var t;return null==(t=this.instance)?void 0:t.update(e)}static reload(){var e;null==(e=this.instance)||e.reload()}static destroy(){var e;null==(e=this.instance)||e.destroy()}static on(e,t){var n;null==(n=this.instance)||n.on(e,t)}static off(e,t){var n;null==(n=this.instance)||n.off(e,t)}static trigger(e,t){var n;null==(n=this.instance)||n.trigger(e,t)}static setDarkMode(e){var t;null==(t=this.instance)||t.setDarkMode(e)}static loadCountWidget(e){const t=new Kt(Qt(e));t.inject("api",new on(t)),_n({ctx:t,pvAdd:!1})}static LoadCountWidget(e){console.warn("The method `LoadCountWidget` is deprecated, please use `loadCountWidget` instead."),this.loadCountWidget(e)}};let Mn=On;return c(Mn,"instance"),c(Mn,"ListLite",Zt),c(Mn,"defaults",Ht),c(Mn,"plugins",[e=>{e.conf.useBackendConf?e.on("list-loaded",(()=>{_n({ctx:e,pvAdd:!0})})):_n({ctx:e,pvAdd:!0})}]),c(Mn,"DisabledComponents",[]),Mn}));