@uniformdev/context-devtools 14.2.1-alpha.34 → 15.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/index.js CHANGED
@@ -1,4 +1,86 @@
1
- var Ft=Object.create;var B=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Nt=Object.getPrototypeOf,Ot=Object.prototype.hasOwnProperty;var ct=e=>B(e,"__esModule",{value:!0});var _t=(e,r)=>{for(var n in r)B(e,n,{get:r[n],enumerable:!0})},lt=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ut(r))!Ot.call(e,a)&&(n||a!=="default")&&B(e,a,{get:()=>r[a],enumerable:!(o=Zt(r,a))||o.enumerable});return e},T=(e,r)=>lt(ct(B(e!=null?Ft(Nt(e)):{},"default",!r&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),Gt=(e=>(r,n)=>e&&e.get(r)||(n=lt(ct({}),r,1),e&&e.set(r,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var ae={};_t(ae,{ContextDevTools:()=>it,EmbeddedContextDevTools:()=>st,ToggleEmbeddedContextDevTools:()=>ne});var t=require("@emotion/react"),d=T(require("react"));var R=require("@emotion/react"),Kt=[{title:"Dimensions",href:"/dimensions",icon:`<svg
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+
29
+ // src/index.ts
30
+ var src_exports = {};
31
+ __export(src_exports, {
32
+ ContextDevTools: () => ContextDevTools,
33
+ EmbeddedContextDevTools: () => EmbeddedContextDevTools,
34
+ ToggleEmbeddedContextDevTools: () => ToggleEmbeddedContextDevTools
35
+ });
36
+
37
+ // ../../scripts/emotion-jsx-shim.js
38
+ var import_react = require("@emotion/react");
39
+ var React = __toESM(require("react"));
40
+
41
+ // src/components/Navigation/Menu.tsx
42
+ var import_react3 = require("@emotion/react");
43
+
44
+ // src/lib/DevToolsSettingsContext.tsx
45
+ var import_react2 = require("react");
46
+ var DevToolsSettingsContext = (0, import_react2.createContext)({
47
+ settings: {},
48
+ saveSettings: () => null
49
+ });
50
+ var useDevToolsSettingsContext = () => (0, import_react2.useContext)(DevToolsSettingsContext);
51
+ var DevToolsSettingsContextProvider = ({
52
+ children,
53
+ settings,
54
+ saveSettings
55
+ }) => {
56
+ return /* @__PURE__ */ (0, import_react.jsx)(DevToolsSettingsContext.Provider, {
57
+ value: {
58
+ settings,
59
+ saveSettings
60
+ }
61
+ }, children);
62
+ };
63
+
64
+ // src/components/Navigation/NavigationLink.tsx
65
+ var NavigationLink = ({ route, children, className }) => {
66
+ const { settings, saveSettings } = useDevToolsSettingsContext();
67
+ return /* @__PURE__ */ (0, import_react.jsx)("a", {
68
+ href: "",
69
+ className,
70
+ onClick: (e) => {
71
+ e.preventDefault();
72
+ saveSettings({ ...settings, route });
73
+ }
74
+ }, children);
75
+ };
76
+ var NavigationLink_default = NavigationLink;
77
+
78
+ // src/components/Navigation/Menu.tsx
79
+ var links = [
80
+ {
81
+ title: "Dimensions",
82
+ href: "/dimensions",
83
+ icon: `<svg
2
84
  width="24"
3
85
  height="24"
4
86
  viewBox="0 0 24 24"
@@ -15,7 +97,20 @@ var Ft=Object.create;var B=Object.defineProperty;var Zt=Object.getOwnPropertyDes
15
97
  fill="currentColor"
16
98
  />
17
99
  </svg>
18
- `},{title:"Quirks",href:"/quirks",icon:`<svg
100
+ `
101
+ },
102
+ {
103
+ title: "What if?",
104
+ href: "/overrides",
105
+ icon: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
106
+ <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"/>
107
+ </svg>
108
+ `
109
+ },
110
+ {
111
+ title: "Quirks",
112
+ href: "/quirks",
113
+ icon: `<svg
19
114
  width="24"
20
115
  height="24"
21
116
  viewBox="0 0 24 24"
@@ -30,53 +125,151 @@ var Ft=Object.create;var B=Object.defineProperty;var Zt=Object.getOwnPropertyDes
30
125
  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"
31
126
  fill="currentColor"
32
127
  />
33
- </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">
128
+ </svg>`
129
+ },
130
+ {
131
+ title: "Settings",
132
+ href: "/settings",
133
+ icon: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
34
134
  <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"/>
35
135
  </svg>
36
- `}],pt=({...e})=>{let r=o=>{if(o.preventDefault(),o.currentTarget.pathname)return e.saveSettings({...e.settings,route:o.currentTarget.pathname})},n=o=>{var i;let a="active";return!((i=e.settings)==null?void 0:i.route)&&o==="/dimensions"||e.settings.route===o?a:""};return(0,t.jsx)("nav",{css:R.css`
136
+ `
137
+ }
138
+ ];
139
+ var Menu = ({ ...props }) => {
140
+ const isActivePath = (href) => {
141
+ var _a;
142
+ const cssName = "active";
143
+ if (!((_a = props.settings) == null ? void 0 : _a.route) && href === "/dimensions") {
144
+ return cssName;
145
+ }
146
+ return props.settings.route === href ? cssName : "";
147
+ };
148
+ return /* @__PURE__ */ (0, import_react.jsx)("nav", {
149
+ css: import_react3.css`
37
150
  background: var(--brand-secondary-1);
38
151
  padding: var(--spacing-base);
39
152
  min-width: 200px;
40
- `},(0,t.jsx)("a",{css:R.css`
153
+ `
154
+ }, /* @__PURE__ */ (0, import_react.jsx)(NavigationLink_default, {
155
+ css: import_react3.css`
41
156
  display: inline-block;
42
157
  margin: 0 var(--spacing-base);
43
- `,href:"/settings",onClick:o=>r(o)},(0,t.jsx)("svg",{css:{display:"block"},width:"120",height:"38",viewBox:"0 0 120 38",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,t.jsx)("g",{clipPath:"url(#clip0_41_612)"},(0,t.jsx)("path",{d:"M8.82261 3.73315L0 8.82209V18.9999L8.82261 13.911L17.6474 8.82209L8.82261 3.73315Z",fill:"#83C6E1"}),(0,t.jsx)("path",{d:"M8.82261 24.089V13.9111L0 19.0001V29.1779L8.82261 34.2669L17.6474 29.1779V19.0001L8.82261 24.089Z",fill:"#438FD5"}),(0,t.jsx)("path",{d:"M17.6474 8.82202L8.82263 13.911L17.6474 18.9999V29.1777L26.47 24.0888V13.911L17.6474 8.82202Z",fill:"#F4220B"}),(0,t.jsx)("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"})),(0,t.jsx)("defs",null,(0,t.jsx)("clipPath",{id:"clip0_41_612"},(0,t.jsx)("rect",{width:"120",height:"38",fill:"white"}))))),(0,t.jsx)("ul",{css:R.css`
158
+ `,
159
+ route: "/settings"
160
+ }, /* @__PURE__ */ (0, import_react.jsx)("svg", {
161
+ css: { display: "block" },
162
+ width: "120",
163
+ height: "38",
164
+ viewBox: "0 0 120 38",
165
+ fill: "none",
166
+ xmlns: "http://www.w3.org/2000/svg"
167
+ }, /* @__PURE__ */ (0, import_react.jsx)("g", {
168
+ clipPath: "url(#clip0_41_612)"
169
+ }, /* @__PURE__ */ (0, import_react.jsx)("path", {
170
+ d: "M8.82261 3.73315L0 8.82209V18.9999L8.82261 13.911L17.6474 8.82209L8.82261 3.73315Z",
171
+ fill: "#83C6E1"
172
+ }), /* @__PURE__ */ (0, import_react.jsx)("path", {
173
+ d: "M8.82261 24.089V13.9111L0 19.0001V29.1779L8.82261 34.2669L17.6474 29.1779V19.0001L8.82261 24.089Z",
174
+ fill: "#438FD5"
175
+ }), /* @__PURE__ */ (0, import_react.jsx)("path", {
176
+ d: "M17.6474 8.82202L8.82263 13.911L17.6474 18.9999V29.1777L26.47 24.0888V13.911L17.6474 8.82202Z",
177
+ fill: "#F4220B"
178
+ }), /* @__PURE__ */ (0, import_react.jsx)("path", {
179
+ 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",
180
+ fill: "white"
181
+ })), /* @__PURE__ */ (0, import_react.jsx)("defs", null, /* @__PURE__ */ (0, import_react.jsx)("clipPath", {
182
+ id: "clip0_41_612"
183
+ }, /* @__PURE__ */ (0, import_react.jsx)("rect", {
184
+ width: "120",
185
+ height: "38",
186
+ fill: "white"
187
+ }))))), /* @__PURE__ */ (0, import_react.jsx)("ul", {
188
+ css: import_react3.css`
44
189
  display: flex;
45
190
  flex-flow: column nowrap;
46
191
  padding: 0;
47
192
  margin: 0;
48
193
  list-style-type: none;
49
194
  height: calc(100% - var(--spacing-base) * 2.5);
50
- `},Kt.map((o,a)=>(0,t.jsx)("li",{css:R.css`
51
- padding: 0;
52
- margin: 0;
53
- list-style-type: none;
54
-
55
- &:last-of-type {
56
- margin-top: auto;
57
- }
58
- `,key:a},(0,t.jsx)("a",{css:R.css`
59
- align-items: center;
60
- border-radius: var(--rounded-base);
61
- display: flex;
62
- color: var(--white);
63
- gap: var(--spacing-sm);
64
- padding: var(--spacing-sm) var(--spacing-base);
65
- text-decoration: none;
66
- transition: background-color 0.25s ease-in-out;
67
-
68
- &:hover,
69
- &.active {
70
- background: var(--gray-700);
195
+ `
196
+ }, links.map((item, index) => {
197
+ var _a, _b, _c, _d;
198
+ let overrideCount = 0;
199
+ if (item.href === "/overrides" && Object.keys((_a = props.settings.scoreOverrides) != null ? _a : {}).length > 0) {
200
+ overrideCount = Object.keys((_b = props.settings.scoreOverrides) != null ? _b : {}).length;
201
+ }
202
+ if (item.href === "/quirks" && Object.keys((_c = props.settings.quirkOverrides) != null ? _c : {}).length > 0) {
203
+ overrideCount = Object.keys((_d = props.settings.quirkOverrides) != null ? _d : {}).length;
204
+ }
205
+ return /* @__PURE__ */ (0, import_react.jsx)("li", {
206
+ css: import_react3.css`
207
+ padding: 0;
208
+ margin: 0;
209
+ list-style-type: none;
210
+
211
+ &:last-of-type {
212
+ margin-top: auto;
71
213
  }
72
- `,className:n(o.href),href:o.href,title:o.title,onClick:i=>r(i)},(0,t.jsx)("i",{css:R.css`
214
+ `,
215
+ key: index
216
+ }, /* @__PURE__ */ (0, import_react.jsx)(NavigationLink_default, {
217
+ css: import_react3.css`
73
218
  align-items: center;
219
+ border-radius: var(--rounded-base);
74
220
  display: flex;
75
- `,dangerouslySetInnerHTML:{__html:o.icon}}),o.title)))))};var dt=()=>(0,t.jsx)("article",null,(0,t.jsx)("h1",null,"Something when wrong"),(0,t.jsx)("p",null,"We could not find the page you're looking for."));var $=T(require("react"));var S=require("@emotion/react"),F=T(require("react")),mt=(0,S.css)({willChange:"height"}),$t=S.css`
221
+ color: var(--white);
222
+ gap: var(--spacing-sm);
223
+ padding: var(--spacing-sm) var(--spacing-base);
224
+ text-decoration: none;
225
+ transition: background-color 0.25s ease-in-out;
226
+
227
+ &:hover,
228
+ &.active {
229
+ background: var(--gray-700);
230
+ }
231
+ `,
232
+ className: isActivePath(item.href),
233
+ route: item.href
234
+ }, /* @__PURE__ */ (0, import_react.jsx)("i", {
235
+ css: import_react3.css`
236
+ align-items: center;
237
+ display: flex;
238
+ `,
239
+ dangerouslySetInnerHTML: { __html: item.icon }
240
+ }), item.title, overrideCount ? /* @__PURE__ */ (0, import_react.jsx)("span", {
241
+ css: import_react3.css`
242
+ font-size: var(--font-xxs);
243
+ display: inline-block;
244
+ width: 12px;
245
+ height: 12px;
246
+ border-radius: 6px;
247
+ background-color: var(--red-tooltip);
248
+ text-align: center;
249
+ line-height: 12px;
250
+ `
251
+ }, overrideCount) : null));
252
+ })));
253
+ };
254
+
255
+ // src/components/StatusPages/NotFound.tsx
256
+ var NotFound = () => {
257
+ return /* @__PURE__ */ (0, import_react.jsx)("article", null, /* @__PURE__ */ (0, import_react.jsx)("h1", null, "Something when wrong"), /* @__PURE__ */ (0, import_react.jsx)("p", null, "We could not find the page you're looking for."));
258
+ };
259
+
260
+ // src/components/Personalization/Dimensions.tsx
261
+ var React4 = __toESM(require("react"));
262
+
263
+ // src/components/Accordion/Accordion.tsx
264
+ var import_react4 = require("@emotion/react");
265
+ var React2 = __toESM(require("react"));
266
+ var willChange = (0, import_react4.css)({ willChange: "height" });
267
+ var titleStyle = import_react4.css`
76
268
  border-bottom: 2px solid var(--brand-secondary-1);
77
269
  font-size: var(--font-base);
78
270
  margin: 0;
79
- `,qt=S.css`
271
+ `;
272
+ var btnStyle = import_react4.css`
80
273
  align-items: center;
81
274
  border: none;
82
275
  background: none;
@@ -86,13 +279,59 @@ var Ft=Object.create;var B=Object.defineProperty;var Zt=Object.getOwnPropertyDes
86
279
  padding: var(--spacing-sm) 0;
87
280
  font-weight: var(--font-bold);
88
281
  justify-content: space-between;
89
- `,Wt=S.css`
282
+ `;
283
+ var iconStyle = import_react4.css`
90
284
  align-self: center;
91
- `,Qt=S.css`
285
+ `;
286
+ var iconActiveStyle = import_react4.css`
92
287
  transform: rotate(-180deg);
93
- `,Z=({children:e})=>(0,t.jsx)("div",{css:[mt]},e),U=({title:e,children:r})=>{let[n,o]=F.useState(!1),a=e.split(" ").join("-").toLocaleLowerCase();return(0,t.jsx)(F.Fragment,null,(0,t.jsx)("h3",{css:$t},(0,t.jsx)("button",{"aria-expanded":n,css:qt,title:e,id:a,"aria-controls":`${a}-section`,onClick:()=>o(i=>!i),type:"button"},e,(0,t.jsx)("i",{css:[Wt,n?Qt:void 0]},(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,t.jsx)("path",{d:"M6.34317 7.75732L4.92896 9.17154L12 16.2426L19.0711 9.17157L17.6569 7.75735L12 13.4142L6.34317 7.75732Z",fill:"currentColor"}))))),(0,t.jsx)("div",{id:`${a}-section`,css:[mt,S.css`
288
+ `;
289
+ var Accordion = ({ children }) => {
290
+ return /* @__PURE__ */ (0, import_react.jsx)("div", {
291
+ css: [willChange]
292
+ }, children);
293
+ };
294
+ var AccordionItem = ({ title, children }) => {
295
+ const [visibility, setVisibility] = React2.useState(false);
296
+ const id = title.split(" ").join("-").toLocaleLowerCase();
297
+ return /* @__PURE__ */ (0, import_react.jsx)(React2.Fragment, null, /* @__PURE__ */ (0, import_react.jsx)("h3", {
298
+ css: titleStyle
299
+ }, /* @__PURE__ */ (0, import_react.jsx)("button", {
300
+ "aria-expanded": visibility,
301
+ css: btnStyle,
302
+ title,
303
+ id,
304
+ "aria-controls": `${id}-section`,
305
+ onClick: () => setVisibility((prev) => !prev),
306
+ type: "button"
307
+ }, title, /* @__PURE__ */ (0, import_react.jsx)("i", {
308
+ css: [iconStyle, visibility ? iconActiveStyle : void 0]
309
+ }, /* @__PURE__ */ (0, import_react.jsx)("svg", {
310
+ width: "24",
311
+ height: "24",
312
+ viewBox: "0 0 24 24",
313
+ fill: "none",
314
+ xmlns: "http://www.w3.org/2000/svg"
315
+ }, /* @__PURE__ */ (0, import_react.jsx)("path", {
316
+ d: "M6.34317 7.75732L4.92896 9.17154L12 16.2426L19.0711 9.17157L17.6569 7.75735L12 13.4142L6.34317 7.75732Z",
317
+ fill: "currentColor"
318
+ }))))), /* @__PURE__ */ (0, import_react.jsx)("div", {
319
+ id: `${id}-section`,
320
+ css: [
321
+ willChange,
322
+ import_react4.css`
94
323
  padding: var(--spacing-sm) 0;
95
- `],role:"region","aria-labelledby":a},n?r:null))};var k=require("@emotion/react"),ut=T(require("react")),Xt=k.css`
324
+ `
325
+ ],
326
+ role: "region",
327
+ "aria-labelledby": id
328
+ }, visibility ? children : null));
329
+ };
330
+
331
+ // src/components/Buttons/Button.tsx
332
+ var import_react5 = require("@emotion/react");
333
+ var React3 = __toESM(require("react"));
334
+ var buttonStyle = import_react5.css`
96
335
  align-items: center;
97
336
  border: 1px solid transparent;
98
337
  cursor: pointer;
@@ -103,29 +342,55 @@ var Ft=Object.create;var B=Object.defineProperty;var Zt=Object.getOwnPropertyDes
103
342
  &:hover {
104
343
  opacity: 0.8;
105
344
  }
106
- `;function Yt(e){let r=k.css`
345
+ `;
346
+ function buttonVariant(variant) {
347
+ const white = import_react5.css`
107
348
  color: var(--white);
108
- `,n=k.css`
349
+ `;
350
+ const bold = import_react5.css`
109
351
  font-weight: var(--font-bold);
110
- `;switch(e){case"primary":return k.css`
352
+ `;
353
+ switch (variant) {
354
+ case "primary":
355
+ return import_react5.css`
111
356
  background: var(--brand-secondary-1);
112
- ${r}
113
- ${n}
114
- `;case"secondary":return k.css`
357
+ ${white}
358
+ ${bold}
359
+ `;
360
+ case "secondary":
361
+ return import_react5.css`
115
362
  background: var(--brand-secondary-5);
116
- ${r}
117
- ${n}
118
- `;case"unimportant":return k.css`
363
+ ${white}
364
+ ${bold}
365
+ `;
366
+ case "unimportant":
367
+ return import_react5.css`
119
368
  background: var(--brand-secondary-3);
120
369
  color: var(--brand-secondary-1);
121
- ${n}
122
- `;case"ghost":return k.css`
370
+ ${bold}
371
+ `;
372
+ case "ghost":
373
+ return import_react5.css`
123
374
  background: transparent;
124
375
  color: var(--brand-secondary-5);
125
376
  &:hover {
126
377
  border: 1px solid var(--brand-secondary-5);
127
378
  }
128
- `}}var H=({buttonType:e="primary",children:r,className:n,...o})=>(0,t.jsx)(ut.Fragment,null,(0,t.jsx)("button",{type:"button",css:[Xt,Yt(e)],className:n,...o},r));var V=require("@emotion/react"),N=V.css`
379
+ `;
380
+ }
381
+ }
382
+ var Button = ({ buttonType = "primary", children, className, ...props }) => {
383
+ return /* @__PURE__ */ (0, import_react.jsx)(React3.Fragment, null, /* @__PURE__ */ (0, import_react.jsx)("button", {
384
+ type: "button",
385
+ css: [buttonStyle, buttonVariant(buttonType)],
386
+ className,
387
+ ...props
388
+ }, children));
389
+ };
390
+
391
+ // src/components/CallToAction/cta.styles.ts
392
+ var import_react6 = require("@emotion/react");
393
+ var cta = import_react6.css`
129
394
  background-color: var(--gray-100);
130
395
  padding: var(--spacing-base) var(--spacing-md);
131
396
  margin: var(--spacing-base) 0;
@@ -133,21 +398,25 @@ var Ft=Object.create;var B=Object.defineProperty;var Zt=Object.getOwnPropertyDes
133
398
  &:first-of-type {
134
399
  margin: 0 0 var(--spacing-base);
135
400
  }
136
- `,gt=V.css`
401
+ `;
402
+ var ctaWithIcon = import_react6.css`
137
403
  background: var(--gray-100)
138
404
  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")
139
405
  no-repeat var(--spacing-sm) var(--spacing-base);
140
406
  padding: var(--spacing-base) var(--spacing-xl);
141
- `,O=V.css`
407
+ `;
408
+ var ctaTitle = import_react6.css`
142
409
  color: var(--brand-secondary-1);
143
410
  margin: 0;
144
411
  font-size: var(--font-base);
145
412
  font-weight: var(--font-bold);
146
- `,_=V.css`
413
+ `;
414
+ var ctaText = import_react6.css`
147
415
  color: var(--brand-secondary-1);
148
416
  margin: var(--spacing-xs) 0 0;
149
417
  font-size: var(--font-sm);
150
- `,ft=V.css`
418
+ `;
419
+ var ctaClose = import_react6.css`
151
420
  align-items: center;
152
421
  border: none;
153
422
  background: transparent
@@ -167,21 +436,43 @@ var Ft=Object.create;var B=Object.defineProperty;var Zt=Object.getOwnPropertyDes
167
436
  &:hover {
168
437
  opacity: 0.6;
169
438
  }
170
- `,G=V.css`
439
+ `;
440
+ var ctaBtnGroup = import_react6.css`
171
441
  display: flex;
172
442
  margin: var(--spacing-sm) 0 0;
173
443
  gap: var(--spacing-base);
174
- `;var K=({title:e,text:r,buttonGroup:n,children:o})=>(0,t.jsx)("div",{css:N},(0,t.jsx)("h2",{css:O},e),(0,t.jsx)("p",{css:_},r),o,n?(0,t.jsx)("div",{css:G},n):null);var M=require("@emotion/react"),bt=M.css`
444
+ `;
445
+
446
+ // src/components/CallToAction/NoActiveDimensions.tsx
447
+ var NoActiveDimensions = ({ title, text, buttonGroup, children }) => {
448
+ return /* @__PURE__ */ (0, import_react.jsx)("div", {
449
+ css: cta
450
+ }, /* @__PURE__ */ (0, import_react.jsx)("h2", {
451
+ css: ctaTitle
452
+ }, title), /* @__PURE__ */ (0, import_react.jsx)("p", {
453
+ css: ctaText
454
+ }, text), children, buttonGroup ? /* @__PURE__ */ (0, import_react.jsx)("div", {
455
+ css: ctaBtnGroup
456
+ }, buttonGroup) : null);
457
+ };
458
+
459
+ // src/components/Inputs/input-switch.styles.ts
460
+ var import_react7 = require("@emotion/react");
461
+ var inputSwitch = import_react7.css`
175
462
  align-items: center;
176
463
  cursor: pointer;
177
464
  display: flex;
178
465
  gap: var(--spacing-xs);
179
- `,ht=M.css`
466
+ margin-top: var(--spacing-base);
467
+ `;
468
+ var inputSwitchLabel = import_react7.css`
180
469
  color: var(--gray-500);
181
470
  font-size: var(--font-sm);
182
- `,fe=M.css`
471
+ `;
472
+ var inputSwitchControl = import_react7.css`
183
473
  background: var(--gray-600);
184
- `,vt=M.css`
474
+ `;
475
+ var inputSwitchBtn = import_react7.css`
185
476
  display: block;
186
477
  background: var(--gray-400);
187
478
  border-radius: var(--rounded-full);
@@ -202,7 +493,8 @@ var Ft=Object.create;var B=Object.defineProperty;var Zt=Object.getOwnPropertyDes
202
493
  transform: translateX(2px);
203
494
  transition: transform 0.2s ease-in-out, background-color 0.3s ease-in-out;
204
495
  }
205
- `,yt=M.css`
496
+ `;
497
+ var inputSwitchCheckbox = import_react7.css`
206
498
  overflow: hidden;
207
499
  clip: rect(0, 0, 0, 0);
208
500
  height: 0;
@@ -216,49 +508,60 @@ var Ft=Object.create;var B=Object.defineProperty;var Zt=Object.getOwnPropertyDes
216
508
  &:checked ~ span {
217
509
  background: var(--brand-secondary-5);
218
510
  }
219
- `;var wt=({label:e,...r})=>(0,t.jsx)("label",{css:bt},(0,t.jsx)("span",{css:ht},e),(0,t.jsx)("input",{type:"checkbox",css:yt,...r}),(0,t.jsx)("span",{css:vt}));var v=require("@emotion/react"),I=({children:e})=>(0,t.jsx)("table",{css:v.css`
220
- border-collapse: collapse;
221
- display: table;
222
- width: 100%;
223
- font-size: var(--font-sm);
224
- `},e),Ct=({children:e})=>(0,t.jsx)("thead",{css:v.css`
225
- background: var(--gray-50);
226
- text-align: left;
227
- & tr {
228
- border-bottom: 1px solid var(--gray-200);
229
- }
230
- `},e),E=({children:e})=>(0,t.jsx)("tbody",null,e),z=({border:e,children:r})=>(0,t.jsx)("tr",{css:e?v.css`
231
- border-bottom: 1px solid var(--gray-200);
232
- &:where(:last-child) {
233
- border: none;
234
- }
235
- `:void 0},r),ot=({children:e})=>(0,t.jsx)("th",{css:v.css`
236
- outline: none;
237
- padding: var(--spacing-sm);
238
- `},e);function Jt(e){switch(e){case"light":return v.css`
239
- color: var(--gray-400);
240
- `;case"dark":return v.css`
241
- color: var(--brand-secondary-1);
242
- `}}function jt(e){return v.css`
243
- text-align: ${e};
244
- `}var w=({alignment:e="left",border:r,color:n="dark",children:o})=>(0,t.jsx)("td",{css:[v.css`
245
- padding: var(--spacing-base);
246
- max-width: 180px;
247
- overflow-wrap: break-word;
248
- position: relative;
249
- `,Jt(n),jt(e),r?v.css`
250
- border-left: 1px solid var(--gray-200);
251
- `:void 0]},o);var y=require("@emotion/react"),te=y.keyframes`from {
511
+ `;
512
+
513
+ // src/components/Inputs/SwitchInput.tsx
514
+ var SwitchInput = ({ label, ...props }) => {
515
+ return /* @__PURE__ */ (0, import_react.jsx)("label", {
516
+ css: inputSwitch
517
+ }, /* @__PURE__ */ (0, import_react.jsx)("span", {
518
+ css: inputSwitchLabel
519
+ }, label), /* @__PURE__ */ (0, import_react.jsx)("input", {
520
+ type: "checkbox",
521
+ css: inputSwitchCheckbox,
522
+ ...props
523
+ }), /* @__PURE__ */ (0, import_react.jsx)("span", {
524
+ css: inputSwitchBtn
525
+ }));
526
+ };
527
+ var FormikSwitchInput = ({ field, form, meta, ...rawProps }) => {
528
+ const { label } = rawProps;
529
+ return /* @__PURE__ */ (0, import_react.jsx)("label", {
530
+ css: inputSwitch
531
+ }, /* @__PURE__ */ (0, import_react.jsx)("span", {
532
+ css: inputSwitchLabel
533
+ }, label), /* @__PURE__ */ (0, import_react.jsx)("input", {
534
+ type: "checkbox",
535
+ css: inputSwitchCheckbox,
536
+ checked: field.value,
537
+ ...field
538
+ }), /* @__PURE__ */ (0, import_react.jsx)("span", {
539
+ css: inputSwitchBtn
540
+ }));
541
+ };
542
+
543
+ // src/components/Personalization/page.styles.ts
544
+ var import_react8 = require("@emotion/react");
545
+ var popIn = import_react8.keyframes`from {
252
546
  transform: scale(1);
253
547
  }
254
548
  to {
255
549
  transform: scale(1.2);
256
550
  }
257
- `,u={page:y.css`
551
+ `;
552
+ var styles = {
553
+ page: import_react8.css`
258
554
  color: var(--brand-secondary-1);
259
- `,text:y.css`
555
+ `,
556
+ text: import_react8.css`
260
557
  margin: var(--spacing-sm) 0;
261
- `,title:y.css`
558
+ `,
559
+ reset: import_react8.css`
560
+ margin: 0 var(--spacing-md);
561
+ font-size: var(--font-sm);
562
+ color: var(--gray-500);
563
+ `,
564
+ title: import_react8.css`
262
565
  margin: 0 0 var(--spacing-sm);
263
566
  font-size: var(--font-md);
264
567
  & > small {
@@ -267,11 +570,14 @@ to {
267
570
  font-weight: var(--font-regular);
268
571
  margin: var(--spacing-xxs) 0 0;
269
572
  }
270
- `,headingGroup:y.css`
573
+ `,
574
+ headingGroup: import_react8.css`
271
575
  align-items: baseline;
272
576
  display: flex;
273
577
  justify-content: space-between;
274
- `,divider:y.css`
578
+ align-items: center;
579
+ `,
580
+ divider: import_react8.css`
275
581
  background: var(--gray-300);
276
582
  display: block;
277
583
  width: 1px;
@@ -279,15 +585,449 @@ to {
279
585
  position: absolute;
280
586
  inset: 0 auto 0 0;
281
587
  margin: auto 0;
282
- `,submitButton:y.css`
588
+ `,
589
+ submitButton: import_react8.css`
283
590
  position: absolute;
284
591
  right: var(--spacing-base);
285
592
  bottom: var(--spacing-base);
286
- animation: 0.5s 2 alternate ${te};
287
- `,error:y.css`
593
+ animation: 0.5s 2 alternate ${popIn};
594
+ `,
595
+ cancelButton: import_react8.css`
596
+ position: absolute;
597
+ left: calc(200px + var(--spacing-base));
598
+ bottom: var(--spacing-base);
599
+ background: white;
600
+ padding: var(--spacing-sm);
601
+ border: 1px solid var(--gray-300);
602
+ `,
603
+ error: import_react8.css`
288
604
  color: var(--brand-secondary-5);
289
605
  font-size: var(--font-sm);
290
- `};var Lt=({dimensionIndex:{index:e},state:{scores:r,data:n},actions:o})=>{let a=$.useMemo(()=>Object.keys(e).filter(c=>!r[c]).map(c=>{var l;return(l=e[c])!=null?l:{name:c,dim:c,type:"Unknown"}}),[r,e]),i=Object.keys(r).length,m=i+a.length,f=()=>{o.rawUpdate([{type:"setcontrol",data:!n.controlGroup}])};return(0,t.jsx)($.Fragment,null,(0,t.jsx)("article",{css:u.page},(0,t.jsx)("div",{css:u.headingGroup},(0,t.jsx)("h2",{css:u.title},"Dimensions",(0,t.jsx)("small",null,i," active of ",m)),(0,t.jsx)(wt,{label:"Control Group",onChange:f,checked:n.controlGroup})),i>0?(0,t.jsx)(I,null,(0,t.jsx)(E,null,Object.entries(r).map(([c,l],p)=>{var L;let{name:b,type:h,category:g}=(L=e==null?void 0:e[c])!=null?L:{name:c,dim:c,type:"Unknown"};return(0,t.jsx)(z,{key:p},(0,t.jsx)(w,null,(0,t.jsx)("b",null,l)),(0,t.jsx)(w,null,(0,t.jsx)("span",{css:u.divider,role:"presentation"}),(0,t.jsx)("strong",null,g?`${g}:`:""," ",b)),(0,t.jsx)(w,{alignment:"right",color:"light"},h))}))):(0,t.jsx)(K,{title:n.controlGroup?"In control group":"No active dimensions",text:n.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:n.controlGroup?(0,t.jsx)(H,{buttonType:"secondary",onClick:f},"Exit control group"):null}),(0,t.jsx)(Z,null,(0,t.jsx)(U,{title:"Inactive Dimensions"},(0,t.jsx)(I,null,(0,t.jsx)(E,null,a.map(({dim:c,type:l,name:p,category:b})=>(0,t.jsx)(z,{key:c},(0,t.jsx)(w,null,(0,t.jsx)("strong",null,b?`${b}:`:""," ",p)),(0,t.jsx)(w,{alignment:"right",color:"light"},l)))))))))};var Tt=({...e})=>{let{state:{data:r}}=e;return(0,t.jsx)(d.Fragment,null,(0,t.jsx)("article",{css:u.page},(0,t.jsx)("h1",{css:u.title},"Quirks"),(0,t.jsx)("p",{css:u.text},"Keys defined in Uniform and their current, programmatically defined values for this visit."),Object.keys(r.quirks).length?(0,t.jsx)(I,null,(0,t.jsx)(Ct,null,(0,t.jsx)(z,null,(0,t.jsx)(ot,null,"Key"),(0,t.jsx)(ot,null,"Value"))),(0,t.jsx)(E,null,Object.entries(r.quirks).map(([n,o],a)=>(0,t.jsx)(z,{key:a,border:"bottom"},(0,t.jsx)(w,null,(0,t.jsx)("strong",null,n)),(0,t.jsx)(w,null,o))))):(0,t.jsx)(K,{title:"No quirks configured",text:"There are currently no quirks setup."})))};var C=require("formik");var Dt=require("formik");var x=require("@emotion/react"),kt=x.css`
606
+ `
607
+ };
608
+
609
+ // src/components/Table/Table.tsx
610
+ var import_react9 = require("@emotion/react");
611
+ var Table = ({ children }) => {
612
+ return /* @__PURE__ */ (0, import_react.jsx)("table", {
613
+ css: import_react9.css`
614
+ border-collapse: collapse;
615
+ display: table;
616
+ width: 100%;
617
+ font-size: var(--font-sm);
618
+ `
619
+ }, children);
620
+ };
621
+ var THead = ({ children }) => {
622
+ return /* @__PURE__ */ (0, import_react.jsx)("thead", {
623
+ css: import_react9.css`
624
+ background: var(--gray-50);
625
+ text-align: left;
626
+ & tr {
627
+ border-bottom: 1px solid var(--gray-200);
628
+ }
629
+ `
630
+ }, children);
631
+ };
632
+ var TBody = ({ children }) => {
633
+ return /* @__PURE__ */ (0, import_react.jsx)("tbody", null, children);
634
+ };
635
+ var TRow = ({ border, children }) => {
636
+ return /* @__PURE__ */ (0, import_react.jsx)("tr", {
637
+ css: border ? import_react9.css`
638
+ border-bottom: 1px solid var(--gray-200);
639
+ &:where(:last-child) {
640
+ border: none;
641
+ }
642
+ ` : void 0
643
+ }, children);
644
+ };
645
+ var THeading = ({ children }) => {
646
+ return /* @__PURE__ */ (0, import_react.jsx)("th", {
647
+ css: import_react9.css`
648
+ outline: none;
649
+ padding: var(--spacing-sm);
650
+ `
651
+ }, children);
652
+ };
653
+ function colour(color) {
654
+ switch (color) {
655
+ case "light":
656
+ return import_react9.css`
657
+ color: var(--gray-400);
658
+ `;
659
+ case "dark":
660
+ return import_react9.css`
661
+ color: var(--brand-secondary-1);
662
+ `;
663
+ }
664
+ }
665
+ function align(alignment) {
666
+ return import_react9.css`
667
+ text-align: ${alignment};
668
+ `;
669
+ }
670
+ var TData = ({ alignment = "left", border, color = "dark", children }) => {
671
+ return /* @__PURE__ */ (0, import_react.jsx)("td", {
672
+ css: [
673
+ import_react9.css`
674
+ padding: var(--spacing-base);
675
+ max-width: 180px;
676
+ overflow-wrap: break-word;
677
+ position: relative;
678
+ `,
679
+ colour(color),
680
+ align(alignment),
681
+ border ? import_react9.css`
682
+ border-left: 1px solid var(--gray-200);
683
+ ` : void 0
684
+ ]
685
+ }, children);
686
+ };
687
+
688
+ // src/components/Table/table.styles.ts
689
+ var import_react10 = require("@emotion/react");
690
+ var scoreTd = import_react10.css`
691
+ position: relative;
692
+ display: inline-block;
693
+ font-size: var(--font-base);
694
+ `;
695
+ var overriddenValue = import_react10.css`
696
+ display: block;
697
+ `;
698
+ var isOverriddenTooltip = import_react10.css`
699
+ position: absolute;
700
+ width: 6px;
701
+ height: 6px;
702
+ right: -10px;
703
+ top: 9px;
704
+ background: var(--red-tooltip);
705
+ border-radius: 3px;
706
+ `;
707
+
708
+ // src/styles/icons.tsx
709
+ var import_react11 = require("@emotion/react");
710
+ var audienceIcon = `<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
711
+ <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"/>
712
+ <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"/>
713
+ <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"/>
714
+ </svg>`;
715
+ var enrichmentIcon = `<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
716
+ <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"/>
717
+ <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"/>
718
+ <path d="M11.9999 5.05762H8.3999V6.2576H11.9999V5.05762Z" fill="#828282"/>
719
+ <path d="M8.3999 7.45752H11.9999V8.6575H8.3999V7.45752Z" fill="#828282"/>
720
+ <path d="M11.9999 2.65771H8.3999V3.8577H11.9999V2.65771Z" fill="#828282"/>
721
+ </svg>`;
722
+ var signalIcon = `<svg width="15" height="11" viewBox="0 0 15 11" fill="none" xmlns="http://www.w3.org/2000/svg">
723
+ <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"/>
724
+ <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"/>
725
+ <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"/>
726
+ <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"/>
727
+ <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"/>
728
+ </svg>`;
729
+ var Icon = ({ type }) => {
730
+ let iconHtml = "";
731
+ switch (type) {
732
+ case "Audience":
733
+ iconHtml = audienceIcon;
734
+ break;
735
+ case "Signal":
736
+ iconHtml = signalIcon;
737
+ break;
738
+ case "Intent":
739
+ iconHtml = signalIcon;
740
+ break;
741
+ case "Enrichment":
742
+ iconHtml = enrichmentIcon;
743
+ break;
744
+ }
745
+ return /* @__PURE__ */ (0, import_react.jsx)("i", {
746
+ css: import_react11.css`
747
+ align-items: center;
748
+ display: inline-block;
749
+ `,
750
+ dangerouslySetInnerHTML: { __html: iconHtml }
751
+ });
752
+ };
753
+
754
+ // src/components/Table/DimensionsTable.tsx
755
+ var DimensionsTable = ({
756
+ dimensionIndex,
757
+ dimensions,
758
+ disableEditOverride,
759
+ onClick,
760
+ preemptiveOverrides
761
+ }) => {
762
+ var _a;
763
+ const { settings } = useDevToolsSettingsContext();
764
+ const overrides = (_a = preemptiveOverrides != null ? preemptiveOverrides : settings.scoreOverrides) != null ? _a : {};
765
+ return /* @__PURE__ */ (0, import_react.jsx)(Table, null, /* @__PURE__ */ (0, import_react.jsx)(TBody, null, Object.entries(dimensions).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => {
766
+ var _a2;
767
+ const { dim, name, type, category } = (_a2 = dimensionIndex[key]) != null ? _a2 : {
768
+ name: key,
769
+ dim: key,
770
+ type: void 0,
771
+ category: void 0
772
+ };
773
+ const override = overrides[dim];
774
+ return /* @__PURE__ */ (0, import_react.jsx)(TRow, {
775
+ key: dim
776
+ }, /* @__PURE__ */ (0, import_react.jsx)(TData, null, override !== void 0 ? /* @__PURE__ */ (0, import_react.jsx)("s", {
777
+ css: overriddenValue
778
+ }, override.initial) : null, /* @__PURE__ */ (0, import_react.jsx)("b", {
779
+ css: scoreTd
780
+ }, value, override !== void 0 && /* @__PURE__ */ (0, import_react.jsx)("i", {
781
+ css: isOverriddenTooltip
782
+ }))), /* @__PURE__ */ (0, import_react.jsx)(TData, null, /* @__PURE__ */ (0, import_react.jsx)("div", {
783
+ onClick: () => onClick == null ? void 0 : onClick(dim),
784
+ css: onClick ? { cursor: "pointer" } : void 0
785
+ }, /* @__PURE__ */ (0, import_react.jsx)("span", {
786
+ css: styles.divider,
787
+ role: "presentation"
788
+ }), /* @__PURE__ */ (0, import_react.jsx)("div", null, /* @__PURE__ */ (0, import_react.jsx)(Icon, {
789
+ type
790
+ }), " ", type), /* @__PURE__ */ (0, import_react.jsx)("strong", null, category ? `${category}:` : "", " ", name))), /* @__PURE__ */ (0, import_react.jsx)(TData, {
791
+ alignment: "right",
792
+ color: "light"
793
+ }, override !== void 0 && !disableEditOverride ? /* @__PURE__ */ (0, import_react.jsx)(NavigationLink_default, {
794
+ route: `/overrides/${dim}`
795
+ }, "Edit override") : null));
796
+ })));
797
+ };
798
+ var DimensionsTable_default = DimensionsTable;
799
+
800
+ // src/components/Buttons/LinkButton.tsx
801
+ var import_react12 = require("@emotion/react");
802
+ var btnStyle2 = import_react12.css`
803
+ background: none;
804
+ border: none;
805
+ color: var(--brand-secondary-3);
806
+ cursor: pointer;
807
+ padding: 0;
808
+ font-weight: var(--font-bold);
809
+ margin-left: auto;
810
+ font-size: var(--font-sm);
811
+ `;
812
+ var LinkButton = ({ children, ...props }) => {
813
+ return /* @__PURE__ */ (0, import_react.jsx)("button", {
814
+ type: "button",
815
+ css: btnStyle2,
816
+ ...props
817
+ }, children);
818
+ };
819
+
820
+ // src/lib/deleteOverride.ts
821
+ async function deleteScoreOverrides({
822
+ actions,
823
+ saveSettings,
824
+ scores,
825
+ settings
826
+ }) {
827
+ var _a, _b;
828
+ const scoreOverrides = (_a = settings.scoreOverrides) != null ? _a : {};
829
+ const newOverrides = { ...scoreOverrides };
830
+ const commands = [];
831
+ for (const dim of Object.keys(scoreOverrides)) {
832
+ const override = scoreOverrides == null ? void 0 : scoreOverrides[dim];
833
+ delete newOverrides[dim];
834
+ commands.push({
835
+ type: "modscoreS",
836
+ data: { dimension: dim, delta: override.initial - ((_b = scores[dim]) != null ? _b : 0) }
837
+ });
838
+ }
839
+ await saveSettings({
840
+ ...settings,
841
+ scoreOverrides: newOverrides
842
+ });
843
+ await actions.rawUpdate(commands);
844
+ }
845
+ async function deleteQuirkOverride({
846
+ quirk: dim,
847
+ settings,
848
+ saveSettings,
849
+ actions
850
+ }) {
851
+ var _a;
852
+ const override = (_a = settings.quirkOverrides) == null ? void 0 : _a[dim];
853
+ if (!override) {
854
+ return;
855
+ }
856
+ const newOverrides = { ...settings.quirkOverrides };
857
+ delete newOverrides[dim];
858
+ await saveSettings({
859
+ ...settings,
860
+ quirkOverrides: newOverrides
861
+ });
862
+ await actions.rawUpdate([{ type: "setquirk", data: { key: dim, value: override.initial } }]);
863
+ }
864
+
865
+ // src/components/Personalization/Dimensions.tsx
866
+ var Dimensions = ({
867
+ dimensionIndex: { index: dimensionIndex },
868
+ state: { scores, data },
869
+ actions,
870
+ saveSettings,
871
+ settings
872
+ }) => {
873
+ const remainingDimensions = React4.useMemo(() => {
874
+ const newRemainingDimensions = {};
875
+ Object.keys(dimensionIndex).filter((dimension) => !scores[dimension]).map((key) => {
876
+ newRemainingDimensions[dimensionIndex[key].dim] = 0;
877
+ });
878
+ return newRemainingDimensions;
879
+ }, [scores, dimensionIndex]);
880
+ const activeDims = Object.keys(scores).length;
881
+ const totalDims = activeDims + Object.keys(remainingDimensions).length;
882
+ const toggleControlGroup = () => {
883
+ actions.rawUpdate([{ type: "setcontrol", data: !data.controlGroup }]);
884
+ };
885
+ return /* @__PURE__ */ (0, import_react.jsx)(React4.Fragment, null, /* @__PURE__ */ (0, import_react.jsx)("article", {
886
+ css: styles.page
887
+ }, /* @__PURE__ */ (0, import_react.jsx)("div", {
888
+ css: styles.headingGroup
889
+ }, /* @__PURE__ */ (0, import_react.jsx)("h2", {
890
+ css: styles.title
891
+ }, "Dimensions", /* @__PURE__ */ (0, import_react.jsx)("small", null, activeDims, " active of ", totalDims)), /* @__PURE__ */ (0, import_react.jsx)("div", {
892
+ css: styles.reset
893
+ }, /* @__PURE__ */ (0, import_react.jsx)(LinkButton, {
894
+ onClick: () => deleteScoreOverrides({ actions, saveSettings, scores, settings }).then(actions.forget)
895
+ }, "clear all dimensions")), /* @__PURE__ */ (0, import_react.jsx)(SwitchInput, {
896
+ label: "Control Group",
897
+ onChange: toggleControlGroup,
898
+ checked: data.controlGroup
899
+ })), activeDims > 0 ? /* @__PURE__ */ (0, import_react.jsx)(DimensionsTable_default, {
900
+ dimensionIndex,
901
+ dimensions: scores
902
+ }) : /* @__PURE__ */ (0, import_react.jsx)(NoActiveDimensions, {
903
+ title: data.controlGroup ? "In control group" : "No active dimensions",
904
+ 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.",
905
+ buttonGroup: data.controlGroup ? /* @__PURE__ */ (0, import_react.jsx)(Button, {
906
+ buttonType: "secondary",
907
+ onClick: toggleControlGroup
908
+ }, "Exit control group") : null
909
+ }), /* @__PURE__ */ (0, import_react.jsx)(Accordion, null, /* @__PURE__ */ (0, import_react.jsx)(AccordionItem, {
910
+ title: `Inactive Dimensions (${Object.keys(remainingDimensions).length})`
911
+ }, /* @__PURE__ */ (0, import_react.jsx)(DimensionsTable_default, {
912
+ dimensionIndex,
913
+ dimensions: remainingDimensions
914
+ })))));
915
+ };
916
+
917
+ // src/components/Personalization/Overrides.tsx
918
+ var React5 = __toESM(require("react"));
919
+
920
+ // src/components/CallToAction/AddButton.tsx
921
+ var import_react13 = require("@emotion/react");
922
+ function AddButton({
923
+ onClick
924
+ }) {
925
+ return /* @__PURE__ */ (0, import_react.jsx)("button", {
926
+ css: import_react13.css`
927
+ width: 3.5rem;
928
+ height: 3.5rem;
929
+ display: flex;
930
+ align-items: center;
931
+ border-radius: 9999px;
932
+ border: none;
933
+ cursor: pointer;
934
+ background-color: var(--red-button);
935
+
936
+ svg {
937
+ color: var(--red-button);
938
+ }
939
+ `,
940
+ onClick,
941
+ "aria-label": "Add new override",
942
+ className: "text-secondary shadow-xl rounded-full flex items-center bg-secondary",
943
+ "data-test-id": "add-new-overrides-button"
944
+ }, /* @__PURE__ */ (0, import_react.jsx)("svg", {
945
+ xmlns: "http://www.w3.org/2000/svg",
946
+ width: "66",
947
+ height: "66",
948
+ viewBox: "0 0 66 66"
949
+ }, /* @__PURE__ */ (0, import_react.jsx)("g", {
950
+ fill: "none",
951
+ fillRule: "evenodd"
952
+ }, /* @__PURE__ */ (0, import_react.jsx)("circle", {
953
+ cx: "33",
954
+ cy: "33",
955
+ r: "33",
956
+ fill: "currentColor"
957
+ }), /* @__PURE__ */ (0, import_react.jsx)("g", {
958
+ fill: "#FFF",
959
+ transform: "translate(19 19)"
960
+ }, /* @__PURE__ */ (0, import_react.jsx)("rect", {
961
+ width: "4",
962
+ height: "28",
963
+ x: "12",
964
+ rx: "2"
965
+ }), /* @__PURE__ */ (0, import_react.jsx)("path", {
966
+ d: "M14,0 C15.1045695,-2.02906125e-16 16,0.8954305 16,2 L16,26 C16,27.1045695 15.1045695,28 14,28 C12.8954305,28 12,27.1045695 12,26 L12,2 C12,0.8954305 12.8954305,2.02906125e-16 14,0 Z",
967
+ transform: "rotate(90 14 14)"
968
+ })))));
969
+ }
970
+
971
+ // src/components/Personalization/Overrides.tsx
972
+ var Overrides = ({
973
+ dimensionIndex: { index: dimensionIndex },
974
+ state: { data, scores },
975
+ actions,
976
+ settings,
977
+ saveSettings
978
+ }) => {
979
+ var _a;
980
+ const overrides = (_a = settings.scoreOverrides) != null ? _a : {};
981
+ const totalOverrides = Object.keys(overrides).length;
982
+ const addNewOverride = (e) => {
983
+ e.preventDefault();
984
+ return saveSettings({ ...settings, route: "/overrides/add" });
985
+ };
986
+ const toggleControlGroup = () => {
987
+ actions.rawUpdate([{ type: "setcontrol", data: !data.controlGroup }]);
988
+ };
989
+ const scoresAffectedByOverrides = {};
990
+ Object.entries(scores).map(([key, value]) => {
991
+ if (overrides[key] !== void 0) {
992
+ scoresAffectedByOverrides[key] = value;
993
+ }
994
+ });
995
+ return /* @__PURE__ */ (0, import_react.jsx)(React5.Fragment, null, /* @__PURE__ */ (0, import_react.jsx)("article", {
996
+ css: styles.page
997
+ }, /* @__PURE__ */ (0, import_react.jsx)("div", {
998
+ css: styles.headingGroup
999
+ }, /* @__PURE__ */ (0, import_react.jsx)("h2", {
1000
+ css: styles.title
1001
+ }, "What if?"), /* @__PURE__ */ (0, import_react.jsx)("div", {
1002
+ css: styles.reset
1003
+ }, /* @__PURE__ */ (0, import_react.jsx)(LinkButton, {
1004
+ onClick: () => deleteScoreOverrides({ actions, settings, saveSettings, scores })
1005
+ }, "delete all overrides")), /* @__PURE__ */ (0, import_react.jsx)(AddButton, {
1006
+ onClick: addNewOverride
1007
+ })), /* @__PURE__ */ (0, import_react.jsx)("p", null, "Override dimension scores to test personalization"), totalOverrides > 0 ? /* @__PURE__ */ (0, import_react.jsx)(DimensionsTable_default, {
1008
+ dimensionIndex,
1009
+ dimensions: scoresAffectedByOverrides,
1010
+ onClick: (dim) => saveSettings({ ...settings, route: `/overrides/${dim}` })
1011
+ }) : /* @__PURE__ */ (0, import_react.jsx)(NoActiveDimensions, {
1012
+ title: data.controlGroup ? "In control group" : "No overrides",
1013
+ 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.",
1014
+ buttonGroup: data.controlGroup ? /* @__PURE__ */ (0, import_react.jsx)(Button, {
1015
+ buttonType: "secondary",
1016
+ onClick: toggleControlGroup
1017
+ }, "Exit control group") : null
1018
+ })));
1019
+ };
1020
+
1021
+ // src/components/Personalization/AddOverride.tsx
1022
+ var import_formik3 = require("formik");
1023
+ var yup = __toESM(require("yup"));
1024
+
1025
+ // src/components/Inputs/SelectInput.tsx
1026
+ var import_formik = require("formik");
1027
+
1028
+ // src/components/Inputs/inputs.styles.ts
1029
+ var import_react14 = require("@emotion/react");
1030
+ var textInput = import_react14.css`
291
1031
  background: var(--white);
292
1032
  border: 1px solid var(--gray-500);
293
1033
  border-radius: var(--rounded-base);
@@ -298,9 +1038,12 @@ to {
298
1038
  cursor: not-allowed;
299
1039
  color: var(--gray-200);
300
1040
  }
301
- `,xt=x.css`
1041
+ `;
1042
+ var selectInput = import_react14.css`
302
1043
  appearance: none;
303
- background: var(--white) url('./assets/chevon-down.svg') no-repeat 98% 50%;
1044
+ background: var(--white)
1045
+ url('data:image/svg+xml;base64,PHN2ZwogIHdpZHRoPSIyNCIKICBoZWlnaHQ9IjI0IgogIHZpZXdCb3g9IjAgMCAyNCAyNCIKICBmaWxsPSJub25lIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKPgogIDxwYXRoCiAgICBkPSJNNi4zNDMxNyA3Ljc1NzMyTDQuOTI4OTYgOS4xNzE1NEwxMiAxNi4yNDI2TDE5LjA3MTEgOS4xNzE1N0wxNy42NTY5IDcuNzU3MzVMMTIgMTMuNDE0Mkw2LjM0MzE3IDcuNzU3MzJaIgogICAgZmlsbD0iIzgyODI4MiIKICAvPgo8L3N2Zz4=')
1046
+ no-repeat 98% 50%;
304
1047
  border: 1px solid var(--gray-500);
305
1048
  border-radius: var(--rounded-base);
306
1049
  color: var(--brand-secondary-1);
@@ -309,31 +1052,776 @@ to {
309
1052
  cursor: not-allowed;
310
1053
  color: var(--gray-200);
311
1054
  }
312
- `,q=x.css`
1055
+ `;
1056
+ var editableInput = import_react14.css`
1057
+ padding: var(--spacing-sm);
1058
+ max-width: 160px;
1059
+ `;
1060
+ var inputWrapper = import_react14.css`
313
1061
  margin: var(--spacing-base) 0;
314
- `,W=x.css`
1062
+ `;
1063
+ var inputLabel = import_react14.css`
315
1064
  color: var(--brand-secondary-1);
316
1065
  display: flex;
317
1066
  flex-direction: column;
318
1067
  margin: 0 0 var(--spacing-sm);
319
- `,Q=x.css`
1068
+ `;
1069
+ var inputText = import_react14.css`
320
1070
  color: var(--brand-secondary-1);
321
1071
  display: block;
1072
+ flex: 1 100%;
322
1073
  font-weight: var(--font-bold);
323
1074
  margin: 0 0 var(--spacing-sm);
324
- `,X=x.css`
1075
+ `;
1076
+ var inputCaption = import_react14.css`
325
1077
  color: var(--gray-600);
326
1078
  font-size: var(--font-sm);
327
- `,Y=x.css`
1079
+ `;
1080
+ var errorMsg = import_react14.css`
328
1081
  color: var(--brand-secondary-5);
329
1082
  display: block;
330
- `;var J=({field:e,form:r,meta:n,...o})=>{let{label:a,caption:i,...m}=o;return(0,t.jsx)("div",{css:q},(0,t.jsx)("label",{css:W},(0,t.jsx)("span",{css:Q},a),(0,t.jsx)("input",{type:"text",css:kt,...e,...m})),i?(0,t.jsx)("span",{css:X},i):null,(0,t.jsx)(Dt.ErrorMessage,{component:"div",css:Y,name:e.name}))};var Rt=require("formik");var St=({field:e,form:r,meta:n,...o})=>{let{label:a,options:i,caption:m,...f}=o;return(0,t.jsx)("div",{css:q},(0,t.jsx)("label",{css:W},(0,t.jsx)("span",{css:Q},a),(0,t.jsx)("select",{...e,...f,css:xt},i.map((c,l)=>(0,t.jsx)("option",{value:c.value,key:l},c.text)))),m?(0,t.jsx)("span",{css:X},m):null,(0,t.jsx)(Rt.ErrorMessage,{component:"div",css:Y,name:e.name}))};var P=T(require("yup"));var Ht=require("@emotion/react"),rt=({children:e,...r})=>(0,t.jsx)("fieldset",{css:Ht.css`
1083
+ `;
1084
+ var rangeInput = import_react14.css`
1085
+ flex-direction: row;
1086
+ flex-wrap: wrap;
1087
+
1088
+ input[type='range'] {
1089
+ height: 28px;
1090
+ -webkit-appearance: none;
1091
+ margin: 10px 0;
1092
+ width: 100%;
1093
+ flex: 1 0 80%;
1094
+ }
1095
+
1096
+ input[type='range']:focus {
1097
+ outline: none;
1098
+ }
1099
+
1100
+ input[type='range']::-webkit-slider-runnable-track {
1101
+ width: 100%;
1102
+ height: 6px;
1103
+ cursor: pointer;
1104
+ animate: 0.2s;
1105
+ box-shadow: 0 0 0 #000000;
1106
+ background: #2ecdb4;
1107
+ border-radius: 0;
1108
+ border: 0 solid #000000;
1109
+ }
1110
+
1111
+ input[type='range']::-moz-range-track {
1112
+ width: 100%;
1113
+ height: 6px;
1114
+ cursor: pointer;
1115
+ animate: 0.2s;
1116
+ box-shadow: 0 0 0 #000000;
1117
+ background: #2ecdb4;
1118
+ border-radius: 0;
1119
+ border: 0 solid #000000;
1120
+ }
1121
+
1122
+ input[type='range']::-webkit-slider-thumb {
1123
+ box-shadow: 1px 1px 2px #000000;
1124
+ border: 1px solid #000000;
1125
+ height: 20px;
1126
+ width: 20px;
1127
+ border-radius: 20px;
1128
+ background: #ffffff;
1129
+ cursor: pointer;
1130
+ -webkit-appearance: none;
1131
+ margin-top: -7.5px;
1132
+ }
1133
+ input[type='range']::-moz-range-thumb {
1134
+ box-shadow: 1px 1px 2px #000000;
1135
+ border: 1px solid #000000;
1136
+ height: 20px;
1137
+ width: 20px;
1138
+ border-radius: 20px;
1139
+ background: #ffffff;
1140
+ cursor: pointer;
1141
+ -webkit-appearance: none;
1142
+ margin-top: -7.5px;
1143
+ }
1144
+ input[type='range']:focus::-webkit-slider-runnable-track {
1145
+ background: #2ecdb4;
1146
+ }
1147
+
1148
+ .value-display {
1149
+ flex: 1 0 20%;
1150
+ padding: 10px;
1151
+ }
1152
+ `;
1153
+
1154
+ // src/components/Inputs/SelectInput.tsx
1155
+ var SelectInput = ({ field, form, meta, ...rawProps }) => {
1156
+ const { label, options, caption, ...passThroughProps } = rawProps;
1157
+ return /* @__PURE__ */ (0, import_react.jsx)("div", {
1158
+ css: inputWrapper
1159
+ }, /* @__PURE__ */ (0, import_react.jsx)("label", {
1160
+ css: inputLabel
1161
+ }, /* @__PURE__ */ (0, import_react.jsx)("span", {
1162
+ css: inputText
1163
+ }, label), /* @__PURE__ */ (0, import_react.jsx)("select", {
1164
+ ...field,
1165
+ ...passThroughProps,
1166
+ css: selectInput
1167
+ }, options.map((o, index) => /* @__PURE__ */ (0, import_react.jsx)("option", {
1168
+ value: o.value,
1169
+ key: index
1170
+ }, o.text)))), caption ? /* @__PURE__ */ (0, import_react.jsx)("span", {
1171
+ css: inputCaption
1172
+ }, caption) : null, /* @__PURE__ */ (0, import_react.jsx)(import_formik.ErrorMessage, {
1173
+ component: "div",
1174
+ css: errorMsg,
1175
+ name: field.name
1176
+ }));
1177
+ };
1178
+
1179
+ // src/components/Inputs/DependableSelectBox.tsx
1180
+ var import_formik2 = require("formik");
1181
+
1182
+ // src/components/Inputs/SliderInput.tsx
1183
+ var SliderInput = ({ field, form, meta, ...rawProps }) => {
1184
+ var _a, _b;
1185
+ const { label, caption, min = 0, max = 100, step } = rawProps;
1186
+ return /* @__PURE__ */ (0, import_react.jsx)("div", null, /* @__PURE__ */ (0, import_react.jsx)("label", {
1187
+ css: [inputLabel, rangeInput]
1188
+ }, /* @__PURE__ */ (0, import_react.jsx)("span", {
1189
+ css: inputText
1190
+ }, label), /* @__PURE__ */ (0, import_react.jsx)("input", {
1191
+ type: "range",
1192
+ min,
1193
+ max,
1194
+ step,
1195
+ ...field,
1196
+ value: (_a = field.value) != null ? _a : 0
1197
+ }), /* @__PURE__ */ (0, import_react.jsx)("span", {
1198
+ className: "value-display"
1199
+ }, (_b = field.value) != null ? _b : 0)), /* @__PURE__ */ (0, import_react.jsx)("p", {
1200
+ css: inputCaption
1201
+ }, caption));
1202
+ };
1203
+ var SliderInput_default = SliderInput;
1204
+
1205
+ // src/components/Inputs/DependableSelectBox.tsx
1206
+ var DependableSelectBox = ({
1207
+ name,
1208
+ label,
1209
+ dimensionToOverride,
1210
+ isSubmitting
1211
+ }) => {
1212
+ const rangeProps = {
1213
+ max: 100,
1214
+ step: 20
1215
+ };
1216
+ if (dimensionToOverride) {
1217
+ rangeProps.max = dimensionToOverride.cap;
1218
+ rangeProps.step = dimensionToOverride.str;
1219
+ }
1220
+ return /* @__PURE__ */ (0, import_react.jsx)(import_formik2.Field, {
1221
+ component: SliderInput_default,
1222
+ label,
1223
+ caption: `Range: 0 - ${rangeProps.max} in increments of ${rangeProps.step}`,
1224
+ id: name,
1225
+ name,
1226
+ disabled: isSubmitting,
1227
+ ...rangeProps
1228
+ });
1229
+ };
1230
+ var DependableSelectBox_default = DependableSelectBox;
1231
+
1232
+ // src/components/Form/Fieldset.tsx
1233
+ var import_react15 = require("@emotion/react");
1234
+ var Fieldset = ({ children, ...props }) => {
1235
+ return /* @__PURE__ */ (0, import_react.jsx)("fieldset", {
1236
+ css: import_react15.css`
331
1237
  border: none;
332
1238
  padding: 0;
333
- `,...r},e);var Vt=require("@emotion/react"),nt=({children:e})=>(0,t.jsx)("legend",{css:Vt.css`
334
- font-size: var(--font-base);
1239
+ `,
1240
+ ...props
1241
+ }, children);
1242
+ };
1243
+
1244
+ // src/components/Form/Legend.tsx
1245
+ var import_react16 = require("@emotion/react");
1246
+ var Legend = ({ children }) => {
1247
+ return /* @__PURE__ */ (0, import_react.jsx)("legend", {
1248
+ css: import_react16.css`
1249
+ font-size: var(--font-md);
335
1250
  font-weight: var(--font-bold);
336
- `},e);var ee=P.object({apiKey:P.string().matches(/^uf.+$/,"API keys start with `uf`, double check your API key"),apiHost:P.string().matches(/^https:\/\/(localhost:8889|([a-z]+\.)?uniform.app)$/,"API host must be a Uniform domain."),logLevel:P.string(),projectId:P.string().uuid()}),Pt=({settings:e,saveSettings:r,dimensionIndex:{error:n,loading:o}})=>{let a=[{value:"none",text:"Logging off"},{value:"info",text:"Log info, warnings, and errors"},{value:"warn",text:"Log warnings and errors"},{value:"error",text:"Log errors"},{value:"debug",text:"Verbose debug logging"}];return(0,t.jsx)(C.Formik,{initialValues:{apiHost:"",apiKey:"",projectId:"",logLevel:"none",...e},validationSchema:ee,enableReinitialize:!0,onSubmit:i=>{r({...e,apiHost:i.apiHost,apiKey:i.apiKey,projectId:i.projectId,logLevel:i.logLevel})}},({dirty:i,isValid:m,isSubmitting:f})=>(0,t.jsx)(C.Form,{css:u.page},(0,t.jsx)("h1",{css:u.title},"Settings"),(0,t.jsx)(C.Field,{component:St,label:"Logging",caption:"Logs can be viewed in the browser console",id:"logging",name:"logLevel",options:a,disabled:f}),(0,t.jsx)(rt,{disabled:f},(0,t.jsx)(nt,null,"Data Connection"),!o&&n?(0,t.jsx)("p",{css:u.error},"Unable to fetch data from Uniform",(0,t.jsx)("br",null),(0,t.jsx)("em",null,n.message)):null,(0,t.jsx)("p",{css:u.text},(0,t.jsx)("small",null,"Adding an API key and project ID enables richer dimension data to be shown. You must have access to the Uniform project to do this.")),(0,t.jsx)(C.Field,{component:J,label:"Uniform API key",caption:"Generate an API key in your Uniform team settings. Grant only Context: Read Drafts permission.",id:"api-key",name:"apiKey",autoComplete:"off"}),(0,t.jsx)(C.Field,{component:J,label:"Uniform Project ID",caption:"Available after generating an API key ",id:"project-id",name:"projectId",autoComplete:"off"}),(0,t.jsx)(Z,null,(0,t.jsx)(U,{title:"Advanced"},(0,t.jsx)(C.Field,{component:J,label:"Alternative API Host",caption:"Use a non-standard Uniform API endpoint. Most people will not not need this option.",id:"api-host",name:"apiHost",autoComplete:"off"}))),i?(0,t.jsx)(H,{type:"submit",css:u.submitButton,disabled:!m},"Save"):null)))};var at=({settings:e,saveSettings:r})=>{let n=()=>{r({...e,route:"/settings"})},o=()=>{r({...e,ignoreApiKeyPrompt:!0})},a=!(e==null?void 0:e.apiKey);return!e.ignoreApiKeyPrompt&&a?(0,t.jsx)("div",{css:[N,gt]},(0,t.jsx)("h2",{css:O},"Connect this site"),(0,t.jsx)("p",{css:_},"Add a Uniform API key to get better data."),(0,t.jsx)("div",{css:G},(0,t.jsx)(H,{buttonType:"secondary",onClick:n},"Connect this site"),(0,t.jsx)(H,{buttonType:"ghost",onClick:o},"Skip for now")),(0,t.jsx)("button",{type:"button",css:ft,title:"close",onClick:o},(0,t.jsx)("span",{hidden:!0},"Close"))):null};var A=require("@uniformdev/context/api"),At=require("react-use"),Mt=T(require("react"));function zt({apiHost:e,apiKey:r,projectId:n},o){let a=Mt.useMemo(()=>{var l,p,b,h;let c={};return o&&(Object.keys((p=(l=o==null?void 0:o.project.pz)==null?void 0:l.sig)!=null?p:{}).forEach(g=>{let L=(0,A.computeDimensionDisplayData)(g,o);L&&(c[g]=L)}),Object.keys((h=(b=o==null?void 0:o.project.pz)==null?void 0:b.agg)!=null?h:{}).forEach(g=>{let L=(0,A.computeDimensionDisplayData)(g,o);L&&(c[g]=L)})),c},[o]),{loading:i,error:m,value:f}=(0,At.useAsync)(async()=>{if(!r||!n)return a;let l=(await new A.DimensionClient({projectId:n,apiKey:r,apiHost:e||void 0}).get()).dimensions,p={...a};return l.forEach(b=>{p[b.dim]=(0,A.computeDimensionDefinitionDisplayData)(b)}),p},[e,r,n,a]);return{loading:i,error:m,index:f!=null?f:a}}var tt=require("@emotion/react");function j(){return(0,t.jsx)("style",null,`
1251
+ border-bottom: 1px solid var(--gray-400);
1252
+ width: 100%;
1253
+ `
1254
+ }, children);
1255
+ };
1256
+
1257
+ // src/lib/computeOverrideEffects.ts
1258
+ var import_context = require("@uniformdev/context");
1259
+ function computeOverrideEffects({ manifest, visitor, override }) {
1260
+ const contextCopy = new import_context.Context({
1261
+ manifest,
1262
+ transitionStore: new CopyTransitionDataStore({ initialData: visitor })
1263
+ });
1264
+ const currentScores = { ...contextCopy.scores };
1265
+ contextCopy.storage.updateData([override]);
1266
+ const newScores = { ...contextCopy.scores };
1267
+ const changes = { ...newScores };
1268
+ Object.entries(changes).forEach(([key, value]) => {
1269
+ const oldScore = currentScores[key];
1270
+ if (oldScore === value) {
1271
+ delete changes[key];
1272
+ }
1273
+ });
1274
+ return changes;
1275
+ }
1276
+ var CopyTransitionDataStore = class extends import_context.TransitionDataStore {
1277
+ async handleDelete() {
1278
+ }
1279
+ async handleUpdateData() {
1280
+ }
1281
+ };
1282
+
1283
+ // src/lib/applyOverrides.ts
1284
+ function applyScoreOverrides({
1285
+ scores,
1286
+ scoreOverrides
1287
+ }) {
1288
+ const commands = [];
1289
+ if (!scoreOverrides)
1290
+ return [];
1291
+ Object.entries(scoreOverrides).forEach(([dim, override]) => {
1292
+ var _a;
1293
+ const score = (_a = scores[dim]) != null ? _a : 0;
1294
+ if (score === override.override) {
1295
+ return;
1296
+ }
1297
+ const delta = override.override - score;
1298
+ commands.push({
1299
+ type: "modscoreS",
1300
+ data: { dimension: dim, delta }
1301
+ });
1302
+ });
1303
+ return commands;
1304
+ }
1305
+ function applyQuirkOverrides({
1306
+ quirks,
1307
+ quirkOverrides
1308
+ }) {
1309
+ const quirkVector = {};
1310
+ if (!quirkOverrides)
1311
+ return void 0;
1312
+ Object.entries(quirkOverrides).forEach(([quirk, override]) => {
1313
+ const quirkValue = quirks[quirk];
1314
+ if (quirkValue === override.override) {
1315
+ return;
1316
+ }
1317
+ quirkVector[quirk] = override.override;
1318
+ });
1319
+ return Object.keys(quirkVector).length > 0 ? quirkVector : void 0;
1320
+ }
1321
+
1322
+ // src/components/Personalization/AddOverride.tsx
1323
+ var overrideSettingsSchema = yup.object({
1324
+ dimension: yup.string(),
1325
+ score: yup.number()
1326
+ });
1327
+ var AddOverride = ({
1328
+ settings,
1329
+ saveSettings,
1330
+ state,
1331
+ actions,
1332
+ dimensionIndex: { index }
1333
+ }) => {
1334
+ var _a, _b;
1335
+ const routeParams = settings.route ? [...settings.route.matchAll(/overrides\/(?!.*add)(\w+)?/g)] : [];
1336
+ const overriddenDimension = routeParams[0] ? routeParams[0][1] : "";
1337
+ if (!((_a = state.manifest.project.pz) == null ? void 0 : _a.sig)) {
1338
+ return /* @__PURE__ */ (0, import_react.jsx)("p", null, "Error, manifest is broken or there is no signal to override.");
1339
+ }
1340
+ const overridableDimensions = Object.entries(index).filter(([, value]) => value.type !== "Audience" && value.type !== "Intent").map(([key, value]) => {
1341
+ const type = value.type ? `${value.type}: ` : "";
1342
+ const category = value.category ? `${value.category} - ` : "";
1343
+ const text = `${type}${category}${value.name}`;
1344
+ return {
1345
+ value: key,
1346
+ text
1347
+ };
1348
+ });
1349
+ overridableDimensions.unshift({
1350
+ value: "_none",
1351
+ text: "Choose dimension to override"
1352
+ });
1353
+ return /* @__PURE__ */ (0, import_react.jsx)(import_formik3.Formik, {
1354
+ initialValues: {
1355
+ dimension: overriddenDimension,
1356
+ score: (_b = state.scores[overriddenDimension]) != null ? _b : 0
1357
+ },
1358
+ validationSchema: overrideSettingsSchema,
1359
+ enableReinitialize: true,
1360
+ onSubmit: async (values) => {
1361
+ var _a2, _b2, _c, _d, _e, _f;
1362
+ const cap = (_b2 = (_a2 = index[values.dimension]) == null ? void 0 : _a2.cap) != null ? _b2 : 0;
1363
+ const cappedOverrideScore = Math.min(values.score, cap);
1364
+ const newSettings = {
1365
+ ...settings,
1366
+ scoreOverrides: {
1367
+ ...settings.scoreOverrides,
1368
+ [values.dimension]: {
1369
+ 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,
1370
+ override: cappedOverrideScore
1371
+ }
1372
+ },
1373
+ route: "/overrides"
1374
+ };
1375
+ await saveSettings(newSettings);
1376
+ const applyCommands = applyScoreOverrides({
1377
+ scores: state.scores,
1378
+ scoreOverrides: newSettings.scoreOverrides
1379
+ });
1380
+ actions.rawUpdate(applyCommands);
1381
+ }
1382
+ }, ({ dirty, isValid, isSubmitting, values }) => {
1383
+ var _a2;
1384
+ const overrideEffects = computeOverrideEffects({
1385
+ manifest: state.manifest,
1386
+ visitor: state.data,
1387
+ override: {
1388
+ type: "modscore",
1389
+ data: {
1390
+ dimension: values.dimension,
1391
+ delta: values.score - ((_a2 = state.scores[values.dimension]) != null ? _a2 : 0)
1392
+ }
1393
+ }
1394
+ });
1395
+ const preemptiveOverrides = Object.entries(state.scores).reduce((acc, [key, value]) => {
1396
+ acc[key] = {
1397
+ initial: value,
1398
+ override: value
1399
+ };
1400
+ return acc;
1401
+ }, {});
1402
+ const hasScoreEffects = values.score && Object.keys(overrideEffects).length > 0;
1403
+ return /* @__PURE__ */ (0, import_react.jsx)(import_formik3.Form, {
1404
+ css: styles.page
1405
+ }, /* @__PURE__ */ (0, import_react.jsx)("h1", {
1406
+ css: styles.title
1407
+ }, "Override Dimension"), /* @__PURE__ */ (0, import_react.jsx)(import_formik3.Field, {
1408
+ component: SelectInput,
1409
+ label: "Dimension",
1410
+ id: "dimension",
1411
+ name: "dimension",
1412
+ options: overridableDimensions,
1413
+ disabled: isSubmitting
1414
+ }), /* @__PURE__ */ (0, import_react.jsx)("p", {
1415
+ css: styles.text
1416
+ }, /* @__PURE__ */ (0, import_react.jsx)("small", null, "Audiences and Intents are aggregated from other dimension scores and cannot be overridden directly.")), values.dimension ? /* @__PURE__ */ (0, import_react.jsx)(DependableSelectBox_default, {
1417
+ name: "score",
1418
+ label: "Score",
1419
+ dimensionToOverride: index[values.dimension],
1420
+ isSubmitting
1421
+ }) : null, /* @__PURE__ */ (0, import_react.jsx)(Fieldset, {
1422
+ disabled: isSubmitting,
1423
+ css: { marginBottom: "2rem" }
1424
+ }, hasScoreEffects ? /* @__PURE__ */ (0, import_react.jsx)(Accordion, null, /* @__PURE__ */ (0, import_react.jsx)(AccordionItem, {
1425
+ title: `Impacted Dimensions (${Object.keys(overrideEffects).length})`
1426
+ }, /* @__PURE__ */ (0, import_react.jsx)(DimensionsTable_default, {
1427
+ preemptiveOverrides,
1428
+ dimensionIndex: index,
1429
+ dimensions: overrideEffects,
1430
+ disableEditOverride: true
1431
+ }))) : null, dirty ? /* @__PURE__ */ (0, import_react.jsx)(Button, {
1432
+ type: "submit",
1433
+ css: styles.submitButton,
1434
+ disabled: !isValid
1435
+ }, "Save") : null, /* @__PURE__ */ (0, import_react.jsx)(NavigationLink_default, {
1436
+ route: "/overrides",
1437
+ css: styles.cancelButton
1438
+ }, "Cancel")));
1439
+ });
1440
+ };
1441
+
1442
+ // src/components/Personalization/Quirks.tsx
1443
+ var import_react18 = require("react");
1444
+
1445
+ // src/components/Inputs/EditableText.tsx
1446
+ var import_react17 = require("react");
1447
+ var EditableText = ({ name, value, submit }) => {
1448
+ const [inputValue, setInputValue] = (0, import_react17.useState)(value != null ? value : "");
1449
+ (0, import_react17.useEffect)(() => {
1450
+ setInputValue(value != null ? value : "");
1451
+ }, [value]);
1452
+ const onChange = (e) => {
1453
+ setInputValue(e.target.value);
1454
+ };
1455
+ return /* @__PURE__ */ (0, import_react.jsx)("div", {
1456
+ css: { display: "flex", gap: "var(--spacing-sm)" }
1457
+ }, /* @__PURE__ */ (0, import_react.jsx)("input", {
1458
+ type: "text",
1459
+ css: [textInput, editableInput],
1460
+ name,
1461
+ value: inputValue,
1462
+ onChange
1463
+ }), /* @__PURE__ */ (0, import_react.jsx)(Button, {
1464
+ buttonType: "primary",
1465
+ onClick: () => submit(name, inputValue != null ? inputValue : "")
1466
+ }, "Save"));
1467
+ };
1468
+ var EditableText_default = EditableText;
1469
+
1470
+ // src/components/Inputs/EditableSelectBox.tsx
1471
+ var EditableSelectBox = ({ name, value, submit, options }) => {
1472
+ const onChange = (e) => submit(e.target.name, e.target.value);
1473
+ return /* @__PURE__ */ (0, import_react.jsx)("select", {
1474
+ name,
1475
+ defaultValue: value,
1476
+ onChange,
1477
+ css: [selectInput, editableInput]
1478
+ }, /* @__PURE__ */ (0, import_react.jsx)("option", {
1479
+ key: "_none",
1480
+ value: "_none"
1481
+ }, "None"), (options != null ? options : []).map((option) => /* @__PURE__ */ (0, import_react.jsx)("option", {
1482
+ key: option.value,
1483
+ value: option.value
1484
+ }, option.name)));
1485
+ };
1486
+ var EditableSelectBox_default = EditableSelectBox;
1487
+
1488
+ // src/components/Personalization/Quirks.tsx
1489
+ var Quirks = ({ ...props }) => {
1490
+ const {
1491
+ state: {
1492
+ data: { quirks }
1493
+ },
1494
+ quirksIndex: { index: quirksIndex },
1495
+ settings,
1496
+ saveSettings,
1497
+ actions
1498
+ } = props;
1499
+ const [editable, setEditable] = (0, import_react18.useState)("");
1500
+ let editableQuirkMetaData;
1501
+ if (editable) {
1502
+ editableQuirkMetaData = quirksIndex[editable];
1503
+ }
1504
+ const submitOverride = async (name, value) => {
1505
+ var _a, _b, _c;
1506
+ setEditable("");
1507
+ const newSettings = {
1508
+ ...settings,
1509
+ quirkOverrides: {
1510
+ ...settings.quirkOverrides,
1511
+ [name]: { initial: (_c = (_b = (_a = settings.quirkOverrides) == null ? void 0 : _a[name]) == null ? void 0 : _b.initial) != null ? _c : quirks[name], override: value }
1512
+ }
1513
+ };
1514
+ await saveSettings(newSettings);
1515
+ const quirkOverrides = applyQuirkOverrides({
1516
+ quirks,
1517
+ quirkOverrides: newSettings.quirkOverrides
1518
+ });
1519
+ actions.update({ quirks: quirkOverrides });
1520
+ };
1521
+ return /* @__PURE__ */ (0, import_react.jsx)(React.Fragment, null, /* @__PURE__ */ (0, import_react.jsx)("article", {
1522
+ css: styles.page
1523
+ }, /* @__PURE__ */ (0, import_react.jsx)("h1", {
1524
+ css: styles.title
1525
+ }, "Quirks"), /* @__PURE__ */ (0, import_react.jsx)("p", {
1526
+ css: styles.text
1527
+ }, "Keys defined in Uniform and their current, programmatically defined values for this visit."), Object.keys(quirksIndex).length ? /* @__PURE__ */ (0, import_react.jsx)(Table, null, /* @__PURE__ */ (0, import_react.jsx)(THead, null, /* @__PURE__ */ (0, import_react.jsx)(TRow, null, /* @__PURE__ */ (0, import_react.jsx)(THeading, null, "Key"), /* @__PURE__ */ (0, import_react.jsx)(THeading, null, "Value"), /* @__PURE__ */ (0, import_react.jsx)(TData, null, ""))), /* @__PURE__ */ (0, import_react.jsx)(TBody, null, Object.values(quirksIndex).map(({ name, value, id }) => {
1528
+ var _a, _b, _c;
1529
+ const initialValue = (_b = (_a = settings.quirkOverrides) == null ? void 0 : _a[name]) == null ? void 0 : _b.initial;
1530
+ return /* @__PURE__ */ (0, import_react.jsx)(TRow, {
1531
+ key: id,
1532
+ border: "bottom"
1533
+ }, /* @__PURE__ */ (0, import_react.jsx)(TData, null, /* @__PURE__ */ (0, import_react.jsx)("strong", null, name)), /* @__PURE__ */ (0, import_react.jsx)(TData, null, editable !== id ? /* @__PURE__ */ (0, import_react.jsx)("div", {
1534
+ onClick: () => {
1535
+ setEditable(id);
1536
+ }
1537
+ }, initialValue ? /* @__PURE__ */ (0, import_react.jsx)("div", null, /* @__PURE__ */ (0, import_react.jsx)("s", null, initialValue)) : null, value) : null, editable === id && editableQuirkMetaData && /* @__PURE__ */ (0, import_react.jsx)(React.Fragment, null, editableQuirkMetaData.options ? /* @__PURE__ */ (0, import_react.jsx)(EditableSelectBox_default, {
1538
+ name: id,
1539
+ value,
1540
+ submit: submitOverride,
1541
+ options: editableQuirkMetaData.options
1542
+ }) : /* @__PURE__ */ (0, import_react.jsx)(EditableText_default, {
1543
+ name: id,
1544
+ value,
1545
+ submit: submitOverride
1546
+ }))), /* @__PURE__ */ (0, import_react.jsx)(TData, null, editable ? null : ((_c = settings.quirkOverrides) == null ? void 0 : _c[id]) ? /* @__PURE__ */ (0, import_react.jsx)(LinkButton, {
1547
+ onClick: () => {
1548
+ deleteQuirkOverride({ quirk: id, settings, saveSettings, actions });
1549
+ }
1550
+ }, /* @__PURE__ */ (0, import_react.jsx)("small", null, "Clear Override")) : /* @__PURE__ */ (0, import_react.jsx)(LinkButton, {
1551
+ onClick: () => {
1552
+ setEditable(id);
1553
+ }
1554
+ }, /* @__PURE__ */ (0, import_react.jsx)("small", null, "Override"))));
1555
+ }))) : /* @__PURE__ */ (0, import_react.jsx)(NoActiveDimensions, {
1556
+ title: "No quirks configured",
1557
+ text: "There are currently no quirks setup. Try to connect to Uniform API to load additional information about Quirks and Quirks without defined value."
1558
+ })));
1559
+ };
1560
+
1561
+ // src/components/Personalization/Settings.tsx
1562
+ var import_formik5 = require("formik");
1563
+
1564
+ // src/components/Inputs/InputText.tsx
1565
+ var import_formik4 = require("formik");
1566
+ var InputText = ({ field, form, meta, ...rawProps }) => {
1567
+ const { label, caption, ...passThroughProps } = rawProps;
1568
+ return /* @__PURE__ */ (0, import_react.jsx)("div", {
1569
+ css: inputWrapper
1570
+ }, /* @__PURE__ */ (0, import_react.jsx)("label", {
1571
+ css: inputLabel
1572
+ }, /* @__PURE__ */ (0, import_react.jsx)("span", {
1573
+ css: inputText
1574
+ }, label), /* @__PURE__ */ (0, import_react.jsx)("input", {
1575
+ type: "text",
1576
+ css: textInput,
1577
+ ...field,
1578
+ ...passThroughProps
1579
+ })), caption ? /* @__PURE__ */ (0, import_react.jsx)("span", {
1580
+ css: inputCaption
1581
+ }, caption) : null, /* @__PURE__ */ (0, import_react.jsx)(import_formik4.ErrorMessage, {
1582
+ component: "div",
1583
+ css: errorMsg,
1584
+ name: field.name
1585
+ }));
1586
+ };
1587
+
1588
+ // src/components/Personalization/Settings.tsx
1589
+ var yup2 = __toESM(require("yup"));
1590
+ var editableSettingsSchema = yup2.object({
1591
+ apiKey: yup2.string().matches(/^uf.+$/, "API keys start with `uf`, double check your API key"),
1592
+ apiHost: yup2.string().matches(/^https:\/\/(localhost:8889|([a-z]+\.)?uniform.app)$/, "API host must be a Uniform domain."),
1593
+ logging: yup2.boolean(),
1594
+ projectId: yup2.string().uuid(),
1595
+ consentMode: yup2.boolean()
1596
+ });
1597
+ var Settings = ({
1598
+ settings,
1599
+ saveSettings,
1600
+ actions,
1601
+ state: { data },
1602
+ dimensionIndex: { error, loading }
1603
+ }) => {
1604
+ var _a, _b, _c;
1605
+ return /* @__PURE__ */ (0, import_react.jsx)(import_formik5.Formik, {
1606
+ initialValues: {
1607
+ apiHost: (_a = settings.apiHost) != null ? _a : "",
1608
+ apiKey: (_b = settings.apiKey) != null ? _b : "",
1609
+ projectId: (_c = settings.projectId) != null ? _c : "",
1610
+ consentMode: !!data.consent,
1611
+ logging: settings.logLevel !== "none" && Boolean(settings.logLevel)
1612
+ },
1613
+ validationSchema: editableSettingsSchema,
1614
+ enableReinitialize: true,
1615
+ onSubmit: (values) => {
1616
+ saveSettings({
1617
+ ...settings,
1618
+ apiHost: values.apiHost,
1619
+ apiKey: values.apiKey,
1620
+ projectId: values.projectId,
1621
+ logLevel: values.logging ? "debug" : "none",
1622
+ consentMode: values.consentMode
1623
+ });
1624
+ actions.rawUpdate([{ type: "consent", data: values.consentMode }]);
1625
+ }
1626
+ }, ({ dirty, isValid, isSubmitting }) => /* @__PURE__ */ (0, import_react.jsx)(import_formik5.Form, {
1627
+ css: styles.page
1628
+ }, /* @__PURE__ */ (0, import_react.jsx)("h1", {
1629
+ css: styles.title
1630
+ }, "Settings"), /* @__PURE__ */ (0, import_react.jsx)(Fieldset, {
1631
+ disabled: isSubmitting
1632
+ }, /* @__PURE__ */ (0, import_react.jsx)(Legend, null, "Data Connection"), !loading && error ? /* @__PURE__ */ (0, import_react.jsx)("p", {
1633
+ css: styles.error
1634
+ }, "Unable to fetch data from Uniform", /* @__PURE__ */ (0, import_react.jsx)("br", null), /* @__PURE__ */ (0, import_react.jsx)("em", null, error.message)) : null, /* @__PURE__ */ (0, import_react.jsx)("p", {
1635
+ css: styles.text
1636
+ }, /* @__PURE__ */ (0, import_react.jsx)("small", null, "Adding an API key and project ID enables richer dimension data to be shown. You must have access to the Uniform project to do this.")), /* @__PURE__ */ (0, import_react.jsx)(import_formik5.Field, {
1637
+ component: InputText,
1638
+ label: "Uniform API key",
1639
+ caption: "Generate an API key in your Uniform team settings. Grant only Context: Read Drafts permission.",
1640
+ id: "api-key",
1641
+ name: "apiKey",
1642
+ autoComplete: "off"
1643
+ }), /* @__PURE__ */ (0, import_react.jsx)(import_formik5.Field, {
1644
+ component: InputText,
1645
+ label: "Uniform Project ID",
1646
+ caption: "Available to copy after generating an API key",
1647
+ id: "project-id",
1648
+ name: "projectId",
1649
+ autoComplete: "off"
1650
+ }), /* @__PURE__ */ (0, import_react.jsx)(Accordion, null, /* @__PURE__ */ (0, import_react.jsx)(AccordionItem, {
1651
+ title: "Advanced"
1652
+ }, /* @__PURE__ */ (0, import_react.jsx)(import_formik5.Field, {
1653
+ component: InputText,
1654
+ label: "Alternative API Host",
1655
+ caption: "Use a non-standard Uniform API endpoint. Most people will not not need this option.",
1656
+ id: "api-host",
1657
+ name: "apiHost",
1658
+ autoComplete: "off"
1659
+ }))), /* @__PURE__ */ (0, import_react.jsx)(Fieldset, null, /* @__PURE__ */ (0, import_react.jsx)(Legend, null, "Storage Consent"), /* @__PURE__ */ (0, import_react.jsx)(import_formik5.Field, {
1660
+ component: FormikSwitchInput,
1661
+ label: "Store visitor data",
1662
+ id: "consent-mode",
1663
+ name: "consentMode"
1664
+ }), /* @__PURE__ */ (0, import_react.jsx)("p", null, /* @__PURE__ */ (0, import_react.jsx)("small", null, "Turning on consents to 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."))), /* @__PURE__ */ (0, import_react.jsx)(Fieldset, null, /* @__PURE__ */ (0, import_react.jsx)(Legend, null, "Logging"), /* @__PURE__ */ (0, import_react.jsx)(import_formik5.Field, {
1665
+ component: FormikSwitchInput,
1666
+ label: "Write Uniform Context diagnostic logs to browser console",
1667
+ id: "logging",
1668
+ name: "logging"
1669
+ })), dirty ? /* @__PURE__ */ (0, import_react.jsx)(Button, {
1670
+ type: "submit",
1671
+ css: styles.submitButton,
1672
+ disabled: !isValid
1673
+ }, "Save") : null)));
1674
+ };
1675
+
1676
+ // src/components/CallToAction/ConnectApiKey.tsx
1677
+ var ConnectApiKey = ({ settings, saveSettings }) => {
1678
+ const handleRedirect = () => {
1679
+ saveSettings({ ...settings, route: "/settings" });
1680
+ };
1681
+ const dismissPrompt = () => {
1682
+ saveSettings({ ...settings, ignoreApiKeyPrompt: true });
1683
+ };
1684
+ const missingApiKey = !(settings == null ? void 0 : settings.apiKey);
1685
+ return !settings.ignoreApiKeyPrompt && missingApiKey ? /* @__PURE__ */ (0, import_react.jsx)("div", {
1686
+ css: [cta, ctaWithIcon]
1687
+ }, /* @__PURE__ */ (0, import_react.jsx)("h2", {
1688
+ css: ctaTitle
1689
+ }, "Connect this site"), /* @__PURE__ */ (0, import_react.jsx)("p", {
1690
+ css: ctaText
1691
+ }, "Add a Uniform API key to get better data."), /* @__PURE__ */ (0, import_react.jsx)("div", {
1692
+ css: ctaBtnGroup
1693
+ }, /* @__PURE__ */ (0, import_react.jsx)(Button, {
1694
+ buttonType: "secondary",
1695
+ onClick: handleRedirect
1696
+ }, "Connect this site"), /* @__PURE__ */ (0, import_react.jsx)(Button, {
1697
+ buttonType: "ghost",
1698
+ onClick: dismissPrompt
1699
+ }, "Skip for now")), /* @__PURE__ */ (0, import_react.jsx)("button", {
1700
+ type: "button",
1701
+ css: ctaClose,
1702
+ title: "close",
1703
+ onClick: dismissPrompt
1704
+ }, /* @__PURE__ */ (0, import_react.jsx)("span", {
1705
+ hidden: true
1706
+ }, "Close"))) : null;
1707
+ };
1708
+
1709
+ // src/hooks/useDimensionIndex.ts
1710
+ var import_api = require("@uniformdev/context/api");
1711
+ var import_react_use = require("react-use");
1712
+ var React6 = __toESM(require("react"));
1713
+ function useDimensionIndex({ apiHost, apiKey, projectId }, manifest) {
1714
+ const { loading, error, value } = (0, import_react_use.useAsync)(async () => {
1715
+ if (!apiKey || !projectId) {
1716
+ return manifestData;
1717
+ }
1718
+ const client = new import_api.DimensionClient({
1719
+ projectId,
1720
+ apiKey,
1721
+ apiHost: apiHost ? apiHost : void 0
1722
+ });
1723
+ const dimensions = (await client.get()).dimensions;
1724
+ const result = {};
1725
+ dimensions.map((dimension) => {
1726
+ var _a, _b, _c, _d;
1727
+ result[dimension.dim] = {
1728
+ ...(0, import_api.computeDimensionDefinitionDisplayData)(dimension),
1729
+ cap: dimension.cap,
1730
+ str: 10
1731
+ };
1732
+ if (result[dimension.dim].type === "Enrichment") {
1733
+ const enrId = dimension.dim.split("_")[0];
1734
+ result[dimension.dim].cap = (_d = (_c = (_b = (_a = manifest == null ? void 0 : manifest.project.pz) == null ? void 0 : _a.enr) == null ? void 0 : _b[enrId]) == null ? void 0 : _c.cap) != null ? _d : 100;
1735
+ }
1736
+ });
1737
+ return result;
1738
+ }, [apiHost, apiKey, projectId]);
1739
+ const manifestData = React6.useMemo(() => {
1740
+ var _a, _b, _c, _d;
1741
+ const data = {};
1742
+ if (!manifest) {
1743
+ return data;
1744
+ }
1745
+ Object.entries((_b = (_a = manifest == null ? void 0 : manifest.project.pz) == null ? void 0 : _a.sig) != null ? _b : {}).map(([dimensionId, dimension]) => {
1746
+ const dim = (0, import_api.computeDimensionDisplayData)(dimensionId, manifest);
1747
+ if (dim) {
1748
+ data[dimensionId] = { ...dimension, ...dim };
1749
+ }
1750
+ });
1751
+ Object.entries((_d = (_c = manifest == null ? void 0 : manifest.project.pz) == null ? void 0 : _c.enr) != null ? _d : {}).map(([dimensionId, enr]) => {
1752
+ var _a2;
1753
+ const dim = (0, import_api.computeDimensionDisplayData)(dimensionId, manifest);
1754
+ const signal = { cap: (_a2 = enr.cap) != null ? _a2 : 100, str: 10 };
1755
+ if (dim) {
1756
+ data[dimensionId] = { ...dim, cap: signal.cap, str: signal.str };
1757
+ }
1758
+ });
1759
+ if (value) {
1760
+ Object.entries(value).map(([dimensionId, dimension]) => {
1761
+ data[dimensionId] = {
1762
+ ...data[dimensionId],
1763
+ ...dimension
1764
+ };
1765
+ });
1766
+ }
1767
+ return data;
1768
+ }, [manifest, value]);
1769
+ return {
1770
+ loading,
1771
+ error,
1772
+ index: manifestData
1773
+ };
1774
+ }
1775
+
1776
+ // src/hooks/useQuirkIndex.ts
1777
+ var import_react19 = require("react");
1778
+ var import_api2 = require("@uniformdev/context/api");
1779
+ var import_react_use2 = require("react-use");
1780
+ function useQuirkIndex({ apiHost, apiKey, projectId }, quirksData) {
1781
+ const { loading, error, value } = (0, import_react_use2.useAsync)(async () => {
1782
+ if (!apiKey || !projectId) {
1783
+ return {};
1784
+ }
1785
+ const client = new import_api2.QuirkClient({
1786
+ projectId,
1787
+ apiKey,
1788
+ apiHost: apiHost ? apiHost : void 0
1789
+ });
1790
+ const quirksResponse = await client.get();
1791
+ const quirksIndexData = {};
1792
+ quirksResponse.quirks.map((quirkData) => {
1793
+ quirksIndexData[quirkData.id] = { ...quirkData, value: quirksData[quirkData.id] };
1794
+ });
1795
+ return quirksIndexData;
1796
+ }, [apiHost, apiKey, projectId]);
1797
+ const contextStateQuirkData = (0, import_react19.useMemo)(() => {
1798
+ const data = {};
1799
+ Object.entries(quirksData).map(([quirkId, queryrValue]) => data[quirkId] = {
1800
+ value: queryrValue,
1801
+ id: quirkId,
1802
+ name: quirkId
1803
+ });
1804
+ if (value) {
1805
+ Object.entries(value).map(([quirkId, quirkValue]) => data[quirkId] = {
1806
+ ...quirkValue,
1807
+ value: quirksData[quirkId]
1808
+ });
1809
+ }
1810
+ return data;
1811
+ }, [quirksData, value]);
1812
+ return {
1813
+ loading,
1814
+ error,
1815
+ index: contextStateQuirkData
1816
+ };
1817
+ }
1818
+
1819
+ // src/components/ContextDevTools.tsx
1820
+ var import_react21 = require("@emotion/react");
1821
+
1822
+ // src/styles/Theme.tsx
1823
+ function Theme() {
1824
+ return /* @__PURE__ */ (0, import_react.jsx)("style", null, `
337
1825
  :root {
338
1826
  --brand-primary-1: #438fd5; /* bright blue */
339
1827
  --brand-primary-2: #f4220b; /* red */
@@ -393,6 +1881,10 @@ to {
393
1881
  --gray-800: #1f2937;
394
1882
  --gray-900: #111827;
395
1883
 
1884
+ /* Red CTA */
1885
+ --red-button: rgb(217 83 79);
1886
+ --red-tooltip: #D9534F;
1887
+
396
1888
  /* z-indexs */
397
1889
  --z-10: 10;
398
1890
  }
@@ -694,7 +2186,29 @@ Add the correct display in Chrome and Safari.
694
2186
 
695
2187
  summary {
696
2188
  display: list-item;
697
- }`)}var oe=tt.css`
2189
+ }`);
2190
+ }
2191
+
2192
+ // src/components/StatusPages/AdditionalDataLoading.tsx
2193
+ var import_react20 = require("react");
2194
+ var import_react_use3 = require("react-use");
2195
+ var AdditionalDataLoading = () => {
2196
+ const [viz, setViz] = (0, import_react20.useState)(false);
2197
+ const mounted = (0, import_react_use3.useMountedState)();
2198
+ (0, import_react20.useEffect)(() => {
2199
+ setTimeout(() => {
2200
+ if (mounted()) {
2201
+ setViz(true);
2202
+ }
2203
+ }, 1e3);
2204
+ }, [mounted]);
2205
+ return viz ? /* @__PURE__ */ (0, import_react.jsx)("article", {
2206
+ css: styles.page
2207
+ }, /* @__PURE__ */ (0, import_react.jsx)("h1", null, "Loading..."), /* @__PURE__ */ (0, import_react.jsx)("p", null, "Connecting to Uniform API for complete data.")) : null;
2208
+ };
2209
+
2210
+ // src/components/ContextDevTools.tsx
2211
+ var mainLayoutStyle = import_react21.css`
698
2212
  background: var(--white);
699
2213
  padding: var(--spacing-base);
700
2214
  overflow-y: auto;
@@ -723,23 +2237,166 @@ summary {
723
2237
  &::-webkit-scrollbar-thumb:hover {
724
2238
  background: var(--gray-500);
725
2239
  }
726
- `;function it(e){let r=typeof chrome!="undefined"&&typeof chrome.storage!="undefined",n=zt(e.settings,e.state.manifest),o={...e,dimensionIndex:n},a=()=>{var i;switch((i=e.settings)==null?void 0:i.route){case void 0:case"/":case"/dimensions":return(0,t.jsx)(Lt,{...o});case"/quirks":return(0,t.jsx)(Tt,{...o});case"/settings":return(0,t.jsx)(Pt,{...o});default:return(0,t.jsx)(dt,null)}};return(0,t.jsx)(d.Fragment,null,(0,t.jsx)(j,null),(0,t.jsx)("div",{css:[tt.css`
727
- display: grid;
728
- grid-template-columns: 200px auto;
729
- font-weight: var(--font-regular);
730
- font-size: var(--base-font-size);
731
- font-family: var(--base-font-family);
732
- line-height: var(--base-line-height);
733
- height: var(--min-height);
734
- min-width: var(--site-width);
735
- `,r?void 0:tt.css`
736
- box-shadow: var(--shadow-base);
737
- position: fixed;
738
- bottom: 82px;
739
- right: var(--spacing-base);
740
- z-index: var(--z-10);
741
- max-width: var(--site-width);
742
- `]},(0,t.jsx)(pt,{...e}),(0,t.jsx)("main",{css:oe},(0,t.jsx)(at,{...e}),a())))}var et=require("@uniformdev/context"),D=T(require("react"));function st({context:e,initialSettings:r}){let n=e!=null?e:typeof window!="undefined"?window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__:void 0,o=n!=null?n:new et.Context({manifest:{project:{}}}),[a,i]=D.useState({data:o.storage.data,manifest:o.manifest.data,scores:o.scores,personalizations:[],tests:[]}),[m,f]=D.useState(r!=null?r:{});D.useEffect(()=>{var p;let l=(0,et.createDebugConsoleLogDrain)((p=m.logLevel)!=null?p:"none");return o.events.on("log",l),()=>{o.events.off("log",l)}},[m,o]),D.useEffect(()=>{let l=()=>{i(h=>({...h,scores:o.scores,data:o.storage.data,manifest:o.manifest.data}))},p=h=>{!h.changed||i(g=>({...g,personalizations:[...g.personalizations,h]}))},b=h=>{!h.variantAssigned||i(g=>({...g,tests:[...g.tests,h]}))};return o.events.on("personalizationResult",p),o.events.on("testResult",b),o.storage.events.on("*",l),()=>{o.storage.events.off("*",l),o.events.off("personalizationResult",p),o.events.off("testResult",b)}},[o,m]);let c=D.useMemo(()=>({update:p=>o.update(p),forget:()=>o.forget(!1),rawUpdate:p=>o.storage.updateData(p)}),[o]);return n?(0,t.jsx)(it,{state:a,actions:c,settings:m,saveSettings:f}):(0,t.jsx)("p",null,"Unable to find Uniform Context. Ensure the devtools plugin is activated.")}var Bt=T(require("react"));var It=require("@emotion/react"),re=It.css`
2240
+ `;
2241
+ function ContextDevTools(props) {
2242
+ const dimensionIndex = useDimensionIndex(props.settings, props.state.manifest);
2243
+ const quirksIndex = useQuirkIndex(props.settings, props.state.data.quirks);
2244
+ const routeProps = {
2245
+ ...props,
2246
+ dimensionIndex,
2247
+ quirksIndex
2248
+ };
2249
+ const component = () => {
2250
+ var _a;
2251
+ if (dimensionIndex.loading || quirksIndex.loading) {
2252
+ return /* @__PURE__ */ (0, import_react.jsx)(AdditionalDataLoading, null);
2253
+ }
2254
+ if (props.settings.route) {
2255
+ if (props.settings.route.match(/overrides\/\w+/)) {
2256
+ return /* @__PURE__ */ (0, import_react.jsx)(AddOverride, {
2257
+ ...routeProps
2258
+ });
2259
+ }
2260
+ }
2261
+ switch ((_a = props.settings) == null ? void 0 : _a.route) {
2262
+ case void 0:
2263
+ case "/":
2264
+ case "/dimensions":
2265
+ return /* @__PURE__ */ (0, import_react.jsx)(Dimensions, {
2266
+ ...routeProps
2267
+ });
2268
+ case "/overrides":
2269
+ return /* @__PURE__ */ (0, import_react.jsx)(Overrides, {
2270
+ ...routeProps
2271
+ });
2272
+ case "/overrides/add":
2273
+ return /* @__PURE__ */ (0, import_react.jsx)(AddOverride, {
2274
+ ...routeProps
2275
+ });
2276
+ case "/quirks":
2277
+ return /* @__PURE__ */ (0, import_react.jsx)(Quirks, {
2278
+ ...routeProps
2279
+ });
2280
+ case "/settings":
2281
+ return /* @__PURE__ */ (0, import_react.jsx)(Settings, {
2282
+ ...routeProps
2283
+ });
2284
+ default:
2285
+ return /* @__PURE__ */ (0, import_react.jsx)(NotFound, null);
2286
+ }
2287
+ };
2288
+ return /* @__PURE__ */ (0, import_react.jsx)(DevToolsSettingsContextProvider, {
2289
+ settings: props.settings,
2290
+ saveSettings: props.saveSettings
2291
+ }, /* @__PURE__ */ (0, import_react.jsx)(Theme, null), /* @__PURE__ */ (0, import_react.jsx)("div", {
2292
+ css: import_react21.css`
2293
+ display: grid;
2294
+ grid-template-columns: 200px auto;
2295
+ font-weight: var(--font-regular);
2296
+ font-size: var(--base-font-size);
2297
+ font-family: var(--base-font-family);
2298
+ line-height: var(--base-line-height);
2299
+ height: var(--min-height);
2300
+ min-width: var(--site-width);
2301
+ `
2302
+ }, /* @__PURE__ */ (0, import_react.jsx)(Menu, {
2303
+ ...props
2304
+ }), /* @__PURE__ */ (0, import_react.jsx)("main", {
2305
+ css: mainLayoutStyle
2306
+ }, /* @__PURE__ */ (0, import_react.jsx)(ConnectApiKey, {
2307
+ ...props
2308
+ }), component())));
2309
+ }
2310
+
2311
+ // src/components/EmbeddedContextDevTools.tsx
2312
+ var import_context2 = require("@uniformdev/context");
2313
+ var React7 = __toESM(require("react"));
2314
+ function EmbeddedContextDevTools({ context, initialSettings }) {
2315
+ const contextValue = context != null ? context : typeof window !== "undefined" ? window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__ : void 0;
2316
+ const contextInstance = contextValue != null ? contextValue : new import_context2.Context({ manifest: { project: {} } });
2317
+ const [state, setState] = React7.useState({
2318
+ data: contextInstance.storage.data,
2319
+ manifest: contextInstance.manifest.data,
2320
+ scores: contextInstance.scores,
2321
+ personalizations: [],
2322
+ tests: []
2323
+ });
2324
+ const [settings, setSettings] = React7.useState(initialSettings != null ? initialSettings : {});
2325
+ React7.useEffect(() => {
2326
+ var _a;
2327
+ const drain = (0, import_context2.createDebugConsoleLogDrain)((_a = settings.logLevel) != null ? _a : "none");
2328
+ contextInstance.events.on("log", drain);
2329
+ return () => {
2330
+ contextInstance.events.off("log", drain);
2331
+ };
2332
+ }, [settings, contextInstance]);
2333
+ React7.useEffect(() => {
2334
+ const onContextDataUpdated = () => {
2335
+ const quirkOverrides = applyQuirkOverrides({
2336
+ quirks: contextInstance.storage.data.quirks,
2337
+ quirkOverrides: settings.quirkOverrides
2338
+ });
2339
+ if (quirkOverrides) {
2340
+ console.log("Applying overridden quirks:", quirkOverrides);
2341
+ contextInstance.update({ quirks: quirkOverrides });
2342
+ }
2343
+ const overrideCommands = applyScoreOverrides({
2344
+ scores: contextInstance.scores,
2345
+ scoreOverrides: settings.scoreOverrides
2346
+ });
2347
+ if (overrideCommands.length) {
2348
+ console.log("Applying overridden scores:", overrideCommands);
2349
+ contextInstance.storage.updateData(overrideCommands);
2350
+ }
2351
+ setState((old) => ({
2352
+ ...old,
2353
+ scores: contextInstance.scores,
2354
+ data: contextInstance.storage.data,
2355
+ manifest: contextInstance.manifest.data
2356
+ }));
2357
+ };
2358
+ const onPersonalizationResult = (e) => {
2359
+ if (!e.changed)
2360
+ return;
2361
+ setState((old) => ({ ...old, personalizations: [...old.personalizations, e] }));
2362
+ };
2363
+ const onTestResult = (e) => {
2364
+ if (!e.variantAssigned)
2365
+ return;
2366
+ setState((old) => ({ ...old, tests: [...old.tests, e] }));
2367
+ };
2368
+ contextInstance.events.on("personalizationResult", onPersonalizationResult);
2369
+ contextInstance.events.on("testResult", onTestResult);
2370
+ contextInstance.storage.events.on("*", onContextDataUpdated);
2371
+ return () => {
2372
+ contextInstance.storage.events.off("*", onContextDataUpdated);
2373
+ contextInstance.events.off("personalizationResult", onPersonalizationResult);
2374
+ contextInstance.events.off("testResult", onTestResult);
2375
+ };
2376
+ }, [contextInstance, settings]);
2377
+ const actions = React7.useMemo(() => {
2378
+ const actions2 = {
2379
+ update: (up) => contextInstance.update(up),
2380
+ forget: () => contextInstance.forget(false),
2381
+ rawUpdate: (commands) => contextInstance.storage.updateData(commands)
2382
+ };
2383
+ return actions2;
2384
+ }, [contextInstance]);
2385
+ return contextValue ? /* @__PURE__ */ (0, import_react.jsx)(ContextDevTools, {
2386
+ state,
2387
+ actions,
2388
+ settings,
2389
+ saveSettings: setSettings
2390
+ }) : /* @__PURE__ */ (0, import_react.jsx)("p", null, "Unable to find Uniform Context. Ensure the devtools plugin is activated.");
2391
+ }
2392
+
2393
+ // src/components/ToggleEmbeddedContextDevTools.tsx
2394
+ var import_react23 = require("@emotion/react");
2395
+ var React8 = __toESM(require("react"));
2396
+
2397
+ // src/components/Buttons/EmbedToggleButton.tsx
2398
+ var import_react22 = require("@emotion/react");
2399
+ var btnStyle3 = import_react22.css`
743
2400
  align-items: center;
744
2401
  border-radius: var(--rounded-full);
745
2402
  background: var(--brand-secondary-5);
@@ -765,4 +2422,56 @@ summary {
765
2422
  max-width: 100%;
766
2423
  height: auto;
767
2424
  }
768
- `,Et=({...e})=>(0,t.jsx)("button",{type:"button",css:re,...e},(0,t.jsx)("span",{hidden:!0},"Uniform devtools"),(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,t.jsx)("path",{d:"M13.325 3.05011L8.66741 20.4323L10.5993 20.9499L15.2568 3.56775L13.325 3.05011Z",fill:"currentColor"}),(0,t.jsx)("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"}),(0,t.jsx)("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"})));function ne(e){var a;let[r,n]=Bt.useState(!1);return((a=e.context)!=null?a:typeof window!="undefined"?window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__:void 0)?(0,t.jsx)("div",null,(0,t.jsx)(j,null),(0,t.jsx)(Et,{onClick:()=>n(i=>!i)}),r?(0,t.jsx)(st,{...e}):null):(0,t.jsx)("p",null,"Unable to find Uniform Context. Ensure the devtools plugin is activated.")}module.exports=Gt(ae);0&&(module.exports={ContextDevTools,EmbeddedContextDevTools,ToggleEmbeddedContextDevTools});
2425
+ `;
2426
+ var EmbedToggleButton = ({ ...props }) => {
2427
+ return /* @__PURE__ */ (0, import_react.jsx)("button", {
2428
+ type: "button",
2429
+ css: btnStyle3,
2430
+ ...props
2431
+ }, /* @__PURE__ */ (0, import_react.jsx)("span", {
2432
+ hidden: true
2433
+ }, "Uniform devtools"), /* @__PURE__ */ (0, import_react.jsx)("svg", {
2434
+ width: "24",
2435
+ height: "24",
2436
+ viewBox: "0 0 24 24",
2437
+ fill: "none",
2438
+ xmlns: "http://www.w3.org/2000/svg"
2439
+ }, /* @__PURE__ */ (0, import_react.jsx)("path", {
2440
+ d: "M13.325 3.05011L8.66741 20.4323L10.5993 20.9499L15.2568 3.56775L13.325 3.05011Z",
2441
+ fill: "currentColor"
2442
+ }), /* @__PURE__ */ (0, import_react.jsx)("path", {
2443
+ 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",
2444
+ fill: "currentColor"
2445
+ }), /* @__PURE__ */ (0, import_react.jsx)("path", {
2446
+ 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",
2447
+ fill: "currentColor"
2448
+ })));
2449
+ };
2450
+
2451
+ // src/components/ToggleEmbeddedContextDevTools.tsx
2452
+ function ToggleEmbeddedContextDevTools(props) {
2453
+ var _a;
2454
+ const [devtoolsOpen, setDevtoolsOpen] = React8.useState(false);
2455
+ const contextValue = (_a = props.context) != null ? _a : typeof window !== "undefined" ? window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__ : void 0;
2456
+ return contextValue ? /* @__PURE__ */ (0, import_react.jsx)("div", null, /* @__PURE__ */ (0, import_react.jsx)(Theme, null), /* @__PURE__ */ (0, import_react.jsx)(EmbedToggleButton, {
2457
+ onClick: () => setDevtoolsOpen((prev) => !prev)
2458
+ }), devtoolsOpen ? /* @__PURE__ */ (0, import_react.jsx)("div", {
2459
+ css: import_react23.css`
2460
+ box-shadow: var(--shadow-base);
2461
+ position: fixed;
2462
+ bottom: 82px;
2463
+ right: var(--spacing-base);
2464
+ z-index: var(--z-10);
2465
+ max-width: var(--site-width);
2466
+ `
2467
+ }, /* @__PURE__ */ (0, import_react.jsx)(EmbeddedContextDevTools, {
2468
+ ...props
2469
+ })) : null) : /* @__PURE__ */ (0, import_react.jsx)("p", null, "Unable to find Uniform Context. Ensure the devtools plugin is activated.");
2470
+ }
2471
+ module.exports = __toCommonJS(src_exports);
2472
+ // Annotate the CommonJS export names for ESM import in node:
2473
+ 0 && (module.exports = {
2474
+ ContextDevTools,
2475
+ EmbeddedContextDevTools,
2476
+ ToggleEmbeddedContextDevTools
2477
+ });