mol_plot_all 1.2.1490 → 1.2.1492

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/web.mjs CHANGED
@@ -275,64 +275,136 @@ var $;
275
275
  $.$mol_style_prop = $mol_style_prop;
276
276
  })($ || ($ = {}));
277
277
 
278
+ ;
279
+ "use strict";
280
+
278
281
  ;
279
282
  "use strict";
280
283
  var $;
281
284
  (function ($) {
282
- $.$mol_theme = $mol_style_prop('mol_theme', [
283
- 'back',
284
- 'hover',
285
- 'card',
286
- 'current',
287
- 'special',
288
- 'text',
289
- 'control',
290
- 'shade',
291
- 'line',
292
- 'focus',
293
- 'field',
294
- 'image',
295
- 'spirit',
296
- ]);
285
+ $.$mol_ambient_ref = Symbol('$mol_ambient_ref');
286
+ function $mol_ambient(overrides) {
287
+ return Object.setPrototypeOf(overrides, this || $);
288
+ }
289
+ $.$mol_ambient = $mol_ambient;
297
290
  })($ || ($ = {}));
298
291
 
299
292
  ;
300
293
  "use strict";
301
294
  var $;
302
295
  (function ($) {
303
- $mol_style_attach("mol/theme/theme.css", ":root {\n\t--mol_theme_hue: 240deg;\n\t--mol_theme_hue_spread: 90deg;\n\tcolor-scheme: dark light;\n}\n\n:where([mol_theme]) {\n\tcolor: var(--mol_theme_text);\n\tfill: var(--mol_theme_text);\n\tbackground-color: var(--mol_theme_back);\n}\n\t\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\n\t--mol_theme_luma: -1;\n\t--mol_theme_image: invert(1) hue-rotate( 180deg );\n\t--mol_theme_spirit: hsl( 0deg, 0%, 0%, .75 );\n\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 10% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 20%, .25 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 8%, .25 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 80% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 60%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 65% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 60%, 65% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 60%, 65% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 60%, 65% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\t\n\t--mol_theme_back: oklch( 20% .03 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 30% .05 var(--mol_theme_hue) / .25 );\n\t--mol_theme_field: oklch( 15% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 80% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 60% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 80% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 70% .1 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 70% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 70% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t\n\t--mol_theme_luma: 1;\n\t--mol_theme_image: none;\n\t--mol_theme_spirit: hsl( 0deg, 0%, 100%, .75 );\n\t\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 92% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 100%, .5 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 100%, .75 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 0% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 40%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 40% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 80%, 30% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 80%, 30% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 80%, 30% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t--mol_theme_back: oklch( 92% .01 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 99% .01 var(--mol_theme_hue) / .5 );\n\t--mol_theme_field: oklch( 100% 0 var(--mol_theme_hue) / .5 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 20% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 50% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 60% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 40% .15 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 50% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 50% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 25% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 35% .1 var(--mol_theme_hue) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 85% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 98% .03 var(--mol_theme_hue) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 35% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 45% .15 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 83% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n\n");
296
+ const instances = new WeakSet();
297
+ function $mol_delegate(proto, target) {
298
+ const proxy = new Proxy(proto, {
299
+ get: (_, field) => {
300
+ const obj = target();
301
+ let val = Reflect.get(obj, field);
302
+ if (typeof val === 'function') {
303
+ val = val.bind(obj);
304
+ }
305
+ return val;
306
+ },
307
+ has: (_, field) => Reflect.has(target(), field),
308
+ set: (_, field, value) => Reflect.set(target(), field, value),
309
+ getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
310
+ ownKeys: () => Reflect.ownKeys(target()),
311
+ getPrototypeOf: () => Reflect.getPrototypeOf(target()),
312
+ setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
313
+ isExtensible: () => Reflect.isExtensible(target()),
314
+ preventExtensions: () => Reflect.preventExtensions(target()),
315
+ apply: (_, self, args) => Reflect.apply(target(), self, args),
316
+ construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
317
+ defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
318
+ deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
319
+ });
320
+ instances.add(proxy);
321
+ return proxy;
322
+ }
323
+ $.$mol_delegate = $mol_delegate;
324
+ Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
325
+ value: (obj) => instances.has(obj),
326
+ });
304
327
  })($ || ($ = {}));
305
328
 
306
329
  ;
307
330
  "use strict";
308
331
  var $;
309
332
  (function ($) {
310
- $.$mol_gap = $mol_style_prop('mol_gap', [
311
- 'block',
312
- 'text',
313
- 'round',
314
- 'space',
315
- 'blur',
316
- ]);
333
+ $.$mol_owning_map = new WeakMap();
334
+ function $mol_owning_allow(having) {
335
+ try {
336
+ if (!having)
337
+ return false;
338
+ if (typeof having !== 'object' && typeof having !== 'function')
339
+ return false;
340
+ if (having instanceof $mol_delegate)
341
+ return false;
342
+ if (typeof having['destructor'] !== 'function')
343
+ return false;
344
+ return true;
345
+ }
346
+ catch {
347
+ return false;
348
+ }
349
+ }
350
+ $.$mol_owning_allow = $mol_owning_allow;
351
+ function $mol_owning_get(having, Owner) {
352
+ if (!$mol_owning_allow(having))
353
+ return null;
354
+ while (true) {
355
+ const owner = $.$mol_owning_map.get(having);
356
+ if (!owner)
357
+ return owner;
358
+ if (!Owner)
359
+ return owner;
360
+ if (owner instanceof Owner)
361
+ return owner;
362
+ having = owner;
363
+ }
364
+ }
365
+ $.$mol_owning_get = $mol_owning_get;
366
+ function $mol_owning_check(owner, having) {
367
+ if (!$mol_owning_allow(having))
368
+ return false;
369
+ if ($.$mol_owning_map.get(having) !== owner)
370
+ return false;
371
+ return true;
372
+ }
373
+ $.$mol_owning_check = $mol_owning_check;
374
+ function $mol_owning_catch(owner, having) {
375
+ if (!$mol_owning_allow(having))
376
+ return false;
377
+ if ($.$mol_owning_map.get(having))
378
+ return false;
379
+ $.$mol_owning_map.set(having, owner);
380
+ return true;
381
+ }
382
+ $.$mol_owning_catch = $mol_owning_catch;
317
383
  })($ || ($ = {}));
318
384
 
319
385
  ;
320
386
  "use strict";
321
387
  var $;
322
388
  (function ($) {
323
- $mol_style_attach("mol/gap/gap.css", ":root {\n\t--mol_gap_block: .75rem;\n\t--mol_gap_text: .5rem .75rem;\n\t--mol_gap_round: .25rem;\n\t--mol_gap_space: .25rem;\n\t--mol_gap_blur: .5rem;\n}\n");
389
+ function $mol_fail(error) {
390
+ throw error;
391
+ }
392
+ $.$mol_fail = $mol_fail;
324
393
  })($ || ($ = {}));
325
394
 
326
395
  ;
327
396
  "use strict";
328
397
  var $;
