@waline/client 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>{"AbortError"!==e.name&&console.error(e.message)},t=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},r=({serverURL:e,paths:r,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(r.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>t(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),n=({serverURL:e,path:r})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})}).then((e=>e.json())).then((e=>t(e,"visit count"))),o=e=>e.dataset.path||e.getAttribute("id"),a=(e,t)=>{t.forEach(((t,r)=>{t.innerText=e[r].toString()}))};exports.pageviewCount=({serverURL:t,path:s=window.location.pathname,selector:i=".waline-pageview-count",update:l=!0})=>{const h=new AbortController,c=Array.from(document.querySelectorAll(i)),p=e=>{const t=o(e);return null!==t&&s!==t},u=n=>r({serverURL:t,paths:n.map((e=>o(e)||s)),signal:h.signal}).then((e=>a(e,n))).catch(e);if(l){const e=c.filter((e=>!p(e))),r=c.filter(p);n({serverURL:t,path:s}).then((t=>a(new Array(e.length).fill(t),e))),r.length&&u(r)}else u(c);return h.abort.bind(h)},exports.version="2.0.4";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>{"AbortError"!==e.name&&console.error(e.message)},t=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},r=({serverURL:e,paths:r,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(r.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>t(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),n=({serverURL:e,path:r})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})}).then((e=>e.json())).then((e=>t(e,"visit count"))),o=e=>e.dataset.path||e.getAttribute("id"),a=(e,t)=>{t.forEach(((t,r)=>{t.innerText=e[r].toString()}))};exports.pageviewCount=({serverURL:t,path:s=window.location.pathname,selector:i=".waline-pageview-count",update:l=!0})=>{const h=new AbortController,c=Array.from(document.querySelectorAll(i)),p=e=>{const t=o(e);return null!==t&&s!==t},u=n=>r({serverURL:t,paths:n.map((e=>o(e)||s)),signal:h.signal}).then((e=>a(e,n))).catch(e);if(l){const e=c.filter((e=>!p(e))),r=c.filter(p);n({serverURL:t,path:s}).then((t=>a(new Array(e.length).fill(t),e))),r.length&&u(r)}else u(c);return h.abort.bind(h)},exports.version="2.0.5";
2
2
  //# sourceMappingURL=pageview.cjs.js.map
@@ -1,2 +1,2 @@
1
- const e="2.0.4",t=e=>{"AbortError"!==e.name&&console.error(e.message)},r=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},n=({serverURL:e,paths:t,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>r(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),o=({serverURL:e,path:t})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})}).then((e=>e.json())).then((e=>r(e,"visit count"))),a=e=>e.dataset.path||e.getAttribute("id"),i=(e,t)=>{t.forEach(((t,r)=>{t.innerText=e[r].toString()}))},s=({serverURL:e,path:r=window.location.pathname,selector:s=".waline-pageview-count",update:h=!0})=>{const l=new AbortController,c=Array.from(document.querySelectorAll(s)),p=e=>{const t=a(e);return null!==t&&r!==t},f=o=>n({serverURL:e,paths:o.map((e=>a(e)||r)),signal:l.signal}).then((e=>i(e,o))).catch(t);if(h){const t=c.filter((e=>!p(e))),n=c.filter(p);o({serverURL:e,path:r}).then((e=>i(new Array(t.length).fill(e),t))),n.length&&f(n)}else f(c);return l.abort.bind(l)};export{s as pageviewCount,e as version};
1
+ const e="2.0.5",t=e=>{"AbortError"!==e.name&&console.error(e.message)},r=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},n=({serverURL:e,paths:t,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>r(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),o=({serverURL:e,path:t})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})}).then((e=>e.json())).then((e=>r(e,"visit count"))),a=e=>e.dataset.path||e.getAttribute("id"),i=(e,t)=>{t.forEach(((t,r)=>{t.innerText=e[r].toString()}))},s=({serverURL:e,path:r=window.location.pathname,selector:s=".waline-pageview-count",update:h=!0})=>{const l=new AbortController,c=Array.from(document.querySelectorAll(s)),p=e=>{const t=a(e);return null!==t&&r!==t},f=o=>n({serverURL:e,paths:o.map((e=>a(e)||r)),signal:l.signal}).then((e=>i(e,o))).catch(t);if(h){const t=c.filter((e=>!p(e))),n=c.filter(p);o({serverURL:e,path:r}).then((e=>i(new Array(t.length).fill(e),t))),n.length&&f(n)}else f(c);return l.abort.bind(l)};export{s as pageviewCount,e as version};
2
2
  //# sourceMappingURL=pageview.esm.js.map
package/dist/pageview.js CHANGED
@@ -1,2 +1,2 @@
1
- !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=void 0;e.version="2.0.4";const t=e=>{"AbortError"!==e.name&&console.error(e.message)},n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("object"==typeof e&&e.errno)throw new TypeError("Fetch ".concat(t," failed with ").concat(e.errno,": ").concat(e.errmsg));return e},r=e=>{let{serverURL:t,paths:r,signal:o}=e;return fetch("".concat(t,"/article?path=").concat(encodeURIComponent(r.join(","))),{signal:o}).then((e=>e.json())).then((e=>n(e,"visit count"))).then((e=>Array.isArray(e)?e:[e]))},o=e=>{let{serverURL:t,path:r}=e;return fetch("".concat(t,"/article"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})}).then((e=>e.json())).then((e=>n(e,"visit count")))},i=e=>e.dataset.path||e.getAttribute("id"),a=(e,t)=>{t.forEach(((t,n)=>{t.innerText=e[n].toString()}))};e.pageviewCount=e=>{let{serverURL:n,path:s=window.location.pathname,selector:l=".waline-pageview-count",update:c=!0}=e;const f=new AbortController,h=Array.from(document.querySelectorAll(l)),p=e=>{const t=i(e);return null!==t&&s!==t},d=e=>r({serverURL:n,paths:e.map((e=>i(e)||s)),signal:f.signal}).then((t=>a(t,e))).catch(t);if(c){const e=h.filter((e=>!p(e))),t=h.filter(p);o({serverURL:n,path:s}).then((t=>a(new Array(e.length).fill(t),e))),t.length&&d(t)}else d(h);return f.abort.bind(f)}}));
1
+ !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=void 0;e.version="2.0.5";const t=e=>{"AbortError"!==e.name&&console.error(e.message)},n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("object"==typeof e&&e.errno)throw new TypeError("Fetch ".concat(t," failed with ").concat(e.errno,": ").concat(e.errmsg));return e},r=e=>{let{serverURL:t,paths:r,signal:o}=e;return fetch("".concat(t,"/article?path=").concat(encodeURIComponent(r.join(","))),{signal:o}).then((e=>e.json())).then((e=>n(e,"visit count"))).then((e=>Array.isArray(e)?e:[e]))},o=e=>{let{serverURL:t,path:r}=e;return fetch("".concat(t,"/article"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r})}).then((e=>e.json())).then((e=>n(e,"visit count")))},i=e=>e.dataset.path||e.getAttribute("id"),a=(e,t)=>{t.forEach(((t,n)=>{t.innerText=e[n].toString()}))};e.pageviewCount=e=>{let{serverURL:n,path:s=window.location.pathname,selector:l=".waline-pageview-count",update:c=!0}=e;const f=new AbortController,h=Array.from(document.querySelectorAll(l)),p=e=>{const t=i(e);return null!==t&&s!==t},d=e=>r({serverURL:n,paths:e.map((e=>i(e)||s)),signal:f.signal}).then((t=>a(t,e))).catch(t);if(c){const e=h.filter((e=>!p(e))),t=h.filter(p);o({serverURL:n,path:s}).then((t=>a(new Array(e.length).fill(t),e))),t.length&&d(t)}else d(h);return f.abort.bind(f)}}));
2
2
  //# sourceMappingURL=pageview.js.map
