@ziteh/yangchun-comment-client 0.1.0 → 0.2.0-alpha.1
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/README.md +6 -0
- package/dist/src/api/apiService.d.ts +22 -0
- package/dist/src/api/globalApiService.d.ts +10 -0
- package/dist/src/components/comment-admin.d.ts +25 -0
- package/dist/src/components/comment-dialog.d.ts +18 -0
- package/dist/src/components/comment-info.d.ts +14 -0
- package/dist/src/components/comment-input.d.ts +31 -0
- package/dist/src/components/list/comment-list-item.d.ts +19 -0
- package/dist/src/components/list/comment-list.d.ts +9 -0
- package/dist/src/components/yangchun-comment.d.ts +58 -0
- package/dist/src/components/yangchun-comment.styles.d.ts +2 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/utils/comment.d.ts +6 -0
- package/dist/src/utils/format.d.ts +2 -0
- package/dist/src/utils/i18n.d.ts +46 -0
- package/dist/src/utils/pow.d.ts +9 -0
- package/dist/{utils → src/utils}/pseudonym.d.ts +0 -1
- package/dist/src/utils/sanitize.d.ts +1 -0
- package/dist/test/sanitize.test.d.ts +1 -0
- package/dist/yangchun-comment.js +962 -0
- package/dist/yangchun-comment.js.map +1 -0
- package/dist/yangchun-comment.umd.cjs +962 -0
- package/dist/yangchun-comment.umd.cjs.map +1 -0
- package/package.json +17 -13
- package/dist/element.d.ts +0 -97
- package/dist/element.js +0 -680
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -23
- package/dist/types.d.ts +0 -3
- package/dist/utils/apiService.d.ts +0 -15
- package/dist/utils/apiService.js +0 -118
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.js +0 -14
- package/dist/utils/i18n.d.ts +0 -51
- package/dist/utils/i18n.js +0 -98
- package/dist/utils/pseudonym.js +0 -34
- package/dist/utils/sanitize.d.ts +0 -4
- package/dist/utils/sanitize.js +0 -59
- package/dist/utils/wordBank.js +0 -692
- package/dist/views/comments.d.ts +0 -3
- package/dist/views/comments.js +0 -119
- package/dist/views/preview.d.ts +0 -3
- package/dist/views/preview.js +0 -53
- package/dist/yangchun-comment.css +0 -1
- package/dist/yangchun-comment.es.js +0 -317
- package/dist/yangchun-comment.es.js.map +0 -1
- package/dist/yangchun-comment.umd.js +0 -317
- package/dist/yangchun-comment.umd.js.map +0 -1
- /package/dist/{types.js → src/utils/pow.worker.d.ts} +0 -0
- /package/dist/{utils → src/utils}/wordBank.d.ts +0 -0
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).YangchunComment={})}(this,function(e){"use strict";var t,n={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function i(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function o(e){return(e+"").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function r(e,t){var a,s,l,c,m,d=/((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,p=[],u="",h=t||{},g=0;function f(e){var t=n[e[1]||""],i=p[p.length-1]==e;return t?t[1]?(i?p.pop():p.push(e),t[0|i]):t[0]:e}function y(){for(var e="";p.length;)e+=f(p[p.length-1]);return e}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(e,t,n){return h[t.toLowerCase()]=n,""}).replace(/^\n+|\n+$/g,"");l=d.exec(e);)s=e.substring(g,l.index),g=d.lastIndex,a=l[0],s.match(/[^\\](\\\\)*\\$/)||((m=l[3]||l[4])?a='<pre class="code '+(l[4]?"poetry":l[2].toLowerCase())+'"><code'+(l[2]?' class="language-'+l[2].toLowerCase()+'"':"")+">"+i(o(m).replace(/^\n+|\n+$/g,""))+"</code></pre>":(m=l[6])?(m.match(/\./)&&(l[5]=l[5].replace(/^\d+/gm,"")),c=r(i(l[5].replace(/^\s*[>*+.-]/gm,""))),">"==m?m="blockquote":(m=m.match(/\./)?"ol":"ul",c=c.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),a="<"+m+">"+c+"</"+m+">"):l[8]?a='<img src="'+o(l[8])+'" alt="'+o(l[7])+'">':l[10]?(u=u.replace("<a>",'<a href="'+o(l[11]||h[s.toLowerCase()])+'">'),a=y()+"</a>"):l[9]?a="<a>":l[12]||l[14]?a="<"+(m="h"+(l[14]?l[14].length:l[13]>"="?1:2))+">"+r(l[12]||l[15],h)+"</"+m+">":l[16]?a="<code>"+o(l[16])+"</code>":(l[17]||l[1])&&(a=f(l[17]||"--"))),u+=s,u+=a;return(u+e.substring(g)+y()).replace(/^\n+|\n+$/g,"")}
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright 2019 Google LLC
|
|
5
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/const a=globalThis,s=a.ShadowRoot&&(void 0===a.ShadyCSS||a.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,l=Symbol(),c=new WeakMap;let m=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==l)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(s&&void 0===e){const n=void 0!==t&&1===t.length;n&&(e=c.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&c.set(t,e))}return e}toString(){return this.cssText}};const d=s?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return(e=>new m("string"==typeof e?e:e+"",void 0,l))(t)})(e):e,{is:p,defineProperty:u,getOwnPropertyDescriptor:h,getOwnPropertyNames:g,getOwnPropertySymbols:f,getPrototypeOf:y}=Object,v=globalThis,b=v.trustedTypes,w=b?b.emptyScript:"",A=v.reactiveElementPolyfillSupport,_=(e,t)=>e,S={toAttribute(e,t){switch(t){case Boolean:e=e?w:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(i){n=null}}return n}},T=(e,t)=>!p(e,t),$={attribute:!0,type:String,converter:S,reflect:!1,useDefault:!1,hasChanged:T};
|
|
7
|
-
/**
|
|
8
|
-
* @license
|
|
9
|
-
* Copyright 2017 Google LLC
|
|
10
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/Symbol.metadata??=Symbol("metadata"),v.litPropertyMetadata??=new WeakMap;let E=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=$){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const n=Symbol(),i=this.getPropertyDescriptor(e,n,t);void 0!==i&&u(this.prototype,e,i)}}static getPropertyDescriptor(e,t,n){const{get:i,set:o}=h(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:i,set(t){const r=i?.call(this);o?.call(this,t),this.requestUpdate(e,r,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??$}static _$Ei(){if(this.hasOwnProperty(_("elementProperties")))return;const e=y(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(_("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(_("properties"))){const e=this.properties,t=[...g(e),...f(e)];for(const n of t)this.createProperty(n,e[n])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(const[t,n]of this.elementProperties){const e=this._$Eu(t,n);void 0!==e&&this._$Eh.set(e,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const e of n)t.unshift(d(e))}else void 0!==e&&t.push(d(e));return t}static _$Eu(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{if(s)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const n of t){const t=document.createElement("style"),i=a.litNonce;void 0!==i&&t.setAttribute("nonce",i),t.textContent=n.cssText,e.appendChild(t)}})(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){const n=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,n);if(void 0!==i&&!0===n.reflect){const o=(void 0!==n.converter?.toAttribute?n.converter:S).toAttribute(t,n.type);this._$Em=e,null==o?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(e,t){const n=this.constructor,i=n._$Eh.get(e);if(void 0!==i&&this._$Em!==i){const e=n.getPropertyOptions(i),o="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:S;this._$Em=i;const r=o.fromAttribute(t,e.type);this[i]=r??this._$Ej?.get(i)??r,this._$Em=null}}requestUpdate(e,t,n){if(void 0!==e){const i=this.constructor,o=this[e];if(n??=i.getPropertyOptions(e),!((n.hasChanged??T)(o,t)||n.useDefault&&n.reflect&&o===this._$Ej?.get(e)&&!this.hasAttribute(i._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:i,wrapped:o},r){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,r??t??this[e]),!0!==o||void 0!==r)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===i&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,n]of e){const{wrapped:e}=n,i=this[t];!0!==e||this._$AL.has(t)||void 0===i||this.C(t,void 0,n,i)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(n){throw e=!1,this._$EM(),n}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};E.elementStyles=[],E.shadowRootOptions={mode:"open"},E[_("elementProperties")]=new Map,E[_("finalized")]=new Map,A?.({ReactiveElement:E}),(v.reactiveElementVersions??=[]).push("2.1.1");
|
|
12
|
-
/**
|
|
13
|
-
* @license
|
|
14
|
-
* Copyright 2017 Google LLC
|
|
15
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
-
*/
|
|
17
|
-
const C=globalThis,k=C.trustedTypes,M=k?k.createPolicy("lit-html",{createHTML:e=>e}):void 0,N="$lit$",x=`lit$${Math.random().toFixed(9).slice(2)}$`,L="?"+x,P=`<${L}>`,R=document,D=()=>R.createComment(""),O=e=>null===e||"object"!=typeof e&&"function"!=typeof e,H=Array.isArray,I="[ \t\n\f\r]",U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,B=/-->/g,F=/>/g,z=RegExp(`>|${I}(?:([^\\s"'>=/]+)(${I}*=${I}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),G=/'/g,W=/"/g,j=/^(?:script|style|textarea|title)$/i,q=(J=1,(e,...t)=>({_$litType$:J,strings:e,values:t})),Y=Symbol.for("lit-noChange"),X=Symbol.for("lit-nothing"),V=new WeakMap,K=R.createTreeWalker(R,129);var J;function Z(e,t){if(!H(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==M?M.createHTML(t):t}class Q{constructor({strings:e,_$litType$:t},n){let i;this.parts=[];let o=0,r=0;const a=e.length-1,s=this.parts,[l,c]=((e,t)=>{const n=e.length-1,i=[];let o,r=2===t?"<svg>":3===t?"<math>":"",a=U;for(let s=0;s<n;s++){const t=e[s];let n,l,c=-1,m=0;for(;m<t.length&&(a.lastIndex=m,l=a.exec(t),null!==l);)m=a.lastIndex,a===U?"!--"===l[1]?a=B:void 0!==l[1]?a=F:void 0!==l[2]?(j.test(l[2])&&(o=RegExp("</"+l[2],"g")),a=z):void 0!==l[3]&&(a=z):a===z?">"===l[0]?(a=o??U,c=-1):void 0===l[1]?c=-2:(c=a.lastIndex-l[2].length,n=l[1],a=void 0===l[3]?z:'"'===l[3]?W:G):a===W||a===G?a=z:a===B||a===F?a=U:(a=z,o=void 0);const d=a===z&&e[s+1].startsWith("/>")?" ":"";r+=a===U?t+P:c>=0?(i.push(n),t.slice(0,c)+N+t.slice(c)+x+d):t+x+(-2===c?s:d)}return[Z(e,r+(e[n]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),i]})(e,t);if(this.el=Q.createElement(l,n),K.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(i=K.nextNode())&&s.length<a;){if(1===i.nodeType){if(i.hasAttributes())for(const e of i.getAttributeNames())if(e.endsWith(N)){const t=c[r++],n=i.getAttribute(e).split(x),a=/([.?@])?(.*)/.exec(t);s.push({type:1,index:o,name:a[2],strings:n,ctor:"."===a[1]?oe:"?"===a[1]?re:"@"===a[1]?ae:ie}),i.removeAttribute(e)}else e.startsWith(x)&&(s.push({type:6,index:o}),i.removeAttribute(e));if(j.test(i.tagName)){const e=i.textContent.split(x),t=e.length-1;if(t>0){i.textContent=k?k.emptyScript:"";for(let n=0;n<t;n++)i.append(e[n],D()),K.nextNode(),s.push({type:2,index:++o});i.append(e[t],D())}}}else if(8===i.nodeType)if(i.data===L)s.push({type:2,index:o});else{let e=-1;for(;-1!==(e=i.data.indexOf(x,e+1));)s.push({type:7,index:o}),e+=x.length-1}o++}}static createElement(e,t){const n=R.createElement("template");return n.innerHTML=e,n}}function ee(e,t,n=e,i){if(t===Y)return t;let o=void 0!==i?n._$Co?.[i]:n._$Cl;const r=O(t)?void 0:t._$litDirective$;return o?.constructor!==r&&(o?._$AO?.(!1),void 0===r?o=void 0:(o=new r(e),o._$AT(e,n,i)),void 0!==i?(n._$Co??=[])[i]=o:n._$Cl=o),void 0!==o&&(t=ee(e,o._$AS(e,t.values),o,i)),t}class te{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:n}=this._$AD,i=(e?.creationScope??R).importNode(t,!0);K.currentNode=i;let o=K.nextNode(),r=0,a=0,s=n[0];for(;void 0!==s;){if(r===s.index){let t;2===s.type?t=new ne(o,o.nextSibling,this,e):1===s.type?t=new s.ctor(o,s.name,s.strings,this,e):6===s.type&&(t=new se(o,this,e)),this._$AV.push(t),s=n[++a]}r!==s?.index&&(o=K.nextNode(),r++)}return K.currentNode=R,i}p(e){let t=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class ne{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,i){this.type=2,this._$AH=X,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ee(this,e,t),O(e)?e===X||null==e||""===e?(this._$AH!==X&&this._$AR(),this._$AH=X):e!==this._$AH&&e!==Y&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>H(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==X&&O(this._$AH)?this._$AA.nextSibling.data=e:this.T(R.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:n}=e,i="number"==typeof n?this._$AC(e):(void 0===n.el&&(n.el=Q.createElement(Z(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===i)this._$AH.p(t);else{const e=new te(i,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=V.get(e.strings);return void 0===t&&V.set(e.strings,t=new Q(e)),t}k(e){H(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,i=0;for(const o of e)i===t.length?t.push(n=new ne(this.O(D()),this.O(D()),this,this.options)):n=t[i],n._$AI(o),i++;i<t.length&&(this._$AR(n&&n._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class ie{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,i,o){this.type=1,this._$AH=X,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=o,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=X}_$AI(e,t=this,n,i){const o=this.strings;let r=!1;if(void 0===o)e=ee(this,e,t,0),r=!O(e)||e!==this._$AH&&e!==Y,r&&(this._$AH=e);else{const i=e;let a,s;for(e=o[0],a=0;a<o.length-1;a++)s=ee(this,i[n+a],t,a),s===Y&&(s=this._$AH[a]),r||=!O(s)||s!==this._$AH[a],s===X?e=X:e!==X&&(e+=(s??"")+o[a+1]),this._$AH[a]=s}r&&!i&&this.j(e)}j(e){e===X?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class oe extends ie{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===X?void 0:e}}class re extends ie{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==X)}}class ae extends ie{constructor(e,t,n,i,o){super(e,t,n,i,o),this.type=5}_$AI(e,t=this){if((e=ee(this,e,t,0)??X)===Y)return;const n=this._$AH,i=e===X&&n!==X||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,o=e!==X&&(n===X||i);i&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class se{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){ee(this,e)}}const le=C.litHtmlPolyfillSupport;le?.(Q,ne),(C.litHtmlVersions??=[]).push("3.3.1");const ce=globalThis;
|
|
18
|
-
/**
|
|
19
|
-
* @license
|
|
20
|
-
* Copyright 2017 Google LLC
|
|
21
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
-
*/let me=class extends E{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,n)=>{const i=n?.renderBefore??t;let o=i._$litPart$;if(void 0===o){const e=n?.renderBefore??null;i._$litPart$=o=new ne(t.insertBefore(D(),e),e,void 0,n??{})}return o._$AI(e),o})(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}};me._$litElement$=!0,me.finalized=!0,ce.litElementHydrateSupport?.({LitElement:me});const de=ce.litElementPolyfillSupport;de?.({LitElement:me}),(ce.litElementVersions??=[]).push("4.2.1");
|
|
23
|
-
/**
|
|
24
|
-
* @license
|
|
25
|
-
* Copyright 2017 Google LLC
|
|
26
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
-
*/
|
|
28
|
-
const pe={attribute:!0,type:String,converter:S,reflect:!1,hasChanged:T},ue=(e=pe,t,n)=>{const{kind:i,metadata:o}=n;let r=globalThis.litPropertyMetadata.get(o);if(void 0===r&&globalThis.litPropertyMetadata.set(o,r=new Map),"setter"===i&&((e=Object.create(e)).wrapped=!0),r.set(n.name,e),"accessor"===i){const{name:i}=n;return{set(n){const o=t.get.call(this);t.set.call(this,n),this.requestUpdate(i,o,e)},init(t){return void 0!==t&&this.C(i,void 0,e,t),t}}}if("setter"===i){const{name:i}=n;return function(n){const o=this[i];t.call(this,n),this.requestUpdate(i,o,e)}}throw Error("Unsupported decorator location: "+i)};function he(e){return(t,n)=>"object"==typeof n?ue(e,t,n):((e,t,n)=>{const i=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),i?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}
|
|
29
|
-
/**
|
|
30
|
-
* @license
|
|
31
|
-
* Copyright 2017 Google LLC
|
|
32
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
-
*/function ge(e){return he({...e,state:!0,attribute:!1})}
|
|
34
|
-
/**
|
|
35
|
-
* @license
|
|
36
|
-
* Copyright 2017 Google LLC
|
|
37
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
|
-
*/const fe=2;class ye{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}
|
|
39
|
-
/**
|
|
40
|
-
* @license
|
|
41
|
-
* Copyright 2017 Google LLC
|
|
42
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
43
|
-
*/class ve extends ye{constructor(e){if(super(e),this.it=X,e.type!==fe)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===X||null==e)return this._t=void 0,this.it=e;if(e===Y)return e;if("string"!=typeof e)throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}ve.directiveName="unsafeHTML",ve.resultType=1;const be=(e=>(...t)=>({_$litDirective$:e,values:t}))(ve),we=e=>{const t=new Map,n=(e,n,i)=>{t.set(e,{timestamp:n,token:i});const o=btoa(JSON.stringify({timestamp:n}));sessionStorage.setItem(`comment_auth_${e}`,o)},i=e=>{const n=t.get(e);return n?{id:e,...n}:null},o=e=>{t.delete(e),sessionStorage.removeItem(`comment_auth_${e}`)};return{getComments:async t=>{const n=new URL("/api/comments",e);n.searchParams.append("post",t);const i=await fetch(n);return await i.json()},addComment:async(t,i,o,r,a)=>{try{const s=new URL("/api/comments",e);s.searchParams.append("post",t);const l=document.querySelector('input[name="website"]'),c=l?l.value:"",m=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pseudonym:i,nameHash:o,msg:r,replyTo:a,website:c})});if(m.ok){const e=await m.json();return n(e.id,e.timestamp,e.token),e.id}return null}catch{return null}},updateComment:async(t,n,o,r,a)=>{const s=i(n);if(!s)return!1;try{const n=new URL("/api/comments",e);n.searchParams.append("post",t);return(await fetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:s.id,timestamp:s.timestamp,token:s.token,pseudonym:o,nameHash:r,msg:a})})).ok}catch{return!1}},deleteComment:async(t,n)=>{const r=i(n);if(!r)return!1;try{const i=new URL("/api/comments",e);i.searchParams.append("post",t);return!!(await fetch(i,{method:"DELETE",headers:{"Content-Type":"application/json","X-Comment-ID":r.id,"X-Comment-Token":r.token,"X-Comment-Timestamp":r.timestamp.toString()}})).ok&&(o(n),!0)}catch{return!1}},saveAuthInfo:n,getAuthInfo:i,removeAuthInfo:o,canEditComment:e=>!!i(e)}},Ae={anonymous:"Anonymous",replyTo:"Reply to",edit:"Edit",delete:"Delete",reply:"Reply",replyingTo:"Replying to: ",modified:"Modified on",cancelReply:"Cancel",editing:"Editing: ",cancelEdit:"Cancel",updateComment:"Update",submitComment:"Submit",namePlaceholder:"Name (optional)",messagePlaceholder:"Your comment...\nSupports Markdown syntax",loading:"Loading...",confirmDelete:"Are you sure you want to delete this comment?",editFailed:"Failed to edit comment. Permission may have expired.",submitFailed:"Failed to submit comment.",deleteFailed:"Failed to delete comment. Permission may have expired.",nameTooLong:"Name is too long",messageTooLong:"Message is too long",write:"Write",preview:"Preview",emptyPreview:"Nothing to preview",markdownHelp:"Help",commentSystemTitle:"Comments",commentSystemDesc:'This is a simple comment system. You can post your opinions or respond to other comments. Click "Preview" to see how your comment looks before posting.',commentTimeLimit:"After posting a comment, you can edit or delete it within two minutes, as long as you don't leave or refresh the page.",markdownSyntax:"Syntax",markdownBasicSupport:"Basic Markdown syntax is supported. HTML is not supported.",markdownLinkExample:"[Link](https://www.example.com)",markdownImageExample:"",markdownItalicExample:"*Italic* or _Italic_",markdownBoldExample:"**Bold** or __Bold__",markdownListExample:"- List item",markdownOrderedListExample:"1. Ordered list item",markdownInlineCodeExample:"`Inline code`",markdownCodeBlockExample:"```\nCode block\n```",pseudonymNotice:"Will be converted to a unique pseudonym, longer names help avoid impersonation",editingPseudonymNotice:"Cannot be changed when editing",author:"Author",noComments:"No comments yet"},_e={anonymous:"匿名",replyTo:"回覆給",edit:"編輯",delete:"刪除",reply:"回覆",modified:"修改於",replyingTo:"回覆給:",cancelReply:"取消",editing:"編輯中:",cancelEdit:"取消",updateComment:"更新",submitComment:"發送",namePlaceholder:"名稱 (選填)",messagePlaceholder:"留言內容...\n支援 Markdown 語法",loading:"載入中...",confirmDelete:"確定要刪除此留言嗎?",editFailed:"編輯留言失敗,可能權限已過期",submitFailed:"發送留言失敗",deleteFailed:"刪除留言失敗,可能權限已過期",nameTooLong:"暱稱過長",messageTooLong:"留言內容過長",write:"編輯",preview:"預覽",emptyPreview:"沒有內容可供預覽",markdownHelp:"說明",commentSystemTitle:"留言",commentSystemDesc:"這是一個簡單的留言系統,你可以發表意見或回應其他留言。發佈前可點擊「預覽」查看留言樣式。",commentTimeLimit:"發佈留言後,在不離開或重新整理頁面的情況下,你可以編輯或刪除兩分鐘內的留言。",markdownSyntax:"語法",markdownBasicSupport:"支援基本 Markdown 語法,不支援 HTML。",markdownLinkExample:"[連結](https://www.example.com)",markdownImageExample:"",markdownItalicExample:"*斜體* 或 _斜體_",markdownBoldExample:"**粗體** 或 __粗體__",markdownListExample:"- 清單",markdownOrderedListExample:"1. 編號清單",markdownInlineCodeExample:"`行內程式碼`",markdownCodeBlockExample:"```\n程式碼區塊\n```",pseudonymNotice:"名稱將被轉換為化名,使用較長的名稱有助於避免被冒充",editingPseudonymNotice:"編輯時無法更改",author:"作者",noComments:"尚未有留言"},Se=(e=Ae)=>{let t=e;return{t:e=>t[e],setLanguage:e=>{t=e},getLanguage:()=>t}},Te=["Brilliant","Elegant","Majestic","Serene","Vibrant","Graceful","Radiant","Mystical","Noble","Charming","Delicate","Gentle","Luminous","Peaceful","Quick","Resilient","Sparkling","Tranquil","Vivid","Wise","Brave","Creative","Dynamic","Enigmatic","Fantastic","Golden","Harmonious","Inspiring","Joyful","Keen","Lively","Magnificent","Natural","Optimistic","Precious","Quiet","Remarkable","Stunning","Thoughtful","Uplifting","Wonderful","Adventurous","Balanced","Confident","Determined","Energetic","Fearless","Gracious","Innovative","Jubilant","Kind","Loyal","Marvelous","Amazing","Bright","Cheerful","Curious","Excited","Fresh","Happy","Intelligent","Jovial","Lovely","Merry","Nimble","Pleasant","Resourceful","Spirited","Talented","Versatile","Warm","Youthful","Active","Agile","Alert","Artistic","Athletic","Authentic","Blissful","Buoyant","Calm","Capable","Caring","Clever","Compassionate","Cool","Courageous","Dazzling","Dedicated","Diligent","Earnest","Efficient","Enthusiastic","Exceptional","Expressive","Fabulous","Faithful","Focused","Friendly","Generous","Gifted","Glorious","Helpful","Honest","Hopeful","Humorous","Independent","Inventive","Lighthearted","Lucky","Mindful","Modest","Motivating","Nurturing","Original","Outgoing","Patient","Playful","Polite","Positive","Proud","Pure","Reliable","Responsible","Sincere","Smart","Smooth","Sociable","Spontaneous","Successful","Sweet","Tender","Trusting","Understanding","Unique","Valuable","Virtuous","Wholesome","Witty"],$e=["Falcon","Phoenix","Dragon","Eagle","Tiger","Lion","Wolf","Bear","Deer","Fox","Hawk","Raven","Swan","Dove","Owl","Butterfly","Rose","Lily","Orchid","Jasmine","Cedar","Oak","Pine","Willow","Maple","Mountain","River","Ocean","Moon","Sun","Cloud","Thunder","Rainbow","Diamond","Ruby","Emerald","Sapphire","Pearl","Crystal","Gold","Silver","Amber","Flame","Breeze","Storm","Mist","Dawn","Dusk","Aurora","Comet","Galaxy","Nebula","Shield","Crown","Gem","Prism","Panda","Koala","Giraffe","Zebra","Leopard","Cheetah","Otter","Dolphin","Whale","Penguin","Rabbit","Squirrel","Hedgehog","Badger","Moose","Camel","Horse","Donkey","Sheep","Goat","Cow","Chicken","Duck","Goose","Turkey","Peacock","Parrot","Canary","Finch","Sparrow","Crane","Stork","Flamingo","Pelican","Shrimp","Crab","Lobster","Octopus","Squid","Walrus","Mole","Ferret","Hamster","Chinchilla","GuineaPig","Lemur","Tapir","Buffalo","Bison","Yak","Ibex","Gazelle","Porcupine","Armadillo","Sloth","Opossum","Platypus","Wombat","Kangaroo","Wallaby","Emu","Cassowary","Orangutan","Gibbon","Chimpanzee","Baboon","Macaque","Lynx","Puma","Jaguar","Cougar","Bobcat","Ocelot","RedPanda","Raccoon","Weasel","Stoat","Ermine","Wolverine","Marten","Jay","Magpie","Rook","Swallow","Swift","Cuckoo","Coot","Grebe","Heron","Egret","Ibis","Gull","Tern","Salmon","Trout","Bass","Cod","Tuna","Ray","Carp","Perch","Catfish","Eel","Pike","Snapper","Bream","Tilapia","Goby","Mullet","Loach","Bamboo","Cactus","Fern","Moss","Palm","Birch","Aspen","Beech","Hazel","Elm","Poplar","Magnolia","Azalea","Gardenia","Hibiscus","Wisteria","Dahlia","Peony","Marigold","Sunflower","Daisy","Violet","Pansy","Begonia","Petunia","Zinnia","Cosmos","Aster","Bluebell","Foxglove","Primrose","Buttercup","Clover","Heather","Lavender","Basil","Rosemary","Thyme","Sage","Parsley","Dill","Fennel","Chive","Oregano","Lotus","Taro","Mushroom","Truffle","Morel","Shiitake","Moth","Dragonfly","Bee","Ant","Termite","Beetle","Ladybug","Firefly","Cicada","Grasshopper","Cricket","Katydid","Locust","Mantis","Earwig","Silverfish","Mayfly","Stonefly","Aphid","Whitefly","Apple","Banana","Orange","Lemon","Lime","Grape","Cherry","Peach","Plum","Pear","Mango","Papaya","Pineapple","Guava","Lychee","Longan","Rambutan","Coconut","Date","Fig","Gooseberry","Blackberry","Blueberry","Raspberry","Strawberry","Cranberry","Currant","Melon","Pumpkin","Squash","Zucchini","Bread","Bagel","Baguette","Croissant","Pretzel","Bun","Roll","Muffin","Cake","Pie","Tart","Cookie","Biscuit","Doughnut","Pancake","Waffle","Crepe","Sandwich","Burger","Pizza","Pasta","Spaghetti","Macaroni","Lasagna","Ravioli","Noodle","Ramen","Udon","Soba","Pho","Dumpling","Wonton","Bao","Sushi","Tempura","Rice","Soup","Stew","Curry","Grill","Roast","Fry","Steam","Boil","Jam","Honey","Butter","Cheese","Cream","Custard","Pudding","IceCream","Sorbet","Milk","Juice","Tea","Coffee","Cocoa","Candy","Mint","Gum","Book","Pen","Pencil","Eraser","Ruler","Scissors","Glue","Paper","Notebook","Bag","Wallet","Key","Lock","Watch","Lamp","Mirror","Brush","Comb","Towel","Soap","Cup","Mug","Bottle","Glass","Plate","Bowl","Spoon","Fork","Tray","Box","Can","Jar","Bin","Pan","Pot","Kettle","Oven","Fan","Phone","Tablet","Laptop","Keyboard","Camera","Radio","TV","Charger","Cable","Plug","Adapter","Battery","Umbrella","Hat","Cap","Scarf","Glove","Sock","Shoe","Boot","Belt","Coat","Jacket","Shirt","Pants","Shorts","Skirt","Dress","Suit","Tie","Mask","Apron","Blanket","Pillow","Chair","Table","Desk","Shelf","Drawer","Cabinet","Door","Window","Wall","Floor","Roof","Stair","Road","Park","Garden","Fence","Gate","Mailbox","Sign","Poster","Flag","Balloon","Kite","Toy","Puzzle","Game","Dice","Card","Coin","Medal","Trophy","Badge","Sticker","Patch","Pin","Ring","Necklace","Bracelet","Earring","Charm","Pendant","Chain","Clip","Hook","Button","Zip","String","Rope","Wire","Band","Tape","Ribbon","Thread","Needle","Thimble","Wrench","Pliers","Level","Map","Globe","Chart","Graph","List","Note","Memo","Label","Tag","Ticket","Pass","Receipt","Bill","Form","Report","File","Folder","Envelope","Stamp","Seal","Circle","Oval","Square","Star","Heart","Arrow","Dot","Line","Wave","Curve","Point","Edge","Corner","Block","Brick","Tile","Panel","Board","Beam","Pole","Rod","Bar","Tube","Pipe","Valve","Tap","Pump","Motor","Gear","Wheel","Axle","Spring","Lever","Handle","Knob","Switch","Dial","Latch","Bolt","Hinge","Frame","Base","Stand","Holder","Mount","Elastic","Rubber","Plastic","Metal","Wood","Stone","Clay","Sand","Soil","Mud","Dust","Salt","Sugar","Oil","Vinegar","Sauce","Paste","Syrup","Fudge","Toffee","Marshmallow","Nougat","Lollipop","Popsicle","Slush","Jellybean"];async function Ee(e){const t=(e||"").trim();if(0===t.length)return{pseudonym:"",hash:""};const n=await async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")}(t),{adjective:i,noun:o}=function(e){const t=parseInt(e.substring(0,8),16)%Te.length,n=parseInt(e.substring(8,16),16)%$e.length;return{adjective:Te[t],noun:$e[n]}}(n);return{pseudonym:`${i} ${o}`,hash:n}}
|
|
44
|
-
/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:Ce,setPrototypeOf:ke,isFrozen:Me,getPrototypeOf:Ne,getOwnPropertyDescriptor:xe}=Object;let{freeze:Le,seal:Pe,create:Re}=Object,{apply:De,construct:Oe}="undefined"!=typeof Reflect&&Reflect;Le||(Le=function(e){return e}),Pe||(Pe=function(e){return e}),De||(De=function(e,t,n){return e.apply(t,n)}),Oe||(Oe=function(e,t){return new e(...t)});const He=Ze(Array.prototype.forEach),Ie=Ze(Array.prototype.lastIndexOf),Ue=Ze(Array.prototype.pop),Be=Ze(Array.prototype.push),Fe=Ze(Array.prototype.splice),ze=Ze(String.prototype.toLowerCase),Ge=Ze(String.prototype.toString),We=Ze(String.prototype.match),je=Ze(String.prototype.replace),qe=Ze(String.prototype.indexOf),Ye=Ze(String.prototype.trim),Xe=Ze(Object.prototype.hasOwnProperty),Ve=Ze(RegExp.prototype.test),Ke=(Je=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Oe(Je,t)});var Je;function Ze(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return De(e,t,i)}}function Qe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ze;ke&&ke(e,null);let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&(Me(t)||(t[i]=e),o=e)}e[o]=!0}return e}function et(e){for(let t=0;t<e.length;t++){Xe(e,t)||(e[t]=null)}return e}function tt(e){const t=Re(null);for(const[n,i]of Ce(e)){Xe(e,n)&&(Array.isArray(i)?t[n]=et(i):i&&"object"==typeof i&&i.constructor===Object?t[n]=tt(i):t[n]=i)}return t}function nt(e,t){for(;null!==e;){const n=xe(e,t);if(n){if(n.get)return Ze(n.get);if("function"==typeof n.value)return Ze(n.value)}e=Ne(e)}return function(){return null}}const it=Le(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ot=Le(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),rt=Le(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),at=Le(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),st=Le(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),lt=Le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ct=Le(["#text"]),mt=Le(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),dt=Le(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),pt=Le(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),ut=Le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ht=Pe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),gt=Pe(/<%[\w\W]*|[\w\W]*%>/gm),ft=Pe(/\$\{[\w\W]*/gm),yt=Pe(/^data-[\-\w.\u00B7-\uFFFF]+$/),vt=Pe(/^aria-[\-\w]+$/),bt=Pe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),wt=Pe(/^(?:\w+script|data):/i),At=Pe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),_t=Pe(/^html$/i),St=Pe(/^[a-z][.\w]*(-[.\w]+)+$/i);var Tt=Object.freeze({__proto__:null,ARIA_ATTR:vt,ATTR_WHITESPACE:At,CUSTOM_ELEMENT:St,DATA_ATTR:yt,DOCTYPE_NAME:_t,ERB_EXPR:gt,IS_ALLOWED_URI:bt,IS_SCRIPT_OR_DATA:wt,MUSTACHE_EXPR:ht,TMPLIT_EXPR:ft});const $t=1,Et=3,Ct=7,kt=8,Mt=9;var Nt=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window;const n=t=>e(t);if(n.version="3.2.6",n.removed=[],!t||!t.document||t.document.nodeType!==Mt||!t.Element)return n.isSupported=!1,n;let{document:i}=t;const o=i,r=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:s,Node:l,Element:c,NodeFilter:m,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:u,trustedTypes:h}=t,g=c.prototype,f=nt(g,"cloneNode"),y=nt(g,"remove"),v=nt(g,"nextSibling"),b=nt(g,"childNodes"),w=nt(g,"parentNode");if("function"==typeof s){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let A,_="";const{implementation:S,createNodeIterator:T,createDocumentFragment:$,getElementsByTagName:E}=i,{importNode:C}=o;let k={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof Ce&&"function"==typeof w&&S&&void 0!==S.createHTMLDocument;const{MUSTACHE_EXPR:M,ERB_EXPR:N,TMPLIT_EXPR:x,DATA_ATTR:L,ARIA_ATTR:P,IS_SCRIPT_OR_DATA:R,ATTR_WHITESPACE:D,CUSTOM_ELEMENT:O}=Tt;let{IS_ALLOWED_URI:H}=Tt,I=null;const U=Qe({},[...it,...ot,...rt,...st,...ct]);let B=null;const F=Qe({},[...mt,...dt,...pt,...ut]);let z=Object.seal(Re(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),G=null,W=null,j=!0,q=!0,Y=!1,X=!0,V=!1,K=!0,J=!1,Z=!1,Q=!1,ee=!1,te=!1,ne=!1,ie=!0,oe=!1,re=!0,ae=!1,se={},le=null;const ce=Qe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let me=null;const de=Qe({},["audio","video","img","source","image","track"]);let pe=null;const ue=Qe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),he="http://www.w3.org/1998/Math/MathML",ge="http://www.w3.org/2000/svg",fe="http://www.w3.org/1999/xhtml";let ye=fe,ve=!1,be=null;const we=Qe({},[he,ge,fe],Ge);let Ae=Qe({},["mi","mo","mn","ms","mtext"]),_e=Qe({},["annotation-xml"]);const Se=Qe({},["title","style","font","a","script"]);let Te=null;const $e=["application/xhtml+xml","text/html"];let Ee=null,ke=null;const Me=i.createElement("form"),Ne=function(e){return e instanceof RegExp||e instanceof Function},xe=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ke||ke!==e){if(e&&"object"==typeof e||(e={}),e=tt(e),Te=-1===$e.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Ee="application/xhtml+xml"===Te?Ge:ze,I=Xe(e,"ALLOWED_TAGS")?Qe({},e.ALLOWED_TAGS,Ee):U,B=Xe(e,"ALLOWED_ATTR")?Qe({},e.ALLOWED_ATTR,Ee):F,be=Xe(e,"ALLOWED_NAMESPACES")?Qe({},e.ALLOWED_NAMESPACES,Ge):we,pe=Xe(e,"ADD_URI_SAFE_ATTR")?Qe(tt(ue),e.ADD_URI_SAFE_ATTR,Ee):ue,me=Xe(e,"ADD_DATA_URI_TAGS")?Qe(tt(de),e.ADD_DATA_URI_TAGS,Ee):de,le=Xe(e,"FORBID_CONTENTS")?Qe({},e.FORBID_CONTENTS,Ee):ce,G=Xe(e,"FORBID_TAGS")?Qe({},e.FORBID_TAGS,Ee):tt({}),W=Xe(e,"FORBID_ATTR")?Qe({},e.FORBID_ATTR,Ee):tt({}),se=!!Xe(e,"USE_PROFILES")&&e.USE_PROFILES,j=!1!==e.ALLOW_ARIA_ATTR,q=!1!==e.ALLOW_DATA_ATTR,Y=e.ALLOW_UNKNOWN_PROTOCOLS||!1,X=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,V=e.SAFE_FOR_TEMPLATES||!1,K=!1!==e.SAFE_FOR_XML,J=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,ne=e.RETURN_TRUSTED_TYPE||!1,Q=e.FORCE_BODY||!1,ie=!1!==e.SANITIZE_DOM,oe=e.SANITIZE_NAMED_PROPS||!1,re=!1!==e.KEEP_CONTENT,ae=e.IN_PLACE||!1,H=e.ALLOWED_URI_REGEXP||bt,ye=e.NAMESPACE||fe,Ae=e.MATHML_TEXT_INTEGRATION_POINTS||Ae,_e=e.HTML_INTEGRATION_POINTS||_e,z=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Ne(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(z.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Ne(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(z.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(z.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),V&&(q=!1),te&&(ee=!0),se&&(I=Qe({},ct),B=[],!0===se.html&&(Qe(I,it),Qe(B,mt)),!0===se.svg&&(Qe(I,ot),Qe(B,dt),Qe(B,ut)),!0===se.svgFilters&&(Qe(I,rt),Qe(B,dt),Qe(B,ut)),!0===se.mathMl&&(Qe(I,st),Qe(B,pt),Qe(B,ut))),e.ADD_TAGS&&(I===U&&(I=tt(I)),Qe(I,e.ADD_TAGS,Ee)),e.ADD_ATTR&&(B===F&&(B=tt(B)),Qe(B,e.ADD_ATTR,Ee)),e.ADD_URI_SAFE_ATTR&&Qe(pe,e.ADD_URI_SAFE_ATTR,Ee),e.FORBID_CONTENTS&&(le===ce&&(le=tt(le)),Qe(le,e.FORBID_CONTENTS,Ee)),re&&(I["#text"]=!0),J&&Qe(I,["html","head","body"]),I.table&&(Qe(I,["tbody"]),delete G.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=e.TRUSTED_TYPES_POLICY,_=A.createHTML("")}else void 0===A&&(A=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:e=>e,createScriptURL:e=>e})}catch(r){return console.warn("TrustedTypes policy "+o+" could not be created."),null}}(h,r)),null!==A&&"string"==typeof _&&(_=A.createHTML(""));Le&&Le(e),ke=e}},Pe=Qe({},[...ot,...rt,...at]),De=Qe({},[...st,...lt]),Oe=function(e){Be(n.removed,{element:e});try{w(e).removeChild(e)}catch(t){y(e)}},Je=function(e,t){try{Be(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(i){Be(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ee||te)try{Oe(t)}catch(i){}else try{t.setAttribute(e,"")}catch(i){}},Ze=function(e){let t=null,n=null;if(Q)e="<remove></remove>"+e;else{const t=We(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Te&&ye===fe&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=A?A.createHTML(e):e;if(ye===fe)try{t=(new u).parseFromString(o,Te)}catch(a){}if(!t||!t.documentElement){t=S.createDocument(ye,"template",null);try{t.documentElement.innerHTML=ve?_:o}catch(a){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(i.createTextNode(n),r.childNodes[0]||null),ye===fe?E.call(t,J?"html":"body")[0]:J?t.documentElement:r},et=function(e){return T.call(e.ownerDocument||e,e,m.SHOW_ELEMENT|m.SHOW_COMMENT|m.SHOW_TEXT|m.SHOW_PROCESSING_INSTRUCTION|m.SHOW_CDATA_SECTION,null)},ht=function(e){return e instanceof p&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof d)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},gt=function(e){return"function"==typeof l&&e instanceof l};function ft(e,t,i){He(e,e=>{e.call(n,t,i,ke)})}const yt=function(e){let t=null;if(ft(k.beforeSanitizeElements,e,null),ht(e))return Oe(e),!0;const i=Ee(e.nodeName);if(ft(k.uponSanitizeElement,e,{tagName:i,allowedTags:I}),K&&e.hasChildNodes()&&!gt(e.firstElementChild)&&Ve(/<[/\w!]/g,e.innerHTML)&&Ve(/<[/\w!]/g,e.textContent))return Oe(e),!0;if(e.nodeType===Ct)return Oe(e),!0;if(K&&e.nodeType===kt&&Ve(/<[/\w]/g,e.data))return Oe(e),!0;if(!I[i]||G[i]){if(!G[i]&&wt(i)){if(z.tagNameCheck instanceof RegExp&&Ve(z.tagNameCheck,i))return!1;if(z.tagNameCheck instanceof Function&&z.tagNameCheck(i))return!1}if(re&&!le[i]){const t=w(e)||e.parentNode,n=b(e)||e.childNodes;if(n&&t){for(let i=n.length-1;i>=0;--i){const o=f(n[i],!0);o.__removalCount=(e.__removalCount||0)+1,t.insertBefore(o,v(e))}}}return Oe(e),!0}return e instanceof c&&!function(e){let t=w(e);t&&t.tagName||(t={namespaceURI:ye,tagName:"template"});const n=ze(e.tagName),i=ze(t.tagName);return!!be[e.namespaceURI]&&(e.namespaceURI===ge?t.namespaceURI===fe?"svg"===n:t.namespaceURI===he?"svg"===n&&("annotation-xml"===i||Ae[i]):Boolean(Pe[n]):e.namespaceURI===he?t.namespaceURI===fe?"math"===n:t.namespaceURI===ge?"math"===n&&_e[i]:Boolean(De[n]):e.namespaceURI===fe?!(t.namespaceURI===ge&&!_e[i])&&!(t.namespaceURI===he&&!Ae[i])&&!De[n]&&(Se[n]||!Pe[n]):!("application/xhtml+xml"!==Te||!be[e.namespaceURI]))}(e)?(Oe(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!Ve(/<\/no(script|embed|frames)/i,e.innerHTML)?(V&&e.nodeType===Et&&(t=e.textContent,He([M,N,x],e=>{t=je(t,e," ")}),e.textContent!==t&&(Be(n.removed,{element:e.cloneNode()}),e.textContent=t)),ft(k.afterSanitizeElements,e,null),!1):(Oe(e),!0)},vt=function(e,t,n){if(ie&&("id"===t||"name"===t)&&(n in i||n in Me))return!1;if(q&&!W[t]&&Ve(L,t));else if(j&&Ve(P,t));else if(!B[t]||W[t]){if(!(wt(e)&&(z.tagNameCheck instanceof RegExp&&Ve(z.tagNameCheck,e)||z.tagNameCheck instanceof Function&&z.tagNameCheck(e))&&(z.attributeNameCheck instanceof RegExp&&Ve(z.attributeNameCheck,t)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(t))||"is"===t&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&Ve(z.tagNameCheck,n)||z.tagNameCheck instanceof Function&&z.tagNameCheck(n))))return!1}else if(pe[t]);else if(Ve(H,je(n,D,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==qe(n,"data:")||!me[e]){if(Y&&!Ve(R,je(n,D,"")));else if(n)return!1}else;return!0},wt=function(e){return"annotation-xml"!==e&&We(e,O)},At=function(e){ft(k.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||ht(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0};let o=t.length;for(;o--;){const a=t[o],{name:s,namespaceURI:l,value:c}=a,m=Ee(s),d=c;let p="value"===s?d:Ye(d);if(i.attrName=m,i.attrValue=p,i.keepAttr=!0,i.forceKeepAttr=void 0,ft(k.uponSanitizeAttribute,e,i),p=i.attrValue,!oe||"id"!==m&&"name"!==m||(Je(s,e),p="user-content-"+p),K&&Ve(/((--!?|])>)|<\/(style|title)/i,p)){Je(s,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){Je(s,e);continue}if(!X&&Ve(/\/>/i,p)){Je(s,e);continue}V&&He([M,N,x],e=>{p=je(p,e," ")});const u=Ee(e.nodeName);if(vt(u,m,p)){if(A&&"object"==typeof h&&"function"==typeof h.getAttributeType)if(l);else switch(h.getAttributeType(u,m)){case"TrustedHTML":p=A.createHTML(p);break;case"TrustedScriptURL":p=A.createScriptURL(p)}if(p!==d)try{l?e.setAttributeNS(l,s,p):e.setAttribute(s,p),ht(e)?Oe(e):Ue(n.removed)}catch(r){Je(s,e)}}else Je(s,e)}ft(k.afterSanitizeAttributes,e,null)},St=function e(t){let n=null;const i=et(t);for(ft(k.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)ft(k.uponSanitizeShadowNode,n,null),yt(n),At(n),n.content instanceof a&&e(n.content);ft(k.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,r=null,s=null,c=null;if(ve=!e,ve&&(e="\x3c!--\x3e"),"string"!=typeof e&&!gt(e)){if("function"!=typeof e.toString)throw Ke("toString is not a function");if("string"!=typeof(e=e.toString()))throw Ke("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Z||xe(t),n.removed=[],"string"==typeof e&&(ae=!1),ae){if(e.nodeName){const t=Ee(e.nodeName);if(!I[t]||G[t])throw Ke("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof l)i=Ze("\x3c!----\x3e"),r=i.ownerDocument.importNode(e,!0),r.nodeType===$t&&"BODY"===r.nodeName||"HTML"===r.nodeName?i=r:i.appendChild(r);else{if(!ee&&!V&&!J&&-1===e.indexOf("<"))return A&&ne?A.createHTML(e):e;if(i=Ze(e),!i)return ee?null:ne?_:""}i&&Q&&Oe(i.firstChild);const m=et(ae?e:i);for(;s=m.nextNode();)yt(s),At(s),s.content instanceof a&&St(s.content);if(ae)return e;if(ee){if(te)for(c=$.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(B.shadowroot||B.shadowrootmode)&&(c=C.call(o,c,!0)),c}let d=J?i.outerHTML:i.innerHTML;return J&&I["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Ve(_t,i.ownerDocument.doctype.name)&&(d="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+d),V&&He([M,N,x],e=>{d=je(d,e," ")}),A&&ne?A.createHTML(d):d},n.setConfig=function(){xe(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Z=!0},n.clearConfig=function(){ke=null,Z=!1},n.isValidAttribute=function(e,t,n){ke||xe({});const i=Ee(e),o=Ee(t);return vt(i,o,n)},n.addHook=function(e,t){"function"==typeof t&&Be(k[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=Ie(k[e],t);return-1===n?void 0:Fe(k[e],n,1)[0]}return Ue(k[e])},n.removeHooks=function(e){k[e]=[]},n.removeAllHooks=function(){k={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();const xt={ALLOWED_TAGS:["a","b","i","em","strong","s","p","ul","ol","li","code","pre","blockquote","h6","hr","br","img"],ALLOWED_ATTR:["href","src","alt"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1};function Lt(e){const t=new Date(e),n=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");let r=t.getHours();const a=String(t.getMinutes()).padStart(2,"0"),s=r>=12?"PM":"AM";r%=12,0===r&&(r=12);return`${n}/${i}/${o} ${String(r).padStart(2,"0")}:${a} ${s}`}function Pt(e,t,n=!1,i=null,o=null,r=null){const a=function(e){const t=e?"comment":"reply";return{item:t,header:`${t}-header ycc-flex ycc-flex-wrap`,name:`${t}-name`,time:`${t}-time`,content:`${t}-content`}}(n),s=e.canEditComment(t.id);return q` <div class="${a.item}" ${n?`data-id="${t.id}"`:""}>
|
|
45
|
-
${function(e,t,n,i,o){const r=e.isMyComment(t),a=t.isAdmin;return q` <div class="${n.header}">
|
|
46
|
-
<span class="${n.name}" title="${t.id}">
|
|
47
|
-
${e.getDisplayName(t)}
|
|
48
|
-
${a?q`<span class="author-badge">${e.i18n$.t("author")}</span>`:r?q`<span class="my-comment-badge">Me</span>`:""}
|
|
49
|
-
</span>
|
|
50
|
-
<span
|
|
51
|
-
class="${n.time}"
|
|
52
|
-
title="${t.modDate?e.formatDate(t.pubDate):void 0}"
|
|
53
|
-
>
|
|
54
|
-
${t.modDate?e.i18n$.t("modified")+" "+e.formatDate(t.modDate):e.formatDate(t.pubDate)}
|
|
55
|
-
</span>
|
|
56
|
-
${i?q`<span class="reply-to"
|
|
57
|
-
>${e.i18n$.t("replyTo")}<span title="${t.replyTo??""}"
|
|
58
|
-
>${i}</span
|
|
59
|
-
></span
|
|
60
|
-
>`:""}
|
|
61
|
-
${o?q`<span class="comment-controls ycc-flex ycc-gap-xs">
|
|
62
|
-
<button
|
|
63
|
-
class="edit-button ycc-clickable ycc-transition ycc-transparent-bg ycc-reset-button"
|
|
64
|
-
@click=${()=>e.handleEdit(t)}
|
|
65
|
-
>
|
|
66
|
-
${e.i18n$.t("edit")}
|
|
67
|
-
</button>
|
|
68
|
-
<button
|
|
69
|
-
class="delete-button ycc-clickable ycc-transition ycc-transparent-bg ycc-reset-button"
|
|
70
|
-
@click=${()=>e.handleDelete(t.id)}
|
|
71
|
-
>
|
|
72
|
-
${e.i18n$.t("delete")}
|
|
73
|
-
</button>
|
|
74
|
-
</span>`:""}
|
|
75
|
-
</div>`}(e,t,a,i,s)}
|
|
76
|
-
${function(e,t,n){return q`<div class="${n}">${e.renderMarkdown(t.msg)}</div>`}(e,t,a.content)} ${function(e,t){return q`<button
|
|
77
|
-
class="reply-button ycc-clickable ycc-transition ycc-transparent-bg ycc-reset-button"
|
|
78
|
-
@click=${()=>e.setReplyTo(t.id)}
|
|
79
|
-
>
|
|
80
|
-
${e.i18n$.t("reply")}
|
|
81
|
-
</button>`}(e,t)}
|
|
82
|
-
${n?q`<div class="replies">
|
|
83
|
-
${o?o.map(t=>{const n=t.replyTo&&r?r[t.replyTo]:void 0,i=n?e.getDisplayName(n):"";return Pt(e,t,!1,i)}):""}
|
|
84
|
-
</div>`:""}
|
|
85
|
-
</div>`}function Rt(e,t,n){const i=t.filter(e=>!e.replyTo),o={};t.forEach(e=>{e.replyTo&&(o[e.replyTo]||=[]).push(e)});return i.map(t=>Pt(e,t,!0,null,(e=>{const t=[],n=[...o[e]||[]];for(;n.length;){const e=n.shift();if(!e)break;t.push(e);const i=o[e.id]||[];i.length&&n.push(...i)}return t})(t.id),n))}var Dt=Object.defineProperty,Ot=(e,t,n,i)=>{for(var o,r=void 0,a=e.length-1;a>=0;a--)(o=e[a])&&(r=o(t,n,r)||r);return r&&Dt(t,n,r),r};const Ht=(t=class extends me{constructor(){super(...arguments),this.post="/blog/my-post",this.apiUrl="http://localhost:8787/",this.authorName=void 0,this.language="en",this.apiService=we(this.apiUrl),this.i18n=Se(Ae),this.commentMap={},this.comments=[],this.currentReplyTo=null,this.previewText="",this.previewName="",this.previewPseudonym="",this.editingComment=null,this.activeTab="write",this.showMarkdownHelp=!1,this.showAdminLogin=!1}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.syncI18n(),this.apiService=we(this.apiUrl),Nt.addHook("afterSanitizeAttributes",e=>{"A"===e.tagName&&(e.setAttribute("rel","noopener noreferrer"),e.setAttribute("target","_blank")),"IMG"===e.tagName&&e.setAttribute("loading","lazy")}),Nt.addHook("uponSanitizeAttribute",(e,t)=>{if("href"===t.attrName||"src"===t.attrName)try{const e=new URL(t.attrValue||"");"http:"!==e.protocol&&"https:"!==e.protocol&&(t.keepAttr=!1)}catch{t.keepAttr=!1}}),this.reloadComments()}disconnectedCallback(){document.body.classList.remove("ycc-modal-open"),super.disconnectedCallback()}updated(e){e.has("apiUrl")&&(this.apiService=we(this.apiUrl)),e.has("language")&&this.syncI18n(),e.has("post")&&this.reloadComments()}syncI18n(){let e=Ae;const t=this.language;"string"==typeof t?e="zh-Hant"===t?_e:Ae:t&&"object"==typeof t&&(e=t),this.i18n=Se(e)}renderMarkdown(e){return be((t=r(e||""),Nt.sanitize(t,xt)));var t}getDisplayName(e){if(e?.isAdmin&&this.authorName)return this.authorName;const t=e?.pseudonym??"";return t.trim()?t:this.i18n.t("anonymous")}canEditComment(e){return this.apiService.canEditComment(e)}saveMyNameHash(e){try{const n=this.getMyNameHashes();e&&!n.includes(e)&&(n.push(e),localStorage.setItem(t.MY_NAME_HASHES_KEY,JSON.stringify(n)))}catch(n){console.warn("Failed to save name hash:",n)}}getMyNameHashes(){try{const e=localStorage.getItem(t.MY_NAME_HASHES_KEY);return e?JSON.parse(e):[]}catch(e){return console.warn("Failed to get name hashes:",e),[]}}isMyComment(e){return!!e.nameHash&&this.getMyNameHashes().includes(e.nameHash)}async loadComments(){return await this.apiService.getComments(this.post)}async reloadComments(){this.comments=await this.loadComments(),this.buildCommentMap()}switchTab(e){this.activeTab=e,"preview"===e&&this.saveCurrentFormInputs()}saveCurrentFormInputs(){const e=document.querySelector('#comment-form input[name="name"]');e&&(this.previewName=e.value)}async renderCommentsList(){0===this.comments.length&&await this.reloadComments()}buildCommentMap(){this.commentMap={},this.comments.forEach(e=>{this.commentMap[e.id]=e})}createCommentsTemplate(){return function(e){const t=e.comments$;return 0===t.length?q`<div id="comments">
|
|
86
|
-
<div class="no-comments-message">${e.i18n$.t("noComments")}</div>
|
|
87
|
-
</div>`:q`<div id="comments">${Rt(e,t,e.commentMap$)}</div>`}(this)}setReplyTo(e){this.editingComment&&(this.editingComment=null,this.previewText="",this.previewName="",this.previewPseudonym=""),this.currentReplyTo=e;const t=this.querySelector("#comment-form-container");t&&t.scrollIntoView({behavior:"smooth"})}cancelReply(){this.currentReplyTo=null}handleInputChange(e){this.previewText=e.target.value}async handleNameInputChange(e){const t=e.target;if(this.previewName=t.value,t.value.trim())try{const{pseudonym:e}=await Ee(t.value);this.previewPseudonym=e}catch{this.previewPseudonym=""}else this.previewPseudonym=""}async handleSubmit(e){e.preventDefault();const n=new FormData(e.target),i=n.get("name"),o=n.get("message");if(i&&i.length>t.MAX_NAME_LENGTH)return void alert(`${this.i18n.t("nameTooLong")} (${i.length}/${t.MAX_NAME_LENGTH})`);if(o.length>t.MAX_MESSAGE_LENGTH)return void alert(`${this.i18n.t("messageTooLong")} (${o.length}/${t.MAX_MESSAGE_LENGTH})`);let r,a;if(this.editingComment)r=this.editingComment.pseudonym||"",a=this.editingComment.nameHash||"";else{const e=await Ee(i||"");r=e.pseudonym,a=e.hash}await this.processSubmission(r,a,o)&&(this.resetFormState(),this.comments.length=0,await this.renderCommentsList())}async processSubmission(e,t,n){if(this.editingComment){const e=await this.apiService.updateComment(this.post,this.editingComment.id,this.editingComment.pseudonym||"",this.editingComment.nameHash||"",n);return e||alert(this.i18n.t("editFailed")),e}return await this.apiService.addComment(this.post,e,t,n,this.currentReplyTo)?(this.saveMyNameHash(t),!0):(alert(this.i18n.t("submitFailed")),!1)}resetFormState(){const e=document.querySelector("#comment-form");e&&e.reset(),this.previewText="",this.previewName="",this.previewPseudonym="",this.editingComment=null,this.currentReplyTo=null}async handlePreviewSubmit(){if(this.previewName&&this.previewName.length>t.MAX_NAME_LENGTH)return void alert(`${this.i18n.t("nameTooLong")} (${this.previewName.length}/${t.MAX_NAME_LENGTH})`);if(this.previewText.length>t.MAX_MESSAGE_LENGTH)return void alert(`${this.i18n.t("messageTooLong")} (${this.previewText.length}/${t.MAX_MESSAGE_LENGTH})`);let e,n;if(this.editingComment)e=this.editingComment.pseudonym||"",n=this.editingComment.nameHash||"";else{const t=await Ee(this.previewName);e=t.pseudonym,n=t.hash}await this.processSubmission(e,n,this.previewText)&&(this.resetPreviewState(),this.comments.length=0,await this.renderCommentsList())}resetPreviewState(){this.previewText="",this.previewName="",this.previewPseudonym="",this.editingComment=null,this.currentReplyTo=null,this.switchTab("write");const e=document.querySelector("#comment-form");e&&e.reset()}async handleDelete(e){if(!confirm(this.i18n.t("confirmDelete")))return;await this.apiService.deleteComment(this.post,e)?(this.comments.length=0,await this.renderCommentsList()):alert(this.i18n.t("deleteFailed"))}handleEdit(e){this.clearReplyState(),this.setEditingState(e),this.populateFormWithComment(e),this.scrollToForm()}clearReplyState(){this.currentReplyTo&&(this.currentReplyTo=null)}setEditingState(e){this.editingComment=e,this.previewText=e.msg||"",this.previewName=e.pseudonym||"",this.previewPseudonym=e.pseudonym||""}populateFormWithComment(e){const t=document.querySelector('#comment-form input[name="name"]'),n=document.querySelector('#comment-form textarea[name="message"]');t&&(t.value=e.pseudonym||"",this.previewName=e.pseudonym||"",this.previewPseudonym=e.pseudonym||""),n&&(n.value=e.msg||"",this.previewText=e.msg||"")}scrollToForm(){const e=document.querySelector("#comment-form-container");e&&e.scrollIntoView({behavior:"smooth"})}cancelEdit(){this.editingComment=null,this.clearFormAndPreview()}clearFormAndPreview(){const e=document.querySelector("#comment-form");e&&e.reset(),this.previewText="",this.previewName="",this.previewPseudonym=""}toggleMarkdownHelp(){this.showMarkdownHelp=!this.showMarkdownHelp,this.updateBodyScrollLock()}createMarkdownHelpTemplate(){return q` <div id="markdown-help-modal" class="active">
|
|
88
|
-
<div class="markdown-help-container ycc-flex">
|
|
89
|
-
<div
|
|
90
|
-
class="markdown-help-backdrop ycc-clickable"
|
|
91
|
-
@click=${()=>this.toggleMarkdownHelp()}
|
|
92
|
-
></div>
|
|
93
|
-
<div class="markdown-help-content" role="dialog" aria-modal="true">
|
|
94
|
-
<button
|
|
95
|
-
class="markdown-help-close ycc-clickable ycc-reset-button"
|
|
96
|
-
@click=${()=>this.toggleMarkdownHelp()}
|
|
97
|
-
aria-label="Close"
|
|
98
|
-
>
|
|
99
|
-
×
|
|
100
|
-
</button>
|
|
101
|
-
<h4>${this.i18n.t("commentSystemTitle")}</h4>
|
|
102
|
-
<p>${this.i18n.t("commentSystemDesc")}</p>
|
|
103
|
-
<p>${this.i18n.t("commentTimeLimit")}</p>
|
|
104
|
-
<p>
|
|
105
|
-
Powered by <a
|
|
106
|
-
href="https://github.com/ziteh/yangchun-comment"
|
|
107
|
-
target="_blank"
|
|
108
|
-
rel="noopener noreferrer"
|
|
109
|
-
>Yang Chun Comment</a
|
|
110
|
-
>
|
|
111
|
-
</p>
|
|
112
|
-
<h4>${this.i18n.t("markdownSyntax")}</h4>
|
|
113
|
-
<p>${this.i18n.t("markdownBasicSupport")}</p>
|
|
114
|
-
<div class="markdown-examples">
|
|
115
|
-
<code>
|
|
116
|
-
<pre>
|
|
117
|
-
${this.i18n.t("markdownLinkExample")}
|
|
118
|
-
|
|
119
|
-
${this.i18n.t("markdownImageExample")}
|
|
120
|
-
|
|
121
|
-
${this.i18n.t("markdownItalicExample")}
|
|
122
|
-
|
|
123
|
-
${this.i18n.t("markdownBoldExample")}
|
|
124
|
-
|
|
125
|
-
${this.i18n.t("markdownListExample")}
|
|
126
|
-
|
|
127
|
-
${this.i18n.t("markdownOrderedListExample")}
|
|
128
|
-
|
|
129
|
-
${this.i18n.t("markdownInlineCodeExample")}
|
|
130
|
-
|
|
131
|
-
${this.i18n.t("markdownCodeBlockExample")}</pre
|
|
132
|
-
>
|
|
133
|
-
</code>
|
|
134
|
-
</div>
|
|
135
|
-
</div>
|
|
136
|
-
</div>
|
|
137
|
-
</div>`}createFormTemplate(){return q`
|
|
138
|
-
${"preview"===this.activeTab?function(e){const t=Date.now(),n=e.previewPseudonym$??"";return q` <div class="comment-box preview-mode">
|
|
139
|
-
<div id="preview">
|
|
140
|
-
${e.previewText$?q` <div class="preview-comment">
|
|
141
|
-
<div class="comment-header">
|
|
142
|
-
<span class="comment-name">${n||e.i18n$.t("anonymous")}</span>
|
|
143
|
-
<span class="comment-time">${Lt(t)}</span>
|
|
144
|
-
${e.currentReplyTo$&&e.commentMap$[e.currentReplyTo$]?q`<span class="reply-to"
|
|
145
|
-
>${e.i18n$.t("replyTo")}<span
|
|
146
|
-
>${e.getDisplayName(e.commentMap$[e.currentReplyTo$])}</span
|
|
147
|
-
></span
|
|
148
|
-
>`:""}
|
|
149
|
-
</div>
|
|
150
|
-
<div class="comment-content">${e.renderMarkdown(e.previewText$)}</div>
|
|
151
|
-
</div>`:q`<div class="empty-preview">${e.i18n$.t("emptyPreview")}</div>`}
|
|
152
|
-
</div>
|
|
153
|
-
<div class="comment-footer ycc-flex ycc-gap-xs">
|
|
154
|
-
<span style="flex: 1;"></span>
|
|
155
|
-
<div class="ycc-flex ycc-gap-xs">
|
|
156
|
-
<button
|
|
157
|
-
type="button"
|
|
158
|
-
class="help-btn ycc-clickable ycc-reset-button"
|
|
159
|
-
title="${e.i18n$.t("markdownHelp")}"
|
|
160
|
-
@click=${()=>e.toggleMarkdownHelp()}
|
|
161
|
-
>
|
|
162
|
-
?
|
|
163
|
-
</button>
|
|
164
|
-
<button
|
|
165
|
-
type="button"
|
|
166
|
-
class="preview-btn ycc-clickable ycc-transition ycc-transparent-bg active ycc-reset-button"
|
|
167
|
-
@click=${()=>e.switchTab("write")}
|
|
168
|
-
>
|
|
169
|
-
${e.i18n$.t("write")}
|
|
170
|
-
</button>
|
|
171
|
-
<button
|
|
172
|
-
type="button"
|
|
173
|
-
class="submit-btn ycc-clickable ycc-transition ycc-reset-button"
|
|
174
|
-
@click=${()=>e.handlePreviewSubmit()}
|
|
175
|
-
>
|
|
176
|
-
${e.editingComment$?e.i18n$.t("updateComment"):e.i18n$.t("submitComment")}
|
|
177
|
-
</button>
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
</div>`}(this):this.createFormContent()}
|
|
181
|
-
${this.createStatusIndicators()}
|
|
182
|
-
${this.showMarkdownHelp?this.createMarkdownHelpTemplate():X}
|
|
183
|
-
${this.showAdminLogin?this.createAdminLoginTemplate():X}
|
|
184
|
-
`}createFormContent(){return q` <div class="comment-box">
|
|
185
|
-
<div id="form-content" class="${"write"===this.activeTab?"active":""}">
|
|
186
|
-
<form
|
|
187
|
-
id="comment-form"
|
|
188
|
-
class="ycc-reset-form"
|
|
189
|
-
@submit=${e=>this.handleSubmit(e)}
|
|
190
|
-
>
|
|
191
|
-
<div class="honeypot-field">
|
|
192
|
-
<input type="text" name="website" tabindex="-1" autocomplete="off" aria-hidden="true" />
|
|
193
|
-
</div>
|
|
194
|
-
${this.createTextareaSection()} ${this.createFormFooter()}
|
|
195
|
-
</form>
|
|
196
|
-
</div>
|
|
197
|
-
</div>`}createTextareaSection(){return q` <div class="comment-input">
|
|
198
|
-
<textarea
|
|
199
|
-
name="message"
|
|
200
|
-
placeholder="${this.i18n.t("messagePlaceholder")}"
|
|
201
|
-
maxlength="${t.MAX_MESSAGE_LENGTH}"
|
|
202
|
-
required
|
|
203
|
-
.value=${this.previewText}
|
|
204
|
-
@input=${e=>this.handleInputChange(e)}
|
|
205
|
-
></textarea>
|
|
206
|
-
<div class="char-count">
|
|
207
|
-
<span
|
|
208
|
-
id="message-char-count"
|
|
209
|
-
class="${this.previewText.length>t.MAX_MESSAGE_LENGTH?"over-limit":""}"
|
|
210
|
-
>${this.previewText.length}</span
|
|
211
|
-
>/${t.MAX_MESSAGE_LENGTH}
|
|
212
|
-
</div>
|
|
213
|
-
</div>`}createFormFooter(){return q` <div class="comment-footer ycc-flex ycc-flex-wrap ycc-gap-xs">
|
|
214
|
-
<div class="name-input-container">
|
|
215
|
-
<input
|
|
216
|
-
type="text"
|
|
217
|
-
name="name"
|
|
218
|
-
autocomplete="name"
|
|
219
|
-
placeholder="${this.i18n.t("namePlaceholder")}"
|
|
220
|
-
maxlength="${t.MAX_NAME_LENGTH}"
|
|
221
|
-
?disabled=${null!==this.editingComment}
|
|
222
|
-
.value=${this.previewName}
|
|
223
|
-
@input=${e=>this.handleNameInputChange(e)}
|
|
224
|
-
/>
|
|
225
|
-
<div class="char-count" style="margin-top: 4px;">
|
|
226
|
-
<span
|
|
227
|
-
id="name-char-count"
|
|
228
|
-
class="${this.previewName.length>t.MAX_NAME_LENGTH?"over-limit":""}"
|
|
229
|
-
>${this.previewName.length}</span
|
|
230
|
-
>/${t.MAX_NAME_LENGTH}
|
|
231
|
-
</div>
|
|
232
|
-
<div class="pseudonym-notice" style="font-size: 0.8em; color: #666; margin-top: 4px;">
|
|
233
|
-
${this.editingComment?this.i18n.t("editingPseudonymNotice"):this.i18n.t("pseudonymNotice")}
|
|
234
|
-
</div>
|
|
235
|
-
</div>
|
|
236
|
-
<div class="ycc-flex ycc-gap-xs">${this.createFormButtons()}</div>
|
|
237
|
-
</div>`}createFormButtons(){return q` <button
|
|
238
|
-
type="button"
|
|
239
|
-
class="help-btn ycc-clickable ycc-reset-button"
|
|
240
|
-
title="${this.i18n.t("markdownHelp")}"
|
|
241
|
-
@click=${()=>this.toggleMarkdownHelp()}
|
|
242
|
-
>
|
|
243
|
-
?
|
|
244
|
-
</button>
|
|
245
|
-
<button
|
|
246
|
-
type="button"
|
|
247
|
-
class="preview-btn ycc-clickable ycc-transition ycc-transparent-bg ycc-reset-button ${"preview"===this.activeTab?"active":""}"
|
|
248
|
-
@click=${()=>this.switchTab("preview"===this.activeTab?"write":"preview")}
|
|
249
|
-
>
|
|
250
|
-
${"preview"===this.activeTab?this.i18n.t("write"):this.i18n.t("preview")}
|
|
251
|
-
</button>
|
|
252
|
-
<button type="submit" class="submit-btn ycc-clickable ycc-transition ycc-reset-button">
|
|
253
|
-
${this.editingComment?this.i18n.t("updateComment"):this.i18n.t("submitComment")}
|
|
254
|
-
</button>`}createAdminButton(){return q`<button
|
|
255
|
-
type="button"
|
|
256
|
-
class="admin-btn ycc-clickable ycc-reset-button"
|
|
257
|
-
title="Admin"
|
|
258
|
-
@click=${()=>this.showAdminModal()}
|
|
259
|
-
>
|
|
260
|
-
⚙
|
|
261
|
-
</button>`}showAdminModal(){this.showAdminLogin=!0,this.updateBodyScrollLock()}hideAdminModal(){this.showAdminLogin=!1,this.updateBodyScrollLock()}updateBodyScrollLock(){const e=this.showMarkdownHelp||this.showAdminLogin;document.body.classList.toggle("ycc-modal-open",e)}createAdminLoginTemplate(){return q`<div
|
|
262
|
-
class="admin-modal-backdrop ycc-clickable"
|
|
263
|
-
@click=${()=>this.hideAdminModal()}
|
|
264
|
-
>
|
|
265
|
-
<div class="admin-modal-content" @click=${e=>e.stopPropagation()}>
|
|
266
|
-
<button
|
|
267
|
-
class="admin-modal-close ycc-clickable ycc-reset-button"
|
|
268
|
-
@click=${()=>this.hideAdminModal()}
|
|
269
|
-
>
|
|
270
|
-
×
|
|
271
|
-
</button>
|
|
272
|
-
<h3>Admin Login</h3>
|
|
273
|
-
<form @submit=${e=>this.handleAdminLogin(e)}>
|
|
274
|
-
<div class="admin-form-group">
|
|
275
|
-
<label for="admin-username">Username:</label
|
|
276
|
-
><input type="text" id="admin-username" name="username" required autocomplete="off" />
|
|
277
|
-
</div>
|
|
278
|
-
<div class="admin-form-group">
|
|
279
|
-
<label for="admin-password">Password:</label
|
|
280
|
-
><input
|
|
281
|
-
type="password"
|
|
282
|
-
id="admin-password"
|
|
283
|
-
name="password"
|
|
284
|
-
required
|
|
285
|
-
autocomplete="off"
|
|
286
|
-
/>
|
|
287
|
-
</div>
|
|
288
|
-
<button type="submit" class="admin-login-btn ycc-clickable ycc-reset-button">
|
|
289
|
-
Login
|
|
290
|
-
</button>
|
|
291
|
-
</form>
|
|
292
|
-
</div>
|
|
293
|
-
</div>`}async handleAdminLogin(e){e.preventDefault();const t=new FormData(e.target),n=t.get("username"),i=t.get("password");try{const e=await fetch(`${this.apiUrl}admin/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:n,password:i})});e.ok?(await e.text(),alert("Admin login successful!"),this.hideAdminModal()):alert("Admin login failed!")}catch(o){console.error("Admin login error:",o),alert("Admin login error!")}}createStatusIndicators(){const e=this.createReplyIndicator(),t=this.createEditIndicator();return""!==e||""!==t?q`${e}${t}`:X}createReplyIndicator(){return this.currentReplyTo&&this.commentMap[this.currentReplyTo]?q`<div class="info ycc-flex ycc-gap-md">
|
|
294
|
-
${this.i18n.t("replyingTo")}
|
|
295
|
-
${this.getDisplayName(this.commentMap[this.currentReplyTo])}<button
|
|
296
|
-
type="button"
|
|
297
|
-
class="cancel-link ycc-clickable ycc-transition ycc-reset-button"
|
|
298
|
-
@click=${()=>this.cancelReply()}
|
|
299
|
-
>
|
|
300
|
-
${this.i18n.t("cancelReply")}
|
|
301
|
-
</button>
|
|
302
|
-
</div>`:""}createEditIndicator(){return this.editingComment?q`<div class="info ycc-flex ycc-gap-md">
|
|
303
|
-
${this.i18n.t("editing")} ${this.editingComment.id}<button
|
|
304
|
-
type="button"
|
|
305
|
-
class="cancel-link ycc-clickable ycc-transition ycc-reset-button"
|
|
306
|
-
@click=${()=>this.cancelEdit()}
|
|
307
|
-
>
|
|
308
|
-
${this.i18n.t("cancelEdit")}
|
|
309
|
-
</button>
|
|
310
|
-
</div>`:""}render(){return q` <div class="ycc-container">
|
|
311
|
-
<div class="comment-box-container">
|
|
312
|
-
<div id="comment-form-container" class="form-content">${this.createFormTemplate()}</div>
|
|
313
|
-
<!-- <div class="admin-btn-wrapper">${this.createAdminButton()}</div> -->
|
|
314
|
-
</div>
|
|
315
|
-
<div id="comments-container">${this.createCommentsTemplate()}</div>
|
|
316
|
-
</div>`}async refresh(){await this.reloadComments()}get i18n$(){return this.i18n}get commentMap$(){return this.commentMap}get currentReplyTo$(){return this.currentReplyTo}get previewText$(){return this.previewText}get previewPseudonym$(){return this.previewPseudonym}get editingComment$(){return this.editingComment}get comments$(){return this.comments}formatDate(e){return Lt(e)}},t.MAX_NAME_LENGTH=25,t.MAX_MESSAGE_LENGTH=1e3,t.MY_NAME_HASHES_KEY="ycc_my_name_hashes",t);Ot([he({type:String})],Ht.prototype,"post"),Ot([he({type:String})],Ht.prototype,"apiUrl"),Ot([he({type:String})],Ht.prototype,"authorName"),Ot([he({attribute:!1})],Ht.prototype,"language"),Ot([ge()],Ht.prototype,"commentMap"),Ot([ge()],Ht.prototype,"comments"),Ot([ge()],Ht.prototype,"currentReplyTo"),Ot([ge()],Ht.prototype,"previewText"),Ot([ge()],Ht.prototype,"previewName"),Ot([ge()],Ht.prototype,"previewPseudonym"),Ot([ge()],Ht.prototype,"editingComment"),Ot([ge()],Ht.prototype,"activeTab"),Ot([ge()],Ht.prototype,"showMarkdownHelp"),Ot([ge()],Ht.prototype,"showAdminLogin");let It=Ht;function Ut(e="ycc-app",t={}){const n=document.getElementById(e);if(!n)throw new Error(`Container #${e} not found`);const i=document.createElement("yangchun-comment");return t.post&&(i.post=t.post),t.apiUrl&&(i.apiUrl=t.apiUrl),t.authorName&&(i.authorName=t.authorName),t.language&&(i.language=t.language),n.innerHTML="",n.appendChild(i),i}customElements.get("yangchun-comment")||customElements.define("yangchun-comment",It),e.default=Ut,e.initYangchunComment=Ut,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
317
|
-
//# sourceMappingURL=yangchun-comment.umd.js.map
|