@faqir-ui/core 1.1.0 → 1.1.2

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.
Files changed (37) hide show
  1. package/cdn.json +35 -35
  2. package/dist/faqir-core.js +528 -333
  3. package/dist/faqir-core.min.js +3 -3
  4. package/dist/faqir-core.min.js.map +3 -3
  5. package/dist/faqir-core.mjs +532 -482
  6. package/dist/faqir.aurora.css +1486 -1036
  7. package/dist/faqir.brutalist.css +1486 -1036
  8. package/dist/faqir.candy.css +1486 -1036
  9. package/dist/faqir.clinical.css +1486 -1036
  10. package/dist/faqir.contrast.css +1486 -1036
  11. package/dist/faqir.default.css +1486 -1036
  12. package/dist/faqir.document-serif.css +1486 -1036
  13. package/dist/faqir.document.css +1486 -1036
  14. package/dist/faqir.editorial-document.css +1486 -1036
  15. package/dist/faqir.editorial.css +1486 -1036
  16. package/dist/faqir.fintech.css +1486 -1036
  17. package/dist/faqir.glass.css +1486 -1036
  18. package/dist/faqir.ink-document.css +1486 -1036
  19. package/dist/faqir.ink.css +1486 -1036
  20. package/dist/faqir.luxe.css +1486 -1036
  21. package/dist/faqir.midnight.css +1486 -1036
  22. package/dist/faqir.neo.css +1486 -1036
  23. package/dist/faqir.neumorph.css +1486 -1036
  24. package/dist/faqir.nordic.css +1486 -1036
  25. package/dist/faqir.organic.css +1486 -1036
  26. package/dist/faqir.paper.css +1486 -1036
  27. package/dist/faqir.slate.css +1486 -1036
  28. package/dist/faqir.soft.css +1486 -1036
  29. package/dist/faqir.sunset.css +1486 -1036
  30. package/dist/faqir.swiss-document.css +1486 -1036
  31. package/dist/faqir.swiss.css +1486 -1036
  32. package/dist/faqir.terminal.css +1486 -1036
  33. package/dist/plugins/faqir-mask.js +1 -2
  34. package/dist/plugins/faqir-rules.js +1 -1
  35. package/dist/sri.json +33 -33
  36. package/faqir-core.d.ts +18 -3
  37. package/package.json +1 -1
@@ -3,21 +3,37 @@ var __getProtoOf = Object.getPrototypeOf;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ function __accessProp(key) {
7
+ return this[key];
8
+ }
9
+ var __toESMCache_node;
10
+ var __toESMCache_esm;
6
11
  var __toESM = (mod, isNodeMode, target) => {
12
+ var canCache = mod != null && typeof mod === "object";
13
+ if (canCache) {
14
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
15
+ var cached = cache.get(mod);
16
+ if (cached)
17
+ return cached;
18
+ }
7
19
  target = mod != null ? __create(__getProtoOf(mod)) : {};
8
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
- for (let key of __getOwnPropNames(mod))
10
- if (!__hasOwnProp.call(to, key))
11
- __defProp(to, key, {
12
- get: () => mod[key],
13
- enumerable: true
14
- });
20
+ const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
21
+ if (mod && typeof mod === "object" || typeof mod === "function") {
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ }
29
+ if (canCache)
30
+ cache.set(mod, to);
15
31
  return to;
16
32
  };
17
33
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
34
 
19
35
  // registry/core/faqir-core.js
