@opentiny/tiny-robot 0.2.0 → 0.3.0-alpha.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/index2.js CHANGED
@@ -1,536 +1,603 @@
1
- import { onMounted as te, nextTick as re, watch as _, getCurrentScope as se, onScopeDispose as ue, isRef as ce, getCurrentInstance as B, toValue as g, hasInjectionContext as ne, inject as ae, shallowRef as S, computed as I, reactive as J, unref as de, watchEffect as fe } from "vue";
2
- function N(e) {
1
+ import { getCurrentScope as se, onScopeDispose as ue, onMounted as oe, nextTick as ce, watch as A, isRef as ae, getCurrentInstance as B, toValue as b, hasInjectionContext as ie, inject as fe, ref as de, readonly as ve, shallowRef as y, computed as I, reactive as K, unref as me, watchEffect as he } from "vue";
2
+ function H(e) {
3
3
  return se() ? (ue(e), !0) : !1;
4
4
  }
5
- const H = /* @__PURE__ */ new WeakMap(), ve = (...e) => {
5
+ function Z() {
6
+ const e = /* @__PURE__ */ new Set(), t = (s) => {
7
+ e.delete(s);
8
+ };
9
+ return {
10
+ on: (s) => {
11
+ e.add(s);
12
+ const a = () => t(s);
13
+ return H(a), {
14
+ off: a
15
+ };
16
+ },
17
+ off: t,
18
+ trigger: (...s) => Promise.all(Array.from(e).map((a) => a(...s))),
19
+ clear: () => {
20
+ e.clear();
21
+ }
22
+ };
23
+ }
24
+ const N = /* @__PURE__ */ new WeakMap(), pe = (...e) => {
6
25
  var t;
7
- const o = e[0], n = (t = B()) == null ? void 0 : t.proxy;
8
- if (n == null && !ne())
26
+ const n = e[0], i = (t = B()) == null ? void 0 : t.proxy;
27
+ if (i == null && !ie())
9
28
  throw new Error("injectLocal must be called in setup");
10
- return n && H.has(n) && o in H.get(n) ? H.get(n)[o] : ae(...e);
11
- }, oe = typeof window < "u" && typeof document < "u";
29
+ return i && N.has(i) && n in N.get(i) ? N.get(i)[n] : fe(...e);
30
+ }, $ = typeof window < "u" && typeof document < "u";
12
31
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
13
- const he = (e) => e != null, me = Object.prototype.toString, pe = (e) => me.call(e) === "[object Object]", x = () => {
14
- }, we = /* @__PURE__ */ be();
15
- function be() {
32
+ const we = (e) => e != null, ge = Object.prototype.toString, be = (e) => ge.call(e) === "[object Object]", O = () => {
33
+ }, ye = (e, t) => Object.prototype.hasOwnProperty.call(e, t), Se = /* @__PURE__ */ Te();
34
+ function Te() {
16
35
  var e, t;
17
- return oe && ((e = window == null ? void 0 : window.navigator) == null ? void 0 : e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window == null ? void 0 : window.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? void 0 : window.navigator.userAgent));
36
+ return $ && ((e = window == null ? void 0 : window.navigator) == null ? void 0 : e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window == null ? void 0 : window.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? void 0 : window.navigator.userAgent));
18
37
  }
