create-prisma-php-app 3.0.0-alpha.2 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/settings/html-events.json +118 -0
- package/dist/src/Lib/IncludeTracker.php +57 -20
- package/dist/src/Lib/PHPX/PHPX.php +27 -13
- package/dist/src/Lib/PHPX/TemplateCompiler.php +116 -21
- package/dist/src/Lib/PrismaPHPSettings.php +19 -0
- package/dist/src/app/assets/images/file.svg +1 -0
- package/dist/src/app/assets/images/globe.svg +1 -0
- package/dist/src/app/assets/images/prisma-php-black.svg +6 -0
- package/dist/src/app/assets/images/window.svg +1 -0
- package/dist/src/app/css/index.css +1 -7
- package/dist/src/app/index.php +66 -49
- package/dist/src/app/js/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
[
|
|
2
|
+
"beforexrselect",
|
|
3
|
+
"abort",
|
|
4
|
+
"beforeinput",
|
|
5
|
+
"beforematch",
|
|
6
|
+
"beforetoggle",
|
|
7
|
+
"blur",
|
|
8
|
+
"cancel",
|
|
9
|
+
"canplay",
|
|
10
|
+
"canplaythrough",
|
|
11
|
+
"change",
|
|
12
|
+
"click",
|
|
13
|
+
"close",
|
|
14
|
+
"contentvisibilityautostatechange",
|
|
15
|
+
"contextlost",
|
|
16
|
+
"contextmenu",
|
|
17
|
+
"contextrestored",
|
|
18
|
+
"cuechange",
|
|
19
|
+
"dblclick",
|
|
20
|
+
"drag",
|
|
21
|
+
"dragend",
|
|
22
|
+
"dragenter",
|
|
23
|
+
"dragleave",
|
|
24
|
+
"dragover",
|
|
25
|
+
"dragstart",
|
|
26
|
+
"drop",
|
|
27
|
+
"durationchange",
|
|
28
|
+
"emptied",
|
|
29
|
+
"ended",
|
|
30
|
+
"error",
|
|
31
|
+
"focus",
|
|
32
|
+
"formdata",
|
|
33
|
+
"input",
|
|
34
|
+
"invalid",
|
|
35
|
+
"keydown",
|
|
36
|
+
"keypress",
|
|
37
|
+
"keyup",
|
|
38
|
+
"load",
|
|
39
|
+
"loadeddata",
|
|
40
|
+
"loadedmetadata",
|
|
41
|
+
"loadstart",
|
|
42
|
+
"mousedown",
|
|
43
|
+
"mouseenter",
|
|
44
|
+
"mouseleave",
|
|
45
|
+
"mousemove",
|
|
46
|
+
"mouseout",
|
|
47
|
+
"mouseover",
|
|
48
|
+
"mouseup",
|
|
49
|
+
"mousewheel",
|
|
50
|
+
"pause",
|
|
51
|
+
"play",
|
|
52
|
+
"playing",
|
|
53
|
+
"progress",
|
|
54
|
+
"ratechange",
|
|
55
|
+
"reset",
|
|
56
|
+
"resize",
|
|
57
|
+
"scroll",
|
|
58
|
+
"securitypolicyviolation",
|
|
59
|
+
"seeked",
|
|
60
|
+
"seeking",
|
|
61
|
+
"select",
|
|
62
|
+
"slotchange",
|
|
63
|
+
"stalled",
|
|
64
|
+
"submit",
|
|
65
|
+
"suspend",
|
|
66
|
+
"timeupdate",
|
|
67
|
+
"toggle",
|
|
68
|
+
"volumechange",
|
|
69
|
+
"waiting",
|
|
70
|
+
"webkitanimationend",
|
|
71
|
+
"webkitanimationiteration",
|
|
72
|
+
"webkitanimationstart",
|
|
73
|
+
"webkittransitionend",
|
|
74
|
+
"wheel",
|
|
75
|
+
"auxclick",
|
|
76
|
+
"gotpointercapture",
|
|
77
|
+
"lostpointercapture",
|
|
78
|
+
"pointerdown",
|
|
79
|
+
"pointermove",
|
|
80
|
+
"pointerrawupdate",
|
|
81
|
+
"pointerup",
|
|
82
|
+
"pointercancel",
|
|
83
|
+
"pointerover",
|
|
84
|
+
"pointerout",
|
|
85
|
+
"pointerenter",
|
|
86
|
+
"pointerleave",
|
|
87
|
+
"selectstart",
|
|
88
|
+
"selectionchange",
|
|
89
|
+
"animationend",
|
|
90
|
+
"animationiteration",
|
|
91
|
+
"animationstart",
|
|
92
|
+
"transitionrun",
|
|
93
|
+
"transitionstart",
|
|
94
|
+
"transitionend",
|
|
95
|
+
"transitioncancel",
|
|
96
|
+
"copy",
|
|
97
|
+
"cut",
|
|
98
|
+
"paste",
|
|
99
|
+
"command",
|
|
100
|
+
"scrollend",
|
|
101
|
+
"scrollsnapchange",
|
|
102
|
+
"scrollsnapchanging",
|
|
103
|
+
"readystatechange",
|
|
104
|
+
"pointerlockchange",
|
|
105
|
+
"pointerlockerror",
|
|
106
|
+
"beforecopy",
|
|
107
|
+
"beforecut",
|
|
108
|
+
"beforepaste",
|
|
109
|
+
"freeze",
|
|
110
|
+
"prerenderingchange",
|
|
111
|
+
"resume",
|
|
112
|
+
"search",
|
|
113
|
+
"visibilitychange",
|
|
114
|
+
"fullscreenchange",
|
|
115
|
+
"fullscreenerror",
|
|
116
|
+
"webkitfullscreenchange",
|
|
117
|
+
"webkitfullscreenerror"
|
|
118
|
+
]
|
|
@@ -4,6 +4,11 @@ namespace Lib;
|
|
|
4
4
|
|
|
5
5
|
use RuntimeException;
|
|
6
6
|
use InvalidArgumentException;
|
|
7
|
+
use Lib\PrismaPHPSettings;
|
|
8
|
+
use DOMDocument;
|
|
9
|
+
use DOMElement;
|
|
10
|
+
use DOMXPath;
|
|
11
|
+
use Lib\PHPX\TemplateCompiler;
|
|
7
12
|
|
|
8
13
|
class IncludeTracker
|
|
9
14
|
{
|
|
@@ -26,33 +31,32 @@ class IncludeTracker
|
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
ob_start();
|
|
34
|
+
match ($mode) {
|
|
35
|
+
'include' => include $filePath,
|
|
36
|
+
'include_once' => include_once $filePath,
|
|
37
|
+
'require' => require $filePath,
|
|
38
|
+
'require_once' => require_once $filePath,
|
|
39
|
+
default => throw new InvalidArgumentException("Invalid include mode: $mode")
|
|
40
|
+
};
|
|
41
|
+
$html = ob_get_clean();
|
|
29
42
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
break;
|
|
34
|
-
case 'include_once':
|
|
35
|
-
include_once $filePath;
|
|
36
|
-
break;
|
|
37
|
-
case 'require':
|
|
38
|
-
require $filePath;
|
|
39
|
-
break;
|
|
40
|
-
case 'require_once':
|
|
41
|
-
require_once $filePath;
|
|
42
|
-
break;
|
|
43
|
-
default:
|
|
44
|
-
throw new InvalidArgumentException("Invalid include mode: $mode");
|
|
45
|
-
}
|
|
43
|
+
$wrapped = self::wrapWithId($filePath, $html);
|
|
44
|
+
|
|
45
|
+
$fragDom = TemplateCompiler::convertToXml($wrapped, false);
|
|
46
46
|
|
|
47
|
-
$
|
|
48
|
-
|
|
47
|
+
self::prefixInlineHandlers($fragDom);
|
|
48
|
+
|
|
49
|
+
$newHtml = '';
|
|
50
|
+
foreach ($fragDom->documentElement->childNodes as $c) {
|
|
51
|
+
$newHtml .= $fragDom->saveXML($c);
|
|
52
|
+
}
|
|
49
53
|
|
|
50
54
|
self::$sections[$filePath] = [
|
|
51
55
|
'path' => $filePath,
|
|
52
|
-
'html' => $
|
|
56
|
+
'html' => $newHtml,
|
|
53
57
|
];
|
|
54
58
|
|
|
55
|
-
echo $
|
|
59
|
+
echo $newHtml;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
private static function wrapWithId(string $filePath, string $html): string
|
|
@@ -61,4 +65,37 @@ class IncludeTracker
|
|
|
61
65
|
|
|
62
66
|
return "<div pp-section-id=\"$id\">\n$html\n</div>";
|
|
63
67
|
}
|
|
68
|
+
|
|
69
|
+
private static function prefixInlineHandlers(DOMDocument $doc): void
|
|
70
|
+
{
|
|
71
|
+
$xp = new DOMXPath($doc);
|
|
72
|
+
|
|
73
|
+
/** @var DOMElement $el */
|
|
74
|
+
foreach ($xp->query('//*') as $el) {
|
|
75
|
+
$handlers = [];
|
|
76
|
+
|
|
77
|
+
foreach (iterator_to_array($el->attributes) as $attr) {
|
|
78
|
+
$name = $attr->name;
|
|
79
|
+
|
|
80
|
+
if (!str_starts_with($name, 'on')) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
$event = substr($name, 2);
|
|
85
|
+
if (
|
|
86
|
+
!in_array($event, PrismaPHPSettings::$htmlEvents, true) ||
|
|
87
|
+
trim($attr->value) === ''
|
|
88
|
+
) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
$handlers[$name] = $attr->value;
|
|
93
|
+
$el->removeAttribute($name);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
foreach ($handlers as $origName => $value) {
|
|
97
|
+
$el->setAttribute("pp-inc-{$origName}", $value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
64
101
|
}
|
|
@@ -113,30 +113,44 @@ class PHPX implements IPHPX
|
|
|
113
113
|
* @param array $exclude Attribute names to remove on the fly (optional)
|
|
114
114
|
* @return string Example: id="btn" data-id="7"
|
|
115
115
|
*/
|
|
116
|
-
protected function getAttributes(
|
|
117
|
-
|
|
118
|
-
array $exclude = []
|
|
119
|
-
): string {
|
|
116
|
+
protected function getAttributes(array $params = [], array $exclude = []): string
|
|
117
|
+
{
|
|
120
118
|
$reserved = ['class', 'children'];
|
|
121
|
-
|
|
122
|
-
$filteredProps = array_diff_key(
|
|
119
|
+
$props = array_diff_key(
|
|
123
120
|
$this->props,
|
|
124
|
-
array_flip(
|
|
121
|
+
array_flip(array_merge($reserved, $exclude))
|
|
125
122
|
);
|
|
126
123
|
|
|
127
|
-
$
|
|
124
|
+
$props = array_combine(
|
|
125
|
+
array_map('strtolower', array_keys($props)),
|
|
126
|
+
$props
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
foreach ($props as $key => $val) {
|
|
130
|
+
if (str_starts_with($key, 'on')) {
|
|
131
|
+
$event = substr($key, 2);
|
|
132
|
+
if (in_array($event, PrismaPHPSettings::$htmlEvents, true) && trim((string)$val) !== '') {
|
|
133
|
+
$props["pp-original-on{$event}"] = (string)$val;
|
|
134
|
+
}
|
|
135
|
+
unset($props[$key]);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
foreach ($params as $k => $v) {
|
|
140
|
+
$props[$k] = $v;
|
|
141
|
+
}
|
|
128
142
|
|
|
129
143
|
$pairs = array_map(
|
|
130
144
|
static fn($k, $v) => sprintf(
|
|
131
145
|
"%s='%s'",
|
|
132
146
|
htmlspecialchars($k, ENT_QUOTES, 'UTF-8'),
|
|
133
|
-
htmlspecialchars((string)
|
|
147
|
+
htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8')
|
|
134
148
|
),
|
|
135
|
-
array_keys($
|
|
136
|
-
$
|
|
149
|
+
array_keys($props),
|
|
150
|
+
$props
|
|
137
151
|
);
|
|
138
152
|
|
|
139
|
-
$this->attributesArray = $
|
|
153
|
+
$this->attributesArray = $props;
|
|
140
154
|
return implode(' ', $pairs);
|
|
141
155
|
}
|
|
142
156
|
|
|
@@ -171,7 +185,7 @@ class PHPX implements IPHPX
|
|
|
171
185
|
try {
|
|
172
186
|
return $this->render();
|
|
173
187
|
} catch (Exception) {
|
|
174
|
-
return '';
|
|
188
|
+
return '';
|
|
175
189
|
}
|
|
176
190
|
}
|
|
177
191
|
}
|
|
@@ -14,9 +14,12 @@ use DOMText;
|
|
|
14
14
|
use RuntimeException;
|
|
15
15
|
use Bootstrap;
|
|
16
16
|
use LibXMLError;
|
|
17
|
+
use DOMXPath;
|
|
17
18
|
|
|
18
19
|
class TemplateCompiler
|
|
19
20
|
{
|
|
21
|
+
protected const BINDING_REGEX = '/\{\{\s*((?:(?!\{\{|\}\})[\s\S])*?)\s*\}\}/uS';
|
|
22
|
+
|
|
20
23
|
protected static array $classMappings = [];
|
|
21
24
|
protected static array $selfClosingTags = [
|
|
22
25
|
'area',
|
|
@@ -37,10 +40,16 @@ class TemplateCompiler
|
|
|
37
40
|
'wbr'
|
|
38
41
|
];
|
|
39
42
|
private static array $sectionStack = [];
|
|
40
|
-
|
|
43
|
+
private static int $compileDepth = 0;
|
|
44
|
+
private static array $componentInstanceCounts = [];
|
|
41
45
|
|
|
42
46
|
public static function compile(string $templateContent): string
|
|
43
47
|
{
|
|
48
|
+
if (self::$compileDepth === 0) {
|
|
49
|
+
self::$componentInstanceCounts = [];
|
|
50
|
+
}
|
|
51
|
+
self::$compileDepth++;
|
|
52
|
+
|
|
44
53
|
if (empty(self::$classMappings)) {
|
|
45
54
|
self::initializeClassMappings();
|
|
46
55
|
}
|
|
@@ -52,6 +61,8 @@ class TemplateCompiler
|
|
|
52
61
|
foreach ($root->childNodes as $child) {
|
|
53
62
|
$output[] = self::processNode($child);
|
|
54
63
|
}
|
|
64
|
+
|
|
65
|
+
self::$compileDepth--;
|
|
55
66
|
return implode('', $output);
|
|
56
67
|
}
|
|
57
68
|
|
|
@@ -134,13 +145,16 @@ class TemplateCompiler
|
|
|
134
145
|
);
|
|
135
146
|
}
|
|
136
147
|
|
|
137
|
-
public static function convertToXml(string $templateContent): DOMDocument
|
|
148
|
+
public static function convertToXml(string $templateContent, bool $escapeAttributes = true): DOMDocument
|
|
138
149
|
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
150
|
+
|
|
151
|
+
if ($escapeAttributes) {
|
|
152
|
+
$templateContent = self::escapeMustacheAngles(
|
|
153
|
+
self::escapeAttributeAngles(
|
|
154
|
+
self::escapeAmpersands($templateContent)
|
|
155
|
+
)
|
|
156
|
+
);
|
|
157
|
+
}
|
|
144
158
|
|
|
145
159
|
$dom = new DOMDocument();
|
|
146
160
|
libxml_use_internal_errors(true);
|
|
@@ -255,33 +269,114 @@ class TemplateCompiler
|
|
|
255
269
|
|
|
256
270
|
private static function processBindingExpression(string $expr): string
|
|
257
271
|
{
|
|
272
|
+
$escaped = htmlspecialchars($expr, ENT_QUOTES, 'UTF-8');
|
|
273
|
+
|
|
258
274
|
if (preg_match('/^[\w.]+$/u', $expr)) {
|
|
259
|
-
return "<span pp-bind=\"{$
|
|
275
|
+
return "<span pp-bind=\"{$escaped}\"></span>";
|
|
260
276
|
}
|
|
261
|
-
return "<span pp-bind-expr=\"{$expr}\"></span>";
|
|
262
|
-
}
|
|
263
277
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
$mapping = self::selectComponentMapping($componentName);
|
|
267
|
-
$attributes = $incomingProps;
|
|
268
|
-
|
|
269
|
-
$attributes['pp-sync-script'] = 's' . base_convert(sprintf('%u', crc32($mapping['className'])), 10, 36);
|
|
278
|
+
return "<span pp-bind-expr=\"{$escaped}\"></span>";
|
|
279
|
+
}
|
|
270
280
|
|
|
271
|
-
|
|
281
|
+
protected static function renderComponent(
|
|
282
|
+
DOMElement $node,
|
|
283
|
+
string $componentName,
|
|
284
|
+
array $incomingProps
|
|
285
|
+
): string {
|
|
286
|
+
$mapping = self::selectComponentMapping($componentName);
|
|
287
|
+
$instance = self::initializeComponentInstance($mapping, $incomingProps);
|
|
272
288
|
|
|
273
289
|
$childHtml = '';
|
|
274
290
|
foreach ($node->childNodes as $c) {
|
|
275
|
-
$childHtml .= self::processNode($c
|
|
291
|
+
$childHtml .= self::processNode($c);
|
|
276
292
|
}
|
|
277
293
|
$instance->children = $childHtml;
|
|
278
294
|
|
|
295
|
+
$baseId = 's' . base_convert(sprintf('%u', crc32($mapping['className'])), 10, 36);
|
|
296
|
+
$idx = self::$componentInstanceCounts[$baseId] ?? 0;
|
|
297
|
+
self::$componentInstanceCounts[$baseId] = $idx + 1;
|
|
298
|
+
$sectionId = $idx === 0 ? $baseId : "{$baseId}{$idx}";
|
|
299
|
+
|
|
279
300
|
$html = $instance->render();
|
|
280
|
-
|
|
281
|
-
|
|
301
|
+
$fragDom = self::convertToXml($html, false);
|
|
302
|
+
$xpath = new DOMXPath($fragDom);
|
|
303
|
+
|
|
304
|
+
/** @var DOMElement $el */
|
|
305
|
+
foreach ($xpath->query('//*') as $el) {
|
|
306
|
+
|
|
307
|
+
$tag = $el->tagName;
|
|
308
|
+
if (ctype_upper($tag[0]) || isset(self::$classMappings[$tag])) {
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
$originalEvents = [];
|
|
313
|
+
$componentEvents = [];
|
|
314
|
+
|
|
315
|
+
foreach (iterator_to_array($el->attributes) as $attr) {
|
|
316
|
+
$name = $attr->name;
|
|
317
|
+
$value = $attr->value;
|
|
318
|
+
|
|
319
|
+
if (str_starts_with($name, 'pp-original-')) {
|
|
320
|
+
$origName = substr($name, strlen('pp-original-'));
|
|
321
|
+
$originalEvents[$origName] = $value;
|
|
322
|
+
} elseif (str_starts_with($name, 'on')) {
|
|
323
|
+
$event = substr($name, 2);
|
|
324
|
+
if (
|
|
325
|
+
in_array($event, PrismaPHPSettings::$htmlEvents, true)
|
|
326
|
+
&& trim((string)$value) !== ''
|
|
327
|
+
) {
|
|
328
|
+
$componentEvents[$name] = $value;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
foreach (array_keys($originalEvents) as $k) $el->removeAttribute("pp-original-{$k}");
|
|
334
|
+
foreach (array_keys($componentEvents) as $k) $el->removeAttribute($k);
|
|
335
|
+
|
|
336
|
+
foreach ($componentEvents as $evAttr => $compValue) {
|
|
337
|
+
|
|
338
|
+
$el->setAttribute(
|
|
339
|
+
"data-pp-child-{$evAttr}",
|
|
340
|
+
$compValue
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
if (isset($originalEvents[$evAttr])) {
|
|
344
|
+
$parentValue = $originalEvents[$evAttr];
|
|
345
|
+
$el->setAttribute(
|
|
346
|
+
"data-pp-parent-{$evAttr}",
|
|
347
|
+
$parentValue
|
|
348
|
+
);
|
|
349
|
+
unset($originalEvents[$evAttr]);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
foreach ($originalEvents as $name => $value) {
|
|
354
|
+
$el->setAttribute($name, $value);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
$root = $fragDom->documentElement;
|
|
359
|
+
foreach ($root->childNodes as $c) {
|
|
360
|
+
if ($c instanceof DOMElement) {
|
|
361
|
+
$c->setAttribute('pp-phpx-id', $sectionId);
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
$htmlOut = '';
|
|
367
|
+
foreach ($root->childNodes as $child) {
|
|
368
|
+
$htmlOut .= $fragDom->saveXML($child);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (
|
|
372
|
+
str_contains($htmlOut, '{{') ||
|
|
373
|
+
self::hasComponentTag($htmlOut) ||
|
|
374
|
+
stripos($htmlOut, '<script') !== false
|
|
375
|
+
) {
|
|
376
|
+
$htmlOut = self::compile($htmlOut);
|
|
282
377
|
}
|
|
283
378
|
|
|
284
|
-
return $
|
|
379
|
+
return $htmlOut;
|
|
285
380
|
}
|
|
286
381
|
|
|
287
382
|
private static function selectComponentMapping(string $componentName): array
|
|
@@ -92,6 +92,13 @@ class PrismaPHPSettings
|
|
|
92
92
|
*/
|
|
93
93
|
public static string $localStoreKey;
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* The HTML events loaded from the html-events.json file.
|
|
97
|
+
*
|
|
98
|
+
* @var array
|
|
99
|
+
*/
|
|
100
|
+
public static array $htmlEvents = [];
|
|
101
|
+
|
|
95
102
|
public static function init(): void
|
|
96
103
|
{
|
|
97
104
|
self::$option = self::getPrismaSettings();
|
|
@@ -99,6 +106,7 @@ class PrismaPHPSettings
|
|
|
99
106
|
self::$classLogFiles = self::getClassesLogFiles();
|
|
100
107
|
self::$includeFiles = self::getIncludeFiles();
|
|
101
108
|
self::$localStoreKey = self::getLocalStorageKey();
|
|
109
|
+
self::$htmlEvents = self::getHtmlEvents();
|
|
102
110
|
}
|
|
103
111
|
|
|
104
112
|
/**
|
|
@@ -178,4 +186,15 @@ class PrismaPHPSettings
|
|
|
178
186
|
$localStorageKey = $_ENV['LOCALSTORE_KEY'] ?? 'pphp_local_store_59e13';
|
|
179
187
|
return strtolower(preg_replace('/\s+/', '_', trim($localStorageKey)));
|
|
180
188
|
}
|
|
189
|
+
|
|
190
|
+
private static function getHtmlEvents(): array
|
|
191
|
+
{
|
|
192
|
+
$path = SETTINGS_PATH . '/html-events.json';
|
|
193
|
+
if (!file_exists($path)) {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
$events = json_decode(file_get_contents($path), true);
|
|
198
|
+
return is_array($events) ? $events : [];
|
|
199
|
+
}
|
|
181
200
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 123.8 126.8">
|
|
3
|
+
<g id="Layer_1-2" data-name="Layer_1">
|
|
4
|
+
<polygon points="113.9 50.6 111.5 49.4 105 46.2 97.1 42.4 92.7 37 89 32.7 84.6 31.3 77.9 32.6 72.4 37.9 71.3 45.5 68.1 50.9 66.2 46.6 64.6 33.1 63.1 21.6 60.3 15.1 50.4 5.5 46.7 20.5 46.7 32.9 39 27.4 24.1 11.8 0 0 6.5 12.1 18.2 24.7 27.8 42.1 41 55.6 47.7 66.2 45.2 73.5 44.1 89 35.8 99.3 34.1 106.8 39.7 105.2 37.1 113.5 39.4 122.5 44.1 116.3 47.7 126.8 53.4 117.9 60.8 123.2 62.2 113.2 68.3 115.3 67.8 108.3 74.2 110.1 72.7 101.7 58.8 90.1 77 80.7 84 72.3 88 62.6 90.8 51.1 94.1 46.6 99.8 47.3 107.2 49.9 112.2 51.6 123.8 58.2 113.9 50.6"/>
|
|
5
|
+
</g>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
|
|
@@ -2,10 +2,4 @@ body {
|
|
|
2
2
|
font-family: Arial, Helvetica, sans-serif; /* Default font for body */
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
/*! tailwindcss v4.0.14 | MIT License | https://tailwindcss.com */@layer theme, base, components, utilities;@layer theme{:host,:root{--font-sans:var(--font-geist-sans);--font-mono:var(--font-geist-mono);--color-red-500:oklch(0.637 0.237 25.331);--color-red-600:oklch(0.577 0.245 27.325);--color-gray-50:oklch(0.985 0.002 247.839);--color-gray-100:oklch(0.967 0.003 264.542);--color-gray-200:oklch(0.928 0.006 264.531);--color-gray-300:oklch(0.872 0.01 258.338);--color-gray-400:oklch(0.707 0.022 261.325);--color-gray-500:oklch(0.551 0.027 264.364);--color-gray-800:oklch(0.278 0.033 256.848);--color-gray-900:oklch(0.21 0.034 264.665);--color-gray-950:oklch(0.13 0.028 261.692);--color-black:#000;--color-white:#fff;--spacing:0.25rem;--container-md:28rem;--text-xs:0.75rem;--text-xs--line-height:1.33333;--text-sm:0.875rem;--text-sm--line-height:1.42857;--text-base:1rem;--text-lg:1.125rem;--text-lg--line-height:1.55556;--text-xl:1.25rem;--text-xl--line-height:1.4;--text-3xl:1.875rem;--text-3xl--line-height:1.2;--text-4xl:2.25rem;--text-4xl--line-height:1.11111;--text-5xl:3rem;--text-5xl--line-height:1;--text-6xl:3.75rem;--text-6xl--line-height:1;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tighter:-0.05em;--leading-relaxed:1.625;--radius-md:0.375rem;--radius-lg:0.5rem;--ease-in:cubic-bezier(0.4,0,1,1);--ease-out:cubic-bezier(0,0,0.2,1);--default-transition-duration:150ms;--default-transition-timing-function:cubic-bezier(0.4,0,0.2,1);--default-font-family:var(--font-sans);--default-font-feature-settings:var(--font-sans--font-feature-settings);--default-font-variation-settings:var(
|
|
6
|
-
--font-sans--font-variation-settings
|
|
7
|
-
);--default-mono-font-family:var(--font-mono);--default-mono-font-feature-settings:var(
|
|
8
|
-
--font-mono--font-feature-settings
|
|
9
|
-
);--default-mono-font-variation-settings:var(
|
|
10
|
-
--font-mono--font-variation-settings
|
|
11
|
-
)}}@layer base{*,::backdrop,::file-selector-button,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:var( --default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji" );font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var( --default-font-variation-settings,normal );tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var( --default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace );font-feature-settings:var( --default-mono-font-feature-settings,normal );font-size:1em;font-variation-settings:var( --default-mono-font-variation-settings,normal )}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}::file-selector-button,button,input,optgroup,select,textarea{background-color:transparent;border-radius:0;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{color:color-mix(in oklab,currentColor 50%,transparent);opacity:1}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}::file-selector-button,button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.visible{visibility:visible}.sr-only{height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;clip:rect(0,0,0,0);border-width:0;white-space:nowrap}.static{position:static}.mx-auto{margin-inline:auto}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.hidden{display:none}.inline-flex{display:inline-flex}.size-9{height:calc(var(--spacing)*9);width:calc(var(--spacing)*9)}.size-20{height:calc(var(--spacing)*20);width:calc(var(--spacing)*20)}.h-10{height:calc(var(--spacing)*10)}.h-14{height:calc(var(--spacing)*14)}.h-screen{height:100vh}.min-h-\[100vh\]{min-height:100vh}.w-full{width:100%}.max-w-\[600px\]{max-width:600px}.max-w-\[700px\]{max-width:700px}.max-w-md{max-width:var(--container-md)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.transform{transform:var(--tw-rotate-x) var(--tw-rotate-y) var(--tw-rotate-z) var(--tw-skew-x) var(--tw-skew-y)}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.space-y-2{:where(&>:not(:last-child)){--tw-space-y-reverse:0;margin-block-end:calc(var(--spacing)*2*(1 - var(--tw-space-y-reverse)));margin-block-start:calc(var(--spacing)*2*var(--tw-space-y-reverse))}}.space-y-4{:where(&>:not(:last-child)){--tw-space-y-reverse:0;margin-block-end:calc(var(--spacing)*4*(1 - var(--tw-space-y-reverse)));margin-block-start:calc(var(--spacing)*4*var(--tw-space-y-reverse))}}.rounded{border-radius:.25rem}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-gray-200{border-color:var(--color-gray-200)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-red-500{background-color:var(--color-red-500)}.bg-white{background-color:var(--color-white)}.bg-linear-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-\[\#a1b8c2\]{--tw-gradient-from:#a1b8c2;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-white{--tw-gradient-to:var(--color-white);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.px-4{padding-inline:calc(var(--spacing)*4)}.px-6{padding-inline:calc(var(--spacing)*6)}.px-8{padding-inline:calc(var(--spacing)*8)}.py-3{padding-block:calc(var(--spacing)*3)}.py-6{padding-block:calc(var(--spacing)*6)}.text-center{text-align:center}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-6xl{font-size:var(--text-6xl);line-height:var(--tw-leading,var(--text-6xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tighter{--tw-tracking:var(--tracking-tighter);letter-spacing:var(--tracking-tighter)}.text-gray-50{color:var(--color-gray-50)}.text-gray-500{color:var(--color-gray-500)}.text-red-500{color:var(--color-red-500)}.underline-offset-4{text-underline-offset:4px}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,rgba(0,0,0,.1)),0 2px 4px -2px var(--tw-shadow-color,rgba(0,0,0,.1))}.shadow-md,.shadow-sm{box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,rgba(0,0,0,.1)),0 1px 2px -1px var(--tw-shadow-color,rgba(0,0,0,.1))}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,rgba(0,0,0,.05));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.transition{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-colors{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.hover\:bg-gray-100{&:hover{@media (hover:hover){background-color:var(--color-gray-100)}}}.hover\:bg-gray-900\/90{&:hover{@media (hover:hover){background-color:color-mix(in oklab,var(--color-gray-900) 90%,transparent)}}}.hover\:bg-red-600{&:hover{@media (hover:hover){background-color:var(--color-red-600)}}}.hover\:text-gray-900{&:hover{@media (hover:hover){color:var(--color-gray-900)}}}.hover\:underline{&:hover{@media (hover:hover){text-decoration-line:underline}}}.focus-visible\:ring-1{&:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\:ring-gray-950{&:focus-visible{--tw-ring-color:var(--color-gray-950)}}.focus-visible\:outline-hidden{&:focus-visible{--tw-outline-style:none;outline-style:none;@media (forced-colors:active){outline:2px solid transparent;outline-offset:2px}}}.disabled\:pointer-events-none{&:disabled{pointer-events:none}}.disabled\:opacity-50{&:disabled{opacity:50%}}.sm\:ml-auto{@media (width >= 40rem){margin-left:auto}}.sm\:block{@media (width >= 40rem){display:block}}.sm\:flex-row{@media (width >= 40rem){flex-direction:row}}.sm\:gap-6{@media (width >= 40rem){gap:calc(var(--spacing)*6)}}.sm\:text-4xl{@media (width >= 40rem){font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}}.sm\:text-5xl{@media (width >= 40rem){font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}}.md\:px-6{@media (width >= 48rem){padding-inline:calc(var(--spacing)*6)}}.md\:text-5xl{@media (width >= 48rem){font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}}.md\:text-6xl{@media (width >= 48rem){font-size:var(--text-6xl);line-height:var(--tw-leading,var(--text-6xl--line-height))}}.md\:text-xl{@media (width >= 48rem){font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}}.md\:text-xl\/relaxed{@media (width >= 48rem){font-size:var(--text-xl);line-height:var(--leading-relaxed)}}.lg\:px-6{@media (width >= 64rem){padding-inline:calc(var(--spacing)*6)}}.lg\:text-6xl\/none{@media (width >= 64rem){font-size:var(--text-6xl);line-height:1}}.lg\:text-base\/relaxed{@media (width >= 64rem){font-size:var(--text-base);line-height:var(--leading-relaxed)}}.xl\:text-xl\/relaxed{@media (width >= 80rem){font-size:var(--text-xl);line-height:var(--leading-relaxed)}}.dark\:border-gray-800{@media (prefers-color-scheme:dark){border-color:var(--color-gray-800)}}.dark\:bg-gray-50{@media (prefers-color-scheme:dark){background-color:var(--color-gray-50)}}.dark\:bg-gray-950{@media (prefers-color-scheme:dark){background-color:var(--color-gray-950)}}.dark\:from-\[\#334455\]{@media (prefers-color-scheme:dark){--tw-gradient-from:#345;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}}.dark\:to-black{@media (prefers-color-scheme:dark){--tw-gradient-to:var(--color-black);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}}.dark\:text-gray-400{@media (prefers-color-scheme:dark){color:var(--color-gray-400)}}.dark\:text-gray-900{@media (prefers-color-scheme:dark){color:var(--color-gray-900)}}.dark\:hover\:bg-gray-50\/90{@media (prefers-color-scheme:dark){&:hover{@media (hover:hover){background-color:color-mix(in oklab,var(--color-gray-50) 90%,transparent)}}}}.dark\:hover\:bg-gray-800{@media (prefers-color-scheme:dark){&:hover{@media (hover:hover){background-color:var(--color-gray-800)}}}}.dark\:hover\:text-gray-50{@media (prefers-color-scheme:dark){&:hover{@media (hover:hover){color:var(--color-gray-50)}}}}.dark\:focus-visible\:ring-gray-300{@media (prefers-color-scheme:dark){&:focus-visible{--tw-ring-color:var(--color-gray-300)}}}}:root{--background:#fff;--foreground:#171717}@media (prefers-color-scheme:dark){:root{--background:#0a0a0a;--foreground:#ededed}}@layer base{@font-face{font-family:GeistVF;src:url(../assets/fonts/GeistVF.woff) format("woff")}@font-face{font-family:GeistMonoVF;src:url(../assets/fonts/GeistMonoVF.woff) format("woff")}body{background:var(--background);color:var(--foreground);font-family:Arial,Helvetica,sans-serif}code{font-family:GeistMonoVF,monospace}}@property --tw-rotate-x{syntax:"*";inherits:false;initial-value:rotateX(0)}@property --tw-rotate-y{syntax:"*";inherits:false;initial-value:rotateY(0)}@property --tw-rotate-z{syntax:"*";inherits:false;initial-value:rotateZ(0)}@property --tw-skew-x{syntax:"*";inherits:false;initial-value:skewX(0)}@property --tw-skew-y{syntax:"*";inherits:false;initial-value:skewY(0)}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --tw-gradient-via-position{syntax:"<length-percentage>";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"<length-percentage>";inherits:false;initial-value:100%}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ease{syntax:"*";inherits:false}
|
|
5
|
+
/*! tailwindcss v4.1.7 | MIT License | https://tailwindcss.com */@layer properties;@layer theme, base, components, utilities;@layer theme{:host,:root{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-500:oklch(63.7% 0.237 25.331);--color-red-600:oklch(57.7% 0.245 27.325);--color-gray-50:oklch(98.5% 0.002 247.839);--color-gray-100:oklch(96.7% 0.003 264.542);--color-gray-200:oklch(92.8% 0.006 264.531);--color-gray-300:oklch(87.2% 0.01 258.338);--color-gray-400:oklch(70.7% 0.022 261.325);--color-gray-500:oklch(55.1% 0.027 264.364);--color-gray-800:oklch(27.8% 0.033 256.848);--color-gray-900:oklch(21% 0.034 264.665);--color-gray-950:oklch(13% 0.028 261.692);--color-black:#000;--color-white:#fff;--spacing:0.25rem;--container-md:28rem;--text-xs:0.75rem;--text-xs--line-height:1.33333;--text-sm:0.875rem;--text-sm--line-height:1.42857;--text-base:1rem;--text-base--line-height:1.5;--text-lg:1.125rem;--text-lg--line-height:1.55556;--text-xl:1.25rem;--text-xl--line-height:1.4;--text-2xl:1.5rem;--text-2xl--line-height:1.33333;--text-3xl:1.875rem;--text-3xl--line-height:1.2;--text-4xl:2.25rem;--text-4xl--line-height:1.11111;--text-5xl:3rem;--text-5xl--line-height:1;--text-6xl:3.75rem;--text-6xl--line-height:1;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tighter:-0.05em;--tracking-tight:-0.025em;--leading-relaxed:1.625;--radius-md:0.375rem;--radius-lg:0.5rem;--ease-in:cubic-bezier(0.4,0,1,1);--ease-out:cubic-bezier(0,0,0.2,1);--default-transition-duration:150ms;--default-transition-timing-function:cubic-bezier(0.4,0,0.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,::backdrop,::file-selector-button,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);tab-size:4;-webkit-tap-highlight-color:transparent}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-size:1em;font-variation-settings:var(--default-mono-font-variation-settings,normal)}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}::file-selector-button,button,input,optgroup,select,textarea{background-color:transparent;border-radius:0;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not (-webkit-appearance:-apple-pay-button)) or (contain-intrinsic-size:1px){::placeholder{color:currentcolor;@supports (color:color-mix(in lab,red,red)){color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}::file-selector-button,button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.visible{visibility:visible}.sr-only{height:1px;margin:-1px;overflow:hidden;padding:0;width:1px;clip:rect(0,0,0,0);border-width:0;white-space:nowrap}.absolute,.sr-only{position:absolute}.relative{position:relative}.static{position:static}.row-start-2{grid-row-start:2}.row-start-3{grid-row-start:3}.mx-auto{margin-inline:auto}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-flex{display:inline-flex}.size-9{height:calc(var(--spacing)*9);width:calc(var(--spacing)*9)}.size-20{height:calc(var(--spacing)*20);width:calc(var(--spacing)*20)}.h-10{height:calc(var(--spacing)*10)}.h-14{height:calc(var(--spacing)*14)}.h-screen{height:100vh}.min-h-\[100vh\],.min-h-screen{min-height:100vh}.w-full{width:100%}.max-w-\[600px\]{max-width:600px}.max-w-\[700px\]{max-width:700px}.max-w-md{max-width:var(--container-md)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.grid-rows-\[20px_1fr_20px\]{grid-template-rows:20px 1fr 20px}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-center{justify-content:center}.justify-items-center{justify-items:center}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-7{gap:calc(var(--spacing)*7)}.gap-14{gap:calc(var(--spacing)*14)}.gap-16{gap:calc(var(--spacing)*16)}.gap-\[24px\]{gap:24px}.gap-\[32px\]{gap:32px}.space-y-2{:where(&>:not(:last-child)){--tw-space-y-reverse:0;margin-block-end:calc(var(--spacing)*2*(1 - var(--tw-space-y-reverse)));margin-block-start:calc(var(--spacing)*2*var(--tw-space-y-reverse))}}.space-y-4{:where(&>:not(:last-child)){--tw-space-y-reverse:0;margin-block-end:calc(var(--spacing)*4*(1 - var(--tw-space-y-reverse)));margin-block-start:calc(var(--spacing)*4*var(--tw-space-y-reverse))}}.rounded{border-radius:.25rem}.rounded-full{border-radius:calc(infinity*1px)}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-black\/\[\.08\]{border-color:color-mix(in srgb,#000 8%,transparent);@supports (color:color-mix(in lab,red,red)){border-color:color-mix(in oklab,var(--color-black) 8%,transparent)}}.border-gray-200{border-color:var(--color-gray-200)}.border-transparent{border-color:transparent}.bg-black\/\[\.05\]{background-color:color-mix(in srgb,#000 5%,transparent);@supports (color:color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-black) 5%,transparent)}}.bg-foreground{background-color:var(--foreground)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-red-500{background-color:var(--color-red-500)}.bg-white{background-color:var(--color-white)}.bg-linear-to-b{--tw-gradient-position:to bottom;@supports (background-image:linear-gradient(in lab,red,red)){--tw-gradient-position:to bottom in oklab}background-image:linear-gradient(var(--tw-gradient-stops))}.from-\[\#a1b8c2\]{--tw-gradient-from:#a1b8c2;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-white{--tw-gradient-to:var(--color-white);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.p-8{padding:calc(var(--spacing)*8)}.px-1{padding-inline:calc(var(--spacing)*1)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-6{padding-inline:calc(var(--spacing)*6)}.px-8{padding-inline:calc(var(--spacing)*8)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-6{padding-block:calc(var(--spacing)*6)}.pb-20{padding-bottom:calc(var(--spacing)*20)}.text-center{text-align:center}.align-super{vertical-align:super}.font-\[family-name\:var\(--font-geist-mono\)\]{font-family:var(--font-geist-mono)}.font-\[family-name\:var\(--font-geist-sans\)\]{font-family:var(--font-geist-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-6xl{font-size:var(--text-6xl);line-height:var(--tw-leading,var(--text-6xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{line-height:var(--tw-leading,var(--text-sm--line-height))}.text-sm,.text-sm\/6{font-size:var(--text-sm)}.text-sm\/6{line-height:calc(var(--spacing)*6)}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[-\.01em\]{--tw-tracking:-.01em;letter-spacing:-.01em}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-tighter{--tw-tracking:var(--tracking-tighter);letter-spacing:var(--tracking-tighter)}.text-background{color:var(--background)}.text-black{color:var(--color-black)}.text-gray-50{color:var(--color-gray-50)}.text-gray-500{color:var(--color-gray-500)}.text-red-500{color:var(--color-red-500)}.text-white{color:var(--color-white)}.underline-offset-4{text-underline-offset:4px}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,rgba(0,0,0,.1)),0 2px 4px -2px var(--tw-shadow-color,rgba(0,0,0,.1))}.shadow-md,.shadow-sm{box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,rgba(0,0,0,.1)),0 1px 2px -1px var(--tw-shadow-color,rgba(0,0,0,.1))}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,rgba(0,0,0,.05));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,visibility,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-colors{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.hover\:border-transparent{&:hover{@media (hover:hover){border-bottom-color:transparent;border-left-color:transparent;border-right-color:transparent;border-top-color:transparent}}}.hover\:bg-\[\#383838\]{&:hover{@media (hover:hover){background-color:#383838}}}.hover\:bg-\[\#f2f2f2\]{&:hover{@media (hover:hover){background-color:#f2f2f2}}}.hover\:bg-gray-100{&:hover{@media (hover:hover){background-color:var(--color-gray-100)}}}.hover\:bg-gray-900\/90{&:hover{@media (hover:hover){background-color:color-mix(in srgb,oklch(21% .034 264.665) 90%,transparent);@supports (color:color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-gray-900) 90%,transparent)}}}}.hover\:bg-red-600{&:hover{@media (hover:hover){background-color:var(--color-red-600)}}}.hover\:text-gray-900{&:hover{@media (hover:hover){color:var(--color-gray-900)}}}.hover\:underline{&:hover{@media (hover:hover){text-decoration-line:underline}}}.hover\:underline-offset-4{&:hover{@media (hover:hover){text-underline-offset:4px}}}.focus-visible\:ring-1{&:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\:ring-gray-950{&:focus-visible{--tw-ring-color:var(--color-gray-950)}}.focus-visible\:outline-hidden{&:focus-visible{--tw-outline-style:none;outline-style:none;@media (forced-colors:active){outline:2px solid transparent;outline-offset:2px}}}.disabled\:pointer-events-none{&:disabled{pointer-events:none}}.disabled\:opacity-50{&:disabled{opacity:50%}}.sm\:ml-auto{@media (width >= 40rem){margin-left:auto}}.sm\:block{@media (width >= 40rem){display:block}}.sm\:h-12{@media (width >= 40rem){height:calc(var(--spacing)*12)}}.sm\:w-auto{@media (width >= 40rem){width:auto}}.sm\:flex-row{@media (width >= 40rem){flex-direction:row}}.sm\:items-center{@media (width >= 40rem){align-items:center}}.sm\:items-start{@media (width >= 40rem){align-items:flex-start}}.sm\:gap-6{@media (width >= 40rem){gap:calc(var(--spacing)*6)}}.sm\:p-20{@media (width >= 40rem){padding:calc(var(--spacing)*20)}}.sm\:px-5{@media (width >= 40rem){padding-inline:calc(var(--spacing)*5)}}.sm\:text-center{@media (width >= 40rem){text-align:center}}.sm\:text-left{@media (width >= 40rem){text-align:left}}.sm\:text-4xl{@media (width >= 40rem){font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}}.sm\:text-5xl{@media (width >= 40rem){font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}}.sm\:text-base{@media (width >= 40rem){font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}}.md\:w-\[158px\]{@media (width >= 48rem){width:158px}}.md\:px-6{@media (width >= 48rem){padding-inline:calc(var(--spacing)*6)}}.md\:text-5xl{@media (width >= 48rem){font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}}.md\:text-6xl{@media (width >= 48rem){font-size:var(--text-6xl);line-height:var(--tw-leading,var(--text-6xl--line-height))}}.md\:text-xl{@media (width >= 48rem){font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}}.md\:text-xl\/relaxed{@media (width >= 48rem){font-size:var(--text-xl);line-height:var(--leading-relaxed)}}.lg\:px-6{@media (width >= 64rem){padding-inline:calc(var(--spacing)*6)}}.lg\:text-6xl\/none{@media (width >= 64rem){font-size:var(--text-6xl);line-height:1}}.lg\:text-base\/relaxed{@media (width >= 64rem){font-size:var(--text-base);line-height:var(--leading-relaxed)}}.xl\:text-xl\/relaxed{@media (width >= 80rem){font-size:var(--text-xl);line-height:var(--leading-relaxed)}}.dark\:border-gray-800{@media (prefers-color-scheme:dark){border-color:var(--color-gray-800)}}.dark\:border-white\/\[\.145\]{@media (prefers-color-scheme:dark){border-bottom-color:color-mix(in srgb,#fff 14.499999999999998%,transparent);border-left-color:color-mix(in srgb,#fff 14.499999999999998%,transparent);border-right-color:color-mix(in srgb,#fff 14.499999999999998%,transparent);border-top-color:color-mix(in srgb,#fff 14.499999999999998%,transparent);@supports (color:color-mix(in lab,red,red)){border-color:color-mix(in oklab,var(--color-white) 14.499999999999998%,transparent)}}}.dark\:bg-gray-50{@media (prefers-color-scheme:dark){background-color:var(--color-gray-50)}}.dark\:bg-gray-950{@media (prefers-color-scheme:dark){background-color:var(--color-gray-950)}}.dark\:bg-white\/\[\.06\]{@media (prefers-color-scheme:dark){background-color:color-mix(in srgb,#fff 6%,transparent);@supports (color:color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-white) 6%,transparent)}}}.dark\:from-\[\#334455\]{@media (prefers-color-scheme:dark){--tw-gradient-from:#345;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}}.dark\:to-black{@media (prefers-color-scheme:dark){--tw-gradient-to:var(--color-black);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}}.dark\:text-gray-400{@media (prefers-color-scheme:dark){color:var(--color-gray-400)}}.dark\:text-gray-900{@media (prefers-color-scheme:dark){color:var(--color-gray-900)}}.dark\:italic{@media (prefers-color-scheme:dark){font-style:italic}}.dark\:invert{@media (prefers-color-scheme:dark){--tw-invert:invert(100%);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}}.dark\:hover\:bg-\[\#1a1a1a\]{@media (prefers-color-scheme:dark){&:hover{@media (hover:hover){background-color:#1a1a1a}}}}.dark\:hover\:bg-\[\#ccc\]{@media (prefers-color-scheme:dark){&:hover{@media (hover:hover){background-color:#ccc}}}}.dark\:hover\:bg-gray-50\/90{@media (prefers-color-scheme:dark){&:hover{@media (hover:hover){background-color:color-mix(in srgb,oklch(98.5% .002 247.839) 90%,transparent);@supports (color:color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-gray-50) 90%,transparent)}}}}}.dark\:hover\:bg-gray-800{@media (prefers-color-scheme:dark){&:hover{@media (hover:hover){background-color:var(--color-gray-800)}}}}.dark\:hover\:text-gray-50{@media (prefers-color-scheme:dark){&:hover{@media (hover:hover){color:var(--color-gray-50)}}}}.dark\:focus-visible\:ring-gray-300{@media (prefers-color-scheme:dark){&:focus-visible{--tw-ring-color:var(--color-gray-300)}}}}:root{--background:#fff;--foreground:#171717}@media (prefers-color-scheme:dark){:root{--background:#0a0a0a;--foreground:#ededed}}body{background:var(--background);color:var(--foreground);font-family:Arial,Helvetica,sans-serif}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --tw-gradient-via-position{syntax:"<length-percentage>";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"<length-percentage>";inherits:false;initial-value:100%}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@layer properties{@supports ((-webkit-hyphens:none) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-ease:initial}}}
|
package/dist/src/app/index.php
CHANGED
|
@@ -1,55 +1,72 @@
|
|
|
1
1
|
<?php use Lib\Request; ?>
|
|
2
2
|
|
|
3
|
-
<div class="
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
<span class="
|
|
8
|
-
</
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
<div class="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20">
|
|
4
|
+
<main class="flex flex-col gap-5 row-start-2 items-center sm:items-center">
|
|
5
|
+
<h1 class="text-6xl font-bold tracking-tight">
|
|
6
|
+
<span class="text-black">PRISMA</span>
|
|
7
|
+
<span class="text-black text-2xl align-super">PHP</span>
|
|
8
|
+
</h1>
|
|
9
|
+
|
|
10
|
+
<ol class="list-inside list-decimal text-sm/6 text-center sm:text-left">
|
|
11
|
+
<li class="mb-2 tracking-[-.01em]">
|
|
12
|
+
Get started by editing
|
|
13
|
+
<code class="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-semibold">
|
|
14
|
+
src/app/index.php
|
|
15
|
+
</code>
|
|
16
|
+
.
|
|
17
|
+
</li>
|
|
18
|
+
<li class="tracking-[-.01em]">
|
|
19
|
+
Save and see your changes instantly.
|
|
20
|
+
</li>
|
|
21
|
+
</ol>
|
|
22
|
+
|
|
23
|
+
<div class="w-full flex items-center justify-center gap-4 sm:gap-6">
|
|
24
|
+
<a
|
|
25
|
+
class="rounded-full border border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] font-medium text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:w-auto"
|
|
26
|
+
href="https://prismaphp.tsnc.tech/docs"
|
|
27
|
+
target="_blank"
|
|
28
|
+
rel="noopener noreferrer">
|
|
29
|
+
<img src="<?= Request::baseUrl ?>/assets/images/prisma-php-black.svg" alt="Read Docs" width="20" height="20" style="filter: invert(1) sepia(1) hue-rotate(180deg);" /> Read Docs
|
|
21
30
|
</a>
|
|
22
|
-
</
|
|
23
|
-
</header>
|
|
24
|
-
<main class="flex-1 flex justify-center items-center">
|
|
25
|
-
<section id="hero" class="w-full">
|
|
26
|
-
<div class="px-4 md:px-6">
|
|
27
|
-
<div class="flex flex-col items-center space-y-4 text-center">
|
|
28
|
-
<h1 class="text-3xl font-bold tracking-tighter sm:text-4xl md:text-5xl lg:text-6xl/none flex items-center gap-3 justify-center">
|
|
29
|
-
Welcome to Prisma PHP <img class="size-20 hidden sm:block" src="<?= Request::baseUrl ?>/assets/images/prisma-php.svg" alt="Prisma PHP" />
|
|
30
|
-
</h1>
|
|
31
|
-
<p class="mx-auto max-w-[700px] text-gray-500 md:text-xl dark:text-gray-400">
|
|
32
|
-
Your Next Generation PHP Framework
|
|
33
|
-
</p>
|
|
34
|
-
<a class="inline-flex h-10 items-center justify-center rounded-md bg-gray-900 px-8 text-sm font-medium text-gray-50 shadow-sm transition-colors hover:bg-gray-900/90 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-gray-950 disabled:pointer-events-none disabled:opacity-50 dark:bg-gray-50 dark:text-gray-900 dark:hover:bg-gray-50/90 dark:focus-visible:ring-gray-300" href="https://prismaphp.tsnc.tech/docs?doc=get-started" target="_blank">
|
|
35
|
-
Get Started
|
|
36
|
-
</a>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
</section>
|
|
31
|
+
</div>
|
|
40
32
|
</main>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
33
|
+
|
|
34
|
+
<footer class="row-start-3 flex gap-[24px] flex-wrap items-center justify-center">
|
|
35
|
+
<a
|
|
36
|
+
class="flex items-center gap-2 hover:underline hover:underline-offset-4"
|
|
37
|
+
href="https://prismaphp.tsnc.tech/docs?doc=learning-path"
|
|
38
|
+
target="_blank"
|
|
39
|
+
rel="noopener noreferrer">
|
|
40
|
+
<img
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
src="<?= Request::baseUrl ?>/assets/images/file.svg"
|
|
43
|
+
alt="File icon"
|
|
44
|
+
width="16"
|
|
45
|
+
height="16" /> Learn
|
|
46
|
+
</a>
|
|
47
|
+
<a
|
|
48
|
+
class="flex items-center gap-2 hover:underline hover:underline-offset-4"
|
|
49
|
+
href="https://prismaphp.tsnc.tech/docs?doc=todo-app"
|
|
50
|
+
target="_blank"
|
|
51
|
+
rel="noopener noreferrer">
|
|
52
|
+
<img
|
|
53
|
+
aria-hidden="true"
|
|
54
|
+
src="<?= Request::baseUrl ?>/assets/images/window.svg"
|
|
55
|
+
alt="File icon"
|
|
56
|
+
width="16"
|
|
57
|
+
height="16" /> Examples
|
|
58
|
+
</a>
|
|
59
|
+
<a
|
|
60
|
+
class="flex items-center gap-2 hover:underline hover:underline-offset-4"
|
|
61
|
+
href="https://prismaphp.tsnc.tech/"
|
|
62
|
+
target="_blank"
|
|
63
|
+
rel="noopener noreferrer">
|
|
64
|
+
<img
|
|
65
|
+
aria-hidden="true"
|
|
66
|
+
src="<?= Request::baseUrl ?>/assets/images/globe.svg"
|
|
67
|
+
alt="File icon"
|
|
68
|
+
width="16"
|
|
69
|
+
height="16" /> prismaphp.tsnc.tech →
|
|
70
|
+
</a>
|
|
54
71
|
</footer>
|
|
55
72
|
</div>
|
package/dist/src/app/js/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{const e=EventTarget.prototype.addEventListener,t=EventTarget.prototype.removeEventListener,s=new Map,n=new Set(["wheel","mousewheel","touchstart","touchmove","touchend","touchcancel","scroll"]);EventTarget.prototype.addEventListener=function(t,r,i){let o=i;n.has(t)&&(void 0===o?o={passive:!0}:"boolean"==typeof o?o={capture:o,passive:!0}:o&&void 0===o.passive&&(o={...o,passive:!0})),s.has(this)||s.set(this,new Map);const a=s.get(this),c=a.get(t)||new Set;c.add(r),a.set(t,c),e.call(this,t,r,o)},EventTarget.prototype.removeEventListener=function(e,n,r){if(s.has(this)&&s.get(this).has(e)){const t=s.get(this).get(e);t.delete(n),0===t.size&&s.get(this).delete(e)}t.call(this,e,n,r)},EventTarget.prototype.removeAllEventListeners=function(e){if(!s.has(this))return;const n=s.get(this).get(e);n&&(n.forEach((s=>{t.call(this,e,s)})),s.get(this).delete(e))}})();class PPHP{props={};_isNavigating=!1;_responseData=null;_elementState={checkedElements:new Set};_activeAbortController=null;_reservedWords;_declaredStateRoots=new Set;_arrayMethodCache=new WeakMap;_scopedKeys=new Map;_updateScheduled=!1;_pendingBindings=new Set;_effects=new Set;_pendingEffects=new Set;_processedPhpSections=new Set;_processedPhpScripts=new WeakSet;_bindings=[];_templateStore=new WeakMap;_inlineDepth=0;_activeSection=null;_inlineModuleFns=new Map;_proxyCache=new WeakMap;_rawProps={};_refs=new Map;_wheelHandlersStashed=!1;_evaluatorCache=new Map;_depsCache=new Map;_eventHandlers;_redirectRegex=/redirect_7F834\s*=\s*(\/[^\s]*)/;_assignmentRe=/^\s*[\w.]+\s*=(?!=)/;_mustacheRe=/\{\{\s*([\s\S]+?)\s*\}\}/gu;_htmlEntitiesRe=/"|'|&/g;_mutators;_boolAttrs=new Set(["checked","selected","disabled","readonly","multiple","hidden"]);static _instance;static _effectCleanups;static debounceTimers=new Map;static _cancelableEvents=new Set(["click","submit","change"]);static _mustacheTest=/\{\{\s*[\s\S]+?\s*\}\}/;static _mustachePattern=/\{\{\s*([\s\S]+?)\s*\}\}/g;static _passiveEvents=new Set(["wheel","mousewheel","touchstart","touchmove","touchend","touchcancel","scroll"]);constructor(){const e=Object.getOwnPropertyNames(HTMLElement.prototype).filter((e=>e.startsWith("on"))),t=Object.getOwnPropertyNames(Document.prototype).filter((e=>e.startsWith("on"))),s=Object.getOwnPropertyNames(Window.prototype).filter((e=>e.startsWith("on")));this._eventHandlers=new Set([...e,...t,...s].map((e=>e.toLowerCase()))),this._reservedWords=new Set(["null","undefined","true","false","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","async","await","implements","interface","event","NaN","Infinity","Number","String","Boolean","Object","Array","Function","Date","RegExp","Error","JSON","Math","Map","Set"]),this._mutators=new Set(["push","pop","shift","unshift","splice","sort","reverse","copyWithin","fill"]),this.handlePopState(),this._proxyCache=new WeakMap,this._evaluatorCache.clear(),this._depsCache.clear(),this.props=this.makeReactive(this._rawProps),this.scheduleInitialHydration()}static get instance(){return PPHP._instance||(PPHP._instance=new PPHP),PPHP._instance}scheduleInitialHydration(){const e=async()=>{await this.initRefs(),await this.processInlineModuleScripts(),await this.initializeAllReferencedProps(),await this.initBindings(),await this.initLoopBindings(),this.attachWireFunctionEvents(),this._bindings.forEach((e=>e.update())),document.body.removeAttribute("hidden")};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}ref(e,t){const s=this._activeSection;let n=[];if(s&&(n=this._sectionRefs.get(s)?.get(e)??[]),0===n.length&&(n=this._refs.get(e)??[]),null!=t){const s=n[t];if(!s)throw new Error(`pphp.ref('${e}', ${t}) — no element at that index`);return s}if(0===n.length)throw new Error(`pphp.ref('${e}') failed — no element was found`);return 1===n.length?n[0]:n}effect(e,t){const s=this._currentSectionId(),n=Array.isArray(t),r=n?t:[],i=n&&0===r.length,o=r.map((e=>{if("function"==typeof e&&e.__pphp_key)return e.__pphp_key;if("string"!=typeof e)return"";if(e.includes("_"))return e;for(const[t,s]of this._scopedKeys)if(s.has(e))return`${t}_${e}`;return s?`${s}_${e}`:e})).filter(Boolean),a=new Set(o),c=new Map;for(const e of o)c.set(e,this.getNested(this.props,e));let l=0;PPHP._effectCleanups||(PPHP._effectCleanups=new WeakMap);const h=PPHP._effectCleanups,p=()=>{const t=h.get(p);if(t){try{t()}catch(e){console.error("cleanup error:",e)}h.delete(p)}if(++l>50)throw new Error("PPHP: effect ran >50 times — possible loop");if(!i&&o.length>0){let e=!1;for(const t of o){if(this.getNested(this.props,t)!==c.get(t)){e=!0;break}}if(!e)return;for(const e of o)c.set(e,this.getNested(this.props,e))}try{const t=e();"function"==typeof t&&h.set(p,t)}catch(e){console.error("effect error:",e)}};Object.assign(p,{__deps:a,__sectionId:s??null,__static:i});try{const t=e();"function"==typeof t&&h.set(p,t)}catch(e){console.error("effect error (initial):",e)}for(const e of o)c.set(e,this.getNested(this.props,e));const d=n&&this._inlineDepth>0?this._pendingEffects:this._effects;return i?this._effects.add(p):d.add(p),()=>{const e=h.get(p);if(e){try{e()}catch(e){console.error("cleanup error:",e)}h.delete(p)}this._effects.delete(p),this._pendingEffects.delete(p)}}getProxiedProps(e){let t=this._proxyCache.get(e);if(t)return t;return t=new Proxy(e,{get:(e,t)=>t in e?e[t]:void 0,set:(e,t,s)=>(e[t]=s,!0)}),this._proxyCache.set(e,t),t}resetProps(){Object.keys(this._rawProps).forEach((e=>{if(window.hasOwnProperty(e)){const t=Object.getOwnPropertyDescriptor(window,e);t&&t.configurable&&delete window[e]}})),this._rawProps={},this._proxyCache=new WeakMap,this._templateStore=new WeakMap,this._arrayMethodCache=new WeakMap,this._depsCache.clear(),this._evaluatorCache.clear(),this._processedPhpSections.clear(),this._processedPhpScripts=new WeakSet,this._scopedKeys=new Map,this._declaredStateRoots.clear(),this._inlineModuleFns.clear(),this._bindings=[],this._pendingBindings.clear(),this._effects.clear(),this._pendingEffects.clear(),this._refs.clear(),this._sectionRefs.clear(),this.props=this.makeReactive(this._rawProps)}async initMakeReactive(){await this.initRefs(),await this.initializeAllReferencedProps(),await this.initBindings(),await this.initLoopBindings(),this.attachWireFunctionEvents(),this._bindings.forEach((e=>e.update())),document.body.removeAttribute("hidden")}async initLoopBindings(){document.querySelectorAll("[pp-for]").forEach((e=>this.registerLoop(e)))}registerLoop(e){const t=e.getAttribute("pp-for").trim(),[s,n]=t.split(/\s+in\s+/),[r,i]=s.replace(/^\(|\)$/g,"").split(",").map((e=>e.trim())),o=e.parentNode,a=document.createComment("pp-for");o.insertBefore(a,e),o.removeChild(e);const c=this.makeSafeEvaluator(n),l=new Set(["value"]),h=this.extractDependencies(n);this._bindings.push({dependencies:h,update:()=>{const t=document.activeElement;let s=null,n=null;const h=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement;if(h&&o.contains(t)){const e=t.closest("[key]");e&&(s=e.getAttribute("key"),n=t.selectionStart)}for(let e=a.nextSibling;e&&e.nodeType!==Node.COMMENT_NODE;){const t=e.nextSibling;o.removeChild(e),e=t}if((c(this.props)??[]).forEach(((t,c)=>{this.props[r]=t,i&&(this.props[i]=c);const p=e.content.cloneNode(!0),d=document.createTreeWalker(p,NodeFilter.SHOW_TEXT);for(let e;e=d.nextNode();)e.nodeValue=(e.nodeValue||"").replace(PPHP._mustachePattern,((e,t)=>{try{return this.formatValue(this.makeSafeEvaluator(t)(this.props))}catch{return""}}));if(h&&null!==s){const e=o.querySelector(`[key="${s}"]`),t=e?.querySelector("input,textarea");if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.focus({preventScroll:!0}),null!==n)){const e=Math.min(n,t.value.length);t.setSelectionRange(e,e)}}p.querySelectorAll("*").forEach((e=>{Array.from(e.attributes).forEach((t=>{if(!PPHP._mustacheTest.test(t.value))return;const s=t.value.replace(PPHP._mustachePattern,((e,t)=>{try{return this.formatValue(this.makeSafeEvaluator(t)(this.props))}catch{return""}})),n=t.name.toLowerCase();if(this._boolAttrs.has(n)){const t=""!==s&&"false"!==s&&"0"!==s;e[n]=t,t?e.setAttribute(n,""):e.removeAttribute(n)}else l.has(n)&&(e[n]=s),t.value=s}))})),p.querySelectorAll("[pp-bind]").forEach((e=>{const t=e.getAttribute("pp-bind");e.textContent=this.formatValue(this.makeSafeEvaluator(t)(this.props))})),p.querySelectorAll("[pp-bind-expr]").forEach((e=>{const t=e.getAttribute("pp-bind-expr");e.textContent=this.formatValue(this.makeSafeEvaluator(t)(this.props))})),p.querySelectorAll("[pp-bind-class]").forEach((e=>{const t=e.getAttribute("pp-bind-class"),s=this.makeSafeEvaluator(t)(this.props);e.setAttribute("class",String(s))})),p.querySelectorAll("*").forEach((e=>{Array.from(e.attributes).forEach((t=>{t.name.startsWith("on")&&/\b(?:i|idx)\b/.test(t.value)&&e.setAttribute(t.name,((e,t)=>e.replace(/\[\s*(?:i|idx)\s*\]/g,`[${t}]`).replace(/(^|[^\w$])(?:i|idx)(?!\w)/g,((e,s)=>s+t)))(t.value,c))}))})),o.insertBefore(p,a.nextSibling)})),null!==s){const e=o.querySelector(`[key="${s}"]`),t=e?.querySelector("input,textarea");if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.focus({preventScroll:!0}),null!==n)){const e=Math.min(n,t.value.length);t.setSelectionRange(e,e)}}this.attachWireFunctionEvents()}})}_sectionRefs=new Map;async initRefs(){document.querySelectorAll("[pp-ref]").forEach((e=>{const t=e.getAttribute("pp-ref"),s=e.closest("[pp-section-id]")?.getAttribute("pp-section-id")??"__global__",n=this._sectionRefs.get(s)??new Map,r=n.get(t)??[];r.push(e),n.set(t,r),this._sectionRefs.set(s,n);const i=this._refs.get(t)??[];i.push(e),this._refs.set(t,i),e.removeAttribute("pp-ref")}))}scheduleBindingUpdate(e){this._pendingBindings.add(e),this._updateScheduled||(this._updateScheduled=!0,requestAnimationFrame((()=>{this.flushBindings()})))}makeReactive(e,t=[]){const s=this._proxyCache.get(e);if(s)return s;if(e instanceof Map||e instanceof Set||"object"!=typeof e||null===e)return e;const n=this,r=new Proxy(e,{get(e,s,r){const i=Reflect.get(e,s,r);if(Array.isArray(e)&&"string"==typeof s&&n._mutators.has(s)){let o=n._arrayMethodCache.get(e);if(o||(o=new Map,n._arrayMethodCache.set(e,o)),!o.has(s)){const e=i.bind(r),a=t.join("."),c=function(...t){const s=e(...t);return queueMicrotask((()=>{n._bindings.forEach((e=>{e.dependencies.has(a)&&n.scheduleBindingUpdate(e)}))})),s};o.set(s,c)}return o.get(s)}return null!==i&&"object"==typeof i?n.makeReactive(i,[...t,s]):i},set(e,s,r,i){let o=r;null!==r&&"object"==typeof r&&(o=n.makeReactive(r,[...t,s]));const a=e[s],c=Reflect.set(e,s,o,i);if(a===o)return c;const l=[...t,s].join(".");return n._bindings.forEach((e=>{for(const t of e.dependencies)if(l===t||l.startsWith(t+".")||t.startsWith(l+".")){n.scheduleBindingUpdate(e);break}})),c}});return this._proxyCache.set(e,r),r}makeAttrTemplateUpdater(e,t,s,n){let r=this._templateStore.get(e);r||(r=new Map,this._templateStore.set(e,r)),r.has(t)||r.set(t,e.getAttribute(t)||"");const i=n??r.get(t)??"";return(i.match(this._mustacheRe)||[]).forEach((e=>{this.extractDependencies(e).forEach((e=>s.add(e)))})),()=>{try{const s=i.replace(this._mustacheRe,((e,t)=>{try{const e=this.makeSafeEvaluator(t);return this.formatValue(e(this.props))}catch(e){return console.error("Error token:",t,e),""}}));e.getAttribute(t)!==s&&e.setAttribute(t,s)}catch(e){console.error(`Error evaluating the template for attribute "${t}". Please check the template syntax and dependencies.`,e)}}}makePrimitiveUpdater(e,t,s){const n={};return this._eventHandlers.forEach((e=>{if(e.startsWith("on")){const t=e.slice(2);n[t]=t}})),n.value="input",n.checked="change",()=>{try{const r=s(this.props),i=this.formatValue(r);let o=!1;if("value"===t){const t=e;"value"in e&&t.value!==i?(t.value=i,o=!0):"value"in e||(e.setAttribute("value",i),o=!0)}else{const t=e,s="true"===i;"checked"in e&&t.checked!==s?(t.checked=s,o=!0):"checked"in e||(e.setAttribute("checked",i),o=!0)}if(!o||e instanceof HTMLInputElement&&("hidden"===e.type||e.disabled||e.readOnly))return;const a=n[t]||t,c="click"===a?new MouseEvent(a,{bubbles:!0,cancelable:!0}):new Event(a,{bubbles:!0});e.dispatchEvent(c)}catch(e){console.error(`Error evaluating attribute "${t}":`,e)}}}formatValue(e){return null!==e&&"object"==typeof e&&1===Object.keys(e).length&&Object.prototype.hasOwnProperty.call(e,"value")?this.formatValue(e.value):"function"==typeof e?"":"boolean"==typeof e?e?"true":"false":Array.isArray(e)?e.map((e=>"object"==typeof e?JSON.stringify(e):String(e))).join(", "):e&&"object"==typeof e?Object.keys(e).length?JSON.stringify(e,null,2):"":e?.toString()??""}registerBinding(e,t,s="text",n){if(this._assignmentRe.test(t))return;const r=e.parentElement?.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;let i=t;if(r){const e=this._scopedKeys.get(r)||new Set,s=new Set;Object.keys(this.props).forEach((e=>{e.startsWith(r+"_")&&s.add(e.slice(r.length+1))}));const n=t=>(e.has(t)||s.has(t))&&!t.startsWith(r+"_")&&!this._reservedWords.has(t);i=t.replace(/\b([A-Za-z_$][\w$]*)\b/g,((e,t,s,i)=>"."===i[s-1]?e:n(t)?`${r}_${t}`:e))}const o=new Set([...this.extractDependencies(i)].map((e=>e.split(".")[0])).filter((e=>e in this.props&&!this._reservedWords.has(e)))),a=this.makeSafeEvaluator(i);if("value"===n||"checked"===n){const t=this.makePrimitiveUpdater(e,n,a);return void this._bindings.push({dependencies:o,update:t})}if(n){const s=n.toLowerCase();if(this._boolAttrs.has(s)){e.removeAttribute(s);const r=()=>{try{const t=!!a(this.props);e[n]!==t&&(e[n]=t),t?e.setAttribute(s,""):e.removeAttribute(s)}catch(e){console.error(`PPHP: error evaluating boolean attribute ${n}="${t}"`,e)}};return void this._bindings.push({dependencies:o,update:r})}const c=e.getAttribute(n)??"";if(this._mustacheRe.test(i)||this._mustacheRe.test(c)){const t=c.replace(this._mustacheRe,((e,t)=>{let s=t;if(r){const e=this._scopedKeys.get(r),n=e instanceof Set?e:new Set(Array.isArray(e)?e:[]);s=t.replace(/\b([A-Za-z_$][\w$]*)\b/g,((e,t,s,i)=>{const o=n.has(t),a=n.has(`${r}_${t}`);return o||a?"."===i[s-1]||this._reservedWords.has(t)||e.startsWith(`${r}_`)?e:`${r}_${t}`:e}))}return`{{ ${s} }}`})),s=this.makeAttrTemplateUpdater(e,n,o,t);return void this._bindings.push({dependencies:o,update:s})}const l=()=>{try{const t=a(this.props),s=this.formatValue(t);n in e&&(e[n]=s),e.setAttribute(n,s)}catch(e){console.error(`Error evaluating attribute ${n}="${t}"`,e)}};return void this._bindings.push({dependencies:o,update:l})}const c={text(e,t){e.textContent!==t&&(e.textContent=t)},value(e,t){e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value!==t&&(e.value=t):e.setAttribute("value",t)},checked(e,t){e instanceof HTMLInputElement?e.checked="true"===t:e.setAttribute("checked",t)},attr(e,t){e.setAttribute("attr",t)}};this._bindings.push({dependencies:o,update:()=>{try{const t=a(this.props),n=this.formatValue(t);c[s](e,n)}catch(e){console.error(`Error evaluating expression "${t}"`,e)}}})}safeTag=(e,...t)=>e.reduce(((e,s,n)=>{const r=t[n];return e+s+(null==r||"object"==typeof r?"":r)}),"");guardInterpolations=e=>{let t=0;const s=e.length,n=(s=0)=>e[t+s],r=()=>e[t++],i=e=>{let o=e;for(;t<s;){const a=r();if(o+=a,"\\"===a)o+=r();else{if(a===e)break;if("`"===e&&"$"===a&&"{"===n()){o+=r();let e=1;for(;t<s&&e;){const t=r();o+=t,"{"===t?e++:"}"===t?e--:"'"!==t&&'"'!==t&&"`"!==t||(o+=i(t).slice(1))}}}}return o},o=()=>{let e="",o=1;for(;t<s&&o;){const t=n();"'"!==t&&'"'!==t&&"`"!==t?(r(),"{"===t?o++:"}"===t&&o--,o&&(e+=t)):(r(),e+=i(t))}return`\${(()=>{try{return ${e}}catch{ return '' }})()}`};let a="";for(;t<s;){const e=n();"$"===e&&"{"===n(1)?(r(),r(),a+=o()):"'"===e||'"'===e||"`"===e?(r(),a+=i(e)):a+=r()}return a};makeSafeEvaluator(e){const t=e.trim(),s=/^\s*[\w.]+\s*=(?!=)/.test(t),n=new Function("ctx",`\n try {\n with (ctx) {\n ${s?`${t}; return "";`:`return (${t});`}\n }\n } catch {\n return "";\n }\n `);return e=>{try{const t=n(e);return null==t?"":t}catch{return""}}}async initBindings(){this._bindings=[];const e=new WeakSet;document.body.querySelectorAll("[pp-if]").forEach((t=>{if(e.has(t))return;const s=[];let n=t;for(;n;){if(n.hasAttribute("pp-if"))s.push({el:n,expr:n.getAttribute("pp-if")});else if(n.hasAttribute("pp-elseif"))s.push({el:n,expr:n.getAttribute("pp-elseif")});else{if(!n.hasAttribute("pp-else"))break;s.push({el:n,expr:null})}e.add(n),n=n.nextElementSibling}s.forEach((e=>{if(null!==e.expr){const t=e.expr.replace(/^{\s*|\s*}$/g,"");e.deps=this.extractDependencies(t);const s=this.makeSafeEvaluator(t);e.evaluate=()=>!!s(this.props)}}));const r=new Set;s.forEach((e=>e.deps?.forEach((e=>r.add(e)))));this._bindings.push({dependencies:r,update:()=>{let e=!1;for(const{el:t,expr:n,evaluate:r}of s)!e&&null!==n&&r()?(t.removeAttribute("hidden"),e=!0):e||null!==n?t.setAttribute("hidden",""):(t.removeAttribute("hidden"),e=!0)}})})),document.body.querySelectorAll("*").forEach((e=>{["pp-bind","pp-bind-expr"].forEach((t=>{const s=e.getAttribute(t);s&&this.registerBinding(e,s,"text")})),Array.from(e.attributes).forEach((t=>{if(!t.name.startsWith("pp-bind-"))return;if("pp-bind"===t.name||"pp-bind-expr"===t.name||"pp-bind-spread"===t.name)return;const s=t.value.replace(this._htmlEntitiesRe,(e=>"""===e?'"':"'"===e?"'":"&")).replace(/^{{\s*|\s*}}$/g,"");let n=t.name.replace(/^(pp-bind-)+/,"");const r="value"===n?"value":"checked"===n?"checked":"text";this.registerBinding(e,s,r,n)})),Array.from(e.attributes).forEach((t=>{if("pp-bind-spread"!==t.name)return;const s=t.value.split(",").map((e=>e.trim())).filter(Boolean),n=new Set;s.forEach((e=>n.add(e.split(".")[0])));const r=new Set;this._bindings.push({dependencies:n,update:()=>{try{const t={};s.forEach((e=>{const s=this.getNested(this.props,e)??{};Object.assign(t,s)})),r.forEach((s=>{s in t||e.hasAttribute(s)||(e.removeAttribute(s),r.delete(s))})),Object.entries(t).forEach((([t,s])=>{if(!r.has(t)&&e.hasAttribute(t))return;if(!1===s||null==s)return void(r.has(t)&&(e.removeAttribute(t),r.delete(t)));const n="object"==typeof s?JSON.stringify(s):String(s);e.getAttribute(t)!==n&&e.setAttribute(t,n),r.add(t)}))}catch(e){console.error("pp-spread error:",e)}}})}))}))}callInlineModule(e,...t){const s=this._inlineModuleFns.get(e);if(!s)throw new Error(`PPHP: no inline module named "${e}"`);return s(...t)}async processInlineModuleScripts(){this._inlineDepth++;try{const e=Array.from(document.body.querySelectorAll('script[type="text/php"]:not([src])')).filter((e=>{const t=e.getAttribute("pp-section-id")??e.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;return t?!this._processedPhpSections.has(t):!this._processedPhpScripts.has(e)}));if(0===e.length)return;const t={};for(const s of e){const e=s.getAttribute("pp-section-id")??s.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;if(!e)continue;const n=s.textContent||"";for(const[,s]of n.matchAll(/export\s+const\s+([A-Za-z_$]\w*)/g))t[s]=e}for(const s of e){const e=s.getAttribute("pp-section-id")??s.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;let n=(s.textContent||"").trim();{n=n.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"");const t=/\b(?:const|let|var)\s*(?:\[\s*([A-Za-z_$]\w*)\s*,\s*([A-Za-z_$]\w*)\s*\]|\[\s*([A-Za-z_$]\w*)\s*\]|([A-Za-z_$]\w*))\s*=\s*pphp\.state\s*\(\s*/g;let s,r="",i=0;const o=[];for(;s=t.exec(n);){const e=s[1],a=s[2],c=s[3],l=s[4],h=e??c??l;let p;e&&a&&o.push(a),r+=n.slice(i,s.index);const d=s[0];p=e&&a||c?d.replace(/\bpphp\.state\s*\(\s*$/,`pphp.state('${h}', `):`const [${h}] = pphp.state('${h}', `,r+=p;let u=1,f=t.lastIndex;for(;f<n.length&&u>0;){const e=n[f++];"("===e?u++:")"===e&&u--}r+=n.slice(t.lastIndex,f-1).trim()+")",i=f,t.lastIndex=f}if(r+=n.slice(i),o.length){r+="\n\n";for(const t of o){r+=`pphp._inlineModuleFns.set('${e?`${e}_${t}`:t}', ${t});\n`}}n=r}e&&(n=n.replace(/(\bpphp\.state\(\s*['"])([^'"]+)(['"])/g,((t,s,n,r)=>s+(n.startsWith(`${e}_`)?n:`${e}_${n}`)+r))),n=n.replace(/\b([A-Za-z_$]\w*)\s*\(/g,((e,s)=>{const n=t[s];return n?`${n}_${s}(`:e}));const r=new Blob([n],{type:"application/javascript"}),i=URL.createObjectURL(r),o=PPHP.prototype._currentSectionId;e&&(PPHP.prototype._currentSectionId=()=>e);try{const t=await import(i);for(const[s,n]of Object.entries(t))if("function"==typeof n){const t=e?`${e}_${s}`:s;this._inlineModuleFns.set(t,n)}}catch(e){console.error("Inline module import failed:",e)}finally{PPHP.prototype._currentSectionId=o,URL.revokeObjectURL(i),e?this._processedPhpSections.add(e):this._processedPhpScripts.add(s)}}}finally{this._inlineDepth--,0===this._inlineDepth&&requestAnimationFrame((()=>{this._pendingEffects.forEach((e=>{try{e()}catch(e){console.error("effect error:",e)}this._effects.add(e)})),this._pendingEffects.clear()}))}}flushBindings(){const e=new Set;this._pendingBindings.forEach((t=>{t.dependencies.forEach((t=>e.add(t))),t.update()})),this._pendingBindings.clear(),this._updateScheduled=!1,this._effects.forEach((t=>{if(t.__static)return;const s=t.__deps||new Set,n=this._activeSection;if(this._activeSection=t.__sectionId??null,0===s.size||[...s].some((t=>e.has(t))))try{t()}catch(e){console.error("effect error:",e)}this._activeSection=n}))}scheduleFlush(){this._updateScheduled||(this._updateScheduled=!0,requestAnimationFrame((()=>{this._updateScheduled=!1,this.flushBindings()})))}scopeKey(e){const t=this._currentSectionId();return t?e.startsWith(`${t}_`)?e:e.includes(".")?e.replace(/^([^\.]+)/,`${t}_$1`):`${t}_${e}`:e}_currentSectionId(){const e=document.currentScript;return e?.closest("[pp-section-id]")?.getAttribute("pp-section-id")||null}getNested(e,t){return t.split(".").reduce(((e,t)=>e?e[t]:void 0),e)}setNested(e,t,s){const n=t.split("."),r=n.pop();n.reduce(((e,t)=>e[t]??={}),e)[r]=s}hasNested(e,t){return void 0!==this.getNested(e,t)}state(e,t){if("string"!=typeof e||""===e.trim())throw new Error("PPHP.state: missing or invalid key—make sure your build-time injector ran and you wrote `const [foo, setFoo] = pphp.state(0)` so it became `pphp.state('foo', 0)`.");arguments.length<2&&(t=void 0);const s=this._currentSectionId(),n=e;if(this._reservedWords.has(n))throw new Error(`'${n}' is reserved – choose another state key.`);const r=this.scopeKey(n);this._declaredStateRoots.add(r),s&&(this._scopedKeys.has(s)||this._scopedKeys.set(s,new Set),this._scopedKeys.get(s).add(n)),this.hasNested(pphp.props,r)||this.setNested(pphp.props,r,t);const i=()=>this.getNested(pphp.props,r),o=e=>{const t=i(),s="function"==typeof e?e(t):e;this.setNested(pphp.props,r,s),this.scheduleFlush()},a=()=>i();Object.defineProperty(a,"value",{get:()=>i(),set:e=>o(e)}),Object.defineProperties(a,{valueOf:{value:()=>i()},toString:{value:()=>String(i())}}),a.__pphp_key=r;const c=i();if(!(null!==c&&"object"==typeof c))return[a,o];return[new Proxy(a,{apply:(e,t,s)=>Reflect.apply(e,t,s),get(e,t,s){if("value"===t)return i();if(t in e)return Reflect.get(e,t,s);return i()[t]},set(e,t,s){if("value"===t)return o(s),!0;return i()[t]=s,!0},has(e,t){if("value"===t||t in a)return!0;return t in i()}}),o]}static _isBuiltIn=(()=>{const e=new Map,t=[Object.prototype,Function.prototype,Array.prototype,String.prototype,Number.prototype,Boolean.prototype,Date.prototype,RegExp.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,Error.prototype,Promise.prototype];return s=>{const n=e.get(s);if(void 0!==n)return n;const r=s in globalThis||t.some((e=>s in e));return e.set(s,r),r}})();extractDependencies(e){let t=e.replace(/\?\./g,".");const s=new Set,n=/(?:^|[^\w$])(?:\(\s*([^)]*?)\s*\)|([A-Za-z_$][\w$]*))\s*=>/g;for(let e;e=n.exec(t);){(e[1]??e[2]??"").split(",").map((e=>e.trim())).filter(Boolean).forEach((e=>s.add(e)))}const r=/function\s*(?:[A-Za-z_$][\w$]*\s*)?\(\s*([^)]*?)\s*\)/g;for(let e;e=r.exec(t);)e[1].split(",").map((e=>e.trim())).filter(Boolean).forEach((e=>s.add(e)));const i=e=>{let t="",s=0;for(;s<e.length;)if("`"===e[s])for(s++;s<e.length;)if("\\"===e[s])s+=2;else if("$"===e[s]&&"{"===e[s+1]){s+=2;let n=1;const r=s;for(;s<e.length&&n>0;)"{"===e[s]?n++:"}"===e[s]&&n--,s++;const o=e.slice(r,s-1);t+=i(o)+" "}else{if("`"===e[s]){s++;break}s++}else t+=e[s++];return t};t=i(t),t=t.replace(/(['"])(?:\\.|[^\\])*?\1/g,""),t=t.replace(/\/(?:\\.|[^\/\\])+\/[gimsuy]*/g,"");const o=new Set,a=/\b[A-Za-z_$]\w*(?:\.[A-Za-z_$]\w*)*\b/g;for(const n of t.match(a)??[]){const[t,...r]=n.split(".");s.has(t)||(0===r.length&&PPHP._isBuiltIn(t)&&new RegExp(`\\.${t}\\b`).test(e)||o.add(n))}return o}async initializeAllReferencedProps(){const e=PPHP._mustachePattern,t=PPHP._mustacheTest,s=this.props,n=new Set,r=(e,t)=>{const s=e.getAttribute("pp-section-id"),n=e.parentElement?.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;return s??n?`${s??n}_${t}`:t},i=(()=>{const e=new Set([...Object.getOwnPropertyNames(String.prototype),...Object.getOwnPropertyNames(Array.prototype),...Object.getOwnPropertyNames(Number.prototype),...Object.getOwnPropertyNames(Boolean.prototype),...Object.getOwnPropertyNames(Object.prototype),...Object.getOwnPropertyNames(Date.prototype),...Object.getOwnPropertyNames(RegExp.prototype)]);return t=>e.has(t)})(),o=(e,t)=>{const[s,o,...a]=t.split(".");if(this._reservedWords.has(s))return void console.warn(`Invalid path “${t}” – “${s}” is a reserved word.`);if(PPHP._isBuiltIn(s)&&console.warn(`Path “${t}” shadows the built-in “${s}”. It will be stored in pphp.props.`),o&&i(o))return void n.add(r(e,s));const c=r(e,s);n.add(o?`${c}.${[o,...a].join(".")}`:c)};for(const s of document.body.getElementsByTagName("*"))for(const{name:n,value:r}of Array.from(s.attributes))if(r){if(t.test(r))for(const t of r.matchAll(e))this.extractDependencies(t[1]).forEach((e=>o(s,e)));"pp-if"!==n&&"pp-elseif"!==n||this.extractDependencies(r).forEach((e=>o(s,e))),n.startsWith("pp-bind")&&this.extractDependencies(r).forEach((e=>o(s,e)))}const a=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:e=>t.test(e.nodeValue??"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT});for(let t;t=a.nextNode();){const s=t.parentElement;for(const n of t.nodeValue.matchAll(e))this.extractDependencies(n[1]).forEach((e=>o(s,e)))}const c=Array.from(n).sort(((e,t)=>t.split(".").length-e.split(".").length));for(const e of c){const t=e.split(".");let n=s;for(let e=0;e<t.length;e++){const s=t[e],r=e===t.length-1;0===e&&PPHP._isBuiltIn(s)&&console.warn(`Root “${s}” shadows the built-in. The placeholder will still be created in pphp.props.`),s in n&&(r||null!=n[s]&&"object"==typeof n[s])||(n[s]=r?void 0:{}),n=n[s]}}}setNestedProperty(e,t,s){const n=t.split(".");let r=e;for(let e=0;e<n.length-1;e++)n[e]in r||(r[n[e]]={}),r=r[n[e]];r[n[n.length-1]]=s}handlePopState(){window.addEventListener("popstate",(async()=>{await this.handleNavigation()}))}alreadyScoped(e,t){const s=`${t}_${e}`;return this._scopedKeys.get(t)?.has(s)??!1}prefixFunctionCalls(e,t){return e.replace(/\b([A-Za-z_$][\w$]*)\s*\(/g,((e,s)=>this._reservedWords.has(s)||s.startsWith(`${t}_`)?e:this.alreadyScoped(s,t)?`${t}_${s}(`:e))}prefixIds(e,t){let s="",n=0,r=(e=this.prefixFunctionCalls(e,t)).length,i=!1,o=!1,a=!1;for(;n<r;){const c=e[n];if("'"!==c||o||a||"\\"===e[n-1])if('"'!==c||i||a||"\\"===e[n-1])if("`"!==c||i||o||"\\"===e[n-1])if(i||o||a)s+=c,n++;else if(/[A-Za-z_$]/.test(c)){let i=n+1;for(;i<r&&/[\w$]/.test(e[i]);)i++;const o=e.slice(n,i),a=e[n-1]??"",c=this._reservedWords.has(o),l="."===a;s+=!o.startsWith(`${t}_`)&&!l&&!c?`${t}_${o}`:o,n=i}else s+=c,n++;else a=!a,s+=c,n++;else o=!o,s+=c,n++;else i=!i,s+=c,n++}return s}attachWireFunctionEvents(){this.handleHiddenAttribute(),this.handleAnchorTag();const e=Array.from(this._eventHandlers).map((e=>`[${e}]`)).join(", "),t=document.body.querySelectorAll(e),s=/^[^(]*(\([\w\s,]*\)|[A-Za-z_$][\w$]*)\s*=>/;t.forEach((e=>{const t=e.closest("[pp-section-id]")?.getAttribute("pp-section-id");if(Array.from(e.attributes).filter((e=>this._eventHandlers.has(e.name))).forEach((n=>{const r=n.name.slice(2);e.removeAllEventListeners(r);const i=n.value.trim();let o;if(s.test(i)||console.warn(`PPHP: Inline handler on [${n.name}] should use arrow syntax, e.g. onclick="() => { … }" or onclick="e => …".`,{element:e,handler:i}),o=s.test(i)?i:`() => { ${i} }`,t){const e=o.indexOf("=>");if(-1!==e){const s=o.slice(0,e+2),n=o.slice(e+2);o=s+this.prefixIds(n,t)}}e instanceof HTMLInputElement&&this.handleInputAppendParams(e,r),e.removeAttribute(n.name),this.handleDebounce(e,r,o)})),e instanceof HTMLFormElement){const n=e.getAttribute("onsubmit")?.trim();if(n){let r;if(s.test(n)||console.warn('PPHP: Inline handler on [onsubmit] should use arrow syntax, e.g. onsubmit="() => { … }" or onsubmit="e => …".'),r=s.test(n)?n:`() => { ${n} }`,t){const e=r.indexOf("=>");if(-1!==e){const s=r.slice(0,e+2),n=r.slice(e+2);r=s+this.prefixIds(n,t)}}e.removeAttribute("onsubmit"),this.handleDebounce(e,"submit",r)}}})),this.handlePassiveWheelStashes(document)}async handleDebounce(e,t,s){const n=e.getAttribute("pp-debounce"),r=n?this.parseTime(n):0,i=e.getAttribute("pp-before-request")??"",o=e.getAttribute("pp-after-request")??"",a=PPHP._cancelableEvents,c=async n=>{a.has(t)&&n.cancelable&&n.preventDefault();try{i&&await this.invokeHandler(e,i,n),await this.invokeHandler(e,s,n),o&&"@close"!==o&&await this.invokeHandler(e,o,n),this.handlerAutofocusAttribute()}catch(e){console.error("Error in debounced handler:",e)}},l={passive:PPHP._passiveEvents.has(t)&&!a.has(t)},h=`${t}::${e.__pphpId||e.tagName}`,p=e=>{if(r>0){const t=PPHP.debounceTimers.get(h);t&&clearTimeout(t);const s=setTimeout((()=>{PPHP.debounceTimers.delete(h),c(e)}),r);PPHP.debounceTimers.set(h,s)}else c(e)};e instanceof HTMLFormElement&&"submit"===t?e.addEventListener("submit",(e=>{e.cancelable&&e.preventDefault(),p(e)}),l):e.addEventListener(t,p,l)}debounce(e,t=300,s=!1){let n;return function(...r){const i=this;n&&clearTimeout(n),n=setTimeout((()=>{n=null,s||e.apply(i,r)}),t),s&&!n&&e.apply(i,r)}}handlerAutofocusAttribute(){const e=document.querySelector("dialog[open]");let t=null;if(e&&(t=e.querySelector("[pp-autofocus]")),t||(t=document.querySelector("[pp-autofocus]")),!t)return;const s=t.getAttribute("pp-autofocus");if(!this.isJsonLike(s))return;const n=this.parseJson(s);requestAnimationFrame((()=>{t.focus(),(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&"function"==typeof this.setCursorPosition&&(t instanceof HTMLInputElement&&"number"===t.type?(t.type="text",this.setCursorPosition(t,n),t.type="number"):this.setCursorPosition(t,n))}))}async invokeHandler(e,t,s){this._activeSection=e.closest("[pp-section-id]")?.getAttribute("pp-section-id")??null;{const e=t.trim().match(/^\s*\(\s*\)\s*=>\s*([A-Za-z_$][\w$]*\s*\([^)]*\))\s*$/);e&&(t=e[1].trim())}try{const n=t.trim(),r=/^\(?\s*[^=]*?\)?\s*=>/.test(n.replace(/(["'`])(?:\\.|(?!\1).)*\1/g,"").replace(/\/(?:\\.|[^\/])+\/[gimsuy]*/g,"").trim()),i=()=>{const e=this.getProxiedProps(pphp.props),t=this._inlineModuleFns;return new Proxy(e,{get(e,s,n){if("string"==typeof s){if(t.has(s))return t.get(s);if(s in e)return Reflect.get(e,s,n);if(s in globalThis){const e=globalThis[s];return"function"==typeof e?e.bind(globalThis):e}}return Reflect.get(e,s,n)},set:(e,t,s,n)=>Reflect.set(e,t,s,n),has:(e,s)=>"string"==typeof s&&t.has(s)||s in e||s in globalThis})};if(r){const t=new Function("event","proxy","props",`\n with (proxy) {\n const out = (${n});\n return (typeof out === 'function')\n ? out.call(this, event, props)\n : out;\n }`);return void await t.call(e,s,i(),pphp.props)}const o=n.match(/^(\w+(?:\.\w+)*)\(([\s\S]*)\)$/);if(o){const t=o[1],r=o[2].trim();if(this._inlineModuleFns.has(t)){if(r)if(this.isJsonLike(r)){const n=this.parseJson(r)??{};await this.callInlineModule(t,{...n,element:e,event:s})}else{const e=this.makeSafeEvaluator(r)(pphp.props);await this.callInlineModule(t,e)}else await this.handleParsedCallback(e,n,s);return}if(t in globalThis&&"function"==typeof globalThis[t]){return void new Function("event","proxy","props",`with (proxy) { ${n}; }`).call(e,s,i(),pphp.props)}const{context:a,methodName:c}=this.resolveContext(t.split("."));if("function"==typeof a[c]){if(this.isJsonLike(r)){const t=this.parseJson(r)??{};await a[c].call(a,{...t,element:e,event:s})}else new Function("event",n).call(e,s);return}return void await this.handleParsedCallback(e,n,s)}await this.handleParsedCallback(e,n,s)}catch(e){console.error(`Error executing handler "${t}". Please ensure the handler is valid.`,e)}finally{this.scheduleFlush()}}async handleParsedCallback(e,t,s){const{funcName:n,data:r}=this.parseCallback(e,t);if(!n)return;const i=Array.isArray(n)?n:[n];let o;for(const e of i){const t=this._inlineModuleFns.get(e);if("function"==typeof t){o=t;break}const s=this[e];if("function"==typeof s){o=s;break}const n=window[e];if("function"==typeof n){o=n;break}}if(o){const t=e.hasAttribute("pp-after-request"),n=Array.isArray(r.args)?r.args:[],i=this._responseData?this.parseJson(this._responseData):{response:this._responseData};let a={args:n,element:e,data:r,event:s};return t&&(a={...a,...i}),void await o.call(this,a)}this._responseData=null,this._responseData=await this.handleUndefinedFunction(e,Array.isArray(n)?n[0]:n,r)}async handleUndefinedFunction(e,t,s){const n={callback:t,...s},r=this.createFetchOptions(n),i=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()});try{this.saveElementOriginalState(e),this.handleSuspenseElement(e);const n=new URL(window.location.href);let o="",a="",c={success:!1};const l=e.querySelector("input[type='file']");if(l){if(o=await this.fetchFileWithData(n.href,t,l,s),a=this.extractJson(o)||"",a)try{c=this.parseJson(a)}catch(e){console.error("Error parsing JSON response. Please ensure the response is in valid JSON format.",e)}}else{const e=await this.fetch(n.href,r);if(o=await e.text(),this.getRedirectUrl(o))return void await this.redirect(this.getRedirectUrl(o)||"");if(a=this.extractJson(o)||"",a)try{c=this.parseJson(a)}catch(e){console.error("Error parsing JSON response. Please ensure the response is in valid JSON format.",e)}}const h=e.getAttribute("pp-before-request")||"",p=e.getAttribute("pp-after-request")||"";if((h||p&&c.success)&&this.restoreSuspenseElement(e),h||p){let e="";if(c.success){e=o.replace(a,"")}else e=o;if(this.appendAfterbegin(e),!p&&!c.success)return}if(p&&c.success){this.handleAfterRequest(p,a);const e=o.replace(a,"");return this.appendAfterbegin(e),a}if("@close"===p)return c.success?a:void 0;const d=await this.fetch(n.href,i),u=await d.text();if(this.getRedirectUrl(u))return void await this.redirect(this.getRedirectUrl(u)||"");await this.handleResponseRedirectOrUpdate(o,u,a,c)}catch(e){console.error(`Error handling undefined function "${t}". Please ensure the function is defined and accessible.`,e)}}handleAfterRequest(e,t){if(!this.isJsonLike(e))return;const s=this.parseJson(e),n=t?this.parseJson(t):null,r=s.targets;Array.isArray(r)&&r.forEach((e=>{const{id:t,...s}=e,r=document.querySelector(t);let i={};if(n){for(const t in s)if(s.hasOwnProperty(t))switch(t){case"innerHTML":case"outerHTML":case"textContent":case"innerText":"response"===s[t]&&(i[t]=e.responseKey?n[e.responseKey]:n.response);break;default:i[t]=s[t]}}else i=s;r&&this.updateElementAttributes(r,i)}))}sanitizePassiveHandlers(e){return e.replace(/\s+onwheel\s*=\s*(['"])([\s\S]*?)\1/gi,((e,t,s)=>` data-onwheel-code="${encodeURIComponent(s)}"`)).replace(/\s+onmousewheel\s*=\s*(['"])[\s\S]*?\1/gi,"")}handlePassiveWheelStashes(e){(e instanceof Document?e.body:e).querySelectorAll("[data-onwheel-code]").forEach((e=>{let t=decodeURIComponent(e.dataset.onwheelCode||"").trim();delete e.dataset.onwheelCode,e.onwheel=null;const s=e.closest("[pp-section-id]")?.getAttribute("pp-section-id");if(s){const e=t.indexOf("=>");if(e>=0){const n=t.slice(0,e+2),r=t.slice(e+2);t=n+this.prefixIds(r,s)}else t=this.prefixIds(t,s)}e.removeAllEventListeners("wheel"),this.handleDebounce(e,"wheel",t)}))}async handleResponseRedirectOrUpdate(e,t,s,n){const r=this.sanitizePassiveHandlers(t),i=this.getUpdatedHTMLContent(e,s,n),o=(new DOMParser).parseFromString(r,"text/html");i&&o.body.insertAdjacentElement("afterbegin",i),this.updateBodyContent(o.body.outerHTML)}getUpdatedHTMLContent(e,t,s){const n=document.createElement("div");if(n.id="afterbegin-8D95D",s&&t?.success){const t=e.replace(s,"");n.innerHTML=t}else n.innerHTML=e;return n.innerHTML?n:null}async updateBodyContent(e){const t=this.saveScrollPositions();this.saveElementState();const s=(new DOMParser).parseFromString(e,"text/html");await this.appendCallbackResponse(s),this.restoreElementState(),this.restoreScrollPositions(t),await this.processInlineModuleScripts(),await this.initMakeReactive()}restoreElementState(){if(this._elementState.focusId){const e=document.getElementById(this._elementState.focusId)||document.querySelector(`[name="${this._elementState.focusId}"]`);if(e instanceof HTMLInputElement){const t=e.value.length||0;void 0!==this._elementState.focusSelectionStart&&null!==this._elementState.focusSelectionEnd&&e.setSelectionRange(t,t),this._elementState.focusValue&&("checkbox"===e.type||"radio"===e.type?e.checked=!!this._elementState.focusChecked:"number"===e.type||"email"===e.type?(e.type="text",e.setSelectionRange(t,t),e.type="number"===e.type?"number":"email"):"date"===e.type||"month"===e.type||"week"===e.type||"time"===e.type||"datetime-local"===e.type||"color"===e.type||"file"===e.type||""!==e.value&&(e.value=this._elementState.focusValue)),e.focus()}else if(e instanceof HTMLTextAreaElement){const t=e.value.length||0;void 0!==this._elementState.focusSelectionStart&&null!==this._elementState.focusSelectionEnd&&e.setSelectionRange(t,t),this._elementState.focusValue&&""!==e.value&&(e.value=this._elementState.focusValue),e.focus()}else e instanceof HTMLSelectElement&&(this._elementState.focusValue&&""!==e.value&&(e.value=this._elementState.focusValue),e.focus())}this._elementState.checkedElements.forEach((e=>{const t=document.getElementById(e);t&&(t.checked=!0)}))}async appendCallbackResponse(e){const t=e.getElementById("afterbegin-8D95D");if(t){const e=document.getElementById("afterbegin-8D95D");e?e.innerHTML=t.innerHTML:document.body.insertAdjacentHTML("afterbegin",t.outerHTML)}await this.populateDocumentBody(e)}saveElementState(){const e=document.activeElement;this._elementState.focusId=e?.id||e?.name,this._elementState.focusValue=e?.value,this._elementState.focusChecked=e?.checked,this._elementState.focusType=e?.type,this._elementState.focusSelectionStart=e?.selectionStart,this._elementState.focusSelectionEnd=e?.selectionEnd,this._elementState.isSuspense=e.hasAttribute("pp-suspense"),this._elementState.checkedElements.clear(),document.querySelectorAll('input[type="checkbox"]:checked').forEach((e=>{this._elementState.checkedElements.add(e.id||e.name)})),document.querySelectorAll('input[type="radio"]:checked').forEach((e=>{this._elementState.checkedElements.add(e.id||e.name)}))}updateElementAttributes(e,t){for(const s in t)if(t.hasOwnProperty(s))switch(s){case"innerHTML":case"outerHTML":case"textContent":case"innerText":e[s]=this.decodeHTML(t[s]);break;case"insertAdjacentHTML":e.insertAdjacentHTML(t.position||"beforeend",this.decodeHTML(t[s].html));break;case"insertAdjacentText":e.insertAdjacentText(t.position||"beforeend",this.decodeHTML(t[s].text));break;case"setAttribute":e.setAttribute(t.attrName,this.decodeHTML(t[s]));break;case"removeAttribute":e.removeAttribute(t[s]);break;case"className":e.className=this.decodeHTML(t[s]);break;case"classList.add":e.classList.add(...this.decodeHTML(t[s]).split(","));break;case"classList.remove":e.classList.remove(...this.decodeHTML(t[s]).split(","));break;case"classList.toggle":e.classList.toggle(this.decodeHTML(t[s]));break;case"classList.replace":const[n,r]=this.decodeHTML(t[s]).split(",");e.classList.replace(n,r);break;case"dataset":e.dataset[t.attrName]=this.decodeHTML(t[s]);break;case"style":Object.assign(e.style,t[s]);break;case"value":e.value=this.decodeHTML(t[s]);break;case"checked":e.checked=t[s];break;default:e.setAttribute(s,this.decodeHTML(t[s]))}}decodeHTML(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}appendAfterbegin(e){if(!e)return;const t="afterbegin-8D95D";let s=document.getElementById(t);s?(s.innerHTML=e,document.body.insertAdjacentElement("afterbegin",s)):(s=document.createElement("div"),s.id=t,s.innerHTML=e,document.body.insertAdjacentElement("afterbegin",s))}restoreSuspenseElement(e){const t=e.getAttribute("pp-original-state");if(e.hasAttribute("pp-suspense")&&t){const s=(e,t)=>{for(const s in t)t.hasOwnProperty(s)&&("textContent"===s?e.textContent=t[s]:"innerHTML"===s?e.innerHTML=t[s]:"disabled"===s?!0===t[s]?e.setAttribute("disabled","true"):e.removeAttribute("disabled"):e.setAttribute(s,t[s]));for(const s of Array.from(e.attributes))t.hasOwnProperty(s.name)||e.removeAttribute(s.name)},n=(e,t)=>{for(const n in t)if(t.hasOwnProperty(n))for(const t of Array.from(e.elements))if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-original-state")||"";if(e){if(this.isJsonLike(e)){const n=this.parseJson(e);s(t,n)}else r(t,e);t.removeAttribute("pp-original-state")}}},r=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},i=(e,t)=>{e instanceof HTMLFormElement?n(e,t):s(e,t)};try{const r=this.parseJson(t);if(r)if(e instanceof HTMLFormElement){const t=e.id;if(t){const e=document.querySelector(`[form="${t}"]`);if(e){const t=e.getAttribute("pp-original-state");if(t&&this.isJsonLike(t)){const n=this.parseJson(t);s(e,n)}}}const r=new FormData(e),i={};if(r.forEach(((e,t)=>{i[t]=e})),n(e,i),e.hasAttribute("pp-suspense")){const t=e.getAttribute("pp-suspense")||"";if(this.parseJson(t).disabled)for(const t of Array.from(e.elements))(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("disabled")}}else if(r.targets){r.targets.forEach((e=>{const{id:t,...s}=e,n=document.querySelector(t);n&&i(n,s)}));const{targets:t,...n}=r;s(e,n)}else{const{empty:t,...n}=r;s(e,n)}}catch(e){console.error(`Error parsing JSON: ${e instanceof Error?e.message:"Unknown error"}. Please ensure the JSON string is valid.`,e)}}e.querySelectorAll("[pp-suspense]").forEach((e=>this.restoreSuspenseElement(e))),e.removeAttribute("pp-original-state")}extractJson(e){const t=e?.match(/\{[\s\S]*\}/);return t?t[0]:null}getRedirectUrl(e){const t=e.match(this._redirectRegex);return t?t[1]:null}async fetchFileWithData(e,t,s,n={}){const r=new FormData,i=s.files;if(i)for(let e=0;e<i.length;e++)r.append("file[]",i[e]);r.append("callback",t);for(const e in n)n.hasOwnProperty(e)&&r.append(e,n[e]);const o=await this.fetch(e,{method:"POST",headers:{HTTP_PPHP_WIRE_REQUEST:"true"},body:r});return await o.text()}async handleSuspenseElement(e){let t=e.getAttribute("pp-suspense")||"";const s=(e,t)=>{for(const s in t)if(t.hasOwnProperty(s))for(const t of e.elements)if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-suspense")||"";if(e)if(this.isJsonLike(e)){const s=this.parseJson(e);"disabled"!==s.onsubmit&&this.updateElementAttributes(t,s),s.targets&&s.targets.forEach((e=>{const{id:t,...s}=e,n=document.querySelector(t);n&&r(n,s)}))}else n(t,e)}},n=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},r=(e,t)=>{e instanceof HTMLFormElement?s(e,t):this.updateElementAttributes(e,t)};try{if(t&&this.isJsonLike(t)){const n=this.parseJson(t);if(n)if(e instanceof HTMLFormElement){const t=new FormData(e),r={};t.forEach(((e,t)=>{r[t]=e})),n.disabled&&this.toggleFormElements(e,!0);const{disabled:i,...o}=n;this.updateElementAttributes(e,o),s(e,r)}else if(n.targets){n.targets.forEach((e=>{const{id:t,...s}=e,n=document.querySelector(t);n&&r(n,s)}));const{targets:t,...s}=n;this.updateElementAttributes(e,s)}else{if("disabled"===n.empty&&""===e.value)return;const{empty:t,...s}=n;this.updateElementAttributes(e,s)}}else if(t)n(e,t);else if(e instanceof HTMLFormElement){const t=new FormData(e),n={};t.forEach(((e,t)=>{n[t]=e})),s(e,n)}}catch(e){console.error(`Error parsing JSON: ${e instanceof Error?e.message:"Unknown error"}. Please ensure the JSON string is valid.`,e)}}toggleFormElements(e,t){Array.from(e.elements).forEach((e=>{(e instanceof HTMLInputElement||e instanceof HTMLButtonElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(e.disabled=t)}))}saveElementOriginalState(e){if(e.hasAttribute("pp-suspense")&&!e.hasAttribute("pp-original-state")){const t={};e.textContent&&(t.textContent=e.textContent.trim()),e.innerHTML&&(t.innerHTML=e.innerHTML.trim()),(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(t.value=e.value);for(let s=0;s<e.attributes.length;s++){const n=e.attributes[s];t[n.name]=n.value}e.setAttribute("pp-original-state",JSON.stringify(t))}if(e instanceof HTMLFormElement){let t=null;const s=e.id;s&&(t=document.querySelector(`[form="${s}"]`)),s&&t||(t=Array.from(e.elements).find((e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement))),t?t.hasAttribute("pp-original-state")||this.saveElementOriginalState(t):console.warn("Warning: No invoker detected for the form. Ensure the form has an associated invoker or an ID for proper handling.")}e.querySelectorAll("[pp-suspense]").forEach((e=>this.saveElementOriginalState(e)))}getUrlParams(){const e={};return new URLSearchParams(window.location.search).forEach(((t,s)=>{e[s]=t})),e}createFetchOptions(e){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PPHP_WIRE_REQUEST:"true"},body:JSON.stringify(e)}}parseCallback(e,t){let s={};const n=e.closest("form");if(n){new FormData(n).forEach(((e,t)=>{s[t]?Array.isArray(s[t])?s[t].push(e):s[t]=[s[t],e]:s[t]=e}))}else e instanceof HTMLInputElement?s=this.handleInputElement(e):(e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(s[e.name]=e.value);const r=t.match(/(\w+)\((.*)\)/);if(r){const e=r[1];let t=r[2].trim();if(t.startsWith("{")&&t.endsWith("}"))try{const e=this.parseJson(t);"object"==typeof e&&null!==e&&(s={...s,...e})}catch(e){console.error(`Error parsing JSON: ${e instanceof Error?e.message:"Unknown error"}. Please ensure the JSON string is valid.`,e)}else{const e=t.split(/,(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/).map((e=>e.trim().replace(/^['"]|['"]$/g,"")));s.args=e}return{funcName:e,data:s}}return{funcName:t,data:s}}handleInputElement(e){let t={};if(e.name)if("checkbox"===e.type)t[e.name]={value:e.value,checked:e.checked};else if("radio"===e.type){const s=document.querySelector(`input[name="${e.name}"]:checked`);t[e.name]=s?s.value:null}else t[e.name]=e.value;else"checkbox"===e.type||"radio"===e.type?t.value=e.checked:t.value=e.value;return t}resolveContext(e){let t=this._inlineModuleFns;for(let s=0;s<e.length-1;s++){const n=e[s];if(t instanceof Map)if(t.has(n))t=t.get(n);else{if(!window[n])throw new Error(`Cannot find object "${n}" in inline modules or window context.`);t=window[n]}else if(t=t[n],!t)throw new Error(`Cannot find object "${n}" in the context.`)}return{context:t,methodName:e[e.length-1]}}setCursorPosition(e,t){if(t.start)e.setSelectionRange(0,0);else if(t.end){const t=e.value.length||0;e.setSelectionRange(t,t)}else if(t.length){const s=parseInt(t.length,10)||0;e.setSelectionRange(s,s)}}handleInputAppendParams(e,t){const s=e.getAttribute("pp-append-params"),n=e.getAttribute("pp-append-params-sync");if("true"===s){if("true"===n){const t=e.name||e.id;if(t){const s=new URL(window.location.href),n=new URLSearchParams(s.search);n.has(t)&&(e.value=n.get(t)||"")}}e.addEventListener(t,(e=>{const t=e.currentTarget,s=t.value,n=new URL(window.location.href),r=new URLSearchParams(n.search),i=t.name||t.id;if(i){s?r.set(i,s):r.delete(i);const e=r.toString()?`${n.pathname}?${r.toString()}`:n.pathname;history.replaceState(null,"",e)}}))}}handleHiddenAttribute(){const e=document.querySelectorAll("[pp-visibility]"),t=document.querySelectorAll("[pp-display]"),s=this.handleElementVisibility.bind(this),n=this.handleElementDisplay.bind(this);e.forEach((e=>this.handleVisibilityElementAttribute(e,"pp-visibility",s))),t.forEach((e=>this.handleVisibilityElementAttribute(e,"pp-display",n)))}handleVisibilityElementAttribute(e,t,s){const n=e.getAttribute(t);if(n)if(this.isJsonLike(n)){s(e,this.parseJson(n))}else{const s=this.parseTime(n);if(s>0){const n="pp-visibility"===t?"visibility":"display",r="visibility"===n?"hidden":"none";this.scheduleChange(e,s,n,r)}}}handleElementVisibility(e,t){this.handleElementChange(e,t,"visibility","hidden","visible")}handleElementDisplay(e,t){this.handleElementChange(e,t,"display","none","block")}handleElementChange(e,t,s,n,r){const i=t.start?this.parseTime(t.start):0,o=t.end?this.parseTime(t.end):0;i>0?(e.style[s]=n,this.scheduleChange(e,i,s,r),o>0&&this.scheduleChange(e,i+o,s,n)):o>0&&this.scheduleChange(e,o,s,n)}handleAnchorTag(){document.querySelectorAll("a").forEach((e=>{e.addEventListener("click",(async e=>{const t=e.currentTarget,s=t.getAttribute("href"),n=t.getAttribute("target");if(s&&"_blank"!==n&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),!this._isNavigating)){this._isNavigating=!0;try{if(/^(https?:)?\/\//i.test(s)&&!s.startsWith(window.location.origin))window.location.href=s;else{const e=t.getAttribute("pp-append-params");if(s.startsWith("?")&&"true"===e){const e=new URL(window.location.href),t=new URLSearchParams(e.search);let n="";const[r,i]=s.split("#");i&&(n=`#${i}`);new URLSearchParams(r.split("?")[1]).forEach(((e,s)=>{t.set(s,e)}));const o=`${e.pathname}?${t.toString()}${n}`;history.pushState(null,"",o)}else{const[e,t]=s.split("#"),n=`${e}${t?`#${t}`:""}`;history.pushState(null,"",n)}const n=s.indexOf("#");if(-1!==n){const e=s.slice(n+1),t=document.getElementById(e);if(t)t.scrollIntoView({behavior:"smooth"});else{await this.handleNavigation();const t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth"})}}else await this.handleNavigation()}}catch(e){console.error("Anchor click error:",e)}finally{this._isNavigating=!1}}}))}))}async handleNavigation(){try{const e=document.getElementById("loading-file-1B87E");if(e){const t=this.findLoadingElement(e,window.location.pathname);t&&await this.updateContentWithTransition(t)}const t=await this.fetch(window.location.href);if(!t.ok)return void console.error(`Navigation error: ${t.status} ${t.statusText}`);const s=await t.text(),n=s.match(this._redirectRegex);if(n&&n[1])return void await this.redirect(n[1]);await this.updateDocumentContent(s)}catch(e){console.error("Navigation error:",e)}}findLoadingElement(e,t){let s=t;for(;;){const t=e.querySelector(`div[pp-loading-url='${s}']`);if(t)return t;if("/"===s)break;const n=s.lastIndexOf("/");s=n<=0?"/":s.substring(0,n)}return e.querySelector("div[pp-loading-url='/' ]")}async updateContentWithTransition(e){const t=document.querySelector("[pp-loading-content='true']")||document.body;if(!t)return;const{fadeIn:s,fadeOut:n}=this.parseTransition(e);await this.fadeOut(t,n),t.innerHTML=e.innerHTML,this.fadeIn(t,s)}parseTransition(e){let t=250,s=250;const n=e.querySelector("[pp-loading-transition]"),r=n?.getAttribute("pp-loading-transition");if(r){const e=this.parseJson(r);e&&"object"==typeof e?(t=this.parseTime(e.fadeIn??t),s=this.parseTime(e.fadeOut??s)):console.warn("pp-loading-transition is not valid JSON → default values (250 ms) will be used. String:",r)}return{fadeIn:t,fadeOut:s}}fadeOut(e,t){return new Promise((s=>{e.style.transition=`opacity ${t}ms ease-out`,e.style.opacity="0",setTimeout((()=>{e.style.transition="",s()}),t)}))}fadeIn(e,t){e.style.transition=`opacity ${t}ms ease-in`,e.style.opacity="1",setTimeout((()=>{e.style.transition=""}),t)}async updateDocumentContent(e){const t=this.saveScrollPositions(),s=this.sanitizePassiveHandlers(e),n=(new DOMParser).parseFromString(s,"text/html"),r="pp-dynamic-script",i="pp-dynamic-link";document.head.querySelectorAll("[pp-dynamic-meta]").forEach((e=>e.remove()));document.head.querySelectorAll(`[${i}]`).forEach((e=>e.remove()));document.head.querySelectorAll(`[${r}]`).forEach((e=>e.remove()));await(async e=>{Array.from(e.head.children).forEach((e=>{const t=e.tagName;if("SCRIPT"===t&&e.hasAttribute(r)){const t=document.createElement("script");Array.from(e.attributes).forEach((e=>t.setAttribute(e.name,e.value))),e.textContent&&(t.textContent=e.textContent),document.head.appendChild(t)}else if("META"===t){if(e.getAttribute("charset")||"viewport"===e.getAttribute("name"))return;const t=e.name,s=e.getAttribute("property"),n=document.head.querySelector(t?`meta[name="${t}"]`:`meta[property="${s}"]`),r=document.head.querySelector("title");n?document.head.replaceChild(e.cloneNode(!0),n):r?.nextSibling?document.head.insertBefore(e.cloneNode(!0),r.nextSibling):document.head.appendChild(e.cloneNode(!0))}else if("TITLE"===t){const t=document.head.querySelector("title");t?document.head.replaceChild(e.cloneNode(!0),t):document.head.appendChild(e.cloneNode(!0))}else if("LINK"===t){const t=t=>{const s=document.head.querySelector('link[rel="icon"]');if(s)document.head.replaceChild(e.cloneNode(!0),s);else{const e=document.createElement("link");e.rel="icon",e.href=t,document.head.appendChild(e)}};if("icon"===e.getAttribute("rel")){t(e.href)}else if(e.hasAttribute(i)){const t=e.cloneNode(!0);document.head.appendChild(t)}}})),await this.updateDocumentBody(e)})(n),this.restoreScrollPositions(t),this.resetProps(),await this.processInlineModuleScripts(),await this.initMakeReactive(),this.handlerAutofocusAttribute()}restoreScrollPositions(e){requestAnimationFrame((()=>{const t=e.window;t&&window.scrollTo(t.scrollLeft,t.scrollTop),document.querySelectorAll("*").forEach((t=>{const s=this.getElementKey(t);e[s]&&(t.scrollTop=e[s].scrollTop,t.scrollLeft=e[s].scrollLeft)}))}))}PRESERVE_HANDLERS={DETAILS:(e,t)=>(t.open=e.open,!0),INPUT(e,t){const s=e,n=t;return s.value!==n.value&&(n.value=s.value),n.checked=s.checked,document.activeElement!==s||(null!=s.selectionStart&&(n.selectionStart=s.selectionStart,n.selectionEnd=s.selectionEnd),!1)},TEXTAREA(e,t){const s=e,n=t;return s.value!==n.value&&(n.value=s.value),document.activeElement!==s||(n.selectionStart=s.selectionStart,n.selectionEnd=s.selectionEnd,!1)},SELECT(e,t){const s=e;return t.selectedIndex=s.selectedIndex,document.activeElement!==s},VIDEO(e,t){const s=e,n=t;return n.currentTime=s.currentTime,s.paused?n.pause():n.play(),!0},AUDIO:(e,t)=>this.PRESERVE_HANDLERS.VIDEO(e,t),CANVAS:()=>!1};async populateDocumentBody(e){try{const t=document.body,s=e.body;this._wheelHandlersStashed||(document.querySelectorAll("[onwheel]").forEach((e=>{const t=e.getAttribute("onwheel").trim();if(e.removeAttribute("onwheel"),t){const s=new Function("event",t);e.addEventListener("wheel",s,{passive:!0})}})),this._wheelHandlersStashed=!0);const n=this.PRESERVE_HANDLERS;morphdom(t,s,{getNodeKey(e){if(e.nodeType!==Node.ELEMENT_NODE)return;const t=e;return t.hasAttribute("pp-sync-script")?`pp-sync-script:${t.getAttribute("pp-sync-script")}`:t.getAttribute("key")||void 0},onBeforeElUpdated(e,t){const s=e.tagName;if("SCRIPT"===s||e.hasAttribute("data-nomorph"))return!1;const r=n[s];return!r||r(e,t)},onBeforeNodeDiscarded:e=>(e instanceof HTMLElement&&e.dataset.timerId&&clearTimeout(Number(e.dataset.timerId)),!0)})}catch(e){console.error("Error populating document body:",e)}}async updateDocumentBody(e){try{const t=e.body.cloneNode(!0);this.manageScriptTags(t),document.body.replaceWith(t)}catch(e){console.error("Error populating document body:",e)}}manageScriptTags(e,t){const s=e.querySelectorAll("script"),n=t?.querySelectorAll("script")||s;s.forEach(((e,t)=>{const s=document.createElement("script"),r=n[t]||e;Array.from(r.attributes).forEach((e=>{s.setAttribute(e.name,e.value)})),r.hasAttribute("src")||(s.textContent=r.textContent),e.parentNode?.replaceChild(s,e)}))}saveScrollPositions(){const e={window:{scrollTop:window.scrollY||document.documentElement.scrollTop,scrollLeft:window.scrollX||document.documentElement.scrollLeft}};return document.querySelectorAll("*").forEach((t=>{(t.scrollTop||t.scrollLeft)&&(e[this.getElementKey(t)]={scrollTop:t.scrollTop,scrollLeft:t.scrollLeft})})),e}getElementKey(e){return e.id||e.className||e.tagName}async redirect(e){if(e)try{const t=new URL(e,window.location.origin);t.origin!==window.location.origin?window.location.href=e:(history.pushState(null,"",e),await this.handleNavigation())}catch(e){console.error("Redirect error:",e)}}abortActiveRequest(){this._activeAbortController&&this._activeAbortController.abort()}async fetch(e,t,s=!1){let n;return s?(this._activeAbortController&&this._activeAbortController.abort(),this._activeAbortController=new AbortController,n=this._activeAbortController):n=new AbortController,fetch(e,{...t,signal:n.signal,headers:{...t?.headers,"X-Requested-With":"XMLHttpRequest"}})}isJsonLike(e){return"string"==typeof e&&((e=e.trim()).startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))}parseJson(e){try{return JSON5.parse(e)}catch(e){return console.error(`Error parsing JSON: ${e.message}. Please ensure the JSON string is valid.`,e),{}}}parseTime(e){if("number"==typeof e)return e;const t=e.match(/^(\d+)(ms|s|m)?$/);if(t){const e=parseInt(t[1],10);switch(t[2]||"ms"){case"ms":default:return e;case"s":return 1e3*e;case"m":return 60*e*1e3}}return 0}scheduleChange(e,t,s,n){setTimeout((()=>{requestAnimationFrame((()=>{e.style[s]=n}))}),t)}async fetchFunction(e,t={},s=!1){try{const n={callback:e,...t},r=window.location.href;let i;if(Object.keys(n).some((e=>{const t=n[e];return t instanceof File||t instanceof FileList&&t.length>0}))){const e=new FormData;Object.keys(n).forEach((t=>{const s=n[t];s instanceof File?e.append(t,s):s instanceof FileList?Array.from(s).forEach((s=>e.append(t,s))):e.append(t,s)})),i={method:"POST",headers:{HTTP_PPHP_WIRE_REQUEST:"true"},body:e}}else i=this.createFetchOptions(n);const o=await this.fetch(r,i,s);if(!o.ok)throw new Error(`Fetch failed with status: ${o.status} ${o.statusText}`);const a=await o.text();try{return JSON.parse(a)}catch{return a}}catch(e){throw console.error("Error in fetchFunction:",e),new Error("Failed to fetch data.")}}processSyncScripts(e){e.forEach((e=>{const t=`script[pp-sync-script="${CSS.escape(e)}"]`,s=document.querySelector(t);if(s){s.remove();const e=document.createElement("script");Array.from(s.attributes).forEach((t=>{e.setAttribute(t.name,t.value)})),s.src?e.src=s.src:e.textContent=s.textContent,e.type=s.type||"module",document.body.appendChild(e)}}))}async sync(...e){try{const t=this.saveScrollPositions();this.saveElementState();const s=e.length>0?e.map((e=>`pp-sync="${e}"`)):['pp-sync="true"'],n=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()}),r=await this.fetch(window.location.href,n),i=await r.text(),o=(new DOMParser).parseFromString(i,"text/html"),a=new Set;s.forEach((e=>{const t=document.querySelectorAll(`[${e}]`),s=o.body.querySelectorAll(`[${e}]`);t.forEach(((e,t)=>{const n=s[t];if(n){if(n.hasAttribute("pp-sync-script")){const e=n.getAttribute("pp-sync-script")||"";e&&a.add(e)}n.querySelectorAll("[pp-sync-script]").forEach((e=>{const t=e.getAttribute("pp-sync-script")||"";t&&a.add(t)})),e.innerHTML=n.innerHTML,this.reRunScripts(e)}}))})),this.processSyncScripts(a),this.restoreElementState(),this.restoreScrollPositions(t),this.attachWireFunctionEvents()}catch(e){console.error("Error in pphpSync:",e)}}async fetchAndUpdateBodyContent(){const e=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()});this.abortActiveRequest();const t=await this.fetch(window.location.href,e,!0),s=await t.text();await this.updateBodyContent(s)}reRunScripts(e){e.querySelectorAll("script").forEach((e=>{const t=document.createElement("script");Array.from(e.attributes).forEach((e=>{t.setAttribute(e.name,e.value)})),e.hasAttribute("src")||(t.textContent=e.textContent),e.parentNode?.replaceChild(t,e)}))}copyCode(e,t,s,n,r="img",i=2e3){if(!(e instanceof HTMLElement))return;const o=e.closest(`.${t}`)?.querySelector("pre code"),a=o?.textContent?.trim()||"";a?navigator.clipboard.writeText(a).then((()=>{const t=e.querySelector(r);if(t)for(const[e,s]of Object.entries(n))e in t?t[e]=s:t.setAttribute(e,s);setTimeout((()=>{if(t)for(const[e,n]of Object.entries(s))e in t?t[e]=n:t.setAttribute(e,n)}),i)}),(()=>{alert("Failed to copy command to clipboard")})):alert("Failed to find the code block to copy")}getCookie(e){return document.cookie.split("; ").find((t=>t.startsWith(e+"=")))?.split("=")[1]||null}}class PPHPLocalStore{state;static instance=null;listeners;pphp;STORAGE_KEY;constructor(e={}){this.state=e,this.listeners=[],this.pphp=PPHP.instance,this.STORAGE_KEY=this.pphp.getCookie("pphp_local_store_key")||"pphp_local_store_59e13",this.loadState()}static getInstance(e={}){return PPHPLocalStore.instance||(PPHPLocalStore.instance=new PPHPLocalStore(e)),PPHPLocalStore.instance}setState(e,t=!1){if(this.state={...this.state,...e},this.listeners.forEach((e=>e(this.state))),this.saveState(),t){const e=localStorage.getItem(this.STORAGE_KEY);e&&this.pphp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:e})}}saveState(){localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.state))}loadState(){const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.state=this.pphp.parseJson(e),this.listeners.forEach((e=>e(this.state))))}resetState(e,t=!1){if(e?(delete this.state[e],this.saveState()):(this.state={},localStorage.removeItem(this.STORAGE_KEY)),this.listeners.forEach((e=>e(this.state))),t){const t=e?localStorage.getItem(this.STORAGE_KEY):null;this.pphp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:t})}}}class SearchParamsManager{static instance=null;listeners=[];constructor(){}static getInstance(){return SearchParamsManager.instance||(SearchParamsManager.instance=new SearchParamsManager),SearchParamsManager.instance}get params(){return new URLSearchParams(window.location.search)}get(e){return this.params.get(e)}set(e,t){const s=this.params;s.set(e,t),this.updateURL(s)}delete(e){const t=this.params;t.delete(e),this.updateURL(t)}replace(e){const t=new URLSearchParams;for(const s in e){const n=e[s];null!==n&&t.set(s,n)}this.updateURL(t,!0)}updateURL(e,t=!1){const s=`${window.location.pathname}?${e.toString()}`;t?history.replaceState(null,"",s):history.pushState(null,"",s),this.notifyListeners(e)}listen(e){this.listeners.push(e)}notifyListeners(e){for(const t of this.listeners)t(e)}enablePopStateListener(){window.addEventListener("popstate",(()=>{this.notifyListeners(this.params)}))}}var pphp=PPHP.instance,store=PPHPLocalStore.getInstance(),searchParams=SearchParamsManager.getInstance();
|
|
1
|
+
(()=>{const e=EventTarget.prototype.addEventListener,t=EventTarget.prototype.removeEventListener,s=new Map,n=new Set(["wheel","mousewheel","touchstart","touchmove","touchend","touchcancel","scroll"]);EventTarget.prototype.addEventListener=function(t,r,i){let a=i;n.has(t)&&(void 0===a?a={passive:!0}:"boolean"==typeof a?a={capture:a,passive:!0}:a&&void 0===a.passive&&(a={...a,passive:!0})),s.has(this)||s.set(this,new Map);const o=s.get(this),c=o.get(t)||new Set;c.add(r),o.set(t,c),e.call(this,t,r,a)},EventTarget.prototype.removeEventListener=function(e,n,r){if(s.has(this)&&s.get(this).has(e)){const t=s.get(this).get(e);t.delete(n),0===t.size&&s.get(this).delete(e)}t.call(this,e,n,r)},EventTarget.prototype.removeAllEventListeners=function(e){if(!s.has(this))return;const n=s.get(this).get(e);n&&(n.forEach((s=>{t.call(this,e,s)})),s.get(this).delete(e))}})();class PPHP{props={};_isNavigating=!1;_responseData=null;_elementState={checkedElements:new Set};_activeAbortController=null;_reservedWords;_declaredStateRoots=new Set;_arrayMethodCache=new WeakMap;_scopedKeys=new Map;_updateScheduled=!1;_pendingBindings=new Set;_effects=new Set;_pendingEffects=new Set;_processedPhpSections=new Set;_processedPhpScripts=new WeakSet;_bindings=[];_templateStore=new WeakMap;_inlineDepth=0;_activeSection=null;_inlineModuleFns=new Map;_proxyCache=new WeakMap;_rawProps={};_refs=new Map;_wheelHandlersStashed=!1;_evaluatorCache=new Map;_depsCache=new Map;_dirtyDeps=new Set;_handlerCache=new Map;_handlerProxyCache=new WeakMap;_sharedStateMap=new Map;_sectionParentMap=new Map;_eventHandlers;_redirectRegex=/redirect_7F834\s*=\s*(\/[^\s]*)/;_assignmentRe=/^\s*[\w.]+\s*=(?!=)/;_mustacheRe=/\{\{\s*([\s\S]+?)\s*\}\}/gu;_mutators;_boolAttrs=new Set(["checked","selected","disabled","readonly","multiple","hidden"]);_bareIdRe=/^\s*([A-Za-z_$][\w$]*)\s*$/;_bareCallReEvent=/^\s*([A-Za-z_$][\w$]*)\(\s*\)\s*;?\s*$/;_arrowSigRe=/^\s*(?:\([\w\s,]*\)|[A-Za-z_$][\w$]*)\s*=>/;_callRe=/^\s*([A-Za-z_$]\w*)\s*\(([\s\S]*)\)\s*;?\s*$/;static _instance;static _effectCleanups;static debounceTimers=new Map;static _cancelableEvents=new Set(["click","submit","change"]);static _mustacheTest=/\{\{\s*[\s\S]+?\s*\}\}/;static _mustachePattern=/\{\{\s*([\s\S]+?)\s*\}\}/g;static _passiveEvents=new Set(["wheel","mousewheel","touchstart","touchmove","touchend","touchcancel","scroll"]);static _bareCallRe=/^[A-Za-z_$]\w*\s*\(.*\)$/;constructor(){const e=Object.getOwnPropertyNames(HTMLElement.prototype).filter((e=>e.startsWith("on"))),t=Object.getOwnPropertyNames(Document.prototype).filter((e=>e.startsWith("on"))),s=Object.getOwnPropertyNames(Window.prototype).filter((e=>e.startsWith("on")));this._eventHandlers=new Set([...e,...t,...s].map((e=>e.toLowerCase()))),this._reservedWords=new Set(["null","undefined","true","false","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","async","await","implements","interface","event","NaN","Infinity","Number","String","Boolean","Object","Array","Function","Date","RegExp","Error","JSON","Math","Map","Set"]),this._mutators=new Set(["push","pop","shift","unshift","splice","sort","reverse","copyWithin","fill"]),this.handlePopState(),this._proxyCache=new WeakMap,this._evaluatorCache.clear(),this._depsCache.clear(),this.props=this.makeReactive(this._rawProps),this.scheduleInitialHydration()}static get instance(){return PPHP._instance||(PPHP._instance=new PPHP),PPHP._instance}scheduleInitialHydration(){const e=async()=>{await this.initRefs(),await this.processInlineModuleScripts(),await this.initializeAllReferencedProps(),await this.initBindings(),await this.initLoopBindings(),this.attachWireFunctionEvents(),this._bindings.forEach((e=>e.update())),document.body.removeAttribute("hidden")};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}getScopeId(e){for(;e;){const t=e.getAttribute("pp-phpx-id");if(t)return t;const s=e.getAttribute("pp-section-id");if(s)return s;e=e.parentElement}return null}getSectionId(e){for(;e;){const t=e.getAttribute("pp-section-id");if(t)return t;e=e.parentElement}return null}getPhpxId(e){for(;e;){const t=e.getAttribute("pp-phpx-id");if(t)return t;e=e.parentElement}return null}getPhpxParentId(e){if(!e)return null;let t=e,s=null;for(;t&&!s;)s=t.getAttribute("pp-phpx-id"),s||(t=t.parentElement);let n=t?.parentElement;for(;n;){const e=n.getAttribute("pp-phpx-id");if(e&&e!==s)return e;n=n.parentElement}return null}ref(e,t){const s=this._activeSection;let n=[];if(s&&(n=this._sectionRefs.get(s)?.get(e)??[]),0===n.length&&(n=this._refs.get(e)??[]),null!=t){const s=n[t];if(!s)throw new Error(`pphp.ref('${e}', ${t}) — no element at that index`);return s}if(0===n.length)throw new Error(`pphp.ref('${e}') failed — no element was found`);return 1===n.length?n[0]:n}effect(e,t){const s=this._currentScopeId(),n=Array.isArray(t),r=n?t:[],i=n&&0===r.length,a=r.map((e=>{if("function"==typeof e&&e.__pphp_key)return e.__pphp_key;if("string"!=typeof e)return"";if(e.includes("_"))return e;for(const[t,s]of this._scopedKeys)if(s.has(e))return`${t}_${e}`;if(s){const t=this._sharedStateMap.get(s);if(t?.has(e)){const t=this._sectionParentMap.get(s);return t?`${t}_${e}`:e}}return e})).filter(Boolean),o=new Set(a),c=new Map;for(const e of a){const t=this.getNested(this.props,e);c.set(e,t)}let l=0;PPHP._effectCleanups||(PPHP._effectCleanups=new WeakMap);const h=PPHP._effectCleanups,p=()=>{const t=h.get(p);if(t){try{t()}catch(e){console.error("cleanup error:",e)}h.delete(p)}if(++l>50)throw new Error("PPHP: effect ran >50 times — possible loop");if(!i&&a.length>0){let e=!1;for(const t of a){if(this.getNested(this.props,t)!==c.get(t)){e=!0;break}}if(!e)return;for(const e of a)c.set(e,this.getNested(this.props,e))}try{const t=e();"function"==typeof t&&h.set(p,t)}catch(e){console.error("effect error:",e)}};Object.assign(p,{__deps:o,__sectionId:s??null,__static:i});try{const t=e();"function"==typeof t&&h.set(p,t)}catch(e){console.error("effect error (initial):",e)}for(const e of a)c.set(e,this.getNested(this.props,e));const u=n&&this._inlineDepth>0?this._pendingEffects:this._effects;return i?this._effects.add(p):u.add(p),()=>{const e=h.get(p);if(e){try{e()}catch(e){console.error("cleanup error:",e)}h.delete(p)}this._effects.delete(p),this._pendingEffects.delete(p)}}resetProps(){Object.keys(this._rawProps).forEach((e=>{if(window.hasOwnProperty(e)){const t=Object.getOwnPropertyDescriptor(window,e);t&&t.configurable&&delete window[e]}})),this._rawProps={},this._proxyCache=new WeakMap,this._templateStore=new WeakMap,this._arrayMethodCache=new WeakMap,this._depsCache.clear(),this._evaluatorCache.clear(),this._processedPhpSections.clear(),this._processedPhpScripts=new WeakSet,this._scopedKeys=new Map,this._declaredStateRoots.clear(),this._inlineModuleFns.clear(),this._bindings=[],this._pendingBindings.clear(),this._effects.clear(),this._pendingEffects.clear(),this._refs.clear(),this._sectionRefs.clear(),this.clearHandlerCaches(),this.props=this.makeReactive(this._rawProps)}async initMakeReactive(){await this.initRefs(),await this.initializeAllReferencedProps(),await this.initBindings(),await this.initLoopBindings(),this.attachWireFunctionEvents(),this._bindings.forEach((e=>e.update())),document.body.removeAttribute("hidden")}async initLoopBindings(){document.querySelectorAll("[pp-for]").forEach((e=>this.registerLoop(e)))}registerLoop(e){const t=this.getScopeId(e),s=e.getAttribute("pp-for").trim(),[n,r]=s.split(/\s+in\s+/),[i,a]=n.replace(/^\(|\)$/g,"").split(",").map((e=>e.trim())),o=t?`${t}_${i}`:i,c=a?t?`${t}_${a}`:a:null,l=t?r.replace(/\b([A-Za-z_$]\w*)\b/g,((e,s,n,r)=>"."===r[n-1]||this._reservedWords.has(s)||s.startsWith(t+"_")?e:`${t}_${s}`)):r,h=e.parentNode,p=document.createComment("pp-for");h.insertBefore(p,e),h.removeChild(e);const u=this.makeSafeEvaluator(l),d=e=>t?e.replace(new RegExp(`\\b${i}\\b`,"g"),o).replace(a?new RegExp(`\\b${a}\\b`,"g"):/$^/,c??""):e,f=this.extractDependencies(l);this._bindings.push({dependencies:f,update:()=>{const t=document.activeElement;let s=null,n=null;if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&h.contains(t)){const e=t.closest("[key]");s=e?.getAttribute("key")??null,n=t.selectionStart}for(let e=p.nextSibling;e&&e.nodeType!==Node.COMMENT_NODE;){const t=e.nextSibling;h.removeChild(e),e=t}const r=u(this.props);Array.isArray(r)||console.warn("[pp-for] expected an Array but got:",r);if((Array.isArray(r)?r:[]).forEach(((t,s)=>{this.props[o]=t,c&&(this.props[c]=s);const n=e.content.cloneNode(!0),r=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);for(let e;e=r.nextNode();)e.nodeValue=(e.nodeValue||"").replace(PPHP._mustachePattern,((e,t)=>{try{const e=d(t);return this.formatValue(this.makeSafeEvaluator(e)(this.props))}catch{return""}}));n.querySelectorAll("*").forEach((e=>{for(const{name:t,value:s}of Array.from(e.attributes)){if("pp-bind"===t){const t=d(s),n=this.makeSafeEvaluator(t)(this.props);e.textContent=this.formatValue(n);continue}if("pp-bind-expr"===t){const t=this.decodeEntities?this.decodeEntities(s):s,n=d(t),r=this.makeSafeEvaluator(n)(this.props);e.textContent=this.formatValue(r);continue}const n=t.match(/^pp-bind-(.+)$/);if(!n)continue;const r=n[1],i=d(s),a=this.makeSafeEvaluator(i)(this.props);if(this._boolAttrs.has(r)){const t=!!a;e[r]=t,t?e.setAttribute(r,""):e.removeAttribute(r)}else r in e?e[r]=a:e.setAttribute(r,String(a))}})),n.querySelectorAll("*").forEach((e=>{for(const{name:t,value:s}of Array.from(e.attributes)){const n=t.match(/^pp-bind-(.+)$/);if(!n)continue;const r=n[1],i=d(s),a=this.makeSafeEvaluator(i)(this.props);if(this._boolAttrs.has(r)){const t=!!a;e[r]=t,t?e.setAttribute(r,""):e.removeAttribute(r)}else r in e?e[r]=a:e.setAttribute(r,String(a))}})),n.querySelectorAll("*").forEach((e=>{Array.from(e.attributes).forEach((n=>{const r=n.name.startsWith("on"),o=n.name.startsWith("pp-inc-on"),c=n.name.startsWith("pp-comp-on");if(!r&&!o&&!c)return;let l=n.value;/\b(?:i|idx)\b/.test(l)&&(l=((e,t)=>e.replace(/\[\s*(?:i|idx)\s*\]/g,`[${t}]`).replace(/(^|[^\w$])(?:i|idx)(?!\w)/g,((e,s)=>s+t)))(l,s));const h=new RegExp(`\\b${i}\\b`,"g");var p;if(l=l.replace(h,(p=t,JSON.stringify(p))),a){const e=new RegExp(`\\b${a}\\b`,"g");l=l.replace(e,String(s))}e.setAttribute(n.name,l)}))})),h.insertBefore(n,p.nextSibling)})),null!==s){const e=h.querySelector(`[key="${s}"]`),t=e?.querySelector("input,textarea");if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.focus({preventScroll:!0}),null!==n)){const e=Math.min(n,t.value.length);t.setSelectionRange(e,e)}}this.attachWireFunctionEvents()}})}_sectionRefs=new Map;async initRefs(){document.querySelectorAll("[pp-ref]").forEach((e=>{const t=e.getAttribute("pp-ref"),s=this.getScopeId(e)??"__global__",n=this._sectionRefs.get(s)??new Map,r=n.get(t)??[];r.push(e),n.set(t,r),this._sectionRefs.set(s,n);const i=this._refs.get(t)??[];i.push(e),this._refs.set(t,i),e.removeAttribute("pp-ref")}))}scheduleBindingUpdate(e){this._pendingBindings.add(e),this._updateScheduled||(this._updateScheduled=!0,requestAnimationFrame((()=>{this.flushBindings()})))}makeReactive(e,t=[]){const s=this._proxyCache.get(e);if(s)return s;if(e instanceof Map||e instanceof Set||"object"!=typeof e||null===e)return e;const n=this,r=new Proxy(e,{get(e,s,r){const i=Reflect.get(e,s,r);if(Array.isArray(e)&&"string"==typeof s&&n._mutators.has(s)){let a=n._arrayMethodCache.get(e);if(a||(a=new Map,n._arrayMethodCache.set(e,a)),!a.has(s)){const e=i.bind(r),o=t.join("."),c=function(...t){const s=e(...t);return queueMicrotask((()=>{n._bindings.forEach((e=>{e.dependencies.has(o)&&n.scheduleBindingUpdate(e)}))})),s};a.set(s,c)}return a.get(s)}return null!==i&&"object"==typeof i?n.makeReactive(i,[...t,s]):i},set(e,s,r,i){let a=r;null!==r&&"object"==typeof r&&(a=n.makeReactive(r,[...t,s]));const o=e[s],c=Reflect.set(e,s,a,i);if(o===a)return c;const l=[...t,s].join(".");return n._bindings.forEach((e=>{for(const t of e.dependencies)if(l===t||l.startsWith(t+".")||t.startsWith(l+".")){n.scheduleBindingUpdate(e);break}})),c}});return this._proxyCache.set(e,r),r}makeAttrTemplateUpdater(e,t,s,n){let r=this._templateStore.get(e);r||(r=new Map,this._templateStore.set(e,r)),r.has(t)||r.set(t,e.getAttribute(t)||"");const i=n??r.get(t)??"";return(i.match(this._mustacheRe)||[]).forEach((e=>{this.extractDependencies(e).forEach((e=>s.add(e)))})),()=>{try{const s=i.replace(this._mustacheRe,((e,t)=>{try{const e=this.makeSafeEvaluator(t);return this.formatValue(e(this.props))}catch(e){return console.error("Error token:",t,e),""}}));e.getAttribute(t)!==s&&e.setAttribute(t,s)}catch(e){console.error(`Error evaluating the template for attribute "${t}". Please check the template syntax and dependencies.`,e)}}}makePrimitiveUpdater(e,t,s){const n={};return this._eventHandlers.forEach((e=>{if(e.startsWith("on")){const t=e.slice(2);n[t]=t}})),n.value="input",n.checked="change",()=>{try{const r=s(this.props),i=this.formatValue(r);let a=!1;if("value"===t){const t=e;"value"in e&&t.value!==i?(t.value=i,a=!0):"value"in e||(e.setAttribute("value",i),a=!0)}else{const t=e,s="true"===i;"checked"in e&&t.checked!==s?(t.checked=s,a=!0):"checked"in e||(e.setAttribute("checked",i),a=!0)}if(!a||e instanceof HTMLInputElement&&("hidden"===e.type||e.disabled||e.readOnly))return;const o=n[t]||t,c="click"===o?new MouseEvent(o,{bubbles:!0,cancelable:!0}):new Event(o,{bubbles:!0});e.dispatchEvent(c)}catch(e){console.error(`Error evaluating attribute "${t}":`,e)}}}formatValue(e){return null!==e&&"object"==typeof e&&1===Object.keys(e).length&&Object.prototype.hasOwnProperty.call(e,"value")?this.formatValue(e.value):"function"==typeof e?"":"boolean"==typeof e?e?"true":"false":Array.isArray(e)?e.map((e=>"object"==typeof e?JSON.stringify(e):String(e))).join(", "):e&&"object"==typeof e?Object.keys(e).length?JSON.stringify(e,null,2):"":e?.toString()??""}registerBinding(e,t,s="text",n){if(this._assignmentRe.test(t))return;const r=this.getScopeId(e);let i=t;if(r){const e=this._scopedKeys.get(r)||new Set,s=this._sharedStateMap.get(r)||new Set,n=this._sectionParentMap.get(r);i=t.replace(/\b([A-Za-z_$][\w$]*)\b/g,((t,i,a,o)=>{if("."===o[a-1]||this._reservedWords.has(i))return t;if(s.has(i))return n?`${n}_${i}`:i;if(e.has(i)||this.hasNested(this.props,`${r}_${i}`))return`${r}_${i}`;let c=this._sectionParentMap.get(r)||null;for(;c;){if(this._scopedKeys.get(c)?.has(i)||this.hasNested(this.props,`${c}_${i}`))return`${c}_${i}`;c=this._sectionParentMap.get(c)||null}return t}))}const a=new Set([...this.extractDependencies(i)].map((e=>e.split(".")[0])).filter((e=>e in this.props&&!this._reservedWords.has(e)))),o=this.makeSafeEvaluator(i);if("value"===n||"checked"===n){const t=this.makePrimitiveUpdater(e,n,o);return void this._bindings.push({dependencies:a,update:t})}if(n){const s=n.toLowerCase();if(this._boolAttrs.has(s)){e.removeAttribute(s);const r=()=>{try{const t=!!o(this.props);e[n]!==t&&(e[n]=t),t?e.setAttribute(s,""):e.removeAttribute(s)}catch(e){console.error(`PPHP: error evaluating boolean attribute ${n}="${t}"`,e)}};return void this._bindings.push({dependencies:a,update:r})}const c=e.getAttribute(n)??"";if(this._mustacheRe.test(i)||this._mustacheRe.test(c)){const t=this._scopedKeys.get(r??"")??new Set,s=this._sharedStateMap.get(r??"")??new Set,i=this._sectionParentMap.get(r??"")??null,o=c.replace(this._mustacheRe,((e,n)=>`{{ ${n.replace(/\b([A-Za-z_$][\w$]*)\b/g,((e,n,a,o)=>{if("."===o[a-1]||this._reservedWords.has(n))return e;if(s.has(n))return i?`${i}_${n}`:n;if(t.has(n))return`${r}_${n}`;let c=this._sectionParentMap.get(r??"")||null;for(;c;){if(this._scopedKeys.get(c)?.has(n)||this.hasNested(this.props,`${c}_${n}`))return`${c}_${n}`;c=this._sectionParentMap.get(c)||null}return e}))} }}`)),l=this.makeAttrTemplateUpdater(e,n,a,o);return void this._bindings.push({dependencies:a,update:l})}const l=()=>{try{const t=o(this.props),s=this.formatValue(t);n in e&&(e[n]=s),e.setAttribute(n,s)}catch(e){console.error(`Error evaluating attribute ${n}="${t}"`,e)}};return void this._bindings.push({dependencies:a,update:l})}const c={text(e,t){e.textContent!==t&&(e.textContent=t)},value(e,t){e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value!==t&&(e.value=t):e.setAttribute("value",t)},checked(e,t){e instanceof HTMLInputElement?e.checked="true"===t:e.setAttribute("checked",t)},attr(e,t){e.setAttribute("attr",t)}};this._bindings.push({dependencies:a,update:()=>{try{const t=o(this.props),n=this.formatValue(t);c[s](e,n)}catch(e){console.error(`Error evaluating expression "${t}"`,e)}}})}makeSafeEvaluator(e){const t=e.trim(),s=`\n try {\n with (ctx) {\n ${/^\s*[\w.]+\s*=(?!=)/.test(t)?`${t}; return "";`:`return (${t});`}\n }\n } catch {\n return "";\n }\n `;let n;try{n=new Function("ctx",s)}catch(t){const s=JSON.stringify(e);n=new Function("ctx",`try { return ${s}; } catch { return ""; }`)}return e=>{try{const t=n(e);return null==t?"":t}catch{return""}}}async initBindings(){this._bindings=[];const e=new WeakSet;document.body.querySelectorAll("[pp-if]").forEach((t=>{if(e.has(t))return;const s=[];let n=t;for(;n;){if(n.hasAttribute("pp-if"))s.push({el:n,expr:n.getAttribute("pp-if")});else if(n.hasAttribute("pp-elseif"))s.push({el:n,expr:n.getAttribute("pp-elseif")});else{if(!n.hasAttribute("pp-else"))break;s.push({el:n,expr:null})}e.add(n),n=n.nextElementSibling}s.forEach((e=>{if(null!==e.expr){const t=e.expr.replace(/^{\s*|\s*}$/g,"");e.deps=this.extractDependencies(t);const s=this.makeSafeEvaluator(t);e.evaluate=()=>!!s(this.props)}}));const r=new Set;s.forEach((e=>e.deps?.forEach((e=>r.add(e)))));this._bindings.push({dependencies:r,update:()=>{let e=!1;for(const{el:t,expr:n,evaluate:r}of s)!e&&null!==n&&r()?(t.removeAttribute("hidden"),e=!0):e||null!==n?t.setAttribute("hidden",""):(t.removeAttribute("hidden"),e=!0)}})})),document.body.querySelectorAll("*").forEach((e=>{["pp-bind","pp-bind-expr"].forEach((t=>{const s=e.getAttribute(t);s&&this.registerBinding(e,s,"text")})),Array.from(e.attributes).forEach((t=>{if(!t.name.startsWith("pp-bind-"))return;if("pp-bind"===t.name||"pp-bind-expr"===t.name||"pp-bind-spread"===t.name)return;const s=this.decodeEntities(t.value).replace(/^{{\s*|\s*}}$/g,"");let n=t.name.replace(/^(pp-bind-)+/,"");const r="value"===n?"value":"checked"===n?"checked":"text";this.registerBinding(e,s,r,n)})),Array.from(e.attributes).forEach((t=>{if("pp-bind-spread"!==t.name)return;const s=this.decodeEntities(t.value).split(",").map((e=>e.trim())).filter(Boolean),n=new Set;s.forEach((e=>n.add(e.split(".")[0])));const r=new Set;this._bindings.push({dependencies:n,update:()=>{try{const t={};s.forEach((e=>{const s=this.getNested(this.props,e)??{};Object.assign(t,s)})),r.forEach((s=>{s in t||e.hasAttribute(s)||(e.removeAttribute(s),r.delete(s))})),Object.entries(t).forEach((([t,s])=>{if(!r.has(t)&&e.hasAttribute(t))return;if(!1===s||null==s)return void(r.has(t)&&(e.removeAttribute(t),r.delete(t)));const n="object"==typeof s?JSON.stringify(s):String(s);e.getAttribute(t)!==n&&e.setAttribute(t,n),r.add(t)}))}catch(e){console.error("pp-spread error:",e)}}})}))}))}callInlineModule(e,...t){const s=this._inlineModuleFns.get(e);if(!s)throw new Error(`PPHP: no inline module named "${e}"`);return s(...t)}async processInlineModuleScripts(){this._inlineDepth++,this._sharedStateMap.clear(),this._sectionParentMap.clear();try{const e=Array.from(document.body.querySelectorAll('script[type="text/php"]:not([src])')).filter((e=>{const t=this.getScopeId(e);return t?!this._processedPhpSections.has(t):!this._processedPhpScripts.has(e)}));if(!e.length)return;document.querySelectorAll("[pp-section-id]").forEach((e=>{const t=e.getAttribute("pp-section-id"),s=this.findParentSectionId(e);s&&this._sectionParentMap.set(t,s)})),document.querySelectorAll("[pp-phpx-id]").forEach((e=>{const t=e.getAttribute("pp-phpx-id"),s=this.findParentSectionId(e);s&&this._sectionParentMap.set(t,s)}));const t=this.sortScriptsByDependency(e),s={};for(const e of t){const t=this.getScopeId(e);if(!t)continue;const n=e.textContent||"";for(const[,e]of[...n.matchAll(/export\s+const\s+([A-Za-z_$]\w*)/g),...n.matchAll(/export\s+function\s+([A-Za-z_$]\w*)/g)])s[e]=t}for(const[e,t]of Object.entries(s))this._scopedKeys.has(t)||this._scopedKeys.set(t,new Set),this._scopedKeys.get(t).add(e);for(const e of t){const t=this.getScopeId(e);let n=(e.textContent||"").trim();if(n=this.decodeEntities(n),n=this.transformStateDeclarations(n,t),t){const e=this._sectionParentMap.get(t)??null,s=t+"_",r=e?e+"_":"",i=new Set;if(this._declaredStateRoots.forEach((e=>{e.startsWith(s)?i.add(e.slice(s.length)):r&&e.startsWith(r)?i.add(e.slice(r.length)):e.includes("_")||i.add(e)})),i.size){let e="";for(const a of i){const i=this.hasNested(pphp.props,s+a)?s+a:this.hasNested(pphp.props,r+a)?r+a:a,o="set"+a[0].toUpperCase()+a.slice(1),c=t?`${t}_${a}`:a,l=t?`${t}_${o}`:o;new RegExp(`\\b(?:const|let|var)\\s+\\[?\\s*${a}\\b`).test(n)||(e+=`\n const ${a} = (() => {\n const fn = () => pphp.props.${i};\n fn.__pphp_key = '${i}';\n Object.defineProperty(fn, 'value', {\n get(){ return pphp.props.${i}; },\n set(v){ pphp.props.${i} = v; }\n });\n return fn;\n })();\n const ${o} = v => {\n pphp.props.${i} = typeof v === 'function' ? v(pphp.props.${i}) : v;\n };\n pphp._inlineModuleFns.set('${c}', ${a});\n pphp._inlineModuleFns.set('${l}', ${o});\n `)}n=e+"\n"+n}}const r=this.extractSetters(n,t);if(r.length){n+="\n\n";for(const e of r){n+=`pphp._inlineModuleFns.set('${t?`${t}_${e}`:e}', ${e});\n`}}if(t){const e=this._sectionParentMap.get(t)??null,s=e?e+"_":"";n=n.replace(/(\bpphp\.state\(\s*['"])([^'"]+)(['"])/g,((e,n,r,i)=>r.startsWith(t+"_")||s&&r.startsWith(s)||!r.includes("_")?n+r+i:n+`${t}_${r}`+i))}n=n.replace(/\b([A-Za-z_$]\w*)\s*\(/g,((e,t,n,r)=>{const i=r.slice(Math.max(0,n-20),n);if(/\b(?:function|export\s+function)\s*$/.test(i.trim()))return e;const a=s[t];return a?`${a}_${t}(`:e}));const i=new Blob([n],{type:"application/javascript"}),a=URL.createObjectURL(i),o=PPHP.prototype._currentScopeId;t&&(PPHP.prototype._currentScopeId=()=>t);try{const e=await import(a);for(const[s,n]of Object.entries(e))if("function"==typeof n){const e=t?`${t}_${s}`:s;this._inlineModuleFns.set(e,n)}}catch(e){console.error("Inline module import failed:",e)}finally{PPHP.prototype._currentScopeId=o,URL.revokeObjectURL(a),t?this._processedPhpSections.add(t):this._processedPhpScripts.add(e)}}}finally{this._inlineDepth--,0===this._inlineDepth&&requestAnimationFrame((()=>{this._pendingEffects.forEach((e=>this._effects.add(e))),this._pendingEffects.clear()}))}}findParentSectionId(e){const t=e.parentElement?.closest("[pp-section-id]");return t?t.getAttribute("pp-section-id"):null}extractSetters(e,t){const s=[],n=/\[\s*([A-Za-z_$]\w*)\s*,\s*([A-Za-z_$]\w*)\s*\]\s*=\s*pphp\.state\(/g;let r;for(;null!==(r=n.exec(e));){const[,,e]=r,n=r[1];t&&this._sharedStateMap.get(t)?.has(n)||s.push(e)}return s}transformStateDeclarations(e,t){return e=(e=(e=e.replace(/(\b(?:const|let|var)\s+\[\s*)([A-Za-z_$]\w*)\s*,\s*([A-Za-z_$]\w*)\s*(\]\s*=\s*pphp\.state\s*\(\s*)/g,((e,s,n,r,i)=>t&&this._sharedStateMap.get(t)?.has(n)?e:`${s}${n}, ${r}${i}'${n}', `))).replace(/(\b(?:const|let|var)\s+\[\s*)([A-Za-z_$]\w*)\s*(\]\s*=\s*pphp\.state\s*\(\s*)/g,((e,s,n,r)=>t&&this._sharedStateMap.get(t)?.has(n)?e:`${s}${n}${r}'${n}', `))).replace(/(\b(?:const|let|var)\s+)([A-Za-z_$]\w*)(\s*=\s*pphp\.state\s*\(\s*)/g,((e,s,n,r)=>t&&this._sharedStateMap.get(t)?.has(n)?e:`${s}[${n}] = pphp.state('${n}', `))}sortScriptsByDependency(e){const t=new Map;for(const s of e){const e=this.getScopeId(s);t.has(e)||t.set(e,[]),t.get(e).push(s)}const s=[],n=new Set,r=e=>{if(!e)return[];const t=this._sectionParentMap.get(e);if(t)return[t];const s=this._sharedStateMap.get(e);return s&&s.size>0?[t||null]:[]},i=e=>{if(n.has(e))return;for(const t of r(e))i(t);const a=t.get(e)||[];s.push(...a),n.add(e)};i(null);for(const e of t.keys())null!==e&&i(e);return s}flushBindings(){const e=new Set(this._dirtyDeps);this._pendingBindings.forEach((t=>{t.dependencies.forEach((t=>e.add(t))),t.update()})),this._pendingBindings.clear(),this._dirtyDeps.clear(),this._updateScheduled=!1,this._effects.forEach((t=>{if(t.__static)return;const s=t.__deps||new Set;if(0===s.size||[...s].some((t=>e.has(t)))){const e=this._activeSection;this._activeSection=t.__sectionId??null;try{t()}catch(e){console.error("effect error:",e)}this._activeSection=e}}))}scheduleFlush(){this._updateScheduled||(this._updateScheduled=!0,requestAnimationFrame((()=>{this._updateScheduled=!1,this.flushBindings()})))}scopeKey(e){const t=this._currentScopeId();if(!t)return e;const s=this._sharedStateMap.get(t);if(s?.has(e)){const s=this._sectionParentMap.get(t);return s?`${s}_${e}`:e}return e.startsWith(`${t}_`)?e:`${t}_${e}`}_currentScopeId(){const e=document.currentScript;return this.getScopeId(e)}getNested(e,t){return t.split(".").reduce(((e,t)=>e?e[t]:void 0),e)}setNested(e,t,s){const n=t.split("."),r=n.pop();n.reduce(((e,t)=>e[t]??={}),e)[r]=s}hasNested(e,t){return void 0!==this.getNested(e,t)}state(e,t){if("string"!=typeof e||""===e.trim())throw new Error("PPHP.state: missing or invalid key—make sure your build-time injector ran and you wrote `const [foo, setFoo] = pphp.state(0)` so it became `pphp.state('foo', 0)`.");arguments.length<2&&(t=void 0);const s=this._currentScopeId(),n=e;if(this._reservedWords.has(n))throw new Error(`'${n}' is reserved – choose another state key.`);const r=this.scopeKey(n);this._declaredStateRoots.add(r),s&&(this._scopedKeys.has(s)||this._scopedKeys.set(s,new Set),this._scopedKeys.get(s).add(n)),this.hasNested(pphp.props,r)||this.setNested(pphp.props,r,t);const i=()=>this.getNested(pphp.props,r),a=e=>{const t=i(),s="function"==typeof e?e(t):e;this.setNested(pphp.props,r,s),this._dirtyDeps.add(r.split(".")[0]),this.scheduleFlush()},o=()=>i();Object.defineProperty(o,"value",{get:()=>i(),set:e=>a(e)}),Object.defineProperties(o,{valueOf:{value:()=>i()},toString:{value:()=>String(i())}}),o.__pphp_key=r;const c=i();if(null===c||"object"!=typeof c)return[o,a];return[new Proxy(o,{apply:(e,t,s)=>Reflect.apply(e,t,s),get(e,t,s){if("value"===t)return i();if(t in e)return Reflect.get(e,t,s);return i()[t]},set(e,t,s){if("value"===t)return a(s),!0;return i()[t]=s,!0},has(e,t){if("value"===t||t in o)return!0;return t in i()}}),a]}static _isBuiltIn=(()=>{const e=new Map,t=[Object.prototype,Function.prototype,Array.prototype,String.prototype,Number.prototype,Boolean.prototype,Date.prototype,RegExp.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,Error.prototype,Promise.prototype];return s=>{const n=e.get(s);if(void 0!==n)return n;const r=s in globalThis||t.some((e=>s in e));return e.set(s,r),r}})();extractDependencies(e){const t=e.trim();if(this.isPlainText(t))return new Set;let s=e.replace(/\?\./g,".");const n=new Set,r=/(?:^|[^\w$])(?:\(\s*([^)]*?)\s*\)|([A-Za-z_$][\w$]*))\s*=>/g;for(let e;e=r.exec(s);){(e[1]??e[2]??"").split(",").map((e=>e.trim())).filter(Boolean).forEach((e=>n.add(e)))}const i=/function\s*(?:[A-Za-z_$][\w$]*\s*)?\(\s*([^)]*?)\s*\)/g;for(let e;e=i.exec(s);)e[1].split(",").map((e=>e.trim())).filter(Boolean).forEach((e=>n.add(e)));const a=e=>{let t="",s=0;for(;s<e.length;)if("`"===e[s])for(s++;s<e.length;)if("\\"===e[s])s+=2;else if("$"===e[s]&&"{"===e[s+1]){s+=2;let n=1;const r=s;for(;s<e.length&&n>0;)"{"===e[s]?n++:"}"===e[s]&&n--,s++;const i=e.slice(r,s-1);t+=a(i)+" "}else{if("`"===e[s]){s++;break}s++}else t+=e[s++];return t};s=a(s),s=s.replace(/(['"])(?:\\.|[^\\])*?\1/g,""),s=s.replace(/\/(?:\\.|[^\/\\])+\/[gimsuy]*/g,"");const o=new Set,c=/\b[A-Za-z_$]\w*(?:\.[A-Za-z_$]\w*)*\b/g;for(const t of s.match(c)??[]){const[s,...r]=t.split(".");n.has(s)||(0===r.length&&PPHP._isBuiltIn(s)&&new RegExp(`\\.${s}\\b`).test(e)||o.add(t))}return o}isPlainText(e){const t=e.trim();if(/^['"`]/.test(t))return!1;return![/[+\-*/%=<>!&|?:]/,/\.\w+/,/\[\s*\w+\s*\]/,/\(\s*[^)]*\s*\)/,/=>/,/\b(true|false|null|undefined|typeof|new|delete|void|in|of|instanceof)\b/,/\?\./,/\?\?/,/\.\.\./,/\{[^}]*\}/,/\[[^\]]*\]/].some((e=>e.test(t)))&&(!!t.includes(" ")&&(!/\w+\.\w+/.test(t)&&!/\w+\[\w+\]/.test(t)))}async initializeAllReferencedProps(){const e=PPHP._mustachePattern,t=PPHP._mustacheTest,s=this.props,n=new Set,r=(e,t)=>{const s=e.getAttribute("pp-section-id"),n=this.getScopeId(e.parentElement);return s??n?`${s??n}_${t}`:t},i=(()=>{const e=new Set([...Object.getOwnPropertyNames(String.prototype),...Object.getOwnPropertyNames(Array.prototype),...Object.getOwnPropertyNames(Number.prototype),...Object.getOwnPropertyNames(Boolean.prototype),...Object.getOwnPropertyNames(Object.prototype),...Object.getOwnPropertyNames(Date.prototype),...Object.getOwnPropertyNames(RegExp.prototype)]);return t=>e.has(t)})(),a=(e,t)=>{const[s,a,...o]=t.split(".");if(this._reservedWords.has(s))return void console.warn(`Invalid path “${t}” – “${s}” is a reserved word.`);if(PPHP._isBuiltIn(s)&&console.warn(`Path “${t}” shadows the built-in “${s}”. It will be stored in pphp.props.`),a&&i(a))return void n.add(r(e,s));const c=r(e,s);n.add(a?`${c}.${[a,...o].join(".")}`:c)};for(const s of document.body.getElementsByTagName("*"))for(const{name:n,value:r}of Array.from(s.attributes))if(r){if(t.test(r))for(const t of r.matchAll(e))this.extractDependencies(t[1]).forEach((e=>a(s,e)));"pp-if"!==n&&"pp-elseif"!==n||this.extractDependencies(r).forEach((e=>a(s,e))),n.startsWith("pp-bind")&&this.extractDependencies(r).forEach((e=>a(s,e)))}const o=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:e=>t.test(e.nodeValue??"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT});for(let t;t=o.nextNode();){const s=t.parentElement;for(const n of t.nodeValue.matchAll(e))this.extractDependencies(n[1]).forEach((e=>a(s,e)))}const c=Array.from(n).sort(((e,t)=>t.split(".").length-e.split(".").length));for(const e of c){const t=e.split(".");let n=s;for(let e=0;e<t.length;e++){const s=t[e],r=e===t.length-1,i=0===e,a=t.slice(0,e+1).join(".");i&&PPHP._isBuiltIn(s)&&console.warn(`Root “${s}” shadows the built-in. The placeholder will still be created in pphp.props.`),s in n&&(r||null!=n[s]&&"object"==typeof n[s])||r&&this._declaredStateRoots.has(a)||(n[s]=r?void 0:{}),n=n[s]}}}setNestedProperty(e,t,s){const n=t.split(".");let r=e;for(let e=0;e<n.length-1;e++)n[e]in r||(r[n[e]]={}),r=r[n[e]];r[n[n.length-1]]=s}attachWireFunctionEvents(){this.handleHiddenAttribute(),this.handleAnchorTag();const e=e=>Array.from(this._eventHandlers).map((t=>`[${e}${t}]`)),t=[...e(""),...e("pp-inc-"),...e("data-pp-child-"),...e("data-pp-parent-")].flat().join(","),s=document.body.querySelectorAll(t);for(const e of s){const t=this.getSectionId(e),s=this.getPhpxId(e),n=this.getPhpxParentId(e);for(const r of this._eventHandlers){const i=r,a=`pp-inc-${r}`,o=`data-pp-child-${r}`,c=`data-pp-parent-${r}`,l=e.getAttribute(i),h=e.getAttribute(a),p=e.getAttribute(o),u=e.getAttribute(c),d=l?this.decodeEntities(l).trim():"",f=h?this.decodeEntities(h).trim():"",m=p?this.decodeEntities(p).trim():"",g=u?this.decodeEntities(u).trim():"";if(!(d||f||m||g))continue;const y=[];if(d&&y.push(this.unwrapArrowBody(this.buildHandlerFromRawBody(d,null))),f&&y.push(this.unwrapArrowBody(this.buildHandlerFromRawBody(f,t))),m&&y.push(this.unwrapArrowBody(this.buildHandlerFromRawBody(m,s))),g){const e=n||t||null;y.push(this.unwrapArrowBody(this.buildHandlerFromRawBody(g,e)))}const b=`(event) => { ${[...new Set(y)].join(" ")} }`;[i,a,o,c].forEach((t=>e.removeAttribute(t)));const w=r.slice(2);e.removeAllEventListeners(w),e instanceof HTMLInputElement&&this.handleInputAppendParams(e,w),this.handleDebounce(e,w,b)}}}alreadyScoped(e,t){const s=`${t}_${e}`;return this._scopedKeys.get(t)?.has(s)??!1}prefixFunctionCalls(e,t){return e.replace(/\b([A-Za-z_$][\w$]*)\s*\(/g,((e,s)=>this._reservedWords.has(s)||s.startsWith(`${t}_`)?e:this.alreadyScoped(s,t)?`${t}_${s}(`:e))}prefixIds(e,t,s=new Set){let n="",r=0,i=(e=this.prefixFunctionCalls(e,t)).length,a=!1,o=!1,c=!1;for(;r<i;){const l=e[r];if("'"!==l||o||c||"\\"===e[r-1])if('"'!==l||a||c||"\\"===e[r-1])if("`"!==l||a||o||"\\"===e[r-1])if(a||o||c)n+=l,r++;else if(/[A-Za-z_$]/.test(l)){let a=r+1;for(;a<i&&/[\w$]/.test(e[a]);)a++;const o=e.slice(r,a),c=e[r-1]??"",l=this._reservedWords.has(o),h="."===c;n+=!(o.startsWith(`${t}_`)||h||l||s.has(o))?`${t}_${o}`:o,r=a}else n+=l,r++;else c=!c,n+=l,r++;else o=!o,n+=l,r++;else a=!a,n+=l,r++}return n}decodeEntities=e=>{const t=document.createElement("textarea");t.innerHTML=e;let s=t.value;for(;s.includes("&");){t.innerHTML=s;const e=t.value;if(e===s)break;s=e}return s};shouldPrefixForSection(e,t){if(!e||!t)return!1;const s=this.getSectionStateKeys(t);if(!s||0===s.size)return!1;const n=this.extractFunctionCalls(e);for(const e of n)if(this.isStateFunctionForSection(e,s))return!0;const r=this.extractVariableAssignments(e);for(const e of r)if(s.has(e))return!0;return!1}getSectionStateKeys(e){const t=this._scopedKeys.get(e);if(!t)return null;const s=new Set;for(const e of t){const t=e.includes("_")?e.split("_").pop():e;s.add(t)}return s}extractFunctionCalls(e){const t=[],s=/\b([A-Za-z_$][\w$]*)\s*\(/g;let n;for(;null!==(n=s.exec(e));)t.push(n[1]);return t}extractVariableAssignments(e){const t=[],s=/\b([A-Za-z_$][\w$]*)\s*=/g;let n;for(;null!==(n=s.exec(e));){const s=e[n.index-1],r=e[n.index+n[0].length];"="!==s&&"="!==r&&t.push(n[1])}return t}isStateFunctionForSection(e,t){const s=e.match(/^set([A-Z][a-zA-Z]*)$/);if(s){const e=s[1].charAt(0).toLowerCase()+s[1].slice(1);return t.has(e)}const n=e.match(/^toggle([A-Z][a-zA-Z]*)$/);if(n){const e=n[1].charAt(0).toLowerCase()+n[1].slice(1);return t.has(e)}return t.has(e)}unwrapArrowBody=e=>{if(!e.trim())return"";const t=e.match(/^\s*(?:\([\w\s,]*\)|[A-Za-z_$][\w$]*)\s*=>\s*\{([\s\S]*)\}\s*$/);if(t){let e=t[1].trim();return e&&!e.endsWith(";")&&(e+=";"),e}const s=e.match(/^\s*(?:\([\w\s,]*\)|[A-Za-z_$][\w$]*)\s*=>\s*/);if(s){let t=e.substring(s[0].length).trim();return t&&!t.endsWith(";")&&(t+=";"),t}let n=e.trim();return n&&!n.endsWith(";")&&(n+=";"),n};buildHandlerFromRawBody(e,t){const{normalized:s,originalParam:n}=this.normalizeToArrow(e),r=this.renameEventParam(s,n),i=this.replaceThisReferences(r);return t?this.prefixBareIdentifiers(i,t):i}replaceThisReferences(e){return e.replace(/\bthis\./g,"event.target.")}collectInlineOnAttributes(e){const t=[];for(const{name:s,value:n}of Array.from(e.attributes))s.startsWith("pp-event-on")&&n.trim().length&&t.push({name:s,rawValue:n});return t}isBareCall(e){return!e.includes("=>")&&PPHP._bareCallRe.test(e)&&!/^[A-Za-z_$]\w*_/.test(e)}normalizeToArrow(e){const t=e.match(/^\s*(?:\([\w\s,]*\)|[A-Za-z_$][\w$]*)\s*=>/);if(!t)return{normalized:`() => { ${e} }`,originalParam:null};const s=t[0].replace(/\s*=>\s*$/,"").trim().replace(/^\(|\)$/g,"").trim();return{normalized:e,originalParam:/^[A-Za-z_$]\w*$/.test(s)?s:null}}renameEventParam(e,t){if(!t||"event"===t)return e;const s=new RegExp(`\\b${this.escapeRegex(t)}\\b`,"g");return e.replace(s,((e,t,s)=>{const n=s[t-1],r=s[t+e.length];return n&&/[\w$]/.test(n)||r&&/[\w$]/.test(r)?e:"event"}))}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}prefixBareIdentifiers(e,t){const s=e.indexOf("=>");if(-1!==s){const n=e.slice(0,s+2),r=e.slice(s+2);return n+this.prefixIds(r,t,new Set(["event"]))}const n=this.prefixIds(e,t,new Set(["event"]));return/^[A-Za-z_$].*\)$/.test(n.trim())?`() => ${n}`:`(event) => { ${n}; }`}processFormOnSubmit(e){const t=e.getAttribute("onsubmit")?.trim();if(!t)return;let s,n=t;/^\s*(?:\([\w\s,]*\)|[A-Za-z_$][\w$]*)\s*=>/.test(n)||(console.warn("PPHP: Inline handler on [onsubmit] should use arrow syntax. Auto-wrapping it."),n=`() => { ${n} }`);const r=this.getScopeId(e);r&&this.isBareCall(n)&&(n=`${r}_${n}`),s=this.buildHandlerFromRawBody(n,r),e.removeAttribute("onsubmit"),this.handleDebounce(e,"submit",s)}async handleDebounce(e,t,s){const n=e.getAttribute("pp-debounce"),r=n?this.parseTime(n):0,i=e.getAttribute("pp-before-request")??"",a=e.getAttribute("pp-after-request")??"",o=PPHP._cancelableEvents,c=async n=>{o.has(t)&&n.cancelable&&n.preventDefault();try{i&&await this.invokeHandler(e,i,n),await this.invokeHandler(e,s,n),a&&"@close"!==a&&await this.invokeHandler(e,a,n),this.handlerAutofocusAttribute()}catch(e){console.error("Error in debounced handler:",e)}},l={passive:PPHP._passiveEvents.has(t)&&!o.has(t)},h=`${t}::${e.__pphpId||e.tagName}`,p=e=>{if(r>0){const t=PPHP.debounceTimers.get(h);t&&clearTimeout(t);const s=setTimeout((()=>{PPHP.debounceTimers.delete(h),c(e)}),r);PPHP.debounceTimers.set(h,s)}else c(e)};e instanceof HTMLFormElement&&"submit"===t?e.addEventListener("submit",(e=>{e.cancelable&&e.preventDefault(),p(e)}),l):e.addEventListener(t,p,l)}debounce(e,t=300,s=!1){let n;return function(...r){const i=this;n&&clearTimeout(n),n=setTimeout((()=>{n=null,s||e.apply(i,r)}),t),s&&!n&&e.apply(i,r)}}handlerAutofocusAttribute(){const e=document.querySelector("dialog[open]");let t=null;if(e&&(t=e.querySelector("[pp-autofocus]")),t||(t=document.querySelector("[pp-autofocus]")),!t)return;const s=t.getAttribute("pp-autofocus");if(!this.isJsonLike(s))return;const n=this.parseJson(s);requestAnimationFrame((()=>{t.focus(),(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&"function"==typeof this.setCursorPosition&&(t instanceof HTMLInputElement&&"number"===t.type?(t.type="text",this.setCursorPosition(t,n),t.type="number"):this.setCursorPosition(t,n))}))}async invokeHandler(e,t,s){this._activeSection=this.getScopeId(e);try{const n=t.trim();let r=this._handlerCache.get(n);r||(r=this.parseHandler(n),this._handlerCache.set(n,r)),await this.executeHandler(r,e,s,n)}catch(s){this.handleInvokeError(s,t,e)}finally{this.scheduleFlush()}}parseHandler(e){const t=e.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").trim();if(this.isArrowFunction(t))return this.parseArrowFunction(t);const s=t.match(/^(\w+(?:\.\w+)*)\s*\(\s*(.*?)\s*\)$/s);if(s)return{type:"call",name:s[1],args:s[2],isAsync:this.isAsyncFunction(s[1])};const n=t.match(/^(\w+)$/);return n?{type:"simple",name:n[1],isAsync:this.isAsyncFunction(n[1])}:{type:"complex",body:t,isAsync:!1}}isArrowFunction(e){let t=!1,s="",n=0;for(let r=0;r<e.length-1;r++){const i=e[r],a=e[r+1];if(t||'"'!==i&&"'"!==i&&"`"!==i){if(t&&i===s&&"\\"!==e[r-1])t=!1,s="";else if(!t&&("("===i&&n++,")"===i&&n--,"="===i&&">"===a&&n>=0))return!0}else t=!0,s=i}return!1}parseArrowFunction(e){const t=this.findArrowIndex(e);let s=e.substring(t+2).trim();return s.startsWith("{")&&s.endsWith("}")&&(s=s.slice(1,-1).trim()),{type:"arrow",body:s,isAsync:e.includes("async")||this.containsAwait(s)}}findArrowIndex(e){let t=!1,s="";for(let n=0;n<e.length-1;n++){const r=e[n],i=e[n+1];if(t||'"'!==r&&"'"!==r&&"`"!==r){if(t&&r===s&&"\\"!==e[n-1])t=!1;else if(!t&&"="===r&&">"===i)return n}else t=!0,s=r}return-1}async executeArrowHandler(e,t,s){const n=this.parseStatements(e.body);let r=!1;for(const e of n)await this.executeSingleStatement(e,t,s)&&(r=!0);r||await this.executeDynamic(e.body,t,s)}async executeComplexHandler(e,t,s){await this.executeDynamic(e.body,t,s)}parseStatements(e){const t=[];let s="",n=0,r=!1,i="";for(let a=0;a<e.length;a++){const o=e[a];r||'"'!==o&&"'"!==o&&"`"!==o?r&&o===i&&"\\"!==e[a-1]&&(r=!1,i=""):(r=!0,i=o),r||("("!==o&&"{"!==o&&"["!==o||n++,")"!==o&&"}"!==o&&"]"!==o||n--,";"!==o||0!==n)?s+=o:s.trim()&&(t.push(s.trim()),s="")}return s.trim()&&t.push(s.trim()),t}async executeInlineModule(e,t,s,n,r){if(t&&t.trim())if(this.isJsonLike(t)){const r=this.parseJson(t);null!==r&&"object"==typeof r?await this.callInlineModule(e,{...r,element:s,event:n}):await this.callInlineModule(e,r)}else try{const s=this.getOrCreateEvaluator(t)(this.props);await this.callInlineModule(e,s)}catch{await this.callInlineModule(e,{element:s,event:n})}else await this.handleParsedCallback(s,r,n)}async executeSingleStatement(e,t,s){const n=e.trim();if(!n)return!1;const r=n.match(/^\(\s*\)\s*=>\s*(.+)$/);if(r)return await this.executeSingleStatement(r[1],t,s);if(/^\s*(if|for|while|switch|try|return|throw|var|let|const|function|class)\b/.test(n))return await this.executeDynamic(n,t,s),!0;const i=n.match(/^(\w+)\s*\(\s*(.*?)\s*\)$/s);if(i){const[,e,r]=i;if(this._inlineModuleFns.has(e))return await this.executeInlineModule(e,r,t,s,n),!0;const a=globalThis[e];return"function"==typeof a?(await this.executeGlobalFunction(a,r,t,s),!0):(await this.handleParsedCallback(t,n,s),!0)}const a=n.match(/^(\w+)$/);if(a){const e=a[1];if(this._inlineModuleFns.has(e))return await this.handleParsedCallback(t,`${e}()`,s),!0;const n=globalThis[e];return"function"==typeof n?(n.call(globalThis,s),!0):(await this.handleParsedCallback(t,`${e}()`,s),!0)}return await this.executeDynamic(n,t,s),!0}async executeCallHandler(e,t,s,n){const{name:r,args:i}=e;if(this._inlineModuleFns.has(r))return void await this.executeInlineModule(r,i||"",t,s,n);const a=globalThis[r];"function"!=typeof a?await this.handleParsedCallback(t,n,s):await this.executeGlobalFunction(a,i||"",t,s)}async executeSimpleHandler(e,t,s){const{name:n}=e;if(this._inlineModuleFns.has(n))return void await this.handleParsedCallback(t,`${n}()`,s);const r=globalThis[n];"function"!=typeof r?await this.handleParsedCallback(t,`${n}()`,s):r.call(globalThis,s)}async executeHandler(e,t,s,n){switch(e.type){case"arrow":await this.executeArrowHandler(e,t,s);break;case"call":await this.executeCallHandler(e,t,s,n);break;case"simple":await this.executeSimpleHandler(e,t,s);break;case"complex":await this.executeComplexHandler(e,t,s);break;default:await this.handleParsedCallback(t,n,s)}}async executeGlobalFunction(e,t,s,n){if(t.trim())if(this.isJsonLike(t)){const r=this.parseJson(t)??{};e.call(globalThis,{...r,element:s,event:n})}else{const r=this.getOrCreateProxy(this.props);new Function("event","proxy","props","fn",`with (proxy) { return fn(${t}); }`).call(s,n,r,this.props,e)}else e.call(globalThis,n)}async executeDynamic(e,t,s){const n=this.getOrCreateProxy(this.props);let r=e;this._activeSection&&(r=this.prefixFunctionCalls(e,this._activeSection));const i=new Function("event","proxy","props",`\n with (proxy) {\n ${r}\n }`);await i.call(t,s,n,this.props)}getOrCreateEvaluator(e){let t=this._evaluatorCache.get(e);return t||(t=this.makeSafeEvaluator(e),this._evaluatorCache.set(e,t)),t}getOrCreateProxy(e){let t=this._handlerProxyCache.get(e);return t||(t=this.createHandlerProxy(e),this._handlerProxyCache.set(e,t)),t}createHandlerProxy(e){const t=this._inlineModuleFns;return new Proxy(e,{get(e,s,n){if("string"==typeof s){if(t.has(s))return t.get(s);if(s in e){const t=Reflect.get(e,s,n),r=globalThis[s];if(!(null==t||"object"==typeof t&&0===Object.keys(t).length||PPHP._isBuiltIn(s)&&typeof t!=typeof r))return t}if(s in globalThis){const e=globalThis[s];return"function"==typeof e&&/^[a-z]/.test(s)?e.bind(globalThis):e}}return Reflect.get(e,s,n)},set:(e,t,s,n)=>Reflect.set(e,t,s,n),has:(e,s)=>"string"==typeof s&&t.has(s)||s in e||s in globalThis})}isAsyncFunction(e){const t=this._inlineModuleFns.get(e)||globalThis[e];return t&&("AsyncFunction"===t.constructor.name||t.toString().includes("async "))}containsAwait(e){return/\bawait\s+/.test(e)}handleInvokeError(e,t,s){const n=e instanceof Error?e.message:String(e),r=s.tagName+(s.id?`#${s.id}`:"");console.error(`Handler execution failed on ${r}:\nHandler: "${t}"\nError: ${n}`,e),s.dispatchEvent(new CustomEvent("pphp:handler-error",{detail:{handler:t,error:e,element:s},bubbles:!0}))}clearHandlerCaches(){this._handlerCache.clear(),this._evaluatorCache.clear()}async handleParsedCallback(e,t,s){const{funcName:n,data:r}=this.parseCallback(e,t);if(!n)return;const i=Array.isArray(n)?n:[n];let a;for(const e of i){const t=this._inlineModuleFns.get(e);if("function"==typeof t){a=t;break}const s=this[e];if("function"==typeof s){a=s;break}const n=window[e];if("function"==typeof n){a=n;break}}if(a){const t=e.hasAttribute("pp-after-request"),n=Array.isArray(r.args)?r.args:[],i=this._responseData?this.parseJson(this._responseData):{response:this._responseData};let o={args:n,element:e,data:r,event:s};return t&&(o={...o,...i}),void await a.call(this,o)}this._responseData=null,this._responseData=await this.handleUndefinedFunction(e,Array.isArray(n)?n[0]:n,r)}async handleUndefinedFunction(e,t,s){const n={callback:t,...s},r=this.createFetchOptions(n),i=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()});try{this.saveElementOriginalState(e),this.handleSuspenseElement(e);const n=new URL(window.location.href);let a="",o="",c={success:!1};const l=e.querySelector("input[type='file']");if(l){if(a=await this.fetchFileWithData(n.href,t,l,s),o=this.extractJson(a)||"",o)try{c=this.parseJson(o)}catch(e){console.error("Error parsing JSON response. Please ensure the response is in valid JSON format.",e)}}else{const e=await this.fetch(n.href,r);if(a=await e.text(),this.getRedirectUrl(a))return void await this.redirect(this.getRedirectUrl(a)||"");if(o=this.extractJson(a)||"",o)try{c=this.parseJson(o)}catch(e){console.error("Error parsing JSON response. Please ensure the response is in valid JSON format.",e)}}const h=e.getAttribute("pp-before-request")||"",p=e.getAttribute("pp-after-request")||"";if((h||p&&c.success)&&this.restoreSuspenseElement(e),h||p){let e="";if(c.success){e=a.replace(o,"")}else e=a;if(this.appendAfterbegin(e),!p&&!c.success)return}if(p&&c.success){this.handleAfterRequest(p,o);const e=a.replace(o,"");return this.appendAfterbegin(e),o}if("@close"===p)return c.success?o:void 0;const u=await this.fetch(n.href,i),d=await u.text();if(this.getRedirectUrl(d))return void await this.redirect(this.getRedirectUrl(d)||"");await this.handleResponseRedirectOrUpdate(a,d,o,c)}catch(e){console.error(`Error handling undefined function "${t}". Please ensure the function is defined and accessible.`,e)}}handleAfterRequest(e,t){if(!this.isJsonLike(e))return;const s=this.parseJson(e),n=t?this.parseJson(t):null,r=s.targets;Array.isArray(r)&&r.forEach((e=>{const{id:t,...s}=e,r=document.querySelector(t);let i={};if(n){for(const t in s)if(s.hasOwnProperty(t))switch(t){case"innerHTML":case"outerHTML":case"textContent":case"innerText":"response"===s[t]&&(i[t]=e.responseKey?n[e.responseKey]:n.response);break;default:i[t]=s[t]}}else i=s;r&&this.updateElementAttributes(r,i)}))}sanitizePassiveHandlers(e){return e.replace(/\s+onwheel\s*=\s*(['"])([\s\S]*?)\1/gi,((e,t,s)=>` data-onwheel-code="${encodeURIComponent(s)}"`)).replace(/\s+onmousewheel\s*=\s*(['"])[\s\S]*?\1/gi,"")}handlePassiveWheelStashes(e){(e instanceof Document?e.body:e).querySelectorAll("[data-onwheel-code]").forEach((e=>{let t=decodeURIComponent(e.dataset.onwheelCode||"").trim();delete e.dataset.onwheelCode,e.onwheel=null;const s=this.getScopeId(e);if(s){const e=t.indexOf("=>");if(e>=0){const n=t.slice(0,e+2),r=t.slice(e+2);t=n+this.prefixIds(r,s)}else t=this.prefixIds(t,s)}e.removeAllEventListeners("wheel"),this.handleDebounce(e,"wheel",t)}))}async handleResponseRedirectOrUpdate(e,t,s,n){const r=this.sanitizePassiveHandlers(t),i=this.getUpdatedHTMLContent(e,s,n),a=(new DOMParser).parseFromString(r,"text/html");i&&a.body.insertAdjacentElement("afterbegin",i),this.updateBodyContent(a.body.outerHTML)}getUpdatedHTMLContent(e,t,s){const n=document.createElement("div");if(n.id="afterbegin-8D95D",s&&t?.success){const t=e.replace(s,"");n.innerHTML=t}else n.innerHTML=e;return n.innerHTML?n:null}async updateBodyContent(e){const t=this.saveScrollPositions();this.saveElementState();const s=(new DOMParser).parseFromString(e,"text/html");await this.appendCallbackResponse(s),this.restoreElementState(),this.restoreScrollPositions(t),await this.processInlineModuleScripts(),await this.initMakeReactive()}restoreElementState(){if(this._elementState.focusId){const e=document.getElementById(this._elementState.focusId)||document.querySelector(`[name="${this._elementState.focusId}"]`);if(e instanceof HTMLInputElement){const t=e.value.length||0;void 0!==this._elementState.focusSelectionStart&&null!==this._elementState.focusSelectionEnd&&e.setSelectionRange(t,t),this._elementState.focusValue&&("checkbox"===e.type||"radio"===e.type?e.checked=!!this._elementState.focusChecked:"number"===e.type||"email"===e.type?(e.type="text",e.setSelectionRange(t,t),e.type="number"===e.type?"number":"email"):"date"===e.type||"month"===e.type||"week"===e.type||"time"===e.type||"datetime-local"===e.type||"color"===e.type||"file"===e.type||""!==e.value&&(e.value=this._elementState.focusValue)),e.focus()}else if(e instanceof HTMLTextAreaElement){const t=e.value.length||0;void 0!==this._elementState.focusSelectionStart&&null!==this._elementState.focusSelectionEnd&&e.setSelectionRange(t,t),this._elementState.focusValue&&""!==e.value&&(e.value=this._elementState.focusValue),e.focus()}else e instanceof HTMLSelectElement&&(this._elementState.focusValue&&""!==e.value&&(e.value=this._elementState.focusValue),e.focus())}this._elementState.checkedElements.forEach((e=>{const t=document.getElementById(e);t&&(t.checked=!0)}))}async appendCallbackResponse(e){const t=e.getElementById("afterbegin-8D95D");if(t){const e=document.getElementById("afterbegin-8D95D");e?e.innerHTML=t.innerHTML:document.body.insertAdjacentHTML("afterbegin",t.outerHTML)}await this.populateDocumentBody(e)}saveElementState(){const e=document.activeElement;this._elementState.focusId=e?.id||e?.name,this._elementState.focusValue=e?.value,this._elementState.focusChecked=e?.checked,this._elementState.focusType=e?.type,this._elementState.focusSelectionStart=e?.selectionStart,this._elementState.focusSelectionEnd=e?.selectionEnd,this._elementState.isSuspense=e.hasAttribute("pp-suspense"),this._elementState.checkedElements.clear(),document.querySelectorAll('input[type="checkbox"]:checked').forEach((e=>{this._elementState.checkedElements.add(e.id||e.name)})),document.querySelectorAll('input[type="radio"]:checked').forEach((e=>{this._elementState.checkedElements.add(e.id||e.name)}))}updateElementAttributes(e,t){for(const s in t)if(t.hasOwnProperty(s))switch(s){case"innerHTML":case"outerHTML":case"textContent":case"innerText":e[s]=this.decodeHTML(t[s]);break;case"insertAdjacentHTML":e.insertAdjacentHTML(t.position||"beforeend",this.decodeHTML(t[s].html));break;case"insertAdjacentText":e.insertAdjacentText(t.position||"beforeend",this.decodeHTML(t[s].text));break;case"setAttribute":e.setAttribute(t.attrName,this.decodeHTML(t[s]));break;case"removeAttribute":e.removeAttribute(t[s]);break;case"className":e.className=this.decodeHTML(t[s]);break;case"classList.add":e.classList.add(...this.decodeHTML(t[s]).split(","));break;case"classList.remove":e.classList.remove(...this.decodeHTML(t[s]).split(","));break;case"classList.toggle":e.classList.toggle(this.decodeHTML(t[s]));break;case"classList.replace":const[n,r]=this.decodeHTML(t[s]).split(",");e.classList.replace(n,r);break;case"dataset":e.dataset[t.attrName]=this.decodeHTML(t[s]);break;case"style":Object.assign(e.style,t[s]);break;case"value":e.value=this.decodeHTML(t[s]);break;case"checked":e.checked=t[s];break;default:e.setAttribute(s,this.decodeHTML(t[s]))}}decodeHTML(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}appendAfterbegin(e){if(!e)return;const t="afterbegin-8D95D";let s=document.getElementById(t);s?(s.innerHTML=e,document.body.insertAdjacentElement("afterbegin",s)):(s=document.createElement("div"),s.id=t,s.innerHTML=e,document.body.insertAdjacentElement("afterbegin",s))}restoreSuspenseElement(e){const t=e.getAttribute("pp-original-state");if(e.hasAttribute("pp-suspense")&&t){const s=(e,t)=>{for(const s in t)t.hasOwnProperty(s)&&("textContent"===s?e.textContent=t[s]:"innerHTML"===s?e.innerHTML=t[s]:"disabled"===s?!0===t[s]?e.setAttribute("disabled","true"):e.removeAttribute("disabled"):e.setAttribute(s,t[s]));for(const s of Array.from(e.attributes))t.hasOwnProperty(s.name)||e.removeAttribute(s.name)},n=(e,t)=>{for(const n in t)if(t.hasOwnProperty(n))for(const t of Array.from(e.elements))if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-original-state")||"";if(e){if(this.isJsonLike(e)){const n=this.parseJson(e);s(t,n)}else r(t,e);t.removeAttribute("pp-original-state")}}},r=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},i=(e,t)=>{e instanceof HTMLFormElement?n(e,t):s(e,t)};try{const r=this.parseJson(t);if(r)if(e instanceof HTMLFormElement){const t=e.id;if(t){const e=document.querySelector(`[form="${t}"]`);if(e){const t=e.getAttribute("pp-original-state");if(t&&this.isJsonLike(t)){const n=this.parseJson(t);s(e,n)}}}const r=new FormData(e),i={};if(r.forEach(((e,t)=>{i[t]=e})),n(e,i),e.hasAttribute("pp-suspense")){const t=e.getAttribute("pp-suspense")||"";if(this.parseJson(t).disabled)for(const t of Array.from(e.elements))(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("disabled")}}else if(r.targets){r.targets.forEach((e=>{const{id:t,...s}=e,n=document.querySelector(t);n&&i(n,s)}));const{targets:t,...n}=r;s(e,n)}else{const{empty:t,...n}=r;s(e,n)}}catch(e){console.error(`Error parsing JSON: ${e instanceof Error?e.message:"Unknown error"}. Please ensure the JSON string is valid.`,e)}}e.querySelectorAll("[pp-suspense]").forEach((e=>this.restoreSuspenseElement(e))),e.removeAttribute("pp-original-state")}extractJson(e){const t=e?.match(/\{[\s\S]*\}/);return t?t[0]:null}getRedirectUrl(e){const t=e.match(this._redirectRegex);return t?t[1]:null}async fetchFileWithData(e,t,s,n={}){const r=new FormData,i=s.files;if(i)for(let e=0;e<i.length;e++)r.append("file[]",i[e]);r.append("callback",t);for(const e in n)n.hasOwnProperty(e)&&r.append(e,n[e]);const a=await this.fetch(e,{method:"POST",headers:{HTTP_PPHP_WIRE_REQUEST:"true"},body:r});return await a.text()}async handleSuspenseElement(e){let t=e.getAttribute("pp-suspense")||"";const s=(e,t)=>{for(const s in t)if(t.hasOwnProperty(s))for(const t of e.elements)if(t instanceof HTMLInputElement||t instanceof HTMLButtonElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){const e=t.getAttribute("pp-suspense")||"";if(e)if(this.isJsonLike(e)){const s=this.parseJson(e);"disabled"!==s.onsubmit&&this.updateElementAttributes(t,s),s.targets&&s.targets.forEach((e=>{const{id:t,...s}=e,n=document.querySelector(t);n&&r(n,s)}))}else n(t,e)}},n=(e,t)=>{e instanceof HTMLInputElement?e.value=t:e.textContent=t},r=(e,t)=>{e instanceof HTMLFormElement?s(e,t):this.updateElementAttributes(e,t)};try{if(t&&this.isJsonLike(t)){const n=this.parseJson(t);if(n)if(e instanceof HTMLFormElement){const t=new FormData(e),r={};t.forEach(((e,t)=>{r[t]=e})),n.disabled&&this.toggleFormElements(e,!0);const{disabled:i,...a}=n;this.updateElementAttributes(e,a),s(e,r)}else if(n.targets){n.targets.forEach((e=>{const{id:t,...s}=e,n=document.querySelector(t);n&&r(n,s)}));const{targets:t,...s}=n;this.updateElementAttributes(e,s)}else{if("disabled"===n.empty&&""===e.value)return;const{empty:t,...s}=n;this.updateElementAttributes(e,s)}}else if(t)n(e,t);else if(e instanceof HTMLFormElement){const t=new FormData(e),n={};t.forEach(((e,t)=>{n[t]=e})),s(e,n)}}catch(e){console.error(`Error parsing JSON: ${e instanceof Error?e.message:"Unknown error"}. Please ensure the JSON string is valid.`,e)}}toggleFormElements(e,t){Array.from(e.elements).forEach((e=>{(e instanceof HTMLInputElement||e instanceof HTMLButtonElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(e.disabled=t)}))}saveElementOriginalState(e){if(e.hasAttribute("pp-suspense")&&!e.hasAttribute("pp-original-state")){const t={};e.textContent&&(t.textContent=e.textContent.trim()),e.innerHTML&&(t.innerHTML=e.innerHTML.trim()),(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(t.value=e.value);for(let s=0;s<e.attributes.length;s++){const n=e.attributes[s];t[n.name]=n.value}e.setAttribute("pp-original-state",JSON.stringify(t))}if(e instanceof HTMLFormElement){let t=null;const s=e.id;s&&(t=document.querySelector(`[form="${s}"]`)),s&&t||(t=Array.from(e.elements).find((e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement))),t?t.hasAttribute("pp-original-state")||this.saveElementOriginalState(t):console.warn("Warning: No invoker detected for the form. Ensure the form has an associated invoker or an ID for proper handling.")}e.querySelectorAll("[pp-suspense]").forEach((e=>this.saveElementOriginalState(e)))}getUrlParams(){const e={};return new URLSearchParams(window.location.search).forEach(((t,s)=>{e[s]=t})),e}createFetchOptions(e){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PPHP_WIRE_REQUEST:"true"},body:JSON.stringify(e)}}parseCallback(e,t){let s={};const n=e.closest("form");if(n){new FormData(n).forEach(((e,t)=>{s[t]?Array.isArray(s[t])?s[t].push(e):s[t]=[s[t],e]:s[t]=e}))}else e instanceof HTMLInputElement?s=this.handleInputElement(e):(e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&(s[e.name]=e.value);const r=t.match(/^(\w+)\(([\s\S]*)\)$/);if(r){const e=r[1];let t=r[2].trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))if(this.isJsonLike(t))try{const e=this.parseJson(t);Array.isArray(e)?s.args=e:e&&"object"==typeof e&&(s={...s,...e})}catch(e){console.error("Error parsing JSON args:",e),s.rawArgs=t}else try{const e=this.evaluateJavaScriptObject(t);Array.isArray(e)?s.args=e:e&&"object"==typeof e?s={...s,...e}:s.rawArgs=t}catch(e){console.error("Error evaluating JS object args:",e),s.rawArgs=t}else try{const e=this.getOrCreateEvaluator(t)(this.props);s.args=[e]}catch{s.args=t.split(/,(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/).map((e=>e.trim().replace(/^['"]|['"]$/g,"")))}return{funcName:e,data:s}}return{funcName:t,data:s}}evaluateJavaScriptObject(e){try{const t=this.getOrCreateProxy(this.props);return new Function("proxy","Date","Math","JSON",`\n with (proxy) {\n return ${e};\n }\n `).call(null,t,Date,Math,JSON)}catch(e){throw console.error("Failed to evaluate JavaScript object:",e),e}}handleInputElement(e){let t={};if(e.name)if("checkbox"===e.type)t[e.name]={value:e.value,checked:e.checked};else if("radio"===e.type){const s=document.querySelector(`input[name="${e.name}"]:checked`);t[e.name]=s?s.value:null}else t[e.name]=e.value;else"checkbox"===e.type||"radio"===e.type?t.value=e.checked:t.value=e.value;return t}setCursorPosition(e,t){if(t.start)e.setSelectionRange(0,0);else if(t.end){const t=e.value.length||0;e.setSelectionRange(t,t)}else if(t.length){const s=parseInt(t.length,10)||0;e.setSelectionRange(s,s)}}handleInputAppendParams(e,t){const s=e.getAttribute("pp-append-params"),n=e.getAttribute("pp-append-params-sync");if("true"===s){if("true"===n){const t=e.name||e.id;if(t){const s=new URL(window.location.href),n=new URLSearchParams(s.search);n.has(t)&&(e.value=n.get(t)||"")}}e.addEventListener(t,(e=>{const t=e.currentTarget,s=t.value,n=new URL(window.location.href),r=new URLSearchParams(n.search),i=t.name||t.id;if(i){s?r.set(i,s):r.delete(i);const e=r.toString()?`${n.pathname}?${r.toString()}`:n.pathname;history.replaceState(null,"",e)}}))}}handleHiddenAttribute(){const e=document.querySelectorAll("[pp-visibility]"),t=document.querySelectorAll("[pp-display]"),s=this.handleElementVisibility.bind(this),n=this.handleElementDisplay.bind(this);e.forEach((e=>this.handleVisibilityElementAttribute(e,"pp-visibility",s))),t.forEach((e=>this.handleVisibilityElementAttribute(e,"pp-display",n)))}handleVisibilityElementAttribute(e,t,s){const n=e.getAttribute(t);if(n)if(this.isJsonLike(n)){s(e,this.parseJson(n))}else{const s=this.parseTime(n);if(s>0){const n="pp-visibility"===t?"visibility":"display",r="visibility"===n?"hidden":"none";this.scheduleChange(e,s,n,r)}}}handleElementVisibility(e,t){this.handleElementChange(e,t,"visibility","hidden","visible")}handleElementDisplay(e,t){this.handleElementChange(e,t,"display","none","block")}handleElementChange(e,t,s,n,r){const i=t.start?this.parseTime(t.start):0,a=t.end?this.parseTime(t.end):0;i>0?(e.style[s]=n,this.scheduleChange(e,i,s,r),a>0&&this.scheduleChange(e,i+a,s,n)):a>0&&this.scheduleChange(e,a,s,n)}handleAnchorTag(){document.querySelectorAll("a").forEach((e=>{e.addEventListener("click",(async e=>{const t=e.currentTarget,s=t.getAttribute("href"),n=t.getAttribute("target");if(s&&"_blank"!==n&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),!this._isNavigating)){this._isNavigating=!0;try{if(/^(https?:)?\/\//i.test(s)&&!s.startsWith(window.location.origin))window.location.href=s;else{const e=t.getAttribute("pp-append-params");if(s.startsWith("?")&&"true"===e){const e=new URL(window.location.href),t=new URLSearchParams(e.search);let n="";const[r,i]=s.split("#");i&&(n=`#${i}`);new URLSearchParams(r.split("?")[1]).forEach(((e,s)=>{t.set(s,e)}));const a=`${e.pathname}?${t.toString()}${n}`;history.pushState(null,"",a)}else{const[e,t]=s.split("#"),n=`${e}${t?`#${t}`:""}`;history.pushState(null,"",n)}const n=s.indexOf("#");if(-1!==n){const e=s.slice(n+1),t=document.getElementById(e);if(t)t.scrollIntoView({behavior:"smooth"});else{await this.handleNavigation();const t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth"})}}else await this.handleNavigation()}}catch(e){console.error("Anchor click error:",e)}finally{this._isNavigating=!1}}}))}))}handlePopState(){window.addEventListener("popstate",(async()=>{await this.handleNavigation()}))}async handleNavigation(){try{const e=document.getElementById("loading-file-1B87E");if(e){const t=this.findLoadingElement(e,window.location.pathname);t&&await this.updateContentWithTransition(t)}const t=await this.fetch(window.location.href);if(!t.ok)return void console.error(`Navigation error: ${t.status} ${t.statusText}`);const s=await t.text(),n=s.match(this._redirectRegex);if(n&&n[1])return void await this.redirect(n[1]);await this.updateDocumentContent(s)}catch(e){console.error("Navigation error:",e)}}findLoadingElement(e,t){let s=t;for(;;){const t=e.querySelector(`div[pp-loading-url='${s}']`);if(t)return t;if("/"===s)break;const n=s.lastIndexOf("/");s=n<=0?"/":s.substring(0,n)}return e.querySelector("div[pp-loading-url='/' ]")}async updateContentWithTransition(e){const t=document.querySelector("[pp-loading-content='true']")||document.body;if(!t)return;const{fadeIn:s,fadeOut:n}=this.parseTransition(e);await this.fadeOut(t,n),t.innerHTML=e.innerHTML,this.fadeIn(t,s)}parseTransition(e){let t=250,s=250;const n=e.querySelector("[pp-loading-transition]"),r=n?.getAttribute("pp-loading-transition");if(r){const e=this.parseJson(r);e&&"object"==typeof e?(t=this.parseTime(e.fadeIn??t),s=this.parseTime(e.fadeOut??s)):console.warn("pp-loading-transition is not valid JSON → default values (250 ms) will be used. String:",r)}return{fadeIn:t,fadeOut:s}}fadeOut(e,t){return new Promise((s=>{e.style.transition=`opacity ${t}ms ease-out`,e.style.opacity="0",setTimeout((()=>{e.style.transition="",s()}),t)}))}fadeIn(e,t){e.style.transition=`opacity ${t}ms ease-in`,e.style.opacity="1",setTimeout((()=>{e.style.transition=""}),t)}async updateDocumentContent(e){const t=this.saveScrollPositions(),s=this.sanitizePassiveHandlers(e),n=(new DOMParser).parseFromString(s,"text/html"),r="pp-dynamic-script",i="pp-dynamic-link";document.head.querySelectorAll("[pp-dynamic-meta]").forEach((e=>e.remove()));document.head.querySelectorAll(`[${i}]`).forEach((e=>e.remove()));document.head.querySelectorAll(`[${r}]`).forEach((e=>e.remove()));await(async e=>{Array.from(e.head.children).forEach((e=>{const t=e.tagName;if("SCRIPT"===t&&e.hasAttribute(r)){const t=document.createElement("script");Array.from(e.attributes).forEach((e=>t.setAttribute(e.name,e.value))),e.textContent&&(t.textContent=e.textContent),document.head.appendChild(t)}else if("META"===t){if(e.getAttribute("charset")||"viewport"===e.getAttribute("name"))return;const t=e.name,s=e.getAttribute("property"),n=document.head.querySelector(t?`meta[name="${t}"]`:`meta[property="${s}"]`),r=document.head.querySelector("title");n?document.head.replaceChild(e.cloneNode(!0),n):r?.nextSibling?document.head.insertBefore(e.cloneNode(!0),r.nextSibling):document.head.appendChild(e.cloneNode(!0))}else if("TITLE"===t){const t=document.head.querySelector("title");t?document.head.replaceChild(e.cloneNode(!0),t):document.head.appendChild(e.cloneNode(!0))}else if("LINK"===t){const t=t=>{const s=document.head.querySelector('link[rel="icon"]');if(s)document.head.replaceChild(e.cloneNode(!0),s);else{const e=document.createElement("link");e.rel="icon",e.href=t,document.head.appendChild(e)}};if("icon"===e.getAttribute("rel")){t(e.href)}else if(e.hasAttribute(i)){const t=e.cloneNode(!0);document.head.appendChild(t)}}})),await this.updateDocumentBody(e)})(n),this.restoreScrollPositions(t),this.resetProps(),await this.processInlineModuleScripts(),await this.initMakeReactive(),this.handlerAutofocusAttribute()}restoreScrollPositions(e){requestAnimationFrame((()=>{const t=e.window;t&&window.scrollTo(t.scrollLeft,t.scrollTop),document.querySelectorAll("*").forEach((t=>{const s=this.getElementKey(t);e[s]&&(t.scrollTop=e[s].scrollTop,t.scrollLeft=e[s].scrollLeft)}))}))}PRESERVE_HANDLERS={DETAILS:(e,t)=>(t.open=e.open,!0),INPUT(e,t){const s=e,n=t;return s.value!==n.value&&(n.value=s.value),n.checked=s.checked,document.activeElement!==s||(null!=s.selectionStart&&(n.selectionStart=s.selectionStart,n.selectionEnd=s.selectionEnd),!1)},TEXTAREA(e,t){const s=e,n=t;return s.value!==n.value&&(n.value=s.value),document.activeElement!==s||(n.selectionStart=s.selectionStart,n.selectionEnd=s.selectionEnd,!1)},SELECT(e,t){const s=e;return t.selectedIndex=s.selectedIndex,document.activeElement!==s},VIDEO(e,t){const s=e,n=t;return n.currentTime=s.currentTime,s.paused?n.pause():n.play(),!0},AUDIO:(e,t)=>this.PRESERVE_HANDLERS.VIDEO(e,t),CANVAS:()=>!1};async populateDocumentBody(e){try{const t=document.body,s=e.body;this._wheelHandlersStashed||(document.querySelectorAll("[onwheel]").forEach((e=>{const t=e.getAttribute("onwheel").trim();if(e.removeAttribute("onwheel"),t){const s=new Function("event",t);e.addEventListener("wheel",s,{passive:!0})}})),this._wheelHandlersStashed=!0);const n=this.PRESERVE_HANDLERS;morphdom(t,s,{getNodeKey(e){if(e.nodeType!==Node.ELEMENT_NODE)return;const t=e;return t.hasAttribute("pp-sync-script")?`pp-sync-script:${t.getAttribute("pp-sync-script")}`:t.getAttribute("key")||void 0},onBeforeElUpdated(e,t){const s=e.tagName;if("SCRIPT"===s||e.hasAttribute("data-nomorph"))return!1;const r=n[s];return!r||r(e,t)},onBeforeNodeDiscarded:e=>(e instanceof HTMLElement&&e.dataset.timerId&&clearTimeout(Number(e.dataset.timerId)),!0)})}catch(e){console.error("Error populating document body:",e)}}async updateDocumentBody(e){try{const t=e.body.cloneNode(!0);this.manageScriptTags(t),document.body.replaceWith(t)}catch(e){console.error("Error populating document body:",e)}}manageScriptTags(e,t){const s=e.querySelectorAll("script"),n=t?.querySelectorAll("script")||s;s.forEach(((e,t)=>{const s=document.createElement("script"),r=n[t]||e;Array.from(r.attributes).forEach((e=>{s.setAttribute(e.name,e.value)})),r.hasAttribute("src")||(s.textContent=r.textContent),e.parentNode?.replaceChild(s,e)}))}saveScrollPositions(){const e={window:{scrollTop:window.scrollY||document.documentElement.scrollTop,scrollLeft:window.scrollX||document.documentElement.scrollLeft}};return document.querySelectorAll("*").forEach((t=>{(t.scrollTop||t.scrollLeft)&&(e[this.getElementKey(t)]={scrollTop:t.scrollTop,scrollLeft:t.scrollLeft})})),e}getElementKey(e){return e.id||e.className||e.tagName}async redirect(e){if(e)try{const t=new URL(e,window.location.origin);t.origin!==window.location.origin?window.location.href=e:(history.pushState(null,"",e),await this.handleNavigation())}catch(e){console.error("Redirect error:",e)}}abortActiveRequest(){this._activeAbortController&&this._activeAbortController.abort()}async fetch(e,t,s=!1){let n;return s?(this._activeAbortController&&this._activeAbortController.abort(),this._activeAbortController=new AbortController,n=this._activeAbortController):n=new AbortController,fetch(e,{...t,signal:n.signal,headers:{...t?.headers,"X-Requested-With":"XMLHttpRequest"}})}isJsonLike(e){if("string"!=typeof e)return!1;const t=e.trim();return!(!/^\{[\s\S]*\}$/.test(t)&&!/^\[[\s\S]*\]$/.test(t))&&!(t.includes("(")||t.includes(")")||t.includes("=>"))}parseJson(e){try{return JSON5.parse(e)}catch(e){return console.error(`Error parsing JSON: ${e.message}. Please ensure the JSON string is valid.`,e),{}}}parseTime(e){if("number"==typeof e)return e;const t=e.match(/^(\d+)(ms|s|m)?$/);if(t){const e=parseInt(t[1],10);switch(t[2]||"ms"){case"ms":default:return e;case"s":return 1e3*e;case"m":return 60*e*1e3}}return 0}scheduleChange(e,t,s,n){setTimeout((()=>{requestAnimationFrame((()=>{e.style[s]=n}))}),t)}async fetchFunction(e,t={},s=!1){try{const n={callback:e,...t},r=window.location.href;let i;if(Object.keys(n).some((e=>{const t=n[e];return t instanceof File||t instanceof FileList&&t.length>0}))){const e=new FormData;Object.keys(n).forEach((t=>{const s=n[t];s instanceof File?e.append(t,s):s instanceof FileList?Array.from(s).forEach((s=>e.append(t,s))):e.append(t,s)})),i={method:"POST",headers:{HTTP_PPHP_WIRE_REQUEST:"true"},body:e}}else i=this.createFetchOptions(n);const a=await this.fetch(r,i,s);if(!a.ok)throw new Error(`Fetch failed with status: ${a.status} ${a.statusText}`);const o=await a.text();try{return JSON.parse(o)}catch{return o}}catch(e){throw console.error("Error in fetchFunction:",e),new Error("Failed to fetch data.")}}processSyncScripts(e){e.forEach((e=>{const t=`script[pp-sync-script="${CSS.escape(e)}"]`,s=document.querySelector(t);if(s){s.remove();const e=document.createElement("script");Array.from(s.attributes).forEach((t=>{e.setAttribute(t.name,t.value)})),s.src?e.src=s.src:e.textContent=s.textContent,e.type=s.type||"module",document.body.appendChild(e)}}))}async sync(...e){try{const t=this.saveScrollPositions();this.saveElementState();const s=e.length>0?e.map((e=>`pp-sync="${e}"`)):['pp-sync="true"'],n=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()}),r=await this.fetch(window.location.href,n),i=await r.text(),a=(new DOMParser).parseFromString(i,"text/html"),o=new Set;s.forEach((e=>{const t=document.querySelectorAll(`[${e}]`),s=a.body.querySelectorAll(`[${e}]`);t.forEach(((e,t)=>{const n=s[t];if(n){if(n.hasAttribute("pp-sync-script")){const e=n.getAttribute("pp-sync-script")||"";e&&o.add(e)}n.querySelectorAll("[pp-sync-script]").forEach((e=>{const t=e.getAttribute("pp-sync-script")||"";t&&o.add(t)})),e.innerHTML=n.innerHTML,this.reRunScripts(e)}}))})),this.processSyncScripts(o),this.restoreElementState(),this.restoreScrollPositions(t),this.attachWireFunctionEvents()}catch(e){console.error("Error in pphpSync:",e)}}async fetchAndUpdateBodyContent(){const e=this.createFetchOptions({secondRequestC69CD:!0,...this.getUrlParams()});this.abortActiveRequest();const t=await this.fetch(window.location.href,e,!0),s=await t.text();await this.updateBodyContent(s)}reRunScripts(e){e.querySelectorAll("script").forEach((e=>{const t=document.createElement("script");Array.from(e.attributes).forEach((e=>{t.setAttribute(e.name,e.value)})),e.hasAttribute("src")||(t.textContent=e.textContent),e.parentNode?.replaceChild(t,e)}))}copyCode(e,t,s,n,r="img",i=2e3){if(!(e instanceof HTMLElement))return;const a=e.closest(`.${t}`)?.querySelector("pre code"),o=a?.textContent?.trim()||"";o?navigator.clipboard.writeText(o).then((()=>{const t=e.querySelector(r);if(t)for(const[e,s]of Object.entries(n))e in t?t[e]=s:t.setAttribute(e,s);setTimeout((()=>{if(t)for(const[e,n]of Object.entries(s))e in t?t[e]=n:t.setAttribute(e,n)}),i)}),(()=>{alert("Failed to copy command to clipboard")})):alert("Failed to find the code block to copy")}getCookie(e){return document.cookie.split("; ").find((t=>t.startsWith(e+"=")))?.split("=")[1]||null}}class PPHPLocalStore{state;static instance=null;listeners;pphp;STORAGE_KEY;constructor(e={}){this.state=e,this.listeners=[],this.pphp=PPHP.instance,this.STORAGE_KEY=this.pphp.getCookie("pphp_local_store_key")||"pphp_local_store_59e13",this.loadState()}static getInstance(e={}){return PPHPLocalStore.instance||(PPHPLocalStore.instance=new PPHPLocalStore(e)),PPHPLocalStore.instance}setState(e,t=!1){if(this.state={...this.state,...e},this.listeners.forEach((e=>e(this.state))),this.saveState(),t){const e=localStorage.getItem(this.STORAGE_KEY);e&&this.pphp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:e})}}saveState(){localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.state))}loadState(){const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.state=this.pphp.parseJson(e),this.listeners.forEach((e=>e(this.state))))}resetState(e,t=!1){if(e?(delete this.state[e],this.saveState()):(this.state={},localStorage.removeItem(this.STORAGE_KEY)),this.listeners.forEach((e=>e(this.state))),t){const t=e?localStorage.getItem(this.STORAGE_KEY):null;this.pphp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:t})}}}class SearchParamsManager{static instance=null;listeners=[];constructor(){}static getInstance(){return SearchParamsManager.instance||(SearchParamsManager.instance=new SearchParamsManager),SearchParamsManager.instance}get params(){return new URLSearchParams(window.location.search)}get(e){return this.params.get(e)}set(e,t){const s=this.params;s.set(e,t),this.updateURL(s)}delete(e){const t=this.params;t.delete(e),this.updateURL(t)}replace(e){const t=new URLSearchParams;for(const s in e){const n=e[s];null!==n&&t.set(s,n)}this.updateURL(t,!0)}updateURL(e,t=!1){const s=`${window.location.pathname}?${e.toString()}`;t?history.replaceState(null,"",s):history.pushState(null,"",s),this.notifyListeners(e)}listen(e){this.listeners.push(e)}notifyListeners(e){for(const t of this.listeners)t(e)}enablePopStateListener(){window.addEventListener("popstate",(()=>{this.notifyListeners(this.params)}))}}var pphp=PPHP.instance,store=PPHPLocalStore.getInstance(),searchParams=SearchParamsManager.getInstance();
|