@shiva004/surveys 0.1.8 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -1
- package/dist/App.d.ts +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +918 -296
- package/dist/journey/JourneyApp.d.ts +1 -1
- package/dist/journey/analytics.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/survey/SurveyApp.d.ts +1 -1
- package/dist/survey/data.d.ts +1 -1
- package/dist/survey/nps.d.ts +1 -1
- package/dist/ui.d.ts +1 -1
- package/dist/walkthrough/JourneyProvider.d.ts +27 -0
- package/dist/walkthrough/TourOverlay.d.ts +23 -0
- package/dist/walkthrough/WalkthroughDemo.d.ts +11 -0
- package/dist/walkthrough/index.d.ts +7 -0
- package/dist/walkthrough/tour.d.ts +39 -0
- package/dist/walkthrough/tracker.d.ts +83 -0
- package/package.json +13 -14
- package/dist/index.cjs +0 -1
- package/dist/main.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { jsxs as r, jsx as e, Fragment as ae } from "react/jsx-runtime";
|
|
2
|
+
import ge, { useState as y, useMemo as Y, useRef as _, useCallback as L, useLayoutEffect as xe, useEffect as B, useContext as je, useSyncExternalStore as Ce, createContext as Te } from "react";
|
|
3
|
+
import { createPortal as ve } from "react-dom";
|
|
4
|
+
const q = ({ label: t, value: a, color: n = "#7c3aed" }) => /* @__PURE__ */ r("div", { className: "stat", style: { borderTopColor: n }, children: [
|
|
4
5
|
/* @__PURE__ */ e("div", { className: "stat-label", children: t }),
|
|
5
|
-
/* @__PURE__ */ e("div", { className: "stat-value", children:
|
|
6
|
-
] }),
|
|
7
|
-
/* @__PURE__ */
|
|
8
|
-
/* @__PURE__ */
|
|
6
|
+
/* @__PURE__ */ e("div", { className: "stat-value", children: a })
|
|
7
|
+
] }), fe = ({ items: t, value: a, onChange: n }) => /* @__PURE__ */ e("div", { className: "tabs", children: t.map((s) => /* @__PURE__ */ e("button", { type: "button", className: s.id === a ? "tab active" : "tab", onClick: () => n(s.id), children: s.label }, s.id)) }), K = ({ pct: t, color: a = "#7c3aed" }) => /* @__PURE__ */ e("div", { className: "bar", children: /* @__PURE__ */ e("div", { className: "bar-fill", style: { width: `${Math.max(0, Math.min(100, t))}%`, background: a } }) }), ee = ({ title: t, subtitle: a, actions: n, children: s }) => /* @__PURE__ */ r("section", { children: [
|
|
8
|
+
/* @__PURE__ */ r("div", { className: "page-head", children: [
|
|
9
|
+
/* @__PURE__ */ r("div", { children: [
|
|
9
10
|
/* @__PURE__ */ e("h2", { children: t }),
|
|
10
|
-
|
|
11
|
+
a && /* @__PURE__ */ e("p", { className: "muted", children: a })
|
|
11
12
|
] }),
|
|
12
|
-
/* @__PURE__ */ e("div", { className: "actions", children:
|
|
13
|
+
/* @__PURE__ */ e("div", { className: "actions", children: n })
|
|
13
14
|
] }),
|
|
14
15
|
s
|
|
15
|
-
] }),
|
|
16
|
+
] }), be = (t) => () => {
|
|
16
17
|
t |= 0, t = t + 1831565813 | 0;
|
|
17
|
-
let
|
|
18
|
-
return
|
|
19
|
-
},
|
|
18
|
+
let a = Math.imul(t ^ t >>> 15, 1 | t);
|
|
19
|
+
return a = a + Math.imul(a ^ a >>> 7, 61 | a) ^ a, ((a ^ a >>> 14) >>> 0) / 4294967296;
|
|
20
|
+
}, Z = (t) => `${t}_${Math.random().toString(36).slice(2, 8)}`, Ie = ["/home", "/pricing", "/features", "/docs", "/signup", "/dashboard", "/checkout"], Me = [["/home", 0.55], ["/pricing", 0.15], ["/features", 0.15], ["/docs", 0.15]], Ee = {
|
|
20
21
|
"/home": [["/pricing", 0.3], ["/features", 0.3], ["/docs", 0.1], ["/signup", 0.1], ["EXIT", 0.2]],
|
|
21
22
|
"/pricing": [["/signup", 0.3], ["/features", 0.15], ["/home", 0.1], ["EXIT", 0.45]],
|
|
22
23
|
"/features": [["/pricing", 0.3], ["/signup", 0.15], ["/docs", 0.15], ["EXIT", 0.4]],
|
|
@@ -24,63 +25,63 @@ const y = ({ label: t, value: i, color: a = "#7c3aed" }) => /* @__PURE__ */ n("d
|
|
|
24
25
|
"/signup": [["/dashboard", 0.6], ["EXIT", 0.4]],
|
|
25
26
|
"/dashboard": [["/checkout", 0.25], ["/docs", 0.15], ["/features", 0.1], ["EXIT", 0.5]],
|
|
26
27
|
"/checkout": [["EXIT", 1]]
|
|
27
|
-
},
|
|
28
|
-
let
|
|
29
|
-
for (const [s,
|
|
30
|
-
if (
|
|
28
|
+
}, he = (t, a) => {
|
|
29
|
+
let n = 0;
|
|
30
|
+
for (const [s, i] of t)
|
|
31
|
+
if (n += i, a < n) return s;
|
|
31
32
|
return t[t.length - 1][0];
|
|
32
33
|
};
|
|
33
|
-
function
|
|
34
|
+
function we(t, a) {
|
|
34
35
|
return Array.from({ length: t }, () => {
|
|
35
|
-
let
|
|
36
|
-
const s = [
|
|
36
|
+
let n = he(Me, a());
|
|
37
|
+
const s = [n];
|
|
37
38
|
for (; s.length < 8; ) {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
s.push(
|
|
39
|
+
const i = he(Ee[n], a());
|
|
40
|
+
if (i === "EXIT") break;
|
|
41
|
+
s.push(i), n = i;
|
|
41
42
|
}
|
|
42
43
|
return s;
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
|
-
const
|
|
46
|
-
function
|
|
47
|
-
const
|
|
46
|
+
const Ae = () => we(400, be(42));
|
|
47
|
+
function Pe(t) {
|
|
48
|
+
const a = /* @__PURE__ */ new Map(), n = (s) => (a.has(s) || a.set(s, { views: 0, entries: 0, bounces: 0, exits: 0 }), a.get(s));
|
|
48
49
|
for (const s of t)
|
|
49
|
-
s.forEach((
|
|
50
|
-
|
|
51
|
-
}),
|
|
52
|
-
return [...
|
|
50
|
+
s.forEach((i) => {
|
|
51
|
+
n(i).views += 1;
|
|
52
|
+
}), n(s[0]).entries += 1, s.length === 1 && (n(s[0]).bounces += 1), n(s[s.length - 1]).exits += 1;
|
|
53
|
+
return [...a.entries()].map(([s, i]) => ({
|
|
53
54
|
page: s,
|
|
54
|
-
views:
|
|
55
|
-
bounceRate:
|
|
56
|
-
exitRate:
|
|
57
|
-
})).sort((s,
|
|
55
|
+
views: i.views,
|
|
56
|
+
bounceRate: i.entries ? i.bounces / i.entries * 100 : 0,
|
|
57
|
+
exitRate: i.views ? i.exits / i.views * 100 : 0
|
|
58
|
+
})).sort((s, i) => i.views - s.views);
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
-
const
|
|
60
|
+
function Re(t, a = 8) {
|
|
61
|
+
const n = /* @__PURE__ */ new Map();
|
|
61
62
|
for (const s of t) {
|
|
62
|
-
const
|
|
63
|
-
|
|
63
|
+
const i = s.slice(0, 4), m = i.join(">"), f = n.get(m) ?? { steps: i, users: 0, conv: 0 };
|
|
64
|
+
f.users += 1, s.includes("/signup") && (f.conv += 1), n.set(m, f);
|
|
64
65
|
}
|
|
65
|
-
return [...
|
|
66
|
+
return [...n.values()].map((s) => ({ steps: s.steps, users: s.users, convRate: s.conv / s.users * 100 })).sort((s, i) => i.users - s.users).slice(0, a);
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
-
const
|
|
69
|
-
for (const
|
|
70
|
-
for (let s = 0; s <
|
|
71
|
-
const
|
|
72
|
-
|
|
68
|
+
function $e(t) {
|
|
69
|
+
const a = /* @__PURE__ */ new Map();
|
|
70
|
+
for (const n of t)
|
|
71
|
+
for (let s = 0; s < n.length - 1; s++) {
|
|
72
|
+
const i = a.get(n[s]) ?? /* @__PURE__ */ new Map();
|
|
73
|
+
i.set(n[s + 1], (i.get(n[s + 1]) ?? 0) + 1), a.set(n[s], i);
|
|
73
74
|
}
|
|
74
|
-
return [...
|
|
75
|
-
const
|
|
75
|
+
return [...a.entries()].map(([n, s]) => {
|
|
76
|
+
const i = [...s.values()].reduce((m, f) => m + f, 0);
|
|
76
77
|
return {
|
|
77
|
-
from:
|
|
78
|
-
total:
|
|
79
|
-
destinations: [...s.entries()].map(([
|
|
78
|
+
from: n,
|
|
79
|
+
total: i,
|
|
80
|
+
destinations: [...s.entries()].map(([m, f]) => ({ to: m, pct: f / i * 100 })).sort((m, f) => f.pct - m.pct)
|
|
80
81
|
};
|
|
81
|
-
}).sort((
|
|
82
|
+
}).sort((n, s) => s.total - n.total);
|
|
82
83
|
}
|
|
83
|
-
const
|
|
84
|
+
const Le = (t, a) => t.length ? t.filter((n) => n.some((s) => a.includes(s))).length / t.length * 100 : 0, qe = {
|
|
84
85
|
id: "jm1",
|
|
85
86
|
name: "New customer journey",
|
|
86
87
|
stages: [
|
|
@@ -90,158 +91,158 @@ const G = (t, i) => t.length ? t.filter((a) => a.some((s) => i.includes(s))).len
|
|
|
90
91
|
{ id: "st4", name: "Activation", emotion: "engaged", pages: ["/dashboard"] },
|
|
91
92
|
{ id: "st5", name: "Purchase", emotion: "satisfied", pages: ["/checkout"] }
|
|
92
93
|
]
|
|
93
|
-
},
|
|
94
|
+
}, Oe = [
|
|
94
95
|
{ id: "nav", label: "Navigation Analysis" },
|
|
95
96
|
{ id: "paths", label: "Paths" },
|
|
96
97
|
{ id: "flows", label: "Userflows" },
|
|
97
98
|
{ id: "maps", label: "Journey Maps" }
|
|
98
|
-
],
|
|
99
|
-
var
|
|
100
|
-
const [t,
|
|
101
|
-
return /* @__PURE__ */
|
|
102
|
-
|
|
99
|
+
], ue = { curious: "#adc6ff", analytical: "#7c3aed", confident: "#4edea3", engaged: "#d2bbff", satisfied: "#ffcc6b", cautious: "#ffb4ab" }, _e = (t) => t.split("/").filter(Boolean).pop() ?? t, Fe = (t) => t > 25 ? "#ffb4ab" : t > 15 ? "#ffcc6b" : "#4edea3", De = () => {
|
|
100
|
+
var u;
|
|
101
|
+
const [t, a] = y("nav"), [n, s] = y(Ae), [i, m] = y(qe), f = Y(() => Pe(n), [n]), g = Y(() => Re(n), [n]), w = Y(() => $e(n), [n]), c = f.reduce((h, l) => h + l.views, 0), d = n.length, o = n.filter((h) => h.length === 1).length;
|
|
102
|
+
return /* @__PURE__ */ r(
|
|
103
|
+
ee,
|
|
103
104
|
{
|
|
104
105
|
title: "User Journey",
|
|
105
106
|
subtitle: "One stream of page views feeds every view below.",
|
|
106
|
-
actions: /* @__PURE__ */ e("button", { className: "btn primary", onClick: () => s((
|
|
107
|
+
actions: /* @__PURE__ */ e("button", { className: "btn primary", onClick: () => s((h) => [...h, ...we(50, Math.random)]), children: "+ Simulate 50 sessions" }),
|
|
107
108
|
children: [
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
-
/* @__PURE__ */ e(
|
|
110
|
-
/* @__PURE__ */ e(
|
|
111
|
-
/* @__PURE__ */ e(
|
|
112
|
-
/* @__PURE__ */ e(
|
|
109
|
+
/* @__PURE__ */ r("div", { className: "stats", children: [
|
|
110
|
+
/* @__PURE__ */ e(q, { label: "Sessions", value: d.toLocaleString(), color: "#6366f1" }),
|
|
111
|
+
/* @__PURE__ */ e(q, { label: "Page views", value: c.toLocaleString(), color: "#0ea5e9" }),
|
|
112
|
+
/* @__PURE__ */ e(q, { label: "Bounce rate", value: `${d ? (o / d * 100).toFixed(1) : 0}%`, color: "#f59e0b" }),
|
|
113
|
+
/* @__PURE__ */ e(q, { label: "Top page", value: ((u = f[0]) == null ? void 0 : u.page) ?? "—", color: "#10b981" })
|
|
113
114
|
] }),
|
|
114
|
-
/* @__PURE__ */ e(
|
|
115
|
-
t === "nav" && /* @__PURE__ */
|
|
116
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */
|
|
115
|
+
/* @__PURE__ */ e(fe, { items: Oe, value: t, onChange: a }),
|
|
116
|
+
t === "nav" && /* @__PURE__ */ r("table", { className: "table", children: [
|
|
117
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ r("tr", { children: [
|
|
117
118
|
/* @__PURE__ */ e("th", { children: "Page" }),
|
|
118
119
|
/* @__PURE__ */ e("th", { children: "Views" }),
|
|
119
120
|
/* @__PURE__ */ e("th", { children: "Share" }),
|
|
120
121
|
/* @__PURE__ */ e("th", { children: "Bounce rate" }),
|
|
121
122
|
/* @__PURE__ */ e("th", { children: "Exit rate" })
|
|
122
123
|
] }) }),
|
|
123
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
124
|
-
/* @__PURE__ */ e("td", { className: "mono", children:
|
|
125
|
-
/* @__PURE__ */ e("td", { className: "mono", children:
|
|
126
|
-
/* @__PURE__ */ e("td", { style: { minWidth: 120 }, children: /* @__PURE__ */ e(
|
|
127
|
-
/* @__PURE__ */
|
|
128
|
-
|
|
124
|
+
/* @__PURE__ */ e("tbody", { children: f.map((h) => /* @__PURE__ */ r("tr", { children: [
|
|
125
|
+
/* @__PURE__ */ e("td", { className: "mono", children: h.page }),
|
|
126
|
+
/* @__PURE__ */ e("td", { className: "mono", children: h.views }),
|
|
127
|
+
/* @__PURE__ */ e("td", { style: { minWidth: 120 }, children: /* @__PURE__ */ e(K, { pct: h.views / c * 100 }) }),
|
|
128
|
+
/* @__PURE__ */ r("td", { className: "mono", style: { color: Fe(h.bounceRate) }, children: [
|
|
129
|
+
h.bounceRate.toFixed(1),
|
|
129
130
|
"%"
|
|
130
131
|
] }),
|
|
131
|
-
/* @__PURE__ */
|
|
132
|
-
|
|
132
|
+
/* @__PURE__ */ r("td", { className: "mono", children: [
|
|
133
|
+
h.exitRate.toFixed(1),
|
|
133
134
|
"%"
|
|
134
135
|
] })
|
|
135
|
-
] },
|
|
136
|
+
] }, h.page)) })
|
|
136
137
|
] }),
|
|
137
|
-
t === "paths" && /* @__PURE__ */ e("div", { className: "grid", children:
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
-
/* @__PURE__ */
|
|
138
|
+
t === "paths" && /* @__PURE__ */ e("div", { className: "grid", children: g.map((h, l) => /* @__PURE__ */ r("div", { className: "card", children: [
|
|
139
|
+
/* @__PURE__ */ r("div", { className: "row", children: [
|
|
140
|
+
/* @__PURE__ */ r("span", { className: "pill passive", children: [
|
|
140
141
|
"#",
|
|
141
142
|
l + 1
|
|
142
143
|
] }),
|
|
143
144
|
/* @__PURE__ */ e("span", { className: "grow" }),
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
|
|
145
|
+
/* @__PURE__ */ r("span", { className: "mono small", children: [
|
|
146
|
+
h.convRate.toFixed(1),
|
|
146
147
|
"% reach signup"
|
|
147
148
|
] })
|
|
148
149
|
] }),
|
|
149
|
-
/* @__PURE__ */ e("div", { className: "steps", title:
|
|
150
|
+
/* @__PURE__ */ e("div", { className: "steps", title: h.steps.join(" → "), children: h.steps.map((k, v) => /* @__PURE__ */ r(ge.Fragment, { children: [
|
|
150
151
|
v > 0 && /* @__PURE__ */ e("span", { className: "muted", children: "→" }),
|
|
151
|
-
/* @__PURE__ */ e("span", { className: "chip static", children:
|
|
152
|
+
/* @__PURE__ */ e("span", { className: "chip static", children: _e(k) })
|
|
152
153
|
] }, v)) }),
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
|
|
154
|
+
/* @__PURE__ */ r("div", { className: "small muted", children: [
|
|
155
|
+
h.users,
|
|
155
156
|
" users"
|
|
156
157
|
] }),
|
|
157
|
-
/* @__PURE__ */ e(
|
|
158
|
-
] },
|
|
159
|
-
t === "flows" && /* @__PURE__ */ e("div", { className: "grid", children:
|
|
160
|
-
/* @__PURE__ */
|
|
161
|
-
/* @__PURE__ */ e("strong", { className: "mono", children:
|
|
158
|
+
/* @__PURE__ */ e(K, { pct: h.convRate, color: "#10b981" })
|
|
159
|
+
] }, h.steps.join(">"))) }),
|
|
160
|
+
t === "flows" && /* @__PURE__ */ e("div", { className: "grid", children: w.map((h) => /* @__PURE__ */ r("div", { className: "card", children: [
|
|
161
|
+
/* @__PURE__ */ r("div", { className: "row", children: [
|
|
162
|
+
/* @__PURE__ */ e("strong", { className: "mono", children: h.from }),
|
|
162
163
|
/* @__PURE__ */ e("span", { className: "grow" }),
|
|
163
|
-
/* @__PURE__ */
|
|
164
|
-
|
|
164
|
+
/* @__PURE__ */ r("span", { className: "small muted", children: [
|
|
165
|
+
h.total,
|
|
165
166
|
" transitions"
|
|
166
167
|
] })
|
|
167
168
|
] }),
|
|
168
|
-
|
|
169
|
-
/* @__PURE__ */
|
|
170
|
-
/* @__PURE__ */
|
|
169
|
+
h.destinations.slice(0, 4).map((l) => /* @__PURE__ */ r("div", { children: [
|
|
170
|
+
/* @__PURE__ */ r("div", { className: "row small", children: [
|
|
171
|
+
/* @__PURE__ */ r("span", { className: "mono", children: [
|
|
171
172
|
"→ ",
|
|
172
173
|
l.to
|
|
173
174
|
] }),
|
|
174
175
|
/* @__PURE__ */ e("span", { className: "grow" }),
|
|
175
|
-
/* @__PURE__ */
|
|
176
|
+
/* @__PURE__ */ r("span", { className: "mono", children: [
|
|
176
177
|
l.pct.toFixed(0),
|
|
177
178
|
"%"
|
|
178
179
|
] })
|
|
179
180
|
] }),
|
|
180
|
-
/* @__PURE__ */ e(
|
|
181
|
+
/* @__PURE__ */ e(K, { pct: l.pct })
|
|
181
182
|
] }, l.to))
|
|
182
|
-
] },
|
|
183
|
-
t === "maps" && /* @__PURE__ */ e(
|
|
183
|
+
] }, h.from)) }),
|
|
184
|
+
t === "maps" && /* @__PURE__ */ e(Je, { map: i, setMap: m, sessions: n })
|
|
184
185
|
]
|
|
185
186
|
}
|
|
186
187
|
);
|
|
187
|
-
},
|
|
188
|
-
const [s,
|
|
189
|
-
if (!s.trim()) return
|
|
190
|
-
if (
|
|
191
|
-
const
|
|
192
|
-
|
|
188
|
+
}, Je = ({ map: t, setMap: a, sessions: n }) => {
|
|
189
|
+
const [s, i] = y(""), [m, f] = y("curious"), [g, w] = y([]), [c, d] = y(""), o = () => {
|
|
190
|
+
if (!s.trim()) return d("Stage name is required.");
|
|
191
|
+
if (g.length === 0) return d("Pick at least one touchpoint page.");
|
|
192
|
+
const u = { id: Z("st"), name: s.trim(), emotion: m, pages: g };
|
|
193
|
+
a({ ...t, stages: [...t.stages, u] }), i(""), w([]), d("");
|
|
193
194
|
};
|
|
194
|
-
return /* @__PURE__ */
|
|
195
|
-
/* @__PURE__ */ e("input", { className: "input", value: t.name, onChange: (
|
|
196
|
-
/* @__PURE__ */
|
|
197
|
-
t.stages.map((
|
|
198
|
-
const l =
|
|
199
|
-
return /* @__PURE__ */
|
|
200
|
-
/* @__PURE__ */
|
|
201
|
-
/* @__PURE__ */ e("span", { className: "badge", style: { background: `${
|
|
202
|
-
/* @__PURE__ */ e("strong", { children:
|
|
195
|
+
return /* @__PURE__ */ r("div", { className: "stack", children: [
|
|
196
|
+
/* @__PURE__ */ e("input", { className: "input", value: t.name, onChange: (u) => a({ ...t, name: u.target.value }), "aria-label": "Journey name" }),
|
|
197
|
+
/* @__PURE__ */ r("div", { className: "stages", children: [
|
|
198
|
+
t.stages.map((u, h) => {
|
|
199
|
+
const l = Le(n, u.pages), k = ue[u.emotion] ?? "#7c3aed";
|
|
200
|
+
return /* @__PURE__ */ r("div", { className: "card stage", children: [
|
|
201
|
+
/* @__PURE__ */ r("div", { className: "row", children: [
|
|
202
|
+
/* @__PURE__ */ e("span", { className: "badge", style: { background: `${k}30`, color: k }, children: h + 1 }),
|
|
203
|
+
/* @__PURE__ */ e("strong", { children: u.name }),
|
|
203
204
|
/* @__PURE__ */ e("span", { className: "grow" }),
|
|
204
|
-
/* @__PURE__ */ e("button", { className: "btn danger", "aria-label": `Remove ${
|
|
205
|
+
/* @__PURE__ */ e("button", { className: "btn danger", "aria-label": `Remove ${u.name}`, onClick: () => a({ ...t, stages: t.stages.filter((v) => v.id !== u.id) }), children: "✕" })
|
|
205
206
|
] }),
|
|
206
|
-
|
|
207
|
+
u.pages.map((v) => /* @__PURE__ */ r("div", { className: "small mono muted", children: [
|
|
207
208
|
"✓ ",
|
|
208
209
|
v
|
|
209
210
|
] }, v)),
|
|
210
|
-
/* @__PURE__ */
|
|
211
|
+
/* @__PURE__ */ r("div", { className: "small", style: { color: k }, children: [
|
|
211
212
|
"Emotion: ",
|
|
212
|
-
|
|
213
|
+
u.emotion
|
|
213
214
|
] }),
|
|
214
|
-
/* @__PURE__ */ e(
|
|
215
|
-
/* @__PURE__ */
|
|
215
|
+
/* @__PURE__ */ e(K, { pct: l }),
|
|
216
|
+
/* @__PURE__ */ r("div", { className: "small mono muted", children: [
|
|
216
217
|
l.toFixed(0),
|
|
217
218
|
"% reach"
|
|
218
219
|
] })
|
|
219
|
-
] },
|
|
220
|
+
] }, u.id);
|
|
220
221
|
}),
|
|
221
222
|
t.stages.length === 0 && /* @__PURE__ */ e("div", { className: "muted", children: "No stages yet. Add one below." })
|
|
222
223
|
] }),
|
|
223
|
-
/* @__PURE__ */
|
|
224
|
+
/* @__PURE__ */ r("div", { className: "card form", children: [
|
|
224
225
|
/* @__PURE__ */ e("strong", { children: "Add stage" }),
|
|
225
|
-
/* @__PURE__ */
|
|
226
|
-
/* @__PURE__ */ e("input", { className: "input", placeholder: "Stage name", value: s, onChange: (
|
|
227
|
-
/* @__PURE__ */ e("select", { className: "input slim", value:
|
|
226
|
+
/* @__PURE__ */ r("div", { className: "row", children: [
|
|
227
|
+
/* @__PURE__ */ e("input", { className: "input", placeholder: "Stage name", value: s, onChange: (u) => i(u.target.value) }),
|
|
228
|
+
/* @__PURE__ */ e("select", { className: "input slim", value: m, onChange: (u) => f(u.target.value), children: Object.keys(ue).map((u) => /* @__PURE__ */ e("option", { children: u }, u)) })
|
|
228
229
|
] }),
|
|
229
|
-
/* @__PURE__ */ e("div", { className: "scale", children:
|
|
230
|
-
/* @__PURE__ */
|
|
230
|
+
/* @__PURE__ */ e("div", { className: "scale", children: Ie.map((u) => /* @__PURE__ */ e("button", { type: "button", className: g.includes(u) ? "chip active" : "chip", onClick: () => w((h) => h.includes(u) ? h.filter((l) => l !== u) : [...h, u]), children: u }, u)) }),
|
|
231
|
+
/* @__PURE__ */ r("div", { className: "row", children: [
|
|
231
232
|
/* @__PURE__ */ e("span", { className: "grow" }),
|
|
232
|
-
|
|
233
|
-
/* @__PURE__ */ e("button", { className: "btn primary", onClick:
|
|
233
|
+
c && /* @__PURE__ */ e("span", { className: "error", children: c }),
|
|
234
|
+
/* @__PURE__ */ e("button", { className: "btn primary", onClick: o, children: "+ Add stage" })
|
|
234
235
|
] })
|
|
235
236
|
] })
|
|
236
237
|
] });
|
|
237
|
-
},
|
|
238
|
+
}, oe = (t) => new Date(Date.UTC(2026, 10, 6) - t * 864e5).toISOString(), Be = [
|
|
238
239
|
{
|
|
239
240
|
id: "s1",
|
|
240
241
|
name: "Q4 Product Satisfaction",
|
|
241
242
|
description: "How do users feel about the product right now?",
|
|
242
243
|
status: "active",
|
|
243
244
|
target: 100,
|
|
244
|
-
createdAt:
|
|
245
|
+
createdAt: oe(30),
|
|
245
246
|
questions: [
|
|
246
247
|
{ id: "s1q1", type: "nps", text: "How likely are you to recommend us to a colleague?", required: !0 },
|
|
247
248
|
{ id: "s1q2", type: "rating", text: "How satisfied are you with the product?", required: !0 },
|
|
@@ -255,95 +256,95 @@ const G = (t, i) => t.length ? t.filter((a) => a.some((s) => i.includes(s))).len
|
|
|
255
256
|
description: "First-week feedback from new accounts.",
|
|
256
257
|
status: "draft",
|
|
257
258
|
target: 50,
|
|
258
|
-
createdAt:
|
|
259
|
+
createdAt: oe(5),
|
|
259
260
|
questions: [
|
|
260
261
|
{ id: "s2q1", type: "nps", text: "How likely are you to recommend our onboarding?", required: !0 },
|
|
261
262
|
{ id: "s2q2", type: "open_text", text: "What was confusing?", required: !1 }
|
|
262
263
|
]
|
|
263
264
|
}
|
|
264
|
-
],
|
|
265
|
-
function
|
|
266
|
-
const t =
|
|
267
|
-
return Array.from({ length: 36 }, (
|
|
265
|
+
], me = ["Love the rollout controls", "Dashboards load slowly", "Needs better docs", "Great support", "Too many clicks to create a flag"];
|
|
266
|
+
function We() {
|
|
267
|
+
const t = be(7);
|
|
268
|
+
return Array.from({ length: 36 }, (a, n) => {
|
|
268
269
|
const s = Math.min(10, Math.floor(t() * t() * 4 + t() * 8 + 3));
|
|
269
270
|
return {
|
|
270
|
-
id: `r${
|
|
271
|
+
id: `r${n}`,
|
|
271
272
|
surveyId: "s1",
|
|
272
|
-
userId: `user_${100 +
|
|
273
|
-
createdAt:
|
|
273
|
+
userId: `user_${100 + n}`,
|
|
274
|
+
createdAt: oe(Math.floor(t() * 28)),
|
|
274
275
|
answers: [
|
|
275
276
|
{ questionId: "s1q1", value: s },
|
|
276
277
|
{ questionId: "s1q2", value: Math.max(1, Math.min(5, Math.round(s / 2))) },
|
|
277
278
|
{ questionId: "s1q3", value: ["Feature Flags", "Experiments", "Segments", "Audit Log"][Math.floor(t() * 4)] },
|
|
278
|
-
{ questionId: "s1q4", value:
|
|
279
|
+
{ questionId: "s1q4", value: me[Math.floor(t() * me.length)] }
|
|
279
280
|
]
|
|
280
281
|
};
|
|
281
282
|
});
|
|
282
283
|
}
|
|
283
|
-
const
|
|
284
|
-
function
|
|
284
|
+
const pe = (t) => t >= 9 ? "promoter" : t >= 7 ? "passive" : "detractor";
|
|
285
|
+
function le(t) {
|
|
285
286
|
if (t.length === 0) return null;
|
|
286
|
-
const
|
|
287
|
+
const a = t.filter((s) => s >= 9).length, n = t.filter((s) => s <= 6).length;
|
|
287
288
|
return {
|
|
288
|
-
score: Math.round((
|
|
289
|
-
promoters:
|
|
290
|
-
passives: t.length -
|
|
291
|
-
detractors:
|
|
289
|
+
score: Math.round((a - n) / t.length * 100),
|
|
290
|
+
promoters: a,
|
|
291
|
+
passives: t.length - a - n,
|
|
292
|
+
detractors: n,
|
|
292
293
|
total: t.length
|
|
293
294
|
};
|
|
294
295
|
}
|
|
295
|
-
function
|
|
296
|
-
const
|
|
297
|
-
return
|
|
298
|
-
var
|
|
299
|
-
return (
|
|
296
|
+
function ce(t, a) {
|
|
297
|
+
const n = t.questions.find((s) => s.type === "nps");
|
|
298
|
+
return n ? a.filter((s) => s.surveyId === t.id).map((s) => {
|
|
299
|
+
var i;
|
|
300
|
+
return (i = s.answers.find((m) => m.questionId === n.id)) == null ? void 0 : i.value;
|
|
300
301
|
}).filter((s) => typeof s == "number") : [];
|
|
301
302
|
}
|
|
302
|
-
const
|
|
303
|
-
const [t,
|
|
304
|
-
if (
|
|
303
|
+
const He = ["nps", "rating", "multiple_choice", "open_text"], ye = (t) => new Date(t).toLocaleDateString(void 0, { day: "2-digit", month: "short", year: "numeric" }), Xe = () => {
|
|
304
|
+
const [t, a] = y(Be), [n, s] = y(We), [i, m] = y({ name: "list" }), f = (o) => t.find((u) => u.id === o), g = () => m({ name: "list" });
|
|
305
|
+
if (i.name === "create")
|
|
305
306
|
return /* @__PURE__ */ e(
|
|
306
|
-
|
|
307
|
+
Ue,
|
|
307
308
|
{
|
|
308
|
-
onCancel:
|
|
309
|
-
onSave: (
|
|
310
|
-
|
|
309
|
+
onCancel: g,
|
|
310
|
+
onSave: (o) => {
|
|
311
|
+
a((u) => [o, ...u]), g();
|
|
311
312
|
}
|
|
312
313
|
}
|
|
313
314
|
);
|
|
314
|
-
if (
|
|
315
|
-
const
|
|
316
|
-
return
|
|
317
|
-
|
|
315
|
+
if (i.name === "take") {
|
|
316
|
+
const o = f(i.id);
|
|
317
|
+
return o ? /* @__PURE__ */ e(
|
|
318
|
+
Ve,
|
|
318
319
|
{
|
|
319
|
-
survey:
|
|
320
|
-
onCancel:
|
|
321
|
-
onSubmit: (
|
|
322
|
-
s((
|
|
320
|
+
survey: o,
|
|
321
|
+
onCancel: g,
|
|
322
|
+
onSubmit: (u) => {
|
|
323
|
+
s((h) => [{ id: Z("r"), surveyId: o.id, userId: `user_${900 + h.length}`, createdAt: (/* @__PURE__ */ new Date()).toISOString(), answers: u }, ...h]), m({ name: "results", id: o.id });
|
|
323
324
|
}
|
|
324
325
|
}
|
|
325
326
|
) : null;
|
|
326
327
|
}
|
|
327
|
-
if (
|
|
328
|
-
const
|
|
329
|
-
return
|
|
328
|
+
if (i.name === "results") {
|
|
329
|
+
const o = f(i.id);
|
|
330
|
+
return o ? /* @__PURE__ */ e(Ye, { survey: o, responses: n.filter((u) => u.surveyId === o.id), onBack: g, onTake: () => m({ name: "take", id: o.id }) }) : null;
|
|
330
331
|
}
|
|
331
|
-
const
|
|
332
|
-
return /* @__PURE__ */
|
|
333
|
-
|
|
332
|
+
const w = n.length, c = t.filter((o) => o.status === "active").length, d = le(t.flatMap((o) => ce(o, n)));
|
|
333
|
+
return /* @__PURE__ */ r(
|
|
334
|
+
ee,
|
|
334
335
|
{
|
|
335
336
|
title: "Surveys",
|
|
336
337
|
subtitle: "Create, run and measure user surveys.",
|
|
337
|
-
actions: /* @__PURE__ */ e("button", { className: "btn primary", onClick: () =>
|
|
338
|
+
actions: /* @__PURE__ */ e("button", { className: "btn primary", onClick: () => m({ name: "create" }), children: "+ Create Survey" }),
|
|
338
339
|
children: [
|
|
339
|
-
/* @__PURE__ */
|
|
340
|
-
/* @__PURE__ */ e(
|
|
341
|
-
/* @__PURE__ */ e(
|
|
342
|
-
/* @__PURE__ */ e(
|
|
343
|
-
/* @__PURE__ */ e(
|
|
340
|
+
/* @__PURE__ */ r("div", { className: "stats", children: [
|
|
341
|
+
/* @__PURE__ */ e(q, { label: "Total surveys", value: t.length, color: "#6366f1" }),
|
|
342
|
+
/* @__PURE__ */ e(q, { label: "Active", value: c, color: "#10b981" }),
|
|
343
|
+
/* @__PURE__ */ e(q, { label: "Total responses", value: w }),
|
|
344
|
+
/* @__PURE__ */ e(q, { label: "Overall NPS", value: d ? d.score : "—", color: "#f59e0b" })
|
|
344
345
|
] }),
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */
|
|
346
|
+
/* @__PURE__ */ r("table", { className: "table", children: [
|
|
347
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ r("tr", { children: [
|
|
347
348
|
/* @__PURE__ */ e("th", { children: "Survey" }),
|
|
348
349
|
/* @__PURE__ */ e("th", { children: "Status" }),
|
|
349
350
|
/* @__PURE__ */ e("th", { children: "Progress" }),
|
|
@@ -351,13 +352,13 @@ const ae = ["nps", "rating", "multiple_choice", "open_text"], q = (t) => new Dat
|
|
|
351
352
|
/* @__PURE__ */ e("th", { children: "Created" }),
|
|
352
353
|
/* @__PURE__ */ e("th", {})
|
|
353
354
|
] }) }),
|
|
354
|
-
/* @__PURE__ */ e("tbody", { children: t.map((
|
|
355
|
-
const
|
|
356
|
-
return /* @__PURE__ */
|
|
357
|
-
/* @__PURE__ */
|
|
358
|
-
/* @__PURE__ */ e("strong", { children:
|
|
359
|
-
/* @__PURE__ */
|
|
360
|
-
|
|
355
|
+
/* @__PURE__ */ e("tbody", { children: t.map((o) => {
|
|
356
|
+
const u = n.filter((l) => l.surveyId === o.id).length, h = le(ce(o, n));
|
|
357
|
+
return /* @__PURE__ */ r("tr", { children: [
|
|
358
|
+
/* @__PURE__ */ r("td", { children: [
|
|
359
|
+
/* @__PURE__ */ e("strong", { children: o.name }),
|
|
360
|
+
/* @__PURE__ */ r("div", { className: "muted small", children: [
|
|
361
|
+
o.questions.length,
|
|
361
362
|
" questions"
|
|
362
363
|
] })
|
|
363
364
|
] }),
|
|
@@ -365,188 +366,809 @@ const ae = ["nps", "rating", "multiple_choice", "open_text"], q = (t) => new Dat
|
|
|
365
366
|
"select",
|
|
366
367
|
{
|
|
367
368
|
className: "input slim",
|
|
368
|
-
value:
|
|
369
|
-
onChange: (l) =>
|
|
369
|
+
value: o.status,
|
|
370
|
+
onChange: (l) => a((k) => k.map((v) => v.id === o.id ? { ...v, status: l.target.value } : v)),
|
|
370
371
|
children: ["draft", "active", "paused", "closed"].map((l) => /* @__PURE__ */ e("option", { children: l }, l))
|
|
371
372
|
}
|
|
372
373
|
) }),
|
|
373
|
-
/* @__PURE__ */
|
|
374
|
-
/* @__PURE__ */
|
|
375
|
-
|
|
374
|
+
/* @__PURE__ */ r("td", { style: { minWidth: 140 }, children: [
|
|
375
|
+
/* @__PURE__ */ r("div", { className: "small mono", children: [
|
|
376
|
+
u,
|
|
376
377
|
" / ",
|
|
377
|
-
|
|
378
|
+
o.target
|
|
378
379
|
] }),
|
|
379
|
-
/* @__PURE__ */ e(
|
|
380
|
+
/* @__PURE__ */ e(K, { pct: u / o.target * 100 })
|
|
380
381
|
] }),
|
|
381
|
-
/* @__PURE__ */ e("td", { className: "mono", children:
|
|
382
|
-
/* @__PURE__ */ e("td", { className: "muted small", children:
|
|
383
|
-
/* @__PURE__ */
|
|
384
|
-
/* @__PURE__ */ e("button", { className: "btn", onClick: () =>
|
|
382
|
+
/* @__PURE__ */ e("td", { className: "mono", children: h ? h.score : "—" }),
|
|
383
|
+
/* @__PURE__ */ e("td", { className: "muted small", children: ye(o.createdAt) }),
|
|
384
|
+
/* @__PURE__ */ r("td", { className: "right", children: [
|
|
385
|
+
/* @__PURE__ */ e("button", { className: "btn", onClick: () => m({ name: "results", id: o.id }), children: "Results" }),
|
|
385
386
|
" ",
|
|
386
|
-
/* @__PURE__ */ e("button", { className: "btn", disabled:
|
|
387
|
+
/* @__PURE__ */ e("button", { className: "btn", disabled: o.status !== "active", title: o.status !== "active" ? "Set status to active to collect answers" : "", onClick: () => m({ name: "take", id: o.id }), children: "Take" }),
|
|
387
388
|
" ",
|
|
388
389
|
/* @__PURE__ */ e(
|
|
389
390
|
"button",
|
|
390
391
|
{
|
|
391
392
|
className: "btn danger",
|
|
392
393
|
onClick: () => {
|
|
393
|
-
window.confirm(`Delete "${
|
|
394
|
+
window.confirm(`Delete "${o.name}" and its responses?`) && (a((l) => l.filter((k) => k.id !== o.id)), s((l) => l.filter((k) => k.surveyId !== o.id)));
|
|
394
395
|
},
|
|
395
396
|
children: "Delete"
|
|
396
397
|
}
|
|
397
398
|
)
|
|
398
399
|
] })
|
|
399
|
-
] },
|
|
400
|
+
] }, o.id);
|
|
400
401
|
}) })
|
|
401
402
|
] })
|
|
402
403
|
]
|
|
403
404
|
}
|
|
404
405
|
);
|
|
405
|
-
},
|
|
406
|
-
const [
|
|
407
|
-
if (!
|
|
408
|
-
if (
|
|
409
|
-
if (
|
|
410
|
-
if (
|
|
406
|
+
}, Ue = ({ onSave: t, onCancel: a }) => {
|
|
407
|
+
const [n, s] = y(""), [i, m] = y(""), [f, g] = y(100), [w, c] = y([{ id: Z("q"), type: "nps", text: "How likely are you to recommend us?", required: !0 }]), [d, o] = y(""), u = (l, k) => c((v) => v.map((I) => I.id === l ? { ...I, ...k } : I)), h = () => {
|
|
408
|
+
if (!n.trim()) return o("Survey name is required.");
|
|
409
|
+
if (w.length === 0) return o("Add at least one question.");
|
|
410
|
+
if (w.some((l) => !l.text.trim())) return o("Every question needs text.");
|
|
411
|
+
if (w.some((l) => l.type === "multiple_choice" && (l.options ?? []).filter((k) => k.trim()).length < 2)) return o("Multiple choice needs at least two options.");
|
|
411
412
|
t({
|
|
412
|
-
id:
|
|
413
|
-
name:
|
|
414
|
-
description:
|
|
413
|
+
id: Z("s"),
|
|
414
|
+
name: n.trim(),
|
|
415
|
+
description: i.trim(),
|
|
415
416
|
status: "active",
|
|
416
|
-
target:
|
|
417
|
+
target: f,
|
|
417
418
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
418
|
-
questions:
|
|
419
|
+
questions: w.map((l) => ({ ...l, text: l.text.trim(), options: l.type === "multiple_choice" ? (l.options ?? []).filter((k) => k.trim()) : void 0 }))
|
|
419
420
|
});
|
|
420
421
|
};
|
|
421
|
-
return /* @__PURE__ */
|
|
422
|
-
/* @__PURE__ */
|
|
423
|
-
/* @__PURE__ */
|
|
422
|
+
return /* @__PURE__ */ r(ee, { title: "Create Survey", subtitle: "Build a new survey.", actions: /* @__PURE__ */ e("button", { className: "btn", onClick: a, children: "Back" }), children: [
|
|
423
|
+
/* @__PURE__ */ r("div", { className: "card form", children: [
|
|
424
|
+
/* @__PURE__ */ r("label", { children: [
|
|
424
425
|
"Name",
|
|
425
|
-
/* @__PURE__ */ e("input", { className: "input", value:
|
|
426
|
+
/* @__PURE__ */ e("input", { className: "input", value: n, onChange: (l) => s(l.target.value), placeholder: "e.g. Q1 Product Satisfaction" })
|
|
426
427
|
] }),
|
|
427
|
-
/* @__PURE__ */
|
|
428
|
+
/* @__PURE__ */ r("label", { children: [
|
|
428
429
|
"Description",
|
|
429
|
-
/* @__PURE__ */ e("input", { className: "input", value:
|
|
430
|
+
/* @__PURE__ */ e("input", { className: "input", value: i, onChange: (l) => m(l.target.value) })
|
|
430
431
|
] }),
|
|
431
|
-
/* @__PURE__ */
|
|
432
|
+
/* @__PURE__ */ r("label", { children: [
|
|
432
433
|
"Target responses",
|
|
433
|
-
/* @__PURE__ */ e("input", { className: "input narrow", type: "number", min: 1, value:
|
|
434
|
+
/* @__PURE__ */ e("input", { className: "input narrow", type: "number", min: 1, value: f, onChange: (l) => g(Math.max(1, parseInt(l.target.value, 10) || 1)) })
|
|
434
435
|
] })
|
|
435
436
|
] }),
|
|
436
|
-
/* @__PURE__ */
|
|
437
|
+
/* @__PURE__ */ r("h3", { children: [
|
|
437
438
|
"Questions (",
|
|
438
|
-
|
|
439
|
+
w.length,
|
|
439
440
|
")"
|
|
440
441
|
] }),
|
|
441
|
-
|
|
442
|
-
/* @__PURE__ */
|
|
443
|
-
/* @__PURE__ */
|
|
442
|
+
w.map((l, k) => /* @__PURE__ */ r("div", { className: "card form", children: [
|
|
443
|
+
/* @__PURE__ */ r("div", { className: "row", children: [
|
|
444
|
+
/* @__PURE__ */ r("strong", { children: [
|
|
444
445
|
"Q",
|
|
445
|
-
|
|
446
|
+
k + 1
|
|
446
447
|
] }),
|
|
447
|
-
/* @__PURE__ */ e("select", { className: "input slim", value: l.type, onChange: (v) =>
|
|
448
|
-
/* @__PURE__ */
|
|
449
|
-
/* @__PURE__ */ e("input", { type: "checkbox", checked: l.required, onChange: (v) =>
|
|
448
|
+
/* @__PURE__ */ e("select", { className: "input slim", value: l.type, onChange: (v) => u(l.id, { type: v.target.value, options: v.target.value === "multiple_choice" ? ["Option 1", "Option 2"] : void 0 }), children: He.map((v) => /* @__PURE__ */ e("option", { value: v, children: v.replace("_", " ") }, v)) }),
|
|
449
|
+
/* @__PURE__ */ r("label", { className: "inline", children: [
|
|
450
|
+
/* @__PURE__ */ e("input", { type: "checkbox", checked: l.required, onChange: (v) => u(l.id, { required: v.target.checked }) }),
|
|
450
451
|
" required"
|
|
451
452
|
] }),
|
|
452
453
|
/* @__PURE__ */ e("span", { className: "grow" }),
|
|
453
|
-
/* @__PURE__ */ e("button", { className: "btn danger", onClick: () =>
|
|
454
|
+
/* @__PURE__ */ e("button", { className: "btn danger", onClick: () => c((v) => v.filter((I) => I.id !== l.id)), children: "Remove" })
|
|
454
455
|
] }),
|
|
455
|
-
/* @__PURE__ */ e("input", { className: "input", value: l.text, onChange: (v) =>
|
|
456
|
-
l.type === "multiple_choice" && /* @__PURE__ */
|
|
457
|
-
(l.options ?? []).map((v,
|
|
458
|
-
/* @__PURE__ */ e("button", { className: "btn", onClick: () =>
|
|
456
|
+
/* @__PURE__ */ e("input", { className: "input", value: l.text, onChange: (v) => u(l.id, { text: v.target.value }), placeholder: "Enter your question…" }),
|
|
457
|
+
l.type === "multiple_choice" && /* @__PURE__ */ r("div", { className: "stack", children: [
|
|
458
|
+
(l.options ?? []).map((v, I) => /* @__PURE__ */ e("input", { className: "input slim", value: v, onChange: (P) => u(l.id, { options: (l.options ?? []).map((R, p) => p === I ? P.target.value : R) }) }, I)),
|
|
459
|
+
/* @__PURE__ */ e("button", { className: "btn", onClick: () => u(l.id, { options: [...l.options ?? [], `Option ${(l.options ?? []).length + 1}`] }), children: "+ Add option" })
|
|
459
460
|
] })
|
|
460
461
|
] }, l.id)),
|
|
461
|
-
/* @__PURE__ */
|
|
462
|
-
/* @__PURE__ */ e("button", { className: "btn", onClick: () =>
|
|
462
|
+
/* @__PURE__ */ r("div", { className: "row", children: [
|
|
463
|
+
/* @__PURE__ */ e("button", { className: "btn", onClick: () => c((l) => [...l, { id: Z("q"), type: "rating", text: "", required: !1 }]), children: "+ Add question" }),
|
|
463
464
|
/* @__PURE__ */ e("span", { className: "grow" }),
|
|
464
|
-
|
|
465
|
-
/* @__PURE__ */ e("button", { className: "btn primary", onClick:
|
|
465
|
+
d && /* @__PURE__ */ e("span", { className: "error", children: d }),
|
|
466
|
+
/* @__PURE__ */ e("button", { className: "btn primary", onClick: h, children: "Create Survey" })
|
|
466
467
|
] })
|
|
467
468
|
] });
|
|
468
|
-
},
|
|
469
|
-
const [s,
|
|
470
|
-
const
|
|
471
|
-
if (
|
|
472
|
-
|
|
469
|
+
}, Ve = ({ survey: t, onSubmit: a, onCancel: n }) => {
|
|
470
|
+
const [s, i] = y({}), [m, f] = y(""), g = (c, d) => i((o) => ({ ...o, [c]: d })), w = () => {
|
|
471
|
+
const c = t.questions.find((d) => d.required && (s[d.id] === void 0 || s[d.id] === ""));
|
|
472
|
+
if (c) return f(`"${c.text}" is required.`);
|
|
473
|
+
f(""), a(t.questions.filter((d) => s[d.id] !== void 0 && s[d.id] !== "").map((d) => ({ questionId: d.id, value: s[d.id] })));
|
|
473
474
|
};
|
|
474
|
-
return /* @__PURE__ */
|
|
475
|
-
t.questions.map((
|
|
476
|
-
/* @__PURE__ */
|
|
477
|
-
|
|
475
|
+
return /* @__PURE__ */ r(ee, { title: t.name, subtitle: t.description || "Answer the questions below.", actions: /* @__PURE__ */ e("button", { className: "btn", onClick: n, children: "Cancel" }), children: [
|
|
476
|
+
t.questions.map((c, d) => /* @__PURE__ */ r("div", { className: "card form", children: [
|
|
477
|
+
/* @__PURE__ */ r("strong", { children: [
|
|
478
|
+
d + 1,
|
|
478
479
|
". ",
|
|
479
|
-
|
|
480
|
-
|
|
480
|
+
c.text,
|
|
481
|
+
c.required && /* @__PURE__ */ e("span", { className: "error", children: " *" })
|
|
481
482
|
] }),
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
483
|
+
c.type === "nps" && /* @__PURE__ */ e("div", { className: "scale", children: Array.from({ length: 11 }, (o, u) => /* @__PURE__ */ e("button", { className: s[c.id] === u ? "chip active" : "chip", onClick: () => g(c.id, u), children: u }, u)) }),
|
|
484
|
+
c.type === "rating" && /* @__PURE__ */ e("div", { className: "scale", children: [1, 2, 3, 4, 5].map((o) => /* @__PURE__ */ r("button", { className: s[c.id] === o ? "chip active" : "chip", onClick: () => g(c.id, o), children: [
|
|
485
|
+
o,
|
|
485
486
|
" ★"
|
|
486
|
-
] },
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
] },
|
|
490
|
-
/* @__PURE__ */
|
|
487
|
+
] }, o)) }),
|
|
488
|
+
c.type === "multiple_choice" && /* @__PURE__ */ e("div", { className: "scale", children: (c.options ?? []).map((o) => /* @__PURE__ */ e("button", { className: s[c.id] === o ? "chip active" : "chip", onClick: () => g(c.id, o), children: o }, o)) }),
|
|
489
|
+
c.type === "open_text" && /* @__PURE__ */ e("textarea", { className: "input", rows: 2, value: String(s[c.id] ?? ""), onChange: (o) => g(c.id, o.target.value) })
|
|
490
|
+
] }, c.id)),
|
|
491
|
+
/* @__PURE__ */ r("div", { className: "row", children: [
|
|
491
492
|
/* @__PURE__ */ e("span", { className: "grow" }),
|
|
492
|
-
|
|
493
|
-
/* @__PURE__ */ e("button", { className: "btn primary", onClick:
|
|
493
|
+
m && /* @__PURE__ */ e("span", { className: "error", children: m }),
|
|
494
|
+
/* @__PURE__ */ e("button", { className: "btn primary", onClick: w, children: "Submit response" })
|
|
494
495
|
] })
|
|
495
496
|
] });
|
|
496
|
-
},
|
|
497
|
-
const
|
|
498
|
-
return /* @__PURE__ */
|
|
499
|
-
|
|
497
|
+
}, Ye = ({ survey: t, responses: a, onBack: n, onTake: s }) => {
|
|
498
|
+
const i = Y(() => le(ce(t, a)), [t, a]), m = t.questions.find((g) => g.type === "nps"), f = (g) => i ? Math.round(g / i.total * 100) : 0;
|
|
499
|
+
return /* @__PURE__ */ r(
|
|
500
|
+
ee,
|
|
500
501
|
{
|
|
501
502
|
title: t.name,
|
|
502
|
-
subtitle: `${
|
|
503
|
-
actions: /* @__PURE__ */
|
|
504
|
-
/* @__PURE__ */ e("button", { className: "btn", onClick:
|
|
503
|
+
subtitle: `${a.length} responses`,
|
|
504
|
+
actions: /* @__PURE__ */ r(ae, { children: [
|
|
505
|
+
/* @__PURE__ */ e("button", { className: "btn", onClick: n, children: "Back" }),
|
|
505
506
|
/* @__PURE__ */ e("button", { className: "btn primary", disabled: t.status !== "active", onClick: s, children: "Take survey" })
|
|
506
507
|
] }),
|
|
507
508
|
children: [
|
|
508
|
-
/* @__PURE__ */
|
|
509
|
-
/* @__PURE__ */ e(
|
|
510
|
-
/* @__PURE__ */ e(
|
|
511
|
-
/* @__PURE__ */ e(
|
|
512
|
-
/* @__PURE__ */ e(
|
|
509
|
+
/* @__PURE__ */ r("div", { className: "stats", children: [
|
|
510
|
+
/* @__PURE__ */ e(q, { label: "NPS", value: i ? i.score : "—", color: "#f59e0b" }),
|
|
511
|
+
/* @__PURE__ */ e(q, { label: "Promoters", value: i ? `${f(i.promoters)}%` : "—", color: "#4edea3" }),
|
|
512
|
+
/* @__PURE__ */ e(q, { label: "Passives", value: i ? `${f(i.passives)}%` : "—", color: "#ffcc6b" }),
|
|
513
|
+
/* @__PURE__ */ e(q, { label: "Detractors", value: i ? `${f(i.detractors)}%` : "—", color: "#ffb4ab" })
|
|
513
514
|
] }),
|
|
514
|
-
/* @__PURE__ */
|
|
515
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */
|
|
515
|
+
/* @__PURE__ */ r("table", { className: "table", children: [
|
|
516
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ r("tr", { children: [
|
|
516
517
|
/* @__PURE__ */ e("th", { children: "User" }),
|
|
517
518
|
/* @__PURE__ */ e("th", { children: "NPS" }),
|
|
518
|
-
t.questions.filter((
|
|
519
|
+
t.questions.filter((g) => g.type !== "nps").map((g) => /* @__PURE__ */ e("th", { children: g.text }, g.id)),
|
|
519
520
|
/* @__PURE__ */ e("th", { children: "Date" })
|
|
520
521
|
] }) }),
|
|
521
|
-
/* @__PURE__ */
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
var
|
|
525
|
-
const
|
|
526
|
-
return /* @__PURE__ */
|
|
527
|
-
/* @__PURE__ */ e("td", { className: "mono", children:
|
|
528
|
-
/* @__PURE__ */ e("td", { children: typeof
|
|
529
|
-
|
|
522
|
+
/* @__PURE__ */ r("tbody", { children: [
|
|
523
|
+
a.length === 0 && /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: 9, className: "muted", children: "No responses yet." }) }),
|
|
524
|
+
a.map((g) => {
|
|
525
|
+
var c;
|
|
526
|
+
const w = m ? (c = g.answers.find((d) => d.questionId === m.id)) == null ? void 0 : c.value : void 0;
|
|
527
|
+
return /* @__PURE__ */ r("tr", { children: [
|
|
528
|
+
/* @__PURE__ */ e("td", { className: "mono", children: g.userId }),
|
|
529
|
+
/* @__PURE__ */ e("td", { children: typeof w == "number" ? /* @__PURE__ */ r("span", { className: `pill ${pe(w)}`, children: [
|
|
530
|
+
w,
|
|
530
531
|
" · ",
|
|
531
|
-
|
|
532
|
+
pe(w)
|
|
532
533
|
] }) : "—" }),
|
|
533
|
-
t.questions.filter((
|
|
534
|
-
var
|
|
535
|
-
return /* @__PURE__ */ e("td", { children: String(((
|
|
534
|
+
t.questions.filter((d) => d.type !== "nps").map((d) => {
|
|
535
|
+
var o;
|
|
536
|
+
return /* @__PURE__ */ e("td", { children: String(((o = g.answers.find((u) => u.questionId === d.id)) == null ? void 0 : o.value) ?? "—") }, d.id);
|
|
536
537
|
}),
|
|
537
|
-
/* @__PURE__ */ e("td", { className: "muted small", children:
|
|
538
|
-
] },
|
|
538
|
+
/* @__PURE__ */ e("td", { className: "muted small", children: ye(g.createdAt) })
|
|
539
|
+
] }, g.id);
|
|
539
540
|
})
|
|
540
541
|
] })
|
|
541
542
|
] })
|
|
542
543
|
]
|
|
543
544
|
}
|
|
544
545
|
);
|
|
545
|
-
}
|
|
546
|
+
}, ht = () => {
|
|
547
|
+
const [t, a] = y("survey");
|
|
548
|
+
return /* @__PURE__ */ r("div", { className: "shell", children: [
|
|
549
|
+
/* @__PURE__ */ r("header", { className: "topbar", children: [
|
|
550
|
+
/* @__PURE__ */ e("strong", { children: "POC" }),
|
|
551
|
+
/* @__PURE__ */ e(fe, { items: [{ id: "survey", label: "Survey" }, { id: "journey", label: "User Journey" }], value: t, onChange: a })
|
|
552
|
+
] }),
|
|
553
|
+
/* @__PURE__ */ e("main", { children: t === "survey" ? /* @__PURE__ */ e(Xe, {}) : /* @__PURE__ */ e(De, {}) })
|
|
554
|
+
] });
|
|
555
|
+
}, X = (t, a) => {
|
|
556
|
+
try {
|
|
557
|
+
return t();
|
|
558
|
+
} catch {
|
|
559
|
+
return a;
|
|
560
|
+
}
|
|
561
|
+
}, re = (t) => Math.random().toString(36).slice(2, 2 + t), z = () => location.pathname + location.hash, Qe = ".sj, [data-sj-ignore]", Ge = () => ({
|
|
562
|
+
pages: {},
|
|
563
|
+
scrollMs: 0,
|
|
564
|
+
clicks: 0,
|
|
565
|
+
nav: 0,
|
|
566
|
+
heat: {},
|
|
567
|
+
steps: {},
|
|
568
|
+
started: 0,
|
|
569
|
+
completed: 0,
|
|
570
|
+
skipped: 0,
|
|
571
|
+
drops: {},
|
|
572
|
+
log: []
|
|
573
|
+
});
|
|
574
|
+
class ze {
|
|
575
|
+
constructor(a) {
|
|
576
|
+
this.getCfg = a, this.activeStep = null, this.q = [], this.version = 0, this.subs = /* @__PURE__ */ new Set(), this.navSubs = /* @__PURE__ */ new Set(), this.overrides = {}, this.prev = "", this.booted = !1, this.scrolling = !1, this.scrollTimer = 0, this.lastMove = 0, this.subscribe = (n) => (this.subs.add(n), () => {
|
|
577
|
+
this.subs.delete(n);
|
|
578
|
+
}), this.getVersion = () => this.version, this.uid = X(() => localStorage.getItem("sjU") || (localStorage.setItem("sjU", re(10)), localStorage.getItem("sjU")), "anon"), this.sid = X(() => sessionStorage.getItem("sjS") || (sessionStorage.setItem("sjS", re(8)), sessionStorage.getItem("sjS")), re(8)), this.state = { ...Ge(), ...X(() => JSON.parse(sessionStorage.getItem("sjState") || "null"), null) };
|
|
579
|
+
}
|
|
580
|
+
get cfg() {
|
|
581
|
+
return { ...this.getCfg(), ...this.overrides };
|
|
582
|
+
}
|
|
583
|
+
configure(a) {
|
|
584
|
+
this.overrides = { ...this.overrides, ...a };
|
|
585
|
+
}
|
|
586
|
+
emit() {
|
|
587
|
+
this.version++, this.subs.forEach((a) => a());
|
|
588
|
+
}
|
|
589
|
+
onNavigate(a) {
|
|
590
|
+
return this.navSubs.add(a), () => {
|
|
591
|
+
this.navSubs.delete(a);
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
/* ---- data ---- */
|
|
595
|
+
page(a = z()) {
|
|
596
|
+
return this.state.pages[a] || (this.state.pages[a] = { ms: 0, scrollMs: 0, depth: 0, clicks: 0, views: 0, m: {} });
|
|
597
|
+
}
|
|
598
|
+
save() {
|
|
599
|
+
X(() => sessionStorage.setItem("sjState", JSON.stringify({ ...this.state, log: this.state.log.slice(0, 40) })), void 0);
|
|
600
|
+
}
|
|
601
|
+
bin(a, n, s) {
|
|
602
|
+
const i = z(), m = document.documentElement.scrollWidth || 1, f = this.state.heat[i] || (this.state.heat[i] = {}), g = Math.round(a / m * 100) + "," + (n / 20 | 0);
|
|
603
|
+
f[g] = (f[g] || 0) + s;
|
|
604
|
+
}
|
|
605
|
+
track(a, n = {}) {
|
|
606
|
+
const s = { sid: this.sid, uid: this.uid, type: a, t: Date.now(), page: z(), ...n };
|
|
607
|
+
this.q.push(s), this.state.log.unshift(s), this.state.log.length > 60 && this.state.log.pop();
|
|
608
|
+
const i = this.cfg.onEvent;
|
|
609
|
+
i && X(() => i(s), void 0);
|
|
610
|
+
}
|
|
611
|
+
payload(a) {
|
|
612
|
+
const n = this.state;
|
|
613
|
+
return JSON.stringify({
|
|
614
|
+
sessionId: this.sid,
|
|
615
|
+
userId: this.uid,
|
|
616
|
+
tourId: this.cfg.tourId || "default",
|
|
617
|
+
url: location.href,
|
|
618
|
+
viewport: [innerWidth, innerHeight],
|
|
619
|
+
doc: [document.documentElement.scrollWidth, document.documentElement.scrollHeight],
|
|
620
|
+
events: a,
|
|
621
|
+
summary: {
|
|
622
|
+
pages: n.pages,
|
|
623
|
+
scrollMs: n.scrollMs,
|
|
624
|
+
clicks: n.clicks,
|
|
625
|
+
nav: n.nav,
|
|
626
|
+
tour: { started: n.started, completed: n.completed, skipped: n.skipped, drops: n.drops, steps: n.steps },
|
|
627
|
+
heat: n.heat
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
flush(a = !1) {
|
|
632
|
+
if (this.save(), !this.q.length) return;
|
|
633
|
+
const n = this.q;
|
|
634
|
+
this.q = [];
|
|
635
|
+
const s = this.cfg;
|
|
636
|
+
if (!s.endpoint) {
|
|
637
|
+
this.state.log.unshift({ type: "flush (dry-run)", t: Date.now(), n: `${n.length} events` });
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
const i = this.payload(n);
|
|
641
|
+
a && navigator.sendBeacon && navigator.sendBeacon(s.endpoint, new Blob([i], { type: "application/json" })) || fetch(s.endpoint, { method: "POST", body: i, keepalive: !0, headers: { "Content-Type": "application/json", ...s.headers || {} } }).then((m) => {
|
|
642
|
+
if (!m.ok) throw new Error("bad status");
|
|
643
|
+
}).catch(() => {
|
|
644
|
+
this.q = n.concat(this.q).slice(-500);
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
/* ---- tour funnel ---- */
|
|
648
|
+
tourStart(a, n) {
|
|
649
|
+
n || this.state.started++, this.track(n ? "tour_resume" : "tour_start", { steps: a });
|
|
650
|
+
}
|
|
651
|
+
stepView(a, n, s) {
|
|
652
|
+
const i = this.state.steps[a] || (this.state.steps[a] = { views: 0, ms: 0, title: n });
|
|
653
|
+
i.views++, this.activeStep = a, this.track("step_view", { step: a, title: n, total: s }), this.save();
|
|
654
|
+
}
|
|
655
|
+
tourEnd(a, n, s, i) {
|
|
656
|
+
a === "complete" ? (this.state.completed++, this.track("tour_complete", { steps: i })) : (this.state.skipped++, this.state.drops[n] = (this.state.drops[n] || 0) + 1, this.track("tour_skip", { step: n, title: s })), this.activeStep = null, X(() => sessionStorage.removeItem("sjTour"), void 0), X(() => localStorage.setItem("sjDone", a), void 0), this.flush();
|
|
657
|
+
}
|
|
658
|
+
/* ---- passive listeners; returns a cleanup function (safe under React StrictMode) ---- */
|
|
659
|
+
attach() {
|
|
660
|
+
const a = this.state;
|
|
661
|
+
this.prev = z();
|
|
662
|
+
let n = performance.now();
|
|
663
|
+
this.booted || (this.booted = !0, this.page().views++, this.track("session_start", { ua: navigator.userAgent.slice(0, 60), ref: document.referrer }));
|
|
664
|
+
const s = [], i = (c, d, o, u) => {
|
|
665
|
+
c.addEventListener(d, o, u), s.push(() => c.removeEventListener(d, o, u));
|
|
666
|
+
}, m = window.setInterval(() => {
|
|
667
|
+
const c = performance.now(), d = c - n;
|
|
668
|
+
if (n = c, document.hidden) return;
|
|
669
|
+
const o = this.page();
|
|
670
|
+
o.ms += d, this.scrolling && (o.scrollMs += d, a.scrollMs += d), this.activeStep !== null && a.steps[this.activeStep] && (a.steps[this.activeStep].ms += d);
|
|
671
|
+
}, 250), f = window.setInterval(() => this.emit(), 500), g = window.setInterval(() => this.flush(), this.cfg.flushMs || 5e3);
|
|
672
|
+
s.push(() => {
|
|
673
|
+
clearInterval(m), clearInterval(f), clearInterval(g);
|
|
674
|
+
}), i(window, "scroll", () => {
|
|
675
|
+
this.scrolling = !0, clearTimeout(this.scrollTimer), this.scrollTimer = window.setTimeout(() => {
|
|
676
|
+
this.scrolling = !1;
|
|
677
|
+
}, 160);
|
|
678
|
+
const c = this.page(), d = Math.min(100, Math.round((scrollY + innerHeight) / document.documentElement.scrollHeight * 100));
|
|
679
|
+
d > c.depth && (c.depth = d, [25, 50, 75, 100].forEach((o) => {
|
|
680
|
+
d >= o && !c.m[o] && (c.m[o] = 1, this.track("scroll_depth", { pct: o }));
|
|
681
|
+
}));
|
|
682
|
+
}, { passive: !0 }), i(window, "mousemove", (c) => {
|
|
683
|
+
const d = Date.now();
|
|
684
|
+
d - this.lastMove > 120 && (this.lastMove = d, this.bin(c.pageX, c.pageY, 1));
|
|
685
|
+
}, { passive: !0 }), i(document, "click", (c) => {
|
|
686
|
+
const d = c.target;
|
|
687
|
+
if (!d || !d.closest || d.closest(Qe)) return;
|
|
688
|
+
a.clicks++, this.page().clicks++, this.bin(c.pageX, c.pageY, 6);
|
|
689
|
+
const o = d.id ? "#" + d.id : d.tagName.toLowerCase() + (typeof d.className == "string" && d.className ? "." + d.className.trim().split(/\s+/)[0] : "");
|
|
690
|
+
this.track("click", { sel: o, x: c.pageX, y: c.pageY, text: (d.textContent || "").trim().slice(0, 30), step: this.activeStep });
|
|
691
|
+
const u = d.closest("a[href]");
|
|
692
|
+
u && !u.getAttribute("href").startsWith("#") && (this.track("navigate_out", { to: u.href }), this.flush(!0));
|
|
693
|
+
}, !0);
|
|
694
|
+
const w = () => {
|
|
695
|
+
const c = z();
|
|
696
|
+
c !== this.prev && (a.nav++, this.track("navigate", { from: this.prev, to: c }), this.prev = c, this.page().views++, this.navSubs.forEach((d) => d()));
|
|
697
|
+
};
|
|
698
|
+
return ["pushState", "replaceState"].forEach((c) => {
|
|
699
|
+
const d = history[c];
|
|
700
|
+
history[c] = function(...o) {
|
|
701
|
+
const u = d.apply(this, o);
|
|
702
|
+
return setTimeout(w), u;
|
|
703
|
+
}, s.push(() => {
|
|
704
|
+
history[c] = d;
|
|
705
|
+
});
|
|
706
|
+
}), i(window, "popstate", w), i(window, "hashchange", w), i(document, "visibilitychange", () => {
|
|
707
|
+
document.hidden && this.flush(!0);
|
|
708
|
+
}), i(window, "pagehide", () => {
|
|
709
|
+
const c = this.activeStep;
|
|
710
|
+
c !== null && (this.track("tour_abandon", { step: c }), a.drops[c] = (a.drops[c] || 0) + 1, X(() => sessionStorage.setItem("sjTour", JSON.stringify({ i: c, t: Date.now() })), void 0)), this.flush(!0);
|
|
711
|
+
}), () => s.forEach((c) => c());
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
const ie = (t) => !!t && t.isConnected && t.getClientRects().length > 0;
|
|
715
|
+
function Ke(t) {
|
|
716
|
+
var s;
|
|
717
|
+
const a = t.dataset, n = (t.getAttribute("aria-label") || t.getAttribute("title") || t.textContent || "").trim().replace(/\s+/g, " ");
|
|
718
|
+
return {
|
|
719
|
+
el: t,
|
|
720
|
+
title: a.sjTitle || t.getAttribute("aria-label") || ((s = t.querySelector("h1,h2,h3")) == null ? void 0 : s.textContent) || n.slice(0, 28) || t.tagName.toLowerCase(),
|
|
721
|
+
body: a.sjBody || n.slice(0, 140),
|
|
722
|
+
placement: a.sjPlace || "auto"
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
function Ze(t) {
|
|
726
|
+
const a = (s) => !s.page || s.page === location.pathname;
|
|
727
|
+
let n;
|
|
728
|
+
if (t.steps)
|
|
729
|
+
n = t.steps.map((s) => ({
|
|
730
|
+
...s,
|
|
731
|
+
placement: s.placement ?? "auto",
|
|
732
|
+
el: s.target && a(s) ? document.querySelector(s.target) : null,
|
|
733
|
+
wait: !!s.target && a(s)
|
|
734
|
+
}));
|
|
735
|
+
else {
|
|
736
|
+
let s = [...document.querySelectorAll("[data-sj-title],[data-sj-step]")];
|
|
737
|
+
s.length || (s = [...document.querySelectorAll("header,nav,main>section,footer")].slice(0, 6)), n = s.filter(ie).sort((i, m) => (+(i.dataset.sjStep || 0) || 99) - (+(m.dataset.sjStep || 0) || 99)).map(Ke);
|
|
738
|
+
}
|
|
739
|
+
return t.welcome && n.unshift({ ...t.welcome, el: null, placement: "auto", welcome: !0 }), t.outro && n.push({ ...t.outro, el: null, placement: "auto", outro: !0 }), n;
|
|
740
|
+
}
|
|
741
|
+
const se = (t, a, n) => Math.max(a, Math.min(n, t)), et = ({ open: t, anim: a, theme: n, steps: s, index: i, startLabel: m, tracker: f, onNext: g, onBack: w, onSkip: c, onTheme: d }) => {
|
|
742
|
+
const o = _(null), u = _(null), h = _(0), [l, k] = y(null), v = s[i], I = L(() => {
|
|
743
|
+
const x = o.current;
|
|
744
|
+
if (!t || !v || !x) return;
|
|
745
|
+
const T = innerWidth, M = innerHeight, E = 12, A = 16;
|
|
746
|
+
let N = { x: T / 2, y: M / 2, w: 0, h: 0 }, D = !0;
|
|
747
|
+
if (ie(v.el)) {
|
|
748
|
+
const C = v.el.getBoundingClientRect(), H = Math.max(C.left - 8, 0), S = Math.max(C.top - 8, 0);
|
|
749
|
+
N = { x: H, y: S, w: Math.min(C.right + 8, T) - H, h: Math.min(C.bottom + 8, M) - S }, D = !1;
|
|
750
|
+
}
|
|
751
|
+
const $ = x.offsetWidth, O = x.offsetHeight;
|
|
752
|
+
let W = (T - $) / 2, J = (M - O) / 2, Q = "c", b = 0, j = 0;
|
|
753
|
+
if (!D) {
|
|
754
|
+
const C = N.x + N.w / 2, H = N.y + N.h / 2, S = {
|
|
755
|
+
top: { x: C - $ / 2, y: N.y - O - A, ok: N.y - O - A >= E },
|
|
756
|
+
bottom: { x: C - $ / 2, y: N.y + N.h + A, ok: N.y + N.h + A + O <= M - E },
|
|
757
|
+
left: { x: N.x - $ - A, y: H - O / 2, ok: N.x - $ - A >= E },
|
|
758
|
+
right: { x: N.x + N.w + A, y: H - O / 2, ok: N.x + N.w + A + $ <= T - E }
|
|
759
|
+
}, G = v.placement !== "auto" && v.placement in S ? v.placement : "bottom", ke = { top: "bottom", bottom: "top", left: "right", right: "left" }[G], te = (v.placement === "auto" ? ["bottom", "top", "right", "left"] : [G, ke, "bottom", "top", "right", "left"]).find((Se) => S[Se].ok);
|
|
760
|
+
te ? (W = S[te].x, J = S[te].y, Q = te) : (J = M - O - E, Q = "in"), W = se(W, E, T - $ - E), J = se(J, E, M - O - E), b = se(C - W, 22, $ - 22), j = se(H - J, 22, O - 22);
|
|
761
|
+
}
|
|
762
|
+
k({ hole: N, centered: D, x: Math.round(W), y: Math.round(J), side: Q, ax: b, ay: j, vw: T, vh: M });
|
|
763
|
+
}, [t, v]), P = L(() => {
|
|
764
|
+
cancelAnimationFrame(h.current), h.current = requestAnimationFrame(I);
|
|
765
|
+
}, [I]);
|
|
766
|
+
if (xe(() => {
|
|
767
|
+
if (!t) return;
|
|
768
|
+
I();
|
|
769
|
+
const x = window.setTimeout(I, 380), T = window.setTimeout(I, 700);
|
|
770
|
+
return () => {
|
|
771
|
+
clearTimeout(x), clearTimeout(T);
|
|
772
|
+
};
|
|
773
|
+
}, [t, i, I]), B(() => {
|
|
774
|
+
if (!t) return;
|
|
775
|
+
addEventListener("scroll", P, { passive: !0 }), addEventListener("resize", P);
|
|
776
|
+
const x = f.onNavigate(P);
|
|
777
|
+
return () => {
|
|
778
|
+
removeEventListener("scroll", P), removeEventListener("resize", P), x(), cancelAnimationFrame(h.current);
|
|
779
|
+
};
|
|
780
|
+
}, [t, P, f]), B(() => {
|
|
781
|
+
var x;
|
|
782
|
+
t && v && ((x = u.current) == null || x.focus({ preventScroll: !0 }));
|
|
783
|
+
}, [t, i, v]), !v) return null;
|
|
784
|
+
const R = i === s.length - 1, p = l, U = p ? [
|
|
785
|
+
[0, 0, p.vw, p.hole.y],
|
|
786
|
+
[p.hole.y + p.hole.h, 0, p.vw, p.vh - p.hole.y - p.hole.h],
|
|
787
|
+
[p.hole.y, 0, p.hole.x, p.hole.h],
|
|
788
|
+
[p.hole.y, p.hole.x + p.hole.w, p.vw - p.hole.x - p.hole.w, p.hole.h]
|
|
789
|
+
] : [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], F = (x) => Math.max(0, x) + "px";
|
|
790
|
+
return ve(
|
|
791
|
+
/* @__PURE__ */ r("div", { className: `sj${t ? " on" : ""}${a ? " anim" : ""}`, "data-theme": n, "data-sj-ignore": !0, children: [
|
|
792
|
+
U.map(([x, T, M, E], A) => /* @__PURE__ */ e("div", { className: "sj-p", style: { top: F(x), left: F(T), width: F(M), height: F(E) } }, A)),
|
|
793
|
+
/* @__PURE__ */ e("div", { className: "sj-ring", style: p ? { top: p.hole.y, left: p.hole.x, width: F(p.hole.w), height: F(p.hole.h), opacity: p.centered ? 0 : 1 } : { opacity: 0 } }),
|
|
794
|
+
/* @__PURE__ */ r(
|
|
795
|
+
"div",
|
|
796
|
+
{
|
|
797
|
+
ref: o,
|
|
798
|
+
className: "sj-pop",
|
|
799
|
+
role: "dialog",
|
|
800
|
+
"aria-modal": "true",
|
|
801
|
+
"aria-live": "polite",
|
|
802
|
+
"data-side": (p == null ? void 0 : p.side) ?? "c",
|
|
803
|
+
style: { transform: p ? `translate(${p.x}px,${p.y}px)` : void 0, "--ax": ((p == null ? void 0 : p.ax) ?? 0) + "px", "--ay": ((p == null ? void 0 : p.ay) ?? 0) + "px" },
|
|
804
|
+
children: [
|
|
805
|
+
/* @__PURE__ */ e("i", { className: "sj-arr" }),
|
|
806
|
+
/* @__PURE__ */ e("div", { className: "sj-bar", children: /* @__PURE__ */ e("b", { style: { width: Math.round((i + 1) / s.length * 100) + "%" } }) }),
|
|
807
|
+
/* @__PURE__ */ r("div", { className: "sj-hd", children: [
|
|
808
|
+
/* @__PURE__ */ e("span", { children: v.welcome ? "Welcome" : `Step ${i + 1} of ${s.length}` }),
|
|
809
|
+
/* @__PURE__ */ r("span", { children: [
|
|
810
|
+
/* @__PURE__ */ e("button", { className: "sj-x", "aria-label": "Switch light or dark theme", onClick: d, children: "◐" }),
|
|
811
|
+
/* @__PURE__ */ e("button", { className: "sj-x", "aria-label": "Close tour", onClick: c, children: "×" })
|
|
812
|
+
] })
|
|
813
|
+
] }),
|
|
814
|
+
/* @__PURE__ */ e("h3", { children: v.title }),
|
|
815
|
+
/* @__PURE__ */ e("p", { children: v.body }),
|
|
816
|
+
/* @__PURE__ */ r("div", { className: "sj-ft", children: [
|
|
817
|
+
/* @__PURE__ */ e("button", { className: "sj-g", style: { visibility: R ? "hidden" : "visible" }, onClick: c, children: "Skip" }),
|
|
818
|
+
/* @__PURE__ */ r("span", { children: [
|
|
819
|
+
/* @__PURE__ */ e("button", { className: "sj-g", style: { visibility: i ? "visible" : "hidden" }, onClick: w, children: "Back" }),
|
|
820
|
+
/* @__PURE__ */ e("button", { ref: u, className: "sj-b", onClick: g, children: v.welcome ? m || "Start tour" : R ? "Finish" : "Next" })
|
|
821
|
+
] })
|
|
822
|
+
] })
|
|
823
|
+
]
|
|
824
|
+
}
|
|
825
|
+
)
|
|
826
|
+
] }),
|
|
827
|
+
document.body
|
|
828
|
+
);
|
|
829
|
+
}, tt = ({ tracker: t }) => {
|
|
830
|
+
const a = _(null);
|
|
831
|
+
return B(() => {
|
|
832
|
+
const n = () => {
|
|
833
|
+
const i = a.current;
|
|
834
|
+
if (!i) return;
|
|
835
|
+
const m = i.getContext("2d");
|
|
836
|
+
if (!m) return;
|
|
837
|
+
const f = document.documentElement.scrollWidth, g = t.state.heat[location.pathname + location.hash] || {};
|
|
838
|
+
i.width = innerWidth, i.height = innerHeight, m.globalCompositeOperation = "lighter";
|
|
839
|
+
for (const w in g) {
|
|
840
|
+
const [c, d] = w.split(",").map(Number), o = c / 100 * f - scrollX, u = d * 20 + 10 - scrollY;
|
|
841
|
+
if (o < -40 || u < -40 || o > innerWidth + 40 || u > innerHeight + 40) continue;
|
|
842
|
+
const h = Math.min(1, g[w] / 6), l = m.createRadialGradient(o, u, 0, o, u, 34);
|
|
843
|
+
l.addColorStop(0, `rgba(255,70,50,${0.5 * h + 0.1})`), l.addColorStop(1, "rgba(255,70,50,0)"), m.fillStyle = l, m.fillRect(o - 34, u - 34, 68, 68);
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
n();
|
|
847
|
+
const s = window.setInterval(n, 250);
|
|
848
|
+
return addEventListener("scroll", n, { passive: !0 }), addEventListener("resize", n), () => {
|
|
849
|
+
clearInterval(s), removeEventListener("scroll", n), removeEventListener("resize", n);
|
|
850
|
+
};
|
|
851
|
+
}, [t]), ve(/* @__PURE__ */ e("canvas", { ref: a, className: "sj-heat", "data-sj-ignore": !0 }), document.body);
|
|
852
|
+
}, Ne = Te(null);
|
|
853
|
+
function de() {
|
|
854
|
+
const t = je(Ne);
|
|
855
|
+
if (!t) throw new Error("useJourney must be used inside <JourneyProvider>");
|
|
856
|
+
return t;
|
|
857
|
+
}
|
|
858
|
+
function st() {
|
|
859
|
+
const { tracker: t } = de();
|
|
860
|
+
return Ce(t.subscribe, t.getVersion, t.getVersion), t.state;
|
|
861
|
+
}
|
|
862
|
+
const V = (t, a) => {
|
|
863
|
+
try {
|
|
864
|
+
return t();
|
|
865
|
+
} catch {
|
|
866
|
+
return a;
|
|
867
|
+
}
|
|
868
|
+
}, nt = ({ config: t, children: a }) => {
|
|
869
|
+
const n = _(t ?? {});
|
|
870
|
+
n.current = t ?? {};
|
|
871
|
+
const s = Y(() => new ze(() => n.current), []), [i, m] = y(() => V(() => localStorage.getItem("sjTheme"), null) ?? (t == null ? void 0 : t.theme) ?? "auto"), [f, g] = y(() => V(() => matchMedia("(prefers-color-scheme:dark)").matches, !1));
|
|
872
|
+
B(() => {
|
|
873
|
+
const b = matchMedia("(prefers-color-scheme:dark)"), j = () => g(b.matches);
|
|
874
|
+
return b.addEventListener("change", j), () => b.removeEventListener("change", j);
|
|
875
|
+
}, []);
|
|
876
|
+
const w = i === "auto" ? f ? "dark" : "light" : i;
|
|
877
|
+
B(() => {
|
|
878
|
+
document.documentElement.setAttribute("data-sj-theme", w);
|
|
879
|
+
}, [w]);
|
|
880
|
+
const c = L((b) => {
|
|
881
|
+
m(b), V(() => localStorage.setItem("sjTheme", b), void 0), s.track("theme", { theme: b });
|
|
882
|
+
}, [s]);
|
|
883
|
+
B(() => s.attach(), [s]);
|
|
884
|
+
const [d, o] = y(!1), [u, h] = y([]), [l, k] = y(-1), [v, I] = y(!1), P = _([]), R = _(-1), p = _(!1), U = _(!1), F = _(0), x = L((b) => {
|
|
885
|
+
if (!p.current) return;
|
|
886
|
+
const j = P.current[R.current];
|
|
887
|
+
s.tourEnd(b, R.current, (j == null ? void 0 : j.title) ?? "", P.current.length), p.current = !1, o(!1);
|
|
888
|
+
}, [s]), T = L((b, j = 0) => {
|
|
889
|
+
const C = P.current, H = n.current;
|
|
890
|
+
if (b < 0 && (b = 0), b >= C.length) return x("complete");
|
|
891
|
+
const S = C[b];
|
|
892
|
+
if (S.page && S.page !== location.pathname) {
|
|
893
|
+
V(() => sessionStorage.setItem("sjTour", JSON.stringify({ i: b, t: Date.now(), go: 1 })), void 0), s.track("step_navigate", { step: b, to: S.page }), s.flush(!0), location.href = S.page;
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
if (S.wait && !S.el && S.target && (S.el = document.querySelector(S.target)), S.target && !ie(S.el)) {
|
|
897
|
+
if (j < (H.waitMs ?? 2500) / 100) {
|
|
898
|
+
window.setTimeout(() => {
|
|
899
|
+
p.current && T(b, j + 1);
|
|
900
|
+
}, 100);
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
s.track("step_missing", { step: b, target: S.target });
|
|
904
|
+
const G = b >= R.current ? 1 : -1;
|
|
905
|
+
return T(b + (b + G < 0 ? 1 : G), 0);
|
|
906
|
+
}
|
|
907
|
+
R.current = b, k(b), s.stepView(b, S.title, C.length), U.current && (I(!0), clearTimeout(F.current), F.current = window.setTimeout(() => I(!1), 520)), ie(S.el) && S.el.scrollIntoView({ block: "center", behavior: U.current ? "smooth" : "auto" }), U.current || requestAnimationFrame(() => {
|
|
908
|
+
U.current = !0;
|
|
909
|
+
});
|
|
910
|
+
}, [x, s]), M = L((b = 0, j = !1) => {
|
|
911
|
+
const C = Ze(n.current);
|
|
912
|
+
C.length && (P.current = C, h(C), p.current = !0, U.current = !1, o(!0), s.tourStart(C.length, j), T(b));
|
|
913
|
+
}, [T, s]), E = L(() => M(0), [M]), A = L(() => x("skip"), [x]), N = L(() => {
|
|
914
|
+
p.current && (s.track("step_next", { step: R.current }), T(R.current + 1));
|
|
915
|
+
}, [T, s]), D = L(() => {
|
|
916
|
+
p.current && T(R.current - 1);
|
|
917
|
+
}, [T]);
|
|
918
|
+
B(() => {
|
|
919
|
+
const b = V(() => JSON.parse(sessionStorage.getItem("sjTour") || "null"), null), j = n.current;
|
|
920
|
+
let C;
|
|
921
|
+
return b && Date.now() - b.t < 3e5 ? C = window.setTimeout(() => M(b.i, !0), 400) : j.autoStart !== !1 && !(j.once && V(() => localStorage.getItem("sjDone"), null)) && (C = window.setTimeout(() => M(0), 600)), () => clearTimeout(C);
|
|
922
|
+
}, [M]), B(() => () => {
|
|
923
|
+
p.current = !1;
|
|
924
|
+
}, []), B(() => {
|
|
925
|
+
if (!d) return;
|
|
926
|
+
const b = (j) => {
|
|
927
|
+
j.key === "Escape" ? x("skip") : j.key === "ArrowRight" ? N() : j.key === "ArrowLeft" && D();
|
|
928
|
+
};
|
|
929
|
+
return addEventListener("keydown", b), () => removeEventListener("keydown", b);
|
|
930
|
+
}, [d, x, N, D]);
|
|
931
|
+
const [$, O] = y(!1), W = L(() => O((b) => !b), []), J = L((b) => s.configure(b), [s]), Q = Y(() => ({
|
|
932
|
+
tracker: s,
|
|
933
|
+
theme: i,
|
|
934
|
+
resolvedTheme: w,
|
|
935
|
+
setTheme: c,
|
|
936
|
+
open: d,
|
|
937
|
+
start: E,
|
|
938
|
+
stop: A,
|
|
939
|
+
next: N,
|
|
940
|
+
back: D,
|
|
941
|
+
heat: $,
|
|
942
|
+
toggleHeat: W,
|
|
943
|
+
configure: J
|
|
944
|
+
}), [s, i, w, c, d, E, A, N, D, $, W, J]);
|
|
945
|
+
return /* @__PURE__ */ r(Ne.Provider, { value: Q, children: [
|
|
946
|
+
a,
|
|
947
|
+
u.length > 0 && /* @__PURE__ */ e(
|
|
948
|
+
et,
|
|
949
|
+
{
|
|
950
|
+
open: d,
|
|
951
|
+
anim: v,
|
|
952
|
+
theme: w,
|
|
953
|
+
steps: u,
|
|
954
|
+
index: l,
|
|
955
|
+
startLabel: t == null ? void 0 : t.startLabel,
|
|
956
|
+
tracker: s,
|
|
957
|
+
onNext: N,
|
|
958
|
+
onBack: D,
|
|
959
|
+
onSkip: A,
|
|
960
|
+
onTheme: () => c(w === "dark" ? "light" : "dark")
|
|
961
|
+
}
|
|
962
|
+
),
|
|
963
|
+
$ && /* @__PURE__ */ e(tt, { tracker: s })
|
|
964
|
+
] });
|
|
965
|
+
}, ne = (t) => t < 6e4 ? (t / 1e3).toFixed(1) + "s" : Math.floor(t / 6e4) + "m " + Math.round(t % 6e4 / 1e3) + "s", at = `import { JourneyProvider } from '@shiva004/surveys';
|
|
966
|
+
|
|
967
|
+
<JourneyProvider
|
|
968
|
+
config={{
|
|
969
|
+
endpoint: '/api/journey/events',
|
|
970
|
+
theme: 'auto', // auto | light | dark
|
|
971
|
+
welcome: { title: 'Welcome', body: 'Quick tour?' },
|
|
972
|
+
steps: [
|
|
973
|
+
{ target: '#menu', title: 'Menu',
|
|
974
|
+
body: 'Your navigation.', placement: 'bottom' },
|
|
975
|
+
{ target: '#billing', page: '/billing',
|
|
976
|
+
title: 'Billing', body: 'Next page.' },
|
|
977
|
+
],
|
|
978
|
+
}}
|
|
979
|
+
>
|
|
980
|
+
<App />
|
|
981
|
+
</JourneyProvider>`, it = ({ open: t, onClose: a }) => {
|
|
982
|
+
const { toggleHeat: n, configure: s } = de(), i = st(), [m, f] = y("m"), g = location.pathname + location.hash, w = i.pages[g] || { ms: 0, depth: 0 }, c = i.started ? Math.round(i.completed / i.started * 100) + "%" : "–", d = [["Time on page", ne(w.ms)], ["Scrolling", ne(i.scrollMs)], ["Scroll depth", w.depth + "%"], ["Clicks", i.clicks], ["Completion", c], ["Navigations", i.nav]], o = Object.entries(i.steps).sort((h, l) => +h[0] - +l[0]), u = Math.max(1, ...o.map((h) => h[1].ms));
|
|
983
|
+
return /* @__PURE__ */ r("aside", { className: `nw-ins${t ? " open" : ""}`, "data-sj-ignore": !0, "aria-label": "Journey insights", children: [
|
|
984
|
+
/* @__PURE__ */ r("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
985
|
+
/* @__PURE__ */ e("strong", { children: "Journey insights" }),
|
|
986
|
+
/* @__PURE__ */ e("button", { className: "nw-x", onClick: a, "aria-label": "Close", children: "×" })
|
|
987
|
+
] }),
|
|
988
|
+
/* @__PURE__ */ e("div", { className: "nw-tabs", children: [["m", "Metrics"], ["e", "Events"], ["c", "Embed"]].map(([h, l]) => /* @__PURE__ */ e("button", { className: m === h ? "on" : "", onClick: () => f(h), children: l }, h)) }),
|
|
989
|
+
m === "m" && /* @__PURE__ */ r(ae, { children: [
|
|
990
|
+
/* @__PURE__ */ e("div", { className: "nw-kpis", children: d.map(([h, l]) => /* @__PURE__ */ r("div", { className: "nw-kpi", children: [
|
|
991
|
+
/* @__PURE__ */ e("small", { children: h }),
|
|
992
|
+
/* @__PURE__ */ e("b", { children: l })
|
|
993
|
+
] }, h)) }),
|
|
994
|
+
/* @__PURE__ */ e("h4", { children: "Time per page" }),
|
|
995
|
+
Object.entries(i.pages).map(([h, l]) => /* @__PURE__ */ r("div", { className: "nw-row", children: [
|
|
996
|
+
/* @__PURE__ */ e("span", { children: h }),
|
|
997
|
+
/* @__PURE__ */ r("span", { children: [
|
|
998
|
+
ne(l.ms),
|
|
999
|
+
" · ",
|
|
1000
|
+
l.depth,
|
|
1001
|
+
"% deep"
|
|
1002
|
+
] })
|
|
1003
|
+
] }, h)),
|
|
1004
|
+
/* @__PURE__ */ e("h4", { children: "Walkthrough funnel and drop-offs" }),
|
|
1005
|
+
o.length ? o.map(([h, l]) => /* @__PURE__ */ r(ge.Fragment, { children: [
|
|
1006
|
+
/* @__PURE__ */ r("div", { className: "nw-row", children: [
|
|
1007
|
+
/* @__PURE__ */ r("span", { children: [
|
|
1008
|
+
+h + 1,
|
|
1009
|
+
". ",
|
|
1010
|
+
l.title
|
|
1011
|
+
] }),
|
|
1012
|
+
/* @__PURE__ */ r("span", { children: [
|
|
1013
|
+
l.views,
|
|
1014
|
+
"× · ",
|
|
1015
|
+
ne(l.ms),
|
|
1016
|
+
i.drops[+h] ? /* @__PURE__ */ r(ae, { children: [
|
|
1017
|
+
" · ",
|
|
1018
|
+
/* @__PURE__ */ r("b", { className: "nw-warn", children: [
|
|
1019
|
+
i.drops[+h],
|
|
1020
|
+
" dropped"
|
|
1021
|
+
] })
|
|
1022
|
+
] }) : null
|
|
1023
|
+
] })
|
|
1024
|
+
] }),
|
|
1025
|
+
/* @__PURE__ */ e("div", { className: "nw-meter", children: /* @__PURE__ */ e("i", { style: { width: Math.round(l.ms / u * 100) + "%" } }) })
|
|
1026
|
+
] }, h)) : /* @__PURE__ */ r("div", { className: "nw-row", children: [
|
|
1027
|
+
/* @__PURE__ */ e("span", { children: "No tour data yet" }),
|
|
1028
|
+
/* @__PURE__ */ e("span", {})
|
|
1029
|
+
] }),
|
|
1030
|
+
/* @__PURE__ */ e("h4", { children: "Heatmap" }),
|
|
1031
|
+
/* @__PURE__ */ e("button", { className: "nw-btn", onClick: n, children: "Toggle heatmap overlay" })
|
|
1032
|
+
] }),
|
|
1033
|
+
m === "e" && i.log.slice(0, 30).map((h, l) => /* @__PURE__ */ r("div", { className: "nw-row", children: [
|
|
1034
|
+
/* @__PURE__ */ e("span", { children: h.type }),
|
|
1035
|
+
/* @__PURE__ */ r("span", { children: [
|
|
1036
|
+
String(h.title || h.sel || h.pct || h.n || h.to || h.theme || ""),
|
|
1037
|
+
" · ",
|
|
1038
|
+
new Date(h.t).toLocaleTimeString()
|
|
1039
|
+
] })
|
|
1040
|
+
] }, `${h.t}-${l}`)),
|
|
1041
|
+
m === "c" && /* @__PURE__ */ r(ae, { children: [
|
|
1042
|
+
/* @__PURE__ */ e("h4", { children: "Install in a React app" }),
|
|
1043
|
+
/* @__PURE__ */ e("pre", { children: at }),
|
|
1044
|
+
/* @__PURE__ */ r("p", { children: [
|
|
1045
|
+
"No ",
|
|
1046
|
+
/* @__PURE__ */ e("code", { children: "steps" }),
|
|
1047
|
+
"? Add ",
|
|
1048
|
+
/* @__PURE__ */ e("code", { children: "data-sj-title" }),
|
|
1049
|
+
", ",
|
|
1050
|
+
/* @__PURE__ */ e("code", { children: "data-sj-body" }),
|
|
1051
|
+
", ",
|
|
1052
|
+
/* @__PURE__ */ e("code", { children: "data-sj-place" }),
|
|
1053
|
+
" and ",
|
|
1054
|
+
/* @__PURE__ */ e("code", { children: "data-sj-step" }),
|
|
1055
|
+
" to any element, or it falls back to the page’s header, nav, sections and footer. A step with ",
|
|
1056
|
+
/* @__PURE__ */ e("code", { children: "page" }),
|
|
1057
|
+
" continues the tour after navigating."
|
|
1058
|
+
] }),
|
|
1059
|
+
/* @__PURE__ */ e("h4", { children: "Backend endpoint" }),
|
|
1060
|
+
/* @__PURE__ */ e("input", { placeholder: "/api/journey/events", onChange: (h) => s({ endpoint: h.target.value.trim() }) }),
|
|
1061
|
+
/* @__PURE__ */ r("p", { children: [
|
|
1062
|
+
"Run ",
|
|
1063
|
+
/* @__PURE__ */ e("code", { children: "node server.js" }),
|
|
1064
|
+
", open ",
|
|
1065
|
+
/* @__PURE__ */ e("code", { children: "http://localhost:4000/?api=/api/journey/events" }),
|
|
1066
|
+
". Without an endpoint it runs in dry-run mode and the Events tab shows each flush."
|
|
1067
|
+
] })
|
|
1068
|
+
] })
|
|
1069
|
+
] });
|
|
1070
|
+
}, rt = () => {
|
|
1071
|
+
const { start: t, setTheme: a, resolvedTheme: n } = de(), [s, i] = y(!1);
|
|
1072
|
+
return /* @__PURE__ */ r("div", { className: "nw", id: "top", children: [
|
|
1073
|
+
/* @__PURE__ */ r("header", { className: "nw-head", "data-sj-step": 1, "data-sj-title": "Main navigation", "data-sj-body": "Jump between Features, Pricing and Contact from here. It stays visible as you scroll.", "data-sj-place": "bottom", children: [
|
|
1074
|
+
/* @__PURE__ */ r("a", { className: "nw-logo", href: "#top", children: [
|
|
1075
|
+
/* @__PURE__ */ e("i", { children: "◆" }),
|
|
1076
|
+
" Northwind"
|
|
1077
|
+
] }),
|
|
1078
|
+
/* @__PURE__ */ r("nav", { className: "nw-nav", children: [
|
|
1079
|
+
/* @__PURE__ */ e("a", { href: "#features", children: "Features" }),
|
|
1080
|
+
/* @__PURE__ */ e("a", { href: "#pricing", children: "Pricing" }),
|
|
1081
|
+
/* @__PURE__ */ e("a", { href: "#contact", children: "Contact" })
|
|
1082
|
+
] }),
|
|
1083
|
+
/* @__PURE__ */ e("button", { className: "nw-btn", id: "srch", "data-sj-step": 2, "data-sj-title": "Search", "data-sj-body": "Find any page or help article instantly.", "data-sj-place": "left", children: "Search" })
|
|
1084
|
+
] }),
|
|
1085
|
+
/* @__PURE__ */ r("main", { className: "nw-wrap", children: [
|
|
1086
|
+
/* @__PURE__ */ r("section", { className: "nw-hero", children: [
|
|
1087
|
+
/* @__PURE__ */ e("h1", { children: "Ship products people actually finish onboarding." }),
|
|
1088
|
+
/* @__PURE__ */ e("p", { children: "Northwind is a sample site. The walkthrough reads each element’s position at runtime, so the same component fits any layout." }),
|
|
1089
|
+
/* @__PURE__ */ r("div", { className: "nw-acts", children: [
|
|
1090
|
+
/* @__PURE__ */ e("a", { className: "nw-btn p", href: "#pricing", "data-sj-step": 3, "data-sj-title": "Primary action", "data-sj-body": "Start here. This button takes new visitors straight to the plans. You can click it while it is highlighted.", "data-sj-place": "right", children: "Get started" }),
|
|
1091
|
+
/* @__PURE__ */ e("a", { className: "nw-btn", href: "#features", children: "See features" })
|
|
1092
|
+
] })
|
|
1093
|
+
] }),
|
|
1094
|
+
/* @__PURE__ */ r("section", { id: "features", "data-sj-step": 4, "data-sj-title": "Feature overview", "data-sj-body": "Three things Northwind does best. Large sections are fitted to the screen automatically.", "data-sj-place": "top", children: [
|
|
1095
|
+
/* @__PURE__ */ e("h2", { children: "Features" }),
|
|
1096
|
+
/* @__PURE__ */ r("div", { className: "nw-grid", children: [
|
|
1097
|
+
/* @__PURE__ */ r("div", { className: "nw-card", children: [
|
|
1098
|
+
/* @__PURE__ */ e("h3", { children: "Live analytics" }),
|
|
1099
|
+
/* @__PURE__ */ e("p", { children: "Page time, scroll depth and clicks, collected as people browse." })
|
|
1100
|
+
] }),
|
|
1101
|
+
/* @__PURE__ */ r("div", { className: "nw-card", children: [
|
|
1102
|
+
/* @__PURE__ */ e("h3", { children: "Heatmaps" }),
|
|
1103
|
+
/* @__PURE__ */ e("p", { children: "See where attention gathers and where it never reaches." })
|
|
1104
|
+
] }),
|
|
1105
|
+
/* @__PURE__ */ r("div", { className: "nw-card", children: [
|
|
1106
|
+
/* @__PURE__ */ e("h3", { children: "Guided tours" }),
|
|
1107
|
+
/* @__PURE__ */ e("p", { children: "Spotlight any element with a popup that repositions itself." })
|
|
1108
|
+
] })
|
|
1109
|
+
] })
|
|
1110
|
+
] }),
|
|
1111
|
+
/* @__PURE__ */ r("section", { id: "pricing", children: [
|
|
1112
|
+
/* @__PURE__ */ e("h2", { children: "Pricing" }),
|
|
1113
|
+
/* @__PURE__ */ r("div", { className: "nw-grid", children: [
|
|
1114
|
+
/* @__PURE__ */ r("div", { className: "nw-card", children: [
|
|
1115
|
+
/* @__PURE__ */ e("h3", { children: "Starter" }),
|
|
1116
|
+
/* @__PURE__ */ e("div", { className: "nw-big", children: "$0" }),
|
|
1117
|
+
/* @__PURE__ */ e("p", { children: "For side projects." })
|
|
1118
|
+
] }),
|
|
1119
|
+
/* @__PURE__ */ r("div", { className: "nw-card", children: [
|
|
1120
|
+
/* @__PURE__ */ e("h3", { children: "Team" }),
|
|
1121
|
+
/* @__PURE__ */ e("div", { className: "nw-big", children: "$29" }),
|
|
1122
|
+
/* @__PURE__ */ e("p", { children: "For growing teams." })
|
|
1123
|
+
] }),
|
|
1124
|
+
/* @__PURE__ */ r("div", { className: "nw-card hot", "data-sj-step": 5, "data-sj-title": "Recommended plan", "data-sj-body": "Most teams pick this one. The popup flips sides on its own when there is no room.", "data-sj-place": "left", children: [
|
|
1125
|
+
/* @__PURE__ */ e("h3", { children: "Scale" }),
|
|
1126
|
+
/* @__PURE__ */ e("div", { className: "nw-big", children: "$99" }),
|
|
1127
|
+
/* @__PURE__ */ e("p", { children: "Unlimited journeys and exports." })
|
|
1128
|
+
] })
|
|
1129
|
+
] })
|
|
1130
|
+
] }),
|
|
1131
|
+
/* @__PURE__ */ r("section", { id: "contact", children: [
|
|
1132
|
+
/* @__PURE__ */ e("h2", { children: "Contact" }),
|
|
1133
|
+
/* @__PURE__ */ e("div", { className: "nw-card", children: /* @__PURE__ */ e("p", { children: "hello@northwind.example: we reply within a day." }) })
|
|
1134
|
+
] })
|
|
1135
|
+
] }),
|
|
1136
|
+
/* @__PURE__ */ e("footer", { className: "nw-foot", "data-sj-step": 6, "data-sj-title": "Footer and help", "data-sj-body": "Legal links, support and contact details live down here.", "data-sj-place": "top", children: "© Northwind · Privacy · Terms · Status" }),
|
|
1137
|
+
/* @__PURE__ */ r("div", { className: "nw-dock", "data-sj-ignore": !0, children: [
|
|
1138
|
+
/* @__PURE__ */ e("button", { onClick: t, children: "▶ Tour" }),
|
|
1139
|
+
/* @__PURE__ */ e("button", { onClick: () => a(n === "dark" ? "light" : "dark"), children: "◐ Theme" }),
|
|
1140
|
+
/* @__PURE__ */ e("button", { onClick: () => i((m) => !m), children: "▤ Insights" })
|
|
1141
|
+
] }),
|
|
1142
|
+
/* @__PURE__ */ e(it, { open: s, onClose: () => i(!1) })
|
|
1143
|
+
] });
|
|
1144
|
+
}, ut = ({ endpoint: t, config: a }) => /* @__PURE__ */ e(
|
|
1145
|
+
nt,
|
|
1146
|
+
{
|
|
1147
|
+
config: {
|
|
1148
|
+
endpoint: t ?? new URLSearchParams(location.search).get("api") ?? "",
|
|
1149
|
+
theme: "auto",
|
|
1150
|
+
welcome: { title: "Welcome to Northwind", body: "Take a 30-second tour of the key parts of this site. Skip any time, or use the arrow keys." },
|
|
1151
|
+
outro: { title: "You’re all set", body: "Open Insights to see the time, scroll depth, clicks and heatmap this session just generated." },
|
|
1152
|
+
...a
|
|
1153
|
+
},
|
|
1154
|
+
children: /* @__PURE__ */ e(rt, {})
|
|
1155
|
+
}
|
|
1156
|
+
);
|
|
546
1157
|
export {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
1158
|
+
De as JourneyApp,
|
|
1159
|
+
nt as JourneyProvider,
|
|
1160
|
+
ze as JourneyTracker,
|
|
1161
|
+
Xe as SurveyApp,
|
|
1162
|
+
ht as SurveyJourneyApp,
|
|
1163
|
+
ut as WalkthroughDemo,
|
|
1164
|
+
$e as flowStats,
|
|
1165
|
+
Pe as navigationStats,
|
|
1166
|
+
pe as npsCategory,
|
|
1167
|
+
le as npsOf,
|
|
1168
|
+
ce as npsScores,
|
|
1169
|
+
Re as pathStats,
|
|
1170
|
+
we as simulate,
|
|
1171
|
+
Le as stageReach,
|
|
1172
|
+
de as useJourney,
|
|
1173
|
+
st as useJourneyStats
|
|
552
1174
|
};
|