@usgb/forms 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +255 -72
  2. package/dist/forms-manifest.json +249 -0
  3. package/dist/index.js +1032 -31
  4. package/dist/src/contract/collectContext.d.ts +9 -0
  5. package/dist/src/contract/collectContext.d.ts.map +1 -0
  6. package/dist/src/contract/createStubAdapter.d.ts +9 -0
  7. package/dist/src/contract/createStubAdapter.d.ts.map +1 -0
  8. package/dist/src/contract/types.d.ts +90 -0
  9. package/dist/src/contract/types.d.ts.map +1 -0
  10. package/dist/src/definitions/consents.d.ts +37 -0
  11. package/dist/src/definitions/consents.d.ts.map +1 -0
  12. package/dist/src/definitions/fields.d.ts +19 -0
  13. package/dist/src/definitions/fields.d.ts.map +1 -0
  14. package/dist/src/definitions/index.d.ts +7 -0
  15. package/dist/src/definitions/index.d.ts.map +1 -0
  16. package/dist/src/definitions/manifest.d.ts +8 -0
  17. package/dist/src/definitions/manifest.d.ts.map +1 -0
  18. package/dist/src/definitions/types.d.ts +77 -0
  19. package/dist/src/definitions/types.d.ts.map +1 -0
  20. package/dist/src/form/FormShell.d.ts +10 -0
  21. package/dist/src/form/FormShell.d.ts.map +1 -0
  22. package/dist/src/form/RegisteredTextField.d.ts +14 -0
  23. package/dist/src/form/RegisteredTextField.d.ts.map +1 -0
  24. package/dist/src/form/UsgbForm.d.ts +25 -0
  25. package/dist/src/form/UsgbForm.d.ts.map +1 -0
  26. package/dist/src/form/chunkFields.d.ts +17 -0
  27. package/dist/src/form/chunkFields.d.ts.map +1 -0
  28. package/dist/src/form/kinds/LeadKindForm.d.ts +4 -0
  29. package/dist/src/form/kinds/LeadKindForm.d.ts.map +1 -0
  30. package/dist/src/form/kinds/NewsletterKindForm.d.ts +4 -0
  31. package/dist/src/form/kinds/NewsletterKindForm.d.ts.map +1 -0
  32. package/dist/src/form/kinds/index.d.ts +6 -0
  33. package/dist/src/form/kinds/index.d.ts.map +1 -0
  34. package/dist/src/form/kinds/types.d.ts +11 -0
  35. package/dist/src/form/kinds/types.d.ts.map +1 -0
  36. package/dist/src/form/useUsgbFormSession.d.ts +41 -0
  37. package/dist/src/form/useUsgbFormSession.d.ts.map +1 -0
  38. package/dist/src/index.d.ts +14 -0
  39. package/dist/src/index.d.ts.map +1 -0
  40. package/dist/src/ui/Button.d.ts +7 -0
  41. package/dist/src/ui/Button.d.ts.map +1 -0
  42. package/dist/src/ui/ConsentField.d.ts +9 -0
  43. package/dist/src/ui/ConsentField.d.ts.map +1 -0
  44. package/dist/src/ui/FieldError.d.ts +8 -0
  45. package/dist/src/ui/FieldError.d.ts.map +1 -0
  46. package/dist/src/ui/FieldLabel.d.ts +9 -0
  47. package/dist/src/ui/FieldLabel.d.ts.map +1 -0
  48. package/dist/src/ui/TextField.d.ts +19 -0
  49. package/dist/src/ui/TextField.d.ts.map +1 -0
  50. package/dist/src/ui/icons.d.ts +4 -0
  51. package/dist/src/ui/icons.d.ts.map +1 -0
  52. package/dist/usgb-forms.1.0.0.js +44 -0
  53. package/dist/usgb-forms.css +574 -0
  54. package/dist/usgb-forms.js +44 -0
  55. package/forms-manifest.json +249 -0
  56. package/package.json +51 -46
  57. package/dist/index.cjs +0 -64
  58. package/dist/index.cjs.map +0 -1
  59. package/dist/index.d.cts +0 -15
  60. package/dist/index.d.ts +0 -15
  61. package/dist/index.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,36 +1,1037 @@