329
398
  (function ($) {
330
- function $mol_fail(error) {
399
+ function $mol_fail_hidden(error) {
331
400
  throw error;
332
401
  }
333
- $.$mol_fail = $mol_fail;
402
+ $.$mol_fail_hidden = $mol_fail_hidden;
334
403
  })($ || ($ = {}));
335
404
 
405
+ ;
406
+ "use strict";
407
+
336
408
  ;
337
409
  "use strict";
338
410
  var $;
@@ -369,473 +441,177 @@ var $;
369
441
  "use strict";
370
442
  var $;
371
443
  (function ($) {
372
- function $mol_dom_render_children(el, childNodes) {
373
- const node_set = new Set(childNodes);
374
- let nextNode = el.firstChild;
375
- for (let view of childNodes) {
376
- if (view == null)
377
- continue;
378
- if (view instanceof $mol_dom_context.Node) {
379
- while (true) {
380
- if (!nextNode) {
381
- el.appendChild(view);
382
- break;
383
- }
384
- if (nextNode == view) {
385
- nextNode = nextNode.nextSibling;
386
- break;
387
- }
388
- else {
389
- if (node_set.has(nextNode)) {
390
- el.insertBefore(view, nextNode);
391
- break;
392
- }
393
- else {
394
- const nn = nextNode.nextSibling;
395
- el.removeChild(nextNode);
396
- nextNode = nn;
397
- }
398
- }
399
- }
400
- }
401
- else {
402
- if (nextNode && nextNode.nodeName === '#text') {
403
- const str = String(view);
404
- if (nextNode.nodeValue !== str)
405
- nextNode.nodeValue = str;
406
- nextNode = nextNode.nextSibling;
407
- }
408
- else {
409
- const textNode = $mol_dom_context.document.createTextNode(String(view));
410
- el.insertBefore(textNode, nextNode);
411
- }
412
- }
444
+ class $mol_object2 {
445
+ static $ = $;
446
+ [Symbol.toStringTag];
447
+ [$mol_ambient_ref] = null;
448
+ get $() {
449
+ if (this[$mol_ambient_ref])
450
+ return this[$mol_ambient_ref];
451
+ const owner = $mol_owning_get(this);
452
+ return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
413
453
  }
414
- while (nextNode) {
415
- const currNode = nextNode;
416
- nextNode = currNode.nextSibling;
417
- el.removeChild(currNode);
454
+ set $(next) {
455
+ if (this[$mol_ambient_ref])
456
+ $mol_fail_hidden(new Error('Context already defined'));
457
+ this[$mol_ambient_ref] = next;
458
+ }
459
+ static create(init) {
460
+ const obj = new this;
461
+ if (init)
462
+ init(obj);
463
+ return obj;
464
+ }
465
+ static [Symbol.toPrimitive]() {
466
+ return this.toString();
467
+ }
468
+ static toString() {
469
+ return this[Symbol.toStringTag] || this.$.$mol_func_name(this);
470
+ }
471
+ static toJSON() {
472
+ return this.toString();
473
+ }
474
+ destructor() { }
475
+ static destructor() { }
476
+ toString() {
477
+ return this[Symbol.toStringTag] || this.constructor.name + '<>';
418
478
  }
419
479
  }
420
- $.$mol_dom_render_children = $mol_dom_render_children;
480
+ $.$mol_object2 = $mol_object2;
421
481
  })($ || ($ = {}));
422
482
 
423
483
  ;
424
484
  "use strict";
485
+ var $;
486
+ (function ($_1) {
487
+ let $$;
488
+ (function ($$) {
489
+ let $;
490
+ })($$ = $_1.$$ || ($_1.$$ = {}));
491
+ $_1.$mol_object_field = Symbol('$mol_object_field');
492
+ class $mol_object extends $mol_object2 {
493
+ static make(config) {
494
+ return super.create(obj => {
495
+ for (let key in config)
496
+ obj[key] = config[key];
497
+ });
498
+ }
499
+ }
500
+ $_1.$mol_object = $mol_object;
501
+ })($ || ($ = {}));
425
502
 
426
503
  ;
427
504
  "use strict";
428
505
  var $;
429
506
  (function ($) {
430
- $.$mol_jsx_prefix = '';
431
- $.$mol_jsx_crumbs = '';
432
- $.$mol_jsx_booked = null;
433
- $.$mol_jsx_document = {
434
- getElementById: () => null,
435
- createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
436
- createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
437
- };
438
- $.$mol_jsx_frag = '';
439
- function $mol_jsx(Elem, props, ...childNodes) {
440
- const id = props && props.id || '';
441
- const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
442
- const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
443
- if (Elem && $.$mol_jsx_booked) {
444
- if ($.$mol_jsx_booked.has(id)) {
445
- $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
446
- }
447
- else {
448
- $.$mol_jsx_booked.add(id);
449
- }
507
+ function $mol_guid(length = 8, exists = () => false) {
508
+ for (;;) {
509
+ let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
510
+ if (exists(id))
511
+ continue;
512
+ return id;
450
513
  }
451
- let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
452
- if ($.$mol_jsx_prefix) {
453
- const prefix_ext = $.$mol_jsx_prefix;
454
- const booked_ext = $.$mol_jsx_booked;
455
- const crumbs_ext = $.$mol_jsx_crumbs;
456
- for (const field in props) {
457
- const func = props[field];
458
- if (typeof func !== 'function')
459
- continue;
460
- const wrapper = function (...args) {
461
- const prefix = $.$mol_jsx_prefix;
462
- const booked = $.$mol_jsx_booked;
463
- const crumbs = $.$mol_jsx_crumbs;
464
- try {
465
- $.$mol_jsx_prefix = prefix_ext;
466
- $.$mol_jsx_booked = booked_ext;
467
- $.$mol_jsx_crumbs = crumbs_ext;
468
- return func.call(this, ...args);
469
- }
470
- finally {
471
- $.$mol_jsx_prefix = prefix;
472
- $.$mol_jsx_booked = booked;
473
- $.$mol_jsx_crumbs = crumbs;
474
- }
475
- };
476
- $mol_func_name_from(wrapper, func);
477
- props[field] = wrapper;
478
- }
479
- }
480
- if (typeof Elem !== 'string') {
481
- if ('prototype' in Elem) {
482
- const view = node && node[String(Elem)] || new Elem;
483
- Object.assign(view, props);
484
- view[Symbol.toStringTag] = guid;
485
- view.childNodes = childNodes;
486
- if (!view.ownerDocument)
487
- view.ownerDocument = $.$mol_jsx_document;
488
- view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
489
- node = view.valueOf();
490
- node[String(Elem)] = view;
491
- return node;
492
- }
493
- else {
494
- const prefix = $.$mol_jsx_prefix;
495
- const booked = $.$mol_jsx_booked;
496
- const crumbs = $.$mol_jsx_crumbs;
497
- try {
498
- $.$mol_jsx_prefix = guid;
499
- $.$mol_jsx_booked = new Set;
500
- $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
501
- return Elem(props, ...childNodes);
502
- }
503
- finally {
504
- $.$mol_jsx_prefix = prefix;
505
- $.$mol_jsx_booked = booked;
506
- $.$mol_jsx_crumbs = crumbs;
507
- }
508
- }
509
- }
510
- if (!node) {
511
- node = Elem
512
- ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
513
- : $.$mol_jsx_document.createDocumentFragment();
514
- }
515
- $mol_dom_render_children(node, [].concat(...childNodes));
516
- if (!Elem)
517
- return node;
518
- if (guid)
519
- node.id = guid;
520
- for (const key in props) {
521
- if (key === 'id')
522
- continue;
523
- if (typeof props[key] === 'string') {
524
- if (typeof node[key] === 'string')
525
- node[key] = props[key];
526
- node.setAttribute(key, props[key]);
527
- }
528
- else if (props[key] &&
529
- typeof props[key] === 'object' &&
530
- Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
531
- if (typeof node[key] === 'object') {
532
- Object.assign(node[key], props[key]);
533
- continue;
534
- }
535
- }
536
- else {
537
- node[key] = props[key];
538
- }
539
- }
540
- if ($.$mol_jsx_crumbs)
541
- node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
542
- return node;
543
- }
544
- $.$mol_jsx = $mol_jsx;
545
- })($ || ($ = {}));
546
-
547
- ;
548
- "use strict";
549
- var $;
550
- (function ($) {
551
- $.$mol_ambient_ref = Symbol('$mol_ambient_ref');
552
- function $mol_ambient(overrides) {
553
- return Object.setPrototypeOf(overrides, this || $);
554
514
  }
555
- $.$mol_ambient = $mol_ambient;
515
+ $.$mol_guid = $mol_guid;
556
516
  })($ || ($ = {}));
557
517
 
558
518
  ;
559
519
  "use strict";
560
520
  var $;
561
521
  (function ($) {
562
- const instances = new WeakSet();
563
- function $mol_delegate(proto, target) {
564
- const proxy = new Proxy(proto, {
565
- get: (_, field) => {
566
- const obj = target();
567
- let val = Reflect.get(obj, field);
568
- if (typeof val === 'function') {
569
- val = val.bind(obj);
570
- }
571
- return val;
572
- },
573
- has: (_, field) => Reflect.has(target(), field),
574
- set: (_, field, value) => Reflect.set(target(), field, value),
575
- getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
576
- ownKeys: () => Reflect.ownKeys(target()),
577
- getPrototypeOf: () => Reflect.getPrototypeOf(target()),
578
- setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
579
- isExtensible: () => Reflect.isExtensible(target()),
580
- preventExtensions: () => Reflect.preventExtensions(target()),
581
- apply: (_, self, args) => Reflect.apply(target(), self, args),
582
- construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
583
- defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
584
- deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
585
- });
586
- instances.add(proxy);
587
- return proxy;
588
- }
589
- $.$mol_delegate = $mol_delegate;
590
- Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
591
- value: (obj) => instances.has(obj),
592
- });
522
+ let $mol_wire_cursor;
523
+ (function ($mol_wire_cursor) {
524
+ $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
525
+ $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
526
+ $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
527
+ $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
528
+ })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
593
529
  })($ || ($ = {}));
594
530
 
595
531
  ;
596
532
  "use strict";
597
533
  var $;
598
534
  (function ($) {
599
- $.$mol_owning_map = new WeakMap();
600
- function $mol_owning_allow(having) {
601
- try {
602
- if (!having)
603
- return false;
604
- if (typeof having !== 'object' && typeof having !== 'function')
605
- return false;
606
- if (having instanceof $mol_delegate)
607
- return false;
608
- if (typeof having['destructor'] !== 'function')
609
- return false;
610
- return true;
535
+ class $mol_wire_pub extends Object {
536
+ constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
537
+ super();
538
+ this[Symbol.toStringTag] = id;
611
539
  }
612
- catch {
613
- return false;
540
+ [Symbol.toStringTag];
541
+ data = [];
542
+ static get [Symbol.species]() {
543
+ return Array;
614
544
  }
615
- }
616
- $.$mol_owning_allow = $mol_owning_allow;
617
- function $mol_owning_get(having, Owner) {
618
- if (!$mol_owning_allow(having))
619
- return null;
620
- while (true) {
621
- const owner = $.$mol_owning_map.get(having);
622
- if (!owner)
623
- return owner;
624
- if (!Owner)
625
- return owner;
626
- if (owner instanceof Owner)
627
- return owner;
628
- having = owner;
545
+ sub_from = 0;
546
+ get sub_list() {
547
+ const res = [];
548
+ for (let i = this.sub_from; i < this.data.length; i += 2) {
549
+ res.push(this.data[i]);
550
+ }
551
+ return res;
629
552
  }
630
- }
631
- $.$mol_owning_get = $mol_owning_get;
632
- function $mol_owning_check(owner, having) {
633
- if (!$mol_owning_allow(having))
634
- return false;
635
- if ($.$mol_owning_map.get(having) !== owner)
636
- return false;
637
- return true;
638
- }
639
- $.$mol_owning_check = $mol_owning_check;
640
- function $mol_owning_catch(owner, having) {
641
- if (!$mol_owning_allow(having))
642
- return false;
643
- if ($.$mol_owning_map.get(having))
553
+ get sub_empty() {
554
+ return this.sub_from === this.data.length;
555
+ }
556
+ sub_on(sub, pub_pos) {
557
+ const pos = this.data.length;
558
+ this.data.push(sub, pub_pos);
559
+ return pos;
560
+ }
561
+ sub_off(sub_pos) {
562
+ if (!(sub_pos < this.data.length)) {
563
+ $mol_fail(new Error(`Wrong pos ${sub_pos}`));
564
+ }
565
+ const end = this.data.length - 2;
566
+ if (sub_pos !== end) {
567
+ this.peer_move(end, sub_pos);
568
+ }
569
+ this.data.length = end;
570
+ if (end === this.sub_from)
571
+ this.reap();
572
+ }
573
+ reap() { }
574
+ promote() {
575
+ $mol_wire_auto()?.track_next(this);
576
+ }
577
+ fresh() { }
578
+ complete() { }
579
+ get incompleted() {
644
580
  return false;
645
- $.$mol_owning_map.set(having, owner);
646
- return true;
581
+ }
582
+ emit(quant = $mol_wire_cursor.stale) {
583
+ for (let i = this.sub_from; i < this.data.length; i += 2) {
584
+ ;
585
+ this.data[i].absorb(quant, this.data[i + 1]);
586
+ }
587
+ }
588
+ peer_move(from_pos, to_pos) {
589
+ const peer = this.data[from_pos];
590
+ const self_pos = this.data[from_pos + 1];
591
+ this.data[to_pos] = peer;
592
+ this.data[to_pos + 1] = self_pos;
593
+ peer.peer_repos(self_pos, to_pos);
594
+ }
595
+ peer_repos(peer_pos, self_pos) {
596
+ this.data[peer_pos + 1] = self_pos;
597
+ }
647
598
  }
648
- $.$mol_owning_catch = $mol_owning_catch;
599
+ $.$mol_wire_pub = $mol_wire_pub;
649
600
  })($ || ($ = {}));
650
601
 
602
+ ;
603
+ "use strict";
604
+
651
605
  ;
652
606
  "use strict";
653
607
  var $;
654
608
  (function ($) {
655
- function $mol_fail_hidden(error) {
656
- throw error;
609
+ $.$mol_wire_auto_sub = null;
610
+ function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
611
+ return $.$mol_wire_auto_sub = next;
657
612
  }
658
- $.$mol_fail_hidden = $mol_fail_hidden;
659
- })($ || ($ = {}));
660
-
661
- ;
662
- "use strict";
663
-
664
- ;
665
- "use strict";
666
- var $;
667
- (function ($) {
668
- class $mol_object2 {
669
- static $ = $;
670
- [Symbol.toStringTag];
671
- [$mol_ambient_ref] = null;
672
- get $() {
673
- if (this[$mol_ambient_ref])
674
- return this[$mol_ambient_ref];
675
- const owner = $mol_owning_get(this);
676
- return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
677
- }
678
- set $(next) {
679
- if (this[$mol_ambient_ref])
680
- $mol_fail_hidden(new Error('Context already defined'));
681
- this[$mol_ambient_ref] = next;
682
- }
683
- static create(init) {
684
- const obj = new this;
685
- if (init)
686
- init(obj);
687
- return obj;
688
- }
689
- static [Symbol.toPrimitive]() {
690
- return this.toString();
691
- }
692
- static toString() {
693
- return this[Symbol.toStringTag] || this.$.$mol_func_name(this);
694
- }
695
- static toJSON() {
696
- return this.toString();
697
- }
698
- destructor() { }
699
- static destructor() { }
700
- toString() {
701
- return this[Symbol.toStringTag] || this.constructor.name + '<>';
702
- }
703
- }
704
- $.$mol_object2 = $mol_object2;
705
- })($ || ($ = {}));
706
-
707
- ;
708
- "use strict";
709
- var $;
710
- (function ($_1) {
711
- let $$;
712
- (function ($$) {
713
- let $;
714
- })($$ = $_1.$$ || ($_1.$$ = {}));
715
- $_1.$mol_object_field = Symbol('$mol_object_field');
716
- class $mol_object extends $mol_object2 {
717
- static make(config) {
718
- return super.create(obj => {
719
- for (let key in config)
720
- obj[key] = config[key];
721
- });
722
- }
723
- }
724
- $_1.$mol_object = $mol_object;
725
- })($ || ($ = {}));
726
-
727
- ;
728
- "use strict";
729
- var $;
730
- (function ($) {
731
- function $mol_guid(length = 8, exists = () => false) {
732
- for (;;) {
733
- let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
734
- if (exists(id))
735
- continue;
736
- return id;
737
- }
738
- }
739
- $.$mol_guid = $mol_guid;
740
- })($ || ($ = {}));
741
-
742
- ;
743
- "use strict";
744
- var $;
745
- (function ($) {
746
- let $mol_wire_cursor;
747
- (function ($mol_wire_cursor) {
748
- $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
749
- $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
750
- $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
751
- $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
752
- })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
753
- })($ || ($ = {}));
754
-
755
- ;
756
- "use strict";
757
- var $;
758
- (function ($) {
759
- class $mol_wire_pub extends Object {
760
- constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
761
- super();
762
- this[Symbol.toStringTag] = id;
763
- }
764
- [Symbol.toStringTag];
765
- data = [];
766
- static get [Symbol.species]() {
767
- return Array;
768
- }
769
- sub_from = 0;
770
- get sub_list() {
771
- const res = [];
772
- for (let i = this.sub_from; i < this.data.length; i += 2) {
773
- res.push(this.data[i]);
774
- }
775
- return res;
776
- }
777
- get sub_empty() {
778
- return this.sub_from === this.data.length;
779
- }
780
- sub_on(sub, pub_pos) {
781
- const pos = this.data.length;
782
- this.data.push(sub, pub_pos);
783
- return pos;
784
- }
785
- sub_off(sub_pos) {
786
- if (!(sub_pos < this.data.length)) {
787
- $mol_fail(new Error(`Wrong pos ${sub_pos}`));
788
- }
789
- const end = this.data.length - 2;
790
- if (sub_pos !== end) {
791
- this.peer_move(end, sub_pos);
792
- }
793
- this.data.length = end;
794
- if (end === this.sub_from)
795
- this.reap();
796
- }
797
- reap() { }
798
- promote() {
799
- $mol_wire_auto()?.track_next(this);
800
- }
801
- fresh() { }
802
- complete() { }
803
- get incompleted() {
804
- return false;
805
- }
806
- emit(quant = $mol_wire_cursor.stale) {
807
- for (let i = this.sub_from; i < this.data.length; i += 2) {
808
- ;
809
- this.data[i].absorb(quant, this.data[i + 1]);
810
- }
811
- }
812
- peer_move(from_pos, to_pos) {
813
- const peer = this.data[from_pos];
814
- const self_pos = this.data[from_pos + 1];
815
- this.data[to_pos] = peer;
816
- this.data[to_pos + 1] = self_pos;
817
- peer.peer_repos(self_pos, to_pos);
818
- }
819
- peer_repos(peer_pos, self_pos) {
820
- this.data[peer_pos + 1] = self_pos;
821
- }
822
- }
823
- $.$mol_wire_pub = $mol_wire_pub;
824
- })($ || ($ = {}));
825
-
826
- ;
827
- "use strict";
828
-
829
- ;
830
- "use strict";
831
- var $;
832
- (function ($) {
833
- $.$mol_wire_auto_sub = null;
834
- function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
835
- return $.$mol_wire_auto_sub = next;
836
- }
837
- $.$mol_wire_auto = $mol_wire_auto;
838
- $.$mol_wire_affected = [];
613
+ $.$mol_wire_auto = $mol_wire_auto;
614
+ $.$mol_wire_affected = [];
839
615
  })($ || ($ = {}));
840
616
 
841
617
  ;
@@ -1621,516 +1397,1170 @@ var $;
1621
1397
  else
1622
1398
  result = false;
1623
1399
  }
1624
- finally {
1625
- left_cache.set(right, result);
1400
+ finally {
1401
+ left_cache.set(right, result);
1402
+ }
1403
+ return result;
1404
+ }
1405
+ $.$mol_compare_deep = $mol_compare_deep;
1406
+ function compare_array(left, right) {
1407
+ const len = left.length;
1408
+ if (len !== right.length)
1409
+ return false;
1410
+ for (let i = 0; i < len; ++i) {
1411
+ if (!$mol_compare_deep(left[i], right[i]))
1412
+ return false;
1413
+ }
1414
+ return true;
1415
+ }
1416
+ function compare_buffer(left, right) {
1417
+ const len = left.byteLength;
1418
+ if (len !== right.byteLength)
1419
+ return false;
1420
+ if (left instanceof DataView)
1421
+ return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, right.byteOffset, right.byteLength));
1422
+ for (let i = 0; i < len; ++i) {
1423
+ if (left[i] !== right[i])
1424
+ return false;
1425
+ }
1426
+ return true;
1427
+ }
1428
+ function compare_iterator(left, right) {
1429
+ while (true) {
1430
+ const left_next = left.next();
1431
+ const right_next = right.next();
1432
+ if (left_next.done !== right_next.done)
1433
+ return false;
1434
+ if (left_next.done)
1435
+ break;
1436
+ if (!$mol_compare_deep(left_next.value, right_next.value))
1437
+ return false;
1438
+ }
1439
+ return true;
1440
+ }
1441
+ function compare_set(left, right) {
1442
+ if (left.size !== right.size)
1443
+ return false;
1444
+ return compare_iterator(left.values(), right.values());
1445
+ }
1446
+ function compare_map(left, right) {
1447
+ if (left.size !== right.size)
1448
+ return false;
1449
+ return compare_iterator(left.keys(), right.keys())
1450
+ && compare_iterator(left.values(), right.values());
1451
+ }
1452
+ function compare_pojo(left, right) {
1453
+ const left_keys = Object.getOwnPropertyNames(left);
1454
+ const right_keys = Object.getOwnPropertyNames(right);
1455
+ if (!compare_array(left_keys, right_keys))
1456
+ return false;
1457
+ for (let key of left_keys) {
1458
+ if (!$mol_compare_deep(left[key], right[key]))
1459
+ return false;
1460
+ }
1461
+ const left_syms = Object.getOwnPropertySymbols(left);
1462
+ const right_syms = Object.getOwnPropertySymbols(right);
1463
+ if (!compare_array(left_syms, right_syms))
1464
+ return false;
1465
+ for (let key of left_syms) {
1466
+ if (!$mol_compare_deep(left[key], right[key]))
1467
+ return false;
1468
+ }
1469
+ return true;
1470
+ }
1471
+ function compare_primitive(left, right) {
1472
+ return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
1473
+ }
1474
+ })($ || ($ = {}));
1475
+
1476
+ ;
1477
+ "use strict";
1478
+ var $;
1479
+ (function ($) {
1480
+ function $mol_log3_area_lazy(event) {
1481
+ const self = this.$;
1482
+ const stack = self.$mol_log3_stack;
1483
+ const deep = stack.length;
1484
+ let logged = false;
1485
+ stack.push(() => {
1486
+ logged = true;
1487
+ self.$mol_log3_area.call(self, event);
1488
+ });
1489
+ return () => {
1490
+ if (logged)
1491
+ self.console.groupEnd();
1492
+ if (stack.length > deep)
1493
+ stack.length = deep;
1494
+ };
1495
+ }
1496
+ $.$mol_log3_area_lazy = $mol_log3_area_lazy;
1497
+ $.$mol_log3_stack = [];
1498
+ })($ || ($ = {}));
1499
+
1500
+ ;
1501
+ "use strict";
1502
+
1503
+ ;
1504
+ "use strict";
1505
+ var $;
1506
+ (function ($) {
1507
+ function $mol_log3_web_make(level, color) {
1508
+ return function $mol_log3_logger(event) {
1509
+ const pending = this.$mol_log3_stack.pop();
1510
+ if (pending)
1511
+ pending();
1512
+ let tpl = '%c';
1513
+ const chunks = Object.entries(event);
1514
+ for (let i = 0; i < chunks.length; ++i) {
1515
+ tpl += (typeof chunks[i][1] === 'string') ? '%s: %s\n' : '%s: %o\n';
1516
+ }
1517
+ const style = `color:${color};font-weight:bolder`;
1518
+ this.console[level](tpl.trim(), style, ...[].concat(...chunks));
1519
+ const self = this;
1520
+ return () => self.console.groupEnd();
1521
+ };
1522
+ }
1523
+ $.$mol_log3_web_make = $mol_log3_web_make;
1524
+ $.$mol_log3_come = $mol_log3_web_make('info', 'royalblue');
1525
+ $.$mol_log3_done = $mol_log3_web_make('info', 'forestgreen');
1526
+ $.$mol_log3_fail = $mol_log3_web_make('error', 'orangered');
1527
+ $.$mol_log3_warn = $mol_log3_web_make('warn', 'goldenrod');
1528
+ $.$mol_log3_rise = $mol_log3_web_make('log', 'magenta');
1529
+ $.$mol_log3_area = $mol_log3_web_make('group', 'cyan');
1530
+ })($ || ($ = {}));
1531
+
1532
+ ;
1533
+ "use strict";
1534
+ var $;
1535
+ (function ($) {
1536
+ class $mol_wire_task extends $mol_wire_fiber {
1537
+ static getter(task) {
1538
+ return function $mol_wire_task_get(host, args) {
1539
+ const sub = $mol_wire_auto();
1540
+ const existen = sub?.track_next();
1541
+ let cause = '';
1542
+ reuse: if (existen) {
1543
+ if (!existen.temp)
1544
+ break reuse;
1545
+ if (existen.task !== task) {
1546
+ cause = 'task';
1547
+ break reuse;
1548
+ }
1549
+ if (existen.host !== host) {
1550
+ cause = 'host';
1551
+ break reuse;
1552
+ }
1553
+ if (!$mol_compare_deep(existen.args, args)) {
1554
+ cause = 'args';
1555
+ break reuse;
1556
+ }
1557
+ return existen;
1558
+ }
1559
+ const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>');
1560
+ const next = new $mol_wire_task(key, task, host, args);
1561
+ if (existen?.temp) {
1562
+ $$.$mol_log3_warn({
1563
+ place: '$mol_wire_task',
1564
+ message: `Different ${cause} on restart`,
1565
+ sub,
1566
+ prev: existen,
1567
+ next,
1568
+ hint: 'Maybe required additional memoization',
1569
+ });
1570
+ }
1571
+ return next;
1572
+ };
1573
+ }
1574
+ get temp() {
1575
+ return true;
1576
+ }
1577
+ complete() {
1578
+ if ($mol_promise_like(this.cache))
1579
+ return;
1580
+ this.destructor();
1581
+ }
1582
+ put(next) {
1583
+ const prev = this.cache;
1584
+ this.cache = next;
1585
+ if ($mol_promise_like(next)) {
1586
+ this.cursor = $mol_wire_cursor.fresh;
1587
+ if (next !== prev)
1588
+ this.emit();
1589
+ if ($mol_owning_catch(this, next)) {
1590
+ try {
1591
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1592
+ }
1593
+ catch {
1594
+ Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1595
+ }
1596
+ }
1597
+ return next;
1598
+ }
1599
+ this.cursor = $mol_wire_cursor.final;
1600
+ if (this.sub_empty)
1601
+ this.destructor();
1602
+ else if (next !== prev)
1603
+ this.emit();
1604
+ return next;
1605
+ }
1606
+ }
1607
+ $.$mol_wire_task = $mol_wire_task;
1608
+ })($ || ($ = {}));
1609
+
1610
+ ;
1611
+ "use strict";
1612
+ var $;
1613
+ (function ($) {
1614
+ function $mol_wire_method(host, field, descr) {
1615
+ if (!descr)
1616
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
1617
+ const orig = descr?.value ?? host[field];
1618
+ const sup = Reflect.getPrototypeOf(host);
1619
+ if (typeof sup[field] === 'function') {
1620
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
1621
+ }
1622
+ const temp = $mol_wire_task.getter(orig);
1623
+ const value = function (...args) {
1624
+ const fiber = temp(this ?? null, args);
1625
+ return fiber.sync();
1626
+ };
1627
+ Object.defineProperty(value, 'name', { value: orig.name + ' ' });
1628
+ Object.assign(value, { orig });
1629
+ const descr2 = { ...descr, value };
1630
+ Reflect.defineProperty(host, field, descr2);
1631
+ return descr2;
1632
+ }
1633
+ $.$mol_wire_method = $mol_wire_method;
1634
+ })($ || ($ = {}));
1635
+
1636
+ ;
1637
+ "use strict";
1638
+
1639
+ ;
1640
+ "use strict";
1641
+
1642
+ ;
1643
+ "use strict";
1644
+ var $;
1645
+ (function ($) {
1646
+ const catched = new WeakMap();
1647
+ function $mol_fail_catch(error) {
1648
+ if (typeof error !== 'object')
1649
+ return false;
1650
+ if ($mol_promise_like(error))
1651
+ $mol_fail_hidden(error);
1652
+ if (catched.get(error))
1653
+ return false;
1654
+ catched.set(error, true);
1655
+ return true;
1656
+ }
1657
+ $.$mol_fail_catch = $mol_fail_catch;
1658
+ })($ || ($ = {}));
1659
+
1660
+ ;
1661
+ "use strict";
1662
+ var $;
1663
+ (function ($) {
1664
+ let error;
1665
+ let result;
1666
+ let handler;
1667
+ function $mol_try(handler2) {
1668
+ handler = handler2;
1669
+ error = undefined;
1670
+ result = undefined;
1671
+ window.dispatchEvent(new Event('$mol_try'));
1672
+ const error2 = error;
1673
+ const result2 = result;
1674
+ error = undefined;
1675
+ result = undefined;
1676
+ return error2 || result2;
1677
+ }
1678
+ $.$mol_try = $mol_try;
1679
+ self.addEventListener('$mol_try', (event) => {
1680
+ result = handler();
1681
+ }, true);
1682
+ self.addEventListener('error', (event) => {
1683
+ error = event.error;
1684
+ }, true);
1685
+ })($ || ($ = {}));
1686
+
1687
+ ;
1688
+ "use strict";
1689
+ var $;
1690
+ (function ($) {
1691
+ function $mol_fail_log(error) {
1692
+ if ($mol_promise_like(error))
1693
+ return false;
1694
+ if (!$mol_fail_catch(error))
1695
+ return false;
1696
+ $mol_try(() => { $mol_fail_hidden(error); });
1697
+ return true;
1698
+ }
1699
+ $.$mol_fail_log = $mol_fail_log;
1700
+ })($ || ($ = {}));
1701
+
1702
+ ;
1703
+ "use strict";
1704
+ var $;
1705
+ (function ($) {
1706
+ class $mol_wire_atom extends $mol_wire_fiber {
1707
+ static solo(host, task) {
1708
+ const field = task.name + '()';
1709
+ const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1710
+ if (existen)
1711
+ return existen;
1712
+ const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
1713
+ const key = prefix + ('.' + task.name + '<>');
1714
+ const fiber = new $mol_wire_atom(key, task, host, []);
1715
+ (host ?? task)[field] = fiber;
1716
+ return fiber;
1717
+ }
1718
+ static plex(host, task, key) {
1719
+ const field = task.name + '()';
1720
+ let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1721
+ const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
1722
+ const key_str = $mol_key(key);
1723
+ if (dict) {
1724
+ const existen = dict.get(key_str);
1725
+ if (existen)
1726
+ return existen;
1727
+ }
1728
+ else {
1729
+ dict = (host ?? task)[field] = new Map();
1730
+ }
1731
+ const id = prefix + ('.' + task.name) + ('<' + key_str.replace(/^"|"$/g, "'") + '>');
1732
+ const fiber = new $mol_wire_atom(id, task, host, [key]);
1733
+ dict.set(key_str, fiber);
1734
+ return fiber;
1735
+ }
1736
+ static watching = new Set();
1737
+ static watcher = null;
1738
+ static watch() {
1739
+ $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
1740
+ for (const atom of $mol_wire_atom.watching) {
1741
+ if (atom.cursor === $mol_wire_cursor.final) {
1742
+ $mol_wire_atom.watching.delete(atom);
1743
+ }
1744
+ else {
1745
+ atom.cursor = $mol_wire_cursor.stale;
1746
+ atom.fresh();
1747
+ }
1748
+ }
1749
+ }
1750
+ watch() {
1751
+ if (!$mol_wire_atom.watcher) {
1752
+ $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
1753
+ }
1754
+ $mol_wire_atom.watching.add(this);
1755
+ }
1756
+ resync(args) {
1757
+ return this.put(this.task.call(this.host, ...args));
1758
+ }
1759
+ once() {
1760
+ return this.sync();
1761
+ }
1762
+ channel() {
1763
+ return Object.assign((next) => {
1764
+ if (next !== undefined)
1765
+ return this.resync([...this.args, next]);
1766
+ if (!$mol_wire_fiber.warm)
1767
+ return this.result();
1768
+ if ($mol_wire_auto()?.temp) {
1769
+ return this.once();
1770
+ }
1771
+ else {
1772
+ return this.sync();
1773
+ }
1774
+ }, { atom: this });
1775
+ }
1776
+ destructor() {
1777
+ super.destructor();
1778
+ if (this.pub_from === 0) {
1779
+ ;
1780
+ (this.host ?? this.task)[this.field()] = null;
1781
+ }
1782
+ else {
1783
+ ;
1784
+ (this.host ?? this.task)[this.field()].delete($mol_key(this.args[0]));
1785
+ }
1786
+ }
1787
+ put(next) {
1788
+ const prev = this.cache;
1789
+ update: if (next !== prev) {
1790
+ try {
1791
+ if ($mol_compare_deep(prev, next))
1792
+ break update;
1793
+ }
1794
+ catch (error) {
1795
+ $mol_fail_log(error);
1796
+ }
1797
+ if ($mol_owning_check(this, prev)) {
1798
+ prev.destructor();
1799
+ }
1800
+ if ($mol_owning_catch(this, next)) {
1801
+ try {
1802
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1803
+ }
1804
+ catch {
1805
+ Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1806
+ }
1807
+ }
1808
+ if (!this.sub_empty)
1809
+ this.emit();
1810
+ }
1811
+ this.cache = next;
1812
+ this.cursor = $mol_wire_cursor.fresh;
1813
+ if ($mol_promise_like(next))
1814
+ return next;
1815
+ this.complete_pubs();
1816
+ return next;
1817
+ }
1818
+ }
1819
+ __decorate([
1820
+ $mol_wire_method
1821
+ ], $mol_wire_atom.prototype, "resync", null);
1822
+ __decorate([
1823
+ $mol_wire_method
1824
+ ], $mol_wire_atom.prototype, "once", null);
1825
+ $.$mol_wire_atom = $mol_wire_atom;
1826
+ })($ || ($ = {}));
1827
+
1828
+ ;
1829
+ "use strict";
1830
+ var $;
1831
+ (function ($) {
1832
+ function $mol_wire_solo(host, field, descr) {
1833
+ if (!descr)
1834
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
1835
+ const orig = descr?.value ?? host[field];
1836
+ const sup = Reflect.getPrototypeOf(host);
1837
+ if (typeof sup[field] === 'function') {
1838
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
1839
+ }
1840
+ const descr2 = {
1841
+ ...descr,
1842
+ value: function (...args) {
1843
+ let atom = $mol_wire_atom.solo(this, orig);
1844
+ if ((args.length === 0) || (args[0] === undefined)) {
1845
+ if (!$mol_wire_fiber.warm)
1846
+ return atom.result();
1847
+ if ($mol_wire_auto()?.temp) {
1848
+ return atom.once();
1849
+ }
1850
+ else {
1851
+ return atom.sync();
1852
+ }
1853
+ }
1854
+ return atom.resync(args);
1855
+ }
1856
+ };
1857
+ Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
1858
+ Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
1859
+ Object.assign(descr2.value, { orig });
1860
+ Reflect.defineProperty(host, field, descr2);
1861
+ return descr2;
1862
+ }
1863
+ $.$mol_wire_solo = $mol_wire_solo;
1864
+ })($ || ($ = {}));
1865
+
1866
+ ;
1867
+ "use strict";
1868
+ var $;
1869
+ (function ($) {
1870
+ function $mol_wire_plex(host, field, descr) {
1871
+ if (!descr)
1872
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
1873
+ const orig = descr?.value ?? host[field];
1874
+ const sup = Reflect.getPrototypeOf(host);
1875
+ if (typeof sup[field] === 'function') {
1876
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
1877
+ }
1878
+ const descr2 = {
1879
+ ...descr,
1880
+ value: function (...args) {
1881
+ let atom = $mol_wire_atom.plex(this, orig, args[0]);
1882
+ if ((args.length === 1) || (args[1] === undefined)) {
1883
+ if (!$mol_wire_fiber.warm)
1884
+ return atom.result();
1885
+ if ($mol_wire_auto()?.temp) {
1886
+ return atom.once();
1887
+ }
1888
+ else {
1889
+ return atom.sync();
1890
+ }
1891
+ }
1892
+ return atom.resync(args);
1893
+ }
1894
+ };
1895
+ Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
1896
+ Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
1897
+ Object.assign(descr2.value, { orig });
1898
+ Reflect.defineProperty(host, field, descr2);
1899
+ return descr2;
1900
+ }
1901
+ $.$mol_wire_plex = $mol_wire_plex;
1902
+ })($ || ($ = {}));
1903
+
1904
+ ;
1905
+ "use strict";
1906
+ var $;
1907
+ (function ($) {
1908
+ $.$mol_mem = $mol_wire_solo;
1909
+ $.$mol_mem_key = $mol_wire_plex;
1910
+ })($ || ($ = {}));
1911
+
1912
+ ;
1913
+ "use strict";
1914
+ var $;
1915
+ (function ($) {
1916
+ $.$mol_action = $mol_wire_method;
1917
+ })($ || ($ = {}));
1918
+
1919
+ ;
1920
+ "use strict";
1921
+ var $;
1922
+ (function ($) {
1923
+ class $mol_state_arg extends $mol_object {
1924
+ prefix;
1925
+ static href(next) {
1926
+ if (next === undefined) {
1927
+ next = $mol_dom_context.location.href;
1928
+ }
1929
+ else if (!/^about:srcdoc/.test(next)) {
1930
+ new $mol_after_frame(() => {
1931
+ const next = this.href();
1932
+ const prev = $mol_dom_context.location.href;
1933
+ if (next === prev)
1934
+ return;
1935
+ const history = $mol_dom_context.history;
1936
+ history.replaceState(history.state, $mol_dom_context.document.title, next);
1937
+ });
1938
+ }
1939
+ if ($mol_dom_context.parent !== $mol_dom_context.self) {
1940
+ $mol_dom_context.parent.postMessage(['hashchange', next], '*');
1941
+ }
1942
+ return next;
1943
+ }
1944
+ static href_normal() {
1945
+ return this.link({});
1946
+ }
1947
+ static href_absolute() {
1948
+ return new URL(this.href(), $mol_dom_context.location.href).toString();
1949
+ }
1950
+ static dict(next) {
1951
+ var href = this.href(next && this.make_link(next)).split(/#!?/)[1] || '';
1952
+ var chunks = href.split(this.separator);
1953
+ var params = {};
1954
+ chunks.forEach(chunk => {
1955
+ if (!chunk)
1956
+ return;
1957
+ var vals = chunk.split('=').map(decodeURIComponent);
1958
+ params[vals.shift()] = vals.join('=');
1959
+ });
1960
+ return params;
1961
+ }
1962
+ static dict_cut(except) {
1963
+ const dict = this.dict();
1964
+ const cut = {};
1965
+ for (const key in dict) {
1966
+ if (except.indexOf(key) >= 0)
1967
+ break;
1968
+ cut[key] = dict[key];
1969
+ }
1970
+ return cut;
1971
+ }
1972
+ static value(key, next) {
1973
+ const nextDict = (next === void 0) ? void 0 : { ...this.dict(), [key]: next };
1974
+ const next2 = this.dict(nextDict)[key];
1975
+ return (next2 == null) ? null : next2;
1626
1976
  }
1627
- return result;
1628
- }
1629
- $.$mol_compare_deep = $mol_compare_deep;
1630
- function compare_array(left, right) {
1631
- const len = left.length;
1632
- if (len !== right.length)
1633
- return false;
1634
- for (let i = 0; i < len; ++i) {
1635
- if (!$mol_compare_deep(left[i], right[i]))
1636
- return false;
1977
+ static link(next) {
1978
+ return this.make_link({
1979
+ ...this.dict_cut(Object.keys(next)),
1980
+ ...next,
1981
+ });
1637
1982
  }
1638
- return true;
1639
- }
1640
- function compare_buffer(left, right) {
1641
- const len = left.byteLength;
1642
- if (len !== right.byteLength)
1643
- return false;
1644
- if (left instanceof DataView)
1645
- return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, right.byteOffset, right.byteLength));
1646
- for (let i = 0; i < len; ++i) {
1647
- if (left[i] !== right[i])
1648
- return false;
1983
+ static prolog = '!';
1984
+ static separator = '/';
1985
+ static make_link(next) {
1986
+ const chunks = [];
1987
+ for (let key in next) {
1988
+ if (null == next[key])
1989
+ continue;
1990
+ const val = next[key];
1991
+ chunks.push([key].concat(val ? [val] : []).map(this.encode).join('='));
1992
+ }
1993
+ return new URL('#' + this.prolog + chunks.join(this.separator), this.href_absolute()).toString();
1649
1994
  }
1650
- return true;
1651
- }
1652
- function compare_iterator(left, right) {
1653
- while (true) {
1654
- const left_next = left.next();
1655
- const right_next = right.next();
1656
- if (left_next.done !== right_next.done)
1657
- return false;
1658
- if (left_next.done)
1659
- break;
1660
- if (!$mol_compare_deep(left_next.value, right_next.value))
1661
- return false;
1995
+ static commit() {
1996
+ $mol_dom.history.pushState($mol_dom.history.state, $mol_dom.document.title, this.href());
1997
+ }
1998
+ static go(next) {
1999
+ $mol_dom_context.location.href = this.link(next);
2000
+ }
2001
+ static encode(str) {
2002
+ return encodeURIComponent(str).replace(/\(/g, '%28').replace(/\)/g, '%29');
2003
+ }
2004
+ constructor(prefix = '') {
2005
+ super();
2006
+ this.prefix = prefix;
2007
+ }
2008
+ value(key, next) {
2009
+ return this.constructor.value(this.prefix + key, next);
2010
+ }
2011
+ sub(postfix) {
2012
+ return new this.constructor(this.prefix + postfix + '.');
2013
+ }
2014
+ link(next) {
2015
+ var prefix = this.prefix;
2016
+ var dict = {};
2017
+ for (var key in next) {
2018
+ dict[prefix + key] = next[key];
2019
+ }
2020
+ return this.constructor.link(dict);
1662
2021
  }
1663
- return true;
1664
- }
1665
- function compare_set(left, right) {
1666
- if (left.size !== right.size)
1667
- return false;
1668
- return compare_iterator(left.values(), right.values());
1669
2022
  }
1670
- function compare_map(left, right) {
1671
- if (left.size !== right.size)
1672
- return false;
1673
- return compare_iterator(left.keys(), right.keys())
1674
- && compare_iterator(left.values(), right.values());
2023
+ __decorate([
2024
+ $mol_mem
2025
+ ], $mol_state_arg, "href", null);
2026
+ __decorate([
2027
+ $mol_mem
2028
+ ], $mol_state_arg, "href_normal", null);
2029
+ __decorate([
2030
+ $mol_mem
2031
+ ], $mol_state_arg, "href_absolute", null);
2032
+ __decorate([
2033
+ $mol_mem
2034
+ ], $mol_state_arg, "dict", null);
2035
+ __decorate([
2036
+ $mol_mem_key
2037
+ ], $mol_state_arg, "dict_cut", null);
2038
+ __decorate([
2039
+ $mol_mem_key
2040
+ ], $mol_state_arg, "value", null);
2041
+ __decorate([
2042
+ $mol_mem_key
2043
+ ], $mol_state_arg, "make_link", null);
2044
+ __decorate([
2045
+ $mol_action
2046
+ ], $mol_state_arg, "commit", null);
2047
+ __decorate([
2048
+ $mol_action
2049
+ ], $mol_state_arg, "go", null);
2050
+ $.$mol_state_arg = $mol_state_arg;
2051
+ function $mol_state_arg_change() {
2052
+ $mol_state_arg.href($mol_dom_context.location.href);
1675
2053
  }
1676
- function compare_pojo(left, right) {
1677
- const left_keys = Object.getOwnPropertyNames(left);
1678
- const right_keys = Object.getOwnPropertyNames(right);
1679
- if (!compare_array(left_keys, right_keys))
1680
- return false;
1681
- for (let key of left_keys) {
1682
- if (!$mol_compare_deep(left[key], right[key]))
1683
- return false;
1684
- }
1685
- const left_syms = Object.getOwnPropertySymbols(left);
1686
- const right_syms = Object.getOwnPropertySymbols(right);
1687
- if (!compare_array(left_syms, right_syms))
1688
- return false;
1689
- for (let key of left_syms) {
1690
- if (!$mol_compare_deep(left[key], right[key]))
1691
- return false;
2054
+ self.addEventListener('hashchange', $mol_state_arg_change);
2055
+ })($ || ($ = {}));
2056
+
2057
+ ;
2058
+ "use strict";
2059
+ var $;
2060
+ (function ($) {
2061
+ class $mol_media extends $mol_object2 {
2062
+ static match(query, next) {
2063
+ if (next !== undefined)
2064
+ return next;
2065
+ const res = this.$.$mol_dom_context.matchMedia?.(query) ?? {};
2066
+ res.onchange = () => this.match(query, res.matches);
2067
+ return res.matches;
1692
2068
  }
1693
- return true;
1694
2069
  }
1695
- function compare_primitive(left, right) {
1696
- return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
2070
+ __decorate([
2071
+ $mol_mem_key
2072
+ ], $mol_media, "match", null);
2073
+ $.$mol_media = $mol_media;
2074
+ })($ || ($ = {}));
2075
+
2076
+ ;
2077
+ "use strict";
2078
+ var $;
2079
+ (function ($) {
2080
+ function $mol_wire_solid() {
2081
+ let current = $mol_wire_auto();
2082
+ if (current.temp)
2083
+ current = current.host;
2084
+ if (current.reap !== nothing) {
2085
+ current?.sub_on(sub, sub.data.length);
2086
+ }
2087
+ current.reap = nothing;
1697
2088
  }
2089
+ $.$mol_wire_solid = $mol_wire_solid;
2090
+ const nothing = () => { };
2091
+ const sub = new $mol_wire_pub_sub;
1698
2092
  })($ || ($ = {}));
1699
2093
 
1700
2094
  ;
1701
2095
  "use strict";
1702
2096
  var $;
1703
2097
  (function ($) {
1704
- function $mol_log3_area_lazy(event) {
1705
- const self = this.$;
1706
- const stack = self.$mol_log3_stack;
1707
- const deep = stack.length;
1708
- let logged = false;
1709
- stack.push(() => {
1710
- logged = true;
1711
- self.$mol_log3_area.call(self, event);
1712
- });
1713
- return () => {
1714
- if (logged)
1715
- self.console.groupEnd();
1716
- if (stack.length > deep)
1717
- stack.length = deep;
1718
- };
2098
+ $.$mol_mem_persist = $mol_wire_solid;
2099
+ })($ || ($ = {}));
2100
+
2101
+ ;
2102
+ "use strict";
2103
+ var $;
2104
+ (function ($) {
2105
+ function $mol_wire_probe(task, def) {
2106
+ const warm = $mol_wire_fiber.warm;
2107
+ try {
2108
+ $mol_wire_fiber.warm = false;
2109
+ const res = task();
2110
+ if (res === undefined)
2111
+ return def;
2112
+ return res;
2113
+ }
2114
+ finally {
2115
+ $mol_wire_fiber.warm = warm;
2116
+ }
1719
2117
  }
1720
- $.$mol_log3_area_lazy = $mol_log3_area_lazy;
1721
- $.$mol_log3_stack = [];
2118
+ $.$mol_wire_probe = $mol_wire_probe;
1722
2119
  })($ || ($ = {}));
1723
2120
 
1724
2121
  ;
1725
2122
  "use strict";
2123
+ var $;
2124
+ (function ($) {
2125
+ $.$mol_mem_cached = $mol_wire_probe;
2126
+ })($ || ($ = {}));
1726
2127
 
1727
2128
  ;
1728
2129
  "use strict";
1729
2130
  var $;
1730
2131
  (function ($) {
1731
- function $mol_log3_web_make(level, color) {
1732
- return function $mol_log3_logger(event) {
1733
- const pending = this.$mol_log3_stack.pop();
1734
- if (pending)
1735
- pending();
1736
- let tpl = '%c';
1737
- const chunks = Object.entries(event);
1738
- for (let i = 0; i < chunks.length; ++i) {
1739
- tpl += (typeof chunks[i][1] === 'string') ? '%s: %s\n' : '%s: %o\n';
1740
- }
1741
- const style = `color:${color};font-weight:bolder`;
1742
- this.console[level](tpl.trim(), style, ...[].concat(...chunks));
1743
- const self = this;
1744
- return () => self.console.groupEnd();
2132
+ const factories = new WeakMap();
2133
+ function factory(val) {
2134
+ let make = factories.get(val);
2135
+ if (make)
2136
+ return make;
2137
+ make = $mol_func_name_from((...args) => new val(...args), val);
2138
+ factories.set(val, make);
2139
+ return make;
2140
+ }
2141
+ const getters = new WeakMap();
2142
+ function get_prop(host, field) {
2143
+ let props = getters.get(host);
2144
+ let get_val = props?.[field];
2145
+ if (get_val)
2146
+ return get_val;
2147
+ get_val = (next) => {
2148
+ if (next !== undefined)
2149
+ host[field] = next;
2150
+ return host[field];
1745
2151
  };
2152
+ Object.defineProperty(get_val, 'name', { value: field });
2153
+ if (!props) {
2154
+ props = {};
2155
+ getters.set(host, props);
2156
+ }
2157
+ props[field] = get_val;
2158
+ return get_val;
1746
2159
  }
1747
- $.$mol_log3_web_make = $mol_log3_web_make;
1748
- $.$mol_log3_come = $mol_log3_web_make('info', 'royalblue');
1749
- $.$mol_log3_done = $mol_log3_web_make('info', 'forestgreen');
1750
- $.$mol_log3_fail = $mol_log3_web_make('error', 'orangered');
1751
- $.$mol_log3_warn = $mol_log3_web_make('warn', 'goldenrod');
1752
- $.$mol_log3_rise = $mol_log3_web_make('log', 'magenta');
1753
- $.$mol_log3_area = $mol_log3_web_make('group', 'cyan');
2160
+ function $mol_wire_sync(obj) {
2161
+ return new Proxy(obj, {
2162
+ get(obj, field) {
2163
+ let val = obj[field];
2164
+ const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
2165
+ if (typeof val !== 'function')
2166
+ return temp(obj, []).sync();
2167
+ return function $mol_wire_sync(...args) {
2168
+ const fiber = temp(obj, args);
2169
+ return fiber.sync();
2170
+ };
2171
+ },
2172
+ set(obj, field, next) {
2173
+ const temp = $mol_wire_task.getter(get_prop(obj, field));
2174
+ temp(obj, [next]).sync();
2175
+ return true;
2176
+ },
2177
+ construct(obj, args) {
2178
+ const temp = $mol_wire_task.getter(factory(obj));
2179
+ return temp(obj, args).sync();
2180
+ },
2181
+ apply(obj, self, args) {
2182
+ const temp = $mol_wire_task.getter(obj);
2183
+ return temp(self, args).sync();
2184
+ },
2185
+ });
2186
+ }
2187
+ $.$mol_wire_sync = $mol_wire_sync;
1754
2188
  })($ || ($ = {}));
1755
2189
 
1756
2190
  ;
1757
2191
  "use strict";
1758
2192
  var $;
1759
2193
  (function ($) {
1760
- class $mol_wire_task extends $mol_wire_fiber {
1761
- static getter(task) {
1762
- return function $mol_wire_task_get(host, args) {
1763
- const sub = $mol_wire_auto();
1764
- const existen = sub?.track_next();
1765
- let cause = '';
1766
- reuse: if (existen) {
1767
- if (!existen.temp)
1768
- break reuse;
1769
- if (existen.task !== task) {
1770
- cause = 'task';
1771
- break reuse;
1772
- }
1773
- if (existen.host !== host) {
1774
- cause = 'host';
1775
- break reuse;
1776
- }
1777
- if (!$mol_compare_deep(existen.args, args)) {
1778
- cause = 'args';
1779
- break reuse;
1780
- }
1781
- return existen;
1782
- }
1783
- const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>');
1784
- const next = new $mol_wire_task(key, task, host, args);
1785
- if (existen?.temp) {
1786
- $$.$mol_log3_warn({
1787
- place: '$mol_wire_task',
1788
- message: `Different ${cause} on restart`,
1789
- sub,
1790
- prev: existen,
1791
- next,
1792
- hint: 'Maybe required additional memoization',
1793
- });
1794
- }
1795
- return next;
2194
+ class $mol_storage extends $mol_object2 {
2195
+ static native() {
2196
+ return this.$.$mol_dom_context.navigator.storage ?? {
2197
+ persisted: async () => false,
2198
+ persist: async () => false,
2199
+ estimate: async () => ({}),
2200
+ getDirectory: async () => null,
1796
2201
  };
1797
2202
  }
1798
- get temp() {
1799
- return true;
2203
+ static persisted(next, cache) {
2204
+ $mol_mem_persist();
2205
+ if (cache)
2206
+ return Boolean(next);
2207
+ const native = this.native();
2208
+ if (next && !$mol_mem_cached(() => this.persisted())) {
2209
+ native.persist().then(actual => {
2210
+ setTimeout(() => this.persisted(actual, 'cache'), 5000);
2211
+ if (actual)
2212
+ this.$.$mol_log3_done({ place: `$mol_storage`, message: `Persist: Yes` });
2213
+ else
2214
+ this.$.$mol_log3_fail({ place: `$mol_storage`, message: `Persist: No` });
2215
+ });
2216
+ }
2217
+ return next ?? $mol_wire_sync(native).persisted();
1800
2218
  }
1801
- complete() {
1802
- if ($mol_promise_like(this.cache))
1803
- return;
1804
- this.destructor();
2219
+ static estimate() {
2220
+ return $mol_wire_sync(this.native() ?? {}).estimate();
1805
2221
  }
1806
- put(next) {
1807
- const prev = this.cache;
1808
- this.cache = next;
1809
- if ($mol_promise_like(next)) {
1810
- this.cursor = $mol_wire_cursor.fresh;
1811
- if (next !== prev)
1812
- this.emit();
1813
- if ($mol_owning_catch(this, next)) {
1814
- try {
1815
- next[Symbol.toStringTag] = this[Symbol.toStringTag];
1816
- }
1817
- catch {
1818
- Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1819
- }
2222
+ static dir() {
2223
+ return $mol_wire_sync(this.native()).getDirectory();
2224
+ }
2225
+ }
2226
+ __decorate([
2227
+ $mol_mem
2228
+ ], $mol_storage, "native", null);
2229
+ __decorate([
2230
+ $mol_mem
2231
+ ], $mol_storage, "persisted", null);
2232
+ $.$mol_storage = $mol_storage;
2233
+ })($ || ($ = {}));
2234
+
2235
+ ;
2236
+ "use strict";
2237
+ var $;
2238
+ (function ($) {
2239
+ class $mol_state_local extends $mol_object {
2240
+ static 'native()';
2241
+ static native() {
2242
+ if (this['native()'])
2243
+ return this['native()'];
2244
+ check: try {
2245
+ const native = $mol_dom_context.localStorage;
2246
+ if (!native)
2247
+ break check;
2248
+ native.setItem('', '');
2249
+ native.removeItem('');
2250
+ return this['native()'] = native;
2251
+ }
2252
+ catch (error) {
2253
+ console.warn(error);
2254
+ }
2255
+ return this['native()'] = {
2256
+ getItem(key) {
2257
+ return this[':' + key];
2258
+ },
2259
+ setItem(key, value) {
2260
+ this[':' + key] = value;
2261
+ },
2262
+ removeItem(key) {
2263
+ this[':' + key] = void 0;
1820
2264
  }
1821
- return next;
2265
+ };
2266
+ }
2267
+ static changes(next) { return next; }
2268
+ static value(key, next) {
2269
+ this.changes();
2270
+ if (next === void 0)
2271
+ return JSON.parse(this.native().getItem(key) || 'null');
2272
+ if (next === null) {
2273
+ this.native().removeItem(key);
2274
+ }
2275
+ else {
2276
+ this.native().setItem(key, JSON.stringify(next));
2277
+ this.$.$mol_storage.persisted(true);
1822
2278
  }
1823
- this.cursor = $mol_wire_cursor.final;
1824
- if (this.sub_empty)
1825
- this.destructor();
1826
- else if (next !== prev)
1827
- this.emit();
1828
2279
  return next;
1829
2280
  }
2281
+ prefix() { return ''; }
2282
+ value(key, next) {
2283
+ return $mol_state_local.value(this.prefix() + '.' + key, next);
2284
+ }
1830
2285
  }
1831
- $.$mol_wire_task = $mol_wire_task;
2286
+ __decorate([
2287
+ $mol_mem
2288
+ ], $mol_state_local, "changes", null);
2289
+ __decorate([
2290
+ $mol_mem_key
2291
+ ], $mol_state_local, "value", null);
2292
+ $.$mol_state_local = $mol_state_local;
1832
2293
  })($ || ($ = {}));
1833
2294
 
1834
2295
  ;
1835
2296
  "use strict";
1836
2297
  var $;
1837
2298
  (function ($) {
1838
- function $mol_wire_method(host, field, descr) {
1839
- if (!descr)
1840
- descr = Reflect.getOwnPropertyDescriptor(host, field);
1841
- const orig = descr?.value ?? host[field];
1842
- const sup = Reflect.getPrototypeOf(host);
1843
- if (typeof sup[field] === 'function') {
1844
- Object.defineProperty(orig, 'name', { value: sup[field].name });
2299
+ self.addEventListener('storage', event => $.$mol_state_local.changes(event));
2300
+ })($ || ($ = {}));
2301
+
2302
+ ;
2303
+ "use strict";
2304
+ var $;
2305
+ (function ($) {
2306
+ function parse(theme) {
2307
+ if (theme === 'true')
2308
+ return true;
2309
+ if (theme === 'false')
2310
+ return false;
2311
+ return null;
2312
+ }
2313
+ function $mol_lights(next) {
2314
+ const arg = parse(this.$mol_state_arg.value('mol_lights'));
2315
+ const base = this.$mol_media.match('(prefers-color-scheme: light)');
2316
+ if (next === undefined) {
2317
+ return arg ?? this.$mol_state_local.value('$mol_lights') ?? base;
2318
+ }
2319
+ else {
2320
+ if (arg === null) {
2321
+ this.$mol_state_local.value('$mol_lights', next === base ? null : next);
2322
+ }
2323
+ else {
2324
+ this.$mol_state_arg.value('mol_lights', String(next));
2325
+ }
2326
+ return next;
1845
2327
  }
1846
- const temp = $mol_wire_task.getter(orig);
1847
- const value = function (...args) {
1848
- const fiber = temp(this ?? null, args);
1849
- return fiber.sync();
1850
- };
1851
- Object.defineProperty(value, 'name', { value: orig.name + ' ' });
1852
- Object.assign(value, { orig });
1853
- const descr2 = { ...descr, value };
1854
- Reflect.defineProperty(host, field, descr2);
1855
- return descr2;
1856
2328
  }
1857
- $.$mol_wire_method = $mol_wire_method;
2329
+ $.$mol_lights = $mol_lights;
1858
2330
  })($ || ($ = {}));
1859
2331
 
1860
2332
  ;
1861
2333
  "use strict";
2334
+ var $;
2335
+ (function ($) {
2336
+ $.$mol_theme = $mol_style_prop('mol_theme', [
2337
+ 'back',
2338
+ 'hover',
2339
+ 'card',
2340
+ 'current',
2341
+ 'special',
2342
+ 'text',
2343
+ 'control',
2344
+ 'shade',
2345
+ 'line',
2346
+ 'focus',
2347
+ 'field',
2348
+ 'image',
2349
+ 'spirit',
2350
+ ]);
2351
+ })($ || ($ = {}));
1862
2352
 
1863
2353
  ;
1864
2354
  "use strict";
2355
+ var $;
2356
+ (function ($) {
2357
+ $mol_style_attach("mol/theme/theme.css", ":root {\n\t--mol_theme_hue: 240deg;\n\t--mol_theme_hue_spread: 90deg;\n\tcolor-scheme: dark light;\n}\n\n:where([mol_theme]) {\n\tcolor: var(--mol_theme_text);\n\tfill: var(--mol_theme_text);\n\tbackground-color: var(--mol_theme_back);\n}\n\t\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\n\t--mol_theme_luma: -1;\n\t--mol_theme_image: invert(1) hue-rotate( 180deg );\n\t--mol_theme_spirit: hsl( 0deg, 0%, 0%, .75 );\n\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 10% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 20%, .25 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 8%, .25 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 80% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 60%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 65% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 60%, 65% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 60%, 65% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 60%, 65% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\t\n\t--mol_theme_back: oklch( 20% .03 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 30% .05 var(--mol_theme_hue) / .25 );\n\t--mol_theme_field: oklch( 15% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 80% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 60% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 80% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 70% .1 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 70% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 70% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t\n\t--mol_theme_luma: 1;\n\t--mol_theme_image: none;\n\t--mol_theme_spirit: hsl( 0deg, 0%, 100%, .75 );\n\t\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 92% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 100%, .5 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 100%, .75 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 0% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 40%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 40% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 80%, 30% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 80%, 30% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 80%, 30% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t--mol_theme_back: oklch( 92% .01 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 99% .01 var(--mol_theme_hue) / .5 );\n\t--mol_theme_field: oklch( 100% 0 var(--mol_theme_hue) / .5 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 20% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 50% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 60% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 40% .15 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 50% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 50% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 25% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 35% .1 var(--mol_theme_hue) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 85% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 98% .03 var(--mol_theme_hue) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 35% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 45% .15 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 83% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n\n");
2358
+ })($ || ($ = {}));
1865
2359
 
1866
2360
  ;
1867
2361
  "use strict";
1868
2362
  var $;
1869
2363
  (function ($) {
1870
- const catched = new WeakMap();
1871
- function $mol_fail_catch(error) {
1872
- if (typeof error !== 'object')
1873
- return false;
1874
- if ($mol_promise_like(error))
1875
- $mol_fail_hidden(error);
1876
- if (catched.get(error))
1877
- return false;
1878
- catched.set(error, true);
1879
- return true;
1880
- }
1881
- $.$mol_fail_catch = $mol_fail_catch;
2364
+ $mol_style_attach('$mol_theme_lights', `:root { --mol_theme_back: oklch( ${$$.$mol_lights() ? 92 : 20}% .01 var(--mol_theme_hue) ) }`);
1882
2365
  })($ || ($ = {}));
1883
2366
 
1884
2367
  ;
1885
2368
  "use strict";
1886
2369
  var $;
1887
2370
  (function ($) {
1888
- let error;
1889
- let result;
1890
- let handler;
1891
- function $mol_try(handler2) {
1892
- handler = handler2;
1893
- error = undefined;
1894
- result = undefined;
1895
- window.dispatchEvent(new Event('$mol_try'));
1896
- const error2 = error;
1897
- const result2 = result;
1898
- error = undefined;
1899
- result = undefined;
1900
- return error2 || result2;
1901
- }
1902
- $.$mol_try = $mol_try;
1903
- self.addEventListener('$mol_try', (event) => {
1904
- result = handler();
1905
- }, true);
1906
- self.addEventListener('error', (event) => {
1907
- error = event.error;
1908
- }, true);
2371
+ $.$mol_gap = $mol_style_prop('mol_gap', [
2372
+ 'block',
2373
+ 'text',
2374
+ 'round',
2375
+ 'space',
2376
+ 'blur',
2377
+ ]);
1909
2378
  })($ || ($ = {}));
1910
2379
 
1911
2380
  ;
1912
2381
  "use strict";
1913
2382
  var $;
1914
2383
  (function ($) {
1915
- function $mol_fail_log(error) {
1916
- if ($mol_promise_like(error))
1917
- return false;
1918
- if (!$mol_fail_catch(error))
1919
- return false;
1920
- $mol_try(() => { $mol_fail_hidden(error); });
1921
- return true;
1922
- }
1923
- $.$mol_fail_log = $mol_fail_log;
2384
+ $mol_style_attach("mol/gap/gap.css", ":root {\n\t--mol_gap_block: .75rem;\n\t--mol_gap_text: .5rem .75rem;\n\t--mol_gap_round: .25rem;\n\t--mol_gap_space: .25rem;\n\t--mol_gap_blur: .5rem;\n}\n");
1924
2385
  })($ || ($ = {}));
1925
2386
 
1926
2387
  ;
1927
2388
  "use strict";
1928
2389
  var $;
1929
2390
  (function ($) {
1930
- class $mol_wire_atom extends $mol_wire_fiber {
1931
- static solo(host, task) {
1932
- const field = task.name + '()';
1933
- const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1934
- if (existen)
1935
- return existen;
1936
- const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
1937
- const key = prefix + ('.' + task.name + '<>');
1938
- const fiber = new $mol_wire_atom(key, task, host, []);
1939
- (host ?? task)[field] = fiber;
1940
- return fiber;
1941
- }
1942
- static plex(host, task, key) {
1943
- const field = task.name + '()';
1944
- let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1945
- const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
1946
- const key_str = $mol_key(key);
1947
- if (dict) {
1948
- const existen = dict.get(key_str);
1949
- if (existen)
1950
- return existen;
1951
- }
1952
- else {
1953
- dict = (host ?? task)[field] = new Map();
1954
- }
1955
- const id = prefix + ('.' + task.name) + ('<' + key_str.replace(/^"|"$/g, "'") + '>');
1956
- const fiber = new $mol_wire_atom(id, task, host, [key]);
1957
- dict.set(key_str, fiber);
1958
- return fiber;
1959
- }
1960
- static watching = new Set();
1961
- static watcher = null;
1962
- static watch() {
1963
- $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
1964
- for (const atom of $mol_wire_atom.watching) {
1965
- if (atom.cursor === $mol_wire_cursor.final) {
1966
- $mol_wire_atom.watching.delete(atom);
1967
- }
1968
- else {
1969
- atom.cursor = $mol_wire_cursor.stale;
1970
- atom.fresh();
1971
- }
1972
- }
1973
- }
1974
- watch() {
1975
- if (!$mol_wire_atom.watcher) {
1976
- $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
1977
- }
1978
- $mol_wire_atom.watching.add(this);
1979
- }
1980
- resync(args) {
1981
- return this.put(this.task.call(this.host, ...args));
1982
- }
1983
- once() {
1984
- return this.sync();
1985
- }
1986
- channel() {
1987
- return Object.assign((next) => {
1988
- if (next !== undefined)
1989
- return this.resync([...this.args, next]);
1990
- if (!$mol_wire_fiber.warm)
1991
- return this.result();
1992
- if ($mol_wire_auto()?.temp) {
1993
- return this.once();
1994
- }
1995
- else {
1996
- return this.sync();
1997
- }
1998
- }, { atom: this });
1999
- }
2000
- destructor() {
2001
- super.destructor();
2002
- if (this.pub_from === 0) {
2003
- ;
2004
- (this.host ?? this.task)[this.field()] = null;
2005
- }
2006
- else {
2007
- ;
2008
- (this.host ?? this.task)[this.field()].delete($mol_key(this.args[0]));
2009
- }
2010
- }
2011
- put(next) {
2012
- const prev = this.cache;
2013
- update: if (next !== prev) {
2014
- try {
2015
- if ($mol_compare_deep(prev, next))
2016
- break update;
2017
- }
2018
- catch (error) {
2019
- $mol_fail_log(error);
2020
- }
2021
- if ($mol_owning_check(this, prev)) {
2022
- prev.destructor();
2023
- }
2024
- if ($mol_owning_catch(this, next)) {
2025
- try {
2026
- next[Symbol.toStringTag] = this[Symbol.toStringTag];
2391
+ function $mol_dom_render_children(el, childNodes) {
2392
+ const node_set = new Set(childNodes);
2393
+ let nextNode = el.firstChild;
2394
+ for (let view of childNodes) {
2395
+ if (view == null)
2396
+ continue;
2397
+ if (view instanceof $mol_dom_context.Node) {
2398
+ while (true) {
2399
+ if (!nextNode) {
2400
+ el.appendChild(view);
2401
+ break;
2027
2402
  }
2028
- catch {
2029
- Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
2403
+ if (nextNode == view) {
2404
+ nextNode = nextNode.nextSibling;
2405
+ break;
2406
+ }
2407
+ else {
2408
+ if (node_set.has(nextNode)) {
2409
+ el.insertBefore(view, nextNode);
2410
+ break;
2411
+ }
2412
+ else {
2413
+ const nn = nextNode.nextSibling;
2414
+ el.removeChild(nextNode);
2415
+ nextNode = nn;
2416
+ }
2030
2417
  }
2031
2418
  }
2032
- if (!this.sub_empty)
2033
- this.emit();
2034
2419
  }
2035
- this.cache = next;
2036
- this.cursor = $mol_wire_cursor.fresh;
2037
- if ($mol_promise_like(next))
2038
- return next;
2039
- this.complete_pubs();
2040
- return next;
2420
+ else {
2421
+ if (nextNode && nextNode.nodeName === '#text') {
2422
+ const str = String(view);
2423
+ if (nextNode.nodeValue !== str)
2424
+ nextNode.nodeValue = str;
2425
+ nextNode = nextNode.nextSibling;
2426
+ }
2427
+ else {
2428
+ const textNode = $mol_dom_context.document.createTextNode(String(view));
2429
+ el.insertBefore(textNode, nextNode);
2430
+ }
2431
+ }
2432
+ }
2433
+ while (nextNode) {
2434
+ const currNode = nextNode;
2435
+ nextNode = currNode.nextSibling;
2436
+ el.removeChild(currNode);
2041
2437
  }
2042
2438
  }
2043
- __decorate([
2044
- $mol_wire_method
2045
- ], $mol_wire_atom.prototype, "resync", null);
2046
- __decorate([
2047
- $mol_wire_method
2048
- ], $mol_wire_atom.prototype, "once", null);
2049
- $.$mol_wire_atom = $mol_wire_atom;
2439
+ $.$mol_dom_render_children = $mol_dom_render_children;
2050
2440
  })($ || ($ = {}));
2051
2441
 
2052
2442
  ;
2053
2443
  "use strict";
2054
- var $;
2055
- (function ($) {
2056
- function $mol_wire_solo(host, field, descr) {
2057
- if (!descr)
2058
- descr = Reflect.getOwnPropertyDescriptor(host, field);
2059
- const orig = descr?.value ?? host[field];
2060
- const sup = Reflect.getPrototypeOf(host);
2061
- if (typeof sup[field] === 'function') {
2062
- Object.defineProperty(orig, 'name', { value: sup[field].name });
2063
- }
2064
- const descr2 = {
2065
- ...descr,
2066
- value: function (...args) {
2067
- let atom = $mol_wire_atom.solo(this, orig);
2068
- if ((args.length === 0) || (args[0] === undefined)) {
2069
- if (!$mol_wire_fiber.warm)
2070
- return atom.result();
2071
- if ($mol_wire_auto()?.temp) {
2072
- return atom.once();
2073
- }
2074
- else {
2075
- return atom.sync();
2076
- }
2077
- }
2078
- return atom.resync(args);
2079
- }
2080
- };
2081
- Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
2082
- Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
2083
- Object.assign(descr2.value, { orig });
2084
- Reflect.defineProperty(host, field, descr2);
2085
- return descr2;
2086
- }
2087
- $.$mol_wire_solo = $mol_wire_solo;
2088
- })($ || ($ = {}));
2089
2444
 
2090
2445
  ;
2091
2446
  "use strict";
2092
2447
  var $;
2093
2448
  (function ($) {
2094
- function $mol_wire_plex(host, field, descr) {
2095
- if (!descr)
2096
- descr = Reflect.getOwnPropertyDescriptor(host, field);
2097
- const orig = descr?.value ?? host[field];
2098
- const sup = Reflect.getPrototypeOf(host);
2099
- if (typeof sup[field] === 'function') {
2100
- Object.defineProperty(orig, 'name', { value: sup[field].name });
2449
+ $.$mol_jsx_prefix = '';
2450
+ $.$mol_jsx_crumbs = '';
2451
+ $.$mol_jsx_booked = null;
2452
+ $.$mol_jsx_document = {
2453
+ getElementById: () => null,
2454
+ createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
2455
+ createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
2456
+ };
2457
+ $.$mol_jsx_frag = '';
2458
+ function $mol_jsx(Elem, props, ...childNodes) {
2459
+ const id = props && props.id || '';
2460
+ const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
2461
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
2462
+ if (Elem && $.$mol_jsx_booked) {
2463
+ if ($.$mol_jsx_booked.has(id)) {
2464
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
2465
+ }
2466
+ else {
2467
+ $.$mol_jsx_booked.add(id);
2468
+ }
2101
2469
  }
2102
- const descr2 = {
2103
- ...descr,
2104
- value: function (...args) {
2105
- let atom = $mol_wire_atom.plex(this, orig, args[0]);
2106
- if ((args.length === 1) || (args[1] === undefined)) {
2107
- if (!$mol_wire_fiber.warm)
2108
- return atom.result();
2109
- if ($mol_wire_auto()?.temp) {
2110
- return atom.once();
2470
+ let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
2471
+ if ($.$mol_jsx_prefix) {
2472
+ const prefix_ext = $.$mol_jsx_prefix;
2473
+ const booked_ext = $.$mol_jsx_booked;
2474
+ const crumbs_ext = $.$mol_jsx_crumbs;
2475
+ for (const field in props) {
2476
+ const func = props[field];
2477
+ if (typeof func !== 'function')
2478
+ continue;
2479
+ const wrapper = function (...args) {
2480
+ const prefix = $.$mol_jsx_prefix;
2481
+ const booked = $.$mol_jsx_booked;
2482
+ const crumbs = $.$mol_jsx_crumbs;
2483
+ try {
2484
+ $.$mol_jsx_prefix = prefix_ext;
2485
+ $.$mol_jsx_booked = booked_ext;
2486
+ $.$mol_jsx_crumbs = crumbs_ext;
2487
+ return func.call(this, ...args);
2111
2488
  }
2112
- else {
2113
- return atom.sync();
2489
+ finally {
2490
+ $.$mol_jsx_prefix = prefix;
2491
+ $.$mol_jsx_booked = booked;
2492
+ $.$mol_jsx_crumbs = crumbs;
2114
2493
  }
2494
+ };
2495
+ $mol_func_name_from(wrapper, func);
2496
+ props[field] = wrapper;
2497
+ }
2498
+ }
2499
+ if (typeof Elem !== 'string') {
2500
+ if ('prototype' in Elem) {
2501
+ const view = node && node[String(Elem)] || new Elem;
2502
+ Object.assign(view, props);
2503
+ view[Symbol.toStringTag] = guid;
2504
+ view.childNodes = childNodes;
2505
+ if (!view.ownerDocument)
2506
+ view.ownerDocument = $.$mol_jsx_document;
2507
+ view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
2508
+ node = view.valueOf();
2509
+ node[String(Elem)] = view;
2510
+ return node;
2511
+ }
2512
+ else {
2513
+ const prefix = $.$mol_jsx_prefix;
2514
+ const booked = $.$mol_jsx_booked;
2515
+ const crumbs = $.$mol_jsx_crumbs;
2516
+ try {
2517
+ $.$mol_jsx_prefix = guid;
2518
+ $.$mol_jsx_booked = new Set;
2519
+ $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
2520
+ return Elem(props, ...childNodes);
2521
+ }
2522
+ finally {
2523
+ $.$mol_jsx_prefix = prefix;
2524
+ $.$mol_jsx_booked = booked;
2525
+ $.$mol_jsx_crumbs = crumbs;
2115
2526
  }
2116
- return atom.resync(args);
2117
2527
  }
2118
- };
2119
- Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
2120
- Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
2121
- Object.assign(descr2.value, { orig });
2122
- Reflect.defineProperty(host, field, descr2);
2123
- return descr2;
2528
+ }
2529
+ if (!node) {
2530
+ node = Elem
2531
+ ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
2532
+ : $.$mol_jsx_document.createDocumentFragment();
2533
+ }
2534
+ $mol_dom_render_children(node, [].concat(...childNodes));
2535
+ if (!Elem)
2536
+ return node;
2537
+ if (guid)
2538
+ node.id = guid;
2539
+ for (const key in props) {
2540
+ if (key === 'id')
2541
+ continue;
2542
+ if (typeof props[key] === 'string') {
2543
+ if (typeof node[key] === 'string')
2544
+ node[key] = props[key];
2545
+ node.setAttribute(key, props[key]);
2546
+ }
2547
+ else if (props[key] &&
2548
+ typeof props[key] === 'object' &&
2549
+ Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
2550
+ if (typeof node[key] === 'object') {
2551
+ Object.assign(node[key], props[key]);
2552
+ continue;
2553
+ }
2554
+ }
2555
+ else {
2556
+ node[key] = props[key];
2557
+ }
2558
+ }
2559
+ if ($.$mol_jsx_crumbs)
2560
+ node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
2561
+ return node;
2124
2562
  }
2125
- $.$mol_wire_plex = $mol_wire_plex;
2126
- })($ || ($ = {}));
2127
-
2128
- ;
2129
- "use strict";
2130
- var $;
2131
- (function ($) {
2132
- $.$mol_mem = $mol_wire_solo;
2133
- $.$mol_mem_key = $mol_wire_plex;
2563
+ $.$mol_jsx = $mol_jsx;
2134
2564
  })($ || ($ = {}));
2135
2565
 
2136
2566
  ;
@@ -2462,26 +2892,6 @@ var $;
2462
2892
  $.$mol_dom_qname = $mol_dom_qname;
2463
2893
  })($ || ($ = {}));
2464
2894
 
2465
- ;
2466
- "use strict";
2467
- var $;
2468
- (function ($) {
2469
- function $mol_wire_probe(task, def) {
2470
- const warm = $mol_wire_fiber.warm;
2471
- try {
2472
- $mol_wire_fiber.warm = false;
2473
- const res = task();
2474
- if (res === undefined)
2475
- return def;
2476
- return res;
2477
- }
2478
- finally {
2479
- $mol_wire_fiber.warm = warm;
2480
- }
2481
- }
2482
- $.$mol_wire_probe = $mol_wire_probe;
2483
- })($ || ($ = {}));
2484
-
2485
2895
  ;
2486
2896
  "use strict";
2487
2897
  var $;
@@ -2512,24 +2922,6 @@ var $;
2512
2922
  $.$mol_const = $mol_const;
2513
2923
  })($ || ($ = {}));
2514
2924
 
2515
- ;
2516
- "use strict";
2517
- var $;
2518
- (function ($) {
2519
- function $mol_wire_solid() {
2520
- let current = $mol_wire_auto();
2521
- if (current.temp)
2522
- current = current.host;
2523
- if (current.reap !== nothing) {
2524
- current?.sub_on(sub, sub.data.length);
2525
- }
2526
- current.reap = nothing;
2527
- }
2528
- $.$mol_wire_solid = $mol_wire_solid;
2529
- const nothing = () => { };
2530
- const sub = new $mol_wire_pub_sub;
2531
- })($ || ($ = {}));
2532
-
2533
2925
  ;
2534
2926
  "use strict";
2535
2927
  var $;
@@ -2663,7 +3055,7 @@ var $;
2663
3055
  "use strict";
2664
3056
  var $;
2665
3057
  (function ($) {
2666
- $mol_style_attach("mol/view/view/view.css", "[mol_view] {\n\ttransition-property: height, width, min-height, min-width, max-width, max-height, transform;\n\ttransition-duration: .2s;\n\ttransition-timing-function: ease-out;\n\t-webkit-appearance: none;\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\tflex-shrink: 0;\n\tcontain: style;\n\tscrollbar-color: var(--mol_theme_line) transparent;\n\tscrollbar-width: thin;\n}\t\n\n[mol_view]::selection {\n\tbackground: var(--mol_theme_line);\n}\t\n\n[mol_view]::-webkit-scrollbar {\n\twidth: .25rem;\n\theight: .25rem;\n}\n\n[mol_view]::-webkit-scrollbar-corner {\n\tbackground-color: var(--mol_theme_line);\n}\n\n[mol_view]::-webkit-scrollbar-track {\n\tbackground-color: transparent;\n}\n\n[mol_view]::-webkit-scrollbar-thumb {\n\tbackground-color: var(--mol_theme_line);\n\tborder-radius: var(--mol_gap_round);\n}\n\n[mol_view] > * {\n\tword-break: inherit;\n}\n\n[mol_view_root] {\n\tmargin: 0;\n\tpadding: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbox-sizing: border-box;\n\tfont-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n\tfont-size: 1rem;\n\tline-height: 1.5rem;\n\tbackground: var(--mol_theme_back);\n\tcolor: var(--mol_theme_text);\n\tcontain: unset; /** Fixes bg ignoring when applied to body on Chrome */\n\ttab-size: 4;\n\toverscroll-behavior: contain; /** Disable navigation gestures **/\n}\n\n@media print {\n\t[mol_view_root] {\n\t\theight: auto;\n\t}\n}\n[mol_view][mol_view_error]:not([mol_view_error=\"Promise\"], [mol_view_error=\"$mol_promise_blocker\"]) {\n\tbackground-image: repeating-linear-gradient(\n\t\t-45deg,\n\t\t#f92323,\n\t\t#f92323 .5rem,\n\t\t#ff3d3d .5rem,\n\t\t#ff3d3d 1.5rem\n\t);\n\tcolor: black;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n@keyframes mol_view_wait {\n\tfrom {\n\t\topacity: .25;\n\t}\n\t20% {\n\t\topacity: .75;\n\t}\n\tto {\n\t\topacity: .25;\n\t}\n}\n\n:where([mol_view][mol_view_error=\"$mol_promise_blocker\"]),\n:where([mol_view][mol_view_error=\"Promise\"]) {\n\tbackground: var(--mol_theme_hover);\n}\n\n[mol_view][mol_view_error=\"Promise\"] {\n\tanimation: mol_view_wait 1s steps(20,end) infinite;\n}\n");
3058
+ $mol_style_attach("mol/view/view/view.css", "[mol_view] {\n\ttransition-property: height, width, min-height, min-width, max-width, max-height, transform;\n\ttransition-duration: .2s;\n\ttransition-timing-function: ease-out;\n\t-webkit-appearance: none;\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\tflex-shrink: 0;\n\tcontain: style;\n\tscrollbar-color: var(--mol_theme_line) transparent;\n\tscrollbar-width: thin;\n}\t\n\n[mol_view]::selection {\n\tbackground: var(--mol_theme_line);\n}\t\n\n[mol_view]::-webkit-scrollbar {\n\twidth: .25rem;\n\theight: .25rem;\n}\n\n[mol_view]::-webkit-scrollbar-corner {\n\tbackground-color: var(--mol_theme_line);\n}\n\n[mol_view]::-webkit-scrollbar-track {\n\tbackground-color: transparent;\n}\n\n[mol_view]::-webkit-scrollbar-thumb {\n\tbackground-color: var(--mol_theme_line);\n\tborder-radius: var(--mol_gap_round);\n}\n\n[mol_view] > * {\n\tword-break: inherit;\n}\n\n[mol_view_root] {\n\tmargin: 0;\n\tpadding: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbox-sizing: border-box;\n\tfont-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n\tfont-size: 1rem;\n\tline-height: 1.5rem;\n\t/* background: var(--mol_theme_back);\n\tcolor: var(--mol_theme_text); */\n\tcontain: unset; /** Fixes bg ignoring when applied to body on Chrome */\n\ttab-size: 4;\n\toverscroll-behavior: contain; /** Disable navigation gestures **/\n}\n\n@media print {\n\t[mol_view_root] {\n\t\theight: auto;\n\t}\n}\n[mol_view][mol_view_error]:not([mol_view_error=\"Promise\"], [mol_view_error=\"$mol_promise_blocker\"]) {\n\tbackground-image: repeating-linear-gradient(\n\t\t-45deg,\n\t\t#f92323,\n\t\t#f92323 .5rem,\n\t\t#ff3d3d .5rem,\n\t\t#ff3d3d 1.5rem\n\t);\n\tcolor: black;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n@keyframes mol_view_wait {\n\tfrom {\n\t\topacity: .25;\n\t}\n\t20% {\n\t\topacity: .75;\n\t}\n\tto {\n\t\topacity: .25;\n\t}\n}\n\n:where([mol_view][mol_view_error=\"$mol_promise_blocker\"]),\n:where([mol_view][mol_view_error=\"Promise\"]) {\n\tbackground: var(--mol_theme_hover);\n}\n\n[mol_view][mol_view_error=\"Promise\"] {\n\tanimation: mol_view_wait 1s steps(20,end) infinite;\n}\n");
2667
3059
  })($ || ($ = {}));
2668
3060
 
2669
3061
  ;
@@ -4049,13 +4441,6 @@ var $;
4049
4441
  ($mol_mem(($.$mol_plot_pane.prototype), "dimensions_viewport"));
4050
4442
 
4051
4443
 
4052
- ;
4053
- "use strict";
4054
- var $;
4055
- (function ($) {
4056
- $.$mol_mem_cached = $mol_wire_probe;
4057
- })($ || ($ = {}));
4058
-
4059
4444
  ;
4060
4445
  ($.$mol_svg_group) = class $mol_svg_group extends ($.$mol_svg) {
4061
4446
  dom_name(){