@sonordev/site-kit 1.2.7
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 +376 -0
- package/dist/SetupWizard-Cki06kB0.d.mts +12 -0
- package/dist/SetupWizard-Cki06kB0.d.ts +12 -0
- package/dist/analytics/index.d.mts +93 -0
- package/dist/analytics/index.d.ts +93 -0
- package/dist/analytics/index.js +89 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics/index.mjs +71 -0
- package/dist/analytics/index.mjs.map +1 -0
- package/dist/api-CWtoFJCO.d.mts +137 -0
- package/dist/api-CWtoFJCO.d.ts +137 -0
- package/dist/blog/index.d.mts +305 -0
- package/dist/blog/index.d.ts +305 -0
- package/dist/blog/index.js +1578 -0
- package/dist/blog/index.js.map +1 -0
- package/dist/blog/index.mjs +1562 -0
- package/dist/blog/index.mjs.map +1 -0
- package/dist/blog/server.d.mts +229 -0
- package/dist/blog/server.d.ts +229 -0
- package/dist/blog/server.js +692 -0
- package/dist/blog/server.js.map +1 -0
- package/dist/blog/server.mjs +666 -0
- package/dist/blog/server.mjs.map +1 -0
- package/dist/chunk-24277A3Q.mjs +968 -0
- package/dist/chunk-24277A3Q.mjs.map +1 -0
- package/dist/chunk-373TK6TZ.js +321 -0
- package/dist/chunk-373TK6TZ.js.map +1 -0
- package/dist/chunk-3MYZS6PD.js +30 -0
- package/dist/chunk-3MYZS6PD.js.map +1 -0
- package/dist/chunk-43GBM4SX.js +283 -0
- package/dist/chunk-43GBM4SX.js.map +1 -0
- package/dist/chunk-4XPGGLVP.mjs +53 -0
- package/dist/chunk-4XPGGLVP.mjs.map +1 -0
- package/dist/chunk-622GAQP5.js +2008 -0
- package/dist/chunk-622GAQP5.js.map +1 -0
- package/dist/chunk-6BIPAKL4.mjs +28 -0
- package/dist/chunk-6BIPAKL4.mjs.map +1 -0
- package/dist/chunk-6ZCISNAB.mjs +343 -0
- package/dist/chunk-6ZCISNAB.mjs.map +1 -0
- package/dist/chunk-72MQFHYJ.js +1429 -0
- package/dist/chunk-72MQFHYJ.js.map +1 -0
- package/dist/chunk-7557OTHW.js +62 -0
- package/dist/chunk-7557OTHW.js.map +1 -0
- package/dist/chunk-7FUV73JZ.js +981 -0
- package/dist/chunk-7FUV73JZ.js.map +1 -0
- package/dist/chunk-7RF6PVHA.mjs +324 -0
- package/dist/chunk-7RF6PVHA.mjs.map +1 -0
- package/dist/chunk-7RYCHO6D.mjs +134 -0
- package/dist/chunk-7RYCHO6D.mjs.map +1 -0
- package/dist/chunk-7UKPRW25.mjs +1999 -0
- package/dist/chunk-7UKPRW25.mjs.map +1 -0
- package/dist/chunk-7URAOG2M.js +14864 -0
- package/dist/chunk-7URAOG2M.js.map +1 -0
- package/dist/chunk-AFAO3TGS.mjs +810 -0
- package/dist/chunk-AFAO3TGS.mjs.map +1 -0
- package/dist/chunk-BYLIU6XG.js +343 -0
- package/dist/chunk-BYLIU6XG.js.map +1 -0
- package/dist/chunk-D63MUKZ6.mjs +4423 -0
- package/dist/chunk-D63MUKZ6.mjs.map +1 -0
- package/dist/chunk-DDKW2FNA.js +390 -0
- package/dist/chunk-DDKW2FNA.js.map +1 -0
- package/dist/chunk-DQYMKR27.mjs +341 -0
- package/dist/chunk-DQYMKR27.mjs.map +1 -0
- package/dist/chunk-DW5UJKHH.js +221 -0
- package/dist/chunk-DW5UJKHH.js.map +1 -0
- package/dist/chunk-EEZCR6E6.js +50 -0
- package/dist/chunk-EEZCR6E6.js.map +1 -0
- package/dist/chunk-GCJXQ4AG.mjs +59 -0
- package/dist/chunk-GCJXQ4AG.mjs.map +1 -0
- package/dist/chunk-JGNQK2G6.mjs +14845 -0
- package/dist/chunk-JGNQK2G6.mjs.map +1 -0
- package/dist/chunk-JTLOJLWQ.mjs +563 -0
- package/dist/chunk-JTLOJLWQ.mjs.map +1 -0
- package/dist/chunk-K23A4G76.mjs +202 -0
- package/dist/chunk-K23A4G76.mjs.map +1 -0
- package/dist/chunk-KKU3K7RG.js +336 -0
- package/dist/chunk-KKU3K7RG.js.map +1 -0
- package/dist/chunk-KUGMH4ZF.js +571 -0
- package/dist/chunk-KUGMH4ZF.js.map +1 -0
- package/dist/chunk-LBVWVP72.js +110 -0
- package/dist/chunk-LBVWVP72.js.map +1 -0
- package/dist/chunk-LIVWLY2P.js +138 -0
- package/dist/chunk-LIVWLY2P.js.map +1 -0
- package/dist/chunk-M2T6R7BA.mjs +1003 -0
- package/dist/chunk-M2T6R7BA.mjs.map +1 -0
- package/dist/chunk-MV3QN7PW.mjs +47 -0
- package/dist/chunk-MV3QN7PW.mjs.map +1 -0
- package/dist/chunk-OB7E654K.js +72 -0
- package/dist/chunk-OB7E654K.js.map +1 -0
- package/dist/chunk-OIIKTGRL.mjs +380 -0
- package/dist/chunk-OIIKTGRL.mjs.map +1 -0
- package/dist/chunk-P3UWIUJS.mjs +1427 -0
- package/dist/chunk-P3UWIUJS.mjs.map +1 -0
- package/dist/chunk-PKN27UMH.mjs +136 -0
- package/dist/chunk-PKN27UMH.mjs.map +1 -0
- package/dist/chunk-QXV4667R.mjs +105 -0
- package/dist/chunk-QXV4667R.mjs.map +1 -0
- package/dist/chunk-S7FRYNSU.mjs +315 -0
- package/dist/chunk-S7FRYNSU.mjs.map +1 -0
- package/dist/chunk-TFLQX7K7.mjs +68 -0
- package/dist/chunk-TFLQX7K7.mjs.map +1 -0
- package/dist/chunk-UWE5PCYJ.mjs +279 -0
- package/dist/chunk-UWE5PCYJ.mjs.map +1 -0
- package/dist/chunk-UYFDNX2F.js +4469 -0
- package/dist/chunk-UYFDNX2F.js.map +1 -0
- package/dist/chunk-W4PALSGM.js +350 -0
- package/dist/chunk-W4PALSGM.js.map +1 -0
- package/dist/chunk-WECQ6KOB.js +1008 -0
- package/dist/chunk-WECQ6KOB.js.map +1 -0
- package/dist/chunk-XQQWI6WB.js +814 -0
- package/dist/chunk-XQQWI6WB.js.map +1 -0
- package/dist/chunk-XZJOZJB6.js +140 -0
- package/dist/chunk-XZJOZJB6.js.map +1 -0
- package/dist/chunk-ZSMWDLMK.js +63 -0
- package/dist/chunk-ZSMWDLMK.js.map +1 -0
- package/dist/cli/index.js +37243 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.mjs +37209 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/commerce/index.d.mts +170 -0
- package/dist/commerce/index.d.ts +170 -0
- package/dist/commerce/index.js +174 -0
- package/dist/commerce/index.js.map +1 -0
- package/dist/commerce/index.mjs +5 -0
- package/dist/commerce/index.mjs.map +1 -0
- package/dist/commerce/server.d.mts +107 -0
- package/dist/commerce/server.d.ts +107 -0
- package/dist/commerce/server.js +187 -0
- package/dist/commerce/server.js.map +1 -0
- package/dist/commerce/server.mjs +177 -0
- package/dist/commerce/server.mjs.map +1 -0
- package/dist/config/index.d.mts +43 -0
- package/dist/config/index.d.ts +43 -0
- package/dist/config/index.js +66 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/index.mjs +64 -0
- package/dist/config/index.mjs.map +1 -0
- package/dist/engage/index.d.mts +33 -0
- package/dist/engage/index.d.ts +33 -0
- package/dist/engage/index.js +22 -0
- package/dist/engage/index.js.map +1 -0
- package/dist/engage/index.mjs +5 -0
- package/dist/engage/index.mjs.map +1 -0
- package/dist/forms/index.d.mts +437 -0
- package/dist/forms/index.d.ts +437 -0
- package/dist/forms/index.js +1168 -0
- package/dist/forms/index.js.map +1 -0
- package/dist/forms/index.mjs +1142 -0
- package/dist/forms/index.mjs.map +1 -0
- package/dist/generators-2XKQMPKH.mjs +4 -0
- package/dist/generators-2XKQMPKH.mjs.map +1 -0
- package/dist/generators-DTMO36DV.js +33 -0
- package/dist/generators-DTMO36DV.js.map +1 -0
- package/dist/images/index.d.mts +4 -0
- package/dist/images/index.d.ts +4 -0
- package/dist/images/index.js +46 -0
- package/dist/images/index.js.map +1 -0
- package/dist/images/index.mjs +5 -0
- package/dist/images/index.mjs.map +1 -0
- package/dist/images/server.d.mts +69 -0
- package/dist/images/server.d.ts +69 -0
- package/dist/images/server.js +21 -0
- package/dist/images/server.js.map +1 -0
- package/dist/images/server.mjs +4 -0
- package/dist/images/server.mjs.map +1 -0
- package/dist/index.d.mts +846 -0
- package/dist/index.d.ts +846 -0
- package/dist/index.js +2623 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2416 -0
- package/dist/index.mjs.map +1 -0
- package/dist/layout/index.d.mts +53 -0
- package/dist/layout/index.d.ts +53 -0
- package/dist/layout/index.js +187 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/index.mjs +185 -0
- package/dist/layout/index.mjs.map +1 -0
- package/dist/llms/index.d.mts +448 -0
- package/dist/llms/index.d.ts +448 -0
- package/dist/llms/index.js +581 -0
- package/dist/llms/index.js.map +1 -0
- package/dist/llms/index.mjs +529 -0
- package/dist/llms/index.mjs.map +1 -0
- package/dist/manifest/index.d.mts +62 -0
- package/dist/manifest/index.d.ts +62 -0
- package/dist/manifest/index.js +85 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/index.mjs +83 -0
- package/dist/manifest/index.mjs.map +1 -0
- package/dist/middleware/index.d.mts +63 -0
- package/dist/middleware/index.d.ts +63 -0
- package/dist/middleware/index.js +54 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/index.mjs +51 -0
- package/dist/middleware/index.mjs.map +1 -0
- package/dist/migrator-2MQHOFDQ.mjs +4 -0
- package/dist/migrator-2MQHOFDQ.mjs.map +1 -0
- package/dist/migrator-THJCF6MZ.js +37 -0
- package/dist/migrator-THJCF6MZ.js.map +1 -0
- package/dist/redirects/index.d.mts +78 -0
- package/dist/redirects/index.d.ts +78 -0
- package/dist/redirects/index.js +26 -0
- package/dist/redirects/index.js.map +1 -0
- package/dist/redirects/index.mjs +5 -0
- package/dist/redirects/index.mjs.map +1 -0
- package/dist/reputation/index.d.mts +57 -0
- package/dist/reputation/index.d.ts +57 -0
- package/dist/reputation/index.js +21 -0
- package/dist/reputation/index.js.map +1 -0
- package/dist/reputation/index.mjs +4 -0
- package/dist/reputation/index.mjs.map +1 -0
- package/dist/robots/index.d.mts +38 -0
- package/dist/robots/index.d.ts +38 -0
- package/dist/robots/index.js +52 -0
- package/dist/robots/index.js.map +1 -0
- package/dist/robots/index.mjs +50 -0
- package/dist/robots/index.mjs.map +1 -0
- package/dist/routing-B5XS-6_W.d.mts +118 -0
- package/dist/routing-DZYzyDHw.d.ts +118 -0
- package/dist/scanner-GAF5PO5F.js +53 -0
- package/dist/scanner-GAF5PO5F.js.map +1 -0
- package/dist/scanner-LKJKW7IT.mjs +4 -0
- package/dist/scanner-LKJKW7IT.mjs.map +1 -0
- package/dist/securityHeaders-nwZ6nP4g.d.mts +24 -0
- package/dist/securityHeaders-nwZ6nP4g.d.ts +24 -0
- package/dist/seo/index.d.mts +600 -0
- package/dist/seo/index.d.ts +600 -0
- package/dist/seo/index.js +883 -0
- package/dist/seo/index.js.map +1 -0
- package/dist/seo/index.mjs +773 -0
- package/dist/seo/index.mjs.map +1 -0
- package/dist/seo/register-sitemap-cli.js +151 -0
- package/dist/seo/register-sitemap-cli.js.map +1 -0
- package/dist/seo/register-sitemap-cli.mjs +144 -0
- package/dist/seo/register-sitemap-cli.mjs.map +1 -0
- package/dist/seo/server.d.mts +107 -0
- package/dist/seo/server.d.ts +107 -0
- package/dist/seo/server.js +207 -0
- package/dist/seo/server.js.map +1 -0
- package/dist/seo/server.mjs +186 -0
- package/dist/seo/server.mjs.map +1 -0
- package/dist/server-api-EWXKOQZA.mjs +4 -0
- package/dist/server-api-EWXKOQZA.mjs.map +1 -0
- package/dist/server-api-GJPNRYUP.js +81 -0
- package/dist/server-api-GJPNRYUP.js.map +1 -0
- package/dist/setup/client.d.mts +60 -0
- package/dist/setup/client.d.ts +60 -0
- package/dist/setup/client.js +31 -0
- package/dist/setup/client.js.map +1 -0
- package/dist/setup/client.mjs +6 -0
- package/dist/setup/client.mjs.map +1 -0
- package/dist/setup/index.d.mts +5 -0
- package/dist/setup/index.d.ts +5 -0
- package/dist/setup/index.js +35 -0
- package/dist/setup/index.js.map +1 -0
- package/dist/setup/index.mjs +6 -0
- package/dist/setup/index.mjs.map +1 -0
- package/dist/setup/server.d.mts +14 -0
- package/dist/setup/server.d.ts +14 -0
- package/dist/setup/server.js +13 -0
- package/dist/setup/server.js.map +1 -0
- package/dist/setup/server.mjs +4 -0
- package/dist/setup/server.mjs.map +1 -0
- package/dist/site-config/index.d.mts +24 -0
- package/dist/site-config/index.d.ts +24 -0
- package/dist/site-config/index.js +17 -0
- package/dist/site-config/index.js.map +1 -0
- package/dist/site-config/index.mjs +4 -0
- package/dist/site-config/index.mjs.map +1 -0
- package/dist/sitemap/index.d.mts +96 -0
- package/dist/sitemap/index.d.ts +96 -0
- package/dist/sitemap/index.js +288 -0
- package/dist/sitemap/index.js.map +1 -0
- package/dist/sitemap/index.mjs +285 -0
- package/dist/sitemap/index.mjs.map +1 -0
- package/dist/socket-loader-J26QHHOB.js +16 -0
- package/dist/socket-loader-J26QHHOB.js.map +1 -0
- package/dist/socket-loader-R7S2YJ2J.mjs +14 -0
- package/dist/socket-loader-R7S2YJ2J.mjs.map +1 -0
- package/dist/types-0dmq3k20.d.mts +168 -0
- package/dist/types-0dmq3k20.d.ts +168 -0
- package/dist/types-Blb2QNkV.d.mts +263 -0
- package/dist/types-Blb2QNkV.d.ts +263 -0
- package/dist/types-BnCwwUX3.d.mts +250 -0
- package/dist/types-BnCwwUX3.d.ts +250 -0
- package/dist/types-CGlnp43R.d.mts +312 -0
- package/dist/types-CGlnp43R.d.ts +312 -0
- package/dist/types-D08004rU.d.mts +179 -0
- package/dist/types-D08004rU.d.ts +179 -0
- package/dist/types-DNSYU7qI.d.mts +127 -0
- package/dist/types-DNSYU7qI.d.ts +127 -0
- package/dist/types-KZP_VWZp.d.mts +266 -0
- package/dist/types-KZP_VWZp.d.ts +266 -0
- package/dist/useEventModal-BVTx69XE.d.mts +274 -0
- package/dist/useEventModal-Dx1dItTJ.d.ts +274 -0
- package/dist/web-vitals-444RLW3B.js +252 -0
- package/dist/web-vitals-444RLW3B.js.map +1 -0
- package/dist/web-vitals-KPICZIEF.mjs +241 -0
- package/dist/web-vitals-KPICZIEF.mjs.map +1 -0
- package/package.json +192 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2623 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkKUGMH4ZF_js = require('./chunk-KUGMH4ZF.js');
|
|
4
|
+
var chunk43GBM4SX_js = require('./chunk-43GBM4SX.js');
|
|
5
|
+
var chunkW4PALSGM_js = require('./chunk-W4PALSGM.js');
|
|
6
|
+
require('./chunk-OB7E654K.js');
|
|
7
|
+
var chunkUYFDNX2F_js = require('./chunk-UYFDNX2F.js');
|
|
8
|
+
var chunk72MQFHYJ_js = require('./chunk-72MQFHYJ.js');
|
|
9
|
+
var chunkLBVWVP72_js = require('./chunk-LBVWVP72.js');
|
|
10
|
+
require('./chunk-7557OTHW.js');
|
|
11
|
+
var chunkLIVWLY2P_js = require('./chunk-LIVWLY2P.js');
|
|
12
|
+
var chunkWECQ6KOB_js = require('./chunk-WECQ6KOB.js');
|
|
13
|
+
var chunk622GAQP5_js = require('./chunk-622GAQP5.js');
|
|
14
|
+
var chunk373TK6TZ_js = require('./chunk-373TK6TZ.js');
|
|
15
|
+
require('./chunk-ZSMWDLMK.js');
|
|
16
|
+
var React2 = require('react');
|
|
17
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
18
|
+
|
|
19
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
|
+
|
|
21
|
+
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
22
|
+
|
|
23
|
+
var SiteKitContext = React2.createContext(null);
|
|
24
|
+
function useSiteKit() {
|
|
25
|
+
const context = React2.useContext(SiteKitContext);
|
|
26
|
+
if (!context) {
|
|
27
|
+
throw new Error("useSiteKit must be used within a SiteKitProvider");
|
|
28
|
+
}
|
|
29
|
+
return context;
|
|
30
|
+
}
|
|
31
|
+
function SiteKitProvider({
|
|
32
|
+
children,
|
|
33
|
+
apiKey,
|
|
34
|
+
apiUrl,
|
|
35
|
+
signalUrl,
|
|
36
|
+
projectId,
|
|
37
|
+
recaptchaSiteKey,
|
|
38
|
+
analytics,
|
|
39
|
+
engage,
|
|
40
|
+
forms,
|
|
41
|
+
signal,
|
|
42
|
+
debug = false
|
|
43
|
+
}) {
|
|
44
|
+
const isDev = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
|
|
45
|
+
const defaultApiUrl = isDev && process.env?.NEXT_PUBLIC_UPTRADE_API_URL ? process.env.NEXT_PUBLIC_UPTRADE_API_URL : "https://api.uptrademedia.com";
|
|
46
|
+
const defaultSignalUrl = isDev && process.env?.NEXT_PUBLIC_SIGNAL_API_URL ? process.env.NEXT_PUBLIC_SIGNAL_API_URL : "https://signal.uptrademedia.com";
|
|
47
|
+
const finalApiUrl = apiUrl || defaultApiUrl;
|
|
48
|
+
const finalSignalUrl = signalUrl || defaultSignalUrl;
|
|
49
|
+
const finalRecaptchaSiteKey = recaptchaSiteKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_RECAPTCHA_SITE_KEY : void 0);
|
|
50
|
+
if (!apiKey) {
|
|
51
|
+
console.error("@sonordev/site-kit: No API key provided. Set NEXT_PUBLIC_UPTRADE_API_KEY environment variable.");
|
|
52
|
+
}
|
|
53
|
+
if (typeof window !== "undefined") {
|
|
54
|
+
window.__SITE_KIT_API_URL__ = finalApiUrl;
|
|
55
|
+
window.__SITE_KIT_SIGNAL_URL__ = finalSignalUrl;
|
|
56
|
+
window.__SITE_KIT_API_KEY__ = apiKey;
|
|
57
|
+
window.__SITE_KIT_RECAPTCHA_SITE_KEY__ = finalRecaptchaSiteKey;
|
|
58
|
+
window.__SITE_KIT_DEBUG__ = debug;
|
|
59
|
+
}
|
|
60
|
+
React2.useEffect(() => {
|
|
61
|
+
if (apiKey && typeof window !== "undefined") {
|
|
62
|
+
chunk373TK6TZ_js.configureFormsApi({
|
|
63
|
+
baseUrl: finalApiUrl,
|
|
64
|
+
apiKey
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}, [finalApiUrl, apiKey]);
|
|
68
|
+
const contextValue = React2.useMemo(
|
|
69
|
+
() => ({
|
|
70
|
+
apiUrl: finalApiUrl,
|
|
71
|
+
signalUrl: finalSignalUrl,
|
|
72
|
+
apiKey,
|
|
73
|
+
analytics,
|
|
74
|
+
engage,
|
|
75
|
+
forms,
|
|
76
|
+
signal,
|
|
77
|
+
debug,
|
|
78
|
+
isReady: true
|
|
79
|
+
}),
|
|
80
|
+
[finalApiUrl, finalSignalUrl, apiKey, analytics, engage, forms, signal, debug]
|
|
81
|
+
);
|
|
82
|
+
let content = /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
83
|
+
if (signal?.enabled) {
|
|
84
|
+
content = /* @__PURE__ */ jsxRuntime.jsx(
|
|
85
|
+
chunkW4PALSGM_js.SignalBridge,
|
|
86
|
+
{
|
|
87
|
+
enabled: signal.enabled,
|
|
88
|
+
realtime: signal.realtime !== false,
|
|
89
|
+
experiments: signal.experiments !== false,
|
|
90
|
+
behaviorTracking: signal.behaviorTracking !== false,
|
|
91
|
+
children: content
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
if (analytics?.enabled) {
|
|
96
|
+
content = /* @__PURE__ */ jsxRuntime.jsx(React2.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
97
|
+
chunkWECQ6KOB_js.AnalyticsProvider,
|
|
98
|
+
{
|
|
99
|
+
apiUrl: finalApiUrl,
|
|
100
|
+
apiKey,
|
|
101
|
+
trackPageViews: analytics.trackPageViews !== false,
|
|
102
|
+
trackWebVitals: analytics.trackWebVitals !== false,
|
|
103
|
+
trackScrollDepth: analytics.trackScrollDepth !== false,
|
|
104
|
+
trackClicks: analytics.trackClicks !== false,
|
|
105
|
+
debug,
|
|
106
|
+
children: content
|
|
107
|
+
}
|
|
108
|
+
) });
|
|
109
|
+
}
|
|
110
|
+
if (engage?.enabled) {
|
|
111
|
+
content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
112
|
+
content,
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
114
|
+
chunk622GAQP5_js.EngageWidget,
|
|
115
|
+
{
|
|
116
|
+
apiUrl: finalApiUrl,
|
|
117
|
+
apiKey,
|
|
118
|
+
projectId,
|
|
119
|
+
position: engage.position || "bottom-right",
|
|
120
|
+
chatEnabled: engage.chatEnabled !== false
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
] });
|
|
124
|
+
}
|
|
125
|
+
content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
126
|
+
content,
|
|
127
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLIVWLY2P_js.SitemapSync, { debug })
|
|
128
|
+
] });
|
|
129
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SiteKitContext.Provider, { value: contextValue, children: content });
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/affiliates/api.ts
|
|
133
|
+
function getApiConfig() {
|
|
134
|
+
const apiUrl = typeof window !== "undefined" ? window.__SITE_KIT_API_URL__ || "https://api.uptrademedia.com" : "https://api.uptrademedia.com";
|
|
135
|
+
const apiKey = typeof window !== "undefined" ? window.__SITE_KIT_API_KEY__ || "" : "";
|
|
136
|
+
return { apiUrl, apiKey };
|
|
137
|
+
}
|
|
138
|
+
async function apiGet(endpoint) {
|
|
139
|
+
const { apiUrl, apiKey } = getApiConfig();
|
|
140
|
+
if (!apiKey) {
|
|
141
|
+
console.error("[Affiliates] No API key configured");
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const response = await fetch(`${apiUrl}${endpoint}`, {
|
|
146
|
+
method: "GET",
|
|
147
|
+
headers: {
|
|
148
|
+
"x-api-key": apiKey
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
if (!response.ok) {
|
|
152
|
+
console.error(`[Affiliates] API error: ${response.statusText}`);
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
return await response.json();
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.error("[Affiliates] Network error:", error);
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async function fetchAffiliates(options = {}) {
|
|
162
|
+
const result = await apiGet(
|
|
163
|
+
"/api/public/affiliates"
|
|
164
|
+
);
|
|
165
|
+
return result?.affiliates || [];
|
|
166
|
+
}
|
|
167
|
+
function getTrackingUrl(affiliateId, offerId) {
|
|
168
|
+
const { apiUrl } = getApiConfig();
|
|
169
|
+
return `${apiUrl}/a/${affiliateId}/${offerId}`;
|
|
170
|
+
}
|
|
171
|
+
function useAffiliates() {
|
|
172
|
+
const [affiliates, setAffiliates] = React2.useState([]);
|
|
173
|
+
const [isLoading, setIsLoading] = React2.useState(true);
|
|
174
|
+
const [error, setError] = React2.useState(null);
|
|
175
|
+
React2.useEffect(() => {
|
|
176
|
+
async function load() {
|
|
177
|
+
try {
|
|
178
|
+
setIsLoading(true);
|
|
179
|
+
setError(null);
|
|
180
|
+
const data = await fetchAffiliates();
|
|
181
|
+
setAffiliates(data);
|
|
182
|
+
} catch (err) {
|
|
183
|
+
setError(err instanceof Error ? err.message : "Failed to load affiliates");
|
|
184
|
+
} finally {
|
|
185
|
+
setIsLoading(false);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
load();
|
|
189
|
+
}, []);
|
|
190
|
+
return {
|
|
191
|
+
affiliates,
|
|
192
|
+
isLoading,
|
|
193
|
+
error,
|
|
194
|
+
getTrackingUrl
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function AffiliateCard({
|
|
198
|
+
affiliate,
|
|
199
|
+
className = "",
|
|
200
|
+
renderLogo,
|
|
201
|
+
showOffers = false
|
|
202
|
+
}) {
|
|
203
|
+
const { getTrackingUrl: getTrackingUrl2 } = useAffiliates();
|
|
204
|
+
const defaultLogo = /* @__PURE__ */ jsxRuntime.jsx("div", { "data-affiliate-logo": true, className: "affiliate-logo", children: affiliate.logo_url ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
205
|
+
"img",
|
|
206
|
+
{
|
|
207
|
+
src: affiliate.logo_url,
|
|
208
|
+
alt: affiliate.name,
|
|
209
|
+
loading: "lazy"
|
|
210
|
+
}
|
|
211
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: affiliate.name.charAt(0) }) });
|
|
212
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, "data-affiliate-card": true, "data-affiliate-id": affiliate.id, children: [
|
|
213
|
+
renderLogo ? renderLogo(affiliate) : defaultLogo,
|
|
214
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "data-affiliate-name": true, className: "affiliate-name", children: affiliate.name }),
|
|
215
|
+
affiliate.website_url && /* @__PURE__ */ jsxRuntime.jsx(
|
|
216
|
+
"a",
|
|
217
|
+
{
|
|
218
|
+
href: affiliate.website_url,
|
|
219
|
+
target: "_blank",
|
|
220
|
+
rel: "noopener noreferrer sponsored",
|
|
221
|
+
"data-affiliate-website": true,
|
|
222
|
+
className: "affiliate-website",
|
|
223
|
+
children: "Visit Website"
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
showOffers && affiliate.offers && affiliate.offers.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-affiliate-offers": true, className: "affiliate-offers", children: affiliate.offers.map((offer) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
227
|
+
"a",
|
|
228
|
+
{
|
|
229
|
+
href: getTrackingUrl2(affiliate.id, offer.id),
|
|
230
|
+
target: "_blank",
|
|
231
|
+
rel: "noopener noreferrer sponsored",
|
|
232
|
+
"data-affiliate-offer": true,
|
|
233
|
+
"data-offer-id": offer.id,
|
|
234
|
+
className: "affiliate-offer",
|
|
235
|
+
children: offer.name
|
|
236
|
+
},
|
|
237
|
+
offer.id
|
|
238
|
+
)) })
|
|
239
|
+
] });
|
|
240
|
+
}
|
|
241
|
+
function AffiliatesWidget({
|
|
242
|
+
className = "",
|
|
243
|
+
loadingComponent,
|
|
244
|
+
emptyComponent,
|
|
245
|
+
errorComponent,
|
|
246
|
+
showOffers = false,
|
|
247
|
+
renderAffiliate,
|
|
248
|
+
limit
|
|
249
|
+
}) {
|
|
250
|
+
const { affiliates, isLoading, error, getTrackingUrl: getTrackingUrl2 } = useAffiliates();
|
|
251
|
+
if (isLoading) {
|
|
252
|
+
return loadingComponent || /* @__PURE__ */ jsxRuntime.jsx("div", { "data-affiliates-loading": true, children: "Loading affiliates..." });
|
|
253
|
+
}
|
|
254
|
+
if (error) {
|
|
255
|
+
return errorComponent || /* @__PURE__ */ jsxRuntime.jsx("div", { "data-affiliates-error": true, children: error });
|
|
256
|
+
}
|
|
257
|
+
const displayAffiliates = limit ? affiliates.slice(0, limit) : affiliates;
|
|
258
|
+
if (displayAffiliates.length === 0) {
|
|
259
|
+
return emptyComponent || null;
|
|
260
|
+
}
|
|
261
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, "data-affiliates-widget": true, children: displayAffiliates.map(
|
|
262
|
+
(affiliate) => renderAffiliate ? renderAffiliate(affiliate) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
263
|
+
AffiliateCard,
|
|
264
|
+
{
|
|
265
|
+
affiliate,
|
|
266
|
+
showOffers
|
|
267
|
+
},
|
|
268
|
+
affiliate.id
|
|
269
|
+
)
|
|
270
|
+
) });
|
|
271
|
+
}
|
|
272
|
+
function SignalExperiment({
|
|
273
|
+
experimentId,
|
|
274
|
+
variants,
|
|
275
|
+
fallback,
|
|
276
|
+
trackImpression = true,
|
|
277
|
+
children
|
|
278
|
+
}) {
|
|
279
|
+
const { assignment, variant, isControl } = chunkW4PALSGM_js.useSignalExperiment(experimentId);
|
|
280
|
+
const trackEvent = chunkW4PALSGM_js.useSignalEvent();
|
|
281
|
+
React2.useEffect(() => {
|
|
282
|
+
if (trackImpression && variant) {
|
|
283
|
+
trackEvent({
|
|
284
|
+
event_type: "experiment",
|
|
285
|
+
event_name: "impression",
|
|
286
|
+
event_data: {
|
|
287
|
+
experiment_id: experimentId,
|
|
288
|
+
variant_key: variant
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}, [experimentId, variant, trackImpression, trackEvent]);
|
|
293
|
+
if (children) {
|
|
294
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children({ variant: variant || "control", isControl }) });
|
|
295
|
+
}
|
|
296
|
+
const selectedVariant = variant || "control";
|
|
297
|
+
const content = variants[selectedVariant];
|
|
298
|
+
if (content !== void 0) {
|
|
299
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: content });
|
|
300
|
+
}
|
|
301
|
+
if (fallback) {
|
|
302
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
|
|
303
|
+
}
|
|
304
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: variants.control || null });
|
|
305
|
+
}
|
|
306
|
+
function useExperimentVariant(experimentId) {
|
|
307
|
+
return chunkW4PALSGM_js.useSignalExperiment(experimentId);
|
|
308
|
+
}
|
|
309
|
+
function ExperimentConversion({
|
|
310
|
+
experimentId,
|
|
311
|
+
outcomeType = "click",
|
|
312
|
+
value,
|
|
313
|
+
children
|
|
314
|
+
}) {
|
|
315
|
+
const trackEvent = chunkW4PALSGM_js.useSignalEvent();
|
|
316
|
+
const { variant } = chunkW4PALSGM_js.useSignalExperiment(experimentId);
|
|
317
|
+
const handleInteraction = () => {
|
|
318
|
+
trackEvent({
|
|
319
|
+
event_type: "experiment",
|
|
320
|
+
event_name: "conversion",
|
|
321
|
+
event_data: {
|
|
322
|
+
experiment_id: experimentId,
|
|
323
|
+
variant_key: variant,
|
|
324
|
+
outcome_type: outcomeType,
|
|
325
|
+
value
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
return React2__default.default.cloneElement(children, {
|
|
330
|
+
onClick: (e) => {
|
|
331
|
+
handleInteraction();
|
|
332
|
+
if (children.props.onClick) {
|
|
333
|
+
children.props.onClick(e);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
var styles = {
|
|
339
|
+
container: {
|
|
340
|
+
display: "flex",
|
|
341
|
+
flexDirection: "column",
|
|
342
|
+
height: "100vh",
|
|
343
|
+
maxWidth: "800px",
|
|
344
|
+
margin: "0 auto",
|
|
345
|
+
padding: "1rem",
|
|
346
|
+
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
347
|
+
},
|
|
348
|
+
header: {
|
|
349
|
+
display: "flex",
|
|
350
|
+
alignItems: "center",
|
|
351
|
+
gap: "0.75rem",
|
|
352
|
+
padding: "1rem 0",
|
|
353
|
+
borderBottom: "1px solid #e5e7eb"
|
|
354
|
+
},
|
|
355
|
+
logo: {
|
|
356
|
+
width: "32px",
|
|
357
|
+
height: "32px",
|
|
358
|
+
borderRadius: "8px",
|
|
359
|
+
background: "linear-gradient(135deg, #3b82f6, #8b5cf6)",
|
|
360
|
+
display: "flex",
|
|
361
|
+
alignItems: "center",
|
|
362
|
+
justifyContent: "center",
|
|
363
|
+
color: "white",
|
|
364
|
+
fontWeight: "bold"
|
|
365
|
+
},
|
|
366
|
+
title: {
|
|
367
|
+
fontSize: "1.25rem",
|
|
368
|
+
fontWeight: "600",
|
|
369
|
+
color: "#111827"
|
|
370
|
+
},
|
|
371
|
+
subtitle: {
|
|
372
|
+
fontSize: "0.875rem",
|
|
373
|
+
color: "#6b7280"
|
|
374
|
+
},
|
|
375
|
+
messages: {
|
|
376
|
+
flex: 1,
|
|
377
|
+
overflowY: "auto",
|
|
378
|
+
padding: "1rem 0",
|
|
379
|
+
display: "flex",
|
|
380
|
+
flexDirection: "column",
|
|
381
|
+
gap: "1rem"
|
|
382
|
+
},
|
|
383
|
+
message: {
|
|
384
|
+
display: "flex",
|
|
385
|
+
gap: "0.75rem",
|
|
386
|
+
maxWidth: "85%"
|
|
387
|
+
},
|
|
388
|
+
messageAssistant: {
|
|
389
|
+
alignSelf: "flex-start"
|
|
390
|
+
},
|
|
391
|
+
messageUser: {
|
|
392
|
+
alignSelf: "flex-end",
|
|
393
|
+
flexDirection: "row-reverse"
|
|
394
|
+
},
|
|
395
|
+
avatar: {
|
|
396
|
+
width: "32px",
|
|
397
|
+
height: "32px",
|
|
398
|
+
borderRadius: "50%",
|
|
399
|
+
display: "flex",
|
|
400
|
+
alignItems: "center",
|
|
401
|
+
justifyContent: "center",
|
|
402
|
+
fontSize: "0.875rem",
|
|
403
|
+
flexShrink: 0
|
|
404
|
+
},
|
|
405
|
+
avatarAssistant: {
|
|
406
|
+
background: "linear-gradient(135deg, #3b82f6, #8b5cf6)",
|
|
407
|
+
color: "white"
|
|
408
|
+
},
|
|
409
|
+
avatarUser: {
|
|
410
|
+
background: "#e5e7eb",
|
|
411
|
+
color: "#374151"
|
|
412
|
+
},
|
|
413
|
+
bubble: {
|
|
414
|
+
padding: "0.75rem 1rem",
|
|
415
|
+
borderRadius: "1rem",
|
|
416
|
+
fontSize: "0.9375rem",
|
|
417
|
+
lineHeight: "1.5"
|
|
418
|
+
},
|
|
419
|
+
bubbleAssistant: {
|
|
420
|
+
background: "#f3f4f6",
|
|
421
|
+
color: "#111827",
|
|
422
|
+
borderTopLeftRadius: "4px"
|
|
423
|
+
},
|
|
424
|
+
bubbleUser: {
|
|
425
|
+
background: "#3b82f6",
|
|
426
|
+
color: "white",
|
|
427
|
+
borderTopRightRadius: "4px"
|
|
428
|
+
},
|
|
429
|
+
actions: {
|
|
430
|
+
display: "flex",
|
|
431
|
+
flexWrap: "wrap",
|
|
432
|
+
gap: "0.5rem",
|
|
433
|
+
marginTop: "0.75rem"
|
|
434
|
+
},
|
|
435
|
+
actionButton: {
|
|
436
|
+
padding: "0.5rem 1rem",
|
|
437
|
+
borderRadius: "0.5rem",
|
|
438
|
+
fontSize: "0.875rem",
|
|
439
|
+
fontWeight: "500",
|
|
440
|
+
cursor: "pointer",
|
|
441
|
+
border: "none",
|
|
442
|
+
transition: "all 0.15s"
|
|
443
|
+
},
|
|
444
|
+
actionPrimary: {
|
|
445
|
+
background: "#3b82f6",
|
|
446
|
+
color: "white"
|
|
447
|
+
},
|
|
448
|
+
actionSecondary: {
|
|
449
|
+
background: "#e5e7eb",
|
|
450
|
+
color: "#374151"
|
|
451
|
+
},
|
|
452
|
+
actionOutline: {
|
|
453
|
+
background: "transparent",
|
|
454
|
+
color: "#3b82f6",
|
|
455
|
+
border: "1px solid #3b82f6"
|
|
456
|
+
},
|
|
457
|
+
inputContainer: {
|
|
458
|
+
display: "flex",
|
|
459
|
+
gap: "0.5rem",
|
|
460
|
+
padding: "1rem 0",
|
|
461
|
+
borderTop: "1px solid #e5e7eb"
|
|
462
|
+
},
|
|
463
|
+
input: {
|
|
464
|
+
flex: 1,
|
|
465
|
+
padding: "0.75rem 1rem",
|
|
466
|
+
borderRadius: "0.75rem",
|
|
467
|
+
border: "1px solid #d1d5db",
|
|
468
|
+
fontSize: "0.9375rem",
|
|
469
|
+
outline: "none"
|
|
470
|
+
},
|
|
471
|
+
sendButton: {
|
|
472
|
+
padding: "0.75rem 1.5rem",
|
|
473
|
+
borderRadius: "0.75rem",
|
|
474
|
+
background: "#3b82f6",
|
|
475
|
+
color: "white",
|
|
476
|
+
border: "none",
|
|
477
|
+
fontWeight: "500",
|
|
478
|
+
cursor: "pointer"
|
|
479
|
+
},
|
|
480
|
+
typing: {
|
|
481
|
+
display: "flex",
|
|
482
|
+
gap: "4px",
|
|
483
|
+
padding: "0.75rem 1rem",
|
|
484
|
+
background: "#f3f4f6",
|
|
485
|
+
borderRadius: "1rem",
|
|
486
|
+
width: "fit-content"
|
|
487
|
+
},
|
|
488
|
+
typingDot: {
|
|
489
|
+
width: "8px",
|
|
490
|
+
height: "8px",
|
|
491
|
+
borderRadius: "50%",
|
|
492
|
+
background: "#9ca3af",
|
|
493
|
+
animation: "typing 1.4s infinite"
|
|
494
|
+
},
|
|
495
|
+
moduleCard: {
|
|
496
|
+
display: "flex",
|
|
497
|
+
alignItems: "center",
|
|
498
|
+
gap: "0.75rem",
|
|
499
|
+
padding: "0.75rem",
|
|
500
|
+
background: "white",
|
|
501
|
+
border: "1px solid #e5e7eb",
|
|
502
|
+
borderRadius: "0.5rem",
|
|
503
|
+
cursor: "pointer",
|
|
504
|
+
transition: "all 0.15s"
|
|
505
|
+
},
|
|
506
|
+
moduleCardSelected: {
|
|
507
|
+
borderColor: "#3b82f6",
|
|
508
|
+
background: "#eff6ff"
|
|
509
|
+
},
|
|
510
|
+
moduleIcon: {
|
|
511
|
+
fontSize: "1.5rem"
|
|
512
|
+
},
|
|
513
|
+
moduleInfo: {
|
|
514
|
+
flex: 1
|
|
515
|
+
},
|
|
516
|
+
moduleName: {
|
|
517
|
+
fontWeight: "500",
|
|
518
|
+
color: "#111827"
|
|
519
|
+
},
|
|
520
|
+
moduleDesc: {
|
|
521
|
+
fontSize: "0.75rem",
|
|
522
|
+
color: "#6b7280"
|
|
523
|
+
},
|
|
524
|
+
checkbox: {
|
|
525
|
+
width: "20px",
|
|
526
|
+
height: "20px",
|
|
527
|
+
accentColor: "#3b82f6"
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
var MODULES = [
|
|
531
|
+
{ id: "analytics", name: "Analytics", icon: "\u{1F4CA}", description: "Page views, events, sessions, web vitals", recommended: true },
|
|
532
|
+
{ id: "seo", name: "SEO", icon: "\u{1F50D}", description: "Managed FAQs, meta tags, schema markup", recommended: true },
|
|
533
|
+
{ id: "forms", name: "Forms", icon: "\u{1F4DD}", description: "Sonor-managed forms with submissions", recommended: true },
|
|
534
|
+
{ id: "engage", name: "Engage", icon: "\u{1F4AC}", description: "Live chat, popups, nudges, banners", recommended: false },
|
|
535
|
+
{ id: "commerce", name: "Commerce", icon: "\u{1F6D2}", description: "Products, services, checkout", recommended: false },
|
|
536
|
+
{ id: "signal", name: "Signal AI", icon: "\u{1F916}", description: "Autonomous optimization & A/B testing", recommended: false }
|
|
537
|
+
];
|
|
538
|
+
function SetupAssistant({
|
|
539
|
+
apiUrl = "https://api.uptrademedia.com",
|
|
540
|
+
signalUrl = "https://signal.uptrademedia.com",
|
|
541
|
+
supabaseUrl,
|
|
542
|
+
supabaseKey,
|
|
543
|
+
projectId,
|
|
544
|
+
orgId,
|
|
545
|
+
authToken,
|
|
546
|
+
onComplete,
|
|
547
|
+
welcomeMessage
|
|
548
|
+
}) {
|
|
549
|
+
const [messages, setMessages] = React2.useState([]);
|
|
550
|
+
const [input, setInput] = React2.useState("");
|
|
551
|
+
const [isTyping, setIsTyping] = React2.useState(false);
|
|
552
|
+
const [isExtracting, setIsExtracting] = React2.useState(false);
|
|
553
|
+
const [state, setState] = React2.useState({
|
|
554
|
+
step: "welcome",
|
|
555
|
+
isAuthenticated: !!authToken,
|
|
556
|
+
selectedModules: ["analytics", "seo", "forms"],
|
|
557
|
+
config: {},
|
|
558
|
+
errors: [],
|
|
559
|
+
context: {
|
|
560
|
+
flow: null,
|
|
561
|
+
step: "welcome",
|
|
562
|
+
project_id: projectId,
|
|
563
|
+
org_id: orgId
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
const messagesEndRef = React2.useRef(null);
|
|
567
|
+
const inputRef = React2.useRef(null);
|
|
568
|
+
const streamingMessageRef = React2.useRef(null);
|
|
569
|
+
const sendToSignalStreaming = React2.useCallback(async (message, context, onToken, onComplete2) => {
|
|
570
|
+
try {
|
|
571
|
+
const response = await fetch(`${signalUrl}/api/skills/setup/chat/stream`, {
|
|
572
|
+
method: "POST",
|
|
573
|
+
headers: {
|
|
574
|
+
"Content-Type": "application/json",
|
|
575
|
+
...authToken ? { Authorization: `Bearer ${authToken}` } : {}
|
|
576
|
+
},
|
|
577
|
+
body: JSON.stringify({
|
|
578
|
+
message,
|
|
579
|
+
context,
|
|
580
|
+
project_id: projectId,
|
|
581
|
+
org_id: orgId
|
|
582
|
+
})
|
|
583
|
+
});
|
|
584
|
+
if (!response.ok) {
|
|
585
|
+
throw new Error("Signal API error");
|
|
586
|
+
}
|
|
587
|
+
const reader = response.body?.getReader();
|
|
588
|
+
if (!reader) throw new Error("No response body");
|
|
589
|
+
const decoder = new TextDecoder();
|
|
590
|
+
let buffer = "";
|
|
591
|
+
let actions = [];
|
|
592
|
+
let updatedContext = {};
|
|
593
|
+
while (true) {
|
|
594
|
+
const { done, value } = await reader.read();
|
|
595
|
+
if (done) break;
|
|
596
|
+
buffer += decoder.decode(value, { stream: true });
|
|
597
|
+
const lines = buffer.split("\n");
|
|
598
|
+
buffer = lines.pop() || "";
|
|
599
|
+
for (const line of lines) {
|
|
600
|
+
if (line.startsWith("data: ")) {
|
|
601
|
+
const data = line.slice(6);
|
|
602
|
+
if (data === "[DONE]") continue;
|
|
603
|
+
try {
|
|
604
|
+
const event = JSON.parse(data);
|
|
605
|
+
if (event.type === "token") {
|
|
606
|
+
onToken(event.content);
|
|
607
|
+
} else if (event.type === "actions") {
|
|
608
|
+
actions = event.actions;
|
|
609
|
+
} else if (event.type === "context") {
|
|
610
|
+
updatedContext = event.context;
|
|
611
|
+
}
|
|
612
|
+
} catch {
|
|
613
|
+
onToken(data);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
onComplete2({ actions, updated_context: updatedContext });
|
|
619
|
+
} catch (error) {
|
|
620
|
+
console.error("Signal streaming error:", error);
|
|
621
|
+
const result = await sendToSignal(message, context);
|
|
622
|
+
onToken(result.response);
|
|
623
|
+
onComplete2({ actions: result.actions, updated_context: result.updated_context });
|
|
624
|
+
}
|
|
625
|
+
}, [signalUrl, authToken, projectId, orgId]);
|
|
626
|
+
const sendToSignal = React2.useCallback(async (message, context) => {
|
|
627
|
+
try {
|
|
628
|
+
const response = await fetch(`${signalUrl}/api/skills/setup/chat`, {
|
|
629
|
+
method: "POST",
|
|
630
|
+
headers: {
|
|
631
|
+
"Content-Type": "application/json",
|
|
632
|
+
...authToken ? { Authorization: `Bearer ${authToken}` } : {}
|
|
633
|
+
},
|
|
634
|
+
body: JSON.stringify({
|
|
635
|
+
message,
|
|
636
|
+
context,
|
|
637
|
+
project_id: projectId,
|
|
638
|
+
org_id: orgId
|
|
639
|
+
})
|
|
640
|
+
});
|
|
641
|
+
if (!response.ok) {
|
|
642
|
+
throw new Error("Signal API error");
|
|
643
|
+
}
|
|
644
|
+
return await response.json();
|
|
645
|
+
} catch (error) {
|
|
646
|
+
console.error("Signal API error:", error);
|
|
647
|
+
return {
|
|
648
|
+
response: "I had trouble connecting to Signal. Let me help you locally.",
|
|
649
|
+
actions: [
|
|
650
|
+
{ id: "1", label: "Continue", action: "continue_local", variant: "primary" }
|
|
651
|
+
]
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
}, [signalUrl, authToken, projectId, orgId]);
|
|
655
|
+
const extractBrandFromDomain = React2.useCallback(async (domain) => {
|
|
656
|
+
setIsExtracting(true);
|
|
657
|
+
try {
|
|
658
|
+
const response = await fetch(`${apiUrl}/site-scrape/brand-only`, {
|
|
659
|
+
method: "POST",
|
|
660
|
+
headers: {
|
|
661
|
+
"Content-Type": "application/json",
|
|
662
|
+
...authToken ? { Authorization: `Bearer ${authToken}` } : {}
|
|
663
|
+
},
|
|
664
|
+
body: JSON.stringify({ domain })
|
|
665
|
+
});
|
|
666
|
+
if (!response.ok) {
|
|
667
|
+
throw new Error("Brand extraction failed");
|
|
668
|
+
}
|
|
669
|
+
const data = await response.json();
|
|
670
|
+
return {
|
|
671
|
+
business_name: data.business_name,
|
|
672
|
+
tagline: data.tagline,
|
|
673
|
+
primary_color: data.primary_color,
|
|
674
|
+
secondary_color: data.secondary_color,
|
|
675
|
+
logo_url: data.logo_url,
|
|
676
|
+
phone_numbers: data.phone_numbers,
|
|
677
|
+
email_addresses: data.email_addresses,
|
|
678
|
+
social_profiles: data.social_profiles
|
|
679
|
+
};
|
|
680
|
+
} catch (error) {
|
|
681
|
+
console.error("Brand extraction error:", error);
|
|
682
|
+
return null;
|
|
683
|
+
} finally {
|
|
684
|
+
setIsExtracting(false);
|
|
685
|
+
}
|
|
686
|
+
}, [apiUrl, authToken]);
|
|
687
|
+
const addMessage = React2.useCallback((message) => {
|
|
688
|
+
const newMessage = {
|
|
689
|
+
...message,
|
|
690
|
+
id: crypto.randomUUID(),
|
|
691
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
692
|
+
};
|
|
693
|
+
setMessages((prev) => [...prev, newMessage]);
|
|
694
|
+
return newMessage;
|
|
695
|
+
}, []);
|
|
696
|
+
React2.useCallback((id, update) => {
|
|
697
|
+
setMessages((prev) => prev.map(
|
|
698
|
+
(m) => m.id === id ? { ...m, ...update } : m
|
|
699
|
+
));
|
|
700
|
+
}, []);
|
|
701
|
+
const addStreamingMessage = React2.useCallback(() => {
|
|
702
|
+
const id = crypto.randomUUID();
|
|
703
|
+
const newMessage = {
|
|
704
|
+
id,
|
|
705
|
+
role: "assistant",
|
|
706
|
+
content: "",
|
|
707
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
708
|
+
isStreaming: true
|
|
709
|
+
};
|
|
710
|
+
setMessages((prev) => [...prev, newMessage]);
|
|
711
|
+
streamingMessageRef.current = id;
|
|
712
|
+
return id;
|
|
713
|
+
}, []);
|
|
714
|
+
const appendToStreamingMessage = React2.useCallback((token) => {
|
|
715
|
+
const id = streamingMessageRef.current;
|
|
716
|
+
if (!id) return;
|
|
717
|
+
setMessages((prev) => prev.map(
|
|
718
|
+
(m) => m.id === id ? { ...m, content: m.content + token } : m
|
|
719
|
+
));
|
|
720
|
+
}, []);
|
|
721
|
+
const finalizeStreamingMessage = React2.useCallback((actions) => {
|
|
722
|
+
const id = streamingMessageRef.current;
|
|
723
|
+
if (!id) return;
|
|
724
|
+
setMessages((prev) => prev.map(
|
|
725
|
+
(m) => m.id === id ? { ...m, isStreaming: false, actions } : m
|
|
726
|
+
));
|
|
727
|
+
streamingMessageRef.current = null;
|
|
728
|
+
}, []);
|
|
729
|
+
const addAssistantMessage = React2.useCallback((content, actions, component) => {
|
|
730
|
+
setIsTyping(true);
|
|
731
|
+
setTimeout(() => {
|
|
732
|
+
setIsTyping(false);
|
|
733
|
+
addMessage({ role: "assistant", content, actions, component });
|
|
734
|
+
}, 500 + Math.random() * 500);
|
|
735
|
+
}, [addMessage]);
|
|
736
|
+
const scrollToBottom = React2.useCallback(() => {
|
|
737
|
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
738
|
+
}, []);
|
|
739
|
+
React2.useEffect(() => {
|
|
740
|
+
scrollToBottom();
|
|
741
|
+
}, [messages, isTyping, scrollToBottom]);
|
|
742
|
+
React2.useEffect(() => {
|
|
743
|
+
const welcome = welcomeMessage || `Hey! \u{1F44B} I'm Signal, your AI setup assistant.
|
|
744
|
+
|
|
745
|
+
I'll help you integrate Uptrade Site-Kit into your project. What are we working with today?`;
|
|
746
|
+
setTimeout(() => {
|
|
747
|
+
addAssistantMessage(welcome, [
|
|
748
|
+
{ id: "1", label: "\u{1F195} New Site", action: "set_flow_new", variant: "primary" },
|
|
749
|
+
{ id: "2", label: "\u{1F4C1} Existing Project", action: "set_flow_existing", variant: "secondary" },
|
|
750
|
+
{ id: "3", label: "\u{1F504} Rebuild from Live Site", action: "set_flow_rebuild", variant: "outline" }
|
|
751
|
+
]);
|
|
752
|
+
}, 500);
|
|
753
|
+
}, []);
|
|
754
|
+
const handleAction = React2.useCallback(async (action, data) => {
|
|
755
|
+
switch (action) {
|
|
756
|
+
case "start":
|
|
757
|
+
addMessage({ role: "user", content: "Let's do it!" });
|
|
758
|
+
setState((prev) => ({ ...prev, step: "auth" }));
|
|
759
|
+
addAssistantMessage(
|
|
760
|
+
`Great! First, let's connect to your Sonor account.
|
|
761
|
+
|
|
762
|
+
You can sign in with your existing Sonor credentials:`,
|
|
763
|
+
[
|
|
764
|
+
{ id: "1", label: "Sign in with Email", action: "auth_email", variant: "primary" },
|
|
765
|
+
{ id: "2", label: "Sign in with Google", action: "auth_google", variant: "secondary" },
|
|
766
|
+
{ id: "3", label: "I don't have an account", action: "auth_signup", variant: "outline" }
|
|
767
|
+
]
|
|
768
|
+
);
|
|
769
|
+
break;
|
|
770
|
+
case "explain":
|
|
771
|
+
addMessage({ role: "user", content: "Tell me more first" });
|
|
772
|
+
addAssistantMessage(
|
|
773
|
+
`Uptrade Site-Kit is a lightweight package that connects your site to Sonor.
|
|
774
|
+
|
|
775
|
+
Here's what you can enable:
|
|
776
|
+
|
|
777
|
+
\u{1F4CA} **Analytics** - Track page views, events, and Core Web Vitals
|
|
778
|
+
\u{1F50D} **SEO** - Managed meta tags, FAQs, and schema markup
|
|
779
|
+
\u{1F4DD} **Forms** - Sonor-managed forms with spam protection
|
|
780
|
+
\u{1F4AC} **Engage** - Live chat, popups, and nudges
|
|
781
|
+
\u{1F6D2} **Commerce** - Products, services, and checkout
|
|
782
|
+
\u{1F916} **Signal AI** - Autonomous optimization and A/B testing
|
|
783
|
+
|
|
784
|
+
You only pay for what you use, and everything is managed from your Sonor dashboard.`,
|
|
785
|
+
[
|
|
786
|
+
{ id: "1", label: "Sounds good, let's set it up", action: "start", variant: "primary" }
|
|
787
|
+
]
|
|
788
|
+
);
|
|
789
|
+
break;
|
|
790
|
+
case "auth_email":
|
|
791
|
+
addMessage({ role: "user", content: "Sign in with Email" });
|
|
792
|
+
addAssistantMessage(
|
|
793
|
+
`What's your Sonor email address?`
|
|
794
|
+
);
|
|
795
|
+
setState((prev) => ({ ...prev, step: "auth" }));
|
|
796
|
+
setTimeout(() => inputRef.current?.focus(), 600);
|
|
797
|
+
break;
|
|
798
|
+
case "auth_google":
|
|
799
|
+
addMessage({ role: "user", content: "Sign in with Google" });
|
|
800
|
+
addAssistantMessage(
|
|
801
|
+
`Opening Google sign-in... (In a real implementation, this would trigger OAuth)`
|
|
802
|
+
);
|
|
803
|
+
setTimeout(() => {
|
|
804
|
+
setState((prev) => ({
|
|
805
|
+
...prev,
|
|
806
|
+
step: "project",
|
|
807
|
+
isAuthenticated: true,
|
|
808
|
+
userEmail: "user@example.com"
|
|
809
|
+
}));
|
|
810
|
+
handleAuthSuccess("user@example.com");
|
|
811
|
+
}, 1500);
|
|
812
|
+
break;
|
|
813
|
+
case "select_project":
|
|
814
|
+
addMessage({ role: "user", content: `Selected: ${data?.name}` });
|
|
815
|
+
setState((prev) => ({
|
|
816
|
+
...prev,
|
|
817
|
+
step: "modules",
|
|
818
|
+
selectedProject: data
|
|
819
|
+
}));
|
|
820
|
+
showModuleSelection();
|
|
821
|
+
break;
|
|
822
|
+
case "confirm_modules":
|
|
823
|
+
addMessage({ role: "user", content: `Selected ${state.selectedModules.length} modules` });
|
|
824
|
+
setState((prev) => ({ ...prev, step: "config" }));
|
|
825
|
+
showConfigGeneration();
|
|
826
|
+
break;
|
|
827
|
+
case "copy_code":
|
|
828
|
+
addMessage({ role: "user", content: "Copy integration code" });
|
|
829
|
+
addAssistantMessage(
|
|
830
|
+
`\u2705 Code copied to clipboard!
|
|
831
|
+
|
|
832
|
+
Paste this in your root layout file (e.g., \`app/layout.tsx\` or \`pages/_app.tsx\`).
|
|
833
|
+
|
|
834
|
+
Want me to help you verify the integration?`,
|
|
835
|
+
[
|
|
836
|
+
{ id: "1", label: "Yes, verify my setup", action: "verify", variant: "primary" },
|
|
837
|
+
{ id: "2", label: "I'm all set, thanks!", action: "complete", variant: "outline" }
|
|
838
|
+
]
|
|
839
|
+
);
|
|
840
|
+
break;
|
|
841
|
+
case "verify":
|
|
842
|
+
addMessage({ role: "user", content: "Verify my setup" });
|
|
843
|
+
setState((prev) => ({ ...prev, step: "verify" }));
|
|
844
|
+
addAssistantMessage(
|
|
845
|
+
`To verify your setup, start your dev server and visit any page.
|
|
846
|
+
|
|
847
|
+
I'll check for:
|
|
848
|
+
\u2022 \u2713 SiteKitProvider is loading
|
|
849
|
+
\u2022 \u2713 API key is valid
|
|
850
|
+
\u2022 \u2713 Analytics events are sending
|
|
851
|
+
\u2022 \u2713 Modules are initializing
|
|
852
|
+
|
|
853
|
+
Run \`npm run dev\` and let me know when you're ready:`,
|
|
854
|
+
[
|
|
855
|
+
{ id: "1", label: "My dev server is running", action: "check_connection", variant: "primary" }
|
|
856
|
+
]
|
|
857
|
+
);
|
|
858
|
+
break;
|
|
859
|
+
case "check_connection":
|
|
860
|
+
addMessage({ role: "user", content: "My dev server is running" });
|
|
861
|
+
setIsTyping(true);
|
|
862
|
+
setTimeout(() => {
|
|
863
|
+
setIsTyping(false);
|
|
864
|
+
addAssistantMessage(
|
|
865
|
+
`\u{1F389} **Everything looks great!**
|
|
866
|
+
|
|
867
|
+
I detected your site at \`localhost:3000\` and verified:
|
|
868
|
+
|
|
869
|
+
\u2705 SiteKitProvider initialized
|
|
870
|
+
\u2705 API key authenticated
|
|
871
|
+
\u2705 Analytics tracking active
|
|
872
|
+
\u2705 SEO components ready
|
|
873
|
+
|
|
874
|
+
You're all set! Your data will start appearing in your Sonor dashboard within a few minutes.`,
|
|
875
|
+
[
|
|
876
|
+
{ id: "1", label: "Open Sonor Dashboard", action: "open_dashboard", variant: "primary" },
|
|
877
|
+
{ id: "2", label: "Enable Signal AI", action: "enable_signal", variant: "secondary" }
|
|
878
|
+
]
|
|
879
|
+
);
|
|
880
|
+
setState((prev) => ({ ...prev, step: "complete" }));
|
|
881
|
+
}, 2e3);
|
|
882
|
+
break;
|
|
883
|
+
case "complete":
|
|
884
|
+
addMessage({ role: "user", content: "I'm all set, thanks!" });
|
|
885
|
+
addAssistantMessage(
|
|
886
|
+
`Awesome! \u{1F680}
|
|
887
|
+
|
|
888
|
+
Your site-kit integration is ready. Here's what happens next:
|
|
889
|
+
|
|
890
|
+
\u2022 Analytics data will appear in Sonor within ~5 minutes
|
|
891
|
+
\u2022 You can manage SEO, forms, and engage from the dashboard
|
|
892
|
+
\u2022 If you enabled Signal, it'll start learning from your traffic
|
|
893
|
+
|
|
894
|
+
Need help anytime? Just come back to \`/_uptrade/setup\` or ping us in Sonor.
|
|
895
|
+
|
|
896
|
+
Happy building! \u{1F3A8}`
|
|
897
|
+
);
|
|
898
|
+
onComplete?.(state);
|
|
899
|
+
break;
|
|
900
|
+
case "enable_signal":
|
|
901
|
+
addMessage({ role: "user", content: "Enable Signal AI" });
|
|
902
|
+
addAssistantMessage(
|
|
903
|
+
`Great choice! \u{1F916}
|
|
904
|
+
|
|
905
|
+
Signal AI will:
|
|
906
|
+
\u2022 Monitor your site for SEO issues
|
|
907
|
+
\u2022 Run A/B tests on CTAs and content
|
|
908
|
+
\u2022 Optimize popups and engagement timing
|
|
909
|
+
\u2022 Learn from user behavior to improve conversions
|
|
910
|
+
|
|
911
|
+
To enable Signal, add \`signal={{ enabled: true }}\` to your SiteKitProvider:
|
|
912
|
+
|
|
913
|
+
\`\`\`tsx
|
|
914
|
+
<SiteKitProvider
|
|
915
|
+
apiKey={process.env.NEXT_PUBLIC_UPTRADE_API_KEY!}
|
|
916
|
+
analytics={{ enabled: true }}
|
|
917
|
+
signal={{ enabled: true }} // Add this
|
|
918
|
+
>
|
|
919
|
+
\`\`\`
|
|
920
|
+
|
|
921
|
+
Signal requires the Business plan. Want me to check your plan?`,
|
|
922
|
+
[
|
|
923
|
+
{ id: "1", label: "Check my plan", action: "check_plan", variant: "primary" },
|
|
924
|
+
{ id: "2", label: "I'll do this later", action: "complete", variant: "outline" }
|
|
925
|
+
]
|
|
926
|
+
);
|
|
927
|
+
break;
|
|
928
|
+
case "confirm_brand":
|
|
929
|
+
addMessage({ role: "user", content: "Brand info confirmed" });
|
|
930
|
+
setState((prev) => ({ ...prev, step: "modules" }));
|
|
931
|
+
showModuleSelectionWithRecommendations();
|
|
932
|
+
break;
|
|
933
|
+
case "edit_brand":
|
|
934
|
+
addMessage({ role: "user", content: "Edit brand info" });
|
|
935
|
+
addAssistantMessage(
|
|
936
|
+
`No problem! Let me know what to change:
|
|
937
|
+
|
|
938
|
+
\u2022 Business name
|
|
939
|
+
\u2022 Primary color (hex like #3b82f6)
|
|
940
|
+
\u2022 Tagline
|
|
941
|
+
|
|
942
|
+
Just type what you'd like to update.`
|
|
943
|
+
);
|
|
944
|
+
break;
|
|
945
|
+
case "manual_brand":
|
|
946
|
+
addMessage({ role: "user", content: "Enter brand manually" });
|
|
947
|
+
addAssistantMessage(
|
|
948
|
+
`Sure! What's your business name?`
|
|
949
|
+
);
|
|
950
|
+
setState((prev) => ({
|
|
951
|
+
...prev,
|
|
952
|
+
context: { ...prev.context, step: "brand_manual" }
|
|
953
|
+
}));
|
|
954
|
+
break;
|
|
955
|
+
case "skip_brand":
|
|
956
|
+
addMessage({ role: "user", content: "Skip brand for now" });
|
|
957
|
+
setState((prev) => ({ ...prev, step: "modules" }));
|
|
958
|
+
showModuleSelection();
|
|
959
|
+
break;
|
|
960
|
+
case "extract_brand":
|
|
961
|
+
addMessage({ role: "user", content: "Extract from website" });
|
|
962
|
+
addAssistantMessage(
|
|
963
|
+
`What's the website URL? I'll extract the brand colors, name, and logo.`
|
|
964
|
+
);
|
|
965
|
+
break;
|
|
966
|
+
case "set_flow_new":
|
|
967
|
+
addMessage({ role: "user", content: "New Site" });
|
|
968
|
+
setState((prev) => ({
|
|
969
|
+
...prev,
|
|
970
|
+
context: { ...prev.context, flow: "new", step: "brand" }
|
|
971
|
+
}));
|
|
972
|
+
addAssistantMessage(
|
|
973
|
+
`Great! For a new site, I'll help you:
|
|
974
|
+
|
|
975
|
+
1. Set up your brand (colors, name)
|
|
976
|
+
2. Choose which modules to enable
|
|
977
|
+
3. Generate integration code
|
|
978
|
+
|
|
979
|
+
Do you have an existing website I can extract brand info from? Or would you prefer to enter it manually?`,
|
|
980
|
+
[
|
|
981
|
+
{ id: "1", label: "Extract from website", action: "extract_brand", variant: "primary" },
|
|
982
|
+
{ id: "2", label: "Enter manually", action: "manual_brand", variant: "outline" },
|
|
983
|
+
{ id: "3", label: "Skip for now", action: "skip_brand", variant: "outline" }
|
|
984
|
+
]
|
|
985
|
+
);
|
|
986
|
+
break;
|
|
987
|
+
case "set_flow_existing":
|
|
988
|
+
addMessage({ role: "user", content: "Existing Project" });
|
|
989
|
+
setState((prev) => ({
|
|
990
|
+
...prev,
|
|
991
|
+
context: { ...prev.context, flow: "existing", step: "scan" }
|
|
992
|
+
}));
|
|
993
|
+
addAssistantMessage(
|
|
994
|
+
`For an existing project, I can scan your codebase to find:
|
|
995
|
+
|
|
996
|
+
\u2022 Forms to migrate (contact forms, newsletter signups)
|
|
997
|
+
\u2022 Chat widgets to replace (Intercom, Crisp, etc.)
|
|
998
|
+
\u2022 Metadata patterns to enhance
|
|
999
|
+
\u2022 Sitemap configuration
|
|
1000
|
+
|
|
1001
|
+
Run this in your project root:
|
|
1002
|
+
|
|
1003
|
+
\`\`\`bash
|
|
1004
|
+
npx @sonordev/site-kit scan
|
|
1005
|
+
\`\`\`
|
|
1006
|
+
|
|
1007
|
+
Then paste the output here, or tell me about your project.`,
|
|
1008
|
+
[
|
|
1009
|
+
{ id: "1", label: "I ran the scan", action: "show_scan_results", variant: "primary" },
|
|
1010
|
+
{ id: "2", label: "Skip scan", action: "skip_scan", variant: "outline" }
|
|
1011
|
+
]
|
|
1012
|
+
);
|
|
1013
|
+
break;
|
|
1014
|
+
case "set_flow_rebuild":
|
|
1015
|
+
addMessage({ role: "user", content: "Rebuild from Live Site" });
|
|
1016
|
+
setState((prev) => ({
|
|
1017
|
+
...prev,
|
|
1018
|
+
context: { ...prev.context, flow: "rebuild", step: "scrape" }
|
|
1019
|
+
}));
|
|
1020
|
+
addAssistantMessage(
|
|
1021
|
+
`I'll help you rebuild with site-kit. Enter the live site URL and I'll:
|
|
1022
|
+
|
|
1023
|
+
\u2022 Extract brand colors and business info
|
|
1024
|
+
\u2022 Import FAQs with schema markup
|
|
1025
|
+
\u2022 Suggest redirect mappings
|
|
1026
|
+
\u2022 Generate copilot-instructions.md
|
|
1027
|
+
|
|
1028
|
+
What's the website URL?`
|
|
1029
|
+
);
|
|
1030
|
+
break;
|
|
1031
|
+
case "show_scan_results":
|
|
1032
|
+
addMessage({ role: "user", content: "I ran the scan" });
|
|
1033
|
+
addAssistantMessage(
|
|
1034
|
+
`Great! Paste the scan output here, or describe what you found.
|
|
1035
|
+
|
|
1036
|
+
I'll analyze the results and recommend a migration plan.`
|
|
1037
|
+
);
|
|
1038
|
+
break;
|
|
1039
|
+
case "skip_scan":
|
|
1040
|
+
addMessage({ role: "user", content: "Skip scan" });
|
|
1041
|
+
setState((prev) => ({ ...prev, step: "modules" }));
|
|
1042
|
+
showModuleSelection();
|
|
1043
|
+
break;
|
|
1044
|
+
case "generate_redirects":
|
|
1045
|
+
addMessage({ role: "user", content: "Generate redirects" });
|
|
1046
|
+
if (state.context.scrape_results?.routes) {
|
|
1047
|
+
addStreamingMessage();
|
|
1048
|
+
await sendToSignalStreaming(
|
|
1049
|
+
`Generate SEO-optimized redirects for these routes: ${JSON.stringify(state.context.scrape_results.routes)}`,
|
|
1050
|
+
state.context,
|
|
1051
|
+
(token) => appendToStreamingMessage(token),
|
|
1052
|
+
(result) => finalizeStreamingMessage(result.actions)
|
|
1053
|
+
);
|
|
1054
|
+
} else {
|
|
1055
|
+
addAssistantMessage(
|
|
1056
|
+
`I need a list of routes to generate redirects. Would you like to:
|
|
1057
|
+
|
|
1058
|
+
1. Scrape a website for routes
|
|
1059
|
+
2. Paste a list of URLs
|
|
1060
|
+
|
|
1061
|
+
What's easier?`,
|
|
1062
|
+
[
|
|
1063
|
+
{ id: "1", label: "Scrape website", action: "set_flow_rebuild", variant: "primary" },
|
|
1064
|
+
{ id: "2", label: "Paste URLs", action: "paste_urls", variant: "outline" }
|
|
1065
|
+
]
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
break;
|
|
1069
|
+
case "generate_copilot_instructions":
|
|
1070
|
+
addMessage({ role: "user", content: "Generate Copilot instructions" });
|
|
1071
|
+
addStreamingMessage();
|
|
1072
|
+
await sendToSignalStreaming(
|
|
1073
|
+
`Generate copilot-instructions.md for project with modules: ${state.selectedModules.join(", ")} and brand: ${state.context.brand?.business_name || "Unknown"}`,
|
|
1074
|
+
state.context,
|
|
1075
|
+
(token) => appendToStreamingMessage(token),
|
|
1076
|
+
(result) => {
|
|
1077
|
+
finalizeStreamingMessage([
|
|
1078
|
+
{ id: "1", label: "\u{1F4CB} Copy to clipboard", action: "copy_copilot_instructions", variant: "primary" },
|
|
1079
|
+
{ id: "2", label: "Continue", action: "complete", variant: "outline" }
|
|
1080
|
+
]);
|
|
1081
|
+
}
|
|
1082
|
+
);
|
|
1083
|
+
break;
|
|
1084
|
+
case "verify_now":
|
|
1085
|
+
addMessage({ role: "user", content: "Verify integration" });
|
|
1086
|
+
verifyIntegration();
|
|
1087
|
+
break;
|
|
1088
|
+
}
|
|
1089
|
+
}, [addMessage, addAssistantMessage, addStreamingMessage, appendToStreamingMessage, finalizeStreamingMessage, sendToSignalStreaming, state, onComplete]);
|
|
1090
|
+
const handleAuthSuccess = React2.useCallback((email) => {
|
|
1091
|
+
addAssistantMessage(
|
|
1092
|
+
`Welcome back, ${email.split("@")[0]}! \u{1F44B}
|
|
1093
|
+
|
|
1094
|
+
I found these projects in your account. Which one are we setting up?`,
|
|
1095
|
+
[
|
|
1096
|
+
{ id: "1", label: "MyCompany.com", action: "select_project", variant: "secondary", data: { id: "1", name: "MyCompany.com", domain: "mycompany.com" } },
|
|
1097
|
+
{ id: "2", label: "Blog Project", action: "select_project", variant: "secondary", data: { id: "2", name: "Blog Project", domain: "blog.mycompany.com" } },
|
|
1098
|
+
{ id: "3", label: "+ Create new project", action: "create_project", variant: "outline" }
|
|
1099
|
+
]
|
|
1100
|
+
);
|
|
1101
|
+
}, [addAssistantMessage]);
|
|
1102
|
+
const verifyIntegration = React2.useCallback(async () => {
|
|
1103
|
+
setState((prev) => ({ ...prev, step: "verify" }));
|
|
1104
|
+
setIsTyping(true);
|
|
1105
|
+
try {
|
|
1106
|
+
const response = await fetch(`${signalUrl}/api/skills/setup/verify`, {
|
|
1107
|
+
method: "POST",
|
|
1108
|
+
headers: {
|
|
1109
|
+
"Content-Type": "application/json",
|
|
1110
|
+
...authToken ? { Authorization: `Bearer ${authToken}` } : {}
|
|
1111
|
+
},
|
|
1112
|
+
body: JSON.stringify({
|
|
1113
|
+
project_id: projectId || state.context.project_id,
|
|
1114
|
+
dev_url: "http://localhost:3000"
|
|
1115
|
+
})
|
|
1116
|
+
});
|
|
1117
|
+
setIsTyping(false);
|
|
1118
|
+
if (!response.ok) {
|
|
1119
|
+
throw new Error("Verification failed");
|
|
1120
|
+
}
|
|
1121
|
+
const result = await response.json();
|
|
1122
|
+
if (result.overall_status === "success") {
|
|
1123
|
+
const checkList = result.checks.map(
|
|
1124
|
+
(c) => `${c.passed ? "\u2705" : "\u274C"} ${c.check.replace(/_/g, " ")}`
|
|
1125
|
+
).join("\n");
|
|
1126
|
+
addAssistantMessage(
|
|
1127
|
+
`\u{1F389} **Integration Verified!**
|
|
1128
|
+
|
|
1129
|
+
${checkList}
|
|
1130
|
+
|
|
1131
|
+
Your site-kit integration is working perfectly. Data will start appearing in Sonor shortly.`,
|
|
1132
|
+
[
|
|
1133
|
+
{ id: "1", label: "Open Sonor Dashboard", action: "open_dashboard", variant: "primary" },
|
|
1134
|
+
{ id: "2", label: "Generate Copilot Instructions", action: "generate_copilot_instructions", variant: "secondary" }
|
|
1135
|
+
]
|
|
1136
|
+
);
|
|
1137
|
+
setState((prev) => ({ ...prev, step: "complete" }));
|
|
1138
|
+
} else {
|
|
1139
|
+
const issues = result.issues?.join("\n\u2022 ") || "Unknown issue";
|
|
1140
|
+
addAssistantMessage(
|
|
1141
|
+
`\u26A0\uFE0F **Verification Found Issues**
|
|
1142
|
+
|
|
1143
|
+
\u2022 ${issues}
|
|
1144
|
+
|
|
1145
|
+
Would you like help troubleshooting?`,
|
|
1146
|
+
[
|
|
1147
|
+
{ id: "1", label: "Help me fix this", action: "troubleshoot", variant: "primary" },
|
|
1148
|
+
{ id: "2", label: "Skip for now", action: "complete", variant: "outline" }
|
|
1149
|
+
]
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
} catch (error) {
|
|
1153
|
+
setIsTyping(false);
|
|
1154
|
+
addAssistantMessage(
|
|
1155
|
+
`I couldn't verify the integration automatically. Make sure your dev server is running.
|
|
1156
|
+
|
|
1157
|
+
You can manually verify by:
|
|
1158
|
+
1. Opening your site in the browser
|
|
1159
|
+
2. Checking the Network tab for requests to api.uptrademedia.com
|
|
1160
|
+
3. Looking for analytics events in your Sonor dashboard`,
|
|
1161
|
+
[
|
|
1162
|
+
{ id: "1", label: "Try again", action: "verify_now", variant: "primary" },
|
|
1163
|
+
{ id: "2", label: "Continue anyway", action: "complete", variant: "outline" }
|
|
1164
|
+
]
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
}, [signalUrl, authToken, projectId, state.context.project_id, addAssistantMessage]);
|
|
1168
|
+
const showModuleSelectionWithRecommendations = React2.useCallback(async () => {
|
|
1169
|
+
const { brand, business_type, scan_results } = state.context;
|
|
1170
|
+
if (brand || business_type) {
|
|
1171
|
+
try {
|
|
1172
|
+
const result = await sendToSignal(
|
|
1173
|
+
`Recommend modules for: ${brand?.business_name || "Unknown"}, type: ${business_type || "general"}`,
|
|
1174
|
+
{ ...state.context, step: "recommend_modules" }
|
|
1175
|
+
);
|
|
1176
|
+
addAssistantMessage(
|
|
1177
|
+
result.response,
|
|
1178
|
+
void 0,
|
|
1179
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1180
|
+
ModuleSelector,
|
|
1181
|
+
{
|
|
1182
|
+
modules: MODULES,
|
|
1183
|
+
selected: state.selectedModules,
|
|
1184
|
+
onChange: (modules) => setState((prev) => ({ ...prev, selectedModules: modules })),
|
|
1185
|
+
onConfirm: () => handleAction("confirm_modules")
|
|
1186
|
+
}
|
|
1187
|
+
)
|
|
1188
|
+
);
|
|
1189
|
+
return;
|
|
1190
|
+
} catch (error) {
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
showModuleSelection();
|
|
1194
|
+
}, [state.context, state.selectedModules, sendToSignal, handleAction]);
|
|
1195
|
+
const showModuleSelection = React2.useCallback(() => {
|
|
1196
|
+
addAssistantMessage(
|
|
1197
|
+
`Perfect! Now let's choose which features to enable.
|
|
1198
|
+
|
|
1199
|
+
I've pre-selected the essentials, but you can customize:`,
|
|
1200
|
+
void 0,
|
|
1201
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1202
|
+
ModuleSelector,
|
|
1203
|
+
{
|
|
1204
|
+
modules: MODULES,
|
|
1205
|
+
selected: state.selectedModules,
|
|
1206
|
+
onChange: (modules) => setState((prev) => ({ ...prev, selectedModules: modules })),
|
|
1207
|
+
onConfirm: () => handleAction("confirm_modules")
|
|
1208
|
+
}
|
|
1209
|
+
)
|
|
1210
|
+
);
|
|
1211
|
+
}, [addAssistantMessage, state.selectedModules, handleAction]);
|
|
1212
|
+
const showConfigGeneration = React2.useCallback(() => {
|
|
1213
|
+
const code = generateIntegrationCode(state);
|
|
1214
|
+
addAssistantMessage(
|
|
1215
|
+
`Here's your integration code! \u{1F389}
|
|
1216
|
+
|
|
1217
|
+
Add this to your root layout:`,
|
|
1218
|
+
[
|
|
1219
|
+
{ id: "1", label: "\u{1F4CB} Copy Code", action: "copy_code", variant: "primary" }
|
|
1220
|
+
],
|
|
1221
|
+
/* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { code })
|
|
1222
|
+
);
|
|
1223
|
+
}, [addAssistantMessage, state]);
|
|
1224
|
+
const handleSubmit = React2.useCallback(async (e) => {
|
|
1225
|
+
e.preventDefault();
|
|
1226
|
+
if (!input.trim()) return;
|
|
1227
|
+
const userInput = input.trim();
|
|
1228
|
+
setInput("");
|
|
1229
|
+
addMessage({ role: "user", content: userInput });
|
|
1230
|
+
if (state.step === "auth" && userInput.includes("@")) {
|
|
1231
|
+
setState((prev) => ({
|
|
1232
|
+
...prev,
|
|
1233
|
+
isAuthenticated: true,
|
|
1234
|
+
userEmail: userInput,
|
|
1235
|
+
step: "project"
|
|
1236
|
+
}));
|
|
1237
|
+
addAssistantMessage(
|
|
1238
|
+
`Sending magic link to ${userInput}...
|
|
1239
|
+
|
|
1240
|
+
(In production, you'd receive an email. For now, I'll simulate a successful login.)`
|
|
1241
|
+
);
|
|
1242
|
+
setTimeout(() => handleAuthSuccess(userInput), 1500);
|
|
1243
|
+
} else if (userInput.toLowerCase().includes("http") || userInput.match(/^[\w.-]+\.[a-z]{2,}$/i)) {
|
|
1244
|
+
const domain = userInput.replace(/^https?:\/\//, "").split("/")[0];
|
|
1245
|
+
setIsTyping(true);
|
|
1246
|
+
addAssistantMessage(`Analyzing ${domain} to extract brand information...`);
|
|
1247
|
+
const brand = await extractBrandFromDomain(domain);
|
|
1248
|
+
setIsTyping(false);
|
|
1249
|
+
if (brand) {
|
|
1250
|
+
setState((prev) => ({
|
|
1251
|
+
...prev,
|
|
1252
|
+
context: { ...prev.context, brand, domain }
|
|
1253
|
+
}));
|
|
1254
|
+
const brandSummary = [
|
|
1255
|
+
brand.business_name && `**Business:** ${brand.business_name}`,
|
|
1256
|
+
brand.tagline && `**Tagline:** ${brand.tagline}`,
|
|
1257
|
+
brand.primary_color && `**Primary Color:** ${brand.primary_color}`,
|
|
1258
|
+
brand.phone_numbers?.length && `**Phone:** ${brand.phone_numbers[0]}`
|
|
1259
|
+
].filter(Boolean).join("\n");
|
|
1260
|
+
addAssistantMessage(
|
|
1261
|
+
`Found brand information:
|
|
1262
|
+
|
|
1263
|
+
${brandSummary}
|
|
1264
|
+
|
|
1265
|
+
Does this look right?`,
|
|
1266
|
+
[
|
|
1267
|
+
{ id: "1", label: "Yes, looks good!", action: "confirm_brand", variant: "primary" },
|
|
1268
|
+
{ id: "2", label: "Edit brand info", action: "edit_brand", variant: "outline" }
|
|
1269
|
+
]
|
|
1270
|
+
);
|
|
1271
|
+
} else {
|
|
1272
|
+
addAssistantMessage(
|
|
1273
|
+
`I couldn't extract brand info from ${domain}. You can enter it manually, or we can continue without it.`,
|
|
1274
|
+
[
|
|
1275
|
+
{ id: "1", label: "Enter manually", action: "manual_brand", variant: "primary" },
|
|
1276
|
+
{ id: "2", label: "Skip for now", action: "skip_brand", variant: "outline" }
|
|
1277
|
+
]
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
} else {
|
|
1281
|
+
addStreamingMessage();
|
|
1282
|
+
try {
|
|
1283
|
+
await sendToSignalStreaming(
|
|
1284
|
+
userInput,
|
|
1285
|
+
state.context,
|
|
1286
|
+
(token) => appendToStreamingMessage(token),
|
|
1287
|
+
(result) => {
|
|
1288
|
+
if (result.updated_context) {
|
|
1289
|
+
setState((prev) => ({
|
|
1290
|
+
...prev,
|
|
1291
|
+
context: { ...prev.context, ...result.updated_context }
|
|
1292
|
+
}));
|
|
1293
|
+
}
|
|
1294
|
+
finalizeStreamingMessage(result.actions);
|
|
1295
|
+
}
|
|
1296
|
+
);
|
|
1297
|
+
} catch (error) {
|
|
1298
|
+
finalizeStreamingMessage();
|
|
1299
|
+
addAssistantMessage(
|
|
1300
|
+
`I understand you said: "${userInput}"
|
|
1301
|
+
|
|
1302
|
+
Let me help you with that. What would you like to do?`,
|
|
1303
|
+
[
|
|
1304
|
+
{ id: "1", label: "Continue setup", action: "start", variant: "primary" },
|
|
1305
|
+
{ id: "2", label: "Ask a question", action: "help", variant: "outline" }
|
|
1306
|
+
]
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}, [input, state.step, state.context, addMessage, addAssistantMessage, handleAuthSuccess, sendToSignalStreaming, appendToStreamingMessage, finalizeStreamingMessage, addStreamingMessage, extractBrandFromDomain]);
|
|
1311
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.container, children: [
|
|
1312
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.header, children: [
|
|
1313
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.logo, children: "U" }),
|
|
1314
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1315
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.title, children: "Uptrade Setup" }),
|
|
1316
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.subtitle, children: "Site-Kit Integration Wizard" })
|
|
1317
|
+
] })
|
|
1318
|
+
] }),
|
|
1319
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.messages, children: [
|
|
1320
|
+
messages.map((message) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1321
|
+
"div",
|
|
1322
|
+
{
|
|
1323
|
+
style: {
|
|
1324
|
+
...styles.message,
|
|
1325
|
+
...message.role === "assistant" ? styles.messageAssistant : styles.messageUser
|
|
1326
|
+
},
|
|
1327
|
+
children: [
|
|
1328
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1329
|
+
"div",
|
|
1330
|
+
{
|
|
1331
|
+
style: {
|
|
1332
|
+
...styles.avatar,
|
|
1333
|
+
...message.role === "assistant" ? styles.avatarAssistant : styles.avatarUser
|
|
1334
|
+
},
|
|
1335
|
+
children: message.role === "assistant" ? "\u2728" : "\u{1F464}"
|
|
1336
|
+
}
|
|
1337
|
+
),
|
|
1338
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1339
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1340
|
+
"div",
|
|
1341
|
+
{
|
|
1342
|
+
style: {
|
|
1343
|
+
...styles.bubble,
|
|
1344
|
+
...message.role === "assistant" ? styles.bubbleAssistant : styles.bubbleUser
|
|
1345
|
+
},
|
|
1346
|
+
children: message.content.split("\n").map((line, i) => /* @__PURE__ */ jsxRuntime.jsxs(React2__default.default.Fragment, { children: [
|
|
1347
|
+
line,
|
|
1348
|
+
i < message.content.split("\n").length - 1 && /* @__PURE__ */ jsxRuntime.jsx("br", {})
|
|
1349
|
+
] }, i))
|
|
1350
|
+
}
|
|
1351
|
+
),
|
|
1352
|
+
message.component,
|
|
1353
|
+
message.actions && /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.actions, children: message.actions.map((action) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1354
|
+
"button",
|
|
1355
|
+
{
|
|
1356
|
+
onClick: () => handleAction(action.action, action.data),
|
|
1357
|
+
style: {
|
|
1358
|
+
...styles.actionButton,
|
|
1359
|
+
...action.variant === "primary" ? styles.actionPrimary : action.variant === "outline" ? styles.actionOutline : styles.actionSecondary
|
|
1360
|
+
},
|
|
1361
|
+
children: action.label
|
|
1362
|
+
},
|
|
1363
|
+
action.id
|
|
1364
|
+
)) })
|
|
1365
|
+
] })
|
|
1366
|
+
]
|
|
1367
|
+
},
|
|
1368
|
+
message.id
|
|
1369
|
+
)),
|
|
1370
|
+
isTyping && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...styles.message, ...styles.messageAssistant }, children: [
|
|
1371
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...styles.avatar, ...styles.avatarAssistant }, children: "\u2728" }),
|
|
1372
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.typing, children: [
|
|
1373
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...styles.typingDot, animationDelay: "0s" } }),
|
|
1374
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...styles.typingDot, animationDelay: "0.2s" } }),
|
|
1375
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...styles.typingDot, animationDelay: "0.4s" } })
|
|
1376
|
+
] })
|
|
1377
|
+
] }),
|
|
1378
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
|
|
1379
|
+
] }),
|
|
1380
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: styles.inputContainer, children: [
|
|
1381
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1382
|
+
"input",
|
|
1383
|
+
{
|
|
1384
|
+
ref: inputRef,
|
|
1385
|
+
type: "text",
|
|
1386
|
+
value: input,
|
|
1387
|
+
onChange: (e) => setInput(e.target.value),
|
|
1388
|
+
placeholder: "Type a message...",
|
|
1389
|
+
style: styles.input
|
|
1390
|
+
}
|
|
1391
|
+
),
|
|
1392
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", style: styles.sendButton, children: "Send" })
|
|
1393
|
+
] }),
|
|
1394
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
1395
|
+
@keyframes typing {
|
|
1396
|
+
0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
|
|
1397
|
+
30% { transform: translateY(-4px); opacity: 1; }
|
|
1398
|
+
}
|
|
1399
|
+
` })
|
|
1400
|
+
] });
|
|
1401
|
+
}
|
|
1402
|
+
function ModuleSelector({
|
|
1403
|
+
modules,
|
|
1404
|
+
selected,
|
|
1405
|
+
onChange,
|
|
1406
|
+
onConfirm
|
|
1407
|
+
}) {
|
|
1408
|
+
const toggle = (id) => {
|
|
1409
|
+
onChange(
|
|
1410
|
+
selected.includes(id) ? selected.filter((m) => m !== id) : [...selected, id]
|
|
1411
|
+
);
|
|
1412
|
+
};
|
|
1413
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "0.75rem", display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
1414
|
+
modules.map((module) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1415
|
+
"div",
|
|
1416
|
+
{
|
|
1417
|
+
onClick: () => toggle(module.id),
|
|
1418
|
+
style: {
|
|
1419
|
+
...styles.moduleCard,
|
|
1420
|
+
...selected.includes(module.id) ? styles.moduleCardSelected : {}
|
|
1421
|
+
},
|
|
1422
|
+
children: [
|
|
1423
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.moduleIcon, children: module.icon }),
|
|
1424
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.moduleInfo, children: [
|
|
1425
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.moduleName, children: [
|
|
1426
|
+
module.name,
|
|
1427
|
+
module.recommended && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { marginLeft: "0.5rem", fontSize: "0.625rem", background: "#dbeafe", color: "#1d4ed8", padding: "2px 6px", borderRadius: "4px" }, children: "Recommended" })
|
|
1428
|
+
] }),
|
|
1429
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.moduleDesc, children: module.description })
|
|
1430
|
+
] }),
|
|
1431
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1432
|
+
"input",
|
|
1433
|
+
{
|
|
1434
|
+
type: "checkbox",
|
|
1435
|
+
checked: selected.includes(module.id),
|
|
1436
|
+
onChange: () => toggle(module.id),
|
|
1437
|
+
style: styles.checkbox
|
|
1438
|
+
}
|
|
1439
|
+
)
|
|
1440
|
+
]
|
|
1441
|
+
},
|
|
1442
|
+
module.id
|
|
1443
|
+
)),
|
|
1444
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1445
|
+
"button",
|
|
1446
|
+
{
|
|
1447
|
+
onClick: onConfirm,
|
|
1448
|
+
style: { ...styles.actionButton, ...styles.actionPrimary, marginTop: "0.5rem" },
|
|
1449
|
+
children: [
|
|
1450
|
+
"Continue with ",
|
|
1451
|
+
selected.length,
|
|
1452
|
+
" modules"
|
|
1453
|
+
]
|
|
1454
|
+
}
|
|
1455
|
+
)
|
|
1456
|
+
] });
|
|
1457
|
+
}
|
|
1458
|
+
function CodeBlock({ code }) {
|
|
1459
|
+
return /* @__PURE__ */ jsxRuntime.jsx("pre", { style: {
|
|
1460
|
+
marginTop: "0.75rem",
|
|
1461
|
+
padding: "1rem",
|
|
1462
|
+
background: "#1f2937",
|
|
1463
|
+
color: "#e5e7eb",
|
|
1464
|
+
borderRadius: "0.5rem",
|
|
1465
|
+
fontSize: "0.8125rem",
|
|
1466
|
+
overflowX: "auto",
|
|
1467
|
+
fontFamily: "monospace"
|
|
1468
|
+
}, children: code });
|
|
1469
|
+
}
|
|
1470
|
+
function generateIntegrationCode(state) {
|
|
1471
|
+
const { selectedModules } = state;
|
|
1472
|
+
const moduleConfigs = [];
|
|
1473
|
+
if (selectedModules.includes("analytics")) {
|
|
1474
|
+
moduleConfigs.push(` analytics={{ enabled: true }}`);
|
|
1475
|
+
}
|
|
1476
|
+
if (selectedModules.includes("engage")) {
|
|
1477
|
+
moduleConfigs.push(` engage={{ enabled: true }}`);
|
|
1478
|
+
}
|
|
1479
|
+
if (selectedModules.includes("forms")) {
|
|
1480
|
+
moduleConfigs.push(` forms={{ enabled: true }}`);
|
|
1481
|
+
}
|
|
1482
|
+
if (selectedModules.includes("signal")) {
|
|
1483
|
+
moduleConfigs.push(` signal={{ enabled: true, realtime: true }}`);
|
|
1484
|
+
}
|
|
1485
|
+
return `// app/layout.tsx (or pages/_app.tsx)
|
|
1486
|
+
import { SiteKitProvider } from '@sonordev/site-kit'
|
|
1487
|
+
|
|
1488
|
+
export default function RootLayout({ children }) {
|
|
1489
|
+
return (
|
|
1490
|
+
<html>
|
|
1491
|
+
<body>
|
|
1492
|
+
<SiteKitProvider
|
|
1493
|
+
apiKey={process.env.NEXT_PUBLIC_UPTRADE_API_KEY!}
|
|
1494
|
+
${moduleConfigs.join("\n")}
|
|
1495
|
+
>
|
|
1496
|
+
{children}
|
|
1497
|
+
</SiteKitProvider>
|
|
1498
|
+
</body>
|
|
1499
|
+
</html>
|
|
1500
|
+
)
|
|
1501
|
+
}`;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
// src/sync/api.ts
|
|
1505
|
+
var DEFAULT_API_URL = "https://api.uptrademedia.com";
|
|
1506
|
+
function getApiConfig2() {
|
|
1507
|
+
const apiUrl = typeof window !== "undefined" ? window.__SITE_KIT_API_URL__ || DEFAULT_API_URL : DEFAULT_API_URL;
|
|
1508
|
+
const apiKey = typeof window !== "undefined" ? window.__SITE_KIT_API_KEY__ : void 0;
|
|
1509
|
+
return { apiUrl, apiKey };
|
|
1510
|
+
}
|
|
1511
|
+
function buildHeaders(apiKey, isPost = false) {
|
|
1512
|
+
const headers = {};
|
|
1513
|
+
if (isPost) headers["Content-Type"] = "application/json";
|
|
1514
|
+
if (apiKey) headers["x-api-key"] = apiKey;
|
|
1515
|
+
return headers;
|
|
1516
|
+
}
|
|
1517
|
+
async function fetchBookingTypes(orgSlug, apiUrl, apiKey) {
|
|
1518
|
+
const cfg = getApiConfig2();
|
|
1519
|
+
const url = apiUrl || cfg.apiUrl;
|
|
1520
|
+
const key = apiKey || cfg.apiKey;
|
|
1521
|
+
const endpoint = key ? `${url}/sync/widget/types` : `${url}/sync/public/${orgSlug}/types`;
|
|
1522
|
+
const response = await fetch(endpoint, { headers: buildHeaders(key) });
|
|
1523
|
+
if (!response.ok) {
|
|
1524
|
+
const msg = await response.json().catch(() => ({ message: response.statusText }));
|
|
1525
|
+
const detail = msg && typeof msg.message === "string" ? msg.message : response.statusText;
|
|
1526
|
+
throw new Error(`Failed to fetch booking types: ${response.status} ${detail}`);
|
|
1527
|
+
}
|
|
1528
|
+
const data = await response.json();
|
|
1529
|
+
return data.types || [];
|
|
1530
|
+
}
|
|
1531
|
+
async function fetchBookingTypeDetails(typeSlug, orgSlug, apiUrl, apiKey) {
|
|
1532
|
+
const cfg = getApiConfig2();
|
|
1533
|
+
const url = apiUrl || cfg.apiUrl;
|
|
1534
|
+
const key = apiKey || cfg.apiKey;
|
|
1535
|
+
const endpoint = key ? `${url}/sync/widget/types/${typeSlug}` : `${url}/sync/public/${orgSlug}/types/${typeSlug}`;
|
|
1536
|
+
const response = await fetch(endpoint, { headers: buildHeaders(key) });
|
|
1537
|
+
if (!response.ok) {
|
|
1538
|
+
const msg = await response.json().catch(() => ({ message: response.statusText }));
|
|
1539
|
+
const detail = msg && typeof msg.message === "string" ? msg.message : response.statusText;
|
|
1540
|
+
throw new Error(`Failed to fetch booking type: ${response.status} ${detail}`);
|
|
1541
|
+
}
|
|
1542
|
+
return response.json();
|
|
1543
|
+
}
|
|
1544
|
+
async function fetchAvailability(typeSlug, date, orgSlug, apiUrl, apiKey, timezone, hostId) {
|
|
1545
|
+
const cfg = getApiConfig2();
|
|
1546
|
+
const url = apiUrl || cfg.apiUrl;
|
|
1547
|
+
const key = apiKey || cfg.apiKey;
|
|
1548
|
+
const params = new URLSearchParams({ date });
|
|
1549
|
+
if (timezone) params.append("timezone", timezone);
|
|
1550
|
+
if (hostId) params.append("hostId", hostId);
|
|
1551
|
+
const endpoint = key ? `${url}/sync/widget/availability/${typeSlug}?${params}` : `${url}/sync/public/${orgSlug}/availability/${typeSlug}?${params}`;
|
|
1552
|
+
const response = await fetch(endpoint, { headers: buildHeaders(key) });
|
|
1553
|
+
if (!response.ok) {
|
|
1554
|
+
const msg = await response.json().catch(() => ({ message: response.statusText }));
|
|
1555
|
+
let detail = msg && typeof msg.message === "string" ? String(msg.message).trim() : (response.statusText || "").trim();
|
|
1556
|
+
if (detail === String(response.status) || /^\d+$/.test(detail)) detail = "";
|
|
1557
|
+
const rest = detail ? `${response.status} ${detail}` : String(response.status);
|
|
1558
|
+
const fallback = response.status === 404 && !detail ? "No times available. In the Portal, check Sync \u2192 Booking Types (Schedule a Tour) has a host assigned and the project API key is set for this site." : null;
|
|
1559
|
+
throw new Error(fallback || `Failed to fetch availability: ${rest}`.trim());
|
|
1560
|
+
}
|
|
1561
|
+
const data = await response.json();
|
|
1562
|
+
const raw = data.slots || [];
|
|
1563
|
+
return raw.map((slot) => ({
|
|
1564
|
+
start: slot.startTime ?? slot.start,
|
|
1565
|
+
end: slot.endTime ?? slot.end,
|
|
1566
|
+
hostId: slot.hostId,
|
|
1567
|
+
available: slot.available !== false
|
|
1568
|
+
}));
|
|
1569
|
+
}
|
|
1570
|
+
async function createSlotHold(holdData, apiUrl, apiKey) {
|
|
1571
|
+
const cfg = getApiConfig2();
|
|
1572
|
+
const url = apiUrl || cfg.apiUrl;
|
|
1573
|
+
const key = apiKey || cfg.apiKey;
|
|
1574
|
+
const endpoint = key ? `${url}/sync/widget/hold` : `${url}/sync/public/hold`;
|
|
1575
|
+
const response = await fetch(endpoint, {
|
|
1576
|
+
method: "POST",
|
|
1577
|
+
headers: buildHeaders(key, true),
|
|
1578
|
+
body: JSON.stringify(holdData)
|
|
1579
|
+
});
|
|
1580
|
+
if (!response.ok) {
|
|
1581
|
+
throw new Error(`Failed to hold slot: ${response.statusText}`);
|
|
1582
|
+
}
|
|
1583
|
+
return response.json();
|
|
1584
|
+
}
|
|
1585
|
+
async function releaseSlotHold(holdId, apiUrl, apiKey) {
|
|
1586
|
+
const cfg = getApiConfig2();
|
|
1587
|
+
const url = apiUrl || cfg.apiUrl;
|
|
1588
|
+
const key = apiKey || cfg.apiKey;
|
|
1589
|
+
const endpoint = key ? `${url}/sync/widget/hold/${holdId}` : `${url}/sync/public/hold/${holdId}`;
|
|
1590
|
+
await fetch(endpoint, {
|
|
1591
|
+
method: "DELETE",
|
|
1592
|
+
headers: buildHeaders(key)
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
async function createBooking(bookingData, apiUrl, apiKey) {
|
|
1596
|
+
const cfg = getApiConfig2();
|
|
1597
|
+
const url = apiUrl || cfg.apiUrl;
|
|
1598
|
+
const key = apiKey || cfg.apiKey;
|
|
1599
|
+
const endpoint = key ? `${url}/sync/widget/booking` : `${url}/sync/public/booking`;
|
|
1600
|
+
const response = await fetch(endpoint, {
|
|
1601
|
+
method: "POST",
|
|
1602
|
+
headers: buildHeaders(key, true),
|
|
1603
|
+
body: JSON.stringify(bookingData)
|
|
1604
|
+
});
|
|
1605
|
+
if (!response.ok) {
|
|
1606
|
+
const errorData = await response.json().catch(() => ({}));
|
|
1607
|
+
throw new Error(errorData.message || `Failed to create booking: ${response.statusText}`);
|
|
1608
|
+
}
|
|
1609
|
+
return response.json();
|
|
1610
|
+
}
|
|
1611
|
+
async function fetchAvailableDates(typeSlug, startDate, endDate, orgSlug, apiUrl, apiKey, timezone) {
|
|
1612
|
+
const availableDates = [];
|
|
1613
|
+
const start = new Date(startDate);
|
|
1614
|
+
const end = new Date(endDate);
|
|
1615
|
+
const current = new Date(start);
|
|
1616
|
+
while (current <= end) {
|
|
1617
|
+
const dateStr = current.toISOString().split("T")[0];
|
|
1618
|
+
try {
|
|
1619
|
+
const slots = await fetchAvailability(typeSlug, dateStr, orgSlug, apiUrl, apiKey, timezone);
|
|
1620
|
+
if (slots.some((s) => s.available)) {
|
|
1621
|
+
availableDates.push(dateStr);
|
|
1622
|
+
}
|
|
1623
|
+
} catch {
|
|
1624
|
+
}
|
|
1625
|
+
current.setDate(current.getDate() + 1);
|
|
1626
|
+
}
|
|
1627
|
+
return availableDates;
|
|
1628
|
+
}
|
|
1629
|
+
function detectTimezone() {
|
|
1630
|
+
try {
|
|
1631
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1632
|
+
} catch {
|
|
1633
|
+
return "America/New_York";
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
function formatTime(isoString, timezone) {
|
|
1637
|
+
const date = new Date(isoString);
|
|
1638
|
+
return date.toLocaleTimeString("en-US", {
|
|
1639
|
+
hour: "numeric",
|
|
1640
|
+
minute: "2-digit",
|
|
1641
|
+
hour12: true,
|
|
1642
|
+
timeZone: timezone
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
function formatDate2(isoString, timezone) {
|
|
1646
|
+
const date = new Date(isoString);
|
|
1647
|
+
return date.toLocaleDateString("en-US", {
|
|
1648
|
+
weekday: "long",
|
|
1649
|
+
month: "long",
|
|
1650
|
+
day: "numeric",
|
|
1651
|
+
year: "numeric",
|
|
1652
|
+
timeZone: timezone
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
function formatDuration(minutes) {
|
|
1656
|
+
if (minutes < 60) {
|
|
1657
|
+
return `${minutes} min`;
|
|
1658
|
+
}
|
|
1659
|
+
const hours = Math.floor(minutes / 60);
|
|
1660
|
+
const mins = minutes % 60;
|
|
1661
|
+
if (mins === 0) {
|
|
1662
|
+
return `${hours} hour${hours > 1 ? "s" : ""}`;
|
|
1663
|
+
}
|
|
1664
|
+
return `${hours}h ${mins}m`;
|
|
1665
|
+
}
|
|
1666
|
+
var DEFAULT_API_URL2 = "https://api.uptrademedia.com";
|
|
1667
|
+
var DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
1668
|
+
var MONTHS = [
|
|
1669
|
+
"January",
|
|
1670
|
+
"February",
|
|
1671
|
+
"March",
|
|
1672
|
+
"April",
|
|
1673
|
+
"May",
|
|
1674
|
+
"June",
|
|
1675
|
+
"July",
|
|
1676
|
+
"August",
|
|
1677
|
+
"September",
|
|
1678
|
+
"October",
|
|
1679
|
+
"November",
|
|
1680
|
+
"December"
|
|
1681
|
+
];
|
|
1682
|
+
function isSameDay(a, b) {
|
|
1683
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
1684
|
+
}
|
|
1685
|
+
function isBeforeDay(a, b) {
|
|
1686
|
+
const ac = new Date(a.getFullYear(), a.getMonth(), a.getDate());
|
|
1687
|
+
const bc = new Date(b.getFullYear(), b.getMonth(), b.getDate());
|
|
1688
|
+
return ac < bc;
|
|
1689
|
+
}
|
|
1690
|
+
function calendarDays(year, month) {
|
|
1691
|
+
const first = new Date(year, month, 1);
|
|
1692
|
+
const last = new Date(year, month + 1, 0);
|
|
1693
|
+
const cells = [];
|
|
1694
|
+
for (let i = 0; i < first.getDay(); i++) cells.push(null);
|
|
1695
|
+
for (let d = 1; d <= last.getDate(); d++) cells.push(new Date(year, month, d));
|
|
1696
|
+
return cells;
|
|
1697
|
+
}
|
|
1698
|
+
function ChevronLeft() {
|
|
1699
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12.5 15L7.5 10L12.5 5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1700
|
+
}
|
|
1701
|
+
function ChevronRight() {
|
|
1702
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7.5 5L12.5 10L7.5 15", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1703
|
+
}
|
|
1704
|
+
function ClockIcon() {
|
|
1705
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
1706
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "8", cy: "8", r: "6.5", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
1707
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 4.5V8L10 10", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
1708
|
+
] });
|
|
1709
|
+
}
|
|
1710
|
+
function GlobeIcon() {
|
|
1711
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
1712
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "8", cy: "8", r: "6.5", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
1713
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M1.5 8H14.5", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
1714
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 1.5C9.66 3.34 10.61 5.62 10.61 8C10.61 10.38 9.66 12.66 8 14.5C6.34 12.66 5.39 10.38 5.39 8C5.39 5.62 6.34 3.34 8 1.5Z", stroke: "currentColor", strokeWidth: "1.2" })
|
|
1715
|
+
] });
|
|
1716
|
+
}
|
|
1717
|
+
function CheckCircleIcon() {
|
|
1718
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "56", height: "56", viewBox: "0 0 56 56", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
1719
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "28", cy: "28", r: "28", fill: "var(--bw-primary)" }),
|
|
1720
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 28.5L24.5 35L38 21.5", stroke: "white", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
1721
|
+
] });
|
|
1722
|
+
}
|
|
1723
|
+
function CalendarPlusIcon() {
|
|
1724
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
1725
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1.5", y: "2.5", width: "13", height: "12", rx: "1.5", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
1726
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M1.5 6.5H14.5", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
1727
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 1V4M11 1V4", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" }),
|
|
1728
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 9V12M6.5 10.5H9.5", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
|
|
1729
|
+
] });
|
|
1730
|
+
}
|
|
1731
|
+
function ArrowLeftIcon() {
|
|
1732
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 3L5 8L10 13", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1733
|
+
}
|
|
1734
|
+
function SpinnerIcon() {
|
|
1735
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "bw-spinner", children: [
|
|
1736
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "10", cy: "10", r: "8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeDasharray: "50.265", strokeDashoffset: "25", opacity: "0.3" }),
|
|
1737
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "10", cy: "10", r: "8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeDasharray: "50.265", strokeDashoffset: "37.7" })
|
|
1738
|
+
] });
|
|
1739
|
+
}
|
|
1740
|
+
function BookingWidget({
|
|
1741
|
+
orgSlug,
|
|
1742
|
+
apiKey: propApiKey,
|
|
1743
|
+
apiUrl: propApiUrl,
|
|
1744
|
+
bookingTypeSlug,
|
|
1745
|
+
timezone: propTimezone,
|
|
1746
|
+
className = "",
|
|
1747
|
+
daysToShow = 60,
|
|
1748
|
+
onBookingComplete,
|
|
1749
|
+
onError,
|
|
1750
|
+
hideTypeSelector = false,
|
|
1751
|
+
styles: styles2 = {}
|
|
1752
|
+
}) {
|
|
1753
|
+
const apiKey = propApiKey || (typeof window !== "undefined" ? window.__SITE_KIT_API_KEY__ : void 0);
|
|
1754
|
+
const apiUrl = propApiUrl || (typeof window !== "undefined" ? window.__SITE_KIT_API_URL__ : void 0) || DEFAULT_API_URL2;
|
|
1755
|
+
const [step, setStep] = React2.useState(bookingTypeSlug ? "datetime" : "type");
|
|
1756
|
+
const [loading, setLoading] = React2.useState(false);
|
|
1757
|
+
const [slotsLoading, setSlotsLoading] = React2.useState(false);
|
|
1758
|
+
const [error, setError] = React2.useState(null);
|
|
1759
|
+
const [bookingTypes, setBookingTypes] = React2.useState([]);
|
|
1760
|
+
const [selectedType, setSelectedType] = React2.useState(null);
|
|
1761
|
+
const [viewMonth, setViewMonth] = React2.useState(() => /* @__PURE__ */ new Date());
|
|
1762
|
+
const [selectedDate, setSelectedDate] = React2.useState(null);
|
|
1763
|
+
const [slots, setSlots] = React2.useState([]);
|
|
1764
|
+
const [selectedSlot, setSelectedSlot] = React2.useState(null);
|
|
1765
|
+
const [confirmedSlot, setConfirmedSlot] = React2.useState(false);
|
|
1766
|
+
const [hold, setHold] = React2.useState(null);
|
|
1767
|
+
const [guestInfo, setGuestInfo] = React2.useState({ name: "", email: "" });
|
|
1768
|
+
const [bookingResult, setBookingResult] = React2.useState(null);
|
|
1769
|
+
const [submitting, setSubmitting] = React2.useState(false);
|
|
1770
|
+
const slotsRef = React2.useRef(null);
|
|
1771
|
+
const today = React2.useMemo(() => {
|
|
1772
|
+
const d = /* @__PURE__ */ new Date();
|
|
1773
|
+
d.setHours(0, 0, 0, 0);
|
|
1774
|
+
return d;
|
|
1775
|
+
}, []);
|
|
1776
|
+
const timezone = React2.useMemo(() => propTimezone || detectTimezone(), [propTimezone]);
|
|
1777
|
+
const shortTz = React2.useMemo(() => {
|
|
1778
|
+
try {
|
|
1779
|
+
const parts = Intl.DateTimeFormat("en-US", { timeZone: timezone, timeZoneName: "short" }).formatToParts(/* @__PURE__ */ new Date());
|
|
1780
|
+
return parts.find((p) => p.type === "timeZoneName")?.value || timezone;
|
|
1781
|
+
} catch {
|
|
1782
|
+
return timezone;
|
|
1783
|
+
}
|
|
1784
|
+
}, [timezone]);
|
|
1785
|
+
const days = React2.useMemo(() => calendarDays(viewMonth.getFullYear(), viewMonth.getMonth()), [viewMonth]);
|
|
1786
|
+
const maxDate = React2.useMemo(() => {
|
|
1787
|
+
const d = new Date(today);
|
|
1788
|
+
d.setDate(d.getDate() + daysToShow);
|
|
1789
|
+
return d;
|
|
1790
|
+
}, [today, daysToShow]);
|
|
1791
|
+
React2.useEffect(() => {
|
|
1792
|
+
if (bookingTypeSlug) {
|
|
1793
|
+
setLoading(true);
|
|
1794
|
+
fetchBookingTypeDetails(bookingTypeSlug, orgSlug, apiUrl, apiKey).then((type) => {
|
|
1795
|
+
setSelectedType(type);
|
|
1796
|
+
setStep("datetime");
|
|
1797
|
+
}).catch((err) => {
|
|
1798
|
+
setError(err.message);
|
|
1799
|
+
onError?.(err);
|
|
1800
|
+
}).finally(() => setLoading(false));
|
|
1801
|
+
} else {
|
|
1802
|
+
setLoading(true);
|
|
1803
|
+
fetchBookingTypes(orgSlug, apiUrl, apiKey).then((types) => setBookingTypes(types.filter((t) => t.is_active))).catch((err) => {
|
|
1804
|
+
setError(err.message);
|
|
1805
|
+
onError?.(err);
|
|
1806
|
+
}).finally(() => setLoading(false));
|
|
1807
|
+
}
|
|
1808
|
+
}, [orgSlug, apiKey, bookingTypeSlug, apiUrl, onError]);
|
|
1809
|
+
React2.useEffect(() => {
|
|
1810
|
+
if (!selectedDate || !selectedType) return;
|
|
1811
|
+
const dateStr = selectedDate.toISOString().split("T")[0];
|
|
1812
|
+
setSlotsLoading(true);
|
|
1813
|
+
setSlots([]);
|
|
1814
|
+
setSelectedSlot(null);
|
|
1815
|
+
setConfirmedSlot(false);
|
|
1816
|
+
fetchAvailability(selectedType.slug, dateStr, orgSlug, apiUrl, apiKey, timezone).then((s) => setSlots(s.filter((slot) => slot.available))).catch((err) => {
|
|
1817
|
+
setError(err.message);
|
|
1818
|
+
onError?.(err);
|
|
1819
|
+
}).finally(() => setSlotsLoading(false));
|
|
1820
|
+
}, [selectedDate, selectedType, orgSlug, apiKey, apiUrl, timezone, onError]);
|
|
1821
|
+
const handleSlotSelect = React2.useCallback((slot) => {
|
|
1822
|
+
setSelectedSlot(slot);
|
|
1823
|
+
setConfirmedSlot(false);
|
|
1824
|
+
}, []);
|
|
1825
|
+
const handleSlotConfirm = React2.useCallback(async () => {
|
|
1826
|
+
if (!selectedType || !selectedSlot) return;
|
|
1827
|
+
if (hold) await releaseSlotHold(hold.holdId, apiUrl, apiKey).catch(() => {
|
|
1828
|
+
});
|
|
1829
|
+
setLoading(true);
|
|
1830
|
+
try {
|
|
1831
|
+
const newHold = await createSlotHold(
|
|
1832
|
+
{
|
|
1833
|
+
bookingType: selectedType.slug,
|
|
1834
|
+
slotStart: selectedSlot.start,
|
|
1835
|
+
slotEnd: selectedSlot.end,
|
|
1836
|
+
hostId: selectedSlot.hostId || "",
|
|
1837
|
+
sessionId: `bw-${Date.now()}`
|
|
1838
|
+
},
|
|
1839
|
+
apiUrl,
|
|
1840
|
+
apiKey
|
|
1841
|
+
);
|
|
1842
|
+
setHold(newHold);
|
|
1843
|
+
setConfirmedSlot(true);
|
|
1844
|
+
setStep("form");
|
|
1845
|
+
} catch (err) {
|
|
1846
|
+
setError(err.message);
|
|
1847
|
+
onError?.(err);
|
|
1848
|
+
} finally {
|
|
1849
|
+
setLoading(false);
|
|
1850
|
+
}
|
|
1851
|
+
}, [selectedType, selectedSlot, hold, timezone, apiUrl, apiKey, onError]);
|
|
1852
|
+
const handleBookingSubmit = React2.useCallback(async (e) => {
|
|
1853
|
+
e.preventDefault();
|
|
1854
|
+
if (!selectedType || !selectedSlot) return;
|
|
1855
|
+
setSubmitting(true);
|
|
1856
|
+
setError(null);
|
|
1857
|
+
try {
|
|
1858
|
+
const result = await createBooking(
|
|
1859
|
+
{
|
|
1860
|
+
bookingType: selectedType.slug,
|
|
1861
|
+
scheduledAt: selectedSlot.start,
|
|
1862
|
+
hostId: selectedSlot.hostId || "",
|
|
1863
|
+
name: guestInfo.name,
|
|
1864
|
+
email: guestInfo.email,
|
|
1865
|
+
phone: guestInfo.phone,
|
|
1866
|
+
message: guestInfo.notes,
|
|
1867
|
+
source: "main-site",
|
|
1868
|
+
timezone,
|
|
1869
|
+
holdId: hold?.holdId,
|
|
1870
|
+
sessionId: `bw-${Date.now()}`,
|
|
1871
|
+
sourceUrl: typeof window !== "undefined" ? window.location.href : void 0
|
|
1872
|
+
},
|
|
1873
|
+
apiUrl,
|
|
1874
|
+
apiKey
|
|
1875
|
+
);
|
|
1876
|
+
setBookingResult(result);
|
|
1877
|
+
setStep("success");
|
|
1878
|
+
onBookingComplete?.(result);
|
|
1879
|
+
} catch (err) {
|
|
1880
|
+
setError(err.message);
|
|
1881
|
+
onError?.(err);
|
|
1882
|
+
} finally {
|
|
1883
|
+
setSubmitting(false);
|
|
1884
|
+
}
|
|
1885
|
+
}, [selectedType, selectedSlot, guestInfo, timezone, hold, apiUrl, apiKey, onBookingComplete, onError]);
|
|
1886
|
+
React2.useEffect(() => {
|
|
1887
|
+
return () => {
|
|
1888
|
+
if (hold) releaseSlotHold(hold.holdId, apiUrl, apiKey).catch(() => {
|
|
1889
|
+
});
|
|
1890
|
+
};
|
|
1891
|
+
}, [hold, apiUrl, apiKey]);
|
|
1892
|
+
const canGoPrev = viewMonth.getFullYear() > today.getFullYear() || viewMonth.getMonth() > today.getMonth();
|
|
1893
|
+
const canGoNext = viewMonth < maxDate;
|
|
1894
|
+
const goMonth = (dir) => {
|
|
1895
|
+
setViewMonth((prev) => new Date(prev.getFullYear(), prev.getMonth() + dir, 1));
|
|
1896
|
+
};
|
|
1897
|
+
const groupedSlots = React2.useMemo(() => {
|
|
1898
|
+
const morning = [];
|
|
1899
|
+
const afternoon = [];
|
|
1900
|
+
const evening = [];
|
|
1901
|
+
for (const s of slots) {
|
|
1902
|
+
const h = new Date(s.start).getHours();
|
|
1903
|
+
if (h < 12) morning.push(s);
|
|
1904
|
+
else if (h < 17) afternoon.push(s);
|
|
1905
|
+
else evening.push(s);
|
|
1906
|
+
}
|
|
1907
|
+
return { morning, afternoon, evening };
|
|
1908
|
+
}, [slots]);
|
|
1909
|
+
const cssVars = {
|
|
1910
|
+
"--bw-primary": styles2.primaryColor || "#0069ff",
|
|
1911
|
+
"--bw-primary-light": styles2.primaryColor ? `color-mix(in srgb, ${styles2.primaryColor} 12%, white)` : "#e8f1ff",
|
|
1912
|
+
"--bw-primary-hover": styles2.primaryColor ? `color-mix(in srgb, ${styles2.primaryColor} 90%, black)` : "#0055d4",
|
|
1913
|
+
"--bw-radius": styles2.borderRadius || "8px",
|
|
1914
|
+
"--bw-font": styles2.fontFamily || "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"
|
|
1915
|
+
};
|
|
1916
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `bw-root ${className}`, style: cssVars, children: [
|
|
1917
|
+
error && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-error", role: "alert", children: [
|
|
1918
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: error }),
|
|
1919
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => setError(null), "aria-label": "Dismiss error", children: "\xD7" })
|
|
1920
|
+
] }),
|
|
1921
|
+
step === "type" && !hideTypeSelector && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-step bw-fade-in", children: [
|
|
1922
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "bw-heading", children: "Select a Service" }),
|
|
1923
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-loading", children: [
|
|
1924
|
+
/* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon, {}),
|
|
1925
|
+
" Loading services..."
|
|
1926
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bw-type-list", children: bookingTypes.map((type) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1927
|
+
"button",
|
|
1928
|
+
{
|
|
1929
|
+
className: "bw-type-card",
|
|
1930
|
+
onClick: () => {
|
|
1931
|
+
setSelectedType(type);
|
|
1932
|
+
setStep("datetime");
|
|
1933
|
+
},
|
|
1934
|
+
children: [
|
|
1935
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-type-name", children: type.name }),
|
|
1936
|
+
type.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-type-desc", children: type.description }),
|
|
1937
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bw-type-meta", children: [
|
|
1938
|
+
/* @__PURE__ */ jsxRuntime.jsx(ClockIcon, {}),
|
|
1939
|
+
" ",
|
|
1940
|
+
formatDuration(type.duration_minutes),
|
|
1941
|
+
type.price_cents ? ` \xB7 $${(type.price_cents / 100).toFixed(2)}` : " \xB7 Free"
|
|
1942
|
+
] })
|
|
1943
|
+
]
|
|
1944
|
+
},
|
|
1945
|
+
type.id
|
|
1946
|
+
)) })
|
|
1947
|
+
] }),
|
|
1948
|
+
step === "datetime" && selectedType && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-step bw-fade-in", children: [
|
|
1949
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-info-header", children: [
|
|
1950
|
+
!bookingTypeSlug && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "bw-back", onClick: () => {
|
|
1951
|
+
setSelectedType(null);
|
|
1952
|
+
setStep("type");
|
|
1953
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsx(ArrowLeftIcon, {}) }),
|
|
1954
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1955
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "bw-heading", children: selectedType.name }),
|
|
1956
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-meta-row", children: [
|
|
1957
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bw-badge", children: [
|
|
1958
|
+
/* @__PURE__ */ jsxRuntime.jsx(ClockIcon, {}),
|
|
1959
|
+
" ",
|
|
1960
|
+
formatDuration(selectedType.duration_minutes)
|
|
1961
|
+
] }),
|
|
1962
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bw-badge", children: [
|
|
1963
|
+
/* @__PURE__ */ jsxRuntime.jsx(GlobeIcon, {}),
|
|
1964
|
+
" ",
|
|
1965
|
+
shortTz
|
|
1966
|
+
] })
|
|
1967
|
+
] })
|
|
1968
|
+
] })
|
|
1969
|
+
] }),
|
|
1970
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-datetime-layout", children: [
|
|
1971
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-calendar", children: [
|
|
1972
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-cal-header", children: [
|
|
1973
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "bw-cal-nav", onClick: () => goMonth(-1), disabled: !canGoPrev, "aria-label": "Previous month", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeft, {}) }),
|
|
1974
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bw-cal-title", children: [
|
|
1975
|
+
MONTHS[viewMonth.getMonth()],
|
|
1976
|
+
" ",
|
|
1977
|
+
viewMonth.getFullYear()
|
|
1978
|
+
] }),
|
|
1979
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "bw-cal-nav", onClick: () => goMonth(1), disabled: !canGoNext, "aria-label": "Next month", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRight, {}) })
|
|
1980
|
+
] }),
|
|
1981
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bw-cal-weekdays", children: DAYS.map((d) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-cal-wd", children: d }, d)) }),
|
|
1982
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bw-cal-grid", children: days.map((date, i) => {
|
|
1983
|
+
if (!date) return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-cal-empty" }, `e-${i}`);
|
|
1984
|
+
const past = isBeforeDay(date, today);
|
|
1985
|
+
const future = date > maxDate;
|
|
1986
|
+
const disabled = past || future;
|
|
1987
|
+
const sel = selectedDate && isSameDay(date, selectedDate);
|
|
1988
|
+
const isToday = isSameDay(date, today);
|
|
1989
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1990
|
+
"button",
|
|
1991
|
+
{
|
|
1992
|
+
className: `bw-cal-day${sel ? " selected" : ""}${isToday ? " today" : ""}${disabled ? " disabled" : ""}`,
|
|
1993
|
+
onClick: () => !disabled && setSelectedDate(date),
|
|
1994
|
+
disabled,
|
|
1995
|
+
"aria-label": date.toLocaleDateString("en-US", { weekday: "long", month: "long", day: "numeric" }),
|
|
1996
|
+
"aria-pressed": sel || void 0,
|
|
1997
|
+
children: date.getDate()
|
|
1998
|
+
},
|
|
1999
|
+
date.toISOString()
|
|
2000
|
+
);
|
|
2001
|
+
}) })
|
|
2002
|
+
] }),
|
|
2003
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `bw-times${selectedDate ? " visible" : ""}`, ref: slotsRef, children: !selectedDate ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-times-placeholder", children: [
|
|
2004
|
+
/* @__PURE__ */ jsxRuntime.jsx(CalendarPlusIcon, {}),
|
|
2005
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Select a date to view available times" })
|
|
2006
|
+
] }) : slotsLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-loading", children: [
|
|
2007
|
+
/* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon, {}),
|
|
2008
|
+
" Loading times..."
|
|
2009
|
+
] }) : slots.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bw-times-empty", children: "No available times on this date. Try another day." }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-times-scroll", children: [
|
|
2010
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "bw-times-date", children: selectedDate.toLocaleDateString("en-US", { weekday: "long", month: "short", day: "numeric" }) }),
|
|
2011
|
+
groupedSlots.morning.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-time-group", children: [
|
|
2012
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-time-label", children: "Morning" }),
|
|
2013
|
+
groupedSlots.morning.map((slot) => /* @__PURE__ */ jsxRuntime.jsx(TimeButton, { slot, selected: selectedSlot?.start === slot.start, confirmed: confirmedSlot && selectedSlot?.start === slot.start, onClick: () => handleSlotSelect(slot), onConfirm: handleSlotConfirm, timezone, loading }, slot.start))
|
|
2014
|
+
] }),
|
|
2015
|
+
groupedSlots.afternoon.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-time-group", children: [
|
|
2016
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-time-label", children: "Afternoon" }),
|
|
2017
|
+
groupedSlots.afternoon.map((slot) => /* @__PURE__ */ jsxRuntime.jsx(TimeButton, { slot, selected: selectedSlot?.start === slot.start, confirmed: confirmedSlot && selectedSlot?.start === slot.start, onClick: () => handleSlotSelect(slot), onConfirm: handleSlotConfirm, timezone, loading }, slot.start))
|
|
2018
|
+
] }),
|
|
2019
|
+
groupedSlots.evening.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-time-group", children: [
|
|
2020
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-time-label", children: "Evening" }),
|
|
2021
|
+
groupedSlots.evening.map((slot) => /* @__PURE__ */ jsxRuntime.jsx(TimeButton, { slot, selected: selectedSlot?.start === slot.start, confirmed: confirmedSlot && selectedSlot?.start === slot.start, onClick: () => handleSlotSelect(slot), onConfirm: handleSlotConfirm, timezone, loading }, slot.start))
|
|
2022
|
+
] }),
|
|
2023
|
+
(groupedSlots.afternoon.length > 0 || groupedSlots.evening.length > 0) && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "bw-times-scroll-hint", children: "Scroll for more times" })
|
|
2024
|
+
] }) })
|
|
2025
|
+
] })
|
|
2026
|
+
] }),
|
|
2027
|
+
step === "form" && selectedType && selectedSlot && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-step bw-fade-in", children: [
|
|
2028
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-info-header", children: [
|
|
2029
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "bw-back", onClick: () => setStep("datetime"), children: /* @__PURE__ */ jsxRuntime.jsx(ArrowLeftIcon, {}) }),
|
|
2030
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2031
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "bw-heading", children: "Your Details" }),
|
|
2032
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-meta-row", children: [
|
|
2033
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bw-badge", children: [
|
|
2034
|
+
/* @__PURE__ */ jsxRuntime.jsx(ClockIcon, {}),
|
|
2035
|
+
" ",
|
|
2036
|
+
formatDuration(selectedType.duration_minutes)
|
|
2037
|
+
] }),
|
|
2038
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bw-badge-accent", children: [
|
|
2039
|
+
formatDate2(selectedSlot.start, timezone),
|
|
2040
|
+
" \xB7 ",
|
|
2041
|
+
formatTime(selectedSlot.start, timezone)
|
|
2042
|
+
] })
|
|
2043
|
+
] })
|
|
2044
|
+
] })
|
|
2045
|
+
] }),
|
|
2046
|
+
hold && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-hold-notice", children: [
|
|
2047
|
+
/* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon, {}),
|
|
2048
|
+
" Slot held for you \u2014 complete your details to confirm."
|
|
2049
|
+
] }),
|
|
2050
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleBookingSubmit, className: "bw-form", children: [
|
|
2051
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-field", children: [
|
|
2052
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: "bw-name", children: [
|
|
2053
|
+
"Name ",
|
|
2054
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-req", children: "*" })
|
|
2055
|
+
] }),
|
|
2056
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2057
|
+
"input",
|
|
2058
|
+
{
|
|
2059
|
+
id: "bw-name",
|
|
2060
|
+
type: "text",
|
|
2061
|
+
required: true,
|
|
2062
|
+
value: guestInfo.name,
|
|
2063
|
+
onChange: (e) => setGuestInfo((p) => ({ ...p, name: e.target.value })),
|
|
2064
|
+
placeholder: "Jane Smith",
|
|
2065
|
+
autoComplete: "name"
|
|
2066
|
+
}
|
|
2067
|
+
)
|
|
2068
|
+
] }),
|
|
2069
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-field", children: [
|
|
2070
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: "bw-email", children: [
|
|
2071
|
+
"Email ",
|
|
2072
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-req", children: "*" })
|
|
2073
|
+
] }),
|
|
2074
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2075
|
+
"input",
|
|
2076
|
+
{
|
|
2077
|
+
id: "bw-email",
|
|
2078
|
+
type: "email",
|
|
2079
|
+
required: true,
|
|
2080
|
+
value: guestInfo.email,
|
|
2081
|
+
onChange: (e) => setGuestInfo((p) => ({ ...p, email: e.target.value })),
|
|
2082
|
+
placeholder: "jane@example.com",
|
|
2083
|
+
autoComplete: "email"
|
|
2084
|
+
}
|
|
2085
|
+
)
|
|
2086
|
+
] }),
|
|
2087
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-field", children: [
|
|
2088
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "bw-phone", children: "Phone" }),
|
|
2089
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2090
|
+
"input",
|
|
2091
|
+
{
|
|
2092
|
+
id: "bw-phone",
|
|
2093
|
+
type: "tel",
|
|
2094
|
+
value: guestInfo.phone || "",
|
|
2095
|
+
onChange: (e) => setGuestInfo((p) => ({ ...p, phone: e.target.value })),
|
|
2096
|
+
placeholder: "(555) 123-4567",
|
|
2097
|
+
autoComplete: "tel"
|
|
2098
|
+
}
|
|
2099
|
+
)
|
|
2100
|
+
] }),
|
|
2101
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-field", children: [
|
|
2102
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "bw-notes", children: "Notes" }),
|
|
2103
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2104
|
+
"textarea",
|
|
2105
|
+
{
|
|
2106
|
+
id: "bw-notes",
|
|
2107
|
+
value: guestInfo.notes || "",
|
|
2108
|
+
onChange: (e) => setGuestInfo((p) => ({ ...p, notes: e.target.value })),
|
|
2109
|
+
placeholder: "Anything you'd like us to know...",
|
|
2110
|
+
rows: 3
|
|
2111
|
+
}
|
|
2112
|
+
)
|
|
2113
|
+
] }),
|
|
2114
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", className: "bw-submit", disabled: submitting || !guestInfo.name || !guestInfo.email, children: submitting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2115
|
+
/* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon, {}),
|
|
2116
|
+
" Confirming..."
|
|
2117
|
+
] }) : "Confirm Booking" })
|
|
2118
|
+
] })
|
|
2119
|
+
] }),
|
|
2120
|
+
step === "success" && bookingResult && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-step bw-fade-in bw-success", children: [
|
|
2121
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bw-success-icon", children: /* @__PURE__ */ jsxRuntime.jsx(CheckCircleIcon, {}) }),
|
|
2122
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "bw-heading", children: "You\u2019re Booked!" }),
|
|
2123
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-details-card", children: [
|
|
2124
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-detail-row", children: [
|
|
2125
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-detail-label", children: "When" }),
|
|
2126
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bw-detail-value", children: [
|
|
2127
|
+
formatDate2(bookingResult.booking.scheduledAt, timezone),
|
|
2128
|
+
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
2129
|
+
formatTime(bookingResult.booking.scheduledAt, timezone),
|
|
2130
|
+
" (",
|
|
2131
|
+
shortTz,
|
|
2132
|
+
")"
|
|
2133
|
+
] })
|
|
2134
|
+
] }),
|
|
2135
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-detail-row", children: [
|
|
2136
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-detail-label", children: "Duration" }),
|
|
2137
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-detail-value", children: formatDuration(bookingResult.booking.durationMinutes) })
|
|
2138
|
+
] }),
|
|
2139
|
+
bookingResult.booking.hostName && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-detail-row", children: [
|
|
2140
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-detail-label", children: "With" }),
|
|
2141
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-detail-value", children: bookingResult.booking.hostName })
|
|
2142
|
+
] })
|
|
2143
|
+
] }),
|
|
2144
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "bw-cal-links-label", children: "Add to your calendar" }),
|
|
2145
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-cal-links", children: [
|
|
2146
|
+
/* @__PURE__ */ jsxRuntime.jsxs("a", { href: bookingResult.calendarLinks.google, target: "_blank", rel: "noopener noreferrer", className: "bw-cal-link", children: [
|
|
2147
|
+
/* @__PURE__ */ jsxRuntime.jsx(CalendarPlusIcon, {}),
|
|
2148
|
+
" Google"
|
|
2149
|
+
] }),
|
|
2150
|
+
/* @__PURE__ */ jsxRuntime.jsxs("a", { href: bookingResult.calendarLinks.outlook, target: "_blank", rel: "noopener noreferrer", className: "bw-cal-link", children: [
|
|
2151
|
+
/* @__PURE__ */ jsxRuntime.jsx(CalendarPlusIcon, {}),
|
|
2152
|
+
" Outlook"
|
|
2153
|
+
] }),
|
|
2154
|
+
/* @__PURE__ */ jsxRuntime.jsxs("a", { href: bookingResult.calendarLinks.ics, download: true, className: "bw-cal-link", children: [
|
|
2155
|
+
/* @__PURE__ */ jsxRuntime.jsx(CalendarPlusIcon, {}),
|
|
2156
|
+
" iCal"
|
|
2157
|
+
] })
|
|
2158
|
+
] }),
|
|
2159
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "bw-email-notice", children: [
|
|
2160
|
+
"If your host uses Google Calendar, a calendar invite will be sent to ",
|
|
2161
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: guestInfo.email }),
|
|
2162
|
+
"."
|
|
2163
|
+
] })
|
|
2164
|
+
] }),
|
|
2165
|
+
loading && step === "datetime" && !selectedType && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-loading", children: [
|
|
2166
|
+
/* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon, {}),
|
|
2167
|
+
" Loading..."
|
|
2168
|
+
] }),
|
|
2169
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: WIDGET_CSS })
|
|
2170
|
+
] });
|
|
2171
|
+
}
|
|
2172
|
+
function TimeButton({
|
|
2173
|
+
slot,
|
|
2174
|
+
selected,
|
|
2175
|
+
confirmed,
|
|
2176
|
+
onClick,
|
|
2177
|
+
onConfirm,
|
|
2178
|
+
timezone,
|
|
2179
|
+
loading
|
|
2180
|
+
}) {
|
|
2181
|
+
if (selected && !confirmed) {
|
|
2182
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bw-time-btn-wrap selected", children: [
|
|
2183
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bw-time-text", children: formatTime(slot.start, timezone) }),
|
|
2184
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "bw-time-confirm", onClick: onConfirm, disabled: loading, children: loading ? /* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon, {}) : "Confirm" })
|
|
2185
|
+
] });
|
|
2186
|
+
}
|
|
2187
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", { className: `bw-time-btn${selected ? " selected" : ""}`, onClick, disabled: loading, children: formatTime(slot.start, timezone) });
|
|
2188
|
+
}
|
|
2189
|
+
var WIDGET_CSS = `
|
|
2190
|
+
/* \u2500\u2500 Base \u2500\u2500 */
|
|
2191
|
+
.bw-root {
|
|
2192
|
+
font-family: var(--bw-font);
|
|
2193
|
+
color: #1a1a1a;
|
|
2194
|
+
line-height: 1.5;
|
|
2195
|
+
-webkit-font-smoothing: antialiased;
|
|
2196
|
+
box-sizing: border-box;
|
|
2197
|
+
}
|
|
2198
|
+
.bw-root *, .bw-root *::before, .bw-root *::after { box-sizing: border-box; }
|
|
2199
|
+
|
|
2200
|
+
/* \u2500\u2500 Animation \u2500\u2500 */
|
|
2201
|
+
@keyframes bw-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
|
|
2202
|
+
@keyframes bw-spin { to { transform: rotate(360deg); } }
|
|
2203
|
+
.bw-fade-in { animation: bw-fade-in 0.25s ease-out; }
|
|
2204
|
+
.bw-spinner { animation: bw-spin 0.8s linear infinite; }
|
|
2205
|
+
|
|
2206
|
+
/* \u2500\u2500 Error \u2500\u2500 */
|
|
2207
|
+
.bw-error {
|
|
2208
|
+
display: flex; align-items: center; justify-content: space-between; gap: 12px;
|
|
2209
|
+
background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
|
|
2210
|
+
padding: 10px 14px; border-radius: var(--bw-radius); margin-bottom: 16px; font-size: 0.875rem;
|
|
2211
|
+
}
|
|
2212
|
+
.bw-error button { background: none; border: none; color: inherit; cursor: pointer; font-size: 1.25rem; line-height: 1; padding: 0; }
|
|
2213
|
+
|
|
2214
|
+
/* \u2500\u2500 Headings \u2500\u2500 */
|
|
2215
|
+
.bw-heading { font-size: 1.125rem; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
|
|
2216
|
+
.bw-meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
|
|
2217
|
+
.bw-badge {
|
|
2218
|
+
display: inline-flex; align-items: center; gap: 4px;
|
|
2219
|
+
font-size: 0.8125rem; color: #6b7280; font-weight: 400;
|
|
2220
|
+
}
|
|
2221
|
+
.bw-badge-accent {
|
|
2222
|
+
display: inline-flex; align-items: center; gap: 4px;
|
|
2223
|
+
font-size: 0.8125rem; color: var(--bw-primary); font-weight: 500;
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
/* \u2500\u2500 Info Header \u2500\u2500 */
|
|
2227
|
+
.bw-info-header { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 20px; }
|
|
2228
|
+
.bw-back {
|
|
2229
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
2230
|
+
width: 32px; height: 32px; border-radius: 50%; border: 1px solid #e5e7eb;
|
|
2231
|
+
background: #fff; cursor: pointer; color: #4b5563; flex-shrink: 0; margin-top: 1px;
|
|
2232
|
+
transition: all 0.15s;
|
|
2233
|
+
}
|
|
2234
|
+
.bw-back:hover { background: #f3f4f6; border-color: #d1d5db; }
|
|
2235
|
+
|
|
2236
|
+
/* \u2500\u2500 Loading \u2500\u2500 */
|
|
2237
|
+
.bw-loading {
|
|
2238
|
+
display: flex; align-items: center; justify-content: center; gap: 8px;
|
|
2239
|
+
padding: 32px; color: #6b7280; font-size: 0.875rem;
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
/* \u2500\u2500 Type Selection \u2500\u2500 */
|
|
2243
|
+
.bw-type-list { display: flex; flex-direction: column; gap: 10px; }
|
|
2244
|
+
.bw-type-card {
|
|
2245
|
+
display: flex; flex-direction: column; text-align: left; gap: 4px;
|
|
2246
|
+
padding: 16px; border: 1.5px solid #e5e7eb; border-radius: var(--bw-radius);
|
|
2247
|
+
background: #fff; cursor: pointer; transition: all 0.15s;
|
|
2248
|
+
}
|
|
2249
|
+
.bw-type-card:hover { border-color: var(--bw-primary); box-shadow: 0 0 0 3px var(--bw-primary-light); }
|
|
2250
|
+
.bw-type-name { font-weight: 600; font-size: 0.9375rem; }
|
|
2251
|
+
.bw-type-desc { color: #6b7280; font-size: 0.8125rem; }
|
|
2252
|
+
.bw-type-meta { display: flex; align-items: center; gap: 4px; font-size: 0.8125rem; color: #9ca3af; margin-top: 4px; }
|
|
2253
|
+
|
|
2254
|
+
/* \u2500\u2500 Date-Time Layout \u2500\u2500 */
|
|
2255
|
+
.bw-datetime-layout {
|
|
2256
|
+
display: flex; gap: 0; border-top: 1px solid #f0f0f0; padding-top: 16px;
|
|
2257
|
+
}
|
|
2258
|
+
@media (max-width: 559px) {
|
|
2259
|
+
.bw-datetime-layout { flex-direction: column; }
|
|
2260
|
+
}
|
|
2261
|
+
@media (min-width: 560px) {
|
|
2262
|
+
.bw-datetime-layout { min-height: 400px; }
|
|
2263
|
+
.bw-calendar { flex: 1 1 auto; padding-right: 16px; border-right: 1px solid #f0f0f0; }
|
|
2264
|
+
.bw-times { width: 180px; flex-shrink: 0; padding-left: 16px; }
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
/* \u2500\u2500 Calendar \u2500\u2500 */
|
|
2268
|
+
.bw-cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
|
|
2269
|
+
.bw-cal-title { font-weight: 600; font-size: 0.9375rem; }
|
|
2270
|
+
.bw-cal-nav {
|
|
2271
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
2272
|
+
width: 32px; height: 32px; border-radius: 50%; border: none;
|
|
2273
|
+
background: transparent; cursor: pointer; color: #374151; transition: background 0.15s;
|
|
2274
|
+
}
|
|
2275
|
+
.bw-cal-nav:hover:not(:disabled) { background: #f3f4f6; }
|
|
2276
|
+
.bw-cal-nav:disabled { opacity: 0.25; cursor: default; }
|
|
2277
|
+
|
|
2278
|
+
.bw-cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0; text-align: center; margin-bottom: 4px; }
|
|
2279
|
+
.bw-cal-wd { font-size: 0.6875rem; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 0; }
|
|
2280
|
+
|
|
2281
|
+
.bw-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
|
|
2282
|
+
.bw-cal-empty { aspect-ratio: 1; }
|
|
2283
|
+
.bw-cal-day {
|
|
2284
|
+
aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
|
|
2285
|
+
border: none; background: none; border-radius: 50%;
|
|
2286
|
+
font-size: 0.8125rem; font-weight: 500; cursor: pointer;
|
|
2287
|
+
color: #1a1a1a; transition: all 0.15s; position: relative;
|
|
2288
|
+
}
|
|
2289
|
+
.bw-cal-day:hover:not(.disabled):not(.selected) { background: #f3f4f6; }
|
|
2290
|
+
.bw-cal-day.today:not(.selected)::after {
|
|
2291
|
+
content: ''; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
|
|
2292
|
+
width: 4px; height: 4px; border-radius: 50%; background: var(--bw-primary);
|
|
2293
|
+
}
|
|
2294
|
+
.bw-cal-day.selected {
|
|
2295
|
+
background: var(--bw-primary); color: #fff; font-weight: 600;
|
|
2296
|
+
}
|
|
2297
|
+
.bw-cal-day.disabled { color: #d1d5db; cursor: default; }
|
|
2298
|
+
|
|
2299
|
+
/* \u2500\u2500 Time Slots \u2500\u2500 */
|
|
2300
|
+
.bw-times { transition: opacity 0.2s; }
|
|
2301
|
+
.bw-times:not(.visible) { opacity: 0.5; }
|
|
2302
|
+
.bw-times.visible { opacity: 1; }
|
|
2303
|
+
.bw-times-placeholder {
|
|
2304
|
+
display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
|
|
2305
|
+
height: 100%; min-height: 160px; color: #9ca3af; font-size: 0.8125rem; text-align: center; padding: 16px;
|
|
2306
|
+
}
|
|
2307
|
+
.bw-times-empty {
|
|
2308
|
+
display: flex; align-items: center; justify-content: center;
|
|
2309
|
+
height: 100%; min-height: 160px; color: #9ca3af; font-size: 0.8125rem; text-align: center; padding: 16px;
|
|
2310
|
+
}
|
|
2311
|
+
.bw-times-scroll { overflow-y: auto; max-height: 400px; overflow-x: hidden; }
|
|
2312
|
+
.bw-times-date { font-weight: 600; font-size: 0.8125rem; color: #374151; margin: 0 0 12px 0; }
|
|
2313
|
+
.bw-time-group { margin-bottom: 16px; }
|
|
2314
|
+
.bw-times-scroll-hint {
|
|
2315
|
+
font-size: 0.6875rem; color: #9ca3af; text-align: center; margin: 8px 0 0 0; padding-bottom: 8px;
|
|
2316
|
+
}
|
|
2317
|
+
.bw-time-label { display: block; font-size: 0.6875rem; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
|
|
2318
|
+
|
|
2319
|
+
.bw-time-btn {
|
|
2320
|
+
display: block; width: 100%;
|
|
2321
|
+
padding: 10px 12px; margin-bottom: 6px;
|
|
2322
|
+
border: 1.5px solid #e5e7eb; border-radius: var(--bw-radius);
|
|
2323
|
+
background: #fff; cursor: pointer;
|
|
2324
|
+
font-size: 0.875rem; font-weight: 500; color: var(--bw-primary); text-align: center;
|
|
2325
|
+
transition: all 0.15s;
|
|
2326
|
+
}
|
|
2327
|
+
.bw-time-btn:hover:not(:disabled) {
|
|
2328
|
+
border-color: var(--bw-primary); background: var(--bw-primary-light);
|
|
2329
|
+
}
|
|
2330
|
+
.bw-time-btn.selected {
|
|
2331
|
+
border-color: var(--bw-primary); background: var(--bw-primary); color: #fff;
|
|
2332
|
+
}
|
|
2333
|
+
.bw-time-btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
2334
|
+
|
|
2335
|
+
.bw-time-btn-wrap {
|
|
2336
|
+
display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
|
|
2337
|
+
border: 1.5px solid var(--bw-primary); border-radius: var(--bw-radius); overflow: hidden;
|
|
2338
|
+
animation: bw-fade-in 0.15s ease-out;
|
|
2339
|
+
}
|
|
2340
|
+
.bw-time-btn-wrap .bw-time-text {
|
|
2341
|
+
flex: 1; padding: 10px 12px; font-size: 0.875rem; font-weight: 500; color: #374151; text-align: center;
|
|
2342
|
+
background: var(--bw-primary-light);
|
|
2343
|
+
}
|
|
2344
|
+
.bw-time-confirm {
|
|
2345
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 4px;
|
|
2346
|
+
padding: 10px 16px; border: none;
|
|
2347
|
+
background: var(--bw-primary); color: #fff;
|
|
2348
|
+
font-size: 0.8125rem; font-weight: 600; cursor: pointer;
|
|
2349
|
+
transition: background 0.15s;
|
|
2350
|
+
}
|
|
2351
|
+
.bw-time-confirm:hover:not(:disabled) { background: var(--bw-primary-hover); }
|
|
2352
|
+
.bw-time-confirm:disabled { opacity: 0.7; cursor: not-allowed; }
|
|
2353
|
+
|
|
2354
|
+
/* \u2500\u2500 Form \u2500\u2500 */
|
|
2355
|
+
.bw-hold-notice {
|
|
2356
|
+
display: flex; align-items: center; gap: 8px;
|
|
2357
|
+
background: var(--bw-primary-light); color: var(--bw-primary);
|
|
2358
|
+
padding: 10px 14px; border-radius: var(--bw-radius);
|
|
2359
|
+
font-size: 0.8125rem; font-weight: 500; margin-bottom: 20px;
|
|
2360
|
+
}
|
|
2361
|
+
.bw-form { display: flex; flex-direction: column; gap: 16px; }
|
|
2362
|
+
.bw-field label {
|
|
2363
|
+
display: block; font-size: 0.8125rem; font-weight: 500; color: #374151; margin-bottom: 4px;
|
|
2364
|
+
}
|
|
2365
|
+
.bw-req { color: #ef4444; }
|
|
2366
|
+
.bw-field input, .bw-field textarea {
|
|
2367
|
+
display: block; width: 100%;
|
|
2368
|
+
padding: 10px 12px; border: 1.5px solid #e5e7eb; border-radius: var(--bw-radius);
|
|
2369
|
+
font-size: 0.9375rem; font-family: inherit; color: #1a1a1a; background: #fff;
|
|
2370
|
+
transition: border-color 0.15s, box-shadow 0.15s;
|
|
2371
|
+
}
|
|
2372
|
+
.bw-field input::placeholder, .bw-field textarea::placeholder { color: #c0c5cc; }
|
|
2373
|
+
.bw-field input:focus, .bw-field textarea:focus {
|
|
2374
|
+
outline: none; border-color: var(--bw-primary);
|
|
2375
|
+
box-shadow: 0 0 0 3px var(--bw-primary-light);
|
|
2376
|
+
}
|
|
2377
|
+
.bw-submit {
|
|
2378
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
|
|
2379
|
+
width: 100%; padding: 14px; margin-top: 4px;
|
|
2380
|
+
background: var(--bw-primary); color: #fff; border: none;
|
|
2381
|
+
border-radius: var(--bw-radius); font-size: 0.9375rem; font-weight: 600;
|
|
2382
|
+
cursor: pointer; transition: background 0.15s;
|
|
2383
|
+
}
|
|
2384
|
+
.bw-submit:hover:not(:disabled) { background: var(--bw-primary-hover); }
|
|
2385
|
+
.bw-submit:disabled { opacity: 0.55; cursor: not-allowed; }
|
|
2386
|
+
|
|
2387
|
+
/* \u2500\u2500 Success \u2500\u2500 */
|
|
2388
|
+
.bw-success { text-align: center; }
|
|
2389
|
+
.bw-success-icon { margin: 0 auto 16px; width: 56px; height: 56px; animation: bw-fade-in 0.4s ease-out; }
|
|
2390
|
+
.bw-conf-code {
|
|
2391
|
+
display: inline-block; font-family: 'SF Mono', 'Fira Code', monospace;
|
|
2392
|
+
background: #f3f4f6; padding: 6px 14px; border-radius: 6px;
|
|
2393
|
+
font-size: 0.8125rem; color: #6b7280; margin: 4px 0 20px; letter-spacing: 0.04em;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
.bw-details-card {
|
|
2397
|
+
text-align: left; background: #f9fafb; border: 1px solid #f0f0f0;
|
|
2398
|
+
border-radius: var(--bw-radius); padding: 16px; margin-bottom: 20px;
|
|
2399
|
+
}
|
|
2400
|
+
.bw-detail-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f0f0; }
|
|
2401
|
+
.bw-detail-row:last-child { border-bottom: none; }
|
|
2402
|
+
.bw-detail-label { width: 70px; flex-shrink: 0; font-size: 0.8125rem; color: #9ca3af; font-weight: 500; }
|
|
2403
|
+
.bw-detail-value { font-size: 0.875rem; font-weight: 500; color: #374151; }
|
|
2404
|
+
|
|
2405
|
+
.bw-cal-links-label { font-size: 0.8125rem; color: #6b7280; margin: 0 0 8px 0; }
|
|
2406
|
+
.bw-cal-links { display: flex; gap: 8px; justify-content: center; margin-bottom: 20px; flex-wrap: wrap; }
|
|
2407
|
+
.bw-cal-link {
|
|
2408
|
+
display: inline-flex; align-items: center; gap: 6px;
|
|
2409
|
+
padding: 8px 14px; border: 1.5px solid #e5e7eb; border-radius: var(--bw-radius);
|
|
2410
|
+
text-decoration: none; color: #374151; font-size: 0.8125rem; font-weight: 500;
|
|
2411
|
+
transition: all 0.15s;
|
|
2412
|
+
}
|
|
2413
|
+
.bw-cal-link:hover { border-color: var(--bw-primary); color: var(--bw-primary); }
|
|
2414
|
+
|
|
2415
|
+
.bw-email-notice { font-size: 0.8125rem; color: #9ca3af; margin: 0; }
|
|
2416
|
+
.bw-email-notice strong { color: #374151; font-weight: 500; }
|
|
2417
|
+
`;
|
|
2418
|
+
|
|
2419
|
+
Object.defineProperty(exports, "ManagedImage", {
|
|
2420
|
+
enumerable: true,
|
|
2421
|
+
get: function () { return chunkKUGMH4ZF_js.ManagedImage; }
|
|
2422
|
+
});
|
|
2423
|
+
Object.defineProperty(exports, "assignImageToSlot", {
|
|
2424
|
+
enumerable: true,
|
|
2425
|
+
get: function () { return chunkKUGMH4ZF_js.assignImageToSlot; }
|
|
2426
|
+
});
|
|
2427
|
+
Object.defineProperty(exports, "clearImageSlot", {
|
|
2428
|
+
enumerable: true,
|
|
2429
|
+
get: function () { return chunkKUGMH4ZF_js.clearImageSlot; }
|
|
2430
|
+
});
|
|
2431
|
+
Object.defineProperty(exports, "fetchManagedImage", {
|
|
2432
|
+
enumerable: true,
|
|
2433
|
+
get: function () { return chunkKUGMH4ZF_js.fetchManagedImage; }
|
|
2434
|
+
});
|
|
2435
|
+
Object.defineProperty(exports, "fetchManagedImages", {
|
|
2436
|
+
enumerable: true,
|
|
2437
|
+
get: function () { return chunkKUGMH4ZF_js.fetchManagedImages; }
|
|
2438
|
+
});
|
|
2439
|
+
Object.defineProperty(exports, "listImageFiles", {
|
|
2440
|
+
enumerable: true,
|
|
2441
|
+
get: function () { return chunkKUGMH4ZF_js.listImageFiles; }
|
|
2442
|
+
});
|
|
2443
|
+
Object.defineProperty(exports, "uploadImage", {
|
|
2444
|
+
enumerable: true,
|
|
2445
|
+
get: function () { return chunkKUGMH4ZF_js.uploadImage; }
|
|
2446
|
+
});
|
|
2447
|
+
Object.defineProperty(exports, "TestimonialSection", {
|
|
2448
|
+
enumerable: true,
|
|
2449
|
+
get: function () { return chunk43GBM4SX_js.TestimonialSection; }
|
|
2450
|
+
});
|
|
2451
|
+
Object.defineProperty(exports, "fetchReviewStats", {
|
|
2452
|
+
enumerable: true,
|
|
2453
|
+
get: function () { return chunk43GBM4SX_js.fetchReviewStats; }
|
|
2454
|
+
});
|
|
2455
|
+
Object.defineProperty(exports, "fetchReviews", {
|
|
2456
|
+
enumerable: true,
|
|
2457
|
+
get: function () { return chunk43GBM4SX_js.fetchReviews; }
|
|
2458
|
+
});
|
|
2459
|
+
Object.defineProperty(exports, "SignalBridge", {
|
|
2460
|
+
enumerable: true,
|
|
2461
|
+
get: function () { return chunkW4PALSGM_js.SignalBridge; }
|
|
2462
|
+
});
|
|
2463
|
+
Object.defineProperty(exports, "useSignal", {
|
|
2464
|
+
enumerable: true,
|
|
2465
|
+
get: function () { return chunkW4PALSGM_js.useSignal; }
|
|
2466
|
+
});
|
|
2467
|
+
Object.defineProperty(exports, "useSignalConfig", {
|
|
2468
|
+
enumerable: true,
|
|
2469
|
+
get: function () { return chunkW4PALSGM_js.useSignalConfig; }
|
|
2470
|
+
});
|
|
2471
|
+
Object.defineProperty(exports, "useSignalEvent", {
|
|
2472
|
+
enumerable: true,
|
|
2473
|
+
get: function () { return chunkW4PALSGM_js.useSignalEvent; }
|
|
2474
|
+
});
|
|
2475
|
+
Object.defineProperty(exports, "useSignalExperiment", {
|
|
2476
|
+
enumerable: true,
|
|
2477
|
+
get: function () { return chunkW4PALSGM_js.useSignalExperiment; }
|
|
2478
|
+
});
|
|
2479
|
+
Object.defineProperty(exports, "useSignalOutcome", {
|
|
2480
|
+
enumerable: true,
|
|
2481
|
+
get: function () { return chunkW4PALSGM_js.useSignalOutcome; }
|
|
2482
|
+
});
|
|
2483
|
+
Object.defineProperty(exports, "CalendarView", {
|
|
2484
|
+
enumerable: true,
|
|
2485
|
+
get: function () { return chunkUYFDNX2F_js.CalendarView; }
|
|
2486
|
+
});
|
|
2487
|
+
Object.defineProperty(exports, "CheckoutForm", {
|
|
2488
|
+
enumerable: true,
|
|
2489
|
+
get: function () { return chunkUYFDNX2F_js.CheckoutForm; }
|
|
2490
|
+
});
|
|
2491
|
+
Object.defineProperty(exports, "EventCalendar", {
|
|
2492
|
+
enumerable: true,
|
|
2493
|
+
get: function () { return chunkUYFDNX2F_js.EventCalendar; }
|
|
2494
|
+
});
|
|
2495
|
+
Object.defineProperty(exports, "EventEmbed", {
|
|
2496
|
+
enumerable: true,
|
|
2497
|
+
get: function () { return chunkUYFDNX2F_js.EventEmbed; }
|
|
2498
|
+
});
|
|
2499
|
+
Object.defineProperty(exports, "EventModal", {
|
|
2500
|
+
enumerable: true,
|
|
2501
|
+
get: function () { return chunkUYFDNX2F_js.EventModal; }
|
|
2502
|
+
});
|
|
2503
|
+
Object.defineProperty(exports, "EventTile", {
|
|
2504
|
+
enumerable: true,
|
|
2505
|
+
get: function () { return chunkUYFDNX2F_js.EventTile; }
|
|
2506
|
+
});
|
|
2507
|
+
Object.defineProperty(exports, "OfferingCard", {
|
|
2508
|
+
enumerable: true,
|
|
2509
|
+
get: function () { return chunkUYFDNX2F_js.OfferingCard; }
|
|
2510
|
+
});
|
|
2511
|
+
Object.defineProperty(exports, "OfferingList", {
|
|
2512
|
+
enumerable: true,
|
|
2513
|
+
get: function () { return chunkUYFDNX2F_js.OfferingList; }
|
|
2514
|
+
});
|
|
2515
|
+
Object.defineProperty(exports, "ProductEmbed", {
|
|
2516
|
+
enumerable: true,
|
|
2517
|
+
get: function () { return chunkUYFDNX2F_js.ProductEmbed; }
|
|
2518
|
+
});
|
|
2519
|
+
Object.defineProperty(exports, "RegistrationForm", {
|
|
2520
|
+
enumerable: true,
|
|
2521
|
+
get: function () { return chunkUYFDNX2F_js.RegistrationForm; }
|
|
2522
|
+
});
|
|
2523
|
+
Object.defineProperty(exports, "UpcomingEvents", {
|
|
2524
|
+
enumerable: true,
|
|
2525
|
+
get: function () { return chunkUYFDNX2F_js.UpcomingEvents; }
|
|
2526
|
+
});
|
|
2527
|
+
Object.defineProperty(exports, "createCheckoutSession", {
|
|
2528
|
+
enumerable: true,
|
|
2529
|
+
get: function () { return chunkUYFDNX2F_js.createCheckoutSession; }
|
|
2530
|
+
});
|
|
2531
|
+
Object.defineProperty(exports, "fetchNextEvent", {
|
|
2532
|
+
enumerable: true,
|
|
2533
|
+
get: function () { return chunkUYFDNX2F_js.fetchNextEvent; }
|
|
2534
|
+
});
|
|
2535
|
+
Object.defineProperty(exports, "fetchOffering", {
|
|
2536
|
+
enumerable: true,
|
|
2537
|
+
get: function () { return chunkUYFDNX2F_js.fetchOffering; }
|
|
2538
|
+
});
|
|
2539
|
+
Object.defineProperty(exports, "fetchOfferings", {
|
|
2540
|
+
enumerable: true,
|
|
2541
|
+
get: function () { return chunkUYFDNX2F_js.fetchOfferings; }
|
|
2542
|
+
});
|
|
2543
|
+
Object.defineProperty(exports, "fetchProducts", {
|
|
2544
|
+
enumerable: true,
|
|
2545
|
+
get: function () { return chunkUYFDNX2F_js.fetchProducts; }
|
|
2546
|
+
});
|
|
2547
|
+
Object.defineProperty(exports, "fetchServices", {
|
|
2548
|
+
enumerable: true,
|
|
2549
|
+
get: function () { return chunkUYFDNX2F_js.fetchServices; }
|
|
2550
|
+
});
|
|
2551
|
+
Object.defineProperty(exports, "fetchUpcomingEvents", {
|
|
2552
|
+
enumerable: true,
|
|
2553
|
+
get: function () { return chunkUYFDNX2F_js.fetchUpcomingEvents; }
|
|
2554
|
+
});
|
|
2555
|
+
Object.defineProperty(exports, "formatDate", {
|
|
2556
|
+
enumerable: true,
|
|
2557
|
+
get: function () { return chunkUYFDNX2F_js.formatDate; }
|
|
2558
|
+
});
|
|
2559
|
+
Object.defineProperty(exports, "formatDateTime", {
|
|
2560
|
+
enumerable: true,
|
|
2561
|
+
get: function () { return chunkUYFDNX2F_js.formatDateTime; }
|
|
2562
|
+
});
|
|
2563
|
+
Object.defineProperty(exports, "formatPrice", {
|
|
2564
|
+
enumerable: true,
|
|
2565
|
+
get: function () { return chunkUYFDNX2F_js.formatPrice; }
|
|
2566
|
+
});
|
|
2567
|
+
Object.defineProperty(exports, "getOfferingUrl", {
|
|
2568
|
+
enumerable: true,
|
|
2569
|
+
get: function () { return chunkUYFDNX2F_js.getOfferingUrl; }
|
|
2570
|
+
});
|
|
2571
|
+
Object.defineProperty(exports, "registerForEvent", {
|
|
2572
|
+
enumerable: true,
|
|
2573
|
+
get: function () { return chunkUYFDNX2F_js.registerForEvent; }
|
|
2574
|
+
});
|
|
2575
|
+
Object.defineProperty(exports, "useEventModal", {
|
|
2576
|
+
enumerable: true,
|
|
2577
|
+
get: function () { return chunkUYFDNX2F_js.useEventModal; }
|
|
2578
|
+
});
|
|
2579
|
+
Object.defineProperty(exports, "SetupWizard", {
|
|
2580
|
+
enumerable: true,
|
|
2581
|
+
get: function () { return chunk72MQFHYJ_js.SetupWizard; }
|
|
2582
|
+
});
|
|
2583
|
+
Object.defineProperty(exports, "clearRedirectCache", {
|
|
2584
|
+
enumerable: true,
|
|
2585
|
+
get: function () { return chunkLBVWVP72_js.clearRedirectCache; }
|
|
2586
|
+
});
|
|
2587
|
+
Object.defineProperty(exports, "fetchRedirectRules", {
|
|
2588
|
+
enumerable: true,
|
|
2589
|
+
get: function () { return chunkLBVWVP72_js.fetchRedirectRules; }
|
|
2590
|
+
});
|
|
2591
|
+
Object.defineProperty(exports, "generateNextRedirects", {
|
|
2592
|
+
enumerable: true,
|
|
2593
|
+
get: function () { return chunkLBVWVP72_js.generateNextRedirects; }
|
|
2594
|
+
});
|
|
2595
|
+
Object.defineProperty(exports, "handleManagedRedirects", {
|
|
2596
|
+
enumerable: true,
|
|
2597
|
+
get: function () { return chunkLBVWVP72_js.handleManagedRedirects; }
|
|
2598
|
+
});
|
|
2599
|
+
exports.AffiliateCard = AffiliateCard;
|
|
2600
|
+
exports.AffiliatesWidget = AffiliatesWidget;
|
|
2601
|
+
exports.BookingWidget = BookingWidget;
|
|
2602
|
+
exports.ExperimentConversion = ExperimentConversion;
|
|
2603
|
+
exports.SetupAssistant = SetupAssistant;
|
|
2604
|
+
exports.SignalExperiment = SignalExperiment;
|
|
2605
|
+
exports.SiteKitProvider = SiteKitProvider;
|
|
2606
|
+
exports.createBooking = createBooking;
|
|
2607
|
+
exports.createSlotHold = createSlotHold;
|
|
2608
|
+
exports.detectTimezone = detectTimezone;
|
|
2609
|
+
exports.fetchAffiliates = fetchAffiliates;
|
|
2610
|
+
exports.fetchAvailability = fetchAvailability;
|
|
2611
|
+
exports.fetchAvailableDates = fetchAvailableDates;
|
|
2612
|
+
exports.fetchBookingTypeDetails = fetchBookingTypeDetails;
|
|
2613
|
+
exports.fetchBookingTypes = fetchBookingTypes;
|
|
2614
|
+
exports.formatBookingDate = formatDate2;
|
|
2615
|
+
exports.formatBookingTime = formatTime;
|
|
2616
|
+
exports.formatDuration = formatDuration;
|
|
2617
|
+
exports.getTrackingUrl = getTrackingUrl;
|
|
2618
|
+
exports.releaseSlotHold = releaseSlotHold;
|
|
2619
|
+
exports.useAffiliates = useAffiliates;
|
|
2620
|
+
exports.useExperimentVariant = useExperimentVariant;
|
|
2621
|
+
exports.useSiteKit = useSiteKit;
|
|
2622
|
+
//# sourceMappingURL=index.js.map
|
|
2623
|
+
//# sourceMappingURL=index.js.map
|