@refraction-ui/react 0.5.0 → 0.7.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.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { cn, cva, createKeyboardHandler, Keys, createMachine, generateId } from './chunk-
|
|
1
|
+
import { cn, devWarn, cva, createKeyboardHandler, Keys, createMachine, generateId } from './chunk-O4453CBF.js';
|
|
2
|
+
import './chunk-XWP763SH.js';
|
|
2
3
|
import * as React11 from 'react';
|
|
3
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
5
|
import * as ReactDOM from 'react-dom';
|
|
@@ -34,7 +35,13 @@ var AccordionItemContext = React11.createContext(null);
|
|
|
34
35
|
var AccordionItem = React11.forwardRef(
|
|
35
36
|
({ className, value, ...props }, ref) => {
|
|
36
37
|
const context = React11.useContext(AccordionContext);
|
|
37
|
-
if (!context)
|
|
38
|
+
if (!context) {
|
|
39
|
+
devWarn(
|
|
40
|
+
"react-accordion/item-outside-accordion",
|
|
41
|
+
"<AccordionItem> must be rendered inside an <Accordion>. The missing AccordionContext makes this throw."
|
|
42
|
+
);
|
|
43
|
+
throw new Error("AccordionItem must be within Accordion");
|
|
44
|
+
}
|
|
38
45
|
const isOpen = context.type === "single" ? context.value === value : Array.isArray(context.value) && context.value.includes(value);
|
|
39
46
|
return /* @__PURE__ */ jsx(AccordionItemContext.Provider, { value: { value, isOpen }, children: /* @__PURE__ */ jsx("div", { ref, className: cn("border-b border-border", className), "data-state": isOpen ? "open" : "closed", ...props }) });
|
|
40
47
|
}
|
|
@@ -44,7 +51,13 @@ var AccordionTrigger = React11.forwardRef(
|
|
|
44
51
|
({ className, children, ...props }, ref) => {
|
|
45
52
|
const accordionContext = React11.useContext(AccordionContext);
|
|
46
53
|
const itemContext = React11.useContext(AccordionItemContext);
|
|
47
|
-
if (!accordionContext || !itemContext)
|
|
54
|
+
if (!accordionContext || !itemContext) {
|
|
55
|
+
devWarn(
|
|
56
|
+
"react-accordion/trigger-missing-context",
|
|
57
|
+
"<AccordionTrigger> must be rendered inside an <AccordionItem> within an <Accordion>. The missing AccordionContext/AccordionItemContext makes this throw."
|
|
58
|
+
);
|
|
59
|
+
throw new Error("AccordionTrigger missing context");
|
|
60
|
+
}
|
|
48
61
|
return /* @__PURE__ */ jsx("h3", { className: "flex m-0 p-0", children: /* @__PURE__ */ jsxs(
|
|
49
62
|
"button",
|
|
50
63
|
{
|
|
@@ -85,7 +98,13 @@ AccordionTrigger.displayName = "AccordionTrigger";
|
|
|
85
98
|
var AccordionContent = React11.forwardRef(
|
|
86
99
|
({ className, children, ...props }, ref) => {
|
|
87
100
|
const itemContext = React11.useContext(AccordionItemContext);
|
|
88
|
-
if (!itemContext)
|
|
101
|
+
if (!itemContext) {
|
|
102
|
+
devWarn(
|
|
103
|
+
"react-accordion/content-missing-context",
|
|
104
|
+
"<AccordionContent> must be rendered inside an <AccordionItem>. The missing AccordionItemContext makes this throw."
|
|
105
|
+
);
|
|
106
|
+
throw new Error("AccordionContent missing context");
|
|
107
|
+
}
|
|
89
108
|
return /* @__PURE__ */ jsx(
|
|
90
109
|
"div",
|
|
91
110
|
{
|
|
@@ -383,6 +402,10 @@ function AuthProvider({ children, ...config }) {
|
|
|
383
402
|
const authRef = React11.useRef(null);
|
|
384
403
|
if (!authRef.current) {
|
|
385
404
|
if (!config.adapter && !config.testMode) {
|
|
405
|
+
devWarn(
|
|
406
|
+
"react-auth/missing-adapter",
|
|
407
|
+
"<AuthProvider> was rendered without a required `adapter` prop (and not in `testMode`). Pass an auth adapter so the provider can create an auth instance."
|
|
408
|
+
);
|
|
386
409
|
throw new Error("[refraction-ui/react-auth] You must provide an `adapter` to AuthProvider.");
|
|
387
410
|
}
|
|
388
411
|
authRef.current = createAuth(config.adapter, config);
|
|
@@ -414,6 +437,10 @@ function AuthProvider({ children, ...config }) {
|
|
|
414
437
|
function useAuth() {
|
|
415
438
|
const ctx = React11.useContext(AuthContext);
|
|
416
439
|
if (!ctx) {
|
|
440
|
+
devWarn(
|
|
441
|
+
"react-auth/use-auth-outside-provider",
|
|
442
|
+
"useAuth() was called outside an <AuthProvider>. Wrap your app (or the consuming subtree) in <AuthProvider> so the auth context is available."
|
|
443
|
+
);
|
|
417
444
|
throw new Error("useAuth must be used within an <AuthProvider>");
|
|
418
445
|
}
|
|
419
446
|
return ctx;
|
|
@@ -1610,6 +1637,10 @@ var CollapsibleContext = React11.createContext(null);
|
|
|
1610
1637
|
function useCollapsibleContext() {
|
|
1611
1638
|
const ctx = React11.useContext(CollapsibleContext);
|
|
1612
1639
|
if (!ctx) {
|
|
1640
|
+
devWarn(
|
|
1641
|
+
"react-collapsible/context-outside-provider",
|
|
1642
|
+
"Collapsible compound components (CollapsibleTrigger/CollapsibleContent) must be rendered inside a <Collapsible>. The missing CollapsibleContext makes this throw."
|
|
1643
|
+
);
|
|
1613
1644
|
throw new Error(
|
|
1614
1645
|
"Collapsible compound components must be used within <Collapsible>"
|
|
1615
1646
|
);
|
|
@@ -1757,6 +1788,10 @@ var ComboboxContext = React11.createContext(null);
|
|
|
1757
1788
|
function useComboboxContext() {
|
|
1758
1789
|
const ctx = React11.useContext(ComboboxContext);
|
|
1759
1790
|
if (!ctx) {
|
|
1791
|
+
devWarn(
|
|
1792
|
+
"react-combobox/context-outside-provider",
|
|
1793
|
+
"Combobox compound components (ComboboxInput/ComboboxContent/ComboboxItem/etc.) must be rendered inside a <Combobox>. The missing ComboboxContext makes this throw."
|
|
1794
|
+
);
|
|
1760
1795
|
throw new Error("Combobox compound components must be used within <Combobox>");
|
|
1761
1796
|
}
|
|
1762
1797
|
return ctx;
|
|
@@ -2429,6 +2464,10 @@ var CommandContext = React11.createContext(null);
|
|
|
2429
2464
|
function useCommandContext() {
|
|
2430
2465
|
const ctx = React11.useContext(CommandContext);
|
|
2431
2466
|
if (!ctx) {
|
|
2467
|
+
devWarn(
|
|
2468
|
+
"react-command/context-outside-provider",
|
|
2469
|
+
"Command compound components (CommandInput/CommandList/CommandItem/CommandGroup/etc.) must be rendered inside a <Command>. The missing CommandContext makes this throw."
|
|
2470
|
+
);
|
|
2432
2471
|
throw new Error("Command compound components must be used within <Command>");
|
|
2433
2472
|
}
|
|
2434
2473
|
return ctx;
|
|
@@ -3266,6 +3305,10 @@ var DialogContext = React11.createContext(null);
|
|
|
3266
3305
|
function useDialogContext() {
|
|
3267
3306
|
const ctx = React11.useContext(DialogContext);
|
|
3268
3307
|
if (!ctx) {
|
|
3308
|
+
devWarn(
|
|
3309
|
+
"react-dialog/context-outside-provider",
|
|
3310
|
+
"Dialog compound components (DialogTrigger/DialogContent/DialogTitle/etc.) must be rendered inside a <Dialog>. The missing DialogContext makes this throw."
|
|
3311
|
+
);
|
|
3269
3312
|
throw new Error("Dialog compound components must be used within <Dialog>");
|
|
3270
3313
|
}
|
|
3271
3314
|
return ctx;
|
|
@@ -3553,6 +3596,10 @@ var DropdownMenuContext = React11.createContext(null);
|
|
|
3553
3596
|
function useDropdownMenuContext() {
|
|
3554
3597
|
const ctx = React11.useContext(DropdownMenuContext);
|
|
3555
3598
|
if (!ctx) {
|
|
3599
|
+
devWarn(
|
|
3600
|
+
"react-dropdown-menu/context-outside-provider",
|
|
3601
|
+
"DropdownMenu compound components (DropdownMenuTrigger/DropdownMenuContent/DropdownMenuItem/etc.) must be rendered inside a <DropdownMenu>. The missing DropdownMenuContext makes this throw."
|
|
3602
|
+
);
|
|
3556
3603
|
throw new Error("DropdownMenu compound components must be used within <DropdownMenu>");
|
|
3557
3604
|
}
|
|
3558
3605
|
return ctx;
|
|
@@ -4803,6 +4850,10 @@ var MobileNavContext = React11.createContext(null);
|
|
|
4803
4850
|
function useMobileNavContext() {
|
|
4804
4851
|
const ctx = React11.useContext(MobileNavContext);
|
|
4805
4852
|
if (!ctx) {
|
|
4853
|
+
devWarn(
|
|
4854
|
+
"react-mobile-nav/compound-outside-provider",
|
|
4855
|
+
"A MobileNav compound component was rendered outside of <MobileNav>. Wrap it in <MobileNav>."
|
|
4856
|
+
);
|
|
4806
4857
|
throw new Error("MobileNav compound components must be used within <MobileNav>");
|
|
4807
4858
|
}
|
|
4808
4859
|
return ctx;
|
|
@@ -5061,6 +5112,10 @@ var PopoverContext = React11.createContext(null);
|
|
|
5061
5112
|
function usePopoverContext() {
|
|
5062
5113
|
const ctx = React11.useContext(PopoverContext);
|
|
5063
5114
|
if (!ctx) {
|
|
5115
|
+
devWarn(
|
|
5116
|
+
"react-popover/context-outside-provider",
|
|
5117
|
+
"Popover compound components (PopoverTrigger/PopoverContent/etc.) must be rendered inside a <Popover>. The missing PopoverContext makes this throw."
|
|
5118
|
+
);
|
|
5064
5119
|
throw new Error("Popover compound components must be used within <Popover>");
|
|
5065
5120
|
}
|
|
5066
5121
|
return ctx;
|
|
@@ -5266,6 +5321,10 @@ var SearchBarContext = React11.createContext(null);
|
|
|
5266
5321
|
function useSearchBarContext() {
|
|
5267
5322
|
const ctx = React11.useContext(SearchBarContext);
|
|
5268
5323
|
if (!ctx) {
|
|
5324
|
+
devWarn(
|
|
5325
|
+
"react-search-bar/compound-outside-provider",
|
|
5326
|
+
"A SearchBar compound component was rendered outside of <SearchBar>. Wrap it in <SearchBar>."
|
|
5327
|
+
);
|
|
5269
5328
|
throw new Error("SearchBar compound components must be used within <SearchBar>");
|
|
5270
5329
|
}
|
|
5271
5330
|
return ctx;
|
|
@@ -5529,6 +5588,10 @@ var SheetContext = React11.createContext(null);
|
|
|
5529
5588
|
function useSheetContext() {
|
|
5530
5589
|
const ctx = React11.useContext(SheetContext);
|
|
5531
5590
|
if (!ctx) {
|
|
5591
|
+
devWarn(
|
|
5592
|
+
"react-sheet/sheet-compound-outside-provider",
|
|
5593
|
+
"A Sheet compound component was rendered outside of <Sheet>. Wrap it in <Sheet>."
|
|
5594
|
+
);
|
|
5532
5595
|
throw new Error("Sheet compound components must be used within <Sheet>");
|
|
5533
5596
|
}
|
|
5534
5597
|
return ctx;
|
|
@@ -5980,6 +6043,10 @@ var TabsContext = React11.createContext(null);
|
|
|
5980
6043
|
function useTabsContext() {
|
|
5981
6044
|
const ctx = React11.useContext(TabsContext);
|
|
5982
6045
|
if (!ctx) {
|
|
6046
|
+
devWarn(
|
|
6047
|
+
"react-tabs/context-outside-provider",
|
|
6048
|
+
"Tabs compound components (TabsList/TabsTrigger/TabsContent) must be rendered inside a <Tabs>. The missing TabsContext makes this throw."
|
|
6049
|
+
);
|
|
5983
6050
|
throw new Error("Tabs compound components must be used within <Tabs>");
|
|
5984
6051
|
}
|
|
5985
6052
|
return ctx;
|
|
@@ -6304,6 +6371,10 @@ var ToastContext = React11.createContext(null);
|
|
|
6304
6371
|
function useToastContext() {
|
|
6305
6372
|
const ctx = React11.useContext(ToastContext);
|
|
6306
6373
|
if (!ctx) {
|
|
6374
|
+
devWarn(
|
|
6375
|
+
"react-toast/use-toast-outside-provider",
|
|
6376
|
+
"useToast() was called outside a <ToastProvider>. Wrap your app (or the consuming subtree) in <ToastProvider> so the toast context is available."
|
|
6377
|
+
);
|
|
6307
6378
|
throw new Error("useToast must be used within a <ToastProvider>");
|
|
6308
6379
|
}
|
|
6309
6380
|
return ctx;
|
|
@@ -6483,6 +6554,10 @@ var TooltipContext = React11.createContext(null);
|
|
|
6483
6554
|
function useTooltipContext() {
|
|
6484
6555
|
const ctx = React11.useContext(TooltipContext);
|
|
6485
6556
|
if (!ctx) {
|
|
6557
|
+
devWarn(
|
|
6558
|
+
"react-tooltip/context-outside-provider",
|
|
6559
|
+
"Tooltip compound components (TooltipTrigger/TooltipContent/etc.) must be rendered inside a <Tooltip>. The missing TooltipContext makes this throw."
|
|
6560
|
+
);
|
|
6486
6561
|
throw new Error("Tooltip compound components must be used within <Tooltip>");
|
|
6487
6562
|
}
|
|
6488
6563
|
return ctx;
|
|
@@ -8684,6 +8759,10 @@ var ResizableLayoutContext = React11.createContext(null);
|
|
|
8684
8759
|
function useResizableLayoutContext() {
|
|
8685
8760
|
const ctx = React11.useContext(ResizableLayoutContext);
|
|
8686
8761
|
if (!ctx) {
|
|
8762
|
+
devWarn(
|
|
8763
|
+
"react-resizable-layout/compound-outside-provider",
|
|
8764
|
+
"A Resizable compound component was rendered outside of <ResizableLayout>. Wrap it in <ResizableLayout>."
|
|
8765
|
+
);
|
|
8687
8766
|
throw new Error("Resizable compound components must be used within <ResizableLayout>");
|
|
8688
8767
|
}
|
|
8689
8768
|
return ctx;
|
|
@@ -9065,6 +9144,10 @@ var AppShellContext = React11.createContext(null);
|
|
|
9065
9144
|
function useAppShell() {
|
|
9066
9145
|
const ctx = React11.useContext(AppShellContext);
|
|
9067
9146
|
if (!ctx) {
|
|
9147
|
+
devWarn(
|
|
9148
|
+
"react-app-shell/use-app-shell-outside-provider",
|
|
9149
|
+
"useAppShell() was called outside of <AppShell>. Wrap the consuming component tree in <AppShell>."
|
|
9150
|
+
);
|
|
9068
9151
|
throw new Error("useAppShell must be used within <AppShell>");
|
|
9069
9152
|
}
|
|
9070
9153
|
return ctx;
|
|
@@ -9271,6 +9354,10 @@ var PageShellContext = React11.createContext(null);
|
|
|
9271
9354
|
function usePageShell() {
|
|
9272
9355
|
const ctx = React11.useContext(PageShellContext);
|
|
9273
9356
|
if (!ctx) {
|
|
9357
|
+
devWarn(
|
|
9358
|
+
"react-app-shell/page-shell-compound-outside-provider",
|
|
9359
|
+
"A PageShell compound component was rendered outside of <PageShell>. Wrap it in <PageShell>."
|
|
9360
|
+
);
|
|
9274
9361
|
throw new Error("PageShell compound components must be used within <PageShell>");
|
|
9275
9362
|
}
|
|
9276
9363
|
return ctx;
|
|
@@ -9373,6 +9460,10 @@ var AuthShellContext = React11.createContext(null);
|
|
|
9373
9460
|
function useAuthShell() {
|
|
9374
9461
|
const ctx = React11.useContext(AuthShellContext);
|
|
9375
9462
|
if (!ctx) {
|
|
9463
|
+
devWarn(
|
|
9464
|
+
"react-app-shell/auth-shell-compound-outside-provider",
|
|
9465
|
+
"An AuthShell compound component was rendered outside of <AuthShell>. Wrap it in <AuthShell>."
|
|
9466
|
+
);
|
|
9376
9467
|
throw new Error("AuthShell compound components must be used within <AuthShell>");
|
|
9377
9468
|
}
|
|
9378
9469
|
return ctx;
|
|
@@ -11770,7 +11861,13 @@ function RadioGroup({
|
|
|
11770
11861
|
}
|
|
11771
11862
|
function RadioItem({ value, children, disabled = false, className }) {
|
|
11772
11863
|
const ctx = React11.useContext(RadioContext);
|
|
11773
|
-
if (!ctx)
|
|
11864
|
+
if (!ctx) {
|
|
11865
|
+
devWarn(
|
|
11866
|
+
"react-radio/radio-item-outside-group",
|
|
11867
|
+
"RadioItem was rendered outside of <RadioGroup>. Wrap it in <RadioGroup>."
|
|
11868
|
+
);
|
|
11869
|
+
throw new Error("RadioItem must be used within RadioGroup");
|
|
11870
|
+
}
|
|
11774
11871
|
const isChecked = ctx.value === value;
|
|
11775
11872
|
const isDisabled = ctx.disabled || disabled;
|
|
11776
11873
|
return React11.createElement(
|
|
@@ -12037,6 +12134,7 @@ var selectItemVariants = cva({
|
|
|
12037
12134
|
}
|
|
12038
12135
|
});
|
|
12039
12136
|
var SelectContext = React11.createContext({
|
|
12137
|
+
__isDefault: true,
|
|
12040
12138
|
value: void 0,
|
|
12041
12139
|
onValueChange: () => {
|
|
12042
12140
|
},
|
|
@@ -12049,6 +12147,16 @@ var SelectContext = React11.createContext({
|
|
|
12049
12147
|
triggerId: "",
|
|
12050
12148
|
contentId: ""
|
|
12051
12149
|
});
|
|
12150
|
+
function useSelectContext(part) {
|
|
12151
|
+
const ctx = React11.useContext(SelectContext);
|
|
12152
|
+
if (ctx.__isDefault) {
|
|
12153
|
+
devWarn(
|
|
12154
|
+
"react-select/no-select-provider",
|
|
12155
|
+
`<${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>.`
|
|
12156
|
+
);
|
|
12157
|
+
}
|
|
12158
|
+
return ctx;
|
|
12159
|
+
}
|
|
12052
12160
|
function Select({
|
|
12053
12161
|
value,
|
|
12054
12162
|
onValueChange,
|
|
@@ -12081,7 +12189,7 @@ function Select({
|
|
|
12081
12189
|
}
|
|
12082
12190
|
var SelectTrigger = React11.forwardRef(
|
|
12083
12191
|
({ className, children, size = "default", ...props }, ref) => {
|
|
12084
|
-
const { open, setOpen, disabled, triggerId, contentId } =
|
|
12192
|
+
const { open, setOpen, disabled, triggerId, contentId } = useSelectContext("SelectTrigger");
|
|
12085
12193
|
const api = createSelect({ disabled, open });
|
|
12086
12194
|
const handleClick = () => {
|
|
12087
12195
|
if (!disabled) {
|
|
@@ -12140,7 +12248,7 @@ var SelectTrigger = React11.forwardRef(
|
|
|
12140
12248
|
SelectTrigger.displayName = "SelectTrigger";
|
|
12141
12249
|
var SelectContent = React11.forwardRef(
|
|
12142
12250
|
({ className, children, ...props }, forwardedRef) => {
|
|
12143
|
-
const { open, contentId, triggerId, setOpen } =
|
|
12251
|
+
const { open, contentId, triggerId, setOpen } = useSelectContext("SelectContent");
|
|
12144
12252
|
const containerRef = React11.useRef(null);
|
|
12145
12253
|
const ref = React11.useCallback(
|
|
12146
12254
|
(node) => {
|
|
@@ -12201,7 +12309,7 @@ var SelectContent = React11.forwardRef(
|
|
|
12201
12309
|
SelectContent.displayName = "SelectContent";
|
|
12202
12310
|
var SelectItem = React11.forwardRef(
|
|
12203
12311
|
({ className, children, value: itemValue, disabled: itemDisabled = false, ...props }, ref) => {
|
|
12204
|
-
const { value, onValueChange, setOpen, triggerId } =
|
|
12312
|
+
const { value, onValueChange, setOpen, triggerId } = useSelectContext("SelectItem");
|
|
12205
12313
|
const isSelected = value === itemValue;
|
|
12206
12314
|
const handleClick = () => {
|
|
12207
12315
|
if (!itemDisabled) {
|
|
@@ -12768,7 +12876,13 @@ var CarouselItemContext = React11.createContext(null);
|
|
|
12768
12876
|
var CarouselItem = React11.forwardRef(
|
|
12769
12877
|
({ className, value, ...props }, ref) => {
|
|
12770
12878
|
const context = React11.useContext(CarouselContext);
|
|
12771
|
-
if (!context)
|
|
12879
|
+
if (!context) {
|
|
12880
|
+
devWarn(
|
|
12881
|
+
"react-carousel/carousel-item-outside-carousel",
|
|
12882
|
+
"CarouselItem was rendered outside of <Carousel>. Wrap it in <Carousel>."
|
|
12883
|
+
);
|
|
12884
|
+
throw new Error("CarouselItem must be within Carousel");
|
|
12885
|
+
}
|
|
12772
12886
|
const isOpen = context.type === "single" ? context.value === value : Array.isArray(context.value) && context.value.includes(value);
|
|
12773
12887
|
return /* @__PURE__ */ jsx(CarouselItemContext.Provider, { value: { value, isOpen }, children: /* @__PURE__ */ jsx("div", { ref, className: cn("border-b border-border", className), "data-state": isOpen ? "open" : "closed", ...props }) });
|
|
12774
12888
|
}
|
|
@@ -12778,7 +12892,13 @@ var CarouselTrigger = React11.forwardRef(
|
|
|
12778
12892
|
({ className, children, ...props }, ref) => {
|
|
12779
12893
|
const carouselContext = React11.useContext(CarouselContext);
|
|
12780
12894
|
const itemContext = React11.useContext(CarouselItemContext);
|
|
12781
|
-
if (!carouselContext || !itemContext)
|
|
12895
|
+
if (!carouselContext || !itemContext) {
|
|
12896
|
+
devWarn(
|
|
12897
|
+
"react-carousel/carousel-trigger-outside-item",
|
|
12898
|
+
"CarouselTrigger was rendered outside of a <CarouselItem> within <Carousel>. Nest it inside <CarouselItem>."
|
|
12899
|
+
);
|
|
12900
|
+
throw new Error("CarouselTrigger missing context");
|
|
12901
|
+
}
|
|
12782
12902
|
return /* @__PURE__ */ jsx("h3", { className: "flex m-0 p-0", children: /* @__PURE__ */ jsxs(
|
|
12783
12903
|
"button",
|
|
12784
12904
|
{
|
|
@@ -12819,7 +12939,13 @@ CarouselTrigger.displayName = "CarouselTrigger";
|
|
|
12819
12939
|
var CarouselContent = React11.forwardRef(
|
|
12820
12940
|
({ className, children, ...props }, ref) => {
|
|
12821
12941
|
const itemContext = React11.useContext(CarouselItemContext);
|
|
12822
|
-
if (!itemContext)
|
|
12942
|
+
if (!itemContext) {
|
|
12943
|
+
devWarn(
|
|
12944
|
+
"react-carousel/carousel-content-outside-item",
|
|
12945
|
+
"CarouselContent was rendered outside of a <CarouselItem> within <Carousel>. Nest it inside <CarouselItem>."
|
|
12946
|
+
);
|
|
12947
|
+
throw new Error("CarouselContent missing context");
|
|
12948
|
+
}
|
|
12823
12949
|
return /* @__PURE__ */ jsx(
|
|
12824
12950
|
"div",
|
|
12825
12951
|
{
|
|
@@ -13324,6 +13450,1185 @@ var PaymentButton = React11.forwardRef(
|
|
|
13324
13450
|
);
|
|
13325
13451
|
PaymentButton.displayName = "PaymentButton";
|
|
13326
13452
|
|
|
13327
|
-
|
|
13453
|
+
// ../logger/dist/index.js
|
|
13454
|
+
var LEVEL_ORDER = {
|
|
13455
|
+
debug: 10,
|
|
13456
|
+
info: 20,
|
|
13457
|
+
warn: 30,
|
|
13458
|
+
error: 40,
|
|
13459
|
+
fatal: 50
|
|
13460
|
+
};
|
|
13461
|
+
var METHOD = {
|
|
13462
|
+
debug: "debug",
|
|
13463
|
+
info: "info",
|
|
13464
|
+
warn: "warn",
|
|
13465
|
+
error: "error",
|
|
13466
|
+
fatal: "error"
|
|
13467
|
+
};
|
|
13468
|
+
function createConsoleSink(opts) {
|
|
13469
|
+
const pretty = opts?.pretty ?? true;
|
|
13470
|
+
const out = opts?.console ?? console;
|
|
13471
|
+
function emit(level, line, payload) {
|
|
13472
|
+
out[METHOD[level]](line, payload);
|
|
13473
|
+
}
|
|
13474
|
+
return {
|
|
13475
|
+
name: "console",
|
|
13476
|
+
log(record) {
|
|
13477
|
+
if (pretty) {
|
|
13478
|
+
const ts = new Date(record.timestamp).toISOString();
|
|
13479
|
+
emit(
|
|
13480
|
+
record.level,
|
|
13481
|
+
`${ts} ${record.level.toUpperCase()} [${record.app}] ${record.message}`,
|
|
13482
|
+
record.context
|
|
13483
|
+
);
|
|
13484
|
+
} else {
|
|
13485
|
+
emit(record.level, JSON.stringify({ type: "log", ...record }), record.context);
|
|
13486
|
+
}
|
|
13487
|
+
},
|
|
13488
|
+
span(record) {
|
|
13489
|
+
const level = record.status === "error" ? "error" : "debug";
|
|
13490
|
+
if (pretty) {
|
|
13491
|
+
emit(
|
|
13492
|
+
level,
|
|
13493
|
+
`[span] ${record.name} ${record.durationMs.toFixed(2)}ms (${record.status})`,
|
|
13494
|
+
record.context
|
|
13495
|
+
);
|
|
13496
|
+
} else {
|
|
13497
|
+
emit(level, JSON.stringify({ type: "span", ...record }), record.context);
|
|
13498
|
+
}
|
|
13499
|
+
},
|
|
13500
|
+
async flush() {
|
|
13501
|
+
}
|
|
13502
|
+
};
|
|
13503
|
+
}
|
|
13504
|
+
var NOOP_SPAN = {
|
|
13505
|
+
end() {
|
|
13506
|
+
}
|
|
13507
|
+
};
|
|
13508
|
+
function createNoopTelemetry() {
|
|
13509
|
+
const noop = {
|
|
13510
|
+
debug() {
|
|
13511
|
+
},
|
|
13512
|
+
info() {
|
|
13513
|
+
},
|
|
13514
|
+
warn() {
|
|
13515
|
+
},
|
|
13516
|
+
error() {
|
|
13517
|
+
},
|
|
13518
|
+
fatal() {
|
|
13519
|
+
},
|
|
13520
|
+
child() {
|
|
13521
|
+
return noop;
|
|
13522
|
+
},
|
|
13523
|
+
startSpan() {
|
|
13524
|
+
return NOOP_SPAN;
|
|
13525
|
+
},
|
|
13526
|
+
async flush() {
|
|
13527
|
+
},
|
|
13528
|
+
get sinks() {
|
|
13529
|
+
return [];
|
|
13530
|
+
},
|
|
13531
|
+
addSink() {
|
|
13532
|
+
},
|
|
13533
|
+
removeSink() {
|
|
13534
|
+
}
|
|
13535
|
+
};
|
|
13536
|
+
return noop;
|
|
13537
|
+
}
|
|
13538
|
+
var PRESETS = {
|
|
13539
|
+
development: {
|
|
13540
|
+
minLevel: "debug",
|
|
13541
|
+
batch: false,
|
|
13542
|
+
batchSize: 1,
|
|
13543
|
+
sampleRate: 1,
|
|
13544
|
+
pretty: true,
|
|
13545
|
+
beaconFlush: false
|
|
13546
|
+
},
|
|
13547
|
+
production: {
|
|
13548
|
+
minLevel: "warn",
|
|
13549
|
+
batch: true,
|
|
13550
|
+
batchSize: 20,
|
|
13551
|
+
sampleRate: 0.25,
|
|
13552
|
+
pretty: false,
|
|
13553
|
+
beaconFlush: true
|
|
13554
|
+
}
|
|
13555
|
+
};
|
|
13556
|
+
function resolvePreset(env) {
|
|
13557
|
+
return { ...PRESETS[env] };
|
|
13558
|
+
}
|
|
13559
|
+
function redact(value, keys) {
|
|
13560
|
+
if (keys.length === 0) return value;
|
|
13561
|
+
const lookup = new Set(keys.map((k) => k.toLowerCase()));
|
|
13562
|
+
return walk(value, lookup, /* @__PURE__ */ new WeakSet());
|
|
13563
|
+
}
|
|
13564
|
+
function walk(value, keys, seen) {
|
|
13565
|
+
if (value === null || typeof value !== "object") return value;
|
|
13566
|
+
if (seen.has(value)) return "[Circular]";
|
|
13567
|
+
seen.add(value);
|
|
13568
|
+
if (Array.isArray(value)) {
|
|
13569
|
+
return value.map((item) => walk(item, keys, seen));
|
|
13570
|
+
}
|
|
13571
|
+
const out = {};
|
|
13572
|
+
for (const [k, v] of Object.entries(value)) {
|
|
13573
|
+
if (keys.has(k.toLowerCase())) {
|
|
13574
|
+
out[k] = "[REDACTED]";
|
|
13575
|
+
continue;
|
|
13576
|
+
}
|
|
13577
|
+
out[k] = walk(v, keys, seen);
|
|
13578
|
+
}
|
|
13579
|
+
return out;
|
|
13580
|
+
}
|
|
13581
|
+
function createTelemetry(config) {
|
|
13582
|
+
if (config.enabled === false) {
|
|
13583
|
+
return createNoopTelemetry();
|
|
13584
|
+
}
|
|
13585
|
+
const preset = resolvePreset(config.env);
|
|
13586
|
+
const sampleRate = config.sampleRate ?? preset.sampleRate;
|
|
13587
|
+
const redactKeys = config.redactKeys ?? [];
|
|
13588
|
+
const sinks = /* @__PURE__ */ new Map();
|
|
13589
|
+
const sinkOrder = [];
|
|
13590
|
+
const buffer = [];
|
|
13591
|
+
function addSinkInternal(sink) {
|
|
13592
|
+
if (sinks.has(sink.name)) {
|
|
13593
|
+
sinks.set(sink.name, sink);
|
|
13594
|
+
} else {
|
|
13595
|
+
sinks.set(sink.name, sink);
|
|
13596
|
+
sinkOrder.push(sink.name);
|
|
13597
|
+
}
|
|
13598
|
+
}
|
|
13599
|
+
addSinkInternal(createConsoleSink({ pretty: preset.pretty }));
|
|
13600
|
+
if (config.endpoint) {
|
|
13601
|
+
const endpoint = config.endpoint;
|
|
13602
|
+
void import('./faro-engine-47HGRAQH-JKINJPMH.js').then(({ createFaroSink: createFaroSink2 }) => createFaroSink2({ app: config.app, endpoint })).then((faro) => {
|
|
13603
|
+
if (faro) addSinkInternal(faro);
|
|
13604
|
+
}).catch(() => {
|
|
13605
|
+
});
|
|
13606
|
+
}
|
|
13607
|
+
function shouldSample() {
|
|
13608
|
+
if (sampleRate >= 1) return true;
|
|
13609
|
+
if (sampleRate <= 0) return false;
|
|
13610
|
+
return Math.random() < sampleRate;
|
|
13611
|
+
}
|
|
13612
|
+
function dispatch(entry) {
|
|
13613
|
+
if (preset.batch) {
|
|
13614
|
+
buffer.push(entry);
|
|
13615
|
+
if (buffer.length >= preset.batchSize) {
|
|
13616
|
+
void flushBuffer();
|
|
13617
|
+
}
|
|
13618
|
+
return;
|
|
13619
|
+
}
|
|
13620
|
+
deliver(entry);
|
|
13621
|
+
}
|
|
13622
|
+
function deliver(entry) {
|
|
13623
|
+
for (const name of sinkOrder) {
|
|
13624
|
+
const sink = sinks.get(name);
|
|
13625
|
+
if (!sink) continue;
|
|
13626
|
+
if (entry.kind === "log") sink.log(entry.record);
|
|
13627
|
+
else sink.span(entry.record);
|
|
13628
|
+
}
|
|
13629
|
+
}
|
|
13630
|
+
async function flushBuffer() {
|
|
13631
|
+
if (buffer.length > 0) {
|
|
13632
|
+
const pending = buffer.splice(0, buffer.length);
|
|
13633
|
+
for (const entry of pending) deliver(entry);
|
|
13634
|
+
}
|
|
13635
|
+
await Promise.all(
|
|
13636
|
+
sinkOrder.map((name) => sinks.get(name)?.flush() ?? Promise.resolve())
|
|
13637
|
+
);
|
|
13638
|
+
}
|
|
13639
|
+
const root = globalThis;
|
|
13640
|
+
if (preset.beaconFlush && typeof root.addEventListener === "function") {
|
|
13641
|
+
const onExit = () => {
|
|
13642
|
+
void flushBuffer();
|
|
13643
|
+
};
|
|
13644
|
+
root.addEventListener("pagehide", onExit);
|
|
13645
|
+
root.addEventListener("visibilitychange", () => {
|
|
13646
|
+
if (root.document?.visibilityState === "hidden") onExit();
|
|
13647
|
+
});
|
|
13648
|
+
}
|
|
13649
|
+
function makeLogger(boundContext) {
|
|
13650
|
+
function emit(level, message, context) {
|
|
13651
|
+
if (LEVEL_ORDER[level] < LEVEL_ORDER[preset.minLevel]) return;
|
|
13652
|
+
if (!shouldSample()) return;
|
|
13653
|
+
const merged = redact({ ...boundContext, ...context }, redactKeys);
|
|
13654
|
+
const record = {
|
|
13655
|
+
level,
|
|
13656
|
+
message,
|
|
13657
|
+
timestamp: Date.now(),
|
|
13658
|
+
app: config.app,
|
|
13659
|
+
env: config.env,
|
|
13660
|
+
context: merged
|
|
13661
|
+
};
|
|
13662
|
+
dispatch({ kind: "log", record });
|
|
13663
|
+
}
|
|
13664
|
+
const logger = {
|
|
13665
|
+
debug(message, context) {
|
|
13666
|
+
emit("debug", message, context);
|
|
13667
|
+
},
|
|
13668
|
+
info(message, context) {
|
|
13669
|
+
emit("info", message, context);
|
|
13670
|
+
},
|
|
13671
|
+
warn(message, context) {
|
|
13672
|
+
emit("warn", message, context);
|
|
13673
|
+
},
|
|
13674
|
+
error(message, context) {
|
|
13675
|
+
emit("error", message, context);
|
|
13676
|
+
},
|
|
13677
|
+
fatal(message, context) {
|
|
13678
|
+
emit("fatal", message, context);
|
|
13679
|
+
},
|
|
13680
|
+
child(context) {
|
|
13681
|
+
return makeLogger({ ...boundContext, ...context });
|
|
13682
|
+
},
|
|
13683
|
+
startSpan(name, attributes) {
|
|
13684
|
+
const startTime = Date.now();
|
|
13685
|
+
let ended = false;
|
|
13686
|
+
return {
|
|
13687
|
+
end(opts) {
|
|
13688
|
+
if (ended) return;
|
|
13689
|
+
ended = true;
|
|
13690
|
+
const endTime = Date.now();
|
|
13691
|
+
const merged = redact(
|
|
13692
|
+
{ ...boundContext, ...attributes, ...opts?.attributes },
|
|
13693
|
+
redactKeys
|
|
13694
|
+
);
|
|
13695
|
+
const err = opts?.error;
|
|
13696
|
+
const record = {
|
|
13697
|
+
name,
|
|
13698
|
+
startTime,
|
|
13699
|
+
endTime,
|
|
13700
|
+
durationMs: endTime - startTime,
|
|
13701
|
+
app: config.app,
|
|
13702
|
+
env: config.env,
|
|
13703
|
+
context: merged,
|
|
13704
|
+
status: err ? "error" : "ok",
|
|
13705
|
+
...err ? {
|
|
13706
|
+
error: {
|
|
13707
|
+
name: err instanceof Error ? err.name : "Error",
|
|
13708
|
+
message: err instanceof Error ? err.message : String(err)
|
|
13709
|
+
}
|
|
13710
|
+
} : {}
|
|
13711
|
+
};
|
|
13712
|
+
dispatch({ kind: "span", record });
|
|
13713
|
+
}
|
|
13714
|
+
};
|
|
13715
|
+
},
|
|
13716
|
+
flush() {
|
|
13717
|
+
return flushBuffer();
|
|
13718
|
+
},
|
|
13719
|
+
get sinks() {
|
|
13720
|
+
return [...sinkOrder];
|
|
13721
|
+
},
|
|
13722
|
+
addSink(sink) {
|
|
13723
|
+
addSinkInternal(sink);
|
|
13724
|
+
},
|
|
13725
|
+
removeSink(name) {
|
|
13726
|
+
if (sinks.has(name)) {
|
|
13727
|
+
sinks.delete(name);
|
|
13728
|
+
const idx = sinkOrder.indexOf(name);
|
|
13729
|
+
if (idx !== -1) sinkOrder.splice(idx, 1);
|
|
13730
|
+
}
|
|
13731
|
+
}
|
|
13732
|
+
};
|
|
13733
|
+
return logger;
|
|
13734
|
+
}
|
|
13735
|
+
return makeLogger({});
|
|
13736
|
+
}
|
|
13737
|
+
|
|
13738
|
+
// ../react-logger/dist/index.js
|
|
13739
|
+
var TelemetryContext = React11.createContext(null);
|
|
13740
|
+
function TelemetryProvider({ children, ...config }) {
|
|
13741
|
+
const telemetryRef = React11.useRef(null);
|
|
13742
|
+
if (!telemetryRef.current) {
|
|
13743
|
+
telemetryRef.current = createTelemetry(config);
|
|
13744
|
+
}
|
|
13745
|
+
const value = React11.useMemo(
|
|
13746
|
+
() => ({ telemetry: telemetryRef.current }),
|
|
13747
|
+
[]
|
|
13748
|
+
);
|
|
13749
|
+
return React11.createElement(TelemetryContext.Provider, { value }, children);
|
|
13750
|
+
}
|
|
13751
|
+
function useTelemetry() {
|
|
13752
|
+
const ctx = React11.useContext(TelemetryContext);
|
|
13753
|
+
if (!ctx) {
|
|
13754
|
+
devWarn(
|
|
13755
|
+
"react-logger/use-telemetry-outside-provider",
|
|
13756
|
+
"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."
|
|
13757
|
+
);
|
|
13758
|
+
throw new Error("useTelemetry must be used within a <TelemetryProvider>");
|
|
13759
|
+
}
|
|
13760
|
+
return ctx.telemetry;
|
|
13761
|
+
}
|
|
13762
|
+
function useLogger(scope) {
|
|
13763
|
+
const telemetry = useTelemetry();
|
|
13764
|
+
const scopeKey = scope ? JSON.stringify(scope) : "";
|
|
13765
|
+
return React11.useMemo(
|
|
13766
|
+
() => scope ? telemetry.child(scope) : telemetry,
|
|
13767
|
+
[telemetry, scope, scopeKey]
|
|
13768
|
+
);
|
|
13769
|
+
}
|
|
13770
|
+
function useSpan() {
|
|
13771
|
+
const telemetry = useTelemetry();
|
|
13772
|
+
const spanRef = React11.useRef(null);
|
|
13773
|
+
const [isActive, setIsActive] = React11.useState(false);
|
|
13774
|
+
const end = React11.useCallback(
|
|
13775
|
+
(opts) => {
|
|
13776
|
+
if (!spanRef.current) return;
|
|
13777
|
+
spanRef.current.end(opts);
|
|
13778
|
+
spanRef.current = null;
|
|
13779
|
+
setIsActive(false);
|
|
13780
|
+
},
|
|
13781
|
+
[]
|
|
13782
|
+
);
|
|
13783
|
+
const start = React11.useCallback(
|
|
13784
|
+
(name, attributes) => {
|
|
13785
|
+
if (spanRef.current) {
|
|
13786
|
+
spanRef.current.end();
|
|
13787
|
+
}
|
|
13788
|
+
const span = telemetry.startSpan(name, attributes);
|
|
13789
|
+
spanRef.current = span;
|
|
13790
|
+
setIsActive(true);
|
|
13791
|
+
return span;
|
|
13792
|
+
},
|
|
13793
|
+
[telemetry]
|
|
13794
|
+
);
|
|
13795
|
+
React11.useEffect(() => {
|
|
13796
|
+
return () => {
|
|
13797
|
+
if (spanRef.current) {
|
|
13798
|
+
spanRef.current.end();
|
|
13799
|
+
spanRef.current = null;
|
|
13800
|
+
}
|
|
13801
|
+
};
|
|
13802
|
+
}, []);
|
|
13803
|
+
return React11.useMemo(
|
|
13804
|
+
() => ({ start, end, isActive }),
|
|
13805
|
+
[start, end, isActive]
|
|
13806
|
+
);
|
|
13807
|
+
}
|
|
13808
|
+
var TelemetryErrorBoundary = class extends React11.Component {
|
|
13809
|
+
static contextType = TelemetryContext;
|
|
13810
|
+
state = { error: null };
|
|
13811
|
+
static getDerivedStateFromError(error) {
|
|
13812
|
+
return { error };
|
|
13813
|
+
}
|
|
13814
|
+
componentDidCatch(error, info) {
|
|
13815
|
+
const telemetry = this.context?.telemetry;
|
|
13816
|
+
if (telemetry) {
|
|
13817
|
+
telemetry.error(error.message, {
|
|
13818
|
+
...this.props.context,
|
|
13819
|
+
name: error.name,
|
|
13820
|
+
stack: error.stack,
|
|
13821
|
+
componentStack: info.componentStack
|
|
13822
|
+
});
|
|
13823
|
+
}
|
|
13824
|
+
this.props.onError?.(error, info);
|
|
13825
|
+
}
|
|
13826
|
+
reset = () => {
|
|
13827
|
+
this.setState({ error: null });
|
|
13828
|
+
};
|
|
13829
|
+
render() {
|
|
13830
|
+
const { error } = this.state;
|
|
13831
|
+
if (error) {
|
|
13832
|
+
const { fallback } = this.props;
|
|
13833
|
+
if (typeof fallback === "function") {
|
|
13834
|
+
return fallback(error, this.reset);
|
|
13835
|
+
}
|
|
13836
|
+
return fallback ?? null;
|
|
13837
|
+
}
|
|
13838
|
+
return this.props.children;
|
|
13839
|
+
}
|
|
13840
|
+
};
|
|
13841
|
+
|
|
13842
|
+
// ../analytics/dist/index.js
|
|
13843
|
+
var SCHEMA_VERSION = 1;
|
|
13844
|
+
function uuidv4() {
|
|
13845
|
+
const c = typeof globalThis !== "undefined" ? globalThis.crypto : void 0;
|
|
13846
|
+
if (c && typeof c.randomUUID === "function") {
|
|
13847
|
+
return c.randomUUID();
|
|
13848
|
+
}
|
|
13849
|
+
const bytes = new Uint8Array(16);
|
|
13850
|
+
if (c && typeof c.getRandomValues === "function") {
|
|
13851
|
+
c.getRandomValues(bytes);
|
|
13852
|
+
} else {
|
|
13853
|
+
for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
|
|
13854
|
+
}
|
|
13855
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
13856
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
13857
|
+
const hex = [];
|
|
13858
|
+
for (let i = 0; i < 256; i++) hex.push((i + 256).toString(16).slice(1));
|
|
13859
|
+
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]];
|
|
13860
|
+
}
|
|
13861
|
+
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;
|
|
13862
|
+
function isUuidV4(value) {
|
|
13863
|
+
return typeof value === "string" && UUID_V4_RE.test(value);
|
|
13864
|
+
}
|
|
13865
|
+
function createMemoryStorage() {
|
|
13866
|
+
const map = /* @__PURE__ */ new Map();
|
|
13867
|
+
return {
|
|
13868
|
+
get: (k) => map.has(k) ? map.get(k) : null,
|
|
13869
|
+
set: (k, v) => {
|
|
13870
|
+
map.set(k, v);
|
|
13871
|
+
},
|
|
13872
|
+
remove: (k) => {
|
|
13873
|
+
map.delete(k);
|
|
13874
|
+
}
|
|
13875
|
+
};
|
|
13876
|
+
}
|
|
13877
|
+
function createLocalStorageAdapter(ls) {
|
|
13878
|
+
return {
|
|
13879
|
+
get: (k) => {
|
|
13880
|
+
try {
|
|
13881
|
+
return ls.getItem(k);
|
|
13882
|
+
} catch {
|
|
13883
|
+
return null;
|
|
13884
|
+
}
|
|
13885
|
+
},
|
|
13886
|
+
set: (k, v) => {
|
|
13887
|
+
try {
|
|
13888
|
+
ls.setItem(k, v);
|
|
13889
|
+
} catch {
|
|
13890
|
+
}
|
|
13891
|
+
},
|
|
13892
|
+
remove: (k) => {
|
|
13893
|
+
try {
|
|
13894
|
+
ls.removeItem(k);
|
|
13895
|
+
} catch {
|
|
13896
|
+
}
|
|
13897
|
+
}
|
|
13898
|
+
};
|
|
13899
|
+
}
|
|
13900
|
+
function createCookieAdapter(doc, maxAgeSeconds = 60 * 60 * 24 * 365) {
|
|
13901
|
+
const read = (k) => {
|
|
13902
|
+
const target = encodeURIComponent(k) + "=";
|
|
13903
|
+
const parts = doc.cookie ? doc.cookie.split(";") : [];
|
|
13904
|
+
for (const part of parts) {
|
|
13905
|
+
const c = part.trim();
|
|
13906
|
+
if (c.startsWith(target)) {
|
|
13907
|
+
return decodeURIComponent(c.slice(target.length));
|
|
13908
|
+
}
|
|
13909
|
+
}
|
|
13910
|
+
return null;
|
|
13911
|
+
};
|
|
13912
|
+
return {
|
|
13913
|
+
get: read,
|
|
13914
|
+
set: (k, v) => {
|
|
13915
|
+
doc.cookie = `${encodeURIComponent(k)}=${encodeURIComponent(
|
|
13916
|
+
v
|
|
13917
|
+
)}; path=/; max-age=${maxAgeSeconds}; SameSite=Lax`;
|
|
13918
|
+
},
|
|
13919
|
+
remove: (k) => {
|
|
13920
|
+
doc.cookie = `${encodeURIComponent(k)}=; path=/; max-age=0; SameSite=Lax`;
|
|
13921
|
+
}
|
|
13922
|
+
};
|
|
13923
|
+
}
|
|
13924
|
+
function resolveStorage(override) {
|
|
13925
|
+
if (override) return override;
|
|
13926
|
+
const g = globalThis;
|
|
13927
|
+
if (g.localStorage) {
|
|
13928
|
+
try {
|
|
13929
|
+
const probe = "__rfx_a_probe__";
|
|
13930
|
+
g.localStorage.setItem(probe, "1");
|
|
13931
|
+
g.localStorage.removeItem(probe);
|
|
13932
|
+
return createLocalStorageAdapter(g.localStorage);
|
|
13933
|
+
} catch {
|
|
13934
|
+
}
|
|
13935
|
+
}
|
|
13936
|
+
if (g.document && typeof g.document.cookie === "string") {
|
|
13937
|
+
return createCookieAdapter(g.document);
|
|
13938
|
+
}
|
|
13939
|
+
return createMemoryStorage();
|
|
13940
|
+
}
|
|
13941
|
+
var DEFAULT_SESSION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
13942
|
+
var DEFAULT_KEY = "rfx:analytics:session";
|
|
13943
|
+
var CAMPAIGN_PARAMS = [
|
|
13944
|
+
"utm_source",
|
|
13945
|
+
"utm_medium",
|
|
13946
|
+
"utm_campaign",
|
|
13947
|
+
"utm_term",
|
|
13948
|
+
"utm_content",
|
|
13949
|
+
"gclid",
|
|
13950
|
+
"fbclid",
|
|
13951
|
+
"msclkid"
|
|
13952
|
+
];
|
|
13953
|
+
function campaignFingerprint(search) {
|
|
13954
|
+
if (!search) return void 0;
|
|
13955
|
+
let qs = search;
|
|
13956
|
+
const q = qs.indexOf("?");
|
|
13957
|
+
if (q !== -1) qs = qs.slice(q + 1);
|
|
13958
|
+
let params;
|
|
13959
|
+
try {
|
|
13960
|
+
params = new URLSearchParams(qs);
|
|
13961
|
+
} catch {
|
|
13962
|
+
return void 0;
|
|
13963
|
+
}
|
|
13964
|
+
const pairs = [];
|
|
13965
|
+
for (const p of CAMPAIGN_PARAMS) {
|
|
13966
|
+
const v = params.get(p);
|
|
13967
|
+
if (v) pairs.push(`${p}=${v}`);
|
|
13968
|
+
}
|
|
13969
|
+
return pairs.length ? pairs.join("&") : void 0;
|
|
13970
|
+
}
|
|
13971
|
+
function createSession(config, now = () => Date.now()) {
|
|
13972
|
+
const storage = resolveStorage(config?.storage);
|
|
13973
|
+
const key = config?.storageKey ?? DEFAULT_KEY;
|
|
13974
|
+
const timeoutMs = config?.timeoutMs ?? DEFAULT_SESSION_TIMEOUT_MS;
|
|
13975
|
+
const resetOnCampaign = config?.resetOnCampaign ?? true;
|
|
13976
|
+
function read() {
|
|
13977
|
+
const raw = storage.get(key);
|
|
13978
|
+
if (!raw) return null;
|
|
13979
|
+
try {
|
|
13980
|
+
const parsed = JSON.parse(raw);
|
|
13981
|
+
if (parsed && typeof parsed.id === "string") return parsed;
|
|
13982
|
+
} catch {
|
|
13983
|
+
}
|
|
13984
|
+
return null;
|
|
13985
|
+
}
|
|
13986
|
+
function write(s) {
|
|
13987
|
+
storage.set(key, JSON.stringify(s));
|
|
13988
|
+
}
|
|
13989
|
+
function mint(campaign) {
|
|
13990
|
+
const s = {
|
|
13991
|
+
id: uuidv4(),
|
|
13992
|
+
lastActivity: now(),
|
|
13993
|
+
campaign
|
|
13994
|
+
};
|
|
13995
|
+
write(s);
|
|
13996
|
+
return s;
|
|
13997
|
+
}
|
|
13998
|
+
function ensure(campaign) {
|
|
13999
|
+
const existing = read();
|
|
14000
|
+
const t = now();
|
|
14001
|
+
if (!existing) return mint(campaign);
|
|
14002
|
+
if (t - existing.lastActivity > timeoutMs) {
|
|
14003
|
+
return mint(campaign);
|
|
14004
|
+
}
|
|
14005
|
+
if (resetOnCampaign && campaign !== void 0 && existing.campaign !== campaign) {
|
|
14006
|
+
return mint(campaign);
|
|
14007
|
+
}
|
|
14008
|
+
return existing;
|
|
14009
|
+
}
|
|
14010
|
+
return {
|
|
14011
|
+
/** Get the current session id, rotating if expired. */
|
|
14012
|
+
id(campaign) {
|
|
14013
|
+
return ensure(campaign).id;
|
|
14014
|
+
},
|
|
14015
|
+
/** Force a brand-new session. */
|
|
14016
|
+
start(campaign) {
|
|
14017
|
+
return mint(campaign).id;
|
|
14018
|
+
},
|
|
14019
|
+
/** End the current session (next id() mints a fresh one). */
|
|
14020
|
+
end() {
|
|
14021
|
+
storage.remove(key);
|
|
14022
|
+
},
|
|
14023
|
+
/** Touch activity so the inactivity window slides forward. */
|
|
14024
|
+
touch(campaign) {
|
|
14025
|
+
const s = ensure(campaign);
|
|
14026
|
+
s.lastActivity = now();
|
|
14027
|
+
write(s);
|
|
14028
|
+
return s.id;
|
|
14029
|
+
},
|
|
14030
|
+
/** Attach/merge session-scoped properties. */
|
|
14031
|
+
set(props) {
|
|
14032
|
+
const s = ensure();
|
|
14033
|
+
s.props = { ...s.props ?? {}, ...props };
|
|
14034
|
+
write(s);
|
|
14035
|
+
},
|
|
14036
|
+
/** Read session-scoped properties (undefined when none). */
|
|
14037
|
+
props() {
|
|
14038
|
+
return read()?.props;
|
|
14039
|
+
}
|
|
14040
|
+
};
|
|
14041
|
+
}
|
|
14042
|
+
var DEFAULT_KEY2 = "rfx:analytics:anon";
|
|
14043
|
+
function createIdentity(config) {
|
|
14044
|
+
const storage = resolveStorage(config?.storage);
|
|
14045
|
+
const key = config?.storageKey ?? DEFAULT_KEY2;
|
|
14046
|
+
let userId;
|
|
14047
|
+
function loadOrMintAnon() {
|
|
14048
|
+
const existing = storage.get(key);
|
|
14049
|
+
if (isUuidV4(existing)) return existing;
|
|
14050
|
+
const fresh = uuidv4();
|
|
14051
|
+
storage.set(key, fresh);
|
|
14052
|
+
return fresh;
|
|
14053
|
+
}
|
|
14054
|
+
let anonymousId = loadOrMintAnon();
|
|
14055
|
+
return {
|
|
14056
|
+
anonymousId() {
|
|
14057
|
+
return anonymousId;
|
|
14058
|
+
},
|
|
14059
|
+
userId() {
|
|
14060
|
+
return userId;
|
|
14061
|
+
},
|
|
14062
|
+
/** identify(): bind an opaque app user id (no validation, no persistence). */
|
|
14063
|
+
setUserId(id) {
|
|
14064
|
+
userId = id;
|
|
14065
|
+
},
|
|
14066
|
+
/**
|
|
14067
|
+
* alias(): returns the stitch pair for the envelope. `previousId`
|
|
14068
|
+
* defaults to the current user or anonymous id.
|
|
14069
|
+
*/
|
|
14070
|
+
alias(nextUserId, previousId) {
|
|
14071
|
+
const prev = previousId ?? userId ?? anonymousId;
|
|
14072
|
+
userId = nextUserId;
|
|
14073
|
+
return { userId: nextUserId, previousId: prev };
|
|
14074
|
+
},
|
|
14075
|
+
/**
|
|
14076
|
+
* reset(): privacy-safe logout. Drops the user binding and mints a brand
|
|
14077
|
+
* new anonymousId so the next visitor is not stitched to the old one.
|
|
14078
|
+
*/
|
|
14079
|
+
reset() {
|
|
14080
|
+
userId = void 0;
|
|
14081
|
+
anonymousId = uuidv4();
|
|
14082
|
+
storage.set(key, anonymousId);
|
|
14083
|
+
return anonymousId;
|
|
14084
|
+
}
|
|
14085
|
+
};
|
|
14086
|
+
}
|
|
14087
|
+
function createConsent(config) {
|
|
14088
|
+
const granted = new Set(config?.granted ?? []);
|
|
14089
|
+
return {
|
|
14090
|
+
strict: config?.strict ?? false,
|
|
14091
|
+
grant(...categories) {
|
|
14092
|
+
for (const c of categories) granted.add(c);
|
|
14093
|
+
},
|
|
14094
|
+
revoke(...categories) {
|
|
14095
|
+
for (const c of categories) granted.delete(c);
|
|
14096
|
+
},
|
|
14097
|
+
granted() {
|
|
14098
|
+
return [...granted];
|
|
14099
|
+
},
|
|
14100
|
+
isGranted(category) {
|
|
14101
|
+
return granted.has(category);
|
|
14102
|
+
},
|
|
14103
|
+
allows(required) {
|
|
14104
|
+
if (!required || required.length === 0) return true;
|
|
14105
|
+
return required.every((c) => granted.has(c));
|
|
14106
|
+
}
|
|
14107
|
+
};
|
|
14108
|
+
}
|
|
14109
|
+
var PII_DENY_LIST = [
|
|
14110
|
+
"email",
|
|
14111
|
+
"phone",
|
|
14112
|
+
"mobile",
|
|
14113
|
+
"firstname",
|
|
14114
|
+
"lastname",
|
|
14115
|
+
"fullname",
|
|
14116
|
+
"givenname",
|
|
14117
|
+
"surname",
|
|
14118
|
+
"password",
|
|
14119
|
+
"passwd",
|
|
14120
|
+
"ssn",
|
|
14121
|
+
"creditcard",
|
|
14122
|
+
"cardnumber",
|
|
14123
|
+
"cvv",
|
|
14124
|
+
"dob",
|
|
14125
|
+
"dateofbirth",
|
|
14126
|
+
"address"
|
|
14127
|
+
];
|
|
14128
|
+
var PII_EXACT_KEYS = ["name"];
|
|
14129
|
+
var REDACTED = "[REDACTED]";
|
|
14130
|
+
function normalize(key) {
|
|
14131
|
+
return key.toLowerCase().replace(/[_\-\s]/g, "");
|
|
14132
|
+
}
|
|
14133
|
+
function createRedactor(extraKeys = []) {
|
|
14134
|
+
const exact = /* @__PURE__ */ new Set([
|
|
14135
|
+
...extraKeys.map(normalize),
|
|
14136
|
+
...PII_EXACT_KEYS.map(normalize)
|
|
14137
|
+
]);
|
|
14138
|
+
const deny = PII_DENY_LIST.map(normalize);
|
|
14139
|
+
const shouldRedact = (key) => {
|
|
14140
|
+
const n = normalize(key);
|
|
14141
|
+
if (exact.has(n)) return true;
|
|
14142
|
+
return deny.some((d) => n.includes(d));
|
|
14143
|
+
};
|
|
14144
|
+
const walk2 = (value) => {
|
|
14145
|
+
if (Array.isArray(value)) return value.map(walk2);
|
|
14146
|
+
if (value && typeof value === "object") {
|
|
14147
|
+
const out = {};
|
|
14148
|
+
for (const [k, v] of Object.entries(value)) {
|
|
14149
|
+
out[k] = shouldRedact(k) ? REDACTED : walk2(v);
|
|
14150
|
+
}
|
|
14151
|
+
return out;
|
|
14152
|
+
}
|
|
14153
|
+
return value;
|
|
14154
|
+
};
|
|
14155
|
+
return {
|
|
14156
|
+
shouldRedact,
|
|
14157
|
+
/** Redact a properties/traits bag (returns a new object). */
|
|
14158
|
+
redact(props) {
|
|
14159
|
+
if (!props) return props;
|
|
14160
|
+
return walk2(props);
|
|
14161
|
+
}
|
|
14162
|
+
};
|
|
14163
|
+
}
|
|
14164
|
+
var NO_RETRY = /* @__PURE__ */ new Set([400, 401, 413]);
|
|
14165
|
+
function base64(input) {
|
|
14166
|
+
const g = globalThis;
|
|
14167
|
+
if (typeof g.btoa === "function") {
|
|
14168
|
+
return g.btoa(input);
|
|
14169
|
+
}
|
|
14170
|
+
if (g.Buffer) {
|
|
14171
|
+
return g.Buffer.from(input, "utf-8").toString("base64");
|
|
14172
|
+
}
|
|
14173
|
+
throw new Error("No base64 implementation available (btoa/Buffer)");
|
|
14174
|
+
}
|
|
14175
|
+
function byteLength(s) {
|
|
14176
|
+
const g = globalThis;
|
|
14177
|
+
if (g.TextEncoder) return new g.TextEncoder().encode(s).length;
|
|
14178
|
+
return unescape(encodeURIComponent(s)).length;
|
|
14179
|
+
}
|
|
14180
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
14181
|
+
function splitBatch(batch, maxBatchBytes, maxEventBytes) {
|
|
14182
|
+
const batches = [];
|
|
14183
|
+
const dropped = [];
|
|
14184
|
+
let current = [];
|
|
14185
|
+
let currentBytes = 2;
|
|
14186
|
+
for (const ev of batch) {
|
|
14187
|
+
const evBytes = byteLength(JSON.stringify(ev));
|
|
14188
|
+
if (evBytes > maxEventBytes) {
|
|
14189
|
+
dropped.push(ev);
|
|
14190
|
+
continue;
|
|
14191
|
+
}
|
|
14192
|
+
if (current.length && currentBytes + evBytes + 1 > maxBatchBytes) {
|
|
14193
|
+
batches.push(current);
|
|
14194
|
+
current = [];
|
|
14195
|
+
currentBytes = 2;
|
|
14196
|
+
}
|
|
14197
|
+
current.push(ev);
|
|
14198
|
+
currentBytes += evBytes + 1;
|
|
14199
|
+
}
|
|
14200
|
+
if (current.length) batches.push(current);
|
|
14201
|
+
return { batches, dropped };
|
|
14202
|
+
}
|
|
14203
|
+
function createHttpSink(options) {
|
|
14204
|
+
const {
|
|
14205
|
+
endpoint,
|
|
14206
|
+
writeKey,
|
|
14207
|
+
maxRetries = 3,
|
|
14208
|
+
backoffBaseMs = 500,
|
|
14209
|
+
consentCategories = ["analytics"],
|
|
14210
|
+
maxBatchBytes = 5e5,
|
|
14211
|
+
maxEventBytes = 32e3
|
|
14212
|
+
} = options;
|
|
14213
|
+
const base = endpoint.replace(/\/+$/, "");
|
|
14214
|
+
const url = `${base}/v${SCHEMA_VERSION}/batch`;
|
|
14215
|
+
const authHeader = `Basic ${base64(`${writeKey}:`)}`;
|
|
14216
|
+
const resolveFetch = () => {
|
|
14217
|
+
if (options.fetchImpl) return options.fetchImpl;
|
|
14218
|
+
const f = globalThis.fetch;
|
|
14219
|
+
if (!f) throw new Error("No fetch implementation available");
|
|
14220
|
+
return f;
|
|
14221
|
+
};
|
|
14222
|
+
const resolveBeacon = () => {
|
|
14223
|
+
if (options.beaconImpl) return options.beaconImpl;
|
|
14224
|
+
const nav = globalThis.navigator;
|
|
14225
|
+
if (nav && typeof nav.sendBeacon === "function") {
|
|
14226
|
+
return (u, body) => nav.sendBeacon(u, body);
|
|
14227
|
+
}
|
|
14228
|
+
return void 0;
|
|
14229
|
+
};
|
|
14230
|
+
function envelope(batch) {
|
|
14231
|
+
return {
|
|
14232
|
+
batch,
|
|
14233
|
+
sentAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14234
|
+
batchId: uuidv4()
|
|
14235
|
+
};
|
|
14236
|
+
}
|
|
14237
|
+
function sendViaBeacon(batch) {
|
|
14238
|
+
const beacon = resolveBeacon();
|
|
14239
|
+
if (!beacon) return false;
|
|
14240
|
+
const beaconUrl = `${url}?writeKey=${encodeURIComponent(writeKey)}`;
|
|
14241
|
+
return beacon(beaconUrl, JSON.stringify(envelope(batch)));
|
|
14242
|
+
}
|
|
14243
|
+
async function sendViaFetch(batch) {
|
|
14244
|
+
const doFetch = resolveFetch();
|
|
14245
|
+
const body = JSON.stringify(envelope(batch));
|
|
14246
|
+
for (let attempt = 0; ; attempt++) {
|
|
14247
|
+
let status;
|
|
14248
|
+
try {
|
|
14249
|
+
const res = await doFetch(url, {
|
|
14250
|
+
method: "POST",
|
|
14251
|
+
headers: {
|
|
14252
|
+
"Content-Type": "application/json",
|
|
14253
|
+
Authorization: authHeader
|
|
14254
|
+
},
|
|
14255
|
+
body,
|
|
14256
|
+
keepalive: true
|
|
14257
|
+
});
|
|
14258
|
+
status = res.status;
|
|
14259
|
+
} catch {
|
|
14260
|
+
status = 0;
|
|
14261
|
+
}
|
|
14262
|
+
if (status >= 200 && status < 300) return;
|
|
14263
|
+
if (NO_RETRY.has(status)) return;
|
|
14264
|
+
if (attempt >= maxRetries) return;
|
|
14265
|
+
const delay = backoffBaseMs * 2 ** attempt;
|
|
14266
|
+
await sleep(delay);
|
|
14267
|
+
}
|
|
14268
|
+
}
|
|
14269
|
+
return {
|
|
14270
|
+
name: "http",
|
|
14271
|
+
consentCategories,
|
|
14272
|
+
async deliver(batch, ctx) {
|
|
14273
|
+
if (batch.length === 0) return;
|
|
14274
|
+
const { batches } = splitBatch(
|
|
14275
|
+
batch,
|
|
14276
|
+
maxBatchBytes,
|
|
14277
|
+
maxEventBytes
|
|
14278
|
+
);
|
|
14279
|
+
for (const part of batches) {
|
|
14280
|
+
if (ctx.unload) {
|
|
14281
|
+
if (sendViaBeacon(part)) continue;
|
|
14282
|
+
void sendViaFetch(part);
|
|
14283
|
+
} else {
|
|
14284
|
+
await sendViaFetch(part);
|
|
14285
|
+
}
|
|
14286
|
+
}
|
|
14287
|
+
}
|
|
14288
|
+
};
|
|
14289
|
+
}
|
|
14290
|
+
function createConsoleSink2(options = {}) {
|
|
14291
|
+
const logger = options.logger ?? globalThis.console;
|
|
14292
|
+
return {
|
|
14293
|
+
name: "console",
|
|
14294
|
+
consentCategories: options.consentCategories,
|
|
14295
|
+
deliver(batch) {
|
|
14296
|
+
for (const ev of batch) {
|
|
14297
|
+
const label = `[analytics] ${ev.type}${ev.event ? ` ${ev.event}` : ""}`;
|
|
14298
|
+
if (typeof logger.groupCollapsed === "function") {
|
|
14299
|
+
logger.groupCollapsed(label);
|
|
14300
|
+
logger.log(ev);
|
|
14301
|
+
logger.groupEnd?.();
|
|
14302
|
+
} else {
|
|
14303
|
+
logger.log(label, ev);
|
|
14304
|
+
}
|
|
14305
|
+
}
|
|
14306
|
+
}
|
|
14307
|
+
};
|
|
14308
|
+
}
|
|
14309
|
+
function createNoopAnalytics() {
|
|
14310
|
+
const sessionId = "00000000-0000-4000-8000-000000000000";
|
|
14311
|
+
const noop = () => {
|
|
14312
|
+
};
|
|
14313
|
+
const api = {
|
|
14314
|
+
track: noop,
|
|
14315
|
+
identify: noop,
|
|
14316
|
+
page: noop,
|
|
14317
|
+
screen: noop,
|
|
14318
|
+
group: noop,
|
|
14319
|
+
alias: noop,
|
|
14320
|
+
session: {
|
|
14321
|
+
id: () => sessionId,
|
|
14322
|
+
start: () => sessionId,
|
|
14323
|
+
end: noop,
|
|
14324
|
+
set: noop
|
|
14325
|
+
},
|
|
14326
|
+
consent: {
|
|
14327
|
+
grant: noop,
|
|
14328
|
+
revoke: noop,
|
|
14329
|
+
granted: () => [],
|
|
14330
|
+
isGranted: () => false
|
|
14331
|
+
},
|
|
14332
|
+
anonymousId: () => sessionId,
|
|
14333
|
+
userId: () => void 0,
|
|
14334
|
+
with: () => api,
|
|
14335
|
+
addSink: noop,
|
|
14336
|
+
removeSink: noop,
|
|
14337
|
+
get sinks() {
|
|
14338
|
+
return [];
|
|
14339
|
+
},
|
|
14340
|
+
flush: async () => {
|
|
14341
|
+
},
|
|
14342
|
+
reset: noop,
|
|
14343
|
+
enabled: false
|
|
14344
|
+
};
|
|
14345
|
+
return api;
|
|
14346
|
+
}
|
|
14347
|
+
var LIBRARY = {
|
|
14348
|
+
name: "@refraction-ui/analytics",
|
|
14349
|
+
version: "0.1.0"
|
|
14350
|
+
};
|
|
14351
|
+
function readPage() {
|
|
14352
|
+
const g = globalThis;
|
|
14353
|
+
if (!g.location && !g.document) return void 0;
|
|
14354
|
+
return {
|
|
14355
|
+
path: g.location?.pathname,
|
|
14356
|
+
url: g.location?.href,
|
|
14357
|
+
search: g.location?.search,
|
|
14358
|
+
title: g.document?.title,
|
|
14359
|
+
referrer: g.document?.referrer
|
|
14360
|
+
};
|
|
14361
|
+
}
|
|
14362
|
+
function createAnalytics(config) {
|
|
14363
|
+
if (config.enabled === false) {
|
|
14364
|
+
return createNoopAnalytics();
|
|
14365
|
+
}
|
|
14366
|
+
const { app, env } = config;
|
|
14367
|
+
const preset = config.preset ?? (env === "production" ? "prod" : "dev");
|
|
14368
|
+
const sampleRate = config.sampleRate ?? 1;
|
|
14369
|
+
const batchSize = config.batchSize ?? 20;
|
|
14370
|
+
const flushIntervalMs = config.flushIntervalMs ?? 1e4;
|
|
14371
|
+
const session = createSession(config.session);
|
|
14372
|
+
const identity = createIdentity(config.identity);
|
|
14373
|
+
const consent = createConsent(config.consent);
|
|
14374
|
+
const redactor = createRedactor(config.redactKeys);
|
|
14375
|
+
const sinks = /* @__PURE__ */ new Map();
|
|
14376
|
+
const sinkOrder = [];
|
|
14377
|
+
const initialized = /* @__PURE__ */ new Set();
|
|
14378
|
+
function registerSink(sink) {
|
|
14379
|
+
if (!sinks.has(sink.name)) sinkOrder.push(sink.name);
|
|
14380
|
+
sinks.set(sink.name, sink);
|
|
14381
|
+
}
|
|
14382
|
+
if (config.endpoint) {
|
|
14383
|
+
registerSink(
|
|
14384
|
+
createHttpSink({
|
|
14385
|
+
endpoint: config.endpoint,
|
|
14386
|
+
writeKey: config.writeKey ?? ""
|
|
14387
|
+
})
|
|
14388
|
+
);
|
|
14389
|
+
}
|
|
14390
|
+
if (preset === "dev") {
|
|
14391
|
+
registerSink(createConsoleSink2());
|
|
14392
|
+
}
|
|
14393
|
+
for (const s of config.sinks ?? []) registerSink(s);
|
|
14394
|
+
function ensureInit(sink) {
|
|
14395
|
+
if (initialized.has(sink.name)) return;
|
|
14396
|
+
initialized.add(sink.name);
|
|
14397
|
+
if (sink.init) {
|
|
14398
|
+
return sink.init({ app, env, endpoint: config.endpoint });
|
|
14399
|
+
}
|
|
14400
|
+
}
|
|
14401
|
+
const buffer = [];
|
|
14402
|
+
let timer;
|
|
14403
|
+
function startTimer() {
|
|
14404
|
+
if (preset !== "prod" || timer) return;
|
|
14405
|
+
timer = setInterval(() => {
|
|
14406
|
+
void flush(false);
|
|
14407
|
+
}, flushIntervalMs);
|
|
14408
|
+
timer.unref?.();
|
|
14409
|
+
}
|
|
14410
|
+
function deliverToSinks(batch, unload) {
|
|
14411
|
+
if (batch.length === 0) return;
|
|
14412
|
+
const ctx = { unload };
|
|
14413
|
+
const pending = [];
|
|
14414
|
+
for (const name of sinkOrder) {
|
|
14415
|
+
const sink = sinks.get(name);
|
|
14416
|
+
if (!sink) continue;
|
|
14417
|
+
if (!consent.allows(sink.consentCategories)) continue;
|
|
14418
|
+
const inited = ensureInit(sink);
|
|
14419
|
+
if (inited && typeof inited.then === "function") {
|
|
14420
|
+
pending.push(
|
|
14421
|
+
inited.then(() => sink.deliver(batch, ctx))
|
|
14422
|
+
);
|
|
14423
|
+
} else {
|
|
14424
|
+
const r = sink.deliver(batch, ctx);
|
|
14425
|
+
if (r && typeof r.then === "function") {
|
|
14426
|
+
pending.push(r);
|
|
14427
|
+
}
|
|
14428
|
+
}
|
|
14429
|
+
}
|
|
14430
|
+
if (pending.length) return Promise.all(pending).then(() => void 0);
|
|
14431
|
+
}
|
|
14432
|
+
async function flush(unload = false) {
|
|
14433
|
+
const batch = buffer.splice(0, buffer.length);
|
|
14434
|
+
await deliverToSinks(batch, unload);
|
|
14435
|
+
for (const name of sinkOrder) {
|
|
14436
|
+
const sink = sinks.get(name);
|
|
14437
|
+
if (sink?.flush && consent.allows(sink.consentCategories)) {
|
|
14438
|
+
await sink.flush();
|
|
14439
|
+
}
|
|
14440
|
+
}
|
|
14441
|
+
}
|
|
14442
|
+
function bindUnload() {
|
|
14443
|
+
if (preset !== "prod") return;
|
|
14444
|
+
const g = globalThis;
|
|
14445
|
+
if (typeof g.addEventListener !== "function") return;
|
|
14446
|
+
const onUnload = () => {
|
|
14447
|
+
void deliverToSinks(buffer.splice(0, buffer.length), true);
|
|
14448
|
+
};
|
|
14449
|
+
g.addEventListener("pagehide", onUnload);
|
|
14450
|
+
g.addEventListener("visibilitychange", () => {
|
|
14451
|
+
if (g.document?.visibilityState === "hidden") onUnload();
|
|
14452
|
+
});
|
|
14453
|
+
}
|
|
14454
|
+
startTimer();
|
|
14455
|
+
bindUnload();
|
|
14456
|
+
function buildContext(extra, childCtx) {
|
|
14457
|
+
const page = readPage();
|
|
14458
|
+
return {
|
|
14459
|
+
app,
|
|
14460
|
+
env,
|
|
14461
|
+
...page ? { page } : {},
|
|
14462
|
+
...childCtx,
|
|
14463
|
+
...extra,
|
|
14464
|
+
library: LIBRARY
|
|
14465
|
+
};
|
|
14466
|
+
}
|
|
14467
|
+
function sampled() {
|
|
14468
|
+
if (sampleRate >= 1) return true;
|
|
14469
|
+
if (sampleRate <= 0) return false;
|
|
14470
|
+
return Math.random() < sampleRate;
|
|
14471
|
+
}
|
|
14472
|
+
function enqueue(ev) {
|
|
14473
|
+
if (preset === "dev") {
|
|
14474
|
+
void deliverToSinks([ev], false);
|
|
14475
|
+
return;
|
|
14476
|
+
}
|
|
14477
|
+
buffer.push(ev);
|
|
14478
|
+
if (buffer.length >= batchSize) {
|
|
14479
|
+
void flush(false);
|
|
14480
|
+
}
|
|
14481
|
+
}
|
|
14482
|
+
function emit(type, fields, childCtx, opts) {
|
|
14483
|
+
if (!sampled()) return;
|
|
14484
|
+
const page = readPage();
|
|
14485
|
+
const campaign = campaignFingerprint(page?.search);
|
|
14486
|
+
const sessionId = session.touch(campaign);
|
|
14487
|
+
const sessionProps = session.props();
|
|
14488
|
+
const ev = {
|
|
14489
|
+
type,
|
|
14490
|
+
messageId: uuidv4(),
|
|
14491
|
+
anonymousId: identity.anonymousId(),
|
|
14492
|
+
userId: identity.userId(),
|
|
14493
|
+
sessionId,
|
|
14494
|
+
context: buildContext(opts?.context, childCtx),
|
|
14495
|
+
timestamp: opts?.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
14496
|
+
schemaVersion: SCHEMA_VERSION,
|
|
14497
|
+
...fields
|
|
14498
|
+
};
|
|
14499
|
+
if (sessionProps && (ev.properties || type === "track" || type === "page" || type === "screen")) {
|
|
14500
|
+
ev.properties = { ...sessionProps, ...ev.properties ?? {} };
|
|
14501
|
+
}
|
|
14502
|
+
enqueue(ev);
|
|
14503
|
+
}
|
|
14504
|
+
function makeApi(childCtx) {
|
|
14505
|
+
const api = {
|
|
14506
|
+
track(event, properties, opts) {
|
|
14507
|
+
emit(
|
|
14508
|
+
"track",
|
|
14509
|
+
{ event, properties: redactor.redact(properties) },
|
|
14510
|
+
childCtx,
|
|
14511
|
+
opts
|
|
14512
|
+
);
|
|
14513
|
+
},
|
|
14514
|
+
identify(userId, traits, opts) {
|
|
14515
|
+
identity.setUserId(userId);
|
|
14516
|
+
emit("identify", { traits: redactor.redact(traits) }, childCtx, opts);
|
|
14517
|
+
},
|
|
14518
|
+
page(name, properties, opts) {
|
|
14519
|
+
emit(
|
|
14520
|
+
"page",
|
|
14521
|
+
{ event: name, properties: redactor.redact(properties) },
|
|
14522
|
+
childCtx,
|
|
14523
|
+
opts
|
|
14524
|
+
);
|
|
14525
|
+
},
|
|
14526
|
+
screen(name, properties, opts) {
|
|
14527
|
+
emit(
|
|
14528
|
+
"screen",
|
|
14529
|
+
{ event: name, properties: redactor.redact(properties) },
|
|
14530
|
+
childCtx,
|
|
14531
|
+
opts
|
|
14532
|
+
);
|
|
14533
|
+
},
|
|
14534
|
+
group(groupId, traits, opts) {
|
|
14535
|
+
emit(
|
|
14536
|
+
"group",
|
|
14537
|
+
{ groupId, traits: redactor.redact(traits) },
|
|
14538
|
+
childCtx,
|
|
14539
|
+
opts
|
|
14540
|
+
);
|
|
14541
|
+
},
|
|
14542
|
+
alias(userId, previousId, opts) {
|
|
14543
|
+
const stitch = identity.alias(userId, previousId);
|
|
14544
|
+
emit(
|
|
14545
|
+
"alias",
|
|
14546
|
+
{ userId: stitch.userId, previousId: stitch.previousId },
|
|
14547
|
+
childCtx,
|
|
14548
|
+
opts
|
|
14549
|
+
);
|
|
14550
|
+
},
|
|
14551
|
+
session: {
|
|
14552
|
+
id: () => session.id(),
|
|
14553
|
+
start: () => session.start(),
|
|
14554
|
+
end: () => session.end(),
|
|
14555
|
+
set: (props) => session.set(props)
|
|
14556
|
+
},
|
|
14557
|
+
consent: {
|
|
14558
|
+
grant: (...c) => consent.grant(...c),
|
|
14559
|
+
revoke: (...c) => consent.revoke(...c),
|
|
14560
|
+
granted: () => consent.granted(),
|
|
14561
|
+
isGranted: (c) => consent.isGranted(c)
|
|
14562
|
+
},
|
|
14563
|
+
anonymousId: () => identity.anonymousId(),
|
|
14564
|
+
userId: () => identity.userId(),
|
|
14565
|
+
with(extra) {
|
|
14566
|
+
return makeApi({ ...childCtx, ...extra });
|
|
14567
|
+
},
|
|
14568
|
+
addSink(sink) {
|
|
14569
|
+
registerSink(sink);
|
|
14570
|
+
},
|
|
14571
|
+
removeSink(name) {
|
|
14572
|
+
if (sinks.has(name)) {
|
|
14573
|
+
sinks.delete(name);
|
|
14574
|
+
const i = sinkOrder.indexOf(name);
|
|
14575
|
+
if (i !== -1) sinkOrder.splice(i, 1);
|
|
14576
|
+
initialized.delete(name);
|
|
14577
|
+
}
|
|
14578
|
+
},
|
|
14579
|
+
get sinks() {
|
|
14580
|
+
return [...sinkOrder];
|
|
14581
|
+
},
|
|
14582
|
+
async flush() {
|
|
14583
|
+
await flush(false);
|
|
14584
|
+
},
|
|
14585
|
+
reset() {
|
|
14586
|
+
identity.reset();
|
|
14587
|
+
session.end();
|
|
14588
|
+
},
|
|
14589
|
+
enabled: true
|
|
14590
|
+
};
|
|
14591
|
+
return api;
|
|
14592
|
+
}
|
|
14593
|
+
return makeApi();
|
|
14594
|
+
}
|
|
14595
|
+
|
|
14596
|
+
// ../react-analytics/dist/index.js
|
|
14597
|
+
var AnalyticsContext = React11.createContext(null);
|
|
14598
|
+
function AnalyticsProvider({ children, value }) {
|
|
14599
|
+
const analyticsRef = React11.useRef(null);
|
|
14600
|
+
if (!analyticsRef.current) {
|
|
14601
|
+
analyticsRef.current = value;
|
|
14602
|
+
}
|
|
14603
|
+
return React11.createElement(
|
|
14604
|
+
AnalyticsContext.Provider,
|
|
14605
|
+
{ value: analyticsRef.current },
|
|
14606
|
+
children
|
|
14607
|
+
);
|
|
14608
|
+
}
|
|
14609
|
+
function useAnalytics(options) {
|
|
14610
|
+
const ctx = React11.useContext(AnalyticsContext);
|
|
14611
|
+
if (!ctx) {
|
|
14612
|
+
devWarn(
|
|
14613
|
+
"react-analytics/use-analytics-outside-provider",
|
|
14614
|
+
"useAnalytics() was called outside an <AnalyticsProvider>. Wrap your app (or the consuming subtree) in <AnalyticsProvider> so the analytics context is available."
|
|
14615
|
+
);
|
|
14616
|
+
throw new Error("useAnalytics must be used within an <AnalyticsProvider>");
|
|
14617
|
+
}
|
|
14618
|
+
const scope = options?.scope;
|
|
14619
|
+
return React11.useMemo(
|
|
14620
|
+
() => scope ? ctx.with(scope) : ctx,
|
|
14621
|
+
[ctx, scope]
|
|
14622
|
+
);
|
|
14623
|
+
}
|
|
14624
|
+
function useTrackEvent(options) {
|
|
14625
|
+
const analytics = useAnalytics(options);
|
|
14626
|
+
return React11.useCallback(
|
|
14627
|
+
(event, properties, opts) => analytics.track(event, properties, opts),
|
|
14628
|
+
[analytics]
|
|
14629
|
+
);
|
|
14630
|
+
}
|
|
14631
|
+
|
|
14632
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AltHintState, AnalyticsProvider, AnimatedText, AppShell, AuthGuard, AuthProvider, Avatar, AvatarFallback, AvatarGroup, AvatarImage, Badge, BadgeDisplay, BottomNav, Breadcrumbs, Button, CATEGORY_LABELS, Calendar, CalendarHeader, Callout, CalloutContent, CalloutDescription, CalloutIcon, CalloutTitle, Card, CardContent, CardDescription, CardFooter, CardGrid, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselTrigger, Checkbox, CodeBlock, CodeBlockContent, CodeBlockHeader, CodeEditor, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, ComboboxTrigger, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, ContentProtection, DEFAULT_VOICE_PILL_POSITION, DEFAULT_VOICE_PILL_SPEAKER, DEFAULT_WAVEFORM_BAR_COUNT, DEFAULT_WAVEFORM_COLOR, DEFAULT_WAVEFORM_HEIGHT, DEFAULT_WAVEFORM_INTENSITY, DEFAULT_WAVEFORM_SMOOTHING, DataTable, DatePicker, DeviceFrame, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, EMOJI_CATEGORIES, EMOJI_DATA, EmojiPicker, FeedbackButton, FeedbackDialog, FileTree, FileUpload, Footer, IconSystem, InlineEditor, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupText, InstallPrompt, KeyboardShortcut, LanguageSelector, LinkCard, MarkdownRenderer, MobileNav, MobileNavContent, MobileNavLink, MobileNavTrigger, Navbar, OtpInput, STATUS_COLORS as PRESENCE_STATUS_COLORS, STATUS_LABELS as PRESENCE_STATUS_LABELS, Pagination, Payment, Popover, PopoverClose, PopoverContent, PopoverTrigger, PresenceIndicator, ProgressBar, RadioGroup, RadioItem, ReactionBar, ResizableDivider, ResizableLayout, ResizablePane, SANE_DEFAULTS, STATUS_INDICATOR_COLORS as STATUS_COLORS, STATUS_INDICATOR_LABELS as STATUS_LABELS, SearchBar, SearchResultItem, SearchResults, Select, SelectContent, SelectItem, SelectTrigger, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetTitle, SheetTrigger, ShortcutBadge, ShortcutContext, ShortcutHint, ShortcutProvider, ShortcutRegistry, Sidebar, Skeleton, SkeletonText, SkipToContent, SlideViewer, StatsGrid, StatusIndicator, Step, StepContent, StepDescription, StepIndicator, StepTitle, Steps, Switch, TableOfContents, Tabs, TabsContent, TabsList, TabsTrigger, TelemetryErrorBoundary, TelemetryProvider, Textarea, ThreadView, Toast, ToastProvider, Toaster, Tooltip, TooltipContent, TooltipTrigger, TypewriterText, VersionSelector, VideoPlayer, VoicePill, Waveform, altHintState, animatedTextVariants, avatarFallbackVariants, avatarImageVariants, avatarTokens, avatarVariants, badgeGridVariants, badgeItemVariants, badgeVariants, bottomNavTabVariants, bottomNavVariants, breadcrumbItemVariants, breadcrumbSeparatorStyles, breadcrumbsVariants, buttonTokens, buttonVariants, calendarVariants, canAccessAdmin, canAccessReviewer, cardContentVariants, cardDescriptionVariants, cardFooterVariants, cardHeaderVariants, cardTitleVariants, cardTokens, cardVariants, cellVariants, checkIconPath, checkboxTokens, checkboxVariants, clampVoicePillIntensity, codeEditorTokens, codeEditorVariants, collapsibleContentVariants, comboboxContentVariants, comboboxEmptyVariants, comboboxInputVariants, comboboxItemVariants, comboboxListVariants, comboboxTriggerVariants, commandGroupVariants, commandInputVariants, commandItemVariants, commandVariants, contentProtectionVariants, controlsVariants, createAnalytics, createIntensitySamples, createSilentSamples, createVoicePill, createWaveform, dayVariants, deviceFrameVariants, dialogContentVariants, drawWaveform, editorVariants, emojiPickerContainerStyles, emojiPickerEmojiButtonStyles, emojiPickerGridStyles, feedbackDialogVariants, fileUploadDropZoneVariants, fileUploadFileItemStyles, fileUploadFileListStyles, footerVariants, formatFileSize, formatRelativeTime, formatShortcut, formatTimestamp, getAssignableRoles, getDefaultPortal, getInitials, getVoicePillAriaLabel, getVoicePillInitials, getVoicePillPosition, getVoicePillPulseStyle, getVoicePillSpeakerKey, getVoicePillSpeakerLabel, getWaveformPeak, globalShortcutRegistry, hasAllRoles, hasAnyRole, hasRole, headerVariants, indeterminateIconPath, inputGroupAddonVariants, inputGroupButtonVariants, inputGroupTokens, inputGroupVariants, inputVariants, installPromptVariants, isWaveformSampleInput, latestBadgeVariants, markdownRendererTokens, menuContentVariants, menuItemVariants, mobileNavContentVariants, mobileNavLinkVariants, mobileNavTokens, mobileNavTriggerVariants, mobileNavVariants, navLinkVariants, navbarVariants, normalizeBarCount, normalizeIntensity, normalizeSmoothing, normalizeWaveformConfig, normalizeWaveformSamples, optionVariants, otpInputContainerVariants, otpInputSlotVariants, otpInputTokens, overlayStyles, overlayVariants, playerVariants, popoverContentVariants, prepareWaveformCanvas, previewVariants, progressBarVariants, proseVariants, radioCircleVariants, radioGroupVariants, radioItemVariants, reactionAddButtonStyles, reactionBarStyles, reactionCountStyles, reactionEmojiStyles, reactionPillVariants, resampleWaveformSamples, resizableDividerVariants, resizableLayoutTokens, resizableLayoutVariants, resizablePaneVariants, rowVariants, scaleWaveformSamples, searchBarVariants, searchResultVariants, selectContentVariants, selectItemVariants, selectTokens, selectTriggerVariants, selectorVariants, sheetContentVariants, sheetOverlayStyles, shortcutBadgeStyles, shortcutKeyStyles, shortcutSeparatorStyles, sidebarItemVariants, sidebarVariants, skeletonVariants, slideTypeBadgeVariants, slideViewerProgressBarVariants, slideViewerTokens, slideViewerVariants, smoothWaveformSamples, statCardVariants, statsGridVariants, statusContainerStyles, statusDotVariants, statusLabelStyles, statusPulseVariants, switchThumbVariants, switchTokens, switchVariants, tableVariants, tabsListVariants, tabsTriggerVariants, textareaVariants, threadAuthorStyles, threadAvatarStyles, threadBodyStyles, threadContainerStyles, threadContentStyles, threadMessageStyles, threadReactionsStyles, threadTimestampStyles, toCssDimension, toastVariants, toolbarVariants, tooltipContentVariants, typewriterVariants, useAnalytics, useAuth, useLogger, useShortcut, useSpan, useTelemetry, useToast, useTrackEvent, versionSelectorOptionVariants, versionSelectorVariants, voicePillAvatarStyles, voicePillAvatarWrapStyles, voicePillLabelStyles, voicePillMuteButtonStyles, voicePillPositionVariants, voicePillPulseRingStyles, voicePillRootStyles, voicePillSpeakerStyles, voicePillSubStyles, voicePillTextStyles, voicePillTokens, watermarkVariants, waveformCanvasVariants, waveformVariants };
|
|
13328
14633
|
//# sourceMappingURL=index.js.map
|
|
13329
14634
|
//# sourceMappingURL=index.js.map
|