datalog-theme 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -0
- data/CITATION.cff +2 -2
- data/README.md +1 -1
- data/_data/i18n/en.yml +28 -0
- data/_data/i18n/es.yml +28 -0
- data/_data/i18n/pt.yml +28 -0
- data/_includes/components/api-function.html +1 -1
- data/_includes/components/breadcrumbs.html +6 -6
- data/_includes/components/enhanced-toc.html +3 -119
- data/_includes/components/package-install.html +76 -163
- data/_includes/components/social-share.html +10 -10
- data/_includes/footer/nav-column.html +5 -2
- data/_includes/footer.html +5 -5
- data/_includes/header/navigation.html +11 -2
- data/_includes/header.html +8 -8
- data/_includes/scripts.html +2 -1
- data/_layouts/package.html +9 -7
- data/_plugins/i18n.rb +15 -1
- data/_plugins/image_optimizer.rb +8 -2
- data/_plugins/js_manifest_filter.rb +35 -0
- data/_plugins/math_preprocessor.rb +42 -2
- data/_sass/_package-docs.scss +57 -31
- data/assets/js/dist/comments.js +2 -2
- data/assets/js/dist/core.js +1 -1
- data/assets/js/dist/math.js +1 -1
- data/assets/js/dist/moderation.js +1 -1
- data/assets/js/dist/sources.json +8 -6
- data/assets/js/dist/subscriptions.js +1 -1
- data/lib/datalog/cli.rb +17 -8
- data/lib/datalog/slug.rb +38 -0
- data/lib/datalog/theme/version.rb +1 -1
- metadata +4 -3
- data/_includes/components/search-facets.html +0 -307
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jekyll
|
|
4
|
+
# `_data/js_manifest.json` records each bundle at a site-root path, so that
|
|
5
|
+
# every template can put it through `relative_url` and a site served from a
|
|
6
|
+
# subdirectory gets the right address. The loader is the one reader that
|
|
7
|
+
# cannot: `_includes/scripts.html` hands it the manifest as JSON, and no
|
|
8
|
+
# Liquid filter reaches inside that. Its copy is prefixed here instead.
|
|
9
|
+
#
|
|
10
|
+
# Without this a site with a `baseurl` imports /assets/js/dist/core.js, the
|
|
11
|
+
# import 404s, and `bootstrapFeatures` returns before it loads a single
|
|
12
|
+
# feature: no dark mode, no navigation, no search, no math (#328).
|
|
13
|
+
module JsManifestFilter
|
|
14
|
+
# The manifest with the site's baseurl in front of every path it holds.
|
|
15
|
+
# Nested, since the bundles are grouped under `features` and `entrypoints`.
|
|
16
|
+
def relative_manifest(manifest)
|
|
17
|
+
relativize_manifest_value(manifest)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def relativize_manifest_value(value)
|
|
23
|
+
case value
|
|
24
|
+
when Hash then value.transform_values { |entry| relativize_manifest_value(entry) }
|
|
25
|
+
when Array then value.map { |entry| relativize_manifest_value(entry) }
|
|
26
|
+
# `relative_url` leaves an absolute URL alone, so a manifest pointing at
|
|
27
|
+
# a CDN survives this untouched.
|
|
28
|
+
when String then relative_url(value)
|
|
29
|
+
else value
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
Liquid::Template.register_filter(Jekyll::JsManifestFilter)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "cgi"
|
|
4
|
+
require "kramdown"
|
|
5
|
+
require "kramdown-parser-gfm"
|
|
4
6
|
|
|
5
7
|
module MathPreprocessor
|
|
6
8
|
DISPLAY_PATTERNS = [
|
|
@@ -46,7 +48,7 @@ module MathPreprocessor
|
|
|
46
48
|
# so fenced blocks, highlight tags, <pre>/<code> elements and inline code
|
|
47
49
|
# spans are set aside before looking for math and put back afterwards.
|
|
48
50
|
CODE_PATTERNS = [
|
|
49
|
-
/^
|
|
51
|
+
/^[ \t]*(?<fence>(?<marker>`|~)\k<marker>{2,})[^\n]*\n.*?(?:^[ \t]*\k<fence>\k<marker>*[ \t]*$|\z)/m,
|
|
50
52
|
/\{%-?\s*highlight\b.*?\{%-?\s*endhighlight\s*-?%\}/m,
|
|
51
53
|
%r{<(pre|code)\b[^>]*>.*?</\1>}mi,
|
|
52
54
|
/(?<!`)(`+)(?!`)(?:(?!\n[ \t]*\n).)+?(?<!`)\1(?!`)/m
|
|
@@ -56,6 +58,31 @@ module MathPreprocessor
|
|
|
56
58
|
# an escape: a raw NUL byte in the source stopped RuboCop from parsing the file.
|
|
57
59
|
PLACEHOLDER = /\x00(\d+)\x00/
|
|
58
60
|
|
|
61
|
+
# Indentation alone does not identify code: list continuations and continued
|
|
62
|
+
# paragraphs can have the same indentation. Let the Markdown parser identify
|
|
63
|
+
# the code blocks, retaining their original source lines for masking.
|
|
64
|
+
class IndentedCodeParser < Kramdown::Parser::GFM
|
|
65
|
+
attr_reader :code_ranges
|
|
66
|
+
|
|
67
|
+
def initialize(source, options)
|
|
68
|
+
super
|
|
69
|
+
@code_ranges = []
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def parse_codeblock
|
|
73
|
+
first = @src.current_line_number - 1
|
|
74
|
+
super.tap do |parsed|
|
|
75
|
+
@code_ranges << (first...(@src.current_line_number - 1)) if parsed
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def self.ranges(source)
|
|
80
|
+
parser = new(source, {})
|
|
81
|
+
parser.parse
|
|
82
|
+
parser.code_ranges
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
59
86
|
class Processor
|
|
60
87
|
attr_reader :expressions
|
|
61
88
|
|
|
@@ -68,7 +95,7 @@ module MathPreprocessor
|
|
|
68
95
|
return @content unless @content&.match?(/\$|\\\(|\\\[|\\begin\{/)
|
|
69
96
|
|
|
70
97
|
@segments = []
|
|
71
|
-
processed = CODE_PATTERNS.reduce(@content
|
|
98
|
+
processed = CODE_PATTERNS.reduce(mask_indented_code(@content)) do |text, pattern|
|
|
72
99
|
text.gsub(pattern) { |match| mask(match) }
|
|
73
100
|
end
|
|
74
101
|
processed = normalize_inline_dollars(processed)
|
|
@@ -86,6 +113,19 @@ module MathPreprocessor
|
|
|
86
113
|
"\x00#{@segments.size - 1}\x00"
|
|
87
114
|
end
|
|
88
115
|
|
|
116
|
+
def mask_indented_code(text)
|
|
117
|
+
return text unless text.match?(/^(?: {4}|\t)/)
|
|
118
|
+
|
|
119
|
+
lines = text.lines
|
|
120
|
+
IndentedCodeParser.ranges(text).reverse_each do |range|
|
|
121
|
+
block = lines[range].join
|
|
122
|
+
# Keep the final line boundary visible to subsequent block patterns.
|
|
123
|
+
ending = block.end_with?("\n") ? "\n" : ""
|
|
124
|
+
lines[range] = [mask(block.delete_suffix(ending)) + ending]
|
|
125
|
+
end
|
|
126
|
+
lines.join
|
|
127
|
+
end
|
|
128
|
+
|
|
89
129
|
# Kramdown accepts $$...$$ inside prose as inline math. A div there is
|
|
90
130
|
# escaped by Markdown and leaks its attributes into the visible article.
|
|
91
131
|
# Normalize before wrapping; code is already masked and standalone or
|
data/_sass/_package-docs.scss
CHANGED
|
@@ -5,9 +5,16 @@
|
|
|
5
5
|
|
|
6
6
|
@use 'sass:color';
|
|
7
7
|
@use 'mixins' as *;
|
|
8
|
+
@use 'variables' as *;
|
|
8
9
|
|
|
9
10
|
// Color scheme - ReadTheDocs inspired
|
|
10
11
|
$pkg-primary: #2980b9;
|
|
12
|
+
// $pkg-primary is a brand colour for borders, gradients and rules. As text it
|
|
13
|
+
// reads at 4.08:1 on the panel, short of WCAG AA, and a single darker value
|
|
14
|
+
// would fail again on a dark surface — so text uses the theme's own accent and
|
|
15
|
+
// secondary inks, which _theme.scss defines for each mode.
|
|
16
|
+
$pkg-primary-text: var(--color-accent-text);
|
|
17
|
+
$pkg-muted-text: var(--color-text-secondary);
|
|
11
18
|
$pkg-success: #27ae60;
|
|
12
19
|
$pkg-warning: #f39c12;
|
|
13
20
|
$pkg-danger: #e74c3c;
|
|
@@ -15,8 +22,26 @@ $pkg-sidebar-bg: #343131;
|
|
|
15
22
|
$pkg-sidebar-text: #b3b3b3;
|
|
16
23
|
$pkg-sidebar-link: #9b9b9b;
|
|
17
24
|
$pkg-sidebar-link-hover: #fff;
|
|
18
|
-
$pkg-code-bg:
|
|
19
|
-
$pkg-border:
|
|
25
|
+
$pkg-code-bg: var(--color-background-secondary);
|
|
26
|
+
$pkg-border: var(--color-border);
|
|
27
|
+
|
|
28
|
+
// The tinted panels: a background and the ink that reads on it, for each
|
|
29
|
+
// mode. _theme.scss has no tokens for these, so they are defined here.
|
|
30
|
+
:root {
|
|
31
|
+
--pkg-tint-note: #e7f2fa;
|
|
32
|
+
--pkg-tint-tip: #dbf5e8;
|
|
33
|
+
--pkg-tint-warning: #fff3cd;
|
|
34
|
+
--pkg-tint-danger: #f8d7da;
|
|
35
|
+
--pkg-tint-ink: #{$color-ink-900};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
body.dark-mode {
|
|
39
|
+
--pkg-tint-note: #{rgba($dark-accent-primary, 0.16)};
|
|
40
|
+
--pkg-tint-tip: #{rgba($dark-accent-secondary, 0.16)};
|
|
41
|
+
--pkg-tint-warning: #{rgba($dark-warning, 0.16)};
|
|
42
|
+
--pkg-tint-danger: #{rgba($dark-danger-400, 0.22)};
|
|
43
|
+
--pkg-tint-ink: #{$dark-ink-900};
|
|
44
|
+
}
|
|
20
45
|
|
|
21
46
|
// Package Docs Container
|
|
22
47
|
.package-docs {
|
|
@@ -126,7 +151,7 @@ $pkg-border: #e1e4e5;
|
|
|
126
151
|
&__main {
|
|
127
152
|
flex: 1;
|
|
128
153
|
padding: 2rem 3rem;
|
|
129
|
-
background:
|
|
154
|
+
background: var(--color-surface);
|
|
130
155
|
min-width: 0;
|
|
131
156
|
}
|
|
132
157
|
|
|
@@ -179,7 +204,7 @@ $pkg-border: #e1e4e5;
|
|
|
179
204
|
}
|
|
180
205
|
|
|
181
206
|
pre {
|
|
182
|
-
background:
|
|
207
|
+
background: var(--color-background-secondary);
|
|
183
208
|
border: 1px solid $pkg-border;
|
|
184
209
|
border-radius: 4px;
|
|
185
210
|
padding: 1rem;
|
|
@@ -201,24 +226,30 @@ $pkg-border: #e1e4e5;
|
|
|
201
226
|
border-left: 4px solid;
|
|
202
227
|
border-radius: 4px;
|
|
203
228
|
|
|
229
|
+
// Tinted panels keep their own ink, so the tint and the text stay a
|
|
230
|
+
// pair whichever way the page is set.
|
|
204
231
|
&.note {
|
|
205
|
-
background:
|
|
232
|
+
background: var(--pkg-tint-note);
|
|
206
233
|
border-color: $pkg-primary;
|
|
234
|
+
color: var(--pkg-tint-ink);
|
|
207
235
|
}
|
|
208
236
|
|
|
209
237
|
&.tip {
|
|
210
|
-
background:
|
|
238
|
+
background: var(--pkg-tint-tip);
|
|
211
239
|
border-color: $pkg-success;
|
|
240
|
+
color: var(--pkg-tint-ink);
|
|
212
241
|
}
|
|
213
242
|
|
|
214
243
|
&.warning {
|
|
215
|
-
background:
|
|
244
|
+
background: var(--pkg-tint-warning);
|
|
216
245
|
border-color: $pkg-warning;
|
|
246
|
+
color: var(--pkg-tint-ink);
|
|
217
247
|
}
|
|
218
248
|
|
|
219
249
|
&.danger {
|
|
220
|
-
background:
|
|
250
|
+
background: var(--pkg-tint-danger);
|
|
221
251
|
border-color: $pkg-danger;
|
|
252
|
+
color: var(--pkg-tint-ink);
|
|
222
253
|
}
|
|
223
254
|
|
|
224
255
|
.admonition-title {
|
|
@@ -242,7 +273,7 @@ $pkg-border: #e1e4e5;
|
|
|
242
273
|
align-items: center;
|
|
243
274
|
gap: 1rem;
|
|
244
275
|
padding: 1rem;
|
|
245
|
-
background:
|
|
276
|
+
background: var(--color-background-secondary);
|
|
246
277
|
border: 1px solid $pkg-border;
|
|
247
278
|
border-radius: 6px;
|
|
248
279
|
text-decoration: none;
|
|
@@ -251,7 +282,7 @@ $pkg-border: #e1e4e5;
|
|
|
251
282
|
flex: 1;
|
|
252
283
|
|
|
253
284
|
&:hover {
|
|
254
|
-
background:
|
|
285
|
+
background: var(--color-border);
|
|
255
286
|
border-color: $pkg-primary;
|
|
256
287
|
}
|
|
257
288
|
|
|
@@ -273,14 +304,14 @@ $pkg-border: #e1e4e5;
|
|
|
273
304
|
|
|
274
305
|
&__footer-nav-label {
|
|
275
306
|
font-size: 0.8125rem;
|
|
276
|
-
color:
|
|
307
|
+
color: var(--color-text-secondary);
|
|
277
308
|
text-transform: uppercase;
|
|
278
309
|
letter-spacing: 0.05em;
|
|
279
310
|
}
|
|
280
311
|
|
|
281
312
|
&__footer-nav-title {
|
|
282
313
|
font-weight: 600;
|
|
283
|
-
color:
|
|
314
|
+
color: var(--color-text-primary);
|
|
284
315
|
}
|
|
285
316
|
}
|
|
286
317
|
|
|
@@ -368,7 +399,7 @@ $pkg-border: #e1e4e5;
|
|
|
368
399
|
.package-install {
|
|
369
400
|
margin: 2rem 0;
|
|
370
401
|
padding: 1.5rem;
|
|
371
|
-
background:
|
|
402
|
+
background: var(--color-background-secondary);
|
|
372
403
|
border: 1px solid $pkg-border;
|
|
373
404
|
border-radius: 6px;
|
|
374
405
|
|
|
@@ -393,15 +424,15 @@ $pkg-border: #e1e4e5;
|
|
|
393
424
|
margin-bottom: -2px;
|
|
394
425
|
cursor: pointer;
|
|
395
426
|
font-weight: 500;
|
|
396
|
-
color:
|
|
427
|
+
color: $pkg-muted-text;
|
|
397
428
|
transition: all 0.2s ease;
|
|
398
429
|
|
|
399
430
|
&:hover {
|
|
400
|
-
color: $pkg-primary;
|
|
431
|
+
color: $pkg-primary-text;
|
|
401
432
|
}
|
|
402
433
|
|
|
403
434
|
&--active {
|
|
404
|
-
color: $pkg-primary;
|
|
435
|
+
color: $pkg-primary-text;
|
|
405
436
|
border-bottom-color: $pkg-primary;
|
|
406
437
|
}
|
|
407
438
|
}
|
|
@@ -469,7 +500,7 @@ $pkg-border: #e1e4e5;
|
|
|
469
500
|
.api-function {
|
|
470
501
|
margin: 2rem 0;
|
|
471
502
|
padding: 1.5rem;
|
|
472
|
-
background:
|
|
503
|
+
background: var(--color-background-secondary);
|
|
473
504
|
border: 1px solid $pkg-border;
|
|
474
505
|
border-left: 4px solid $pkg-primary;
|
|
475
506
|
border-radius: 4px;
|
|
@@ -481,7 +512,7 @@ $pkg-border: #e1e4e5;
|
|
|
481
512
|
&__name {
|
|
482
513
|
margin: 0 0 0.75rem;
|
|
483
514
|
font-size: 1.5rem;
|
|
484
|
-
color: $pkg-primary;
|
|
515
|
+
color: $pkg-primary-text;
|
|
485
516
|
|
|
486
517
|
code {
|
|
487
518
|
background: none;
|
|
@@ -519,7 +550,7 @@ $pkg-border: #e1e4e5;
|
|
|
519
550
|
margin: 0 0 0.75rem;
|
|
520
551
|
font-size: 1.125rem;
|
|
521
552
|
font-weight: 600;
|
|
522
|
-
color:
|
|
553
|
+
color: var(--color-text-primary);
|
|
523
554
|
}
|
|
524
555
|
|
|
525
556
|
&__params {
|
|
@@ -550,7 +581,7 @@ $pkg-border: #e1e4e5;
|
|
|
550
581
|
|
|
551
582
|
&__param-type {
|
|
552
583
|
font-size: 0.875rem;
|
|
553
|
-
color:
|
|
584
|
+
color: var(--color-text-secondary);
|
|
554
585
|
font-style: italic;
|
|
555
586
|
font-weight: normal;
|
|
556
587
|
}
|
|
@@ -564,18 +595,18 @@ $pkg-border: #e1e4e5;
|
|
|
564
595
|
&__param-badge {
|
|
565
596
|
display: inline-block;
|
|
566
597
|
padding: 0.125rem 0.5rem;
|
|
567
|
-
background:
|
|
598
|
+
background: var(--color-border);
|
|
568
599
|
border-radius: 3px;
|
|
569
600
|
font-size: 0.75rem;
|
|
570
601
|
font-weight: 500;
|
|
571
602
|
text-transform: uppercase;
|
|
572
|
-
color:
|
|
603
|
+
color: var(--color-text-secondary);
|
|
573
604
|
}
|
|
574
605
|
|
|
575
606
|
&__param-desc {
|
|
576
607
|
margin: 0;
|
|
577
608
|
padding-left: 1rem;
|
|
578
|
-
color:
|
|
609
|
+
color: var(--color-text-primary);
|
|
579
610
|
line-height: 1.6;
|
|
580
611
|
|
|
581
612
|
p:last-child {
|
|
@@ -585,16 +616,16 @@ $pkg-border: #e1e4e5;
|
|
|
585
616
|
|
|
586
617
|
&__returns {
|
|
587
618
|
padding: 1rem;
|
|
588
|
-
background:
|
|
619
|
+
background: var(--color-surface);
|
|
589
620
|
border-radius: 4px;
|
|
590
621
|
}
|
|
591
622
|
|
|
592
623
|
&__return-type {
|
|
593
624
|
display: inline-block;
|
|
594
625
|
padding: 0.25rem 0.625rem;
|
|
595
|
-
background:
|
|
626
|
+
background: var(--pkg-tint-note);
|
|
596
627
|
border-radius: 3px;
|
|
597
|
-
color:
|
|
628
|
+
color: var(--pkg-tint-ink);
|
|
598
629
|
font-weight: 600;
|
|
599
630
|
font-size: 0.9375rem;
|
|
600
631
|
margin-bottom: 0.5rem;
|
|
@@ -602,12 +633,7 @@ $pkg-border: #e1e4e5;
|
|
|
602
633
|
|
|
603
634
|
&__examples {
|
|
604
635
|
pre {
|
|
605
|
-
background: #2d2d2d;
|
|
606
636
|
border: none;
|
|
607
|
-
|
|
608
|
-
code {
|
|
609
|
-
color: #e6e6e6;
|
|
610
|
-
}
|
|
611
637
|
}
|
|
612
638
|
}
|
|
613
639
|
|
data/assets/js/dist/comments.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
`).forEach((
|
|
1
|
+
import{a as P,c as x,d as V,e as W}from"./chunks/chunk-WIRUK3OZ.js";import{a as L,b as J,c as K}from"./chunks/chunk-VZ5WKQVA.js";import{a as F,b as I}from"./chunks/chunk-PATLC23F.js";var R="comments",ee=3,Y=/^https?:\/\//i,te=new Set(["disabled","unsupported","version"]);function ne(e,t){let n=e.querySelector(t);if(!n)return{};try{return JSON.parse(n.textContent)||{}}catch(a){return{}}}function re(e,t){return Object.keys(t).reduce((n,a)=>n.split(`{{${a}}}`).join(t[a]),e)}function ae(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return String(e||"");try{return n.toLocaleString(t||void 0,{dateStyle:"medium",timeStyle:"short"})}catch(a){return n.toISOString()}}function se(e,t=!0){let n=Array.isArray(e)?e.filter(i=>i&&typeof i=="object"):[],a=new Map;n.forEach(i=>a.set(String(i.id),{comment:i,replies:[]}));let f=[];a.forEach(i=>{let s=i.comment.parent_id,p=t&&s!==null&&s!==void 0?a.get(String(s)):null;p&&p!==i?p.replies.push(i):f.push(i)});let m=(i,s)=>(Date.parse(i.comment.created_at)||0)-(Date.parse(s.comment.created_at)||0),g=i=>(i.sort(m),i.forEach(s=>g(s.replies)),i);return g(f)}function z(e,t,n={}){let{labels:a={},lang:f,replies:m=!1,onReply:g}=n,i=t.status==="pending",s=e.createElement("li");s.className=i?"comment comment--pending":"comment",t.id!==null&&t.id!==void 0&&(s.id=`comment-${t.id}`);let p=e.createElement("article");p.className="comment__card";let _=e.createElement("header");_.className="comment__meta";let h=t.author&&typeof t.author=="object"?t.author:{},y=String(h.name||"").trim()||a.anonymous||"Anonymous",o;if(Y.test(String(h.url||""))?(o=e.createElement("a"),o.href=h.url,o.rel="nofollow noopener ugc"):o=e.createElement("span"),o.className="comment__author",o.textContent=y,_.appendChild(o),t.created_at){let c=e.createElement("time");c.className="comment__time",c.dateTime=String(t.created_at),c.textContent=ae(t.created_at,f),_.appendChild(c)}if(i){let c=e.createElement("span");c.className="comment__pending",c.textContent=a.pending||"Awaiting moderation",_.appendChild(c)}p.appendChild(_);let C=e.createElement("div");if(C.className="comment__body",String(t.body||"").split(/\n{2,}/).forEach(c=>{let b=e.createElement("p");c.split(`
|
|
2
|
+
`).forEach((N,E)=>{E>0&&b.appendChild(e.createElement("br")),b.appendChild(e.createTextNode(N))}),C.appendChild(b)}),p.appendChild(C),m&&g&&!i&&t.id!==null&&t.id!==void 0){let c=e.createElement("button");c.type="button",c.className="comment__reply post-tool",c.textContent=a.reply||"Reply",c.addEventListener("click",()=>g(t)),p.appendChild(c)}return s.appendChild(p),s}function G(e,t){let n=t.querySelector(":scope > .comments-thread__replies");return n||(n=e.createElement("ol"),n.className="comments-thread__replies",t.appendChild(n)),n}function H(e,t,n,a){n.forEach(f=>{let m=z(e,f.comment,a);f.replies.length>0&&H(e,G(e,m),f.replies,a),t.appendChild(m)})}function ie(e,t){let n={name:e.name||""};return e.email&&(n.email=e.email),e.url&&(n.url=e.url),{path:t,parent_id:e.parent_id||null,author:n,body:e.body||""}}function oe(e,t,n={}){let a={};return e.author.name||(a.name=n.name_required||"Say who you are."),e.author.email&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.author.email)&&(a.email=n.email_invalid||"That does not look like an email address."),e.author.url&&!Y.test(e.author.url)&&(a.url=n.url_invalid||"A website address starts with http:// or https://."),e.body.trim().length<ee&&(a.body=n.body_short||"Say a little more."),t.website&&(a.website="spam"),Object.keys(a).length>0?a:null}function le(e,t={}){let n=e.ownerDocument,a=t.window||n.defaultView,f=e.dataset.commentsEndpoint||"",m=t.client||(f?J(I(F({},a&&a.DatalogDynamicServices||{}),{base_url:f})):K()),g=e.dataset.commentsPath||"/",i=e.dataset.commentsReplies!=="false",s=ne(e,"[data-comments-labels]"),p=s.errors||{},_=n.documentElement.lang||void 0,h=e.querySelector("[data-comments-status]"),y=e.querySelector("[data-comments-list]"),o=e.querySelector("form"),C=P(o),c=o?o.elements.namedItem("parent_id"):null,b=e.querySelector("[data-comments-replying]"),N=e.querySelector("[data-comments-replying-to]"),E=null,D=!1,j=!1,O=new Map,v=(r,d="",u={})=>{if(e.dataset.state=r,!!h&&(h.textContent=d,h.hidden=d==="",h.setAttribute("role",u.alert?"alert":"status"),u.retry)){let l=n.createElement("button");l.type="button",l.className="post-tool",l.setAttribute("data-comments-retry",""),l.textContent=s.retry||"Try again",l.addEventListener("click",()=>A.load()),h.appendChild(n.createTextNode(" ")),h.appendChild(l)}},k=()=>(E||(E=m.feature(R).catch(r=>{throw E=null,r})),E),$=r=>{if(!c)return;if(c.value=String(r.id),N){let u=r.author&&r.author.name?r.author.name:s.anonymous||"Anonymous";N.textContent=re(s.replying_to||"Replying to {{name}}",{name:u})}b&&(b.hidden=!1);let d=o.elements.namedItem("body");d&&typeof d.focus=="function"&&d.focus()},T=()=>{c&&(c.value=""),b&&(b.hidden=!0)},M={labels:s,lang:_,replies:i,onReply:$},Z=(r,d)=>{let u=r.id?n.getElementById(r.id):null;if(u&&y.contains(u)){let S=u.querySelector(":scope > .comments-thread__replies");S&&r.appendChild(S),u.replaceWith(r);return}let l=i&&d!==null&&d!==void 0?y.querySelector(`#comment-${CSS.escape(String(d))}`):null;(l?G(n,l):y).appendChild(r),y.hidden=!1,e.dataset.state==="empty"&&v("loaded")},A={root:e,form:o,reply:$,cancelReply:T,async load(){if(D)return null;D=!0,v("loading",s.loading||"");try{await k();let r=await m.get(`${m.pathFor(R)}?path=${encodeURIComponent(g)}`),d=r&&r.data&&Array.isArray(r.data.comments)?[...r.data.comments]:[];d.forEach(l=>{(l==null?void 0:l.id)!=null&&O.delete(String(l.id))}),d.push(...O.values()),y.textContent="";let u=se(d,i);return H(n,y,u,M),y.hidden=u.length===0,v(u.length>0?"loaded":"empty",u.length>0?"":s.empty||""),j=!0,d}catch(r){return r&&te.has(r.kind)?(v("disabled",L(r,p)),o&&(o.hidden=!0)):v("error",L(r,p),{alert:!0,retry:!0}),null}finally{D=!1}},async submit(){let r=V(o),d=ie(r,g),u=oe(d,r,s);if(u)return u.website?(x(o,"success",s.posted_pending||""),null):(x(o,"invalid",p.invalid||"",u),null);x(o,"pending",s.sending||"");try{await k();let l=await m.post(m.pathFor(R),d,{idempotencyKey:C.key(d)}),S=l&&l.data&&typeof l.data=="object"?l.data:{},w=S.comment&&typeof S.comment=="object"?S.comment:null,B=S.status==="pending"||w!==null&&w.status==="pending";if(w){let q=B?I(F({},w),{status:"pending"}):w;q.id!=null&&O.set(String(q.id),q),Z(z(n,q,M),w.parent_id)}return C.clear(),o.reset(),T(),x(o,"success",B?s.posted_pending||"":s.posted||""),l}catch(l){return W(o,l,p),null}}};o&&(o.addEventListener("submit",r=>{r.preventDefault(),A.submit()}),e.querySelectorAll("[data-comments-cancel-reply]").forEach(r=>{r.addEventListener("click",T)}));let U=()=>{j||A.load()};if(t.immediate||!a||typeof a.IntersectionObserver!="function")U();else{let r=new a.IntersectionObserver(d=>{d.some(u=>u.isIntersecting)&&(r.disconnect(),U())},{rootMargin:"400px 0px"});r.observe(e)}return A}function Q(e=document){return Array.from(e.querySelectorAll("[data-comments-thread]")).map(t=>le(t))}function X(){Q(document)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",X,{once:!0}):X();
|
data/assets/js/dist/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p}from"./chunks/chunk-PATLC23F.js";var _="[data-copy-citation], [data-copy-bibliography]";var g=!1;function G(t){let e=t.getAttribute("data-target"),n=e?document.getElementById(e):null;return n?"value"in n?n.value:n.textContent||"":""}async function O(t){let e=G(t);if(!(!e||!navigator.clipboard||!navigator.clipboard.writeText)){t.dataset.originalText===void 0&&(t.dataset.originalText=t.textContent);try{await navigator.clipboard.writeText(e),t.dataset.copied="true",t.textContent="Copied!",setTimeout(()=>{t.dataset.copied="false",t.textContent=t.dataset.originalText},2e3)}catch(n){t.dataset.copied="error",t.textContent="Error"}}}function h(){g||(g=!0,document.addEventListener("click",t=>{let e=t.target instanceof Element?t.target.closest(_):null;e&&O(e)}))}var y="datalog-color-mode",l="dark-mode";function b(){try{return localStorage.getItem(y)}catch(t){return null}}function $(t){try{localStorage.setItem(y,t)}catch(e){}}function q(t){let e=b();return e==="dark"?!0:e==="light"?!1:t.matches}function E(){let t=document.querySelector("[data-toggle-dark-mode]"),e=document.body,n=window.matchMedia("(prefers-color-scheme: dark)");q(n)&&e.classList.add(l);let r=()=>{let a=e.classList.contains(l)?"dark":"light";e.dataset.theme=a,document.documentElement.dataset.theme=a},o=()=>{r(),t&&t.setAttribute("aria-pressed",e.classList.contains(l))};o(),t&&t.addEventListener("click",()=>{let a=e.classList.toggle(l);t.setAttribute("aria-pressed",String(a)),$(a?"dark":"light"),r()}),n.addEventListener("change",a=>{b()||(a.matches?e.classList.add(l):e.classList.remove(l),o())})}var H="datalog-github-";var S=Symbol("recently-failed");function f(t,e){return`${H}${t}-${e}`}function K(t,e,n){try{let r=localStorage.getItem(f(t,e));if(!r)return null;let o=JSON.parse(r);if(!o||typeof o!="object")return null;let a=o.failed?6e5:n;return Date.now()-o.timestamp>a?(localStorage.removeItem(f(t,e)),null):o.failed?S:o.data}catch(r){return null}}function L(t,e,n){try{localStorage.setItem(f(t,e),JSON.stringify(p({timestamp:Date.now()},n)))}catch(r){}}async function M(t,e,n,r){let o=K(t,e,r);if(o===S)return null;if(o)return o;try{let a=await fetch(`${n}/${t}/${e}`);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let s=await a.json();return L(t,e,{data:s}),s}catch(a){return L(t,e,{failed:!0}),null}}function B(t,e){t.querySelectorAll("[data-github-stat]").forEach(r=>{let o=r.getAttribute("data-github-stat");if(!o)return;let a=e[o];typeof a=="number"?r.textContent=a.toLocaleString():typeof a=="string"&&a.length>0&&(r.textContent=a)})}function F(t){t.dataset.githubState="error";let e=t.getAttribute("data-github-unavailable");e&&t.querySelectorAll("[data-github-stat]").forEach(n=>{n.textContent=e})}function v(){let t=document.querySelectorAll("[data-github-owner][data-github-repo]");if(!t.length)return Promise.resolve();let n=(window.DatalogIntegrations||{}).github||{};if(n.enabled===!1)return Promise.resolve();let r=n.api_base||"https://api.github.com/repos",o=Number(n.cache_ttl||43200)*1e3,a=Array.from(t).map(s=>{let u=s.getAttribute("data-github-owner"),d=s.getAttribute("data-github-repo");return!u||!d?Promise.resolve():(s.dataset.githubState="loading",M(u,d,r,o).then(i=>{if(!i){F(s);return}B(s,i),s.dataset.githubState="ready"}))});return Promise.all(a)}var z="[data-language-filter], [data-navigate-on-change]";function U(t){if(typeof t!="string")return null;let e=Array.from(t).filter(r=>{let o=r.codePointAt(0);return o>31&&o!==127}).join("").trim();if(!e)return null;let n=/^[a-z][a-z0-9+.-]*:/i.exec(e);return n&&!/^https?:$/i.test(n[0])?null:e}function A(){let t=document.querySelectorAll(z);t.length!==0&&t.forEach(e=>{e.addEventListener("change",n=>{let r=U(n.target&&n.target.value);r&&(window.location.href=r)})})}var V="(min-width: 48rem)",T="#site-nav",k=".nav-toggle",m="nav-open";function w(t){return t.replace(/index\.html$/,"").replace(/\/$/,"")}function j(t){let e=t.getAttribute("href");if(!e)return null;try{let n=new URL(e,window.location.origin);if(!n.hash)return null;let r=new URL(window.location.href);return w(n.pathname)!==w(r.pathname)?null:n.hash.replace("#","")}catch(n){return null}}function Y(t){if(!t)return!1;let e=document.getElementById(t);return e?(e.scrollIntoView({block:"start"}),!0):!1}function x(){let t=document.querySelector(T);if(!t)return;let e=document.querySelector(k),n=document.body,r=window.matchMedia(V),o=i=>{if(i){t.dataset.open="true",n.classList.remove(m),e&&(e.setAttribute("aria-expanded","false"),e.classList.remove("is-active"));return}let c=t.dataset.open==="true";c||(t.dataset.open="false"),e&&(e.setAttribute("aria-expanded",String(c)),e.classList.toggle("is-active",c))},a=({focusToggle:i=!1}={})=>{r.matches||(t.dataset.open="false",n.classList.remove(m),e&&(e.setAttribute("aria-expanded","false"),e.classList.remove("is-active"),i&&e.focus()))},s=()=>{r.matches||(t.dataset.open="true",n.classList.add(m),e&&(e.setAttribute("aria-expanded","true"),e.classList.add("is-active")))},u=()=>{r.matches||(t.dataset.open==="true"?a():s())};r.matches||(t.dataset.open="false"),o(r.matches),r.addEventListener("change",i=>{i.matches?o(!0):(a(),t.dataset.open="false",o(!1))}),t.querySelectorAll(".nav-link").forEach(i=>{let c=j(i);i.addEventListener("click",R=>{r.matches||a(),c&&Y(c)&&R.preventDefault()})}),e&&e.addEventListener("click",()=>{u()}),document.addEventListener("keydown",i=>{i.key==="Escape"&&t.dataset.open==="true"&&a({focusToggle:!0})}),document.addEventListener("click",i=>{if(r.matches||t.dataset.open!=="true")return;let c=i.target;!c||typeof c.closest!="function"||c.closest(T)||e&&c.closest(k)||a()})}function J(t,e){let n=window.pageYOffset||document.documentElement.scrollTop,r=document.documentElement.scrollHeight-window.innerHeight,o=r>0?Math.min(n/r*100,100):0;t.tagName==="PROGRESS"?t.setAttribute("value",String(o)):t.style.setProperty("--progress",`${o}%`),e&&(e.textContent=Math.round(o))}function C(){let t=document.querySelector("[data-scroll-progress]");if(!t)return;let e=document.querySelector("[data-scroll-progress-value]"),n=()=>J(t,e);n(),window.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",n)}function I(t){if(!t)return;let e=t.querySelector("input[type='search']"),n=t.getAttribute("action");e?(e.focus(),e.select()):n&&(window.location.href=n)}function X(t){if(!t)return!1;if(t.isContentEditable)return!0;let e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||e==="SELECT"}function N(){let t=document.querySelector(".site-search");t&&document.addEventListener("keydown",e=>{X(document.activeElement)||(e.key==="/"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),I(t)),(e.key==="k"||e.key==="K")&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),I(t)))})}function Q(t){if(!t)return;t.getAttribute("tabindex")===null&&(t.setAttribute("tabindex","-1"),t.dataset.skipLinkTempTabindex="true"),t.addEventListener("blur",()=>{t.dataset.skipLinkTempTabindex&&(t.removeAttribute("tabindex"),delete t.dataset.skipLinkTempTabindex)},{once:!0}),t.focus()}function P(){let t=document.querySelectorAll(".skip-link[href^='#']");t.length&&t.forEach(e=>{e.addEventListener("click",n=>{let o=(e.getAttribute("href")||"").slice(1);if(!o)return;let a=document.getElementById(o);a&&(n.preventDefault(),Q(a))})})}var Z=[P,x,E,A,C,N,v,h];function D(t=Z){t.forEach(e=>{try{e()}catch(n){}})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>D()):D();export{D as initializeCore};
|
|
1
|
+
import{a as T}from"./chunks/chunk-PATLC23F.js";var j="[data-copy-citation], [data-copy-bibliography], [data-copy-target]";var v=!1;function J(t){let e=t.getAttribute("data-target"),n=e?document.getElementById(e):null;return n?"value"in n?n.value:n.textContent||"":""}function X(t){let e=document.createElement("textarea");e.value=t,e.setAttribute("aria-hidden","true"),e.setAttribute("readonly","readonly"),e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();let n=!1;try{n=document.execCommand("copy")}catch(r){n=!1}return e.remove(),n}async function Q(t){if(navigator.clipboard&&navigator.clipboard.writeText)try{return await navigator.clipboard.writeText(t),!0}catch(e){}return X(t)}async function Z(t){let e=J(t);if(!e)return;t.dataset.originalText===void 0&&(t.dataset.originalText=t.textContent);let n=await Q(e);t.dataset.copied=n?"true":"error",t.textContent=n?t.dataset.copiedLabel||"Copied!":t.dataset.errorLabel||"Error",n&&setTimeout(()=>{t.dataset.copied="false",t.textContent=t.dataset.originalText},2e3)}function w(){v||(v=!0,document.addEventListener("click",t=>{let e=t.target instanceof Element?t.target.closest(j):null;e&&Z(e)}))}var x="datalog-color-mode",f="dark-mode";function k(){try{return localStorage.getItem(x)}catch(t){return null}}function W(t){try{localStorage.setItem(x,t)}catch(e){}}function tt(t){let e=k();return e==="dark"?!0:e==="light"?!1:t.matches}function I(){let t=document.querySelector("[data-toggle-dark-mode]"),e=document.body,n=window.matchMedia("(prefers-color-scheme: dark)");tt(n)&&e.classList.add(f);let r=()=>{let a=e.classList.contains(f)?"dark":"light";e.dataset.theme=a,document.documentElement.dataset.theme=a},o=()=>{r(),t&&t.setAttribute("aria-pressed",e.classList.contains(f))};o(),t&&t.addEventListener("click",()=>{let a=e.classList.toggle(f);t.setAttribute("aria-pressed",String(a)),W(a?"dark":"light"),r()}),n.addEventListener("change",a=>{k()||(a.matches?e.classList.add(f):e.classList.remove(f),o())})}var et="datalog-github-";var _=Symbol("recently-failed");function E(t,e){return`${et}${t}-${e}`}function nt(t,e,n){try{let r=localStorage.getItem(E(t,e));if(!r)return null;let o=JSON.parse(r);if(!o||typeof o!="object")return null;let a=o.failed?6e5:n;return Date.now()-o.timestamp>a?(localStorage.removeItem(E(t,e)),null):o.failed?_:o.data}catch(r){return null}}function C(t,e,n){try{localStorage.setItem(E(t,e),JSON.stringify(T({timestamp:Date.now()},n)))}catch(r){}}async function rt(t,e,n,r){let o=nt(t,e,r);if(o===_)return null;if(o)return o;try{let a=await fetch(`${n}/${t}/${e}`);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let s=await a.json();return C(t,e,{data:s}),s}catch(a){return C(t,e,{failed:!0}),null}}function ot(t,e){t.querySelectorAll("[data-github-stat]").forEach(r=>{let o=r.getAttribute("data-github-stat");if(!o)return;let a=e[o];typeof a=="number"?r.textContent=a.toLocaleString():typeof a=="string"&&a.length>0&&(r.textContent=a)})}function at(t){t.dataset.githubState="error";let e=t.getAttribute("data-github-unavailable");e&&t.querySelectorAll("[data-github-stat]").forEach(n=>{n.textContent=e})}function N(){let t=document.querySelectorAll("[data-github-owner][data-github-repo]");if(!t.length)return Promise.resolve();let n=(window.DatalogIntegrations||{}).github||{};if(n.enabled===!1)return Promise.resolve();let r=n.api_base||"https://api.github.com/repos",o=Number(n.cache_ttl||43200)*1e3,a=Array.from(t).map(s=>{let u=s.getAttribute("data-github-owner"),d=s.getAttribute("data-github-repo");return!u||!d?Promise.resolve():(s.dataset.githubState="loading",rt(u,d,r,o).then(i=>{if(!i){at(s);return}ot(s,i),s.dataset.githubState="ready"}))});return Promise.all(a)}var it={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1};function h(t,e,n,r=!1){t.forEach(o=>{let a=o===n;o.setAttribute("aria-selected",a?"true":"false"),o.tabIndex=a?0:-1,o.classList.toggle("package-install__tab-btn--active",a)}),e.forEach(o=>{o.hidden=o.dataset.tabContent!==n.dataset.tab}),r&&n.focus()}function st(t){let e=Array.from(t.querySelectorAll("[data-tab]")),n=Array.from(t.querySelectorAll("[data-tab-content]"));if(e.length===0)return null;let r=e.find(o=>o.getAttribute("aria-selected")==="true")||e[0];return h(e,n,r),e.forEach(o=>{o.addEventListener("click",()=>h(e,n,o)),o.addEventListener("keydown",a=>{if(a.key==="Home"||a.key==="End"){a.preventDefault(),h(e,n,a.key==="Home"?e[0]:e[e.length-1],!0);return}let s=it[a.key];if(!s)return;a.preventDefault();let u=(e.indexOf(o)+s+e.length)%e.length;h(e,n,e[u],!0)})}),{container:t,tabs:e,panels:n}}function D(t=document){return Array.from(t.querySelectorAll("[data-install-tabs]")).map(e=>st(e)).filter(Boolean)}var ct="[data-language-filter], [data-navigate-on-change]";function lt(t){if(typeof t!="string")return null;let e=Array.from(t).filter(r=>{let o=r.codePointAt(0);return o>31&&o!==127}).join("").trim();if(!e)return null;let n=/^[a-z][a-z0-9+.-]*:/i.exec(e);return n&&!/^https?:$/i.test(n[0])?null:e}function R(){let t=document.querySelectorAll(ct);t.length!==0&&t.forEach(e=>{e.addEventListener("change",n=>{let r=lt(n.target&&n.target.value);r&&(window.location.href=r)})})}var ut="(min-width: 48rem)",P="#site-nav",q=".nav-toggle",A="nav-open";function G(t){return t.replace(/index\.html$/,"").replace(/\/$/,"")}function dt(t){let e=t.getAttribute("href");if(!e)return null;try{let n=new URL(e,window.location.origin);if(!n.hash)return null;let r=new URL(window.location.href);return G(n.pathname)!==G(r.pathname)?null:n.hash.replace("#","")}catch(n){return null}}function ft(t){if(!t)return!1;let e=document.getElementById(t);return e?(e.scrollIntoView({block:"start"}),!0):!1}function H(){let t=document.querySelector(P);if(!t)return;let e=document.querySelector(q),n=document.body,r=window.matchMedia(ut),o=i=>{if(i){t.dataset.open="true",n.classList.remove(A),e&&(e.setAttribute("aria-expanded","false"),e.classList.remove("is-active"));return}let l=t.dataset.open==="true";l||(t.dataset.open="false"),e&&(e.setAttribute("aria-expanded",String(l)),e.classList.toggle("is-active",l))},a=({focusToggle:i=!1}={})=>{r.matches||(t.dataset.open="false",n.classList.remove(A),e&&(e.setAttribute("aria-expanded","false"),e.classList.remove("is-active"),i&&e.focus()))},s=()=>{r.matches||(t.dataset.open="true",n.classList.add(A),e&&(e.setAttribute("aria-expanded","true"),e.classList.add("is-active")))},u=()=>{r.matches||(t.dataset.open==="true"?a():s())};r.matches||(t.dataset.open="false"),o(r.matches),r.addEventListener("change",i=>{i.matches?o(!0):(a(),t.dataset.open="false",o(!1))}),t.querySelectorAll(".nav-link").forEach(i=>{let l=dt(i);i.addEventListener("click",p=>{r.matches||a(),l&&ft(l)&&p.preventDefault()})}),e&&e.addEventListener("click",()=>{u()}),document.addEventListener("keydown",i=>{i.key==="Escape"&&t.dataset.open==="true"&&a({focusToggle:!0})}),document.addEventListener("click",i=>{if(r.matches||t.dataset.open!=="true")return;let l=i.target;!l||typeof l.closest!="function"||l.closest(P)||e&&l.closest(q)||a()})}function pt(t,e){let n=window.pageYOffset||document.documentElement.scrollTop,r=document.documentElement.scrollHeight-window.innerHeight,o=r>0?Math.min(n/r*100,100):0;t.tagName==="PROGRESS"?t.setAttribute("value",String(o)):t.style.setProperty("--progress",`${o}%`),e&&(e.textContent=Math.round(o))}function K(){let t=document.querySelector("[data-scroll-progress]");if(!t)return;let e=document.querySelector("[data-scroll-progress-value]"),n=()=>pt(t,e);n(),window.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",n)}function B(t){if(!t)return;let e=t.querySelector("input[type='search']"),n=t.getAttribute("action");e?(e.focus(),e.select()):n&&(window.location.href=n)}function mt(t){if(!t)return!1;if(t.isContentEditable)return!0;let e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||e==="SELECT"}function M(){let t=document.querySelector(".site-search");t&&document.addEventListener("keydown",e=>{mt(document.activeElement)||(e.key==="/"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),B(t)),(e.key==="k"||e.key==="K")&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),B(t)))})}function gt(t){if(!t)return;t.getAttribute("tabindex")===null&&(t.setAttribute("tabindex","-1"),t.dataset.skipLinkTempTabindex="true"),t.addEventListener("blur",()=>{t.dataset.skipLinkTempTabindex&&(t.removeAttribute("tabindex"),delete t.dataset.skipLinkTempTabindex)},{once:!0}),t.focus()}function F(){let t=document.querySelectorAll(".skip-link[href^='#']");t.length&&t.forEach(e=>{e.addEventListener("click",n=>{let o=(e.getAttribute("href")||"").slice(1);if(!o)return;let a=document.getElementById(o);a&&(n.preventDefault(),gt(a))})})}var ht="is-active",yt=".post-content h2[id], .post-content h3[id], .post-content h4[id]";function Et(t,e=100){let n=null;return t.forEach(r=>{r.getBoundingClientRect().top<=e&&(n=r)}),n}function At(t,e,n){let r=n-e;return r<=0?0:Math.min(100,Math.max(0,Math.floor(t/r*100)))}function bt(t,e={}){let n=t.ownerDocument,r=e.window||n.defaultView,o=Array.from(t.querySelectorAll(".enhanced-toc__content a")),a=t.querySelector("[data-toc-toggle]"),s=t.querySelector(".enhanced-toc__content"),u=t.querySelector("[data-toc-progress]"),d=t.querySelector("[data-progress-percent]"),i=Array.from(n.querySelectorAll(yt)),l=t.parentElement||t,p=null;a&&s&&a.addEventListener("click",()=>{let c=a.getAttribute("aria-expanded")==="true";a.setAttribute("aria-expanded",c?"false":"true"),s.hidden=c,t.classList.toggle("is-collapsed",c)});let Y=()=>{if(i.length===0)return 100;let c=parseFloat(r.getComputedStyle(i[0]).scrollMarginTop);return(Number.isFinite(c)?c:100)+8},z=()=>{let c=Et(i,Y()),L=c?`#${c.id}`:null;o.forEach(g=>{let S=L!==null&&g.getAttribute("href")===L;g.classList.toggle(ht,S),S?g.setAttribute("aria-current","location"):g.removeAttribute("aria-current")})},U=()=>{let c=At(r.scrollY,r.innerHeight,n.documentElement.scrollHeight);c!==p&&(p=c,u&&(u.style.width=`${c}%`),d&&(d.textContent=String(c)))},V=()=>{let c=l.getBoundingClientRect().top+r.scrollY;t.classList.toggle("is-sticky",r.scrollY>c-20)},y=()=>{z(),U(),V()},m=null,b=()=>{m!==null&&r.cancelAnimationFrame(m),m=r.requestAnimationFrame(()=>{m=null,y()})};return i.length>0&&(r.addEventListener("scroll",b,{passive:!0}),r.addEventListener("resize",b,{passive:!0}),y()),{toc:t,update:y,headings:i,links:o}}function O(t=document){return Array.from(t.querySelectorAll("[data-toc-enhanced]")).map(e=>bt(e))}var Lt=[F,H,I,R,K,M,N,w,O,D];function $(t=Lt){t.forEach(e=>{try{e()}catch(n){}})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>$()):$();export{$ as initializeCore};
|
data/assets/js/dist/math.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){let d={init(t){this.MathJax=t,this.displayCounter=0,this.anchorCounter=0,this.equationMap=new Map,this.editor=null,this.editorOpen=!1,this.messageTimeout=null,this.initialized=!0,this.pendingTypeset=[],this.setupEditor(),t.startup.promise.then(()=>{if(this.decorateExisting(t.startup.document.math||[]),this.updateEquationReferences(),this.pendingTypeset.length>0){let e=[...this.pendingTypeset];this.pendingTypeset=[],e.forEach(a=>{this.renderLatex(a.target,a.latex,a.options||{})})}}).catch(e=>{}),document.addEventListener("click",e=>this.handleClick(e)),document.addEventListener("keydown",e=>this.handleKeydown(e))},onPageReady(){this.updateEquationReferences()},decorateExisting(t){!t||t.length===0||(this.displayCounter=0,this.anchorCounter=0,this.equationMap.clear(),t.forEach(e=>{try{this.decorateMathItem(e)}catch(a){}}))},decorateMathItem(t){if(!t||!t.typesetRoot)return;let e=t.typesetRoot,a=t.math||"",n=e.closest("[data-math-alt]")||e,i=this.resolveAltText(n,a);e.dataset.mathLatex=a,e.setAttribute("tabindex","0"),e.setAttribute("role","math"),this.syncAltAttributes(n,e,i),t.display?this.decorateDisplay(e,a):this.decorateInline(e,a),this.exposeReferenceLinks(e)},exposeAllReferenceLinks(t){(t&&typeof t.querySelectorAll=="function"?t:document).querySelectorAll("mjx-container").forEach(a=>this.exposeReferenceLinks(a))},exposeReferenceLinks(t){if(!t||typeof t.querySelectorAll!="function")return;let e=Array.from(t.querySelectorAll("mjx-assistive-mml [href]")),a=t;t.querySelectorAll('[aria-hidden="true"] a[href]').forEach(n=>{n.setAttribute("tabindex","-1");let i=n.getAttribute("href")||"";if(!i.startsWith("#")||n.dataset.mathReferenceExposed==="true")return;n.dataset.mathReferenceExposed="true";let r=e.find(l=>l.getAttribute("href")===i),s=(r&&r.textContent||n.textContent||"").replace(/\s+/g," ").trim(),o=document.createElement("a");o.className="math-reference-link",o.href=i,o.textContent=s?`Equation ${s}`:"Equation",a.insertAdjacentElement("afterend",o),a=o})},decorateInline(t,e){t&&(t.classList.contains("math-expression__inline")||t.classList.add("math-expression__inline"),t.dataset.mathLatexClean=this.cleanLatex(e))},decorateDisplay(t,e){if(!t)return;let n=t.parentElement&&t.parentElement.classList.contains("math-expression")?t.parentElement:null;n||(n=document.createElement("figure"),n.className="math-expression math-expression--display",t.parentNode.insertBefore(n,t),n.appendChild(t));let i=this.extractEquationInfo(e);this.anchorCounter+=1;let r=`eq:auto-${this.anchorCounter}`,s=i.tag||"";i.skipNumber||(this.displayCounter+=1,s||(s=String(this.displayCounter)));let o=s?`(${s})`:"",l=this.buildAnchorId(i.label,r);if(n.dataset.mathLatex=e,n.dataset.mathLatexClean=this.cleanLatex(e),t.dataset.mathAlt&&!n.dataset.mathAlt&&(n.dataset.mathAlt=t.dataset.mathAlt),o?n.dataset.equationNumber=o:n.removeAttribute("data-equation-number"),n.dataset.equationLabel=i.label||"",l){n.id=l;let c=o||i.label||l;if((o||i.label)&&(this.setEquationReference(l,c),i.label&&i.label!==l&&this.setEquationReference(i.label,c,l),i.label&&i.label.startsWith("eq:"))){let h=i.label.replace(/^eq:/,"");this.setEquationReference(h,c,l)}}this.attachNumberBadge(n,o),this.attachToolbar(n)},extractEquationInfo(t){let e=(t||"").trim(),a=e.match(/\\tag\*?\{([^}]*)\}/),n=e.match(/\\label\{([^}]*)\}/),i=/\\notag|\\nonumber/.test(e);return{tag:a?a[1].trim():"",label:n?n[1].trim():"",skipNumber:i}},buildAnchorId(t,e){return t?t.startsWith("eq:")?t:`eq:${t}`:e||""},setEquationReference(t,e,a){if(!t)return;let n=a||t,i=e||t;this.equationMap.set(t,{anchor:n,label:t,number:i}),t.startsWith("eq:")||this.equationMap.set(`eq:${t}`,{anchor:n,label:t,number:i})},attachNumberBadge(t,e){let a=t.querySelector(".math-expression__number"),n=t.querySelector(".math-expression__sr");if(!e){a&&a.remove(),n&&n.remove();return}a||(a=document.createElement("span"),a.className="math-expression__number",a.setAttribute("aria-hidden","true"),t.appendChild(a)),a.textContent=e,n||(n=document.createElement("span"),n.className="visually-hidden math-expression__sr",t.appendChild(n)),n.textContent=`Equation ${e.replace(/[()]/g,"")}`},attachToolbar(t){let e=t.querySelector(".math-expression__toolbar");if(!e){e=document.createElement("div"),e.className="math-expression__toolbar";let a=document.createElement("button");a.type="button",a.className="math-expression__button",a.setAttribute("data-math-copy","true"),a.setAttribute("aria-label","Copy LaTeX code");let n=document.createElement("span");n.setAttribute("aria-hidden","true"),n.textContent="\u29C9";let i=document.createElement("span");i.className="visually-hidden",i.textContent="Copy equation",a.appendChild(n),a.appendChild(i);let r=document.createElement("button");r.type="button",r.className="math-expression__button",r.setAttribute("data-math-edit","true"),r.setAttribute("aria-label","Open equation editor");let s=document.createElement("span");s.setAttribute("aria-hidden","true"),s.textContent="\u270E";let o=document.createElement("span");o.className="visually-hidden",o.textContent="Edit equation",r.appendChild(s),r.appendChild(o);let l=document.createElement("span");l.className="math-expression__message",l.setAttribute("aria-live","polite"),l.hidden=!0,e.appendChild(a),e.appendChild(r),e.appendChild(l),t.appendChild(e)}},handleClick(t){let e=t.target.closest("[data-math-copy]");if(e){t.preventDefault();let s=e.closest(".math-expression"),o=s?s.dataset.mathLatexClean||s.dataset.mathLatex:null;this.copyLatex(o,s);return}let a=t.target.closest("[data-math-edit]");if(a){t.preventDefault();let s=a.closest(".math-expression"),o=s&&s.dataset.mathLatex||"";this.openEditor(o);return}if(t.target.closest("[data-math-editor-close]")){t.preventDefault(),this.closeEditor();return}if(t.target.closest("[data-math-editor-copy]")){t.preventDefault(),this.editor&&this.editor.textarea&&this.copyLatex(this.editor.textarea.value,null,this.editor.status);return}let r=t.target.closest("[data-symbol-insert]");if(r){t.preventDefault();let s=r.getAttribute("data-symbol-insert");this.insertSymbol(s||"")}},handleKeydown(t){let e=document.activeElement,a=e&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable);if((t.ctrlKey||t.metaKey)&&t.altKey&&(t.key==="e"||t.key==="E")){t.preventDefault();let n=a&&e&&e.value||"";this.openEditor(n);return}t.key==="Escape"&&this.editorOpen&&(t.preventDefault(),this.closeEditor())},copyLatex(t,e,a){if(!t)return;let n=r=>{if(a)a.hidden=!1,a.textContent=r,clearTimeout(this.messageTimeout),this.messageTimeout=window.setTimeout(()=>{a.hidden=!0,a.textContent=""},2e3);else if(e){let s=e.querySelector(".math-expression__message");s&&(s.hidden=!1,s.textContent=r,clearTimeout(this.messageTimeout),this.messageTimeout=window.setTimeout(()=>{s.hidden=!0,s.textContent=""},2e3))}},i=()=>{let r=document.createElement("textarea");r.value=t,r.setAttribute("aria-hidden","true"),r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();try{document.execCommand("copy"),n("Copied equation")}catch(s){n("Unable to copy")}document.body.removeChild(r)};navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(t).then(()=>n("Copied equation")).catch(()=>i()):i()},setupEditor(){if(this.editor)return;let t=document.createElement("div");t.id="math-tooling-panel",t.hidden=!0;let e=document.createElement("div");e.className="math-tooling",e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-labelledby","math-tooling-title");let a=document.createElement("h2");a.id="math-tooling-title",a.className="math-tooling__title",a.textContent="Equation editor";let n=document.createElement("p");n.className="math-tooling__description",n.innerHTML="Craft LaTeX expressions with live preview, quick statistical symbols, and chemistry support.";let i=document.createElement("textarea");i.className="math-tooling__input",i.setAttribute("data-math-editor-input","true"),i.setAttribute("spellcheck","false"),i.rows=10;let r=document.createElement("div");r.className="math-tooling__actions";let s=document.createElement("div");s.className="math-tooling__preview",s.setAttribute("data-math-editor-preview","true"),s.setAttribute("aria-live","polite");let o=document.createElement("span");o.className="math-tooling__status",o.hidden=!0;let l=document.createElement("div");l.className="math-tooling__library";let c=document.createElement("h3");c.className="math-tooling__library-title",c.textContent="Quick insert";let h=document.createElement("div");h.className="math-tooling__symbols",[{label:"Mean \u03BC",value:"\\mu"},{label:"Variance \u03C3\xB2",value:"\\sigma^2"},{label:"Std. dev \u03C3",value:"\\sigma"},{label:"Probability",value:"\\mathbb{P}(A)"},{label:"Expectation",value:"\\mathbb{E}[X]"},{label:"Covariance",value:"\\mathrm{Cov}(X, Y)"},{label:"Vector",value:"\\mathbf{x}"},{label:"Norm",value:"\\lVert x \\rVert_2"},{label:"Inner product",value:"\\langle x, y \\rangle"},{label:"Derivative",value:"\\frac{\\mathrm{d}}{\\mathrm{d}t}"},{label:"Integral",value:"\\int_0^1 f(x) \\, \\mathrm{d}x"},{label:"Bayes",value:"\\mathbb{P}(A \\mid B)"},{label:"Chemical H\u2082O",value:"\\ce{H2O}"},{label:"Chemical CO\u2082",value:"\\ce{CO2}"}].forEach(g=>{let p=document.createElement("button");p.type="button",p.className="math-tooling__symbol",p.setAttribute("data-symbol-insert",g.value),p.textContent=g.label,h.appendChild(p)});let u=document.createElement("button");u.type="button",u.className="math-tooling__close",u.setAttribute("data-math-editor-close","true");let f=document.createElement("span");f.setAttribute("aria-hidden","true"),f.textContent="\u2715";let b=document.createElement("span");b.className="visually-hidden",b.textContent="Close equation editor",u.appendChild(f),u.appendChild(b);let m=document.createElement("button");m.type="button",m.className="math-tooling__copy",m.setAttribute("data-math-editor-copy","true"),m.textContent="Copy LaTeX",r.appendChild(m),r.appendChild(u),r.appendChild(o),l.appendChild(c),l.appendChild(h),e.appendChild(a),e.appendChild(n),e.appendChild(i),e.appendChild(s),e.appendChild(r),e.appendChild(l),t.appendChild(e),document.body.appendChild(t),i.addEventListener("input",()=>this.updateEditorPreview()),this.editor={overlay:t,dialog:e,textarea:i,preview:s,status:o}},openEditor(t){if(!this.editor)return;let e=(t||"").trim();this.editor.overlay.hidden=!1,document.body.classList.add("math-tooling-open"),this.editor.textarea.value=e,this.editor.textarea.focus(),this.editor.textarea.setSelectionRange(e.length,e.length),this.editorOpen=!0,this.updateEditorPreview()},closeEditor(){this.editor&&(this.editor.overlay.hidden=!0,document.body.classList.remove("math-tooling-open"),this.editorOpen=!1)},updateEditorPreview(){if(!this.editor||!this.MathJax)return;let t=this.editor.textarea.value.trim();if(!t){this.editor.preview.replaceChildren();let e=document.createElement("p");e.className="math-tooling__placeholder",e.textContent="Preview will appear here.",this.editor.preview.appendChild(e);return}this.renderLatex(this.editor.preview,t,{display:!0,enhance:!1})},insertSymbol(t){if(!this.editor||!this.editor.textarea)return;let e=this.editor.textarea,a=e.selectionStart||0,n=e.selectionEnd||0,i=e.value,r=`${i.slice(0,a)}${t}${i.slice(n)}`;e.value=r;let s=a+t.length;e.focus(),e.setSelectionRange(s,s),this.updateEditorPreview()},updateEquationReferences(){if(!this.equationMap||this.equationMap.size===0)return;document.querySelectorAll("[data-equation-ref]").forEach(a=>{let n=a.getAttribute("data-equation-ref");if(!n)return;let i=this.lookupEquation(n.replace(/^#/,""));if(!i)return;a.setAttribute("href",`#${i.anchor}`);let r=a.textContent.trim();(!r||r===n||r===i.anchor||r===`(${n})`)&&(a.textContent=i.number||i.anchor),a.classList.add("math-reference"),a.setAttribute("aria-label",`Jump to equation ${i.number||i.anchor}`)}),document.querySelectorAll('a[href^="#eq:"]').forEach(a=>{let n=a.getAttribute("href");if(!n)return;let i=n.replace(/^#/,""),r=this.lookupEquation(i);if(!r)return;a.setAttribute("href",`#${r.anchor}`);let s=a.textContent.trim();(!s||s===n||s===i)&&(a.textContent=r.number||r.anchor),a.dataset.equationRef=r.anchor,a.classList.add("math-reference")})},lookupEquation(t){if(!t)return null;if(this.equationMap.has(t))return this.equationMap.get(t);let e=t.startsWith("eq:")?t:`eq:${t}`;return this.equationMap.get(e)||null},renderLatex(t,e,a={}){if(!t)return Promise.resolve();let n=a.display!==!1;if(!this.MathJax)return t.textContent=e,this.pendingTypeset||(this.pendingTypeset=[]),this.pendingTypeset.push({target:t,latex:e,options:a}),Promise.resolve();let i=n?`\\[${e}\\]`:`\\(${e}\\)`;return t.innerHTML=i,this.MathJax.typesetPromise([t]).catch(r=>{})},cleanLatex(t){return(t||"").replace(/%\s*alt:.*$/gm,"").replace(/\\label\{[^}]*\}/g,"").replace(/\\tag\*?\{[^}]*\}/g,"").trim()},resolveAltText(t,e){let a=t||null,n=this.findDatasetAlt(a);if(n)return n;let i=this.extractAltComment(e);if(i)return i;let s=(a&&a.getAttribute?a.getAttribute("data-math-source"):null)||e;return this.generateAltFromLatex(s)},findDatasetAlt(t){let e=t;for(;e;){if(e.dataset&&e.dataset.mathAlt){let a=e.dataset.mathAlt.trim();if(a)return a}e=e.parentElement}return""},extractAltComment(t){if(!t)return"";let e=String(t).split(/\r?\n/);for(let a=0;a<e.length;a+=1){let n=e[a];if(!n)continue;let i=n.match(/%\s*alt:\s*(.+)$/i);if(i)return i[1].trim()}return""},generateAltFromLatex(t){if(!t)return"";let e=String(t).replace(/%.*$/gm,"");return e=e.replace(/\\frac\s*\{([^{}]+)\}\s*\{([^{}]+)\}/g,(a,n,i)=>{let r=this.sanitizeSegment(n),s=this.sanitizeSegment(i);return`${r} over ${s}`.trim()}),e=e.replace(/\\int(?:_\{([^}]*)\}|_([^\s^{}]+))?(?:\^\{([^}]*)\}|\^([^\s_{}]+))?/g,(a,n,i,r,s)=>{let o=this.sanitizeSegment(n||i),l=this.sanitizeSegment(r||s),c="integral";return o&&(c+=` from ${o}`),l&&(c+=` to ${l}`),c}),e=e.replace(/\\sum(?:_\{([^}]*)\}|_([^\s^{}]+))?(?:\^\{([^}]*)\}|\^([^\s_{}]+))?/g,(a,n,i,r,s)=>{let o=this.sanitizeSegment(n||i),l=this.sanitizeSegment(r||s),c="summation";return o&&(c+=` from ${o}`),l&&(c+=` to ${l}`),c}),e=e.replace(/\\sqrt\s*\{([^{}]+)\}/g,(a,n)=>`square root of ${this.sanitizeSegment(n)}`),e=e.replace(/\\mathrm\s*\{([^{}]+)\}/g,(a,n)=>this.sanitizeSegment(n)),e=e.replace(/\\operatorname\*?\s*\{([^{}]+)\}/g,(a,n)=>this.sanitizeSegment(n)),e=e.replace(/\\[a-zA-Z]+/g," "),e=e.replace(/[{}]/g," "),e=e.replace(/\s+/g," ").trim(),e||"Mathematical expression"},sanitizeSegment(t){return t?String(t).replace(/\\[a-zA-Z]+/g," ").replace(/[{}]/g," ").replace(/\s+/g," ").trim():""},syncAltAttributes(t,e,a){a&&(t&&t.setAttribute&&(t.setAttribute("aria-label",a),t.dataset&&(t.dataset.mathAlt=a)),e&&e.setAttribute&&(e.setAttribute("aria-label",a),e.dataset&&(e.dataset.mathAlt=a)))}};typeof globalThis!="undefined"&&(globalThis.__DATALOG_MATH_INTERNALS__=d),typeof document!="undefined"&&(document.addEventListener("datalog:math-ready",()=>d.exposeAllReferenceLinks(document)),d.exposeAllReferenceLinks(document)),window.DatalogMath={init(t){d.init(t)},onPageReady(){d.initialized&&d.onPageReady()},renderLatex(t,e,a){return d.renderLatex(t,e,a)}}})();
|
|
1
|
+
(function(){let d={init(e){this.MathJax=e,this.displayCounter=0,this.anchorCounter=0,this.equationMap=new Map,this.editor=null,this.editorOpen=!1,this.messageTimeout=null,this.initialized=!0,this.pendingTypeset=[],this.setupEditor(),e.startup.promise.then(()=>{if(this.decorateExisting(e.startup.document.math),this.updateEquationReferences(),this.pendingTypeset.length>0){let t=[...this.pendingTypeset];this.pendingTypeset=[],t.forEach(a=>{this.renderLatex(a.target,a.latex,a.options||{})})}}).catch(t=>{}),document.addEventListener("click",t=>this.handleClick(t)),document.addEventListener("keydown",t=>this.handleKeydown(t))},onPageReady(){this.updateEquationReferences()},decorateExisting(e){let t=e?Array.from(e):[];t.length!==0&&(this.displayCounter=0,this.anchorCounter=0,this.equationMap.clear(),t.forEach(a=>{try{this.decorateMathItem(a)}catch(i){}}))},decorateMathItem(e){if(!e||!e.typesetRoot)return;let t=e.typesetRoot,a=e.math||"",i=t.closest("[data-math-alt]")||t,n=this.resolveAltText(i,a);t.dataset.mathLatex=a,t.querySelector("a[href]")||(t.setAttribute("tabindex","0"),t.setAttribute("role","math"),this.syncAltAttributes(i,t,n)),e.display?this.decorateDisplay(t,a):this.decorateInline(t,a),this.exposeReferenceLinks(t)},exposeAllReferenceLinks(e){(e&&typeof e.querySelectorAll=="function"?e:document).querySelectorAll("mjx-container").forEach(a=>this.exposeReferenceLinks(a))},exposeReferenceLinks(e){if(!e||typeof e.querySelectorAll!="function")return;let t=Array.from(e.querySelectorAll("mjx-assistive-mml [href]")),a=e;e.querySelectorAll('[aria-hidden="true"] a[href]').forEach(i=>{i.setAttribute("tabindex","-1");let n=i.getAttribute("href")||"";if(!n.startsWith("#")||i.dataset.mathReferenceExposed==="true")return;i.dataset.mathReferenceExposed="true";let r=t.find(l=>l.getAttribute("href")===n),s=(r&&r.textContent||i.textContent||"").replace(/\s+/g," ").trim(),o=document.createElement("a");o.className="math-reference-link",o.href=n,o.textContent=s?`Equation ${s}`:"Equation",a.insertAdjacentElement("afterend",o),a=o})},decorateInline(e,t){e&&(e.classList.contains("math-expression__inline")||e.classList.add("math-expression__inline"),e.dataset.mathLatexClean=this.cleanLatex(t))},decorateDisplay(e,t){if(!e)return;let i=e.parentElement&&e.parentElement.classList.contains("math-expression")?e.parentElement:null;i||(i=document.createElement("figure"),i.className="math-expression math-expression--display",e.parentNode.insertBefore(i,e),i.appendChild(e)),i.removeAttribute("role"),i.removeAttribute("aria-label"),i.removeAttribute("tabindex");let n=this.extractEquationInfo(t);this.anchorCounter+=1;let r=`eq:auto-${this.anchorCounter}`,s=this.mathJaxNumbersEquations(),o=s?this.mathJaxNumber(e):this.ownNumber(n),l=this.buildAnchorId(n.label,r);if(i.dataset.mathLatex=t,i.dataset.mathLatexClean=this.cleanLatex(t),e.dataset.mathAlt&&!i.dataset.mathAlt&&(i.dataset.mathAlt=e.dataset.mathAlt),o?i.dataset.equationNumber=o:i.removeAttribute("data-equation-number"),i.dataset.equationLabel=n.label||"",l){i.id=l;let c=o||n.label||l;if((o||n.label)&&(this.setEquationReference(l,c),n.label&&n.label!==l&&this.setEquationReference(n.label,c,l),n.label&&n.label.startsWith("eq:"))){let h=n.label.replace(/^eq:/,"");this.setEquationReference(h,c,l)}}s||this.attachNumberBadge(i,o),this.attachToolbar(i)},mathJaxNumbersEquations(){let e=this.MathJax&&this.MathJax.config?this.MathJax.config.tex:null,t=e?e.tags:null;return!!t&&t!=="none"},mathJaxNumber(e){let t=e.querySelector("mjx-assistive-mml mlabeledtr > mtd:first-child");return t?(t.textContent||"").replace(/\s+/g," ").trim():""},ownNumber(e){let t=e.tag||"";return e.skipNumber||(this.displayCounter+=1,t||(t=String(this.displayCounter))),t?`(${t})`:""},extractEquationInfo(e){let t=(e||"").trim(),a=t.match(/\\tag\*?\{([^}]*)\}/),i=t.match(/\\label\{([^}]*)\}/),n=/\\notag|\\nonumber/.test(t);return{tag:a?a[1].trim():"",label:i?i[1].trim():"",skipNumber:n}},buildAnchorId(e,t){return e?e.startsWith("eq:")?e:`eq:${e}`:t||""},setEquationReference(e,t,a){if(!e)return;let i=a||e,n=t||e;this.equationMap.set(e,{anchor:i,label:e,number:n}),e.startsWith("eq:")||this.equationMap.set(`eq:${e}`,{anchor:i,label:e,number:n})},attachNumberBadge(e,t){let a=e.querySelector(".math-expression__number"),i=e.querySelector(".math-expression__sr");if(!t){a&&a.remove(),i&&i.remove();return}a||(a=document.createElement("span"),a.className="math-expression__number",a.setAttribute("aria-hidden","true"),e.appendChild(a)),a.textContent=t,i||(i=document.createElement("span"),i.className="visually-hidden math-expression__sr",e.appendChild(i)),i.textContent=`Equation ${t.replace(/[()]/g,"")}`},attachToolbar(e){let t=e.querySelector(".math-expression__toolbar");if(!t){t=document.createElement("div"),t.className="math-expression__toolbar";let a=document.createElement("button");a.type="button",a.className="math-expression__button",a.setAttribute("data-math-copy","true"),a.setAttribute("aria-label","Copy LaTeX code");let i=document.createElement("span");i.setAttribute("aria-hidden","true"),i.textContent="\u29C9";let n=document.createElement("span");n.className="visually-hidden",n.textContent="Copy equation",a.appendChild(i),a.appendChild(n);let r=document.createElement("button");r.type="button",r.className="math-expression__button",r.setAttribute("data-math-edit","true"),r.setAttribute("aria-label","Open equation editor");let s=document.createElement("span");s.setAttribute("aria-hidden","true"),s.textContent="\u270E";let o=document.createElement("span");o.className="visually-hidden",o.textContent="Edit equation",r.appendChild(s),r.appendChild(o);let l=document.createElement("span");l.className="math-expression__message",l.setAttribute("aria-live","polite"),l.hidden=!0,t.appendChild(a),t.appendChild(r),t.appendChild(l),e.appendChild(t)}},handleClick(e){let t=e.target.closest("[data-math-copy]");if(t){e.preventDefault();let s=t.closest(".math-expression"),o=s?s.dataset.mathLatexClean||s.dataset.mathLatex:null;this.copyLatex(o,s);return}let a=e.target.closest("[data-math-edit]");if(a){e.preventDefault();let s=a.closest(".math-expression"),o=s&&s.dataset.mathLatex||"";this.openEditor(o);return}if(e.target.closest("[data-math-editor-close]")){e.preventDefault(),this.closeEditor();return}if(e.target.closest("[data-math-editor-copy]")){e.preventDefault(),this.editor&&this.editor.textarea&&this.copyLatex(this.editor.textarea.value,null,this.editor.status);return}let r=e.target.closest("[data-symbol-insert]");if(r){e.preventDefault();let s=r.getAttribute("data-symbol-insert");this.insertSymbol(s||"")}},handleKeydown(e){let t=document.activeElement,a=t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable);if((e.ctrlKey||e.metaKey)&&e.altKey&&(e.key==="e"||e.key==="E")){e.preventDefault();let i=a&&t&&t.value||"";this.openEditor(i);return}e.key==="Escape"&&this.editorOpen&&(e.preventDefault(),this.closeEditor())},copyLatex(e,t,a){if(!e)return;let i=r=>{if(a)a.hidden=!1,a.textContent=r,clearTimeout(this.messageTimeout),this.messageTimeout=window.setTimeout(()=>{a.hidden=!0,a.textContent=""},2e3);else if(t){let s=t.querySelector(".math-expression__message");s&&(s.hidden=!1,s.textContent=r,clearTimeout(this.messageTimeout),this.messageTimeout=window.setTimeout(()=>{s.hidden=!0,s.textContent=""},2e3))}},n=()=>{let r=document.createElement("textarea");r.value=e,r.setAttribute("aria-hidden","true"),r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();try{document.execCommand("copy"),i("Copied equation")}catch(s){i("Unable to copy")}document.body.removeChild(r)};navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e).then(()=>i("Copied equation")).catch(()=>n()):n()},setupEditor(){if(this.editor)return;let e=document.createElement("div");e.id="math-tooling-panel",e.hidden=!0;let t=document.createElement("div");t.className="math-tooling",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-labelledby","math-tooling-title");let a=document.createElement("h2");a.id="math-tooling-title",a.className="math-tooling__title",a.textContent="Equation editor";let i=document.createElement("p");i.id="math-tooling-description",i.className="math-tooling__description",i.textContent="Craft LaTeX expressions with live preview, quick statistical symbols, and chemistry support.";let n=document.createElement("textarea");n.className="math-tooling__input",n.setAttribute("data-math-editor-input","true"),n.setAttribute("spellcheck","false"),n.setAttribute("aria-label","LaTeX source"),n.setAttribute("aria-describedby",i.id),n.rows=10;let r=document.createElement("div");r.className="math-tooling__actions";let s=document.createElement("div");s.className="math-tooling__preview",s.setAttribute("data-math-editor-preview","true"),s.setAttribute("aria-live","polite");let o=document.createElement("span");o.className="math-tooling__status",o.hidden=!0;let l=document.createElement("div");l.className="math-tooling__library";let c=document.createElement("h3");c.className="math-tooling__library-title",c.textContent="Quick insert";let h=document.createElement("div");h.className="math-tooling__symbols",[{label:"Mean \u03BC",value:"\\mu"},{label:"Variance \u03C3\xB2",value:"\\sigma^2"},{label:"Std. dev \u03C3",value:"\\sigma"},{label:"Probability",value:"\\mathbb{P}(A)"},{label:"Expectation",value:"\\mathbb{E}[X]"},{label:"Covariance",value:"\\mathrm{Cov}(X, Y)"},{label:"Vector",value:"\\mathbf{x}"},{label:"Norm",value:"\\lVert x \\rVert_2"},{label:"Inner product",value:"\\langle x, y \\rangle"},{label:"Derivative",value:"\\frac{\\mathrm{d}}{\\mathrm{d}t}"},{label:"Integral",value:"\\int_0^1 f(x) \\, \\mathrm{d}x"},{label:"Bayes",value:"\\mathbb{P}(A \\mid B)"},{label:"Chemical H\u2082O",value:"\\ce{H2O}"},{label:"Chemical CO\u2082",value:"\\ce{CO2}"}].forEach(g=>{let p=document.createElement("button");p.type="button",p.className="math-tooling__symbol",p.setAttribute("data-symbol-insert",g.value),p.textContent=g.label,h.appendChild(p)});let u=document.createElement("button");u.type="button",u.className="math-tooling__close",u.setAttribute("data-math-editor-close","true");let b=document.createElement("span");b.setAttribute("aria-hidden","true"),b.textContent="\u2715";let f=document.createElement("span");f.className="visually-hidden",f.textContent="Close equation editor",u.appendChild(b),u.appendChild(f);let m=document.createElement("button");m.type="button",m.className="math-tooling__copy",m.setAttribute("data-math-editor-copy","true"),m.textContent="Copy LaTeX",r.appendChild(m),r.appendChild(u),r.appendChild(o),l.appendChild(c),l.appendChild(h),t.appendChild(a),t.appendChild(i),t.appendChild(n),t.appendChild(s),t.appendChild(r),t.appendChild(l),e.appendChild(t),document.body.appendChild(e),n.addEventListener("input",()=>this.updateEditorPreview()),this.editor={overlay:e,dialog:t,textarea:n,preview:s,status:o}},openEditor(e){if(!this.editor)return;let t=(e||"").trim();this.editor.overlay.hidden=!1,document.body.classList.add("math-tooling-open"),this.editor.textarea.value=t,this.editor.textarea.focus(),this.editor.textarea.setSelectionRange(t.length,t.length),this.editorOpen=!0,this.updateEditorPreview()},closeEditor(){this.editor&&(this.editor.overlay.hidden=!0,document.body.classList.remove("math-tooling-open"),this.editorOpen=!1)},updateEditorPreview(){if(!this.editor||!this.MathJax)return;let e=this.editor.textarea.value.trim();if(!e){this.editor.preview.replaceChildren();let t=document.createElement("p");t.className="math-tooling__placeholder",t.textContent="Preview will appear here.",this.editor.preview.appendChild(t);return}this.renderLatex(this.editor.preview,e,{display:!0,enhance:!1})},insertSymbol(e){if(!this.editor||!this.editor.textarea)return;let t=this.editor.textarea,a=t.selectionStart||0,i=t.selectionEnd||0,n=t.value,r=`${n.slice(0,a)}${e}${n.slice(i)}`;t.value=r;let s=a+e.length;t.focus(),t.setSelectionRange(s,s),this.updateEditorPreview()},updateEquationReferences(){if(!this.equationMap||this.equationMap.size===0)return;document.querySelectorAll("[data-equation-ref]").forEach(a=>{let i=a.getAttribute("data-equation-ref");if(!i)return;let n=this.lookupEquation(i.replace(/^#/,""));if(!n)return;a.setAttribute("href",`#${n.anchor}`);let r=a.textContent.trim();(!r||r===i||r===n.anchor||r===`(${i})`)&&(a.textContent=n.number||n.anchor),a.classList.add("math-reference"),a.setAttribute("aria-label",`Jump to equation ${n.number||n.anchor}`)}),document.querySelectorAll('a[href^="#eq:"]').forEach(a=>{let i=a.getAttribute("href");if(!i)return;let n=i.replace(/^#/,""),r=this.lookupEquation(n);if(!r)return;a.setAttribute("href",`#${r.anchor}`);let s=a.textContent.trim();(!s||s===i||s===n)&&(a.textContent=r.number||r.anchor),a.dataset.equationRef=r.anchor,a.classList.add("math-reference")})},lookupEquation(e){if(!e)return null;if(this.equationMap.has(e))return this.equationMap.get(e);let t=e.startsWith("eq:")?e:`eq:${e}`;return this.equationMap.get(t)||null},renderLatex(e,t,a={}){if(!e)return Promise.resolve();let i=a.display!==!1;if(!this.MathJax)return e.textContent=t,this.pendingTypeset||(this.pendingTypeset=[]),this.pendingTypeset.push({target:e,latex:t,options:a}),Promise.resolve();let n=i?`\\[${t}\\]`:`\\(${t}\\)`;return e.innerHTML=n,this.MathJax.typesetPromise([e]).catch(r=>{})},cleanLatex(e){return(e||"").replace(/%\s*alt:.*$/gm,"").replace(/\\label\{[^}]*\}/g,"").replace(/\\tag\*?\{[^}]*\}/g,"").trim()},resolveAltText(e,t){let a=e||null,i=this.findDatasetAlt(a);if(i)return i;let n=this.extractAltComment(t);if(n)return n;let s=(a&&a.getAttribute?a.getAttribute("data-math-source"):null)||t;return this.generateAltFromLatex(s)},findDatasetAlt(e){let t=e;for(;t;){if(t.dataset&&t.dataset.mathAlt){let a=t.dataset.mathAlt.trim();if(a)return a}t=t.parentElement}return""},extractAltComment(e){if(!e)return"";let t=String(e).split(/\r?\n/);for(let a=0;a<t.length;a+=1){let i=t[a];if(!i)continue;let n=i.match(/%\s*alt:\s*(.+)$/i);if(n)return n[1].trim()}return""},generateAltFromLatex(e){if(!e)return"";let t=String(e).replace(/%.*$/gm,"");return t=t.replace(/\\frac\s*\{([^{}]+)\}\s*\{([^{}]+)\}/g,(a,i,n)=>{let r=this.sanitizeSegment(i),s=this.sanitizeSegment(n);return`${r} over ${s}`.trim()}),t=t.replace(/\\int(?:_\{([^}]*)\}|_([^\s^{}]+))?(?:\^\{([^}]*)\}|\^([^\s_{}]+))?/g,(a,i,n,r,s)=>{let o=this.sanitizeSegment(i||n),l=this.sanitizeSegment(r||s),c="integral";return o&&(c+=` from ${o}`),l&&(c+=` to ${l}`),c}),t=t.replace(/\\sum(?:_\{([^}]*)\}|_([^\s^{}]+))?(?:\^\{([^}]*)\}|\^([^\s_{}]+))?/g,(a,i,n,r,s)=>{let o=this.sanitizeSegment(i||n),l=this.sanitizeSegment(r||s),c="summation";return o&&(c+=` from ${o}`),l&&(c+=` to ${l}`),c}),t=t.replace(/\\sqrt\s*\{([^{}]+)\}/g,(a,i)=>`square root of ${this.sanitizeSegment(i)}`),t=t.replace(/\\mathrm\s*\{([^{}]+)\}/g,(a,i)=>this.sanitizeSegment(i)),t=t.replace(/\\operatorname\*?\s*\{([^{}]+)\}/g,(a,i)=>this.sanitizeSegment(i)),t=t.replace(/\\[a-zA-Z]+/g," "),t=t.replace(/[{}]/g," "),t=t.replace(/\s+/g," ").trim(),t||"Mathematical expression"},sanitizeSegment(e){return e?String(e).replace(/\\[a-zA-Z]+/g," ").replace(/[{}]/g," ").replace(/\s+/g," ").trim():""},syncAltAttributes(e,t,a){a&&(e&&e.setAttribute&&(e.setAttribute("aria-label",a),e.dataset&&(e.dataset.mathAlt=a)),t&&t.setAttribute&&(t.setAttribute("aria-label",a),t.dataset&&(t.dataset.mathAlt=a)))}};typeof globalThis!="undefined"&&(globalThis.__DATALOG_MATH_INTERNALS__=d),typeof document!="undefined"&&(document.addEventListener("datalog:math-ready",()=>d.exposeAllReferenceLinks(document)),d.exposeAllReferenceLinks(document)),window.DatalogMath={init(e){d.init(e)},onPageReady(){d.initialized&&d.onPageReady()},renderLatex(e,t,a){return d.renderLatex(e,t,a)}}})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as H}from"./chunks/chunk-WIRUK3OZ.js";import{a as T,b as W}from"./chunks/chunk-VZ5WKQVA.js";import{a as O,b as B}from"./chunks/chunk-PATLC23F.js";var P="moderation",et=["comment","correction","abuse"],nt={approve:"approved",spam:"spam",hide:"hidden",delete:"deleted",reviewed:"reviewed",accept:"accepted",reject:"rejected",resolve:"resolved",dismiss:"dismissed"},ot={comment:{pending:["approve","spam","delete"],approved:["hide","spam","delete"],spam:["approve","delete"],hidden:["approve","delete"]},correction:{new:["reviewed","accept","reject"],reviewed:["accept","reject"],accepted:["resolve","reject"]},abuse:{open:["dismiss","hide","delete"]}},at={comment:["pending"],correction:["new","reviewed","accepted"],abuse:["open"]},Y=/^https?:\/\//i,rt=new Set(["unauthorized","forbidden"]),it=new Set(["disabled","unsupported","version"]);function st(t,e){let i=t.querySelector(e);if(!i)return{};try{return JSON.parse(i.textContent)||{}}catch(s){return{}}}function r(t){return typeof t=="string"?t:""}function G(t){return(ot[t.type]||{})[t.status]||[]}function J(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=r(t.type).toLowerCase();if(t.id===null||t.id===void 0||!et.includes(e))return null;let i=t.author&&typeof t.author=="object"?t.author:{},s=t.context&&typeof t.context=="object"?t.context:{},c=s.parent&&typeof s.parent=="object"?s.parent:null,u=t.resolution&&typeof t.resolution=="object"?t.resolution:{},_=Array.isArray(t.history)?t.history:[];return{id:String(t.id),type:e,status:r(t.status).toLowerCase(),created_at:r(t.created_at),path:r(t.path),title:r(t.title),author:{name:r(i.name),email:r(i.email)},body:r(t.body)||r(t.message),category:r(t.category),section:r(t.section),quote:r(t.quote),reason:r(t.reason),parent:c?{author:r(c.author&&c.author.name),body:r(c.body)}:null,link:Y.test(r(u.url))?u.url:"",history:_.filter(g=>g&&typeof g=="object").map(g=>({action:r(g.action),at:r(g.at),moderator:r(g.moderator),note:r(g.note)}))}}function lt(t={},e=""){let i=new URLSearchParams;["type","status","path","category","since","q"].forEach(c=>{let u=r(t[c]).trim();u&&u!=="all"&&i.set(c,u)}),e&&i.set("cursor",e);let s=i.toString();return s?`?${s}`:""}function K(t,e){let i=new Date(t);if(Number.isNaN(i.getTime()))return t;try{return i.toLocaleString(e||void 0,{dateStyle:"medium",timeStyle:"short"})}catch(s){return i.toISOString()}}function o(t,e,i,s,c){let u=t.createElement(i);return s&&(u.className=s),c!==void 0&&(u.textContent=c),e.appendChild(u),u}function V(t,e,i={}){let{labels:s={},lang:c,siteUrl:u="",onAction:_}=i,g=s.types||{},h=s.statuses||{},j=s.actions||{},C=t.createElement("li");C.className=`moderation-item moderation-item--${e.type}`,C.dataset.itemId=e.id,C.dataset.itemStatus=e.status;let b=o(t,C,"article","moderation-item__card"),x=o(t,b,"header","moderation-item__meta");if(o(t,x,"span","moderation-item__type",g[e.type]||e.type),o(t,x,"span","moderation-item__status",h[e.status]||e.status),e.category&&o(t,x,"span","moderation-item__category",(s.categories||{})[e.category]||e.category),e.created_at){let l=o(t,x,"time","moderation-item__time",K(e.created_at,c));l.dateTime=e.created_at}if(e.path){let l=o(t,b,"p","moderation-item__where"),d=o(t,l,"a","",e.title||e.path);e.path.startsWith("/")&&!e.path.startsWith("//")&&(d.href=`${u.replace(/\/+$/,"")}${e.path}${e.section?`#${encodeURIComponent(e.section)}`:""}`)}if((e.author.name||e.author.email)&&o(t,b,"p","moderation-item__author",[e.author.name,e.author.email].filter(Boolean).join(" \xB7 ")),e.parent){let l=o(t,b,"blockquote","moderation-item__context");o(t,l,"p","",`${s.in_reply_to||"In reply to"} ${e.parent.author||""}`.trim()),o(t,l,"p","",e.parent.body)}e.quote&&o(t,b,"blockquote","moderation-item__quote",e.quote),e.reason&&o(t,b,"p","moderation-item__reason",e.reason);let v=o(t,b,"div","moderation-item__body");if(e.body.split(/\n{2,}/).forEach(l=>o(t,v,"p","",l)),e.link){let l=o(t,b,"p","moderation-item__link"),d=o(t,l,"a","",e.link);d.href=e.link,d.rel="noopener"}if(e.history.length>0){let l=o(t,b,"ol","moderation-item__history");e.history.forEach(d=>{let E=[j[d.action]||d.action,d.moderator,d.at?K(d.at,c):"",d.note].filter(Boolean).join(" \xB7 ");o(t,l,"li","",E)})}let A=G(e);if(A.length>0&&_){let l=o(t,b,"div","moderation-item__actions"),d=`moderation-note-${e.id}`,E=o(t,l,"label","moderation-item__note-label",s.note||"Note");E.htmlFor=d;let q=o(t,l,"input","moderation-item__note");q.type="text",q.id=d,q.name="note";let k=null;if(A.includes("resolve")){let m=`moderation-link-${e.id}`,L=o(t,l,"label","moderation-item__note-label",s.link||"Issue, pull request or revision");L.htmlFor=m,k=o(t,l,"input","moderation-item__note"),k.type="url",k.id=m,k.name="link"}let U=o(t,l,"div","moderation-item__buttons");A.forEach(m=>{let L=o(t,U,"button","post-tool",j[m]||m);L.type="button",L.dataset.moderationAction=m,L.addEventListener("click",()=>_(e,m,{note:q.value.trim(),link:k?k.value.trim():""}))})}let S=o(t,b,"p","moderation-item__message");return S.setAttribute("data-item-message",""),S.setAttribute("role","status"),S.hidden=!0,C}function dt(t,e={}){let i=t.ownerDocument,s=i.defaultView,c=s&&s.DatalogDynamicServices||{},u=t.dataset.moderationEndpoint||"",_=e.client||W(B(O({},c),{features:u?{}:c.features,base_url:u||c.base_url||"",credentials:t.dataset.moderationCredentials||"include"})),g=H(),h=st(t,"[data-moderation-labels]"),j=h.errors||{},C=i.documentElement.lang||void 0,b=t.dataset.moderationSite||"",x=t.querySelector("[data-moderation-status]"),v=t.querySelector("[data-moderation-list]"),A=t.querySelector("[data-moderation-filters]"),S=t.querySelector("[data-moderation-more]"),l=t.querySelector("[data-moderation-sign-in]"),d="",E=!1,q=0,k={},U=0,m=(n,a="",y=!1)=>{t.dataset.state=n,t.setAttribute("aria-busy",n==="loading"?"true":"false"),x&&(x.textContent=a,x.hidden=a==="",x.setAttribute("role",y?"alert":"status")),l&&(l.hidden=n!=="unauthorized")},L=()=>{let n={};return A&&new FormData(A).forEach((a,y)=>{n[y]=String(a)}),n},Q=n=>{v.textContent="",S&&(S.hidden=!0),n&&n.kind==="unauthorized"?m("unauthorized",h.unauthorized||"",!0):n&&n.kind==="forbidden"?m("forbidden",h.forbidden||"",!0):n&&it.has(n.kind)?m("disabled",T(n,j)):m("error",T(n,j),!0)},N=(n,a,y=!1)=>{let f=n.querySelector("[data-item-message]");f&&(f.textContent=a,f.hidden=a==="",f.setAttribute("role",y?"alert":"status"))},tt=n=>{let a=r(k.status).trim();return a?a===n.status:(at[n.type]||[]).includes(n.status)},w={root:t,client:_,async load(n=!1,a=n?k:L()){if(E&&n)return null;let y=++q,f=U;E=!0,n||(d=""),m("loading",h.loading||"");try{await _.feature(P);let I=await _.get(`${_.pathFor(P)}/items${lt(a,n?d:"")}`);if(y!==q)return null;if(f!==U)return E=!1,w.load(n,a);k=a;let $=I&&I.data&&typeof I.data=="object"?I.data:{},p=(Array.isArray($.items)?$.items:[]).map(J).filter(Boolean);n||(v.textContent=""),p.forEach(F=>v.appendChild(V(i,F,{labels:h,lang:C,siteUrl:b,onAction:w.act}))),d=r($.next_cursor),S&&(S.hidden=d==="");let D=v.children.length;return m(D>0?"loaded":"empty",D>0?"":h.empty||""),p}catch(I){return y!==q?null:f!==U?(E=!1,w.load(n,a)):(Q(I),null)}finally{y===q&&(E=!1)}},async act(n,a,y={}){let f=Array.from(v.children).find(p=>p.dataset.itemId===n.id);if(!f||!G(n).includes(a))return null;if(a==="resolve"&&!Y.test(y.link||""))return N(f,h.link_required||"",!0),null;let I=Array.from(f.querySelectorAll("button"));I.forEach(p=>{p.disabled=!0}),f.setAttribute("aria-busy","true"),N(f,h.working||"");let $={action:a};y.note&&($.note=y.note),a==="resolve"&&($.link=y.link);try{let p=await _.post(`${_.pathFor(P)}/items/${encodeURIComponent(n.id)}/actions`,$,{idempotencyKey:g.key($,n.id)});g.clear(n.id),U+=1;let F=J(p&&p.data&&p.data.item)||B(O({},n),{status:nt[a]||n.status}),z=Array.from(v.children).find(R=>R.dataset.itemId===n.id);if(!z)return F;let M=(h.done||"{{action}}").split("{{action}}").join((h.actions||{})[a]||a);if(tt(F)){let R=V(i,F,{labels:h,lang:C,siteUrl:b,onAction:w.act});v.replaceChild(R,z),N(R,M)}else z.remove(),m(v.children.length>0?"loaded":"empty",v.children.length>0?M:`${M} ${h.empty||""}`.trim());return F}catch(p){return p&&rt.has(p.kind)?Q(p):(f.setAttribute("aria-busy","false"),I.forEach(D=>{D.disabled=!1}),N(f,T(p,j),!0)),null}}};return A&&(A.addEventListener("submit",n=>{n.preventDefault(),w.load()}),A.addEventListener("reset",()=>{Promise.resolve().then(()=>w.load())})),S&&S.addEventListener("click",()=>w.load(!0)),_.enabled?(w.load(),w):(m("disabled",j.disabled||""),w)}function X(t=document){return Array.from(t.querySelectorAll("[data-moderation-inbox]")).map(e=>dt(e))}function Z(){X(document)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Z,{once:!0}):Z();
|