!function(e,t){if("function"==typeof define&&define.amd)define("Waline",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var n={exports:{}};t(n.exports),e.Waline=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.version=e.pageviewCount=e.init=e.defaultLocales=e.commentCount=e.RecentComments=void 0;const t=["nick","mail","link"],n=e=>e.filter((e=>t.includes(e))),o="zh-CN",r=e=>new Promise(((t,n)=>{const o=new FileReader;o.readAsDataURL(e),o.onload=()=>{var e;return t((null===(e=o.result)||void 0===e?void 0:e.toString())||"")},o.onerror=n})),l=e=>!0===e?'
Tex is not available in preview
':'Tex is not available in preview',i=new RegExp("(".concat(/[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/.source,"|").concat(/{let t=0;return e.replace(i,((e,n,o)=>{if(o)return''.concat(o,"");if("<"===n)return"<";let r;u[n]?r=u[n]:(r=s[t],u[n]=r);const l='').concat(n,"");return t=++t%s.length,l}))},c=["nick","nickError","mail","mailError","link","optional","placeholder","sofa","submit","like","cancelLike","reply","cancelReply","comment","refresh","more","preview","emoji","uploadImage","seconds","minutes","hours","days","now","uploading","login","logout","admin","sticky","word","wordHint","anonymous","level0","level1","level2","level3","level4","level5","gif","gifSearchPlaceholder"],p=e=>Object.fromEntries(e.map(((e,t)=>[c[t],e])));var d=p(["NickName","NickName cannot be less than 3 bytes.","E-Mail","Please confirm your email address.","Website","Optional","Comment here...","No comment yet.","Submit","Like","Cancel like","Reply","Cancel reply","Comments","Refresh","Load More...","Preview","Emoji","Upload Image","seconds ago","minutes ago","hours ago","days ago","just now","Uploading","Login","logout","Admin","Sticky","Words","Please input comments between $0 and $1 words!\n Current word number: $2","Anonymous","Dwarves","Hobbits","Ents","Wizards","Elves","Maiar","GIF","Search GIF"]),h=p(["ニックネーム","3バイト以上のニックネームをご入力ください.","メールアドレス","メールアドレスをご確認ください.","サイト","オプション","ここにコメント","コメントしましょう~","提出する","Like","Cancel like","返信する","キャンセル","コメント","更新","さらに読み込む","プレビュー","絵文字","画像をアップロード","秒前","分前","時間前","日前","たっだ今","アップロード","ログインする","ログアウト","管理者","トップに置く","ワード","コメントは $0 から $1 ワードの間でなければなりません!\n 現在の単語番号: $2","匿名","うえにん","なかにん","しもおし","特にしもおし","かげ","なぬし","GIF","探す GIF"]),f=p(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","喜欢","取消喜欢","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字","评论字数应在 $0 到 $1 字之间!\n当前字数:$2","匿名","潜水","冒泡","吐槽","活跃","话痨","传说","表情包","搜索表情包"]),g=p(["暱稱","郵箱","網址","可選","暱稱不能少於3個字元","請填寫正確的郵件地址","歡迎評論","來發評論吧~","提交","喜歡","取消喜歡","回覆","取消回覆","評論","刷新","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登錄","退出","博主","置頂","字","評論字數應在 $0 到 $1 字之間!\n當前字數:$2","匿名","潛水","冒泡","吐槽","活躍","話癆","傳說","表情包","搜索表情包"]),m=p(["Apelido","Apelido não pode ser menor que 3 bytes.","E-Mail","Por favor, confirme seu endereço de e-mail.","Website","Opcional","Comente aqui...","Nenhum comentário, ainda.","Enviar","Like","Cancel like","Responder","Cancelar resposta","Comentários","Refrescar","Carregar Mais...","Visualizar","Emoji","Enviar Imagem","segundos atrás","minutos atrás","horas atrás","dias atrás","agora mesmo","Enviando","Entrar","Sair","Admin","Sticky","Palavras","Favor enviar comentário com $0 a $1 palavras!\n Número de palavras atuais: $2","Anônimo","Dwarves","Hobbits","Ents","Wizards","Elves","Maiar","GIF","Pesquisar GIF"]),v=p(["Псевдоним","Никнейм не может быть меньше 3 байт.","Эл. адрес","Пожалуйста, подтвердите адрес вашей электронной почты.","Веб-сайт","Необязательный","Комментарий здесь...","Пока нет комментариев.","Отправить","Like","Cancel like","Отвечать","Отменить ответ","Комментарии","Обновить","Загрузи больше...","Превью","эмодзи","Загрузить изображение","секунд назад","несколько минут назад","несколько часов назад","дней назад","прямо сейчас","Загрузка","Авторизоваться","Выход из системы","Админ","Липкий","Слова","Пожалуйста, введите комментарии от $0 до $1 слов!\nНомер текущего слова: $2","Анонимный","Dwarves","Hobbits","Ents","Wizards","Elves","Maiar","GIF","Поиск GIF"]);const y={zh:f,"zh-cn":f,"zh-CN":f,"zh-tw":g,"zh-TW":g,en:d,"en-US":d,"en-us":d,jp:h,"jp-jp":h,"jp-JP":h,"pt-br":m,"pt-BR":m,ru:v,"ru-ru":v,"ru-RU":v};function w(e,t){const n=Object.create(null),o=e.split(",");for(let e=0;ec?Z(e,r,l,!0,!1,p):E(t,n,o,r,l,i,s,u,p)},M=(e,t,n,o,r,l,i,s,u)=>{let a=0;const c=t.length;let p=e.length-1,d=c-1;for(;a<=p&&a<=d;){const o=e[a],c=t[a]=u?Ho(t[a]):Vo(t[a]);if(!Ro(o,c))break;g(o,c,n,null,r,l,i,s,u),a++}for(;a<=p&&a<=d;){const o=e[p],a=t[d]=u?Ho(t[d]):Vo(t[d]);if(!Ro(o,a))break;g(o,a,n,null,r,l,i,s,u),p--,d--}if(a>p){if(a<=d){const e=d+1,p=e ".concat(e," An error occurred:
\n":"'+(n?e:yi(e,!0))+"
\n"}blockquote(e){return""+(n?e:yi(e,!0))+"
\n".concat(e,"
\n")}html(e){return e}heading(e,t,n,o){if(this.options.headerIds){const r=this.options.headerPrefix+o.slug(n);return"
\n":"
\n"}list(e,t,n){const o=t?"ol":"ul";return"<"+o+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+""+o+">\n"}listitem(e){return"\n\n"+e+"\n"+t+"
\n"}tablerow(e){return"\n".concat(e," \n")}tablecell(e,t){const n=t.header?"th":"td";return(t.align?"<".concat(n,' align="').concat(t.align,'">'):"<".concat(n,">"))+e+"".concat(n,">\n")}strong(e){return"".concat(e,"")}em(e){return"".concat(e,"")}codespan(e){return"".concat(e,"
")}br(){return this.options.xhtml?"
":"
"}del(e){return"".concat(e,"")}link(e,t,n){if(null===(e=Ci(this.options.sanitize,this.options.baseUrl,e)))return n;let o='"+n+"",o}image(e,t,n){if(null===(e=Ci(this.options.sanitize,this.options.baseUrl,e)))return n;let o='":">",o}text(e){return e}}class Hi{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 Wi{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,o=0;if(this.seen.hasOwnProperty(n)){o=this.seen[e];do{o++,n=e+"-"+o}while(this.seen.hasOwnProperty(n))}return t||(this.seen[e]=o,this.seen[n]=0),n}slug(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.serialize(e);return this.getNextSafeSlug(n,t.dryrun)}}class qi{constructor(e){this.options=e||pi,this.options.renderer=this.options.renderer||new Vi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Hi,this.slugger=new Wi}static parse(e,t){return new qi(t).parse(e)}static parseInline(e,t){return new qi(t).parseInline(e)}parse(e){let t,n,o,r,l,i,s,u,a,c,p,d,h,f,g,m,v,y,w,k=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],b="";const A=e.length;for(t=0;t0&&"paragraph"===g.tokens[0].type?(g.tokens[0].text=y+" "+g.tokens[0].text,g.tokens[0].tokens&&g.tokens[0].tokens.length>0&&"text"===g.tokens[0].tokens[0].type&&(g.tokens[0].tokens[0].text=y+" "+g.tokens[0].tokens[0].text)):g.tokens.unshift({type:"text",text:y}):f+=y),f+=this.parse(g.tokens,h),a+=this.renderer.listitem(f,v,m);b+=this.renderer.list(a,p,d);continue;case"html":b+=this.renderer.html(c.text);continue;case"paragraph":b+=this.renderer.paragraph(this.parseInline(c.tokens));continue;case"text":for(a=c.tokens?this.parseInline(c.tokens):c.text;t+1{o(e.text,e.lang,(function(t,n){if(t)return l(t);null!=n&&n!==e.text&&(e.text=n,e.escaped=!0),i--,0===i&&l()}))}),0))})),void(0===i&&l())}try{const n=Ni.lex(e,t);return t.walkTokens&&Zi.walkTokens(n,t.walkTokens),qi.parse(n,t)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return""+yi(e.message+"",!0)+"
";throw e}}Zi.options=Zi.setOptions=function(e){var t;return Ii(Zi.defaults,e),t=Zi.defaults,pi=t,Zi},Zi.getDefaults=ci,Zi.defaults=pi,Zi.use=function(){for(var e=arguments.length,t=new Array(e),n=0;n
"+yi(e.message+"",!0)+"";throw e}},Zi.Parser=qi,Zi.parser=qi.parse,Zi.Renderer=Vi,Zi.TextRenderer=Hi,Zi.Lexer=Ni,Zi.lexer=Ni.lex,Zi.Tokenizer=$i,Zi.Slugger=Wi,Zi.parse=Zi;const Gi=/\$.*?\$/,Ji=/^\$(.*?)\$/,Ki=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,Qi=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.replace(/:(.+?):/g,((e,n)=>t[n]?''):e))},Yi=(e,t)=>{let{emojiMap:n,highlighter:o,texRenderer:r}=t;if(Zi.setOptions({highlight:o||void 0,breaks:!0,smartLists:!0,smartypants:!0}),r){const e=(e=>[{name:"blockMath",level:"block",tokenizer(t){const n=Ki.exec(t);if(null!==n)return{type:"html",raw:n[0],text:e(!0,n[1])}}},{name:"inlineMath",level:"inline",start(e){const t=e.search(Gi);return-1!==t?t:e.length},tokenizer(t){const n=Ji.exec(t);if(null!==n)return{type:"html",raw:n[0],text:e(!1,n[1])}}}])(r);Zi.use({extensions:e})}return Zi.parse(Qi(e,n))},Xi=e=>e.dataset.path||e.getAttribute("id"),es=e=>{let{key:t,keyword:n,pos:o,limit:r}=e;const l=new URLSearchParams("media_filter=minimal");return l.set("key",t||"PAY5JLFIH6V6"),l.set("limit",(r||20).toString()),l.set("pos",o||""),l.set("q",n),fetch("".concat("https://g.tenor.com/v1/search","?").concat(l.toString()),{headers:{"Content-Type":"application/json"}}).then((e=>e.json()))},ts=(e,t)=>{const n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{controls:t=!1,interval:n="requestAnimationFrame"}=e,o=jt(new Date),r=()=>o.value=new Date,l="requestAnimationFrame"===n?Tl(r,{immediate:!0}):ul(r,n,{immediate:!0});return t?Nl({now:o},l):o}();return sr((()=>Yl(e,n.value,t)))};let ns=null;const os=()=>ns||(ns=jl("USER_KEY",{}));let rs=null;const ls=()=>rs||(rs=jl("WALINE_LIKE",[])),is=e=>{var t;let{serverURL:n,path:o=window.location.pathname,selector:r=".waline-comment-count",lang:l="zh-CN"}=e;const i=new AbortController,s=document.querySelectorAll(r),u=os();return s.length&&(e=>{let{serverURL:t,lang:n,paths:o,signal:r,token:l}=e;const i={};return l&&(i.Authorization="Bearer ".concat(l)),fetch("".concat(t,"/comment?type=count&url=").concat(encodeURIComponent(o.join(",")),"&lang=").concat(n),{signal:r,headers:i}).then((e=>e.json())).then((e=>oi(e,"comment count"))).then((e=>Array.isArray(e)?e:[e]))})({serverURL:n,paths:Array.from(s).map((e=>Hl(e.dataset.path||e.getAttribute("id")||o))),lang:l,signal:i.signal,token:null===(t=u.value)||void 0===t?void 0:t.token}).then((e=>{s.forEach(((t,n)=>{t.innerText=e[n].toString()}))})).catch(ti),i.abort.bind(i)};e.commentCount=is;var ss,us,as="function"==typeof Map?new Map:(ss=[],us=[],{has:function(e){return ss.indexOf(e)>-1},get:function(e){return us[ss.indexOf(e)]},set:function(e,t){-1===ss.indexOf(e)&&(ss.push(e),us.push(t))},delete:function(e){var t=ss.indexOf(e);t>-1&&(ss.splice(t,1),us.splice(t,1))}}),cs=function(e){return new Event(e,{bubbles:!0})};try{new Event("test")}catch(ss){cs=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t}}function ps(e){var t=as.get(e);t&&t.destroy()}function ds(e){var t=as.get(e);t&&t.update()}var hs=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((hs=function(e){return e}).destroy=function(e){return e},hs.update=function(e){return e}):((hs=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],(function(e){return function(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!as.has(e)){var t,n=null,o=null,r=null,l=function(){e.clientWidth!==o&&a()},i=function(t){window.removeEventListener("resize",l,!1),e.removeEventListener("input",a,!1),e.removeEventListener("keyup",a,!1),e.removeEventListener("autosize:destroy",i,!1),e.removeEventListener("autosize:update",a,!1),Object.keys(t).forEach((function(n){e.style[n]=t[n]})),as.delete(e)}.bind(e,{height:e.style.height,resize:e.style.resize,overflowY:e.style.overflowY,overflowX:e.style.overflowX,wordWrap:e.style.wordWrap});e.addEventListener("autosize:destroy",i,!1),"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",a,!1),window.addEventListener("resize",l,!1),e.addEventListener("input",a,!1),e.addEventListener("autosize:update",a,!1),e.style.overflowX="hidden",e.style.wordWrap="break-word",as.set(e,{destroy:i,update:a}),"vertical"===(t=window.getComputedStyle(e,null)).resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal"),n="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),isNaN(n)&&(n=0),a()}function s(t){var n=e.style.width;e.style.width="0px",e.style.width=n,e.style.overflowY=t}function u(){if(0!==e.scrollHeight){var t=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push({node:e.parentNode,scrollTop:e.parentNode.scrollTop}),e=e.parentNode;return t}(e),r=document.documentElement&&document.documentElement.scrollTop;e.style.height="",e.style.height=e.scrollHeight+n+"px",o=e.clientWidth,t.forEach((function(e){e.node.scrollTop=e.scrollTop})),r&&(document.documentElement.scrollTop=r)}}function a(){u();var t=Math.round(parseFloat(e.style.height)),n=window.getComputedStyle(e,null),o="content-box"===n.boxSizing?Math.round(parseFloat(n.height)):e.offsetHeight;if(o