@verbb/formie-browser 1.0.0 → 1.0.2

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 (120) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/chunks/address-finder-CQW81kY0.js +37 -0
  3. package/dist/chunks/bpoint-D8OjLmsn.js +26 -0
  4. package/dist/chunks/calculations-BqZsENCq.js +147 -0
  5. package/dist/chunks/captcha-eu-DIa6aUWz.js +34 -0
  6. package/dist/chunks/checkbox-radio-BI-UjgMF.js +136 -0
  7. package/dist/chunks/conditions-BVl6jTYo.js +433 -0
  8. package/dist/chunks/date-picker-69TgvErA.js +4994 -0
  9. package/dist/chunks/eway-1GPxH6DU.js +74 -0
  10. package/dist/chunks/file-upload-BDZZftgL.js +281 -0
  11. package/dist/chunks/friendly-captcha-v1-DA2QPKA3.js +33 -0
  12. package/dist/chunks/friendly-captcha-v2-BorOWiz_.js +38 -0
  13. package/dist/chunks/go-cardless-DwBgERcA.js +24 -0
  14. package/dist/chunks/google-address-BcTBncyS.js +162 -0
  15. package/dist/chunks/hcaptcha-BchdVCqq.js +56 -0
  16. package/dist/chunks/hidden-D8RqSPt7.js +31 -0
  17. package/dist/chunks/index-BEsfee-D.js +1839 -0
  18. package/dist/chunks/index-BP7Unm5Y.js +863 -0
  19. package/dist/chunks/index-C1ZOKiAi.js +4229 -0
  20. package/dist/chunks/loqate-nXuTX7In.js +55 -0
  21. package/dist/chunks/mollie-qdCynQCd.js +24 -0
  22. package/dist/chunks/moneris-BNEA-laO.js +101 -0
  23. package/dist/chunks/opayo-BJtXOkuK.js +122 -0
  24. package/dist/chunks/paddle-D72Pa8kr.js +60 -0
  25. package/dist/chunks/paypal-Cqt2bned.js +100 -0
  26. package/dist/chunks/payway-BjCqsc0H.js +56 -0
  27. package/dist/chunks/phone-country-K9pYAlzM.js +3765 -0
  28. package/dist/chunks/place-kit-Dg6f_UoM.js +42 -0
  29. package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +1299 -0
  30. package/dist/chunks/recaptcha-enterprise--VYAeeqz.js +71 -0
  31. package/dist/chunks/recaptcha-shared-PSIEEEe1.js +15 -0
  32. package/dist/chunks/recaptcha-v2-checkbox-atBNe5ml.js +41 -0
  33. package/dist/chunks/recaptcha-v2-invisible-DnBufNPT.js +59 -0
  34. package/dist/chunks/recaptcha-v3-CF6O8rDj.js +28 -0
  35. package/dist/chunks/repeater-CB7Yojvx.js +124 -0
  36. package/dist/chunks/rich-text-nAV_SQZo.js +304 -0
  37. package/dist/chunks/scripts-BkAAux0i.js +36 -0
  38. package/dist/chunks/sdk-3SicTWby.js +1559 -0
  39. package/dist/chunks/shared-DGqeMvcJ.js +80 -0
  40. package/dist/chunks/signature-BT6CsQ6n.js +550 -0
  41. package/dist/chunks/snaptcha-C7qQo02f.js +8 -0
  42. package/dist/chunks/square-C5AH3trb.js +46 -0
  43. package/dist/chunks/stripe-EJK0RyUv.js +202 -0
  44. package/dist/chunks/styles-C3aqgtek.js +21 -0
  45. package/dist/chunks/summary-DC_ipXCU.js +126 -0
  46. package/dist/chunks/table-BEAI99qo.js +95 -0
  47. package/dist/chunks/text-limit-Blgq5G-G.js +135 -0
  48. package/dist/chunks/turnstile-_uCRwnU-.js +59 -0
  49. package/dist/chunks/utils-BntI3W4S.js +6149 -0
  50. package/dist/index.js +39 -3205
  51. package/package.json +5 -5
  52. package/src/js/modules/fields/file-upload.ts +1 -1
  53. package/src/js/modules/fields/repeater.ts +1 -1
  54. package/src/js/modules/fields/rich-text.ts +2 -2
  55. package/src/js/modules/fields/signature.ts +1 -1
  56. package/src/js/modules/fields/summary.ts +1 -1
  57. package/src/js/modules/fields/table.ts +1 -1
  58. package/src/js/modules/fields/text-limit.ts +1 -1
  59. package/src/js/modules/payments/paypal.ts +1 -1
  60. package/src/js/modules/payments/payway.ts +1 -1
  61. package/src/js/modules/payments/stripe.ts +1 -1
  62. package/dist/chunks/address-finder-DfMCiW89.js +0 -47
  63. package/dist/chunks/api-CbqEMQT5.js +0 -181
  64. package/dist/chunks/api-DE7LfK-R.js +0 -960
  65. package/dist/chunks/api-DOfDzYC_.js +0 -538
  66. package/dist/chunks/async-B3DUf1GZ.js +0 -26
  67. package/dist/chunks/bpoint-Ciy3yY9Q.js +0 -34
  68. package/dist/chunks/calculations-CkYAqO_-.js +0 -197
  69. package/dist/chunks/captcha-eu-DnOWhMwr.js +0 -43
  70. package/dist/chunks/checkbox-radio-0x7Tc0br.js +0 -197
  71. package/dist/chunks/chunk-K6L4z4UQ.js +0 -24
  72. package/dist/chunks/conditions-4fXKhEJS.js +0 -609
  73. package/dist/chunks/date-picker-B6iZkjHS.js +0 -6204
  74. package/dist/chunks/debug-KnZeKYBI.js +0 -39
  75. package/dist/chunks/dist-D09GnXMW.js +0 -2663
  76. package/dist/chunks/event-names-DamGPtXR.js +0 -51
  77. package/dist/chunks/eway-DEAYcwT0.js +0 -86
  78. package/dist/chunks/field-references.keys-BpBZ_quS.js +0 -24
  79. package/dist/chunks/field-references.resolver-Ba6xhiJC.js +0 -183
  80. package/dist/chunks/file-upload-Bh63PQSE.js +0 -430
  81. package/dist/chunks/friendly-captcha-v1-CqO4WVre.js +0 -40
  82. package/dist/chunks/friendly-captcha-v2-CyykcJcM.js +0 -47
  83. package/dist/chunks/friendly-challenge-Dg8XkStd.js +0 -1101
  84. package/dist/chunks/go-cardless-CuND59rR.js +0 -26
  85. package/dist/chunks/google-address--uR8WDSm.js +0 -208
  86. package/dist/chunks/hcaptcha-CmaFUesv.js +0 -72
  87. package/dist/chunks/hidden-CYnZYple.js +0 -36
  88. package/dist/chunks/http-18nn97DZ.js +0 -29
  89. package/dist/chunks/i18n-vUh-KGiH.js +0 -55
  90. package/dist/chunks/loqate-BICNJlVK.js +0 -97
  91. package/dist/chunks/mollie-DwlsgHZ1.js +0 -26
  92. package/dist/chunks/moneris-B_IFZFTx.js +0 -159
  93. package/dist/chunks/opayo-U2x_TOII.js +0 -192
  94. package/dist/chunks/paddle-BqXFrc79.js +0 -75
  95. package/dist/chunks/paypal-Cn_DYGDb.js +0 -121
  96. package/dist/chunks/payway-Rnq796eC.js +0 -75
  97. package/dist/chunks/phone-country-B6Me4lK0.js +0 -3317
  98. package/dist/chunks/place-kit-ldUl-u9w.js +0 -56
  99. package/dist/chunks/placekit-autocomplete.esm-D-lGeaZl.js +0 -1771
  100. package/dist/chunks/recaptcha-enterprise-DPJNyv1X.js +0 -72
  101. package/dist/chunks/recaptcha-shared-DTI4qWVR.js +0 -22
  102. package/dist/chunks/recaptcha-v2-checkbox-zFjpvJ5c.js +0 -49
  103. package/dist/chunks/recaptcha-v2-invisible-CnYtkNvz.js +0 -62
  104. package/dist/chunks/recaptcha-v3-EAlWhnkX.js +0 -33
  105. package/dist/chunks/repeater-CXD1eLSn.js +0 -151
  106. package/dist/chunks/rich-text-DkmZRhGj.js +0 -442
  107. package/dist/chunks/scripts-BGD_iU_6.js +0 -41
  108. package/dist/chunks/sdk-B7u9fTlP.js +0 -2103
  109. package/dist/chunks/shared-DC6_1u8X.js +0 -85
  110. package/dist/chunks/signature-E9KyYXS1.js +0 -765
  111. package/dist/chunks/snaptcha-CCDunGeb.js +0 -8
  112. package/dist/chunks/square-BLqK51rS.js +0 -61
  113. package/dist/chunks/stripe-B8gHpZNC.js +0 -273
  114. package/dist/chunks/styles-BIh6g7V_.js +0 -22
  115. package/dist/chunks/summary-EcNE0cvg.js +0 -191
  116. package/dist/chunks/table-yxEDL6kA.js +0 -124
  117. package/dist/chunks/text-limit-D0H_Ca2c.js +0 -179
  118. package/dist/chunks/theme-classes-vSHpdCUO.js +0 -59
  119. package/dist/chunks/turnstile-DP0bdR7T.js +0 -68
  120. package/dist/chunks/utils-ByrEVYrJ.js +0 -49584
