diff --git a/43cd4fb344b35c375f0195c04167206c.txt b/43cd4fb344b35c375f0195c04167206c.txt new file mode 100644 index 0000000..6d6914c --- /dev/null +++ b/43cd4fb344b35c375f0195c04167206c.txt @@ -0,0 +1 @@ +352bd565dba7475c6fea2025b91ed85021a14e5b \ No newline at end of file diff --git a/58f97de7eceaa2f7ce7d982b1c9ad661.txt b/58f97de7eceaa2f7ce7d982b1c9ad661.txt new file mode 100644 index 0000000..37a9f6f --- /dev/null +++ b/58f97de7eceaa2f7ce7d982b1c9ad661.txt @@ -0,0 +1 @@ +b45e7a190b591ffb595d4b39fbdb1d2e815dba99 \ No newline at end of file diff --git a/about.html b/about.html new file mode 100644 index 0000000..cfd71ec --- /dev/null +++ b/about.html @@ -0,0 +1,6 @@ +关于 · Leen Zhu

Leen Zhu

while(life--) money++;

简介

  • 2024年,开始学习React,Solidjs,Svelte,不知道算不算49年入国军。

时间线

  • 2021-10-05 正式开站。
\ No newline at end of file diff --git a/categories.html b/categories.html new file mode 100644 index 0000000..5769525 --- /dev/null +++ b/categories.html @@ -0,0 +1,6 @@ +Categories · Leen Zhu

Leen Zhu

while(life--) money++;

分类

\ No newline at end of file diff --git a/categories/index.xml b/categories/index.xml new file mode 100644 index 0000000..d0bb4e8 --- /dev/null +++ b/categories/index.xml @@ -0,0 +1 @@ +Categories on Leen Zhuhttps://leenzhu.com/categories.htmlRecent content in Categories on Leen ZhuHugo -- gohugo.iozh-cnMon, 23 Sep 2024 17:10:58 +0800Techhttps://leenzhu.com/categories/tech.htmlMon, 23 Sep 2024 17:10:58 +0800https://leenzhu.com/categories/tech.html \ No newline at end of file diff --git a/categories/tech.html b/categories/tech.html new file mode 100644 index 0000000..b341bbf --- /dev/null +++ b/categories/tech.html @@ -0,0 +1,12 @@ +Tech · Leen Zhu

Leen Zhu

while(life--) money++;

@Tech

\ No newline at end of file diff --git a/categories/tech/index.xml b/categories/tech/index.xml new file mode 100644 index 0000000..735005d --- /dev/null +++ b/categories/tech/index.xml @@ -0,0 +1,4 @@ +Tech on Leen Zhuhttps://leenzhu.com/categories/tech.htmlRecent content in Tech on Leen ZhuHugo -- gohugo.iozh-cnMon, 23 Sep 2024 17:10:58 +0800ldconfighttps://leenzhu.com/posts/ldconfig.htmlMon, 23 Sep 2024 17:10:58 +0800https://leenzhu.com/posts/ldconfig.html<p>工作时遇到了一个奇的问题。手动创建某个<code>so</code>符号链接似乎不能被<code>ldconfig</code>识别。</p>git 根据commit反查branch、tag名https://leenzhu.com/posts/git-branch-points-at.htmlFri, 31 May 2024 10:57:48 +0800https://leenzhu.com/posts/git-branch-points-at.html<p>在使用 <code>git</code> 的时候大部分时候都是通过 <code>git rev-parse &lt;branch-name&gt;</code> 来获取某个分支名对应的 <code>commit id</code> 但是一直没遇到通过 <code>commit id</code> 来获取分支名的场景。在学习 <code>git rebase</code> 命令的时候突然想知道有没有这个命令。于是就开始问 <code>chatgpt</code> 了。</p>git本地分支与远端重名https://leenzhu.com/posts/git%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E4%B8%8E%E8%BF%9C%E7%AB%AF%E9%87%8D%E5%90%8D.htmlWed, 26 Jul 2023 00:00:00 +0000https://leenzhu.com/posts/git%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E4%B8%8E%E8%BF%9C%E7%AB%AF%E9%87%8D%E5%90%8D.html<p>今天遇到一个git名字ambiguous的问题。</p> +<blockquote> +<p>warning: refname &lsquo;origin/master&rsquo; is ambiguous.</p> +</blockquote>round_pow2 函数分析https://leenzhu.com/posts/round_pow2-%E5%87%BD%E6%95%B0%E5%88%86%E6%9E%90.htmlTue, 25 Jul 2023 00:00:00 +0000https://leenzhu.com/posts/round_pow2-%E5%87%BD%E6%95%B0%E5%88%86%E6%9E%90.html<p>网上搜了一圈没有搜到对这个函数的说明。这个函数的名称给我造成一些误解,让我认为这是<strong>四舍五入</strong>的概念,对于浮点数取整一般有3种情况:</p>Golang Binary包使用https://leenzhu.com/posts/golang-binary.htmlMon, 15 May 2023 00:00:00 +0000https://leenzhu.com/posts/golang-binary.html<p>在使用golang的过程需要进行NBNS的报文解析,经调研发现NBNS的报文大都是定长报文,并且需要处理这些报文也不需要太高的性能,所有就决定使用 <code>encoding/binary</code>包来进行编解码。学习过程中对这个包内每个函数都进行尝试并整理出笔记如下。</p>hugo 显相对路径下的图片https://leenzhu.com/posts/hugo-show-buddle-img.htmlWed, 06 Oct 2021 11:36:03 +0800https://leenzhu.com/posts/hugo-show-buddle-img.html<p>很早以前发现 <code>hugo server</code> 命令在本地预览时不能显示相文章相对路径下的图片。但是普通web服务器是可以显示的一直都不知道是什么原因,之前也曾花费大量时间翻遍整个hugo论坛,也没有找到解决方案,因为我的 <code>emacs</code> 可以直接预览图片,发布后也能正常显示图片,后来也就不去管它了。但是今天非常偶然的发现原来 <code>hugo server</code> 也可能预览相对路径的下图片。</p> \ No newline at end of file diff --git a/categories/tech/page/1.html b/categories/tech/page/1.html new file mode 100644 index 0000000..24d0545 --- /dev/null +++ b/categories/tech/page/1.html @@ -0,0 +1 @@ +https://leenzhu.com/categories/tech.html \ No newline at end of file diff --git a/css/chroma.css b/css/chroma.css new file mode 100644 index 0000000..e2c5d6c --- /dev/null +++ b/css/chroma.css @@ -0,0 +1,68 @@ +/* Background */ .chroma { background-color: #e0e0e0 ; padding: 10px;white-space: pre-line;word-wrap: break-word;} +/* Error */ .chroma .err { } +/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; } +/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; width: auto; overflow: auto; display: block; } +/* LineHighlight */ .chroma .hl { display: block; width: 100%;background-color: #ffffcc } +/* LineNumbersTable */ .chroma .lnt { margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f } +/* LineNumbers */ .chroma .ln { margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f } +/* Keyword */ .chroma .k { color: #007020; font-weight: bold } +/* KeywordConstant */ .chroma .kc { color: #007020; font-weight: bold } +/* KeywordDeclaration */ .chroma .kd { color: #007020; font-weight: bold } +/* KeywordNamespace */ .chroma .kn { color: #007020; font-weight: bold } +/* KeywordPseudo */ .chroma .kp { color: #007020 } +/* KeywordReserved */ .chroma .kr { color: #007020; font-weight: bold } +/* KeywordType */ .chroma .kt { color: #902000 } +/* NameAttribute */ .chroma .na { color: #4070a0 } +/* NameBuiltin */ .chroma .nb { color: #007020 } +/* NameClass */ .chroma .nc { color: #0e84b5; font-weight: bold } +/* NameConstant */ .chroma .no { color: #60add5 } +/* NameDecorator */ .chroma .nd { color: #555555; font-weight: bold } +/* NameEntity */ .chroma .ni { color: #d55537; font-weight: bold } +/* NameException */ .chroma .ne { color: #007020 } +/* NameFunction */ .chroma .nf { color: #06287e } +/* NameLabel */ .chroma .nl { color: #002070; font-weight: bold } +/* NameNamespace */ .chroma .nn { color: #0e84b5; font-weight: bold } +/* NameTag */ .chroma .nt { color: #062873; font-weight: bold } +/* NameVariable */ .chroma .nv { color: #bb60d5 } +/* LiteralString */ .chroma .s { color: #4070a0 } +/* LiteralStringAffix */ .chroma .sa { color: #4070a0 } +/* LiteralStringBacktick */ .chroma .sb { color: #4070a0 } +/* LiteralStringChar */ .chroma .sc { color: #4070a0 } +/* LiteralStringDelimiter */ .chroma .dl { color: #4070a0 } +/* LiteralStringDoc */ .chroma .sd { color: #4070a0; font-style: italic } +/* LiteralStringDouble */ .chroma .s2 { color: #4070a0 } +/* LiteralStringEscape */ .chroma .se { color: #4070a0; font-weight: bold } +/* LiteralStringHeredoc */ .chroma .sh { color: #4070a0 } +/* LiteralStringInterpol */ .chroma .si { color: #70a0d0; font-style: italic } +/* LiteralStringOther */ .chroma .sx { color: #c65d09 } +/* LiteralStringRegex */ .chroma .sr { color: #235388 } +/* LiteralStringSingle */ .chroma .s1 { color: #4070a0 } +/* LiteralStringSymbol */ .chroma .ss { color: #517918 } +/* LiteralNumber */ .chroma .m { color: #40a070 } +/* LiteralNumberBin */ .chroma .mb { color: #40a070 } +/* LiteralNumberFloat */ .chroma .mf { color: #40a070 } +/* LiteralNumberHex */ .chroma .mh { color: #40a070 } +/* LiteralNumberInteger */ .chroma .mi { color: #40a070 } +/* LiteralNumberIntegerLong */ .chroma .il { color: #40a070 } +/* LiteralNumberOct */ .chroma .mo { color: #40a070 } +/* Operator */ .chroma .o { color: #666666 } +/* OperatorWord */ .chroma .ow { color: #007020; font-weight: bold } +/* Comment */ .chroma .c { color: #60a0b0; font-style: italic } +/* CommentHashbang */ .chroma .ch { color: #60a0b0; font-style: italic } +/* CommentMultiline */ .chroma .cm { color: #60a0b0; font-style: italic } +/* CommentSingle */ .chroma .c1 { color: #60a0b0; font-style: italic } +/* CommentSpecial */ .chroma .cs { color: #60a0b0; background-color: #fff0f0 } +/* CommentPreproc */ .chroma .cp { color: #007020 } +/* CommentPreprocFile */ .chroma .cpf { color: #007020 } +/* GenericDeleted */ .chroma .gd { color: #a00000 } +/* GenericEmph */ .chroma .ge { font-style: italic } +/* GenericError */ .chroma .gr { color: #ff0000 } +/* GenericHeading */ .chroma .gh { color: #000080; font-weight: bold } +/* GenericInserted */ .chroma .gi { color: #00a000 } +/* GenericOutput */ .chroma .go { color: #888888 } +/* GenericPrompt */ .chroma .gp { color: #c65d09; font-weight: bold } +/* GenericStrong */ .chroma .gs { font-weight: bold } +/* GenericSubheading */ .chroma .gu { color: #800080; font-weight: bold } +/* GenericTraceback */ .chroma .gt { color: #0044dd } +/* GenericUnderline */ .chroma .gl { text-decoration: underline } +/* TextWhitespace */ .chroma .w { color: #bbbbbb } diff --git a/css/normalize.css b/css/normalize.css new file mode 100644 index 0000000..0471edb --- /dev/null +++ b/css/normalize.css @@ -0,0 +1,375 @@ +/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ + +/* Document + ========================================================================== */ + +/** + * 1. Correct the line height in all browsers. + * 2. Prevent adjustments of font size after orientation changes in iOS. + */ + +html { + line-height: 1.15; /* 1 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/* Sections + ========================================================================== */ + +/** + * Remove the margin in all browsers. + */ + +body { + margin: 0; +} + +/** + * Render the `main` element consistently in IE. + */ + +main { + display: block; +} + +/** + * Correct the font size and margin on `h1` elements within `section` and + * `article` contexts in Chrome, Firefox, and Safari. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/* Grouping content + ========================================================================== */ + +/** + * 1. Add the correct box sizing in Firefox. + * 2. Show the overflow in Edge and IE. + */ + +hr { + box-sizing: content-box; /* 1 */ + height: 0; /* 1 */ + overflow: visible; /* 2 */ +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +pre { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Remove the gray background on active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * 1. Remove the bottom border in Chrome 57- + * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. + */ + +abbr[title] { + border-bottom: none; /* 1 */ + text-decoration: underline; /* 2 */ + text-decoration: underline dotted; /* 2 */ +} + +/** + * Add the correct font weight in Chrome, Edge, and Safari. + */ + +b, +strong { + font-weight: bolder; +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +code, +kbd, +samp { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/** + * Add the correct font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` elements from affecting the line height in + * all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sub { + bottom: -0.25em; +} + +sup { + top: -0.5em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove the border on images inside links in IE 10. + */ + +img { + border-style: none; +} + +/* Forms + ========================================================================== */ + +/** + * 1. Change the font styles in all browsers. + * 2. Remove the margin in Firefox and Safari. + */ + +button, +input, +optgroup, +select, +textarea { + font-family: inherit; /* 1 */ + font-size: 100%; /* 1 */ + line-height: 1.15; /* 1 */ + margin: 0; /* 2 */ +} + +/** + * Show the overflow in IE. + * 1. Show the overflow in Edge. + */ + +button, +input { /* 1 */ + overflow: visible; +} + +/** + * Remove the inheritance of text transform in Edge, Firefox, and IE. + * 1. Remove the inheritance of text transform in Firefox. + */ + +button, +select { /* 1 */ + text-transform: none; +} + +/** + * Correct the inability to style clickable types in iOS and Safari. + */ + +button, +[type="button"], +[type="reset"], +[type="submit"] { + -webkit-appearance: button; +} + +/** + * Remove the inner border and padding in Firefox. + */ + +button::-moz-focus-inner, +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; +} + +/** + * Restore the focus styles unset by the previous rule. + */ + +button:-moz-focusring, +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring { + outline: 1px dotted ButtonText; +} + +/** + * Correct the padding in Firefox. + */ + +fieldset { + padding: 0.35em 0.75em 0.625em; +} + +/** + * 1. Correct the text wrapping in Edge and IE. + * 2. Correct the color inheritance from `fieldset` elements in IE. + * 3. Remove the padding so developers are not caught out when they zero out + * `fieldset` elements in all browsers. + */ + +legend { + box-sizing: border-box; /* 1 */ + color: inherit; /* 2 */ + display: table; /* 1 */ + max-width: 100%; /* 1 */ + padding: 0; /* 3 */ + white-space: normal; /* 1 */ +} + +/** + * Add the correct vertical alignment in Chrome, Firefox, and Opera. + */ + +progress { + vertical-align: baseline; +} + +/** + * Remove the default vertical scrollbar in IE 10+. + */ + +textarea { + overflow: auto; +} + +/** + * 1. Add the correct box sizing in IE 10. + * 2. Remove the padding in IE 10. + */ + +[type="checkbox"], +[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Correct the cursor style of increment and decrement buttons in Chrome. + */ + +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Correct the odd appearance in Chrome and Safari. + * 2. Correct the outline style in Safari. + */ + +[type="search"] { + -webkit-appearance: textfield; /* 1 */ + outline-offset: -2px; /* 2 */ +} + +/** + * Remove the inner padding in Chrome and Safari on macOS. + */ + +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * 1. Correct the inability to style clickable types in iOS and Safari. + * 2. Change font properties to `inherit` in Safari. + */ + +::-webkit-file-upload-button { + -webkit-appearance: button; /* 1 */ + font: inherit; /* 2 */ +} + +/* Interactive + ========================================================================== */ + +/* + * Add the correct display in Edge, IE 10+, and Firefox. + */ + +details { + display: block; +} + +/* + * Add the correct display in all browsers. + */ + +summary { + display: list-item; +} + +/* Misc + ========================================================================== */ + +/** + * Add the correct display in IE 10+. + */ + +template { + display: none; +} + +/** + * Add the correct display in IE 10. + */ + +[hidden] { + display: none; +} + +@media print { + header, .footer, .page-nav { + display:none; + } + body { + background-color:#fff!important; + } + .main { + -webkit-box-shadow: none!important; + box-shadow: none!important; + padding-top:0px!important; + padding-right:2em!important; + padding-left:2em!important; + } + .print-url { + display: block; + padding-top: 0.5em; + } +} + +@media screen { + .print-url { + display: none; + } +} \ No newline at end of file diff --git a/en/categories.html b/en/categories.html new file mode 100644 index 0000000..2f83737 --- /dev/null +++ b/en/categories.html @@ -0,0 +1,6 @@ +Categories · Leen Zhu

Leen Zhu

