@graphysdk/theme-botanical 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,1123 @@
1
+ import { useId as Ct, useMemo as I } from "react";
2
+ import { DefaultGeomCircle as Ht, GROUP_VARIABLES as At, createAreaPathGenerators as It, createStableCellKeyGenerator as Rt, createStableKeyGenerator as O, defineGeomRenderer as W, getAngleExtent as $t, getBarRectBounds as Ot, getPaintedTileRect as Nt, getRadiusExtent as Q, getStackRole as Bt, getX as H, getXMax as Dt, getXMin as Gt, getY as z, getYMax as xt, getYMin as Ft, polarToUnit as kt, prepareAreaObservations as zt, readMainAxis as ot, style as p, toPaintColor as jt, toStrokeDasharray as Kt, toViewBoxX as Vt, toViewBoxY as Ut, useGeomStyleReader as J } from "@graphysdk/react";
3
+ import { jsx as g, jsxs as w } from "react/jsx-runtime";
4
+ var Yt = /[a-df-zA-DF-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/gu, Xt = /^[a-zA-Z]$/u, Zt = (t, e) => t === "H" ? "x" : t === "V" ? "y" : e % 2 === 0 ? "x" : "y", it = (t, e) => {
5
+ let r = "", a = 0;
6
+ return (t.match(Yt) ?? []).map((n) => {
7
+ if (Xt.test(n))
8
+ return r = n.toUpperCase(), a = 0, n;
9
+ const i = Zt(r, a);
10
+ return a += 1, String(Number(n) * (i === "x" ? e.width : e.height));
11
+ }).join(" ");
12
+ }, tt = (t, e) => {
13
+ const r = H(t), a = z(t) ?? xt(t);
14
+ return r === null || a === null ? null : {
15
+ x: Vt(r) * e.width,
16
+ y: Ut(a) * e.height
17
+ };
18
+ }, j = (t, e) => {
19
+ const r = H(t), a = z(t) ?? Q(t).outerRadius;
20
+ if (r === null || a === null) return null;
21
+ const n = kt(r, a), i = Math.min(e.width, e.height) / 2;
22
+ return {
23
+ x: e.width / 2 + n.x * i,
24
+ y: e.height / 2 - n.y * i
25
+ };
26
+ }, qt = (t) => `${t.map((e, r) => `${r === 0 ? "M" : "L"}${e.x},${e.y}`).join(" ")} Z`, T = (t) => {
27
+ let e = 2166136261;
28
+ for (let r = 0; r < t.length; r += 1)
29
+ e ^= t.charCodeAt(r), e = Math.imul(e, 16777619);
30
+ return e >>> 0;
31
+ }, N = (t) => {
32
+ let e = t || 1;
33
+ return () => {
34
+ e = e + 1831565813 | 0;
35
+ let r = Math.imul(e ^ e >>> 15, 1 | e);
36
+ return r = r + Math.imul(r ^ r >>> 7, 61 | r) ^ r, ((r ^ r >>> 14) >>> 0) / 4294967296;
37
+ };
38
+ }, Qt = (t) => {
39
+ const e = [
40
+ 0.035,
41
+ 0.07,
42
+ 0.13
43
+ ].map((a, n) => ({
44
+ frequency: a * (0.7 + t() * 0.6),
45
+ phase: t() * Math.PI * 2,
46
+ weight: 1 / (n + 1)
47
+ })), r = e.reduce((a, n) => a + n.weight, 0);
48
+ return (a) => e.reduce((n, i) => n + i.weight * Math.sin(a * i.frequency + i.phase), 0) / r;
49
+ }, b = (t, { wander: e, seed: r, closed: a = !1, step: n = 9, cornered: i = !1 }) => {
50
+ if (t.length < 2) return "";
51
+ const s = Qt(N(r)), o = a ? [...t, t[0]] : [...t], l = [], c = [];
52
+ let h = 0;
53
+ for (let u = 0; u < o.length - 1; u += 1) {
54
+ const d = o[u], f = o[u + 1], y = Math.hypot(f.x - d.x, f.y - d.y);
55
+ if (y === 0) continue;
56
+ const P = {
57
+ x: -(f.y - d.y) / y,
58
+ y: (f.x - d.x) / y
59
+ }, S = Math.max(1, Math.ceil(y / n)), k = [];
60
+ for (let _ = 0; _ <= S; _ += 1) {
61
+ const M = _ / S, V = e * Math.sin(Math.PI * M) * s(h + M * y);
62
+ k.push({
63
+ x: d.x + (f.x - d.x) * M + P.x * V,
64
+ y: d.y + (f.y - d.y) * M + P.y * V
65
+ });
66
+ }
67
+ c.push(k), l.push(...k.slice(0, -1)), h += y;
68
+ }
69
+ return i ? `${c.map((u) => st(u, !1)).map((u, d) => d === 0 ? u : u.replace(/^M/u, "L")).join(" ")}${a ? " Z" : ""}` : (a || l.push(o[o.length - 1]), st(l, a));
70
+ }, A = (t) => (Math.round(t * 100) / 100).toString(), st = (t, e) => {
71
+ const r = t.length, a = (o) => e ? t[(o + r) % r] : t[Math.max(0, Math.min(r - 1, o))], n = a(0), i = [`M${A(n.x)},${A(n.y)}`], s = e ? r : r - 1;
72
+ for (let o = 0; o < s; o += 1) {
73
+ const [l, c, h, u] = [
74
+ a(o - 1),
75
+ a(o),
76
+ a(o + 1),
77
+ a(o + 2)
78
+ ], d = {
79
+ x: c.x + (h.x - l.x) / 6,
80
+ y: c.y + (h.y - l.y) / 6
81
+ }, f = {
82
+ x: h.x - (u.x - c.x) / 6,
83
+ y: h.y - (u.y - c.y) / 6
84
+ };
85
+ i.push(`C${A(d.x)},${A(d.y)} ${A(f.x)},${A(f.y)} ${A(h.x)},${A(h.y)}`);
86
+ }
87
+ return `${i.join(" ")}${e ? " Z" : ""}`;
88
+ }, Z = (t, e, r, a) => {
89
+ const n = {
90
+ x: Math.cos(a),
91
+ y: Math.sin(a)
92
+ }, i = {
93
+ x: -n.y,
94
+ y: n.x
95
+ }, s = (o, l) => `${A(t.x + n.x * o + i.x * l)},${A(t.y + n.y * o + i.y * l)}`;
96
+ return {
97
+ blade: `M${s(0, 0)} Q${s(e * 0.45, r)} ${s(e, 0)} Q${s(e * 0.55, -r)} ${s(0, 0)} Z`,
98
+ rib: `M${s(0, 0)} L${s(e * 0.8, 0)}`
99
+ };
100
+ }, Et = (t) => `data:image/svg+xml,${encodeURIComponent(t)}`, Jt = (t, e) => Et(`<svg xmlns="http://www.w3.org/2000/svg" width="240" height="240"><filter id="g" x="0" y="0" width="100%" height="100%"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="2" seed="4" stitchTiles="stitch"/><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.6 1.05"/></filter><rect width="240" height="240" fill="${t}"/><rect width="240" height="240" fill="${e}" filter="url(#g)" opacity="0.07"/></svg>`), te = 74, ee = 22, lt = (t, e) => {
101
+ const r = N(e), a = te / 2, n = (i, s) => Array.from({ length: 6 }, (o, l) => {
102
+ const c = -11 + ee * l / 5;
103
+ return `${(i + s * r() * 3).toFixed(1)},${c.toFixed(1)}`;
104
+ });
105
+ return `<polygon points="${[...n(-37, -1), ...n(a, 1).reverse()].join(" ")}" fill="${t}" fill-opacity="0.7" stroke="#B9A776" stroke-opacity="0.35" stroke-width="0.5"/>`;
106
+ }, U = (t, e, r, a) => `<svg x="${t}" y="${e}" width="1" height="1" overflow="visible"><g transform="${a}">${r}</g></svg>`, ht = 150, re = 0.95, ae = (t, e, r) => {
107
+ const a = N(r), n = Array.from({ length: 7 }, (l, c) => {
108
+ const h = c / 6;
109
+ return {
110
+ x: h * ht,
111
+ y: -Math.sin(h * Math.PI * 0.9) * 16 - h * 6
112
+ };
113
+ }), i = b(n, {
114
+ wander: 1.2,
115
+ seed: r
116
+ }), s = n.slice(1, -1).flatMap((l, c) => {
117
+ const h = c % 2 === 0 ? -1 : 1, u = 22 - c * 2.2 + a() * 4, d = -0.35 + h * (0.95 + a() * 0.25), { blade: f, rib: y } = Z(l, u, u * 0.3, d);
118
+ return [`<path d="${f}" fill="${e}" fill-opacity="0.55" stroke="${t}" stroke-width="0.85" stroke-linejoin="round"/>`, `<path d="${y}" fill="none" stroke="${t}" stroke-width="0.55" stroke-opacity="0.7"/>`];
119
+ }), o = Z(n[n.length - 1] ?? {
120
+ x: ht,
121
+ y: 0
122
+ }, 13, 5, -0.2);
123
+ return `<path d="${i}" fill="none" stroke="${t}" stroke-width="1.1" stroke-linecap="round"/>` + s.join("") + `<path d="${o.blade}" fill="#C4607C" fill-opacity="0.45" stroke="${t}" stroke-width="0.85"/>`;
124
+ }, ne = ({ ink: t, leaf: e, tape: r }) => Et('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">' + U("0", "0", lt(r, 3), "translate(26 20) rotate(-36)") + U("100%", "0", lt(r, 9), "translate(-26 20) rotate(36)") + U("0", "100%", ae(t, e, 21), `translate(16 -8) scale(${re})`) + "</svg>"), v = {
125
+ paper: "#F4EEDD",
126
+ raised: "#FBF8EE",
127
+ text: "#1E2A21",
128
+ secondary: "#4A5648",
129
+ rule: "#CFC7B0",
130
+ edge: "#BFB79E",
131
+ ink: "#3A2C1E",
132
+ tape: "#D9C89A"
133
+ }, wt = "'Kalam', 'Comic Neue', ui-rounded, sans-serif", q = "'Cormorant Garamond', 'Iowan Old Style', Georgia, serif", oe = wt, m = {
134
+ forest: "#2E5E3B",
135
+ petal: "#C4607C",
136
+ bark: "#5C4033",
137
+ sage: "#6E8A5A",
138
+ berry: "#8C2A3C",
139
+ gold: "#9A7A1E",
140
+ gentian: "#4A6A8C",
141
+ leaf: "#4E8A4A"
142
+ }, ie = [
143
+ m.forest,
144
+ m.petal,
145
+ m.bark,
146
+ m.sage,
147
+ m.berry,
148
+ m.gold,
149
+ m.gentian,
150
+ m.leaf
151
+ ], se = ["#DDE6CC", "#1C4A2B"], Y = 1.5, le = 2, X = 0.75, L = { textColor: v.text }, C = { textColor: v.secondary }, G = { fontFamily: wt }, dt = {
152
+ fontFamily: q,
153
+ fontStyle: "italic"
154
+ }, B = {
155
+ ...G,
156
+ textColor: v.ink,
157
+ fontWeight: 400,
158
+ fontSize: 15,
159
+ fill: v.paper,
160
+ stroke: "transparent",
161
+ strokeWidth: 0,
162
+ cornerRadius: 0,
163
+ paddingInline: 2,
164
+ paddingBlock: 0,
165
+ shadow: "none"
166
+ }, he = {
167
+ tokens: {
168
+ graphBackground: v.paper,
169
+ graphBorder: v.ink,
170
+ geom: m.forest,
171
+ geomBorder: v.secondary,
172
+ textPrimary: v.text,
173
+ textSecondary: v.secondary,
174
+ ruleLine: v.ink,
175
+ gridLine: v.rule,
176
+ hoverAffordance: v.text,
177
+ hoverGuideFill: "rgba(30, 42, 33, 0.06)",
178
+ hoverGuideLine: v.secondary,
179
+ tooltipBackground: v.raised,
180
+ tooltipBorder: v.text,
181
+ tooltipPrimaryRow: "rgba(46, 94, 59, 0.1)",
182
+ annotationShape: m.gold,
183
+ annotationArrow: v.text,
184
+ differenceLabelBackground: v.paper
185
+ },
186
+ defaults: [
187
+ p.graph({
188
+ fill: {
189
+ image: Jt(v.paper, v.ink),
190
+ fit: "tile",
191
+ fallback: v.paper
192
+ },
193
+ overlay: {
194
+ image: ne({
195
+ ink: v.ink,
196
+ leaf: m.sage,
197
+ tape: v.tape
198
+ }),
199
+ fit: "stretch",
200
+ fallback: "transparent"
201
+ },
202
+ strokeWidth: 0,
203
+ cornerRadius: 2,
204
+ shadow: {
205
+ offsetX: 0,
206
+ offsetY: 2,
207
+ blur: 10,
208
+ color: "rgba(58, 44, 30, 0.18)"
209
+ },
210
+ fontFamily: oe,
211
+ padding: {
212
+ top: 26,
213
+ right: 26,
214
+ bottom: 36,
215
+ left: 26
216
+ }
217
+ }),
218
+ p.geom({ shadow: "none" }, { state: "hovered" }),
219
+ p.geom.bar({
220
+ stroke: v.paper,
221
+ strokeWidth: 1,
222
+ cornerRadius: "none"
223
+ }),
224
+ p.geom.bar({
225
+ stroke: v.text,
226
+ strokeWidth: Y
227
+ }, { state: "hovered" }),
228
+ p.geom.line({
229
+ strokeWidth: le,
230
+ dashArray: [],
231
+ lineCap: "round",
232
+ lineJoin: "round"
233
+ }),
234
+ p.geom.area({
235
+ fillAlpha: 0.55,
236
+ strokeWidth: Y,
237
+ dashArray: [],
238
+ lineCap: "round",
239
+ lineJoin: "round"
240
+ }),
241
+ p.geom.point({
242
+ size: 8,
243
+ stroke: v.paper,
244
+ strokeWidth: 1
245
+ }),
246
+ p.geom.tile({
247
+ cornerRadius: 0,
248
+ stroke: v.paper,
249
+ strokeWidth: 1
250
+ }),
251
+ p.geom.tile({
252
+ stroke: v.text,
253
+ strokeWidth: Y
254
+ }, { state: "hovered" }),
255
+ p.geom.rule({
256
+ stroke: v.secondary,
257
+ strokeWidth: 1,
258
+ dashArray: [6, 4]
259
+ }),
260
+ p.geom.rule.label({
261
+ ...L,
262
+ fontWeight: 400,
263
+ fontSize: 12.5
264
+ }),
265
+ p.gridLine({ dashArray: [] }),
266
+ p.gridLine.x({ strokeWidth: 0 }),
267
+ p.gridLine.y({ strokeWidth: X }),
268
+ p.panelBorder({ strokeWidth: 0 }),
269
+ p.panelBorder.bottom({
270
+ stroke: v.ink,
271
+ strokeWidth: 1,
272
+ dashArray: []
273
+ }),
274
+ p.tickLine({ strokeWidth: 0 }),
275
+ p.tickLabel({
276
+ ...C,
277
+ fontWeight: 400,
278
+ fontSize: 14,
279
+ lineHeight: 1
280
+ }),
281
+ p.tickLabel.y({
282
+ fontFamily: q,
283
+ fontWeight: 600,
284
+ fontSize: 13,
285
+ lineHeight: 1
286
+ }),
287
+ p.axisLabel({
288
+ ...C,
289
+ ...dt,
290
+ fontWeight: 500,
291
+ fontSize: 16,
292
+ lineHeight: 1
293
+ }),
294
+ p.heading({
295
+ ...L,
296
+ ...G
297
+ }),
298
+ p.heading.h1({
299
+ fontWeight: 400,
300
+ fontSize: 28,
301
+ lineHeight: 1
302
+ }),
303
+ p.heading.h2({
304
+ ...C,
305
+ ...dt,
306
+ fontWeight: 500,
307
+ fontSize: 19,
308
+ lineHeight: 1.1
309
+ }),
310
+ p.header({ margin: { bottom: 16 } }),
311
+ p.caption({
312
+ ...C,
313
+ fontWeight: 400,
314
+ fontSize: 12.5
315
+ }),
316
+ p.source({
317
+ ...C,
318
+ fontWeight: 400,
319
+ fontSize: 12
320
+ }),
321
+ p.dataLabel({
322
+ ...L,
323
+ fontFamily: q,
324
+ fontWeight: 600,
325
+ fontSize: 13,
326
+ lineHeight: 1,
327
+ paddingBlock: 1,
328
+ paddingInline: 4,
329
+ fill: "transparent"
330
+ }),
331
+ p.legendItem({
332
+ ...L,
333
+ fontWeight: 400,
334
+ fontSize: 15,
335
+ fill: "transparent",
336
+ stroke: "transparent"
337
+ }),
338
+ p.directLabel({
339
+ fontWeight: 700,
340
+ fontSize: 12.5
341
+ }),
342
+ p.headlineItem.number({
343
+ ...G,
344
+ fontWeight: 600,
345
+ fontSize: 32,
346
+ lineHeight: 1.1
347
+ }),
348
+ p.tooltip({
349
+ strokeWidth: X,
350
+ cornerRadius: 0,
351
+ paddingInline: 10,
352
+ paddingBlock: 8,
353
+ shadow: "none"
354
+ }),
355
+ p.tooltip.heading({
356
+ ...L,
357
+ ...G,
358
+ fontWeight: 700,
359
+ fontSize: 17,
360
+ lineHeight: 1.2
361
+ }),
362
+ p.tooltip.label({
363
+ ...C,
364
+ fontWeight: 400,
365
+ fontSize: 13,
366
+ lineHeight: 1.35
367
+ }),
368
+ p.tooltip.value({
369
+ ...L,
370
+ fontWeight: 700,
371
+ fontSize: 13,
372
+ lineHeight: 1.35
373
+ }),
374
+ p.legend.popover({
375
+ strokeWidth: X,
376
+ cornerRadius: 0,
377
+ shadow: "none"
378
+ }),
379
+ p.annotation.text({
380
+ ...B,
381
+ fontSize: 16,
382
+ lineHeight: 1.2
383
+ }),
384
+ p.annotation.pinnedNumber({
385
+ fill: v.ink,
386
+ stroke: v.paper,
387
+ shadow: "none"
388
+ }),
389
+ p.annotation.pinnedNumber.label({ ...B }),
390
+ p.annotation.comment({
391
+ fill: v.ink,
392
+ stroke: v.paper,
393
+ shadow: "none"
394
+ }),
395
+ p.annotation.comment.label({ ...B }),
396
+ p.annotation.differenceArrow({
397
+ stroke: v.ink,
398
+ strokeWidth: 1.25
399
+ }),
400
+ p.annotation.differenceArrow.label({ ...B }),
401
+ p.annotation.arrow({
402
+ stroke: v.ink,
403
+ strokeWidth: 1.25,
404
+ dashArray: []
405
+ }),
406
+ p.annotation.shape({
407
+ fill: m.sage,
408
+ fillAlpha: 0.14,
409
+ strokeWidth: 0
410
+ }),
411
+ p.panelBorder.bottom({ strokeWidth: 0 }, { coord: "polar" }),
412
+ p.geom.area({ fillAlpha: 0.35 }, { coord: "polar" }),
413
+ p.tickLabel({
414
+ ...L,
415
+ fontWeight: 700,
416
+ textOutlineColor: v.paper,
417
+ textOutlineWidth: 3
418
+ }, { coord: "polar" })
419
+ ]
420
+ }, et = v.ink;
421
+ var bt = 0.6, Mt = 0.7, de = 5, ce = 0.35, ue = (t) => `${t}-${Ct().replace(/[^a-zA-Z0-9]/gu, "")}`, K = ({ path: t, color: e, opacity: r }) => {
422
+ const a = ue("wash");
423
+ return /* @__PURE__ */ w("g", { children: [
424
+ /* @__PURE__ */ g("clipPath", {
425
+ id: a,
426
+ children: /* @__PURE__ */ g("path", { d: t })
427
+ }),
428
+ /* @__PURE__ */ g("path", {
429
+ d: t,
430
+ fill: e,
431
+ fillOpacity: r
432
+ }),
433
+ /* @__PURE__ */ g("path", {
434
+ d: t,
435
+ fill: "none",
436
+ stroke: e,
437
+ strokeOpacity: ce,
438
+ strokeWidth: de,
439
+ clipPath: `url(#${a})`
440
+ })
441
+ ] });
442
+ }, x = ({ path: t, width: e = 1, opacity: r = 1 }) => /* @__PURE__ */ g("path", {
443
+ d: t,
444
+ fill: "none",
445
+ stroke: et,
446
+ strokeWidth: e,
447
+ strokeOpacity: r,
448
+ strokeLinecap: "round",
449
+ strokeLinejoin: "round"
450
+ }), rt = ({ base: t, length: e, angle: r, color: a, opacity: n = 1, washOpacity: i = 0.6 }) => {
451
+ const { blade: s, rib: o } = Z(t, e, e * 0.32, r);
452
+ return /* @__PURE__ */ w("g", {
453
+ opacity: n,
454
+ children: [/* @__PURE__ */ g("path", {
455
+ d: s,
456
+ fill: a,
457
+ fillOpacity: i,
458
+ stroke: et,
459
+ strokeWidth: 0.8,
460
+ strokeLinejoin: "round"
461
+ }), /* @__PURE__ */ g(x, {
462
+ path: o,
463
+ width: bt,
464
+ opacity: Mt
465
+ })]
466
+ });
467
+ }, R = (t) => {
468
+ const e = J(t);
469
+ return (r, a) => ({
470
+ color: jt(e.get("fill", r, a)),
471
+ opacity: e.get("alpha", r, a),
472
+ fillOpacity: e.get("fillAlpha", r, a),
473
+ edge: e.get("stroke", r, a),
474
+ edgeWidth: e.get("strokeWidth", r, a)
475
+ });
476
+ }, Pt = (t) => {
477
+ const e = J(t);
478
+ return (r, a) => {
479
+ const n = e.get("strokeWidth", r, a);
480
+ return {
481
+ color: e.get("stroke", r, a),
482
+ opacity: e.get("alpha", r, a) * e.get("strokeAlpha", r, a),
483
+ width: n,
484
+ dashArray: Kt(e.get("dashArray", r, a), n)
485
+ };
486
+ };
487
+ }, ge = 16, ct = (t, e) => {
488
+ const r = O(t.data, t.mapping, t.id), a = [];
489
+ return t.data.groupBy(At.group).forEach((n) => {
490
+ const i = [...n], [s] = i, o = e(i);
491
+ s === void 0 || o === null || a.push({
492
+ key: r(s),
493
+ observation: s,
494
+ path: o
495
+ });
496
+ }), a;
497
+ }, pe = (t, e) => {
498
+ const r = t.flatMap((a) => {
499
+ const n = H(a), i = j(a, e);
500
+ return n === null || i === null ? [] : [{
501
+ angle: n,
502
+ point: i
503
+ }];
504
+ }).sort((a, n) => a.angle - n.angle).map(({ point: a }) => a);
505
+ return r.length === 0 ? null : qt(r);
506
+ }, St = ({ geom: t, observation: e, panel: r, project: a, color: n, opacity: i }) => {
507
+ const s = a(e, r);
508
+ return s === null ? null : /* @__PURE__ */ g("g", {
509
+ "data-geom": t,
510
+ children: /* @__PURE__ */ g(rt, {
511
+ base: s,
512
+ length: ge,
513
+ angle: -Math.PI / 4,
514
+ color: n,
515
+ opacity: i
516
+ })
517
+ });
518
+ }, fe = 1.2, ve = /^[ML\d\s.,eE+-]+$/u, ye = /[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/gu, me = (t) => {
519
+ if (!ve.test(t)) return null;
520
+ const e = (t.match(ye) ?? []).map(Number), r = [];
521
+ for (let a = 0; a + 1 < e.length; a += 2) r.push({
522
+ x: e[a],
523
+ y: e[a + 1]
524
+ });
525
+ return r;
526
+ }, ut = (t, e, r) => {
527
+ const a = me(t.replace(/\s*Z\s*$/u, ""));
528
+ return a === null || a.length < 2 ? t : b(a, {
529
+ wander: fe,
530
+ seed: e,
531
+ closed: r
532
+ });
533
+ }, _t = ({ layer: t, coordSystem: e, panel: r }) => {
534
+ const a = R(t), n = I(() => {
535
+ if (e === void 0) return ct(t, (l) => pe(l, r)).map((l) => ({
536
+ ...l,
537
+ fill: l.path,
538
+ edge: ut(l.path, T(l.key), !0)
539
+ }));
540
+ const { areaGenerator: i, lineGenerator: s } = It(e, t.params), o = /* @__PURE__ */ new Map();
541
+ return ct(t, (l) => {
542
+ const c = zt(l, t.params.missingValues), h = i(c), u = s(c);
543
+ if (!h) return null;
544
+ const d = it(h, r);
545
+ return u && o.set(d, it(u, r)), d;
546
+ }).map((l) => ({
547
+ ...l,
548
+ fill: l.path,
549
+ edge: ut(o.get(l.path) ?? "", T(l.key), !1)
550
+ }));
551
+ }, [
552
+ t,
553
+ e,
554
+ r
555
+ ]);
556
+ return r.width <= 0 || r.height <= 0 ? null : /* @__PURE__ */ g("g", {
557
+ "data-geom": "area",
558
+ children: n.map(({ key: i, observation: s, fill: o, edge: l }) => {
559
+ const c = a(s);
560
+ return /* @__PURE__ */ w("g", {
561
+ opacity: c.opacity,
562
+ children: [/* @__PURE__ */ g(K, {
563
+ path: o,
564
+ color: c.color,
565
+ opacity: c.fillOpacity
566
+ }), /* @__PURE__ */ g(x, {
567
+ path: l,
568
+ width: c.edgeWidth
569
+ })]
570
+ }, i);
571
+ })
572
+ });
573
+ }, Lt = ({ layer: t, observation: e, panel: r, project: a }) => {
574
+ const n = R(t)(e, "hovered");
575
+ return /* @__PURE__ */ g(St, {
576
+ geom: "area",
577
+ observation: e,
578
+ panel: r,
579
+ project: a,
580
+ color: n.color,
581
+ opacity: n.opacity
582
+ });
583
+ }, Ae = W("area", {
584
+ coord: "cartesian",
585
+ guideMode: "crosshair",
586
+ swatchShape: "area",
587
+ render: ({ layer: t, coordSystem: e, panelRect: r }) => e.type !== "cartesian" ? null : /* @__PURE__ */ g(_t, {
588
+ layer: t,
589
+ coordSystem: e,
590
+ panel: r
591
+ }),
592
+ renderHover: ({ layer: t, primary: e, panelRect: r }) => /* @__PURE__ */ g(Lt, {
593
+ layer: t,
594
+ observation: e.observation,
595
+ panel: r,
596
+ project: tt
597
+ }),
598
+ renderHoverCompanions: () => null
599
+ }), xe = W("area", {
600
+ coord: "polar",
601
+ guideMode: "crosshair",
602
+ swatchShape: "area",
603
+ render: ({ layer: t, panelRect: e }) => /* @__PURE__ */ g(_t, {
604
+ layer: t,
605
+ panel: e
606
+ }),
607
+ renderHover: ({ layer: t, primary: e, panelRect: r }) => /* @__PURE__ */ g(Lt, {
608
+ layer: t,
609
+ observation: e.observation,
610
+ panel: r,
611
+ project: j
612
+ }),
613
+ renderHoverCompanions: () => null
614
+ }), ke = 1.4, Ee = 0.8, we = 0.6, $ = 13, be = 14, Me = 6, Pe = 2, Se = {
615
+ solo: {
616
+ base: !0,
617
+ value: !0
618
+ },
619
+ floor: {
620
+ base: !0,
621
+ value: !1
622
+ },
623
+ ceiling: {
624
+ base: !1,
625
+ value: !0
626
+ },
627
+ middle: {
628
+ base: !1,
629
+ value: !1
630
+ }
631
+ }, _e = {
632
+ top: "bottom",
633
+ bottom: "top",
634
+ left: "right",
635
+ right: "left"
636
+ }, Le = (t, e) => e === "x" ? (xt(t) ?? z(t) ?? 0) >= (Ft(t) ?? 0) ? "top" : "bottom" : (Dt(t) ?? 0) >= (Gt(t) ?? 0) ? "right" : "left", Te = (t, e, r) => {
637
+ const a = Math.max(0, t.width - r), n = Math.max(0, t.height - r);
638
+ return e === "top" ? {
639
+ ...t,
640
+ y: t.y + t.height - n,
641
+ height: n
642
+ } : e === "bottom" ? {
643
+ ...t,
644
+ height: n
645
+ } : e === "left" ? {
646
+ ...t,
647
+ x: t.x + t.width - a,
648
+ width: a
649
+ } : {
650
+ ...t,
651
+ width: a
652
+ };
653
+ }, We = (t, e) => e === "top" || e === "bottom" ? {
654
+ breadth: t.width,
655
+ length: t.height
656
+ } : {
657
+ breadth: t.height,
658
+ length: t.width
659
+ }, E = (t, e, r, a) => {
660
+ const { x: n, y: i, width: s, height: o } = t;
661
+ return e === "top" ? {
662
+ x: n + r,
663
+ y: i + o - a
664
+ } : e === "bottom" ? {
665
+ x: n + r,
666
+ y: i + a
667
+ } : e === "right" ? {
668
+ x: n + a,
669
+ y: i + r
670
+ } : {
671
+ x: n + s - a,
672
+ y: i + r
673
+ };
674
+ }, Ce = (t, e, r, a) => {
675
+ const n = r / 2, i = r * 0.36, s = [];
676
+ for (let o = $ * 0.8; o < a - $ * 0.6; o += $) for (const l of [-1, 1]) {
677
+ const c = E(t, e, n, o), h = E(t, e, n + l * i * 0.55, o + $ * 0.25), u = E(t, e, n + l * i, o + $ * 0.6);
678
+ s.push(`M${c.x},${c.y} Q${h.x},${h.y} ${u.x},${u.y}`);
679
+ }
680
+ return s.join(" ");
681
+ }, He = ({ layer: t, observation: e, seedKey: r, mainAxis: a, panel: n, state: i }) => {
682
+ const s = R(t), o = Ot(a, e);
683
+ if (!o || o.width <= 0 || o.height <= 0) return null;
684
+ const l = s(e, i), c = Se[Bt(e)], h = Le(e, a), u = {
685
+ x: o.x * n.width,
686
+ y: o.y * n.height,
687
+ width: o.width * n.width,
688
+ height: o.height * n.height
689
+ }, d = [c.value ? [] : [h], c.base ? [] : [_e[h]]].flat().reduce((_, M) => Te(_, M, Pe / 2), u), { breadth: f, length: y } = We(d, h);
690
+ if (f <= 0 || y <= 0) return null;
691
+ const P = T(r), S = b([
692
+ E(d, h, 0, 0),
693
+ E(d, h, 0, y),
694
+ E(d, h, f, y),
695
+ E(d, h, f, 0)
696
+ ], {
697
+ wander: Math.min(ke, f / 8),
698
+ seed: P,
699
+ closed: !0,
700
+ cornered: !0
701
+ }), k = f >= Me && y > 8 ? b([E(d, h, f / 2, 1), E(d, h, f / 2, y - 3)], {
702
+ wander: Ee,
703
+ seed: P + 1
704
+ }) : "";
705
+ return /* @__PURE__ */ w("g", {
706
+ opacity: l.opacity,
707
+ children: [
708
+ /* @__PURE__ */ g(K, {
709
+ path: S,
710
+ color: l.color,
711
+ opacity: l.fillOpacity * we
712
+ }),
713
+ k !== "" && /* @__PURE__ */ g(x, {
714
+ path: k,
715
+ width: 0.6 * 1.4,
716
+ opacity: 0.7
717
+ }),
718
+ f >= be && /* @__PURE__ */ g(x, {
719
+ path: Ce(d, h, f, y),
720
+ width: 0.6,
721
+ opacity: 0.7 * 0.8
722
+ }),
723
+ /* @__PURE__ */ g(x, {
724
+ path: S,
725
+ width: l.edgeWidth
726
+ })
727
+ ]
728
+ });
729
+ }, gt = ({ layer: t, observations: e, mainAxis: r, panel: a, state: n }) => {
730
+ const i = I(() => O(t.data, t.mapping, t.id), [
731
+ t.data,
732
+ t.mapping,
733
+ t.id
734
+ ]);
735
+ return a.width <= 0 || a.height <= 0 ? null : /* @__PURE__ */ g("g", {
736
+ "data-geom": "bar",
737
+ children: Array.from(e, (s) => {
738
+ const o = i(s);
739
+ return /* @__PURE__ */ g(He, {
740
+ layer: t,
741
+ observation: s,
742
+ seedKey: o,
743
+ mainAxis: r,
744
+ panel: a,
745
+ state: n
746
+ }, o);
747
+ })
748
+ });
749
+ }, Ie = W("bar", {
750
+ coord: "cartesian",
751
+ guideMode: "band",
752
+ swatchShape: "square",
753
+ render: ({ layer: t, coordSystem: e, panelRect: r }) => /* @__PURE__ */ g(gt, {
754
+ layer: t,
755
+ observations: t.data,
756
+ mainAxis: ot(e),
757
+ panel: r
758
+ }),
759
+ renderHover: ({ layer: t, coordSystem: e, primary: r, panelRect: a }) => /* @__PURE__ */ g(gt, {
760
+ layer: t,
761
+ observations: [r.observation],
762
+ mainAxis: ot(e),
763
+ panel: a,
764
+ state: "hovered"
765
+ }),
766
+ renderHoverCompanions: () => null
767
+ }), Re = 1.2, $e = 15, Oe = 20, Ne = 0.75, Be = (t, e, r, a) => {
768
+ const n = O(t.data, t.mapping, t.id), i = [];
769
+ return t.data.groupBy(At.group).forEach((s) => {
770
+ const o = [...s], [l] = o;
771
+ if (l === void 0) return;
772
+ const c = (r === "polar" ? o.sort((u, d) => (H(u) ?? 0) - (H(d) ?? 0)) : o).flatMap((u) => {
773
+ const d = a(u, e);
774
+ return d === null ? [] : [d];
775
+ });
776
+ if (c.length < 2) return;
777
+ const h = n(l);
778
+ i.push({
779
+ key: h,
780
+ observation: l,
781
+ points: c,
782
+ stem: b(c, {
783
+ wander: Re,
784
+ seed: T(h),
785
+ closed: r === "polar"
786
+ })
787
+ });
788
+ }), i;
789
+ }, De = (t) => {
790
+ const e = [];
791
+ let r = null;
792
+ return t.forEach((a, n) => {
793
+ if (r !== null && Math.hypot(a.x - r.x, a.y - r.y) < Oe) return;
794
+ const i = t[Math.max(0, n - 1)], s = t[Math.min(t.length - 1, n + 1)], o = Math.atan2(s.y - i.y, s.x - i.x), l = e.length % 2 === 0 ? -1 : 1;
795
+ e.push({
796
+ base: a,
797
+ angle: o + l * (Math.PI / 2 - Ne)
798
+ }), r = a;
799
+ }), e;
800
+ }, Ge = ({ layer: t, panel: e, coord: r, project: a }) => {
801
+ const n = Pt(t), i = I(() => Be(t, e, r, a), [
802
+ t,
803
+ e,
804
+ r,
805
+ a
806
+ ]);
807
+ return e.width <= 0 || e.height <= 0 ? null : /* @__PURE__ */ g("g", {
808
+ "data-geom": "line",
809
+ children: i.map(({ key: s, observation: o, stem: l, points: c }) => {
810
+ const h = n(o);
811
+ return /* @__PURE__ */ w("g", {
812
+ opacity: h.opacity,
813
+ children: [/* @__PURE__ */ g("path", {
814
+ d: l,
815
+ fill: "none",
816
+ stroke: h.color,
817
+ strokeWidth: h.width,
818
+ strokeDasharray: h.dashArray,
819
+ strokeLinecap: "round",
820
+ strokeLinejoin: "round"
821
+ }), De(c).map(({ base: u, angle: d }, f) => /* @__PURE__ */ g(rt, {
822
+ base: u,
823
+ length: $e,
824
+ angle: d,
825
+ color: h.color
826
+ }, f))]
827
+ }, s);
828
+ })
829
+ });
830
+ }, Fe = ({ layer: t, observation: e, panel: r, project: a }) => {
831
+ const n = Pt(t)(e, "hovered");
832
+ return /* @__PURE__ */ g(St, {
833
+ geom: "line",
834
+ observation: e,
835
+ panel: r,
836
+ project: a,
837
+ color: n.color,
838
+ opacity: n.opacity
839
+ });
840
+ }, Tt = (t, e) => W("line", {
841
+ coord: t,
842
+ guideMode: "crosshair",
843
+ swatchShape: "line",
844
+ render: ({ layer: r, panelRect: a }) => /* @__PURE__ */ g(Ge, {
845
+ layer: r,
846
+ panel: a,
847
+ coord: t,
848
+ project: e
849
+ }),
850
+ renderHover: ({ layer: r, primary: a, panelRect: n }) => /* @__PURE__ */ g(Fe, {
851
+ layer: r,
852
+ observation: a.observation,
853
+ panel: n,
854
+ project: e
855
+ }),
856
+ renderHoverCompanions: () => null,
857
+ getOverlayAnchor: ({ observation: r }) => {
858
+ const a = H(r), n = z(r);
859
+ return a === null || n === null ? null : {
860
+ x: a,
861
+ y: n
862
+ };
863
+ }
864
+ }), ze = Tt("cartesian", tt), je = Tt("polar", j), Ke = 2.6, Ve = 4, pt = ({ layer: t, observations: e, panel: r, project: a, state: n }) => {
865
+ const i = J(t), s = R(t), o = I(() => O(t.data, t.mapping, t.id), [
866
+ t.data,
867
+ t.mapping,
868
+ t.id
869
+ ]), l = n === "hovered" ? Ve : 0;
870
+ return /* @__PURE__ */ g("g", {
871
+ "data-geom": "point",
872
+ children: Array.from(e, (c) => {
873
+ const h = a(c, r);
874
+ if (h === null) return null;
875
+ const u = o(c), d = s(c, n), f = (i.get("size", c, n) + l) * Ke, y = N(T(u))() * Math.PI * 2;
876
+ return /* @__PURE__ */ g(rt, {
877
+ base: {
878
+ x: h.x - Math.cos(y) * f / 2,
879
+ y: h.y - Math.sin(y) * f / 2
880
+ },
881
+ length: f,
882
+ angle: y,
883
+ color: d.color,
884
+ opacity: d.opacity,
885
+ washOpacity: d.fillOpacity * 0.7
886
+ }, u);
887
+ })
888
+ });
889
+ }, Wt = (t, e) => W("point", {
890
+ coord: t,
891
+ swatchShape: "circle",
892
+ render: ({ layer: r, panelRect: a }) => /* @__PURE__ */ g(pt, {
893
+ layer: r,
894
+ observations: r.data,
895
+ panel: a,
896
+ project: e
897
+ }),
898
+ renderHover: ({ layer: r, primary: a, panelRect: n }) => /* @__PURE__ */ g(pt, {
899
+ layer: r,
900
+ observations: [a.observation],
901
+ panel: n,
902
+ project: e,
903
+ state: "hovered"
904
+ }),
905
+ renderHoverCompanions: () => null
906
+ }), Ue = Wt("cartesian", tt), Ye = Wt("polar", j), Xe = 3, Ze = 1.6, qe = Math.PI / 30, Qe = 0.6, Je = 0.3, tr = 0.13, ft = 34, er = "#B08A2E", F = (t, e, r) => {
907
+ const a = kt(e, 1);
908
+ return {
909
+ x: t.width / 2 + a.x * r,
910
+ y: t.height / 2 - a.y * r
911
+ };
912
+ }, vt = (t, e, r, a) => {
913
+ const n = Math.max(1, Math.ceil(Math.abs(r - e) / qe));
914
+ return Array.from({ length: n + 1 }, (i, s) => F(t, e + (r - e) * s / n, a));
915
+ }, rr = (t, e, r) => {
916
+ const { startAngle: a, endAngle: n } = $t(t), { innerRadius: i, outerRadius: s } = Q(t);
917
+ if (a === null || n === null || i === null || s === null) return null;
918
+ const o = Math.min(e.width, e.height) / 2, l = s * o, c = i * o;
919
+ if (l <= 0) return null;
920
+ const h = Math.max(0, n - a), u = h >= 2 * Math.PI - 1e-6 ? 0 : Math.min(Xe / 2 / l, h / 4), d = a + u, f = n - u, y = vt(e, d, f, l), P = c > 0 ? vt(e, f, d, c) : [F(e, 0, 0)], S = b([...y, ...P], {
921
+ wander: Ze,
922
+ seed: r,
923
+ closed: !0,
924
+ step: 12
925
+ }), k = Math.max(1, Math.round((f - d) / Je)), _ = c + (l - c) * 0.12, M = l - (l - c) * 0.14;
926
+ return {
927
+ outline: S,
928
+ veins: Array.from({ length: k }, (V, at) => {
929
+ const nt = d + (f - d) * (at + 0.5) / k;
930
+ return b([F(e, nt, _), F(e, nt, M)], {
931
+ wander: 0.8,
932
+ seed: r + at + 1
933
+ });
934
+ }).join(" ")
935
+ };
936
+ }, ar = (t, e, r) => {
937
+ const a = N(r), n = Math.PI * (3 - Math.sqrt(5));
938
+ return Array.from({ length: ft }, (i, s) => {
939
+ const o = e * 0.85 * Math.sqrt((s + 0.5) / ft), l = s * n + a() * 0.2, c = t.x + Math.cos(l) * o, h = t.y + Math.sin(l) * o;
940
+ return `M${c.toFixed(2)},${h.toFixed(2)} h0.01`;
941
+ }).join(" ");
942
+ }, yt = ({ layer: t, observations: e, panel: r, state: a }) => {
943
+ const n = R(t), i = I(() => O(t.data, t.mapping, t.id), [
944
+ t.data,
945
+ t.mapping,
946
+ t.id
947
+ ]);
948
+ if (r.width <= 0 || r.height <= 0) return null;
949
+ const s = Array.from(e, (u) => {
950
+ const d = i(u);
951
+ return {
952
+ key: d,
953
+ observation: u,
954
+ paint: n(u, a),
955
+ petal: rr(u, r, T(d))
956
+ };
957
+ }), o = s.map(({ observation: u }) => Q(u)), l = a === void 0 && s.length > 1 && o.every(({ innerRadius: u, outerRadius: d }) => u === 0 && d === o[0]?.outerRadius), c = {
958
+ x: r.width / 2,
959
+ y: r.height / 2
960
+ }, h = Math.min(r.width, r.height) / 2 * tr;
961
+ return /* @__PURE__ */ w("g", {
962
+ "data-geom": "bar",
963
+ children: [s.map(({ key: u, paint: d, petal: f }) => f === null ? null : /* @__PURE__ */ w("g", {
964
+ opacity: d.opacity,
965
+ children: [
966
+ /* @__PURE__ */ g(K, {
967
+ path: f.outline,
968
+ color: d.color,
969
+ opacity: d.fillOpacity * Qe
970
+ }),
971
+ /* @__PURE__ */ g(x, {
972
+ path: f.veins,
973
+ width: bt,
974
+ opacity: Mt * 0.8
975
+ }),
976
+ /* @__PURE__ */ g(x, {
977
+ path: f.outline,
978
+ width: d.edgeWidth
979
+ })
980
+ ]
981
+ }, u)), l && /* @__PURE__ */ w("g", { children: [
982
+ /* @__PURE__ */ g("circle", {
983
+ cx: c.x,
984
+ cy: c.y,
985
+ r: h,
986
+ fill: er,
987
+ fillOpacity: 0.55
988
+ }),
989
+ /* @__PURE__ */ g(x, {
990
+ path: ar(c, h, 7),
991
+ width: 2.2
992
+ }),
993
+ /* @__PURE__ */ g(x, { path: b(Array.from({ length: 13 }, (u, d) => {
994
+ const f = d / 12 * Math.PI * 2;
995
+ return {
996
+ x: c.x + Math.cos(f) * h,
997
+ y: c.y + Math.sin(f) * h
998
+ };
999
+ }), {
1000
+ wander: 0.8,
1001
+ seed: 11
1002
+ }) })
1003
+ ] })]
1004
+ });
1005
+ }, nr = W("bar", {
1006
+ coord: "polar",
1007
+ guideMode: "band",
1008
+ swatchShape: "slice",
1009
+ render: ({ layer: t, panelRect: e }) => /* @__PURE__ */ g(yt, {
1010
+ layer: t,
1011
+ observations: t.data,
1012
+ panel: e
1013
+ }),
1014
+ renderHover: ({ layer: t, primary: e, panelRect: r }) => /* @__PURE__ */ g(yt, {
1015
+ layer: t,
1016
+ observations: [e.observation],
1017
+ panel: r,
1018
+ state: "hovered"
1019
+ }),
1020
+ renderHoverCompanions: () => null
1021
+ }), D = 3, or = 1, ir = ({ layer: t, observation: e, seedKey: r, panel: a, state: n }) => {
1022
+ const i = R(t), s = Nt(e);
1023
+ if (s === null) return null;
1024
+ const o = i(e, n), l = s.x * a.width + D / 2, c = s.y * a.height + D / 2, h = s.width * a.width - D, u = s.height * a.height - D;
1025
+ if (h <= 0 || u <= 0) return null;
1026
+ const d = b([
1027
+ {
1028
+ x: l,
1029
+ y: c
1030
+ },
1031
+ {
1032
+ x: l + h,
1033
+ y: c
1034
+ },
1035
+ {
1036
+ x: l + h,
1037
+ y: c + u
1038
+ },
1039
+ {
1040
+ x: l,
1041
+ y: c + u
1042
+ }
1043
+ ], {
1044
+ wander: Math.min(or, h / 10, u / 10),
1045
+ seed: T(r),
1046
+ closed: !0,
1047
+ cornered: !0
1048
+ });
1049
+ return /* @__PURE__ */ w("g", {
1050
+ opacity: o.opacity,
1051
+ children: [/* @__PURE__ */ g(K, {
1052
+ path: d,
1053
+ color: o.color,
1054
+ opacity: o.fillOpacity * 0.85
1055
+ }), /* @__PURE__ */ g(x, {
1056
+ path: d,
1057
+ width: n === "hovered" ? o.edgeWidth : 0.8,
1058
+ opacity: 0.85
1059
+ })]
1060
+ });
1061
+ }, mt = ({ layer: t, observations: e, panel: r, state: a }) => {
1062
+ const n = I(() => Rt(t.data, t.mapping, t.id), [
1063
+ t.data,
1064
+ t.mapping,
1065
+ t.id
1066
+ ]);
1067
+ return r.width <= 0 || r.height <= 0 ? null : /* @__PURE__ */ g("g", {
1068
+ "data-geom": "tile",
1069
+ children: Array.from(e, (i) => {
1070
+ const s = n(i);
1071
+ return /* @__PURE__ */ g(ir, {
1072
+ layer: t,
1073
+ observation: i,
1074
+ seedKey: s,
1075
+ panel: r,
1076
+ state: a
1077
+ }, s);
1078
+ })
1079
+ });
1080
+ }, sr = W("tile", {
1081
+ coord: "cartesian",
1082
+ guideMode: null,
1083
+ swatchShape: "square",
1084
+ render: ({ layer: t, panelRect: e }) => /* @__PURE__ */ g(mt, {
1085
+ layer: t,
1086
+ observations: t.data,
1087
+ panel: e
1088
+ }),
1089
+ renderHover: ({ layer: t, primary: e, panelRect: r }) => /* @__PURE__ */ g(mt, {
1090
+ layer: t,
1091
+ observations: [e.observation],
1092
+ panel: r,
1093
+ state: "hovered"
1094
+ }),
1095
+ renderHoverCompanions: () => null
1096
+ }), lr = [
1097
+ Ie,
1098
+ nr,
1099
+ sr,
1100
+ ze,
1101
+ je,
1102
+ Ae,
1103
+ xe,
1104
+ Ue,
1105
+ Ye
1106
+ ], hr = ({ fill: t, fillOpacity: e, ...r }) => /* @__PURE__ */ g(Ht, {
1107
+ ...r,
1108
+ fill: t,
1109
+ fillOpacity: 0.6,
1110
+ stroke: et,
1111
+ strokeWidth: 0.9
1112
+ }), dr = { Circle: hr }, pr = {
1113
+ name: "botanical",
1114
+ styles: he,
1115
+ palette: ie,
1116
+ colormap: se,
1117
+ colorScheme: "light",
1118
+ plugins: lr,
1119
+ shapes: dr
1120
+ };
1121
+ export {
1122
+ pr as botanical
1123
+ };