@@ -0,0 +1,433 @@
1
+ import { S as j, A as U } from "./index-BEsfee-D.js";
2
+ import { e as R } from "./shared-DGqeMvcJ.js";
3
+ import { j as _, h as W } from "./index-C1ZOKiAi.js";
4
+ const C = "[data-formie-conditions]";
5
+ function G(e) {
6
+ if (!e || typeof e != "object")
7
+ return null;
8
+ const t = e, r = t.transformerParams;
9
+ return {
10
+ raw: typeof t.raw == "string" ? t.raw : "",
11
+ target: typeof t.target == "string" ? t.target : "",
12
+ handle: typeof t.handle == "string" ? t.handle : "",
13
+ selector: typeof t.selector == "string" ? t.selector : "",
14
+ defaultValue: typeof t.defaultValue == "string" ? t.defaultValue : "",
15
+ transformerId: typeof t.transformerId == "string" ? t.transformerId : "",
16
+ transformerParams: r && typeof r == "object" ? Object.fromEntries(Object.entries(r).map(([n, i]) => [n, String(i ?? "")])) : {},
17
+ isValid: t.isValid !== !1
18
+ };
19
+ }
20
+ function O(e) {
21
+ const t = Array.from(e.querySelectorAll(C));
22
+ return e.matches(C) ? [e, ...t] : t;
23
+ }
24
+ function z(e) {
25
+ const t = e.getAttribute("data-formie-conditions");
26
+ if (!t)
27
+ return null;
28
+ try {
29
+ const r = JSON.parse(t), n = Array.isArray(r.conditions) ? r.conditions.filter((i) => {
30
+ if (!i || typeof i != "object")
31
+ return !1;
32
+ const o = i;
33
+ return typeof o.field == "string" && typeof o.condition == "string";
34
+ }).map((i) => {
35
+ const o = i;
36
+ return {
37
+ field: i.field,
38
+ source: G(o.source),
39
+ condition: i.condition,
40
+ value: i.value
41
+ };
42
+ }) : [];
43
+ return {
44
+ showRule: r.showRule === "hide" ? "hide" : "show",
45
+ conditionRule: r.conditionRule === "any" ? "any" : "all",
46
+ clearOnHide: r.clearOnHide !== !1,
47
+ isNested: !!r.isNested,
48
+ conditions: n
49
+ };
50
+ } catch (r) {
51
+ return console.error("[formie] Invalid condition JSON.", r), null;
52
+ }
53
+ }
54
+ const I = "data-formie-conditions-disabled", H = "data-formie-preserve-disabled", x = "data-formie-conditionally-hidden", $ = "data-formie-page-hidden", J = "formie-conditionally-hidden", K = "formie-page-hidden", y = "data-formie-row-hidden", L = "formie-row-hidden", T = "data-formie-field-count", w = "[data-formie-row], [data-formie-subfield-row], [data-formie-nested-field-row]", Q = ":scope > [data-formie-field]";
55
+ function X(e) {
56
+ e.querySelectorAll("input, select, textarea").forEach((t) => {
57
+ !(t instanceof HTMLInputElement) && !(t instanceof HTMLSelectElement) && !(t instanceof HTMLTextAreaElement) || (t instanceof HTMLInputElement && (t.type === "checkbox" || t.type === "radio" ? t.checked = !1 : t.type !== "hidden" && (t.value = "")), t instanceof HTMLSelectElement && (t.multiple ? Array.from(t.options).forEach((r) => {
58
+ r.selected = !1;
59
+ }) : t.selectedIndex = 0), t instanceof HTMLTextAreaElement && (t.value = ""));
60
+ });
61
+ }
62
+ function Z(e, t) {
63
+ const r = e.hasAttribute("data-formie-page"), n = r ? $ : x, i = r ? K : J, o = e.hasAttribute(n);
64
+ return t ? (o || e.setAttribute(n, "true"), e.classList.contains(i) || e.classList.add(i)) : (o && e.removeAttribute(n), e.classList.contains(i) && e.classList.remove(i)), o !== t;
65
+ }
66
+ function ee(e, t) {
67
+ e.querySelectorAll("input, textarea, select").forEach((r) => {
68
+ if (t) {
69
+ r.hasAttribute(I) || (r.hasAttribute("disabled") && r.setAttribute(H, "true"), r.setAttribute(I, "true")), r.setAttribute("disabled", "true");
70
+ return;
71
+ }
72
+ r.hasAttribute(I) && (r.hasAttribute(H) ? (r.setAttribute("disabled", "true"), r.removeAttribute(H)) : r.removeAttribute("disabled"), r.removeAttribute(I));
73
+ });
74
+ }
75
+ function te(e) {
76
+ return !e.hasAttribute(x) && !e.hasAttribute($) && !e.hasAttribute(y) && !e.hasAttribute("hidden");
77
+ }
78
+ function re(e) {
79
+ const r = Array.from(e.querySelectorAll(Q)).filter((n) => te(n)).length;
80
+ if (r > 0) {
81
+ const n = String(r);
82
+ e.getAttribute(T) !== n && e.setAttribute(T, n), e.hasAttribute(y) && e.removeAttribute(y), e.classList.contains(L) && e.classList.remove(L);
83
+ return;
84
+ }
85
+ e.hasAttribute(T) && e.removeAttribute(T), e.hasAttribute(y) || e.setAttribute(y, "true"), e.classList.contains(L) || e.classList.add(L);
86
+ }
87
+ function ne(e) {
88
+ let t = e.closest(w);
89
+ for (; t; )
90
+ re(t), t = t.parentElement?.closest(w) || null;
91
+ }
92
+ function ie(e, t, r) {
93
+ const n = Z(e, t);
94
+ return ee(e, t), ne(e), t && r && n && X(e), n;
95
+ }
96
+ const v = "input, select, textarea", oe = "[data-formie-repeater-item], [data-formie-table-row]";
97
+ function g(e) {
98
+ return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
99
+ }
100
+ function se(e) {
101
+ const t = e.querySelector(v);
102
+ if (!t)
103
+ return null;
104
+ const r = t.getAttribute("name") || "", n = Array.from(r.matchAll(/\[(\d+)\]/g));
105
+ return n.length && n[n.length - 1]?.[1] || null;
106
+ }
107
+ function D(e) {
108
+ return e.closest(oe);
109
+ }
110
+ function ae(e) {
111
+ return Array.from(e.querySelectorAll(v)).filter((t) => g(t));
112
+ }
113
+ function ue(e) {
114
+ const t = e.getAttribute("name") || "";
115
+ return Array.from(t.matchAll(/\[([^\]]+)\]/g)).map((r) => r[1] || "").filter(Boolean);
116
+ }
117
+ function le(e, t) {
118
+ if (!t)
119
+ return !0;
120
+ const r = t.split(/[.:]/).filter(Boolean);
121
+ if (!r.length)
122
+ return !0;
123
+ const n = ue(e);
124
+ return n.length < r.length ? !1 : r.every((i, o) => n[n.length - r.length + o] === i);
125
+ }
126
+ function ce(e, t) {
127
+ if (!t)
128
+ return e;
129
+ const r = e.filter((n) => le(n, t));
130
+ return r.length ? r : e;
131
+ }
132
+ function V(e, t) {
133
+ const r = D(e);
134
+ if (!r)
135
+ return t;
136
+ const n = t.filter((i) => D(i) === r);
137
+ return n.length ? n : t;
138
+ }
139
+ function B(e) {
140
+ return e.source?.target === "field" && e.source.handle ? e.source : null;
141
+ }
142
+ function P(e, t, r) {
143
+ const n = B(r);
144
+ if (!n || n.target !== "field" || !n.handle)
145
+ return [];
146
+ const i = R(n.handle), o = Array.from(e.querySelectorAll(`[data-formie-field-handle="${i}"]`));
147
+ if (o.length)
148
+ return V(t, o).flatMap((f) => ce(ae(f), n.selector));
149
+ const l = _(n.handle), c = R(l), m = Array.from(e.querySelectorAll(`[name="${c}"]`)).filter((f) => g(f)), S = Array.from(e.querySelectorAll(`[name="${c}[]"]`)).filter((f) => g(f));
150
+ if (m.length || S.length)
151
+ return V(t, [...m, ...S]);
152
+ if (!n.handle.includes("__ROW__"))
153
+ return [];
154
+ const h = se(t);
155
+ if (h) {
156
+ const f = _(n.handle.replace(/__ROW__/g, h)), b = R(f), s = Array.from(e.querySelectorAll(`[name="${b}"]`)).filter((u) => g(u)), a = Array.from(e.querySelectorAll(`[name="${b}[]"]`)).filter((u) => g(u));
157
+ if (s.length || a.length)
158
+ return [...s, ...a];
159
+ }
160
+ const N = _(n.handle).replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/__ROW__/g, "\\d+"), E = new RegExp(N);
161
+ return Array.from(e.querySelectorAll("[name]")).filter((f) => g(f) && E.test(f.getAttribute("name") || ""));
162
+ }
163
+ function fe(e) {
164
+ return e == null ? "" : String(e);
165
+ }
166
+ function de(e) {
167
+ if (typeof e == "boolean")
168
+ return e;
169
+ if (typeof e == "number")
170
+ return e !== 0;
171
+ const t = fe(e).trim().toLowerCase();
172
+ return !(!t || ["0", "false", "no", "off"].includes(t));
173
+ }
174
+ function me(e) {
175
+ return e.toLowerCase().replace(/\b\w/g, (t) => t.toUpperCase());
176
+ }
177
+ function he(e, t) {
178
+ const r = Number.isFinite(Number(t.decimals)) ? Number(t.decimals) : 0, n = t.decimalPoint ?? ".", i = t.thousandsSeparator ?? ",", o = e.toFixed(r), [l, c = ""] = o.split("."), m = l.replace(/\B(?=(\d{3})+(?!\d))/g, i);
179
+ return r === 0 ? m : `${m}${n}${c}`;
180
+ }
181
+ function A(e) {
182
+ return String(e).padStart(2, "0");
183
+ }
184
+ function pe(e, t) {
185
+ return [
186
+ ["Y", String(e.getFullYear())],
187
+ ["m", A(e.getMonth() + 1)],
188
+ ["d", A(e.getDate())],
189
+ ["j", String(e.getDate())],
190
+ ["H", A(e.getHours())],
191
+ ["h", A((e.getHours() + 11) % 12 + 1)],
192
+ ["i", A(e.getMinutes())],
193
+ ["A", e.getHours() >= 12 ? "PM" : "AM"],
194
+ ["F", e.toLocaleString(void 0, { month: "long" })]
195
+ ].reduce((n, [i, o]) => n.replaceAll(i, o), t);
196
+ }
197
+ function ge(e) {
198
+ switch (e) {
199
+ case "datetimeUs12":
200
+ return "m/d/Y h:i A";
201
+ case "datetimeEu12":
202
+ return "d/m/Y h:i A";
203
+ case "datetimeEu24":
204
+ return "d/m/Y H:i";
205
+ case "datetimeIso24":
206
+ return "Y-m-d H:i";
207
+ case "dateUs":
208
+ return "m/d/Y";
209
+ case "dateEu":
210
+ return "d/m/Y";
211
+ case "isoDate":
212
+ return "Y-m-d";
213
+ case "dateLong":
214
+ return "F j, Y";
215
+ case "time12":
216
+ return "h:i A";
217
+ case "time24":
218
+ return "H:i";
219
+ default:
220
+ return "";
221
+ }
222
+ }
223
+ function be(e, t) {
224
+ const r = t.transformerId, n = t.transformerParams;
225
+ switch (r) {
226
+ case "round":
227
+ case "floor":
228
+ case "ceil": {
229
+ const i = Number(e);
230
+ return Number.isFinite(i) ? String(r === "round" ? Math.round(i) : r === "floor" ? Math.floor(i) : Math.ceil(i)) : e;
231
+ }
232
+ case "format": {
233
+ const i = Number(e);
234
+ if (Number.isFinite(i) && e.trim() !== "")
235
+ return he(i, n);
236
+ const o = n.preset || "", l = o === "custom" ? n.pattern || "" : ge(o);
237
+ if (!l)
238
+ return e;
239
+ const c = new Date(e);
240
+ return Number.isNaN(c.getTime()) ? e : pe(c, l);
241
+ }
242
+ case "lower":
243
+ return e.toLowerCase();
244
+ case "upper":
245
+ return e.toUpperCase();
246
+ case "title":
247
+ return me(e);
248
+ case "capitalize":
249
+ return e && e.charAt(0).toUpperCase() + e.slice(1);
250
+ case "replace": {
251
+ const i = n.search || "";
252
+ return i ? e.split(i).join(n.replace || "") : e;
253
+ }
254
+ case "truncate": {
255
+ const i = Math.max(1, Number.parseInt(n.length || "50", 10) || 50), o = n.suffix || "...";
256
+ return e.length <= i ? e : `${e.slice(0, Math.max(0, i - o.length))}${o}`;
257
+ }
258
+ case "map":
259
+ return de(e) ? n.trueLabel || "Yes" : n.falseLabel || "No";
260
+ default:
261
+ return e;
262
+ }
263
+ }
264
+ function Ae(e, t) {
265
+ if (!t)
266
+ return e;
267
+ const r = t.transformerId ? e.map((n) => be(n, t)) : e;
268
+ return (r.length === 0 || r.every((n) => n.trim() === "")) && t.defaultValue ? [t.defaultValue] : r;
269
+ }
270
+ function ye(e, t) {
271
+ return e.name || `__condition_input_${t}`;
272
+ }
273
+ function F(e) {
274
+ const t = e.id ? e.ownerDocument.querySelector(`label[for="${e.id}"]`)?.textContent?.trim() : "";
275
+ return t || e.closest("label")?.textContent?.trim() || "";
276
+ }
277
+ function Se(e, t = "") {
278
+ const r = e[0];
279
+ if (!r)
280
+ return [];
281
+ if (r instanceof HTMLInputElement) {
282
+ if (r.type === "checkbox") {
283
+ const n = e.filter((i) => i instanceof HTMLInputElement && i.checked);
284
+ return t === "label" ? n.map((i) => F(i)).filter(Boolean) : n.map((i) => i.value);
285
+ }
286
+ if (r.type === "radio") {
287
+ const n = e.filter((i) => i instanceof HTMLInputElement && i.checked);
288
+ return t === "label" ? n.map((i) => F(i)).filter(Boolean) : n.map((i) => i.value);
289
+ }
290
+ if (r.type === "file")
291
+ return Array.from(r.files || []).map((n) => n.name);
292
+ }
293
+ return r instanceof HTMLSelectElement && r.multiple ? t === "label" ? Array.from(r.selectedOptions).map((n) => n.label || n.text) : Array.from(r.selectedOptions).map((n) => n.value) : r instanceof HTMLSelectElement && t === "label" ? Array.from(r.selectedOptions).map((n) => n.label || n.text) : e.map((n) => n.value);
294
+ }
295
+ function k(e) {
296
+ return ["input", "change"];
297
+ }
298
+ function Ee(e, t = null) {
299
+ const r = /* @__PURE__ */ new Map();
300
+ e.forEach((i, o) => {
301
+ const l = ye(i, o), c = r.get(l) || [];
302
+ c.push(i), r.set(l, c);
303
+ });
304
+ const n = Array.from(r.values()).flatMap((i) => Se(i, t?.selector || ""));
305
+ return Ae(n, t);
306
+ }
307
+ function Ie(e) {
308
+ return e.closest("[data-formie-conditionally-hidden]") || e.closest("[data-formie-page-hidden]") || e.closest("[hidden]") || e.closest('[aria-hidden="true"]') ? !1 : !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
309
+ }
310
+ function Le(e) {
311
+ return e.length ? e.some((t) => Ie(t)) : null;
312
+ }
313
+ function Te(e, t) {
314
+ const r = e.conditions.map((n) => {
315
+ const i = t(n), o = B(n);
316
+ return j(n, Ee(i, o), {
317
+ visibility: Le(i)
318
+ });
319
+ });
320
+ return U(e, r);
321
+ }
322
+ const M = 4, p = W("conditions");
323
+ function q(e) {
324
+ const t = /* @__PURE__ */ new Set();
325
+ return e.filter((r) => t.has(r) ? !1 : (t.add(r), !0));
326
+ }
327
+ const _e = {
328
+ id: "conditions",
329
+ kind: "field",
330
+ match: (e) => e.target instanceof HTMLElement && (e.target.matches(C) || !!e.target.querySelector(C)),
331
+ setup: async (e) => {
332
+ const t = e.target instanceof HTMLElement ? e.target : e.root;
333
+ if (!O(t).length) {
334
+ p.log("No condition nodes in scope.");
335
+ return;
336
+ }
337
+ const r = [];
338
+ let n = [], i = !1, o = !1;
339
+ const l = () => {
340
+ r.forEach((s) => {
341
+ s();
342
+ }), r.length = 0;
343
+ }, c = () => O(t).flatMap((s) => {
344
+ const a = z(s);
345
+ if (!a || !a.conditions.length)
346
+ return [];
347
+ const u = q(a.conditions.flatMap((d) => P(t, s, d)));
348
+ return [{
349
+ node: s,
350
+ settings: a,
351
+ sourceInputs: u
352
+ }];
353
+ }), m = () => {
354
+ let s = !1;
355
+ return n.forEach((a) => {
356
+ const u = Te(a.settings, (Y) => P(t, a.node, Y)), d = ie(a.node, u.shouldHide, a.settings.clearOnHide);
357
+ s = s || d, p.log("Condition evaluated.", {
358
+ shouldHide: u.shouldHide,
359
+ finalResult: u.finalResult,
360
+ stateChanged: d
361
+ }), e.emit("formie:conditions:evaluated", {
362
+ node: a.node,
363
+ shouldHide: u.shouldHide,
364
+ finalResult: u.finalResult,
365
+ clearOnHide: a.settings.clearOnHide
366
+ });
367
+ }), s;
368
+ }, S = () => {
369
+ for (let s = 0; s < M && m(); s += 1)
370
+ s === M - 1 && p.warn("Reached max evaluation passes.", { maxPasses: M });
371
+ }, h = () => {
372
+ i || (i = !0, queueMicrotask(() => {
373
+ i = !1, S();
374
+ }));
375
+ }, N = () => {
376
+ if (q(n.flatMap((s) => s.sourceInputs)).forEach((s) => {
377
+ const a = () => {
378
+ h();
379
+ };
380
+ k().forEach((u) => {
381
+ s.addEventListener(u, a);
382
+ }), r.push(() => {
383
+ k().forEach((u) => {
384
+ s.removeEventListener(u, a);
385
+ });
386
+ });
387
+ }), e.form) {
388
+ const s = () => {
389
+ window.setTimeout(() => {
390
+ h();
391
+ }, 0);
392
+ };
393
+ e.form.addEventListener("reset", s), r.push(() => {
394
+ e.form?.removeEventListener("reset", s);
395
+ });
396
+ }
397
+ }, E = () => {
398
+ l(), n = c(), N(), p.log("Rebuilt condition graph.", {
399
+ entryCount: n.length
400
+ }), h();
401
+ }, f = () => {
402
+ o || (o = !0, queueMicrotask(() => {
403
+ o = !1, E();
404
+ }));
405
+ }, b = new MutationObserver((s) => {
406
+ const a = s.some((d) => d.type === "childList" && (d.addedNodes.length > 0 || d.removedNodes.length > 0)), u = s.some((d) => d.type === "attributes");
407
+ a ? f() : u && h();
408
+ });
409
+ return b.observe(t, {
410
+ childList: !0,
411
+ subtree: !0,
412
+ attributes: !0,
413
+ attributeFilter: [
414
+ "class",
415
+ "style",
416
+ "hidden",
417
+ "aria-hidden",
418
+ "data-formie-conditionally-hidden",
419
+ "data-formie-page-hidden",
420
+ "data-formie-row-hidden"
421
+ ]
422
+ }), E(), await e.emit("formie:module:conditions:init", {
423
+ count: n.length
424
+ }), p.log("Module setup complete.", { entryCount: n.length }), {
425
+ destroy: () => {
426
+ l(), b.disconnect(), p.log("Module destroy."), e.emit("formie:module:conditions:destroy", {});
427
+ }
428
+ };
429
+ }
430
+ };
431
+ export {
432
+ _e as conditionsModule
433
+ };