@tryghost/activitypub 1.0.9

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.
@@ -0,0 +1,599 @@
1
+ import { f as q, u as C, a as E, b as Q, c as T, d as K, e as tt, g as et, C as it, v as st, h as X } from "./index-Dj0FEjRY.mjs";
2
+ const nt = (n, t) => n == null ? t : t == null ? n : Math.max(n, t), A = /* @__PURE__ */ new WeakMap(), Et = {
3
+ onUpdate(n, t, e) {
4
+ if (A.set(e, void 0), !e.computedTrend)
5
+ return;
6
+ const i = t.integer.concat(t.fraction).filter((o) => o.type === "integer" || o.type === "fraction"), s = n.integer.concat(n.fraction).filter((o) => o.type === "integer" || o.type === "fraction"), r = i.find((o) => !s.find((l) => l.pos === o.pos && l.value === o.value)), a = s.find((o) => !i.find((l) => o.pos === l.pos && o.value === l.value));
7
+ A.set(e, nt(r == null ? void 0 : r.pos, a == null ? void 0 : a.pos));
8
+ },
9
+ getDelta(n, t, e) {
10
+ const i = n - t, s = A.get(e.flow);
11
+ if (!i && s != null && s >= e.pos)
12
+ return e.length * e.flow.computedTrend;
13
+ }
14
+ }, v = (n, t, e) => {
15
+ const i = document.createElement(n), [s, r] = Array.isArray(t) ? [void 0, t] : [t, e];
16
+ return s && Object.assign(i, s), r == null || r.forEach((a) => i.appendChild(a)), i;
17
+ }, at = (n, t) => {
18
+ var e;
19
+ return t === "left" ? n.offsetLeft : (((e = n.offsetParent instanceof HTMLElement ? n.offsetParent : null) == null ? void 0 : e.offsetWidth) ?? 0) - n.offsetWidth - n.offsetLeft;
20
+ }, rt = (n) => n.offsetWidth > 0 && n.offsetHeight > 0, ot = (n, t) => {
21
+ !customElements.get(n) && customElements.define(n, t);
22
+ };
23
+ function lt(n, t, { reverse: e = !1 } = {}) {
24
+ const i = n.length;
25
+ for (let s = e ? i - 1 : 0; e ? s >= 0 : s < i; e ? s-- : s++)
26
+ t(n[s], s);
27
+ }
28
+ function ht(n, t, e, i) {
29
+ const s = t.formatToParts(n);
30
+ e && s.unshift({ type: "prefix", value: e }), i && s.push({ type: "suffix", value: i });
31
+ const r = [], a = [], o = [], l = [], d = {}, u = (c) => `${c}:${d[c] = (d[c] ?? -1) + 1}`;
32
+ let f = "", m = !1, g = !1;
33
+ for (const c of s) {
34
+ f += c.value;
35
+ const h = c.type === "minusSign" || c.type === "plusSign" ? "sign" : c.type;
36
+ h === "integer" ? (m = !0, a.push(...c.value.split("").map((x) => ({ type: h, value: parseInt(x) })))) : h === "group" ? a.push({ type: h, value: c.value }) : h === "decimal" ? (g = !0, o.push({ type: h, value: c.value, key: u(h) })) : h === "fraction" ? o.push(...c.value.split("").map((x) => ({
37
+ type: h,
38
+ value: parseInt(x),
39
+ key: u(h),
40
+ pos: -1 - d[h]
41
+ }))) : (m || g ? l : r).push({
42
+ type: h,
43
+ value: c.value,
44
+ key: u(h)
45
+ });
46
+ }
47
+ const w = [];
48
+ for (let c = a.length - 1; c >= 0; c--) {
49
+ const h = a[c];
50
+ w.unshift(h.type === "integer" ? {
51
+ ...h,
52
+ key: u(h.type),
53
+ pos: d[h.type]
54
+ } : {
55
+ ...h,
56
+ key: u(h.type)
57
+ });
58
+ }
59
+ return {
60
+ pre: r,
61
+ integer: w,
62
+ fraction: o,
63
+ post: l,
64
+ valueAsString: f,
65
+ value: typeof n == "string" ? parseFloat(n) : n
66
+ };
67
+ }
68
+ const ct = String.raw, dt = (() => {
69
+ try {
70
+ document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
71
+ } catch {
72
+ return !1;
73
+ }
74
+ return !0;
75
+ })(), ut = typeof CSS < "u" && CSS.supports && CSS.supports("line-height", "mod(1,1)"), p = typeof matchMedia < "u" ? matchMedia("(prefers-reduced-motion: reduce)") : null, R = "--_number-flow-d-opacity", N = "--_number-flow-d-width", $ = "--_number-flow-dx", M = "--_number-flow-d", pt = (() => {
76
+ try {
77
+ return CSS.registerProperty({
78
+ name: R,
79
+ syntax: "<number>",
80
+ inherits: !1,
81
+ initialValue: "0"
82
+ }), CSS.registerProperty({
83
+ name: $,
84
+ syntax: "<length>",
85
+ inherits: !0,
86
+ initialValue: "0px"
87
+ }), CSS.registerProperty({
88
+ name: N,
89
+ syntax: "<number>",
90
+ inherits: !1,
91
+ initialValue: "0"
92
+ }), CSS.registerProperty({
93
+ name: M,
94
+ syntax: "<number>",
95
+ inherits: !0,
96
+ initialValue: "0"
97
+ }), !0;
98
+ } catch {
99
+ return !1;
100
+ }
101
+ })(), ft = "var(--number-flow-char-height, 1em)", y = "var(--number-flow-mask-height, 0.25em)", P = `calc(${y} / 2)`, k = "var(--number-flow-mask-width, 0.5em)", _ = `calc(${k} / var(--scale-x))`, b = "#000 0, transparent 71%", O = ct`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${ft} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${N}) / var(--width));transform:translateX(var(${$})) scaleX(var(--scale-x));margin:0 calc(-1 * ${k});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${_},#000 calc(100% - ${_}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${y},#000 calc(100% - ${y}),transparent 100% ),radial-gradient(at bottom right,${b}),radial-gradient(at bottom left,${b}),radial-gradient(at top left,${b}),radial-gradient(at top right,${b});-webkit-mask-size:100% calc(100% - ${y} * 2),calc(100% - ${_} * 2) 100%,${_} ${y},${_} ${y},${_} ${y},${_} ${y};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${P} ${k};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${$})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${M})}.digit__num,.number .section::after{padding:${P} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${R}))}`, mt = HTMLElement, H = ut && dt && pt;
102
+ let S;
103
+ class z extends mt {
104
+ constructor() {
105
+ super(), this.created = !1, this.batched = !1;
106
+ const { animated: t, ...e } = this.constructor.defaultProps;
107
+ this._animated = this.computedAnimated = t, Object.assign(this, e);
108
+ }
109
+ get animated() {
110
+ return this._animated;
111
+ }
112
+ set animated(t) {
113
+ var e;
114
+ this.animated !== t && (this._animated = t, (e = this.shadowRoot) == null || e.getAnimations().forEach((i) => i.finish()));
115
+ }
116
+ /**
117
+ * @internal
118
+ */
119
+ set data(t) {
120
+ var e;
121
+ if (t == null)
122
+ return;
123
+ const { pre: i, integer: s, fraction: r, post: a, value: o } = t;
124
+ if (this.created) {
125
+ const l = this._data;
126
+ this._data = t, this.computedTrend = typeof this.trend == "function" ? this.trend(l.value, o) : this.trend, this.computedAnimated = H && this._animated && (!this.respectMotionPreference || !(p != null && p.matches)) && // https://github.com/barvian/number-flow/issues/9
127
+ rt(this), (e = this.plugins) == null || e.forEach((d) => {
128
+ var u;
129
+ return (u = d.onUpdate) == null ? void 0 : u.call(d, t, l, this);
130
+ }), this.batched || this.willUpdate(), this._pre.update(i), this._num.update({ integer: s, fraction: r }), this._post.update(a), this.batched || this.didUpdate();
131
+ } else {
132
+ this._data = t, this.attachShadow({ mode: "open" });
133
+ try {
134
+ this._internals ?? (this._internals = this.attachInternals()), this._internals.role = "img";
135
+ } catch {
136
+ }
137
+ if (typeof CSSStyleSheet < "u" && this.shadowRoot.adoptedStyleSheets)
138
+ S || (S = new CSSStyleSheet(), S.replaceSync(O)), this.shadowRoot.adoptedStyleSheets = [S];
139
+ else {
140
+ const l = document.createElement("style");
141
+ l.textContent = O, this.shadowRoot.appendChild(l);
142
+ }
143
+ this._pre = new B(this, i, {
144
+ justify: "right",
145
+ part: "left"
146
+ }), this.shadowRoot.appendChild(this._pre.el), this._num = new gt(this, s, r), this.shadowRoot.appendChild(this._num.el), this._post = new B(this, a, {
147
+ justify: "left",
148
+ part: "right"
149
+ }), this.shadowRoot.appendChild(this._post.el), this.created = !0;
150
+ }
151
+ try {
152
+ this._internals.ariaLabel = t.valueAsString;
153
+ } catch {
154
+ }
155
+ }
156
+ /**
157
+ * @internal
158
+ */
159
+ willUpdate() {
160
+ this._pre.willUpdate(), this._num.willUpdate(), this._post.willUpdate();
161
+ }
162
+ /**
163
+ * @internal
164
+ */
165
+ didUpdate() {
166
+ if (!this.computedAnimated)
167
+ return;
168
+ this._abortAnimationsFinish ? this._abortAnimationsFinish.abort() : this.dispatchEvent(new Event("animationsstart")), this._pre.didUpdate(), this._num.didUpdate(), this._post.didUpdate();
169
+ const t = new AbortController();
170
+ Promise.all(this.shadowRoot.getAnimations().map((e) => e.finished)).then(() => {
171
+ t.signal.aborted || (this.dispatchEvent(new Event("animationsfinish")), this._abortAnimationsFinish = void 0);
172
+ }), this._abortAnimationsFinish = t;
173
+ }
174
+ }
175
+ z.defaultProps = {
176
+ transformTiming: {
177
+ duration: 900,
178
+ // Make sure to keep this minified:
179
+ easing: "linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"
180
+ },
181
+ spinTiming: void 0,
182
+ opacityTiming: { duration: 450, easing: "ease-out" },
183
+ animated: !0,
184
+ trend: (n, t) => Math.sign(t - n),
185
+ respectMotionPreference: !0,
186
+ plugins: void 0,
187
+ digits: void 0
188
+ };
189
+ class gt {
190
+ constructor(t, e, i, { className: s, ...r } = {}) {
191
+ this.flow = t, this._integer = new V(t, e, {
192
+ justify: "right",
193
+ part: "integer"
194
+ }), this._fraction = new V(t, i, {
195
+ justify: "left",
196
+ part: "fraction"
197
+ }), this._inner = v("span", {
198
+ className: "number__inner"
199
+ }, [this._integer.el, this._fraction.el]), this.el = v("span", {
200
+ ...r,
201
+ part: "number",
202
+ className: `number ${s ?? ""}`
203
+ }, [this._inner]);
204
+ }
205
+ willUpdate() {
206
+ this._prevWidth = this.el.offsetWidth, this._prevLeft = this.el.getBoundingClientRect().left, this._integer.willUpdate(), this._fraction.willUpdate();
207
+ }
208
+ update({ integer: t, fraction: e }) {
209
+ this._integer.update(t), this._fraction.update(e);
210
+ }
211
+ didUpdate() {
212
+ const t = this.el.getBoundingClientRect();
213
+ this._integer.didUpdate(), this._fraction.didUpdate();
214
+ const e = this._prevLeft - t.left, i = this.el.offsetWidth, s = this._prevWidth - i;
215
+ this.el.style.setProperty("--width", String(i)), this.el.animate({
216
+ [$]: [`${e}px`, "0px"],
217
+ [N]: [s, 0]
218
+ }, {
219
+ ...this.flow.transformTiming,
220
+ composite: "accumulate"
221
+ });
222
+ }
223
+ }
224
+ class J {
225
+ constructor(t, e, { justify: i, className: s, ...r }, a) {
226
+ this.flow = t, this.children = /* @__PURE__ */ new Map(), this.onCharRemove = (l) => () => {
227
+ this.children.delete(l);
228
+ }, this.justify = i;
229
+ const o = e.map((l) => this.addChar(l).el);
230
+ this.el = v("span", {
231
+ ...r,
232
+ className: `section section--justify-${i} ${s ?? ""}`
233
+ }, a ? a(o) : o);
234
+ }
235
+ addChar(t, { startDigitsAtZero: e = !1, ...i } = {}) {
236
+ const s = t.type === "integer" || t.type === "fraction" ? new Y(this, t.type, e ? 0 : t.value, t.pos, {
237
+ ...i,
238
+ onRemove: this.onCharRemove(t.key)
239
+ }) : new yt(this, t.type, t.value, {
240
+ ...i,
241
+ onRemove: this.onCharRemove(t.key)
242
+ });
243
+ return this.children.set(t.key, s), s;
244
+ }
245
+ unpop(t) {
246
+ t.el.removeAttribute("inert"), t.el.style.top = "", t.el.style[this.justify] = "";
247
+ }
248
+ pop(t) {
249
+ t.forEach((e) => {
250
+ e.el.style.top = `${e.el.offsetTop}px`, e.el.style[this.justify] = `${at(e.el, this.justify)}px`;
251
+ }), t.forEach((e) => {
252
+ e.el.setAttribute("inert", ""), e.present = !1;
253
+ });
254
+ }
255
+ addNewAndUpdateExisting(t) {
256
+ const e = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = this.justify === "left", r = s ? "prepend" : "append";
257
+ if (lt(t, (a) => {
258
+ let o;
259
+ this.children.has(a.key) ? (o = this.children.get(a.key), i.set(a, o), this.unpop(o), o.present = !0) : (o = this.addChar(a, { startDigitsAtZero: !0, animateIn: !0 }), e.set(a, o)), this.el[r](o.el);
260
+ }, { reverse: s }), this.flow.computedAnimated) {
261
+ const a = this.el.getBoundingClientRect();
262
+ e.forEach((o) => {
263
+ o.willUpdate(a);
264
+ });
265
+ }
266
+ e.forEach((a, o) => {
267
+ a.update(o.value);
268
+ }), i.forEach((a, o) => {
269
+ a.update(o.value);
270
+ });
271
+ }
272
+ willUpdate() {
273
+ const t = this.el.getBoundingClientRect();
274
+ this._prevOffset = t[this.justify], this.children.forEach((e) => e.willUpdate(t));
275
+ }
276
+ didUpdate() {
277
+ const t = this.el.getBoundingClientRect();
278
+ this.children.forEach((s) => s.didUpdate(t));
279
+ const e = t[this.justify], i = this._prevOffset - e;
280
+ i && this.children.size && this.el.animate({
281
+ transform: [`translateX(${i}px)`, "none"]
282
+ }, {
283
+ ...this.flow.transformTiming,
284
+ composite: "accumulate"
285
+ });
286
+ }
287
+ }
288
+ class V extends J {
289
+ update(t) {
290
+ const e = /* @__PURE__ */ new Map();
291
+ this.children.forEach((i, s) => {
292
+ t.find((r) => r.key === s) || e.set(s, i), this.unpop(i);
293
+ }), this.addNewAndUpdateExisting(t), e.forEach((i) => {
294
+ i instanceof Y && i.update(0);
295
+ }), this.pop(e);
296
+ }
297
+ }
298
+ class B extends J {
299
+ update(t) {
300
+ const e = /* @__PURE__ */ new Map();
301
+ this.children.forEach((i, s) => {
302
+ t.find((r) => r.key === s) || e.set(s, i);
303
+ }), this.pop(e), this.addNewAndUpdateExisting(t);
304
+ }
305
+ }
306
+ class j {
307
+ constructor(t, e, { onRemove: i, animateIn: s = !1 } = {}) {
308
+ this.flow = t, this.el = e, this._present = !0, this._remove = () => {
309
+ var r;
310
+ this.el.remove(), (r = this._onRemove) == null || r.call(this);
311
+ }, this.el.classList.add("animate-presence"), this.flow.computedAnimated && s && this.el.animate({
312
+ [R]: [-0.9999, 0]
313
+ }, {
314
+ ...this.flow.opacityTiming,
315
+ composite: "accumulate"
316
+ }), this._onRemove = i;
317
+ }
318
+ get present() {
319
+ return this._present;
320
+ }
321
+ set present(t) {
322
+ if (this._present !== t) {
323
+ if (this._present = t, t ? this.el.removeAttribute("inert") : this.el.setAttribute("inert", ""), !this.flow.computedAnimated) {
324
+ t || this._remove();
325
+ return;
326
+ }
327
+ this.el.style.setProperty("--_number-flow-d-opacity", t ? "0" : "-.999"), this.el.animate({
328
+ [R]: t ? [-0.9999, 0] : [0.999, 0]
329
+ }, {
330
+ ...this.flow.opacityTiming,
331
+ composite: "accumulate"
332
+ }), t ? this.flow.removeEventListener("animationsfinish", this._remove) : this.flow.addEventListener("animationsfinish", this._remove, {
333
+ once: !0
334
+ });
335
+ }
336
+ }
337
+ }
338
+ class G extends j {
339
+ constructor(t, e, i, s) {
340
+ super(t.flow, i, s), this.section = t, this.value = e, this.el = i;
341
+ }
342
+ }
343
+ class Y extends G {
344
+ constructor(t, e, i, s, r) {
345
+ var a, o;
346
+ const l = (((o = (a = t.flow.digits) == null ? void 0 : a[s]) == null ? void 0 : o.max) ?? 9) + 1, d = Array.from({ length: l }).map((f, m) => {
347
+ const g = v("span", { className: "digit__num" }, [
348
+ document.createTextNode(String(m))
349
+ ]);
350
+ return m !== i && g.setAttribute("inert", ""), g.style.setProperty("--n", String(m)), g;
351
+ }), u = v("span", {
352
+ part: `digit ${e}-digit`,
353
+ className: "digit"
354
+ }, d);
355
+ u.style.setProperty("--current", String(i)), u.style.setProperty("--length", String(l)), super(t, i, u, r), this.pos = s, this._onAnimationsFinish = () => {
356
+ this.el.classList.remove("is-spinning");
357
+ }, this._numbers = d, this.length = l;
358
+ }
359
+ willUpdate(t) {
360
+ const e = this.el.getBoundingClientRect();
361
+ this._prevValue = this.value;
362
+ const i = e[this.section.justify] - t[this.section.justify], s = e.width / 2;
363
+ this._prevCenter = this.section.justify === "left" ? i + s : i - s;
364
+ }
365
+ update(t) {
366
+ this.el.style.setProperty("--current", String(t)), this._numbers.forEach((e, i) => i === t ? e.removeAttribute("inert") : e.setAttribute("inert", "")), this.value = t;
367
+ }
368
+ didUpdate(t) {
369
+ const e = this.el.getBoundingClientRect(), i = e[this.section.justify] - t[this.section.justify], s = e.width / 2, r = this.section.justify === "left" ? i + s : i - s, a = this._prevCenter - r;
370
+ a && this.el.animate({
371
+ transform: [`translateX(${a}px)`, "none"]
372
+ }, {
373
+ ...this.flow.transformTiming,
374
+ composite: "accumulate"
375
+ });
376
+ const o = this.getDelta();
377
+ o && (this.el.classList.add("is-spinning"), this.el.animate({
378
+ [M]: [-o, 0]
379
+ }, {
380
+ ...this.flow.spinTiming ?? this.flow.transformTiming,
381
+ composite: "accumulate"
382
+ }), this.flow.addEventListener("animationsfinish", this._onAnimationsFinish, { once: !0 }));
383
+ }
384
+ getDelta() {
385
+ var t;
386
+ if (this.flow.plugins)
387
+ for (const s of this.flow.plugins) {
388
+ const r = (t = s.getDelta) == null ? void 0 : t.call(s, this.value, this._prevValue, this);
389
+ if (r != null)
390
+ return r;
391
+ }
392
+ const e = this.value - this._prevValue, i = this.flow.computedTrend || Math.sign(e);
393
+ return i < 0 && this.value > this._prevValue ? this.value - this.length - this._prevValue : i > 0 && this.value < this._prevValue ? this.length - this._prevValue + this.value : e;
394
+ }
395
+ }
396
+ class yt extends G {
397
+ constructor(t, e, i, s) {
398
+ const r = v("span", {
399
+ className: "symbol__value",
400
+ textContent: i
401
+ });
402
+ super(t, i, v("span", {
403
+ part: `symbol ${e}`,
404
+ className: "symbol"
405
+ }, [r]), s), this.type = e, this._children = /* @__PURE__ */ new Map(), this._onChildRemove = (a) => () => {
406
+ this._children.delete(a);
407
+ }, this._children.set(i, new j(this.flow, r, {
408
+ onRemove: this._onChildRemove(i)
409
+ }));
410
+ }
411
+ willUpdate(t) {
412
+ if (this.type === "decimal")
413
+ return;
414
+ const e = this.el.getBoundingClientRect();
415
+ this._prevOffset = e[this.section.justify] - t[this.section.justify];
416
+ }
417
+ update(t) {
418
+ if (this.value !== t) {
419
+ const e = this._children.get(this.value);
420
+ e && (e.present = !1);
421
+ const i = this._children.get(t);
422
+ if (i)
423
+ i.present = !0;
424
+ else {
425
+ const s = v("span", {
426
+ className: "symbol__value",
427
+ textContent: t
428
+ });
429
+ this.el.appendChild(s), this._children.set(t, new j(this.flow, s, {
430
+ animateIn: !0,
431
+ onRemove: this._onChildRemove(t)
432
+ }));
433
+ }
434
+ }
435
+ this.value = t;
436
+ }
437
+ didUpdate(t) {
438
+ if (this.type === "decimal")
439
+ return;
440
+ const e = this.el.getBoundingClientRect()[this.section.justify] - t[this.section.justify], i = this._prevOffset - e;
441
+ i && this.el.animate({
442
+ transform: [`translateX(${i}px)`, "none"]
443
+ }, { ...this.flow.transformTiming, composite: "accumulate" });
444
+ }
445
+ }
446
+ var W;
447
+ const vt = parseInt((W = st.match(/^(\d+)\./)) == null ? void 0 : W[1]), L = vt >= 19, _t = [
448
+ "data",
449
+ "digits"
450
+ ];
451
+ class F extends z {
452
+ attributeChangedCallback(t, e, i) {
453
+ this[t] = JSON.parse(i);
454
+ }
455
+ }
456
+ F.observedAttributes = L ? [] : _t;
457
+ ot("number-flow-react", F);
458
+ const U = {}, I = L ? (n) => n : JSON.stringify;
459
+ function D(n) {
460
+ const { transformTiming: t, spinTiming: e, opacityTiming: i, animated: s, respectMotionPreference: r, trend: a, plugins: o, ...l } = n;
461
+ return [
462
+ {
463
+ transformTiming: t,
464
+ spinTiming: e,
465
+ opacityTiming: i,
466
+ animated: s,
467
+ respectMotionPreference: r,
468
+ trend: a,
469
+ plugins: o
470
+ },
471
+ l
472
+ ];
473
+ }
474
+ class wt extends it {
475
+ // Update the non-`data` props to avoid JSON serialization
476
+ // Data needs to be set in render still:
477
+ updateProperties(t) {
478
+ if (!this.el) return;
479
+ this.el.batched = !this.props.isolate;
480
+ const [e] = D(this.props);
481
+ Object.entries(e).forEach(([i, s]) => {
482
+ this.el[i] = s ?? F.defaultProps[i];
483
+ }), t != null && t.onAnimationsStart && this.el.removeEventListener("animationsstart", t.onAnimationsStart), this.props.onAnimationsStart && this.el.addEventListener("animationsstart", this.props.onAnimationsStart), t != null && t.onAnimationsFinish && this.el.removeEventListener("animationsfinish", t.onAnimationsFinish), this.props.onAnimationsFinish && this.el.addEventListener("animationsfinish", this.props.onAnimationsFinish);
484
+ }
485
+ componentDidMount() {
486
+ this.updateProperties(), L && this.el && (this.el.digits = this.props.digits, this.el.data = this.props.data);
487
+ }
488
+ getSnapshotBeforeUpdate(t) {
489
+ var e;
490
+ if (this.updateProperties(t), t.data !== this.props.data) {
491
+ if (this.props.group)
492
+ return this.props.group.willUpdate(), () => {
493
+ var i;
494
+ return (i = this.props.group) == null ? void 0 : i.didUpdate();
495
+ };
496
+ if (!this.props.isolate)
497
+ return (e = this.el) == null || e.willUpdate(), () => {
498
+ var i;
499
+ return (i = this.el) == null ? void 0 : i.didUpdate();
500
+ };
501
+ }
502
+ return null;
503
+ }
504
+ componentDidUpdate(t, e, i) {
505
+ i == null || i();
506
+ }
507
+ handleRef(t) {
508
+ this.props.innerRef && (this.props.innerRef.current = t), this.el = t;
509
+ }
510
+ render() {
511
+ const [t, { innerRef: e, className: i, data: s, willChange: r, isolate: a, group: o, digits: l, onAnimationsStart: d, onAnimationsFinish: u, ...f }] = D(this.props);
512
+ return (
513
+ // @ts-expect-error missing types
514
+ /* @__PURE__ */ T("number-flow-react", {
515
+ ref: this.handleRef,
516
+ "data-will-change": r ? "" : void 0,
517
+ // Have to rename this:
518
+ class: i,
519
+ ...f,
520
+ dangerouslySetInnerHTML: {
521
+ __html: ""
522
+ },
523
+ suppressHydrationWarning: !0,
524
+ digits: I(l),
525
+ // Make sure data is set last, everything else is updated:
526
+ data: I(s)
527
+ })
528
+ );
529
+ }
530
+ constructor(t) {
531
+ super(t), this.handleRef = this.handleRef.bind(this);
532
+ }
533
+ }
534
+ const Rt = /* @__PURE__ */ q(function({ value: t, locales: e, format: i, prefix: s, suffix: r, ...a }, o) {
535
+ tt(o, () => l.current, []);
536
+ const l = C(), d = et(Z);
537
+ d == null || d.useRegister(l);
538
+ const u = E(() => e ? JSON.stringify(e) : "", [
539
+ e
540
+ ]), f = E(() => i ? JSON.stringify(i) : "", [
541
+ i
542
+ ]), m = E(() => {
543
+ var w;
544
+ const g = U[w = `${u}:${f}`] ?? (U[w] = new Intl.NumberFormat(e, i));
545
+ return ht(t, g, s, r);
546
+ }, [
547
+ t,
548
+ u,
549
+ f,
550
+ s,
551
+ r
552
+ ]);
553
+ return /* @__PURE__ */ T(wt, {
554
+ ...a,
555
+ group: d,
556
+ data: m,
557
+ innerRef: l
558
+ });
559
+ }), Z = /* @__PURE__ */ K(void 0);
560
+ function $t({ children: n }) {
561
+ const t = C(/* @__PURE__ */ new Set()), e = C(!1), i = C(/* @__PURE__ */ new WeakMap()), s = E(() => ({
562
+ useRegister(r) {
563
+ Q(() => (t.current.add(r), () => {
564
+ t.current.delete(r);
565
+ }), []);
566
+ },
567
+ willUpdate() {
568
+ e.current || (e.current = !0, t.current.forEach((r) => {
569
+ const a = r.current;
570
+ !a || !a.created || (a.willUpdate(), i.current.set(a, !0));
571
+ }));
572
+ },
573
+ didUpdate() {
574
+ t.current.forEach((r) => {
575
+ const a = r.current;
576
+ !a || !i.current.get(a) || (a.didUpdate(), i.current.delete(a));
577
+ }), e.current = !1;
578
+ }
579
+ }), []);
580
+ return /* @__PURE__ */ T(Z.Provider, {
581
+ value: s
582
+ }, n);
583
+ }
584
+ const bt = () => X(() => () => {
585
+ }, () => H, () => !1), St = () => X((n) => (p == null || p.addEventListener("change", n), () => p == null ? void 0 : p.removeEventListener("change", n)), () => p.matches, () => !1);
586
+ function xt({ respectMotionPreference: n = !0 } = {}) {
587
+ const t = bt(), e = St();
588
+ return t && (!n || !e);
589
+ }
590
+ export {
591
+ F as NumberFlowElement,
592
+ $t as NumberFlowGroup,
593
+ Et as continuous,
594
+ Rt as default,
595
+ xt as useCanAnimate,
596
+ bt as useIsSupported,
597
+ St as usePrefersReducedMotion
598
+ };
599
+ //# sourceMappingURL=index-j4ec6XEX.mjs.map