while(life--) money++;

    \ No newline at end of file diff --git a/en/categories/index.xml b/en/categories/index.xml new file mode 100644 index 0000000..79f6e91 --- /dev/null +++ b/en/categories/index.xml @@ -0,0 +1 @@ +Categories on Leen Zhuhttps://leenzhu.com/en/categories.htmlRecent content in Categories on Leen ZhuHugo -- gohugo.ioen \ No newline at end of file diff --git a/en/index.html b/en/index.html new file mode 100644 index 0000000..61c7ebf --- /dev/null +++ b/en/index.html @@ -0,0 +1,6 @@ +Leen Zhu

    Leen Zhu

    while(life--) money++;

    \ No newline at end of file diff --git a/en/index.xml b/en/index.xml new file mode 100644 index 0000000..ec9ec85 --- /dev/null +++ b/en/index.xml @@ -0,0 +1 @@ +Leen Zhuhttps://leenzhu.com/en/Recent content on Leen ZhuHugo -- gohugo.ioen \ No newline at end of file diff --git a/en/page/1.html b/en/page/1.html new file mode 100644 index 0000000..0f9e903 --- /dev/null +++ b/en/page/1.html @@ -0,0 +1 @@ +https://leenzhu.com/en/ \ No newline at end of file diff --git a/en/sitemap.xml b/en/sitemap.xml new file mode 100644 index 0000000..e5f34b1 --- /dev/null +++ b/en/sitemap.xml @@ -0,0 +1 @@ +https://leenzhu.com/en/categories.htmlweekly0.5https://leenzhu.com/en/weekly0.5https://leenzhu.com/en/tags.htmlweekly0.5 \ No newline at end of file diff --git a/en/tags.html b/en/tags.html new file mode 100644 index 0000000..ebcd4ce --- /dev/null +++ b/en/tags.html @@ -0,0 +1,6 @@ +Tags · Leen Zhu

    Leen Zhu

    while(life--) money++;

      \ No newline at end of file diff --git a/en/tags/index.xml b/en/tags/index.xml new file mode 100644 index 0000000..701ac16 --- /dev/null +++ b/en/tags/index.xml @@ -0,0 +1 @@ +Tags on Leen Zhuhttps://leenzhu.com/en/tags.htmlRecent content in Tags on Leen ZhuHugo -- gohugo.ioen \ No newline at end of file diff --git a/faq.html b/faq.html new file mode 100644 index 0000000..34dff16 --- /dev/null +++ b/faq.html @@ -0,0 +1,6 @@ +关于 · Leen Zhu

      Leen Zhu

      while(life--) money++;

      记录日常学习过程中遇到的问题。

      \ No newline at end of file diff --git a/image/fav.svg b/image/fav.svg new file mode 100644 index 0000000..5be362e --- /dev/null +++ b/image/fav.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/image/logo.png b/image/logo.png new file mode 100644 index 0000000..db445f0 Binary files /dev/null and b/image/logo.png differ diff --git a/images/fav.svg b/images/fav.svg new file mode 100644 index 0000000..5be362e --- /dev/null +++ b/images/fav.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/loading.gif b/images/loading.gif new file mode 100644 index 0000000..4744c45 Binary files /dev/null and b/images/loading.gif differ diff --git a/images/logo.png b/images/logo.png new file mode 100644 index 0000000..db445f0 Binary files /dev/null and b/images/logo.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..e2828f4 --- /dev/null +++ b/index.html @@ -0,0 +1,10 @@ +Leen Zhu

      Leen Zhu

      while(life--) money++;

      ldconfig

      工作时遇到了一个奇的问题。手动创建某个so符号链接似乎不能被ldconfig识别。

      阅读全文

      git 根据commit反查branch、tag名

      在使用 git 的时候大部分时候都是通过 git rev-parse <branch-name> 来获取某个分支名对应的 commit id 但是一直没遇到通过 commit id 来获取分支名的场景。在学习 git rebase 命令的时候突然想知道有没有这个命令。于是就开始问 chatgpt 了。

      阅读全文

      round_pow2 函数分析

      网上搜了一圈没有搜到对这个函数的说明。这个函数的名称给我造成一些误解,让我认为这是四舍五入的概念,对于浮点数取整一般有3种情况:

      阅读全文

      Golang Binary包使用

      在使用golang的过程需要进行NBNS的报文解析,经调研发现NBNS的报文大都是定长报文,并且需要处理这些报文也不需要太高的性能,所有就决定使用 encoding/binary包来进行编解码。学习过程中对这个包内每个函数都进行尝试并整理出笔记如下。

      阅读全文

      hugo 显相对路径下的图片

      很早以前发现 hugo server 命令在本地预览时不能显示相文章相对路径下的图片。但是普通web服务器是可以显示的一直都不知道是什么原因,之前也曾花费大量时间翻遍整个hugo论坛,也没有找到解决方案,因为我的 emacs 可以直接预览图片,发布后也能正常显示图片,后来也就不去管它了。但是今天非常偶然的发现原来 hugo server 也可能预览相对路径的下图片。

      阅读全文

      \ No newline at end of file diff --git a/index.xml b/index.xml new file mode 100644 index 0000000..8aed569 --- /dev/null +++ b/index.xml @@ -0,0 +1,4 @@ +Leen Zhuhttps://leenzhu.com/Recent content on Leen ZhuHugo -- gohugo.iozh-cnMon, 23 Sep 2024 17:10:58 +0800ldconfighttps://leenzhu.com/posts/ldconfig.htmlMon, 23 Sep 2024 17:10:58 +0800https://leenzhu.com/posts/ldconfig.html<p>工作时遇到了一个奇的问题。手动创建某个<code>so</code>符号链接似乎不能被<code>ldconfig</code>识别。</p>git 根据commit反查branch、tag名https://leenzhu.com/posts/git-branch-points-at.htmlFri, 31 May 2024 10:57:48 +0800https://leenzhu.com/posts/git-branch-points-at.html<p>在使用 <code>git</code> 的时候大部分时候都是通过 <code>git rev-parse &lt;branch-name&gt;</code> 来获取某个分支名对应的 <code>commit id</code> 但是一直没遇到通过 <code>commit id</code> 来获取分支名的场景。在学习 <code>git rebase</code> 命令的时候突然想知道有没有这个命令。于是就开始问 <code>chatgpt</code> 了。</p>git本地分支与远端重名https://leenzhu.com/posts/git%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E4%B8%8E%E8%BF%9C%E7%AB%AF%E9%87%8D%E5%90%8D.htmlWed, 26 Jul 2023 00:00:00 +0000https://leenzhu.com/posts/git%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E4%B8%8E%E8%BF%9C%E7%AB%AF%E9%87%8D%E5%90%8D.html<p>今天遇到一个git名字ambiguous的问题。</p> +<blockquote> +<p>warning: refname &lsquo;origin/master&rsquo; is ambiguous.</p> +</blockquote>round_pow2 函数分析https://leenzhu.com/posts/round_pow2-%E5%87%BD%E6%95%B0%E5%88%86%E6%9E%90.htmlTue, 25 Jul 2023 00:00:00 +0000https://leenzhu.com/posts/round_pow2-%E5%87%BD%E6%95%B0%E5%88%86%E6%9E%90.html<p>网上搜了一圈没有搜到对这个函数的说明。这个函数的名称给我造成一些误解,让我认为这是<strong>四舍五入</strong>的概念,对于浮点数取整一般有3种情况:</p>Golang Binary包使用https://leenzhu.com/posts/golang-binary.htmlMon, 15 May 2023 00:00:00 +0000https://leenzhu.com/posts/golang-binary.html<p>在使用golang的过程需要进行NBNS的报文解析,经调研发现NBNS的报文大都是定长报文,并且需要处理这些报文也不需要太高的性能,所有就决定使用 <code>encoding/binary</code>包来进行编解码。学习过程中对这个包内每个函数都进行尝试并整理出笔记如下。</p>hugo 显相对路径下的图片https://leenzhu.com/posts/hugo-show-buddle-img.htmlWed, 06 Oct 2021 11:36:03 +0800https://leenzhu.com/posts/hugo-show-buddle-img.html<p>很早以前发现 <code>hugo server</code> 命令在本地预览时不能显示相文章相对路径下的图片。但是普通web服务器是可以显示的一直都不知道是什么原因,之前也曾花费大量时间翻遍整个hugo论坛,也没有找到解决方案,因为我的 <code>emacs</code> 可以直接预览图片,发布后也能正常显示图片,后来也就不去管它了。但是今天非常偶然的发现原来 <code>hugo server</code> 也可能预览相对路径的下图片。</p>关于https://leenzhu.com/about.htmlWed, 21 Aug 2019 20:27:06 +0800https://leenzhu.com/about.html简介 2024年,开始学习React,Solidjs,Svelte,不知道算不算49年入国军。 时间线 2021-10-05 正式开站。关于https://leenzhu.com/faq.htmlWed, 21 Aug 2019 20:27:06 +0800https://leenzhu.com/faq.html记录日常学习过程中遇到的问题。 \ No newline at end of file diff --git a/js/Artalk.js b/js/Artalk.js new file mode 100644 index 0000000..0659162 --- /dev/null +++ b/js/Artalk.js @@ -0,0 +1,11 @@ +!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).Artalk={})}(this,(function(e){"use strict";var t,n,s,i,r=Object.defineProperty,o=Object.defineProperties,a=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))h.call(t,n)&&d(e,n,t[n]);return e},p=(e,t)=>o(e,a(t)),g=(e,t,n)=>(d(e,"symbol"!=typeof t?t+"":t,n),n),m=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},f=(e,t,n)=>(((e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)})(e,t,"access private method"),n),k=(e,t,n)=>new Promise(((s,i)=>{var r=e=>{try{a(n.next(e))}catch(t){i(t)}},o=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(r,o);a((n=n.apply(e,t)).next())}));class y{constructor(e={}){g(this,"baseUrl","/api/v2"),g(this,"securityData",null),g(this,"securityWorker"),g(this,"abortControllers",new Map),g(this,"customFetch",((...e)=>fetch(...e))),g(this,"baseApiParams",{credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"}),g(this,"setSecurityData",(e=>{this.securityData=e})),g(this,"contentFormatters",{"application/json":e=>null===e||"object"!=typeof e&&"string"!=typeof e?e:JSON.stringify(e),"text/plain":e=>null!==e&&"string"!=typeof e?JSON.stringify(e):e,"multipart/form-data":e=>Object.keys(e||{}).reduce(((t,n)=>{const s=e[n];return t.append(n,s instanceof Blob?s:"object"==typeof s&&null!==s?JSON.stringify(s):`${s}`),t}),new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)}),g(this,"createAbortSignal",(e=>{if(this.abortControllers.has(e)){const t=this.abortControllers.get(e);return t?t.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal})),g(this,"abortRequest",(e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))})),g(this,"request",(e=>k(this,null,(function*(){var t=e,{body:n,secure:s,path:i,type:r,query:o,format:a,baseUrl:d,cancelToken:g}=t,m=((e,t)=>{var n={};for(var s in e)c.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&l)for(var s of l(e))t.indexOf(s)<0&&h.call(e,s)&&(n[s]=e[s]);return n})(t,["body","secure","path","type","query","format","baseUrl","cancelToken"]);const f=("boolean"==typeof s?s:this.baseApiParams.secure)&&this.securityWorker&&(yield this.securityWorker(this.securityData))||{},y=this.mergeRequestParams(m,f),$=o&&this.toQueryString(o),v=this.contentFormatters[r||"application/json"],b=a||y.format;return this.customFetch(`${d||this.baseUrl||""}${i}${$?`?${$}`:""}`,p(u({},y),{headers:u(u({},y.headers||{}),r&&"multipart/form-data"!==r?{"Content-Type":r}:{}),signal:(g?this.createAbortSignal(g):y.signal)||null,body:null==n?null:v(n)})).then((e=>k(this,null,(function*(){const t=e;t.data=null,t.error=null;const n=b?yield e[b]().then((e=>(t.ok?t.data=e:t.error=e,t))).catch((e=>(t.error=e,t))):t;if(g&&this.abortControllers.delete(g),!e.ok)throw n;return n}))))})))),Object.assign(this,e)}encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent("number"==typeof t?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map((e=>this.encodeQueryParam(t,e))).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter((e=>void 0!==t[e])).map((e=>Array.isArray(t[e])?this.addArrayQueryParam(t,e):this.addQueryParam(t,e))).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}mergeRequestParams(e,t){return p(u(u(u({},this.baseApiParams),e),t||{}),{headers:u(u(u({},this.baseApiParams.headers||{}),e.headers||{}),t&&t.headers||{})})}} +/** + * @title Artalk API + * @version 2.0 + * @license MIT (https://github.com/ArtalkJS/Artalk/blob/master/LICENSE) + * @baseUrl /api/v2 + * @contact API Support (https://artalk.js.org) + * + * Artalk is a modern comment system based on Golang. + */let $=class extends y{constructor(){super(...arguments),g(this,"cache",{flushCache:(e={})=>this.request(u({path:"/cache/flush",method:"POST",secure:!0,format:"json"},e)),warmUpCache:(e={})=>this.request(u({path:"/cache/warm_up",method:"POST",secure:!0,format:"json"},e))}),g(this,"captcha",{getCaptcha:(e={})=>this.request(u({path:"/captcha",method:"GET",format:"json"},e)),getCaptchaStatus:(e={})=>this.request(u({path:"/captcha/status",method:"GET",format:"json"},e)),verifyCaptcha:(e,t={})=>this.request(u({path:"/captcha/verify",method:"POST",body:e,type:"application/json",format:"json"},t))}),g(this,"comments",{getComments:(e,t={})=>this.request(u({path:"/comments",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),createComment:(e,t={})=>this.request(u({path:"/comments",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),updateComment:(e,t,n={})=>this.request(u({path:`/comments/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteComment:(e,t={})=>this.request(u({path:`/comments/${e}`,method:"DELETE",secure:!0,format:"json"},t))}),g(this,"conf",{conf:(e={})=>this.request(u({path:"/conf",method:"GET",format:"json"},e))}),g(this,"notifies",{getNotifies:(e,t={})=>this.request(u({path:"/notifies",method:"GET",query:e,type:"application/json",format:"json"},t)),markAllNotifyRead:(e,t={})=>this.request(u({path:"/notifies/read",method:"POST",body:e,type:"application/json",format:"json"},t)),markNotifyRead:(e,t,n={})=>this.request(u({path:`/notifies/${e}/${t}`,method:"POST",format:"json"},n))}),g(this,"pages",{getPages:(e,t={})=>this.request(u({path:"/pages",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),fetchAllPages:(e,t={})=>this.request(u({path:"/pages/fetch",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),getPageFetchStatus:(e={})=>this.request(u({path:"/pages/fetch/status",method:"GET",secure:!0,format:"json"},e)),logPv:(e,t={})=>this.request(u({path:"/pages/pv",method:"POST",body:e,type:"application/json",format:"json"},t)),updatePage:(e,t,n={})=>this.request(u({path:`/pages/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deletePage:(e,t={})=>this.request(u({path:`/pages/${e}`,method:"DELETE",secure:!0,format:"json"},t)),fetchPage:(e,t={})=>this.request(u({path:`/pages/${e}/fetch`,method:"POST",secure:!0,type:"application/json",format:"json"},t))}),g(this,"sendEmail",{sendEmail:(e,t={})=>this.request(u({path:"/send_email",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t))}),g(this,"settings",{getSettings:(e={})=>this.request(u({path:"/settings",method:"GET",secure:!0,format:"json"},e)),applySettings:(e,t={})=>this.request(u({path:"/settings",method:"PUT",body:e,secure:!0,type:"application/json",format:"json"},t)),getSettingsTemplate:(e,t={})=>this.request(u({path:`/settings/template/${e}`,method:"GET",secure:!0,format:"json"},t))}),g(this,"sites",{getSites:(e={})=>this.request(u({path:"/sites",method:"GET",secure:!0,format:"json"},e)),createSite:(e,t={})=>this.request(u({path:"/sites",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),updateSite:(e,t,n={})=>this.request(u({path:`/sites/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteSite:(e,t={})=>this.request(u({path:`/sites/${e}`,method:"DELETE",secure:!0,format:"json"},t))}),g(this,"stats",{getStats:(e,t,n={})=>this.request(u({path:`/stats/${e}`,method:"GET",query:t,type:"application/json",format:"json"},n))}),g(this,"transfer",{exportArtrans:(e={})=>this.request(u({path:"/transfer/export",method:"GET",secure:!0,format:"json"},e)),importArtrans:(e,t={})=>this.request(u({path:"/transfer/import",method:"POST",body:e,secure:!0,type:"application/json"},t)),uploadArtrans:(e,t={})=>this.request(u({path:"/transfer/upload",method:"POST",body:e,secure:!0,type:"multipart/form-data",format:"json"},t))}),g(this,"upload",{upload:(e,t={})=>this.request(u({path:"/upload",method:"POST",body:e,secure:!0,type:"multipart/form-data",format:"json"},t))}),g(this,"user",{getUser:(e,t={})=>this.request(u({path:"/user",method:"GET",query:e,secure:!0,format:"json"},t)),login:(e,t={})=>this.request(u({path:"/user/access_token",method:"POST",body:e,type:"application/json",format:"json"},t)),getUserStatus:(e,t={})=>this.request(u({path:"/user/status",method:"GET",query:e,secure:!0,format:"json"},t))}),g(this,"users",{createUser:(e,t={})=>this.request(u({path:"/users",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),updateUser:(e,t,n={})=>this.request(u({path:`/users/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteUser:(e,t={})=>this.request(u({path:`/users/${e}`,method:"DELETE",secure:!0,format:"json"},t)),getUsers:(e,t,n={})=>this.request(u({path:`/users/${e}`,method:"GET",query:t,secure:!0,type:"application/json",format:"json"},n))}),g(this,"version",{getVersion:(e={})=>this.request(u({path:"/version",method:"GET",format:"json"},e))}),g(this,"votes",{syncVotes:(e={})=>this.request(u({path:"/votes/sync",method:"POST",secure:!0,format:"json"},e)),vote:(e,t,n,s={})=>this.request(u({path:`/votes/${e}/${t}`,method:"POST",body:n,type:"application/json",format:"json"},s))})}};var v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function b(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}!function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;nk(this,null,(function*(){const s=e.getApiToken&&e.getApiToken(),i=new Headers(u({Authorization:s?`Bearer ${s}`:""},null==n?void 0:n.headers));i.get("Authorization")||i.delete("Authorization");const r=yield fetch(t,p(u({},n),{headers:i}));if(!r.ok){const s=(yield r.json().catch((()=>{})))||{};if(s.need_captcha)return e.onNeedCheckCaptcha&&(yield e.onNeedCheckCaptcha({data:{imgData:s.img_data,iframe:s.iframe}})),w(e,t,n);if(s.need_login)return e.onNeedCheckAdmin&&(yield e.onNeedCheckAdmin({})),w(e,t,n);throw function(e,t){const n=new x;return n.message=t.msg||t.message||"fetch error",n.code=e,n.data=t,console.error(n),n}(r.status,s)}return r}));class x extends Error{constructor(){super(...arguments),g(this,"code",0),g(this,"message","fetch error"),g(this,"data")}}class C extends ${constructor(e){super({baseUrl:e.baseURL,customFetch:(t,n)=>w(e,t,n)}),g(this,"_opts"),this._opts=e}getUserFields(){const e=this._opts.userInfo;if((null==e?void 0:e.name)&&(null==e?void 0:e.email))return{name:e.name,email:e.email}}}function E(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let S={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function T(e){S=e}const A=/[&<>"']/,L=new RegExp(A.source,"g"),R=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,M=new RegExp(R.source,"g"),P={"&":"&","<":"<",">":">",'"':""","'":"'"},O=e=>P[e];function I(e,t){if(t){if(A.test(e))return e.replace(L,O)}else if(R.test(e))return e.replace(M,O);return e}const _=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;const U=/(^|[^\[])\^/g;function q(e,t){let n="string"==typeof e?e:e.source;t=t||"";const s={replace:(e,t)=>{let i="string"==typeof t?t:t.source;return i=i.replace(U,"$1"),n=n.replace(e,i),s},getRegex:()=>new RegExp(n,t)};return s}function D(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(t){return null}return e}const j={exec:()=>null};function B(e,t){const n=e.replace(/\|/g,((e,t,n)=>{let s=!1,i=t;for(;--i>=0&&"\\"===n[i];)s=!s;return s?"|":" |"})).split(/ \|/);let s=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:F(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const s=n[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=s.length?e.slice(s.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=F(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const e=F(t[0].replace(/^ *>[ \t]?/gm,""),"\n"),n=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:s,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const s=n.length>1,i={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");const r=new RegExp(`^( {0,3}${n})((?:[\t ][^\\n]*)?(?:\\n|$))`);let o="",a="",l=!1;for(;e;){let n=!1;if(!(t=r.exec(e)))break;if(this.rules.block.hr.test(e))break;o=t[0],e=e.substring(o.length);let s=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),c=e.split("\n",1)[0],h=0;this.options.pedantic?(h=2,a=s.trimStart()):(h=t[2].search(/[^ ]/),h=h>4?1:h,a=s.slice(h),h+=t[1].length);let d=!1;if(!s&&/^ *$/.test(c)&&(o+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),n=new RegExp(`^ {0,${Math.min(3,h-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),i=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:\`\`\`|~~~)`),r=new RegExp(`^ {0,${Math.min(3,h-1)}}#`);for(;e;){const l=e.split("\n",1)[0];if(c=l,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),i.test(c))break;if(r.test(c))break;if(t.test(c))break;if(n.test(e))break;if(c.search(/[^ ]/)>=h||!c.trim())a+="\n"+c.slice(h);else{if(d)break;if(s.search(/[^ ]/)>=4)break;if(i.test(s))break;if(r.test(s))break;if(n.test(s))break;a+="\n"+c}d||c.trim()||(d=!0),o+=l+"\n",e=e.substring(l.length+1),s=c.slice(h)}}i.loose||(l?i.loose=!0:/\n *\n *$/.test(o)&&(l=!0));let u,p=null;this.options.gfm&&(p=/^\[[ xX]\] /.exec(a),p&&(u="[ ] "!==p[0],a=a.replace(/^\[[ xX]\] +/,""))),i.items.push({type:"list_item",raw:o,task:!!p,checked:u,loose:!1,text:a,tokens:[]}),i.raw+=o}i.items[i.items.length-1].raw=o.trimEnd(),i.items[i.items.length-1].text=a.trimEnd(),i.raw=i.raw.trimEnd();for(let e=0;e"space"===e.type)),n=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));i.loose=n}if(i.loose)for(let e=0;e$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const n=B(t[1]),s=t[2].replace(/^\||\| *$/g,"").split("|"),i=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(const e of s)/^ *-+: *$/.test(e)?r.align.push("right"):/^ *:-+: *$/.test(e)?r.align.push("center"):/^ *:-+ *$/.test(e)?r.align.push("left"):r.align.push(null);for(const e of n)r.header.push({text:e,tokens:this.lexer.inline(e)});for(const e of i)r.rows.push(B(e,r.header.length).map((e=>({text:e,tokens:this.lexer.inline(e)}))));return r}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:I(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^$/.test(e))return;const t=F(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let s=0;s-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],s="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],s=e[3])}else s=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^$/.test(e)?n.slice(1):n.slice(1,-1)),N(t,{href:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n,title:s?s.replace(this.rules.inline.anyPunctuation,"$1"):s},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const e=t[(n[2]||n[1]).replace(/\s+/g," ").toLowerCase()];if(!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return N(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s)return;if(s[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const n=[...s[0]].length-1;let i,r,o=n,a=0;const l="*"===s[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+n);null!=(s=l.exec(t));){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(r=[...i].length,s[3]||s[4]){o+=r;continue}if((s[5]||s[6])&&n%3&&!((n+r)%3)){a+=r;continue}if(o-=r,o>0)continue;r=Math.min(r,r+o+a);const t=[...s[0]][0].length,l=e.slice(0,n+s.index+t+r);if(Math.min(n,r)%2){const e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}const c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),s=/^ /.test(e)&&/ $/.test(e);return n&&s&&(e=e.substring(1,e.length-1)),e=I(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=I(t[1]),n="mailto:"+e):(e=I(t[1]),n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){var t,n;let s;if(s=this.rules.inline.url.exec(e)){let e,i;if("@"===s[2])e=I(s[0]),i="mailto:"+e;else{let r;do{r=s[0],s[0]=null!=(n=null==(t=this.rules.inline._backpedal.exec(s[0]))?void 0:t[0])?n:""}while(r!==s[0]);e=I(s[0]),i="www."===s[1]?"http://"+s[0]:s[0]}return{type:"link",raw:s[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:I(t[0]),{type:"text",raw:t[0],text:e}}}}const z=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,H=/(?:[*+-]|\d{1,9}[.)])/,Q=q(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,H).getRegex(),G=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,V=/(?!\s*\])(?:\\.|[^\[\]\\])+/,K=q(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",V).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Z=q(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,H).getRegex(),Y="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",X=/|$)/,J=q("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",X).replace("tag",Y).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ee=q(G).replace("hr",z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Y).getRegex(),te={blockquote:q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ee).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:K,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:z,html:J,lheading:Q,list:Z,newline:/^(?: *(?:\n|$))+/,paragraph:ee,table:j,text:/^[^\n]+/},ne=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Y).getRegex(),se=p(u({},te),{table:ne,paragraph:q(G).replace("hr",z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ne).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Y).getRegex()}),ie=p(u({},te),{html:q("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",X).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:j,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(G).replace("hr",z).replace("heading"," *#{1,6} *[^\n]").replace("lheading",Q).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()}),re=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,oe=/^( {2,}|\\)\n(?!\s*$)/,ae="\\p{P}$+<=>`^|~",le=q(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,ae).getRegex(),ce=q(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,ae).getRegex(),he=q("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,ae).getRegex(),de=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,ae).getRegex(),ue=q(/\\([punct])/,"gu").replace(/punct/g,ae).getRegex(),pe=q(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[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])?)+(?![-_])/).getRegex(),ge=q(X).replace("(?:--\x3e|$)","--\x3e").getRegex(),me=q("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment",ge).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),fe=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ke=q(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",fe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ye=q(/^!?\[(label)\]\[(ref)\]/).replace("label",fe).replace("ref",V).getRegex(),$e=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",V).getRegex(),ve={_backpedal:j,anyPunctuation:ue,autolink:pe,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:oe,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:j,emStrongLDelim:ce,emStrongRDelimAst:he,emStrongRDelimUnd:de,escape:re,link:ke,nolink:$e,punctuation:le,reflink:ye,reflinkSearch:q("reflink|nolink(?!\\()","g").replace("reflink",ye).replace("nolink",$e).getRegex(),tag:me,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\t+" ".repeat(n.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((s=>!!(n=s.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),1===n.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?t.push(n):(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(s.raw+="\n"+n.raw,s.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(i=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const n=e.slice(1);let s;this.options.extensions.startBlock.forEach((e=>{s=e.call({lexer:this},n),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i)))s=t[t.length-1],r&&"paragraph"===s.type?(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n),r=i.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===s.type?(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,s,i,r,o,a,l=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(l));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(l));)l=l.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.anyPunctuation.exec(l));)l=l.slice(0,r.index)+"++"+l.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(o||(a=""),o=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((s=>!!(n=s.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===n.type&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===n.type&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,l,a))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e))){if(i=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const n=e.slice(1);let s;this.options.extensions.startInline.forEach((e=>{s=e.call({lexer:this},n),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(i))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(a=n.raw.slice(-1)),o=!0,s=t[t.length-1],s&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(n.raw.length),t.push(n);return t}}class Te{constructor(e){g(this,"options"),this.options=e||S}code(e,t,n){var s;const i=null==(s=(t||"").match(/^\S*/))?void 0:s[0];return e=e.replace(/\n$/,"")+"\n",i?'
      '+(n?e:I(e,!0))+"
      \n":"
      "+(n?e:I(e,!0))+"
      \n"}blockquote(e){return`
      \n${e}
      \n`}html(e,t){return e}heading(e,t,n){return`${e}\n`}hr(){return"
      \n"}list(e,t,n){const s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"\n"}listitem(e,t,n){return`
    • ${e}
    • \n`}checkbox(e){return"'}paragraph(e){return`

      ${e}

      \n`}table(e,t){return t&&(t=`${t}`),"\n\n"+e+"\n"+t+"
      \n"}tablerow(e){return`\n${e}\n`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`\n`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return"
      "}del(e){return`${e}`}link(e,t,n){const s=D(e);if(null===s)return n;let i='
      ",i}image(e,t,n){const s=D(e);if(null===s)return n;let i=`${n}"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):"")));continue}case"code":{const e=i;n+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=i;let t="",s="";for(let n=0;n0&&"paragraph"===t.tokens[0].type?(t.tokens[0].text=e+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&"text"===t.tokens[0].tokens[0].type&&(t.tokens[0].tokens[0].text=e+" "+t.tokens[0].tokens[0].text)):t.tokens.unshift({type:"text",text:e+" "}):a+=e+" "}a+=this.parse(t.tokens,r),o+=this.renderer.listitem(a,i,!!s)}n+=this.renderer.list(o,t,s);continue}case"html":{const e=i;n+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=i;n+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let r=i,o=r.tokens?this.parseInline(r.tokens):r.text;for(;s+1{const o=u({},r),a=u(u({},this.defaults),o);!0===this.defaults.async&&!1===o.async&&(a.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),a.async=!0);const l=f(this,s,i).call(this,!!a.silent,!!a.async);if(null==n)return l(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(a.hooks&&(a.hooks.options=a),a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(n):n).then((t=>e(t,a))).then((e=>a.hooks?a.hooks.processAllTokens(e):e)).then((e=>a.walkTokens?Promise.all(this.walkTokens(e,a.walkTokens)).then((()=>e)):e)).then((e=>t(e,a))).then((e=>a.hooks?a.hooks.postprocess(e):e)).catch(l);try{a.hooks&&(n=a.hooks.preprocess(n));let s=e(n,a);a.hooks&&(s=a.hooks.processAllTokens(s)),a.walkTokens&&this.walkTokens(s,a.walkTokens);let i=t(s,a);return a.hooks&&(i=a.hooks.postprocess(i)),i}catch(c){return l(c)}}},s=new WeakSet,i=function(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="

      An error occurred:

      "+I(n.message+"",!0)+"
      ";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}};const Me=new class{constructor(...e){m(this,t),m(this,s),g(this,"defaults",{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}),g(this,"options",this.setOptions),g(this,"parse",f(this,t,n).call(this,Se.lex,Le.parse)),g(this,"parseInline",f(this,t,n).call(this,Se.lexInline,Le.parseInline)),g(this,"Parser",Le),g(this,"Renderer",Te),g(this,"TextRenderer",Ae),g(this,"Lexer",Se),g(this,"Tokenizer",W),g(this,"Hooks",Re),this.use(...e)}walkTokens(e,t){var n,s;let i=[];for(const r of e)switch(i=i.concat(t.call(this,r)),r.type){case"table":{const e=r;for(const n of e.header)i=i.concat(this.walkTokens(n.tokens,t));for(const n of e.rows)for(const e of n)i=i.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=r;i=i.concat(this.walkTokens(e.items,t));break}default:{const e=r;(null==(s=null==(n=this.defaults.extensions)?void 0:n.childTokens)?void 0:s[e.type])?this.defaults.extensions.childTokens[e.type].forEach((n=>{const s=e[n].flat(1/0);i=i.concat(this.walkTokens(s,t))})):e.tokens&&(i=i.concat(this.walkTokens(e.tokens,t)))}}return i}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const n=u({},e);if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let s=e.renderer.apply(this,t);return!1===s&&(s=n.apply(this,t)),s}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){const t=this.defaults.renderer||new Te(this.defaults);for(const n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if("options"===n)continue;const s=n,i=e.renderer[s],r=t[s];t[s]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=r.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new W(this.defaults);for(const n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const s=n,i=e.tokenizer[s],r=t[s];t[s]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new Re;for(const n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if("options"===n)continue;const s=n,i=e.hooks[s],r=t[s];Re.passThroughHooks.has(n)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then((e=>r.call(t,e)));const n=i.call(t,e);return r.call(t,n)}:t[s]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,s=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(s.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults=u(u({},this.defaults),n)})),this}setOptions(e){return this.defaults=u(u({},this.defaults),e),this}lexer(e,t){return Se.lex(e,null!=t?t:this.defaults)}parser(e,t){return Le.parse(e,null!=t?t:this.defaults)}};function Pe(e,t){return Me.parse(e,t)}Pe.options=Pe.setOptions=function(e){return Me.setOptions(e),Pe.defaults=Me.defaults,T(Pe.defaults),Pe},Pe.getDefaults=E,Pe.defaults=S,Pe.use=function(...e){return Me.use(...e),Pe.defaults=Me.defaults,T(Pe.defaults),Pe},Pe.walkTokens=function(e,t){return Me.walkTokens(e,t)},Pe.parseInline=Me.parseInline,Pe.Parser=Le,Pe.parser=Le.parse,Pe.Renderer=Te,Pe.TextRenderer=Ae,Pe.Lexer=Se,Pe.lexer=Se.lex,Pe.Tokenizer=W,Pe.Hooks=Re,Pe.parse=Pe,Pe.options,Pe.setOptions,Pe.use,Pe.walkTokens,Pe.parseInline,Le.parse,Se.lex;var Oe={"&":"&","<":"<",">":">",'"':""","'":"'"},Ie={"&":"&","<":"<",">":">",""":'"',"'":"'"},_e=/(&|<|>|"|')/g,Ue=/[&<>"']/g;function qe(e){return Oe[e]}function De(e){return Ie[e]}function je(e){return null==e?"":String(e).replace(Ue,qe)}function Be(e){return null==e?"":String(e).replace(_e,De)}je.options=Be.options={};var Fe={encode:je,escape:je,decode:Be,unescape:Be,version:"1.0.0-browser"};var Ne=function e(t){for(var n,s,i=Array.prototype.slice.call(arguments,1);i.length;)for(s in n=i.shift())n.hasOwnProperty(s)&&("[object Object]"===Object.prototype.toString.call(t[s])?t[s]=e(t[s],n[s]):t[s]=n[s]);return t},We=function(e){return"string"==typeof e?e.toLowerCase():e};function ze(e,t){return e[t]=!0,e}var He=function(e){return e.reduce(ze,{})},Qe={uris:He(["background","base","cite","href","longdesc","src","usemap"])},Ge={voids:He(["area","br","col","hr","img","wbr","input","base","basefont","link","meta"])},Ve=Fe,Ke=We,Ze=Ge,Ye=/^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/,Xe=/^<\s*\/\s*([\w:-]+)[^>]*>/,Je=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,et=/^=0&&(t.comment&&t.comment(e.substring(4,s)),e=e.substring(s+3),n=!1):tt.test(e)?o(Xe,l):et.test(e)&&o(Ye,a);var s;!function(){if(!n)return;var s,i=e.indexOf("<");i>=0?(s=e.substring(0,i),e=e.substring(i)):(s=e,e="");t.chars&&t.chars(s)}()}();var s=e===i;i=e,s&&(e="")}function o(t,s){var i=e.match(t);i&&(e=e.substring(i[0].length),i[0].replace(t,s),n=!1)}function a(e,n,i,r){var o={},a=Ke(n),l=Ze.voids[a]||!!r;i.replace(Je,(function(e,t,n,s,i){o[t]=void 0===n&&void 0===s&&void 0===i?void 0:Ve.decode(n||s||i||"")})),l||s.push(a),t.start&&t.start(a,o,l)}function l(e,n){var i,r=0,o=Ke(n);if(o)for(r=s.length-1;r>=0&&s[r]!==o;r--);if(r>=0){for(i=s.length-1;i>=r;i--)t.end&&t.end(s[i]);s.length=r}}l()},lt=function(e,t){var n,s=t||{};return a(),{start:function(e,t,o){var a=st(e);if(n.ignoring)return void r(a);if(-1===(s.allowedTags||[]).indexOf(a))return void r(a);if(s.filter&&!s.filter({tag:a,attrs:t}))return void r(a);i("<"),i(a),Object.keys(t).forEach((function(e){var n=t[e],r=(s.allowedClasses||{})[a]||[],o=(s.allowedAttributes||{})[a]||[],l=st(e);("class"===l&&-1===o.indexOf(l)?(n=n.split(" ").filter((function(e){return r&&-1!==r.indexOf(e)})).join(" ").trim()).length:-1!==o.indexOf(l)&&(!0!==it.uris[l]||function(e){var t=e[0];if("#"===t||"/"===t)return!0;var n=e.indexOf(":");if(-1===n)return!0;var i=e.indexOf("?");if(-1!==i&&n>i)return!0;var r=e.indexOf("#");return-1!==r&&n>r||s.allowedSchemes.some(o);function o(t){return 0===e.indexOf(t+":")}}(n)))&&(i(" "),i(e),"string"==typeof n&&(i('="'),i(nt.encode(n)),i('"')))})),i(o?"/>":">")},end:function(e){var t=st(e);-1!==(s.allowedTags||[]).indexOf(t)&&!1===n.ignoring?(i("")):o(t)},chars:function(e){!1===n.ignoring&&i(s.transformText?s.transformText(e):e)}};function i(t){e.push(t)}function r(e){rt.voids[e]||(!1===n.ignoring?n={ignoring:e,depth:1}:n.ignoring===e&&n.depth++)}function o(e){n.ignoring===e&&--n.depth<=0&&a()}function a(){n={ignoring:!1,depth:0}}},ct={allowedAttributes:{a:["href","name","target","title","aria-label"],iframe:["allowfullscreen","frameborder","src"],img:["src","alt","title","aria-label"]},allowedClasses:{},allowedSchemes:["http","https","mailto"],allowedTags:["a","abbr","article","b","blockquote","br","caption","code","del","details","div","em","h1","h2","h3","h4","h5","h6","hr","i","img","ins","kbd","li","main","mark","ol","p","pre","section","span","strike","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],filter:null};function ht(e,t,n){var s=[],i=!0===n?t:ot({},ct,t),r=lt(s,i);return at(e,r),s.join("")}ht.defaults=ct;const dt=b(ht),ut={allowedClasses:{},allowedSchemes:["http","https","mailto","data"],allowedTags:["a","abbr","article","b","blockquote","br","caption","code","del","details","div","em","h1","h2","h3","h4","h5","h6","hr","i","img","ins","kbd","li","main","mark","ol","p","pre","section","span","strike","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],allowedAttributes:{"*":["title","accesskey"],a:["href","name","target","aria-label","rel"],img:["src","alt","title","atk-emoticon","aria-label"],code:["class"],span:["class","style"]},filter:e=>([["code",/^hljs\W+language-(.*)$/],["span",/^(hljs-.*)$/]].forEach((([t,n])=>{e.tag===t&&e.attrs.class&&!n.test(e.attrs.class)&&delete e.attrs.class})),"span"===e.tag&&e.attrs.style&&!/^color:(\W+)?#[0-9a-f]{3,6};?$/i.test(e.attrs.style)&&delete e.attrs.style,!0)};function pt(e){return dt(e,ut)}var gt={exports:{}};gt.exports=function(){function e(e,t){return e(t={exports:{}},t.exports),t.exports}var t=e((function(e){var t=e.exports=function(){return new RegExp("(?:"+t.line().source+")|(?:"+t.block().source+")","gm")};t.line=function(){return/(?:^|\s)\/\/(.+?)$/gm},t.block=function(){return/\/\*([\S\s]*?)\*\//gm}})),n=["23AC69","91C132","F19726","E8552D","1AAB8E","E1147F","2980C1","1BA1E6","9FA0A0","F19726","E30B20","E30B20","A3338B"];function s(e){return''+e+""}return function(e,i){void 0===i&&(i={});var r=i.colors;void 0===r&&(r=n);var o=0,a={},l=new RegExp("("+/[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/.source+"|"+/'+t+"";return o=++o%r.length,l}))}}();const mt=b(gt.exports);function ft(e){return mt(e)}function kt(){const e=new Pe.Renderer;return e.link=yt(e,e.link),e.code=$t(),e}const yt=(e,t)=>(n,s,i)=>{const r=null==n?void 0:n.startsWith(`${window.location.protocol}//${window.location.hostname}`);return t.call(e,n,s,i).replace(/^
      (e,t)=>{const n=t||"plaintext";let s=e;return window.hljs?n&&window.hljs.getLanguage(n)&&(s=window.hljs.highlight(n,e).value):s=ft(e),`
      \n${s.replace(/&/g,"&")}\n
      `};let vt,bt=[];const wt={gfm:!0,breaks:!0,async:!1};function xt(){return vt}function Ct(e){var t;let n=null==(t=xt())?void 0:t.parse(e);n||(n=function(e){return e.replace(/```\s*([^]+?.*?[^]+?[^]+?)```/g,((e,t)=>`
      ${ft(t)}
      `)).replace(/!\[(.*?)\]\((.*?)\)/g,((e,t,n)=>`${t}`)).replace(/\[(.*?)\]\((.*?)\)/g,((e,t,n)=>`
      ${t}`)).replace(/\n/g,"
      ")}(e));let s=pt(n);return bt.forEach((e=>{"function"==typeof e&&(s=e(s))})),s}function Et(...e){const t=e=>e&&"object"==typeof e&&e.constructor===Object;return e.reduce(((e,n)=>(Object.keys(null!=n?n:{}).forEach((s=>{if("__proto__"===s||"constructor"===s||"prototype"===s)return;const i=e[s],r=n[s];Array.isArray(i)&&Array.isArray(r)?e[s]=i.concat(...r):t(i)&&t(r)?e[s]=Et(i,r):e[s]=r})),e)),{})}class St{constructor(e){g(this,"loading",!1),g(this,"listLastFetch"),g(this,"comments",[]),g(this,"notifies",[]),g(this,"page"),this.events=e}getLoading(){return this.loading}setLoading(e){this.loading=e}getListLastFetch(){return this.listLastFetch}setListLastFetch(e){this.listLastFetch=e}getComments(){return this.comments}fetchComments(e){this.events.trigger("list-fetch",e)}findComment(e){return this.comments.find((t=>t.id===e))}clearComments(){this.comments=[],this.events.trigger("list-loaded",this.comments)}loadComments(e){this.events.trigger("list-load",e),this.comments.push(...e),this.events.trigger("list-loaded",this.comments)}insertComment(e){this.comments.push(e),this.events.trigger("comment-inserted",e),this.events.trigger("list-loaded",this.comments)}updateComment(e){this.comments=this.comments.map((t=>t.id===e.id?e:t)),this.events.trigger("comment-updated",e),this.events.trigger("list-loaded",this.comments)}deleteComment(e){const t=this.comments.find((t=>t.id===e));if(!t)throw new Error(`Comment ${e} not found`);this.comments=this.comments.filter((t=>t.id!==e)),this.events.trigger("comment-deleted",t),this.events.trigger("list-loaded",this.comments)}getNotifies(){return this.notifies}updateNotifies(e){this.notifies=e,this.events.trigger("notifies-updated",this.notifies)}getPage(){return this.page}updatePage(e){this.page=e,this.events.trigger("page-loaded",e)}}const Tt={placeholder:"Leave a comment",noComment:"No Comment",send:"Send",save:"Save",nick:"Nickname",email:"Email",link:"Website",emoticon:"Emoji",preview:"Preview",image:"Image",uploadFail:"Upload Failed",commentFail:"Failed to comment",restoredMsg:"Content has been restored",onlyAdminCanReply:"Only admin can reply",uploadLoginMsg:"Please fill in your name and email to upload",counter:"{count} Comments",sortLatest:"Latest",sortOldest:"Oldest",sortBest:"Best",sortAuthor:"Author",openComment:"Open Comment",closeComment:"Close Comment",listLoadFailMsg:"Failed to load comments",listRetry:"Retry",loadMore:"Load More",admin:"Admin",reply:"Reply",voteUp:"Up",voteDown:"Down",voteFail:"Vote Failed",readMore:"Read More",actionConfirm:"Confirm",collapse:"Collapse",collapsed:"Collapsed",collapsedMsg:"This comment has been collapsed",expand:"Expand",approved:"Approved",pending:"Pending",pendingMsg:"Pending, visible only to commenter.",edit:"Edit",editCancel:"Cancel Edit",delete:"Delete",deleteConfirm:"Confirm",pin:"Pin",unpin:"Unpin",seconds:"seconds ago",minutes:"minutes ago",hours:"hours ago",days:"days ago",now:"just now",adminCheck:"Enter admin password:",captchaCheck:"Enter the CAPTCHA to continue:",confirm:"Confirm",cancel:"Cancel",msgCenter:"Messages",ctrlCenter:"Admin",frontend:"Frontend",backend:"Backend",loading:"Loading",loadFail:"Load Failed",editing:"Editing",editFail:"Edit Failed",deleting:"Deleting",deleteFail:"Delete Failed",reqGot:"Request got",reqAborted:"Request timed out or terminated unexpectedly",updateMsg:"Please update Artalk {name} to get the full experience",currentVersion:"Current Version",ignore:"Ignore",open:"Open",openName:"Open {name}"},At="ArtalkI18n";function Lt(e=""){const t=document.createElement("div");return t.innerHTML=e.trim(),t.firstElementChild||t}function Rt(e){return parseFloat(getComputedStyle(e,null).height.replace("px",""))}function Mt(e){const t=document.createElement("div");t.innerText=e;return t.innerHTML}function Pt(e){const t=RegExp(`[?&]${e}=([^&]*)`).exec(window.location.search);return t&&decodeURIComponent(t[1].replace(/\+/g," "))}function Ot(e,t){const n=e=>{const t=e.getBoundingClientRect(),n=window.pageXOffset||document.documentElement.scrollLeft,s=window.pageYOffset||document.documentElement.scrollTop;return{top:t.top+s,left:t.left+n}},s=n(e);if(!t)return s;const i=n(t);return{top:s.top-i.top,left:s.left-i.left}}function It(e,t){let n=e.toString();for(;n.lengthe)){try{const n=e.getTime(),s=(new Date).getTime()-n,i=Math.floor(s/864e5);if(0===i){const e=s%864e5,n=Math.floor(e/36e5);if(0===n){const n=e%36e5,s=Math.floor(n/6e4);if(0===s){const e=n%6e4,s=Math.round(e/1e3);return s<10?t("now"):`${s} ${t("seconds")}`}return`${s} ${t("minutes")}`}return`${n} ${t("hours")}`}return i<0?t("now"):i<8?`${i} ${t("days")}`:function(e){const t=It(e.getDate(),2),n=It(e.getMonth()+1,2);return`${It(e.getFullYear(),2)}-${n}-${t}`}(e)}catch(n){return console.error(n)," - "}}function Ut(){return k(this,null,(function*(){const e=navigator.userAgent;if(!navigator.userAgentData||!navigator.userAgentData.getHighEntropyValues)return e;const t=navigator.userAgentData;let n=null;try{n=yield t.getHighEntropyValues(["platformVersion"])}catch(i){return console.error(i),e}const s=Number(n.platformVersion.split(".")[0]);return"Windows"===t.platform&&s>=13?e.replace(/Windows NT 10.0/,"Windows NT 11.0"):"macOS"===t.platform&&s>=11?e.replace(/(Mac OS X \d+_\d+_\d+|Mac OS X)/,`Mac OS X ${n.platformVersion.replace(/\./g,"_")}`):e}))}function qt(e){let t;try{t=new URL(e)}catch(n){return!1}return"http:"===t.protocol||"https:"===t.protocol}function Dt(e){return t=e.base,n=e.path,`${t.replace(/\/$/,"")}/${n.replace(/^\//,"")}`;var t,n}const jt={en:Tt,"en-US":Tt,"zh-CN":{placeholder:"键入内容...",noComment:"「此时无声胜有声」",send:"发送评论",save:"保存评论",nick:"昵称",email:"邮箱",link:"网址",emoticon:"表情",preview:"预览",image:"图片",uploadFail:"上传失败",commentFail:"评论失败",restoredMsg:"内容已自动恢复",onlyAdminCanReply:"仅管理员可评论",uploadLoginMsg:"填入你的名字邮箱才能上传哦",counter:"{count} 条评论",sortLatest:"最新",sortOldest:"最早",sortBest:"最热",sortAuthor:"作者",openComment:"打开评论",closeComment:"关闭评论",listLoadFailMsg:"无法获取评论列表数据",listRetry:"点击重新获取",loadMore:"加载更多",admin:"管理员",reply:"回复",voteUp:"赞同",voteDown:"反对",voteFail:"投票失败",readMore:"阅读更多",actionConfirm:"确认操作",collapse:"折叠",collapsed:"已折叠",collapsedMsg:"该评论已被系统或管理员折叠",expand:"展开",approved:"已审",pending:"待审",pendingMsg:"审核中,仅本人可见。",edit:"编辑",editCancel:"取消编辑",delete:"删除",deleteConfirm:"确认删除",pin:"置顶",unpin:"取消置顶",seconds:"秒前",minutes:"分钟前",hours:"小时前",days:"天前",now:"刚刚",adminCheck:"键入密码来验证管理员身份:",captchaCheck:"键入验证码继续:",confirm:"确认",cancel:"取消",msgCenter:"通知中心",ctrlCenter:"控制中心",frontend:"前端",backend:"后端",loading:"加载中",loadFail:"加载失败",editing:"修改中",editFail:"修改失败",deleting:"删除中",deleteFail:"删除失败",reqGot:"请求响应",reqAborted:"请求超时或意外终止",updateMsg:"请更新 Artalk {name} 以获得完整体验",currentVersion:"当前版本",ignore:"忽略",open:"打开",openName:"打开{name}"}};function Bt(e){return e=e.replace(/^([a-zA-Z]+)(-[a-zA-Z]+)?$/,((e,t,n)=>t.toLowerCase()+(n||"").toUpperCase())),jt[e]?jt[e]:window[At]&&window[At][e]?window[At][e]:jt.en}let Ft="en",Nt=Bt(Ft);function Wt(e){e!==Ft&&(Ft=e,Nt="string"==typeof e?Bt(e):e)}function zt(e,t={}){let n=(null==Nt?void 0:Nt[e])||e;return n=n.replace(/\{\s*(\w+?)\s*\}/g,((e,n)=>t[n]||"")),Mt(n)}class Ht{constructor(){g(this,"events",[])}on(e,t,n={}){this.events.push(u({name:e,handler:t},n))}off(e,t){t&&(this.events=this.events.filter((n=>!(n.name===e&&n.handler===t))))}trigger(e,t){this.events.slice(0).filter((t=>t.name===e&&"function"==typeof t.handler)).forEach((n=>{n.once&&this.off(e,n.handler),n.handler(t)}))}}const Qt={el:"",pageKey:"",pageTitle:"",server:"",site:"",placeholder:"",noComment:"",sendBtn:"",darkMode:!1,editorTravel:!0,flatMode:"auto",nestMax:2,nestSort:"DATE_ASC",emoticons:"https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json",vote:!0,voteDown:!1,uaBadge:!0,listSort:!0,preview:!0,countEl:"#ArtalkCount",pvEl:"#ArtalkPV",gravatar:{mirror:"https://cravatar.cn/avatar/",params:"d=mp&s=240"},pagination:{pageSize:20,readMore:!0,autoLoad:!0},heightLimit:{content:300,children:400,scrollable:!1},imgUpload:!0,reqTimeout:15e3,versionCheck:!0,useBackendConf:!0,locale:"en"};function Gt(e,t=!1){const n=t?Et(Qt,e):e;if(n.el&&"string"==typeof n.el)try{const e=document.querySelector(n.el);if(!e)throw Error(`Target element "${n.el}" was not found.`);n.el=e}catch(s){throw console.error(s),new Error("Please check your Artalk `el` config.")}return""===n.pageKey&&(n.pageKey=`${window.location.pathname}`),""===n.pageTitle&&(n.pageTitle=`${document.title}`),n.server&&(n.server=n.server.replace(/\/$/,"").replace(/\/api\/?$/,"")),"auto"===n.locale&&(n.locale=navigator.language),"auto"===n.flatMode&&(n.flatMode=window.matchMedia("(max-width: 768px)").matches),"number"==typeof n.nestMax&&Number(n.nestMax)<=1&&(n.flatMode=!0),n}function Vt(e,t){return{baseURL:`${e.server}/api/v2`,siteName:e.site||"",pageKey:e.pageKey||"",pageTitle:e.pageTitle||"",timeout:e.reqTimeout,getApiToken:()=>null==t?void 0:t.get("user").getData().token,userInfo:(null==t?void 0:t.get("user").checkHasBasicUserInfo())?{name:null==t?void 0:t.get("user").getData().nick,email:null==t?void 0:t.get("user").getData().email}:void 0,onNeedCheckAdmin:e=>{if(!t)throw new Error("`ctx` is required when `onNeedCheckAdmin` is called.");return t.checkAdmin({})},onNeedCheckCaptcha:e=>{if(!t)throw new Error("`ctx` is required when `onNeedCheckCaptcha` is called.");return t.checkCaptcha({imgData:e.data.imgData,iframe:e.data.iframe})}}}function Kt(e,t,n){let s=null;const i=()=>{const i=(()=>{const n=e.getConf(),s={};return t.forEach((e=>{s[e]=n[e]})),s})();var r,o;(null==s||(r=s,o=i,!(JSON.stringify(r)===JSON.stringify(o))))&&(s=i,n(i))};e.on("mounted",i),e.on("updated",i)}class Zt{constructor(e){g(this,"conf"),g(this,"data"),g(this,"$root"),g(this,"events",new Ht),g(this,"mounted",!1),g(this,"getCommentList",this.getCommentNodes),g(this,"getCommentDataList",this.getComments),this.conf=e,this.$root=e.el,this.$root.classList.add("artalk"),this.$root.innerHTML="",this.data=new St(this.events),this.on("mounted",(()=>{this.mounted=!0}))}inject(e,t){this[e]=t}get(e){return this[e]}getApi(){return new C(Vt(this.conf,this))}getData(){return this.data}replyComment(e,t){this.editor.setReply(e,t)}editComment(e,t){this.editor.setEditComment(e,t)}fetch(e){this.data.fetchComments(e)}reload(){this.data.fetchComments({offset:0})}listGotoFirst(){this.events.trigger("list-goto-first")}getCommentNodes(){return this.list.getCommentNodes()}getComments(){return this.data.getComments()}editorShowLoading(){this.editor.showLoading()}editorHideLoading(){this.editor.hideLoading()}editorShowNotify(e,t){this.editor.showNotify(e,t)}editorResetState(){this.editor.resetState()}showSidebar(e){this.sidebarLayer.show(e)}hideSidebar(){this.sidebarLayer.hide()}checkAdmin(e){return this.checkerLauncher.checkAdmin(e)}checkCaptcha(e){return this.checkerLauncher.checkCaptcha(e)}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}trigger(e,t){this.events.trigger(e,t)}$t(e,t={}){return zt(e,t)}setDarkMode(e){this.updateConf({darkMode:e})}updateConf(e){this.conf=Et(this.conf,Gt(e,!1)),this.mounted&&this.events.trigger("updated",this.conf)}getConf(){return this.conf}getEl(){return this.$root}getMarked(){return xt()}watchConf(e,t){Kt(this,e,t)}}class Yt{constructor(e){g(this,"$el"),g(this,"$content"),g(this,"$actions"),this.$el=Lt('
      \n
      \n
      \n
      \n
      \n
      '),this.$actions=this.$el.querySelector(".atk-layer-dialog-actions"),this.$content=this.$el.querySelector(".atk-layer-dialog-content"),this.$content.appendChild(e)}setYes(e){const t=Lt(``);return t.onclick=this.onBtnClick(e),this.$actions.appendChild(t),this}setNo(e){const t=Lt(``);return t.onclick=this.onBtnClick(e),this.$actions.appendChild(t),this}onBtnClick(e){return t=>{const n=e(t.currentTarget,this);void 0!==n&&!0!==n||this.$el.remove()}}}function Xt(e,t){let n=e.querySelector(":scope > .atk-loading");n||(n=Lt(''),(null==t?void 0:t.transparentBg)&&(n.style.background="transparent"),e.appendChild(n)),n.style.display="";const s=n.querySelector(".atk-loading-spinner");s&&(s.style.display="none",window.setTimeout((()=>{s.style.display=""}),500))}function Jt(e){const t=e.querySelector(":scope > .atk-loading");t&&(t.style.display="none")}function en(e,t){e?Xt(t):Jt(t)}function tn(e,t=!0,n){let s;if(n){const t=n.getBoundingClientRect();s=e.getBoundingClientRect().top-t.top+n.scrollTop,s+=Rt(n)/2-Rt(e)/2}else{const t=e.getBoundingClientRect();s=t.top+window.scrollY-(window.innerHeight/2-t.height/2)}const i={top:s,left:0,behavior:"instant"};n?n.scroll(i):window.scroll(i)}function nn(e,t){!function(e,t,n="in"){e.classList.add(`atk-fade-${n}`);const s=()=>{e.classList.remove(`atk-fade-${n}`),e.removeEventListener("animationend",s),t&&t()};e.addEventListener("animationend",s)}(e,t,"in")}function sn(e,t,n='Artalk Error'){let s=e.querySelector(".atk-error-layer");if(null===t)return void(null!==s&&s.remove());s||(s=Lt(`
      ${n}
      `),e.appendChild(s));const i=s.querySelector(".atk-error-text");i.innerHTML="",null!==t&&(t instanceof HTMLElement?i.appendChild(t):i.innerText=t)}function rn(e){const t=Lt('
      '),n=Lt('');n.style.display="none",Xt(t,{transparentBg:!0}),n.src=e.getOpts().getCaptchaIframeURL(),n.onload=()=>{n.style.display="",Jt(t)},t.append(n);const s=Lt('
      ');t.append(s),e.hideInteractInput();let i=!1;return function t(){return k(this,null,(function*(){var n;if(yield(n=1e3,new Promise((e=>{window.setTimeout((()=>{e(null)}),n)}))),i)return;let s=!1;try{s=(yield e.getApi().captcha.getCaptchaStatus()).data.is_pass}catch(r){s=!1}s?e.triggerSuccess():t()}))}(),s.onclick=()=>{i=!0,e.cancel()},t}const on={request:(e,t)=>e.getApi().captcha.verifyCaptcha({value:t}),body:e=>e.get("iframe")?rn(e):function(e){const t=Lt(`${zt("captchaCheck")}`);return t.querySelector(".atk-captcha-img").onclick=()=>{const n=t.querySelector(".atk-captcha-img");e.getApi().captcha.getCaptcha().then((e=>{n.setAttribute("src",e.data.img_data)})).catch((e=>{console.error("Failed to get captcha image ",e)}))},t}(e),onSuccess(e,t,n,s){e.set("val",n)},onError(e,t,n,s){s.querySelector(".atk-captcha-img").click(),s.querySelector('input[type="text"]').value=""}},an={inputType:"password",request(e,t){return k(this,null,(function*(){return(yield e.getApi().user.login({name:e.getUser().getData().nick,email:e.getUser().getData().email,password:t})).data}))},body:e=>Lt(`${zt("adminCheck")}`),onSuccess(e,t,n,s){e.getUser().update({isAdmin:!0,token:t.token}),e.getOpts().onReload()},onError(e,t,n,s){}};function ln(e){return t=>new Promise(((n,s)=>{const i=t.onCancel;t.onCancel=()=>{i&&i(),s(new Error("user canceled the checker"))};const r=t.onSuccess;t.onSuccess=()=>{r&&r(),n()},e(t)}))}class cn{constructor(e){g(this,"checkCaptcha",ln((e=>{this.fire(on,e,(t=>{t.set("img_data",e.imgData),t.set("iframe",e.iframe)}))}))),g(this,"checkAdmin",ln((e=>{this.fire(an,e)}))),this.opts=e}fire(e,t,n){const s=this.opts.getCtx().get("layerManager").create(`checker-${(new Date).getTime()}`);s.show();const i=()=>{s.destroy()},r={};let o=!1;const a={set:(e,t)=>{r[e]=t},get:e=>r[e],getOpts:()=>this.opts,getUser:()=>this.opts.getCtx().get("user"),getApi:()=>this.opts.getApi(),hideInteractInput:()=>{o=!0},triggerSuccess:()=>{i(),e.onSuccess&&e.onSuccess(a,"","",l),t.onSuccess&&t.onSuccess()},cancel:()=>{i(),t.onCancel&&t.onCancel()}};n&&n(a);const l=Lt();l.appendChild(e.body(a));const c=Lt(``);let h;l.appendChild(c),setTimeout((()=>c.focus()),80),c.onkeyup=e=>{"Enter"!==e.key&&13!==e.keyCode||(e.preventDefault(),s.getEl().querySelector('button[data-action="confirm"]').click())};const d=new Yt(l);d.setYes((n=>{const s=c.value.trim();h||(h=n.innerText);const r=()=>{n.innerText=h||"",n.classList.remove("error")};return n.innerText=`${zt("loading")}...`,e.request(a,s).then((n=>{i(),e.onSuccess&&e.onSuccess(a,n,s,l),t.onSuccess&&t.onSuccess()})).catch((t=>{var i;i=String(t.msg||String(t)),n.innerText=i,n.classList.add("error"),e.onError&&e.onError(a,t,s,l);const o=setTimeout((()=>r()),3e3);c.onfocus=()=>{r(),clearTimeout(o)}})),!1})),d.setNo((()=>(i(),t.onCancel&&t.onCancel(),!1))),o&&(c.style.display="none",d.$el.querySelector(".atk-layer-dialog-actions").style.display="none"),s.getEl().append(d.$el),t.onMount&&t.onMount(d.$el)}}class hn{constructor(e){g(this,"$el"),this.ctx=e}get conf(){return this.ctx.conf}}const dn={$header:".atk-header",$nick:'.atk-header [name="nick"]',$email:'.atk-header [name="email"]',$link:'.atk-header [name="link"]',$textareaWrap:".atk-textarea-wrap",$textarea:".atk-textarea",$bottom:".atk-bottom",$submitBtn:".atk-send-btn",$notifyWrap:".atk-notify-wrap",$plugBtnWrap:".atk-plug-btn-wrap",$plugPanelWrap:".atk-plug-panel-wrap"};class un{constructor(e){this.kit=e}useBtn(e="
      "){return this.$btn=Lt(`${e}`),this.$btn}usePanel(e="
      "){return this.$panel=Lt(e),this.$panel}useContentTransformer(e){this.contentTransformer=e}usePanelShow(e){this.kit.useEvents().on("panel-show",(t=>{t===this&&e()}))}usePanelHide(e){this.kit.useEvents().on("panel-hide",(t=>{t===this&&e()}))}useEditorStateEffect(e,t){this.editorStateEffectWhen=e,this.editorStateEffect=t}}class pn extends un{constructor(){super(...arguments),g(this,"isMoved",!1)}move(e){if(this.isMoved)return;this.isMoved=!0;const t=this.kit.useUI().$el;t.after(Lt('
      '));const n=Lt("
      ");e.after(n),n.replaceWith(t),t.classList.add("atk-fade-in"),t.classList.add("editor-traveling")}back(){var e;this.isMoved&&(this.isMoved=!1,null==(e=this.kit.useGlobalCtx().$root.querySelector(".atk-editor-travel-placeholder"))||e.replaceWith(this.kit.useUI().$el),this.kit.useUI().$el.classList.remove("editor-traveling"))}}class gn{constructor(e){g(this,"stateCurt","normal"),g(this,"stateUnmountFn",null),this.editor=e}get(){return this.stateCurt}switch(e,t){var n,s,i,r,o;if(this.stateUnmountFn&&(this.stateUnmountFn(),this.stateUnmountFn=null,null==(s=null==(n=this.editor.getPlugs())?void 0:n.get(pn))||s.back()),"normal"!==e&&t){let n=t.$comment;this.editor.conf.flatMode||(n=n.querySelector(".atk-footer")),null==(r=null==(i=this.editor.getPlugs())?void 0:i.get(pn))||r.move(n);const s=this.editor.ctx.conf.scrollRelativeTo&&this.editor.ctx.conf.scrollRelativeTo();tn(this.editor.getUI().$el,!0,s);const a=null==(o=this.editor.getPlugs())?void 0:o.getPlugs().find((t=>t.editorStateEffectWhen===e));a&&a.editorStateEffect&&(this.stateUnmountFn=a.editorStateEffect(t.comment))}this.stateCurt=e}}class mn extends hn{constructor(e){super(e),g(this,"ui"),g(this,"state"),this.ui=function(){const e=Lt('
      \n
      \n \n \n \n
      \n
      \n \n
      \n \n
      \n
      \n
      \n \n
      \n
      \n
      \n
      \n'),t={$el:e};return Object.entries(dn).forEach((([n,s])=>{t[n]=e.querySelector(s)})),t}(),this.$el=this.ui.$el,this.state=new gn(this)}getUI(){return this.ui}getPlugs(){return this.ctx.get("editorPlugs")}getState(){return this.state.get()}getHeaderInputEls(){return{nick:this.ui.$nick,email:this.ui.$email,link:this.ui.$link}}getContentFinal(){let e=this.getContentRaw();const t=this.getPlugs();return t&&(e=t.getTransformedContent(e)),e}getContentRaw(){return this.ui.$textarea.value||""}getContentMarked(){return Ct(this.getContentFinal())}setContent(e){var t;this.ui.$textarea.value=e,null==(t=this.getPlugs())||t.getEvents().trigger("content-updated",e)}insertContent(e){if(document.selection)this.ui.$textarea.focus(),document.selection.createRange().text=e,this.ui.$textarea.focus();else if(this.ui.$textarea.selectionStart||0===this.ui.$textarea.selectionStart){const t=this.ui.$textarea.selectionStart,n=this.ui.$textarea.selectionEnd,s=this.ui.$textarea.scrollTop;this.setContent(this.ui.$textarea.value.substring(0,t)+e+this.ui.$textarea.value.substring(n,this.ui.$textarea.value.length)),this.ui.$textarea.focus(),this.ui.$textarea.selectionStart=t+e.length,this.ui.$textarea.selectionEnd=t+e.length,this.ui.$textarea.scrollTop=s}else this.ui.$textarea.focus(),this.ui.$textarea.value+=e}focus(){this.ui.$textarea.focus()}reset(){this.setContent(""),this.resetState()}resetState(){this.state.switch("normal")}setReply(e,t){this.state.switch("reply",{comment:e,$comment:t})}setEditComment(e,t){this.state.switch("edit",{comment:e,$comment:t})}showNotify(e,t){!function(e,t,n){const s=Lt(`
      `);s.querySelector(".atk-notify-content").innerHTML=Mt(t).replace("\n","
      "),e.appendChild(s);const i=()=>{s.classList.add("atk-fade-out"),setTimeout((()=>{s.remove()}),200)};let r;r=window.setTimeout((()=>{i()}),3e3),s.addEventListener("click",(()=>{i(),window.clearTimeout(r)}))}(this.ui.$notifyWrap,e,t)}showLoading(){Xt(this.ui.$el)}hideLoading(){Jt(this.ui.$el)}submit(){this.ctx.trigger("editor-submit")}}class fn extends hn{constructor(e){super(e),g(this,"layer"),g(this,"$header"),g(this,"$closeBtn"),g(this,"$iframeWrap"),g(this,"$iframe"),g(this,"refreshOnShow",!0),g(this,"animTimer"),this.$el=Lt('
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n'),this.$header=this.$el.querySelector(".atk-sidebar-header"),this.$closeBtn=this.$header.querySelector(".atk-sidebar-close"),this.$iframeWrap=this.$el.querySelector(".atk-sidebar-iframe-wrap"),this.$closeBtn.onclick=()=>{this.hide()},this.ctx.on("user-changed",(()=>{this.refreshOnShow=!0}))}show(){return k(this,arguments,(function*(e={}){if(this.$el.style.transform="",this.initLayer(),this.layer.show(),this.refreshOnShow)this.refreshOnShow=!1,this.$iframeWrap.innerHTML="",this.$iframe=this.createIframe(e.view),this.$iframeWrap.append(this.$iframe);else{const e=this.$iframe,t=e.src;this.conf.darkMode!==t.includes("darkMode=1")&&this.iframeLoad(e,this.conf.darkMode?t.concat("&darkMode=1"):t.replace("&darkMode=1",""))}this.authCheck({onSuccess:()=>this.show(e)}),this.animTimer=setTimeout((()=>{this.animTimer=void 0,this.$el.style.transform="translate(0, 0)",setTimeout((()=>{this.ctx.getData().updateNotifies([])}),0),this.ctx.trigger("sidebar-show")}),100)}))}hide(){var e;null==(e=this.layer)||e.hide()}authCheck(e){return k(this,null,(function*(){const t=(yield this.ctx.getApi().user.getUserStatus(u({},this.ctx.getApi().getUserFields()))).data;t.is_admin&&!t.is_login&&(this.refreshOnShow=!0,this.ctx.checkAdmin({onSuccess:()=>{setTimeout((()=>{e.onSuccess()}),500)},onCancel:()=>{this.hide()}}),this.hide())}))}initLayer(){this.layer||(this.layer=this.ctx.get("layerManager").create("sidebar",this.$el),this.layer.setOnAfterHide((()=>{this.ctx.editorResetState(),this.animTimer&&clearTimeout(this.animTimer),this.$el.style.transform="",this.ctx.trigger("sidebar-hide")})))}createIframe(e){const t=Lt(''),n=Dt({base:this.ctx.conf.server,path:"/sidebar/"}),s={pageKey:this.conf.pageKey,site:this.conf.site||"",user:JSON.stringify(this.ctx.get("user").getData()),time:+new Date};e&&(s.view=e),this.conf.darkMode&&(s.darkMode="1");const i=new URLSearchParams(s);return this.iframeLoad(t,`${n}?${i.toString()}`),t}iframeLoad(e,t){e.src=t,Xt(this.$iframeWrap),e.onload=()=>{Jt(this.$iframeWrap)}}}class kn{constructor(e){this.options=e}import(e){this.options.flatMode?e.forEach((t=>{this.putCommentFlatMode(t,e,"append")})):this.importCommentsNestMode(e)}insert(e){this.options.flatMode?this.insertCommentFlatMode(e):this.insertCommentNest(e)}importCommentsNestMode(e){const t=function(e,t="DATE_DESC",n=2){const s=[];e.filter((e=>0===e.rid)).forEach((t=>{const i={id:t.id,comment:t,children:[],level:1};i.parent=i,s.push(i),function t(s){const i=e.filter((e=>e.rid===s.id));0!==i.length&&(s.level>=n&&(s=s.parent),i.forEach((e=>{const n={id:e.id,comment:e,children:[],parent:s,level:s.level+1};s.children.push(n),t(n)})))}(i)}));const i=(n,s)=>{let i=n.id-s.id;return"DATE_ASC"===t?i=+new Date(n.comment.date)-+new Date(s.comment.date):"DATE_DESC"===t?i=+new Date(s.comment.date)-+new Date(n.comment.date):"SRC_INDEX"===t?i=e.indexOf(n.comment)-e.indexOf(s.comment):"VOTE_UP_DESC"===t&&(i=s.comment.vote_up-n.comment.vote_up),i};return function e(t){t.forEach((t=>{t.children=t.children.sort(i),e(t.children)}))}(s),s}(e,this.options.nestSortBy,this.options.nestMax);t.forEach((t=>{var n;const s=this.options.createCommentNode(t.comment,e);null==(n=this.options.$commentsWrap)||n.appendChild(s.getEl()),s.getRender().playFadeAnim();const i=(t,n)=>{n.children.forEach((n=>{const s=n.comment,r=this.options.createCommentNode(s,e);t.putChild(r),i(r,n)}))};i(s,t),s.getRender().checkHeightLimit()}))}putCommentFlatMode(e,t,n){var s,i;e.is_collapsed&&(e.is_allow_reply=!1);const r=this.options.createCommentNode(e,t);return e.visible&&("append"===n&&(null==(s=this.options.$commentsWrap)||s.append(r.getEl())),"prepend"===n&&(null==(i=this.options.$commentsWrap)||i.prepend(r.getEl())),r.getRender().playFadeAnim()),r.getRender().checkHeightLimit(),r}insertCommentNest(e){var t;const n=this.options.createCommentNode(e,this.options.getCommentDataList());if(0===e.rid)null==(t=this.options.$commentsWrap)||t.prepend(n.getEl());else{const t=this.options.findCommentNode(e.rid);t&&(t.putChild(n,"DATE_ASC"===this.options.nestSortBy?"append":"prepend"),n.getParents().forEach((e=>{e.getRender().heightLimitRemoveForChildren()})))}n.getRender().checkHeightLimit(),tn(n.getEl()),n.getRender().playFadeAnim()}insertCommentFlatMode(e){tn(this.putCommentFlatMode(e,this.options.getCommentDataList(),"prepend").getEl())}}function yn(e,t){t.forEach((({el:t,max:n,imgContains:s})=>{const i=()=>{t&&(e.scrollable?function(e){if(!e.el)return;if(e.el.classList.contains(bn))return;e.el.classList.add(bn),e.el.style.height=`${e.maxHeight}px`}({el:t,maxHeight:n}):function(e){if(!e.el)return;if(!e.maxHeight)return;if(e.el.classList.contains($n))return;e.el.classList.add($n),e.el.style.height=`${e.maxHeight}px`,e.el.style.overflow="hidden";const t=Lt(`
      ${zt("readMore")}`);t.onclick=t=>{t.stopPropagation(),vn(e.el),e.postBtnClick&&e.postBtnClick(t)},e.el.append(t)}({el:t,maxHeight:n,postBtnClick:e.postExpandBtnClick}))},r=()=>{t&&Rt(t)>n&&i()};r(),s&&t&&function(e,t){if(!e)return;const n=e.getElementsByTagName("img");if(!n.length)return;let s=n.length;for(let i=0;i{s--,0===s&&t()})),0===s&&t()}(t,(()=>r()))}))}const $n="atk-height-limit";function vn(e){e&&e.classList.contains($n)&&(e.classList.remove($n),Array.from(e.children).forEach((e=>{e.classList.contains("atk-height-limit-btn")&&e.remove()})),e.style.height="",e.style.overflow="")}const bn="atk-height-limit-scroll";function wn(e){if(e.$headerNick=e.$el.querySelector(".atk-nick"),e.data.link){const t=Lt('');t.innerText=e.data.nick,t.href=qt(e.data.link)?e.data.link:`https://${e.data.link}`,e.$headerNick.append(t)}else e.$headerNick.innerText=e.data.nick}function xn(e){e.$headerBadgeWrap=e.$el.querySelector(".atk-badge-wrap"),e.$headerBadgeWrap.innerHTML="";const t=e.data.badge_name,n=e.data.badge_color;if(t){const s=Lt('');s.innerText=t.replace("管理员",e.ctx.$t("admin")),s.style.backgroundColor=n||"",e.$headerBadgeWrap.append(s)}if(e.data.is_pinned){const t=Lt(`${e.ctx.$t("pin")}`);e.$headerBadgeWrap.append(t)}}function Cn(e){const t=e.$el.querySelector(".atk-date");t.innerText=e.comment.getDateFormatted(),t.setAttribute("data-atk-comment-date",String(+new Date(e.data.date)))}function En(e){if(!e.ctx.conf.uaBadge&&!e.data.ip_region)return;let t=e.$header.querySelector("atk-ua-wrap");if(t||(t=Lt(''),e.$header.append(t)),t.innerHTML="",e.data.ip_region){const n=Lt('');n.innerText=e.data.ip_region,t.append(n)}if(e.ctx.conf.uaBadge){const{browser:n,os:s}=e.comment.getUserUA();if(String(n).trim()){const e=Lt('');e.innerText=n,t.append(e)}if(String(s).trim()){const e=Lt('');e.innerText=s,t.append(e)}}}class Sn{constructor(e){g(this,"opts"),g(this,"$el"),g(this,"isLoading",!1),g(this,"msgRecTimer"),g(this,"msgRecTimerFunc"),g(this,"isConfirming",!1),g(this,"confirmRecTimer"),this.$el=Lt(''),this.opts="object"!=typeof e?{text:e}:e,this.$el.innerText=this.getText(),this.opts.adminOnly&&this.$el.setAttribute("atk-only-admin-show","")}get isMessaging(){return!!this.msgRecTimer}appendTo(e){return e.append(this.$el),this}getText(){return"string"==typeof this.opts.text?this.opts.text:this.opts.text()}setClick(e){this.$el.onclick=t=>{if(t.stopPropagation(),!this.isLoading){if(this.opts.confirm&&!this.isMessaging){const e=()=>{this.isConfirming=!1,this.$el.classList.remove("atk-btn-confirm"),this.$el.innerText=this.getText()};if(!this.isConfirming)return this.isConfirming=!0,this.$el.classList.add("atk-btn-confirm"),this.$el.innerText=this.opts.confirmText||zt("actionConfirm"),void(this.confirmRecTimer=window.setTimeout((()=>e()),5e3));this.confirmRecTimer&&window.clearTimeout(this.confirmRecTimer),e()}if(this.msgRecTimer)return this.fireMsgRecTimer(),void this.clearMsgRecTimer();e()}}}updateText(e){e&&(this.opts.text=e),this.setLoading(!1),this.$el.innerText=this.getText()}setLoading(e,t){this.isLoading!==e&&(this.isLoading=e,e?(this.$el.classList.add("atk-btn-loading"),this.$el.innerText=t||`${zt("loading")}...`):(this.$el.classList.remove("atk-btn-loading"),this.$el.innerText=this.getText()))}setError(e){this.setMsg(e,"atk-btn-error")}setWarn(e){this.setMsg(e,"atk-btn-warn")}setSuccess(e){this.setMsg(e,"atk-btn-success")}setMsg(e,t,n,s){this.setLoading(!1),t&&this.$el.classList.add(t),this.$el.innerText=e,this.setMsgRecTimer((()=>{this.$el.innerText=this.getText(),t&&this.$el.classList.remove(t),s&&s()}),n||2500)}setMsgRecTimer(e,t){this.fireMsgRecTimer(),this.clearMsgRecTimer(),this.msgRecTimerFunc=e,this.msgRecTimer=window.setTimeout((()=>{e(),this.clearMsgRecTimer()}),t)}fireMsgRecTimer(){this.msgRecTimerFunc&&this.msgRecTimerFunc()}clearMsgRecTimer(){this.msgRecTimer&&window.clearTimeout(this.msgRecTimer),this.msgRecTimer=void 0,this.msgRecTimerFunc=void 0}}function Tn(e){e.ctx.conf.vote&&(e.voteBtnUp=new Sn((()=>`${e.ctx.$t("voteUp")} (${e.data.vote_up||0})`)).appendTo(e.$actions),e.voteBtnUp.setClick((()=>{e.comment.getActions().vote("up")})),e.ctx.conf.voteDown&&(e.voteBtnDown=new Sn((()=>`${e.ctx.$t("voteDown")} (${e.data.vote_down||0})`)).appendTo(e.$actions),e.voteBtnDown.setClick((()=>{e.comment.getActions().vote("down")}))))}function An(e){if(!e.data.is_allow_reply)return;const t=Lt(`${e.ctx.$t("reply")}`);e.$actions.append(t),t.addEventListener("click",(t=>{t.stopPropagation(),e.cConf.onReplyBtnClick?e.cConf.onReplyBtnClick():e.ctx.replyComment(e.data,e.$el)}))}function Ln(e){const t=new Sn({text:()=>e.data.is_collapsed?e.ctx.$t("expand"):e.ctx.$t("collapse"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminEdit("collapsed",t)}))}function Rn(e){const t=new Sn({text:()=>e.data.is_pending?e.ctx.$t("pending"):e.ctx.$t("approved"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminEdit("pending",t)}))}function Mn(e){const t=new Sn({text:()=>e.data.is_pinned?e.ctx.$t("unpin"):e.ctx.$t("pin"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminEdit("pinned",t)}))}function Pn(e){const t=new Sn({text:e.ctx.$t("edit"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.ctx.editComment(e.data,e.$el)}))}function On(e){const t=new Sn({text:e.ctx.$t("delete"),confirm:!0,confirmText:e.ctx.$t("deleteConfirm"),adminOnly:!0});t.appendTo(e.$actions),t.setClick((()=>{e.comment.getActions().adminDelete(t)}))}const In={Avatar:function(e){const t=e.$el.querySelector(".atk-avatar"),n=Lt(""),s=e.conf.avatarURLBuilder;if(n.src=s?s(e.data):e.comment.getGravatarURL(),e.data.link){const s=Lt('');s.href=qt(e.data.link)?e.data.link:`https://${e.data.link}`,s.append(n),t.append(s)}else t.append(n)},Header:function(e){Object.entries({renderNick:wn,renderVerifyBadge:xn,renderDate:Cn,renderUABadge:En}).forEach((([t,n])=>{n(e)}))},Content:function(e){if(!e.data.is_collapsed)return e.$content.innerHTML=e.comment.getContentMarked(),void e.$content.classList.remove("atk-hide","atk-collapsed");e.$content.classList.add("atk-hide","atk-type-collapsed");const t=Lt(`\n
      \n ${e.ctx.$t("collapsedMsg")}\n ${e.ctx.$t("expand")}\n
      `);e.$body.insertAdjacentElement("beforeend",t);const n=t.querySelector(".atk-show-btn");n.addEventListener("click",(t=>{t.stopPropagation(),e.$content.classList.contains("atk-hide")?(e.$content.innerHTML=e.comment.getContentMarked(),e.$content.classList.remove("atk-hide"),nn(e.$content),n.innerText=e.ctx.$t("collapse")):(e.$content.innerHTML="",e.$content.classList.add("atk-hide"),n.innerText=e.ctx.$t("expand"))}))},ReplyAt:function(e){e.cConf.isFlatMode||0===e.data.rid||e.cConf.replyTo&&(e.$replyAt=Lt(''),e.$replyAt.querySelector(".atk-nick").innerText=`${e.cConf.replyTo.nick}`,e.$replyAt.onclick=()=>{e.comment.getActions().goToReplyComment()},e.$headerBadgeWrap.insertAdjacentElement("afterend",e.$replyAt))},ReplyTo:function(e){if(!e.cConf.isFlatMode)return;if(!e.cConf.replyTo)return;e.$replyTo=Lt(`\n
      \n
      ${e.ctx.$t("reply")} :
      \n
      \n
      `);const t=e.$replyTo.querySelector(".atk-nick");t.innerText=`@${e.cConf.replyTo.nick}`,t.onclick=()=>{e.comment.getActions().goToReplyComment()};let n=Ct(e.cConf.replyTo.content);e.cConf.replyTo.is_collapsed&&(n=`[${e.ctx.$t("collapsed")}]`),e.$replyTo.querySelector(".atk-content").innerHTML=n,e.$body.prepend(e.$replyTo)},Pending:function(e){if(!e.data.is_pending)return;const t=Lt(`
      ${e.ctx.$t("pendingMsg")}
      `);e.$body.prepend(t)},Actions:function(e){Object.entries({renderVote:Tn,renderReply:An,renderCollapse:Ln,renderModerator:Rn,renderPin:Mn,renderEdit:Pn,renderDel:On}).forEach((([t,n])=>{n(e)}))}};class _n{constructor(e){g(this,"comment"),g(this,"$el"),g(this,"$main"),g(this,"$header"),g(this,"$headerNick"),g(this,"$headerBadgeWrap"),g(this,"$body"),g(this,"$content"),g(this,"$childrenWrap"),g(this,"$actions"),g(this,"voteBtnUp"),g(this,"voteBtnDown"),g(this,"$replyTo"),g(this,"$replyAt"),this.comment=e}get ctx(){return this.comment.ctx}get data(){return this.comment.getData()}get conf(){return this.comment.conf}get cConf(){return this.comment.getConf()}render(){var e;return this.$el=Lt('
      \n
      \n
      \n
      \n
      \n \n \n \n
      \n
      \n
      \n
      \n \n
      \n
      \n
      \n'),this.$main=this.$el.querySelector(".atk-main"),this.$header=this.$el.querySelector(".atk-header"),this.$body=this.$el.querySelector(".atk-body"),this.$content=this.$body.querySelector(".atk-content"),this.$actions=this.$el.querySelector(".atk-actions"),this.$el.setAttribute("id",`atk-comment-${this.data.id}`),e=this,Object.entries(In).forEach((([t,n])=>{n(e)})),this.recoveryChildrenWrap(),this.$el}checkHeightLimit(){const e=this.ctx.conf.heightLimit;if(!e||!e.content||!e.children)return;const t=e.content,n=e.children;yn({postExpandBtnClick:()=>{const e=this.comment.getChildren();1===e.length&&vn(e[0].getRender().$content)},scrollable:e.scrollable},[{el:this.$content,max:t,imgContains:!0},{el:this.$replyTo,max:t,imgContains:!0},{el:this.$childrenWrap,max:n,imgContains:!1}])}heightLimitRemoveForChildren(){this.$childrenWrap&&vn(this.$childrenWrap)}playFadeAnim(){nn(this.comment.getRender().$el)}playFadeAnimForBody(){nn(this.comment.getRender().$body)}getChildrenWrap(){return this.$childrenWrap}renderChildrenWrap(){return this.$childrenWrap||(this.$childrenWrap=Lt('
      '),this.$main.append(this.$childrenWrap)),this.$childrenWrap}recoveryChildrenWrap(){this.$childrenWrap&&this.$main.append(this.$childrenWrap)}setUnread(e){e?this.$el.classList.add("atk-unread"):this.$el.classList.remove("atk-unread")}setOpenable(e){e?this.$el.classList.add("atk-openable"):this.$el.classList.remove("atk-openable")}setOpenURL(e){this.setOpenable(!0),this.$el.onclick=t=>{t.preventDefault(),window.open(e),this.cConf.openEvt&&this.cConf.openEvt()}}setOpenAction(e){this.setOpenable(!0),this.$el.onclick=t=>{t.preventDefault(),e()}}}class Un{constructor(e){g(this,"comment"),this.comment=e}get ctx(){return this.comment.ctx}get data(){return this.comment.getData()}get cConf(){return this.comment.getConf()}vote(e){const t="up"===e?this.comment.getRender().voteBtnUp:this.comment.getRender().voteBtnDown;this.ctx.getApi().votes.vote(`comment_${e}`,this.data.id,u({},this.ctx.getApi().getUserFields())).then((e=>{var t,n;this.data.vote_up=e.data.up,this.data.vote_down=e.data.down,null==(t=this.comment.getRender().voteBtnUp)||t.updateText(),null==(n=this.comment.getRender().voteBtnDown)||n.updateText()})).catch((e=>{null==t||t.setError(this.ctx.$t("voteFail")),console.log(e)}))}adminEdit(e,t){if(t.isLoading)return;t.setLoading(!0,`${this.ctx.$t("editing")}...`);const n=u({},this.data);"collapsed"===e?n.is_collapsed=!n.is_collapsed:"pending"===e?n.is_pending=!n.is_pending:"pinned"===e&&(n.is_pinned=!n.is_pinned),this.ctx.getApi().comments.updateComment(this.data.id,u({},n)).then((e=>{t.setLoading(!1),this.comment.setData(e.data)})).catch((e=>{console.error(e),t.setError(this.ctx.$t("editFail"))}))}adminDelete(e){e.isLoading||(e.setLoading(!0,`${this.ctx.$t("deleting")}...`),this.ctx.getApi().comments.deleteComment(this.data.id).then((()=>{e.setLoading(!1),this.cConf.onDelete&&this.cConf.onDelete(this.comment)})).catch((t=>{console.error(t),e.setError(this.ctx.$t("deleteFail"))})))}goToReplyComment(){const e=window.location.hash,t=`#atk-comment-${this.data.rid}`;window.location.hash=t,t===e&&window.dispatchEvent(new Event("hashchange"))}}class qn extends hn{constructor(e,t,n){super(e),g(this,"renderInstance"),g(this,"actionInstance"),g(this,"data"),g(this,"cConf"),g(this,"parent"),g(this,"children",[]),g(this,"nestCurt"),g(this,"nestMax"),this.nestMax=e.conf.nestMax||3,this.cConf=n,this.data=u({},t),this.data.date=this.data.date.replace(/-/g,"/"),this.parent=null,this.nestCurt=1,this.actionInstance=new Un(this),this.renderInstance=new _n(this)}render(){const e=this.renderInstance.render();this.$el&&this.$el.replaceWith(e),this.$el=e,this.cConf.afterRender&&this.cConf.afterRender()}getActions(){return this.actionInstance}getRender(){return this.renderInstance}getData(){return this.data}setData(e){this.data=e,this.render(),this.getRender().playFadeAnimForBody()}getParent(){return this.parent}getChildren(){return this.children}getNestCurt(){return this.nestCurt}getIsRoot(){return 0===this.data.rid}getID(){return this.data.id}putChild(e,t="append"){e.parent=this,e.nestCurt=this.nestCurt+1,this.children.push(e);const n=this.getChildrenEl();"append"===t?n.append(e.getEl()):"prepend"===t&&n.prepend(e.getEl()),e.getRender().playFadeAnim(),e.getRender().checkHeightLimit()}getChildrenEl(){let e=this.getRender().getChildrenWrap();return e||(e=this.nestCurt{n.parent&&(e.push(n.parent),t(n.parent))};return t(this),e}getEl(){return this.$el}getGravatarURL(){return`${(e={mirror:this.ctx.conf.gravatar.mirror,params:this.ctx.conf.gravatar.params,emailMD5:this.data.email_encrypted}).mirror.replace(/\/$/,"")}/${e.emailMD5}?${e.params.replace(/^\?/,"")}`;var e}getContentMarked(){return Ct(this.data.content)}getDateFormatted(){return _t(new Date(this.data.date),this.ctx.$t)}getUserUA(){const e=function(e){const t=window||{},n=navigator||{},s=String(e||n.userAgent),i={os:"",osVersion:"",engine:"",browser:"",device:"",language:"",version:""},r={Trident:s.includes("Trident")||s.includes("NET CLR"),Presto:s.includes("Presto"),WebKit:s.includes("AppleWebKit"),Gecko:s.includes("Gecko/")},o={Safari:s.includes("Safari"),Chrome:s.includes("Chrome")||s.includes("CriOS"),IE:s.includes("MSIE")||s.includes("Trident"),Edge:s.includes("Edge")||s.includes("Edg"),Firefox:s.includes("Firefox")||s.includes("FxiOS"),"Firefox Focus":s.includes("Focus"),Chromium:s.includes("Chromium"),Opera:s.includes("Opera")||s.includes("OPR"),Vivaldi:s.includes("Vivaldi"),Yandex:s.includes("YaBrowser"),Kindle:s.includes("Kindle")||s.includes("Silk/"),360:s.includes("360EE")||s.includes("360SE"),UC:s.includes("UC")||s.includes(" UBrowser"),QQBrowser:s.includes("QQBrowser"),QQ:s.includes("QQ/"),Baidu:s.includes("Baidu")||s.includes("BIDUBrowser"),Maxthon:s.includes("Maxthon"),Sogou:s.includes("MetaSr")||s.includes("Sogou"),LBBROWSER:s.includes("LBBROWSER"),"2345Explorer":s.includes("2345Explorer"),TheWorld:s.includes("TheWorld"),MIUI:s.includes("MiuiBrowser"),Quark:s.includes("Quark"),Qiyu:s.includes("Qiyu"),Wechat:s.includes("MicroMessenger"),Taobao:s.includes("AliApp(TB"),Alipay:s.includes("AliApp(AP"),Weibo:s.includes("Weibo"),Douban:s.includes("com.douban.frodo"),Suning:s.includes("SNEBUY-APP"),iQiYi:s.includes("IqiyiApp")},a={Windows:s.includes("Windows"),Linux:s.includes("Linux")||s.includes("X11"),macOS:s.includes("Macintosh"),Android:s.includes("Android")||s.includes("Adr"),Ubuntu:s.includes("Ubuntu"),FreeBSD:s.includes("FreeBSD"),Debian:s.includes("Debian"),"Windows Phone":s.includes("IEMobile")||s.includes("Windows Phone"),BlackBerry:s.includes("BlackBerry")||s.includes("RIM"),MeeGo:s.includes("MeeGo"),Symbian:s.includes("Symbian"),iOS:s.includes("like Mac OS X"),"Chrome OS":s.includes("CrOS"),WebOS:s.includes("hpwOS")},l={Mobile:s.includes("Mobi")||s.includes("iPh")||s.includes("480"),Tablet:s.includes("Tablet")||s.includes("Pad")||s.includes("Nexus 7")};l.Mobile?l.Mobile=!s.includes("iPad"):o.Chrome&&s.includes("Edg")?(o.Chrome=!1,o.Edge=!0):t.showModalDialog&&t.chrome&&(o.Chrome=!1,o[360]=!0),i.device="PC",i.language=(()=>{const e=(n.browserLanguage||n.language).split("-");return e[1]&&(e[1]=e[1].toUpperCase()),e.join("_")})();const c={engine:r,browser:o,os:a,device:l};Object.entries(c).forEach((([e,t])=>{Object.entries(t).forEach((([t,n])=>{!0===n&&(i[e]=t)}))}));const h={Windows:()=>{const e=s.replace(/^.*Windows NT ([\d.]+);.*$/,"$1");return{6.4:"10",6.3:"8.1",6.2:"8",6.1:"7","6.0":"Vista",5.2:"XP",5.1:"XP","5.0":"2000","10.0":"10","11.0":"11"}[e]||e},Android:()=>s.replace(/^.*Android ([\d.]+);.*$/,"$1"),iOS:()=>s.replace(/^.*OS ([\d_]+) like.*$/,"$1").replace(/_/g,"."),Debian:()=>s.replace(/^.*Debian\/([\d.]+).*$/,"$1"),"Windows Phone":()=>s.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/,"$2"),macOS:()=>s.replace(/^.*Mac OS X ([\d_]+).*$/,"$1").replace(/_/g,"."),WebOS:()=>s.replace(/^.*hpwOS\/([\d.]+);.*$/,"$1")};i.osVersion="",h[i.os]&&(i.osVersion=h[i.os](),i.osVersion===s&&(i.osVersion=""));const d={Safari:()=>s.replace(/^.*Version\/([\d.]+).*$/,"$1"),Chrome:()=>s.replace(/^.*Chrome\/([\d.]+).*$/,"$1").replace(/^.*CriOS\/([\d.]+).*$/,"$1"),IE:()=>s.replace(/^.*MSIE ([\d.]+).*$/,"$1").replace(/^.*rv:([\d.]+).*$/,"$1"),Edge:()=>s.replace(/^.*(Edge|Edg|Edg[A-Z]{1})\/([\d.]+).*$/,"$2"),Firefox:()=>s.replace(/^.*Firefox\/([\d.]+).*$/,"$1").replace(/^.*FxiOS\/([\d.]+).*$/,"$1"),"Firefox Focus":()=>s.replace(/^.*Focus\/([\d.]+).*$/,"$1"),Chromium:()=>s.replace(/^.*Chromium\/([\d.]+).*$/,"$1"),Opera:()=>s.replace(/^.*Opera\/([\d.]+).*$/,"$1").replace(/^.*OPR\/([\d.]+).*$/,"$1"),Vivaldi:()=>s.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1"),Yandex:()=>s.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1"),Kindle:()=>s.replace(/^.*Version\/([\d.]+).*$/,"$1"),Maxthon:()=>s.replace(/^.*Maxthon\/([\d.]+).*$/,"$1"),QQBrowser:()=>s.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1"),QQ:()=>s.replace(/^.*QQ\/([\d.]+).*$/,"$1"),Baidu:()=>s.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/,"$1"),UC:()=>s.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1"),Sogou:()=>s.replace(/^.*SE ([\d.X]+).*$/,"$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1"),"2345Explorer":()=>s.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1"),TheWorld:()=>s.replace(/^.*TheWorld ([\d.]+).*$/,"$1"),MIUI:()=>s.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1"),Quark:()=>s.replace(/^.*Quark\/([\d.]+).*$/,"$1"),Qiyu:()=>s.replace(/^.*Qiyu\/([\d.]+).*$/,"$1"),Wechat:()=>s.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1"),Taobao:()=>s.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1"),Alipay:()=>s.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1"),Weibo:()=>s.replace(/^.*weibo__([\d.]+).*$/,"$1"),Douban:()=>s.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1"),Suning:()=>s.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1"),iQiYi:()=>s.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")};return i.version="",d[i.browser]&&(i.version=d[i.browser](),i.version===s&&(i.version="")),i.version.indexOf(".")&&(i.version=i.version.substring(0,i.version.indexOf("."))),"iOS"===i.os&&s.includes("iPad")?i.os="iPadOS":"Edge"!==i.browser||s.includes("Edg")?"MIUI"===i.browser?i.os="Android":"Chrome"===i.browser&&Number(i.version)>27||"Opera"===i.browser&&Number(i.version)>12||"Yandex"===i.browser?i.engine="Blink":void 0===i.browser&&(i.browser="Unknow App"):i.engine="EdgeHTML",i}(this.data.ua);return{browser:`${e.browser} ${e.version}`,os:`${e.os} ${e.osVersion}`}}getConf(){return this.cConf}}class Dn{constructor(e){g(this,"opts"),g(this,"$el"),g(this,"$loading"),g(this,"$text"),g(this,"offset",0),g(this,"total",0),g(this,"origText","Load More"),this.opts=e,this.origText=this.opts.text||this.origText,this.$el=Lt(``),this.$loading=this.$el.querySelector(".atk-loading-icon"),this.$text=this.$el.querySelector(".atk-text"),this.$el.onclick=()=>{this.click()}}get hasMore(){return this.total>this.offset+this.opts.pageSize}click(){this.hasMore&&this.opts.onClick(this.offset+this.opts.pageSize),this.checkDisabled()}show(){this.$el.style.display=""}hide(){this.$el.style.display="none"}setLoading(e){this.$loading.style.display=e?"":"none",this.$text.style.display=e?"none":""}showErr(e){this.setLoading(!1),this.$text.innerText=e,this.$el.classList.add("atk-err"),window.setTimeout((()=>{this.$text.innerText=this.origText,this.$el.classList.remove("atk-err")}),2e3)}update(e,t){this.offset=e,this.total=t,this.checkDisabled()}checkDisabled(){this.hasMore?this.show():this.hide()}}class jn{constructor(){g(this,"instance"),g(this,"onReachedBottom",null),g(this,"opt")}create(e){return this.opt=e,this.instance=new Dn({pageSize:e.pageSize,onClick:t=>k(this,null,(function*(){e.ctx.fetch({offset:t})})),text:zt("loadMore")}),e.readMoreAutoLoad&&(this.onReachedBottom=()=>{this.instance.hasMore&&!this.opt.ctx.getData().getLoading()&&this.instance.click()},this.opt.ctx.on("list-reach-bottom",this.onReachedBottom)),this.instance.$el}setLoading(e){this.instance.setLoading(e)}update(e,t){this.instance.update(e,t)}showErr(e){this.instance.showErr(e)}next(){this.instance.click()}getHasMore(){return this.instance.hasMore}getIsClearComments(e){return 0===e.offset}dispose(){this.onReachedBottom&&this.opt.ctx.off("list-reach-bottom",this.onReachedBottom),this.instance.$el.remove()}}class Bn{constructor(e,t){g(this,"opts"),g(this,"total"),g(this,"$el"),g(this,"$input"),g(this,"inputTimer"),g(this,"$prevBtn"),g(this,"$nextBtn"),g(this,"page",1),this.total=e,this.opts=t,this.$el=Lt('
      \n
      \n
      \n \n
      \n \n
      \n \n
      \n
      \n
      '),this.$input=this.$el.querySelector(".atk-input"),this.$input.value=`${this.page}`,this.$input.oninput=()=>this.input(),this.$input.onkeydown=e=>this.keydown(e),this.$prevBtn=this.$el.querySelector(".atk-btn-prev"),this.$nextBtn=this.$el.querySelector(".atk-btn-next"),this.$prevBtn.onclick=()=>this.prev(),this.$nextBtn.onclick=()=>this.next(),this.checkDisabled()}get pageSize(){return this.opts.pageSize}get offset(){return this.pageSize*(this.page-1)}get maxPage(){return Math.ceil(this.total/this.pageSize)}update(e,t){this.page=Math.ceil(e/this.pageSize)+1,this.total=t,this.setInput(this.page),this.checkDisabled()}setInput(e){this.$input.value=`${e}`}input(e=!1){window.clearTimeout(this.inputTimer);const t=this.$input.value.trim(),n=()=>{if(""===t)return void this.setInput(this.page);let e=Number(t);Number.isNaN(e)||e<1?this.setInput(this.page):(e>this.maxPage&&(this.setInput(this.maxPage),e=this.maxPage),this.change(e))};e?n():this.inputTimer=window.setTimeout((()=>n()),800)}prev(){const e=this.page-1;e<1||this.change(e)}next(){const e=this.page+1;e>this.maxPage||this.change(e)}getHasMore(){return this.page+1<=this.maxPage}change(e){this.page=e,this.opts.onChange(this.offset),this.setInput(e),this.checkDisabled()}checkDisabled(){this.page+1>this.maxPage?this.$nextBtn.classList.add("atk-disabled"):this.$nextBtn.classList.remove("atk-disabled"),this.page-1<1?this.$prevBtn.classList.add("atk-disabled"):this.$prevBtn.classList.remove("atk-disabled")}keydown(e){const t=e.keyCode||e.which;if(38===t){const e=Number(this.$input.value)+1;if(e>this.maxPage)return;this.setInput(e),this.input()}else if(40===t){const e=Number(this.$input.value)-1;if(e<1)return;this.setInput(e),this.input()}else 13===t&&this.input(!0)}setLoading(e){e?Xt(this.$el):Jt(this.$el)}}class Fn{constructor(){g(this,"instance")}create(e){return this.instance=new Bn(e.total,{pageSize:e.pageSize,onChange:t=>k(this,null,(function*(){e.ctx.editorResetState(),e.ctx.fetch({offset:t,onSuccess:()=>{e.ctx.listGotoFirst()}})}))}),this.instance.$el}setLoading(e){this.instance.setLoading(e)}update(e,t){this.instance.update(e,t)}next(){this.instance.next()}getHasMore(){return this.instance.getHasMore()}getIsClearComments(){return!0}dispose(){this.instance.$el.remove()}}function Nn(e){const t=e.getData().getListLastFetch(),n={offset:0,total:0};return t?(n.offset=t.params.offset,t.data&&(n.total=t.params.flatMode?t.data.count:t.data.roots_count),n):n}const Wn=e=>{let t=null;e.watchConf(["pagination","locale"],(n=>{const s=e.get("list");t&&t.dispose(),t=function(e){return e.pagination.readMore?new jn:new Fn}(n);const{offset:i,total:r}=Nn(e),o=t.create({ctx:e,pageSize:n.pagination.pageSize,total:r,readMoreAutoLoad:n.pagination.autoLoad});s.$commentsWrap.after(o),null==t||t.update(i,r)})),e.on("list-loaded",(n=>{const{offset:s,total:i}=Nn(e);null==t||t.update(s,i)})),e.on("list-fetch",(n=>{e.getData().getComments().length>0&&(null==t?void 0:t.getIsClearComments(n))&&e.getData().clearComments()})),e.on("list-failed",(()=>{var e;null==(e=null==t?void 0:t.showErr)||e.call(t,zt("loadFail"))})),e.on("list-fetch",(e=>{null==t||t.setLoading(!0)})),e.on("list-fetched",(({params:e})=>{null==t||t.setLoading(!1)}))};class zn extends hn{constructor(e){super(e),g(this,"$commentsWrap"),g(this,"commentNodes",[]),this.$el=Lt('
      \n
      \n
      \n
      \n
      \n
      \n \n \n \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n \n
      \n'),this.$commentsWrap=this.$el.querySelector(".atk-list-comments-wrap"),Wn(e),this.initCrudEvents()}getCommentsWrapEl(){return this.$commentsWrap}getCommentNodes(){return this.commentNodes}getListLayout(){return new kn({$commentsWrap:this.$commentsWrap,nestSortBy:this.ctx.conf.nestSort,nestMax:this.ctx.conf.nestMax,flatMode:this.ctx.conf.flatMode,createCommentNode:(e,t)=>{const n=function(e,t,n){var s;const i=new qn(e,t,{isFlatMode:null==(s=e.getData().getListLastFetch())?void 0:s.params.flatMode,afterRender:()=>{e.trigger("comment-rendered",i)},onDelete:t=>{e.getData().deleteComment(t.getID())},replyTo:t.rid?n.find((e=>e.id===t.rid)):void 0});return i.render(),i}(this.ctx,e,t);return this.commentNodes.push(n),n},findCommentNode:e=>this.commentNodes.find((t=>t.getID()===e)),getCommentDataList:()=>this.ctx.getData().getComments()})}initCrudEvents(){this.ctx.on("list-load",(e=>{this.getListLayout().import(e)})),this.ctx.on("list-loaded",(e=>{0===e.length&&(this.$commentsWrap.innerHTML="")})),this.ctx.on("comment-inserted",(e=>{this.getListLayout().insert(e)})),this.ctx.on("comment-deleted",(e=>{const t=this.commentNodes.find((t=>t.getID()===e.id));t?(t.getEl().remove(),this.commentNodes=this.commentNodes.filter((t=>t.getID()!==e.id))):console.error(`comment node id=${e.id} not found`)})),this.ctx.on("comment-updated",(e=>{const t=this.commentNodes.find((t=>t.getID()===e.id));t&&t.setData(e)}))}}let Hn,Qn;function Gn(){return{init(){Hn=document.body.style.overflow,Qn=document.body.style.paddingRight},unlock(){document.body.style.overflow=Hn,document.body.style.paddingRight=Qn},lock(){document.body.style.overflow="hidden";const e=parseInt(window.getComputedStyle(document.body,null).getPropertyValue("padding-right"),10);document.body.style.paddingRight=`${function(){const e=document.createElement("p");e.style.width="100%",e.style.height="200px";const t=document.createElement("div");t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.visibility="hidden",t.style.width="200px",t.style.height="150px",t.style.overflow="hidden",t.appendChild(e),document.body.appendChild(t);const n=e.offsetWidth;t.style.overflow="scroll";let s=e.offsetWidth;return n===s&&(s=t.clientWidth),document.body.removeChild(t),n-s}()+e||0}px`}}}class Vn{constructor(e,t){g(this,"allowMaskClose",!0),g(this,"onAfterHide"),this.$el=e,this.opts=t}setOnAfterHide(e){this.onAfterHide=e}setAllowMaskClose(e){this.allowMaskClose=e}getAllowMaskClose(){return this.allowMaskClose}getEl(){return this.$el}show(){this.opts.onShow(),this.$el.style.display=""}hide(){return k(this,null,(function*(){this.opts.onHide(),this.$el.style.display="none",this.onAfterHide&&this.onAfterHide()}))}destroy(){return k(this,null,(function*(){this.opts.onHide(),this.$el.remove(),this.onAfterHide&&this.onAfterHide()}))}}class Kn{constructor(){g(this,"$wrap"),g(this,"$mask"),g(this,"items",[]),this.$wrap=Lt(''),this.$mask=this.$wrap.querySelector(".atk-layer-mask")}createItem(e,t){(t=t||this.createItemElement(e)).setAttribute("data-layer-name",e),this.$wrap.appendChild(t);const n=new Vn(t,{onHide:()=>this.hideWrap(t),onShow:()=>this.showWrap()});return this.getMask().addEventListener("click",(()=>{n.getAllowMaskClose()&&n.hide()})),this.items.push(n),n}createItemElement(e){const t=document.createElement("div");return t.classList.add("atk-layer-item"),t.style.display="none",this.$wrap.appendChild(t),t}getWrap(){return this.$wrap}getMask(){return this.$mask}showWrap(){this.$wrap.style.display="block",this.$mask.style.display="block",this.$mask.classList.add("atk-fade-in"),Gn().lock()}hideWrap(e){if(this.items.map((e=>e.getEl())).filter((t=>t!==e&&t.isConnected&&"none"!==t.style.display)).length>0)return;const t=()=>{this.$wrap.style.display="none",this.$wrap.classList.remove("atk-fade-out"),Gn().unlock(),this.$wrap.onanimationend=null};this.$wrap.classList.add("atk-fade-out"),"none"!==window.getComputedStyle(this.$wrap)["animation-name"]?this.$wrap.onanimationend=()=>t():t()}}class Zn{constructor(e){g(this,"wrap"),this.wrap=new Kn,document.body.appendChild(this.wrap.getWrap()),e.on("unmounted",(()=>{this.wrap.getWrap().remove()})),Gn().init()}getEl(){return this.wrap.getWrap()}create(e,t){return this.wrap.createItem(e,t)}}const Yn="ArtalkUser";class Xn{constructor(e){g(this,"data"),this.opts=e;const t=JSON.parse(window.localStorage.getItem(Yn)||"{}");this.data={nick:t.nick||"",email:t.email||"",link:t.link||"",token:t.token||"",isAdmin:t.isAdmin||!1}}getData(){return this.data}update(e={}){Object.entries(e).forEach((([e,t])=>{this.data[e]=t})),window.localStorage.setItem(Yn,JSON.stringify(this.data)),this.opts.onUserChanged&&this.opts.onUserChanged(this.data)}logout(){this.update({token:"",isAdmin:!1})}checkHasBasicUserInfo(){return!!this.data.nick&&!!this.data.email}}const Jn={i18n(e){Wt(e.conf.locale),e.watchConf(["locale"],(e=>{Wt(e.locale)}))},user:e=>new Xn({onUserChanged:t=>{e.trigger("user-changed",t)}}),layerManager:e=>new Zn(e),checkerLauncher:e=>new cn({getCtx:()=>e,getApi:()=>e.getApi(),onReload:()=>e.reload(),getCaptchaIframeURL:()=>`${e.conf.server}/api/v2/captcha/?t=${+new Date}`}),editor(e){const t=new mn(e);return e.$root.appendChild(t.$el),t},list(e){const t=new zn(e);return e.$root.appendChild(t.$el),t},sidebarLayer:e=>new fn(e),editorPlugs(){}};function es(e){const t=Lt('

      ');if(t.querySelector(".error-message").innerText=`${zt("listLoadFailMsg")}\n${e.errMsg}`,e.retryFn){const n=Lt(`${zt("listRetry")}`);n.onclick=()=>e.retryFn&&e.retryFn(),t.appendChild(n)}if(e.onOpenSidebar){const n=Lt(` | ${zt("openName",{name:zt("ctrlCenter")})}`);t.appendChild(n),n.onclick=()=>e.onOpenSidebar&&e.onOpenSidebar()}sn(e.$err,t)}function ts(e){e.getApi().conf.conf().then((t=>{var n;let s={apiVersion:null==(n=t.data.version)?void 0:n.version};if(e.conf.useBackendConf){if(!t.data.frontend_conf)throw new Error("The remote backend does not respond to the frontend conf, but `useBackendConf` conf is enabled");s=u(u({},s),function(e){const t=["el","pageKey","pageTitle","server","site","darkMode"];return Object.keys(e).forEach((n=>{t.includes(n)&&delete e[n]})),e.emoticons&&"string"==typeof e.emoticons&&(e.emoticons=e.emoticons.trim(),e.emoticons.startsWith("[")||e.emoticons.startsWith("{")?e.emoticons=JSON.parse(e.emoticons):"false"===e.emoticons&&(e.emoticons=!1)),e}(t.data.frontend_conf))}e.conf.remoteConfModifier&&e.conf.remoteConfModifier(s),e.updateConf(s)})).catch((t=>{var n;e.updateConf({});let s="";if(null==(n=t.data)?void 0:n.err_no_site){const t={create_name:e.conf.site,create_urls:`${window.location.protocol}//${window.location.host}`};s=`sites|${JSON.stringify(t)}`}throw es({$err:e.get("list").$el,errMsg:t.msg||String(t),errData:t.data,retryFn:()=>ts(e),onOpenSidebar:e.get("user").getData().isAdmin?()=>e.showSidebar({view:s}):void 0}),console.error(t),t})).then((()=>{e.trigger("mounted")})).then((()=>{e.conf.remoteConfModifier||e.fetch({offset:0})})).catch((()=>{}))}const ns="ArtalkContent";class ss{constructor(e){this.kit=e}reqAdd(){return k(this,null,(function*(){return(yield this.kit.useApi().comments.createComment(u({},yield this.getSubmitAddParams()))).data}))}getSubmitAddParams(){return k(this,null,(function*(){const{nick:e,email:t,link:n}=this.kit.useUser().getData(),s=this.kit.useConf();return{content:this.kit.useEditor().getContentFinal(),name:e,email:t,link:n,rid:0,page_key:s.pageKey,page_title:s.pageTitle,site_name:s.site,ua:yield Ut()}}))}postSubmitAdd(e){this.kit.useGlobalCtx().getData().insertComment(e)}}class is extends un{constructor(e){super(e),g(this,"customs",[]),g(this,"defaultPreset"),this.defaultPreset=new ss(this.kit);const t=()=>this.do();this.kit.useMounted((()=>{this.kit.useGlobalCtx().on("editor-submit",t)})),this.kit.useUnmounted((()=>{this.kit.useGlobalCtx().off("editor-submit",t)}))}registerCustom(e){this.customs.push(e)}do(){return k(this,null,(function*(){if(""===this.kit.useEditor().getContentFinal().trim())return void this.kit.useEditor().focus();const e=this.customs.find((e=>e.activeCond()));this.kit.useEditor().showLoading();try{let t;(null==e?void 0:e.pre)&&e.pre(),t=(null==e?void 0:e.req)?yield e.req():yield this.defaultPreset.reqAdd(),(null==e?void 0:e.post)?e.post(t):this.defaultPreset.postSubmitAdd(t)}catch(t){return console.error(t),void this.kit.useEditor().showNotify(`${zt("commentFail")}: ${t.msg||String(t)}`,"e")}finally{this.kit.useEditor().hideLoading()}this.kit.useEditor().reset(),this.kit.useGlobalCtx().trigger("editor-submitted")}))}}class rs extends un{constructor(e){super(e),g(this,"emoticons",[]),g(this,"loadingTask",null),g(this,"$grpWrap"),g(this,"$grpSwitcher"),g(this,"isListLoaded",!1),g(this,"isImgLoaded",!1),this.kit.useMounted((()=>{this.usePanel('
      '),this.useBtn(zt("emoticon"))})),this.kit.useUnmounted((()=>{})),this.useContentTransformer((e=>this.transEmoticonImageText(e))),this.usePanelShow((()=>{(()=>{k(this,null,(function*(){yield this.loadEmoticonsData(),this.isImgLoaded||(this.initEmoticonsList(),this.isImgLoaded=!0),setTimeout((()=>{this.changeListHeight()}),30)}))})()})),this.usePanelHide((()=>{this.$panel.parentElement.style.height=""})),window.setTimeout((()=>{this.loadEmoticonsData()}),1e3)}loadEmoticonsData(){return k(this,null,(function*(){this.isListLoaded||(null===this.loadingTask?(this.loadingTask=(()=>k(this,null,(function*(){Xt(this.$panel),this.emoticons=yield this.handleData(this.kit.useConf().emoticons),Jt(this.$panel),this.loadingTask=null,this.isListLoaded=!0})))(),yield this.loadingTask):yield this.loadingTask)}))}handleData(e){return k(this,null,(function*(){if(!Array.isArray(e)&&["object","string"].includes(typeof e)&&(e=[e]),!Array.isArray(e))return sn(this.$panel,`[${zt("emoticon")}] Data must be of Array/Object/String type`),Jt(this.$panel),[];const t=t=>{"object"==typeof t&&(t.name&&e.find((e=>e.name===t.name))||e.push(t))},n=e=>k(this,null,(function*(){yield Promise.all(e.map(((e,s)=>k(this,null,(function*(){if("object"!=typeof e||Array.isArray(e)){if(Array.isArray(e))yield n(e);else if("string"==typeof e){const s=yield this.remoteLoad(e);Array.isArray(s)?yield n(s):"object"==typeof s&&t(s)}}else t(e)})))))}));return yield n(e),e.forEach((e=>{if(this.isOwOFormat(e)){this.convertOwO(e).forEach((e=>{t(e)}))}else Array.isArray(e)&&e.forEach((e=>{t(e)}))})),e=e.filter((e=>"object"==typeof e&&!Array.isArray(e)&&!!e&&!!e.name)),this.solveNullKey(e),this.solveSameKey(e),e}))}remoteLoad(e){return k(this,null,(function*(){if(!e)return[];try{const t=yield fetch(e);return yield t.json()}catch(t){return Jt(this.$panel),console.error("[Emoticons] Load Failed:",t),sn(this.$panel,`[${zt("emoticon")}] ${zt("loadFail")}: ${String(t)}`),[]}}))}solveNullKey(e){e.forEach((e=>{e.items.forEach(((t,n)=>{t.key||(t.key=`${e.name} ${n+1}`)}))}))}solveSameKey(e){const t={};e.forEach((e=>{e.items.forEach((e=>{e.key&&""!==String(e.key).trim()&&(t[e.key]?t[e.key]++:t[e.key]=1,t[e.key]>1&&(e.key=`${e.key} ${t[e.key]}`))}))}))}isOwOFormat(e){try{return"object"==typeof e&&!!Object.values(e).length&&Array.isArray(Object.keys(Object.values(e)[0].container))&&Object.keys(Object.values(e)[0].container[0]).includes("icon")}catch(t){return!1}}convertOwO(e){const t=[];return Object.entries(e).forEach((([e,n])=>{const s={name:e,type:n.type,items:[]};n.container.forEach(((t,n)=>{const i=t.icon;if(/<(img|IMG)/.test(i)){const e=/src=["'](.*?)["']/.exec(i);e&&e.length>1&&(t.icon=e[1])}s.items.push({key:t.text||`${e} ${n+1}`,val:t.icon})})),t.push(s)})),t}initEmoticonsList(){this.$grpWrap=Lt('
      '),this.$panel.append(this.$grpWrap),this.emoticons.forEach(((e,t)=>{const n=Lt('');this.$grpWrap.append(n),n.setAttribute("data-index",String(t)),n.setAttribute("data-grp-name",e.name),n.setAttribute("data-type",e.type),e.items.forEach((t=>{const s=Lt('');if(n.append(s),t.key&&!new RegExp(`^(${e.name})?\\s?[0-9]+$`).test(t.key)&&s.setAttribute("title",t.key),"image"===e.type){const e=document.createElement("img");e.src=t.val,e.alt=t.key,s.append(e)}else s.innerText=t.val;s.onclick=()=>{"image"===e.type?this.kit.useEditor().insertContent(`:[${t.key}]`):this.kit.useEditor().insertContent(t.val||"")}}))})),this.emoticons.length>1&&(this.$grpSwitcher=Lt('
      '),this.$panel.append(this.$grpSwitcher),this.emoticons.forEach(((e,t)=>{const n=Lt("");n.innerText=e.name,n.setAttribute("data-index",String(t)),n.onclick=()=>this.openGrp(t),this.$grpSwitcher.append(n)}))),this.emoticons.length>0&&this.openGrp(0)}openGrp(e){var t,n,s;Array.from(this.$grpWrap.children).forEach((t=>{const n=t;n.getAttribute("data-index")!==String(e)?n.style.display="none":n.style.display=""})),null==(t=this.$grpSwitcher)||t.querySelectorAll("span.active").forEach((e=>e.classList.remove("active"))),null==(s=null==(n=this.$grpSwitcher)?void 0:n.querySelector(`span[data-index="${e}"]`))||s.classList.add("active"),this.changeListHeight()}changeListHeight(){}transEmoticonImageText(e){return this.emoticons&&Array.isArray(this.emoticons)?(this.emoticons.forEach((t=>{"image"===t.type&&Object.entries(t.items).forEach((([t,n])=>{e=e.split(`:[${n.key}]`).join(``)}))})),e):e}}const os=["png","jpg","jpeg","gif","bmp","svg","webp"];class as extends un{constructor(e){super(e),g(this,"$imgUploadInput"),this.kit.useMounted((()=>this.init())),this.initDragImg()}init(){this.$imgUploadInput=document.createElement("input"),this.$imgUploadInput.type="file",this.$imgUploadInput.style.display="none",this.$imgUploadInput.accept=os.map((e=>`.${e}`)).join(",");const e=this.useBtn(`${zt("image")}`);e.after(this.$imgUploadInput),e.onclick=()=>{const e=this.$imgUploadInput;e.onchange=()=>{(()=>{k(this,null,(function*(){if(!e.files||0===e.files.length)return;const t=e.files[0];this.uploadImg(t)}))})()},e.click()},this.kit.useConf().imgUpload||this.$btn.setAttribute("atk-only-admin-show","")}initDragImg(){const e=e=>{if(e)for(let t=0;t{e.stopPropagation(),e.preventDefault()},n=t=>{var n;const s=null==(n=t.dataTransfer)?void 0:n.files;(null==s?void 0:s.length)&&(t.preventDefault(),e(s))},s=t=>{var n;const s=null==(n=t.clipboardData)?void 0:n.files;(null==s?void 0:s.length)&&(t.preventDefault(),e(s))};this.kit.useMounted((()=>{this.kit.useUI().$textarea.addEventListener("dragover",t),this.kit.useUI().$textarea.addEventListener("drop",n),this.kit.useUI().$textarea.addEventListener("paste",s)})),this.kit.useUnmounted((()=>{this.kit.useUI().$textarea.removeEventListener("dragover",t),this.kit.useUI().$textarea.removeEventListener("drop",n),this.kit.useUI().$textarea.removeEventListener("paste",s)}))}uploadImg(e){return k(this,null,(function*(){const t=/[^.]+$/.exec(e.name);if(!t||!os.includes(t[0]))return;if(!this.kit.useUser().checkHasBasicUserInfo())return void this.kit.useEditor().showNotify(zt("uploadLoginMsg"),"w");let n="\n";""===this.kit.useUI().$textarea.value.trim()&&(n="");const s=`${n}![](Uploading ${e.name}...)`;let i;this.kit.useEditor().insertContent(s);try{const t=this.kit.useConf().imgUploader;i=t?{public_url:yield t(e)}:(yield this.kit.useApi().upload.upload({file:e})).data}catch(r){console.error(r),this.kit.useEditor().showNotify(`${zt("uploadFail")}: ${r.msg}`,"e")}if(i&&i.public_url){let e=i.public_url;qt(e)||(e=Dt({base:this.kit.useConf().server,path:e})),this.kit.useEditor().setContent(this.kit.useUI().$textarea.value.replace(s,`${n}![](${e})`))}else this.kit.useEditor().setContent(this.kit.useUI().$textarea.value.replace(s,""))}))}}class ls extends un{constructor(e){super(e),g(this,"isPlugPanelShow",!1),this.kit.useMounted((()=>{this.usePanel('
      ');let e=zt("preview");xt()&&(e+=' '),this.useBtn(e)})),this.kit.useUnmounted((()=>{})),this.kit.useEvents().on("content-updated",(e=>{this.isPlugPanelShow&&this.updateContent()})),this.usePanelShow((()=>{this.isPlugPanelShow=!0,this.updateContent()})),this.usePanelHide((()=>{this.isPlugPanelShow=!1}))}updateContent(){this.$panel.innerHTML=this.kit.useEditor().getContentMarked()}}const cs=[class extends un{constructor(e){super(e);const t=()=>{this.save()};this.kit.useMounted((()=>{const e=window.localStorage.getItem(ns)||"";""!==e.trim()&&(this.kit.useEditor().showNotify(zt("restoredMsg"),"i"),this.kit.useEditor().setContent(e)),this.kit.useEvents().on("content-updated",t)})),this.kit.useUnmounted((()=>{this.kit.useEvents().off("content-updated",t)}))}save(){window.localStorage.setItem(ns,this.kit.useEditor().getContentRaw().trim())}},class extends un{get $inputs(){return this.kit.useEditor().getHeaderInputEls()}constructor(e){super(e);const t={},n={},s=(e,t,n)=>()=>{this.kit.useEvents().trigger(e,{field:n,$input:t})};this.kit.useMounted((()=>{Object.entries(this.$inputs).forEach((([e,i])=>{i.addEventListener("input",t[e]=s("header-input",i,e)),i.addEventListener("change",n[e]=s("header-change",i,e))}))})),this.kit.useUnmounted((()=>{Object.entries(this.$inputs).forEach((([e,s])=>{s.removeEventListener("input",t[e]),s.removeEventListener("change",n[e])}))}))}},class extends un{constructor(e){super(e),g(this,"query",{timer:null,abortFn:null});const t=({$input:e,field:t})=>{"edit"!==this.kit.useEditor().getState()&&(this.kit.useUser().update({[t]:e.value.trim()}),"nick"!==t&&"email"!==t||this.fetchUserInfo())};this.kit.useMounted((()=>{Object.entries(this.kit.useEditor().getHeaderInputEls()).forEach((([e,t])=>{t.placeholder=`${zt(e)}`,t.value=this.kit.useUser().getData()[e]||""})),this.kit.useEvents().on("header-input",t)})),this.kit.useUnmounted((()=>{this.kit.useEvents().off("header-input",t)}))}fetchUserInfo(){this.kit.useUser().logout(),this.query.timer&&window.clearTimeout(this.query.timer),this.query.abortFn&&this.query.abortFn(),this.query.timer=window.setTimeout((()=>{this.query.timer=null;const e=this.kit.useApi(),t="getUserCancelToken";this.query.abortFn=()=>e.abortRequest(t),e.user.getUser(u({},e.getUserFields()),{cancelToken:t}).then((e=>this.onUserInfoFetched(e.data))).catch((e=>{})).finally((()=>{this.query.abortFn=null}))}),400)}onUserInfoFetched(e){var t;e.is_login||this.kit.useUser().logout(),this.kit.useGlobalCtx().getData().updateNotifies(e.notifies),this.kit.useUser().checkHasBasicUserInfo()&&!e.is_login&&(null==(t=e.user)?void 0:t.is_admin)&&this.kit.useGlobalCtx().checkAdmin({onSuccess:()=>{}}),e.user&&e.user.link&&(this.kit.useUI().$link.value=e.user.link,this.kit.useUser().update({link:e.user.link}))}},class extends un{constructor(e){super(e);const t=({field:e})=>{"link"===e&&this.onLinkInputChange()};this.kit.useMounted((()=>{this.kit.useEvents().on("header-change",t)})),this.kit.useUnmounted((()=>{this.kit.useEvents().off("header-change",t)}))}onLinkInputChange(){const e=this.kit.useUI().$link.value.trim();e&&!/^(http|https):\/\//.test(e)&&(this.kit.useUI().$link.value=`https://${e}`,this.kit.useUser().update({link:this.kit.useUI().$link.value}))}},class extends un{constructor(e){super(e);const t=e=>this.onKeydown(e),n=()=>this.onInput();this.kit.useMounted((()=>{this.kit.useUI().$textarea.placeholder=this.kit.useConf().placeholder||zt("placeholder"),this.kit.useUI().$textarea.addEventListener("keydown",t),this.kit.useUI().$textarea.addEventListener("input",n)})),this.kit.useUnmounted((()=>{this.kit.useUI().$textarea.removeEventListener("keydown",t),this.kit.useUI().$textarea.removeEventListener("input",n)})),this.kit.useEvents().on("content-updated",(()=>{window.setTimeout((()=>{this.adaptiveHeightByContent()}),80)}))}onKeydown(e){9===(e.keyCode||e.which)&&(e.preventDefault(),this.kit.useEditor().insertContent("\t"))}onInput(){this.kit.useEvents().trigger("content-updated",this.kit.useEditor().getContentRaw())}adaptiveHeightByContent(){const e=this.kit.useUI().$textarea.offsetHeight-this.kit.useUI().$textarea.clientHeight;this.kit.useUI().$textarea.style.height="0px",this.kit.useUI().$textarea.style.height=`${this.kit.useUI().$textarea.scrollHeight+e}px`}},is,class extends un{constructor(e){super(e);const t=()=>{this.kit.useEditor().submit()};this.kit.useMounted((()=>{this.kit.useUI().$submitBtn.innerText=this.kit.useConf().sendBtn||zt("send"),this.kit.useUI().$submitBtn.addEventListener("click",t)})),this.kit.useUnmounted((()=>{this.kit.useUI().$submitBtn.removeEventListener("click",t)}))}},pn,class extends un{constructor(e){super(e),g(this,"comment"),this.useEditorStateEffect("reply",(e=>(this.setReply(e),()=>{this.cancelReply()}))),this.kit.useEvents().on("mounted",(()=>{const e=this.kit.useDeps(is);if(!e)throw Error("SubmitPlug not initialized");const t=new ss(this.kit);e.registerCustom({activeCond:()=>!!this.comment,req:()=>k(this,null,(function*(){if(!this.comment)throw new Error("reply comment cannot be empty");return(yield this.kit.useApi().comments.createComment(p(u({},yield t.getSubmitAddParams()),{rid:this.comment.id,page_key:this.comment.page_key,page_title:void 0,site_name:this.comment.site_name}))).data})),post:e=>{const n=this.kit.useConf();e.page_key!==n.pageKey&&window.open(`${e.page_url}#atk-comment-${e.id}`),t.postSubmitAdd(e)}})}))}setReply(e){const t=this.kit.useUI();t.$sendReply||(t.$sendReply=Lt(`
      ${zt("reply")} ×
      `),t.$sendReply.querySelector(".atk-text").innerText=`@${e.nick}`,t.$sendReply.addEventListener("click",(()=>{this.kit.useEditor().resetState()})),t.$textareaWrap.append(t.$sendReply)),this.comment=e,t.$textarea.focus()}cancelReply(){if(!this.comment)return;const e=this.kit.useUI();e.$sendReply&&(e.$sendReply.remove(),e.$sendReply=void 0),this.comment=void 0}},class extends un{constructor(e){super(e),g(this,"comment"),g(this,"originalSubmitBtnText","Send"),this.useEditorStateEffect("edit",(e=>(this.edit(e),()=>{this.cancelEdit()}))),this.kit.useMounted((()=>{const e=this.kit.useDeps(is);if(!e)throw Error("SubmitPlug not initialized");e.registerCustom({activeCond:()=>!!this.comment,req:()=>k(this,null,(function*(){const e={content:this.kit.useEditor().getContentFinal(),nick:this.kit.useUI().$nick.value,email:this.kit.useUI().$email.value,link:this.kit.useUI().$link.value},t=this.comment;return(yield this.kit.useApi().comments.updateComment(t.id,u(u({},t),e))).data})),post:e=>{this.kit.useGlobalCtx().getData().updateComment(e)}})}))}edit(e){const t=this.kit.useUI();if(!t.$editCancelBtn){const e=Lt(`
      ${zt("editCancel")} ×
      `);e.onclick=()=>{this.kit.useEditor().resetState()},t.$textareaWrap.append(e),t.$editCancelBtn=e}this.comment=e,t.$header.style.display="none",t.$nick.value=e.nick||"",t.$email.value=e.email||"",t.$link.value=e.link||"",this.kit.useEditor().setContent(e.content),t.$textarea.focus(),this.updateSubmitBtnText(zt("save"))}cancelEdit(){if(!this.comment)return;const e=this.kit.useUI();e.$editCancelBtn&&(e.$editCancelBtn.remove(),e.$editCancelBtn=void 0),this.comment=void 0;const{nick:t,email:n,link:s}=this.kit.useUser().getData();e.$nick.value=t,e.$email.value=n,e.$link.value=s,this.kit.useEditor().setContent(""),this.restoreSubmitBtnText(),e.$header.style.display=""}updateSubmitBtnText(e){this.originalSubmitBtnText=this.kit.useUI().$submitBtn.innerText,this.kit.useUI().$submitBtn.innerText=e}restoreSubmitBtnText(){this.kit.useUI().$submitBtn.innerText=this.originalSubmitBtnText}},class extends un{constructor(e){super(e);const t=()=>this.open(),n=()=>this.close();this.kit.useMounted((()=>{this.kit.useEvents().on("editor-open",t),this.kit.useEvents().on("editor-close",n)})),this.kit.useUnmounted((()=>{this.kit.useEvents().off("editor-open",t),this.kit.useEvents().off("editor-close",n)}))}open(){var e;null==(e=this.kit.useUI().$textareaWrap.querySelector(".atk-comment-closed"))||e.remove(),this.kit.useUI().$textarea.style.display="",this.kit.useUI().$bottom.style.display=""}close(){this.kit.useUI().$textareaWrap.querySelector(".atk-comment-closed")||this.kit.useUI().$textareaWrap.prepend(Lt(`
      ${zt("onlyAdminCanReply")}
      `)),this.kit.useUser().getData().isAdmin?(this.kit.useUI().$textarea.style.display="",this.kit.useUI().$bottom.style.display=""):(this.kit.useUI().$textarea.style.display="none",this.kit.useEvents().trigger("panel-close"),this.kit.useUI().$bottom.style.display="none")}},rs,as,ls];class hs{constructor(e){this.plugs=e}useEditor(){return this.plugs.editor}useGlobalCtx(){return this.plugs.editor.ctx}useConf(){return this.plugs.editor.ctx.conf}useApi(){return this.plugs.editor.ctx.getApi()}useUser(){return this.plugs.editor.ctx.get("user")}useUI(){return this.plugs.editor.getUI()}useEvents(){return this.plugs.getEvents()}useMounted(e){this.useEvents().on("mounted",e)}useUnmounted(e){this.useEvents().on("unmounted",e)}useDeps(e){return this.plugs.get(e)}}class ds{constructor(e){g(this,"plugs",[]),g(this,"openedPlug",null),g(this,"events",new Ht),this.editor=e;let t=!1;this.editor.ctx.watchConf(["imgUpload","emoticons","preview","editorTravel","locale"],(e=>{t&&this.getEvents().trigger("unmounted"),this.clear(),function(e){const t=new Map;return t.set(as,e.imgUpload),t.set(rs,e.emoticons),t.set(ls,e.preview),t.set(pn,e.editorTravel),cs.filter((e=>!t.has(e)||!!t.get(e)))}(e).forEach((e=>{const t=new hs(this);this.plugs.push(new e(t))})),this.getEvents().trigger("mounted"),t=!0,this.loadPluginUI()})),this.events.on("panel-close",(()=>this.closePlugPanel()))}getPlugs(){return this.plugs}getEvents(){return this.events}clear(){this.plugs=[],this.events=new Ht,this.openedPlug&&this.closePlugPanel()}loadPluginUI(){this.editor.getUI().$plugPanelWrap.innerHTML="",this.editor.getUI().$plugPanelWrap.style.display="none",this.editor.getUI().$plugBtnWrap.innerHTML="",this.editor.getUI().$el.addEventListener("click",(e=>{e.stopPropagation()})),this.plugs.forEach((e=>this.loadPluginItem(e)))}loadPluginItem(e){const t=e.$btn;if(!t)return;this.editor.getUI().$plugBtnWrap.appendChild(t),!t.onclick&&(t.onclick=()=>{this.editor.getUI().$plugBtnWrap.querySelectorAll(".active").forEach((e=>e.classList.remove("active"))),e!==this.openedPlug?(this.openPlugPanel(e),t.classList.add("active")):this.closePlugPanel()});const n=e.$panel;n&&(n.style.display="none",this.editor.getUI().$plugPanelWrap.appendChild(n))}get(e){return this.plugs.find((t=>t instanceof e))}openPlugPanel(e){this.plugs.forEach((t=>{const n=t.$panel;n&&(t===e?(n.style.display="",this.events.trigger("panel-show",e)):(n.style.display="none",this.events.trigger("panel-hide",e)))})),this.editor.getUI().$plugPanelWrap.style.display="",this.openedPlug=e}closePlugPanel(){this.openedPlug&&(this.editor.getUI().$plugPanelWrap.style.display="none",this.events.trigger("panel-hide",this.openedPlug),this.openedPlug=null)}getTransformedContent(e){let t=e;return this.plugs.forEach((e=>{e.contentTransformer&&(t=e.contentTransformer(t))})),t}}const us="2.8.0";function ps(e){return k(this,null,(function*(){e.countEl&&document.querySelector(e.countEl)&&gs(e,{query:"page_comment",numEl:e.countEl});const t=e.pvAdd?{[e.pageKey]:(yield e.getApi().pages.logPv({page_key:e.pageKey,page_title:e.pageKey,site_name:e.siteName})).data.pv}:void 0;e.pvEl&&document.querySelector(e.pvEl)&&gs(e,{query:"page_pv",numEl:e.pvEl,data:t})}))}function gs(e,t){return k(this,null,(function*(){let n=t.data||{},s=Array.from(document.querySelectorAll(t.numEl)).map((t=>t.getAttribute("data-page-key")||e.pageKey)).filter((e=>"number"!=typeof n[e]));if(s=[...new Set(s)],s.length>0){const i=(yield e.getApi().stats.getStats(t.query,{page_keys:s.join(","),site_name:e.siteName})).data.data;n=u(u({},n),i)}!function(e,t,n){document.querySelectorAll(e).forEach((e=>{const s=e.getAttribute("data-page-key"),i=Number(s?t[s]:n);e.innerHTML=`${i}`}))}(t.numEl,n,n[e.pageKey])}))}let ms=!1;let fs;function ks(e,t){const n="atk-dark-mode";e.forEach((e=>{t?e.classList.add(n):e.classList.remove(n)}))}const ys=[...[e=>{e.on("created",(()=>{!1!==e.conf.immediateFetch&&e.trigger("conf-fetch")})),e.on("conf-fetch",(()=>{ts(e)}))},e=>{!function(){try{if(!Pe.name)return}catch(e){return}Pe.setOptions(u({renderer:kt()},wt)),vt=Pe}(),e.on("updated",(e=>{var t;e.markedReplacers&&(t=e.markedReplacers,bt=t)}))},e=>{const t=e.get("editor"),n=new ds(t);e.inject("editorPlugs",n)},e=>{const t=()=>{var t;t=e.get("user").getData().isAdmin,function(e){const t=[];e.$root.querySelectorAll("[atk-only-admin-show]").forEach((e=>t.push(e)));const n=document.querySelector(".atk-sidebar");return n&&n.querySelectorAll("[atk-only-admin-show]").forEach((e=>t.push(e))),t}({$root:e.$root}).forEach((e=>{t?e.classList.remove("atk-hide"):e.classList.add("atk-hide")}))};e.on("list-loaded",(()=>{t()})),e.on("user-changed",(e=>{t()}))},...[e=>{e.on("list-fetch",(t=>{if(e.getData().getLoading())return;e.getData().setLoading(!0);const n=u({offset:0,limit:e.conf.pagination.pageSize,flatMode:e.conf.flatMode,paramsModifier:e.conf.listFetchParamsModifier},t);e.getData().setListLastFetch({params:n});const s={limit:n.limit,offset:n.offset,flat_mode:n.flatMode,page_key:e.getConf().pageKey,site_name:e.getConf().site};n.paramsModifier&&n.paramsModifier(s),e.getApi().comments.getComments(u(u({},s),e.getApi().getUserFields())).then((({data:t})=>{e.getData().setListLastFetch({params:n,data:t}),e.getData().loadComments(t.comments),e.getData().updatePage(t.page),n.onSuccess&&n.onSuccess(t),e.trigger("list-fetched",{params:n,data:t})})).catch((t=>{const s={msg:t.msg||String(t),data:t.data};throw n.onError&&n.onError(s),e.trigger("list-failed",s),e.trigger("list-fetched",{params:n,error:s}),t})).finally((()=>{e.getData().setLoading(!1)}))}))},e=>{e.on("list-fetch",(t=>{const n=e.get("list");0===t.offset&&en(!0,n.$el)})),e.on("list-fetched",(()=>{en(!1,e.get("list").$el)}))},e=>{e.on("comment-rendered",(t=>{if(!0===e.conf.listUnreadHighlight){const n=e.getData().getNotifies(),s=n.find((e=>e.comment_id===t.getID()));s?(t.getRender().setUnread(!0),t.getRender().setOpenAction((()=>{window.open(s.read_link),e.getData().updateNotifies(n.filter((e=>e.comment_id!==t.getID())))}))):t.getRender().setUnread(!1)}})),e.on("list-goto",(t=>{const n=Pt("atk_notify_key");n&&e.getApi().notifies.markNotifyRead(t,n).then((()=>{e.getData().updateNotifies(e.getData().getNotifies().filter((e=>e.comment_id!==t)))}))}))},e=>{let t;e.on("mounted",(()=>{const n=e.get("list");t=n.$el.querySelector('[data-action="admin-close-comment"]'),t.addEventListener("click",(()=>{const t=e.getData().getPage();if(!t)throw new Error("Page data not found");t.admin_only=!t.admin_only,function(e,t){e.editorShowLoading(),e.getApi().pages.updatePage(t.id,t).then((({data:t})=>{e.getData().updatePage(t)})).catch((t=>{e.editorShowNotify(`${zt("editFail")}: ${t.msg||String(t)}`,"e")})).finally((()=>{e.editorHideLoading()}))}(e,t)}))})),e.on("page-loaded",(n=>{var s,i;const r=e.get("editor");!0===(null==n?void 0:n.admin_only)?(null==(s=r.getPlugs())||s.getEvents().trigger("editor-close"),t&&(t.innerText=zt("openComment"))):(null==(i=r.getPlugs())||i.getEvents().trigger("editor-open"),t&&(t.innerText=zt("closeComment")))})),e.on("list-loaded",(t=>{e.editorResetState()}))},e=>{e.on("list-loaded",(()=>{(()=>{var t,n;const s=e.get("list").$el.querySelector(".atk-comment-count .atk-text");if(!s)return;const i=Mt(zt("counter",{count:`${Number(null==(n=null==(t=e.getData().getListLastFetch())?void 0:t.data)?void 0:n.count)||0}`}));s.innerHTML=i.replace(/(\d+)/,'$1')})()})),e.on("comment-inserted",(()=>{const t=e.getData().getListLastFetch();(null==t?void 0:t.data)&&(t.data.count+=1)})),e.on("comment-deleted",(()=>{const t=e.getData().getListLastFetch();(null==t?void 0:t.data)&&(t.data.count-=1)}))},e=>{let t=null;const n=()=>{if(!t)return;const n=e.get("user").getData();if(n.nick&&n.email){t.classList.remove("atk-hide");const e=t.querySelector(".atk-text");e&&(e.innerText=n.isAdmin?zt("ctrlCenter"):zt("msgCenter"))}else t.classList.add("atk-hide")};e.watchConf(["locale"],(s=>{const i=e.get("list");t=i.$el.querySelector('[data-action="open-sidebar"]'),t&&(t.onclick=()=>{e.showSidebar()},n())})),e.on("user-changed",(e=>{n()}))},e=>{let t=null;e.on("mounted",(()=>{const n=e.get("list");t=n.$el.querySelector(".atk-unread-badge")})),e.on("notifies-updated",(e=>{var n;n=e.length||0,t&&(n>0?(t.innerText=`${Number(n||0)}`,t.style.display="block"):t.style.display="none")}))},e=>{const t=t=>{e.conf.listFetchParamsModifier=t,e.reload()},n=e=>{!function(e){const{$dropdownWrap:t,dropdownList:n}=e;if(t.querySelector(".atk-dropdown"))return;t.classList.add("atk-dropdown-wrap"),t.append(Lt(''));let s=0;const i=(e,t,n,i)=>{i(),s=e,r.querySelectorAll(".active").forEach((e=>{e.classList.remove("active")})),t.classList.add("active"),r.style.display="none",setTimeout((()=>{r.style.display=""}),80)},r=Lt('
        ');n.forEach(((e,t)=>{const n=e[0],o=e[1],a=Lt('
      • '),l=a.querySelector("span");l.innerText=n,l.onclick=()=>{i(t,a,n,o)},r.append(a),t===s&&a.classList.add("active")})),t.append(r)}({$dropdownWrap:e,dropdownList:[[zt("sortLatest"),()=>{t((e=>{e.sort_by="date_desc"}))}],[zt("sortBest"),()=>{t((e=>{e.sort_by="vote"}))}],[zt("sortOldest"),()=>{t((e=>{e.sort_by="date_asc"}))}],[zt("sortAuthor"),()=>{t((e=>{e.view_only_admin=!0}))}]]})};e.watchConf(["listSort","locale"],(t=>{const s=e.get("list").$el.querySelector(".atk-comment-count");s&&(t.listSort?n(s):function(e){var t,n;const{$dropdownWrap:s}=e;s.classList.remove("atk-dropdown-wrap"),null==(t=s.querySelector(".atk-arrow-down-icon"))||t.remove(),null==(n=s.querySelector(".atk-dropdown"))||n.remove()}({$dropdownWrap:s}))}))},e=>{let t=!0;const n=()=>{const n=function(){let e=Number(Pt("atk_comment"));if(!e){const t=window.location.hash.match(/#atk-comment-([0-9]+)/);if(!t||!t[1]||Number.isNaN(Number(t[1])))return null;e=Number(t[1])}return e||null}();n&&(e.trigger("list-goto",n),t=!0)},s=()=>{t=!1,n()};e.on("mounted",(()=>{window.addEventListener("hashchange",s),e.on("list-loaded",n)})),e.on("unmounted",(()=>{window.removeEventListener("hashchange",s),e.off("list-loaded",n)}));let i=0;e.on("list-goto",(n=>{if(i===n)return;const s=e.get("list").getCommentNodes().find((e=>e.getID()===n));if(!s)return;i=n,s.getParents().forEach((e=>{e.getRender().heightLimitRemoveForChildren()}));const r=()=>{tn(s.getEl(),!1),s.getEl().classList.remove("atk-flash-once"),window.setTimeout((()=>{s.getEl().classList.add("atk-flash-once")}),150)};t?window.setTimeout((()=>r()),350):r()}))},e=>{let t=!1;e.on("list-fetch",(e=>{t=!0})),e.on("list-loaded",(n=>{if(!t)return;t=!1;const s=e.get("list"),i=n.length<=0;let r=s.getCommentsWrapEl().querySelector(".atk-list-no-comment");i?r||(r=Lt('
        '),r.innerHTML=pt(s.ctx.conf.noComment||s.ctx.$t("noComment")),s.getCommentsWrapEl().appendChild(r)):null==r||r.remove()}))},e=>{e.on("mounted",(()=>{const t=e.get("list").$el.querySelector(".atk-copyright");t&&(t.innerHTML=`Powered By Artalk`)}))},e=>{let t=null;e.on("mounted",(()=>{t=window.setInterval((()=>{e.get("list").$el.querySelectorAll("[data-atk-comment-date]").forEach((t=>{const n=t.getAttribute("data-atk-comment-date");t.innerText=_t(new Date(Number(n)),e.$t)}))}),3e4)})),e.on("unmounted",(()=>{t&&window.clearInterval(t)}))},e=>{e.on("list-fetch",(()=>{sn(e.get("list").$el,null)})),e.on("list-failed",(t=>{es({$err:e.get("list").$el,errMsg:t.msg,errData:t.data,retryFn:()=>e.fetch({offset:0})})}))},e=>{let t=null;const n=()=>{null==t||t.disconnect(),t=null};e.on("list-loaded",(()=>{n();const s=e.get("list").getCommentsWrapEl().childNodes,i=s.length>2?s[s.length-2]:null;i&&("IntersectionObserver"in window?(s=>{const i=e.conf.scrollRelativeTo&&e.conf.scrollRelativeTo()||null;t=new IntersectionObserver((([t])=>{t.isIntersecting&&(n(),e.trigger("list-reach-bottom"))}),{threshold:.9,root:i}),t.observe(s)})(i):console.warn("IntersectionObserver api not supported"))})),e.on("unmounted",(()=>{n()}))},e=>{const t=()=>{const t=e.get("list"),n=e.conf.scrollRelativeTo&&e.conf.scrollRelativeTo();(n||window).scroll({top:Ot(t.$el,n).top,left:0})};e.on("mounted",(()=>{e.on("list-goto-first",t)})),e.on("unmounted",(()=>{e.off("list-goto-first",t)}))}],e=>{e.on("list-fetch",(t=>{if(0!==t.offset)return;const n=e.getApi().getUserFields();n&&e.getApi().notifies.getNotifies(n).then((t=>{e.getData().updateNotifies(t.data.notifies)}))}))},e=>{e.watchConf(["site","pageKey","countEl","pvEl"],(t=>{ps({getApi:()=>e.getApi(),siteName:t.site,pageKey:t.pageKey,countEl:t.countEl,pvEl:t.pvEl,pvAdd:"boolean"!=typeof e.conf.pvAdd||e.conf.pvAdd})}))},e=>{e.watchConf(["apiVersion","versionCheck"],(t=>{const n=e.get("list");t.apiVersion&&t.versionCheck&&!ms&&function(e,t,n){const s=function(e,t){const n=e.split("."),s=t.split(".");for(let i=0;i<3;i++){const e=Number(n[i]),t=Number(s[i]);if(e>t)return 1;if(t>e)return-1;if(!Number.isNaN(e)&&Number.isNaN(t))return 1;if(Number.isNaN(e)&&!Number.isNaN(t))return-1}return 0}(t,n);if(0===s)return;const i=Lt(`
        ${zt("updateMsg",{name:zt(s<0?"frontend":"backend")})}

        ${zt("currentVersion")}: ${zt("frontend")} ${t} / ${zt("backend")} ${n}

        `),r=Lt(`${zt("ignore")}`);r.onclick=()=>{sn(e.$el.parentElement,null),ms=!0,e.ctx.fetch({offset:0})},i.append(r),sn(e.$el.parentElement,i,'Artalk Warn')}(n,us,t.apiVersion)}))},e=>{let t;const n=n=>{const s=[e.$root,e.get("layerManager").getEl()];fs||(fs=window.matchMedia("(prefers-color-scheme: dark)")),"auto"===n?(t||(t=e=>ks(s,e.matches),fs.addEventListener("change",t)),ks(s,fs.matches)):(t&&(fs.removeEventListener("change",t),t=void 0),ks(s,n))};e.watchConf(["darkMode"],(e=>n(e.darkMode))),e.on("created",(()=>n(e.conf.darkMode))),e.on("unmounted",(()=>{t&&(null==fs||fs.removeEventListener("change",t)),t=void 0}))}]];class $s{constructor(e){g(this,"ctx"),g(this,"plugins",[...ys]);const t=Gt(e,!0);this.ctx=new Zt(t),Object.entries(Jn).forEach((([e,t])=>{const n=t(this.ctx);n&&this.ctx.inject(e,n)})),this.plugins.forEach((e=>{"function"==typeof e&&e(this.ctx)})),this.ctx.trigger("created")}getConf(){return this.ctx.getConf()}getEl(){return this.ctx.$root}update(e){return this.ctx.updateConf(e),this}reload(){this.ctx.reload()}destroy(){this.ctx.trigger("unmounted"),this.ctx.$root.remove()}on(e,t){this.ctx.on(e,t)}off(e,t){this.ctx.off(e,t)}trigger(e,t){this.ctx.trigger(e,t)}setDarkMode(e){this.ctx.setDarkMode(e)}static init(e){return new $s(e)}static use(e){ys.includes(e)||ys.push(e)}static loadCountWidget(e){const t=Gt(e,!0);ps({getApi:()=>new C(Vt(t)),siteName:t.site,pageKey:t.pageKey,countEl:t.countEl,pvEl:t.pvEl,pvAdd:!1})}get $root(){return this.ctx.$root}get conf(){return this.ctx.getConf()}}const vs=$s.init,bs=$s.use,ws=$s.loadCountWidget;e.default=$s,e.init=vs,e.loadCountWidget=ws,e.use=bs,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})); +//# sourceMappingURL=Artalk.js.map diff --git a/page/1.html b/page/1.html new file mode 100644 index 0000000..3d0290c --- /dev/null +++ b/page/1.html @@ -0,0 +1 @@ +https://leenzhu.com/ \ No newline at end of file diff --git a/posts.html b/posts.html new file mode 100644 index 0000000..1a7f25f --- /dev/null +++ b/posts.html @@ -0,0 +1,12 @@ +Posts · Leen Zhu \ No newline at end of file diff --git a/posts/git-branch-points-at.html b/posts/git-branch-points-at.html new file mode 100644 index 0000000..ea15abe --- /dev/null +++ b/posts/git-branch-points-at.html @@ -0,0 +1,13 @@ +git 根据commit反查branch、tag名 · Leen Zhu

        Leen Zhu

        while(life--) money++;

        git 根据commit反查branch、tag名


        在使用 git 的时候大部分时候都是通过 git rev-parse <branch-name> 来获取某个分支名对应的 commit id 但是一直没遇到通过 commit id 来获取分支名的场景。在学习 git rebase 命令的时候突然想知道有没有这个命令。于是就开始问 chatgpt 了。

        最开始,我问 chatgpt

        git rev-pase <branch-name> 这个命令可以根据分支名获取对应的commit id,有没有相反的命令:根据commit id获取对应的分支名?

        chatgpt 跟我说:

        可以通过 git branch --contains <commit-id> 这个命令来实现。

        很明显这个命令不是我想要的,我需要是精确匹配,也就是 branch-name 通过 git rev-parse 解析后,刚好等于我指定的 commit-id 。于是我纠正 chatgpt ,让它给我提供一个可以精确匹配的方案。

        于是 chatgpt 又给出了一个解决方案:

        git show-ref | grep <commit-id>

        这个方案确实可以满足我的需求,但是我总觉得不是最优解。于是我继问:

        你上面的命是可以实现的。但有没有更高效的命令,像git rev-parse一样直接获取。而不是需要我自己去grep

        接着 chatgpt 又给出一个解决方案:

        git name-rev --name-only <commit-id>

        如果这个 commit id 正好对应某个分支的最新 commit,这个命令会返回对应的分支名。

        然而,git name-rev 会尝试找到最接近的引用(分支或标签)来命名 commit,因此如果 commit 不正好是某个分支的 HEAD,返回的结果可能会是一个基于最接近引用的名称(例如 master~2 表示 master 分支倒数第二个 commit)。 +如果你需要更加精确地确定某个 commit id 是否正好对应于某个分支的 HEAD,可以使用以下命令:

        git for-each-ref --format='%(refname)' refs/heads/ | while read ref; do if [ "$(git rev-parse $ref)" = "<commit-id>" ]; then echo $ref fi done
        +

        很明显,这个方案越来越复杂了,还不如最开始的 git show-ref | grep <commit-id> 简洁。然后我又追问 chatgpt

        脚本太复杂了,就没有更简洁的命令吗?

        最后 chatgpt 终于给出了我满意的答案:

        确实可以简化查询是否有分支的 HEAD 完全匹配指定的 commit ID。以下是一个更简洁的命令:

        git branch --points-at <commit-id>
        +

        这个命令会列出所有分支,它们的 HEAD 完全匹配指定的 commit ID。

        假设你的 commit ID 是 abc123,你可以运行以下命令:

        git branch --points-at abc123
        +

        这将列出所有 HEAD 指向 abc123 的分支。这样,你就可以直接找到那些分支的 HEAD 完全匹配特定的 commit ID,而不需要编写复杂的脚本。

        最后,我查了一下,git branch --points-at 替换成 git tag --points-at 就可以处理 tag 相关的查询了。

        \ No newline at end of file diff --git "a/posts/git\346\234\254\345\234\260\345\210\206\346\224\257\344\270\216\350\277\234\347\253\257\351\207\215\345\220\215.html" "b/posts/git\346\234\254\345\234\260\345\210\206\346\224\257\344\270\216\350\277\234\347\253\257\351\207\215\345\220\215.html" new file mode 100644 index 0000000..13f045d --- /dev/null +++ "b/posts/git\346\234\254\345\234\260\345\210\206\346\224\257\344\270\216\350\277\234\347\253\257\351\207\215\345\220\215.html" @@ -0,0 +1,17 @@ +git本地分支与远端重名 · Leen Zhu

        Leen Zhu

        while(life--) money++;

        git本地分支与远端重名


        今天遇到一个git名字ambiguous的问题。

        warning: refname ‘origin/master’ is ambiguous.

        git checkout -b newb origin/master
        +warning: refname 'origin/master' is ambiguous.
        +

        正常来说,这名字应该不会有歧义。通过git show-ref命令查看:

        $ git show-ref origin/master
        +b73e1c8fd21c28926884c8ac61d0666172930fef refs/heads/origin/master (wrong one)
        +aea283f55e75242cf57134c824e05007df4fab06 refs/remotes/origin/master
        +

        原来是有一个本地分支名称被命名称origin/master了。这样当引用origin/master时,gitf就无法确定是要用本地分支origin/master还是origin命名空间下的master分支。

        实际上这个本地分支origin/master是被错误的创建的,所以只需要简单的将其删除即可。

        git branch -d origin/master
        +

        上命的命令是可以正常工作的,没有报ambiguous的错误,大概是因为remote命名空间下的分支不能通过这个命令删除。所以这个命令才正常工作吧。

        另外想精确的指定这个origin/master分支,可以通过git update-ref这个命令来实现:

        $ git update-ref -d refs/heads/origin/master
        +

        注:本地分支都是在heads命名空间下的。

        \ No newline at end of file diff --git a/posts/golang-binary.html b/posts/golang-binary.html new file mode 100644 index 0000000..63a4a7d --- /dev/null +++ b/posts/golang-binary.html @@ -0,0 +1,290 @@ +Golang Binary包使用 · Leen Zhu

        Leen Zhu

        while(life--) money++;

        Golang Binary包使用


        在使用golang的过程需要进行NBNS的报文解析,经调研发现NBNS的报文大都是定长报文,并且需要处理这些报文也不需要太高的性能,所有就决定使用 encoding/binary包来进行编解码。学习过程中对这个包内每个函数都进行尝试并整理出笔记如下。

        Binary 包实现了简单的数字和字节序列之间的转换以及变量的编码与解码。

        数字的翻译是通过读写固定大小的值来进行的。固定大小的值要么是固定大小的算术类型(bool,int8,uint8,int16,flaot32,complex64,...) 要么是包含固定大小值的数组或结构体。

        vaint 函数使用变长编码对单个整型值进行编、解码。值越小,需要的字节越少。具体规范可以参考 https://developers.google.com/protocol-buffers/docs/encoding

        本包更倾向于简单的实现而不是更高的性能。如果客户需要高性能序列化,尤其是大型数据结构,应该看看更高级的解决方案,例如 encoding/gob 包 或者 protocol buffers

        函数

        Read

        func Read(r io.Readr, order ByteOrder, data any) error
        +

        Read 函数从 r 中读取结构化的二进制数据到 data 中。也就是说 Read 是一个 反序列化(解码) 的过程。 data 必须是一个有固定大小值的指针类型或者是有固定大小值的切片(可以是int32,但不能是int类型)。从 r 读取的字节使用指定的字节顺序解码并写入 data 中连续的字段。在解码 bool 值时, 值为 0x00 的字节被解码成 false 其它任何非 0x00 字节都被解码成 true 。当将数据读取到体中时,字段名是空白(_)的,对应该字段的数据将被跳过。例如空白字段名称可以用来处理 padding 。结构体中的字段如果不是空白字段,都必须是导出字段(字段名首字母必须大写),否则会导致 Read 崩溃(panic: reflect: reflect.Value.SetInt using value obtained using unexported field)。

        只有当没有任何字节被读取的时候,error 的值才是 EOF。如果 Read 函数读取了一部分字节,但是没有读取全部所需的字节时发生了 EOF,那么Read函数就会返回ErrUnexpectedEOF

        
        +package main
        +
        +import (
        +	"bytes"
        +	"encoding/binary"
        +	"fmt"
        +)
        +
        +func main() {
        +	var u16l uint16
        +	var u16b uint16
        +	b := []byte{0x12, 0x34}
        +	r := bytes.NewReader(b)
        +	err := binary.Read(r, binary.LittleEndian, &u16l)
        +	if err != nil {
        +		fmt.Println("binary.Read failed:", err)
        +		return
        +	}
        +	r.Reset(b)
        +	err = binary.Read(r, binary.BigEndian, &u16b)
        +	if err != nil {
        +		fmt.Println("binary.Read failed:", err)
        +		return
        +	}
        +	fmt.Printf("littleEndian: 0x%x, bigEndian: 0x%x\n", u16l, u16b)
        +}
        +

        output:

        littleEndian: 0x3412, bigEndian: 0x1234
        +

        对于 uint16uint32uint64 这样的类型其实并不需要用 Read 函数来进行解码,可以直接调用 binary.LittleEndian.Uint16() 这样的函数来进行处理:

        package main
        +
        +import (
        +	"encoding/binary"
        +	"fmt"
        +)
        +
        +func main() {
        +
        +	b := []byte{0x12, 0x34}
        +	u16l := binary.LittleEndian.Uint16(b)
        +	u16b := binary.BigEndian.Uint16(b)
        +	fmt.Printf("littleEndian: 0x%x, bigEndian: 0x%x\n", u16l, u16b)
        +}
        +

        输出为:

        littleEndian: 0x3412, bigEndian: 0x1234
        +

        另外还有一点需要注意的是,上面的代码仅针对无符号类型的,如果是有符号类型的数那么该如何处理?其实可以简单的通过强制类型转换就能完成。如,var i16 int16; i16 = int16(binary.LittleEndian.Uint16(b))

        对于结构体类型或字节类型通常更适合用 Read 函数来进行处理:

        package main
        +
        +import (
        +	"bytes"
        +	"encoding/binary"
        +	"fmt"
        +)
        +
        +type Info struct {
        +	A int16
        +	B uint32
        +	_ uint8
        +	C [3]byte
        +}
        +
        +func main() {
        +	var inf Info
        +	b := []byte{
        +		0x12, 0x34,
        +		0x22, 0x34, 0x56, 0x78,
        +		0xff,
        +		0xaa, 0xbb, 0xcc,
        +		0x00, 0x00,
        +	}
        +	r := bytes.NewReader(b)
        +	fmt.Printf("struct len = %d, bytes = %d\n", binary.Size(inf), len(b))
        +	err := binary.Read(r, binary.BigEndian, &inf)
        +
        +	fmt.Printf("Info: %x, err = %v\n", inf, err)
        +}
        +

        输出:

        struct len = 10, bytes = 12
        +Info: {1234 22345678 0 aabbcc}, err = <nil>
        +

        由上面输出可以知道,字节流中的 0xff 被跳过了(结构成员对应的位置为0值),字节流的大小超过要解析结构大小不会产生错误。如果字节流比要读取的结构大小还要小,那么就会报错误 unexpected EOF

        另外,如果结构体成员中有任何一个字段的类型不是固定大小的,那么 Read 函数就是报错: invalid type 。同时 Size 函数返回值是 -1

        Size

        func Size(v any) int
        +

        该函数返回 Write 将对 v 编码成多少个字节,v 必须是一个固定大小的值,或者是固定大小值的切片,或者是指向上述类型的指针。如果 v 不是上面这些类型,那么本函数将返回 -1

        package main
        +
        +import (
        +	"encoding/binary"
        +	"fmt"
        +)
        +
        +type Info1 struct { // size = 2 + 4 = 6
        +	A int16
        +	B int32
        +}
        +
        +type Info2 struct { // size = 4 + 32 = 36
        +	A int32
        +	B [32]byte
        +}
        +
        +type Info3 struct { // size = 2 * 6 + 36 = 48
        +	A [2]Info1
        +	B Info2
        +}
        +
        +// 匿名内嵌体
        +type Info4 struct { // size = 6 + 4 = 10
        +	Info1
        +	C int32
        +}
        +
        +type Info5 struct { // size = -1, 因为 int 大小不固定
        +	A int
        +	B uint8
        +}
        +
        +func main() {
        +	var inf1 Info1
        +	var inf2 Info2
        +	var inf3 Info3
        +	var inf4 Info4
        +	var inf5 Info5
        +
        +	fmt.Println(binary.Size(inf1))
        +	fmt.Println(binary.Size(inf2))
        +	fmt.Println(binary.Size(inf3))
        +	fmt.Println(binary.Size(inf4))
        +	fmt.Println(binary.Size(inf5))
        +}
        +

        输出:

        6
        +36
        +48
        +10
        +-1
        +

        需要注意的是,binary.Size 只能计算固定大小变量的大小,而不能计算类型的大小。这个不同于 unsafe.Sizeof ,参见 对比unsafe.Sizeof

        Write

        func Write(w io.Writer, order ByteOrder, data any) error
        +

        Write 函数将 data 的二进制表现形式的数据写入 wdata 必须是固定大小的值或者固定大小值的切片或者指向这类数据的指针。

        注: +data 类型在 Read 中只能是变量指针,在 Write 中可以是变量本身。因为 Read 需要向变量填充数据,而 Write 只是使用这个数据,所以是不是指针都没有影响。

        bool 类型的值的被编码成一个字节:1 表示 true0 表示 falsedata 中连续的字段值根据指定的字节序被依次编码成二进制数据写入 w 中。对结构体进行编码时,如果字段名称是空白 (_ ),那么 0 值将被写入 w 中。

        package main
        +
        +import (
        +	"bytes"
        +	"encoding/binary"
        +	"fmt"
        +)
        +
        +type NameQuery struct {
        +	Name  [16]byte
        +	Type  uint16
        +	Class uint16
        +}
        +
        +func main() {
        +	nq := NameQuery{
        +		Name:  [16]byte{'a', 'b'},
        +		Type:  0x1234,
        +		Class: 0xcd,
        +	}
        +	buf := new(bytes.Buffer)
        +	err := binary.Write(buf, binary.BigEndian, nq)
        +	if err != nil {
        +		fmt.Println("binary.Write failed:", err)
        +	}
        +	fmt.Printf("% x", buf.Bytes())
        +}
        +

        输出:

        61 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 34 00 cd
        +

        PutUvarint

        func PutUvarint(buf []byte, x uint64) int
        +

        PutUvarintuint64 类型的值编码到 buf 中并返回编码后字节大小,如果 buf 空间太小,不足以容纳编码后的字节,那么将会导致本函数 panic 。所以在编码前需要确保 buf 的空间是足够的。每种数值所需要最大空间可以通过 MaxVarintLenN 来获取。

        包里定义了三个常量,分别是:

        const (
        +	MaxVarintLen16 = 3
        +	MaxVarintLen32 = 5
        +	MarVarintLen64 = 10
        +)
        +

        MaxVarintLenN 中的 N 表示整型有多少 bitMaxVarintLen16 = 3 表示 16bit 的整型在变长编码时最多可以编码成 3 个字节。其它两个类型依此类推。

        注: +如果 buf 空间不足,假设,需要3个字节,而 buf 只有 2 个字节空间,那么报错内容如下: +panic: runtime error: index out of range [2] with length 2

        package main
        +
        +import (
        +	"encoding/binary"
        +	"fmt"
        +)
        +
        +func main() {
        +	buf := make([]byte, binary.MaxVarintLen64)
        +
        +	for _, x := range []uint64{1, 2, 127, 128, 255, 256, 32767, 32768, 65535, 65536} {
        +		n := binary.PutUvarint(buf, x)
        +		fmt.Printf("Encode x = %5d into [% x] with %d bytes\n", x, buf, n)
        +	}
        +}
        +

        输出:

        Encode x =     1 into [01 00 00 00 00 00 00 00 00 00] with 1 bytes
        +Encode x =     2 into [02 00 00 00 00 00 00 00 00 00] with 1 bytes
        +Encode x =   127 into [7f 00 00 00 00 00 00 00 00 00] with 1 bytes
        +Encode x =   128 into [80 01 00 00 00 00 00 00 00 00] with 2 bytes
        +Encode x =   255 into [ff 01 00 00 00 00 00 00 00 00] with 2 bytes
        +Encode x =   256 into [80 02 00 00 00 00 00 00 00 00] with 2 bytes
        +Encode x = 32767 into [ff ff 01 00 00 00 00 00 00 00] with 3 bytes
        +Encode x = 32768 into [80 80 02 00 00 00 00 00 00 00] with 3 bytes
        +Encode x = 65535 into [ff ff 03 00 00 00 00 00 00 00] with 3 bytes
        +Encode x = 65536 into [80 80 04 00 00 00 00 00 00 00] with 3 bytes
        +

        Uvarint

        func Uvarint(buf []byte) (uint64, int)
        +

        Uvarintbuf 内容解码成 uint64,并返回解码后的数值和读取 buf 的字节数,如果发生错误,那么解码的值是 0 同时读取的字节 n <= 0 , 这将表示:

        	n == 0: buf 空间太小
        +	n < 0: 解码后的值大于64位(溢出),`-n` 表示已经读取的字节。
        +
        package main
        +
        +import (
        +	"encoding/binary"
        +	"fmt"
        +)
        +
        +func main() {
        +	inputs := [][]byte{
        +		{0x01},
        +		{0x02},
        +		{0x7f},
        +		{0x80, 0x01},
        +		{0xff, 0x01},
        +		{0x80, 0x02},
        +		{0x80, 0x80}, // n = 0, 不完整的编码,还需要后面有最高位不为1的字节。
        +		{0x08, 0x80}, // n = 1, 后续有不需要的字节。
        +		{0x88, 0x80, 0x88, 0x80, 0x88, 0x80, 0x88, 0x80, 0x88, 0x80, 0x77}, // n = -11, 数值太大
        +	}
        +	for _, b := range inputs {
        +		x, n := binary.Uvarint(b)
        +		if n != len(b) {
        +			fmt.Printf("Uvarint did not consume all of in when decoding:[% x], x = %d, n = %d\n", b, x, n)
        +		} else {
        +			fmt.Printf("0x%x\n", x)
        +		}
        +	}
        +}
        +

        输出:

        0x1
        +0x2
        +0x7f
        +0x80
        +0xff
        +0x100
        +Uvarint did not consume all of in when decoding:[80 80], x = 0, n = 0
        +Uvarint did not consume all of in when decoding:[08 80], x = 8, n = 1
        +Uvarint did not consume all of in when decoding:[88 80 88 80 88 80 88 80 88 80 77], x = 0, n = -11
        +

        PutVarint

        func PutVarint(buf []byte, x int64) int
        +

        本函数功能同PutUvarint,只是编码的整型类型是 int64

        AppendUvarint

        func AppendUvarint(buf []byte, x uint64) []byte
        +

        AppendUvarint 将由 PutUvarint 生成的 x 的变长编码追加到 buf 中, 并返回扩展后的 buf

        AppendVarint

        func AppendVarint(buf []byte, x int64) []byte
        +

        本函数功能同 AppendUvarint ,只是针对 int64 类的进行编码追加。

        ReadUvarint

        func ReadUvarint(r io.ByteReader) (uint64, error)
        +

        本函数功能同 Uvarint(),只是读取数据是通过 io.ByteReader 进行,而不是直接传入 []byte 类型的参数。如果没能读取到任何字节,那么 error 的值是 EOF ,如果已经读取了部分数据然后遇到 EOF并且没有读取到所有需要的数据,那么将返回 io.ErrUnexpectedEOF

        package main
        +
        +import (
        +	"bytes"
        +	"encoding/binary"
        +	"fmt"
        +)
        +
        +func main() {
        +	inputs := [][]byte{
        +		{0x80, 0x02}, // 正常解析
        +		{0x80, 0x80}, // 还需要数据,但已经没有数据可以读取
        +		{0x08, 0x08}, // 有多余的数据
        +		{0x88, 0x80, 0x88, 0x80, 0x88, 0x80, 0x88, 0x80, 0x88, 0x80, 0x77}, // 数值太大溢出
        +	}
        +	for _, b := range inputs {
        +
        +		x, err := binary.ReadUvarint(bytes.NewReader(b))
        +		if err != nil {
        +			fmt.Printf("Uvarint did not consume all of in when decoding:[% x], x = %d, err = %v\n", b, x, err)
        +		} else {
        +			fmt.Printf("0x%x\n", x)
        +		}
        +	}
        +}
        +

        输出:

        0x100
        +Uvarint did not consume all of in when decoding:[80 80], x = 0, err = unexpected EOF
        +0x8
        +Uvarint did not consume all of in when decoding:[88 80 88 80 88 80 88 80 88 80 77], x = 576495938823127048, err = binary: varint overflows a 64-bit integer
        +

        ReadVarint

        func ReadVarint(r io.ByteReader) (int64, error)
        +

        本函数功能同 ReadUvarint。与 ReadUvarint 的区别是本函数是解析 int64 类型的值。

        ByteOrder与AppendByteOrder

        ByteOrderAppendByteOrder 都是接口类型。 它们的定义如下:

        type ByteOrder interface {
        +    Uint16([]byte) uint16
        +    Uint32([]byte) uint32
        +    Uint64([]byte) uint64
        +    PutUint16([]byte, uint16)
        +    PutUint32([]byte, uint32)
        +    PutUint64([]byte, uint64)
        +    String() string
        +}
        +
        +type AppendByteOrder interface {
        +    AppendUint16([]byte, uint16) []byte
        +    AppendUint32([]byte, uint32) []byte
        +    AppendUint64([]byte, uint64) []byte
        +    String() string
        +}
        +

        包里有两个变量,一个是变量是 BigEndian 另一个是 LittleEndian 。 这两个变量都是定义成 struct {} 空结构体的类型,只要用这类型变量实现接口函数即可,而不用关心这个变量具体的值。

        BigEndian 变量类型是 bigEndian ,相应的 LitlleEndian 的类型是 littleEdian 。这两个变量都是大写的,可以导出使用,而这两个变量的类型都是小写的,只能在 binary 包内部使用。

        这两种类型的变量都分别实现了两个接口 ByteOrderAppendByteOrder 。如果当前字节序变量不能满足需求,可以自己定义一个类型 type MyOrder struct {} ,然后实现这两个接口。在这个包里只有 binary.Readbinary.Write 这两个函数用到这个变量。

        总结

        1. binary包只能处理固定大小的类型。
        2. binary更倾向于易用,不适合用在有高性能需求的场景。
        3. Read/Write函数都是对io进行读写,如果需要处理 []byte 类型,需要借助 bytes.NewReadernew(bytes.Buffer) 来处理。
        4. 如果要处理 struct 类型,成员必须是可导出(首字母大小)类型
        5. 只有 go1.19及以后版本才能使用 AppendUvarintAppendVarintAppendByteOrder
        6. 针对简单类型的二进制转换,可以直接调用类似 binary.BigEndian.PutUint16()binary.BigEndian.Uint16 这样的函数进行编解码。如果需要在原有 buf 中进行追加,可以调用 binary.BigEndian.AppendUint16 函数来实现。
        \ No newline at end of file diff --git a/posts/hugo-show-buddle-img.html b/posts/hugo-show-buddle-img.html new file mode 100644 index 0000000..180f6df --- /dev/null +++ b/posts/hugo-show-buddle-img.html @@ -0,0 +1,35 @@ +hugo 显相对路径下的图片 · Leen Zhu

        Leen Zhu

        while(life--) money++;

        hugo 显相对路径下的图片


        很早以前发现 hugo server 命令在本地预览时不能显示相文章相对路径下的图片。但是普通web服务器是可以显示的一直都不知道是什么原因,之前也曾花费大量时间翻遍整个hugo论坛,也没有找到解决方案,因为我的 emacs 可以直接预览图片,发布后也能正常显示图片,后来也就不去管它了。但是今天非常偶然的发现原来 hugo server 也可能预览相对路径的下图片。

        目前我的文章目录结构如下:

        
        +  $ tree content/
        +  content/
        +  |-- about.org
        +  `-- posts
        +      `-- Tech
        +          |-- checksum-offload.org
        +          |-- cpu.org
        +          |-- cpu.assets
        +          |   |-- core-threads-283x300.jpg
        +          |   |-- cores-hand.jpg
        +          |   |-- cpu-with-cores.png
        +          |   |-- logical-cpu.png
        +          |   |-- mainboard-notes.jpg
        +          |   |-- mainboard.jpg
        +          |   |-- quad-core-processor.jpg
        +          |   |-- quad_core_hyperthreading_cpu.png
        +          |   |-- single-core-ht.png
        +          |   `-- socket-cpu-cores.png
        +          |-- debian.org
        +          `-- x230i.org
        +

        如果文章有配图,那么图片资源就会存储到相应的资源目录中,比如文章名称是 cpu.org ,那么资源目录就是 cpu.assets , 在文章中引用图片就可以用相对路径来实现如 ./cpu.assets/mainboard.jpg

        网上好多都是先把图片上传到图床,然后获取图片的绝对链接再插入文章中。这种情况其实有一些弊端,比如不联网的情况下,就无法预览图片,如果图床挂了,想要迁移文章的图片那就非常困难。而原始文章用相对图片,发布时候可以根据需要采用本地图片,或者是动态替换成指定的图床链接。

        大多数情况, 我都是通过命令 =hugo server= 来启动服务,然后通过打 http://localhost:1313 来预览内容,这种情况下却不能显示相对路径下的图片。

        今天忽然想看看到底是什么原因导致 =hugo= 不能预览相对路径下的图片,简单看了下 hugo 的参数,发现有 --debug 选项,那么就试一下,看看浏览器请求不到图片的时候 hugo 是不是什么什么报错的日志吧,于是我就用命令 hugo server -debug 来启动 hugo 然后打开浏览器,这个时候,神奇的事情发生了,相对图片竟然显示出来了。而 hugo 程序,并没有任何特殊的输出,这个时候我把 hugo 停掉,又重新输入一遍,并且加上了 -v 参数 hugo server --debug -v , 启动的过程中,明显多输出了一些信息,这个时候我再打开浏览器,刷新页面,突然发现加了 -v 参数后,图片竟然又不显示了。这是什么情况?然后我又把 =-v= 参数去掉,再次输入 hugo server --debug 这个时候,再刷新浏览器,发现图片依然不显示。这就奇怪了,怎么会有这样情况呢?

        我翻了一下自己的命令记录,发现了一个问题,那就是我第一次输命令的时候, deubg 前面应该有两个减号 - 结果我输入成了一个,这就变成了 hugo server -debughugo server --debug 的区别。那么 -debug--debug 有什么区别呢?

          -d, --destination string     filesystem path to write files to
        +  --debug                      debug output
        +

        原来 -debug 的意思是 -d 选项后接 ebug 这个参数。指定了这个参数后, hugo server -debug 会有一个提示:

          Serving pages from D:\Home\nBox\blog.leenzhu.com\ebug
        +

        一开始以这个先项有点类似于设定web服务的root目录,但是我本地不存在 =ebug= 这样的目录,我后来又试了在 =-d= 接其它的内容:

          hugo server -de
        +  hugo server -dx
        +  hugo server -d.
        +  hugo server -dpublic
        +

        发现无论指定什么字符串都没有任何影响,网页浏览正常,图片显示正常。后来打开目录才发现,原来 -d 的作用就是把网站临时发布到其指定的目录中,大概是不指定 -d 先项的情况下,页面的渲染都是在内存中的,所有内存中只有页面数据,不是会有页面同目录的资源数据,而指定渲染目录后, hugo 会把相关资源以及渲染结果都输出到指定目录中,然后以这个目录为 web 服务的根目录,这样就可以正常显示所有相关资源了。

        至少目前为止我需要功能能满足了,其它就不管了,也算是一个意外的收获了。

        • 附(<2022-11-16 Wed>)

        今天测试发现图片竟然不能显示了。发现原来启用 uglyurls = true 和不启用,文件的布局是不一样的。所以除了指定 =-d= 选项外,还需要配置 uglyurls=true

        \ No newline at end of file diff --git a/posts/index.xml b/posts/index.xml new file mode 100644 index 0000000..2f67e42 --- /dev/null +++ b/posts/index.xml @@ -0,0 +1,4 @@ +Posts on Leen Zhuhttps://leenzhu.com/posts.htmlRecent content in Posts on Leen ZhuHugo -- gohugo.iozh-cnMon, 23 Sep 2024 17:10:58 +0800ldconfighttps://leenzhu.com/posts/ldconfig.htmlMon, 23 Sep 2024 17:10:58 +0800https://leenzhu.com/posts/ldconfig.html<p>工作时遇到了一个奇的问题。手动创建某个<code>so</code>符号链接似乎不能被<code>ldconfig</code>识别。</p>git 根据commit反查branch、tag名https://leenzhu.com/posts/git-branch-points-at.htmlFri, 31 May 2024 10:57:48 +0800https://leenzhu.com/posts/git-branch-points-at.html<p>在使用 <code>git</code> 的时候大部分时候都是通过 <code>git rev-parse &lt;branch-name&gt;</code> 来获取某个分支名对应的 <code>commit id</code> 但是一直没遇到通过 <code>commit id</code> 来获取分支名的场景。在学习 <code>git rebase</code> 命令的时候突然想知道有没有这个命令。于是就开始问 <code>chatgpt</code> 了。</p>git本地分支与远端重名https://leenzhu.com/posts/git%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E4%B8%8E%E8%BF%9C%E7%AB%AF%E9%87%8D%E5%90%8D.htmlWed, 26 Jul 2023 00:00:00 +0000https://leenzhu.com/posts/git%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E4%B8%8E%E8%BF%9C%E7%AB%AF%E9%87%8D%E5%90%8D.html<p>今天遇到一个git名字ambiguous的问题。</p> +<blockquote> +<p>warning: refname &lsquo;origin/master&rsquo; is ambiguous.</p> +</blockquote>round_pow2 函数分析https://leenzhu.com/posts/round_pow2-%E5%87%BD%E6%95%B0%E5%88%86%E6%9E%90.htmlTue, 25 Jul 2023 00:00:00 +0000https://leenzhu.com/posts/round_pow2-%E5%87%BD%E6%95%B0%E5%88%86%E6%9E%90.html<p>网上搜了一圈没有搜到对这个函数的说明。这个函数的名称给我造成一些误解,让我认为这是<strong>四舍五入</strong>的概念,对于浮点数取整一般有3种情况:</p>Golang Binary包使用https://leenzhu.com/posts/golang-binary.htmlMon, 15 May 2023 00:00:00 +0000https://leenzhu.com/posts/golang-binary.html<p>在使用golang的过程需要进行NBNS的报文解析,经调研发现NBNS的报文大都是定长报文,并且需要处理这些报文也不需要太高的性能,所有就决定使用 <code>encoding/binary</code>包来进行编解码。学习过程中对这个包内每个函数都进行尝试并整理出笔记如下。</p>hugo 显相对路径下的图片https://leenzhu.com/posts/hugo-show-buddle-img.htmlWed, 06 Oct 2021 11:36:03 +0800https://leenzhu.com/posts/hugo-show-buddle-img.html<p>很早以前发现 <code>hugo server</code> 命令在本地预览时不能显示相文章相对路径下的图片。但是普通web服务器是可以显示的一直都不知道是什么原因,之前也曾花费大量时间翻遍整个hugo论坛,也没有找到解决方案,因为我的 <code>emacs</code> 可以直接预览图片,发布后也能正常显示图片,后来也就不去管它了。但是今天非常偶然的发现原来 <code>hugo server</code> 也可能预览相对路径的下图片。</p> \ No newline at end of file diff --git a/posts/ldconfig.html b/posts/ldconfig.html new file mode 100644 index 0000000..a2b425f --- /dev/null +++ b/posts/ldconfig.html @@ -0,0 +1,16 @@ +ldconfig · Leen Zhu

        Leen Zhu

        while(life--) money++;

        ldconfig


        工作时遇到了一个奇的问题。手动创建某个so符号链接似乎不能被ldconfig识别。

        事情的起因为是这样的,我有一个程序P,通过ldd检查,它明确依赖libcrypto.so.1.0.0,我的系统中只有这几个so

        libcrypto.so
        +libcrypto.so.1.1
        +libcrypto.so.1.1.1k
        +

        所以最开始的想着建立一个符号链接就可以了,因为我在系统中只有libcrypto.so.1.0.2k的时候成功过。所以我在/lib64目录中创建了一个符号链接:

        [root@localhost certus]# ll /lib64/  | grep libcrypto
        +lrwxrwxrwx.  1 root root       19 Dec 18  2023 libcrypto.so -> libcrypto.so.1.1.1k
        +lrwxrwxrwx.  1 root root       26 Sep 23 05:17 libcrypto.so.1.0.0 -> /lib64/libcrypto.so.1.1.1k
        +lrwxrwxrwx.  1 root root       19 Dec 18  2023 libcrypto.so.1.1 -> libcrypto.so.1.1.1k
        +-rwxr-xr-x.  1 root root  3087888 Dec 18  2023 libcrypto.so.1.1.1k
        +

        然后这样并没有达到预期效果,我的程序P无法运行。我知道这个应该是版本太高的原因。

        所以我从其它机器上复了较低版本libcrypt.so.1.0.2k,然后给它创建了符号链接libcrypt.1.0.0,最后运行一下程序,发现可以正常运行。本来事情到这里就可以结束了。但是我觉得直接在系统的/lib64目录中新文件的方式不太好,不如单独指定一个目录,然后通过ldconfig来更新依赖库。于是我就遇到了一个困扰我一天的问题。

        操作流程如下:

        1. 新建一个目录/usr/local/lib64/foo
        2. libcrpyto.so.1.0.2k复制到/usr/local/lib64/foo目录中
        3. libcrypto.so.1.0.0符号链接复制到/usr/local/lib64/foo目录中
        4. 新建一个ldconfig配置文件/etc/ld.so.conf.d/foo.conf,内容为:/usr/local/lib64/foo
        5. 执行ldconfig 命令。

        操作完上述流程后,我再次运行我的程序P,发现依然找不到libcrypto.so.1.0.0。那么为什么/usr/local/lib64/foo目录中的libcrypto.so.1.0.0这个符号没有被找到呢?通过ldconfig -v查看,发现ldconfig根据libcrypto.so.1.0.2k生成了libcrpyto.so.10这个符号,而这个符号是可以被识别的。而我自己手动创建的符号libcrypto.so.1.0.0却不能工作。我猜测肯定是有什么原因导致ldconfig没有识别我的符号链接。于是我又偿试不用符号链接,直接把libcrypt.so.1.0.2k重命名成libcrypto.so.1.0.0,但是这样依然不能生效。

        通过调试,发现search cache=/etc/ld.so.cache里面就没有libcrypto.so.1.0.0

         LD_DEBUG=libs /path/to/progP
        +

        后来我在/lib64目录中创建符号链接libcrypto.so.1.0.0,这里的符号是可以被程序P找到的。

        搜索了很多资料,也没有发现有什么能解释这个问题的。问了chatgpt,它跟扯了一堆没用的,什么lib命令问题,权限的问题,优先级问题等等,都没有解决问题。

        后来我想了一下,应该是和ldconfig的机制有关,想去看看ldconfig的源码,发现一时半会儿也理不清,就放弃了。但是我注意到ldconfig会根据libcrypto.so.1.0.2k自动生成符号链接libcrypto.so.10,为什么ldconfig自己生成的符号有效,而我手动创建的符号无效?我猜测ldconfig在搜索目录时,可能只会处理目录中有效的SONAME,我重新编译了一个 libcrypto.so.1.0.0,然后放入/usr/local/lib64/foo目录中,这次运行ldconfig就能识别这个库了。

        经过上述偿试,我最终猜测ldconfg处理lib库的机制是:

        1. ldconfig遍历指定的目录,只搜索不是符号链接的lib*.so*文件。
        2. 从对应的lib*.so*文件提取SONAME如果有SONAME,那么就根据SONAME创建对应的符号链接,如果SONAME与文件名同名,则不用创建。把对应的SONAME加入ld.so.cache。如果没有SONAME,那么就把该库本身加入ld.so.cache

        这样就可以解释两点:

        1. 直接在/usr/local/lib64/foo中手动创建符号链接不生效:因为ldconfig不处理符号链接。
        2. libcrypto.so.1.0.2k改名成libcrypto.so.1.0.0不生效:因为ldconfig会根据 libcrypto.so.1.0.0 中的 SONAME 生成对应的符号链接 libcrypt.so.10 所以只会把 libcrypto.so.10 加入 ld.so.cache

        至于为何直接在 /lib64 中手动创建符号可以生效,我猜测这个和 ldconfig 没有关系,因为 /lib64 是进程默认的 so 加载路径。所以可以直接找。通过 LD_LIBRARY_PATH 也可以指定程序搜索对应目录的 so 文件,也同样不需要 ldconfig 的参于。

        \ No newline at end of file diff --git a/posts/page/1.html b/posts/page/1.html new file mode 100644 index 0000000..548c496 --- /dev/null +++ b/posts/page/1.html @@ -0,0 +1 @@ +https://leenzhu.com/posts.html \ No newline at end of file diff --git "a/posts/round_pow2-\345\207\275\346\225\260\345\210\206\346\236\220.html" "b/posts/round_pow2-\345\207\275\346\225\260\345\210\206\346\236\220.html" new file mode 100644 index 0000000..9b847e9 --- /dev/null +++ "b/posts/round_pow2-\345\207\275\346\225\260\345\210\206\346\236\220.html" @@ -0,0 +1,13 @@ +round_pow2 函数分析 · Leen Zhu

        Leen Zhu

        while(life--) money++;

        round_pow2 函数分析


        网上搜了一圈没有搜到对这个函数的说明。这个函数的名称给我造成一些误解,让我认为这是四舍五入的概念,对于浮点数取整一般有3种情况:

        • round: 四舍五入
        • floor: 向下取整
        • ceil: 向上取整
        always_inline uword round_pow2 (uword x, uword pow2)
        +{
        +  return (x + pow2 - 1) &~ (pow2 - 1);
        +}
        +

        这个函数虽然不是作用于对浮点数,但它的行为更接近ceil,即向上取整。

        简单的说这个函数作用就是将x取整成pow2的整倍数。同时要求取整后的结果必须大于等于x的值。

        这个函有一点需要注意:参数pow2必须是大于等2,并且是2的幂。

        下面来看下运算过程:

        1. pow2 - 1:因为pow2是2的幂,pow2就可以表示为1 << n(其中n >= 1)如果pow2=8,那么n=3,二进制值就是0000 1000pow2 - 1的值就是0000 0111
        2. ~(pow2 - 1): 取反后的结果就是:1111 1000,这样就得到了计算pow2整倍数二进制掩码,任何数与这个掩码相于都可以被pow2整除。
        3. x + pow2 - 1: 任何一个数与上面的掩码进行相于都会得到一个小于等pow2的数。所需要x加上一个pow2最大的模数(pow2-1),确保x向上靠近pow2的整倍数。
        4. (x + pow2 - 1) &~ (pow2 - 1): 对结果进行pow2掩码运算,最终得到一个pow2的整倍数,并且可以保证结果大于等于x
        \ No newline at end of file diff --git a/scss/sun.min.173be92a65a018529d78026ec3240959d2a3dd35b070c391cad265c861d20173.css b/scss/sun.min.173be92a65a018529d78026ec3240959d2a3dd35b070c391cad265c861d20173.css new file mode 100644 index 0000000..b4b16cb --- /dev/null +++ b/scss/sun.min.173be92a65a018529d78026ec3240959d2a3dd35b070c391cad265c861d20173.css @@ -0,0 +1 @@ +@charset "UTF-8";html{font-size:16px}body{background-color:#fff;color:#444;font-family:微软雅黑,lxgw wenkai screen,droid serif,Georgia,times new roman,pingfang sc,hiragino sans gb,source han sans cn,wenquanyi micro hei,microsoft yahei,serif}h1{font-size:26px}h2{font-size:24px}h3{font-size:22px}h4{font-size:20px}h5{font-size:18px}h6{font-size:16px}li{line-height:2em}body{background-color:#f2f2f2;margin:0}a{text-decoration:none;color:#111}p{line-height:1.8em;font-weight:400;letter-spacing:.2px}li p{line-height:1.2em;margin:.3em}body{counter-reset:h2}h2{counter-reset:h3}h3{counter-reset:h4}h4{counter-reset:h5}h5{counter-reset:h6}h1,h2,h3,h4,h5,h6{text-rendering:optimizeLegibility}.post-content h2:before{content:counter(h2,decimal)". ";counter-increment:h2}.post-content h3:before{content:counter(h2,decimal)"." counter(h3,decimal)". ";counter-increment:h3}.post-content h4:before{content:counter(h2,decimal)"." counter(h3,decimal)"." counter(h4,decimal)". ";counter-increment:h4}.post-content h5:before{content:counter(h2,decimal)"." counter(h3,decimal)"." counter(h4,decimal)"." counter(h5,decimal)". ";counter-increment:h5}.post-content h6:before{content:counter(h2,decimal)"." counter(h3,decimal)"." counter(h4,decimal)"." counter(h5,decimal)"." counter(h6,decimal)". ";counter-increment:h6}.post-content h2.nocount:before,.post-content h3.nocount:before,.post-content h4.nocount:before,.post-content h5.nocount:before,.post-content h6.nocount:before{content:"";counter-increment:none}.post-content table th{text-align:left;background-color:#111;color:#fff;border:4px solid #fff;padding:5px 15px}.post-content th{display:table-cell;vertical-align:inherit;font-weight:700;text-align:-internal-center}.post-content table{border-collapse:collapse;border-spacing:0;border:none;width:100%}.post-content td{background-color:#2baae026;border:4px solid #fff;padding:5px 15px}p:not(.readmore) a,li a,a:hover,a:active{color:#111;border-bottom:2px solid #f08502}blockquote{background-color:#f3f3f3;padding:.2em 1em;margin:1em auto;position:relative;border-left:5px solid #999}pre{background-color:#f0f0f0;padding:1em;margin:1em auto;word-break:break-word;white-space:pre-wrap}p code,li code{padding:2px 4px;border-radius:4px;background-color:#f0f0f0}.tag{padding:2px 10px;color:#4586bd;background-color:#8296e23b;border-radius:4px}.date{background-color:#f3f3f3;padding:2px 10px}p img{display:block;margin:0 auto;max-width:600px}*,*::before,*::after{box-sizing:inherit}.clearfix:before{content:"";display:table}.clearfix:after{content:"";display:table;clear:both}.main{max-width:760px;margin:30px auto 0;padding-top:5em;padding-bottom:5em;padding-left:6em;padding-right:6em;background-color:#fff;-webkit-box-shadow:0 10px 20px 0 rgba(150,150,150,.86);box-shadow:0 10px 20px rgba(150,150,150,.86)}.header{margin-bottom:3em}.footer{text-align:center;margin:10px auto;padding:20px}.footnotes-separatator{display:none}.site-logo{float:left;width:70px;height:70px;margin-right:10px}.site-logo img{width:100%;height:100%}.site-info{float:left}.site-name{margin:0;color:#333;cursor:pointer;font-weight:300;letter-spacing:1px}.site-nav{float:right;margin-top:23px}.site-nav a{padding:10px}.site-nav a:hover{background-color:#f2f2f2}.site-description{color:#666}.post-summary{margin-bottom:2em;margin-top:1em;border-bottom:2px solid #ddd}.post-meta{color:#666}.readmore{text-align:right;margin:0}.readmore a{color:#111;background-color:#3a7ef43b;padding:5px}hr{border:1px solid #e3e3e3;margin-bottom:2em}@media screen and (max-width:600px){.main{padding-left:1em;padding-right:1em}}.pages a{border-radius:4px;margin-left:4px;padding:6px 10px;height:26px;border:1px solid #ebebeb;background:#fbfbfb;color:#909090;overflow:hidden;text-decoration:none}.pages span{border-radius:4px;margin-left:4px;padding:6px 10px;background-repeat:no-repeat;overflow:hidden;color:#000;height:26px;line-height:26px}.pages span.page_current{background:0 0;border:none;color:#000}.pages{font-size:12px;padding:40px 0 60px;text-align:center}.archive-item{margin:5px auto;padding:5px}.page-nav{margin-top:2em;border-top:2px solid #f0f0f0;padding-top:5px}.nav-btn{padding:10px;background-color:#f3f3f3}.page-next{float:right}.page-next::after{content:" >"}.page-prev{float:left}.page-prev::before{content:"< "}.footer{color:gray} \ No newline at end of file diff --git a/sitemap.xml b/sitemap.xml new file mode 100644 index 0000000..7fa0082 --- /dev/null +++ b/sitemap.xml @@ -0,0 +1 @@ +https://leenzhu.com/en/sitemap.xmlhttps://leenzhu.com/zh-cn/sitemap.xml2024-09-23T17:10:58+08:00 \ No newline at end of file diff --git a/tags.html b/tags.html new file mode 100644 index 0000000..63338fd --- /dev/null +++ b/tags.html @@ -0,0 +1,6 @@ +Tags · Leen Zhu

        Leen Zhu

        while(life--) money++;

        标签

        \ No newline at end of file diff --git a/tags/git.html b/tags/git.html new file mode 100644 index 0000000..1b624d1 --- /dev/null +++ b/tags/git.html @@ -0,0 +1,8 @@ +git · Leen Zhu \ No newline at end of file diff --git a/tags/git/index.xml b/tags/git/index.xml new file mode 100644 index 0000000..9a1ad7c --- /dev/null +++ b/tags/git/index.xml @@ -0,0 +1,4 @@ +git on Leen Zhuhttps://leenzhu.com/tags/git.htmlRecent content in git on Leen ZhuHugo -- gohugo.iozh-cnFri, 31 May 2024 10:57:48 +0800git 根据commit反查branch、tag名https://leenzhu.com/posts/git-branch-points-at.htmlFri, 31 May 2024 10:57:48 +0800https://leenzhu.com/posts/git-branch-points-at.html<p>在使用 <code>git</code> 的时候大部分时候都是通过 <code>git rev-parse &lt;branch-name&gt;</code> 来获取某个分支名对应的 <code>commit id</code> 但是一直没遇到通过 <code>commit id</code> 来获取分支名的场景。在学习 <code>git rebase</code> 命令的时候突然想知道有没有这个命令。于是就开始问 <code>chatgpt</code> 了。</p>git本地分支与远端重名https://leenzhu.com/posts/git%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E4%B8%8E%E8%BF%9C%E7%AB%AF%E9%87%8D%E5%90%8D.htmlWed, 26 Jul 2023 00:00:00 +0000https://leenzhu.com/posts/git%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E4%B8%8E%E8%BF%9C%E7%AB%AF%E9%87%8D%E5%90%8D.html<p>今天遇到一个git名字ambiguous的问题。</p> +<blockquote> +<p>warning: refname &lsquo;origin/master&rsquo; is ambiguous.</p> +</blockquote> \ No newline at end of file diff --git a/tags/git/page/1.html b/tags/git/page/1.html new file mode 100644 index 0000000..a766e2e --- /dev/null +++ b/tags/git/page/1.html @@ -0,0 +1 @@ +https://leenzhu.com/tags/git.html \ No newline at end of file diff --git a/tags/golang.html b/tags/golang.html new file mode 100644 index 0000000..e2506c4 --- /dev/null +++ b/tags/golang.html @@ -0,0 +1,7 @@ +golang · Leen Zhu

        Leen Zhu

        while(life--) money++;

        #golang

        \ No newline at end of file diff --git a/tags/golang/index.xml b/tags/golang/index.xml new file mode 100644 index 0000000..08507d4 --- /dev/null +++ b/tags/golang/index.xml @@ -0,0 +1 @@ +golang on Leen Zhuhttps://leenzhu.com/tags/golang.htmlRecent content in golang on Leen ZhuHugo -- gohugo.iozh-cnMon, 15 May 2023 00:00:00 +0000Golang Binary包使用https://leenzhu.com/posts/golang-binary.htmlMon, 15 May 2023 00:00:00 +0000https://leenzhu.com/posts/golang-binary.html<p>在使用golang的过程需要进行NBNS的报文解析,经调研发现NBNS的报文大都是定长报文,并且需要处理这些报文也不需要太高的性能,所有就决定使用 <code>encoding/binary</code>包来进行编解码。学习过程中对这个包内每个函数都进行尝试并整理出笔记如下。</p> \ No newline at end of file diff --git a/tags/golang/page/1.html b/tags/golang/page/1.html new file mode 100644 index 0000000..f43cfca --- /dev/null +++ b/tags/golang/page/1.html @@ -0,0 +1 @@ +https://leenzhu.com/tags/golang.html \ No newline at end of file diff --git a/tags/index.xml b/tags/index.xml new file mode 100644 index 0000000..259a3ba --- /dev/null +++ b/tags/index.xml @@ -0,0 +1 @@ +Tags on Leen Zhuhttps://leenzhu.com/tags.htmlRecent content in Tags on Leen ZhuHugo -- gohugo.iozh-cnFri, 31 May 2024 10:57:48 +0800githttps://leenzhu.com/tags/git.htmlFri, 31 May 2024 10:57:48 +0800https://leenzhu.com/tags/git.htmlvpphttps://leenzhu.com/tags/vpp.htmlTue, 25 Jul 2023 00:00:00 +0000https://leenzhu.com/tags/vpp.htmlgolanghttps://leenzhu.com/tags/golang.htmlMon, 15 May 2023 00:00:00 +0000https://leenzhu.com/tags/golang.html \ No newline at end of file diff --git a/tags/vpp.html b/tags/vpp.html new file mode 100644 index 0000000..9498cd7 --- /dev/null +++ b/tags/vpp.html @@ -0,0 +1,7 @@ +vpp · Leen Zhu

        Leen Zhu

        while(life--) money++;

        \ No newline at end of file diff --git a/tags/vpp/index.xml b/tags/vpp/index.xml new file mode 100644 index 0000000..0ca160d --- /dev/null +++ b/tags/vpp/index.xml @@ -0,0 +1 @@ +vpp on Leen Zhuhttps://leenzhu.com/tags/vpp.htmlRecent content in vpp on Leen ZhuHugo -- gohugo.iozh-cnTue, 25 Jul 2023 00:00:00 +0000round_pow2 函数分析https://leenzhu.com/posts/round_pow2-%E5%87%BD%E6%95%B0%E5%88%86%E6%9E%90.htmlTue, 25 Jul 2023 00:00:00 +0000https://leenzhu.com/posts/round_pow2-%E5%87%BD%E6%95%B0%E5%88%86%E6%9E%90.html<p>网上搜了一圈没有搜到对这个函数的说明。这个函数的名称给我造成一些误解,让我认为这是<strong>四舍五入</strong>的概念,对于浮点数取整一般有3种情况:</p> \ No newline at end of file diff --git a/tags/vpp/page/1.html b/tags/vpp/page/1.html new file mode 100644 index 0000000..1d01001 --- /dev/null +++ b/tags/vpp/page/1.html @@ -0,0 +1 @@ +https://leenzhu.com/tags/vpp.html \ No newline at end of file diff --git a/zh-cn/index.html b/zh-cn/index.html new file mode 100644 index 0000000..8db945a --- /dev/null +++ b/zh-cn/index.html @@ -0,0 +1 @@ +https://leenzhu.com \ No newline at end of file diff --git a/zh-cn/sitemap.xml b/zh-cn/sitemap.xml new file mode 100644 index 0000000..09d95dc --- /dev/null +++ b/zh-cn/sitemap.xml @@ -0,0 +1 @@ +https://leenzhu.com/categories.html2024-09-23T17:10:58+08:00weekly0.5https://leenzhu.com/posts/ldconfig.html2024-09-23T17:10:58+08:00weekly0.5https://leenzhu.com/2024-09-23T17:10:58+08:00weekly0.5https://leenzhu.com/posts.html2024-09-23T17:10:58+08:00weekly0.5https://leenzhu.com/categories/tech.html2024-09-23T17:10:58+08:00weekly0.5https://leenzhu.com/tags/git.html2024-05-31T10:57:48+08:00weekly0.5https://leenzhu.com/posts/git-branch-points-at.html2024-05-31T10:57:48+08:00weekly0.5https://leenzhu.com/tags.html2024-05-31T10:57:48+08:00weekly0.5https://leenzhu.com/posts/git%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E4%B8%8E%E8%BF%9C%E7%AB%AF%E9%87%8D%E5%90%8D.html2023-07-26T00:00:00+00:00weekly0.5https://leenzhu.com/posts/round_pow2-%E5%87%BD%E6%95%B0%E5%88%86%E6%9E%90.html2023-07-25T00:00:00+00:00weekly0.5https://leenzhu.com/tags/vpp.html2023-07-25T00:00:00+00:00weekly0.5https://leenzhu.com/tags/golang.html2023-05-15T00:00:00+00:00weekly0.5https://leenzhu.com/posts/golang-binary.html2023-05-15T00:00:00+00:00weekly0.5https://leenzhu.com/posts/hugo-show-buddle-img.html2021-10-06T11:36:03+08:00weekly0.5https://leenzhu.com/about.html2019-08-21T20:27:06+08:00weekly0.5https://leenzhu.com/faq.html2019-08-21T20:27:06+08:00weekly0.5 \ No newline at end of file