@webqit/oohtml 3.1.7 → 3.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,11 +5,11 @@
5
5
  [![bundle][bundle-src]][bundle-href]
6
6
  [![License][license-src]][license-href]
7
7
 
8
- **[On the Agenda](#on-the-agenda) • [Modular HTML](#modular-html) • [HTML Imports](#html-imports) • [Data Binding](#data-binding) • [Data Plumbing](#data-plumbing) • [Polyfill](#polyfill) • [Examples](#examples) • [License](#license)**
8
+ **[Explainer](#explainer) • [On the Agenda](#on-the-agenda) • [Modular HTML](#modular-html) • [HTML Imports](#html-imports) • [Data Binding](#data-binding) • [Data Plumbing](#data-plumbing) • [Polyfill](#polyfill) • [Examples](#examples) • [License](#license)**
9
9
 
10
- Object-Oriented HTML (OOHTML) is a set of features that extend standard HTML and the DOM to enable authoring modular, reusable and reactive markup - with a "buildless", web-native workflow as design goal! This project presents what "modern HTML" could mean today!
10
+ Object-Oriented HTML (OOHTML) is a set of features that extend standard HTML and the DOM to enable authoring modular, reusable and reactive markup - with a "buildless" and intuitive workflow as design goal! This project revisits the HTML problem space to solve for an object-oriented approach to HTML!
11
11
 
12
- Building Single Page Applications? OOHTML is a special love letter!
12
+ Building Single Page Applications? OOHTML is a special love letter! Writing Web Components? Now you can do that with zero tooling! Love vanilla HTML but can't go far with that? Now you can!
13
13
 
14
14
  <details><summary>Versions</summary>
15
15
 
@@ -17,17 +17,17 @@ Building Single Page Applications? OOHTML is a special love letter!
17
17
 
18
18
  </details>
19
19
 
20
- ## Motivation
20
+ ## Explainer
21
21
 
22
22
  <details><summary>Show</summary>
23
23
 
24
- Vanilla HTML is unsurprisingly becoming the most compelling option for an increasing number of developers! But the current authoring experience still leaves much to be desired in how the language lacks modularity, reusability, and other fundamental capabilities like data binding! Authors still have to rely on tools - or, to say the least, have to do half of the work in HTML and half in JS - to get even basic things working!
24
+ Amidst a multitude of approaches, vanilla HTML remains an attractive option for the UI author! But the current authoring experience still leaves much to be desired in how the language lacks modularity, reusability, and certain modern paradigms like data binding! Authors still have to rely on tools - and, for the most part, have to do half of the work in HTML and half in JS - to express even basic concepts!
25
25
 
26
- This project pursues an object-oriented approach to HTML and implicitly revisits much of what inhibits the idea of a *component* architecture for HTML!
26
+ "As an author, I want to be able to do 'x' *declaratively* instead of *imperatively* in JavaScript or by means of a special Custom Element!" "As a Web Component author, I want to be able to leverage *conventions* that keep my component logic *concise*!" All such "user stories" represent important developer intuitions that has yet to be met in HTML; much of which belong under a broad subject: an object-oriented markup language! This subject is what we explore with OOHTML!
27
27
 
28
- <!--
29
- └ [See more in the introductory blog post](https://dev.to/oxharris/the-web-native-equations-1m1p-temp-slug-6661657?preview=ba70ad2c17f05b5761bc74516dbde8c9eff8b581a0420d87334fd9ef6bab9d6e6d3ab6aaf3fe02542bb9e7250d0a88a6df91dae40919aabcc9a07320)<sup>draft</sup>
30
- -->
28
+ OOHTML comes, not as a specific technology, but as a conceptual "framework" of features that solves for HTML as an object-oriented language - whether that means re-aligning existing features or introducing new ones! While features may be discussed or explored individually, the one agenda "Object-Oriented HTML" helps us stay aligned with the original problem! Each of these features has been introduced below with a small explainer.
29
+
30
+ OOHTML is effectively different from Web Components (and from the related Declarative Custom Elements and Declarative Shadow DOM efforts) in its focus on "arbitrary" HTML and the DOM rather than on just the Custom Element or Shadow DOM "subset" of the language. This in turns lets us have a niftier authoring experience in Web Components as the latter actually just relies on the very HTML and DOM.
31
31
 
32
32
  </details>
33
33
 
@@ -48,7 +48,7 @@ OOHTML makes this possible by introducing "namespacing" and style and script sco
48
48
 
49
49
  Naming things is hard! That's especially so where you have one global namespace and a miriad of potentially conflicting names to coordinate!
50
50
 
51
- Here, we get the `namespace` attribute for designating an element as own naming context for identifiers instead of the global document namespace:
51
+ Here, we get the `namespace` attribute for designating an element as own naming context for identifiers in its subtree:
52
52
 
53
53
  ```html
54
54
  <div id="user" namespace>
@@ -126,7 +126,7 @@ console.log(window.foo); // div
126
126
 
127
127
  ### Style and Script Scoping
128
128
 
129
- We often need a way to keep things like component-specific stylesheets and scripts [scoped to a component](https://vuejs.org/guide/scaling-up/sfc.html).
129
+ We often need a way to keep component-specific stylesheets and scripts [scoped to a component](https://vuejs.org/guide/scaling-up/sfc.html). **This is especially crucial to "page components" in an SPA architecture.**
130
130
 
131
131
  Here, we get the `scoped` attribute for doing just that:
132
132
 
@@ -161,15 +161,48 @@ Here, the `scoped` attribute has two effects on the `<script>` element:
161
161
 
162
162
  ## HTML Imports
163
163
 
164
- HTML Imports is a realtime module system for HTML that speaks HTML! Something like it is the [`<defs>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs) and [`<use>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use) system in SVG.
164
+ HTML Imports is a realtime *import* system for HTML that's drawn entirely on HTML - and that's worlds apart from [the abandoned `<link type="import">` feature](https://www.w3.org/TR/html-imports/) and the [HTML Modules proposal](https://github.com/WICG/webcomponents/blob/gh-pages/proposals/html-modules-explainer.md)! **Something like it is the [`<defs>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs) and [`<use>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use) system in SVG.**
165
+
166
+ Here, we get a way to have both the definition and usage of a snippet based out of *same* document:
167
+
168
+ ```html
169
+ <head>
170
+
171
+ <template def="foo">
172
+ <div></div>
173
+ </template>
174
+
175
+ </head>
176
+ <body>
177
+
178
+ <import ref="foo"></import>
179
+
180
+ </body>
181
+ ```
182
+
183
+ ...and optionally support remote documents without a change in paradigm:
184
+
185
+ ```html
186
+ <head>
187
+
188
+ <template def="foo" src="/foo.html"></template>
189
+
190
+ </head>
191
+ <body>
192
+
193
+ <import ref="foo"></import>
194
+
195
+ </body>
196
+ ```
197
+
165
198
 
166
- OOHTML makes this possible in just simple conventions - via a new `def` attribute and a complementary new `<import>` element!
199
+ OOHTML makes this possible in a simple new `def` attribute and a complementary new `<import>` element!
167
200
 
168
201
  ### Module Definition
169
202
 
170
- A module here is any piece of markup that can be reused.
203
+ A "module" here is any piece of markup that can be reused.
171
204
 
172
- Here, we get the `def` attribute for defining those - both at the `<template>` element level and at its contents (*fragment*) level:
205
+ Here, we get the `def` attribute for defining those - both at the `<template>` element level and at its direct children (*fragments*) level:
173
206
 
174
207
  ```html
175
208
  <head>
@@ -203,7 +236,7 @@ Here, we get the `def` attribute for defining those - both at the `<template>` e
203
236
 
204
237
  We shouldn't need a different mechanism to work with remote content.
205
238
 
206
- Here, we get remote-loading modules with same `<template>` element using the `src` attribute:
239
+ Here, OOHTML introduces an `src` attribute that lets us have self-loading `<template>` elements:
207
240
 
208
241
  ```html
209
242
  <template def="foo" src="/foo.html"></template>
@@ -222,7 +255,7 @@ Here, we get remote-loading modules with same `<template>` element using the `sr
222
255
  <div def="fragment2"></div>
223
256
  ```
224
257
 
225
- **-->** *which borrow from how `src` works in elements like `<img>`; terminating with either a `load` or an `error` event*:
258
+ **-->** *which just draws on the existing semantics of `src` in elements like `<img>`; terminating with either a `load` or an `error` event*:
226
259
 
227
260
  ```js
228
261
  foo.addEventListener('load', loadCallback);
@@ -231,9 +264,7 @@ foo.addEventListener('error', errorCallback);
231
264
 
232
265
  ### Declarative Module Imports
233
266
 
234
- HTML snippets should be reusable in HTML itself!
235
-
236
- Here, we get an `<import>` element that lets us do just that:
267
+ HTML snippets should be reusable entire out of HTML! So, we get an `<import>` element that lets us do just that:
237
268
 
238
269
  ```html
239
270
  <body>
@@ -253,12 +284,12 @@ Here, we get an `<import>` element that lets us do just that:
253
284
 
254
285
  Here, import *refs* are live bindings that are sensitive to:
255
286
 
256
- + changes in the *ref* itself (as to getting defined/undefined/redefined)
257
- + changes in the referenced *defs* themselves (as to becoming available/loaded/unavailable)
287
+ + changes in the *ref* itself (as to *refs* that are later defined/undefined/redefined)
288
+ + changes in the referenced *defs* themselves (as to these later becoming available/loaded/unavailable)
258
289
 
259
290
  And an `<import>` element that has been resolved will self-restore in the event that:
260
291
 
261
- + the above changes resolve to no imports.
292
+ + the above changes invalidate the reference.
262
293
  + the previously slotted contents have *all* been programmatically removed and slot is empty.
263
294
 
264
295
  </details>
@@ -433,14 +464,14 @@ Here, we get module nesting with inheritance to facilitate more reusability:
433
464
 
434
465
  We should be able to have *relative* import refs that resolve against local contexts in the document tree.
435
466
 
436
- Here, we get just that - as "Imports Contexts", which could be:
467
+ Here, we call these "Imports Contexts", and these could be:
437
468
 
438
469
  + Simple Base Path Contexts ([below](#base-path-contexts))
439
470
  + Scoped Module Contexts ([below](#scoped-module-contexts))
440
471
  + Named Contexts ([below](#named-contexts))
441
472
  + Extended Scoped Module Contexts ([below](#extended-scoped-module-contexts))
442
473
 
443
- And to facilitate thinking in contexts, we also get an `Element.prototype.import()` API for context-based module imports.
474
+ And to facilitate working with contexts, we also get an `Element.prototype.import()` API that is context-aware.
444
475
 
445
476
  #### "Base Path" Contexts
446
477
 
@@ -493,14 +524,14 @@ const response = contextElement.import('#fragment1'); // Relative path (beginnin
493
524
  ```js
494
525
  // Using the HTMLImports API to import from context
495
526
  const contextElement = document.querySelector('main');
496
- const response = contextElement.import('#fragment1'); // Relative path (beginning without a slash), resolving to: /foo/nested#fragment1
527
+ const response = contextElement.import('#fragment2'); // Relative path (beginning without a slash), resolving to: /foo/nested#fragment2
497
528
  ```
498
529
 
499
530
  #### "Scoped Module" Contexts
500
531
 
501
532
  Some modules will only be relevant within a specific context in the page, and those wouldn't need to have a business with the global scope.
502
533
 
503
- Here, we get the `scoped` attribute for scoping those to their respective contexts, to give us an *object-scoped* module system (like what Scoped Registries seek to be to Custom Elements):
534
+ Here, we get the `scoped` attribute for scoping those to their respective hosts, to give us an *object-scoped* module system (like what Scoped Registries seek to be to Custom Elements):
504
535
 
505
536
  ```html
506
537
  <section> <!-- Host object -->
@@ -522,7 +553,7 @@ Here, we get the `scoped` attribute for scoping those to their respective contex
522
553
  ```js
523
554
  // Using the HTMLImports API for local import
524
555
  const contextElement = document.querySelector('div');
525
- const localModule = moduleHost.import('#fragment1'); // Relative path (beginning without a slash), resolving to the local module: foo#fragment1
556
+ const localModule = moduleHost.import('foo#fragment1'); // Relative path (beginning without a slash), resolving to the local module: foo#fragment1
526
557
  ```
527
558
 
528
559
  ```js
@@ -588,22 +619,22 @@ Scoped Module Contexts may also have a Base Path Context that they inherit from:
588
619
  ```js
589
620
  // Using the HTMLImports API
590
621
  const contextElement = document.querySelector('div');
591
- const result = contextElement.import('#fragment2'); // the local module: foo#fragment2, and if not found, the inherited module: /bar/nested#fragment2
622
+ const result = contextElement.import('foo#fragment2'); // the local module: foo#fragment2, and if not found, the inherited module: /bar/nested#fragment2
592
623
  ```
593
624
 
594
625
  </details>
595
626
 
596
627
  ## Data Binding
597
628
 
598
- Data binding is about declaratively binding the UI to application data, wherein the relevant parts of the UI *automatically* update as application state changes.
629
+ Data binding is a declarative approach to binding the UI to application data, wherein the relevant parts of the UI *automatically* update as application state changes.
599
630
 
600
631
  OOHTML makes this possible in just simple conventions - via a new comment-based data-binding syntax `<?{ }?>` and a complementary new `expr` attribute!
601
632
 
602
- And there's one more: Quantum Scripts for when we need to write extended reactive logic on the UI!
633
+ And for when we need to write extended reactive logic on the UI, a perfect answer: Quantum Scripts!
603
634
 
604
635
  ### Discrete Data-Binding
605
636
 
606
- Here, we get a comment-based data-binding tag `<?{ }?>` which gives us a regular HTML comment but also an insertion point for application data:
637
+ Here, we get a comment-based data-binding tag `<?{ }?>` (or `<!--?{ }?-->`), **which goes as a regular HTML comment** but also an insertion point for application data:
607
638
 
608
639
  ```js
609
640
  <html>
@@ -620,7 +651,7 @@ Here, we get a comment-based data-binding tag `<?{ }?>` which gives us a regular
620
651
 
621
652
  <details><summary>Resolution details</summary>
622
653
 
623
- Here, JavaScript references are resolved from the closest node up the document tree that exposes a corresponding *binding* on its Bindings API ([discussed below](#bindings-api)). Thus, for the above markup, our underlying data structure could be something like the below:
654
+ Here, JavaScript references are resolved from the closest node up the document tree that exposes a corresponding *binding* on its Bindings API ([discussed below](#bindings-api)). For the above markup, our underlying data structure could be something like the below:
624
655
 
625
656
  ```js
626
657
  document.bind({ name: 'James Boye', cool: '100%', app: { title: 'Demo App' } });
@@ -668,7 +699,7 @@ Now, on getting to the client, that extra bit of information gets decoded, and o
668
699
 
669
700
  ### Inline Data-Binding
670
701
 
671
- Here, we get the `expr` attribute for a declarative, neat, key/value data-binding syntax:
702
+ For attribute-based data binding, OOHTML deviates from the usual (and problematic) idea of bringing markup-style bindings into attribute texts: `title="Hello { titleValue }"`, **as though attributes had the same semantics as markup**. Instead, we get a dedicated "expressions" attribute - `expr` - for a nifty, key/value data-binding language:
672
703
 
673
704
  ```html
674
705
  <div expr="<directive> <param>: <arg>;"></div>
@@ -727,7 +758,7 @@ Here, we get the `expr` attribute for a declarative, neat, key/value data-bindin
727
758
 
728
759
  <details><summary>Resolution details</summary>
729
760
 
730
- Here, JavaScript references are resolved from the closest node up the document tree that exposes a corresponding *binding* on its Bindings API ([discussed below](#bindings-api)). Thus, for the above CSS bindings, our underlying data structure could be something like the below:
761
+ Here, JavaScript references are resolved from the closest node up the document tree that exposes a corresponding *binding* on its Bindings API ([discussed below](#bindings-api)). For the above CSS bindings, our underlying data structure could be something like the below:
731
762
 
732
763
  ```js
733
764
  document.bind({ someColor: 'green', someBgColor: 'yellow' });
@@ -882,7 +913,7 @@ But while that is automatic, DOM event handlers bound via `addEventListener()` w
882
913
 
883
914
  ## Data Plumbing
884
915
 
885
- Components often need to manage, and be managed by, dynamic data. That could get pretty problematic and messy if all of that should go on DOM nodes as direct properties:
916
+ Components often need to manage, and be driven by, dynamic application state. That could get pretty problematic and messy if all of that should go on DOM nodes as direct properties:
886
917
 
887
918
  <details><summary>Example</summary>
888
919
 
@@ -1210,11 +1241,11 @@ Now, by design...
1210
1241
  └── body:
1211
1242
  ```
1212
1243
 
1213
- While, in all, the requesting code is saved that "admin" work!
1244
+ While, in all, the requesting code is spared all of that "admin" work!
1214
1245
 
1215
1246
  </details>
1216
1247
 
1217
- **-->** *all of which gives us a standardized API underneath context-based features in HTML - like HTMLImports and Data Binding*:
1248
+ **-->** *all of which gives us a standardized API across context-based features in HTML - like HTMLImports and Data Binding*:
1218
1249
 
1219
1250
  ```html
1220
1251
  <div contextname="vendor1">
@@ -1261,7 +1292,7 @@ console.log(response.value.title);
1261
1292
 
1262
1293
  ## Polyfill
1263
1294
 
1264
- OOHTML is being developed as something to be used today—via a polyfill. This is an intentional effort that has continued to ensure that the proposal evolves through a practice-driven process.
1295
+ OOHTML is being developed as something to be used today—via a polyfill. This is an intentional effort that in turn ensures that the proposal evolves through a practice-driven process.
1265
1296
 
1266
1297
  <details><summary>Load from a CDN<br>
1267
1298
  └───────── <a href="https://bundlephobia.com/result?p=@webqit/oohtml"><img align="right" src="https://img.shields.io/badge/21.8%20kB-black"></a></summary>
@@ -1318,7 +1349,7 @@ If you'll be going ahead to build a real app with OOHTML, you may want to consid
1318
1349
 
1319
1350
  + **Scoped/Quantum Scripts**. This feature is an extension of [Quantum JS](https://github.com/webqit/quantum-js). While the main OOHTML build is based on the main Quantum JS APIs, a companion "OOHTML Lite" build is also available based on the [Quantum JS Lite](https://github.com/webqit/quantum-js#quantum-js-lite) edition. The trade-off is in the execution timing of `<script quantum></script>` and `<script scoped></script>` elements: being "synchronous/blocking" with the former, and "asynchronous/non-blocking" with the latter! (See [`async`/`defer`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attributes).)
1320
1351
 
1321
- Of the two, the "OOHTML Lite" edition is the recommend option (as used above) for faster load times unless there's a requirment to have classic scripts follow their [native synchronous timing](https://html.spec.whatwg.org/multipage/parsing.html#scripts-that-modify-the-page-as-it-is-being-parsed), in which case you'd need the main OOHTML build:
1352
+ Of the two, the "OOHTML Lite" edition is the recommend option on web pages (as used above) for faster load times unless there's a requirment to emulate the [native synchronous timing](https://html.spec.whatwg.org/multipage/parsing.html#scripts-that-modify-the-page-as-it-is-being-parsed) of classic scripts, in which case you'd need the main OOHTML build:
1322
1353
 
1323
1354
  ```html
1324
1355
  <head>
@@ -1389,17 +1420,86 @@ If you'll be going ahead to build a real app with OOHTML, you may want to consid
1389
1420
  <script src="https://unpkg.com/style-scoped/scoped.min.js"></script>
1390
1421
  ```
1391
1422
 
1392
- + **HTML Imports**. The attribute names for exposing reusable modules and for referencing them - the `def` and `ref` keywords, respectively - aren't finalized. While the principle of operation remains, these attributes may be renamed in subsequent iterations. But the polyfill is designed to always defer to any syntax that has been explicitly specified using a meta tag. Here's an example:
1423
+ + **Syntax**. The syntax for attribute names and API names across features - e.g. the `def` and `ref` attributes, the `expr` attribute - isn't finalized, and may change on subsequent iterations, albeit with same principle of operation. But the polyfill is designed to be configurable via meta tags, and to honour any such "overrides". Here's an example:
1393
1424
 
1394
1425
  ```html
1395
1426
  <head>
1396
- <meta name="html-imports" content="template.attr.moduledef=def; template.attr.fragmentdef=def; import.attr.moduleref=ref;"> <!-- Must come before the polyfil -->
1427
+ <!-- Configurations come before the polyfil -->
1428
+ <meta name="data-binding" content="attr.expr=expr;">
1429
+ <meta name="namespaced-html" content="attr.id=id;">
1430
+ <meta name="html-imports" content="attr.def=def; attr.ref=ref;">
1397
1431
  <script src="https://unpkg.com/@webqit/oohtml/dist/main.js"></script>
1398
1432
  <head>
1399
1433
  ```
1400
1434
 
1401
- Now, even when the default attribute names change, your `def` and `ref` implementation will still work:
1402
-
1435
+ Now, even when the default syntax change, your `def`, `ref`, etc. overrides will keep your implementation intact.
1436
+
1437
+ Additionally, you could employ a global prefix in your implementation:
1438
+
1439
+ ```html
1440
+ <meta name="webqit" content="prefix=wq;">
1441
+ ```
1442
+
1443
+ ...which automatically applies to all `webqit` attributes and APIs (with the exception of the `scoped`, `quantum`, and `data-*` attributes), such that:
1444
+
1445
+ + `<template def="foo"></template>` now becomes: `<template wq-def="foo"></template>`,
1446
+ + `<import ref="foo"></import>` now becomes: `<wq-import wq-ref="foo"></wq-import>`,
1447
+ + `document.import()` now becomes: `document.wqImport()`,
1448
+ + `document.bind()` now becomes: `document.wqBind()`,
1449
+ + `document.bindings` now becomes: `document.wqBindings`,
1450
+ + etc.
1451
+
1452
+ The following is the full syntax table.
1453
+
1454
+ Spec: **data-binding**
1455
+
1456
+ | Config | Default Syntax | Description |
1457
+ | :----- | :------------- | :---------- |
1458
+ | `attr.expr` | `expr` | The "expr" attribute for inline data binding. ([Docs](#inline-data-binding)) |
1459
+ | `attr.itemIndex` | `data-index` | The "item index" attribute for assigning indexes to list items. ([Docs](#inline-data-binding)) |
1460
+
1461
+ Spec: **bindings-api**
1462
+
1463
+ | Config | Default Syntax | Description |
1464
+ | :----- | :------------- | :---------- |
1465
+ | `attr.bindingsreflection` | `bindings` | The attribute for exposing an element's bindings. |
1466
+ | `api.bind` | `bind` | The `document.bind()` and `Element.prototype.bind()` methods. ([Docs](#the-bindings-api)) |
1467
+ | `api.bindings` | `bindings` | The `document.bindings` and `Element.prototype.bindings` object properties. ([Docs](#the-bindings-api)) |
1468
+
1469
+ Spec: **context-api**
1470
+
1471
+ | Config | Default Syntax | Description |
1472
+ | :----- | :------------- | :---------- |
1473
+ | `attr.contextname` | `contextname` | The "context name" attribute on arbitrary elements. ([Docs](#the-context-api)) |
1474
+ | `api.contexts` | `contexts` | The `document.contexts` and `Element.prototype.contexts` object properties. ([Docs](#the-context-api)) |
1475
+
1476
+ Spec: **html-imports**
1477
+
1478
+ | Config | Default Syntax | Description |
1479
+ | :----- | :------------- | :---------- |
1480
+ | `elements.import` | `import` | The tag name for "import" elements. ([Docs](#html-imports)) |
1481
+ | `attr.def` | `def` | The "definition" attribute on the `<template>` elements. ([Docs](#module-definition)) |
1482
+ | `attr.fragmentdef` | *Inherits the value of `attr.def`* | The "definition" attribute on a `<template>`'s contents. ([Docs](#module-definition)) |
1483
+ | `attr.extends` | `extends` | The "extends" attribute for extending definitions. ([Docs](#module-inheritance)) |
1484
+ | `attr.inherits` | `inherits` | The "inherits" attribute for inheriting definitions. ([Docs](#module-inheritance)) |
1485
+ | `attr.ref` | `ref` | The "import ref" attribute on "import" elements. ([Docs](#declarative-module-imports)) |
1486
+ | `attr.importscontext` | `importscontext` | The "importscontext" attribute on arbitrary elements. ([Docs](#imports-contexts)) |
1487
+ | `api.def` | `def` | The readonly string property for accessing an element's "def" value. ([Docs](#module-definition)) |
1488
+ | `api.defs` | `defs` | The readonly object property for accessing a `<template>`'s list of definitions. ([Docs](#module-definition)) |
1489
+ | `api.import` | `import` | The `document.import()` and `Element.prototype.import()` methods. ([Docs](#imperative-module-imports)) |
1490
+
1491
+ Spec: **namespaced-html**
1492
+
1493
+ | Config | Default Syntax | Description |
1494
+ | :----- | :------------- | :---------- |
1495
+ | `attr.namespace` | `namespace` | The "namespace" attribute on arbitrary elements. ([Docs](#namespacing)) |
1496
+ | `attr.id` | `id` | The "id" attribute on arbitrary elements. ([Docs](#namespacing)) |
1497
+ | `api.namespace` | `namespace` | The "namespace" object property on arbitrary elements. ([Docs](#namespacing)) |
1498
+
1499
+ Spec: **scoped-css** (TODO)
1500
+
1501
+ Spec: **scoped-js** (TODO)
1502
+
1403
1503
  </details>
1404
1504
 
1405
1505
  ## Examples
@@ -1,2 +1,2 @@
1
- (()=>{var Vt=Object.defineProperty;var Wt=(n,t,r)=>t in n?Vt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var tt=(n,t,r)=>(Wt(n,typeof t!="symbol"?t+"":t,r),r);function w(n){return!Array.isArray(n)&&typeof n=="object"&&n}function y(n){return Array.isArray(n)}function ot(n,t,r=null){return y(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function $(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new W}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new W,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new W,i.set(e,r));return r}var W=class extends Map{constructor(...t){super(...t),this.observers=new Set}set(t,r){let e=super.set(t,r);return this.fire("set",t,r,t),e}delete(t){let r=super.delete(t);return this.fire("delete",t),r}has(t){return this.fire("has",t),super.has(t)}get(t){return this.fire("get",t),super.get(t)}keyNames(){return Array.from(super.keys())}observe(t,r,e){let i={type:t,key:r,callback:e};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(t,r,e){if(Array.isArray(t)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(et([t,"*"],i.type)&&et([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(et([t,"*"],i.type)&&et([r,"*"],i.key))||i.callback(...e)}},et=(n,t)=>Array.isArray(t)?ot(n,t).length:n.includes(t);function N(n){return typeof n=="function"}function B(n){return n===null||n===""}function I(n){return arguments.length&&(n===void 0||typeof n>"u")}function v(n){return Array.isArray(n)||typeof n=="object"&&n||N(n)}function st(n){return B(n)||I(n)||n===!1||n===0||v(n)&&!Object.keys(n).length}function b(n){return N(n)||n&&{}.toString.call(n)==="[object function]"}function G(n){return n instanceof Number||typeof n=="number"}function C(n){return G(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function R(n){return n instanceof String||typeof n=="string"&&n!==null}function ft(n){return!R(n)&&!I(n.length)}function rt(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function lt(e,t){t=t||Object.prototype,t=t&&!y(t)?[t]:t;for(var r=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)r.push(e),e=e?Object.getPrototypeOf(e):null;return r}function ct(n,t){var r=[];return lt(n,t).forEach(e=>{rt(r,...Object.getOwnPropertyNames(e))}),r}function T(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((C(s)||s===!0||s===!1)&&(o=s,s=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((f,m)=>{!v(f)&&!b(f)||(r?ct(f):Object.keys(f)).forEach(u=>{if(!!t(u,s,f,m)){var l=s[u],a=f[u];if((y(l)&&y(a)||w(l)&&w(a))&&(o===!0||o>0))s[u]=y(l)&&y(a)?[]:{},T([C(o)?o-1:o,s[u],l,a],t,r,e,i);else if(y(s)&&y(f))e?s[u]=a:s.push(a);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(f,u)):s[u]=f[u]}catch{}}})}),s}function X(...n){return T(n,(t,r,e)=>!0,!1,!1,!1)}function A(n,t=!0){return y(n)?n:!t&&w(n)?[n]:n!==!1&&n!==0&&st(n)?[]:ft(n)?Array.prototype.slice.call(n):w(n)?Object.values(n):[n]}function U(n,t,r={},e={}){t=A(t).slice();for(var i=n;!I(i)&&!B(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):v(i)?o in i:i[o])){e.exists=!1;return}i=r.get?r.get(i,o):i[o]}return e.exists=!0,i}function at(n,t,r,e={},i={}){let o=(l,a,c)=>i.set?i.set(l,a,c):(C(t[f])&&y(l)?l.push(c):l[a]=c,!0);t=A(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!v(s)&&!b(s))return!1;var m=U(s,t[f],i);if(!v(m)){if(i.buildTree===!1)return!1;m=b(i.buildTree)?i.buildTree(f):C(t[f+1])?[]:{};var u=o(s,t[f],m);if(!u)return!1}s=m}else return o(s,t[f],r)}var z=class{constructor(t,r=!0){Object.defineProperty(this,"window",{value:t}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),this.async=r,this.window.requestAnimationFrame?this._run():this.async=!1}_run(){this.window.requestAnimationFrame(()=>{for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t);this._run()})}onread(t,r=!1){if(r)return new Promise(e=>{this.async===!1?e(t()):this.readCallbacks.add(()=>{e(t())})});this.async===!1?t():this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.async===!1?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.async===!1?t():this.writeCallbacks.add(t)}cycle(t,r,e){this.onread(()=>{let i=t(e),o=s=>{s!==void 0&&this.onwrite(()=>{let f=r(s,e),m=u=>{u!==void 0&&this.cycle(t,r,u)};f instanceof Promise?f.then(m):m(f)})};i instanceof Promise?i.then(o):o(i)})}};function Et(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function it(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(f=>(f+"").replace("(",e?"(.//":"(./")).join("|");let i=n.document.evaluate(r,t,null,XPathResult.ANY_TYPE),o=[],s;for(;s=i.iterateNext();)o.push(s);return o}function Ct(n,t,r){return r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|"),n.document.evaluate(`${r}`,t,null,XPathResult.BOOLEAN_TYPE).booleanValue}function St(n,t="|"){return[...n].reduce(([r,e,i,o],s)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(s)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,e,i]),[null,0,[""]])[2].reverse()}var S=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Et(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=St(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var D=class{constructor(t,r,e){this.context=t,this.namespace=r,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(b(t[0])?t=[[],...t]:w(t[0])&&!(t[0]instanceof S)&&t.length===1?t=[[],void 0,t[0]]:w(t[1])&&t.length===2?t=[A(t[0],!1),void 0,t[1]]:t[0]=A(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof S)&&!(r instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return t[0]=t[0].map(r=>r instanceof S?r:new S(r)),t}registry(...t){return $("realdom.realtime",this.window,this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,o=Array.isArray(r)?r:[r],s=new Set;for(let[f,m]of this.registry(t))for(let[u,l]of m){let a=o.filter(c=>u.contains(c.target)?f==="subtree"||c.target===u:!1);if(!!a.length){Array.isArray(r)||(a=a[0]);for(let c of l)s.add([c,a,u])}}for(let[f,m,u]of s)e.call(i,f,m,u)}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&b(i.disconnect)&&i.disconnect()||b(i)&&i()||w(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var k=class extends D{constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof S;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=Mt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let m of s){let u=f?.generate()||{};r(m,u,o)}else{let m=f?.generate()||{};r(s,m,o)}if(e.live){f&&(e={...e,signalGenerator:f});let m=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,m)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof S;if([t=[],r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Pt.call(s,"intercept",()=>{});let m=new s.MutationObserver(c=>{c=It(c).map(p=>kt.call(s,p)),qt.call(s,a,c,o)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree};t.length&&(u.attributeFilter=t.map(c=>c+"")),m.observe(o,u);let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:m};return this.disconnectables(e.signal,m,l)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof S;[t,r,e={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let f=e.timing==="intercept"?"intercept":"sync",m=e.subtree?"subtree":"children";this.registry(f).size||Pt.call(s,f,_=>{this.forEachMatchingContext(f,_,qt)});let u={disconnect(){p.delete(a),p.size||c.delete(o)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:u},c=this.registry(f,m);c.has(o)||c.set(o,new Set);let p=c.get(o);return p.add(a),this.disconnectables(e.signal,u,l)}};function It(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName?t:t.concat(r),[])}function qt(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:m}=n,u=e.map(c=>c+"");if(o.atomic&&!s.size?t=Mt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(c=>u.includes(c.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(c=>{let p;return o.eventDetails||({event:p,...c}=c),!o.oldValue&&"oldValue"in c&&({oldValue:p,...c}=c),!o.newValue&&"value"in c?{value:p,...c}=c:o.newValue&&typeof c.value>"u"&&(c={...c,value:c.target.getAttribute(c.name)}),c})),o.atomic&&(t.forEach(c=>s.set(c.name,c)),t=Array.from(s.entries()).map(([,c])=>c));let l=f?t[0]:t,a=m?.generate()||{};i(l,a,r)}function Mt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:n.getAttribute(o),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:o.nodeValue,...e})}function kt({target:n,attributeName:t,value:r,oldValue:e}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:s}}function Pt(n,t){let r=this,{webqit:e,document:i,Element:o}=r;e.realdom.attrInterceptionHooks||Object.defineProperty(e.realdom,"attrInterceptionHooks",{value:new Map}),e.realdom.attrInterceptionHooks.has(n)||e.realdom.attrInterceptionHooks.set(n,new Set),e.realdom.attrInterceptionHooks.get(n).add(t);let s=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(l,a)=>{e.realdom.attrInterceptionRecords.has(l.target)||e.realdom.attrInterceptionRecords.set(l.target,{});let c=e.realdom.attrInterceptionRecords.get(l.target);c[l.name]=c[l.name]||[],c[l.name].unshift(l.event),e.realdom.attrInterceptionHooks.get("intercept")?.forEach(_=>_([l]));let p=a();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(_=>_([l])),p};new r.MutationObserver(l=>{l=l.filter(a=>!(r.webqit.realdom.attrInterceptionRecords?.get(a.target)||{})[a.attributeName]?.shift()),l=It(l).map(a=>kt.call(r,a)),l.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(a=>a(l)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(a=>a(l)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{u[l]=o.prototype[l],o.prototype[l]=function(...a){let c,p=this.getAttribute(a[0]);["setAttribute","toggleAttribute"].includes(l)&&(c=a[1]),l==="toggleAttribute"&&c===void 0&&(c=p===null);let _={target:this,name:a[0],value:c,oldValue:p,type:"interception",event:[this,l]};return f(_,()=>u[l].call(this,...a))}}),s}var J=class extends D{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new k(i,o).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=u=>(o.has(u)||o.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),o.get(u));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(u=>s(i).entrants.push(u));else if(t.every(u=>u.type==="selector")){let[u,l]=t.reduce(([c,p],_)=>_.kind==="xpath"?[c,p.concat(_)]:[c.concat(_),p],[[],[]]),a=[];e.subtree?(u.length&&a.push(...i.querySelectorAll(u.join(","))),l.length&&a.push(...it(this.window,i,l))):(u.length&&a.push(...[...i.children].filter(c=>c.matches(u))),l.length&&a.push(...it(this.window,i,l,!1))),a.forEach(c=>s(c.parentNode||i).entrants.push(c))}}if(!r)return o;let f={disconnected:!1},m=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(f.disconnected)break;let l=m?.generate()||{};r(u,l,i)}if(e.live){m&&(e={...e,signalGenerator:m});let u=this.observe(t,r,e);return this.disconnectables(e.signal,f,u)}return this.disconnectables(e.signal,f,m)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&Lt.call(o,"sync",()=>{});let m=new o.MutationObserver(a=>a.forEach(c=>{dt.call(o,l,Ht.call(o,c),i)}));m.observe(i,{childList:!0,subtree:e.subtree});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:m};if(e.staticSensitivity){let a=jt.call(o,l);return this.disconnectables(e.signal,m,u,a)}return this.disconnectables(e.signal,m,u)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let s=e.timing==="intercept"?"intercept":"sync",f=e.subtree?"subtree":"children";this.registry(s).size||Lt.call(o,s,_=>{this.forEachMatchingContext(s,_,dt)});let m=new o.MutationObserver(_=>_.forEach(d=>{Array.isArray((d=Ht.call(o,d)).event)||dt.call(o,a,d,i)}));m.observe(i,{childList:!0,subtree:e.subtree});let u={disconnect(){m.disconnect(),p.delete(a),p.size||c.delete(i)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:u},c=this.registry(s,f);c.has(i)||c.set(i,new Set);let p=c.get(i);if(p.add(a),e.staticSensitivity){let _=jt.call(o,a);return this.disconnectables(e.signal,u,l,_)}return this.disconnectables(e.signal,u,l)}};function jt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(p=>p.kind==="css"),m=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],u=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],l=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(_=>_[1]).concat(m(p)).concat(u(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,_)=>p.concat(l(_+"")),[])))).length)return;let a=new Set,c=new Set;return a.push=p=>(c.delete(p),a.add(p)),c.push=p=>(a.delete(p),c.add(p)),n.$deliveryCache={entrants:a,exits:c},new k(r,t).observe(n.$attrs,p=>{let _=new Map,d=h=>(_.has(h)||_.set(h,{target:h,entrants:[],exits:[],type:"static",event:null}),_.get(h)),O=new WeakMap,g=h=>(O.has(h)||O.set(h,f.some(x=>h.matches(x+""))),O.get(h));for(let h of p)["entrants","exits"].forEach(x=>{o.generation&&x!==o.generation||n.$deliveryCache[x].has(h.target)||(x==="entrants"?!g(h.target):g(h.target))||(n.$deliveryCache[x].push(h.target),d(h.target)[x].push(h.target),d(h.target).event=h.event)});for(let[,h]of _){let x=s?.generate()||{};i(h,x,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function dt(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,m={...t,entrants:[],exits:[]};if(o.eventDetails||delete m.event,["entrants","exits"].forEach(l=>{if(!(o.generation&&l!==o.generation)&&(e.length?m[l]=ie.call(this,e,t[l],t.event!=="parse"):m[l]=[...t[l]],!!f))for(let a of m[l])f[l].push(a)}),!m.entrants.length&&!m.exits.length)return;let u=s?.generate()||{};i(m,u,r)}function ie(n,t,r){t=Array.isArray(t)?t:[...t];let e=(i,o)=>{if(o.type==="selector"){let s=o.isXpathAttr?[]:i.filter(f=>o.kind==="xpath"?Ct(this,f,o+""):f.matches&&f.matches(o+""));if((r||o.isXpathAttr)&&(s=i.reduce((f,m)=>o.kind==="xpath"?[...f,...it(this,m,o,r)]:m.querySelectorAll?[...f,...m.querySelectorAll(o+"")]:f,s)),s.length)return s}else if(i.includes(o.content)||r&&i.some(s=>s.contains(o.content)))return[o.content]};return t.$$searchCache||(t.$$searchCache=new Map),n.reduce((i,o)=>{let s;return t.$$searchCache.has(o.content)?s=t.$$searchCache.get(o.content):(s=e(t,o)||[],o.type==="instance"&&t.$$searchCache.set(o.content,s)),i.concat(s)},[])}function Ht({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=A(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=A(r).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Lt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:m,HTMLTemplateElement:u,DocumentFragment:l}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let a=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return a;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let c=(d,O)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,d.event);let x=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:x,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let g=O();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),g},p={characterData:Object.create(null),other:Object.create(null)};["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(d=>{function O(...g){let h=this instanceof s?p.characterData:p.other,x=()=>h[d].call(this,...g);if(!(this instanceof s||this instanceof f||this instanceof l))return x();let P=[],E=[],V=this;["insertBefore"].includes(d)?E=[g[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(E=[g[1]],["beforebegin","afterend"].includes(g[0])&&(V=this.parentNode)):["setHTML","replaceChildren"].includes(d)?(P=[...this.childNodes],E=d==="replaceChildren"?[...g]:[g[0]]):["replaceWith","remove"].includes(d)?(P=[this],E=d==="replaceWith"?[...g]:[],V=this.parentNode):["replaceChild"].includes(d)?(P=[g[1]],E=[g[0]]):["removeChild"].includes(d)?P=[...g]:(E=[...g],["before","after"].includes(d)&&(V=this.parentNode));let L=d;if(["insertAdjacentHTML","setHTML"].includes(d)){let _t=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(g[0])){if(!this.parentNode)return h[d].call(this,...g);_t=this.parentNode.nodeName}let K=i.createElement(_t);h.setHTML.call(K,E[0],d==="setHTML"?g[1]:{}),E=[...K.childNodes],d==="insertAdjacentHTML"?(L="insertAdjacentElement",g[1]=new l,g[1].______isTemp=!0,g[1].append(...K.childNodes)):(L="replaceChildren",g=[...K.childNodes])}return c({target:V,entrants:E,exits:P,type:"interception",event:[this,d]},()=>h[L].call(this,...g))}["insertBefore","replaceChild","removeChild","appendChild"].includes(d)?(p.other[d]=o.prototype[d],o.prototype[d]=O):(["after","before","remove","replaceWith"].includes(d)&&(p.characterData[d]=s.prototype[d],s.prototype[d]=O),f.prototype[d]&&(p.other[d]=f.prototype[d],f.prototype[d]=O))});let _=Object.create(null);return["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(d=>{let O=["textContent","nodeValue"].includes(d)?o:["outerText","innerText"].includes(d)?m:f;_[d]=Object.getOwnPropertyDescriptor(O.prototype,d),Object.defineProperty(O.prototype,d,{..._[d],set:function(g){let h=()=>_[d].set.call(this,g);if(!(this instanceof f))return h();let x=[],P=[],E=this;if(["outerHTML","outerText"].includes(d)?(x=[this],E=this.parentNode):x=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let L=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return h();L=this.parentNode.nodeName}let F=i.createElement(L==="TEMPLATE"?"div":L);_[d].set.call(F,g),P=this instanceof u?[]:[...F.childNodes],d==="outerHTML"?(g=new l,g.______isTemp=!0,g.append(...F.childNodes),h=()=>f.prototype.replaceWith.call(this,g)):this instanceof u?h=()=>this.content.replaceChildren(...F.childNodes):h=()=>f.prototype.replaceChildren.call(this,...F.childNodes)}return c({target:E,entrants:P,exits:x,type:"interception",event:[this,d]},h)}})}),["append","prepend","replaceChildren"].forEach(d=>{[i,l.prototype].forEach(O=>{let g=O[d];O[d]=function(...h){if(this.______isTemp)return g.call(this,...h);let x=d==="replaceChildren"?[...this.childNodes]:[];return c({target:this,entrants:h,exits:x,type:"interception",event:[this,d]},()=>g.call(this,...h))}})}),a}function Dt(){oe.call(this),se.call(this),fe.call(this)}function oe(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function se(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function fe(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Ft(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},Dt.call(n),n.webqit.realdom.meta=(...r)=>le.call(n,...r),n.webqit.realdom.ready=(...r)=>pt.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new J(r,n);if(e==="attr")return new k(r,n)};let t=new z(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom}function pt(...n){let t="interactive",r;R(n[0])?(t=n[0],b(n[1])&&(r=n[1])):b(n[0])&&(r=n[0]);let e={interactive:["interactive","complete"],complete:["complete"]};if(!e[t])throw new Error(`Invalid ready-state timing: ${t}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(o=>pt.call(this,"interactive",o)),complete:new Promise(o=>pt.call(this,"complete",o))}),i.webqit.realdom.readyStatePromises[t];if(e[t].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let o=i.document.readyState;for(let s of i.webqit.realdom.readyStateCallbacks[o].splice(0))s(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function le(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(f=>f.trim());return at(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:C(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}var j=(...n)=>$("oohtml",...n),q={};function $t(n,t,r){let e=this,i=Ft.call(e);e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");return e.webqit.oohtml.configs[o]||(e.webqit.oohtml.configs[o]={}),q.window=e,X(2,e.webqit.oohtml.configs[o],r,t,i.meta(n).json()),{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function Nt(){let{window:n}=q,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let o=i.pop();if(typeof o!="function")throw new Error("Callback must be provided.");let s=i.pop();if(!s?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],m=i.pop()||f[0];if(!f.includes(m))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:u,detail:l,targetContext:a,live:c,signal:p,diff:_,...d}=s;super(m,{...d,bubbles:d.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>u}),Object.defineProperty(this,"targetContext",{get:()=>a}),Object.defineProperty(this,"detail",{get:()=>l}),Object.defineProperty(this,"live",{get:()=>c}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>_}),Object.defineProperty(this,"options",{get:()=>d})}respondWith(i){if(this.diff){if("_prevValue"in this&&this._prevValue===i)return;Object.defineProperty(this,"_prevValue",{value:i,configurable:!0})}return this.callback(i)}}return t.DOMContextRequestEvent=r,r}var Y=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=q;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var Q=class extends Error{};var Z=class{static instance(t){return j(t).get("contexts::instance")||new this(t)}constructor(t){j(t).get("contexts::instance")?.dispose(),j(t).set("contexts::instance",this);let r={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}get[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(r=>typeof t[0]=="function"?t[0](r):r.constructor.kind===t[0]&&(t.length===1||r.detail===t[1]))}attach(t){if(!(t instanceof H))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new Q(`Context of same kind "${t.constructor.kind}"${t.detail?` and detail "${t.detail}"`:""} already exists.`);this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}request(...t){return new Y((r,e)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(r):t[t.length-1]=r);let i;(i=t.find(s=>typeof s=="object"&&s))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let o=new(Nt())(...t);this["#"].host.dispatchEvent(o)})}};var ht=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=q;return t}get name(){return this.host===q.window.document?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(t){}handle(t){}unsubscribed(t){}matchEvent(t){return t.kind===this.constructor.kind&&(!t.targetContext||t.targetContext===this.name)}handleEvent(t){if(!(this.disposed||typeof t.respondWith!="function")){if(t.type==="contextclaim"){if(t.target===this.host||!(t.detail instanceof ht))return;let r=new Set;return this.subscriptions.forEach(e=>{!t.target.contains(e.target)||!t.detail.matchEvent(e)||(t.stopPropagation(),this.subscriptions.delete(e),r.add(e))}),t.respondWith(r)}if(t.type==="contextrequest")return this.matchEvent(t)?(t.live&&(this.subscriptions.add(t),this.subscribed(t),t.signal?.addEventListener("abort",()=>{this.subscriptions.delete(t),this.unsubscribed(t)})),t.stopPropagation(),this.handle(t)):void 0}}initialize(t){this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this);let{value:r}=Z.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return r.forEach(e=>{this.subscriptions.add(e),this.subscribed(e),this.handle(e)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(r=>{this.subscriptions.delete(r),this.unsubscribed(r);let{target:e}=r;e.dispatchEvent(r)}),this}},H=ht;tt(H,"kind");var M=class extends H{static createRequest(t=null){let r=super.createRequest();if(t?.startsWith("@")){let[e,...i]=i.slice(1).split(".").map(o=>o.trim());r.targetContext=e,r.detail=i.join(".")}else r.detail=t;return r}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t._controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:r}}}=q;t._controller=r.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],r.get,e=>{this.disposed||t.respondWith(e.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t._controller?.abort()}};tt(M,"kind","bindings");function yt(n={}){let{config:t,window:r}=$t.call(this,"bindings-api",n,{context:{attr:{bindingsreflection:"bindings"}},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=M,ce.call(r,t)}function gt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!j(t).has("bindings")){let o=Object.create(null);j(t).set("bindings",o),e.observe(o,s=>{let f=Object.keys(o),m=t===r.document?r.document.documentElement:t,u=n.context.attr.bindingsreflection;f.length&&u?m.setAttribute(n.context.attr.bindingsreflection,f.join(" ")):u&&m.toggleAttribute(n.context.attr.bindingsreflection,!1);let l=t[i.api.contexts];for(let a of s)if(a.type==="delete"){let c=l.find(M.kind,a.key);c&&l.detach(c)}else l.find(M.kind,a.key)||l.attach(new M(a.key))})}return j(t).get("bindings")}function Rt(n,t,r,{merge:e,diff:i,namespace:o}={}){let s=this,{webqit:{Observer:f}}=s,m=gt.call(this,n,t),u={diff:i,namespace:o},l=e?[]:f.ownKeys(m,u).filter(a=>!(a in r));return f.batch(m,()=>(l.length&&f.deleteProperties(m,l,u),f.set(m,r,u)),u)}function ce(n){let t=this,{webqit:{Observer:r}}=t;if(n.api.bind in t.document)throw new Error(`document already has a "${n.api.bind}" property!`);if(n.api.bindings in t.document)throw new Error(`document already has a "${n.api.bindings}" property!`);if(n.api.bind in t.Element.prototype)throw new Error(`The "Element" class already has a "${n.api.bind}" property!`);if(n.api.bindings in t.Element.prototype)throw new Error(`The "Element" class already has a "${n.api.bindings}" property!`);Object.defineProperty(t.document,n.api.bind,{value:function(e,i={}){return Rt.call(t,n,t.document,e,i)}}),Object.defineProperty(t.document,n.api.bindings,{get:function(){return r.proxy(gt.call(t,n,t.document))}}),Object.defineProperty(t.Element.prototype,n.api.bind,{value:function(e,i={}){return Rt.call(t,n,this,e,i)}}),Object.defineProperty(t.Element.prototype,n.api.bindings,{get:function(){return r.proxy(gt.call(t,n,this))}})}yt.call(window);})();
1
+ (()=>{var Bt=Object.defineProperty;var Gt=(n,t,r)=>t in n?Bt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var tt=(n,t,r)=>(Gt(n,typeof t!="symbol"?t+"":t,r),r);function w(n){return!Array.isArray(n)&&typeof n=="object"&&n}function y(n){return Array.isArray(n)}function st(n,t,r=null){return y(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function F(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new V}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new V,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new V,i.set(e,r));return r}var V=class extends Map{constructor(...t){super(...t),this.observers=new Set}set(t,r){let e=super.set(t,r);return this.fire("set",t,r,t),e}delete(t){let r=super.delete(t);return this.fire("delete",t),r}has(t){return this.fire("has",t),super.has(t)}get(t){return this.fire("get",t),super.get(t)}keyNames(){return Array.from(super.keys())}observe(t,r,e){let i={type:t,key:r,callback:e};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(t,r,e){if(Array.isArray(t)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(et([t,"*"],i.type)&&et([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(et([t,"*"],i.type)&&et([r,"*"],i.key))||i.callback(...e)}},et=(n,t)=>Array.isArray(t)?st(n,t).length:n.includes(t);function N(n){return typeof n=="function"}function B(n){return n===null||n===""}function I(n){return arguments.length&&(n===void 0||typeof n>"u")}function v(n){return Array.isArray(n)||typeof n=="object"&&n||N(n)}function ft(n){return B(n)||I(n)||n===!1||n===0||v(n)&&!Object.keys(n).length}function b(n){return N(n)||n&&{}.toString.call(n)==="[object function]"}function G(n){return n instanceof Number||typeof n=="number"}function C(n){return G(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function W(n){return n instanceof String||typeof n=="string"&&n!==null}function lt(n){return!W(n)&&!I(n.length)}function rt(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function ct(e,t){t=t||Object.prototype,t=t&&!y(t)?[t]:t;for(var r=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)r.push(e),e=e?Object.getPrototypeOf(e):null;return r}function ut(n,t){var r=[];return ct(n,t).forEach(e=>{rt(r,...Object.getOwnPropertyNames(e))}),r}function T(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((C(s)||s===!0||s===!1)&&(o=s,s=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((f,a)=>{!v(f)&&!b(f)||(r?ut(f):Object.keys(f)).forEach(u=>{if(!!t(u,s,f,a)){var l=s[u],m=f[u];if((y(l)&&y(m)||w(l)&&w(m))&&(o===!0||o>0))s[u]=y(l)&&y(m)?[]:{},T([C(o)?o-1:o,s[u],l,m],t,r,e,i);else if(y(s)&&y(f))e?s[u]=m:s.push(m);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(f,u)):s[u]=f[u]}catch{}}})}),s}function X(...n){return T(n,(t,r,e)=>!0,!1,!1,!1)}function A(n,t=!0){return y(n)?n:!t&&w(n)?[n]:n!==!1&&n!==0&&ft(n)?[]:lt(n)?Array.prototype.slice.call(n):w(n)?Object.values(n):[n]}function U(n,t,r={},e={}){t=A(t).slice();for(var i=n;!I(i)&&!B(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):v(i)?o in i:i[o])){e.exists=!1;return}i=r.get?r.get(i,o):i[o]}return e.exists=!0,i}function mt(n,t,r,e={},i={}){let o=(l,m,c)=>i.set?i.set(l,m,c):(C(t[f])&&y(l)?l.push(c):l[m]=c,!0);t=A(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!v(s)&&!b(s))return!1;var a=U(s,t[f],i);if(!v(a)){if(i.buildTree===!1)return!1;a=b(i.buildTree)?i.buildTree(f):C(t[f+1])?[]:{};var u=o(s,t[f],a);if(!u)return!1}s=a}else return o(s,t[f],r)}var z=class{constructor(t,r=!1){Object.defineProperty(this,"window",{value:t}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!r&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(t){this._synthesis++,this._fulfill();let r=await t();return this._synthesis--,r}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.readCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,r,e){this.onread(()=>{let i=t(e),o=s=>{s!==void 0&&this.onwrite(()=>{let f=r(s,e),a=u=>{u!==void 0&&this.cycle(t,r,u)};f instanceof Promise?f.then(a):a(f)})};i instanceof Promise?i.then(o):o(i)})}};function Ct(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function it(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",e?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,t,null,XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function St(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function Tt(n,t="|"){return[...n].reduce(([r,e,i,o],s)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(s)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,e,i]),[null,0,[""]])[2].reverse()}var S=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Ct(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Tt(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var $=class{constructor(t,r,e){this.context=t,this.namespace=r,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(b(t[0])?t=[[],...t]:w(t[0])&&!(t[0]instanceof S)&&t.length===1?t=[[],void 0,t[0]]:w(t[1])&&t.length===2?t=[A(t[0],!1),void 0,t[1]]:t[0]=A(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof S)&&!(r instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return t[0]=t[0].map(r=>r instanceof S?r:new S(r)),t}registry(...t){return F("realdom.realtime",this.window,this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,o=Array.isArray(r)?r:[r],s=new Set;for(let[f,a]of this.registry(t))for(let[u,l]of a){let m=o.filter(c=>u.contains(c.target)?f==="subtree"||c.target===u:!1);if(!!m.length){Array.isArray(r)||(m=m[0]);for(let c of l)s.add([c,m,u])}}for(let[f,a,u]of s)e.call(i,f,a,u)}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&b(i.disconnect)&&i.disconnect()||b(i)&&i()||w(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var j=class extends ${constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof S;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=jt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let a of s){let u=f?.generate()||{};r(a,u,o)}else{let a=f?.generate()||{};r(s,a,o)}if(e.live){f&&(e={...e,signalGenerator:f});let a=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,a)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof S;if([t=[],r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&It.call(s,"intercept",()=>{});let a=new s.MutationObserver(c=>{c=Mt(c).map(p=>kt.call(s,p)),Pt.call(s,m,c,o)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree};t.length&&(u.attributeFilter=t.map(c=>c+"")),a.observe(o,u);let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:a};return this.disconnectables(e.signal,a,l)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof S;[t,r,e={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let f=e.timing==="intercept"?"intercept":"sync",a=e.subtree?"subtree":"children";this.registry(f).size||It.call(s,f,_=>{this.forEachMatchingContext(f,_,Pt)});let u={disconnect(){p.delete(m),p.size||c.delete(o)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:u},c=this.registry(f,a);c.has(o)||c.set(o,new Set);let p=c.get(o);return p.add(m),this.disconnectables(e.signal,u,l)}};function Mt(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName?t:t.concat(r),[])}function Pt(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:a}=n,u=e.map(c=>c+"");if(o.atomic&&!s.size?t=jt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(c=>u.includes(c.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(c=>{let p;return o.eventDetails||({event:p,...c}=c),!o.oldValue&&"oldValue"in c&&({oldValue:p,...c}=c),!o.newValue&&"value"in c?{value:p,...c}=c:o.newValue&&typeof c.value>"u"&&(c={...c,value:c.target.getAttribute(c.name)}),c})),o.atomic&&(t.forEach(c=>s.set(c.name,c)),t=Array.from(s.entries()).map(([,c])=>c));let l=f?t[0]:t,m=a?.generate()||{};i(l,m,r)}function jt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:n.getAttribute(o),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:o.nodeValue,...e})}function kt({target:n,attributeName:t,value:r,oldValue:e}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:s}}function It(n,t){let r=this,{webqit:e,document:i,Element:o}=r;e.realdom.attrInterceptionHooks||Object.defineProperty(e.realdom,"attrInterceptionHooks",{value:new Map}),e.realdom.attrInterceptionHooks.has(n)||e.realdom.attrInterceptionHooks.set(n,new Set),e.realdom.attrInterceptionHooks.get(n).add(t);let s=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(l,m)=>{e.realdom.attrInterceptionRecords.has(l.target)||e.realdom.attrInterceptionRecords.set(l.target,{});let c=e.realdom.attrInterceptionRecords.get(l.target);c[l.name]=c[l.name]||[],c[l.name].unshift(l.event),e.realdom.attrInterceptionHooks.get("intercept")?.forEach(_=>_([l]));let p=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(_=>_([l])),p};new r.MutationObserver(l=>{l=l.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),l=Mt(l).map(m=>kt.call(r,m)),l.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(l)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(l)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{u[l]=o.prototype[l],o.prototype[l]=function(...m){let c,p=this.getAttribute(m[0]);["setAttribute","toggleAttribute"].includes(l)&&(c=m[1]),l==="toggleAttribute"&&c===void 0&&(c=p===null);let _={target:this,name:m[0],value:c,oldValue:p,type:"interception",event:[this,l]};return f(_,()=>u[l].call(this,...m))}}),s}var J=class extends ${constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new j(i,o).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=u=>(o.has(u)||o.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),o.get(u));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(u=>s(i).entrants.push(u));else if(t.every(u=>u.type==="selector")){let[u,l]=t.reduce(([c,p],_)=>_.kind==="xpath"?[c,p.concat(_)]:[c.concat(_),p],[[],[]]),m=[];e.subtree?(u.length&&m.push(...i.querySelectorAll(u.join(","))),l.length&&m.push(...it(this.window,i,l))):(u.length&&m.push(...[...i.children].filter(c=>c.matches(u))),l.length&&m.push(...it(this.window,i,l,!1))),m.forEach(c=>s(c.parentNode||i).entrants.push(c))}}if(!r)return o;let f={disconnected:!1},a=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(f.disconnected)break;let l=a?.generate()||{};r(u,l,i)}if(e.live){a&&(e={...e,signalGenerator:a});let u=this.observe(t,r,e);return this.disconnectables(e.signal,f,u)}return this.disconnectables(e.signal,f,a)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&$t.call(o,"sync",()=>{});let a=new o.MutationObserver(m=>m.forEach(c=>{pt.call(o,l,Ht.call(o,c),i)}));a.observe(i,{childList:!0,subtree:e.subtree});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:a};if(e.staticSensitivity){let m=Lt.call(o,l);return this.disconnectables(e.signal,a,u,m)}return this.disconnectables(e.signal,a,u)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let s=e.timing==="intercept"?"intercept":"sync",f=e.subtree?"subtree":"children";this.registry(s).size||$t.call(o,s,_=>{this.forEachMatchingContext(s,_,pt)});let a=new o.MutationObserver(_=>_.forEach(d=>{Array.isArray((d=Ht.call(o,d)).event)||pt.call(o,m,d,i)}));a.observe(i,{childList:!0,subtree:e.subtree});let u={disconnect(){a.disconnect(),p.delete(m),p.size||c.delete(i)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:u},c=this.registry(s,f);c.has(i)||c.set(i,new Set);let p=c.get(i);if(p.add(m),e.staticSensitivity){let _=Lt.call(o,m);return this.disconnectables(e.signal,u,l,_)}return this.disconnectables(e.signal,u,l)}};function Lt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(p=>p.kind==="css"),a=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],u=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],l=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(_=>_[1]).concat(a(p)).concat(u(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,_)=>p.concat(l(_+"")),[])))).length)return;let m=new Set,c=new Set;return m.push=p=>(c.delete(p),m.add(p)),c.push=p=>(m.delete(p),c.add(p)),n.$deliveryCache={entrants:m,exits:c},new j(r,t).observe(n.$attrs,p=>{let _=new Map,d=h=>(_.has(h)||_.set(h,{target:h,entrants:[],exits:[],type:"static",event:null}),_.get(h)),O=new WeakMap,g=h=>(O.has(h)||O.set(h,f.some(x=>h.matches(x+""))),O.get(h));for(let h of p)["entrants","exits"].forEach(x=>{o.generation&&x!==o.generation||n.$deliveryCache[x].has(h.target)||(x==="entrants"?!g(h.target):g(h.target))||(n.$deliveryCache[x].push(h.target),d(h.target)[x].push(h.target),d(h.target).event=h.event)});for(let[,h]of _){let x=s?.generate()||{};i(h,x,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function pt(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,a={...t,entrants:[],exits:[]};if(o.eventDetails||delete a.event,["entrants","exits"].forEach(l=>{if(!(o.generation&&l!==o.generation)&&(e.length?a[l]=se.call(this,e,t[l],t.event!=="parse"):a[l]=[...t[l]],!!f))for(let m of a[l])f[l].push(m)}),!a.entrants.length&&!a.exits.length)return;let u=s?.generate()||{};i(a,u,r)}function se(n,t,r){t=Array.isArray(t)?t:[...t];let e=(i,o)=>{if(o.type==="selector"){let s=o.isXpathAttr?[]:i.filter(f=>o.kind==="xpath"?St(this,f,o+""):f.matches&&f.matches(o+""));if((r||o.isXpathAttr)&&(s=i.reduce((f,a)=>o.kind==="xpath"?[...f,...it(this,a,o,r)]:a.querySelectorAll?[...f,...a.querySelectorAll(o+"")]:f,s)),s.length)return s}else if(i.includes(o.content)||r&&i.some(s=>s.contains(o.content)))return[o.content]};return t.$$searchCache||(t.$$searchCache=new Map),n.reduce((i,o)=>{let s;return t.$$searchCache.has(o.content)?s=t.$$searchCache.get(o.content):(s=e(t,o)||[],o.type==="instance"&&t.$$searchCache.set(o.content,s)),i.concat(s)},[])}function Ht({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=A(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=A(r).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function $t(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:a,HTMLTemplateElement:u,DocumentFragment:l}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let m=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let c=(d,O)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,d.event);let x=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:x,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let g=O();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),g},p={characterData:Object.create(null),other:Object.create(null)};["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(d=>{function O(...g){let h=this instanceof s?p.characterData:p.other,x=()=>h[d].call(this,...g);if(!(this instanceof s||this instanceof f||this instanceof l))return x();let P=[],E=[],R=this;["insertBefore"].includes(d)?E=[g[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(E=[g[1]],["beforebegin","afterend"].includes(g[0])&&(R=this.parentNode)):["setHTML","replaceChildren"].includes(d)?(P=[...this.childNodes],E=d==="replaceChildren"?[...g]:[g[0]]):["replaceWith","remove"].includes(d)?(P=[this],E=d==="replaceWith"?[...g]:[],R=this.parentNode):["replaceChild"].includes(d)?(P=[g[1]],E=[g[0]]):["removeChild"].includes(d)?P=[...g]:(E=[...g],["before","after"].includes(d)&&(R=this.parentNode));let H=d;if(["insertAdjacentHTML","setHTML"].includes(d)){let bt=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(g[0])){if(!this.parentNode)return h[d].call(this,...g);bt=this.parentNode.nodeName}let K=i.createElement(bt);h.setHTML.call(K,E[0],d==="setHTML"?g[1]:{}),E=[...K.childNodes],d==="insertAdjacentHTML"?(H="insertAdjacentElement",g[1]=new l,g[1].______isTemp=!0,g[1].append(...K.childNodes)):(H="replaceChildren",g=[...K.childNodes])}return c({target:R,entrants:E,exits:P,type:"interception",event:[this,d]},()=>h[H].call(this,...g))}["insertBefore","replaceChild","removeChild","appendChild"].includes(d)?(p.other[d]=o.prototype[d],o.prototype[d]=O):(["after","before","remove","replaceWith"].includes(d)&&(p.characterData[d]=s.prototype[d],s.prototype[d]=O),f.prototype[d]&&(p.other[d]=f.prototype[d],f.prototype[d]=O))});let _=Object.create(null);return["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(d=>{let O=["textContent","nodeValue"].includes(d)?o:["outerText","innerText"].includes(d)?a:f;_[d]=Object.getOwnPropertyDescriptor(O.prototype,d),Object.defineProperty(O.prototype,d,{..._[d],set:function(g){let h=()=>_[d].set.call(this,g);if(!(this instanceof f))return h();let x=[],P=[],E=this;if(["outerHTML","outerText"].includes(d)?(x=[this],E=this.parentNode):x=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let H=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return h();H=this.parentNode.nodeName}let D=i.createElement(H==="TEMPLATE"?"div":H);_[d].set.call(D,g),P=this instanceof u?[]:[...D.childNodes],d==="outerHTML"?(g=new l,g.______isTemp=!0,g.append(...D.childNodes),h=()=>f.prototype.replaceWith.call(this,g)):this instanceof u?h=()=>this.content.replaceChildren(...D.childNodes):h=()=>f.prototype.replaceChildren.call(this,...D.childNodes)}return c({target:E,entrants:P,exits:x,type:"interception",event:[this,d]},h)}})}),["append","prepend","replaceChildren"].forEach(d=>{[i,l.prototype].forEach(O=>{let g=O[d];O[d]=function(...h){if(this.______isTemp)return g.call(this,...h);let x=d==="replaceChildren"?[...this.childNodes]:[];return c({target:this,entrants:h,exits:x,type:"interception",event:[this,d]},()=>g.call(this,...h))}})}),m}function Dt(){fe.call(this),le.call(this),ce.call(this)}function fe(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function le(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function ce(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Ft(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},Dt.call(n),n.webqit.realdom.meta=(...r)=>ue.call(n,...r),n.webqit.realdom.ready=(...r)=>ht.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new J(r,n);if(e==="attr")return new j(r,n)};let t=new z(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function ht(...n){let t="interactive",r;W(n[0])?(t=n[0],b(n[1])&&(r=n[1])):b(n[0])&&(r=n[0]);let e={interactive:["interactive","complete"],complete:["complete"]};if(!e[t])throw new Error(`Invalid ready-state timing: ${t}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(o=>ht.call(this,"interactive",o)),complete:new Promise(o=>ht.call(this,"complete",o))}),i.webqit.realdom.readyStatePromises[t];if(e[t].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let o=i.document.readyState;for(let s of i.webqit.realdom.readyStateCallbacks[o].splice(0))s(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function ue(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(f=>f.trim());return mt(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:C(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function ot(n,t){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof t!==void 0&&t?r.substr(1).toLowerCase():r.substr(1))})}var k=(...n)=>F("oohtml",...n),q={};function Wt(n,t,r){let e=this,i=Ft.call(e);q.window=e,e.webqitConfig||(e.webqitConfig=i.meta("webqit").json()),e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[o]){e.webqit.oohtml.configs[o]={};let s=e.webqit.oohtml.configs[o];X(2,s,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(s).forEach(f=>{Object.keys(s[f]).forEach(a=>{f==="api"&&typeof s[f][a]=="string"?s[f][a]=`${e.webqitConfig.prefix}${ot(s[f][a])}`:["attr","elements"].includes(f)&&s[f][a]?.startsWith("data-")===!1&&(s[f][a]=`${e.webqitConfig.prefix}-${s[f][a]}`)})})}return{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function Rt(){let{window:n}=q,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let o=i.pop();if(typeof o!="function")throw new Error("Callback must be provided.");let s=i.pop();if(!s?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],a=i.pop()||f[0];if(!f.includes(a))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:u,detail:l,targetContext:m,live:c,signal:p,diff:_,...d}=s;super(a,{...d,bubbles:d.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>u}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>l}),Object.defineProperty(this,"live",{get:()=>c}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>_}),Object.defineProperty(this,"options",{get:()=>d})}respondWith(i){if(this.diff){if("_prevValue"in this&&this._prevValue===i)return;Object.defineProperty(this,"_prevValue",{value:i,configurable:!0})}return this.callback(i)}}return t.DOMContextRequestEvent=r,r}var Y=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=q;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var Q=class extends Error{};var Z=class{static instance(t){return k(t).get("contexts::instance")||new this(t)}constructor(t){k(t).get("contexts::instance")?.dispose(),k(t).set("contexts::instance",this);let r={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}get[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(r=>typeof t[0]=="function"?t[0](r):r.constructor.kind===t[0]&&(t.length===1||r.detail===t[1]))}attach(t){if(!(t instanceof L))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new Q(`Context of same kind "${t.constructor.kind}"${t.detail?` and detail "${t.detail}"`:""} already exists.`);this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}request(...t){return new Y((r,e)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(r):t[t.length-1]=r);let i;(i=t.find(s=>typeof s=="object"&&s))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let o=new(Rt())(...t);this["#"].host.dispatchEvent(o)})}};var gt=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=q;return t}get name(){return this.host===q.window.document?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(t){}handle(t){}unsubscribed(t){}matchEvent(t){return t.kind===this.constructor.kind&&(!t.targetContext||t.targetContext===this.name)}handleEvent(t){if(!(this.disposed||typeof t.respondWith!="function")){if(t.type==="contextclaim"){if(t.target===this.host||!(t.detail instanceof gt))return;let r=new Set;return this.subscriptions.forEach(e=>{!t.target.contains(e.target)||!t.detail.matchEvent(e)||(t.stopPropagation(),this.subscriptions.delete(e),r.add(e))}),t.respondWith(r)}if(t.type==="contextrequest")return this.matchEvent(t)?(t.live&&(this.subscriptions.add(t),this.subscribed(t),t.signal?.addEventListener("abort",()=>{this.subscriptions.delete(t),this.unsubscribed(t)})),t.stopPropagation(),this.handle(t)):void 0}}initialize(t){this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this);let{value:r}=Z.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return r?.forEach(e=>{this.subscriptions.add(e),this.subscribed(e),this.handle(e)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(r=>{this.subscriptions.delete(r),this.unsubscribed(r);let{target:e}=r;e.dispatchEvent(r)}),this}},L=gt;tt(L,"kind");var M=class extends L{static createRequest(t=null){let r=super.createRequest();if(t?.startsWith("@")){let[e,...i]=i.slice(1).split(".").map(o=>o.trim());r.targetContext=e,r.detail=i.join(".")}else r.detail=t;return r}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t._controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:r}}}=q;t._controller=r.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],r.get,e=>{this.disposed||t.respondWith(e.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t._controller?.abort()}};tt(M,"kind","bindings");function _t(n={}){let{config:t,window:r}=Wt.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=M,de.call(r,t)}function yt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!k(t).has("bindings")){let o=Object.create(null);k(t).set("bindings",o),e.observe(o,s=>{let f=Object.keys(o),a=t===r.document?r.document.documentElement:t,u=n.attr.bindingsreflection;f.length&&u?a.setAttribute(n.attr.bindingsreflection,f.join(" ")):u&&a.toggleAttribute(n.attr.bindingsreflection,!1);let l=t[i.api.contexts];for(let m of s)if(m.type==="delete"){let c=l.find(M.kind,m.key);c&&l.detach(c)}else l.find(M.kind,m.key)||l.attach(new M(m.key))})}return k(t).get("bindings")}function Vt(n,t,r,{merge:e,diff:i,namespace:o}={}){let s=this,{webqit:{Observer:f}}=s,a=yt.call(this,n,t),u={diff:i,namespace:o},l=e?[]:f.ownKeys(a,u).filter(m=>!(m in r));return f.batch(a,()=>(l.length&&f.deleteProperties(a,l,u),f.set(a,r,u)),u)}function de(n){let t=this,{webqit:{Observer:r}}=t;if(n.api.bind in t.document)throw new Error(`document already has a "${n.api.bind}" property!`);if(n.api.bindings in t.document)throw new Error(`document already has a "${n.api.bindings}" property!`);if(n.api.bind in t.Element.prototype)throw new Error(`The "Element" class already has a "${n.api.bind}" property!`);if(n.api.bindings in t.Element.prototype)throw new Error(`The "Element" class already has a "${n.api.bindings}" property!`);Object.defineProperty(t.document,n.api.bind,{value:function(e,i={}){return Vt.call(t,n,t.document,e,i)}}),Object.defineProperty(t.document,n.api.bindings,{get:function(){return r.proxy(yt.call(t,n,t.document))}}),Object.defineProperty(t.Element.prototype,n.api.bind,{value:function(e,i={}){return Vt.call(t,n,this,e,i)}}),Object.defineProperty(t.Element.prototype,n.api.bindings,{get:function(){return r.proxy(yt.call(t,n,this))}})}_t.call(window);})();
2
2
  //# sourceMappingURL=bindings-api.js.map