@uniformdev/context-devtools 17.7.1-alpha.34 → 18.0.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/esm/index.js CHANGED
@@ -1,4 +1,160 @@
1
- import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}from"@emotion/react";import{Theme as sr}from"@uniformdev/design-system";import{computeDimensionDefinitionDisplayData as Nt,computeDimensionDisplayData as Ae,UncachedDimensionClient as Zt}from"@uniformdev/context/api";import*as Be from"react";import{useAsync as zt}from"react-use";function Qe({apiHost:e,apiKey:o,projectId:r},t){let{loading:n,error:s,value:l}=zt(async()=>{if(!o||!r)return d;let m=(await new Zt({projectId:r,apiKey:o,apiHost:e||void 0}).get()).dimensions,i={};return m.map(a=>{var c,v,u,f,C,w,k,q;if(i[a.dim]={...Nt(a),cap:a.cap,str:(f=(u=(v=(c=t==null?void 0:t.project.pz)==null?void 0:c.sig)==null?void 0:v[a.dim])==null?void 0:u.str)!=null?f:50},i[a.dim].type==="Enrichment"){let N=a.dim.split("_")[0];i[a.dim].cap=(q=(k=(w=(C=t==null?void 0:t.project.pz)==null?void 0:C.enr)==null?void 0:w[N])==null?void 0:k.cap)!=null?q:100}}),i},[e,o,r]),d=Be.useMemo(()=>{var m,i,a,c;let p={};return t&&(Object.entries((i=(m=t==null?void 0:t.project.pz)==null?void 0:m.sig)!=null?i:{}).map(([v,u])=>{let f=Ae(v,t);f&&(p[v]={...u,...f})}),Object.entries((c=(a=t==null?void 0:t.project.pz)==null?void 0:a.enr)!=null?c:{}).map(([v,u])=>{var w;let f=Ae(v,t),C={cap:(w=u.cap)!=null?w:100,str:10};f&&(p[v]={...f,cap:C.cap,str:C.str})}),l&&Object.entries(l).map(([v,u])=>{p[v]={...p[v],...u}})),p},[t,l]);return{loading:n,error:s,index:d}}import{UncachedQuirkClient as Ut}from"@uniformdev/context/api";import{useMemo as jt}from"react";import{useAsync as _t}from"react-use";function Fe({apiHost:e,apiKey:o,projectId:r},t){let{loading:n,error:s,value:l}=_t(async()=>{if(!o||!r)return{};let m=await new Ut({projectId:r,apiKey:o,apiHost:e||void 0}).get(),i={};return m.quirks.map(a=>{i[a.id]={...a,value:t[a.id]}}),i},[e,o,r]),d=jt(()=>{let p={};return Object.entries(t).map(([m,i])=>p[m]={value:i,id:m,name:m}),l&&Object.entries(l).map(([m,i])=>p[m]={...i,value:t[m]}),p},[t,l]);return{loading:n,error:s,index:d}}import{createContext as Gt,useContext as $t}from"react";import{jsx as Kt}from"@emotion/react/jsx-runtime";var qe=Gt({settings:{},saveSettings:()=>{}}),ce=()=>$t(qe),Ne=({children:e,settings:o,saveSettings:r})=>Kt(qe.Provider,{value:{settings:o,saveSettings:r},children:e});import{jsx as Wt}from"@emotion/react/jsx-runtime";function le(){return Wt("style",{children:`
1
+ // ../../scripts/emotion-jsx-shim.js
2
+ import { jsx } from "@emotion/react";
3
+ import * as React from "react";
4
+
5
+ // src/components/ContextDevTools.tsx
6
+ import { css as css12 } from "@emotion/react";
7
+ import { Theme as DesignSystemTheme } from "@uniformdev/design-system";
8
+
9
+ // src/hooks/useDimensionIndex.ts
10
+ import {
11
+ computeDimensionDefinitionDisplayData,
12
+ computeDimensionDisplayData,
13
+ UncachedDimensionClient
14
+ } from "@uniformdev/context/api";
15
+ import * as React2 from "react";
16
+ import { useAsync } from "react-use";
17
+ function useDimensionIndex({ apiHost, apiKey, projectId }, manifest) {
18
+ const { loading, error, value } = useAsync(async () => {
19
+ if (!apiKey || !projectId) {
20
+ return manifestData;
21
+ }
22
+ const client = new UncachedDimensionClient({
23
+ projectId,
24
+ apiKey,
25
+ apiHost: apiHost ? apiHost : void 0
26
+ });
27
+ const dimensions = (await client.get()).dimensions;
28
+ const result = {};
29
+ dimensions.map((dimension) => {
30
+ var _a, _b, _c, _d, _e, _f, _g, _h;
31
+ result[dimension.dim] = {
32
+ ...computeDimensionDefinitionDisplayData(dimension),
33
+ cap: dimension.cap,
34
+ str: (_d = (_c = (_b = (_a = manifest == null ? void 0 : manifest.project.pz) == null ? void 0 : _a.sig) == null ? void 0 : _b[dimension.dim]) == null ? void 0 : _c.str) != null ? _d : 50
35
+ };
36
+ if (result[dimension.dim].type === "Enrichment") {
37
+ const enrId = dimension.dim.split("_")[0];
38
+ result[dimension.dim].cap = (_h = (_g = (_f = (_e = manifest == null ? void 0 : manifest.project.pz) == null ? void 0 : _e.enr) == null ? void 0 : _f[enrId]) == null ? void 0 : _g.cap) != null ? _h : 100;
39
+ }
40
+ });
41
+ return result;
42
+ }, [apiHost, apiKey, projectId]);
43
+ const manifestData = React2.useMemo(() => {
44
+ var _a, _b, _c, _d;
45
+ const data = {};
46
+ if (!manifest) {
47
+ return data;
48
+ }
49
+ Object.entries((_b = (_a = manifest == null ? void 0 : manifest.project.pz) == null ? void 0 : _a.sig) != null ? _b : {}).map(([dimensionId, dimension]) => {
50
+ const dim = computeDimensionDisplayData(dimensionId, manifest);
51
+ if (dim) {
52
+ data[dimensionId] = { ...dimension, ...dim };
53
+ }
54
+ });
55
+ Object.entries((_d = (_c = manifest == null ? void 0 : manifest.project.pz) == null ? void 0 : _c.enr) != null ? _d : {}).map(([dimensionId, enr]) => {
56
+ var _a2;
57
+ const dim = computeDimensionDisplayData(dimensionId, manifest);
58
+ const signal = { cap: (_a2 = enr.cap) != null ? _a2 : 100, str: 10 };
59
+ if (dim) {
60
+ data[dimensionId] = { ...dim, cap: signal.cap, str: signal.str };
61
+ }
62
+ });
63
+ if (value) {
64
+ Object.entries(value).map(([dimensionId, dimension]) => {
65
+ data[dimensionId] = {
66
+ ...data[dimensionId],
67
+ ...dimension
68
+ };
69
+ });
70
+ }
71
+ return data;
72
+ }, [manifest, value]);
73
+ return {
74
+ loading,
75
+ error,
76
+ index: manifestData
77
+ };
78
+ }
79
+
80
+ // src/hooks/useQuirkIndex.ts
81
+ import { UncachedQuirkClient } from "@uniformdev/context/api";
82
+ import { useMemo as useMemo2 } from "react";
83
+ import { useAsync as useAsync2 } from "react-use";
84
+ function useQuirkIndex({ apiHost, apiKey, projectId }, quirksData) {
85
+ const { loading, error, value } = useAsync2(async () => {
86
+ if (!apiKey || !projectId) {
87
+ return {};
88
+ }
89
+ const client = new UncachedQuirkClient({
90
+ projectId,
91
+ apiKey,
92
+ apiHost: apiHost ? apiHost : void 0
93
+ });
94
+ const quirksResponse = await client.get();
95
+ const quirksIndexData = {};
96
+ quirksResponse.quirks.map((quirkData) => {
97
+ quirksIndexData[quirkData.id] = { ...quirkData, value: quirksData[quirkData.id] };
98
+ });
99
+ return quirksIndexData;
100
+ }, [apiHost, apiKey, projectId]);
101
+ const contextStateQuirkData = useMemo2(() => {
102
+ const data = {};
103
+ Object.entries(quirksData).map(
104
+ ([quirkId, queryrValue]) => data[quirkId] = {
105
+ value: queryrValue,
106
+ id: quirkId,
107
+ name: quirkId
108
+ }
109
+ );
110
+ if (value) {
111
+ Object.entries(value).map(
112
+ ([quirkId, quirkValue]) => data[quirkId] = {
113
+ ...quirkValue,
114
+ value: quirksData[quirkId]
115
+ }
116
+ );
117
+ }
118
+ return data;
119
+ }, [quirksData, value]);
120
+ return {
121
+ loading,
122
+ error,
123
+ index: contextStateQuirkData
124
+ };
125
+ }
126
+
127
+ // src/lib/DevToolsSettingsContext.tsx
128
+ import { createContext, useContext } from "react";
129
+ import { jsx as jsx2 } from "@emotion/react/jsx-runtime";
130
+ var DevToolsSettingsContext = createContext({
131
+ settings: {},
132
+ saveSettings: () => {
133
+ return;
134
+ }
135
+ });
136
+ var useDevToolsSettingsContext = () => useContext(DevToolsSettingsContext);
137
+ var DevToolsSettingsContextProvider = ({
138
+ children,
139
+ settings,
140
+ saveSettings
141
+ }) => {
142
+ return /* @__PURE__ */ jsx2(
143
+ DevToolsSettingsContext.Provider,
144
+ {
145
+ value: {
146
+ settings,
147
+ saveSettings
148
+ },
149
+ children
150
+ }
151
+ );
152
+ };
153
+
154
+ // src/utils/Theme.tsx
155
+ import { jsx as jsx3 } from "@emotion/react/jsx-runtime";
156
+ function Theme() {
157
+ return /* @__PURE__ */ jsx3("style", { children: `
2
158
  :root {
3
159
  --site-width: 700px;
4
160
 
@@ -8,7 +164,15 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
8
164
 
9
165
  --min-height: 450px;
10
166
  }
11
- `})}import{Button as Ue}from"@uniformdev/design-system";import{css as j}from"@emotion/react";var de=j`
167
+ ` });
168
+ }
169
+
170
+ // src/components/CallToAction/ConnectApiKey.tsx
171
+ import { Button } from "@uniformdev/design-system";
172
+
173
+ // src/components/CallToAction/cta.styles.ts
174
+ import { css } from "@emotion/react";
175
+ var cta = css`
12
176
  background-color: var(--gray-100);
13
177
  padding: var(--spacing-base) var(--spacing-md);
14
178
  margin: var(--spacing-base) 0;
@@ -16,21 +180,25 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
16
180
  &:first-of-type {
17
181
  margin: 0 0 var(--spacing-base);
18
182
  }
19
- `,Ze=j`
183
+ `;
184
+ var ctaWithIcon = css`
20
185
  background: var(--gray-100)
21
186
  url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%0A%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M9 2C8.44771 2 8 2.44772 8 3V5C8 5.55228 8.44771 6 9 6C9.55229 6 10 5.55228 10 5V3C10 2.44772 9.55229 2 9 2ZM8 9H16V11C16 13.2091 14.2091 15 12 15C9.79086 15 8 13.2091 8 11V9ZM13 16.917C15.8377 16.441 18 13.973 18 11V7H6V11C6 13.973 8.16229 16.441 11 16.917V22C11 22.5523 11.4477 23 12 23C12.5523 23 13 22.5523 13 22V16.917ZM14 3C14 2.44772 14.4477 2 15 2C15.5523 2 16 2.44772 16 3V5C16 5.55228 15.5523 6 15 6C14.4477 6 14 5.55228 14 5V3Z' fill='%232ecdb4' /%3E%3C/svg%3E")
22
187
  no-repeat var(--spacing-sm) var(--spacing-base);
23
188
  padding: var(--spacing-base) var(--spacing-xl);
24
- `,pe=j`
189
+ `;
190
+ var ctaTitle = css`
25
191
  color: var(--brand-secondary-1);
26
192
  margin: 0;
27
193
  font-size: var(--fs-base);
28
194
  font-weight: var(--fw-bold);
29
- `,me=j`
195
+ `;
196
+ var ctaText = css`
30
197
  color: var(--brand-secondary-1);
31
198
  margin: var(--spacing-xs) 0 0;
32
199
  font-size: var(--fs-sm);
33
- `,ze=j`
200
+ `;
201
+ var ctaClose = css`
34
202
  align-items: center;
35
203
  border: none;
36
204
  background: transparent
@@ -50,17 +218,86 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
50
218
  &:hover {
51
219
  opacity: 0.6;
52
220
  }
53
- `,ue=j`
221
+ `;
222
+ var ctaBtnGroup = css`
54
223
  display: flex;
55
224
  margin: var(--spacing-sm) 0 0;
56
225
  gap: var(--spacing-base);
57
- `;import{jsx as _,jsxs as je}from"@emotion/react/jsx-runtime";var Se=({settings:e,saveSettings:o})=>{let r=()=>{o({...e,route:"/connect"})},t=()=>{o({...e,ignoreApiKeyPrompt:!0})},n=e.route==="/connect",s=!(e!=null&&e.apiKey);return!e.ignoreApiKeyPrompt&&s&&!n?je("div",{css:[de,Ze],children:[_("h2",{css:pe,children:"Connect to a Uniform Project"}),_("p",{css:me,children:"This allows reading human-readable labels for the dimensions."}),je("div",{css:ue,children:[_(Ue,{buttonType:"secondary",onClick:r,children:"Connect this site"}),_(Ue,{buttonType:"ghost",onClick:t,children:"Skip for now"})]}),_("button",{type:"button",css:ze,title:"close",onClick:t,children:_("span",{hidden:!0,children:"Close"})})]}):null};import{css as V}from"@emotion/react";import{css as Yt}from"@emotion/react";import{jsx as Jt}from"@emotion/react/jsx-runtime";var _e=()=>{var r;let e=typeof chrome!="undefined"&&typeof chrome.storage!="undefined"&&((r=chrome==null?void 0:chrome.runtime)==null?void 0:r.getManifest()),o=e?e==null?void 0:e.version:"DEV";return Jt("div",{css:Yt`
226
+ `;
227
+
228
+ // src/components/CallToAction/ConnectApiKey.tsx
229
+ import { jsx as jsx4, jsxs } from "@emotion/react/jsx-runtime";
230
+ var ConnectApiKey = ({ settings, saveSettings }) => {
231
+ const handleRedirect = () => {
232
+ saveSettings({ ...settings, route: "/connect" });
233
+ };
234
+ const dismissPrompt = () => {
235
+ saveSettings({ ...settings, ignoreApiKeyPrompt: true });
236
+ };
237
+ const isOnConnect = settings.route === "/connect";
238
+ const missingApiKey = !(settings == null ? void 0 : settings.apiKey);
239
+ return !settings.ignoreApiKeyPrompt && missingApiKey && !isOnConnect ? /* @__PURE__ */ jsxs("div", { css: [cta, ctaWithIcon], children: [
240
+ /* @__PURE__ */ jsx4("h2", { css: ctaTitle, children: "Connect to a Uniform Project" }),
241
+ /* @__PURE__ */ jsx4("p", { css: ctaText, children: "This allows reading human-readable labels for the dimensions." }),
242
+ /* @__PURE__ */ jsxs("div", { css: ctaBtnGroup, children: [
243
+ /* @__PURE__ */ jsx4(Button, { buttonType: "secondary", onClick: handleRedirect, children: "Connect this site" }),
244
+ /* @__PURE__ */ jsx4(Button, { buttonType: "ghost", onClick: dismissPrompt, children: "Skip for now" })
245
+ ] }),
246
+ /* @__PURE__ */ jsx4("button", { type: "button", css: ctaClose, title: "close", onClick: dismissPrompt, children: /* @__PURE__ */ jsx4("span", { hidden: true, children: "Close" }) })
247
+ ] }) : null;
248
+ };
249
+
250
+ // src/components/Navigation/Menu.tsx
251
+ import { css as css3 } from "@emotion/react";
252
+
253
+ // src/components/ExtensionVersion.tsx
254
+ import { css as css2 } from "@emotion/react";
255
+ import { jsx as jsx5 } from "@emotion/react/jsx-runtime";
256
+ var ExtensionVersion = () => {
257
+ var _a;
258
+ const manifestData = typeof chrome !== "undefined" && typeof chrome.storage !== "undefined" && ((_a = chrome == null ? void 0 : chrome.runtime) == null ? void 0 : _a.getManifest());
259
+ const extensionVersion = manifestData ? manifestData == null ? void 0 : manifestData.version : "DEV";
260
+ return /* @__PURE__ */ jsx5(
261
+ "div",
262
+ {
263
+ css: css2`
58
264
  font-size: var(--fs-sm);
59
265
  color: var(--gray-400);
60
266
  position: absolute;
61
267
  bottom: 2px;
62
268
  right: 5px;
63
- `,children:`v${o}`})};import{jsx as eo}from"@emotion/react/jsx-runtime";var Xt=({route:e,children:o,className:r})=>{let{settings:t,saveSettings:n}=ce();return eo("a",{href:"",className:r,onClick:s=>{s.preventDefault(),n({...t,route:e})},children:o})},G=Xt;import{jsx as T,jsxs as re}from"@emotion/react/jsx-runtime";var to=[{title:"Dimensions",href:"/dimensions",icon:`<svg
269
+ `,
270
+ children: `v${extensionVersion}`
271
+ }
272
+ );
273
+ };
274
+
275
+ // src/components/Navigation/NavigationLink.tsx
276
+ import { jsx as jsx6 } from "@emotion/react/jsx-runtime";
277
+ var NavigationLink = ({ route, children, className }) => {
278
+ const { settings, saveSettings } = useDevToolsSettingsContext();
279
+ return /* @__PURE__ */ jsx6(
280
+ "a",
281
+ {
282
+ href: "",
283
+ className,
284
+ onClick: (e) => {
285
+ e.preventDefault();
286
+ saveSettings({ ...settings, route });
287
+ },
288
+ children
289
+ }
290
+ );
291
+ };
292
+ var NavigationLink_default = NavigationLink;
293
+
294
+ // src/components/Navigation/Menu.tsx
295
+ import { jsx as jsx7, jsxs as jsxs2 } from "@emotion/react/jsx-runtime";
296
+ var links = [
297
+ {
298
+ title: "Dimensions",
299
+ href: "/dimensions",
300
+ icon: `<svg
64
301
  width="24"
65
302
  height="24"
66
303
  viewBox="0 0 24 24"
@@ -77,10 +314,20 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
77
314
  fill="currentColor"
78
315
  />
79
316
  </svg>
80
- `},{title:"What if?",href:"/overrides",icon:`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
317
+ `
318
+ },
319
+ {
320
+ title: "What if?",
321
+ href: "/overrides",
322
+ icon: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
81
323
  <path fill-rule="evenodd" clip-rule="evenodd" d="M16.5123 7.91666L14.5804 8.4343L13.9179 5.96175L11.3371 10.0021L11.3575 10.0143C11.1348 10.3854 10.8997 10.7125 10.6556 11.0003H18.7603L16.9135 9.15347L18.3277 7.73926L22.5703 11.9819L18.3276 16.2245L16.9134 14.8103L18.7235 13.0003H6.65606C6.89995 13.2879 7.13495 13.6148 7.35749 13.9857L7.33713 13.9979L9.9179 18.0382L10.5804 15.5657L12.5123 16.0833L10.9594 21.8789L5.16384 20.326L5.68147 18.3941L8.20425 19.0701C8.20425 19.0701 6.17064 16.0325 5.21659 14.398C4.70173 13.7544 4.17055 13.4257 3.70352 13.2461C3.10532 13.016 2.54358 13.0011 2.06154 13.0003H2V13.0002V11.0003V11.0002L2.02253 11.0002C2.05059 11.0002 2.07985 11.0002 2.11025 11.0003H6V10.9998C6.49549 10.9998 7.07968 10.9939 7.70352 10.7539C8.17055 10.5743 8.70173 10.2456 9.21659 9.60198C10.1706 7.96745 12.2043 4.92988 12.2043 4.92988L9.68147 5.60586L9.16384 3.67401L14.9594 2.12109L16.5123 7.91666Z" fill="white"/>
82
324
  </svg>
83
- `},{title:"Quirks",href:"/quirks",icon:`<svg
325
+ `
326
+ },
327
+ {
328
+ title: "Quirks",
329
+ href: "/quirks",
330
+ icon: `<svg
84
331
  width="24"
85
332
  height="24"
86
333
  viewBox="0 0 24 24"
@@ -95,32 +342,124 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
95
342
  d="M12 8.5C10.067 8.5 8.5 10.067 8.5 12C8.5 13.933 10.067 15.5 12 15.5C13.933 15.5 15.5 13.933 15.5 12C15.5 10.067 13.933 8.5 12 8.5Z"
96
343
  fill="currentColor"
97
344
  />
98
- </svg>`},{title:"Settings",href:"/settings",icon:`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
345
+ </svg>`
346
+ },
347
+ {
348
+ title: "Settings",
349
+ href: "/settings",
350
+ icon: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
99
351
  <path d="M19.1469 12.716C19.1986 12.2636 19.201 11.8069 19.1539 11.354L21.7429 9.474C21.8681 9.3822 21.9548 9.24723 21.9862 9.0952C22.0176 8.94316 21.9915 8.78489 21.9129 8.651L19.9939 5.399C19.9182 5.26986 19.7985 5.17231 19.6568 5.1242C19.515 5.07608 19.3606 5.08063 19.2219 5.137L16.3599 6.292C15.9237 5.9578 15.4502 5.67525 14.9489 5.45L14.5739 2.545C14.5547 2.39441 14.4813 2.25598 14.3673 2.15566C14.2534 2.05534 14.1068 1.99999 13.9549 2H10.0859C9.93402 1.99997 9.78728 2.05527 9.67317 2.15558C9.55906 2.25588 9.48539 2.39432 9.46595 2.545L9.09395 5.433C8.63957 5.63249 8.20723 5.87882 7.80395 6.168L5.00895 4.954C4.87173 4.89484 4.71787 4.88672 4.57519 4.9311C4.4325 4.97549 4.3104 5.06945 4.23095 5.196L2.22195 8.398C2.1396 8.52998 2.10934 8.68789 2.13707 8.84096C2.1648 8.99403 2.24854 9.1313 2.37195 9.226L4.86795 11.142C4.83172 11.4266 4.81302 11.7131 4.81195 12C4.81195 12.18 4.82095 12.362 4.83795 12.558L2.26495 14.375C2.13766 14.4647 2.04844 14.5987 2.01478 14.7508C1.98112 14.9028 2.00543 15.0619 2.08295 15.197L3.95695 18.474C4.11095 18.742 4.43695 18.857 4.72595 18.746L7.56095 17.644C8.00795 17.997 8.49195 18.294 9.00795 18.53L9.33795 21.396C9.37495 21.709 9.63795 21.946 9.95195 21.95L13.8169 22H13.8249C14.1349 22 14.3989 21.771 14.4439 21.463L14.8549 18.59C15.3703 18.3674 15.8579 18.0855 16.3079 17.75L19.1279 18.93C19.4129 19.05 19.7419 18.944 19.9029 18.679L21.8669 15.452C21.9477 15.319 21.976 15.1608 21.9464 15.0081C21.9168 14.8554 21.8315 14.7192 21.7069 14.626L19.1469 12.716ZM11.9999 15C10.3459 15 8.99995 13.655 8.99995 12C8.99995 10.346 10.3449 9 11.9999 9C13.6539 9 14.9999 10.345 14.9999 12C14.9999 13.654 13.6539 15 11.9999 15Z" fill="white"/>
100
352
  </svg>
101
- `}],oo=`<svg width="24" height="24" fill="white" viewBox="0 0 122.88 116.67" xmlns="http://www.w3.org/2000/svg">
353
+ `
354
+ }
355
+ ];
356
+ var googleChromeExtensionSvg = `<svg width="24" height="24" fill="white" viewBox="0 0 122.88 116.67" xmlns="http://www.w3.org/2000/svg">
102
357
  <g>
103
358
  <path d="M84.55,116.66c2.49,0,4.53-1.99,4.53-4.41V88.08c1.55-13.03,7.27-9.16,14-5.13 c16.27,9.74,27.08-15.88,13.93-23.78c-10.32-6.2-14.79,4.46-22.35,3.36c-2.92-0.43-4.95-3.5-5.59-8.17V36.9 c0-2.43-2.04-4.41-4.53-4.41H63.73c-17.18-2.12-1.93-11.37-1.93-19.98C61.81,5.6,55.38,0,47.45,0c-7.92,0-15.19,5.6-15.19,12.51 c0,8.12,15.78,17.86-1.64,19.98H4.53C2.04,32.49,0,34.47,0,36.9v17.42c1.33,7.43,6.49,9.15,13.1,4.25 c2.23-1.66,5.99-3.59,8.71-3.59c7.09,0,12.85,6.25,12.85,13.96S28.91,84.6,21.81,84.6c-2.53,0-4.89-0.8-6.89-2.19 c0,0.59-12.4-10.85-14.92,3.15v26.71c0,2.43,2.04,4.41,4.53,4.41c13.97,0,27.92,0,41.88-0.01c0.55-2.55-1.24-5.47-2.92-8 c-13.22-19.93,38.21-21.92,24.99,0.62c-0.65,1.11-1.3,2.19-1.8,3.24c-0.63,1.31-1.05,2.91-0.96,4.14L84.55,116.66L84.55,116.66z"></path>
104
359
  </g>
105
- </svg>`,Ge=({...e})=>{var t,n;let o=s=>{var d;let l="active";return!((d=e.settings)!=null&&d.route)&&s==="/dimensions"||e.settings.route===s?l:""},r=Boolean(typeof window!="undefined"&&((n=(t=window.chrome)==null?void 0:t.runtime)==null?void 0:n.id));return re("nav",{css:V`
360
+ </svg>`;
361
+ var Menu = ({ ...props }) => {
362
+ var _a, _b;
363
+ const isActivePath = (href) => {
364
+ var _a2;
365
+ const cssName = "active";
366
+ if (!((_a2 = props.settings) == null ? void 0 : _a2.route) && href === "/dimensions") {
367
+ return cssName;
368
+ }
369
+ return props.settings.route === href ? cssName : "";
370
+ };
371
+ const isChromeExtension = Boolean(typeof window !== "undefined" && ((_b = (_a = window.chrome) == null ? void 0 : _a.runtime) == null ? void 0 : _b.id));
372
+ return /* @__PURE__ */ jsxs2(
373
+ "nav",
374
+ {
375
+ css: css3`
106
376
  background: var(--brand-secondary-1);
107
377
  padding: var(--spacing-base) var(--spacing-base) var(--spacing-md);
108
378
  min-width: 200px;
109
379
  display: flex;
110
380
  flex-direction: column;
111
381
  position: relative;
112
- `,children:[T("a",{css:V`
382
+ `,
383
+ children: [
384
+ /* @__PURE__ */ jsx7(
385
+ "a",
386
+ {
387
+ css: css3`
113
388
  flex-grow: 0;
114
389
  display: inline-block;
115
390
  margin: 0 var(--spacing-base);
116
- `,href:"https://uniform.dev/",children:re("svg",{css:{display:"block"},width:"120",height:"38",viewBox:"0 0 120 38",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[re("g",{clipPath:"url(#clip0_41_612)",children:[T("path",{d:"M8.82261 3.73315L0 8.82209V18.9999L8.82261 13.911L17.6474 8.82209L8.82261 3.73315Z",fill:"#83C6E1"}),T("path",{d:"M8.82261 24.089V13.9111L0 19.0001V29.1779L8.82261 34.2669L17.6474 29.1779V19.0001L8.82261 24.089Z",fill:"#438FD5"}),T("path",{d:"M17.6474 8.82202L8.82263 13.911L17.6474 18.9999V29.1777L26.47 24.0888V13.911L17.6474 8.82202Z",fill:"#F4220B"}),T("path",{d:"M64.6069 13.9025H67.8036V25.5528H64.6069V13.9025ZM64.4902 8.5415H67.9181V11.7348H64.4902V8.5415ZM72.5153 10.1025V13.9025H70.3691V16.6272H72.5153V25.5528H75.7119V16.6272H78.2774V13.9025H75.7119V11.2684H78.2774V8.5415H75.2213L72.5153 10.1025ZM83.1059 13.7859L80.3999 15.3469V24.1084L83.1059 25.6694H88.0748L90.7808 24.1084V15.3469L88.0748 13.7859H83.1059ZM87.5842 22.9425H83.5943V16.5106H87.5842V22.9425ZM97.4723 14.8611L95.8103 13.9025H94.2779V25.5528H97.4745V16.6272H101.486V13.9025H99.1344L97.4723 14.8611ZM55.713 13.7859L53.8499 14.8611L51.9847 13.7859H50.7289V25.5528H53.9256V16.5106H57.9133V25.5528H61.1099V15.3469L58.4039 13.7859H55.713ZM44.0353 22.9425H40.0454V13.9025H36.851V24.1084L39.557 25.6694H42.3753L44.0309 24.7129L44.0331 24.7151L44.0353 24.7129V24.7151L45.6887 25.6694H47.2297V13.9025H44.0353V22.9425ZM117.51 13.7859H115.271L113.079 15.0425L110.909 13.7859H108.67L107.015 14.7402L105.359 13.7859H103.818V25.5528H107.015V16.5106H110.421V25.5528H113.615V16.5106H117.022V25.5528H120.216V15.3469L117.51 13.7859Z",fill:"white"})]}),T("defs",{children:T("clipPath",{id:"clip0_41_612",children:T("rect",{width:"120",height:"38",fill:"white"})})})]})}),T("ul",{css:V`
391
+ `,
392
+ href: "https://uniform.dev/",
393
+ children: /* @__PURE__ */ jsxs2(
394
+ "svg",
395
+ {
396
+ css: { display: "block" },
397
+ width: "120",
398
+ height: "38",
399
+ viewBox: "0 0 120 38",
400
+ fill: "none",
401
+ xmlns: "http://www.w3.org/2000/svg",
402
+ children: [
403
+ /* @__PURE__ */ jsxs2("g", { clipPath: "url(#clip0_41_612)", children: [
404
+ /* @__PURE__ */ jsx7(
405
+ "path",
406
+ {
407
+ d: "M8.82261 3.73315L0 8.82209V18.9999L8.82261 13.911L17.6474 8.82209L8.82261 3.73315Z",
408
+ fill: "#83C6E1"
409
+ }
410
+ ),
411
+ /* @__PURE__ */ jsx7(
412
+ "path",
413
+ {
414
+ d: "M8.82261 24.089V13.9111L0 19.0001V29.1779L8.82261 34.2669L17.6474 29.1779V19.0001L8.82261 24.089Z",
415
+ fill: "#438FD5"
416
+ }
417
+ ),
418
+ /* @__PURE__ */ jsx7(
419
+ "path",
420
+ {
421
+ d: "M17.6474 8.82202L8.82263 13.911L17.6474 18.9999V29.1777L26.47 24.0888V13.911L17.6474 8.82202Z",
422
+ fill: "#F4220B"
423
+ }
424
+ ),
425
+ /* @__PURE__ */ jsx7(
426
+ "path",
427
+ {
428
+ d: "M64.6069 13.9025H67.8036V25.5528H64.6069V13.9025ZM64.4902 8.5415H67.9181V11.7348H64.4902V8.5415ZM72.5153 10.1025V13.9025H70.3691V16.6272H72.5153V25.5528H75.7119V16.6272H78.2774V13.9025H75.7119V11.2684H78.2774V8.5415H75.2213L72.5153 10.1025ZM83.1059 13.7859L80.3999 15.3469V24.1084L83.1059 25.6694H88.0748L90.7808 24.1084V15.3469L88.0748 13.7859H83.1059ZM87.5842 22.9425H83.5943V16.5106H87.5842V22.9425ZM97.4723 14.8611L95.8103 13.9025H94.2779V25.5528H97.4745V16.6272H101.486V13.9025H99.1344L97.4723 14.8611ZM55.713 13.7859L53.8499 14.8611L51.9847 13.7859H50.7289V25.5528H53.9256V16.5106H57.9133V25.5528H61.1099V15.3469L58.4039 13.7859H55.713ZM44.0353 22.9425H40.0454V13.9025H36.851V24.1084L39.557 25.6694H42.3753L44.0309 24.7129L44.0331 24.7151L44.0353 24.7129V24.7151L45.6887 25.6694H47.2297V13.9025H44.0353V22.9425ZM117.51 13.7859H115.271L113.079 15.0425L110.909 13.7859H108.67L107.015 14.7402L105.359 13.7859H103.818V25.5528H107.015V16.5106H110.421V25.5528H113.615V16.5106H117.022V25.5528H120.216V15.3469L117.51 13.7859Z",
429
+ fill: "white"
430
+ }
431
+ )
432
+ ] }),
433
+ /* @__PURE__ */ jsx7("defs", { children: /* @__PURE__ */ jsx7("clipPath", { id: "clip0_41_612", children: /* @__PURE__ */ jsx7("rect", { width: "120", height: "38", fill: "white" }) }) })
434
+ ]
435
+ }
436
+ )
437
+ }
438
+ ),
439
+ /* @__PURE__ */ jsx7(
440
+ "ul",
441
+ {
442
+ css: css3`
117
443
  display: flex;
118
444
  flex-flow: column nowrap;
119
445
  padding: 0;
120
446
  margin: 0;
121
447
  list-style-type: none;
122
448
  flex-grow: 1;
123
- `,children:to.map((s,l)=>{var p,m,i,a;let d=0;return s.href==="/overrides"&&Object.keys((p=e.settings.scoreOverrides)!=null?p:{}).length>0&&(d=Object.keys((m=e.settings.scoreOverrides)!=null?m:{}).length),s.href==="/quirks"&&Object.keys((i=e.settings.quirkOverrides)!=null?i:{}).length>0&&(d=Object.keys((a=e.settings.quirkOverrides)!=null?a:{}).length),T("li",{css:V`
449
+ `,
450
+ children: links.map((item, index) => {
451
+ var _a2, _b2, _c, _d;
452
+ let overrideCount = 0;
453
+ if (item.href === "/overrides" && Object.keys((_a2 = props.settings.scoreOverrides) != null ? _a2 : {}).length > 0) {
454
+ overrideCount = Object.keys((_b2 = props.settings.scoreOverrides) != null ? _b2 : {}).length;
455
+ }
456
+ if (item.href === "/quirks" && Object.keys((_c = props.settings.quirkOverrides) != null ? _c : {}).length > 0) {
457
+ overrideCount = Object.keys((_d = props.settings.quirkOverrides) != null ? _d : {}).length;
458
+ }
459
+ return /* @__PURE__ */ jsx7(
460
+ "li",
461
+ {
462
+ css: css3`
124
463
  padding: 0;
125
464
  margin: 0;
126
465
  list-style-type: none;
@@ -128,7 +467,11 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
128
467
  &:last-of-type {
129
468
  margin-top: auto;
130
469
  }
131
- `,children:re(G,{css:V`
470
+ `,
471
+ children: /* @__PURE__ */ jsxs2(
472
+ NavigationLink_default,
473
+ {
474
+ css: css3`
132
475
  align-items: center;
133
476
  border-radius: var(--rounded-base);
134
477
  display: flex;
@@ -142,10 +485,25 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
142
485
  &.active {
143
486
  background: var(--gray-700);
144
487
  }
145
- `,className:o(s.href),route:s.href,children:[T("i",{css:V`
488
+ `,
489
+ className: isActivePath(item.href),
490
+ route: item.href,
491
+ children: [
492
+ /* @__PURE__ */ jsx7(
493
+ "i",
494
+ {
495
+ css: css3`
146
496
  align-items: center;
147
497
  display: flex;
148
- `,dangerouslySetInnerHTML:{__html:s.icon}}),s.title,d?T("span",{css:V`
498
+ `,
499
+ dangerouslySetInnerHTML: { __html: item.icon }
500
+ }
501
+ ),
502
+ item.title,
503
+ overrideCount ? /* @__PURE__ */ jsx7(
504
+ "span",
505
+ {
506
+ css: css3`
149
507
  font-size: var(--fs-xxs);
150
508
  display: inline-block;
151
509
  width: 12px;
@@ -154,7 +512,25 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
154
512
  background-color: var(--red-tooltip);
155
513
  text-align: center;
156
514
  line-height: 12px;
157
- `,children:d}):null]})},l)})}),!r&&re("a",{target:"_blank",href:"https://chrome.google.com/webstore/detail/uniform-context/dcmlokofjljnfjcknpmhjocogllfbhkg",css:V`
515
+ `,
516
+ children: overrideCount
517
+ }
518
+ ) : null
519
+ ]
520
+ }
521
+ )
522
+ },
523
+ index
524
+ );
525
+ })
526
+ }
527
+ ),
528
+ !isChromeExtension && /* @__PURE__ */ jsxs2(
529
+ "a",
530
+ {
531
+ target: "_blank",
532
+ href: "https://chrome.google.com/webstore/detail/uniform-context/dcmlokofjljnfjcknpmhjocogllfbhkg",
533
+ css: css3`
158
534
  align-items: center;
159
535
  border-radius: var(--rounded-base);
160
536
  display: flex;
@@ -169,14 +545,110 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
169
545
  &.active {
170
546
  background: var(--gray-700);
171
547
  }
172
- `,rel:"noreferrer",children:[T("i",{css:V`
548
+ `,
549
+ rel: "noreferrer",
550
+ children: [
551
+ /* @__PURE__ */ jsx7(
552
+ "i",
553
+ {
554
+ css: css3`
173
555
  align-items: center;
174
556
  display: flex;
175
- `,dangerouslySetInnerHTML:{__html:oo}}),"Install Chrome Extension"]}),T(_e,{})]})};import{Button as Ro}from"@uniformdev/design-system";import{Field as pt,Form as Vo,Formik as Po}from"formik";import*as X from"yup";function ne({scores:e,scoreOverrides:o}){let r=[];return o?(Object.entries(o).forEach(([t,n])=>{var d;let s=(d=e[t])!=null?d:0;if(s===n.override)return;let l=n.override-s;r.push({type:"modscoreS",data:{dimension:t,delta:l}})}),r):[]}function ge({quirks:e,quirkOverrides:o}){let r={};if(!!o)return Object.entries(o).forEach(([t,n])=>{e[t]!==n.override&&(r[t]=n.override)}),Object.keys(r).length>0?r:void 0}import{Context as ro,TransitionDataStore as no}from"@uniformdev/context";function $e({manifest:e,visitor:o,override:r}){let t=new ro({manifest:e,transitionStore:new Le({initialData:o})}),n={...t.scores};t.storage.updateData([r]);let l={...{...t.scores}};return Object.entries(l).forEach(([d,p])=>{n[d]===p&&delete l[d]}),l}var Le=class extends no{async handleDelete(){}async handleUpdateData(){}};import{css as K}from"@emotion/react";import*as We from"react";import{Fragment as lo,jsx as $,jsxs as Ke}from"@emotion/react/jsx-runtime";var Ye=K({willChange:"height"}),io=K`
557
+ `,
558
+ dangerouslySetInnerHTML: { __html: googleChromeExtensionSvg }
559
+ }
560
+ ),
561
+ "Install Chrome Extension"
562
+ ]
563
+ }
564
+ ),
565
+ /* @__PURE__ */ jsx7(ExtensionVersion, {})
566
+ ]
567
+ }
568
+ );
569
+ };
570
+
571
+ // src/components/Personalization/AddOverride.tsx
572
+ import { Button as Button2 } from "@uniformdev/design-system";
573
+ import { Field, Form, Formik } from "formik";
574
+ import * as yup from "yup";
575
+
576
+ // src/lib/applyOverrides.ts
577
+ function applyScoreOverrides({
578
+ scores,
579
+ scoreOverrides
580
+ }) {
581
+ const commands = [];
582
+ if (!scoreOverrides)
583
+ return [];
584
+ Object.entries(scoreOverrides).forEach(([dim, override]) => {
585
+ var _a;
586
+ const score = (_a = scores[dim]) != null ? _a : 0;
587
+ if (score === override.override) {
588
+ return;
589
+ }
590
+ const delta = override.override - score;
591
+ commands.push({
592
+ type: "modscoreS",
593
+ data: { dimension: dim, delta }
594
+ });
595
+ });
596
+ return commands;
597
+ }
598
+ function applyQuirkOverrides({
599
+ quirks,
600
+ quirkOverrides
601
+ }) {
602
+ const quirkVector = {};
603
+ if (!quirkOverrides)
604
+ return void 0;
605
+ Object.entries(quirkOverrides).forEach(([quirk, override]) => {
606
+ const quirkValue = quirks[quirk];
607
+ if (quirkValue === override.override) {
608
+ return;
609
+ }
610
+ quirkVector[quirk] = override.override;
611
+ });
612
+ return Object.keys(quirkVector).length > 0 ? quirkVector : void 0;
613
+ }
614
+
615
+ // src/lib/computeOverrideEffects.ts
616
+ import { Context, TransitionDataStore } from "@uniformdev/context";
617
+ function computeOverrideEffects({ manifest, visitor, override }) {
618
+ const contextCopy = new Context({
619
+ manifest,
620
+ transitionStore: new CopyTransitionDataStore({ initialData: visitor })
621
+ });
622
+ const currentScores = { ...contextCopy.scores };
623
+ contextCopy.storage.updateData([override]);
624
+ const newScores = { ...contextCopy.scores };
625
+ const changes = { ...newScores };
626
+ Object.entries(changes).forEach(([key, value]) => {
627
+ const oldScore = currentScores[key];
628
+ if (oldScore === value) {
629
+ delete changes[key];
630
+ }
631
+ });
632
+ return changes;
633
+ }
634
+ var CopyTransitionDataStore = class extends TransitionDataStore {
635
+ async handleDelete() {
636
+ }
637
+ async handleUpdateData() {
638
+ }
639
+ };
640
+
641
+ // src/components/Accordion/Accordion.tsx
642
+ import { css as css4 } from "@emotion/react";
643
+ import * as React3 from "react";
644
+ import { Fragment, jsx as jsx8, jsxs as jsxs3 } from "@emotion/react/jsx-runtime";
645
+ var willChange = css4({ willChange: "height" });
646
+ var titleStyle = css4`
176
647
  border-bottom: 2px solid var(--brand-secondary-1);
177
648
  font-size: var(--fs-base);
178
649
  margin: 0;
179
- `,so=K`
650
+ `;
651
+ var btnStyle = css4`
180
652
  align-items: center;
181
653
  border: none;
182
654
  background: none;
@@ -186,24 +658,119 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
186
658
  padding: var(--spacing-sm) 0;
187
659
  font-weight: var(--fw-bold);
188
660
  justify-content: space-between;
189
- `,ao=K`
661
+ `;
662
+ var iconStyle = css4`
190
663
  align-self: center;
191
- `,co=K`
664
+ `;
665
+ var iconActiveStyle = css4`
192
666
  transform: rotate(-180deg);
193
- `,ve=({children:e})=>$("div",{css:[Ye],children:e}),fe=({title:e,children:o})=>{let[r,t]=We.useState(!1),n=e.split(" ").join("-").toLocaleLowerCase();return Ke(lo,{children:[$("h3",{css:io,children:Ke("button",{"aria-expanded":r,css:so,title:e,id:n,"aria-controls":`${n}-section`,onClick:()=>t(s=>!s),type:"button",children:[e,$("i",{css:[ao,r?co:void 0],children:$("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:$("path",{d:"M6.34317 7.75732L4.92896 9.17154L12 16.2426L19.0711 9.17157L17.6569 7.75735L12 13.4142L6.34317 7.75732Z",fill:"currentColor"})})})]})}),$("div",{id:`${n}-section`,css:[Ye,K`
667
+ `;
668
+ var Accordion = ({ children }) => {
669
+ return /* @__PURE__ */ jsx8("div", { css: [willChange], children });
670
+ };
671
+ var AccordionItem = ({ title, children }) => {
672
+ const [visibility, setVisibility] = React3.useState(false);
673
+ const id = title.split(" ").join("-").toLocaleLowerCase();
674
+ return /* @__PURE__ */ jsxs3(Fragment, { children: [
675
+ /* @__PURE__ */ jsx8("h3", { css: titleStyle, children: /* @__PURE__ */ jsxs3(
676
+ "button",
677
+ {
678
+ "aria-expanded": visibility,
679
+ css: btnStyle,
680
+ title,
681
+ id,
682
+ "aria-controls": `${id}-section`,
683
+ onClick: () => setVisibility((prev) => !prev),
684
+ type: "button",
685
+ children: [
686
+ title,
687
+ /* @__PURE__ */ jsx8("i", { css: [iconStyle, visibility ? iconActiveStyle : void 0], children: /* @__PURE__ */ jsx8("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx8(
688
+ "path",
689
+ {
690
+ d: "M6.34317 7.75732L4.92896 9.17154L12 16.2426L19.0711 9.17157L17.6569 7.75735L12 13.4142L6.34317 7.75732Z",
691
+ fill: "currentColor"
692
+ }
693
+ ) }) })
694
+ ]
695
+ }
696
+ ) }),
697
+ /* @__PURE__ */ jsx8(
698
+ "div",
699
+ {
700
+ id: `${id}-section`,
701
+ css: [
702
+ willChange,
703
+ css4`
194
704
  padding: var(--spacing-sm) 0;
195
- `],role:"region","aria-labelledby":n,children:r?o:null})]})};import{css as po}from"@emotion/react";import{jsx as mo}from"@emotion/react/jsx-runtime";var B=({children:e,...o})=>mo("fieldset",{css:po`
705
+ `
706
+ ],
707
+ role: "region",
708
+ "aria-labelledby": id,
709
+ children: visibility ? children : null
710
+ }
711
+ )
712
+ ] });
713
+ };
714
+
715
+ // src/components/Form/Fieldset.tsx
716
+ import { css as css5 } from "@emotion/react";
717
+ import { jsx as jsx9 } from "@emotion/react/jsx-runtime";
718
+ var Fieldset = ({ children, ...props }) => {
719
+ return /* @__PURE__ */ jsx9(
720
+ "fieldset",
721
+ {
722
+ css: css5`
196
723
  border: none;
197
724
  padding: 0;
198
725
  & legend {
199
726
  margin-bottom: var(--spacing-base);
200
727
  }
201
- `,...o,children:e});import{css as uo}from"@emotion/react";import{jsx as go}from"@emotion/react/jsx-runtime";var W=({children:e})=>go("legend",{css:uo`
728
+ `,
729
+ ...props,
730
+ children
731
+ }
732
+ );
733
+ };
734
+
735
+ // src/components/Form/Legend.tsx
736
+ import { css as css6 } from "@emotion/react";
737
+ import { jsx as jsx10 } from "@emotion/react/jsx-runtime";
738
+ var Legend = ({ children }) => {
739
+ return /* @__PURE__ */ jsx10(
740
+ "legend",
741
+ {
742
+ css: css6`
202
743
  font-size: var(--fs-md);
203
744
  font-weight: var(--fw-bold);
204
745
  border-bottom: 1px solid var(--gray-400);
205
746
  width: 100%;
206
- `,children:e});import{Input as fo,InputSelect as ho}from"@uniformdev/design-system";import{jsx as vo}from"@emotion/react/jsx-runtime";var Oe=e=>({field:o,form:r,meta:t,...n})=>vo(e,{...o,...n,errorMessage:r.errors[o.name]});var he=Oe(fo),Je=Oe(ho);import{Caption as bo,ErrorMessage as xo}from"@uniformdev/design-system";import{css as Z}from"@emotion/react";var Xe=Z`
747
+ `,
748
+ children
749
+ }
750
+ );
751
+ };
752
+
753
+ // src/components/Inputs/FormikInputs.tsx
754
+ import { Input, InputSelect } from "@uniformdev/design-system";
755
+
756
+ // src/utils/withFormikField.tsx
757
+ import { jsx as jsx11 } from "@emotion/react/jsx-runtime";
758
+ var withFormikField = (Component) => {
759
+ return ({ field, form, meta, ...rawProps }) => {
760
+ return /* @__PURE__ */ jsx11(Component, { ...field, ...rawProps, errorMessage: form.errors[field.name] });
761
+ };
762
+ };
763
+
764
+ // src/components/Inputs/FormikInputs.tsx
765
+ var FormikInput = withFormikField(Input);
766
+ var FormikInputSelect = withFormikField(InputSelect);
767
+
768
+ // src/components/Inputs/FormikSliderInput.tsx
769
+ import { Caption, ErrorMessage } from "@uniformdev/design-system";
770
+
771
+ // src/components/Inputs/inputs.styles.ts
772
+ import { css as css7 } from "@emotion/react";
773
+ var textInput = css7`
207
774
  background: var(--white);
208
775
  border: 1px solid var(--gray-500);
209
776
  border-radius: var(--rounded-base);
@@ -214,26 +781,32 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
214
781
  cursor: not-allowed;
215
782
  color: var(--gray-200);
216
783
  }
217
- `,hn=Z`
784
+ `;
785
+ var inputWrapper = css7`
218
786
  margin: var(--spacing-base) 0;
219
- `,et=Z`
787
+ `;
788
+ var inputLabel = css7`
220
789
  color: var(--brand-secondary-1);
221
790
  display: flex;
222
791
  flex-direction: column;
223
792
  margin: 0 0 var(--spacing-sm);
224
- `,tt=Z`
793
+ `;
794
+ var inputText = css7`
225
795
  color: var(--brand-secondary-1);
226
796
  display: block;
227
797
  flex: 1 100%;
228
798
  font-weight: var(--fw-bold);
229
799
  margin: 0 0 var(--spacing-sm);
230
- `,bn=Z`
800
+ `;
801
+ var inputCaption = css7`
231
802
  color: var(--gray-600);
232
803
  font-size: var(--fs-sm);
233
- `,xn=Z`
804
+ `;
805
+ var errorMsg = css7`
234
806
  color: var(--brand-secondary-5);
235
807
  display: block;
236
- `,ot=Z`
808
+ `;
809
+ var rangeInput = css7`
237
810
  flex-direction: row;
238
811
  flex-wrap: wrap;
239
812
 
@@ -301,40 +874,96 @@ import{jsx as g}from"@emotion/react";import*as b from"react";import{css as Mt}fr
301
874
  flex: 1 0 20%;
302
875
  padding: 10px;
303
876
  }
304
- `;import{jsx as ie,jsxs as rt}from"@emotion/react/jsx-runtime";var nt=({field:e,form:o,meta:r,...t})=>{var m,i;let{label:n,caption:s,min:l=0,max:d=100,step:p}=t;return rt("div",{children:[rt("label",{css:[et,ot],children:[ie("span",{css:tt,children:n}),ie("input",{type:"range",min:l,max:d,step:p,...e,value:(m=e.value)!=null?m:0}),ie("span",{className:"value-display",children:(i=e.value)!=null?i:0})]}),s?ie(bo,{children:s}):null,o.touched[e.name]&&o.errors[e.name]?ie(xo,{message:o.errors[e.name]}):null]})};import{css as yo}from"@emotion/react";import{jsx as ko}from"@emotion/react/jsx-runtime";var Co=`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
877
+ `;
878
+
879
+ // src/components/Inputs/FormikSliderInput.tsx
880
+ import { jsx as jsx12, jsxs as jsxs4 } from "@emotion/react/jsx-runtime";
881
+ var FormikSliderInput = ({ field, form, meta, ...rawProps }) => {
882
+ var _a, _b;
883
+ const { label, caption, min = 0, max = 100, step } = rawProps;
884
+ return /* @__PURE__ */ jsxs4("div", { children: [
885
+ /* @__PURE__ */ jsxs4("label", { css: [inputLabel, rangeInput], children: [
886
+ /* @__PURE__ */ jsx12("span", { css: inputText, children: label }),
887
+ /* @__PURE__ */ jsx12("input", { type: "range", min, max, step, ...field, value: (_a = field.value) != null ? _a : 0 }),
888
+ /* @__PURE__ */ jsx12("span", { className: "value-display", children: (_b = field.value) != null ? _b : 0 })
889
+ ] }),
890
+ caption ? /* @__PURE__ */ jsx12(Caption, { children: caption }) : null,
891
+ form.touched[field.name] && form.errors[field.name] ? /* @__PURE__ */ jsx12(ErrorMessage, { message: form.errors[field.name] }) : null
892
+ ] });
893
+ };
894
+
895
+ // src/styles/icons.tsx
896
+ import { css as css8 } from "@emotion/react";
897
+ import { jsx as jsx13 } from "@emotion/react/jsx-runtime";
898
+ var audienceIcon = `<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
305
899
  <path d="M4.2 7.2C4.53137 7.2 4.8 6.93137 4.8 6.6C4.8 6.26863 4.53137 6 4.2 6C3.86863 6 3.6 6.26863 3.6 6.6C3.6 6.93137 3.86863 7.2 4.2 7.2Z" fill="#828282"/>
306
900
  <path d="M8.4 6.6C8.4 6.93137 8.13137 7.2 7.8 7.2C7.46863 7.2 7.2 6.93137 7.2 6.6C7.2 6.26863 7.46863 6 7.8 6C8.13137 6 8.4 6.26863 8.4 6.6Z" fill="#828282"/>
307
901
  <path fill-rule="evenodd" clip-rule="evenodd" d="M6 12C9.31371 12 12 9.31371 12 6C12 2.68629 9.31371 0 6 0C2.68629 0 0 2.68629 0 6C0 9.31371 2.68629 12 6 12ZM6 10.8C8.65097 10.8 10.8 8.65097 10.8 6C10.8 5.49824 10.723 5.01447 10.5802 4.55984C10.0795 4.69533 9.55274 4.76763 9.00913 4.76763C6.77526 4.76763 4.82652 3.54683 3.79366 1.73601C2.25282 2.53492 1.2 4.14451 1.2 6C1.2 8.65097 3.34903 10.8 6 10.8Z" fill="#828282"/>
308
- </svg>`,wo=`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
902
+ </svg>`;
903
+ var enrichmentIcon = `<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
309
904
  <path fill-rule="evenodd" clip-rule="evenodd" d="M3.59995 5.05775C4.9254 5.05775 5.99992 3.98325 5.99992 2.65778C5.99992 1.33232 4.9254 0.257812 3.59995 0.257812C2.27448 0.257812 1.19998 1.33232 1.19998 2.65778C1.19998 3.98325 2.27448 5.05775 3.59995 5.05775ZM3.59999 3.85777C4.26272 3.85777 4.79997 3.32052 4.79997 2.65778C4.79997 1.99505 4.26272 1.4578 3.59999 1.4578C2.93725 1.4578 2.4 1.99505 2.4 2.65778C2.4 3.32052 2.93725 3.85777 3.59999 3.85777Z" fill="#828282"/>
310
905
  <path d="M5.39993 6.8577C5.73131 6.8577 5.99993 7.12632 5.99993 7.45769V11.0576H7.19991V7.45769C7.19991 6.46356 6.39406 5.65771 5.39993 5.65771H1.79998C0.80588 5.65771 0 6.46356 0 7.45769V11.0576H1.19999V7.45769C1.19999 7.12632 1.46861 6.8577 1.79998 6.8577H5.39993Z" fill="#828282"/>
311
906
  <path d="M11.9999 5.05762H8.3999V6.2576H11.9999V5.05762Z" fill="#828282"/>
312
907
  <path d="M8.3999 7.45752H11.9999V8.6575H8.3999V7.45752Z" fill="#828282"/>
313
908
  <path d="M11.9999 2.65771H8.3999V3.8577H11.9999V2.65771Z" fill="#828282"/>
314
- </svg>`,it=`<svg width="15" height="11" viewBox="0 0 15 11" fill="none" xmlns="http://www.w3.org/2000/svg">
909
+ </svg>`;
910
+ var signalIcon = `<svg width="15" height="11" viewBox="0 0 15 11" fill="none" xmlns="http://www.w3.org/2000/svg">
315
911
  <path fill-rule="evenodd" clip-rule="evenodd" d="M7.113 3.12646C8.16729 3.12646 9.02195 3.98113 9.02195 5.03541C9.02195 5.86658 8.49075 6.57368 7.74932 6.83573V10.1259H6.47669V6.83573C5.73526 6.57368 5.20405 5.86658 5.20405 5.03541C5.20405 3.98113 6.05872 3.12646 7.113 3.12646ZM7.113 4.39909C7.46443 4.39909 7.74932 4.68398 7.74932 5.03541C7.74932 5.38684 7.46443 5.67172 7.113 5.67172C6.76158 5.67172 6.47669 5.38684 6.47669 5.03541C6.47669 4.68398 6.76158 4.39909 7.113 4.39909Z" fill="#828282"/>
316
912
  <path d="M3.96336 1.88578C3.15733 2.69183 2.65879 3.80537 2.65879 5.03535C2.65879 6.42093 3.29145 7.65875 4.28366 8.47569L5.1895 7.56984C4.42501 6.98876 3.93142 6.06969 3.93142 5.03535C3.93142 4.1568 4.28752 3.36142 4.86325 2.78567L3.96336 1.88578Z" fill="#828282"/>
317
913
  <path d="M9.36269 2.7856C9.93846 3.36136 10.2946 4.15676 10.2946 5.03535C10.2946 6.06973 9.80096 6.98882 9.03643 7.5699L9.94228 8.47575C10.9345 7.65881 11.5672 6.42096 11.5672 5.03535C11.5672 3.80533 11.0687 2.69177 10.2626 1.88571L9.36269 2.7856Z" fill="#828282"/>
318
914
  <path d="M0.113525 5.03534C0.113525 3.10251 0.896953 1.35266 2.16359 0.0860049L3.06347 0.985892C2.02714 2.02224 1.38616 3.45394 1.38616 5.03534C1.38616 6.61674 2.02714 8.04844 3.06347 9.08479L2.16358 9.98468C0.89695 8.71802 0.113525 6.96817 0.113525 5.03534Z" fill="#828282"/>
319
915
  <path d="M12.0624 9.98474C13.329 8.71809 14.1125 6.96821 14.1125 5.03534C14.1125 3.10248 13.329 1.3526 12.0624 0.0859375L11.1625 0.985824C12.1988 2.02218 12.8398 3.4539 12.8398 5.03534C12.8398 6.61678 12.1988 8.0485 11.1625 9.08486L12.0624 9.98474Z" fill="#828282"/>
320
- </svg>`,st=({type:e})=>{let o="";switch(e){case"Audience":o=Co;break;case"Signal":o=it;break;case"Intent":o=it;break;case"Enrichment":o=wo;break}return ko("i",{css:yo`
916
+ </svg>`;
917
+ var Icon = ({ type }) => {
918
+ let iconHtml = "";
919
+ switch (type) {
920
+ case "Audience":
921
+ iconHtml = audienceIcon;
922
+ break;
923
+ case "Signal":
924
+ iconHtml = signalIcon;
925
+ break;
926
+ case "Intent":
927
+ iconHtml = signalIcon;
928
+ break;
929
+ case "Enrichment":
930
+ iconHtml = enrichmentIcon;
931
+ break;
932
+ }
933
+ return /* @__PURE__ */ jsx13(
934
+ "i",
935
+ {
936
+ css: css8`
321
937
  align-items: center;
322
938
  display: inline-block;
323
- `,dangerouslySetInnerHTML:{__html:o}})};import{css as O,keyframes as To}from"@emotion/react";var Do=To`from {
939
+ `,
940
+ dangerouslySetInnerHTML: { __html: iconHtml }
941
+ }
942
+ );
943
+ };
944
+
945
+ // src/components/Personalization/page.styles.ts
946
+ import { css as css9, keyframes } from "@emotion/react";
947
+ var popIn = keyframes`from {
324
948
  transform: scale(1);
325
949
  }
326
950
  to {
327
951
  transform: scale(1.2);
328
952
  }
329
- `,h={page:O`
953
+ `;
954
+ var styles = {
955
+ page: css9`
330
956
  color: var(--brand-secondary-1);
331
- `,text:O`
957
+ `,
958
+ text: css9`
332
959
  margin: var(--spacing-sm) 0;
333
- `,reset:O`
960
+ `,
961
+ reset: css9`
334
962
  margin: 0 var(--spacing-md);
335
963
  font-size: var(--fs-sm);
336
964
  color: var(--gray-500);
337
- `,title:O`
965
+ `,
966
+ title: css9`
338
967
  margin: 0 0 var(--spacing-sm);
339
968
  font-size: var(--fs-md);
340
969
  & > small {
@@ -343,12 +972,14 @@ to {
343
972
  font-weight: var(--fw-regular);
344
973
  margin: var(--spacing-xxs) 0 0;
345
974
  }
346
- `,headingGroup:O`
975
+ `,
976
+ headingGroup: css9`
347
977
  align-items: baseline;
348
978
  display: flex;
349
979
  justify-content: space-between;
350
980
  align-items: center;
351
- `,divider:O`
981
+ `,
982
+ divider: css9`
352
983
  background: var(--gray-300);
353
984
  display: block;
354
985
  width: 1px;
@@ -356,67 +987,146 @@ to {
356
987
  position: absolute;
357
988
  inset: 0 auto 0 0;
358
989
  margin: auto 0;
359
- `,submitButton:O`
990
+ `,
991
+ submitButton: css9`
360
992
  position: absolute;
361
993
  right: var(--spacing-base);
362
994
  bottom: var(--spacing-base);
363
- animation: 0.5s 2 alternate ${Do};
364
- `,cancelButton:O`
995
+ animation: 0.5s 2 alternate ${popIn};
996
+ `,
997
+ cancelButton: css9`
365
998
  position: absolute;
366
999
  left: calc(200px + var(--spacing-base));
367
1000
  bottom: var(--spacing-base);
368
1001
  background: white;
369
1002
  padding: var(--spacing-sm);
370
1003
  border: 1px solid var(--gray-300);
371
- `,error:O`
1004
+ `,
1005
+ error: css9`
372
1006
  color: var(--brand-secondary-5);
373
1007
  font-size: var(--fs-sm);
374
- `,quirks:O`
1008
+ `,
1009
+ quirks: css9`
375
1010
  .uniform-input-select,
376
1011
  input {
377
1012
  padding: var(--spacing-sm);
378
1013
  }
379
- `};import{css as P}from"@emotion/react";import{jsx as Y}from"@emotion/react/jsx-runtime";var be=({children:e})=>Y("table",{css:P`
1014
+ `
1015
+ };
1016
+
1017
+ // src/components/Table/Table.tsx
1018
+ import { css as css10 } from "@emotion/react";
1019
+ import { jsx as jsx14 } from "@emotion/react/jsx-runtime";
1020
+ var Table = ({ children }) => {
1021
+ return /* @__PURE__ */ jsx14(
1022
+ "table",
1023
+ {
1024
+ css: css10`
380
1025
  border-collapse: collapse;
381
1026
  display: table;
382
1027
  width: 100%;
383
1028
  font-size: var(--fs-sm);
384
- `,children:e}),at=({children:e})=>Y("thead",{css:P`
1029
+ `,
1030
+ children
1031
+ }
1032
+ );
1033
+ };
1034
+ var THead = ({ children }) => {
1035
+ return /* @__PURE__ */ jsx14(
1036
+ "thead",
1037
+ {
1038
+ css: css10`
385
1039
  background: var(--gray-50);
386
1040
  text-align: left;
387
1041
  & tr {
388
1042
  border-bottom: 1px solid var(--gray-200);
389
1043
  }
390
- `,children:e}),xe=({children:e})=>Y("tbody",{children:e}),se=({border:e,children:o})=>Y("tr",{css:e?P`
1044
+ `,
1045
+ children
1046
+ }
1047
+ );
1048
+ };
1049
+ var TBody = ({ children }) => {
1050
+ return /* @__PURE__ */ jsx14("tbody", { children });
1051
+ };
1052
+ var TRow = ({ border, children }) => {
1053
+ return /* @__PURE__ */ jsx14(
1054
+ "tr",
1055
+ {
1056
+ css: border ? css10`
391
1057
  border-bottom: 1px solid var(--gray-200);
392
1058
  &:where(:last-child) {
393
1059
  border: none;
394
1060
  }
395
- `:void 0,children:o}),ye=({children:e,width:o})=>Y("th",{css:P`
1061
+ ` : void 0,
1062
+ children
1063
+ }
1064
+ );
1065
+ };
1066
+ var THeading = ({ children, width }) => {
1067
+ return /* @__PURE__ */ jsx14(
1068
+ "th",
1069
+ {
1070
+ css: css10`
396
1071
  outline: none;
397
1072
  padding: var(--spacing-sm);
398
- width: ${o!=null?o:"auto"};
399
- `,children:e});function So(e){switch(e){case"light":return P`
1073
+ width: ${width != null ? width : "auto"};
1074
+ `,
1075
+ children
1076
+ }
1077
+ );
1078
+ };
1079
+ function colour(color) {
1080
+ switch (color) {
1081
+ case "light":
1082
+ return css10`
400
1083
  color: var(--gray-400);
401
- `;case"dark":return P`
1084
+ `;
1085
+ case "dark":
1086
+ return css10`
402
1087
  color: var(--brand-secondary-1);
403
- `}}function Lo(e){return P`
404
- text-align: ${e};
405
- `}var Q=({alignment:e="left",border:o,color:r="dark",children:t})=>Y("td",{css:[P`
1088
+ `;
1089
+ }
1090
+ }
1091
+ function align(alignment) {
1092
+ return css10`
1093
+ text-align: ${alignment};
1094
+ `;
1095
+ }
1096
+ var TData = ({ alignment = "left", border, color = "dark", children }) => {
1097
+ return /* @__PURE__ */ jsx14(
1098
+ "td",
1099
+ {
1100
+ css: [
1101
+ css10`
406
1102
  padding: var(--spacing-base);
407
1103
  max-width: 180px;
408
1104
  overflow-wrap: break-word;
409
1105
  position: relative;
410
- `,So(r),Lo(e),o?P`
1106
+ `,
1107
+ colour(color),
1108
+ align(alignment),
1109
+ border ? css10`
411
1110
  border-left: 1px solid var(--gray-200);
412
- `:void 0],children:t});import{css as Re}from"@emotion/react";var ct=Re`
1111
+ ` : void 0
1112
+ ],
1113
+ children
1114
+ }
1115
+ );
1116
+ };
1117
+
1118
+ // src/components/Table/table.styles.ts
1119
+ import { css as css11 } from "@emotion/react";
1120
+ var scoreTd = css11`
413
1121
  position: relative;
414
1122
  display: inline-block;
415
1123
  font-size: var(--fs-base);
416
- `,lt=Re`
1124
+ `;
1125
+ var overriddenValue = css11`
417
1126
  display: block;
418
1127
  text-decoration: line-through;
419
- `,dt=Re`
1128
+ `;
1129
+ var isOverriddenTooltip = css11`
420
1130
  position: absolute;
421
1131
  width: 6px;
422
1132
  height: 6px;
@@ -424,7 +1134,863 @@ to {
424
1134
  top: 9px;
425
1135
  background: var(--red-tooltip);
426
1136
  border-radius: 3px;
427
- `;import{jsx as I,jsxs as J}from"@emotion/react/jsx-runtime";var Oo=({dimensionIndex:e,dimensions:o,disableEditOverride:r,onClick:t,preemptiveOverrides:n})=>{var d;let{settings:s}=ce(),l=(d=n!=null?n:s.scoreOverrides)!=null?d:{};return I(be,{children:I(xe,{children:Object.entries(o).sort(([p],[m])=>p.localeCompare(m)).map(([p,m])=>{var f;let{dim:i,name:a,type:c,category:v}=(f=e[p])!=null?f:{name:p,dim:p,type:void 0,category:void 0},u=l[i];return J(se,{children:[J(Q,{children:[u!==void 0?I("s",{css:lt,children:u.initial}):null,J("b",{css:ct,children:[m,u!==void 0&&I("i",{css:dt})]})]}),I(Q,{children:J("div",{onClick:()=>t==null?void 0:t(i),css:t?{cursor:"pointer"}:void 0,children:[I("span",{css:h.divider,role:"presentation"}),J("div",{children:[I(st,{type:c})," ",c]}),J("strong",{children:[v?`${v}:`:""," ",a]})]})}),I(Q,{alignment:"right",color:"light",children:u!==void 0&&!r?I(G,{route:`/overrides/${i}`,children:"Edit override"}):null})]},i)})})})},z=Oo;import{jsx as L,jsxs as mt}from"@emotion/react/jsx-runtime";var Io=X.object({dimension:X.string(),score:X.number()}),Ve=({settings:e,saveSettings:o,state:r,actions:t,dimensionIndex:{index:n}})=>{var p,m;let s=e.route?[...e.route.matchAll(/overrides\/(?!.*add)(\w+)?/g)]:[],l=s[0]?s[0][1]:"";if(!((p=r.manifest.project.pz)!=null&&p.sig))return L("p",{children:"Error, manifest is broken or there is no signal to override."});let d=Object.entries(n).filter(([,i])=>i.type!=="Audience"&&i.type!=="Intent").map(([i,a])=>{let c=a.type?`${a.type}: `:"",v=a.category?`${a.category} - `:"",u=`${c}${v}${a.name}`;return{value:i,label:u}});return d.unshift({value:"",label:"Choose dimension to override"}),L(Po,{initialValues:{dimension:l,score:(m=r.scores[l])!=null?m:0},validate:i=>{let a={};return(i.score===r.scores[i.dimension]||i.score===0&&!r.scores[l])&&(a.score="You have to modify current score value"),a},validationSchema:Io,enableReinitialize:!0,validateOnChange:!1,validateOnBlur:!1,onSubmit:async i=>{var f,C,w,k,q,N;let a=(C=(f=n[i.dimension])==null?void 0:f.cap)!=null?C:0,c=Math.min(i.score,a),v={...e,scoreOverrides:{...e.scoreOverrides,[i.dimension]:{initial:(N=(q=(k=(w=e.scoreOverrides)==null?void 0:w[i.dimension])==null?void 0:k.initial)!=null?q:r.scores[i.dimension])!=null?N:0,override:c}},route:"/overrides"};await o(v);let u=ne({scores:r.scores,scoreOverrides:v.scoreOverrides});t.rawUpdate(u)},children:({isSubmitting:i,values:a,setFieldValue:c})=>{var w;let v=$e({manifest:r.manifest,visitor:r.data,override:{type:"modscore",data:{dimension:a.dimension,delta:a.score-((w=r.scores[a.dimension])!=null?w:0)}}}),u=Object.entries(r.scores).reduce((k,[q,N])=>(k[q]={initial:N,override:N},k),{}),f={max:100,step:50};n[a.dimension]&&(f.max=n[a.dimension].cap,f.step=n[a.dimension].str);let C=a.score&&Object.keys(v).length>0;return mt(Vo,{css:h.page,children:[L("h1",{css:h.title,children:"Override Dimension"}),L(pt,{component:Je,label:"Dimension",id:"dimension",name:"dimension",options:d,disabled:i,onChange:k=>{c("score",0,!1),c("dimension",k.target.value)}}),L("p",{css:h.text,children:L("small",{children:"Audiences and Intents are aggregated from other dimension scores and cannot be overridden directly."})}),a.dimension?L(pt,{component:nt,name:"score",label:"Score",disabled:i,max:f.max,step:f.step,caption:`Range: 0 - ${f.max} in increments of ${f.step}`}):null,mt(B,{disabled:i,css:{marginBottom:"2rem"},children:[C?L(ve,{children:L(fe,{title:`Impacted Dimensions (${Object.keys(v).length})`,children:L(z,{preemptiveOverrides:u,dimensionIndex:n,dimensions:v,disableEditOverride:!0})})}):null,L(Ro,{type:"submit",css:h.submitButton,disabled:i,children:"Save"}),L(G,{route:"/overrides",css:h.cancelButton,children:"Cancel"})]})]})}})};import{Button as gt}from"@uniformdev/design-system";import{Switch as Mo}from"@uniformdev/design-system";import*as vt from"react";async function Ce({actions:e,saveSettings:o,scores:r,settings:t}){var d,p;let n=(d=t.scoreOverrides)!=null?d:{},s={...n},l=[];for(let m of Object.keys(n)){let i=n==null?void 0:n[m];delete s[m],l.push({type:"modscoreS",data:{dimension:m,delta:i.initial-((p=r[m])!=null?p:0)}})}await o({...t,scoreOverrides:s}),await e.rawUpdate(l)}async function ut({quirk:e,settings:o,saveSettings:r,actions:t}){var l;let n=(l=o.quirkOverrides)==null?void 0:l[e];if(!n)return;let s={...o.quirkOverrides};delete s[e],await r({...o,quirkOverrides:s}),await t.rawUpdate([{type:"setquirk",data:{key:e,value:n.initial}}])}import{jsx as Pe,jsxs as Ho}from"@emotion/react/jsx-runtime";var ee=({title:e,text:o,buttonGroup:r,children:t})=>Ho("div",{css:de,children:[Pe("h2",{css:pe,children:e}),Pe("p",{css:me,children:o}),t,r?Pe("div",{css:ue,children:r}):null]});import{Fragment as Eo,jsx as R,jsxs as we}from"@emotion/react/jsx-runtime";var ft=({dimensionIndex:{index:e},state:{scores:o,data:r},actions:t,saveSettings:n,settings:s})=>{let l=vt.useMemo(()=>{let i={};return Object.keys(e).filter(a=>!o[a]).map(a=>{i[e[a].dim]=0}),i},[o,e]),d=Object.keys(o).length,p=d+Object.keys(l).length,m=()=>{t.rawUpdate([{type:"setcontrol",data:!r.controlGroup}])};return R(Eo,{children:we("article",{css:h.page,children:[we("div",{css:h.headingGroup,children:[we("h2",{css:h.title,children:["Dimensions",we("small",{children:[d," active of ",p]})]}),R("div",{css:h.reset,children:R(gt,{buttonType:"ghost",onClick:()=>Ce({actions:t,saveSettings:n,scores:o,settings:s}).then(t.forget),children:"clear all dimensions"})}),R(Mo,{name:"controlGroup",label:"Control Group",onChange:m,checked:r.controlGroup})]}),d>0?R(z,{dimensionIndex:e,dimensions:o}):R(ee,{title:r.controlGroup?"In control group":"No active dimensions",text:r.controlGroup?"You are part of the personalization control group. While in the control group you do not have dimension scores and will not see personalized content. A/B tests will still run.":"You do not have score in any dimensions yet.",buttonGroup:r.controlGroup?R(gt,{buttonType:"secondary",onClick:m,children:"Exit control group"}):null}),R(ve,{children:R(fe,{title:`Inactive Dimensions (${Object.keys(l).length})`,children:R(z,{dimensionIndex:e,dimensions:l})})})]})})};import{AddButton as Ao}from"@uniformdev/design-system";import{Button as ht}from"@uniformdev/design-system";import{Fragment as Bo,jsx as H,jsxs as bt}from"@emotion/react/jsx-runtime";var xt=({dimensionIndex:{index:e},state:{data:o,scores:r},actions:t,settings:n,saveSettings:s})=>{var a;let l=(a=n.scoreOverrides)!=null?a:{},d=Object.keys(l).length,p=c=>(c==null||c.preventDefault(),s({...n,route:"/overrides/add"})),m=()=>{t.rawUpdate([{type:"setcontrol",data:!o.controlGroup}])},i={};return Object.entries(r).map(([c,v])=>{l[c]!==void 0&&(i[c]=v)}),H(Bo,{children:bt("article",{css:h.page,children:[bt("div",{css:h.headingGroup,children:[H("h2",{css:h.title,children:"What if?"}),H("div",{css:h.reset,children:H(ht,{buttonType:"ghost",onClick:()=>Ce({actions:t,settings:n,saveSettings:s,scores:r}),children:"delete all overrides"})}),H(Ao,{onClick:p})]}),H("p",{children:"Override dimension scores to test personalization"}),d>0?H(z,{dimensionIndex:e,dimensions:i,onClick:c=>s({...n,route:`/overrides/${c}`})}):H(ee,{title:o.controlGroup?"In control group":"No overrides",text:o.controlGroup?"You are part of the personalization control group. While in the control group you do not have dimension scores and will not see personalized content. A/B tests will still run.":"You do not have any dimension overrides yet.",buttonGroup:o.controlGroup?H(ht,{buttonType:"secondary",onClick:m,children:"Exit control group"}):null})]})})};import{Button as wt,InputSelect as Uo}from"@uniformdev/design-system";import{useState as jo}from"react";import{Button as Qo,Input as Fo}from"@uniformdev/design-system";import{useEffect as qo,useState as No}from"react";import{jsx as yt,jsxs as zo}from"@emotion/react/jsx-runtime";var Zo=({name:e,value:o,submit:r})=>{let[t,n]=No(o!=null?o:"");return qo(()=>{n(o!=null?o:"")},[o]),zo("div",{css:{display:"flex",gap:"var(--spacing-sm)"},children:[yt(Fo,{type:"text",css:[Xe],name:e,value:t,onChange:d=>{n(d.target.value)}}),yt(Qo,{buttonType:"primary",disabled:t===o,size:"sm",onClick:()=>r(e,t!=null?t:""),children:"Save"})]})},Ct=Zo;import{Fragment as kt,jsx as y,jsxs as te}from"@emotion/react/jsx-runtime";var Tt=({...e})=>{let{state:{data:{quirks:o}},quirksIndex:{index:r},settings:t,saveSettings:n,actions:s}=e,[l,d]=jo(""),p;l&&(p=r[l]);let m=async(i,a)=>{var u,f,C;d("");let c={...t,quirkOverrides:{...t.quirkOverrides,[i]:{initial:(C=(f=(u=t.quirkOverrides)==null?void 0:u[i])==null?void 0:f.initial)!=null?C:o[i],override:a}}};await n(c);let v=ge({quirks:o,quirkOverrides:c.quirkOverrides});await s.update({quirks:v})};return y(kt,{children:te("article",{css:[h.page,h.quirks],children:[y("h1",{css:h.title,children:"Quirks"}),y("p",{css:h.text,children:"Keys defined in Uniform and their current, programmatically defined values for this visit."}),Object.keys(r).length?te(be,{children:[y(at,{children:te(se,{children:[y(ye,{width:"30%",children:"Key"}),y(ye,{width:"50%",children:"Value"}),y(ye,{width:"20%",children:""})]})}),y(xe,{children:Object.values(r).map(({name:i,value:a,id:c})=>{var f,C,w;let v=(C=(f=t.quirkOverrides)==null?void 0:f[i])==null?void 0:C.initial,u=[];return p&&p.options&&(u=p.options.map(k=>({value:k.value,label:k.name}))),te(se,{border:"bottom",children:[y(Q,{children:y("strong",{children:i})}),te(Q,{children:[l!==c?te("div",{onClick:()=>{d(c)},children:[v?y("div",{children:y("s",{children:v})}):null,a]}):null,l===c&&p&&y(kt,{children:p.options?y(Uo,{showLabel:!1,label:`Change ${i}`,defaultOption:`Change ${i}`,name:c,onChange:k=>m(k.target.name,k.target.value),options:u}):y(Ct,{name:c,value:a,submit:m})})]}),y(Q,{children:l?null:(w=t.quirkOverrides)!=null&&w[c]?y(wt,{buttonType:"ghost",onClick:()=>{ut({quirk:c,settings:t,saveSettings:n,actions:s})},children:y("small",{children:"Clear Override"})}):y(wt,{buttonType:"ghost",onClick:()=>{d(c)},children:y("small",{children:"Override"})})})]},c)})})]}):y(ee,{title:"No quirks configured",text:"There are currently no quirks setup. Try to connect to Uniform API to load additional information about Quirks and Quirks without defined value."})]})})};import{Button as Dt}from"@uniformdev/design-system";import{Switch as St}from"@uniformdev/design-system";import{jsx as D,jsxs as ae}from"@emotion/react/jsx-runtime";var Lt=({settings:e,saveSettings:o,actions:r,state:{data:t},clearAllExtensionData:n})=>ae("article",{css:[h.page,{display:"flex",flexDirection:"column",gap:"var(--spacing-base)"}],children:[D("h1",{css:h.title,children:"Settings"}),ae(B,{children:[D(W,{children:"Data Connection"}),D(Dt,{buttonType:"tertiary",onClick:()=>{o({...e,route:"/connect"})},children:"Manage Connection to Uniform"})]}),ae(B,{children:[D(W,{children:"Storage Consent"}),D(St,{label:"Store visitor data",id:"consent-mode",name:"consentMode",checked:t.consent,onChange:s=>{r.rawUpdate([{type:"consent",data:s.currentTarget.checked}]),o({...e,consentMode:s.currentTarget.checked})}}),D("p",{children:D("small",{children:"Enabling storage consent allows storing behavior in this browser for personalization across sessions. Only affects this browser. Personalization works with this disabled, but dimension scores are lost on refresh."})})]}),ae(B,{children:[D(W,{children:"Logging"}),D(St,{label:"Write Uniform Context diagnostic logs to browser console",id:"logging",name:"logging",checked:e.logLevel==="debug",onChange:s=>o({...e,logLevel:s.currentTarget.checked?"debug":"none"})})]}),ae(B,{children:[D(W,{children:"Clear extension storage"}),D(Dt,{onClick:()=>{n()},children:"Clear"}),D("p",{children:D("small",{children:"May be necessary when you have multiple different sites on the same domain name (e.g. http://localhost:3000) and there are some conflicts or other unexpected behaviour."})})]})]});import{parseQuickConnect as _o}from"@uniformdev/context";import{ApiClientError as Go,UncachedManifestClient as $o}from"@uniformdev/context/api";import{Button as oe,ErrorMessage as Ko,Input as Wo}from"@uniformdev/design-system";import{Field as Ie,Form as Yo,Formik as Jo}from"formik";import*as F from"react";import{Fragment as ke,jsx as x,jsxs as M}from"@emotion/react/jsx-runtime";function Ot(e){let[o,r]=F.useState(e.currentData?"c":"qc"),[t,n]=F.useState(void 0),[s,l]=F.useState(void 0),d=F.useCallback(async i=>{let a=new $o(i);n(void 0);try{let c=await a.get({preview:!0});return l({manifest:c,target:i}),c}catch(c){if(c instanceof Go){c.statusCode===403?n("API key is valid but does not have Context > Read Drafts permission, or the API key does not have permissions to the project, or the project does not exist."):n(c.errorMessage);return}if("message"in c){c.message==="Failed to fetch"?n("A network error occurred. Ensure the API host is valid."):n(c.message);return}n(JSON.stringify(c,null,2));return}},[]);F.useEffect(()=>{!e.currentData||d(e.currentData)},[d,e.currentData]);let p=async i=>{await d(i)&&(r("c"),await e.onConnect(i))},m=()=>{confirm("Disconnect from Uniform? Make sure to save your API key if you want to reconnect.")&&(r("qc"),l(void 0),n(void 0),e.onConnect(null))};return M("div",{children:[t?M(ke,{children:[x(Ko,{message:t}),x(oe,{buttonType:"secondary",type:"button",onClick:m,children:"Clear old/broken settings"})]}):null,o==="qc"||o==="mc"?x(Xo,{...e,state:o,setState:r,onConnect:p}):x("div",{children:s?M(ke,{children:[M("p",{children:["Connected to"," ",x("a",{href:`${s==null?void 0:s.target.apiHost}/projects/${s==null?void 0:s.target.projectId}`,target:"_blank",rel:"noopener noreferrer",css:{textDecoration:"underline"},children:x("strong",{children:s==null?void 0:s.manifest.project.name})})," ",M("small",{children:["(",s==null?void 0:s.manifest.project.id,")"]})]}),x(oe,{buttonType:"secondary",type:"button",onClick:m,children:"Disconnect"})]}):null})]})}function Xo({setState:e,state:o,currentData:r,onConnect:t}){var n,s,l;return x("div",{children:x(Jo,{initialValues:{apiHost:(n=r==null?void 0:r.apiHost)!=null?n:"https://uniform.app",apiKey:(s=r==null?void 0:r.apiKey)!=null?s:"",projectId:(l=r==null?void 0:r.projectId)!=null?l:"",qc:""},onSubmit:t,children:({setFieldValue:d,setFieldError:p,errors:{qc:m},isSubmitting:i})=>x(Yo,{children:x("fieldset",{css:{display:"flex",flexDirection:"column",gap:"var(--spacing-base)"},children:o==="qc"?M(ke,{children:[x("div",{children:x(Wo,{placeholder:"Paste Quick Connect Code Here",caption:"Copy the Quick Connect code after creating an API key in Uniform.",errorMessage:m,onChange:a=>{try{let c=_o(a.currentTarget.value);d("apiHost",c.apiHost),d("apiKey",c.apiKey),d("projectId",c.projectId)}catch(c){p("qc",c.message)}}})}),M("section",{css:{display:"flex",gap:"var(--spacing-sm)"},children:[x(oe,{type:"submit",buttonType:"primary",disabled:i,children:i?"Verifying...":"Connect"}),x(oe,{type:"button",buttonType:"ghost",onClick:()=>e("mc"),disabled:i,children:"Connect Manually"})]})]}):M(ke,{children:[x("div",{children:x(Ie,{component:he,label:"API Key",name:"apiKey",caption:"Generate an API key in your Uniform team settings."})}),x("div",{children:x(Ie,{component:he,label:"Project ID",name:"projectId",caption:"Available to copy after generating an API key"})}),x("div",{children:x(Ie,{component:he,label:"API Host",name:"apiHost",caption:"Use a non-standard Uniform API endpoint. Most people will not not need this option."})}),M("section",{css:{display:"flex",gap:"var(--spacing-sm)"},children:[x(oe,{type:"submit",buttonType:"primary",disabled:i,children:i?"Verifying...":"Connect"}),x(oe,{type:"button",buttonType:"ghost",onClick:()=>e("qc"),disabled:i,children:"Use Quick Connect"})]})]})})})})})}import{jsx as Te,jsxs as er}from"@emotion/react/jsx-runtime";var Rt=({settings:e,saveSettings:o})=>{let r=e.apiKey&&e.projectId?{apiKey:e.apiKey,projectId:e.projectId,apiHost:e.apiHost}:void 0;return er("article",{css:h.page,children:[Te("h1",{css:h.title,children:"Connect to a Uniform Project"}),Te("p",{css:h.text,children:Te("small",{children:"Adding an API key and project ID enables human-readable dimension labels to be shown. You must have access to the Uniform project to do this."})}),Te(Ot,{onConnect:async t=>{t?await o({...e,apiKey:t.apiKey,projectId:t.projectId,apiHost:t.apiHost}):await o({...e,apiKey:void 0,projectId:void 0,apiHost:void 0})},currentData:r})]})};import{useEffect as tr,useState as or}from"react";import{useMountedState as rr}from"react-use";import{jsx as Vt,jsxs as nr}from"@emotion/react/jsx-runtime";var Pt=()=>{let[e,o]=or(!1),r=rr();return tr(()=>{setTimeout(()=>{r()&&o(!0)},1e3)},[r]),e?nr("article",{css:h.page,children:[Vt("h1",{children:"Loading..."}),Vt("p",{children:"Connecting to Uniform API for complete data."})]}):null};import{jsx as It,jsxs as ir}from"@emotion/react/jsx-runtime";var Ht=()=>ir("article",{children:[It("h1",{children:"Something when wrong"}),It("p",{children:"We could not find the page you're looking for."})]});import{jsx as S,jsxs as He}from"@emotion/react/jsx-runtime";var ar=Mt`
1137
+ `;
1138
+
1139
+ // src/components/Table/DimensionsTable.tsx
1140
+ import { jsx as jsx15, jsxs as jsxs5 } from "@emotion/react/jsx-runtime";
1141
+ var DimensionsTable = ({
1142
+ dimensionIndex,
1143
+ dimensions,
1144
+ disableEditOverride,
1145
+ onClick,
1146
+ preemptiveOverrides
1147
+ }) => {
1148
+ var _a;
1149
+ const { settings } = useDevToolsSettingsContext();
1150
+ const overrides = (_a = preemptiveOverrides != null ? preemptiveOverrides : settings.scoreOverrides) != null ? _a : {};
1151
+ return /* @__PURE__ */ jsx15(Table, { children: /* @__PURE__ */ jsx15(TBody, { children: Object.entries(dimensions).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => {
1152
+ var _a2;
1153
+ const { dim, name, type, category } = (_a2 = dimensionIndex[key]) != null ? _a2 : {
1154
+ name: key,
1155
+ dim: key,
1156
+ type: void 0,
1157
+ category: void 0
1158
+ };
1159
+ const override = overrides[dim];
1160
+ return /* @__PURE__ */ jsxs5(TRow, { children: [
1161
+ /* @__PURE__ */ jsxs5(TData, { children: [
1162
+ override !== void 0 ? /* @__PURE__ */ jsx15("s", { css: overriddenValue, children: override.initial }) : null,
1163
+ /* @__PURE__ */ jsxs5("b", { css: scoreTd, children: [
1164
+ value,
1165
+ override !== void 0 && /* @__PURE__ */ jsx15("i", { css: isOverriddenTooltip })
1166
+ ] })
1167
+ ] }),
1168
+ /* @__PURE__ */ jsx15(TData, { children: /* @__PURE__ */ jsxs5("div", { onClick: () => onClick == null ? void 0 : onClick(dim), css: onClick ? { cursor: "pointer" } : void 0, children: [
1169
+ /* @__PURE__ */ jsx15("span", { css: styles.divider, role: "presentation" }),
1170
+ /* @__PURE__ */ jsxs5("div", { children: [
1171
+ /* @__PURE__ */ jsx15(Icon, { type }),
1172
+ " ",
1173
+ type
1174
+ ] }),
1175
+ /* @__PURE__ */ jsxs5("strong", { children: [
1176
+ category ? `${category}:` : "",
1177
+ " ",
1178
+ name
1179
+ ] })
1180
+ ] }) }),
1181
+ /* @__PURE__ */ jsx15(TData, { alignment: "right", color: "light", children: override !== void 0 && !disableEditOverride ? /* @__PURE__ */ jsx15(NavigationLink_default, { route: `/overrides/${dim}`, children: "Edit override" }) : null })
1182
+ ] }, dim);
1183
+ }) }) });
1184
+ };
1185
+ var DimensionsTable_default = DimensionsTable;
1186
+
1187
+ // src/components/Personalization/AddOverride.tsx
1188
+ import { jsx as jsx16, jsxs as jsxs6 } from "@emotion/react/jsx-runtime";
1189
+ var overrideSettingsSchema = yup.object({
1190
+ dimension: yup.string(),
1191
+ score: yup.number()
1192
+ });
1193
+ var AddOverride = ({
1194
+ settings,
1195
+ saveSettings,
1196
+ state,
1197
+ actions,
1198
+ dimensionIndex: { index }
1199
+ }) => {
1200
+ var _a, _b;
1201
+ const routeParams = settings.route ? [...settings.route.matchAll(/overrides\/(?!.*add)(\w+)?/g)] : [];
1202
+ const overriddenDimension = routeParams[0] ? routeParams[0][1] : "";
1203
+ if (!((_a = state.manifest.project.pz) == null ? void 0 : _a.sig)) {
1204
+ return /* @__PURE__ */ jsx16("p", { children: "Error, manifest is broken or there is no signal to override." });
1205
+ }
1206
+ const overridableDimensions = Object.entries(index).filter(([, value]) => value.type !== "Audience" && value.type !== "Intent").map(([key, value]) => {
1207
+ const type = value.type ? `${value.type}: ` : "";
1208
+ const category = value.category ? `${value.category} - ` : "";
1209
+ const label = `${type}${category}${value.name}`;
1210
+ return {
1211
+ value: key,
1212
+ label
1213
+ };
1214
+ });
1215
+ overridableDimensions.unshift({
1216
+ value: "",
1217
+ label: "Choose dimension to override"
1218
+ });
1219
+ return /* @__PURE__ */ jsx16(
1220
+ Formik,
1221
+ {
1222
+ initialValues: {
1223
+ dimension: overriddenDimension,
1224
+ score: (_b = state.scores[overriddenDimension]) != null ? _b : 0
1225
+ },
1226
+ validate: (values) => {
1227
+ const errors = {};
1228
+ if (values.score === state.scores[values.dimension] || values.score === 0 && !state.scores[overriddenDimension]) {
1229
+ errors.score = "You have to modify current score value";
1230
+ }
1231
+ return errors;
1232
+ },
1233
+ validationSchema: overrideSettingsSchema,
1234
+ enableReinitialize: true,
1235
+ validateOnChange: false,
1236
+ validateOnBlur: false,
1237
+ onSubmit: async (values) => {
1238
+ var _a2, _b2, _c, _d, _e, _f;
1239
+ const cap = (_b2 = (_a2 = index[values.dimension]) == null ? void 0 : _a2.cap) != null ? _b2 : 0;
1240
+ const cappedOverrideScore = Math.min(values.score, cap);
1241
+ const newSettings = {
1242
+ ...settings,
1243
+ scoreOverrides: {
1244
+ ...settings.scoreOverrides,
1245
+ [values.dimension]: {
1246
+ initial: (_f = (_e = (_d = (_c = settings.scoreOverrides) == null ? void 0 : _c[values.dimension]) == null ? void 0 : _d.initial) != null ? _e : state.scores[values.dimension]) != null ? _f : 0,
1247
+ override: cappedOverrideScore
1248
+ }
1249
+ },
1250
+ route: "/overrides"
1251
+ };
1252
+ await saveSettings(newSettings);
1253
+ const applyCommands = applyScoreOverrides({
1254
+ scores: state.scores,
1255
+ scoreOverrides: newSettings.scoreOverrides
1256
+ });
1257
+ actions.rawUpdate(applyCommands);
1258
+ },
1259
+ children: ({ isSubmitting, values, setFieldValue }) => {
1260
+ var _a2;
1261
+ const overrideEffects = computeOverrideEffects({
1262
+ manifest: state.manifest,
1263
+ visitor: state.data,
1264
+ override: {
1265
+ type: "modscore",
1266
+ data: {
1267
+ dimension: values.dimension,
1268
+ delta: values.score - ((_a2 = state.scores[values.dimension]) != null ? _a2 : 0)
1269
+ }
1270
+ }
1271
+ });
1272
+ const preemptiveOverrides = Object.entries(state.scores).reduce(
1273
+ (acc, [key, value]) => {
1274
+ acc[key] = {
1275
+ initial: value,
1276
+ override: value
1277
+ };
1278
+ return acc;
1279
+ },
1280
+ {}
1281
+ );
1282
+ const rangeProps = {
1283
+ max: 100,
1284
+ step: 50
1285
+ };
1286
+ if (index[values.dimension]) {
1287
+ rangeProps.max = index[values.dimension].cap;
1288
+ rangeProps.step = index[values.dimension].str;
1289
+ }
1290
+ const hasScoreEffects = values.score && Object.keys(overrideEffects).length > 0;
1291
+ return /* @__PURE__ */ jsxs6(Form, { css: styles.page, children: [
1292
+ /* @__PURE__ */ jsx16("h1", { css: styles.title, children: "Override Dimension" }),
1293
+ /* @__PURE__ */ jsx16(
1294
+ Field,
1295
+ {
1296
+ component: FormikInputSelect,
1297
+ label: "Dimension",
1298
+ id: "dimension",
1299
+ name: "dimension",
1300
+ options: overridableDimensions,
1301
+ disabled: isSubmitting,
1302
+ onChange: (e) => {
1303
+ setFieldValue("score", 0, false);
1304
+ setFieldValue("dimension", e.target.value);
1305
+ }
1306
+ }
1307
+ ),
1308
+ /* @__PURE__ */ jsx16("p", { css: styles.text, children: /* @__PURE__ */ jsx16("small", { children: "Audiences and Intents are aggregated from other dimension scores and cannot be overridden directly." }) }),
1309
+ values.dimension ? /* @__PURE__ */ jsx16(
1310
+ Field,
1311
+ {
1312
+ component: FormikSliderInput,
1313
+ name: "score",
1314
+ label: "Score",
1315
+ disabled: isSubmitting,
1316
+ max: rangeProps.max,
1317
+ step: rangeProps.step,
1318
+ caption: `Range: 0 - ${rangeProps.max} in increments of ${rangeProps.step}`
1319
+ }
1320
+ ) : null,
1321
+ /* @__PURE__ */ jsxs6(Fieldset, { disabled: isSubmitting, css: { marginBottom: "2rem" }, children: [
1322
+ hasScoreEffects ? /* @__PURE__ */ jsx16(Accordion, { children: /* @__PURE__ */ jsx16(AccordionItem, { title: `Impacted Dimensions (${Object.keys(overrideEffects).length})`, children: /* @__PURE__ */ jsx16(
1323
+ DimensionsTable_default,
1324
+ {
1325
+ preemptiveOverrides,
1326
+ dimensionIndex: index,
1327
+ dimensions: overrideEffects,
1328
+ disableEditOverride: true
1329
+ }
1330
+ ) }) }) : null,
1331
+ /* @__PURE__ */ jsx16(Button2, { type: "submit", css: styles.submitButton, disabled: isSubmitting, children: "Save" }),
1332
+ /* @__PURE__ */ jsx16(NavigationLink_default, { route: "/overrides", css: styles.cancelButton, children: "Cancel" })
1333
+ ] })
1334
+ ] });
1335
+ }
1336
+ }
1337
+ );
1338
+ };
1339
+
1340
+ // src/components/Personalization/Dimensions.tsx
1341
+ import { Button as Button3 } from "@uniformdev/design-system";
1342
+ import { Switch } from "@uniformdev/design-system";
1343
+ import * as React4 from "react";
1344
+
1345
+ // src/lib/deleteOverride.ts
1346
+ async function deleteScoreOverrides({
1347
+ actions,
1348
+ saveSettings,
1349
+ scores,
1350
+ settings
1351
+ }) {
1352
+ var _a, _b;
1353
+ const scoreOverrides = (_a = settings.scoreOverrides) != null ? _a : {};
1354
+ const newOverrides = { ...scoreOverrides };
1355
+ const commands = [];
1356
+ for (const dim of Object.keys(scoreOverrides)) {
1357
+ const override = scoreOverrides == null ? void 0 : scoreOverrides[dim];
1358
+ delete newOverrides[dim];
1359
+ commands.push({
1360
+ type: "modscoreS",
1361
+ data: { dimension: dim, delta: override.initial - ((_b = scores[dim]) != null ? _b : 0) }
1362
+ });
1363
+ }
1364
+ await saveSettings({
1365
+ ...settings,
1366
+ scoreOverrides: newOverrides
1367
+ });
1368
+ await actions.rawUpdate(commands);
1369
+ }
1370
+ async function deleteQuirkOverride({
1371
+ quirk: dim,
1372
+ settings,
1373
+ saveSettings,
1374
+ actions
1375
+ }) {
1376
+ var _a;
1377
+ const override = (_a = settings.quirkOverrides) == null ? void 0 : _a[dim];
1378
+ if (!override) {
1379
+ return;
1380
+ }
1381
+ const newOverrides = { ...settings.quirkOverrides };
1382
+ delete newOverrides[dim];
1383
+ await saveSettings({
1384
+ ...settings,
1385
+ quirkOverrides: newOverrides
1386
+ });
1387
+ await actions.rawUpdate([{ type: "setquirk", data: { key: dim, value: override.initial } }]);
1388
+ }
1389
+
1390
+ // src/components/CallToAction/NoActiveDimensions.tsx
1391
+ import { jsx as jsx17, jsxs as jsxs7 } from "@emotion/react/jsx-runtime";
1392
+ var NoActiveDimensions = ({ title, text, buttonGroup, children }) => {
1393
+ return /* @__PURE__ */ jsxs7("div", { css: cta, children: [
1394
+ /* @__PURE__ */ jsx17("h2", { css: ctaTitle, children: title }),
1395
+ /* @__PURE__ */ jsx17("p", { css: ctaText, children: text }),
1396
+ children,
1397
+ buttonGroup ? /* @__PURE__ */ jsx17("div", { css: ctaBtnGroup, children: buttonGroup }) : null
1398
+ ] });
1399
+ };
1400
+
1401
+ // src/components/Personalization/Dimensions.tsx
1402
+ import { Fragment as Fragment2, jsx as jsx18, jsxs as jsxs8 } from "@emotion/react/jsx-runtime";
1403
+ var Dimensions = ({
1404
+ dimensionIndex: { index: dimensionIndex },
1405
+ state: { scores, data },
1406
+ actions,
1407
+ saveSettings,
1408
+ settings
1409
+ }) => {
1410
+ const remainingDimensions = React4.useMemo(() => {
1411
+ const newRemainingDimensions = {};
1412
+ Object.keys(dimensionIndex).filter((dimension) => !scores[dimension]).map((key) => {
1413
+ newRemainingDimensions[dimensionIndex[key].dim] = 0;
1414
+ });
1415
+ return newRemainingDimensions;
1416
+ }, [scores, dimensionIndex]);
1417
+ const activeDims = Object.keys(scores).length;
1418
+ const totalDims = activeDims + Object.keys(remainingDimensions).length;
1419
+ const toggleControlGroup = () => {
1420
+ actions.rawUpdate([{ type: "setcontrol", data: !data.controlGroup }]);
1421
+ };
1422
+ return /* @__PURE__ */ jsx18(Fragment2, { children: /* @__PURE__ */ jsxs8("article", { css: styles.page, children: [
1423
+ /* @__PURE__ */ jsxs8("div", { css: styles.headingGroup, children: [
1424
+ /* @__PURE__ */ jsxs8("h2", { css: styles.title, children: [
1425
+ "Dimensions",
1426
+ /* @__PURE__ */ jsxs8("small", { children: [
1427
+ activeDims,
1428
+ " active of ",
1429
+ totalDims
1430
+ ] })
1431
+ ] }),
1432
+ /* @__PURE__ */ jsx18("div", { css: styles.reset, children: /* @__PURE__ */ jsx18(
1433
+ Button3,
1434
+ {
1435
+ buttonType: "ghost",
1436
+ onClick: () => deleteScoreOverrides({ actions, saveSettings, scores, settings }).then(actions.forget),
1437
+ children: "clear all dimensions"
1438
+ }
1439
+ ) }),
1440
+ /* @__PURE__ */ jsx18(
1441
+ Switch,
1442
+ {
1443
+ name: "controlGroup",
1444
+ label: "Control Group",
1445
+ onChange: toggleControlGroup,
1446
+ checked: data.controlGroup
1447
+ }
1448
+ )
1449
+ ] }),
1450
+ activeDims > 0 ? /* @__PURE__ */ jsx18(DimensionsTable_default, { dimensionIndex, dimensions: scores }) : /* @__PURE__ */ jsx18(
1451
+ NoActiveDimensions,
1452
+ {
1453
+ title: data.controlGroup ? "In control group" : "No active dimensions",
1454
+ text: data.controlGroup ? "You are part of the personalization control group. While in the control group you do not have dimension scores and will not see personalized content. A/B tests will still run." : "You do not have score in any dimensions yet.",
1455
+ buttonGroup: data.controlGroup ? /* @__PURE__ */ jsx18(Button3, { buttonType: "secondary", onClick: toggleControlGroup, children: "Exit control group" }) : null
1456
+ }
1457
+ ),
1458
+ /* @__PURE__ */ jsx18(Accordion, { children: /* @__PURE__ */ jsx18(AccordionItem, { title: `Inactive Dimensions (${Object.keys(remainingDimensions).length})`, children: /* @__PURE__ */ jsx18(DimensionsTable_default, { dimensionIndex, dimensions: remainingDimensions }) }) })
1459
+ ] }) });
1460
+ };
1461
+
1462
+ // src/components/Personalization/Overrides.tsx
1463
+ import { AddButton } from "@uniformdev/design-system";
1464
+ import { Button as Button4 } from "@uniformdev/design-system";
1465
+ import { Fragment as Fragment3, jsx as jsx19, jsxs as jsxs9 } from "@emotion/react/jsx-runtime";
1466
+ var Overrides = ({
1467
+ dimensionIndex: { index: dimensionIndex },
1468
+ state: { data, scores },
1469
+ actions,
1470
+ settings,
1471
+ saveSettings
1472
+ }) => {
1473
+ var _a;
1474
+ const overrides = (_a = settings.scoreOverrides) != null ? _a : {};
1475
+ const totalOverrides = Object.keys(overrides).length;
1476
+ const addNewOverride = (e) => {
1477
+ e == null ? void 0 : e.preventDefault();
1478
+ return saveSettings({ ...settings, route: "/overrides/add" });
1479
+ };
1480
+ const toggleControlGroup = () => {
1481
+ actions.rawUpdate([{ type: "setcontrol", data: !data.controlGroup }]);
1482
+ };
1483
+ const scoresAffectedByOverrides = {};
1484
+ Object.entries(scores).map(([key, value]) => {
1485
+ if (overrides[key] !== void 0) {
1486
+ scoresAffectedByOverrides[key] = value;
1487
+ }
1488
+ });
1489
+ return /* @__PURE__ */ jsx19(Fragment3, { children: /* @__PURE__ */ jsxs9("article", { css: styles.page, children: [
1490
+ /* @__PURE__ */ jsxs9("div", { css: styles.headingGroup, children: [
1491
+ /* @__PURE__ */ jsx19("h2", { css: styles.title, children: "What if?" }),
1492
+ /* @__PURE__ */ jsx19("div", { css: styles.reset, children: /* @__PURE__ */ jsx19(
1493
+ Button4,
1494
+ {
1495
+ buttonType: "ghost",
1496
+ onClick: () => deleteScoreOverrides({ actions, settings, saveSettings, scores }),
1497
+ children: "delete all overrides"
1498
+ }
1499
+ ) }),
1500
+ /* @__PURE__ */ jsx19(AddButton, { onClick: addNewOverride })
1501
+ ] }),
1502
+ /* @__PURE__ */ jsx19("p", { children: "Override dimension scores to test personalization" }),
1503
+ totalOverrides > 0 ? /* @__PURE__ */ jsx19(
1504
+ DimensionsTable_default,
1505
+ {
1506
+ dimensionIndex,
1507
+ dimensions: scoresAffectedByOverrides,
1508
+ onClick: (dim) => saveSettings({ ...settings, route: `/overrides/${dim}` })
1509
+ }
1510
+ ) : /* @__PURE__ */ jsx19(
1511
+ NoActiveDimensions,
1512
+ {
1513
+ title: data.controlGroup ? "In control group" : "No overrides",
1514
+ text: data.controlGroup ? "You are part of the personalization control group. While in the control group you do not have dimension scores and will not see personalized content. A/B tests will still run." : "You do not have any dimension overrides yet.",
1515
+ buttonGroup: data.controlGroup ? /* @__PURE__ */ jsx19(Button4, { buttonType: "secondary", onClick: toggleControlGroup, children: "Exit control group" }) : null
1516
+ }
1517
+ )
1518
+ ] }) });
1519
+ };
1520
+
1521
+ // src/components/Personalization/Quirks.tsx
1522
+ import { Button as Button6, InputSelect as InputSelect2 } from "@uniformdev/design-system";
1523
+ import { useState as useState3 } from "react";
1524
+
1525
+ // src/components/Inputs/EditableText.tsx
1526
+ import { Button as Button5, Input as Input2 } from "@uniformdev/design-system";
1527
+ import { useEffect, useState as useState2 } from "react";
1528
+ import { jsx as jsx20, jsxs as jsxs10 } from "@emotion/react/jsx-runtime";
1529
+ var EditableText = ({ name, value, submit }) => {
1530
+ const [inputValue, setInputValue] = useState2(value != null ? value : "");
1531
+ useEffect(() => {
1532
+ setInputValue(value != null ? value : "");
1533
+ }, [value]);
1534
+ const onChange = (e) => {
1535
+ setInputValue(e.target.value);
1536
+ };
1537
+ const isSameValue = inputValue === value;
1538
+ return /* @__PURE__ */ jsxs10("div", { css: { display: "flex", gap: "var(--spacing-sm)" }, children: [
1539
+ /* @__PURE__ */ jsx20(Input2, { type: "text", css: [textInput], name, value: inputValue, onChange }),
1540
+ /* @__PURE__ */ jsx20(
1541
+ Button5,
1542
+ {
1543
+ buttonType: "primary",
1544
+ disabled: isSameValue,
1545
+ size: "sm",
1546
+ onClick: () => submit(name, inputValue != null ? inputValue : ""),
1547
+ children: "Save"
1548
+ }
1549
+ )
1550
+ ] });
1551
+ };
1552
+ var EditableText_default = EditableText;
1553
+
1554
+ // src/components/Personalization/Quirks.tsx
1555
+ import { Fragment as Fragment4, jsx as jsx21, jsxs as jsxs11 } from "@emotion/react/jsx-runtime";
1556
+ var Quirks = ({ ...props }) => {
1557
+ const {
1558
+ state: {
1559
+ data: { quirks }
1560
+ },
1561
+ quirksIndex: { index: quirksIndex },
1562
+ settings,
1563
+ saveSettings,
1564
+ actions
1565
+ } = props;
1566
+ const [editable, setEditable] = useState3("");
1567
+ let editableQuirkMetaData;
1568
+ if (editable) {
1569
+ editableQuirkMetaData = quirksIndex[editable];
1570
+ }
1571
+ const submitOverride = async (name, value) => {
1572
+ var _a, _b, _c;
1573
+ setEditable("");
1574
+ const newSettings = {
1575
+ ...settings,
1576
+ quirkOverrides: {
1577
+ ...settings.quirkOverrides,
1578
+ [name]: { initial: (_c = (_b = (_a = settings.quirkOverrides) == null ? void 0 : _a[name]) == null ? void 0 : _b.initial) != null ? _c : quirks[name], override: value }
1579
+ }
1580
+ };
1581
+ await saveSettings(newSettings);
1582
+ const quirkOverrides = applyQuirkOverrides({
1583
+ quirks,
1584
+ quirkOverrides: newSettings.quirkOverrides
1585
+ });
1586
+ await actions.update({ quirks: quirkOverrides });
1587
+ };
1588
+ return /* @__PURE__ */ jsx21(Fragment4, { children: /* @__PURE__ */ jsxs11("article", { css: [styles.page, styles.quirks], children: [
1589
+ /* @__PURE__ */ jsx21("h1", { css: styles.title, children: "Quirks" }),
1590
+ /* @__PURE__ */ jsx21("p", { css: styles.text, children: "Keys defined in Uniform and their current, programmatically defined values for this visit." }),
1591
+ Object.keys(quirksIndex).length ? /* @__PURE__ */ jsxs11(Table, { children: [
1592
+ /* @__PURE__ */ jsx21(THead, { children: /* @__PURE__ */ jsxs11(TRow, { children: [
1593
+ /* @__PURE__ */ jsx21(THeading, { width: "30%", children: "Key" }),
1594
+ /* @__PURE__ */ jsx21(THeading, { width: "50%", children: "Value" }),
1595
+ /* @__PURE__ */ jsx21(THeading, { width: "20%", children: "" })
1596
+ ] }) }),
1597
+ /* @__PURE__ */ jsx21(TBody, { children: Object.values(quirksIndex).map(({ name, value, id }) => {
1598
+ var _a, _b, _c;
1599
+ const initialValue = (_b = (_a = settings.quirkOverrides) == null ? void 0 : _a[name]) == null ? void 0 : _b.initial;
1600
+ let quirkOptions = [];
1601
+ if (editableQuirkMetaData && editableQuirkMetaData.options) {
1602
+ quirkOptions = editableQuirkMetaData.options.map((option) => ({
1603
+ value: option.value,
1604
+ label: option.name
1605
+ }));
1606
+ }
1607
+ return /* @__PURE__ */ jsxs11(TRow, { border: "bottom", children: [
1608
+ /* @__PURE__ */ jsx21(TData, { children: /* @__PURE__ */ jsx21("strong", { children: name }) }),
1609
+ /* @__PURE__ */ jsxs11(TData, { children: [
1610
+ editable !== id ? /* @__PURE__ */ jsxs11(
1611
+ "div",
1612
+ {
1613
+ onClick: () => {
1614
+ setEditable(id);
1615
+ },
1616
+ children: [
1617
+ initialValue ? /* @__PURE__ */ jsx21("div", { children: /* @__PURE__ */ jsx21("s", { children: initialValue }) }) : null,
1618
+ value
1619
+ ]
1620
+ }
1621
+ ) : null,
1622
+ editable === id && editableQuirkMetaData && /* @__PURE__ */ jsx21(Fragment4, { children: editableQuirkMetaData.options ? /* @__PURE__ */ jsx21(
1623
+ InputSelect2,
1624
+ {
1625
+ showLabel: false,
1626
+ label: `Change ${name}`,
1627
+ defaultOption: `Change ${name}`,
1628
+ name: id,
1629
+ onChange: (e) => submitOverride(e.target.name, e.target.value),
1630
+ options: quirkOptions
1631
+ }
1632
+ ) : /* @__PURE__ */ jsx21(EditableText_default, { name: id, value, submit: submitOverride }) })
1633
+ ] }),
1634
+ /* @__PURE__ */ jsx21(TData, { children: editable ? null : ((_c = settings.quirkOverrides) == null ? void 0 : _c[id]) ? /* @__PURE__ */ jsx21(
1635
+ Button6,
1636
+ {
1637
+ buttonType: "ghost",
1638
+ onClick: () => {
1639
+ deleteQuirkOverride({ quirk: id, settings, saveSettings, actions });
1640
+ },
1641
+ children: /* @__PURE__ */ jsx21("small", { children: "Clear Override" })
1642
+ }
1643
+ ) : /* @__PURE__ */ jsx21(
1644
+ Button6,
1645
+ {
1646
+ buttonType: "ghost",
1647
+ onClick: () => {
1648
+ setEditable(id);
1649
+ },
1650
+ children: /* @__PURE__ */ jsx21("small", { children: "Override" })
1651
+ }
1652
+ ) })
1653
+ ] }, id);
1654
+ }) })
1655
+ ] }) : /* @__PURE__ */ jsx21(
1656
+ NoActiveDimensions,
1657
+ {
1658
+ title: "No quirks configured",
1659
+ text: "There are currently no quirks setup. Try to connect to Uniform API to load additional information about Quirks and Quirks without defined value."
1660
+ }
1661
+ )
1662
+ ] }) });
1663
+ };
1664
+
1665
+ // src/components/Personalization/Settings.tsx
1666
+ import { Button as Button7 } from "@uniformdev/design-system";
1667
+ import { Switch as Switch2 } from "@uniformdev/design-system";
1668
+ import { jsx as jsx22, jsxs as jsxs12 } from "@emotion/react/jsx-runtime";
1669
+ var Settings = ({
1670
+ settings,
1671
+ saveSettings,
1672
+ actions,
1673
+ state: { data },
1674
+ clearAllExtensionData
1675
+ }) => {
1676
+ return /* @__PURE__ */ jsxs12("article", { css: [styles.page, { display: "flex", flexDirection: "column", gap: "var(--spacing-base)" }], children: [
1677
+ /* @__PURE__ */ jsx22("h1", { css: styles.title, children: "Settings" }),
1678
+ /* @__PURE__ */ jsxs12(Fieldset, { children: [
1679
+ /* @__PURE__ */ jsx22(Legend, { children: "Data Connection" }),
1680
+ /* @__PURE__ */ jsx22(
1681
+ Button7,
1682
+ {
1683
+ buttonType: "tertiary",
1684
+ onClick: () => {
1685
+ saveSettings({ ...settings, route: "/connect" });
1686
+ },
1687
+ children: "Manage Connection to Uniform"
1688
+ }
1689
+ )
1690
+ ] }),
1691
+ /* @__PURE__ */ jsxs12(Fieldset, { children: [
1692
+ /* @__PURE__ */ jsx22(Legend, { children: "Storage Consent" }),
1693
+ /* @__PURE__ */ jsx22(
1694
+ Switch2,
1695
+ {
1696
+ label: "Store visitor data",
1697
+ id: "consent-mode",
1698
+ name: "consentMode",
1699
+ checked: data.consent,
1700
+ onChange: (e) => {
1701
+ actions.rawUpdate([{ type: "consent", data: e.currentTarget.checked }]);
1702
+ saveSettings({
1703
+ ...settings,
1704
+ consentMode: e.currentTarget.checked
1705
+ });
1706
+ }
1707
+ }
1708
+ ),
1709
+ /* @__PURE__ */ jsx22("p", { children: /* @__PURE__ */ jsx22("small", { children: "Enabling storage consent allows storing behavior in this browser for personalization across sessions. Only affects this browser. Personalization works with this disabled, but dimension scores are lost on refresh." }) })
1710
+ ] }),
1711
+ /* @__PURE__ */ jsxs12(Fieldset, { children: [
1712
+ /* @__PURE__ */ jsx22(Legend, { children: "Logging" }),
1713
+ /* @__PURE__ */ jsx22(
1714
+ Switch2,
1715
+ {
1716
+ label: "Write Uniform Context diagnostic logs to browser console",
1717
+ id: "logging",
1718
+ name: "logging",
1719
+ checked: settings.logLevel === "debug",
1720
+ onChange: (e) => saveSettings({
1721
+ ...settings,
1722
+ logLevel: e.currentTarget.checked ? "debug" : "none"
1723
+ })
1724
+ }
1725
+ )
1726
+ ] }),
1727
+ /* @__PURE__ */ jsxs12(Fieldset, { children: [
1728
+ /* @__PURE__ */ jsx22(Legend, { children: "Clear extension storage" }),
1729
+ /* @__PURE__ */ jsx22(
1730
+ Button7,
1731
+ {
1732
+ onClick: () => {
1733
+ clearAllExtensionData();
1734
+ },
1735
+ children: "Clear"
1736
+ }
1737
+ ),
1738
+ /* @__PURE__ */ jsx22("p", { children: /* @__PURE__ */ jsx22("small", { children: "May be necessary when you have multiple different sites on the same domain name (e.g. http://localhost:3000) and there are some conflicts or other unexpected behaviour." }) })
1739
+ ] })
1740
+ ] });
1741
+ };
1742
+
1743
+ // src/components/QuickConnect/QuickConnect.tsx
1744
+ import { parseQuickConnect } from "@uniformdev/context";
1745
+ import { ApiClientError, UncachedManifestClient } from "@uniformdev/context/api";
1746
+ import { Button as Button8, ErrorMessage as ErrorMessage2, Input as Input3 } from "@uniformdev/design-system";
1747
+ import { Field as Field2, Form as Form2, Formik as Formik2 } from "formik";
1748
+ import * as React5 from "react";
1749
+ import { Fragment as Fragment5, jsx as jsx23, jsxs as jsxs13 } from "@emotion/react/jsx-runtime";
1750
+ function QuickConnect(props) {
1751
+ const [state, setState] = React5.useState(props.currentData ? "c" : "qc");
1752
+ const [error, setError] = React5.useState(void 0);
1753
+ const [manifest, setManifest] = React5.useState(void 0);
1754
+ const fetchManifest = React5.useCallback(async (data) => {
1755
+ const client = new UncachedManifestClient(data);
1756
+ setError(void 0);
1757
+ try {
1758
+ const manifest2 = await client.get({ preview: true });
1759
+ setManifest({ manifest: manifest2, target: data });
1760
+ return manifest2;
1761
+ } catch (e) {
1762
+ if (e instanceof ApiClientError) {
1763
+ if (e.statusCode === 403) {
1764
+ setError(
1765
+ "API key is valid but does not have Context > Read Drafts permission, or the API key does not have permissions to the project, or the project does not exist."
1766
+ );
1767
+ } else {
1768
+ setError(e.errorMessage);
1769
+ }
1770
+ return;
1771
+ }
1772
+ if ("message" in e) {
1773
+ if (e.message === "Failed to fetch") {
1774
+ setError("A network error occurred. Ensure the API host is valid.");
1775
+ } else {
1776
+ setError(e.message);
1777
+ }
1778
+ return;
1779
+ }
1780
+ setError(JSON.stringify(e, null, 2));
1781
+ return;
1782
+ }
1783
+ }, []);
1784
+ React5.useEffect(() => {
1785
+ if (!props.currentData)
1786
+ return;
1787
+ fetchManifest(props.currentData);
1788
+ }, [fetchManifest, props.currentData]);
1789
+ const onConnect = async (data) => {
1790
+ const manifest2 = await fetchManifest(data);
1791
+ if (manifest2) {
1792
+ setState("c");
1793
+ await props.onConnect(data);
1794
+ }
1795
+ };
1796
+ const onDisconnect = () => {
1797
+ if (confirm("Disconnect from Uniform? Make sure to save your API key if you want to reconnect.")) {
1798
+ setState("qc");
1799
+ setManifest(void 0);
1800
+ setError(void 0);
1801
+ props.onConnect(null);
1802
+ }
1803
+ };
1804
+ return /* @__PURE__ */ jsxs13("div", { children: [
1805
+ error ? /* @__PURE__ */ jsxs13(Fragment5, { children: [
1806
+ /* @__PURE__ */ jsx23(ErrorMessage2, { message: error }),
1807
+ /* @__PURE__ */ jsx23(Button8, { buttonType: "secondary", type: "button", onClick: onDisconnect, children: "Clear old/broken settings" })
1808
+ ] }) : null,
1809
+ state === "qc" || state === "mc" ? /* @__PURE__ */ jsx23(ConnectForm, { ...props, state, setState, onConnect }) : /* @__PURE__ */ jsx23("div", { children: manifest ? /* @__PURE__ */ jsxs13(Fragment5, { children: [
1810
+ /* @__PURE__ */ jsxs13("p", { children: [
1811
+ "Connected to",
1812
+ " ",
1813
+ /* @__PURE__ */ jsx23(
1814
+ "a",
1815
+ {
1816
+ href: `${manifest == null ? void 0 : manifest.target.apiHost}/projects/${manifest == null ? void 0 : manifest.target.projectId}`,
1817
+ target: "_blank",
1818
+ rel: "noopener noreferrer",
1819
+ css: { textDecoration: "underline" },
1820
+ children: /* @__PURE__ */ jsx23("strong", { children: manifest == null ? void 0 : manifest.manifest.project.name })
1821
+ }
1822
+ ),
1823
+ " ",
1824
+ /* @__PURE__ */ jsxs13("small", { children: [
1825
+ "(",
1826
+ manifest == null ? void 0 : manifest.manifest.project.id,
1827
+ ")"
1828
+ ] })
1829
+ ] }),
1830
+ /* @__PURE__ */ jsx23(Button8, { buttonType: "secondary", type: "button", onClick: onDisconnect, children: "Disconnect" })
1831
+ ] }) : null })
1832
+ ] });
1833
+ }
1834
+ function ConnectForm({
1835
+ setState,
1836
+ state,
1837
+ currentData,
1838
+ onConnect
1839
+ }) {
1840
+ var _a, _b, _c;
1841
+ return /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
1842
+ Formik2,
1843
+ {
1844
+ initialValues: {
1845
+ apiHost: (_a = currentData == null ? void 0 : currentData.apiHost) != null ? _a : "https://uniform.app",
1846
+ apiKey: (_b = currentData == null ? void 0 : currentData.apiKey) != null ? _b : "",
1847
+ projectId: (_c = currentData == null ? void 0 : currentData.projectId) != null ? _c : "",
1848
+ qc: ""
1849
+ },
1850
+ onSubmit: onConnect,
1851
+ children: ({ setFieldValue, setFieldError, errors: { qc }, isSubmitting }) => /* @__PURE__ */ jsx23(Form2, { children: /* @__PURE__ */ jsx23("fieldset", { css: { display: "flex", flexDirection: "column", gap: "var(--spacing-base)" }, children: state === "qc" ? /* @__PURE__ */ jsxs13(Fragment5, { children: [
1852
+ /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
1853
+ Input3,
1854
+ {
1855
+ placeholder: "Paste Quick Connect Code Here",
1856
+ caption: "Copy the Quick Connect code after creating an API key in Uniform.",
1857
+ errorMessage: qc,
1858
+ onChange: (e) => {
1859
+ try {
1860
+ const qc2 = parseQuickConnect(e.currentTarget.value);
1861
+ setFieldValue("apiHost", qc2.apiHost);
1862
+ setFieldValue("apiKey", qc2.apiKey);
1863
+ setFieldValue("projectId", qc2.projectId);
1864
+ } catch (e2) {
1865
+ setFieldError("qc", e2.message);
1866
+ }
1867
+ }
1868
+ }
1869
+ ) }),
1870
+ /* @__PURE__ */ jsxs13("section", { css: { display: "flex", gap: "var(--spacing-sm)" }, children: [
1871
+ /* @__PURE__ */ jsx23(Button8, { type: "submit", buttonType: "primary", disabled: isSubmitting, children: isSubmitting ? "Verifying..." : "Connect" }),
1872
+ /* @__PURE__ */ jsx23(
1873
+ Button8,
1874
+ {
1875
+ type: "button",
1876
+ buttonType: "ghost",
1877
+ onClick: () => setState("mc"),
1878
+ disabled: isSubmitting,
1879
+ children: "Connect Manually"
1880
+ }
1881
+ )
1882
+ ] })
1883
+ ] }) : /* @__PURE__ */ jsxs13(Fragment5, { children: [
1884
+ /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
1885
+ Field2,
1886
+ {
1887
+ component: FormikInput,
1888
+ label: "API Key",
1889
+ name: "apiKey",
1890
+ caption: "Generate an API key in your Uniform team settings."
1891
+ }
1892
+ ) }),
1893
+ /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
1894
+ Field2,
1895
+ {
1896
+ component: FormikInput,
1897
+ label: "Project ID",
1898
+ name: "projectId",
1899
+ caption: "Available to copy after generating an API key"
1900
+ }
1901
+ ) }),
1902
+ /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
1903
+ Field2,
1904
+ {
1905
+ component: FormikInput,
1906
+ label: "API Host",
1907
+ name: "apiHost",
1908
+ caption: "Use a non-standard Uniform API endpoint. Most people will not not need this option."
1909
+ }
1910
+ ) }),
1911
+ /* @__PURE__ */ jsxs13("section", { css: { display: "flex", gap: "var(--spacing-sm)" }, children: [
1912
+ /* @__PURE__ */ jsx23(Button8, { type: "submit", buttonType: "primary", disabled: isSubmitting, children: isSubmitting ? "Verifying..." : "Connect" }),
1913
+ /* @__PURE__ */ jsx23(
1914
+ Button8,
1915
+ {
1916
+ type: "button",
1917
+ buttonType: "ghost",
1918
+ onClick: () => setState("qc"),
1919
+ disabled: isSubmitting,
1920
+ children: "Use Quick Connect"
1921
+ }
1922
+ )
1923
+ ] })
1924
+ ] }) }) })
1925
+ }
1926
+ ) });
1927
+ }
1928
+
1929
+ // src/components/QuickConnect/ConnectRoute.tsx
1930
+ import { jsx as jsx24, jsxs as jsxs14 } from "@emotion/react/jsx-runtime";
1931
+ var ConnectRoute = ({ settings, saveSettings }) => {
1932
+ const currentData = settings.apiKey && settings.projectId ? { apiKey: settings.apiKey, projectId: settings.projectId, apiHost: settings.apiHost } : void 0;
1933
+ return /* @__PURE__ */ jsxs14("article", { css: styles.page, children: [
1934
+ /* @__PURE__ */ jsx24("h1", { css: styles.title, children: "Connect to a Uniform Project" }),
1935
+ /* @__PURE__ */ jsx24("p", { css: styles.text, children: /* @__PURE__ */ jsx24("small", { children: "Adding an API key and project ID enables human-readable dimension labels to be shown. You must have access to the Uniform project to do this." }) }),
1936
+ /* @__PURE__ */ jsx24(
1937
+ QuickConnect,
1938
+ {
1939
+ onConnect: async (data) => {
1940
+ if (data) {
1941
+ await saveSettings({
1942
+ ...settings,
1943
+ apiKey: data.apiKey,
1944
+ projectId: data.projectId,
1945
+ apiHost: data.apiHost
1946
+ });
1947
+ } else {
1948
+ await saveSettings({
1949
+ ...settings,
1950
+ apiKey: void 0,
1951
+ projectId: void 0,
1952
+ apiHost: void 0
1953
+ });
1954
+ }
1955
+ },
1956
+ currentData
1957
+ }
1958
+ )
1959
+ ] });
1960
+ };
1961
+
1962
+ // src/components/StatusPages/AdditionalDataLoading.tsx
1963
+ import { useEffect as useEffect3, useState as useState5 } from "react";
1964
+ import { useMountedState } from "react-use";
1965
+ import { jsx as jsx25, jsxs as jsxs15 } from "@emotion/react/jsx-runtime";
1966
+ var AdditionalDataLoading = () => {
1967
+ const [viz, setViz] = useState5(false);
1968
+ const mounted = useMountedState();
1969
+ useEffect3(() => {
1970
+ setTimeout(() => {
1971
+ if (mounted()) {
1972
+ setViz(true);
1973
+ }
1974
+ }, 1e3);
1975
+ }, [mounted]);
1976
+ return viz ? /* @__PURE__ */ jsxs15("article", { css: styles.page, children: [
1977
+ /* @__PURE__ */ jsx25("h1", { children: "Loading..." }),
1978
+ /* @__PURE__ */ jsx25("p", { children: "Connecting to Uniform API for complete data." })
1979
+ ] }) : null;
1980
+ };
1981
+
1982
+ // src/components/StatusPages/NotFound.tsx
1983
+ import { jsx as jsx26, jsxs as jsxs16 } from "@emotion/react/jsx-runtime";
1984
+ var NotFound = () => {
1985
+ return /* @__PURE__ */ jsxs16("article", { children: [
1986
+ /* @__PURE__ */ jsx26("h1", { children: "Something when wrong" }),
1987
+ /* @__PURE__ */ jsx26("p", { children: "We could not find the page you're looking for." })
1988
+ ] });
1989
+ };
1990
+
1991
+ // src/components/ContextDevTools.tsx
1992
+ import { jsx as jsx27, jsxs as jsxs17 } from "@emotion/react/jsx-runtime";
1993
+ var mainLayoutStyle = css12`
428
1994
  background: var(--white);
429
1995
  padding: var(--spacing-base);
430
1996
  overflow-y: auto;
@@ -453,7 +2019,51 @@ to {
453
2019
  &::-webkit-scrollbar-thumb:hover {
454
2020
  background: var(--gray-500);
455
2021
  }
456
- `;function Et(e){let o=Qe(e.settings,e.state.manifest),r=Fe(e.settings,e.state.data.quirks),t={...e,dimensionIndex:o,quirksIndex:r},n=()=>{var s;if(o.loading||r.loading)return S(Pt,{});if(e.settings.route&&e.settings.route.match(/overrides\/\w+/))return S(Ve,{...t});switch((s=e.settings)==null?void 0:s.route){case void 0:case"/":case"/dimensions":return S(ft,{...t});case"/overrides":return S(xt,{...t});case"/overrides/add":return S(Ve,{...t});case"/quirks":return S(Tt,{...t});case"/settings":return S(Lt,{...t});case"/connect":return S(Rt,{...t});default:return S(Ht,{})}};return He(Ne,{settings:e.settings,saveSettings:e.saveSettings,children:[S(sr,{}),S(le,{}),He("div",{css:Mt`
2022
+ `;
2023
+ function ContextDevTools(props) {
2024
+ const dimensionIndex = useDimensionIndex(props.settings, props.state.manifest);
2025
+ const quirksIndex = useQuirkIndex(props.settings, props.state.data.quirks);
2026
+ const routeProps = {
2027
+ ...props,
2028
+ dimensionIndex,
2029
+ quirksIndex
2030
+ };
2031
+ const component = () => {
2032
+ var _a;
2033
+ if (dimensionIndex.loading || quirksIndex.loading) {
2034
+ return /* @__PURE__ */ jsx27(AdditionalDataLoading, {});
2035
+ }
2036
+ if (props.settings.route) {
2037
+ if (props.settings.route.match(/overrides\/\w+/)) {
2038
+ return /* @__PURE__ */ jsx27(AddOverride, { ...routeProps });
2039
+ }
2040
+ }
2041
+ switch ((_a = props.settings) == null ? void 0 : _a.route) {
2042
+ case void 0:
2043
+ case "/":
2044
+ case "/dimensions":
2045
+ return /* @__PURE__ */ jsx27(Dimensions, { ...routeProps });
2046
+ case "/overrides":
2047
+ return /* @__PURE__ */ jsx27(Overrides, { ...routeProps });
2048
+ case "/overrides/add":
2049
+ return /* @__PURE__ */ jsx27(AddOverride, { ...routeProps });
2050
+ case "/quirks":
2051
+ return /* @__PURE__ */ jsx27(Quirks, { ...routeProps });
2052
+ case "/settings":
2053
+ return /* @__PURE__ */ jsx27(Settings, { ...routeProps });
2054
+ case "/connect":
2055
+ return /* @__PURE__ */ jsx27(ConnectRoute, { ...routeProps });
2056
+ default:
2057
+ return /* @__PURE__ */ jsx27(NotFound, {});
2058
+ }
2059
+ };
2060
+ return /* @__PURE__ */ jsxs17(DevToolsSettingsContextProvider, { settings: props.settings, saveSettings: props.saveSettings, children: [
2061
+ /* @__PURE__ */ jsx27(DesignSystemTheme, {}),
2062
+ /* @__PURE__ */ jsx27(Theme, {}),
2063
+ /* @__PURE__ */ jsxs17(
2064
+ "div",
2065
+ {
2066
+ css: css12`
457
2067
  display: grid;
458
2068
  grid-template-columns: 200px auto;
459
2069
  font-weight: var(--fs-base);
@@ -462,7 +2072,157 @@ to {
462
2072
  line-height: var(--base-line-height);
463
2073
  height: var(--min-height);
464
2074
  min-width: var(--site-width);
465
- `,children:[S(Ge,{...e}),He("main",{css:ar,children:[S(Se,{...e}),n()]})]})]})}import{Context as cr,createDebugConsoleLogDrain as lr}from"@uniformdev/context";import*as E from"react";import{jsx as At}from"@emotion/react/jsx-runtime";var Me="embeddedUniformDevToolsSettings";function Bt({context:e,initialSettings:o}){let r=e!=null?e:typeof window!="undefined"?window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__:void 0,t=r!=null?r:new cr({manifest:{project:{}}}),[n,s]=E.useState({data:t.storage.data,manifest:t.manifest.data,scores:t.scores,personalizations:[],tests:[]}),[l,d]=E.useState(o!=null?o:{});E.useEffect(()=>{var c;let a=lr((c=l.logLevel)!=null?c:"none");return t.events.on("log",a),()=>{t.events.off("log",a)}},[l,t]),E.useEffect(()=>{let a=()=>{let u=window.localStorage.getItem(Me)||"{}",f=JSON.parse(u),C=ge({quirks:t.storage.data.quirks,quirkOverrides:f.quirkOverrides});C&&(console.log("Applying overridden quirks:",C),t.update({quirks:C}));let w=ne({scores:t.scores,scoreOverrides:f.scoreOverrides});w.length&&(console.log("Applying overridden scores:",w),t.storage.updateData(w)),s(k=>({...k,scores:t.scores,data:t.storage.data,manifest:t.manifest.data}))},c=u=>{!u.changed||s(f=>({...f,personalizations:[...f.personalizations,u]}))},v=u=>{!u.variantAssigned||s(f=>({...f,tests:[...f.tests,u]}))};return t.events.on("personalizationResult",c),t.events.on("testResult",v),t.storage.events.on("*",a),()=>{t.storage.events.off("*",a),t.events.off("personalizationResult",c),t.events.off("testResult",v)}},[t]),E.useEffect(()=>{if(window.localStorage){let a=window.localStorage.getItem(Me);if(a)try{let c=JSON.parse(a),v={...o,...c};d(v);let u=ne({scores:n.scores,scoreOverrides:v.scoreOverrides});p.rawUpdate(u)}catch(c){window.localStorage.removeItem(Me),console.error("Failed to parse settings from localStorage: ",c.message)}}},[]);let{actions:p,saveSettings:m,clearAllExtensionData:i}=E.useMemo(()=>({actions:{update:u=>t.update(u),forget:()=>t.forget(!1),rawUpdate:u=>t.storage.updateData(u)},saveSettings:async u=>{d(u),window.localStorage&&window.localStorage.setItem("embeddedUniformDevToolsSettings",JSON.stringify(u))},clearAllExtensionData:async()=>{d({route:"/"}),window.localStorage&&(window.localStorage.removeItem("embeddedUniformDevToolsSettings"),window.location.reload())}}),[t]);return r?At(Et,{state:n,actions:p,settings:l,saveSettings:m,clearAllExtensionData:i}):At("p",{children:"Unable to find Uniform Context. Ensure the devtools plugin is activated."})}import{css as Ee}from"@emotion/react";import{Button as mr,Callout as ur,Paragraph as gr,Theme as vr}from"@uniformdev/design-system";import*as U from"react";import{useLocalStorage as fr}from"react-use";import{css as dr}from"@emotion/react";import{jsx as De,jsxs as Qt}from"@emotion/react/jsx-runtime";var pr=dr`
2075
+ `,
2076
+ children: [
2077
+ /* @__PURE__ */ jsx27(Menu, { ...props }),
2078
+ /* @__PURE__ */ jsxs17("main", { css: mainLayoutStyle, children: [
2079
+ /* @__PURE__ */ jsx27(ConnectApiKey, { ...props }),
2080
+ component()
2081
+ ] })
2082
+ ]
2083
+ }
2084
+ )
2085
+ ] });
2086
+ }
2087
+
2088
+ // src/components/EmbeddedContextDevTools.tsx
2089
+ import {
2090
+ Context as Context2,
2091
+ createDebugConsoleLogDrain
2092
+ } from "@uniformdev/context";
2093
+ import * as React6 from "react";
2094
+ import { jsx as jsx28 } from "@emotion/react/jsx-runtime";
2095
+ var LOCAL_STORAGE_SETTINGS_KEY = "embeddedUniformDevToolsSettings";
2096
+ function EmbeddedContextDevTools({ context, initialSettings }) {
2097
+ const contextValue = context != null ? context : typeof window !== "undefined" ? window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__ : void 0;
2098
+ const contextInstance = contextValue != null ? contextValue : new Context2({ manifest: { project: {} } });
2099
+ const [state, setState] = React6.useState({
2100
+ data: contextInstance.storage.data,
2101
+ manifest: contextInstance.manifest.data,
2102
+ scores: contextInstance.scores,
2103
+ personalizations: [],
2104
+ tests: []
2105
+ });
2106
+ const [settings, setSettings] = React6.useState(initialSettings != null ? initialSettings : {});
2107
+ React6.useEffect(() => {
2108
+ var _a;
2109
+ const drain = createDebugConsoleLogDrain((_a = settings.logLevel) != null ? _a : "none");
2110
+ contextInstance.events.on("log", drain);
2111
+ return () => {
2112
+ contextInstance.events.off("log", drain);
2113
+ };
2114
+ }, [settings, contextInstance]);
2115
+ React6.useEffect(() => {
2116
+ const onContextDataUpdated = () => {
2117
+ const settingsJson = window.localStorage.getItem(LOCAL_STORAGE_SETTINGS_KEY) || "{}";
2118
+ const currentSettings = JSON.parse(settingsJson);
2119
+ const quirkOverrides = applyQuirkOverrides({
2120
+ quirks: contextInstance.storage.data.quirks,
2121
+ quirkOverrides: currentSettings.quirkOverrides
2122
+ });
2123
+ if (quirkOverrides) {
2124
+ console.log("Applying overridden quirks:", quirkOverrides);
2125
+ contextInstance.update({ quirks: quirkOverrides });
2126
+ }
2127
+ const overrideCommands = applyScoreOverrides({
2128
+ scores: contextInstance.scores,
2129
+ scoreOverrides: currentSettings.scoreOverrides
2130
+ });
2131
+ if (overrideCommands.length) {
2132
+ console.log("Applying overridden scores:", overrideCommands);
2133
+ contextInstance.storage.updateData(overrideCommands);
2134
+ }
2135
+ setState((old) => ({
2136
+ ...old,
2137
+ scores: contextInstance.scores,
2138
+ data: contextInstance.storage.data,
2139
+ manifest: contextInstance.manifest.data
2140
+ }));
2141
+ };
2142
+ const onPersonalizationResult = (e) => {
2143
+ if (!e.changed)
2144
+ return;
2145
+ setState((old) => ({ ...old, personalizations: [...old.personalizations, e] }));
2146
+ };
2147
+ const onTestResult = (e) => {
2148
+ if (!e.variantAssigned)
2149
+ return;
2150
+ setState((old) => ({ ...old, tests: [...old.tests, e] }));
2151
+ };
2152
+ contextInstance.events.on("personalizationResult", onPersonalizationResult);
2153
+ contextInstance.events.on("testResult", onTestResult);
2154
+ contextInstance.storage.events.on("*", onContextDataUpdated);
2155
+ return () => {
2156
+ contextInstance.storage.events.off("*", onContextDataUpdated);
2157
+ contextInstance.events.off("personalizationResult", onPersonalizationResult);
2158
+ contextInstance.events.off("testResult", onTestResult);
2159
+ };
2160
+ }, [contextInstance]);
2161
+ React6.useEffect(() => {
2162
+ if (window.localStorage) {
2163
+ const settingsJson = window.localStorage.getItem(LOCAL_STORAGE_SETTINGS_KEY);
2164
+ if (settingsJson) {
2165
+ try {
2166
+ const parsedSettings = JSON.parse(settingsJson);
2167
+ const newSettings = { ...initialSettings, ...parsedSettings };
2168
+ setSettings(newSettings);
2169
+ const applyCommands = applyScoreOverrides({
2170
+ scores: state.scores,
2171
+ scoreOverrides: newSettings.scoreOverrides
2172
+ });
2173
+ actions.rawUpdate(applyCommands);
2174
+ } catch (e) {
2175
+ window.localStorage.removeItem(LOCAL_STORAGE_SETTINGS_KEY);
2176
+ console.error("Failed to parse settings from localStorage: ", e.message);
2177
+ }
2178
+ }
2179
+ }
2180
+ }, []);
2181
+ const { actions, saveSettings, clearAllExtensionData } = React6.useMemo(() => {
2182
+ const actions2 = {
2183
+ update: (up) => contextInstance.update(up),
2184
+ forget: () => contextInstance.forget(false),
2185
+ rawUpdate: (commands) => contextInstance.storage.updateData(commands)
2186
+ };
2187
+ const saveSettings2 = async (settings2) => {
2188
+ setSettings(settings2);
2189
+ if (window.localStorage) {
2190
+ window.localStorage.setItem("embeddedUniformDevToolsSettings", JSON.stringify(settings2));
2191
+ }
2192
+ };
2193
+ const clearAllExtensionData2 = async () => {
2194
+ setSettings({
2195
+ route: "/"
2196
+ });
2197
+ if (window.localStorage) {
2198
+ window.localStorage.removeItem("embeddedUniformDevToolsSettings");
2199
+ window.location.reload();
2200
+ }
2201
+ };
2202
+ return { actions: actions2, saveSettings: saveSettings2, clearAllExtensionData: clearAllExtensionData2 };
2203
+ }, [contextInstance]);
2204
+ return contextValue ? /* @__PURE__ */ jsx28(
2205
+ ContextDevTools,
2206
+ {
2207
+ state,
2208
+ actions,
2209
+ settings,
2210
+ saveSettings,
2211
+ clearAllExtensionData
2212
+ }
2213
+ ) : /* @__PURE__ */ jsx28("p", { children: "Unable to find Uniform Context. Ensure the devtools plugin is activated." });
2214
+ }
2215
+
2216
+ // src/components/ToggleEmbeddedContextDevTools.tsx
2217
+ import { css as css14 } from "@emotion/react";
2218
+ import { Button as Button9, Callout, Paragraph, Theme as DesignSystemTheme2 } from "@uniformdev/design-system";
2219
+ import * as React7 from "react";
2220
+ import { useLocalStorage } from "react-use";
2221
+
2222
+ // src/components/EmbedToggleButton/EmbedToggleButton.tsx
2223
+ import { css as css13 } from "@emotion/react";
2224
+ import { jsx as jsx29, jsxs as jsxs18 } from "@emotion/react/jsx-runtime";
2225
+ var btnStyle2 = css13`
466
2226
  align-items: center;
467
2227
  border-radius: var(--rounded-full);
468
2228
  background: var(--brand-secondary-5);
@@ -488,15 +2248,106 @@ to {
488
2248
  max-width: 100%;
489
2249
  height: auto;
490
2250
  }
491
- `,Ft=({...e})=>Qt("button",{type:"button",css:pr,...e,children:[De("span",{hidden:!0,children:"Uniform devtools"}),Qt("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[De("path",{d:"M13.325 3.05011L8.66741 20.4323L10.5993 20.9499L15.2568 3.56775L13.325 3.05011Z",fill:"currentColor"}),De("path",{d:"M7.61197 18.3608L8.97136 16.9124L8.97086 16.8933L3.87657 12.1121L8.66699 7.00798L7.20868 5.63928L1.04956 12.2017L7.61197 18.3608Z",fill:"currentColor"}),De("path",{d:"M16.388 18.3608L15.0286 16.9124L15.0291 16.8933L20.1234 12.1121L15.333 7.00798L16.7913 5.63928L22.9504 12.2017L16.388 18.3608Z",fill:"currentColor"})]})]});import{jsx as A,jsxs as qt}from"@emotion/react/jsx-runtime";var hr="dblgnkbknchechcibdojfdoeeodhmgbd",br="dcmlokofjljnfjcknpmhjocogllfbhkg";function Os(e){let[o,r]=U.useState(!1),[t,n]=U.useState(e.context),[s,l]=U.useState(!1),[d,p]=fr("isUniformInlineDevtoolsDisabled",!1);return U.useEffect(()=>{!e.context&&typeof document!="undefined"&&n(window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__)},[e.context]),U.useEffect(()=>{[br,hr].map(m=>{let i=new Image;i.src=`chrome-extension://${m}/icons/uniform-logo.png`,i.onload=()=>l(!0)})},[]),d?null:t?qt("div",{children:[A(vr,{}),A(le,{}),A(Ft,{onClick:()=>r(m=>!m)}),o?A("div",{css:Ee`
2251
+ `;
2252
+ var EmbedToggleButton = ({ ...props }) => {
2253
+ return /* @__PURE__ */ jsxs18("button", { type: "button", css: btnStyle2, ...props, children: [
2254
+ /* @__PURE__ */ jsx29("span", { hidden: true, children: "Uniform devtools" }),
2255
+ /* @__PURE__ */ jsxs18("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
2256
+ /* @__PURE__ */ jsx29(
2257
+ "path",
2258
+ {
2259
+ d: "M13.325 3.05011L8.66741 20.4323L10.5993 20.9499L15.2568 3.56775L13.325 3.05011Z",
2260
+ fill: "currentColor"
2261
+ }
2262
+ ),
2263
+ /* @__PURE__ */ jsx29(
2264
+ "path",
2265
+ {
2266
+ d: "M7.61197 18.3608L8.97136 16.9124L8.97086 16.8933L3.87657 12.1121L8.66699 7.00798L7.20868 5.63928L1.04956 12.2017L7.61197 18.3608Z",
2267
+ fill: "currentColor"
2268
+ }
2269
+ ),
2270
+ /* @__PURE__ */ jsx29(
2271
+ "path",
2272
+ {
2273
+ d: "M16.388 18.3608L15.0286 16.9124L15.0291 16.8933L20.1234 12.1121L15.333 7.00798L16.7913 5.63928L22.9504 12.2017L16.388 18.3608Z",
2274
+ fill: "currentColor"
2275
+ }
2276
+ )
2277
+ ] })
2278
+ ] });
2279
+ };
2280
+
2281
+ // src/components/ToggleEmbeddedContextDevTools.tsx
2282
+ import { jsx as jsx30, jsxs as jsxs19 } from "@emotion/react/jsx-runtime";
2283
+ var localChromex = "dblgnkbknchechcibdojfdoeeodhmgbd";
2284
+ var prodChromex = "dcmlokofjljnfjcknpmhjocogllfbhkg";
2285
+ function ToggleEmbeddedContextDevTools(props) {
2286
+ const [devtoolsOpen, setDevtoolsOpen] = React7.useState(false);
2287
+ const [contextValue, setContextValue] = React7.useState(props.context);
2288
+ const [extensionExists, setExtensionExists] = React7.useState(false);
2289
+ const [isUniformInlineDevtoolsDisabled, setUniformInlineDevtoolsDisabled] = useLocalStorage(
2290
+ "isUniformInlineDevtoolsDisabled",
2291
+ false
2292
+ );
2293
+ React7.useEffect(() => {
2294
+ if (!props.context && typeof document !== "undefined") {
2295
+ setContextValue(window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__);
2296
+ }
2297
+ }, [props.context]);
2298
+ React7.useEffect(() => {
2299
+ [prodChromex, localChromex].map((extensionId) => {
2300
+ const img = new Image();
2301
+ img.src = `chrome-extension://${extensionId}/icons/uniform-logo.png`;
2302
+ img.onload = () => setExtensionExists(true);
2303
+ });
2304
+ }, []);
2305
+ if (isUniformInlineDevtoolsDisabled) {
2306
+ return null;
2307
+ }
2308
+ return contextValue ? /* @__PURE__ */ jsxs19("div", { children: [
2309
+ /* @__PURE__ */ jsx30(DesignSystemTheme2, {}),
2310
+ /* @__PURE__ */ jsx30(Theme, {}),
2311
+ /* @__PURE__ */ jsx30(EmbedToggleButton, { onClick: () => setDevtoolsOpen((prev) => !prev) }),
2312
+ devtoolsOpen ? /* @__PURE__ */ jsx30(
2313
+ "div",
2314
+ {
2315
+ css: css14`
492
2316
  box-shadow: var(--shadow-base);
493
2317
  position: fixed;
494
2318
  bottom: 82px;
495
2319
  right: var(--spacing-base);
496
2320
  z-index: var(--z-10);
497
2321
  max-width: var(--site-width);
498
- `,children:s?A("div",{css:Ee`
2322
+ `,
2323
+ children: extensionExists ? /* @__PURE__ */ jsx30(
2324
+ "div",
2325
+ {
2326
+ css: css14`
499
2327
  padding: var(--spacing-md);
500
- `,children:qt(ur,{type:"danger",title:"This functionality is disabled.",children:[A(gr,{children:"We detected you already use the Uniform Context browser extension. Using both tools is not supported. Please use the functionality of the browser extension instead."}),A(mr,{css:Ee`
2328
+ `,
2329
+ children: /* @__PURE__ */ jsxs19(Callout, { type: "danger", title: "This functionality is disabled.", children: [
2330
+ /* @__PURE__ */ jsx30(Paragraph, { children: "We detected you already use the Uniform Context browser extension. Using both tools is not supported. Please use the functionality of the browser extension instead." }),
2331
+ /* @__PURE__ */ jsx30(
2332
+ Button9,
2333
+ {
2334
+ css: css14`
501
2335
  margin-top: var(--spacing-md);
502
- `,buttonType:"secondary",onClick:()=>p(!0),children:"Disabled inline tools"})]})}):A(Bt,{...e})}):null]}):A("p",{children:"Unable to find Uniform Context. Ensure the devtools plugin is activated."})}export{Et as ContextDevTools,Bt as EmbeddedContextDevTools,Os as ToggleEmbeddedContextDevTools};
2336
+ `,
2337
+ buttonType: "secondary",
2338
+ onClick: () => setUniformInlineDevtoolsDisabled(true),
2339
+ children: "Disabled inline tools"
2340
+ }
2341
+ )
2342
+ ] })
2343
+ }
2344
+ ) : /* @__PURE__ */ jsx30(EmbeddedContextDevTools, { ...props })
2345
+ }
2346
+ ) : null
2347
+ ] }) : /* @__PURE__ */ jsx30("p", { children: "Unable to find Uniform Context. Ensure the devtools plugin is activated." });
2348
+ }
2349
+ export {
2350
+ ContextDevTools,
2351
+ EmbeddedContextDevTools,
2352
+ ToggleEmbeddedContextDevTools
2353
+ };