1
- // src/Form.tsx
2
- import { jsx } from "react/jsx-runtime";
3
- function Form({ children, ...props }) {
4
- return /* @__PURE__ */ jsx("form", { ...props, children });
5
- }
6
-
7
- // src/TextField.tsx
8
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
9
- function TextField({
10
- label,
11
- error,
12
- id,
13
- name,
14
- ...props
15
- }) {
16
- const inputId = id ?? name;
17
- return /* @__PURE__ */ jsxs("div", { children: [
18
- /* @__PURE__ */ jsx2("label", { htmlFor: inputId, children: label }),
19
- /* @__PURE__ */ jsx2(
20
- "input",
21
- {
22
- id: inputId,
23
- name,
24
- ...props,
25
- "aria-invalid": error ? "true" : void 0,
26
- "aria-describedby": error && inputId ? `${inputId}-error` : void 0
1
+ import { jsxs as p, Fragment as Y, jsx as s } from "react/jsx-runtime";
2
+ import { validate as te } from "email-validator";
3
+ import { useId as ne, useMemo as P, useState as ie, useEffect as re, forwardRef as O } from "react";
4
+ import { useForm as oe } from "react-hook-form";
5
+ import x from "classnames";
6
+ const se = "1.0.0", ae = { version: "1.0.0", transport: "server-proxy", payloadShape: "data-and-context" }, le = { page_url: { destination: "form_submission_url", category: "page", collection: "server", required: !0, states: ["collected", "unavailable"], description: "Canonical landing-page URL at submission time" }, page_title: { destination: "pageName", category: "page", collection: "server", required: !1, states: ["collected", "unavailable"] }, referrer: { destination: "referrer", category: "page", collection: "browser", required: !1, states: ["collected", "unavailable"] }, first_touch_url: { destination: "crossDomain_landing_url", category: "attribution", collection: "host-adapter", required: !1, states: ["collected", "unavailable"] }, utm_source: { destination: "utm_source", category: "attribution", collection: "host-adapter", required: !1, states: ["collected", "unavailable"] }, utm_medium: { destination: "utm_medium", category: "attribution", collection: "host-adapter", required: !1, states: ["collected", "unavailable"] }, utm_campaign: { destination: "utm_campaign", category: "attribution", collection: "host-adapter", required: !1, states: ["collected", "unavailable"] }, utm_term: { destination: "utm_term", category: "attribution", collection: "host-adapter", required: !1, states: ["collected", "unavailable"] }, utm_content: { destination: "utm_content", category: "attribution", collection: "host-adapter", required: !1, states: ["collected", "unavailable"] }, gclid: { destination: "gclid", category: "click-id", collection: "host-adapter", required: !1, states: ["collected", "unavailable"] }, msclkid: { destination: "msclkid", category: "click-id", collection: "host-adapter", required: !1, states: ["collected", "unavailable"] }, gbraid: { destination: "gbraid", category: "click-id", collection: "host-adapter", required: !1, states: ["collected", "unavailable"] }, wbraid: { destination: "wbraid", category: "click-id", collection: "host-adapter", required: !1, states: ["collected", "unavailable"] }, hubspot_utk: { destination: "hubspot_utk", category: "identity", collection: "host-adapter", required: !1, states: ["collected", "unavailable", "consent-withheld"] }, ga_client_id: { destination: "ga_client_id", category: "analytics", collection: "host-adapter", required: !1, states: ["collected", "unavailable", "consent-withheld"] }, ga_session_id: { destination: "session_id_start", category: "analytics", collection: "host-adapter", required: !1, states: ["collected", "unavailable", "consent-withheld"] }, snowplow_id: { destination: "snowplow_id", category: "analytics", collection: "host-adapter", required: !1, states: ["collected", "unavailable", "consent-withheld"] }, vwo_uuid: { destination: "vwo_uuid", category: "experiment", collection: "host-adapter", required: !1, states: ["collected", "unavailable", "consent-withheld"] }, user_agent: { destination: "header_http_client_details", category: "technical", collection: "server", required: !1, states: ["collected", "unavailable"] }, ip_address: { destination: "ipAddress", category: "technical", collection: "server", required: !1, states: ["collected", "unavailable"] } }, ce = { "main-investors-kit": { definitionVersion: "1", kind: "lead", flow: { type: "single" }, supportedHosts: ["pwa", "wordpress"], fields: [{ name: "firstname", required: !0, group: "name" }, { name: "lastname", required: !0, group: "name" }, { name: "email", required: !0 }, { name: "phone", required: !1 }], trackingFields: ["page_url", "page_title", "referrer", "first_touch_url", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "gclid", "msclkid", "gbraid", "wbraid", "hubspot_utk", "ga_client_id", "ga_session_id", "snowplow_id", "vwo_uuid", "user_agent", "ip_address"], consent: { definitionId: "lead-tcpa", definitionVersion: "1", required: !0, submitFields: ["tcpa_form_consent_granted", "tcpa_form_opt_in_date"] }, editor: { label: "Main Investors Kit", description: "Standard lead form: name, email, phone, TCPA consent. Use on full-width landing pages and PWA kit/sidebar placements.", whenToUse: "Default kit request. Do not use for affiliate landers or IRA-specific leads.", whenNotToUse: "Affiliate pages (separate definition). IRA kit (separate definition when added).", supportedAppearances: ["light", "navy"], supportedVariants: ["dense", "large", "sidebar", "two-column"] } }, newsletter: { definitionVersion: "1", kind: "newsletter", flow: { type: "single" }, supportedHosts: ["pwa"], fields: [{ name: "email", required: !0 }], trackingFields: ["page_url", "page_title", "referrer", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], editor: { label: "Newsletter", description: "Email-only newsletter signup. No TCPA consent.", whenToUse: "Footer or landing newsletter capture where only an email is required.", whenNotToUse: "Lead kits that need name, phone, or TCPA consent.", supportedAppearances: ["light", "navy"], supportedVariants: [] } } }, de = { hosts: ["pwa", "wordpress"], mayProvide: ["browser cookies", "URL parameters", "page and placement context", "host/store identity"], mustNotDefine: ["new tracking keys", "destination property names", "consent definitions", "form fields", "submission endpoints"] }, ue = {
7
+ schemaVersion: se,
8
+ package: { name: "@usgb/forms", compatiblePackageVersions: "^1.0.0" },
9
+ submissionContract: ae,
10
+ trackingRegistry: le,
11
+ forms: ce,
12
+ hostAdapterContract: de
13
+ }, D = ue;
14
+ function me(t) {
15
+ return D.forms[t];
16
+ }
17
+ function Me() {
18
+ return Object.entries(D.forms).map(([t, e]) => ({
19
+ formId: t,
20
+ definition: e
21
+ }));
22
+ }
23
+ function fe(t, e) {
24
+ return typeof t == "function" ? t(e) : t;
25
+ }
26
+ const U = {
27
+ definitionId: "lead-tcpa",
28
+ definitionVersion: "1",
29
+ requiredLegalUrls: ["clientAgreement", "privacyPolicy"],
30
+ items: [
31
+ {
32
+ type: "checkbox",
33
+ name: "tcpa_form_consent_granted",
34
+ required: !0,
35
+ content: (t) => /* @__PURE__ */ p(Y, { children: [
36
+ "By checking this box, I agree to receive automated text messages from U.S. Gold Bureau. Message and data rates may apply. Consent is not a condition of purchase. View our",
37
+ " ",
38
+ /* @__PURE__ */ s(
39
+ "a",
40
+ {
41
+ href: t.clientAgreement,
42
+ target: "_blank",
43
+ rel: "noreferrer",
44
+ children: "Client Agreement"
45
+ }
46
+ ),
47
+ " ",
48
+ "and",
49
+ " ",
50
+ /* @__PURE__ */ s(
51
+ "a",
52
+ {
53
+ href: t.privacyPolicy,
54
+ target: "_blank",
55
+ rel: "noreferrer",
56
+ children: "Privacy Policy"
57
+ }
58
+ ),
59
+ "."
60
+ ] })
61
+ }
62
+ ]
63
+ }, $ = {
64
+ definitionId: "lead-clickwrap",
65
+ definitionVersion: "1",
66
+ requiredLegalUrls: [
67
+ "privacyPolicy",
68
+ "userAgreement",
69
+ "marketLossPolicy",
70
+ "electronicDisclaimer",
71
+ "termsOfSale"
72
+ ],
73
+ items: [
74
+ {
75
+ type: "notice",
76
+ content: (t) => /* @__PURE__ */ p(Y, { children: [
77
+ "By clicking the button, I agree to be bound by your",
78
+ " ",
79
+ /* @__PURE__ */ s(
80
+ "a",
81
+ {
82
+ href: t.privacyPolicy,
83
+ target: "_blank",
84
+ rel: "noreferrer",
85
+ children: "Privacy Policy"
86
+ }
87
+ ),
88
+ ",",
89
+ " ",
90
+ /* @__PURE__ */ s(
91
+ "a",
92
+ {
93
+ href: t.userAgreement,
94
+ target: "_blank",
95
+ rel: "noreferrer",
96
+ children: "User Agreement"
97
+ }
98
+ ),
99
+ ",",
100
+ " ",
101
+ /* @__PURE__ */ s(
102
+ "a",
103
+ {
104
+ href: t.marketLossPolicy,
105
+ target: "_blank",
106
+ rel: "noreferrer",
107
+ children: "Market Loss Policy"
108
+ }
109
+ ),
110
+ ",",
111
+ " ",
112
+ /* @__PURE__ */ s(
113
+ "a",
114
+ {
115
+ href: t.electronicDisclaimer,
116
+ target: "_blank",
117
+ rel: "noreferrer",
118
+ children: "Electronic Disclaimer"
119
+ }
120
+ ),
121
+ " ",
122
+ "and",
123
+ " ",
124
+ /* @__PURE__ */ s("a", { href: t.termsOfSale, target: "_blank", rel: "noreferrer", children: "Terms & Conditions of Sale" }),
125
+ "."
126
+ ] })
127
+ }
128
+ ]
129
+ }, ge = {
130
+ [`${U.definitionId}@${U.definitionVersion}`]: U,
131
+ [`${$.definitionId}@${$.definitionVersion}`]: $
132
+ };
133
+ function Z(t, e) {
134
+ return ge[`${t}@${e}`];
135
+ }
136
+ function z(t) {
137
+ return (e, n) => n ? e.trim().length > 0 || `${t} is required` : !0;
138
+ }
139
+ const pe = /^[2-9]\d{2}[2-9]\d{6}$/;
140
+ function J(t) {
141
+ let e = t.replace(/\D/g, "");
142
+ return e.length === 11 && e.startsWith("1") && (e = e.slice(1)), e.length !== 10 || !pe.test(e) ? null : e;
143
+ }
144
+ function he(t) {
145
+ const e = t.trim();
146
+ if (!e) return "";
147
+ const n = J(e);
148
+ if (!n) return e;
149
+ const o = e.replace(/\D/g, "");
150
+ return o.length === 11 && o.startsWith("1") ? `1${n}` : n;
151
+ }
152
+ const be = {
153
+ firstname: {
154
+ name: "firstname",
155
+ control: "text",
156
+ label: "First name",
157
+ autoComplete: "given-name",
158
+ validate: z("First name")
159
+ },
160
+ lastname: {
161
+ name: "lastname",
162
+ control: "text",
163
+ label: "Last name",
164
+ autoComplete: "family-name",
165
+ validate: z("Last name")
166
+ },
167
+ email: {
168
+ name: "email",
169
+ control: "email",
170
+ label: "Email",
171
+ autoComplete: "email",
172
+ validate: (t, e) => {
173
+ const n = t.trim();
174
+ return n ? te(n) || "Enter a valid email" : e ? "Email is required" : !0;
175
+ }
176
+ },
177
+ phone: {
178
+ name: "phone",
179
+ control: "tel",
180
+ label: "Phone",
181
+ autoComplete: "tel",
182
+ validate: (t, e) => {
183
+ const n = t.trim();
184
+ return n ? J(n) ? !0 : "Enter a valid phone number" : e ? "Phone is required" : !0;
185
+ },
186
+ serialize: he
187
+ }
188
+ };
189
+ function j(t) {
190
+ return be[t];
191
+ }
192
+ function R({
193
+ className: t,
194
+ appearance: e,
195
+ variantValue: n,
196
+ kind: o,
197
+ children: l
198
+ }) {
199
+ return /* @__PURE__ */ s(
200
+ "div",
201
+ {
202
+ className: `usgb-form ${t ?? ""}`,
203
+ "data-appearance": e,
204
+ ...n ? { "data-variant": n } : {},
205
+ "data-kind": o,
206
+ children: l
207
+ }
208
+ );
209
+ }
210
+ const _e = [
211
+ "hubspot_utk",
212
+ "ga_client_id",
213
+ "ga_session_id",
214
+ "snowplow_id",
215
+ "vwo_uuid"
216
+ ];
217
+ function L(t, e) {
218
+ return t === "collected" && e != null && e !== "" ? { status: "collected", value: e } : { status: t };
219
+ }
220
+ function we(t) {
221
+ const { trackingFields: e, trackingRegistry: n, adapter: o } = t, l = o.getTrackingHints(), a = {};
222
+ for (const i of e) {
223
+ const r = n[i];
224
+ if (!r) continue;
225
+ const c = new Set(r.states);
226
+ if (r.collection === "server") {
227
+ a[i] = L("unavailable");
228
+ continue;
229
+ }
230
+ if (r.collection === "browser") {
231
+ if (i === "referrer" && typeof document < "u") {
232
+ const f = document.referrer;
233
+ a[i] = f ? L("collected", f) : L("unavailable");
234
+ } else
235
+ a[i] = L("unavailable");
236
+ continue;
237
+ }
238
+ const d = l[i];
239
+ if (d != null && d !== "") {
240
+ a[i] = L("collected", d);
241
+ continue;
242
+ }
243
+ if (_e.includes(i) && c.has("consent-withheld")) {
244
+ a[i] = L("unavailable");
245
+ continue;
246
+ }
247
+ a[i] = L("unavailable");
248
+ }
249
+ return a;
250
+ }
251
+ function ke() {
252
+ return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `usgb-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
253
+ }
254
+ function ye(t, e) {
255
+ const n = {};
256
+ for (const o of t)
257
+ n[o.name] = "";
258
+ for (const o of e)
259
+ n[o] = !1;
260
+ return n;
261
+ }
262
+ function M(t) {
263
+ const e = t == null ? void 0 : t.trim();
264
+ return e || void 0;
265
+ }
266
+ function ve({
267
+ formId: t,
268
+ definition: e,
269
+ variantValue: n,
270
+ source: o,
271
+ campaign: l,
272
+ successUrl: a,
273
+ adapter: i,
274
+ analytics: r,
275
+ onAccepted: c,
276
+ onFailed: d
277
+ }) {
278
+ const f = ne(), h = e.consent, w = h ? Z(
279
+ h.definitionId,
280
+ h.definitionVersion
281
+ ) : void 0, g = P(
282
+ () => (w == null ? void 0 : w.items.filter(
283
+ (_) => _.type === "checkbox"
284
+ )) ?? [],
285
+ [w]
286
+ ), k = P(
287
+ () => g.map((_) => _.name),
288
+ [g]
289
+ ), u = P(
290
+ () => ye(e.fields, k),
291
+ [e.fields, k]
292
+ ), {
293
+ register: m,
294
+ handleSubmit: N,
295
+ formState: { errors: b }
296
+ } = oe({
297
+ defaultValues: u
298
+ }), [q, C] = ie({ kind: "idle" });
299
+ re(() => {
300
+ r == null || r({ type: "view", formId: t });
301
+ }, [r, t]);
302
+ const T = P(() => {
303
+ const _ = {};
304
+ for (const S of e.fields)
305
+ _[S.name] = `${f}-${S.name}`;
306
+ for (const S of k)
307
+ _[S] = `${f}-${S}`;
308
+ return _;
309
+ }, [f, e.fields, k]), I = N(async (_) => {
310
+ const S = Object.keys(b);
311
+ if (S.length) {
312
+ r == null || r({
313
+ type: "validation_failure",
314
+ formId: t,
315
+ fields: S
316
+ });
317
+ return;
318
+ }
319
+ r == null || r({ type: "submit_attempt", formId: t }), C({ kind: "submitting" });
320
+ const W = /* @__PURE__ */ new Date(), G = W.toISOString().slice(0, 10), ee = we({
321
+ trackingFields: e.trackingFields,
322
+ trackingRegistry: D.trackingRegistry,
323
+ adapter: i
324
+ }), E = {};
325
+ for (const y of e.fields) {
326
+ const v = _[y.name];
327
+ if (typeof v != "string") {
328
+ E[y.name] = !!v;
329
+ continue;
27
330
  }
28
- ),
29
- error ? /* @__PURE__ */ jsx2("p", { id: inputId ? `${inputId}-error` : void 0, role: "alert", children: error }) : null
331
+ const A = j(y.name);
332
+ E[y.name] = A != null && A.serialize ? A.serialize(v) : v.trim();
333
+ }
334
+ let H;
335
+ if (h && w) {
336
+ const y = {};
337
+ for (const v of g)
338
+ y[v.name] = !!_[v.name], E[v.name] = !!_[v.name];
339
+ h.submitFields.includes("tcpa_form_opt_in_date") && (y.tcpa_form_opt_in_date = G, E.tcpa_form_opt_in_date = G), H = {
340
+ definitionId: h.definitionId,
341
+ definitionVersion: h.definitionVersion,
342
+ values: y,
343
+ timestamp: W.toISOString(),
344
+ source: o,
345
+ placement: n || e.kind
346
+ };
347
+ }
348
+ const V = {
349
+ formId: t,
350
+ definitionVersion: e.definitionVersion,
351
+ submissionContractVersion: D.submissionContract.version,
352
+ idempotencyKey: ke(),
353
+ data: E,
354
+ consent: H,
355
+ context: {
356
+ host: i.host,
357
+ source: o,
358
+ campaign: l,
359
+ page: typeof window < "u" ? window.location.href : void 0,
360
+ tracking: ee
361
+ }
362
+ };
363
+ try {
364
+ const y = await i.submit(V);
365
+ if (y.status === "accepted") {
366
+ r == null || r({ type: "success", formId: t, status: "accepted" }), c == null || c(V), C({ kind: "accepted" });
367
+ const v = M(a);
368
+ v && typeof window < "u" && window.location.assign(v);
369
+ } else
370
+ C({
371
+ kind: "failed",
372
+ message: y.message ?? "Submission failed"
373
+ }), r == null || r({
374
+ type: "failure",
375
+ formId: t,
376
+ message: y.message
377
+ }), d == null || d(V, y.message);
378
+ } catch (y) {
379
+ const v = y instanceof Error ? y.message : "Submission failed";
380
+ C({ kind: "failed", message: v }), r == null || r({ type: "failure", formId: t, message: v }), d == null || d(V, v);
381
+ }
382
+ });
383
+ return {
384
+ register: m,
385
+ errors: b,
386
+ fieldIds: T,
387
+ consentDef: w,
388
+ consentCheckboxes: g,
389
+ uiState: q,
390
+ onSubmit: I
391
+ };
392
+ }
393
+ function Ce() {
394
+ return /* @__PURE__ */ p(
395
+ "svg",
396
+ {
397
+ className: "usgb-field-error-icon",
398
+ width: "14",
399
+ height: "14",
400
+ viewBox: "0 0 14 14",
401
+ fill: "none",
402
+ xmlns: "http://www.w3.org/2000/svg",
403
+ "aria-hidden": "true",
404
+ focusable: "false",
405
+ children: [
406
+ /* @__PURE__ */ s(
407
+ "path",
408
+ {
409
+ d: "M7 13C10.3137 13 13 10.3137 13 7C13 3.68629 10.3137 1 7 1C3.68629 1 1 3.68629 1 7C1 10.3137 3.68629 13 7 13Z",
410
+ fill: "currentColor",
411
+ stroke: "currentColor",
412
+ strokeWidth: "0.7"
413
+ }
414
+ ),
415
+ /* @__PURE__ */ s(
416
+ "path",
417
+ {
418
+ d: "M6.31724 3.75816L6.42662 8.16962H7.57506L7.68444 3.75816H6.31724ZM7.00084 10.4483C7.41555 10.4483 7.74367 10.1338 7.74367 9.73277C7.74367 9.33173 7.41555 9.01727 7.00084 9.01727C6.58613 9.01727 6.258 9.33173 6.258 9.73277C6.258 10.1338 6.58613 10.4483 7.00084 10.4483Z",
419
+ fill: "var(--usgb-primary)"
420
+ }
421
+ )
422
+ ]
423
+ }
424
+ );
425
+ }
426
+ function Se() {
427
+ return /* @__PURE__ */ s(
428
+ "svg",
429
+ {
430
+ className: "usgb-form-checkbox-mark",
431
+ width: "10",
432
+ height: "7",
433
+ viewBox: "0 0 10 7",
434
+ fill: "none",
435
+ xmlns: "http://www.w3.org/2000/svg",
436
+ "aria-hidden": "true",
437
+ focusable: "false",
438
+ children: /* @__PURE__ */ s(
439
+ "path",
440
+ {
441
+ d: "M1 3.5L2.33333 4.75L3.66667 6L9 1",
442
+ stroke: "currentColor",
443
+ strokeWidth: "1.75",
444
+ strokeLinecap: "round",
445
+ strokeLinejoin: "round"
446
+ }
447
+ )
448
+ }
449
+ );
450
+ }
451
+ function K({
452
+ id: t,
453
+ message: e,
454
+ className: n
455
+ }) {
456
+ return e ? /* @__PURE__ */ p(
457
+ "span",
458
+ {
459
+ id: t,
460
+ role: "alert",
461
+ className: x("usgb-field-error", n),
462
+ children: [
463
+ /* @__PURE__ */ s(Ce, {}),
464
+ e
465
+ ]
466
+ }
467
+ ) : null;
468
+ }
469
+ const qe = O(
470
+ function({ id: e, label: n, errorMessage: o, required: l, className: a, ...i }, r) {
471
+ const c = o ? `${e}-error` : void 0;
472
+ return /* @__PURE__ */ p("div", { className: "usgb-form-group", children: [
473
+ /* @__PURE__ */ p("div", { className: "usgb-consent-row", children: [
474
+ /* @__PURE__ */ p("span", { className: "usgb-form-checkbox-wrap", children: [
475
+ /* @__PURE__ */ s(
476
+ "input",
477
+ {
478
+ ref: r,
479
+ id: e,
480
+ type: "checkbox",
481
+ className: x("usgb-form-checkbox", a),
482
+ "aria-invalid": o ? !0 : void 0,
483
+ "aria-describedby": c,
484
+ "aria-required": l || void 0,
485
+ ...i
486
+ }
487
+ ),
488
+ /* @__PURE__ */ s(Se, {})
489
+ ] }),
490
+ /* @__PURE__ */ s("label", { htmlFor: e, className: "usgb-consent-copy", children: n })
491
+ ] }),
492
+ /* @__PURE__ */ s(K, { id: c, message: o })
493
+ ] });
494
+ }
495
+ ), Q = O(
496
+ function({
497
+ className: e,
498
+ variant: n = "primary",
499
+ loading: o = !1,
500
+ disabled: l = !1,
501
+ children: a,
502
+ ...i
503
+ }, r) {
504
+ return /* @__PURE__ */ s(
505
+ "button",
506
+ {
507
+ ref: r,
508
+ type: i.type ?? "button",
509
+ className: x(
510
+ "usgb-btn",
511
+ n === "primary" && "usgb-btn-primary",
512
+ e
513
+ ),
514
+ disabled: l || o,
515
+ "aria-busy": o || void 0,
516
+ ...i,
517
+ children: o ? "Submitting…" : a
518
+ }
519
+ );
520
+ }
521
+ ), Be = {
522
+ clientAgreement: "/content/client-agreement",
523
+ privacyPolicy: "/content/privacy-policy"
524
+ };
525
+ function Ne(t, e = ["clientAgreement", "privacyPolicy"]) {
526
+ return e.every((n) => {
527
+ var o;
528
+ return !!((o = t == null ? void 0 : t[n]) != null && o.trim());
529
+ });
530
+ }
531
+ function Le(t) {
532
+ const e = [];
533
+ let n = 0;
534
+ for (; n < t.length; ) {
535
+ const o = t[n];
536
+ if (o.group) {
537
+ const l = o.group, a = [];
538
+ for (; n < t.length && t[n].group === l; )
539
+ a.push(t[n]), n += 1;
540
+ e.push({ type: "group", group: l, fields: a });
541
+ continue;
542
+ }
543
+ e.push({ type: "field", field: o }), n += 1;
544
+ }
545
+ return e;
546
+ }
547
+ function Ee({
548
+ htmlFor: t,
549
+ children: e,
550
+ className: n,
551
+ required: o
552
+ }) {
553
+ return /* @__PURE__ */ p("label", { htmlFor: t, className: x("usgb-field-label", n), children: [
554
+ e,
555
+ o ? /* @__PURE__ */ s("span", { className: "usgb-field-label-asterisk", "aria-hidden": "true", children: "*" }) : null
30
556
  ] });
31
557
  }
558
+ function Fe(t) {
559
+ return t.replace(/\b\w/g, (e) => e.toUpperCase());
560
+ }
561
+ const Pe = O(
562
+ function({
563
+ id: e,
564
+ label: n,
565
+ type: o = "text",
566
+ errorMessage: l,
567
+ required: a,
568
+ hideLabel: i = !1,
569
+ placeholderCase: r = "upper",
570
+ showError: c = !0,
571
+ className: d,
572
+ placeholder: f,
573
+ ...h
574
+ }, w) {
575
+ const g = l ? `${e}-error` : void 0, k = i ? `${n}${a ? "*" : ""}` : f, u = i && k ? r === "title" ? Fe(k) : k.toUpperCase() : k;
576
+ return /* @__PURE__ */ p("div", { className: "usgb-form-group", children: [
577
+ /* @__PURE__ */ s(
578
+ Ee,
579
+ {
580
+ htmlFor: e,
581
+ required: a,
582
+ className: i ? "usgb-field-label--sr-only" : void 0,
583
+ children: n
584
+ }
585
+ ),
586
+ /* @__PURE__ */ s(
587
+ "input",
588
+ {
589
+ ref: w,
590
+ id: e,
591
+ type: o,
592
+ className: x(
593
+ "usgb-field-control",
594
+ l && "usgb-field-invalid",
595
+ d
596
+ ),
597
+ placeholder: u,
598
+ "aria-invalid": l ? !0 : void 0,
599
+ "aria-describedby": g,
600
+ "aria-required": a || void 0,
601
+ ...h
602
+ }
603
+ ),
604
+ c ? /* @__PURE__ */ s(K, { id: g, message: l }) : null
605
+ ] });
606
+ }
607
+ );
608
+ function B({
609
+ fieldRef: t,
610
+ fieldIds: e,
611
+ register: n,
612
+ errors: o,
613
+ hideLabel: l,
614
+ placeholderCase: a,
615
+ showError: i = !0
616
+ }) {
617
+ const r = j(t.name);
618
+ if (!r) return null;
619
+ const c = o[t.name], d = typeof (c == null ? void 0 : c.message) == "string" ? c.message : void 0;
620
+ return /* @__PURE__ */ s(
621
+ Pe,
622
+ {
623
+ id: e[t.name],
624
+ label: r.label,
625
+ type: r.control,
626
+ required: t.required,
627
+ hideLabel: l,
628
+ placeholderCase: a,
629
+ showError: i,
630
+ autoComplete: r.autoComplete,
631
+ errorMessage: d,
632
+ ...n(t.name, {
633
+ validate: (f) => r.validate(
634
+ typeof f == "string" ? f : "",
635
+ t.required
636
+ )
637
+ })
638
+ }
639
+ );
640
+ }
641
+ function xe({
642
+ definition: t,
643
+ variants: e,
644
+ ctaLabel: n,
645
+ legalUrls: o,
646
+ session: l
647
+ }) {
648
+ const { register: a, errors: i, fieldIds: r, consentDef: c, uiState: d, onSubmit: f } = l, h = P(
649
+ () => Le(t.fields),
650
+ [t.fields]
651
+ ), w = e.includes("sidebar"), g = e.includes("dense") || w, k = w ? "title" : "upper";
652
+ return /* @__PURE__ */ p("form", { onSubmit: f, noValidate: !0, children: [
653
+ h.map((u) => u.type === "group" ? /* @__PURE__ */ s(
654
+ "div",
655
+ {
656
+ className: "usgb-form-grid",
657
+ children: u.fields.map((m) => /* @__PURE__ */ s(
658
+ B,
659
+ {
660
+ fieldRef: m,
661
+ fieldIds: r,
662
+ register: a,
663
+ errors: i,
664
+ hideLabel: g,
665
+ placeholderCase: k
666
+ },
667
+ m.name
668
+ ))
669
+ },
670
+ `group-${u.group}-${u.fields.map((m) => m.name).join("-")}`
671
+ ) : /* @__PURE__ */ s(
672
+ B,
673
+ {
674
+ fieldRef: u.field,
675
+ fieldIds: r,
676
+ register: a,
677
+ errors: i,
678
+ hideLabel: g,
679
+ placeholderCase: k
680
+ },
681
+ u.field.name
682
+ )),
683
+ c && Ne(o, c.requiredLegalUrls) ? c.items.map((u, m) => {
684
+ const N = fe(
685
+ u.content,
686
+ o
687
+ );
688
+ if (u.type === "notice")
689
+ return /* @__PURE__ */ s(
690
+ "p",
691
+ {
692
+ className: "usgb-consent-copy usgb-consent-notice",
693
+ children: N
694
+ },
695
+ `notice-${m}`
696
+ );
697
+ const b = i[u.name], q = typeof (b == null ? void 0 : b.message) == "string" ? b.message : void 0;
698
+ return /* @__PURE__ */ s(
699
+ qe,
700
+ {
701
+ id: r[u.name],
702
+ label: N,
703
+ required: u.required,
704
+ errorMessage: q,
705
+ ...a(u.name, {
706
+ required: u.required ? "This field is required" : !1
707
+ })
708
+ },
709
+ u.name
710
+ );
711
+ }) : null,
712
+ /* @__PURE__ */ s(Q, { type: "submit", loading: d.kind === "submitting", children: n }),
713
+ d.kind === "failed" ? /* @__PURE__ */ s(
714
+ "p",
715
+ {
716
+ className: "usgb-form-status usgb-form-status-error",
717
+ role: "alert",
718
+ children: d.message ?? "Something went wrong. Please try again."
719
+ }
720
+ ) : null
721
+ ] });
722
+ }
723
+ function Te({
724
+ definition: t,
725
+ ctaLabel: e,
726
+ session: n
727
+ }) {
728
+ var f;
729
+ const { register: o, errors: l, fieldIds: a, uiState: i, onSubmit: r } = n, c = t.fields.find((h) => h.name === "email"), d = typeof ((f = l.email) == null ? void 0 : f.message) == "string" ? l.email.message : void 0;
730
+ return c ? /* @__PURE__ */ p("form", { onSubmit: r, noValidate: !0, children: [
731
+ /* @__PURE__ */ p("div", { className: "usgb-form-inline", children: [
732
+ /* @__PURE__ */ s(
733
+ B,
734
+ {
735
+ fieldRef: c,
736
+ fieldIds: a,
737
+ register: o,
738
+ errors: l,
739
+ hideLabel: !0,
740
+ placeholderCase: "upper",
741
+ showError: !1
742
+ }
743
+ ),
744
+ /* @__PURE__ */ s(Q, { type: "submit", loading: i.kind === "submitting", children: e })
745
+ ] }),
746
+ /* @__PURE__ */ s(
747
+ K,
748
+ {
749
+ id: d ? `${a.email}-error` : void 0,
750
+ message: d
751
+ }
752
+ ),
753
+ i.kind === "failed" ? /* @__PURE__ */ s(
754
+ "p",
755
+ {
756
+ className: "usgb-form-status usgb-form-status-error",
757
+ role: "alert",
758
+ children: i.message ?? "Something went wrong. Please try again."
759
+ }
760
+ ) : null
761
+ ] }) : /* @__PURE__ */ s("p", { className: "usgb-form-status usgb-form-status-error", role: "alert", children: "Newsletter kind requires an email field" });
762
+ }
763
+ const X = {
764
+ lead: xe,
765
+ newsletter: Te
766
+ }, Ie = "Thank you. Your request has been accepted and is being processed.";
767
+ function F({
768
+ className: t,
769
+ appearance: e,
770
+ variantValue: n,
771
+ kind: o,
772
+ children: l
773
+ }) {
774
+ return /* @__PURE__ */ s(
775
+ R,
776
+ {
777
+ className: t,
778
+ appearance: e,
779
+ variantValue: n,
780
+ kind: o,
781
+ children: /* @__PURE__ */ s("p", { className: "usgb-form-status usgb-form-status-error", role: "alert", children: l })
782
+ }
783
+ );
784
+ }
785
+ function Ve({
786
+ formId: t,
787
+ definition: e,
788
+ appearance: n,
789
+ variants: o,
790
+ variantValue: l,
791
+ heading: a,
792
+ body: i,
793
+ ctaLabel: r,
794
+ source: c,
795
+ campaign: d,
796
+ legalUrls: f,
797
+ successMessage: h,
798
+ successUrl: w,
799
+ adapter: g,
800
+ analytics: k,
801
+ className: u,
802
+ onAccepted: m,
803
+ onFailed: N
804
+ }) {
805
+ const b = ve({
806
+ formId: t,
807
+ definition: e,
808
+ variantValue: l,
809
+ source: c,
810
+ campaign: d,
811
+ successUrl: w,
812
+ adapter: g,
813
+ analytics: k,
814
+ onAccepted: m,
815
+ onFailed: N
816
+ });
817
+ if (b.uiState.kind === "accepted") {
818
+ const C = !!M(w);
819
+ return /* @__PURE__ */ p(
820
+ R,
821
+ {
822
+ className: u,
823
+ appearance: n,
824
+ variantValue: l,
825
+ kind: e.kind,
826
+ children: [
827
+ a ? /* @__PURE__ */ s("h2", { className: "usgb-form-heading", children: a }) : null,
828
+ C ? null : /* @__PURE__ */ s(
829
+ "p",
830
+ {
831
+ className: "usgb-form-status usgb-form-status-success",
832
+ role: "status",
833
+ children: M(h) ?? Ie
834
+ }
835
+ )
836
+ ]
837
+ }
838
+ );
839
+ }
840
+ const q = X[e.kind];
841
+ return /* @__PURE__ */ p(
842
+ R,
843
+ {
844
+ className: u,
845
+ appearance: n,
846
+ variantValue: l,
847
+ kind: e.kind,
848
+ children: [
849
+ a ? /* @__PURE__ */ s("h2", { className: "usgb-form-heading", children: a }) : null,
850
+ i ? /* @__PURE__ */ s("p", { className: "usgb-form-body", children: i }) : null,
851
+ /* @__PURE__ */ s(
852
+ q,
853
+ {
854
+ definition: e,
855
+ variants: o,
856
+ ctaLabel: r,
857
+ legalUrls: f,
858
+ session: b
859
+ }
860
+ )
861
+ ]
862
+ }
863
+ );
864
+ }
865
+ function Oe({
866
+ formId: t,
867
+ appearance: e = "light",
868
+ variants: n = ["dense"],
869
+ heading: o,
870
+ body: l,
871
+ ctaLabel: a = "GET MY FREE GUIDE",
872
+ source: i,
873
+ campaign: r,
874
+ legalUrls: c,
875
+ successMessage: d,
876
+ successUrl: f,
877
+ adapter: h,
878
+ analytics: w,
879
+ className: g,
880
+ onAccepted: k,
881
+ onFailed: u
882
+ }) {
883
+ const m = me(t), b = (m == null ? void 0 : m.kind) === "newsletter" ? "" : n.join(" ");
884
+ if (!m)
885
+ return /* @__PURE__ */ p(
886
+ F,
887
+ {
888
+ className: g,
889
+ appearance: e,
890
+ variantValue: b,
891
+ children: [
892
+ "Unknown form definition: ",
893
+ t
894
+ ]
895
+ }
896
+ );
897
+ const q = m.consent, C = q ? Z(
898
+ q.definitionId,
899
+ q.definitionVersion
900
+ ) : void 0;
901
+ if (q && !C)
902
+ return /* @__PURE__ */ p(
903
+ F,
904
+ {
905
+ className: g,
906
+ appearance: e,
907
+ variantValue: b,
908
+ kind: m.kind,
909
+ children: [
910
+ "Missing consent definition for ",
911
+ t
912
+ ]
913
+ }
914
+ );
915
+ const T = (C == null ? void 0 : C.requiredLegalUrls.filter(
916
+ (_) => {
917
+ var S;
918
+ return !((S = c == null ? void 0 : c[_]) != null && S.trim());
919
+ }
920
+ )) ?? [];
921
+ if (C && T.length)
922
+ return /* @__PURE__ */ p(
923
+ F,
924
+ {
925
+ className: g,
926
+ appearance: e,
927
+ variantValue: b,
928
+ kind: m.kind,
929
+ children: [
930
+ "Missing legal URL(s) for ",
931
+ t,
932
+ ": ",
933
+ T.join(", ")
934
+ ]
935
+ }
936
+ );
937
+ const I = m.fields.filter(
938
+ (_) => !j(_.name)
939
+ );
940
+ return I.length ? /* @__PURE__ */ p(
941
+ F,
942
+ {
943
+ className: g,
944
+ appearance: e,
945
+ variantValue: b,
946
+ kind: m.kind,
947
+ children: [
948
+ "Unknown field(s) in ",
949
+ t,
950
+ ":",
951
+ " ",
952
+ I.map((_) => _.name).join(", ")
953
+ ]
954
+ }
955
+ ) : m.kind in X ? /* @__PURE__ */ s(
956
+ Ve,
957
+ {
958
+ formId: t,
959
+ definition: m,
960
+ appearance: e,
961
+ variants: n,
962
+ variantValue: b,
963
+ heading: o,
964
+ body: l,
965
+ ctaLabel: a,
966
+ source: i,
967
+ campaign: r,
968
+ legalUrls: c,
969
+ successMessage: d,
970
+ successUrl: f,
971
+ adapter: h,
972
+ analytics: w,
973
+ className: g,
974
+ onAccepted: k,
975
+ onFailed: u
976
+ }
977
+ ) : /* @__PURE__ */ p(
978
+ F,
979
+ {
980
+ className: g,
981
+ appearance: e,
982
+ variantValue: b,
983
+ kind: m.kind,
984
+ children: [
985
+ "Missing renderer for kind: ",
986
+ m.kind
987
+ ]
988
+ }
989
+ );
990
+ }
991
+ function je(t = {}) {
992
+ const e = typeof t == "string" ? { host: t } : t, n = e.host ?? "pwa", o = e.delayMs ?? 400, l = e.result ?? { status: "accepted" };
993
+ return {
994
+ host: n,
995
+ getTrackingHints() {
996
+ if (typeof window > "u") return {};
997
+ const a = new URLSearchParams(window.location.search), i = (r) => a.get(r) ?? void 0;
998
+ return {
999
+ utm_source: i("utm_source"),
1000
+ utm_medium: i("utm_medium"),
1001
+ utm_campaign: i("utm_campaign"),
1002
+ utm_term: i("utm_term"),
1003
+ utm_content: i("utm_content"),
1004
+ gclid: i("gclid"),
1005
+ msclkid: i("msclkid"),
1006
+ gbraid: i("gbraid"),
1007
+ wbraid: i("wbraid")
1008
+ };
1009
+ },
1010
+ async submit(a) {
1011
+ var i;
1012
+ return (i = e.onSubmit) == null || i.call(e, a), await new Promise((r) => setTimeout(r, o)), l;
1013
+ }
1014
+ };
1015
+ }
32
1016
  export {
33
- Form,
34
- TextField
1017
+ Q as Button,
1018
+ qe as ConsentField,
1019
+ be as FIELD_REGISTRY,
1020
+ K as FieldError,
1021
+ Ee as FieldLabel,
1022
+ $ as LEAD_CLICKWRAP_V1,
1023
+ U as LEAD_TCPA_V1,
1024
+ Be as PWA_LEGAL_URLS,
1025
+ Pe as TextField,
1026
+ Oe as UsgbForm,
1027
+ we as collectTrackingContext,
1028
+ ke as createIdempotencyKey,
1029
+ je as createStubAdapter,
1030
+ D as formsManifest,
1031
+ Z as getConsentDefinition,
1032
+ j as getFieldDefinition,
1033
+ me as getFormDefinition,
1034
+ Ne as isCompleteLegalUrls,
1035
+ Me as listFormDefinitions,
1036
+ fe as resolveConsentContent
35
1037
  };
36
- //# sourceMappingURL=index.js.map