@firerian/fireui 1.0.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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/dist/fireui.cjs +2 -0
  4. package/dist/fireui.cjs.map +1 -0
  5. package/dist/fireui.css +1 -0
  6. package/dist/fireui.es.mjs +3867 -0
  7. package/dist/fireui.es.mjs.map +1 -0
  8. package/dist/fireui.umd.js +2 -0
  9. package/dist/fireui.umd.js.map +1 -0
  10. package/dist/types/index.d.ts +1590 -0
  11. package/package.json +132 -0
  12. package/src/components/button/button.test.ts +357 -0
  13. package/src/components/button/button.vue +366 -0
  14. package/src/components/button/index.ts +17 -0
  15. package/src/components/button/types.ts +76 -0
  16. package/src/components/form/form-item.vue +136 -0
  17. package/src/components/form/form.vue +76 -0
  18. package/src/components/form/index.ts +16 -0
  19. package/src/components/grid/col.vue +99 -0
  20. package/src/components/grid/index.ts +16 -0
  21. package/src/components/grid/row.vue +85 -0
  22. package/src/components/grid/types.ts +66 -0
  23. package/src/components/index.ts +36 -0
  24. package/src/components/input/index.ts +8 -0
  25. package/src/components/input/input.test.ts +129 -0
  26. package/src/components/input/input.vue +256 -0
  27. package/src/components/input/types.ts +100 -0
  28. package/src/components/layout/aside.vue +89 -0
  29. package/src/components/layout/container.vue +53 -0
  30. package/src/components/layout/footer.vue +57 -0
  31. package/src/components/layout/header.vue +56 -0
  32. package/src/components/layout/index.ts +28 -0
  33. package/src/components/layout/main.vue +36 -0
  34. package/src/components/layout/types.ts +74 -0
  35. package/src/components/table/index.ts +16 -0
  36. package/src/components/table/table-column.vue +69 -0
  37. package/src/components/table/table.vue +354 -0
  38. package/src/components/tips/index.ts +12 -0
  39. package/src/components/tips/tips.test.ts +96 -0
  40. package/src/components/tips/tips.vue +206 -0
  41. package/src/components/tips/types.ts +56 -0
  42. package/src/components/tooltip/index.ts +8 -0
  43. package/src/components/tooltip/tooltip.test.ts +187 -0
  44. package/src/components/tooltip/tooltip.vue +261 -0
  45. package/src/components/tooltip/types.ts +60 -0
  46. package/src/hooks/useForm.ts +233 -0
  47. package/src/hooks/useTable.ts +153 -0
  48. package/src/index.ts +48 -0
  49. package/src/styles/main.scss +6 -0
  50. package/src/styles/mixins.scss +48 -0
  51. package/src/styles/reset.scss +49 -0
  52. package/src/styles/variables.scss +137 -0
  53. package/src/types/component.ts +9 -0
  54. package/src/types/form.ts +149 -0
  55. package/src/types/global.d.ts +49 -0
  56. package/src/types/grid.ts +76 -0
  57. package/src/types/index.ts +23 -0
  58. package/src/types/table.ts +181 -0
  59. package/src/types/tooltip.ts +44 -0
  60. package/src/utils/auto-import.ts +41 -0
  61. package/src/utils/index.ts +2 -0
  62. package/src/utils/install.ts +20 -0
  63. package/src/utils/useNamespace.ts +29 -0
