arethesis 0.1.1 → 0.1.4

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.
@@ -827,11 +827,11 @@ function S(e, t, n, i) {
827
827
  };
828
828
  }
829
829
  // src/utils/backoff.ts
830
- function C(e, t = {}, n = Math.random) {
830
+ function ee(e, t = {}, n = Math.random) {
831
831
  let r = t.baseDelay ?? 1e3, i = t.maxDelay ?? 3e4, a = t.jitter ?? .3, o = Math.min(r * 2 ** e, i);
832
832
  return Math.min(o + n() * a * o, i);
833
833
  }
834
- function ee(e, t) {
834
+ function te(e, t) {
835
835
  return new Promise((n, r) => {
836
836
  if (t?.aborted) {
837
837
  r(t.reason ?? new DOMException("Aborted", "AbortError"));
@@ -846,7 +846,7 @@ function ee(e, t) {
846
846
  });
847
847
  }
848
848
  // src/http/http-client.ts
849
- var te = {
849
+ var ne = {
850
850
  maxAttempts: 3,
851
851
  baseDelay: 500,
852
852
  maxDelay: 1e4,
@@ -861,20 +861,20 @@ var te = {
861
861
  504
862
862
  ],
863
863
  retryNonIdempotent: !1
864
- }, ne = /* @__PURE__ */ new Set([
864
+ }, re = /* @__PURE__ */ new Set([
865
865
  "GET",
866
866
  "HEAD",
867
867
  "PUT",
868
868
  "DELETE",
869
869
  "OPTIONS"
870
870
  ]);
871
- function re(e) {
871
+ function ie(e) {
872
872
  return typeof e == "string" || typeof FormData < "u" && e instanceof FormData || typeof Blob < "u" && e instanceof Blob || typeof URLSearchParams < "u" && e instanceof URLSearchParams || e instanceof ArrayBuffer || ArrayBuffer.isView(e);
873
873
  }
874
- function ie(e) {
874
+ function ae(e) {
875
875
  return e instanceof Error && e.name === "AbortError";
876
876
  }
877
- var ae = class {
877
+ var C = class {
878
878
  config = {};
879
879
  endpoints = /* @__PURE__ */ new Map();
880
880
  auth = null;
@@ -975,23 +975,23 @@ var ae = class {
975
975
  }
976
976
  async requestWithRetry(e, t, n) {
977
977
  let r = n.retry === !1 || this.config.retry === !1 ? {
978
- ...te,
978
+ ...ne,
979
979
  maxAttempts: 1
980
980
  } : {
981
- ...te,
981
+ ...ne,
982
982
  ...this.config.retry,
983
983
  ...n.retry
984
- }, i = ne.has(t) || r.retryNonIdempotent, a = 0, o = !1;
984
+ }, i = re.has(t) || r.retryNonIdempotent, a = 0, o = !1;
985
985
  for (;;) try {
986
986
  return await this.send(e, t, n, a);
987
987
  } catch (e) {
988
- if (ie(e)) throw e;
988
+ if (ae(e)) throw e;
989
989
  let t = e;
990
990
  if (t.status === 401 && !o && n.auth !== !1 && this.auth?.getRefreshToken() && (o = !0, await this.auth.refreshAccessToken())) continue;
991
991
  a++;
992
992
  let s = t.kind === "network" || t.kind === "timeout" || r.retryOn.includes(t.status);
993
993
  if (!i || !s || t.kind === "parse" || a >= r.maxAttempts) throw t;
994
- await ee(t.retryAfter === void 0 ? C(a - 1, r) : Math.min(t.retryAfter * 1e3, r.maxDelay), n.signal);
994
+ await te(t.retryAfter === void 0 ? ee(a - 1, r) : Math.min(t.retryAfter * 1e3, r.maxDelay), n.signal);
995
995
  }
996
996
  }
997
997
  async send(e, t, n, r) {
@@ -1001,7 +1001,7 @@ var ae = class {
1001
1001
  e && (i.Authorization = `Bearer ${e}`);
1002
1002
  }
1003
1003
  let a;
1004
- n.body !== void 0 && (re(n.body) ? a = n.body : (a = JSON.stringify(n.body), Object.keys(i).some((e) => e.toLowerCase() === "content-type") || (i["Content-Type"] = "application/json")));
1004
+ n.body !== void 0 && (ie(n.body) ? a = n.body : (a = JSON.stringify(n.body), Object.keys(i).some((e) => e.toLowerCase() === "content-type") || (i["Content-Type"] = "application/json")));
1005
1005
  let o = new AbortController(), s = n.timeout ?? this.config.timeout ?? 3e4, c = !1, l = s > 0 ? setTimeout(() => {
1006
1006
  c = !0, o.abort();
1007
1007
  }, s) : void 0, u = () => o.abort(n.signal?.reason);
@@ -1174,7 +1174,7 @@ var ae = class {
1174
1174
  url: t.url,
1175
1175
  method: "POST",
1176
1176
  body: o,
1177
- retry: { retryNonIdempotent: a.every((e) => ne.has(e.method)) }
1177
+ retry: { retryNonIdempotent: a.every((e) => re.has(e.method)) }
1178
1178
  }), c = t.parseResponse ? t.parseResponse(s) : Array.isArray(s) ? s : r(s, "results") ?? [], l = new Map(c.filter((e) => e.id !== void 0).map((e) => [e.id, e]));
1179
1179
  a.forEach((e, t) => n.push(l.get(e.id) ?? c[t] ?? {
1180
1180
  id: e.id,
@@ -1221,18 +1221,18 @@ var ae = class {
1221
1221
  this.map.delete(e);
1222
1222
  }
1223
1223
  };
1224
- function se(e) {
1224
+ function w(e) {
1225
1225
  try {
1226
1226
  return e === "memory" ? new oe() : e === "session" ? sessionStorage : e && typeof e == "object" ? e : localStorage;
1227
1227
  } catch {
1228
1228
  return new oe();
1229
1229
  }
1230
1230
  }
1231
- function ce(e) {
1231
+ function se(e) {
1232
1232
  let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t + "=".repeat((4 - t.length % 4) % 4), r = atob(n), i = Uint8Array.from(r, (e) => e.charCodeAt(0));
1233
1233
  return new TextDecoder().decode(i);
1234
1234
  }
1235
- var le = class extends f {
1235
+ var T = class extends f {
1236
1236
  config;
1237
1237
  storage;
1238
1238
  refreshPromise = null;
@@ -1247,7 +1247,7 @@ var le = class extends f {
1247
1247
  refreshThreshold: 60,
1248
1248
  refreshBodyField: "refresh_token",
1249
1249
  ...e
1250
- }, this.storage = se(e.storage), this.fetchImpl = t.fetch ?? (() => globalThis.fetch.bind(globalThis)), this.resolveUrl = t.resolveUrl ?? ((e) => e), typeof window < "u" && (e.storage === void 0 || e.storage === "local") && (this.storageListener = (e) => {
1250
+ }, this.storage = w(e.storage), this.fetchImpl = t.fetch ?? (() => globalThis.fetch.bind(globalThis)), this.resolveUrl = t.resolveUrl ?? ((e) => e), typeof window < "u" && (e.storage === void 0 || e.storage === "local") && (this.storageListener = (e) => {
1251
1251
  (e.key === this.config.accessTokenKey || e.key === null) && (this.parsed = null, this.emit("change", { authenticated: this.isAuthenticated() }));
1252
1252
  }, window.addEventListener("storage", this.storageListener));
1253
1253
  }
@@ -1286,7 +1286,7 @@ var le = class extends f {
1286
1286
  else {
1287
1287
  let n = e.split(".");
1288
1288
  if (n.length === 3) try {
1289
- let e = JSON.parse(ce(n[1]));
1289
+ let e = JSON.parse(se(n[1]));
1290
1290
  t = e && typeof e == "object" ? e : null;
1291
1291
  } catch {
1292
1292
  t = null;
@@ -1397,7 +1397,7 @@ var le = class extends f {
1397
1397
  destroy() {
1398
1398
  this.storageListener && window.removeEventListener("storage", this.storageListener), this.storageListener = null, this.clear();
1399
1399
  }
1400
- }, ue = class extends f {
1400
+ }, E = class extends f {
1401
1401
  options;
1402
1402
  attempts = 0;
1403
1403
  timer = null;
@@ -1420,7 +1420,7 @@ var le = class extends f {
1420
1420
  schedule(e) {
1421
1421
  if (this.options.reconnect === !1 || this.attempts >= (this.options.maxReconnectAttempts ?? Infinity)) return this.status = "closed", !1;
1422
1422
  if (this.timer) return !0;
1423
- let t = C(this.attempts, {
1423
+ let t = ee(this.attempts, {
1424
1424
  baseDelay: this.options.baseDelay ?? 1e3,
1425
1425
  maxDelay: this.options.maxDelay ?? 3e4,
1426
1426
  jitter: this.options.jitter ?? .3
@@ -1432,7 +1432,7 @@ var le = class extends f {
1432
1432
  cancel() {
1433
1433
  this.timer && clearTimeout(this.timer), this.timer = null, this.attempts = 0;
1434
1434
  }
1435
- }, de = class {
1435
+ }, ce = class {
1436
1436
  config;
1437
1437
  source = null;
1438
1438
  store = null;
@@ -1444,7 +1444,7 @@ var le = class extends f {
1444
1444
  handlers = new f();
1445
1445
  customEvents = /* @__PURE__ */ new Set();
1446
1446
  constructor(e) {
1447
- this.config = e, this.policy = new ue(e);
1447
+ this.config = e, this.policy = new E(e);
1448
1448
  }
1449
1449
  connectStore(e, t) {
1450
1450
  this.store = e, this.listViews = t ?? null;
@@ -1556,7 +1556,7 @@ var le = class extends f {
1556
1556
  disconnect() {
1557
1557
  this.generation++, this.policy.cancel(), this.source?.close(), this.source = null, this.policy.status = "closed";
1558
1558
  }
1559
- }, fe = /* @__PURE__ */ new Set(["ping", "pong"]), pe = class {
1559
+ }, le = /* @__PURE__ */ new Set(["ping", "pong"]), ue = class {
1560
1560
  config;
1561
1561
  socket = null;
1562
1562
  channels = /* @__PURE__ */ new Map();
@@ -1571,7 +1571,7 @@ var le = class extends f {
1571
1571
  pingInterval: 3e4,
1572
1572
  maxQueue: 1e3,
1573
1573
  ...e
1574
- }, this.policy = new ue(e);
1574
+ }, this.policy = new E(e);
1575
1575
  }
1576
1576
  setTokenProvider(e) {
1577
1577
  this.getToken = e;
@@ -1626,7 +1626,7 @@ var le = class extends f {
1626
1626
  console.error("WebSocket: ignoring non-JSON message");
1627
1627
  return;
1628
1628
  }
1629
- t && typeof t.type == "string" && !fe.has(t.type) && this.dispatch(t);
1629
+ t && typeof t.type == "string" && !le.has(t.type) && this.dispatch(t);
1630
1630
  };
1631
1631
  }
1632
1632
  dispatch(e) {
@@ -1692,7 +1692,7 @@ var le = class extends f {
1692
1692
  }
1693
1693
  this.policy.status = "closed";
1694
1694
  }
1695
- }, me = "json.webpubsub.azure.v1", he = class {
1695
+ }, de = "json.webpubsub.azure.v1", fe = class {
1696
1696
  config;
1697
1697
  socket = null;
1698
1698
  channels = /* @__PURE__ */ new Map();
@@ -1713,7 +1713,7 @@ var le = class extends f {
1713
1713
  ackTimeout: 15e3,
1714
1714
  autoJoinGroups: [],
1715
1715
  ...e
1716
- }, this.policy = new ue(e);
1716
+ }, this.policy = new E(e);
1717
1717
  }
1718
1718
  connectStore(e, t) {
1719
1719
  this.store = e, this.listViews = t ?? null;
@@ -1749,7 +1749,7 @@ var le = class extends f {
1749
1749
  return;
1750
1750
  }
1751
1751
  if (e !== this.generation) return;
1752
- let n = this.config.socketFactory ? this.config.socketFactory(t, me) : new WebSocket(t, me);
1752
+ let n = this.config.socketFactory ? this.config.socketFactory(t, de) : new WebSocket(t, de);
1753
1753
  this.socket = n, n.onmessage = (e) => {
1754
1754
  if (this.socket !== n) return;
1755
1755
  let t;
@@ -1901,11 +1901,11 @@ var le = class extends f {
1901
1901
  }
1902
1902
  this.policy.status = "closed";
1903
1903
  }
1904
- }, w = (e) => typeof e == "number" && e > 0, ge = (e) => typeof e == "number" && e < 0, T = (e) => typeof e == "string";
1905
- function E(e) {
1904
+ }, D = (e) => typeof e == "number" && e > 0, pe = (e) => typeof e == "number" && e < 0, O = (e) => typeof e == "string";
1905
+ function me(e) {
1906
1906
  return e === void 0 ? "none" : typeof e == "string" ? "insert" : e > 0 ? "retain" : "delete";
1907
1907
  }
1908
- var D = class e {
1908
+ var k = class e {
1909
1909
  ops = [];
1910
1910
  baseLength = 0;
1911
1911
  targetLength = 0;
@@ -1914,16 +1914,16 @@ var D = class e {
1914
1914
  if (e === 0) return this;
1915
1915
  this.baseLength += e, this.targetLength += e;
1916
1916
  let t = this.ops[this.ops.length - 1];
1917
- return t !== void 0 && w(t) ? this.ops[this.ops.length - 1] = t + e : this.ops.push(e), this;
1917
+ return t !== void 0 && D(t) ? this.ops[this.ops.length - 1] = t + e : this.ops.push(e), this;
1918
1918
  }
1919
1919
  insert(e) {
1920
1920
  if (e === "") return this;
1921
1921
  this.targetLength += e.length;
1922
1922
  let t = this.ops, n = t[t.length - 1];
1923
- if (n !== void 0 && T(n)) t[t.length - 1] = n + e;
1924
- else if (n !== void 0 && ge(n)) {
1923
+ if (n !== void 0 && O(n)) t[t.length - 1] = n + e;
1924
+ else if (n !== void 0 && pe(n)) {
1925
1925
  let r = t[t.length - 2];
1926
- r !== void 0 && T(r) ? t[t.length - 2] = r + e : (t[t.length] = n, t[t.length - 2] = e);
1926
+ r !== void 0 && O(r) ? t[t.length - 2] = r + e : (t[t.length] = n, t[t.length - 2] = e);
1927
1927
  } else t.push(e);
1928
1928
  return this;
1929
1929
  }
@@ -1932,27 +1932,27 @@ var D = class e {
1932
1932
  if (t === 0) return this;
1933
1933
  this.baseLength += t;
1934
1934
  let n = this.ops[this.ops.length - 1];
1935
- return n !== void 0 && ge(n) ? this.ops[this.ops.length - 1] = n - t : this.ops.push(-t), this;
1935
+ return n !== void 0 && pe(n) ? this.ops[this.ops.length - 1] = n - t : this.ops.push(-t), this;
1936
1936
  }
1937
1937
  isNoop() {
1938
- return this.ops.length === 0 || this.ops.length === 1 && w(this.ops[0]);
1938
+ return this.ops.length === 0 || this.ops.length === 1 && D(this.ops[0]);
1939
1939
  }
1940
1940
  apply(e) {
1941
1941
  if (e.length !== this.baseLength) throw Error(`Operation base length ${this.baseLength} does not match document length ${e.length}`);
1942
1942
  let t = [], n = 0;
1943
- for (let r of this.ops) w(r) ? (t.push(e.slice(n, n + r)), n += r) : T(r) ? t.push(r) : n -= r;
1943
+ for (let r of this.ops) D(r) ? (t.push(e.slice(n, n + r)), n += r) : O(r) ? t.push(r) : n -= r;
1944
1944
  return t.join("");
1945
1945
  }
1946
1946
  invert(t) {
1947
1947
  let n = new e(), r = 0;
1948
- for (let e of this.ops) w(e) ? (n.retain(e), r += e) : T(e) ? n.delete(e.length) : (n.insert(t.slice(r, r - e)), r -= e);
1948
+ for (let e of this.ops) D(e) ? (n.retain(e), r += e) : O(e) ? n.delete(e.length) : (n.insert(t.slice(r, r - e)), r -= e);
1949
1949
  return n;
1950
1950
  }
1951
1951
  compose(t) {
1952
1952
  if (this.targetLength !== t.baseLength) throw Error("compose: length mismatch");
1953
1953
  let n = new e(), r = this.ops, i = t.ops, a = 0, o = 0, s = r[a++], c = i[o++];
1954
1954
  for (;;) {
1955
- let e = E(s), t = E(c);
1955
+ let e = me(s), t = me(c);
1956
1956
  if (e === "none" && t === "none") break;
1957
1957
  if (e === "delete") n.delete(s), s = r[a++];
1958
1958
  else if (t === "insert") n.insert(c), c = i[o++];
@@ -1979,7 +1979,7 @@ var D = class e {
1979
1979
  if (t.baseLength !== n.baseLength) throw Error("transform: operations must share a base");
1980
1980
  let r = new e(), i = new e(), a = t.ops, o = n.ops, s = 0, c = 0, l = a[s++], u = o[c++];
1981
1981
  for (;;) {
1982
- let e = E(l), t = E(u);
1982
+ let e = me(l), t = me(u);
1983
1983
  if (e === "none" && t === "none") break;
1984
1984
  if (e === "insert") {
1985
1985
  r.insert(l), i.retain(l.length), l = a[s++];
@@ -1999,7 +1999,7 @@ var D = class e {
1999
1999
  let n = e, r = 0;
2000
2000
  for (let i of this.ops) {
2001
2001
  if (r > e) break;
2002
- w(i) ? r += i : T(i) ? (r < e || r === e && !t) && (n += i.length) : (n -= Math.min(-i, Math.max(0, e - r)), r -= i);
2002
+ D(i) ? r += i : O(i) ? (r < e || r === e && !t) && (n += i.length) : (n -= Math.min(-i, Math.max(0, e - r)), r -= i);
2003
2003
  }
2004
2004
  return n;
2005
2005
  }
@@ -2025,9 +2025,9 @@ var D = class e {
2025
2025
  return n;
2026
2026
  }
2027
2027
  toString() {
2028
- return this.ops.map((e) => w(e) ? `retain ${e}` : T(e) ? `insert ${JSON.stringify(e)}` : `delete ${-e}`).join(", ");
2028
+ return this.ops.map((e) => D(e) ? `retain ${e}` : O(e) ? `insert ${JSON.stringify(e)}` : `delete ${-e}`).join(", ");
2029
2029
  }
2030
- }, _e = class {
2030
+ }, he = class {
2031
2031
  callbacks;
2032
2032
  revision;
2033
2033
  outstanding = null;
@@ -2045,9 +2045,9 @@ var D = class e {
2045
2045
  this.revision++;
2046
2046
  let t = e;
2047
2047
  if (this.outstanding) {
2048
- let [e, n] = D.transform(this.outstanding, t);
2048
+ let [e, n] = k.transform(this.outstanding, t);
2049
2049
  if (this.outstanding = e, t = n, this.buffer) {
2050
- let [e, n] = D.transform(this.buffer, t);
2050
+ let [e, n] = k.transform(this.buffer, t);
2051
2051
  this.buffer = e, t = n;
2052
2052
  }
2053
2053
  }
@@ -2064,7 +2064,7 @@ var D = class e {
2064
2064
  let t = e;
2065
2065
  return this.outstanding && (t = this.outstanding.transformIndex(t)), this.buffer && (t = this.buffer.transformIndex(t)), t;
2066
2066
  }
2067
- }, ve = class {
2067
+ }, A = class {
2068
2068
  element;
2069
2069
  previous;
2070
2070
  composing = !1;
@@ -2097,7 +2097,7 @@ var D = class e {
2097
2097
  if (this.composing) return;
2098
2098
  let t = this.element.value;
2099
2099
  if (t === this.previous) return;
2100
- let n = D.fromDiff(this.previous, t);
2100
+ let n = k.fromDiff(this.previous, t);
2101
2101
  this.previous = t, e(n);
2102
2102
  };
2103
2103
  this.element.addEventListener("input", r, { signal: n }), this.element.addEventListener("compositionstart", () => this.composing = !0, { signal: n }), this.element.addEventListener("compositionend", () => {
@@ -2117,10 +2117,10 @@ var D = class e {
2117
2117
  destroy() {
2118
2118
  this.controller.abort();
2119
2119
  }
2120
- }, ye = /* @__PURE__ */ "boxSizing.width.height.overflowX.overflowY.borderTopWidth.borderRightWidth.borderBottomWidth.borderLeftWidth.paddingTop.paddingRight.paddingBottom.paddingLeft.fontStyle.fontVariant.fontWeight.fontStretch.fontSize.lineHeight.fontFamily.textAlign.textTransform.textIndent.letterSpacing.wordSpacing.tabSize.whiteSpace.wordBreak.overflowWrap".split(".");
2121
- function be(e, t) {
2120
+ }, ge = /* @__PURE__ */ "boxSizing.width.height.overflowX.overflowY.borderTopWidth.borderRightWidth.borderBottomWidth.borderLeftWidth.paddingTop.paddingRight.paddingBottom.paddingLeft.fontStyle.fontVariant.fontWeight.fontStretch.fontSize.lineHeight.fontFamily.textAlign.textTransform.textIndent.letterSpacing.wordSpacing.tabSize.whiteSpace.wordBreak.overflowWrap".split(".");
2121
+ function _e(e, t) {
2122
2122
  let n = document.createElement("div"), r = getComputedStyle(e);
2123
- for (let e of ye) n.style[e] = r[e];
2123
+ for (let e of ge) n.style[e] = r[e];
2124
2124
  Object.assign(n.style, {
2125
2125
  position: "absolute",
2126
2126
  visibility: "hidden",
@@ -2139,7 +2139,7 @@ function be(e, t) {
2139
2139
  };
2140
2140
  return n.remove(), o;
2141
2141
  }
2142
- var xe = class {
2142
+ var ve = class {
2143
2143
  textarea;
2144
2144
  layer;
2145
2145
  cursors = [];
@@ -2173,7 +2173,7 @@ var xe = class {
2173
2173
  this.layer.replaceChildren();
2174
2174
  for (let r of this.cursors) {
2175
2175
  if (!r.selection) continue;
2176
- let i = r.user?.color ?? "#7c3aed", a = be(e, Math.min(r.selection.head, e.value.length)), o = document.createElement("div");
2176
+ let i = r.user?.color ?? "#7c3aed", a = _e(e, Math.min(r.selection.head, e.value.length)), o = document.createElement("div");
2177
2177
  o.className = "collab-cursor", Object.assign(o.style, {
2178
2178
  position: "absolute",
2179
2179
  top: `${t + a.top}px`,
@@ -2196,7 +2196,7 @@ var xe = class {
2196
2196
  destroy() {
2197
2197
  cancelAnimationFrame(this.frame), this.controller.abort(), this.layer.remove();
2198
2198
  }
2199
- }, Se = class extends f {
2199
+ }, ye = class extends f {
2200
2200
  ws;
2201
2201
  options;
2202
2202
  docId;
@@ -2212,9 +2212,10 @@ var xe = class {
2212
2212
  opCounter = 0;
2213
2213
  presenceTimer = null;
2214
2214
  _status = "connecting";
2215
+ wasReadOnly = null;
2215
2216
  clientId = null;
2216
2217
  constructor(e, t, n, r = {}) {
2217
- super(), this.ws = e, this.options = r, this.docId = t, this.channel = `doc:${t}`, this.adapter = n instanceof HTMLElement ? new ve(n) : n, n instanceof HTMLTextAreaElement && r.cursors !== !1 && (this.overlay = new xe(n)), n instanceof HTMLElement && n.setAttribute("aria-busy", "true"), this.adapter.attach((e) => this.handleLocalEdit(e), (e) => this.queuePresence(e)), this.unsubscribe = e.subscribe(this.channel, (e) => this.handleMessage(e)), this.offOpen = e.onOpen(() => this.join()), this.offStatus = e.onStatusChange((e) => {
2218
+ super(), this.ws = e, this.options = r, this.docId = t, this.channel = `doc:${t}`, this.adapter = n instanceof HTMLElement ? new A(n) : n, n instanceof HTMLTextAreaElement && r.cursors !== !1 && (this.overlay = new ve(n)), n instanceof HTMLElement && (n.setAttribute("aria-busy", "true"), (n instanceof HTMLTextAreaElement || n instanceof HTMLInputElement) && (this.wasReadOnly = n.readOnly, n.readOnly = !0)), this.adapter.attach((e) => this.handleLocalEdit(e), (e) => this.queuePresence(e)), this.unsubscribe = e.subscribe(this.channel, (e) => this.handleMessage(e)), this.offOpen = e.onOpen(() => this.join()), this.offStatus = e.onStatusChange((e) => {
2218
2219
  e !== "open" && this.setStatus("offline");
2219
2220
  }), e.isConnected ? this.join() : e.connect();
2220
2221
  }
@@ -2251,7 +2252,7 @@ var xe = class {
2251
2252
  break;
2252
2253
  case "collab:op":
2253
2254
  if (!this.client || t.clientId === this.clientId) return;
2254
- this.client.applyServer(D.fromJSON(t.op)), this.updateStatus();
2255
+ this.client.applyServer(k.fromJSON(t.op)), this.updateStatus();
2255
2256
  break;
2256
2257
  case "collab:ack":
2257
2258
  if (!this.client || t.opId && t.opId !== this.outstandingOpId) return;
@@ -2275,7 +2276,7 @@ var xe = class {
2275
2276
  }
2276
2277
  }
2277
2278
  handleInit(e) {
2278
- if (this.clientId = e.clientId, !this.client || e.since === null || e.since === void 0 || !e.missed) this.client = new _e(e.revision, {
2279
+ if (this.clientId = e.clientId, !this.client || e.since === null || e.since === void 0 || !e.missed) this.client = new he(e.revision, {
2279
2280
  send: (e, t) => this.sendOp(e, t),
2280
2281
  apply: (e) => this.applyRemote(e)
2281
2282
  }), this.outstandingOpId = null, this.adapter.setValue(e.content), this.emit("ready", {
@@ -2286,12 +2287,12 @@ var xe = class {
2286
2287
  remote: !0
2287
2288
  });
2288
2289
  else {
2289
- for (let t of e.missed) t.opId && t.opId === this.outstandingOpId ? (this.outstandingOpId = null, this.client.serverAck()) : this.client.applyServer(D.fromJSON(t.op));
2290
+ for (let t of e.missed) t.opId && t.opId === this.outstandingOpId ? (this.outstandingOpId = null, this.client.serverAck()) : this.client.applyServer(k.fromJSON(t.op));
2290
2291
  this.client.resend();
2291
2292
  }
2292
2293
  this.cursors.clear();
2293
2294
  for (let t of e.peers ?? []) this.cursors.set(t.clientId, t);
2294
- this.emitPresence(), this.adapter instanceof ve && this.adapter.element.removeAttribute("aria-busy"), this.updateStatus();
2295
+ this.emitPresence(), this.adapter instanceof A && (this.adapter.element.removeAttribute("aria-busy"), this.wasReadOnly !== null && (this.adapter.element.readOnly = this.wasReadOnly), this.wasReadOnly = null), this.updateStatus();
2295
2296
  }
2296
2297
  sendOp(e, t) {
2297
2298
  this.outstandingOpId = `${this.clientId ?? "c"}-${++this.opCounter}`, this.ws.send({
@@ -2357,9 +2358,9 @@ var xe = class {
2357
2358
  this.presenceTimer && clearTimeout(this.presenceTimer), this.ws.isConnected && this.ws.send({
2358
2359
  type: "collab:leave",
2359
2360
  channel: this.channel
2360
- }), this.unsubscribe?.(), this.offOpen?.(), this.offStatus?.(), this.adapter.destroy(), this.overlay?.destroy(), this.clear();
2361
+ }), this.unsubscribe?.(), this.offOpen?.(), this.offStatus?.(), this.adapter instanceof A && this.wasReadOnly !== null && (this.adapter.element.readOnly = this.wasReadOnly, this.adapter.element.removeAttribute("aria-busy")), this.adapter.destroy(), this.overlay?.destroy(), this.clear();
2361
2362
  }
2362
- }, Ce = class {
2363
+ }, be = class {
2363
2364
  getWs;
2364
2365
  constructor(e) {
2365
2366
  this.getWs = e;
@@ -2367,17 +2368,17 @@ var xe = class {
2367
2368
  open(e, t, n = {}) {
2368
2369
  let r = this.getWs();
2369
2370
  if (!r) throw Error("Collaboration needs a WebSocket: pass `websocket` to Arethesis.init().");
2370
- return new Se(r, e, t, n);
2371
+ return new ye(r, e, t, n);
2371
2372
  }
2372
- }, we = /^(\d{4})-(\d{2})-(\d{2})$/;
2373
- function O(e) {
2373
+ }, xe = /^(\d{4})-(\d{2})-(\d{2})$/;
2374
+ function j(e) {
2374
2375
  if (e == null || e === "") return null;
2375
2376
  if (e instanceof Date) return isNaN(e.getTime()) ? null : e;
2376
2377
  if (typeof e == "number") {
2377
2378
  let t = new Date(e);
2378
2379
  return isNaN(t.getTime()) ? null : t;
2379
2380
  }
2380
- let t = String(e), n = we.exec(t);
2381
+ let t = String(e), n = xe.exec(t);
2381
2382
  if (n) {
2382
2383
  let e = new Date(Number(n[1]), Number(n[2]) - 1, Number(n[3]));
2383
2384
  return isNaN(e.getTime()) ? null : e;
@@ -2385,45 +2386,45 @@ function O(e) {
2385
2386
  let r = new Date(t);
2386
2387
  return isNaN(r.getTime()) ? null : r;
2387
2388
  }
2388
- var k = (e, t = 2) => String(e).padStart(t, "0");
2389
- function A(e) {
2390
- return `${e.getFullYear()}-${k(e.getMonth() + 1)}-${k(e.getDate())}`;
2389
+ var M = (e, t = 2) => String(e).padStart(t, "0");
2390
+ function N(e) {
2391
+ return `${e.getFullYear()}-${M(e.getMonth() + 1)}-${M(e.getDate())}`;
2391
2392
  }
2392
- function Te(e) {
2393
- return `${A(e)}T${k(e.getHours())}:${k(e.getMinutes())}`;
2393
+ function Se(e) {
2394
+ return `${N(e)}T${M(e.getHours())}:${M(e.getMinutes())}`;
2394
2395
  }
2395
- function j(e) {
2396
+ function P(e) {
2396
2397
  return new Date(e.getFullYear(), e.getMonth(), e.getDate());
2397
2398
  }
2398
- var Ee = /YYYY|YY|MM|M|DD|D|HH|H|hh|h|mm|ss|A/g;
2399
- function De(e, t) {
2399
+ var Ce = /YYYY|YY|MM|M|DD|D|HH|H|hh|h|mm|ss|A/g;
2400
+ function we(e, t) {
2400
2401
  let n = e.getHours() % 12 || 12, r = {
2401
2402
  YYYY: String(e.getFullYear()),
2402
2403
  YY: String(e.getFullYear()).slice(-2),
2403
- MM: k(e.getMonth() + 1),
2404
+ MM: M(e.getMonth() + 1),
2404
2405
  M: String(e.getMonth() + 1),
2405
- DD: k(e.getDate()),
2406
+ DD: M(e.getDate()),
2406
2407
  D: String(e.getDate()),
2407
- HH: k(e.getHours()),
2408
+ HH: M(e.getHours()),
2408
2409
  H: String(e.getHours()),
2409
- hh: k(n),
2410
+ hh: M(n),
2410
2411
  h: String(n),
2411
- mm: k(e.getMinutes()),
2412
- ss: k(e.getSeconds()),
2412
+ mm: M(e.getMinutes()),
2413
+ ss: M(e.getSeconds()),
2413
2414
  A: e.getHours() < 12 ? "AM" : "PM"
2414
2415
  };
2415
- return t.split(/(\[[^\]]*\])/).map((e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e.replace(Ee, (e) => r[e])).join("");
2416
+ return t.split(/(\[[^\]]*\])/).map((e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e.replace(Ce, (e) => r[e])).join("");
2416
2417
  }
2417
2418
  // src/binding/validation-engine.ts
2418
- var M = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, Oe = /^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/, ke = /^\+?[\d\s\-().]+$/, Ae = class {
2419
+ var F = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, Te = /^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/, Ee = /^\+?[\d\s\-().]+$/, De = class {
2419
2420
  validators = /* @__PURE__ */ new Map();
2420
2421
  constructor() {
2421
2422
  this.registerBuiltIns();
2422
2423
  }
2423
2424
  registerBuiltIns() {
2424
2425
  let e = (e) => Array.isArray(e) ? e.length : String(e).length;
2425
- this.registerValidator("required", (e) => typeof e == "string" ? e.trim().length > 0 : typeof e == "boolean" ? e : !M(e), { message: "This field is required" }), this.registerValidator("email", (e) => M(e) || Oe.test(String(e)), { message: "Enter a valid email address" }), this.registerValidator("url", (e) => {
2426
- if (M(e)) return !0;
2426
+ this.registerValidator("required", (e) => typeof e == "string" ? e.trim().length > 0 : typeof e == "boolean" ? e : !F(e), { message: "This field is required" }), this.registerValidator("email", (e) => F(e) || Te.test(String(e)), { message: "Enter a valid email address" }), this.registerValidator("url", (e) => {
2427
+ if (F(e)) return !0;
2427
2428
  try {
2428
2429
  let t = new URL(String(e));
2429
2430
  return t.protocol === "http:" || t.protocol === "https:";
@@ -2431,16 +2432,16 @@ var M = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, Oe =
2431
2432
  return !1;
2432
2433
  }
2433
2434
  }, { message: "Enter a valid URL" }), this.registerValidator("phone", (e) => {
2434
- if (M(e)) return !0;
2435
+ if (F(e)) return !0;
2435
2436
  let t = String(e), n = t.replace(/\D/g, "").length;
2436
- return ke.test(t) && n >= 7 && n <= 15;
2437
- }, { message: "Enter a valid phone number" }), this.registerValidator("minLength", (t, n) => M(t) || e(t) >= Number(n.min), { message: "Must be at least {min} characters" }), this.registerValidator("maxLength", (t, n) => M(t) || e(t) <= Number(n.max), { message: "Must be at most {max} characters" });
2437
+ return Ee.test(t) && n >= 7 && n <= 15;
2438
+ }, { message: "Enter a valid phone number" }), this.registerValidator("minLength", (t, n) => F(t) || e(t) >= Number(n.min), { message: "Must be at least {min} characters" }), this.registerValidator("maxLength", (t, n) => F(t) || e(t) <= Number(n.max), { message: "Must be at most {max} characters" });
2438
2439
  let t = (e) => typeof e == "number" ? e : Number(e);
2439
- this.registerValidator("numeric", (e) => M(e) || !isNaN(t(e)), { message: "Must be a number" }), this.registerValidator("integer", (e) => M(e) || Number.isInteger(t(e)), { message: "Must be a whole number" }), this.registerValidator("min", (e, n) => M(e) || !isNaN(t(e)) && t(e) >= Number(n.min), { message: "Must be at least {min}" }), this.registerValidator("max", (e, n) => M(e) || !isNaN(t(e)) && t(e) <= Number(n.max), { message: "Must be at most {max}" }), this.registerValidator("between", (e, n) => M(e) || !isNaN(t(e)) && t(e) >= Number(n.min) && t(e) <= Number(n.max), { message: "Must be between {min} and {max}" }), this.registerValidator("pattern", (e, t) => {
2440
- if (M(e)) return !0;
2440
+ this.registerValidator("numeric", (e) => F(e) || !isNaN(t(e)), { message: "Must be a number" }), this.registerValidator("integer", (e) => F(e) || Number.isInteger(t(e)), { message: "Must be a whole number" }), this.registerValidator("min", (e, n) => F(e) || !isNaN(t(e)) && t(e) >= Number(n.min), { message: "Must be at least {min}" }), this.registerValidator("max", (e, n) => F(e) || !isNaN(t(e)) && t(e) <= Number(n.max), { message: "Must be at most {max}" }), this.registerValidator("between", (e, n) => F(e) || !isNaN(t(e)) && t(e) >= Number(n.min) && t(e) <= Number(n.max), { message: "Must be between {min} and {max}" }), this.registerValidator("pattern", (e, t) => {
2441
+ if (F(e)) return !0;
2441
2442
  let n = t.pattern instanceof RegExp ? t.pattern : new RegExp(String(t.pattern), typeof t.flags == "string" ? t.flags : void 0);
2442
2443
  return n.lastIndex = 0, n.test(String(e));
2443
- }, { message: "Invalid format" }), this.registerValidator("oneOf", (e, t) => M(e) || Array.isArray(t.values) && t.values.includes(e), { message: "Choose a valid option" }), this.registerValidator("equals", (e, t, n) => e === n.data[String(t.field)], { message: "Must match {field}" }), this.registerValidator("date", (e) => M(e) || O(e) !== null, { message: "Enter a valid date" }), this.registerValidator("custom", (e, t, n) => {
2444
+ }, { message: "Invalid format" }), this.registerValidator("oneOf", (e, t) => F(e) || Array.isArray(t.values) && t.values.includes(e), { message: "Choose a valid option" }), this.registerValidator("equals", (e, t, n) => e === n.data[String(t.field)], { message: "Must match {field}" }), this.registerValidator("date", (e) => F(e) || j(e) !== null, { message: "Enter a valid date" }), this.registerValidator("custom", (e, t, n) => {
2444
2445
  let r = t.fn;
2445
2446
  return !r || r(e, n);
2446
2447
  }, { message: "Invalid value" });
@@ -2530,27 +2531,27 @@ var M = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, Oe =
2530
2531
  };
2531
2532
  return e.replace(/\{(\w+)\}/g, (e, t) => t in r ? String(r[t]) : e);
2532
2533
  }
2533
- }, je = /* @__PURE__ */ new Set([
2534
+ }, Oe = /* @__PURE__ */ new Set([
2534
2535
  "http:",
2535
2536
  "https:",
2536
2537
  "mailto:",
2537
2538
  "tel:"
2538
- ]), Me = /* @__PURE__ */ new Set([
2539
+ ]), ke = /* @__PURE__ */ new Set([
2539
2540
  "http:",
2540
2541
  "https:",
2541
2542
  "blob:"
2542
- ]), Ne = /^data:image\/(png|gif|jpe?g|webp|avif|svg\+xml);/i;
2543
- function N(e, t = "link") {
2543
+ ]), Ae = /^data:image\/(png|gif|jpe?g|webp|avif|svg\+xml);/i;
2544
+ function I(e, t = "link") {
2544
2545
  if (e == null) return "";
2545
2546
  let n = String(e).trim();
2546
2547
  if (n === "") return "";
2547
2548
  let r = n.replace(/[\u0000-\u001F\u007F\s]+/g, ""), i = /^([a-z][a-z0-9+.-]*):/i.exec(r);
2548
2549
  if (!i) return n;
2549
2550
  let a = `${i[1].toLowerCase()}:`;
2550
- return t === "image" ? a === "data:" ? Ne.test(r) && !/svg/i.test(r) ? n : "" : Me.has(a) ? n : "" : je.has(a) ? n : "";
2551
+ return t === "image" ? a === "data:" ? Ae.test(r) && !/svg/i.test(r) ? n : "" : ke.has(a) ? n : "" : Oe.has(a) ? n : "";
2551
2552
  }
2552
2553
  // src/utils/sanitize.ts
2553
- var Pe = /* @__PURE__ */ "a.abbr.b.blockquote.br.code.del.div.em.figcaption.figure.h1.h2.h3.h4.h5.h6.hr.i.img.ins.kbd.li.mark.ol.p.pre.s.small.span.strong.sub.sup.table.tbody.td.tfoot.th.thead.tr.u.ul".split("."), Fe = {
2554
+ var je = /* @__PURE__ */ "a.abbr.b.blockquote.br.code.del.div.em.figcaption.figure.h1.h2.h3.h4.h5.h6.hr.i.img.ins.kbd.li.mark.ol.p.pre.s.small.span.strong.sub.sup.table.tbody.td.tfoot.th.thead.tr.u.ul".split("."), Me = {
2554
2555
  "*": [
2555
2556
  "class",
2556
2557
  "title",
@@ -2575,7 +2576,7 @@ var Pe = /* @__PURE__ */ "a.abbr.b.blockquote.br.code.del.div.em.figcaption.figu
2575
2576
  "scope"
2576
2577
  ],
2577
2578
  ol: ["start"]
2578
- }, Ie = /* @__PURE__ */ new Set([
2579
+ }, Ne = /* @__PURE__ */ new Set([
2579
2580
  "script",
2580
2581
  "style",
2581
2582
  "iframe",
@@ -2596,12 +2597,12 @@ var Pe = /* @__PURE__ */ "a.abbr.b.blockquote.br.code.del.div.em.figcaption.figu
2596
2597
  "frame",
2597
2598
  "frameset"
2598
2599
  ]);
2599
- function P(e, t = {}) {
2600
+ function L(e, t = {}) {
2600
2601
  if (e == null) return "";
2601
- let n = new Set(t.allowedTags ?? Pe), r = t.allowedAttributes ?? Fe, i = new DOMParser().parseFromString(`<body>${String(e)}</body>`, "text/html");
2602
- return Le(i.body, n, r), i.body.innerHTML;
2602
+ let n = new Set(t.allowedTags ?? je), r = t.allowedAttributes ?? Me, i = new DOMParser().parseFromString(`<body>${String(e)}</body>`, "text/html");
2603
+ return Pe(i.body, n, r), i.body.innerHTML;
2603
2604
  }
2604
- function Le(e, t, n) {
2605
+ function Pe(e, t, n) {
2605
2606
  for (let r of Array.from(e.childNodes)) {
2606
2607
  if (r.nodeType === Node.COMMENT_NODE || r.nodeType === Node.PROCESSING_INSTRUCTION_NODE) {
2607
2608
  r.remove();
@@ -2609,44 +2610,44 @@ function Le(e, t, n) {
2609
2610
  }
2610
2611
  if (r.nodeType !== Node.ELEMENT_NODE) continue;
2611
2612
  let e = r, i = e.tagName.toLowerCase();
2612
- Ie.has(i) ? e.remove() : (Le(e, t, n), t.has(i) ? Re(e, i, n) : e.replaceWith(...Array.from(e.childNodes)));
2613
+ Ne.has(i) ? e.remove() : (Pe(e, t, n), t.has(i) ? Fe(e, i, n) : e.replaceWith(...Array.from(e.childNodes)));
2613
2614
  }
2614
2615
  }
2615
- function Re(e, t, n) {
2616
+ function Fe(e, t, n) {
2616
2617
  let r = /* @__PURE__ */ new Set([...n["*"] ?? [], ...n[t] ?? []]);
2617
2618
  for (let t of Array.from(e.attributes)) {
2618
2619
  let n = t.name.toLowerCase();
2619
2620
  if (!r.has(n) || n.startsWith("on")) e.removeAttribute(t.name);
2620
2621
  else if (n === "href") {
2621
- let n = N(t.value, "link");
2622
+ let n = I(t.value, "link");
2622
2623
  n ? e.setAttribute("href", n) : e.removeAttribute("href");
2623
2624
  } else if (n === "src") {
2624
- let n = N(t.value, "image");
2625
+ let n = I(t.value, "image");
2625
2626
  n ? e.setAttribute("src", n) : e.removeAttribute("src");
2626
2627
  }
2627
2628
  }
2628
2629
  t === "a" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer");
2629
2630
  }
2630
- function F(e) {
2631
+ function R(e) {
2631
2632
  return e == null ? "" : new DOMParser().parseFromString(String(e), "text/html").body.textContent ?? "";
2632
2633
  }
2633
2634
  // src/utils/dom.ts
2634
- function I(e) {
2635
+ function z(e) {
2635
2636
  return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/([^\w-])/g, "\\$1").replace(/^(\d)/, "\\3$1 ");
2636
2637
  }
2637
- function ze(e) {
2638
+ function Ie(e) {
2638
2639
  return e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase());
2639
2640
  }
2640
- var Be = 0;
2641
- function L(e = "ar") {
2642
- return Be += 1, `${e}-${Be.toString(36)}`;
2641
+ var Le = 0;
2642
+ function B(e = "ar") {
2643
+ return Le += 1, `${e}-${Le.toString(36)}`;
2643
2644
  }
2644
- function Ve(e) {
2645
+ function Re(e) {
2645
2646
  let t = document.createElement("template");
2646
2647
  return t.innerHTML = e, t.content;
2647
2648
  }
2648
2649
  // src/binding/data-binder.ts
2649
- var He = /* @__PURE__ */ new Set([
2650
+ var ze = /* @__PURE__ */ new Set([
2650
2651
  "href",
2651
2652
  "src",
2652
2653
  "action",
@@ -2657,29 +2658,29 @@ var He = /* @__PURE__ */ new Set([
2657
2658
  "background",
2658
2659
  "ping"
2659
2660
  ]);
2660
- function R(e) {
2661
+ function V(e) {
2661
2662
  return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement;
2662
2663
  }
2663
- function z(e) {
2664
+ function H(e) {
2664
2665
  return e instanceof HTMLElement && (e.isContentEditable || e.getAttribute("contenteditable") === "true");
2665
2666
  }
2666
- function Ue() {
2667
+ function Be() {
2667
2668
  return typeof document < "u" && document.documentElement.lang || "en-US";
2668
2669
  }
2669
- var We = class {
2670
+ var Ve = class {
2670
2671
  validationEngine;
2671
2672
  bindings = /* @__PURE__ */ new WeakMap();
2672
2673
  timers = /* @__PURE__ */ new WeakMap();
2673
2674
  validationRuns = /* @__PURE__ */ new WeakMap();
2674
2675
  touched = /* @__PURE__ */ new WeakSet();
2675
2676
  constructor(e) {
2676
- this.validationEngine = e ?? new Ae();
2677
+ this.validationEngine = e ?? new De();
2677
2678
  }
2678
2679
  bind(e, t, n) {
2679
2680
  this.unbind(e);
2680
2681
  let r = new AbortController(), i = [];
2681
2682
  for (let [t, r] of Object.entries(n.fields)) {
2682
- let n = r.selector ?? `[data-bind="${I(t)}"]`, a = Array.from(e.querySelectorAll(n));
2683
+ let n = r.selector ?? `[data-bind="${z(t)}"]`, a = Array.from(e.querySelectorAll(n));
2683
2684
  e.matches?.(n) && a.unshift(e), i.push({
2684
2685
  key: t,
2685
2686
  path: r.field ?? t,
@@ -2717,7 +2718,7 @@ var We = class {
2717
2718
  let n = r(t, e.path);
2718
2719
  if (!(e.initialized && s(n, e.lastValue))) {
2719
2720
  e.lastValue = n, e.initialized = !0;
2720
- for (let r of e.targets) r === document.activeElement && (R(r) || z(r)) && e.config.twoWay || this.applyValue(r, n, e.config, t);
2721
+ for (let r of e.targets) r === document.activeElement && (V(r) || H(r)) && e.config.twoWay || this.applyValue(r, n, e.config, t);
2721
2722
  }
2722
2723
  }
2723
2724
  }
@@ -2734,13 +2735,13 @@ var We = class {
2734
2735
  }
2735
2736
  }
2736
2737
  applyValue(e, t, n, r) {
2737
- n.visible && (e.hidden = !n.visible(t, r)), n.attribute ? this.applyAttribute(e, n.attribute, this.format(t, n, r)) : R(e) ? this.applyToControl(e, t, n) : n.inputType === "rich-text" && z(e) ? e.innerHTML = P(t) : this.applyToDisplay(e, t, n, r);
2738
+ n.visible && (e.hidden = !n.visible(t, r)), n.attribute ? this.applyAttribute(e, n.attribute, this.format(t, n, r)) : V(e) ? this.applyToControl(e, t, n) : n.inputType === "rich-text" && H(e) ? e.innerHTML = L(t) : this.applyToDisplay(e, t, n, r);
2738
2739
  }
2739
2740
  applyAttribute(e, t, n) {
2740
2741
  let r = t.toLowerCase();
2741
2742
  if (!(r.startsWith("on") || r === "style" && /expression|url\s*\(/i.test(n))) {
2742
- if (He.has(r)) {
2743
- let i = N(n, r === "href" || r === "action" || r === "formaction" || r === "ping" ? "link" : "image");
2743
+ if (ze.has(r)) {
2744
+ let i = I(n, r === "href" || r === "action" || r === "formaction" || r === "ping" ? "link" : "image");
2744
2745
  i ? e.setAttribute(t, i) : e.removeAttribute(t);
2745
2746
  } else e.setAttribute(t, n);
2746
2747
  }
@@ -2748,21 +2749,21 @@ var We = class {
2748
2749
  format(e, t, n) {
2749
2750
  if (typeof t.format == "function") return t.format(e, n);
2750
2751
  if (e == null || e === "") return t.emptyText ?? "";
2751
- let r = t.locale ?? Ue(), i = t.displayType ?? "text";
2752
+ let r = t.locale ?? Be(), i = t.displayType ?? "text";
2752
2753
  switch (i) {
2753
2754
  case "date":
2754
2755
  case "datetime":
2755
2756
  case "time": {
2756
- let n = O(e);
2757
- return n ? typeof t.format == "string" ? De(n, t.format) : i === "date" ? n.toLocaleDateString(r, t.intl) : i === "time" ? n.toLocaleTimeString(r, {
2757
+ let n = j(e);
2758
+ return n ? typeof t.format == "string" ? we(n, t.format) : i === "date" ? n.toLocaleDateString(r, t.intl) : i === "time" ? n.toLocaleTimeString(r, {
2758
2759
  hour: "numeric",
2759
2760
  minute: "2-digit",
2760
2761
  ...t.intl
2761
2762
  }) : n.toLocaleString(r, t.intl) : t.emptyText ?? "";
2762
2763
  }
2763
2764
  case "relative": {
2764
- let n = O(e);
2765
- return n ? V(n, r) : t.emptyText ?? "";
2765
+ let n = j(e);
2766
+ return n ? Ke(n, r) : t.emptyText ?? "";
2766
2767
  }
2767
2768
  case "currency":
2768
2769
  case "number":
@@ -2788,10 +2789,10 @@ var We = class {
2788
2789
  let i = n.displayType ?? "text", a = this.format(t, n, r);
2789
2790
  switch (i) {
2790
2791
  case "html":
2791
- e.innerHTML = n.trusted ? String(t ?? "") : P(t);
2792
+ e.innerHTML = n.trusted ? String(t ?? "") : L(t);
2792
2793
  return;
2793
2794
  case "image": {
2794
- let n = N(t, "image");
2795
+ let n = I(t, "image");
2795
2796
  if (e instanceof HTMLImageElement) {
2796
2797
  n ? e.src = n : e.removeAttribute("src");
2797
2798
  return;
@@ -2803,7 +2804,7 @@ var We = class {
2803
2804
  return;
2804
2805
  }
2805
2806
  case "link": {
2806
- let i = N(n.href ? n.href(t, r) : t, "link"), o = n.linkText ?? a;
2807
+ let i = I(n.href ? n.href(t, r) : t, "link"), o = n.linkText ?? a;
2807
2808
  if (e instanceof HTMLAnchorElement) {
2808
2809
  i ? e.href = i : e.removeAttribute("href"), n.linkText === void 0 && e.dataset.keepText || (e.textContent = o);
2809
2810
  return;
@@ -2831,11 +2832,11 @@ var We = class {
2831
2832
  }
2832
2833
  case "relative": {
2833
2834
  e.textContent = a;
2834
- let r = typeof n.format == "function" ? null : O(t);
2835
+ let r = typeof n.format == "function" ? null : j(t);
2835
2836
  if (r) {
2836
- let t = n.locale ?? Ue();
2837
- e instanceof HTMLTimeElement && (e.dateTime = r.toISOString()), (!e.hasAttribute("title") || e.hasAttribute("data-relative-title")) && (e.setAttribute("title", r.toLocaleString(t)), e.setAttribute("data-relative-title", "")), n.live === !1 ? B.unwatch(e) : B.watch(e, r, t);
2838
- } else B.unwatch(e);
2837
+ let t = n.locale ?? Be();
2838
+ e instanceof HTMLTimeElement && (e.dateTime = r.toISOString()), (!e.hasAttribute("title") || e.hasAttribute("data-relative-title")) && (e.setAttribute("title", r.toLocaleString(t)), e.setAttribute("data-relative-title", "")), n.live === !1 ? Ge.unwatch(e) : Ge.watch(e, r, t);
2839
+ } else Ge.unwatch(e);
2839
2840
  return;
2840
2841
  }
2841
2842
  default: e.textContent = a;
@@ -2860,13 +2861,13 @@ var We = class {
2860
2861
  return;
2861
2862
  }
2862
2863
  case "date": {
2863
- let n = O(t);
2864
- e.value = n ? A(n) : "";
2864
+ let n = j(t);
2865
+ e.value = n ? N(n) : "";
2865
2866
  return;
2866
2867
  }
2867
2868
  case "datetime": {
2868
- let n = O(t);
2869
- e.value = n ? Te(n) : "";
2869
+ let n = j(t);
2870
+ e.value = n ? Se(n) : "";
2870
2871
  return;
2871
2872
  }
2872
2873
  case "tags":
@@ -2877,7 +2878,7 @@ var We = class {
2877
2878
  }
2878
2879
  readValue(e, t) {
2879
2880
  let n;
2880
- if (R(e)) switch (this.inputTypeOf(e, t)) {
2881
+ if (V(e)) switch (this.inputTypeOf(e, t)) {
2881
2882
  case "checkbox":
2882
2883
  case "toggle":
2883
2884
  n = e.checked;
@@ -2894,14 +2895,14 @@ var We = class {
2894
2895
  break;
2895
2896
  default: n = e.value;
2896
2897
  }
2897
- else n = z(e) && t.inputType === "rich-text" ? P(e.innerHTML) : e.textContent;
2898
+ else n = H(e) && t.inputType === "rich-text" ? L(e.innerHTML) : e.textContent;
2898
2899
  return t.parse ? t.parse(n) : n;
2899
2900
  }
2900
2901
  values(e) {
2901
2902
  let t = this.bindings.get(e), n = {};
2902
2903
  if (!t) return n;
2903
2904
  for (let e of t.fields) {
2904
- let i = e.targets.find((e) => R(e) || z(e));
2905
+ let i = e.targets.find((e) => V(e) || H(e));
2905
2906
  n[e.key] = i ? this.readValue(i, e.config) : r(t.data, e.path);
2906
2907
  }
2907
2908
  return n;
@@ -2910,7 +2911,7 @@ var We = class {
2910
2911
  return new Set(e.config.validateOn ?? ["blur", "change"]);
2911
2912
  }
2912
2913
  listen(e, t, n) {
2913
- if (!(R(n) || z(n))) return;
2914
+ if (!(V(n) || H(n))) return;
2914
2915
  let { signal: r } = e.controller, i = t.config.validation, a = this.triggers(e), o = (r) => {
2915
2916
  let o = this.readValue(n, t.config), s = () => {
2916
2917
  t.config.twoWay && (t.lastValue = o, e.config.onChange?.(t.path, o));
@@ -2959,7 +2960,7 @@ var We = class {
2959
2960
  let n = [];
2960
2961
  for (let e of t.fields) {
2961
2962
  if (!e.config.validation) continue;
2962
- let i = e.targets.find((e) => R(e) || z(e));
2963
+ let i = e.targets.find((e) => V(e) || H(e));
2963
2964
  if (i) {
2964
2965
  this.touched.add(i);
2965
2966
  let r = await this.validateTarget(t, e, i);
@@ -2983,9 +2984,9 @@ var We = class {
2983
2984
  o.className = "error-summary__title", o.textContent = n.length === 1 ? "Please fix 1 error:" : `Please fix ${n.length} errors:`;
2984
2985
  let s = document.createElement("ul");
2985
2986
  for (let e of n) {
2986
- let n = document.createElement("li"), r = t.fields.find((t) => t.key === e.field), i = r?.config.validation?.label, a = i && !e.message.toLowerCase().includes(i.toLowerCase()) ? `${i}: ${e.message}` : e.message, o = r?.targets.find((e) => R(e) || z(e));
2987
+ let n = document.createElement("li"), r = t.fields.find((t) => t.key === e.field), i = r?.config.validation?.label, a = i && !e.message.toLowerCase().includes(i.toLowerCase()) ? `${i}: ${e.message}` : e.message, o = r?.targets.find((e) => V(e) || H(e));
2987
2988
  if (o) {
2988
- o.id ||= L("field");
2989
+ o.id ||= B("field");
2989
2990
  let e = document.createElement("a");
2990
2991
  e.href = `#${o.id}`, e.textContent = a, e.addEventListener("click", (e) => {
2991
2992
  e.preventDefault(), o.focus();
@@ -3015,14 +3016,14 @@ var We = class {
3015
3016
  let n = e.ownerDocument.getElementById(t);
3016
3017
  if (n?.classList.contains("field-error")) return n;
3017
3018
  }
3018
- let i = (t ? e.closest("form, [data-form], body")?.querySelector(`[data-error-for="${I(t)}"]`) : null) ?? null;
3019
+ let i = (t ? e.closest("form, [data-form], body")?.querySelector(`[data-error-for="${z(t)}"]`) : null) ?? null;
3019
3020
  if (!i) {
3020
3021
  if (!n) return null;
3021
3022
  i = document.createElement("div"), i.className = "field-error", i.setAttribute("data-generated", ""), e.insertAdjacentElement("afterend", i);
3022
3023
  }
3023
- return i.classList.add("field-error"), i.id || (i.id = L("error")), i.setAttribute("aria-live", "polite"), e.setAttribute("aria-describedby", [...r, i.id].join(" ")), i;
3024
+ return i.classList.add("field-error"), i.id || (i.id = B("error")), i.setAttribute("aria-live", "polite"), e.setAttribute("aria-describedby", [...r, i.id].join(" ")), i;
3024
3025
  }
3025
- }, Ge = [
3026
+ }, He = [
3026
3027
  ["year", 31536e3],
3027
3028
  ["month", 2592e3],
3028
3029
  ["week", 604800],
@@ -3031,11 +3032,11 @@ var We = class {
3031
3032
  ["minute", 60],
3032
3033
  ["second", 1]
3033
3034
  ];
3034
- function Ke(e, t) {
3035
+ function Ue(e, t) {
3035
3036
  let n = Math.abs(t - e.getTime()) / 1e3;
3036
3037
  return n < 60 ? 5e3 : n < 3600 ? 15e3 : n < 86400 ? 3e5 : 36e5;
3037
3038
  }
3038
- var qe = class {
3039
+ var We = class {
3039
3040
  targets = /* @__PURE__ */ new Map();
3040
3041
  timer = null;
3041
3042
  listening = !1;
@@ -3061,7 +3062,7 @@ var qe = class {
3061
3062
  this.targets.delete(t);
3062
3063
  continue;
3063
3064
  }
3064
- let i = V(n, r, e);
3065
+ let i = Ke(n, r, e);
3065
3066
  t.textContent !== i && (t.textContent = i);
3066
3067
  }
3067
3068
  this.targets.size ? this.schedule(e) : this.stop();
@@ -3072,26 +3073,26 @@ var qe = class {
3072
3073
  schedule(e = Date.now()) {
3073
3074
  if (this.timer || this.targets.size === 0) return;
3074
3075
  let t = Infinity;
3075
- for (let { date: n } of this.targets.values()) t = Math.min(t, Ke(n, e));
3076
+ for (let { date: n } of this.targets.values()) t = Math.min(t, Ue(n, e));
3076
3077
  this.timer = setTimeout(() => this.tick(), t), !this.listening && typeof document < "u" && (document.addEventListener("visibilitychange", this.onVisibility), this.listening = !0);
3077
3078
  }
3078
- }, B = new qe();
3079
- function V(e, t = "en-US", n = Date.now()) {
3079
+ }, Ge = new We();
3080
+ function Ke(e, t = "en-US", n = Date.now()) {
3080
3081
  let r = Math.round((e.getTime() - n) / 1e3), i = new Intl.RelativeTimeFormat(t, { numeric: "auto" });
3081
- for (let [e, t] of Ge) if (Math.abs(r) >= t || e === "second") return i.format(Math.round(r / t), e);
3082
+ for (let [e, t] of He) if (Math.abs(r) >= t || e === "second") return i.format(Math.round(r / t), e);
3082
3083
  return i.format(0, "second");
3083
3084
  }
3084
3085
  // src/components/runtime.ts
3085
- var H = null;
3086
+ var qe = null;
3086
3087
  function Je(e) {
3087
- H = e;
3088
+ qe = e;
3088
3089
  }
3089
3090
  function U() {
3090
- if (!H) throw Error("Arethesis is not loaded. Import from \"arethesis\" and call getArethesis() first.");
3091
- return H;
3091
+ if (!qe) throw Error("Arethesis is not loaded. Import from \"arethesis\" and call getArethesis() first.");
3092
+ return qe;
3092
3093
  }
3093
3094
  function Ye() {
3094
- return H !== null;
3095
+ return qe !== null;
3095
3096
  }
3096
3097
  // src/components/template-loader.ts
3097
3098
  var Xe = class {
@@ -3103,7 +3104,7 @@ var Xe = class {
3103
3104
  this.fetchImpl = () => e;
3104
3105
  }
3105
3106
  register(e, t) {
3106
- this.files.set(e, Ve(t));
3107
+ this.files.set(e, Re(t));
3107
3108
  for (let t of this.extracted.keys()) t.startsWith(`${e}#`) && this.extracted.delete(t);
3108
3109
  }
3109
3110
  async load(e, t) {
@@ -3113,7 +3114,7 @@ var Xe = class {
3113
3114
  return i || (i = this.extract(n, t, e), this.extracted.set(r, i)), i.cloneNode(!0);
3114
3115
  }
3115
3116
  async has(e, t) {
3116
- return (await this.loadFile(e)).querySelector(`template#${I(t)}`) !== null;
3117
+ return (await this.loadFile(e)).querySelector(`template#${z(t)}`) !== null;
3117
3118
  }
3118
3119
  loadFile(e) {
3119
3120
  let t = this.files.get(e);
@@ -3126,10 +3127,10 @@ var Xe = class {
3126
3127
  async fetchFile(e) {
3127
3128
  let t = await this.fetchImpl()(e);
3128
3129
  if (!t.ok) throw Error(`Failed to load template ${e} (${t.status})`);
3129
- return Ve(await t.text());
3130
+ return Re(await t.text());
3130
3131
  }
3131
3132
  extract(e, t, n) {
3132
- let r = e.querySelector(`template#${I(t)}`);
3133
+ let r = e.querySelector(`template#${z(t)}`);
3133
3134
  if (r) return r.content.cloneNode(!0);
3134
3135
  if (t === "main" && !e.querySelector("template")) return e.cloneNode(!0);
3135
3136
  throw Error(`Template "#${t}" not found in ${n}`);
@@ -3167,8 +3168,10 @@ var Xe = class {
3167
3168
  for (let e of r.conflicts ?? []) if (i.has(e)) return console.error(`Mixin "${t}" conflicts with "${e}"`), null;
3168
3169
  for (let t of r.dependencies ?? []) i.has(t) || this.apply(e, t, {});
3169
3170
  try {
3170
- let a = r.fn(e, n);
3171
- return i.set(t, a), e.dataset.mixinsApplied = Array.from(i.keys()).join(" "), a;
3171
+ let a = r.fn(e, n), o = a.destroy.bind(a), s = i;
3172
+ return a.destroy = () => {
3173
+ s.get(t) === a && (s.delete(t), s.size ? e.dataset.mixinsApplied = Array.from(s.keys()).join(" ") : delete e.dataset.mixinsApplied), o();
3174
+ }, i.set(t, a), e.dataset.mixinsApplied = Array.from(i.keys()).join(" "), a;
3172
3175
  } catch (e) {
3173
3176
  return console.error(`Failed to apply mixin "${t}":`, e), null;
3174
3177
  }
@@ -3181,12 +3184,12 @@ var Xe = class {
3181
3184
  }
3182
3185
  remove(e, t) {
3183
3186
  let n = this.applied.get(e), r = n?.get(t);
3184
- return !n || !r ? !1 : (r.destroy(), n.delete(t), n.size ? e.dataset.mixinsApplied = Array.from(n.keys()).join(" ") : delete e.dataset.mixinsApplied, !0);
3187
+ return !n || !r ? !1 : (r.destroy(), !0);
3185
3188
  }
3186
3189
  removeAll(e) {
3187
3190
  let t = this.applied.get(e);
3188
3191
  if (t) {
3189
- for (let e of t.values()) e.destroy();
3192
+ for (let e of [...t.values()]) e.destroy();
3190
3193
  t.clear(), delete e.dataset.mixinsApplied;
3191
3194
  }
3192
3195
  }
@@ -3198,7 +3201,7 @@ var Xe = class {
3198
3201
  console.error(`data-mixin-${t} is not valid JSON`);
3199
3202
  }
3200
3203
  let i = `data-mixin-${t}-`;
3201
- for (let t of Array.from(e.attributes)) t.name.startsWith(i) && (n[ze(t.name.slice(i.length))] = Qe(t.value));
3204
+ for (let t of Array.from(e.attributes)) t.name.startsWith(i) && (n[Ie(t.name.slice(i.length))] = Qe(t.value));
3202
3205
  return n;
3203
3206
  }
3204
3207
  init(e = document) {
@@ -3268,29 +3271,32 @@ var lt = class extends HTMLElement {
3268
3271
  loadingTemplateId = "loading";
3269
3272
  errorTemplateId = "error";
3270
3273
  #e = null;
3271
- #t = [];
3272
- #n = null;
3273
- #r = [];
3274
- #i = 0;
3275
- #a = null;
3276
- #o = () => {};
3277
- #s = /* @__PURE__ */ new Map();
3278
- #c = null;
3274
+ #t = null;
3275
+ #n = [];
3276
+ #r = null;
3277
+ #i = [];
3278
+ #a = 0;
3279
+ #o = null;
3280
+ #s = () => {};
3281
+ #c = /* @__PURE__ */ new Map();
3279
3282
  #l = null;
3280
- #u = !1;
3283
+ #u = null;
3284
+ #d = !1;
3281
3285
  ready = new Promise((e) => {
3282
- this.#o = e;
3286
+ this.#s = e;
3283
3287
  });
3284
3288
  async connectedCallback() {
3285
- this.#n = new AbortController(), this.#u || (this.#u = !0, await st(), this.hasAttribute("data-hydrate") || !this.metadata?.templateKey ? this.#a = this.mainTemplateId : this.#a === null && await this.render(this.mainTemplateId), this.#o()), this.onConnected(), this.#p();
3289
+ this.#r = new AbortController(), this.#d || (this.#d = !0, await st(), this.hasAttribute("data-hydrate") || !this.metadata?.templateKey ? this.#o = this.mainTemplateId : this.#o === null && await this.render(this.mainTemplateId), this.#s()), this.onConnected();
3290
+ let e = this.#t;
3291
+ this.#t = null, e && !this.#e && this.bind(e.kind === "list" ? e.view : e.ref, e.config), this.#m();
3286
3292
  }
3287
3293
  disconnectedCallback() {
3288
- this.#n?.abort(), this.#n = null;
3289
- for (let e of this.#r.splice(0)) e.destroy();
3290
- this.#f(), this.onDisconnected();
3294
+ this.#r?.abort(), this.#r = null;
3295
+ for (let e of this.#i.splice(0)) e.destroy();
3296
+ this.#t = this.#e, this.#p(), this.onDisconnected();
3291
3297
  }
3292
3298
  get signal() {
3293
- return this.#n ||= new AbortController(), this.#n.signal;
3299
+ return this.#r ||= new AbortController(), this.#r.signal;
3294
3300
  }
3295
3301
  listen(e, t, n, r = {}) {
3296
3302
  e.addEventListener(t, n, {
@@ -3306,7 +3312,7 @@ var lt = class extends HTMLElement {
3306
3312
  }
3307
3313
  useMixin(e, t = {}, n = this) {
3308
3314
  let r = G.apply(n, e, t);
3309
- return r && this.#r.push(r), r;
3315
+ return r && this.#i.push(r), r;
3310
3316
  }
3311
3317
  on(e, t) {
3312
3318
  let n = (e) => t(e.detail, e);
@@ -3337,10 +3343,10 @@ var lt = class extends HTMLElement {
3337
3343
  }
3338
3344
  }
3339
3345
  async render(e) {
3340
- let t = ++this.#i, n = await this.loadTemplate(e);
3341
- return t !== this.#i || !n ? !1 : (this.replaceChildren(n), this.#a = e, this.#s.clear(), this.#c = null, this.#l?.disconnect(), this.#l = null, !0);
3346
+ let t = ++this.#a, n = await this.loadTemplate(e);
3347
+ return t !== this.#a || !n ? !1 : (this.replaceChildren(n), this.#o = e, this.#c.clear(), this.#l = null, this.#u?.disconnect(), this.#u = null, !0);
3342
3348
  }
3343
- #d(e) {
3349
+ #f(e) {
3344
3350
  this.state = e, this.dataset.state = e, this.toggleAttribute("aria-busy", e === "loading");
3345
3351
  }
3346
3352
  get bindConfig() {
@@ -3350,14 +3356,14 @@ var lt = class extends HTMLElement {
3350
3356
  return this.#e ? this.#e.kind === "object" ? this.#e.ref : this.#e.view : null;
3351
3357
  }
3352
3358
  bind(e, t) {
3353
- this.#f();
3359
+ this.#t = null, this.#p();
3354
3360
  let { store: n, listViews: r } = U();
3355
3361
  if (ct(e)) {
3356
3362
  this.#e = {
3357
3363
  kind: "list",
3358
3364
  view: e,
3359
3365
  config: t
3360
- }, this.#t.push(r.subscribe(e.id, (e) => void this.#y(e))), this.#t.push(n.subscribeToType(e.type, (e, t) => this.#C(e, t))), this.ready.then(() => this.#y(e)), (e.status === "idle" || e.status === "stale") && r.load(e).catch((e) => console.error(`<${this.localName}>: failed to load list`, e));
3366
+ }, this.#n.push(r.subscribe(e.id, (e) => void this.#b(e))), this.#n.push(n.subscribeToType(e.type, (e, t) => this.#w(e, t))), this.ready.then(() => this.#b(e)), (e.status === "idle" || e.status === "stale") && r.load(e).catch((e) => console.error(`<${this.localName}>: failed to load list`, e));
3361
3367
  return;
3362
3368
  }
3363
3369
  let i = {
@@ -3368,25 +3374,33 @@ var lt = class extends HTMLElement {
3368
3374
  kind: "object",
3369
3375
  ref: i,
3370
3376
  config: t
3371
- }, this.#t.push(n.subscribe(i.type, i.id, (e, t) => this.#h(e, t)));
3377
+ }, this.#n.push(n.subscribe(i.type, i.id, (e, t) => this.#g(e, t)));
3372
3378
  let a = n.get(i.type, i.id);
3373
- a ? (this.ready.then(() => this.#g(a)), a.status === "stale" && this.refetch()) : n.getTypeConfig(i.type).endpoint && this.refetch();
3379
+ a ? (this.ready.then(() => this.#_(a)), a.status === "stale" && this.refetch()) : n.getTypeConfig(i.type).endpoint && this.refetch();
3374
3380
  }
3375
3381
  bindList(e, t) {
3376
3382
  let n = U().listViews.getOrCreate(e);
3377
3383
  return this.bind(n, t), n;
3378
3384
  }
3379
3385
  unbind() {
3386
+ this.#t = null;
3380
3387
  let e = this.#e !== null;
3381
- this.#f(), e && (this.#d("idle"), this.onUnbind());
3382
- }
3383
- #f() {
3384
- for (let e of this.#t.splice(0)) e();
3385
- this.#l?.disconnect(), this.#l = null, this.#e && U().binder.unbind(this);
3386
- for (let e of this.#s.values()) U().binder.unbind(e);
3387
- this.#s.clear(), this.#e = null;
3388
+ this.#p(), e && (this.#f("idle"), this.onUnbind());
3388
3389
  }
3389
3390
  #p() {
3391
+ for (let e of this.#n.splice(0)) e();
3392
+ this.#u?.disconnect(), this.#u = null;
3393
+ let { binder: e } = U();
3394
+ if (this.#e && e.unbind(this), this.#e?.kind === "list") {
3395
+ let e = this.#y();
3396
+ this.#x(e), this.#l?.remove(), this.#l = null, e.removeAttribute("aria-busy");
3397
+ } else {
3398
+ for (let t of this.#c.values()) e.unbind(t);
3399
+ this.#c.clear();
3400
+ }
3401
+ this.#e = null;
3402
+ }
3403
+ #m() {
3390
3404
  if (this.#e) return;
3391
3405
  let e = this.getAttribute("data-source");
3392
3406
  if (e && e.includes(":")) {
@@ -3429,7 +3443,7 @@ var lt = class extends HTMLElement {
3429
3443
  let { type: r, id: i } = this.#e.ref, a = e.getTypeConfig(r).endpoint;
3430
3444
  if (!a) return;
3431
3445
  let o = e.has(r, i);
3432
- o ? e.setStatus(r, i, "updating") : (this.#d("loading"), await this.#m(this.loadingTemplateId));
3446
+ o ? e.setStatus(r, i, "updating") : (this.#f("loading"), await this.#h(this.loadingTemplateId));
3433
3447
  try {
3434
3448
  await t.fetchEndpoint(a, { id: i });
3435
3449
  } catch (t) {
@@ -3437,28 +3451,28 @@ var lt = class extends HTMLElement {
3437
3451
  o ? e.setStatus(r, i, "error") : await this.showError(t);
3438
3452
  }
3439
3453
  }
3440
- async #m(e) {
3441
- return this.#a === e ? !0 : await this.hasTemplate(e) ? this.render(e) : !1;
3454
+ async #h(e) {
3455
+ return this.#o === e ? !0 : await this.hasTemplate(e) ? this.render(e) : !1;
3442
3456
  }
3443
- #h(e, t) {
3444
- t === "delete" ? (this.#d("idle"), this.onUnbind()) : e && (t === "invalidate" ? (this.dataset.stale = "", U().store.subscriberCount(e.type, e.id) > 0 && this.refetch()) : this.#g(e));
3457
+ #g(e, t) {
3458
+ t === "delete" ? (this.#f("idle"), this.onUnbind()) : e && (t === "invalidate" ? (this.dataset.stale = "", U().store.subscriberCount(e.type, e.id) > 0 && this.refetch()) : this.#_(e));
3445
3459
  }
3446
- async #g(e) {
3460
+ async #_(e) {
3447
3461
  let { binder: t } = U();
3448
- if (this.#a !== this.mainTemplateId) {
3462
+ if (this.#o !== this.mainTemplateId) {
3449
3463
  if (!await this.render(this.mainTemplateId) && this.metadata?.templateKey) return;
3450
3464
  t.unbind(this);
3451
3465
  }
3452
3466
  if (this.#e?.kind !== "object" || this.#e.ref.id !== e.id || this.#e.ref.type !== e.type) return;
3453
- this.#d("loaded"), this.toggleAttribute("data-updating", e.status === "updating"), e.status !== "stale" && delete this.dataset.stale;
3467
+ this.#f("loaded"), this.toggleAttribute("data-updating", e.status === "updating"), e.status !== "stale" && delete this.dataset.stale;
3454
3468
  let n = this.bindConfig;
3455
3469
  if (n) {
3456
3470
  let r = t.getHandle(this);
3457
- r ? r.update(e.data) : t.bind(this, e.data, this.#_(n, e.type, e.id));
3471
+ r ? r.update(e.data) : t.bind(this, e.data, this.#v(n, e.type, e.id));
3458
3472
  }
3459
3473
  this.onBind(e);
3460
3474
  }
3461
- #_(e, t, n) {
3475
+ #v(e, t, n) {
3462
3476
  return e.onChange ? e : {
3463
3477
  ...e,
3464
3478
  onChange: (e, r) => {
@@ -3478,25 +3492,25 @@ var lt = class extends HTMLElement {
3478
3492
  }
3479
3493
  };
3480
3494
  }
3481
- #v() {
3495
+ #y() {
3482
3496
  let e = this.bindConfig?.itemsSelector ?? "[data-items]";
3483
3497
  return this.querySelector(e) ?? this;
3484
3498
  }
3485
- async #y(e) {
3486
- if (this.#e?.kind !== "list" || this.#e.view.id !== e.id || (await this.ready, this.#a !== this.mainTemplateId && !await this.render(this.mainTemplateId) && this.metadata?.templateKey)) return;
3487
- let t = this.bindConfig ?? { fields: {} }, n = this.#v();
3499
+ async #b(e) {
3500
+ if (this.#e?.kind !== "list" || this.#e.view.id !== e.id || (await this.ready, this.#o !== this.mainTemplateId && !await this.render(this.mainTemplateId) && this.metadata?.templateKey)) return;
3501
+ let t = this.bindConfig ?? { fields: {} }, n = this.#y();
3488
3502
  if (n.setAttribute("aria-busy", String(e.status === "loading" || e.status === "loading-more")), e.ids.length === 0) {
3489
- this.#b(n);
3503
+ this.#x(n);
3490
3504
  let r = e.status === "loading" || e.status === "idle" ? t.loadingTemplate : e.status === "error" ? t.errorTemplate : t.emptyTemplate;
3491
- this.#d(e.status === "error" ? "error" : e.status === "loaded" ? "empty" : "loading"), r && await this.#x(n, r, e.error), this.onListChange(e);
3492
- } else n.querySelector(":scope > [data-placeholder]")?.remove(), this.#d(e.status === "error" ? "error" : "loaded"), await this.#S(n, e, t), t.infiniteScroll && this.#w(n, e, t), this.onListChange(e);
3505
+ this.#f(e.status === "error" ? "error" : e.status === "loaded" ? "empty" : "loading"), r && await this.#S(n, r, e.error), this.onListChange(e);
3506
+ } else n.querySelector(":scope > [data-placeholder]")?.remove(), this.#f(e.status === "error" ? "error" : "loaded"), await this.#C(n, e, t), t.infiniteScroll && this.#T(n, e, t), this.onListChange(e);
3493
3507
  }
3494
- #b(e) {
3508
+ #x(e) {
3495
3509
  let { binder: t } = U();
3496
- for (let e of this.#s.values()) t.unbind(e), e.remove();
3497
- this.#s.clear(), e.querySelector(":scope > [data-placeholder]")?.remove();
3510
+ for (let e of this.#c.values()) t.unbind(e), e.remove();
3511
+ this.#c.clear(), e.querySelector(":scope > [data-placeholder]")?.remove();
3498
3512
  }
3499
- async #x(e, t, n) {
3513
+ async #S(e, t, n) {
3500
3514
  let r = await this.loadTemplate(t);
3501
3515
  if (!r) return;
3502
3516
  let i = document.createElement("div");
@@ -3506,64 +3520,64 @@ var lt = class extends HTMLElement {
3506
3520
  }
3507
3521
  i.querySelector("[data-retry]")?.addEventListener("click", () => void this.retry(), { once: !0 });
3508
3522
  }
3509
- async #S(e, t, n) {
3523
+ async #C(e, t, n) {
3510
3524
  let { store: r, binder: i } = U(), a = n.itemTemplate ?? "item", o = new Set(t.ids);
3511
- for (let [e, t] of this.#s) o.has(e) || (i.unbind(t), t.remove(), this.#s.delete(e));
3525
+ for (let [e, t] of this.#c) o.has(e) || (i.unbind(t), t.remove(), this.#c.delete(e));
3512
3526
  let s = null, c = null;
3513
3527
  for (let o of t.ids) {
3514
3528
  let l = r.get(t.type, o);
3515
3529
  if (!l) continue;
3516
- let u = this.#s.get(o);
3530
+ let u = this.#c.get(o);
3517
3531
  if (!u) {
3518
3532
  if (s ??= await this.loadTemplate(a), !s || this.#e?.kind !== "list" || this.#e.view.id !== t.id) return;
3519
- u = s.cloneNode(!0).firstElementChild ?? document.createElement("div"), u.setAttribute("data-id", o), this.#s.set(o, u), i.bind(u, l.data, this.#_(n, t.type, o)), this.onItemRender(u, l);
3533
+ u = s.cloneNode(!0).firstElementChild ?? document.createElement("div"), u.setAttribute("data-id", o), this.#c.set(o, u), i.bind(u, l.data, this.#v(n, t.type, o)), this.onItemRender(u, l);
3520
3534
  }
3521
3535
  let d = c ? c.nextSibling : e.firstChild;
3522
3536
  u !== d && (c ? c.after(u) : e.prepend(u)), c = u;
3523
3537
  }
3524
- this.#c && this.#c.parentElement === e && e.append(this.#c);
3538
+ this.#l && this.#l.parentElement === e && e.append(this.#l);
3525
3539
  }
3526
- #C(e, t) {
3540
+ #w(e, t) {
3527
3541
  if (!e || t !== "update") return;
3528
- let n = this.#s.get(e.id);
3542
+ let n = this.#c.get(e.id);
3529
3543
  n && (U().binder.update(n, e.data), n.toggleAttribute("data-pending", e.sources.has("optimistic") && [...e.sources].pop() === "optimistic"), this.onItemRender(n, e));
3530
3544
  }
3531
- #w(e, t, n) {
3545
+ #T(e, t, n) {
3532
3546
  let r = typeof n.infiniteScroll == "object" ? n.infiniteScroll : {};
3533
- if (this.#c || (this.#c = document.createElement("div"), this.#c.className = "ar-scroll-sentinel", this.#c.setAttribute("aria-hidden", "true")), this.#c.parentElement !== e && e.append(this.#c), !t.hasMore) {
3534
- this.#l?.disconnect(), this.#l = null;
3547
+ if (this.#l || (this.#l = document.createElement("div"), this.#l.className = "ar-scroll-sentinel", this.#l.setAttribute("aria-hidden", "true")), this.#l.parentElement !== e && e.append(this.#l), !t.hasMore) {
3548
+ this.#u?.disconnect(), this.#u = null;
3535
3549
  return;
3536
3550
  }
3537
3551
  if (typeof IntersectionObserver > "u") return;
3538
- this.#l?.disconnect();
3552
+ this.#u?.disconnect();
3539
3553
  let i = r.root === "self" ? this : null;
3540
- this.#l = new IntersectionObserver((e) => {
3554
+ this.#u = new IntersectionObserver((e) => {
3541
3555
  e.some((e) => e.isIntersecting) && this.#e?.kind === "list" && U().listViews.loadMore(this.#e.view).catch((e) => console.error("loadMore failed", e));
3542
3556
  }, {
3543
3557
  root: i,
3544
3558
  rootMargin: `0px 0px ${r.threshold ?? 300}px 0px`
3545
- }), this.#l.observe(this.#c);
3559
+ }), this.#u.observe(this.#l);
3546
3560
  }
3547
3561
  itemElement(e) {
3548
- return this.#s.get(e);
3562
+ return this.#c.get(e);
3549
3563
  }
3550
3564
  async fetchData(e) {
3551
- this.error = null, this.#d("loading"), await this.#m(this.loadingTemplateId);
3565
+ this.error = null, this.#f("loading"), await this.#h(this.loadingTemplateId);
3552
3566
  try {
3553
3567
  let t = await e();
3554
- return await this.#T(), t;
3568
+ return await this.#E(), t;
3555
3569
  } catch (e) {
3556
3570
  return await this.showError(e), null;
3557
3571
  }
3558
3572
  }
3559
- async #T() {
3560
- if (this.#a !== this.mainTemplateId && (await this.render(this.mainTemplateId), U().binder.unbind(this)), this.#d("loaded"), this.#e?.kind === "object") {
3573
+ async #E() {
3574
+ if (this.#o !== this.mainTemplateId && (await this.render(this.mainTemplateId), U().binder.unbind(this)), this.#f("loaded"), this.#e?.kind === "object") {
3561
3575
  let e = U().store.get(this.#e.ref.type, this.#e.ref.id);
3562
- e && await this.#g(e);
3563
- } else this.#e?.kind === "list" && await this.#y(this.#e.view);
3576
+ e && await this.#_(e);
3577
+ } else this.#e?.kind === "list" && await this.#b(this.#e.view);
3564
3578
  }
3565
3579
  async showError(e) {
3566
- if (this.error = e instanceof Error ? e : Error(String(e)), this.#d("error"), !await this.#m(this.errorTemplateId)) return;
3580
+ if (this.error = e instanceof Error ? e : Error(String(e)), this.#f("error"), !await this.#h(this.errorTemplateId)) return;
3567
3581
  let t = this.querySelector("[data-error-message]");
3568
3582
  t && (t.textContent = this.formatErrorMessage(this.error)), this.querySelector("[data-retry]")?.addEventListener("click", () => void this.retry(), { once: !0 });
3569
3583
  }
@@ -3590,10 +3604,10 @@ var lt = class extends HTMLElement {
3590
3604
  onListChange(e) {}
3591
3605
  onRetry() {}
3592
3606
  }, ut = /* @__PURE__ */ new Map();
3593
- function K(e, t) {
3607
+ function dt(e, t) {
3594
3608
  ut.set(e, t);
3595
3609
  }
3596
- var dt = class {
3610
+ var ft = class {
3597
3611
  app;
3598
3612
  plugins = /* @__PURE__ */ new Map();
3599
3613
  pending = [];
@@ -3659,17 +3673,17 @@ var dt = class {
3659
3673
  }
3660
3674
  };
3661
3675
  // src/mixins/utils.ts
3662
- function q(e, t, n) {
3676
+ function K(e, t, n) {
3663
3677
  return e.dispatchEvent(new CustomEvent(t, {
3664
3678
  detail: n,
3665
3679
  bubbles: !0,
3666
3680
  cancelable: !0
3667
3681
  }));
3668
3682
  }
3669
- var J = null;
3670
- function Y(e) {
3683
+ var q = null;
3684
+ function J(e) {
3671
3685
  if (typeof document > "u") return;
3672
- J && J.isConnected || (J = document.createElement("div"), J.setAttribute("aria-live", "assertive"), J.setAttribute("role", "status"), J.className = "ar-visually-hidden", Object.assign(J.style, {
3686
+ q && q.isConnected || (q = document.createElement("div"), q.setAttribute("aria-live", "assertive"), q.setAttribute("role", "status"), q.className = "ar-visually-hidden", Object.assign(q.style, {
3673
3687
  position: "absolute",
3674
3688
  width: "1px",
3675
3689
  height: "1px",
@@ -3679,13 +3693,13 @@ function Y(e) {
3679
3693
  margin: "-1px",
3680
3694
  padding: "0",
3681
3695
  border: "0"
3682
- }), document.body.appendChild(J)), J.textContent = "";
3683
- let t = J;
3696
+ }), document.body.appendChild(q)), q.textContent = "";
3697
+ let t = q;
3684
3698
  setTimeout(() => {
3685
3699
  t.textContent = e;
3686
3700
  }, 30);
3687
3701
  }
3688
- function ft(e, t, n, r = 8) {
3702
+ function pt(e, t, n, r = 8) {
3689
3703
  e.style.position = "fixed", e.style.left = "0px", e.style.top = "0px";
3690
3704
  let i = e.getBoundingClientRect(), a = window.innerWidth, o = window.innerHeight, s = {
3691
3705
  top: t.top - i.height - r >= 0,
@@ -3712,7 +3726,7 @@ function ft(e, t, n, r = 8) {
3712
3726
  }
3713
3727
  return e.style.left = `${Math.max(4, Math.min(u, a - i.width - 4))}px`, e.style.top = `${Math.max(4, Math.min(d, o - i.height - 4))}px`, e.dataset.placement = l, l;
3714
3728
  }
3715
- function pt(e) {
3729
+ function mt(e) {
3716
3730
  let t = /translate\(\s*(-?[\d.]+)px\s*,\s*(-?[\d.]+)px\s*\)/.exec(e.style.transform);
3717
3731
  return t ? {
3718
3732
  x: Number(t[1]),
@@ -3723,8 +3737,8 @@ function pt(e) {
3723
3737
  };
3724
3738
  }
3725
3739
  // src/mixins/draggable.ts
3726
- function mt(e, t = {}) {
3727
- let { axis: n = "both", grid: r, keyboardStep: i = 10 } = t, a = new AbortController(), { signal: o } = a, s = t.handle && e.querySelector(t.handle) || e, c = pt(e), l = null, u = s.style.touchAction;
3740
+ function ht(e, t = {}) {
3741
+ let { axis: n = "both", grid: r, keyboardStep: i = 10 } = t, a = new AbortController(), { signal: o } = a, s = t.handle && e.querySelector(t.handle) || e, c = mt(e), l = null, u = s.style.touchAction;
3728
3742
  s.style.touchAction = "none", s.style.cursor = "grab", e.hasAttribute("tabindex") || (e.tabIndex = 0), e.classList.add("is-draggable"), e.getAttribute("aria-roledescription") || e.setAttribute("aria-roledescription", "draggable");
3729
3743
  function d() {
3730
3744
  let n = t.containment;
@@ -3770,19 +3784,19 @@ function mt(e, t = {}) {
3770
3784
  bounds: f()
3771
3785
  }, s.setPointerCapture?.(n.pointerId), s.style.cursor = "grabbing", e.classList.add("is-dragging");
3772
3786
  let i = h(l.base);
3773
- t.onStart?.(i), q(e, "draggable:start", i), n.preventDefault();
3787
+ t.onStart?.(i), K(e, "draggable:start", i), n.preventDefault();
3774
3788
  }, { signal: o }), s.addEventListener("pointermove", (n) => {
3775
3789
  if (!l || n.pointerId !== l.pointerId) return;
3776
3790
  m(p(l.base.x + n.clientX - l.startX, l.base.y + n.clientY - l.startY, l.bounds));
3777
3791
  let r = h(l.base);
3778
- t.onDrag?.(r), q(e, "draggable:move", r);
3792
+ t.onDrag?.(r), K(e, "draggable:move", r);
3779
3793
  }, { signal: o });
3780
3794
  let g = (n) => {
3781
3795
  if (!l || n.pointerId !== l.pointerId) return;
3782
3796
  let r = l.base;
3783
3797
  l = null, s.releasePointerCapture?.(n.pointerId), s.style.cursor = "grab", e.classList.remove("is-dragging");
3784
3798
  let i = h(r);
3785
- t.onEnd?.(i), q(e, "draggable:end", i);
3799
+ t.onEnd?.(i), K(e, "draggable:end", i);
3786
3800
  };
3787
3801
  return s.addEventListener("pointerup", g, { signal: o }), s.addEventListener("pointercancel", g, { signal: o }), e.addEventListener("keydown", (n) => {
3788
3802
  if (n.target !== e) return;
@@ -3797,7 +3811,7 @@ function mt(e, t = {}) {
3797
3811
  let o = { ...c };
3798
3812
  m(p(c.x + a[0], c.y + a[1], f()));
3799
3813
  let s = h(o);
3800
- t.onEnd?.(s), q(e, "draggable:end", s);
3814
+ t.onEnd?.(s), K(e, "draggable:end", s);
3801
3815
  }, { signal: o }), {
3802
3816
  name: "draggable",
3803
3817
  element: e,
@@ -3812,9 +3826,9 @@ function mt(e, t = {}) {
3812
3826
  }
3813
3827
  };
3814
3828
  }
3815
- G.register("draggable", mt);
3829
+ G.register("draggable", ht);
3816
3830
  // src/mixins/editable.ts
3817
- function ht(e, t = {}) {
3831
+ function gt(e, t = {}) {
3818
3832
  let { type: n = "text", placeholder: r = "", saveOnBlur: i = !0 } = t, a = new AbortController(), o = null;
3819
3833
  e.hasAttribute("tabindex") || (e.tabIndex = 0), e.classList.add("is-editable"), e.setAttribute("aria-roledescription", "editable");
3820
3834
  function s(i) {
@@ -3840,7 +3854,7 @@ function ht(e, t = {}) {
3840
3854
  }, e.classList.add("is-editing"), e.replaceChildren(r), r.focus(), "select" in r && typeof r.select == "function" && r.select(), r.addEventListener("keydown", (e) => {
3841
3855
  let t = e;
3842
3856
  t.stopPropagation(), t.key === "Escape" ? (t.preventDefault(), f()) : t.key === "Enter" && (n !== "textarea" || t.ctrlKey || t.metaKey) && (t.preventDefault(), d());
3843
- }, { signal: a.signal }), i && r.addEventListener("blur", () => void d(), { signal: a.signal }), n === "select" && r.addEventListener("change", () => void d(), { signal: a.signal }), q(e, "editable:start", { value: t });
3857
+ }, { signal: a.signal }), i && r.addEventListener("blur", () => void d(), { signal: a.signal }), n === "select" && r.addEventListener("change", () => void d(), { signal: a.signal }), K(e, "editable:start", { value: t });
3844
3858
  }
3845
3859
  function l(t, n) {
3846
3860
  o && (o.controller.abort(), o = null, e.classList.remove("is-editing", "is-invalid"), e.removeAttribute("aria-invalid"), e.textContent = t, n && e.focus());
@@ -3848,7 +3862,7 @@ function ht(e, t = {}) {
3848
3862
  function u(t) {
3849
3863
  if (!o) return;
3850
3864
  let n = o.input, r = e.querySelector(".editable-error");
3851
- r || (r = document.createElement("div"), r.className = "editable-error", r.id = L("editable-error"), r.setAttribute("role", "alert"), e.appendChild(r)), r.textContent = t, n.setAttribute("aria-invalid", "true"), n.setAttribute("aria-describedby", r.id), e.classList.add("is-invalid"), n.focus();
3865
+ r || (r = document.createElement("div"), r.className = "editable-error", r.id = B("editable-error"), r.setAttribute("role", "alert"), e.appendChild(r)), r.textContent = t, n.setAttribute("aria-invalid", "true"), n.setAttribute("aria-describedby", r.id), e.classList.add("is-invalid"), n.focus();
3852
3866
  }
3853
3867
  async function d() {
3854
3868
  if (!o || o.saving) return;
@@ -3864,7 +3878,7 @@ function ht(e, t = {}) {
3864
3878
  return;
3865
3879
  }
3866
3880
  }
3867
- if (!q(e, "editable:save", {
3881
+ if (!K(e, "editable:save", {
3868
3882
  value: r,
3869
3883
  previous: n.previous
3870
3884
  })) l(n.previous, !0);
@@ -3873,7 +3887,7 @@ function ht(e, t = {}) {
3873
3887
  try {
3874
3888
  await t.onSave(r, e);
3875
3889
  } catch (t) {
3876
- e.textContent = n.previous, q(e, "editable:error", {
3890
+ e.textContent = n.previous, K(e, "editable:error", {
3877
3891
  error: t,
3878
3892
  value: r
3879
3893
  });
@@ -3884,7 +3898,7 @@ function ht(e, t = {}) {
3884
3898
  }
3885
3899
  }
3886
3900
  function f() {
3887
- o && (l(o.previous, !0), t.onCancel?.(e), q(e, "editable:cancel", {}));
3901
+ o && (l(o.previous, !0), t.onCancel?.(e), K(e, "editable:cancel", {}));
3888
3902
  }
3889
3903
  return e.addEventListener("dblclick", c, { signal: a.signal }), e.addEventListener("keydown", (t) => {
3890
3904
  o || t.target !== e || t.key !== "Enter" && t.key !== "F2" || (t.preventDefault(), c());
@@ -3901,9 +3915,9 @@ function ht(e, t = {}) {
3901
3915
  }
3902
3916
  };
3903
3917
  }
3904
- G.register("editable", ht);
3918
+ G.register("editable", gt);
3905
3919
  // src/mixins/grid-navigation.ts
3906
- function gt(e, t = {}) {
3920
+ function _t(e, t = {}) {
3907
3921
  let { cellSelector: n = "[data-cell], td, th[scope=\"col\"], [role=\"gridcell\"]", rowSelector: r = "[data-row], tr, [role=\"row\"]", wrap: i = !1, tabBehavior: a = "exit", pageSize: o = 10 } = t, s = new AbortController(), { signal: c } = s, l = null, u = !e.hasAttribute("role") && !(e instanceof HTMLTableElement);
3908
3922
  u && e.setAttribute("role", "grid");
3909
3923
  let d = () => Array.from(e.querySelectorAll(r)).filter((e) => e.querySelector(n)), f = (e) => Array.from(e.querySelectorAll(n)).filter((t) => t.closest(r) === e);
@@ -3931,7 +3945,7 @@ function gt(e, t = {}) {
3931
3945
  inline: "nearest"
3932
3946
  });
3933
3947
  let i = p(n);
3934
- t.onNavigate?.(n, r), q(e, "grid:navigate", {
3948
+ t.onNavigate?.(n, r), K(e, "grid:navigate", {
3935
3949
  cell: n,
3936
3950
  row: i?.row ?? -1,
3937
3951
  col: i?.col ?? -1,
@@ -3955,7 +3969,7 @@ function gt(e, t = {}) {
3955
3969
  return !u || u === l ? !1 : (h(u, n), !0);
3956
3970
  }
3957
3971
  function _(n) {
3958
- l && (t.onEdit?.(l, n), q(e, "grid:edit", {
3972
+ l && (t.onEdit?.(l, n), K(e, "grid:edit", {
3959
3973
  cell: l,
3960
3974
  key: n
3961
3975
  }));
@@ -4036,9 +4050,9 @@ function gt(e, t = {}) {
4036
4050
  }
4037
4051
  };
4038
4052
  }
4039
- G.register("grid-navigation", gt);
4053
+ G.register("grid-navigation", _t);
4040
4054
  // src/mixins/infinite-scroll.ts
4041
- function _t(e, t = {}) {
4055
+ function vt(e, t = {}) {
4042
4056
  let n = t.threshold ?? 300, r = !1, i = !1, a = () => t.view && Ye() ? U().listViews.get(t.view) : void 0, o = () => {
4043
4057
  if (t.hasMore) return t.hasMore();
4044
4058
  let e = a();
@@ -4062,12 +4076,12 @@ function _t(e, t = {}) {
4062
4076
  }), f.observe(u));
4063
4077
  };
4064
4078
  async function m() {
4065
- if (!(r || i || !o()) && q(e, "infinite-scroll:load", {})) {
4079
+ if (!(r || i || !o()) && K(e, "infinite-scroll:load", {})) {
4066
4080
  r = !0, e.classList.add("is-loading-more"), e.setAttribute("aria-busy", "true");
4067
4081
  try {
4068
- await s(), q(e, "infinite-scroll:loaded", {});
4082
+ await s(), K(e, "infinite-scroll:loaded", {});
4069
4083
  } catch (t) {
4070
- q(e, "infinite-scroll:error", { error: t });
4084
+ K(e, "infinite-scroll:error", { error: t });
4071
4085
  } finally {
4072
4086
  r = !1, e.classList.remove("is-loading-more"), e.removeAttribute("aria-busy"), u.parentElement === e && e.lastElementChild !== u && e.appendChild(u), !i && o() ? p() : f?.disconnect();
4073
4087
  }
@@ -4083,178 +4097,330 @@ function _t(e, t = {}) {
4083
4097
  }
4084
4098
  };
4085
4099
  }
4086
- G.register("infinite-scroll", _t);
4100
+ G.register("infinite-scroll", vt);
4087
4101
  // src/mixins/sortable.ts
4088
- var X = /* @__PURE__ */ new Map(), vt = !1;
4089
- function yt(e, t = {}) {
4090
- let n = new AbortController(), { signal: r } = n, i = t.draggingClass ?? "is-sorting", a = t.placeholderClass ?? "sortable-placeholder", o = t.group, s = null;
4091
- o && (X.has(o) || X.set(o, /* @__PURE__ */ new Set()), X.get(o).add(e)), e.classList.add("is-sortable"), e.hasAttribute("role") || e.setAttribute("role", "list");
4092
- let c = (e, n) => e.parentElement === n && !e.classList.contains(a) && (!t.items || e.matches(t.items)), l = (e) => Array.from(e.children).filter((t) => t instanceof HTMLElement && c(t, e)), u = () => (o ? Array.from(X.get(o) ?? []) : [e]).filter((e) => e.isConnected);
4093
- function d() {
4094
- for (let t of l(e)) t.hasAttribute("tabindex") || (t.tabIndex = 0), t.hasAttribute("role") || t.setAttribute("role", "listitem"), t.setAttribute("aria-roledescription", "sortable item");
4102
+ var Y = /* @__PURE__ */ new Map(), yt = !1, X = 48, bt = 18, xt = 6, St = 64, Ct = () => typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
4103
+ function wt(e, t, n) {
4104
+ if (n <= 0 || Ct() || typeof Element.prototype.animate != "function") {
4105
+ t();
4106
+ return;
4107
+ }
4108
+ let r = new Map(e.map((e) => [e, e.getBoundingClientRect()]));
4109
+ t();
4110
+ for (let [e, t] of r) {
4111
+ if (!e.isConnected) continue;
4112
+ let r = e.getBoundingClientRect(), i = t.left - r.left, a = t.top - r.top;
4113
+ Math.abs(i) < .5 && Math.abs(a) < .5 || (e.getAnimations?.().forEach((e) => e.cancel()), e.animate([{ transform: `translate(${i}px, ${a}px)` }, { transform: "translate(0, 0)" }], {
4114
+ duration: n,
4115
+ easing: "cubic-bezier(0.2, 0, 0, 1)"
4116
+ }));
4095
4117
  }
4096
- d();
4097
- let f = typeof MutationObserver < "u" ? new MutationObserver(d) : null;
4098
- f?.observe(e, { childList: !0 });
4099
- function p(e) {
4118
+ }
4119
+ function Tt(e) {
4120
+ let t = [];
4121
+ for (let n = e; n && n !== document.body; n = n.parentElement) {
4122
+ let e = getComputedStyle(n), r = /(auto|scroll)/.test(e.overflowY) && n.scrollHeight > n.clientHeight;
4123
+ (/(auto|scroll)/.test(e.overflowX) && n.scrollWidth > n.clientWidth || r) && t.push(n);
4124
+ }
4125
+ let n = document.scrollingElement;
4126
+ return n && t.push(n), t;
4127
+ }
4128
+ function Et(e) {
4129
+ let t = e.getBoundingClientRect(), n = getComputedStyle(e).transform;
4130
+ if (!n || n === "none" || typeof DOMMatrixReadOnly > "u") return t;
4131
+ let r = new DOMMatrixReadOnly(n);
4132
+ return new DOMRect(t.left - r.e, t.top - r.f, t.width, t.height);
4133
+ }
4134
+ function Dt(e, t, n) {
4135
+ let r = Math.max(e.left - t, 0, t - e.right), i = Math.max(e.top - n, 0, n - e.bottom);
4136
+ return Math.hypot(r, i);
4137
+ }
4138
+ function Ot(e, t = {}) {
4139
+ let n = new AbortController(), { signal: r } = n, i = t.draggingClass ?? "is-sorting", a = t.placeholderClass ?? "sortable-placeholder", o = t.animation ?? 180, s = t.activationDistance ?? 5, c = t.touchDelay ?? 200, l = t.group, u = null, d = null;
4140
+ l && (Y.has(l) || Y.set(l, /* @__PURE__ */ new Set()), Y.get(l).add(e)), e.classList.add("is-sortable"), e.hasAttribute("role") || e.setAttribute("role", "list");
4141
+ let f = (e, n) => e.parentElement === n && !e.classList.contains(a) && (!t.items || e.matches(t.items)), p = (e) => Array.from(e.children).filter((t) => t instanceof HTMLElement && f(t, e)), m = () => (l ? Array.from(Y.get(l) ?? []) : [e]).filter((e) => e.isConnected);
4142
+ function h() {
4143
+ for (let t of p(e)) t.hasAttribute("tabindex") || (t.tabIndex = 0), t.hasAttribute("role") || t.setAttribute("role", "listitem"), t.setAttribute("aria-roledescription", "sortable item");
4144
+ }
4145
+ h();
4146
+ let g = typeof MutationObserver < "u" ? new MutationObserver(h) : null;
4147
+ g?.observe(e, { childList: !0 });
4148
+ function _(e) {
4100
4149
  if (t.direction) return t.direction;
4101
4150
  let n = getComputedStyle(e);
4102
4151
  return n.display.includes("flex") && !n.flexDirection.startsWith("column") ? "horizontal" : "vertical";
4103
4152
  }
4104
- function m(e) {
4153
+ function v(e) {
4105
4154
  return e.getAttribute("aria-label") ?? e.textContent?.trim().slice(0, 60) ?? "item";
4106
4155
  }
4107
- function h(e) {
4108
- let t = document.createElement(e.tagName === "LI" ? "li" : "div");
4109
- t.className = a, t.setAttribute("aria-hidden", "true");
4110
- let n = e.getBoundingClientRect();
4111
- return t.style.height = `${n.height}px`, p(e.parentElement) === "horizontal" && (t.style.width = `${n.width}px`), t;
4112
- }
4113
- function g(t, n, a) {
4114
- let o = t.getBoundingClientRect();
4115
- s = {
4116
- item: t,
4117
- from: t.parentElement,
4118
- oldIndex: l(t.parentElement).indexOf(t),
4119
- placeholder: h(t),
4120
- pointerId: a?.pointerId,
4121
- offsetX: a ? a.clientX - o.left : 0,
4122
- offsetY: a ? a.clientY - o.top : 0,
4123
- startX: a?.clientX ?? 0,
4124
- startY: a?.clientY ?? 0,
4125
- started: n,
4126
- keyboard: n,
4127
- nextSibling: t.nextSibling
4128
- }, n && (vt = !0, t.addEventListener("keydown", C, { signal: r }), t.classList.add(i), t.setAttribute("aria-grabbed", "true"), q(e, "sortable:start", {
4129
- item: t,
4130
- from: s.from,
4131
- oldIndex: s.oldIndex
4132
- }), Y(`Picked up ${m(t)}. Position ${s.oldIndex + 1} of ${l(s.from).length}. Use arrow keys to move, Space to drop, Escape to cancel.`));
4133
- }
4134
- function _() {
4135
- if (!s) return;
4136
- let { item: t } = s, n = t.getBoundingClientRect();
4137
- t.parentElement.insertBefore(s.placeholder, t), t.classList.add(i), Object.assign(t.style, {
4156
+ function y() {
4157
+ return m().flatMap((e) => [...p(e), ...Array.from(e.querySelectorAll(`:scope > .${CSS.escape(a)}`))]).filter((e) => e !== d?.item);
4158
+ }
4159
+ function b(e, t) {
4160
+ let n = e.parentElement, r = p(n).indexOf(e);
4161
+ return d = {
4162
+ item: e,
4163
+ from: n,
4164
+ oldIndex: r,
4165
+ keyboard: t,
4166
+ nextSibling: e.nextSibling,
4167
+ offsetX: 0,
4168
+ offsetY: 0,
4169
+ fixX: 0,
4170
+ fixY: 0,
4171
+ x: 0,
4172
+ y: 0,
4173
+ lastX: 0,
4174
+ lastY: 0,
4175
+ style: e.getAttribute("style") ?? "",
4176
+ container: n,
4177
+ index: r
4178
+ }, d;
4179
+ }
4180
+ function x(t, n, r) {
4181
+ let o = b(t.item, !1), { item: s } = o, c = s.getBoundingClientRect();
4182
+ o.pointerId = t.pointerId, o.offsetX = t.startX - c.left, o.offsetY = t.startY - c.top;
4183
+ let l = document.createElement(s.tagName === "LI" ? "li" : "div");
4184
+ l.className = a, l.setAttribute("aria-hidden", "true");
4185
+ let u = getComputedStyle(s);
4186
+ Object.assign(l.style, {
4187
+ height: `${c.height}px`,
4188
+ width: _(o.from) === "horizontal" ? `${c.width}px` : "",
4189
+ flex: u.flex,
4190
+ minWidth: u.minWidth,
4191
+ maxWidth: u.maxWidth,
4192
+ margin: u.margin
4193
+ }), s.before(l), o.placeholder = l, s.classList.add(i), Object.assign(s.style, {
4138
4194
  position: "fixed",
4139
- left: `${n.left}px`,
4140
- top: `${n.top}px`,
4141
- width: `${n.width}px`,
4142
- height: `${n.height}px`,
4195
+ left: `${c.left}px`,
4196
+ top: `${c.top}px`,
4197
+ width: `${c.width}px`,
4198
+ height: `${c.height}px`,
4199
+ margin: "0",
4143
4200
  zIndex: "9999",
4144
4201
  pointerEvents: "none",
4145
- margin: "0"
4146
- }), document.body.appendChild(t), s.started = !0, q(e, "sortable:start", {
4147
- item: t,
4148
- from: s.from,
4149
- oldIndex: s.oldIndex
4202
+ boxSizing: "border-box"
4150
4203
  });
4204
+ let d = s.getBoundingClientRect();
4205
+ o.fixX = c.left - d.left, o.fixY = c.top - d.top, document.documentElement.classList.add("is-sorting-active"), K(e, "sortable:start", {
4206
+ item: s,
4207
+ from: o.from,
4208
+ oldIndex: o.oldIndex
4209
+ }), S(n, r);
4210
+ }
4211
+ function S(e, t) {
4212
+ d && !d.keyboard && (d.x = e, d.y = t, d.item.style.left = `${e - d.offsetX + d.fixX}px`, d.item.style.top = `${t - d.offsetY + d.fixY}px`, d.frame === void 0 && (d.frame = requestAnimationFrame(ee)));
4213
+ }
4214
+ function ee() {
4215
+ if (!d || d.keyboard) return;
4216
+ d.frame = void 0;
4217
+ let e = t.autoScroll !== !1 && te(d.x, d.y);
4218
+ ie(d.x, d.y), e && (d.frame = requestAnimationFrame(ee));
4219
+ }
4220
+ function te(e, t) {
4221
+ if (!d) return !1;
4222
+ let n = !1;
4223
+ for (let r of Tt(d.container)) {
4224
+ let i = r === document.scrollingElement, a = i ? new DOMRect(0, 0, innerWidth, innerHeight) : r.getBoundingClientRect();
4225
+ if (!i && Dt(a, e, t) > 0) continue;
4226
+ let o = (e) => Math.ceil(bt * Math.min(1, (X - e) / X)), s = t - a.top < X ? -o(t - a.top) : a.bottom - t < X ? o(a.bottom - t) : 0, c = e - a.left < X ? -o(e - a.left) : a.right - e < X ? o(a.right - e) : 0;
4227
+ if (!c && !s) continue;
4228
+ let l = r.scrollTop, u = r.scrollLeft;
4229
+ r.scrollBy?.(c, s), (r.scrollTop !== l || r.scrollLeft !== u) && (n = !0);
4230
+ }
4231
+ return n;
4151
4232
  }
4152
- function v(e, t) {
4153
- let n = document.elementFromPoint?.(e, t);
4154
- for (let e of u()) if (n && (e === n || e.contains(n))) return e;
4155
- return null;
4233
+ function ne(e, t) {
4234
+ let n = null, r = St;
4235
+ for (let i of m()) {
4236
+ let a = Dt(i.getBoundingClientRect(), e, t);
4237
+ (a < r || a === 0 && r === 0) && (n = i, r = a);
4238
+ }
4239
+ return n;
4156
4240
  }
4157
- function y(e, t, n) {
4158
- if (!s) return;
4159
- let r = p(e) === "horizontal", i = l(e).filter((e) => e !== s.item), a = null;
4160
- for (let e of i) {
4161
- let i = e.getBoundingClientRect(), o = r ? i.left + i.width / 2 : i.top + i.height / 2;
4162
- if ((r ? t : n) < o) {
4163
- a = e;
4164
- break;
4241
+ function re(e, t, n) {
4242
+ let r = p(e).filter((e) => e !== d?.item);
4243
+ if (!r.length) return 0;
4244
+ let i = _(e) === "horizontal", a = 0, o = Infinity, s = Infinity, c = r.map(Et);
4245
+ c.forEach((e, r) => {
4246
+ let i = Dt(e, t, n), c = Math.hypot(t - (e.left + e.width / 2), n - (e.top + e.height / 2));
4247
+ (i < o || i === o && c < s) && (a = r, o = i, s = c);
4248
+ });
4249
+ let l = c[a], u;
4250
+ return u = i ? n >= l.top && n <= l.bottom ? t > l.left + l.width / 2 : n > l.bottom : n > l.top + l.height / 2, a + +!!u;
4251
+ }
4252
+ function ie(t, n) {
4253
+ if (!d?.placeholder || Math.hypot(t - d.lastX, n - d.lastY) < xt || d.placeholder.isConnected && Dt(Et(d.placeholder), t, n) === 0) return;
4254
+ let r = ne(t, n);
4255
+ if (!r) return;
4256
+ let i = re(r, t, n);
4257
+ if (r === d.container && i === d.index) return;
4258
+ let a = d, s = p(r).filter((e) => e !== a.item);
4259
+ wt(y(), () => r.insertBefore(a.placeholder, s[i] ?? null), o), a.container = r, a.index = i, a.lastX = t, a.lastY = n, K(e, "sortable:move", {
4260
+ item: a.item,
4261
+ to: r,
4262
+ index: i
4263
+ });
4264
+ }
4265
+ function ae(e) {
4266
+ e.frame !== void 0 && cancelAnimationFrame(e.frame), e.item.classList.remove(i), e.item.removeAttribute("aria-grabbed"), e.style ? e.item.setAttribute("style", e.style) : e.item.removeAttribute("style"), document.documentElement.classList.remove("is-sorting-active");
4267
+ }
4268
+ function C(e) {
4269
+ if (!d) return;
4270
+ let t = d;
4271
+ d = null, t.keyboard && (yt = !1, t.item.removeEventListener("keydown", E));
4272
+ let { item: n, placeholder: r } = t, i = () => {
4273
+ ae(t), r && (e && r.parentElement && r.replaceWith(n), r.remove()), oe(t, e);
4274
+ };
4275
+ if (!r || !e || o <= 0 || Ct() || typeof n.animate != "function") {
4276
+ if (r && !e) {
4277
+ ae(t), wt(y(), () => r.remove(), o), oe(t, !1);
4278
+ return;
4165
4279
  }
4280
+ i();
4281
+ return;
4166
4282
  }
4167
- a ? s.placeholder.nextSibling !== a && e.insertBefore(s.placeholder, a) : e.lastElementChild !== s.placeholder && e.appendChild(s.placeholder);
4168
- }
4169
- function b(n) {
4170
- if (!s) return;
4171
- let r = s;
4172
- s = null;
4173
- let { item: a, placeholder: o } = r;
4174
- r.keyboard && (vt = !1, a.removeEventListener("keydown", C)), a.classList.remove(i), a.removeAttribute("aria-grabbed"), a.style.cssText = a.style.cssText.replace(/(position|left|top|width|height|z-index|pointer-events|margin):[^;]+;?/g, ""), r.keyboard || (o.parentElement ? o.replaceWith(a) : r.from.insertBefore(a, r.nextSibling)), o.remove();
4175
- let c = a.parentElement, u = l(c).indexOf(a), d = {
4176
- item: a,
4177
- id: a.getAttribute("data-id"),
4178
- from: r.from,
4179
- to: c,
4180
- oldIndex: r.oldIndex,
4181
- newIndex: u
4182
- }, f = c !== r.from || u !== r.oldIndex;
4183
- if (!n || f && !q(e, "sortable:end", d)) {
4184
- let e = l(r.from).filter((e) => e !== a);
4185
- r.from.insertBefore(a, e[r.oldIndex] ?? null), r.keyboard && Y(`${m(a)} returned to position ${r.oldIndex + 1}.`);
4186
- } else f ? (t.onEnd?.(d), r.keyboard && Y(`${m(a)} dropped at position ${u + 1} of ${l(c).length}.`)) : r.keyboard && Y(`${m(a)} dropped.`);
4187
- r.keyboard && a.focus();
4283
+ let a = n.getBoundingClientRect(), s = r.getBoundingClientRect();
4284
+ n.style.transition = "none";
4285
+ let c = n.animate([{ transform: "translate(0, 0)" }, { transform: `translate(${s.left - a.left}px, ${s.top - a.top}px)` }], {
4286
+ duration: o,
4287
+ easing: "cubic-bezier(0.2, 0, 0, 1)",
4288
+ fill: "forwards"
4289
+ }), l = () => {
4290
+ c.cancel(), i();
4291
+ };
4292
+ c.finished.then(l, l);
4293
+ }
4294
+ function oe(n, r) {
4295
+ let { item: i } = n, a = i.parentElement, s = p(a).indexOf(i), c = {
4296
+ item: i,
4297
+ id: i.getAttribute("data-id"),
4298
+ from: n.from,
4299
+ to: a,
4300
+ oldIndex: n.oldIndex,
4301
+ newIndex: s
4302
+ }, l = a !== n.from || s !== n.oldIndex;
4303
+ if (!r || l && !K(e, "sortable:end", c)) {
4304
+ if (l) {
4305
+ let e = p(n.from).filter((e) => e !== i);
4306
+ wt(y(), () => n.from.insertBefore(i, e[n.oldIndex] ?? null), o);
4307
+ }
4308
+ n.keyboard && J(`${v(i)} returned to position ${n.oldIndex + 1}.`);
4309
+ } else l ? (t.onEnd?.(c), n.keyboard && J(`${v(i)} dropped at position ${s + 1} of ${p(a).length}.`)) : n.keyboard && J(`${v(i)} dropped.`);
4310
+ n.keyboard && i.focus();
4311
+ }
4312
+ function w() {
4313
+ u?.timer && clearTimeout(u.timer), u = null;
4188
4314
  }
4189
4315
  e.addEventListener("pointerdown", (n) => {
4190
- if (n.button !== 0 || s) return;
4191
- let r = n.target, i = Array.from(e.children).find((t) => t instanceof HTMLElement && t.contains(r) && c(t, e));
4192
- !i || t.handle && !r.closest(t.handle) || r.closest("input, textarea, select, button, a, [contenteditable=\"true\"]") || g(i, !1, n);
4316
+ if (n.button !== 0 || d || u) return;
4317
+ let r = n.target, i = Array.from(e.children).find((t) => t instanceof HTMLElement && t.contains(r) && f(t, e));
4318
+ if (!i || t.handle && !r.closest(t.handle) || r.closest("input, textarea, select, button, a, [contenteditable=\"true\"]")) return;
4319
+ let a = n.pointerType === "touch";
4320
+ if (u = {
4321
+ item: i,
4322
+ pointerId: n.pointerId,
4323
+ startX: n.clientX,
4324
+ startY: n.clientY,
4325
+ touch: a,
4326
+ ready: !a || c <= 0
4327
+ }, !u.ready) {
4328
+ let e = u;
4329
+ e.timer = setTimeout(() => {
4330
+ u === e && (u = null, x(e, e.startX, e.startY));
4331
+ }, c);
4332
+ }
4193
4333
  }, { signal: r });
4194
- let x = (e) => {
4195
- if (!s || s.keyboard || e.pointerId !== s.pointerId) return;
4196
- if (!s.started) {
4197
- if (Math.hypot(e.clientX - s.startX, e.clientY - s.startY) < 4) return;
4198
- _();
4199
- }
4200
- e.preventDefault(), s.item.style.left = `${e.clientX - s.offsetX}px`, s.item.style.top = `${e.clientY - s.offsetY}px`;
4201
- let t = v(e.clientX, e.clientY);
4202
- t && y(t, e.clientX, e.clientY);
4203
- }, S = (e) => {
4204
- s && !s.keyboard && e.pointerId === s.pointerId && (s.started ? b(e.type === "pointerup") : s = null);
4334
+ let se = (e) => {
4335
+ if (u && e.pointerId === u.pointerId) {
4336
+ let t = Math.hypot(e.clientX - u.startX, e.clientY - u.startY);
4337
+ if (!u.ready) {
4338
+ t > 8 && w();
4339
+ return;
4340
+ }
4341
+ if (t < s) return;
4342
+ let n = u;
4343
+ u = null, x(n, e.clientX, e.clientY), e.preventDefault();
4344
+ } else d && !d.keyboard && e.pointerId === d.pointerId && (e.preventDefault(), S(e.clientX, e.clientY));
4345
+ }, T = (e) => {
4346
+ u && e.pointerId === u.pointerId ? w() : d && !d.keyboard && e.pointerId === d.pointerId && (e.type === "pointerup" && ie(e.clientX, e.clientY), C(e.type === "pointerup"));
4205
4347
  };
4206
- document.addEventListener("pointermove", x, {
4348
+ document.addEventListener("pointermove", se, {
4207
4349
  signal: r,
4208
4350
  passive: !1
4209
- }), document.addEventListener("pointerup", S, { signal: r }), document.addEventListener("pointercancel", S, { signal: r }), e.addEventListener("keydown", (t) => {
4351
+ }), document.addEventListener("pointerup", T, { signal: r }), document.addEventListener("pointercancel", T, { signal: r }), document.addEventListener("touchmove", (e) => {
4352
+ d && !d.keyboard && e.cancelable && e.preventDefault();
4353
+ }, {
4354
+ signal: r,
4355
+ passive: !1
4356
+ }), e.addEventListener("dragstart", (e) => {
4357
+ (d || u) && e.preventDefault();
4358
+ }, { signal: r }), e.addEventListener("keydown", (t) => {
4210
4359
  let n = t.target;
4211
- vt || s || c(n, n.parentElement) && n.parentElement === e && (t.key === " " || t.key === "Enter") && (t.preventDefault(), g(n, !0));
4360
+ if (!(yt || d) && f(n, n.parentElement) && n.parentElement === e && (t.key === " " || t.key === "Enter")) {
4361
+ t.preventDefault();
4362
+ let a = b(n, !0);
4363
+ yt = !0, n.addEventListener("keydown", E, { signal: r }), n.classList.add(i), n.setAttribute("aria-grabbed", "true"), K(e, "sortable:start", {
4364
+ item: n,
4365
+ from: a.from,
4366
+ oldIndex: a.oldIndex
4367
+ }), J(`Picked up ${v(n)}. Position ${a.oldIndex + 1} of ${p(a.from).length}. Use arrow keys to move, Space to drop, Escape to cancel.`);
4368
+ }
4212
4369
  }, { signal: r });
4213
- function C(e) {
4214
- if (!s || !s.keyboard || e.target !== s.item) return;
4215
- e.stopPropagation();
4216
- let t = s.item, n = t.parentElement, r = l(n), i = r.indexOf(t), a = p(n) === "horizontal", o = a ? "ArrowLeft" : "ArrowUp", c = a ? "ArrowRight" : "ArrowDown", d = u(), f = d.indexOf(n);
4217
- switch (e.key) {
4218
- case o:
4219
- i > 0 && n.insertBefore(t, r[i - 1]);
4220
- break;
4370
+ function E(t) {
4371
+ if (!d || !d.keyboard || t.target !== d.item) return;
4372
+ t.stopPropagation();
4373
+ let n = d.item, r = n.parentElement, i = p(r), a = i.indexOf(n), s = _(r) === "horizontal", c = s ? "ArrowLeft" : "ArrowUp", l = s ? "ArrowRight" : "ArrowDown", u = m(), f = u.indexOf(r), h = null;
4374
+ switch (t.key) {
4221
4375
  case c:
4222
- i < r.length - 1 && n.insertBefore(t, r[i + 1].nextSibling);
4376
+ a > 0 && (h = () => r.insertBefore(n, i[a - 1]));
4377
+ break;
4378
+ case l:
4379
+ a < i.length - 1 && (h = () => r.insertBefore(n, i[a + 1].nextSibling));
4223
4380
  break;
4224
4381
  case "ArrowLeft":
4225
4382
  case "ArrowRight": {
4226
- let n = d[f + (e.key === "ArrowLeft" ? -1 : 1)];
4227
- if (!n) break;
4228
- let r = l(n);
4229
- n.insertBefore(t, r[Math.min(i, r.length)] ?? null);
4383
+ let e = u[f + (t.key === "ArrowLeft" ? -1 : 1)];
4384
+ if (!e) break;
4385
+ let r = p(e);
4386
+ h = () => e.insertBefore(n, r[Math.min(a, r.length)] ?? null);
4230
4387
  break;
4231
4388
  }
4232
4389
  case " ":
4233
4390
  case "Enter":
4234
- e.preventDefault(), b(!0);
4391
+ t.preventDefault(), C(!0);
4235
4392
  return;
4236
4393
  case "Escape":
4237
- e.preventDefault(), b(!1);
4394
+ t.preventDefault(), C(!1);
4238
4395
  return;
4239
4396
  default: return;
4240
4397
  }
4241
- e.preventDefault(), t.focus();
4242
- let m = t.parentElement;
4243
- Y(`Position ${l(m).indexOf(t) + 1} of ${l(m).length}${m === n ? "" : `, in ${m.getAttribute("aria-label") ?? "next list"}`}.`);
4398
+ if (t.preventDefault(), h) {
4399
+ wt([...y(), n], h, o);
4400
+ let t = n.parentElement;
4401
+ d.container = t, d.index = p(t).indexOf(n), K(e, "sortable:move", {
4402
+ item: n,
4403
+ to: t,
4404
+ index: d.index
4405
+ });
4406
+ }
4407
+ n.focus();
4408
+ let g = n.parentElement;
4409
+ J(`Position ${p(g).indexOf(n) + 1} of ${p(g).length}${g === r ? "" : `, in ${g.getAttribute("aria-label") ?? "next list"}`}.`);
4244
4410
  }
4245
4411
  return {
4246
4412
  name: "sortable",
4247
4413
  element: e,
4248
4414
  options: t,
4249
- toArray: () => l(e).map((e) => e.getAttribute("data-id") ?? ""),
4415
+ toArray: () => p(e).map((e) => e.getAttribute("data-id") ?? ""),
4250
4416
  destroy: () => {
4251
- s && b(!1), n.abort(), f?.disconnect(), o && X.get(o)?.delete(e), e.classList.remove("is-sortable");
4417
+ w(), d && C(!1), n.abort(), g?.disconnect(), l && Y.get(l)?.delete(e), e.classList.remove("is-sortable");
4252
4418
  }
4253
4419
  };
4254
4420
  }
4255
- G.register("sortable", yt);
4421
+ G.register("sortable", Ot);
4256
4422
  // src/mixins/resizable.ts
4257
- function bt(e, t = {}) {
4423
+ function kt(e, t = {}) {
4258
4424
  let n = t.handles ?? [
4259
4425
  "e",
4260
4426
  "s",
@@ -4286,7 +4452,7 @@ function bt(e, t = {}) {
4286
4452
  let t = e.dataset.edge;
4287
4453
  e.setAttribute("aria-valuenow", String(t === "e" || t === "w" ? h.width : h.height));
4288
4454
  }
4289
- t.onResize?.(h), q(e, "resizable:resize", h);
4455
+ t.onResize?.(h), K(e, "resizable:resize", h);
4290
4456
  }
4291
4457
  for (let a of n) {
4292
4458
  let n = document.createElement("div");
@@ -4303,7 +4469,7 @@ function bt(e, t = {}) {
4303
4469
  y: t.clientY,
4304
4470
  ...r,
4305
4471
  pointerId: t.pointerId
4306
- }, n.setPointerCapture?.(t.pointerId), e.classList.add("is-resizing"), q(e, "resizable:start", r);
4472
+ }, n.setPointerCapture?.(t.pointerId), e.classList.add("is-resizing"), K(e, "resizable:start", r);
4307
4473
  }, { signal: c.signal }), n.addEventListener("pointermove", (e) => {
4308
4474
  if (!u || e.pointerId !== u.pointerId) return;
4309
4475
  let t = e.clientX - u.x, n = e.clientY - u.y;
@@ -4313,7 +4479,7 @@ function bt(e, t = {}) {
4313
4479
  if (!u || n.pointerId !== u.pointerId) return;
4314
4480
  u = null, e.classList.remove("is-resizing");
4315
4481
  let r = d();
4316
- t.onEnd?.(r), q(e, "resizable:end", r);
4482
+ t.onEnd?.(r), K(e, "resizable:end", r);
4317
4483
  };
4318
4484
  n.addEventListener("pointerup", f, { signal: c.signal }), n.addEventListener("pointercancel", f, { signal: c.signal }), n.addEventListener("keydown", (n) => {
4319
4485
  let r = n.shiftKey ? s * 5 : s, i = d(), o = {
@@ -4325,7 +4491,7 @@ function bt(e, t = {}) {
4325
4491
  if (!o) return;
4326
4492
  n.preventDefault(), p(a, i.width + o[0], i.height + o[1]);
4327
4493
  let c = d();
4328
- t.onEnd?.(c), q(e, "resizable:end", c);
4494
+ t.onEnd?.(c), K(e, "resizable:end", c);
4329
4495
  }, { signal: c.signal });
4330
4496
  }
4331
4497
  return {
@@ -4338,11 +4504,11 @@ function bt(e, t = {}) {
4338
4504
  }
4339
4505
  };
4340
4506
  }
4341
- G.register("resizable", bt);
4507
+ G.register("resizable", kt);
4342
4508
  // src/mixins/dropdown.ts
4343
- function xt(e, t = {}) {
4509
+ function At(e, t = {}) {
4344
4510
  if (!(e instanceof HTMLSelectElement)) throw Error("dropdown mixin must be applied to a <select>");
4345
- let n = e, { searchable: r = !0, emptyText: i = "No matches" } = t, a = new AbortController(), { signal: o } = a, s = L("dropdown"), c = document.createElement("div");
4511
+ let n = e, { searchable: r = !0, emptyText: i = "No matches" } = t, a = new AbortController(), { signal: o } = a, s = B("dropdown"), c = document.createElement("div");
4346
4512
  c.className = "dropdown";
4347
4513
  let l = document.createElement("input");
4348
4514
  l.type = "text", l.className = "dropdown__input", l.setAttribute("role", "combobox"), l.setAttribute("aria-expanded", "false"), l.setAttribute("aria-controls", `${s}-list`), l.setAttribute("aria-autocomplete", r ? "list" : "none"), l.autocomplete = "off", l.readOnly = !r, l.placeholder = t.placeholder ?? n.getAttribute("placeholder") ?? "";
@@ -4397,7 +4563,7 @@ function xt(e, t = {}) {
4397
4563
  let r = h[e];
4398
4564
  if (!r || r.disabled) return;
4399
4565
  let i = n.value !== r.value;
4400
- n.value = r.value, l.value = r.textContent ?? "", x(!1), i && (n.dispatchEvent(new Event("input", { bubbles: !0 })), n.dispatchEvent(new Event("change", { bubbles: !0 })), t.onChange?.(r.value), q(n, "dropdown:change", {
4566
+ n.value = r.value, l.value = r.textContent ?? "", x(!1), i && (n.dispatchEvent(new Event("input", { bubbles: !0 })), n.dispatchEvent(new Event("change", { bubbles: !0 })), t.onChange?.(r.value), K(n, "dropdown:change", {
4401
4567
  value: r.value,
4402
4568
  label: r.textContent
4403
4569
  }));
@@ -4445,20 +4611,20 @@ function xt(e, t = {}) {
4445
4611
  }
4446
4612
  };
4447
4613
  }
4448
- G.register("dropdown", xt);
4614
+ G.register("dropdown", At);
4449
4615
  // src/mixins/tooltip.ts
4450
- function St(e, t = {}) {
4616
+ function jt(e, t = {}) {
4451
4617
  let { placement: n = "top", delay: r = 300 } = t, i = new AbortController(), { signal: a } = i, o = e.getAttribute("title"), s = () => t.content ?? e.dataset.tooltip ?? o ?? "";
4452
4618
  o !== null && e.removeAttribute("title");
4453
4619
  let c = document.createElement("div");
4454
- c.id = L("tooltip"), c.className = "tooltip", c.setAttribute("role", "tooltip"), c.hidden = !0;
4620
+ c.id = B("tooltip"), c.className = "tooltip", c.setAttribute("role", "tooltip"), c.hidden = !0;
4455
4621
  let l = e.getAttribute("aria-describedby");
4456
4622
  e.setAttribute("aria-describedby", [l, c.id].filter(Boolean).join(" "));
4457
4623
  let u = null;
4458
4624
  function d() {
4459
4625
  u && clearTimeout(u), u = null;
4460
4626
  let t = s();
4461
- t && (c.textContent = t, c.isConnected || document.body.appendChild(c), c.hidden = !1, ft(c, e.getBoundingClientRect(), n));
4627
+ t && (c.textContent = t, c.isConnected || document.body.appendChild(c), c.hidden = !1, pt(c, e.getBoundingClientRect(), n));
4462
4628
  }
4463
4629
  function f() {
4464
4630
  u && clearTimeout(u), u = setTimeout(d, r);
@@ -4486,9 +4652,9 @@ function St(e, t = {}) {
4486
4652
  }
4487
4653
  };
4488
4654
  }
4489
- G.register("tooltip", St);
4655
+ G.register("tooltip", jt);
4490
4656
  // src/mixins/context-menu.ts
4491
- function Ct(e, t = {}) {
4657
+ function Mt(e, t = {}) {
4492
4658
  let n = new AbortController(), { signal: r } = n, i = null, a = null, o = null, s = null, c = "", l = null, u = () => t.items ?? [];
4493
4659
  function d() {
4494
4660
  return i ? Array.from(i.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])")) : [];
@@ -4500,7 +4666,7 @@ function Ct(e, t = {}) {
4500
4666
  function p(t, n, r) {
4501
4667
  h(!1), o = r, s = document.activeElement, a = new AbortController();
4502
4668
  let p = a.signal;
4503
- i = document.createElement("div"), i.className = "context-menu", i.id = L("menu"), i.setAttribute("role", "menu");
4669
+ i = document.createElement("div"), i.className = "context-menu", i.id = B("menu"), i.setAttribute("role", "menu");
4504
4670
  for (let e of u()) {
4505
4671
  if (e.separator) {
4506
4672
  let e = document.createElement("div");
@@ -4559,7 +4725,7 @@ function Ct(e, t = {}) {
4559
4725
  }
4560
4726
  function m(n) {
4561
4727
  let r = o ?? e;
4562
- h(), t.onSelect?.(n, r), q(e, "context-menu:select", {
4728
+ h(), t.onSelect?.(n, r), K(e, "context-menu:select", {
4563
4729
  action: n,
4564
4730
  target: r
4565
4731
  });
@@ -4593,103 +4759,103 @@ function Ct(e, t = {}) {
4593
4759
  }
4594
4760
  };
4595
4761
  }
4596
- G.register("context-menu", Ct);
4762
+ G.register("context-menu", Mt);
4597
4763
  // src/mixins/index.ts
4598
- function wt() {
4764
+ function Nt() {
4599
4765
  let e = {
4600
- draggable: mt,
4601
- editable: ht,
4602
- "grid-navigation": gt,
4603
- "infinite-scroll": _t,
4604
- sortable: yt,
4605
- resizable: bt,
4606
- dropdown: xt,
4607
- tooltip: St,
4608
- "context-menu": Ct
4766
+ draggable: ht,
4767
+ editable: gt,
4768
+ "grid-navigation": _t,
4769
+ "infinite-scroll": vt,
4770
+ sortable: Ot,
4771
+ resizable: kt,
4772
+ dropdown: At,
4773
+ tooltip: jt,
4774
+ "context-menu": Mt
4609
4775
  };
4610
4776
  for (let [t, n] of Object.entries(e)) G.has(t) || G.register(t, n);
4611
4777
  }
4612
4778
  // src/version.ts
4613
- var Z = "0.1.1";
4779
+ var Z = "0.1.4";
4614
4780
  // src/plugins/date-utils.ts
4615
- function Tt(e, t = {}) {
4781
+ function Pt(e, t = {}) {
4616
4782
  let n = e instanceof HTMLInputElement ? e : e.querySelector("input"), r = new AbortController();
4617
4783
  if (!n) throw Error("datepicker: no <input> found");
4618
4784
  let i = n.type;
4619
4785
  n.type = "date";
4620
- let a = O(t.min), o = O(t.max);
4621
- return a && (n.min = A(a)), o && (n.max = A(o)), n.addEventListener("change", () => {
4622
- let e = O(n.value);
4623
- t.onChange?.(e), q(n, "datepicker:change", { date: e });
4786
+ let a = j(t.min), o = j(t.max);
4787
+ return a && (n.min = N(a)), o && (n.max = N(o)), n.addEventListener("change", () => {
4788
+ let e = j(n.value);
4789
+ t.onChange?.(e), K(n, "datepicker:change", { date: e });
4624
4790
  }, { signal: r.signal }), {
4625
4791
  name: "datepicker",
4626
4792
  element: e,
4627
4793
  options: t,
4628
- value: () => O(n.value),
4794
+ value: () => j(n.value),
4629
4795
  destroy: () => {
4630
4796
  r.abort(), n.type = i;
4631
4797
  }
4632
4798
  };
4633
4799
  }
4634
- function Et(e, t = {}) {
4800
+ function Ft(e, t = {}) {
4635
4801
  let n = e.querySelector(t.startSelector ?? "[data-start], [name=\"start\"]"), r = e.querySelector(t.endSelector ?? "[data-end], [name=\"end\"]");
4636
4802
  if (!n || !r) throw Error("daterange: start and end inputs are required");
4637
4803
  let i = new AbortController();
4638
4804
  n.type = "date", r.type = "date";
4639
4805
  let a = () => (r.min = n.value || "", n.max = r.value || "", {
4640
- start: O(n.value),
4641
- end: O(r.value)
4806
+ start: j(n.value),
4807
+ end: j(r.value)
4642
4808
  }), o = () => {
4643
4809
  let n = a();
4644
- t.onChange?.(n), q(e, "daterange:change", n);
4810
+ t.onChange?.(n), K(e, "daterange:change", n);
4645
4811
  };
4646
4812
  return a(), n.addEventListener("change", o, { signal: i.signal }), r.addEventListener("change", o, { signal: i.signal }), {
4647
4813
  name: "daterange",
4648
4814
  element: e,
4649
4815
  options: t,
4650
4816
  value: () => ({
4651
- start: O(n.value),
4652
- end: O(r.value)
4817
+ start: j(n.value),
4818
+ end: j(r.value)
4653
4819
  }),
4654
4820
  destroy: () => i.abort()
4655
4821
  };
4656
4822
  }
4657
- var Q = () => j(/* @__PURE__ */ new Date());
4658
- function Dt() {
4823
+ var Q = () => P(/* @__PURE__ */ new Date());
4824
+ function It() {
4659
4825
  return {
4660
4826
  name: "date-utils",
4661
4827
  version: Z,
4662
4828
  mixins: {
4663
- datepicker: Tt,
4664
- daterange: Et
4829
+ datepicker: Pt,
4830
+ daterange: Ft
4665
4831
  },
4666
4832
  validators: {
4667
4833
  futureDate: {
4668
4834
  fn: (e, t) => {
4669
- let n = O(e);
4670
- return n ? t.includeToday === !1 ? j(n) > Q() : j(n) >= Q() : !0;
4835
+ let n = j(e);
4836
+ return n ? t.includeToday === !1 ? P(n) > Q() : P(n) >= Q() : !0;
4671
4837
  },
4672
4838
  message: "Choose a date in the future"
4673
4839
  },
4674
4840
  pastDate: {
4675
4841
  fn: (e, t) => {
4676
- let n = O(e);
4677
- return n ? t.includeToday === !1 ? j(n) < Q() : j(n) <= Q() : !0;
4842
+ let n = j(e);
4843
+ return n ? t.includeToday === !1 ? P(n) < Q() : P(n) <= Q() : !0;
4678
4844
  },
4679
4845
  message: "Choose a date in the past"
4680
4846
  },
4681
4847
  dateRange: {
4682
4848
  fn: (e, t) => {
4683
- let n = O(e);
4849
+ let n = j(e);
4684
4850
  if (!n) return !0;
4685
- let r = O(t.min), i = O(t.max);
4686
- return !(r && j(n) < j(r) || i && j(n) > j(i));
4851
+ let r = j(t.min), i = j(t.max);
4852
+ return !(r && P(n) < P(r) || i && P(n) > P(i));
4687
4853
  },
4688
4854
  message: "Choose a date between {min} and {max}"
4689
4855
  },
4690
4856
  businessDay: {
4691
4857
  fn: (e) => {
4692
- let t = O(e);
4858
+ let t = j(e);
4693
4859
  if (!t) return !0;
4694
4860
  let n = t.getDay();
4695
4861
  return n !== 0 && n !== 6;
@@ -4698,10 +4864,10 @@ function Dt() {
4698
4864
  },
4699
4865
  minAge: {
4700
4866
  fn: (e, t) => {
4701
- let n = O(e);
4867
+ let n = j(e);
4702
4868
  if (!n) return !0;
4703
4869
  let r = Number(t.years ?? 18), i = Q();
4704
- return i.setFullYear(i.getFullYear() - r), j(n) <= i;
4870
+ return i.setFullYear(i.getFullYear() - r), P(n) <= i;
4705
4871
  },
4706
4872
  message: "You must be at least {years} years old"
4707
4873
  }
@@ -4709,7 +4875,7 @@ function Dt() {
4709
4875
  };
4710
4876
  }
4711
4877
  // src/plugins/async-validators.ts
4712
- function Ot() {
4878
+ function Lt() {
4713
4879
  let e = null, t = {
4714
4880
  debounce: 300,
4715
4881
  failOpen: !0
@@ -4720,7 +4886,7 @@ function Ot() {
4720
4886
  let s = new AbortController();
4721
4887
  n.set(o, s), e.signal?.addEventListener("abort", () => s.abort(), { once: !0 });
4722
4888
  try {
4723
- return await ee(r ?? t.debounce, s.signal), await i(s.signal);
4889
+ return await te(r ?? t.debounce, s.signal), await i(s.signal);
4724
4890
  } catch {
4725
4891
  return s.signal.aborted || t.failOpen ? !0 : a;
4726
4892
  } finally {
@@ -4784,7 +4950,7 @@ function Ot() {
4784
4950
  };
4785
4951
  }
4786
4952
  // src/plugins/rich-text.ts
4787
- var kt = [
4953
+ var Rt = [
4788
4954
  "bold",
4789
4955
  "italic",
4790
4956
  "underline",
@@ -4796,7 +4962,7 @@ var kt = [
4796
4962
  "blockquote",
4797
4963
  "link",
4798
4964
  "clear"
4799
- ], At = {
4965
+ ], zt = {
4800
4966
  bold: {
4801
4967
  label: "Bold",
4802
4968
  icon: "B",
@@ -4900,14 +5066,14 @@ function $(e, t) {
4900
5066
  return !1;
4901
5067
  }
4902
5068
  }
4903
- function jt(e, t = {}) {
4904
- let n = new AbortController(), { signal: r } = n, i = e instanceof HTMLTextAreaElement ? e : null, a = i ? document.createElement("div") : e, o = (e) => P(e, t.sanitize), s = document.createElement("div");
5069
+ function Bt(e, t = {}) {
5070
+ let n = new AbortController(), { signal: r } = n, i = e instanceof HTMLTextAreaElement ? e : null, a = i ? document.createElement("div") : e, o = (e) => L(e, t.sanitize), s = document.createElement("div");
4905
5071
  s.className = "rich-text", e.insertAdjacentElement("beforebegin", s);
4906
5072
  let c = document.createElement("div");
4907
- c.className = "rich-text__toolbar", c.setAttribute("role", "toolbar"), c.setAttribute("aria-label", "Formatting"), s.appendChild(c), i ? (a.innerHTML = o(i.value), i.hidden = !0, s.append(a, i)) : (a.innerHTML = o(a.innerHTML), s.appendChild(a)), a.contentEditable = "true", a.classList.add("rich-text__content"), a.setAttribute("role", "textbox"), a.setAttribute("aria-multiline", "true"), t.label && a.setAttribute("aria-label", t.label), t.placeholder && (a.dataset.placeholder = t.placeholder), a.id ||= L("rich-text"), $("defaultParagraphSeparator", "p");
5073
+ c.className = "rich-text__toolbar", c.setAttribute("role", "toolbar"), c.setAttribute("aria-label", "Formatting"), s.appendChild(c), i ? (a.innerHTML = o(i.value), i.hidden = !0, s.append(a, i)) : (a.innerHTML = o(a.innerHTML), s.appendChild(a)), a.contentEditable = "true", a.classList.add("rich-text__content"), a.setAttribute("role", "textbox"), a.setAttribute("aria-multiline", "true"), t.label && a.setAttribute("aria-label", t.label), t.placeholder && (a.dataset.placeholder = t.placeholder), a.id ||= B("rich-text"), $("defaultParagraphSeparator", "p");
4908
5074
  let l = [];
4909
- for (let e of t.toolbar ?? kt) {
4910
- let t = At[e];
5075
+ for (let e of t.toolbar ?? Rt) {
5076
+ let t = zt[e];
4911
5077
  if (!t) continue;
4912
5078
  let n = document.createElement("button");
4913
5079
  n.type = "button", n.className = `rich-text__button rich-text__button--${e}`, n.dataset.command = e, n.dataset.icon = t.icon, n.setAttribute("aria-label", t.label), n.title = t.shortcut ? `${t.label} (Ctrl+${t.shortcut.toUpperCase()})` : t.label, n.tabIndex = l.length === 0 ? 0 : -1, (t.state || t.block) && n.setAttribute("aria-pressed", "false"), c.appendChild(n), l.push(n);
@@ -4921,12 +5087,12 @@ function jt(e, t = {}) {
4921
5087
  let p = null, m = a.innerHTML;
4922
5088
  function h() {
4923
5089
  let e = o(a.innerHTML);
4924
- e !== m && (m = e, i && (i.value = e, i.dispatchEvent(new Event("input", { bubbles: !0 }))), a.classList.toggle("is-empty", F(e).trim() === ""), q(a, "rich-text:change", {
5090
+ e !== m && (m = e, i && (i.value = e, i.dispatchEvent(new Event("input", { bubbles: !0 }))), a.classList.toggle("is-empty", R(e).trim() === ""), K(a, "rich-text:change", {
4925
5091
  html: e,
4926
- text: F(e)
5092
+ text: R(e)
4927
5093
  }));
4928
5094
  }
4929
- a.classList.toggle("is-empty", F(a.innerHTML).trim() === "");
5095
+ a.classList.toggle("is-empty", R(a.innerHTML).trim() === "");
4930
5096
  function g() {
4931
5097
  let e = document.getSelection();
4932
5098
  if (!e || !e.anchorNode || !a.contains(e.anchorNode)) return;
@@ -4934,7 +5100,7 @@ function jt(e, t = {}) {
4934
5100
  for (; t && t !== a && !/^(P|H2|H3|BLOCKQUOTE|PRE|LI)$/.test(t.tagName);) t = t.parentElement;
4935
5101
  let n = t && t !== a ? t.tagName.toLowerCase() : "p";
4936
5102
  for (let e of l) {
4937
- let t = At[e.dataset.command], r = null;
5103
+ let t = zt[e.dataset.command], r = null;
4938
5104
  if (t.block) r = n === t.block;
4939
5105
  else if (t.state) try {
4940
5106
  r = document.queryCommandState?.(t.state) ?? !1;
@@ -4951,12 +5117,12 @@ function jt(e, t = {}) {
4951
5117
  d.value = t?.getAttribute("href") ?? "", u.hidden = !1, d.focus();
4952
5118
  }
4953
5119
  function v(e) {
4954
- let t = At[e];
5120
+ let t = zt[e];
4955
5121
  a.focus(), e === "link" ? _() : (t.block ? $("formatBlock", l.find((t) => t.dataset.command === e)?.getAttribute("aria-pressed") === "true" ? "p" : `<${t.arg}>`) : $(t.exec, t.arg), h(), g());
4956
5122
  }
4957
5123
  return u.addEventListener("submit", (e) => {
4958
5124
  e.preventDefault();
4959
- let t = N(d.value.trim(), "link");
5125
+ let t = I(d.value.trim(), "link");
4960
5126
  if (u.hidden = !0, a.focus(), p) {
4961
5127
  let e = document.getSelection();
4962
5128
  e?.removeAllRanges(), e?.addRange(p);
@@ -4987,7 +5153,7 @@ function jt(e, t = {}) {
4987
5153
  u: "underline",
4988
5154
  k: "link"
4989
5155
  };
4990
- r[n] && (t.toolbar ?? kt).includes(r[n]) ? (e.preventDefault(), v(r[n])) : e.shiftKey && (n === "7" || n === "&") ? (e.preventDefault(), v("orderedList")) : e.shiftKey && (n === "8" || n === "*") && (e.preventDefault(), v("bulletList"));
5156
+ r[n] && (t.toolbar ?? Rt).includes(r[n]) ? (e.preventDefault(), v(r[n])) : e.shiftKey && (n === "7" || n === "&") ? (e.preventDefault(), v("orderedList")) : e.shiftKey && (n === "8" || n === "*") && (e.preventDefault(), v("bulletList"));
4991
5157
  }, { signal: r }), a.addEventListener("paste", (e) => {
4992
5158
  let t = e.clipboardData;
4993
5159
  if (!t) return;
@@ -5002,7 +5168,7 @@ function jt(e, t = {}) {
5002
5168
  options: t,
5003
5169
  editor: a,
5004
5170
  getHTML: () => o(a.innerHTML),
5005
- getText: () => F(a.innerHTML),
5171
+ getText: () => R(a.innerHTML),
5006
5172
  setHTML: (e) => {
5007
5173
  a.innerHTML = o(e), h();
5008
5174
  },
@@ -5012,21 +5178,21 @@ function jt(e, t = {}) {
5012
5178
  }
5013
5179
  };
5014
5180
  }
5015
- function Mt() {
5181
+ function Vt() {
5016
5182
  return {
5017
5183
  name: "rich-text",
5018
5184
  version: Z,
5019
- mixins: { "rich-text": jt },
5185
+ mixins: { "rich-text": Bt },
5020
5186
  validators: {
5021
5187
  richTextMinLength: {
5022
5188
  fn: (e, t) => {
5023
- let n = F(e).trim();
5189
+ let n = R(e).trim();
5024
5190
  return n === "" || n.length >= Number(t.min ?? 0);
5025
5191
  },
5026
5192
  message: "Write at least {min} characters"
5027
5193
  },
5028
5194
  richTextMaxLength: {
5029
- fn: (e, t) => F(e).trim().length <= Number(t.max ?? Infinity),
5195
+ fn: (e, t) => R(e).trim().length <= Number(t.max ?? Infinity),
5030
5196
  message: "Keep it under {max} characters"
5031
5197
  },
5032
5198
  noEmptyParagraphs: {
@@ -5037,19 +5203,19 @@ function Mt() {
5037
5203
  };
5038
5204
  }
5039
5205
  // src/plugins/builtins.ts
5040
- function Nt() {
5041
- K("date-utils", Dt), K("async-validators", Ot), K("rich-text", Mt);
5206
+ function Ht() {
5207
+ dt("date-utils", It), dt("async-validators", Lt), dt("rich-text", Vt);
5042
5208
  }
5043
- Nt();
5209
+ Ht();
5044
5210
  // src/core/arethesis.ts
5045
- var Pt = class e extends f {
5211
+ var Ut = class e extends f {
5046
5212
  static instance = null;
5047
5213
  version = Z;
5048
5214
  store = new l();
5049
5215
  listViews = new u();
5050
5216
  optimistic;
5051
- http = new ae();
5052
- validation = new Ae();
5217
+ http = new C();
5218
+ validation = new De();
5053
5219
  binder;
5054
5220
  plugins;
5055
5221
  collab;
@@ -5064,7 +5230,7 @@ var Pt = class e extends f {
5064
5230
  initPromise = null;
5065
5231
  stopObserving = null;
5066
5232
  constructor() {
5067
- super(), wt(), Nt(), this.optimistic = new m(this.store, this.listViews), this.binder = new We(this.validation), this.plugins = new dt(this), this.collab = new Ce(() => this.ws), this.http.connect({
5233
+ super(), Nt(), Ht(), this.optimistic = new m(this.store, this.listViews), this.binder = new Ve(this.validation), this.plugins = new ft(this), this.collab = new be(() => this.ws), this.http.connect({
5068
5234
  store: this.store,
5069
5235
  listViews: this.listViews
5070
5236
  }), this.listViews.setLoader((e, t) => this.http.loadListView(e, t)), Je({
@@ -5105,7 +5271,7 @@ var Pt = class e extends f {
5105
5271
  for (let e of t.types ?? []) this.defineType(e);
5106
5272
  for (let [e, n] of Object.entries(t.endpoints ?? {})) this.defineEndpoint(e, n);
5107
5273
  for (let [e, n] of Object.entries(t.validation?.messages ?? {})) this.validation.setMessage(e, n);
5108
- t.auth && (this.auth = new le(t.auth, {
5274
+ t.auth && (this.auth = new T(t.auth, {
5109
5275
  fetch: () => t.http?.fetch ?? globalThis.fetch.bind(globalThis),
5110
5276
  resolveUrl: (e) => this.http.resolveUrl(e)
5111
5277
  }), this.http.connect({ auth: this.auth })), t.persistence !== !1 && await this.initPersistence(typeof t.persistence == "object" ? t.persistence : {});
@@ -5113,10 +5279,10 @@ var Pt = class e extends f {
5113
5279
  let t = e.replace(/^ws(s?):\/\//i, "http$1://");
5114
5280
  return this.auth && this.http.isTrustedUrl(t) ? this.auth.ensureValidToken() : null;
5115
5281
  };
5116
- if (t.sse && (this.sse = new de({
5282
+ if (t.sse && (this.sse = new ce({
5117
5283
  ...t.sse,
5118
5284
  url: this.http.resolveUrl(t.sse.url)
5119
- }), this.sse.connectStore(this.store, this.listViews), this.sse.setTokenProvider(n(this.sse.config.url))), t.websocket && (this.ws = new pe(t.websocket), this.ws.setTokenProvider(n(t.websocket.url))), t.azurePubSub && (this.azurePubSub = new he({
5285
+ }), this.sse.connectStore(this.store, this.listViews), this.sse.setTokenProvider(n(this.sse.config.url))), t.websocket && (this.ws = new ue(t.websocket), this.ws.setTokenProvider(n(t.websocket.url))), t.azurePubSub && (this.azurePubSub = new fe({
5120
5286
  ...t.azurePubSub,
5121
5287
  negotiateUrl: this.http.resolveUrl(t.azurePubSub.negotiateUrl),
5122
5288
  fetch: t.azurePubSub.fetch ?? t.http?.fetch
@@ -5165,15 +5331,15 @@ var Pt = class e extends f {
5165
5331
  this.disconnect(), this.stopObserving?.(), this.stopObserving = null, this.plugins.destroy(), this.auth?.destroy(), this.persistence?.close(), this.clear(), e.instance === this && (e.instance = null);
5166
5332
  }
5167
5333
  };
5168
- function Ft() {
5169
- return Pt.getInstance();
5334
+ function Wt() {
5335
+ return Ut.getInstance();
5170
5336
  }
5171
- function It(e) {
5172
- return Ft().defineType(e);
5337
+ function Gt(e) {
5338
+ return Wt().defineType(e);
5173
5339
  }
5174
- function Lt(e, t) {
5175
- return Ft().defineEndpoint(e, t);
5340
+ function Kt(e, t) {
5341
+ return Wt().defineEndpoint(e, t);
5176
5342
  }
5177
- export { ve as $, rt as A, I as B, it as C, et as D, Ze as E, U as F, De as G, P as H, We as I, Te as J, O as K, qe as L, tt as M, Xe as N, nt as O, W as P, be as Q, V as R, lt as S, ot as T, N as U, F as V, Ae as W, Se as X, Ce as Y, xe as Z, gt as _, jt as a, le as at, dt as b, Dt as c, _ as ct, Ct as d, u as dt, _e as et, St as f, l as ft, _t as g, i as gt, yt as h, r as ht, Ft as i, de as it, $e as j, G as k, Z as l, m as lt, bt as m, a as mt, Lt as n, he as nt, Mt as o, ae as ot, xt as p, s as pt, A as q, It as r, pe as rt, Ot as s, v as st, Pt as t, D as tt, wt as u, f as ut, ht as v, at as w, K as x, mt as y, B as z };
5343
+ export { A as $, rt as A, z as B, it as C, et as D, Ze as E, U as F, we as G, L as H, Ve as I, Se as J, j as K, We as L, tt as M, Xe as N, nt as O, W as P, _e as Q, Ke as R, lt as S, ot as T, I as U, R as V, De as W, ye as X, be as Y, ve as Z, _t as _, Bt as a, T as at, ft as b, It as c, _ as ct, Mt as d, u as dt, he as et, jt as f, l as ft, vt as g, i as gt, Ot as h, r as ht, Wt as i, ce as it, $e as j, G as k, Z as l, m as lt, kt as m, a as mt, Kt as n, fe as nt, Vt as o, C as ot, At as p, s as pt, N as q, Gt as r, ue as rt, Lt as s, v as st, Ut as t, k as tt, Nt as u, f as ut, gt as v, at as w, dt as x, ht as y, Ge as z };
5178
5344
 
5179
- //# sourceMappingURL=arethesis-DTJOJ7F-.js.map
5345
+ //# sourceMappingURL=arethesis-Cu_lOx8o.js.map