@waline/client 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component.js +1 -1
- package/dist/component.js.map +1 -1
- package/dist/legacy.js +1 -1
- package/dist/legacy.js.map +1 -1
- package/dist/pageview.cjs.js +1 -1
- package/dist/pageview.esm.js +1 -1
- package/dist/pageview.js +1 -1
- package/dist/shim.esm.js +1 -1
- package/dist/shim.esm.js.map +1 -1
- package/dist/shim.js +1 -1
- package/dist/shim.js.map +1 -1
- package/dist/waline.cjs.js +1 -1
- package/dist/waline.cjs.js.map +1 -1
- package/dist/waline.esm.js +1 -1
- package/dist/waline.esm.js.map +1 -1
- package/dist/waline.js +1 -1
- package/dist/waline.js.map +1 -1
- package/package.json +15 -8
- package/src/comment.ts +1 -1
- package/src/components/CommentBox.vue +13 -18
- package/src/components/CommentCard.vue +6 -3
- package/src/components/Waline.vue +3 -25
- package/src/composables/index.ts +1 -1
- package/src/composables/inputs.ts +9 -21
- package/src/composables/timeAgo.ts +61 -0
- package/src/composables/userInfo.ts +14 -21
- package/src/init.ts +1 -1
- package/src/utils/date.ts +17 -0
- package/src/utils/emoji.ts +8 -6
- package/src/utils/{data.ts → image.ts} +0 -0
- package/src/utils/index.ts +2 -3
- package/src/widgets/recentComments.ts +4 -2
- package/src/composables/store.ts +0 -38
- package/src/utils/timeAgo.ts +0 -75
- package/src/utils/userInfo.ts +0 -26
package/dist/pageview.cjs.js
CHANGED
|
@@ -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.
|
|
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.3";
|
|
2
2
|
//# sourceMappingURL=pageview.cjs.js.map
|
package/dist/pageview.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e="2.0.
|
|
1
|
+
const e="2.0.3",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.
|
|
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.3";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{reactive as e,ref as t,readonly as n,h as o,defineComponent as l,inject as r,computed as i,watch as a,onMounted as s,onUnmounted as c,resolveComponent as m,openBlock as u,createElementBlock as d,createElementVNode as p,createVNode as v,toDisplayString as g,createCommentVNode as h,normalizeClass as f,Fragment as y,renderList as w,withDirectives as b,vModelDynamic as k,vModelText as C,vShow as $,createTextVNode as I,createBlock as L,provide as R,watchEffect as S,onBeforeUnmount as j,createApp as x}from"vue";import U from"autosize";import{marked as E}from"marked";import z from"hanabi";const A=["nick","mail","link"],M=e=>e.filter((e=>A.includes(e))),N="zh-CN",P=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})),T=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>',O=["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"],B=e=>Object.fromEntries(e.map(((e,t)=>[O[t],e])));var _=B(["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"]),H=B(["ニックネーム","3バイト以上のニックネームをご入力ください.","メールアドレス","メールアドレスをご確認ください.","サイト","オプション","ここにコメント","コメントしましょう~","提出する","返信する","キャンセル","コメント","更新","さらに読み込む","プレビュー","絵文字","画像をアップロード","秒前","分前","時間前","日前","たっだ今","アップロード","ログインする","ログアウト","管理者","トップに置く","ワード","コメントは $0 から $1 ワードの間でなければなりません!\n 現在の単語番号: $2","匿名"]),W=B(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字","评论字数应在 $0 到 $1 字之间!\n当前字数:$2","匿名"]),q=B(["暱稱","郵箱","網址","可選","暱稱不能少於3個字元","請填寫正確的郵件地址","歡迎評論","來發評論吧~","提交","回覆","取消回覆","評論","刷新","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登錄","退出","博主","置頂","字","評論字數應在 $0 到 $1 字之間!\n當前字數:$2","匿名"]),V=B(["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"]),D=B(["Псевдоним","Никнейм не может быть меньше 3 байт.","Эл. адрес","Пожалуйста, подтвердите адрес вашей электронной почты.","Веб-сайт","Необязательный","Комментарий здесь...","Пока нет комментариев.","Отправить","Отвечать","Отменить ответ","Комментарии","Обновить","Загрузи больше...","Превью","эмодзи","Загрузить изображение","секунд назад","несколько минут назад","несколько часов назад","дней назад","прямо сейчас","Загрузка","Авторизоваться","Выход из системы","Админ","Липкий","Слова","Пожалуйста, введите комментарии от $0 до $1 слов!\nНомер текущего слова: $2","Анонимный"]);const J={zh:W,"zh-cn":W,"zh-CN":W,"zh-tw":q,"zh-TW":q,en:_,"en-US":_,"en-us":_,jp:H,"jp-jp":H,"jp-JP":H,"pt-br":V,"pt-BR":V,ru:D,"ru-ru":D,"ru-RU":D},F=e=>{let t={};const n=localStorage.getItem(e);if(n)try{t=JSON.parse(n)}catch(e){}return{get:e=>t[e]||null,set(n,o){try{t[n]=JSON.parse(JSON.stringify(o)),localStorage.setItem(e,JSON.stringify(t))}catch(e){}},update(n){t=JSON.parse(JSON.stringify(n)),localStorage.setItem(e,JSON.stringify(t))}}};let K,Y;const G=()=>(Y||(K=F("WALINE_USER_CACHE"),Y=e({nick:K.get("nick")||"",mail:K.get("mail")||"",link:K.get("link")||"",editor:""})),{inputs:Y,store:K}),Q=e=>{try{e=decodeURI(e)}catch(e){}return e},X=(e="")=>e.replace(/\/$/u,""),Z=e=>/^(https?:)?\/\//.test(e);let ee;const te=e=>{ee||(ee=F("WALINE_EMOJI"));const t=Boolean(/@[0-9]+\.[0-9]+\.[0-9]+/.test(e));if(t){const t=ee.get(e);if(t)return Promise.resolve(t)}return fetch(`${e}/info.json`).then((e=>e.json())).then((n=>{const o={folder:e,...n};return t&&ee.set(e,o),o}))},ne=(e,t="",n="",o="")=>`${t?`${t}/`:""}${n}${e}${o?`.${o}`:""}`,oe=e=>{const t=X(e);return Z(t)?t:`https://${t}`},le=(e,t)=>"function"==typeof e?e:!1!==e&&t,re="{--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}",ie=e=>e.type.includes("image"),ae=e=>{const t=Array.from(e).find(ie);return t?t.getAsFile():null},se=e=>{"AbortError"!==e.name&&console.error(e.message)},ce=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},me=({serverURL:e,paths:t,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>ce(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),ue=({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=>ce(e,"visit count"))),de=e=>e instanceof HTMLElement?e:"string"==typeof e?document.querySelector(e):null,pe=/\$.*?\$/,ve=/^\$(.*?)\$/,ge=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,he=(e="",t={})=>e.replace(/:(.+?):/g,((e,n)=>t[n]?`<img class="wl-emoji" src="${t[n]}" alt="${n}">`:e)),fe=(e,{emojiMap:t,highlighter:n,texRenderer:o})=>{if(E.setOptions({highlight:n||void 0,breaks:!0,smartLists:!0,smartypants:!0}),o){const e=(e=>[{name:"blockMath",level:"block",tokenizer(t){const n=ge.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(pe);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);E.use({extensions:e})}return E.parse(he(e,t))},ye=e=>e.dataset.path||e.getAttribute("id"),we=(e,t)=>{let n=e.toString();for(;n.length<t;)n="0"+n;return n},be=(e,t)=>{if(e)try{"string"==typeof e&&(e=new Date(-1!==e.indexOf(" ")?e.replace(/-/g,"/"):e));const n=e.getTime(),o=(new Date).getTime()-n,l=Math.floor(o/864e5);if(0===l){const e=o%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=we(e.getDate(),2),n=we(e.getMonth()+1,2);return`${we(e.getFullYear(),2)}-${n}-${t}`})(e)}catch(e){console.log(e)}return""},ke=()=>{try{const e=localStorage.getItem("WALINE_USER"),t=sessionStorage.getItem("WALINE_USER");return e?JSON.parse(e):t?JSON.parse(t):null}catch(e){return null}},Ce=t({}),$e=()=>{if(!Ce.value.token){const e=ke();e&&(Ce.value=e)}return{userInfo:n(Ce),setUserInfo:e=>{Ce.value=e}}},Ie=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-comment-count"})=>{var o;const l=new AbortController,r=document.querySelectorAll(n),{userInfo:i}=$e();return r.length&&(({serverURL:e,paths:t,signal:n,token:o})=>{const l={};return o&&(l.Authorization=`Bearer ${o}`),fetch(`${e}/comment?type=count&url=${encodeURIComponent(t.join(","))}`,{signal:n,headers:l}).then((e=>e.json())).then((e=>ce(e,"comment count"))).then((e=>Array.isArray(e)?e:[e]))})({serverURL:e,paths:Array.from(r).map((e=>Q(e.dataset.path||e.getAttribute("id")||t))),signal:l.signal,token:null===(o=i.value)||void 0===o?void 0:o.token}).then((e=>{r.forEach(((t,n)=>{t.innerText=e[n].toString()}))})).catch(se),l.abort.bind(l)},Le=({size:e})=>o("svg",{width:e,height:e,viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid"},o("circle",{cx:50,cy:50,fill:"none",stroke:"currentColor",strokeWidth:"4",r:"40","stroke-dasharray":"85 30"},o("animateTransform",{attributeName:"transform",type:"rotate",repeatCount:"indefinite",dur:"1s",values:"0 50 50;360 50 50",keyTimes:"0;1"})));var Re=l({name:"CommentBox",components:{CloseIcon:({size:e})=>o("svg",{class:"wl-close-icon",viewBox:"0 0 1024 1024",width:e,height:e},[o("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"}),o("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:()=>o("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},o("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:()=>o("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[o("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"}),o("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:()=>o("svg",{width:"16",height:"16",ariaHidden:"true"},o("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:()=>o("svg",{viewBox:"0 0 1024 1024",width:"24",height:"24"},[o("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"}),o("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:Le},props:{rootId:{type:String,default:""},replyId:{type:String,default:""},replyUser:{type:String,default:""}},emits:["submit","cancel-reply"],setup(e,{emit:n}){const o=r("config"),{inputs:l,store:m}=G(),{userInfo:u,setUserInfo:d}=$e(),p=t({}),v=t(null),g=t(null),h=t(null),f=t(null),y=t({tabs:[],map:{}}),w=t(0),b=t(!1),k=t(!1),C=t(""),$=t(0),I=t(0),L=t(!1),R=t(""),S=t(!1),j=i((()=>o.value.locale)),x=i((()=>{var e;return Boolean(null===(e=u.value)||void 0===e?void 0:e.token)})),E=i((()=>!1!==o.value.imageUploader)),z=e=>{const t=v.value,n=t.selectionStart,o=t.selectionEnd||0,r=t.scrollTop;l.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},A=e=>{const t=`![${o.value.locale.uploading} ${e.name}]()`;return z(t),Promise.resolve().then((()=>o.value.imageUploader(e))).then((n=>{l.editor=l.editor.replace(t,`\r\n`)}))},M=()=>{var t,r,i,a,s;const{serverURL:c,lang:d,login:g,wordLimit:h,requiredMeta:f}=o.value,w={comment:R.value,nick:l.nick,mail:l.mail,link:l.link,ua:navigator.userAgent,url:o.value.path};if(null===(t=u.value)||void 0===t?void 0:t.token)w.nick=u.value.display_name,w.mail=u.value.email,w.link=u.value.url;else{if("force"===g)return;if((f.indexOf("nick")>-1||w.nick)&&!w.nick)return null===(r=p.value.nick)||void 0===r||r.focus(),alert(j.value.nickError);if(f.indexOf("mail")>-1&&!w.mail)return null===(i=p.value.mail)||void 0===i||i.focus(),alert(j.value.mailError);if(!w.comment)return void(null===(a=v.value)||void 0===a||a.focus());w.nick||(w.nick=j.value.anonymous)}if(!L.value)return alert(j.value.wordHint.replace("$0",h[0].toString()).replace("$1",h[1].toString()).replace("$2",$.value.toString()));w.comment=he(w.comment,y.value.map),e.replyId&&e.rootId&&(w.pid=e.replyId,w.rid=e.rootId,w.at=e.replyUser),S.value=!0,(({serverURL:e,lang:t,token:n,comment:o})=>{const l={"Content-Type":"application/json"};return n&&(l.Authorization=`Bearer ${n}`),fetch(`${e}/comment?lang=${t}`,{method:"POST",headers:l,body:JSON.stringify(o)}).then((e=>e.json()))})({serverURL:c,lang:d,token:null===(s=u.value)||void 0===s?void 0:s.token,comment:w}).then((t=>{if(S.value=!1,m.update({nick:w.nick,link:w.link,mail:w.mail}),t.errmsg)return alert(t.errmsg);n("submit",t.data),l.editor="",C.value="",e.replyId&&n("cancel-reply")})).catch((e=>{S.value=!1,alert(e.message)}))},N=e=>{h.value.contains(e.target)||f.value.contains(e.target)||(b.value=!1)};return a((()=>l.editor),(e=>{const{highlighter:t,texRenderer:n}=o.value;R.value=e,C.value=fe(e,{emojiMap:y.value.map,highlighter:t,texRenderer:n}),$.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),v.value&&(e?U(v.value):U.destroy(v.value))}),{immediate:!0}),a((()=>o.value.emoji),(e=>e.then((e=>{y.value=e}))),{immediate:!0}),a([o,$],(([e,t])=>{const{wordLimit:n}=e;n?t<n[0]&&0!==n[0]?(I.value=n[0],L.value=!1):t>n[1]?(I.value=n[1],L.value=!1):(I.value=n[1],L.value=!0):(I.value=0,L.value=!0)}),{immediate:!0}),s((()=>{document.body.addEventListener("click",N)})),c((()=>{document.body.removeEventListener("click",N)})),{config:o,locale:j,insert:z,onChange:()=>{const e=g.value;e.files&&E.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=ae(e.dataTransfer.items);t&&E.value&&(A(t),e.preventDefault())}},onKeyDown:e=>{const t=e.key;(e.ctrlKey||e.metaKey)&&"Enter"===t&&M()},onPaste:e=>{if(e.clipboardData){const t=ae(e.clipboardData.items);t&&E.value&&A(t)}},onLogin:e=>{e.preventDefault();const{lang:t,serverURL:n}=o.value,l=(window.innerWidth-450)/2,r=(window.innerHeight-450)/2,i=window.open(`${n}/ui/login?lng=${encodeURIComponent(t)}`,"_blank",`width=450,height=450,left=${l},top=${r},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==i||i.postMessage({type:"TOKEN",data:null},"*");const a=({data:e})=>{e&&"userInfo"===e.type&&e.data.token&&(null==i||i.close(),d(e.data),(e.data.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(e.data)),window.removeEventListener("message",a))};window.addEventListener("message",a)},onLogout:()=>{d({}),localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null")},onProfile:e=>{e.preventDefault();const{lang:t,serverURL:n}=o.value,l=(window.innerWidth-800)/2,r=(window.innerHeight-800)/2,i=window.open(`${n}/ui/profile?lng=${encodeURIComponent(t)}`,"_blank",`width=800,height=800,left=${l},top=${r},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);null==i||i.postMessage({type:"TOKEN",data:u.value.token},"*");const a=({data:e})=>{e&&"profile"===e.type&&(d(Object.assign({},u.value,e)),[localStorage,sessionStorage].filter((e=>e.getItem("WALINE_USER"))).forEach((e=>e.setItem("WALINE_USER",JSON.stringify(u)))),window.removeEventListener("message",a))};window.addEventListener("message",a)},submitComment:M,isLogin:x,userInfo:u,isSubmitting:S,wordNumber:$,wordLimit:I,isWordNumberLegal:L,inputs:l,emoji:y,emojiTabIndex:w,showEmoji:b,canUploadImage:E,previewText:C,showPreview:k,inputRefs:p,editorRef:v,emojiButtonRef:h,emojiPopupRef:f,imageUploadRef:g}}});const Se={class:"wl-comment"},je={key:0,class:"wl-login-info"},xe={class:"wl-avatar"},Ue=["title"],Ee=["src"],ze=["textContent"],Ae={class:"wl-panel"},Me=["for","textContent"],Ne=["id","name","type","onUpdate:modelValue"],Pe=["placeholder"],Te={class:"wl-preview"},Oe=p("hr",null,null,-1),Be=["innerHTML"],_e={class:"wl-footer"},He={class:"wl-actions"},We={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noreferrer"},qe=["title"],Ve=["title"],De=["title"],Je={class:"wl-info"},Fe={class:"wl-text-number"},Ke={key:0},Ye=I(" / "),Ge=["textContent"],Qe=["textContent"],Xe=["disabled"],Ze={key:0,class:"wl-tab-wrapper"},et=["title","onClick"],tt=["src","alt"],nt={key:0,class:"wl-tabs"},ot=["onClick"],lt=["src","alt","title"],rt=["title"];Re.render=function(e,t,n,o,l,r){const i=m("CloseIcon"),a=m("MarkdownIcon"),s=m("EmojiIcon"),c=m("ImageIcon"),R=m("PreviewIcon"),S=m("LoadingIcon");return u(),d("div",Se,["disable"!==e.config.login&&e.isLogin?(u(),d("div",je,[p("div",xe,[p("button",{class:"wl-logout-btn",title:e.locale.logout,onClick:t[0]||(t[0]=(...t)=>e.onLogout&&e.onLogout(...t))},[v(i,{size:14})],8,Ue),p("img",{src:e.userInfo.avatar,alt:"avatar"},null,8,Ee)]),p("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",onClick:t[1]||(t[1]=(...t)=>e.onProfile&&e.onProfile(...t)),textContent:g(e.userInfo.display_name)},null,8,ze)])):h("v-if",!0),p("div",Ae,["force"!==e.config.login&&e.config.meta.length&&!e.isLogin?(u(),d("div",{key:0,class:f(["wl-header",`item${e.config.meta.length}`])},[(u(!0),d(y,null,w(e.config.meta,(t=>(u(),d("div",{class:"wl-header-item",key:t},[p("label",{for:t,textContent:g(e.locale[t]+(e.config.requiredMeta.includes(t)||!e.config.requiredMeta.length?"":`(${e.locale.optional})`))},null,8,Me),b(p("input",{ref_for:!0,ref:n=>{n&&(e.inputRefs[t]=n)},id:`wl-${t}`,class:f(["wl-input",`wl-${t}`]),name:t,type:"mail"===t?"email":"text","onUpdate:modelValue":n=>e.inputs[t]=n},null,10,Ne),[[k,e.inputs[t]]])])))),128))],2)):h("v-if",!0),b(p("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,Pe),[[C,e.inputs.editor]]),b(p("div",Te,[Oe,p("h4",null,g(e.locale.preview)+":",1),p("div",{class:"wl-content",innerHTML:e.previewText},null,8,Be)],512),[[$,e.showPreview]]),p("div",_e,[p("div",He,[p("a",We,[v(a)]),p("button",{ref:"emojiButtonRef",class:f(["wl-action",{actived:e.showEmoji}]),title:e.locale.emoji,onClick:t[6]||(t[6]=t=>e.showEmoji=!e.showEmoji)},[v(s)],10,qe),p("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?(u(),d("label",{key:0,for:"wl-image-upload",class:"wl-action",title:e.locale.uploadImage},[v(c)],8,Ve)):h("v-if",!0),p("button",{class:f(["wl-action",{actived:e.showPreview}]),title:e.locale.preview,onClick:t[8]||(t[8]=t=>e.showPreview=!e.showPreview)},[v(R)],10,De)]),p("div",Je,[p("div",Fe,[I(g(e.wordNumber)+" ",1),e.config.wordLimit?(u(),d("span",Ke,[Ye,p("span",{class:f({illegal:!e.isWordNumberLegal}),textContent:g(e.wordLimit)},null,10,Ge)])):h("v-if",!0),I(" "+g(e.locale.word),1)]),"disable"===e.config.login||e.isLogin?h("v-if",!0):(u(),d("button",{key:0,class:"wl-btn",onClick:t[9]||(t[9]=(...t)=>e.onLogin&&e.onLogin(...t)),textContent:g(e.locale.login)},null,8,Qe)),"force"!==e.config.login||e.isLogin?(u(),d("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?(u(),L(S,{key:0,size:16})):(u(),d(y,{key:1},[I(g(e.locale.submit),1)],2112))],8,Xe)):h("v-if",!0)]),p("div",{ref:"emojiPopupRef",class:f(["wl-emoji-popup",{display:e.showEmoji}])},[(u(!0),d(y,null,w(e.emoji.tabs,((t,n)=>(u(),d(y,{key:t.name},[n===e.emojiTabIndex?(u(),d("div",Ze,[(u(!0),d(y,null,w(t.items,(t=>(u(),d("button",{key:t,title:t,onClick:n=>e.insert(`:${t}:`)},[e.showEmoji?(u(),d("img",{key:0,class:"wl-emoji",src:e.emoji.map[t],alt:t,loading:"lazy",referrerPolicy:"no-referrer"},null,8,tt)):h("v-if",!0)],8,et)))),128))])):h("v-if",!0)],64)))),128)),e.emoji.tabs.length>1?(u(),d("div",nt,[(u(!0),d(y,null,w(e.emoji.tabs,((t,n)=>(u(),d("button",{key:t.name,class:f(["wl-tab",{active:e.emojiTabIndex===n}]),onClick:t=>e.emojiTabIndex=n},[p("img",{class:"wl-emoji",src:t.icon,alt:t.name,title:t.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,lt)],10,ot)))),128))])):h("v-if",!0)],2)])]),e.replyId?(u(),d("button",{key:1,class:"wl-close",title:e.locale.cancelReply,onClick:t[11]||(t[11]=t=>e.$emit("cancel-reply"))},[v(i,{size:24})],8,rt)):h("v-if",!0)])},Re.__file="src/components/CommentBox.vue";var it=l({props:{comment:{type:Object,required:!0},rootId:{type:String,required:!0},reply:{type:Object}},components:{CommentBox:Re,ReplyIcon:()=>o("svg",{viewBox:"0 0 1024 1024",width:"18",height:"18"},o("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:()=>o("svg",{class:"verified-icon",viewBox:"0 0 1024 1024",width:"14",height:"14"},o("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=r("config"),n=i((()=>t.value.locale)),o=i((()=>{let{link:t}=e.comment;return t?Z(t)?t:`https://${t}`:""})),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,timeAgo:be}}});const at=["id"],st={class:"wl-user","aria-hidden":"true"},ct=["src"],mt={class:"wl-card"},ut={class:"wl-head"},dt=["href"],pt={key:1,class:"wl-nick"},vt=["textContent"],gt=["textContent"],ht=["textContent"],ft=["title"],yt={class:"wl-meta","aria-hidden":"true"},wt=["textContent"],bt=["textContent"],kt=["innerHTML"],Ct={key:0,class:"wl-reply-wrapper"},$t={key:1,class:"wl-quote"};it.render=function(e,t,n,o,l,r){const i=m("VerifiedIcon"),a=m("ReplyIcon"),s=m("CommentBox"),c=m("CommentCard",!0);return u(),d("div",{class:"wl-item",id:e.comment.objectId},[p("div",st,[e.comment.avatar?(u(),d("img",{key:0,src:e.comment.avatar},null,8,ct)):h("v-if",!0),e.comment.type?(u(),L(i,{key:1})):h("v-if",!0)]),p("div",mt,[p("div",ut,[e.link?(u(),d("a",{key:0,class:"wl-nick",href:e.link,target:"_blank",rel:"nofollow noreferrer"},g(e.comment.nick),9,dt)):(u(),d("span",pt,g(e.comment.nick),1)),"administrator"===e.comment.type?(u(),d("span",{key:2,class:"wl-badge",textContent:g(e.locale.admin)},null,8,vt)):h("v-if",!0),e.comment.sticky?(u(),d("span",{key:3,class:"wl-badge",textContent:g(e.locale.sticky)},null,8,gt)):h("v-if",!0),p("span",{class:"wl-time",textContent:g(e.timeAgo(e.comment.insertedAt,e.locale))},null,8,ht),p("button",{class:f(["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))},[v(a)],10,ft)]),p("div",yt,[e.comment.browser?(u(),d("span",{key:0,textContent:g(e.comment.browser)},null,8,wt)):h("v-if",!0),e.comment.os?(u(),d("span",{key:1,textContent:g(e.comment.os)},null,8,bt)):h("v-if",!0)]),p("div",{class:"wl-content",innerHTML:e.comment.comment},null,8,kt),e.isReplyingCurrent?(u(),d("div",Ct,[v(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"])])):h("v-if",!0),e.comment.children?(u(),d("div",$t,[(u(!0),d(y,null,w(e.comment.children,(n=>(u(),L(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))])):h("v-if",!0)])],8,at)},it.__file="src/components/CommentCard.vue";var It=l({name:"WalineRoot",components:{CommentBox:Re,CommentCard:it,LoadingIcon:Le},props:{serverURL:{type:String,required:!0},path:{type:String,required:!0},meta:{type:Array},requiredMeta:{type:Array},visitor:{type:Boolean},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,!1]},texRenderer:{type:Function}},setup(e){const n=i((()=>(({serverURL:e,path:t=location.pathname,lang:n="zh-CN",locale:o,emoji:l=["https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo"],meta:r=["nick","mail","link"],requiredMeta:i=[],pageSize:a=10,wordLimit:s,imageUploader:c,highlighter:m,texRenderer:u,copyright:d=!0,login:p="enable",...v})=>{return{serverURL:oe(e),path:Q(t),lang:n,locale:{...J[n]||J["zh-CN"],..."object"==typeof o?o:{}},emoji:(g=l,Promise.all(g.map((e=>"string"==typeof e?te(X(e)):Promise.resolve(e)))).then((e=>{const t={tabs:[],map:{}};return e.forEach((e=>{const{name:n,folder:o,icon:l,prefix:r,type:i,items:a}=e;t.tabs.push({name:n,icon:ne(l,o,r,i),items:a.map((e=>{const n=`${r||""}${e}`;return t.map[n]=ne(e,o,r,i),n}))})})),t}))),wordLimit:Array.isArray(s)?s:!!s&&[0,s],meta:M(r),requiredMeta:M(i),pageSize:a,login:p,imageUploader:le(c,P),highlighter:le(m,z),texRenderer:le(u,T),copyright:d,...v};var g})(e))),{userInfo:o}=$e(),l=t("loading"),r=t(0),c=t(1),m=t(0),u=t([]),d=t(null),p=i((()=>{return"string"==typeof(e=n.value.dark)?"auto"===e?`@media(prefers-color-scheme:dark){body${re}}`:`${e}${re}`:!0===e?`:root${re}`:"";var e}));let v,g;const h=e=>{var t;const{serverURL:i,path:a,pageSize:s}=n.value,d=new AbortController;l.value="loading",null==v||v(),(({serverURL:e,path:t,page:n,pageSize:o,signal:l,token:r})=>{const i={};return r&&(i.Authorization=`Bearer ${r}`),fetch(`${e}/comment?path=${encodeURIComponent(t)}&pageSize=${o}&page=${n}`,{signal:l,headers:i}).then((e=>e.json())).then((e=>ce(e,"comment list")))})({serverURL:i,path:a,pageSize:s,page:e,signal:d.signal,token:null===(t=o.value)||void 0===t?void 0:t.token}).then((t=>{l.value="success",r.value=t.count,u.value.push(...t.data),c.value=e,m.value=t.totalPages})).catch((e=>{"AbortError"!==e.name&&(console.error(e.message),l.value="error")})),v=d.abort.bind(d)},f=()=>{r.value=0,u.value=[],h(1)};return R("config",n),a((()=>e.path),f),s((()=>{var e;f();const t=document.createElement("style");t.innerText=p.value,null===(e=document.querySelector("[data-waline]"))||void 0===e||e.appendChild(t),g=S((()=>{t.innerText=p.value}))})),j((()=>g())),{config:n,darkmodeStyle:p,i18n:i((()=>n.value.locale)),status:l,count:r,page:c,totalPages:m,data:u,reply:d,loadMore:()=>h(c.value+1),refresh:f,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.2"}}});const Lt={"data-waline":""},Rt={class:"wl-count"},St=["textContent"],jt={class:"wl-cards"},xt={key:1,class:"wl-operation"},Ut=["textContent"],Et={key:0,class:"wl-loading"},zt=["textContent"],At={class:"wl-operation"},Mt=["textContent"],Nt={key:3,class:"wl-power"},Pt=I(" Powered by "),Tt=p("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noreferrer"}," Waline ",-1);It.render=function(e,t,n,o,l,r){const i=m("CommentBox"),a=m("CommentCard"),s=m("LoadingIcon");return u(),d("div",Lt,[e.reply?h("v-if",!0):(u(),L(i,{key:0,onSubmit:e.onSubmit},null,8,["onSubmit"])),p("div",Rt,[e.count?(u(),d("span",{key:0,class:"wl-num",textContent:g(e.count)},null,8,St)):h("v-if",!0),I(" "+g(e.i18n.comment),1)]),p("div",jt,[(u(!0),d(y,null,w(e.data,(t=>(u(),L(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?(u(),d("div",xt,[p("button",{type:"button",class:"wl-btn",onClick:t[0]||(t[0]=(...t)=>e.refresh&&e.refresh(...t)),textContent:g(e.i18n.refresh)},null,8,Ut)])):(u(),d(y,{key:2},["loading"===e.status?(u(),d("div",Et,[v(s,{size:30})])):e.data.length?e.page<e.totalPages?(u(),d(y,{key:2},[h(" Load more button "),p("div",At,[p("button",{type:"button",class:"wl-btn",onClick:t[1]||(t[1]=(...t)=>e.loadMore&&e.loadMore(...t)),textContent:g(e.i18n.more)},null,8,Mt)])],2112)):h("v-if",!0):(u(),d("div",{key:1,class:"wl-empty",textContent:g(e.i18n.sofa)},null,8,zt))],2112)),h(" Copyright Information "),e.config.copyright?(u(),d("div",Nt,[Pt,Tt,I(" v"+g(e.version),1)])):h("v-if",!0)])},It.__file="src/components/Waline.vue";const Ot=(e,t)=>{t.forEach(((t,n)=>{t.innerText=e[n].toString()}))},Bt=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-pageview-count",update:o=!0})=>{const l=new AbortController,r=Array.from(document.querySelectorAll(n)),i=e=>{const n=ye(e);return null!==n&&t!==n},a=n=>me({serverURL:e,paths:n.map((e=>ye(e)||t)),signal:l.signal}).then((e=>Ot(e,n))).catch(se);if(o){const n=r.filter((e=>!i(e))),o=r.filter(i);ue({serverURL:e,path:t}).then((e=>Ot(new Array(n.length).fill(e),n))),o.length&&a(o)}else a(r);return l.abort.bind(l)},_t=({el:t="#waline",path:n=window.location.pathname,comment:l=!1,pageview:r=!1,...i})=>{const a=t?de(t):null;if(t&&!a)throw new Error("Option 'el' do not match any domElement!");if(!i.serverURL)throw new Error("Option 'serverURL' is missing!");const s=e({...i}),c=e({comment:l,pageview:r,path:n}),m=()=>{c.comment&&Ie({serverURL:s.serverURL,path:c.path,selector:"string"==typeof c.comment?c.comment:void 0})},u=()=>{c.pageview&&Bt({serverURL:s.serverURL,path:c.path,selector:"string"==typeof c.pageview?c.pageview:void 0})},d=a?x((()=>o(It,{path:c.path,...s}))):null;d&&d.mount(a),m(),u();const p=S(m),v=S(u);return{el:a,update:({comment:e,pageview:t,path:n=window.location.pathname,...o})=>{Object.entries(o).map((([e,t])=>{s[e]=t})),c.path=n,void 0!==e&&(c.comment=e),void 0!==t&&(c.pageview=t)},destroy:()=>{null==d||d.unmount(),p(),v()}}},Ht="2.0.2",Wt=({el:e,serverURL:t,count:n})=>{var o;const l=de(e),r=new AbortController;return(({serverURL:e,count:t,signal:n,token:o})=>{const l={};return o&&(l.Authorization=`Bearer ${o}`),fetch(`${e}/comment?type=recent&count=${t}`,{signal:n,headers:l}).then((e=>e.json())).then((e=>ce(e,"recent comment")))})({serverURL:t,count:n,signal:r.signal,token:null===(o=ke())||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:()=>{r.abort(),l.innerHTML=""}}):{comments:e,destroy:()=>r.abort()}))};export{Wt as RecentComments,Ie as commentCount,N as defaultLang,T as defaultTexRenderer,P as defaultUploadImage,M as getMeta,_t as init,J as locales,Bt as pageviewCount,Ht as version};
|
|
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=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}))},Ue=(e,t="",n="",o="")=>`${t?`${t}/`:""}${n}${e}${o?`.${o}`:""}`,ze=e=>{const t=xe(e);return Ee(t)?t:`https://${t}`},Oe=(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}",Pe=(e,t)=>{let n=e.toString();for(;n.length<t;)n="0"+n;return n},Ne=e=>{"AbortError"!==e.name&&console.error(e.message)},Te=(e,t="")=>{if("object"==typeof e&&e.errno)throw new TypeError(`Fetch ${t} failed with ${e.errno}: ${e.errmsg}`);return e},_e=({serverURL:e,paths:t,signal:n})=>fetch(`${e}/article?path=${encodeURIComponent(t.join(","))}`,{signal:n}).then((e=>e.json())).then((e=>Te(e,"visit count"))).then((e=>Array.isArray(e)?e:[e])),Be=({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=>Te(e,"visit count"))),Fe=e=>e instanceof HTMLElement?e:"string"==typeof e?document.querySelector(e):null,De=e=>e.type.includes("image"),He=e=>{const t=Array.from(e).find(De);return t?t.getAsFile():null},qe=/\$.*?\$/,We=/^\$(.*?)\$/,Ve=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,Je=(e="",t={})=>e.replace(/:(.+?):/g,((e,n)=>t[n]?`<img class="wl-emoji" src="${t[n]}" alt="${n}">`:e)),Ke=(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=Ve.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(qe);return-1!==t?t:e.length},tokenizer(t){const n=We.exec(t);if(null!==n)return{type:"html",raw:n[0],text:e(!1,n[1])}}}])(o);M.use({extensions:e})}return M.parse(Je(e,t))},Ye=e=>e.dataset.path||e.getAttribute("id"),Ge=(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=Pe(e.getDate(),2),n=Pe(e.getMonth()+1,2);return`${Pe(e.getFullYear(),2)}-${n}-${t}`})(o)}))},Qe=()=>ye("USER_KEY",{}),Xe=({serverURL:e,path:t=window.location.pathname,selector:n=".waline-comment-count"})=>{var o;const r=new AbortController,l=document.querySelectorAll(n),i=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=>Te(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(Ne),r.abort.bind(r)},Ze=({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 et=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:Ze},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=Qe(),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`)}))},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=Je(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((()=>l.value.editor),(e=>{const{highlighter:t,texRenderer:n}=r.value;j.value=e,b.value=Ke(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),c.value&&(e?O(c.value):O.destroy(c.value))}),{immediate:!0}),o((()=>r.value.emoji),(e=>e.then((e=>{f.value=e}))),{immediate:!0}),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)})),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=He(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=He(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 tt={class:"wl-comment"},nt={key:0,class:"wl-login-info"},ot={class:"wl-avatar"},rt=["title"],lt=["src"],it=["textContent"],at={class:"wl-panel"},st=["for","textContent"],ct=["id","name","type","onUpdate:modelValue"],ut=["placeholder"],mt={class:"wl-preview"},dt=f("hr",null,null,-1),pt=["innerHTML"],vt={class:"wl-footer"},gt={class:"wl-actions"},ft={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noreferrer"},ht=["title"],wt=["title"],yt=["title"],bt={class:"wl-info"},kt={class:"wl-text-number"},Ct={key:0},$t=S(" / "),jt=["textContent"],It=["textContent"],Lt=["disabled"],St={key:0,class:"wl-tab-wrapper"},Rt=["title","onClick"],xt=["src","alt"],Et={key:0,class:"wl-tabs"},At=["onClick"],Ut=["src","alt","title"],zt=["title"];et.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",tt,["disable"!==e.config.login&&e.isLogin?(v(),g("div",nt,[f("div",ot,[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,rt),f("img",{src:e.userInfo.avatar,alt:"avatar"},null,8,lt)]),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",at,["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,st),$(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,ct),[[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,ut),[[I,e.inputs.editor]]),$(f("div",mt,[dt,f("h4",null,w(e.locale.preview)+":",1),f("div",{class:"wl-content",innerHTML:e.previewText},null,8,pt)],512),[[L,e.showPreview]]),f("div",vt,[f("div",gt,[f("a",ft,[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,ht),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,wt)):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,yt)]),f("div",bt,[f("div",kt,[S(w(e.wordNumber)+" ",1),e.config.wordLimit?(v(),g("span",Ct,[$t,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,It)),"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,Lt)):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",St,[(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,xt)):y("v-if",!0)],8,Rt)))),128))])):y("v-if",!0)],64)))),128)),e.emoji.tabs.length>1?(v(),g("div",Et,[(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,Ut)],10,At)))),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,zt)):y("v-if",!0)])},et.__file="src/components/CommentBox.vue";var Ot=c({props:{comment:{type:Object,required:!0},rootId:{type:String,required:!0},reply:{type:Object}},components:{CommentBox:et,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=Ge(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 Mt=["id"],Pt={class:"wl-user","aria-hidden":"true"},Nt=["src"],Tt={class:"wl-card"},_t={class:"wl-head"},Bt=["href"],Ft={key:1,class:"wl-nick"},Dt=["textContent"],Ht=["textContent"],qt=["textContent"],Wt=["title"],Vt={class:"wl-meta","aria-hidden":"true"},Jt=["textContent"],Kt=["textContent"],Yt=["innerHTML"],Gt={key:0,class:"wl-reply-wrapper"},Qt={key:1,class:"wl-quote"};Ot.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",Pt,[e.comment.avatar?(v(),g("img",{key:0,src:e.comment.avatar},null,8,Nt)):y("v-if",!0),e.comment.type?(v(),R(i,{key:1})):y("v-if",!0)]),f("div",Tt,[f("div",_t,[e.link?(v(),g("a",{key:0,class:"wl-nick",href:e.link,target:"_blank",rel:"nofollow noreferrer"},w(e.comment.nick),9,Bt)):(v(),g("span",Ft,w(e.comment.nick),1)),"administrator"===e.comment.type?(v(),g("span",{key:2,class:"wl-badge",textContent:w(e.locale.admin)},null,8,Dt)):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,qt),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,Wt)]),f("div",Vt,[e.comment.browser?(v(),g("span",{key:0,textContent:w(e.comment.browser)},null,8,Jt)):y("v-if",!0),e.comment.os?(v(),g("span",{key:1,textContent:w(e.comment.os)},null,8,Kt)):y("v-if",!0)]),f("div",{class:"wl-content",innerHTML:e.comment.comment},null,8,Yt),e.isReplyingCurrent?(v(),g("div",Gt,[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,Mt)},Ot.__file="src/components/CommentCard.vue";var Xt=c({name:"WalineRoot",components:{CommentBox:et,CommentCard:Ot,LoadingIcon:Ze},props:{serverURL:{type:String,required:!0},path:{type:String,required:!0},meta:{type:Array},requiredMeta:{type:Array},visitor:{type:Boolean},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=[],pageSize:a=10,wordLimit:s,imageUploader:c,highlighter:u,texRenderer:m,copyright:d=!0,login:p="enable",...v})=>{return{serverURL:ze(e),path:Re(t),lang:n,locale:{...G[n]||G["zh-CN"],..."object"==typeof o?o:{}},emoji:(g=r,Promise.all(g.map((e=>"string"==typeof e?Ae(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:Ue(r,o,l,i),items:a.map((e=>{const n=`${l||""}${e}`;return t.map[n]=Ue(e,o,l,i),n}))})})),t}))),wordLimit:Array.isArray(s)?s:!!s&&[0,s],meta:T(l),requiredMeta:T(i),pageSize:a,login:p,imageUploader:Oe(c,B),highlighter:Oe(u,P),texRenderer:Oe(m,F),copyright:d,...v};var g})(t))),r=Qe(),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${Me}}`:`${e}${Me}`:!0===e?`:root${Me}`:"";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=>Te(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.3"}}});const Zt={"data-waline":""},en={class:"wl-count"},tn=["textContent"],nn={class:"wl-cards"},on={key:1,class:"wl-operation"},rn=["textContent"],ln={key:0,class:"wl-loading"},an=["textContent"],sn={class:"wl-operation"},cn=["textContent"],un={key:3,class:"wl-power"},mn=S(" Powered by "),dn=f("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noreferrer"}," Waline ",-1);Xt.render=function(e,t,n,o,r,l){const i=p("CommentBox"),a=p("CommentCard"),s=p("LoadingIcon");return v(),g("div",Zt,[e.reply?y("v-if",!0):(v(),R(i,{key:0,onSubmit:e.onSubmit},null,8,["onSubmit"])),f("div",en,[e.count?(v(),g("span",{key:0,class:"wl-num",textContent:w(e.count)},null,8,tn)):y("v-if",!0),S(" "+w(e.i18n.comment),1)]),f("div",nn,[(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",on,[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,rn)])):(v(),g(k,{key:2},["loading"===e.status?(v(),g("div",ln,[h(s,{size:30})])):e.data.length?e.page<e.totalPages?(v(),g(k,{key:2},[y(" Load more button "),f("div",sn,[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,cn)])],2112)):y("v-if",!0):(v(),g("div",{key:1,class:"wl-empty",textContent:w(e.i18n.sofa)},null,8,an))],2112)),y(" Copyright Information "),e.config.copyright?(v(),g("div",un,[mn,dn,S(" v"+w(e.version),1)])):y("v-if",!0)])},Xt.__file="src/components/Waline.vue";const pn=(e,t)=>{t.forEach(((t,n)=>{t.innerText=e[n].toString()}))},vn=({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=Ye(e);return null!==n&&t!==n},a=n=>_e({serverURL:e,paths:n.map((e=>Ye(e)||t)),signal:r.signal}).then((e=>pn(e,n))).catch(Ne);if(o){const n=l.filter((e=>!i(e))),o=l.filter(i);Be({serverURL:e,path:t}).then((e=>pn(new Array(n.length).fill(e),n))),o.length&&a(o)}else a(l);return r.abort.bind(r)},gn=({el:e="#waline",path:t=window.location.pathname,comment:n=!1,pageview:o=!1,...r})=>{const l=e?Fe(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&&Xe({serverURL:i.serverURL,path:a.path,selector:"string"==typeof a.comment?a.comment:void 0})},u=()=>{a.pageview&&vn({serverURL:i.serverURL,path:a.path,selector:"string"==typeof a.pageview?a.pageview:void 0})},m=l?z((()=>s(Xt,{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()}}},fn="2.0.3",hn=({el:e,serverURL:t,count:n})=>{var o;const r=Qe(),l=Fe(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=>Te(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{hn as RecentComments,Xe as commentCount,_ as defaultLang,F as defaultTexRenderer,B as defaultUploadImage,T as getMeta,gn as init,G as locales,vn as pageviewCount,fn as version};
|
|
2
2
|
//# sourceMappingURL=shim.esm.js.map
|