@refraction-ui/react 0.5.0 → 0.6.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/dist/{chunk-ZWRGVWUY.js → chunk-O4453CBF.js} +20 -3
- package/dist/chunk-O4453CBF.js.map +1 -0
- package/dist/chunk-XWP763SH.js +76 -0
- package/dist/chunk-XWP763SH.js.map +1 -0
- package/dist/faro-engine-47HGRAQH-JKINJPMH.js +3 -0
- package/dist/faro-engine-47HGRAQH-JKINJPMH.js.map +1 -0
- package/dist/form.cjs +25 -0
- package/dist/form.cjs.map +1 -1
- package/dist/form.js +9 -1
- package/dist/form.js.map +1 -1
- package/dist/index.cjs +1438 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1317 -12
- package/dist/index.js.map +1 -1
- package/dist/internal/analytics/index.d.cts +448 -0
- package/dist/internal/analytics/index.d.ts +448 -0
- package/dist/internal/logger/index.d.cts +229 -0
- package/dist/internal/logger/index.d.ts +229 -0
- package/dist/internal/react-analytics/index.d.cts +44 -0
- package/dist/internal/react-analytics/index.d.ts +44 -0
- package/dist/internal/react-logger/index.d.cts +107 -0
- package/dist/internal/react-logger/index.d.ts +107 -0
- package/dist/internal/shared/index.d.cts +171 -1
- package/dist/internal/shared/index.d.ts +171 -1
- package/dist/theme.cjs +23 -0
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.js +5 -2
- package/dist/theme.js.map +1 -1
- package/package.json +4 -2
- package/dist/chunk-ZWRGVWUY.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -25,7 +25,104 @@ function _interopNamespace(e) {
|
|
|
25
25
|
var React11__namespace = /*#__PURE__*/_interopNamespace(React11);
|
|
26
26
|
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
var __defProp = Object.defineProperty;
|
|
29
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
30
|
+
var __esm = (fn, res) => function __init() {
|
|
31
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
32
|
+
};
|
|
33
|
+
var __export = (target, all) => {
|
|
34
|
+
for (var name in all)
|
|
35
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// ../logger/dist/chunk-57LG5ZUS.js
|
|
39
|
+
async function createFaroSink(opts) {
|
|
40
|
+
const transport = opts.transport ?? await loadFaroTransport(opts);
|
|
41
|
+
if (!transport) return null;
|
|
42
|
+
return {
|
|
43
|
+
name: "faro",
|
|
44
|
+
log(record) {
|
|
45
|
+
transport.push({ kind: "log", record });
|
|
46
|
+
},
|
|
47
|
+
span(record) {
|
|
48
|
+
transport.push({ kind: "span", record });
|
|
49
|
+
},
|
|
50
|
+
async flush() {
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function loadFaroTransport(opts) {
|
|
55
|
+
try {
|
|
56
|
+
const sdkName = "@grafana/faro-web-sdk";
|
|
57
|
+
const tracingName = "@grafana/faro-web-tracing";
|
|
58
|
+
const sdk = await import(
|
|
59
|
+
/* @vite-ignore */
|
|
60
|
+
sdkName
|
|
61
|
+
);
|
|
62
|
+
const tracing = await import(
|
|
63
|
+
/* @vite-ignore */
|
|
64
|
+
tracingName
|
|
65
|
+
);
|
|
66
|
+
const faro = sdk.initializeFaro({
|
|
67
|
+
url: opts.endpoint,
|
|
68
|
+
app: { name: opts.app },
|
|
69
|
+
instrumentations: [
|
|
70
|
+
...sdk.getWebInstrumentations(),
|
|
71
|
+
new tracing.TracingInstrumentation()
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
push({ kind, record }) {
|
|
76
|
+
if (kind === "log") {
|
|
77
|
+
const r = record;
|
|
78
|
+
faro.api.pushLog([r.message], {
|
|
79
|
+
level: FARO_LEVEL[r.level],
|
|
80
|
+
context: flatten(r.context)
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
const r = record;
|
|
84
|
+
faro.api.pushEvent(`span:${r.name}`, {
|
|
85
|
+
durationMs: String(r.durationMs),
|
|
86
|
+
status: r.status,
|
|
87
|
+
...flatten(r.context)
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
} catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function flatten(ctx) {
|
|
97
|
+
const out = {};
|
|
98
|
+
for (const [k, v] of Object.entries(ctx)) {
|
|
99
|
+
out[k] = typeof v === "string" ? v : JSON.stringify(v);
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
var FARO_LEVEL;
|
|
104
|
+
var init_chunk_57LG5ZUS = __esm({
|
|
105
|
+
"../logger/dist/chunk-57LG5ZUS.js"() {
|
|
106
|
+
FARO_LEVEL = {
|
|
107
|
+
debug: "debug",
|
|
108
|
+
info: "info",
|
|
109
|
+
warn: "warn",
|
|
110
|
+
error: "error",
|
|
111
|
+
fatal: "error"
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// ../logger/dist/faro-engine-47HGRAQH.js
|
|
117
|
+
var faro_engine_47HGRAQH_exports = {};
|
|
118
|
+
__export(faro_engine_47HGRAQH_exports, {
|
|
119
|
+
createFaroSink: () => createFaroSink
|
|
120
|
+
});
|
|
121
|
+
var init_faro_engine_47HGRAQH = __esm({
|
|
122
|
+
"../logger/dist/faro-engine-47HGRAQH.js"() {
|
|
123
|
+
init_chunk_57LG5ZUS();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
29
126
|
|
|
30
127
|
// ../shared/dist/index.js
|
|
31
128
|
var idCounter = 0;
|
|
@@ -138,6 +235,23 @@ function cva(config) {
|
|
|
138
235
|
return classes.filter(Boolean).join(" ");
|
|
139
236
|
};
|
|
140
237
|
}
|
|
238
|
+
var seen = /* @__PURE__ */ new Set();
|
|
239
|
+
function isDev() {
|
|
240
|
+
return typeof process === "undefined" || process.env?.NODE_ENV !== "production";
|
|
241
|
+
}
|
|
242
|
+
function emit(level, code, message, detail) {
|
|
243
|
+
if (!isDev()) return;
|
|
244
|
+
const key = `${level}:${code}`;
|
|
245
|
+
if (seen.has(key)) return;
|
|
246
|
+
seen.add(key);
|
|
247
|
+
const text = `[refraction-ui] ${code}: ${message}`;
|
|
248
|
+
{
|
|
249
|
+
console.warn(text, "");
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function devWarn(code, message, detail) {
|
|
253
|
+
emit("warn", code, message);
|
|
254
|
+
}
|
|
141
255
|
var AccordionContext = React11__namespace.createContext(null);
|
|
142
256
|
var Accordion = React11__namespace.forwardRef(
|
|
143
257
|
({ className, type = "single", collapsible, value: controlledValue, defaultValue, onValueChange, ...props }, ref) => {
|
|
@@ -168,7 +282,13 @@ var AccordionItemContext = React11__namespace.createContext(null);
|
|
|
168
282
|
var AccordionItem = React11__namespace.forwardRef(
|
|
169
283
|
({ className, value, ...props }, ref) => {
|
|
170
284
|
const context = React11__namespace.useContext(AccordionContext);
|
|
171
|
-
if (!context)
|
|
285
|
+
if (!context) {
|
|
286
|
+
devWarn(
|
|
287
|
+
"react-accordion/item-outside-accordion",
|
|
288
|
+
"<AccordionItem> must be rendered inside an <Accordion>. The missing AccordionContext makes this throw."
|
|
289
|
+
);
|
|
290
|
+
throw new Error("AccordionItem must be within Accordion");
|
|
291
|
+
}
|
|
172
292
|
const isOpen = context.type === "single" ? context.value === value : Array.isArray(context.value) && context.value.includes(value);
|
|
173
293
|
return /* @__PURE__ */ jsxRuntime.jsx(AccordionItemContext.Provider, { value: { value, isOpen }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("border-b border-border", className), "data-state": isOpen ? "open" : "closed", ...props }) });
|
|
174
294
|
}
|
|
@@ -178,7 +298,13 @@ var AccordionTrigger = React11__namespace.forwardRef(
|
|
|
178
298
|
({ className, children, ...props }, ref) => {
|
|
179
299
|
const accordionContext = React11__namespace.useContext(AccordionContext);
|
|
180
300
|
const itemContext = React11__namespace.useContext(AccordionItemContext);
|
|
181
|
-
if (!accordionContext || !itemContext)
|
|
301
|
+
if (!accordionContext || !itemContext) {
|
|
302
|
+
devWarn(
|
|
303
|
+
"react-accordion/trigger-missing-context",
|
|
304
|
+
"<AccordionTrigger> must be rendered inside an <AccordionItem> within an <Accordion>. The missing AccordionContext/AccordionItemContext makes this throw."
|
|
305
|
+
);
|
|
306
|
+
throw new Error("AccordionTrigger missing context");
|
|
307
|
+
}
|
|
182
308
|
return /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "flex m-0 p-0", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
183
309
|
"button",
|
|
184
310
|
{
|
|
@@ -219,7 +345,13 @@ AccordionTrigger.displayName = "AccordionTrigger";
|
|
|
219
345
|
var AccordionContent = React11__namespace.forwardRef(
|
|
220
346
|
({ className, children, ...props }, ref) => {
|
|
221
347
|
const itemContext = React11__namespace.useContext(AccordionItemContext);
|
|
222
|
-
if (!itemContext)
|
|
348
|
+
if (!itemContext) {
|
|
349
|
+
devWarn(
|
|
350
|
+
"react-accordion/content-missing-context",
|
|
351
|
+
"<AccordionContent> must be rendered inside an <AccordionItem>. The missing AccordionItemContext makes this throw."
|
|
352
|
+
);
|
|
353
|
+
throw new Error("AccordionContent missing context");
|
|
354
|
+
}
|
|
223
355
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
224
356
|
"div",
|
|
225
357
|
{
|
|
@@ -517,6 +649,10 @@ function AuthProvider({ children, ...config }) {
|
|
|
517
649
|
const authRef = React11__namespace.useRef(null);
|
|
518
650
|
if (!authRef.current) {
|
|
519
651
|
if (!config.adapter && !config.testMode) {
|
|
652
|
+
devWarn(
|
|
653
|
+
"react-auth/missing-adapter",
|
|
654
|
+
"<AuthProvider> was rendered without a required `adapter` prop (and not in `testMode`). Pass an auth adapter so the provider can create an auth instance."
|
|
655
|
+
);
|
|
520
656
|
throw new Error("[refraction-ui/react-auth] You must provide an `adapter` to AuthProvider.");
|
|
521
657
|
}
|
|
522
658
|
authRef.current = createAuth(config.adapter, config);
|
|
@@ -548,6 +684,10 @@ function AuthProvider({ children, ...config }) {
|
|
|
548
684
|
function useAuth() {
|
|
549
685
|
const ctx = React11__namespace.useContext(AuthContext);
|
|
550
686
|
if (!ctx) {
|
|
687
|
+
devWarn(
|
|
688
|
+
"react-auth/use-auth-outside-provider",
|
|
689
|
+
"useAuth() was called outside an <AuthProvider>. Wrap your app (or the consuming subtree) in <AuthProvider> so the auth context is available."
|
|
690
|
+
);
|
|
551
691
|
throw new Error("useAuth must be used within an <AuthProvider>");
|
|
552
692
|
}
|
|
553
693
|
return ctx;
|
|
@@ -1744,6 +1884,10 @@ var CollapsibleContext = React11__namespace.createContext(null);
|
|
|
1744
1884
|
function useCollapsibleContext() {
|
|
1745
1885
|
const ctx = React11__namespace.useContext(CollapsibleContext);
|
|
1746
1886
|
if (!ctx) {
|
|
1887
|
+
devWarn(
|
|
1888
|
+
"react-collapsible/context-outside-provider",
|
|
1889
|
+
"Collapsible compound components (CollapsibleTrigger/CollapsibleContent) must be rendered inside a <Collapsible>. The missing CollapsibleContext makes this throw."
|
|
1890
|
+
);
|
|
1747
1891
|
throw new Error(
|
|
1748
1892
|
"Collapsible compound components must be used within <Collapsible>"
|
|
1749
1893
|
);
|
|
@@ -1891,6 +2035,10 @@ var ComboboxContext = React11__namespace.createContext(null);
|
|
|
1891
2035
|
function useComboboxContext() {
|
|
1892
2036
|
const ctx = React11__namespace.useContext(ComboboxContext);
|
|
1893
2037
|
if (!ctx) {
|
|
2038
|
+
devWarn(
|
|
2039
|
+
"react-combobox/context-outside-provider",
|
|
2040
|
+
"Combobox compound components (ComboboxInput/ComboboxContent/ComboboxItem/etc.) must be rendered inside a <Combobox>. The missing ComboboxContext makes this throw."
|
|
2041
|
+
);
|
|
1894
2042
|
throw new Error("Combobox compound components must be used within <Combobox>");
|
|
1895
2043
|
}
|
|
1896
2044
|
return ctx;
|
|
@@ -2563,6 +2711,10 @@ var CommandContext = React11__namespace.createContext(null);
|
|
|
2563
2711
|
function useCommandContext() {
|
|
2564
2712
|
const ctx = React11__namespace.useContext(CommandContext);
|
|
2565
2713
|
if (!ctx) {
|
|
2714
|
+
devWarn(
|
|
2715
|
+
"react-command/context-outside-provider",
|
|
2716
|
+
"Command compound components (CommandInput/CommandList/CommandItem/CommandGroup/etc.) must be rendered inside a <Command>. The missing CommandContext makes this throw."
|
|
2717
|
+
);
|
|
2566
2718
|
throw new Error("Command compound components must be used within <Command>");
|
|
2567
2719
|
}
|
|
2568
2720
|
return ctx;
|
|
@@ -3400,6 +3552,10 @@ var DialogContext = React11__namespace.createContext(null);
|
|
|
3400
3552
|
function useDialogContext() {
|
|
3401
3553
|
const ctx = React11__namespace.useContext(DialogContext);
|
|
3402
3554
|
if (!ctx) {
|
|
3555
|
+
devWarn(
|
|
3556
|
+
"react-dialog/context-outside-provider",
|
|
3557
|
+
"Dialog compound components (DialogTrigger/DialogContent/DialogTitle/etc.) must be rendered inside a <Dialog>. The missing DialogContext makes this throw."
|
|
3558
|
+
);
|
|
3403
3559
|
throw new Error("Dialog compound components must be used within <Dialog>");
|
|
3404
3560
|
}
|
|
3405
3561
|
return ctx;
|
|
@@ -3687,6 +3843,10 @@ var DropdownMenuContext = React11__namespace.createContext(null);
|
|
|
3687
3843
|
function useDropdownMenuContext() {
|
|
3688
3844
|
const ctx = React11__namespace.useContext(DropdownMenuContext);
|
|
3689
3845
|
if (!ctx) {
|
|
3846
|
+
devWarn(
|
|
3847
|
+
"react-dropdown-menu/context-outside-provider",
|
|
3848
|
+
"DropdownMenu compound components (DropdownMenuTrigger/DropdownMenuContent/DropdownMenuItem/etc.) must be rendered inside a <DropdownMenu>. The missing DropdownMenuContext makes this throw."
|
|
3849
|
+
);
|
|
3690
3850
|
throw new Error("DropdownMenu compound components must be used within <DropdownMenu>");
|
|
3691
3851
|
}
|
|
3692
3852
|
return ctx;
|
|
@@ -4937,6 +5097,10 @@ var MobileNavContext = React11__namespace.createContext(null);
|
|
|
4937
5097
|
function useMobileNavContext() {
|
|
4938
5098
|
const ctx = React11__namespace.useContext(MobileNavContext);
|
|
4939
5099
|
if (!ctx) {
|
|
5100
|
+
devWarn(
|
|
5101
|
+
"react-mobile-nav/compound-outside-provider",
|
|
5102
|
+
"A MobileNav compound component was rendered outside of <MobileNav>. Wrap it in <MobileNav>."
|
|
5103
|
+
);
|
|
4940
5104
|
throw new Error("MobileNav compound components must be used within <MobileNav>");
|
|
4941
5105
|
}
|
|
4942
5106
|
return ctx;
|
|
@@ -5195,6 +5359,10 @@ var PopoverContext = React11__namespace.createContext(null);
|
|
|
5195
5359
|
function usePopoverContext() {
|
|
5196
5360
|
const ctx = React11__namespace.useContext(PopoverContext);
|
|
5197
5361
|
if (!ctx) {
|
|
5362
|
+
devWarn(
|
|
5363
|
+
"react-popover/context-outside-provider",
|
|
5364
|
+
"Popover compound components (PopoverTrigger/PopoverContent/etc.) must be rendered inside a <Popover>. The missing PopoverContext makes this throw."
|
|
5365
|
+
);
|
|
5198
5366
|
throw new Error("Popover compound components must be used within <Popover>");
|
|
5199
5367
|
}
|
|
5200
5368
|
return ctx;
|
|
@@ -5400,6 +5568,10 @@ var SearchBarContext = React11__namespace.createContext(null);
|
|
|
5400
5568
|
function useSearchBarContext() {
|
|
5401
5569
|
const ctx = React11__namespace.useContext(SearchBarContext);
|
|
5402
5570
|
if (!ctx) {
|
|
5571
|
+
devWarn(
|
|
5572
|
+
"react-search-bar/compound-outside-provider",
|
|
5573
|
+
"A SearchBar compound component was rendered outside of <SearchBar>. Wrap it in <SearchBar>."
|
|
5574
|
+
);
|
|
5403
5575
|
throw new Error("SearchBar compound components must be used within <SearchBar>");
|
|
5404
5576
|
}
|
|
5405
5577
|
return ctx;
|
|
@@ -5663,6 +5835,10 @@ var SheetContext = React11__namespace.createContext(null);
|
|
|
5663
5835
|
function useSheetContext() {
|
|
5664
5836
|
const ctx = React11__namespace.useContext(SheetContext);
|
|
5665
5837
|
if (!ctx) {
|
|
5838
|
+
devWarn(
|
|
5839
|
+
"react-sheet/sheet-compound-outside-provider",
|
|
5840
|
+
"A Sheet compound component was rendered outside of <Sheet>. Wrap it in <Sheet>."
|
|
5841
|
+
);
|
|
5666
5842
|
throw new Error("Sheet compound components must be used within <Sheet>");
|
|
5667
5843
|
}
|
|
5668
5844
|
return ctx;
|
|
@@ -6114,6 +6290,10 @@ var TabsContext = React11__namespace.createContext(null);
|
|
|
6114
6290
|
function useTabsContext() {
|
|
6115
6291
|
const ctx = React11__namespace.useContext(TabsContext);
|
|
6116
6292
|
if (!ctx) {
|
|
6293
|
+
devWarn(
|
|
6294
|
+
"react-tabs/context-outside-provider",
|
|
6295
|
+
"Tabs compound components (TabsList/TabsTrigger/TabsContent) must be rendered inside a <Tabs>. The missing TabsContext makes this throw."
|
|
6296
|
+
);
|
|
6117
6297
|
throw new Error("Tabs compound components must be used within <Tabs>");
|
|
6118
6298
|
}
|
|
6119
6299
|
return ctx;
|
|
@@ -6438,6 +6618,10 @@ var ToastContext = React11__namespace.createContext(null);
|
|
|
6438
6618
|
function useToastContext() {
|
|
6439
6619
|
const ctx = React11__namespace.useContext(ToastContext);
|
|
6440
6620
|
if (!ctx) {
|
|
6621
|
+
devWarn(
|
|
6622
|
+
"react-toast/use-toast-outside-provider",
|
|
6623
|
+
"useToast() was called outside a <ToastProvider>. Wrap your app (or the consuming subtree) in <ToastProvider> so the toast context is available."
|
|
6624
|
+
);
|
|
6441
6625
|
throw new Error("useToast must be used within a <ToastProvider>");
|
|
6442
6626
|
}
|
|
6443
6627
|
return ctx;
|
|
@@ -6617,6 +6801,10 @@ var TooltipContext = React11__namespace.createContext(null);
|
|
|
6617
6801
|
function useTooltipContext() {
|
|
6618
6802
|
const ctx = React11__namespace.useContext(TooltipContext);
|
|
6619
6803
|
if (!ctx) {
|
|
6804
|
+
devWarn(
|
|
6805
|
+
"react-tooltip/context-outside-provider",
|
|
6806
|
+
"Tooltip compound components (TooltipTrigger/TooltipContent/etc.) must be rendered inside a <Tooltip>. The missing TooltipContext makes this throw."
|
|
6807
|
+
);
|
|
6620
6808
|
throw new Error("Tooltip compound components must be used within <Tooltip>");
|
|
6621
6809
|
}
|
|
6622
6810
|
return ctx;
|
|
@@ -8818,6 +9006,10 @@ var ResizableLayoutContext = React11__namespace.createContext(null);
|
|
|
8818
9006
|
function useResizableLayoutContext() {
|
|
8819
9007
|
const ctx = React11__namespace.useContext(ResizableLayoutContext);
|
|
8820
9008
|
if (!ctx) {
|
|
9009
|
+
devWarn(
|
|
9010
|
+
"react-resizable-layout/compound-outside-provider",
|
|
9011
|
+
"A Resizable compound component was rendered outside of <ResizableLayout>. Wrap it in <ResizableLayout>."
|
|
9012
|
+
);
|
|
8821
9013
|
throw new Error("Resizable compound components must be used within <ResizableLayout>");
|
|
8822
9014
|
}
|
|
8823
9015
|
return ctx;
|
|
@@ -9199,6 +9391,10 @@ var AppShellContext = React11__namespace.createContext(null);
|
|
|
9199
9391
|
function useAppShell() {
|
|
9200
9392
|
const ctx = React11__namespace.useContext(AppShellContext);
|
|
9201
9393
|
if (!ctx) {
|
|
9394
|
+
devWarn(
|
|
9395
|
+
"react-app-shell/use-app-shell-outside-provider",
|
|
9396
|
+
"useAppShell() was called outside of <AppShell>. Wrap the consuming component tree in <AppShell>."
|
|
9397
|
+
);
|
|
9202
9398
|
throw new Error("useAppShell must be used within <AppShell>");
|
|
9203
9399
|
}
|
|
9204
9400
|
return ctx;
|
|
@@ -9405,6 +9601,10 @@ var PageShellContext = React11__namespace.createContext(null);
|
|
|
9405
9601
|
function usePageShell() {
|
|
9406
9602
|
const ctx = React11__namespace.useContext(PageShellContext);
|
|
9407
9603
|
if (!ctx) {
|
|
9604
|
+
devWarn(
|
|
9605
|
+
"react-app-shell/page-shell-compound-outside-provider",
|
|
9606
|
+
"A PageShell compound component was rendered outside of <PageShell>. Wrap it in <PageShell>."
|
|
9607
|
+
);
|
|
9408
9608
|
throw new Error("PageShell compound components must be used within <PageShell>");
|
|
9409
9609
|
}
|
|
9410
9610
|
return ctx;
|
|
@@ -9507,6 +9707,10 @@ var AuthShellContext = React11__namespace.createContext(null);
|
|
|
9507
9707
|
function useAuthShell() {
|
|
9508
9708
|
const ctx = React11__namespace.useContext(AuthShellContext);
|
|
9509
9709
|
if (!ctx) {
|
|
9710
|
+
devWarn(
|
|
9711
|
+
"react-app-shell/auth-shell-compound-outside-provider",
|
|
9712
|
+
"An AuthShell compound component was rendered outside of <AuthShell>. Wrap it in <AuthShell>."
|
|
9713
|
+
);
|
|
9510
9714
|
throw new Error("AuthShell compound components must be used within <AuthShell>");
|
|
9511
9715
|
}
|
|
9512
9716
|
return ctx;
|
|
@@ -11904,7 +12108,13 @@ function RadioGroup({
|
|
|
11904
12108
|
}
|
|
11905
12109
|
function RadioItem({ value, children, disabled = false, className }) {
|
|
11906
12110
|
const ctx = React11__namespace.useContext(RadioContext);
|
|
11907
|
-
if (!ctx)
|
|
12111
|
+
if (!ctx) {
|
|
12112
|
+
devWarn(
|
|
12113
|
+
"react-radio/radio-item-outside-group",
|
|
12114
|
+
"RadioItem was rendered outside of <RadioGroup>. Wrap it in <RadioGroup>."
|
|
12115
|
+
);
|
|
12116
|
+
throw new Error("RadioItem must be used within RadioGroup");
|
|
12117
|
+
}
|
|
11908
12118
|
const isChecked = ctx.value === value;
|
|
11909
12119
|
const isDisabled = ctx.disabled || disabled;
|
|
11910
12120
|
return React11__namespace.createElement(
|
|
@@ -12171,6 +12381,7 @@ var selectItemVariants = cva({
|
|
|
12171
12381
|
}
|
|
12172
12382
|
});
|
|
12173
12383
|
var SelectContext = React11__namespace.createContext({
|
|
12384
|
+
__isDefault: true,
|
|
12174
12385
|
value: void 0,
|
|
12175
12386
|
onValueChange: () => {
|
|
12176
12387
|
},
|
|
@@ -12183,6 +12394,16 @@ var SelectContext = React11__namespace.createContext({
|
|
|
12183
12394
|
triggerId: "",
|
|
12184
12395
|
contentId: ""
|
|
12185
12396
|
});
|
|
12397
|
+
function useSelectContext(part) {
|
|
12398
|
+
const ctx = React11__namespace.useContext(SelectContext);
|
|
12399
|
+
if (ctx.__isDefault) {
|
|
12400
|
+
devWarn(
|
|
12401
|
+
"react-select/no-select-provider",
|
|
12402
|
+
`<${part}> was rendered without a <Select> ancestor. It is silently reading inert context defaults (clicks/keyboard do nothing, it never opens). Wrap it in <Select>\u2026</Select>.`
|
|
12403
|
+
);
|
|
12404
|
+
}
|
|
12405
|
+
return ctx;
|
|
12406
|
+
}
|
|
12186
12407
|
function Select({
|
|
12187
12408
|
value,
|
|
12188
12409
|
onValueChange,
|
|
@@ -12215,7 +12436,7 @@ function Select({
|
|
|
12215
12436
|
}
|
|
12216
12437
|
var SelectTrigger = React11__namespace.forwardRef(
|
|
12217
12438
|
({ className, children, size = "default", ...props }, ref) => {
|
|
12218
|
-
const { open, setOpen, disabled, triggerId, contentId } =
|
|
12439
|
+
const { open, setOpen, disabled, triggerId, contentId } = useSelectContext("SelectTrigger");
|
|
12219
12440
|
const api = createSelect({ disabled, open });
|
|
12220
12441
|
const handleClick = () => {
|
|
12221
12442
|
if (!disabled) {
|
|
@@ -12274,7 +12495,7 @@ var SelectTrigger = React11__namespace.forwardRef(
|
|
|
12274
12495
|
SelectTrigger.displayName = "SelectTrigger";
|
|
12275
12496
|
var SelectContent = React11__namespace.forwardRef(
|
|
12276
12497
|
({ className, children, ...props }, forwardedRef) => {
|
|
12277
|
-
const { open, contentId, triggerId, setOpen } =
|
|
12498
|
+
const { open, contentId, triggerId, setOpen } = useSelectContext("SelectContent");
|
|
12278
12499
|
const containerRef = React11__namespace.useRef(null);
|
|
12279
12500
|
const ref = React11__namespace.useCallback(
|
|
12280
12501
|
(node) => {
|
|
@@ -12335,7 +12556,7 @@ var SelectContent = React11__namespace.forwardRef(
|
|
|
12335
12556
|
SelectContent.displayName = "SelectContent";
|
|
12336
12557
|
var SelectItem = React11__namespace.forwardRef(
|
|
12337
12558
|
({ className, children, value: itemValue, disabled: itemDisabled = false, ...props }, ref) => {
|
|
12338
|
-
const { value, onValueChange, setOpen, triggerId } =
|
|
12559
|
+
const { value, onValueChange, setOpen, triggerId } = useSelectContext("SelectItem");
|
|
12339
12560
|
const isSelected = value === itemValue;
|
|
12340
12561
|
const handleClick = () => {
|
|
12341
12562
|
if (!itemDisabled) {
|
|
@@ -12902,7 +13123,13 @@ var CarouselItemContext = React11__namespace.createContext(null);
|
|
|
12902
13123
|
var CarouselItem = React11__namespace.forwardRef(
|
|
12903
13124
|
({ className, value, ...props }, ref) => {
|
|
12904
13125
|
const context = React11__namespace.useContext(CarouselContext);
|
|
12905
|
-
if (!context)
|
|
13126
|
+
if (!context) {
|
|
13127
|
+
devWarn(
|
|
13128
|
+
"react-carousel/carousel-item-outside-carousel",
|
|
13129
|
+
"CarouselItem was rendered outside of <Carousel>. Wrap it in <Carousel>."
|
|
13130
|
+
);
|
|
13131
|
+
throw new Error("CarouselItem must be within Carousel");
|
|
13132
|
+
}
|
|
12906
13133
|
const isOpen = context.type === "single" ? context.value === value : Array.isArray(context.value) && context.value.includes(value);
|
|
12907
13134
|
return /* @__PURE__ */ jsxRuntime.jsx(CarouselItemContext.Provider, { value: { value, isOpen }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("border-b border-border", className), "data-state": isOpen ? "open" : "closed", ...props }) });
|
|
12908
13135
|
}
|
|
@@ -12912,7 +13139,13 @@ var CarouselTrigger = React11__namespace.forwardRef(
|
|
|
12912
13139
|
({ className, children, ...props }, ref) => {
|
|
12913
13140
|
const carouselContext = React11__namespace.useContext(CarouselContext);
|
|
12914
13141
|
const itemContext = React11__namespace.useContext(CarouselItemContext);
|
|
12915
|
-
if (!carouselContext || !itemContext)
|
|
13142
|
+
if (!carouselContext || !itemContext) {
|
|
13143
|
+
devWarn(
|
|
13144
|
+
"react-carousel/carousel-trigger-outside-item",
|
|
13145
|
+
"CarouselTrigger was rendered outside of a <CarouselItem> within <Carousel>. Nest it inside <CarouselItem>."
|
|
13146
|
+
);
|
|
13147
|
+
throw new Error("CarouselTrigger missing context");
|
|
13148
|
+
}
|
|
12916
13149
|
return /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "flex m-0 p-0", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12917
13150
|
"button",
|
|
12918
13151
|
{
|
|
@@ -12953,7 +13186,13 @@ CarouselTrigger.displayName = "CarouselTrigger";
|
|
|
12953
13186
|
var CarouselContent = React11__namespace.forwardRef(
|
|
12954
13187
|
({ className, children, ...props }, ref) => {
|
|
12955
13188
|
const itemContext = React11__namespace.useContext(CarouselItemContext);
|
|
12956
|
-
if (!itemContext)
|
|
13189
|
+
if (!itemContext) {
|
|
13190
|
+
devWarn(
|
|
13191
|
+
"react-carousel/carousel-content-outside-item",
|
|
13192
|
+
"CarouselContent was rendered outside of a <CarouselItem> within <Carousel>. Nest it inside <CarouselItem>."
|
|
13193
|
+
);
|
|
13194
|
+
throw new Error("CarouselContent missing context");
|
|
13195
|
+
}
|
|
12957
13196
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12958
13197
|
"div",
|
|
12959
13198
|
{
|
|
@@ -13458,11 +13697,1191 @@ var PaymentButton = React11__namespace.forwardRef(
|
|
|
13458
13697
|
);
|
|
13459
13698
|
PaymentButton.displayName = "PaymentButton";
|
|
13460
13699
|
|
|
13700
|
+
// ../logger/dist/index.js
|
|
13701
|
+
var LEVEL_ORDER = {
|
|
13702
|
+
debug: 10,
|
|
13703
|
+
info: 20,
|
|
13704
|
+
warn: 30,
|
|
13705
|
+
error: 40,
|
|
13706
|
+
fatal: 50
|
|
13707
|
+
};
|
|
13708
|
+
var METHOD = {
|
|
13709
|
+
debug: "debug",
|
|
13710
|
+
info: "info",
|
|
13711
|
+
warn: "warn",
|
|
13712
|
+
error: "error",
|
|
13713
|
+
fatal: "error"
|
|
13714
|
+
};
|
|
13715
|
+
function createConsoleSink(opts) {
|
|
13716
|
+
const pretty = opts?.pretty ?? true;
|
|
13717
|
+
const out = opts?.console ?? console;
|
|
13718
|
+
function emit2(level, line, payload) {
|
|
13719
|
+
out[METHOD[level]](line, payload);
|
|
13720
|
+
}
|
|
13721
|
+
return {
|
|
13722
|
+
name: "console",
|
|
13723
|
+
log(record) {
|
|
13724
|
+
if (pretty) {
|
|
13725
|
+
const ts = new Date(record.timestamp).toISOString();
|
|
13726
|
+
emit2(
|
|
13727
|
+
record.level,
|
|
13728
|
+
`${ts} ${record.level.toUpperCase()} [${record.app}] ${record.message}`,
|
|
13729
|
+
record.context
|
|
13730
|
+
);
|
|
13731
|
+
} else {
|
|
13732
|
+
emit2(record.level, JSON.stringify({ type: "log", ...record }), record.context);
|
|
13733
|
+
}
|
|
13734
|
+
},
|
|
13735
|
+
span(record) {
|
|
13736
|
+
const level = record.status === "error" ? "error" : "debug";
|
|
13737
|
+
if (pretty) {
|
|
13738
|
+
emit2(
|
|
13739
|
+
level,
|
|
13740
|
+
`[span] ${record.name} ${record.durationMs.toFixed(2)}ms (${record.status})`,
|
|
13741
|
+
record.context
|
|
13742
|
+
);
|
|
13743
|
+
} else {
|
|
13744
|
+
emit2(level, JSON.stringify({ type: "span", ...record }), record.context);
|
|
13745
|
+
}
|
|
13746
|
+
},
|
|
13747
|
+
async flush() {
|
|
13748
|
+
}
|
|
13749
|
+
};
|
|
13750
|
+
}
|
|
13751
|
+
var NOOP_SPAN = {
|
|
13752
|
+
end() {
|
|
13753
|
+
}
|
|
13754
|
+
};
|
|
13755
|
+
function createNoopTelemetry() {
|
|
13756
|
+
const noop = {
|
|
13757
|
+
debug() {
|
|
13758
|
+
},
|
|
13759
|
+
info() {
|
|
13760
|
+
},
|
|
13761
|
+
warn() {
|
|
13762
|
+
},
|
|
13763
|
+
error() {
|
|
13764
|
+
},
|
|
13765
|
+
fatal() {
|
|
13766
|
+
},
|
|
13767
|
+
child() {
|
|
13768
|
+
return noop;
|
|
13769
|
+
},
|
|
13770
|
+
startSpan() {
|
|
13771
|
+
return NOOP_SPAN;
|
|
13772
|
+
},
|
|
13773
|
+
async flush() {
|
|
13774
|
+
},
|
|
13775
|
+
get sinks() {
|
|
13776
|
+
return [];
|
|
13777
|
+
},
|
|
13778
|
+
addSink() {
|
|
13779
|
+
},
|
|
13780
|
+
removeSink() {
|
|
13781
|
+
}
|
|
13782
|
+
};
|
|
13783
|
+
return noop;
|
|
13784
|
+
}
|
|
13785
|
+
var PRESETS = {
|
|
13786
|
+
development: {
|
|
13787
|
+
minLevel: "debug",
|
|
13788
|
+
batch: false,
|
|
13789
|
+
batchSize: 1,
|
|
13790
|
+
sampleRate: 1,
|
|
13791
|
+
pretty: true,
|
|
13792
|
+
beaconFlush: false
|
|
13793
|
+
},
|
|
13794
|
+
production: {
|
|
13795
|
+
minLevel: "warn",
|
|
13796
|
+
batch: true,
|
|
13797
|
+
batchSize: 20,
|
|
13798
|
+
sampleRate: 0.25,
|
|
13799
|
+
pretty: false,
|
|
13800
|
+
beaconFlush: true
|
|
13801
|
+
}
|
|
13802
|
+
};
|
|
13803
|
+
function resolvePreset(env) {
|
|
13804
|
+
return { ...PRESETS[env] };
|
|
13805
|
+
}
|
|
13806
|
+
function redact(value, keys) {
|
|
13807
|
+
if (keys.length === 0) return value;
|
|
13808
|
+
const lookup = new Set(keys.map((k) => k.toLowerCase()));
|
|
13809
|
+
return walk(value, lookup, /* @__PURE__ */ new WeakSet());
|
|
13810
|
+
}
|
|
13811
|
+
function walk(value, keys, seen2) {
|
|
13812
|
+
if (value === null || typeof value !== "object") return value;
|
|
13813
|
+
if (seen2.has(value)) return "[Circular]";
|
|
13814
|
+
seen2.add(value);
|
|
13815
|
+
if (Array.isArray(value)) {
|
|
13816
|
+
return value.map((item) => walk(item, keys, seen2));
|
|
13817
|
+
}
|
|
13818
|
+
const out = {};
|
|
13819
|
+
for (const [k, v] of Object.entries(value)) {
|
|
13820
|
+
if (keys.has(k.toLowerCase())) {
|
|
13821
|
+
out[k] = "[REDACTED]";
|
|
13822
|
+
continue;
|
|
13823
|
+
}
|
|
13824
|
+
out[k] = walk(v, keys, seen2);
|
|
13825
|
+
}
|
|
13826
|
+
return out;
|
|
13827
|
+
}
|
|
13828
|
+
function createTelemetry(config) {
|
|
13829
|
+
if (config.enabled === false) {
|
|
13830
|
+
return createNoopTelemetry();
|
|
13831
|
+
}
|
|
13832
|
+
const preset = resolvePreset(config.env);
|
|
13833
|
+
const sampleRate = config.sampleRate ?? preset.sampleRate;
|
|
13834
|
+
const redactKeys = config.redactKeys ?? [];
|
|
13835
|
+
const sinks = /* @__PURE__ */ new Map();
|
|
13836
|
+
const sinkOrder = [];
|
|
13837
|
+
const buffer = [];
|
|
13838
|
+
function addSinkInternal(sink) {
|
|
13839
|
+
if (sinks.has(sink.name)) {
|
|
13840
|
+
sinks.set(sink.name, sink);
|
|
13841
|
+
} else {
|
|
13842
|
+
sinks.set(sink.name, sink);
|
|
13843
|
+
sinkOrder.push(sink.name);
|
|
13844
|
+
}
|
|
13845
|
+
}
|
|
13846
|
+
addSinkInternal(createConsoleSink({ pretty: preset.pretty }));
|
|
13847
|
+
if (config.endpoint) {
|
|
13848
|
+
const endpoint = config.endpoint;
|
|
13849
|
+
void Promise.resolve().then(() => (init_faro_engine_47HGRAQH(), faro_engine_47HGRAQH_exports)).then(({ createFaroSink: createFaroSink2 }) => createFaroSink2({ app: config.app, endpoint })).then((faro) => {
|
|
13850
|
+
if (faro) addSinkInternal(faro);
|
|
13851
|
+
}).catch(() => {
|
|
13852
|
+
});
|
|
13853
|
+
}
|
|
13854
|
+
function shouldSample() {
|
|
13855
|
+
if (sampleRate >= 1) return true;
|
|
13856
|
+
if (sampleRate <= 0) return false;
|
|
13857
|
+
return Math.random() < sampleRate;
|
|
13858
|
+
}
|
|
13859
|
+
function dispatch(entry) {
|
|
13860
|
+
if (preset.batch) {
|
|
13861
|
+
buffer.push(entry);
|
|
13862
|
+
if (buffer.length >= preset.batchSize) {
|
|
13863
|
+
void flushBuffer();
|
|
13864
|
+
}
|
|
13865
|
+
return;
|
|
13866
|
+
}
|
|
13867
|
+
deliver(entry);
|
|
13868
|
+
}
|
|
13869
|
+
function deliver(entry) {
|
|
13870
|
+
for (const name of sinkOrder) {
|
|
13871
|
+
const sink = sinks.get(name);
|
|
13872
|
+
if (!sink) continue;
|
|
13873
|
+
if (entry.kind === "log") sink.log(entry.record);
|
|
13874
|
+
else sink.span(entry.record);
|
|
13875
|
+
}
|
|
13876
|
+
}
|
|
13877
|
+
async function flushBuffer() {
|
|
13878
|
+
if (buffer.length > 0) {
|
|
13879
|
+
const pending = buffer.splice(0, buffer.length);
|
|
13880
|
+
for (const entry of pending) deliver(entry);
|
|
13881
|
+
}
|
|
13882
|
+
await Promise.all(
|
|
13883
|
+
sinkOrder.map((name) => sinks.get(name)?.flush() ?? Promise.resolve())
|
|
13884
|
+
);
|
|
13885
|
+
}
|
|
13886
|
+
const root = globalThis;
|
|
13887
|
+
if (preset.beaconFlush && typeof root.addEventListener === "function") {
|
|
13888
|
+
const onExit = () => {
|
|
13889
|
+
void flushBuffer();
|
|
13890
|
+
};
|
|
13891
|
+
root.addEventListener("pagehide", onExit);
|
|
13892
|
+
root.addEventListener("visibilitychange", () => {
|
|
13893
|
+
if (root.document?.visibilityState === "hidden") onExit();
|
|
13894
|
+
});
|
|
13895
|
+
}
|
|
13896
|
+
function makeLogger(boundContext) {
|
|
13897
|
+
function emit2(level, message, context) {
|
|
13898
|
+
if (LEVEL_ORDER[level] < LEVEL_ORDER[preset.minLevel]) return;
|
|
13899
|
+
if (!shouldSample()) return;
|
|
13900
|
+
const merged = redact({ ...boundContext, ...context }, redactKeys);
|
|
13901
|
+
const record = {
|
|
13902
|
+
level,
|
|
13903
|
+
message,
|
|
13904
|
+
timestamp: Date.now(),
|
|
13905
|
+
app: config.app,
|
|
13906
|
+
env: config.env,
|
|
13907
|
+
context: merged
|
|
13908
|
+
};
|
|
13909
|
+
dispatch({ kind: "log", record });
|
|
13910
|
+
}
|
|
13911
|
+
const logger = {
|
|
13912
|
+
debug(message, context) {
|
|
13913
|
+
emit2("debug", message, context);
|
|
13914
|
+
},
|
|
13915
|
+
info(message, context) {
|
|
13916
|
+
emit2("info", message, context);
|
|
13917
|
+
},
|
|
13918
|
+
warn(message, context) {
|
|
13919
|
+
emit2("warn", message, context);
|
|
13920
|
+
},
|
|
13921
|
+
error(message, context) {
|
|
13922
|
+
emit2("error", message, context);
|
|
13923
|
+
},
|
|
13924
|
+
fatal(message, context) {
|
|
13925
|
+
emit2("fatal", message, context);
|
|
13926
|
+
},
|
|
13927
|
+
child(context) {
|
|
13928
|
+
return makeLogger({ ...boundContext, ...context });
|
|
13929
|
+
},
|
|
13930
|
+
startSpan(name, attributes) {
|
|
13931
|
+
const startTime = Date.now();
|
|
13932
|
+
let ended = false;
|
|
13933
|
+
return {
|
|
13934
|
+
end(opts) {
|
|
13935
|
+
if (ended) return;
|
|
13936
|
+
ended = true;
|
|
13937
|
+
const endTime = Date.now();
|
|
13938
|
+
const merged = redact(
|
|
13939
|
+
{ ...boundContext, ...attributes, ...opts?.attributes },
|
|
13940
|
+
redactKeys
|
|
13941
|
+
);
|
|
13942
|
+
const err = opts?.error;
|
|
13943
|
+
const record = {
|
|
13944
|
+
name,
|
|
13945
|
+
startTime,
|
|
13946
|
+
endTime,
|
|
13947
|
+
durationMs: endTime - startTime,
|
|
13948
|
+
app: config.app,
|
|
13949
|
+
env: config.env,
|
|
13950
|
+
context: merged,
|
|
13951
|
+
status: err ? "error" : "ok",
|
|
13952
|
+
...err ? {
|
|
13953
|
+
error: {
|
|
13954
|
+
name: err instanceof Error ? err.name : "Error",
|
|
13955
|
+
message: err instanceof Error ? err.message : String(err)
|
|
13956
|
+
}
|
|
13957
|
+
} : {}
|
|
13958
|
+
};
|
|
13959
|
+
dispatch({ kind: "span", record });
|
|
13960
|
+
}
|
|
13961
|
+
};
|
|
13962
|
+
},
|
|
13963
|
+
flush() {
|
|
13964
|
+
return flushBuffer();
|
|
13965
|
+
},
|
|
13966
|
+
get sinks() {
|
|
13967
|
+
return [...sinkOrder];
|
|
13968
|
+
},
|
|
13969
|
+
addSink(sink) {
|
|
13970
|
+
addSinkInternal(sink);
|
|
13971
|
+
},
|
|
13972
|
+
removeSink(name) {
|
|
13973
|
+
if (sinks.has(name)) {
|
|
13974
|
+
sinks.delete(name);
|
|
13975
|
+
const idx = sinkOrder.indexOf(name);
|
|
13976
|
+
if (idx !== -1) sinkOrder.splice(idx, 1);
|
|
13977
|
+
}
|
|
13978
|
+
}
|
|
13979
|
+
};
|
|
13980
|
+
return logger;
|
|
13981
|
+
}
|
|
13982
|
+
return makeLogger({});
|
|
13983
|
+
}
|
|
13984
|
+
|
|
13985
|
+
// ../react-logger/dist/index.js
|
|
13986
|
+
var TelemetryContext = React11__namespace.createContext(null);
|
|
13987
|
+
function TelemetryProvider({ children, ...config }) {
|
|
13988
|
+
const telemetryRef = React11__namespace.useRef(null);
|
|
13989
|
+
if (!telemetryRef.current) {
|
|
13990
|
+
telemetryRef.current = createTelemetry(config);
|
|
13991
|
+
}
|
|
13992
|
+
const value = React11__namespace.useMemo(
|
|
13993
|
+
() => ({ telemetry: telemetryRef.current }),
|
|
13994
|
+
[]
|
|
13995
|
+
);
|
|
13996
|
+
return React11__namespace.createElement(TelemetryContext.Provider, { value }, children);
|
|
13997
|
+
}
|
|
13998
|
+
function useTelemetry() {
|
|
13999
|
+
const ctx = React11__namespace.useContext(TelemetryContext);
|
|
14000
|
+
if (!ctx) {
|
|
14001
|
+
devWarn(
|
|
14002
|
+
"react-logger/use-telemetry-outside-provider",
|
|
14003
|
+
"useTelemetry() (or useSpan(), which depends on it) was called outside a <TelemetryProvider>. Wrap your app (or the consuming subtree) in <TelemetryProvider> so the telemetry context is available."
|
|
14004
|
+
);
|
|
14005
|
+
throw new Error("useTelemetry must be used within a <TelemetryProvider>");
|
|
14006
|
+
}
|
|
14007
|
+
return ctx.telemetry;
|
|
14008
|
+
}
|
|
14009
|
+
function useLogger(scope) {
|
|
14010
|
+
const telemetry = useTelemetry();
|
|
14011
|
+
const scopeKey = scope ? JSON.stringify(scope) : "";
|
|
14012
|
+
return React11__namespace.useMemo(
|
|
14013
|
+
() => scope ? telemetry.child(scope) : telemetry,
|
|
14014
|
+
[telemetry, scope, scopeKey]
|
|
14015
|
+
);
|
|
14016
|
+
}
|
|
14017
|
+
function useSpan() {
|
|
14018
|
+
const telemetry = useTelemetry();
|
|
14019
|
+
const spanRef = React11__namespace.useRef(null);
|
|
14020
|
+
const [isActive, setIsActive] = React11__namespace.useState(false);
|
|
14021
|
+
const end = React11__namespace.useCallback(
|
|
14022
|
+
(opts) => {
|
|
14023
|
+
if (!spanRef.current) return;
|
|
14024
|
+
spanRef.current.end(opts);
|
|
14025
|
+
spanRef.current = null;
|
|
14026
|
+
setIsActive(false);
|
|
14027
|
+
},
|
|
14028
|
+
[]
|
|
14029
|
+
);
|
|
14030
|
+
const start = React11__namespace.useCallback(
|
|
14031
|
+
(name, attributes) => {
|
|
14032
|
+
if (spanRef.current) {
|
|
14033
|
+
spanRef.current.end();
|
|
14034
|
+
}
|
|
14035
|
+
const span = telemetry.startSpan(name, attributes);
|
|
14036
|
+
spanRef.current = span;
|
|
14037
|
+
setIsActive(true);
|
|
14038
|
+
return span;
|
|
14039
|
+
},
|
|
14040
|
+
[telemetry]
|
|
14041
|
+
);
|
|
14042
|
+
React11__namespace.useEffect(() => {
|
|
14043
|
+
return () => {
|
|
14044
|
+
if (spanRef.current) {
|
|
14045
|
+
spanRef.current.end();
|
|
14046
|
+
spanRef.current = null;
|
|
14047
|
+
}
|
|
14048
|
+
};
|
|
14049
|
+
}, []);
|
|
14050
|
+
return React11__namespace.useMemo(
|
|
14051
|
+
() => ({ start, end, isActive }),
|
|
14052
|
+
[start, end, isActive]
|
|
14053
|
+
);
|
|
14054
|
+
}
|
|
14055
|
+
var TelemetryErrorBoundary = class extends React11__namespace.Component {
|
|
14056
|
+
static contextType = TelemetryContext;
|
|
14057
|
+
state = { error: null };
|
|
14058
|
+
static getDerivedStateFromError(error) {
|
|
14059
|
+
return { error };
|
|
14060
|
+
}
|
|
14061
|
+
componentDidCatch(error, info) {
|
|
14062
|
+
const telemetry = this.context?.telemetry;
|
|
14063
|
+
if (telemetry) {
|
|
14064
|
+
telemetry.error(error.message, {
|
|
14065
|
+
...this.props.context,
|
|
14066
|
+
name: error.name,
|
|
14067
|
+
stack: error.stack,
|
|
14068
|
+
componentStack: info.componentStack
|
|
14069
|
+
});
|
|
14070
|
+
}
|
|
14071
|
+
this.props.onError?.(error, info);
|
|
14072
|
+
}
|
|
14073
|
+
reset = () => {
|
|
14074
|
+
this.setState({ error: null });
|
|
14075
|
+
};
|
|
14076
|
+
render() {
|
|
14077
|
+
const { error } = this.state;
|
|
14078
|
+
if (error) {
|
|
14079
|
+
const { fallback } = this.props;
|
|
14080
|
+
if (typeof fallback === "function") {
|
|
14081
|
+
return fallback(error, this.reset);
|
|
14082
|
+
}
|
|
14083
|
+
return fallback ?? null;
|
|
14084
|
+
}
|
|
14085
|
+
return this.props.children;
|
|
14086
|
+
}
|
|
14087
|
+
};
|
|
14088
|
+
|
|
14089
|
+
// ../analytics/dist/index.js
|
|
14090
|
+
var SCHEMA_VERSION = 1;
|
|
14091
|
+
function uuidv4() {
|
|
14092
|
+
const c = typeof globalThis !== "undefined" ? globalThis.crypto : void 0;
|
|
14093
|
+
if (c && typeof c.randomUUID === "function") {
|
|
14094
|
+
return c.randomUUID();
|
|
14095
|
+
}
|
|
14096
|
+
const bytes = new Uint8Array(16);
|
|
14097
|
+
if (c && typeof c.getRandomValues === "function") {
|
|
14098
|
+
c.getRandomValues(bytes);
|
|
14099
|
+
} else {
|
|
14100
|
+
for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
|
|
14101
|
+
}
|
|
14102
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
14103
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
14104
|
+
const hex = [];
|
|
14105
|
+
for (let i = 0; i < 256; i++) hex.push((i + 256).toString(16).slice(1));
|
|
14106
|
+
return hex[bytes[0]] + hex[bytes[1]] + hex[bytes[2]] + hex[bytes[3]] + "-" + hex[bytes[4]] + hex[bytes[5]] + "-" + hex[bytes[6]] + hex[bytes[7]] + "-" + hex[bytes[8]] + hex[bytes[9]] + "-" + hex[bytes[10]] + hex[bytes[11]] + hex[bytes[12]] + hex[bytes[13]] + hex[bytes[14]] + hex[bytes[15]];
|
|
14107
|
+
}
|
|
14108
|
+
var UUID_V4_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
14109
|
+
function isUuidV4(value) {
|
|
14110
|
+
return typeof value === "string" && UUID_V4_RE.test(value);
|
|
14111
|
+
}
|
|
14112
|
+
function createMemoryStorage() {
|
|
14113
|
+
const map = /* @__PURE__ */ new Map();
|
|
14114
|
+
return {
|
|
14115
|
+
get: (k) => map.has(k) ? map.get(k) : null,
|
|
14116
|
+
set: (k, v) => {
|
|
14117
|
+
map.set(k, v);
|
|
14118
|
+
},
|
|
14119
|
+
remove: (k) => {
|
|
14120
|
+
map.delete(k);
|
|
14121
|
+
}
|
|
14122
|
+
};
|
|
14123
|
+
}
|
|
14124
|
+
function createLocalStorageAdapter(ls) {
|
|
14125
|
+
return {
|
|
14126
|
+
get: (k) => {
|
|
14127
|
+
try {
|
|
14128
|
+
return ls.getItem(k);
|
|
14129
|
+
} catch {
|
|
14130
|
+
return null;
|
|
14131
|
+
}
|
|
14132
|
+
},
|
|
14133
|
+
set: (k, v) => {
|
|
14134
|
+
try {
|
|
14135
|
+
ls.setItem(k, v);
|
|
14136
|
+
} catch {
|
|
14137
|
+
}
|
|
14138
|
+
},
|
|
14139
|
+
remove: (k) => {
|
|
14140
|
+
try {
|
|
14141
|
+
ls.removeItem(k);
|
|
14142
|
+
} catch {
|
|
14143
|
+
}
|
|
14144
|
+
}
|
|
14145
|
+
};
|
|
14146
|
+
}
|
|
14147
|
+
function createCookieAdapter(doc, maxAgeSeconds = 60 * 60 * 24 * 365) {
|
|
14148
|
+
const read = (k) => {
|
|
14149
|
+
const target = encodeURIComponent(k) + "=";
|
|
14150
|
+
const parts = doc.cookie ? doc.cookie.split(";") : [];
|
|
14151
|
+
for (const part of parts) {
|
|
14152
|
+
const c = part.trim();
|
|
14153
|
+
if (c.startsWith(target)) {
|
|
14154
|
+
return decodeURIComponent(c.slice(target.length));
|
|
14155
|
+
}
|
|
14156
|
+
}
|
|
14157
|
+
return null;
|
|
14158
|
+
};
|
|
14159
|
+
return {
|
|
14160
|
+
get: read,
|
|
14161
|
+
set: (k, v) => {
|
|
14162
|
+
doc.cookie = `${encodeURIComponent(k)}=${encodeURIComponent(
|
|
14163
|
+
v
|
|
14164
|
+
)}; path=/; max-age=${maxAgeSeconds}; SameSite=Lax`;
|
|
14165
|
+
},
|
|
14166
|
+
remove: (k) => {
|
|
14167
|
+
doc.cookie = `${encodeURIComponent(k)}=; path=/; max-age=0; SameSite=Lax`;
|
|
14168
|
+
}
|
|
14169
|
+
};
|
|
14170
|
+
}
|
|
14171
|
+
function resolveStorage(override) {
|
|
14172
|
+
if (override) return override;
|
|
14173
|
+
const g = globalThis;
|
|
14174
|
+
if (g.localStorage) {
|
|
14175
|
+
try {
|
|
14176
|
+
const probe = "__rfx_a_probe__";
|
|
14177
|
+
g.localStorage.setItem(probe, "1");
|
|
14178
|
+
g.localStorage.removeItem(probe);
|
|
14179
|
+
return createLocalStorageAdapter(g.localStorage);
|
|
14180
|
+
} catch {
|
|
14181
|
+
}
|
|
14182
|
+
}
|
|
14183
|
+
if (g.document && typeof g.document.cookie === "string") {
|
|
14184
|
+
return createCookieAdapter(g.document);
|
|
14185
|
+
}
|
|
14186
|
+
return createMemoryStorage();
|
|
14187
|
+
}
|
|
14188
|
+
var DEFAULT_SESSION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
14189
|
+
var DEFAULT_KEY = "rfx:analytics:session";
|
|
14190
|
+
var CAMPAIGN_PARAMS = [
|
|
14191
|
+
"utm_source",
|
|
14192
|
+
"utm_medium",
|
|
14193
|
+
"utm_campaign",
|
|
14194
|
+
"utm_term",
|
|
14195
|
+
"utm_content",
|
|
14196
|
+
"gclid",
|
|
14197
|
+
"fbclid",
|
|
14198
|
+
"msclkid"
|
|
14199
|
+
];
|
|
14200
|
+
function campaignFingerprint(search) {
|
|
14201
|
+
if (!search) return void 0;
|
|
14202
|
+
let qs = search;
|
|
14203
|
+
const q = qs.indexOf("?");
|
|
14204
|
+
if (q !== -1) qs = qs.slice(q + 1);
|
|
14205
|
+
let params;
|
|
14206
|
+
try {
|
|
14207
|
+
params = new URLSearchParams(qs);
|
|
14208
|
+
} catch {
|
|
14209
|
+
return void 0;
|
|
14210
|
+
}
|
|
14211
|
+
const pairs = [];
|
|
14212
|
+
for (const p of CAMPAIGN_PARAMS) {
|
|
14213
|
+
const v = params.get(p);
|
|
14214
|
+
if (v) pairs.push(`${p}=${v}`);
|
|
14215
|
+
}
|
|
14216
|
+
return pairs.length ? pairs.join("&") : void 0;
|
|
14217
|
+
}
|
|
14218
|
+
function createSession(config, now = () => Date.now()) {
|
|
14219
|
+
const storage = resolveStorage(config?.storage);
|
|
14220
|
+
const key = config?.storageKey ?? DEFAULT_KEY;
|
|
14221
|
+
const timeoutMs = config?.timeoutMs ?? DEFAULT_SESSION_TIMEOUT_MS;
|
|
14222
|
+
const resetOnCampaign = config?.resetOnCampaign ?? true;
|
|
14223
|
+
function read() {
|
|
14224
|
+
const raw = storage.get(key);
|
|
14225
|
+
if (!raw) return null;
|
|
14226
|
+
try {
|
|
14227
|
+
const parsed = JSON.parse(raw);
|
|
14228
|
+
if (parsed && typeof parsed.id === "string") return parsed;
|
|
14229
|
+
} catch {
|
|
14230
|
+
}
|
|
14231
|
+
return null;
|
|
14232
|
+
}
|
|
14233
|
+
function write(s) {
|
|
14234
|
+
storage.set(key, JSON.stringify(s));
|
|
14235
|
+
}
|
|
14236
|
+
function mint(campaign) {
|
|
14237
|
+
const s = {
|
|
14238
|
+
id: uuidv4(),
|
|
14239
|
+
lastActivity: now(),
|
|
14240
|
+
campaign
|
|
14241
|
+
};
|
|
14242
|
+
write(s);
|
|
14243
|
+
return s;
|
|
14244
|
+
}
|
|
14245
|
+
function ensure(campaign) {
|
|
14246
|
+
const existing = read();
|
|
14247
|
+
const t = now();
|
|
14248
|
+
if (!existing) return mint(campaign);
|
|
14249
|
+
if (t - existing.lastActivity > timeoutMs) {
|
|
14250
|
+
return mint(campaign);
|
|
14251
|
+
}
|
|
14252
|
+
if (resetOnCampaign && campaign !== void 0 && existing.campaign !== campaign) {
|
|
14253
|
+
return mint(campaign);
|
|
14254
|
+
}
|
|
14255
|
+
return existing;
|
|
14256
|
+
}
|
|
14257
|
+
return {
|
|
14258
|
+
/** Get the current session id, rotating if expired. */
|
|
14259
|
+
id(campaign) {
|
|
14260
|
+
return ensure(campaign).id;
|
|
14261
|
+
},
|
|
14262
|
+
/** Force a brand-new session. */
|
|
14263
|
+
start(campaign) {
|
|
14264
|
+
return mint(campaign).id;
|
|
14265
|
+
},
|
|
14266
|
+
/** End the current session (next id() mints a fresh one). */
|
|
14267
|
+
end() {
|
|
14268
|
+
storage.remove(key);
|
|
14269
|
+
},
|
|
14270
|
+
/** Touch activity so the inactivity window slides forward. */
|
|
14271
|
+
touch(campaign) {
|
|
14272
|
+
const s = ensure(campaign);
|
|
14273
|
+
s.lastActivity = now();
|
|
14274
|
+
write(s);
|
|
14275
|
+
return s.id;
|
|
14276
|
+
},
|
|
14277
|
+
/** Attach/merge session-scoped properties. */
|
|
14278
|
+
set(props) {
|
|
14279
|
+
const s = ensure();
|
|
14280
|
+
s.props = { ...s.props ?? {}, ...props };
|
|
14281
|
+
write(s);
|
|
14282
|
+
},
|
|
14283
|
+
/** Read session-scoped properties (undefined when none). */
|
|
14284
|
+
props() {
|
|
14285
|
+
return read()?.props;
|
|
14286
|
+
}
|
|
14287
|
+
};
|
|
14288
|
+
}
|
|
14289
|
+
var DEFAULT_KEY2 = "rfx:analytics:anon";
|
|
14290
|
+
function createIdentity(config) {
|
|
14291
|
+
const storage = resolveStorage(config?.storage);
|
|
14292
|
+
const key = config?.storageKey ?? DEFAULT_KEY2;
|
|
14293
|
+
let userId;
|
|
14294
|
+
function loadOrMintAnon() {
|
|
14295
|
+
const existing = storage.get(key);
|
|
14296
|
+
if (isUuidV4(existing)) return existing;
|
|
14297
|
+
const fresh = uuidv4();
|
|
14298
|
+
storage.set(key, fresh);
|
|
14299
|
+
return fresh;
|
|
14300
|
+
}
|
|
14301
|
+
let anonymousId = loadOrMintAnon();
|
|
14302
|
+
return {
|
|
14303
|
+
anonymousId() {
|
|
14304
|
+
return anonymousId;
|
|
14305
|
+
},
|
|
14306
|
+
userId() {
|
|
14307
|
+
return userId;
|
|
14308
|
+
},
|
|
14309
|
+
/** identify(): bind an opaque app user id (no validation, no persistence). */
|
|
14310
|
+
setUserId(id) {
|
|
14311
|
+
userId = id;
|
|
14312
|
+
},
|
|
14313
|
+
/**
|
|
14314
|
+
* alias(): returns the stitch pair for the envelope. `previousId`
|
|
14315
|
+
* defaults to the current user or anonymous id.
|
|
14316
|
+
*/
|
|
14317
|
+
alias(nextUserId, previousId) {
|
|
14318
|
+
const prev = previousId ?? userId ?? anonymousId;
|
|
14319
|
+
userId = nextUserId;
|
|
14320
|
+
return { userId: nextUserId, previousId: prev };
|
|
14321
|
+
},
|
|
14322
|
+
/**
|
|
14323
|
+
* reset(): privacy-safe logout. Drops the user binding and mints a brand
|
|
14324
|
+
* new anonymousId so the next visitor is not stitched to the old one.
|
|
14325
|
+
*/
|
|
14326
|
+
reset() {
|
|
14327
|
+
userId = void 0;
|
|
14328
|
+
anonymousId = uuidv4();
|
|
14329
|
+
storage.set(key, anonymousId);
|
|
14330
|
+
return anonymousId;
|
|
14331
|
+
}
|
|
14332
|
+
};
|
|
14333
|
+
}
|
|
14334
|
+
function createConsent(config) {
|
|
14335
|
+
const granted = new Set(config?.granted ?? []);
|
|
14336
|
+
return {
|
|
14337
|
+
strict: config?.strict ?? false,
|
|
14338
|
+
grant(...categories) {
|
|
14339
|
+
for (const c of categories) granted.add(c);
|
|
14340
|
+
},
|
|
14341
|
+
revoke(...categories) {
|
|
14342
|
+
for (const c of categories) granted.delete(c);
|
|
14343
|
+
},
|
|
14344
|
+
granted() {
|
|
14345
|
+
return [...granted];
|
|
14346
|
+
},
|
|
14347
|
+
isGranted(category) {
|
|
14348
|
+
return granted.has(category);
|
|
14349
|
+
},
|
|
14350
|
+
allows(required) {
|
|
14351
|
+
if (!required || required.length === 0) return true;
|
|
14352
|
+
return required.every((c) => granted.has(c));
|
|
14353
|
+
}
|
|
14354
|
+
};
|
|
14355
|
+
}
|
|
14356
|
+
var PII_DENY_LIST = [
|
|
14357
|
+
"email",
|
|
14358
|
+
"phone",
|
|
14359
|
+
"mobile",
|
|
14360
|
+
"firstname",
|
|
14361
|
+
"lastname",
|
|
14362
|
+
"fullname",
|
|
14363
|
+
"givenname",
|
|
14364
|
+
"surname",
|
|
14365
|
+
"password",
|
|
14366
|
+
"passwd",
|
|
14367
|
+
"ssn",
|
|
14368
|
+
"creditcard",
|
|
14369
|
+
"cardnumber",
|
|
14370
|
+
"cvv",
|
|
14371
|
+
"dob",
|
|
14372
|
+
"dateofbirth",
|
|
14373
|
+
"address"
|
|
14374
|
+
];
|
|
14375
|
+
var PII_EXACT_KEYS = ["name"];
|
|
14376
|
+
var REDACTED = "[REDACTED]";
|
|
14377
|
+
function normalize(key) {
|
|
14378
|
+
return key.toLowerCase().replace(/[_\-\s]/g, "");
|
|
14379
|
+
}
|
|
14380
|
+
function createRedactor(extraKeys = []) {
|
|
14381
|
+
const exact = /* @__PURE__ */ new Set([
|
|
14382
|
+
...extraKeys.map(normalize),
|
|
14383
|
+
...PII_EXACT_KEYS.map(normalize)
|
|
14384
|
+
]);
|
|
14385
|
+
const deny = PII_DENY_LIST.map(normalize);
|
|
14386
|
+
const shouldRedact = (key) => {
|
|
14387
|
+
const n = normalize(key);
|
|
14388
|
+
if (exact.has(n)) return true;
|
|
14389
|
+
return deny.some((d) => n.includes(d));
|
|
14390
|
+
};
|
|
14391
|
+
const walk2 = (value) => {
|
|
14392
|
+
if (Array.isArray(value)) return value.map(walk2);
|
|
14393
|
+
if (value && typeof value === "object") {
|
|
14394
|
+
const out = {};
|
|
14395
|
+
for (const [k, v] of Object.entries(value)) {
|
|
14396
|
+
out[k] = shouldRedact(k) ? REDACTED : walk2(v);
|
|
14397
|
+
}
|
|
14398
|
+
return out;
|
|
14399
|
+
}
|
|
14400
|
+
return value;
|
|
14401
|
+
};
|
|
14402
|
+
return {
|
|
14403
|
+
shouldRedact,
|
|
14404
|
+
/** Redact a properties/traits bag (returns a new object). */
|
|
14405
|
+
redact(props) {
|
|
14406
|
+
if (!props) return props;
|
|
14407
|
+
return walk2(props);
|
|
14408
|
+
}
|
|
14409
|
+
};
|
|
14410
|
+
}
|
|
14411
|
+
var NO_RETRY = /* @__PURE__ */ new Set([400, 401, 413]);
|
|
14412
|
+
function base64(input) {
|
|
14413
|
+
const g = globalThis;
|
|
14414
|
+
if (typeof g.btoa === "function") {
|
|
14415
|
+
return g.btoa(input);
|
|
14416
|
+
}
|
|
14417
|
+
if (g.Buffer) {
|
|
14418
|
+
return g.Buffer.from(input, "utf-8").toString("base64");
|
|
14419
|
+
}
|
|
14420
|
+
throw new Error("No base64 implementation available (btoa/Buffer)");
|
|
14421
|
+
}
|
|
14422
|
+
function byteLength(s) {
|
|
14423
|
+
const g = globalThis;
|
|
14424
|
+
if (g.TextEncoder) return new g.TextEncoder().encode(s).length;
|
|
14425
|
+
return unescape(encodeURIComponent(s)).length;
|
|
14426
|
+
}
|
|
14427
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
14428
|
+
function splitBatch(batch, maxBatchBytes, maxEventBytes) {
|
|
14429
|
+
const batches = [];
|
|
14430
|
+
const dropped = [];
|
|
14431
|
+
let current = [];
|
|
14432
|
+
let currentBytes = 2;
|
|
14433
|
+
for (const ev of batch) {
|
|
14434
|
+
const evBytes = byteLength(JSON.stringify(ev));
|
|
14435
|
+
if (evBytes > maxEventBytes) {
|
|
14436
|
+
dropped.push(ev);
|
|
14437
|
+
continue;
|
|
14438
|
+
}
|
|
14439
|
+
if (current.length && currentBytes + evBytes + 1 > maxBatchBytes) {
|
|
14440
|
+
batches.push(current);
|
|
14441
|
+
current = [];
|
|
14442
|
+
currentBytes = 2;
|
|
14443
|
+
}
|
|
14444
|
+
current.push(ev);
|
|
14445
|
+
currentBytes += evBytes + 1;
|
|
14446
|
+
}
|
|
14447
|
+
if (current.length) batches.push(current);
|
|
14448
|
+
return { batches, dropped };
|
|
14449
|
+
}
|
|
14450
|
+
function createHttpSink(options) {
|
|
14451
|
+
const {
|
|
14452
|
+
endpoint,
|
|
14453
|
+
writeKey,
|
|
14454
|
+
maxRetries = 3,
|
|
14455
|
+
backoffBaseMs = 500,
|
|
14456
|
+
consentCategories = ["analytics"],
|
|
14457
|
+
maxBatchBytes = 5e5,
|
|
14458
|
+
maxEventBytes = 32e3
|
|
14459
|
+
} = options;
|
|
14460
|
+
const base = endpoint.replace(/\/+$/, "");
|
|
14461
|
+
const url = `${base}/v${SCHEMA_VERSION}/batch`;
|
|
14462
|
+
const authHeader = `Basic ${base64(`${writeKey}:`)}`;
|
|
14463
|
+
const resolveFetch = () => {
|
|
14464
|
+
if (options.fetchImpl) return options.fetchImpl;
|
|
14465
|
+
const f = globalThis.fetch;
|
|
14466
|
+
if (!f) throw new Error("No fetch implementation available");
|
|
14467
|
+
return f;
|
|
14468
|
+
};
|
|
14469
|
+
const resolveBeacon = () => {
|
|
14470
|
+
if (options.beaconImpl) return options.beaconImpl;
|
|
14471
|
+
const nav = globalThis.navigator;
|
|
14472
|
+
if (nav && typeof nav.sendBeacon === "function") {
|
|
14473
|
+
return (u, body) => nav.sendBeacon(u, body);
|
|
14474
|
+
}
|
|
14475
|
+
return void 0;
|
|
14476
|
+
};
|
|
14477
|
+
function envelope(batch) {
|
|
14478
|
+
return {
|
|
14479
|
+
batch,
|
|
14480
|
+
sentAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14481
|
+
batchId: uuidv4()
|
|
14482
|
+
};
|
|
14483
|
+
}
|
|
14484
|
+
function sendViaBeacon(batch) {
|
|
14485
|
+
const beacon = resolveBeacon();
|
|
14486
|
+
if (!beacon) return false;
|
|
14487
|
+
const beaconUrl = `${url}?writeKey=${encodeURIComponent(writeKey)}`;
|
|
14488
|
+
return beacon(beaconUrl, JSON.stringify(envelope(batch)));
|
|
14489
|
+
}
|
|
14490
|
+
async function sendViaFetch(batch) {
|
|
14491
|
+
const doFetch = resolveFetch();
|
|
14492
|
+
const body = JSON.stringify(envelope(batch));
|
|
14493
|
+
for (let attempt = 0; ; attempt++) {
|
|
14494
|
+
let status;
|
|
14495
|
+
try {
|
|
14496
|
+
const res = await doFetch(url, {
|
|
14497
|
+
method: "POST",
|
|
14498
|
+
headers: {
|
|
14499
|
+
"Content-Type": "application/json",
|
|
14500
|
+
Authorization: authHeader
|
|
14501
|
+
},
|
|
14502
|
+
body,
|
|
14503
|
+
keepalive: true
|
|
14504
|
+
});
|
|
14505
|
+
status = res.status;
|
|
14506
|
+
} catch {
|
|
14507
|
+
status = 0;
|
|
14508
|
+
}
|
|
14509
|
+
if (status >= 200 && status < 300) return;
|
|
14510
|
+
if (NO_RETRY.has(status)) return;
|
|
14511
|
+
if (attempt >= maxRetries) return;
|
|
14512
|
+
const delay = backoffBaseMs * 2 ** attempt;
|
|
14513
|
+
await sleep(delay);
|
|
14514
|
+
}
|
|
14515
|
+
}
|
|
14516
|
+
return {
|
|
14517
|
+
name: "http",
|
|
14518
|
+
consentCategories,
|
|
14519
|
+
async deliver(batch, ctx) {
|
|
14520
|
+
if (batch.length === 0) return;
|
|
14521
|
+
const { batches } = splitBatch(
|
|
14522
|
+
batch,
|
|
14523
|
+
maxBatchBytes,
|
|
14524
|
+
maxEventBytes
|
|
14525
|
+
);
|
|
14526
|
+
for (const part of batches) {
|
|
14527
|
+
if (ctx.unload) {
|
|
14528
|
+
if (sendViaBeacon(part)) continue;
|
|
14529
|
+
void sendViaFetch(part);
|
|
14530
|
+
} else {
|
|
14531
|
+
await sendViaFetch(part);
|
|
14532
|
+
}
|
|
14533
|
+
}
|
|
14534
|
+
}
|
|
14535
|
+
};
|
|
14536
|
+
}
|
|
14537
|
+
function createConsoleSink2(options = {}) {
|
|
14538
|
+
const logger = options.logger ?? globalThis.console;
|
|
14539
|
+
return {
|
|
14540
|
+
name: "console",
|
|
14541
|
+
consentCategories: options.consentCategories,
|
|
14542
|
+
deliver(batch) {
|
|
14543
|
+
for (const ev of batch) {
|
|
14544
|
+
const label = `[analytics] ${ev.type}${ev.event ? ` ${ev.event}` : ""}`;
|
|
14545
|
+
if (typeof logger.groupCollapsed === "function") {
|
|
14546
|
+
logger.groupCollapsed(label);
|
|
14547
|
+
logger.log(ev);
|
|
14548
|
+
logger.groupEnd?.();
|
|
14549
|
+
} else {
|
|
14550
|
+
logger.log(label, ev);
|
|
14551
|
+
}
|
|
14552
|
+
}
|
|
14553
|
+
}
|
|
14554
|
+
};
|
|
14555
|
+
}
|
|
14556
|
+
function createNoopAnalytics() {
|
|
14557
|
+
const sessionId = "00000000-0000-4000-8000-000000000000";
|
|
14558
|
+
const noop = () => {
|
|
14559
|
+
};
|
|
14560
|
+
const api = {
|
|
14561
|
+
track: noop,
|
|
14562
|
+
identify: noop,
|
|
14563
|
+
page: noop,
|
|
14564
|
+
screen: noop,
|
|
14565
|
+
group: noop,
|
|
14566
|
+
alias: noop,
|
|
14567
|
+
session: {
|
|
14568
|
+
id: () => sessionId,
|
|
14569
|
+
start: () => sessionId,
|
|
14570
|
+
end: noop,
|
|
14571
|
+
set: noop
|
|
14572
|
+
},
|
|
14573
|
+
consent: {
|
|
14574
|
+
grant: noop,
|
|
14575
|
+
revoke: noop,
|
|
14576
|
+
granted: () => [],
|
|
14577
|
+
isGranted: () => false
|
|
14578
|
+
},
|
|
14579
|
+
anonymousId: () => sessionId,
|
|
14580
|
+
userId: () => void 0,
|
|
14581
|
+
with: () => api,
|
|
14582
|
+
addSink: noop,
|
|
14583
|
+
removeSink: noop,
|
|
14584
|
+
get sinks() {
|
|
14585
|
+
return [];
|
|
14586
|
+
},
|
|
14587
|
+
flush: async () => {
|
|
14588
|
+
},
|
|
14589
|
+
reset: noop,
|
|
14590
|
+
enabled: false
|
|
14591
|
+
};
|
|
14592
|
+
return api;
|
|
14593
|
+
}
|
|
14594
|
+
var LIBRARY = {
|
|
14595
|
+
name: "@refraction-ui/analytics",
|
|
14596
|
+
version: "0.1.0"
|
|
14597
|
+
};
|
|
14598
|
+
function readPage() {
|
|
14599
|
+
const g = globalThis;
|
|
14600
|
+
if (!g.location && !g.document) return void 0;
|
|
14601
|
+
return {
|
|
14602
|
+
path: g.location?.pathname,
|
|
14603
|
+
url: g.location?.href,
|
|
14604
|
+
search: g.location?.search,
|
|
14605
|
+
title: g.document?.title,
|
|
14606
|
+
referrer: g.document?.referrer
|
|
14607
|
+
};
|
|
14608
|
+
}
|
|
14609
|
+
function createAnalytics(config) {
|
|
14610
|
+
if (config.enabled === false) {
|
|
14611
|
+
return createNoopAnalytics();
|
|
14612
|
+
}
|
|
14613
|
+
const { app, env } = config;
|
|
14614
|
+
const preset = config.preset ?? (env === "production" ? "prod" : "dev");
|
|
14615
|
+
const sampleRate = config.sampleRate ?? 1;
|
|
14616
|
+
const batchSize = config.batchSize ?? 20;
|
|
14617
|
+
const flushIntervalMs = config.flushIntervalMs ?? 1e4;
|
|
14618
|
+
const session = createSession(config.session);
|
|
14619
|
+
const identity = createIdentity(config.identity);
|
|
14620
|
+
const consent = createConsent(config.consent);
|
|
14621
|
+
const redactor = createRedactor(config.redactKeys);
|
|
14622
|
+
const sinks = /* @__PURE__ */ new Map();
|
|
14623
|
+
const sinkOrder = [];
|
|
14624
|
+
const initialized = /* @__PURE__ */ new Set();
|
|
14625
|
+
function registerSink(sink) {
|
|
14626
|
+
if (!sinks.has(sink.name)) sinkOrder.push(sink.name);
|
|
14627
|
+
sinks.set(sink.name, sink);
|
|
14628
|
+
}
|
|
14629
|
+
if (config.endpoint) {
|
|
14630
|
+
registerSink(
|
|
14631
|
+
createHttpSink({
|
|
14632
|
+
endpoint: config.endpoint,
|
|
14633
|
+
writeKey: config.writeKey ?? ""
|
|
14634
|
+
})
|
|
14635
|
+
);
|
|
14636
|
+
}
|
|
14637
|
+
if (preset === "dev") {
|
|
14638
|
+
registerSink(createConsoleSink2());
|
|
14639
|
+
}
|
|
14640
|
+
for (const s of config.sinks ?? []) registerSink(s);
|
|
14641
|
+
function ensureInit(sink) {
|
|
14642
|
+
if (initialized.has(sink.name)) return;
|
|
14643
|
+
initialized.add(sink.name);
|
|
14644
|
+
if (sink.init) {
|
|
14645
|
+
return sink.init({ app, env, endpoint: config.endpoint });
|
|
14646
|
+
}
|
|
14647
|
+
}
|
|
14648
|
+
const buffer = [];
|
|
14649
|
+
let timer;
|
|
14650
|
+
function startTimer() {
|
|
14651
|
+
if (preset !== "prod" || timer) return;
|
|
14652
|
+
timer = setInterval(() => {
|
|
14653
|
+
void flush(false);
|
|
14654
|
+
}, flushIntervalMs);
|
|
14655
|
+
timer.unref?.();
|
|
14656
|
+
}
|
|
14657
|
+
function deliverToSinks(batch, unload) {
|
|
14658
|
+
if (batch.length === 0) return;
|
|
14659
|
+
const ctx = { unload };
|
|
14660
|
+
const pending = [];
|
|
14661
|
+
for (const name of sinkOrder) {
|
|
14662
|
+
const sink = sinks.get(name);
|
|
14663
|
+
if (!sink) continue;
|
|
14664
|
+
if (!consent.allows(sink.consentCategories)) continue;
|
|
14665
|
+
const inited = ensureInit(sink);
|
|
14666
|
+
if (inited && typeof inited.then === "function") {
|
|
14667
|
+
pending.push(
|
|
14668
|
+
inited.then(() => sink.deliver(batch, ctx))
|
|
14669
|
+
);
|
|
14670
|
+
} else {
|
|
14671
|
+
const r = sink.deliver(batch, ctx);
|
|
14672
|
+
if (r && typeof r.then === "function") {
|
|
14673
|
+
pending.push(r);
|
|
14674
|
+
}
|
|
14675
|
+
}
|
|
14676
|
+
}
|
|
14677
|
+
if (pending.length) return Promise.all(pending).then(() => void 0);
|
|
14678
|
+
}
|
|
14679
|
+
async function flush(unload = false) {
|
|
14680
|
+
const batch = buffer.splice(0, buffer.length);
|
|
14681
|
+
await deliverToSinks(batch, unload);
|
|
14682
|
+
for (const name of sinkOrder) {
|
|
14683
|
+
const sink = sinks.get(name);
|
|
14684
|
+
if (sink?.flush && consent.allows(sink.consentCategories)) {
|
|
14685
|
+
await sink.flush();
|
|
14686
|
+
}
|
|
14687
|
+
}
|
|
14688
|
+
}
|
|
14689
|
+
function bindUnload() {
|
|
14690
|
+
if (preset !== "prod") return;
|
|
14691
|
+
const g = globalThis;
|
|
14692
|
+
if (typeof g.addEventListener !== "function") return;
|
|
14693
|
+
const onUnload = () => {
|
|
14694
|
+
void deliverToSinks(buffer.splice(0, buffer.length), true);
|
|
14695
|
+
};
|
|
14696
|
+
g.addEventListener("pagehide", onUnload);
|
|
14697
|
+
g.addEventListener("visibilitychange", () => {
|
|
14698
|
+
if (g.document?.visibilityState === "hidden") onUnload();
|
|
14699
|
+
});
|
|
14700
|
+
}
|
|
14701
|
+
startTimer();
|
|
14702
|
+
bindUnload();
|
|
14703
|
+
function buildContext(extra, childCtx) {
|
|
14704
|
+
const page = readPage();
|
|
14705
|
+
return {
|
|
14706
|
+
app,
|
|
14707
|
+
env,
|
|
14708
|
+
...page ? { page } : {},
|
|
14709
|
+
...childCtx,
|
|
14710
|
+
...extra,
|
|
14711
|
+
library: LIBRARY
|
|
14712
|
+
};
|
|
14713
|
+
}
|
|
14714
|
+
function sampled() {
|
|
14715
|
+
if (sampleRate >= 1) return true;
|
|
14716
|
+
if (sampleRate <= 0) return false;
|
|
14717
|
+
return Math.random() < sampleRate;
|
|
14718
|
+
}
|
|
14719
|
+
function enqueue(ev) {
|
|
14720
|
+
if (preset === "dev") {
|
|
14721
|
+
void deliverToSinks([ev], false);
|
|
14722
|
+
return;
|
|
14723
|
+
}
|
|
14724
|
+
buffer.push(ev);
|
|
14725
|
+
if (buffer.length >= batchSize) {
|
|
14726
|
+
void flush(false);
|
|
14727
|
+
}
|
|
14728
|
+
}
|
|
14729
|
+
function emit2(type, fields, childCtx, opts) {
|
|
14730
|
+
if (!sampled()) return;
|
|
14731
|
+
const page = readPage();
|
|
14732
|
+
const campaign = campaignFingerprint(page?.search);
|
|
14733
|
+
const sessionId = session.touch(campaign);
|
|
14734
|
+
const sessionProps = session.props();
|
|
14735
|
+
const ev = {
|
|
14736
|
+
type,
|
|
14737
|
+
messageId: uuidv4(),
|
|
14738
|
+
anonymousId: identity.anonymousId(),
|
|
14739
|
+
userId: identity.userId(),
|
|
14740
|
+
sessionId,
|
|
14741
|
+
context: buildContext(opts?.context, childCtx),
|
|
14742
|
+
timestamp: opts?.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
14743
|
+
schemaVersion: SCHEMA_VERSION,
|
|
14744
|
+
...fields
|
|
14745
|
+
};
|
|
14746
|
+
if (sessionProps && (ev.properties || type === "track" || type === "page" || type === "screen")) {
|
|
14747
|
+
ev.properties = { ...sessionProps, ...ev.properties ?? {} };
|
|
14748
|
+
}
|
|
14749
|
+
enqueue(ev);
|
|
14750
|
+
}
|
|
14751
|
+
function makeApi(childCtx) {
|
|
14752
|
+
const api = {
|
|
14753
|
+
track(event, properties, opts) {
|
|
14754
|
+
emit2(
|
|
14755
|
+
"track",
|
|
14756
|
+
{ event, properties: redactor.redact(properties) },
|
|
14757
|
+
childCtx,
|
|
14758
|
+
opts
|
|
14759
|
+
);
|
|
14760
|
+
},
|
|
14761
|
+
identify(userId, traits, opts) {
|
|
14762
|
+
identity.setUserId(userId);
|
|
14763
|
+
emit2("identify", { traits: redactor.redact(traits) }, childCtx, opts);
|
|
14764
|
+
},
|
|
14765
|
+
page(name, properties, opts) {
|
|
14766
|
+
emit2(
|
|
14767
|
+
"page",
|
|
14768
|
+
{ event: name, properties: redactor.redact(properties) },
|
|
14769
|
+
childCtx,
|
|
14770
|
+
opts
|
|
14771
|
+
);
|
|
14772
|
+
},
|
|
14773
|
+
screen(name, properties, opts) {
|
|
14774
|
+
emit2(
|
|
14775
|
+
"screen",
|
|
14776
|
+
{ event: name, properties: redactor.redact(properties) },
|
|
14777
|
+
childCtx,
|
|
14778
|
+
opts
|
|
14779
|
+
);
|
|
14780
|
+
},
|
|
14781
|
+
group(groupId, traits, opts) {
|
|
14782
|
+
emit2(
|
|
14783
|
+
"group",
|
|
14784
|
+
{ groupId, traits: redactor.redact(traits) },
|
|
14785
|
+
childCtx,
|
|
14786
|
+
opts
|
|
14787
|
+
);
|
|
14788
|
+
},
|
|
14789
|
+
alias(userId, previousId, opts) {
|
|
14790
|
+
const stitch = identity.alias(userId, previousId);
|
|
14791
|
+
emit2(
|
|
14792
|
+
"alias",
|
|
14793
|
+
{ userId: stitch.userId, previousId: stitch.previousId },
|
|
14794
|
+
childCtx,
|
|
14795
|
+
opts
|
|
14796
|
+
);
|
|
14797
|
+
},
|
|
14798
|
+
session: {
|
|
14799
|
+
id: () => session.id(),
|
|
14800
|
+
start: () => session.start(),
|
|
14801
|
+
end: () => session.end(),
|
|
14802
|
+
set: (props) => session.set(props)
|
|
14803
|
+
},
|
|
14804
|
+
consent: {
|
|
14805
|
+
grant: (...c) => consent.grant(...c),
|
|
14806
|
+
revoke: (...c) => consent.revoke(...c),
|
|
14807
|
+
granted: () => consent.granted(),
|
|
14808
|
+
isGranted: (c) => consent.isGranted(c)
|
|
14809
|
+
},
|
|
14810
|
+
anonymousId: () => identity.anonymousId(),
|
|
14811
|
+
userId: () => identity.userId(),
|
|
14812
|
+
with(extra) {
|
|
14813
|
+
return makeApi({ ...childCtx, ...extra });
|
|
14814
|
+
},
|
|
14815
|
+
addSink(sink) {
|
|
14816
|
+
registerSink(sink);
|
|
14817
|
+
},
|
|
14818
|
+
removeSink(name) {
|
|
14819
|
+
if (sinks.has(name)) {
|
|
14820
|
+
sinks.delete(name);
|
|
14821
|
+
const i = sinkOrder.indexOf(name);
|
|
14822
|
+
if (i !== -1) sinkOrder.splice(i, 1);
|
|
14823
|
+
initialized.delete(name);
|
|
14824
|
+
}
|
|
14825
|
+
},
|
|
14826
|
+
get sinks() {
|
|
14827
|
+
return [...sinkOrder];
|
|
14828
|
+
},
|
|
14829
|
+
async flush() {
|
|
14830
|
+
await flush(false);
|
|
14831
|
+
},
|
|
14832
|
+
reset() {
|
|
14833
|
+
identity.reset();
|
|
14834
|
+
session.end();
|
|
14835
|
+
},
|
|
14836
|
+
enabled: true
|
|
14837
|
+
};
|
|
14838
|
+
return api;
|
|
14839
|
+
}
|
|
14840
|
+
return makeApi();
|
|
14841
|
+
}
|
|
14842
|
+
|
|
14843
|
+
// ../react-analytics/dist/index.js
|
|
14844
|
+
var AnalyticsContext = React11__namespace.createContext(null);
|
|
14845
|
+
function AnalyticsProvider({ children, value }) {
|
|
14846
|
+
const analyticsRef = React11__namespace.useRef(null);
|
|
14847
|
+
if (!analyticsRef.current) {
|
|
14848
|
+
analyticsRef.current = value;
|
|
14849
|
+
}
|
|
14850
|
+
return React11__namespace.createElement(
|
|
14851
|
+
AnalyticsContext.Provider,
|
|
14852
|
+
{ value: analyticsRef.current },
|
|
14853
|
+
children
|
|
14854
|
+
);
|
|
14855
|
+
}
|
|
14856
|
+
function useAnalytics(options) {
|
|
14857
|
+
const ctx = React11__namespace.useContext(AnalyticsContext);
|
|
14858
|
+
if (!ctx) {
|
|
14859
|
+
devWarn(
|
|
14860
|
+
"react-analytics/use-analytics-outside-provider",
|
|
14861
|
+
"useAnalytics() was called outside an <AnalyticsProvider>. Wrap your app (or the consuming subtree) in <AnalyticsProvider> so the analytics context is available."
|
|
14862
|
+
);
|
|
14863
|
+
throw new Error("useAnalytics must be used within an <AnalyticsProvider>");
|
|
14864
|
+
}
|
|
14865
|
+
const scope = options?.scope;
|
|
14866
|
+
return React11__namespace.useMemo(
|
|
14867
|
+
() => scope ? ctx.with(scope) : ctx,
|
|
14868
|
+
[ctx, scope]
|
|
14869
|
+
);
|
|
14870
|
+
}
|
|
14871
|
+
function useTrackEvent(options) {
|
|
14872
|
+
const analytics = useAnalytics(options);
|
|
14873
|
+
return React11__namespace.useCallback(
|
|
14874
|
+
(event, properties, opts) => analytics.track(event, properties, opts),
|
|
14875
|
+
[analytics]
|
|
14876
|
+
);
|
|
14877
|
+
}
|
|
14878
|
+
|
|
13461
14879
|
exports.Accordion = Accordion;
|
|
13462
14880
|
exports.AccordionContent = AccordionContent;
|
|
13463
14881
|
exports.AccordionItem = AccordionItem;
|
|
13464
14882
|
exports.AccordionTrigger = AccordionTrigger;
|
|
13465
14883
|
exports.AltHintState = AltHintState;
|
|
14884
|
+
exports.AnalyticsProvider = AnalyticsProvider;
|
|
13466
14885
|
exports.AnimatedText = AnimatedText;
|
|
13467
14886
|
exports.AppShell = AppShell;
|
|
13468
14887
|
exports.AuthGuard = AuthGuard;
|
|
@@ -13628,6 +15047,8 @@ exports.Tabs = Tabs;
|
|
|
13628
15047
|
exports.TabsContent = TabsContent;
|
|
13629
15048
|
exports.TabsList = TabsList;
|
|
13630
15049
|
exports.TabsTrigger = TabsTrigger;
|
|
15050
|
+
exports.TelemetryErrorBoundary = TelemetryErrorBoundary;
|
|
15051
|
+
exports.TelemetryProvider = TelemetryProvider;
|
|
13631
15052
|
exports.Textarea = Textarea;
|
|
13632
15053
|
exports.ThreadView = ThreadView;
|
|
13633
15054
|
exports.Toast = Toast;
|
|
@@ -13687,6 +15108,7 @@ exports.commandItemVariants = commandItemVariants;
|
|
|
13687
15108
|
exports.commandVariants = commandVariants;
|
|
13688
15109
|
exports.contentProtectionVariants = contentProtectionVariants;
|
|
13689
15110
|
exports.controlsVariants = controlsVariants;
|
|
15111
|
+
exports.createAnalytics = createAnalytics;
|
|
13690
15112
|
exports.createIntensitySamples = createIntensitySamples;
|
|
13691
15113
|
exports.createSilentSamples = createSilentSamples;
|
|
13692
15114
|
exports.createVoicePill = createVoicePill;
|
|
@@ -13820,9 +15242,14 @@ exports.toastVariants = toastVariants;
|
|
|
13820
15242
|
exports.toolbarVariants = toolbarVariants;
|
|
13821
15243
|
exports.tooltipContentVariants = tooltipContentVariants;
|
|
13822
15244
|
exports.typewriterVariants = typewriterVariants;
|
|
15245
|
+
exports.useAnalytics = useAnalytics;
|
|
13823
15246
|
exports.useAuth = useAuth;
|
|
15247
|
+
exports.useLogger = useLogger;
|
|
13824
15248
|
exports.useShortcut = useShortcut;
|
|
15249
|
+
exports.useSpan = useSpan;
|
|
15250
|
+
exports.useTelemetry = useTelemetry;
|
|
13825
15251
|
exports.useToast = useToast;
|
|
15252
|
+
exports.useTrackEvent = useTrackEvent;
|
|
13826
15253
|
exports.versionSelectorOptionVariants = versionSelectorOptionVariants;
|
|
13827
15254
|
exports.versionSelectorVariants = versionSelectorVariants;
|
|
13828
15255
|
exports.voicePillAvatarStyles = voicePillAvatarStyles;
|