@wealthreach/site-kit 0.0.0-stage → 1.0.1

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 (42) hide show
  1. package/README.md +20 -2
  2. package/dist/a11y/client.d.ts +23 -0
  3. package/dist/a11y/client.js +72 -0
  4. package/dist/a11y/index.d.ts +43 -0
  5. package/dist/a11y/index.js +194 -0
  6. package/dist/a11y/shell-client.d.ts +19 -0
  7. package/dist/a11y/shell-client.js +45 -0
  8. package/dist/analytics/index.d.ts +47 -0
  9. package/dist/analytics/index.js +122 -0
  10. package/dist/attribution-DQaAWtA5.d.ts +41 -0
  11. package/dist/blog/index.d.ts +131 -0
  12. package/dist/blog/index.js +259 -0
  13. package/dist/chunk-4YRCSRZZ.js +32 -0
  14. package/dist/chunk-7GDXQ6UB.js +772 -0
  15. package/dist/chunk-QQP7VG2C.js +231 -0
  16. package/dist/chunk-Y77ARZE4.js +214 -0
  17. package/dist/config/index.d.ts +20 -0
  18. package/dist/config/index.js +445 -0
  19. package/dist/consent/index.d.ts +103 -0
  20. package/dist/consent/index.js +61 -0
  21. package/dist/disclosures/index.d.ts +57 -0
  22. package/dist/disclosures/index.js +361 -0
  23. package/dist/forms/index.d.ts +128 -0
  24. package/dist/forms/index.js +449 -0
  25. package/dist/mdx/index.d.ts +15 -0
  26. package/dist/mdx/index.js +45 -0
  27. package/dist/next/config.cjs +140 -0
  28. package/dist/next/config.d.cts +36 -0
  29. package/dist/next/config.d.ts +36 -0
  30. package/dist/next/config.js +111 -0
  31. package/dist/next/draft-route.d.ts +10 -0
  32. package/dist/next/draft-route.js +49 -0
  33. package/dist/next/leads-route.d.ts +138 -0
  34. package/dist/next/leads-route.js +771 -0
  35. package/dist/next/privacy-mode.d.ts +14 -0
  36. package/dist/next/privacy-mode.js +86 -0
  37. package/dist/next/proxy.d.ts +19 -0
  38. package/dist/next/proxy.js +93 -0
  39. package/dist/regulatory-schema-uDKNJ7q8.d.ts +1301 -0
  40. package/dist/schema-C1ixytx2.d.ts +2911 -0
  41. package/dist/schema-DD0nDOD0.d.ts +1744 -0
  42. package/package.json +85 -3
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
1
+ # `@wealthreach/site-kit`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared runtime plumbing for WealthReach Next.js 16 advisor websites. **Standardizes plumbing, never presentation.**
4
+
5
+ ## Subpath Exports
6
+
7
+ - `@wealthreach/site-kit/config` — Contract v3.8+ `siteConfigSchema`, `defineSiteConfig()`, `normalizeSiteConfig()`, `buildMetadata()`, `buildOrganizationJsonLd()`
8
+ - `@wealthreach/site-kit/disclosures` — Signed ENG-1460 regulatory disclosure generator (all 9 registration kinds) + `disclosureRegionProps()` / `disclosureLinkProps()`
9
+ - `@wealthreach/site-kit/consent` — Unified geo-aware consent engine (`wr_consent`, `privacy_mode`, GPC, legacy cookie migration, `/api/privacy-mode` 304 fallback, `<ConsentProvider>`, `<ConsentGate>`, `<ConsentBanner />`, `<PrivacyChoicesButton />`)
10
+ - `@wealthreach/site-kit/analytics` — First-touch UTM/gclid/referrer capture, consent-gated first-party + GTM `dataLayer` tracking, `<BookingEmbed />` + `useBookingTracker()`
11
+ - `@wealthreach/site-kit/forms` — Universal `useWealthReachForm()`, `<WealthReachForm>`, `<WealthReachHiddenContext>` (for Server Actions), automatic field packing + sensitive PII key blocklist
12
+ - `@wealthreach/site-kit/a11y` & `/a11y/client` — Static-SSG-safe `<SiteShell>`, `:focus-visible` `<SkipLink>`, `useAccessibleDialog()`
13
+ - `@wealthreach/site-kit/blog` & `/mdx` — Exact Contract 3.5 `status: "waiting"` hold gate, `isPostLive()`, `assertPostReadable()`, `isDraftViewEnabled()`, `isOwnerDraftAudience()`, `<DraftOwnerBanner />`, `buildPostJsonLd()`, `safeUrl()`, `rehypeSafeUrls()`
14
+ - `@wealthreach/site-kit/next`, `/next/proxy`, `/next/privacy-mode`, `/next/leads`, `/next/draft` — `withWealthReach()` (sandbox-safe), Edge geo proxy, `/api/privacy-mode` 304 fallback route, `/api/leads` handler + `submitLeadToWealthReach()`, and timing-safe `/api/draft` door
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install @wealthreach/site-kit
20
+ npm install -D @wealthreach/site-cli
21
+ ```
@@ -0,0 +1,23 @@
1
+ import * as React$1 from 'react';
2
+
3
+ interface UseAccessibleDialogOptions {
4
+ open: boolean;
5
+ onClose: () => void;
6
+ /** Optional ref to the trigger element; focus returns here on close. */
7
+ triggerRef?: React.RefObject<HTMLElement | null>;
8
+ }
9
+ /**
10
+ * Headless WCAG 2.2 AA dialog/drawer behavior: Escape to close, Tab focus trap,
11
+ * initial focus into dialog, and automatic focus restoration on close.
12
+ */
13
+ declare function useAccessibleDialog<T extends HTMLElement = HTMLDivElement>({ open, onClose, triggerRef, }: UseAccessibleDialogOptions): {
14
+ dialogRef: React$1.RefObject<T | null>;
15
+ dialogProps: {
16
+ role: "dialog";
17
+ "aria-modal": true;
18
+ tabIndex: number;
19
+ };
20
+ };
21
+
22
+ export { useAccessibleDialog };
23
+ export type { UseAccessibleDialogOptions };
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/a11y/dialog.ts
5
+ import { useEffect, useRef } from "react";
6
+ var FOCUSABLE_SELECTOR = [
7
+ 'a[href]:not([tabindex="-1"])',
8
+ 'button:not([disabled]):not([tabindex="-1"])',
9
+ 'input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])',
10
+ 'select:not([disabled]):not([tabindex="-1"])',
11
+ 'textarea:not([disabled]):not([tabindex="-1"])',
12
+ '[tabindex]:not([tabindex="-1"])'
13
+ ].join(", ");
14
+ function useAccessibleDialog({
15
+ open,
16
+ onClose,
17
+ triggerRef
18
+ }) {
19
+ const dialogRef = useRef(null);
20
+ const previousActiveRef = useRef(null);
21
+ useEffect(() => {
22
+ if (!open) return;
23
+ previousActiveRef.current = document.activeElement ?? null;
24
+ const dialog = dialogRef.current;
25
+ if (dialog) {
26
+ const firstFocusable = dialog.querySelector(FOCUSABLE_SELECTOR);
27
+ (firstFocusable ?? dialog).focus();
28
+ }
29
+ const onKeyDown = (event) => {
30
+ if (event.key === "Escape") {
31
+ event.preventDefault();
32
+ onClose();
33
+ return;
34
+ }
35
+ if (event.key !== "Tab" || !dialog) return;
36
+ const focusables = Array.from(
37
+ dialog.querySelectorAll(FOCUSABLE_SELECTOR)
38
+ );
39
+ if (focusables.length === 0) {
40
+ event.preventDefault();
41
+ dialog.focus();
42
+ return;
43
+ }
44
+ const first = focusables[0];
45
+ const last = focusables[focusables.length - 1];
46
+ if (event.shiftKey && document.activeElement === first) {
47
+ event.preventDefault();
48
+ last.focus();
49
+ } else if (!event.shiftKey && document.activeElement === last) {
50
+ event.preventDefault();
51
+ first.focus();
52
+ }
53
+ };
54
+ window.addEventListener("keydown", onKeyDown);
55
+ return () => {
56
+ window.removeEventListener("keydown", onKeyDown);
57
+ const restoreTarget = triggerRef?.current ?? previousActiveRef.current;
58
+ restoreTarget?.focus?.();
59
+ };
60
+ }, [open, onClose, triggerRef]);
61
+ return {
62
+ dialogRef,
63
+ dialogProps: {
64
+ role: "dialog",
65
+ "aria-modal": true,
66
+ tabIndex: -1
67
+ }
68
+ };
69
+ }
70
+ export {
71
+ useAccessibleDialog
72
+ };
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { SiteConfig } from '../config/index.js';
3
+ import 'zod';
4
+ import '../regulatory-schema-uDKNJ7q8.js';
5
+
6
+ interface SkipLinkProps {
7
+ targetId?: string;
8
+ label?: string;
9
+ className?: string;
10
+ }
11
+ /**
12
+ * Keyboard-only WCAG 2.2 AA skip link: visually hidden until `:focus-visible`,
13
+ * jumps directly to `#main-content`.
14
+ */
15
+ declare function SkipLink({ targetId, label, className, }: SkipLinkProps): React.JSX.Element;
16
+
17
+ interface SiteShellProps {
18
+ config: SiteConfig;
19
+ header?: React.ReactNode;
20
+ footer?: React.ReactNode;
21
+ /** Replace the default token-styled consent banner with a 100% custom component using `useConsent()`. */
22
+ consentBanner?: React.ReactNode;
23
+ /** Optional analytics component (e.g. `<Analytics />` from `@vercel/analytics/next`), auto-gated by consent. */
24
+ analytics?: React.ReactNode;
25
+ /** Extra elements to render inside `<head>` (fonts, custom preconnects, etc.). */
26
+ head?: React.ReactNode;
27
+ htmlClassName?: string;
28
+ bodyClassName?: string;
29
+ mainClassName?: string;
30
+ /** Override 304 privacy-mode fallback endpoint (defaults to "/api/privacy-mode"). */
31
+ privacyModeEndpoint?: string;
32
+ children: React.ReactNode;
33
+ }
34
+ /**
35
+ * Invisible compliance, consent, accessibility, and SEO root shell.
36
+ *
37
+ * HARD STATIC-SSG INVARIANT: SiteShell NEVER calls `cookies()` or `headers()`
38
+ * from `next/headers`, keeping every page 100% statically cacheable on Vercel CDN.
39
+ */
40
+ declare function SiteShell({ config, header, footer, consentBanner, analytics, head, htmlClassName, bodyClassName, mainClassName, privacyModeEndpoint, children, }: SiteShellProps): React.JSX.Element;
41
+
42
+ export { SiteShell, SkipLink };
43
+ export type { SiteShellProps, SkipLinkProps };
@@ -0,0 +1,194 @@
1
+ // src/a11y/skip-link.tsx
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ function SkipLink({
4
+ targetId = "main-content",
5
+ label = "Skip to main content",
6
+ className
7
+ }) {
8
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
9
+ !className && /* @__PURE__ */ jsx("style", { children: `
10
+ .wr-skip-link {
11
+ position: absolute;
12
+ width: 1px;
13
+ height: 1px;
14
+ padding: 0;
15
+ margin: -1px;
16
+ overflow: hidden;
17
+ clip: rect(0, 0, 0, 0);
18
+ white-space: nowrap;
19
+ border: 0;
20
+ }
21
+ .wr-skip-link:focus,
22
+ .wr-skip-link:focus-visible {
23
+ position: fixed;
24
+ top: 0.75rem;
25
+ left: 0.75rem;
26
+ z-index: 9999;
27
+ width: auto;
28
+ height: auto;
29
+ margin: 0;
30
+ overflow: visible;
31
+ clip: auto;
32
+ white-space: normal;
33
+ padding: 0.625rem 1rem;
34
+ border-radius: var(--wr-radius, 0.375rem);
35
+ background: var(--wr-primary, #111827);
36
+ color: var(--wr-primary-foreground, #ffffff);
37
+ font-size: 0.875rem;
38
+ font-weight: 600;
39
+ text-decoration: none;
40
+ outline: 2px solid var(--wr-foreground, #111827);
41
+ outline-offset: 2px;
42
+ }
43
+ ` }),
44
+ /* @__PURE__ */ jsx(
45
+ "a",
46
+ {
47
+ href: `#${targetId}`,
48
+ "data-wr-skip-link": "",
49
+ className: className ?? "wr-skip-link",
50
+ children: label
51
+ }
52
+ )
53
+ ] });
54
+ }
55
+
56
+ // src/config/metadata.ts
57
+ function buildOrganizationJsonLd(config) {
58
+ const org = config.jsonLd?.organization;
59
+ if (!org) return null;
60
+ return {
61
+ "@context": "https://schema.org",
62
+ "@type": org.type ?? "FinancialService",
63
+ name: config.brand.legalName,
64
+ ...config.seo.siteUrl ? { url: config.seo.siteUrl } : {},
65
+ ...config.brand.logoUrl ? { logo: config.brand.logoUrl } : {},
66
+ ...org.sameAs ? { sameAs: org.sameAs } : {},
67
+ ...org.areaServed ? { areaServed: org.areaServed } : {}
68
+ };
69
+ }
70
+ function serializeJsonLd(data) {
71
+ return JSON.stringify(data).replace(/</g, "\\u003c");
72
+ }
73
+
74
+ // src/consent/core.ts
75
+ var CONSENT_COOKIE = "wr_consent";
76
+ var MODE_COOKIE = "privacy_mode";
77
+ var CONSENT_MAX_AGE = 60 * 60 * 24 * 180;
78
+ var MODE_MAX_AGE = 60 * 60 * 24;
79
+ var VISITOR_SCRIPT_ID = "wr-site-script";
80
+ var GTM_SCRIPT_ID = "wr-gtm-script";
81
+ var GA4_SCRIPT_ID = "wr-ga4-script";
82
+
83
+ // src/consent/bootstrap.ts
84
+ function safeJson(value) {
85
+ return JSON.stringify(value).replace(/</g, "\\u003c");
86
+ }
87
+ var GTM_ID_RE = /^GTM-[A-Z0-9]{4,16}$/;
88
+ var GA4_ID_RE = /^G-[A-Z0-9]{4,16}$/;
89
+ var ALLOWED_VISITOR_HOST_RE = /(?:^|\.)wealthreach\.(?:ai|com)$/i;
90
+ function sanitizeVisitorScriptUrl(raw) {
91
+ const trimmed = raw?.trim() || "";
92
+ if (!trimmed) return "";
93
+ if (trimmed.startsWith("/") && !trimmed.startsWith("//") && !trimmed.includes("\\")) {
94
+ return trimmed;
95
+ }
96
+ try {
97
+ const parsed = new URL(trimmed);
98
+ if (parsed.protocol === "https:" && ALLOWED_VISITOR_HOST_RE.test(parsed.hostname)) {
99
+ return parsed.toString();
100
+ }
101
+ } catch {
102
+ }
103
+ return "";
104
+ }
105
+ function sanitizeGtmId(raw) {
106
+ const trimmed = raw?.trim() || "";
107
+ return GTM_ID_RE.test(trimmed) ? trimmed : "";
108
+ }
109
+ function sanitizeGa4Id(raw) {
110
+ const trimmed = raw?.trim() || "";
111
+ return GA4_ID_RE.test(trimmed) ? trimmed : "";
112
+ }
113
+ function buildConsentBootstrapScript(options) {
114
+ const visitorUrl = sanitizeVisitorScriptUrl(options.visitorScriptUrl);
115
+ const gtmId = sanitizeGtmId(options.gtmId);
116
+ const ga4Id = sanitizeGa4Id(options.ga4MeasurementId);
117
+ if (!visitorUrl && !gtmId && !ga4Id) return null;
118
+ const legacy = options.legacyConsentCookies ?? [];
119
+ const loaders = [];
120
+ if (visitorUrl) {
121
+ loaders.push(
122
+ `if(!document.getElementById('${VISITOR_SCRIPT_ID}')){var s=document.createElement('script');s.id='${VISITOR_SCRIPT_ID}';s.async=true;s.src=${safeJson(visitorUrl)};s.setAttribute('data-consent-category','analytics');document.head.appendChild(s);}`
123
+ );
124
+ }
125
+ if (gtmId) {
126
+ loaders.push(
127
+ `if(!document.getElementById('${GTM_SCRIPT_ID}')){window.dataLayer=window.dataLayer||[];window.dataLayer.push({'gtm.start':Date.now(),event:'gtm.js'});var g=document.createElement('script');g.id='${GTM_SCRIPT_ID}';g.async=true;g.src=${safeJson(`https://www.googletagmanager.com/gtm.js?id=${encodeURIComponent(gtmId)}`)};g.setAttribute('data-consent-category','analytics');document.head.appendChild(g);}`
128
+ );
129
+ }
130
+ if (ga4Id) {
131
+ loaders.push(
132
+ `if(!document.getElementById('${GA4_SCRIPT_ID}')){window.dataLayer=window.dataLayer||[];function gtag(){window.dataLayer.push(arguments);}window.gtag=window.gtag||gtag;gtag('js',new Date());gtag('config',${safeJson(ga4Id)});var a=document.createElement('script');a.id='${GA4_SCRIPT_ID}';a.async=true;a.src=${safeJson(`https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(ga4Id)}`)};a.setAttribute('data-consent-category','analytics');document.head.appendChild(a);}`
133
+ );
134
+ }
135
+ return `(function(){try{var g=function(n){var p=document.cookie.split('; ').find(function(v){return v.indexOf(n+'=')===0});return p?decodeURIComponent(p.slice(n.length+1)):null};var c=g('${CONSENT_COOKIE}');if(!c){var leg=${safeJson(legacy)};for(var i=0;i<leg.length;i++){var lv=g(leg[i]);if(lv){c=lv.indexOf('analytics:yes')>-1?'analytics:yes':lv.indexOf('analytics:no')>-1?'analytics:no':null;if(c)break;}}}if(c==='analytics:no')return;var gpc=navigator.globalPrivacyControl===true;if(c!=='analytics:yes'&&!(g('${MODE_COOKIE}')==='opt-out'&&!gpc))return;${loaders.join("")}}catch(e){}})();`;
136
+ }
137
+
138
+ // src/a11y/site-shell.tsx
139
+ import { SiteShellClient } from "./shell-client.js";
140
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
141
+ function SiteShell({
142
+ config,
143
+ header,
144
+ footer,
145
+ consentBanner,
146
+ analytics,
147
+ head,
148
+ htmlClassName,
149
+ bodyClassName = "antialiased",
150
+ mainClassName,
151
+ privacyModeEndpoint,
152
+ children
153
+ }) {
154
+ const bootstrapScript = buildConsentBootstrapScript({
155
+ visitorScriptUrl: config.visitors?.enabled ? config.visitors.siteScriptUrl : void 0,
156
+ gtmId: config.integrations?.gtmId,
157
+ ga4MeasurementId: config.integrations?.ga4MeasurementId,
158
+ legacyConsentCookies: config.consent?.legacyConsentCookies
159
+ });
160
+ const orgJsonLd = buildOrganizationJsonLd(config);
161
+ return /* @__PURE__ */ jsxs2("html", { lang: config.seo?.lang || "en", className: htmlClassName, children: [
162
+ /* @__PURE__ */ jsxs2("head", { children: [
163
+ bootstrapScript && /* @__PURE__ */ jsx2("script", { dangerouslySetInnerHTML: { __html: bootstrapScript } }),
164
+ head
165
+ ] }),
166
+ /* @__PURE__ */ jsxs2("body", { className: bodyClassName, children: [
167
+ orgJsonLd && /* @__PURE__ */ jsx2(
168
+ "script",
169
+ {
170
+ type: "application/ld+json",
171
+ dangerouslySetInnerHTML: { __html: serializeJsonLd(orgJsonLd) }
172
+ }
173
+ ),
174
+ /* @__PURE__ */ jsx2(SkipLink, {}),
175
+ /* @__PURE__ */ jsx2(
176
+ SiteShellClient,
177
+ {
178
+ config,
179
+ header,
180
+ footer,
181
+ consentBanner,
182
+ analytics,
183
+ mainClassName,
184
+ privacyModeEndpoint,
185
+ children
186
+ }
187
+ )
188
+ ] })
189
+ ] });
190
+ }
191
+ export {
192
+ SiteShell,
193
+ SkipLink
194
+ };
@@ -0,0 +1,19 @@
1
+ import React__default from 'react';
2
+ import { S as SiteConfig } from '../schema-DD0nDOD0.js';
3
+ import 'zod';
4
+
5
+ interface SiteShellClientProps {
6
+ config: SiteConfig;
7
+ header?: React__default.ReactNode;
8
+ footer?: React__default.ReactNode;
9
+ consentBanner?: React__default.ReactNode;
10
+ /** Optional analytics component (e.g. `<Analytics />` from `@vercel/analytics/next`), auto-gated by BrandywineOak consent. */
11
+ analytics?: React__default.ReactNode;
12
+ mainClassName?: string;
13
+ privacyModeEndpoint?: string;
14
+ children: React__default.ReactNode;
15
+ }
16
+ declare function SiteShellClient({ config, header, footer, consentBanner, analytics, mainClassName, privacyModeEndpoint, children, }: SiteShellClientProps): React__default.JSX.Element;
17
+
18
+ export { SiteShellClient };
19
+ export type { SiteShellClientProps };
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ "use client";
3
+ import {
4
+ ConsentBanner
5
+ } from "../chunk-Y77ARZE4.js";
6
+ import {
7
+ PageTracker
8
+ } from "../chunk-4YRCSRZZ.js";
9
+ import "../chunk-QQP7VG2C.js";
10
+ import {
11
+ ConsentGate,
12
+ ConsentProvider
13
+ } from "../chunk-7GDXQ6UB.js";
14
+
15
+ // src/a11y/shell-client.tsx
16
+ import { jsx, jsxs } from "react/jsx-runtime";
17
+ function SiteShellClient({
18
+ config,
19
+ header,
20
+ footer,
21
+ consentBanner,
22
+ analytics,
23
+ mainClassName,
24
+ privacyModeEndpoint,
25
+ children
26
+ }) {
27
+ return /* @__PURE__ */ jsxs(
28
+ ConsentProvider,
29
+ {
30
+ config,
31
+ privacyModeEndpoint,
32
+ children: [
33
+ header,
34
+ /* @__PURE__ */ jsx("main", { id: "main-content", tabIndex: -1, className: mainClassName, children }),
35
+ footer,
36
+ consentBanner !== void 0 ? consentBanner : /* @__PURE__ */ jsx(ConsentBanner, {}),
37
+ /* @__PURE__ */ jsx(PageTracker, {}),
38
+ !config.visitors?.enabled && analytics ? /* @__PURE__ */ jsx(ConsentGate, { children: analytics }) : null
39
+ ]
40
+ }
41
+ );
42
+ }
43
+ export {
44
+ SiteShellClient
45
+ };
@@ -0,0 +1,47 @@
1
+ export { A as AttributionSnapshot, W as WebsiteVisitSnapshot, c as captureAttributionOnLanding, r as readAttributionSnapshot, a as readConsentedWebsiteVisit } from '../attribution-DQaAWtA5.js';
2
+ import { S as SiteConfig } from '../schema-DD0nDOD0.js';
3
+ import React__default from 'react';
4
+ import 'zod';
5
+
6
+ declare function trackPageView(pageSlug: string, config?: SiteConfig): void;
7
+ declare function trackEvent(eventName: string, pageSlug: string, payload?: Record<string, unknown>, config?: SiteConfig): void;
8
+ declare function trackCtaClick(ctaLabel: string, pageSlug: string, config?: SiteConfig): void;
9
+ declare function trackFormSubmission(formId: string, pageSlug: string, config?: SiteConfig): void;
10
+ declare function trackBookingCompleted(provider: string, pageSlug: string, config?: SiteConfig): void;
11
+ /**
12
+ * Consent-gated Google Tag Manager dataLayer push (Vistica / DEV-56 pattern).
13
+ * No-ops unless BrandywineOak consent currently allows analytics.
14
+ */
15
+ declare function pushDataLayerEvent(event: string, extra?: Record<string, unknown>, configOverride?: SiteConfig): boolean;
16
+
17
+ /**
18
+ * Automatically captures cookie-free first-touch landing attribution and tracks
19
+ * consent-gated first-party page views on route transitions. Mounted by `<SiteShell>`.
20
+ */
21
+ declare function PageTracker(): null;
22
+
23
+ type BookingProvider = "calendly" | "calcom" | "none";
24
+ /**
25
+ * Headless listener for Calendly / Cal.com iframe booking completion events.
26
+ * Fires consent-gated `booking_completed` conversions automatically.
27
+ */
28
+ declare function useBookingTracker(options: {
29
+ provider: BookingProvider;
30
+ url: string;
31
+ enabled?: boolean;
32
+ onBookingCompleted?: () => void;
33
+ }): void;
34
+ interface BookingEmbedProps {
35
+ provider?: BookingProvider;
36
+ url?: string;
37
+ mode?: "embed" | "link";
38
+ label?: string;
39
+ height?: number;
40
+ className?: string;
41
+ title?: string;
42
+ onBookingCompleted?: () => void;
43
+ }
44
+ declare function BookingEmbed({ provider: providerProp, url: urlProp, mode: modeProp, label, height, className, title, onBookingCompleted, }: BookingEmbedProps): React__default.JSX.Element | null;
45
+
46
+ export { BookingEmbed, PageTracker, pushDataLayerEvent, trackBookingCompleted, trackCtaClick, trackEvent, trackFormSubmission, trackPageView, useBookingTracker };
47
+ export type { BookingEmbedProps, BookingProvider };
@@ -0,0 +1,122 @@
1
+ "use client";
2
+ import {
3
+ PageTracker
4
+ } from "../chunk-4YRCSRZZ.js";
5
+ import {
6
+ captureAttributionOnLanding,
7
+ pushDataLayerEvent,
8
+ readAttributionSnapshot,
9
+ readConsentedWebsiteVisit,
10
+ trackBookingCompleted,
11
+ trackCtaClick,
12
+ trackEvent,
13
+ trackFormSubmission,
14
+ trackPageView
15
+ } from "../chunk-QQP7VG2C.js";
16
+ import {
17
+ useConsent
18
+ } from "../chunk-7GDXQ6UB.js";
19
+
20
+ // src/analytics/booking.tsx
21
+ import { useEffect } from "react";
22
+ import { usePathname } from "next/navigation";
23
+ import { jsx } from "react/jsx-runtime";
24
+ function isCalendlyBookingCompleted(data) {
25
+ return typeof data === "object" && data !== null && data.event === "calendly.event_scheduled";
26
+ }
27
+ function isCalcomBookingCompleted(data) {
28
+ if (typeof data !== "object" || data === null) return false;
29
+ const obj = data;
30
+ return obj.originator === "CAL" && obj.type === "bookingSuccessfulV2";
31
+ }
32
+ function useBookingTracker(options) {
33
+ const pathname = usePathname();
34
+ const { config, allowed } = useConsent();
35
+ const { provider, url, enabled = true, onBookingCompleted } = options;
36
+ useEffect(() => {
37
+ if (!enabled || provider === "none" || !url) return;
38
+ const allowedOrigins = /* @__PURE__ */ new Set();
39
+ try {
40
+ allowedOrigins.add(new URL(url).origin);
41
+ } catch {
42
+ }
43
+ if (provider === "calendly") allowedOrigins.add("https://calendly.com");
44
+ if (provider === "calcom") {
45
+ allowedOrigins.add("https://cal.com");
46
+ allowedOrigins.add("https://app.cal.com");
47
+ }
48
+ function onMessage(event) {
49
+ if (!allowedOrigins.has(event.origin)) return;
50
+ const completed = provider === "calendly" ? isCalendlyBookingCompleted(event.data) : isCalcomBookingCompleted(event.data);
51
+ if (!completed) return;
52
+ if (allowed) {
53
+ trackBookingCompleted(provider, pathname ?? "/", config);
54
+ }
55
+ onBookingCompleted?.();
56
+ }
57
+ window.addEventListener("message", onMessage);
58
+ return () => window.removeEventListener("message", onMessage);
59
+ }, [enabled, provider, url, pathname, config, allowed, onBookingCompleted]);
60
+ }
61
+ function BookingEmbed({
62
+ provider: providerProp,
63
+ url: urlProp,
64
+ mode: modeProp,
65
+ label = "Schedule a meeting",
66
+ height = 680,
67
+ className,
68
+ title = "Schedule a meeting",
69
+ onBookingCompleted
70
+ }) {
71
+ const pathname = usePathname();
72
+ const { config } = useConsent();
73
+ const provider = providerProp ?? config.booking?.provider ?? "none";
74
+ const url = urlProp ?? config.booking?.url ?? config.contact?.calendarUrl ?? "";
75
+ const mode = modeProp ?? config.booking?.mode ?? "link";
76
+ useBookingTracker({
77
+ provider,
78
+ url,
79
+ enabled: mode === "embed",
80
+ onBookingCompleted
81
+ });
82
+ if (provider === "none" || !url) return null;
83
+ if (mode === "link") {
84
+ return /* @__PURE__ */ jsx(
85
+ "a",
86
+ {
87
+ href: url,
88
+ target: "_blank",
89
+ rel: "noopener noreferrer",
90
+ "data-wr-booking-link": provider,
91
+ onClick: () => trackCtaClick(label, pathname ?? "/", config),
92
+ className,
93
+ children: label
94
+ }
95
+ );
96
+ }
97
+ return /* @__PURE__ */ jsx(
98
+ "iframe",
99
+ {
100
+ src: url,
101
+ title,
102
+ loading: "lazy",
103
+ "data-wr-booking-embed": provider,
104
+ className,
105
+ style: { width: "100%", height: `${height}px`, border: 0 }
106
+ }
107
+ );
108
+ }
109
+ export {
110
+ BookingEmbed,
111
+ PageTracker,
112
+ captureAttributionOnLanding,
113
+ pushDataLayerEvent,
114
+ readAttributionSnapshot,
115
+ readConsentedWebsiteVisit,
116
+ trackBookingCompleted,
117
+ trackCtaClick,
118
+ trackEvent,
119
+ trackFormSubmission,
120
+ trackPageView,
121
+ useBookingTracker
122
+ };
@@ -0,0 +1,41 @@
1
+ interface AttributionSnapshot {
2
+ gclid?: string;
3
+ gbraid?: string;
4
+ wbraid?: string;
5
+ utm_source?: string;
6
+ utm_medium?: string;
7
+ utm_campaign?: string;
8
+ utm_term?: string;
9
+ utm_content?: string;
10
+ utm_id?: string;
11
+ adgroup?: string;
12
+ landing_path?: string;
13
+ referrer_host?: string;
14
+ captured_at?: string;
15
+ }
16
+ interface WebsiteVisitSnapshot {
17
+ visitorKey: string;
18
+ sessionId: string;
19
+ device: "desktop" | "mobile";
20
+ journey?: {
21
+ landingPath?: string;
22
+ referrerHost?: string;
23
+ pagesViewed?: string[];
24
+ };
25
+ }
26
+ /**
27
+ * Cookie-free first-touch attribution capture (stored in sessionStorage only).
28
+ * Safe to run on landing without consent because it uses no cross-site cookies
29
+ * or persistent visitor identifiers; attached only when the user voluntarily
30
+ * submits a form.
31
+ */
32
+ declare function captureAttributionOnLanding(): AttributionSnapshot;
33
+ declare function readAttributionSnapshot(): AttributionSnapshot;
34
+ /**
35
+ * Reads optional first-party website visitor identity ONLY when caller has
36
+ * already verified BrandywineOak consent (`allowed === true`).
37
+ */
38
+ declare function readConsentedWebsiteVisit(siteId: string, consentAllowed: boolean): WebsiteVisitSnapshot | undefined;
39
+
40
+ export { readConsentedWebsiteVisit as a, captureAttributionOnLanding as c, readAttributionSnapshot as r };
41
+ export type { AttributionSnapshot as A, WebsiteVisitSnapshot as W };