@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.
- package/CHANGELOG.md +16 -0
- package/dist/chunks/address-finder-CQW81kY0.js +37 -0
- package/dist/chunks/bpoint-D8OjLmsn.js +26 -0
- package/dist/chunks/calculations-BqZsENCq.js +147 -0
- package/dist/chunks/captcha-eu-DIa6aUWz.js +34 -0
- package/dist/chunks/checkbox-radio-BI-UjgMF.js +136 -0
- package/dist/chunks/conditions-BVl6jTYo.js +433 -0
- package/dist/chunks/date-picker-69TgvErA.js +4994 -0
- package/dist/chunks/eway-1GPxH6DU.js +74 -0
- package/dist/chunks/file-upload-BDZZftgL.js +281 -0
- package/dist/chunks/friendly-captcha-v1-DA2QPKA3.js +33 -0
- package/dist/chunks/friendly-captcha-v2-BorOWiz_.js +38 -0
- package/dist/chunks/go-cardless-DwBgERcA.js +24 -0
- package/dist/chunks/google-address-BcTBncyS.js +162 -0
- package/dist/chunks/hcaptcha-BchdVCqq.js +56 -0
- package/dist/chunks/hidden-D8RqSPt7.js +31 -0
- package/dist/chunks/index-BEsfee-D.js +1839 -0
- package/dist/chunks/index-BP7Unm5Y.js +863 -0
- package/dist/chunks/index-C1ZOKiAi.js +4229 -0
- package/dist/chunks/loqate-nXuTX7In.js +55 -0
- package/dist/chunks/mollie-qdCynQCd.js +24 -0
- package/dist/chunks/moneris-BNEA-laO.js +101 -0
- package/dist/chunks/opayo-BJtXOkuK.js +122 -0
- package/dist/chunks/paddle-D72Pa8kr.js +60 -0
- package/dist/chunks/paypal-Cqt2bned.js +100 -0
- package/dist/chunks/payway-BjCqsc0H.js +56 -0
- package/dist/chunks/phone-country-K9pYAlzM.js +3765 -0
- package/dist/chunks/place-kit-Dg6f_UoM.js +42 -0
- package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +1299 -0
- package/dist/chunks/recaptcha-enterprise--VYAeeqz.js +71 -0
- package/dist/chunks/recaptcha-shared-PSIEEEe1.js +15 -0
- package/dist/chunks/recaptcha-v2-checkbox-atBNe5ml.js +41 -0
- package/dist/chunks/recaptcha-v2-invisible-DnBufNPT.js +59 -0
- package/dist/chunks/recaptcha-v3-CF6O8rDj.js +28 -0
- package/dist/chunks/repeater-CB7Yojvx.js +124 -0
- package/dist/chunks/rich-text-nAV_SQZo.js +304 -0
- package/dist/chunks/scripts-BkAAux0i.js +36 -0
- package/dist/chunks/sdk-3SicTWby.js +1559 -0
- package/dist/chunks/shared-DGqeMvcJ.js +80 -0
- package/dist/chunks/signature-BT6CsQ6n.js +550 -0
- package/dist/chunks/snaptcha-C7qQo02f.js +8 -0
- package/dist/chunks/square-C5AH3trb.js +46 -0
- package/dist/chunks/stripe-EJK0RyUv.js +202 -0
- package/dist/chunks/styles-C3aqgtek.js +21 -0
- package/dist/chunks/summary-DC_ipXCU.js +126 -0
- package/dist/chunks/table-BEAI99qo.js +95 -0
- package/dist/chunks/text-limit-Blgq5G-G.js +135 -0
- package/dist/chunks/turnstile-_uCRwnU-.js +59 -0
- package/dist/chunks/utils-BntI3W4S.js +6149 -0
- package/dist/index.js +39 -3205
- package/package.json +5 -5
- package/src/js/modules/fields/file-upload.ts +1 -1
- package/src/js/modules/fields/repeater.ts +1 -1
- package/src/js/modules/fields/rich-text.ts +2 -2
- package/src/js/modules/fields/signature.ts +1 -1
- package/src/js/modules/fields/summary.ts +1 -1
- package/src/js/modules/fields/table.ts +1 -1
- package/src/js/modules/fields/text-limit.ts +1 -1
- package/src/js/modules/payments/paypal.ts +1 -1
- package/src/js/modules/payments/payway.ts +1 -1
- package/src/js/modules/payments/stripe.ts +1 -1
- package/dist/chunks/address-finder-DfMCiW89.js +0 -47
- package/dist/chunks/api-CbqEMQT5.js +0 -181
- package/dist/chunks/api-DE7LfK-R.js +0 -960
- package/dist/chunks/api-DOfDzYC_.js +0 -538
- package/dist/chunks/async-B3DUf1GZ.js +0 -26
- package/dist/chunks/bpoint-Ciy3yY9Q.js +0 -34
- package/dist/chunks/calculations-CkYAqO_-.js +0 -197
- package/dist/chunks/captcha-eu-DnOWhMwr.js +0 -43
- package/dist/chunks/checkbox-radio-0x7Tc0br.js +0 -197
- package/dist/chunks/chunk-K6L4z4UQ.js +0 -24
- package/dist/chunks/conditions-4fXKhEJS.js +0 -609
- package/dist/chunks/date-picker-B6iZkjHS.js +0 -6204
- package/dist/chunks/debug-KnZeKYBI.js +0 -39
- package/dist/chunks/dist-D09GnXMW.js +0 -2663
- package/dist/chunks/event-names-DamGPtXR.js +0 -51
- package/dist/chunks/eway-DEAYcwT0.js +0 -86
- package/dist/chunks/field-references.keys-BpBZ_quS.js +0 -24
- package/dist/chunks/field-references.resolver-Ba6xhiJC.js +0 -183
- package/dist/chunks/file-upload-Bh63PQSE.js +0 -430
- package/dist/chunks/friendly-captcha-v1-CqO4WVre.js +0 -40
- package/dist/chunks/friendly-captcha-v2-CyykcJcM.js +0 -47
- package/dist/chunks/friendly-challenge-Dg8XkStd.js +0 -1101
- package/dist/chunks/go-cardless-CuND59rR.js +0 -26
- package/dist/chunks/google-address--uR8WDSm.js +0 -208
- package/dist/chunks/hcaptcha-CmaFUesv.js +0 -72
- package/dist/chunks/hidden-CYnZYple.js +0 -36
- package/dist/chunks/http-18nn97DZ.js +0 -29
- package/dist/chunks/i18n-vUh-KGiH.js +0 -55
- package/dist/chunks/loqate-BICNJlVK.js +0 -97
- package/dist/chunks/mollie-DwlsgHZ1.js +0 -26
- package/dist/chunks/moneris-B_IFZFTx.js +0 -159
- package/dist/chunks/opayo-U2x_TOII.js +0 -192
- package/dist/chunks/paddle-BqXFrc79.js +0 -75
- package/dist/chunks/paypal-Cn_DYGDb.js +0 -121
- package/dist/chunks/payway-Rnq796eC.js +0 -75
- package/dist/chunks/phone-country-B6Me4lK0.js +0 -3317
- package/dist/chunks/place-kit-ldUl-u9w.js +0 -56
- package/dist/chunks/placekit-autocomplete.esm-D-lGeaZl.js +0 -1771
- package/dist/chunks/recaptcha-enterprise-DPJNyv1X.js +0 -72
- package/dist/chunks/recaptcha-shared-DTI4qWVR.js +0 -22
- package/dist/chunks/recaptcha-v2-checkbox-zFjpvJ5c.js +0 -49
- package/dist/chunks/recaptcha-v2-invisible-CnYtkNvz.js +0 -62
- package/dist/chunks/recaptcha-v3-EAlWhnkX.js +0 -33
- package/dist/chunks/repeater-CXD1eLSn.js +0 -151
- package/dist/chunks/rich-text-DkmZRhGj.js +0 -442
- package/dist/chunks/scripts-BGD_iU_6.js +0 -41
- package/dist/chunks/sdk-B7u9fTlP.js +0 -2103
- package/dist/chunks/shared-DC6_1u8X.js +0 -85
- package/dist/chunks/signature-E9KyYXS1.js +0 -765
- package/dist/chunks/snaptcha-CCDunGeb.js +0 -8
- package/dist/chunks/square-BLqK51rS.js +0 -61
- package/dist/chunks/stripe-B8gHpZNC.js +0 -273
- package/dist/chunks/styles-BIh6g7V_.js +0 -22
- package/dist/chunks/summary-EcNE0cvg.js +0 -191
- package/dist/chunks/table-yxEDL6kA.js +0 -124
- package/dist/chunks/text-limit-D0H_Ca2c.js +0 -179
- package/dist/chunks/theme-classes-vSHpdCUO.js +0 -59
- package/dist/chunks/turnstile-DP0bdR7T.js +0 -68
- package/dist/chunks/utils-ByrEVYrJ.js +0 -49584
|
@@ -0,0 +1,4229 @@
|
|
|
1
|
+
const Pr = [
|
|
2
|
+
{ legacyEvent: "onFormieLoaded", canonicalEvent: "formie:mount:after", disposition: "approximate", target: "document" },
|
|
3
|
+
{ legacyEvent: "onFormieInit", canonicalEvent: "formie:mount:after", disposition: "approximate", target: "document" },
|
|
4
|
+
{ legacyEvent: "onFormieReady", canonicalEvent: "formie:mount:after", disposition: "safe" },
|
|
5
|
+
{ legacyEvent: "onAfterFormieSubmit", canonicalEvent: "formie:submit:result", disposition: "safe" },
|
|
6
|
+
{ legacyEvent: "onFormieSubmitError", canonicalEvent: "formie:submit:result", disposition: "safe" },
|
|
7
|
+
{ legacyEvent: "onFormiePageToggle", canonicalEvent: "formie:page:navigate:after", disposition: "safe" },
|
|
8
|
+
{ legacyEvent: "onBeforeFormieSubmit", canonicalEvent: "formie:submit:before", disposition: "approximate" },
|
|
9
|
+
{ legacyEvent: "onFormieValidate", canonicalEvent: "formie:stage:validate:before", disposition: "approximate" },
|
|
10
|
+
{ legacyEvent: "onAfterFormieValidate", canonicalEvent: "formie:stage:validate:after", disposition: "approximate" },
|
|
11
|
+
{ legacyEvent: "onFormieSubmit", canonicalEvent: "formie:submit:after", disposition: "approximate" }
|
|
12
|
+
], Uo = [
|
|
13
|
+
{ legacyEvent: "formieValidatorInitialized", canonicalEvent: "formie:validator:ready", disposition: "safe" },
|
|
14
|
+
{ legacyEvent: "formieValidatorDestroyed", canonicalEvent: "formie:validator:destroy", disposition: "safe" },
|
|
15
|
+
{ legacyEvent: "formieValidatorShowError", canonicalEvent: "formie:validator:show-error", disposition: "safe" },
|
|
16
|
+
{ legacyEvent: "formieValidatorClearError", canonicalEvent: "formie:validator:clear-error", disposition: "safe" }
|
|
17
|
+
];
|
|
18
|
+
function $r(e) {
|
|
19
|
+
if (!e)
|
|
20
|
+
return {
|
|
21
|
+
enabled: !1,
|
|
22
|
+
legacyDomEvents: !1,
|
|
23
|
+
legacyValidatorEvents: !1
|
|
24
|
+
};
|
|
25
|
+
if (e === !0)
|
|
26
|
+
return {
|
|
27
|
+
enabled: !0,
|
|
28
|
+
legacyDomEvents: !0,
|
|
29
|
+
legacyValidatorEvents: !0
|
|
30
|
+
};
|
|
31
|
+
const t = e.legacyDomEvents ?? !0, r = e.legacyValidatorEvents ?? !0;
|
|
32
|
+
return {
|
|
33
|
+
enabled: t || r,
|
|
34
|
+
legacyDomEvents: t,
|
|
35
|
+
legacyValidatorEvents: r
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const Vr = [
|
|
39
|
+
"formie:mount:after",
|
|
40
|
+
"formie:unmount:before",
|
|
41
|
+
"formie:unmount:after",
|
|
42
|
+
"formie:validator:ready",
|
|
43
|
+
"formie:theme:applied",
|
|
44
|
+
"formie:page:navigate",
|
|
45
|
+
"formie:page:navigate:after",
|
|
46
|
+
"formie:page:navigate:error",
|
|
47
|
+
"formie:submit:before",
|
|
48
|
+
"formie:submit:after",
|
|
49
|
+
"formie:submit:final:before",
|
|
50
|
+
"formie:submit:final:after",
|
|
51
|
+
"formie:submit:result",
|
|
52
|
+
"formie:client-event",
|
|
53
|
+
"formie:refresh-tokens:after",
|
|
54
|
+
"formie:refresh-tokens:refreshed"
|
|
55
|
+
];
|
|
56
|
+
function Ne(e) {
|
|
57
|
+
return e;
|
|
58
|
+
}
|
|
59
|
+
function zo(e) {
|
|
60
|
+
return e;
|
|
61
|
+
}
|
|
62
|
+
function jo(e, t) {
|
|
63
|
+
return `formie:field:${e}:${t}`;
|
|
64
|
+
}
|
|
65
|
+
function pe(e) {
|
|
66
|
+
return `formie:validator:${e}`;
|
|
67
|
+
}
|
|
68
|
+
function Bo(e, t) {
|
|
69
|
+
return `formie:address:${e}:${t}`;
|
|
70
|
+
}
|
|
71
|
+
function Wo(e) {
|
|
72
|
+
return `formie:file-upload:${e}`;
|
|
73
|
+
}
|
|
74
|
+
function Ko(e, t) {
|
|
75
|
+
return `formie:payment:${e}:${t}`;
|
|
76
|
+
}
|
|
77
|
+
function Ue(e) {
|
|
78
|
+
return `formie:state:${e}`;
|
|
79
|
+
}
|
|
80
|
+
function Or(e, t) {
|
|
81
|
+
return `formie:module:${e}:${t}`;
|
|
82
|
+
}
|
|
83
|
+
function Hr(e) {
|
|
84
|
+
return `formie:module:${e}`;
|
|
85
|
+
}
|
|
86
|
+
function _r(e, t, r) {
|
|
87
|
+
e.dispatchEvent(new CustomEvent(t, {
|
|
88
|
+
bubbles: !0,
|
|
89
|
+
detail: r
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
function Dr(e, t) {
|
|
93
|
+
if (e.canonicalEvent !== "formie:submit:result")
|
|
94
|
+
return !0;
|
|
95
|
+
const r = t;
|
|
96
|
+
return e.legacyEvent === "onAfterFormieSubmit" ? !!r?.ok : e.legacyEvent === "onFormieSubmitError" ? r?.ok === !1 : !0;
|
|
97
|
+
}
|
|
98
|
+
function xr(e, t) {
|
|
99
|
+
const r = t && typeof t == "object" ? t : {}, n = typeof r.pageId == "string" ? r.pageId : "", i = Array.from(e.querySelectorAll("[data-formie-page-id]")), o = i.findIndex((a) => a.getAttribute("data-formie-page-id") === n);
|
|
100
|
+
return {
|
|
101
|
+
data: {
|
|
102
|
+
nextPageId: n,
|
|
103
|
+
nextPageIndex: o,
|
|
104
|
+
totalPages: i.length
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function Nr(e, t, r, n, i) {
|
|
109
|
+
const o = globalThis.Formie || i;
|
|
110
|
+
return e.legacyEvent === "onFormieLoaded" ? {
|
|
111
|
+
formie: o
|
|
112
|
+
} : e.legacyEvent === "onFormieInit" ? {
|
|
113
|
+
formie: o,
|
|
114
|
+
form: i,
|
|
115
|
+
$form: n,
|
|
116
|
+
formId: i.id
|
|
117
|
+
} : e.legacyEvent === "onFormieReady" ? {
|
|
118
|
+
...t && typeof t == "object" ? t : {},
|
|
119
|
+
form: n,
|
|
120
|
+
target: r,
|
|
121
|
+
instance: i
|
|
122
|
+
} : e.legacyEvent === "onFormiePageToggle" ? xr(n, t) : t;
|
|
123
|
+
}
|
|
124
|
+
function Ur({
|
|
125
|
+
target: e,
|
|
126
|
+
form: t,
|
|
127
|
+
instance: r,
|
|
128
|
+
options: n,
|
|
129
|
+
unbinds: i
|
|
130
|
+
}) {
|
|
131
|
+
n.legacyDomEvents && Pr.forEach((o) => {
|
|
132
|
+
const a = (s) => {
|
|
133
|
+
if (!(s instanceof CustomEvent) || !Dr(o, s.detail))
|
|
134
|
+
return;
|
|
135
|
+
const l = o.target === "document" ? document : t;
|
|
136
|
+
_r(l, o.legacyEvent, Nr(o, s.detail, e, t, r));
|
|
137
|
+
};
|
|
138
|
+
e.addEventListener(Ne(o.canonicalEvent), a), i.push(() => {
|
|
139
|
+
e.removeEventListener(Ne(o.canonicalEvent), a);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function ge(e, t, r) {
|
|
144
|
+
e.dispatchEvent(new CustomEvent(t, {
|
|
145
|
+
bubbles: !0,
|
|
146
|
+
detail: r
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
function $e(e, t) {
|
|
150
|
+
return !!e && typeof e == "object" && e.validator === t;
|
|
151
|
+
}
|
|
152
|
+
function zr({
|
|
153
|
+
target: e,
|
|
154
|
+
form: t,
|
|
155
|
+
validatorDetail: r,
|
|
156
|
+
options: n,
|
|
157
|
+
unbinds: i
|
|
158
|
+
}) {
|
|
159
|
+
if (!n.legacyValidatorEvents || !r)
|
|
160
|
+
return;
|
|
161
|
+
const { validator: o, addValidator: a, removeValidator: s } = r, l = {
|
|
162
|
+
...r,
|
|
163
|
+
form: t,
|
|
164
|
+
target: e
|
|
165
|
+
};
|
|
166
|
+
ge(document, "formieValidatorInitialized", l);
|
|
167
|
+
const d = (c) => {
|
|
168
|
+
!(c instanceof CustomEvent) || !$e(c.detail, o) || ge(document, "formieValidatorDestroyed", {
|
|
169
|
+
...l,
|
|
170
|
+
...c.detail
|
|
171
|
+
});
|
|
172
|
+
}, p = (c) => {
|
|
173
|
+
!(c instanceof CustomEvent) || !$e(c.detail, o) || !(c.target instanceof Element) || t.contains(c.target) && ge(c.target, "formieValidatorShowError", {
|
|
174
|
+
...c.detail,
|
|
175
|
+
addValidator: a,
|
|
176
|
+
removeValidator: s,
|
|
177
|
+
form: t,
|
|
178
|
+
target: e
|
|
179
|
+
});
|
|
180
|
+
}, y = (c) => {
|
|
181
|
+
!(c instanceof CustomEvent) || !$e(c.detail, o) || !(c.target instanceof Element) || t.contains(c.target) && ge(c.target, "formieValidatorClearError", {
|
|
182
|
+
...c.detail,
|
|
183
|
+
addValidator: a,
|
|
184
|
+
removeValidator: s,
|
|
185
|
+
form: t,
|
|
186
|
+
target: e
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
document.addEventListener("formie:validator:destroy", d), document.addEventListener("formie:validator:show-error", p), document.addEventListener("formie:validator:clear-error", y), i.push(() => {
|
|
190
|
+
document.removeEventListener("formie:validator:destroy", d), document.removeEventListener("formie:validator:show-error", p), document.removeEventListener("formie:validator:clear-error", y);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
function I(e, t, r) {
|
|
194
|
+
e.dispatchEvent(new CustomEvent(Ne(t), {
|
|
195
|
+
bubbles: !0,
|
|
196
|
+
detail: r
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
function Ut() {
|
|
200
|
+
return globalThis;
|
|
201
|
+
}
|
|
202
|
+
function zt() {
|
|
203
|
+
return Ut().__FORMIE_DEBUG__ === !0;
|
|
204
|
+
}
|
|
205
|
+
function Go(e) {
|
|
206
|
+
Ut().__FORMIE_DEBUG__ = e;
|
|
207
|
+
}
|
|
208
|
+
function jr(e, t, r) {
|
|
209
|
+
if (zt()) {
|
|
210
|
+
if (typeof r > "u") {
|
|
211
|
+
console.log(`[formie:${e}] ${t}`);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
console.log(`[formie:${e}] ${t}`, r);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function Br(e, t, r) {
|
|
218
|
+
if (zt()) {
|
|
219
|
+
if (typeof r > "u") {
|
|
220
|
+
console.warn(`[formie:${e}] ${t}`);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
console.warn(`[formie:${e}] ${t}`, r);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function _(e, t) {
|
|
227
|
+
const r = t ? `${e}:${t}` : e;
|
|
228
|
+
return {
|
|
229
|
+
log: (n, i) => {
|
|
230
|
+
jr(r, n, i);
|
|
231
|
+
},
|
|
232
|
+
warn: (n, i) => {
|
|
233
|
+
Br(r, n, i);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const ve = _("general", "page-client-event"), Wr = "data-formie-client-event";
|
|
238
|
+
function Kr(e) {
|
|
239
|
+
return typeof window < "u" && window.CSS?.escape ? window.CSS.escape(e) : e.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
240
|
+
}
|
|
241
|
+
function Gr(e) {
|
|
242
|
+
const r = e.querySelector('input[name="pageId"]')?.value?.trim();
|
|
243
|
+
if (r)
|
|
244
|
+
return r;
|
|
245
|
+
const i = e.querySelector("[data-formie-page]:not([data-formie-page-hidden])")?.getAttribute("data-formie-page-id")?.trim();
|
|
246
|
+
return i || e.querySelector("[data-formie-page]")?.getAttribute("data-formie-page-id")?.trim() || null;
|
|
247
|
+
}
|
|
248
|
+
function Jr(e) {
|
|
249
|
+
if (!e?.trim())
|
|
250
|
+
return null;
|
|
251
|
+
try {
|
|
252
|
+
const t = JSON.parse(e);
|
|
253
|
+
return t && typeof t == "object" ? t : null;
|
|
254
|
+
} catch {
|
|
255
|
+
return ve.warn("Invalid data-formie-client-event JSON.", {
|
|
256
|
+
rawPreview: e.slice(0, 80)
|
|
257
|
+
}), null;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function Yr(e) {
|
|
261
|
+
const t = {};
|
|
262
|
+
return e.forEach((r) => {
|
|
263
|
+
const n = typeof r.label == "string" ? r.label.trim() : "";
|
|
264
|
+
n && (t[n] = typeof r.value == "string" ? r.value : "");
|
|
265
|
+
}), t;
|
|
266
|
+
}
|
|
267
|
+
function jt(e, t) {
|
|
268
|
+
if (t !== "submit")
|
|
269
|
+
return;
|
|
270
|
+
const r = Gr(e);
|
|
271
|
+
if (!r) {
|
|
272
|
+
ve.log("No submitted page id; skipping client event.");
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const n = e.querySelector(
|
|
276
|
+
`[data-formie-page][data-formie-page-id="${Kr(r)}"]`
|
|
277
|
+
);
|
|
278
|
+
if (!n) {
|
|
279
|
+
ve.log("No page section for id; skipping client event.", { pageId: r });
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const i = n.getAttribute(Wr);
|
|
283
|
+
if (i === null)
|
|
284
|
+
return;
|
|
285
|
+
const o = Jr(i);
|
|
286
|
+
if (!o || !Array.isArray(o.fields))
|
|
287
|
+
return;
|
|
288
|
+
const a = Yr(o.fields), s = window;
|
|
289
|
+
s.dataLayer = s.dataLayer || [], s.dataLayer.push(a), e.dispatchEvent(new CustomEvent("formie:client-event", {
|
|
290
|
+
bubbles: !0,
|
|
291
|
+
detail: { payload: a }
|
|
292
|
+
})), ve.log("Dispatched page client event.", {
|
|
293
|
+
pageId: r,
|
|
294
|
+
keys: Object.keys(a)
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
const Ae = /* @__PURE__ */ new WeakMap(), Zr = "[data-formie-form], [data-formie], form";
|
|
298
|
+
function Qr(e) {
|
|
299
|
+
return e ? (Array.isArray(e) ? e : [e]).flatMap((r) => String(r).split(/\s+/)).map((r) => r.trim()).filter(Boolean) : [];
|
|
300
|
+
}
|
|
301
|
+
function Xe(e) {
|
|
302
|
+
return Array.from(new Set(e));
|
|
303
|
+
}
|
|
304
|
+
function Xr(e) {
|
|
305
|
+
if (!e)
|
|
306
|
+
return {};
|
|
307
|
+
const t = Ae.get(e);
|
|
308
|
+
if (t)
|
|
309
|
+
return t;
|
|
310
|
+
const r = e.closest(Zr);
|
|
311
|
+
return r ? Ae.get(r) || {} : {};
|
|
312
|
+
}
|
|
313
|
+
function en(e) {
|
|
314
|
+
const t = {};
|
|
315
|
+
return Object.entries(e || {}).forEach(([r, n]) => {
|
|
316
|
+
const i = Xe(Qr(n));
|
|
317
|
+
i.length && (t[r] = i);
|
|
318
|
+
}), t;
|
|
319
|
+
}
|
|
320
|
+
function gt(e, t, r) {
|
|
321
|
+
const n = en(t), i = r || (e instanceof HTMLFormElement ? e : e.querySelector("form"));
|
|
322
|
+
return Ae.set(e, n), i && Ae.set(i, n), n;
|
|
323
|
+
}
|
|
324
|
+
function et(e, t) {
|
|
325
|
+
return Xr(e)[t] || [];
|
|
326
|
+
}
|
|
327
|
+
function V(e, t, ...r) {
|
|
328
|
+
const n = Xe(r.flatMap((i) => et(t, i)));
|
|
329
|
+
n.length && e.classList.add(...n);
|
|
330
|
+
}
|
|
331
|
+
function le(e, t, ...r) {
|
|
332
|
+
const n = Xe(r.flatMap((i) => et(t, i)));
|
|
333
|
+
n.length && e.classList.remove(...n);
|
|
334
|
+
}
|
|
335
|
+
function ue(e, t, r, n) {
|
|
336
|
+
et(t, r).forEach((i) => {
|
|
337
|
+
e.classList.toggle(i, n);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
function tn(e, t) {
|
|
341
|
+
if (ue(e, e, "tabError", t), t) {
|
|
342
|
+
e.setAttribute("data-formie-tab-error", "true");
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
e.removeAttribute("data-formie-tab-error");
|
|
346
|
+
}
|
|
347
|
+
function J(e) {
|
|
348
|
+
const t = /* @__PURE__ */ new Set();
|
|
349
|
+
e.querySelectorAll("[data-formie-page]").forEach((r) => {
|
|
350
|
+
const n = r, i = n.getAttribute("data-formie-page-id");
|
|
351
|
+
i && n.querySelector("[data-formie-field-has-error]") && t.add(i);
|
|
352
|
+
}), e.querySelectorAll("[data-formie-tab]").forEach((r) => {
|
|
353
|
+
const n = r, i = n.getAttribute("data-formie-page-id");
|
|
354
|
+
tn(n, !!i && t.has(i));
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
class Bt {
|
|
358
|
+
constructor() {
|
|
359
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
360
|
+
}
|
|
361
|
+
on(t, r) {
|
|
362
|
+
return this.listeners.has(t) || this.listeners.set(t, /* @__PURE__ */ new Set()), this.listeners.get(t)?.add(r), () => {
|
|
363
|
+
this.listeners.get(t)?.delete(r);
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
async emit(t, r) {
|
|
367
|
+
const n = this.listeners.get(t);
|
|
368
|
+
if (!(!n || n.size === 0))
|
|
369
|
+
for (const i of n)
|
|
370
|
+
await i(r);
|
|
371
|
+
}
|
|
372
|
+
async emitSafe(t, r) {
|
|
373
|
+
const n = this.listeners.get(t), i = {
|
|
374
|
+
eventName: t,
|
|
375
|
+
total: n?.size || 0,
|
|
376
|
+
succeeded: 0,
|
|
377
|
+
failed: []
|
|
378
|
+
};
|
|
379
|
+
if (!n || n.size === 0)
|
|
380
|
+
return i;
|
|
381
|
+
let o = 0;
|
|
382
|
+
for (const a of n) {
|
|
383
|
+
try {
|
|
384
|
+
await a(r), i.succeeded += 1;
|
|
385
|
+
} catch (s) {
|
|
386
|
+
i.failed.push({
|
|
387
|
+
index: o,
|
|
388
|
+
error: s
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
o += 1;
|
|
392
|
+
}
|
|
393
|
+
return i;
|
|
394
|
+
}
|
|
395
|
+
async emitParallelSafe(t, r) {
|
|
396
|
+
const n = this.listeners.get(t), i = {
|
|
397
|
+
eventName: t,
|
|
398
|
+
total: n?.size || 0,
|
|
399
|
+
succeeded: 0,
|
|
400
|
+
failed: []
|
|
401
|
+
};
|
|
402
|
+
return !n || n.size === 0 || (await Promise.allSettled(Array.from(n).map(async (a) => a(r)))).forEach((a, s) => {
|
|
403
|
+
if (a.status === "fulfilled") {
|
|
404
|
+
i.succeeded += 1;
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
i.failed.push({
|
|
408
|
+
index: s,
|
|
409
|
+
error: a.reason
|
|
410
|
+
});
|
|
411
|
+
}), i;
|
|
412
|
+
}
|
|
413
|
+
clear() {
|
|
414
|
+
this.listeners.clear();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
async function Wt(e, t = {}) {
|
|
418
|
+
const r = {
|
|
419
|
+
Accept: "application/json",
|
|
420
|
+
...t.headers || {}
|
|
421
|
+
};
|
|
422
|
+
return delete r["X-Requested-With"], delete r["x-requested-with"], fetch(String(e), {
|
|
423
|
+
method: t.method || "GET",
|
|
424
|
+
body: t.body ?? null,
|
|
425
|
+
signal: t.signal,
|
|
426
|
+
// Avoid sending `Cache-Control`: not CORS-safelisted; use fetch cache mode instead.
|
|
427
|
+
cache: "no-store",
|
|
428
|
+
headers: r,
|
|
429
|
+
// `include` + `Access-Control-Allow-Origin: *` is invalid; many Craft GraphQL setups use `*`.
|
|
430
|
+
// `same-origin` keeps cookies for same-host deployments and avoids credentialed cross-origin
|
|
431
|
+
// fetches (e.g. Vite on localhost → ddev HTTPS) so wildcard CORS can succeed.
|
|
432
|
+
credentials: "same-origin"
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
async function Ie(e, t = {}) {
|
|
436
|
+
const r = await Wt(e, t);
|
|
437
|
+
if (!r.ok)
|
|
438
|
+
throw new Error(`Request failed (${r.status}) for ${String(e)}`);
|
|
439
|
+
return r.json();
|
|
440
|
+
}
|
|
441
|
+
async function Jo(e, t = {}) {
|
|
442
|
+
const r = await Wt(e, t);
|
|
443
|
+
if (!r.ok)
|
|
444
|
+
throw new Error(`Request failed (${r.status}) for ${String(e)}`);
|
|
445
|
+
return r.text();
|
|
446
|
+
}
|
|
447
|
+
const H = _("general", "transport");
|
|
448
|
+
function rn(e) {
|
|
449
|
+
const t = {};
|
|
450
|
+
return ["theme", "themeConfig", "locale", "siteId"].forEach((r) => {
|
|
451
|
+
e[r] !== void 0 && (t[r] = e[r]);
|
|
452
|
+
}), t;
|
|
453
|
+
}
|
|
454
|
+
function Kt(e, t = "", r = {}) {
|
|
455
|
+
if (Array.isArray(e)) {
|
|
456
|
+
const n = e.map((i) => typeof i == "string" ? i : String(i ?? "")).filter((i) => i.trim() !== "");
|
|
457
|
+
return t && n.length && (r[t] = (r[t] || []).concat(n)), r;
|
|
458
|
+
}
|
|
459
|
+
return e && typeof e == "object" && Object.entries(e).forEach(([n, i]) => {
|
|
460
|
+
const o = t ? `${t}.${n}` : n;
|
|
461
|
+
Kt(i, o, r);
|
|
462
|
+
}), r;
|
|
463
|
+
}
|
|
464
|
+
function nn(e, t) {
|
|
465
|
+
const r = e.success === !0, n = e.keepSubmitLoading === !0, i = e.errors, o = Kt(i || {}), a = o.form || [], s = {};
|
|
466
|
+
Object.entries(o).forEach(([y, c]) => {
|
|
467
|
+
if (y === "form")
|
|
468
|
+
return;
|
|
469
|
+
const u = y.split(".")[0];
|
|
470
|
+
s[u] = (s[u] || []).concat(c);
|
|
471
|
+
});
|
|
472
|
+
const l = !r && a.length === 0 && Object.keys(s).length > 0 ? [t || "Submission failed."] : a, d = !r && n && l.length === 0 && Object.keys(s).length === 0;
|
|
473
|
+
return {
|
|
474
|
+
ok: r,
|
|
475
|
+
action: e.submitAction === "back" || e.submitAction === "save" || e.submitAction === "submit" ? e.submitAction : void 0,
|
|
476
|
+
message: e.submitActionMessage || (r ? "Submission completed." : d ? "" : l[0] || "Submission failed."),
|
|
477
|
+
code: r ? void 0 : String(e.code || "SUBMIT_ERROR"),
|
|
478
|
+
keepSubmitLoading: n,
|
|
479
|
+
fieldErrors: Object.keys(s).length ? s : void 0,
|
|
480
|
+
formErrors: l.length ? l : void 0,
|
|
481
|
+
nextPage: e.nextPageId ? {
|
|
482
|
+
id: String(e.nextPageId)
|
|
483
|
+
} : null,
|
|
484
|
+
redirect: e.redirectUrl ? {
|
|
485
|
+
url: String(e.redirectUrl),
|
|
486
|
+
target: e.submitActionTab === "new-tab" ? "new-tab" : "same-tab"
|
|
487
|
+
} : null,
|
|
488
|
+
submitData: Array.isArray(e.submitData) ? e.submitData : void 0,
|
|
489
|
+
meta: e
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
async function on(e, t, r = {}) {
|
|
493
|
+
const n = JSON.stringify({
|
|
494
|
+
handle: t,
|
|
495
|
+
renderOptions: r
|
|
496
|
+
});
|
|
497
|
+
H.log("requestRender start.", { endpoint: e, handle: t });
|
|
498
|
+
const i = await Ie(e, {
|
|
499
|
+
method: "POST",
|
|
500
|
+
body: n,
|
|
501
|
+
headers: {
|
|
502
|
+
"Content-Type": "application/json"
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
return H.log("requestRender complete.", {
|
|
506
|
+
hasHtml: !!i.html
|
|
507
|
+
}), i;
|
|
508
|
+
}
|
|
509
|
+
async function an(e, t, r = {}) {
|
|
510
|
+
const i = JSON.stringify({
|
|
511
|
+
query: `
|
|
512
|
+
query FormieHtmlForm($handle: String!, $input: ServerRenderPayloadInput) {
|
|
513
|
+
formieHtmlForm(handle: $handle, input: $input) {
|
|
514
|
+
html
|
|
515
|
+
}
|
|
516
|
+
}`,
|
|
517
|
+
variables: {
|
|
518
|
+
handle: t,
|
|
519
|
+
input: rn(r)
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
H.log("requestGraphqlRender start.", { endpoint: e, handle: t });
|
|
523
|
+
const o = await Ie(e, {
|
|
524
|
+
method: "POST",
|
|
525
|
+
body: i,
|
|
526
|
+
headers: {
|
|
527
|
+
"Content-Type": "application/json"
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
if (Array.isArray(o.errors) && o.errors.length > 0)
|
|
531
|
+
throw new Error(o.errors.map((s) => s.message || "Unknown GraphQL error").join("; "));
|
|
532
|
+
if (!o.data?.formieHtmlForm)
|
|
533
|
+
throw new Error(`Form not found for handle "${t}".`);
|
|
534
|
+
const a = o.data.formieHtmlForm;
|
|
535
|
+
return H.log("requestGraphqlRender complete.", {
|
|
536
|
+
hasHtml: !!a.html
|
|
537
|
+
}), a;
|
|
538
|
+
}
|
|
539
|
+
async function tt(e, t, r) {
|
|
540
|
+
const n = new URL(e, window.location.origin);
|
|
541
|
+
n.searchParams.set("handle", t), r && n.searchParams.set("renderId", r), H.log("requestRefreshTokens start.", {
|
|
542
|
+
endpoint: n.toString(),
|
|
543
|
+
handle: t,
|
|
544
|
+
hasRenderId: !!r
|
|
545
|
+
});
|
|
546
|
+
const i = await Ie(n.toString());
|
|
547
|
+
return H.log("requestRefreshTokens complete.", {
|
|
548
|
+
hasRefreshTokens: !!i.refreshTokens
|
|
549
|
+
}), i.refreshTokens || i;
|
|
550
|
+
}
|
|
551
|
+
async function sn(e, t, r) {
|
|
552
|
+
const n = new URL(e, window.location.origin), i = new FormData();
|
|
553
|
+
if (r && i.append("pageId", r), t) {
|
|
554
|
+
["handle", "renderId", "draftContextToken", "draftContext", "continuationToken"].forEach((d) => {
|
|
555
|
+
const y = t.querySelector(`input[name="${d}"]`)?.value?.trim();
|
|
556
|
+
y && i.append(d, y);
|
|
557
|
+
});
|
|
558
|
+
const l = t.querySelector('input[name="CRAFT_CSRF_TOKEN"]')?.value?.trim();
|
|
559
|
+
l && i.append("CRAFT_CSRF_TOKEN", l);
|
|
560
|
+
}
|
|
561
|
+
H.log("requestSetPage start.", {
|
|
562
|
+
requestUrl: n.toString(),
|
|
563
|
+
pageId: r || null
|
|
564
|
+
});
|
|
565
|
+
const o = await Ie(n.toString(), {
|
|
566
|
+
method: "POST",
|
|
567
|
+
body: i
|
|
568
|
+
});
|
|
569
|
+
return H.log("requestSetPage complete.", o), o;
|
|
570
|
+
}
|
|
571
|
+
function ln(e, t) {
|
|
572
|
+
const r = new URL(e, window.location.origin), n = new FormData();
|
|
573
|
+
["handle", "renderId", "draftContextToken", "draftContext"].forEach((s) => {
|
|
574
|
+
const d = t.querySelector(`input[name="${s}"]`)?.value?.trim();
|
|
575
|
+
d && n.append(s, d);
|
|
576
|
+
});
|
|
577
|
+
const a = t.querySelector('input[name="CRAFT_CSRF_TOKEN"]')?.value?.trim();
|
|
578
|
+
a && n.append("CRAFT_CSRF_TOKEN", a), H.log("clearSubmissionOnUnload start.", {
|
|
579
|
+
requestUrl: r.toString()
|
|
580
|
+
});
|
|
581
|
+
try {
|
|
582
|
+
if (typeof navigator.sendBeacon == "function" && navigator.sendBeacon(r.toString(), n))
|
|
583
|
+
return;
|
|
584
|
+
} catch {
|
|
585
|
+
}
|
|
586
|
+
fetch(r.toString(), {
|
|
587
|
+
method: "POST",
|
|
588
|
+
body: n,
|
|
589
|
+
credentials: "include",
|
|
590
|
+
keepalive: !0,
|
|
591
|
+
headers: {
|
|
592
|
+
Accept: "application/json"
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
async function un(e, t) {
|
|
597
|
+
const r = (e.getAttribute("method") || "POST").toUpperCase(), n = e.getAttribute("action") || window.location.href, i = e.dataset.formieErrorMessage?.trim() || "Submission failed.";
|
|
598
|
+
H.log("submitForm start.", {
|
|
599
|
+
method: r,
|
|
600
|
+
action: n,
|
|
601
|
+
submitAction: t.get("submitAction")
|
|
602
|
+
});
|
|
603
|
+
const o = await fetch(n, {
|
|
604
|
+
method: r,
|
|
605
|
+
body: t,
|
|
606
|
+
credentials: "include",
|
|
607
|
+
headers: {
|
|
608
|
+
Accept: "application/json"
|
|
609
|
+
}
|
|
610
|
+
}), a = o.headers.get("content-type") || "";
|
|
611
|
+
if (!a.includes("application/json"))
|
|
612
|
+
return o.ok ? (H.log("submitForm non-JSON success response.", {
|
|
613
|
+
status: o.status,
|
|
614
|
+
contentType: a
|
|
615
|
+
}), {
|
|
616
|
+
ok: !0,
|
|
617
|
+
message: "Submission completed."
|
|
618
|
+
}) : (H.warn("submitForm non-JSON HTTP error.", {
|
|
619
|
+
status: o.status,
|
|
620
|
+
contentType: a
|
|
621
|
+
}), {
|
|
622
|
+
ok: !1,
|
|
623
|
+
code: "HTTP_ERROR",
|
|
624
|
+
message: `Request failed (${o.status}).`,
|
|
625
|
+
formErrors: [`Request failed (${o.status}).`]
|
|
626
|
+
});
|
|
627
|
+
const s = await o.json(), l = nn(s, i);
|
|
628
|
+
return H.log("submitForm JSON response normalized.", {
|
|
629
|
+
ok: l.ok,
|
|
630
|
+
code: l.code,
|
|
631
|
+
hasRedirect: !!l.redirect?.url,
|
|
632
|
+
hasSubmitData: Array.isArray(l.submitData) && l.submitData.length > 0
|
|
633
|
+
}), l;
|
|
634
|
+
}
|
|
635
|
+
const cn = ["prepare", "normalize", "validate", "screen", "authorize", "dispatch", "finalize"], dn = ["prepare", "normalize", "validate", "screen", "authorize"], R = _("general", "pipeline");
|
|
636
|
+
function Ve(e, t) {
|
|
637
|
+
return {
|
|
638
|
+
ok: !1,
|
|
639
|
+
stage: e,
|
|
640
|
+
code: "ABORTED",
|
|
641
|
+
message: t || "Submission aborted.",
|
|
642
|
+
formErrors: [t || "Submission aborted."]
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
function rt(e) {
|
|
646
|
+
return Array.from(e.querySelectorAll("[data-formie-page]"));
|
|
647
|
+
}
|
|
648
|
+
function fn(e) {
|
|
649
|
+
const t = rt(e);
|
|
650
|
+
if (!t.length)
|
|
651
|
+
return {
|
|
652
|
+
scope: e,
|
|
653
|
+
final: !0
|
|
654
|
+
};
|
|
655
|
+
const r = t.find((n) => !n.hasAttribute("data-formie-page-hidden")) || t[t.length - 1];
|
|
656
|
+
return {
|
|
657
|
+
scope: r,
|
|
658
|
+
final: r === t[t.length - 1]
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
function Gt(e) {
|
|
662
|
+
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
663
|
+
}
|
|
664
|
+
function Jt(e) {
|
|
665
|
+
return !(!e.name || e.disabled || e instanceof HTMLInputElement && (e.type === "submit" || e.type === "button" || e.type === "reset" || e.type === "image" || (e.type === "checkbox" || e.type === "radio") && !e.checked || e.type === "file" && (!e.files || e.files.length === 0)));
|
|
666
|
+
}
|
|
667
|
+
function Yt(e, t) {
|
|
668
|
+
if (t instanceof HTMLInputElement) {
|
|
669
|
+
if (t.type === "file") {
|
|
670
|
+
Array.from(t.files || []).forEach((r) => {
|
|
671
|
+
e.append(t.name, r);
|
|
672
|
+
});
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
e.append(t.name, t.value);
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
if (t instanceof HTMLSelectElement && t.multiple) {
|
|
679
|
+
Array.from(t.selectedOptions).forEach((r) => {
|
|
680
|
+
e.append(t.name, r.value);
|
|
681
|
+
});
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
e.append(t.name, t.value);
|
|
685
|
+
}
|
|
686
|
+
function mn(e, t) {
|
|
687
|
+
t.querySelectorAll("input, select, textarea").forEach((r) => {
|
|
688
|
+
const n = Gt(r) ? r : null;
|
|
689
|
+
!n || n.closest("[data-formie-page]") || Jt(n) && Yt(e, n);
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
function pn(e, t) {
|
|
693
|
+
const r = /* @__PURE__ */ new Set();
|
|
694
|
+
return t.querySelectorAll("input, select, textarea").forEach((n) => {
|
|
695
|
+
const i = Gt(n) ? n : null;
|
|
696
|
+
!i || !i.name || i.disabled || i instanceof HTMLInputElement && (i.type === "submit" || i.type === "button" || i.type === "reset" || i.type === "image") || (i.name.startsWith("fields[") && r.add(i.name), Jt(i) && Yt(e, i));
|
|
697
|
+
}), r;
|
|
698
|
+
}
|
|
699
|
+
function gn(e, t) {
|
|
700
|
+
t.forEach((r) => {
|
|
701
|
+
e.has(r) || e.append(r, "");
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
function ht(e, t) {
|
|
705
|
+
const r = rt(e), n = r.find((a) => !a.hasAttribute("data-formie-page-hidden")) || null;
|
|
706
|
+
if (!r.length || !n) {
|
|
707
|
+
const a = new FormData(e);
|
|
708
|
+
return a.set("submitAction", t), a;
|
|
709
|
+
}
|
|
710
|
+
const i = new FormData();
|
|
711
|
+
mn(i, e);
|
|
712
|
+
const o = pn(i, n);
|
|
713
|
+
return gn(i, o), i.set("submitAction", t), i;
|
|
714
|
+
}
|
|
715
|
+
function hn(e, t) {
|
|
716
|
+
if (t !== "submit")
|
|
717
|
+
return !1;
|
|
718
|
+
const r = rt(e);
|
|
719
|
+
return r.length ? (r.find((i) => !i.hasAttribute("data-formie-page-hidden")) || r[r.length - 1]) === r[r.length - 1] : !0;
|
|
720
|
+
}
|
|
721
|
+
async function Zt(e, t, r, n = {}) {
|
|
722
|
+
R.log("Starting submit pipeline.", {
|
|
723
|
+
action: t,
|
|
724
|
+
preflightOnly: n.preflightOnly === !0
|
|
725
|
+
});
|
|
726
|
+
let i = !1, o, a = null;
|
|
727
|
+
const s = hn(e, t), l = {
|
|
728
|
+
form: e,
|
|
729
|
+
action: t,
|
|
730
|
+
formData: ht(e, t),
|
|
731
|
+
abort: (c) => {
|
|
732
|
+
i = !0, o = c, R.warn("Pipeline aborted.", { reason: c });
|
|
733
|
+
},
|
|
734
|
+
isAborted: () => i,
|
|
735
|
+
abortReason: () => o
|
|
736
|
+
}, d = {
|
|
737
|
+
prepare: async (c) => {
|
|
738
|
+
const u = c.form.querySelector('input[name="submitAction"]');
|
|
739
|
+
return u && (u.value = c.action), c.formData.set("submitAction", c.action), null;
|
|
740
|
+
},
|
|
741
|
+
normalize: async () => null,
|
|
742
|
+
validate: async (c) => {
|
|
743
|
+
if (c.action !== "submit" || n.validateOnSubmit === !1)
|
|
744
|
+
return null;
|
|
745
|
+
if (n.validator) {
|
|
746
|
+
const { scope: u, final: h } = fn(c.form), A = n.validator.submit(h ? c.form : u, { final: h });
|
|
747
|
+
return A.length > 0 ? (A[0]?.input.focus(), {
|
|
748
|
+
ok: !1,
|
|
749
|
+
stage: "validate",
|
|
750
|
+
code: "VALIDATION_FAILED",
|
|
751
|
+
message: n.validator.config.errorMessage || "Validation failed.",
|
|
752
|
+
fieldErrors: n.validator.getFieldErrors(A),
|
|
753
|
+
formErrors: [n.validator.config.errorMessage || "Validation failed."]
|
|
754
|
+
}) : null;
|
|
755
|
+
}
|
|
756
|
+
return c.form.checkValidity() ? null : (c.form.querySelector(":invalid")?.focus(), {
|
|
757
|
+
ok: !1,
|
|
758
|
+
stage: "validate",
|
|
759
|
+
code: "VALIDATION_FAILED",
|
|
760
|
+
message: "Validation failed.",
|
|
761
|
+
formErrors: ["Validation failed."]
|
|
762
|
+
});
|
|
763
|
+
},
|
|
764
|
+
screen: async () => null,
|
|
765
|
+
authorize: async () => null,
|
|
766
|
+
dispatch: async (c) => {
|
|
767
|
+
c.formData = ht(c.form, c.action);
|
|
768
|
+
const u = await un(c.form, c.formData);
|
|
769
|
+
return a = u, u;
|
|
770
|
+
},
|
|
771
|
+
finalize: async (c) => (a && a.ok && a.redirect?.url && (a.redirect.target === "new-tab" ? window.open(a.redirect.url, "_blank") : window.location.href = a.redirect.url), null)
|
|
772
|
+
};
|
|
773
|
+
{
|
|
774
|
+
const c = await r.emitSafe("formie:submit:before", l);
|
|
775
|
+
c.failed.length > 0 && R.warn("Submit before listeners failed.", {
|
|
776
|
+
eventName: c.eventName,
|
|
777
|
+
failed: c.failed.length
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
if (s) {
|
|
781
|
+
const c = await r.emitSafe("formie:submit:final:before", l);
|
|
782
|
+
c.failed.length > 0 && R.warn("Final submit before listeners failed.", {
|
|
783
|
+
eventName: c.eventName,
|
|
784
|
+
failed: c.failed.length
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
const p = n.preflightOnly ? dn : cn;
|
|
788
|
+
for (const c of p) {
|
|
789
|
+
if (R.log("Stage start.", { stage: c, action: t }), i)
|
|
790
|
+
return R.warn("Stage skipped due to abort.", { stage: c, reason: o }), Ve(c, o);
|
|
791
|
+
{
|
|
792
|
+
const h = await r.emitSafe(`formie:stage:${c}:before`, {
|
|
793
|
+
...l,
|
|
794
|
+
stage: c
|
|
795
|
+
});
|
|
796
|
+
h.failed.length > 0 && R.warn("Stage before listeners failed.", {
|
|
797
|
+
stage: c,
|
|
798
|
+
failed: h.failed.length
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
if (i) {
|
|
802
|
+
const h = Ve(c, o);
|
|
803
|
+
{
|
|
804
|
+
const A = await r.emitSafe("formie:submit:after", h);
|
|
805
|
+
A.failed.length > 0 && R.warn("Submit after listeners failed (abort before stage).", {
|
|
806
|
+
stage: c,
|
|
807
|
+
failed: A.failed.length
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
if (s) {
|
|
811
|
+
const A = await r.emitSafe("formie:submit:final:after", h);
|
|
812
|
+
A.failed.length > 0 && R.warn("Final submit after listeners failed (abort before stage).", {
|
|
813
|
+
stage: c,
|
|
814
|
+
failed: A.failed.length
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
return R.warn("Aborted after stage before-hooks.", { stage: c, reason: o }), h;
|
|
818
|
+
}
|
|
819
|
+
const u = await d[c](l);
|
|
820
|
+
R.log("Stage runner complete.", {
|
|
821
|
+
stage: c,
|
|
822
|
+
hasResult: !!u,
|
|
823
|
+
ok: u ? u.ok : void 0,
|
|
824
|
+
code: u?.code
|
|
825
|
+
});
|
|
826
|
+
{
|
|
827
|
+
const h = await r.emitSafe(`formie:stage:${c}:after`, {
|
|
828
|
+
...l,
|
|
829
|
+
stage: c,
|
|
830
|
+
result: u
|
|
831
|
+
});
|
|
832
|
+
h.failed.length > 0 && R.warn("Stage after listeners failed.", {
|
|
833
|
+
stage: c,
|
|
834
|
+
failed: h.failed.length
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
if (i) {
|
|
838
|
+
const h = Ve(c, o);
|
|
839
|
+
{
|
|
840
|
+
const A = await r.emitSafe("formie:submit:after", h);
|
|
841
|
+
A.failed.length > 0 && R.warn("Submit after listeners failed (abort after stage).", {
|
|
842
|
+
stage: c,
|
|
843
|
+
failed: A.failed.length
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
if (s) {
|
|
847
|
+
const A = await r.emitSafe("formie:submit:final:after", h);
|
|
848
|
+
A.failed.length > 0 && R.warn("Final submit after listeners failed (abort after stage).", {
|
|
849
|
+
stage: c,
|
|
850
|
+
failed: A.failed.length
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
return R.warn("Aborted after stage after-hooks.", { stage: c, reason: o }), h;
|
|
854
|
+
}
|
|
855
|
+
if (u && !u.ok) {
|
|
856
|
+
{
|
|
857
|
+
const h = await r.emitSafe("formie:submit:after", u);
|
|
858
|
+
h.failed.length > 0 && R.warn("Submit after listeners failed (failed stage).", {
|
|
859
|
+
stage: c,
|
|
860
|
+
failed: h.failed.length
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
if (s) {
|
|
864
|
+
const h = await r.emitSafe("formie:submit:final:after", u);
|
|
865
|
+
h.failed.length > 0 && R.warn("Final submit after listeners failed (failed stage).", {
|
|
866
|
+
stage: c,
|
|
867
|
+
failed: h.failed.length
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
return R.warn("Pipeline short-circuited by failed stage.", {
|
|
871
|
+
stage: c,
|
|
872
|
+
code: u.code,
|
|
873
|
+
message: u.message
|
|
874
|
+
}), u;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
const y = a || {
|
|
878
|
+
ok: !0,
|
|
879
|
+
stage: n.preflightOnly ? "authorize" : "finalize",
|
|
880
|
+
message: n.preflightOnly ? "Submission preflight completed." : "Submission completed."
|
|
881
|
+
};
|
|
882
|
+
{
|
|
883
|
+
const c = await r.emitSafe("formie:submit:after", y);
|
|
884
|
+
c.failed.length > 0 && R.warn("Submit after listeners failed (success).", {
|
|
885
|
+
failed: c.failed.length
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
if (s) {
|
|
889
|
+
const c = await r.emitSafe("formie:submit:final:after", y);
|
|
890
|
+
c.failed.length > 0 && R.warn("Final submit after listeners failed (success).", {
|
|
891
|
+
failed: c.failed.length
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
return R.log("Pipeline completed.", {
|
|
895
|
+
ok: y.ok,
|
|
896
|
+
stage: y.stage,
|
|
897
|
+
code: y.code
|
|
898
|
+
}), y;
|
|
899
|
+
}
|
|
900
|
+
const bn = {
|
|
901
|
+
rule: ({ input: e, getRule: t }) => !t("email") || !e.value || e.value.length < 1 ? !0 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.value),
|
|
902
|
+
message: ({ input: e, label: t, t: r }) => e.getAttribute("data-formie-pattern-email-message") ?? e.getAttribute("data-pattern-email-message") ?? r("{attribute} is not a valid email address.", { attribute: t })
|
|
903
|
+
};
|
|
904
|
+
function yn(e) {
|
|
905
|
+
return e?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() || "";
|
|
906
|
+
}
|
|
907
|
+
function bt(e) {
|
|
908
|
+
const t = e.getRule("match");
|
|
909
|
+
if (!t || t === !0 || typeof t != "object" || !e.field)
|
|
910
|
+
return null;
|
|
911
|
+
const r = typeof t.fieldHandle == "string" ? t.fieldHandle.trim() : "";
|
|
912
|
+
if (!r)
|
|
913
|
+
return null;
|
|
914
|
+
const n = e.form.querySelector(`[data-formie-field-handle="${r}"]`);
|
|
915
|
+
return n ? n.querySelector(e.config.fieldsSelector) : null;
|
|
916
|
+
}
|
|
917
|
+
const vn = {
|
|
918
|
+
rule: (e) => {
|
|
919
|
+
const t = bt(e);
|
|
920
|
+
return t ? t.value === e.input.value : !0;
|
|
921
|
+
},
|
|
922
|
+
message: (e) => {
|
|
923
|
+
const r = bt(e)?.closest("[data-formie-field-handle]"), n = yn(r);
|
|
924
|
+
return e.t("{name} must match {value}.", {
|
|
925
|
+
name: e.label,
|
|
926
|
+
value: n
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
}, En = {
|
|
930
|
+
rule: ({ input: e, getRule: t }) => {
|
|
931
|
+
const r = t("number");
|
|
932
|
+
if (!r || !e.value || e.value.trim() === "")
|
|
933
|
+
return !0;
|
|
934
|
+
const n = parseFloat(e.value);
|
|
935
|
+
if (Number.isNaN(n))
|
|
936
|
+
return !1;
|
|
937
|
+
if (r !== !0 && typeof r == "object") {
|
|
938
|
+
const i = typeof r.min == "number" ? r.min : null, o = typeof r.max == "number" ? r.max : null;
|
|
939
|
+
if (i !== null && n < i || o !== null && n > o)
|
|
940
|
+
return !1;
|
|
941
|
+
}
|
|
942
|
+
return !0;
|
|
943
|
+
},
|
|
944
|
+
message: ({ input: e, label: t, getRule: r, t: n }) => {
|
|
945
|
+
const i = r("number"), o = i !== !0 && i && typeof i == "object" && typeof i.min == "number" ? i.min : null, a = i !== !0 && i && typeof i == "object" && typeof i.max == "number" ? i.max : null;
|
|
946
|
+
return o !== null && a !== null ? n("{attribute} must be between {min} and {max}.", { attribute: t, min: o, max: a }) : o !== null ? n("{attribute} must be no less than {min}.", { attribute: t, min: o }) : a !== null ? n("{attribute} must be no greater than {max}.", { attribute: t, max: a }) : e.getAttribute("data-formie-pattern-number-message") ?? e.getAttribute("data-pattern-number-message") ?? n("{attribute} is not a valid number.", { attribute: t });
|
|
947
|
+
}
|
|
948
|
+
}, Sn = {
|
|
949
|
+
rule: ({ input: e, getRule: t }) => {
|
|
950
|
+
if (!t("required") || e.type === "hidden")
|
|
951
|
+
return !0;
|
|
952
|
+
if (e.type === "checkbox" || e.type === "radio") {
|
|
953
|
+
const r = e.form?.querySelectorAll(`[name="${e.name}"]:not([type="hidden"]):not([disabled])`) || [];
|
|
954
|
+
return r.length ? Array.from(r).some((n) => n instanceof HTMLInputElement && n.checked) : e instanceof HTMLInputElement ? e.checked : !0;
|
|
955
|
+
}
|
|
956
|
+
return e.value.trim() !== "";
|
|
957
|
+
},
|
|
958
|
+
message: ({ input: e, label: t, t: r }) => e.getAttribute("data-formie-required-message") ?? e.getAttribute("data-required-message") ?? r("{attribute} cannot be blank.", { attribute: t })
|
|
959
|
+
}, An = {
|
|
960
|
+
rule: ({ input: e, getRule: t }) => {
|
|
961
|
+
if (!t("url") || !e.value || e.value.length < 1)
|
|
962
|
+
return !0;
|
|
963
|
+
try {
|
|
964
|
+
return new URL(e.value), !0;
|
|
965
|
+
} catch {
|
|
966
|
+
return !1;
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
message: ({ input: e, label: t, t: r }) => e.getAttribute("data-formie-pattern-url-message") ?? e.getAttribute("data-pattern-url-message") ?? r("{attribute} is not a valid URL.", { attribute: t })
|
|
970
|
+
}, wn = {
|
|
971
|
+
// Keep the core validator registry centralized so FormieValidator can extend
|
|
972
|
+
// it at runtime while still shipping one predictable builtin rule surface.
|
|
973
|
+
required: Sn,
|
|
974
|
+
email: bn,
|
|
975
|
+
url: An,
|
|
976
|
+
number: En,
|
|
977
|
+
match: vn
|
|
978
|
+
};
|
|
979
|
+
function Qt() {
|
|
980
|
+
return window.FormieTranslations || {};
|
|
981
|
+
}
|
|
982
|
+
function Tn() {
|
|
983
|
+
if (typeof document > "u")
|
|
984
|
+
return;
|
|
985
|
+
const e = Array.from(document.querySelectorAll('script[type="application/json"][data-formie-translations]:not([data-formie-translations-loaded="true"])'));
|
|
986
|
+
if (e.length === 0)
|
|
987
|
+
return;
|
|
988
|
+
let t = null;
|
|
989
|
+
for (const r of e) {
|
|
990
|
+
r.dataset.formieTranslationsLoaded = "true";
|
|
991
|
+
const n = r.textContent?.trim();
|
|
992
|
+
if (n)
|
|
993
|
+
try {
|
|
994
|
+
const i = JSON.parse(n);
|
|
995
|
+
if (!i || Array.isArray(i) || typeof i != "object")
|
|
996
|
+
continue;
|
|
997
|
+
t = {
|
|
998
|
+
...t ?? Qt(),
|
|
999
|
+
...i
|
|
1000
|
+
};
|
|
1001
|
+
} catch {
|
|
1002
|
+
continue;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
t && (window.FormieTranslations = t);
|
|
1006
|
+
}
|
|
1007
|
+
function nt() {
|
|
1008
|
+
return Tn(), Qt();
|
|
1009
|
+
}
|
|
1010
|
+
function Xt() {
|
|
1011
|
+
return { ...nt() };
|
|
1012
|
+
}
|
|
1013
|
+
function Yo(e) {
|
|
1014
|
+
return window.FormieTranslations = { ...e }, Xt();
|
|
1015
|
+
}
|
|
1016
|
+
function Zo(e) {
|
|
1017
|
+
return window.FormieTranslations = {
|
|
1018
|
+
...nt(),
|
|
1019
|
+
...e
|
|
1020
|
+
}, Xt();
|
|
1021
|
+
}
|
|
1022
|
+
function x(e, t = {}) {
|
|
1023
|
+
let r = nt()[e] || e;
|
|
1024
|
+
return r = r.replace(/{([a-zA-Z0-9]+)}/g, (n, i) => Object.prototype.hasOwnProperty.call(t, i) ? String(t[i]) : n), r;
|
|
1025
|
+
}
|
|
1026
|
+
const Qo = x, Cn = {
|
|
1027
|
+
// eslint-disable-next-line
|
|
1028
|
+
email: /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*(\.\w{2,})+$/,
|
|
1029
|
+
url: /^(?:(?:https?|HTTPS?|ftp|FTP):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)*(?:\.(?:[a-zA-Z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/,
|
|
1030
|
+
number: /^(?:[-+]?[0-9]*[.,]?[0-9]+)$/,
|
|
1031
|
+
color: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,
|
|
1032
|
+
date: /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))/,
|
|
1033
|
+
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
1034
|
+
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/
|
|
1035
|
+
}, K = _("general", "validator");
|
|
1036
|
+
function oe(e) {
|
|
1037
|
+
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement);
|
|
1038
|
+
}
|
|
1039
|
+
function Mn(e, t) {
|
|
1040
|
+
const r = (e.getAttribute("aria-describedby") || "").trim();
|
|
1041
|
+
if (!r)
|
|
1042
|
+
return;
|
|
1043
|
+
const n = r.split(/\s+/).filter((i) => i !== t);
|
|
1044
|
+
if (n.length) {
|
|
1045
|
+
e.setAttribute("aria-describedby", n.join(" "));
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
e.removeAttribute("aria-describedby");
|
|
1049
|
+
}
|
|
1050
|
+
function Ln(e, t) {
|
|
1051
|
+
const r = (e.getAttribute("aria-describedby") || "").trim(), n = r ? r.split(/\s+/) : [];
|
|
1052
|
+
n.includes(t) || n.push(t), e.setAttribute("aria-describedby", n.join(" ").trim());
|
|
1053
|
+
}
|
|
1054
|
+
function In(e, t) {
|
|
1055
|
+
e.setAttribute("aria-errormessage", t);
|
|
1056
|
+
}
|
|
1057
|
+
function Fn(e, t) {
|
|
1058
|
+
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
1059
|
+
}
|
|
1060
|
+
class Rn {
|
|
1061
|
+
constructor(t, r = {}) {
|
|
1062
|
+
this.errors = [], this.validators = {}, this.boundListeners = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.submitted = !1, this.initialValues = /* @__PURE__ */ new WeakMap(), this.form = t, this.onBlur = this.blurHandler.bind(this), this.onChange = this.changeHandler.bind(this), this.onInput = this.inputHandler.bind(this), this.config = {
|
|
1063
|
+
live: !1,
|
|
1064
|
+
errorMessage: "",
|
|
1065
|
+
fieldContainerErrorClass: [],
|
|
1066
|
+
inputErrorClass: [],
|
|
1067
|
+
messagesClass: [],
|
|
1068
|
+
messageClass: [],
|
|
1069
|
+
fieldsSelector: 'input:not([type="hidden"]):not([type="submit"]):not([type="button"]):not([disabled]), select:not([disabled]), textarea:not([disabled])',
|
|
1070
|
+
patterns: Cn,
|
|
1071
|
+
...r
|
|
1072
|
+
}, Object.entries(wn).forEach(([n, i]) => {
|
|
1073
|
+
this.addValidator(n, i.rule, i.message);
|
|
1074
|
+
}), this.init();
|
|
1075
|
+
}
|
|
1076
|
+
init() {
|
|
1077
|
+
K.log("Initializing validator.", {
|
|
1078
|
+
formId: this.form.id || null,
|
|
1079
|
+
live: this.config.live
|
|
1080
|
+
}), this.form.setAttribute("novalidate", "true"), this.inputs().forEach((t) => {
|
|
1081
|
+
this.initialValues.set(t, this.getInputValue(t));
|
|
1082
|
+
}), this.config.live && this.addEventListeners(), this.emitEvent(document, pe("ready"), {
|
|
1083
|
+
validator: this
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
inputs(t = null) {
|
|
1087
|
+
if (oe(t))
|
|
1088
|
+
return [t];
|
|
1089
|
+
const r = t || this.form;
|
|
1090
|
+
return Array.from(r.querySelectorAll(this.config.fieldsSelector)).filter((n) => oe(n));
|
|
1091
|
+
}
|
|
1092
|
+
getInputValue(t) {
|
|
1093
|
+
return t instanceof HTMLInputElement && (t.type === "checkbox" || t.type === "radio") ? t.checked : t instanceof HTMLInputElement && t.type === "file" ? t.files?.length ? Array.from(t.files).map((r) => r.name).join("|") : "" : t.value ?? "";
|
|
1094
|
+
}
|
|
1095
|
+
isDirty(t) {
|
|
1096
|
+
return this.initialValues.has(t) ? this.getInputValue(t) !== this.initialValues.get(t) : (this.initialValues.set(t, this.getInputValue(t)), !1);
|
|
1097
|
+
}
|
|
1098
|
+
shouldShowError(t) {
|
|
1099
|
+
return this.submitted || this.activated.has(t);
|
|
1100
|
+
}
|
|
1101
|
+
validate(t = null, r = {}) {
|
|
1102
|
+
this.errors = [];
|
|
1103
|
+
const n = /* @__PURE__ */ new Set();
|
|
1104
|
+
return this.inputs(t).forEach((i) => {
|
|
1105
|
+
let o = !1;
|
|
1106
|
+
if (!this.isVisible(i, r))
|
|
1107
|
+
return;
|
|
1108
|
+
const a = i.closest("[data-formie-field-handle]"), s = i instanceof HTMLInputElement && (i.type === "checkbox" || i.type === "radio") ? `${a?.getAttribute("data-formie-field-handle") || ""}:${i.name}` : null;
|
|
1109
|
+
if (s) {
|
|
1110
|
+
if (n.has(s))
|
|
1111
|
+
return;
|
|
1112
|
+
n.add(s);
|
|
1113
|
+
}
|
|
1114
|
+
this.shouldShowError(i) && this.removeError(i);
|
|
1115
|
+
const l = this.getValidatorCallbackOptions(i);
|
|
1116
|
+
Object.entries(this.validators).forEach(([d, p]) => {
|
|
1117
|
+
if (!p.validate(l)) {
|
|
1118
|
+
const c = this.getErrorMessage(i, d, p, l);
|
|
1119
|
+
this.shouldShowError(i) && !o && this.showError(i, d, c), this.errors.push({
|
|
1120
|
+
input: i,
|
|
1121
|
+
field: l.field,
|
|
1122
|
+
validator: d,
|
|
1123
|
+
message: c,
|
|
1124
|
+
handle: l.field?.getAttribute("data-formie-field-handle") || null,
|
|
1125
|
+
result: !1
|
|
1126
|
+
}), o = !0;
|
|
1127
|
+
}
|
|
1128
|
+
}), !o && this.shouldShowError(i) && this.removeError(i);
|
|
1129
|
+
}), K.log("Validation pass complete.", {
|
|
1130
|
+
errorCount: this.errors.length,
|
|
1131
|
+
includeHiddenPages: r.includeHiddenPages === !0
|
|
1132
|
+
}), this.errors;
|
|
1133
|
+
}
|
|
1134
|
+
removeAllErrors() {
|
|
1135
|
+
this.inputs().forEach((t) => {
|
|
1136
|
+
this.removeError(t);
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
removeError(t) {
|
|
1140
|
+
const r = t.closest("[data-formie-field-handle]");
|
|
1141
|
+
if (!r) {
|
|
1142
|
+
t.removeAttribute("aria-invalid");
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
const n = r.querySelector("[data-formie-field-errors]"), i = n?.id || "";
|
|
1146
|
+
r.querySelectorAll("[data-formie-field-error]").forEach((o) => {
|
|
1147
|
+
o.remove();
|
|
1148
|
+
}), n && (n.innerHTML = ""), r.querySelectorAll("input, select, textarea").forEach((o) => {
|
|
1149
|
+
const a = o;
|
|
1150
|
+
a.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && a.classList.remove(...this.config.inputErrorClass), a.removeAttribute("data-formie-input-has-error"), i && Mn(a, i), r.querySelectorAll("[data-formie-field-error]").forEach((s) => {
|
|
1151
|
+
const l = s.id;
|
|
1152
|
+
l && Fn(a, l);
|
|
1153
|
+
});
|
|
1154
|
+
});
|
|
1155
|
+
for (let o = r; o; o = o.parentElement?.closest("[data-formie-field-handle]"))
|
|
1156
|
+
this.config.fieldContainerErrorClass.length && o.classList.remove(...this.config.fieldContainerErrorClass), o.removeAttribute("data-formie-field-has-error");
|
|
1157
|
+
this.emitEvent(t, pe("clear-error"), {
|
|
1158
|
+
validator: this
|
|
1159
|
+
}), J(this.form);
|
|
1160
|
+
}
|
|
1161
|
+
showError(t, r, n) {
|
|
1162
|
+
const i = t.closest("[data-formie-field-handle]");
|
|
1163
|
+
if (!i)
|
|
1164
|
+
return;
|
|
1165
|
+
let o = i.querySelector("[data-formie-field-errors]");
|
|
1166
|
+
o || (o = document.createElement("div"), o.setAttribute("data-formie-field-errors", "true"), this.config.messagesClass.length && o.classList.add(...this.config.messagesClass), i.appendChild(o)), this.config.messagesClass.length && o.classList.add(...this.config.messagesClass), o.innerHTML = "";
|
|
1167
|
+
const a = i.getAttribute("data-formie-field-handle") || "field", s = `${a}-error`;
|
|
1168
|
+
o.id = o.id || `${a}-errors`, o.setAttribute("aria-live", "polite"), o.setAttribute("aria-atomic", "true");
|
|
1169
|
+
const l = document.createElement("div");
|
|
1170
|
+
l.setAttribute("data-formie-field-error", "true"), l.setAttribute(`data-formie-field-error-${r}`, "true"), l.setAttribute("id", s), l.setAttribute("role", "alert"), this.config.messageClass.length && l.classList.add(...this.config.messageClass), l.textContent = n, o.appendChild(l), i.setAttribute("data-formie-field-has-error", "true"), i.querySelectorAll("input, select, textarea").forEach((d) => {
|
|
1171
|
+
const p = d;
|
|
1172
|
+
p.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && p.classList.add(...this.config.inputErrorClass), p.setAttribute("data-formie-input-has-error", "true"), Ln(p, o.id), In(p, s);
|
|
1173
|
+
});
|
|
1174
|
+
for (let d = i; d; d = d.parentElement?.closest("[data-formie-field-handle]"))
|
|
1175
|
+
this.config.fieldContainerErrorClass.length && d.classList.add(...this.config.fieldContainerErrorClass), d.setAttribute("data-formie-field-has-error", "true");
|
|
1176
|
+
this.emitEvent(t, pe("show-error"), {
|
|
1177
|
+
validator: this,
|
|
1178
|
+
validatorName: r,
|
|
1179
|
+
errorMessage: n
|
|
1180
|
+
}), J(this.form);
|
|
1181
|
+
}
|
|
1182
|
+
getValidatorCallbackOptions(t) {
|
|
1183
|
+
const r = t.closest("[data-formie-field-handle]"), n = r?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() ?? "", i = this.parseValidationRules(r?.getAttribute("data-formie-validation"));
|
|
1184
|
+
return {
|
|
1185
|
+
t: x,
|
|
1186
|
+
input: t,
|
|
1187
|
+
label: n,
|
|
1188
|
+
field: r,
|
|
1189
|
+
form: this.form,
|
|
1190
|
+
config: this.config,
|
|
1191
|
+
rules: i,
|
|
1192
|
+
getRule: (o) => this.getRule(r, o)
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
getErrorMessage(t, r, n, i) {
|
|
1196
|
+
return (typeof n.errorMessage == "function" ? n.errorMessage(i) : n.errorMessage) ?? x("{attribute} is invalid.", { attribute: i.label });
|
|
1197
|
+
}
|
|
1198
|
+
getErrors() {
|
|
1199
|
+
return this.errors;
|
|
1200
|
+
}
|
|
1201
|
+
getFieldErrors(t = this.errors) {
|
|
1202
|
+
const r = {};
|
|
1203
|
+
return t.forEach((n) => {
|
|
1204
|
+
!n.handle || r[n.handle]?.length || (r[n.handle] = [n.message]);
|
|
1205
|
+
}), r;
|
|
1206
|
+
}
|
|
1207
|
+
getRule(t, r) {
|
|
1208
|
+
if (!t)
|
|
1209
|
+
return !1;
|
|
1210
|
+
const n = this.parseValidationRules(t.getAttribute("data-formie-validation"));
|
|
1211
|
+
return Object.prototype.hasOwnProperty.call(n, r) ? n[r] : !1;
|
|
1212
|
+
}
|
|
1213
|
+
parseValidationRules(t) {
|
|
1214
|
+
const r = {};
|
|
1215
|
+
if (!t)
|
|
1216
|
+
return r;
|
|
1217
|
+
let n = null;
|
|
1218
|
+
try {
|
|
1219
|
+
n = JSON.parse(t);
|
|
1220
|
+
} catch {
|
|
1221
|
+
return K.warn("Invalid validation rules payload.", {
|
|
1222
|
+
formId: this.form.id || null
|
|
1223
|
+
}), r;
|
|
1224
|
+
}
|
|
1225
|
+
return Array.isArray(n) && n.forEach((i) => {
|
|
1226
|
+
if (!i || typeof i != "object" || Array.isArray(i))
|
|
1227
|
+
return;
|
|
1228
|
+
const o = i, a = typeof o.type == "string" ? o.type.trim() : "";
|
|
1229
|
+
a && (r[a] = o);
|
|
1230
|
+
}), r;
|
|
1231
|
+
}
|
|
1232
|
+
destroy() {
|
|
1233
|
+
K.log("Destroying validator.", {
|
|
1234
|
+
formId: this.form.id || null
|
|
1235
|
+
}), this.removeEventListeners(), this.form.removeAttribute("novalidate"), this.emitEvent(document, pe("destroy"), {
|
|
1236
|
+
validator: this
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
isVisible(t, r = {}) {
|
|
1240
|
+
return t.closest("[data-formie-conditionally-hidden]") ? !1 : t.closest("[data-formie-page-hidden]") ? !!r.includeHiddenPages : !!(t.offsetWidth || t.offsetHeight || t.getClientRects().length);
|
|
1241
|
+
}
|
|
1242
|
+
blurHandler(t) {
|
|
1243
|
+
!(t.target instanceof HTMLElement) || !oe(t.target) || !t.target.form?.isSameNode(this.form) || t instanceof CustomEvent || t.target instanceof HTMLInputElement && t.target.type === "file" || t.target instanceof HTMLInputElement && (t.target.type === "checkbox" || t.target.type === "radio") || (this.isDirty(t.target) && this.activated.add(t.target), this.shouldShowError(t.target) && this.validate(t.target));
|
|
1244
|
+
}
|
|
1245
|
+
changeHandler(t) {
|
|
1246
|
+
if (!(!(t.target instanceof HTMLElement) || !oe(t.target) || !t.target.form?.isSameNode(this.form)) && !(t instanceof CustomEvent)) {
|
|
1247
|
+
if (t.target instanceof HTMLSelectElement) {
|
|
1248
|
+
this.activated.add(t.target), this.validate(t.target);
|
|
1249
|
+
return;
|
|
1250
|
+
}
|
|
1251
|
+
t.target instanceof HTMLInputElement && (t.target.type !== "file" && t.target.type !== "checkbox" && t.target.type !== "radio" || (this.activated.add(t.target), this.validate(t.target)));
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
inputHandler(t) {
|
|
1255
|
+
!(t.target instanceof HTMLElement) || !oe(t.target) || !t.target.form?.isSameNode(this.form) || t instanceof CustomEvent || t.target instanceof HTMLInputElement && (t.target.type === "checkbox" || t.target.type === "radio") || this.shouldShowError(t.target) && this.validate(t.target);
|
|
1256
|
+
}
|
|
1257
|
+
submit(t = null, { final: r = !1 } = {}) {
|
|
1258
|
+
return this.submitted = !0, K.log("Submit validation requested.", {
|
|
1259
|
+
final: r
|
|
1260
|
+
}), this.boundListeners || this.addEventListeners(), this.removeAllErrors(), this.validate(t, {
|
|
1261
|
+
includeHiddenPages: r
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
resetLiveState() {
|
|
1265
|
+
this.submitted = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.errors = [], this.removeAllErrors();
|
|
1266
|
+
}
|
|
1267
|
+
addEventListeners() {
|
|
1268
|
+
this.boundListeners || (this.form.addEventListener("blur", this.onBlur, !0), this.form.addEventListener("change", this.onChange, !1), this.form.addEventListener("input", this.onInput, !1), this.boundListeners = !0, K.log("Event listeners attached."));
|
|
1269
|
+
}
|
|
1270
|
+
removeEventListeners() {
|
|
1271
|
+
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1, K.log("Event listeners removed.");
|
|
1272
|
+
}
|
|
1273
|
+
emitEvent(t, r, n = {}) {
|
|
1274
|
+
t.dispatchEvent(new CustomEvent(r, {
|
|
1275
|
+
bubbles: !0,
|
|
1276
|
+
detail: n
|
|
1277
|
+
}));
|
|
1278
|
+
}
|
|
1279
|
+
addValidator(t, r, n) {
|
|
1280
|
+
this.validators[t] = {
|
|
1281
|
+
validate: r,
|
|
1282
|
+
errorMessage: n
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
removeValidator(t) {
|
|
1286
|
+
delete this.validators[t];
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
const kn = "STALE_SUBMISSION_STATE", yt = /* @__PURE__ */ new WeakMap(), we = /* @__PURE__ */ new WeakMap(), j = _("general", "submit-result");
|
|
1290
|
+
function ze(e, t, r) {
|
|
1291
|
+
let n = e.querySelector(`input[name="${t}"]`);
|
|
1292
|
+
n || (n = document.createElement("input"), n.type = "hidden", n.name = t, e.appendChild(n)), n.value = r;
|
|
1293
|
+
}
|
|
1294
|
+
function vt(e, t) {
|
|
1295
|
+
e.setAttribute("data-formie-internal-navigation", t);
|
|
1296
|
+
}
|
|
1297
|
+
function ae(e, t) {
|
|
1298
|
+
e.querySelector(`input[name="${t}"]`)?.remove();
|
|
1299
|
+
}
|
|
1300
|
+
function qn(e, t) {
|
|
1301
|
+
try {
|
|
1302
|
+
const r = new URL(e, window.location.href);
|
|
1303
|
+
return r.searchParams.delete(t), r.toString();
|
|
1304
|
+
} catch {
|
|
1305
|
+
return e;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
function Pn(e) {
|
|
1309
|
+
try {
|
|
1310
|
+
return new URL(e, window.location.href).origin === window.location.origin;
|
|
1311
|
+
} catch {
|
|
1312
|
+
return !1;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
function er(e) {
|
|
1316
|
+
return Array.from(e.querySelectorAll("[data-formie-page]"));
|
|
1317
|
+
}
|
|
1318
|
+
function $n(e) {
|
|
1319
|
+
return Array.from(e.querySelectorAll("[data-formie-tab]"));
|
|
1320
|
+
}
|
|
1321
|
+
function Vn(e, t, r) {
|
|
1322
|
+
return t < 0 || r < 1 ? 0 : (e.dataset.formieProgressCalculation === "page-position" ? "page-position" : "completion") === "page-position" ? Math.round((t + 1) / r * 100) : Math.round(t / r * 100);
|
|
1323
|
+
}
|
|
1324
|
+
function On(e) {
|
|
1325
|
+
return e <= 0 ? "start" : e >= 100 ? "end" : "middle";
|
|
1326
|
+
}
|
|
1327
|
+
function Et(e) {
|
|
1328
|
+
return (e.dataset.formieSubmitAction || "").trim();
|
|
1329
|
+
}
|
|
1330
|
+
function St(e) {
|
|
1331
|
+
const t = e.dataset.formieSubmitActionFormHide;
|
|
1332
|
+
if (t === void 0)
|
|
1333
|
+
return !1;
|
|
1334
|
+
const r = t.trim().toLowerCase();
|
|
1335
|
+
return r === "true" || r === "1" || r === "";
|
|
1336
|
+
}
|
|
1337
|
+
function it(e, t) {
|
|
1338
|
+
const r = [
|
|
1339
|
+
"[data-formie-form-header]",
|
|
1340
|
+
"[data-formie-form-navigation]",
|
|
1341
|
+
"[data-formie-form-body]",
|
|
1342
|
+
"[data-formie-form-footer]"
|
|
1343
|
+
];
|
|
1344
|
+
e.toggleAttribute("data-formie-form-hidden", t), r.forEach((n) => {
|
|
1345
|
+
e.querySelectorAll(n).forEach((i) => {
|
|
1346
|
+
const o = i;
|
|
1347
|
+
t ? o.hidden = !0 : o.hidden = !1;
|
|
1348
|
+
});
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
function z(e) {
|
|
1352
|
+
const t = yt.get(e);
|
|
1353
|
+
typeof t == "number" && (window.clearTimeout(t), yt.delete(e));
|
|
1354
|
+
}
|
|
1355
|
+
function Hn(e, t) {
|
|
1356
|
+
we.has(e) || we.set(e, e.innerHTML), e.textContent = t;
|
|
1357
|
+
}
|
|
1358
|
+
function je(e) {
|
|
1359
|
+
const t = we.get(e);
|
|
1360
|
+
t !== void 0 && (e.innerHTML = t, we.delete(e));
|
|
1361
|
+
}
|
|
1362
|
+
function _n(e, t) {
|
|
1363
|
+
const r = e.querySelector("[data-formie-progress-bar]"), n = e.querySelector("[data-formie-progress-value]");
|
|
1364
|
+
r && (r.style.width = `${t}%`, r.setAttribute("aria-valuenow", `${t}`), r.setAttribute("data-formie-progress-state", On(t)), n && (n.textContent = `${t}%`, n.setAttribute("data-formie-progress-value", `${t}`)));
|
|
1365
|
+
}
|
|
1366
|
+
function Dn(e, t) {
|
|
1367
|
+
if (!t)
|
|
1368
|
+
return;
|
|
1369
|
+
const r = (e.dataset.formieLoadingIndicator || "").trim();
|
|
1370
|
+
if (r) {
|
|
1371
|
+
if (t.setAttribute("data-formie-loading-indicator", r), r === "spinner") {
|
|
1372
|
+
ue(t, e, "loading", !0), je(t), t.removeAttribute("data-formie-loading-text");
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
if (r === "text") {
|
|
1376
|
+
const n = (e.dataset.formieLoadingIndicatorText || "").trim(), i = t.textContent?.trim() || "", o = n || i;
|
|
1377
|
+
t.setAttribute("data-formie-loading-text", o), Hn(t, o);
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
je(t), t.removeAttribute("data-formie-loading-text");
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
function tr(e) {
|
|
1384
|
+
return Array.from(e.querySelectorAll("[data-formie-action]"));
|
|
1385
|
+
}
|
|
1386
|
+
function rr(e, t) {
|
|
1387
|
+
if (e.getAttribute("data-formie-loading") === "true")
|
|
1388
|
+
return;
|
|
1389
|
+
e.setAttribute("data-formie-loading", "true"), tr(e).forEach((n) => {
|
|
1390
|
+
"disabled" in n && (n.disabled ? n.setAttribute("data-formie-was-disabled", "true") : n.removeAttribute("data-formie-was-disabled"), n.disabled = !0);
|
|
1391
|
+
}), t && (t.setAttribute("data-formie-loading", "true"), Dn(e, t));
|
|
1392
|
+
}
|
|
1393
|
+
function Te(e) {
|
|
1394
|
+
e.removeAttribute("data-formie-loading"), tr(e).forEach((r) => {
|
|
1395
|
+
if ("disabled" in r) {
|
|
1396
|
+
const n = r, i = n.getAttribute("data-formie-was-disabled") === "true";
|
|
1397
|
+
n.disabled = i;
|
|
1398
|
+
}
|
|
1399
|
+
je(r), r.removeAttribute("data-formie-was-disabled"), r.removeAttribute("data-formie-loading"), ue(r, e, "loading", !1), r.removeAttribute("data-formie-loading-indicator"), r.removeAttribute("data-formie-loading-text");
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
function ot(e, t) {
|
|
1403
|
+
const r = er(e), n = $n(e), i = r.findIndex((o) => o.getAttribute("data-formie-page-id") === t);
|
|
1404
|
+
if (r.forEach((o) => {
|
|
1405
|
+
o.getAttribute("data-formie-page-id") === t ? (o.removeAttribute("data-formie-page-hidden"), le(o, e, "pageHidden")) : (o.setAttribute("data-formie-page-hidden", "true"), V(o, e, "pageHidden"));
|
|
1406
|
+
}), n.forEach((o, a) => {
|
|
1407
|
+
const s = o.getAttribute("data-formie-page-id") === t, l = i > -1 && a < i;
|
|
1408
|
+
ue(o, e, "tabCurrent", s), ue(o, e, "tabComplete", l), s ? o.setAttribute("aria-current", "page") : o.removeAttribute("aria-current"), l ? o.setAttribute("data-formie-tab-complete", "true") : o.removeAttribute("data-formie-tab-complete");
|
|
1409
|
+
}), i > -1 && r.length > 0) {
|
|
1410
|
+
const o = Vn(e, i, r.length);
|
|
1411
|
+
_n(e, o);
|
|
1412
|
+
}
|
|
1413
|
+
ze(e, "pageId", t), J(e);
|
|
1414
|
+
}
|
|
1415
|
+
function xn(e, t) {
|
|
1416
|
+
const r = t.meta?.submissionUid;
|
|
1417
|
+
typeof r == "string" && r.trim() !== "" && ze(e, "submissionUid", r);
|
|
1418
|
+
const n = t.meta?.session?.continuation?.continuationToken;
|
|
1419
|
+
typeof n == "string" && n.trim() !== "" ? ze(e, "continuationToken", n) : ae(e, "continuationToken");
|
|
1420
|
+
}
|
|
1421
|
+
function Nn(e) {
|
|
1422
|
+
const t = e.getAttribute("action");
|
|
1423
|
+
t && e.setAttribute("action", qn(t, "resumeToken"));
|
|
1424
|
+
try {
|
|
1425
|
+
const r = new URL(window.location.href);
|
|
1426
|
+
if (!r.searchParams.has("resumeToken"))
|
|
1427
|
+
return;
|
|
1428
|
+
r.searchParams.delete("resumeToken"), window.history.replaceState({}, document.title, `${r.pathname}${r.search}${r.hash}`);
|
|
1429
|
+
} catch {
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
function Un(e, t) {
|
|
1433
|
+
const r = t.meta?.resumeUrl;
|
|
1434
|
+
if (typeof r != "string" || r.trim() === "")
|
|
1435
|
+
return;
|
|
1436
|
+
const n = r.trim();
|
|
1437
|
+
if (!Pn(n))
|
|
1438
|
+
return;
|
|
1439
|
+
e.getAttribute("action") && e.setAttribute("action", n);
|
|
1440
|
+
try {
|
|
1441
|
+
const o = new URL(n, window.location.href);
|
|
1442
|
+
window.history.replaceState({}, document.title, `${o.pathname}${o.search}${o.hash}`);
|
|
1443
|
+
} catch {
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
function he(e, t = {}) {
|
|
1447
|
+
const n = e.formieValidation, i = er(e)[0]?.getAttribute("data-formie-page-id");
|
|
1448
|
+
if (z(e), e.reset(), t.preserveHiddenState || it(e, !1), ae(e, "submissionId"), ae(e, "submissionUid"), ae(e, "continuationToken"), ae(e, "pageId"), Nn(e), n?.resetLiveState(), i) {
|
|
1449
|
+
ot(e, i), e.dispatchEvent(new CustomEvent(Ue("reset"), { bubbles: !0 }));
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
J(e), e.dispatchEvent(new CustomEvent(Ue("reset"), { bubbles: !0 }));
|
|
1453
|
+
}
|
|
1454
|
+
function zn(e) {
|
|
1455
|
+
return e.code === kn || e.meta?.resetState === !0;
|
|
1456
|
+
}
|
|
1457
|
+
function jn(e, t) {
|
|
1458
|
+
const r = t.submitData, n = /* @__PURE__ */ new Set();
|
|
1459
|
+
let i = !1;
|
|
1460
|
+
if (Array.isArray(r) && r.length > 0) {
|
|
1461
|
+
const p = r.filter(
|
|
1462
|
+
(y) => typeof y == "object" && y !== null && "event" in y && typeof y.event == "string"
|
|
1463
|
+
);
|
|
1464
|
+
for (const y of p) {
|
|
1465
|
+
const c = y.event;
|
|
1466
|
+
n.add(c), j.log("Dispatching submitData event.", {
|
|
1467
|
+
eventName: c
|
|
1468
|
+
}), c.startsWith("formie:payment:") && (i = !0), e.dispatchEvent(new CustomEvent(c, {
|
|
1469
|
+
bubbles: !0,
|
|
1470
|
+
detail: { data: y.data }
|
|
1471
|
+
}));
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
const o = t.meta || {}, a = (o.paymentAction && typeof o.paymentAction == "object" ? o.paymentAction : null) || (o.paymentDecision && typeof o.paymentDecision == "object" ? o.paymentDecision.action : null), s = a ? String(a.event || "") : "", l = a ? a.payload : void 0, d = s;
|
|
1475
|
+
return d && !n.has(d) && (d.startsWith("formie:payment:") && (i = !0), e.dispatchEvent(new CustomEvent(d, {
|
|
1476
|
+
bubbles: !0,
|
|
1477
|
+
detail: { data: l }
|
|
1478
|
+
})), j.log("Dispatching fallback payment action event.", {
|
|
1479
|
+
eventName: d
|
|
1480
|
+
})), { hasPaymentFollowUpEvent: i };
|
|
1481
|
+
}
|
|
1482
|
+
function Bn(e, t, r) {
|
|
1483
|
+
if (j.log("Applying submit result state.", {
|
|
1484
|
+
ok: t.ok,
|
|
1485
|
+
action: r,
|
|
1486
|
+
code: t.code,
|
|
1487
|
+
hasRedirect: !!t.redirect?.url,
|
|
1488
|
+
hasSubmitData: Array.isArray(t.submitData) && t.submitData.length > 0
|
|
1489
|
+
}), zn(t)) {
|
|
1490
|
+
he(e), j.log("Resetting state due to stale/reset marker.");
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
const n = jn(e, t);
|
|
1494
|
+
if (!t.ok && t.redirect?.url && !n.hasPaymentFollowUpEvent) {
|
|
1495
|
+
j.log("Applying redirect fallback for failed result.", {
|
|
1496
|
+
url: t.redirect.url,
|
|
1497
|
+
target: t.redirect.target
|
|
1498
|
+
}), z(e), t.redirect.target === "new-tab" ? window.open(t.redirect.url, "_blank") : (vt(e, "redirect"), window.location.href = t.redirect.url);
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
if (xn(e, t), !t.ok) {
|
|
1502
|
+
j.log("Non-redirect failure; keeping current form state."), z(e);
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
if (jt(e, r), t.nextPage?.id) {
|
|
1506
|
+
z(e), e.formieValidation?.resetLiveState(), ot(e, t.nextPage.id), j.log("Advanced to next page.", {
|
|
1507
|
+
nextPageId: t.nextPage.id
|
|
1508
|
+
});
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1511
|
+
if (r === "save") {
|
|
1512
|
+
z(e), Un(e, t), j.log("Applied save/resume token state.");
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
if (r === "submit" && !t.redirect?.url) {
|
|
1516
|
+
const i = Et(e), o = i === "message" && St(e);
|
|
1517
|
+
if (i === "reload") {
|
|
1518
|
+
z(e), vt(e, "reload"), window.location.reload();
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
if (i === "reset") {
|
|
1522
|
+
he(e);
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
z(e), he(e, { preserveHiddenState: o });
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
if (r === "submit" && t.redirect?.url && t.redirect.target === "new-tab") {
|
|
1529
|
+
const o = Et(e) === "message" && St(e);
|
|
1530
|
+
z(e), he(e, { preserveHiddenState: o });
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
z(e);
|
|
1534
|
+
}
|
|
1535
|
+
const Ce = /* @__PURE__ */ new WeakMap();
|
|
1536
|
+
function nr(e) {
|
|
1537
|
+
return (e.dataset.formieSubmitAction || "").trim();
|
|
1538
|
+
}
|
|
1539
|
+
function Wn(e) {
|
|
1540
|
+
return (e.dataset.formieErrorMessagePosition || "top-form").trim() || "top-form";
|
|
1541
|
+
}
|
|
1542
|
+
function ir(e) {
|
|
1543
|
+
return (e.dataset.formieSubmitActionMessagePosition || "").trim();
|
|
1544
|
+
}
|
|
1545
|
+
function Kn(e) {
|
|
1546
|
+
const t = (e.dataset.formieSubmitActionMessageTimeout || "").trim();
|
|
1547
|
+
if (!t)
|
|
1548
|
+
return null;
|
|
1549
|
+
const r = Number.parseFloat(t);
|
|
1550
|
+
return !Number.isFinite(r) || r < 0 ? null : Math.round(r * 1e3);
|
|
1551
|
+
}
|
|
1552
|
+
function at(e) {
|
|
1553
|
+
const t = e.dataset.formieSubmitActionFormHide;
|
|
1554
|
+
if (t === void 0)
|
|
1555
|
+
return !1;
|
|
1556
|
+
const r = t.trim().toLowerCase();
|
|
1557
|
+
return r === "true" || r === "1" || r === "";
|
|
1558
|
+
}
|
|
1559
|
+
function Gn(e) {
|
|
1560
|
+
const t = Ce.get(e);
|
|
1561
|
+
typeof t == "number" && (window.clearTimeout(t), Ce.delete(e));
|
|
1562
|
+
}
|
|
1563
|
+
function or(e) {
|
|
1564
|
+
return e.querySelector("[data-formie-form-messages-top]") || e;
|
|
1565
|
+
}
|
|
1566
|
+
function ar(e) {
|
|
1567
|
+
return e.querySelector("[data-formie-form-messages-bottom]") || e;
|
|
1568
|
+
}
|
|
1569
|
+
function Jn(e, t) {
|
|
1570
|
+
return t === "bottom-form" ? ar(e) : or(e);
|
|
1571
|
+
}
|
|
1572
|
+
function Yn(e, t) {
|
|
1573
|
+
return t === "top-form" ? or(e) : t === "bottom-form" && !at(e) ? ar(e) : e;
|
|
1574
|
+
}
|
|
1575
|
+
function Zn(e) {
|
|
1576
|
+
const t = Wn(e), r = Jn(e, t);
|
|
1577
|
+
let n = r.querySelector("[data-formie-error-container], [data-formie-errors]");
|
|
1578
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-errors", "true"), V(n, e, "errors")), n.setAttribute("data-formie-error-container", "true"), t === "bottom-form" ? r.append(n) : r.prepend(n), n;
|
|
1579
|
+
}
|
|
1580
|
+
function Qn(e, t) {
|
|
1581
|
+
let r = t.querySelector("[data-formie-error-message-container], [data-formie-message][data-formie-message-error]");
|
|
1582
|
+
return r || (r = document.createElement("div"), r.setAttribute("data-formie-error-message-container", "true"), t.appendChild(r)), r.setAttribute("data-formie-message", "true"), r.setAttribute("data-formie-message-error", "true"), V(r, e, "message", "messageError"), r.setAttribute("role", "alert"), r.setAttribute("aria-live", "polite"), r.setAttribute("aria-atomic", "true"), r;
|
|
1583
|
+
}
|
|
1584
|
+
function Xn(e, t) {
|
|
1585
|
+
let r = e.querySelector("[data-formie-success-container]");
|
|
1586
|
+
const n = Yn(e, t);
|
|
1587
|
+
return r || (r = document.createElement("div"), r.setAttribute("data-formie-success-container", "true"), V(r, e, "successes")), t === "bottom-form" ? n.append(r) : n.prepend(r), r;
|
|
1588
|
+
}
|
|
1589
|
+
function ei(e) {
|
|
1590
|
+
let t = e.querySelector("[data-formie-field-errors]");
|
|
1591
|
+
return t || (t = document.createElement("div"), t.setAttribute("data-formie-field-errors", "true"), V(t, e, "fieldErrors"), e.appendChild(t)), t;
|
|
1592
|
+
}
|
|
1593
|
+
function ti(e, t) {
|
|
1594
|
+
const r = (e.getAttribute("aria-describedby") || "").trim();
|
|
1595
|
+
if (!r)
|
|
1596
|
+
return;
|
|
1597
|
+
const n = r.split(/\s+/).filter((i) => i !== t).join(" ").trim();
|
|
1598
|
+
if (n) {
|
|
1599
|
+
e.setAttribute("aria-describedby", n);
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1602
|
+
e.removeAttribute("aria-describedby");
|
|
1603
|
+
}
|
|
1604
|
+
function ri(e, t) {
|
|
1605
|
+
e.setAttribute("aria-errormessage", t);
|
|
1606
|
+
}
|
|
1607
|
+
function ni(e, t) {
|
|
1608
|
+
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
1609
|
+
}
|
|
1610
|
+
function sr(e) {
|
|
1611
|
+
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
1612
|
+
const r = t, n = r.querySelector("[data-formie-field-errors]"), i = n?.id || "", o = Array.from(r.querySelectorAll("[data-formie-field-error]")).map((a) => a.id).filter(Boolean);
|
|
1613
|
+
le(r, e, "fieldLayoutError"), r.removeAttribute("data-formie-field-has-error"), r.querySelectorAll("[data-formie-field-error]").forEach((a) => {
|
|
1614
|
+
a.remove();
|
|
1615
|
+
}), n && !n.querySelector("[data-formie-field-error]") && (n.innerHTML = ""), r.querySelectorAll("input, select, textarea").forEach((a) => {
|
|
1616
|
+
const s = a;
|
|
1617
|
+
s.removeAttribute("aria-invalid"), le(s, e, "fieldControlError"), s.removeAttribute("data-formie-input-has-error"), i && ti(s, i), o.forEach((l) => {
|
|
1618
|
+
ni(s, l);
|
|
1619
|
+
});
|
|
1620
|
+
});
|
|
1621
|
+
}), J(e);
|
|
1622
|
+
}
|
|
1623
|
+
function lr(e) {
|
|
1624
|
+
e.querySelectorAll("[data-formie-error-container], [data-formie-errors]").forEach((t) => {
|
|
1625
|
+
const r = t;
|
|
1626
|
+
r.querySelectorAll("[data-formie-error]").forEach((n) => {
|
|
1627
|
+
n.remove();
|
|
1628
|
+
}), le(r, e, "message", "messageError"), r.removeAttribute("data-formie-message"), r.removeAttribute("data-formie-message-error"), r.removeAttribute("role"), r.removeAttribute("aria-live"), r.removeAttribute("aria-atomic"), r.querySelector("[data-formie-error]") || (r.innerHTML = "");
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
function st(e) {
|
|
1632
|
+
Gn(e), e.querySelectorAll("[data-formie-message-success]:not([data-formie-success-container])").forEach((t) => {
|
|
1633
|
+
t.remove();
|
|
1634
|
+
}), e.querySelectorAll("[data-formie-success-container]").forEach((t) => {
|
|
1635
|
+
const r = t;
|
|
1636
|
+
r.querySelectorAll("[data-formie-success]").forEach((n) => {
|
|
1637
|
+
n.remove();
|
|
1638
|
+
}), le(r, e, "message", "messageSuccess"), r.removeAttribute("data-formie-message"), r.removeAttribute("data-formie-message-success"), r.removeAttribute("role"), r.removeAttribute("aria-live"), r.removeAttribute("aria-atomic"), r.querySelector("[data-formie-success]") || (r.innerHTML = "");
|
|
1639
|
+
}), nr(e) === "message" && at(e) || it(e, !1);
|
|
1640
|
+
}
|
|
1641
|
+
function ur(e) {
|
|
1642
|
+
e.querySelectorAll('[aria-invalid="true"]').forEach((t) => {
|
|
1643
|
+
t.removeAttribute("aria-invalid");
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
function At(e, t) {
|
|
1647
|
+
const r = (e.getAttribute("aria-describedby") || "").trim(), n = r ? r.split(/\s+/) : [];
|
|
1648
|
+
n.includes(t) || n.push(t), e.setAttribute("aria-describedby", n.join(" ").trim());
|
|
1649
|
+
}
|
|
1650
|
+
function ii(e, t) {
|
|
1651
|
+
Object.entries(t).forEach(([r, n]) => {
|
|
1652
|
+
const i = e.querySelector(`[data-formie-field-handle="${r}"]`);
|
|
1653
|
+
if (!i)
|
|
1654
|
+
return;
|
|
1655
|
+
const o = ei(i), a = o.id && o.id.trim() ? o.id : `${r}-errors`;
|
|
1656
|
+
o.id = a, o.setAttribute("aria-live", "polite"), o.setAttribute("aria-atomic", "true"), V(i, e, "fieldLayoutError"), i.setAttribute("data-formie-field-has-error", "true"), n.forEach((l, d) => {
|
|
1657
|
+
const p = document.createElement("div");
|
|
1658
|
+
p.setAttribute("data-formie-field-error", "true"), p.setAttribute("role", "alert"), p.id = `${a}-${d + 1}`, V(p, e, "fieldError"), p.textContent = l, o.appendChild(p);
|
|
1659
|
+
});
|
|
1660
|
+
const s = o.querySelector("[data-formie-field-error]")?.id;
|
|
1661
|
+
i.querySelectorAll("input, select, textarea").forEach((l) => {
|
|
1662
|
+
const d = l;
|
|
1663
|
+
d.setAttribute("aria-invalid", "true"), V(d, e, "fieldControlError"), d.setAttribute("data-formie-input-has-error", "true"), At(d, a), s && ri(d, s);
|
|
1664
|
+
const p = i.querySelector("[data-formie-instructions]");
|
|
1665
|
+
p?.id && At(d, p.id);
|
|
1666
|
+
});
|
|
1667
|
+
}), J(e);
|
|
1668
|
+
}
|
|
1669
|
+
function wt(e, t) {
|
|
1670
|
+
const r = Zn(e), n = Qn(e, r);
|
|
1671
|
+
V(r, e, "errors"), t.forEach((i) => {
|
|
1672
|
+
const o = document.createElement("div");
|
|
1673
|
+
o.setAttribute("data-formie-error", "true"), o.setAttribute("role", "alert"), V(o, e, "error"), o.innerHTML = i, n.appendChild(o);
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
function oi(e, t) {
|
|
1677
|
+
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" ? !0 : nr(e) === "message" && ir(e) !== "";
|
|
1678
|
+
}
|
|
1679
|
+
function ai(e, t) {
|
|
1680
|
+
const r = ir(e);
|
|
1681
|
+
if (!r)
|
|
1682
|
+
return;
|
|
1683
|
+
const n = Xn(e, r);
|
|
1684
|
+
V(n, e, "message", "messageSuccess"), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-success", "true"), n.setAttribute("role", "status"), n.setAttribute("aria-live", "polite"), n.setAttribute("aria-atomic", "true");
|
|
1685
|
+
const i = document.createElement("div");
|
|
1686
|
+
i.setAttribute("data-formie-success", "true"), V(i, e, "success"), i.innerHTML = t, n.appendChild(i), at(e) && it(e, !0);
|
|
1687
|
+
const o = Kn(e);
|
|
1688
|
+
if (o !== null) {
|
|
1689
|
+
const a = window.setTimeout(() => {
|
|
1690
|
+
Ce.delete(e), st(e);
|
|
1691
|
+
}, o);
|
|
1692
|
+
Ce.set(e, a);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
function Me(e, t) {
|
|
1696
|
+
if (sr(e), lr(e), st(e), ur(e), t.ok) {
|
|
1697
|
+
oi(e, t) && ai(e, t.message || "");
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
if (t.fieldErrors && ii(e, t.fieldErrors), t.formErrors?.length) {
|
|
1701
|
+
wt(e, t.formErrors);
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
!t.fieldErrors && t.message && wt(e, [t.message]);
|
|
1705
|
+
}
|
|
1706
|
+
const si = _("general", "submit-flow");
|
|
1707
|
+
function li(e) {
|
|
1708
|
+
return !(!e.ok && e.stage === "validate");
|
|
1709
|
+
}
|
|
1710
|
+
function cr(e) {
|
|
1711
|
+
return e ? !!(e.keepSubmitLoading === !0 || e.ok && e.redirect?.url && e.redirect.target !== "new-tab") : !1;
|
|
1712
|
+
}
|
|
1713
|
+
function dr(e) {
|
|
1714
|
+
sr(e), lr(e), st(e), ur(e);
|
|
1715
|
+
}
|
|
1716
|
+
async function fr(e) {
|
|
1717
|
+
const {
|
|
1718
|
+
id: t,
|
|
1719
|
+
target: r,
|
|
1720
|
+
form: n,
|
|
1721
|
+
bus: i,
|
|
1722
|
+
validator: o,
|
|
1723
|
+
validateOnSubmit: a,
|
|
1724
|
+
action: s,
|
|
1725
|
+
submitter: l,
|
|
1726
|
+
waitForSubmitDelay: d,
|
|
1727
|
+
onRefreshTokensAfterSubmit: p,
|
|
1728
|
+
dispatchSubmitResult: y
|
|
1729
|
+
} = e;
|
|
1730
|
+
dr(n), rr(n, l || null);
|
|
1731
|
+
let c = {
|
|
1732
|
+
ok: !1,
|
|
1733
|
+
code: "SUBMIT_ERROR",
|
|
1734
|
+
message: "Submission failed.",
|
|
1735
|
+
formErrors: ["Submission failed."]
|
|
1736
|
+
};
|
|
1737
|
+
try {
|
|
1738
|
+
await d(n), c = await Zt(n, s, i, {
|
|
1739
|
+
validator: o,
|
|
1740
|
+
validateOnSubmit: a
|
|
1741
|
+
}), Me(n, c), Bn(n, c, s), li(c) && await p(c), y(c);
|
|
1742
|
+
} catch (u) {
|
|
1743
|
+
c = {
|
|
1744
|
+
ok: !1,
|
|
1745
|
+
code: "SUBMIT_ERROR",
|
|
1746
|
+
message: u instanceof Error ? u.message : "Submission failed.",
|
|
1747
|
+
formErrors: [u instanceof Error ? u.message : "Submission failed."]
|
|
1748
|
+
}, Me(n, c), y(c), si.warn("Submit failed with exception.", {
|
|
1749
|
+
id: t,
|
|
1750
|
+
action: s,
|
|
1751
|
+
target: r,
|
|
1752
|
+
error: u instanceof Error ? u.message : u
|
|
1753
|
+
});
|
|
1754
|
+
} finally {
|
|
1755
|
+
cr(c) || Te(n);
|
|
1756
|
+
}
|
|
1757
|
+
return c;
|
|
1758
|
+
}
|
|
1759
|
+
class mr {
|
|
1760
|
+
constructor() {
|
|
1761
|
+
this.modules = /* @__PURE__ */ new Map();
|
|
1762
|
+
}
|
|
1763
|
+
register(t, r = {}) {
|
|
1764
|
+
const n = this.modules.get(t.id);
|
|
1765
|
+
return n === t ? !0 : n && !r.replace ? (console.warn(
|
|
1766
|
+
`[formie] Module "${t.id}" is already registered. Pass { replace: true } to override the existing definition.`
|
|
1767
|
+
), !1) : (this.modules.set(t.id, t), !0);
|
|
1768
|
+
}
|
|
1769
|
+
unregister(t) {
|
|
1770
|
+
this.modules.delete(t);
|
|
1771
|
+
}
|
|
1772
|
+
get(t) {
|
|
1773
|
+
return this.modules.get(t) || null;
|
|
1774
|
+
}
|
|
1775
|
+
getAll() {
|
|
1776
|
+
return Array.from(this.modules.values());
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
const ui = {
|
|
1780
|
+
// Address providers stay behind lazy importer entries because their SDKs are
|
|
1781
|
+
// optional and often much heavier than the base form client.
|
|
1782
|
+
"address-finder": () => import("./address-finder-CQW81kY0.js").then((e) => e.addressFinderModule),
|
|
1783
|
+
"google-address": () => import("./google-address-BcTBncyS.js").then((e) => e.googleAddressModule),
|
|
1784
|
+
loqate: () => import("./loqate-nXuTX7In.js").then((e) => e.loqateModule),
|
|
1785
|
+
"place-kit": () => import("./place-kit-Dg6f_UoM.js").then((e) => e.placeKitModule)
|
|
1786
|
+
}, ci = {
|
|
1787
|
+
// Module ids map directly to importer functions so the loader can fetch only
|
|
1788
|
+
// the captcha chunks required by the current form manifest.
|
|
1789
|
+
"captcha-eu": () => import("./captcha-eu-DIa6aUWz.js").then((e) => e.captchaEuModule),
|
|
1790
|
+
"friendly-captcha-v1": () => import("./friendly-captcha-v1-DA2QPKA3.js").then((e) => e.friendlyCaptchaV1Module),
|
|
1791
|
+
"friendly-captcha-v2": () => import("./friendly-captcha-v2-BorOWiz_.js").then((e) => e.friendlyCaptchaV2Module),
|
|
1792
|
+
hcaptcha: () => import("./hcaptcha-BchdVCqq.js").then((e) => e.hcaptchaModule),
|
|
1793
|
+
"recaptcha-enterprise": () => import("./recaptcha-enterprise--VYAeeqz.js").then((e) => e.recaptchaEnterpriseModule),
|
|
1794
|
+
"recaptcha-v2-checkbox": () => import("./recaptcha-v2-checkbox-atBNe5ml.js").then((e) => e.recaptchaV2CheckboxModule),
|
|
1795
|
+
"recaptcha-v2-invisible": () => import("./recaptcha-v2-invisible-DnBufNPT.js").then((e) => e.recaptchaV2InvisibleModule),
|
|
1796
|
+
"recaptcha-v3": () => import("./recaptcha-v3-CF6O8rDj.js").then((e) => e.recaptchaV3Module),
|
|
1797
|
+
snaptcha: () => import("./snaptcha-C7qQo02f.js").then((e) => e.snaptchaModule),
|
|
1798
|
+
turnstile: () => import("./turnstile-_uCRwnU-.js").then((e) => e.turnstileModule)
|
|
1799
|
+
}, di = {
|
|
1800
|
+
// Keep the builtin map flat and explicit so manifest ids remain the source of
|
|
1801
|
+
// truth for lazy-loading first-party field enhancements.
|
|
1802
|
+
calculations: () => import("./calculations-BqZsENCq.js").then((e) => e.calculationsModule),
|
|
1803
|
+
"checkbox-radio": () => import("./checkbox-radio-BI-UjgMF.js").then((e) => e.checkboxRadioModule),
|
|
1804
|
+
conditions: () => import("./conditions-BVl6jTYo.js").then((e) => e.conditionsModule),
|
|
1805
|
+
"date-picker": () => import("./date-picker-69TgvErA.js").then((e) => e.datePickerModule),
|
|
1806
|
+
"file-upload": () => import("./file-upload-BDZZftgL.js").then((e) => e.fileUploadModule),
|
|
1807
|
+
hidden: () => import("./hidden-D8RqSPt7.js").then((e) => e.hiddenModule),
|
|
1808
|
+
"phone-country": () => import("./phone-country-K9pYAlzM.js").then((e) => e.phoneCountryModule),
|
|
1809
|
+
repeater: () => import("./repeater-CB7Yojvx.js").then((e) => e.repeaterModule),
|
|
1810
|
+
"rich-text": () => import("./rich-text-nAV_SQZo.js").then((e) => e.richTextModule),
|
|
1811
|
+
signature: () => import("./signature-BT6CsQ6n.js").then((e) => e.signatureModule),
|
|
1812
|
+
summary: () => import("./summary-DC_ipXCU.js").then((e) => e.summaryModule),
|
|
1813
|
+
table: () => import("./table-BEAI99qo.js").then((e) => e.tableModule),
|
|
1814
|
+
"text-limit": () => import("./text-limit-Blgq5G-G.js").then((e) => e.textLimitModule)
|
|
1815
|
+
}, fi = {
|
|
1816
|
+
// Keep payment providers lazy and separately addressable so forms only ship
|
|
1817
|
+
// the payment SDK wrapper code they actually declare in their manifest.
|
|
1818
|
+
bpoint: () => import("./bpoint-D8OjLmsn.js").then((e) => e.bpointModule),
|
|
1819
|
+
eway: () => import("./eway-1GPxH6DU.js").then((e) => e.ewayModule),
|
|
1820
|
+
"go-cardless": () => import("./go-cardless-DwBgERcA.js").then((e) => e.goCardlessModule),
|
|
1821
|
+
mollie: () => import("./mollie-qdCynQCd.js").then((e) => e.mollieModule),
|
|
1822
|
+
moneris: () => import("./moneris-BNEA-laO.js").then((e) => e.monerisModule),
|
|
1823
|
+
opayo: () => import("./opayo-BJtXOkuK.js").then((e) => e.opayoModule),
|
|
1824
|
+
paddle: () => import("./paddle-D72Pa8kr.js").then((e) => e.paddleModule),
|
|
1825
|
+
paypal: () => import("./paypal-Cqt2bned.js").then((e) => e.paypalModule),
|
|
1826
|
+
payway: () => import("./payway-BjCqsc0H.js").then((e) => e.paywayModule),
|
|
1827
|
+
square: () => import("./square-C5AH3trb.js").then((e) => e.squareModule),
|
|
1828
|
+
stripe: () => import("./stripe-EJK0RyUv.js").then((e) => e.stripeModule)
|
|
1829
|
+
}, mi = {
|
|
1830
|
+
...di,
|
|
1831
|
+
...ui,
|
|
1832
|
+
...ci,
|
|
1833
|
+
...fi
|
|
1834
|
+
}, Oe = /* @__PURE__ */ new Map(), D = _("general", "loader"), pi = new Function("src", "return import(src);");
|
|
1835
|
+
async function be(e, t, r, n) {
|
|
1836
|
+
await e(Hr(r), n), await e(Or(t, r), n);
|
|
1837
|
+
}
|
|
1838
|
+
function pr(e) {
|
|
1839
|
+
return !!e && typeof e == "object" && typeof e.id == "string" && typeof e.setup == "function" && typeof e.match == "function";
|
|
1840
|
+
}
|
|
1841
|
+
async function gi(e, t) {
|
|
1842
|
+
const r = mi[e];
|
|
1843
|
+
return r ? (Oe.has(e) || Oe.set(e, (async () => {
|
|
1844
|
+
try {
|
|
1845
|
+
const n = await r();
|
|
1846
|
+
return pr(n) ? (t.registry.register(n), n) : null;
|
|
1847
|
+
} catch (n) {
|
|
1848
|
+
return console.error("[formie] Failed to load builtin module:", e, n), D.warn("Failed loading builtin module.", { moduleId: e, error: n }), null;
|
|
1849
|
+
}
|
|
1850
|
+
})()), Oe.get(e) || null) : null;
|
|
1851
|
+
}
|
|
1852
|
+
async function hi(e) {
|
|
1853
|
+
try {
|
|
1854
|
+
const t = await pi(e), r = t?.default || t?.formieModule || null;
|
|
1855
|
+
return pr(r) ? r : null;
|
|
1856
|
+
} catch (t) {
|
|
1857
|
+
return console.error("[formie] Failed to load module from src:", e, t), D.warn("Failed loading module from src.", { src: e, error: t }), null;
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
async function bi(e, t) {
|
|
1861
|
+
const r = t.registry.get(e.id);
|
|
1862
|
+
if (r)
|
|
1863
|
+
return r;
|
|
1864
|
+
const n = await gi(e.id, t);
|
|
1865
|
+
if (n)
|
|
1866
|
+
return n;
|
|
1867
|
+
if (e.src) {
|
|
1868
|
+
const i = await hi(e.src);
|
|
1869
|
+
if (i)
|
|
1870
|
+
return t.registry.register(i), i;
|
|
1871
|
+
}
|
|
1872
|
+
return null;
|
|
1873
|
+
}
|
|
1874
|
+
function He(e) {
|
|
1875
|
+
return typeof window.CSS?.escape == "function" ? window.CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
|
|
1876
|
+
}
|
|
1877
|
+
function ye(e, t) {
|
|
1878
|
+
return e.matches(t) ? [e, ...Array.from(e.querySelectorAll(t))] : Array.from(e.querySelectorAll(t));
|
|
1879
|
+
}
|
|
1880
|
+
function yi(e, t) {
|
|
1881
|
+
const r = t.setupContext.root, n = t.setupContext.form, i = e.targetType, o = e.targetId;
|
|
1882
|
+
return i === "selector" ? ye(r, o).map((a) => ({ scope: i, element: a })) : i === "field" ? ye(r, `[data-formie-field-handle="${He(o)}"]`).map((a) => ({ scope: i, element: a })) : i === "page" ? ye(r, `[data-formie-page-id="${He(o)}"]`).map((a) => ({ scope: i, element: a })) : i === "button" ? ye(r, `[data-formie-action="${He(o)}"]`).map((a) => ({ scope: i, element: a })) : [{
|
|
1883
|
+
scope: "form",
|
|
1884
|
+
element: n || r
|
|
1885
|
+
}];
|
|
1886
|
+
}
|
|
1887
|
+
function vi(e, t) {
|
|
1888
|
+
return (e.targets && e.targets.length > 0 ? e.targets : [{
|
|
1889
|
+
targetType: "form",
|
|
1890
|
+
targetId: "form"
|
|
1891
|
+
}]).flatMap((n) => yi(n, t));
|
|
1892
|
+
}
|
|
1893
|
+
async function gr(e, t) {
|
|
1894
|
+
const r = [];
|
|
1895
|
+
D.log("Loading module manifest.", {
|
|
1896
|
+
manifestCount: e.length
|
|
1897
|
+
});
|
|
1898
|
+
for (const n of e) {
|
|
1899
|
+
const i = await bi(n, t);
|
|
1900
|
+
if (!i) {
|
|
1901
|
+
D.warn("Skipping manifest item (definition not resolved).", {
|
|
1902
|
+
moduleId: n.id,
|
|
1903
|
+
src: n.src
|
|
1904
|
+
});
|
|
1905
|
+
continue;
|
|
1906
|
+
}
|
|
1907
|
+
const o = vi(n, t);
|
|
1908
|
+
D.log("Resolved module targets.", {
|
|
1909
|
+
moduleId: i.id,
|
|
1910
|
+
targets: n.targets || [],
|
|
1911
|
+
targetCount: o.length
|
|
1912
|
+
}), o.length === 0 && i.kind === "address" && console.warn(
|
|
1913
|
+
`[formie] Address module "${n.id}" skipped: no target element found for fieldHandle="${n.targets?.find((a) => a.targetType === "field")?.targetId ?? "?"}". Check that the Address field exists in the rendered form.`
|
|
1914
|
+
);
|
|
1915
|
+
for (const a of o) {
|
|
1916
|
+
const s = {
|
|
1917
|
+
...t.matchContext,
|
|
1918
|
+
target: a.element,
|
|
1919
|
+
scope: a.scope,
|
|
1920
|
+
manifestItem: n
|
|
1921
|
+
};
|
|
1922
|
+
if (!i.match(s)) {
|
|
1923
|
+
i.kind === "address" && console.warn(
|
|
1924
|
+
`[formie] Address module "${i.id}" skipped: target element does not contain [data-formie-address-autocomplete-input]. Enable the Auto-Complete subfield.`
|
|
1925
|
+
), D.log("Module target did not match predicate.", {
|
|
1926
|
+
moduleId: i.id,
|
|
1927
|
+
scope: a.scope
|
|
1928
|
+
});
|
|
1929
|
+
continue;
|
|
1930
|
+
}
|
|
1931
|
+
const l = n.config || t.setupContext.options, d = i.id, p = {
|
|
1932
|
+
moduleId: i.id,
|
|
1933
|
+
moduleKind: i.kind,
|
|
1934
|
+
target: a.element,
|
|
1935
|
+
scope: a.scope,
|
|
1936
|
+
options: l,
|
|
1937
|
+
manifestItem: n
|
|
1938
|
+
};
|
|
1939
|
+
await be(t.setupContext.emit, d, "before-setup", p);
|
|
1940
|
+
let y = null;
|
|
1941
|
+
try {
|
|
1942
|
+
const c = await i.setup({
|
|
1943
|
+
...t.setupContext,
|
|
1944
|
+
target: a.element,
|
|
1945
|
+
scope: a.scope,
|
|
1946
|
+
options: l
|
|
1947
|
+
});
|
|
1948
|
+
c && (y = c);
|
|
1949
|
+
} catch (c) {
|
|
1950
|
+
console.error(`[formie] Module "${i.id}" setup failed:`, c), D.warn("Module setup failed.", {
|
|
1951
|
+
moduleId: i.id,
|
|
1952
|
+
scope: a.scope,
|
|
1953
|
+
error: c
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
await be(t.setupContext.emit, d, "after-setup", {
|
|
1957
|
+
...p,
|
|
1958
|
+
instanceCreated: !!y
|
|
1959
|
+
}), y && (D.log("Module instance created.", {
|
|
1960
|
+
moduleId: i.id,
|
|
1961
|
+
scope: a.scope
|
|
1962
|
+
}), r.push({
|
|
1963
|
+
...y,
|
|
1964
|
+
destroy: async () => {
|
|
1965
|
+
D.log("Destroying module instance.", {
|
|
1966
|
+
moduleId: i.id,
|
|
1967
|
+
scope: a.scope
|
|
1968
|
+
}), await be(t.setupContext.emit, d, "before-destroy", p), await y.destroy(), await be(t.setupContext.emit, d, "after-destroy", p), D.log("Module instance destroyed.", {
|
|
1969
|
+
moduleId: i.id,
|
|
1970
|
+
scope: a.scope
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
}));
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
return D.log("Module manifest processing complete.", {
|
|
1977
|
+
instanceCount: r.length
|
|
1978
|
+
}), r;
|
|
1979
|
+
}
|
|
1980
|
+
const Ei = /* @__PURE__ */ new Set([
|
|
1981
|
+
"CRAFT_CSRF_TOKEN",
|
|
1982
|
+
"action",
|
|
1983
|
+
"redirect",
|
|
1984
|
+
"requestToken",
|
|
1985
|
+
"renderId",
|
|
1986
|
+
"submitAction",
|
|
1987
|
+
"pageId",
|
|
1988
|
+
"draftContextToken",
|
|
1989
|
+
"draftContext",
|
|
1990
|
+
"continuationToken"
|
|
1991
|
+
]);
|
|
1992
|
+
function Be(e, t) {
|
|
1993
|
+
if (e == null)
|
|
1994
|
+
return String(e);
|
|
1995
|
+
if (typeof e == "string")
|
|
1996
|
+
return JSON.stringify(e);
|
|
1997
|
+
if (typeof e == "number" || typeof e == "boolean")
|
|
1998
|
+
return String(e);
|
|
1999
|
+
if (typeof e == "function")
|
|
2000
|
+
return "[function]";
|
|
2001
|
+
if (typeof File < "u" && e instanceof File)
|
|
2002
|
+
return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
2003
|
+
if (typeof Blob < "u" && e instanceof Blob)
|
|
2004
|
+
return `[blob:${e.size}:${e.type}]`;
|
|
2005
|
+
if (Array.isArray(e))
|
|
2006
|
+
return `[${e.map((r) => Be(r, t)).join(",")}]`;
|
|
2007
|
+
if (typeof e == "object") {
|
|
2008
|
+
if (t.has(e))
|
|
2009
|
+
return "[circular]";
|
|
2010
|
+
t.add(e);
|
|
2011
|
+
const r = Object.entries(e).sort(([n], [i]) => n.localeCompare(i)).map(([n, i]) => `${JSON.stringify(n)}:${Be(i, t)}`);
|
|
2012
|
+
return t.delete(e), `{${r.join(",")}}`;
|
|
2013
|
+
}
|
|
2014
|
+
return JSON.stringify(String(e));
|
|
2015
|
+
}
|
|
2016
|
+
function Si(e) {
|
|
2017
|
+
return Be(e, /* @__PURE__ */ new WeakSet());
|
|
2018
|
+
}
|
|
2019
|
+
function Ai(e) {
|
|
2020
|
+
if (!e)
|
|
2021
|
+
return !1;
|
|
2022
|
+
const t = e.endsWith("[]") ? e.slice(0, -2) : e;
|
|
2023
|
+
return !Ei.has(t);
|
|
2024
|
+
}
|
|
2025
|
+
function Tt(e) {
|
|
2026
|
+
const t = Array.from(new FormData(e).entries()).filter(([r]) => Ai(String(r || "")));
|
|
2027
|
+
return Si(t);
|
|
2028
|
+
}
|
|
2029
|
+
function wi(e, t = {}) {
|
|
2030
|
+
let r = null, n = !1, i = !1, o = null, a = null, s = null;
|
|
2031
|
+
const l = () => {
|
|
2032
|
+
o !== null && (window.cancelAnimationFrame(o), o = null), a !== null && (window.clearTimeout(a), a = null), s !== null && (window.clearTimeout(s), s = null);
|
|
2033
|
+
}, d = () => n ? (i = Tt(e) !== r, i) : !1, p = () => {
|
|
2034
|
+
r = Tt(e), n = !0, i = !1;
|
|
2035
|
+
}, y = () => {
|
|
2036
|
+
l(), n = !1, o = window.requestAnimationFrame(() => {
|
|
2037
|
+
o = null, s = window.setTimeout(() => {
|
|
2038
|
+
s = null, p();
|
|
2039
|
+
}, 0);
|
|
2040
|
+
});
|
|
2041
|
+
}, c = () => {
|
|
2042
|
+
a !== null && window.clearTimeout(a), a = window.setTimeout(() => {
|
|
2043
|
+
a = null, d();
|
|
2044
|
+
}, 120);
|
|
2045
|
+
}, u = (h) => {
|
|
2046
|
+
t.shouldWarn && !t.shouldWarn() || d() && (h.preventDefault(), h.returnValue = "");
|
|
2047
|
+
};
|
|
2048
|
+
return e.addEventListener("input", c), e.addEventListener("change", c), window.addEventListener("beforeunload", u), y(), {
|
|
2049
|
+
captureBaseline: p,
|
|
2050
|
+
scheduleBaselineCapture: y,
|
|
2051
|
+
refreshDirtyState: d,
|
|
2052
|
+
destroy: () => {
|
|
2053
|
+
l(), e.removeEventListener("input", c), e.removeEventListener("change", c), window.removeEventListener("beforeunload", u);
|
|
2054
|
+
}
|
|
2055
|
+
};
|
|
2056
|
+
}
|
|
2057
|
+
const X = '[data-formie]:not([data-formie-init="false"]), [data-formie-form]:not([data-formie-init="false"])', Ti = 300, Ci = "/actions/formie/server/forms/render", Ct = "/api", Mi = "/actions/formie/server/forms/refresh-tokens", Li = "/actions/formie/server/submissions/submit", Ii = "/actions/formie/server/submissions/set-page", Fi = "/actions/formie/server/submissions/clear-submission", Ri = "/actions/formie/file-upload/hydrate", L = _("general", "client"), Mt = /* @__PURE__ */ new Set();
|
|
2058
|
+
function ce(e, t) {
|
|
2059
|
+
if (e == null || e === "")
|
|
2060
|
+
return t;
|
|
2061
|
+
const r = e.toLowerCase();
|
|
2062
|
+
return !(r === "false" || r === "0" || r === "off");
|
|
2063
|
+
}
|
|
2064
|
+
function We(e) {
|
|
2065
|
+
return e.formieRefreshTokens != null && e.formieRefreshTokens !== "" ? ce(e.formieRefreshTokens, !1) : e.formieStaticCache != null && e.formieStaticCache !== "" ? ce(e.formieStaticCache, !1) : !1;
|
|
2066
|
+
}
|
|
2067
|
+
function ee(e) {
|
|
2068
|
+
const t = e instanceof HTMLElement ? e.dataset : {};
|
|
2069
|
+
return {
|
|
2070
|
+
mode: "server-rendered",
|
|
2071
|
+
transport: t.formieTransport || "rest",
|
|
2072
|
+
formHandle: t.formieHandle,
|
|
2073
|
+
endpoint: t.formieEndpoint,
|
|
2074
|
+
staticCache: We(t),
|
|
2075
|
+
autoVisible: ce(t.formieAutoVisible, !0),
|
|
2076
|
+
compatibility: ce(t.formieCompatibility, !1)
|
|
2077
|
+
};
|
|
2078
|
+
}
|
|
2079
|
+
function Fe(e) {
|
|
2080
|
+
return e || "server-rendered";
|
|
2081
|
+
}
|
|
2082
|
+
function Re(e) {
|
|
2083
|
+
return e || "rest";
|
|
2084
|
+
}
|
|
2085
|
+
function Ee(e) {
|
|
2086
|
+
return e instanceof HTMLFormElement ? e : e.querySelector("form");
|
|
2087
|
+
}
|
|
2088
|
+
function ki(e, t) {
|
|
2089
|
+
Mt.has(e) || (Mt.add(e), L.warn(t));
|
|
2090
|
+
}
|
|
2091
|
+
function hr(e, t) {
|
|
2092
|
+
if (!e)
|
|
2093
|
+
return e;
|
|
2094
|
+
try {
|
|
2095
|
+
return new URL(e).toString();
|
|
2096
|
+
} catch {
|
|
2097
|
+
}
|
|
2098
|
+
if (!t)
|
|
2099
|
+
return e;
|
|
2100
|
+
try {
|
|
2101
|
+
return new URL(e, t).toString();
|
|
2102
|
+
} catch {
|
|
2103
|
+
return e;
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
function re(e, t) {
|
|
2107
|
+
const r = (e || "").trim();
|
|
2108
|
+
return r ? r.includes("/actions/") ? r : hr(t, r) : t;
|
|
2109
|
+
}
|
|
2110
|
+
function qi(e, t) {
|
|
2111
|
+
return re(e.endpoint || t.dataset.formieEndpoint, Ci);
|
|
2112
|
+
}
|
|
2113
|
+
function Pi(e, t) {
|
|
2114
|
+
const r = (e.endpoint || t.dataset.formieEndpoint || "").trim();
|
|
2115
|
+
return r ? r.includes("/graphql") || r.endsWith("/api") || r.includes("/actions/graphql/") ? r : hr(Ct, r) : Ct;
|
|
2116
|
+
}
|
|
2117
|
+
function lt(e, t) {
|
|
2118
|
+
return re(
|
|
2119
|
+
t.dataset.formieRefreshTokensEndpoint || e.endpoint || t.dataset.formieEndpoint,
|
|
2120
|
+
Mi
|
|
2121
|
+
);
|
|
2122
|
+
}
|
|
2123
|
+
function Lt(e, t) {
|
|
2124
|
+
if (!e)
|
|
2125
|
+
return t;
|
|
2126
|
+
try {
|
|
2127
|
+
const r = new URL(e, window.location.origin), n = new URL(t, window.location.origin);
|
|
2128
|
+
return r.searchParams.forEach((i, o) => {
|
|
2129
|
+
n.searchParams.has(o) || n.searchParams.set(o, i);
|
|
2130
|
+
}), n.toString();
|
|
2131
|
+
} catch {
|
|
2132
|
+
return t;
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
function $i(e, t, r) {
|
|
2136
|
+
const n = r.endpoint || e.dataset.formieEndpoint, i = re(n, Li), o = t.getAttribute("action");
|
|
2137
|
+
t.setAttribute("action", Lt(o, i)), t.querySelectorAll("[data-formie-tab-link]").forEach((a) => {
|
|
2138
|
+
const s = a.getAttribute("href"), l = re(n, Ii);
|
|
2139
|
+
a.setAttribute("href", Lt(s, l));
|
|
2140
|
+
}), t.querySelectorAll("[data-formie-file-upload-hydrate-endpoint]").forEach((a) => {
|
|
2141
|
+
a.setAttribute(
|
|
2142
|
+
"data-formie-file-upload-hydrate-endpoint",
|
|
2143
|
+
re(n, Ri)
|
|
2144
|
+
);
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
function ut(e, t) {
|
|
2148
|
+
if (e === "graphql" && t !== "server-rendered")
|
|
2149
|
+
throw new Error(`Formie ${t} mode does not support GraphQL transport yet.`);
|
|
2150
|
+
}
|
|
2151
|
+
function ct(e) {
|
|
2152
|
+
if (e == null)
|
|
2153
|
+
return !1;
|
|
2154
|
+
const t = e.trim().toLowerCase();
|
|
2155
|
+
return t === "true" || t === "1" || t === "";
|
|
2156
|
+
}
|
|
2157
|
+
function Vi(e) {
|
|
2158
|
+
return ce(e.dataset.formieAutomaticSubmissionState, !0);
|
|
2159
|
+
}
|
|
2160
|
+
function Oi(e, t, r) {
|
|
2161
|
+
return re(
|
|
2162
|
+
r.dataset.formieClearSubmissionEndpoint || e.endpoint || t.dataset.formieEndpoint,
|
|
2163
|
+
Fi
|
|
2164
|
+
);
|
|
2165
|
+
}
|
|
2166
|
+
function Hi(e) {
|
|
2167
|
+
return ct(e.dataset.formieUnloadWarning);
|
|
2168
|
+
}
|
|
2169
|
+
function It(e, t) {
|
|
2170
|
+
e.setAttribute("data-formie-internal-navigation", t);
|
|
2171
|
+
}
|
|
2172
|
+
function _e(e) {
|
|
2173
|
+
e.removeAttribute("data-formie-internal-navigation");
|
|
2174
|
+
}
|
|
2175
|
+
function Ft(e) {
|
|
2176
|
+
return e.getAttribute("data-formie-internal-navigation") !== null;
|
|
2177
|
+
}
|
|
2178
|
+
function Rt(e, t) {
|
|
2179
|
+
if (!e)
|
|
2180
|
+
return !1;
|
|
2181
|
+
try {
|
|
2182
|
+
return new URL(e, window.location.origin).searchParams.has(t);
|
|
2183
|
+
} catch {
|
|
2184
|
+
return !1;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
function _i(e) {
|
|
2188
|
+
return Rt(window.location.href, "resumeToken") || Rt(e.getAttribute("action"), "resumeToken");
|
|
2189
|
+
}
|
|
2190
|
+
function Di(e) {
|
|
2191
|
+
return e instanceof MouseEvent ? e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey : !0;
|
|
2192
|
+
}
|
|
2193
|
+
function xi(e, t = 0) {
|
|
2194
|
+
if (!e)
|
|
2195
|
+
return t;
|
|
2196
|
+
const r = Number.parseInt(e, 10);
|
|
2197
|
+
return Number.isFinite(r) ? r : t;
|
|
2198
|
+
}
|
|
2199
|
+
function Ni(e) {
|
|
2200
|
+
return Math.max(0, xi(e.dataset.formieSubmitDelay, Ti));
|
|
2201
|
+
}
|
|
2202
|
+
function Ke(e) {
|
|
2203
|
+
return ct(e.dataset.formieValidationOnSubmit);
|
|
2204
|
+
}
|
|
2205
|
+
async function Ge(e) {
|
|
2206
|
+
const t = Ni(e);
|
|
2207
|
+
t < 1 || await new Promise((r) => {
|
|
2208
|
+
window.setTimeout(r, t);
|
|
2209
|
+
});
|
|
2210
|
+
}
|
|
2211
|
+
function kt(e, t) {
|
|
2212
|
+
const r = e?.getAttribute(t)?.trim();
|
|
2213
|
+
if (!r)
|
|
2214
|
+
return null;
|
|
2215
|
+
try {
|
|
2216
|
+
return JSON.parse(r);
|
|
2217
|
+
} catch (n) {
|
|
2218
|
+
return console.error(`[formie] Failed to parse ${t}.`, n), null;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
function qt(e, t) {
|
|
2222
|
+
const r = t || (e instanceof HTMLFormElement ? e : null);
|
|
2223
|
+
if (!r)
|
|
2224
|
+
return null;
|
|
2225
|
+
const n = kt(r, "data-formie-modules"), i = kt(r, "data-formie-theme");
|
|
2226
|
+
return !n && !i ? null : {
|
|
2227
|
+
modules: n || void 0,
|
|
2228
|
+
theme: i || void 0
|
|
2229
|
+
};
|
|
2230
|
+
}
|
|
2231
|
+
function Ui(e) {
|
|
2232
|
+
if (!(e instanceof HTMLElement))
|
|
2233
|
+
return !0;
|
|
2234
|
+
if (!e.isConnected || e.hidden || e.closest("[hidden]"))
|
|
2235
|
+
return !1;
|
|
2236
|
+
const t = window.getComputedStyle(e);
|
|
2237
|
+
return t.display === "none" || t.visibility === "hidden" ? !1 : e.getClientRects().length > 0;
|
|
2238
|
+
}
|
|
2239
|
+
function zi(e, t) {
|
|
2240
|
+
return t === document ? !0 : t instanceof Element ? t === e || t.contains(e) : !0;
|
|
2241
|
+
}
|
|
2242
|
+
function P(e) {
|
|
2243
|
+
const t = e, r = t.id ? `#${t.id}` : "", n = t.dataset?.formieHandle ? `[handle="${t.dataset.formieHandle}"]` : "";
|
|
2244
|
+
return `${t.tagName ? t.tagName.toLowerCase() : "element"}${r}${n}`;
|
|
2245
|
+
}
|
|
2246
|
+
function dt(e, t) {
|
|
2247
|
+
if (t) {
|
|
2248
|
+
if (t.csrf?.param && t.csrf?.token) {
|
|
2249
|
+
const r = e.querySelector(`input[name="${t.csrf.param}"]`);
|
|
2250
|
+
r && (r.value = t.csrf.token);
|
|
2251
|
+
}
|
|
2252
|
+
if (t.requestToken) {
|
|
2253
|
+
const r = e.querySelector('input[name="requestToken"]');
|
|
2254
|
+
r && (r.value = t.requestToken);
|
|
2255
|
+
}
|
|
2256
|
+
if (t.renderId) {
|
|
2257
|
+
const r = e.querySelector('input[name="renderId"]');
|
|
2258
|
+
r && (r.value = t.renderId);
|
|
2259
|
+
}
|
|
2260
|
+
t.captchas && typeof t.captchas == "object" && Object.values(t.captchas).forEach((r) => {
|
|
2261
|
+
if (!r || typeof r != "object")
|
|
2262
|
+
return;
|
|
2263
|
+
const n = r;
|
|
2264
|
+
if (!n.sessionKey)
|
|
2265
|
+
return;
|
|
2266
|
+
const i = e.querySelector(`input[name="${n.sessionKey}"]`);
|
|
2267
|
+
i && typeof n.value == "string" && (i.value = n.value);
|
|
2268
|
+
});
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
async function ji(e, t) {
|
|
2272
|
+
const r = Fe(t.mode), n = Re(t.transport);
|
|
2273
|
+
if (r !== "server-rendered")
|
|
2274
|
+
return null;
|
|
2275
|
+
if (t.payload)
|
|
2276
|
+
return t.payload.html && (e.innerHTML = t.payload.html), t.payload;
|
|
2277
|
+
ut(n, r);
|
|
2278
|
+
const i = !!Ee(e), o = t.formHandle || e.dataset.formieHandle;
|
|
2279
|
+
if (i || !o)
|
|
2280
|
+
return null;
|
|
2281
|
+
const a = {
|
|
2282
|
+
mode: r,
|
|
2283
|
+
endpoint: t.endpoint,
|
|
2284
|
+
locale: t.locale,
|
|
2285
|
+
siteId: t.siteId,
|
|
2286
|
+
theme: t.theme,
|
|
2287
|
+
themeConfig: t.themeConfig
|
|
2288
|
+
}, s = n === "graphql" ? Pi(t, e) : qi(t, e), l = n === "graphql" ? await an(s, o, a) : await on(s, o, {
|
|
2289
|
+
...a,
|
|
2290
|
+
endpoint: s
|
|
2291
|
+
});
|
|
2292
|
+
return l?.html && (e.innerHTML = l.html), l;
|
|
2293
|
+
}
|
|
2294
|
+
async function br(e, t, r) {
|
|
2295
|
+
if (t.refreshTokens === !1)
|
|
2296
|
+
return;
|
|
2297
|
+
ut(Re(t.transport), Fe(t.mode));
|
|
2298
|
+
const n = t.formHandle || e.dataset.formieHandle;
|
|
2299
|
+
if (!n)
|
|
2300
|
+
return;
|
|
2301
|
+
const i = lt(t, e), a = r.querySelector('input[name="renderId"]')?.value || void 0, s = await tt(i, n, a);
|
|
2302
|
+
dt(r, s), I(e, "formie:refresh-tokens:refreshed", s);
|
|
2303
|
+
}
|
|
2304
|
+
function Bi(e, t, r, n, i, o) {
|
|
2305
|
+
const a = String(
|
|
2306
|
+
t.dataset.formieSubmitMethod || ""
|
|
2307
|
+
).trim().toLowerCase(), s = Oi(r, e, t);
|
|
2308
|
+
let l = !1;
|
|
2309
|
+
const d = t.querySelectorAll("[data-formie-action]"), p = (u) => {
|
|
2310
|
+
if (u) {
|
|
2311
|
+
t.setAttribute("data-formie-pending-action", u);
|
|
2312
|
+
return;
|
|
2313
|
+
}
|
|
2314
|
+
t.removeAttribute("data-formie-pending-action");
|
|
2315
|
+
};
|
|
2316
|
+
if (Hi(t)) {
|
|
2317
|
+
const u = wi(t, {
|
|
2318
|
+
shouldWarn: () => !Ft(t)
|
|
2319
|
+
}), h = (f) => {
|
|
2320
|
+
if (!(f instanceof CustomEvent))
|
|
2321
|
+
return;
|
|
2322
|
+
const v = f.detail;
|
|
2323
|
+
v?.ok && v.action === "save" && u.scheduleBaselineCapture();
|
|
2324
|
+
}, A = () => {
|
|
2325
|
+
u.scheduleBaselineCapture();
|
|
2326
|
+
};
|
|
2327
|
+
e.addEventListener("formie:submit:result", h), t.addEventListener("formie:state:reset", A), o.push(() => {
|
|
2328
|
+
e.removeEventListener("formie:submit:result", h), t.removeEventListener("formie:state:reset", A), u.destroy();
|
|
2329
|
+
});
|
|
2330
|
+
}
|
|
2331
|
+
if (d.forEach((u) => {
|
|
2332
|
+
const h = (A) => {
|
|
2333
|
+
const f = A.currentTarget.getAttribute("data-formie-action"), v = t.querySelector('input[name="submitAction"]');
|
|
2334
|
+
p(f), f && v && (v.value = f);
|
|
2335
|
+
};
|
|
2336
|
+
u.addEventListener("click", h), o.push(() => {
|
|
2337
|
+
u.removeEventListener("click", h);
|
|
2338
|
+
});
|
|
2339
|
+
}), t.querySelectorAll("[data-formie-tab-link]").forEach((u) => {
|
|
2340
|
+
const h = async (A) => {
|
|
2341
|
+
if (a !== "ajax") {
|
|
2342
|
+
Di(A) && It(t, "set-page");
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2345
|
+
A.preventDefault();
|
|
2346
|
+
const f = A.currentTarget, v = f?.getAttribute("data-formie-page-id"), E = f?.getAttribute("href");
|
|
2347
|
+
if (!(!v || !E)) {
|
|
2348
|
+
ot(t, v), I(e, "formie:page:navigate", {
|
|
2349
|
+
pageId: v,
|
|
2350
|
+
href: E
|
|
2351
|
+
});
|
|
2352
|
+
try {
|
|
2353
|
+
const b = await sn(E, t, v);
|
|
2354
|
+
I(e, "formie:page:navigate:after", {
|
|
2355
|
+
pageId: v,
|
|
2356
|
+
href: E,
|
|
2357
|
+
response: b
|
|
2358
|
+
});
|
|
2359
|
+
} catch (b) {
|
|
2360
|
+
console.error("[formie] Failed to persist page navigation state.", b), I(e, "formie:page:navigate:error", {
|
|
2361
|
+
pageId: v,
|
|
2362
|
+
href: E,
|
|
2363
|
+
error: b
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
};
|
|
2368
|
+
u.addEventListener("click", h), o.push(() => {
|
|
2369
|
+
u.removeEventListener("click", h);
|
|
2370
|
+
});
|
|
2371
|
+
}), !Vi(t)) {
|
|
2372
|
+
let u = !1;
|
|
2373
|
+
const h = () => {
|
|
2374
|
+
u || Ft(t) || _i(t) || (u = !0, ln(s, t));
|
|
2375
|
+
};
|
|
2376
|
+
window.addEventListener("pagehide", h), window.addEventListener("beforeunload", h), o.push(() => {
|
|
2377
|
+
window.removeEventListener("pagehide", h), window.removeEventListener("beforeunload", h);
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
const c = async (u) => {
|
|
2381
|
+
if (l)
|
|
2382
|
+
return;
|
|
2383
|
+
const h = a === "ajax";
|
|
2384
|
+
if (u.preventDefault(), t.getAttribute("data-formie-loading") === "true") {
|
|
2385
|
+
if (!(t.getAttribute("data-formie-internal-resubmit") === "true"))
|
|
2386
|
+
return;
|
|
2387
|
+
t.removeAttribute("data-formie-internal-resubmit");
|
|
2388
|
+
} else
|
|
2389
|
+
t.removeAttribute("data-formie-internal-resubmit");
|
|
2390
|
+
const f = u.submitter, v = f?.getAttribute("data-formie-action"), E = t.getAttribute("data-formie-pending-action"), b = t.querySelector('input[name="submitAction"]'), m = v || E || b?.value || "submit";
|
|
2391
|
+
let g = null, S = !1;
|
|
2392
|
+
try {
|
|
2393
|
+
if (h)
|
|
2394
|
+
g = await fr({
|
|
2395
|
+
target: e,
|
|
2396
|
+
form: t,
|
|
2397
|
+
bus: n,
|
|
2398
|
+
validator: i,
|
|
2399
|
+
validateOnSubmit: Ke(t),
|
|
2400
|
+
action: m,
|
|
2401
|
+
submitter: f,
|
|
2402
|
+
waitForSubmitDelay: Ge,
|
|
2403
|
+
onRefreshTokensAfterSubmit: async () => {
|
|
2404
|
+
await br(e, r, t);
|
|
2405
|
+
},
|
|
2406
|
+
dispatchSubmitResult: (C) => {
|
|
2407
|
+
I(e, "formie:submit:result", C);
|
|
2408
|
+
}
|
|
2409
|
+
});
|
|
2410
|
+
else {
|
|
2411
|
+
if (dr(t), rr(t, f), await Ge(t), g = await Zt(t, m, n, {
|
|
2412
|
+
validator: i,
|
|
2413
|
+
validateOnSubmit: Ke(t),
|
|
2414
|
+
preflightOnly: !0
|
|
2415
|
+
}), g.ok) {
|
|
2416
|
+
jt(t, m), l = !0, It(t, "submit"), p(null);
|
|
2417
|
+
let C = !1;
|
|
2418
|
+
const T = () => {
|
|
2419
|
+
C = !0, l = !1, _e(t), Te(t);
|
|
2420
|
+
};
|
|
2421
|
+
if (typeof t.requestSubmit == "function") {
|
|
2422
|
+
t.addEventListener("invalid", T, !0);
|
|
2423
|
+
try {
|
|
2424
|
+
t.requestSubmit();
|
|
2425
|
+
} finally {
|
|
2426
|
+
t.removeEventListener("invalid", T, !0);
|
|
2427
|
+
}
|
|
2428
|
+
} else
|
|
2429
|
+
t.submit();
|
|
2430
|
+
if (C)
|
|
2431
|
+
return;
|
|
2432
|
+
S = !0;
|
|
2433
|
+
return;
|
|
2434
|
+
}
|
|
2435
|
+
Me(t, g), I(e, "formie:submit:result", g), _e(t);
|
|
2436
|
+
}
|
|
2437
|
+
} catch (C) {
|
|
2438
|
+
l = !1, g = {
|
|
2439
|
+
ok: !1,
|
|
2440
|
+
code: "SUBMIT_ERROR",
|
|
2441
|
+
message: C instanceof Error ? C.message : "Submission failed.",
|
|
2442
|
+
formErrors: [C instanceof Error ? C.message : "Submission failed."]
|
|
2443
|
+
}, Me(t, g), I(e, "formie:submit:result", g), _e(t);
|
|
2444
|
+
} finally {
|
|
2445
|
+
p(null), !h && !S && !cr(g) && Te(t);
|
|
2446
|
+
}
|
|
2447
|
+
};
|
|
2448
|
+
t.addEventListener("submit", c), o.push(() => {
|
|
2449
|
+
t.removeEventListener("submit", c);
|
|
2450
|
+
});
|
|
2451
|
+
}
|
|
2452
|
+
async function Wi(e, t, r) {
|
|
2453
|
+
if (t.refreshTokens === !1 || !t.staticCache)
|
|
2454
|
+
return;
|
|
2455
|
+
ut(Re(t.transport), Fe(t.mode));
|
|
2456
|
+
const n = t.formHandle || e.dataset.formieHandle, i = lt(t, e), a = r?.querySelector('input[name="renderId"]')?.value || void 0;
|
|
2457
|
+
if (!n)
|
|
2458
|
+
return;
|
|
2459
|
+
const s = await tt(i, n, a);
|
|
2460
|
+
!s || !r || (dt(r, s), I(e, "formie:refresh-tokens:after", s));
|
|
2461
|
+
}
|
|
2462
|
+
function Ki() {
|
|
2463
|
+
const e = /* @__PURE__ */ new Map(), t = new mr(), r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), i = [
|
|
2464
|
+
"prepare",
|
|
2465
|
+
"normalize",
|
|
2466
|
+
"validate",
|
|
2467
|
+
"screen",
|
|
2468
|
+
"authorize",
|
|
2469
|
+
"dispatch",
|
|
2470
|
+
"finalize"
|
|
2471
|
+
], o = async (f) => {
|
|
2472
|
+
const v = n.get(f);
|
|
2473
|
+
if (v) {
|
|
2474
|
+
await v;
|
|
2475
|
+
return;
|
|
2476
|
+
}
|
|
2477
|
+
const E = (async () => {
|
|
2478
|
+
L.log("Unmount requested.", { target: P(f) });
|
|
2479
|
+
const b = r.get(f);
|
|
2480
|
+
b && (b(), r.delete(f));
|
|
2481
|
+
const m = e.get(f);
|
|
2482
|
+
if (!m) {
|
|
2483
|
+
L.log("Unmount skipped (no mounted state).", { target: P(f) });
|
|
2484
|
+
return;
|
|
2485
|
+
}
|
|
2486
|
+
I(f, "formie:unmount:before", {
|
|
2487
|
+
id: m.instance.id
|
|
2488
|
+
}), m.unbinds.forEach((g) => {
|
|
2489
|
+
g();
|
|
2490
|
+
}), m.unbinds = [], m.validator?.destroy(), m.validator = null;
|
|
2491
|
+
for (const g of m.modules)
|
|
2492
|
+
await g.destroy();
|
|
2493
|
+
m.modules = [], m.bus.clear(), e.delete(f), I(f, "formie:unmount:after", {
|
|
2494
|
+
id: m.instance.id
|
|
2495
|
+
}), L.log("Unmount complete.", { id: m.instance.id, target: P(f) });
|
|
2496
|
+
})().finally(() => {
|
|
2497
|
+
n.delete(f);
|
|
2498
|
+
});
|
|
2499
|
+
n.set(f, E), await E;
|
|
2500
|
+
}, a = async (f, v) => {
|
|
2501
|
+
L.log("Mount requested.", {
|
|
2502
|
+
target: P(f),
|
|
2503
|
+
mode: v.mode,
|
|
2504
|
+
autoVisible: v.autoVisible
|
|
2505
|
+
});
|
|
2506
|
+
const E = r.get(f);
|
|
2507
|
+
E && (E(), r.delete(f));
|
|
2508
|
+
const b = e.get(f);
|
|
2509
|
+
if (b)
|
|
2510
|
+
return L.log("Mount skipped (already mounted).", {
|
|
2511
|
+
id: b.instance.id,
|
|
2512
|
+
target: P(f)
|
|
2513
|
+
}), b.instance;
|
|
2514
|
+
const m = new Bt(), g = [], S = f?.id || `formie-${e.size + 1}`, C = ee(f), T = {
|
|
2515
|
+
...C,
|
|
2516
|
+
...v,
|
|
2517
|
+
mode: Fe(v.mode ?? C.mode),
|
|
2518
|
+
transport: Re(v.transport ?? C.transport)
|
|
2519
|
+
}, F = $r(T.compatibility);
|
|
2520
|
+
if (T.mode !== "server-rendered" && !Ee(f))
|
|
2521
|
+
throw new Error(`Formie ${T.mode} mode is not implemented yet in the browser client.`);
|
|
2522
|
+
const k = await ji(f, T), w = Ee(f);
|
|
2523
|
+
T.staticCache = v.staticCache ?? We(w ? w.dataset : f.dataset);
|
|
2524
|
+
const q = qt(f, w), N = k || q ? {
|
|
2525
|
+
...k || {},
|
|
2526
|
+
...q || {}
|
|
2527
|
+
} : null, B = N?.theme, Y = {}, fe = (N?.modules || []).filter((M) => !!M?.id && !!M?.type);
|
|
2528
|
+
L.log("Resolved mount payload.", {
|
|
2529
|
+
target: P(f),
|
|
2530
|
+
hasRenderPayload: !!k,
|
|
2531
|
+
hasEmbeddedPayload: !!q,
|
|
2532
|
+
moduleCount: fe.length
|
|
2533
|
+
});
|
|
2534
|
+
const ne = gt(f, B, w), $ = w ? new Rn(w, {
|
|
2535
|
+
live: ct(w.dataset.formieValidationOnFocus),
|
|
2536
|
+
errorMessage: w.dataset.formieErrorMessage || "",
|
|
2537
|
+
fieldContainerErrorClass: ne.fieldLayoutError || [],
|
|
2538
|
+
inputErrorClass: ne.fieldControlError || [],
|
|
2539
|
+
messagesClass: ne.fieldErrors || [],
|
|
2540
|
+
messageClass: ne.fieldError || []
|
|
2541
|
+
}) : null;
|
|
2542
|
+
if (w && $) {
|
|
2543
|
+
const M = w;
|
|
2544
|
+
M.formieValidation = $, Y.validation = $;
|
|
2545
|
+
const O = {
|
|
2546
|
+
validator: $,
|
|
2547
|
+
addValidator: $.addValidator.bind($),
|
|
2548
|
+
removeValidator: $.removeValidator.bind($)
|
|
2549
|
+
};
|
|
2550
|
+
I(w, "formie:validator:ready", O), I(f, "formie:validator:ready", O);
|
|
2551
|
+
}
|
|
2552
|
+
w && ((k || T.endpoint || f.dataset.formieEndpoint) && $i(f, w, T), J(w)), Object.keys(ne).length && I(f, "formie:theme:applied", {
|
|
2553
|
+
hasClasses: !0
|
|
2554
|
+
});
|
|
2555
|
+
const me = await gr(fe, {
|
|
2556
|
+
registry: t,
|
|
2557
|
+
matchContext: {
|
|
2558
|
+
root: f,
|
|
2559
|
+
form: w,
|
|
2560
|
+
mode: T.mode
|
|
2561
|
+
},
|
|
2562
|
+
setupContext: {
|
|
2563
|
+
formId: S,
|
|
2564
|
+
root: f,
|
|
2565
|
+
form: w,
|
|
2566
|
+
target: f,
|
|
2567
|
+
scope: "form",
|
|
2568
|
+
state: Y,
|
|
2569
|
+
on: (M, O) => m.on(M, O),
|
|
2570
|
+
emit: (M, O) => (I(f, M, O), m.emitSafe(M, O).then((Z) => {
|
|
2571
|
+
Z.failed.length > 0 && L.warn("Lifecycle listeners failed.", {
|
|
2572
|
+
eventName: M,
|
|
2573
|
+
failed: Z.failed.length
|
|
2574
|
+
});
|
|
2575
|
+
}))
|
|
2576
|
+
}
|
|
2577
|
+
});
|
|
2578
|
+
L.log("Module setup complete.", {
|
|
2579
|
+
target: P(f),
|
|
2580
|
+
moduleInstances: me.length
|
|
2581
|
+
});
|
|
2582
|
+
const qe = {
|
|
2583
|
+
id: S,
|
|
2584
|
+
root: f,
|
|
2585
|
+
submit: async (M = "submit") => {
|
|
2586
|
+
if (L.log("Submit requested.", {
|
|
2587
|
+
id: S,
|
|
2588
|
+
target: P(f),
|
|
2589
|
+
action: M
|
|
2590
|
+
}), !w)
|
|
2591
|
+
return {
|
|
2592
|
+
ok: !1,
|
|
2593
|
+
code: "FORM_NOT_FOUND",
|
|
2594
|
+
message: "No form element found for mount target.",
|
|
2595
|
+
formErrors: ["No form element found for mount target."]
|
|
2596
|
+
};
|
|
2597
|
+
const O = w.querySelector('input[name="submitAction"]');
|
|
2598
|
+
if (O && (O.value = M), w.getAttribute("data-formie-loading") === "true")
|
|
2599
|
+
return {
|
|
2600
|
+
ok: !1,
|
|
2601
|
+
code: "SUBMIT_IN_PROGRESS",
|
|
2602
|
+
message: "Submission already in progress.",
|
|
2603
|
+
formErrors: []
|
|
2604
|
+
};
|
|
2605
|
+
const Z = w.querySelector(`[data-formie-action="${M}"]`), Q = await fr({
|
|
2606
|
+
id: S,
|
|
2607
|
+
target: f,
|
|
2608
|
+
form: w,
|
|
2609
|
+
bus: m,
|
|
2610
|
+
validator: $,
|
|
2611
|
+
validateOnSubmit: Ke(w),
|
|
2612
|
+
action: M,
|
|
2613
|
+
submitter: Z,
|
|
2614
|
+
waitForSubmitDelay: Ge,
|
|
2615
|
+
onRefreshTokensAfterSubmit: async () => {
|
|
2616
|
+
await br(f, T, w);
|
|
2617
|
+
},
|
|
2618
|
+
dispatchSubmitResult: (Pe) => {
|
|
2619
|
+
I(f, "formie:submit:result", Pe);
|
|
2620
|
+
}
|
|
2621
|
+
});
|
|
2622
|
+
return L.log("Submit completed.", {
|
|
2623
|
+
id: S,
|
|
2624
|
+
action: M,
|
|
2625
|
+
ok: Q.ok,
|
|
2626
|
+
code: Q.code,
|
|
2627
|
+
message: Q.message
|
|
2628
|
+
}), Q;
|
|
2629
|
+
},
|
|
2630
|
+
destroy: async () => {
|
|
2631
|
+
await o(f);
|
|
2632
|
+
},
|
|
2633
|
+
on: (M, O) => m.on(M, O)
|
|
2634
|
+
};
|
|
2635
|
+
w && (zr({
|
|
2636
|
+
target: f,
|
|
2637
|
+
form: w,
|
|
2638
|
+
validatorDetail: $ ? {
|
|
2639
|
+
validator: $,
|
|
2640
|
+
addValidator: $.addValidator.bind($),
|
|
2641
|
+
removeValidator: $.removeValidator.bind($)
|
|
2642
|
+
} : null,
|
|
2643
|
+
options: F,
|
|
2644
|
+
unbinds: g
|
|
2645
|
+
}), Ur({
|
|
2646
|
+
target: f,
|
|
2647
|
+
form: w,
|
|
2648
|
+
instance: qe,
|
|
2649
|
+
options: F,
|
|
2650
|
+
unbinds: g
|
|
2651
|
+
})), w && (Bi(f, w, T, m, $, g), await Wi(f, T, w)), i.forEach((M) => {
|
|
2652
|
+
const O = m.on(`formie:stage:${M}:before`, async (W) => {
|
|
2653
|
+
I(f, `formie:stage:${M}:before`, W);
|
|
2654
|
+
}), Z = m.on(`formie:stage:${M}:before`, async (W) => {
|
|
2655
|
+
for (const ie of me)
|
|
2656
|
+
ie.onBeforeStage && await ie.onBeforeStage(W);
|
|
2657
|
+
}), Q = m.on(`formie:stage:${M}:after`, async (W) => {
|
|
2658
|
+
I(f, `formie:stage:${M}:after`, W);
|
|
2659
|
+
}), Pe = m.on(`formie:stage:${M}:after`, async (W) => {
|
|
2660
|
+
const ie = W;
|
|
2661
|
+
for (const pt of me)
|
|
2662
|
+
pt.onAfterStage && await pt.onAfterStage(ie, ie.result);
|
|
2663
|
+
});
|
|
2664
|
+
g.push(O, Z, Q, Pe);
|
|
2665
|
+
});
|
|
2666
|
+
const Fr = m.on("formie:submit:before", async (M) => {
|
|
2667
|
+
I(f, "formie:submit:before", M);
|
|
2668
|
+
}), Rr = m.on("formie:submit:after", async (M) => {
|
|
2669
|
+
I(f, "formie:submit:after", M);
|
|
2670
|
+
}), kr = m.on("formie:submit:final:before", async (M) => {
|
|
2671
|
+
I(f, "formie:submit:final:before", M);
|
|
2672
|
+
}), qr = m.on("formie:submit:final:after", async (M) => {
|
|
2673
|
+
I(f, "formie:submit:final:after", M);
|
|
2674
|
+
});
|
|
2675
|
+
return g.push(
|
|
2676
|
+
Fr,
|
|
2677
|
+
Rr,
|
|
2678
|
+
kr,
|
|
2679
|
+
qr
|
|
2680
|
+
), e.set(f, {
|
|
2681
|
+
options: T,
|
|
2682
|
+
bus: m,
|
|
2683
|
+
form: w,
|
|
2684
|
+
validator: $,
|
|
2685
|
+
modules: me,
|
|
2686
|
+
unbinds: g,
|
|
2687
|
+
instance: qe
|
|
2688
|
+
}), I(f, "formie:mount:after", {
|
|
2689
|
+
id: S,
|
|
2690
|
+
mode: T.mode
|
|
2691
|
+
}), L.log("Mount complete.", {
|
|
2692
|
+
id: S,
|
|
2693
|
+
target: P(f),
|
|
2694
|
+
mode: T.mode
|
|
2695
|
+
}), qe;
|
|
2696
|
+
}, s = (f, v) => {
|
|
2697
|
+
if (!v.autoVisible || Ui(f) || typeof IntersectionObserver > "u")
|
|
2698
|
+
return a(f, v);
|
|
2699
|
+
if (e.has(f))
|
|
2700
|
+
return Promise.resolve(e.get(f)?.instance || null);
|
|
2701
|
+
if (r.has(f))
|
|
2702
|
+
return L.log("Mount deferred (already waiting visibility).", {
|
|
2703
|
+
target: P(f)
|
|
2704
|
+
}), Promise.resolve(null);
|
|
2705
|
+
const E = new IntersectionObserver((b) => {
|
|
2706
|
+
b.some((g) => g.target === f && g.isIntersecting) && (E.disconnect(), r.delete(f), L.log("Visibility reached, proceeding mount.", {
|
|
2707
|
+
target: P(f)
|
|
2708
|
+
}), a(f, {
|
|
2709
|
+
...v,
|
|
2710
|
+
autoVisible: !1
|
|
2711
|
+
}));
|
|
2712
|
+
}, {
|
|
2713
|
+
threshold: 0.01
|
|
2714
|
+
});
|
|
2715
|
+
return E.observe(f), r.set(f, () => {
|
|
2716
|
+
E.disconnect();
|
|
2717
|
+
}), L.log("Mount deferred until visible.", {
|
|
2718
|
+
target: P(f)
|
|
2719
|
+
}), Promise.resolve(null);
|
|
2720
|
+
};
|
|
2721
|
+
return {
|
|
2722
|
+
mount: a,
|
|
2723
|
+
unmount: o,
|
|
2724
|
+
update: async (f, v) => {
|
|
2725
|
+
const E = e.get(f);
|
|
2726
|
+
if (!E)
|
|
2727
|
+
return a(f, {
|
|
2728
|
+
...ee(f),
|
|
2729
|
+
...v,
|
|
2730
|
+
mode: v.mode || "server-rendered"
|
|
2731
|
+
});
|
|
2732
|
+
E.options = {
|
|
2733
|
+
...E.options,
|
|
2734
|
+
...v
|
|
2735
|
+
};
|
|
2736
|
+
const b = v.payload?.theme || E.options.payload?.theme || qt(f, E.form)?.theme, m = gt(f, b, E.form);
|
|
2737
|
+
return E.validator && (E.validator.config.fieldContainerErrorClass = m.fieldLayoutError || [], E.validator.config.inputErrorClass = m.fieldControlError || [], E.validator.config.messagesClass = m.fieldErrors || [], E.validator.config.messageClass = m.fieldError || []), Object.keys(m).length && I(f, "formie:theme:applied", {
|
|
2738
|
+
hasClasses: !0,
|
|
2739
|
+
reason: "update"
|
|
2740
|
+
}), E.instance;
|
|
2741
|
+
},
|
|
2742
|
+
getInstance: (f) => e.get(f)?.instance || null,
|
|
2743
|
+
refreshForCache: async (f) => {
|
|
2744
|
+
ki(
|
|
2745
|
+
"refreshForCache",
|
|
2746
|
+
"Global `Formie.refreshForCache()` has been deprecated. Use built-in static-cache token refresh handling instead."
|
|
2747
|
+
);
|
|
2748
|
+
let v = null;
|
|
2749
|
+
if (typeof f == "string") {
|
|
2750
|
+
const k = document.getElementById(f);
|
|
2751
|
+
k ? v = k : v = document.querySelector(`[data-formie-form-id="${f}"]`);
|
|
2752
|
+
} else
|
|
2753
|
+
v = f;
|
|
2754
|
+
if (!v) {
|
|
2755
|
+
L.warn("refreshForCache target not found.", {
|
|
2756
|
+
targetOrId: f
|
|
2757
|
+
});
|
|
2758
|
+
return;
|
|
2759
|
+
}
|
|
2760
|
+
const E = e.get(v), b = Ee(v), m = E?.options || ee(v);
|
|
2761
|
+
if (!b) {
|
|
2762
|
+
L.warn("refreshForCache found no form element for target.", {
|
|
2763
|
+
target: P(v)
|
|
2764
|
+
});
|
|
2765
|
+
return;
|
|
2766
|
+
}
|
|
2767
|
+
const g = m.formHandle || v.dataset.formieHandle || b.dataset.formieHandle, S = lt(m, v), T = b.querySelector('input[name="renderId"]')?.value || void 0;
|
|
2768
|
+
if (!g) {
|
|
2769
|
+
L.warn("refreshForCache found no form handle for target.", {
|
|
2770
|
+
target: P(v)
|
|
2771
|
+
});
|
|
2772
|
+
return;
|
|
2773
|
+
}
|
|
2774
|
+
const F = await tt(S, g, T);
|
|
2775
|
+
F && (dt(b, F), I(v, "formie:refresh-tokens:after", F));
|
|
2776
|
+
},
|
|
2777
|
+
registerModule: (f, v) => t.register(f, v),
|
|
2778
|
+
unregisterModule: (f) => {
|
|
2779
|
+
t.unregister(f);
|
|
2780
|
+
},
|
|
2781
|
+
getRegisteredModules: () => t.getAll(),
|
|
2782
|
+
scan: async (f) => {
|
|
2783
|
+
const v = f || document, E = Array.from(v.querySelectorAll(X));
|
|
2784
|
+
L.log("Scan started.", {
|
|
2785
|
+
scope: v === document ? "document" : v,
|
|
2786
|
+
targetCount: E.length
|
|
2787
|
+
});
|
|
2788
|
+
const m = (await Promise.all(E.map((g) => {
|
|
2789
|
+
const S = ee(g);
|
|
2790
|
+
return s(g, S);
|
|
2791
|
+
}))).filter((g) => !!g);
|
|
2792
|
+
return L.log("Scan finished.", {
|
|
2793
|
+
mountedCount: m.length,
|
|
2794
|
+
deferredCount: E.length - m.length
|
|
2795
|
+
}), m;
|
|
2796
|
+
},
|
|
2797
|
+
observe: (f) => {
|
|
2798
|
+
if (typeof MutationObserver > "u")
|
|
2799
|
+
return () => {
|
|
2800
|
+
};
|
|
2801
|
+
const v = f || document;
|
|
2802
|
+
L.log("Observer started.", {
|
|
2803
|
+
scope: v === document ? "document" : v
|
|
2804
|
+
});
|
|
2805
|
+
const E = new MutationObserver((b) => {
|
|
2806
|
+
b.forEach((m) => {
|
|
2807
|
+
m.addedNodes.forEach((g) => {
|
|
2808
|
+
g instanceof Element && (g.matches(X) && (L.log("Observer detected new root.", {
|
|
2809
|
+
target: P(g)
|
|
2810
|
+
}), s(g, ee(g))), g.querySelectorAll(X).forEach((S) => {
|
|
2811
|
+
L.log("Observer detected new nested root.", {
|
|
2812
|
+
target: P(S)
|
|
2813
|
+
}), s(S, ee(S));
|
|
2814
|
+
}));
|
|
2815
|
+
}), m.removedNodes.forEach((g) => {
|
|
2816
|
+
g instanceof Element && (e.has(g) && (L.log("Observer detected removed root.", {
|
|
2817
|
+
target: P(g)
|
|
2818
|
+
}), o(g)), g.querySelectorAll(X).forEach((S) => {
|
|
2819
|
+
e.has(S) && (L.log("Observer detected removed nested root.", {
|
|
2820
|
+
target: P(S)
|
|
2821
|
+
}), o(S));
|
|
2822
|
+
}));
|
|
2823
|
+
});
|
|
2824
|
+
});
|
|
2825
|
+
});
|
|
2826
|
+
return E.observe(v, {
|
|
2827
|
+
childList: !0,
|
|
2828
|
+
subtree: !0
|
|
2829
|
+
}), () => {
|
|
2830
|
+
E.disconnect(), L.log("Observer stopped."), r.forEach((m, g) => {
|
|
2831
|
+
zi(g, v) && (m(), r.delete(g));
|
|
2832
|
+
});
|
|
2833
|
+
const b = [];
|
|
2834
|
+
v instanceof Element && v.matches(X) && b.push(v), v.querySelectorAll(X).forEach((m) => {
|
|
2835
|
+
b.push(m);
|
|
2836
|
+
}), b.forEach((m) => {
|
|
2837
|
+
e.has(m) && o(m);
|
|
2838
|
+
});
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2841
|
+
};
|
|
2842
|
+
}
|
|
2843
|
+
const yr = _("general", "module-hydrator");
|
|
2844
|
+
async function Xo(e) {
|
|
2845
|
+
const t = e.root, r = e.form ?? (t instanceof HTMLFormElement ? t : t.closest("form")), n = e.modules ?? [], i = e.mode ?? "server-rendered", o = e.registry ?? new mr(), a = new Bt(), s = await gr(n, {
|
|
2846
|
+
registry: o,
|
|
2847
|
+
setupContext: {
|
|
2848
|
+
formId: r?.id || t.id || "formie-modules",
|
|
2849
|
+
root: t,
|
|
2850
|
+
form: r,
|
|
2851
|
+
target: t,
|
|
2852
|
+
scope: "form",
|
|
2853
|
+
state: {},
|
|
2854
|
+
options: {},
|
|
2855
|
+
on: (l, d) => a.on(l, d),
|
|
2856
|
+
emit: async (l, d) => {
|
|
2857
|
+
await a.emit(l, d);
|
|
2858
|
+
}
|
|
2859
|
+
},
|
|
2860
|
+
matchContext: {
|
|
2861
|
+
root: t,
|
|
2862
|
+
form: r,
|
|
2863
|
+
mode: i
|
|
2864
|
+
}
|
|
2865
|
+
});
|
|
2866
|
+
return yr.log("Hydrated module manifest.", {
|
|
2867
|
+
moduleCount: n.length,
|
|
2868
|
+
instanceCount: s.length,
|
|
2869
|
+
mode: i
|
|
2870
|
+
}), {
|
|
2871
|
+
destroy: async () => {
|
|
2872
|
+
await Gi(s), a.clear();
|
|
2873
|
+
},
|
|
2874
|
+
on: (l, d) => a.on(l, d),
|
|
2875
|
+
emit: async (l, d) => {
|
|
2876
|
+
await a.emit(l, d);
|
|
2877
|
+
},
|
|
2878
|
+
registerModule: (l, d = {}) => o.register(l, d),
|
|
2879
|
+
unregisterModule: (l) => {
|
|
2880
|
+
o.unregister(l);
|
|
2881
|
+
},
|
|
2882
|
+
getRegisteredModules: () => o.getAll()
|
|
2883
|
+
};
|
|
2884
|
+
}
|
|
2885
|
+
async function Gi(e) {
|
|
2886
|
+
for (const t of e)
|
|
2887
|
+
try {
|
|
2888
|
+
await t.destroy();
|
|
2889
|
+
} catch (r) {
|
|
2890
|
+
console.error("[formie] Failed to destroy module instance.", r), yr.warn("Failed destroying module instance.", { error: r });
|
|
2891
|
+
}
|
|
2892
|
+
}
|
|
2893
|
+
function ke(e) {
|
|
2894
|
+
return e instanceof Element;
|
|
2895
|
+
}
|
|
2896
|
+
function Ji(e) {
|
|
2897
|
+
return e.ok;
|
|
2898
|
+
}
|
|
2899
|
+
function Yi(e) {
|
|
2900
|
+
return typeof e == "string" ? `selector "${e}"` : ke(e) ? `element "${e.tagName.toLowerCase()}"` : "provided element collection";
|
|
2901
|
+
}
|
|
2902
|
+
function Zi(e) {
|
|
2903
|
+
const t = /* @__PURE__ */ new Set(), r = [];
|
|
2904
|
+
for (const n of e)
|
|
2905
|
+
!ke(n) || t.has(n) || (t.add(n), r.push(n));
|
|
2906
|
+
return r;
|
|
2907
|
+
}
|
|
2908
|
+
function Je(e) {
|
|
2909
|
+
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : ke(e) ? [e] : Zi(e);
|
|
2910
|
+
}
|
|
2911
|
+
function Qi() {
|
|
2912
|
+
return document.readyState !== "loading" ? Promise.resolve() : new Promise((e) => {
|
|
2913
|
+
document.addEventListener("DOMContentLoaded", () => e(), { once: !0 });
|
|
2914
|
+
});
|
|
2915
|
+
}
|
|
2916
|
+
async function Xi(e) {
|
|
2917
|
+
const t = Je(e);
|
|
2918
|
+
return t.length > 0 || typeof e != "string" ? t : (await Qi(), Je(e));
|
|
2919
|
+
}
|
|
2920
|
+
function eo(e) {
|
|
2921
|
+
return typeof e == "string" ? document : ke(e) ? e.getRootNode() : document;
|
|
2922
|
+
}
|
|
2923
|
+
function to(e) {
|
|
2924
|
+
const {
|
|
2925
|
+
element: t,
|
|
2926
|
+
observe: r,
|
|
2927
|
+
allowEmpty: n,
|
|
2928
|
+
client: i,
|
|
2929
|
+
onReady: o,
|
|
2930
|
+
onResult: a,
|
|
2931
|
+
onSuccess: s,
|
|
2932
|
+
onError: l,
|
|
2933
|
+
onEvent: d,
|
|
2934
|
+
...p
|
|
2935
|
+
} = e;
|
|
2936
|
+
return {
|
|
2937
|
+
mode: "server-rendered",
|
|
2938
|
+
...p
|
|
2939
|
+
};
|
|
2940
|
+
}
|
|
2941
|
+
async function Pt(e, t, r, n) {
|
|
2942
|
+
const i = [], o = to(e);
|
|
2943
|
+
for (const a of n) {
|
|
2944
|
+
const s = r.get(a);
|
|
2945
|
+
if (s) {
|
|
2946
|
+
i.push(s.instance);
|
|
2947
|
+
continue;
|
|
2948
|
+
}
|
|
2949
|
+
const l = await t.mount(a, o), d = [];
|
|
2950
|
+
if (e.onReady?.(l), d.push(l.on("formie:submit:result", (p) => {
|
|
2951
|
+
const y = p;
|
|
2952
|
+
e.onResult?.(y, l), Ji(y) ? e.onSuccess?.(y, l) : e.onError?.(y, l);
|
|
2953
|
+
})), e.onEvent)
|
|
2954
|
+
for (const p of Vr)
|
|
2955
|
+
d.push(l.on(p, (y) => {
|
|
2956
|
+
e.onEvent?.({
|
|
2957
|
+
name: p,
|
|
2958
|
+
payload: y
|
|
2959
|
+
}, l);
|
|
2960
|
+
}));
|
|
2961
|
+
r.set(a, {
|
|
2962
|
+
instance: l,
|
|
2963
|
+
unsubs: d
|
|
2964
|
+
}), i.push(l);
|
|
2965
|
+
}
|
|
2966
|
+
return i;
|
|
2967
|
+
}
|
|
2968
|
+
async function ea(e) {
|
|
2969
|
+
const t = e.client ?? Ki(), r = /* @__PURE__ */ new Map(), n = await Xi(e.element);
|
|
2970
|
+
if (n.length === 0 && !e.allowEmpty)
|
|
2971
|
+
throw new Error(`Formie could not find any elements for ${Yi(e.element)}.`);
|
|
2972
|
+
await Pt(e, t, r, n);
|
|
2973
|
+
const i = e.observe ? t.observe(eo(e.element)) : null;
|
|
2974
|
+
return {
|
|
2975
|
+
client: t,
|
|
2976
|
+
get instances() {
|
|
2977
|
+
return Array.from(r.values()).map(({ instance: o }) => o);
|
|
2978
|
+
},
|
|
2979
|
+
get(o) {
|
|
2980
|
+
const a = typeof o == "string" ? document.querySelector(o) : o;
|
|
2981
|
+
return a ? r.get(a)?.instance ?? t.getInstance(a) : null;
|
|
2982
|
+
},
|
|
2983
|
+
async rescan() {
|
|
2984
|
+
const o = Je(e.element);
|
|
2985
|
+
return o.length === 0 ? Array.from(r.values()).map(({ instance: a }) => a) : Pt(e, t, r, o);
|
|
2986
|
+
},
|
|
2987
|
+
async destroy() {
|
|
2988
|
+
i?.();
|
|
2989
|
+
const o = Array.from(r.entries());
|
|
2990
|
+
for (const [a, s] of o)
|
|
2991
|
+
s.unsubs.forEach((l) => l()), await t.unmount(a), r.delete(a);
|
|
2992
|
+
}
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
const ft = 2e3, ta = 5e3, ra = 5e3, na = 12e4;
|
|
2996
|
+
async function mt(e) {
|
|
2997
|
+
await new Promise((t) => {
|
|
2998
|
+
window.setTimeout(t, Math.max(e, 0));
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
3001
|
+
async function ia(e, {
|
|
3002
|
+
timeoutMs: t = 5e3,
|
|
3003
|
+
intervalMs: r = 30
|
|
3004
|
+
} = {}) {
|
|
3005
|
+
const n = Date.now();
|
|
3006
|
+
for (; Date.now() - n < t; ) {
|
|
3007
|
+
const i = e();
|
|
3008
|
+
if (i)
|
|
3009
|
+
return i;
|
|
3010
|
+
await mt(r);
|
|
3011
|
+
}
|
|
3012
|
+
throw new Error("Timed out waiting for async condition.");
|
|
3013
|
+
}
|
|
3014
|
+
function vr(e, t) {
|
|
3015
|
+
let r = null;
|
|
3016
|
+
return (...n) => {
|
|
3017
|
+
r !== null && window.clearTimeout(r), r = window.setTimeout(() => {
|
|
3018
|
+
e(...n);
|
|
3019
|
+
}, Math.max(t, 0));
|
|
3020
|
+
};
|
|
3021
|
+
}
|
|
3022
|
+
function oa(e) {
|
|
3023
|
+
const t = String(e || "asyncDefer").toLowerCase();
|
|
3024
|
+
return {
|
|
3025
|
+
async: t.includes("async"),
|
|
3026
|
+
defer: t.includes("defer")
|
|
3027
|
+
};
|
|
3028
|
+
}
|
|
3029
|
+
function Er(e, t) {
|
|
3030
|
+
const r = Array.from(e.querySelectorAll(`input[name="${t}"], textarea[name="${t}"]`));
|
|
3031
|
+
for (const n of r) {
|
|
3032
|
+
const i = String(n.value || "").trim();
|
|
3033
|
+
if (i !== "")
|
|
3034
|
+
return i;
|
|
3035
|
+
}
|
|
3036
|
+
return "";
|
|
3037
|
+
}
|
|
3038
|
+
function Ye(e, t) {
|
|
3039
|
+
return t.some((r) => Er(e, r) !== "");
|
|
3040
|
+
}
|
|
3041
|
+
function ro(e, t) {
|
|
3042
|
+
t.forEach((r) => {
|
|
3043
|
+
Array.from(e.querySelectorAll(`input[name="${r}"], textarea[name="${r}"]`)).forEach((i) => {
|
|
3044
|
+
i.value = "";
|
|
3045
|
+
});
|
|
3046
|
+
});
|
|
3047
|
+
}
|
|
3048
|
+
function Sr(e, t, {
|
|
3049
|
+
value: r = "",
|
|
3050
|
+
container: n
|
|
3051
|
+
} = {}) {
|
|
3052
|
+
let i = e.querySelector(`input[name="${t}"]`);
|
|
3053
|
+
return i || (i = document.createElement("input"), i.type = "hidden", i.name = t, (n || (e instanceof HTMLElement ? e : null))?.appendChild(i)), i.value = r, i;
|
|
3054
|
+
}
|
|
3055
|
+
async function Ar(e, t, r) {
|
|
3056
|
+
if (Ye(e, t))
|
|
3057
|
+
return !0;
|
|
3058
|
+
const n = Date.now() + Math.max(r, 0);
|
|
3059
|
+
for (; Date.now() < n; )
|
|
3060
|
+
if (await mt(120), Ye(e, t))
|
|
3061
|
+
return !0;
|
|
3062
|
+
return !1;
|
|
3063
|
+
}
|
|
3064
|
+
const no = /* @__PURE__ */ new Set([
|
|
3065
|
+
"handle",
|
|
3066
|
+
"placeholderSelector",
|
|
3067
|
+
"errorMessage",
|
|
3068
|
+
"sessionKey",
|
|
3069
|
+
"value"
|
|
3070
|
+
]), io = "[data-formie-captcha-error-container]", oo = [
|
|
3071
|
+
"formie:page:navigate",
|
|
3072
|
+
"formie:page:navigate:after",
|
|
3073
|
+
"formie:submit:result"
|
|
3074
|
+
];
|
|
3075
|
+
function se(e, t, r) {
|
|
3076
|
+
return e.addEventListener(t, r), () => {
|
|
3077
|
+
e.removeEventListener(t, r);
|
|
3078
|
+
};
|
|
3079
|
+
}
|
|
3080
|
+
function Le(e, t) {
|
|
3081
|
+
return e instanceof HTMLElement && e.matches(t) ? [e, ...Array.from(e.querySelectorAll(t))] : Array.from(e.querySelectorAll(t));
|
|
3082
|
+
}
|
|
3083
|
+
function Ze(e) {
|
|
3084
|
+
if (!(e instanceof HTMLElement) || !e.isConnected || e.hidden || e.closest("[hidden]") || e.closest("[data-formie-page-hidden]") || e.closest('[aria-hidden="true"]'))
|
|
3085
|
+
return !1;
|
|
3086
|
+
const t = window.getComputedStyle(e);
|
|
3087
|
+
return t.display !== "none" && t.visibility !== "hidden";
|
|
3088
|
+
}
|
|
3089
|
+
function De(e, t) {
|
|
3090
|
+
const r = Le(e, t);
|
|
3091
|
+
return r.find((n) => Ze(n)) || r[0] || null;
|
|
3092
|
+
}
|
|
3093
|
+
function ao(e) {
|
|
3094
|
+
e.innerHTML = "";
|
|
3095
|
+
const t = document.createElement("div");
|
|
3096
|
+
return e.appendChild(t), t;
|
|
3097
|
+
}
|
|
3098
|
+
function Qe(e) {
|
|
3099
|
+
e?.querySelector(io)?.remove();
|
|
3100
|
+
}
|
|
3101
|
+
function so(e, t, r) {
|
|
3102
|
+
if (!e)
|
|
3103
|
+
return;
|
|
3104
|
+
Qe(e);
|
|
3105
|
+
const n = document.createElement("div");
|
|
3106
|
+
n.setAttribute("data-formie-captcha-error-container", ""), n.setAttribute("aria-live", "polite"), n.setAttribute("aria-atomic", "true"), V(n, r || e, "fieldErrors");
|
|
3107
|
+
const i = document.createElement("div");
|
|
3108
|
+
i.setAttribute("data-formie-captcha-error", ""), i.setAttribute("role", "alert"), V(i, r || e, "fieldError"), i.textContent = t, n.appendChild(i), e.appendChild(n);
|
|
3109
|
+
}
|
|
3110
|
+
function lo(e) {
|
|
3111
|
+
const t = e instanceof CustomEvent ? e.detail : null;
|
|
3112
|
+
return !t || typeof t != "object" ? null : t;
|
|
3113
|
+
}
|
|
3114
|
+
function uo(e, t) {
|
|
3115
|
+
if (!e?.captchas || typeof e.captchas != "object")
|
|
3116
|
+
return null;
|
|
3117
|
+
const r = e.captchas[t];
|
|
3118
|
+
return !r || typeof r != "object" ? null : r;
|
|
3119
|
+
}
|
|
3120
|
+
function co(e, t, r, n) {
|
|
3121
|
+
const i = /* @__PURE__ */ new Set(), o = () => {
|
|
3122
|
+
const d = Le(e, t), p = new Set(d.filter((y) => Ze(y)));
|
|
3123
|
+
d.forEach((y) => {
|
|
3124
|
+
p.has(y) && !i.has(y) && (i.add(y), r(y));
|
|
3125
|
+
}), Array.from(i).forEach((y) => {
|
|
3126
|
+
p.has(y) || (i.delete(y), n(y));
|
|
3127
|
+
});
|
|
3128
|
+
}, a = vr(o, 20), s = new MutationObserver(() => {
|
|
3129
|
+
a();
|
|
3130
|
+
});
|
|
3131
|
+
s.observe(e, {
|
|
3132
|
+
childList: !0,
|
|
3133
|
+
subtree: !0,
|
|
3134
|
+
attributes: !0,
|
|
3135
|
+
attributeFilter: ["class", "style", "hidden", "aria-hidden", "data-formie-page-hidden"]
|
|
3136
|
+
});
|
|
3137
|
+
const l = [
|
|
3138
|
+
se(window, "resize", () => {
|
|
3139
|
+
a();
|
|
3140
|
+
}),
|
|
3141
|
+
...oo.map((d) => se(e, d, () => {
|
|
3142
|
+
a();
|
|
3143
|
+
}))
|
|
3144
|
+
];
|
|
3145
|
+
return o(), {
|
|
3146
|
+
cleanup: () => {
|
|
3147
|
+
s.disconnect(), l.forEach((d) => {
|
|
3148
|
+
d();
|
|
3149
|
+
}), Array.from(i).forEach((d) => {
|
|
3150
|
+
n(d);
|
|
3151
|
+
}), i.clear();
|
|
3152
|
+
},
|
|
3153
|
+
reconcile: a,
|
|
3154
|
+
getVisible: () => Le(e, t).filter((d) => Ze(d))
|
|
3155
|
+
};
|
|
3156
|
+
}
|
|
3157
|
+
function fo(e, t) {
|
|
3158
|
+
return (typeof t.handle == "string" && t.handle.trim() !== "" ? t.handle.trim() : "") || e;
|
|
3159
|
+
}
|
|
3160
|
+
function mo(e, t, {
|
|
3161
|
+
defaultPlaceholderSelector: r,
|
|
3162
|
+
defaultTokenFieldNames: n = [],
|
|
3163
|
+
defaultWaitForValueMs: i = ft
|
|
3164
|
+
}) {
|
|
3165
|
+
const o = t || {}, a = Object.entries(o).reduce((u, [h, A]) => (no.has(h) || (u[h] = A), u), {}), s = n.map(String).filter(Boolean), l = Number(i), d = typeof o.placeholderSelector == "string" && o.placeholderSelector.trim() !== "" ? o.placeholderSelector.trim() : r, p = typeof o.errorMessage == "string" && o.errorMessage.trim() !== "" ? o.errorMessage.trim() : x("Captcha challenge must be completed."), y = typeof o.sessionKey == "string" && o.sessionKey.trim() !== "" ? o.sessionKey.trim() : null, c = typeof o.value == "string" ? o.value : null;
|
|
3166
|
+
return {
|
|
3167
|
+
handle: fo(e, o),
|
|
3168
|
+
ui: {
|
|
3169
|
+
placeholderSelector: d,
|
|
3170
|
+
errorMessage: p
|
|
3171
|
+
},
|
|
3172
|
+
transport: {
|
|
3173
|
+
tokenFieldNames: s,
|
|
3174
|
+
waitForValueMs: Number.isFinite(l) ? l : i,
|
|
3175
|
+
sessionKey: y,
|
|
3176
|
+
value: c
|
|
3177
|
+
},
|
|
3178
|
+
provider: a
|
|
3179
|
+
};
|
|
3180
|
+
}
|
|
3181
|
+
function po(e, t) {
|
|
3182
|
+
const r = e.form || e.root, n = t.ui.placeholderSelector, i = t.handle;
|
|
3183
|
+
return {
|
|
3184
|
+
form: e.form,
|
|
3185
|
+
root: e.root,
|
|
3186
|
+
placeholder: {
|
|
3187
|
+
query: () => Le(e.root, n),
|
|
3188
|
+
getPrimary: () => De(e.root, n),
|
|
3189
|
+
observe: (o, a) => co(e.root, n, o, a),
|
|
3190
|
+
createContainer: (o) => ao(o),
|
|
3191
|
+
clear: (o) => {
|
|
3192
|
+
o && (Qe(o), o.innerHTML = "");
|
|
3193
|
+
}
|
|
3194
|
+
},
|
|
3195
|
+
errors: {
|
|
3196
|
+
getDefaultMessage: () => t.ui.errorMessage,
|
|
3197
|
+
show: (o, a) => {
|
|
3198
|
+
so(a || De(e.root, n), o || t.ui.errorMessage, e.form || e.root);
|
|
3199
|
+
},
|
|
3200
|
+
clear: (o) => {
|
|
3201
|
+
Qe(o || De(e.root, n));
|
|
3202
|
+
}
|
|
3203
|
+
},
|
|
3204
|
+
tokens: {
|
|
3205
|
+
names: t.transport.tokenFieldNames,
|
|
3206
|
+
has: (o = t.transport.tokenFieldNames, a = r) => Ye(a, o),
|
|
3207
|
+
read: (o = t.transport.tokenFieldNames[0], a = r) => o ? Er(a, o) : "",
|
|
3208
|
+
write: (o, {
|
|
3209
|
+
names: a = t.transport.tokenFieldNames,
|
|
3210
|
+
root: s = r,
|
|
3211
|
+
container: l = e.form
|
|
3212
|
+
} = {}) => {
|
|
3213
|
+
a.forEach((d) => {
|
|
3214
|
+
Sr(s, d, {
|
|
3215
|
+
value: o,
|
|
3216
|
+
container: l
|
|
3217
|
+
});
|
|
3218
|
+
});
|
|
3219
|
+
},
|
|
3220
|
+
clear: (o = t.transport.tokenFieldNames, a = r) => {
|
|
3221
|
+
ro(a, o);
|
|
3222
|
+
},
|
|
3223
|
+
wait: (o = t.transport.waitForValueMs, a = t.transport.tokenFieldNames, s = r) => Ar(s, a, o)
|
|
3224
|
+
},
|
|
3225
|
+
refresh: {
|
|
3226
|
+
providerHandle: i,
|
|
3227
|
+
onTokensRefreshed: (o) => {
|
|
3228
|
+
const a = ["formie:refresh-tokens:after", "formie:refresh-tokens:refreshed"].map((s) => se(e.root, s, (l) => {
|
|
3229
|
+
const d = lo(l), p = uo(d, i);
|
|
3230
|
+
p && o(p);
|
|
3231
|
+
}));
|
|
3232
|
+
return () => {
|
|
3233
|
+
a.forEach((s) => {
|
|
3234
|
+
s();
|
|
3235
|
+
});
|
|
3236
|
+
};
|
|
3237
|
+
}
|
|
3238
|
+
},
|
|
3239
|
+
events: {
|
|
3240
|
+
onRoot: (o, a) => se(e.root, o, a),
|
|
3241
|
+
onForm: (o, a) => e.form ? se(e.form, o, a) : () => {
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
};
|
|
3245
|
+
}
|
|
3246
|
+
const G = _("captchas");
|
|
3247
|
+
function wr({
|
|
3248
|
+
id: e,
|
|
3249
|
+
defaultPlaceholderSelector: t,
|
|
3250
|
+
defaultTokenFieldNames: r = [],
|
|
3251
|
+
defaultWaitForValueMs: n = ft,
|
|
3252
|
+
setup: i
|
|
3253
|
+
}) {
|
|
3254
|
+
return {
|
|
3255
|
+
id: e,
|
|
3256
|
+
kind: "captcha",
|
|
3257
|
+
match: () => !0,
|
|
3258
|
+
setup: async (o) => {
|
|
3259
|
+
const a = mo(e, o.options || {}, {
|
|
3260
|
+
defaultPlaceholderSelector: t,
|
|
3261
|
+
defaultTokenFieldNames: r,
|
|
3262
|
+
defaultWaitForValueMs: n
|
|
3263
|
+
});
|
|
3264
|
+
G.log("Setup module.", {
|
|
3265
|
+
moduleId: e,
|
|
3266
|
+
placeholderSelector: a.ui.placeholderSelector,
|
|
3267
|
+
tokenFieldNames: a.transport.tokenFieldNames
|
|
3268
|
+
});
|
|
3269
|
+
const s = po(o, a);
|
|
3270
|
+
return i({
|
|
3271
|
+
...o,
|
|
3272
|
+
options: a,
|
|
3273
|
+
services: s
|
|
3274
|
+
});
|
|
3275
|
+
}
|
|
3276
|
+
};
|
|
3277
|
+
}
|
|
3278
|
+
function go({
|
|
3279
|
+
id: e,
|
|
3280
|
+
defaultPlaceholderSelector: t,
|
|
3281
|
+
defaultTokenFieldNames: r = [],
|
|
3282
|
+
defaultWaitForValueMs: n = ft
|
|
3283
|
+
}) {
|
|
3284
|
+
return wr({
|
|
3285
|
+
id: e,
|
|
3286
|
+
defaultPlaceholderSelector: t,
|
|
3287
|
+
defaultTokenFieldNames: r,
|
|
3288
|
+
defaultWaitForValueMs: n,
|
|
3289
|
+
setup: async ({ services: i, options: o, root: a }) => {
|
|
3290
|
+
const s = [];
|
|
3291
|
+
let l = i.placeholder.getPrimary(), d = o.transport.sessionKey, p = o.transport.value || "";
|
|
3292
|
+
const y = (u) => {
|
|
3293
|
+
!u || !d || (u.innerHTML = "", Sr(u, d, {
|
|
3294
|
+
value: p,
|
|
3295
|
+
container: u
|
|
3296
|
+
}));
|
|
3297
|
+
}, c = i.placeholder.observe(
|
|
3298
|
+
(u) => {
|
|
3299
|
+
l = u, G.log("Passive placeholder visible.", {
|
|
3300
|
+
moduleId: e
|
|
3301
|
+
}), y(u);
|
|
3302
|
+
},
|
|
3303
|
+
(u) => {
|
|
3304
|
+
l === u && (l = i.placeholder.getPrimary()), u.innerHTML = "";
|
|
3305
|
+
}
|
|
3306
|
+
);
|
|
3307
|
+
return s.push(c.cleanup), y(l), s.push(i.refresh.onTokensRefreshed((u) => {
|
|
3308
|
+
d = typeof u.sessionKey == "string" && u.sessionKey.trim() !== "" ? u.sessionKey.trim() : d, p = typeof u.value == "string" ? u.value : "";
|
|
3309
|
+
const h = i.placeholder.getPrimary() || l;
|
|
3310
|
+
l = h, y(h);
|
|
3311
|
+
})), {
|
|
3312
|
+
destroy: () => {
|
|
3313
|
+
s.forEach((u) => {
|
|
3314
|
+
u();
|
|
3315
|
+
});
|
|
3316
|
+
},
|
|
3317
|
+
onBeforeStage: async (u) => {
|
|
3318
|
+
if (u.stage !== "screen" || u.action !== "submit")
|
|
3319
|
+
return;
|
|
3320
|
+
const h = d ? [d] : o.transport.tokenFieldNames;
|
|
3321
|
+
if (h.length === 0)
|
|
3322
|
+
return;
|
|
3323
|
+
if (!await Ar(a, h, o.transport.waitForValueMs)) {
|
|
3324
|
+
const f = i.errors.getDefaultMessage();
|
|
3325
|
+
i.errors.show(f, l), G.warn("Passive captcha missing token.", {
|
|
3326
|
+
moduleId: e,
|
|
3327
|
+
tokenFieldNames: h
|
|
3328
|
+
}), u.abort(f);
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
};
|
|
3332
|
+
}
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
function ho(e) {
|
|
3336
|
+
return wr({
|
|
3337
|
+
id: e.id,
|
|
3338
|
+
defaultPlaceholderSelector: e.defaultPlaceholderSelector,
|
|
3339
|
+
defaultTokenFieldNames: e.defaultTokenFieldNames,
|
|
3340
|
+
setup: async (t) => {
|
|
3341
|
+
const r = [], n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
3342
|
+
let o = t.services.placeholder.getPrimary(), a = !1, s = null;
|
|
3343
|
+
const l = async () => (s || (G.log("Loading captcha provider API.", {
|
|
3344
|
+
moduleId: e.id
|
|
3345
|
+
}), s = e.load(t)), s), d = async (u) => {
|
|
3346
|
+
const h = n.get(u);
|
|
3347
|
+
if (t.services.errors.clear(u), !h) {
|
|
3348
|
+
u.innerHTML = "";
|
|
3349
|
+
return;
|
|
3350
|
+
}
|
|
3351
|
+
const A = await l();
|
|
3352
|
+
e.unmount && await e.unmount({
|
|
3353
|
+
api: A,
|
|
3354
|
+
widget: h,
|
|
3355
|
+
placeholder: u,
|
|
3356
|
+
services: t.services,
|
|
3357
|
+
options: t.options,
|
|
3358
|
+
provider: t.options.provider
|
|
3359
|
+
}), n.delete(u), u.innerHTML = "", t.services.tokens.clear(), G.log("Unmounted captcha placeholder widget.", {
|
|
3360
|
+
moduleId: e.id
|
|
3361
|
+
}), o === u && (o = t.services.placeholder.getPrimary());
|
|
3362
|
+
}, p = async (u) => {
|
|
3363
|
+
if (a || n.has(u) || i.has(u))
|
|
3364
|
+
return;
|
|
3365
|
+
const h = (async () => {
|
|
3366
|
+
const A = await l();
|
|
3367
|
+
if (a || n.has(u))
|
|
3368
|
+
return;
|
|
3369
|
+
const f = t.services.placeholder.createContainer(u), v = await e.mount({
|
|
3370
|
+
api: A,
|
|
3371
|
+
placeholder: u,
|
|
3372
|
+
container: f,
|
|
3373
|
+
services: t.services,
|
|
3374
|
+
options: t.options,
|
|
3375
|
+
provider: t.options.provider
|
|
3376
|
+
});
|
|
3377
|
+
n.set(u, v), o = u, G.log("Mounted captcha placeholder widget.", {
|
|
3378
|
+
moduleId: e.id
|
|
3379
|
+
});
|
|
3380
|
+
})().finally(() => {
|
|
3381
|
+
i.delete(u);
|
|
3382
|
+
});
|
|
3383
|
+
i.set(u, h), await h;
|
|
3384
|
+
}, y = t.services.placeholder.observe(
|
|
3385
|
+
(u) => {
|
|
3386
|
+
o = u, p(u);
|
|
3387
|
+
},
|
|
3388
|
+
(u) => {
|
|
3389
|
+
d(u);
|
|
3390
|
+
}
|
|
3391
|
+
);
|
|
3392
|
+
r.push(y.cleanup);
|
|
3393
|
+
const c = async (u) => {
|
|
3394
|
+
const A = y.getVisible();
|
|
3395
|
+
if (e.reset) {
|
|
3396
|
+
const f = await l();
|
|
3397
|
+
for (const v of A) {
|
|
3398
|
+
const E = n.get(v);
|
|
3399
|
+
if (!E) {
|
|
3400
|
+
await p(v);
|
|
3401
|
+
continue;
|
|
3402
|
+
}
|
|
3403
|
+
await e.reset({
|
|
3404
|
+
api: f,
|
|
3405
|
+
widget: E,
|
|
3406
|
+
placeholder: v,
|
|
3407
|
+
services: t.services,
|
|
3408
|
+
options: t.options,
|
|
3409
|
+
provider: t.options.provider,
|
|
3410
|
+
reason: u
|
|
3411
|
+
}), t.services.tokens.clear(), t.services.errors.clear(v);
|
|
3412
|
+
}
|
|
3413
|
+
y.reconcile();
|
|
3414
|
+
return;
|
|
3415
|
+
}
|
|
3416
|
+
for (const f of Array.from(n.keys()))
|
|
3417
|
+
await d(f);
|
|
3418
|
+
for (const f of A)
|
|
3419
|
+
await p(f);
|
|
3420
|
+
y.reconcile();
|
|
3421
|
+
};
|
|
3422
|
+
return r.push(t.services.events.onRoot("formie:submit:result", (u) => {
|
|
3423
|
+
const h = u instanceof CustomEvent ? u.detail : null;
|
|
3424
|
+
h?.stage !== "validate" && (h?.ok === !1 && h?.stage === "screen" || h?.ok !== !0 && c("submit-result"));
|
|
3425
|
+
})), t.form && r.push(t.services.events.onForm(Ue("reset"), () => {
|
|
3426
|
+
o = t.services.placeholder.getPrimary() || o, window.setTimeout(() => {
|
|
3427
|
+
c("reset-state");
|
|
3428
|
+
}, 0);
|
|
3429
|
+
})), {
|
|
3430
|
+
destroy: async () => {
|
|
3431
|
+
a = !0, r.forEach((u) => {
|
|
3432
|
+
u();
|
|
3433
|
+
});
|
|
3434
|
+
for (const u of Array.from(n.keys()))
|
|
3435
|
+
await d(u);
|
|
3436
|
+
},
|
|
3437
|
+
onBeforeStage: async (u) => {
|
|
3438
|
+
if (u.stage !== "screen" || u.action !== "submit")
|
|
3439
|
+
return;
|
|
3440
|
+
const h = y.getVisible();
|
|
3441
|
+
if (h.length === 0)
|
|
3442
|
+
return;
|
|
3443
|
+
let A = h.find((E) => E === o) || h[0];
|
|
3444
|
+
await p(A), A = o || A, t.services.errors.clear(A);
|
|
3445
|
+
const f = n.get(A);
|
|
3446
|
+
if (!f) {
|
|
3447
|
+
const E = t.services.errors.getDefaultMessage();
|
|
3448
|
+
t.services.errors.show(E, A), G.warn("Captcha widget unavailable at screen stage.", {
|
|
3449
|
+
moduleId: e.id
|
|
3450
|
+
}), u.abort(E);
|
|
3451
|
+
return;
|
|
3452
|
+
}
|
|
3453
|
+
const v = await l();
|
|
3454
|
+
await e.screen({
|
|
3455
|
+
api: v,
|
|
3456
|
+
widget: f,
|
|
3457
|
+
placeholder: A,
|
|
3458
|
+
services: t.services,
|
|
3459
|
+
options: t.options,
|
|
3460
|
+
provider: t.options.provider,
|
|
3461
|
+
stageCtx: u
|
|
3462
|
+
});
|
|
3463
|
+
}
|
|
3464
|
+
};
|
|
3465
|
+
}
|
|
3466
|
+
});
|
|
3467
|
+
}
|
|
3468
|
+
const aa = ho, sa = go, $t = 2500, bo = {
|
|
3469
|
+
bpoint: ["bpointToken"],
|
|
3470
|
+
stripe: ["stripePaymentIntentId"],
|
|
3471
|
+
paypal: ["paypalOrderId", "paypalAuthId"],
|
|
3472
|
+
payway: ["paywayTokenId"],
|
|
3473
|
+
opayo: ["opayoTokenId"],
|
|
3474
|
+
eway: ["ewayTokenData"],
|
|
3475
|
+
"go-cardless": ["goCardlessRedirectId"],
|
|
3476
|
+
mollie: ["molliePaymentId"],
|
|
3477
|
+
moneris: ["monerisTokenId"],
|
|
3478
|
+
paddle: ["paddleTransactionId"],
|
|
3479
|
+
square: ["squarePaymentId"]
|
|
3480
|
+
};
|
|
3481
|
+
function yo(e) {
|
|
3482
|
+
return e.replace("{field:", "").replace("{", "").replace("}", "").replace("]", "").split("[").join("][");
|
|
3483
|
+
}
|
|
3484
|
+
function vo(e) {
|
|
3485
|
+
return `fields[${yo(e)}]`;
|
|
3486
|
+
}
|
|
3487
|
+
function Eo(e, t) {
|
|
3488
|
+
const r = vo(t), n = Array.from(e.querySelectorAll(`[name="${r}"]`)), i = Array.from(e.querySelectorAll(`[name="${r}[]"]`));
|
|
3489
|
+
return (i.length ? i : n).filter((o) => o instanceof HTMLElement);
|
|
3490
|
+
}
|
|
3491
|
+
function Vt(e, t) {
|
|
3492
|
+
const r = Eo(e, t);
|
|
3493
|
+
for (const n of r) {
|
|
3494
|
+
const o = n.closest("[data-formie-field-handle]")?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim();
|
|
3495
|
+
if (o)
|
|
3496
|
+
return o;
|
|
3497
|
+
}
|
|
3498
|
+
return "";
|
|
3499
|
+
}
|
|
3500
|
+
function xe(e) {
|
|
3501
|
+
let t = e.replace(/[^\d.,-]/g, "");
|
|
3502
|
+
const r = t.includes(","), n = t.includes(".");
|
|
3503
|
+
return r && n ? t = t.replace(/\./g, "").replace(/,/, ".") : r && !n ? t = t.replace(/,/, ".") : t = t.replace(/,/g, ""), parseFloat(t);
|
|
3504
|
+
}
|
|
3505
|
+
function So(e) {
|
|
3506
|
+
return e.replace(/^\{field:/, "").replace(/^\{/, "").replace(/\}$/, "").trim();
|
|
3507
|
+
}
|
|
3508
|
+
function de(e) {
|
|
3509
|
+
return So(e).replace(/\]/g, "").split("[").join(".").replace(/\.+/g, ".").replace(/^\./, "").replace(/\.$/, "");
|
|
3510
|
+
}
|
|
3511
|
+
function Tr(e) {
|
|
3512
|
+
const r = de(e).split(".").filter(Boolean);
|
|
3513
|
+
if (!r.length)
|
|
3514
|
+
return "";
|
|
3515
|
+
const [n, ...i] = r;
|
|
3516
|
+
return `fields[${n}]${i.map((o) => `[${o}]`).join("")}`;
|
|
3517
|
+
}
|
|
3518
|
+
function Ao(e) {
|
|
3519
|
+
const r = String(e || "").trim().match(/^fields\[([^\]]+)\](.*)$/);
|
|
3520
|
+
if (!r)
|
|
3521
|
+
return "";
|
|
3522
|
+
const n = r[1] || "", i = r[2] || "", o = Array.from(i.matchAll(/\[([^\]]+)\]/g)).map((a) => a[1] || "").filter(Boolean);
|
|
3523
|
+
return [n, ...o].join(".");
|
|
3524
|
+
}
|
|
3525
|
+
function wo(e) {
|
|
3526
|
+
const t = e.split(";").map((a) => a.trim()).filter(Boolean);
|
|
3527
|
+
if (!t.length)
|
|
3528
|
+
return {
|
|
3529
|
+
source: "",
|
|
3530
|
+
transforms: []
|
|
3531
|
+
};
|
|
3532
|
+
const [r, ...n] = t, i = [];
|
|
3533
|
+
let o = null;
|
|
3534
|
+
return n.forEach((a) => {
|
|
3535
|
+
if (a.startsWith("transform=")) {
|
|
3536
|
+
o && i.push(o), o = {
|
|
3537
|
+
id: decodeURIComponent(a.slice(10) || "").trim(),
|
|
3538
|
+
params: {}
|
|
3539
|
+
};
|
|
3540
|
+
return;
|
|
3541
|
+
}
|
|
3542
|
+
if (!o || !a.includes("="))
|
|
3543
|
+
return;
|
|
3544
|
+
const [s, l] = a.split("=", 2), d = (s || "").trim();
|
|
3545
|
+
!d || d === "transform" || (o.params[d] = decodeURIComponent(l || "").trim());
|
|
3546
|
+
}), o && i.push(o), {
|
|
3547
|
+
source: r || "",
|
|
3548
|
+
transforms: i
|
|
3549
|
+
};
|
|
3550
|
+
}
|
|
3551
|
+
function Cr(e) {
|
|
3552
|
+
const t = String(e || "").trim();
|
|
3553
|
+
if (!t)
|
|
3554
|
+
return {
|
|
3555
|
+
raw: t,
|
|
3556
|
+
target: "",
|
|
3557
|
+
key: "",
|
|
3558
|
+
selector: "",
|
|
3559
|
+
defaultValue: "",
|
|
3560
|
+
transforms: [],
|
|
3561
|
+
isToken: !1,
|
|
3562
|
+
isValid: !1
|
|
3563
|
+
};
|
|
3564
|
+
const r = t.match(/^\{([a-zA-Z]+)(?::(.*))?\}$/);
|
|
3565
|
+
if (!r)
|
|
3566
|
+
return {
|
|
3567
|
+
raw: t,
|
|
3568
|
+
target: "",
|
|
3569
|
+
key: de(t),
|
|
3570
|
+
selector: "",
|
|
3571
|
+
defaultValue: "",
|
|
3572
|
+
transforms: [],
|
|
3573
|
+
isToken: !1,
|
|
3574
|
+
isValid: !0
|
|
3575
|
+
};
|
|
3576
|
+
const n = (r[1] || "").trim().toLowerCase(), i = (r[2] || "").trim(), [o, a = ""] = i.split("|", 2), { source: s, transforms: l } = wo(o || "");
|
|
3577
|
+
if (n !== "field")
|
|
3578
|
+
return {
|
|
3579
|
+
raw: t,
|
|
3580
|
+
target: "",
|
|
3581
|
+
key: "",
|
|
3582
|
+
selector: "",
|
|
3583
|
+
defaultValue: a.trim(),
|
|
3584
|
+
transforms: l,
|
|
3585
|
+
isToken: !0,
|
|
3586
|
+
isValid: !1
|
|
3587
|
+
};
|
|
3588
|
+
const d = s.indexOf(":"), p = d === -1 ? s : s.slice(0, d), y = d === -1 ? "" : s.slice(d + 1), c = de(p);
|
|
3589
|
+
return {
|
|
3590
|
+
raw: t,
|
|
3591
|
+
target: "field",
|
|
3592
|
+
key: c,
|
|
3593
|
+
selector: y.trim(),
|
|
3594
|
+
defaultValue: a.trim(),
|
|
3595
|
+
transforms: l,
|
|
3596
|
+
isToken: !0,
|
|
3597
|
+
isValid: c !== ""
|
|
3598
|
+
};
|
|
3599
|
+
}
|
|
3600
|
+
function To(e) {
|
|
3601
|
+
return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement;
|
|
3602
|
+
}
|
|
3603
|
+
function Co(e, t, r) {
|
|
3604
|
+
const n = t.trim(), i = String(r.name || "").trim();
|
|
3605
|
+
if (!n || !i)
|
|
3606
|
+
return;
|
|
3607
|
+
const o = e.get(n) || {
|
|
3608
|
+
key: n,
|
|
3609
|
+
names: [],
|
|
3610
|
+
inputs: []
|
|
3611
|
+
};
|
|
3612
|
+
o.names.includes(i) || o.names.push(i), o.inputs.includes(r) || o.inputs.push(r), e.set(n, o);
|
|
3613
|
+
}
|
|
3614
|
+
function Mo(e) {
|
|
3615
|
+
const t = /* @__PURE__ */ new Map();
|
|
3616
|
+
return Array.from(e.querySelectorAll("[name]")).filter((n) => To(n)).forEach((n) => {
|
|
3617
|
+
const i = Ao(n.name);
|
|
3618
|
+
i && Co(t, i, n);
|
|
3619
|
+
}), t;
|
|
3620
|
+
}
|
|
3621
|
+
function Lo(e) {
|
|
3622
|
+
if (!e.length)
|
|
3623
|
+
return "";
|
|
3624
|
+
const t = e[0];
|
|
3625
|
+
if (t instanceof HTMLSelectElement && t.multiple)
|
|
3626
|
+
return Array.from(t.selectedOptions).map((n) => n.value);
|
|
3627
|
+
if (e.some((n) => n instanceof HTMLInputElement && (n.type === "checkbox" || n.type === "radio"))) {
|
|
3628
|
+
const n = e.flatMap((i) => !(i instanceof HTMLInputElement) || !i.checked ? [] : [i.value]);
|
|
3629
|
+
return n.length > 1 ? n : n[0] || "";
|
|
3630
|
+
}
|
|
3631
|
+
return t.value;
|
|
3632
|
+
}
|
|
3633
|
+
function Mr(e, t) {
|
|
3634
|
+
return e.get(de(t)) || null;
|
|
3635
|
+
}
|
|
3636
|
+
function Io(e, t) {
|
|
3637
|
+
const r = Cr(e), n = r.key, i = Mr(t, n);
|
|
3638
|
+
if (!i)
|
|
3639
|
+
return {
|
|
3640
|
+
key: n,
|
|
3641
|
+
value: r.defaultValue,
|
|
3642
|
+
found: !1
|
|
3643
|
+
};
|
|
3644
|
+
const o = Lo(i.inputs);
|
|
3645
|
+
return {
|
|
3646
|
+
key: n,
|
|
3647
|
+
value: o === "" && r.defaultValue !== "" ? r.defaultValue : o,
|
|
3648
|
+
found: !0
|
|
3649
|
+
};
|
|
3650
|
+
}
|
|
3651
|
+
function la(e, t, r) {
|
|
3652
|
+
const n = Cr(e), i = n.key;
|
|
3653
|
+
if (!i)
|
|
3654
|
+
return {
|
|
3655
|
+
key: i,
|
|
3656
|
+
value: n.defaultValue,
|
|
3657
|
+
found: !1
|
|
3658
|
+
};
|
|
3659
|
+
const o = r ? Mr(r, i) : null, s = (o?.names?.length ? o.names : [Tr(i)]).flatMap((l) => {
|
|
3660
|
+
const d = t.getAll(l).map((p) => String(p ?? ""));
|
|
3661
|
+
return d.length ? d : t.getAll(`${l}[]`).map((p) => String(p ?? ""));
|
|
3662
|
+
}).filter((l) => l !== "");
|
|
3663
|
+
return s.length ? {
|
|
3664
|
+
key: i,
|
|
3665
|
+
value: s.length > 1 ? s : s[0],
|
|
3666
|
+
found: !0
|
|
3667
|
+
} : {
|
|
3668
|
+
key: i,
|
|
3669
|
+
value: n.defaultValue,
|
|
3670
|
+
found: !1
|
|
3671
|
+
};
|
|
3672
|
+
}
|
|
3673
|
+
function Lr(e, t) {
|
|
3674
|
+
const r = t.replace(/"/g, '\\"');
|
|
3675
|
+
return e.querySelector(`input[name$="[${r}]"]`) || e.querySelector(`input[name$="${r}"]`);
|
|
3676
|
+
}
|
|
3677
|
+
function Se(e, t) {
|
|
3678
|
+
const r = t.find((n) => {
|
|
3679
|
+
const i = Lr(e, n);
|
|
3680
|
+
return !i || String(i.value || "").trim() === "";
|
|
3681
|
+
});
|
|
3682
|
+
return {
|
|
3683
|
+
ok: !r,
|
|
3684
|
+
missingSuffix: r
|
|
3685
|
+
};
|
|
3686
|
+
}
|
|
3687
|
+
async function Ir(e, t, r) {
|
|
3688
|
+
const n = Se(e, t);
|
|
3689
|
+
if (n.ok)
|
|
3690
|
+
return n;
|
|
3691
|
+
const i = Date.now() + Math.max(r, 0);
|
|
3692
|
+
for (; Date.now() < i; ) {
|
|
3693
|
+
await mt(120);
|
|
3694
|
+
const o = Se(e, t);
|
|
3695
|
+
if (o.ok)
|
|
3696
|
+
return o;
|
|
3697
|
+
}
|
|
3698
|
+
return Se(e, t);
|
|
3699
|
+
}
|
|
3700
|
+
const Fo = /* @__PURE__ */ new Set([
|
|
3701
|
+
"handle",
|
|
3702
|
+
"requiredInputSuffixes",
|
|
3703
|
+
"waitForValueMs",
|
|
3704
|
+
"errorMessage"
|
|
3705
|
+
]), Ot = "[data-payment-success]", Ht = "[data-payment-error]";
|
|
3706
|
+
function Ro(e, t) {
|
|
3707
|
+
return (typeof t.handle == "string" && t.handle.trim() !== "" ? t.handle.trim() : "") || e;
|
|
3708
|
+
}
|
|
3709
|
+
function ko(e, t, r) {
|
|
3710
|
+
const n = t || {}, i = Object.entries(n).reduce((l, [d, p]) => (Fo.has(d) || (l[d] = p), l), {}), o = Array.isArray(n.requiredInputSuffixes) ? n.requiredInputSuffixes.map(String).filter(Boolean) : r.defaultRequiredInputSuffixes || [], a = Number(n.waitForValueMs ?? r.defaultWaitForValueMs ?? $t), s = typeof n.errorMessage == "string" && n.errorMessage.trim() !== "" ? n.errorMessage.trim() : "Payment authorization is incomplete.";
|
|
3711
|
+
return {
|
|
3712
|
+
handle: Ro(e, n),
|
|
3713
|
+
transport: {
|
|
3714
|
+
requiredInputSuffixes: o,
|
|
3715
|
+
waitForValueMs: Number.isFinite(a) ? a : $t,
|
|
3716
|
+
errorMessage: s
|
|
3717
|
+
},
|
|
3718
|
+
provider: i
|
|
3719
|
+
};
|
|
3720
|
+
}
|
|
3721
|
+
function _t(e, t, r) {
|
|
3722
|
+
return e.addEventListener(t, r), () => {
|
|
3723
|
+
e.removeEventListener(t, r);
|
|
3724
|
+
};
|
|
3725
|
+
}
|
|
3726
|
+
function qo(e, t) {
|
|
3727
|
+
const r = e.target, n = e.form, i = e.root, o = n || i, a = t.transport.requiredInputSuffixes, s = () => Mo(n || i), l = (b) => {
|
|
3728
|
+
const g = Io(b, s()).value;
|
|
3729
|
+
return Array.isArray(g) ? g[0] || "" : String(g || "");
|
|
3730
|
+
};
|
|
3731
|
+
return {
|
|
3732
|
+
root: i,
|
|
3733
|
+
form: n,
|
|
3734
|
+
field: r,
|
|
3735
|
+
updateInputs: (b, m) => {
|
|
3736
|
+
const g = Array.isArray(b) ? b : [b];
|
|
3737
|
+
for (const S of g) {
|
|
3738
|
+
const C = Lr(o, S) ?? r.querySelector(`input[name*="${S}"]`);
|
|
3739
|
+
C && (C.value = m);
|
|
3740
|
+
}
|
|
3741
|
+
},
|
|
3742
|
+
addError: (b) => {
|
|
3743
|
+
const m = r.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || r, g = m.querySelector(Ht);
|
|
3744
|
+
g && g.remove();
|
|
3745
|
+
const S = document.createElement("div");
|
|
3746
|
+
S.setAttribute("data-payment-error", ""), S.textContent = b, V(S, n || i, "fieldError"), m.appendChild(S);
|
|
3747
|
+
},
|
|
3748
|
+
removeError: () => {
|
|
3749
|
+
r.querySelector(Ht)?.remove();
|
|
3750
|
+
},
|
|
3751
|
+
addSuccess: (b) => {
|
|
3752
|
+
const m = r.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || r, g = m.querySelector(Ot);
|
|
3753
|
+
g && g.remove();
|
|
3754
|
+
const S = document.createElement("div");
|
|
3755
|
+
S.setAttribute("data-payment-success", ""), S.textContent = b, V(S, n || i, "successMessage"), m.appendChild(S);
|
|
3756
|
+
},
|
|
3757
|
+
removeSuccess: () => {
|
|
3758
|
+
r.querySelector(Ot)?.remove();
|
|
3759
|
+
},
|
|
3760
|
+
hasToken: () => Se(o, a).ok,
|
|
3761
|
+
waitForToken: (b = t.transport.waitForValueMs) => Ir(o, a, b).then((m) => m.ok),
|
|
3762
|
+
getFieldValue: (b, m = "string") => {
|
|
3763
|
+
const g = l(b);
|
|
3764
|
+
return m === "float" || m === "int" || m === "number" ? xe(g) : g;
|
|
3765
|
+
},
|
|
3766
|
+
resolveAmount: (b) => {
|
|
3767
|
+
const m = n || i, S = String(b.type || "").toLowerCase() === "dynamic" && typeof b.variable == "string" && b.variable.trim() !== "", C = b.value ?? (S ? b.variable : b.fixed), T = String(C ?? "").trim(), F = typeof C == "number" ? C : xe(T);
|
|
3768
|
+
if (Number.isFinite(F) && F > 0)
|
|
3769
|
+
return { ok: !0, value: F };
|
|
3770
|
+
if (T !== "") {
|
|
3771
|
+
const k = l(T), w = xe(k);
|
|
3772
|
+
if (Number.isFinite(w) && w > 0)
|
|
3773
|
+
return { ok: !0, value: w };
|
|
3774
|
+
const q = Vt(m, T);
|
|
3775
|
+
if (!k)
|
|
3776
|
+
return {
|
|
3777
|
+
ok: !1,
|
|
3778
|
+
error: q ? x('Provide a value for "{label}" to proceed.', { label: q }) : x("Provide a payment amount to proceed.")
|
|
3779
|
+
};
|
|
3780
|
+
}
|
|
3781
|
+
return {
|
|
3782
|
+
ok: !1,
|
|
3783
|
+
error: x("Payment amount must be greater than 0.")
|
|
3784
|
+
};
|
|
3785
|
+
},
|
|
3786
|
+
resolveCurrency: (b) => {
|
|
3787
|
+
const m = n || i, S = String(b.type || "").toLowerCase() === "dynamic" && typeof b.variable == "string" && b.variable.trim() !== "", C = b.value ?? (S ? b.variable : b.fixed ?? b.defaultCurrency ?? ""), T = String(C ?? "").trim(), F = T.toUpperCase();
|
|
3788
|
+
if (/^[A-Z]{3}$/.test(F) && !S)
|
|
3789
|
+
return { ok: !0, value: F };
|
|
3790
|
+
if (T !== "") {
|
|
3791
|
+
const k = String(l(T) || "").trim(), w = k.toUpperCase();
|
|
3792
|
+
if (/^[A-Z]{3}$/.test(w))
|
|
3793
|
+
return { ok: !0, value: w };
|
|
3794
|
+
const q = Vt(m, T);
|
|
3795
|
+
if (!k)
|
|
3796
|
+
return {
|
|
3797
|
+
ok: !1,
|
|
3798
|
+
error: q ? x('Provide a value for "{label}" to proceed.', { label: q }) : x("Provide a payment currency to proceed.")
|
|
3799
|
+
};
|
|
3800
|
+
}
|
|
3801
|
+
return {
|
|
3802
|
+
ok: !1,
|
|
3803
|
+
error: x("Payment currency must be a valid 3-letter code.")
|
|
3804
|
+
};
|
|
3805
|
+
},
|
|
3806
|
+
watchFieldValueChanges: (b, m, g = 600) => {
|
|
3807
|
+
const S = n || i, C = b.map((q) => String(q || "").trim()).filter(Boolean);
|
|
3808
|
+
if (C.length === 0)
|
|
3809
|
+
return () => {
|
|
3810
|
+
};
|
|
3811
|
+
const T = s(), F = /* @__PURE__ */ new Set();
|
|
3812
|
+
C.forEach((q) => {
|
|
3813
|
+
const N = de(q), B = T.get(N);
|
|
3814
|
+
if (B?.names?.length) {
|
|
3815
|
+
B.names.forEach((fe) => {
|
|
3816
|
+
F.add(fe);
|
|
3817
|
+
});
|
|
3818
|
+
return;
|
|
3819
|
+
}
|
|
3820
|
+
const Y = Tr(N);
|
|
3821
|
+
Y && (F.add(Y), F.add(`${Y}[]`));
|
|
3822
|
+
});
|
|
3823
|
+
const k = vr(() => {
|
|
3824
|
+
m();
|
|
3825
|
+
}, g), w = (q) => {
|
|
3826
|
+
const B = q.target?.name || "";
|
|
3827
|
+
!B || !F.has(B) || k();
|
|
3828
|
+
};
|
|
3829
|
+
return S.addEventListener("input", w), S.addEventListener("change", w), () => {
|
|
3830
|
+
S.removeEventListener("input", w), S.removeEventListener("change", w);
|
|
3831
|
+
};
|
|
3832
|
+
},
|
|
3833
|
+
triggerSubmit: () => {
|
|
3834
|
+
n && n.setAttribute("data-formie-internal-resubmit", "true"), n && typeof n.requestSubmit == "function" ? n.requestSubmit() : n && n.submit();
|
|
3835
|
+
},
|
|
3836
|
+
releaseSubmitLoading: () => {
|
|
3837
|
+
n && (n.removeAttribute("data-formie-internal-resubmit"), Te(n));
|
|
3838
|
+
},
|
|
3839
|
+
getBillingData: (b) => {
|
|
3840
|
+
const m = {};
|
|
3841
|
+
if (!b || typeof b != "object")
|
|
3842
|
+
return { billing_details: m };
|
|
3843
|
+
if (b.billingName) {
|
|
3844
|
+
const g = l(b.billingName);
|
|
3845
|
+
g && (m.name = g);
|
|
3846
|
+
}
|
|
3847
|
+
if (b.billingEmail) {
|
|
3848
|
+
const g = l(b.billingEmail);
|
|
3849
|
+
g && (m.email = g);
|
|
3850
|
+
}
|
|
3851
|
+
if (b.billingAddress) {
|
|
3852
|
+
const g = b.billingAddress, S = {}, C = l(`${g}.address1`), T = l(`${g}.address2`), F = l(`${g}.address3`), k = l(`${g}.city`), w = l(`${g}.zip`), q = l(`${g}.state`), N = l(`${g}.country`);
|
|
3853
|
+
C && (S.line1 = C), T && (S.line2 = T), F && (S.line3 = F), k && (S.city = k), w && (S.postal_code = w), q && (S.state = q), N && (S.country = N), Object.keys(S).length && (m.address = S);
|
|
3854
|
+
}
|
|
3855
|
+
return { billing_details: m };
|
|
3856
|
+
},
|
|
3857
|
+
events: {
|
|
3858
|
+
onForm: (b, m) => n ? _t(n, b, m) : () => {
|
|
3859
|
+
},
|
|
3860
|
+
onRoot: (b, m) => _t(i, b, m)
|
|
3861
|
+
}
|
|
3862
|
+
};
|
|
3863
|
+
}
|
|
3864
|
+
const U = _("payments");
|
|
3865
|
+
function Dt(e) {
|
|
3866
|
+
const t = e;
|
|
3867
|
+
return !t.closest("[data-formie-page-hidden]") && !t.closest("[hidden]");
|
|
3868
|
+
}
|
|
3869
|
+
function Po(e) {
|
|
3870
|
+
const t = e.defaultRequiredInputSuffixes ?? bo[e.id] ?? [];
|
|
3871
|
+
return {
|
|
3872
|
+
id: e.id,
|
|
3873
|
+
kind: "payment",
|
|
3874
|
+
match: (r) => !!(r.target.querySelector('[data-formie-field-type="payment"]') || r.target.closest('[data-formie-field-type="payment"]') || r.target.getAttribute?.("data-formie-field-type") === "payment"),
|
|
3875
|
+
setup: async (r) => {
|
|
3876
|
+
const n = r.target, i = n.__formiePaymentModuleRegistry || {};
|
|
3877
|
+
n.__formiePaymentModuleRegistry = i;
|
|
3878
|
+
const o = i[e.id];
|
|
3879
|
+
if (o?.destroy) {
|
|
3880
|
+
U.warn("Found stale payment module instance; destroying previous.", {
|
|
3881
|
+
moduleId: e.id
|
|
3882
|
+
});
|
|
3883
|
+
try {
|
|
3884
|
+
await o.destroy();
|
|
3885
|
+
} catch {
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
const a = ko(
|
|
3889
|
+
e.id,
|
|
3890
|
+
r.options || {},
|
|
3891
|
+
{
|
|
3892
|
+
defaultRequiredInputSuffixes: t
|
|
3893
|
+
}
|
|
3894
|
+
), s = qo(r, a), l = {
|
|
3895
|
+
...r,
|
|
3896
|
+
options: a,
|
|
3897
|
+
services: s
|
|
3898
|
+
}, d = [];
|
|
3899
|
+
let p = null, y = null, c = null, u = null;
|
|
3900
|
+
const h = async () => (p || (U.log("Loading payment provider API.", { moduleId: e.id }), p = e.load(l)), p), A = async () => {
|
|
3901
|
+
if (!e.mount || y || !Dt(r.target))
|
|
3902
|
+
return;
|
|
3903
|
+
const E = await h();
|
|
3904
|
+
try {
|
|
3905
|
+
y = await e.mount({
|
|
3906
|
+
api: E,
|
|
3907
|
+
field: r.target,
|
|
3908
|
+
services: s,
|
|
3909
|
+
options: a,
|
|
3910
|
+
provider: a.provider
|
|
3911
|
+
}), U.log("Payment widget mounted.", {
|
|
3912
|
+
moduleId: e.id,
|
|
3913
|
+
handle: a.handle
|
|
3914
|
+
});
|
|
3915
|
+
} catch {
|
|
3916
|
+
U.warn("Payment widget mount failed.", {
|
|
3917
|
+
moduleId: e.id,
|
|
3918
|
+
handle: a.handle
|
|
3919
|
+
});
|
|
3920
|
+
}
|
|
3921
|
+
};
|
|
3922
|
+
if (d.push(r.on("formie:submit:before", () => {
|
|
3923
|
+
s.removeError(), s.removeSuccess();
|
|
3924
|
+
})), e.setup) {
|
|
3925
|
+
const E = r.root || r.form || r.target;
|
|
3926
|
+
c = await e.setup({ ...l, root: E }), c.destroy && d.push(c.destroy);
|
|
3927
|
+
}
|
|
3928
|
+
e.mount && Dt(r.target) && await A(), ["formie:page:navigate:after", "formie:submit:result"].forEach((E) => {
|
|
3929
|
+
const b = () => {
|
|
3930
|
+
A();
|
|
3931
|
+
};
|
|
3932
|
+
r.root.addEventListener(E, b), d.push(() => {
|
|
3933
|
+
r.root.removeEventListener(E, b);
|
|
3934
|
+
});
|
|
3935
|
+
});
|
|
3936
|
+
const v = async () => {
|
|
3937
|
+
if (U.log("Destroying payment module.", {
|
|
3938
|
+
moduleId: e.id,
|
|
3939
|
+
handle: a.handle
|
|
3940
|
+
}), d.forEach((E) => E()), y && e.unmount) {
|
|
3941
|
+
const E = await h();
|
|
3942
|
+
await e.unmount({
|
|
3943
|
+
api: E,
|
|
3944
|
+
widget: y,
|
|
3945
|
+
field: r.target,
|
|
3946
|
+
services: s,
|
|
3947
|
+
options: a,
|
|
3948
|
+
provider: a.provider
|
|
3949
|
+
}), U.log("Payment widget unmounted.", {
|
|
3950
|
+
moduleId: e.id,
|
|
3951
|
+
handle: a.handle
|
|
3952
|
+
});
|
|
3953
|
+
}
|
|
3954
|
+
i[e.id]?.destroy === v && delete i[e.id], U.log("Payment module destroy complete.", {
|
|
3955
|
+
moduleId: e.id,
|
|
3956
|
+
handle: a.handle
|
|
3957
|
+
});
|
|
3958
|
+
};
|
|
3959
|
+
return i[e.id] = { destroy: v }, {
|
|
3960
|
+
destroy: v,
|
|
3961
|
+
onBeforeStage: async (E) => {
|
|
3962
|
+
if (c?.onBeforeStage) {
|
|
3963
|
+
await c.onBeforeStage(E);
|
|
3964
|
+
return;
|
|
3965
|
+
}
|
|
3966
|
+
if (E.stage !== "authorize" || E.action !== "submit" || r.target.closest("[data-formie-page]")?.hasAttribute("data-formie-page-hidden"))
|
|
3967
|
+
return;
|
|
3968
|
+
await A();
|
|
3969
|
+
const g = await h();
|
|
3970
|
+
if (e.onBeforeAuthorize) {
|
|
3971
|
+
u || (u = (async () => e.onBeforeAuthorize({
|
|
3972
|
+
api: g,
|
|
3973
|
+
widget: y,
|
|
3974
|
+
field: r.target,
|
|
3975
|
+
services: s,
|
|
3976
|
+
options: a,
|
|
3977
|
+
provider: a.provider,
|
|
3978
|
+
stageCtx: E
|
|
3979
|
+
}))().finally(() => {
|
|
3980
|
+
u = null;
|
|
3981
|
+
}));
|
|
3982
|
+
const T = await u;
|
|
3983
|
+
if (U.log("onBeforeAuthorize resolved.", {
|
|
3984
|
+
moduleId: e.id,
|
|
3985
|
+
handle: a.handle,
|
|
3986
|
+
ok: T
|
|
3987
|
+
}), !T) {
|
|
3988
|
+
E.abort(a.transport.errorMessage);
|
|
3989
|
+
return;
|
|
3990
|
+
}
|
|
3991
|
+
return;
|
|
3992
|
+
}
|
|
3993
|
+
if (a.transport.requiredInputSuffixes.length === 0)
|
|
3994
|
+
return;
|
|
3995
|
+
const S = r.form || r.root, C = await Ir(
|
|
3996
|
+
S,
|
|
3997
|
+
a.transport.requiredInputSuffixes,
|
|
3998
|
+
a.transport.waitForValueMs
|
|
3999
|
+
);
|
|
4000
|
+
C.ok || (U.warn("Required payment input(s) missing.", {
|
|
4001
|
+
moduleId: e.id,
|
|
4002
|
+
handle: a.handle,
|
|
4003
|
+
missingSuffix: C.missingSuffix
|
|
4004
|
+
}), E.abort(a.transport.errorMessage));
|
|
4005
|
+
},
|
|
4006
|
+
onAfterStage: async (E, b) => {
|
|
4007
|
+
E.stage !== "dispatch" || !e.onAfterSubmit || await e.onAfterSubmit({
|
|
4008
|
+
field: r.target,
|
|
4009
|
+
services: s,
|
|
4010
|
+
options: a,
|
|
4011
|
+
provider: a.provider,
|
|
4012
|
+
result: b
|
|
4013
|
+
});
|
|
4014
|
+
}
|
|
4015
|
+
};
|
|
4016
|
+
}
|
|
4017
|
+
};
|
|
4018
|
+
}
|
|
4019
|
+
const ua = Po, $o = "[data-formie-address-autocomplete-input]", xt = "[data-formie-address-location]", Vo = {
|
|
4020
|
+
autoComplete: "[data-formie-address-autocomplete-input]",
|
|
4021
|
+
address1: "[data-formie-address-line1-input]",
|
|
4022
|
+
address2: "[data-formie-address-line2-input]",
|
|
4023
|
+
address3: "[data-formie-address-line3-input]",
|
|
4024
|
+
city: "[data-formie-address-city-input]",
|
|
4025
|
+
state: "[data-formie-address-state-input]",
|
|
4026
|
+
zip: "[data-formie-address-zip-input]",
|
|
4027
|
+
country: "[data-formie-address-country-input]"
|
|
4028
|
+
}, Oo = /* @__PURE__ */ new Set(["handle"]);
|
|
4029
|
+
function Ho(e, t) {
|
|
4030
|
+
return (typeof t.handle == "string" && t.handle.trim() !== "" ? t.handle.trim() : "") || e;
|
|
4031
|
+
}
|
|
4032
|
+
function _o(e, t) {
|
|
4033
|
+
const r = t || {}, n = Object.entries(r).reduce((i, [o, a]) => (Oo.has(o) || (i[o] = a), i), {});
|
|
4034
|
+
return {
|
|
4035
|
+
handle: Ho(e, r),
|
|
4036
|
+
provider: n
|
|
4037
|
+
};
|
|
4038
|
+
}
|
|
4039
|
+
function Do(e, t, r) {
|
|
4040
|
+
return e.addEventListener(t, r), () => {
|
|
4041
|
+
e.removeEventListener(t, r);
|
|
4042
|
+
};
|
|
4043
|
+
}
|
|
4044
|
+
function xo(e) {
|
|
4045
|
+
const t = e.target, r = e.form, n = e.root, i = $o;
|
|
4046
|
+
return {
|
|
4047
|
+
root: n,
|
|
4048
|
+
field: t,
|
|
4049
|
+
form: r,
|
|
4050
|
+
input: {
|
|
4051
|
+
getAutocomplete: () => t.querySelector(i),
|
|
4052
|
+
setValue: (o, a, s) => {
|
|
4053
|
+
const l = Vo[o], d = t.querySelector(l);
|
|
4054
|
+
d && (d.value = a || s || "");
|
|
4055
|
+
}
|
|
4056
|
+
},
|
|
4057
|
+
location: {
|
|
4058
|
+
getButton: () => t.querySelector(xt),
|
|
4059
|
+
onUseLocation: (o) => {
|
|
4060
|
+
const a = t.querySelector(xt);
|
|
4061
|
+
if (!a)
|
|
4062
|
+
return () => {
|
|
4063
|
+
};
|
|
4064
|
+
const s = (l) => {
|
|
4065
|
+
l.preventDefault(), navigator.geolocation && navigator.geolocation.getCurrentPosition(
|
|
4066
|
+
o,
|
|
4067
|
+
() => {
|
|
4068
|
+
},
|
|
4069
|
+
{ enableHighAccuracy: !0 }
|
|
4070
|
+
);
|
|
4071
|
+
};
|
|
4072
|
+
return a.addEventListener("click", s), () => {
|
|
4073
|
+
a.removeEventListener("click", s);
|
|
4074
|
+
};
|
|
4075
|
+
}
|
|
4076
|
+
},
|
|
4077
|
+
events: {
|
|
4078
|
+
onField: (o, a) => Do(t, o, a)
|
|
4079
|
+
}
|
|
4080
|
+
};
|
|
4081
|
+
}
|
|
4082
|
+
const te = _("address");
|
|
4083
|
+
function Nt(e) {
|
|
4084
|
+
const t = e;
|
|
4085
|
+
return !t.closest("[data-formie-page-hidden]") && !t.closest("[hidden]");
|
|
4086
|
+
}
|
|
4087
|
+
function No(e) {
|
|
4088
|
+
return {
|
|
4089
|
+
id: e.id,
|
|
4090
|
+
kind: "address",
|
|
4091
|
+
match: (t) => !!t.target.querySelector("[data-formie-address-autocomplete-input]"),
|
|
4092
|
+
setup: async (t) => {
|
|
4093
|
+
const r = _o(e.id, t.options || {}), n = xo(t);
|
|
4094
|
+
te.log("Setup module.", {
|
|
4095
|
+
moduleId: e.id
|
|
4096
|
+
});
|
|
4097
|
+
const i = {
|
|
4098
|
+
...t,
|
|
4099
|
+
options: r,
|
|
4100
|
+
services: n
|
|
4101
|
+
}, o = [];
|
|
4102
|
+
let a = null, s = null;
|
|
4103
|
+
if (!n.input.getAutocomplete())
|
|
4104
|
+
return console.warn(
|
|
4105
|
+
`[formie] Address module "${e.id}" skipped: no autocomplete input found in target. Ensure the Address field has the Auto-Complete subfield enabled.`
|
|
4106
|
+
), te.warn("Autocomplete input missing; skipping module.", {
|
|
4107
|
+
moduleId: e.id
|
|
4108
|
+
}), {
|
|
4109
|
+
destroy: () => {
|
|
4110
|
+
}
|
|
4111
|
+
};
|
|
4112
|
+
const d = async () => (a || (te.log("Loading provider API.", {
|
|
4113
|
+
moduleId: e.id
|
|
4114
|
+
}), a = e.load(i)), a), p = async () => {
|
|
4115
|
+
if (s || !Nt(t.target))
|
|
4116
|
+
return;
|
|
4117
|
+
const u = await d();
|
|
4118
|
+
s = await e.mount({
|
|
4119
|
+
api: u,
|
|
4120
|
+
field: t.target,
|
|
4121
|
+
services: n,
|
|
4122
|
+
options: r,
|
|
4123
|
+
provider: r.provider
|
|
4124
|
+
}), te.log("Widget mounted.", {
|
|
4125
|
+
moduleId: e.id
|
|
4126
|
+
});
|
|
4127
|
+
};
|
|
4128
|
+
Nt(t.target) && await p(), ["formie:page:navigate:after", "formie:submit:result"].forEach((u) => {
|
|
4129
|
+
const h = () => {
|
|
4130
|
+
p();
|
|
4131
|
+
};
|
|
4132
|
+
t.root.addEventListener(u, h), o.push(() => {
|
|
4133
|
+
t.root.removeEventListener(u, h);
|
|
4134
|
+
});
|
|
4135
|
+
});
|
|
4136
|
+
const c = n.location.onUseLocation((u) => {
|
|
4137
|
+
e.onCurrentLocation && (async () => {
|
|
4138
|
+
if (await p(), !s)
|
|
4139
|
+
return;
|
|
4140
|
+
const h = await d();
|
|
4141
|
+
await e.onCurrentLocation?.(u, {
|
|
4142
|
+
api: h,
|
|
4143
|
+
widget: s,
|
|
4144
|
+
field: t.target,
|
|
4145
|
+
services: n,
|
|
4146
|
+
options: r,
|
|
4147
|
+
provider: r.provider
|
|
4148
|
+
});
|
|
4149
|
+
})();
|
|
4150
|
+
});
|
|
4151
|
+
return c && o.push(c), {
|
|
4152
|
+
destroy: async () => {
|
|
4153
|
+
if (te.log("Destroying module.", {
|
|
4154
|
+
moduleId: e.id
|
|
4155
|
+
}), o.forEach((u) => u()), s && e.unmount) {
|
|
4156
|
+
const u = await d();
|
|
4157
|
+
await e.unmount({
|
|
4158
|
+
api: u,
|
|
4159
|
+
widget: s,
|
|
4160
|
+
field: t.target,
|
|
4161
|
+
services: n,
|
|
4162
|
+
options: r,
|
|
4163
|
+
provider: r.provider
|
|
4164
|
+
}), te.log("Widget unmounted.", {
|
|
4165
|
+
moduleId: e.id
|
|
4166
|
+
});
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
};
|
|
4170
|
+
}
|
|
4171
|
+
};
|
|
4172
|
+
}
|
|
4173
|
+
const ca = No;
|
|
4174
|
+
export {
|
|
4175
|
+
Qo as $,
|
|
4176
|
+
Vo as A,
|
|
4177
|
+
Uo as B,
|
|
4178
|
+
ta as C,
|
|
4179
|
+
Ur as D,
|
|
4180
|
+
zr as E,
|
|
4181
|
+
Vr as F,
|
|
4182
|
+
Ki as G,
|
|
4183
|
+
jr as H,
|
|
4184
|
+
Br as I,
|
|
4185
|
+
ea as J,
|
|
4186
|
+
Xt as K,
|
|
4187
|
+
Pr as L,
|
|
4188
|
+
mr as M,
|
|
4189
|
+
Hr as N,
|
|
4190
|
+
Or as O,
|
|
4191
|
+
Xo as P,
|
|
4192
|
+
Ao as Q,
|
|
4193
|
+
zt as R,
|
|
4194
|
+
Zo as S,
|
|
4195
|
+
zo as T,
|
|
4196
|
+
Cr as U,
|
|
4197
|
+
la as V,
|
|
4198
|
+
$r as W,
|
|
4199
|
+
Go as X,
|
|
4200
|
+
Yo as Y,
|
|
4201
|
+
x as Z,
|
|
4202
|
+
Ne as _,
|
|
4203
|
+
aa as a,
|
|
4204
|
+
oa as b,
|
|
4205
|
+
na as c,
|
|
4206
|
+
ca as d,
|
|
4207
|
+
sa as e,
|
|
4208
|
+
ra as f,
|
|
4209
|
+
Bo as g,
|
|
4210
|
+
_ as h,
|
|
4211
|
+
Mo as i,
|
|
4212
|
+
Tr as j,
|
|
4213
|
+
Wo as k,
|
|
4214
|
+
Ue as l,
|
|
4215
|
+
Ie as m,
|
|
4216
|
+
de as n,
|
|
4217
|
+
vr as o,
|
|
4218
|
+
Jo as p,
|
|
4219
|
+
jo as q,
|
|
4220
|
+
Io as r,
|
|
4221
|
+
mt as s,
|
|
4222
|
+
ue as t,
|
|
4223
|
+
ua as u,
|
|
4224
|
+
Ko as v,
|
|
4225
|
+
ia as w,
|
|
4226
|
+
V as x,
|
|
4227
|
+
le as y,
|
|
4228
|
+
Rn as z
|
|
4229
|
+
};
|