19
- function $(e, t) {
20
- function o(...n) {
21
- return new Promise((v, c) => {
22
- Promise.resolve(e(() => t.apply(this, n), { fn: t, thisArg: this, args: n })).then(v).catch(c);
38
+ function G(e, t) {
39
+ function n(...i) {
40
+ return new Promise((f, s) => {
41
+ Promise.resolve(e(() => t.apply(this, i), { fn: t, thisArg: this, args: i })).then(f).catch(s);
23
42
  });
24
43
  }
25
- return o;
44
+ return n;
26
45
  }
27
- const ge = (e) => e();
28
- function ie(e, t = {}) {
29
- let o, n, v = x;
30
- const c = (l) => {
31
- clearTimeout(l), v(), v = x;
46
+ const Ee = (e) => e();
47
+ function re(e, t = {}) {
48
+ let n, i, f = O;
49
+ const s = (l) => {
50
+ clearTimeout(l), f(), f = O;
32
51
  };
33
- let d;
52
+ let a;
34
53
  return (l) => {
35
- const s = g(e), h = g(t.maxWait);
36
- return o && c(o), s <= 0 || h !== void 0 && h <= 0 ? (n && (c(n), n = null), Promise.resolve(l())) : new Promise((r, a) => {
37
- v = t.rejectOnCancel ? a : r, d = l, h && !n && (n = setTimeout(() => {
38
- o && c(o), n = null, r(d());
39
- }, h)), o = setTimeout(() => {
40
- n && c(n), n = null, r(l());
41
- }, s);
54
+ const u = b(e), d = b(t.maxWait);
55
+ return n && s(n), u <= 0 || d !== void 0 && d <= 0 ? (i && (s(i), i = null), Promise.resolve(l())) : new Promise((r, v) => {
56
+ f = t.rejectOnCancel ? v : r, a = l, d && !i && (i = setTimeout(() => {
57
+ n && s(n), i = null, r(a());
58
+ }, d)), n = setTimeout(() => {
59
+ i && s(i), i = null, r(l());
60
+ }, u);
42
61
  });
43
62
  };
44
63
  }
45
- function Se(...e) {
46
- let t = 0, o, n = !0, v = x, c, d, i, l, s;
47
- !ce(e[0]) && typeof e[0] == "object" ? { delay: d, trailing: i = !0, leading: l = !0, rejectOnCancel: s = !1 } = e[0] : [d, i = !0, l = !0, s = !1] = e;
48
- const h = () => {
49
- o && (clearTimeout(o), o = void 0, v(), v = x);
64
+ function Oe(...e) {
65
+ let t = 0, n, i = !0, f = O, s, a, o, l, u;
66
+ !ae(e[0]) && typeof e[0] == "object" ? { delay: a, trailing: o = !0, leading: l = !0, rejectOnCancel: u = !1 } = e[0] : [a, o = !0, l = !0, u = !1] = e;
67
+ const d = () => {
68
+ n && (clearTimeout(n), n = void 0, f(), f = O);
50
69
  };
51
- return (a) => {
52
- const m = g(d), b = Date.now() - t, y = () => c = a();
53
- return h(), m <= 0 ? (t = Date.now(), y()) : (b > m && (l || !n) ? (t = Date.now(), y()) : i && (c = new Promise((u, f) => {
54
- v = s ? f : u, o = setTimeout(() => {
55
- t = Date.now(), n = !0, u(y()), h();
56
- }, Math.max(0, m - b));
57
- })), !l && !o && (o = setTimeout(() => n = !0, m)), n = !1, c);
70
+ return (v) => {
71
+ const h = b(a), g = Date.now() - t, S = () => s = v();
72
+ return d(), h <= 0 ? (t = Date.now(), S()) : (g > h && (l || !i) ? (t = Date.now(), S()) : o && (s = new Promise((c, m) => {
73
+ f = u ? m : c, n = setTimeout(() => {
74
+ t = Date.now(), i = !0, c(S()), d();
75
+ }, Math.max(0, h - g));
76
+ })), !l && !n && (n = setTimeout(() => i = !0, h)), i = !1, s);
58
77
  };
59
78
  }
60
- function K(e) {
79
+ function ee(e) {
61
80
  return e.endsWith("rem") ? Number.parseFloat(e) * 16 : Number.parseFloat(e);
62
81
  }
63
- function D(e) {
82
+ function C(e) {
64
83
  return Array.isArray(e) ? e : [e];
65
84
  }
66
- function ye(e) {
85
+ function xe(e) {
67
86
  return B();
68
87
  }
69
- function Ee(e, t = 200, o = {}) {
70
- return $(
71
- ie(t, o),
88
+ function We(e, t = 200, n = {}) {
89
+ return G(
90
+ re(t, n),
72
91
  e
73
92
  );
74
93
  }
75
- function Te(e, t = 200, o = !1, n = !0, v = !1) {
76
- return $(
77
- Se(t, o, n, v),
94
+ function Me(e, t = 200, n = !1, i = !0, f = !1) {
95
+ return G(
96
+ Oe(t, n, i, f),
78
97
  e
79
98
  );
80
99
  }
81
- function xe(e, t, o = {}) {
100
+ function Ie(e, t, n = {}) {
82
101
  const {
83
- eventFilter: n = ge,
84
- ...v
85
- } = o;
86
- return _(
102
+ eventFilter: i = Ee,
103
+ ...f
104
+ } = n;
105
+ return A(
87
106
  e,
88
- $(
89
- n,
107
+ G(
108
+ i,
90
109
  t
91
110
  ),
92
- v
111
+ f
93
112
  );
94
113
  }
95
- function V(e, t = !0, o) {
96
- ye() ? te(e, o) : t ? e() : re(e);
114
+ function V(e, t = !0, n) {
115
+ xe() ? oe(e, n) : t ? e() : ce(e);
97
116
  }
98
- function _e(e, t, o = {}) {
117
+ function He(e, t, n = {}) {
99
118
  const {
100
- debounce: n = 0,
101
- maxWait: v = void 0,
102
- ...c
103
- } = o;
104
- return xe(
119
+ debounce: i = 0,
120
+ maxWait: f = void 0,
121
+ ...s
122
+ } = n;
123
+ return Ie(
105
124
  e,
106
125
  t,
107
126
  {
108
- ...c,
109
- eventFilter: ie(n, { maxWait: v })
127
+ ...s,
128
+ eventFilter: re(i, { maxWait: f })
110
129
  }
111
130
  );
112
131
  }
113
- function We(e, t, o) {
114
- return _(
132
+ function Fe(e, t, n) {
133
+ return A(
115
134
  e,
116
135
  t,
117
136
  {
118
- ...o,
137
+ ...n,
119
138
  immediate: !0
120
139
  }
121
140
  );
122
141
  }
123
- const R = oe ? window : void 0;
124
- function E(e) {
142
+ const F = $ ? window : void 0, Pe = $ ? window.document : void 0;
143
+ function T(e) {
125
144
  var t;
126
- const o = g(e);
127
- return (t = o == null ? void 0 : o.$el) != null ? t : o;
145
+ const n = b(e);
146
+ return (t = n == null ? void 0 : n.$el) != null ? t : n;
128
147
  }
129
- function W(...e) {
130
- const t = [], o = () => {
131
- t.forEach((i) => i()), t.length = 0;
132
- }, n = (i, l, s, h) => (i.addEventListener(l, s, h), () => i.removeEventListener(l, s, h)), v = I(() => {
133
- const i = D(g(e[0])).filter((l) => l != null);
134
- return i.every((l) => typeof l != "string") ? i : void 0;
135
- }), c = We(
148
+ function x(...e) {
149
+ const t = [], n = () => {
150
+ t.forEach((o) => o()), t.length = 0;
151
+ }, i = (o, l, u, d) => (o.addEventListener(l, u, d), () => o.removeEventListener(l, u, d)), f = I(() => {
152
+ const o = C(b(e[0])).filter((l) => l != null);
153
+ return o.every((l) => typeof l != "string") ? o : void 0;
154
+ }), s = Fe(
136
155
  () => {
137
- var i, l;
156
+ var o, l;
138
157
  return [
139
- (l = (i = v.value) == null ? void 0 : i.map((s) => E(s))) != null ? l : [R].filter((s) => s != null),
140
- D(g(v.value ? e[1] : e[0])),
141
- D(de(v.value ? e[2] : e[1])),
158
+ (l = (o = f.value) == null ? void 0 : o.map((u) => T(u))) != null ? l : [F].filter((u) => u != null),
159
+ C(b(f.value ? e[1] : e[0])),
160
+ C(me(f.value ? e[2] : e[1])),
142
161
  // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
143
- g(v.value ? e[3] : e[2])
162
+ b(f.value ? e[3] : e[2])
144
163
  ];
145
164
  },
146
- ([i, l, s, h]) => {
147
- if (o(), !(i != null && i.length) || !(l != null && l.length) || !(s != null && s.length))
165
+ ([o, l, u, d]) => {
166
+ if (n(), !(o != null && o.length) || !(l != null && l.length) || !(u != null && u.length))
148
167
  return;
149
- const r = pe(h) ? { ...h } : h;
168
+ const r = be(d) ? { ...d } : d;
150
169
  t.push(
151
- ...i.flatMap(
152
- (a) => l.flatMap(
153
- (m) => s.map((b) => n(a, m, b, r))
170
+ ...o.flatMap(
171
+ (v) => l.flatMap(
172
+ (h) => u.map((g) => i(v, h, g, r))
154
173
  )
155
174
  )
156
175
  );
157
176
  },
158
177
  { flush: "post" }
159
- ), d = () => {
160
- c(), o();
178
+ ), a = () => {
179
+ s(), n();
161
180
  };
162
- return N(o), d;
181
+ return H(n), a;
163
182
  }
164
- let Z = !1;
165
- function Fe(e, t, o = {}) {
166
- const { window: n = R, ignore: v = [], capture: c = !0, detectIframe: d = !1, controls: i = !1 } = o;
167
- if (!n)
168
- return i ? { stop: x, cancel: x, trigger: x } : x;
169
- if (we && !Z) {
170
- Z = !0;
171
- const u = { passive: !0 };
172
- Array.from(n.document.body.children).forEach((f) => W(f, "click", x, u)), W(n.document.documentElement, "click", x, u);
183
+ let te = !1;
184
+ function Ve(e, t, n = {}) {
185
+ const { window: i = F, ignore: f = [], capture: s = !0, detectIframe: a = !1, controls: o = !1 } = n;
186
+ if (!i)
187
+ return o ? { stop: O, cancel: O, trigger: O } : O;
188
+ if (Se && !te) {
189
+ te = !0;
190
+ const c = { passive: !0 };
191
+ Array.from(i.document.body.children).forEach((m) => x(m, "click", O, c)), x(i.document.documentElement, "click", O, c);
173
192
  }
174
193
  let l = !0;
175
- const s = (u) => g(v).some((f) => {
176
- if (typeof f == "string")
177
- return Array.from(n.document.querySelectorAll(f)).some((p) => p === u.target || u.composedPath().includes(p));
194
+ const u = (c) => b(f).some((m) => {
195
+ if (typeof m == "string")
196
+ return Array.from(i.document.querySelectorAll(m)).some((p) => p === c.target || c.composedPath().includes(p));
178
197
  {
179
- const p = E(f);
180
- return p && (u.target === p || u.composedPath().includes(p));
198
+ const p = T(m);
199
+ return p && (c.target === p || c.composedPath().includes(p));
181
200
  }
182
201
  });
183
- function h(u) {
184
- const f = g(u);
185
- return f && f.$.subTree.shapeFlag === 16;
202
+ function d(c) {
203
+ const m = b(c);
204
+ return m && m.$.subTree.shapeFlag === 16;
186
205
  }
187
- function r(u, f) {
188
- const p = g(u), F = p.$.subTree && p.$.subTree.children;
189
- return F == null || !Array.isArray(F) ? !1 : F.some((L) => L.el === f.target || f.composedPath().includes(L.el));
206
+ function r(c, m) {
207
+ const p = b(c), _ = p.$.subTree && p.$.subTree.children;
208
+ return _ == null || !Array.isArray(_) ? !1 : _.some((L) => L.el === m.target || m.composedPath().includes(L.el));
190
209
  }
191
- const a = (u) => {
192
- const f = E(e);
193
- if (u.target != null && !(!(f instanceof Element) && h(e) && r(e, u)) && !(!f || f === u.target || u.composedPath().includes(f))) {
194
- if ("detail" in u && u.detail === 0 && (l = !s(u)), !l) {
210
+ const v = (c) => {
211
+ const m = T(e);
212
+ if (c.target != null && !(!(m instanceof Element) && d(e) && r(e, c)) && !(!m || m === c.target || c.composedPath().includes(m))) {
213
+ if ("detail" in c && c.detail === 0 && (l = !u(c)), !l) {
195
214
  l = !0;
196
215
  return;
197
216
  }
198
- t(u);
217
+ t(c);
199
218
  }
200
219
  };
201
- let m = !1;
202
- const b = [
203
- W(n, "click", (u) => {
204
- m || (m = !0, setTimeout(() => {
205
- m = !1;
206
- }, 0), a(u));
207
- }, { passive: !0, capture: c }),
208
- W(n, "pointerdown", (u) => {
209
- const f = E(e);
210
- l = !s(u) && !!(f && !u.composedPath().includes(f));
220
+ let h = !1;
221
+ const g = [
222
+ x(i, "click", (c) => {
223
+ h || (h = !0, setTimeout(() => {
224
+ h = !1;
225
+ }, 0), v(c));
226
+ }, { passive: !0, capture: s }),
227
+ x(i, "pointerdown", (c) => {
228
+ const m = T(e);
229
+ l = !u(c) && !!(m && !c.composedPath().includes(m));
211
230
  }, { passive: !0 }),
212
- d && W(n, "blur", (u) => {
231
+ a && x(i, "blur", (c) => {
213
232
  setTimeout(() => {
214
- var f;
215
- const p = E(e);
216
- ((f = n.document.activeElement) == null ? void 0 : f.tagName) === "IFRAME" && !(p != null && p.contains(n.document.activeElement)) && t(u);
233
+ var m;
234
+ const p = T(e);
235
+ ((m = i.document.activeElement) == null ? void 0 : m.tagName) === "IFRAME" && !(p != null && p.contains(i.document.activeElement)) && t(c);
217
236
  }, 0);
218
237
  }, { passive: !0 })
219
- ].filter(Boolean), y = () => b.forEach((u) => u());
220
- return i ? {
221
- stop: y,
238
+ ].filter(Boolean), S = () => g.forEach((c) => c());
239
+ return o ? {
240
+ stop: S,
222
241
  cancel: () => {
223
242
  l = !1;
224
243
  },
225
- trigger: (u) => {
226
- l = !0, a(u), l = !1;
244
+ trigger: (c) => {
245
+ l = !0, v(c), l = !1;
227
246
  }
228
- } : y;
247
+ } : S;
229
248
  }
230
- function Me() {
231
- const e = S(!1), t = B();
232
- return t && te(() => {
249
+ function Re() {
250
+ const e = y(!1), t = B();
251
+ return t && oe(() => {
233
252
  e.value = !0;
234
253
  }, t), e;
235
254
  }
236
- function G(e) {
237
- const t = Me();
255
+ function Y(e) {
256
+ const t = Re();
238
257
  return I(() => (t.value, !!e()));
239
258
  }
240
- function Oe(e, t, o = {}) {
241
- const { window: n = R, ...v } = o;
242
- let c;
243
- const d = G(() => n && "MutationObserver" in n), i = () => {
244
- c && (c.disconnect(), c = void 0);
259
+ function Ae(e, t, n = {}) {
260
+ const { window: i = F, ...f } = n;
261
+ let s;
262
+ const a = Y(() => i && "MutationObserver" in i), o = () => {
263
+ s && (s.disconnect(), s = void 0);
245
264
  }, l = I(() => {
246
- const a = g(e), m = D(a).map(E).filter(he);
247
- return new Set(m);
248
- }), s = _(
265
+ const v = b(e), h = C(v).map(T).filter(we);
266
+ return new Set(h);
267
+ }), u = A(
249
268
  () => l.value,
250
- (a) => {
251
- i(), d.value && a.size && (c = new MutationObserver(t), a.forEach((m) => c.observe(m, v)));
269
+ (v) => {
270
+ o(), a.value && v.size && (s = new MutationObserver(t), v.forEach((h) => s.observe(h, f)));
252
271
  },
253
272
  { immediate: !0, flush: "post" }
254
- ), h = () => c == null ? void 0 : c.takeRecords(), r = () => {
255
- s(), i();
273
+ ), d = () => s == null ? void 0 : s.takeRecords(), r = () => {
274
+ u(), o();
256
275
  };
257
- return N(r), {
258
- isSupported: d,
276
+ return H(r), {
277
+ isSupported: a,
259
278
  stop: r,
260
- takeRecords: h
279
+ takeRecords: d
261
280
  };
262
281
  }
263
- const Ie = Symbol("vueuse-ssr-width");
264
- function Re() {
265
- const e = ne() ? ve(Ie, null) : null;
282
+ const _e = Symbol("vueuse-ssr-width");
283
+ function De() {
284
+ const e = ie() ? pe(_e, null) : null;
266
285
  return typeof e == "number" ? e : void 0;
267
286
  }
268
- function Pe(e, t = {}) {
269
- const { window: o = R, ssrWidth: n = Re() } = t, v = G(() => o && "matchMedia" in o && typeof o.matchMedia == "function"), c = S(typeof n == "number"), d = S(), i = S(!1), l = (s) => {
270
- i.value = s.matches;
287
+ function ke(e, t = {}) {
288
+ const { window: n = F, ssrWidth: i = De() } = t, f = Y(() => n && "matchMedia" in n && typeof n.matchMedia == "function"), s = y(typeof i == "number"), a = y(), o = y(!1), l = (u) => {
289
+ o.value = u.matches;
271
290
  };
272
- return fe(() => {
273
- if (c.value) {
274
- c.value = !v.value;
275
- const s = g(e).split(",");
276
- i.value = s.some((h) => {
277
- const r = h.includes("not all"), a = h.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), m = h.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
278
- let b = !!(a || m);
279
- return a && b && (b = n >= K(a[1])), m && b && (b = n <= K(m[1])), r ? !b : b;
291
+ return he(() => {
292
+ if (s.value) {
293
+ s.value = !f.value;
294
+ const u = b(e).split(",");
295
+ o.value = u.some((d) => {
296
+ const r = d.includes("not all"), v = d.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), h = d.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
297
+ let g = !!(v || h);
298
+ return v && g && (g = i >= ee(v[1])), h && g && (g = i <= ee(h[1])), r ? !g : g;
280
299
  });
281
300
  return;
282
301
  }
283
- v.value && (d.value = o.matchMedia(g(e)), i.value = d.value.matches);
284
- }), W(d, "change", l, { passive: !0 }), I(() => i.value);
302
+ f.value && (a.value = n.matchMedia(b(e)), o.value = a.value.matches);
303
+ }), x(a, "change", l, { passive: !0 }), I(() => o.value);
285
304
  }
286
- function le(e, t, o = {}) {
287
- const { window: n = R, ...v } = o;
288
- let c;
289
- const d = G(() => n && "ResizeObserver" in n), i = () => {
290
- c && (c.disconnect(), c = void 0);
305
+ function le(e, t, n = {}) {
306
+ const { window: i = F, ...f } = n;
307
+ let s;
308
+ const a = Y(() => i && "ResizeObserver" in i), o = () => {
309
+ s && (s.disconnect(), s = void 0);
291
310
  }, l = I(() => {
292
- const r = g(e);
293
- return Array.isArray(r) ? r.map((a) => E(a)) : [E(r)];
294
- }), s = _(
311
+ const r = b(e);
312
+ return Array.isArray(r) ? r.map((v) => T(v)) : [T(r)];
313
+ }), u = A(
295
314
  l,
296
315
  (r) => {
297
- if (i(), d.value && n) {
298
- c = new ResizeObserver(t);
299
- for (const a of r)
300
- a && c.observe(a, v);
316
+ if (o(), a.value && i) {
317
+ s = new ResizeObserver(t);
318
+ for (const v of r)
319
+ v && s.observe(v, f);
301
320
  }
302
321
  },
303
322
  { immediate: !0, flush: "post" }
304
- ), h = () => {
305
- i(), s();
323
+ ), d = () => {
324
+ o(), u();
306
325
  };
307
- return N(h), {
308
- isSupported: d,
309
- stop: h
326
+ return H(d), {
327
+ isSupported: a,
328
+ stop: d
310
329
  };
311
330
  }
312
- function Ce(e, t = {}) {
331
+ function ze(e, t = {}) {
313
332
  const {
314
- reset: o = !0,
315
- windowResize: n = !0,
316
- windowScroll: v = !0,
317
- immediate: c = !0,
318
- updateTiming: d = "sync"
319
- } = t, i = S(0), l = S(0), s = S(0), h = S(0), r = S(0), a = S(0), m = S(0), b = S(0);
320
- function y() {
321
- const f = E(e);
322
- if (!f) {
323
- o && (i.value = 0, l.value = 0, s.value = 0, h.value = 0, r.value = 0, a.value = 0, m.value = 0, b.value = 0);
333
+ reset: n = !0,
334
+ windowResize: i = !0,
335
+ windowScroll: f = !0,
336
+ immediate: s = !0,
337
+ updateTiming: a = "sync"
338
+ } = t, o = y(0), l = y(0), u = y(0), d = y(0), r = y(0), v = y(0), h = y(0), g = y(0);
339
+ function S() {
340
+ const m = T(e);
341
+ if (!m) {
342
+ n && (o.value = 0, l.value = 0, u.value = 0, d.value = 0, r.value = 0, v.value = 0, h.value = 0, g.value = 0);
324
343
  return;
325
344
  }
326
- const p = f.getBoundingClientRect();
327
- i.value = p.height, l.value = p.bottom, s.value = p.left, h.value = p.right, r.value = p.top, a.value = p.width, m.value = p.x, b.value = p.y;
345
+ const p = m.getBoundingClientRect();
346
+ o.value = p.height, l.value = p.bottom, u.value = p.left, d.value = p.right, r.value = p.top, v.value = p.width, h.value = p.x, g.value = p.y;
328
347
  }
329
- function u() {
330
- d === "sync" ? y() : d === "next-frame" && requestAnimationFrame(() => y());
348
+ function c() {
349
+ a === "sync" ? S() : a === "next-frame" && requestAnimationFrame(() => S());
331
350
  }
332
- return le(e, u), _(() => E(e), (f) => !f && u()), Oe(e, u, {
351
+ return le(e, c), A(() => T(e), (m) => !m && c()), Ae(e, c, {
333
352
  attributeFilter: ["style", "class"]
334
- }), v && W("scroll", u, { capture: !0, passive: !0 }), n && W("resize", u, { passive: !0 }), V(() => {
335
- c && u();
353
+ }), f && x("scroll", c, { capture: !0, passive: !0 }), i && x("resize", c, { passive: !0 }), V(() => {
354
+ s && c();
336
355
  }), {
337
- height: i,
356
+ height: o,
338
357
  bottom: l,
339
- left: s,
340
- right: h,
358
+ left: u,
359
+ right: d,
341
360
  top: r,
342
- width: a,
343
- x: m,
344
- y: b,
345
- update: u
361
+ width: v,
362
+ x: h,
363
+ y: g,
364
+ update: c
346
365
  };
347
366
  }
348
- function ke(e, t = { width: 0, height: 0 }, o = {}) {
349
- const { window: n = R, box: v = "content-box" } = o, c = I(() => {
350
- var r, a;
351
- return (a = (r = E(e)) == null ? void 0 : r.namespaceURI) == null ? void 0 : a.includes("svg");
352
- }), d = S(t.width), i = S(t.height), { stop: l } = le(
367
+ function Ne(e, t = { width: 0, height: 0 }, n = {}) {
368
+ const { window: i = F, box: f = "content-box" } = n, s = I(() => {
369
+ var r, v;
370
+ return (v = (r = T(e)) == null ? void 0 : r.namespaceURI) == null ? void 0 : v.includes("svg");
371
+ }), a = y(t.width), o = y(t.height), { stop: l } = le(
353
372
  e,
354
373
  ([r]) => {
355
- const a = v === "border-box" ? r.borderBoxSize : v === "content-box" ? r.contentBoxSize : r.devicePixelContentBoxSize;
356
- if (n && c.value) {
357
- const m = E(e);
358
- if (m) {
359
- const b = m.getBoundingClientRect();
360
- d.value = b.width, i.value = b.height;
374
+ const v = f === "border-box" ? r.borderBoxSize : f === "content-box" ? r.contentBoxSize : r.devicePixelContentBoxSize;
375
+ if (i && s.value) {
376
+ const h = T(e);
377
+ if (h) {
378
+ const g = h.getBoundingClientRect();
379
+ a.value = g.width, o.value = g.height;
361
380
  }
362
- } else if (a) {
363
- const m = D(a);
364
- d.value = m.reduce((b, { inlineSize: y }) => b + y, 0), i.value = m.reduce((b, { blockSize: y }) => b + y, 0);
381
+ } else if (v) {
382
+ const h = C(v);
383
+ a.value = h.reduce((g, { inlineSize: S }) => g + S, 0), o.value = h.reduce((g, { blockSize: S }) => g + S, 0);
365
384
  } else
366
- d.value = r.contentRect.width, i.value = r.contentRect.height;
385
+ a.value = r.contentRect.width, o.value = r.contentRect.height;
367
386
  },
368
- o
387
+ n
369
388
  );
370
389
  V(() => {
371
- const r = E(e);
372
- r && (d.value = "offsetWidth" in r ? r.offsetWidth : t.width, i.value = "offsetHeight" in r ? r.offsetHeight : t.height);
390
+ const r = T(e);
391
+ r && (a.value = "offsetWidth" in r ? r.offsetWidth : t.width, o.value = "offsetHeight" in r ? r.offsetHeight : t.height);
373
392
  });
374
- const s = _(
375
- () => E(e),
393
+ const u = A(
394
+ () => T(e),
376
395
  (r) => {
377
- d.value = r ? t.width : 0, i.value = r ? t.height : 0;
396
+ a.value = r ? t.width : 0, o.value = r ? t.height : 0;
378
397
  }
379
398
  );
380
- function h() {
381
- l(), s();
399
+ function d() {
400
+ l(), u();
382
401
  }
383
402
  return {
384
- width: d,
385
- height: i,
386
- stop: h
403
+ width: a,
404
+ height: o,
405
+ stop: d
406
+ };
407
+ }
408
+ const Ce = {
409
+ multiple: !0,
410
+ accept: "*",
411
+ reset: !1,
412
+ directory: !1
413
+ };
414
+ function Le(e) {
415
+ if (!e)
416
+ return null;
417
+ if (e instanceof FileList)
418
+ return e;
419
+ const t = new DataTransfer();
420
+ for (const n of e)
421
+ t.items.add(n);
422
+ return t.files;
423
+ }
424
+ function Be(e = {}) {
425
+ const {
426
+ document: t = Pe
427
+ } = e, n = de(Le(e.initialFiles)), { on: i, trigger: f } = Z(), { on: s, trigger: a } = Z();
428
+ let o;
429
+ t && (o = t.createElement("input"), o.type = "file", o.onchange = (d) => {
430
+ const r = d.target;
431
+ n.value = r.files, f(n.value);
432
+ }, o.oncancel = () => {
433
+ a();
434
+ });
435
+ const l = () => {
436
+ n.value = null, o && o.value && (o.value = "", f(null));
437
+ }, u = (d) => {
438
+ if (!o)
439
+ return;
440
+ const r = {
441
+ ...Ce,
442
+ ...e,
443
+ ...d
444
+ };
445
+ o.multiple = r.multiple, o.accept = r.accept, o.webkitdirectory = r.directory, ye(r, "capture") && (o.capture = r.capture), r.reset && l(), o.click();
446
+ };
447
+ return {
448
+ files: ve(n),
449
+ open: u,
450
+ reset: l,
451
+ onCancel: s,
452
+ onChange: i
387
453
  };
388
454
  }
389
- const ee = 1;
390
- function De(e, t = {}) {
455
+ const ne = 1;
456
+ function $e(e, t = {}) {
391
457
  const {
392
- throttle: o = 0,
393
- idle: n = 200,
394
- onStop: v = x,
395
- onScroll: c = x,
396
- offset: d = {
458
+ throttle: n = 0,
459
+ idle: i = 200,
460
+ onStop: f = O,
461
+ onScroll: s = O,
462
+ offset: a = {
397
463
  left: 0,
398
464
  right: 0,
399
465
  top: 0,
400
466
  bottom: 0
401
467
  },
402
- eventListenerOptions: i = {
468
+ eventListenerOptions: o = {
403
469
  capture: !1,
404
470
  passive: !0
405
471
  },
406
472
  behavior: l = "auto",
407
- window: s = R,
408
- onError: h = (w) => {
473
+ window: u = F,
474
+ onError: d = (w) => {
409
475
  console.error(w);
410
476
  }
411
- } = t, r = S(0), a = S(0), m = I({
477
+ } = t, r = y(0), v = y(0), h = I({
412
478
  get() {
413
479
  return r.value;
414
480
  },
415
481
  set(w) {
416
- y(w, void 0);
482
+ S(w, void 0);
417
483
  }
418
- }), b = I({
484
+ }), g = I({
419
485
  get() {
420
- return a.value;
486
+ return v.value;
421
487
  },
422
488
  set(w) {
423
- y(void 0, w);
489
+ S(void 0, w);
424
490
  }
425
491
  });
426
- function y(w, P) {
427
- var T, C, k, j;
428
- if (!s)
492
+ function S(w, P) {
493
+ var E, D, k, j;
494
+ if (!u)
429
495
  return;
430
- const M = g(e);
431
- if (!M)
496
+ const W = b(e);
497
+ if (!W)
432
498
  return;
433
- (k = M instanceof Document ? s.document.body : M) == null || k.scrollTo({
434
- top: (T = g(P)) != null ? T : b.value,
435
- left: (C = g(w)) != null ? C : m.value,
436
- behavior: g(l)
499
+ (k = W instanceof Document ? u.document.body : W) == null || k.scrollTo({
500
+ top: (E = b(P)) != null ? E : g.value,
501
+ left: (D = b(w)) != null ? D : h.value,
502
+ behavior: b(l)
437
503
  });
438
- const O = ((j = M == null ? void 0 : M.document) == null ? void 0 : j.documentElement) || (M == null ? void 0 : M.documentElement) || M;
439
- m != null && (r.value = O.scrollLeft), b != null && (a.value = O.scrollTop);
504
+ const M = ((j = W == null ? void 0 : W.document) == null ? void 0 : j.documentElement) || (W == null ? void 0 : W.documentElement) || W;
505
+ h != null && (r.value = M.scrollLeft), g != null && (v.value = M.scrollTop);
440
506
  }
441
- const u = S(!1), f = J({
507
+ const c = y(!1), m = K({
442
508
  left: !0,
443
509
  right: !1,
444
510
  top: !0,
445
511
  bottom: !1
446
- }), p = J({
512
+ }), p = K({
447
513
  left: !1,
448
514
  right: !1,
449
515
  top: !1,
450
516
  bottom: !1
451
- }), F = (w) => {
452
- u.value && (u.value = !1, p.left = !1, p.right = !1, p.top = !1, p.bottom = !1, v(w));
453
- }, L = Ee(F, o + n), z = (w) => {
517
+ }), _ = (w) => {
518
+ c.value && (c.value = !1, p.left = !1, p.right = !1, p.top = !1, p.bottom = !1, f(w));
519
+ }, L = We(_, n + i), z = (w) => {
454
520
  var P;
455
- if (!s)
521
+ if (!u)
456
522
  return;
457
- const T = ((P = w == null ? void 0 : w.document) == null ? void 0 : P.documentElement) || (w == null ? void 0 : w.documentElement) || E(w), { display: C, flexDirection: k, direction: j } = getComputedStyle(T), M = j === "rtl" ? -1 : 1, O = T.scrollLeft;
458
- p.left = O < r.value, p.right = O > r.value;
459
- const Q = Math.abs(O * M) <= (d.left || 0), X = Math.abs(O * M) + T.clientWidth >= T.scrollWidth - (d.right || 0) - ee;
460
- C === "flex" && k === "row-reverse" ? (f.left = X, f.right = Q) : (f.left = Q, f.right = X), r.value = O;
461
- let A = T.scrollTop;
462
- w === s.document && !A && (A = s.document.body.scrollTop), p.top = A < a.value, p.bottom = A > a.value;
463
- const U = Math.abs(A) <= (d.top || 0), q = Math.abs(A) + T.clientHeight >= T.scrollHeight - (d.bottom || 0) - ee;
464
- C === "flex" && k === "column-reverse" ? (f.top = q, f.bottom = U) : (f.top = U, f.bottom = q), a.value = A;
465
- }, Y = (w) => {
523
+ const E = ((P = w == null ? void 0 : w.document) == null ? void 0 : P.documentElement) || (w == null ? void 0 : w.documentElement) || T(w), { display: D, flexDirection: k, direction: j } = getComputedStyle(E), W = j === "rtl" ? -1 : 1, M = E.scrollLeft;
524
+ p.left = M < r.value, p.right = M > r.value;
525
+ const U = Math.abs(M * W) <= (a.left || 0), X = Math.abs(M * W) + E.clientWidth >= E.scrollWidth - (a.right || 0) - ne;
526
+ D === "flex" && k === "row-reverse" ? (m.left = X, m.right = U) : (m.left = U, m.right = X), r.value = M;
527
+ let R = E.scrollTop;
528
+ w === u.document && !R && (R = u.document.body.scrollTop), p.top = R < v.value, p.bottom = R > v.value;
529
+ const q = Math.abs(R) <= (a.top || 0), J = Math.abs(R) + E.clientHeight >= E.scrollHeight - (a.bottom || 0) - ne;
530
+ D === "flex" && k === "column-reverse" ? (m.top = J, m.bottom = q) : (m.top = q, m.bottom = J), v.value = R;
531
+ }, Q = (w) => {
466
532
  var P;
467
- if (!s)
533
+ if (!u)
468
534
  return;
469
- const T = (P = w.target.documentElement) != null ? P : w.target;
470
- z(T), u.value = !0, L(w), c(w);
535
+ const E = (P = w.target.documentElement) != null ? P : w.target;
536
+ z(E), c.value = !0, L(w), s(w);
471
537
  };
472
- return W(
538
+ return x(
473
539
  e,
474
540
  "scroll",
475
- o ? Te(Y, o, !0, !1) : Y,
476
- i
541
+ n ? Me(Q, n, !0, !1) : Q,
542
+ o
477
543
  ), V(() => {
478
544
  try {
479
- const w = g(e);
545
+ const w = b(e);
480
546
  if (!w)
481
547
  return;
482
548
  z(w);
483
549
  } catch (w) {
484
- h(w);
550
+ d(w);
485
551
  }
486
- }), W(
552
+ }), x(
487
553
  e,
488
554
  "scrollend",
489
- F,
490
- i
555
+ _,
556
+ o
491
557
  ), {
492
- x: m,
493
- y: b,
494
- isScrolling: u,
495
- arrivedState: f,
558
+ x: h,
559
+ y: g,
560
+ isScrolling: c,
561
+ arrivedState: m,
496
562
  directions: p,
497
563
  measure() {
498
- const w = g(e);
499
- s && w && z(w);
564
+ const w = b(e);
565
+ u && w && z(w);
500
566
  }
501
567
  };
502
568
  }
503
- function Le(e = {}) {
569
+ function Ge(e = {}) {
504
570
  const {
505
- window: t = R,
506
- initialWidth: o = Number.POSITIVE_INFINITY,
507
- initialHeight: n = Number.POSITIVE_INFINITY,
508
- listenOrientation: v = !0,
509
- includeScrollbar: c = !0,
510
- type: d = "inner"
511
- } = e, i = S(o), l = S(n), s = () => {
571
+ window: t = F,
572
+ initialWidth: n = Number.POSITIVE_INFINITY,
573
+ initialHeight: i = Number.POSITIVE_INFINITY,
574
+ listenOrientation: f = !0,
575
+ includeScrollbar: s = !0,
576
+ type: a = "inner"
577
+ } = e, o = y(n), l = y(i), u = () => {
512
578
  if (t)
513
- if (d === "outer")
514
- i.value = t.outerWidth, l.value = t.outerHeight;
515
- else if (d === "visual" && t.visualViewport) {
516
- const { width: r, height: a, scale: m } = t.visualViewport;
517
- i.value = Math.round(r * m), l.value = Math.round(a * m);
518
- } else c ? (i.value = t.innerWidth, l.value = t.innerHeight) : (i.value = t.document.documentElement.clientWidth, l.value = t.document.documentElement.clientHeight);
579
+ if (a === "outer")
580
+ o.value = t.outerWidth, l.value = t.outerHeight;
581
+ else if (a === "visual" && t.visualViewport) {
582
+ const { width: r, height: v, scale: h } = t.visualViewport;
583
+ o.value = Math.round(r * h), l.value = Math.round(v * h);
584
+ } else s ? (o.value = t.innerWidth, l.value = t.innerHeight) : (o.value = t.document.documentElement.clientWidth, l.value = t.document.documentElement.clientHeight);
519
585
  };
520
- s(), V(s);
521
- const h = { passive: !0 };
522
- if (W("resize", s, h), t && d === "visual" && t.visualViewport && W(t.visualViewport, "resize", s, h), v) {
523
- const r = Pe("(orientation: portrait)");
524
- _(r, () => s());
586
+ u(), V(u);
587
+ const d = { passive: !0 };
588
+ if (x("resize", u, d), t && a === "visual" && t.visualViewport && x(t.visualViewport, "resize", u, d), f) {
589
+ const r = ke("(orientation: portrait)");
590
+ A(r, () => u());
525
591
  }
526
- return { width: i, height: l };
592
+ return { width: o, height: l };
527
593
  }
528
594
  export {
529
- Le as a,
530
- ke as b,
531
- Ce as c,
532
- Pe as d,
533
- Fe as o,
534
- De as u,
535
- _e as w
595
+ $e as a,
596
+ Ge as b,
597
+ Ne as c,
598
+ ze as d,
599
+ ke as e,
600
+ Ve as o,
601
+ Be as u,
602
+ He as w
536
603
  };