@guardian/interactive-component-library 0.1.0-alpha.10

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.
@@ -0,0 +1,2977 @@
1
+ (function(global2, factory) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("preact/jsx-runtime"), require("preact/hooks"), require("preact/compat"), require("preact"), require("d3-scale"), require("d3-geo")) : typeof define === "function" && define.amd ? define(["exports", "preact/jsx-runtime", "preact/hooks", "preact/compat", "preact", "d3-scale", "d3-geo"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["interactive-component-library"] = {}, global2["preact/jsx-runtime"], global2["preact/hooks"], global2["preact/compat"], global2.preact, global2["d3-scale"], global2["d3-geo"]));
3
+ })(this, function(exports2, jsxRuntime, hooks, compat, preact, d3Scale, d3Geo) {
4
+ "use strict";
5
+ const main = "";
6
+ const group = "_group_nq9z3_1";
7
+ const rotated = "_rotated_nq9z3_6";
8
+ const path$4 = "_path_nq9z3_10";
9
+ const active = "_active_nq9z3_14";
10
+ const defaultStyles$q = {
11
+ group,
12
+ rotated,
13
+ path: path$4,
14
+ active
15
+ };
16
+ function mergeStyles(firstStyle, secondStyle) {
17
+ if (!secondStyle)
18
+ return firstStyle;
19
+ if (typeof firstStyle === "string") {
20
+ if (typeof secondStyle !== "string") {
21
+ throw new Error("Styles to merge must be of the same type");
22
+ }
23
+ return firstStyle.concat(" ", secondStyle);
24
+ }
25
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(firstStyle), ...Object.keys(secondStyle)]);
26
+ const merged = Array.from(allKeys).reduce((result, key) => {
27
+ const classNames = [];
28
+ if (firstStyle && key in firstStyle) {
29
+ classNames.push(firstStyle[key]);
30
+ }
31
+ if (secondStyle && key in secondStyle) {
32
+ classNames.push(secondStyle[key]);
33
+ }
34
+ result[key] = classNames.join(" ");
35
+ return result;
36
+ }, {});
37
+ return merged;
38
+ }
39
+ const DIRECTION = {
40
+ up: "up",
41
+ down: "down"
42
+ };
43
+ function Chevron({
44
+ active: active2 = false,
45
+ direction = DIRECTION.down,
46
+ styles: styles2
47
+ }) {
48
+ const defaultStylesCopy = {
49
+ ...defaultStyles$q
50
+ };
51
+ if (active2) {
52
+ defaultStylesCopy.path = mergeStyles(defaultStyles$q.path, defaultStyles$q.active);
53
+ }
54
+ if (direction === DIRECTION.up) {
55
+ defaultStylesCopy.group = mergeStyles(defaultStyles$q.group, defaultStyles$q.rotated);
56
+ }
57
+ styles2 = mergeStyles(defaultStylesCopy, styles2);
58
+ return jsxRuntime.jsx("svg", {
59
+ width: "16",
60
+ height: "24",
61
+ viewBox: "0 0 16 24",
62
+ fill: "none",
63
+ xmlns: "http://www.w3.org/2000/svg",
64
+ children: jsxRuntime.jsx("g", {
65
+ className: styles2.group,
66
+ style: "transform-box: fill-box;",
67
+ children: jsxRuntime.jsx("path", {
68
+ "fill-rule": "evenodd",
69
+ "clip-rule": "evenodd",
70
+ d: "M7.80569 10.7123L11.6344 15H12.365L16.1938 10.7123L15.4997 10L11.9997 13L8.49976 10L7.80569 10.7123Z",
71
+ className: styles2.path
72
+ })
73
+ })
74
+ });
75
+ }
76
+ const container$4 = "_container_jzalm_1";
77
+ const dot = "_dot_jzalm_6";
78
+ const circle$1 = "_circle_jzalm_13";
79
+ const text$4 = "_text_jzalm_17";
80
+ const defaultStyles$p = {
81
+ container: container$4,
82
+ dot,
83
+ circle: circle$1,
84
+ text: text$4
85
+ };
86
+ const DOT_TYPE = {
87
+ round: "round",
88
+ square: "square"
89
+ };
90
+ const LegendItem = ({
91
+ dotType = DOT_TYPE.round,
92
+ text: text2,
93
+ styles: styles2,
94
+ abbreviation
95
+ }) => {
96
+ const defaultStylesCopy = {
97
+ ...defaultStyles$p
98
+ };
99
+ if (dotType === DOT_TYPE.round) {
100
+ defaultStylesCopy.dot = mergeStyles(defaultStyles$p.dot, defaultStyles$p.circle);
101
+ }
102
+ styles2 = mergeStyles(defaultStylesCopy, styles2);
103
+ return jsxRuntime.jsxs("div", {
104
+ className: styles2.container,
105
+ children: [jsxRuntime.jsx("span", {
106
+ className: `${styles2.dot} bg-color--${abbreviation}`
107
+ }), jsxRuntime.jsx("p", {
108
+ className: styles2.text,
109
+ children: text2
110
+ })]
111
+ });
112
+ };
113
+ function isDarkColor(color) {
114
+ let r, g, b;
115
+ if (color.match(/^rgb/)) {
116
+ color = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);
117
+ r = color[1];
118
+ g = color[2];
119
+ b = color[3];
120
+ } else {
121
+ color = +`0x${color.slice(1).replace(color.length < 5 && /./g, "$&$&")}`;
122
+ r = color >> 16;
123
+ g = color >> 8 & 255;
124
+ b = color & 255;
125
+ }
126
+ const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b));
127
+ if (hsp > 140) {
128
+ return false;
129
+ }
130
+ return true;
131
+ }
132
+ const bar$2 = "_bar_wmb0k_1";
133
+ const label$1 = "_label_wmb0k_5";
134
+ const backgroundRect = "_backgroundRect_wmb0k_11";
135
+ const defaultStyles$o = {
136
+ bar: bar$2,
137
+ label: label$1,
138
+ backgroundRect
139
+ };
140
+ function StackedBar({
141
+ stack,
142
+ width,
143
+ height,
144
+ showBackgroundRect = false,
145
+ createSVG = true,
146
+ styles: styles2
147
+ }) {
148
+ const rectElements = hooks.useRef([]);
149
+ const textElements = hooks.useRef([]);
150
+ const [hideLabels, setHideLabels] = hooks.useState(true);
151
+ hooks.useLayoutEffect(() => {
152
+ for (let index2 = 0; index2 < stack.length; index2++) {
153
+ const rectElement = rectElements.current[index2];
154
+ const textElement = textElements.current[index2];
155
+ const paddingX = 8;
156
+ const hideText = textElement.getBBox().width + paddingX > rectElement.getBBox().width;
157
+ const rectStyle = window.getComputedStyle(rectElement);
158
+ const rectColor = rectStyle.getPropertyValue("fill");
159
+ const textColor = isDarkColor(rectColor) ? "#FFF" : "#121212";
160
+ textElement.style.fill = textColor;
161
+ if (hideText) {
162
+ setHideLabels(true);
163
+ return;
164
+ }
165
+ }
166
+ setHideLabels(false);
167
+ }, [stack, width, height]);
168
+ styles2 = mergeStyles({
169
+ ...defaultStyles$o
170
+ }, styles2);
171
+ let totalWidth = 0;
172
+ const content2 = stack.map((d2, index2) => {
173
+ const itemWidth = d2.fraction * width;
174
+ const value = jsxRuntime.jsxs("g", {
175
+ transform: `translate(${totalWidth}, 0)`,
176
+ children: [jsxRuntime.jsx("rect", {
177
+ ref: (element) => rectElements.current[index2] = element,
178
+ width: itemWidth,
179
+ height,
180
+ className: `${styles2.bar} fill-color--${d2.abbreviation}`,
181
+ style: {
182
+ fill: d2.fill
183
+ },
184
+ "shape-rendering": "crispEdges"
185
+ }), jsxRuntime.jsx("text", {
186
+ ref: (element) => textElements.current[index2] = element,
187
+ x: itemWidth - 4,
188
+ y: height / 2,
189
+ "text-anchor": "end",
190
+ "alignment-baseline": "central",
191
+ "text-rendering": "optimizeLegibility",
192
+ className: styles2.label,
193
+ style: {
194
+ visibility: hideLabels ? "hidden" : "visible"
195
+ },
196
+ children: d2.label
197
+ })]
198
+ }, index2);
199
+ totalWidth += itemWidth;
200
+ return value;
201
+ });
202
+ const backgroundRect2 = jsxRuntime.jsx("g", {
203
+ children: jsxRuntime.jsx("rect", {
204
+ x: "0",
205
+ y: "0",
206
+ height,
207
+ width,
208
+ className: styles2.backgroundRect
209
+ })
210
+ });
211
+ if (createSVG) {
212
+ return jsxRuntime.jsxs("svg", {
213
+ overflow: "hidden",
214
+ width,
215
+ height,
216
+ viewBox: `0 0 ${width} ${height}`,
217
+ xmlns: "http://www.w3.org/2000/svg",
218
+ children: [showBackgroundRect && backgroundRect2, content2]
219
+ });
220
+ }
221
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
222
+ children: content2
223
+ });
224
+ }
225
+ const svg$7 = "_svg_un4gp_1";
226
+ const previous = "_previous_un4gp_7";
227
+ const next = "_next_un4gp_11";
228
+ const defaultStyles$n = {
229
+ svg: svg$7,
230
+ previous,
231
+ next
232
+ };
233
+ const GradientIcon = ({
234
+ previous: previous2,
235
+ next: next2,
236
+ styles: styles2
237
+ }) => {
238
+ styles2 = mergeStyles({
239
+ ...defaultStyles$n
240
+ }, styles2);
241
+ const gradientId = hooks.useId();
242
+ return jsxRuntime.jsxs("svg", {
243
+ class: styles2.svg,
244
+ width: "24",
245
+ height: "11",
246
+ viewBox: "0 0 24 11",
247
+ xmlns: "http://www.w3.org/2000/svg",
248
+ children: [jsxRuntime.jsx("path", {
249
+ d: "M0 5.434C0 2.43288 2.43288 0 5.434 0H5.69626C6.85818 0 7.9797 0.426401 8.84813 1.19834C10.6456 2.79612 13.3544 2.79612 15.1519 1.19834C16.0203 0.426401 17.1418 0 18.3037 0L18.566 0C21.5671 0 24 2.43288 24 5.434V5.566C24 8.56712 21.5671 11 18.566 11H18.3037C17.1418 11 16.0203 10.5736 15.1519 9.80166C13.3544 8.20388 10.6456 8.20388 8.84813 9.80166C7.9797 10.5736 6.85818 11 5.69626 11H5.434C2.43288 11 0 8.56712 0 5.566V5.434Z",
250
+ fill: `url(#${gradientId})`
251
+ }), jsxRuntime.jsx("defs", {
252
+ children: jsxRuntime.jsxs("linearGradient", {
253
+ id: gradientId,
254
+ x1: "5.5",
255
+ y1: "5.5",
256
+ x2: "12",
257
+ y2: "5.5",
258
+ gradientUnits: "userSpaceOnUse",
259
+ children: [jsxRuntime.jsx("stop", {
260
+ class: `${styles2.previous} stop-color--${previous2}`
261
+ }), jsxRuntime.jsx("stop", {
262
+ class: `${styles2.next} stop-color--${next2}`,
263
+ offset: "1"
264
+ })]
265
+ })
266
+ })]
267
+ });
268
+ };
269
+ const button$4 = "_button_kpmyt_1";
270
+ const svg$6 = "_svg_kpmyt_14";
271
+ const defaultStyles$m = {
272
+ button: button$4,
273
+ svg: svg$6
274
+ };
275
+ const InfoButton = ({
276
+ onClick,
277
+ styles: styles2
278
+ }) => {
279
+ styles2 = mergeStyles({
280
+ ...defaultStyles$m
281
+ }, styles2);
282
+ return jsxRuntime.jsx("button", {
283
+ class: styles2.button,
284
+ onClick,
285
+ children: jsxRuntime.jsx("svg", {
286
+ class: styles2.svg,
287
+ viewBox: "0 0 5 13",
288
+ xmlns: "http://www.w3.org/2000/svg",
289
+ children: jsxRuntime.jsx("path", {
290
+ d: "m3.72905 10.8229v.5256c-.11944.0955-.28666.1672-.45388.2628-.16723.0716-.35834.1433-.54945.215-.19111.0716-.38222.1194-.57333.1433s-.38222.0478-.54945.0478c-.38222 0-.621109-.0717-.764442-.215-.167222-.1434-.238889-.3106-.238889-.4778 0-.1911.023889-.3822.047778-.5733s.071667-.3823.119445-.6211l1.003328-4.56282-.931662-.215v-.50167c.143333-.04777.334442-.11944.597222-.19111.23889-.07166.50167-.11944.78833-.16722.28667-.04778.54945-.09556.81223-.11944.26277-.02389.50166-.04778.71666-.04778l.26278.16722-1.33778 6.33052zm.45389-8.02663c-.215.19111-.52555.28667-.88389.28667-.33444 0-.62111-.09556-.86-.28667-.215-.19111-.33444-.43-.33444-.74056 0-.33444.11944-.59722.33444-.78833s.50167-.286667.86-.286667c.38223 0 .66889.095557.88389.286667s.33445.45389.33445.78833c-.02389.31056-.11945.54945-.33445.74056z"
291
+ })
292
+ })
293
+ });
294
+ };
295
+ const circleicon = "_circleicon_1ge2m_1";
296
+ const rect = "_rect_1ge2m_7";
297
+ const defaultStyles$l = {
298
+ circleicon,
299
+ rect
300
+ };
301
+ const CircleIcon = ({
302
+ abbreviation,
303
+ styles: styles2
304
+ }) => {
305
+ styles2 = mergeStyles({
306
+ ...defaultStyles$l
307
+ }, styles2);
308
+ return jsxRuntime.jsx("svg", {
309
+ style: styles2.circleicon,
310
+ fill: "none",
311
+ height: "11",
312
+ viewBox: "0 0 11 11",
313
+ width: "11",
314
+ xmlns: "http://www.w3.org/2000/svg",
315
+ children: jsxRuntime.jsx("rect", {
316
+ class: `${styles2.rect} fill-color--${abbreviation}`,
317
+ height: "11",
318
+ rx: "5.5",
319
+ width: "11"
320
+ })
321
+ });
322
+ };
323
+ const text$3 = "_text_1okyv_1";
324
+ const defaultStyles$k = {
325
+ text: text$3
326
+ };
327
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
328
+ function getDefaultExportFromCjs(x) {
329
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
330
+ }
331
+ var dayjs_min = { exports: {} };
332
+ (function(module2, exports3) {
333
+ !function(t, e) {
334
+ module2.exports = e();
335
+ }(commonjsGlobal, function() {
336
+ var t = 1e3, e = 6e4, n2 = 36e5, r = "millisecond", i = "second", s2 = "minute", u2 = "hour", a = "day", o = "week", c2 = "month", f = "quarter", h = "year", d2 = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
337
+ var e2 = ["th", "st", "nd", "rd"], n3 = t2 % 100;
338
+ return "[" + t2 + (e2[(n3 - 20) % 10] || e2[n3] || e2[0]) + "]";
339
+ } }, m = function(t2, e2, n3) {
340
+ var r2 = String(t2);
341
+ return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n3) + t2;
342
+ }, v = { s: m, z: function(t2) {
343
+ var e2 = -t2.utcOffset(), n3 = Math.abs(e2), r2 = Math.floor(n3 / 60), i2 = n3 % 60;
344
+ return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
345
+ }, m: function t2(e2, n3) {
346
+ if (e2.date() < n3.date())
347
+ return -t2(n3, e2);
348
+ var r2 = 12 * (n3.year() - e2.year()) + (n3.month() - e2.month()), i2 = e2.clone().add(r2, c2), s3 = n3 - i2 < 0, u3 = e2.clone().add(r2 + (s3 ? -1 : 1), c2);
349
+ return +(-(r2 + (n3 - i2) / (s3 ? i2 - u3 : u3 - i2)) || 0);
350
+ }, a: function(t2) {
351
+ return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
352
+ }, p: function(t2) {
353
+ return { M: c2, y: h, w: o, d: a, D: d2, h: u2, m: s2, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
354
+ }, u: function(t2) {
355
+ return void 0 === t2;
356
+ } }, g = "en", D = {};
357
+ D[g] = M;
358
+ var p2 = "$isDayjsObject", S = function(t2) {
359
+ return t2 instanceof _2 || !(!t2 || !t2[p2]);
360
+ }, w = function t2(e2, n3, r2) {
361
+ var i2;
362
+ if (!e2)
363
+ return g;
364
+ if ("string" == typeof e2) {
365
+ var s3 = e2.toLowerCase();
366
+ D[s3] && (i2 = s3), n3 && (D[s3] = n3, i2 = s3);
367
+ var u3 = e2.split("-");
368
+ if (!i2 && u3.length > 1)
369
+ return t2(u3[0]);
370
+ } else {
371
+ var a2 = e2.name;
372
+ D[a2] = e2, i2 = a2;
373
+ }
374
+ return !r2 && i2 && (g = i2), i2 || !r2 && g;
375
+ }, O = function(t2, e2) {
376
+ if (S(t2))
377
+ return t2.clone();
378
+ var n3 = "object" == typeof e2 ? e2 : {};
379
+ return n3.date = t2, n3.args = arguments, new _2(n3);
380
+ }, b = v;
381
+ b.l = w, b.i = S, b.w = function(t2, e2) {
382
+ return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
383
+ };
384
+ var _2 = function() {
385
+ function M2(t2) {
386
+ this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p2] = true;
387
+ }
388
+ var m2 = M2.prototype;
389
+ return m2.parse = function(t2) {
390
+ this.$d = function(t3) {
391
+ var e2 = t3.date, n3 = t3.utc;
392
+ if (null === e2)
393
+ return /* @__PURE__ */ new Date(NaN);
394
+ if (b.u(e2))
395
+ return /* @__PURE__ */ new Date();
396
+ if (e2 instanceof Date)
397
+ return new Date(e2);
398
+ if ("string" == typeof e2 && !/Z$/i.test(e2)) {
399
+ var r2 = e2.match($);
400
+ if (r2) {
401
+ var i2 = r2[2] - 1 || 0, s3 = (r2[7] || "0").substring(0, 3);
402
+ return n3 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s3)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s3);
403
+ }
404
+ }
405
+ return new Date(e2);
406
+ }(t2), this.init();
407
+ }, m2.init = function() {
408
+ var t2 = this.$d;
409
+ this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
410
+ }, m2.$utils = function() {
411
+ return b;
412
+ }, m2.isValid = function() {
413
+ return !(this.$d.toString() === l);
414
+ }, m2.isSame = function(t2, e2) {
415
+ var n3 = O(t2);
416
+ return this.startOf(e2) <= n3 && n3 <= this.endOf(e2);
417
+ }, m2.isAfter = function(t2, e2) {
418
+ return O(t2) < this.startOf(e2);
419
+ }, m2.isBefore = function(t2, e2) {
420
+ return this.endOf(e2) < O(t2);
421
+ }, m2.$g = function(t2, e2, n3) {
422
+ return b.u(t2) ? this[e2] : this.set(n3, t2);
423
+ }, m2.unix = function() {
424
+ return Math.floor(this.valueOf() / 1e3);
425
+ }, m2.valueOf = function() {
426
+ return this.$d.getTime();
427
+ }, m2.startOf = function(t2, e2) {
428
+ var n3 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
429
+ var i2 = b.w(n3.$u ? Date.UTC(n3.$y, e3, t3) : new Date(n3.$y, e3, t3), n3);
430
+ return r2 ? i2 : i2.endOf(a);
431
+ }, $2 = function(t3, e3) {
432
+ return b.w(n3.toDate()[t3].apply(n3.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n3);
433
+ }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
434
+ switch (f2) {
435
+ case h:
436
+ return r2 ? l2(1, 0) : l2(31, 11);
437
+ case c2:
438
+ return r2 ? l2(1, M3) : l2(0, M3 + 1);
439
+ case o:
440
+ var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
441
+ return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
442
+ case a:
443
+ case d2:
444
+ return $2(v2 + "Hours", 0);
445
+ case u2:
446
+ return $2(v2 + "Minutes", 1);
447
+ case s2:
448
+ return $2(v2 + "Seconds", 2);
449
+ case i:
450
+ return $2(v2 + "Milliseconds", 3);
451
+ default:
452
+ return this.clone();
453
+ }
454
+ }, m2.endOf = function(t2) {
455
+ return this.startOf(t2, false);
456
+ }, m2.$set = function(t2, e2) {
457
+ var n3, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n3 = {}, n3[a] = f2 + "Date", n3[d2] = f2 + "Date", n3[c2] = f2 + "Month", n3[h] = f2 + "FullYear", n3[u2] = f2 + "Hours", n3[s2] = f2 + "Minutes", n3[i] = f2 + "Seconds", n3[r] = f2 + "Milliseconds", n3)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
458
+ if (o2 === c2 || o2 === h) {
459
+ var y2 = this.clone().set(d2, 1);
460
+ y2.$d[l2]($2), y2.init(), this.$d = y2.set(d2, Math.min(this.$D, y2.daysInMonth())).$d;
461
+ } else
462
+ l2 && this.$d[l2]($2);
463
+ return this.init(), this;
464
+ }, m2.set = function(t2, e2) {
465
+ return this.clone().$set(t2, e2);
466
+ }, m2.get = function(t2) {
467
+ return this[b.p(t2)]();
468
+ }, m2.add = function(r2, f2) {
469
+ var d3, l2 = this;
470
+ r2 = Number(r2);
471
+ var $2 = b.p(f2), y2 = function(t2) {
472
+ var e2 = O(l2);
473
+ return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
474
+ };
475
+ if ($2 === c2)
476
+ return this.set(c2, this.$M + r2);
477
+ if ($2 === h)
478
+ return this.set(h, this.$y + r2);
479
+ if ($2 === a)
480
+ return y2(1);
481
+ if ($2 === o)
482
+ return y2(7);
483
+ var M3 = (d3 = {}, d3[s2] = e, d3[u2] = n2, d3[i] = t, d3)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
484
+ return b.w(m3, this);
485
+ }, m2.subtract = function(t2, e2) {
486
+ return this.add(-1 * t2, e2);
487
+ }, m2.format = function(t2) {
488
+ var e2 = this, n3 = this.$locale();
489
+ if (!this.isValid())
490
+ return n3.invalidDate || l;
491
+ var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s3 = this.$H, u3 = this.$m, a2 = this.$M, o2 = n3.weekdays, c3 = n3.months, f2 = n3.meridiem, h2 = function(t3, n4, i3, s4) {
492
+ return t3 && (t3[n4] || t3(e2, r2)) || i3[n4].slice(0, s4);
493
+ }, d3 = function(t3) {
494
+ return b.s(s3 % 12 || 12, t3, "0");
495
+ }, $2 = f2 || function(t3, e3, n4) {
496
+ var r3 = t3 < 12 ? "AM" : "PM";
497
+ return n4 ? r3.toLowerCase() : r3;
498
+ };
499
+ return r2.replace(y, function(t3, r3) {
500
+ return r3 || function(t4) {
501
+ switch (t4) {
502
+ case "YY":
503
+ return String(e2.$y).slice(-2);
504
+ case "YYYY":
505
+ return b.s(e2.$y, 4, "0");
506
+ case "M":
507
+ return a2 + 1;
508
+ case "MM":
509
+ return b.s(a2 + 1, 2, "0");
510
+ case "MMM":
511
+ return h2(n3.monthsShort, a2, c3, 3);
512
+ case "MMMM":
513
+ return h2(c3, a2);
514
+ case "D":
515
+ return e2.$D;
516
+ case "DD":
517
+ return b.s(e2.$D, 2, "0");
518
+ case "d":
519
+ return String(e2.$W);
520
+ case "dd":
521
+ return h2(n3.weekdaysMin, e2.$W, o2, 2);
522
+ case "ddd":
523
+ return h2(n3.weekdaysShort, e2.$W, o2, 3);
524
+ case "dddd":
525
+ return o2[e2.$W];
526
+ case "H":
527
+ return String(s3);
528
+ case "HH":
529
+ return b.s(s3, 2, "0");
530
+ case "h":
531
+ return d3(1);
532
+ case "hh":
533
+ return d3(2);
534
+ case "a":
535
+ return $2(s3, u3, true);
536
+ case "A":
537
+ return $2(s3, u3, false);
538
+ case "m":
539
+ return String(u3);
540
+ case "mm":
541
+ return b.s(u3, 2, "0");
542
+ case "s":
543
+ return String(e2.$s);
544
+ case "ss":
545
+ return b.s(e2.$s, 2, "0");
546
+ case "SSS":
547
+ return b.s(e2.$ms, 3, "0");
548
+ case "Z":
549
+ return i2;
550
+ }
551
+ return null;
552
+ }(t3) || i2.replace(":", "");
553
+ });
554
+ }, m2.utcOffset = function() {
555
+ return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
556
+ }, m2.diff = function(r2, d3, l2) {
557
+ var $2, y2 = this, M3 = b.p(d3), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
558
+ return b.m(y2, m3);
559
+ };
560
+ switch (M3) {
561
+ case h:
562
+ $2 = D2() / 12;
563
+ break;
564
+ case c2:
565
+ $2 = D2();
566
+ break;
567
+ case f:
568
+ $2 = D2() / 3;
569
+ break;
570
+ case o:
571
+ $2 = (g2 - v2) / 6048e5;
572
+ break;
573
+ case a:
574
+ $2 = (g2 - v2) / 864e5;
575
+ break;
576
+ case u2:
577
+ $2 = g2 / n2;
578
+ break;
579
+ case s2:
580
+ $2 = g2 / e;
581
+ break;
582
+ case i:
583
+ $2 = g2 / t;
584
+ break;
585
+ default:
586
+ $2 = g2;
587
+ }
588
+ return l2 ? $2 : b.a($2);
589
+ }, m2.daysInMonth = function() {
590
+ return this.endOf(c2).$D;
591
+ }, m2.$locale = function() {
592
+ return D[this.$L];
593
+ }, m2.locale = function(t2, e2) {
594
+ if (!t2)
595
+ return this.$L;
596
+ var n3 = this.clone(), r2 = w(t2, e2, true);
597
+ return r2 && (n3.$L = r2), n3;
598
+ }, m2.clone = function() {
599
+ return b.w(this.$d, this);
600
+ }, m2.toDate = function() {
601
+ return new Date(this.valueOf());
602
+ }, m2.toJSON = function() {
603
+ return this.isValid() ? this.toISOString() : null;
604
+ }, m2.toISOString = function() {
605
+ return this.$d.toISOString();
606
+ }, m2.toString = function() {
607
+ return this.$d.toUTCString();
608
+ }, M2;
609
+ }(), k = _2.prototype;
610
+ return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s2], ["$H", u2], ["$W", a], ["$M", c2], ["$y", h], ["$D", d2]].forEach(function(t2) {
611
+ k[t2[1]] = function(e2) {
612
+ return this.$g(e2, t2[0], t2[1]);
613
+ };
614
+ }), O.extend = function(t2, e2) {
615
+ return t2.$i || (t2(e2, _2, O), t2.$i = true), O;
616
+ }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
617
+ return O(1e3 * t2);
618
+ }, O.en = D[g], O.Ls = D, O.p = {}, O;
619
+ });
620
+ })(dayjs_min);
621
+ var dayjs_minExports = dayjs_min.exports;
622
+ const dayjs = /* @__PURE__ */ getDefaultExportFromCjs(dayjs_minExports);
623
+ var relativeTime$1 = { exports: {} };
624
+ (function(module2, exports3) {
625
+ !function(r, e) {
626
+ module2.exports = e();
627
+ }(commonjsGlobal, function() {
628
+ return function(r, e, t) {
629
+ r = r || {};
630
+ var n2 = e.prototype, o = { future: "in %s", past: "%s ago", s: "a few seconds", m: "a minute", mm: "%d minutes", h: "an hour", hh: "%d hours", d: "a day", dd: "%d days", M: "a month", MM: "%d months", y: "a year", yy: "%d years" };
631
+ function i(r2, e2, t2, o2) {
632
+ return n2.fromToBase(r2, e2, t2, o2);
633
+ }
634
+ t.en.relativeTime = o, n2.fromToBase = function(e2, n3, i2, d3, u2) {
635
+ for (var f, a, s2, l = i2.$locale().relativeTime || o, h = r.thresholds || [{ l: "s", r: 44, d: "second" }, { l: "m", r: 89 }, { l: "mm", r: 44, d: "minute" }, { l: "h", r: 89 }, { l: "hh", r: 21, d: "hour" }, { l: "d", r: 35 }, { l: "dd", r: 25, d: "day" }, { l: "M", r: 45 }, { l: "MM", r: 10, d: "month" }, { l: "y", r: 17 }, { l: "yy", d: "year" }], m = h.length, c2 = 0; c2 < m; c2 += 1) {
636
+ var y = h[c2];
637
+ y.d && (f = d3 ? t(e2).diff(i2, y.d, true) : i2.diff(e2, y.d, true));
638
+ var p2 = (r.rounding || Math.round)(Math.abs(f));
639
+ if (s2 = f > 0, p2 <= y.r || !y.r) {
640
+ p2 <= 1 && c2 > 0 && (y = h[c2 - 1]);
641
+ var v = l[y.l];
642
+ u2 && (p2 = u2("" + p2)), a = "string" == typeof v ? v.replace("%d", p2) : v(p2, n3, y.l, s2);
643
+ break;
644
+ }
645
+ }
646
+ if (n3)
647
+ return a;
648
+ var M = s2 ? l.future : l.past;
649
+ return "function" == typeof M ? M(a) : M.replace("%s", a);
650
+ }, n2.to = function(r2, e2) {
651
+ return i(r2, e2, this, true);
652
+ }, n2.from = function(r2, e2) {
653
+ return i(r2, e2, this);
654
+ };
655
+ var d2 = function(r2) {
656
+ return r2.$u ? t.utc() : t();
657
+ };
658
+ n2.toNow = function(r2) {
659
+ return this.to(d2(this), r2);
660
+ }, n2.fromNow = function(r2) {
661
+ return this.from(d2(this), r2);
662
+ };
663
+ };
664
+ });
665
+ })(relativeTime$1);
666
+ var relativeTimeExports = relativeTime$1.exports;
667
+ const relativeTime = /* @__PURE__ */ getDefaultExportFromCjs(relativeTimeExports);
668
+ dayjs.extend(relativeTime);
669
+ const RelativeTimeSentence = ({
670
+ timeStamp,
671
+ styles: styles2
672
+ }) => {
673
+ styles2 = mergeStyles({
674
+ ...defaultStyles$k
675
+ }, styles2);
676
+ let timeSince = dayjs(timeStamp).fromNow();
677
+ return jsxRuntime.jsx("span", {
678
+ className: styles2.text,
679
+ children: timeSince
680
+ });
681
+ };
682
+ const pageContainer = "_pageContainer_1s0yq_9";
683
+ const sideBorders = "_sideBorders_1s0yq_42";
684
+ const defaultStyles$j = {
685
+ pageContainer,
686
+ sideBorders
687
+ };
688
+ function Container({
689
+ children,
690
+ sideBorders: sideBorders2 = false,
691
+ styles: styles2
692
+ }) {
693
+ const {
694
+ pageContainer: pageContainer2,
695
+ sideBorders: sideBordersStyle
696
+ } = mergeStyles(defaultStyles$j, styles2);
697
+ return jsxRuntime.jsx("div", {
698
+ className: [pageContainer2, sideBorders2 && sideBordersStyle].join(" "),
699
+ children
700
+ });
701
+ }
702
+ const bar$1 = "_bar_17pyf_9";
703
+ const defaultStyles$i = {
704
+ bar: bar$1
705
+ };
706
+ function ChangeBar({
707
+ fraction,
708
+ positive,
709
+ party,
710
+ width,
711
+ height,
712
+ styles: styles2
713
+ }) {
714
+ let centre = parseFloat(width) / 2;
715
+ let barwidth = parseFloat(fraction) * (parseFloat(width) / 2);
716
+ let negleft = `${centre - barwidth}px`;
717
+ let posleft = `${centre}px`;
718
+ let thisStyles = ` height: ${height}; width: ${barwidth}px; ${positive ? `left: ${posleft}` : `left: ${negleft}`}`;
719
+ let thisColor = ` bg-color--${party}`;
720
+ styles2 = mergeStyles({
721
+ ...defaultStyles$i
722
+ }, styles2);
723
+ return jsxRuntime.jsx("div", {
724
+ className: styles2.wrapper,
725
+ style: `width: ${width}px`,
726
+ children: jsxRuntime.jsx("div", {
727
+ className: styles2.bar.concat(thisColor),
728
+ style: thisStyles
729
+ })
730
+ });
731
+ }
732
+ const svg$5 = "_svg_886i1_9";
733
+ const dividingLineColor = "_dividingLineColor_886i1_16";
734
+ const square = "_square_886i1_20";
735
+ const corner = "_corner_886i1_24";
736
+ const defaultStyles$h = {
737
+ svg: svg$5,
738
+ dividingLineColor,
739
+ square,
740
+ corner
741
+ };
742
+ const SquareCutCornerIcon = ({
743
+ cornerColor,
744
+ squareColor,
745
+ squareSize,
746
+ styles: styles2
747
+ }) => {
748
+ styles2 = mergeStyles({
749
+ ...defaultStyles$h
750
+ }, styles2);
751
+ let cornerSize = squareSize * 0.625;
752
+ let cornerMargin = squareSize < 100 ? squareSize / 6 : 10;
753
+ return jsxRuntime.jsx("svg", {
754
+ width: squareSize,
755
+ height: squareSize,
756
+ className: styles2.svg,
757
+ viewBox: `0 0 ${squareSize} ${squareSize}`,
758
+ children: jsxRuntime.jsxs("g", {
759
+ id: "square-cutoff-corner-icon",
760
+ children: [jsxRuntime.jsx("rect", {
761
+ id: "square",
762
+ fill: squareColor,
763
+ className: styles2.square,
764
+ width: squareSize,
765
+ height: squareSize
766
+ }), jsxRuntime.jsxs("g", {
767
+ id: "corner",
768
+ children: [jsxRuntime.jsx("polygon", {
769
+ id: "cornerTriangleBg",
770
+ className: styles2.dividingLineColor,
771
+ points: `0,0 0,${cornerSize} ${cornerSize},0`
772
+ }), jsxRuntime.jsx("polygon", {
773
+ id: "cornerTriangle",
774
+ fill: cornerColor,
775
+ className: styles2.corner,
776
+ points: `0,0 0,${cornerSize - cornerMargin} ${cornerSize - cornerMargin},0`
777
+ })]
778
+ })]
779
+ })
780
+ });
781
+ };
782
+ const stackedGridContainer = "_stackedGridContainer_1e05o_1";
783
+ const stackedGridRotateItems0 = "_stackedGridRotateItems0_1e05o_13";
784
+ const stackedGridRotateItems90 = "_stackedGridRotateItems90_1e05o_19";
785
+ const stackedGridRotateItems180 = "_stackedGridRotateItems180_1e05o_25";
786
+ const stackedGridRotateItems270 = "_stackedGridRotateItems270_1e05o_31";
787
+ const defaultStyles$g = {
788
+ stackedGridContainer,
789
+ stackedGridRotateItems0,
790
+ stackedGridRotateItems90,
791
+ stackedGridRotateItems180,
792
+ stackedGridRotateItems270
793
+ };
794
+ const getItemRotate = (fromBottom, fromLeft) => {
795
+ if (fromBottom && fromLeft) {
796
+ return "stackedGridRotateItems270";
797
+ } else if (fromBottom && !fromLeft) {
798
+ return "stackedGridRotateItems180";
799
+ } else if (!fromBottom && !fromLeft) {
800
+ return "stackedGridRotateItems90";
801
+ } else if (!fromBottom && fromLeft) {
802
+ return "stackedGridRotateItems0";
803
+ }
804
+ };
805
+ const getContainerFlip = (fromBottom, fromLeft) => {
806
+ let scaleX = fromLeft ? 1 : -1;
807
+ let scaleY = fromBottom ? -1 : 1;
808
+ return `scale(${scaleX}, ${scaleY})`;
809
+ };
810
+ const StackedGrid = ({
811
+ fromLeft,
812
+ fromBottom,
813
+ containerWidth,
814
+ children,
815
+ styles: styles2
816
+ }) => {
817
+ let containerFlip = getContainerFlip(fromBottom, fromLeft);
818
+ let itemRotateClass = getItemRotate(fromBottom, fromLeft);
819
+ let flexStyles = {
820
+ display: "flex",
821
+ flexDirection: "row",
822
+ flexWrap: "wrap",
823
+ width: containerWidth,
824
+ transform: containerFlip
825
+ };
826
+ styles2 = mergeStyles(defaultStyles$g, styles2);
827
+ return jsxRuntime.jsx("div", {
828
+ style: flexStyles,
829
+ className: `${styles2.stackedGridContainer} ${styles2[itemRotateClass]}`,
830
+ children
831
+ });
832
+ };
833
+ const svg$4 = "_svg_l2fsl_9";
834
+ const squareFill = "_squareFill_l2fsl_16";
835
+ const defaultStyles$f = {
836
+ svg: svg$4,
837
+ squareFill
838
+ };
839
+ const SquareIcon = ({
840
+ color,
841
+ size,
842
+ styles: styles2
843
+ }) => {
844
+ styles2 = mergeStyles({
845
+ ...defaultStyles$f
846
+ }, styles2);
847
+ return jsxRuntime.jsx("svg", {
848
+ width: size,
849
+ height: size,
850
+ className: styles2.svg,
851
+ viewBox: `0 0 ${size} ${size}`,
852
+ children: jsxRuntime.jsx("rect", {
853
+ id: "square",
854
+ fill: color,
855
+ className: styles2.squareFill,
856
+ width: size,
857
+ height: size
858
+ })
859
+ });
860
+ };
861
+ const button$3 = "_button_1fees_1";
862
+ const icon = "_icon_1fees_6";
863
+ const defaultStyles$e = {
864
+ button: button$3,
865
+ icon
866
+ };
867
+ function ArrowButton({
868
+ direction = "right",
869
+ disabled = false,
870
+ styles: styles2,
871
+ onClick
872
+ }) {
873
+ styles2 = mergeStyles(defaultStyles$e, styles2);
874
+ return jsxRuntime.jsx("button", {
875
+ className: styles2.button,
876
+ disabled,
877
+ onClick,
878
+ children: jsxRuntime.jsxs("svg", {
879
+ className: [styles2.icon, direction].join(" "),
880
+ viewBox: "0 0 28 28",
881
+ xmlns: "http://www.w3.org/2000/svg",
882
+ children: [jsxRuntime.jsx("circle", {
883
+ cx: 14,
884
+ cy: 14,
885
+ r: "13",
886
+ "fill-rule": "nonzero"
887
+ }), jsxRuntime.jsx("g", {
888
+ transform: "translate(6 7)",
889
+ children: jsxRuntime.jsx("path", {
890
+ d: "M0.667319 7.63692L12.8497 7.63692L8.07231 13.3539L8.69338 13.975L15.334 7.31842L15.334 6.68143L8.69338 0.0249018L8.07231 0.645966L12.8497 6.36294L0.667319 6.36294L0.667319 7.63692Z",
891
+ fill: "#121212"
892
+ })
893
+ })]
894
+ })
895
+ });
896
+ }
897
+ const button$2 = "_button_19t7j_1";
898
+ const buttonInner$1 = "_buttonInner_19t7j_6";
899
+ const defaultStyles$d = {
900
+ button: button$2,
901
+ buttonInner: buttonInner$1
902
+ };
903
+ function Button({
904
+ type = "regular",
905
+ onClick,
906
+ styles: styles2,
907
+ children
908
+ }) {
909
+ styles2 = mergeStyles(defaultStyles$d, styles2);
910
+ return jsxRuntime.jsx("button", {
911
+ className: styles2.button,
912
+ "data-type": type,
913
+ onClick,
914
+ children: jsxRuntime.jsx("div", {
915
+ className: styles2.buttonInner,
916
+ children
917
+ })
918
+ });
919
+ }
920
+ const button$1 = "_button_6w12u_1";
921
+ const buttonBorder = "_buttonBorder_6w12u_10";
922
+ const svg$3 = "_svg_6w12u_18";
923
+ const path$3 = "_path_6w12u_24";
924
+ const defaultStyles$c = {
925
+ button: button$1,
926
+ buttonBorder,
927
+ svg: svg$3,
928
+ path: path$3
929
+ };
930
+ function CloseButton({
931
+ border = true,
932
+ onClick,
933
+ styles: styles2
934
+ }) {
935
+ styles2 = mergeStyles(defaultStyles$c, styles2);
936
+ return jsxRuntime.jsx("button", {
937
+ className: [styles2.button, border && styles2.buttonBorder].join(" "),
938
+ onClick,
939
+ children: jsxRuntime.jsx("svg", {
940
+ className: styles2.svg,
941
+ viewBox: "0 0 17 17",
942
+ fill: "none",
943
+ xmlns: "http://www.w3.org/2000/svg",
944
+ children: jsxRuntime.jsx("path", {
945
+ className: styles2.path,
946
+ "fill-rule": "evenodd",
947
+ "clip-rule": "evenodd",
948
+ d: "M8.32497 10.025L15.5499 16.6499L16.6249 15.5749L10.025 8.32497L16.6249 1.075L15.5499 0L8.32497 6.62498L1.075 0.0249999L0 1.1L6.62498 8.32497L0 15.5499L1.075 16.6249L8.32497 10.025Z"
949
+ })
950
+ })
951
+ });
952
+ }
953
+ const sortAscending = (accessor) => {
954
+ return (a, b) => {
955
+ const valueA = a[accessor];
956
+ const valueB = b[accessor];
957
+ if (valueA < valueB)
958
+ return -1;
959
+ if (valueA > valueB)
960
+ return 1;
961
+ return 0;
962
+ };
963
+ };
964
+ const sortDescending = (accessor) => {
965
+ return (a, b) => {
966
+ const valueA = a[accessor];
967
+ const valueB = b[accessor];
968
+ if (valueA > valueB)
969
+ return -1;
970
+ if (valueA < valueB)
971
+ return 1;
972
+ return 0;
973
+ };
974
+ };
975
+ function useTable({
976
+ columns,
977
+ data,
978
+ sortState
979
+ }) {
980
+ const sortedData = hooks.useMemo(() => {
981
+ if (sortState.columnIndex < 0) {
982
+ return data;
983
+ }
984
+ const column = columns[sortState.columnIndex];
985
+ const sortFunction = sortState.ascending ? sortAscending(column.accessor) : sortDescending(column.accessor);
986
+ return data.toSorted(sortFunction);
987
+ }, [columns, data, sortState]);
988
+ const columnModels = hooks.useMemo(() => {
989
+ return columns.map((column, columnIndex) => {
990
+ const isSorted = sortState.columnIndex === columnIndex && sortState;
991
+ return new ColumnModel(columnIndex, column, isSorted);
992
+ });
993
+ }, [columns, sortState]);
994
+ const rowModels = hooks.useMemo(() => {
995
+ return sortedData.map((d2, rowIndex) => {
996
+ const cells = columnModels.map((column, columnIndex) => {
997
+ return new CellModel(column, columnIndex, d2, column.cell);
998
+ });
999
+ return new RowModel(rowIndex, cells);
1000
+ });
1001
+ }, [columnModels, sortedData]);
1002
+ return {
1003
+ columns: columnModels,
1004
+ rows: rowModels
1005
+ };
1006
+ }
1007
+ class ColumnModel {
1008
+ constructor(index2, definition, isSorted) {
1009
+ this.index = index2;
1010
+ this.definition = definition;
1011
+ this.isSorted = isSorted;
1012
+ this.defaultValue = definition.defaultValue;
1013
+ }
1014
+ get id() {
1015
+ return this.definition.id || this.header;
1016
+ }
1017
+ get accessor() {
1018
+ return this.definition.accessor;
1019
+ }
1020
+ get header() {
1021
+ return this.definition.header;
1022
+ }
1023
+ get headerProps() {
1024
+ return {
1025
+ text: this.header,
1026
+ sortable: this.definition.sortable,
1027
+ isSorted: this.isSorted,
1028
+ ...this.headerCellStyle
1029
+ };
1030
+ }
1031
+ get cell() {
1032
+ return this.definition.cell;
1033
+ }
1034
+ get styles() {
1035
+ return this.definition.styles;
1036
+ }
1037
+ }
1038
+ class RowModel {
1039
+ constructor(index2, cells) {
1040
+ this.index = index2;
1041
+ this.cells = cells;
1042
+ }
1043
+ get id() {
1044
+ return this.index;
1045
+ }
1046
+ }
1047
+ class CellModel {
1048
+ constructor(column, columnIndex, row, cell) {
1049
+ this.column = column;
1050
+ this.columnIndex = columnIndex;
1051
+ this.row = row;
1052
+ this.cell = cell;
1053
+ }
1054
+ get id() {
1055
+ return this.columnIndex;
1056
+ }
1057
+ get displayValue() {
1058
+ if (this.cell) {
1059
+ return this.cell(this.row);
1060
+ }
1061
+ if (!Object.prototype.hasOwnProperty.call(this.row, this.column.accessor)) {
1062
+ if (this.column.defaultValue) {
1063
+ return this.column.defaultValue.toString();
1064
+ }
1065
+ const rowData = JSON.stringify(this.row, null, 2);
1066
+ throw new Error(`Missing value for key ${this.column.accessor} in ${rowData}`);
1067
+ }
1068
+ return this.row[this.column.accessor].toString();
1069
+ }
1070
+ }
1071
+ const table = "_table_1b75c_9";
1072
+ const hideHeader = "_hideHeader_1b75c_18";
1073
+ const hideHeaderNoBorder = "_hideHeaderNoBorder_1b75c_27";
1074
+ const headerCell = "_headerCell_1b75c_31";
1075
+ const headerCellButton = "_headerCellButton_1b75c_39";
1076
+ const bodyRow = "_bodyRow_1b75c_48";
1077
+ const bodyCell = "_bodyCell_1b75c_53";
1078
+ const defaultStyles$b = {
1079
+ table,
1080
+ hideHeader,
1081
+ hideHeaderNoBorder,
1082
+ headerCell,
1083
+ headerCellButton,
1084
+ bodyRow,
1085
+ bodyCell
1086
+ };
1087
+ function Table({
1088
+ columns,
1089
+ data,
1090
+ hideHeader: hideHeader2 = false,
1091
+ styles: styles2
1092
+ }) {
1093
+ const [sortState, setSortState] = hooks.useState(() => {
1094
+ const columnIndex = columns.findIndex((column) => {
1095
+ if ("sort" in column) {
1096
+ return true;
1097
+ }
1098
+ return false;
1099
+ });
1100
+ const ascending = columnIndex >= 0 ? columns[columnIndex].sort.ascending : false;
1101
+ return {
1102
+ columnIndex,
1103
+ ascending
1104
+ };
1105
+ });
1106
+ const table2 = useTable({
1107
+ columns,
1108
+ data,
1109
+ sortState
1110
+ });
1111
+ const sortByColumn = (index2) => {
1112
+ setSortState((currentState) => {
1113
+ return {
1114
+ columnIndex: index2,
1115
+ ascending: index2 === currentState.columnIndex ? !currentState.ascending : false
1116
+ };
1117
+ });
1118
+ };
1119
+ styles2 = mergeStyles(defaultStyles$b, styles2);
1120
+ return jsxRuntime.jsxs("table", {
1121
+ className: styles2.table,
1122
+ children: [jsxRuntime.jsx("thead", {
1123
+ className: hideHeader2 && styles2.hideHeader,
1124
+ children: jsxRuntime.jsx("tr", {
1125
+ children: table2.columns.map((column, index2) => {
1126
+ var _a;
1127
+ return jsxRuntime.jsx("th", {
1128
+ className: mergeStyles(styles2.headerCell, (_a = column.styles) == null ? void 0 : _a.headerCell),
1129
+ children: jsxRuntime.jsx(HeaderCell, {
1130
+ styles: mergeStyles(styles2, column.styles),
1131
+ onClick: () => sortByColumn(index2),
1132
+ ...column.headerProps
1133
+ }, index2)
1134
+ }, column.id);
1135
+ })
1136
+ })
1137
+ }), jsxRuntime.jsx("tbody", {
1138
+ className: hideHeader2 && styles2.hideHeaderNoBorder,
1139
+ children: table2.rows.map((row) => {
1140
+ return jsxRuntime.jsx("tr", {
1141
+ className: styles2.bodyRow,
1142
+ children: row.cells.map((cell) => {
1143
+ var _a;
1144
+ return jsxRuntime.jsx("td", {
1145
+ className: mergeStyles(styles2.bodyCell, (_a = cell.column.styles) == null ? void 0 : _a.bodyCell),
1146
+ children: cell.displayValue
1147
+ }, cell.id);
1148
+ })
1149
+ }, row.id);
1150
+ })
1151
+ })]
1152
+ });
1153
+ }
1154
+ function HeaderCell({
1155
+ text: text2,
1156
+ sortable,
1157
+ isSorted,
1158
+ styles: styles2,
1159
+ onClick
1160
+ }) {
1161
+ if (!sortable) {
1162
+ return text2;
1163
+ }
1164
+ let direction = "down";
1165
+ if ((isSorted == null ? void 0 : isSorted.ascending) === false) {
1166
+ direction = "up";
1167
+ }
1168
+ return jsxRuntime.jsxs("button", {
1169
+ onClick,
1170
+ className: styles2.headerCellButton,
1171
+ children: [jsxRuntime.jsx("span", {
1172
+ children: text2
1173
+ }), jsxRuntime.jsx(Chevron, {
1174
+ active: !!isSorted,
1175
+ direction
1176
+ })]
1177
+ });
1178
+ }
1179
+ function preventOverlap(labelPositions, iteration = 0, labelHeight = 12) {
1180
+ const maxIterations = 10;
1181
+ let totalOverlap = 0;
1182
+ for (let index2 = 1; index2 < labelPositions.length; index2++) {
1183
+ const previousElement = labelPositions[index2 - 1];
1184
+ const element = labelPositions[index2];
1185
+ const overlap = previousElement.y - (element.y - labelHeight);
1186
+ if (overlap < 0) {
1187
+ continue;
1188
+ }
1189
+ previousElement.y -= overlap / 2;
1190
+ element.y += overlap / 2;
1191
+ totalOverlap += overlap;
1192
+ }
1193
+ if (totalOverlap > 0 && iteration < maxIterations) {
1194
+ return preventOverlap(labelPositions, iteration + 1);
1195
+ }
1196
+ return labelPositions;
1197
+ }
1198
+ function uniqueBy(array, key) {
1199
+ return [...array.reduce((map, d2) => map.set(d2[key], d2), /* @__PURE__ */ new Map()).values()];
1200
+ }
1201
+ function positionLabels(labels) {
1202
+ labels = uniqueBy(labels, "value");
1203
+ labels.sort((a, b) => a.y - b.y);
1204
+ return preventOverlap(labels);
1205
+ }
1206
+ function scaleLinear(domain, range) {
1207
+ const [domainMin, domainMax] = domain;
1208
+ const [rangeMin, rangeMax] = range;
1209
+ const slope = (rangeMax - rangeMin) / (domainMax - domainMin);
1210
+ const intercept = rangeMin - slope * domainMin;
1211
+ return function(x) {
1212
+ return slope * x + intercept;
1213
+ };
1214
+ }
1215
+ function useWindowSize() {
1216
+ const [windowSize, setWindowSize] = hooks.useState(() => {
1217
+ if (typeof window === "undefined")
1218
+ return {
1219
+ width: 0,
1220
+ height: 0
1221
+ };
1222
+ return {
1223
+ width: window.innerWidth,
1224
+ height: window.innerHeight
1225
+ };
1226
+ });
1227
+ hooks.useEffect(() => {
1228
+ if (typeof window === "undefined")
1229
+ return;
1230
+ function handleResize() {
1231
+ setWindowSize({
1232
+ width: window.innerWidth,
1233
+ height: window.innerHeight
1234
+ });
1235
+ }
1236
+ window.addEventListener("resize", handleResize);
1237
+ return () => {
1238
+ window.removeEventListener("resize", handleResize);
1239
+ };
1240
+ }, []);
1241
+ return windowSize;
1242
+ }
1243
+ const slopeChartContainer = "_slopeChartContainer_gj7pr_1";
1244
+ const svg$2 = "_svg_gj7pr_5";
1245
+ const line = "_line_gj7pr_9";
1246
+ const circle = "_circle_gj7pr_14";
1247
+ const label = "_label_gj7pr_18";
1248
+ const y1Label = "_y1Label_gj7pr_24";
1249
+ const y2Label = "_y2Label_gj7pr_28";
1250
+ const axis$1 = "_axis_gj7pr_32";
1251
+ const axisLabel = "_axisLabel_gj7pr_37";
1252
+ const defaultStyles$a = {
1253
+ slopeChartContainer,
1254
+ svg: svg$2,
1255
+ line,
1256
+ circle,
1257
+ label,
1258
+ y1Label,
1259
+ y2Label,
1260
+ axis: axis$1,
1261
+ axisLabel
1262
+ };
1263
+ const SlopeChart = ({
1264
+ domain,
1265
+ lines,
1266
+ y1Label: y1Label2 = (d2) => d2.y1,
1267
+ y2Label: y2Label2 = (d2) => d2.y2,
1268
+ axis: axis2,
1269
+ styles: styles2,
1270
+ padding = {
1271
+ left: 24,
1272
+ right: 24,
1273
+ top: 20,
1274
+ bottom: 20
1275
+ }
1276
+ }) => {
1277
+ const wrapperRef = hooks.useRef(null);
1278
+ const windowSize = useWindowSize();
1279
+ const [width, setWidth] = hooks.useState(0);
1280
+ const contentWidth = Math.floor(width - padding.left - padding.right);
1281
+ const contentHeight = contentWidth;
1282
+ const height = contentHeight + padding.top + padding.bottom;
1283
+ const yScale = scaleLinear(domain, [contentHeight, 0]);
1284
+ const show = width > 0;
1285
+ hooks.useLayoutEffect(() => {
1286
+ const newWidth = wrapperRef.current.getBoundingClientRect().width;
1287
+ setWidth(newWidth);
1288
+ }, [windowSize]);
1289
+ const y1Labels = hooks.useMemo(() => {
1290
+ let labels = lines.map((d2) => ({
1291
+ y: yScale(d2.y1),
1292
+ value: y1Label2(d2)
1293
+ }));
1294
+ return positionLabels(labels);
1295
+ }, [lines, y1Label2, yScale]);
1296
+ const y2Labels = hooks.useMemo(() => {
1297
+ let labels = lines.map((d2) => ({
1298
+ y: yScale(d2.y2),
1299
+ value: y2Label2(d2)
1300
+ }));
1301
+ return positionLabels(labels);
1302
+ }, [lines, y2Label2, yScale]);
1303
+ styles2 = mergeStyles({
1304
+ ...defaultStyles$a
1305
+ }, styles2);
1306
+ const chart = jsxRuntime.jsx("svg", {
1307
+ class: styles2.svg,
1308
+ width,
1309
+ height,
1310
+ children: jsxRuntime.jsxs("g", {
1311
+ transform: `translate(${padding.left} ${padding.top})`,
1312
+ children: [jsxRuntime.jsxs("g", {
1313
+ transform: `translate(0 ${contentHeight})`,
1314
+ children: [jsxRuntime.jsx("line", {
1315
+ x1: 0,
1316
+ x2: contentWidth,
1317
+ className: styles2.axis,
1318
+ "shape-rendering": "crispEdges"
1319
+ }), jsxRuntime.jsx("text", {
1320
+ "dominant-baseline": "hanging",
1321
+ className: [styles2.label, styles2.axisLabel].join(" "),
1322
+ children: axis2.startLabel
1323
+ }), jsxRuntime.jsx("text", {
1324
+ x: contentWidth,
1325
+ "dominant-baseline": "hanging",
1326
+ "text-anchor": "end",
1327
+ className: [styles2.label, styles2.axisLabel].join(" "),
1328
+ children: axis2.endLabel
1329
+ })]
1330
+ }), lines.map((line2, index2) => {
1331
+ const itemStyles = mergeStyles({
1332
+ ...styles2
1333
+ }, line2.styles);
1334
+ return jsxRuntime.jsxs("g", {
1335
+ children: [jsxRuntime.jsx("line", {
1336
+ x1: 0,
1337
+ y1: yScale(line2.y1),
1338
+ x2: contentWidth,
1339
+ y2: yScale(line2.y2),
1340
+ className: `${itemStyles.line} stroke-color--${line2.abbreviation}`
1341
+ }), jsxRuntime.jsx("circle", {
1342
+ cx: 0,
1343
+ cy: yScale(line2.y1),
1344
+ r: 4,
1345
+ className: `${itemStyles.circle} fill-color--${line2.abbreviation}`
1346
+ }), jsxRuntime.jsx("circle", {
1347
+ cx: contentWidth,
1348
+ cy: yScale(line2.y2),
1349
+ r: 4,
1350
+ className: `${itemStyles.circle} fill-color--${line2.abbreviation}`
1351
+ })]
1352
+ }, index2);
1353
+ }), y1Labels.map((label2, index2) => {
1354
+ return jsxRuntime.jsx("g", {
1355
+ children: jsxRuntime.jsx("text", {
1356
+ x: 0,
1357
+ y: label2.y,
1358
+ className: [styles2.label, styles2.y1Label].join(" "),
1359
+ "text-anchor": "end",
1360
+ "dominant-baseline": "middle",
1361
+ children: label2.value
1362
+ })
1363
+ }, index2);
1364
+ }), y2Labels.map((label2, index2) => {
1365
+ return jsxRuntime.jsx("g", {
1366
+ children: jsxRuntime.jsx("text", {
1367
+ x: contentWidth,
1368
+ y: label2.y,
1369
+ className: [styles2.label, styles2.y2Label].join(" "),
1370
+ "text-anchor": "start",
1371
+ "dominant-baseline": "middle",
1372
+ children: label2.value
1373
+ })
1374
+ }, index2);
1375
+ })]
1376
+ })
1377
+ });
1378
+ return jsxRuntime.jsx("div", {
1379
+ class: styles2.slopeChartContainer,
1380
+ ref: wrapperRef,
1381
+ children: show && chart
1382
+ });
1383
+ };
1384
+ const useTooltipTarget = (targetElement, trackPosition) => {
1385
+ const [targetRect, setTargetRect] = hooks.useState();
1386
+ const [position, setPosition] = hooks.useState(null);
1387
+ const [hoverActive, setHoverActive] = hooks.useState(false);
1388
+ const onMouseMove = ({
1389
+ clientX,
1390
+ clientY,
1391
+ currentTarget
1392
+ }) => {
1393
+ const rect2 = currentTarget.getBoundingClientRect();
1394
+ const x = clientX - rect2.left;
1395
+ const y = clientY - rect2.top;
1396
+ requestAnimationFrame(() => {
1397
+ setPosition({
1398
+ x,
1399
+ y
1400
+ });
1401
+ setHoverActive(true);
1402
+ });
1403
+ };
1404
+ const onMouseOut = () => {
1405
+ requestAnimationFrame(() => {
1406
+ setHoverActive(false);
1407
+ });
1408
+ };
1409
+ hooks.useEffect(() => {
1410
+ setTargetRect(targetElement.getBoundingClientRect());
1411
+ if (trackPosition) {
1412
+ targetElement.addEventListener("mousemove", onMouseMove);
1413
+ targetElement.addEventListener("mouseout", onMouseOut);
1414
+ }
1415
+ return () => {
1416
+ if (trackPosition) {
1417
+ targetElement.removeEventListener("mousemove", onMouseMove);
1418
+ targetElement.removeEventListener("mouseout", onMouseOut);
1419
+ }
1420
+ };
1421
+ }, [targetElement, trackPosition]);
1422
+ return {
1423
+ targetRect,
1424
+ positionInTarget: position,
1425
+ hoverActive
1426
+ };
1427
+ };
1428
+ function n(n2) {
1429
+ return (r) => {
1430
+ n2.forEach((n3) => {
1431
+ "function" == typeof n3 ? n3(r) : null != n3 && (n3.current = r);
1432
+ });
1433
+ };
1434
+ }
1435
+ var T, c;
1436
+ !function(e) {
1437
+ e.APPEAR = "appear", e.APPEAR_ACTIVE = "appearActive", e.APPEAR_DONE = "appearDone", e.ENTER = "enter", e.ENTER_ACTIVE = "enterActive", e.ENTER_DONE = "enterDone", e.EXIT = "exit", e.EXIT_ACTIVE = "exitActive", e.EXIT_DONE = "exitDone";
1438
+ }(T || (T = {})), function(e) {
1439
+ e.ENTER = "onEnter", e.ENTERING = "onEntering", e.ENTERED = "onEntered", e.EXIT = "onExit", e.EXITING = "onExiting", e.EXITED = "onExited";
1440
+ }(c || (c = {}));
1441
+ const s = { [T.APPEAR]: [c.ENTER, T.APPEAR_ACTIVE], [T.APPEAR_ACTIVE]: [c.ENTERING, T.APPEAR_DONE, true], [T.APPEAR_DONE]: [c.ENTERED], [T.ENTER]: [c.ENTER, T.ENTER_ACTIVE], [T.ENTER_ACTIVE]: [c.ENTERING, T.ENTER_DONE, true], [T.ENTER_DONE]: [c.ENTERED], [T.EXIT]: [c.EXIT, T.EXIT_ACTIVE], [T.EXIT_ACTIVE]: [c.EXITING, T.EXIT_DONE, true], [T.EXIT_DONE]: [c.EXITED] };
1442
+ var u = (r) => {
1443
+ const { children: c2, in: u2 = false, appear: A = false, enter: N2 = true, exit: l = true, duration: I = 500, alwaysMounted: p2 = false, addEndListener: R2 } = r, P2 = hooks.useRef(), _2 = hooks.useRef();
1444
+ let d2 = false;
1445
+ const [f, D] = hooks.useState(() => (d2 = true, u2 ? A ? T.APPEAR : T.APPEAR_DONE : T.EXIT_DONE));
1446
+ hooks.useEffect(() => {
1447
+ var e;
1448
+ const { setTimeout: E, clearTimeout: t } = window, [n2, o, i] = s[f];
1449
+ return null == (e = r[n2]) || e.call(r, P2.current), o && (i ? R2 ? R2(P2.current, () => D(o)) : _2.current = E(D, I, o) : D(o)), () => {
1450
+ t(_2.current);
1451
+ };
1452
+ }, [f, I]), hooks.useLayoutEffect(() => {
1453
+ d2 || D(u2 ? N2 ? T.ENTER : T.ENTER_DONE : l ? T.EXIT : T.EXIT_DONE);
1454
+ }, [u2]);
1455
+ const X = hooks.useMemo(() => {
1456
+ const e = {};
1457
+ return Object.values(T).forEach((r2) => {
1458
+ e[r2] = f === r2;
1459
+ }), e;
1460
+ }, [f]);
1461
+ if (!p2 && f === T.EXIT_DONE)
1462
+ return null;
1463
+ const O = c2(X, f);
1464
+ return preact.cloneElement(O, { ref: n([P2, O.ref]) });
1465
+ };
1466
+ function N(e, r) {
1467
+ if (null == e)
1468
+ return {};
1469
+ var E, t, n2 = {}, o = Object.keys(e);
1470
+ for (t = 0; t < o.length; t++)
1471
+ r.indexOf(E = o[t]) >= 0 || (n2[E] = e[E]);
1472
+ return n2;
1473
+ }
1474
+ const p = ["children", "classNames"], R = { [T.APPEAR]: "-appear", [T.APPEAR_ACTIVE]: "-appear-active", [T.APPEAR_DONE]: "-appear-done", [T.ENTER]: "-enter", [T.ENTER_ACTIVE]: "-enter-active", [T.ENTER_DONE]: "-enter-done", [T.EXIT]: "-exit", [T.EXIT_ACTIVE]: "-exit-active", [T.EXIT_DONE]: "-exit-done" }, P = (...e) => e.filter((e2) => !!e2).join(" "), _ = (e, r) => "string" == typeof r ? `${r}${R[e]}` : r[e];
1475
+ var d = (E) => {
1476
+ const { children: t, classNames: n2 } = E, o = N(E, p);
1477
+ return preact.createElement(u, o, (r, E2) => {
1478
+ const { className: o2 } = t.props, i = hooks.useMemo(() => P(o2, ((e, r2) => {
1479
+ const E3 = _(e, r2);
1480
+ switch (e) {
1481
+ case T.APPEAR_ACTIVE:
1482
+ return P(_(T.APPEAR, r2), E3);
1483
+ case T.ENTER_ACTIVE:
1484
+ return P(_(T.ENTER, r2), E3);
1485
+ case T.EXIT_ACTIVE:
1486
+ return P(_(T.EXIT, r2), E3);
1487
+ default:
1488
+ return E3;
1489
+ }
1490
+ })(E2, n2)), [o2, n2, E2]);
1491
+ return preact.cloneElement(t, { className: i });
1492
+ });
1493
+ };
1494
+ const transitionContainer = "_transitionContainer_1gzlr_1";
1495
+ const modalBox = "_modalBox_1gzlr_13";
1496
+ const enter = "_enter_1gzlr_21";
1497
+ const exitDone = "_exitDone_1gzlr_22";
1498
+ const enterActive = "_enterActive_1gzlr_31";
1499
+ const exit = "_exit_1gzlr_22";
1500
+ const styles$4 = {
1501
+ transitionContainer,
1502
+ modalBox,
1503
+ enter,
1504
+ exitDone,
1505
+ enterActive,
1506
+ exit
1507
+ };
1508
+ function Modal({
1509
+ visible = false,
1510
+ children
1511
+ }) {
1512
+ return jsxRuntime.jsx(d, {
1513
+ in: visible,
1514
+ duration: 300,
1515
+ classNames: styles$4,
1516
+ alwaysMounted: true,
1517
+ children: jsxRuntime.jsx("div", {
1518
+ class: styles$4.transitionContainer,
1519
+ children: jsxRuntime.jsx("div", {
1520
+ class: styles$4.modalBox,
1521
+ children
1522
+ })
1523
+ })
1524
+ });
1525
+ }
1526
+ const tooltip = "_tooltip_11t5d_1";
1527
+ const defaultStyles$9 = {
1528
+ tooltip
1529
+ };
1530
+ const TooltipType = {
1531
+ float: "float",
1532
+ modal: "modal"
1533
+ };
1534
+ function Tooltip({
1535
+ for: targetElement,
1536
+ renderIn: refOrSelector,
1537
+ type = TooltipType.float,
1538
+ styles: styles2,
1539
+ children
1540
+ }) {
1541
+ if (!targetElement)
1542
+ throw new Error("Target for tooltip cannot be undefined");
1543
+ const [tooltipPosition, setTooltipPosition] = hooks.useState({
1544
+ x: 0,
1545
+ y: 0
1546
+ });
1547
+ const [displayElement, setDisplayElement] = hooks.useState(null);
1548
+ const trackPosition = typeof children === "function";
1549
+ const {
1550
+ targetRect,
1551
+ positionInTarget,
1552
+ hoverActive
1553
+ } = useTooltipTarget(targetElement, trackPosition);
1554
+ const tooltipRef = hooks.useRef(null);
1555
+ styles2 = mergeStyles(defaultStyles$9, styles2);
1556
+ hooks.useEffect(() => {
1557
+ let element = null;
1558
+ if (typeof refOrSelector === "string") {
1559
+ element = document.querySelector(refOrSelector);
1560
+ } else if ("current" in refOrSelector) {
1561
+ element = refOrSelector.current;
1562
+ } else {
1563
+ throw new Error("renderIn prop needs to be a selector or ref (from useRef)");
1564
+ }
1565
+ setDisplayElement(element);
1566
+ }, [refOrSelector]);
1567
+ hooks.useLayoutEffect(() => {
1568
+ if (!tooltipRef.current)
1569
+ return;
1570
+ if (trackPosition && positionInTarget) {
1571
+ const newPosition = tooltipPositionForPoint({
1572
+ targetRect,
1573
+ positionInTarget,
1574
+ tooltip: tooltipRef.current,
1575
+ displayElement
1576
+ });
1577
+ setTooltipPosition(newPosition);
1578
+ } else if (!trackPosition) {
1579
+ const newPosition = tooltipPositionForRect({
1580
+ targetRect,
1581
+ tooltip: tooltipRef.current,
1582
+ displayElement
1583
+ });
1584
+ setTooltipPosition(newPosition);
1585
+ }
1586
+ }, [trackPosition, targetRect, positionInTarget, displayElement, tooltipRef]);
1587
+ if (!displayElement)
1588
+ return;
1589
+ const displayTooltip = hoverActive || !trackPosition;
1590
+ const fixedStyle = type === TooltipType.modal ? {} : {
1591
+ display: displayTooltip ? "block" : "none",
1592
+ position: "fixed",
1593
+ left: tooltipPosition.x,
1594
+ top: tooltipPosition.y,
1595
+ zIndex: 100
1596
+ };
1597
+ const tooltip2 = jsxRuntime.jsxs("div", {
1598
+ ref: tooltipRef,
1599
+ className: styles2.tooltip,
1600
+ style: fixedStyle,
1601
+ children: [positionInTarget && children(positionInTarget), !trackPosition && children]
1602
+ });
1603
+ return compat.createPortal(type === TooltipType.modal ? jsxRuntime.jsx(Modal, {
1604
+ visible: hoverActive,
1605
+ children: tooltip2
1606
+ }) : tooltip2, displayElement);
1607
+ }
1608
+ function tooltipPositionForPoint({
1609
+ targetRect,
1610
+ positionInTarget,
1611
+ tooltip: tooltip2,
1612
+ displayElement
1613
+ }) {
1614
+ const newPosition = {
1615
+ x: positionInTarget.x + targetRect.x,
1616
+ y: positionInTarget.y + targetRect.y
1617
+ };
1618
+ const tooltipWidth = tooltip2.offsetWidth;
1619
+ const tooltipHeight = tooltip2.offsetHeight;
1620
+ const displayElementRect = displayElement.getBoundingClientRect();
1621
+ if (newPosition.x + tooltipWidth > displayElementRect.right) {
1622
+ newPosition.x -= tooltipWidth;
1623
+ }
1624
+ if (newPosition.y + tooltipHeight > displayElementRect.bottom) {
1625
+ newPosition.y -= tooltipHeight;
1626
+ }
1627
+ return newPosition;
1628
+ }
1629
+ function tooltipPositionForRect({
1630
+ targetRect,
1631
+ tooltip: tooltip2,
1632
+ displayElement
1633
+ }) {
1634
+ const newPosition = {
1635
+ x: targetRect.right,
1636
+ y: targetRect.top
1637
+ };
1638
+ const tooltipWidth = tooltip2.offsetWidth;
1639
+ const tooltipHeight = tooltip2.offsetHeight;
1640
+ const displayElementRect = displayElement.getBoundingClientRect();
1641
+ if (newPosition.x + tooltipWidth > displayElementRect.right) {
1642
+ newPosition.x = targetRect.left - tooltipWidth;
1643
+ }
1644
+ if (newPosition.y - tooltipHeight < displayElementRect.top) {
1645
+ newPosition.y = targetRect.bottom;
1646
+ }
1647
+ return newPosition;
1648
+ }
1649
+ const text$2 = "_text_1b8t2_1";
1650
+ const container$3 = "_container_1b8t2_10";
1651
+ const defaultStyles$8 = {
1652
+ text: text$2,
1653
+ container: container$3
1654
+ };
1655
+ const ControlChange = ({
1656
+ previous: previous2,
1657
+ next: next2,
1658
+ text: text2,
1659
+ styles: styles2
1660
+ }) => {
1661
+ styles2 = mergeStyles({
1662
+ ...defaultStyles$8
1663
+ }, styles2);
1664
+ let hasChanged = next2 !== previous2;
1665
+ return jsxRuntime.jsx("div", {
1666
+ class: styles2.container,
1667
+ children: jsxRuntime.jsxs(jsxRuntime.Fragment, {
1668
+ children: [hasChanged ? jsxRuntime.jsx(GradientIcon, {
1669
+ previous: previous2,
1670
+ next: next2,
1671
+ styles: {
1672
+ previous: styles2.previous,
1673
+ next: styles2.next
1674
+ }
1675
+ }) : jsxRuntime.jsx(CircleIcon, {
1676
+ abbreviation: next2,
1677
+ styles: {
1678
+ rect: styles2.next
1679
+ }
1680
+ }), jsxRuntime.jsx("strong", {
1681
+ className: styles2.text,
1682
+ children: text2
1683
+ })]
1684
+ })
1685
+ });
1686
+ };
1687
+ const toplineResult = "_toplineResult_lvw57_9";
1688
+ const name = "_name_lvw57_12";
1689
+ const displayNumbers = "_displayNumbers_lvw57_25";
1690
+ const mainNumber = "_mainNumber_lvw57_34";
1691
+ const secondaryNumber = "_secondaryNumber_lvw57_38";
1692
+ const displayRow = "_displayRow_lvw57_45";
1693
+ const displayColumn = "_displayColumn_lvw57_51";
1694
+ const topRow = "_topRow_lvw57_55";
1695
+ const defaultStyles$7 = {
1696
+ toplineResult,
1697
+ name,
1698
+ displayNumbers,
1699
+ mainNumber,
1700
+ secondaryNumber,
1701
+ displayRow,
1702
+ displayColumn,
1703
+ topRow
1704
+ };
1705
+ const ToplineResult = ({
1706
+ name: name2,
1707
+ mainNumber: mainNumber2,
1708
+ secondaryNumber: secondaryNumber2,
1709
+ styles: styles2,
1710
+ displayRow: displayRow2 = false,
1711
+ abbreviation,
1712
+ onMouseOver,
1713
+ onInfoPress,
1714
+ showInfoButton = false
1715
+ }) => {
1716
+ styles2 = mergeStyles({
1717
+ ...defaultStyles$7
1718
+ }, styles2);
1719
+ const displayStyle = displayRow2 ? styles2.displayRow : styles2.displayColumn;
1720
+ return jsxRuntime.jsxs("div", {
1721
+ class: styles2.toplineResult,
1722
+ onMouseOver,
1723
+ children: [jsxRuntime.jsxs("div", {
1724
+ class: styles2.topRow,
1725
+ children: [jsxRuntime.jsx("span", {
1726
+ class: `${styles2.name} before-color--${abbreviation}`,
1727
+ children: name2
1728
+ }), " ", showInfoButton && jsxRuntime.jsx("span", {
1729
+ class: styles2.infoButton,
1730
+ children: jsxRuntime.jsx(InfoButton, {
1731
+ onClick: onInfoPress
1732
+ })
1733
+ })]
1734
+ }), jsxRuntime.jsxs("div", {
1735
+ class: `${styles2.displayNumbers} ${displayStyle}`,
1736
+ children: [jsxRuntime.jsx("div", {
1737
+ class: styles2.mainNumber,
1738
+ children: mainNumber2
1739
+ }), jsxRuntime.jsx("div", {
1740
+ class: styles2.secondaryNumber,
1741
+ children: secondaryNumber2
1742
+ })]
1743
+ })]
1744
+ });
1745
+ };
1746
+ const section = "_section_te61d_9";
1747
+ const borderTop = "_borderTop_te61d_13";
1748
+ const header = "_header_te61d_45";
1749
+ const content = "_content_te61d_65";
1750
+ const defaultStyles$6 = {
1751
+ section,
1752
+ borderTop,
1753
+ header,
1754
+ content
1755
+ };
1756
+ const PageSection = compat.forwardRef(({
1757
+ children,
1758
+ styles: styles2,
1759
+ borderTop: borderTop2 = false
1760
+ }, ref) => {
1761
+ styles2 = mergeStyles({
1762
+ ...defaultStyles$6
1763
+ }, styles2);
1764
+ return jsxRuntime.jsxs("section", {
1765
+ ref,
1766
+ className: [styles2.section, borderTop2 && styles2.borderTop].join(" "),
1767
+ children: [jsxRuntime.jsx("div", {
1768
+ className: styles2.header,
1769
+ children: children.header
1770
+ }), jsxRuntime.jsx("div", {
1771
+ className: styles2.content,
1772
+ children: children.content
1773
+ })]
1774
+ });
1775
+ });
1776
+ const text$1 = "_text_lo5h3_1";
1777
+ const axis = "_axis_lo5h3_6";
1778
+ const bar = "_bar_lo5h3_10";
1779
+ const defaultStyles$5 = {
1780
+ text: text$1,
1781
+ axis,
1782
+ bar
1783
+ };
1784
+ const ColumnChart = ({
1785
+ columns,
1786
+ maxValue,
1787
+ minValue,
1788
+ chartHeight,
1789
+ chartWidth,
1790
+ columnWidth,
1791
+ columnPadding,
1792
+ styles: styles2
1793
+ }) => {
1794
+ styles2 = mergeStyles(defaultStyles$5, styles2);
1795
+ const yScale = d3Scale.scaleLinear([maxValue, minValue], [0, chartHeight]);
1796
+ return jsxRuntime.jsxs("svg", {
1797
+ width: chartWidth,
1798
+ height: chartHeight,
1799
+ style: "",
1800
+ children: [columns.map((column, index2) => {
1801
+ const getHeight = (input2) => {
1802
+ return yScale(0) - yScale(input2);
1803
+ };
1804
+ let totalColumnWidth = Number(columnWidth) + Number(columnPadding.left) + Number(columnPadding.right);
1805
+ return jsxRuntime.jsxs("g", {
1806
+ children: [jsxRuntime.jsx("rect", {
1807
+ x: index2 * totalColumnWidth,
1808
+ height: getHeight(Math.abs(column.value)),
1809
+ width: columnWidth,
1810
+ y: column.value > 0 ? yScale(column.value) : yScale(0),
1811
+ fill: column.color,
1812
+ className: `${styles2.bar} fill-color--${column.id}`,
1813
+ id: column.id
1814
+ }, index2), jsxRuntime.jsx("text", {
1815
+ className: styles2.text,
1816
+ x: index2 * totalColumnWidth + 2,
1817
+ y: column.value < 0 ? yScale(0) - 6 : yScale(0) + 20,
1818
+ children: column.label
1819
+ })]
1820
+ }, index2);
1821
+ }), jsxRuntime.jsx("rect", {
1822
+ className: styles2.axis,
1823
+ x: 0,
1824
+ y: yScale(0),
1825
+ width: chartWidth,
1826
+ height: 1
1827
+ })]
1828
+ });
1829
+ };
1830
+ const text = "_text_vd5ly_1";
1831
+ const container$2 = "_container_vd5ly_9";
1832
+ const title$1 = "_title_vd5ly_16";
1833
+ const subtitle = "_subtitle_vd5ly_33";
1834
+ const blurb = "_blurb_vd5ly_44";
1835
+ const leftCell = "_leftCell_vd5ly_55";
1836
+ const rightCell = "_rightCell_vd5ly_55";
1837
+ const mugshot = "_mugshot_vd5ly_71";
1838
+ const defaultStyles$4 = {
1839
+ text,
1840
+ container: container$2,
1841
+ title: title$1,
1842
+ subtitle,
1843
+ blurb,
1844
+ leftCell,
1845
+ rightCell,
1846
+ mugshot
1847
+ };
1848
+ const PartyProfile = ({
1849
+ styles: styles2,
1850
+ title: title2,
1851
+ subtitle: subtitle2,
1852
+ blurb: blurb2,
1853
+ imgSrc,
1854
+ abbreviation
1855
+ }) => {
1856
+ styles2 = mergeStyles({
1857
+ ...defaultStyles$4
1858
+ }, styles2);
1859
+ return jsxRuntime.jsx("div", {
1860
+ class: styles2.container,
1861
+ children: jsxRuntime.jsxs(jsxRuntime.Fragment, {
1862
+ children: [jsxRuntime.jsxs("div", {
1863
+ className: styles2.leftCell,
1864
+ children: [jsxRuntime.jsx("h3", {
1865
+ className: `${styles2.title}`,
1866
+ children: title2
1867
+ }), jsxRuntime.jsx("div", {
1868
+ className: styles2.subtitle,
1869
+ children: subtitle2
1870
+ }), jsxRuntime.jsx("div", {
1871
+ className: styles2.blurb,
1872
+ children: blurb2
1873
+ })]
1874
+ }), jsxRuntime.jsx("div", {
1875
+ className: styles2.rightCell,
1876
+ children: jsxRuntime.jsx("img", {
1877
+ src: imgSrc,
1878
+ className: `${styles2.mugshot} bg-color--${abbreviation}`
1879
+ })
1880
+ })]
1881
+ })
1882
+ });
1883
+ };
1884
+ var epsilon$1 = 1e-6;
1885
+ function noop() {
1886
+ }
1887
+ var x0 = Infinity, y0 = x0, x1 = -x0, y1 = x1;
1888
+ var boundsStream = {
1889
+ point: boundsPoint,
1890
+ lineStart: noop,
1891
+ lineEnd: noop,
1892
+ polygonStart: noop,
1893
+ polygonEnd: noop,
1894
+ result: function() {
1895
+ var bounds = [[x0, y0], [x1, y1]];
1896
+ x1 = y1 = -(y0 = x0 = Infinity);
1897
+ return bounds;
1898
+ }
1899
+ };
1900
+ function boundsPoint(x, y) {
1901
+ if (x < x0)
1902
+ x0 = x;
1903
+ if (x > x1)
1904
+ x1 = x;
1905
+ if (y < y0)
1906
+ y0 = y;
1907
+ if (y > y1)
1908
+ y1 = y;
1909
+ }
1910
+ function fitExtent(projection, extent, object) {
1911
+ var w = extent[1][0] - extent[0][0], h = extent[1][1] - extent[0][1], clip = projection.clipExtent && projection.clipExtent();
1912
+ projection.scale(150).translate([0, 0]);
1913
+ if (clip != null)
1914
+ projection.clipExtent(null);
1915
+ d3Geo.geoStream(object, projection.stream(boundsStream));
1916
+ var b = boundsStream.result(), k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])), x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2, y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;
1917
+ if (clip != null)
1918
+ projection.clipExtent(clip);
1919
+ return projection.scale(k * 150).translate([x, y]);
1920
+ }
1921
+ function fitSize(projection, size, object) {
1922
+ return fitExtent(projection, [[0, 0], size], object);
1923
+ }
1924
+ const pi = Math.PI, tau = 2 * pi, epsilon = 1e-6, tauEpsilon = tau - epsilon;
1925
+ function Path() {
1926
+ this._x0 = this._y0 = // start of current subpath
1927
+ this._x1 = this._y1 = null;
1928
+ this._ = "";
1929
+ }
1930
+ function path$2() {
1931
+ return new Path();
1932
+ }
1933
+ Path.prototype = path$2.prototype = {
1934
+ constructor: Path,
1935
+ moveTo: function(x, y) {
1936
+ this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y);
1937
+ },
1938
+ closePath: function() {
1939
+ if (this._x1 !== null) {
1940
+ this._x1 = this._x0, this._y1 = this._y0;
1941
+ this._ += "Z";
1942
+ }
1943
+ },
1944
+ lineTo: function(x, y) {
1945
+ this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y);
1946
+ },
1947
+ quadraticCurveTo: function(x12, y12, x, y) {
1948
+ this._ += "Q" + +x12 + "," + +y12 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
1949
+ },
1950
+ bezierCurveTo: function(x12, y12, x2, y2, x, y) {
1951
+ this._ += "C" + +x12 + "," + +y12 + "," + +x2 + "," + +y2 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
1952
+ },
1953
+ arcTo: function(x12, y12, x2, y2, r) {
1954
+ x12 = +x12, y12 = +y12, x2 = +x2, y2 = +y2, r = +r;
1955
+ var x02 = this._x1, y02 = this._y1, x21 = x2 - x12, y21 = y2 - y12, x01 = x02 - x12, y01 = y02 - y12, l01_2 = x01 * x01 + y01 * y01;
1956
+ if (r < 0)
1957
+ throw new Error("negative radius: " + r);
1958
+ if (this._x1 === null) {
1959
+ this._ += "M" + (this._x1 = x12) + "," + (this._y1 = y12);
1960
+ } else if (!(l01_2 > epsilon))
1961
+ ;
1962
+ else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) {
1963
+ this._ += "L" + (this._x1 = x12) + "," + (this._y1 = y12);
1964
+ } else {
1965
+ var x20 = x2 - x02, y20 = y2 - y02, l21_2 = x21 * x21 + y21 * y21, l20_2 = x20 * x20 + y20 * y20, l21 = Math.sqrt(l21_2), l01 = Math.sqrt(l01_2), l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), t01 = l / l01, t21 = l / l21;
1966
+ if (Math.abs(t01 - 1) > epsilon) {
1967
+ this._ += "L" + (x12 + t01 * x01) + "," + (y12 + t01 * y01);
1968
+ }
1969
+ this._ += "A" + r + "," + r + ",0,0," + +(y01 * x20 > x01 * y20) + "," + (this._x1 = x12 + t21 * x21) + "," + (this._y1 = y12 + t21 * y21);
1970
+ }
1971
+ },
1972
+ arc: function(x, y, r, a0, a1, ccw) {
1973
+ x = +x, y = +y, r = +r, ccw = !!ccw;
1974
+ var dx = r * Math.cos(a0), dy = r * Math.sin(a0), x02 = x + dx, y02 = y + dy, cw = 1 ^ ccw, da = ccw ? a0 - a1 : a1 - a0;
1975
+ if (r < 0)
1976
+ throw new Error("negative radius: " + r);
1977
+ if (this._x1 === null) {
1978
+ this._ += "M" + x02 + "," + y02;
1979
+ } else if (Math.abs(this._x1 - x02) > epsilon || Math.abs(this._y1 - y02) > epsilon) {
1980
+ this._ += "L" + x02 + "," + y02;
1981
+ }
1982
+ if (!r)
1983
+ return;
1984
+ if (da < 0)
1985
+ da = da % tau + tau;
1986
+ if (da > tauEpsilon) {
1987
+ this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x02) + "," + (this._y1 = y02);
1988
+ } else if (da > epsilon) {
1989
+ this._ += "A" + r + "," + r + ",0," + +(da >= pi) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1));
1990
+ }
1991
+ },
1992
+ rect: function(x, y, w, h) {
1993
+ this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + +w + "v" + +h + "h" + -w + "Z";
1994
+ },
1995
+ toString: function() {
1996
+ return this._;
1997
+ }
1998
+ };
1999
+ function multiplex(streams) {
2000
+ var n2 = streams.length;
2001
+ return {
2002
+ point: function(x, y) {
2003
+ var i = -1;
2004
+ while (++i < n2)
2005
+ streams[i].point(x, y);
2006
+ },
2007
+ sphere: function() {
2008
+ var i = -1;
2009
+ while (++i < n2)
2010
+ streams[i].sphere();
2011
+ },
2012
+ lineStart: function() {
2013
+ var i = -1;
2014
+ while (++i < n2)
2015
+ streams[i].lineStart();
2016
+ },
2017
+ lineEnd: function() {
2018
+ var i = -1;
2019
+ while (++i < n2)
2020
+ streams[i].lineEnd();
2021
+ },
2022
+ polygonStart: function() {
2023
+ var i = -1;
2024
+ while (++i < n2)
2025
+ streams[i].polygonStart();
2026
+ },
2027
+ polygonEnd: function() {
2028
+ var i = -1;
2029
+ while (++i < n2)
2030
+ streams[i].polygonEnd();
2031
+ }
2032
+ };
2033
+ }
2034
+ function geoAlbersUk() {
2035
+ var cache, cacheStream, main2 = d3Geo.geoAlbers().rotate([4.4, 0.8]).center([0, 55.4]).parallels([50, 60]), mainPoint, shetland = d3Geo.geoAlbers().rotate([4.4, 0.8]).center([0, 55.4]).parallels([50, 60]), shetlandPoint, point, pointStream = {
2036
+ point: function(x, y) {
2037
+ point = [x, y];
2038
+ }
2039
+ };
2040
+ function albersUk(coordinates) {
2041
+ var x = coordinates[0], y = coordinates[1];
2042
+ return point = null, (mainPoint.point(x, y), point) || (shetlandPoint.point(x, y), point);
2043
+ }
2044
+ albersUk.invert = function(coordinates) {
2045
+ var k = main2.scale(), t = main2.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k;
2046
+ return (y >= -0.089 && y < 0.06 && x >= 0.029 && x < 0.046 ? shetland : main2).invert(coordinates);
2047
+ };
2048
+ albersUk.stream = function(stream) {
2049
+ return cache && cacheStream === stream ? cache : cache = multiplex([
2050
+ main2.stream(cacheStream = stream),
2051
+ shetland.stream(stream)
2052
+ ]);
2053
+ };
2054
+ albersUk.precision = function(_2) {
2055
+ if (!arguments.length)
2056
+ return main2.precision();
2057
+ main2.precision(_2), shetland.precision(_2);
2058
+ return reset();
2059
+ };
2060
+ albersUk.scale = function(_2) {
2061
+ if (!arguments.length)
2062
+ return main2.scale();
2063
+ main2.scale(_2), shetland.scale(_2);
2064
+ return albersUk.translate(main2.translate());
2065
+ };
2066
+ albersUk.translate = function(_2) {
2067
+ if (!arguments.length)
2068
+ return main2.translate();
2069
+ var k = main2.scale(), x = +_2[0], y = +_2[1];
2070
+ mainPoint = main2.translate(_2).clipExtent([
2071
+ [x - 0.065 * k, y - 0.089 * k],
2072
+ [x + 0.075 * k, y + 0.089 * k]
2073
+ ]).stream(pointStream);
2074
+ shetlandPoint = shetland.translate([x + 0.01 * k, y + 0.025 * k]).clipExtent([
2075
+ [x + 0.029 * k + epsilon$1, y - 0.089 * k + epsilon$1],
2076
+ [x + 0.046 * k - epsilon$1, y - 0.06 * k - epsilon$1]
2077
+ ]).stream(pointStream);
2078
+ return reset();
2079
+ };
2080
+ albersUk.fitExtent = function(extent, object) {
2081
+ return fitExtent(albersUk, extent, object);
2082
+ };
2083
+ albersUk.fitSize = function(size, object) {
2084
+ return fitSize(albersUk, size, object);
2085
+ };
2086
+ function reset() {
2087
+ cache = cacheStream = null;
2088
+ return albersUk;
2089
+ }
2090
+ albersUk.drawCompositionBorders = function(context) {
2091
+ var ul, ur, ld, ll;
2092
+ ul = main2([-1.113205870242365, 59.64920050773357]);
2093
+ ur = main2([0.807899092399606, 59.59085836472269]);
2094
+ ld = main2([0.5778611961420386, 57.93467822832577]);
2095
+ ll = main2([-1.25867782078448, 57.99029450085142]);
2096
+ context.moveTo(ul[0], ul[1]);
2097
+ context.lineTo(ur[0], ur[1]);
2098
+ context.lineTo(ld[0], ld[1]);
2099
+ context.lineTo(ll[0], ll[1]);
2100
+ context.closePath();
2101
+ };
2102
+ albersUk.getCompositionBorders = function() {
2103
+ var context = path$2();
2104
+ this.drawCompositionBorders(context);
2105
+ return context.toString();
2106
+ };
2107
+ return albersUk.scale(2800);
2108
+ }
2109
+ function bboxFeature(bounds) {
2110
+ const minLon = bounds[0][0];
2111
+ const minLat = bounds[0][1];
2112
+ const maxLon = bounds[1][0];
2113
+ const maxLat = bounds[1][1];
2114
+ const feature = {
2115
+ type: "Feature",
2116
+ properties: {},
2117
+ geometry: {
2118
+ coordinates: [[[minLon, maxLat], [maxLon, maxLat], [maxLon, minLat], [minLon, minLat], [minLon, maxLat]]],
2119
+ type: "Polygon"
2120
+ }
2121
+ };
2122
+ return feature;
2123
+ }
2124
+ const MapContext = preact.createContext();
2125
+ function SVGMapProvider({
2126
+ id,
2127
+ mapRef,
2128
+ width,
2129
+ height,
2130
+ padding,
2131
+ config,
2132
+ zoom,
2133
+ selectedFeature,
2134
+ children
2135
+ }) {
2136
+ const contentSize = hooks.useMemo(() => ({
2137
+ width: width - padding.left - padding.right,
2138
+ height: height - padding.top - padding.bottom
2139
+ }), [width, height, padding]);
2140
+ const projection = hooks.useMemo(() => {
2141
+ return config.projection.fitSize([contentSize.width, contentSize.height], bboxFeature(config.bounds));
2142
+ }, [contentSize, config]);
2143
+ const path2 = d3Geo.geoPath().projection(projection);
2144
+ const context = {
2145
+ id,
2146
+ mapRef,
2147
+ projection,
2148
+ config,
2149
+ path: path2,
2150
+ size: {
2151
+ width,
2152
+ height
2153
+ },
2154
+ contentSize,
2155
+ padding,
2156
+ zoom,
2157
+ extent: [[0, 0], [width, height]],
2158
+ selectedFeature
2159
+ };
2160
+ return jsxRuntime.jsx(MapContext.Provider, {
2161
+ value: context,
2162
+ children
2163
+ });
2164
+ }
2165
+ const path$1 = "_path_1cwd5_9";
2166
+ const defaultStyles$3 = {
2167
+ path: path$1
2168
+ };
2169
+ function CompositionBorders({
2170
+ styles: styles2
2171
+ }) {
2172
+ const {
2173
+ projection
2174
+ } = hooks.useContext(MapContext);
2175
+ styles2 = mergeStyles(defaultStyles$3, styles2);
2176
+ return jsxRuntime.jsx("path", {
2177
+ className: styles2.path,
2178
+ d: projection.getCompositionBorders()
2179
+ });
2180
+ }
2181
+ function SVGRenderer({
2182
+ children
2183
+ }) {
2184
+ const {
2185
+ id,
2186
+ mapRef,
2187
+ config,
2188
+ size,
2189
+ selectedFeature,
2190
+ padding
2191
+ } = hooks.useContext(MapContext);
2192
+ return jsxRuntime.jsx("svg", {
2193
+ id,
2194
+ ref: mapRef,
2195
+ width: size.width,
2196
+ height: size.height,
2197
+ viewBox: `0 0 ${size.width} ${size.height}`,
2198
+ xmlns: "http://www.w3.org/2000/svg",
2199
+ onClick: () => {
2200
+ if (selectedFeature) {
2201
+ selectedFeature.value = null;
2202
+ }
2203
+ },
2204
+ children: jsxRuntime.jsxs("g", {
2205
+ transform: `translate(${padding.left} ${padding.top})`,
2206
+ children: [jsxRuntime.jsx("g", {
2207
+ children
2208
+ }), config.drawCompositionBorders && Object.prototype.hasOwnProperty.call(config.projection, "getCompositionBorders") && jsxRuntime.jsx(CompositionBorders, {})]
2209
+ })
2210
+ });
2211
+ }
2212
+ function useContainerSize(containerRef) {
2213
+ const windowSize = useWindowSize();
2214
+ const [containerSize, setContainerSize] = hooks.useState();
2215
+ hooks.useLayoutEffect(() => {
2216
+ const container2 = containerRef.current;
2217
+ if (!container2)
2218
+ return;
2219
+ setContainerSize({
2220
+ width: container2.clientWidth,
2221
+ height: container2.clientHeight
2222
+ });
2223
+ }, [containerRef, windowSize]);
2224
+ return containerSize;
2225
+ }
2226
+ const container$1 = "_container_cyrny_1";
2227
+ const svg$1 = "_svg_cyrny_6";
2228
+ const styles$3 = {
2229
+ container: container$1,
2230
+ svg: svg$1
2231
+ };
2232
+ function dynamicPropValue(prop, d2, index2) {
2233
+ if (typeof prop === "function") {
2234
+ return prop(d2, index2);
2235
+ }
2236
+ return prop;
2237
+ }
2238
+ function Polygon({
2239
+ id,
2240
+ features,
2241
+ fill = null,
2242
+ stroke = null,
2243
+ strokeWidth = 1,
2244
+ styles: styles2
2245
+ }) {
2246
+ const context = hooks.useContext(MapContext);
2247
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
2248
+ children: features.map((d2, index2) => {
2249
+ return jsxRuntime.jsx("path", {
2250
+ id: dynamicPropValue(id, d2, index2),
2251
+ className: dynamicPropValue(styles2, d2, index2),
2252
+ fill: dynamicPropValue(fill, d2, index2),
2253
+ stroke: dynamicPropValue(stroke, d2, index2),
2254
+ "stroke-width": dynamicPropValue(strokeWidth, d2, index2),
2255
+ d: context.path(d2)
2256
+ }, index2);
2257
+ })
2258
+ });
2259
+ }
2260
+ function Line({
2261
+ id,
2262
+ features,
2263
+ stroke = null,
2264
+ strokeWidth = 1,
2265
+ styles: styles2
2266
+ }) {
2267
+ const context = hooks.useContext(MapContext);
2268
+ const draw = (ctx, path2) => {
2269
+ for (const feature of features) {
2270
+ ctx.beginPath();
2271
+ ctx.lineWidth = strokeWidth / context.pixelRatio;
2272
+ ctx.strokeStyle = stroke;
2273
+ path2(feature);
2274
+ ctx.stroke();
2275
+ }
2276
+ };
2277
+ hooks.useEffect(() => {
2278
+ if (context.config.drawToCanvas) {
2279
+ context.register(draw);
2280
+ }
2281
+ return () => {
2282
+ if (context.config.drawToCanvas) {
2283
+ context.unregister(draw);
2284
+ }
2285
+ };
2286
+ }, []);
2287
+ if (context.config.drawToCanvas) {
2288
+ return "<!--Line layer-->";
2289
+ }
2290
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
2291
+ children: features.map((d2, index2) => {
2292
+ const initialStrokeWidth = dynamicPropValue(strokeWidth, d2, index2);
2293
+ const scaledStrokeWidth = initialStrokeWidth / context.zoomScale;
2294
+ return jsxRuntime.jsx("path", {
2295
+ id: dynamicPropValue(id, d2, index2),
2296
+ stroke: dynamicPropValue(stroke, d2, index2),
2297
+ "stroke-line-join": "round",
2298
+ "stroke-width": scaledStrokeWidth,
2299
+ fill: "none",
2300
+ className: dynamicPropValue(styles2, d2, index2),
2301
+ d: context.path(d2)
2302
+ }, index2);
2303
+ })
2304
+ });
2305
+ }
2306
+ function Prerendered({
2307
+ url
2308
+ }) {
2309
+ const context = hooks.useContext(MapContext);
2310
+ const {
2311
+ width,
2312
+ height
2313
+ } = context.contentSize;
2314
+ return jsxRuntime.jsx("image", {
2315
+ width,
2316
+ height,
2317
+ href: url
2318
+ });
2319
+ }
2320
+ function Point({
2321
+ id,
2322
+ features,
2323
+ radius = 4,
2324
+ fill = null,
2325
+ stroke = null,
2326
+ strokeWidth = 1,
2327
+ styles: styles2
2328
+ }) {
2329
+ const context = hooks.useContext(MapContext);
2330
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
2331
+ children: features.map((d2, index2) => {
2332
+ const [cx, cy] = context.projection(d2.geometry.coordinates);
2333
+ return jsxRuntime.jsx("circle", {
2334
+ id: dynamicPropValue(id, d2, index2),
2335
+ cx,
2336
+ cy,
2337
+ r: dynamicPropValue(radius, d2, index2),
2338
+ className: dynamicPropValue(styles2, d2, index2),
2339
+ fill: dynamicPropValue(fill, d2, index2),
2340
+ stroke: dynamicPropValue(stroke, d2, index2),
2341
+ strokeWidth: dynamicPropValue(strokeWidth, d2, index2)
2342
+ }, index2);
2343
+ })
2344
+ });
2345
+ }
2346
+ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2347
+ __proto__: null,
2348
+ CompositionBorders,
2349
+ Line,
2350
+ Point,
2351
+ Polygon,
2352
+ Prerendered
2353
+ }, Symbol.toStringTag, { value: "Module" }));
2354
+ const Projection = {
2355
+ geoAlbersUKComposite: geoAlbersUk(),
2356
+ geoAlbersEngland: d3Geo.geoAlbers().center([0, 52.7]).rotate([1.1743, 0]).parallels([50, 54]),
2357
+ geoMercator: d3Geo.geoMercator()
2358
+ };
2359
+ const MapConfiguration = {
2360
+ UKComposite: {
2361
+ projection: Projection.geoAlbersUKComposite,
2362
+ bounds: [[-8.642194417322951, 49.88234469492934], [1.7683086664999994, 60.8456995072]],
2363
+ drawCompositionBorders: true,
2364
+ drawToCanvas: false
2365
+ },
2366
+ England: {
2367
+ projection: Projection.geoAlbersEngland,
2368
+ bounds: [[-6.41866730264044, 49.8647926027119], [1.76370537625026, 55.8111151140706]],
2369
+ drawCompositionBorders: false,
2370
+ drawToCanvas: false
2371
+ },
2372
+ London: {
2373
+ projection: d3Geo.geoMercator(),
2374
+ bounds: [[-0.510356073504132, 51.2867586289553], [0.334043866981608, 51.6918768002741]],
2375
+ drawCompositionBorders: false,
2376
+ drawToCanvas: false
2377
+ }
2378
+ };
2379
+ const ZERO_PADDING = {
2380
+ top: 0,
2381
+ right: 0,
2382
+ bottom: 0,
2383
+ left: 0
2384
+ };
2385
+ const DEFAULT_ZOOM = {
2386
+ enabled: false,
2387
+ minZoom: 1,
2388
+ maxZoom: 8
2389
+ };
2390
+ const Map$1 = compat.forwardRef(({
2391
+ id,
2392
+ width,
2393
+ height,
2394
+ config,
2395
+ children,
2396
+ padding = {
2397
+ top: 20,
2398
+ right: 20,
2399
+ bottom: 20,
2400
+ left: 20
2401
+ },
2402
+ zoom,
2403
+ selectedFeature
2404
+ }, ref) => {
2405
+ padding = padding || ZERO_PADDING;
2406
+ zoom = Object.assign(DEFAULT_ZOOM, zoom);
2407
+ const containerRef = hooks.useRef();
2408
+ const [isReady, setIsReady] = hooks.useState(false);
2409
+ hooks.useLayoutEffect(() => {
2410
+ if (!isReady) {
2411
+ setIsReady(true);
2412
+ }
2413
+ }, [isReady]);
2414
+ hooks.useImperativeHandle(
2415
+ ref,
2416
+ () => ({
2417
+ isReady,
2418
+ getContainer: () => containerRef.current,
2419
+ findFeatureAtPoint
2420
+ }),
2421
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2422
+ [isReady]
2423
+ );
2424
+ function findFeatureAtPoint({
2425
+ x,
2426
+ y
2427
+ }) {
2428
+ const adjustedPoint = [x - padding.left, y - padding.top];
2429
+ const coordinates = config.projection.invert(adjustedPoint);
2430
+ for (const child of preact.toChildArray(children)) {
2431
+ if (Object.prototype.hasOwnProperty.call(child.props, "features")) {
2432
+ const features = child.props.features;
2433
+ for (const feature of features) {
2434
+ if (d3Geo.geoContains(feature, coordinates)) {
2435
+ return feature;
2436
+ }
2437
+ }
2438
+ }
2439
+ }
2440
+ return null;
2441
+ }
2442
+ const containerSize = useContainerSize(containerRef);
2443
+ const containerStyle = hooks.useMemo(() => {
2444
+ const style = {};
2445
+ if (width > 0)
2446
+ style["width"] = width;
2447
+ if (height > 0)
2448
+ style["height"] = height;
2449
+ return style;
2450
+ }, [width, height]);
2451
+ const mapRef = hooks.useRef();
2452
+ const renderSVG = containerSize && !config.drawToCanvas;
2453
+ return jsxRuntime.jsx("div", {
2454
+ ref: containerRef,
2455
+ className: styles$3.container,
2456
+ style: containerStyle,
2457
+ children: renderSVG && jsxRuntime.jsx(SVGMapProvider, {
2458
+ id,
2459
+ width: containerSize.width,
2460
+ height: containerSize.height,
2461
+ padding,
2462
+ config,
2463
+ mapRef,
2464
+ selectedFeature,
2465
+ zoom,
2466
+ children: jsxRuntime.jsx(SVGRenderer, {
2467
+ children
2468
+ })
2469
+ })
2470
+ });
2471
+ });
2472
+ const container = "_container_azu4a_1";
2473
+ const paragraph = "_paragraph_azu4a_12";
2474
+ const defaultStyles$2 = {
2475
+ container,
2476
+ paragraph
2477
+ };
2478
+ function ResultSummary({
2479
+ previous: previous2,
2480
+ next: next2,
2481
+ title: title2,
2482
+ text: text2,
2483
+ timestamp,
2484
+ styles: styles2
2485
+ }) {
2486
+ styles2 = mergeStyles({
2487
+ ...defaultStyles$2
2488
+ }, styles2);
2489
+ return jsxRuntime.jsxs("div", {
2490
+ class: styles2.container,
2491
+ children: [jsxRuntime.jsx(ControlChange, {
2492
+ previous: previous2,
2493
+ next: next2,
2494
+ text: title2
2495
+ }), jsxRuntime.jsx("p", {
2496
+ className: styles2.paragraph,
2497
+ children: text2
2498
+ }), jsxRuntime.jsx(RelativeTimeSentence, {
2499
+ timeStamp: timestamp
2500
+ })]
2501
+ });
2502
+ }
2503
+ const svg = "_svg_1dms8_1";
2504
+ const path = "_path_1dms8_8";
2505
+ const styles$2 = {
2506
+ svg,
2507
+ path
2508
+ };
2509
+ function SearchIcon() {
2510
+ return jsxRuntime.jsx("svg", {
2511
+ viewBox: "0 0 20 20",
2512
+ xmlns: "http://www.w3.org/2000/svg",
2513
+ className: styles$2.svg,
2514
+ children: jsxRuntime.jsx("path", {
2515
+ className: styles$2.path,
2516
+ "fill-rule": "evenodd",
2517
+ "clip-rule": "evenodd",
2518
+ d: "M7.273 0c4.022 0 7.25 3.295 7.25 7.273a7.226 7.226 0 01-7.25 7.25C3.25 14.523 0 11.295 0 7.273 0 3.295 3.25 0 7.273 0zm0 1.84A5.403 5.403 0 001.84 7.274c0 3 2.409 5.454 5.432 5.454 3 0 5.454-2.454 5.454-5.454 0-3.023-2.454-5.432-5.454-5.432zM20 18.16l-5.432-5.432h-.932l-.909.91v.931L18.16 20 20 18.159z"
2519
+ })
2520
+ });
2521
+ }
2522
+ const searchContainer = "_searchContainer_g5w44_1";
2523
+ const input = "_input_g5w44_5";
2524
+ const searchIcon = "_searchIcon_g5w44_21";
2525
+ const clearButton = "_clearButton_g5w44_30";
2526
+ const suggestions = "_suggestions_g5w44_36";
2527
+ const suggestion = "_suggestion_g5w44_36";
2528
+ const selected = "_selected_g5w44_59";
2529
+ const highlighted = "_highlighted_g5w44_63";
2530
+ const defaultStyles$1 = {
2531
+ searchContainer,
2532
+ input,
2533
+ searchIcon,
2534
+ clearButton,
2535
+ suggestions,
2536
+ suggestion,
2537
+ selected,
2538
+ highlighted
2539
+ };
2540
+ function SearchInput({
2541
+ placeholder,
2542
+ inputValue,
2543
+ maxSuggestions = 5,
2544
+ onInputChange,
2545
+ onSubmit,
2546
+ onSelect,
2547
+ onClear,
2548
+ styles: styles2
2549
+ }) {
2550
+ var _a, _b, _c;
2551
+ styles2 = mergeStyles(defaultStyles$1, styles2);
2552
+ const inputRef = hooks.useRef(null);
2553
+ const [selectedIndex, setSelectedIndex] = hooks.useState(-1);
2554
+ const [suggestions2, setSuggestions] = hooks.useState();
2555
+ const [showSuggestions, setShowSuggestions] = hooks.useState(true);
2556
+ function onKeyDown(event) {
2557
+ if (event.key === "ArrowDown") {
2558
+ event.preventDefault();
2559
+ setSelectedIndex((currentIndex) => Math.min(currentIndex + 1, suggestions2.length - 1));
2560
+ } else if (event.key === "ArrowUp") {
2561
+ event.preventDefault();
2562
+ setSelectedIndex((currentIndex) => Math.max(currentIndex - 1, -1));
2563
+ } else if (event.key === "Enter" && selectedIndex >= 0) {
2564
+ event.preventDefault();
2565
+ onSelectSuggestion(suggestions2[selectedIndex]);
2566
+ } else if (event.key === "Enter") {
2567
+ onSubmit(inputRef.current.value);
2568
+ }
2569
+ }
2570
+ async function inputChanged(input2) {
2571
+ let suggestions22 = await onInputChange(input2);
2572
+ if (suggestions22) {
2573
+ suggestions22 = suggestions22.slice(0, maxSuggestions);
2574
+ }
2575
+ setSuggestions(suggestions22);
2576
+ setSelectedIndex(-1);
2577
+ }
2578
+ function onSelectSuggestion(suggestion2) {
2579
+ onSelect(suggestion2);
2580
+ inputRef.current.value = suggestion2.text;
2581
+ inputRef.current.blur();
2582
+ }
2583
+ const showClearButton = ((_a = inputRef.current) == null ? void 0 : _a.value) && ((_b = inputRef.current) == null ? void 0 : _b.value) !== "";
2584
+ return jsxRuntime.jsxs("div", {
2585
+ className: styles2.searchContainer,
2586
+ children: [jsxRuntime.jsx("input", {
2587
+ name: "search",
2588
+ placeholder,
2589
+ ref: inputRef,
2590
+ type: "text",
2591
+ "aria-label": "Search input",
2592
+ value: inputValue,
2593
+ onKeyDown,
2594
+ onInput: (e) => {
2595
+ inputChanged(e.target.value);
2596
+ },
2597
+ onBlur: () => {
2598
+ setShowSuggestions(false);
2599
+ },
2600
+ onFocus: (e) => {
2601
+ e.target.select();
2602
+ setShowSuggestions(true);
2603
+ },
2604
+ className: styles2.input
2605
+ }), jsxRuntime.jsx("div", {
2606
+ className: styles2.searchIcon,
2607
+ children: jsxRuntime.jsx(SearchIcon, {})
2608
+ }), showClearButton && jsxRuntime.jsx("div", {
2609
+ className: styles2.clearButton,
2610
+ children: jsxRuntime.jsx(CloseButton, {
2611
+ border: false,
2612
+ onClick: () => {
2613
+ const emptyValue = "";
2614
+ inputRef.current.value = emptyValue;
2615
+ inputChanged(emptyValue);
2616
+ inputRef.current.focus();
2617
+ onClear();
2618
+ }
2619
+ })
2620
+ }), showSuggestions && jsxRuntime.jsx(SuggestionList, {
2621
+ suggestions: suggestions2,
2622
+ highlightText: (_c = inputRef.current) == null ? void 0 : _c.value,
2623
+ selectedIndex,
2624
+ styles: styles2,
2625
+ onMouseOver: (_2, index2) => setSelectedIndex(index2),
2626
+ onSelect: onSelectSuggestion
2627
+ })]
2628
+ });
2629
+ }
2630
+ function SuggestionList({
2631
+ suggestions: suggestions2,
2632
+ highlightText,
2633
+ selectedIndex,
2634
+ styles: styles2,
2635
+ onMouseOver,
2636
+ onSelect
2637
+ }) {
2638
+ if (!suggestions2 || suggestions2.length === 0)
2639
+ return;
2640
+ return jsxRuntime.jsx("ul", {
2641
+ className: styles2.suggestions,
2642
+ "aria-label": "Search suggestions",
2643
+ children: suggestions2.map((d2, index2) => {
2644
+ return jsxRuntime.jsx("li", {
2645
+ "aria-label": d2.text,
2646
+ className: [styles2.suggestion, index2 === selectedIndex && styles2.selected].join(" "),
2647
+ onMouseDown: (e) => e.preventDefault(),
2648
+ onMouseOver: () => onMouseOver(d2, index2),
2649
+ onClick: () => {
2650
+ onSelect(d2);
2651
+ },
2652
+ children: d2.text.split(new RegExp(`(${highlightText})`, "ig")).map((part, i) => i % 2 === 1 ? jsxRuntime.jsx("span", {
2653
+ className: styles2.highlighted,
2654
+ children: part
2655
+ }, i) : part)
2656
+ }, index2);
2657
+ })
2658
+ });
2659
+ }
2660
+ const coalitionsWrapper = "_coalitionsWrapper_1ahqy_9";
2661
+ const coalitionsContainer = "_coalitionsContainer_1ahqy_14";
2662
+ const coalition = "_coalition_1ahqy_9";
2663
+ const title = "_title_1ahqy_27";
2664
+ const description = "_description_1ahqy_28";
2665
+ const thresholdText = "_thresholdText_1ahqy_43";
2666
+ const thresholdTextBold = "_thresholdTextBold_1ahqy_54";
2667
+ const thresholdDot = "_thresholdDot_1ahqy_61";
2668
+ const thresholdLine = "_thresholdLine_1ahqy_61";
2669
+ const defaultStyles = {
2670
+ coalitionsWrapper,
2671
+ coalitionsContainer,
2672
+ coalition,
2673
+ title,
2674
+ description,
2675
+ thresholdText,
2676
+ thresholdTextBold,
2677
+ thresholdDot,
2678
+ thresholdLine
2679
+ };
2680
+ function CoalitionsTracker({
2681
+ coalitions,
2682
+ threshold,
2683
+ barChartHeight = 32,
2684
+ listMembersAccessor = "parties",
2685
+ listMemberTotalAccessor = "totalSeats",
2686
+ listDescriptionAccessor = "description",
2687
+ abbreviationAccessor = "abbreviation",
2688
+ thresholdTextBold: thresholdTextBold2,
2689
+ thresholdText: thresholdText2,
2690
+ styles: styles2
2691
+ }) {
2692
+ const wrapperRef = hooks.useRef(null);
2693
+ const thresholdTextRef = hooks.useRef(null);
2694
+ const [width, setWidth] = hooks.useState(0);
2695
+ const biggestListTotal = Math.max(...coalitions.map((l) => l[listMembersAccessor].reduce((acc, cur) => acc + cur[listMemberTotalAccessor], 0)));
2696
+ const windowSize = useWindowSize();
2697
+ const thresholdTextMinWidth = windowSize.width < 740 ? 66 : 150;
2698
+ const thresholdDotWidth = 11;
2699
+ const thresholdTextPaddingLeft = 5;
2700
+ const maxBarWidth = width - thresholdTextMinWidth - (thresholdDotWidth - 1) / 2 - thresholdTextPaddingLeft;
2701
+ const thresholdLeft = threshold / biggestListTotal * maxBarWidth;
2702
+ const parsedLists = coalitions.map((coalition2) => {
2703
+ const listTotal = coalition2[listMembersAccessor].reduce((acc, cur) => acc + cur[listMemberTotalAccessor], 0);
2704
+ return {
2705
+ title: coalition2["name"],
2706
+ description: coalition2[listDescriptionAccessor],
2707
+ height: barChartHeight,
2708
+ width: listTotal / biggestListTotal * maxBarWidth,
2709
+ stack: coalition2[listMembersAccessor].map((m) => {
2710
+ const listTotal2 = coalition2[listMembersAccessor].reduce((acc, cur) => acc + cur[listMemberTotalAccessor], 0);
2711
+ return {
2712
+ label: m[listMemberTotalAccessor],
2713
+ fraction: m[listMemberTotalAccessor] / listTotal2,
2714
+ abbreviation: m[abbreviationAccessor]
2715
+ };
2716
+ }).sort((a, b) => b.fraction - a.fraction)
2717
+ };
2718
+ });
2719
+ styles2 = mergeStyles(defaultStyles, styles2);
2720
+ hooks.useLayoutEffect(() => {
2721
+ const newWidth = wrapperRef.current.getBoundingClientRect().width;
2722
+ setWidth(newWidth);
2723
+ }, [windowSize]);
2724
+ const renderCoalition = (list, index2) => {
2725
+ if (list.width <= 0) {
2726
+ return;
2727
+ }
2728
+ return jsxRuntime.jsxs("div", {
2729
+ className: styles2.coalition,
2730
+ style: {
2731
+ position: "relative",
2732
+ zIndex: 2
2733
+ },
2734
+ children: [jsxRuntime.jsx("h4", {
2735
+ className: styles2.title,
2736
+ children: list.title
2737
+ }), jsxRuntime.jsx("p", {
2738
+ className: styles2.description,
2739
+ style: {
2740
+ maxWidth: thresholdLeft <= 620 ? thresholdLeft - 8 : 620
2741
+ },
2742
+ children: list.description
2743
+ }), jsxRuntime.jsx(StackedBar, {
2744
+ stack: list.stack,
2745
+ width: list.width,
2746
+ height: barChartHeight,
2747
+ createSVG: true
2748
+ })]
2749
+ }, index2);
2750
+ };
2751
+ return jsxRuntime.jsxs("div", {
2752
+ ref: wrapperRef,
2753
+ className: styles2.coalitionsWrapper,
2754
+ children: [jsxRuntime.jsx("div", {
2755
+ className: styles2.coalitionsContainer,
2756
+ children: parsedLists.map(renderCoalition)
2757
+ }), jsxRuntime.jsx("div", {
2758
+ className: styles2.thresholdDot,
2759
+ style: {
2760
+ position: "absolute",
2761
+ height: thresholdDotWidth,
2762
+ width: thresholdDotWidth,
2763
+ top: 0,
2764
+ left: 0.5 + thresholdLeft - thresholdDotWidth / 2
2765
+ }
2766
+ }), jsxRuntime.jsx("div", {
2767
+ className: styles2.thresholdLine,
2768
+ style: {
2769
+ position: "absolute",
2770
+ height: "100%",
2771
+ width: 1,
2772
+ top: 0,
2773
+ left: thresholdLeft
2774
+ }
2775
+ }), jsxRuntime.jsxs("div", {
2776
+ ref: thresholdTextRef,
2777
+ className: styles2.thresholdText,
2778
+ style: {
2779
+ position: "absolute",
2780
+ minWidth: thresholdTextMinWidth,
2781
+ width: "auto",
2782
+ top: -(thresholdDotWidth + 1) / 2,
2783
+ left: thresholdLeft + (thresholdDotWidth - 1) / 2 + thresholdTextPaddingLeft
2784
+ },
2785
+ children: [thresholdTextBold2 && jsxRuntime.jsx("span", {
2786
+ className: styles2.thresholdTextBold,
2787
+ children: thresholdTextBold2
2788
+ }), thresholdText2 && jsxRuntime.jsx("span", {
2789
+ children: thresholdText2
2790
+ })]
2791
+ })]
2792
+ });
2793
+ }
2794
+ const gradient$1 = "_gradient_plpaq_9";
2795
+ const firstStop = "_firstStop_plpaq_24";
2796
+ const lastStop = "_lastStop_plpaq_29";
2797
+ const styles$1 = {
2798
+ gradient: gradient$1,
2799
+ firstStop,
2800
+ lastStop
2801
+ };
2802
+ function Gradient() {
2803
+ return jsxRuntime.jsxs("svg", {
2804
+ width: "100%",
2805
+ height: "100%",
2806
+ viewBox: "0 0 10 10",
2807
+ fill: "none",
2808
+ xmlns: "http://www.w3.org/2000/svg",
2809
+ preserveAspectRatio: "none",
2810
+ children: [jsxRuntime.jsx("g", {
2811
+ className: styles$1.gradient,
2812
+ children: jsxRuntime.jsx("rect", {
2813
+ fill: "url(#paint0_linear_3798_6653)"
2814
+ })
2815
+ }), jsxRuntime.jsx("defs", {
2816
+ children: jsxRuntime.jsxs("linearGradient", {
2817
+ id: "paint0_linear_3798_6653",
2818
+ x1: "0%",
2819
+ y1: "0%",
2820
+ x2: "100%",
2821
+ y2: "0%",
2822
+ children: [jsxRuntime.jsx("stop", {
2823
+ className: styles$1.firstStop
2824
+ }), jsxRuntime.jsx("stop", {
2825
+ className: styles$1.lastStop,
2826
+ offset: "1"
2827
+ })]
2828
+ })
2829
+ })]
2830
+ });
2831
+ }
2832
+ const ticker = "_ticker_1tpek_9";
2833
+ const tickerItems = "_tickerItems_1tpek_19";
2834
+ const tickerItem = "_tickerItem_1tpek_19";
2835
+ const controls = "_controls_1tpek_41";
2836
+ const gradient = "_gradient_1tpek_56";
2837
+ const buttons = "_buttons_1tpek_70";
2838
+ const button = "_button_1tpek_70";
2839
+ const buttonInner = "_buttonInner_1tpek_96";
2840
+ const styles = {
2841
+ ticker,
2842
+ tickerItems,
2843
+ tickerItem,
2844
+ controls,
2845
+ gradient,
2846
+ buttons,
2847
+ button,
2848
+ buttonInner
2849
+ };
2850
+ function totalSizeForElements(elements) {
2851
+ return Array.from(elements).reduce((totalSize, element) => {
2852
+ totalSize.width += element.clientWidth;
2853
+ totalSize.height += element.clientHeight;
2854
+ return totalSize;
2855
+ }, {
2856
+ width: 0,
2857
+ height: 0
2858
+ });
2859
+ }
2860
+ function Ticker({
2861
+ maxItems = 20,
2862
+ onStateChange,
2863
+ children
2864
+ }) {
2865
+ const [offset, setOffset] = hooks.useState(0);
2866
+ const windowSize = useWindowSize();
2867
+ const tickerRef = hooks.useRef();
2868
+ const tickerItemsRef = hooks.useRef();
2869
+ const [hideButtons, setHideButtons] = hooks.useState(false);
2870
+ const [nextButtonDisabled, setNextButtonDisabled] = hooks.useState(false);
2871
+ const [expanded, setExpanded] = hooks.useState(false);
2872
+ const childArray = preact.toChildArray(children);
2873
+ hooks.useLayoutEffect(() => {
2874
+ const tickerItemsContainer = tickerItemsRef.current;
2875
+ if (tickerItemsContainer) {
2876
+ const {
2877
+ width,
2878
+ height
2879
+ } = totalSizeForElements(tickerItemsContainer.children);
2880
+ const hideButtons2 = windowSize.width >= 480 ? width <= tickerItemsContainer.clientWidth : height <= tickerItemsContainer.clientHeight;
2881
+ setHideButtons(hideButtons2);
2882
+ if (tickerItemsContainer.children.length > 0) {
2883
+ const itemWidth = tickerItemsContainer.children[0].clientWidth;
2884
+ const nextButtonDisabled2 = offset * itemWidth > width - tickerItemsContainer.clientWidth;
2885
+ setNextButtonDisabled(nextButtonDisabled2);
2886
+ }
2887
+ }
2888
+ }, [offset, windowSize, childArray, setHideButtons, setNextButtonDisabled]);
2889
+ function toggleExpandedState() {
2890
+ setExpanded((expanded2) => {
2891
+ const newState = !expanded2;
2892
+ if (onStateChange)
2893
+ onStateChange({
2894
+ expanded: newState
2895
+ });
2896
+ return newState;
2897
+ });
2898
+ }
2899
+ return jsxRuntime.jsxs("div", {
2900
+ ref: tickerRef,
2901
+ className: styles.ticker,
2902
+ style: `--ticker-offset: ${offset}`,
2903
+ "data-expanded": expanded,
2904
+ children: [jsxRuntime.jsx("div", {
2905
+ ref: tickerItemsRef,
2906
+ className: styles.tickerItems,
2907
+ children: childArray.map((child, index2) => jsxRuntime.jsx("div", {
2908
+ className: styles.tickerItem,
2909
+ children: child
2910
+ }, index2))
2911
+ }), jsxRuntime.jsxs("div", {
2912
+ className: styles.controls,
2913
+ style: hideButtons && {
2914
+ display: "none"
2915
+ },
2916
+ children: [jsxRuntime.jsx("div", {
2917
+ className: styles.gradient,
2918
+ children: jsxRuntime.jsx(Gradient, {})
2919
+ }), jsxRuntime.jsxs("div", {
2920
+ className: styles.buttons,
2921
+ children: [jsxRuntime.jsx(ArrowButton, {
2922
+ onClick: () => setOffset((d2) => d2 + 1),
2923
+ disabled: nextButtonDisabled
2924
+ }), jsxRuntime.jsx(ArrowButton, {
2925
+ direction: "left",
2926
+ onClick: () => setOffset((d2) => d2 - 1),
2927
+ disabled: offset <= 0
2928
+ })]
2929
+ }), jsxRuntime.jsx("div", {
2930
+ className: styles.button,
2931
+ children: jsxRuntime.jsx(Button, {
2932
+ type: "small",
2933
+ styles: {
2934
+ buttonInner: styles.buttonInner
2935
+ },
2936
+ onClick: toggleExpandedState,
2937
+ children: expanded ? "Show less" : `Show ${maxItems} most recent`
2938
+ })
2939
+ })]
2940
+ })]
2941
+ });
2942
+ }
2943
+ exports2.ArrowButton = ArrowButton;
2944
+ exports2.Button = Button;
2945
+ exports2.ChangeBar = ChangeBar;
2946
+ exports2.Chevron = Chevron;
2947
+ exports2.CircleIcon = CircleIcon;
2948
+ exports2.CloseButton = CloseButton;
2949
+ exports2.CoalitionsTracker = CoalitionsTracker;
2950
+ exports2.ColumnChart = ColumnChart;
2951
+ exports2.Container = Container;
2952
+ exports2.ControlChange = ControlChange;
2953
+ exports2.GradientIcon = GradientIcon;
2954
+ exports2.InfoButton = InfoButton;
2955
+ exports2.LegendItem = LegendItem;
2956
+ exports2.Map = Map$1;
2957
+ exports2.MapConfiguration = MapConfiguration;
2958
+ exports2.MapLayers = index;
2959
+ exports2.PageSection = PageSection;
2960
+ exports2.PartyProfile = PartyProfile;
2961
+ exports2.Projection = Projection;
2962
+ exports2.RelativeTimeSentence = RelativeTimeSentence;
2963
+ exports2.ResultSummary = ResultSummary;
2964
+ exports2.SearchInput = SearchInput;
2965
+ exports2.SlopeChart = SlopeChart;
2966
+ exports2.SquareCutCornerIcon = SquareCutCornerIcon;
2967
+ exports2.SquareIcon = SquareIcon;
2968
+ exports2.StackedBar = StackedBar;
2969
+ exports2.StackedGrid = StackedGrid;
2970
+ exports2.Table = Table;
2971
+ exports2.Ticker = Ticker;
2972
+ exports2.Tooltip = Tooltip;
2973
+ exports2.TooltipType = TooltipType;
2974
+ exports2.ToplineResult = ToplineResult;
2975
+ Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
2976
+ });
2977
+ //# sourceMappingURL=interactive-component-library.umd.cjs.map