@nodii/onboarding 0.1.0-dev.0 → 0.1.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.
- package/README.md +78 -0
- package/dist/chunk-AZE3NPSY.js +186 -0
- package/dist/chunk-AZE3NPSY.js.map +1 -0
- package/dist/{chunk-BQCTDU5V.js → chunk-BMQINH6O.js} +89 -15
- package/dist/chunk-BMQINH6O.js.map +1 -0
- package/dist/{chunk-34BQX2KR.js → chunk-F75ZJERM.js} +41 -6
- package/dist/chunk-F75ZJERM.js.map +1 -0
- package/dist/chunk-FIRSA7EH.js +3 -0
- package/dist/{chunk-ZDY2I6KY.js.map → chunk-FIRSA7EH.js.map} +1 -1
- package/dist/{chunk-SWMIIUXR.js → chunk-IPAKPLIF.js} +590 -92
- package/dist/chunk-IPAKPLIF.js.map +1 -0
- package/dist/chunk-JFDQZ3AC.js +3 -0
- package/dist/chunk-JFDQZ3AC.js.map +1 -0
- package/dist/{chunk-4SWOVHZ2.js → chunk-KQTS47FC.js} +129 -17
- package/dist/chunk-KQTS47FC.js.map +1 -0
- package/dist/chunk-LVJM4CTG.js +306 -0
- package/dist/chunk-LVJM4CTG.js.map +1 -0
- package/dist/chunk-SEKNVHD3.js +59 -0
- package/dist/chunk-SEKNVHD3.js.map +1 -0
- package/dist/chunk-SIMLMQPT.js +37 -0
- package/dist/chunk-SIMLMQPT.js.map +1 -0
- package/dist/chunk-U56GQITG.js +79 -0
- package/dist/chunk-U56GQITG.js.map +1 -0
- package/dist/{chunk-AFCJLUPK.js → chunk-U6AXKGYQ.js} +14 -5
- package/dist/chunk-U6AXKGYQ.js.map +1 -0
- package/dist/{chunk-AW7W3HAC.js → chunk-XJTJPBJB.js} +40 -3
- package/dist/chunk-XJTJPBJB.js.map +1 -0
- package/dist/client-CqE2dF9A.d.ts +86 -0
- package/dist/consent/index.d.ts +59 -0
- package/dist/consent/index.js +7 -0
- package/dist/consent/index.js.map +1 -0
- package/dist/controller-BQb62D0N.d.ts +177 -0
- package/dist/dynamic/index.d.ts +57 -6
- package/dist/dynamic/index.js +4 -2
- package/dist/errors-vJkye4a0.d.ts +110 -0
- package/dist/form/index.d.ts +2 -2
- package/dist/form/index.js +2 -2
- package/dist/index-Dqfa890U.d.ts +83 -0
- package/dist/index.d.ts +12 -6
- package/dist/index.js +12 -8
- package/dist/{model-IEyDI54w.d.ts → model-ESLSEbi0.d.ts} +199 -46
- package/dist/model-mnjAEtKe.d.ts +253 -0
- package/dist/render-DC7P2BGQ.js +5 -0
- package/dist/render-DC7P2BGQ.js.map +1 -0
- package/dist/schema-BrXb9gnh.d.ts +267 -0
- package/dist/{signup-client-Bl6eUrxR.d.ts → signup-client-BL5DfarJ.d.ts} +152 -19
- package/dist/spec/index.d.ts +10 -81
- package/dist/spec/index.js +3 -2
- package/dist/submit/index.d.ts +7 -71
- package/dist/submit/index.js +3 -3
- package/dist/viewer/index.d.ts +4 -0
- package/dist/viewer/index.js +5 -0
- package/dist/viewer/index.js.map +1 -0
- package/dist/widget/index.d.ts +50 -7
- package/dist/widget/index.js +9 -7
- package/package.json +21 -2
- package/dist/chunk-34BQX2KR.js.map +0 -1
- package/dist/chunk-4SWOVHZ2.js.map +0 -1
- package/dist/chunk-AFCJLUPK.js.map +0 -1
- package/dist/chunk-AW7W3HAC.js.map +0 -1
- package/dist/chunk-BIFANV7M.js +0 -22
- package/dist/chunk-BIFANV7M.js.map +0 -1
- package/dist/chunk-BQCTDU5V.js.map +0 -1
- package/dist/chunk-SWMIIUXR.js.map +0 -1
- package/dist/chunk-ZDY2I6KY.js +0 -3
- package/dist/schema-TfyBU6JW.d.ts +0 -107
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/widget/dom-utils.ts","../src/widget/styles.ts","../src/widget/contact-form.ts","../src/widget/consent-step.ts","../src/widget/signup-form.ts","../src/widget/index.ts"],"names":["el"],"mappings":";;;;;;;;AAiBO,SAAS,UAAU,KAAA,EAAuB;AAC/C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AA,KAC7E;AAAA,EACF;AACF","file":"chunk-IPAKPLIF.js","sourcesContent":["/**\n * Shared DOM helpers for the widget layer.\n *\n * `idSelector` builds a `#id` CSS selector with the id CSS-escaped, so a field\n * key (which originates in the fetched onboarder spec) can never break out of\n * the selector or match unintended nodes. This is defense-in-depth: the spec\n * model already constrains field keys to `[A-Za-z0-9_-]+` (FIELD_KEY_PATTERN),\n * but the escaping guarantees selector safety even for the widget's own\n * internally-composed ids and for any future relaxation of that alphabet.\n */\n\n/**\n * CSS-escape a string for safe use as an identifier in a selector.\n * Uses the standard `CSS.escape` when available (all modern browsers), with a\n * spec-compliant-enough fallback for non-DOM/test runtimes: escape everything\n * that is not an ASCII identifier char.\n */\nexport function cssEscape(value: string): string {\n const g = globalThis as { CSS?: { escape?: (v: string) => string } };\n if (g.CSS && typeof g.CSS.escape === \"function\") {\n return g.CSS.escape(value);\n }\n // Fallback: backslash-escape any char outside [A-Za-z0-9_-]. Sufficient to\n // neutralize CSS metacharacters ([]().,#*:>+~ whitespace, quotes, etc.).\n return value.replace(/[^A-Za-z0-9_-]/g, (ch) => `\\\\${ch}`);\n}\n\n/** Build a safe `#id` selector with the id CSS-escaped. */\nexport function idSelector(id: string): string {\n return `#${cssEscape(id)}`;\n}\n","/// <reference lib=\"dom\" />\n/// <reference lib=\"dom.iterable\" />\n/**\n * Default CSS for the onboarding contact form widget.\n *\n * Uses CSS custom properties (variables) for theming. Consumers override\n * these on the host element or globally:\n *\n * --nodii-onboarding-font-family\n * --nodii-onboarding-primary-color\n * --nodii-onboarding-primary-hover\n * --nodii-onboarding-error-color\n * --nodii-onboarding-border-color\n * --nodii-onboarding-input-bg\n * --nodii-onboarding-label-color\n * --nodii-onboarding-radius\n * --nodii-onboarding-spacing\n *\n * The widget scopes all styles under `.nodii-onboarding-widget` to avoid\n * leaking into the host page.\n */\n\nexport const DEFAULT_WIDGET_CSS = `\n.nodii-onboarding-widget {\n --_font: var(--nodii-onboarding-font-family, system-ui, -apple-system, sans-serif);\n --_primary: var(--nodii-onboarding-primary-color, #2563eb);\n --_primary-hover: var(--nodii-onboarding-primary-hover, #1d4ed8);\n --_error: var(--nodii-onboarding-error-color, #dc2626);\n --_border: var(--nodii-onboarding-border-color, #d1d5db);\n --_input-bg: var(--nodii-onboarding-input-bg, #fff);\n --_label: var(--nodii-onboarding-label-color, #374151);\n --_radius: var(--nodii-onboarding-radius, 6px);\n --_spacing: var(--nodii-onboarding-spacing, 16px);\n\n font-family: var(--_font);\n box-sizing: border-box;\n}\n\n.nodii-onboarding-widget *,\n.nodii-onboarding-widget *::before,\n.nodii-onboarding-widget *::after {\n box-sizing: inherit;\n}\n\n.nodii-onboarding-field {\n display: flex;\n flex-direction: column;\n gap: calc(var(--_spacing) * 0.25);\n margin-bottom: var(--_spacing);\n}\n\n.nodii-onboarding-label {\n font-size: 0.875rem;\n font-weight: 500;\n color: var(--_label);\n}\n\n.nodii-onboarding-label.required::after {\n content: \" *\";\n color: var(--_error);\n}\n\n.nodii-onboarding-input,\n.nodii-onboarding-textarea {\n width: 100%;\n padding: calc(var(--_spacing) * 0.5) calc(var(--_spacing) * 0.75);\n border: 1px solid var(--_border);\n border-radius: var(--_radius);\n background: var(--_input-bg);\n font-family: var(--_font);\n font-size: 1rem;\n line-height: 1.5;\n outline: none;\n transition: border-color 0.15s ease;\n}\n\n.nodii-onboarding-input:focus,\n.nodii-onboarding-textarea:focus {\n border-color: var(--_primary);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--_primary) 20%, transparent);\n}\n\n.nodii-onboarding-input.has-error,\n.nodii-onboarding-textarea.has-error {\n border-color: var(--_error);\n}\n\n.nodii-onboarding-textarea {\n min-height: 100px;\n resize: vertical;\n}\n\n.nodii-onboarding-field-error {\n font-size: 0.75rem;\n color: var(--_error);\n margin-top: 2px;\n}\n\n.nodii-onboarding-server-error {\n padding: calc(var(--_spacing) * 0.75);\n border-radius: var(--_radius);\n background: color-mix(in srgb, var(--_error) 8%, transparent);\n border: 1px solid color-mix(in srgb, var(--_error) 30%, transparent);\n color: var(--_error);\n font-size: 0.875rem;\n margin-bottom: var(--_spacing);\n}\n\n.nodii-onboarding-success {\n padding: var(--_spacing);\n border-radius: var(--_radius);\n background: #f0fdf4;\n border: 1px solid #bbf7d0;\n color: #15803d;\n font-size: 0.9375rem;\n text-align: center;\n}\n\n.nodii-onboarding-submit-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n padding: calc(var(--_spacing) * 0.625) var(--_spacing);\n background: var(--_primary);\n color: #fff;\n border: none;\n border-radius: var(--_radius);\n font-family: var(--_font);\n font-size: 1rem;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.15s ease;\n}\n\n.nodii-onboarding-submit-btn:hover:not(:disabled) {\n background: var(--_primary-hover);\n}\n\n.nodii-onboarding-submit-btn:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n.nodii-onboarding-spinner {\n display: inline-block;\n width: 1em;\n height: 1em;\n border: 2px solid rgba(255,255,255,0.4);\n border-top-color: #fff;\n border-radius: 50%;\n animation: nodii-spin 0.6s linear infinite;\n margin-right: 0.5em;\n}\n\n@keyframes nodii-spin {\n to { transform: rotate(360deg); }\n}\n\n.nodii-onboarding-recaptcha-notice {\n font-size: 0.7rem;\n color: #6b7280;\n margin-top: calc(var(--_spacing) * 0.5);\n text-align: center;\n}\n\n.nodii-onboarding-recaptcha-notice a {\n color: inherit;\n}\n\n/* ── dynamic stepper (signup form) ── */\n\n.nodii-onboarding-steps {\n display: flex;\n gap: calc(var(--_spacing) * 0.5);\n margin-bottom: var(--_spacing);\n}\n\n.nodii-onboarding-step-dot {\n flex: 1;\n height: 4px;\n border-radius: 2px;\n background: var(--_border);\n}\n\n.nodii-onboarding-step-dot.active {\n background: var(--_primary);\n}\n\n.nodii-onboarding-stage-title {\n font-size: 1.0625rem;\n font-weight: 600;\n color: var(--_label);\n margin: 0 0 var(--_spacing) 0;\n}\n\n.nodii-onboarding-nav {\n display: flex;\n gap: calc(var(--_spacing) * 0.5);\n margin-top: var(--_spacing);\n}\n\n.nodii-onboarding-back-btn {\n padding: calc(var(--_spacing) * 0.625) var(--_spacing);\n background: transparent;\n color: var(--_label);\n border: 1px solid var(--_border);\n border-radius: var(--_radius);\n font-family: var(--_font);\n font-size: 1rem;\n cursor: pointer;\n}\n\n.nodii-onboarding-stale-banner {\n padding: calc(var(--_spacing) * 0.75);\n border-radius: var(--_radius);\n background: #fffbeb;\n border: 1px solid #fcd34d;\n color: #92400e;\n font-size: 0.875rem;\n margin-bottom: var(--_spacing);\n}\n\n.nodii-onboarding-consent-row {\n display: flex;\n align-items: flex-start;\n gap: calc(var(--_spacing) * 0.5);\n margin-bottom: calc(var(--_spacing) * 0.5);\n font-size: 0.875rem;\n color: var(--_label);\n}\n\n.nodii-onboarding-consent-row input[type=\"checkbox\"] {\n margin-top: 3px;\n}\n\n.nodii-onboarding-account-section {\n border-top: 1px solid var(--_border);\n margin-top: var(--_spacing);\n padding-top: var(--_spacing);\n}\n\n.nodii-onboarding-loading {\n padding: var(--_spacing);\n text-align: center;\n color: var(--_label);\n}\n\n/* ── D543 ConsentPack step (full-width, generous spacing) ── */\n\n.nodii-onboarding-consent-stage {\n /* Full-bleed within the widget host — consent cards may span the page. */\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: calc(var(--_spacing) * 2);\n margin: calc(var(--_spacing) * 1.5) 0;\n}\n\n.nodii-onboarding-consent-intro {\n font-size: 0.9375rem;\n color: var(--_label);\n margin: 0 0 calc(var(--_spacing) * 0.5) 0;\n line-height: 1.6;\n}\n\n.nodii-onboarding-consent-card {\n width: 100%;\n border: 1px solid var(--_border);\n border-radius: var(--_radius);\n background: var(--_input-bg);\n padding: calc(var(--_spacing) * 1.5);\n display: flex;\n flex-direction: column;\n gap: var(--_spacing);\n}\n\n.nodii-onboarding-consent-card.is-stale {\n border-color: #fcd34d;\n background: #fffbeb;\n}\n\n.nodii-onboarding-consent-card.has-error {\n border-color: var(--_error);\n}\n\n.nodii-onboarding-consent-title {\n font-size: 1.125rem;\n font-weight: 600;\n color: var(--_label);\n margin: 0;\n}\n\n.nodii-onboarding-consent-stale-tag {\n font-size: 0.8125rem;\n font-weight: 500;\n color: #92400e;\n}\n\n.nodii-onboarding-consent-gate {\n width: 100%;\n}\n\n.nodii-onboarding-consent-scrollbox {\n width: 100%;\n height: 360px;\n overflow-y: auto;\n border: 1px solid var(--_border);\n border-radius: var(--_radius);\n background: #fff;\n position: relative;\n}\n\n.nodii-onboarding-consent-scrollbox:focus {\n outline: none;\n border-color: var(--_primary);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--_primary) 20%, transparent);\n}\n\n/* Inline, same-origin document content (no iframe). Rendered by the default\n viewer: sanitized HTML/markdown, escaped plain text, or PDF.js canvases. */\n.nodii-onboarding-consent-doc-body {\n padding: var(--_spacing);\n font-size: 0.9375rem;\n line-height: 1.7;\n color: var(--_label);\n word-break: break-word;\n}\n\n.nodii-onboarding-consent-doc-body:not(.nodii-consent-pdf) {\n white-space: pre-wrap;\n}\n\n.nodii-onboarding-consent-doc-loading {\n padding: var(--_spacing);\n color: #6b7280;\n font-size: 0.875rem;\n}\n\n.nodii-consent-pdf {\n display: flex;\n flex-direction: column;\n gap: var(--_spacing);\n white-space: normal;\n}\n\n.nodii-consent-pdf-page {\n max-width: 100%;\n height: auto;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);\n}\n\n.nodii-onboarding-consent-note {\n font-size: 0.8125rem;\n color: #6b7280;\n margin: calc(var(--_spacing) * 0.5) 0 0 0;\n}\n\n/* A gated doc that could not be rendered inline: the gate stays unsatisfiable\n (accept disabled); we surface a clear error + Retry. NO click-to-satisfy. */\n.nodii-onboarding-consent-unrenderable {\n display: flex;\n flex-direction: column;\n gap: calc(var(--_spacing) * 0.5);\n padding: var(--_spacing);\n border: 1px solid color-mix(in srgb, var(--_error) 30%, transparent);\n border-radius: var(--_radius);\n background: color-mix(in srgb, var(--_error) 6%, transparent);\n}\n\n.nodii-onboarding-consent-retry {\n align-self: flex-start;\n padding: calc(var(--_spacing) * 0.5) var(--_spacing);\n background: transparent;\n color: var(--_primary);\n border: 1px solid var(--_primary);\n border-radius: var(--_radius);\n font-family: var(--_font);\n font-size: 0.875rem;\n cursor: pointer;\n}\n\n.nodii-onboarding-consent-open-row,\n.nodii-onboarding-consent-preview-row {\n display: flex;\n}\n\n.nodii-onboarding-consent-open {\n display: inline-flex;\n align-items: center;\n padding: calc(var(--_spacing) * 0.625) var(--_spacing);\n border: 1px solid var(--_primary);\n border-radius: var(--_radius);\n color: var(--_primary);\n text-decoration: none;\n font-size: 0.9375rem;\n font-weight: 500;\n}\n\n.nodii-onboarding-consent-open:hover {\n background: color-mix(in srgb, var(--_primary) 8%, transparent);\n}\n\n.nodii-onboarding-consent-preview {\n font-size: 0.875rem;\n color: var(--_primary);\n}\n\n.nodii-onboarding-consent-accept-row {\n display: flex;\n align-items: flex-start;\n gap: calc(var(--_spacing) * 0.5);\n}\n\n.nodii-onboarding-consent-accept {\n margin-top: 3px;\n width: 1.125rem;\n height: 1.125rem;\n}\n\n.nodii-onboarding-consent-accept:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n\n.nodii-onboarding-consent-accept-label {\n font-size: 0.9375rem;\n color: var(--_label);\n line-height: 1.5;\n}\n\n.nodii-onboarding-consent-required {\n color: var(--_error);\n}\n`;\n\n/**\n * Inject the default widget CSS once into the document head.\n * Idempotent — will not add a duplicate style tag.\n */\nexport function injectWidgetStyles(): void {\n if (typeof document === \"undefined\") return;\n const styleId = \"__nodii_onboarding_styles__\";\n if (document.getElementById(styleId)) return;\n const style = document.createElement(\"style\");\n style.id = styleId;\n style.textContent = DEFAULT_WIDGET_CSS;\n document.head.appendChild(style);\n}\n","/// <reference lib=\"dom\" />\n/// <reference lib=\"dom.iterable\" />\n/**\n * Default vanilla-TS contact form widget.\n *\n * Renders a form into a host element and handles the full lifecycle:\n * 1. Render fields (name, email, phone, message)\n * 2. Client-side validation on submit\n * 3. reCAPTCHA token acquisition (D537)\n * 4. POST to /api/v1/public/onboarding/leads via submit client\n * 5. Retry on 5xx with SAME idempotency key\n * 6. Show success or error state\n *\n * No React or framework required. CSS via injectWidgetStyles().\n */\n\nimport {\n createContactFormState,\n type ContactFormControl,\n type FieldError,\n} from \"../form/state.js\";\nimport type { ContactFormValues } from \"../form/schema.js\";\nimport {\n submitLead,\n generateIdempotencyKey,\n computePayloadFingerprint,\n} from \"../submit/client.js\";\nimport {\n OnboardingBotChallengeError,\n OnboardingRateLimitError,\n} from \"../submit/errors.js\";\nimport { executeRecaptcha, loadRecaptcha } from \"../recaptcha/loader.js\";\nimport { idSelector } from \"./dom-utils.js\";\nimport { injectWidgetStyles } from \"./styles.js\";\n\nexport interface ContactFormMountOptions {\n /**\n * The onboarder identifier (slug or UUID).\n *\n * NOT transmitted on the wire — by design. Per LOCKED D536, onboarder\n * trust/scoping is derived server-side from the request Host at the edge\n * (\"onboarder derived from the bundle, never client-supplied\", D540 §1);\n * a client-supplied identifier is never trusted and therefore never sent.\n *\n * This option is reserved for Phase 2, where it becomes the client-side\n * cache key for the spec-fetch (`(onboarder, specVersion)` per D540 §3).\n * In Phase 1 it has no runtime effect.\n */\n onboarder: string;\n /**\n * Base URL for the intake service.\n * e.g. \"https://api.acme.nucleus-cloud.in\"\n */\n baseUrl: string;\n /**\n * reCAPTCHA v3 site key. Obtained from the spec endpoint (D540 §1)\n * or passed directly in Phase 1 before spec-fetch is wired.\n */\n siteKey?: string;\n /**\n * Which form to render. Phase 1 supports \"contact\" only.\n * Phase 2 will add \"signup\" (dynamic stepper from spec).\n */\n form: \"contact\";\n /** Called after a successful lead submission. */\n onSuccess?: () => void;\n /** Called on non-retryable errors (bot challenge, rate limit). */\n onError?: (error: unknown) => void;\n /** Custom fetch implementation (defaults to globalThis.fetch). */\n fetch?: typeof globalThis.fetch;\n /**\n * Per-request timeout in ms (default 15s), applied to BOTH the reCAPTCHA\n * execute() and the submit POST so a hung dependency re-enables the form.\n */\n timeoutMs?: number;\n /** Success message override. */\n successMessage?: string;\n /** Submit button label override. */\n submitLabel?: string;\n}\n\nexport interface MountedWidget {\n /** Unmount and clean up the widget from the host element. */\n unmount(): void;\n /** Reset the form to its initial state. */\n reset(): void;\n}\n\nfunction el<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n attrs: Record<string, string> = {},\n children: Array<HTMLElement | Text | string> = [],\n): HTMLElementTagNameMap[K] {\n const element = document.createElement(tag);\n for (const [key, value] of Object.entries(attrs)) {\n element.setAttribute(key, value);\n }\n for (const child of children) {\n if (typeof child === \"string\") {\n element.appendChild(document.createTextNode(child));\n } else {\n element.appendChild(child);\n }\n }\n return element;\n}\n\nfunction createFieldEl(\n id: string,\n label: string,\n input: HTMLInputElement | HTMLTextAreaElement,\n required: boolean,\n): HTMLElement {\n const labelEl = el(\n \"label\",\n { for: id, class: `nodii-onboarding-label${required ? \" required\" : \"\"}` },\n [label],\n );\n const errorEl = el(\"div\", {\n class: \"nodii-onboarding-field-error\",\n id: `${id}-error`,\n role: \"alert\",\n \"aria-live\": \"polite\",\n });\n const field = el(\"div\", { class: \"nodii-onboarding-field\" }, [\n labelEl,\n input,\n errorEl,\n ]);\n return field;\n}\n\nfunction setFieldError(\n container: HTMLElement,\n fieldId: string,\n message: string,\n): void {\n // CSS-escape the id: fieldId derives from spec field keys — never build a\n // selector from unescaped, spec-controlled input.\n const errorEl = container.querySelector(idSelector(`${fieldId}-error`));\n if (errorEl) errorEl.textContent = message;\n const inputEl = container.querySelector(idSelector(fieldId));\n if (inputEl) inputEl.classList.add(\"has-error\");\n}\n\nfunction clearFieldErrors(container: HTMLElement): void {\n for (const el of container.querySelectorAll(\n \".nodii-onboarding-field-error\",\n )) {\n el.textContent = \"\";\n }\n for (const el of container.querySelectorAll(\".has-error\")) {\n el.classList.remove(\"has-error\");\n }\n}\n\nfunction applyErrors(container: HTMLElement, errors: FieldError[]): void {\n clearFieldErrors(container);\n for (const err of errors) {\n // Zod paths are bare field names (\"name\", \"email\"); the DOM ids carry\n // the \"nodii-\" prefix (\"nodii-name\"). Map explicitly — a bare path\n // would querySelector nothing and silently drop the error display.\n setFieldError(container, `nodii-${err.path}`, err.message);\n }\n}\n\n/**\n * Mount the contact form widget into a host element.\n *\n * @example\n * ```ts\n * import { OnboardingWidget } from \"@nodii/onboarding/widget\";\n * const widget = OnboardingWidget.mount(document.getElementById(\"signup\"), {\n * onboarder: \"acme-corp\",\n * form: \"contact\",\n * baseUrl: \"https://api.acme.nucleus-cloud.in\",\n * siteKey: \"6Lc...\",\n * });\n * ```\n */\nexport function mountContactForm(\n host: HTMLElement,\n options: ContactFormMountOptions,\n): MountedWidget {\n injectWidgetStyles();\n\n const formControl: ContactFormControl = createContactFormState();\n\n // Pre-load reCAPTCHA script to minimize latency at submit time.\n // Non-fatal: the loader evicts its cache on failure, so a failed\n // pre-load genuinely retries from scratch at submit time.\n if (options.siteKey) {\n loadRecaptcha(options.siteKey).catch(() => {\n // Swallowed by design — executeRecaptcha at submit re-attempts.\n });\n }\n\n // --- Build DOM ---\n const wrapper = el(\"div\", { class: \"nodii-onboarding-widget\" });\n\n const nameInput = el(\"input\", {\n type: \"text\",\n id: \"nodii-name\",\n name: \"name\",\n class: \"nodii-onboarding-input\",\n placeholder: \"Your name\",\n autocomplete: \"name\",\n maxlength: \"200\",\n required: \"required\",\n }) as HTMLInputElement;\n\n const emailInput = el(\"input\", {\n type: \"email\",\n id: \"nodii-email\",\n name: \"email\",\n class: \"nodii-onboarding-input\",\n placeholder: \"you@company.com\",\n autocomplete: \"email\",\n required: \"required\",\n }) as HTMLInputElement;\n\n const phoneInput = el(\"input\", {\n type: \"tel\",\n id: \"nodii-phone\",\n name: \"phone\",\n class: \"nodii-onboarding-input\",\n placeholder: \"+1 555 000 0000\",\n autocomplete: \"tel\",\n }) as HTMLInputElement;\n\n const messageInput = el(\"textarea\", {\n id: \"nodii-message\",\n name: \"message\",\n class: \"nodii-onboarding-textarea\",\n placeholder: \"How can we help?\",\n maxlength: \"4000\",\n rows: \"4\",\n }) as HTMLTextAreaElement;\n\n const serverErrorEl = el(\"div\", {\n class: \"nodii-onboarding-server-error\",\n role: \"alert\",\n \"aria-live\": \"assertive\",\n style: \"display:none\",\n });\n\n const successEl = el(\n \"div\",\n {\n class: \"nodii-onboarding-success\",\n role: \"status\",\n style: \"display:none\",\n },\n [options.successMessage ?? \"Thank you! We'll be in touch shortly.\"],\n );\n\n const submitBtn = el(\n \"button\",\n {\n type: \"submit\",\n class: \"nodii-onboarding-submit-btn\",\n },\n [options.submitLabel ?? \"Get in touch\"],\n );\n\n const recaptchaNotice = el(\n \"p\",\n { class: \"nodii-onboarding-recaptcha-notice\" },\n [\n \"Protected by reCAPTCHA. \",\n Object.assign(\n el(\"a\", {\n href: \"https://policies.google.com/privacy\",\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n }),\n { textContent: \"Privacy\" },\n ),\n \" & \",\n Object.assign(\n el(\"a\", {\n href: \"https://policies.google.com/terms\",\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n }),\n { textContent: \"Terms\" },\n ),\n ],\n );\n\n const form = el(\"form\", {\n novalidate: \"true\",\n \"aria-label\": \"Contact us\",\n });\n\n form.appendChild(createFieldEl(\"nodii-name\", \"Name\", nameInput, true));\n form.appendChild(createFieldEl(\"nodii-email\", \"Email\", emailInput, true));\n form.appendChild(\n createFieldEl(\"nodii-phone\", \"Phone (optional)\", phoneInput, false),\n );\n form.appendChild(\n createFieldEl(\"nodii-message\", \"Message (optional)\", messageInput, false),\n );\n form.appendChild(serverErrorEl);\n form.appendChild(submitBtn);\n form.appendChild(recaptchaNotice);\n\n wrapper.appendChild(successEl);\n wrapper.appendChild(form);\n host.appendChild(wrapper);\n\n // --- Wire input events ---\n nameInput.addEventListener(\"input\", () => {\n formControl.setValue(\"name\", nameInput.value);\n });\n emailInput.addEventListener(\"input\", () => {\n formControl.setValue(\"email\", emailInput.value);\n });\n phoneInput.addEventListener(\"input\", () => {\n formControl.setValue(\"phone\", phoneInput.value || undefined);\n });\n messageInput.addEventListener(\"input\", () => {\n formControl.setValue(\"message\", messageInput.value || undefined);\n });\n\n const submitLabel = options.submitLabel ?? \"Get in touch\";\n\n // Render the submit button content via DOM nodes ONLY — never innerHTML.\n // options.submitLabel may be integrator/CMS-influenced text; text nodes\n // guarantee it can never be interpreted as markup.\n function renderSubmitButton(submitting: boolean): void {\n while (submitBtn.firstChild) {\n submitBtn.removeChild(submitBtn.firstChild);\n }\n if (submitting) {\n const spinner = document.createElement(\"span\");\n spinner.className = \"nodii-onboarding-spinner\";\n submitBtn.appendChild(spinner);\n submitBtn.appendChild(document.createTextNode(\"Sending…\"));\n } else {\n submitBtn.appendChild(document.createTextNode(submitLabel));\n }\n }\n\n // Subscribe to state changes\n const unsubscribe = formControl.subscribe((state) => {\n // Update submit button state\n submitBtn.disabled = state.status === \"submitting\";\n renderSubmitButton(state.status === \"submitting\");\n\n // Apply field errors\n applyErrors(wrapper, state.errors);\n\n // Server error\n if (state.serverError) {\n serverErrorEl.textContent = state.serverError;\n serverErrorEl.style.display = \"\";\n } else {\n serverErrorEl.style.display = \"none\";\n }\n\n // Success state\n if (state.status === \"success\") {\n successEl.style.display = \"\";\n form.style.display = \"none\";\n }\n });\n\n // --- Submit handler ---\n //\n // Idempotency-Key discipline (mirrors the server's D538 payload-match\n // guard — same key + different payload is INVALID_ARGUMENT server-side):\n // - The key is stable across RETRIES of the SAME payload (fingerprint\n // of the outgoing body minus botToken).\n // - If the user EDITS any field after a failed attempt, the fingerprint\n // changes → a NEW key is minted: an edited resubmission is a NEW\n // logical submission, not a retry.\n // - Cleared on success and on reset().\n let idempotencyKey: string | null = null;\n let lastFingerprint: string | null = null;\n\n form.addEventListener(\"submit\", async (event: Event) => {\n event.preventDefault();\n\n // Sync inputs to state\n formControl.setValue(\"name\", nameInput.value);\n formControl.setValue(\"email\", emailInput.value);\n formControl.setValue(\"phone\", phoneInput.value || undefined);\n formControl.setValue(\"message\", messageInput.value || undefined);\n\n const valid = formControl.validate();\n if (!valid) return;\n\n formControl.setSubmitting();\n\n const values = formControl.getState().values as ContactFormValues;\n\n // Key management per the discipline above.\n const fingerprint = computePayloadFingerprint(values);\n if (idempotencyKey === null || fingerprint !== lastFingerprint) {\n idempotencyKey = generateIdempotencyKey();\n lastFingerprint = fingerprint;\n }\n\n // Acquire the FIRST token up front so a mount-time reCAPTCHA failure\n // surfaces a clear message before any HTTP. On retries, submitLead mints\n // a FRESH token per attempt via this same provider (tokens are\n // single-use — reusing one after a 5xx would 403). Bounded by timeoutMs.\n let firstToken: string | undefined;\n if (options.siteKey) {\n try {\n firstToken = await executeRecaptcha(options.siteKey, \"contact_submit\", {\n timeoutMs: options.timeoutMs,\n });\n } catch (recaptchaErr) {\n formControl.setError(\n \"Could not load bot protection. Please try again.\",\n );\n options.onError?.(recaptchaErr);\n return;\n }\n }\n let usedFirst = false;\n const tokenProvider = async (): Promise<string> => {\n if (!usedFirst) {\n usedFirst = true;\n return firstToken!;\n }\n return executeRecaptcha(options.siteKey!, \"contact_submit\", {\n timeoutMs: options.timeoutMs,\n });\n };\n\n try {\n await submitLead(values, {\n baseUrl: options.baseUrl,\n ...(options.siteKey ? { botToken: tokenProvider } : {}),\n idempotencyKey,\n fetch: options.fetch,\n timeoutMs: options.timeoutMs,\n });\n // Clear for the next logical submission.\n idempotencyKey = null;\n lastFingerprint = null;\n formControl.setSuccess();\n options.onSuccess?.();\n } catch (err) {\n if (err instanceof OnboardingBotChallengeError) {\n formControl.setError(\n \"Bot protection check failed. Please refresh the page and try again.\",\n );\n options.onError?.(err);\n } else if (err instanceof OnboardingRateLimitError) {\n const msg =\n err.retryAfterSeconds !== null\n ? `Too many requests. Please wait ${err.retryAfterSeconds}s.`\n : \"Too many requests. Please wait a moment.\";\n formControl.setError(msg);\n options.onError?.(err);\n } else {\n formControl.setError(\n \"Something went wrong. Please try again in a moment.\",\n );\n options.onError?.(err);\n }\n }\n });\n\n return {\n unmount() {\n unsubscribe();\n host.removeChild(wrapper);\n },\n reset() {\n idempotencyKey = null;\n lastFingerprint = null;\n formControl.reset();\n form.style.display = \"\";\n successEl.style.display = \"none\";\n nameInput.value = \"\";\n emailInput.value = \"\";\n phoneInput.value = \"\";\n messageInput.value = \"\";\n },\n };\n}\n","/**\n * Default ConsentPack step components (D543 §5) — built ON the headless\n * ConsentController (dogfooding it). This is the batteries-included layer for\n * Nodii's own turnkey signup + tenants who want a default UI. Advanced tenants\n * skip this entirely and bind their OWN rendering to the headless controller\n * (see @nodii/onboarding/consent) — the TanStack model.\n *\n * NO IFRAME. A cross-origin iframe cannot report scroll position, so it can't\n * drive `scroll_then_accept`. The default document VIEWER\n * (@nodii/onboarding/viewer, lazy-imported) renders content INLINE, SAME-ORIGIN\n * (HTML→DOMPurify, markdown→marked, PDF→PDF.js) in a scroll `<div>` whose real\n * scroll events feed reportScrollProgress — so scroll-to-end is genuinely\n * detected. The scroll box reports progress ONLY after real content is present.\n *\n * Gate affordance per acceptance level:\n * - checkbox → a lightweight preview link (no gate; accept enabled).\n * - scroll_then_accept → the viewer renders the doc inline; scroll-to-end\n * drives the gate.\n * - open_then_accept → an open-in-a-new-tab control; a REAL open marks\n * `opened` (the open IS the gate).\n *\n * COMPLIANCE (P0 — never fabricate consent): if the viewer MODULE fails to load\n * (CDN chunk 404 / offline) for a scroll_then_accept doc, the gate stays\n * UNSATISFIABLE — a clear error + Retry is shown and accept remains DISABLED.\n * We NEVER satisfy a scroll gate on a click; an \"open in a new tab\" link on the\n * error is INFORMATIONAL only and does not unlock the gate. (The viewer's own\n * fetch/render failures follow the same rule; see @nodii/onboarding/viewer.)\n *\n * Theming rides the existing --nodii-onboarding-* CSS custom properties; all\n * classes are scoped under `.nodii-onboarding-widget`. Full-width, generous\n * spacing (operator directive) via styles.ts.\n *\n * a11y: every accept checkbox has a `<label for>` pointing at its real id; the\n * id token derives from the doc's stable key (docType | custom:<key>),\n * sanitized to an id-safe token and CSS-escaped in every selector.\n */\n\nimport type {\n ConsentController,\n ConsentDocState,\n ConsentState,\n} from \"../consent/controller.js\";\nimport { SCROLL_END_THRESHOLD } from \"../consent/controller.js\";\nimport { cssEscape, idSelector } from \"./dom-utils.js\";\n\n/** Prefix for every consent DOM id (kept distinct from field/account ids). */\nconst CONSENT_ID_PREFIX = \"nodii-consent-doc-\";\n\n/** Render-time options for the default consent step. */\nexport interface ConsentStepRenderOptions {\n /** Injectable fetch for doc-content load (defaults to global). */\n fetch?: typeof globalThis.fetch;\n timeoutMs?: number;\n /**\n * Injectable viewer-module importer (defaults to the real dynamic\n * `import(\"../viewer/render.js\")`). Exposed so a consumer can control code-\n * splitting AND so tests can drive the module-load-FAILURE branch WITHOUT\n * `mock.module` (which leaks across bun tests). Must resolve to an object\n * exposing `renderConsentDocument`; rejecting simulates a chunk-load failure.\n */\n importViewer?: () => Promise<typeof import(\"../viewer/render.js\")>;\n}\n\nfunction el<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n attrs: Record<string, string> = {},\n children: Array<HTMLElement | Text | string> = [],\n): HTMLElementTagNameMap[K] {\n const element = document.createElement(tag);\n for (const [key, value] of Object.entries(attrs)) {\n element.setAttribute(key, value);\n }\n for (const child of children) {\n if (typeof child === \"string\") {\n element.appendChild(document.createTextNode(child));\n } else {\n element.appendChild(child);\n }\n }\n return element;\n}\n\n/**\n * Turn a consent doc's stable key into a DOM-id-safe token. `doc_type` is a\n * fixed enum (safe); a custom key arrives as `custom:<key>` — the `:` and any\n * residual metachar are replaced so the raw token is valid inside an id AND\n * inside a `#id` selector. (The key is already `[A-Za-z0-9_-]+` past the `:`\n * per model.ts; this only neutralizes the `custom:` prefix separator.)\n */\nexport function consentDocElementId(key: string): string {\n return `${CONSENT_ID_PREFIX}${key.replace(/[^A-Za-z0-9_-]/g, \"-\")}`;\n}\n\n/** Build the accept-checkbox row for one document. */\nfunction buildAcceptRow(\n control: ConsentController,\n doc: ConsentDocState,\n): { row: HTMLElement; errorEl: HTMLElement } {\n const id = consentDocElementId(doc.key);\n const checkbox = el(\"input\", {\n type: \"checkbox\",\n id,\n class: \"nodii-onboarding-consent-accept\",\n }) as HTMLInputElement;\n checkbox.checked = doc.accepted;\n checkbox.disabled = !doc.gateSatisfied;\n checkbox.addEventListener(\"change\", () => {\n // The controller REFUSES acceptance when the gate is unsatisfied; reflect\n // the authoritative post-mutation state back into the DOM so a disabled-\n // bypass (e.g. programmatic .checked) cannot desync the UI from consent.\n control.setAccepted(doc.key, checkbox.checked);\n checkbox.checked =\n control.getState().documents.find((d) => d.key === doc.key)?.accepted ??\n false;\n });\n\n const labelText =\n doc.acceptanceLevel === \"checkbox\"\n ? `I accept the ${doc.doc.title}`\n : `I have reviewed and accept the ${doc.doc.title}`;\n const label = el(\n \"label\",\n { for: id, class: \"nodii-onboarding-consent-accept-label\" },\n [labelText],\n );\n if (doc.required) {\n label.appendChild(\n el(\"span\", { class: \"nodii-onboarding-consent-required\" }, [\" *\"]),\n );\n }\n\n const row = el(\"div\", { class: \"nodii-onboarding-consent-accept-row\" }, [\n checkbox,\n label,\n ]);\n const errorEl = el(\"div\", {\n class: \"nodii-onboarding-field-error nodii-onboarding-consent-error\",\n id: `${id}-error`,\n role: \"alert\",\n \"aria-live\": \"polite\",\n });\n return { row, errorEl };\n}\n\n/**\n * An open-in-tab affordance for an `open_then_accept` doc — opening the doc in\n * a new tab IS the gate for this level, so marking `opened` on a REAL open is\n * legitimate. A native <a target=\"_blank\"> navigates on click and on Enter\n * (keyboard activation). We do NOT bind Space — Space does not activate an\n * anchor (no navigation → no real open → marking opened would fabricate).\n */\nfunction buildOpenAffordance(\n control: ConsentController,\n doc: ConsentDocState,\n): HTMLElement {\n const id = consentDocElementId(doc.key);\n const openLink = el(\n \"a\",\n {\n class: \"nodii-onboarding-consent-open\",\n id: `${id}-open`,\n href: doc.doc.downloadUrl,\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n [`Open ${doc.doc.title}`],\n );\n const markOpened = (): void => control.markOpened(doc.key);\n openLink.addEventListener(\"click\", markOpened);\n openLink.addEventListener(\"keydown\", (event) => {\n if ((event as KeyboardEvent).key === \"Enter\") markOpened();\n });\n return el(\"div\", { class: \"nodii-onboarding-consent-open-row\" }, [openLink]);\n}\n\n/**\n * Build the gate affordance for one document.\n *\n * - open_then_accept → an open-in-tab control (marks opened).\n * - checkbox → a lightweight preview link (no gate).\n * - scroll_then_accept → an inline document container populated by the DEFAULT\n * VIEWER (@nodii/onboarding/viewer), loaded via a DYNAMIC import() so the\n * base widget bundle never statically pulls DOMPurify / marked / pdfjs. The\n * viewer renders the doc inline same-origin (HTML→DOMPurify, md→marked, PDF→\n * PDF.js) and wires the scroll container's scroll-to-end to the controller\n * so the gate is real. COMPLIANCE (P0): if the viewer MODULE fails to load,\n * the scroll gate stays UNSATISFIABLE — a clear error + Retry is shown and\n * accept stays DISABLED; we NEVER unlock a scroll gate on a click. (The\n * viewer's own fetch/render failures follow the same rule.)\n */\nfunction buildGateAffordance(\n control: ConsentController,\n doc: ConsentDocState,\n opts: ConsentStepRenderOptions,\n): HTMLElement {\n const id = consentDocElementId(doc.key);\n\n if (doc.acceptanceLevel === \"open_then_accept\") {\n return buildOpenAffordance(control, doc);\n }\n\n if (doc.acceptanceLevel === \"checkbox\") {\n return el(\"div\", { class: \"nodii-onboarding-consent-preview-row\" }, [\n el(\n \"a\",\n {\n class: \"nodii-onboarding-consent-preview\",\n id: `${id}-preview`,\n href: doc.doc.downloadUrl,\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n [`View ${doc.doc.title}`],\n ),\n ]);\n }\n\n // scroll_then_accept: delegate to the default viewer (dynamically imported).\n const container = el(\"div\", {\n class: \"nodii-onboarding-consent-gate\",\n id: `${id}-gate`,\n });\n container.appendChild(\n el(\"div\", { class: \"nodii-onboarding-consent-doc-loading\" }, [\n \"Loading document…\",\n ]),\n );\n\n const importViewer =\n opts.importViewer ?? (() => import(\"../viewer/render.js\"));\n const loadViewer = (): void => {\n void (async () => {\n try {\n const { renderConsentDocument } = await importViewer();\n await renderConsentDocument(container, doc.doc, control, {\n consentKey: doc.key,\n fetch: opts.fetch,\n timeoutMs: opts.timeoutMs,\n });\n } catch {\n // COMPLIANCE-CRITICAL (P0): the viewer MODULE itself failed to load\n // (CDN chunk 404, offline). A scroll_then_accept doc cannot be\n // scrolled → its gate stays UNSATISFIABLE. We MUST NOT satisfy the\n // scroll gate on a click — that would fabricate scrolled_to_end.\n // Render a clear error + Retry (re-attempts the import); accept stays\n // disabled. An informational open link does NOT satisfy the gate.\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n const wrap = el(\"div\", {\n class: \"nodii-onboarding-consent-unrenderable\",\n role: \"alert\",\n });\n wrap.appendChild(\n el(\n \"p\",\n {\n // DISTINCT id (NOT `${id}-error`): buildAcceptRow already owns\n // `${id}-error`, and updateConsentStep's querySelector would match\n // THIS paragraph first and blank it on the next state change,\n // silently wiping the compliance message. A unique id keeps this\n // load-failure error persistent (P1b).\n class:\n \"nodii-onboarding-field-error nodii-onboarding-consent-error\",\n id: `${id}-load-error`,\n },\n [\n `“${doc.doc.title}” could not be loaded, so it cannot be accepted yet. Please retry.`,\n ],\n ),\n );\n const retry = el(\n \"button\",\n { type: \"button\", class: \"nodii-onboarding-consent-retry\" },\n [\"Retry loading document\"],\n );\n retry.addEventListener(\"click\", loadViewer);\n wrap.appendChild(retry);\n // Informational only — opening in a new tab does NOT satisfy scroll.\n wrap.appendChild(\n el(\n \"a\",\n {\n class: \"nodii-onboarding-consent-open\",\n href: doc.doc.downloadUrl,\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n [`Open ${doc.doc.title} in a new tab`],\n ),\n );\n container.appendChild(wrap);\n }\n })();\n };\n loadViewer();\n\n return container;\n}\n\n/** Build one full-width consent card for a document. */\nfunction buildConsentCard(\n control: ConsentController,\n doc: ConsentDocState,\n stale: boolean,\n opts: ConsentStepRenderOptions,\n): HTMLElement {\n const card = el(\"div\", {\n class: `nodii-onboarding-consent-card${stale ? \" is-stale\" : \"\"}`,\n \"data-consent-key\": doc.key,\n });\n card.appendChild(\n el(\"h4\", { class: \"nodii-onboarding-consent-title\" }, [doc.doc.title]),\n );\n if (stale) {\n card.appendChild(\n el(\n \"div\",\n { class: \"nodii-onboarding-consent-stale-tag\", role: \"status\" },\n [\"Updated — please review and re-accept.\"],\n ),\n );\n }\n card.appendChild(buildGateAffordance(control, doc, opts));\n const { row, errorEl } = buildAcceptRow(control, doc);\n card.appendChild(row);\n card.appendChild(errorEl);\n return card;\n}\n\n/**\n * Render (or re-render) the consent stage into a host container from the given\n * consent state. Full re-render (the doc set is small); disabled/checked/error\n * state is refreshed in place via updateConsentStep so scroll position and\n * inline doc content are not lost on unrelated state changes.\n */\nexport function renderConsentStep(\n host: HTMLElement,\n control: ConsentController,\n state: ConsentState,\n staleKeys: string[] = [],\n opts: ConsentStepRenderOptions = {},\n): void {\n while (host.firstChild) host.removeChild(host.firstChild);\n const staleSet = new Set(staleKeys);\n\n host.appendChild(\n el(\"h3\", { class: \"nodii-onboarding-stage-title\" }, [\n \"Review & accept documents\",\n ]),\n );\n host.appendChild(\n el(\"p\", { class: \"nodii-onboarding-consent-intro\" }, [\n \"Please review each document below and accept to continue.\",\n ]),\n );\n\n for (const doc of state.documents) {\n host.appendChild(\n buildConsentCard(control, doc, staleSet.has(doc.key), opts),\n );\n }\n}\n\n/**\n * Refresh the consent cards' disabled/checked/error state in place (no full\n * re-render) — called on every stepper state change so gate unlocks and\n * live-clearing errors reflect immediately without losing scroll position or\n * re-fetching inline doc content.\n */\nexport function updateConsentStep(\n host: HTMLElement,\n state: ConsentState,\n consentErrors: Array<{ path: string; message: string }>,\n): void {\n const errorByKey = new Map(consentErrors.map((e) => [e.path, e.message]));\n for (const doc of state.documents) {\n const id = consentDocElementId(doc.key);\n const checkbox = host.querySelector(\n idSelector(id),\n ) as HTMLInputElement | null;\n if (checkbox) {\n checkbox.disabled = !doc.gateSatisfied;\n checkbox.checked = doc.accepted;\n }\n const errorNode = host.querySelector(idSelector(`${id}-error`));\n if (errorNode) errorNode.textContent = errorByKey.get(doc.key) ?? \"\";\n const card = host.querySelector(\n `[data-consent-key=\"${cssEscape(doc.key)}\"]`,\n );\n if (card) {\n if (errorByKey.has(doc.key)) card.classList.add(\"has-error\");\n else card.classList.remove(\"has-error\");\n }\n }\n}\n\n/** Re-export for consumers wiring their own scroll handler to the controller. */\nexport { SCROLL_END_THRESHOLD };\n","/// <reference lib=\"dom\" />\n/// <reference lib=\"dom.iterable\" />\n/**\n * Default vanilla-TS dynamic signup stepper widget (D540 Phase 2).\n *\n * Mount flow:\n * 1. Fetch + validate the spec (GET /api/v1/public/onboarding/spec);\n * the reCAPTCHA siteKey comes FROM THE SPEC (botChallenge.siteKey) —\n * the mount-option siteKey is only an override/fallback.\n * 2. Build the headless stepper from spec.forms.signup.steps.\n * 3. Render the current step's fields per descriptor type; Back/Next\n * navigate with per-step validation.\n * 4. The FINAL step carries the account section (credentials + consent\n * clickwrap) and the submit button.\n * 5. Submit: validateAll → payload-fingerprint key management (same\n * D538 discipline as the contact widget) → reCAPTCHA token →\n * submitSignup.\n * 6. 409 spec_stale: refetch the spec, applyNewSpec (drops removed\n * fields, re-validates), show a \"form updated — please review\"\n * banner. The SDK NEVER auto-resubmits a stale submission.\n */\n\nimport {\n fetchOnboardingSpec,\n OnboardingSpecCache,\n defaultSpecCache,\n diffSpecFields,\n type OnboardingSpec,\n} from \"../spec/index.js\";\nimport type { SpecField } from \"../spec/model.js\";\nimport {\n createSignupStepper,\n type SignupStepperControl,\n type SignupStepperState,\n} from \"../dynamic/stepper.js\";\nimport { optionValue } from \"../dynamic/derive.js\";\nimport {\n submitSignup,\n computeSignupFingerprint,\n type SignupSubmitResult,\n} from \"../submit/signup-client.js\";\nimport { generateIdempotencyKey } from \"../submit/client.js\";\nimport {\n OnboardingBotChallengeError,\n OnboardingConsentIncompleteError,\n OnboardingConsentStaleError,\n OnboardingRateLimitError,\n OnboardingSpecStaleError,\n} from \"../submit/errors.js\";\nimport { executeRecaptcha } from \"../recaptcha/loader.js\";\nimport { idSelector } from \"./dom-utils.js\";\nimport { injectWidgetStyles } from \"./styles.js\";\nimport { renderConsentStep, updateConsentStep } from \"./consent-step.js\";\nimport type { MountedWidget } from \"./contact-form.js\";\n\nexport interface SignupFormMountOptions {\n /**\n * The onboarder identifier — the CLIENT-side spec-cache key\n * (D540 §3 `(onboarder, specVersion)`). NOT transmitted: per LOCKED\n * D536, onboarder trust/scoping is host-derived at the edge.\n */\n onboarder: string;\n baseUrl: string;\n /**\n * OPTIONAL siteKey override. Normally the widget uses the siteKey the\n * spec serves (botChallenge.siteKey, D537/D540); pass this only for\n * environments where the spec cannot carry it yet.\n */\n siteKey?: string;\n form: \"signup\";\n onSuccess?: (result: SignupSubmitResult) => void;\n onError?: (error: unknown) => void;\n /** Called after the spec loads and the stepper renders. */\n onReady?: (spec: OnboardingSpec) => void;\n fetch?: typeof globalThis.fetch;\n /**\n * Per-request timeout in ms (default 15s), applied to the boot spec fetch,\n * the reCAPTCHA execute(), the submit POST, and the 409 refetch — so a hung\n * dependency never leaves \"Loading signup form…\"/\"Sending…\" stuck.\n */\n timeoutMs?: number;\n submitLabel?: string;\n tosUrl?: string;\n privacyUrl?: string;\n /** Spec cache override (defaults to the module-level cache). */\n cache?: OnboardingSpecCache;\n}\n\nconst STAGE_TITLES: Record<string, string> = {\n lead: \"About you\",\n prospect: \"Your business\",\n activation: \"Choose your services\",\n};\n\nfunction el<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n attrs: Record<string, string> = {},\n children: Array<HTMLElement | Text | string> = [],\n): HTMLElementTagNameMap[K] {\n const element = document.createElement(tag);\n for (const [key, value] of Object.entries(attrs)) {\n element.setAttribute(key, value);\n }\n for (const child of children) {\n if (typeof child === \"string\") {\n element.appendChild(document.createTextNode(child));\n } else {\n element.appendChild(child);\n }\n }\n return element;\n}\n\nfunction optionLabel(option: unknown): string {\n if (option !== null && typeof option === \"object\") {\n const o = option as Record<string, unknown>;\n if (typeof o[\"label\"] === \"string\") return o[\"label\"];\n }\n return optionValue(option);\n}\n\n/** Build the input element for one spec field descriptor. */\nfunction buildFieldInput(\n field: SpecField,\n currentValue: unknown,\n onChange: (value: unknown) => void,\n): HTMLElement {\n const id = `nodii-f-${field.key}`;\n\n switch (field.type) {\n case \"textarea\": {\n const input = el(\"textarea\", {\n id,\n class: \"nodii-onboarding-textarea\",\n rows: \"4\",\n }) as HTMLTextAreaElement;\n if (typeof currentValue === \"string\") input.value = currentValue;\n input.addEventListener(\"input\", () => onChange(input.value));\n return input;\n }\n case \"checkbox\":\n case \"boolean\": {\n const input = el(\"input\", {\n type: \"checkbox\",\n id,\n }) as HTMLInputElement;\n input.checked = currentValue === true;\n input.addEventListener(\"change\", () => onChange(input.checked));\n return input;\n }\n case \"select\":\n case \"radio\": {\n const select = el(\"select\", {\n id,\n class: \"nodii-onboarding-input\",\n }) as HTMLSelectElement;\n select.appendChild(el(\"option\", { value: \"\" }, [\"— select —\"]));\n for (const opt of field.options ?? []) {\n const value = optionValue(opt);\n const optionEl = el(\"option\", { value }, [optionLabel(opt)]);\n select.appendChild(optionEl);\n }\n if (typeof currentValue === \"string\") select.value = currentValue;\n select.addEventListener(\"change\", () => onChange(select.value));\n return select;\n }\n case \"multiselect\": {\n const select = el(\"select\", {\n id,\n class: \"nodii-onboarding-input\",\n multiple: \"multiple\",\n }) as HTMLSelectElement;\n const current = Array.isArray(currentValue)\n ? currentValue.map(String)\n : [];\n for (const opt of field.options ?? []) {\n const value = optionValue(opt);\n const optionEl = el(\"option\", { value }, [\n optionLabel(opt),\n ]) as HTMLOptionElement;\n if (current.includes(value)) optionEl.selected = true;\n select.appendChild(optionEl);\n }\n select.addEventListener(\"change\", () => {\n const values: string[] = [];\n for (const o of Array.from(select.options)) {\n if (o.selected && o.value !== \"\") values.push(o.value);\n }\n onChange(values);\n });\n return select;\n }\n default: {\n // text | email | tel | number | date | unknown → typed <input>\n const typeAttr =\n field.type === \"email\" ||\n field.type === \"tel\" ||\n field.type === \"number\" ||\n field.type === \"date\"\n ? field.type\n : \"text\";\n const input = el(\"input\", {\n type: typeAttr,\n id,\n class: \"nodii-onboarding-input\",\n }) as HTMLInputElement;\n if (typeof currentValue === \"string\") input.value = currentValue;\n if (typeof currentValue === \"number\") input.value = String(currentValue);\n input.addEventListener(\"input\", () => onChange(input.value));\n return input;\n }\n }\n}\n\n/**\n * Build a labelled field row. The label `for`, the input id, and the error\n * element id must ALL agree so click-to-focus and screen-reader association\n * work. Callers whose input id is NOT `nodii-f-<key>` (the account section,\n * whose inputs are `nodii-account-*`) pass `idOverride` so the label points\n * at the REAL input — never a dangling id patched up post-hoc.\n */\nfunction fieldRow(\n field: SpecField,\n input: HTMLElement,\n idOverride?: string,\n): HTMLElement {\n const id = idOverride ?? `nodii-f-${field.key}`;\n const labelEl = el(\n \"label\",\n {\n for: id,\n class: `nodii-onboarding-label${field.required ? \" required\" : \"\"}`,\n },\n [field.label],\n );\n const errorEl = el(\"div\", {\n class: \"nodii-onboarding-field-error\",\n id: `${id}-error`,\n role: \"alert\",\n \"aria-live\": \"polite\",\n });\n return el(\"div\", { class: \"nodii-onboarding-field\" }, [\n labelEl,\n input,\n errorEl,\n ]);\n}\n\n/**\n * Mount the dynamic signup stepper into a host element.\n * Returns synchronously; the spec loads in the background (loading state\n * rendered meanwhile; onReady fires when interactive).\n */\nexport function mountSignupForm(\n host: HTMLElement,\n options: SignupFormMountOptions,\n): MountedWidget {\n injectWidgetStyles();\n\n const wrapper = el(\"div\", { class: \"nodii-onboarding-widget\" });\n const loadingEl = el(\"div\", { class: \"nodii-onboarding-loading\" }, [\n \"Loading signup form…\",\n ]);\n wrapper.appendChild(loadingEl);\n host.appendChild(wrapper);\n\n const cache = options.cache ?? defaultSpecCache;\n let stepper: SignupStepperControl | null = null;\n let unsubscribe: (() => void) | null = null;\n let unmounted = false;\n let siteKey = options.siteKey ?? \"\";\n let idempotencyKey: string | null = null;\n let lastFingerprint: string | null = null;\n let renderedStepIndex = -1;\n let renderedStale = false;\n // Tracks the last-rendered consentStale flag so a consent_stale swap forces\n // a full step re-render (like specStale) — the cards must re-render with the\n // \"Updated — please review\" tags and cleared acceptance.\n let renderedConsentStale = false;\n // The (onboarder, specVersion) currently driving the form — used to READ\n // the prior cached version back out on a 409 and diff what changed.\n let currentSpecVersion: string | null = null;\n let staleDiffSummary = \"\";\n\n // DOM regions (populated by renderShell)\n const stepArea = el(\"div\", {});\n const staleBanner = el(\"div\", {\n class: \"nodii-onboarding-stale-banner\",\n role: \"alert\",\n style: \"display:none\",\n });\n const serverErrorEl = el(\"div\", {\n class: \"nodii-onboarding-server-error\",\n role: \"alert\",\n \"aria-live\": \"assertive\",\n style: \"display:none\",\n });\n const successEl = el(\"div\", {\n class: \"nodii-onboarding-success\",\n role: \"status\",\n style: \"display:none\",\n });\n const stepsIndicator = el(\"div\", { class: \"nodii-onboarding-steps\" });\n const form = el(\"form\", { novalidate: \"true\", \"aria-label\": \"Sign up\" });\n\n function setFieldErrorsInPlace(\n container: HTMLElement,\n errors: Array<{ path: string; message: string }>,\n idPrefix: (path: string) => string,\n ): void {\n for (const errEl of container.querySelectorAll(\n \".nodii-onboarding-field-error\",\n )) {\n errEl.textContent = \"\";\n }\n for (const marked of container.querySelectorAll(\".has-error\")) {\n marked.classList.remove(\"has-error\");\n }\n for (const err of errors) {\n const id = idPrefix(err.path);\n // CSS-escape: id derives from spec field keys (err.path).\n const errorNode = container.querySelector(idSelector(`${id}-error`));\n if (errorNode) errorNode.textContent = err.message;\n const inputNode = container.querySelector(idSelector(id));\n if (inputNode) inputNode.classList.add(\"has-error\");\n }\n }\n\n function accountIdOf(path: string): string {\n if (path === \"email\") return \"nodii-account-email\";\n if (path === \"displayName\") return \"nodii-account-display-name\";\n if (path === \"tosAccepted\") return \"nodii-consent-tos\";\n if (path === \"privacyAccepted\") return \"nodii-consent-privacy\";\n return `nodii-account-${path}`;\n }\n\n function renderStepsIndicator(state: SignupStepperState): void {\n while (stepsIndicator.firstChild) {\n stepsIndicator.removeChild(stepsIndicator.firstChild);\n }\n for (let i = 0; i < state.stepCount; i++) {\n stepsIndicator.appendChild(\n el(\"div\", {\n class: `nodii-onboarding-step-dot${i <= state.stepIndex ? \" active\" : \"\"}`,\n }),\n );\n }\n }\n\n function renderAccountSection(\n control: SignupStepperControl,\n state: SignupStepperState,\n ): HTMLElement {\n const section = el(\"div\", { class: \"nodii-onboarding-account-section\" });\n\n const emailInput = el(\"input\", {\n type: \"email\",\n id: \"nodii-account-email\",\n class: \"nodii-onboarding-input\",\n autocomplete: \"email\",\n }) as HTMLInputElement;\n emailInput.value = state.credentials.email;\n emailInput.addEventListener(\"input\", () =>\n control.setCredentials({ email: emailInput.value }),\n );\n section.appendChild(\n fieldRow(\n {\n key: \"account-email\",\n type: \"email\",\n label: \"Account email\",\n required: true,\n },\n emailInput,\n \"nodii-account-email\", // label for + error id match the real input id\n ),\n );\n\n const displayNameInput = el(\"input\", {\n type: \"text\",\n id: \"nodii-account-display-name\",\n class: \"nodii-onboarding-input\",\n autocomplete: \"name\",\n maxlength: \"200\",\n }) as HTMLInputElement;\n displayNameInput.value = state.credentials.displayName;\n displayNameInput.addEventListener(\"input\", () =>\n control.setCredentials({ displayName: displayNameInput.value }),\n );\n section.appendChild(\n fieldRow(\n {\n key: \"account-display-name\",\n type: \"text\",\n label: \"Your name\",\n required: true,\n },\n displayNameInput,\n \"nodii-account-display-name\",\n ),\n );\n\n for (const [key, label, autocomplete] of [\n [\"organisationName\", \"Organisation name\", \"organization\"],\n [\"subdomain\", \"Workspace subdomain\", \"off\"],\n ] as const) {\n const input = el(\"input\", {\n type: \"text\",\n id: `nodii-account-${key}`,\n class: \"nodii-onboarding-input\",\n autocomplete,\n maxlength: key === \"subdomain\" ? \"63\" : \"200\",\n }) as HTMLInputElement;\n input.value = state.credentials[key];\n input.addEventListener(\"input\", () =>\n control.setCredentials({ [key]: input.value }),\n );\n section.appendChild(\n fieldRow(\n { key: `account-${key}`, type: \"text\", label, required: true },\n input,\n `nodii-account-${key}`,\n ),\n );\n }\n\n const tosCheckbox = el(\"input\", {\n type: \"checkbox\",\n id: \"nodii-consent-tos\",\n }) as HTMLInputElement;\n tosCheckbox.checked = state.consent.tosAccepted;\n tosCheckbox.addEventListener(\"change\", () =>\n control.setConsent({ tosAccepted: tosCheckbox.checked }),\n );\n const tosLabelChildren: Array<HTMLElement | string> = [\"I accept the \"];\n if (options.tosUrl) {\n tosLabelChildren.push(\n el(\n \"a\",\n {\n href: options.tosUrl,\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n [\"Terms of Service\"],\n ),\n );\n } else {\n tosLabelChildren.push(\"Terms of Service\");\n }\n section.appendChild(\n el(\"div\", { class: \"nodii-onboarding-consent-row\" }, [\n tosCheckbox,\n el(\"label\", { for: \"nodii-consent-tos\" }, tosLabelChildren),\n ]),\n );\n section.appendChild(\n el(\"div\", {\n class: \"nodii-onboarding-field-error\",\n id: \"nodii-consent-tos-error\",\n role: \"alert\",\n }),\n );\n\n const privacyCheckbox = el(\"input\", {\n type: \"checkbox\",\n id: \"nodii-consent-privacy\",\n }) as HTMLInputElement;\n privacyCheckbox.checked = state.consent.privacyAccepted;\n privacyCheckbox.addEventListener(\"change\", () =>\n control.setConsent({ privacyAccepted: privacyCheckbox.checked }),\n );\n const privacyLabelChildren: Array<HTMLElement | string> = [\"I accept the \"];\n if (options.privacyUrl) {\n privacyLabelChildren.push(\n el(\n \"a\",\n {\n href: options.privacyUrl,\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n [\"Privacy Policy\"],\n ),\n );\n } else {\n privacyLabelChildren.push(\"Privacy Policy\");\n }\n section.appendChild(\n el(\"div\", { class: \"nodii-onboarding-consent-row\" }, [\n privacyCheckbox,\n el(\"label\", { for: \"nodii-consent-privacy\" }, privacyLabelChildren),\n ]),\n );\n section.appendChild(\n el(\"div\", {\n class: \"nodii-onboarding-field-error\",\n id: \"nodii-consent-privacy-error\",\n role: \"alert\",\n }),\n );\n\n return section;\n }\n\n function renderStep(\n control: SignupStepperControl,\n state: SignupStepperState,\n ): void {\n while (stepArea.firstChild) stepArea.removeChild(stepArea.firstChild);\n\n const step = state.currentStep;\n if (step) {\n stepArea.appendChild(\n el(\"h3\", { class: \"nodii-onboarding-stage-title\" }, [\n STAGE_TITLES[step.stage] ?? step.stage,\n ]),\n );\n for (const field of step.fields) {\n const input = buildFieldInput(\n field,\n state.answers[field.key],\n (value) => control.setAnswer(field.key, value),\n );\n stepArea.appendChild(fieldRow(field, input));\n }\n }\n\n const isLast = control.isLastStep();\n if (isLast) {\n // D543 consent stage — full-width consent cards ABOVE the account\n // section on the final step. Rendered only when the spec served a\n // consentPack (control.consent.isEmpty() ⇒ skipped entirely).\n if (!control.consent.isEmpty()) {\n const consentStage = el(\"div\", {\n class: \"nodii-onboarding-consent-stage\",\n });\n renderConsentStep(\n consentStage,\n control.consent,\n state.consentState,\n state.staleConsentKeys,\n { fetch: options.fetch, timeoutMs: options.timeoutMs },\n );\n stepArea.appendChild(consentStage);\n }\n stepArea.appendChild(renderAccountSection(control, state));\n }\n\n const nav = el(\"div\", { class: \"nodii-onboarding-nav\" });\n if (!control.isFirstStep()) {\n const backBtn = el(\n \"button\",\n { type: \"button\", class: \"nodii-onboarding-back-btn\" },\n [\"Back\"],\n );\n backBtn.addEventListener(\"click\", () => control.back());\n nav.appendChild(backBtn);\n }\n const forwardBtn = el(\n \"button\",\n {\n type: isLast ? \"submit\" : \"button\",\n class: \"nodii-onboarding-submit-btn\",\n id: \"nodii-signup-forward\",\n },\n [isLast ? (options.submitLabel ?? \"Create account\") : \"Next\"],\n );\n if (!isLast) {\n forwardBtn.addEventListener(\"click\", () => control.next());\n }\n nav.appendChild(forwardBtn);\n stepArea.appendChild(nav);\n }\n\n async function handleSpecStale(control: SignupStepperControl): Promise<void> {\n // READ the previously-served version back out of the cache (populated on\n // boot under (onboarder, specVersion)) so we can diff it against the\n // refetched spec and tell the user exactly what changed.\n const prior =\n currentSpecVersion !== null\n ? cache.get(options.onboarder, currentSpecVersion)\n : undefined;\n\n const fresh = await fetchOnboardingSpec({\n baseUrl: options.baseUrl,\n onboarder: options.onboarder,\n fetch: options.fetch,\n timeoutMs: options.timeoutMs,\n cache,\n });\n if (unmounted) return;\n\n if (prior) {\n const diff = diffSpecFields(prior, fresh);\n const parts: string[] = [];\n if (diff.added.length) parts.push(`added: ${diff.added.join(\", \")}`);\n if (diff.removed.length)\n parts.push(`removed: ${diff.removed.join(\", \")}`);\n if (diff.changed.length)\n parts.push(`changed: ${diff.changed.join(\", \")}`);\n staleDiffSummary = parts.length ? ` (${parts.join(\"; \")})` : \"\";\n } else {\n staleDiffSummary = \"\";\n }\n\n siteKey = options.siteKey ?? fresh.botChallenge?.siteKey ?? \"\";\n currentSpecVersion = fresh.specVersion;\n control.applyNewSpec(fresh);\n // A stale submission's payload is dead; the next submit is a NEW\n // logical submission against the new specVersion.\n idempotencyKey = null;\n lastFingerprint = null;\n }\n\n /**\n * 409 consent_stale (D543 §4): a required legal doc changed. Refetch the\n * spec and swap ONLY the consentPack — changed docs are reset (re-acceptance\n * required, NEVER auto-accepted). The form fields are left as-is. The user\n * re-accepts and resubmits; the SDK never auto-resubmits.\n */\n async function handleConsentStale(\n control: SignupStepperControl,\n ): Promise<void> {\n const fresh = await fetchOnboardingSpec({\n baseUrl: options.baseUrl,\n onboarder: options.onboarder,\n fetch: options.fetch,\n timeoutMs: options.timeoutMs,\n cache,\n });\n if (unmounted) return;\n\n siteKey = options.siteKey ?? fresh.botChallenge?.siteKey ?? \"\";\n currentSpecVersion = fresh.specVersion;\n control.applyNewConsentPack(fresh);\n // Re-accepting changed docs is a NEW logical submission → rotate the key.\n idempotencyKey = null;\n lastFingerprint = null;\n }\n\n async function handleSubmit(control: SignupStepperControl): Promise<void> {\n if (!control.validateAll()) return;\n control.acknowledgeSpecStale();\n control.setSubmitting();\n\n const body = control.buildSubmitPayload();\n const fingerprint = computeSignupFingerprint(body);\n if (idempotencyKey === null || fingerprint !== lastFingerprint) {\n idempotencyKey = generateIdempotencyKey();\n lastFingerprint = fingerprint;\n }\n\n // First token up front (clear pre-HTTP failure); fresh token per retry\n // attempt via the provider (single-use tokens).\n let firstToken: string | undefined;\n if (siteKey) {\n try {\n firstToken = await executeRecaptcha(siteKey, \"signup_submit\", {\n timeoutMs: options.timeoutMs,\n });\n } catch (recaptchaErr) {\n control.setError(\"Could not load bot protection. Please try again.\");\n options.onError?.(recaptchaErr);\n return;\n }\n }\n let usedFirst = false;\n const tokenProvider = async (): Promise<string> => {\n if (!usedFirst) {\n usedFirst = true;\n return firstToken!;\n }\n return executeRecaptcha(siteKey, \"signup_submit\", {\n timeoutMs: options.timeoutMs,\n });\n };\n\n try {\n const result = await submitSignup(body, {\n baseUrl: options.baseUrl,\n ...(siteKey ? { botToken: tokenProvider } : {}),\n idempotencyKey,\n fetch: options.fetch,\n timeoutMs: options.timeoutMs,\n });\n idempotencyKey = null;\n lastFingerprint = null;\n control.setSuccess(result.terminalStage);\n options.onSuccess?.(result);\n } catch (err) {\n if (err instanceof OnboardingSpecStaleError) {\n try {\n await handleSpecStale(control);\n } catch (refetchErr) {\n control.setError(\n \"The signup form changed and could not be reloaded. Please refresh the page.\",\n );\n options.onError?.(refetchErr);\n return;\n }\n options.onError?.(err);\n } else if (err instanceof OnboardingConsentStaleError) {\n // D543 §4: refetch + swap consentPack; changed docs require\n // re-acceptance. NEVER auto-accept a changed doc, NEVER auto-resubmit.\n try {\n await handleConsentStale(control);\n } catch (refetchErr) {\n control.setError(\n \"The legal documents changed and could not be reloaded. Please refresh the page.\",\n );\n options.onError?.(refetchErr);\n return;\n }\n options.onError?.(err);\n } else if (err instanceof OnboardingConsentIncompleteError) {\n // The server found a required doc missing/unaccepted — route the user\n // back to the consent step. validateAll() will surface the per-doc\n // errors on the next state emit.\n control.validateAll();\n control.setError(\"Please accept all required documents to continue.\");\n options.onError?.(err);\n } else if (err instanceof OnboardingBotChallengeError) {\n control.setError(\n \"Bot protection check failed. Please refresh the page and try again.\",\n );\n options.onError?.(err);\n } else if (err instanceof OnboardingRateLimitError) {\n control.setError(\n err.retryAfterSeconds !== null\n ? `Too many requests. Please wait ${err.retryAfterSeconds}s.`\n : \"Too many requests. Please wait a moment.\",\n );\n options.onError?.(err);\n } else {\n control.setError(\"Something went wrong. Please try again in a moment.\");\n options.onError?.(err);\n }\n }\n }\n\n function onStateChange(\n control: SignupStepperControl,\n state: SignupStepperState,\n ): void {\n // Full step re-render only when the step (or staleness) changed —\n // in-place updates otherwise so typing never loses focus. A consent_stale\n // swap ALSO forces a re-render so the cards re-render cleared + tagged.\n if (\n state.stepIndex !== renderedStepIndex ||\n state.specStale !== renderedStale ||\n state.consentStale !== renderedConsentStale\n ) {\n renderedStepIndex = state.stepIndex;\n renderedStale = state.specStale;\n renderedConsentStale = state.consentStale;\n renderStep(control, state);\n renderStepsIndicator(state);\n }\n\n staleBanner.style.display =\n state.specStale || state.consentStale ? \"\" : \"none\";\n staleBanner.textContent = state.specStale\n ? `This form was just updated by the provider${staleDiffSummary}. Please review your answers below and submit again.`\n : state.consentStale\n ? \"One or more legal documents were updated. Please review and re-accept the updated documents below, then submit again.\"\n : \"\";\n\n setFieldErrorsInPlace(\n stepArea,\n state.errors,\n (path) => `nodii-f-${path.split(\".\")[0] ?? path}`,\n );\n // Account errors overlay (only present on the last step's DOM)\n for (const err of state.accountErrors) {\n const id = accountIdOf(err.path.split(\".\")[0] ?? err.path);\n const errorNode = stepArea.querySelector(idSelector(`${id}-error`));\n if (errorNode) errorNode.textContent = err.message;\n const inputNode = stepArea.querySelector(idSelector(id));\n if (inputNode) inputNode.classList.add(\"has-error\");\n }\n\n // Consent cards' disabled/checked/error state in place (only present on\n // the last step's DOM; a no-op elsewhere or with an empty consentPack).\n // MUST run AFTER setFieldErrorsInPlace — that function blanket-clears every\n // `.nodii-onboarding-field-error` node in stepArea (the consent error nodes\n // carry that class too), so writing consent errors first would be wiped.\n const consentStage = stepArea.querySelector(\n \".nodii-onboarding-consent-stage\",\n ) as HTMLElement | null;\n if (consentStage) {\n updateConsentStep(consentStage, state.consentState, state.consentErrors);\n }\n\n if (state.serverError) {\n serverErrorEl.textContent = state.serverError;\n serverErrorEl.style.display = \"\";\n } else {\n serverErrorEl.style.display = \"none\";\n }\n\n const forwardBtn = stepArea.querySelector(\n \"#nodii-signup-forward\",\n ) as HTMLButtonElement | null;\n if (forwardBtn) {\n forwardBtn.disabled = state.status === \"submitting\";\n }\n\n if (state.status === \"success\") {\n const message =\n state.terminalStage === \"active\"\n ? \"Your account is ready — you're all set!\"\n : state.terminalStage === \"inactive\"\n ? \"Your account was created. Complete verification to activate it.\"\n : \"Thanks for signing up! Check your email to verify your account.\";\n successEl.textContent = message;\n successEl.style.display = \"\";\n form.style.display = \"none\";\n } else {\n // Any non-success status (editing/submitting/error) shows the form and\n // hides the success panel. Without this, a reset()→\"editing\" re-emit\n // would leave the success panel up and the form hidden until reload.\n successEl.style.display = \"none\";\n form.style.display = \"\";\n }\n }\n\n // ── Boot: fetch spec, then build the interactive form ──\n void (async () => {\n let spec: OnboardingSpec;\n try {\n spec = await fetchOnboardingSpec({\n baseUrl: options.baseUrl,\n onboarder: options.onboarder,\n fetch: options.fetch,\n timeoutMs: options.timeoutMs,\n cache,\n // Reuse a spec already loaded for this onboarder this session (a\n // remount into the same page shouldn't re-hit the network). A 409 on\n // submit is the authoritative staleness signal that triggers refetch.\n preferCached: true,\n });\n } catch (err) {\n if (unmounted) return;\n loadingEl.textContent =\n \"The signup form could not be loaded. Please refresh the page.\";\n options.onError?.(err);\n return;\n }\n if (unmounted) return;\n\n siteKey = options.siteKey ?? spec.botChallenge?.siteKey ?? \"\";\n currentSpecVersion = spec.specVersion;\n\n const control = createSignupStepper(spec);\n stepper = control;\n\n form.addEventListener(\"submit\", (event: Event) => {\n event.preventDefault();\n void handleSubmit(control);\n });\n\n form.appendChild(stepsIndicator);\n form.appendChild(staleBanner);\n form.appendChild(stepArea);\n form.appendChild(serverErrorEl);\n\n wrapper.removeChild(loadingEl);\n wrapper.appendChild(successEl);\n wrapper.appendChild(form);\n\n unsubscribe = control.subscribe((state) => onStateChange(control, state));\n // Initial render\n onStateChange(control, control.getState());\n options.onReady?.(spec);\n })();\n\n return {\n unmount() {\n unmounted = true;\n unsubscribe?.();\n if (wrapper.parentNode === host) host.removeChild(wrapper);\n },\n reset() {\n idempotencyKey = null;\n lastFingerprint = null;\n // Force a full re-render on the next state emit so cleared answers\n // actually re-render as empty inputs.\n renderedStepIndex = -1;\n renderedStale = false;\n if (stepper) {\n // stepper.reset() clears answers/credentials/consent and transitions\n // status back to \"editing\"; the emitted state re-renders the form,\n // hides the success panel (via onStateChange's else branch), and\n // repositions to step 0.\n stepper.reset();\n } else {\n form.style.display = \"\";\n successEl.style.display = \"none\";\n }\n },\n };\n}\n","/// <reference lib=\"dom\" />\n/// <reference lib=\"dom.iterable\" />\nexport {\n mountContactForm,\n type ContactFormMountOptions,\n type MountedWidget,\n} from \"./contact-form.js\";\n\nexport { mountSignupForm, type SignupFormMountOptions } from \"./signup-form.js\";\n\nexport { injectWidgetStyles, DEFAULT_WIDGET_CSS } from \"./styles.js\";\n\nexport { cssEscape, idSelector } from \"./dom-utils.js\";\n\n// D543 default ConsentPack step components (opt-in — the headless controller\n// in @nodii/onboarding/consent is enough to build a bespoke consent UI). NO\n// iframe: doc content renders inline same-origin so scroll-to-end is real.\nexport {\n renderConsentStep,\n updateConsentStep,\n consentDocElementId,\n type ConsentStepRenderOptions,\n} from \"./consent-step.js\";\n\n/**\n * Namespace entrypoint mirroring the plan's mount API:\n * OnboardingWidget.mount(el, { onboarder, form: 'contact'|'signup', baseUrl, ... })\n */\nimport { mountContactForm } from \"./contact-form.js\";\nimport type { ContactFormMountOptions, MountedWidget } from \"./contact-form.js\";\nimport { mountSignupForm } from \"./signup-form.js\";\nimport type { SignupFormMountOptions } from \"./signup-form.js\";\n\nexport type WidgetMountOptions =\n ContactFormMountOptions | SignupFormMountOptions;\n\nexport const OnboardingWidget = {\n /**\n * Mount the onboarding widget into a host element.\n *\n * @param el - The DOM element to render into.\n * @param options - Widget configuration. `form: \"contact\"` renders the\n * fixed contact form (Phase 1); `form: \"signup\"` fetches the D540 spec\n * and renders the dynamic stepper (Phase 2 — siteKey comes from the\n * spec's botChallenge unless overridden).\n * @returns A mounted widget control (unmount / reset).\n *\n * @example\n * ```ts\n * import { OnboardingWidget } from \"@nodii/onboarding/widget\";\n *\n * OnboardingWidget.mount(document.getElementById(\"signup-form\")!, {\n * onboarder: \"acme-corp\",\n * form: \"signup\",\n * baseUrl: \"https://api.acme.nucleus-cloud.in\",\n * onSuccess: (r) => console.log(\"landed at\", r.terminalStage),\n * });\n * ```\n */\n mount(el: HTMLElement, options: WidgetMountOptions): MountedWidget {\n if (options.form === \"contact\") {\n return mountContactForm(el, options);\n }\n if (options.form === \"signup\") {\n return mountSignupForm(el, options);\n }\n throw new Error(\n `OnboardingWidget.mount: unknown form \"${(options as { form: string }).form}\". Supported: \"contact\", \"signup\".`,\n );\n },\n} as const;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-JFDQZ3AC.js"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { createConsentController } from './chunk-AZE3NPSY.js';
|
|
1
2
|
import { z } from 'zod/v3';
|
|
2
3
|
|
|
3
|
-
// src/dynamic/derive.ts
|
|
4
4
|
function optionValue(option) {
|
|
5
5
|
if (option !== null && typeof option === "object") {
|
|
6
6
|
const o = option;
|
|
@@ -144,7 +144,9 @@ function deriveAnswersSchema(steps) {
|
|
|
144
144
|
}
|
|
145
145
|
var credentialsSchema = z.object({
|
|
146
146
|
email: z.string().email("A valid account email is required"),
|
|
147
|
-
|
|
147
|
+
displayName: z.string().trim().min(1, "Your name is required").max(200),
|
|
148
|
+
organisationName: z.string().trim().min(1, "Organisation name is required").max(200),
|
|
149
|
+
subdomain: z.string().trim().min(1, "Workspace subdomain is required").max(63)
|
|
148
150
|
});
|
|
149
151
|
function zodIssuesToFieldErrors(issues) {
|
|
150
152
|
return issues.map((issue) => ({
|
|
@@ -161,6 +163,7 @@ function serviceIdsOf(key, value) {
|
|
|
161
163
|
function createSignupStepper(spec) {
|
|
162
164
|
let steps = spec.forms.signup.steps;
|
|
163
165
|
let specVersion = spec.specVersion;
|
|
166
|
+
let consentController = createConsentController(spec.consentPack);
|
|
164
167
|
let state = {
|
|
165
168
|
stepIndex: 0,
|
|
166
169
|
stepCount: steps.length,
|
|
@@ -170,20 +173,52 @@ function createSignupStepper(spec) {
|
|
|
170
173
|
errors: [],
|
|
171
174
|
accountErrors: [],
|
|
172
175
|
consent: { tosAccepted: false, privacyAccepted: false },
|
|
173
|
-
credentials: {
|
|
176
|
+
credentials: {
|
|
177
|
+
email: "",
|
|
178
|
+
displayName: "",
|
|
179
|
+
organisationName: "",
|
|
180
|
+
subdomain: ""
|
|
181
|
+
},
|
|
174
182
|
status: "editing",
|
|
175
183
|
serverError: null,
|
|
176
184
|
specStale: false,
|
|
177
185
|
specVersion,
|
|
178
|
-
terminalStage: null
|
|
186
|
+
terminalStage: null,
|
|
187
|
+
consentState: consentController.getState(),
|
|
188
|
+
consentStale: false,
|
|
189
|
+
staleConsentKeys: [],
|
|
190
|
+
consentErrors: []
|
|
179
191
|
};
|
|
180
192
|
let validatedSteps = /* @__PURE__ */ new Set();
|
|
193
|
+
let consentValidated = false;
|
|
181
194
|
const listeners = /* @__PURE__ */ new Set();
|
|
182
195
|
function emit() {
|
|
183
196
|
for (const listener of listeners) {
|
|
184
197
|
listener(structuredClone(state));
|
|
185
198
|
}
|
|
186
199
|
}
|
|
200
|
+
function syncConsentState() {
|
|
201
|
+
const consentState = consentController.getState();
|
|
202
|
+
const consentErrors = consentValidated ? computeConsentErrors() : state.consentErrors;
|
|
203
|
+
state = { ...state, consentState, consentErrors };
|
|
204
|
+
emit();
|
|
205
|
+
}
|
|
206
|
+
let unsubscribeConsent = consentController.subscribe(
|
|
207
|
+
() => syncConsentState()
|
|
208
|
+
);
|
|
209
|
+
function computeConsentErrors() {
|
|
210
|
+
const errors = [];
|
|
211
|
+
for (const d of consentController.getState().documents) {
|
|
212
|
+
if (d.doc.required && !(d.accepted && d.gateSatisfied)) {
|
|
213
|
+
const need = d.doc.acceptanceLevel === "scroll_then_accept" && !d.gateSatisfied ? "scroll to the end, then accept" : d.doc.acceptanceLevel === "open_then_accept" && !d.gateSatisfied ? "open the document, then accept" : "accept";
|
|
214
|
+
errors.push({
|
|
215
|
+
path: d.key,
|
|
216
|
+
message: `You must ${need} "${d.doc.title}".`
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return errors;
|
|
221
|
+
}
|
|
187
222
|
function knownFieldKeys() {
|
|
188
223
|
const keys = /* @__PURE__ */ new Set();
|
|
189
224
|
for (const step of steps) {
|
|
@@ -209,10 +244,25 @@ function createSignupStepper(spec) {
|
|
|
209
244
|
}
|
|
210
245
|
return [...new Set(services)];
|
|
211
246
|
}
|
|
247
|
+
function effectiveConsentBooleans() {
|
|
248
|
+
if (consentController.isEmpty()) return { ...state.consent };
|
|
249
|
+
const byType = /* @__PURE__ */ new Map();
|
|
250
|
+
for (const d of consentController.getState().documents) {
|
|
251
|
+
byType.set(d.doc.docType, d.accepted && d.gateSatisfied);
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
tosAccepted: byType.has("tos") ? byType.get("tos") === true : state.consent.tosAccepted,
|
|
255
|
+
privacyAccepted: byType.has("privacy") ? byType.get("privacy") === true : state.consent.privacyAccepted
|
|
256
|
+
};
|
|
257
|
+
}
|
|
212
258
|
function runStepValidation(step) {
|
|
213
259
|
const result = deriveStepSchema(step).safeParse(stepAnswers(step));
|
|
214
260
|
return result.success ? [] : zodIssuesToFieldErrors(result.error.issues);
|
|
215
261
|
}
|
|
262
|
+
function swapConsentPack(newSpec) {
|
|
263
|
+
const resetKeys = consentController.applyNewPack(newSpec.consentPack);
|
|
264
|
+
return resetKeys;
|
|
265
|
+
}
|
|
216
266
|
function firstStepWithErrors() {
|
|
217
267
|
for (let i = 0; i < steps.length; i++) {
|
|
218
268
|
const step = steps[i];
|
|
@@ -221,6 +271,9 @@ function createSignupStepper(spec) {
|
|
|
221
271
|
return 0;
|
|
222
272
|
}
|
|
223
273
|
return {
|
|
274
|
+
get consent() {
|
|
275
|
+
return consentController;
|
|
276
|
+
},
|
|
224
277
|
getState() {
|
|
225
278
|
return structuredClone(state);
|
|
226
279
|
},
|
|
@@ -300,28 +353,39 @@ function createSignupStepper(spec) {
|
|
|
300
353
|
if (!credResult.success) {
|
|
301
354
|
accountErrors.push(...zodIssuesToFieldErrors(credResult.error.issues));
|
|
302
355
|
}
|
|
303
|
-
|
|
356
|
+
const effective = effectiveConsentBooleans();
|
|
357
|
+
if (effective.tosAccepted !== true) {
|
|
304
358
|
accountErrors.push({
|
|
305
359
|
path: "tosAccepted",
|
|
306
360
|
message: "You must accept the Terms of Service"
|
|
307
361
|
});
|
|
308
362
|
}
|
|
309
|
-
if (
|
|
363
|
+
if (effective.privacyAccepted !== true) {
|
|
310
364
|
accountErrors.push({
|
|
311
365
|
path: "privacyAccepted",
|
|
312
366
|
message: "You must accept the Privacy Policy"
|
|
313
367
|
});
|
|
314
368
|
}
|
|
315
|
-
|
|
369
|
+
consentValidated = true;
|
|
370
|
+
const consentErrors = consentController.isEmpty() ? [] : computeConsentErrors();
|
|
371
|
+
state = {
|
|
372
|
+
...state,
|
|
373
|
+
errors,
|
|
374
|
+
accountErrors,
|
|
375
|
+
consentErrors,
|
|
376
|
+
consentState: consentController.getState()
|
|
377
|
+
};
|
|
316
378
|
emit();
|
|
317
|
-
return errors.length === 0 && accountErrors.length === 0;
|
|
379
|
+
return errors.length === 0 && accountErrors.length === 0 && consentErrors.length === 0;
|
|
318
380
|
},
|
|
319
381
|
buildSubmitPayload() {
|
|
320
|
-
|
|
382
|
+
const effective = effectiveConsentBooleans();
|
|
383
|
+
if (effective.tosAccepted !== true || effective.privacyAccepted !== true) {
|
|
321
384
|
throw new Error(
|
|
322
385
|
"buildSubmitPayload: cannot build a submit payload without genuine user consent (tosAccepted && privacyAccepted must both be true). Call validateAll() and surface the consent errors to the user first."
|
|
323
386
|
);
|
|
324
387
|
}
|
|
388
|
+
const consentDocuments = consentController.isEmpty() ? void 0 : consentController.buildConsentPayload();
|
|
325
389
|
const parsed = deriveAnswersSchema(steps).safeParse(state.answers);
|
|
326
390
|
if (!parsed.success) {
|
|
327
391
|
const detail = parsed.error.issues.map((i) => `${i.path.join(".") || "(answers)"}: ${i.message}`).join("; ");
|
|
@@ -342,10 +406,16 @@ function createSignupStepper(spec) {
|
|
|
342
406
|
answers,
|
|
343
407
|
...selectedServices.length > 0 ? { selectedServices } : {},
|
|
344
408
|
consent: {
|
|
345
|
-
tosAccepted:
|
|
346
|
-
privacyAccepted:
|
|
409
|
+
tosAccepted: effective.tosAccepted,
|
|
410
|
+
privacyAccepted: effective.privacyAccepted,
|
|
411
|
+
...consentDocuments !== void 0 ? { documents: consentDocuments } : {}
|
|
347
412
|
},
|
|
348
|
-
credentials: {
|
|
413
|
+
credentials: {
|
|
414
|
+
email: state.credentials.email,
|
|
415
|
+
...state.credentials.displayName ? { displayName: state.credentials.displayName } : {}
|
|
416
|
+
},
|
|
417
|
+
organisationName: state.credentials.organisationName,
|
|
418
|
+
subdomain: state.credentials.subdomain
|
|
349
419
|
};
|
|
350
420
|
},
|
|
351
421
|
applyNewSpec(newSpec) {
|
|
@@ -359,6 +429,7 @@ function createSignupStepper(spec) {
|
|
|
359
429
|
for (const [key, value] of Object.entries(state.answers)) {
|
|
360
430
|
if (known.has(key)) answers[key] = value;
|
|
361
431
|
}
|
|
432
|
+
const resetKeys = swapConsentPack(newSpec);
|
|
362
433
|
state = {
|
|
363
434
|
...state,
|
|
364
435
|
answers,
|
|
@@ -366,7 +437,11 @@ function createSignupStepper(spec) {
|
|
|
366
437
|
specVersion,
|
|
367
438
|
specStale: true,
|
|
368
439
|
status: "editing",
|
|
369
|
-
serverError: null
|
|
440
|
+
serverError: null,
|
|
441
|
+
consentState: consentController.getState(),
|
|
442
|
+
consentStale: state.consentStale || resetKeys.length > 0,
|
|
443
|
+
staleConsentKeys: resetKeys,
|
|
444
|
+
consentErrors: []
|
|
370
445
|
};
|
|
371
446
|
state.selectedServices = deriveSelectedServices();
|
|
372
447
|
const stepIndex = Math.min(firstStepWithErrors(), steps.length - 1);
|
|
@@ -380,6 +455,25 @@ function createSignupStepper(spec) {
|
|
|
380
455
|
};
|
|
381
456
|
emit();
|
|
382
457
|
},
|
|
458
|
+
applyNewConsentPack(newSpec) {
|
|
459
|
+
const resetKeys = swapConsentPack(newSpec);
|
|
460
|
+
specVersion = newSpec.specVersion;
|
|
461
|
+
state = {
|
|
462
|
+
...state,
|
|
463
|
+
specVersion,
|
|
464
|
+
consentState: consentController.getState(),
|
|
465
|
+
consentStale: true,
|
|
466
|
+
staleConsentKeys: resetKeys,
|
|
467
|
+
consentErrors: [],
|
|
468
|
+
status: "editing",
|
|
469
|
+
serverError: null
|
|
470
|
+
};
|
|
471
|
+
emit();
|
|
472
|
+
},
|
|
473
|
+
acknowledgeConsentStale() {
|
|
474
|
+
state = { ...state, consentStale: false, staleConsentKeys: [] };
|
|
475
|
+
emit();
|
|
476
|
+
},
|
|
383
477
|
acknowledgeSpecStale() {
|
|
384
478
|
state = { ...state, specStale: false };
|
|
385
479
|
emit();
|
|
@@ -402,6 +496,15 @@ function createSignupStepper(spec) {
|
|
|
402
496
|
},
|
|
403
497
|
reset() {
|
|
404
498
|
validatedSteps = /* @__PURE__ */ new Set();
|
|
499
|
+
consentValidated = false;
|
|
500
|
+
const currentDocs = consentController.getState().documents.map((d) => d.doc);
|
|
501
|
+
unsubscribeConsent();
|
|
502
|
+
consentController = createConsentController(
|
|
503
|
+
currentDocs.length > 0 ? { documents: currentDocs } : void 0
|
|
504
|
+
);
|
|
505
|
+
unsubscribeConsent = consentController.subscribe(
|
|
506
|
+
() => syncConsentState()
|
|
507
|
+
);
|
|
405
508
|
state = {
|
|
406
509
|
stepIndex: 0,
|
|
407
510
|
stepCount: steps.length,
|
|
@@ -411,12 +514,21 @@ function createSignupStepper(spec) {
|
|
|
411
514
|
errors: [],
|
|
412
515
|
accountErrors: [],
|
|
413
516
|
consent: { tosAccepted: false, privacyAccepted: false },
|
|
414
|
-
credentials: {
|
|
517
|
+
credentials: {
|
|
518
|
+
email: "",
|
|
519
|
+
displayName: "",
|
|
520
|
+
organisationName: "",
|
|
521
|
+
subdomain: ""
|
|
522
|
+
},
|
|
415
523
|
status: "editing",
|
|
416
524
|
serverError: null,
|
|
417
525
|
specStale: false,
|
|
418
526
|
specVersion,
|
|
419
|
-
terminalStage: null
|
|
527
|
+
terminalStage: null,
|
|
528
|
+
consentState: consentController.getState(),
|
|
529
|
+
consentStale: false,
|
|
530
|
+
staleConsentKeys: [],
|
|
531
|
+
consentErrors: []
|
|
420
532
|
};
|
|
421
533
|
emit();
|
|
422
534
|
},
|
|
@@ -430,5 +542,5 @@ function createSignupStepper(spec) {
|
|
|
430
542
|
}
|
|
431
543
|
|
|
432
544
|
export { createSignupStepper, deriveAnswersSchema, deriveFieldSchema, deriveStepSchema, optionValue };
|
|
433
|
-
//# sourceMappingURL=chunk-
|
|
434
|
-
//# sourceMappingURL=chunk-
|
|
545
|
+
//# sourceMappingURL=chunk-KQTS47FC.js.map
|
|
546
|
+
//# sourceMappingURL=chunk-KQTS47FC.js.map
|