@waline/client 3.3.2 → 3.4.0

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/comment.js CHANGED
@@ -1,2 +1,2 @@
1
- const h=t=>`${t.replace(/\/?$/,"/")}api/`,i=(t,e="")=>{if(typeof t=="object"&&t.errno)throw new TypeError(`${e} failed with ${t.errno}: ${t.errmsg}`);return t},g=({serverURL:t,lang:e,paths:r,signal:o})=>fetch(`${h(t)}comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${e}`,{signal:o}).then(n=>n.json()).then(n=>i(n,"Get comment count").data),p=t=>{try{t=decodeURI(t)}catch{}return t},m=(t="")=>t.replace(/\/$/u,""),u=t=>/^(https?:)?\/\//.test(t),d=t=>{const e=m(t);return u(e)?e:`https://${e}`},$=t=>{t.name!=="AbortError"&&console.error(t.message)},f=t=>{const{path:e}=t.dataset;return e!=null&&e.length?e:null},v=({serverURL:t,path:e=window.location.pathname,selector:r=".waline-comment-count",lang:o=navigator.language})=>{const n=new AbortController,a=document.querySelectorAll(r);return a.length&&g({serverURL:d(t),paths:Array.from(a).map(c=>p(f(c)??e)),lang:o,signal:n.signal}).then(c=>{a.forEach((s,l)=>{s.innerText=c[l].toString()})}).catch($),n.abort.bind(n)},w="3.3.2";export{v as commentCount,w as version};
1
+ const h=t=>`${t.replace(/\/?$/,"/")}api/`,i=(t,e="")=>{if(typeof t=="object"&&t.errno)throw new TypeError(`${e} failed with ${t.errno}: ${t.errmsg}`);return t},g=({serverURL:t,lang:e,paths:r,signal:o})=>fetch(`${h(t)}comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${e}`,{signal:o}).then(n=>n.json()).then(n=>i(n,"Get comment count").data),p=t=>{try{t=decodeURI(t)}catch{}return t},m=(t="")=>t.replace(/\/$/u,""),u=t=>/^(https?:)?\/\//.test(t),d=t=>{const e=m(t);return u(e)?e:`https://${e}`},$=t=>{t.name!=="AbortError"&&console.error(t.message)},f=t=>{const{path:e}=t.dataset;return e!=null&&e.length?e:null},v=({serverURL:t,path:e=window.location.pathname,selector:r=".waline-comment-count",lang:o=navigator.language})=>{const n=new AbortController,a=document.querySelectorAll(r);return a.length&&g({serverURL:d(t),paths:Array.from(a).map(c=>p(f(c)??e)),lang:o,signal:n.signal}).then(c=>{a.forEach((s,l)=>{s.innerText=c[l].toString()})}).catch($),n.abort.bind(n)},w="3.4.0";export{v as commentCount,w as version};
2
2
  //# sourceMappingURL=comment.js.map
