tosijs 1.5.2 → 1.5.3

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
@@ -28,7 +28,8 @@ If you want to build a web-application that's performant, robust, and maintainab
28
28
 
29
29
  - build user-interfaces with pure javascript/typescript—no JSX, complex tooling, or spooky action-at-a-distance
30
30
  - manage application state almost effortlessly—eliminate most binding code
31
- - written in Typescript, Javascript-friendly
31
+ - bind application state to the UI and services without locking yourself into a specific framework
32
+ - work in Typescript or Javascript
32
33
  - use web-components, build your own web-components quickly and easily
33
34
  - manage CSS efficiently and flexibly using CSS variables and Color computations
34
35
  - leverage existing business logic and libraries without complex wrappers
@@ -54,7 +55,7 @@ const { h4, ul, template, li, label, input } = elements
54
55
  preview.append(
55
56
  h4('To Do List'),
56
57
  ul(
57
- ...readmeTodoDemo.list.tosiListBinding(
58
+ ...readmeTodoDemo.list.listBinding(
58
59
  ({ li, button }, item) =>
59
60
  li(
60
61
  item.reminder,
@@ -92,7 +93,7 @@ and simplicity as you get with highly-refined React-centric toolchains, but with
92
93
  domain-specific-languages, or other tricks that provide "convenience" at the cost of becoming locked-in
93
94
  to React, a specific state-management system (which permeates your business logic), and usually a specific UI framework.
94
95
 
95
- `tosijs` lets you work with pure HTML and web-component as cleanly—more cleanly—and efficiently than
96
+ `tosijs` lets you work with pure HTML and web-components as cleanly—more cleanly—and efficiently than
96
97
  React toolchains let you work with JSX.
97
98
 
98
99
  export default function App() {
@@ -114,7 +115,7 @@ Becomes:
114
115
  )
115
116
 
116
117
  Except this reusable component outputs native DOM nodes. No transpilation, spooky magic at a distance,
117
- or virtual DOM required. And it all works just as well with web-components. This is you get when
118
+ or virtual DOM required. And it all works just as well with web-components. This is what you get when
118
119
  you run App() in the console:
119
120
 
120
121
  ▼ <div class="App">
@@ -140,13 +141,13 @@ more compactly than with `jsx` (and without a virtual DOM).
140
141
 
141
142
  import { Component, elements, css } from 'tosijs'
142
143
 
143
- const { style, h1, slot } = elements
144
+ const { h1, slot } = elements
144
145
  export class MyComponent extends Component {
145
- styleNode = style(css({
146
+ static shadowStyleSpec = css({
146
147
  h1: {
147
148
  color: 'blue'
148
149
  }
149
- }))
150
+ })
150
151
  content = [ h1('hello world'), slot() ]
151
152
  }
152
153
 
@@ -161,9 +162,9 @@ and are natively supported by all modern browsers.
161
162
  `tosijs` tracks the state of objects you assign to it using `paths` allowing economical
162
163
  and direct updates to application state.
163
164
 
164
- import { xinProxy, observe } from 'tosijs'
165
+ import { tosi, observe } from 'tosijs'
165
166
 
166
- const { app } = xinProxy({
167
+ const { app } = tosi({
167
168
  app: {
168
169
  prefs: {
169
170
  darkmode: false
@@ -179,29 +180,28 @@ and direct updates to application state.
179
180
  })
180
181
 
181
182
  observe('app.prefs.darkmode', () => {
182
- document.body.classList.toggle('dark-mode', app.prefs.darkmode)
183
+ document.body.classList.toggle('dark-mode', app.prefs.darkmode.value)
183
184
  })
184
185
 
185
186
  observe('app.docs', () => {
186
187
  // render docs
187
188
  })
188
189
 
189
- > #### What does `xinProxy` do, and what is a `XinProxy`?
190
+ > #### What does `tosi` do, and what is a `BoxedProxy`?
190
191
  >
191
- > `xinProxy` is syntax sugar for assigning something to `xin` (which is a `XinProxyObject`)
192
- > and then getting it back out again.
192
+ > `tosi` is syntax sugar for assigning something to `xin` (which is a proxy over
193
+ > the central registry) and then getting it back out as a `BoxedProxy`.
193
194
  >
194
- > A `XinProxy` is an [ES Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
195
+ > A `BoxedProxy` is an [ES Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
195
196
  > wrapped around an `object` (which in Javascript means anything
196
197
  > that has a `constructor` which in particular includes `Array`s, `class` instances, `function`s
197
198
  > and so on, but not "scalars" like `number`s, `string`s, `boolean`s, `null`, and `undefined`)
198
199
  >
199
- > All you need to know about a `XinProxy` is that it's Proxy wrapped around your original
200
+ > All you need to know about a `BoxedProxy` is that it's a Proxy wrapped around your original
200
201
  > object that allows you to interact with the object normally, but which allows `tosijs` to
201
202
  > **observe** changes made to the wrapped object and tell interested parties about the changes.
202
203
  >
203
- > If you want to original object back you can just hold on to a reference or use `xinValue(someProxy)`
204
- > to unwrap it.
204
+ > If you want the original object back you can use `.value` on any proxy to unwrap it.
205
205
 
206
206
  ### No Tax, No Packaging
207
207
 
@@ -209,17 +209,17 @@ and direct updates to application state.
209
209
  with a `Proxy` and then if you use `xin` to make changes to those objects,
210
210
  `tosijs` will notify any interested observers.
211
211
 
212
- **Note** `xinProxy({foo: {...}})` is syntax sugar for `xin.foo = {...}`.
212
+ **Note** `tosi({foo: {...}})` is syntax sugar for `xin.foo = {...}`.
213
213
 
214
- import { xinProxy, observe } from 'tosijs'
215
- const { foo } = xinProxy({
214
+ import { tosi, observe } from 'tosijs'
215
+ const { foo } = tosi({
216
216
  foo: {
217
217
  bar: 17
218
218
  }
219
219
  })
220
220
 
221
- observe('foo.bar', v => {
222
- console.log('foo.bar was changed to', xin.foo.bar)
221
+ observe('foo.bar', (path) => {
222
+ console.log('foo.bar was changed to', foo.bar.value)
223
223
  })
224
224
 
225
225
  foo.bar = 17 // does not trigger the observer
@@ -230,13 +230,13 @@ with a `Proxy` and then if you use `xin` to make changes to those objects,
230
230
  `xin` is designed to behave just like a JavaScript `Object`. What you put
231
231
  into it is what you get out of it:
232
232
 
233
- import { xin, xinValue } from 'tosijs'
233
+ import { xin } from 'tosijs'
234
234
 
235
235
  const foo = {bar: 'baz'}
236
236
  xin.foo = foo
237
237
 
238
- // xin.foo returns a Proxy wrapped around foo (without touching foo)
239
- xinValue(xin.foo) === foo
238
+ // xin.foo returns the value directly
239
+ xin.foo.bar === 'baz'
240
240
 
241
241
  // really, it's just the original object
242
242
  xin.foo.bar = 'lurman'
@@ -251,9 +251,9 @@ into it is what you get out of it:
251
251
  It's very common to deal with arrays of objects that have unique id values,
252
252
  so `tosijs` supports the idea of id-paths
253
253
 
254
- import { xinProxy, xin } from 'tosijs
254
+ import { tosi, xin } from 'tosijs'
255
255
 
256
- const { app } = xinProxy ({
256
+ const { app } = tosi({
257
257
  app: {
258
258
  list: [
259
259
  {
@@ -270,7 +270,7 @@ so `tosijs` supports the idea of id-paths
270
270
 
271
271
  console.log(app.list[0].text) // hello world
272
272
  console.log(app.list['id=5678efgh']) // so long, redux
273
- console.log(xin['app.list[id=1234abcd']) // hello world
273
+ console.log(xin['app.list[id=1234abcd]']) // hello world
274
274
 
275
275
  ### Telling `xin` about changes using `touch()`
276
276
 
@@ -281,7 +281,7 @@ When you want to trigger updates, simply touch the path.
281
281
 
282
282
  const foo = { bar: 17 }
283
283
  xin.foo = foo
284
- observe('foo.bar', path => console.log(path, '->', xin[path])
284
+ observe('foo.bar', (path) => console.log(path, '->', xin[path]))
285
285
  xin.foo.bar = -2 // console will show: foo.bar -> -2
286
286
 
287
287
  foo.bar = 100 // nothing happens
@@ -320,37 +320,35 @@ elements are reused (no teardown/recreation).
320
320
 
321
321
  `tosijs` includes utilities for working with css.
322
322
 
323
- import {css, vars, initVars, darkMode} from 'tosijs'
324
- const cssVars = {
325
- textFont: 'sans-serif'
326
- color: '#111'
327
- }
328
-
329
- `initVars()` processes an object changing its keys from camelCase to --kabob-case:
330
-
331
- initVars(cssVars) // emits { --text-font: "sans-serif", --color: "#111" }
332
-
333
- `darkMode()` processes an object, taking only the color properties and inverting their luminance values:
334
- darkMode(cssVars) // emits { color: '#ededed' }
323
+ import { css, vars } from 'tosijs'
335
324
 
336
- The `vars` simply converts its camelCase properties into css variable references
325
+ The `vars` proxy converts camelCase properties into css variable references:
337
326
 
338
327
  vars.fooBar // emits 'var(--foo-bar)'
339
- calc(`${vars.width} + 2 * ${vars.spacing}`) // emits 'calc(var(--width) + 2 * var(--spacing))'
328
+ `calc(${vars.width} + 2 * ${vars.spacing})` // emits 'calc(var(--width) + 2 * var(--spacing))'
340
329
 
341
- `css()` processes an object, rendering it as CSS
330
+ `css()` processes an object, rendering it as CSS:
342
331
 
343
332
  css({
344
333
  '.container': {
345
- 'position', 'relative'
334
+ position: 'relative'
346
335
  }
347
336
  }) // emits .container { position: relative; }
348
337
 
338
+ CSS variables can be declared using `_` and `__` prefixes in `css()` objects:
339
+
340
+ css({
341
+ ':root': {
342
+ _textFont: 'sans-serif', // emits --text-font: sans-serif
343
+ _color: '#111', // emits --color: #111
344
+ }
345
+ })
346
+
349
347
  ## Color
350
348
 
351
349
  `tosijs` includes a powerful `Color` class for manipulating colors.
352
350
 
353
- import {Color} from 'tosijs
351
+ import { Color } from 'tosijs'
354
352
  const translucentBlue = new Color(0, 0, 255, 0.5) // r, g, b, a parameters
355
353
  const postItBackground = Color.fromCss('#e7e79d')
356
354
  const darkGrey = Color.fromHsl(0, 0, 0.2)
@@ -358,13 +356,15 @@ The `vars` simply converts its camelCase properties into css variable references
358
356
  The color objects have computed properties for rendering the color in different ways,
359
357
  making adjustments, blending colors, and so forth.
360
358
 
359
+ Use `invertLuminance()` to generate dark-mode equivalents of color values.
360
+
361
361
  ## Hot Reload
362
362
 
363
363
  One of the nice things about working with the React toolchain is hot reloading.
364
364
  `tosijs` supports hot reloading (and not just in development!) via the `hotReload()`
365
365
  function:
366
366
 
367
- import {xin, hotReload} from 'tosijs'
367
+ import { xin, hotReload } from 'tosijs'
368
368
 
369
369
  xin.app = {
370
370
  ...
@@ -381,42 +381,21 @@ Only top-level properties in `xin` that pass the test will be persisted.
381
381
 
382
382
  To completely reset the app, run `localStorage.clear()` in the console.
383
383
 
384
- ### Types
385
-
386
- `tosijs` [type-by-example](https://www.npmjs.com/package/type-by-example) has been
387
- broken out into a separate standalone library. (Naturally it works very well with
388
- tosijs but they are completely independent.)
389
-
390
384
  ## Development Notes
391
385
 
392
- You'll need to install [bun](https://bun.sh/) and [nodejs](https://nodejs.org)),
393
- and then run `npm install` and `bun install`. `bun` is used because it's
394
- **fast** and is a really nice test-runner.
395
-
396
- To work interactively on the demo code, use `bun start`. This runs the demo
397
- site on localhost.
398
-
399
- To build everything run `bun run make` which builds production versions of the
400
- demo site (in `www`) and the `dist` and `cdn` directories.
401
-
402
- To create a local package (for experimenting with a build) run `bun pack`.
403
-
404
- ### Parcel Occasionally Gets Screwed Up
386
+ You'll need to install [bun](https://bun.sh/) and then run `bun install`.
405
387
 
406
- - remove all the parcel transformer dependencies @parcel/\*
407
- - rm -rf node_modules
408
- - run the update script
409
- - npx parcel build (which restores needed parcel transformers)
388
+ bun start # dev server with hot reload (https://localhost:8018)
389
+ bun test # run all tests
390
+ bun run dev.ts --build # production build (runs tests, then bundles)
391
+ bun run format # lint and format (ESLint + Prettier)
392
+ bun pack # create local package tarball
410
393
 
411
394
  ## Related Libraries
412
395
 
413
- - react-tosijs [react-tosijs](https://github.com/tonioloewald/react-tosijs#readme)
414
- allows you to use xin's path-observer model in React [ReactJS](https://reactjs.org) apps
415
- - type-by-example [github](https://github.com/tonioloewald/type-by-example) | [npm](https://www.npmjs.com/package/type-by-example)
416
- is a library for declaring types in pure javascript, allowing run-time type-checking.
417
- - filter-shapes [github](https://github.com/tonioloewald/filter-shapes) | [npm](https://www.npmjs.com/package/filter-shapes)
418
- is a library for filtering objects (and arrays of objects) to specific shapes (e.g. to reduce storage / bandwidth costs).
419
- It is built on top of type-by-example.
396
+ - [tosijs-ui](https://ui.tosijs.net) — a web-component library built on tosijs `Component`
397
+ - [tosijs-3d](https://3d.tosijs.net) — 3D graphics library built on tosijs
398
+ - [react-tosijs](https://github.com/tonioloewald/react-tosijs#readme) use tosijs's path-observer model in [React](https://reactjs.org) apps
420
399
 
421
400
  ## Credits
422
401
 
@@ -100,7 +100,7 @@ export declare abstract class Component<T = PartsMap> extends HTMLElement {
100
100
  interface SlotParts extends PartsMap {
101
101
  slotty: HTMLSlotElement;
102
102
  }
103
- declare class XinSlot extends Component<SlotParts> {
103
+ declare class TosiSlot extends Component<SlotParts> {
104
104
  static preferredTagName: string;
105
105
  static initAttributes: {
106
106
  name: string;
@@ -108,5 +108,15 @@ declare class XinSlot extends Component<SlotParts> {
108
108
  content: null;
109
109
  static replaceSlot(slot: HTMLSlotElement): void;
110
110
  }
111
+ export declare const tosiSlot: ElementCreator<TosiSlot>;
112
+ declare class XinSlot extends Component<SlotParts> {
113
+ static preferredTagName: string;
114
+ static initAttributes: {
115
+ name: string;
116
+ };
117
+ content: null;
118
+ constructor();
119
+ static replaceSlot: typeof TosiSlot.replaceSlot;
120
+ }
111
121
  export declare const xinSlot: ElementCreator<XinSlot>;
112
122
  export {};
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { css, invertLuminance, initVars, vars, varDefault, StyleSheet, onStylesh
4
4
  export type { ColorScheme, ContrastPreference, ThemePreferences } from './css';
5
5
  export type { XinStyleSheet, XinStyleMap, XinStyleRule } from './css-types';
6
6
  export { Color } from './color';
7
- export { Component } from './component';
7
+ export { Component, tosiSlot, xinSlot } from './component';
8
8
  export { validateAgainstConstraints, type FormValidation, } from './form-validation';
9
9
  export { elements, svgElements, mathML, bindParts } from './elements';
10
10
  export type { ElementsProxy } from './elements-types';
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- (()=>{var{defineProperty:gE,getOwnPropertyNames:PM,getOwnPropertyDescriptor:cM}=Object,bM=Object.prototype.hasOwnProperty;function uM(E){return this[E]}var nM=(E)=>{var f=(Rf??=new WeakMap).get(E),M;if(f)return f;if(f=gE({},"__esModule",{value:!0}),E&&typeof E==="object"||typeof E==="function"){for(var L of PM(E))if(!bM.call(f,L))gE(f,L,{get:uM.bind(E,L),enumerable:!(M=cM(E,L))||M.enumerable})}return Rf.set(E,f),f},Rf;var vM=(E)=>E;function dM(E,f){this[E]=vM.bind(null,f)}var gM=(E,f)=>{for(var M in f)gE(E,M,{get:f[M],enumerable:!0,configurable:!0,set:dM.bind(f,M)})};var PL={};gM(PL,{xinValue:()=>_f,xinProxy:()=>nE,xinPath:()=>Sf,xin:()=>C,warnDeprecated:()=>V,version:()=>uE,vars:()=>BE,varDefault:()=>WE,validateAgainstConstraints:()=>cE,updates:()=>EE,unobserve:()=>m,touchElement:()=>PE,touch:()=>k,tosiValue:()=>A,tosiSetValue:()=>yf,tosiPath:()=>T,tosiLoader:()=>yM,tosiBlueprint:()=>BM,tosi:()=>KE,throttle:()=>fE,sync:()=>IM,svgElements:()=>SE,share:()=>RM,settings:()=>i,scrollListItemIntoView:()=>qM,onThemePreferencesChange:()=>LM,onStylesheetChange:()=>ef,on:()=>LE,observe:()=>GE,mathML:()=>_E,makeComponent:()=>AE,invertLuminance:()=>MM,initVars:()=>fM,hotReload:()=>jM,getThemePreferences:()=>Gf,getListItem:()=>NE,getListInstance:()=>mE,getListBinding:()=>QE,getCssVar:()=>kE,elements:()=>W,deprecated:()=>xE,deleteListItem:()=>DM,debounce:()=>ZE,css:()=>s,boxedProxy:()=>TE,boxed:()=>B,blueprintLoader:()=>NM,blueprint:()=>_M,bindings:()=>zE,bindParts:()=>GM,bind:()=>P,StyleSheet:()=>af,MoreMath:()=>pf,Component:()=>c,Color:()=>w,BlueprintLoader:()=>dE,Blueprint:()=>jE});function b(E){if(E==null||typeof E!=="object")return E;if(E instanceof Set)return new Set(E);else if(Array.isArray(E))return E.map(b);let f={};for(let M in E){let L=E[M];if(E!=null&&typeof E==="object")f[M]=b(L);else f[M]=L}return f}var hE="-xin-data",g=`.${hE}`,sE="-xin-event",oE=`.${sE}`,S=Symbol.for("xin-path"),n=Symbol.for("xin-value"),rE="xinObserve",pE="xinBind",lE="xinOn",YE=Symbol("list-binding"),t=Symbol("list-instance"),iE=new Map;function If(E,f){let M=iE.get(E);if(M===void 0)M=new Set,iE.set(E,M);M.add(f)}function Bf(E){return iE.get(E)}var kf=new Set;function V(E,f){if(!kf.has(E))console.warn(f),kf.add(E)}function xE(E,f){let M=!1;return(...L)=>{if(!M)console.warn(f),M=!0;return E(...L)}}var T=(E)=>{return E&&E[S]||void 0};function A(E){if(typeof E==="object"&&E!==null){let f=E[n];return f!==void 0?f:E}return E}function yf(E,f){if(T(E)===void 0)throw Error("tosiSetValue requires a xin or boxed proxy");E[n]=f}var Sf=xE(T,"xinPath is deprecated. Use tosiPath instead."),_f=xE(A,"xinValue is deprecated. Use tosiValue instead."),l=new WeakMap,u=new WeakMap;var e=(E)=>{let f=E.cloneNode();if(f instanceof Element){let M=u.get(E),L=l.get(E);if(M!=null)u.set(f,b(M));if(L!=null)l.set(f,b(L))}for(let M of Array.from(E instanceof HTMLTemplateElement?E.content.childNodes:E.childNodes))if(M instanceof Element||M instanceof DocumentFragment)f.appendChild(e(M));else f.appendChild(M.cloneNode());return f};var i={debug:!1,perf:!1};var iM=(E)=>{try{return JSON.stringify(E)}catch(f){return"{has circular references}"}},tE=(...E)=>Error(E.map(iM).join(" "));var hM=()=>new Date(parseInt("1000000000",36)+Date.now()).valueOf().toString(36).slice(1),sM=0,oM=()=>(parseInt("10000",36)+ ++sM).toString(36).slice(-5),rM=()=>hM()+oM(),aE=Symbol("delete"),Pf=Symbol("new-object"),eE=Symbol("automatic-index");function cf(E){if(E==="")return[];if(Array.isArray(E))return E;else{let f=[];while(E.length>0){let M=E.search(/\[[^\]]+\]/);if(M===-1){f.push(E.split("."));break}else{let L=E.slice(0,M);if(E=E.slice(M),L!=="")f.push(L.split("."));if(M=E.indexOf("]")+1,f.push(E.slice(1,M-1)),E.slice(M,M+1)===".")M+=1;E=E.slice(M)}}return f}}var v=new WeakMap;function bf(E,f){if(v.get(E)===void 0)v.set(E,{});if(v.get(E)[f]===void 0)v.get(E)[f]={};let M=v.get(E)[f];if(f==="_auto_")E.forEach((L,H)=>{if(L[eE]===void 0)L[eE]=rM();M[L[eE]+""]=H});else E.forEach((L,H)=>{M[j(L,f)+""]=H});return M}function pM(E,f){if(v.get(E)===void 0||v.get(E)[f]===void 0)return bf(E,f);else return v.get(E)[f]}function lM(E,f,M){M=M+"";let L=pM(E,f)[M];if(L===void 0||j(E[L],f)+""!==M)L=bf(E,f)[M];return L}function tM(E,f,M){if(E[f]===void 0&&M!==void 0)E[f]=M;return E[f]}function uf(E,f,M,L){let H=f!==""?lM(E,f,M):M;if(L===aE)return E.splice(H,1),v.delete(E),Symbol("deleted");else if(L===Pf){if(f===""&&E[H]===void 0)E[H]={}}else if(L!==void 0)if(H!==void 0)E[H]=L;else if(f!==""&&j(L,f)+""===M+"")E.push(L),H=E.length-1;else throw Error(`byIdPath insert failed at [${f}=${M}]`);return E[H]}function mf(E){if(!Array.isArray(E))throw tE("setByPath failed: expected array, found",E)}function Nf(E){if(E==null||!(E instanceof Object))throw tE("setByPath failed: expected Object, found",E)}function j(E,f){let M=cf(f),L=E,H,J,$,Z;for(H=0,J=M.length;L!==void 0&&H<J;H++){let Y=M[H];if(Array.isArray(Y))for($=0,Z=Y.length;L!==void 0&&$<Z;$++){let Q=Y[$];L=L[Q]}else if(L.length===0){if(L=L[Number(Y.slice(1))],Y[0]!=="=")return}else if(Y.includes("=")){let[Q,...G]=Y.split("=");L=uf(L,Q,G.join("="))}else $=parseInt(Y,10),L=L[$]}return L}function a(E,f,M){let L=E;if(f==="")throw Error("setByPath cannot be used to set the root object");let H=cf(f);while(L!=null&&H.length>0){let J=H.shift();if(typeof J==="string"){let $=J.indexOf("=");if($>-1){if($===0)Nf(L);else mf(L);let Z=J.slice(0,$),Y=J.slice($+1);if(L=uf(L,Z,Y,H.length>0?Pf:M),H.length===0)return!0}else{mf(L);let Z=parseInt(J,10);if(H.length>0)L=L[Z];else{if(M!==aE){if(L[Z]===M)return!1;L[Z]=M}else L.splice(Z,1);return!0}}}else if(Array.isArray(J)&&J.length>0){Nf(L);while(J.length>0){let $=J.shift();if(J.length>0||H.length>0)L=tM(L,$,J.length>0?{}:[]);else{if(M!==aE){if(L[$]===M)return!1;L[$]=M}else{if(!Object.prototype.hasOwnProperty.call(L,$))return!1;delete L[$]}return!0}}}else throw Error(`setByPath failed, bad path ${f}`)}throw Error(`setByPath(${E}, ${f}, ${M}) failed`)}var R={},Ef=null,nf=(E)=>{Ef=E},VE=()=>{if(Ef===null)throw Error("xin proxy not initialized");return Ef},ff=null,Mf=null,vf=(E,f)=>{ff=E,Mf=f},wE=()=>{if(ff===null)throw Error("bind not initialized");return ff},FE=()=>{if(Mf===null)throw Error("on not initialized");return Mf};var df=Symbol("observer should be removed"),RE=[],$E=[],Lf=!1,Hf,Jf;function eM(E,f,M,L){let H=Bf(E);if(H===void 0)return[];let J=[];for(let $ of H){let Z=j(M,$);if(Z!==void 0)J.push(`${E}[${$}=${Z}]${L}`)}return J}class gf{description;test;callback;constructor(E,f){let M=typeof f==="string"?`"${f}"`:`function ${f.name}`,L;if(typeof E==="string")this.test=(H)=>typeof H==="string"&&H!==""&&(E.startsWith(H)||H.startsWith(E)),L=`test = "${E}"`;else if(E instanceof RegExp)this.test=E.test.bind(E),L=`test = "${E.toString()}"`;else if(E instanceof Function)this.test=E,L=`test = function ${E.name}`;else throw Error("expect listener test to be a string, RegExp, or test function");if(this.description=`${L}, ${M}`,typeof f==="function")this.callback=f;else throw Error("expect callback to be a path or function");RE.push(this)}}var EE=async()=>{if(Hf===void 0)return;await Hf},aM=()=>{if(i.perf)console.time("xin async update");let E=Array.from($E);$E.length=0,Lf=!1;for(let f of E)RE.filter((M)=>{let L;try{L=M.test(f)}catch(H){throw Error(`Listener ${M.description} threw "${H}" at "${f}"`)}if(L===df)return m(M),!1;return L}).forEach((M)=>{let L;try{L=M.callback(f)}catch(H){console.error(`Listener ${M.description} threw "${H}" handling "${f}"`)}if(L===df)m(M)});if(typeof Jf==="function")Jf();if(i.perf)console.timeEnd("xin async update")},k=(E)=>{let f=typeof E==="string"?E:T(E);if(f===void 0)throw console.error("touch was called on an invalid target",E),Error("touch was called on an invalid target");if(Lf===!1)Hf=new Promise((L)=>{Jf=L}),Lf=setTimeout(aM);if($E.find((L)=>f.startsWith(L))==null)$E.push(f);let M=f.match(/^(.+)\[(\d+)\](.*)$/);if(M!==null){let[,L,H,J]=M,$=parseInt(H,10),Z=j(R,`${L}[${$}]`);if(Z!=null){let Y=eM(L,$,Z,J);for(let Q of Y)if($E.find((G)=>Q.startsWith(G))==null)$E.push(Q)}}},_=(E,f)=>{return new gf(E,f)},m=(E)=>{let f=RE.indexOf(E);if(f>-1)RE.splice(f,1);else throw Error("unobserve failed, listener not found")};var Yf=(E,f)=>{let M=new Event(f);E.dispatchEvent(M)},sf=(E)=>{if(E instanceof HTMLInputElement)return E.type;else if(E instanceof HTMLSelectElement&&E.hasAttribute("multiple"))return"multi-select";else return"other"},of=(E,f)=>{switch(sf(E)){case"radio":E.checked=E.value===f;break;case"checkbox":E.checked=!!f;break;case"date":E.valueAsDate=new Date(f);break;case"multi-select":for(let M of Array.from(E.querySelectorAll("option")))M.selected=f[M.value];break;default:E.value=f}},rf=(E)=>{switch(sf(E)){case"radio":{let f=E.parentElement?.querySelector(`[name="${E.name}"]:checked`);return f!=null?f.value:null}case"checkbox":return E.checked;case"date":return E.valueAsDate?.toISOString();case"multi-select":return Array.from(E.querySelectorAll("option")).reduce((f,M)=>{return f[M.value]=M.selected,f},{});default:return E.value}},{ResizeObserver:hf}=globalThis,XE=hf!=null?new hf((E)=>{for(let f of E){let M=f.target;Yf(M,"resize")}}):{observe(){},unobserve(){}},$f=(E,f,M=!0)=>{if(E!=null&&f!=null)if(typeof f==="string")E.textContent=f;else if(Array.isArray(f))f.forEach((L)=>{E.append(L instanceof Node&&M?e(L):L)});else if(f instanceof Node)E.append(M?e(f):f);else throw Error("expect text content or document node")};var ZE=(E,f=250)=>{let M;return(...L)=>{if(M!==void 0)clearTimeout(M);M=setTimeout(()=>{E(...L)},f)}},fE=(E,f=250)=>{let M,L=Date.now()-f,H=!1;return(...J)=>{if(clearTimeout(M),M=setTimeout(()=>{E(...J),L=Date.now()},f),!H&&Date.now()-L>=f){H=!0;try{E(...J),L=Date.now()}finally{H=!1}}}};var zE={value:{toDOM:of,fromDOM(E){return rf(E)}},text:{toDOM(E,f){E.textContent=f}},enabled:{toDOM(E,f){E.disabled=!f}},disabled:{toDOM(E,f){E.disabled=Boolean(f)}},list:{toDOM(E,f,M){QE(E,f,M).update(f)}}};function I(E){return E.replace(/[A-Z]/g,(f)=>{return`-${f.toLocaleLowerCase()}`})}function Zf(E){return E.replace(/-([a-z])/g,(f,M)=>{return M.toLocaleUpperCase()})}var EL=180/Math.PI,fL=Math.PI/180;function N(E,f,M){return M<E?NaN:f<E?E:f>M?M:f}function d(E,f,M,L=!0){if(L)M=N(0,M,1);return M*(f-E)+E}var pf={RADIANS_TO_DEGREES:EL,DEGREES_TO_RADIANS:fL,clamp:N,lerp:d};function kE(E,f=document.body){let M=getComputedStyle(f);if(E.endsWith(")")&&E.startsWith("var("))E=E.slice(4,-1);return M.getPropertyValue(E).trim()}var ML=(E,f,M)=>{return(0.299*E+0.587*f+0.114*M)/255},ME=(E)=>("00"+Math.round(Number(E)).toString(16)).slice(-2);class lf{h;s;l;constructor(E,f,M){E/=255,f/=255,M/=255;let L=Math.max(E,f,M),H=L-Math.min(E,f,M),J=H!==0?L===E?(f-M)/H:L===f?2+(M-E)/H:4+(E-f)/H:0;this.h=60*J<0?60*J+360:60*J,this.s=H!==0?L<=0.5?H/(2*L-H):H/(2-(2*L-H)):0,this.l=(2*L-H)/2}}var h=globalThis.document!==void 0?globalThis.document.createElement("span"):void 0;if(h)h.style.display="none";class w{r;g;b;a;static fromVar(E,f=document.body){return w.fromCss(kE(E,f))}static fromCss(E){let f=E.match(/^#([0-9a-fA-F]+)$/);if(f){let Y=f[1];if(Y.length===3)return new w(parseInt(Y[0]+Y[0],16),parseInt(Y[1]+Y[1],16),parseInt(Y[2]+Y[2],16));if(Y.length===4)return new w(parseInt(Y[0]+Y[0],16),parseInt(Y[1]+Y[1],16),parseInt(Y[2]+Y[2],16),parseInt(Y[3]+Y[3],16)/255);if(Y.length===6)return new w(parseInt(Y.slice(0,2),16),parseInt(Y.slice(2,4),16),parseInt(Y.slice(4,6),16));if(Y.length===8)return new w(parseInt(Y.slice(0,2),16),parseInt(Y.slice(2,4),16),parseInt(Y.slice(4,6),16),parseInt(Y.slice(6,8),16)/255)}let M=E;if(h instanceof HTMLSpanElement)h.style.color="black",h.style.color=E,document.body.appendChild(h),M=getComputedStyle(h).color,h.remove();let[L,H,J,$]=M.match(/[\d.]+/g)||["0","0","0","0"],Z=M.startsWith("color(srgb")?255:1;return new w(Number(L)*Z,Number(H)*Z,Number(J)*Z,$==null?1:Number($))}static fromHsl(E,f,M,L=1){let H,J,$;if(f===0)H=J=$=M;else{let Y=(U,x,X)=>{if(X<0)X+=1;if(X>1)X-=1;if(X<0.16666666666666666)return U+(x-U)*6*X;if(X<0.5)return x;if(X<0.6666666666666666)return U+(x-U)*(0.6666666666666666-X)*6;return U},Q=M<0.5?M*(1+f):M+f-M*f,G=2*M-Q,F=(E%360+360)%360/360;H=Y(G,Q,F+0.3333333333333333),J=Y(G,Q,F),$=Y(G,Q,F-0.3333333333333333)}let Z=new w(H*255,J*255,$*255,L);return Z.hslCached={h:(E%360+360)%360,s:f,l:M},Z}static black=new w(0,0,0);static white=new w(255,255,255);constructor(E,f,M,L=1){this.r=N(0,E,255),this.g=N(0,f,255),this.b=N(0,M,255),this.a=N(0,L,1)}get inverse(){return new w(255-this.r,255-this.g,255-this.b,this.a)}get inverseLuminance(){let{h:E,s:f,l:M}=this._hsl;return w.fromHsl(E,f,1-M,this.a)}get opaque(){return this.a===1?this:new w(this.r,this.g,this.b,1)}contrasting(E=1){return this.opaque.blend(this.brightness>0.5?w.black:w.white,E)}get rgb(){let{r:E,g:f,b:M}=this;return`rgb(${E.toFixed(0)},${f.toFixed(0)},${M.toFixed(0)})`}get rgba(){let{r:E,g:f,b:M,a:L}=this;return`rgba(${E.toFixed(0)},${f.toFixed(0)},${M.toFixed(0)},${L.toFixed(2)})`}get RGBA(){return[this.r/255,this.g/255,this.b/255,this.a]}get ARGB(){return[this.a,this.r/255,this.g/255,this.b/255]}hslCached;get _hsl(){if(this.hslCached==null)this.hslCached=new lf(this.r,this.g,this.b);return this.hslCached}get hsl(){let{h:E,s:f,l:M}=this._hsl;return`hsl(${E.toFixed(0)}deg ${(f*100).toFixed(0)}% ${(M*100).toFixed(0)}%)`}get hsla(){let{h:E,s:f,l:M}=this._hsl;return`hsl(${E.toFixed(0)}deg ${(f*100).toFixed(0)}% ${(M*100).toFixed(0)}% / ${(this.a*100).toFixed(0)}%)`}get mono(){let E=this.brightness*255;return new w(E,E,E)}get brightness(){return ML(this.r,this.g,this.b)}get html(){return this.toString()}toString(){return this.a===1?"#"+ME(this.r)+ME(this.g)+ME(this.b):"#"+ME(this.r)+ME(this.g)+ME(this.b)+ME(Math.floor(255*this.a))}brighten(E){let{h:f,s:M,l:L}=this._hsl,H=N(0,L+E*(1-L),1);return w.fromHsl(f,M,H,this.a)}darken(E){let{h:f,s:M,l:L}=this._hsl,H=N(0,L*(1-E),1);return w.fromHsl(f,M,H,this.a)}saturate(E){let{h:f,s:M,l:L}=this._hsl,H=N(0,M+E*(1-M),1);return w.fromHsl(f,H,L,this.a)}desaturate(E){let{h:f,s:M,l:L}=this._hsl,H=N(0,M*(1-E),1);return w.fromHsl(f,H,L,this.a)}rotate(E){let{h:f,s:M,l:L}=this._hsl,H=(f+360+E)%360;return w.fromHsl(H,M,L,this.a)}opacity(E){let{h:f,s:M,l:L}=this._hsl;return w.fromHsl(f,M,L,E)}swatch(){return console.log(`%c %c ${this.html}, ${this.rgba}`,`background-color: ${this.html}`,"background-color: transparent"),this}blend(E,f){return new w(d(this.r,E.r,f),d(this.g,E.g,f),d(this.b,E.b,f),d(this.a,E.a,f))}static blendHue(E,f,M){let L=(f-E+720)%360;if(L<180)return E+M*L;else return E-(360-L)*M}mix(E,f){let M=this._hsl,L=E._hsl;return w.fromHsl(M.s===0?L.h:L.s===0?M.h:w.blendHue(M.h,L.h,f),d(M.s,L.s,f),d(M.l,L.l,f),d(this.a,E.a,f))}colorMix(E,f){return w.fromCss(`color-mix(in hsl, ${this.html}, ${E.html} ${(f*100).toFixed(0)}%)`)}static computedColorStylesheet=null;static computedColors=new Map;static recomputeQueued=!1;static registerComputedColor(E,f,M,L){if(!w.computedColors.has(E))w.computedColors.set(E,{varName:f,scale:M,method:L}),w.queueRecompute()}static queueRecompute(){if(w.recomputeQueued)return;w.recomputeQueued=!0,queueMicrotask(()=>{w.recomputeQueued=!1,w.recomputeColors()})}static recomputeColors(){if(w.computedColors.size===0)return;let E=[];for(let[M,{varName:L,scale:H,method:J}]of w.computedColors)try{let $=w.fromVar(L),Z;switch(J){case"b":Z=H>0?$.brighten(H):$.darken(-H);break;case"s":Z=H>0?$.saturate(H):$.desaturate(-H);break;case"h":Z=$.rotate(H*100);break;case"o":Z=$.opacity(H);break;default:continue}E.push(` ${M}: ${Z.rgba};`)}catch($){}if(E.length===0)return;let f=`:root {
1
+ (()=>{var{defineProperty:hE,getOwnPropertyNames:uM,getOwnPropertyDescriptor:nM}=Object,vM=Object.prototype.hasOwnProperty;function dM(E){return this[E]}var gM=(E)=>{var f=(If??=new WeakMap).get(E),M;if(f)return f;if(f=hE({},"__esModule",{value:!0}),E&&typeof E==="object"||typeof E==="function"){for(var L of uM(E))if(!vM.call(f,L))hE(f,L,{get:dM.bind(E,L),enumerable:!(M=nM(E,L))||M.enumerable})}return If.set(E,f),f},If;var iM=(E)=>E;function hM(E,f){this[E]=iM.bind(null,f)}var sM=(E,f)=>{for(var M in f)hE(E,M,{get:f[M],enumerable:!0,configurable:!0,set:hM.bind(f,M)})};var uL={};sM(uL,{xinValue:()=>Nf,xinSlot:()=>xM,xinProxy:()=>dE,xinPath:()=>_f,xin:()=>x,warnDeprecated:()=>C,version:()=>vE,vars:()=>BE,varDefault:()=>WE,validateAgainstConstraints:()=>bE,updates:()=>EE,unobserve:()=>m,touchElement:()=>cE,touch:()=>I,tosiValue:()=>T,tosiSlot:()=>jM,tosiSetValue:()=>Sf,tosiPath:()=>O,tosiLoader:()=>NM,tosiBlueprint:()=>_M,tosi:()=>KE,throttle:()=>fE,sync:()=>SM,svgElements:()=>_E,share:()=>BM,settings:()=>i,scrollListItemIntoView:()=>qM,onThemePreferencesChange:()=>HM,onStylesheetChange:()=>af,on:()=>LE,observe:()=>GE,mathML:()=>NE,makeComponent:()=>TE,invertLuminance:()=>LM,initVars:()=>MM,hotReload:()=>VM,getThemePreferences:()=>Ff,getListItem:()=>PE,getListInstance:()=>mE,getListBinding:()=>QE,getCssVar:()=>IE,elements:()=>W,deprecated:()=>xE,deleteListItem:()=>DM,debounce:()=>ZE,css:()=>s,boxedProxy:()=>AE,boxed:()=>B,blueprintLoader:()=>bM,blueprint:()=>PM,bindings:()=>zE,bindParts:()=>GM,bind:()=>c,StyleSheet:()=>EM,MoreMath:()=>lf,Component:()=>N,Color:()=>X,BlueprintLoader:()=>iE,Blueprint:()=>jE});function b(E){if(E==null||typeof E!=="object")return E;if(E instanceof Set)return new Set(E);else if(Array.isArray(E))return E.map(b);let f={};for(let M in E){let L=E[M];if(E!=null&&typeof E==="object")f[M]=b(L);else f[M]=L}return f}var oE="-xin-data",g=`.${oE}`,rE="-xin-event",pE=`.${rE}`,S=Symbol.for("xin-path"),n=Symbol.for("xin-value"),lE="xinObserve",tE="xinBind",eE="xinOn",YE=Symbol("list-binding"),t=Symbol("list-instance"),sE=new Map;function Bf(E,f){let M=sE.get(E);if(M===void 0)M=new Set,sE.set(E,M);M.add(f)}function yf(E){return sE.get(E)}var kf=new Set;function C(E,f){if(!kf.has(E))console.warn(f),kf.add(E)}function xE(E,f){let M=!1;return(...L)=>{if(!M)console.warn(f),M=!0;return E(...L)}}var O=(E)=>{return E&&E[S]||void 0};function T(E){if(typeof E==="object"&&E!==null){let f=E[n];return f!==void 0?f:E}return E}function Sf(E,f){if(O(E)===void 0)throw Error("tosiSetValue requires a xin or boxed proxy");E[n]=f}var _f=xE(O,"xinPath is deprecated. Use tosiPath instead."),Nf=xE(T,"xinValue is deprecated. Use tosiValue instead."),l=new WeakMap,u=new WeakMap;var e=(E)=>{let f=E.cloneNode();if(f instanceof Element){let M=u.get(E),L=l.get(E);if(M!=null)u.set(f,b(M));if(L!=null)l.set(f,b(L))}for(let M of Array.from(E instanceof HTMLTemplateElement?E.content.childNodes:E.childNodes))if(M instanceof Element||M instanceof DocumentFragment)f.appendChild(e(M));else f.appendChild(M.cloneNode());return f};var i={debug:!1,perf:!1};var oM=(E)=>{try{return JSON.stringify(E)}catch(f){return"{has circular references}"}},aE=(...E)=>Error(E.map(oM).join(" "));var rM=()=>new Date(parseInt("1000000000",36)+Date.now()).valueOf().toString(36).slice(1),pM=0,lM=()=>(parseInt("10000",36)+ ++pM).toString(36).slice(-5),tM=()=>rM()+lM(),ff=Symbol("delete"),cf=Symbol("new-object"),Ef=Symbol("automatic-index");function bf(E){if(E==="")return[];if(Array.isArray(E))return E;else{let f=[];while(E.length>0){let M=E.search(/\[[^\]]+\]/);if(M===-1){f.push(E.split("."));break}else{let L=E.slice(0,M);if(E=E.slice(M),L!=="")f.push(L.split("."));if(M=E.indexOf("]")+1,f.push(E.slice(1,M-1)),E.slice(M,M+1)===".")M+=1;E=E.slice(M)}}return f}}var v=new WeakMap;function uf(E,f){if(v.get(E)===void 0)v.set(E,{});if(v.get(E)[f]===void 0)v.get(E)[f]={};let M=v.get(E)[f];if(f==="_auto_")E.forEach((L,H)=>{if(L[Ef]===void 0)L[Ef]=tM();M[L[Ef]+""]=H});else E.forEach((L,H)=>{M[j(L,f)+""]=H});return M}function eM(E,f){if(v.get(E)===void 0||v.get(E)[f]===void 0)return uf(E,f);else return v.get(E)[f]}function aM(E,f,M){M=M+"";let L=eM(E,f)[M];if(L===void 0||j(E[L],f)+""!==M)L=uf(E,f)[M];return L}function EL(E,f,M){if(E[f]===void 0&&M!==void 0)E[f]=M;return E[f]}function nf(E,f,M,L){let H=f!==""?aM(E,f,M):M;if(L===ff)return E.splice(H,1),v.delete(E),Symbol("deleted");else if(L===cf){if(f===""&&E[H]===void 0)E[H]={}}else if(L!==void 0)if(H!==void 0)E[H]=L;else if(f!==""&&j(L,f)+""===M+"")E.push(L),H=E.length-1;else throw Error(`byIdPath insert failed at [${f}=${M}]`);return E[H]}function mf(E){if(!Array.isArray(E))throw aE("setByPath failed: expected array, found",E)}function Pf(E){if(E==null||!(E instanceof Object))throw aE("setByPath failed: expected Object, found",E)}function j(E,f){let M=bf(f),L=E,H,J,$,Z;for(H=0,J=M.length;L!==void 0&&H<J;H++){let Y=M[H];if(Array.isArray(Y))for($=0,Z=Y.length;L!==void 0&&$<Z;$++){let Q=Y[$];L=L[Q]}else if(L.length===0){if(L=L[Number(Y.slice(1))],Y[0]!=="=")return}else if(Y.includes("=")){let[Q,...G]=Y.split("=");L=nf(L,Q,G.join("="))}else $=parseInt(Y,10),L=L[$]}return L}function a(E,f,M){let L=E;if(f==="")throw Error("setByPath cannot be used to set the root object");let H=bf(f);while(L!=null&&H.length>0){let J=H.shift();if(typeof J==="string"){let $=J.indexOf("=");if($>-1){if($===0)Pf(L);else mf(L);let Z=J.slice(0,$),Y=J.slice($+1);if(L=nf(L,Z,Y,H.length>0?cf:M),H.length===0)return!0}else{mf(L);let Z=parseInt(J,10);if(H.length>0)L=L[Z];else{if(M!==ff){if(L[Z]===M)return!1;L[Z]=M}else L.splice(Z,1);return!0}}}else if(Array.isArray(J)&&J.length>0){Pf(L);while(J.length>0){let $=J.shift();if(J.length>0||H.length>0)L=EL(L,$,J.length>0?{}:[]);else{if(M!==ff){if(L[$]===M)return!1;L[$]=M}else{if(!Object.prototype.hasOwnProperty.call(L,$))return!1;delete L[$]}return!0}}}else throw Error(`setByPath failed, bad path ${f}`)}throw Error(`setByPath(${E}, ${f}, ${M}) failed`)}var R={},Mf=null,vf=(E)=>{Mf=E},VE=()=>{if(Mf===null)throw Error("xin proxy not initialized");return Mf},Lf=null,Hf=null,df=(E,f)=>{Lf=E,Hf=f},XE=()=>{if(Lf===null)throw Error("bind not initialized");return Lf},FE=()=>{if(Hf===null)throw Error("on not initialized");return Hf};var gf=Symbol("observer should be removed"),RE=[],$E=[],Jf=!1,Yf,$f;function fL(E,f,M,L){let H=yf(E);if(H===void 0)return[];let J=[];for(let $ of H){let Z=j(M,$);if(Z!==void 0)J.push(`${E}[${$}=${Z}]${L}`)}return J}class hf{description;test;callback;constructor(E,f){let M=typeof f==="string"?`"${f}"`:`function ${f.name}`,L;if(typeof E==="string")this.test=(H)=>typeof H==="string"&&H!==""&&(E.startsWith(H)||H.startsWith(E)),L=`test = "${E}"`;else if(E instanceof RegExp)this.test=E.test.bind(E),L=`test = "${E.toString()}"`;else if(E instanceof Function)this.test=E,L=`test = function ${E.name}`;else throw Error("expect listener test to be a string, RegExp, or test function");if(this.description=`${L}, ${M}`,typeof f==="function")this.callback=f;else throw Error("expect callback to be a path or function");RE.push(this)}}var EE=async()=>{if(Yf===void 0)return;await Yf},ML=()=>{if(i.perf)console.time("xin async update");let E=Array.from($E);$E.length=0,Jf=!1;for(let f of E)RE.filter((M)=>{let L;try{L=M.test(f)}catch(H){throw Error(`Listener ${M.description} threw "${H}" at "${f}"`)}if(L===gf)return m(M),!1;return L}).forEach((M)=>{let L;try{L=M.callback(f)}catch(H){console.error(`Listener ${M.description} threw "${H}" handling "${f}"`)}if(L===gf)m(M)});if(typeof $f==="function")$f();if(i.perf)console.timeEnd("xin async update")},I=(E)=>{let f=typeof E==="string"?E:O(E);if(f===void 0)throw console.error("touch was called on an invalid target",E),Error("touch was called on an invalid target");if(Jf===!1)Yf=new Promise((L)=>{$f=L}),Jf=setTimeout(ML);if($E.find((L)=>f.startsWith(L))==null)$E.push(f);let M=f.match(/^(.+)\[(\d+)\](.*)$/);if(M!==null){let[,L,H,J]=M,$=parseInt(H,10),Z=j(R,`${L}[${$}]`);if(Z!=null){let Y=fL(L,$,Z,J);for(let Q of Y)if($E.find((G)=>Q.startsWith(G))==null)$E.push(Q)}}},_=(E,f)=>{return new hf(E,f)},m=(E)=>{let f=RE.indexOf(E);if(f>-1)RE.splice(f,1);else throw Error("unobserve failed, listener not found")};var Zf=(E,f)=>{let M=new Event(f);E.dispatchEvent(M)},of=(E)=>{if(E instanceof HTMLInputElement)return E.type;else if(E instanceof HTMLSelectElement&&E.hasAttribute("multiple"))return"multi-select";else return"other"},rf=(E,f)=>{switch(of(E)){case"radio":E.checked=E.value===f;break;case"checkbox":E.checked=!!f;break;case"date":E.valueAsDate=new Date(f);break;case"multi-select":for(let M of Array.from(E.querySelectorAll("option")))M.selected=f[M.value];break;default:E.value=f}},pf=(E)=>{switch(of(E)){case"radio":{let f=E.parentElement?.querySelector(`[name="${E.name}"]:checked`);return f!=null?f.value:null}case"checkbox":return E.checked;case"date":return E.valueAsDate?.toISOString();case"multi-select":return Array.from(E.querySelectorAll("option")).reduce((f,M)=>{return f[M.value]=M.selected,f},{});default:return E.value}},{ResizeObserver:sf}=globalThis,wE=sf!=null?new sf((E)=>{for(let f of E){let M=f.target;Zf(M,"resize")}}):{observe(){},unobserve(){}},Qf=(E,f,M=!0)=>{if(E!=null&&f!=null)if(typeof f==="string")E.textContent=f;else if(Array.isArray(f))f.forEach((L)=>{E.append(L instanceof Node&&M?e(L):L)});else if(f instanceof Node)E.append(M?e(f):f);else throw Error("expect text content or document node")};var ZE=(E,f=250)=>{let M;return(...L)=>{if(M!==void 0)clearTimeout(M);M=setTimeout(()=>{E(...L)},f)}},fE=(E,f=250)=>{let M,L=Date.now()-f,H=!1;return(...J)=>{if(clearTimeout(M),M=setTimeout(()=>{E(...J),L=Date.now()},f),!H&&Date.now()-L>=f){H=!0;try{E(...J),L=Date.now()}finally{H=!1}}}};var zE={value:{toDOM:rf,fromDOM(E){return pf(E)}},text:{toDOM(E,f){E.textContent=f}},enabled:{toDOM(E,f){E.disabled=!f}},disabled:{toDOM(E,f){E.disabled=Boolean(f)}},list:{toDOM(E,f,M){QE(E,f,M).update(f)}}};function k(E){return E.replace(/[A-Z]/g,(f)=>{return`-${f.toLocaleLowerCase()}`})}function Gf(E){return E.replace(/-([a-z])/g,(f,M)=>{return M.toLocaleUpperCase()})}var LL=180/Math.PI,HL=Math.PI/180;function P(E,f,M){return M<E?NaN:f<E?E:f>M?M:f}function d(E,f,M,L=!0){if(L)M=P(0,M,1);return M*(f-E)+E}var lf={RADIANS_TO_DEGREES:LL,DEGREES_TO_RADIANS:HL,clamp:P,lerp:d};function IE(E,f=document.body){let M=getComputedStyle(f);if(E.endsWith(")")&&E.startsWith("var("))E=E.slice(4,-1);return M.getPropertyValue(E).trim()}var JL=(E,f,M)=>{return(0.299*E+0.587*f+0.114*M)/255},ME=(E)=>("00"+Math.round(Number(E)).toString(16)).slice(-2);class tf{h;s;l;constructor(E,f,M){E/=255,f/=255,M/=255;let L=Math.max(E,f,M),H=L-Math.min(E,f,M),J=H!==0?L===E?(f-M)/H:L===f?2+(M-E)/H:4+(E-f)/H:0;this.h=60*J<0?60*J+360:60*J,this.s=H!==0?L<=0.5?H/(2*L-H):H/(2-(2*L-H)):0,this.l=(2*L-H)/2}}var h=globalThis.document!==void 0?globalThis.document.createElement("span"):void 0;if(h)h.style.display="none";class X{r;g;b;a;static fromVar(E,f=document.body){return X.fromCss(IE(E,f))}static fromCss(E){let f=E.match(/^#([0-9a-fA-F]+)$/);if(f){let Y=f[1];if(Y.length===3)return new X(parseInt(Y[0]+Y[0],16),parseInt(Y[1]+Y[1],16),parseInt(Y[2]+Y[2],16));if(Y.length===4)return new X(parseInt(Y[0]+Y[0],16),parseInt(Y[1]+Y[1],16),parseInt(Y[2]+Y[2],16),parseInt(Y[3]+Y[3],16)/255);if(Y.length===6)return new X(parseInt(Y.slice(0,2),16),parseInt(Y.slice(2,4),16),parseInt(Y.slice(4,6),16));if(Y.length===8)return new X(parseInt(Y.slice(0,2),16),parseInt(Y.slice(2,4),16),parseInt(Y.slice(4,6),16),parseInt(Y.slice(6,8),16)/255)}let M=E;if(h instanceof HTMLSpanElement)h.style.color="black",h.style.color=E,document.body.appendChild(h),M=getComputedStyle(h).color,h.remove();let[L,H,J,$]=M.match(/[\d.]+/g)||["0","0","0","0"],Z=M.startsWith("color(srgb")?255:1;return new X(Number(L)*Z,Number(H)*Z,Number(J)*Z,$==null?1:Number($))}static fromHsl(E,f,M,L=1){let H,J,$;if(f===0)H=J=$=M;else{let Y=(U,V,w)=>{if(w<0)w+=1;if(w>1)w-=1;if(w<0.16666666666666666)return U+(V-U)*6*w;if(w<0.5)return V;if(w<0.6666666666666666)return U+(V-U)*(0.6666666666666666-w)*6;return U},Q=M<0.5?M*(1+f):M+f-M*f,G=2*M-Q,F=(E%360+360)%360/360;H=Y(G,Q,F+0.3333333333333333),J=Y(G,Q,F),$=Y(G,Q,F-0.3333333333333333)}let Z=new X(H*255,J*255,$*255,L);return Z.hslCached={h:(E%360+360)%360,s:f,l:M},Z}static black=new X(0,0,0);static white=new X(255,255,255);constructor(E,f,M,L=1){this.r=P(0,E,255),this.g=P(0,f,255),this.b=P(0,M,255),this.a=P(0,L,1)}get inverse(){return new X(255-this.r,255-this.g,255-this.b,this.a)}get inverseLuminance(){let{h:E,s:f,l:M}=this._hsl;return X.fromHsl(E,f,1-M,this.a)}get opaque(){return this.a===1?this:new X(this.r,this.g,this.b,1)}contrasting(E=1){return this.opaque.blend(this.brightness>0.5?X.black:X.white,E)}get rgb(){let{r:E,g:f,b:M}=this;return`rgb(${E.toFixed(0)},${f.toFixed(0)},${M.toFixed(0)})`}get rgba(){let{r:E,g:f,b:M,a:L}=this;return`rgba(${E.toFixed(0)},${f.toFixed(0)},${M.toFixed(0)},${L.toFixed(2)})`}get RGBA(){return[this.r/255,this.g/255,this.b/255,this.a]}get ARGB(){return[this.a,this.r/255,this.g/255,this.b/255]}hslCached;get _hsl(){if(this.hslCached==null)this.hslCached=new tf(this.r,this.g,this.b);return this.hslCached}get hsl(){let{h:E,s:f,l:M}=this._hsl;return`hsl(${E.toFixed(0)}deg ${(f*100).toFixed(0)}% ${(M*100).toFixed(0)}%)`}get hsla(){let{h:E,s:f,l:M}=this._hsl;return`hsl(${E.toFixed(0)}deg ${(f*100).toFixed(0)}% ${(M*100).toFixed(0)}% / ${(this.a*100).toFixed(0)}%)`}get mono(){let E=this.brightness*255;return new X(E,E,E)}get brightness(){return JL(this.r,this.g,this.b)}get html(){return this.toString()}toString(){return this.a===1?"#"+ME(this.r)+ME(this.g)+ME(this.b):"#"+ME(this.r)+ME(this.g)+ME(this.b)+ME(Math.floor(255*this.a))}brighten(E){let{h:f,s:M,l:L}=this._hsl,H=P(0,L+E*(1-L),1);return X.fromHsl(f,M,H,this.a)}darken(E){let{h:f,s:M,l:L}=this._hsl,H=P(0,L*(1-E),1);return X.fromHsl(f,M,H,this.a)}saturate(E){let{h:f,s:M,l:L}=this._hsl,H=P(0,M+E*(1-M),1);return X.fromHsl(f,H,L,this.a)}desaturate(E){let{h:f,s:M,l:L}=this._hsl,H=P(0,M*(1-E),1);return X.fromHsl(f,H,L,this.a)}rotate(E){let{h:f,s:M,l:L}=this._hsl,H=(f+360+E)%360;return X.fromHsl(H,M,L,this.a)}opacity(E){let{h:f,s:M,l:L}=this._hsl;return X.fromHsl(f,M,L,E)}swatch(){return console.log(`%c %c ${this.html}, ${this.rgba}`,`background-color: ${this.html}`,"background-color: transparent"),this}blend(E,f){return new X(d(this.r,E.r,f),d(this.g,E.g,f),d(this.b,E.b,f),d(this.a,E.a,f))}static blendHue(E,f,M){let L=(f-E+720)%360;if(L<180)return E+M*L;else return E-(360-L)*M}mix(E,f){let M=this._hsl,L=E._hsl;return X.fromHsl(M.s===0?L.h:L.s===0?M.h:X.blendHue(M.h,L.h,f),d(M.s,L.s,f),d(M.l,L.l,f),d(this.a,E.a,f))}colorMix(E,f){return X.fromCss(`color-mix(in hsl, ${this.html}, ${E.html} ${(f*100).toFixed(0)}%)`)}static computedColorStylesheet=null;static computedColors=new Map;static recomputeQueued=!1;static registerComputedColor(E,f,M,L){if(!X.computedColors.has(E))X.computedColors.set(E,{varName:f,scale:M,method:L}),X.queueRecompute()}static queueRecompute(){if(X.recomputeQueued)return;X.recomputeQueued=!0,queueMicrotask(()=>{X.recomputeQueued=!1,X.recomputeColors()})}static recomputeColors(){if(X.computedColors.size===0)return;let E=[];for(let[M,{varName:L,scale:H,method:J}]of X.computedColors)try{let $=X.fromVar(L),Z;switch(J){case"b":Z=H>0?$.brighten(H):$.darken(-H);break;case"s":Z=H>0?$.saturate(H):$.desaturate(-H);break;case"h":Z=$.rotate(H*100);break;case"o":Z=$.opacity(H);break;default:continue}E.push(` ${M}: ${Z.rgba};`)}catch($){}if(E.length===0)return;let f=`:root {
2
2
  ${E.join(`
3
3
  `)}
4
- }`;if(w.computedColorStylesheet===null)w.computedColorStylesheet=document.createElement("style"),w.computedColorStylesheet.id="tosijs-computed-colors",document.head.append(w.computedColorStylesheet);w.computedColorStylesheet.textContent=f}}var IE=new Set,tf=!1;function LL(){if(!tf)tf=!0,IE.add(()=>w.queueRecompute())}function ef(E){return IE.add(E),()=>IE.delete(E)}function HL(){LL();for(let E of IE)E()}function af(E,f){let M=A(f),L=W.style(s(M));L.id=E,document.head.append(L);let H=T(f);if(H!==void 0)GE(H,()=>{L.textContent=s(A(f)),HL()})}var JL=/^(animation-iteration-count|column-count|flex(-grow|-shrink)?|font-weight|line-height|opacity|order|orphans|scale|tab-size|widows|z-index|zoom)$/,Qf=(E,f)=>{if(typeof f==="number"&&!JL.test(E))f=`${f}px`;if(E.startsWith("_"))if(E.startsWith("__"))E="--"+E.substring(2),f=`var(${E}-default, ${f})`;else E="--"+E.substring(1);return{prop:E,value:String(f)}},YL=(E,f,M)=>{if(M===void 0)return"";if(M instanceof w)M=M.html;let L=Qf(f,M);return`${E} ${L.prop}: ${L.value};`},EM=(E,f,M="")=>{let L=I(E);if(typeof f==="object"&&!(f instanceof w)){let H=Object.keys(f).map((J)=>EM(J,f[J],`${M} `)).join(`
4
+ }`;if(X.computedColorStylesheet===null)X.computedColorStylesheet=document.createElement("style"),X.computedColorStylesheet.id="tosijs-computed-colors",document.head.append(X.computedColorStylesheet);X.computedColorStylesheet.textContent=f}}var kE=new Set,ef=!1;function YL(){if(!ef)ef=!0,kE.add(()=>X.queueRecompute())}function af(E){return kE.add(E),()=>kE.delete(E)}function $L(){YL();for(let E of kE)E()}function EM(E,f){let M=T(f),L=W.style(s(M));L.id=E,document.head.append(L);let H=O(f);if(H!==void 0)GE(H,()=>{L.textContent=s(T(f)),$L()})}var ZL=/^(animation-iteration-count|column-count|flex(-grow|-shrink)?|font-weight|line-height|opacity|order|orphans|scale|tab-size|widows|z-index|zoom)$/,Xf=(E,f)=>{if(typeof f==="number"&&!ZL.test(E))f=`${f}px`;if(E.startsWith("_"))if(E.startsWith("__"))E="--"+E.substring(2),f=`var(${E}-default, ${f})`;else E="--"+E.substring(1);return{prop:E,value:String(f)}},QL=(E,f,M)=>{if(M===void 0)return"";if(M instanceof X)M=M.html;let L=Xf(f,M);return`${E} ${L.prop}: ${L.value};`},fM=(E,f,M="")=>{let L=k(E);if(typeof f==="object"&&!(f instanceof X)){let H=Object.keys(f).map((J)=>fM(J,f[J],`${M} `)).join(`
5
5
  `);return`${M} ${E} {
6
6
  ${H}
7
- ${M} }`}else return YL(M,L,f)},s=(E,f="")=>{return Object.keys(E).map((L)=>{let H=E[L];if(typeof H==="string"){if(L==="@import")return`@import url('${H}');`;throw Error("top-level string value only allowed for `@import`")}let J=Object.keys(H).map(($)=>EM($,H[$])).join(`
7
+ ${M} }`}else return QL(M,L,f)},s=(E,f="")=>{return Object.keys(E).map((L)=>{let H=E[L];if(typeof H==="string"){if(L==="@import")return`@import url('${H}');`;throw Error("top-level string value only allowed for `@import`")}let J=Object.keys(H).map(($)=>fM($,H[$])).join(`
8
8
  `);return`${f}${L} {
9
9
  ${J}
10
10
  }`}).join(`
11
11
 
12
- `)},fM=(E)=>{V("initVars","initVars is deprecated. Just use _ and __ prefixes instead.");let f={};for(let M of Object.keys(E)){let L=E[M],H=I(M);f[`--${H}`]=typeof L==="number"&&L!==0?String(L)+"px":L}return f},MM=(E)=>{let f={};for(let M of Object.keys(E)){let L=E[M];if(L instanceof w)f[M]=L.inverseLuminance;else if(typeof L==="string"&&L.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))f[M]=w.fromCss(L).inverseLuminance}return f},WE=new Proxy({},{get(E,f){if(E[f]===void 0){let M="--"+I(f);E[f]=(L)=>`var(${M}, ${L})`}return E[f]}}),BE=new Proxy({},{get(E,f){if(f==="default")return WE;if(E[f]==null){f=I(f);let[,M,,L,H,J]=f.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",f],$=`--${M}`;if(H!=null){let Z=L==null?Number(H)/100:-Number(H)/100;switch(J){case"b":case"s":case"h":case"o":{let Y=`--${f}`;w.registerComputedColor(Y,$,Z,J),E[f]=`var(${Y})`}break;case"":E[f]=`calc(var(${$}) * ${Z})`;break;default:throw console.error(J),Error(`Unrecognized method ${J} for css variable ${$}`)}}else E[f]=`var(${$})`}return E[f]}});function Gf(){let E=(f)=>typeof matchMedia<"u"&&matchMedia(f).matches;return{colorScheme:E("(prefers-color-scheme: dark)")?"dark":"light",contrast:E("(prefers-contrast: more)")?"more":E("(prefers-contrast: less)")?"less":E("(prefers-contrast: custom)")?"custom":"no-preference",reducedMotion:E("(prefers-reduced-motion: reduce)"),reducedTransparency:E("(prefers-reduced-transparency: reduce)"),forcedColors:E("(forced-colors: active)")}}function LM(E){if(typeof matchMedia>"u")return()=>{};let f=["(prefers-color-scheme: dark)","(prefers-contrast: more)","(prefers-contrast: less)","(prefers-contrast: custom)","(prefers-reduced-motion: reduce)","(prefers-reduced-transparency: reduce)","(forced-colors: active)"],M=()=>E(Gf()),L=f.map((H)=>matchMedia(H));for(let H of L)H.addEventListener("change",M);return()=>{for(let H of L)H.removeEventListener("change",M)}}var HM="http://www.w3.org/1998/Math/MathML",JM="http://www.w3.org/2000/svg";var yE={},$M=(E,f,M)=>{let L=Qf(I(f),M);if(L.prop.startsWith("--"))E.style.setProperty(L.prop,L.value);else E.style[f]=L.value},$L=(E)=>{return{toDOM(f,M){$M(f,E,M)}}},ZM=(E,f,M)=>{if(f==="style")if(typeof M==="object")for(let L of Object.keys(M))if(T(M[L]))P(E,M[L],$L(L));else $M(E,L,M[L]);else E.setAttribute("style",M);else{let L=I(f),H=E.constructor.observedAttributes;if(H?.includes(f)||H?.includes(L))if(typeof M==="boolean")M?E.setAttribute(L,""):E.removeAttribute(L);else E.setAttribute(L,M);else if(E[f]!==void 0){let{MathMLElement:$}=globalThis;if(E instanceof SVGElement||$!==void 0&&E instanceof $)E.setAttribute(f,M);else E[f]=M}else if(L==="class")M.split(" ").forEach(($)=>{E.classList.add($)});else if(E[L]!==void 0)E[L]=M;else if(typeof M==="boolean")M?E.setAttribute(L,""):E.removeAttribute(L);else E.setAttribute(L,M)}},wf={},ZL=(E)=>{if(!wf[E])wf[E]={toDOM(f,M){ZM(f,E,M)}};return wf[E]},QM=(E,f,M)=>{if(f==="apply")M(E);else if(f.match(/^on[A-Z]/)!=null){let L=f.substring(2).toLowerCase();LE(E,L,M)}else if(f==="bind")if((typeof M.binding==="string"?zE[M.binding]:M.binding)!==void 0&&M.value!==void 0)P(E,M.value,M.binding instanceof Function?{toDOM:M.binding}:M.binding);else throw Error("bad binding");else if(f.match(/^bind[A-Z]/)!=null){let L=f.substring(4,5).toLowerCase()+f.substring(5),H=zE[L];if(H!==void 0)P(E,M,H);else throw Error(`${f} is not allowed, bindings.${L} is not defined`)}else if(T(M))P(E,M,ZL(f));else ZM(E,f,M)},Ff=(E,...f)=>{if(yE[E]===void 0){let[H,J]=E.split("|");if(J===void 0)yE[E]=globalThis.document.createElement(H);else yE[E]=globalThis.document.createElementNS(J,H)}let M=yE[E].cloneNode(),L={};for(let H of f)if(H instanceof Element||H instanceof DocumentFragment||typeof H==="string"||typeof H==="number")if(M instanceof HTMLTemplateElement)M.content.append(H);else M.append(H);else if(T(H))M.append(W.span({bindText:H}));else Object.assign(L,H);for(let H of Object.keys(L)){let J=L[H];QM(M,H,J)}return M},Xf=(...E)=>{let f=globalThis.document.createDocumentFragment();for(let M of E)f.append(M);return f},W=new Proxy({fragment:Xf},{get(E,f){if(f=f.replace(/[A-Z]/g,(M)=>`-${M.toLocaleLowerCase()}`),E[f]===void 0)E[f]=(...M)=>Ff(f,...M);return E[f]},set(){throw Error("You may not add new properties to elements")}}),SE=new Proxy({fragment:Xf},{get(E,f){if(E[f]===void 0)E[f]=(...M)=>Ff(`${f}|${JM}`,...M);return E[f]},set(){throw Error("You may not add new properties to elements")}}),_E=new Proxy({fragment:Xf},{get(E,f){if(E[f]===void 0)E[f]=(...M)=>Ff(`${f}|${HM}`,...M);return E[f]},set(){throw Error("You may not add new properties to elements")}}),YM=new WeakSet;function GM(E,f,M="part"){let L=`[data-${M}]`;for(let H of Array.from(E.querySelectorAll(L))){if(YM.has(H))continue;let J=H.getAttribute(`data-${M}`);if(J==null)continue;let $=f[J];if($==null)continue;YM.add(H);for(let Z of Object.keys($))QM(H,Z,$[Z])}}var QL=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],GL=!0,wL=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,FL=(E)=>wL.test(E),o=(E="",f="")=>{if(E==="")return f;else if(f.match(/^\d+$/)!==null||f.includes("="))return`${E}[${f}]`;else return`${E}.${f}`},zM={};function zf(E,f){if(E!==null&&(typeof E==="object"||typeof E==="function"))return E;return new Proxy(zM,r(f,!0))}var UE=()=>new Proxy({},r("^",!0)),Wf=(E)=>{let M=E(UE())?.path;if(!M?.startsWith("^."))throw Error("selector must return a property of the item");return M.substring(2)},Uf=(E,f,M)=>{for(let L=0;L<E.length;L++)if(`${j(E[L],f)}`===`${M}`)return L;return-1},wM=(E,f)=>({listFind(M,L){if(M instanceof Element){let $=M;while($&&!$[t]&&$.parentElement)$=$.parentElement;let Z=$?.[t];if(Z==null)return;let Y=f.indexOf(Z);return Y!==-1?B[E][Y]:void 0}let H=Wf(M),J=Uf(f,H,L);return J!==-1?B[E][J]:void 0},listUpdate(M,L){let H=Wf(M),J=j(L,H),$=Uf(f,H,J);if($!==-1){let Z=B[E][$];for(let Y of Object.keys(L))Z[Y]=L[Y];return Z}return B[E].push(L),B[E][f.length-1]},listRemove(M,L){let H=Wf(M),J=Uf(f,H,L);if(J===-1)return!1;return B[E].splice(J,1),!0}}),FM=!1;function HE(){if(!FM)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use value, path, observe, bind, on, binding, listBinding instead."),FM=!0}var XM=(E)=>{return E===zM},r=(E,f)=>({get(M,L){if(XM(M)){let Z=()=>j(R,E);switch(L){case"path":return E;case"value":return Z();case"valueOf":case"toJSON":return()=>Z();case Symbol.toPrimitive:return(Y)=>{let Q=Z();if(Y==="number")return Number(Q);if(Y==="string")return String(Q);return Q};case"toString":return()=>String(Z());case"touch":return()=>k(E);case"observe":return(Y)=>{let Q=_(E,Y);return()=>m(Q)};case"on":return(Y,Q)=>FE()(Y,Q,Z());case"bind":return(Y,Q,G)=>{wE()(Y,E,Q,G)};case"binding":return(Y)=>({bind:{value:E,binding:Y}});case"listBinding":return(Y=({span:G})=>G({bindText:"^"}),Q={})=>[{bindList:{value:E,...Q}},W.template(Y(W,UE()))];case"listFind":case"listUpdate":case"listRemove":return wM(E,M)[L];case n:case"xinValue":case"tosiValue":return HE(),Z();case S:case"xinPath":case"tosiPath":return HE(),E;case rE:case"tosiObserve":return HE(),(Y)=>{let Q=_(E,Y);return()=>m(Q)};case lE:case"tosiOn":return HE(),(Y,Q)=>FE()(Y,Q,Z());case pE:case"tosiBind":return HE(),(Y,Q,G)=>{wE()(Y,E,Q,G)};case"tosiBinding":return HE(),(Y)=>({bind:{value:E,binding:Y}});case"tosiListBinding":return HE(),(Y=({span:G})=>G({bindText:"^"}),Q={})=>[{bindList:{value:E,...Q}},W.template(Y(W,UE()))]}if(typeof L==="string"&&/^\d+$/.test(L)){let Y=Z();if(typeof Y==="string")return Y[parseInt(L,10)]}if(L==="length"){let Y=Z();if(typeof Y==="string")return Y.length}return}if(f&&!(L in M))switch(L){case"path":return E;case"value":return M.valueOf?M.valueOf():M;case"valueOf":case"toJSON":return()=>M.valueOf?M.valueOf():M;case"touch":return()=>k(E);case"observe":return(Z)=>{let Y=_(E,Z);return()=>m(Y)};case"on":return(Z,Y)=>FE()(Z,Y,A(M));case"bind":return(Z,Y,Q)=>{wE()(Z,E,Y,Q)};case"binding":return(Z)=>({bind:{value:E,binding:Z}});case"listBinding":return(Z=({span:Q})=>Q({bindText:"^"}),Y={})=>[{bindList:{value:E,...Y}},W.template(Z(W,UE()))];case"listFind":case"listUpdate":case"listRemove":return wM(E,M)[L]}switch(L){case S:case"xinPath":case"tosiPath":return E;case n:case"xinValue":case"tosiValue":return M.valueOf?M.valueOf():M;case rE:case"xinObserve":case"tosiObserve":return(Z)=>{let Y=_(E,Z);return()=>m(Y)};case lE:case"xinOn":case"tosiOn":return(Z,Y)=>FE()(Z,Y,A(M));case pE:case"xinBind":case"tosiBind":return(Z,Y,Q)=>{wE()(Z,E,Y,Q)};case"tosiBinding":return(Z)=>({bind:{value:E,binding:Z}});case"tosiListBinding":return(Z=({span:Q})=>Q({bindText:"^"}),Y={})=>[{bindList:{value:E,...Y}},W.template(Z(W,UE()))]}if(typeof L==="symbol")return M[L];let H=Object.getOwnPropertyDescriptor(M,L);if(H&&!H.configurable&&!H.writable&&"value"in H)return H.value;let J=L,$=J.match(/^([^.[]+)\.(.+)$/)??J.match(/^([^\]]+)(\[.+)/)??J.match(/^(\[[^\]]+\])\.(.+)$/)??J.match(/^(\[[^\]]+\])\[(.+)$/);if($!==null){let[,Z,Y]=$,Q=o(E,Z),G=j(M,Z);return G!==null&&typeof G==="object"?new Proxy(G,r(Q,f))[Y]:G}if(J.startsWith("[")&&J.endsWith("]"))J=J.substring(1,J.length-1);if(!Array.isArray(M)&&M[J]!==void 0||Array.isArray(M)&&J.includes("=")){let Z;if(J.includes("=")){let[Y,Q]=J.split("=");Z=M.find((G)=>`${j(G,Y)}`===Q)}else Z=M[J];if(Z instanceof Object){let Y=o(E,J);return new Proxy(Z instanceof Function?Z.bind(M):Z,r(Y,f))}else return f?zf(Z,o(E,J)):Z}else if(Array.isArray(M)){let Z=M[J];return typeof Z==="function"?(...Y)=>{let Q=Y.map((F)=>A(F)),G=Z.apply(M,Q);if(QL.includes(J))k(E);if(G!=null&&typeof G==="object"){if(J==="find"||J==="findLast"||J==="at"){let F=M.indexOf(G);if(F!==-1)return new Proxy(G,r(o(E,String(F)),f))}}return G}:typeof Z==="object"?new Proxy(Z,r(o(E,J),f)):f?zf(Z,o(E,J)):Z}else return f?zf(M[J],o(E,J)):M[J]},set(M,L,H){H=A(H);let $=L===n||L==="xinValue"||L==="tosiValue"||L==="value"&&(XM(M)||f)?E:o(E,L);if(GL&&!FL($))throw Error(`setting invalid path ${$}`);if(A(C[$])!==H&&a(R,$,H))k($);return!0}}),GE=(E,f)=>{let M=typeof f==="function"?f:C[f];if(typeof M!=="function")throw Error(`observe expects a function or path to a function, ${f} is neither`);return _(E,M)},C=new Proxy(R,r("",!1));nf(C);var B=new Proxy(R,r("",!0));var XL=16,zL=100;function WM(E,f){let M=Array.from(E.querySelectorAll(g));if(E.matches(g))M.unshift(E);for(let L of M){let H=u.get(L);for(let J of H){if(J.path.startsWith("^"))J.path=`${f}${J.path.substring(1)}`;if(J.binding.toDOM!=null)J.binding.toDOM(L,C[J.path])}}}class UM{boundElement;listTop;listBottom;isNamespaced;template;options;itemToElement;array=[];_filteredCache;_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(E,f,M={}){if(this.boundElement=E,this.itemToElement=new WeakMap,M.idPath!=null){let H=T(f);if(H!=null)If(H,M.idPath)}if(E.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(E.children[0]instanceof HTMLTemplateElement){let H=E.children[0];if(H.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=e(H.content.children[0])}else this.template=E.children[0],this.template.remove();this.options=M;let L=E.namespaceURI;if(this.isNamespaced=L==="http://www.w3.org/2000/svg"||L==="http://www.w3.org/1998/Math/MathML",this.isNamespaced)this.listTop=null,this.listBottom=null;else this.listTop=document.createElement("div"),this.listBottom=document.createElement("div"),this.listTop.classList.add("virtual-list-padding"),this.listBottom.classList.add("virtual-list-padding"),this.boundElement.append(this.listTop),this.boundElement.append(this.listBottom);if(this.boundElement[YE]=this,this.isNamespaced&&M.virtual!=null)console.warn("ListBinding: virtual scrolling is not supported in SVG/MathML containers, ignoring virtual option");if(!this.isNamespaced&&M.virtual!=null)if(XE.observe(this.boundElement),this._update=fE(()=>{this.update(this.array,!0)},XL),this.boundElement.addEventListener("resize",this._update),M.virtual.scrollContainer==="window")window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update);else this.boundElement.addEventListener("scroll",this._update)}filteredArray(){if(this._filteredCache!=null)return this._filteredCache;let{hiddenProp:E,visibleProp:f}=this.options,M=this.array;if(E!==void 0)M=M.filter((L)=>L[E]!==!0);if(f!==void 0)M=M.filter((L)=>L[f]===!0);if(this.options.filter&&this.needle!==void 0)M=this.options.filter(M,this.needle);return this._filteredCache=M,M}visibleSlice(){let{virtual:E}=this.options,f=this.filteredArray(),M=0,L=f.length-1,H=0,J=0;if(E!=null&&this.boundElement instanceof HTMLElement){let $=this.boundElement.offsetWidth,Z=E.scrollContainer==="window",Y,Q;if(Z){Y=window.innerHeight;let U=this.boundElement.getBoundingClientRect();Q=Math.max(0,-U.top)}else Y=this.boundElement.offsetHeight,Q=this.boundElement.scrollTop;let G=E.width!=null?Math.max(1,Math.floor($/E.width)):E.visibleColumns??1,F=Math.ceil(f.length/G);if(E.minHeight!=null){let U=E.minHeight,x=Math.ceil(Y/U)+(E.rowChunkSize||1),X=G*x,q=F*U,D=Math.max(0,q-Y),y=D>0?Math.min(1,Math.max(0,Q/D)):0,z=Math.max(0,F-x+1),O=y*z,K=Math.floor(O);if(E.rowChunkSize)K-=K%E.rowChunkSize;return M=K*G,L=M+X-1,H=Q,J=Math.max(0,q-Q-Y),{items:f,firstItem:M,lastItem:L,topBuffer:H,bottomBuffer:J,interpolation:{t:y,position:O,scrollTop:Q,viewportHeight:Y,totalScrollHeight:q,rowHeight:E.height}}}else{let U=Math.ceil(Y/E.height)+(E.rowChunkSize||1),x=G*U,X=Math.floor(Q/E.height);if(X>F-U+1)X=Math.max(0,F-U+1);if(E.rowChunkSize)X-=X%E.rowChunkSize;M=X*G,L=M+x-1,H=X*E.height,J=Math.max((F-U)*E.height-H,0)}}return{items:f,firstItem:M,lastItem:L,topBuffer:H,bottomBuffer:J}}needle;filter=fE((E)=>{if(this.needle!==E)this.needle=E,this.update(this.array)},zL);update(E,f){if(E==null)E=[];if(this.array=E,!f)this._filteredCache=void 0;let{hiddenProp:M,visibleProp:L}=this.options,H=T(E),J=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",J.items.length===0);let $=this._previousSlice,{firstItem:Z,lastItem:Y,topBuffer:Q,bottomBuffer:G}=J,F=M===void 0&&L===void 0&&f===!0&&$!=null&&Z===$.firstItem&&Y===$.lastItem;if(F&&J.interpolation==null&&Q===$.topBuffer&&G===$.bottomBuffer)return;if(F&&J.interpolation!=null){this._updateInterpolatedBuffers(J);return}this._previousSlice=J;let U=0,x=0,X=0;for(let z of Array.from(this.boundElement.children)){if(z===this.listTop||z===this.listBottom)continue;let O=z[t];if(O==null)z.remove();else{let K=J.items.indexOf(O);if(K<Z||K>Y)z.remove(),this.itemToElement.delete(O),U++}}if(this.listTop!=null&&this.listBottom!=null)this.listTop.style.height=String(Q)+"px",this.listBottom.style.height=String(G)+"px";let q=[],{idPath:D}=this.options;for(let z=Z;z<=Y;z++){let O=J.items[z];if(O===void 0)continue;let K=this.itemToElement.get(A(O));if(K==null){if(X++,K=e(this.template),typeof O==="object")this.itemToElement.set(A(O),K),K[t]=A(O);if(this.listBottom!=null)this.boundElement.insertBefore(K,this.listBottom);else this.boundElement.append(K);if(D!=null){let p=O[D],CE=`${H}[${D}=${p}]`;WM(K,CE)}else{let p=`${H}[${z}]`;WM(K,p)}}q.push(K)}let y=null;for(let z of q){if(z.previousElementSibling!==y)if(x++,y?.nextElementSibling!=null)this.boundElement.insertBefore(z,y.nextElementSibling);else if(this.listBottom!=null)this.boundElement.insertBefore(z,this.listBottom);else this.boundElement.append(z);y=z}if(J.interpolation!=null)this._updateInterpolatedBuffers(J);if(i.perf)console.log(H,"updated",{removed:U,created:X,moved:x})}_updateInterpolatedBuffers(E){let{t:f,position:M,scrollTop:L,viewportHeight:H,totalScrollHeight:J,rowHeight:$}=E.interpolation,Z=0;for(let F of Array.from(this.boundElement.children)){if(F===this.listTop||F===this.listBottom)continue;Z+=F.offsetHeight||$}let Y=L,Q=L+H-Z,G=Math.max(0,f*Q+(1-f)*Y-M%1*$);if(this.listTop!=null&&this.listBottom!=null)this.listTop.style.height=String(G)+"px",this.listBottom.style.height=String(Math.max(0,J-G-Z))+"px"}}var QE=(E,f,M)=>{let L=E[YE];if(f&&L===void 0)L=new UM(E,f,M),E[YE]=L;return L},mE=(E)=>{let f;while(!(f=E[t])&&E&&E.parentElement)E=E.parentElement;return f?{element:E,item:f}:void 0},NE=(E)=>{let f=mE(E);return f?f.item:void 0},DM=(E)=>{let f=mE(E);if(!f)return console.error("deleteListItem failed, element is not part of a list instance",E),!1;let M=QE(f.element.parentElement);if(!M.options.idPath)return console.error("deleteListItem failed, list binding has no idPath",E.parentElement,M),!1;let L=M.array.indexOf(f.item);if(L>-1)return M.array.splice(L,1),!0;return!1},WL={start:"start",middle:"center",end:"end",nearest:"nearest"},qM=(E,f,M={})=>{let L=QE(E);if(L==null)return console.error("scrollListItemIntoView failed, element has no list binding",E),!1;let{position:H="middle"}=M,J=L.filteredArray(),$=A(f)??f,Z=J.indexOf($);if(Z===-1)return console.error("scrollListItemIntoView failed, item not found in list",f),!1;let{virtual:Y}=L.options;if(Y!=null&&E instanceof HTMLElement){let Q=Y.width!=null?Math.max(1,Math.floor(E.offsetWidth/Y.width)):Y.visibleColumns??1,G=Math.floor(Z/Q),F=Y.minHeight??Y.height,U=Math.ceil(J.length/Q),x=Y.scrollContainer==="window",X=x?window.innerHeight:E.offsetHeight,q;if(Y.minHeight!=null){let D=Math.ceil(X/F)+(Y.rowChunkSize||1),y=U*F,z=Math.max(0,y-X),O=Math.max(1,U-D+1),K=G/O;switch(H){case"start":q=K*z;break;case"end":q=Math.max(0,(G-D+1)/O*z);break;case"nearest":{let p=x?Math.max(0,-E.getBoundingClientRect().top):E.scrollTop,CE=z>0?p/z:0,Vf=Math.floor(CE*O);if(G<Vf)q=K*z;else if(G>=Vf+D)q=Math.max(0,(G-D+1)/O*z);else return!0;break}default:{let p=G-Math.floor(D/2);q=Math.max(0,p)/O*z}}}else{let D=G*Y.height;switch(H){case"start":q=D;break;case"end":q=D-X+Y.height;break;case"nearest":{let y=x?Math.max(0,-E.getBoundingClientRect().top):E.scrollTop;if(D<y)q=D;else if(D+Y.height>y+X)q=D-X+Y.height;else return!0;break}default:q=D-(X-Y.height)/2}}if(q=Math.max(0,q),x){let D=E.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:D+q,behavior:"smooth"})}else E.scrollTo({top:q,behavior:"smooth"})}else{let Q=L.itemToElement.get($);if(Q==null)return console.error("scrollListItemIntoView failed, no DOM element found for item",f),!1;Q.scrollIntoView({block:WL[H]??"center",behavior:"smooth"})}return!0};var{document:DE,MutationObserver:OM}=globalThis,PE=(E,f)=>{let M=u.get(E);if(M==null)return;for(let L of M){let{binding:H,options:J}=L,{path:$}=L,{toDOM:Z}=H;if(Z!=null){if($.startsWith("^")){let Y=NE(E);if(Y!=null&&Y[S]!=null)$=L.path=`${Y[S]}${$.substring(1)}`;else{if(E instanceof HTMLElement)console.warn(`Unresolved relative binding "${$}" —`,E,"is not part of a list. If this is a list template, wrap it in a <template>.");continue}}if(f==null||$.startsWith(f))Z(E,VE()[$],J)}}};if(OM!=null)new OM((f)=>{f.forEach((M)=>{Array.from(M.addedNodes).forEach((L)=>{if(L instanceof Element)Array.from(L.querySelectorAll(g)).forEach((H)=>PE(H))})})}).observe(DE.body,{subtree:!0,childList:!0});_(()=>!0,(E)=>{let f=Array.from(DE.querySelectorAll(g));for(let M of f)PE(M,E)});var KM=(E)=>{let f=E.target?.closest(g);while(f!=null){let M=u.get(f);for(let L of M){let{binding:H,path:J}=L,{fromDOM:$}=H;if($!=null){let Z;try{Z=$(f,L.options)}catch(Y){throw console.error("Cannot get value from",f,"via",L),Error("Cannot obtain value fromDOM")}if(Z!=null){let Y=VE(),Q=Y[J];if(Q==null)Y[J]=Z;else{let G=Q[S]!=null?Q[n]:Q,F=Z[S]!=null?Z[n]:Z;if(G!==F)Y[J]=F}}}}f=f.parentElement.closest(g)}};if(globalThis.document!=null)DE.body.addEventListener("change",KM,!0),DE.body.addEventListener("input",KM,!0);function P(E,f,M,L){if(E instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let H;if(typeof f==="object"&&f[S]===void 0&&L===void 0){let{value:Z}=f;H=typeof Z==="string"?Z:Z[S],L=f,delete L.value}else H=typeof f==="string"?f:f[S];if(H==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:J}=M;E.classList?.add(hE);let $=u.get(E);if($==null)$=[],u.set(E,$);if($.push({path:H,binding:M,options:L}),J!=null&&!H.startsWith("^"))k(H);if(L?.filter&&L?.needle)P(E,L.needle,{toDOM(Z,Y){console.log({needle:Y}),Z[YE]?.filter(Y)}});return E}var TM=new Set,UL=(E)=>{let f=E?.target?.closest(oE),M=!1,L=new Proxy(E,{get(J,$){if($==="stopPropagation")return()=>{E.stopPropagation(),M=!0};else{let Z=J[$];return typeof Z==="function"?Z.bind(J):Z}}}),H=new Set;while(!M&&f!=null){let $=l.get(f)[E.type]||H;for(let Z of $){if(typeof Z==="function")Z(L);else{let Y=VE()[Z];if(typeof Y==="function")Y(L);else throw Error(`no event handler found at path ${Z}`)}if(M)continue}f=f.parentElement!=null?f.parentElement.closest(oE):null}};function LE(E,f,M){let L=l.get(E);if(E.classList.add(sE),L==null)L={},l.set(E,L);if(!L[f])L[f]=new Set;if(L[f].add(M),!TM.has(f))TM.add(f),DE.body.addEventListener(f,UL,!0);return()=>{L[f].delete(M)}}vf(P,LE);function cE(E,f){if(!E.internals)return;let M={},L="";if(E.hasAttribute("required")&&f==="")M.valueMissing=!0,L="Please fill out this field.";let H=E.getAttribute("minlength");if(H&&f.length<parseInt(H,10))M.tooShort=!0,L=`Please use at least ${H} characters.`;let J=E.getAttribute("maxlength");if(J&&f.length>parseInt(J,10))M.tooLong=!0,L=`Please use no more than ${J} characters.`;let $=E.getAttribute("pattern");if($&&f!=="")try{if(!new RegExp(`^(?:${$})$`).test(f))M.patternMismatch=!0,L="Please match the requested format."}catch{}if(Object.keys(M).length>0)E.internals.setValidity(M,L,E);else E.internals.setValidity({})}var DL=0;function Df(){return`custom-elt${(DL++).toString(36)}`}var AM=0,qf=null;function qL(){if(qf===null)qf=new MutationObserver((E)=>{let f=new Set;for(let M of E)if(M.type==="attributes"&&M.target instanceof c){let L=M.target,H=Zf(M.attributeName);if(L._legacyTrackedAttrs?.has(H))f.add(L)}for(let M of f)M.queueRender(!1)});return qf}var qE={};function OL(E,f){let M=qE[E],L=s(f).replace(/:host\(([^)]+)\)/g,`${E}$1`).replace(/:host\b/g,E);qE[E]=M?M+`
13
- `+L:L}function KL(E){if(qE[E])document.head.append(W.style({id:E+"-component"},qE[E]));delete qE[E]}class c extends HTMLElement{static elements=W;static _elementCreator;static initAttributes;static formAssociated;static preferredTagName;static shadowStyleSpec;static lightStyleSpec;static extends;internals;get validity(){return this.internals?.validity}get validationMessage(){return this.internals?.validationMessage??""}get willValidate(){return this.internals?.willValidate??!1}checkValidity(){return this.internals?.checkValidity()??!0}reportValidity(){return this.internals?.reportValidity()??!0}setCustomValidity(E){if(this.internals)if(E)this.internals.setValidity({customError:!0},E);else this.internals.setValidity({})}setValidity(E,f,M){this.internals?.setValidity(E,f,M)}setFormValue(E,f){this.internals?.setFormValue(E,f)}static get observedAttributes(){let E=this.initAttributes;if(E)return["hidden",...Object.keys(E).map(I)];return["hidden"]}instanceId;styleNode;static styleSpec;static styleNode;content=W.slot();isSlotted;static _tagName=null;static get tagName(){return this._tagName}_legacyTrackedAttrs;_attrValues;_valueChanged=!1;static StyleNode(E){return console.warn("StyleNode is deprecated, use static shadowStyleSpec instead"),W.style(s(E))}static elementCreator(E={}){let f=this;if(!Object.prototype.hasOwnProperty.call(f,"_elementCreator")){if(E.tag!==void 0)V("elementCreator-tag","Passing tag to elementCreator() is deprecated. Use static preferredTagName instead.");if(E.styleSpec!==void 0)V("elementCreator-styleSpec","Passing styleSpec to elementCreator() is deprecated. Use static lightStyleSpec instead.");if(E.extends!==void 0)V("elementCreator-extends","Passing extends to elementCreator() is deprecated. Use static extends instead.");let M=E.tag??f.preferredTagName;if(M==null)if(typeof f.name==="string"&&f.name!==""){if(M=I(f.name),M.startsWith("-"))M=M.slice(1)}else M=Df();if(customElements.get(M)!=null)console.warn(`${M} is already defined`);if(M.match(/\w+(-\w+)+/)==null)console.warn(`${M} is not a legal tag for a custom-element`),M=Df();while(customElements.get(M)!==void 0)M=Df();f._tagName=M;let L=E.styleSpec??f.lightStyleSpec;if(L!==void 0)OL(M,L);let H=E.extends??f.extends,J=H?{extends:H}:void 0;window.customElements.define(M,this,J),f._elementCreator=W[M]}return f._elementCreator}initAttributes(...E){if(V("initAttributes","initAttributes() is deprecated. Use static initAttributes = { ... } instead."),!this._legacyTrackedAttrs)this._legacyTrackedAttrs=new Set;for(let H of E)this._legacyTrackedAttrs.add(H);qL().observe(this,{attributes:!0});let M={},L={};E.forEach((H)=>{M[H]=b(this[H]);let J=I(H);Object.defineProperty(this,H,{enumerable:!1,get(){if(typeof M[H]==="boolean")return this.hasAttribute(J);else if(this.hasAttribute(J))return typeof M[H]==="number"?parseFloat(this.getAttribute(J)):this.getAttribute(J);else if(L[H]!==void 0)return L[H];else return M[H]},set($){if(typeof M[H]==="boolean"){if($!==this[H]){if($)this.setAttribute(J,"");else this.removeAttribute(J);this.queueRender()}}else if(typeof M[H]==="number"){if($!==parseFloat(this[H]))this.setAttribute(J,$),this.queueRender()}else if(typeof $==="object"||`${$}`!==`${this[H]}`){if($===null||$===void 0||typeof $==="object")this.removeAttribute(J);else this.setAttribute(J,$);this.queueRender(),L[H]=$}}})})}initValue(){let E=Object.getOwnPropertyDescriptor(this,"value");if(E===void 0||E.get!==void 0||E.set!==void 0)return;let f=this.hasAttribute("value")?this.getAttribute("value"):b(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return f},set(M){if(f!==M)f=M,this._valueChanged=!0,this.queueRender(!0)}})}_parts;get parts(){let E=this.shadowRoot!=null?this.shadowRoot:this;if(this._parts==null)this._parts=new Proxy({},{get(f,M){if(f[M]===void 0){let L=E.querySelector(`[part="${M}"]`);if(L==null)L=E.querySelector(M);if(L==null)throw Error(`elementRef "${M}" does not exist!`);L.removeAttribute("data-ref"),f[M]=L}return f[M]}});return this._parts}attributeChangedCallback(E,f,M){let L=Zf(E);if(!this._legacyTrackedAttrs?.has(L))this.queueRender(!1)}constructor(){super();if(AM+=1,this.constructor.formAssociated&&typeof this.attachInternals==="function"&&!this.internals)this.internals=this.attachInternals();let E=this.constructor.initAttributes;if(E)this._setupAttributeAccessors(E);this.instanceId=`${this.tagName.toLocaleLowerCase()}-${AM}`,this._value=b(this.defaultValue)}_setupAttributeAccessors(E){if(!this._attrValues)this._attrValues=new Map;for(let f of Object.keys(E)){let M=I(f),L=E[f];if(f==="value"){console.warn(`${this.tagName}: 'value' cannot be an attribute. Use the Component value property instead.`);continue}if(typeof L==="object"&&L!==null){console.warn(`${this.tagName}: initAttributes.${f} is an object. Use a regular property instead.`);continue}let H=this,J=!1;while(H){let $=Object.getOwnPropertyDescriptor(H,f);if($){if(!$.configurable||$.get||$.set){J=!0;break}break}H=Object.getPrototypeOf(H)}if(J)continue;Object.defineProperty(this,f,{enumerable:!1,get:()=>{if(typeof L==="boolean")return this.hasAttribute(M);else if(this.hasAttribute(M))return typeof L==="number"?parseFloat(this.getAttribute(M)):this.getAttribute(M);else if(this._attrValues.has(f))return this._attrValues.get(f);else return L},set:($)=>{if(typeof L==="boolean"){if($!==this[f]){if($)this.setAttribute(M,"");else this.removeAttribute(M);this.queueRender()}}else if(typeof L==="number"){if($!==parseFloat(this[f]))this.setAttribute(M,$),this.queueRender()}else if(typeof $==="object"||`${$}`!==`${this[f]}`){if($===null||$===void 0||typeof $==="object")this.removeAttribute(M);else this.setAttribute(M,$);this.queueRender(),this._attrValues.set(f,$)}}})}}connectedCallback(){if(KL(this.constructor.tagName),this.hydrate(),this.role!=null)this.setAttribute("role",this.role);if(this.constructor.formAssociated&&!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.onResize!==void 0){if(XE.observe(this),this._onResize==null)this._onResize=this.onResize.bind(this);this.addEventListener("resize",this._onResize)}if(this.value!=null&&this.getAttribute("value")!=null)this._value=this.getAttribute("value");if(this.internals&&this.value!==void 0)this.internals.setFormValue(this.value),this.validateValue();this.queueRender()}disconnectedCallback(){XE.unobserve(this)}formResetCallback(){if(this.value!==void 0)this.value=this.defaultValue??""}formDisabledCallback(E){if(E)this.setAttribute("disabled","");else this.removeAttribute("disabled")}formStateRestoreCallback(E){if(this.value!==void 0&&typeof E==="string")this.value=E}_changeQueued=!1;_renderQueued=!1;queueRender(E=!1){if(!this._hydrated)return;if(!this._changeQueued)this._changeQueued=E;if(!this._renderQueued)this._renderQueued=!0,requestAnimationFrame(()=>{if(this._changeQueued){if(Yf(this,"change"),this.internals&&this.value!==void 0)this.internals.setFormValue(this.value)}this._changeQueued=!1,this._renderQueued=!1,this.render()})}_hydrated=!1;hydrate(){if(!this._hydrated){this.initValue();let E=typeof this.content!=="function",f=typeof this.content==="function"?this.content(W):this.content,M=this.constructor,L=M.shadowStyleSpec??M.styleSpec;if(M.styleSpec&&!M.shadowStyleSpec)V("static-styleSpec","static styleSpec is deprecated. Use static shadowStyleSpec instead.");let{styleNode:H}=M;if(L)H=M.styleNode=W.style(s(L)),delete M.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecated, use static shadowStyleSpec instead"),H=this.styleNode;if(H){let J=this.attachShadow({mode:"open"});J.appendChild(H.cloneNode(!0)),$f(J,f,E)}else if(f!==null){let J=Array.from(this.childNodes);$f(this,f,E),this.isSlotted=this.querySelector("slot,xin-slot")!==void 0;let $=Array.from(this.querySelectorAll("slot"));if($.length>0)$.forEach(Of.replaceSlot);if(J.length>0){let Z={"":this};Array.from(this.querySelectorAll("xin-slot")).forEach((Y)=>{Z[Y.name]=Y}),J.forEach((Y)=>{let Q=Z[""],G=Y instanceof Element?Z[Y.slot]:Q;(G!==void 0?G:Q).append(Y)})}}this._hydrated=!0}}render(){if(this._valueChanged&&this.internals&&this.value!==void 0)this.internals.setFormValue(this.value),this.validateValue();this._valueChanged=!1}validateValue(){if(!this.internals||this.value===void 0)return;let E=typeof this.value==="string"?this.value:String(this.value);cE(this,E)}}class Of extends c{static preferredTagName="xin-slot";static initAttributes={name:""};content=null;static replaceSlot(E){let f=document.createElement("xin-slot");if(E.name!=="")f.setAttribute("name",E.name);E.replaceWith(f)}}var fH=Of.elementCreator();var jM=(E=()=>!0)=>{let f=localStorage.getItem("xin-state");if(f!=null){let L=JSON.parse(f);for(let H of Object.keys(L).filter(E))if(C[H]!==void 0)Object.assign(C[H],L[H]);else C[H]=L[H]}let M=ZE(()=>{let L={},H=A(C);for(let J of Object.keys(H).filter(E))L[J]=H[J];localStorage.setItem("xin-state",JSON.stringify(L)),console.log("xin state saved to localStorage")},500);GE(E,M)};var TL="tosijs-share",AL="tosijs-share",OE="shared",jL=1,Tf=new Set,Af=new Set,Kf=new Map,JE=null,jf="",bE=null,CL=null;function CM(){if(bE!=null)return Promise.resolve(bE);return new Promise((E,f)=>{let M=indexedDB.open(AL,jL);M.onupgradeneeded=()=>{M.result.createObjectStore(OE)},M.onsuccess=()=>{bE=M.result,E(bE)},M.onerror=()=>f(M.error)})}var xL={async get(E){let f=await CM();return new Promise((M,L)=>{let J=f.transaction(OE,"readonly").objectStore(OE).get(E);J.onsuccess=()=>M(J.result),J.onerror=()=>L(J.error)})},async set(E,f){let M=await CM();return new Promise((L,H)=>{let J=M.transaction(OE,"readwrite");J.objectStore(OE).put(f,E),J.oncomplete=()=>L(),J.onerror=()=>H(J.error)})}};function xM(){return CL??xL}function VL(E){return E!=null&&E.type==="tosijs-share"&&typeof E.path==="string"}function VM(E){for(let f of Tf)if(E===f||E.startsWith(f+"."))return f;return}function RL(E){for(let f of Af)if(E===f||E.startsWith(f+"."))return!0;return!1}function kL(E,f){Af.add(E),a(R,E,f),k(E),EE().then(()=>{Af.delete(E)})}function IL(){if(JE!=null)return JE;return jf=crypto.randomUUID(),JE=new BroadcastChannel(TL),JE.onmessage=(E)=>{let f=E.data;if(!VL(f))return;if(f.origin===jf)return;if(VM(f.path)===void 0)return;kL(f.path,f.value)},JE}function BL(E,f){if(JE==null)return;let M={type:"tosijs-share",path:E,value:f,origin:jf};JE.postMessage(M)}function yL(E){if(!Kf.has(E))Kf.set(E,ZE(()=>{let f=j(R,E);xM().set(E,f)},500));Kf.get(E)()}async function RM(...E){if(typeof BroadcastChannel>"u")return{restored:[]};IL();let f=[],M=xM();for(let L of E){let H=typeof L==="string"?L:T(L);if(H===void 0)throw Error("share() requires boxed proxies or string paths. Got a non-proxy value.");if(Tf.has(H))continue;Tf.add(H);let J=await M.get(H);if(J!==void 0)a(R,H,J),k(H),f.push(L);else{let $=j(R,H);await M.set(H,$)}_(($)=>$===H||$.startsWith(H+"."),($)=>{if(RL($))return;let Z=VM($);if(Z===void 0)return;let Y=j(R,$);BL($,Y),yL(Z)})}return{restored:f}}var Cf=new Set;function kM(E,f){for(let M of E)if(f===M||f.startsWith(M+"."))return M;return}function SL(E){for(let f of Cf)if(E===f||E.startsWith(f+"."))return!0;return!1}function _L(E,f){Cf.add(E),a(R,E,f),k(E),EE().then(()=>{Cf.delete(E)})}async function IM(E,f,...M){let L=new Set,H=[],J=[],$=f.throttleInterval??100;await E.connect();let Z=fE(()=>{if(H.length===0)return;let Y=H.splice(0);E.send(Y)},$);E.onReceive((Y)=>{for(let Q of Y){if(kM(L,Q.path)===void 0)continue;_L(Q.path,Q.value)}});for(let Y of M){let Q=typeof Y==="string"?Y:T(Y);if(Q===void 0)throw Error("sync() requires boxed proxies or string paths. Got a non-proxy value.");L.add(Q);let G=_((F)=>F===Q||F.startsWith(Q+"."),(F)=>{if(SL(F))return;if(kM(L,F)===void 0)return;let U=j(R,F);H.push({path:F,value:U}),Z()});J.push(G)}return{disconnect(){for(let Y of J)m(Y);J.length=0,L.clear(),H.length=0,E.disconnect()}}}var uE="1.5.2";function KE(E){return Object.assign(B,E),B}function TE(E){return V("boxedProxy","boxedProxy is deprecated, please use tosi() instead"),KE(E)}function nE(E,f=!1){if(f)return V("xinProxy-boxed","xinProxy(..., true) is deprecated; use tosi(...) instead"),TE(E);return Object.keys(E).forEach((M)=>{C[M]=E[M]}),C}var mL={};async function AE(E,f){let M=await f(E,{Color:w,Component:c,elements:W,svgElements:SE,mathML:_E,varDefault:WE,vars:BE,xin:C,boxed:B,xinProxy:nE,boxedProxy:TE,tosi:KE,makeComponent:AE,bind:P,on:LE,version:uE}),{type:L}=M;L.preferredTagName=E;let H=M.lightStyleSpec??M.styleSpec;if(H)L.lightStyleSpec=H;let J={type:L,creator:L.elementCreator()};return mL[E]=J,J}var vE={":host":{display:"none"}},xf={},NL=(E)=>import(E);class jE extends c{static preferredTagName="tosi-blueprint";static lightStyleSpec=vE;static initAttributes={tag:"anon-elt",src:"",property:"default"};loaded;blueprintLoaded=(E)=>{};async packaged(){let{tag:E,src:f,property:M}=this,L=`${E}.${M}:${f}`;if(!this.loaded){if(xf[L]===void 0)xf[L]=NL(f).then((H)=>{let J=H[M];return AE(E,J)});else console.log(`using cached ${E} with signature ${L}`);this.loaded=await xf[L],this.blueprintLoaded(this.loaded)}return this.loaded}}var BM=jE.elementCreator();class dE extends c{static preferredTagName="tosi-loader";static lightStyleSpec=vE;allLoaded=()=>{};async load(){let f=Array.from(this.querySelectorAll("tosi-blueprint, xin-blueprint")).filter((M)=>M.src).map((M)=>M.packaged());await Promise.all(f),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var yM=dE.elementCreator();class SM extends jE{static preferredTagName="xin-blueprint";static lightStyleSpec=vE;constructor(){super();V("xin-blueprint","<xin-blueprint> is deprecated. Use <tosi-blueprint> instead.")}}var _M=SM.elementCreator();class mM extends c{static preferredTagName="xin-loader";static lightStyleSpec=vE;allLoaded=()=>{};constructor(){super();V("xin-loader","<xin-loader> is deprecated. Use <tosi-loader> instead.")}async load(){let f=Array.from(this.querySelectorAll("xin-blueprint")).filter((M)=>M.src).map((M)=>M.packaged());await Promise.all(f),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var NM=mM.elementCreator();})();
12
+ `)},MM=(E)=>{C("initVars","initVars is deprecated. Just use _ and __ prefixes instead.");let f={};for(let M of Object.keys(E)){let L=E[M],H=k(M);f[`--${H}`]=typeof L==="number"&&L!==0?String(L)+"px":L}return f},LM=(E)=>{let f={};for(let M of Object.keys(E)){let L=E[M];if(L instanceof X)f[M]=L.inverseLuminance;else if(typeof L==="string"&&L.match(/^(#[0-9a-fA-F]{3}|rgba?\(|hsla?\()/))f[M]=X.fromCss(L).inverseLuminance}return f},WE=new Proxy({},{get(E,f){if(E[f]===void 0){let M="--"+k(f);E[f]=(L)=>`var(${M}, ${L})`}return E[f]}}),BE=new Proxy({},{get(E,f){if(f==="default")return WE;if(E[f]==null){f=k(f);let[,M,,L,H,J]=f.match(/^([-\w]*?)((_)?(\d+)(\w?))?$/)||["",f],$=`--${M}`;if(H!=null){let Z=L==null?Number(H)/100:-Number(H)/100;switch(J){case"b":case"s":case"h":case"o":{let Y=`--${f}`;X.registerComputedColor(Y,$,Z,J),E[f]=`var(${Y})`}break;case"":E[f]=`calc(var(${$}) * ${Z})`;break;default:throw console.error(J),Error(`Unrecognized method ${J} for css variable ${$}`)}}else E[f]=`var(${$})`}return E[f]}});function Ff(){let E=(f)=>typeof matchMedia<"u"&&matchMedia(f).matches;return{colorScheme:E("(prefers-color-scheme: dark)")?"dark":"light",contrast:E("(prefers-contrast: more)")?"more":E("(prefers-contrast: less)")?"less":E("(prefers-contrast: custom)")?"custom":"no-preference",reducedMotion:E("(prefers-reduced-motion: reduce)"),reducedTransparency:E("(prefers-reduced-transparency: reduce)"),forcedColors:E("(forced-colors: active)")}}function HM(E){if(typeof matchMedia>"u")return()=>{};let f=["(prefers-color-scheme: dark)","(prefers-contrast: more)","(prefers-contrast: less)","(prefers-contrast: custom)","(prefers-reduced-motion: reduce)","(prefers-reduced-transparency: reduce)","(forced-colors: active)"],M=()=>E(Ff()),L=f.map((H)=>matchMedia(H));for(let H of L)H.addEventListener("change",M);return()=>{for(let H of L)H.removeEventListener("change",M)}}var JM="http://www.w3.org/1998/Math/MathML",YM="http://www.w3.org/2000/svg";var yE={},ZM=(E,f,M)=>{let L=Xf(k(f),M);if(L.prop.startsWith("--"))E.style.setProperty(L.prop,L.value);else E.style[f]=L.value},GL=(E)=>{return{toDOM(f,M){ZM(f,E,M)}}},QM=(E,f,M)=>{if(f==="style")if(typeof M==="object")for(let L of Object.keys(M))if(O(M[L]))c(E,M[L],GL(L));else ZM(E,L,M[L]);else E.setAttribute("style",M);else{let L=k(f),H=E.constructor.observedAttributes;if(H?.includes(f)||H?.includes(L))if(typeof M==="boolean")M?E.setAttribute(L,""):E.removeAttribute(L);else E.setAttribute(L,M);else if(E[f]!==void 0){let{MathMLElement:$}=globalThis;if(E instanceof SVGElement||$!==void 0&&E instanceof $)E.setAttribute(f,M);else E[f]=M}else if(L==="class")M.split(" ").forEach(($)=>{E.classList.add($)});else if(E[L]!==void 0)E[L]=M;else if(typeof M==="boolean")M?E.setAttribute(L,""):E.removeAttribute(L);else E.setAttribute(L,M)}},wf={},XL=(E)=>{if(!wf[E])wf[E]={toDOM(f,M){QM(f,E,M)}};return wf[E]},SE=(E,f,M)=>{if(f==="apply")M(E);else if(f.match(/^on[A-Z]/)!=null){let L=f.substring(2).toLowerCase();LE(E,L,M)}else if(f==="bind")if((typeof M.binding==="string"?zE[M.binding]:M.binding)!==void 0&&M.value!==void 0)c(E,M.value,M.binding instanceof Function?{toDOM:M.binding}:M.binding);else throw Error("bad binding");else if(f.match(/^bind[A-Z]/)!=null){let L=f.substring(4,5).toLowerCase()+f.substring(5),H=zE[L];if(H!==void 0)c(E,M,H);else throw Error(`${f} is not allowed, bindings.${L} is not defined`)}else if(O(M))c(E,M,XL(f));else QM(E,f,M)},zf=(E,...f)=>{if(yE[E]===void 0){let[H,J]=E.split("|");if(J===void 0)yE[E]=globalThis.document.createElement(H);else yE[E]=globalThis.document.createElementNS(J,H)}let M=yE[E].cloneNode(),L={};for(let H of f)if(H instanceof Element||H instanceof DocumentFragment||typeof H==="string"||typeof H==="number")if(M instanceof HTMLTemplateElement)M.content.append(H);else M.append(H);else if(O(H))M.append(W.span({bindText:H}));else Object.assign(L,H);for(let H of Object.keys(L)){let J=L[H];SE(M,H,J)}return M},Wf=(...E)=>{let f=globalThis.document.createDocumentFragment();for(let M of E)f.append(M);return f},W=new Proxy({fragment:Wf},{get(E,f){if(f=f.replace(/[A-Z]/g,(M)=>`-${M.toLocaleLowerCase()}`),E[f]===void 0)E[f]=(...M)=>zf(f,...M);return E[f]},set(){throw Error("You may not add new properties to elements")}}),_E=new Proxy({fragment:Wf},{get(E,f){if(E[f]===void 0)E[f]=(...M)=>zf(`${f}|${YM}`,...M);return E[f]},set(){throw Error("You may not add new properties to elements")}}),NE=new Proxy({fragment:Wf},{get(E,f){if(E[f]===void 0)E[f]=(...M)=>zf(`${f}|${JM}`,...M);return E[f]},set(){throw Error("You may not add new properties to elements")}}),$M=new WeakSet;function GM(E,f,M="part"){let L=`[data-${M}]`;for(let H of Array.from(E.querySelectorAll(L))){if($M.has(H))continue;let J=H.getAttribute(`data-${M}`);if(J==null)continue;let $=f[J];if($==null)continue;$M.add(H);for(let Z of Object.keys($))SE(H,Z,$[Z])}}var FL=["sort","splice","copyWithin","fill","pop","push","reverse","shift","unshift"],wL=!0,zL=/^\.?([^.[\](),])+(\.[^.[\](),]+|\[\d+\]|\[[^=[\](),]*=[^[\]()]+\])*$/,WL=(E)=>zL.test(E),o=(E="",f="")=>{if(E==="")return f;else if(f.match(/^\d+$/)!==null||f.includes("="))return`${E}[${f}]`;else return`${E}.${f}`},zM={};function Uf(E,f){if(E!==null&&(typeof E==="object"||typeof E==="function"))return E;return new Proxy(zM,r(f,!0))}var UE=()=>new Proxy({},r("^",!0)),Df=(E)=>{let M=E(UE())?.path;if(!M?.startsWith("^."))throw Error("selector must return a property of the item");return M.substring(2)},qf=(E,f,M)=>{for(let L=0;L<E.length;L++)if(`${j(E[L],f)}`===`${M}`)return L;return-1},XM=(E,f)=>({listFind(M,L){if(M instanceof Element){let $=M;while($&&!$[t]&&$.parentElement)$=$.parentElement;let Z=$?.[t];if(Z==null)return;let Y=f.indexOf(Z);return Y!==-1?B[E][Y]:void 0}let H=Df(M),J=qf(f,H,L);return J!==-1?B[E][J]:void 0},listUpdate(M,L){let H=Df(M),J=j(L,H),$=qf(f,H,J);if($!==-1){let Z=B[E][$];for(let Y of Object.keys(L))Z[Y]=L[Y];return Z}return B[E].push(L),B[E][f.length-1]},listRemove(M,L){let H=Df(M),J=qf(f,H,L);if(J===-1)return!1;return B[E].splice(J,1),!0}}),FM=!1;function HE(){if(!FM)console.warn("xinValue, tosiValue, xinPath, tosiPath, etc. are deprecated. Use value, path, observe, bind, on, binding, listBinding instead."),FM=!0}var wM=(E)=>{return E===zM},r=(E,f)=>({get(M,L){if(wM(M)){let Z=()=>j(R,E);switch(L){case"path":return E;case"value":return Z();case"valueOf":case"toJSON":return()=>Z();case Symbol.toPrimitive:return(Y)=>{let Q=Z();if(Y==="number")return Number(Q);if(Y==="string")return String(Q);return Q};case"toString":return()=>String(Z());case"touch":return()=>I(E);case"observe":return(Y)=>{let Q=_(E,Y);return()=>m(Q)};case"on":return(Y,Q)=>FE()(Y,Q,Z());case"bind":return(Y,Q,G)=>{XE()(Y,E,Q,G)};case"binding":return(Y)=>({bind:{value:E,binding:Y}});case"listBinding":return(Y=({span:G})=>G({bindText:"^"}),Q={})=>[{bindList:{value:E,...Q}},W.template(Y(W,UE()))];case"listFind":case"listUpdate":case"listRemove":return XM(E,M)[L];case n:case"xinValue":case"tosiValue":return HE(),Z();case S:case"xinPath":case"tosiPath":return HE(),E;case lE:case"tosiObserve":return HE(),(Y)=>{let Q=_(E,Y);return()=>m(Q)};case eE:case"tosiOn":return HE(),(Y,Q)=>FE()(Y,Q,Z());case tE:case"tosiBind":return HE(),(Y,Q,G)=>{XE()(Y,E,Q,G)};case"tosiBinding":return HE(),(Y)=>({bind:{value:E,binding:Y}});case"tosiListBinding":return HE(),(Y=({span:G})=>G({bindText:"^"}),Q={})=>[{bindList:{value:E,...Q}},W.template(Y(W,UE()))]}if(typeof L==="string"&&/^\d+$/.test(L)){let Y=Z();if(typeof Y==="string")return Y[parseInt(L,10)]}if(L==="length"){let Y=Z();if(typeof Y==="string")return Y.length}return}if(f&&!(L in M))switch(L){case"path":return E;case"value":return M.valueOf?M.valueOf():M;case"valueOf":case"toJSON":return()=>M.valueOf?M.valueOf():M;case"touch":return()=>I(E);case"observe":return(Z)=>{let Y=_(E,Z);return()=>m(Y)};case"on":return(Z,Y)=>FE()(Z,Y,T(M));case"bind":return(Z,Y,Q)=>{XE()(Z,E,Y,Q)};case"binding":return(Z)=>({bind:{value:E,binding:Z}});case"listBinding":return(Z=({span:Q})=>Q({bindText:"^"}),Y={})=>[{bindList:{value:E,...Y}},W.template(Z(W,UE()))];case"listFind":case"listUpdate":case"listRemove":return XM(E,M)[L]}switch(L){case S:case"xinPath":case"tosiPath":return E;case n:case"xinValue":case"tosiValue":return M.valueOf?M.valueOf():M;case lE:case"xinObserve":case"tosiObserve":return(Z)=>{let Y=_(E,Z);return()=>m(Y)};case eE:case"xinOn":case"tosiOn":return(Z,Y)=>FE()(Z,Y,T(M));case tE:case"xinBind":case"tosiBind":return(Z,Y,Q)=>{XE()(Z,E,Y,Q)};case"tosiBinding":return(Z)=>({bind:{value:E,binding:Z}});case"tosiListBinding":return(Z=({span:Q})=>Q({bindText:"^"}),Y={})=>[{bindList:{value:E,...Y}},W.template(Z(W,UE()))]}if(typeof L==="symbol")return M[L];let H=Object.getOwnPropertyDescriptor(M,L);if(H&&!H.configurable&&!H.writable&&"value"in H)return H.value;let J=L,$=J.match(/^([^.[]+)\.(.+)$/)??J.match(/^([^\]]+)(\[.+)/)??J.match(/^(\[[^\]]+\])\.(.+)$/)??J.match(/^(\[[^\]]+\])\[(.+)$/);if($!==null){let[,Z,Y]=$,Q=o(E,Z),G=j(M,Z);return G!==null&&typeof G==="object"?new Proxy(G,r(Q,f))[Y]:G}if(J.startsWith("[")&&J.endsWith("]"))J=J.substring(1,J.length-1);if(!Array.isArray(M)&&M[J]!==void 0||Array.isArray(M)&&J.includes("=")){let Z;if(J.includes("=")){let[Y,Q]=J.split("=");Z=M.find((G)=>`${j(G,Y)}`===Q)}else Z=M[J];if(Z instanceof Object){let Y=o(E,J);return new Proxy(Z instanceof Function?Z.bind(M):Z,r(Y,f))}else return f?Uf(Z,o(E,J)):Z}else if(Array.isArray(M)){let Z=M[J];return typeof Z==="function"?(...Y)=>{let Q=Y.map((F)=>T(F)),G=Z.apply(M,Q);if(FL.includes(J))I(E);if(G!=null&&typeof G==="object"){if(J==="find"||J==="findLast"||J==="at"){let F=M.indexOf(G);if(F!==-1)return new Proxy(G,r(o(E,String(F)),f))}}return G}:typeof Z==="object"?new Proxy(Z,r(o(E,J),f)):f?Uf(Z,o(E,J)):Z}else return f?Uf(M[J],o(E,J)):M[J]},set(M,L,H){H=T(H);let $=L===n||L==="xinValue"||L==="tosiValue"||L==="value"&&(wM(M)||f)?E:o(E,L);if(wL&&!WL($))throw Error(`setting invalid path ${$}`);if(T(x[$])!==H&&a(R,$,H))I($);return!0}}),GE=(E,f)=>{let M=typeof f==="function"?f:x[f];if(typeof M!=="function")throw Error(`observe expects a function or path to a function, ${f} is neither`);return _(E,M)},x=new Proxy(R,r("",!1));vf(x);var B=new Proxy(R,r("",!0));var UL=16,DL=100;function WM(E,f){let M=Array.from(E.querySelectorAll(g));if(E.matches(g))M.unshift(E);for(let L of M){let H=u.get(L);for(let J of H){if(J.path.startsWith("^"))J.path=`${f}${J.path.substring(1)}`;if(J.binding.toDOM!=null)J.binding.toDOM(L,x[J.path])}}}class UM{boundElement;listTop;listBottom;isNamespaced;template;options;itemToElement;array=[];_filteredCache;_update;_previousSlice;static filterBoundObservers=new WeakMap;constructor(E,f,M={}){if(this.boundElement=E,this.itemToElement=new WeakMap,M.idPath!=null){let H=O(f);if(H!=null)Bf(H,M.idPath)}if(E.children.length!==1)throw Error("ListBinding expects an element with exactly one child element");if(E.children[0]instanceof HTMLTemplateElement){let H=E.children[0];if(H.content.children.length!==1)throw Error("ListBinding expects a template with exactly one child element");this.template=e(H.content.children[0])}else this.template=E.children[0],this.template.remove();this.options=M;let L=E.namespaceURI;if(this.isNamespaced=L==="http://www.w3.org/2000/svg"||L==="http://www.w3.org/1998/Math/MathML",this.isNamespaced)this.listTop=null,this.listBottom=null;else this.listTop=document.createElement("div"),this.listBottom=document.createElement("div"),this.listTop.classList.add("virtual-list-padding"),this.listBottom.classList.add("virtual-list-padding"),this.boundElement.append(this.listTop),this.boundElement.append(this.listBottom);if(this.boundElement[YE]=this,this.isNamespaced&&M.virtual!=null)console.warn("ListBinding: virtual scrolling is not supported in SVG/MathML containers, ignoring virtual option");if(!this.isNamespaced&&M.virtual!=null)if(wE.observe(this.boundElement),this._update=fE(()=>{this.update(this.array,!0)},UL),this.boundElement.addEventListener("resize",this._update),M.virtual.scrollContainer==="window")window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update);else this.boundElement.addEventListener("scroll",this._update)}filteredArray(){if(this._filteredCache!=null)return this._filteredCache;let{hiddenProp:E,visibleProp:f}=this.options,M=this.array;if(E!==void 0)M=M.filter((L)=>L[E]!==!0);if(f!==void 0)M=M.filter((L)=>L[f]===!0);if(this.options.filter&&this.needle!==void 0)M=this.options.filter(M,this.needle);return this._filteredCache=M,M}visibleSlice(){let{virtual:E}=this.options,f=this.filteredArray(),M=0,L=f.length-1,H=0,J=0;if(E!=null&&this.boundElement instanceof HTMLElement){let $=this.boundElement.offsetWidth,Z=E.scrollContainer==="window",Y,Q;if(Z){Y=window.innerHeight;let U=this.boundElement.getBoundingClientRect();Q=Math.max(0,-U.top)}else Y=this.boundElement.offsetHeight,Q=this.boundElement.scrollTop;let G=E.width!=null?Math.max(1,Math.floor($/E.width)):E.visibleColumns??1,F=Math.ceil(f.length/G);if(E.minHeight!=null){let U=E.minHeight,V=Math.ceil(Y/U)+(E.rowChunkSize||1),w=G*V,q=F*U,D=Math.max(0,q-Y),y=D>0?Math.min(1,Math.max(0,Q/D)):0,z=Math.max(0,F-V+1),K=y*z,A=Math.floor(K);if(E.rowChunkSize)A-=A%E.rowChunkSize;return M=A*G,L=M+w-1,H=Q,J=Math.max(0,q-Q-Y),{items:f,firstItem:M,lastItem:L,topBuffer:H,bottomBuffer:J,interpolation:{t:y,position:K,scrollTop:Q,viewportHeight:Y,totalScrollHeight:q,rowHeight:E.height}}}else{let U=Math.ceil(Y/E.height)+(E.rowChunkSize||1),V=G*U,w=Math.floor(Q/E.height);if(w>F-U+1)w=Math.max(0,F-U+1);if(E.rowChunkSize)w-=w%E.rowChunkSize;M=w*G,L=M+V-1,H=w*E.height,J=Math.max((F-U)*E.height-H,0)}}return{items:f,firstItem:M,lastItem:L,topBuffer:H,bottomBuffer:J}}needle;filter=fE((E)=>{if(this.needle!==E)this.needle=E,this.update(this.array)},DL);update(E,f){if(E==null)E=[];if(this.array=E,!f)this._filteredCache=void 0;let{hiddenProp:M,visibleProp:L}=this.options,H=O(E),J=this.visibleSlice();this.boundElement.classList.toggle("-xin-empty-list",J.items.length===0);let $=this._previousSlice,{firstItem:Z,lastItem:Y,topBuffer:Q,bottomBuffer:G}=J,F=M===void 0&&L===void 0&&f===!0&&$!=null&&Z===$.firstItem&&Y===$.lastItem;if(F&&J.interpolation==null&&Q===$.topBuffer&&G===$.bottomBuffer)return;if(F&&J.interpolation!=null){this._updateInterpolatedBuffers(J);return}this._previousSlice=J;let U=0,V=0,w=0;for(let z of Array.from(this.boundElement.children)){if(z===this.listTop||z===this.listBottom)continue;let K=z[t];if(K==null)z.remove();else{let A=J.items.indexOf(K);if(A<Z||A>Y)z.remove(),this.itemToElement.delete(K),U++}}if(this.listTop!=null&&this.listBottom!=null)this.listTop.style.height=String(Q)+"px",this.listBottom.style.height=String(G)+"px";let q=[],{idPath:D}=this.options;for(let z=Z;z<=Y;z++){let K=J.items[z];if(K===void 0)continue;let A=this.itemToElement.get(T(K));if(A==null){if(w++,A=e(this.template),typeof K==="object")this.itemToElement.set(T(K),A),A[t]=T(K);if(this.listBottom!=null)this.boundElement.insertBefore(A,this.listBottom);else this.boundElement.append(A);if(D!=null){let p=K[D],CE=`${H}[${D}=${p}]`;WM(A,CE)}else{let p=`${H}[${z}]`;WM(A,p)}}q.push(A)}let y=null;for(let z of q){if(z.previousElementSibling!==y)if(V++,y?.nextElementSibling!=null)this.boundElement.insertBefore(z,y.nextElementSibling);else if(this.listBottom!=null)this.boundElement.insertBefore(z,this.listBottom);else this.boundElement.append(z);y=z}if(J.interpolation!=null)this._updateInterpolatedBuffers(J);if(i.perf)console.log(H,"updated",{removed:U,created:w,moved:V})}_updateInterpolatedBuffers(E){let{t:f,position:M,scrollTop:L,viewportHeight:H,totalScrollHeight:J,rowHeight:$}=E.interpolation,Z=0;for(let F of Array.from(this.boundElement.children)){if(F===this.listTop||F===this.listBottom)continue;Z+=F.offsetHeight||$}let Y=L,Q=L+H-Z,G=Math.max(0,f*Q+(1-f)*Y-M%1*$);if(this.listTop!=null&&this.listBottom!=null)this.listTop.style.height=String(G)+"px",this.listBottom.style.height=String(Math.max(0,J-G-Z))+"px"}}var QE=(E,f,M)=>{let L=E[YE];if(f&&L===void 0)L=new UM(E,f,M),E[YE]=L;return L},mE=(E)=>{let f;while(!(f=E[t])&&E&&E.parentElement)E=E.parentElement;return f?{element:E,item:f}:void 0},PE=(E)=>{let f=mE(E);return f?f.item:void 0},DM=(E)=>{let f=mE(E);if(!f)return console.error("deleteListItem failed, element is not part of a list instance",E),!1;let M=QE(f.element.parentElement);if(!M.options.idPath)return console.error("deleteListItem failed, list binding has no idPath",E.parentElement,M),!1;let L=M.array.indexOf(f.item);if(L>-1)return M.array.splice(L,1),!0;return!1},qL={start:"start",middle:"center",end:"end",nearest:"nearest"},qM=(E,f,M={})=>{let L=QE(E);if(L==null)return console.error("scrollListItemIntoView failed, element has no list binding",E),!1;let{position:H="middle"}=M,J=L.filteredArray(),$=T(f)??f,Z=J.indexOf($);if(Z===-1)return console.error("scrollListItemIntoView failed, item not found in list",f),!1;let{virtual:Y}=L.options;if(Y!=null&&E instanceof HTMLElement){let Q=Y.width!=null?Math.max(1,Math.floor(E.offsetWidth/Y.width)):Y.visibleColumns??1,G=Math.floor(Z/Q),F=Y.minHeight??Y.height,U=Math.ceil(J.length/Q),V=Y.scrollContainer==="window",w=V?window.innerHeight:E.offsetHeight,q;if(Y.minHeight!=null){let D=Math.ceil(w/F)+(Y.rowChunkSize||1),y=U*F,z=Math.max(0,y-w),K=Math.max(1,U-D+1),A=G/K;switch(H){case"start":q=A*z;break;case"end":q=Math.max(0,(G-D+1)/K*z);break;case"nearest":{let p=V?Math.max(0,-E.getBoundingClientRect().top):E.scrollTop,CE=z>0?p/z:0,Rf=Math.floor(CE*K);if(G<Rf)q=A*z;else if(G>=Rf+D)q=Math.max(0,(G-D+1)/K*z);else return!0;break}default:{let p=G-Math.floor(D/2);q=Math.max(0,p)/K*z}}}else{let D=G*Y.height;switch(H){case"start":q=D;break;case"end":q=D-w+Y.height;break;case"nearest":{let y=V?Math.max(0,-E.getBoundingClientRect().top):E.scrollTop;if(D<y)q=D;else if(D+Y.height>y+w)q=D-w+Y.height;else return!0;break}default:q=D-(w-Y.height)/2}}if(q=Math.max(0,q),V){let D=E.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:D+q,behavior:"smooth"})}else E.scrollTo({top:q,behavior:"smooth"})}else{let Q=L.itemToElement.get($);if(Q==null)return console.error("scrollListItemIntoView failed, no DOM element found for item",f),!1;Q.scrollIntoView({block:qL[H]??"center",behavior:"smooth"})}return!0};var{document:DE,MutationObserver:OM}=globalThis,cE=(E,f)=>{let M=u.get(E);if(M==null)return;for(let L of M){let{binding:H,options:J}=L,{path:$}=L,{toDOM:Z}=H;if(Z!=null){if($.startsWith("^")){let Y=PE(E);if(Y!=null&&Y[S]!=null)$=L.path=`${Y[S]}${$.substring(1)}`;else{if(E instanceof HTMLElement)console.warn(`Unresolved relative binding "${$}" —`,E,"is not part of a list. If this is a list template, wrap it in a <template>.");continue}}if(f==null||$.startsWith(f))Z(E,VE()[$],J)}}};if(OM!=null)new OM((f)=>{f.forEach((M)=>{Array.from(M.addedNodes).forEach((L)=>{if(L instanceof Element)Array.from(L.querySelectorAll(g)).forEach((H)=>cE(H))})})}).observe(DE.body,{subtree:!0,childList:!0});_(()=>!0,(E)=>{let f=Array.from(DE.querySelectorAll(g));for(let M of f)cE(M,E)});var KM=(E)=>{let f=E.target?.closest(g);while(f!=null){let M=u.get(f);for(let L of M){let{binding:H,path:J}=L,{fromDOM:$}=H;if($!=null){let Z;try{Z=$(f,L.options)}catch(Y){throw console.error("Cannot get value from",f,"via",L),Error("Cannot obtain value fromDOM")}if(Z!=null){let Y=VE(),Q=Y[J];if(Q==null)Y[J]=Z;else{let G=Q[S]!=null?Q[n]:Q,F=Z[S]!=null?Z[n]:Z;if(G!==F)Y[J]=F}}}}f=f.parentElement.closest(g)}};if(globalThis.document!=null)DE.body.addEventListener("change",KM,!0),DE.body.addEventListener("input",KM,!0);function c(E,f,M,L){if(E instanceof DocumentFragment)throw Error("bind cannot bind to a DocumentFragment");let H;if(typeof f==="object"&&f[S]===void 0&&L===void 0){let{value:Z}=f;H=typeof Z==="string"?Z:Z[S],L=f,delete L.value}else H=typeof f==="string"?f:f[S];if(H==null)throw Error("bind requires a path or object with xin Proxy");let{toDOM:J}=M;E.classList?.add(oE);let $=u.get(E);if($==null)$=[],u.set(E,$);if($.push({path:H,binding:M,options:L}),J!=null&&!H.startsWith("^"))I(H);if(L?.filter&&L?.needle)c(E,L.needle,{toDOM(Z,Y){console.log({needle:Y}),Z[YE]?.filter(Y)}});return E}var AM=new Set,OL=(E)=>{let f=E?.target?.closest(pE),M=!1,L=new Proxy(E,{get(J,$){if($==="stopPropagation")return()=>{E.stopPropagation(),M=!0};else{let Z=J[$];return typeof Z==="function"?Z.bind(J):Z}}}),H=new Set;while(!M&&f!=null){let $=l.get(f)[E.type]||H;for(let Z of $){if(typeof Z==="function")Z(L);else{let Y=VE()[Z];if(typeof Y==="function")Y(L);else throw Error(`no event handler found at path ${Z}`)}if(M)continue}f=f.parentElement!=null?f.parentElement.closest(pE):null}};function LE(E,f,M){let L=l.get(E);if(E.classList.add(rE),L==null)L={},l.set(E,L);if(!L[f])L[f]=new Set;if(L[f].add(M),!AM.has(f))AM.add(f),DE.body.addEventListener(f,OL,!0);return()=>{L[f].delete(M)}}df(c,LE);function bE(E,f){if(!E.internals)return;let M={},L="";if(E.hasAttribute("required")&&f==="")M.valueMissing=!0,L="Please fill out this field.";let H=E.getAttribute("minlength");if(H&&f.length<parseInt(H,10))M.tooShort=!0,L=`Please use at least ${H} characters.`;let J=E.getAttribute("maxlength");if(J&&f.length>parseInt(J,10))M.tooLong=!0,L=`Please use no more than ${J} characters.`;let $=E.getAttribute("pattern");if($&&f!=="")try{if(!new RegExp(`^(?:${$})$`).test(f))M.patternMismatch=!0,L="Please match the requested format."}catch{}if(Object.keys(M).length>0)E.internals.setValidity(M,L,E);else E.internals.setValidity({})}var KL=0;function Of(){return`custom-elt${(KL++).toString(36)}`}var TM=0,Kf=null;function AL(){if(Kf===null)Kf=new MutationObserver((E)=>{let f=new Set;for(let M of E)if(M.type==="attributes"&&M.target instanceof N){let L=M.target,H=Gf(M.attributeName);if(L._legacyTrackedAttrs?.has(H))f.add(L)}for(let M of f)M.queueRender(!1)});return Kf}var qE={};function TL(E,f){let M=qE[E],L=s(f).replace(/:host\(([^)]+)\)/g,`${E}$1`).replace(/:host\b/g,E);qE[E]=M?M+`
13
+ `+L:L}function jL(E){if(qE[E])document.head.append(W.style({id:E+"-component"},qE[E]));delete qE[E]}class N extends HTMLElement{static elements=W;static _elementCreator;static initAttributes;static formAssociated;static preferredTagName;static shadowStyleSpec;static lightStyleSpec;static extends;internals;get validity(){return this.internals?.validity}get validationMessage(){return this.internals?.validationMessage??""}get willValidate(){return this.internals?.willValidate??!1}checkValidity(){return this.internals?.checkValidity()??!0}reportValidity(){return this.internals?.reportValidity()??!0}setCustomValidity(E){if(this.internals)if(E)this.internals.setValidity({customError:!0},E);else this.internals.setValidity({})}setValidity(E,f,M){this.internals?.setValidity(E,f,M)}setFormValue(E,f){this.internals?.setFormValue(E,f)}static get observedAttributes(){let E=this.initAttributes;if(E)return["hidden",...Object.keys(E).map(k)];return["hidden"]}instanceId;styleNode;static styleSpec;static styleNode;content=W.slot();isSlotted;static _tagName=null;static get tagName(){return this._tagName}_legacyTrackedAttrs;_attrValues;_valueChanged=!1;static StyleNode(E){return console.warn("StyleNode is deprecated, use static shadowStyleSpec instead"),W.style(s(E))}static elementCreator(E={}){let f=this;if(!Object.prototype.hasOwnProperty.call(f,"_elementCreator")){if(E.tag!==void 0)C("elementCreator-tag","Passing tag to elementCreator() is deprecated. Use static preferredTagName instead.");if(E.styleSpec!==void 0)C("elementCreator-styleSpec","Passing styleSpec to elementCreator() is deprecated. Use static lightStyleSpec instead.");if(E.extends!==void 0)C("elementCreator-extends","Passing extends to elementCreator() is deprecated. Use static extends instead.");let M=E.tag??f.preferredTagName;if(M==null)if(typeof f.name==="string"&&f.name!==""){if(M=k(f.name),M.startsWith("-"))M=M.slice(1)}else M=Of();if(customElements.get(M)!=null)console.warn(`${M} is already defined`);if(M.match(/\w+(-\w+)+/)==null)console.warn(`${M} is not a legal tag for a custom-element`),M=Of();while(customElements.get(M)!==void 0)M=Of();f._tagName=M;let L=E.styleSpec??f.lightStyleSpec;if(L!==void 0)TL(M,L);let H=E.extends??f.extends,J=H?{extends:H}:void 0;window.customElements.define(M,this,J),f._elementCreator=W[M]}return f._elementCreator}initAttributes(...E){if(C("initAttributes","initAttributes() is deprecated. Use static initAttributes = { ... } instead."),!this._legacyTrackedAttrs)this._legacyTrackedAttrs=new Set;for(let H of E)this._legacyTrackedAttrs.add(H);AL().observe(this,{attributes:!0});let M={},L={};E.forEach((H)=>{M[H]=b(this[H]);let J=k(H);Object.defineProperty(this,H,{enumerable:!1,get(){if(typeof M[H]==="boolean")return this.hasAttribute(J);else if(this.hasAttribute(J))return typeof M[H]==="number"?parseFloat(this.getAttribute(J)):this.getAttribute(J);else if(L[H]!==void 0)return L[H];else return M[H]},set($){if(typeof M[H]==="boolean"){if($!==this[H]){if($)this.setAttribute(J,"");else this.removeAttribute(J);this.queueRender()}}else if(typeof M[H]==="number"){if($!==parseFloat(this[H]))this.setAttribute(J,$),this.queueRender()}else if(typeof $==="object"||`${$}`!==`${this[H]}`){if($===null||$===void 0||typeof $==="object")this.removeAttribute(J);else this.setAttribute(J,$);this.queueRender(),L[H]=$}}})})}initValue(){let E=Object.getOwnPropertyDescriptor(this,"value");if(E===void 0||E.get!==void 0||E.set!==void 0)return;let f=this.hasAttribute("value")?this.getAttribute("value"):b(this.value);delete this.value,Object.defineProperty(this,"value",{enumerable:!1,get(){return f},set(M){if(f!==M)f=M,this._valueChanged=!0,this.queueRender(!0)}})}_parts;get parts(){let E=this.shadowRoot!=null?this.shadowRoot:this;if(this._parts==null)this._parts=new Proxy({},{get(f,M){if(f[M]===void 0){let L=E.querySelector(`[part="${M}"]`);if(L==null)L=E.querySelector(M);if(L==null)throw Error(`elementRef "${M}" does not exist!`);L.removeAttribute("data-ref"),f[M]=L}return f[M]}});return this._parts}attributeChangedCallback(E,f,M){let L=Gf(E);if(!this._legacyTrackedAttrs?.has(L))this.queueRender(!1)}constructor(){super();if(TM+=1,this.constructor.formAssociated&&typeof this.attachInternals==="function"&&!this.internals)this.internals=this.attachInternals();let E=this.constructor.initAttributes;if(E)this._setupAttributeAccessors(E);this.instanceId=`${this.tagName.toLocaleLowerCase()}-${TM}`,this._value=b(this.defaultValue)}_setupAttributeAccessors(E){if(!this._attrValues)this._attrValues=new Map;for(let f of Object.keys(E)){let M=k(f),L=E[f];if(f==="value"){console.warn(`${this.tagName}: 'value' cannot be an attribute. Use the Component value property instead.`);continue}if(typeof L==="object"&&L!==null){console.warn(`${this.tagName}: initAttributes.${f} is an object. Use a regular property instead.`);continue}let H=this,J=!1;while(H){let $=Object.getOwnPropertyDescriptor(H,f);if($){if(!$.configurable||$.get||$.set){J=!0;break}break}H=Object.getPrototypeOf(H)}if(J)continue;Object.defineProperty(this,f,{enumerable:!1,get:()=>{if(typeof L==="boolean")return this.hasAttribute(M);else if(this.hasAttribute(M))return typeof L==="number"?parseFloat(this.getAttribute(M)):this.getAttribute(M);else if(this._attrValues.has(f))return this._attrValues.get(f);else return L},set:($)=>{if(typeof L==="boolean"){if($!==this[f]){if($)this.setAttribute(M,"");else this.removeAttribute(M);this.queueRender()}}else if(typeof L==="number"){if($!==parseFloat(this[f]))this.setAttribute(M,$),this.queueRender()}else if(typeof $==="object"||`${$}`!==`${this[f]}`){if($===null||$===void 0||typeof $==="object")this.removeAttribute(M);else this.setAttribute(M,$);this.queueRender(),this._attrValues.set(f,$)}}})}}connectedCallback(){if(jL(this.constructor.tagName),this.hydrate(),this.role!=null)this.setAttribute("role",this.role);if(this.constructor.formAssociated&&!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.onResize!==void 0){if(wE.observe(this),this._onResize==null)this._onResize=this.onResize.bind(this);this.addEventListener("resize",this._onResize)}if(this.value!=null&&this.getAttribute("value")!=null)this._value=this.getAttribute("value");if(this.internals&&this.value!==void 0)this.internals.setFormValue(this.value),this.validateValue();this.queueRender()}disconnectedCallback(){wE.unobserve(this)}formResetCallback(){if(this.value!==void 0)this.value=this.defaultValue??""}formDisabledCallback(E){if(E)this.setAttribute("disabled","");else this.removeAttribute("disabled")}formStateRestoreCallback(E){if(this.value!==void 0&&typeof E==="string")this.value=E}_changeQueued=!1;_renderQueued=!1;queueRender(E=!1){if(!this._hydrated)return;if(!this._changeQueued)this._changeQueued=E;if(!this._renderQueued)this._renderQueued=!0,requestAnimationFrame(()=>{if(this._changeQueued){if(Zf(this,"change"),this.internals&&this.value!==void 0)this.internals.setFormValue(this.value)}this._changeQueued=!1,this._renderQueued=!1,this.render()})}_hydrated=!1;hydrate(){if(!this._hydrated){this.initValue();let E=typeof this.content!=="function",f=typeof this.content==="function"?this.content(W):this.content;if(Array.isArray(f)){let J={};f=f.filter(($)=>{if($ instanceof Node||typeof $==="string"||typeof $==="number"||O($))return!0;return Object.assign(J,$),!1});for(let $ of Object.keys(J))SE(this,$,J[$])}let M=this.constructor,L=M.shadowStyleSpec??M.styleSpec;if(M.styleSpec&&!M.shadowStyleSpec)C("static-styleSpec","static styleSpec is deprecated. Use static shadowStyleSpec instead.");let{styleNode:H}=M;if(L)H=M.styleNode=W.style(s(L)),delete M.styleNode;if(this.styleNode)console.warn(this,"styleNode is deprecated, use static shadowStyleSpec instead"),H=this.styleNode;if(H){let J=this.attachShadow({mode:"open"});J.appendChild(H.cloneNode(!0)),Qf(J,f,E)}else if(f!==null){let J=Array.from(this.childNodes);Qf(this,f,E),this.isSlotted=this.querySelector("slot,tosi-slot,xin-slot")!==void 0;let $=Array.from(this.querySelectorAll("slot"));if($.length>0)$.forEach(uE.replaceSlot);if(J.length>0){let Z={"":this};Array.from(this.querySelectorAll("tosi-slot,xin-slot")).forEach((Y)=>{Z[Y.name]=Y}),J.forEach((Y)=>{let Q=Z[""],G=Y instanceof Element?Z[Y.slot]:Q;(G!==void 0?G:Q).append(Y)})}}this._hydrated=!0}}render(){if(this._valueChanged&&this.internals&&this.value!==void 0)this.internals.setFormValue(this.value),this.validateValue();this._valueChanged=!1}validateValue(){if(!this.internals||this.value===void 0)return;let E=typeof this.value==="string"?this.value:String(this.value);bE(this,E)}}class uE extends N{static preferredTagName="tosi-slot";static initAttributes={name:""};content=null;static replaceSlot(E){let f=document.createElement("tosi-slot");if(E.name!=="")f.setAttribute("name",E.name);E.replaceWith(f)}}var jM=uE.elementCreator();class CM extends N{static preferredTagName="xin-slot";static initAttributes={name:""};content=null;constructor(){super();C("xin-slot","<xin-slot> is deprecated. Use <tosi-slot> instead.")}static replaceSlot=uE.replaceSlot}var xM=CM.elementCreator();var VM=(E=()=>!0)=>{let f=localStorage.getItem("xin-state");if(f!=null){let L=JSON.parse(f);for(let H of Object.keys(L).filter(E))if(x[H]!==void 0)Object.assign(x[H],L[H]);else x[H]=L[H]}let M=ZE(()=>{let L={},H=T(x);for(let J of Object.keys(H).filter(E))L[J]=H[J];localStorage.setItem("xin-state",JSON.stringify(L)),console.log("xin state saved to localStorage")},500);GE(E,M)};var CL="tosijs-share",xL="tosijs-share",OE="shared",VL=1,Tf=new Set,jf=new Set,Af=new Map,JE=null,Cf="",nE=null,RL=null;function RM(){if(nE!=null)return Promise.resolve(nE);return new Promise((E,f)=>{let M=indexedDB.open(xL,VL);M.onupgradeneeded=()=>{M.result.createObjectStore(OE)},M.onsuccess=()=>{nE=M.result,E(nE)},M.onerror=()=>f(M.error)})}var IL={async get(E){let f=await RM();return new Promise((M,L)=>{let J=f.transaction(OE,"readonly").objectStore(OE).get(E);J.onsuccess=()=>M(J.result),J.onerror=()=>L(J.error)})},async set(E,f){let M=await RM();return new Promise((L,H)=>{let J=M.transaction(OE,"readwrite");J.objectStore(OE).put(f,E),J.oncomplete=()=>L(),J.onerror=()=>H(J.error)})}};function IM(){return RL??IL}function kL(E){return E!=null&&E.type==="tosijs-share"&&typeof E.path==="string"}function kM(E){for(let f of Tf)if(E===f||E.startsWith(f+"."))return f;return}function BL(E){for(let f of jf)if(E===f||E.startsWith(f+"."))return!0;return!1}function yL(E,f){jf.add(E),a(R,E,f),I(E),EE().then(()=>{jf.delete(E)})}function SL(){if(JE!=null)return JE;return Cf=crypto.randomUUID(),JE=new BroadcastChannel(CL),JE.onmessage=(E)=>{let f=E.data;if(!kL(f))return;if(f.origin===Cf)return;if(kM(f.path)===void 0)return;yL(f.path,f.value)},JE}function _L(E,f){if(JE==null)return;let M={type:"tosijs-share",path:E,value:f,origin:Cf};JE.postMessage(M)}function NL(E){if(!Af.has(E))Af.set(E,ZE(()=>{let f=j(R,E);IM().set(E,f)},500));Af.get(E)()}async function BM(...E){if(typeof BroadcastChannel>"u")return{restored:[]};SL();let f=[],M=IM();for(let L of E){let H=typeof L==="string"?L:O(L);if(H===void 0)throw Error("share() requires boxed proxies or string paths. Got a non-proxy value.");if(Tf.has(H))continue;Tf.add(H);let J=await M.get(H);if(J!==void 0)a(R,H,J),I(H),f.push(L);else{let $=j(R,H);await M.set(H,$)}_(($)=>$===H||$.startsWith(H+"."),($)=>{if(BL($))return;let Z=kM($);if(Z===void 0)return;let Y=j(R,$);_L($,Y),NL(Z)})}return{restored:f}}var xf=new Set;function yM(E,f){for(let M of E)if(f===M||f.startsWith(M+"."))return M;return}function mL(E){for(let f of xf)if(E===f||E.startsWith(f+"."))return!0;return!1}function PL(E,f){xf.add(E),a(R,E,f),I(E),EE().then(()=>{xf.delete(E)})}async function SM(E,f,...M){let L=new Set,H=[],J=[],$=f.throttleInterval??100;await E.connect();let Z=fE(()=>{if(H.length===0)return;let Y=H.splice(0);E.send(Y)},$);E.onReceive((Y)=>{for(let Q of Y){if(yM(L,Q.path)===void 0)continue;PL(Q.path,Q.value)}});for(let Y of M){let Q=typeof Y==="string"?Y:O(Y);if(Q===void 0)throw Error("sync() requires boxed proxies or string paths. Got a non-proxy value.");L.add(Q);let G=_((F)=>F===Q||F.startsWith(Q+"."),(F)=>{if(mL(F))return;if(yM(L,F)===void 0)return;let U=j(R,F);H.push({path:F,value:U}),Z()});J.push(G)}return{disconnect(){for(let Y of J)m(Y);J.length=0,L.clear(),H.length=0,E.disconnect()}}}var vE="1.5.3";function KE(E){return Object.assign(B,E),B}function AE(E){return C("boxedProxy","boxedProxy is deprecated, please use tosi() instead"),KE(E)}function dE(E,f=!1){if(f)return C("xinProxy-boxed","xinProxy(..., true) is deprecated; use tosi(...) instead"),AE(E);return Object.keys(E).forEach((M)=>{x[M]=E[M]}),x}var cL={};async function TE(E,f){let M=await f(E,{Color:X,Component:N,elements:W,svgElements:_E,mathML:NE,varDefault:WE,vars:BE,xin:x,boxed:B,xinProxy:dE,boxedProxy:AE,tosi:KE,makeComponent:TE,bind:c,on:LE,version:vE}),{type:L}=M;L.preferredTagName=E;let H=M.lightStyleSpec??M.styleSpec;if(H)L.lightStyleSpec=H;let J={type:L,creator:L.elementCreator()};return cL[E]=J,J}var gE={":host":{display:"none"}},Vf={},bL=(E)=>import(E);class jE extends N{static preferredTagName="tosi-blueprint";static lightStyleSpec=gE;static initAttributes={tag:"anon-elt",src:"",property:"default"};loaded;blueprintLoaded=(E)=>{};async packaged(){let{tag:E,src:f,property:M}=this,L=`${E}.${M}:${f}`;if(!this.loaded){if(Vf[L]===void 0)Vf[L]=bL(f).then((H)=>{let J=H[M];return TE(E,J)});else console.log(`using cached ${E} with signature ${L}`);this.loaded=await Vf[L],this.blueprintLoaded(this.loaded)}return this.loaded}}var _M=jE.elementCreator();class iE extends N{static preferredTagName="tosi-loader";static lightStyleSpec=gE;allLoaded=()=>{};async load(){let f=Array.from(this.querySelectorAll("tosi-blueprint, xin-blueprint")).filter((M)=>M.src).map((M)=>M.packaged());await Promise.all(f),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var NM=iE.elementCreator();class mM extends jE{static preferredTagName="xin-blueprint";static lightStyleSpec=gE;constructor(){super();C("xin-blueprint","<xin-blueprint> is deprecated. Use <tosi-blueprint> instead.")}}var PM=mM.elementCreator();class cM extends N{static preferredTagName="xin-loader";static lightStyleSpec=gE;allLoaded=()=>{};constructor(){super();C("xin-loader","<xin-loader> is deprecated. Use <tosi-loader> instead.")}async load(){let f=Array.from(this.querySelectorAll("xin-blueprint")).filter((M)=>M.src).map((M)=>M.packaged());await Promise.all(f),this.allLoaded()}connectedCallback(){super.connectedCallback(),this.load()}}var bM=cM.elementCreator();})();
14
14
 
15
- //# debugId=8E8FF25BC6DF40F464756E2164756E21
15
+ //# debugId=CB0FAB542E5FDF3F64756E2164756E21
16
16
  //# sourceMappingURL=index.js.map