20
- var require_faqir_core = __commonJS((exports, module) => {
36
+ var require_faqir_core = __commonJS(function(exports, module) {
21
37
  (function(global, factory) {
22
38
  if (typeof exports === "object" && typeof module !== "undefined") {
23
39
  module.exports = factory();
@@ -165,7 +181,7 @@ var require_faqir_core = __commonJS((exports, module) => {
165
181
  function evaluate(expression, scope, el) {
166
182
  try {
167
183
  const fn = compileExpression(expression);
168
- return fn.call(scope, scope, el);
184
+ return fn.call(scope, scope, el, el);
169
185
  } catch (e) {
170
186
  console.warn('[Faqir] Expression error: "' + expression + '"', e);
171
187
  return;
@@ -174,7 +190,7 @@ var require_faqir_core = __commonJS((exports, module) => {
174
190
  function evaluateAssignment(expression, scope, el) {
175
191
  try {
176
192
  const fn = compileStatement(expression);
177
- fn.call(scope, scope, el);
193
+ fn.call(scope, scope, el, el);
178
194
  } catch (e) {
179
195
  console.warn('[Faqir] Statement error: "' + expression + '"', e);
180
196
  }
@@ -191,7 +207,7 @@ var require_faqir_core = __commonJS((exports, module) => {
191
207
  var key = "expr:" + expr;
192
208
  if (expressionCache.has(key))
193
209
  return expressionCache.get(key);
194
- var fn = new Function("$scope", "$el", "with($scope) { return (" + expr + ") }");
210
+ var fn = new Function("$scope", "$el", "$this", "with($scope) { return (" + expr + ") }");
195
211
  expressionCache.set(key, fn);
196
212
  return fn;
197
213
  }
@@ -199,7 +215,7 @@ var require_faqir_core = __commonJS((exports, module) => {
199
215
  var key = "stmt:" + expr;
200
216
  if (expressionCache.has(key))
201
217
  return expressionCache.get(key);
202
- var fn = new Function("$scope", "$el", "with($scope) { " + expr + " }");
218
+ var fn = new Function("$scope", "$el", "$this", "with($scope) { " + expr + " }");
203
219
  expressionCache.set(key, fn);
204
220
  return fn;
205
221
  }
@@ -299,6 +315,32 @@ var require_faqir_core = __commonJS((exports, module) => {
299
315
  teleport: 100
300
316
  };
301
317
  var ROOT_CONSUMED = { data: 1, source: 1, init: 1 };
318
+ var pendingInits = null;
319
+ function runInit(fn) {
320
+ if (pendingInits)
321
+ pendingInits.push(fn);
322
+ else
323
+ fn();
324
+ }
325
+ function renderThenInit(render) {
326
+ if (pendingInits)
327
+ return render();
328
+ var queue = pendingInits = [];
329
+ var nodes;
330
+ try {
331
+ nodes = render();
332
+ } finally {
333
+ pendingInits = null;
334
+ }
335
+ untrack(function() {
336
+ for (var i = 0;i < nodes.length; i++) {
337
+ if (nodes[i].nodeType === 1 && nodes[i].isConnected)
338
+ startControllers(nodes[i]);
339
+ }
340
+ for (var q = 0;q < queue.length; q++)
341
+ queue[q]();
342
+ });
343
+ }
302
344
  function initTree(root, parentScope) {
303
345
  var scope = initScope(root, parentScope);
304
346
  var rootDirectives = parseDirectives(root);
@@ -345,6 +387,7 @@ var require_faqir_core = __commonJS((exports, module) => {
345
387
  }
346
388
  }
347
389
  var strayScope = null;
390
+ var scopeRoots = new WeakMap;
348
391
  function getStrayScope() {
349
392
  if (!strayScope) {
350
393
  if (!document.body.__scopeId)
@@ -352,6 +395,7 @@ var require_faqir_core = __commonJS((exports, module) => {
352
395
  if (!document.body.__faqirCleanups)
353
396
  document.body.__faqirCleanups = [];
354
397
  strayScope = createScopeWithMagics({}, document.body, document.body);
398
+ scopeRoots.set(strayScope, document.body);
355
399
  }
356
400
  return strayScope;
357
401
  }
@@ -392,6 +436,7 @@ var require_faqir_core = __commonJS((exports, module) => {
392
436
  Object.assign(userData, propData);
393
437
  var scopeId = ++scopeCounter;
394
438
  var scope = createScopeWithMagics(userData, root, root);
439
+ scopeRoots.set(scope, root);
395
440
  root.__faqirScope = scope;
396
441
  root.__scopeId = scopeId;
397
442
  root.__faqirCleanups = [];
@@ -405,7 +450,9 @@ var require_faqir_core = __commonJS((exports, module) => {
405
450
  processSourceDirectives(root, scope);
406
451
  var initExpr = root.getAttribute("l-init");
407
452
  if (initExpr) {
408
- evaluateAssignment(initExpr, scope, root);
453
+ runInit(function() {
454
+ evaluateAssignment(initExpr, scope, root);
455
+ });
409
456
  }
410
457
  return scope;
411
458
  }
@@ -505,6 +552,11 @@ var require_faqir_core = __commonJS((exports, module) => {
505
552
  var descriptors = Object.getOwnPropertyDescriptors(data);
506
553
  Object.defineProperties(target, descriptors);
507
554
  var scope = reactive(target);
555
+ for (var k in descriptors) {
556
+ var d = descriptors[k];
557
+ if (d.writable && typeof d.value === "function")
558
+ target[k] = d.value.bind(scope);
559
+ }
508
560
  return scope;
509
561
  }
510
562
  function watchProperty(scope, key, cb) {
@@ -520,7 +572,7 @@ var require_faqir_core = __commonJS((exports, module) => {
520
572
  return dispose;
521
573
  }
522
574
  function getScopeRefs(root) {
523
- return root.__faqirRefs || {};
575
+ return root.__faqirRefs || (root.__faqirRefs = {});
524
576
  }
525
577
  function findScopeRoot(el) {
526
578
  var node = el;
@@ -896,14 +948,24 @@ var require_faqir_core = __commonJS((exports, module) => {
896
948
  "formnovalidate",
897
949
  "inert"
898
950
  ]);
951
+ var PROPS = new Set(["checked", "selected", "muted", "indeterminate", "value"]);
952
+ function writeProp(el, name, value) {
953
+ if (!(name in el) || el[name] === value)
954
+ return;
955
+ el[name] = value;
956
+ if (name === "checked" || name === "selected") {
957
+ el.dispatchEvent(new CustomEvent("faqir:model", { bubbles: true }));
958
+ }
959
+ }
899
960
  function handleBind(el, dir, scope) {
900
961
  var attrName = dir.arg;
962
+ var prev = {};
901
963
  var cl = effect(function() {
902
964
  var value = evaluate(dir.expression, scope, el);
903
965
  if (attrName === "class") {
904
- applyClassBinding(el, value);
966
+ prev = applyClassBinding(el, value, prev);
905
967
  } else if (attrName === "style") {
906
- applyStyleBinding(el, value);
968
+ prev = applyStyleBinding(el, value, prev);
907
969
  } else if (BOOLEAN_ATTRS.has(attrName)) {
908
970
  if (value) {
909
971
  el.setAttribute(attrName, "");
@@ -917,40 +979,69 @@ var require_faqir_core = __commonJS((exports, module) => {
917
979
  el.setAttribute(attrName, String(value));
918
980
  }
919
981
  }
982
+ if (PROPS.has(attrName)) {
983
+ writeProp(el, attrName, attrName === "value" ? value == null || value === false ? "" : String(value) : !!value);
984
+ }
920
985
  });
921
986
  addCleanup(el, cl);
922
987
  }
923
- function applyClassBinding(el, value) {
924
- if (typeof value === "string") {
925
- el.className = value;
926
- } else if (Array.isArray(value)) {
927
- el.className = value.filter(Boolean).join(" ");
928
- } else if (typeof value === "object" && value !== null) {
929
- for (var cls in value) {
930
- if (value.hasOwnProperty(cls)) {
931
- el.classList.toggle(cls, !!value[cls]);
932
- }
933
- }
988
+ function classMap(v, out, on) {
989
+ if (typeof v === "string") {
990
+ v.split(/\s+/).forEach(function(c) {
991
+ if (c)
992
+ out[c] = on;
993
+ });
994
+ } else if (Array.isArray(v)) {
995
+ v.forEach(function(x) {
996
+ if (x)
997
+ classMap(x, out, true);
998
+ });
999
+ } else if (v && typeof v === "object") {
1000
+ for (var k in v)
1001
+ classMap(k, out, !!v[k]);
934
1002
  }
1003
+ return out;
935
1004
  }
936
- function applyStyleBinding(el, value) {
937
- if (typeof value === "string") {
938
- el.style.cssText = value;
939
- } else if (typeof value === "object" && value !== null) {
940
- for (var prop in value) {
941
- if (value.hasOwnProperty(prop)) {
942
- var cssProp = prop.replace(/[A-Z]/g, function(m) {
943
- return "-" + m.toLowerCase();
944
- });
945
- var val = value[prop];
946
- if (val === null || val === undefined || val === false) {
947
- el.style.removeProperty(cssProp);
948
- } else {
949
- el.style.setProperty(cssProp, String(val));
950
- }
951
- }
1005
+ function applyClassBinding(el, value, prev) {
1006
+ var next = classMap(value, {}, true), c;
1007
+ for (c in prev)
1008
+ if (prev[c] && !(c in next))
1009
+ el.classList.remove(c);
1010
+ for (c in next)
1011
+ el.classList.toggle(c, next[c]);
1012
+ return next;
1013
+ }
1014
+ var styleScratch;
1015
+ function styleMap(v, out) {
1016
+ if (typeof v === "string") {
1017
+ var s = (styleScratch || (styleScratch = document.createElement("div"))).style;
1018
+ s.cssText = v;
1019
+ for (var i = 0;i < s.length; i++) {
1020
+ out[s[i]] = [s.getPropertyValue(s[i]), s.getPropertyPriority(s[i])];
1021
+ }
1022
+ } else if (Array.isArray(v)) {
1023
+ v.forEach(function(x) {
1024
+ styleMap(x, out);
1025
+ });
1026
+ } else if (v && typeof v === "object") {
1027
+ for (var k in v) {
1028
+ out[/^--/.test(k) ? k : k.replace(/[A-Z]/g, "-$&").toLowerCase()] = v[k] == null || v[k] === false ? null : [String(v[k]), ""];
952
1029
  }
953
1030
  }
1031
+ return out;
1032
+ }
1033
+ function applyStyleBinding(el, value, prev) {
1034
+ var next = styleMap(value, {}), p;
1035
+ for (p in prev)
1036
+ if (prev[p] && !(p in next))
1037
+ el.style.removeProperty(p);
1038
+ for (p in next) {
1039
+ if (next[p])
1040
+ el.style.setProperty(p, next[p][0], next[p][1]);
1041
+ else
1042
+ el.style.removeProperty(p);
1043
+ }
1044
+ return next;
954
1045
  }
955
1046
  var KEY_MAP = {
956
1047
  enter: "Enter",
@@ -1065,32 +1156,26 @@ var require_faqir_core = __commonJS((exports, module) => {
1065
1156
  }
1066
1157
  function handleRef(el, dir, scope) {
1067
1158
  var name = dir.expression;
1068
- var root = findScopeRoot(el);
1069
- if (!root.__faqirRefs)
1070
- root.__faqirRefs = {};
1071
- root.__faqirRefs[name] = el;
1159
+ var refs = reactive(getScopeRefs(scopeRoots.get(scope) || findScopeRoot(el)));
1160
+ refs[name] = el;
1072
1161
  addCleanup(el, function() {
1073
- if (root.__faqirRefs && root.__faqirRefs[name] === el) {
1074
- delete root.__faqirRefs[name];
1162
+ if (refs.__target[name] === el) {
1163
+ refs[name] = undefined;
1164
+ delete refs.__target[name];
1075
1165
  }
1076
1166
  });
1077
1167
  }
1078
1168
  function handleInit(el, dir, scope) {
1079
- evaluateAssignment(dir.expression, scope, el);
1080
- }
1081
- function handleEffect(el, dir, scope) {
1082
- var cl = effect(function() {
1169
+ runInit(function() {
1083
1170
  evaluateAssignment(dir.expression, scope, el);
1084
1171
  });
1085
- addCleanup(el, cl);
1086
1172
  }
1087
- function injectCloakStyle() {
1088
- if (document.querySelector("style[data-faqir-cloak]"))
1089
- return;
1090
- var style = document.createElement("style");
1091
- style.setAttribute("data-faqir-cloak", "");
1092
- style.textContent = "[l-cloak] { display: none !important; }";
1093
- document.head.appendChild(style);
1173
+ function handleEffect(el, dir, scope) {
1174
+ runInit(function() {
1175
+ addCleanup(el, effect(function() {
1176
+ evaluateAssignment(dir.expression, scope, el);
1177
+ }));
1178
+ });
1094
1179
  }
1095
1180
  function removeCloaks(within) {
1096
1181
  var host = within || document;
@@ -1184,10 +1269,10 @@ var require_faqir_core = __commonJS((exports, module) => {
1184
1269
  function handleModel(el, dir, scope) {
1185
1270
  var prop = dir.expression;
1186
1271
  var modifiers = new Set(dir.modifiers);
1187
- function bind(eventName2, handler) {
1188
- el.addEventListener(eventName2, handler);
1272
+ function bind(eventName, handler) {
1273
+ el.addEventListener(eventName, handler);
1189
1274
  addCleanup(el, function() {
1190
- el.removeEventListener(eventName2, handler);
1275
+ el.removeEventListener(eventName, handler);
1191
1276
  });
1192
1277
  }
1193
1278
  var tag = el.tagName.toLowerCase();
@@ -1196,7 +1281,7 @@ var require_faqir_core = __commonJS((exports, module) => {
1196
1281
  if (isFaqirSwitch) {
1197
1282
  var cl = effect(function() {
1198
1283
  var value = evaluate(prop, scope, el);
1199
- el.checked = !!value;
1284
+ writeProp(el, "checked", !!value);
1200
1285
  el.dataset.state = value ? "on" : "off";
1201
1286
  el.setAttribute("aria-checked", value ? "true" : "false");
1202
1287
  });
@@ -1207,11 +1292,7 @@ var require_faqir_core = __commonJS((exports, module) => {
1207
1292
  } else if (tag === "input" && type === "checkbox") {
1208
1293
  var cl = effect(function() {
1209
1294
  var current = evaluate(prop, scope, el);
1210
- if (Array.isArray(current)) {
1211
- el.checked = current.indexOf(el.value) >= 0;
1212
- } else {
1213
- el.checked = !!current;
1214
- }
1295
+ writeProp(el, "checked", Array.isArray(current) ? current.indexOf(el.value) >= 0 : !!current);
1215
1296
  });
1216
1297
  bind("change", function() {
1217
1298
  var current = evaluate(prop, scope, el);
@@ -1230,7 +1311,7 @@ var require_faqir_core = __commonJS((exports, module) => {
1230
1311
  addCleanup(el, cl);
1231
1312
  } else if (tag === "input" && type === "radio") {
1232
1313
  var cl = effect(function() {
1233
- el.checked = evaluate(prop, scope, el) === el.value;
1314
+ writeProp(el, "checked", evaluate(prop, scope, el) === el.value);
1234
1315
  });
1235
1316
  bind("change", function() {
1236
1317
  if (el.checked) {
@@ -1240,7 +1321,7 @@ var require_faqir_core = __commonJS((exports, module) => {
1240
1321
  addCleanup(el, cl);
1241
1322
  } else if (tag === "select") {
1242
1323
  var cl = effect(function() {
1243
- el.value = evaluate(prop, scope, el) || "";
1324
+ writeProp(el, "value", evaluate(prop, scope, el) || "");
1244
1325
  });
1245
1326
  bind("change", function() {
1246
1327
  writeModel(prop, el.value, scope, el);
@@ -1303,30 +1384,32 @@ var require_faqir_core = __commonJS((exports, module) => {
1303
1384
  var cl = effect(function() {
1304
1385
  var value = evaluate(dir.expression, scope, el);
1305
1386
  if (value) {
1306
- if (insertedNodes.length === 0) {
1307
- var fragment = el.content.cloneNode(true);
1308
- var nodes = [].slice.call(fragment.childNodes);
1309
- for (var i = 0;i < nodes.length; i++) {
1310
- if (nodes[i].nodeType !== 1)
1311
- continue;
1312
- if (nodes[i].hasAttribute("l-data")) {
1313
- initTree(nodes[i], scope);
1314
- continue;
1387
+ if (insertedNodes.length === 0)
1388
+ renderThenInit(function() {
1389
+ var fragment = el.content.cloneNode(true);
1390
+ var nodes = [].slice.call(fragment.childNodes);
1391
+ for (var i = 0;i < nodes.length; i++) {
1392
+ if (nodes[i].nodeType !== 1)
1393
+ continue;
1394
+ if (nodes[i].hasAttribute("l-data")) {
1395
+ initTree(nodes[i], scope);
1396
+ continue;
1397
+ }
1398
+ nodes[i].__faqirScope = scope;
1399
+ nodes[i].__faqirCleanups = nodes[i].__faqirCleanups || [];
1400
+ processElement(nodes[i], scope);
1401
+ if (nodes[i].parentNode)
1402
+ walkChildren(nodes[i], scope);
1315
1403
  }
1316
- nodes[i].__faqirScope = scope;
1317
- nodes[i].__faqirCleanups = nodes[i].__faqirCleanups || [];
1318
- processElement(nodes[i], scope);
1319
- if (nodes[i].parentNode)
1320
- walkChildren(nodes[i], scope);
1321
- }
1322
- insertedNodes = [].slice.call(fragment.childNodes);
1323
- anchor.parentNode.insertBefore(fragment, anchor.nextSibling);
1324
- for (var i = 0;i < insertedNodes.length; i++) {
1325
- if (insertedNodes[i].nodeType === 1 && insertedNodes[i].hasAttribute("l-transition")) {
1326
- runEnterTransition(insertedNodes[i]);
1404
+ insertedNodes = [].slice.call(fragment.childNodes);
1405
+ anchor.parentNode.insertBefore(fragment, anchor.nextSibling);
1406
+ for (var i = 0;i < insertedNodes.length; i++) {
1407
+ if (insertedNodes[i].nodeType === 1 && insertedNodes[i].hasAttribute("l-transition")) {
1408
+ runEnterTransition(insertedNodes[i]);
1409
+ }
1327
1410
  }
1328
- }
1329
- }
1411
+ return insertedNodes;
1412
+ });
1330
1413
  } else {
1331
1414
  for (var i = 0;i < insertedNodes.length; i++) {
1332
1415
  var node = insertedNodes[i];
@@ -1472,6 +1555,7 @@ var require_faqir_core = __commonJS((exports, module) => {
1472
1555
  own[itemName] = item;
1473
1556
  own[indexName] = i;
1474
1557
  var childScope = createForItemScope(own, scope);
1558
+ scopeRoots.set(childScope, scopeRoots.get(scope));
1475
1559
  for (var j = 0;j < nodes.length; j++) {
1476
1560
  if (nodes[j].nodeType !== 1)
1477
1561
  continue;
@@ -1488,10 +1572,10 @@ var require_faqir_core = __commonJS((exports, module) => {
1488
1572
  return { key, scope: childScope, nodes: [].slice.call(clone.childNodes) };
1489
1573
  }
1490
1574
  var currentEntries = [];
1491
- var cl = effect(function() {
1575
+ function renderList() {
1492
1576
  var list = evaluate(listExpr, scope, el);
1493
- var items = Array.isArray(list) ? list : typeof list === "number" ? Array.from({ length: list }, function(_, i2) {
1494
- return i2 + 1;
1577
+ var items = Array.isArray(list) ? list : typeof list === "number" ? Array.from({ length: list }, function(_, i) {
1578
+ return i + 1;
1495
1579
  }) : [];
1496
1580
  var oldMap = new Map;
1497
1581
  for (var i = 0;i < currentEntries.length; i++) {
@@ -1518,11 +1602,11 @@ var require_faqir_core = __commonJS((exports, module) => {
1518
1602
  }
1519
1603
  newEntries[i] = entry;
1520
1604
  }
1521
- oldMap.forEach(function(olds2) {
1522
- for (var e = 0;e < olds2.length; e++) {
1523
- for (var j2 = 0;j2 < olds2[e].nodes.length; j2++) {
1524
- destroyScope(olds2[e].nodes[j2]);
1525
- olds2[e].nodes[j2].remove();
1605
+ oldMap.forEach(function(olds) {
1606
+ for (var e = 0;e < olds.length; e++) {
1607
+ for (var j = 0;j < olds[e].nodes.length; j++) {
1608
+ destroyScope(olds[e].nodes[j]);
1609
+ olds[e].nodes[j].remove();
1526
1610
  }
1527
1611
  }
1528
1612
  });
@@ -1542,6 +1626,14 @@ var require_faqir_core = __commonJS((exports, module) => {
1542
1626
  nextNode = entry.nodes[0];
1543
1627
  }
1544
1628
  currentEntries = newEntries;
1629
+ var fresh = [];
1630
+ for (var i = 0;i < n; i++)
1631
+ if (!source[i])
1632
+ fresh.push.apply(fresh, newEntries[i].nodes);
1633
+ return fresh;
1634
+ }
1635
+ var cl = effect(function() {
1636
+ renderThenInit(renderList);
1545
1637
  });
1546
1638
  addCleanup(el, cl, anchor);
1547
1639
  }
@@ -1633,47 +1725,14 @@ var require_faqir_core = __commonJS((exports, module) => {
1633
1725
  scheduleFlush();
1634
1726
  }
1635
1727
  }
1636
- var $ = function(selector, scope) {
1637
- return (scope || document).querySelector(selector);
1638
- };
1639
1728
  var $$ = function(selector, scope) {
1640
1729
  return [].slice.call((scope || document).querySelectorAll(selector));
1641
1730
  };
1642
- function create(tag, attrs) {
1643
- var el = document.createElement(tag);
1644
- if (attrs) {
1645
- var keys = Object.keys(attrs);
1646
- for (var i = 0;i < keys.length; i++) {
1647
- el.setAttribute(keys[i], attrs[keys[i]]);
1648
- }
1649
- }
1650
- for (var j = 2;j < arguments.length; j++) {
1651
- var child = arguments[j];
1652
- el.append(typeof child === "string" ? document.createTextNode(child) : child);
1653
- }
1654
- return el;
1655
- }
1656
- function delegate(root, event, selector, handler) {
1657
- function listener(e) {
1658
- var target = e.target.closest(selector);
1659
- if (target && root.contains(target))
1660
- handler(e, target);
1661
- }
1662
- root.addEventListener(event, listener);
1663
- return function() {
1664
- root.removeEventListener(event, listener);
1665
- };
1666
- }
1667
- function once(el, event, handler) {
1668
- function listener(e) {
1669
- cleanupOnce();
1670
- handler(e);
1671
- }
1672
- function cleanupOnce() {
1673
- el.removeEventListener(event, listener);
1674
- }
1675
- el.addEventListener(event, listener);
1676
- return cleanupOnce;
1731
+ var OWNER = "[data-ui]:not([data-ui=stack],[data-ui=cluster],[data-ui=grid],[data-ui=container],[data-ui=surface],[data-ui=switcher],[data-ui=aspect-ratio])";
1732
+ function ownParts(root, part) {
1733
+ return $$("[data-part='" + part + "']", root).filter(function(el) {
1734
+ return el.parentElement.closest(OWNER) === root;
1735
+ });
1677
1736
  }
1678
1737
  function onOutsideClick(el, handler) {
1679
1738
  function listener(e) {
@@ -1731,24 +1790,9 @@ var require_faqir_core = __commonJS((exports, module) => {
1731
1790
  container.removeEventListener("keydown", onKeyDown);
1732
1791
  };
1733
1792
  }
1734
- function waitForTransition(el) {
1735
- if (prefersReducedMotion())
1736
- return Promise.resolve();
1737
- var style = getComputedStyle(el);
1738
- var hasDuration = parseFloat(style.transitionDuration) > 0 || style.animationName !== "none" && parseFloat(style.animationDuration) > 0;
1739
- if (!hasDuration)
1740
- return Promise.resolve();
1741
- return new Promise(function(resolve) {
1742
- function done(e) {
1743
- if (e.target !== el)
1744
- return;
1745
- el.removeEventListener("transitionend", done);
1746
- el.removeEventListener("animationend", done);
1747
- resolve();
1748
- }
1749
- el.addEventListener("transitionend", done);
1750
- el.addEventListener("animationend", done);
1751
- });
1793
+ function returnFocus(root, target, active) {
1794
+ if ((!active || active === document.body || root.contains(active)) && target && target.isConnected && !target.closest("[hidden]"))
1795
+ target.focus();
1752
1796
  }
1753
1797
  var EXIT_EVENTS = ["transitionend", "transitioncancel", "animationend", "animationcancel"];
1754
1798
  function longestTimeMs(value) {
@@ -1779,8 +1823,8 @@ var require_faqir_core = __commonJS((exports, module) => {
1779
1823
  clearTimeout(timer);
1780
1824
  timer = null;
1781
1825
  }
1782
- for (var i2 = 0;i2 < EXIT_EVENTS.length; i2++)
1783
- el.removeEventListener(EXIT_EVENTS[i2], onMotionEvent);
1826
+ for (var i = 0;i < EXIT_EVENTS.length; i++)
1827
+ el.removeEventListener(EXIT_EVENTS[i], onMotionEvent);
1784
1828
  }
1785
1829
  function settle() {
1786
1830
  if (settled)
@@ -1866,7 +1910,7 @@ var require_faqir_core = __commonJS((exports, module) => {
1866
1910
  function currentIndex() {
1867
1911
  return items().indexOf(current());
1868
1912
  }
1869
- function focusFirst2() {
1913
+ function focusFirst() {
1870
1914
  return focus(0);
1871
1915
  }
1872
1916
  function focusLast() {
@@ -1916,7 +1960,7 @@ var require_faqir_core = __commonJS((exports, module) => {
1916
1960
  }
1917
1961
  if (event.key === "Home") {
1918
1962
  event.preventDefault();
1919
- focusFirst2();
1963
+ focusFirst();
1920
1964
  return;
1921
1965
  }
1922
1966
  if (event.key === "End") {
@@ -1953,7 +1997,7 @@ var require_faqir_core = __commonJS((exports, module) => {
1953
1997
  current,
1954
1998
  sync,
1955
1999
  focus,
1956
- focusFirst: focusFirst2,
2000
+ focusFirst,
1957
2001
  focusLast,
1958
2002
  focusNext,
1959
2003
  focusPrevious,
@@ -1962,10 +2006,10 @@ var require_faqir_core = __commonJS((exports, module) => {
1962
2006
  }
1963
2007
  var controllerRegistry = {};
1964
2008
  var createAccordion = controllerRegistry["accordion"] = function() {
1965
- function createAccordion2(root) {
2009
+ function createAccordion(root) {
1966
2010
  if (root._faqirAccordion)
1967
2011
  return root._faqirAccordion;
1968
- const getItems = () => [...root.querySelectorAll("[data-part='item']")];
2012
+ const getItems = () => [...root.querySelectorAll(":scope > [data-part='item']")];
1969
2013
  const isSingle = () => root.dataset.variant === "single";
1970
2014
  function expand(index) {
1971
2015
  const items = getItems();
@@ -2021,30 +2065,24 @@ var require_faqir_core = __commonJS((exports, module) => {
2021
2065
  if (content)
2022
2066
  content.hidden = true;
2023
2067
  }
2024
- function onTriggerClick(e) {
2068
+ function triggerIndex(e) {
2025
2069
  const trigger = e.target.closest("[data-part='trigger']");
2026
- if (!trigger)
2027
- return;
2028
- const item = trigger.closest("[data-part='item']");
2029
- if (!item)
2030
- return;
2031
- const items = getItems();
2032
- const index = items.indexOf(item);
2070
+ const item = trigger?.closest("[data-part='item']");
2071
+ if (!item || item.querySelector("[data-part='trigger']") !== trigger)
2072
+ return -1;
2073
+ return getItems().indexOf(item);
2074
+ }
2075
+ function onTriggerClick(e) {
2076
+ const index = triggerIndex(e);
2033
2077
  if (index >= 0)
2034
2078
  toggle(index);
2035
2079
  }
2036
2080
  function onKeyDown(e) {
2037
2081
  if (e.key === "Enter" || e.key === " ") {
2038
- const trigger = e.target.closest("[data-part='trigger']");
2039
- if (trigger) {
2082
+ const index = triggerIndex(e);
2083
+ if (index >= 0) {
2040
2084
  e.preventDefault();
2041
- const item = trigger.closest("[data-part='item']");
2042
- if (!item)
2043
- return;
2044
- const items = getItems();
2045
- const index = items.indexOf(item);
2046
- if (index >= 0)
2047
- toggle(index);
2085
+ toggle(index);
2048
2086
  }
2049
2087
  }
2050
2088
  }
@@ -2059,17 +2097,17 @@ var require_faqir_core = __commonJS((exports, module) => {
2059
2097
  root._faqirAccordion = api;
2060
2098
  return api;
2061
2099
  }
2062
- return createAccordion2;
2100
+ return createAccordion;
2063
2101
  }();
2064
2102
  var createAlertDialog = controllerRegistry["alert-dialog"] = function() {
2065
- function createAlertDialog2(root) {
2103
+ function createAlertDialog(root) {
2066
2104
  const dialogFactory = typeof createDialog === "function" && createDialog || typeof controllerRegistry !== "undefined" && controllerRegistry["dialog"];
2067
2105
  if (typeof dialogFactory !== "function") {
2068
2106
  throw new Error("alert-dialog requires the dialog controller to be available");
2069
2107
  }
2070
2108
  return dialogFactory(root);
2071
2109
  }
2072
- return createAlertDialog2;
2110
+ return createAlertDialog;
2073
2111
  }();
2074
2112
  var createBarcode = controllerRegistry["barcode"] = function() {
2075
2113
  const CODE128_PATTERNS = Object.freeze([
@@ -2204,7 +2242,7 @@ var require_faqir_core = __commonJS((exports, module) => {
2204
2242
  weighted += data[i] * (i + 1);
2205
2243
  const checksum = weighted % 103;
2206
2244
  const codewords = [START_B, ...data, checksum, STOP];
2207
- const pattern = codewords.map((value2) => CODE128_PATTERNS[value2]).join("");
2245
+ const pattern = codewords.map((value) => CODE128_PATTERNS[value]).join("");
2208
2246
  return { checksum, codewords, pattern };
2209
2247
  }
2210
2248
  function patternToSVG(encoded) {
@@ -2242,7 +2280,7 @@ var require_faqir_core = __commonJS((exports, module) => {
2242
2280
  svg.appendChild(bars);
2243
2281
  return svg;
2244
2282
  }
2245
- function createBarcode2(root) {
2283
+ function createBarcode(root) {
2246
2284
  if (root._faqirBarcode)
2247
2285
  return root._faqirBarcode;
2248
2286
  function removeGeneratedSVG() {
@@ -2293,7 +2331,7 @@ var require_faqir_core = __commonJS((exports, module) => {
2293
2331
  render();
2294
2332
  return api;
2295
2333
  }
2296
- return createBarcode2;
2334
+ return createBarcode;
2297
2335
  }();
2298
2336
  var createCalendar = controllerRegistry["calendar"] = function() {
2299
2337
  const MONTH_NAMES = [
@@ -2325,7 +2363,7 @@ var require_faqir_core = __commonJS((exports, module) => {
2325
2363
  const d = new Date(str + "T00:00:00");
2326
2364
  return isNaN(d.getTime()) ? null : d;
2327
2365
  }
2328
- function createCalendar2(root) {
2366
+ function createCalendar(root) {
2329
2367
  if (root._faqirCalendar)
2330
2368
  return root._faqirCalendar;
2331
2369
  const navPrev = root.querySelector("[data-part='nav-prev']");
@@ -2507,12 +2545,12 @@ var require_faqir_core = __commonJS((exports, module) => {
2507
2545
  viewYear = target.getFullYear();
2508
2546
  buildGrid();
2509
2547
  } else {
2510
- gridBody.querySelectorAll("[data-part='day']").forEach((btn3) => {
2511
- btn3.tabIndex = -1;
2548
+ gridBody.querySelectorAll("[data-part='day']").forEach((btn) => {
2549
+ btn.tabIndex = -1;
2512
2550
  });
2513
- const btn2 = dayButton(target);
2514
- if (btn2)
2515
- btn2.tabIndex = 0;
2551
+ const btn = dayButton(target);
2552
+ if (btn)
2553
+ btn.tabIndex = 0;
2516
2554
  }
2517
2555
  const btn = dayButton(target);
2518
2556
  if (btn)
@@ -2734,22 +2772,22 @@ var require_faqir_core = __commonJS((exports, module) => {
2734
2772
  root._faqirCalendar = api;
2735
2773
  return api;
2736
2774
  }
2737
- return createCalendar2;
2775
+ return createCalendar;
2738
2776
  }();
2739
2777
  var createCarousel = controllerRegistry["carousel"] = function() {
2740
- function createCarousel2(root) {
2778
+ function createCarousel(root) {
2741
2779
  if (root._faqirCarousel)
2742
2780
  return root._faqirCarousel;
2743
2781
  const viewport = root.querySelector("[data-part='viewport']");
2744
2782
  if (!viewport)
2745
2783
  return null;
2746
2784
  const loop = root.hasAttribute("data-loop");
2747
- const slides = () => [...viewport.querySelectorAll("[data-part='slide']")];
2748
- const dots = () => [...root.querySelectorAll("[data-part='dot']")];
2749
- const prevBtn = root.querySelector("[data-part='prev']");
2750
- const nextBtn = root.querySelector("[data-part='next']");
2751
- const status = root.querySelector("[data-part='status']");
2752
- const enhanced = [...root.querySelectorAll("[data-part='controls'], [data-part='dots']")];
2785
+ const slides = () => [...viewport.querySelectorAll(":scope > [data-part='slide']")];
2786
+ const dots = () => ownParts(root, "dot");
2787
+ const [prevBtn] = ownParts(root, "prev");
2788
+ const [nextBtn] = ownParts(root, "next");
2789
+ const [status] = ownParts(root, "status");
2790
+ const enhanced = [...ownParts(root, "controls"), ...ownParts(root, "dots")];
2753
2791
  let index = 0;
2754
2792
  const reducedMotion = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && !!window.matchMedia("(prefers-reduced-motion: reduce)").matches;
2755
2793
  const isRtl = () => {
@@ -2826,16 +2864,14 @@ var require_faqir_core = __commonJS((exports, module) => {
2826
2864
  const next = () => goTo(index + 1);
2827
2865
  const prev = () => goTo(index - 1);
2828
2866
  function onClick(e) {
2829
- const btn = e.target.closest && e.target.closest("[data-part]");
2830
- if (!btn || !root.contains(btn))
2831
- return;
2832
- const part = btn.dataset.part;
2833
- if (part === "next")
2867
+ const btn = e.target.closest("[data-part]");
2868
+ const dot = dots().indexOf(btn);
2869
+ if (btn === nextBtn)
2834
2870
  next();
2835
- else if (part === "prev")
2871
+ else if (btn === prevBtn)
2836
2872
  prev();
2837
- else if (part === "dot")
2838
- goTo(dots().indexOf(btn));
2873
+ else if (dot >= 0)
2874
+ goTo(dot);
2839
2875
  }
2840
2876
  const schedule = typeof requestAnimationFrame === "function" ? requestAnimationFrame : (fn) => setTimeout(fn, 16);
2841
2877
  let ticking = false;
@@ -2866,10 +2902,10 @@ var require_faqir_core = __commonJS((exports, module) => {
2866
2902
  root._faqirCarousel = api;
2867
2903
  return api;
2868
2904
  }
2869
- return createCarousel2;
2905
+ return createCarousel;
2870
2906
  }();
2871
2907
  var createCombobox = controllerRegistry["combobox"] = function() {
2872
- function createCombobox2(root) {
2908
+ function createCombobox(root) {
2873
2909
  if (root._faqirCombobox)
2874
2910
  return root._faqirCombobox;
2875
2911
  const input = root.querySelector("[data-part='input']");
@@ -3055,10 +3091,10 @@ var require_faqir_core = __commonJS((exports, module) => {
3055
3091
  root._faqirCombobox = api;
3056
3092
  return api;
3057
3093
  }
3058
- return createCombobox2;
3094
+ return createCombobox;
3059
3095
  }();
3060
3096
  var createCommandPalette = controllerRegistry["command-palette"] = function() {
3061
- function createCommandPalette2(root) {
3097
+ function createCommandPalette(root) {
3062
3098
  if (root._faqirCommandPalette)
3063
3099
  return root._faqirCommandPalette;
3064
3100
  const overlay = root.querySelector("[data-part='overlay']");
@@ -3094,8 +3130,9 @@ var require_faqir_core = __commonJS((exports, module) => {
3094
3130
  }
3095
3131
  }
3096
3132
  function close() {
3133
+ const active = document.activeElement;
3097
3134
  dismiss();
3098
- previouslyFocused?.focus();
3135
+ returnFocus(root, previouslyFocused, active);
3099
3136
  }
3100
3137
  function itemId(item) {
3101
3138
  if (!item.id)
@@ -3250,13 +3287,18 @@ var require_faqir_core = __commonJS((exports, module) => {
3250
3287
  }
3251
3288
  }
3252
3289
  function onGlobalKeyDown(e) {
3253
- if ((e.metaKey || e.ctrlKey) && e.key === "k") {
3254
- e.preventDefault();
3255
- if (root.dataset.state === "open") {
3256
- close();
3257
- } else {
3258
- open();
3259
- }
3290
+ if (e.defaultPrevented || !root.isConnected || root.hasAttribute("data-no-shortcut"))
3291
+ return;
3292
+ if (!(e.metaKey || e.ctrlKey) || e.altKey || e.shiftKey || e.repeat || e.isComposing)
3293
+ return;
3294
+ const k = (e.key || "").toLowerCase();
3295
+ if (k !== "k" && (/^[a-z]$/.test(k) || e.code !== "KeyK"))
3296
+ return;
3297
+ e.preventDefault();
3298
+ if (root.dataset.state === "open") {
3299
+ close();
3300
+ } else {
3301
+ open();
3260
3302
  }
3261
3303
  }
3262
3304
  searchInput?.addEventListener("input", onSearchInput);
@@ -3279,14 +3321,14 @@ var require_faqir_core = __commonJS((exports, module) => {
3279
3321
  root._faqirCommandPalette = api;
3280
3322
  return api;
3281
3323
  }
3282
- return createCommandPalette2;
3324
+ return createCommandPalette;
3283
3325
  }();
3284
3326
  var createContextMenu = controllerRegistry["context-menu"] = function() {
3285
- function createContextMenu2(root) {
3327
+ function createContextMenu(root) {
3286
3328
  if (root._faqirContextMenu)
3287
3329
  return root._faqirContextMenu;
3288
- const target = root.querySelector("[data-part='target']");
3289
- const menu = root.querySelector("[data-part='menu']");
3330
+ const [target] = ownParts(root, "target");
3331
+ const [menu] = ownParts(root, "menu");
3290
3332
  if (!target || !menu) {
3291
3333
  console.warn("[Faqir] context-menu needs [data-part='target'] and [data-part='menu'] — " + `missing ${[!target && "target", !menu && "menu"].filter(Boolean).join(" and ")}. ` + "Component left inert.", root);
3292
3334
  const inert = { open() {}, close() {}, destroy() {} };
@@ -3370,7 +3412,7 @@ var require_faqir_core = __commonJS((exports, module) => {
3370
3412
  root._faqirContextMenu = api;
3371
3413
  return api;
3372
3414
  }
3373
- return createContextMenu2;
3415
+ return createContextMenu;
3374
3416
  }();
3375
3417
  var createDatePicker = controllerRegistry["date-picker"] = function() {
3376
3418
  const MONTH_NAMES = [
@@ -3387,7 +3429,7 @@ var require_faqir_core = __commonJS((exports, module) => {
3387
3429
  "November",
3388
3430
  "December"
3389
3431
  ];
3390
- function createDatePicker2(root) {
3432
+ function createDatePicker(root) {
3391
3433
  if (root._faqirDatePicker)
3392
3434
  return root._faqirDatePicker;
3393
3435
  const trigger = root.querySelector("[data-part='trigger']");
@@ -3495,19 +3537,21 @@ var require_faqir_core = __commonJS((exports, module) => {
3495
3537
  root._faqirDatePicker = api;
3496
3538
  return api;
3497
3539
  }
3498
- return createDatePicker2;
3540
+ return createDatePicker;
3499
3541
  }();
3500
3542
  var createDialog = controllerRegistry["dialog"] = function() {
3501
- function createDialog2(root) {
3543
+ function createDialog(root) {
3502
3544
  if (root._faqirDialog)
3503
3545
  return root._faqirDialog;
3504
- const trigger = root.querySelector("[data-part='trigger']");
3505
- const overlay = root.querySelector("[data-part='overlay']");
3506
- const panel = root.querySelector("[data-part='panel']");
3507
- const closeButtons = root.querySelectorAll("[data-part='close']");
3508
- const confirmButtons = root.querySelectorAll("[data-part='confirm']");
3509
- const cancelButtons = root.querySelectorAll("[data-part='cancel']");
3546
+ const [trigger] = ownParts(root, "trigger");
3547
+ const overlay = root.querySelector(":scope > [data-part='overlay']");
3548
+ const panel = root.querySelector(":scope > [data-part='panel']");
3549
+ const closeButtons = ownParts(root, "close");
3550
+ const confirmButtons = ownParts(root, "confirm");
3551
+ const cancelButtons = ownParts(root, "cancel");
3510
3552
  const isAlert = !!panel && panel.getAttribute("role") === "alertdialog";
3553
+ if (panel && !panel.hasAttribute("tabindex"))
3554
+ panel.setAttribute("tabindex", "-1");
3511
3555
  let focusCleanup = null;
3512
3556
  let previouslyFocused = null;
3513
3557
  function confirmRequired() {
@@ -3524,7 +3568,7 @@ var require_faqir_core = __commonJS((exports, module) => {
3524
3568
  }
3525
3569
  function focusInitial() {
3526
3570
  if (isAlert) {
3527
- const target = root.querySelector("[data-part='cancel']") || root.querySelector("[data-part='close']") || panel;
3571
+ const target = cancelButtons[0] || closeButtons[0] || panel;
3528
3572
  target?.focus?.();
3529
3573
  } else {
3530
3574
  panel?.focus?.();
@@ -3551,13 +3595,14 @@ var require_faqir_core = __commonJS((exports, module) => {
3551
3595
  root.dataset.state = "closing";
3552
3596
  const onEnd = () => {
3553
3597
  cancelExitWait = null;
3598
+ const active = document.activeElement;
3554
3599
  root.dataset.state = "closed";
3555
3600
  overlay.hidden = true;
3556
3601
  panel.hidden = true;
3557
3602
  if (focusCleanup)
3558
3603
  focusCleanup();
3559
3604
  focusCleanup = null;
3560
- previouslyFocused?.focus();
3605
+ returnFocus(root, previouslyFocused, active);
3561
3606
  };
3562
3607
  cancelExitWait = whenExitDone(panel, null, onEnd);
3563
3608
  }
@@ -3638,16 +3683,18 @@ var require_faqir_core = __commonJS((exports, module) => {
3638
3683
  root._faqirDialog = api;
3639
3684
  return api;
3640
3685
  }
3641
- return createDialog2;
3686
+ return createDialog;
3642
3687
  }();
3643
3688
  var createDrawer = controllerRegistry["drawer"] = function() {
3644
- function createDrawer2(root) {
3689
+ function createDrawer(root) {
3645
3690
  if (root._faqirDrawer)
3646
3691
  return root._faqirDrawer;
3647
- const trigger = root.querySelector("[data-part='trigger']");
3648
- const overlay = root.querySelector("[data-part='overlay']");
3649
- const panel = root.querySelector("[data-part='panel']");
3650
- const closeButtons = root.querySelectorAll("[data-part='close']");
3692
+ const [trigger] = ownParts(root, "trigger");
3693
+ const overlay = root.querySelector(":scope > [data-part='overlay']");
3694
+ const panel = root.querySelector(":scope > [data-part='panel']");
3695
+ const closeButtons = ownParts(root, "close");
3696
+ if (panel && !panel.hasAttribute("tabindex"))
3697
+ panel.setAttribute("tabindex", "-1");
3651
3698
  let focusCleanup = null;
3652
3699
  let previouslyFocused = null;
3653
3700
  let prevBodyOverflow = null;
@@ -3681,6 +3728,7 @@ var require_faqir_core = __commonJS((exports, module) => {
3681
3728
  root.dataset.state = "closing";
3682
3729
  const onEnd = () => {
3683
3730
  cancelExitWait = null;
3731
+ const active = document.activeElement;
3684
3732
  root.dataset.state = "closed";
3685
3733
  overlay.hidden = true;
3686
3734
  panel.hidden = true;
@@ -3688,7 +3736,7 @@ var require_faqir_core = __commonJS((exports, module) => {
3688
3736
  if (focusCleanup)
3689
3737
  focusCleanup();
3690
3738
  focusCleanup = null;
3691
- previouslyFocused?.focus();
3739
+ returnFocus(root, previouslyFocused, active);
3692
3740
  };
3693
3741
  cancelExitWait = whenExitDone(panel, "transform", onEnd);
3694
3742
  }
@@ -3746,10 +3794,10 @@ var require_faqir_core = __commonJS((exports, module) => {
3746
3794
  root._faqirDrawer = api;
3747
3795
  return api;
3748
3796
  }
3749
- return createDrawer2;
3797
+ return createDrawer;
3750
3798
  }();
3751
3799
  var createDropdown = controllerRegistry["dropdown"] = function() {
3752
- function createDropdown2(root) {
3800
+ function createDropdown(root) {
3753
3801
  if (root._faqirDropdown)
3754
3802
  return root._faqirDropdown;
3755
3803
  const trigger = root.querySelector("[data-part='trigger']");
@@ -3833,10 +3881,10 @@ var require_faqir_core = __commonJS((exports, module) => {
3833
3881
  root._faqirDropdown = api;
3834
3882
  return api;
3835
3883
  }
3836
- return createDropdown2;
3884
+ return createDropdown;
3837
3885
  }();
3838
3886
  var createFileUpload = controllerRegistry["file-upload"] = function() {
3839
- function createFileUpload2(root) {
3887
+ function createFileUpload(root) {
3840
3888
  if (root._faqirFileUpload)
3841
3889
  return root._faqirFileUpload;
3842
3890
  let dropzone = root.querySelector("[data-part='dropzone']");
@@ -3892,15 +3940,15 @@ var require_faqir_core = __commonJS((exports, module) => {
3892
3940
  const transfer = new DataTransfer;
3893
3941
  for (const file of files)
3894
3942
  transfer.items.add(file);
3895
- const list2 = transfer.files;
3896
- if (list2 instanceof FileList)
3897
- return list2;
3943
+ const list = transfer.files;
3944
+ if (list instanceof FileList)
3945
+ return list;
3898
3946
  try {
3899
3947
  const fallback = new FileList;
3900
3948
  fallback.push(...files);
3901
3949
  return fallback;
3902
3950
  } catch {
3903
- return list2;
3951
+ return list;
3904
3952
  }
3905
3953
  }
3906
3954
  function syncState() {
@@ -3941,14 +3989,14 @@ var require_faqir_core = __commonJS((exports, module) => {
3941
3989
  const metadata = document.createElement("span");
3942
3990
  metadata.setAttribute("data-part", "metadata");
3943
3991
  metadata.textContent = `${file.type || "Unknown type"} · ${formatSize(file.size)}`;
3944
- const remove2 = document.createElement("button");
3945
- remove2.setAttribute("data-part", "remove");
3946
- remove2.setAttribute("type", "button");
3947
- remove2.setAttribute("aria-label", `Remove ${file.name}`);
3948
- remove2.textContent = "Remove";
3949
- remove2.disabled = isDisabled();
3992
+ const remove = document.createElement("button");
3993
+ remove.setAttribute("data-part", "remove");
3994
+ remove.setAttribute("type", "button");
3995
+ remove.setAttribute("aria-label", `Remove ${file.name}`);
3996
+ remove.textContent = "Remove";
3997
+ remove.disabled = isDisabled();
3950
3998
  details.append(name, metadata);
3951
- row.append(details, remove2);
3999
+ row.append(details, remove);
3952
4000
  list.appendChild(row);
3953
4001
  }
3954
4002
  syncState();
@@ -4128,10 +4176,10 @@ var require_faqir_core = __commonJS((exports, module) => {
4128
4176
  root._faqirFileUpload = api;
4129
4177
  return api;
4130
4178
  }
4131
- return createFileUpload2;
4179
+ return createFileUpload;
4132
4180
  }();
4133
4181
  var createInputOTP = controllerRegistry["input-otp"] = function() {
4134
- function createInputOTP2(root) {
4182
+ function createInputOTP(root) {
4135
4183
  if (root._faqirInputOTP)
4136
4184
  return root._faqirInputOTP;
4137
4185
  const N = clampInt(root.getAttribute("data-length"), 6, 1, 12);
@@ -4223,9 +4271,9 @@ var require_faqir_core = __commonJS((exports, module) => {
4223
4271
  updateActive();
4224
4272
  }
4225
4273
  function updateActive() {
4226
- for (const seg2 of segments) {
4227
- seg2.removeAttribute("data-active");
4228
- seg2.removeAttribute("data-caret");
4274
+ for (const seg of segments) {
4275
+ seg.removeAttribute("data-active");
4276
+ seg.removeAttribute("data-caret");
4229
4277
  }
4230
4278
  if (!focused || isDisabled())
4231
4279
  return;
@@ -4463,10 +4511,10 @@ var require_faqir_core = __commonJS((exports, module) => {
4463
4511
  return fallback;
4464
4512
  return Math.max(lo, Math.min(hi, n));
4465
4513
  }
4466
- return createInputOTP2;
4514
+ return createInputOTP;
4467
4515
  }();
4468
4516
  var createMenubar = controllerRegistry["menubar"] = function() {
4469
- function createMenubar2(root) {
4517
+ function createMenubar(root) {
4470
4518
  if (root._faqirMenubar)
4471
4519
  return root._faqirMenubar;
4472
4520
  const submenus = [...root.querySelectorAll("[data-part='submenu'][role='menu']")].filter((menu) => menu.closest("[data-ui='menubar']") === root);
@@ -4671,10 +4719,10 @@ var require_faqir_core = __commonJS((exports, module) => {
4671
4719
  root._faqirMenubar = api;
4672
4720
  return api;
4673
4721
  }
4674
- return createMenubar2;
4722
+ return createMenubar;
4675
4723
  }();
4676
4724
  var createPagination = controllerRegistry["pagination"] = function() {
4677
- function createPagination2(root) {
4725
+ function createPagination(root) {
4678
4726
  if (root._faqirPagination)
4679
4727
  return root._faqirPagination;
4680
4728
  const nav = root.querySelector("[data-part='nav']");
@@ -4823,15 +4871,15 @@ var require_faqir_core = __commonJS((exports, module) => {
4823
4871
  ...endPages
4824
4872
  ];
4825
4873
  }
4826
- return createPagination2;
4874
+ return createPagination;
4827
4875
  }();
4828
4876
  var createPopover = controllerRegistry["popover"] = function() {
4829
- function createPopover2(root) {
4877
+ function createPopover(root) {
4830
4878
  if (root._faqirPopover)
4831
4879
  return root._faqirPopover;
4832
4880
  const trigger = root.querySelector("[data-part='trigger']");
4833
4881
  const content = root.querySelector("[data-part='content']");
4834
- const closeBtn = root.querySelector("[data-part='close']");
4882
+ const [closeBtn] = ownParts(root, "close");
4835
4883
  let outsideClickCleanup = null;
4836
4884
  function open() {
4837
4885
  root.dataset.state = "open";
@@ -4882,7 +4930,7 @@ var require_faqir_core = __commonJS((exports, module) => {
4882
4930
  root._faqirPopover = api;
4883
4931
  return api;
4884
4932
  }
4885
- return createPopover2;
4933
+ return createPopover;
4886
4934
  }();
4887
4935
  var createQRCode = controllerRegistry["qr-code"] = function() {
4888
4936
  const EXP = new Uint8Array(256);
@@ -5230,7 +5278,7 @@ var require_faqir_core = __commonJS((exports, module) => {
5230
5278
  svg.appendChild(path);
5231
5279
  return svg;
5232
5280
  }
5233
- function createQRCode2(root) {
5281
+ function createQRCode(root) {
5234
5282
  if (root._faqirQR)
5235
5283
  return root._faqirQR;
5236
5284
  function render() {
@@ -5282,10 +5330,10 @@ var require_faqir_core = __commonJS((exports, module) => {
5282
5330
  root._faqirQR = api;
5283
5331
  return api;
5284
5332
  }
5285
- return createQRCode2;
5333
+ return createQRCode;
5286
5334
  }();
5287
5335
  var createSelectCustom = controllerRegistry["select-custom"] = function() {
5288
- function createSelectCustom2(root) {
5336
+ function createSelectCustom(root) {
5289
5337
  if (root._faqirSelectCustom)
5290
5338
  return root._faqirSelectCustom;
5291
5339
  const trigger = root.querySelector("[data-part='trigger']");
@@ -5529,16 +5577,18 @@ var require_faqir_core = __commonJS((exports, module) => {
5529
5577
  root._faqirSelectCustom = api;
5530
5578
  return api;
5531
5579
  }
5532
- return createSelectCustom2;
5580
+ return createSelectCustom;
5533
5581
  }();
5534
5582
  var createSheet = controllerRegistry["sheet"] = function() {
5535
- function createSheet2(root) {
5583
+ function createSheet(root) {
5536
5584
  if (root._faqirSheet)
5537
5585
  return root._faqirSheet;
5538
- const trigger = root.querySelector("[data-part='trigger']");
5539
- const overlay = root.querySelector("[data-part='overlay']");
5540
- const panel = root.querySelector("[data-part='panel']");
5541
- const closeButtons = root.querySelectorAll("[data-part='close']");
5586
+ const [trigger] = ownParts(root, "trigger");
5587
+ const overlay = root.querySelector(":scope > [data-part='overlay']");
5588
+ const panel = root.querySelector(":scope > [data-part='panel']");
5589
+ const closeButtons = ownParts(root, "close");
5590
+ if (panel && !panel.hasAttribute("tabindex"))
5591
+ panel.setAttribute("tabindex", "-1");
5542
5592
  let focusCleanup = null;
5543
5593
  let previouslyFocused = null;
5544
5594
  let prevBodyOverflow = null;
@@ -5572,6 +5622,7 @@ var require_faqir_core = __commonJS((exports, module) => {
5572
5622
  root.dataset.state = "closing";
5573
5623
  const onEnd = () => {
5574
5624
  cancelExitWait = null;
5625
+ const active = document.activeElement;
5575
5626
  root.dataset.state = "closed";
5576
5627
  overlay.hidden = true;
5577
5628
  panel.hidden = true;
@@ -5579,7 +5630,7 @@ var require_faqir_core = __commonJS((exports, module) => {
5579
5630
  if (focusCleanup)
5580
5631
  focusCleanup();
5581
5632
  focusCleanup = null;
5582
- previouslyFocused?.focus();
5633
+ returnFocus(root, previouslyFocused, active);
5583
5634
  };
5584
5635
  cancelExitWait = whenExitDone(panel, "transform", onEnd);
5585
5636
  }
@@ -5630,15 +5681,15 @@ var require_faqir_core = __commonJS((exports, module) => {
5630
5681
  root._faqirSheet = api;
5631
5682
  return api;
5632
5683
  }
5633
- return createSheet2;
5684
+ return createSheet;
5634
5685
  }();
5635
5686
  var createSidebar = controllerRegistry["sidebar"] = function() {
5636
- function createSidebar2(root) {
5687
+ function createSidebar(root) {
5637
5688
  if (root._faqirSidebar)
5638
5689
  return root._faqirSidebar;
5639
- const overlay = root.querySelector("[data-part='overlay']");
5640
- const panel = root.querySelector("[data-part='panel']") || root;
5641
- const internalTriggers = [...root.querySelectorAll("[data-part='trigger']")];
5690
+ const overlay = root.querySelector(":scope > [data-part='overlay']");
5691
+ const panel = root.querySelector(":scope > [data-part='panel']") || root;
5692
+ const internalTriggers = ownParts(root, "trigger");
5642
5693
  const externalTriggers = root.id ? [...document.querySelectorAll(`[data-sidebar-toggle="${root.id}"]`)] : [];
5643
5694
  const triggers = [...internalTriggers, ...externalTriggers];
5644
5695
  const declared = root.dataset.state || "expanded";
@@ -5788,10 +5839,10 @@ var require_faqir_core = __commonJS((exports, module) => {
5788
5839
  root._faqirSidebar = api;
5789
5840
  return api;
5790
5841
  }
5791
- return createSidebar2;
5842
+ return createSidebar;
5792
5843
  }();
5793
5844
  var createSlider = controllerRegistry["slider"] = function() {
5794
- function createSlider2(root) {
5845
+ function createSlider(root) {
5795
5846
  if (root._faqirSlider)
5796
5847
  return root._faqirSlider;
5797
5848
  const track = root.querySelector("[data-part='track']");
@@ -6081,16 +6132,17 @@ var require_faqir_core = __commonJS((exports, module) => {
6081
6132
  const n = Number(raw);
6082
6133
  return Number.isFinite(n) ? n : fallback;
6083
6134
  }
6084
- return createSlider2;
6135
+ return createSlider;
6085
6136
  }();
6086
6137
  var createTable = controllerRegistry["table"] = function() {
6087
- function createTable2(root) {
6138
+ function createTable(root) {
6088
6139
  if (root._faqirTable)
6089
6140
  return root._faqirTable;
6141
+ const mine = (el) => el.closest("[data-ui='table']") === root;
6090
6142
  const table = root.querySelector("[data-part='table']");
6091
6143
  const thead = root.querySelector("[data-part='thead']");
6092
6144
  const tbody = root.querySelector("[data-part='tbody']");
6093
- const tfoot = root.querySelector("[data-part='tfoot']");
6145
+ const tfoot = [...root.querySelectorAll("[data-part='tfoot']")].find(mine);
6094
6146
  const headerCheckbox = thead?.querySelector("[data-part='checkbox']");
6095
6147
  const opts = {
6096
6148
  multiSort: root.hasAttribute("data-multi-sort"),
@@ -6130,7 +6182,7 @@ var require_faqir_core = __commonJS((exports, module) => {
6130
6182
  const originalIndex = new WeakMap;
6131
6183
  let originSeq = 0;
6132
6184
  const collator = new Intl.Collator(opts.locale, { numeric: true, sensitivity: "base" });
6133
- const toggleAttr = (el, name, on2) => on2 ? el.setAttribute(name, "") : el.removeAttribute(name);
6185
+ const toggleAttr = (el, name, on) => on ? el.setAttribute(name, "") : el.removeAttribute(name);
6134
6186
  const later = (fn, ms) => {
6135
6187
  const t = setTimeout(() => {
6136
6188
  timers.delete(t);
@@ -6291,23 +6343,10 @@ var require_faqir_core = __commonJS((exports, module) => {
6291
6343
  return type;
6292
6344
  }
6293
6345
  function formatValue(n, fmt) {
6346
+ const o = fmt === "currency" ? { style: fmt, currency: opts.currency, currencySign: accounting ? "accounting" : "standard" } : fmt === "percent" ? { style: fmt, maximumFractionDigits: 2 } : fmt === "number" && { maximumFractionDigits: 2 };
6294
6347
  try {
6295
- if (fmt === "currency") {
6296
- return new Intl.NumberFormat(opts.locale, {
6297
- style: "currency",
6298
- currency: opts.currency,
6299
- currencySign: accounting ? "accounting" : "standard"
6300
- }).format(n);
6301
- }
6302
- if (fmt === "percent") {
6303
- return new Intl.NumberFormat(opts.locale, {
6304
- style: "percent",
6305
- maximumFractionDigits: 2
6306
- }).format(n / 100);
6307
- }
6308
- if (fmt === "number") {
6309
- return new Intl.NumberFormat(opts.locale, { maximumFractionDigits: 2 }).format(n);
6310
- }
6348
+ if (o)
6349
+ return new Intl.NumberFormat(opts.locale, o).format(fmt === "percent" ? n / 100 : n);
6311
6350
  } catch {}
6312
6351
  return String(n);
6313
6352
  }
@@ -6429,10 +6468,10 @@ var require_faqir_core = __commonJS((exports, module) => {
6429
6468
  if (!rb)
6430
6469
  return -1;
6431
6470
  if (type === "date") {
6432
- const na2 = parseDateValue(ra);
6433
- const nb2 = parseDateValue(rb);
6434
- if (!isNaN(na2) && !isNaN(nb2))
6435
- return na2 - nb2;
6471
+ const na = parseDateValue(ra);
6472
+ const nb = parseDateValue(rb);
6473
+ if (!isNaN(na) && !isNaN(nb))
6474
+ return na - nb;
6436
6475
  }
6437
6476
  const na = parseNumeric(ra);
6438
6477
  const nb = parseNumeric(rb);
@@ -6555,13 +6594,16 @@ var require_faqir_core = __commonJS((exports, module) => {
6555
6594
  });
6556
6595
  refreshStripes();
6557
6596
  }
6597
+ function sortChanged() {
6598
+ applySorts();
6599
+ emit("sort", { sorts: sorts.map((s) => ({ column: s.index, direction: s.dir })) });
6600
+ scheduleStateSave();
6601
+ }
6558
6602
  function sort(columnIndex, direction) {
6559
6603
  if (!tbody || bodyRows().length === 0)
6560
6604
  return;
6561
6605
  sorts = [{ index: columnIndex, dir: direction }];
6562
- applySorts();
6563
- emit("sort", { sorts: sorts.map((s) => ({ column: s.index, direction: s.dir })) });
6564
- scheduleStateSave();
6606
+ sortChanged();
6565
6607
  }
6566
6608
  function sortBy(specs) {
6567
6609
  if (!tbody || bodyRows().length === 0)
@@ -6570,17 +6612,13 @@ var require_faqir_core = __commonJS((exports, module) => {
6570
6612
  index: s.column != null ? s.column : s.index,
6571
6613
  dir: s.direction || s.dir || "ascending"
6572
6614
  })).filter((s) => Number.isInteger(s.index) && s.index >= 0 && s.index < columnCount());
6573
- applySorts();
6574
- emit("sort", { sorts: sorts.map((s) => ({ column: s.index, direction: s.dir })) });
6575
- scheduleStateSave();
6615
+ sortChanged();
6576
6616
  }
6577
6617
  function clearSort() {
6578
6618
  if (!sorts.length)
6579
6619
  return;
6580
6620
  sorts = [];
6581
- applySorts();
6582
- emit("sort", { sorts: [] });
6583
- scheduleStateSave();
6621
+ sortChanged();
6584
6622
  }
6585
6623
  function handleSortRequest(idx, additive) {
6586
6624
  const existing = sorts.find((s) => s.index === idx);
@@ -6601,9 +6639,7 @@ var require_faqir_core = __commonJS((exports, module) => {
6601
6639
  } else {
6602
6640
  sorts = dir === null ? [] : [{ index: idx, dir }];
6603
6641
  }
6604
- applySorts();
6605
- emit("sort", { sorts: sorts.map((s) => ({ column: s.index, direction: s.dir })) });
6606
- scheduleStateSave();
6642
+ sortChanged();
6607
6643
  }
6608
6644
  function setRowSelected(row, selected) {
6609
6645
  toggleAttr(row, "data-selected", selected);
@@ -6618,8 +6654,7 @@ var require_faqir_core = __commonJS((exports, module) => {
6618
6654
  const row = rows[index];
6619
6655
  setRowSelected(row, !row.hasAttribute("data-selected"));
6620
6656
  lastSelectedIndex = index;
6621
- updateHeaderCheckbox();
6622
- emit("selection-change", { selected: getSelected() });
6657
+ selectionChanged();
6623
6658
  }
6624
6659
  function selectAll() {
6625
6660
  const filtered = !!globalFilter || columnFilters.size > 0;
@@ -6628,15 +6663,13 @@ var require_faqir_core = __commonJS((exports, module) => {
6628
6663
  continue;
6629
6664
  setRowSelected(row, true);
6630
6665
  }
6631
- updateHeaderCheckbox();
6632
- emit("selection-change", { selected: getSelected() });
6666
+ selectionChanged();
6633
6667
  }
6634
6668
  function deselectAll() {
6635
6669
  for (const row of bodyRows())
6636
6670
  setRowSelected(row, false);
6637
6671
  lastSelectedIndex = -1;
6638
- updateHeaderCheckbox();
6639
- emit("selection-change", { selected: getSelected() });
6672
+ selectionChanged();
6640
6673
  }
6641
6674
  function getSelected() {
6642
6675
  return bodyRows().map((row, index) => ({ row, index })).filter(({ row }) => row.hasAttribute("data-selected")).map(({ index }) => index);
@@ -6649,23 +6682,18 @@ var require_faqir_core = __commonJS((exports, module) => {
6649
6682
  if (i >= 0 && i < rows.length && isRowVisible(rows[i]))
6650
6683
  setRowSelected(rows[i], true);
6651
6684
  }
6685
+ }
6686
+ function selectionChanged() {
6652
6687
  updateHeaderCheckbox();
6688
+ emit("selection-change", { selected: getSelected() });
6653
6689
  }
6654
6690
  function updateHeaderCheckbox() {
6655
6691
  if (!headerCheckbox)
6656
6692
  return;
6657
6693
  const rows = visibleBodyRows();
6658
- const selected = rows.filter((r) => r.hasAttribute("data-selected"));
6659
- if (selected.length === 0) {
6660
- headerCheckbox.checked = false;
6661
- headerCheckbox.indeterminate = false;
6662
- } else if (selected.length === rows.length) {
6663
- headerCheckbox.checked = true;
6664
- headerCheckbox.indeterminate = false;
6665
- } else {
6666
- headerCheckbox.checked = false;
6667
- headerCheckbox.indeterminate = true;
6668
- }
6694
+ const n = rows.filter((r) => r.hasAttribute("data-selected")).length;
6695
+ headerCheckbox.checked = n > 0 && n === rows.length;
6696
+ headerCheckbox.indeterminate = n > 0 && n < rows.length;
6669
6697
  }
6670
6698
  function matchQuery(cell, query, type) {
6671
6699
  const q = String(query).trim();
@@ -6762,6 +6790,7 @@ var require_faqir_core = __commonJS((exports, module) => {
6762
6790
  refreshStripes();
6763
6791
  updateHeaderCheckbox();
6764
6792
  computeAggregates();
6793
+ setupNavigability();
6765
6794
  emit("filter", { query: globalFilter, visible, total: rows.length });
6766
6795
  scheduleStateSave();
6767
6796
  }
@@ -6783,7 +6812,7 @@ var require_faqir_core = __commonJS((exports, module) => {
6783
6812
  applyFilters();
6784
6813
  }
6785
6814
  function syncFilterInputs() {
6786
- const g = root.querySelector("[data-part='filter']");
6815
+ const g = [...root.querySelectorAll("[data-part='filter']")].find(mine);
6787
6816
  if (g && g.value !== globalFilter)
6788
6817
  g.value = globalFilter;
6789
6818
  const fr = filterRowEl();
@@ -6809,6 +6838,7 @@ var require_faqir_core = __commonJS((exports, module) => {
6809
6838
  toggleAttr(m, "data-collapsed", !expand);
6810
6839
  refreshStripes();
6811
6840
  updateHeaderCheckbox();
6841
+ setupNavigability();
6812
6842
  emit("group-toggle", { group: gh, expanded: expand });
6813
6843
  }
6814
6844
  function revealChildren(row) {
@@ -6837,6 +6867,7 @@ var require_faqir_core = __commonJS((exports, module) => {
6837
6867
  }
6838
6868
  refreshStripes();
6839
6869
  updateHeaderCheckbox();
6870
+ setupNavigability();
6840
6871
  emit("tree-toggle", { row, expanded: expand });
6841
6872
  }
6842
6873
  function toggleDetail(rowOrIndex, force) {
@@ -6849,30 +6880,20 @@ var require_faqir_core = __commonJS((exports, module) => {
6849
6880
  row.querySelector("[data-part='row-toggle']")?.setAttribute("aria-expanded", String(expand));
6850
6881
  emit("row-expand", { row, detail, expanded: expand });
6851
6882
  }
6852
- function expandAll() {
6853
- mutedRun(() => {
6854
- for (const gh of groupHeaders())
6855
- toggleGroup(gh, true);
6856
- if (opts.tree) {
6857
- for (const r of bodyRows())
6858
- if (isTreeParent(r))
6859
- toggleRow(r, true);
6860
- }
6861
- });
6862
- refreshStripes();
6863
- }
6864
- function collapseAll() {
6883
+ function setAllExpanded(expand) {
6865
6884
  mutedRun(() => {
6866
6885
  for (const gh of groupHeaders())
6867
- toggleGroup(gh, false);
6886
+ toggleGroup(gh, expand);
6868
6887
  if (opts.tree) {
6869
6888
  for (const r of bodyRows())
6870
6889
  if (isTreeParent(r))
6871
- toggleRow(r, false);
6890
+ toggleRow(r, expand);
6872
6891
  }
6873
6892
  });
6874
6893
  refreshStripes();
6875
6894
  }
6895
+ const expandAll = () => setAllExpanded(true);
6896
+ const collapseAll = () => setAllExpanded(false);
6876
6897
  function writeAggregate(cell, rows, ownIndex) {
6877
6898
  const fn = cell.getAttribute("data-aggregate");
6878
6899
  const col = cell.hasAttribute("data-col") ? parseInt(cell.getAttribute("data-col"), 10) : ownIndex != null ? ownIndex : cellsOf(cell.parentElement).indexOf(cell);
@@ -6911,7 +6932,7 @@ var require_faqir_core = __commonJS((exports, module) => {
6911
6932
  return;
6912
6933
  }
6913
6934
  cell.setAttribute("data-value", String(out));
6914
- const fmt = fn === "count" ? cell.getAttribute("data-format") : cell.getAttribute("data-format") || headerCells()[col]?.getAttribute("data-format") || "number";
6935
+ const fmt = fn === "count" ? cell.getAttribute("data-format") : cellFormatOf(cell, col) || "number";
6915
6936
  cell.textContent = fmt ? formatValue(out, fmt) : String(out);
6916
6937
  applyNegativeFlag(cell);
6917
6938
  }
@@ -6986,9 +7007,9 @@ var require_faqir_core = __commonJS((exports, module) => {
6986
7007
  if (a instanceof Element)
6987
7008
  cell = a;
6988
7009
  else {
6989
- const row2 = bodyRows()[a];
6990
- if (row2)
6991
- cell = cellsOf(row2)[b] || null;
7010
+ const row = bodyRows()[a];
7011
+ if (row)
7012
+ cell = cellsOf(row)[b] || null;
6992
7013
  }
6993
7014
  if (!cell || !isCellEditable(cell))
6994
7015
  return false;
@@ -7107,17 +7128,15 @@ var require_faqir_core = __commonJS((exports, module) => {
7107
7128
  function onEditorKeydown(e) {
7108
7129
  if (!editing)
7109
7130
  return;
7131
+ e.stopPropagation();
7110
7132
  if (e.key === "Enter") {
7111
7133
  e.preventDefault();
7112
- e.stopPropagation();
7113
7134
  commitEdit(true);
7114
7135
  } else if (e.key === "Escape") {
7115
7136
  e.preventDefault();
7116
- e.stopPropagation();
7117
7137
  cancelEdit(true);
7118
7138
  } else if (e.key === "Tab") {
7119
7139
  e.preventDefault();
7120
- e.stopPropagation();
7121
7140
  const from = editing.cell;
7122
7141
  if (commitEdit()) {
7123
7142
  const next = nextEditableCell(from, e.shiftKey ? -1 : 1);
@@ -7126,7 +7145,6 @@ var require_faqir_core = __commonJS((exports, module) => {
7126
7145
  }
7127
7146
  } else {
7128
7147
  e.target.removeAttribute("data-invalid");
7129
- e.stopPropagation();
7130
7148
  }
7131
7149
  }
7132
7150
  function onEditorBlur(e) {
@@ -7171,6 +7189,7 @@ var require_faqir_core = __commonJS((exports, module) => {
7171
7189
  return;
7172
7190
  forEachColumnCell(i, (cell) => toggleAttr(cell, "data-col-hidden", hidden));
7173
7191
  refreshPins();
7192
+ setupNavigability();
7174
7193
  emit("col-visibility", { column: i, hidden: !!hidden });
7175
7194
  scheduleStateSave();
7176
7195
  }
@@ -7282,14 +7301,11 @@ var require_faqir_core = __commonJS((exports, module) => {
7282
7301
  }
7283
7302
  }
7284
7303
  function elementAt(e) {
7285
- if (document.elementFromPoint) {
7286
- try {
7287
- return document.elementFromPoint(e.clientX, e.clientY);
7288
- } catch {
7289
- return null;
7290
- }
7304
+ try {
7305
+ return document.elementFromPoint(e.clientX, e.clientY);
7306
+ } catch {
7307
+ return null;
7291
7308
  }
7292
- return null;
7293
7309
  }
7294
7310
  function resolveRowAt(e) {
7295
7311
  let row = elementAt(e)?.closest?.("[data-part='tr']");
@@ -7297,18 +7313,13 @@ var require_faqir_core = __commonJS((exports, module) => {
7297
7313
  row = e.target?.closest?.("[data-part='tr']");
7298
7314
  return row && tbody?.contains(row) ? row : null;
7299
7315
  }
7300
- function dropPos(e, el) {
7301
- const rect = el.getBoundingClientRect?.();
7302
- if (!rect || !rect.height)
7303
- return "after";
7304
- return e.clientY < rect.top + rect.height / 2 ? "before" : "after";
7305
- }
7306
- function dropPosX(e, el) {
7316
+ function dropPos(e, el, horizontal) {
7307
7317
  const rect = el.getBoundingClientRect?.();
7308
- if (!rect || !rect.width)
7318
+ const size = rect && (horizontal ? rect.width : rect.height);
7319
+ if (!size)
7309
7320
  return "after";
7310
- const before = e.clientX < rect.left + rect.width / 2;
7311
- return before !== isRTL ? "before" : "after";
7321
+ const before = horizontal ? e.clientX < rect.left + size / 2 !== isRTL : e.clientY < rect.top + size / 2;
7322
+ return before ? "before" : "after";
7312
7323
  }
7313
7324
  function bindDocDrag() {
7314
7325
  document.addEventListener("pointermove", onDocPointerMove);
@@ -7411,7 +7422,7 @@ var require_faqir_core = __commonJS((exports, module) => {
7411
7422
  if (!th || th === drag.th || !headerRowEl()?.contains(th))
7412
7423
  return;
7413
7424
  th.setAttribute("data-drop-target", "");
7414
- th.setAttribute("data-drop-pos", dropPosX(e, th));
7425
+ th.setAttribute("data-drop-pos", dropPos(e, th, true));
7415
7426
  }
7416
7427
  }
7417
7428
  function onDocPointerUp() {
@@ -7622,15 +7633,13 @@ var require_faqir_core = __commonJS((exports, module) => {
7622
7633
  existing.remove();
7623
7634
  existing = null;
7624
7635
  }
7625
- let el;
7626
- if (isParent) {
7627
- el = document.createElement("button");
7636
+ const el = document.createElement(isParent ? "button" : "span");
7637
+ if (isParent)
7628
7638
  el.type = "button";
7629
- el.setAttribute("data-part", "expander");
7639
+ el.setAttribute("data-part", "expander");
7640
+ if (isParent)
7630
7641
  el.setAttribute("aria-label", "Toggle");
7631
- } else {
7632
- el = document.createElement("span");
7633
- el.setAttribute("data-part", "expander");
7642
+ else {
7634
7643
  el.setAttribute("data-leaf", "");
7635
7644
  el.setAttribute("aria-hidden", "true");
7636
7645
  }
@@ -7739,16 +7748,26 @@ var require_faqir_core = __commonJS((exports, module) => {
7739
7748
  rows.push(r);
7740
7749
  return rows;
7741
7750
  }
7751
+ const demoted = new WeakMap;
7752
+ const cellControls = (cell) => [...cell.querySelectorAll("input,select,textarea,button,a[href],[tabindex]")].filter((el) => mine(el) && !el.closest("[data-part='checkbox'],[data-part='drag-handle'],[data-part='expander'],[data-part='row-toggle']"));
7742
7753
  function setupNavigability() {
7743
7754
  if (opts.navigable) {
7755
+ const rows = navMatrix();
7756
+ if (activeCell && (!rows.includes(activeCell.parentElement) || activeCell.hasAttribute("data-col-hidden"))) {
7757
+ activeCell.setAttribute("tabindex", "-1");
7758
+ activeCell = null;
7759
+ }
7744
7760
  let first = null;
7745
- for (const row of navMatrix()) {
7761
+ for (const row of rows) {
7746
7762
  for (const cell of cellsOf(row)) {
7747
- if (cell.hasAttribute("data-col-hidden"))
7748
- continue;
7749
- if (!first && !activeCell)
7763
+ if (!first && !activeCell && !cell.hasAttribute("data-col-hidden"))
7750
7764
  first = cell;
7751
7765
  cell.setAttribute("tabindex", cell === (activeCell || first) ? "0" : "-1");
7766
+ for (const el of cellControls(cell)) {
7767
+ if (!demoted.has(el))
7768
+ demoted.set(el, el.getAttribute("tabindex"));
7769
+ el.setAttribute("tabindex", "-1");
7770
+ }
7752
7771
  }
7753
7772
  }
7754
7773
  if (!activeCell)
@@ -7765,9 +7784,7 @@ var require_faqir_core = __commonJS((exports, module) => {
7765
7784
  activeCell.setAttribute("tabindex", "-1");
7766
7785
  activeCell = cell;
7767
7786
  cell.setAttribute("tabindex", "0");
7768
- try {
7769
- cell.focus();
7770
- } catch {}
7787
+ cell.focus();
7771
7788
  }
7772
7789
  function moveFocus(rowDelta, colDelta, edge) {
7773
7790
  const cell = activeCell;
@@ -7811,7 +7828,7 @@ var require_faqir_core = __commonJS((exports, module) => {
7811
7828
  const cell = e.target.closest("[data-part='td'],[data-part='th']");
7812
7829
  if (!cell || cell === activeCell || !root.contains(cell))
7813
7830
  return;
7814
- if (e.target !== cell)
7831
+ if (e.target !== cell && !demoted.has(e.target))
7815
7832
  return;
7816
7833
  if (activeCell)
7817
7834
  activeCell.setAttribute("tabindex", "-1");
@@ -7852,13 +7869,12 @@ var require_faqir_core = __commonJS((exports, module) => {
7852
7869
  if (e.shiftKey && lastSelectedIndex >= 0) {
7853
7870
  e.preventDefault();
7854
7871
  selectRange(lastSelectedIndex, index);
7855
- emit("selection-change", { selected: getSelected() });
7872
+ selectionChanged();
7856
7873
  return;
7857
7874
  }
7858
7875
  toggleAttr(row, "data-selected", checkbox.checked);
7859
7876
  lastSelectedIndex = index;
7860
- updateHeaderCheckbox();
7861
- emit("selection-change", { selected: getSelected() });
7877
+ selectionChanged();
7862
7878
  }
7863
7879
  function onRootClick(e) {
7864
7880
  if (Date.now() < suppressClickUntil)
@@ -7903,7 +7919,7 @@ var require_faqir_core = __commonJS((exports, module) => {
7903
7919
  return;
7904
7920
  if (e.shiftKey && lastSelectedIndex >= 0) {
7905
7921
  selectRange(lastSelectedIndex, index);
7906
- emit("selection-change", { selected: getSelected() });
7922
+ selectionChanged();
7907
7923
  return;
7908
7924
  }
7909
7925
  if (opts.selectable != null) {
@@ -7916,8 +7932,7 @@ var require_faqir_core = __commonJS((exports, module) => {
7916
7932
  setRowSelected(row, !row.hasAttribute("data-selected"));
7917
7933
  }
7918
7934
  lastSelectedIndex = index;
7919
- updateHeaderCheckbox();
7920
- emit("selection-change", { selected: getSelected() });
7935
+ selectionChanged();
7921
7936
  }
7922
7937
  }
7923
7938
  function onDblClick(e) {
@@ -7968,9 +7983,14 @@ var require_faqir_core = __commonJS((exports, module) => {
7968
7983
  }
7969
7984
  return;
7970
7985
  }
7986
+ const cell = target.closest?.("[data-part='td'],[data-part='th']");
7987
+ if (e.key === "Escape" && demoted.has(target)) {
7988
+ e.preventDefault();
7989
+ focusCell(cell);
7990
+ return;
7991
+ }
7971
7992
  if (target.closest?.("input,select,textarea,button,a"))
7972
7993
  return;
7973
- const cell = target.closest?.("[data-part='td'],[data-part='th']");
7974
7994
  const inHeader = cell && thead?.contains(cell);
7975
7995
  if (inHeader && (e.key === "Enter" || e.key === " ") && cell.hasAttribute("data-sortable")) {
7976
7996
  e.preventDefault();
@@ -8055,6 +8075,12 @@ var require_faqir_core = __commonJS((exports, module) => {
8055
8075
  if (isCellEditable(cell)) {
8056
8076
  e.preventDefault();
8057
8077
  startEdit(cell);
8078
+ return;
8079
+ }
8080
+ const ctl = cellControls(cell)[0];
8081
+ if (ctl) {
8082
+ e.preventDefault();
8083
+ ctl.focus();
8058
8084
  }
8059
8085
  return;
8060
8086
  }
@@ -8090,7 +8116,7 @@ var require_faqir_core = __commonJS((exports, module) => {
8090
8116
  toggleAttr(root, "data-stacked", width < stackBreakpoint());
8091
8117
  }
8092
8118
  function measureSticky() {
8093
- const needsHeaderVar = root.hasAttribute("data-sticky-header") || !!tbody?.querySelector("[data-part='tr'][data-pin='top']");
8119
+ const needsHeaderVar = root.hasAttribute("data-sticky-header") || bodyRows().some((r) => r.dataset.pin === "top");
8094
8120
  if (needsHeaderVar && thead && thead.offsetHeight) {
8095
8121
  root.style.setProperty("--table-thead-h", thead.offsetHeight + "px");
8096
8122
  }
@@ -8127,6 +8153,12 @@ var require_faqir_core = __commonJS((exports, module) => {
8127
8153
  cleanups.length = 0;
8128
8154
  observer?.disconnect();
8129
8155
  observer = null;
8156
+ for (const el of root.querySelectorAll("[tabindex]")) {
8157
+ if (demoted.has(el)) {
8158
+ const t = demoted.get(el);
8159
+ t == null ? el.removeAttribute("tabindex") : el.setAttribute("tabindex", t);
8160
+ }
8161
+ }
8130
8162
  for (const t of timers)
8131
8163
  clearTimeout(t);
8132
8164
  timers.clear();
@@ -8137,14 +8169,15 @@ var require_faqir_core = __commonJS((exports, module) => {
8137
8169
  on(thead, "click", onHeaderClick);
8138
8170
  if (headerCheckbox)
8139
8171
  on(headerCheckbox, "change", onHeaderCheckboxChange);
8172
+ const onOwn = (target, ev, fn) => on(target, ev, (e) => mine(e.target) && fn(e));
8140
8173
  if (tbody)
8141
- on(tbody, "change", onRowCheckboxChange);
8142
- on(root, "click", onRootClick);
8143
- on(root, "dblclick", onDblClick);
8144
- on(root, "keydown", onKeydown);
8145
- on(root, "input", onFilterInput);
8146
- on(root, "pointerdown", onPointerDown);
8147
- on(root, "focusin", onFocusIn);
8174
+ onOwn(tbody, "change", onRowCheckboxChange);
8175
+ onOwn(root, "click", onRootClick);
8176
+ onOwn(root, "dblclick", onDblClick);
8177
+ onOwn(root, "keydown", onKeydown);
8178
+ onOwn(root, "input", onFilterInput);
8179
+ onOwn(root, "pointerdown", onPointerDown);
8180
+ onOwn(root, "focusin", onFocusIn);
8148
8181
  if (typeof window !== "undefined") {
8149
8182
  let resizeTimer = null;
8150
8183
  const onWinResize = () => {
@@ -8209,15 +8242,17 @@ var require_faqir_core = __commonJS((exports, module) => {
8209
8242
  root._faqirTable = api;
8210
8243
  return api;
8211
8244
  }
8212
- return createTable2;
8245
+ return createTable;
8213
8246
  }();
8214
8247
  var createTabs = controllerRegistry["tabs"] = function() {
8215
- function createTabs2(root) {
8248
+ function createTabs(root) {
8216
8249
  if (root._faqirTabs)
8217
8250
  return root._faqirTabs;
8218
- const list = root.querySelector("[data-part='list']");
8219
- const triggers = () => [...root.querySelectorAll("[data-part='trigger']")];
8220
- const panels = () => [...root.querySelectorAll("[data-part='panel']")];
8251
+ const list = root.querySelector(":scope > [data-part='list']");
8252
+ const triggers = () => [
8253
+ ...root.querySelectorAll(":scope > [data-part='list'] > [data-part='trigger']")
8254
+ ];
8255
+ const panels = () => [...root.querySelectorAll(":scope > [data-part='panel']")];
8221
8256
  function activate(index) {
8222
8257
  const allTriggers = triggers();
8223
8258
  const allPanels = panels();
@@ -8282,10 +8317,10 @@ var require_faqir_core = __commonJS((exports, module) => {
8282
8317
  root._faqirTabs = api;
8283
8318
  return api;
8284
8319
  }
8285
- return createTabs2;
8320
+ return createTabs;
8286
8321
  }();
8287
8322
  var createTagInput = controllerRegistry["tag-input"] = function() {
8288
- function createTagInput2(root) {
8323
+ function createTagInput(root) {
8289
8324
  if (root._faqirTagInput)
8290
8325
  return root._faqirTagInput;
8291
8326
  const taglist = root.querySelector("[data-part='taglist']");
@@ -8580,10 +8615,10 @@ var require_faqir_core = __commonJS((exports, module) => {
8580
8615
  root._faqirTagInput = api;
8581
8616
  return api;
8582
8617
  }
8583
- return createTagInput2;
8618
+ return createTagInput;
8584
8619
  }();
8585
8620
  var createToastContainer = controllerRegistry["toast"] = function() {
8586
- function createToastContainer2(root) {
8621
+ function createToastContainer(root) {
8587
8622
  if (root._faqirToast)
8588
8623
  return root._faqirToast;
8589
8624
  const toasts = new Map;
@@ -8712,10 +8747,10 @@ var require_faqir_core = __commonJS((exports, module) => {
8712
8747
  root._faqirToast = api;
8713
8748
  return api;
8714
8749
  }
8715
- return createToastContainer2;
8750
+ return createToastContainer;
8716
8751
  }();
8717
8752
  var createToggleGroup = controllerRegistry["toggle-group"] = function() {
8718
- function createToggleGroup2(root) {
8753
+ function createToggleGroup(root) {
8719
8754
  if (root._faqirToggleGroup)
8720
8755
  return root._faqirToggleGroup;
8721
8756
  const mode = root.dataset.mode === "multi" ? "multi" : "single";
@@ -8852,26 +8887,34 @@ var require_faqir_core = __commonJS((exports, module) => {
8852
8887
  if (el)
8853
8888
  select(el);
8854
8889
  }
8890
+ const form = root.closest("form");
8891
+ const onReset = () => setTimeout(syncState, 0);
8855
8892
  root.addEventListener("change", onChange);
8893
+ root.addEventListener("faqir:model", syncState);
8856
8894
  root.addEventListener("keydown", onKeyDown);
8895
+ if (form)
8896
+ form.addEventListener("reset", onReset);
8857
8897
  syncState();
8858
8898
  function destroy() {
8859
8899
  root.removeEventListener("change", onChange);
8900
+ root.removeEventListener("faqir:model", syncState);
8860
8901
  root.removeEventListener("keydown", onKeyDown);
8902
+ if (form)
8903
+ form.removeEventListener("reset", onReset);
8861
8904
  delete root._faqirToggleGroup;
8862
8905
  }
8863
8906
  const api = { getValue, setValue, toggle, destroy };
8864
8907
  root._faqirToggleGroup = api;
8865
8908
  return api;
8866
8909
  }
8867
- return createToggleGroup2;
8910
+ return createToggleGroup;
8868
8911
  }();
8869
8912
  var createTooltip = controllerRegistry["tooltip"] = function() {
8870
- function createTooltip2(root) {
8913
+ function createTooltip(root) {
8871
8914
  if (root._faqirTooltip)
8872
8915
  return root._faqirTooltip;
8873
8916
  const trigger = root.querySelector("[data-part='trigger']");
8874
- const content = root.querySelector("[data-part='content']");
8917
+ const [content] = ownParts(root, "content");
8875
8918
  let showTimer = null;
8876
8919
  let hideTimer = null;
8877
8920
  function show() {
@@ -8934,10 +8977,10 @@ var require_faqir_core = __commonJS((exports, module) => {
8934
8977
  root._faqirTooltip = api;
8935
8978
  return api;
8936
8979
  }
8937
- return createTooltip2;
8980
+ return createTooltip;
8938
8981
  }();
8939
8982
  var createTreeView = controllerRegistry["tree-view"] = function() {
8940
- function createTreeView2(root) {
8983
+ function createTreeView(root) {
8941
8984
  if (root._faqirTreeView) {
8942
8985
  root._faqirTreeView.refresh();
8943
8986
  return root._faqirTreeView;
@@ -9335,7 +9378,7 @@ var require_faqir_core = __commonJS((exports, module) => {
9335
9378
  refresh();
9336
9379
  return api;
9337
9380
  }
9338
- return createTreeView2;
9381
+ return createTreeView;
9339
9382
  }();
9340
9383
  var customMagics = new Map;
9341
9384
  function findParentScope(el) {
@@ -9350,7 +9393,8 @@ var require_faqir_core = __commonJS((exports, module) => {
9350
9393
  var SNAPSHOT_MAX_DEPTH = 4;
9351
9394
  function snapshotValue(value, stack, depth) {
9352
9395
  if (typeof value === "function") {
9353
- return "[Function" + (value.name ? " " + value.name : "") + "]";
9396
+ var name = String(value.name || "").replace(/^bound /, "");
9397
+ return "[Function" + (name ? " " + name : "") + "]";
9354
9398
  }
9355
9399
  if (value === null || typeof value !== "object")
9356
9400
  return value;
@@ -9535,17 +9579,26 @@ var require_faqir_core = __commonJS((exports, module) => {
9535
9579
  console.error('[Faqir] Controller "' + name + '" failed to initialize', el, err);
9536
9580
  }
9537
9581
  }
9538
- var mutationObserver = null;
9539
- var observedBody = null;
9540
- function bootstrap() {
9541
- injectCloakStyle();
9582
+ function startControllers(root) {
9583
+ var own = root.getAttribute && root.getAttribute("data-ui");
9584
+ if (own && controllerRegistry[own])
9585
+ initController(own, root);
9542
9586
  var names = Object.keys(controllerRegistry);
9543
9587
  for (var n = 0;n < names.length; n++) {
9544
- var els = document.querySelectorAll('[data-ui="' + names[n] + '"]');
9545
- for (var e = 0;e < els.length; e++) {
9588
+ var els = root.querySelectorAll('[data-ui="' + names[n] + '"]');
9589
+ for (var e = 0;e < els.length; e++)
9546
9590
  initController(names[n], els[e]);
9547
- }
9548
9591
  }
9592
+ }
9593
+ function publicInitTree(root, parentScope) {
9594
+ if (root.isConnected)
9595
+ startControllers(root);
9596
+ initTree(root, parentScope);
9597
+ }
9598
+ var mutationObserver = null;
9599
+ var observedBody = null;
9600
+ function bootstrap() {
9601
+ startControllers(document);
9549
9602
  var roots = document.querySelectorAll("[l-data], [data-ui]");
9550
9603
  var processed = new Set;
9551
9604
  for (var r = 0;r < roots.length; r++) {
@@ -9554,7 +9607,7 @@ var require_faqir_core = __commonJS((exports, module) => {
9554
9607
  continue;
9555
9608
  if (rootEl.__faqirScope) {
9556
9609
  processed.add(rootEl);
9557
- var seen = rootEl.querySelectorAll("[l-data]");
9610
+ var seen = rootEl.querySelectorAll("[l-data], [data-ui]");
9558
9611
  for (var sd = 0;sd < seen.length; sd++)
9559
9612
  processed.add(seen[sd]);
9560
9613
  continue;
@@ -9580,19 +9633,14 @@ var require_faqir_core = __commonJS((exports, module) => {
9580
9633
  }
9581
9634
  if (!skipThis) {
9582
9635
  initTree(rootEl, null);
9583
- var descendants = rootEl.querySelectorAll("[l-data]");
9636
+ var descendants = rootEl.querySelectorAll("[l-data], [data-ui]");
9584
9637
  for (var d = 0;d < descendants.length; d++)
9585
9638
  processed.add(descendants[d]);
9586
9639
  processed.add(rootEl);
9587
9640
  }
9588
9641
  }
9589
9642
  walkUnscoped(document.body, getStrayScope());
9590
- for (var n2 = 0;n2 < names.length; n2++) {
9591
- var els2 = document.querySelectorAll('[data-ui="' + names[n2] + '"]');
9592
- for (var e2 = 0;e2 < els2.length; e2++) {
9593
- initController(names[n2], els2[e2]);
9594
- }
9595
- }
9643
+ startControllers(document);
9596
9644
  removeCloaks();
9597
9645
  if (mutationObserver && observedBody === document.body)
9598
9646
  return;
@@ -9610,22 +9658,13 @@ var require_faqir_core = __commonJS((exports, module) => {
9610
9658
  if (node.nodeType !== 1)
9611
9659
  continue;
9612
9660
  removeCloaks(node);
9613
- var uiName = node.getAttribute ? node.getAttribute("data-ui") : null;
9614
- if (uiName && controllerRegistry[uiName]) {
9615
- initController(uiName, node);
9616
- }
9661
+ startControllers(node);
9617
9662
  if (node.__faqirScope) {} else if (node.hasAttribute && node.hasAttribute("l-data")) {
9618
9663
  initTree(node, findParentScope(node));
9619
9664
  } else if (node.hasAttribute && node.hasAttribute("data-ui") && !findParentScope(node)) {
9620
9665
  initTree(node, null);
9621
9666
  }
9622
9667
  if (node.querySelectorAll) {
9623
- var cNames = Object.keys(controllerRegistry);
9624
- for (var cn = 0;cn < cNames.length; cn++) {
9625
- var cEls = node.querySelectorAll('[data-ui="' + cNames[cn] + '"]');
9626
- for (var ce = 0;ce < cEls.length; ce++)
9627
- initController(cNames[cn], cEls[ce]);
9628
- }
9629
9668
  var scopeEls = node.querySelectorAll("[l-data]");
9630
9669
  for (var se = 0;se < scopeEls.length; se++) {
9631
9670
  if (!scopeEls[se].__faqirScope) {
@@ -9645,16 +9684,25 @@ var require_faqir_core = __commonJS((exports, module) => {
9645
9684
  mutationObserver.observe(document.body, { childList: true, subtree: true });
9646
9685
  }
9647
9686
  var currentScript = typeof document !== "undefined" ? document.currentScript : null;
9648
- var isManual = currentScript && currentScript.hasAttribute("data-manual");
9687
+ var isManual = currentScript ? currentScript.hasAttribute("data-manual") : typeof document !== "undefined" && !!document.querySelector('script[type="module"][data-manual]');
9688
+ var autoStarted = false;
9689
+ function autoStart() {
9690
+ if (autoStarted)
9691
+ return;
9692
+ autoStarted = true;
9693
+ bootstrap();
9694
+ }
9649
9695
  if (!isManual && typeof document !== "undefined") {
9650
9696
  if (document.readyState === "loading") {
9651
- document.addEventListener("DOMContentLoaded", bootstrap);
9697
+ document.addEventListener("DOMContentLoaded", autoStart);
9652
9698
  } else {
9653
- bootstrap();
9699
+ if (document.readyState === "interactive")
9700
+ document.addEventListener("DOMContentLoaded", autoStart);
9701
+ setTimeout(autoStart, 0);
9654
9702
  }
9655
9703
  }
9656
9704
  var Faqir = {
9657
- version: "1.1.0",
9705
+ version: "1.1.2",
9658
9706
  reactive,
9659
9707
  effect,
9660
9708
  batch,
@@ -9674,6 +9722,8 @@ var require_faqir_core = __commonJS((exports, module) => {
9674
9722
  customDirectives.set(name, handler);
9675
9723
  },
9676
9724
  magic: function(name, callback) {
9725
+ if (name === "this")
9726
+ throw new Error('[Faqir] "this" is reserved: $this is the directive element');
9677
9727
  customMagics.set(name, callback);
9678
9728
  },
9679
9729
  plugin: function(fn) {
@@ -9683,7 +9733,7 @@ var require_faqir_core = __commonJS((exports, module) => {
9683
9733
  controllerRegistry[name] = factory;
9684
9734
  },
9685
9735
  start: bootstrap,
9686
- initTree,
9736
+ initTree: publicInitTree,
9687
9737
  inspect,
9688
9738
  devtools,
9689
9739
  destroy: destroyScope
@@ -9719,24 +9769,24 @@ var destroy = import_faqir_core.default.destroy;
9719
9769
  var inspect = import_faqir_core.default.inspect;
9720
9770
  var devtools = import_faqir_core.default.devtools;
9721
9771
  export {
9722
- version,
9723
- untrack,
9724
- store,
9725
- start,
9726
- reactive,
9727
- plugin,
9728
- nextTick,
9729
- magic,
9730
- inspect,
9731
- initTree,
9732
- evaluateAssignment,
9733
- evaluate,
9734
- effect,
9735
- directive,
9736
- devtools,
9737
- destroy,
9738
- esm_entry_default as default,
9739
- data,
9772
+ batch,
9740
9773
  controller,
9741
- batch
9774
+ data,
9775
+ esm_entry_default as default,
9776
+ destroy,
9777
+ devtools,
9778
+ directive,
9779
+ effect,
9780
+ evaluate,
9781
+ evaluateAssignment,
9782
+ initTree,
9783
+ inspect,
9784
+ magic,
9785
+ nextTick,
9786
+ plugin,
9787
+ reactive,
9788
+ start,
9789
+ store,
9790
+ untrack,
9791
+ version
9742
9792
  };