@@ -0,0 +1,3867 @@
1
+ import { defineComponent, ref, computed, openBlock, createElementBlock, normalizeStyle, unref, normalizeClass, renderSlot, createElementVNode, createBlock, resolveDynamicComponent, createCommentVNode, shallowRef, watch, getCurrentScope, onScopeDispose, shallowReadonly, onMounted, onUnmounted, Teleport, createVNode, Transition, withCtx, createTextVNode, toDisplayString, withKeys, reactive, provide, readonly, inject, withModifiers, Fragment, renderList, useSlots } from "vue";
2
+ import { Info, XCircle, AlertTriangle, CheckCircle, X, Eye, EyeOff, ChevronUp, ChevronDown } from "lucide-vue-next";
3
+ const _hoisted_1$5 = ["disabled", "type"];
4
+ const _hoisted_2$4 = ["src", "alt"];
5
+ const prefixCls = "f-button";
6
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7
+ ...{
8
+ name: "FButton",
9
+ inheritAttrs: false
10
+ },
11
+ __name: "button",
12
+ props: {
13
+ type: { default: "default" },
14
+ size: { default: "default" },
15
+ nativeType: { default: "button" },
16
+ disabled: { type: Boolean, default: false },
17
+ loading: { type: Boolean, default: false },
18
+ circle: { type: Boolean, default: false },
19
+ block: { type: Boolean, default: false },
20
+ loadingIcon: { default: "" },
21
+ icon: { default: "" }
22
+ },
23
+ emits: ["click"],
24
+ setup(__props, { expose: __expose, emit: __emit }) {
25
+ const props = __props;
26
+ const emit = __emit;
27
+ const buttonRef = ref();
28
+ const { type: type4, size, disabled, loading, circle, block, nativeType, loadingIcon, icon } = props;
29
+ const buttonClasses = computed(() => [
30
+ prefixCls,
31
+ `${prefixCls}--${type4}`,
32
+ `${prefixCls}--${size}`,
33
+ {
34
+ [`${prefixCls}--disabled`]: disabled,
35
+ [`${prefixCls}--loading`]: loading,
36
+ [`${prefixCls}--circle`]: circle,
37
+ [`${prefixCls}--block`]: block
38
+ }
39
+ ]);
40
+ const buttonStyles = computed(() => ({
41
+ "--f-button-primary-color": `var(--f-color-${type4})`,
42
+ "--f-button-primary-hover": `var(--f-color-${type4}-hover)`,
43
+ "--f-button-primary-active": `var(--f-color-${type4}-active)`
44
+ }));
45
+ const handleClick = (event) => {
46
+ if (disabled || loading) return;
47
+ emit("click", event);
48
+ };
49
+ __expose({
50
+ ref: buttonRef
51
+ });
52
+ return (_ctx, _cache) => {
53
+ return openBlock(), createElementBlock("button", {
54
+ ref_key: "buttonRef",
55
+ ref: buttonRef,
56
+ class: normalizeClass(buttonClasses.value),
57
+ disabled: unref(disabled) || unref(loading),
58
+ type: unref(nativeType),
59
+ style: normalizeStyle(buttonStyles.value),
60
+ onClick: handleClick
61
+ }, [
62
+ unref(loading) ? renderSlot(_ctx.$slots, "loading", { key: 0 }, () => [
63
+ createElementVNode("span", {
64
+ class: normalizeClass(`${prefixCls}-loading-icon`)
65
+ }, [
66
+ !unref(loadingIcon) ? (openBlock(), createElementBlock("svg", {
67
+ key: 0,
68
+ class: normalizeClass(`${prefixCls}-loading-svg`),
69
+ viewBox: "0 0 16 16",
70
+ width: "1em",
71
+ height: "1em"
72
+ }, [..._cache[0] || (_cache[0] = [
73
+ createElementVNode("circle", {
74
+ cx: "8",
75
+ cy: "8",
76
+ r: "7",
77
+ stroke: "currentColor",
78
+ "stroke-width": "2",
79
+ fill: "none",
80
+ "stroke-linecap": "round",
81
+ "stroke-dasharray": "44",
82
+ "stroke-dashoffset": "11"
83
+ }, null, -1)
84
+ ])], 2)) : (openBlock(), createElementBlock("img", {
85
+ key: 1,
86
+ src: unref(loadingIcon),
87
+ alt: unref(loadingIcon),
88
+ class: normalizeClass(`${prefixCls}-loading-img`)
89
+ }, null, 10, _hoisted_2$4))
90
+ ], 2)
91
+ ], true) : unref(icon) ? renderSlot(_ctx.$slots, "icon", { key: 1 }, () => [
92
+ createElementVNode("span", {
93
+ class: normalizeClass(`${prefixCls}-icon`)
94
+ }, [
95
+ (openBlock(), createBlock(resolveDynamicComponent(unref(icon))))
96
+ ], 2)
97
+ ], true) : createCommentVNode("", true),
98
+ createElementVNode("span", {
99
+ class: normalizeClass(`${prefixCls}-content`)
100
+ }, [
101
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
102
+ ], 2)
103
+ ], 14, _hoisted_1$5);
104
+ };
105
+ }
106
+ });
107
+ const _export_sfc = (sfc, props) => {
108
+ const target = sfc.__vccOpts || sfc;
109
+ for (const [key, val] of props) {
110
+ target[key] = val;
111
+ }
112
+ return target;
113
+ };
114
+ const FButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-69f05370"]]);
115
+ function withInstall(component) {
116
+ const comp = component;
117
+ comp.install = (app) => {
118
+ app.component(comp.name || comp.__name, component);
119
+ };
120
+ return component;
121
+ }
122
+ function registerComponent(app, component) {
123
+ const comp = component;
124
+ app.component(comp.name || comp.__name, component);
125
+ }
126
+ function registerComponents(app, components2) {
127
+ components2.forEach((component) => {
128
+ registerComponent(app, component);
129
+ });
130
+ }
131
+ function useNamespace(block) {
132
+ const b = computed(() => `fire-${block}`);
133
+ const e = (element) => {
134
+ return element ? `${b.value}__${element}` : b.value;
135
+ };
136
+ const m = (modifier) => {
137
+ return modifier ? `${b.value}--${modifier}` : b.value;
138
+ };
139
+ const em = (element, modifier) => {
140
+ return `${e(element)}--${modifier}`;
141
+ };
142
+ return {
143
+ b: b.value,
144
+ e,
145
+ m,
146
+ em
147
+ };
148
+ }
149
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
150
+ __name: "row",
151
+ props: {
152
+ gutter: { default: 0 },
153
+ justify: { default: "start" },
154
+ align: { default: "top" },
155
+ class: {},
156
+ style: {}
157
+ },
158
+ setup(__props) {
159
+ const ns = useNamespace("row");
160
+ const props = __props;
161
+ const rowStyle = computed(() => {
162
+ const style = {};
163
+ if (props.gutter) {
164
+ const [horizontal, vertical] = Array.isArray(props.gutter) ? props.gutter : [props.gutter, props.gutter];
165
+ style["--fire-row-gutter-horizontal"] = `${horizontal}px`;
166
+ style["--fire-row-gutter-vertical"] = `${vertical}px`;
167
+ }
168
+ return style;
169
+ });
170
+ return (_ctx, _cache) => {
171
+ return openBlock(), createElementBlock("div", {
172
+ class: normalizeClass([
173
+ unref(ns).b,
174
+ {
175
+ [unref(ns).m(`justify-${__props.justify}`)]: __props.justify,
176
+ [unref(ns).m(`align-${__props.align}`)]: __props.align
177
+ }
178
+ ]),
179
+ style: normalizeStyle(rowStyle.value)
180
+ }, [
181
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
182
+ ], 6);
183
+ };
184
+ }
185
+ });
186
+ const Row = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-62576f0f"]]);
187
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
188
+ __name: "col",
189
+ props: {
190
+ span: { default: 24 },
191
+ offset: { default: 0 },
192
+ xs: {},
193
+ sm: {},
194
+ md: {},
195
+ lg: {},
196
+ xl: {},
197
+ class: {},
198
+ style: {}
199
+ },
200
+ setup(__props) {
201
+ const ns = useNamespace("col");
202
+ const props = __props;
203
+ const responsiveClasses = computed(() => {
204
+ const classes = [];
205
+ const breakpoints = ["xs", "sm", "md", "lg", "xl"];
206
+ breakpoints.forEach((breakpoint) => {
207
+ const value = props[breakpoint];
208
+ if (value) {
209
+ if (typeof value === "number") {
210
+ classes.push(ns.m(`${breakpoint}-span-${value}`));
211
+ } else {
212
+ if (value.span) {
213
+ classes.push(ns.m(`${breakpoint}-span-${value.span}`));
214
+ }
215
+ if (value.offset) {
216
+ classes.push(ns.m(`${breakpoint}-offset-${value.offset}`));
217
+ }
218
+ }
219
+ }
220
+ });
221
+ return classes;
222
+ });
223
+ const colStyle = computed(() => {
224
+ return {
225
+ padding: `calc(var(--fire-row-gutter-vertical, 0) * 0.5) calc(var(--fire-row-gutter-horizontal, 0) * 0.5)`
226
+ };
227
+ });
228
+ return (_ctx, _cache) => {
229
+ return openBlock(), createElementBlock("div", {
230
+ class: normalizeClass([
231
+ unref(ns).b,
232
+ {
233
+ [unref(ns).m(`span-${__props.span}`)]: __props.span,
234
+ [unref(ns).m(`offset-${__props.offset}`)]: __props.offset
235
+ },
236
+ ...responsiveClasses.value
237
+ ]),
238
+ style: normalizeStyle(colStyle.value)
239
+ }, [
240
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
241
+ ], 6);
242
+ };
243
+ }
244
+ });
245
+ const Col = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-84066fd0"]]);
246
+ const FireRow = withInstall(Row);
247
+ const FireCol = withInstall(Col);
248
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
249
+ __name: "container",
250
+ props: {
251
+ direction: { default: "horizontal" },
252
+ class: {},
253
+ style: {}
254
+ },
255
+ setup(__props) {
256
+ const ns = useNamespace("container");
257
+ return (_ctx, _cache) => {
258
+ return openBlock(), createElementBlock("div", {
259
+ class: normalizeClass([
260
+ unref(ns).b,
261
+ unref(ns).m(`direction-${__props.direction}`)
262
+ ])
263
+ }, [
264
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
265
+ ], 2);
266
+ };
267
+ }
268
+ });
269
+ const Container = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-6db987fb"]]);
270
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
271
+ __name: "header",
272
+ props: {
273
+ height: { default: 64 },
274
+ class: {},
275
+ style: {}
276
+ },
277
+ setup(__props) {
278
+ const ns = useNamespace("header");
279
+ const props = __props;
280
+ const headerStyle = computed(() => {
281
+ const style = {};
282
+ if (props.height) {
283
+ style.height = typeof props.height === "number" ? `${props.height}px` : props.height;
284
+ }
285
+ return style;
286
+ });
287
+ return (_ctx, _cache) => {
288
+ return openBlock(), createElementBlock("header", {
289
+ class: normalizeClass(unref(ns).b),
290
+ style: normalizeStyle(headerStyle.value)
291
+ }, [
292
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
293
+ ], 6);
294
+ };
295
+ }
296
+ });
297
+ const Header = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-aab8d9a5"]]);
298
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
299
+ __name: "aside",
300
+ props: {
301
+ width: { default: 240 },
302
+ collapsed: { type: Boolean, default: false },
303
+ class: {},
304
+ style: {}
305
+ },
306
+ emits: ["update:collapsed"],
307
+ setup(__props) {
308
+ const ns = useNamespace("aside");
309
+ const props = __props;
310
+ const asideStyle = computed(() => {
311
+ const style = {};
312
+ if (props.width) {
313
+ style.width = typeof props.width === "number" ? `${props.width}px` : props.width;
314
+ }
315
+ return style;
316
+ });
317
+ return (_ctx, _cache) => {
318
+ return openBlock(), createElementBlock("aside", {
319
+ class: normalizeClass([
320
+ unref(ns).b,
321
+ {
322
+ [unref(ns).m("collapsed")]: __props.collapsed
323
+ }
324
+ ]),
325
+ style: normalizeStyle(asideStyle.value)
326
+ }, [
327
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
328
+ ], 6);
329
+ };
330
+ }
331
+ });
332
+ const Aside = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-ab32fa1d"]]);
333
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
334
+ __name: "main",
335
+ props: {
336
+ class: {},
337
+ style: {}
338
+ },
339
+ setup(__props) {
340
+ const ns = useNamespace("main");
341
+ return (_ctx, _cache) => {
342
+ return openBlock(), createElementBlock("main", {
343
+ class: normalizeClass(unref(ns).b)
344
+ }, [
345
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
346
+ ], 2);
347
+ };
348
+ }
349
+ });
350
+ const Main = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-13e2ee00"]]);
351
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
352
+ __name: "footer",
353
+ props: {
354
+ height: { default: 64 },
355
+ class: {},
356
+ style: {}
357
+ },
358
+ setup(__props) {
359
+ const ns = useNamespace("footer");
360
+ const props = __props;
361
+ const footerStyle = computed(() => {
362
+ const style = {};
363
+ if (props.height) {
364
+ style.height = typeof props.height === "number" ? `${props.height}px` : props.height;
365
+ }
366
+ return style;
367
+ });
368
+ return (_ctx, _cache) => {
369
+ return openBlock(), createElementBlock("footer", {
370
+ class: normalizeClass(unref(ns).b),
371
+ style: normalizeStyle(footerStyle.value)
372
+ }, [
373
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
374
+ ], 6);
375
+ };
376
+ }
377
+ });
378
+ const Footer = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-fe55d656"]]);
379
+ const FireContainer = withInstall(Container);
380
+ const FireHeader = withInstall(Header);
381
+ const FireAside = withInstall(Aside);
382
+ const FireMain = withInstall(Main);
383
+ const FireFooter = withInstall(Footer);
384
+ const min = Math.min;
385
+ const max = Math.max;
386
+ const round = Math.round;
387
+ const floor = Math.floor;
388
+ const createCoords = (v) => ({
389
+ x: v,
390
+ y: v
391
+ });
392
+ const oppositeSideMap = {
393
+ left: "right",
394
+ right: "left",
395
+ bottom: "top",
396
+ top: "bottom"
397
+ };
398
+ const oppositeAlignmentMap = {
399
+ start: "end",
400
+ end: "start"
401
+ };
402
+ function evaluate(value, param) {
403
+ return typeof value === "function" ? value(param) : value;
404
+ }
405
+ function getSide(placement) {
406
+ return placement.split("-")[0];
407
+ }
408
+ function getAlignment(placement) {
409
+ return placement.split("-")[1];
410
+ }
411
+ function getOppositeAxis(axis) {
412
+ return axis === "x" ? "y" : "x";
413
+ }
414
+ function getAxisLength(axis) {
415
+ return axis === "y" ? "height" : "width";
416
+ }
417
+ const yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
418
+ function getSideAxis(placement) {
419
+ return yAxisSides.has(getSide(placement)) ? "y" : "x";
420
+ }
421
+ function getAlignmentAxis(placement) {
422
+ return getOppositeAxis(getSideAxis(placement));
423
+ }
424
+ function getAlignmentSides(placement, rects, rtl) {
425
+ if (rtl === void 0) {
426
+ rtl = false;
427
+ }
428
+ const alignment = getAlignment(placement);
429
+ const alignmentAxis = getAlignmentAxis(placement);
430
+ const length = getAxisLength(alignmentAxis);
431
+ let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
432
+ if (rects.reference[length] > rects.floating[length]) {
433
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
434
+ }
435
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
436
+ }
437
+ function getExpandedPlacements(placement) {
438
+ const oppositePlacement = getOppositePlacement(placement);
439
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
440
+ }
441
+ function getOppositeAlignmentPlacement(placement) {
442
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
443
+ }
444
+ const lrPlacement = ["left", "right"];
445
+ const rlPlacement = ["right", "left"];
446
+ const tbPlacement = ["top", "bottom"];
447
+ const btPlacement = ["bottom", "top"];
448
+ function getSideList(side, isStart, rtl) {
449
+ switch (side) {
450
+ case "top":
451
+ case "bottom":
452
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
453
+ return isStart ? lrPlacement : rlPlacement;
454
+ case "left":
455
+ case "right":
456
+ return isStart ? tbPlacement : btPlacement;
457
+ default:
458
+ return [];
459
+ }
460
+ }
461
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
462
+ const alignment = getAlignment(placement);
463
+ let list = getSideList(getSide(placement), direction === "start", rtl);
464
+ if (alignment) {
465
+ list = list.map((side) => side + "-" + alignment);
466
+ if (flipAlignment) {
467
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
468
+ }
469
+ }
470
+ return list;
471
+ }
472
+ function getOppositePlacement(placement) {
473
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
474
+ }
475
+ function expandPaddingObject(padding) {
476
+ return {
477
+ top: 0,
478
+ right: 0,
479
+ bottom: 0,
480
+ left: 0,
481
+ ...padding
482
+ };
483
+ }
484
+ function getPaddingObject(padding) {
485
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
486
+ top: padding,
487
+ right: padding,
488
+ bottom: padding,
489
+ left: padding
490
+ };
491
+ }
492
+ function rectToClientRect(rect) {
493
+ const {
494
+ x,
495
+ y,
496
+ width,
497
+ height
498
+ } = rect;
499
+ return {
500
+ width,
501
+ height,
502
+ top: y,
503
+ left: x,
504
+ right: x + width,
505
+ bottom: y + height,
506
+ x,
507
+ y
508
+ };
509
+ }
510
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
511
+ let {
512
+ reference,
513
+ floating
514
+ } = _ref;
515
+ const sideAxis = getSideAxis(placement);
516
+ const alignmentAxis = getAlignmentAxis(placement);
517
+ const alignLength = getAxisLength(alignmentAxis);
518
+ const side = getSide(placement);
519
+ const isVertical = sideAxis === "y";
520
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
521
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
522
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
523
+ let coords;
524
+ switch (side) {
525
+ case "top":
526
+ coords = {
527
+ x: commonX,
528
+ y: reference.y - floating.height
529
+ };
530
+ break;
531
+ case "bottom":
532
+ coords = {
533
+ x: commonX,
534
+ y: reference.y + reference.height
535
+ };
536
+ break;
537
+ case "right":
538
+ coords = {
539
+ x: reference.x + reference.width,
540
+ y: commonY
541
+ };
542
+ break;
543
+ case "left":
544
+ coords = {
545
+ x: reference.x - floating.width,
546
+ y: commonY
547
+ };
548
+ break;
549
+ default:
550
+ coords = {
551
+ x: reference.x,
552
+ y: reference.y
553
+ };
554
+ }
555
+ switch (getAlignment(placement)) {
556
+ case "start":
557
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
558
+ break;
559
+ case "end":
560
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
561
+ break;
562
+ }
563
+ return coords;
564
+ }
565
+ async function detectOverflow(state, options) {
566
+ var _await$platform$isEle;
567
+ if (options === void 0) {
568
+ options = {};
569
+ }
570
+ const {
571
+ x,
572
+ y,
573
+ platform: platform2,
574
+ rects,
575
+ elements,
576
+ strategy
577
+ } = state;
578
+ const {
579
+ boundary = "clippingAncestors",
580
+ rootBoundary = "viewport",
581
+ elementContext = "floating",
582
+ altBoundary = false,
583
+ padding = 0
584
+ } = evaluate(options, state);
585
+ const paddingObject = getPaddingObject(padding);
586
+ const altContext = elementContext === "floating" ? "reference" : "floating";
587
+ const element = elements[altBoundary ? altContext : elementContext];
588
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
589
+ element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
590
+ boundary,
591
+ rootBoundary,
592
+ strategy
593
+ }));
594
+ const rect = elementContext === "floating" ? {
595
+ x,
596
+ y,
597
+ width: rects.floating.width,
598
+ height: rects.floating.height
599
+ } : rects.reference;
600
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
601
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
602
+ x: 1,
603
+ y: 1
604
+ } : {
605
+ x: 1,
606
+ y: 1
607
+ };
608
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
609
+ elements,
610
+ rect,
611
+ offsetParent,
612
+ strategy
613
+ }) : rect);
614
+ return {
615
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
616
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
617
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
618
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
619
+ };
620
+ }
621
+ const computePosition$1 = async (reference, floating, config) => {
622
+ const {
623
+ placement = "bottom",
624
+ strategy = "absolute",
625
+ middleware = [],
626
+ platform: platform2
627
+ } = config;
628
+ const validMiddleware = middleware.filter(Boolean);
629
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
630
+ let rects = await platform2.getElementRects({
631
+ reference,
632
+ floating,
633
+ strategy
634
+ });
635
+ let {
636
+ x,
637
+ y
638
+ } = computeCoordsFromPlacement(rects, placement, rtl);
639
+ let statefulPlacement = placement;
640
+ let middlewareData = {};
641
+ let resetCount = 0;
642
+ for (let i = 0; i < validMiddleware.length; i++) {
643
+ var _platform$detectOverf;
644
+ const {
645
+ name,
646
+ fn
647
+ } = validMiddleware[i];
648
+ const {
649
+ x: nextX,
650
+ y: nextY,
651
+ data,
652
+ reset
653
+ } = await fn({
654
+ x,
655
+ y,
656
+ initialPlacement: placement,
657
+ placement: statefulPlacement,
658
+ strategy,
659
+ middlewareData,
660
+ rects,
661
+ platform: {
662
+ ...platform2,
663
+ detectOverflow: (_platform$detectOverf = platform2.detectOverflow) != null ? _platform$detectOverf : detectOverflow
664
+ },
665
+ elements: {
666
+ reference,
667
+ floating
668
+ }
669
+ });
670
+ x = nextX != null ? nextX : x;
671
+ y = nextY != null ? nextY : y;
672
+ middlewareData = {
673
+ ...middlewareData,
674
+ [name]: {
675
+ ...middlewareData[name],
676
+ ...data
677
+ }
678
+ };
679
+ if (reset && resetCount <= 50) {
680
+ resetCount++;
681
+ if (typeof reset === "object") {
682
+ if (reset.placement) {
683
+ statefulPlacement = reset.placement;
684
+ }
685
+ if (reset.rects) {
686
+ rects = reset.rects === true ? await platform2.getElementRects({
687
+ reference,
688
+ floating,
689
+ strategy
690
+ }) : reset.rects;
691
+ }
692
+ ({
693
+ x,
694
+ y
695
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
696
+ }
697
+ i = -1;
698
+ }
699
+ }
700
+ return {
701
+ x,
702
+ y,
703
+ placement: statefulPlacement,
704
+ strategy,
705
+ middlewareData
706
+ };
707
+ };
708
+ const flip$1 = function(options) {
709
+ if (options === void 0) {
710
+ options = {};
711
+ }
712
+ return {
713
+ name: "flip",
714
+ options,
715
+ async fn(state) {
716
+ var _middlewareData$arrow, _middlewareData$flip;
717
+ const {
718
+ placement,
719
+ middlewareData,
720
+ rects,
721
+ initialPlacement,
722
+ platform: platform2,
723
+ elements
724
+ } = state;
725
+ const {
726
+ mainAxis: checkMainAxis = true,
727
+ crossAxis: checkCrossAxis = true,
728
+ fallbackPlacements: specifiedFallbackPlacements,
729
+ fallbackStrategy = "bestFit",
730
+ fallbackAxisSideDirection = "none",
731
+ flipAlignment = true,
732
+ ...detectOverflowOptions
733
+ } = evaluate(options, state);
734
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
735
+ return {};
736
+ }
737
+ const side = getSide(placement);
738
+ const initialSideAxis = getSideAxis(initialPlacement);
739
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
740
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
741
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
742
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
743
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
744
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
745
+ }
746
+ const placements = [initialPlacement, ...fallbackPlacements];
747
+ const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
748
+ const overflows = [];
749
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
750
+ if (checkMainAxis) {
751
+ overflows.push(overflow[side]);
752
+ }
753
+ if (checkCrossAxis) {
754
+ const sides = getAlignmentSides(placement, rects, rtl);
755
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
756
+ }
757
+ overflowsData = [...overflowsData, {
758
+ placement,
759
+ overflows
760
+ }];
761
+ if (!overflows.every((side2) => side2 <= 0)) {
762
+ var _middlewareData$flip2, _overflowsData$filter;
763
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
764
+ const nextPlacement = placements[nextIndex];
765
+ if (nextPlacement) {
766
+ const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
767
+ if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
768
+ // overflows the main axis.
769
+ overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
770
+ return {
771
+ data: {
772
+ index: nextIndex,
773
+ overflows: overflowsData
774
+ },
775
+ reset: {
776
+ placement: nextPlacement
777
+ }
778
+ };
779
+ }
780
+ }
781
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
782
+ if (!resetPlacement) {
783
+ switch (fallbackStrategy) {
784
+ case "bestFit": {
785
+ var _overflowsData$filter2;
786
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
787
+ if (hasFallbackAxisSideDirection) {
788
+ const currentSideAxis = getSideAxis(d.placement);
789
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
790
+ // reading directions favoring greater width.
791
+ currentSideAxis === "y";
792
+ }
793
+ return true;
794
+ }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
795
+ if (placement2) {
796
+ resetPlacement = placement2;
797
+ }
798
+ break;
799
+ }
800
+ case "initialPlacement":
801
+ resetPlacement = initialPlacement;
802
+ break;
803
+ }
804
+ }
805
+ if (placement !== resetPlacement) {
806
+ return {
807
+ reset: {
808
+ placement: resetPlacement
809
+ }
810
+ };
811
+ }
812
+ }
813
+ return {};
814
+ }
815
+ };
816
+ };
817
+ const originSides = /* @__PURE__ */ new Set(["left", "top"]);
818
+ async function convertValueToCoords(state, options) {
819
+ const {
820
+ placement,
821
+ platform: platform2,
822
+ elements
823
+ } = state;
824
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
825
+ const side = getSide(placement);
826
+ const alignment = getAlignment(placement);
827
+ const isVertical = getSideAxis(placement) === "y";
828
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
829
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
830
+ const rawValue = evaluate(options, state);
831
+ let {
832
+ mainAxis,
833
+ crossAxis,
834
+ alignmentAxis
835
+ } = typeof rawValue === "number" ? {
836
+ mainAxis: rawValue,
837
+ crossAxis: 0,
838
+ alignmentAxis: null
839
+ } : {
840
+ mainAxis: rawValue.mainAxis || 0,
841
+ crossAxis: rawValue.crossAxis || 0,
842
+ alignmentAxis: rawValue.alignmentAxis
843
+ };
844
+ if (alignment && typeof alignmentAxis === "number") {
845
+ crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
846
+ }
847
+ return isVertical ? {
848
+ x: crossAxis * crossAxisMulti,
849
+ y: mainAxis * mainAxisMulti
850
+ } : {
851
+ x: mainAxis * mainAxisMulti,
852
+ y: crossAxis * crossAxisMulti
853
+ };
854
+ }
855
+ const offset$1 = function(options) {
856
+ if (options === void 0) {
857
+ options = 0;
858
+ }
859
+ return {
860
+ name: "offset",
861
+ options,
862
+ async fn(state) {
863
+ var _middlewareData$offse, _middlewareData$arrow;
864
+ const {
865
+ x,
866
+ y,
867
+ placement,
868
+ middlewareData
869
+ } = state;
870
+ const diffCoords = await convertValueToCoords(state, options);
871
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
872
+ return {};
873
+ }
874
+ return {
875
+ x: x + diffCoords.x,
876
+ y: y + diffCoords.y,
877
+ data: {
878
+ ...diffCoords,
879
+ placement
880
+ }
881
+ };
882
+ }
883
+ };
884
+ };
885
+ function hasWindow() {
886
+ return typeof window !== "undefined";
887
+ }
888
+ function getNodeName(node) {
889
+ if (isNode(node)) {
890
+ return (node.nodeName || "").toLowerCase();
891
+ }
892
+ return "#document";
893
+ }
894
+ function getWindow(node) {
895
+ var _node$ownerDocument;
896
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
897
+ }
898
+ function getDocumentElement(node) {
899
+ var _ref;
900
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
901
+ }
902
+ function isNode(value) {
903
+ if (!hasWindow()) {
904
+ return false;
905
+ }
906
+ return value instanceof Node || value instanceof getWindow(value).Node;
907
+ }
908
+ function isElement(value) {
909
+ if (!hasWindow()) {
910
+ return false;
911
+ }
912
+ return value instanceof Element || value instanceof getWindow(value).Element;
913
+ }
914
+ function isHTMLElement(value) {
915
+ if (!hasWindow()) {
916
+ return false;
917
+ }
918
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
919
+ }
920
+ function isShadowRoot(value) {
921
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
922
+ return false;
923
+ }
924
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
925
+ }
926
+ const invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
927
+ function isOverflowElement(element) {
928
+ const {
929
+ overflow,
930
+ overflowX,
931
+ overflowY,
932
+ display
933
+ } = getComputedStyle$1(element);
934
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
935
+ }
936
+ const tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]);
937
+ function isTableElement(element) {
938
+ return tableElements.has(getNodeName(element));
939
+ }
940
+ const topLayerSelectors = [":popover-open", ":modal"];
941
+ function isTopLayer(element) {
942
+ return topLayerSelectors.some((selector) => {
943
+ try {
944
+ return element.matches(selector);
945
+ } catch (_e) {
946
+ return false;
947
+ }
948
+ });
949
+ }
950
+ const transformProperties = ["transform", "translate", "scale", "rotate", "perspective"];
951
+ const willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"];
952
+ const containValues = ["paint", "layout", "strict", "content"];
953
+ function isContainingBlock(elementOrCss) {
954
+ const webkit = isWebKit();
955
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
956
+ return transformProperties.some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || willChangeValues.some((value) => (css.willChange || "").includes(value)) || containValues.some((value) => (css.contain || "").includes(value));
957
+ }
958
+ function getContainingBlock(element) {
959
+ let currentNode = getParentNode(element);
960
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
961
+ if (isContainingBlock(currentNode)) {
962
+ return currentNode;
963
+ } else if (isTopLayer(currentNode)) {
964
+ return null;
965
+ }
966
+ currentNode = getParentNode(currentNode);
967
+ }
968
+ return null;
969
+ }
970
+ function isWebKit() {
971
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
972
+ return CSS.supports("-webkit-backdrop-filter", "none");
973
+ }
974
+ const lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]);
975
+ function isLastTraversableNode(node) {
976
+ return lastTraversableNodeNames.has(getNodeName(node));
977
+ }
978
+ function getComputedStyle$1(element) {
979
+ return getWindow(element).getComputedStyle(element);
980
+ }
981
+ function getNodeScroll(element) {
982
+ if (isElement(element)) {
983
+ return {
984
+ scrollLeft: element.scrollLeft,
985
+ scrollTop: element.scrollTop
986
+ };
987
+ }
988
+ return {
989
+ scrollLeft: element.scrollX,
990
+ scrollTop: element.scrollY
991
+ };
992
+ }
993
+ function getParentNode(node) {
994
+ if (getNodeName(node) === "html") {
995
+ return node;
996
+ }
997
+ const result = (
998
+ // Step into the shadow DOM of the parent of a slotted node.
999
+ node.assignedSlot || // DOM Element detected.
1000
+ node.parentNode || // ShadowRoot detected.
1001
+ isShadowRoot(node) && node.host || // Fallback.
1002
+ getDocumentElement(node)
1003
+ );
1004
+ return isShadowRoot(result) ? result.host : result;
1005
+ }
1006
+ function getNearestOverflowAncestor(node) {
1007
+ const parentNode = getParentNode(node);
1008
+ if (isLastTraversableNode(parentNode)) {
1009
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1010
+ }
1011
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1012
+ return parentNode;
1013
+ }
1014
+ return getNearestOverflowAncestor(parentNode);
1015
+ }
1016
+ function getOverflowAncestors(node, list, traverseIframes) {
1017
+ var _node$ownerDocument2;
1018
+ if (list === void 0) {
1019
+ list = [];
1020
+ }
1021
+ if (traverseIframes === void 0) {
1022
+ traverseIframes = true;
1023
+ }
1024
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1025
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1026
+ const win = getWindow(scrollableAncestor);
1027
+ if (isBody) {
1028
+ const frameElement = getFrameElement(win);
1029
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1030
+ }
1031
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1032
+ }
1033
+ function getFrameElement(win) {
1034
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1035
+ }
1036
+ function getCssDimensions(element) {
1037
+ const css = getComputedStyle$1(element);
1038
+ let width = parseFloat(css.width) || 0;
1039
+ let height = parseFloat(css.height) || 0;
1040
+ const hasOffset = isHTMLElement(element);
1041
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1042
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1043
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1044
+ if (shouldFallback) {
1045
+ width = offsetWidth;
1046
+ height = offsetHeight;
1047
+ }
1048
+ return {
1049
+ width,
1050
+ height,
1051
+ $: shouldFallback
1052
+ };
1053
+ }
1054
+ function unwrapElement$1(element) {
1055
+ return !isElement(element) ? element.contextElement : element;
1056
+ }
1057
+ function getScale(element) {
1058
+ const domElement = unwrapElement$1(element);
1059
+ if (!isHTMLElement(domElement)) {
1060
+ return createCoords(1);
1061
+ }
1062
+ const rect = domElement.getBoundingClientRect();
1063
+ const {
1064
+ width,
1065
+ height,
1066
+ $
1067
+ } = getCssDimensions(domElement);
1068
+ let x = ($ ? round(rect.width) : rect.width) / width;
1069
+ let y = ($ ? round(rect.height) : rect.height) / height;
1070
+ if (!x || !Number.isFinite(x)) {
1071
+ x = 1;
1072
+ }
1073
+ if (!y || !Number.isFinite(y)) {
1074
+ y = 1;
1075
+ }
1076
+ return {
1077
+ x,
1078
+ y
1079
+ };
1080
+ }
1081
+ const noOffsets = /* @__PURE__ */ createCoords(0);
1082
+ function getVisualOffsets(element) {
1083
+ const win = getWindow(element);
1084
+ if (!isWebKit() || !win.visualViewport) {
1085
+ return noOffsets;
1086
+ }
1087
+ return {
1088
+ x: win.visualViewport.offsetLeft,
1089
+ y: win.visualViewport.offsetTop
1090
+ };
1091
+ }
1092
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1093
+ if (isFixed === void 0) {
1094
+ isFixed = false;
1095
+ }
1096
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1097
+ return false;
1098
+ }
1099
+ return isFixed;
1100
+ }
1101
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1102
+ if (includeScale === void 0) {
1103
+ includeScale = false;
1104
+ }
1105
+ if (isFixedStrategy === void 0) {
1106
+ isFixedStrategy = false;
1107
+ }
1108
+ const clientRect = element.getBoundingClientRect();
1109
+ const domElement = unwrapElement$1(element);
1110
+ let scale = createCoords(1);
1111
+ if (includeScale) {
1112
+ if (offsetParent) {
1113
+ if (isElement(offsetParent)) {
1114
+ scale = getScale(offsetParent);
1115
+ }
1116
+ } else {
1117
+ scale = getScale(element);
1118
+ }
1119
+ }
1120
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1121
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1122
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1123
+ let width = clientRect.width / scale.x;
1124
+ let height = clientRect.height / scale.y;
1125
+ if (domElement) {
1126
+ const win = getWindow(domElement);
1127
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1128
+ let currentWin = win;
1129
+ let currentIFrame = getFrameElement(currentWin);
1130
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1131
+ const iframeScale = getScale(currentIFrame);
1132
+ const iframeRect = currentIFrame.getBoundingClientRect();
1133
+ const css = getComputedStyle$1(currentIFrame);
1134
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1135
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1136
+ x *= iframeScale.x;
1137
+ y *= iframeScale.y;
1138
+ width *= iframeScale.x;
1139
+ height *= iframeScale.y;
1140
+ x += left;
1141
+ y += top;
1142
+ currentWin = getWindow(currentIFrame);
1143
+ currentIFrame = getFrameElement(currentWin);
1144
+ }
1145
+ }
1146
+ return rectToClientRect({
1147
+ width,
1148
+ height,
1149
+ x,
1150
+ y
1151
+ });
1152
+ }
1153
+ function getWindowScrollBarX(element, rect) {
1154
+ const leftScroll = getNodeScroll(element).scrollLeft;
1155
+ if (!rect) {
1156
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1157
+ }
1158
+ return rect.left + leftScroll;
1159
+ }
1160
+ function getHTMLOffset(documentElement, scroll) {
1161
+ const htmlRect = documentElement.getBoundingClientRect();
1162
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
1163
+ const y = htmlRect.top + scroll.scrollTop;
1164
+ return {
1165
+ x,
1166
+ y
1167
+ };
1168
+ }
1169
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1170
+ let {
1171
+ elements,
1172
+ rect,
1173
+ offsetParent,
1174
+ strategy
1175
+ } = _ref;
1176
+ const isFixed = strategy === "fixed";
1177
+ const documentElement = getDocumentElement(offsetParent);
1178
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1179
+ if (offsetParent === documentElement || topLayer && isFixed) {
1180
+ return rect;
1181
+ }
1182
+ let scroll = {
1183
+ scrollLeft: 0,
1184
+ scrollTop: 0
1185
+ };
1186
+ let scale = createCoords(1);
1187
+ const offsets = createCoords(0);
1188
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1189
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1190
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1191
+ scroll = getNodeScroll(offsetParent);
1192
+ }
1193
+ if (isHTMLElement(offsetParent)) {
1194
+ const offsetRect = getBoundingClientRect(offsetParent);
1195
+ scale = getScale(offsetParent);
1196
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1197
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1198
+ }
1199
+ }
1200
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1201
+ return {
1202
+ width: rect.width * scale.x,
1203
+ height: rect.height * scale.y,
1204
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1205
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1206
+ };
1207
+ }
1208
+ function getClientRects(element) {
1209
+ return Array.from(element.getClientRects());
1210
+ }
1211
+ function getDocumentRect(element) {
1212
+ const html = getDocumentElement(element);
1213
+ const scroll = getNodeScroll(element);
1214
+ const body = element.ownerDocument.body;
1215
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1216
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1217
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1218
+ const y = -scroll.scrollTop;
1219
+ if (getComputedStyle$1(body).direction === "rtl") {
1220
+ x += max(html.clientWidth, body.clientWidth) - width;
1221
+ }
1222
+ return {
1223
+ width,
1224
+ height,
1225
+ x,
1226
+ y
1227
+ };
1228
+ }
1229
+ const SCROLLBAR_MAX = 25;
1230
+ function getViewportRect(element, strategy) {
1231
+ const win = getWindow(element);
1232
+ const html = getDocumentElement(element);
1233
+ const visualViewport = win.visualViewport;
1234
+ let width = html.clientWidth;
1235
+ let height = html.clientHeight;
1236
+ let x = 0;
1237
+ let y = 0;
1238
+ if (visualViewport) {
1239
+ width = visualViewport.width;
1240
+ height = visualViewport.height;
1241
+ const visualViewportBased = isWebKit();
1242
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
1243
+ x = visualViewport.offsetLeft;
1244
+ y = visualViewport.offsetTop;
1245
+ }
1246
+ }
1247
+ const windowScrollbarX = getWindowScrollBarX(html);
1248
+ if (windowScrollbarX <= 0) {
1249
+ const doc = html.ownerDocument;
1250
+ const body = doc.body;
1251
+ const bodyStyles = getComputedStyle(body);
1252
+ const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
1253
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
1254
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
1255
+ width -= clippingStableScrollbarWidth;
1256
+ }
1257
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
1258
+ width += windowScrollbarX;
1259
+ }
1260
+ return {
1261
+ width,
1262
+ height,
1263
+ x,
1264
+ y
1265
+ };
1266
+ }
1267
+ const absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
1268
+ function getInnerBoundingClientRect(element, strategy) {
1269
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
1270
+ const top = clientRect.top + element.clientTop;
1271
+ const left = clientRect.left + element.clientLeft;
1272
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1273
+ const width = element.clientWidth * scale.x;
1274
+ const height = element.clientHeight * scale.y;
1275
+ const x = left * scale.x;
1276
+ const y = top * scale.y;
1277
+ return {
1278
+ width,
1279
+ height,
1280
+ x,
1281
+ y
1282
+ };
1283
+ }
1284
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1285
+ let rect;
1286
+ if (clippingAncestor === "viewport") {
1287
+ rect = getViewportRect(element, strategy);
1288
+ } else if (clippingAncestor === "document") {
1289
+ rect = getDocumentRect(getDocumentElement(element));
1290
+ } else if (isElement(clippingAncestor)) {
1291
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1292
+ } else {
1293
+ const visualOffsets = getVisualOffsets(element);
1294
+ rect = {
1295
+ x: clippingAncestor.x - visualOffsets.x,
1296
+ y: clippingAncestor.y - visualOffsets.y,
1297
+ width: clippingAncestor.width,
1298
+ height: clippingAncestor.height
1299
+ };
1300
+ }
1301
+ return rectToClientRect(rect);
1302
+ }
1303
+ function hasFixedPositionAncestor(element, stopNode) {
1304
+ const parentNode = getParentNode(element);
1305
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1306
+ return false;
1307
+ }
1308
+ return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
1309
+ }
1310
+ function getClippingElementAncestors(element, cache) {
1311
+ const cachedResult = cache.get(element);
1312
+ if (cachedResult) {
1313
+ return cachedResult;
1314
+ }
1315
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
1316
+ let currentContainingBlockComputedStyle = null;
1317
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
1318
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1319
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1320
+ const computedStyle = getComputedStyle$1(currentNode);
1321
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1322
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
1323
+ currentContainingBlockComputedStyle = null;
1324
+ }
1325
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1326
+ if (shouldDropCurrentNode) {
1327
+ result = result.filter((ancestor) => ancestor !== currentNode);
1328
+ } else {
1329
+ currentContainingBlockComputedStyle = computedStyle;
1330
+ }
1331
+ currentNode = getParentNode(currentNode);
1332
+ }
1333
+ cache.set(element, result);
1334
+ return result;
1335
+ }
1336
+ function getClippingRect(_ref) {
1337
+ let {
1338
+ element,
1339
+ boundary,
1340
+ rootBoundary,
1341
+ strategy
1342
+ } = _ref;
1343
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1344
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1345
+ const firstClippingAncestor = clippingAncestors[0];
1346
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1347
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1348
+ accRect.top = max(rect.top, accRect.top);
1349
+ accRect.right = min(rect.right, accRect.right);
1350
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1351
+ accRect.left = max(rect.left, accRect.left);
1352
+ return accRect;
1353
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1354
+ return {
1355
+ width: clippingRect.right - clippingRect.left,
1356
+ height: clippingRect.bottom - clippingRect.top,
1357
+ x: clippingRect.left,
1358
+ y: clippingRect.top
1359
+ };
1360
+ }
1361
+ function getDimensions(element) {
1362
+ const {
1363
+ width,
1364
+ height
1365
+ } = getCssDimensions(element);
1366
+ return {
1367
+ width,
1368
+ height
1369
+ };
1370
+ }
1371
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1372
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1373
+ const documentElement = getDocumentElement(offsetParent);
1374
+ const isFixed = strategy === "fixed";
1375
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1376
+ let scroll = {
1377
+ scrollLeft: 0,
1378
+ scrollTop: 0
1379
+ };
1380
+ const offsets = createCoords(0);
1381
+ function setLeftRTLScrollbarOffset() {
1382
+ offsets.x = getWindowScrollBarX(documentElement);
1383
+ }
1384
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1385
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
1386
+ scroll = getNodeScroll(offsetParent);
1387
+ }
1388
+ if (isOffsetParentAnElement) {
1389
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1390
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1391
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1392
+ } else if (documentElement) {
1393
+ setLeftRTLScrollbarOffset();
1394
+ }
1395
+ }
1396
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
1397
+ setLeftRTLScrollbarOffset();
1398
+ }
1399
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1400
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1401
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1402
+ return {
1403
+ x,
1404
+ y,
1405
+ width: rect.width,
1406
+ height: rect.height
1407
+ };
1408
+ }
1409
+ function isStaticPositioned(element) {
1410
+ return getComputedStyle$1(element).position === "static";
1411
+ }
1412
+ function getTrueOffsetParent(element, polyfill) {
1413
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
1414
+ return null;
1415
+ }
1416
+ if (polyfill) {
1417
+ return polyfill(element);
1418
+ }
1419
+ let rawOffsetParent = element.offsetParent;
1420
+ if (getDocumentElement(element) === rawOffsetParent) {
1421
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1422
+ }
1423
+ return rawOffsetParent;
1424
+ }
1425
+ function getOffsetParent(element, polyfill) {
1426
+ const win = getWindow(element);
1427
+ if (isTopLayer(element)) {
1428
+ return win;
1429
+ }
1430
+ if (!isHTMLElement(element)) {
1431
+ let svgOffsetParent = getParentNode(element);
1432
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1433
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1434
+ return svgOffsetParent;
1435
+ }
1436
+ svgOffsetParent = getParentNode(svgOffsetParent);
1437
+ }
1438
+ return win;
1439
+ }
1440
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1441
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1442
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1443
+ }
1444
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1445
+ return win;
1446
+ }
1447
+ return offsetParent || getContainingBlock(element) || win;
1448
+ }
1449
+ const getElementRects = async function(data) {
1450
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1451
+ const getDimensionsFn = this.getDimensions;
1452
+ const floatingDimensions = await getDimensionsFn(data.floating);
1453
+ return {
1454
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1455
+ floating: {
1456
+ x: 0,
1457
+ y: 0,
1458
+ width: floatingDimensions.width,
1459
+ height: floatingDimensions.height
1460
+ }
1461
+ };
1462
+ };
1463
+ function isRTL(element) {
1464
+ return getComputedStyle$1(element).direction === "rtl";
1465
+ }
1466
+ const platform = {
1467
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1468
+ getDocumentElement,
1469
+ getClippingRect,
1470
+ getOffsetParent,
1471
+ getElementRects,
1472
+ getClientRects,
1473
+ getDimensions,
1474
+ getScale,
1475
+ isElement,
1476
+ isRTL
1477
+ };
1478
+ function rectsAreEqual(a, b) {
1479
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
1480
+ }
1481
+ function observeMove(element, onMove) {
1482
+ let io = null;
1483
+ let timeoutId;
1484
+ const root = getDocumentElement(element);
1485
+ function cleanup() {
1486
+ var _io;
1487
+ clearTimeout(timeoutId);
1488
+ (_io = io) == null || _io.disconnect();
1489
+ io = null;
1490
+ }
1491
+ function refresh(skip, threshold) {
1492
+ if (skip === void 0) {
1493
+ skip = false;
1494
+ }
1495
+ if (threshold === void 0) {
1496
+ threshold = 1;
1497
+ }
1498
+ cleanup();
1499
+ const elementRectForRootMargin = element.getBoundingClientRect();
1500
+ const {
1501
+ left,
1502
+ top,
1503
+ width,
1504
+ height
1505
+ } = elementRectForRootMargin;
1506
+ if (!skip) {
1507
+ onMove();
1508
+ }
1509
+ if (!width || !height) {
1510
+ return;
1511
+ }
1512
+ const insetTop = floor(top);
1513
+ const insetRight = floor(root.clientWidth - (left + width));
1514
+ const insetBottom = floor(root.clientHeight - (top + height));
1515
+ const insetLeft = floor(left);
1516
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1517
+ const options = {
1518
+ rootMargin,
1519
+ threshold: max(0, min(1, threshold)) || 1
1520
+ };
1521
+ let isFirstUpdate = true;
1522
+ function handleObserve(entries) {
1523
+ const ratio = entries[0].intersectionRatio;
1524
+ if (ratio !== threshold) {
1525
+ if (!isFirstUpdate) {
1526
+ return refresh();
1527
+ }
1528
+ if (!ratio) {
1529
+ timeoutId = setTimeout(() => {
1530
+ refresh(false, 1e-7);
1531
+ }, 1e3);
1532
+ } else {
1533
+ refresh(false, ratio);
1534
+ }
1535
+ }
1536
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
1537
+ refresh();
1538
+ }
1539
+ isFirstUpdate = false;
1540
+ }
1541
+ try {
1542
+ io = new IntersectionObserver(handleObserve, {
1543
+ ...options,
1544
+ // Handle <iframe>s
1545
+ root: root.ownerDocument
1546
+ });
1547
+ } catch (_e) {
1548
+ io = new IntersectionObserver(handleObserve, options);
1549
+ }
1550
+ io.observe(element);
1551
+ }
1552
+ refresh(true);
1553
+ return cleanup;
1554
+ }
1555
+ function autoUpdate(reference, floating, update, options) {
1556
+ if (options === void 0) {
1557
+ options = {};
1558
+ }
1559
+ const {
1560
+ ancestorScroll = true,
1561
+ ancestorResize = true,
1562
+ elementResize = typeof ResizeObserver === "function",
1563
+ layoutShift = typeof IntersectionObserver === "function",
1564
+ animationFrame = false
1565
+ } = options;
1566
+ const referenceEl = unwrapElement$1(reference);
1567
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
1568
+ ancestors.forEach((ancestor) => {
1569
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
1570
+ passive: true
1571
+ });
1572
+ ancestorResize && ancestor.addEventListener("resize", update);
1573
+ });
1574
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1575
+ let reobserveFrame = -1;
1576
+ let resizeObserver = null;
1577
+ if (elementResize) {
1578
+ resizeObserver = new ResizeObserver((_ref) => {
1579
+ let [firstEntry] = _ref;
1580
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1581
+ resizeObserver.unobserve(floating);
1582
+ cancelAnimationFrame(reobserveFrame);
1583
+ reobserveFrame = requestAnimationFrame(() => {
1584
+ var _resizeObserver;
1585
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1586
+ });
1587
+ }
1588
+ update();
1589
+ });
1590
+ if (referenceEl && !animationFrame) {
1591
+ resizeObserver.observe(referenceEl);
1592
+ }
1593
+ resizeObserver.observe(floating);
1594
+ }
1595
+ let frameId;
1596
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1597
+ if (animationFrame) {
1598
+ frameLoop();
1599
+ }
1600
+ function frameLoop() {
1601
+ const nextRefRect = getBoundingClientRect(reference);
1602
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
1603
+ update();
1604
+ }
1605
+ prevRefRect = nextRefRect;
1606
+ frameId = requestAnimationFrame(frameLoop);
1607
+ }
1608
+ update();
1609
+ return () => {
1610
+ var _resizeObserver2;
1611
+ ancestors.forEach((ancestor) => {
1612
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
1613
+ ancestorResize && ancestor.removeEventListener("resize", update);
1614
+ });
1615
+ cleanupIo == null || cleanupIo();
1616
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1617
+ resizeObserver = null;
1618
+ if (animationFrame) {
1619
+ cancelAnimationFrame(frameId);
1620
+ }
1621
+ };
1622
+ }
1623
+ const offset = offset$1;
1624
+ const flip = flip$1;
1625
+ const computePosition = (reference, floating, options) => {
1626
+ const cache = /* @__PURE__ */ new Map();
1627
+ const mergedOptions = {
1628
+ platform,
1629
+ ...options
1630
+ };
1631
+ const platformWithCache = {
1632
+ ...mergedOptions.platform,
1633
+ _c: cache
1634
+ };
1635
+ return computePosition$1(reference, floating, {
1636
+ ...mergedOptions,
1637
+ platform: platformWithCache
1638
+ });
1639
+ };
1640
+ function isComponentPublicInstance(target) {
1641
+ return target != null && typeof target === "object" && "$el" in target;
1642
+ }
1643
+ function unwrapElement(target) {
1644
+ if (isComponentPublicInstance(target)) {
1645
+ const element = target.$el;
1646
+ return isNode(element) && getNodeName(element) === "#comment" ? null : element;
1647
+ }
1648
+ return target;
1649
+ }
1650
+ function toValue(source) {
1651
+ return typeof source === "function" ? source() : unref(source);
1652
+ }
1653
+ function getDPR(element) {
1654
+ if (typeof window === "undefined") {
1655
+ return 1;
1656
+ }
1657
+ const win = element.ownerDocument.defaultView || window;
1658
+ return win.devicePixelRatio || 1;
1659
+ }
1660
+ function roundByDPR(element, value) {
1661
+ const dpr = getDPR(element);
1662
+ return Math.round(value * dpr) / dpr;
1663
+ }
1664
+ function useFloating(reference, floating, options) {
1665
+ if (options === void 0) {
1666
+ options = {};
1667
+ }
1668
+ const whileElementsMountedOption = options.whileElementsMounted;
1669
+ const openOption = computed(() => {
1670
+ var _toValue;
1671
+ return (_toValue = toValue(options.open)) != null ? _toValue : true;
1672
+ });
1673
+ const middlewareOption = computed(() => toValue(options.middleware));
1674
+ const placementOption = computed(() => {
1675
+ var _toValue2;
1676
+ return (_toValue2 = toValue(options.placement)) != null ? _toValue2 : "bottom";
1677
+ });
1678
+ const strategyOption = computed(() => {
1679
+ var _toValue3;
1680
+ return (_toValue3 = toValue(options.strategy)) != null ? _toValue3 : "absolute";
1681
+ });
1682
+ const transformOption = computed(() => {
1683
+ var _toValue4;
1684
+ return (_toValue4 = toValue(options.transform)) != null ? _toValue4 : true;
1685
+ });
1686
+ const referenceElement = computed(() => unwrapElement(reference.value));
1687
+ const floatingElement = computed(() => unwrapElement(floating.value));
1688
+ const x = ref(0);
1689
+ const y = ref(0);
1690
+ const strategy = ref(strategyOption.value);
1691
+ const placement = ref(placementOption.value);
1692
+ const middlewareData = shallowRef({});
1693
+ const isPositioned = ref(false);
1694
+ const floatingStyles = computed(() => {
1695
+ const initialStyles = {
1696
+ position: strategy.value,
1697
+ left: "0",
1698
+ top: "0"
1699
+ };
1700
+ if (!floatingElement.value) {
1701
+ return initialStyles;
1702
+ }
1703
+ const xVal = roundByDPR(floatingElement.value, x.value);
1704
+ const yVal = roundByDPR(floatingElement.value, y.value);
1705
+ if (transformOption.value) {
1706
+ return {
1707
+ ...initialStyles,
1708
+ transform: "translate(" + xVal + "px, " + yVal + "px)",
1709
+ ...getDPR(floatingElement.value) >= 1.5 && {
1710
+ willChange: "transform"
1711
+ }
1712
+ };
1713
+ }
1714
+ return {
1715
+ position: strategy.value,
1716
+ left: xVal + "px",
1717
+ top: yVal + "px"
1718
+ };
1719
+ });
1720
+ let whileElementsMountedCleanup;
1721
+ function update() {
1722
+ if (referenceElement.value == null || floatingElement.value == null) {
1723
+ return;
1724
+ }
1725
+ const open = openOption.value;
1726
+ computePosition(referenceElement.value, floatingElement.value, {
1727
+ middleware: middlewareOption.value,
1728
+ placement: placementOption.value,
1729
+ strategy: strategyOption.value
1730
+ }).then((position) => {
1731
+ x.value = position.x;
1732
+ y.value = position.y;
1733
+ strategy.value = position.strategy;
1734
+ placement.value = position.placement;
1735
+ middlewareData.value = position.middlewareData;
1736
+ isPositioned.value = open !== false;
1737
+ });
1738
+ }
1739
+ function cleanup() {
1740
+ if (typeof whileElementsMountedCleanup === "function") {
1741
+ whileElementsMountedCleanup();
1742
+ whileElementsMountedCleanup = void 0;
1743
+ }
1744
+ }
1745
+ function attach() {
1746
+ cleanup();
1747
+ if (whileElementsMountedOption === void 0) {
1748
+ update();
1749
+ return;
1750
+ }
1751
+ if (referenceElement.value != null && floatingElement.value != null) {
1752
+ whileElementsMountedCleanup = whileElementsMountedOption(referenceElement.value, floatingElement.value, update);
1753
+ return;
1754
+ }
1755
+ }
1756
+ function reset() {
1757
+ if (!openOption.value) {
1758
+ isPositioned.value = false;
1759
+ }
1760
+ }
1761
+ watch([middlewareOption, placementOption, strategyOption, openOption], update, {
1762
+ flush: "sync"
1763
+ });
1764
+ watch([referenceElement, floatingElement], attach, {
1765
+ flush: "sync"
1766
+ });
1767
+ watch(openOption, reset, {
1768
+ flush: "sync"
1769
+ });
1770
+ if (getCurrentScope()) {
1771
+ onScopeDispose(cleanup);
1772
+ }
1773
+ return {
1774
+ x: shallowReadonly(x),
1775
+ y: shallowReadonly(y),
1776
+ strategy: shallowReadonly(strategy),
1777
+ placement: shallowReadonly(placement),
1778
+ middlewareData: shallowReadonly(middlewareData),
1779
+ isPositioned: shallowReadonly(isPositioned),
1780
+ floatingStyles,
1781
+ update
1782
+ };
1783
+ }
1784
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1785
+ __name: "tooltip",
1786
+ props: {
1787
+ content: { default: "" },
1788
+ placement: { default: "top" },
1789
+ trigger: { default: "hover" },
1790
+ disabled: { type: Boolean, default: false },
1791
+ visible: { type: Boolean, default: false },
1792
+ offset: { default: 8 }
1793
+ },
1794
+ emits: ["update:visible", "show", "hide"],
1795
+ setup(__props, { emit: __emit }) {
1796
+ const ns = useNamespace("tooltip");
1797
+ const props = __props;
1798
+ const emit = __emit;
1799
+ const reference = ref(null);
1800
+ const floating = ref(null);
1801
+ const isVisible = ref(props.visible);
1802
+ const tooltipId = `fire-tooltip-${Math.random().toString(36).substr(2, 9)}`;
1803
+ const position = ref(props.placement);
1804
+ const { x, y, strategy } = useFloating(
1805
+ reference,
1806
+ floating,
1807
+ {
1808
+ placement: props.placement,
1809
+ middleware: [
1810
+ offset(props.offset),
1811
+ flip()
1812
+ ],
1813
+ whileElementsMounted: autoUpdate
1814
+ }
1815
+ );
1816
+ const floatingStyles = computed(() => ({
1817
+ position: strategy.value,
1818
+ left: `${x.value ?? 0}px`,
1819
+ top: `${y.value ?? 0}px`
1820
+ }));
1821
+ const show = () => {
1822
+ if (props.disabled) return;
1823
+ isVisible.value = true;
1824
+ emit("update:visible", true);
1825
+ emit("show");
1826
+ };
1827
+ const hide = () => {
1828
+ isVisible.value = false;
1829
+ emit("update:visible", false);
1830
+ emit("hide");
1831
+ };
1832
+ const handleMouseEnter = () => {
1833
+ if (props.trigger === "hover") {
1834
+ show();
1835
+ }
1836
+ };
1837
+ const handleMouseLeave = () => {
1838
+ if (props.trigger === "hover") {
1839
+ hide();
1840
+ }
1841
+ };
1842
+ const handleFocus = () => {
1843
+ if (props.trigger === "focus") {
1844
+ show();
1845
+ }
1846
+ };
1847
+ const handleBlur = () => {
1848
+ if (props.trigger === "focus") {
1849
+ hide();
1850
+ }
1851
+ };
1852
+ const handleClickOutside = (event) => {
1853
+ if (reference.value && !reference.value.contains(event.target) && floating.value && !floating.value.contains(event.target)) {
1854
+ hide();
1855
+ }
1856
+ };
1857
+ onMounted(() => {
1858
+ if (props.trigger === "click") {
1859
+ document.addEventListener("click", handleClickOutside);
1860
+ }
1861
+ });
1862
+ onUnmounted(() => {
1863
+ if (props.trigger === "click") {
1864
+ document.removeEventListener("click", handleClickOutside);
1865
+ }
1866
+ });
1867
+ watch(() => props.visible, (val) => {
1868
+ isVisible.value = val;
1869
+ });
1870
+ return (_ctx, _cache) => {
1871
+ return openBlock(), createElementBlock("div", {
1872
+ ref_key: "reference",
1873
+ ref: reference,
1874
+ class: normalizeClass(unref(ns).b),
1875
+ onMouseenter: handleMouseEnter,
1876
+ onMouseleave: handleMouseLeave,
1877
+ onFocus: handleFocus,
1878
+ onBlur: handleBlur
1879
+ }, [
1880
+ renderSlot(_ctx.$slots, "default", {}, void 0, true),
1881
+ (openBlock(), createBlock(Teleport, { to: "body" }, [
1882
+ createVNode(Transition, { name: "fire-tooltip" }, {
1883
+ default: withCtx(() => [
1884
+ isVisible.value ? (openBlock(), createElementBlock("div", {
1885
+ key: 0,
1886
+ ref_key: "floating",
1887
+ ref: floating,
1888
+ class: normalizeClass([
1889
+ unref(ns).e("content"),
1890
+ unref(ns).m(position.value)
1891
+ ]),
1892
+ style: normalizeStyle(floatingStyles.value),
1893
+ id: tooltipId,
1894
+ role: "tooltip"
1895
+ }, [
1896
+ createElementVNode("div", {
1897
+ class: normalizeClass(unref(ns).e("arrow"))
1898
+ }, null, 2),
1899
+ createElementVNode("div", {
1900
+ class: normalizeClass(unref(ns).e("inner"))
1901
+ }, [
1902
+ renderSlot(_ctx.$slots, "content", {}, () => [
1903
+ createTextVNode(toDisplayString(__props.content), 1)
1904
+ ], true)
1905
+ ], 2)
1906
+ ], 6)) : createCommentVNode("", true)
1907
+ ]),
1908
+ _: 3
1909
+ })
1910
+ ]))
1911
+ ], 34);
1912
+ };
1913
+ }
1914
+ });
1915
+ const Tooltip = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-2e386c10"]]);
1916
+ const FireTooltip = withInstall(Tooltip);
1917
+ const _hoisted_1$4 = { class: "fire-tips-icon" };
1918
+ const _hoisted_2$3 = { class: "fire-tips-content" };
1919
+ const _hoisted_3$3 = {
1920
+ key: 0,
1921
+ class: "fire-tips-title"
1922
+ };
1923
+ const _hoisted_4$2 = {
1924
+ key: 1,
1925
+ class: "fire-tips-description"
1926
+ };
1927
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1928
+ __name: "tips",
1929
+ props: {
1930
+ type: { default: "info" },
1931
+ closable: { type: Boolean, default: false },
1932
+ icon: { default: void 0 },
1933
+ title: { default: "" },
1934
+ description: { default: "" },
1935
+ class: {},
1936
+ style: {}
1937
+ },
1938
+ emits: ["close"],
1939
+ setup(__props, { emit: __emit }) {
1940
+ const ns = useNamespace("tips");
1941
+ const props = __props;
1942
+ const emit = __emit;
1943
+ const iconComponent = computed(() => {
1944
+ switch (props.type) {
1945
+ case "success":
1946
+ return CheckCircle;
1947
+ case "warning":
1948
+ return AlertTriangle;
1949
+ case "error":
1950
+ return XCircle;
1951
+ default:
1952
+ return Info;
1953
+ }
1954
+ });
1955
+ const handleClose = () => {
1956
+ emit("close");
1957
+ };
1958
+ return (_ctx, _cache) => {
1959
+ return openBlock(), createElementBlock("div", {
1960
+ class: normalizeClass([
1961
+ unref(ns).b,
1962
+ unref(ns).m(__props.type),
1963
+ {
1964
+ [unref(ns).m("closable")]: __props.closable
1965
+ }
1966
+ ])
1967
+ }, [
1968
+ createElementVNode("div", _hoisted_1$4, [
1969
+ renderSlot(_ctx.$slots, "icon", {}, () => [
1970
+ !__props.icon ? (openBlock(), createBlock(resolveDynamicComponent(iconComponent.value), { key: 0 })) : (openBlock(), createBlock(resolveDynamicComponent(__props.icon), { key: 1 }))
1971
+ ], true)
1972
+ ]),
1973
+ createElementVNode("div", _hoisted_2$3, [
1974
+ __props.title || _ctx.$slots.title ? (openBlock(), createElementBlock("div", _hoisted_3$3, [
1975
+ renderSlot(_ctx.$slots, "title", {}, () => [
1976
+ createTextVNode(toDisplayString(__props.title), 1)
1977
+ ], true)
1978
+ ])) : createCommentVNode("", true),
1979
+ __props.description || _ctx.$slots.description ? (openBlock(), createElementBlock("div", _hoisted_4$2, [
1980
+ renderSlot(_ctx.$slots, "description", {}, () => [
1981
+ createTextVNode(toDisplayString(__props.description), 1)
1982
+ ], true)
1983
+ ])) : createCommentVNode("", true),
1984
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
1985
+ ]),
1986
+ __props.closable ? (openBlock(), createElementBlock("button", {
1987
+ key: 0,
1988
+ class: "fire-tips-close",
1989
+ onClick: handleClose,
1990
+ "aria-label": "Close"
1991
+ }, [
1992
+ createVNode(unref(X), { size: 16 })
1993
+ ])) : createCommentVNode("", true)
1994
+ ], 2);
1995
+ };
1996
+ }
1997
+ });
1998
+ const Tips = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-7c18dbd2"]]);
1999
+ const FireTips = withInstall(Tips);
2000
+ const _hoisted_1$3 = {
2001
+ key: 0,
2002
+ class: "fire-input__prefix"
2003
+ };
2004
+ const _hoisted_2$2 = ["type", "value", "placeholder", "disabled", "readonly", "maxlength", "minlength"];
2005
+ const _hoisted_3$2 = {
2006
+ key: 1,
2007
+ class: "fire-input__suffix"
2008
+ };
2009
+ const _hoisted_4$1 = {
2010
+ key: 0,
2011
+ class: "fire-input__word-limit"
2012
+ };
2013
+ const _hoisted_5$1 = {
2014
+ key: 1,
2015
+ class: "fire-input__password-toggle"
2016
+ };
2017
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
2018
+ __name: "input",
2019
+ props: {
2020
+ type: { default: "text" },
2021
+ modelValue: { default: "" },
2022
+ placeholder: { default: "" },
2023
+ disabled: { type: Boolean, default: false },
2024
+ readonly: { type: Boolean, default: false },
2025
+ password: { type: Boolean, default: false },
2026
+ maxlength: { default: void 0 },
2027
+ minlength: { default: void 0 },
2028
+ showWordLimit: { type: Boolean, default: false },
2029
+ size: { default: "medium" },
2030
+ prefixIcon: { default: void 0 },
2031
+ suffixIcon: { default: void 0 },
2032
+ class: {},
2033
+ style: {}
2034
+ },
2035
+ emits: ["update:modelValue", "input", "focus", "blur", "enter", "clear"],
2036
+ setup(__props, { emit: __emit }) {
2037
+ const ns = useNamespace("input");
2038
+ const emit = __emit;
2039
+ const inputRef = ref();
2040
+ const showPassword = ref(false);
2041
+ const handleInput = (event) => {
2042
+ const target = event.target;
2043
+ const value = target.value;
2044
+ emit("update:modelValue", value);
2045
+ emit("input", value);
2046
+ };
2047
+ const handleFocus = (event) => {
2048
+ emit("focus", event);
2049
+ };
2050
+ const handleBlur = (event) => {
2051
+ emit("blur", event);
2052
+ };
2053
+ const handleEnter = (event) => {
2054
+ emit("enter", event);
2055
+ };
2056
+ const togglePassword = () => {
2057
+ showPassword.value = !showPassword.value;
2058
+ };
2059
+ return (_ctx, _cache) => {
2060
+ return openBlock(), createElementBlock("div", {
2061
+ class: normalizeClass([
2062
+ unref(ns).b,
2063
+ unref(ns).m(__props.size),
2064
+ {
2065
+ [unref(ns).m("disabled")]: __props.disabled,
2066
+ [unref(ns).m("prefix")]: _ctx.$slots.prefix || __props.prefixIcon,
2067
+ [unref(ns).m("suffix")]: _ctx.$slots.suffix || __props.suffixIcon || __props.showWordLimit
2068
+ }
2069
+ ])
2070
+ }, [
2071
+ _ctx.$slots.prefix || __props.prefixIcon ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
2072
+ renderSlot(_ctx.$slots, "prefix", {}, () => [
2073
+ __props.prefixIcon ? (openBlock(), createBlock(resolveDynamicComponent(__props.prefixIcon), { key: 0 })) : createCommentVNode("", true)
2074
+ ], true)
2075
+ ])) : createCommentVNode("", true),
2076
+ createElementVNode("input", {
2077
+ ref_key: "inputRef",
2078
+ ref: inputRef,
2079
+ type: __props.password ? showPassword.value ? "text" : "password" : __props.type,
2080
+ value: __props.modelValue,
2081
+ placeholder: __props.placeholder,
2082
+ disabled: __props.disabled,
2083
+ readonly: __props.readonly,
2084
+ maxlength: __props.maxlength,
2085
+ minlength: __props.minlength,
2086
+ onInput: handleInput,
2087
+ onFocus: handleFocus,
2088
+ onBlur: handleBlur,
2089
+ onKeydown: withKeys(handleEnter, ["enter"]),
2090
+ class: "fire-input__inner"
2091
+ }, null, 40, _hoisted_2$2),
2092
+ _ctx.$slots.suffix || __props.suffixIcon || __props.showWordLimit || __props.password && !__props.disabled ? (openBlock(), createElementBlock("div", _hoisted_3$2, [
2093
+ __props.showWordLimit ? (openBlock(), createElementBlock("span", _hoisted_4$1, toDisplayString((__props.modelValue || "").toString().length) + "/" + toDisplayString(__props.maxlength), 1)) : createCommentVNode("", true),
2094
+ __props.password && !__props.disabled ? (openBlock(), createElementBlock("div", _hoisted_5$1, [
2095
+ createElementVNode("button", {
2096
+ type: "button",
2097
+ onClick: togglePassword,
2098
+ class: "fire-input__password-icon",
2099
+ "aria-label": "Toggle password visibility"
2100
+ }, [
2101
+ !showPassword.value ? (openBlock(), createBlock(unref(Eye), {
2102
+ key: 0,
2103
+ size: 16
2104
+ })) : (openBlock(), createBlock(unref(EyeOff), {
2105
+ key: 1,
2106
+ size: 16
2107
+ }))
2108
+ ])
2109
+ ])) : createCommentVNode("", true),
2110
+ renderSlot(_ctx.$slots, "suffix", {}, () => [
2111
+ __props.suffixIcon ? (openBlock(), createBlock(resolveDynamicComponent(__props.suffixIcon), { key: 0 })) : createCommentVNode("", true)
2112
+ ], true)
2113
+ ])) : createCommentVNode("", true)
2114
+ ], 2);
2115
+ };
2116
+ }
2117
+ });
2118
+ const Input = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-01eb6da8"]]);
2119
+ const FireInput = withInstall(Input);
2120
+ function _extends() {
2121
+ _extends = Object.assign ? Object.assign.bind() : function(target) {
2122
+ for (var i = 1; i < arguments.length; i++) {
2123
+ var source = arguments[i];
2124
+ for (var key in source) {
2125
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
2126
+ target[key] = source[key];
2127
+ }
2128
+ }
2129
+ }
2130
+ return target;
2131
+ };
2132
+ return _extends.apply(this, arguments);
2133
+ }
2134
+ function _inheritsLoose(subClass, superClass) {
2135
+ subClass.prototype = Object.create(superClass.prototype);
2136
+ subClass.prototype.constructor = subClass;
2137
+ _setPrototypeOf(subClass, superClass);
2138
+ }
2139
+ function _getPrototypeOf(o) {
2140
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
2141
+ return o2.__proto__ || Object.getPrototypeOf(o2);
2142
+ };
2143
+ return _getPrototypeOf(o);
2144
+ }
2145
+ function _setPrototypeOf(o, p) {
2146
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
2147
+ o2.__proto__ = p2;
2148
+ return o2;
2149
+ };
2150
+ return _setPrototypeOf(o, p);
2151
+ }
2152
+ function _isNativeReflectConstruct() {
2153
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
2154
+ if (Reflect.construct.sham) return false;
2155
+ if (typeof Proxy === "function") return true;
2156
+ try {
2157
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
2158
+ }));
2159
+ return true;
2160
+ } catch (e) {
2161
+ return false;
2162
+ }
2163
+ }
2164
+ function _construct(Parent, args, Class) {
2165
+ if (_isNativeReflectConstruct()) {
2166
+ _construct = Reflect.construct.bind();
2167
+ } else {
2168
+ _construct = function _construct2(Parent2, args2, Class2) {
2169
+ var a = [null];
2170
+ a.push.apply(a, args2);
2171
+ var Constructor = Function.bind.apply(Parent2, a);
2172
+ var instance = new Constructor();
2173
+ if (Class2) _setPrototypeOf(instance, Class2.prototype);
2174
+ return instance;
2175
+ };
2176
+ }
2177
+ return _construct.apply(null, arguments);
2178
+ }
2179
+ function _isNativeFunction(fn) {
2180
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
2181
+ }
2182
+ function _wrapNativeSuper(Class) {
2183
+ var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
2184
+ _wrapNativeSuper = function _wrapNativeSuper2(Class2) {
2185
+ if (Class2 === null || !_isNativeFunction(Class2)) return Class2;
2186
+ if (typeof Class2 !== "function") {
2187
+ throw new TypeError("Super expression must either be null or a function");
2188
+ }
2189
+ if (typeof _cache !== "undefined") {
2190
+ if (_cache.has(Class2)) return _cache.get(Class2);
2191
+ _cache.set(Class2, Wrapper);
2192
+ }
2193
+ function Wrapper() {
2194
+ return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
2195
+ }
2196
+ Wrapper.prototype = Object.create(Class2.prototype, {
2197
+ constructor: {
2198
+ value: Wrapper,
2199
+ enumerable: false,
2200
+ writable: true,
2201
+ configurable: true
2202
+ }
2203
+ });
2204
+ return _setPrototypeOf(Wrapper, Class2);
2205
+ };
2206
+ return _wrapNativeSuper(Class);
2207
+ }
2208
+ var formatRegExp = /%[sdj%]/g;
2209
+ var warning = function warning2() {
2210
+ };
2211
+ if (typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" && typeof window !== "undefined" && typeof document !== "undefined") {
2212
+ warning = function warning3(type4, errors) {
2213
+ if (typeof console !== "undefined" && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING === "undefined") {
2214
+ if (errors.every(function(e) {
2215
+ return typeof e === "string";
2216
+ })) {
2217
+ console.warn(type4, errors);
2218
+ }
2219
+ }
2220
+ };
2221
+ }
2222
+ function convertFieldsError(errors) {
2223
+ if (!errors || !errors.length) return null;
2224
+ var fields = {};
2225
+ errors.forEach(function(error) {
2226
+ var field = error.field;
2227
+ fields[field] = fields[field] || [];
2228
+ fields[field].push(error);
2229
+ });
2230
+ return fields;
2231
+ }
2232
+ function format(template) {
2233
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2234
+ args[_key - 1] = arguments[_key];
2235
+ }
2236
+ var i = 0;
2237
+ var len = args.length;
2238
+ if (typeof template === "function") {
2239
+ return template.apply(null, args);
2240
+ }
2241
+ if (typeof template === "string") {
2242
+ var str = template.replace(formatRegExp, function(x) {
2243
+ if (x === "%%") {
2244
+ return "%";
2245
+ }
2246
+ if (i >= len) {
2247
+ return x;
2248
+ }
2249
+ switch (x) {
2250
+ case "%s":
2251
+ return String(args[i++]);
2252
+ case "%d":
2253
+ return Number(args[i++]);
2254
+ case "%j":
2255
+ try {
2256
+ return JSON.stringify(args[i++]);
2257
+ } catch (_) {
2258
+ return "[Circular]";
2259
+ }
2260
+ break;
2261
+ default:
2262
+ return x;
2263
+ }
2264
+ });
2265
+ return str;
2266
+ }
2267
+ return template;
2268
+ }
2269
+ function isNativeStringType(type4) {
2270
+ return type4 === "string" || type4 === "url" || type4 === "hex" || type4 === "email" || type4 === "date" || type4 === "pattern";
2271
+ }
2272
+ function isEmptyValue(value, type4) {
2273
+ if (value === void 0 || value === null) {
2274
+ return true;
2275
+ }
2276
+ if (type4 === "array" && Array.isArray(value) && !value.length) {
2277
+ return true;
2278
+ }
2279
+ if (isNativeStringType(type4) && typeof value === "string" && !value) {
2280
+ return true;
2281
+ }
2282
+ return false;
2283
+ }
2284
+ function asyncParallelArray(arr, func, callback) {
2285
+ var results = [];
2286
+ var total = 0;
2287
+ var arrLength = arr.length;
2288
+ function count(errors) {
2289
+ results.push.apply(results, errors || []);
2290
+ total++;
2291
+ if (total === arrLength) {
2292
+ callback(results);
2293
+ }
2294
+ }
2295
+ arr.forEach(function(a) {
2296
+ func(a, count);
2297
+ });
2298
+ }
2299
+ function asyncSerialArray(arr, func, callback) {
2300
+ var index2 = 0;
2301
+ var arrLength = arr.length;
2302
+ function next(errors) {
2303
+ if (errors && errors.length) {
2304
+ callback(errors);
2305
+ return;
2306
+ }
2307
+ var original = index2;
2308
+ index2 = index2 + 1;
2309
+ if (original < arrLength) {
2310
+ func(arr[original], next);
2311
+ } else {
2312
+ callback([]);
2313
+ }
2314
+ }
2315
+ next([]);
2316
+ }
2317
+ function flattenObjArr(objArr) {
2318
+ var ret = [];
2319
+ Object.keys(objArr).forEach(function(k) {
2320
+ ret.push.apply(ret, objArr[k] || []);
2321
+ });
2322
+ return ret;
2323
+ }
2324
+ var AsyncValidationError = /* @__PURE__ */ (function(_Error) {
2325
+ _inheritsLoose(AsyncValidationError2, _Error);
2326
+ function AsyncValidationError2(errors, fields) {
2327
+ var _this;
2328
+ _this = _Error.call(this, "Async Validation Error") || this;
2329
+ _this.errors = errors;
2330
+ _this.fields = fields;
2331
+ return _this;
2332
+ }
2333
+ return AsyncValidationError2;
2334
+ })(/* @__PURE__ */ _wrapNativeSuper(Error));
2335
+ function asyncMap(objArr, option, func, callback, source) {
2336
+ if (option.first) {
2337
+ var _pending = new Promise(function(resolve, reject) {
2338
+ var next = function next2(errors) {
2339
+ callback(errors);
2340
+ return errors.length ? reject(new AsyncValidationError(errors, convertFieldsError(errors))) : resolve(source);
2341
+ };
2342
+ var flattenArr = flattenObjArr(objArr);
2343
+ asyncSerialArray(flattenArr, func, next);
2344
+ });
2345
+ _pending["catch"](function(e) {
2346
+ return e;
2347
+ });
2348
+ return _pending;
2349
+ }
2350
+ var firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || [];
2351
+ var objArrKeys = Object.keys(objArr);
2352
+ var objArrLength = objArrKeys.length;
2353
+ var total = 0;
2354
+ var results = [];
2355
+ var pending = new Promise(function(resolve, reject) {
2356
+ var next = function next2(errors) {
2357
+ results.push.apply(results, errors);
2358
+ total++;
2359
+ if (total === objArrLength) {
2360
+ callback(results);
2361
+ return results.length ? reject(new AsyncValidationError(results, convertFieldsError(results))) : resolve(source);
2362
+ }
2363
+ };
2364
+ if (!objArrKeys.length) {
2365
+ callback(results);
2366
+ resolve(source);
2367
+ }
2368
+ objArrKeys.forEach(function(key) {
2369
+ var arr = objArr[key];
2370
+ if (firstFields.indexOf(key) !== -1) {
2371
+ asyncSerialArray(arr, func, next);
2372
+ } else {
2373
+ asyncParallelArray(arr, func, next);
2374
+ }
2375
+ });
2376
+ });
2377
+ pending["catch"](function(e) {
2378
+ return e;
2379
+ });
2380
+ return pending;
2381
+ }
2382
+ function isErrorObj(obj) {
2383
+ return !!(obj && obj.message !== void 0);
2384
+ }
2385
+ function getValue(value, path) {
2386
+ var v = value;
2387
+ for (var i = 0; i < path.length; i++) {
2388
+ if (v == void 0) {
2389
+ return v;
2390
+ }
2391
+ v = v[path[i]];
2392
+ }
2393
+ return v;
2394
+ }
2395
+ function complementError(rule, source) {
2396
+ return function(oe) {
2397
+ var fieldValue;
2398
+ if (rule.fullFields) {
2399
+ fieldValue = getValue(source, rule.fullFields);
2400
+ } else {
2401
+ fieldValue = source[oe.field || rule.fullField];
2402
+ }
2403
+ if (isErrorObj(oe)) {
2404
+ oe.field = oe.field || rule.fullField;
2405
+ oe.fieldValue = fieldValue;
2406
+ return oe;
2407
+ }
2408
+ return {
2409
+ message: typeof oe === "function" ? oe() : oe,
2410
+ fieldValue,
2411
+ field: oe.field || rule.fullField
2412
+ };
2413
+ };
2414
+ }
2415
+ function deepMerge(target, source) {
2416
+ if (source) {
2417
+ for (var s in source) {
2418
+ if (source.hasOwnProperty(s)) {
2419
+ var value = source[s];
2420
+ if (typeof value === "object" && typeof target[s] === "object") {
2421
+ target[s] = _extends({}, target[s], value);
2422
+ } else {
2423
+ target[s] = value;
2424
+ }
2425
+ }
2426
+ }
2427
+ }
2428
+ return target;
2429
+ }
2430
+ var required$1 = function required(rule, value, source, errors, options, type4) {
2431
+ if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type4 || rule.type))) {
2432
+ errors.push(format(options.messages.required, rule.fullField));
2433
+ }
2434
+ };
2435
+ var whitespace = function whitespace2(rule, value, source, errors, options) {
2436
+ if (/^\s+$/.test(value) || value === "") {
2437
+ errors.push(format(options.messages.whitespace, rule.fullField));
2438
+ }
2439
+ };
2440
+ var urlReg;
2441
+ var getUrlRegex = (function() {
2442
+ if (urlReg) {
2443
+ return urlReg;
2444
+ }
2445
+ var word = "[a-fA-F\\d:]";
2446
+ var b = function b2(options) {
2447
+ return options && options.includeBoundaries ? "(?:(?<=\\s|^)(?=" + word + ")|(?<=" + word + ")(?=\\s|$))" : "";
2448
+ };
2449
+ var v4 = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}";
2450
+ var v6seg = "[a-fA-F\\d]{1,4}";
2451
+ var v6 = ("\n(?:\n(?:" + v6seg + ":){7}(?:" + v6seg + "|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:" + v6seg + ":){6}(?:" + v4 + "|:" + v6seg + "|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:" + v6seg + ":){5}(?::" + v4 + "|(?::" + v6seg + "){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:" + v6seg + ":){4}(?:(?::" + v6seg + "){0,1}:" + v4 + "|(?::" + v6seg + "){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:" + v6seg + ":){3}(?:(?::" + v6seg + "){0,2}:" + v4 + "|(?::" + v6seg + "){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:" + v6seg + ":){2}(?:(?::" + v6seg + "){0,3}:" + v4 + "|(?::" + v6seg + "){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:" + v6seg + ":){1}(?:(?::" + v6seg + "){0,4}:" + v4 + "|(?::" + v6seg + "){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::" + v6seg + "){0,5}:" + v4 + "|(?::" + v6seg + "){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n").replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim();
2452
+ var v46Exact = new RegExp("(?:^" + v4 + "$)|(?:^" + v6 + "$)");
2453
+ var v4exact = new RegExp("^" + v4 + "$");
2454
+ var v6exact = new RegExp("^" + v6 + "$");
2455
+ var ip = function ip2(options) {
2456
+ return options && options.exact ? v46Exact : new RegExp("(?:" + b(options) + v4 + b(options) + ")|(?:" + b(options) + v6 + b(options) + ")", "g");
2457
+ };
2458
+ ip.v4 = function(options) {
2459
+ return options && options.exact ? v4exact : new RegExp("" + b(options) + v4 + b(options), "g");
2460
+ };
2461
+ ip.v6 = function(options) {
2462
+ return options && options.exact ? v6exact : new RegExp("" + b(options) + v6 + b(options), "g");
2463
+ };
2464
+ var protocol = "(?:(?:[a-z]+:)?//)";
2465
+ var auth = "(?:\\S+(?::\\S*)?@)?";
2466
+ var ipv4 = ip.v4().source;
2467
+ var ipv6 = ip.v6().source;
2468
+ var host = "(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)";
2469
+ var domain = "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*";
2470
+ var tld = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";
2471
+ var port = "(?::\\d{2,5})?";
2472
+ var path = '(?:[/?#][^\\s"]*)?';
2473
+ var regex = "(?:" + protocol + "|www\\.)" + auth + "(?:localhost|" + ipv4 + "|" + ipv6 + "|" + host + domain + tld + ")" + port + path;
2474
+ urlReg = new RegExp("(?:^" + regex + "$)", "i");
2475
+ return urlReg;
2476
+ });
2477
+ var pattern$2 = {
2478
+ // http://emailregex.com/
2479
+ email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
2480
+ // url: new RegExp(
2481
+ // '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$',
2482
+ // 'i',
2483
+ // ),
2484
+ hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
2485
+ };
2486
+ var types = {
2487
+ integer: function integer(value) {
2488
+ return types.number(value) && parseInt(value, 10) === value;
2489
+ },
2490
+ "float": function float(value) {
2491
+ return types.number(value) && !types.integer(value);
2492
+ },
2493
+ array: function array(value) {
2494
+ return Array.isArray(value);
2495
+ },
2496
+ regexp: function regexp(value) {
2497
+ if (value instanceof RegExp) {
2498
+ return true;
2499
+ }
2500
+ try {
2501
+ return !!new RegExp(value);
2502
+ } catch (e) {
2503
+ return false;
2504
+ }
2505
+ },
2506
+ date: function date(value) {
2507
+ return typeof value.getTime === "function" && typeof value.getMonth === "function" && typeof value.getYear === "function" && !isNaN(value.getTime());
2508
+ },
2509
+ number: function number(value) {
2510
+ if (isNaN(value)) {
2511
+ return false;
2512
+ }
2513
+ return typeof value === "number";
2514
+ },
2515
+ object: function object(value) {
2516
+ return typeof value === "object" && !types.array(value);
2517
+ },
2518
+ method: function method(value) {
2519
+ return typeof value === "function";
2520
+ },
2521
+ email: function email(value) {
2522
+ return typeof value === "string" && value.length <= 320 && !!value.match(pattern$2.email);
2523
+ },
2524
+ url: function url(value) {
2525
+ return typeof value === "string" && value.length <= 2048 && !!value.match(getUrlRegex());
2526
+ },
2527
+ hex: function hex(value) {
2528
+ return typeof value === "string" && !!value.match(pattern$2.hex);
2529
+ }
2530
+ };
2531
+ var type$1 = function type(rule, value, source, errors, options) {
2532
+ if (rule.required && value === void 0) {
2533
+ required$1(rule, value, source, errors, options);
2534
+ return;
2535
+ }
2536
+ var custom = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"];
2537
+ var ruleType = rule.type;
2538
+ if (custom.indexOf(ruleType) > -1) {
2539
+ if (!types[ruleType](value)) {
2540
+ errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
2541
+ }
2542
+ } else if (ruleType && typeof value !== rule.type) {
2543
+ errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
2544
+ }
2545
+ };
2546
+ var range = function range2(rule, value, source, errors, options) {
2547
+ var len = typeof rule.len === "number";
2548
+ var min2 = typeof rule.min === "number";
2549
+ var max2 = typeof rule.max === "number";
2550
+ var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
2551
+ var val = value;
2552
+ var key = null;
2553
+ var num = typeof value === "number";
2554
+ var str = typeof value === "string";
2555
+ var arr = Array.isArray(value);
2556
+ if (num) {
2557
+ key = "number";
2558
+ } else if (str) {
2559
+ key = "string";
2560
+ } else if (arr) {
2561
+ key = "array";
2562
+ }
2563
+ if (!key) {
2564
+ return false;
2565
+ }
2566
+ if (arr) {
2567
+ val = value.length;
2568
+ }
2569
+ if (str) {
2570
+ val = value.replace(spRegexp, "_").length;
2571
+ }
2572
+ if (len) {
2573
+ if (val !== rule.len) {
2574
+ errors.push(format(options.messages[key].len, rule.fullField, rule.len));
2575
+ }
2576
+ } else if (min2 && !max2 && val < rule.min) {
2577
+ errors.push(format(options.messages[key].min, rule.fullField, rule.min));
2578
+ } else if (max2 && !min2 && val > rule.max) {
2579
+ errors.push(format(options.messages[key].max, rule.fullField, rule.max));
2580
+ } else if (min2 && max2 && (val < rule.min || val > rule.max)) {
2581
+ errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));
2582
+ }
2583
+ };
2584
+ var ENUM$1 = "enum";
2585
+ var enumerable$1 = function enumerable(rule, value, source, errors, options) {
2586
+ rule[ENUM$1] = Array.isArray(rule[ENUM$1]) ? rule[ENUM$1] : [];
2587
+ if (rule[ENUM$1].indexOf(value) === -1) {
2588
+ errors.push(format(options.messages[ENUM$1], rule.fullField, rule[ENUM$1].join(", ")));
2589
+ }
2590
+ };
2591
+ var pattern$1 = function pattern(rule, value, source, errors, options) {
2592
+ if (rule.pattern) {
2593
+ if (rule.pattern instanceof RegExp) {
2594
+ rule.pattern.lastIndex = 0;
2595
+ if (!rule.pattern.test(value)) {
2596
+ errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
2597
+ }
2598
+ } else if (typeof rule.pattern === "string") {
2599
+ var _pattern = new RegExp(rule.pattern);
2600
+ if (!_pattern.test(value)) {
2601
+ errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
2602
+ }
2603
+ }
2604
+ }
2605
+ };
2606
+ var rules = {
2607
+ required: required$1,
2608
+ whitespace,
2609
+ type: type$1,
2610
+ range,
2611
+ "enum": enumerable$1,
2612
+ pattern: pattern$1
2613
+ };
2614
+ var string = function string2(rule, value, callback, source, options) {
2615
+ var errors = [];
2616
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2617
+ if (validate) {
2618
+ if (isEmptyValue(value, "string") && !rule.required) {
2619
+ return callback();
2620
+ }
2621
+ rules.required(rule, value, source, errors, options, "string");
2622
+ if (!isEmptyValue(value, "string")) {
2623
+ rules.type(rule, value, source, errors, options);
2624
+ rules.range(rule, value, source, errors, options);
2625
+ rules.pattern(rule, value, source, errors, options);
2626
+ if (rule.whitespace === true) {
2627
+ rules.whitespace(rule, value, source, errors, options);
2628
+ }
2629
+ }
2630
+ }
2631
+ callback(errors);
2632
+ };
2633
+ var method2 = function method3(rule, value, callback, source, options) {
2634
+ var errors = [];
2635
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2636
+ if (validate) {
2637
+ if (isEmptyValue(value) && !rule.required) {
2638
+ return callback();
2639
+ }
2640
+ rules.required(rule, value, source, errors, options);
2641
+ if (value !== void 0) {
2642
+ rules.type(rule, value, source, errors, options);
2643
+ }
2644
+ }
2645
+ callback(errors);
2646
+ };
2647
+ var number2 = function number3(rule, value, callback, source, options) {
2648
+ var errors = [];
2649
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2650
+ if (validate) {
2651
+ if (value === "") {
2652
+ value = void 0;
2653
+ }
2654
+ if (isEmptyValue(value) && !rule.required) {
2655
+ return callback();
2656
+ }
2657
+ rules.required(rule, value, source, errors, options);
2658
+ if (value !== void 0) {
2659
+ rules.type(rule, value, source, errors, options);
2660
+ rules.range(rule, value, source, errors, options);
2661
+ }
2662
+ }
2663
+ callback(errors);
2664
+ };
2665
+ var _boolean = function _boolean2(rule, value, callback, source, options) {
2666
+ var errors = [];
2667
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2668
+ if (validate) {
2669
+ if (isEmptyValue(value) && !rule.required) {
2670
+ return callback();
2671
+ }
2672
+ rules.required(rule, value, source, errors, options);
2673
+ if (value !== void 0) {
2674
+ rules.type(rule, value, source, errors, options);
2675
+ }
2676
+ }
2677
+ callback(errors);
2678
+ };
2679
+ var regexp2 = function regexp3(rule, value, callback, source, options) {
2680
+ var errors = [];
2681
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2682
+ if (validate) {
2683
+ if (isEmptyValue(value) && !rule.required) {
2684
+ return callback();
2685
+ }
2686
+ rules.required(rule, value, source, errors, options);
2687
+ if (!isEmptyValue(value)) {
2688
+ rules.type(rule, value, source, errors, options);
2689
+ }
2690
+ }
2691
+ callback(errors);
2692
+ };
2693
+ var integer2 = function integer3(rule, value, callback, source, options) {
2694
+ var errors = [];
2695
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2696
+ if (validate) {
2697
+ if (isEmptyValue(value) && !rule.required) {
2698
+ return callback();
2699
+ }
2700
+ rules.required(rule, value, source, errors, options);
2701
+ if (value !== void 0) {
2702
+ rules.type(rule, value, source, errors, options);
2703
+ rules.range(rule, value, source, errors, options);
2704
+ }
2705
+ }
2706
+ callback(errors);
2707
+ };
2708
+ var floatFn = function floatFn2(rule, value, callback, source, options) {
2709
+ var errors = [];
2710
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2711
+ if (validate) {
2712
+ if (isEmptyValue(value) && !rule.required) {
2713
+ return callback();
2714
+ }
2715
+ rules.required(rule, value, source, errors, options);
2716
+ if (value !== void 0) {
2717
+ rules.type(rule, value, source, errors, options);
2718
+ rules.range(rule, value, source, errors, options);
2719
+ }
2720
+ }
2721
+ callback(errors);
2722
+ };
2723
+ var array2 = function array3(rule, value, callback, source, options) {
2724
+ var errors = [];
2725
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2726
+ if (validate) {
2727
+ if ((value === void 0 || value === null) && !rule.required) {
2728
+ return callback();
2729
+ }
2730
+ rules.required(rule, value, source, errors, options, "array");
2731
+ if (value !== void 0 && value !== null) {
2732
+ rules.type(rule, value, source, errors, options);
2733
+ rules.range(rule, value, source, errors, options);
2734
+ }
2735
+ }
2736
+ callback(errors);
2737
+ };
2738
+ var object2 = function object3(rule, value, callback, source, options) {
2739
+ var errors = [];
2740
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2741
+ if (validate) {
2742
+ if (isEmptyValue(value) && !rule.required) {
2743
+ return callback();
2744
+ }
2745
+ rules.required(rule, value, source, errors, options);
2746
+ if (value !== void 0) {
2747
+ rules.type(rule, value, source, errors, options);
2748
+ }
2749
+ }
2750
+ callback(errors);
2751
+ };
2752
+ var ENUM = "enum";
2753
+ var enumerable2 = function enumerable3(rule, value, callback, source, options) {
2754
+ var errors = [];
2755
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2756
+ if (validate) {
2757
+ if (isEmptyValue(value) && !rule.required) {
2758
+ return callback();
2759
+ }
2760
+ rules.required(rule, value, source, errors, options);
2761
+ if (value !== void 0) {
2762
+ rules[ENUM](rule, value, source, errors, options);
2763
+ }
2764
+ }
2765
+ callback(errors);
2766
+ };
2767
+ var pattern2 = function pattern3(rule, value, callback, source, options) {
2768
+ var errors = [];
2769
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2770
+ if (validate) {
2771
+ if (isEmptyValue(value, "string") && !rule.required) {
2772
+ return callback();
2773
+ }
2774
+ rules.required(rule, value, source, errors, options);
2775
+ if (!isEmptyValue(value, "string")) {
2776
+ rules.pattern(rule, value, source, errors, options);
2777
+ }
2778
+ }
2779
+ callback(errors);
2780
+ };
2781
+ var date2 = function date3(rule, value, callback, source, options) {
2782
+ var errors = [];
2783
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2784
+ if (validate) {
2785
+ if (isEmptyValue(value, "date") && !rule.required) {
2786
+ return callback();
2787
+ }
2788
+ rules.required(rule, value, source, errors, options);
2789
+ if (!isEmptyValue(value, "date")) {
2790
+ var dateObject;
2791
+ if (value instanceof Date) {
2792
+ dateObject = value;
2793
+ } else {
2794
+ dateObject = new Date(value);
2795
+ }
2796
+ rules.type(rule, dateObject, source, errors, options);
2797
+ if (dateObject) {
2798
+ rules.range(rule, dateObject.getTime(), source, errors, options);
2799
+ }
2800
+ }
2801
+ }
2802
+ callback(errors);
2803
+ };
2804
+ var required2 = function required3(rule, value, callback, source, options) {
2805
+ var errors = [];
2806
+ var type4 = Array.isArray(value) ? "array" : typeof value;
2807
+ rules.required(rule, value, source, errors, options, type4);
2808
+ callback(errors);
2809
+ };
2810
+ var type2 = function type3(rule, value, callback, source, options) {
2811
+ var ruleType = rule.type;
2812
+ var errors = [];
2813
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2814
+ if (validate) {
2815
+ if (isEmptyValue(value, ruleType) && !rule.required) {
2816
+ return callback();
2817
+ }
2818
+ rules.required(rule, value, source, errors, options, ruleType);
2819
+ if (!isEmptyValue(value, ruleType)) {
2820
+ rules.type(rule, value, source, errors, options);
2821
+ }
2822
+ }
2823
+ callback(errors);
2824
+ };
2825
+ var any = function any2(rule, value, callback, source, options) {
2826
+ var errors = [];
2827
+ var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
2828
+ if (validate) {
2829
+ if (isEmptyValue(value) && !rule.required) {
2830
+ return callback();
2831
+ }
2832
+ rules.required(rule, value, source, errors, options);
2833
+ }
2834
+ callback(errors);
2835
+ };
2836
+ var validators = {
2837
+ string,
2838
+ method: method2,
2839
+ number: number2,
2840
+ "boolean": _boolean,
2841
+ regexp: regexp2,
2842
+ integer: integer2,
2843
+ "float": floatFn,
2844
+ array: array2,
2845
+ object: object2,
2846
+ "enum": enumerable2,
2847
+ pattern: pattern2,
2848
+ date: date2,
2849
+ url: type2,
2850
+ hex: type2,
2851
+ email: type2,
2852
+ required: required2,
2853
+ any
2854
+ };
2855
+ function newMessages() {
2856
+ return {
2857
+ "default": "Validation error on field %s",
2858
+ required: "%s is required",
2859
+ "enum": "%s must be one of %s",
2860
+ whitespace: "%s cannot be empty",
2861
+ date: {
2862
+ format: "%s date %s is invalid for format %s",
2863
+ parse: "%s date could not be parsed, %s is invalid ",
2864
+ invalid: "%s date %s is invalid"
2865
+ },
2866
+ types: {
2867
+ string: "%s is not a %s",
2868
+ method: "%s is not a %s (function)",
2869
+ array: "%s is not an %s",
2870
+ object: "%s is not an %s",
2871
+ number: "%s is not a %s",
2872
+ date: "%s is not a %s",
2873
+ "boolean": "%s is not a %s",
2874
+ integer: "%s is not an %s",
2875
+ "float": "%s is not a %s",
2876
+ regexp: "%s is not a valid %s",
2877
+ email: "%s is not a valid %s",
2878
+ url: "%s is not a valid %s",
2879
+ hex: "%s is not a valid %s"
2880
+ },
2881
+ string: {
2882
+ len: "%s must be exactly %s characters",
2883
+ min: "%s must be at least %s characters",
2884
+ max: "%s cannot be longer than %s characters",
2885
+ range: "%s must be between %s and %s characters"
2886
+ },
2887
+ number: {
2888
+ len: "%s must equal %s",
2889
+ min: "%s cannot be less than %s",
2890
+ max: "%s cannot be greater than %s",
2891
+ range: "%s must be between %s and %s"
2892
+ },
2893
+ array: {
2894
+ len: "%s must be exactly %s in length",
2895
+ min: "%s cannot be less than %s in length",
2896
+ max: "%s cannot be greater than %s in length",
2897
+ range: "%s must be between %s and %s in length"
2898
+ },
2899
+ pattern: {
2900
+ mismatch: "%s value %s does not match pattern %s"
2901
+ },
2902
+ clone: function clone() {
2903
+ var cloned = JSON.parse(JSON.stringify(this));
2904
+ cloned.clone = this.clone;
2905
+ return cloned;
2906
+ }
2907
+ };
2908
+ }
2909
+ var messages = newMessages();
2910
+ var Schema = /* @__PURE__ */ (function() {
2911
+ function Schema2(descriptor) {
2912
+ this.rules = null;
2913
+ this._messages = messages;
2914
+ this.define(descriptor);
2915
+ }
2916
+ var _proto = Schema2.prototype;
2917
+ _proto.define = function define(rules2) {
2918
+ var _this = this;
2919
+ if (!rules2) {
2920
+ throw new Error("Cannot configure a schema with no rules");
2921
+ }
2922
+ if (typeof rules2 !== "object" || Array.isArray(rules2)) {
2923
+ throw new Error("Rules must be an object");
2924
+ }
2925
+ this.rules = {};
2926
+ Object.keys(rules2).forEach(function(name) {
2927
+ var item = rules2[name];
2928
+ _this.rules[name] = Array.isArray(item) ? item : [item];
2929
+ });
2930
+ };
2931
+ _proto.messages = function messages2(_messages) {
2932
+ if (_messages) {
2933
+ this._messages = deepMerge(newMessages(), _messages);
2934
+ }
2935
+ return this._messages;
2936
+ };
2937
+ _proto.validate = function validate(source_, o, oc) {
2938
+ var _this2 = this;
2939
+ if (o === void 0) {
2940
+ o = {};
2941
+ }
2942
+ if (oc === void 0) {
2943
+ oc = function oc2() {
2944
+ };
2945
+ }
2946
+ var source = source_;
2947
+ var options = o;
2948
+ var callback = oc;
2949
+ if (typeof options === "function") {
2950
+ callback = options;
2951
+ options = {};
2952
+ }
2953
+ if (!this.rules || Object.keys(this.rules).length === 0) {
2954
+ if (callback) {
2955
+ callback(null, source);
2956
+ }
2957
+ return Promise.resolve(source);
2958
+ }
2959
+ function complete(results) {
2960
+ var errors = [];
2961
+ var fields = {};
2962
+ function add(e) {
2963
+ if (Array.isArray(e)) {
2964
+ var _errors;
2965
+ errors = (_errors = errors).concat.apply(_errors, e);
2966
+ } else {
2967
+ errors.push(e);
2968
+ }
2969
+ }
2970
+ for (var i = 0; i < results.length; i++) {
2971
+ add(results[i]);
2972
+ }
2973
+ if (!errors.length) {
2974
+ callback(null, source);
2975
+ } else {
2976
+ fields = convertFieldsError(errors);
2977
+ callback(errors, fields);
2978
+ }
2979
+ }
2980
+ if (options.messages) {
2981
+ var messages$1 = this.messages();
2982
+ if (messages$1 === messages) {
2983
+ messages$1 = newMessages();
2984
+ }
2985
+ deepMerge(messages$1, options.messages);
2986
+ options.messages = messages$1;
2987
+ } else {
2988
+ options.messages = this.messages();
2989
+ }
2990
+ var series = {};
2991
+ var keys = options.keys || Object.keys(this.rules);
2992
+ keys.forEach(function(z) {
2993
+ var arr = _this2.rules[z];
2994
+ var value = source[z];
2995
+ arr.forEach(function(r) {
2996
+ var rule = r;
2997
+ if (typeof rule.transform === "function") {
2998
+ if (source === source_) {
2999
+ source = _extends({}, source);
3000
+ }
3001
+ value = source[z] = rule.transform(value);
3002
+ }
3003
+ if (typeof rule === "function") {
3004
+ rule = {
3005
+ validator: rule
3006
+ };
3007
+ } else {
3008
+ rule = _extends({}, rule);
3009
+ }
3010
+ rule.validator = _this2.getValidationMethod(rule);
3011
+ if (!rule.validator) {
3012
+ return;
3013
+ }
3014
+ rule.field = z;
3015
+ rule.fullField = rule.fullField || z;
3016
+ rule.type = _this2.getType(rule);
3017
+ series[z] = series[z] || [];
3018
+ series[z].push({
3019
+ rule,
3020
+ value,
3021
+ source,
3022
+ field: z
3023
+ });
3024
+ });
3025
+ });
3026
+ var errorFields = {};
3027
+ return asyncMap(series, options, function(data, doIt) {
3028
+ var rule = data.rule;
3029
+ var deep = (rule.type === "object" || rule.type === "array") && (typeof rule.fields === "object" || typeof rule.defaultField === "object");
3030
+ deep = deep && (rule.required || !rule.required && data.value);
3031
+ rule.field = data.field;
3032
+ function addFullField(key, schema) {
3033
+ return _extends({}, schema, {
3034
+ fullField: rule.fullField + "." + key,
3035
+ fullFields: rule.fullFields ? [].concat(rule.fullFields, [key]) : [key]
3036
+ });
3037
+ }
3038
+ function cb(e) {
3039
+ if (e === void 0) {
3040
+ e = [];
3041
+ }
3042
+ var errorList = Array.isArray(e) ? e : [e];
3043
+ if (!options.suppressWarning && errorList.length) {
3044
+ Schema2.warning("async-validator:", errorList);
3045
+ }
3046
+ if (errorList.length && rule.message !== void 0) {
3047
+ errorList = [].concat(rule.message);
3048
+ }
3049
+ var filledErrors = errorList.map(complementError(rule, source));
3050
+ if (options.first && filledErrors.length) {
3051
+ errorFields[rule.field] = 1;
3052
+ return doIt(filledErrors);
3053
+ }
3054
+ if (!deep) {
3055
+ doIt(filledErrors);
3056
+ } else {
3057
+ if (rule.required && !data.value) {
3058
+ if (rule.message !== void 0) {
3059
+ filledErrors = [].concat(rule.message).map(complementError(rule, source));
3060
+ } else if (options.error) {
3061
+ filledErrors = [options.error(rule, format(options.messages.required, rule.field))];
3062
+ }
3063
+ return doIt(filledErrors);
3064
+ }
3065
+ var fieldsSchema = {};
3066
+ if (rule.defaultField) {
3067
+ Object.keys(data.value).map(function(key) {
3068
+ fieldsSchema[key] = rule.defaultField;
3069
+ });
3070
+ }
3071
+ fieldsSchema = _extends({}, fieldsSchema, data.rule.fields);
3072
+ var paredFieldsSchema = {};
3073
+ Object.keys(fieldsSchema).forEach(function(field) {
3074
+ var fieldSchema = fieldsSchema[field];
3075
+ var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema];
3076
+ paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field));
3077
+ });
3078
+ var schema = new Schema2(paredFieldsSchema);
3079
+ schema.messages(options.messages);
3080
+ if (data.rule.options) {
3081
+ data.rule.options.messages = options.messages;
3082
+ data.rule.options.error = options.error;
3083
+ }
3084
+ schema.validate(data.value, data.rule.options || options, function(errs) {
3085
+ var finalErrors = [];
3086
+ if (filledErrors && filledErrors.length) {
3087
+ finalErrors.push.apply(finalErrors, filledErrors);
3088
+ }
3089
+ if (errs && errs.length) {
3090
+ finalErrors.push.apply(finalErrors, errs);
3091
+ }
3092
+ doIt(finalErrors.length ? finalErrors : null);
3093
+ });
3094
+ }
3095
+ }
3096
+ var res;
3097
+ if (rule.asyncValidator) {
3098
+ res = rule.asyncValidator(rule, data.value, cb, data.source, options);
3099
+ } else if (rule.validator) {
3100
+ try {
3101
+ res = rule.validator(rule, data.value, cb, data.source, options);
3102
+ } catch (error) {
3103
+ console.error == null ? void 0 : console.error(error);
3104
+ if (!options.suppressValidatorError) {
3105
+ setTimeout(function() {
3106
+ throw error;
3107
+ }, 0);
3108
+ }
3109
+ cb(error.message);
3110
+ }
3111
+ if (res === true) {
3112
+ cb();
3113
+ } else if (res === false) {
3114
+ cb(typeof rule.message === "function" ? rule.message(rule.fullField || rule.field) : rule.message || (rule.fullField || rule.field) + " fails");
3115
+ } else if (res instanceof Array) {
3116
+ cb(res);
3117
+ } else if (res instanceof Error) {
3118
+ cb(res.message);
3119
+ }
3120
+ }
3121
+ if (res && res.then) {
3122
+ res.then(function() {
3123
+ return cb();
3124
+ }, function(e) {
3125
+ return cb(e);
3126
+ });
3127
+ }
3128
+ }, function(results) {
3129
+ complete(results);
3130
+ }, source);
3131
+ };
3132
+ _proto.getType = function getType(rule) {
3133
+ if (rule.type === void 0 && rule.pattern instanceof RegExp) {
3134
+ rule.type = "pattern";
3135
+ }
3136
+ if (typeof rule.validator !== "function" && rule.type && !validators.hasOwnProperty(rule.type)) {
3137
+ throw new Error(format("Unknown rule type %s", rule.type));
3138
+ }
3139
+ return rule.type || "string";
3140
+ };
3141
+ _proto.getValidationMethod = function getValidationMethod(rule) {
3142
+ if (typeof rule.validator === "function") {
3143
+ return rule.validator;
3144
+ }
3145
+ var keys = Object.keys(rule);
3146
+ var messageIndex = keys.indexOf("message");
3147
+ if (messageIndex !== -1) {
3148
+ keys.splice(messageIndex, 1);
3149
+ }
3150
+ if (keys.length === 1 && keys[0] === "required") {
3151
+ return validators.required;
3152
+ }
3153
+ return validators[this.getType(rule)] || void 0;
3154
+ };
3155
+ return Schema2;
3156
+ })();
3157
+ Schema.register = function register(type4, validator) {
3158
+ if (typeof validator !== "function") {
3159
+ throw new Error("Cannot register a validator by type, validator is not a function");
3160
+ }
3161
+ validators[type4] = validator;
3162
+ };
3163
+ Schema.warning = warning;
3164
+ Schema.messages = messages;
3165
+ Schema.validators = validators;
3166
+ const formContextKey = Symbol("formContext");
3167
+ function useForm() {
3168
+ const formItems = ref([]);
3169
+ const formInstance = reactive({
3170
+ validate: async (callback) => {
3171
+ const errors = [];
3172
+ const validatePromises = formItems.value.map((formItem) => {
3173
+ return formItem.validate("submit").catch((errorMessage) => {
3174
+ errors.push({ message: errorMessage, field: "" });
3175
+ });
3176
+ });
3177
+ await Promise.all(validatePromises);
3178
+ const valid = errors.length === 0;
3179
+ if (callback) {
3180
+ callback(valid, errors);
3181
+ }
3182
+ return valid;
3183
+ },
3184
+ validateField: async (props, callback) => {
3185
+ const propsArray = Array.isArray(props) ? props : [props];
3186
+ const errors = [];
3187
+ const fields = {};
3188
+ const validatePromises = formItems.value.filter((item) => {
3189
+ const itemProp = item.prop;
3190
+ return itemProp && propsArray.includes(itemProp);
3191
+ }).map((formItem) => {
3192
+ return formItem.validate("blur").catch((errorMessage) => {
3193
+ const field = formItem.prop;
3194
+ errors.push({ message: errorMessage, field });
3195
+ if (field) {
3196
+ if (!fields[field]) {
3197
+ fields[field] = [];
3198
+ }
3199
+ fields[field].push({ message: errorMessage, field });
3200
+ }
3201
+ });
3202
+ });
3203
+ await Promise.all(validatePromises);
3204
+ const valid = errors.length === 0;
3205
+ if (callback) {
3206
+ callback(valid ? null : errors[0], fields);
3207
+ }
3208
+ return valid;
3209
+ },
3210
+ resetFields: () => {
3211
+ formItems.value.forEach((formItem) => {
3212
+ formItem.resetField();
3213
+ });
3214
+ },
3215
+ clearValidate: (props) => {
3216
+ if (props) {
3217
+ const propsArray = Array.isArray(props) ? props : [props];
3218
+ formItems.value.filter((item) => {
3219
+ const itemProp = item.prop;
3220
+ return itemProp && propsArray.includes(itemProp);
3221
+ }).forEach((formItem) => {
3222
+ formItem.clearValidate();
3223
+ });
3224
+ } else {
3225
+ formItems.value.forEach((formItem) => {
3226
+ formItem.clearValidate();
3227
+ });
3228
+ }
3229
+ },
3230
+ scrollToField: (prop) => {
3231
+ const formItem = formItems.value.find((item) => item.prop === prop);
3232
+ if (formItem) {
3233
+ const el = formItem.$el;
3234
+ if (el) {
3235
+ el.scrollIntoView({ behavior: "smooth", block: "center" });
3236
+ }
3237
+ }
3238
+ }
3239
+ });
3240
+ const addFormItem = (formItem) => {
3241
+ formItems.value.push(formItem);
3242
+ };
3243
+ const removeFormItem = (formItem) => {
3244
+ const index2 = formItems.value.indexOf(formItem);
3245
+ if (index2 > -1) {
3246
+ formItems.value.splice(index2, 1);
3247
+ }
3248
+ };
3249
+ return {
3250
+ formInstance,
3251
+ addFormItem,
3252
+ removeFormItem
3253
+ };
3254
+ }
3255
+ function provideForm(props) {
3256
+ const { formInstance, addFormItem, removeFormItem } = useForm();
3257
+ const formContext = reactive({
3258
+ model: props.model || {},
3259
+ rules: props.rules || {},
3260
+ labelWidth: props.labelWidth || "",
3261
+ labelPosition: props.labelPosition || "left",
3262
+ requiredSymbol: props.requiredSymbol || "*",
3263
+ statusIcon: props.statusIcon || false,
3264
+ inline: props.inline || false,
3265
+ hideRequiredAsterisk: props.hideRequiredAsterisk || false,
3266
+ form: formInstance,
3267
+ addFormItem,
3268
+ removeFormItem
3269
+ });
3270
+ provide(formContextKey, readonly(formContext));
3271
+ return formContext;
3272
+ }
3273
+ function useFormContext() {
3274
+ const formContext = inject(formContextKey);
3275
+ if (!formContext) {
3276
+ throw new Error("FormItem must be used within Form");
3277
+ }
3278
+ return formContext;
3279
+ }
3280
+ function useFormItem(prop) {
3281
+ const formContext = useFormContext();
3282
+ const error = ref("");
3283
+ const validated = ref(false);
3284
+ const validate = async (_trigger = "blur", callback) => {
3285
+ if (!prop || !formContext.model || !formContext.rules[prop]) {
3286
+ const valid = true;
3287
+ if (callback) {
3288
+ callback(valid, "");
3289
+ }
3290
+ return valid;
3291
+ }
3292
+ const rules2 = formContext.rules[prop];
3293
+ const value = getFieldValue(formContext.model, prop);
3294
+ const schema = new Schema({
3295
+ [prop]: rules2
3296
+ });
3297
+ try {
3298
+ await schema.validate({
3299
+ [prop]: value
3300
+ }, {
3301
+ first: true
3302
+ });
3303
+ error.value = "";
3304
+ validated.value = true;
3305
+ if (callback) {
3306
+ callback(true, "");
3307
+ }
3308
+ return true;
3309
+ } catch (err) {
3310
+ error.value = err.errors[0];
3311
+ validated.value = false;
3312
+ if (callback) {
3313
+ callback(false, err.errors[0]);
3314
+ }
3315
+ return false;
3316
+ }
3317
+ };
3318
+ const resetField = () => {
3319
+ if (!prop || !formContext.model) return;
3320
+ setFieldValue(formContext.model, prop, "");
3321
+ error.value = "";
3322
+ validated.value = false;
3323
+ };
3324
+ const clearValidate = () => {
3325
+ error.value = "";
3326
+ validated.value = false;
3327
+ };
3328
+ return {
3329
+ formContext,
3330
+ error,
3331
+ validated,
3332
+ validate,
3333
+ resetField,
3334
+ clearValidate
3335
+ };
3336
+ }
3337
+ function getFieldValue(obj, path) {
3338
+ return path.split(".").reduce((prev, curr) => prev && prev[curr], obj);
3339
+ }
3340
+ function setFieldValue(obj, path, value) {
3341
+ const keys = path.split(".");
3342
+ const lastKey = keys.pop();
3343
+ if (!lastKey) return;
3344
+ const target = keys.reduce((prev, curr) => {
3345
+ if (!prev[curr]) {
3346
+ prev[curr] = {};
3347
+ }
3348
+ return prev[curr];
3349
+ }, obj);
3350
+ target[lastKey] = value;
3351
+ }
3352
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3353
+ __name: "form",
3354
+ props: {
3355
+ model: { default: () => ({}) },
3356
+ rules: { default: () => ({}) },
3357
+ labelWidth: { default: "" },
3358
+ labelPosition: { default: "left" },
3359
+ inline: { type: Boolean, default: false },
3360
+ hideRequiredAsterisk: { type: Boolean, default: false },
3361
+ requiredSymbol: {},
3362
+ statusIcon: { type: Boolean },
3363
+ class: {},
3364
+ style: {}
3365
+ },
3366
+ emits: ["submit", "reset"],
3367
+ setup(__props, { emit: __emit }) {
3368
+ const ns = useNamespace("form");
3369
+ const props = __props;
3370
+ const emit = __emit;
3371
+ const formContext = provideForm(props);
3372
+ const handleSubmit = (evt) => {
3373
+ emit("submit", evt);
3374
+ };
3375
+ const handleReset = () => {
3376
+ formContext.form.resetFields();
3377
+ emit("reset");
3378
+ };
3379
+ return (_ctx, _cache) => {
3380
+ return openBlock(), createElementBlock("form", {
3381
+ class: normalizeClass([
3382
+ unref(ns).b,
3383
+ unref(ns).m(__props.labelPosition),
3384
+ {
3385
+ [unref(ns).m("inline")]: __props.inline
3386
+ }
3387
+ ]),
3388
+ onSubmit: withModifiers(handleSubmit, ["prevent"]),
3389
+ onReset: handleReset
3390
+ }, [
3391
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
3392
+ ], 34);
3393
+ };
3394
+ }
3395
+ });
3396
+ const Form = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-e8640a65"]]);
3397
+ const _hoisted_1$2 = {
3398
+ key: 0,
3399
+ class: "fire-form-item__asterisk"
3400
+ };
3401
+ const _hoisted_2$1 = { class: "fire-form-item__content" };
3402
+ const _hoisted_3$1 = {
3403
+ key: 0,
3404
+ class: "fire-form-item__error"
3405
+ };
3406
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3407
+ __name: "form-item",
3408
+ props: {
3409
+ prop: { default: "" },
3410
+ label: { default: "" },
3411
+ labelWidth: { default: "" },
3412
+ required: { type: Boolean, default: false },
3413
+ error: { default: "" },
3414
+ class: {},
3415
+ style: {}
3416
+ },
3417
+ emits: ["validate"],
3418
+ setup(__props) {
3419
+ const ns = useNamespace("form-item");
3420
+ const props = __props;
3421
+ const { formContext, error, validate, resetField, clearValidate } = useFormItem(props.prop);
3422
+ const errorMessage = computed(() => {
3423
+ return props.error || error.value;
3424
+ });
3425
+ const isRequired = computed(() => {
3426
+ if (props.required) return true;
3427
+ if (!props.prop) return false;
3428
+ const rules2 = formContext.rules[props.prop];
3429
+ if (!rules2) return false;
3430
+ const ruleArray = Array.isArray(rules2) ? rules2 : [rules2];
3431
+ return ruleArray.some((rule) => rule.required);
3432
+ });
3433
+ const labelStyle = computed(() => {
3434
+ const width = props.labelWidth || formContext.labelWidth;
3435
+ return width ? { width: typeof width === "number" ? `${width}px` : width } : {};
3436
+ });
3437
+ onMounted(() => {
3438
+ formContext.addFormItem({
3439
+ validate,
3440
+ resetField,
3441
+ clearValidate
3442
+ });
3443
+ });
3444
+ onUnmounted(() => {
3445
+ formContext.removeFormItem({
3446
+ validate,
3447
+ resetField,
3448
+ clearValidate
3449
+ });
3450
+ });
3451
+ if (props.prop) {
3452
+ watch(() => formContext.model[props.prop], () => {
3453
+ validate("change");
3454
+ });
3455
+ }
3456
+ return (_ctx, _cache) => {
3457
+ return openBlock(), createElementBlock("div", {
3458
+ class: normalizeClass([
3459
+ unref(ns).b,
3460
+ {
3461
+ [unref(ns).m("error")]: errorMessage.value
3462
+ }
3463
+ ])
3464
+ }, [
3465
+ __props.label ? (openBlock(), createElementBlock("label", {
3466
+ key: 0,
3467
+ class: "fire-form-item__label",
3468
+ style: normalizeStyle(labelStyle.value)
3469
+ }, [
3470
+ isRequired.value && !unref(formContext).hideRequiredAsterisk ? (openBlock(), createElementBlock("span", _hoisted_1$2, "*")) : createCommentVNode("", true),
3471
+ createTextVNode(" " + toDisplayString(__props.label), 1)
3472
+ ], 4)) : createCommentVNode("", true),
3473
+ createElementVNode("div", _hoisted_2$1, [
3474
+ renderSlot(_ctx.$slots, "default", {}, void 0, true),
3475
+ errorMessage.value ? (openBlock(), createElementBlock("div", _hoisted_3$1, toDisplayString(errorMessage.value), 1)) : createCommentVNode("", true)
3476
+ ])
3477
+ ], 2);
3478
+ };
3479
+ }
3480
+ });
3481
+ const FormItem = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-074e5183"]]);
3482
+ const FireForm = withInstall(Form);
3483
+ const FireFormItem = withInstall(FormItem);
3484
+ const tableContextKey = Symbol("tableContext");
3485
+ function useTable() {
3486
+ const columns = ref([]);
3487
+ const currentRow = ref(null);
3488
+ const oldCurrentRow = ref(null);
3489
+ const tableInstance = reactive({
3490
+ clearSort: () => {
3491
+ columns.value.forEach((column) => {
3492
+ if (column.column.sortable) {
3493
+ column.updateColumn({ sortOrder: null });
3494
+ }
3495
+ });
3496
+ },
3497
+ clearFilter: (columnKey) => {
3498
+ if (columnKey) {
3499
+ const keys = Array.isArray(columnKey) ? columnKey : [columnKey];
3500
+ columns.value.filter((column) => keys.includes(column.column.prop || "")).forEach((column) => {
3501
+ column.updateColumn({ filteredValue: [] });
3502
+ });
3503
+ } else {
3504
+ columns.value.forEach((column) => {
3505
+ if (column.column.filters) {
3506
+ column.updateColumn({ filteredValue: [] });
3507
+ }
3508
+ });
3509
+ }
3510
+ },
3511
+ setCurrentRow: (row) => {
3512
+ oldCurrentRow.value = currentRow.value;
3513
+ currentRow.value = row;
3514
+ },
3515
+ doLayout: () => {
3516
+ },
3517
+ getRows: () => {
3518
+ return [];
3519
+ }
3520
+ });
3521
+ const addColumn = (column) => {
3522
+ columns.value.push(column);
3523
+ };
3524
+ const removeColumn = (column) => {
3525
+ const index2 = columns.value.indexOf(column);
3526
+ if (index2 > -1) {
3527
+ columns.value.splice(index2, 1);
3528
+ }
3529
+ };
3530
+ return {
3531
+ tableInstance,
3532
+ columns,
3533
+ currentRow,
3534
+ oldCurrentRow,
3535
+ addColumn,
3536
+ removeColumn
3537
+ };
3538
+ }
3539
+ function provideTable(props) {
3540
+ const { tableInstance, currentRow, oldCurrentRow, addColumn, removeColumn } = useTable();
3541
+ const tableContext = reactive({
3542
+ data: props.data || [],
3543
+ border: props.border || false,
3544
+ stripe: props.stripe || false,
3545
+ highlightCurrentRow: props.highlightCurrentRow || false,
3546
+ currentRowKey: props.currentRowKey || "",
3547
+ table: tableInstance,
3548
+ addColumn,
3549
+ removeColumn
3550
+ });
3551
+ provide(tableContextKey, readonly(tableContext));
3552
+ return {
3553
+ tableContext,
3554
+ currentRow,
3555
+ oldCurrentRow
3556
+ };
3557
+ }
3558
+ function useTableContext() {
3559
+ const tableContext = inject(tableContextKey);
3560
+ if (!tableContext) {
3561
+ throw new Error("TableColumn must be used within Table");
3562
+ }
3563
+ return tableContext;
3564
+ }
3565
+ function useTableColumn(props) {
3566
+ const tableContext = useTableContext();
3567
+ const columnInstance = reactive({
3568
+ column: props,
3569
+ updateColumn: (newProps) => {
3570
+ Object.assign(columnInstance.column, newProps);
3571
+ }
3572
+ });
3573
+ return {
3574
+ tableContext,
3575
+ columnInstance
3576
+ };
3577
+ }
3578
+ const _hoisted_1$1 = { class: "fire-table__inner" };
3579
+ const _hoisted_2 = ["onClick"];
3580
+ const _hoisted_3 = { class: "fire-table__column-header" };
3581
+ const _hoisted_4 = { key: 1 };
3582
+ const _hoisted_5 = {
3583
+ key: 0,
3584
+ class: "fire-table__column-sorter"
3585
+ };
3586
+ const _hoisted_6 = ["onClick"];
3587
+ const _hoisted_7 = { key: 1 };
3588
+ const _hoisted_8 = {
3589
+ key: 0,
3590
+ class: "fire-table__empty"
3591
+ };
3592
+ const _hoisted_9 = ["colspan"];
3593
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3594
+ __name: "table",
3595
+ props: {
3596
+ data: { default: () => [] },
3597
+ border: { type: Boolean, default: false },
3598
+ stripe: { type: Boolean, default: false },
3599
+ highlightCurrentRow: { type: Boolean, default: false },
3600
+ currentRowKey: { default: "" },
3601
+ height: {},
3602
+ maxHeight: {},
3603
+ class: {},
3604
+ style: {}
3605
+ },
3606
+ emits: ["row-click", "sort-change", "filter-change", "current-change"],
3607
+ setup(__props, { expose: __expose, emit: __emit }) {
3608
+ const ns = useNamespace("table");
3609
+ const props = __props;
3610
+ const emit = __emit;
3611
+ const { tableContext, currentRow } = provideTable(props);
3612
+ const columns = ref([]);
3613
+ watch(() => props.data, (newData) => {
3614
+ tableContext.data = newData;
3615
+ });
3616
+ watch(() => props.highlightCurrentRow, (value) => {
3617
+ tableContext.highlightCurrentRow = value;
3618
+ });
3619
+ watch(() => props.currentRowKey, (key) => {
3620
+ tableContext.currentRowKey = key;
3621
+ if (key && props.data.length > 0) {
3622
+ const row = props.data.find((item) => item.key === key || item.id === key);
3623
+ if (row) {
3624
+ currentRow.value = row;
3625
+ }
3626
+ }
3627
+ });
3628
+ watch(currentRow, (newRow, oldRow) => {
3629
+ emit("current-change", newRow, oldRow);
3630
+ });
3631
+ const handleRowClick = (row, event) => {
3632
+ if (props.highlightCurrentRow) {
3633
+ currentRow.value = row;
3634
+ }
3635
+ emit("row-click", row, event);
3636
+ };
3637
+ const handleColumnClick = (column) => {
3638
+ if (column.sortable) {
3639
+ if (column.sortOrder === "ascending") {
3640
+ column.sortOrder = "descending";
3641
+ } else if (column.sortOrder === "descending") {
3642
+ column.sortOrder = null;
3643
+ } else {
3644
+ column.sortOrder = "ascending";
3645
+ }
3646
+ columns.value.forEach((col) => {
3647
+ if (col !== column) {
3648
+ col.sortOrder = null;
3649
+ }
3650
+ });
3651
+ emit("sort-change", column, column.sortOrder);
3652
+ }
3653
+ };
3654
+ const registerColumn = (column) => {
3655
+ columns.value.push(column);
3656
+ };
3657
+ const unregisterColumn = (column) => {
3658
+ const index2 = columns.value.indexOf(column);
3659
+ if (index2 > -1) {
3660
+ columns.value.splice(index2, 1);
3661
+ }
3662
+ };
3663
+ __expose({
3664
+ registerColumn,
3665
+ unregisterColumn
3666
+ });
3667
+ return (_ctx, _cache) => {
3668
+ return openBlock(), createElementBlock("div", {
3669
+ class: normalizeClass([
3670
+ unref(ns).b,
3671
+ {
3672
+ [unref(ns).m("border")]: __props.border,
3673
+ [unref(ns).m("stripe")]: __props.stripe
3674
+ }
3675
+ ])
3676
+ }, [
3677
+ createElementVNode("table", _hoisted_1$1, [
3678
+ createElementVNode("thead", null, [
3679
+ createElementVNode("tr", null, [
3680
+ (openBlock(true), createElementBlock(Fragment, null, renderList(columns.value, (column) => {
3681
+ return openBlock(), createElementBlock("th", {
3682
+ key: column.prop || column.label,
3683
+ class: normalizeClass([
3684
+ "fire-table__column",
3685
+ {
3686
+ [`fire-table__column--fixed-${column.fixed}`]: column.fixed,
3687
+ [`fire-table__column--sortable`]: column.sortable
3688
+ }
3689
+ ]),
3690
+ style: normalizeStyle({ width: column.width }),
3691
+ onClick: ($event) => handleColumnClick(column)
3692
+ }, [
3693
+ createElementVNode("div", _hoisted_3, [
3694
+ renderSlot(_ctx.$slots, `header-${column.prop}`, { column }, () => [
3695
+ column.$slots.header ? renderSlot(_ctx.$slots, "header", {
3696
+ key: 0,
3697
+ column
3698
+ }, void 0, true) : (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(column.label), 1))
3699
+ ], true),
3700
+ column.sortable ? (openBlock(), createElementBlock("div", _hoisted_5, [
3701
+ createElementVNode("span", {
3702
+ class: normalizeClass(["fire-table__column-sorter-icon", {
3703
+ "fire-table__column-sorter-icon--ascending": column.sortOrder === "ascending",
3704
+ "fire-table__column-sorter-icon--descending": column.sortOrder === "descending"
3705
+ }])
3706
+ }, [
3707
+ createVNode(unref(ChevronUp), { size: 12 }),
3708
+ createVNode(unref(ChevronDown), { size: 12 })
3709
+ ], 2)
3710
+ ])) : createCommentVNode("", true)
3711
+ ])
3712
+ ], 14, _hoisted_2);
3713
+ }), 128))
3714
+ ])
3715
+ ]),
3716
+ createElementVNode("tbody", null, [
3717
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.data, (row, index2) => {
3718
+ return openBlock(), createElementBlock("tr", {
3719
+ key: row.key || index2,
3720
+ class: normalizeClass({
3721
+ "fire-table__row--current": __props.highlightCurrentRow && row === unref(currentRow)
3722
+ }),
3723
+ onClick: ($event) => handleRowClick(row, $event)
3724
+ }, [
3725
+ (openBlock(true), createElementBlock(Fragment, null, renderList(columns.value, (column) => {
3726
+ return openBlock(), createElementBlock("td", {
3727
+ key: column.prop || column.label,
3728
+ class: normalizeClass([
3729
+ "fire-table__cell",
3730
+ {
3731
+ [`fire-table__cell--fixed-${column.fixed}`]: column.fixed
3732
+ }
3733
+ ]),
3734
+ style: normalizeStyle({ width: column.width })
3735
+ }, [
3736
+ renderSlot(_ctx.$slots, `default-${column.prop}`, {
3737
+ row,
3738
+ column,
3739
+ $index: index2
3740
+ }, () => [
3741
+ column.$slots.default ? renderSlot(_ctx.$slots, "default", {
3742
+ key: 0,
3743
+ row,
3744
+ column,
3745
+ $index: index2
3746
+ }, void 0, true) : (openBlock(), createElementBlock("span", _hoisted_7, toDisplayString(row[column.prop]), 1))
3747
+ ], true)
3748
+ ], 6);
3749
+ }), 128))
3750
+ ], 10, _hoisted_6);
3751
+ }), 128)),
3752
+ __props.data.length === 0 ? (openBlock(), createElementBlock("tr", _hoisted_8, [
3753
+ createElementVNode("td", {
3754
+ colspan: columns.value.length,
3755
+ class: "fire-table__empty-cell"
3756
+ }, [
3757
+ renderSlot(_ctx.$slots, "empty", {}, () => [
3758
+ _cache[0] || (_cache[0] = createElementVNode("div", { class: "fire-table__empty-content" }, [
3759
+ createElementVNode("div", { style: { "font-size": "48px", "margin-bottom": "16px" } }, "📦"),
3760
+ createElementVNode("p", null, "暂无数据")
3761
+ ], -1))
3762
+ ], true)
3763
+ ], 8, _hoisted_9)
3764
+ ])) : createCommentVNode("", true)
3765
+ ])
3766
+ ])
3767
+ ], 2);
3768
+ };
3769
+ }
3770
+ });
3771
+ const Table = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-690936e8"]]);
3772
+ const _hoisted_1 = { style: { "display": "none" } };
3773
+ const _sfc_main = /* @__PURE__ */ defineComponent({
3774
+ __name: "table-column",
3775
+ props: {
3776
+ prop: { default: "" },
3777
+ label: { default: "" },
3778
+ width: { default: "" },
3779
+ fixed: { default: void 0 },
3780
+ sortable: { type: Boolean, default: false },
3781
+ sortMethod: {},
3782
+ sortOrder: { default: null },
3783
+ filters: { default: void 0 },
3784
+ filterMethod: {},
3785
+ filteredValue: { default: void 0 },
3786
+ class: {},
3787
+ style: {}
3788
+ },
3789
+ setup(__props) {
3790
+ const props = __props;
3791
+ const slots = useSlots();
3792
+ const tableContext = useTableContext();
3793
+ const { columnInstance } = useTableColumn(props);
3794
+ const columnWithSlots = computed(() => {
3795
+ return {
3796
+ ...columnInstance.column,
3797
+ $slots: slots
3798
+ };
3799
+ });
3800
+ onMounted(() => {
3801
+ const table = tableContext.table;
3802
+ if (table && table.registerColumn) {
3803
+ table.registerColumn(columnWithSlots.value);
3804
+ }
3805
+ const tableElement = document.querySelector(".fire-table");
3806
+ if (tableElement && tableElement.__vueParentComponent) {
3807
+ const parent = tableElement.__vueParentComponent;
3808
+ if (parent.proxy && parent.proxy.registerColumn) {
3809
+ parent.proxy.registerColumn(columnWithSlots.value);
3810
+ }
3811
+ }
3812
+ });
3813
+ onUnmounted(() => {
3814
+ const table = tableContext.table;
3815
+ if (table && table.unregisterColumn) {
3816
+ table.unregisterColumn(columnWithSlots.value);
3817
+ }
3818
+ const tableElement = document.querySelector(".fire-table");
3819
+ if (tableElement && tableElement.__vueParentComponent) {
3820
+ const parent = tableElement.__vueParentComponent;
3821
+ if (parent.proxy && parent.proxy.unregisterColumn) {
3822
+ parent.proxy.unregisterColumn(columnWithSlots.value);
3823
+ }
3824
+ }
3825
+ });
3826
+ return (_ctx, _cache) => {
3827
+ return openBlock(), createElementBlock("div", _hoisted_1);
3828
+ };
3829
+ }
3830
+ });
3831
+ const FireTable = withInstall(Table);
3832
+ const FireTableColumn = withInstall(_sfc_main);
3833
+ const components = [FButton, FireRow, FireCol, FireContainer, FireHeader, FireAside, FireMain, FireFooter, FireTooltip, FireTips, FireInput, FireForm, FireFormItem, FireTable, FireTableColumn];
3834
+ const install = (app) => {
3835
+ components.forEach((component) => {
3836
+ if (component && component.name) {
3837
+ app.component(component.name, component);
3838
+ }
3839
+ });
3840
+ };
3841
+ const index = {
3842
+ install,
3843
+ version: "0.1.0"
3844
+ };
3845
+ export {
3846
+ FButton,
3847
+ FireAside,
3848
+ FireCol,
3849
+ FireContainer,
3850
+ FireFooter,
3851
+ FireForm,
3852
+ FireFormItem,
3853
+ FireHeader,
3854
+ FireInput,
3855
+ FireMain,
3856
+ FireRow,
3857
+ FireTable,
3858
+ FireTableColumn,
3859
+ FireTips,
3860
+ FireTooltip,
3861
+ index as default,
3862
+ registerComponent,
3863
+ registerComponents,
3864
+ useNamespace,
3865
+ withInstall
3866
+ };
3867
+ //# sourceMappingURL=fireui.es.mjs.map