package/dist/component.js CHANGED
@@ -8,5 +8,5 @@ import{h as M,defineComponent as ce,inject as we,ref as C,computed as W,onMounte
8
8
  Số từ hiện tại: $2`,"Vô danh","Người lùn","Người tí hon","Thần rừng","Pháp sư","Tiên tộc","Maiar","Ảnh GIF","Tìm kiếm ảnh GIF","thông tin cá nhân","Đã được phê duyệt","Đang chờ đợi","Thư rác","Không dính","lâu đời nhất","muộn nhất","nóng nhất","What do you think?"]),it=Q(["昵称","昵称不能少于3个字符","邮箱","请填写正确的邮件地址","网址","可选","欢迎评论","来发评论吧~","提交","喜欢","取消喜欢","回复","取消回复","评论","刷新","加载更多...","预览","表情","上传图片","秒前","分钟前","小时前","天前","刚刚","正在上传","登录","退出","博主","置顶","字",`评论字数应在 $0 到 $1 字之间!
9
9
  当前字数:$2`,"匿名","潜水","冒泡","吐槽","活跃","话痨","传说","表情包","搜索表情包","个人资料","通过","待审核","垃圾","取消置顶","按倒序","按正序","按热度","你认为这篇文章怎么样?"]),xl=Q(["暱稱","暱稱不能少於3個字元","郵箱","請填寫正確的郵件地址","網址","可選","歡迎留言","來發留言吧~","送出","喜歡","取消喜歡","回覆","取消回覆","留言","重整","載入更多...","預覽","表情","上傳圖片","秒前","分鐘前","小時前","天前","剛剛","正在上傳","登入","登出","管理者","置頂","字",`留言字數應在 $0 到 $1 字之間!
10
10
  目前字數:$2`,"匿名","潛水","冒泡","吐槽","活躍","多話","傳說","表情包","搜尋表情包","個人資料","通過","待審核","垃圾","取消置頂","最早","最新","熱門","你認為這篇文章怎麼樣?"]);const ot="en-US",Ce={zh:it,"zh-cn":it,"zh-tw":xl,en:Qe,"en-us":Qe,fr:tt,"fr-fr":tt,jp:lt,"jp-jp":lt,"pt-br":Ll,ru:at,"ru-ru":at,vi:nt,"vi-vn":nt,de:El,es:et,"es-mx":et},Al=e=>Ce[e.toLowerCase()]||Ce[ot.toLowerCase()],rt=e=>Object.keys(Ce).includes(e.toLowerCase())?e:ot,Ml=e=>{const a=Ke(e);return Ze(a)?a:`https://${a}`},Sl=e=>Array.isArray(e)?e:e?[0,e]:!1,$e=(e,a)=>typeof e=="function"?e:e===!1?!1:a,Rl=({serverURL:e,path:a=location.pathname,lang:t=typeof navigator>"u"?"en-US":navigator.language,locale:l,emoji:n=Je,meta:v=["nick","mail","link"],requiredMeta:E=[],dark:y=!1,pageSize:z=10,wordLimit:b,imageUploader:I,highlighter:U,texRenderer:d,copyright:S=!0,login:R="enable",search:k,reaction:g,recaptchaV3Key:o="",turnstileKey:p="",commentSorting:F="latest",...q})=>({serverURL:Ml(e),path:vl(a),lang:rt(t),locale:{...Al(rt(t)),...typeof l=="object"?l:{}},wordLimit:Sl(b),meta:Xe(v),requiredMeta:Xe(E),imageUploader:$e(I,gl),highlighter:$e(U,$l),texRenderer:$e(d,hl),dark:y,emoji:typeof n=="boolean"?n?Je:[]:n,pageSize:z,login:R,copyright:S,search:k===!1?!1:typeof k=="object"?k:fl(t),recaptchaV3Key:o,turnstileKey:p,reaction:Array.isArray(g)?g:g===!0?pl:[],commentSorting:F,...q}),Ie=e=>typeof e=="string",Ee="{--waline-white:#000;--waline-light-grey:#666;--waline-dark-grey:#999;--waline-color:#888;--waline-bg-color:#1e1e1e;--waline-bg-color-light:#272727;--waline-bg-color-hover: #444;--waline-border-color:#333;--waline-disable-bg-color:#444;--waline-disable-color:#272727;--waline-bq-color:#272727;--waline-info-bg-color:#272727;--waline-info-color:#666}",jl=e=>Ie(e)?e==="auto"?`@media(prefers-color-scheme:dark){body${Ee}}`:`${e}${Ee}`:e===!0?`:root${Ee}`:"",Le=(e,a)=>{let t=e.toString();for(;t.length<a;)t="0"+t;return t},zl=e=>{const a=Le(e.getDate(),2),t=Le(e.getMonth()+1,2);return`${Le(e.getFullYear(),2)}-${t}-${a}`},_l=(e,a,t)=>{if(!e)return"";const l=Ie(e)?new Date(e.includes(" ")?e.replace(/-/g,"/"):e):e,n=a.getTime()-l.getTime(),v=Math.floor(n/(24*3600*1e3));if(v===0){const E=n%864e5,y=Math.floor(E/(3600*1e3));if(y===0){const z=E%36e5,b=Math.floor(z/(60*1e3));if(b===0){const I=z%6e4;return`${Math.round(I/1e3)} ${t.seconds}`}return`${b} ${t.minutes}`}return`${y} ${t.hours}`}return v<0?t.now:v<8?`${v} ${t.days}`:zl(l)},Vl=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Ul=e=>Vl.test(e),Hl=e=>!!/@[0-9]+\.[0-9]+\.[0-9]+/.test(e),Tl=e=>{const a=oe("WALINE_EMOJI",{}),t=Hl(e);if(t){const l=a.value[e];if(l)return Promise.resolve(l)}return fetch(`${e}/info.json`).then(l=>l.json()).then(l=>{const n={folder:e,...l};return t&&(a.value[e]=n),n})},st=(e,a="",t="",l="")=>`${a?`${a}/`:""}${t}${e}${l?`.${l}`:""}`,Fl=e=>Promise.all(e.map(a=>Ie(a)?Tl(Ke(a)):Promise.resolve(a))).then(a=>{const t={tabs:[],map:{}};return a.forEach(l=>{const{name:n,folder:v,icon:E,prefix:y="",type:z,items:b}=l;t.tabs.push({name:n,icon:st(E,v,y,z),items:b.map(I=>{const U=`${y}${I}`;return t.map[U]=st(I,v,y,z),U})})}),t}),Nl=e=>e.type.includes("image"),ct=e=>{const a=Array.from(e).find(Nl);return a?a.getAsFile():null},Wl=/\$.*?\$/,Bl=/^\$(.*?)\$/,Pl=/^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/,Dl=e=>[{name:"blockMath",level:"block",tokenizer(a){const t=Pl.exec(a);if(t!==null)return{type:"html",raw:t[0],text:e(!0,t[1])}}},{name:"inlineMath",level:"inline",start(a){const t=a.search(Wl);return t!==-1?t:a.length},tokenizer(a){const t=Bl.exec(a);if(t!==null)return{type:"html",raw:t[0],text:e(!1,t[1])}}}],ut=(e="",a={})=>e.replace(/:(.+?):/g,(t,l)=>a[l]?`<img class="wl-emoji" src="${a[l]}" alt="${l}">`:t),Ol=(e,{emojiMap:a,highlighter:t,texRenderer:l})=>{const n=new zt;if(n.setOptions({breaks:!0}),t&&n.use(_t({highlight:t})),l){const v=Dl(l);n.use({extensions:v})}return n.parse(ut(e,a))},ql=e=>e.match(/[\w\d\s,.\u00C0-\u024F\u0400-\u04FF]+/giu),Gl=e=>e.match(/[\u4E00-\u9FD5]/gu),Kl=e=>{var a,t;return(((a=ql(e))==null?void 0:a.reduce((l,n)=>l+(["",",","."].includes(n.trim())?0:n.trim().split(/\s+/u).length),0))??0)+(((t=Gl(e))==null?void 0:t.length)??0)},Zl=async()=>{if(!navigator)return"";const{userAgentData:e}=navigator;let a=navigator.userAgent;if(!e||e.platform!=="Windows")return a;const{platformVersion:t}=await e.getHighEntropyValues(["platformVersion"]);return t&&parseInt(t.split(".")[0])>=13&&(a=a.replace("Windows NT 10.0","Windows NT 11.0")),a},Xl={key:0,class:"wl-login-info"},Jl={class:"wl-avatar"},Yl=["title"],Ql=["title"],ea=["src"],ta=["title","textContent"],la={class:"wl-panel"},aa=["for","textContent"],na=["id","onUpdate:modelValue","name","type"],ia=["placeholder"],oa={class:"wl-preview"},ra=["innerHTML"],sa={class:"wl-footer"},ca={class:"wl-actions"},ua={href:"https://guides.github.com/features/mastering-markdown/",title:"Markdown Guide","aria-label":"Markdown is supported",class:"wl-action",target:"_blank",rel:"noopener noreferrer"},ma=["title"],va=["title"],da=["title","aria-label"],pa=["title"],ga={class:"wl-info"},ha={class:"wl-text-number"},fa={key:0},ya=["textContent"],wa=["textContent"],ka=["disabled"],ba=["placeholder"],Ca={key:1,class:"wl-loading"},$a={key:0,class:"wl-tab-wrapper"},Ia=["title","onClick"],Ea=["src","alt"],La={key:0,class:"wl-tabs"},xa=["onClick"],Aa=["src","alt","title"],Ma=["title"];var mt=ce({__name:"CommentBox",props:{edit:{default:null},rootId:{default:""},replyId:{default:""},replyUser:{default:""}},emits:["log","cancelEdit","cancelReply","submit"],setup(e,{emit:a}){const t=e,l=a,n=we("config"),v=Gt(),E=qt(),y=ke(),z=C({}),b=C(null),I=C(null),U=C(null),d=C(null),S=C(null),R=C(null),k=C(null),g=C({tabs:[],map:{}}),o=C(0),p=C(!1),F=C(!1),q=C(!1),L=C(""),_=C(0),H=yt({loading:!0,list:[]}),te=C(0),le=C(!1),me=C(""),Y=C(!1),re=C(!1),u=W(()=>n.value.locale),x=W(()=>{var c;return!!((c=y.value)!=null&&c.token)}),j=W(()=>n.value.imageUploader!==!1),G=c=>{const i=b.value,h=i.selectionStart,V=i.selectionEnd||0,f=i.scrollTop;v.value=i.value.substring(0,h)+c+i.value.substring(V,i.value.length),i.focus(),i.selectionStart=h+c.length,i.selectionEnd=h+c.length,i.scrollTop=f},K=c=>{if(Y.value)return;const i=c.key;(c.ctrlKey||c.metaKey)&&i==="Enter"&&ve()},Z=c=>{const i=`![${n.value.locale.uploading} ${c.name}]()`;return G(i),Y.value=!0,Promise.resolve().then(()=>n.value.imageUploader(c)).then(h=>{v.value=v.value.replace(i,`\r
11
- ![${c.name}](${h})`)}).catch(h=>{alert(h.message),v.value=v.value.replace(i,"")}).then(()=>{Y.value=!1})},X=c=>{var i;if((i=c.dataTransfer)!=null&&i.items){const h=ct(c.dataTransfer.items);h&&j.value&&(Z(h),c.preventDefault())}},se=c=>{if(c.clipboardData){const i=ct(c.clipboardData.items);i&&j.value&&Z(i)}},xe=()=>{const c=I.value;c.files&&j.value&&Z(c.files[0]).then(()=>{c.value=""})},ve=async()=>{var c,i,h,V,f,P;const{serverURL:N,lang:ee,login:de,wordLimit:Re,requiredMeta:je,recaptchaV3Key:ze,turnstileKey:_e}=n.value,ht=await Zl(),T={comment:me.value,nick:E.value.nick,mail:E.value.mail,link:E.value.link,url:n.value.path,ua:ht};if(!t.edit)if((c=y.value)!=null&&c.token)T.nick=y.value.display_name,T.mail=y.value.email,T.link=y.value.url;else{if(de==="force")return;if(je.includes("nick")&&!T.nick)return(i=z.value.nick)==null||i.focus(),alert(u.value.nickError);if(je.includes("mail")&&!T.mail||T.mail&&!Ul(T.mail))return(h=z.value.mail)==null||h.focus(),alert(u.value.mailError);T.nick||(T.nick=u.value.anonymous)}if(!T.comment){(V=b.value)==null||V.focus();return}if(!le.value)return alert(u.value.wordHint.replace("$0",Re[0].toString()).replace("$1",Re[1].toString()).replace("$2",_.value.toString()));T.comment=ut(T.comment,g.value.map),t.replyId&&t.rootId&&(T.pid=t.replyId,T.rid=t.rootId,T.at=t.replyUser),Y.value=!0;try{ze&&(T.recaptchaV3=await Jt(ze).execute("social")),_e&&(T.turnstile=await Yt(_e).execute("social"));const pe={serverURL:N,lang:ee,token:(f=y.value)==null?void 0:f.token,comment:T},ye=await(t.edit?fe({objectId:t.edit.objectId,...pe}):Mt(pe));if(Y.value=!1,ye.errmsg)return alert(ye.errmsg);l("submit",ye.data),v.value="",L.value="",await He(),t.replyId&&l("cancelReply"),(P=t.edit)!=null&&P.objectId&&l("cancelEdit")}catch(pe){Y.value=!1,alert(pe.message)}},dt=c=>{c.preventDefault();const{lang:i,serverURL:h}=n.value;St({serverURL:h,lang:i}).then(V=>{y.value=V,(V.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(V)),l("log")})},pt=()=>{y.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),l("log")},Ae=c=>{c.preventDefault();const{lang:i,serverURL:h}=n.value,V=800,f=800,P=(window.innerWidth-V)/2,N=(window.innerHeight-f)/2,ee=new URLSearchParams({lng:i,token:y.value.token}),de=window.open(`${h}/ui/profile?${ee.toString()}`,"_blank",`width=${V},height=${f},left=${P},top=${N},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);de==null||de.postMessage({type:"TOKEN",data:y.value.token},"*")},gt=c=>{var i,h,V,f;!((i=U.value)!=null&&i.contains(c.target))&&!((h=d.value)!=null&&h.contains(c.target))&&(p.value=!1),!((V=S.value)!=null&&V.contains(c.target))&&!((f=R.value)!=null&&f.contains(c.target))&&(F.value=!1)},Me=async c=>{var i;const{scrollTop:h,clientHeight:V,scrollHeight:f}=c.target,P=(V+h)/f,N=n.value.search,ee=((i=k.value)==null?void 0:i.value)??"";P<.9||H.loading||re.value||(H.loading=!0,(N.more&&H.list.length?await N.more(ee,H.list.length):await N.search(ee)).length?H.list=[...H.list,...N.more&&H.list.length?await N.more(ee,H.list.length):await N.search(ee)]:re.value=!0,H.loading=!1,setTimeout(()=>{c.target.scrollTop=h},50))},Se=Et(c=>{H.list=[],re.value=!1,Me(c)},300);return ae([n,_],([c,i])=>{const{wordLimit:h}=c;h?i<h[0]&&h[0]!==0?(te.value=h[0],le.value=!1):i>h[1]?(te.value=h[1],le.value=!1):(te.value=h[1],le.value=!0):(te.value=0,le.value=!0)},{immediate:!0}),Fe("click",gt),Fe("message",({data:c})=>{!c||c.type!=="profile"||(y.value={...y.value,...c.data},[localStorage,sessionStorage].filter(i=>i.getItem("WALINE_USER")).forEach(i=>i.setItem("WALINE_USER",JSON.stringify(y))))}),ae(F,async c=>{var i;if(!c)return;const h=n.value.search;k.value&&(k.value.value=""),H.loading=!0,H.list=await(((i=h.default)==null?void 0:i.call(h))??h.search("")),H.loading=!1}),ge(()=>{var c;(c=t.edit)!=null&&c.objectId&&(v.value=t.edit.orig),ae(()=>v.value,i=>{const{highlighter:h,texRenderer:V}=n.value;me.value=i,L.value=Ol(i,{emojiMap:g.value.map,highlighter:h,texRenderer:V}),_.value=Kl(i),i?We(b.value):We.destroy(b.value)},{immediate:!0}),ae(()=>n.value.emoji,i=>Fl(i).then(h=>{g.value=h}),{immediate:!0})}),(c,i)=>{var h,V;return r(),s("div",{key:w(y).token,class:"wl-comment"},[w(n).login!=="disable"&&x.value&&!((h=c.edit)!=null&&h.objectId)?(r(),s("div",Xl,[m("div",Jl,[m("button",{type:"submit",class:"wl-logout-btn",title:u.value.logout,onClick:pt},[O(w(Be),{size:14})],8,Yl),m("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:u.value.profile,onClick:Ae},[m("img",{src:w(y).avatar,alt:"avatar"},null,8,ea)],8,Ql)]),m("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:u.value.profile,onClick:Ae,textContent:A(w(y).display_name)},null,8,ta)])):$("v-if",!0),m("div",la,[w(n).login!=="force"&&w(n).meta.length&&!x.value?(r(),s("div",{key:0,class:D(["wl-header",`item${w(n).meta.length}`])},[(r(!0),s(B,null,J(w(n).meta,f=>(r(),s("div",{key:f,class:"wl-header-item"},[m("label",{for:`wl-${f}`,textContent:A(u.value[f]+(w(n).requiredMeta.includes(f)||!w(n).requiredMeta.length?"":`(${u.value.optional})`))},null,8,aa),he(m("input",{id:`wl-${f}`,ref_for:!0,ref:P=>{P&&(z.value[f]=P)},"onUpdate:modelValue":P=>w(E)[f]=P,class:D(["wl-input",`wl-${f}`]),name:f,type:f==="mail"?"email":"text"},null,10,na),[[wt,w(E)[f]]])]))),128))],2)):$("v-if",!0),he(m("textarea",{id:"wl-edit",ref_key:"editorRef",ref:b,"onUpdate:modelValue":i[0]||(i[0]=f=>kt(v)?v.value=f:null),class:"wl-editor",placeholder:c.replyUser?`@${c.replyUser}`:u.value.placeholder,onKeydown:K,onDrop:X,onPaste:se},null,40,ia),[[bt,w(v)]]),he(m("div",oa,[i[7]||(i[7]=m("hr",null,null,-1)),m("h4",null,A(u.value.preview)+":",1),m("div",{class:"wl-content",innerHTML:L.value},null,8,ra)],512),[[Te,q.value]]),m("div",sa,[m("div",ca,[m("a",ua,[O(w(Wt))]),he(m("button",{ref_key:"emojiButtonRef",ref:U,type:"button",class:D(["wl-action",{active:p.value}]),title:u.value.emoji,onClick:i[1]||(i[1]=f=>p.value=!p.value)},[O(w(Ht))],10,ma),[[Te,g.value.tabs.length]]),w(n).search?(r(),s("button",{key:0,ref_key:"gifButtonRef",ref:S,type:"button",class:D(["wl-action",{active:F.value}]),title:u.value.gif,onClick:i[2]||(i[2]=f=>F.value=!F.value)},[O(w(Ot))],10,va)):$("v-if",!0),m("input",{id:"wl-image-upload",ref_key:"imageUploadRef",ref:I,class:"upload","aria-hidden":"true",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:xe},null,544),j.value?(r(),s("label",{key:1,for:"wl-image-upload",class:"wl-action",title:u.value.uploadImage,"aria-label":u.value.uploadImage},[O(w(Tt))],8,da)):$("v-if",!0),m("button",{type:"button",class:D(["wl-action",{active:q.value}]),title:u.value.preview,onClick:i[3]||(i[3]=f=>q.value=!q.value)},[O(w(Nt))],10,pa)]),m("div",ga,[i[9]||(i[9]=m("div",{class:"wl-captcha-container"},null,-1)),m("div",ha,[ie(A(_.value)+" ",1),w(n).wordLimit?(r(),s("span",fa,[i[8]||(i[8]=ie("  /  ")),m("span",{class:D({illegal:!le.value}),textContent:A(te.value)},null,10,ya)])):$("v-if",!0),ie("  "+A(u.value.word),1)]),w(n).login!=="disable"&&!x.value?(r(),s("button",{key:0,type:"button",class:"wl-btn",onClick:dt,textContent:A(u.value.login)},null,8,wa)):$("v-if",!0),w(n).login!=="force"||x.value?(r(),s("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:Y.value,onClick:ve},[Y.value?(r(),ne(w(ue),{key:0,size:16})):(r(),s(B,{key:1},[ie(A(u.value.submit),1)],64))],8,ka)):$("v-if",!0)]),m("div",{ref_key:"gifPopupRef",ref:R,class:D(["wl-gif-popup",{display:F.value}])},[m("input",{ref_key:"gifSearchInputRef",ref:k,type:"text",placeholder:u.value.gifSearchPlaceholder,onInput:i[4]||(i[4]=(...f)=>w(Se)&&w(Se)(...f))},null,40,ba),H.list.length?(r(),ne(ml,{key:0,items:H.list,"column-width":200,gap:6,onInsert:i[5]||(i[5]=f=>G(f)),onScroll:Me},null,8,["items"])):$("v-if",!0),H.loading?(r(),s("div",Ca,[O(w(ue),{size:30})])):$("v-if",!0)],2),m("div",{ref_key:"emojiPopupRef",ref:d,class:D(["wl-emoji-popup",{display:p.value}])},[(r(!0),s(B,null,J(g.value.tabs,(f,P)=>(r(),s(B,{key:f.name},[P===o.value?(r(),s("div",$a,[(r(!0),s(B,null,J(f.items,N=>(r(),s("button",{key:N,type:"button",title:N,onClick:ee=>G(`:${N}:`)},[p.value?(r(),s("img",{key:0,class:"wl-emoji",src:g.value.map[N],alt:N,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Ea)):$("v-if",!0)],8,Ia))),128))])):$("v-if",!0)],64))),128)),g.value.tabs.length>1?(r(),s("div",La,[(r(!0),s(B,null,J(g.value.tabs,(f,P)=>(r(),s("button",{key:f.name,type:"button",class:D(["wl-tab",{active:o.value===P}]),onClick:N=>o.value=P},[m("img",{class:"wl-emoji",src:f.icon,alt:f.name,title:f.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Aa)],10,xa))),128))])):$("v-if",!0)],2)])]),c.replyId||(V=c.edit)!=null&&V.objectId?(r(),s("button",{key:1,type:"button",class:"wl-close",title:u.value.cancelReply,onClick:i[6]||(i[6]=f=>c.replyId?l("cancelReply"):l("cancelEdit"))},[O(w(Be),{size:24})],8,Ma)):$("v-if",!0)])}}});const Sa=["id"],Ra={class:"wl-user","aria-hidden":"true"},ja=["src"],za={class:"wl-card"},_a={class:"wl-head"},Va=["href"],Ua={key:1,class:"wl-nick"},Ha=["textContent"],Ta=["textContent"],Fa=["textContent"],Na=["textContent"],Wa=["textContent"],Ba={class:"wl-comment-actions"},Pa=["title"],Da=["title"],Oa={class:"wl-meta","aria-hidden":"true"},qa=["data-value","textContent"],Ga={key:0,class:"wl-content"},Ka={key:0},Za=["href"],Xa=["innerHTML"],Ja={key:1,class:"wl-admin-actions"},Ya={class:"wl-comment-status"},Qa=["disabled","onClick","textContent"],en={key:3,class:"wl-quote"};var tn=ce({__name:"CommentCard",props:{comment:{},edit:{default:null},rootId:{},reply:{default:null}},emits:["log","submit","delete","edit","like","status","sticky","reply"],setup(e,{emit:a}){const t=e,l=a,n=["approved","waiting","spam"],v=we("config"),E=De(),y=Lt(),z=ke(),b=W(()=>v.value.locale),I=W(()=>{const{link:o}=t.comment;return o?Ze(o)?o:`https://${o}`:""}),U=W(()=>E.value.includes(t.comment.objectId)),d=W(()=>_l(new Date(t.comment.time),y.value,b.value)),S=W(()=>z.value.type==="administrator"),R=W(()=>t.comment.user_id&&z.value.objectId===t.comment.user_id),k=W(()=>{var o;return t.comment.objectId===((o=t.reply)==null?void 0:o.objectId)}),g=W(()=>{var o;return t.comment.objectId===((o=t.edit)==null?void 0:o.objectId)});return(o,p)=>{var F;const q=Ct("CommentCard",!0);return r(),s("div",{id:o.comment.objectId,class:"wl-card-item"},[m("div",Ra,[o.comment.avatar?(r(),s("img",{key:0,class:"wl-user-avatar",src:o.comment.avatar,alt:""},null,8,ja)):$("v-if",!0),o.comment.type?(r(),ne(w(Dt),{key:1})):$("v-if",!0)]),m("div",za,[m("div",_a,[I.value?(r(),s("a",{key:0,class:"wl-nick",href:I.value,target:"_blank",rel:"nofollow noopener noreferrer"},A(o.comment.nick),9,Va)):(r(),s("span",Ua,A(o.comment.nick),1)),o.comment.type==="administrator"?(r(),s("span",{key:2,class:"wl-badge",textContent:A(b.value.admin)},null,8,Ha)):$("v-if",!0),o.comment.label?(r(),s("span",{key:3,class:"wl-badge",textContent:A(o.comment.label)},null,8,Ta)):$("v-if",!0),o.comment.sticky?(r(),s("span",{key:4,class:"wl-badge",textContent:A(b.value.sticky)},null,8,Fa)):$("v-if",!0),typeof o.comment.level=="number"?(r(),s("span",{key:5,class:D(`wl-badge level${o.comment.level}`),textContent:A(b.value[`level${o.comment.level}`]||`Level ${o.comment.level}`)},null,10,Na)):$("v-if",!0),m("span",{class:"wl-time",textContent:A(d.value)},null,8,Wa),m("div",Ba,[S.value||R.value?(r(),s(B,{key:0},[m("button",{type:"button",class:"wl-edit",onClick:p[0]||(p[0]=L=>l("edit",o.comment))},[O(w(Pt))]),m("button",{type:"button",class:"wl-delete",onClick:p[1]||(p[1]=L=>l("delete",o.comment))},[O(w(Ut))])],64)):$("v-if",!0),m("button",{type:"button",class:"wl-like",title:U.value?b.value.cancelLike:b.value.like,onClick:p[2]||(p[2]=L=>l("like",o.comment))},[O(w(Ft),{active:U.value},null,8,["active"]),ie(" "+A("like"in o.comment?o.comment.like:""),1)],8,Pa),m("button",{type:"button",class:D(["wl-reply",{active:k.value}]),title:k.value?b.value.cancelReply:b.value.reply,onClick:p[3]||(p[3]=L=>l("reply",k.value?null:o.comment))},[O(w(Bt))],10,Da)])]),m("div",Oa,[(r(),s(B,null,J(["addr","browser","os"],L=>(r(),s(B,null,[o.comment[L]?(r(),s("span",{key:L,class:D(`wl-${L}`),"data-value":o.comment[L],textContent:A(o.comment[L])},null,10,qa)):$("v-if",!0)],64))),64))]),g.value?$("v-if",!0):(r(),s("div",Ga,[o.comment.reply_user?(r(),s("p",Ka,[m("a",{href:"#"+o.comment.pid},"@"+A(o.comment.reply_user.nick),9,Za),p[17]||(p[17]=m("span",null,": ",-1))])):$("v-if",!0),m("div",{innerHTML:o.comment.comment},null,8,Xa)])),S.value&&!g.value?(r(),s("div",Ja,[m("span",Ya,[(r(),s(B,null,J(n,L=>m("button",{key:L,type:"submit",class:D(`wl-btn wl-${L}`),disabled:o.comment.status===L,onClick:_=>l("status",{status:L,comment:o.comment}),textContent:A(b.value[L])},null,10,Qa)),64))]),S.value&&!("rid"in o.comment)?(r(),s("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:p[4]||(p[4]=L=>l("sticky",o.comment))},A(o.comment.sticky?b.value.unsticky:b.value.sticky),1)):$("v-if",!0)])):$("v-if",!0),k.value||g.value?(r(),s("div",{key:2,class:D({"wl-reply-wrapper":k.value,"wl-edit-wrapper":g.value})},[O(mt,{edit:o.edit,"reply-id":(F=o.reply)==null?void 0:F.objectId,"reply-user":o.comment.nick,"root-id":o.rootId,onLog:p[5]||(p[5]=L=>l("log")),onCancelReply:p[6]||(p[6]=L=>l("reply",null)),onCancelEdit:p[7]||(p[7]=L=>l("edit",null)),onSubmit:p[8]||(p[8]=L=>l("submit",L))},null,8,["edit","reply-id","reply-user","root-id"])],2)):$("v-if",!0),"children"in o.comment?(r(),s("div",en,[(r(!0),s(B,null,J(o.comment.children,L=>(r(),ne(q,{key:L.objectId,comment:L,reply:o.reply,edit:o.edit,"root-id":o.rootId,onLog:p[9]||(p[9]=_=>l("log")),onDelete:p[10]||(p[10]=_=>l("delete",_)),onEdit:p[11]||(p[11]=_=>l("edit",_)),onLike:p[12]||(p[12]=_=>l("like",_)),onReply:p[13]||(p[13]=_=>l("reply",_)),onStatus:p[14]||(p[14]=_=>l("status",_)),onSticky:p[15]||(p[15]=_=>l("sticky",_)),onSubmit:p[16]||(p[16]=_=>l("submit",_))},null,8,["comment","reply","edit","root-id"]))),128))])):$("v-if",!0)])],8,Sa)}}});const vt="3.3.2",ln={"data-waline":""},an={class:"wl-meta-head"},nn={class:"wl-count"},on=["textContent"],rn={class:"wl-sort"},sn=["onClick"],cn={class:"wl-cards"},un={key:1,class:"wl-operation"},mn=["textContent"],vn={key:2,class:"wl-loading"},dn=["textContent"],pn={key:4,class:"wl-operation"},gn=["textContent"],hn={key:5,class:"wl-power"};var fn=ce({__name:"WalineComment",props:["serverURL","path","meta","requiredMeta","dark","commentSorting","lang","locale","pageSize","wordLimit","emoji","login","highlighter","texRenderer","imageUploader","search","copyright","recaptchaV3Key","turnstileKey","reaction"],setup(e){const a=e,t={latest:"insertedAt_desc",oldest:"insertedAt_asc",hottest:"like_desc"},l=Object.keys(t),n=ke(),v=De(),E=C("loading"),y=C(0),z=C(1),b=C(0),I=W(()=>Rl(a)),U=C(I.value.commentSorting),d=C([]),S=C(null),R=C(null),k=W(()=>jl(I.value.dark)),g=W(()=>I.value.locale);xt(k,{id:"waline-darkmode"});let o;const p=u=>{var x;const{serverURL:j,path:G,pageSize:K}=I.value,Z=new AbortController;E.value="loading",o==null||o(),jt({serverURL:j,lang:I.value.lang,path:G,pageSize:K,sortBy:t[U.value],page:u,signal:Z.signal,token:(x=n.value)==null?void 0:x.token}).then(X=>{E.value="success",y.value=X.count,d.value.push(...X.data),z.value=u,b.value=X.totalPages}).catch(X=>{X.name!=="AbortError"&&(console.error(X.message),E.value="error")}),o=Z.abort.bind(Z)},F=()=>p(z.value+1),q=()=>{y.value=0,d.value=[],p(1)},L=u=>{U.value!==u&&(U.value=u,q())},_=u=>{S.value=u},H=u=>{R.value=u},te=u=>{if(R.value)R.value.comment=u.comment,R.value.orig=u.orig;else if("rid"in u){const x=d.value.find(({objectId:j})=>j===u.rid);if(!x)return;Array.isArray(x.children)||(x.children=[]),x.children.push(u)}else d.value.unshift(u),y.value+=1},le=async({comment:u,status:x})=>{var j;if(u.status===x)return;const{serverURL:G,lang:K}=I.value;await fe({serverURL:G,lang:K,token:(j=n.value)==null?void 0:j.token,objectId:u.objectId,comment:{status:x}}),u.status=x},me=async u=>{var x;if("rid"in u)return;const{serverURL:j,lang:G}=I.value;await fe({serverURL:j,lang:G,token:(x=n.value)==null?void 0:x.token,objectId:u.objectId,comment:{sticky:u.sticky?0:1}}),u.sticky=!u.sticky},Y=async({objectId:u})=>{var x;if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:j,lang:G}=I.value;await Rt({serverURL:j,lang:G,token:(x=n.value)==null?void 0:x.token,objectId:u}),d.value.some((K,Z)=>K.objectId===u?(d.value=d.value.filter((X,se)=>se!==Z),!0):K.children.some((X,se)=>X.objectId===u?(d.value[Z].children=K.children.filter((xe,ve)=>ve!==se),!0):!1))},re=async u=>{var x;const{serverURL:j,lang:G}=I.value,{objectId:K}=u,Z=v.value.includes(K);await fe({serverURL:j,lang:G,objectId:K,token:(x=n.value)==null?void 0:x.token,comment:{like:!Z}}),Z?v.value=v.value.filter(X=>X!==K):(v.value=[...v.value,K],v.value.length>50&&(v.value=v.value.slice(-50))),u.like=(u.like||0)+(Z?-1:1)};return $t("config",I),ge(()=>{ae(()=>[a.serverURL,a.path],()=>q(),{immediate:!0})}),Ve(()=>o==null?void 0:o()),(u,x)=>(r(),s("div",ln,[O(sl),!S.value&&!R.value?(r(),ne(mt,{key:0,onLog:q,onSubmit:te})):$("v-if",!0),m("div",an,[m("div",nn,[y.value?(r(),s("span",{key:0,class:"wl-num",textContent:A(y.value)},null,8,on)):$("v-if",!0),ie(" "+A(g.value.comment),1)]),m("ul",rn,[(r(!0),s(B,null,J(w(l),j=>(r(),s("li",{key:j,class:D([j===U.value?"active":""]),onClick:G=>L(j)},A(g.value[j]),11,sn))),128))])]),m("div",cn,[(r(!0),s(B,null,J(d.value,j=>(r(),ne(tn,{key:j.objectId,"root-id":j.objectId,comment:j,reply:S.value,edit:R.value,onLog:q,onReply:_,onEdit:H,onSubmit:te,onStatus:le,onDelete:Y,onSticky:me,onLike:re},null,8,["root-id","comment","reply","edit"]))),128))]),E.value==="error"?(r(),s("div",un,[m("button",{type:"button",class:"wl-btn",onClick:q,textContent:A(g.value.refresh)},null,8,mn)])):E.value==="loading"?(r(),s("div",vn,[O(w(ue),{size:30})])):d.value.length?z.value<b.value?(r(),s("div",pn,[m("button",{type:"button",class:"wl-btn",onClick:F,textContent:A(g.value.more)},null,8,gn)])):$("v-if",!0):(r(),s("div",{key:3,class:"wl-empty",textContent:A(g.value.sofa)},null,8,dn)),I.value.copyright?(r(),s("div",hn,[x[0]||(x[0]=ie(" Powered by ")),x[1]||(x[1]=m("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1)),ie(" v"+A(w(vt)),1)])):$("v-if",!0)]))}});export{fn as Waline,vt as version};
11
+ ![${c.name}](${h})`)}).catch(h=>{alert(h.message),v.value=v.value.replace(i,"")}).then(()=>{Y.value=!1})},X=c=>{var i;if((i=c.dataTransfer)!=null&&i.items){const h=ct(c.dataTransfer.items);h&&j.value&&(Z(h),c.preventDefault())}},se=c=>{if(c.clipboardData){const i=ct(c.clipboardData.items);i&&j.value&&Z(i)}},xe=()=>{const c=I.value;c.files&&j.value&&Z(c.files[0]).then(()=>{c.value=""})},ve=async()=>{var c,i,h,V,f,P;const{serverURL:N,lang:ee,login:de,wordLimit:Re,requiredMeta:je,recaptchaV3Key:ze,turnstileKey:_e}=n.value,ht=await Zl(),T={comment:me.value,nick:E.value.nick,mail:E.value.mail,link:E.value.link,url:n.value.path,ua:ht};if(!t.edit)if((c=y.value)!=null&&c.token)T.nick=y.value.display_name,T.mail=y.value.email,T.link=y.value.url;else{if(de==="force")return;if(je.includes("nick")&&!T.nick)return(i=z.value.nick)==null||i.focus(),alert(u.value.nickError);if(je.includes("mail")&&!T.mail||T.mail&&!Ul(T.mail))return(h=z.value.mail)==null||h.focus(),alert(u.value.mailError);T.nick||(T.nick=u.value.anonymous)}if(!T.comment){(V=b.value)==null||V.focus();return}if(!le.value)return alert(u.value.wordHint.replace("$0",Re[0].toString()).replace("$1",Re[1].toString()).replace("$2",_.value.toString()));T.comment=ut(T.comment,g.value.map),t.replyId&&t.rootId&&(T.pid=t.replyId,T.rid=t.rootId,T.at=t.replyUser),Y.value=!0;try{ze&&(T.recaptchaV3=await Jt(ze).execute("social")),_e&&(T.turnstile=await Yt(_e).execute("social"));const pe={serverURL:N,lang:ee,token:(f=y.value)==null?void 0:f.token,comment:T},ye=await(t.edit?fe({objectId:t.edit.objectId,...pe}):Mt(pe));if(Y.value=!1,ye.errmsg)return alert(ye.errmsg);l("submit",ye.data),v.value="",L.value="",await He(),t.replyId&&l("cancelReply"),(P=t.edit)!=null&&P.objectId&&l("cancelEdit")}catch(pe){Y.value=!1,alert(pe.message)}},dt=c=>{c.preventDefault();const{lang:i,serverURL:h}=n.value;St({serverURL:h,lang:i}).then(V=>{y.value=V,(V.remember?localStorage:sessionStorage).setItem("WALINE_USER",JSON.stringify(V)),l("log")})},pt=()=>{y.value={},localStorage.setItem("WALINE_USER","null"),sessionStorage.setItem("WALINE_USER","null"),l("log")},Ae=c=>{c.preventDefault();const{lang:i,serverURL:h}=n.value,V=800,f=800,P=(window.innerWidth-V)/2,N=(window.innerHeight-f)/2,ee=new URLSearchParams({lng:i,token:y.value.token}),de=window.open(`${h}/ui/profile?${ee.toString()}`,"_blank",`width=${V},height=${f},left=${P},top=${N},scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no`);de==null||de.postMessage({type:"TOKEN",data:y.value.token},"*")},gt=c=>{var i,h,V,f;!((i=U.value)!=null&&i.contains(c.target))&&!((h=d.value)!=null&&h.contains(c.target))&&(p.value=!1),!((V=S.value)!=null&&V.contains(c.target))&&!((f=R.value)!=null&&f.contains(c.target))&&(F.value=!1)},Me=async c=>{var i;const{scrollTop:h,clientHeight:V,scrollHeight:f}=c.target,P=(V+h)/f,N=n.value.search,ee=((i=k.value)==null?void 0:i.value)??"";P<.9||H.loading||re.value||(H.loading=!0,(N.more&&H.list.length?await N.more(ee,H.list.length):await N.search(ee)).length?H.list=[...H.list,...N.more&&H.list.length?await N.more(ee,H.list.length):await N.search(ee)]:re.value=!0,H.loading=!1,setTimeout(()=>{c.target.scrollTop=h},50))},Se=Et(c=>{H.list=[],re.value=!1,Me(c)},300);return ae([n,_],([c,i])=>{const{wordLimit:h}=c;h?i<h[0]&&h[0]!==0?(te.value=h[0],le.value=!1):i>h[1]?(te.value=h[1],le.value=!1):(te.value=h[1],le.value=!0):(te.value=0,le.value=!0)},{immediate:!0}),Fe("click",gt),Fe("message",({data:c})=>{!c||c.type!=="profile"||(y.value={...y.value,...c.data},[localStorage,sessionStorage].filter(i=>i.getItem("WALINE_USER")).forEach(i=>i.setItem("WALINE_USER",JSON.stringify(y))))}),ae(F,async c=>{var i;if(!c)return;const h=n.value.search;k.value&&(k.value.value=""),H.loading=!0,H.list=await(((i=h.default)==null?void 0:i.call(h))??h.search("")),H.loading=!1}),ge(()=>{var c;(c=t.edit)!=null&&c.objectId&&(v.value=t.edit.orig),ae(()=>v.value,i=>{const{highlighter:h,texRenderer:V}=n.value;me.value=i,L.value=Ol(i,{emojiMap:g.value.map,highlighter:h,texRenderer:V}),_.value=Kl(i),i?We(b.value):We.destroy(b.value)},{immediate:!0}),ae(()=>n.value.emoji,i=>Fl(i).then(h=>{g.value=h}),{immediate:!0})}),(c,i)=>{var h,V;return r(),s("div",{key:w(y).token,class:"wl-comment"},[w(n).login!=="disable"&&x.value&&!((h=c.edit)!=null&&h.objectId)?(r(),s("div",Xl,[m("div",Jl,[m("button",{type:"submit",class:"wl-logout-btn",title:u.value.logout,onClick:pt},[O(w(Be),{size:14})],8,Yl),m("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:u.value.profile,onClick:Ae},[m("img",{src:w(y).avatar,alt:"avatar"},null,8,ea)],8,Ql)]),m("a",{href:"#",class:"wl-login-nick","aria-label":"Profile",title:u.value.profile,onClick:Ae,textContent:A(w(y).display_name)},null,8,ta)])):$("v-if",!0),m("div",la,[w(n).login!=="force"&&w(n).meta.length&&!x.value?(r(),s("div",{key:0,class:D(["wl-header",`item${w(n).meta.length}`])},[(r(!0),s(B,null,J(w(n).meta,f=>(r(),s("div",{key:f,class:"wl-header-item"},[m("label",{for:`wl-${f}`,textContent:A(u.value[f]+(w(n).requiredMeta.includes(f)||!w(n).requiredMeta.length?"":`(${u.value.optional})`))},null,8,aa),he(m("input",{id:`wl-${f}`,ref_for:!0,ref:P=>{P&&(z.value[f]=P)},"onUpdate:modelValue":P=>w(E)[f]=P,class:D(["wl-input",`wl-${f}`]),name:f,type:f==="mail"?"email":"text"},null,10,na),[[wt,w(E)[f]]])]))),128))],2)):$("v-if",!0),he(m("textarea",{id:"wl-edit",ref_key:"editorRef",ref:b,"onUpdate:modelValue":i[0]||(i[0]=f=>kt(v)?v.value=f:null),class:"wl-editor",placeholder:c.replyUser?`@${c.replyUser}`:u.value.placeholder,onKeydown:K,onDrop:X,onPaste:se},null,40,ia),[[bt,w(v)]]),he(m("div",oa,[i[7]||(i[7]=m("hr",null,null,-1)),m("h4",null,A(u.value.preview)+":",1),m("div",{class:"wl-content",innerHTML:L.value},null,8,ra)],512),[[Te,q.value]]),m("div",sa,[m("div",ca,[m("a",ua,[O(w(Wt))]),he(m("button",{ref_key:"emojiButtonRef",ref:U,type:"button",class:D(["wl-action",{active:p.value}]),title:u.value.emoji,onClick:i[1]||(i[1]=f=>p.value=!p.value)},[O(w(Ht))],10,ma),[[Te,g.value.tabs.length]]),w(n).search?(r(),s("button",{key:0,ref_key:"gifButtonRef",ref:S,type:"button",class:D(["wl-action",{active:F.value}]),title:u.value.gif,onClick:i[2]||(i[2]=f=>F.value=!F.value)},[O(w(Ot))],10,va)):$("v-if",!0),m("input",{id:"wl-image-upload",ref_key:"imageUploadRef",ref:I,class:"upload","aria-hidden":"true",type:"file",accept:".png,.jpg,.jpeg,.webp,.bmp,.gif",onChange:xe},null,544),j.value?(r(),s("label",{key:1,for:"wl-image-upload",class:"wl-action",title:u.value.uploadImage,"aria-label":u.value.uploadImage},[O(w(Tt))],8,da)):$("v-if",!0),m("button",{type:"button",class:D(["wl-action",{active:q.value}]),title:u.value.preview,onClick:i[3]||(i[3]=f=>q.value=!q.value)},[O(w(Nt))],10,pa)]),m("div",ga,[i[9]||(i[9]=m("div",{class:"wl-captcha-container"},null,-1)),m("div",ha,[ie(A(_.value)+" ",1),w(n).wordLimit?(r(),s("span",fa,[i[8]||(i[8]=ie("  /  ")),m("span",{class:D({illegal:!le.value}),textContent:A(te.value)},null,10,ya)])):$("v-if",!0),ie("  "+A(u.value.word),1)]),w(n).login!=="disable"&&!x.value?(r(),s("button",{key:0,type:"button",class:"wl-btn",onClick:dt,textContent:A(u.value.login)},null,8,wa)):$("v-if",!0),w(n).login!=="force"||x.value?(r(),s("button",{key:1,type:"submit",class:"primary wl-btn",title:"Cmd|Ctrl + Enter",disabled:Y.value,onClick:ve},[Y.value?(r(),ne(w(ue),{key:0,size:16})):(r(),s(B,{key:1},[ie(A(u.value.submit),1)],64))],8,ka)):$("v-if",!0)]),m("div",{ref_key:"gifPopupRef",ref:R,class:D(["wl-gif-popup",{display:F.value}])},[m("input",{ref_key:"gifSearchInputRef",ref:k,type:"text",placeholder:u.value.gifSearchPlaceholder,onInput:i[4]||(i[4]=(...f)=>w(Se)&&w(Se)(...f))},null,40,ba),H.list.length?(r(),ne(ml,{key:0,items:H.list,"column-width":200,gap:6,onInsert:i[5]||(i[5]=f=>G(f)),onScroll:Me},null,8,["items"])):$("v-if",!0),H.loading?(r(),s("div",Ca,[O(w(ue),{size:30})])):$("v-if",!0)],2),m("div",{ref_key:"emojiPopupRef",ref:d,class:D(["wl-emoji-popup",{display:p.value}])},[(r(!0),s(B,null,J(g.value.tabs,(f,P)=>(r(),s(B,{key:f.name},[P===o.value?(r(),s("div",$a,[(r(!0),s(B,null,J(f.items,N=>(r(),s("button",{key:N,type:"button",title:N,onClick:ee=>G(`:${N}:`)},[p.value?(r(),s("img",{key:0,class:"wl-emoji",src:g.value.map[N],alt:N,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Ea)):$("v-if",!0)],8,Ia))),128))])):$("v-if",!0)],64))),128)),g.value.tabs.length>1?(r(),s("div",La,[(r(!0),s(B,null,J(g.value.tabs,(f,P)=>(r(),s("button",{key:f.name,type:"button",class:D(["wl-tab",{active:o.value===P}]),onClick:N=>o.value=P},[m("img",{class:"wl-emoji",src:f.icon,alt:f.name,title:f.name,loading:"lazy",referrerPolicy:"no-referrer"},null,8,Aa)],10,xa))),128))])):$("v-if",!0)],2)])]),c.replyId||(V=c.edit)!=null&&V.objectId?(r(),s("button",{key:1,type:"button",class:"wl-close",title:u.value.cancelReply,onClick:i[6]||(i[6]=f=>c.replyId?l("cancelReply"):l("cancelEdit"))},[O(w(Be),{size:24})],8,Ma)):$("v-if",!0)])}}});const Sa=["id"],Ra={class:"wl-user","aria-hidden":"true"},ja=["src"],za={class:"wl-card"},_a={class:"wl-head"},Va=["href"],Ua={key:1,class:"wl-nick"},Ha=["textContent"],Ta=["textContent"],Fa=["textContent"],Na=["textContent"],Wa=["textContent"],Ba={class:"wl-comment-actions"},Pa=["title"],Da=["title"],Oa={class:"wl-meta","aria-hidden":"true"},qa=["data-value","textContent"],Ga={key:0,class:"wl-content"},Ka={key:0},Za=["href"],Xa=["innerHTML"],Ja={key:1,class:"wl-admin-actions"},Ya={class:"wl-comment-status"},Qa=["disabled","onClick","textContent"],en={key:3,class:"wl-quote"};var tn=ce({__name:"CommentCard",props:{comment:{},edit:{default:null},rootId:{},reply:{default:null}},emits:["log","submit","delete","edit","like","status","sticky","reply"],setup(e,{emit:a}){const t=e,l=a,n=["approved","waiting","spam"],v=we("config"),E=De(),y=Lt(),z=ke(),b=W(()=>v.value.locale),I=W(()=>{const{link:o}=t.comment;return o?Ze(o)?o:`https://${o}`:""}),U=W(()=>E.value.includes(t.comment.objectId)),d=W(()=>_l(new Date(t.comment.time),y.value,b.value)),S=W(()=>z.value.type==="administrator"),R=W(()=>t.comment.user_id&&z.value.objectId===t.comment.user_id),k=W(()=>{var o;return t.comment.objectId===((o=t.reply)==null?void 0:o.objectId)}),g=W(()=>{var o;return t.comment.objectId===((o=t.edit)==null?void 0:o.objectId)});return(o,p)=>{var F;const q=Ct("CommentCard",!0);return r(),s("div",{id:o.comment.objectId,class:"wl-card-item"},[m("div",Ra,[o.comment.avatar?(r(),s("img",{key:0,class:"wl-user-avatar",src:o.comment.avatar,alt:""},null,8,ja)):$("v-if",!0),o.comment.type?(r(),ne(w(Dt),{key:1})):$("v-if",!0)]),m("div",za,[m("div",_a,[I.value?(r(),s("a",{key:0,class:"wl-nick",href:I.value,target:"_blank",rel:"nofollow noopener noreferrer"},A(o.comment.nick),9,Va)):(r(),s("span",Ua,A(o.comment.nick),1)),o.comment.type==="administrator"?(r(),s("span",{key:2,class:"wl-badge",textContent:A(b.value.admin)},null,8,Ha)):$("v-if",!0),o.comment.label?(r(),s("span",{key:3,class:"wl-badge",textContent:A(o.comment.label)},null,8,Ta)):$("v-if",!0),o.comment.sticky?(r(),s("span",{key:4,class:"wl-badge",textContent:A(b.value.sticky)},null,8,Fa)):$("v-if",!0),typeof o.comment.level=="number"?(r(),s("span",{key:5,class:D(`wl-badge level${o.comment.level}`),textContent:A(b.value[`level${o.comment.level}`]||`Level ${o.comment.level}`)},null,10,Na)):$("v-if",!0),m("span",{class:"wl-time",textContent:A(d.value)},null,8,Wa),m("div",Ba,[S.value||R.value?(r(),s(B,{key:0},[m("button",{type:"button",class:"wl-edit",onClick:p[0]||(p[0]=L=>l("edit",o.comment))},[O(w(Pt))]),m("button",{type:"button",class:"wl-delete",onClick:p[1]||(p[1]=L=>l("delete",o.comment))},[O(w(Ut))])],64)):$("v-if",!0),m("button",{type:"button",class:"wl-like",title:U.value?b.value.cancelLike:b.value.like,onClick:p[2]||(p[2]=L=>l("like",o.comment))},[O(w(Ft),{active:U.value},null,8,["active"]),ie(" "+A("like"in o.comment?o.comment.like:""),1)],8,Pa),m("button",{type:"button",class:D(["wl-reply",{active:k.value}]),title:k.value?b.value.cancelReply:b.value.reply,onClick:p[3]||(p[3]=L=>l("reply",k.value?null:o.comment))},[O(w(Bt))],10,Da)])]),m("div",Oa,[(r(),s(B,null,J(["addr","browser","os"],L=>(r(),s(B,null,[o.comment[L]?(r(),s("span",{key:L,class:D(`wl-${L}`),"data-value":o.comment[L],textContent:A(o.comment[L])},null,10,qa)):$("v-if",!0)],64))),64))]),g.value?$("v-if",!0):(r(),s("div",Ga,[o.comment.reply_user?(r(),s("p",Ka,[m("a",{href:"#"+o.comment.pid},"@"+A(o.comment.reply_user.nick),9,Za),p[17]||(p[17]=m("span",null,": ",-1))])):$("v-if",!0),m("div",{innerHTML:o.comment.comment},null,8,Xa)])),S.value&&!g.value?(r(),s("div",Ja,[m("span",Ya,[(r(),s(B,null,J(n,L=>m("button",{key:L,type:"submit",class:D(`wl-btn wl-${L}`),disabled:o.comment.status===L,onClick:_=>l("status",{status:L,comment:o.comment}),textContent:A(b.value[L])},null,10,Qa)),64))]),S.value&&!("rid"in o.comment)?(r(),s("button",{key:0,type:"submit",class:"wl-btn wl-sticky",onClick:p[4]||(p[4]=L=>l("sticky",o.comment))},A(o.comment.sticky?b.value.unsticky:b.value.sticky),1)):$("v-if",!0)])):$("v-if",!0),k.value||g.value?(r(),s("div",{key:2,class:D({"wl-reply-wrapper":k.value,"wl-edit-wrapper":g.value})},[O(mt,{edit:o.edit,"reply-id":(F=o.reply)==null?void 0:F.objectId,"reply-user":o.comment.nick,"root-id":o.rootId,onLog:p[5]||(p[5]=L=>l("log")),onCancelReply:p[6]||(p[6]=L=>l("reply",null)),onCancelEdit:p[7]||(p[7]=L=>l("edit",null)),onSubmit:p[8]||(p[8]=L=>l("submit",L))},null,8,["edit","reply-id","reply-user","root-id"])],2)):$("v-if",!0),"children"in o.comment?(r(),s("div",en,[(r(!0),s(B,null,J(o.comment.children,L=>(r(),ne(q,{key:L.objectId,comment:L,reply:o.reply,edit:o.edit,"root-id":o.rootId,onLog:p[9]||(p[9]=_=>l("log")),onDelete:p[10]||(p[10]=_=>l("delete",_)),onEdit:p[11]||(p[11]=_=>l("edit",_)),onLike:p[12]||(p[12]=_=>l("like",_)),onReply:p[13]||(p[13]=_=>l("reply",_)),onStatus:p[14]||(p[14]=_=>l("status",_)),onSticky:p[15]||(p[15]=_=>l("sticky",_)),onSubmit:p[16]||(p[16]=_=>l("submit",_))},null,8,["comment","reply","edit","root-id"]))),128))])):$("v-if",!0)])],8,Sa)}}});const vt="3.4.0",ln={"data-waline":""},an={class:"wl-meta-head"},nn={class:"wl-count"},on=["textContent"],rn={class:"wl-sort"},sn=["onClick"],cn={class:"wl-cards"},un={key:1,class:"wl-operation"},mn=["textContent"],vn={key:2,class:"wl-loading"},dn=["textContent"],pn={key:4,class:"wl-operation"},gn=["textContent"],hn={key:5,class:"wl-power"};var fn=ce({__name:"WalineComment",props:["serverURL","path","meta","requiredMeta","dark","commentSorting","lang","locale","pageSize","wordLimit","emoji","login","highlighter","texRenderer","imageUploader","search","copyright","recaptchaV3Key","turnstileKey","reaction"],setup(e){const a=e,t={latest:"insertedAt_desc",oldest:"insertedAt_asc",hottest:"like_desc"},l=Object.keys(t),n=ke(),v=De(),E=C("loading"),y=C(0),z=C(1),b=C(0),I=W(()=>Rl(a)),U=C(I.value.commentSorting),d=C([]),S=C(null),R=C(null),k=W(()=>jl(I.value.dark)),g=W(()=>I.value.locale);xt(k,{id:"waline-darkmode"});let o;const p=u=>{var x;const{serverURL:j,path:G,pageSize:K}=I.value,Z=new AbortController;E.value="loading",o==null||o(),jt({serverURL:j,lang:I.value.lang,path:G,pageSize:K,sortBy:t[U.value],page:u,signal:Z.signal,token:(x=n.value)==null?void 0:x.token}).then(X=>{E.value="success",y.value=X.count,d.value.push(...X.data),z.value=u,b.value=X.totalPages}).catch(X=>{X.name!=="AbortError"&&(console.error(X.message),E.value="error")}),o=Z.abort.bind(Z)},F=()=>p(z.value+1),q=()=>{y.value=0,d.value=[],p(1)},L=u=>{U.value!==u&&(U.value=u,q())},_=u=>{S.value=u},H=u=>{R.value=u},te=u=>{if(R.value)R.value.comment=u.comment,R.value.orig=u.orig;else if("rid"in u){const x=d.value.find(({objectId:j})=>j===u.rid);if(!x)return;Array.isArray(x.children)||(x.children=[]),x.children.push(u)}else d.value.unshift(u),y.value+=1},le=async({comment:u,status:x})=>{var j;if(u.status===x)return;const{serverURL:G,lang:K}=I.value;await fe({serverURL:G,lang:K,token:(j=n.value)==null?void 0:j.token,objectId:u.objectId,comment:{status:x}}),u.status=x},me=async u=>{var x;if("rid"in u)return;const{serverURL:j,lang:G}=I.value;await fe({serverURL:j,lang:G,token:(x=n.value)==null?void 0:x.token,objectId:u.objectId,comment:{sticky:u.sticky?0:1}}),u.sticky=!u.sticky},Y=async({objectId:u})=>{var x;if(!confirm("Are you sure you want to delete this comment?"))return;const{serverURL:j,lang:G}=I.value;await Rt({serverURL:j,lang:G,token:(x=n.value)==null?void 0:x.token,objectId:u}),d.value.some((K,Z)=>K.objectId===u?(d.value=d.value.filter((X,se)=>se!==Z),!0):K.children.some((X,se)=>X.objectId===u?(d.value[Z].children=K.children.filter((xe,ve)=>ve!==se),!0):!1))},re=async u=>{var x;const{serverURL:j,lang:G}=I.value,{objectId:K}=u,Z=v.value.includes(K);await fe({serverURL:j,lang:G,objectId:K,token:(x=n.value)==null?void 0:x.token,comment:{like:!Z}}),Z?v.value=v.value.filter(X=>X!==K):(v.value=[...v.value,K],v.value.length>50&&(v.value=v.value.slice(-50))),u.like=(u.like||0)+(Z?-1:1)};return $t("config",I),ge(()=>{ae(()=>[a.serverURL,a.path],()=>q(),{immediate:!0})}),Ve(()=>o==null?void 0:o()),(u,x)=>(r(),s("div",ln,[O(sl),!S.value&&!R.value?(r(),ne(mt,{key:0,onLog:q,onSubmit:te})):$("v-if",!0),m("div",an,[m("div",nn,[y.value?(r(),s("span",{key:0,class:"wl-num",textContent:A(y.value)},null,8,on)):$("v-if",!0),ie(" "+A(g.value.comment),1)]),m("ul",rn,[(r(!0),s(B,null,J(w(l),j=>(r(),s("li",{key:j,class:D([j===U.value?"active":""]),onClick:G=>L(j)},A(g.value[j]),11,sn))),128))])]),m("div",cn,[(r(!0),s(B,null,J(d.value,j=>(r(),ne(tn,{key:j.objectId,"root-id":j.objectId,comment:j,reply:S.value,edit:R.value,onLog:q,onReply:_,onEdit:H,onSubmit:te,onStatus:le,onDelete:Y,onSticky:me,onLike:re},null,8,["root-id","comment","reply","edit"]))),128))]),E.value==="error"?(r(),s("div",un,[m("button",{type:"button",class:"wl-btn",onClick:q,textContent:A(g.value.refresh)},null,8,mn)])):E.value==="loading"?(r(),s("div",vn,[O(w(ue),{size:30})])):d.value.length?z.value<b.value?(r(),s("div",pn,[m("button",{type:"button",class:"wl-btn",onClick:F,textContent:A(g.value.more)},null,8,gn)])):$("v-if",!0):(r(),s("div",{key:3,class:"wl-empty",textContent:A(g.value.sofa)},null,8,dn)),I.value.copyright?(r(),s("div",hn,[x[0]||(x[0]=ie(" Powered by ")),x[1]||(x[1]=m("a",{href:"https://github.com/walinejs/waline",target:"_blank",rel:"noopener noreferrer"}," Waline ",-1)),ie(" v"+A(w(vt)),1)])):$("v-if",!0)]))}});export{fn as Waline,vt as version};
12
12
  //# sourceMappingURL=component.js.map