cally 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cally.js CHANGED
@@ -1,4 +1,4 @@
1
- class oe {
1
+ class te {
2
2
  /**
3
3
  * @type {T}
4
4
  */
@@ -20,7 +20,7 @@ class oe {
20
20
  * @param {T} value
21
21
  */
22
22
  set current(t) {
23
- this.#t != t && (this.#t = t, this.#e.forEach((s) => s(t)));
23
+ this.#t != t && (this.#t = t, this.#e.forEach((n) => n(t)));
24
24
  }
25
25
  /**
26
26
  * @type {import("hooks").Ref["on"]}
@@ -29,113 +29,113 @@ class oe {
29
29
  return this.#e.add(t), () => this.#e.delete(t);
30
30
  }
31
31
  }
32
- const Nt = (e) => new oe(e), tt = Symbol.for("atomico.hooks");
33
- globalThis[tt] = globalThis[tt] || {};
34
- let N = globalThis[tt];
35
- const re = Symbol.for("Atomico.suspense"), Pt = Symbol.for("Atomico.effect"), ie = Symbol.for("Atomico.layoutEffect"), Ot = Symbol.for("Atomico.insertionEffect"), O = (e, t, s) => {
36
- const { i: n, hooks: o } = N.c, r = o[n] = o[n] || {};
37
- return r.value = e(r.value), r.effect = t, r.tag = s, N.c.i++, o[n].value;
38
- }, ae = (e) => O((t = Nt(e)) => t), U = () => O((e = Nt(N.c.host)) => e), Ft = () => N.c.update, ce = (e, t, s = 0) => {
39
- let n = {}, o = !1;
40
- const r = () => o, i = (l, c) => {
41
- for (const h in n) {
42
- const a = n[h];
43
- a.effect && a.tag === l && (a.value = a.effect(a.value, c));
32
+ const Ct = (e) => new te(e), X = Symbol.for("atomico.hooks");
33
+ globalThis[X] = globalThis[X] || {};
34
+ let N = globalThis[X];
35
+ const ee = Symbol.for("Atomico.suspense"), Pt = Symbol.for("Atomico.effect"), ne = Symbol.for("Atomico.layoutEffect"), Nt = Symbol.for("Atomico.insertionEffect"), k = (e, t, n) => {
36
+ const { i: s, hooks: o } = N.c, r = o[s] = o[s] || {};
37
+ return r.value = e(r.value), r.effect = t, r.tag = n, N.c.i++, o[s].value;
38
+ }, se = (e) => k((t = Ct(e)) => t), $ = () => k((e = Ct(N.c.host)) => e), kt = () => N.c.update, oe = (e, t, n = 0) => {
39
+ let s = {}, o = !1;
40
+ const r = () => o, c = (i, u) => {
41
+ for (const d in s) {
42
+ const l = s[d];
43
+ l.effect && l.tag === i && (l.value = l.effect(l.value, u));
44
44
  }
45
45
  };
46
- return { load: (l) => {
47
- N.c = { host: t, hooks: n, update: e, i: 0, id: s };
48
- let c;
46
+ return { load: (i) => {
47
+ N.c = { host: t, hooks: s, update: e, i: 0, id: n };
48
+ let u;
49
49
  try {
50
- o = !1, c = l();
51
- } catch (h) {
52
- if (h !== re)
53
- throw h;
50
+ o = !1, u = i();
51
+ } catch (d) {
52
+ if (d !== ee)
53
+ throw d;
54
54
  o = !0;
55
55
  } finally {
56
56
  N.c = null;
57
57
  }
58
- return c;
59
- }, cleanEffects: (l) => (i(Ot, l), () => (i(ie, l), () => {
60
- i(Pt, l);
58
+ return u;
59
+ }, cleanEffects: (i) => (c(Nt, i), () => (c(ne, i), () => {
60
+ c(Pt, i);
61
61
  })), isSuspense: r };
62
- }, F = Symbol.for;
63
- function Mt(e, t) {
64
- const s = e.length;
65
- if (s !== t.length)
62
+ }, O = Symbol.for;
63
+ function Ot(e, t) {
64
+ const n = e.length;
65
+ if (n !== t.length)
66
66
  return !1;
67
- for (let n = 0; n < s; n++) {
68
- let o = e[n], r = t[n];
67
+ for (let s = 0; s < n; s++) {
68
+ let o = e[s], r = t[s];
69
69
  if (o !== r)
70
70
  return !1;
71
71
  }
72
72
  return !0;
73
73
  }
74
- const S = (e) => typeof e == "function", A = (e) => typeof e == "object", { isArray: ue } = Array, et = (e, t) => (t ? e instanceof HTMLStyleElement : !0) && "hydrate" in (e?.dataset || {});
75
- function kt(e, t) {
76
- let s;
77
- const n = (o) => {
74
+ const T = (e) => typeof e == "function", R = (e) => typeof e == "object", { isArray: re } = Array, G = (e, t) => (t ? e instanceof HTMLStyleElement : !0) && "hydrate" in (e?.dataset || {});
75
+ function At(e, t) {
76
+ let n;
77
+ const s = (o) => {
78
78
  let { length: r } = o;
79
- for (let i = 0; i < r; i++) {
80
- const f = o[i];
79
+ for (let c = 0; c < r; c++) {
80
+ const f = o[c];
81
81
  if (f && Array.isArray(f))
82
- n(f);
82
+ s(f);
83
83
  else {
84
- const u = typeof f;
85
- if (f == null || u === "function" || u === "boolean")
84
+ const a = typeof f;
85
+ if (f == null || a === "function" || a === "boolean")
86
86
  continue;
87
- u === "string" || u === "number" ? (s == null && (s = ""), s += f) : (s != null && (t(s), s = null), t(f));
87
+ a === "string" || a === "number" ? (n == null && (n = ""), n += f) : (n != null && (t(n), n = null), t(f));
88
88
  }
89
89
  }
90
90
  };
91
- n(e), s != null && t(s);
91
+ s(e), n != null && t(n);
92
92
  }
93
- const At = (e, t, s) => (e.addEventListener(t, s), () => e.removeEventListener(t, s));
94
- class Rt {
93
+ const Rt = (e, t, n) => (e.addEventListener(t, n), () => e.removeEventListener(t, n));
94
+ class Mt {
95
95
  /**
96
96
  *
97
97
  * @param {HTMLElement} target
98
98
  * @param {string} message
99
99
  * @param {string} value
100
100
  */
101
- constructor(t, s, n) {
102
- this.message = s, this.target = t, this.value = n;
101
+ constructor(t, n, s) {
102
+ this.message = n, this.target = t, this.value = s;
103
103
  }
104
104
  }
105
- class It extends Rt {
105
+ class Ft extends Mt {
106
106
  }
107
- class le extends Rt {
107
+ class ce extends Mt {
108
108
  }
109
- const L = "Custom", fe = null, de = { true: 1, "": 1, 1: 1 };
110
- function he(e, t, s, n, o) {
109
+ const _ = "Custom", ie = null, ae = { true: 1, "": 1, 1: 1 };
110
+ function le(e, t, n, s, o) {
111
111
  const {
112
112
  type: r,
113
- reflect: i,
113
+ reflect: c,
114
114
  event: f,
115
- value: u,
116
- attr: l = me(t)
117
- } = s?.name != L && A(s) && s != fe ? s : { type: s }, c = r?.name === L && r.map, h = u != null ? r == Function || !S(u) ? () => u : u : null;
115
+ value: a,
116
+ attr: i = ue(t)
117
+ } = n?.name != _ && R(n) && n != ie ? n : { type: n }, u = r?.name === _ && r.map, d = a != null ? r == Function || !T(a) ? () => a : a : null;
118
118
  Object.defineProperty(e, t, {
119
119
  configurable: !0,
120
120
  /**
121
121
  * @this {import("dom").AtomicoThisInternal}
122
122
  * @param {any} newValue
123
123
  */
124
- set(a) {
125
- const d = this[t];
126
- h && r != Boolean && a == null && (a = h());
127
- const { error: y, value: D } = (c ? pe : ge)(
124
+ set(l) {
125
+ const m = this[t];
126
+ d && r != Boolean && l == null && (l = d());
127
+ const { error: p, value: y } = (u ? he : me)(
128
128
  r,
129
- a
129
+ l
130
130
  );
131
- if (y && D != null)
132
- throw new It(
131
+ if (p && y != null)
132
+ throw new Ft(
133
133
  this,
134
134
  `The value defined for prop '${t}' must be of type '${r.name}'`,
135
- D
135
+ y
136
136
  );
137
- d != D && (this._props[t] = D ?? void 0, this.update(), f && Ut(this, f), this.updated.then(() => {
138
- i && (this._ignoreAttr = l, ye(this, r, l, this[t]), this._ignoreAttr = null);
137
+ m != y && (this._props[t] = y ?? void 0, this.update(), f && It(this, f), this.updated.then(() => {
138
+ c && (this._ignoreAttr = i, fe(this, r, i, this[t]), this._ignoreAttr = null);
139
139
  }));
140
140
  },
141
141
  /**
@@ -144,21 +144,21 @@ function he(e, t, s, n, o) {
144
144
  get() {
145
145
  return this._props[t];
146
146
  }
147
- }), h && (o[t] = h()), n[l] = { prop: t, type: r };
147
+ }), d && (o[t] = d()), s[i] = { prop: t, type: r };
148
148
  }
149
- const Ut = (e, { type: t, base: s = CustomEvent, ...n }) => e.dispatchEvent(new s(t, n)), me = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), ye = (e, t, s, n) => n == null || t == Boolean && !n ? e.removeAttribute(s) : e.setAttribute(
150
- s,
151
- t?.name === L && t?.serialize ? t?.serialize(n) : A(n) ? JSON.stringify(n) : t == Boolean ? "" : n
152
- ), be = (e, t) => e == Boolean ? !!de[t] : e == Number ? Number(t) : e == String ? t : e == Array || e == Object ? JSON.parse(t) : e.name == L ? t : (
149
+ const It = (e, { type: t, base: n = CustomEvent, ...s }) => e.dispatchEvent(new n(t, s)), ue = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), fe = (e, t, n, s) => s == null || t == Boolean && !s ? e.removeAttribute(n) : e.setAttribute(
150
+ n,
151
+ t?.name === _ && t?.serialize ? t?.serialize(s) : R(s) ? JSON.stringify(s) : t == Boolean ? "" : s
152
+ ), de = (e, t) => e == Boolean ? !!ae[t] : e == Number ? Number(t) : e == String ? t : e == Array || e == Object ? JSON.parse(t) : e.name == _ ? t : (
153
153
  // TODO: If when defining reflect the prop can also be of type string?
154
154
  new e(t)
155
- ), pe = ({ map: e }, t) => {
155
+ ), he = ({ map: e }, t) => {
156
156
  try {
157
157
  return { value: e(t), error: !1 };
158
158
  } catch {
159
159
  return { value: t, error: !0 };
160
160
  }
161
- }, ge = (e, t) => e == null || t == null ? { value: t, error: !1 } : e != String && t === "" ? { value: void 0, error: !1 } : e == Object || e == Array || e == Symbol ? {
161
+ }, me = (e, t) => e == null || t == null ? { value: t, error: !1 } : e != String && t === "" ? { value: void 0, error: !1 } : e == Object || e == Array || e == Symbol ? {
162
162
  value: t,
163
163
  error: {}.toString.call(t) !== `[object ${e.name}]`
164
164
  } : t instanceof e ? {
@@ -168,17 +168,17 @@ const Ut = (e, { type: t, base: s = CustomEvent, ...n }) => e.dispatchEvent(new
168
168
  value: t,
169
169
  error: e == Number ? typeof t != "number" ? !0 : Number.isNaN(t) : e == String ? typeof t != "string" : typeof t != "boolean"
170
170
  } : { value: t, error: !0 };
171
- let De = 0;
172
- const we = (e) => {
171
+ let ye = 0;
172
+ const pe = (e) => {
173
173
  const t = (e?.dataset || {})?.hydrate || "";
174
- return t || "c" + De++;
175
- }, $ = (e, t = HTMLElement) => {
176
- const s = {}, n = {}, o = "prototype" in t && t.prototype instanceof Element, r = o ? t : "base" in t ? t.base : HTMLElement, { props: i, styles: f } = o ? e : t;
177
- class u extends r {
174
+ return t || "c" + ye++;
175
+ }, j = (e, t = HTMLElement) => {
176
+ const n = {}, s = {}, o = "prototype" in t && t.prototype instanceof Element, r = o ? t : "base" in t ? t.base : HTMLElement, { props: c, styles: f } = o ? e : t;
177
+ class a extends r {
178
178
  constructor() {
179
179
  super(), this._setup(), this._render = () => e({ ...this._props });
180
- for (const c in n)
181
- this[c] = n[c];
180
+ for (const u in s)
181
+ this[u] = s[u];
182
182
  }
183
183
  /**
184
184
  * @returns {import("core").Sheets[]}
@@ -190,37 +190,37 @@ const we = (e) => {
190
190
  if (this._props)
191
191
  return;
192
192
  this._props = {};
193
- let c, h;
193
+ let u, d;
194
194
  this.mounted = new Promise(
195
- (m) => this.mount = () => {
196
- m(), c != this.parentNode && (h != c ? this.unmounted.then(this.update) : this.update()), c = this.parentNode;
195
+ (E) => this.mount = () => {
196
+ E(), u != this.parentNode && (d != u ? this.unmounted.then(this.update) : this.update()), u = this.parentNode;
197
197
  }
198
198
  ), this.unmounted = new Promise(
199
- (m) => this.unmount = () => {
200
- m(), (c != this.parentNode || !this.isConnected) && (a.cleanEffects(!0)()(), h = this.parentNode, c = null);
199
+ (E) => this.unmount = () => {
200
+ E(), (u != this.parentNode || !this.isConnected) && (l.cleanEffects(!0)()(), d = this.parentNode, u = null);
201
201
  }
202
202
  ), this.symbolId = this.symbolId || Symbol(), this.symbolIdParent = Symbol();
203
- const a = ce(
203
+ const l = oe(
204
204
  () => this.update(),
205
205
  this,
206
- we(this)
206
+ pe(this)
207
207
  );
208
- let d, y = !0;
209
- const D = et(this);
210
- this.update = () => (d || (d = !0, this.updated = (this.updated || this.mounted).then(() => {
208
+ let m, p = !0;
209
+ const y = G(this);
210
+ this.update = () => (m || (m = !0, this.updated = (this.updated || this.mounted).then(() => {
211
211
  try {
212
- const m = a.load(this._render), w = a.cleanEffects();
213
- return m && //@ts-ignore
214
- m.render(this, this.symbolId, D), d = !1, y && !a.isSuspense() && (y = !1, !D && Ee(this)), w();
212
+ const E = l.load(this._render), h = l.cleanEffects();
213
+ return E && //@ts-ignore
214
+ E.render(this, this.symbolId, y), m = !1, p && !l.isSuspense() && (p = !1, !y && be(this)), h();
215
215
  } finally {
216
- d = !1;
216
+ m = !1;
217
217
  }
218
218
  }).then(
219
219
  /**
220
220
  * @param {import("internal/hooks.js").CleanUseEffects} [cleanUseEffect]
221
221
  */
222
- (m) => {
223
- m && m();
222
+ (E) => {
223
+ E && E();
224
224
  }
225
225
  )), this.updated), this.update();
226
226
  }
@@ -236,74 +236,74 @@ const we = (e) => {
236
236
  * @param {(string|null)} oldValue
237
237
  * @param {(string|null)} value
238
238
  */
239
- attributeChangedCallback(c, h, a) {
240
- if (s[c]) {
241
- if (c === this._ignoreAttr || h === a)
239
+ attributeChangedCallback(u, d, l) {
240
+ if (n[u]) {
241
+ if (u === this._ignoreAttr || d === l)
242
242
  return;
243
- const { prop: d, type: y } = s[c];
243
+ const { prop: m, type: p } = n[u];
244
244
  try {
245
- this[d] = be(y, a);
245
+ this[m] = de(p, l);
246
246
  } catch {
247
- throw new le(
247
+ throw new ce(
248
248
  this,
249
- `The value defined as attr '${c}' cannot be parsed by type '${y.name}'`,
250
- a
249
+ `The value defined as attr '${u}' cannot be parsed by type '${p.name}'`,
250
+ l
251
251
  );
252
252
  }
253
253
  } else
254
- super.attributeChangedCallback(c, h, a);
254
+ super.attributeChangedCallback(u, d, l);
255
255
  }
256
256
  static get props() {
257
- return { ...super.props, ...i };
257
+ return { ...super.props, ...c };
258
258
  }
259
259
  static get observedAttributes() {
260
- const c = super.observedAttributes || [];
261
- for (const h in i)
262
- he(this.prototype, h, i[h], s, n);
263
- return Object.keys(s).concat(c);
260
+ const u = super.observedAttributes || [];
261
+ for (const d in c)
262
+ le(this.prototype, d, c[d], n, s);
263
+ return Object.keys(n).concat(u);
264
264
  }
265
265
  }
266
- return u;
266
+ return a;
267
267
  };
268
- function Ee(e) {
269
- const { styles: t } = e.constructor, { shadowRoot: s } = e;
270
- if (s && t.length) {
271
- const n = [];
272
- kt(t, (o) => {
273
- o && (o instanceof Element ? s.appendChild(o.cloneNode(!0)) : n.push(o));
274
- }), n.length && (s.adoptedStyleSheets = n);
268
+ function be(e) {
269
+ const { styles: t } = e.constructor, { shadowRoot: n } = e;
270
+ if (n && t.length) {
271
+ const s = [];
272
+ At(t, (o) => {
273
+ o && (o instanceof Element ? n.appendChild(o.cloneNode(!0)) : s.push(o));
274
+ }), s.length && (n.adoptedStyleSheets = s);
275
275
  }
276
276
  }
277
- const xt = (e) => (t, s) => {
278
- O(
277
+ const Ut = (e) => (t, n) => {
278
+ k(
279
279
  /**
280
280
  * Clean the effect hook
281
281
  * @type {import("internal/hooks.js").CollectorEffect}
282
282
  */
283
- ([n, o] = []) => ((o || !o) && (o && Mt(o, s) ? n = n || !0 : (S(n) && n(), n = null)), [n, s]),
283
+ ([s, o] = []) => ((o || !o) && (o && Ot(o, n) ? s = s || !0 : (T(s) && s(), s = null)), [s, n]),
284
284
  /**
285
285
  * @returns {any}
286
286
  */
287
- ([n, o], r) => r ? (S(n) && n(), []) : [n || t(), o],
287
+ ([s, o], r) => r ? (T(s) && s(), []) : [s || t(), o],
288
288
  e
289
289
  );
290
- }, j = xt(Pt), Se = xt(Ot);
291
- class _t extends Array {
290
+ }, nt = Ut(Pt), ge = Ut(Nt);
291
+ class $t extends Array {
292
292
  /**
293
293
  *
294
294
  * @param {any} initialState
295
295
  * @param {(nextState: any, state:any[], mount: boolean )=>void} mapState
296
296
  */
297
- constructor(t, s) {
298
- let n = !0;
297
+ constructor(t, n) {
298
+ let s = !0;
299
299
  const o = (r) => {
300
300
  try {
301
- s(r, this, n);
301
+ n(r, this, s);
302
302
  } finally {
303
- n = !1;
303
+ s = !1;
304
304
  }
305
305
  };
306
- super(void 0, o, s), o(t);
306
+ super(void 0, o, n), o(t);
307
307
  }
308
308
  /**
309
309
  * The following code allows a mutable approach to useState
@@ -318,45 +318,45 @@ class _t extends Array {
318
318
  // this[2](nextState, this);
319
319
  // }
320
320
  }
321
- const ct = (e) => {
322
- const t = Ft();
323
- return O(
324
- (s = new _t(e, (n, o, r) => {
325
- n = S(n) ? n(o[0]) : n, n !== o[0] && (o[0] = n, r || t());
326
- })) => s
321
+ const st = (e) => {
322
+ const t = kt();
323
+ return k(
324
+ (n = new $t(e, (s, o, r) => {
325
+ s = T(s) ? s(o[0]) : s, s !== o[0] && (o[0] = s, r || t());
326
+ })) => n
327
327
  );
328
328
  }, P = (e, t) => {
329
- const [s] = O(([n, o, r = 0] = []) => ((!o || o && !Mt(o, t)) && (n = e()), [n, t, r]));
330
- return s;
329
+ const [n] = k(([s, o, r = 0] = []) => ((!o || o && !Ot(o, t)) && (s = e()), [s, t, r]));
330
+ return n;
331
331
  }, Lt = (e) => {
332
- const { current: t } = U();
332
+ const { current: t } = $();
333
333
  if (!(e in t))
334
- throw new It(
334
+ throw new Ft(
335
335
  t,
336
336
  `For useProp("${e}"), the prop does not exist on the host.`,
337
337
  e
338
338
  );
339
- return O(
340
- (s = new _t(t[e], (n, o) => {
341
- n = S(n) ? n(t[e]) : n, t[e] = n;
342
- })) => (s[0] = t[e], s)
339
+ return k(
340
+ (n = new $t(t[e], (s, o) => {
341
+ s = T(s) ? s(t[e]) : s, t[e] = s;
342
+ })) => (n[0] = t[e], n)
343
343
  );
344
- }, v = (e, t = {}) => {
345
- const s = U();
346
- return s[e] || (s[e] = (n = t.detail) => Ut(s.current, {
344
+ }, C = (e, t = {}) => {
345
+ const n = $();
346
+ return n[e] || (n[e] = (s = t.detail) => It(n.current, {
347
347
  type: e,
348
348
  ...t,
349
- detail: n
350
- })), s[e];
351
- }, nt = F("atomico/options");
352
- globalThis[nt] = globalThis[nt] || {
349
+ detail: s
350
+ })), n[e];
351
+ }, Q = O("atomico/options");
352
+ globalThis[Q] = globalThis[Q] || {
353
353
  sheet: !!document.adoptedStyleSheets
354
354
  };
355
- const Yt = globalThis[nt], ve = {
355
+ const _t = globalThis[Q], Ee = {
356
356
  checked: 1,
357
357
  value: 1,
358
358
  selected: 1
359
- }, Te = {
359
+ }, De = {
360
360
  list: 1,
361
361
  type: 1,
362
362
  size: 1,
@@ -366,24 +366,24 @@ const Yt = globalThis[nt], ve = {
366
366
  src: 1,
367
367
  href: 1,
368
368
  slot: 1
369
- }, Ce = {
369
+ }, Se = {
370
370
  shadowDom: 1,
371
371
  staticNode: 1,
372
372
  cloneNode: 1,
373
373
  children: 1,
374
374
  key: 1
375
- }, _ = {}, st = [];
376
- class ot extends Text {
375
+ }, L = {}, V = [];
376
+ class tt extends Text {
377
377
  }
378
- const Ne = F("atomico/id"), R = F("atomico/type"), X = F("atomico/ref"), $t = F("atomico/vnode"), Pe = () => {
378
+ const we = O("atomico/id"), M = O("atomico/type"), H = O("atomico/ref"), jt = O("atomico/vnode"), ve = () => {
379
379
  };
380
- function Oe(e, t, s) {
381
- return qt(this, e, t, s);
380
+ function Te(e, t, n) {
381
+ return xt(this, e, t, n);
382
382
  }
383
- const jt = (e, t, ...s) => {
384
- const n = t || _;
385
- let { children: o } = n;
386
- if (o = o ?? (s.length ? s : st), e === Pe)
383
+ const Yt = (e, t, ...n) => {
384
+ const s = t || L;
385
+ let { children: o } = s;
386
+ if (o = o ?? (n.length ? n : V), e === ve)
387
387
  return o;
388
388
  const r = e ? e instanceof Node ? 1 : (
389
389
  //@ts-ignore
@@ -391,170 +391,170 @@ const jt = (e, t, ...s) => {
391
391
  ) : 0;
392
392
  if (r === !1 && e instanceof Function)
393
393
  return e(
394
- o != st ? { children: o, ...n } : n
394
+ o != V ? { children: o, ...s } : s
395
395
  );
396
- const i = Yt.render || Oe;
396
+ const c = _t.render || Te;
397
397
  return {
398
- [R]: $t,
398
+ [M]: jt,
399
399
  type: e,
400
- props: n,
400
+ props: s,
401
401
  children: o,
402
- key: n.key,
402
+ key: s.key,
403
403
  // key for lists by keys
404
404
  // define if the node declares its shadowDom
405
- shadow: n.shadowDom,
405
+ shadow: s.shadowDom,
406
406
  // allows renderings to run only once
407
- static: n.staticNode,
407
+ static: s.staticNode,
408
408
  // defines whether the type is a childNode `1` or a constructor `2`
409
409
  raw: r,
410
410
  // defines whether to use the second parameter for document.createElement
411
- is: n.is,
411
+ is: s.is,
412
412
  // clone the node if it comes from a reference
413
- clone: n.cloneNode,
414
- render: i
413
+ clone: s.cloneNode,
414
+ render: c
415
415
  };
416
416
  };
417
- function qt(e, t, s = Ne, n, o) {
417
+ function xt(e, t, n = we, s, o) {
418
418
  let r;
419
- if (t && t[s] && t[s].vnode == e || e[R] != $t)
419
+ if (t && t[n] && t[n].vnode == e || e[M] != jt)
420
420
  return t;
421
- (e || !t) && (o = o || e.type == "svg", r = e.type != "host" && (e.raw == 1 ? (t && e.clone ? t[X] : t) != e.type : e.raw == 2 ? !(t instanceof e.type) : t ? t[X] || t.localName != e.type : !t), r && e.type != null && (e.raw == 1 && e.clone ? (n = !0, t = e.type.cloneNode(!0), t[X] = e.type) : t = e.raw == 1 ? e.type : e.raw == 2 ? new e.type() : o ? document.createElementNS(
421
+ (e || !t) && (o = o || e.type == "svg", r = e.type != "host" && (e.raw == 1 ? (t && e.clone ? t[H] : t) != e.type : e.raw == 2 ? !(t instanceof e.type) : t ? t[H] || t.localName != e.type : !t), r && e.type != null && (e.raw == 1 && e.clone ? (s = !0, t = e.type.cloneNode(!0), t[H] = e.type) : t = e.raw == 1 ? e.type : e.raw == 2 ? new e.type() : o ? document.createElementNS(
422
422
  "http://www.w3.org/2000/svg",
423
423
  e.type
424
424
  ) : document.createElement(
425
425
  e.type,
426
426
  e.is ? { is: e.is } : void 0
427
427
  )));
428
- const i = t[s] ? t[s] : _, { vnode: f = _, cycle: u = 0 } = i;
429
- let { fragment: l, handlers: c } = i;
430
- const { children: h = st, props: a = _ } = f;
431
- if (c = r ? {} : c || {}, e.static && !r)
428
+ const c = t[n] ? t[n] : L, { vnode: f = L, cycle: a = 0 } = c;
429
+ let { fragment: i, handlers: u } = c;
430
+ const { children: d = V, props: l = L } = f;
431
+ if (u = r ? {} : u || {}, e.static && !r)
432
432
  return t;
433
433
  if (e.shadow && !t.shadowRoot && // @ts-ignore
434
- t.attachShadow({ mode: "open", ...e.shadow }), e.props != a && ke(t, a, e.props, c, o), e.children !== h) {
435
- const d = e.shadow ? t.shadowRoot : t;
436
- l = Me(
434
+ t.attachShadow({ mode: "open", ...e.shadow }), e.props != l && Ne(t, l, e.props, u, o), e.children !== d) {
435
+ const m = e.shadow ? t.shadowRoot : t;
436
+ i = Pe(
437
437
  e.children,
438
438
  /**
439
439
  * @todo for hydration use attribute and send childNodes
440
440
  */
441
- l,
442
- d,
443
- s,
441
+ i,
442
+ m,
443
+ n,
444
444
  // add support to foreignObject, children will escape from svg
445
- !u && n,
445
+ !a && s,
446
446
  o && e.type == "foreignObject" ? !1 : o
447
447
  );
448
448
  }
449
- return t[s] = { vnode: e, handlers: c, fragment: l, cycle: u + 1 }, t;
449
+ return t[n] = { vnode: e, handlers: u, fragment: i, cycle: a + 1 }, t;
450
450
  }
451
- function Fe(e, t) {
452
- const s = new ot(""), n = new ot("");
451
+ function Ce(e, t) {
452
+ const n = new tt(""), s = new tt("");
453
453
  let o;
454
- if (e[t ? "prepend" : "append"](s), t) {
454
+ if (e[t ? "prepend" : "append"](n), t) {
455
455
  let { lastElementChild: r } = e;
456
456
  for (; r; ) {
457
- const { previousElementSibling: i } = r;
458
- if (et(r, !0) && !et(i, !0)) {
457
+ const { previousElementSibling: c } = r;
458
+ if (G(r, !0) && !G(c, !0)) {
459
459
  o = r;
460
460
  break;
461
461
  }
462
- r = i;
462
+ r = c;
463
463
  }
464
464
  }
465
- return o ? o.before(n) : e.append(n), {
466
- markStart: s,
467
- markEnd: n
465
+ return o ? o.before(s) : e.append(s), {
466
+ markStart: n,
467
+ markEnd: s
468
468
  };
469
469
  }
470
- function Me(e, t, s, n, o, r) {
471
- e = e == null ? null : ue(e) ? e : [e];
472
- const i = t || Fe(s, o), { markStart: f, markEnd: u, keyes: l } = i;
473
- let c;
474
- const h = l && /* @__PURE__ */ new Set();
475
- let a = f;
476
- if (e && kt(e, (d) => {
477
- if (typeof d == "object" && !d[R])
470
+ function Pe(e, t, n, s, o, r) {
471
+ e = e == null ? null : re(e) ? e : [e];
472
+ const c = t || Ce(n, o), { markStart: f, markEnd: a, keyes: i } = c;
473
+ let u;
474
+ const d = i && /* @__PURE__ */ new Set();
475
+ let l = f;
476
+ if (e && At(e, (m) => {
477
+ if (typeof m == "object" && !m[M])
478
478
  return;
479
- const y = d[R] && d.key, D = l && y != null && l.get(y);
480
- a != u && a === D ? h.delete(a) : a = a == u ? u : a.nextSibling;
481
- const m = l ? D : a;
482
- let w = m;
483
- if (d[R])
484
- w = qt(d, m, n, o, r);
479
+ const p = m[M] && m.key, y = i && p != null && i.get(p);
480
+ l != a && l === y ? d.delete(l) : l = l == a ? a : l.nextSibling;
481
+ const E = i ? y : l;
482
+ let h = E;
483
+ if (m[M])
484
+ h = xt(m, E, s, o, r);
485
485
  else {
486
- const M = d + "";
487
- !(w instanceof Text) || w instanceof ot ? w = new Text(M) : w.data != M && (w.data = M);
486
+ const v = m + "";
487
+ !(h instanceof Text) || h instanceof tt ? h = new Text(v) : h.data != v && (h.data = v);
488
488
  }
489
- w != a && (l && h.delete(w), !m || l ? (s.insertBefore(w, a), l && a != u && h.add(a)) : m == u ? s.insertBefore(w, u) : (s.replaceChild(w, m), a = w)), y != null && (c = c || /* @__PURE__ */ new Map(), c.set(y, w));
490
- }), a = a == u ? u : a.nextSibling, t && a != u)
491
- for (; a != u; ) {
492
- const d = a;
493
- a = a.nextSibling, d.remove();
489
+ h != l && (i && d.delete(h), !E || i ? (n.insertBefore(h, l), i && l != a && d.add(l)) : E == a ? n.insertBefore(h, a) : (n.replaceChild(h, E), l = h)), p != null && (u = u || /* @__PURE__ */ new Map(), u.set(p, h));
490
+ }), l = l == a ? a : l.nextSibling, t && l != a)
491
+ for (; l != a; ) {
492
+ const m = l;
493
+ l = l.nextSibling, m.remove();
494
494
  }
495
- return h && h.forEach((d) => d.remove()), i.keyes = c, i;
495
+ return d && d.forEach((m) => m.remove()), c.keyes = u, c;
496
496
  }
497
- function ke(e, t, s, n, o) {
497
+ function Ne(e, t, n, s, o) {
498
498
  for (const r in t)
499
- !(r in s) && bt(e, r, t[r], null, o, n);
500
- for (const r in s)
501
- bt(e, r, t[r], s[r], o, n);
499
+ !(r in n) && yt(e, r, t[r], null, o, s);
500
+ for (const r in n)
501
+ yt(e, r, t[r], n[r], o, s);
502
502
  }
503
- function bt(e, t, s, n, o, r) {
504
- if (t = t == "class" && !o ? "className" : t, s = s ?? null, n = n ?? null, t in e && ve[t] && (s = e[t]), !(n === s || Ce[t] || t[0] == "_"))
505
- if (t[0] == "o" && t[1] == "n" && (S(n) || S(s)))
506
- Ae(e, t.slice(2), n, r);
503
+ function yt(e, t, n, s, o, r) {
504
+ if (t = t == "class" && !o ? "className" : t, n = n ?? null, s = s ?? null, t in e && Ee[t] && (n = e[t]), !(s === n || Se[t] || t[0] == "_"))
505
+ if (t[0] == "o" && t[1] == "n" && (T(s) || T(n)))
506
+ ke(e, t.slice(2), s, r);
507
507
  else if (t == "ref")
508
- n && (S(n) ? n(e) : n.current = e);
508
+ s && (T(s) ? s(e) : s.current = e);
509
509
  else if (t == "style") {
510
- const { style: i } = e;
511
- s = s || "", n = n || "";
512
- const f = A(s), u = A(n);
510
+ const { style: c } = e;
511
+ n = n || "", s = s || "";
512
+ const f = R(n), a = R(s);
513
513
  if (f)
514
- for (const l in s)
515
- if (u)
516
- !(l in n) && pt(i, l, null);
514
+ for (const i in n)
515
+ if (a)
516
+ !(i in s) && pt(c, i, null);
517
517
  else
518
518
  break;
519
- if (u)
520
- for (const l in n) {
521
- const c = n[l];
522
- f && s[l] === c || pt(i, l, c);
519
+ if (a)
520
+ for (const i in s) {
521
+ const u = s[i];
522
+ f && n[i] === u || pt(c, i, u);
523
523
  }
524
524
  else
525
- i.cssText = n;
525
+ c.cssText = s;
526
526
  } else {
527
- const i = t[0] == "$" ? t.slice(1) : t;
528
- i === t && (!o && !Te[t] && t in e || S(n) || S(s)) ? e[t] = n ?? "" : n == null ? e.removeAttribute(i) : e.setAttribute(
529
- i,
530
- A(n) ? JSON.stringify(n) : n
527
+ const c = t[0] == "$" ? t.slice(1) : t;
528
+ c === t && (!o && !De[t] && t in e || T(s) || T(n)) ? e[t] = s ?? "" : s == null ? e.removeAttribute(c) : e.setAttribute(
529
+ c,
530
+ R(s) ? JSON.stringify(s) : s
531
531
  );
532
532
  }
533
533
  }
534
- function Ae(e, t, s, n) {
535
- if (n.handleEvent || (n.handleEvent = (o) => n[o.type].call(e, o)), s) {
536
- if (!n[t]) {
537
- const o = s.capture || s.once || s.passive ? Object.assign({}, s) : null;
538
- e.addEventListener(t, n, o);
534
+ function ke(e, t, n, s) {
535
+ if (s.handleEvent || (s.handleEvent = (o) => s[o.type].call(e, o)), n) {
536
+ if (!s[t]) {
537
+ const o = n.capture || n.once || n.passive ? Object.assign({}, n) : null;
538
+ e.addEventListener(t, s, o);
539
539
  }
540
- n[t] = s;
540
+ s[t] = n;
541
541
  } else
542
- n[t] && (e.removeEventListener(t, n), delete n[t]);
542
+ s[t] && (e.removeEventListener(t, s), delete s[t]);
543
543
  }
544
- function pt(e, t, s) {
545
- let n = "setProperty";
546
- s == null && (n = "removeProperty", s = null), ~t.indexOf("-") ? e[n](t, s) : e[t] = s;
544
+ function pt(e, t, n) {
545
+ let s = "setProperty";
546
+ n == null && (s = "removeProperty", n = null), ~t.indexOf("-") ? e[s](t, n) : e[t] = n;
547
547
  }
548
- const gt = {};
549
- function q(e, ...t) {
550
- const s = (e.raw || e).reduce(
551
- (n, o, r) => n + o + (t[r] || ""),
548
+ const bt = {};
549
+ function Y(e, ...t) {
550
+ const n = (e.raw || e).reduce(
551
+ (s, o, r) => s + o + (t[r] || ""),
552
552
  ""
553
553
  );
554
- return gt[s] = gt[s] || Re(s);
554
+ return bt[n] = bt[n] || Oe(n);
555
555
  }
556
- function Re(e) {
557
- if (Yt.sheet) {
556
+ function Oe(e) {
557
+ if (_t.sheet) {
558
558
  const t = new CSSStyleSheet();
559
559
  return t.replaceSync(e), t;
560
560
  } else {
@@ -562,52 +562,52 @@ function Re(e) {
562
562
  return t.textContent = e, t;
563
563
  }
564
564
  }
565
- const Ie = jt("host", { style: "display: contents" }), G = F("atomico/context"), Ue = (e, t) => {
566
- const s = U();
567
- Se(
568
- () => At(
569
- s.current,
565
+ const Ae = Yt("host", { style: "display: contents" }), K = O("atomico/context"), Re = (e, t) => {
566
+ const n = $();
567
+ ge(
568
+ () => Rt(
569
+ n.current,
570
570
  "ConnectContext",
571
571
  /**
572
572
  * @param {CustomEvent<import("context").DetailConnectContext>} event
573
573
  */
574
- (n) => {
575
- e === n.detail.id && (n.stopPropagation(), n.detail.connect(t));
574
+ (s) => {
575
+ e === s.detail.id && (s.stopPropagation(), s.detail.connect(t));
576
576
  }
577
577
  ),
578
578
  [e]
579
579
  );
580
- }, xe = (e) => {
581
- const t = v("ConnectContext", {
580
+ }, Me = (e) => {
581
+ const t = C("ConnectContext", {
582
582
  bubbles: !0,
583
583
  composed: !0
584
- }), s = () => {
584
+ }), n = () => {
585
585
  let r;
586
586
  return t({
587
587
  id: e,
588
- connect(i) {
589
- r = i;
588
+ connect(c) {
589
+ r = c;
590
590
  }
591
591
  }), r;
592
- }, [n, o] = ct(
593
- s
592
+ }, [s, o] = st(
593
+ n
594
594
  );
595
- return j(() => {
596
- n || (e[G] || (e[G] = customElements.whenDefined(
595
+ return nt(() => {
596
+ s || (e[K] || (e[K] = customElements.whenDefined(
597
597
  new e().localName
598
- )), e[G].then(
599
- () => o(s)
598
+ )), e[K].then(
599
+ () => o(n)
600
600
  ));
601
- }, [e]), n;
602
- }, _e = (e) => {
603
- const t = xe(e), s = Ft();
604
- return j(() => {
601
+ }, [e]), s;
602
+ }, Fe = (e) => {
603
+ const t = Me(e), n = kt();
604
+ return nt(() => {
605
605
  if (t)
606
- return At(t, "UpdatedValue", s);
606
+ return Rt(t, "UpdatedValue", n);
607
607
  }, [t]), (t || e).value;
608
- }, Le = (e) => {
609
- const t = $(
610
- () => (Ue(t, U().current), Ie),
608
+ }, Ie = (e) => {
609
+ const t = j(
610
+ () => (Re(t, $().current), Ae),
611
611
  {
612
612
  props: {
613
613
  value: {
@@ -619,345 +619,254 @@ const Ie = jt("host", { style: "display: contents" }), G = F("atomico/context"),
619
619
  }
620
620
  );
621
621
  return t.value = e, t;
622
- }, b = (e, t, s) => (t == null ? t = { key: s } : t.key = s, jt(e, t)), I = b, zt = q`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation}`, Bt = q`.vh{position:absolute;transform:scale(0)}`;
623
- function z() {
624
- const e = new Date(Date.now());
625
- return new g(e.getUTCFullYear(), e.getUTCMonth() + 1, e.getUTCDate());
626
- }
627
- function B(e, t = 0) {
628
- const s = e.toDate(), n = s.getUTCDay(), o = (n < t ? 7 : 0) + n - t;
629
- return s.setUTCDate(s.getUTCDate() - o), g.from(s);
630
- }
631
- function Ht(e, t = 0) {
632
- return B(e, t).add({ days: 6 });
633
- }
634
- function ut(e) {
635
- return g.from(new Date(Date.UTC(e.year, e.month, 0)));
636
- }
637
- function Wt(e, t) {
638
- const s = e.toDate(), n = t.toDate();
639
- return s < n ? -1 : s > n ? 1 : 0;
640
- }
641
- function H(e, t, s) {
642
- return t && g.compare(e, t) < 0 ? t : s && g.compare(e, s) > 0 ? s : e;
643
- }
644
- function rt(e, t, s) {
645
- return H(e, t, s) === e;
646
- }
647
- function Ye(e, t) {
648
- const s = { days: 1 }, n = [e];
649
- for (; !e.equals(t); )
650
- e = e.add(s), n.push(e);
651
- return n;
652
- }
653
- function $e(e, t) {
654
- const s = [];
655
- for (let n = 0; n < e.length; n += t)
656
- s.push(e.slice(n, n + t));
657
- return s;
622
+ }, b = (e, t, n) => (t == null ? t = { key: n } : t.key = n, Yt(e, t)), F = b, Bt = Y`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation;cursor:pointer;user-select:none}`, zt = Y`.vh{position:absolute;transform:scale(0)}`;
623
+ function ot() {
624
+ return D.from(/* @__PURE__ */ new Date());
658
625
  }
659
- function je(e, t = 0) {
660
- const s = B(e.toPlainDate(), t), n = Ht(ut(e), t);
661
- return $e(Ye(s, n), 7);
662
- }
663
- function qe(e, t, s) {
664
- const n = [], o = { weekday: e }, r = B(z(), t).toDate(), i = new Intl.DateTimeFormat(s, o);
665
- for (let f = 0; f < 7; f++)
666
- n[f] = i.format(r), r.setDate(r.getDate() + 1);
667
- return n;
626
+ function rt(e, t = 0) {
627
+ const n = w(e), s = n.getUTCDay(), o = (s < t ? 7 : 0) + s - t;
628
+ return n.setUTCDate(n.getUTCDate() - o), D.from(n);
668
629
  }
669
- const ze = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/, Kt = "years", Jt = "months", Zt = "days";
670
- function Be(e) {
671
- if (Kt in e)
672
- return { years: -e.years };
673
- if (Jt in e)
674
- return { months: -e.months };
675
- if (Zt in e)
676
- return { days: -e.days };
677
- throw new TypeError();
630
+ function qt(e, t = 0) {
631
+ return rt(e, t).add({ days: 6 });
678
632
  }
679
- function He(e, t) {
680
- return g.from(new Date(Date.UTC(e.year, e.month - 1, t)));
633
+ function Ht(e) {
634
+ return D.from(new Date(Date.UTC(e.year, e.month, 0)));
681
635
  }
682
- function We(e, t) {
683
- const s = new g(t, e.month, 1), n = ut(s), o = e.toDate();
684
- return o.setUTCFullYear(t), H(g.from(o), s, n);
636
+ function x(e, t, n) {
637
+ return t && D.compare(e, t) < 0 ? t : n && D.compare(e, n) > 0 ? n : e;
685
638
  }
686
- function Ke(e, t) {
687
- const s = new g(e.year, t, 1), n = ut(s), o = e.toDate();
688
- return o.setUTCMonth(t - 1), H(g.from(o), s, n);
639
+ const Ue = { days: 1 };
640
+ function $e(e, t = 0) {
641
+ let n = rt(e.toPlainDate(), t);
642
+ const s = qt(Ht(e), t), o = [];
643
+ for (; D.compare(n, s) < 0; ) {
644
+ const r = [];
645
+ for (let c = 0; c < 7; c++)
646
+ r.push(n), n = n.add(Ue);
647
+ o.push(r);
648
+ }
649
+ return o;
689
650
  }
690
- function Dt(e, t) {
691
- return Zt in t ? He(e, e.day + t.days) : Jt in t ? Ke(e, e.month + t.months) : Kt in t ? We(e, e.year + t.years) : e;
651
+ function w(e) {
652
+ return new Date(Date.UTC(e.year, e.month - 1, e.day ?? 1));
692
653
  }
693
- const Q = (e, t) => e.toString().padStart(t, "0");
694
- class g {
695
- constructor(t, s, n) {
696
- this.year = t, this.month = s, this.day = n;
654
+ const Le = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/, J = (e, t) => e.toString().padStart(t, "0");
655
+ class D {
656
+ constructor(t, n, s) {
657
+ this.year = t, this.month = n, this.day = s;
697
658
  }
659
+ // this is an incomplete implementation that only handles arithmetic on a single unit at a time.
660
+ // i didn't want to get into more complex arithmetic since it get tricky fast
661
+ // this is enough to serve my needs and will still be a drop-in replacement when actual Temporal API lands
698
662
  add(t) {
699
- return Dt(this, t);
700
- }
701
- subtract(t) {
702
- return Dt(this, Be(t));
663
+ const n = w(this);
664
+ if ("days" in t)
665
+ return n.setUTCDate(this.day + t.days), D.from(n);
666
+ let { year: s, month: o } = this;
667
+ "months" in t ? (o = this.month + t.months, n.setUTCMonth(o - 1)) : (s = this.year + t.years, n.setUTCFullYear(s));
668
+ const r = D.from(w({ year: s, month: o, day: 1 }));
669
+ return x(D.from(n), r, Ht(r));
703
670
  }
704
671
  toString() {
705
- return `${Q(this.year, 4)}-${Q(this.month, 2)}-${Q(this.day, 2)}`;
706
- }
707
- toDate() {
708
- return new Date(Date.UTC(this.year, this.month - 1, this.day, 0, 0, 0));
672
+ return `${J(this.year, 4)}-${J(this.month, 2)}-${J(this.day, 2)}`;
709
673
  }
710
674
  toPlainYearMonth() {
711
- return new C(this.year, this.month);
675
+ return new B(this.year, this.month);
712
676
  }
713
677
  equals(t) {
714
- return this.year === t.year && this.month === t.month && this.day === t.day;
678
+ return D.compare(this, t) === 0;
715
679
  }
716
- static compare(t, s) {
717
- return Wt(t, s);
680
+ static compare(t, n) {
681
+ return t.year < n.year ? -1 : t.year > n.year ? 1 : t.month < n.month ? -1 : t.month > n.month ? 1 : t.day < n.day ? -1 : t.day > n.day ? 1 : 0;
718
682
  }
719
683
  static from(t) {
720
- return typeof t == "string" ? this.fromString(t) : this.fromDate(t);
721
- }
722
- static fromString(t) {
723
- const s = t.match(ze);
724
- if (!s)
725
- throw new TypeError(t);
726
- const [, n, o, r] = s;
727
- return new g(
728
- parseInt(n, 10),
729
- parseInt(o, 10),
730
- parseInt(r, 10)
731
- );
732
- }
733
- static fromDate(t) {
734
- return new g(
684
+ if (typeof t == "string") {
685
+ const n = t.match(Le);
686
+ if (!n)
687
+ throw new TypeError(t);
688
+ const [, s, o, r] = n;
689
+ return new D(
690
+ parseInt(s, 10),
691
+ parseInt(o, 10),
692
+ parseInt(r, 10)
693
+ );
694
+ }
695
+ return new D(
735
696
  t.getUTCFullYear(),
736
697
  t.getUTCMonth() + 1,
737
698
  t.getUTCDate()
738
699
  );
739
700
  }
740
701
  }
741
- function wt(e) {
742
- return (e.months ?? 0) + (e.years ?? 0) * 12;
743
- }
744
- function Et(e, t) {
745
- const s = e.toDate();
746
- return s.setUTCMonth(s.getUTCMonth() + t), new C(s.getUTCFullYear(), s.getUTCMonth() + 1);
747
- }
748
- class C {
749
- constructor(t, s) {
750
- this.year = t, this.month = s;
702
+ class B {
703
+ constructor(t, n) {
704
+ this.year = t, this.month = n;
751
705
  }
752
706
  add(t) {
753
- return Et(this, wt(t));
754
- }
755
- subtract(t) {
756
- return Et(this, -wt(t));
757
- }
758
- toDate() {
759
- return new Date(Date.UTC(this.year, this.month - 1, 1));
707
+ const n = w(this), s = (t.months ?? 0) + (t.years ?? 0) * 12;
708
+ return n.setUTCMonth(n.getUTCMonth() + s), new B(n.getUTCFullYear(), n.getUTCMonth() + 1);
760
709
  }
761
710
  equals(t) {
762
711
  return this.year === t.year && this.month === t.month;
763
712
  }
764
713
  toPlainDate() {
765
- return new g(this.year, this.month, 1);
766
- }
767
- static compare(t, s) {
768
- const n = t instanceof g ? t.toPlainYearMonth() : t, o = s instanceof g ? s.toPlainYearMonth() : s;
769
- return Wt(n, o);
714
+ return new D(this.year, this.month, 1);
770
715
  }
771
716
  }
772
- function it(e, t) {
717
+ function et(e, t) {
773
718
  if (t)
774
719
  try {
775
720
  return e.from(t);
776
721
  } catch {
777
722
  }
778
723
  }
779
- function at(e) {
780
- const [t, s] = Lt(e);
781
- return [P(() => it(g, t), [t]), (r) => s(r.toString())];
724
+ function I(e) {
725
+ const [t, n] = Lt(e);
726
+ return [P(() => et(D, t), [t]), (r) => n(r.toString())];
782
727
  }
783
- function Je(e) {
728
+ function _e(e) {
784
729
  if (e) {
785
- const [t, s] = e.split("/"), n = it(g, t), o = it(g, s);
786
- if (n && o)
787
- return [n, o];
730
+ const [t, n] = e.split("/"), s = et(D, t), o = et(D, n);
731
+ if (s && o)
732
+ return [s, o];
788
733
  }
789
734
  return [];
790
735
  }
791
- function Ze(e, t) {
792
- return `${e}/${t}`;
793
- }
794
- function Xe(e) {
795
- const [t, s] = Lt(e);
796
- return [P(() => Je(t), [t]), (r) => s(Ze(r[0], r[1]))];
736
+ function je(e) {
737
+ const [t, n] = Lt(e);
738
+ return [P(() => _e(t), [t]), (r) => n(`${r[0]}/${r[1]}`)];
797
739
  }
798
- function Y(e, t) {
740
+ function U(e, t) {
799
741
  return P(
800
742
  () => new Intl.DateTimeFormat(t, { timeZone: "UTC", ...e }),
801
743
  [t, e]
802
744
  );
803
745
  }
804
- function St(e, t, s) {
805
- return P(
806
- () => qe(e, t, s),
807
- [e, t, s]
808
- );
809
- }
810
- function Ge(e) {
811
- let t = "";
812
- for (const s in e)
813
- e[s] && (t += ` ${s}`);
814
- return t;
746
+ function gt(e, t, n) {
747
+ const s = U(e, n);
748
+ return P(() => {
749
+ const o = [], r = /* @__PURE__ */ new Date();
750
+ for (var c = 0; c < 7; c++) {
751
+ const f = (r.getDay() - t + 7) % 7;
752
+ o[f] = s.format(r), r.setDate(r.getDate() + 1);
753
+ }
754
+ return o;
755
+ }, [t, s]);
815
756
  }
816
- const vt = (e) => e.target.matches(":dir(ltr)"), Qe = { month: "long", day: "numeric" }, Ve = { month: "long" }, V = { bubbles: !0 };
817
- function tn({ props: e, context: t }) {
818
- const { offset: s } = e, { firstDayOfWeek: n, isDateDisallowed: o, min: r, max: i, dateWindow: f, locale: u } = t, l = z(), c = St("long", n, u), h = St("narrow", n, u), a = Y(Qe, u), d = Y(Ve, u), { focusedDate: y } = f, D = P(
819
- () => f.start.add({ months: s }),
820
- [f, s]
821
- ), m = P(
822
- () => je(D, n),
823
- [D, n]
824
- ), w = v("focusday", V), M = v("selectday", V), te = v("hoverday", V);
825
- function ft(p) {
826
- w(H(p, r, i));
757
+ const Et = (e, t, n) => x(e, t, n) === e, Dt = (e) => e.target.matches(":dir(ltr)"), Ye = { month: "long", day: "numeric" }, xe = { month: "long" }, Be = { weekday: "narrow" }, ze = { weekday: "long" }, Z = { bubbles: !0 };
758
+ function qe({ props: e, context: t }) {
759
+ const { offset: n } = e, {
760
+ firstDayOfWeek: s,
761
+ isDateDisallowed: o,
762
+ min: r,
763
+ max: c,
764
+ page: f,
765
+ locale: a,
766
+ focusedDate: i
767
+ } = t, u = ot(), d = gt(ze, s, a), l = gt(Be, s, a), m = U(Ye, a), p = U(xe, a), y = P(
768
+ () => f.start.add({ months: n }),
769
+ [f, n]
770
+ ), E = P(
771
+ () => $e(y, s),
772
+ [y, s]
773
+ ), h = C("focusday", Z), v = C("selectday", Z), z = C("hoverday", Z);
774
+ function it(g) {
775
+ h(x(g, r, c));
827
776
  }
828
- function ee(p) {
829
- let E;
830
- switch (p.key) {
777
+ function Xt(g) {
778
+ let S;
779
+ switch (g.key) {
831
780
  case "ArrowRight":
832
- E = y.add({ days: vt(p) ? 1 : -1 });
781
+ S = i.add({ days: Dt(g) ? 1 : -1 });
833
782
  break;
834
783
  case "ArrowLeft":
835
- E = y.add({ days: vt(p) ? -1 : 1 });
784
+ S = i.add({ days: Dt(g) ? -1 : 1 });
836
785
  break;
837
786
  case "ArrowDown":
838
- E = y.add({ days: 7 });
787
+ S = i.add({ days: 7 });
839
788
  break;
840
789
  case "ArrowUp":
841
- E = y.add({ days: -7 });
790
+ S = i.add({ days: -7 });
842
791
  break;
843
792
  case "PageUp":
844
- E = y.add(p.shiftKey ? { years: -1 } : { months: -1 });
793
+ S = i.add(g.shiftKey ? { years: -1 } : { months: -1 });
845
794
  break;
846
795
  case "PageDown":
847
- E = y.add(p.shiftKey ? { years: 1 } : { months: 1 });
796
+ S = i.add(g.shiftKey ? { years: 1 } : { months: 1 });
848
797
  break;
849
798
  case "Home":
850
- E = B(y, n);
799
+ S = rt(i, s);
851
800
  break;
852
801
  case "End":
853
- E = Ht(y, n);
802
+ S = qt(i, s);
854
803
  break;
855
804
  default:
856
805
  return;
857
806
  }
858
- ft(E), p.preventDefault();
807
+ it(S), g.preventDefault();
859
808
  }
860
- function ne(p) {
861
- const E = D.equals(p), se = p.equals(y), dt = p.equals(l), ht = p.toDate(), x = o?.(ht), mt = !rt(p, r, i);
862
- let k = !1, yt = !1, W = !1, K = !1;
809
+ function Gt(g) {
810
+ const S = y.equals(g);
811
+ if (!S && !t.showOutsideDays)
812
+ return;
813
+ const Qt = g.equals(i), Vt = g.equals(u), at = w(g), q = o?.(at), lt = !Et(g, r, c);
814
+ let ut = "", A;
863
815
  if ("highlightedRange" in t) {
864
- const [J, Z] = t.highlightedRange;
865
- yt = !0, W = J?.equals(p) ?? !1, K = Z?.equals(p) ?? !1, k = J && Z ? rt(p, J, Z) : !1;
816
+ const [ft, dt] = t.highlightedRange, ht = ft?.equals(g), mt = dt?.equals(g);
817
+ A = Et(g, ft, dt), ut = `${ht ? "range-start" : ""} ${mt ? "range-end" : ""} ${A && !ht && !mt ? "range-inner" : ""}`;
866
818
  } else
867
- "value" in t && (k = t.value?.equals(p) ?? !1);
819
+ A = t.value?.equals(g);
868
820
  return {
869
- part: Ge({
870
- button: !0,
871
- day: !0,
872
- selected: E && k,
873
- today: dt,
874
- disallowed: x,
875
- outside: !E,
876
- "range-start": W,
877
- "range-end": K,
878
- "range-inner": yt && k && !W && !K
879
- }),
880
- tabindex: E && se ? 0 : -1,
881
- disabled: mt,
882
- "aria-disabled": x ? "true" : void 0,
883
- "aria-pressed": E && k,
884
- "aria-current": dt ? "date" : void 0,
885
- "aria-label": a.format(ht),
886
- onkeydown: ee,
821
+ part: `button day ${S && A ? "selected" : ""} ${ut}`,
822
+ tabindex: S && Qt ? 0 : -1,
823
+ disabled: lt,
824
+ "aria-disabled": q ? "true" : void 0,
825
+ "aria-pressed": S && A,
826
+ "aria-current": Vt ? "date" : void 0,
827
+ "aria-label": m.format(at),
828
+ onkeydown: Xt,
887
829
  onclick() {
888
- x || M(p), ft(p);
830
+ q || v(g), it(g);
889
831
  },
890
832
  onmouseover() {
891
- !x && !mt && te(p);
833
+ !q && !lt && z(g);
892
834
  }
893
835
  };
894
836
  }
895
837
  return {
896
- weeks: m,
897
- yearMonth: D,
898
- dayNamesLong: c,
899
- dayNamesShort: h,
900
- monthFormatter: d,
901
- getDayProps: ne
838
+ weeks: E,
839
+ yearMonth: y,
840
+ daysLong: d,
841
+ daysShort: l,
842
+ formatter: p,
843
+ getDayProps: Gt
902
844
  };
903
845
  }
904
- class T {
905
- constructor(t, s, n) {
906
- this.start = t, this.duration = s, this.focusedDate = n, this.end = t.add({ months: s.months - 1 });
907
- }
908
- end;
909
- contains(t) {
910
- return C.compare(t, this.start) >= 0 && C.compare(t, this.end) <= 0;
911
- }
912
- adjust(t) {
913
- const { start: s, duration: n } = this, o = C.compare(s, t) > 0;
914
- let r = new T(s, n, t);
915
- for (; !r.contains(t); )
916
- r = new T(
917
- o ? r.start.subtract(n) : r.start.add(n),
918
- n,
919
- t
920
- );
921
- return r;
922
- }
923
- next() {
924
- return new T(
925
- this.start.add(this.duration),
926
- this.duration,
927
- this.focusedDate.add(this.duration)
928
- );
929
- }
930
- prev() {
931
- return new T(
932
- this.start.subtract(this.duration),
933
- this.duration,
934
- this.focusedDate.subtract(this.duration)
935
- );
936
- }
937
- }
938
- const Tt = z(), lt = Le({
939
- firstDayOfWeek: 0,
846
+ const W = ot(), ct = Ie({
847
+ firstDayOfWeek: 1,
940
848
  isDateDisallowed: () => !1,
941
- dateWindow: new T(Tt.toPlainYearMonth(), { months: 1 }, Tt)
849
+ focusedDate: W,
850
+ page: { start: W.toPlainYearMonth(), end: W.toPlainYearMonth() }
942
851
  });
943
- customElements.define("calendar-month-ctx", lt);
944
- const en = $(
852
+ customElements.define("calendar-month-ctx", ct);
853
+ const He = j(
945
854
  (e) => {
946
- const t = _e(lt), s = ae(), n = tn({ props: e, context: t });
855
+ const t = Fe(ct), n = se(), s = qe({ props: e, context: t });
947
856
  function o() {
948
- s.current.querySelector("button[tabindex='0']")?.focus();
857
+ n.current.querySelector("button[tabindex='0']")?.focus();
949
858
  }
950
- return /* @__PURE__ */ I("host", { shadowDom: !0, focus: o, children: [
951
- /* @__PURE__ */ b("div", { id: "heading", part: "heading", children: n.monthFormatter.format(n.yearMonth.toDate()) }),
952
- /* @__PURE__ */ I("table", { ref: s, "aria-labelledby": "heading", part: "table", children: [
953
- /* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { part: "tr head", children: n.dayNamesLong.map((r, i) => /* @__PURE__ */ I("th", { part: "th", scope: "col", children: [
859
+ return /* @__PURE__ */ F("host", { shadowDom: !0, focus: o, children: [
860
+ /* @__PURE__ */ b("div", { id: "h", part: "heading", children: s.formatter.format(w(s.yearMonth)) }),
861
+ /* @__PURE__ */ F("table", { ref: n, "aria-labelledby": "h", part: "table", children: [
862
+ /* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { part: "tr head", children: s.daysLong.map((r, c) => /* @__PURE__ */ F("th", { part: "th", scope: "col", children: [
954
863
  /* @__PURE__ */ b("span", { class: "vh", children: r }),
955
- /* @__PURE__ */ b("span", { "aria-hidden": "true", children: n.dayNamesShort[i] })
864
+ /* @__PURE__ */ b("span", { "aria-hidden": "true", children: s.daysShort[c] })
956
865
  ] })) }) }),
957
- /* @__PURE__ */ b("tbody", { children: n.weeks.map((r, i) => /* @__PURE__ */ b("tr", { part: "tr week", children: r.map((f, u) => {
958
- const l = n.yearMonth.equals(f), c = t.showOutsideDays || l;
959
- return /* @__PURE__ */ b("td", { part: "td", children: c && /* @__PURE__ */ b("button", { ...n.getDayProps(f), children: f.day }) }, u);
960
- }) }, i)) })
866
+ /* @__PURE__ */ b("tbody", { children: s.weeks.map((r, c) => /* @__PURE__ */ b("tr", { part: "tr week", children: r.map((f, a) => {
867
+ const i = s.getDayProps(f);
868
+ return /* @__PURE__ */ b("td", { part: "td", children: i && /* @__PURE__ */ b("button", { ...i, children: f.day }) }, a);
869
+ }) }, c)) })
961
870
  ] })
962
871
  ] });
963
872
  },
@@ -969,40 +878,35 @@ const en = $(
969
878
  }
970
879
  },
971
880
  styles: [
972
- zt,
973
881
  Bt,
974
- q`:host{--color-accent: black;--color-text-on-accent: white;display:flex;flex-direction:column;gap:.25rem;text-align:center;inline-size:fit-content}table{border-collapse:collapse;border-spacing:0;table-layout:fixed;inline-size:max-content;font-size:.875rem}th{font-weight:700;block-size:2.25rem}td{padding-inline:0;padding-block:1px}button{color:inherit;font-size:inherit;background:transparent;border:0;cursor:pointer;font-variant-numeric:tabular-nums;block-size:2.25rem;inline-size:2.25rem}button:hover:where(:not(:disabled)){background:#0000000d}button:is([aria-pressed=true],:focus-visible){background:var(--color-accent);color:var(--color-text-on-accent)}button:focus-visible{outline:1px solid var(--color-text-on-accent);outline-offset:-2px}button:disabled,:host::part(outside),:host::part(disallowed){cursor:default;opacity:.5}`
882
+ zt,
883
+ Y`:host{--color-accent: black;--color-text-on-accent: white;display:flex;flex-direction:column;gap:.25rem;text-align:center;inline-size:fit-content}table{border-collapse:collapse;font-size:.875rem}th{font-weight:700;block-size:2.25rem}td{padding-inline:0}button{color:inherit;font-size:inherit;background:transparent;border:0;font-variant-numeric:tabular-nums;block-size:2.25rem;inline-size:2.25rem}button:hover:where(:not(:disabled)){background:#0000000d}button:is([aria-pressed=true],:focus-visible){background:var(--color-accent);color:var(--color-text-on-accent)}button:focus-visible{outline:1px solid var(--color-text-on-accent);outline-offset:-2px}button:disabled,:host::part(outside),:host::part(disallowed){cursor:default;opacity:.5}`
975
884
  ]
976
885
  }
977
886
  );
978
- customElements.define("calendar-month", en);
979
- function Xt(e) {
980
- const t = e.dateWindow.start.toDate(), s = e.dateWindow.end.toDate();
981
- return /* @__PURE__ */ I("div", { role: "group", "aria-labelledby": "label", part: "container", children: [
982
- /* @__PURE__ */ b("div", { id: "label", class: "vh", "aria-live": "polite", "aria-atomic": "true", children: e.formatVerbose.formatRange(t, s) }),
983
- /* @__PURE__ */ I("div", { class: "header", part: "header", children: [
984
- /* @__PURE__ */ b(
985
- "button",
986
- {
987
- part: `button previous ${e.previous ? "" : "disabled"}`,
988
- onclick: e.previous,
989
- "aria-disabled": e.previous ? null : "true",
990
- children: /* @__PURE__ */ b("slot", { name: "previous", children: "Previous" })
991
- }
992
- ),
993
- /* @__PURE__ */ b("div", { id: "heading", part: "heading", "aria-hidden": "true", children: e.format.formatRange(t, s) }),
994
- /* @__PURE__ */ b(
995
- "button",
996
- {
997
- part: `button next ${e.next ? "" : "disabled"}`,
998
- onclick: e.next,
999
- "aria-disabled": e.next ? null : "true",
1000
- children: /* @__PURE__ */ b("slot", { name: "next", children: "Next" })
1001
- }
1002
- )
887
+ customElements.define("calendar-month", He);
888
+ function St(e) {
889
+ return /* @__PURE__ */ b(
890
+ "button",
891
+ {
892
+ part: `button ${e.name} ${e.onclick ? "" : "disabled"}`,
893
+ onclick: e.onclick,
894
+ "aria-disabled": e.onclick ? null : "true",
895
+ children: /* @__PURE__ */ b("slot", { name: e.name, children: e.children })
896
+ }
897
+ );
898
+ }
899
+ function Kt(e) {
900
+ const t = w(e.page.start), n = w(e.page.end);
901
+ return /* @__PURE__ */ F("div", { role: "group", "aria-labelledby": "h", part: "container", children: [
902
+ /* @__PURE__ */ b("div", { id: "h", class: "vh", "aria-live": "polite", "aria-atomic": "true", children: e.formatVerbose.formatRange(t, n) }),
903
+ /* @__PURE__ */ F("div", { part: "header", children: [
904
+ /* @__PURE__ */ b(St, { name: "previous", onclick: e.previous, children: "Previous" }),
905
+ /* @__PURE__ */ b("div", { part: "heading", "aria-hidden": "true", children: e.format.formatRange(t, n) }),
906
+ /* @__PURE__ */ b(St, { name: "next", onclick: e.next, children: "Next" })
1003
907
  ] }),
1004
908
  /* @__PURE__ */ b(
1005
- lt,
909
+ ct,
1006
910
  {
1007
911
  value: e,
1008
912
  onselectday: e.onSelect,
@@ -1013,7 +917,7 @@ function Xt(e) {
1013
917
  )
1014
918
  ] });
1015
919
  }
1016
- const Gt = {
920
+ const Jt = {
1017
921
  value: {
1018
922
  type: String,
1019
923
  value: ""
@@ -1036,7 +940,7 @@ const Gt = {
1036
940
  },
1037
941
  showOutsideDays: {
1038
942
  type: Boolean,
1039
- value: () => !1
943
+ value: !1
1040
944
  },
1041
945
  locale: {
1042
946
  type: String,
@@ -1046,101 +950,129 @@ const Gt = {
1046
950
  months: {
1047
951
  type: Number,
1048
952
  value: 1
953
+ },
954
+ focusedDate: {
955
+ type: String,
956
+ value: () => {
957
+ }
1049
958
  }
1050
- }, Qt = [
1051
- zt,
959
+ }, Zt = [
1052
960
  Bt,
1053
- q`:host{display:block;inline-size:fit-content}[role=group]{display:flex;flex-direction:column;gap:1em}.header{display:flex;align-items:center;justify-content:space-between}#heading{font-weight:700;font-size:1.25em}button{cursor:pointer;user-select:none;display:flex;align-items:center;justify-content:center}button[aria-disabled]{cursor:default;opacity:.4}`
1054
- ], nn = { year: "numeric" }, sn = { year: "numeric", month: "long" };
1055
- function Vt({ months: e, locale: t }) {
1056
- const [s] = at("min"), [n] = at("max"), o = v("focusday"), r = v("change"), [i, f] = ct(() => {
1057
- const m = z(), w = e === 12 ? new C(m.year, 1) : m.toPlainYearMonth();
1058
- return new T(w, { months: e }, m);
1059
- });
1060
- function u(m) {
1061
- f(m), o(m.focusedDate.toDate());
1062
- }
1063
- function l(m) {
1064
- f(i.adjust(m));
961
+ zt,
962
+ Y`:host{display:block;inline-size:fit-content}[role=group]{display:flex;flex-direction:column;gap:1em}:host::part(header){display:flex;align-items:center;justify-content:space-between}:host::part(heading){font-weight:700;font-size:1.25em}button{display:flex;align-items:center;justify-content:center}button[aria-disabled]{cursor:default;opacity:.5}`
963
+ ], Ke = { year: "numeric" }, Je = { year: "numeric", month: "long" };
964
+ function wt(e, t) {
965
+ return (t.year - e.year) * 12 + t.month - e.month;
966
+ }
967
+ const vt = (e, t) => (e = t === 12 ? new B(e.year, 1) : e, {
968
+ start: e,
969
+ end: e.add({ months: t - 1 })
970
+ });
971
+ function Wt({
972
+ months: e,
973
+ locale: t,
974
+ focusedDate: n,
975
+ setFocusedDate: s
976
+ }) {
977
+ const [o] = I("min"), [r] = I("max"), c = C("focusday"), f = C("change"), a = P(
978
+ () => x(n ?? ot(), o, r),
979
+ [n, o, r]
980
+ ), [i, u] = st(
981
+ () => vt(a.toPlainYearMonth(), e)
982
+ ), d = (h) => {
983
+ const v = wt(i.start, h.toPlainYearMonth());
984
+ return v >= 0 && v < e;
985
+ };
986
+ nt(() => {
987
+ let h = i.start;
988
+ if (!d(a)) {
989
+ const v = wt(h, a.toPlainYearMonth()), z = Math.floor(v / e);
990
+ h = h.add({ months: z * e });
991
+ }
992
+ u(vt(h, e));
993
+ }, [a, e]);
994
+ const l = $();
995
+ function m() {
996
+ l.current.querySelectorAll("calendar-month").forEach((h) => h.focus());
1065
997
  }
1066
- const c = U();
1067
- function h() {
1068
- c.current.querySelectorAll("calendar-month").forEach((m) => m.focus());
998
+ function p(h) {
999
+ s(h), c(w(h));
1069
1000
  }
1070
- const a = Y(nn, t), d = Y(sn, t), y = n == null || !i.contains(n), D = s == null || !i.contains(s);
1001
+ const y = U(Ke, t), E = U(Je, t);
1071
1002
  return {
1072
- format: a,
1073
- formatVerbose: d,
1074
- dateWindow: i,
1075
- dispatch: r,
1076
- handleFocus(m) {
1077
- m.stopPropagation(), l(m.detail), o(m.detail.toDate()), setTimeout(h);
1003
+ format: y,
1004
+ formatVerbose: E,
1005
+ page: i,
1006
+ focusedDate: a,
1007
+ dispatch: f,
1008
+ onFocus(h) {
1009
+ h.stopPropagation(), p(h.detail), setTimeout(m);
1078
1010
  },
1079
- setFocusedDate: l,
1080
- min: s,
1081
- max: n,
1082
- next: y ? () => u(i.next()) : void 0,
1083
- previous: D ? () => u(i.prev()) : void 0,
1084
- focus: h
1011
+ min: o,
1012
+ max: r,
1013
+ next: r == null || !d(r) ? () => p(a.add({ months: e })) : void 0,
1014
+ previous: o == null || !d(o) ? () => p(a.add({ months: -e })) : void 0,
1015
+ focus: m
1085
1016
  };
1086
1017
  }
1087
- const on = $(
1018
+ const Ze = j(
1088
1019
  (e) => {
1089
- const [t, s] = at("value"), n = Vt(e);
1090
- j(() => {
1091
- t && n.setFocusedDate(t);
1092
- }, [t]);
1093
- function o(r) {
1094
- s(r.detail), n.dispatch();
1020
+ const [t, n] = I("value"), [s = t, o] = I("focusedDate"), r = Wt({
1021
+ ...e,
1022
+ focusedDate: s,
1023
+ setFocusedDate: o
1024
+ });
1025
+ function c(f) {
1026
+ n(f.detail), r.dispatch();
1095
1027
  }
1096
- return /* @__PURE__ */ b("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ b(
1097
- Xt,
1028
+ return /* @__PURE__ */ b("host", { shadowDom: !0, focus: r.focus, children: /* @__PURE__ */ b(
1029
+ Kt,
1098
1030
  {
1099
1031
  ...e,
1100
- ...n,
1032
+ ...r,
1101
1033
  value: t,
1102
- onFocus: n.handleFocus,
1103
- onSelect: o
1034
+ onSelect: c
1104
1035
  }
1105
1036
  ) });
1106
1037
  },
1107
- { props: Gt, styles: Qt }
1038
+ { props: Jt, styles: Zt }
1108
1039
  );
1109
- customElements.define("calendar-date", on);
1110
- const Ct = (e, t) => g.compare(e, t) < 0 ? [e, t] : [t, e], rn = $(
1040
+ customElements.define("calendar-date", Ze);
1041
+ const Tt = (e, t) => D.compare(e, t) < 0 ? [e, t] : [t, e], We = j(
1111
1042
  (e) => {
1112
- const [t, s] = Xe("value"), n = Vt(e), o = v("rangestart"), r = v("rangeend"), [i, f] = ct();
1113
- j(() => {
1114
- t.length && !rt(n.dateWindow.focusedDate, t[0], t[1]) && n.setFocusedDate(t[1]);
1115
- }, [t]);
1116
- async function u(a) {
1117
- n.handleFocus(a), l(a);
1043
+ const [t, n] = je("value"), [s = t[0], o] = I("focusedDate"), r = Wt({
1044
+ ...e,
1045
+ focusedDate: s,
1046
+ setFocusedDate: o
1047
+ }), c = C("rangestart"), f = C("rangeend"), [a, i] = st();
1048
+ function u(p) {
1049
+ r.onFocus(p), d(p);
1118
1050
  }
1119
- function l(a) {
1120
- a.stopPropagation(), f((d) => d && { ...d, second: a.detail });
1051
+ function d(p) {
1052
+ p.stopPropagation(), i((y) => y && { ...y, b: p.detail });
1121
1053
  }
1122
- function c(a) {
1123
- const d = a.detail;
1124
- a.stopPropagation(), i ? (s(Ct(i.first, d)), f(void 0), r(d.toDate()), n.dispatch()) : (f({ first: d, second: d }), o(d.toDate()));
1054
+ function l(p) {
1055
+ const y = p.detail;
1056
+ p.stopPropagation(), a ? (n(Tt(a.a, y)), i(void 0), f(w(y)), r.dispatch()) : (i({ a: y, b: y }), c(w(y)));
1125
1057
  }
1126
- const h = i ? Ct(i.first, i.second) : t;
1127
- return /* @__PURE__ */ b("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ b(
1128
- Xt,
1058
+ const m = a ? Tt(a.a, a.b) : t;
1059
+ return /* @__PURE__ */ b("host", { shadowDom: !0, focus: r.focus, children: /* @__PURE__ */ b(
1060
+ Kt,
1129
1061
  {
1130
1062
  ...e,
1131
- ...n,
1132
- highlightedRange: h,
1063
+ ...r,
1064
+ highlightedRange: m,
1133
1065
  onFocus: u,
1134
- onHover: l,
1135
- onSelect: c
1066
+ onHover: d,
1067
+ onSelect: l
1136
1068
  }
1137
1069
  ) });
1138
1070
  },
1139
- { props: Gt, styles: Qt }
1071
+ { props: Jt, styles: Zt }
1140
1072
  );
1141
- customElements.define("calendar-range", rn);
1073
+ customElements.define("calendar-range", We);
1142
1074
  export {
1143
- on as CalendarDate,
1144
- en as CalendarMonth,
1145
- rn as CalendarRange
1075
+ Ze as CalendarDate,
1076
+ He as CalendarMonth,
1077
+ We as CalendarRange
1146
1078
  };