@bquery/bquery 1.1.2 → 1.3.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.
Files changed (307) hide show
  1. package/README.md +501 -323
  2. package/dist/batch-4LAvfLE7.js +13 -0
  3. package/dist/batch-4LAvfLE7.js.map +1 -0
  4. package/dist/component/component.d.ts +69 -0
  5. package/dist/component/component.d.ts.map +1 -0
  6. package/dist/component/html.d.ts +35 -0
  7. package/dist/component/html.d.ts.map +1 -0
  8. package/dist/component/index.d.ts +3 -126
  9. package/dist/component/index.d.ts.map +1 -1
  10. package/dist/component/props.d.ts +18 -0
  11. package/dist/component/props.d.ts.map +1 -0
  12. package/dist/component/types.d.ts +77 -0
  13. package/dist/component/types.d.ts.map +1 -0
  14. package/dist/component.es.mjs +90 -59
  15. package/dist/component.es.mjs.map +1 -1
  16. package/dist/core/collection.d.ts +36 -0
  17. package/dist/core/collection.d.ts.map +1 -1
  18. package/dist/core/dom.d.ts +6 -0
  19. package/dist/core/dom.d.ts.map +1 -0
  20. package/dist/core/element.d.ts +8 -0
  21. package/dist/core/element.d.ts.map +1 -1
  22. package/dist/core/index.d.ts +1 -0
  23. package/dist/core/index.d.ts.map +1 -1
  24. package/dist/core/utils/array.d.ts +74 -0
  25. package/dist/core/utils/array.d.ts.map +1 -0
  26. package/dist/core/utils/function.d.ts +70 -0
  27. package/dist/core/utils/function.d.ts.map +1 -0
  28. package/dist/core/utils/index.d.ts +70 -0
  29. package/dist/core/utils/index.d.ts.map +1 -0
  30. package/dist/core/utils/misc.d.ts +63 -0
  31. package/dist/core/utils/misc.d.ts.map +1 -0
  32. package/dist/core/utils/number.d.ts +65 -0
  33. package/dist/core/utils/number.d.ts.map +1 -0
  34. package/dist/core/utils/object.d.ts +133 -0
  35. package/dist/core/utils/object.d.ts.map +1 -0
  36. package/dist/core/utils/string.d.ts +80 -0
  37. package/dist/core/utils/string.d.ts.map +1 -0
  38. package/dist/core/utils/type-guards.d.ts +79 -0
  39. package/dist/core/utils/type-guards.d.ts.map +1 -0
  40. package/dist/core-COenAZjD.js +145 -0
  41. package/dist/core-COenAZjD.js.map +1 -0
  42. package/dist/core.es.mjs +411 -448
  43. package/dist/core.es.mjs.map +1 -1
  44. package/dist/full.d.ts +8 -2
  45. package/dist/full.d.ts.map +1 -1
  46. package/dist/full.es.mjs +86 -40
  47. package/dist/full.es.mjs.map +1 -1
  48. package/dist/full.iife.js +6 -1
  49. package/dist/full.iife.js.map +1 -1
  50. package/dist/full.umd.js +6 -1
  51. package/dist/full.umd.js.map +1 -1
  52. package/dist/index.d.ts +3 -0
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.es.mjs +137 -44
  55. package/dist/index.es.mjs.map +1 -1
  56. package/dist/motion/animate.d.ts +25 -0
  57. package/dist/motion/animate.d.ts.map +1 -0
  58. package/dist/motion/easing.d.ts +30 -0
  59. package/dist/motion/easing.d.ts.map +1 -0
  60. package/dist/motion/flip.d.ts +55 -0
  61. package/dist/motion/flip.d.ts.map +1 -0
  62. package/dist/motion/index.d.ts +11 -138
  63. package/dist/motion/index.d.ts.map +1 -1
  64. package/dist/motion/keyframes.d.ts +21 -0
  65. package/dist/motion/keyframes.d.ts.map +1 -0
  66. package/dist/motion/reduced-motion.d.ts +12 -0
  67. package/dist/motion/reduced-motion.d.ts.map +1 -0
  68. package/dist/motion/scroll.d.ts +15 -0
  69. package/dist/motion/scroll.d.ts.map +1 -0
  70. package/dist/motion/spring.d.ts +42 -0
  71. package/dist/motion/spring.d.ts.map +1 -0
  72. package/dist/motion/stagger.d.ts +22 -0
  73. package/dist/motion/stagger.d.ts.map +1 -0
  74. package/dist/motion/timeline.d.ts +21 -0
  75. package/dist/motion/timeline.d.ts.map +1 -0
  76. package/dist/motion/transition.d.ts +22 -0
  77. package/dist/motion/transition.d.ts.map +1 -0
  78. package/dist/motion/types.d.ts +182 -0
  79. package/dist/motion/types.d.ts.map +1 -0
  80. package/dist/motion.es.mjs +320 -61
  81. package/dist/motion.es.mjs.map +1 -1
  82. package/dist/persisted-Dz_ryNuC.js +278 -0
  83. package/dist/persisted-Dz_ryNuC.js.map +1 -0
  84. package/dist/reactive/batch.d.ts +13 -0
  85. package/dist/reactive/batch.d.ts.map +1 -0
  86. package/dist/reactive/computed.d.ts +50 -0
  87. package/dist/reactive/computed.d.ts.map +1 -0
  88. package/dist/reactive/core.d.ts +60 -0
  89. package/dist/reactive/core.d.ts.map +1 -0
  90. package/dist/reactive/effect.d.ts +15 -0
  91. package/dist/reactive/effect.d.ts.map +1 -0
  92. package/dist/reactive/index.d.ts +2 -2
  93. package/dist/reactive/index.d.ts.map +1 -1
  94. package/dist/reactive/internals.d.ts +36 -0
  95. package/dist/reactive/internals.d.ts.map +1 -0
  96. package/dist/reactive/linked.d.ts +36 -0
  97. package/dist/reactive/linked.d.ts.map +1 -0
  98. package/dist/reactive/persisted.d.ts +14 -0
  99. package/dist/reactive/persisted.d.ts.map +1 -0
  100. package/dist/reactive/readonly.d.ts +26 -0
  101. package/dist/reactive/readonly.d.ts.map +1 -0
  102. package/dist/reactive/signal.d.ts +13 -305
  103. package/dist/reactive/signal.d.ts.map +1 -1
  104. package/dist/reactive/type-guards.d.ts +20 -0
  105. package/dist/reactive/type-guards.d.ts.map +1 -0
  106. package/dist/reactive/untrack.d.ts +29 -0
  107. package/dist/reactive/untrack.d.ts.map +1 -0
  108. package/dist/reactive/watch.d.ts +42 -0
  109. package/dist/reactive/watch.d.ts.map +1 -0
  110. package/dist/reactive.es.mjs +30 -154
  111. package/dist/reactive.es.mjs.map +1 -1
  112. package/dist/router/index.d.ts +41 -0
  113. package/dist/router/index.d.ts.map +1 -0
  114. package/dist/router/links.d.ts +44 -0
  115. package/dist/router/links.d.ts.map +1 -0
  116. package/dist/router/match.d.ts +20 -0
  117. package/dist/router/match.d.ts.map +1 -0
  118. package/dist/router/navigation.d.ts +45 -0
  119. package/dist/router/navigation.d.ts.map +1 -0
  120. package/dist/router/query.d.ts +16 -0
  121. package/dist/router/query.d.ts.map +1 -0
  122. package/dist/router/router.d.ts +34 -0
  123. package/dist/router/router.d.ts.map +1 -0
  124. package/dist/router/state.d.ts +27 -0
  125. package/dist/router/state.d.ts.map +1 -0
  126. package/dist/router/types.d.ts +88 -0
  127. package/dist/router/types.d.ts.map +1 -0
  128. package/dist/router/utils.d.ts +65 -0
  129. package/dist/router/utils.d.ts.map +1 -0
  130. package/dist/router.es.mjs +202 -0
  131. package/dist/router.es.mjs.map +1 -0
  132. package/dist/sanitize-1FBEPAFH.js +272 -0
  133. package/dist/sanitize-1FBEPAFH.js.map +1 -0
  134. package/dist/security/constants.d.ts +42 -0
  135. package/dist/security/constants.d.ts.map +1 -0
  136. package/dist/security/csp.d.ts +24 -0
  137. package/dist/security/csp.d.ts.map +1 -0
  138. package/dist/security/index.d.ts +4 -2
  139. package/dist/security/index.d.ts.map +1 -1
  140. package/dist/security/sanitize-core.d.ts +13 -0
  141. package/dist/security/sanitize-core.d.ts.map +1 -0
  142. package/dist/security/sanitize.d.ts +5 -57
  143. package/dist/security/sanitize.d.ts.map +1 -1
  144. package/dist/security/trusted-types.d.ts +25 -0
  145. package/dist/security/trusted-types.d.ts.map +1 -0
  146. package/dist/security/types.d.ts +36 -0
  147. package/dist/security/types.d.ts.map +1 -0
  148. package/dist/security.es.mjs +50 -277
  149. package/dist/security.es.mjs.map +1 -1
  150. package/dist/store/create-store.d.ts +15 -0
  151. package/dist/store/create-store.d.ts.map +1 -0
  152. package/dist/store/define-store.d.ts +28 -0
  153. package/dist/store/define-store.d.ts.map +1 -0
  154. package/dist/store/devtools.d.ts +22 -0
  155. package/dist/store/devtools.d.ts.map +1 -0
  156. package/dist/store/index.d.ts +12 -0
  157. package/dist/store/index.d.ts.map +1 -0
  158. package/dist/store/mapping.d.ts +28 -0
  159. package/dist/store/mapping.d.ts.map +1 -0
  160. package/dist/store/persisted.d.ts +13 -0
  161. package/dist/store/persisted.d.ts.map +1 -0
  162. package/dist/store/plugins.d.ts +13 -0
  163. package/dist/store/plugins.d.ts.map +1 -0
  164. package/dist/store/registry.d.ts +28 -0
  165. package/dist/store/registry.d.ts.map +1 -0
  166. package/dist/store/types.d.ts +71 -0
  167. package/dist/store/types.d.ts.map +1 -0
  168. package/dist/store/utils.d.ts +28 -0
  169. package/dist/store/utils.d.ts.map +1 -0
  170. package/dist/store/watch.d.ts +23 -0
  171. package/dist/store/watch.d.ts.map +1 -0
  172. package/dist/store.es.mjs +27 -0
  173. package/dist/store.es.mjs.map +1 -0
  174. package/dist/type-guards-DRma3-Kc.js +16 -0
  175. package/dist/type-guards-DRma3-Kc.js.map +1 -0
  176. package/dist/untrack-BuEQKH7_.js +6 -0
  177. package/dist/untrack-BuEQKH7_.js.map +1 -0
  178. package/dist/view/directives/bind.d.ts +7 -0
  179. package/dist/view/directives/bind.d.ts.map +1 -0
  180. package/dist/view/directives/class.d.ts +8 -0
  181. package/dist/view/directives/class.d.ts.map +1 -0
  182. package/dist/view/directives/for.d.ts +23 -0
  183. package/dist/view/directives/for.d.ts.map +1 -0
  184. package/dist/view/directives/html.d.ts +7 -0
  185. package/dist/view/directives/html.d.ts.map +1 -0
  186. package/dist/view/directives/if.d.ts +7 -0
  187. package/dist/view/directives/if.d.ts.map +1 -0
  188. package/dist/view/directives/index.d.ts +12 -0
  189. package/dist/view/directives/index.d.ts.map +1 -0
  190. package/dist/view/directives/model.d.ts +7 -0
  191. package/dist/view/directives/model.d.ts.map +1 -0
  192. package/dist/view/directives/on.d.ts +7 -0
  193. package/dist/view/directives/on.d.ts.map +1 -0
  194. package/dist/view/directives/ref.d.ts +7 -0
  195. package/dist/view/directives/ref.d.ts.map +1 -0
  196. package/dist/view/directives/show.d.ts +7 -0
  197. package/dist/view/directives/show.d.ts.map +1 -0
  198. package/dist/view/directives/style.d.ts +7 -0
  199. package/dist/view/directives/style.d.ts.map +1 -0
  200. package/dist/view/directives/text.d.ts +7 -0
  201. package/dist/view/directives/text.d.ts.map +1 -0
  202. package/dist/view/evaluate.d.ts +43 -0
  203. package/dist/view/evaluate.d.ts.map +1 -0
  204. package/dist/view/index.d.ts +111 -0
  205. package/dist/view/index.d.ts.map +1 -0
  206. package/dist/view/mount.d.ts +69 -0
  207. package/dist/view/mount.d.ts.map +1 -0
  208. package/dist/view/process.d.ts +26 -0
  209. package/dist/view/process.d.ts.map +1 -0
  210. package/dist/view/types.d.ts +36 -0
  211. package/dist/view/types.d.ts.map +1 -0
  212. package/dist/view.es.mjs +426 -0
  213. package/dist/view.es.mjs.map +1 -0
  214. package/dist/watch-CXyaBC_9.js +58 -0
  215. package/dist/watch-CXyaBC_9.js.map +1 -0
  216. package/package.json +26 -14
  217. package/src/component/component.ts +289 -0
  218. package/src/component/html.ts +53 -0
  219. package/src/component/index.ts +40 -414
  220. package/src/component/props.ts +116 -0
  221. package/src/component/types.ts +85 -0
  222. package/src/core/collection.ts +588 -454
  223. package/src/core/dom.ts +38 -0
  224. package/src/core/element.ts +746 -740
  225. package/src/core/index.ts +43 -0
  226. package/src/core/utils/array.ts +102 -0
  227. package/src/core/utils/function.ts +110 -0
  228. package/src/core/utils/index.ts +83 -0
  229. package/src/core/utils/misc.ts +82 -0
  230. package/src/core/utils/number.ts +78 -0
  231. package/src/core/utils/object.ts +206 -0
  232. package/src/core/utils/string.ts +112 -0
  233. package/src/core/utils/type-guards.ts +112 -0
  234. package/src/full.ts +187 -106
  235. package/src/index.ts +36 -27
  236. package/src/motion/animate.ts +113 -0
  237. package/src/motion/easing.ts +40 -0
  238. package/src/motion/flip.ts +176 -0
  239. package/src/motion/index.ts +41 -358
  240. package/src/motion/keyframes.ts +46 -0
  241. package/src/motion/reduced-motion.ts +17 -0
  242. package/src/motion/scroll.ts +57 -0
  243. package/src/motion/spring.ts +150 -0
  244. package/src/motion/stagger.ts +43 -0
  245. package/src/motion/timeline.ts +246 -0
  246. package/src/motion/transition.ts +51 -0
  247. package/src/motion/types.ts +198 -0
  248. package/src/reactive/batch.ts +22 -0
  249. package/src/reactive/computed.ts +92 -0
  250. package/src/reactive/core.ts +93 -0
  251. package/src/reactive/effect.ts +43 -0
  252. package/src/reactive/index.ts +23 -22
  253. package/src/reactive/internals.ts +105 -0
  254. package/src/reactive/linked.ts +56 -0
  255. package/src/reactive/persisted.ts +74 -0
  256. package/src/reactive/readonly.ts +35 -0
  257. package/src/reactive/signal.ts +20 -506
  258. package/src/reactive/type-guards.ts +22 -0
  259. package/src/reactive/untrack.ts +31 -0
  260. package/src/reactive/watch.ts +73 -0
  261. package/src/router/index.ts +41 -0
  262. package/src/router/links.ts +130 -0
  263. package/src/router/match.ts +106 -0
  264. package/src/router/navigation.ts +71 -0
  265. package/src/router/query.ts +35 -0
  266. package/src/router/router.ts +211 -0
  267. package/src/router/state.ts +46 -0
  268. package/src/router/types.ts +93 -0
  269. package/src/router/utils.ts +116 -0
  270. package/src/security/constants.ts +209 -0
  271. package/src/security/csp.ts +77 -0
  272. package/src/security/index.ts +4 -12
  273. package/src/security/sanitize-core.ts +343 -0
  274. package/src/security/sanitize.ts +66 -625
  275. package/src/security/trusted-types.ts +69 -0
  276. package/src/security/types.ts +40 -0
  277. package/src/store/create-store.ts +329 -0
  278. package/src/store/define-store.ts +48 -0
  279. package/src/store/devtools.ts +45 -0
  280. package/src/store/index.ts +22 -0
  281. package/src/store/mapping.ts +73 -0
  282. package/src/store/persisted.ts +61 -0
  283. package/src/store/plugins.ts +32 -0
  284. package/src/store/registry.ts +51 -0
  285. package/src/store/types.ts +94 -0
  286. package/src/store/utils.ts +141 -0
  287. package/src/store/watch.ts +52 -0
  288. package/src/view/directives/bind.ts +23 -0
  289. package/src/view/directives/class.ts +70 -0
  290. package/src/view/directives/for.ts +275 -0
  291. package/src/view/directives/html.ts +19 -0
  292. package/src/view/directives/if.ts +30 -0
  293. package/src/view/directives/index.ts +11 -0
  294. package/src/view/directives/model.ts +56 -0
  295. package/src/view/directives/on.ts +41 -0
  296. package/src/view/directives/ref.ts +41 -0
  297. package/src/view/directives/show.ts +26 -0
  298. package/src/view/directives/style.ts +47 -0
  299. package/src/view/directives/text.ts +15 -0
  300. package/src/view/evaluate.ts +274 -0
  301. package/src/view/index.ts +112 -0
  302. package/src/view/mount.ts +200 -0
  303. package/src/view/process.ts +92 -0
  304. package/src/view/types.ts +44 -0
  305. package/dist/core/utils.d.ts +0 -313
  306. package/dist/core/utils.d.ts.map +0 -1
  307. package/src/core/utils.ts +0 -444