package/dist/shim.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{ref as e,unref as t,isRef as n,watch as o,getCurrentScope as r,onScopeDispose as l,shallowRef as i,computed as a,h as s,defineComponent as c,inject as u,onMounted as m,onUnmounted as d,resolveComponent as p,openBlock as v,createElementBlock as g,createElementVNode as f,createVNode as h,toDisplayString as w,createCommentVNode as y,normalizeClass as b,Fragment as k,renderList as C,withDirectives as $,vModelDynamic as j,vModelText as I,vShow as L,createTextVNode as S,createBlock as R,provide as x,watchEffect as E,onBeforeUnmount as A,reactive as U,createApp as z}from"vue";import O from"autosize";import{marked as M}from"marked";import P from"hanabi";const N=["nick","mail","link"],T=e=>e.filter((e=>N.includes(e))),_="zh-CN",B=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})),F=e=>!0===e?'<p class="wl-tex">Tex is not available in preview</p>':'<span class="wl-tex">Tex is not available in preview</span>',D=["nick","nickError","mail","mailError","link","optional","placeholder","sofa","submit","reply","cancelReply","comment","refresh","more","preview","emoji","uploadImage","seconds","minutes","hours","days","now","uploading","login","logout","admin","sticky","word","wordHint","anonymous"],H=e=>Object.fromEntries(e.map(((e,t)=>[D[t],e])));var q=H(["NickName","NickName cannot be less than 3 bytes.","E-Mail","Please confirm your email address.","Website","Optional","Comment here...","No comment yet.","Submit","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"]),W=H(["ニックネーム","3バイト以上のニックネームをご入力ください.","メールアドレス","メールアドレスをご確認ください.","サイト","オプション","ここにコメント","コメントしましょう~","提出する","返信する","キャンセル","コメント","更新","さらに読み込む","プレビュー","絵文字","画像をアップロード","秒前","分前","時間前","日前","たっだ今","アップロード","ログインする","ログアウト","管理者","トップに置く","ワード","コメントは $0 から $1 ワードの間でなければなりません!\n 現在の単語番号: $2","匿名"]),V=H(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字","评论字数应在 $0 到 $1 字之间!\n当前字数:$2","匿名"]),J=H(["暱稱","郵箱","網址","可選","暱稱不能少於3個字元","請填寫正確的郵件地址","歡迎評論","來發評論吧~","提交","回覆","取消回覆","評論","刷新","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登錄","退出","博主","置頂","字","評論字數應在 $0 到 $1 字之間!\n當前字數:$2","匿名"]),K=H(["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","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"]),Y=H(["Псевдоним","Никнейм не может быть меньше 3 байт.","Эл. адрес","Пожалуйста, подтвердите адрес вашей электронной почты.","Веб-сайт","Необязательный","Комментарий здесь...","Пока нет комментариев.","Отправить","Отвечать","Отменить ответ","Комментарии","Обновить","Загрузи больше...","Превью","эмодзи","Загрузить изображение","секунд назад","несколько минут назад","несколько часов назад","дней назад","прямо сейчас","Загрузка","Авторизоваться","Выход из системы","Админ","Липкий","Слова","Пожалуйста, введите комментарии от $0 до $1 слов!\nНомер текущего слова: $2","Анонимный"]);const G={zh:V,"zh-cn":V,"zh-CN":V,"zh-tw":J,"zh-TW":J,en:q,"en-US":q,"en-us":q,jp:W,"jp-jp":W,"jp-JP":W,"pt-br":K,"pt-BR":K,ru:Y,"ru-ru":Y,"ru-RU":Y};function Q(e){return!!r()&&(l(e),!0)}const X="undefined"!=typeof window,Z=()=>{};const ee=e=>e();var te=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;function re(e,t,n={}){const r=n,{eventFilter:l=ee}=r,i=((e,t)=>{var n={};for(var o in e)ne.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&te)for(var o of te(e))t.indexOf(o)<0&&oe.call(e,o)&&(n[o]=e[o]);return n})(r,["eventFilter"]);return o(e,(a=l,s=t,function(...e){a((()=>s.apply(this,e)),{fn:s,thisArg:this,args:e})}),i);var a,s}var le=Object.defineProperty,ie=Object.defineProperties,ae=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,me=(e,t,n)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function de(t,n,o={}){const r=o,{eventFilter:l}=r,i=((e,t)=>{var n={};for(var o in e)ce.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&se)for(var o of se(e))t.indexOf(o)<0&&ue.call(e,o)&&(n[o]=e[o]);return n})(r,["eventFilter"]),{eventFilter:a,pause:s,resume:c,isActive:u}=function(t=ee){const n=e(!0);return{isActive:n,pause:function(){n.value=!1},resume:function(){n.value=!0},eventFilter:(...e)=>{n.value&&t(...e)}}}(l),m=re(t,n,(d=((e,t)=>{for(var n in t||(t={}))ce.call(t,n)&&me(e,n,t[n]);if(se)for(var n of se(t))ue.call(t,n)&&me(e,n,t[n]);return e})({},i),ie(d,ae({eventFilter:a}))));var d;return{stop:m,pause:s,resume:c,isActive:u}}const pe=X?window:void 0;function ve(...e){let n,r,l,i;if("string"==typeof e[0]?([r,l,i]=e,n=pe):[n,r,l,i]=e,!n)return Z;let a=Z;const s=o((()=>function(e){var n;const o=t(e);return null!=(n=null==o?void 0:o.$el)?n:o}(n)),(e=>{a(),e&&(e.addEventListener(r,l,i),a=()=>{e.removeEventListener(r,l,i),a=Z})}),{immediate:!0,flush:"post"}),c=()=>{s(),a()};return Q(c),c}X&&window.document,X&&window.navigator,X&&window.location;const ge="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},fe="__vueuse_ssr_handlers__";ge[fe]=ge[fe]||{};const he=ge[fe];const we={boolean:{read:e=>"true"===e,write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}};function ye(n,o,r,l={}){var a;const{flush:s="pre",deep:c=!0,listenToStorageChanges:u=!0,writeDefaults:m=!0,shallow:d,window:p=pe,eventFilter:v,onError:g=(e=>{console.error(e)})}=l,f=(d?i:e)(o);if(!r)try{r=function(e,t){return he[e]||t}("getDefaultStorage",(()=>{var e;return null==(e=pe)?void 0:e.localStorage}))()}catch(e){g(e)}if(!r)return f;const h=t(o),w=function(e){return null==e?"any":e instanceof Set?"set":e instanceof Map?"map":e instanceof Date?"date":"boolean"==typeof e?"boolean":"string"==typeof e?"string":"object"==typeof e||Array.isArray(e)?"object":Number.isNaN(e)?"any":"number"}(h),y=null!=(a=l.serializer)?a:we[w],{pause:b,resume:k}=de(f,(()=>function(e){try{null==e?r.removeItem(n):r.setItem(n,y.write(e))}catch(e){g(e)}}(f.value)),{flush:s,deep:c,eventFilter:v});return p&&u&&ve(p,"storage",C),C(),f;function C(e){e&&e.key!==n||(f.value=function(e){if(!e||e.key===n){b();try{const t=e?e.newValue:r.getItem(n);return null==t?(m&&null!==h&&r.setItem(n,y.write(h)),h):"string"!=typeof t?t:y.read(t)}catch(e){g(e)}finally{k()}}}(e))}}var be,ke,Ce=Object.defineProperty,$e=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,Le=(e,t,n)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function Se(r={}){const{controls:l=!1,interval:i="requestAnimationFrame"}=r,a=e(new Date),s=()=>a.value=new Date,c="requestAnimationFrame"===i?function(t,n={}){const{immediate:o=!0,window:r=pe}=n,l=e(!1);let i=null;function a(){l.value&&r&&(t(),i=r.requestAnimationFrame(a))}function s(){!l.value&&r&&(l.value=!0,a())}function c(){l.value=!1,null!=i&&r&&(r.cancelAnimationFrame(i),i=null)}return o&&s(),Q(c),{isActive:l,pause:c,resume:s}}(s,{immediate:!0}):function(r,l=1e3,i={}){const{immediate:a=!0,immediateCallback:s=!1}=i;let c=null;const u=e(!1);function m(){c&&(clearInterval(c),c=null)}function d(){u.value=!1,m()}function p(){l<=0||(u.value=!0,s&&r(),m(),c=setInterval(r,t(l)))}a&&X&&p(),n(l)&&Q(o(l,(()=>{a&&X&&p()})));return Q(d),{isActive:u,pause:d,resume:p}}(s,i,{immediate:!0});return l?((e,t)=>{for(var n in t||(t={}))je.call(t,n)&&Le(e,n,t[n]);if($e)for(var n of $e(t))Ie.call(t,n)&&Le(e,n,t[n]);return e})({now:a},c):a}X&&(null==window?void 0:window.navigator)&&(null==(be=null==window?void 0:window.navigator)?void 0:be.platform)&&/iP(ad|hone|od)/.test(null==(ke=null==window?void 0:window.navigator)?void 0:ke.platform);const Re=e=>{try{e=decodeURI(e)}catch(e){}return e},xe=(e="")=>e.replace(/\/$/u,""),Ee=e=>/^(https?:)?\/\//.test(e),Ae=e=>{const t=xe(e);return Ee(t)?t:`https://${t}`},Ue=e=>Array.isArray(e)?e:!!e&&[0,e],ze=(e,t)=>"function"==typeof e?e:!1!==e&&t,Oe="{--waline-white:#000;--waline-light-grey:#666;--waline-dark-grey:#999;--waline-color:#888;--waline-bgcolor:#1e1e1e;--waline-bgcolor-light:#272727;--waline-bgcolor-hover: #444;--waline-border-color:#333;--waline-disable-bgcolor:#444;--waline-disable-color:#272727;--waline-bq-color:#272727;--waline-info-bgcolor:#272727;--waline-info-color:#666}",Me=(e,t)=>{let n=e.toString();for(;n.length<t;)n="0"+n;return n},Pe=e=>{const t=ye("WALINE_EMOJI",{}),n=Boolean(/@[0-9]+\.[0-9]+\.[0-9]+/.test(e));if(n){const e=t.value.link;if(e)return Promise.resolve(e)}return fetch(`${e}/info.json`).then((e=>e.json())).then((o=>{const r={folder:e,...o};return n&&(t.value.link=r),r}))},Ne=(e,t="",n="",o="")=>`${t?`${t}/`:""}${n}${e}${o?`.${o}`:""}`,Te=e=>{"AbortError"!==e.name&&console.error(e.message)},_e=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},Be=({serverURL:e,paths:t,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>_e(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),Fe=({serverURL:e,path:t})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})}).then((e=>e.json())).then((e=>_e(e,"visit count"))),De=e=>e instanceof HTMLElement?e:"string"==typeof e?document.querySelector(e):null,He=e=>e.type.includes("image"),qe=e=>{const t=Array.from(e).find(He);return t?t.getAsFile():null},We=/\$.*?\$/,Ve=/^\$(.*?)\$/,Je=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,Ke=(e="",t={})=>e.replace(/:(.+?):/g,((e,n)=>t[n]?`<img class="wl-emoji" src="${t[n]}" alt="${n}">`:e)),Ye=(e,{emojiMap:t,highlighter:n,texRenderer:o})=>{if(M.setOptions({highlight:n||void 0,breaks:!0,smartLists:!0,smartypants:!0}),o){const e=(e=>[{name:"blockMath",level:"block",tokenizer(t){const n=Je.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(We);return-1!==t?t:e.length},tokenizer(t){const n=Ve.exec(t);if(null!==n)return{type:"html",raw:n[0],text:e(!1,n[1])}}}])(o);M.use({extensions:e})}return M.parse(Ke(e,t))},Ge=e=>e.dataset.path||e.getAttribute("id"),Qe=(e,t)=>{const n=Se();return a((()=>{if(!e)return"";const o="string"==typeof e?new Date(-1!==e.indexOf(" ")?e.replace(/-/g,"/"):e):e,r=n.value.getTime()-o.getTime(),l=Math.floor(r/864e5);if(0===l){const e=r%864e5,n=Math.floor(e/36e5);if(0===n){const n=e%36e5,o=Math.floor(n/6e4);if(0===o){const e=n%6e4;return`${Math.round(e/1e3)} ${t.seconds}`}return`${o} ${t.minutes}`}return`${n} ${t.hours}`}return l<0?t.now:l<8?`${l} ${t.days}`:(e=>{const t=Me(e.getDate(),2),n=Me(e.getMonth()+1,2);return`${Me(e.getFullYear(),2)}-${n}-${t}`})(o)}))},Xe=()=>ye("USER_KEY",{}),Ze=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-comment-count"})=>{var o;const r=new AbortController,l=document.querySelectorAll(n),i=Xe();return l.length&&(({serverURL:e,paths:t,signal:n,token:o})=>{const r={};return o&&(r.Authorization=`Bearer ${o}`),fetch(`${e}/comment?type=count&url=${encodeURIComponent(t.join(","))}`,{signal:n,headers:r}).then((e=>e.json())).then((e=>_e(e,"comment count"))).then((e=>Array.isArray(e)?e:[e]))})({serverURL:e,paths:Array.from(l).map((e=>Re(e.dataset.path||e.getAttribute("id")||t))),signal:r.signal,token:null===(o=i.value)||void 0===o?void 0:o.token}).then((e=>{l.forEach(((t,n)=>{t.innerText=e[n].toString()}))})).catch(Te),r.abort.bind(r)},et=({size:e})=>s("svg",{width:e,height:e,viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid"},s("circle",{cx:50,cy:50,fill:"none",stroke:"currentColor",strokeWidth:"4",r:"40","stroke-dasharray":"85 30"},s("animateTransform",{attributeName:"transform",type:"rotate",repeatCount:"indefinite",dur:"1s",values:"0 50 50;360 50 50",keyTimes:"0;1"})));var tt=c({name:"CommentBox",components:{CloseIcon:({size:e})=>s("svg",{class:"wl-close-icon",viewBox:"0 0 1024 1024",width:e,height:e},[s("path",{d:"M697.173 85.333h-369.92c-144.64 0-241.92 101.547-241.92 252.587v348.587c0 150.613 97.28 252.16 241.92 252.16h369.92c144.64 0 241.494-101.547 241.494-252.16V337.92c0-151.04-96.854-252.587-241.494-252.587z",fill:"currentColor"}),s("path",{d:"m640.683 587.52-75.947-75.861 75.904-75.862a37.29 37.29 0 0 0 0-52.778 37.205 37.205 0 0 0-52.779 0l-75.946 75.818-75.862-75.946a37.419 37.419 0 0 0-52.821 0 37.419 37.419 0 0 0 0 52.821l75.947 75.947-75.776 75.733a37.29 37.29 0 1 0 52.778 52.821l75.776-75.776 75.947 75.947a37.376 37.376 0 0 0 52.779-52.821z",fill:"#888"})]),EmojiIcon:()=>s("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},s("path",{d:"M563.2 463.3 677 540c1.7 1.2 3.7 1.8 5.8 1.8.7 0 1.4-.1 2-.2 2.7-.5 5.1-2.1 6.6-4.4l25.3-37.8c1.5-2.3 2.1-5.1 1.6-7.8s-2.1-5.1-4.4-6.6l-73.6-49.1 73.6-49.1c2.3-1.5 3.9-3.9 4.4-6.6.5-2.7 0-5.5-1.6-7.8l-25.3-37.8a10.1 10.1 0 0 0-6.6-4.4c-.7-.1-1.3-.2-2-.2-2.1 0-4.1.6-5.8 1.8l-113.8 76.6c-9.2 6.2-14.7 16.4-14.7 27.5.1 11 5.5 21.3 14.7 27.4zM387 348.8h-45.5c-5.7 0-10.4 4.7-10.4 10.4v153.3c0 5.7 4.7 10.4 10.4 10.4H387c5.7 0 10.4-4.7 10.4-10.4V359.2c0-5.7-4.7-10.4-10.4-10.4zm333.8 241.3-41-20a10.3 10.3 0 0 0-8.1-.5c-2.6.9-4.8 2.9-5.9 5.4-30.1 64.9-93.1 109.1-164.4 115.2-5.7.5-9.9 5.5-9.5 11.2l3.9 45.5c.5 5.3 5 9.5 10.3 9.5h.9c94.8-8 178.5-66.5 218.6-152.7 2.4-5 .3-11.2-4.8-13.6zm186-186.1c-11.9-42-30.5-81.4-55.2-117.1-24.1-34.9-53.5-65.6-87.5-91.2-33.9-25.6-71.5-45.5-111.6-59.2-41.2-14-84.1-21.1-127.8-21.1h-1.2c-75.4 0-148.8 21.4-212.5 61.7-63.7 40.3-114.3 97.6-146.5 165.8-32.2 68.1-44.3 143.6-35.1 218.4 9.3 74.8 39.4 145 87.3 203.3.1.2.3.3.4.5l36.2 38.4c1.1 1.2 2.5 2.1 3.9 2.6 73.3 66.7 168.2 103.5 267.5 103.5 73.3 0 145.2-20.3 207.7-58.7 37.3-22.9 70.3-51.5 98.1-85 27.1-32.7 48.7-69.5 64.2-109.1 15.5-39.7 24.4-81.3 26.6-123.8 2.4-43.6-2.5-87-14.5-129zm-60.5 181.1c-8.3 37-22.8 72-43 104-19.7 31.1-44.3 58.6-73.1 81.7-28.8 23.1-61 41-95.7 53.4-35.6 12.7-72.9 19.1-110.9 19.1-82.6 0-161.7-30.6-222.8-86.2l-34.1-35.8c-23.9-29.3-42.4-62.2-55.1-97.7-12.4-34.7-18.8-71-19.2-107.9-.4-36.9 5.4-73.3 17.1-108.2 12-35.8 30-69.2 53.4-99.1 31.7-40.4 71.1-72 117.2-94.1 44.5-21.3 94-32.6 143.4-32.6 49.3 0 97 10.8 141.8 32 34.3 16.3 65.3 38.1 92 64.8 26.1 26 47.5 56 63.6 89.2 16.2 33.2 26.6 68.5 31 105.1 4.6 37.5 2.7 75.3-5.6 112.3z",fill:"currentColor"})),ImageIcon:()=>s("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[s("path",{d:"M784 112H240c-88 0-160 72-160 160v480c0 88 72 160 160 160h544c88 0 160-72 160-160V272c0-88-72-160-160-160zm96 640c0 52.8-43.2 96-96 96H240c-52.8 0-96-43.2-96-96V272c0-52.8 43.2-96 96-96h544c52.8 0 96 43.2 96 96v480z",fill:"currentColor"}),s("path",{d:"M352 480c52.8 0 96-43.2 96-96s-43.2-96-96-96-96 43.2-96 96 43.2 96 96 96zm0-128c17.6 0 32 14.4 32 32s-14.4 32-32 32-32-14.4-32-32 14.4-32 32-32zm462.4 379.2-3.2-3.2-177.6-177.6c-25.6-25.6-65.6-25.6-91.2 0l-80 80-36.8-36.8c-25.6-25.6-65.6-25.6-91.2 0L200 728c-4.8 6.4-8 14.4-8 24 0 17.6 14.4 32 32 32 9.6 0 16-3.2 22.4-9.6L380.8 640l134.4 134.4c6.4 6.4 14.4 9.6 24 9.6 17.6 0 32-14.4 32-32 0-9.6-4.8-17.6-9.6-24l-52.8-52.8 80-80L769.6 776c6.4 4.8 12.8 8 20.8 8 17.6 0 32-14.4 32-32 0-8-3.2-16-8-20.8z",fill:"currentColor"})]),MarkdownIcon:()=>s("svg",{width:"16",height:"16",ariaHidden:"true"},s("path",{d:"M14.85 3H1.15C.52 3 0 3.52 0 4.15v7.69C0 12.48.52 13 1.15 13h13.69c.64 0 1.15-.52 1.15-1.15v-7.7C16 3.52 15.48 3 14.85 3zM9 11H7V8L5.5 9.92 4 8v3H2V5h2l1.5 2L7 5h2v6zm2.99.5L9.5 8H11V5h2v3h1.5l-2.51 3.5z",fill:"currentColor"})),PreviewIcon:()=>s("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[s("path",{d:"M710.816 654.301c70.323-96.639 61.084-230.578-23.705-314.843-46.098-46.098-107.183-71.109-172.28-71.109-65.008 0-126.092 25.444-172.28 71.109-45.227 46.098-70.756 107.183-70.756 172.106 0 64.923 25.444 126.007 71.194 172.106 46.099 46.098 107.184 71.109 172.28 71.109 51.414 0 100.648-16.212 142.824-47.404l126.53 126.006c7.058 7.06 16.297 10.979 26.406 10.979 10.105 0 19.343-3.919 26.402-10.979 14.467-14.467 14.467-38.172 0-52.723L710.816 654.301zm-315.107-23.265c-65.88-65.88-65.88-172.54 0-238.42 32.069-32.07 74.245-49.149 119.471-49.149 45.227 0 87.407 17.603 119.472 49.149 65.88 65.879 65.88 172.539 0 238.42-63.612 63.178-175.242 63.178-238.943 0zm0 0",fill:"currentColor"}),s("path",{d:"M703.319 121.603H321.03c-109.8 0-199.469 89.146-199.469 199.38v382.034c0 109.796 89.236 199.38 199.469 199.38h207.397c20.653 0 37.384-16.645 37.384-37.299 0-20.649-16.731-37.296-37.384-37.296H321.03c-68.582 0-124.352-55.77-124.352-124.267V321.421c0-68.496 55.77-124.267 124.352-124.267h382.289c68.582 0 124.352 55.771 124.352 124.267V524.72c0 20.654 16.736 37.299 37.385 37.299 20.654 0 37.384-16.645 37.384-37.299V320.549c-.085-109.8-89.321-198.946-199.121-198.946zm0 0",fill:"currentColor"})]),LoadingIcon:et},props:{rootId:{type:String,default:""},replyId:{type:String,default:""},replyUser:{type:String,default:""}},emits:["submit","cancel-reply"],setup(t,{emit:n}){const r=u("config"),l=ye("WALINE_USER_CACHE",{nick:"",mail:"",link:"",editor:""}),i=Xe(),s=e({}),c=e(null),p=e(null),v=e(null),g=e(null),f=e({tabs:[],map:{}}),h=e(0),w=e(!1),y=e(!1),b=e(""),k=e(0),C=e(0),$=e(!1),j=e(""),I=e(!1),L=a((()=>r.value.locale)),S=a((()=>{var e;return Boolean(null===(e=i.value)||void 0===e?void 0:e.token)})),R=a((()=>!1!==r.value.imageUploader)),x=e=>{const t=c.value,n=t.selectionStart,o=t.selectionEnd||0,r=t.scrollTop;l.value.editor=t.value.substring(0,n)+e+t.value.substring(o,t.value.length),t.focus(),t.selectionStart=n+e.length,t.selectionEnd=n+e.length,t.scrollTop=r},E=e=>{const t=`![${r.value.locale.uploading} ${e.name}]()`;return x(t),Promise.resolve().then((()=>r.value.imageUploader(e))).then((n=>{l.value.editor=l.value.editor.replace(t,`\r\n![${e.name}](${n})`)}))},A=()=>{var e,o,a,u,m;const{serverURL:d,lang:p,login:v,wordLimit:g,requiredMeta:h}=r.value,w={comment:j.value,nick:l.value.nick,mail:l.value.mail,link:l.value.link,ua:navigator.userAgent,url:r.value.path};if(null===(e=i.value)||void 0===e?void 0:e.token)w.nick=i.value.display_name,w.mail=i.value.email,w.link=i.value.url;else{if("force"===v)return;if((h.indexOf("nick")>-1||w.nick)&&!w.nick)return null===(o=s.value.nick)||void 0===o||o.focus(),alert(L.value.nickError);if(h.indexOf("mail")>-1&&!w.mail)return null===(a=s.value.mail)||void 0===a||a.focus(),alert(L.value.mailError);if(!w.comment)return void(null===(u=c.value)||void 0===u||u.focus());w.nick||(w.nick=L.value.anonymous)}if(!$.value)return alert(L.value.wordHint.replace("$0",g[0].toString()).replace("$1",g[1].toString()).replace("$2",k.value.toString()));w.comment=Ke(w.comment,f.value.map),t.replyId&&t.rootId&&(w.pid=t.replyId,w.rid=t.rootId,w.at=t.replyUser),I.value=!0,(({serverURL:e,lang:t,token:n,comment:o})=>{const r={"Content-Type":"application/json"};return n&&(r.Authorization=`Bearer ${n}`),fetch(`${e}/comment?lang=${t}`,{method:"POST",headers:r,body:JSON.stringify(o)}).then((e=>e.json()))})({serverURL:d,lang:p,token:null===(m=i.value)||void 0===m?void 0:m.token,comment:w}).then((e=>{if(I.value=!1,e.errmsg)return alert(e.errmsg);n("submit",e.data),l.value.editor="",b.value="",t.replyId&&n("cancel-reply")})).catch((e=>{I.value=!1,alert(e.message)}))},U=e=>{v.value.contains(e.target)||g.value.contains(e.target)||(w.value=!1)};return o([r,k],(([e,t])=>{const{wordLimit:n}=e;n?t<n[0]&&0!==n[0]?(C.value=n[0],$.value=!1):t>n[1]?(C.value=n[1],$.value=!1):(C.value=n[1],$.value=!0):(C.value=0,$.value=!0)}),{immediate:!0}),m((()=>{document.body.addEventListener("click",U),o((()=>l.value.editor),(e=>{const{highlighter:t,texRenderer:n}=r.value;j.value=e,b.value=Ye(e,{emojiMap:f.value.map,highlighter:t,texRenderer:n}),k.value=(e=>(e=>e.match(/[\w\d\s\u00C0-\u024F]+/giu)||[])(e).reduce(((e,t)=>e+(""===t.trim()?0:t.trim().split(/\s+/u).length)),0)+(e=>e.match(/[\u4E00-\u9FA5]/gu)||[])(e).length)(e),e?O(c.value):O.destroy(c.value)}),{immediate:!0}),o((()=>r.value.emoji),(e=>{return(t=e,Promise.all(t.map((e=>"string"==typeof e?Pe(xe(e)):Promise.resolve(e)))).then((e=>{const t={tabs:[],map:{}};return e.forEach((e=>{const{name:n,folder:o,icon:r,prefix:l,type:i,items:a}=e;t.tabs.push({name:n,icon:Ne(r,o,l,i),items:a.map((e=>{const n=`${l||""}${e}`;return t.map[n]=Ne(e,o,l,i),n}))})})),t}))).then((e=>{f.value=e}));var t}),{immediate:!0})})),d((()=>{document.body.removeEventListener("click",U)})),{config:r,locale:L,insert:x,onChange:()=>{const e=p.value;e.files&&R.value&&E(e.files[0]).then((()=>{e.value=""}))},onDrop:e=>{var t;if(null===(t=e.dataTransfer)||void 0===t?void 0:t.items){const t=qe(e.dataTransfer.items);t&&R.value&&(E(t),e.preventDefault())}},onKeyDown:e=>{const t=e.key;(e.ctrlKey||e.metaKey)&&"Enter"===t&&A()},onPaste:e=>{if(e.clipboardData){const t=qe(e.clipboardData.items);t&&R.value&&E(t)}},onLogin:e=>{e.preventDefault();const{lang:t,serverURL:n}=r.value,o=(window.innerWidth-450)/2,l=(window.innerHeight-450)/2,a=window.open(`${n}/ui/login?lng=${encodeURIComponent(t)}`,"_blank",`width=450,height=450,left=${o},top=${l},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==a||a.postMessage({type:"TOKEN",data:null},"*");const s=({data:e})=>{e&&"userInfo"===e.type&&e.data.token&&(null==a||a.close(),i.value=e.data,(e.data.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(e.data)),window.removeEventListener("message",s))};window.addEventListener("message",s)},onLogout:()=>{i.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null")},onProfile:e=>{e.preventDefault();const{lang:t,serverURL:n}=r.value,o=(window.innerWidth-800)/2,l=(window.innerHeight-800)/2,a=window.open(`${n}/ui/profile?lng=${encodeURIComponent(t)}`,"_blank",`width=800,height=800,left=${o},top=${l},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==a||a.postMessage({type:"TOKEN",data:i.value.token},"*");const s=({data:e})=>{e&&"profile"===e.type&&(i.value={...i.value,...e},[localStorage,sessionStorage].filter((e=>e.getItem("WALINE_USER"))).forEach((e=>e.setItem("WALINE_USER",JSON.stringify(i)))),window.removeEventListener("message",s))};window.addEventListener("message",s)},submitComment:A,isLogin:S,userInfo:i,isSubmitting:I,wordNumber:k,wordLimit:C,isWordNumberLegal:$,inputs:l,emoji:f,emojiTabIndex:h,showEmoji:w,canUploadImage:R,previewText:b,showPreview:y,inputRefs:s,editorRef:c,emojiButtonRef:v,emojiPopupRef:g,imageUploadRef:p}}});const nt={class:"wl-comment"},ot={key:0,class:"wl-login-info"},rt={class:"wl-avatar"},lt=["title"],it=["src"],at=["textContent"],st={class:"wl-panel"},ct=["for","textContent"],ut=["id","name","type","onUpdate:modelValue"],mt=["placeholder"],dt={class:"wl-preview"},pt=f("hr",null,null,-1),vt=["innerHTML"],gt={class:"wl-footer"},ft={class:"wl-actions"},ht={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noreferrer"},wt=["title"],yt=["title"],bt=["title"],kt={class:"wl-info"},Ct={class:"wl-text-number"},$t={key:0},jt=S("  /  "),It=["textContent"],Lt=["textContent"],St=["disabled"],Rt={key:0,class:"wl-tab-wrapper"},xt=["title","onClick"],Et=["src","alt"],At={key:0,class:"wl-tabs"},Ut=["onClick"],zt=["src","alt","title"],Ot=["title"];tt.render=function(e,t,n,o,r,l){const i=p("CloseIcon"),a=p("MarkdownIcon"),s=p("EmojiIcon"),c=p("ImageIcon"),u=p("PreviewIcon"),m=p("LoadingIcon");return v(),g("div",nt,["disable"!==e.config.login&&e.isLogin?(v(),g("div",ot,[f("div",rt,[f("button",{class:"wl-logout-btn",title:e.locale.logout,onClick:t[0]||(t[0]=(...t)=>e.onLogout&&e.onLogout(...t))},[h(i,{size:14})],8,lt),f("img",{src:e.userInfo.avatar,alt:"avatar"},null,8,it)]),f("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",onClick:t[1]||(t[1]=(...t)=>e.onProfile&&e.onProfile(...t)),textContent:w(e.userInfo.display_name)},null,8,at)])):y("v-if",!0),f("div",st,["force"!==e.config.login&&e.config.meta.length&&!e.isLogin?(v(),g("div",{key:0,class:b(["wl-header",`item${e.config.meta.length}`])},[(v(!0),g(k,null,C(e.config.meta,(t=>(v(),g("div",{class:"wl-header-item",key:t},[f("label",{for:t,textContent:w(e.locale[t]+(e.config.requiredMeta.includes(t)||!e.config.requiredMeta.length?"":`(${e.locale.optional})`))},null,8,ct),$(f("input",{ref_for:!0,ref:n=>{n&&(e.inputRefs[t]=n)},id:`wl-${t}`,class:b(["wl-input",`wl-${t}`]),name:t,type:"mail"===t?"email":"text","onUpdate:modelValue":n=>e.inputs[t]=n},null,10,ut),[[j,e.inputs[t]]])])))),128))],2)):y("v-if",!0),$(f("textarea",{class:"wl-editor",ref:"editorRef",id:"wl-edit",placeholder:e.replyUser?`@${e.replyUser}`:e.locale.placeholder,"onUpdate:modelValue":t[2]||(t[2]=t=>e.inputs.editor=t),onKeydown:t[3]||(t[3]=(...t)=>e.onKeyDown&&e.onKeyDown(...t)),onDrop:t[4]||(t[4]=(...t)=>e.onDrop&&e.onDrop(...t)),onPaste:t[5]||(t[5]=(...t)=>e.onPaste&&e.onPaste(...t))},null,40,mt),[[I,e.inputs.editor]]),$(f("div",dt,[pt,f("h4",null,w(e.locale.preview)+":",1),f("div",{class:"wl-content",innerHTML:e.previewText},null,8,vt)],512),[[L,e.showPreview]]),f("div",gt,[f("div",ft,[f("a",ht,[h(a)]),f("button",{ref:"emojiButtonRef",class:b(["wl-action",{actived:e.showEmoji}]),title:e.locale.emoji,onClick:t[6]||(t[6]=t=>e.showEmoji=!e.showEmoji)},[h(s)],10,wt),f("input",{ref:"imageUploadRef",class:"upload",id:"wl-image-upload",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:t[7]||(t[7]=(...t)=>e.onChange&&e.onChange(...t))},null,544),e.canUploadImage?(v(),g("label",{key:0,for:"wl-image-upload",class:"wl-action",title:e.locale.uploadImage},[h(c)],8,yt)):y("v-if",!0),f("button",{class:b(["wl-action",{actived:e.showPreview}]),title:e.locale.preview,onClick:t[8]||(t[8]=t=>e.showPreview=!e.showPreview)},[h(u)],10,bt)]),f("div",kt,[f("div",Ct,[S(w(e.wordNumber)+" ",1),e.config.wordLimit?(v(),g("span",$t,[jt,f("span",{class:b({illegal:!e.isWordNumberLegal}),textContent:w(e.wordLimit)},null,10,It)])):y("v-if",!0),S("  "+w(e.locale.word),1)]),"disable"===e.config.login||e.isLogin?y("v-if",!0):(v(),g("button",{key:0,class:"wl-btn",onClick:t[9]||(t[9]=(...t)=>e.onLogin&&e.onLogin(...t)),textContent:w(e.locale.login)},null,8,Lt)),"force"!==e.config.login||e.isLogin?(v(),g("button",{key:1,class:"wl-btn primary",title:"Cmd|Ctrl + Enter",disabled:e.isSubmitting,onClick:t[10]||(t[10]=(...t)=>e.submitComment&&e.submitComment(...t))},[e.isSubmitting?(v(),R(m,{key:0,size:16})):(v(),g(k,{key:1},[S(w(e.locale.submit),1)],2112))],8,St)):y("v-if",!0)]),f("div",{ref:"emojiPopupRef",class:b(["wl-emoji-popup",{display:e.showEmoji}])},[(v(!0),g(k,null,C(e.emoji.tabs,((t,n)=>(v(),g(k,{key:t.name},[n===e.emojiTabIndex?(v(),g("div",Rt,[(v(!0),g(k,null,C(t.items,(t=>(v(),g("button",{key:t,title:t,onClick:n=>e.insert(`:${t}:`)},[e.showEmoji?(v(),g("img",{key:0,class:"wl-emoji",src:e.emoji.map[t],alt:t,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Et)):y("v-if",!0)],8,xt)))),128))])):y("v-if",!0)],64)))),128)),e.emoji.tabs.length>1?(v(),g("div",At,[(v(!0),g(k,null,C(e.emoji.tabs,((t,n)=>(v(),g("button",{key:t.name,class:b(["wl-tab",{active:e.emojiTabIndex===n}]),onClick:t=>e.emojiTabIndex=n},[f("img",{class:"wl-emoji",src:t.icon,alt:t.name,title:t.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,zt)],10,Ut)))),128))])):y("v-if",!0)],2)])]),e.replyId?(v(),g("button",{key:1,class:"wl-close",title:e.locale.cancelReply,onClick:t[11]||(t[11]=t=>e.$emit("cancel-reply"))},[h(i,{size:24})],8,Ot)):y("v-if",!0)])},tt.__file="src/components/CommentBox.vue";var Mt=c({props:{comment:{type:Object,required:!0},rootId:{type:String,required:!0},reply:{type:Object}},components:{CommentBox:tt,ReplyIcon:()=>s("svg",{viewBox:"0 0 1024 1024",width:"18",height:"18"},s("path",{d:"M1019.2 720C1001.6 625.6 968 566.4 904 497.6c-89.6-89.6-214.4-150.4-347.2-176v-120c0-25.6-8-51.2-25.6-64-33.6-30.4-81.6-30.4-112-4.8L33.6 441.6C12.8 459.2 0 484.8 0 510.4c0 25.6 12.8 51.2 30.4 68.8l385.6 312c17.6 12.8 33.6 17.6 51.2 17.6 12.8 0 25.6-4.8 38.4-8C536 888 552 857.6 552 824v-99.2c124.8 20.8 248 86.4 339.2 140.8 25.6 17.6 59.2 17.6 89.6 0 25.6-17.6 43.2-46.4 43.2-76.8 0-33.6 0-56-4.8-68.8zm-500.8-89.6-46.4-4.8v193.6L86.4 510.4 472 201.6V400l38.4 4.8c128 12.8 248 68.8 334.4 153.6 51.2 56 76.8 102.4 94.4 179.2 0 4.8 4.8 20.8 4.8 51.2C835.2 720 672 640 518.4 630.4z",fill:"currentColor"})),VerifiedIcon:()=>s("svg",{class:"verified-icon",viewBox:"0 0 1024 1024",width:"14",height:"14"},s("path",{d:"m894.4 461.56-54.4-63.2c-10.4-12-18.8-34.4-18.8-50.4v-68c0-42.4-34.8-77.2-77.2-77.2h-68c-15.6 0-38.4-8.4-50.4-18.8l-63.2-54.4c-27.6-23.6-72.8-23.6-100.8 0l-62.8 54.8c-12 10-34.8 18.4-50.4 18.4h-69.2c-42.4 0-77.2 34.8-77.2 77.2v68.4c0 15.6-8.4 38-18.4 50l-54 63.6c-23.2 27.6-23.2 72.4 0 100l54 63.6c10 12 18.4 34.4 18.4 50v68.4c0 42.4 34.8 77.2 77.2 77.2h69.2c15.6 0 38.4 8.4 50.4 18.8l63.2 54.4c27.6 23.6 72.8 23.6 100.8 0l63.2-54.4c12-10.4 34.4-18.8 50.4-18.8h68c42.4 0 77.2-34.8 77.2-77.2v-68c0-15.6 8.4-38.4 18.8-50.4l54.4-63.2c23.2-27.6 23.2-73.2-.4-100.8zm-216-25.2-193.2 193.2a30 30 0 0 1-42.4 0l-96.8-96.8a30.16 30.16 0 0 1 0-42.4c11.6-11.6 30.8-11.6 42.4 0l75.6 75.6 172-172c11.6-11.6 30.8-11.6 42.4 0 11.6 11.6 11.6 30.8 0 42.4z",fill:"#27ae60"}))},emits:["submit","reply"],setup(e){const t=u("config"),n=a((()=>t.value.locale)),o=a((()=>{let{link:t}=e.comment;return t?Ee(t)?t:`https://${t}`:""})),r=Qe(e.comment.insertedAt,n.value),l=a((()=>{var t;return e.comment.objectId===(null===(t=e.reply)||void 0===t?void 0:t.objectId)}));return{config:t,locale:n,isReplyingCurrent:l,link:o,time:r}}});const Pt=["id"],Nt={class:"wl-user","aria-hidden":"true"},Tt=["src"],_t={class:"wl-card"},Bt={class:"wl-head"},Ft=["href"],Dt={key:1,class:"wl-nick"},Ht=["textContent"],qt=["textContent"],Wt=["textContent"],Vt=["title"],Jt={class:"wl-meta","aria-hidden":"true"},Kt=["textContent"],Yt=["textContent"],Gt=["innerHTML"],Qt={key:0,class:"wl-reply-wrapper"},Xt={key:1,class:"wl-quote"};Mt.render=function(e,t,n,o,r,l){const i=p("VerifiedIcon"),a=p("ReplyIcon"),s=p("CommentBox"),c=p("CommentCard",!0);return v(),g("div",{class:"wl-item",id:e.comment.objectId},[f("div",Nt,[e.comment.avatar?(v(),g("img",{key:0,src:e.comment.avatar},null,8,Tt)):y("v-if",!0),e.comment.type?(v(),R(i,{key:1})):y("v-if",!0)]),f("div",_t,[f("div",Bt,[e.link?(v(),g("a",{key:0,class:"wl-nick",href:e.link,target:"_blank",rel:"nofollow noreferrer"},w(e.comment.nick),9,Ft)):(v(),g("span",Dt,w(e.comment.nick),1)),"administrator"===e.comment.type?(v(),g("span",{key:2,class:"wl-badge",textContent:w(e.locale.admin)},null,8,Ht)):y("v-if",!0),e.comment.sticky?(v(),g("span",{key:3,class:"wl-badge",textContent:w(e.locale.sticky)},null,8,qt)):y("v-if",!0),f("span",{class:"wl-time",textContent:w(e.time)},null,8,Wt),f("button",{class:b(["wl-reply",{active:e.isReplyingCurrent}]),title:e.isReplyingCurrent?e.locale.cancelReply:e.locale.reply,onClick:t[0]||(t[0]=t=>e.$emit("reply",e.isReplyingCurrent?null:e.comment))},[h(a)],10,Vt)]),f("div",Jt,[e.comment.browser?(v(),g("span",{key:0,textContent:w(e.comment.browser)},null,8,Kt)):y("v-if",!0),e.comment.os?(v(),g("span",{key:1,textContent:w(e.comment.os)},null,8,Yt)):y("v-if",!0)]),f("div",{class:"wl-content",innerHTML:e.comment.comment},null,8,Gt),e.isReplyingCurrent?(v(),g("div",Qt,[h(s,{replyId:e.comment.objectId,replyUser:e.comment.nick,rootId:e.rootId,onSubmit:t[1]||(t[1]=t=>e.$emit("submit",t)),onCancelReply:t[2]||(t[2]=t=>e.$emit("reply",null))},null,8,["replyId","replyUser","rootId"])])):y("v-if",!0),e.comment.children?(v(),g("div",Xt,[(v(!0),g(k,null,C(e.comment.children,(n=>(v(),R(c,{key:n.objectId,comment:n,reply:e.reply,rootId:e.rootId,onReply:t[3]||(t[3]=t=>e.$emit("reply",t)),onSubmit:t[4]||(t[4]=t=>e.$emit("submit",t))},null,8,["comment","reply","rootId"])))),128))])):y("v-if",!0)])],8,Pt)},Mt.__file="src/components/CommentCard.vue";var Zt=c({name:"WalineRoot",components:{CommentBox:tt,CommentCard:Mt,LoadingIcon:et},props:{serverURL:{type:String,required:!0},path:{type:String,required:!0},meta:{type:Array},requiredMeta:{type:Array},dark:{type:[String,Boolean]},lang:{type:String},locale:{type:Object},pageSize:{type:Number},wordLimit:{type:[Number,Array]},emoji:{type:Array},login:{type:String},highlighter:{type:Function},imageUploader:{type:[Function,Boolean]},texRenderer:{type:[Function,Boolean]}},setup(t){const n=a((()=>(({serverURL:e,path:t=location.pathname,lang:n="zh-CN",locale:o,emoji:r=["https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo"],meta:l=["nick","mail","link"],requiredMeta:i=[],dark:a=!1,pageSize:s=10,wordLimit:c,imageUploader:u,highlighter:m,texRenderer:d,copyright:p=!0,login:v="enable",...g})=>({serverURL:Ae(e),path:Re(t),locale:{...G[n]||G["zh-CN"],..."object"==typeof o?o:{}},wordLimit:Ue(c),meta:T(l),requiredMeta:T(i),imageUploader:ze(u,B),highlighter:ze(m,P),texRenderer:ze(d,F),lang:n,dark:a,emoji:r,pageSize:s,login:v,copyright:p,...g}))(t))),r=Xe(),l=e("loading"),i=e(0),s=e(1),c=e(0),u=e([]),d=e(null),p=a((()=>{return"string"==typeof(e=n.value.dark)?"auto"===e?`@media(prefers-color-scheme:dark){body${Oe}}`:`${e}${Oe}`:!0===e?`:root${Oe}`:"";var e}));let v,g;const f=e=>{var t;const{serverURL:o,path:a,pageSize:m}=n.value,d=new AbortController;l.value="loading",null==v||v(),(({serverURL:e,path:t,page:n,pageSize:o,signal:r,token:l})=>{const i={};return l&&(i.Authorization=`Bearer ${l}`),fetch(`${e}/comment?path=${encodeURIComponent(t)}&pageSize=${o}&page=${n}`,{signal:r,headers:i}).then((e=>e.json())).then((e=>_e(e,"comment list")))})({serverURL:o,path:a,pageSize:m,page:e,signal:d.signal,token:null===(t=r.value)||void 0===t?void 0:t.token}).then((t=>{l.value="success",i.value=t.count,u.value.push(...t.data),s.value=e,c.value=t.totalPages})).catch((e=>{"AbortError"!==e.name&&(console.error(e.message),l.value="error")})),v=d.abort.bind(d)},h=()=>{i.value=0,u.value=[],f(1)};return x("config",n),o((()=>t.path),h),m((()=>{var e;h();const t=document.createElement("style");t.innerText=p.value,null===(e=document.querySelector("[data-waline]"))||void 0===e||e.appendChild(t),g=E((()=>{t.innerText=p.value}))})),A((()=>g())),{config:n,darkmodeStyle:p,i18n:a((()=>n.value.locale)),status:l,count:i,page:s,totalPages:c,data:u,reply:d,loadMore:()=>f(s.value+1),refresh:h,onReply:e=>{d.value=e},onSubmit:e=>{if(e.rid){const t=u.value.find((({objectId:t})=>t===e.rid));if(!t)return;Array.isArray(t.children)||(t.children=[]),t.children.push(e)}else u.value.unshift(e)},version:"2.0.4"}}});const en={"data-waline":""},tn={class:"wl-count"},nn=["textContent"],on={class:"wl-cards"},rn={key:1,class:"wl-operation"},ln=["textContent"],an={key:0,class:"wl-loading"},sn=["textContent"],cn={class:"wl-operation"},un=["textContent"],mn={key:3,class:"wl-power"},dn=S(" Powered by "),pn=f("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noreferrer"}," Waline ",-1);Zt.render=function(e,t,n,o,r,l){const i=p("CommentBox"),a=p("CommentCard"),s=p("LoadingIcon");return v(),g("div",en,[e.reply?y("v-if",!0):(v(),R(i,{key:0,onSubmit:e.onSubmit},null,8,["onSubmit"])),f("div",tn,[e.count?(v(),g("span",{key:0,class:"wl-num",textContent:w(e.count)},null,8,nn)):y("v-if",!0),S(" "+w(e.i18n.comment),1)]),f("div",on,[(v(!0),g(k,null,C(e.data,(t=>(v(),R(a,{key:t.objectId,"root-id":t.objectId,comment:t,reply:e.reply,onReply:e.onReply,onSubmit:e.onSubmit},null,8,["root-id","comment","reply","onReply","onSubmit"])))),128))]),"error"===e.status?(v(),g("div",rn,[f("button",{type:"button",class:"wl-btn",onClick:t[0]||(t[0]=(...t)=>e.refresh&&e.refresh(...t)),textContent:w(e.i18n.refresh)},null,8,ln)])):(v(),g(k,{key:2},["loading"===e.status?(v(),g("div",an,[h(s,{size:30})])):e.data.length?e.page<e.totalPages?(v(),g(k,{key:2},[y(" Load more button "),f("div",cn,[f("button",{type:"button",class:"wl-btn",onClick:t[1]||(t[1]=(...t)=>e.loadMore&&e.loadMore(...t)),textContent:w(e.i18n.more)},null,8,un)])],2112)):y("v-if",!0):(v(),g("div",{key:1,class:"wl-empty",textContent:w(e.i18n.sofa)},null,8,sn))],2112)),y(" Copyright Information "),e.config.copyright?(v(),g("div",mn,[dn,pn,S(" v"+w(e.version),1)])):y("v-if",!0)])},Zt.__file="src/components/Waline.vue";const vn=(e,t)=>{t.forEach(((t,n)=>{t.innerText=e[n].toString()}))},gn=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-pageview-count",update:o=!0})=>{const r=new AbortController,l=Array.from(document.querySelectorAll(n)),i=e=>{const n=Ge(e);return null!==n&&t!==n},a=n=>Be({serverURL:e,paths:n.map((e=>Ge(e)||t)),signal:r.signal}).then((e=>vn(e,n))).catch(Te);if(o){const n=l.filter((e=>!i(e))),o=l.filter(i);Fe({serverURL:e,path:t}).then((e=>vn(new Array(n.length).fill(e),n))),o.length&&a(o)}else a(l);return r.abort.bind(r)},fn=({el:e="#waline",path:t=window.location.pathname,comment:n=!1,pageview:o=!1,...r})=>{const l=e?De(e):null;if(e&&!l)throw new Error("Option 'el' do not match any domElement!");if(!r.serverURL)throw new Error("Option 'serverURL' is missing!");const i=U({...r}),a=U({comment:n,pageview:o,path:t}),c=()=>{a.comment&&Ze({serverURL:i.serverURL,path:a.path,selector:"string"==typeof a.comment?a.comment:void 0})},u=()=>{a.pageview&&gn({serverURL:i.serverURL,path:a.path,selector:"string"==typeof a.pageview?a.pageview:void 0})},m=l?z((()=>s(Zt,{path:a.path,...i}))):null;m&&m.mount(l),c(),u();const d=E(c),p=E(u);return{el:l,update:({comment:e,pageview:t,path:n=window.location.pathname,...o})=>{Object.entries(o).forEach((([e,t])=>{i[e]=t})),a.path=n,void 0!==e&&(a.comment=e),void 0!==t&&(a.pageview=t)},destroy:()=>{null==m||m.unmount(),d(),p()}}},hn="2.0.4",wn=({el:e,serverURL:t,count:n})=>{var o;const r=Xe(),l=De(e),i=new AbortController;return(({serverURL:e,count:t,signal:n,token:o})=>{const r={};return o&&(r.Authorization=`Bearer ${o}`),fetch(`${e}/comment?type=recent&count=${t}`,{signal:n,headers:r}).then((e=>e.json())).then((e=>_e(e,"recent comment")))})({serverURL:t,count:n,signal:i.signal,token:null===(o=r.value)||void 0===o?void 0:o.token}).then((e=>l&&e.length?(l.innerHTML=`<ul class="wl-recent-list">${e.map((e=>`<li class="wl-recent-item"><a href="${e.url}">${e.nick}</a>:${e.comment}</li>`)).join("")}</ul>`,{comments:e,destroy:()=>{i.abort(),l.innerHTML=""}}):{comments:e,destroy:()=>i.abort()}))};export{wn as RecentComments,Ze as commentCount,_ as defaultLang,F as defaultTexRenderer,B as defaultUploadImage,T as getMeta,fn as init,G as locales,gn as pageviewCount,hn as version};
1
+ import{ref as e,unref as t,isRef as n,watch as o,getCurrentScope as r,onScopeDispose as l,shallowRef as a,computed as i,h as s,defineComponent as c,inject as u,onMounted as m,onUnmounted as d,resolveComponent as p,openBlock as v,createElementBlock as g,createElementVNode as f,createVNode as h,toDisplayString as w,createCommentVNode as y,normalizeClass as b,Fragment as k,renderList as C,withDirectives as $,vModelDynamic as I,vModelText as j,vShow as L,createTextVNode as S,createBlock as R,provide as x,watchEffect as E,onBeforeUnmount as A,reactive as U,createApp as z}from"vue";import M from"autosize";import{marked as O}from"marked";import P from"hanabi";const N=["nick","mail","link"],T=e=>e.filter((e=>N.includes(e))),_="zh-CN",B=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})),F=e=>!0===e?'<p class="wl-tex">Tex is not available in preview</p>':'<span class="wl-tex">Tex is not available in preview</span>',D=["nick","nickError","mail","mailError","link","optional","placeholder","sofa","submit","reply","cancelReply","comment","refresh","more","preview","emoji","uploadImage","seconds","minutes","hours","days","now","uploading","login","logout","admin","sticky","word","wordHint","anonymous"],q=e=>Object.fromEntries(e.map(((e,t)=>[D[t],e])));var H=q(["NickName","NickName cannot be less than 3 bytes.","E-Mail","Please confirm your email address.","Website","Optional","Comment here...","No comment yet.","Submit","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"]),W=q(["ニックネーム","3バイト以上のニックネームをご入力ください.","メールアドレス","メールアドレスをご確認ください.","サイト","オプション","ここにコメント","コメントしましょう~","提出する","返信する","キャンセル","コメント","更新","さらに読み込む","プレビュー","絵文字","画像をアップロード","秒前","分前","時間前","日前","たっだ今","アップロード","ログインする","ログアウト","管理者","トップに置く","ワード","コメントは $0 から $1 ワードの間でなければなりません!\n 現在の単語番号: $2","匿名"]),V=q(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字","评论字数应在 $0 到 $1 字之间!\n当前字数:$2","匿名"]),J=q(["暱稱","郵箱","網址","可選","暱稱不能少於3個字元","請填寫正確的郵件地址","歡迎評論","來發評論吧~","提交","回覆","取消回覆","評論","刷新","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登錄","退出","博主","置頂","字","評論字數應在 $0 到 $1 字之間!\n當前字數:$2","匿名"]),K=q(["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","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"]),Y=q(["Псевдоним","Никнейм не может быть меньше 3 байт.","Эл. адрес","Пожалуйста, подтвердите адрес вашей электронной почты.","Веб-сайт","Необязательный","Комментарий здесь...","Пока нет комментариев.","Отправить","Отвечать","Отменить ответ","Комментарии","Обновить","Загрузи больше...","Превью","эмодзи","Загрузить изображение","секунд назад","несколько минут назад","несколько часов назад","дней назад","прямо сейчас","Загрузка","Авторизоваться","Выход из системы","Админ","Липкий","Слова","Пожалуйста, введите комментарии от $0 до $1 слов!\nНомер текущего слова: $2","Анонимный"]);const G={zh:V,"zh-cn":V,"zh-CN":V,"zh-tw":J,"zh-TW":J,en:H,"en-US":H,"en-us":H,jp:W,"jp-jp":W,"jp-JP":W,"pt-br":K,"pt-BR":K,ru:Y,"ru-ru":Y,"ru-RU":Y};function X(e){return!!r()&&(l(e),!0)}const Q="undefined"!=typeof window,Z=()=>{};const ee=e=>e();var te=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;function re(e,t,n={}){const r=n,{eventFilter:l=ee}=r,a=((e,t)=>{var n={};for(var o in e)ne.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&te)for(var o of te(e))t.indexOf(o)<0&&oe.call(e,o)&&(n[o]=e[o]);return n})(r,["eventFilter"]);return o(e,(i=l,s=t,function(...e){i((()=>s.apply(this,e)),{fn:s,thisArg:this,args:e})}),a);var i,s}var le=Object.defineProperty,ae=Object.defineProperties,ie=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,me=(e,t,n)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function de(t,n,o={}){const r=o,{eventFilter:l}=r,a=((e,t)=>{var n={};for(var o in e)ce.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&se)for(var o of se(e))t.indexOf(o)<0&&ue.call(e,o)&&(n[o]=e[o]);return n})(r,["eventFilter"]),{eventFilter:i,pause:s,resume:c,isActive:u}=function(t=ee){const n=e(!0);return{isActive:n,pause:function(){n.value=!1},resume:function(){n.value=!0},eventFilter:(...e)=>{n.value&&t(...e)}}}(l),m=re(t,n,(d=((e,t)=>{for(var n in t||(t={}))ce.call(t,n)&&me(e,n,t[n]);if(se)for(var n of se(t))ue.call(t,n)&&me(e,n,t[n]);return e})({},a),ae(d,ie({eventFilter:i}))));var d;return{stop:m,pause:s,resume:c,isActive:u}}const pe=Q?window:void 0;function ve(...e){let n,r,l,a;if("string"==typeof e[0]?([r,l,a]=e,n=pe):[n,r,l,a]=e,!n)return Z;let i=Z;const s=o((()=>function(e){var n;const o=t(e);return null!=(n=null==o?void 0:o.$el)?n:o}(n)),(e=>{i(),e&&(e.addEventListener(r,l,a),i=()=>{e.removeEventListener(r,l,a),i=Z})}),{immediate:!0,flush:"post"}),c=()=>{s(),i()};return X(c),c}Q&&window.document,Q&&window.navigator,Q&&window.location;const ge="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},fe="__vueuse_ssr_handlers__";ge[fe]=ge[fe]||{};const he=ge[fe];const we={boolean:{read:e=>"true"===e,write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}};function ye(n,o,r,l={}){var i;const{flush:s="pre",deep:c=!0,listenToStorageChanges:u=!0,writeDefaults:m=!0,shallow:d,window:p=pe,eventFilter:v,onError:g=(e=>{console.error(e)})}=l,f=(d?a:e)(o);if(!r)try{r=function(e,t){return he[e]||t}("getDefaultStorage",(()=>{var e;return null==(e=pe)?void 0:e.localStorage}))()}catch(e){g(e)}if(!r)return f;const h=t(o),w=function(e){return null==e?"any":e instanceof Set?"set":e instanceof Map?"map":e instanceof Date?"date":"boolean"==typeof e?"boolean":"string"==typeof e?"string":"object"==typeof e||Array.isArray(e)?"object":Number.isNaN(e)?"any":"number"}(h),y=null!=(i=l.serializer)?i:we[w],{pause:b,resume:k}=de(f,(()=>function(e){try{null==e?r.removeItem(n):r.setItem(n,y.write(e))}catch(e){g(e)}}(f.value)),{flush:s,deep:c,eventFilter:v});return p&&u&&ve(p,"storage",C),C(),f;function C(e){e&&e.key!==n||(f.value=function(e){if(!e||e.key===n){b();try{const t=e?e.newValue:r.getItem(n);return null==t?(m&&null!==h&&r.setItem(n,y.write(h)),h):"string"!=typeof t?t:y.read(t)}catch(e){g(e)}finally{k()}}}(e))}}var be,ke,Ce=Object.defineProperty,$e=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,Le=(e,t,n)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function Se(r={}){const{controls:l=!1,interval:a="requestAnimationFrame"}=r,i=e(new Date),s=()=>i.value=new Date,c="requestAnimationFrame"===a?function(t,n={}){const{immediate:o=!0,window:r=pe}=n,l=e(!1);let a=null;function i(){l.value&&r&&(t(),a=r.requestAnimationFrame(i))}function s(){!l.value&&r&&(l.value=!0,i())}function c(){l.value=!1,null!=a&&r&&(r.cancelAnimationFrame(a),a=null)}return o&&s(),X(c),{isActive:l,pause:c,resume:s}}(s,{immediate:!0}):function(r,l=1e3,a={}){const{immediate:i=!0,immediateCallback:s=!1}=a;let c=null;const u=e(!1);function m(){c&&(clearInterval(c),c=null)}function d(){u.value=!1,m()}function p(){l<=0||(u.value=!0,s&&r(),m(),c=setInterval(r,t(l)))}i&&Q&&p(),n(l)&&X(o(l,(()=>{i&&Q&&p()})));return X(d),{isActive:u,pause:d,resume:p}}(s,a,{immediate:!0});return l?((e,t)=>{for(var n in t||(t={}))Ie.call(t,n)&&Le(e,n,t[n]);if($e)for(var n of $e(t))je.call(t,n)&&Le(e,n,t[n]);return e})({now:i},c):i}Q&&(null==window?void 0:window.navigator)&&(null==(be=null==window?void 0:window.navigator)?void 0:be.platform)&&/iP(ad|hone|od)/.test(null==(ke=null==window?void 0:window.navigator)?void 0:ke.platform);const Re=e=>{try{e=decodeURI(e)}catch(e){}return e},xe=(e="")=>e.replace(/\/$/u,""),Ee=e=>/^(https?:)?\/\//.test(e),Ae=e=>{const t=xe(e);return Ee(t)?t:`https://${t}`},Ue=e=>Array.isArray(e)?e:!!e&&[0,e],ze=(e,t)=>"function"==typeof e?e:!1!==e&&t,Me="{--waline-white:#000;--waline-light-grey:#666;--waline-dark-grey:#999;--waline-color:#888;--waline-bgcolor:#1e1e1e;--waline-bgcolor-light:#272727;--waline-bgcolor-hover: #444;--waline-border-color:#333;--waline-disable-bgcolor:#444;--waline-disable-color:#272727;--waline-bq-color:#272727;--waline-info-bgcolor:#272727;--waline-info-color:#666}",Oe=(e,t)=>{let n=e.toString();for(;n.length<t;)n="0"+n;return n},Pe=e=>{const t=ye("WALINE_EMOJI",{}),n=Boolean(/@[0-9]+\.[0-9]+\.[0-9]+/.test(e));if(n){const e=t.value.link;if(e)return Promise.resolve(e)}return fetch(`${e}/info.json`).then((e=>e.json())).then((o=>{const r={folder:e,...o};return n&&(t.value.link=r),r}))},Ne=(e,t="",n="",o="")=>`${t?`${t}/`:""}${n}${e}${o?`.${o}`:""}`,Te=e=>{"AbortError"!==e.name&&console.error(e.message)},_e=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},Be=({serverURL:e,paths:t,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>_e(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),Fe=({serverURL:e,path:t})=>fetch(`${e}/article`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})}).then((e=>e.json())).then((e=>_e(e,"visit count"))),De=e=>e instanceof HTMLElement?e:"string"==typeof e?document.querySelector(e):null,qe=e=>e.type.includes("image"),He=e=>{const t=Array.from(e).find(qe);return t?t.getAsFile():null},We=/\$.*?\$/,Ve=/^\$(.*?)\$/,Je=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,Ke=(e="",t={})=>e.replace(/:(.+?):/g,((e,n)=>t[n]?`<img class="wl-emoji" src="${t[n]}" alt="${n}">`:e)),Ye=(e,{emojiMap:t,highlighter:n,texRenderer:o})=>{if(O.setOptions({highlight:n||void 0,breaks:!0,smartLists:!0,smartypants:!0}),o){const e=(e=>[{name:"blockMath",level:"block",tokenizer(t){const n=Je.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(We);return-1!==t?t:e.length},tokenizer(t){const n=Ve.exec(t);if(null!==n)return{type:"html",raw:n[0],text:e(!1,n[1])}}}])(o);O.use({extensions:e})}return O.parse(Ke(e,t))},Ge=e=>e.dataset.path||e.getAttribute("id"),Xe=(e,t)=>{const n=Se();return i((()=>{if(!e)return"";const o="string"==typeof e?new Date(-1!==e.indexOf(" ")?e.replace(/-/g,"/"):e):e,r=n.value.getTime()-o.getTime(),l=Math.floor(r/864e5);if(0===l){const e=r%864e5,n=Math.floor(e/36e5);if(0===n){const n=e%36e5,o=Math.floor(n/6e4);if(0===o){const e=n%6e4;return`${Math.round(e/1e3)} ${t.seconds}`}return`${o} ${t.minutes}`}return`${n} ${t.hours}`}return l<0?t.now:l<8?`${l} ${t.days}`:(e=>{const t=Oe(e.getDate(),2),n=Oe(e.getMonth()+1,2);return`${Oe(e.getFullYear(),2)}-${n}-${t}`})(o)}))},Qe=()=>ye("USER_KEY",{}),Ze=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-comment-count"})=>{var o;const r=new AbortController,l=document.querySelectorAll(n),a=Qe();return l.length&&(({serverURL:e,paths:t,signal:n,token:o})=>{const r={};return o&&(r.Authorization=`Bearer ${o}`),fetch(`${e}/comment?type=count&url=${encodeURIComponent(t.join(","))}`,{signal:n,headers:r}).then((e=>e.json())).then((e=>_e(e,"comment count"))).then((e=>Array.isArray(e)?e:[e]))})({serverURL:e,paths:Array.from(l).map((e=>Re(e.dataset.path||e.getAttribute("id")||t))),signal:r.signal,token:null===(o=a.value)||void 0===o?void 0:o.token}).then((e=>{l.forEach(((t,n)=>{t.innerText=e[n].toString()}))})).catch(Te),r.abort.bind(r)},et=({size:e})=>s("svg",{width:e,height:e,viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid"},s("circle",{cx:50,cy:50,fill:"none",stroke:"currentColor",strokeWidth:"4",r:"40","stroke-dasharray":"85 30"},s("animateTransform",{attributeName:"transform",type:"rotate",repeatCount:"indefinite",dur:"1s",values:"0 50 50;360 50 50",keyTimes:"0;1"})));var tt=c({name:"CommentBox",components:{CloseIcon:({size:e})=>s("svg",{class:"wl-close-icon",viewBox:"0 0 1024 1024",width:e,height:e},[s("path",{d:"M697.173 85.333h-369.92c-144.64 0-241.92 101.547-241.92 252.587v348.587c0 150.613 97.28 252.16 241.92 252.16h369.92c144.64 0 241.494-101.547 241.494-252.16V337.92c0-151.04-96.854-252.587-241.494-252.587z",fill:"currentColor"}),s("path",{d:"m640.683 587.52-75.947-75.861 75.904-75.862a37.29 37.29 0 0 0 0-52.778 37.205 37.205 0 0 0-52.779 0l-75.946 75.818-75.862-75.946a37.419 37.419 0 0 0-52.821 0 37.419 37.419 0 0 0 0 52.821l75.947 75.947-75.776 75.733a37.29 37.29 0 1 0 52.778 52.821l75.776-75.776 75.947 75.947a37.376 37.376 0 0 0 52.779-52.821z",fill:"#888"})]),EmojiIcon:()=>s("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},s("path",{d:"M563.2 463.3 677 540c1.7 1.2 3.7 1.8 5.8 1.8.7 0 1.4-.1 2-.2 2.7-.5 5.1-2.1 6.6-4.4l25.3-37.8c1.5-2.3 2.1-5.1 1.6-7.8s-2.1-5.1-4.4-6.6l-73.6-49.1 73.6-49.1c2.3-1.5 3.9-3.9 4.4-6.6.5-2.7 0-5.5-1.6-7.8l-25.3-37.8a10.1 10.1 0 0 0-6.6-4.4c-.7-.1-1.3-.2-2-.2-2.1 0-4.1.6-5.8 1.8l-113.8 76.6c-9.2 6.2-14.7 16.4-14.7 27.5.1 11 5.5 21.3 14.7 27.4zM387 348.8h-45.5c-5.7 0-10.4 4.7-10.4 10.4v153.3c0 5.7 4.7 10.4 10.4 10.4H387c5.7 0 10.4-4.7 10.4-10.4V359.2c0-5.7-4.7-10.4-10.4-10.4zm333.8 241.3-41-20a10.3 10.3 0 0 0-8.1-.5c-2.6.9-4.8 2.9-5.9 5.4-30.1 64.9-93.1 109.1-164.4 115.2-5.7.5-9.9 5.5-9.5 11.2l3.9 45.5c.5 5.3 5 9.5 10.3 9.5h.9c94.8-8 178.5-66.5 218.6-152.7 2.4-5 .3-11.2-4.8-13.6zm186-186.1c-11.9-42-30.5-81.4-55.2-117.1-24.1-34.9-53.5-65.6-87.5-91.2-33.9-25.6-71.5-45.5-111.6-59.2-41.2-14-84.1-21.1-127.8-21.1h-1.2c-75.4 0-148.8 21.4-212.5 61.7-63.7 40.3-114.3 97.6-146.5 165.8-32.2 68.1-44.3 143.6-35.1 218.4 9.3 74.8 39.4 145 87.3 203.3.1.2.3.3.4.5l36.2 38.4c1.1 1.2 2.5 2.1 3.9 2.6 73.3 66.7 168.2 103.5 267.5 103.5 73.3 0 145.2-20.3 207.7-58.7 37.3-22.9 70.3-51.5 98.1-85 27.1-32.7 48.7-69.5 64.2-109.1 15.5-39.7 24.4-81.3 26.6-123.8 2.4-43.6-2.5-87-14.5-129zm-60.5 181.1c-8.3 37-22.8 72-43 104-19.7 31.1-44.3 58.6-73.1 81.7-28.8 23.1-61 41-95.7 53.4-35.6 12.7-72.9 19.1-110.9 19.1-82.6 0-161.7-30.6-222.8-86.2l-34.1-35.8c-23.9-29.3-42.4-62.2-55.1-97.7-12.4-34.7-18.8-71-19.2-107.9-.4-36.9 5.4-73.3 17.1-108.2 12-35.8 30-69.2 53.4-99.1 31.7-40.4 71.1-72 117.2-94.1 44.5-21.3 94-32.6 143.4-32.6 49.3 0 97 10.8 141.8 32 34.3 16.3 65.3 38.1 92 64.8 26.1 26 47.5 56 63.6 89.2 16.2 33.2 26.6 68.5 31 105.1 4.6 37.5 2.7 75.3-5.6 112.3z",fill:"currentColor"})),ImageIcon:()=>s("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[s("path",{d:"M784 112H240c-88 0-160 72-160 160v480c0 88 72 160 160 160h544c88 0 160-72 160-160V272c0-88-72-160-160-160zm96 640c0 52.8-43.2 96-96 96H240c-52.8 0-96-43.2-96-96V272c0-52.8 43.2-96 96-96h544c52.8 0 96 43.2 96 96v480z",fill:"currentColor"}),s("path",{d:"M352 480c52.8 0 96-43.2 96-96s-43.2-96-96-96-96 43.2-96 96 43.2 96 96 96zm0-128c17.6 0 32 14.4 32 32s-14.4 32-32 32-32-14.4-32-32 14.4-32 32-32zm462.4 379.2-3.2-3.2-177.6-177.6c-25.6-25.6-65.6-25.6-91.2 0l-80 80-36.8-36.8c-25.6-25.6-65.6-25.6-91.2 0L200 728c-4.8 6.4-8 14.4-8 24 0 17.6 14.4 32 32 32 9.6 0 16-3.2 22.4-9.6L380.8 640l134.4 134.4c6.4 6.4 14.4 9.6 24 9.6 17.6 0 32-14.4 32-32 0-9.6-4.8-17.6-9.6-24l-52.8-52.8 80-80L769.6 776c6.4 4.8 12.8 8 20.8 8 17.6 0 32-14.4 32-32 0-8-3.2-16-8-20.8z",fill:"currentColor"})]),MarkdownIcon:()=>s("svg",{width:"16",height:"16",ariaHidden:"true"},s("path",{d:"M14.85 3H1.15C.52 3 0 3.52 0 4.15v7.69C0 12.48.52 13 1.15 13h13.69c.64 0 1.15-.52 1.15-1.15v-7.7C16 3.52 15.48 3 14.85 3zM9 11H7V8L5.5 9.92 4 8v3H2V5h2l1.5 2L7 5h2v6zm2.99.5L9.5 8H11V5h2v3h1.5l-2.51 3.5z",fill:"currentColor"})),PreviewIcon:()=>s("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[s("path",{d:"M710.816 654.301c70.323-96.639 61.084-230.578-23.705-314.843-46.098-46.098-107.183-71.109-172.28-71.109-65.008 0-126.092 25.444-172.28 71.109-45.227 46.098-70.756 107.183-70.756 172.106 0 64.923 25.444 126.007 71.194 172.106 46.099 46.098 107.184 71.109 172.28 71.109 51.414 0 100.648-16.212 142.824-47.404l126.53 126.006c7.058 7.06 16.297 10.979 26.406 10.979 10.105 0 19.343-3.919 26.402-10.979 14.467-14.467 14.467-38.172 0-52.723L710.816 654.301zm-315.107-23.265c-65.88-65.88-65.88-172.54 0-238.42 32.069-32.07 74.245-49.149 119.471-49.149 45.227 0 87.407 17.603 119.472 49.149 65.88 65.879 65.88 172.539 0 238.42-63.612 63.178-175.242 63.178-238.943 0zm0 0",fill:"currentColor"}),s("path",{d:"M703.319 121.603H321.03c-109.8 0-199.469 89.146-199.469 199.38v382.034c0 109.796 89.236 199.38 199.469 199.38h207.397c20.653 0 37.384-16.645 37.384-37.299 0-20.649-16.731-37.296-37.384-37.296H321.03c-68.582 0-124.352-55.77-124.352-124.267V321.421c0-68.496 55.77-124.267 124.352-124.267h382.289c68.582 0 124.352 55.771 124.352 124.267V524.72c0 20.654 16.736 37.299 37.385 37.299 20.654 0 37.384-16.645 37.384-37.299V320.549c-.085-109.8-89.321-198.946-199.121-198.946zm0 0",fill:"currentColor"})]),LoadingIcon:et},props:{rootId:{type:String,default:""},replyId:{type:String,default:""},replyUser:{type:String,default:""}},emits:["submit","cancel-reply"],setup(t,{emit:n}){const r=u("config"),l=ye("WALINE_COMMENT_BOX_EDITOR",""),a=ye("WALINE_USER_META",{nick:"",mail:"",link:""}),s=Qe(),c=e({}),p=e(null),v=e(null),g=e(null),f=e(null),h=e({tabs:[],map:{}}),w=e(0),y=e(!1),b=e(!1),k=e(""),C=e(0),$=e(0),I=e(!1),j=e(""),L=e(!1),S=i((()=>r.value.locale)),R=i((()=>{var e;return Boolean(null===(e=s.value)||void 0===e?void 0:e.token)})),x=i((()=>!1!==r.value.imageUploader)),E=e=>{const t=p.value,n=t.selectionStart,o=t.selectionEnd||0,r=t.scrollTop;l.value=t.value.substring(0,n)+e+t.value.substring(o,t.value.length),t.focus(),t.selectionStart=n+e.length,t.selectionEnd=n+e.length,t.scrollTop=r},A=e=>{const t=`![${r.value.locale.uploading} ${e.name}]()`;return E(t),Promise.resolve().then((()=>r.value.imageUploader(e))).then((n=>{l.value=l.value.replace(t,`\r\n![${e.name}](${n})`)}))},U=()=>{var e,o,i,u,m;const{serverURL:d,lang:v,login:g,wordLimit:f,requiredMeta:w}=r.value,y={comment:j.value,nick:a.value.nick,mail:a.value.mail,link:a.value.link,ua:navigator.userAgent,url:r.value.path};if(null===(e=s.value)||void 0===e?void 0:e.token)y.nick=s.value.display_name,y.mail=s.value.email,y.link=s.value.url;else{if("force"===g)return;if((w.indexOf("nick")>-1||y.nick)&&!y.nick)return null===(o=c.value.nick)||void 0===o||o.focus(),alert(S.value.nickError);if(w.indexOf("mail")>-1&&!y.mail)return null===(i=c.value.mail)||void 0===i||i.focus(),alert(S.value.mailError);if(!y.comment)return void(null===(u=p.value)||void 0===u||u.focus());y.nick||(y.nick=S.value.anonymous)}if(!I.value)return alert(S.value.wordHint.replace("$0",f[0].toString()).replace("$1",f[1].toString()).replace("$2",C.value.toString()));y.comment=Ke(y.comment,h.value.map),t.replyId&&t.rootId&&(y.pid=t.replyId,y.rid=t.rootId,y.at=t.replyUser),L.value=!0,(({serverURL:e,lang:t,token:n,comment:o})=>{const r={"Content-Type":"application/json"};return n&&(r.Authorization=`Bearer ${n}`),fetch(`${e}/comment?lang=${t}`,{method:"POST",headers:r,body:JSON.stringify(o)}).then((e=>e.json()))})({serverURL:d,lang:v,token:null===(m=s.value)||void 0===m?void 0:m.token,comment:y}).then((e=>{if(L.value=!1,e.errmsg)return alert(e.errmsg);n("submit",e.data),l.value="",k.value="",t.replyId&&n("cancel-reply")})).catch((e=>{L.value=!1,alert(e.message)}))},z=e=>{g.value.contains(e.target)||f.value.contains(e.target)||(y.value=!1)};return o([r,C],(([e,t])=>{const{wordLimit:n}=e;n?t<n[0]&&0!==n[0]?($.value=n[0],I.value=!1):t>n[1]?($.value=n[1],I.value=!1):($.value=n[1],I.value=!0):($.value=0,I.value=!0)}),{immediate:!0}),m((()=>{document.body.addEventListener("click",z),o((()=>l.value),(e=>{const{highlighter:t,texRenderer:n}=r.value;j.value=e,k.value=Ye(e,{emojiMap:h.value.map,highlighter:t,texRenderer:n}),C.value=(e=>(e=>e.match(/[\w\d\s\u00C0-\u024F]+/giu)||[])(e).reduce(((e,t)=>e+(""===t.trim()?0:t.trim().split(/\s+/u).length)),0)+(e=>e.match(/[\u4E00-\u9FA5]/gu)||[])(e).length)(e),e?M(p.value):M.destroy(p.value)}),{immediate:!0}),o((()=>r.value.emoji),(e=>{return(t=e,Promise.all(t.map((e=>"string"==typeof e?Pe(xe(e)):Promise.resolve(e)))).then((e=>{const t={tabs:[],map:{}};return e.forEach((e=>{const{name:n,folder:o,icon:r,prefix:l,type:a,items:i}=e;t.tabs.push({name:n,icon:Ne(r,o,l,a),items:i.map((e=>{const n=`${l||""}${e}`;return t.map[n]=Ne(e,o,l,a),n}))})})),t}))).then((e=>{h.value=e}));var t}),{immediate:!0})})),d((()=>{document.body.removeEventListener("click",z)})),{config:r,locale:S,insert:E,onChange:()=>{const e=v.value;e.files&&x.value&&A(e.files[0]).then((()=>{e.value=""}))},onDrop:e=>{var t;if(null===(t=e.dataTransfer)||void 0===t?void 0:t.items){const t=He(e.dataTransfer.items);t&&x.value&&(A(t),e.preventDefault())}},onKeyDown:e=>{const t=e.key;(e.ctrlKey||e.metaKey)&&"Enter"===t&&U()},onPaste:e=>{if(e.clipboardData){const t=He(e.clipboardData.items);t&&x.value&&A(t)}},onLogin:e=>{e.preventDefault();const{lang:t,serverURL:n}=r.value,o=(window.innerWidth-450)/2,l=(window.innerHeight-450)/2,a=window.open(`${n}/ui/login?lng=${encodeURIComponent(t)}`,"_blank",`width=450,height=450,left=${o},top=${l},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==a||a.postMessage({type:"TOKEN",data:null},"*");const i=({data:e})=>{e&&"userInfo"===e.type&&e.data.token&&(null==a||a.close(),s.value=e.data,(e.data.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(e.data)),window.removeEventListener("message",i))};window.addEventListener("message",i)},onLogout:()=>{s.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null")},onProfile:e=>{e.preventDefault();const{lang:t,serverURL:n}=r.value,o=(window.innerWidth-800)/2,l=(window.innerHeight-800)/2,a=window.open(`${n}/ui/profile?lng=${encodeURIComponent(t)}`,"_blank",`width=800,height=800,left=${o},top=${l},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==a||a.postMessage({type:"TOKEN",data:s.value.token},"*");const i=({data:e})=>{e&&"profile"===e.type&&(s.value={...s.value,...e},[localStorage,sessionStorage].filter((e=>e.getItem("WALINE_USER"))).forEach((e=>e.setItem("WALINE_USER",JSON.stringify(s)))),window.removeEventListener("message",i))};window.addEventListener("message",i)},submitComment:U,isLogin:R,userInfo:s,isSubmitting:L,wordNumber:C,wordLimit:$,isWordNumberLegal:I,editor:l,userMeta:a,emoji:h,emojiTabIndex:w,showEmoji:y,canUploadImage:x,previewText:k,showPreview:b,inputRefs:c,editorRef:p,emojiButtonRef:g,emojiPopupRef:f,imageUploadRef:v}}});const nt={class:"wl-comment"},ot={key:0,class:"wl-login-info"},rt={class:"wl-avatar"},lt=["title"],at=["src"],it=["textContent"],st={class:"wl-panel"},ct=["for","textContent"],ut=["id","name","type","onUpdate:modelValue"],mt=["placeholder"],dt={class:"wl-preview"},pt=f("hr",null,null,-1),vt=["innerHTML"],gt={class:"wl-footer"},ft={class:"wl-actions"},ht={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noreferrer"},wt=["title"],yt=["title"],bt=["title"],kt={class:"wl-info"},Ct={class:"wl-text-number"},$t={key:0},It=S("  /  "),jt=["textContent"],Lt=["textContent"],St=["disabled"],Rt={key:0,class:"wl-tab-wrapper"},xt=["title","onClick"],Et=["src","alt"],At={key:0,class:"wl-tabs"},Ut=["onClick"],zt=["src","alt","title"],Mt=["title"];tt.render=function(e,t,n,o,r,l){const a=p("CloseIcon"),i=p("MarkdownIcon"),s=p("EmojiIcon"),c=p("ImageIcon"),u=p("PreviewIcon"),m=p("LoadingIcon");return v(),g("div",nt,["disable"!==e.config.login&&e.isLogin?(v(),g("div",ot,[f("div",rt,[f("button",{class:"wl-logout-btn",title:e.locale.logout,onClick:t[0]||(t[0]=(...t)=>e.onLogout&&e.onLogout(...t))},[h(a,{size:14})],8,lt),f("img",{src:e.userInfo.avatar,alt:"avatar"},null,8,at)]),f("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",onClick:t[1]||(t[1]=(...t)=>e.onProfile&&e.onProfile(...t)),textContent:w(e.userInfo.display_name)},null,8,it)])):y("v-if",!0),f("div",st,["force"!==e.config.login&&e.config.meta.length&&!e.isLogin?(v(),g("div",{key:0,class:b(["wl-header",`item${e.config.meta.length}`])},[(v(!0),g(k,null,C(e.config.meta,(t=>(v(),g("div",{class:"wl-header-item",key:t},[f("label",{for:t,textContent:w(e.locale[t]+(e.config.requiredMeta.includes(t)||!e.config.requiredMeta.length?"":`(${e.locale.optional})`))},null,8,ct),$(f("input",{ref_for:!0,ref:n=>{n&&(e.inputRefs[t]=n)},id:`wl-${t}`,class:b(["wl-input",`wl-${t}`]),name:t,type:"mail"===t?"email":"text","onUpdate:modelValue":n=>e.userMeta[t]=n},null,10,ut),[[I,e.userMeta[t]]])])))),128))],2)):y("v-if",!0),$(f("textarea",{class:"wl-editor",ref:"editorRef",id:"wl-edit",placeholder:e.replyUser?`@${e.replyUser}`:e.locale.placeholder,"onUpdate:modelValue":t[2]||(t[2]=t=>e.editor=t),onKeydown:t[3]||(t[3]=(...t)=>e.onKeyDown&&e.onKeyDown(...t)),onDrop:t[4]||(t[4]=(...t)=>e.onDrop&&e.onDrop(...t)),onPaste:t[5]||(t[5]=(...t)=>e.onPaste&&e.onPaste(...t))},null,40,mt),[[j,e.editor]]),$(f("div",dt,[pt,f("h4",null,w(e.locale.preview)+":",1),f("div",{class:"wl-content",innerHTML:e.previewText},null,8,vt)],512),[[L,e.showPreview]]),f("div",gt,[f("div",ft,[f("a",ht,[h(i)]),f("button",{ref:"emojiButtonRef",class:b(["wl-action",{actived:e.showEmoji}]),title:e.locale.emoji,onClick:t[6]||(t[6]=t=>e.showEmoji=!e.showEmoji)},[h(s)],10,wt),f("input",{ref:"imageUploadRef",class:"upload",id:"wl-image-upload",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:t[7]||(t[7]=(...t)=>e.onChange&&e.onChange(...t))},null,544),e.canUploadImage?(v(),g("label",{key:0,for:"wl-image-upload",class:"wl-action",title:e.locale.uploadImage},[h(c)],8,yt)):y("v-if",!0),f("button",{class:b(["wl-action",{actived:e.showPreview}]),title:e.locale.preview,onClick:t[8]||(t[8]=t=>e.showPreview=!e.showPreview)},[h(u)],10,bt)]),f("div",kt,[f("div",Ct,[S(w(e.wordNumber)+" ",1),e.config.wordLimit?(v(),g("span",$t,[It,f("span",{class:b({illegal:!e.isWordNumberLegal}),textContent:w(e.wordLimit)},null,10,jt)])):y("v-if",!0),S("  "+w(e.locale.word),1)]),"disable"===e.config.login||e.isLogin?y("v-if",!0):(v(),g("button",{key:0,class:"wl-btn",onClick:t[9]||(t[9]=(...t)=>e.onLogin&&e.onLogin(...t)),textContent:w(e.locale.login)},null,8,Lt)),"force"!==e.config.login||e.isLogin?(v(),g("button",{key:1,class:"wl-btn primary",title:"Cmd|Ctrl + Enter",disabled:e.isSubmitting,onClick:t[10]||(t[10]=(...t)=>e.submitComment&&e.submitComment(...t))},[e.isSubmitting?(v(),R(m,{key:0,size:16})):(v(),g(k,{key:1},[S(w(e.locale.submit),1)],2112))],8,St)):y("v-if",!0)]),f("div",{ref:"emojiPopupRef",class:b(["wl-emoji-popup",{display:e.showEmoji}])},[(v(!0),g(k,null,C(e.emoji.tabs,((t,n)=>(v(),g(k,{key:t.name},[n===e.emojiTabIndex?(v(),g("div",Rt,[(v(!0),g(k,null,C(t.items,(t=>(v(),g("button",{key:t,title:t,onClick:n=>e.insert(`:${t}:`)},[e.showEmoji?(v(),g("img",{key:0,class:"wl-emoji",src:e.emoji.map[t],alt:t,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Et)):y("v-if",!0)],8,xt)))),128))])):y("v-if",!0)],64)))),128)),e.emoji.tabs.length>1?(v(),g("div",At,[(v(!0),g(k,null,C(e.emoji.tabs,((t,n)=>(v(),g("button",{key:t.name,class:b(["wl-tab",{active:e.emojiTabIndex===n}]),onClick:t=>e.emojiTabIndex=n},[f("img",{class:"wl-emoji",src:t.icon,alt:t.name,title:t.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,zt)],10,Ut)))),128))])):y("v-if",!0)],2)])]),e.replyId?(v(),g("button",{key:1,class:"wl-close",title:e.locale.cancelReply,onClick:t[11]||(t[11]=t=>e.$emit("cancel-reply"))},[h(a,{size:24})],8,Mt)):y("v-if",!0)])},tt.__file="src/components/CommentBox.vue";var Ot=c({props:{comment:{type:Object,required:!0},rootId:{type:String,required:!0},reply:{type:Object}},components:{CommentBox:tt,ReplyIcon:()=>s("svg",{viewBox:"0 0 1024 1024",width:"18",height:"18"},s("path",{d:"M1019.2 720C1001.6 625.6 968 566.4 904 497.6c-89.6-89.6-214.4-150.4-347.2-176v-120c0-25.6-8-51.2-25.6-64-33.6-30.4-81.6-30.4-112-4.8L33.6 441.6C12.8 459.2 0 484.8 0 510.4c0 25.6 12.8 51.2 30.4 68.8l385.6 312c17.6 12.8 33.6 17.6 51.2 17.6 12.8 0 25.6-4.8 38.4-8C536 888 552 857.6 552 824v-99.2c124.8 20.8 248 86.4 339.2 140.8 25.6 17.6 59.2 17.6 89.6 0 25.6-17.6 43.2-46.4 43.2-76.8 0-33.6 0-56-4.8-68.8zm-500.8-89.6-46.4-4.8v193.6L86.4 510.4 472 201.6V400l38.4 4.8c128 12.8 248 68.8 334.4 153.6 51.2 56 76.8 102.4 94.4 179.2 0 4.8 4.8 20.8 4.8 51.2C835.2 720 672 640 518.4 630.4z",fill:"currentColor"})),VerifiedIcon:()=>s("svg",{class:"verified-icon",viewBox:"0 0 1024 1024",width:"14",height:"14"},s("path",{d:"m894.4 461.56-54.4-63.2c-10.4-12-18.8-34.4-18.8-50.4v-68c0-42.4-34.8-77.2-77.2-77.2h-68c-15.6 0-38.4-8.4-50.4-18.8l-63.2-54.4c-27.6-23.6-72.8-23.6-100.8 0l-62.8 54.8c-12 10-34.8 18.4-50.4 18.4h-69.2c-42.4 0-77.2 34.8-77.2 77.2v68.4c0 15.6-8.4 38-18.4 50l-54 63.6c-23.2 27.6-23.2 72.4 0 100l54 63.6c10 12 18.4 34.4 18.4 50v68.4c0 42.4 34.8 77.2 77.2 77.2h69.2c15.6 0 38.4 8.4 50.4 18.8l63.2 54.4c27.6 23.6 72.8 23.6 100.8 0l63.2-54.4c12-10.4 34.4-18.8 50.4-18.8h68c42.4 0 77.2-34.8 77.2-77.2v-68c0-15.6 8.4-38.4 18.8-50.4l54.4-63.2c23.2-27.6 23.2-73.2-.4-100.8zm-216-25.2-193.2 193.2a30 30 0 0 1-42.4 0l-96.8-96.8a30.16 30.16 0 0 1 0-42.4c11.6-11.6 30.8-11.6 42.4 0l75.6 75.6 172-172c11.6-11.6 30.8-11.6 42.4 0 11.6 11.6 11.6 30.8 0 42.4z",fill:"#27ae60"}))},emits:["submit","reply"],setup(e){const t=u("config"),n=i((()=>t.value.locale)),o=i((()=>{let{link:t}=e.comment;return t?Ee(t)?t:`https://${t}`:""})),r=Xe(e.comment.insertedAt,n.value),l=i((()=>{var t;return e.comment.objectId===(null===(t=e.reply)||void 0===t?void 0:t.objectId)}));return{config:t,locale:n,isReplyingCurrent:l,link:o,time:r}}});const Pt=["id"],Nt={class:"wl-user","aria-hidden":"true"},Tt=["src"],_t={class:"wl-card"},Bt={class:"wl-head"},Ft=["href"],Dt={key:1,class:"wl-nick"},qt=["textContent"],Ht=["textContent"],Wt=["textContent"],Vt=["title"],Jt={class:"wl-meta","aria-hidden":"true"},Kt=["textContent"],Yt=["textContent"],Gt=["innerHTML"],Xt={key:0,class:"wl-reply-wrapper"},Qt={key:1,class:"wl-quote"};Ot.render=function(e,t,n,o,r,l){const a=p("VerifiedIcon"),i=p("ReplyIcon"),s=p("CommentBox"),c=p("CommentCard",!0);return v(),g("div",{class:"wl-item",id:e.comment.objectId},[f("div",Nt,[e.comment.avatar?(v(),g("img",{key:0,src:e.comment.avatar},null,8,Tt)):y("v-if",!0),e.comment.type?(v(),R(a,{key:1})):y("v-if",!0)]),f("div",_t,[f("div",Bt,[e.link?(v(),g("a",{key:0,class:"wl-nick",href:e.link,target:"_blank",rel:"nofollow noreferrer"},w(e.comment.nick),9,Ft)):(v(),g("span",Dt,w(e.comment.nick),1)),"administrator"===e.comment.type?(v(),g("span",{key:2,class:"wl-badge",textContent:w(e.locale.admin)},null,8,qt)):y("v-if",!0),e.comment.sticky?(v(),g("span",{key:3,class:"wl-badge",textContent:w(e.locale.sticky)},null,8,Ht)):y("v-if",!0),f("span",{class:"wl-time",textContent:w(e.time)},null,8,Wt),f("button",{class:b(["wl-reply",{active:e.isReplyingCurrent}]),title:e.isReplyingCurrent?e.locale.cancelReply:e.locale.reply,onClick:t[0]||(t[0]=t=>e.$emit("reply",e.isReplyingCurrent?null:e.comment))},[h(i)],10,Vt)]),f("div",Jt,[e.comment.browser?(v(),g("span",{key:0,textContent:w(e.comment.browser)},null,8,Kt)):y("v-if",!0),e.comment.os?(v(),g("span",{key:1,textContent:w(e.comment.os)},null,8,Yt)):y("v-if",!0)]),f("div",{class:"wl-content",innerHTML:e.comment.comment},null,8,Gt),e.isReplyingCurrent?(v(),g("div",Xt,[h(s,{replyId:e.comment.objectId,replyUser:e.comment.nick,rootId:e.rootId,onSubmit:t[1]||(t[1]=t=>e.$emit("submit",t)),onCancelReply:t[2]||(t[2]=t=>e.$emit("reply",null))},null,8,["replyId","replyUser","rootId"])])):y("v-if",!0),e.comment.children?(v(),g("div",Qt,[(v(!0),g(k,null,C(e.comment.children,(n=>(v(),R(c,{key:n.objectId,comment:n,reply:e.reply,rootId:e.rootId,onReply:t[3]||(t[3]=t=>e.$emit("reply",t)),onSubmit:t[4]||(t[4]=t=>e.$emit("submit",t))},null,8,["comment","reply","rootId"])))),128))])):y("v-if",!0)])],8,Pt)},Ot.__file="src/components/CommentCard.vue";var Zt=c({name:"WalineRoot",components:{CommentBox:tt,CommentCard:Ot,LoadingIcon:et},props:{serverURL:{type:String,required:!0},path:{type:String,required:!0},meta:{type:Array},requiredMeta:{type:Array},dark:{type:[String,Boolean]},lang:{type:String},locale:{type:Object},pageSize:{type:Number},wordLimit:{type:[Number,Array]},emoji:{type:Array},login:{type:String},highlighter:{type:Function},imageUploader:{type:[Function,Boolean]},texRenderer:{type:[Function,Boolean]}},setup(t){const n=i((()=>(({serverURL:e,path:t=location.pathname,lang:n="zh-CN",locale:o,emoji:r=["https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo"],meta:l=["nick","mail","link"],requiredMeta:a=[],dark:i=!1,pageSize:s=10,wordLimit:c,imageUploader:u,highlighter:m,texRenderer:d,copyright:p=!0,login:v="enable",...g})=>({serverURL:Ae(e),path:Re(t),locale:{...G[n]||G["zh-CN"],..."object"==typeof o?o:{}},wordLimit:Ue(c),meta:T(l),requiredMeta:T(a),imageUploader:ze(u,B),highlighter:ze(m,P),texRenderer:ze(d,F),lang:n,dark:i,emoji:r,pageSize:s,login:v,copyright:p,...g}))(t))),r=Qe(),l=e("loading"),a=e(0),s=e(1),c=e(0),u=e([]),d=e(null),p=i((()=>{return"string"==typeof(e=n.value.dark)?"auto"===e?`@media(prefers-color-scheme:dark){body${Me}}`:`${e}${Me}`:!0===e?`:root${Me}`:"";var e}));let v,g;const f=e=>{var t;const{serverURL:o,path:i,pageSize:m}=n.value,d=new AbortController;l.value="loading",null==v||v(),(({serverURL:e,path:t,page:n,pageSize:o,signal:r,token:l})=>{const a={};return l&&(a.Authorization=`Bearer ${l}`),fetch(`${e}/comment?path=${encodeURIComponent(t)}&pageSize=${o}&page=${n}`,{signal:r,headers:a}).then((e=>e.json())).then((e=>_e(e,"comment list")))})({serverURL:o,path:i,pageSize:m,page:e,signal:d.signal,token:null===(t=r.value)||void 0===t?void 0:t.token}).then((t=>{l.value="success",a.value=t.count,u.value.push(...t.data),s.value=e,c.value=t.totalPages})).catch((e=>{"AbortError"!==e.name&&(console.error(e.message),l.value="error")})),v=d.abort.bind(d)},h=()=>{a.value=0,u.value=[],f(1)};return x("config",n),o((()=>t.path),h),m((()=>{var e;h();const t=document.createElement("style");t.innerText=p.value,null===(e=document.querySelector("[data-waline]"))||void 0===e||e.appendChild(t),g=E((()=>{t.innerText=p.value}))})),A((()=>g())),{config:n,darkmodeStyle:p,i18n:i((()=>n.value.locale)),status:l,count:a,page:s,totalPages:c,data:u,reply:d,loadMore:()=>f(s.value+1),refresh:h,onReply:e=>{d.value=e},onSubmit:e=>{if(e.rid){const t=u.value.find((({objectId:t})=>t===e.rid));if(!t)return;Array.isArray(t.children)||(t.children=[]),t.children.push(e)}else u.value.unshift(e)},version:"2.0.5"}}});const en={"data-waline":""},tn={class:"wl-count"},nn=["textContent"],on={class:"wl-cards"},rn={key:1,class:"wl-operation"},ln=["textContent"],an={key:0,class:"wl-loading"},sn=["textContent"],cn={class:"wl-operation"},un=["textContent"],mn={key:3,class:"wl-power"},dn=S(" Powered by "),pn=f("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noreferrer"}," Waline ",-1);Zt.render=function(e,t,n,o,r,l){const a=p("CommentBox"),i=p("CommentCard"),s=p("LoadingIcon");return v(),g("div",en,[e.reply?y("v-if",!0):(v(),R(a,{key:0,onSubmit:e.onSubmit},null,8,["onSubmit"])),f("div",tn,[e.count?(v(),g("span",{key:0,class:"wl-num",textContent:w(e.count)},null,8,nn)):y("v-if",!0),S(" "+w(e.i18n.comment),1)]),f("div",on,[(v(!0),g(k,null,C(e.data,(t=>(v(),R(i,{key:t.objectId,"root-id":t.objectId,comment:t,reply:e.reply,onReply:e.onReply,onSubmit:e.onSubmit},null,8,["root-id","comment","reply","onReply","onSubmit"])))),128))]),"error"===e.status?(v(),g("div",rn,[f("button",{type:"button",class:"wl-btn",onClick:t[0]||(t[0]=(...t)=>e.refresh&&e.refresh(...t)),textContent:w(e.i18n.refresh)},null,8,ln)])):(v(),g(k,{key:2},["loading"===e.status?(v(),g("div",an,[h(s,{size:30})])):e.data.length?e.page<e.totalPages?(v(),g(k,{key:2},[y(" Load more button "),f("div",cn,[f("button",{type:"button",class:"wl-btn",onClick:t[1]||(t[1]=(...t)=>e.loadMore&&e.loadMore(...t)),textContent:w(e.i18n.more)},null,8,un)])],2112)):y("v-if",!0):(v(),g("div",{key:1,class:"wl-empty",textContent:w(e.i18n.sofa)},null,8,sn))],2112)),y(" Copyright Information "),e.config.copyright?(v(),g("div",mn,[dn,pn,S(" v"+w(e.version),1)])):y("v-if",!0)])},Zt.__file="src/components/Waline.vue";const vn=(e,t)=>{t.forEach(((t,n)=>{t.innerText=e[n].toString()}))},gn=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-pageview-count",update:o=!0})=>{const r=new AbortController,l=Array.from(document.querySelectorAll(n)),a=e=>{const n=Ge(e);return null!==n&&t!==n},i=n=>Be({serverURL:e,paths:n.map((e=>Ge(e)||t)),signal:r.signal}).then((e=>vn(e,n))).catch(Te);if(o){const n=l.filter((e=>!a(e))),o=l.filter(a);Fe({serverURL:e,path:t}).then((e=>vn(new Array(n.length).fill(e),n))),o.length&&i(o)}else i(l);return r.abort.bind(r)},fn=({el:e="#waline",path:t=window.location.pathname,comment:n=!1,pageview:o=!1,...r})=>{const l=e?De(e):null;if(e&&!l)throw new Error("Option 'el' do not match any domElement!");if(!r.serverURL)throw new Error("Option 'serverURL' is missing!");const a=U({...r}),i=U({comment:n,pageview:o,path:t}),c=()=>{i.comment&&Ze({serverURL:a.serverURL,path:i.path,selector:"string"==typeof i.comment?i.comment:void 0})},u=()=>{i.pageview&&gn({serverURL:a.serverURL,path:i.path,selector:"string"==typeof i.pageview?i.pageview:void 0})},m=l?z((()=>s(Zt,{path:i.path,...a}))):null;m&&m.mount(l),c(),u();const d=E(c),p=E(u);return{el:l,update:({comment:e,pageview:t,path:n=window.location.pathname,...o})=>{Object.entries(o).forEach((([e,t])=>{a[e]=t})),i.path=n,void 0!==e&&(i.comment=e),void 0!==t&&(i.pageview=t)},destroy:()=>{null==m||m.unmount(),d(),p()}}},hn="2.0.5",wn=({el:e,serverURL:t,count:n})=>{var o;const r=Qe(),l=De(e),a=new AbortController;return(({serverURL:e,count:t,signal:n,token:o})=>{const r={};return o&&(r.Authorization=`Bearer ${o}`),fetch(`${e}/comment?type=recent&count=${t}`,{signal:n,headers:r}).then((e=>e.json())).then((e=>_e(e,"recent comment")))})({serverURL:t,count:n,signal:a.signal,token:null===(o=r.value)||void 0===o?void 0:o.token}).then((e=>l&&e.length?(l.innerHTML=`<ul class="wl-recent-list">${e.map((e=>`<li class="wl-recent-item"><a href="${e.url}">${e.nick}</a>:${e.comment}</li>`)).join("")}</ul>`,{comments:e,destroy:()=>{a.abort(),l.innerHTML=""}}):{comments:e,destroy:()=>a.abort()}))};export{wn as RecentComments,Ze as commentCount,_ as defaultLang,F as defaultTexRenderer,B as defaultUploadImage,T as getMeta,fn as init,G as locales,gn as pageviewCount,hn as version};
2
2
  //# sourceMappingURL=shim.esm.js.map