package/dist/core.es.mjs CHANGED
@@ -1,9 +1,23 @@
1
- import { sanitize as f } from "./security.es.mjs";
2
- const p = (r) => Array.isArray(r) ? r : [r], o = (r, e) => {
3
- for (const t of r)
1
+ import { s as f } from "./sanitize-1FBEPAFH.js";
2
+ const g = (n) => Array.isArray(n) ? n : [n], o = (n, e) => {
3
+ for (const t of n)
4
4
  e(t);
5
+ }, p = (n) => f(n), w = (n, e) => {
6
+ n.innerHTML = f(e);
7
+ }, y = (n) => {
8
+ const e = document.createElement("template");
9
+ return e.innerHTML = f(n), e.content.firstElementChild ?? document.createElement("div");
10
+ }, b = (n, e, t) => {
11
+ if (typeof e == "string") {
12
+ n.insertAdjacentHTML(t, f(e));
13
+ return;
14
+ }
15
+ const r = g(e), i = t === "afterbegin" || t === "afterend" ? r.slice().reverse() : r;
16
+ o(i, (l) => {
17
+ n.insertAdjacentElement(t, l);
18
+ });
5
19
  };
6
- class a {
20
+ class h {
7
21
  /**
8
22
  * Creates a new BQueryElement wrapper.
9
23
  * @param element - The DOM element to wrap
@@ -41,14 +55,23 @@ class a {
41
55
  attr(e, t) {
42
56
  return t === void 0 ? this.element.getAttribute(e) ?? "" : (this.element.setAttribute(e, t), this);
43
57
  }
58
+ /** Remove an attribute. */
59
+ removeAttr(e) {
60
+ return this.element.removeAttribute(e), this;
61
+ }
62
+ /** Toggle an attribute on/off. */
63
+ toggleAttr(e, t) {
64
+ const r = this.element.hasAttribute(e);
65
+ return t ?? !r ? this.element.setAttribute(e, "") : this.element.removeAttribute(e), this;
66
+ }
44
67
  /** Get or set a property. */
45
68
  prop(e, t) {
46
69
  return t === void 0 ? this.element[e] : (this.element[e] = t, this);
47
70
  }
48
71
  /** Read or write data attributes in camelCase. */
49
72
  data(e, t) {
50
- const n = e.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
51
- return t === void 0 ? this.element.getAttribute(`data-${n}`) ?? "" : (this.element.setAttribute(`data-${n}`, t), this);
73
+ const r = e.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
74
+ return t === void 0 ? this.element.getAttribute(`data-${r}`) ?? "" : (this.element.setAttribute(`data-${r}`, t), this);
52
75
  }
53
76
  /** Get or set text content. */
54
77
  text(e) {
@@ -68,7 +91,7 @@ class a {
68
91
  * ```
69
92
  */
70
93
  html(e) {
71
- return this.element.innerHTML = f(e), this;
94
+ return w(this.element, e), this;
72
95
  }
73
96
  /**
74
97
  * Sets HTML content without sanitization.
@@ -101,8 +124,8 @@ class a {
101
124
  css(e, t) {
102
125
  if (typeof e == "string")
103
126
  return t !== void 0 && this.element.style.setProperty(e, t), this;
104
- for (const [n, s] of Object.entries(e))
105
- this.element.style.setProperty(n, s);
127
+ for (const [r, s] of Object.entries(e))
128
+ this.element.style.setProperty(r, s);
106
129
  return this;
107
130
  }
108
131
  /**
@@ -161,6 +184,10 @@ class a {
161
184
  * Removes the parent element, keeping this element in its place.
162
185
  * Essentially the opposite of wrap().
163
186
  *
187
+ * **Important**: This method only moves the current element out of its parent
188
+ * before removing the parent. Any sibling elements will be removed along with
189
+ * the parent. For unwrapping multiple siblings, use a collection: `$$(siblings).unwrap()`.
190
+ *
164
191
  * @returns The instance for method chaining
165
192
  *
166
193
  * @example
@@ -186,13 +213,8 @@ class a {
186
213
  * ```
187
214
  */
188
215
  replaceWith(e) {
189
- let t;
190
- if (typeof e == "string") {
191
- const n = document.createElement("template");
192
- n.innerHTML = f(e), t = n.content.firstElementChild ?? document.createElement("div");
193
- } else
194
- t = e;
195
- return this.element.replaceWith(t), new a(t);
216
+ const t = typeof e == "string" ? y(e) : e;
217
+ return this.element.replaceWith(t), new h(t);
196
218
  }
197
219
  /**
198
220
  * Scrolls the element into view with configurable behavior.
@@ -232,7 +254,7 @@ class a {
232
254
  * @returns A new BQueryElement wrapping the cloned element
233
255
  */
234
256
  clone(e = !0) {
235
- return new a(this.element.cloneNode(e));
257
+ return new h(this.element.cloneNode(e));
236
258
  }
237
259
  /**
238
260
  * Finds all descendant elements matching the selector.
@@ -363,12 +385,12 @@ class a {
363
385
  * $('#list').undelegate('click', '.item', handler);
364
386
  * ```
365
387
  */
366
- delegate(e, t, n) {
388
+ delegate(e, t, r) {
367
389
  const s = `${e}:${t}`, i = (l) => {
368
- const h = l.target.closest(t);
369
- h && this.element.contains(h) && n(l, h);
390
+ const u = l.target.closest(t);
391
+ u && this.element.contains(u) && r(l, u);
370
392
  };
371
- return this.delegatedHandlers.has(s) || this.delegatedHandlers.set(s, /* @__PURE__ */ new Map()), this.delegatedHandlers.get(s).set(n, i), this.element.addEventListener(e, i), this;
393
+ return this.delegatedHandlers.has(s) || this.delegatedHandlers.set(s, /* @__PURE__ */ new Map()), this.delegatedHandlers.get(s).set(r, i), this.element.addEventListener(e, i), this;
372
394
  }
373
395
  /**
374
396
  * Removes a delegated event listener previously added with `delegate()`.
@@ -387,11 +409,11 @@ class a {
387
409
  * $('#list').undelegate('click', '.item', handler);
388
410
  * ```
389
411
  */
390
- undelegate(e, t, n) {
412
+ undelegate(e, t, r) {
391
413
  const s = `${e}:${t}`, i = this.delegatedHandlers.get(s);
392
414
  if (i) {
393
- const l = i.get(n);
394
- l && (this.element.removeEventListener(e, l), i.delete(n), i.size === 0 && this.delegatedHandlers.delete(s));
415
+ const l = i.get(r);
416
+ l && (this.element.removeEventListener(e, l), i.delete(r), i.size === 0 && this.delegatedHandlers.delete(s));
395
417
  }
396
418
  return this;
397
419
  }
@@ -483,8 +505,8 @@ class a {
483
505
  const e = this.element;
484
506
  if (e.tagName.toLowerCase() !== "form")
485
507
  return {};
486
- const t = {}, n = new FormData(e);
487
- for (const [s, i] of n.entries())
508
+ const t = {}, r = new FormData(e);
509
+ for (const [s, i] of r.entries())
488
510
  if (typeof i == "string")
489
511
  if (s in t) {
490
512
  const l = t[s];
@@ -508,10 +530,10 @@ class a {
508
530
  const e = this.element;
509
531
  if (e.tagName.toLowerCase() !== "form")
510
532
  return "";
511
- const t = new FormData(e), n = new URLSearchParams();
533
+ const t = new FormData(e), r = new URLSearchParams();
512
534
  for (const [s, i] of t.entries())
513
- typeof i == "string" && n.append(s, i);
514
- return n.toString();
535
+ typeof i == "string" && r.append(s, i);
536
+ return r.toString();
515
537
  }
516
538
  /**
517
539
  * Gets the bounding client rectangle of the element.
@@ -540,17 +562,10 @@ class a {
540
562
  * @internal
541
563
  */
542
564
  insertContent(e, t) {
543
- if (typeof e == "string") {
544
- this.element.insertAdjacentHTML(t, f(e));
545
- return;
546
- }
547
- const n = p(e);
548
- o(n, (s) => {
549
- this.element.insertAdjacentElement(t, s);
550
- });
565
+ b(this.element, e, t);
551
566
  }
552
567
  }
553
- class m {
568
+ class c {
554
569
  /**
555
570
  * Creates a new collection wrapper.
556
571
  * @param elements - Array of DOM elements to wrap
@@ -579,7 +594,7 @@ class m {
579
594
  */
580
595
  eq(e) {
581
596
  const t = this.elements[e];
582
- return t ? new a(t) : void 0;
597
+ return t ? new h(t) : void 0;
583
598
  }
584
599
  /**
585
600
  * Gets the first element as a BQueryElement wrapper.
@@ -604,8 +619,8 @@ class m {
604
619
  * @returns The instance for method chaining
605
620
  */
606
621
  each(e) {
607
- return this.elements.forEach((t, n) => {
608
- e(new a(t), n);
622
+ return this.elements.forEach((t, r) => {
623
+ e(new h(t), r);
609
624
  }), this;
610
625
  }
611
626
  /**
@@ -624,7 +639,7 @@ class m {
624
639
  * @returns New BQueryCollection with matching elements
625
640
  */
626
641
  filter(e) {
627
- return new m(this.elements.filter(e));
642
+ return new c(this.elements.filter(e));
628
643
  }
629
644
  /**
630
645
  * Reduces the collection to a single value.
@@ -642,7 +657,7 @@ class m {
642
657
  * @returns Array of BQueryElement instances
643
658
  */
644
659
  toArray() {
645
- return this.elements.map((e) => new a(e));
660
+ return this.elements.map((e) => new h(e));
646
661
  }
647
662
  /** Add one or more classes to all elements. */
648
663
  addClass(...e) {
@@ -654,7 +669,7 @@ class m {
654
669
  }
655
670
  /** Toggle a class on all elements. */
656
671
  toggleClass(e, t) {
657
- return o(this.elements, (n) => n.classList.toggle(e, t)), this;
672
+ return o(this.elements, (r) => r.classList.toggle(e, t)), this;
658
673
  }
659
674
  /**
660
675
  * Sets an attribute on all elements or gets from first.
@@ -664,7 +679,7 @@ class m {
664
679
  * @returns Attribute value when getting, instance when setting
665
680
  */
666
681
  attr(e, t) {
667
- return t === void 0 ? this.first()?.getAttribute(e) ?? "" : (o(this.elements, (n) => n.setAttribute(e, t)), this);
682
+ return t === void 0 ? this.first()?.getAttribute(e) ?? "" : (o(this.elements, (r) => r.setAttribute(e, t)), this);
668
683
  }
669
684
  /**
670
685
  * Removes an attribute from all elements.
@@ -675,6 +690,13 @@ class m {
675
690
  removeAttr(e) {
676
691
  return o(this.elements, (t) => t.removeAttribute(e)), this;
677
692
  }
693
+ /** Toggle an attribute on all elements. */
694
+ toggleAttr(e, t) {
695
+ return o(this.elements, (r) => {
696
+ const s = r.hasAttribute(e);
697
+ t ?? !s ? r.setAttribute(e, "") : r.removeAttribute(e);
698
+ }), this;
699
+ }
678
700
  /**
679
701
  * Sets text content on all elements or gets from first.
680
702
  *
@@ -695,9 +717,9 @@ class m {
695
717
  html(e) {
696
718
  if (e === void 0)
697
719
  return this.first()?.innerHTML ?? "";
698
- const t = f(e);
699
- return o(this.elements, (n) => {
700
- n.innerHTML = t;
720
+ const t = p(e);
721
+ return o(this.elements, (r) => {
722
+ r.innerHTML = t;
701
723
  }), this;
702
724
  }
703
725
  /**
@@ -712,6 +734,22 @@ class m {
712
734
  t.innerHTML = e;
713
735
  }), this;
714
736
  }
737
+ /** Append content to all elements. */
738
+ append(e) {
739
+ return this.insertAll(e, "beforeend"), this;
740
+ }
741
+ /** Prepend content to all elements. */
742
+ prepend(e) {
743
+ return this.insertAll(e, "afterbegin"), this;
744
+ }
745
+ /** Insert content before all elements. */
746
+ before(e) {
747
+ return this.insertAll(e, "beforebegin"), this;
748
+ }
749
+ /** Insert content after all elements. */
750
+ after(e) {
751
+ return this.insertAll(e, "afterend"), this;
752
+ }
715
753
  /**
716
754
  * Applies CSS styles to all elements.
717
755
  *
@@ -720,13 +758,59 @@ class m {
720
758
  * @returns The instance for method chaining
721
759
  */
722
760
  css(e, t) {
723
- return typeof e == "string" ? (t !== void 0 && o(this.elements, (n) => {
724
- n.style.setProperty(e, t);
725
- }), this) : (o(this.elements, (n) => {
761
+ return typeof e == "string" ? (t !== void 0 && o(this.elements, (r) => {
762
+ r.style.setProperty(e, t);
763
+ }), this) : (o(this.elements, (r) => {
726
764
  for (const [s, i] of Object.entries(e))
727
- n.style.setProperty(s, i);
765
+ r.style.setProperty(s, i);
728
766
  }), this);
729
767
  }
768
+ /** Wrap each element with a wrapper element or tag. */
769
+ wrap(e) {
770
+ return this.elements.forEach((t, r) => {
771
+ const s = typeof e == "string" ? document.createElement(e) : r === 0 ? e : e.cloneNode(!0);
772
+ t.parentNode?.insertBefore(s, t), s.appendChild(t);
773
+ }), this;
774
+ }
775
+ /**
776
+ * Remove the parent element of each element, keeping the elements in place.
777
+ *
778
+ * **Important**: This method unwraps ALL children of each parent element,
779
+ * not just the elements in the collection. If you call `unwrap()` on a
780
+ * collection containing only some children of a parent, all siblings will
781
+ * also be unwrapped. This behavior is consistent with jQuery's `.unwrap()`.
782
+ *
783
+ * @returns The collection for chaining
784
+ *
785
+ * @example
786
+ * ```ts
787
+ * // HTML: <div><section><span>A</span><span>B</span></section></div>
788
+ * const spans = $$('span');
789
+ * spans.unwrap(); // Removes <section>, both spans move to <div>
790
+ * // Result: <div><span>A</span><span>B</span></div>
791
+ * ```
792
+ */
793
+ unwrap() {
794
+ const e = /* @__PURE__ */ new Set();
795
+ for (const t of this.elements)
796
+ t.parentElement && e.add(t.parentElement);
797
+ return e.forEach((t) => {
798
+ const r = t.parentNode;
799
+ if (r) {
800
+ for (; t.firstChild; )
801
+ r.insertBefore(t.firstChild, t);
802
+ t.remove();
803
+ }
804
+ }), this;
805
+ }
806
+ /** Replace each element with provided content. */
807
+ replaceWith(e) {
808
+ const t = [];
809
+ return this.elements.forEach((r, s) => {
810
+ const i = typeof e == "string" ? y(e) : s === 0 ? e : e.cloneNode(!0);
811
+ r.replaceWith(i), t.push(i);
812
+ }), new c(t);
813
+ }
730
814
  /**
731
815
  * Shows all elements.
732
816
  *
@@ -756,7 +840,7 @@ class m {
756
840
  * @returns The instance for method chaining
757
841
  */
758
842
  on(e, t) {
759
- return o(this.elements, (n) => n.addEventListener(e, t)), this;
843
+ return o(this.elements, (r) => r.addEventListener(e, t)), this;
760
844
  }
761
845
  /**
762
846
  * Adds a one-time event listener to all elements.
@@ -766,7 +850,7 @@ class m {
766
850
  * @returns The instance for method chaining
767
851
  */
768
852
  once(e, t) {
769
- return o(this.elements, (n) => n.addEventListener(e, t, { once: !0 })), this;
853
+ return o(this.elements, (r) => r.addEventListener(e, t, { once: !0 })), this;
770
854
  }
771
855
  /**
772
856
  * Removes an event listener from all elements.
@@ -776,7 +860,7 @@ class m {
776
860
  * @returns The instance for method chaining
777
861
  */
778
862
  off(e, t) {
779
- return o(this.elements, (n) => n.removeEventListener(e, t)), this;
863
+ return o(this.elements, (r) => r.removeEventListener(e, t)), this;
780
864
  }
781
865
  /**
782
866
  * Triggers a custom event on all elements.
@@ -786,8 +870,8 @@ class m {
786
870
  * @returns The instance for method chaining
787
871
  */
788
872
  trigger(e, t) {
789
- return o(this.elements, (n) => {
790
- n.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 }));
873
+ return o(this.elements, (r) => {
874
+ r.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 }));
791
875
  }), this;
792
876
  }
793
877
  /**
@@ -810,16 +894,16 @@ class m {
810
894
  * $$('.container').undelegate('click', '.item', handler);
811
895
  * ```
812
896
  */
813
- delegate(e, t, n) {
897
+ delegate(e, t, r) {
814
898
  const s = `${e}:${t}`;
815
899
  return o(this.elements, (i) => {
816
- const l = (u) => {
817
- const d = u.target.closest(t);
818
- d && i.contains(d) && n(u, d);
900
+ const l = (a) => {
901
+ const m = a.target.closest(t);
902
+ m && i.contains(m) && r(a, m);
819
903
  };
820
904
  this.delegatedHandlers.has(i) || this.delegatedHandlers.set(i, /* @__PURE__ */ new Map());
821
- const h = this.delegatedHandlers.get(i);
822
- h.has(s) || h.set(s, /* @__PURE__ */ new Map()), h.get(s).set(n, l), i.addEventListener(e, l);
905
+ const u = this.delegatedHandlers.get(i);
906
+ u.has(s) || u.set(s, /* @__PURE__ */ new Map()), u.get(s).set(r, l), i.addEventListener(e, l);
823
907
  }), this;
824
908
  }
825
909
  /**
@@ -839,15 +923,15 @@ class m {
839
923
  * $$('.container').undelegate('click', '.item', handler);
840
924
  * ```
841
925
  */
842
- undelegate(e, t, n) {
926
+ undelegate(e, t, r) {
843
927
  const s = `${e}:${t}`;
844
928
  return o(this.elements, (i) => {
845
929
  const l = this.delegatedHandlers.get(i);
846
930
  if (!l) return;
847
- const h = l.get(s);
848
- if (!h) return;
849
- const u = h.get(n);
850
- u && (i.removeEventListener(e, u), h.delete(n), h.size === 0 && l.delete(s), l.size === 0 && this.delegatedHandlers.delete(i));
931
+ const u = l.get(s);
932
+ if (!u) return;
933
+ const a = u.get(r);
934
+ a && (i.removeEventListener(e, a), u.delete(r), u.size === 0 && l.delete(s), l.size === 0 && this.delegatedHandlers.delete(i));
851
935
  }), this;
852
936
  }
853
937
  /**
@@ -868,391 +952,270 @@ class m {
868
952
  e.innerHTML = "";
869
953
  }), this;
870
954
  }
955
+ /** @internal */
956
+ insertAll(e, t) {
957
+ if (typeof e == "string") {
958
+ const s = p(e);
959
+ o(this.elements, (i) => {
960
+ i.insertAdjacentHTML(t, s);
961
+ });
962
+ return;
963
+ }
964
+ const r = g(e);
965
+ this.elements.forEach((s, i) => {
966
+ const l = i === 0 ? r : r.map((u) => u.cloneNode(!0));
967
+ b(s, l, t);
968
+ });
969
+ }
871
970
  }
872
- const y = (r) => {
873
- if (typeof r != "string")
874
- return new a(r);
875
- const e = document.querySelector(r);
971
+ const oe = (n) => {
972
+ if (typeof n != "string")
973
+ return new h(n);
974
+ const e = document.querySelector(n);
876
975
  if (!e)
877
- throw new Error(`bQuery: element not found for selector "${r}"`);
878
- return new a(e);
879
- }, b = (r) => Array.isArray(r) ? new m(r) : r instanceof NodeList ? new m(Array.from(r)) : new m(Array.from(document.querySelectorAll(r))), c = {
880
- /**
881
- * Creates a deep clone using structuredClone if available, otherwise fallback to JSON.
882
- *
883
- * @template T - The type of value being cloned
884
- * @param value - The value to clone
885
- * @returns A deep copy of the value
886
- *
887
- * @example
888
- * ```ts
889
- * const original = { nested: { value: 1 } };
890
- * const copy = utils.clone(original);
891
- * copy.nested.value = 2;
892
- * console.log(original.nested.value); // 1
893
- * ```
894
- */
895
- clone(r) {
896
- return typeof structuredClone == "function" ? structuredClone(r) : JSON.parse(JSON.stringify(r));
897
- },
898
- /**
899
- * Deep-merges plain objects into a new object.
900
- * Later sources override earlier ones for primitive values.
901
- * Objects are recursively merged.
902
- *
903
- * @template T - The type of the merged object
904
- * @param sources - Objects to merge
905
- * @returns A new object with all sources merged
906
- *
907
- * @example
908
- * ```ts
909
- * const result = utils.merge(
910
- * { a: 1, nested: { x: 1 } },
911
- * { b: 2, nested: { y: 2 } }
912
- * );
913
- * // Result: { a: 1, b: 2, nested: { x: 1, y: 2 } }
914
- * ```
915
- *
916
- * @security This method is protected against prototype pollution attacks.
917
- * Keys like `__proto__`, `constructor`, and `prototype` are ignored.
918
- */
919
- merge(...r) {
920
- const e = {};
921
- for (const t of r)
922
- for (const [n, s] of Object.entries(t))
923
- c.isPrototypePollutionKey(n) || (c.isPlainObject(s) && c.isPlainObject(e[n]) ? e[n] = c.merge(
924
- e[n],
925
- s
926
- ) : e[n] = s);
976
+ throw new Error(`bQuery: element not found for selector "${n}"`);
977
+ return new h(e);
978
+ }, le = (n) => Array.isArray(n) ? new c(n) : n instanceof NodeList ? new c(Array.from(n)) : new c(Array.from(document.querySelectorAll(n)));
979
+ function E(n) {
980
+ return n == null ? [] : Array.isArray(n) ? n : [n];
981
+ }
982
+ function C(n) {
983
+ return Array.from(new Set(n));
984
+ }
985
+ function L(n, e) {
986
+ if (e <= 0) return [];
987
+ const t = [];
988
+ for (let r = 0; r < n.length; r += e)
989
+ t.push(n.slice(r, r + e));
990
+ return t;
991
+ }
992
+ function H(n) {
993
+ return n.filter(Boolean);
994
+ }
995
+ function v(n) {
996
+ const e = [];
997
+ for (const t of n)
998
+ Array.isArray(t) ? e.push(...t) : e.push(t);
999
+ return e;
1000
+ }
1001
+ function N(n, e) {
1002
+ let t;
1003
+ return (...r) => {
1004
+ t && clearTimeout(t), t = setTimeout(() => n(...r), e);
1005
+ };
1006
+ }
1007
+ function $(n, e) {
1008
+ let t = 0;
1009
+ return (...r) => {
1010
+ const s = Date.now();
1011
+ s - t >= e && (t = s, n(...r));
1012
+ };
1013
+ }
1014
+ function M(n) {
1015
+ let e = !1, t;
1016
+ return (...r) => (e || (t = n(...r), e = !0), t);
1017
+ }
1018
+ function S() {
1019
+ }
1020
+ function j(n = "bQuery") {
1021
+ return `${n}_${Math.random().toString(36).slice(2, 9)}`;
1022
+ }
1023
+ function O(n) {
1024
+ return new Promise((e) => setTimeout(e, n));
1025
+ }
1026
+ function T(n, e) {
1027
+ try {
1028
+ return JSON.parse(n);
1029
+ } catch {
927
1030
  return e;
928
- },
929
- /**
930
- * Checks if a key could cause prototype pollution.
931
- * These keys are dangerous when used in object merging operations.
932
- *
933
- * @param key - The key to check
934
- * @returns True if the key is a prototype pollution vector
935
- *
936
- * @internal
937
- */
938
- isPrototypePollutionKey(r) {
939
- return r === "__proto__" || r === "constructor" || r === "prototype";
940
- },
941
- /**
942
- * Creates a debounced function that delays execution until after
943
- * the specified delay has elapsed since the last call.
944
- *
945
- * @template TArgs - The argument types of the function
946
- * @param fn - The function to debounce
947
- * @param delayMs - Delay in milliseconds
948
- * @returns A debounced version of the function
949
- *
950
- * @example
951
- * ```ts
952
- * const search = utils.debounce((query: string) => {
953
- * console.log('Searching:', query);
954
- * }, 300);
955
- *
956
- * search('h');
957
- * search('he');
958
- * search('hello'); // Only this call executes after 300ms
959
- * ```
960
- */
961
- debounce(r, e) {
962
- let t;
963
- return (...n) => {
964
- t && clearTimeout(t), t = setTimeout(() => r(...n), e);
965
- };
966
- },
967
- /**
968
- * Creates a throttled function that runs at most once per interval.
969
- *
970
- * @template TArgs - The argument types of the function
971
- * @param fn - The function to throttle
972
- * @param intervalMs - Minimum interval between calls in milliseconds
973
- * @returns A throttled version of the function
974
- *
975
- * @example
976
- * ```ts
977
- * const handleScroll = utils.throttle(() => {
978
- * console.log('Scroll position:', window.scrollY);
979
- * }, 100);
980
- *
981
- * window.addEventListener('scroll', handleScroll);
982
- * ```
983
- */
984
- throttle(r, e) {
985
- let t = 0;
986
- return (...n) => {
987
- const s = Date.now();
988
- s - t >= e && (t = s, r(...n));
989
- };
990
- },
991
- /**
992
- * Creates a stable unique ID for DOM usage.
993
- *
994
- * @param prefix - Optional prefix for the ID (default: 'bQuery')
995
- * @returns A unique identifier string
996
- *
997
- * @example
998
- * ```ts
999
- * const id = utils.uid('modal'); // 'modal_x7k2m9p'
1000
- * ```
1001
- */
1002
- uid(r = "bQuery") {
1003
- return `${r}_${Math.random().toString(36).slice(2, 9)}`;
1004
- },
1005
- /**
1006
- * Checks if a value is a DOM Element.
1007
- *
1008
- * @param value - The value to check
1009
- * @returns True if the value is an Element
1010
- */
1011
- isElement(r) {
1012
- return r instanceof Element;
1013
- },
1014
- /**
1015
- * Checks if a value is a BQueryCollection-like object.
1016
- *
1017
- * @param value - The value to check
1018
- * @returns True if the value has an elements array property
1019
- */
1020
- isCollection(r) {
1021
- return !!(r && typeof r == "object" && "elements" in r);
1022
- },
1023
- /**
1024
- * Checks for emptiness across common value types.
1025
- *
1026
- * @param value - The value to check
1027
- * @returns True if the value is empty (null, undefined, empty string, empty array, or empty object)
1028
- *
1029
- * @example
1030
- * ```ts
1031
- * utils.isEmpty(''); // true
1032
- * utils.isEmpty([]); // true
1033
- * utils.isEmpty({}); // true
1034
- * utils.isEmpty(null); // true
1035
- * utils.isEmpty('hello'); // false
1036
- * utils.isEmpty([1, 2]); // false
1037
- * ```
1038
- */
1039
- isEmpty(r) {
1040
- return r == null ? !0 : typeof r == "string" ? r.trim().length === 0 : Array.isArray(r) ? r.length === 0 : typeof r == "object" ? Object.keys(r).length === 0 : !1;
1041
- },
1042
- /**
1043
- * Checks if a value is a plain object (not null, array, or class instance).
1044
- *
1045
- * @param value - The value to check
1046
- * @returns True if the value is a plain object
1047
- */
1048
- isPlainObject(r) {
1049
- return Object.prototype.toString.call(r) === "[object Object]";
1050
- },
1051
- /**
1052
- * Checks if a value is a function.
1053
- *
1054
- * @param value - The value to check
1055
- * @returns True if the value is a function
1056
- */
1057
- isFunction(r) {
1058
- return typeof r == "function";
1059
- },
1060
- /**
1061
- * Checks if a value is a string.
1062
- *
1063
- * @param value - The value to check
1064
- * @returns True if the value is a string
1065
- */
1066
- isString(r) {
1067
- return typeof r == "string";
1068
- },
1069
- /**
1070
- * Checks if a value is a number (excluding NaN).
1071
- *
1072
- * @param value - The value to check
1073
- * @returns True if the value is a valid number
1074
- */
1075
- isNumber(r) {
1076
- return typeof r == "number" && !Number.isNaN(r);
1077
- },
1078
- /**
1079
- * Checks if a value is a boolean.
1080
- *
1081
- * @param value - The value to check
1082
- * @returns True if the value is a boolean
1083
- */
1084
- isBoolean(r) {
1085
- return typeof r == "boolean";
1086
- },
1087
- /**
1088
- * Checks if a value is an array.
1089
- *
1090
- * @template T - The type of array elements
1091
- * @param value - The value to check
1092
- * @returns True if the value is an array
1093
- */
1094
- isArray(r) {
1095
- return Array.isArray(r);
1096
- },
1097
- /**
1098
- * Safely parses a JSON string, returning a default value on error.
1099
- *
1100
- * @template T - The expected type of the parsed value
1101
- * @param json - The JSON string to parse
1102
- * @param fallback - The default value if parsing fails
1103
- * @returns The parsed value or the fallback
1104
- *
1105
- * @example
1106
- * ```ts
1107
- * utils.parseJson('{"name":"bQuery"}', {}); // { name: 'bQuery' }
1108
- * utils.parseJson('invalid', {}); // {}
1109
- * ```
1110
- */
1111
- parseJson(r, e) {
1112
- try {
1113
- return JSON.parse(r);
1114
- } catch {
1115
- return e;
1116
- }
1117
- },
1118
- /**
1119
- * Picks specified keys from an object.
1120
- *
1121
- * @template T - The object type
1122
- * @template K - The key type
1123
- * @param obj - The source object
1124
- * @param keys - Keys to pick
1125
- * @returns A new object with only the specified keys
1126
- *
1127
- * @example
1128
- * ```ts
1129
- * const user = { name: 'John', age: 30, email: 'john@example.com' };
1130
- * utils.pick(user, ['name', 'email']); // { name: 'John', email: 'john@example.com' }
1131
- * ```
1132
- */
1133
- pick(r, e) {
1134
- const t = {};
1135
- for (const n of e)
1136
- n in r && (t[n] = r[n]);
1137
- return t;
1138
- },
1139
- /**
1140
- * Omits specified keys from an object.
1141
- *
1142
- * @template T - The object type
1143
- * @template K - The key type
1144
- * @param obj - The source object
1145
- * @param keys - Keys to omit
1146
- * @returns A new object without the specified keys
1147
- *
1148
- * @example
1149
- * ```ts
1150
- * const user = { name: 'John', age: 30, password: 'secret' };
1151
- * utils.omit(user, ['password']); // { name: 'John', age: 30 }
1152
- * ```
1153
- */
1154
- omit(r, e) {
1155
- const t = { ...r };
1156
- for (const n of e)
1157
- delete t[n];
1158
- return t;
1159
- },
1160
- /**
1161
- * Delays execution for a specified number of milliseconds.
1162
- *
1163
- * @param ms - Milliseconds to delay
1164
- * @returns A promise that resolves after the delay
1165
- *
1166
- * @example
1167
- * ```ts
1168
- * await utils.sleep(1000); // Wait 1 second
1169
- * console.log('Done!');
1170
- * ```
1171
- */
1172
- sleep(r) {
1173
- return new Promise((e) => setTimeout(e, r));
1174
- },
1175
- /**
1176
- * Generates a random integer between min and max (inclusive).
1177
- *
1178
- * @param min - Minimum value
1179
- * @param max - Maximum value
1180
- * @returns A random integer in the range [min, max]
1181
- *
1182
- * @example
1183
- * ```ts
1184
- * const roll = utils.randomInt(1, 6); // Random dice roll
1185
- * ```
1186
- */
1187
- randomInt(r, e) {
1188
- return Math.floor(Math.random() * (e - r + 1)) + r;
1189
- },
1190
- /**
1191
- * Clamps a number between a minimum and maximum value.
1192
- *
1193
- * @param value - The value to clamp
1194
- * @param min - Minimum value
1195
- * @param max - Maximum value
1196
- * @returns The clamped value
1197
- *
1198
- * @example
1199
- * ```ts
1200
- * utils.clamp(150, 0, 100); // 100
1201
- * utils.clamp(-10, 0, 100); // 0
1202
- * utils.clamp(50, 0, 100); // 50
1203
- * ```
1204
- */
1205
- clamp(r, e, t) {
1206
- return Math.min(Math.max(r, e), t);
1207
- },
1208
- /**
1209
- * Capitalizes the first letter of a string.
1210
- *
1211
- * @param str - The string to capitalize
1212
- * @returns The capitalized string
1213
- *
1214
- * @example
1215
- * ```ts
1216
- * utils.capitalize('hello'); // 'Hello'
1217
- * ```
1218
- */
1219
- capitalize(r) {
1220
- return r && r.charAt(0).toUpperCase() + r.slice(1);
1221
- },
1222
- /**
1223
- * Converts a string to kebab-case.
1224
- *
1225
- * @param str - The string to convert
1226
- * @returns The kebab-cased string
1227
- *
1228
- * @example
1229
- * ```ts
1230
- * utils.toKebabCase('myVariableName'); // 'my-variable-name'
1231
- * ```
1232
- */
1233
- toKebabCase(r) {
1234
- return r.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
1235
- },
1236
- /**
1237
- * Converts a string to camelCase.
1238
- *
1239
- * @param str - The string to convert
1240
- * @returns The camelCased string
1241
- *
1242
- * @example
1243
- * ```ts
1244
- * utils.toCamelCase('my-variable-name'); // 'myVariableName'
1245
- * ```
1246
- */
1247
- toCamelCase(r) {
1248
- return r.replace(/[-_\s]+(.)?/g, (e, t) => t ? t.toUpperCase() : "").replace(/^[A-Z]/, (e) => e.toLowerCase());
1249
1031
  }
1032
+ }
1033
+ function k(n) {
1034
+ return n == null ? !0 : typeof n == "string" ? n.trim().length === 0 : Array.isArray(n) ? n.length === 0 : typeof n == "object" ? Object.keys(n).length === 0 : !1;
1035
+ }
1036
+ function P(n, e) {
1037
+ return Math.floor(Math.random() * (e - n + 1)) + n;
1038
+ }
1039
+ function z(n, e, t) {
1040
+ return Math.min(Math.max(n, e), t);
1041
+ }
1042
+ function x(n, e, t, r = !0) {
1043
+ return r ? n >= e && n <= t : n > e && n < t;
1044
+ }
1045
+ function q(n, e = 0) {
1046
+ const t = typeof n == "number" ? n : Number(n);
1047
+ return Number.isNaN(t) ? e : t;
1048
+ }
1049
+ function d(n) {
1050
+ return Object.prototype.toString.call(n) === "[object Object]";
1051
+ }
1052
+ function D(n) {
1053
+ return n === "__proto__" || n === "constructor" || n === "prototype";
1054
+ }
1055
+ function R(n) {
1056
+ return typeof structuredClone == "function" ? structuredClone(n) : JSON.parse(JSON.stringify(n));
1057
+ }
1058
+ function A(...n) {
1059
+ const e = {};
1060
+ for (const t of n)
1061
+ for (const [r, s] of Object.entries(t))
1062
+ D(r) || (d(s) && d(e[r]) ? e[r] = A(
1063
+ e[r],
1064
+ s
1065
+ ) : e[r] = s);
1066
+ return e;
1067
+ }
1068
+ function B(n, e) {
1069
+ const t = {};
1070
+ for (const r of e)
1071
+ r in n && (t[r] = n[r]);
1072
+ return t;
1073
+ }
1074
+ function W(n, e) {
1075
+ const t = { ...n };
1076
+ for (const r of e)
1077
+ delete t[r];
1078
+ return t;
1079
+ }
1080
+ function F(n, e) {
1081
+ return Object.prototype.hasOwnProperty.call(n, e);
1082
+ }
1083
+ function U(n) {
1084
+ return n && n.charAt(0).toUpperCase() + n.slice(1);
1085
+ }
1086
+ function _(n) {
1087
+ return n.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
1088
+ }
1089
+ function J(n) {
1090
+ return n.replace(/[-_\s]+(.)?/g, (e, t) => t ? t.toUpperCase() : "").replace(/^[A-Z]/, (e) => e.toLowerCase());
1091
+ }
1092
+ function I(n, e, t = "…") {
1093
+ if (e <= 0) return "";
1094
+ if (n.length <= e) return n;
1095
+ const r = Math.max(0, e - t.length);
1096
+ return `${n.slice(0, r)}${t}`;
1097
+ }
1098
+ function Z(n) {
1099
+ return n.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\w\s-]/g, "").trim().replace(/[\s_-]+/g, "-").toLowerCase();
1100
+ }
1101
+ function K(n) {
1102
+ return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1103
+ }
1104
+ function G(n) {
1105
+ return typeof Element < "u" && n instanceof Element;
1106
+ }
1107
+ function Q(n) {
1108
+ return !!(n && typeof n == "object" && "elements" in n);
1109
+ }
1110
+ function V(n) {
1111
+ return typeof n == "function";
1112
+ }
1113
+ function X(n) {
1114
+ return typeof n == "string";
1115
+ }
1116
+ function Y(n) {
1117
+ return typeof n == "number" && !Number.isNaN(n);
1118
+ }
1119
+ function ee(n) {
1120
+ return typeof n == "boolean";
1121
+ }
1122
+ function te(n) {
1123
+ return Array.isArray(n);
1124
+ }
1125
+ function ne(n) {
1126
+ return n instanceof Date;
1127
+ }
1128
+ function re(n) {
1129
+ return !!(n && (n instanceof Promise || typeof n == "object" && "then" in n && typeof n.then == "function"));
1130
+ }
1131
+ function se(n) {
1132
+ return typeof n == "object" && n !== null;
1133
+ }
1134
+ const ue = {
1135
+ clone: R,
1136
+ merge: A,
1137
+ pick: B,
1138
+ omit: W,
1139
+ hasOwn: F,
1140
+ debounce: N,
1141
+ throttle: $,
1142
+ once: M,
1143
+ noop: S,
1144
+ uid: j,
1145
+ isElement: G,
1146
+ isCollection: Q,
1147
+ isEmpty: k,
1148
+ isPlainObject: d,
1149
+ isFunction: V,
1150
+ isString: X,
1151
+ isNumber: Y,
1152
+ isBoolean: ee,
1153
+ isArray: te,
1154
+ isDate: ne,
1155
+ isPromise: re,
1156
+ isObject: se,
1157
+ parseJson: T,
1158
+ sleep: O,
1159
+ randomInt: P,
1160
+ clamp: z,
1161
+ inRange: x,
1162
+ toNumber: q,
1163
+ capitalize: U,
1164
+ toKebabCase: _,
1165
+ toCamelCase: J,
1166
+ truncate: I,
1167
+ slugify: Z,
1168
+ escapeRegExp: K,
1169
+ ensureArray: E,
1170
+ unique: C,
1171
+ chunk: L,
1172
+ compact: H,
1173
+ flatten: v
1250
1174
  };
1251
1175
  export {
1252
- y as $,
1253
- b as $$,
1254
- m as BQueryCollection,
1255
- a as BQueryElement,
1256
- c as utils
1176
+ oe as $,
1177
+ le as $$,
1178
+ c as BQueryCollection,
1179
+ h as BQueryElement,
1180
+ U as capitalize,
1181
+ L as chunk,
1182
+ z as clamp,
1183
+ R as clone,
1184
+ H as compact,
1185
+ N as debounce,
1186
+ E as ensureArray,
1187
+ K as escapeRegExp,
1188
+ v as flatten,
1189
+ F as hasOwn,
1190
+ x as inRange,
1191
+ te as isArray,
1192
+ ee as isBoolean,
1193
+ Q as isCollection,
1194
+ ne as isDate,
1195
+ G as isElement,
1196
+ k as isEmpty,
1197
+ V as isFunction,
1198
+ Y as isNumber,
1199
+ se as isObject,
1200
+ d as isPlainObject,
1201
+ re as isPromise,
1202
+ X as isString,
1203
+ A as merge,
1204
+ S as noop,
1205
+ W as omit,
1206
+ M as once,
1207
+ T as parseJson,
1208
+ B as pick,
1209
+ P as randomInt,
1210
+ O as sleep,
1211
+ Z as slugify,
1212
+ $ as throttle,
1213
+ J as toCamelCase,
1214
+ _ as toKebabCase,
1215
+ q as toNumber,
1216
+ I as truncate,
1217
+ j as uid,
1218
+ C as unique,
1219
+ ue as utils
1257
1220
  };
1258
1221
  //# sourceMappingURL=core.es.mjs.map