@redus/georedus-ui 0.1.3 → 0.1.5

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/main.js +40 -1287
  3. package/package.json +8 -4
package/dist/main.js CHANGED
@@ -1,44 +1,39 @@
1
- import React, { useMemo, createContext, useState, useRef, useContext, useCallback, forwardRef, useImperativeHandle, createRef, useEffect, useReducer } from 'react';
2
- import { Flex, TextEllipsis, TextInput, Button, MARKDOWN_DEFAULT_REMARK_PLUGINS, MARKDOWN_DEFAULT_REHYPE_PLUGINS, Markdown as Markdown$1, CANCELLED, DropdownMenu, Box, Input, SwitchInput, withDefaults, LoadingOverlay, useRefByKey, fileReadAs, SingleFileInput, InputProvider as InputProvider$1, rendererSpecList, withLabeledLayout, INPUTS, useLocalState, EvenSpacedList, LoadingIndicator } from '@orioro/react-ui-core';
3
- import { nodesFromPaths, treeModel, nodeIdFromPath } from '@orioro/tree-model';
4
- import * as Tabs from '@radix-ui/react-tabs';
1
+ import React, { useState, useMemo, useCallback, useContext, createContext, useReducer, useEffect, useRef } from 'react';
2
+ import { MARKDOWN_DEFAULT_REMARK_PLUGINS, MARKDOWN_DEFAULT_REHYPE_PLUGINS, Markdown as Markdown$1, CANCELLED, Flex, DropdownMenu, Box, Input, SwitchInput, TextEllipsis, withDefaults, LoadingOverlay, Button, fileReadAs, SingleFileInput, InputProvider as InputProvider$1, rendererSpecList, TextInput, withLabeledLayout, INPUTS, useLocalState, EvenSpacedList, LoadingIndicator } from '@orioro/react-ui-core';
3
+ import { nodeIdFromPath } from '@orioro/tree-model';
4
+ import { makeDirNav } from '@orioro/react-dir-nav';
5
+ import { Icon } from '@mdi/react';
6
+ import { mdiHelpCircleOutline, mdiDownload, mdiDotsVertical, mdiOpacity, mdiFilterVariant, mdiHospitalBox, mdiHomeCity, mdiSchool, mdiAccountGroup, mdiChevronLeft, mdiShareVariantOutline, mdiDragVertical, mdiLayers, mdiClose } from '@mdi/js';
7
+ import { Tabs, Tooltip, IconButton, Theme, Heading, Text, Dialog, Portal, Popover } from '@radix-ui/themes';
5
8
  import styled, { keyframes } from 'styled-components';
6
- import { Tooltip, Heading, Select, Tabs as Tabs$1, IconButton, Theme, Text, Dialog, Portal, Popover } from '@radix-ui/themes';
7
- import { makeTreeRenderer } from '@orioro/react-tree';
8
9
  import * as Collapsible from '@radix-ui/react-collapsible';
9
- import Icon$1, { Icon } from '@mdi/react';
10
- import { mdiMagnify, mdiClose, mdiFolderOutline, mdiChevronRight, mdiFolderOpen, mdiFolder, mdiHelpCircleOutline, mdiDownload, mdiDotsVertical, mdiOpacity, mdiFilterVariant, mdiHospitalBox, mdiHomeCity, mdiSchool, mdiAccountGroup, mdiChevronLeft, mdiShareVariantOutline, mdiDragVertical, mdiLayers } from '@mdi/js';
11
- import { groupBy, isPlainObject as isPlainObject$1, uniq, uniqBy, range, chunk } from 'lodash-es';
12
- import { optionsIndexer } from '@orioro/react-select';
13
- import { __makeTemplateObject as __makeTemplateObject$2, __rest as __rest$2, __assign, __spreadArray as __spreadArray$2, __awaiter, __generator } from '/Users/simon/code/georedus/node_modules/tslib/tslib.es6.js';
10
+ import { __makeTemplateObject, __assign, __awaiter, __generator, __spreadArray } from '/Users/simon/code/georedus/node_modules/tslib/tslib.es6.js';
14
11
  import remarkMath from 'remark-math';
15
12
  import rehypeKatex from 'rehype-katex';
16
13
  import 'katex/dist/katex.min.css';
17
- import { isPlainObject, pick, omit, set, get as get$1, uniqBy as uniqBy$1, groupBy as groupBy$1, uniq as uniq$1 } from 'lodash';
14
+ import { isPlainObject, pick, omit, set, get as get$1, uniqBy, groupBy, uniq } from 'lodash';
18
15
  import { useDebounce } from 'react-use';
19
16
  import { createDialogSystem, DIALOGS } from '@orioro/react-dialogs';
20
17
  import { CsvImportDialog } from '@orioro/react-csv';
21
18
  import Highlighter from 'react-highlight-words';
22
19
  import { makeSortableMultiList } from '@orioro/react-sortable';
23
- import { Map, Source, Layer, useMap, GeolocateControl, NavigationControl, ScaleControl, AttributionControl } from 'react-map-gl/maplibre';
24
- import { mergeRefs } from 'react-merge-refs';
25
- import 'simple-statistics';
26
- import { schemeTableau10, schemeSet3, schemeSet2, schemeSet1, schemePastel2, schemePastel1, schemePaired, schemeObservable10, schemeDark2, schemeAccent, schemeCategory10, schemeSpectral, schemeRdYlGn, schemeRdYlBu, schemeRdGy, schemeRdBu, schemePuOr, schemePiYG, schemePRGn, schemeBrBG, schemeYlOrRd, schemeYlOrBr, schemeYlGn, schemeYlGnBu, schemeRdPu, schemePuRd, schemePuBu, schemePuBuGn, schemeOrRd, schemeGnBu, schemeBuPu, schemeBuGn, schemeReds, schemePurples, schemeOranges, schemeGreys, schemeGreens, schemeBlues } from 'd3-scale-chromatic';
27
- import 'd3';
28
- import { bbox, buffer } from '@turf/turf';
29
- import { interpolate, slugify, dataJoin } from '@orioro/util';
30
- import { cast, strAutoCast } from '@orioro/cast';
31
- import { scaleLinear } from 'd3-scale';
20
+ import { makeSyncedMaps, LayeredMap, HoverTooltip, MapWindow, fitGeometry } from '@orioro/react-maplibre-util';
21
+ import { Legend } from '@orioro/react-chart-util';
32
22
  import 'maplibre-gl/dist/maplibre-gl.css';
33
23
  import { useQuery, useQueries } from '@tanstack/react-query';
34
24
  import { makeResolve, $$literal, withExpressionResolvers, expressions, ALL_EXPR, fetchExpr, resolve, resolveAsync } from '@orioro/resolve';
35
25
  import queryString from 'query-string';
36
26
  import { wrap } from 'comlink';
37
27
  import { get } from '@orioro/get';
28
+ import { GeolocateControl, NavigationControl, ScaleControl, AttributionControl } from 'react-map-gl/maplibre';
29
+ import { slugify, dataJoin } from '@orioro/util';
30
+ import { schemeTableau10, schemeSet3, schemeSet2, schemeSet1, schemePastel2, schemePastel1, schemePaired, schemeObservable10, schemeDark2, schemeAccent, schemeCategory10, schemeSpectral, schemeRdYlGn, schemeRdYlBu, schemeRdGy, schemeRdBu, schemePuOr, schemePiYG, schemePRGn, schemeBrBG, schemeYlOrRd, schemeYlOrBr, schemeYlGn, schemeYlGnBu, schemeRdPu, schemePuRd, schemePuBu, schemePuBuGn, schemeOrRd, schemeGnBu, schemeBuPu, schemeBuGn, schemeReds, schemePurples, schemeOranges, schemeGreys, schemeGreens, schemeBlues } from 'd3-scale-chromatic';
38
31
  import { saveAs } from 'file-saver';
39
32
  import initGdalJs from 'gdal3.js';
40
33
  import { validate } from '@orioro/validate';
34
+ import { buffer } from '@turf/turf';
41
35
  import { csvParse } from 'd3-dsv';
36
+ import { strAutoCast } from '@orioro/cast';
42
37
 
43
38
  function _arrayLikeToArray(r, a) {
44
39
  (null == a || a > r.length) && (a = r.length);
@@ -515,427 +510,10 @@ function _unsupportedIterableToArray(r, a) {
515
510
  }
516
511
  }
517
512
 
518
- var _assign$1 = function __assign() {
519
- _assign$1 = Object.assign || function __assign(t) {
520
- for (var s, i = 1, n = arguments.length; i < n; i++) {
521
- s = arguments[i];
522
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
523
- }
524
- return t;
525
- };
526
- return _assign$1.apply(this, arguments);
527
- };
528
- function __rest$1(s, e) {
529
- var t = {};
530
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
531
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
532
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
533
- }
534
- return t;
535
- }
536
- function __spreadArray$1(to, from, pack) {
537
- for (var i = 0, l = from.length, ar; i < l; i++) {
538
- if (ar || !(i in from)) {
539
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
540
- ar[i] = from[i];
541
- }
542
- }
543
- return to.concat(ar || Array.prototype.slice.call(from));
544
- }
545
- function __makeTemplateObject$1(cooked, raw) {
546
- if (Object.defineProperty) {
547
- Object.defineProperty(cooked, "raw", {
548
- value: raw
549
- });
550
- } else {
551
- cooked.raw = raw;
552
- }
553
- return cooked;
554
- }
555
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
556
- var e = new Error(message);
557
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
558
- };
559
- var CollapsibleContent_slideDown$1 = keyframes(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject$1(["\n from {\n height: 0;\n }\n to {\n height: var(--radix-collapsible-content-height);\n }\n"], ["\n from {\n height: 0;\n }\n to {\n height: var(--radix-collapsible-content-height);\n }\n"])));
560
- var CollapsibleContent_slideUp$1 = keyframes(templateObject_2$4$1 || (templateObject_2$4$1 = __makeTemplateObject$1(["\n from {\n height: var(--radix-collapsible-content-height);\n }\n to {\n height: 0;\n }\n"], ["\n from {\n height: var(--radix-collapsible-content-height);\n }\n to {\n height: 0;\n }\n"])));
561
- var CollapsibleContent$1 = styled(Collapsible.Content)(templateObject_3$1$1 || (templateObject_3$1$1 = __makeTemplateObject$1(["\n overflow: hidden;\n &[data-state='open'] {\n animation: ", " 100ms ease-out;\n }\n &[data-state='closed'] {\n animation: ", " 100ms ease-out;\n }\n"], ["\n overflow: hidden;\n &[data-state='open'] {\n animation: ", " 100ms ease-out;\n }\n &[data-state='closed'] {\n animation: ", " 100ms ease-out;\n }\n"])), CollapsibleContent_slideDown$1, CollapsibleContent_slideUp$1);
562
- var templateObject_1$6, templateObject_2$4$1, templateObject_3$1$1;
563
- var CollapsibleTrigger = styled(Collapsible.Trigger)(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject$1(["\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: center;\n\n background-color: var(--dir-nav-surface-color);\n color: var(--accent-9);\n border: none;\n padding: 6px 8px;\n font-size: 1rem;\n cursor: pointer;\n\n > div:first-child {\n display: flex;\n flex-shrink: 0;\n flex-grow: 0;\n margin-left: -6px;\n margin-right: 10px;\n }\n\n &[data-state='open'] {\n border-bottom: 1px solid var(--dir-nav-separator-color);\n }\n"], ["\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: center;\n\n background-color: var(--dir-nav-surface-color);\n color: var(--accent-9);\n border: none;\n padding: 6px 8px;\n font-size: 1rem;\n cursor: pointer;\n\n > div:first-child {\n display: flex;\n flex-shrink: 0;\n flex-grow: 0;\n margin-left: -6px;\n margin-right: 10px;\n }\n\n &[data-state='open'] {\n border-bottom: 1px solid var(--dir-nav-separator-color);\n }\n"])));
564
- var templateObject_1$5;
565
- var Container$3 = styled.div(templateObject_1$4$1 || (templateObject_1$4$1 = __makeTemplateObject$1(["\n &:not(:last-child) {\n border-bottom: 1px solid var(--dir-nav-separator-color);\n }\n"], ["\n &:not(:last-child) {\n border-bottom: 1px solid var(--dir-nav-separator-color);\n }\n"])));
566
- var EmptyNodeList = styled.div(templateObject_2$3$1 || (templateObject_2$3$1 = __makeTemplateObject$1(["\n padding: var(--dir-nav-base-padding);\n"], ["\n padding: var(--dir-nav-base-padding);\n"])));
567
- var DefaultDirContainer = styled.div(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject$1([""], [""])));
568
- var DefaultItemContainer$1 = styled.div(templateObject_4$2 || (templateObject_4$2 = __makeTemplateObject$1([""], [""])));
569
- function DefaultDirLabel(_a) {
570
- var node = _a.node;
571
- return /*#__PURE__*/React.createElement(TextEllipsis, {
572
- style: {
573
- textAlign: 'left'
574
- }
575
- }, node.label);
576
- }
577
- function makeDir(config) {
578
- var _a = (config === null || config === void 0 ? void 0 : config.components) || {},
579
- _b = _a.DirLabel,
580
- DirLabel = _b === void 0 ? DefaultDirLabel : _b,
581
- _c = _a.DirContainer,
582
- DirContainer = _c === void 0 ? DefaultDirContainer : _c,
583
- _d = _a.ItemContainer,
584
- ItemContainer = _d === void 0 ? DefaultItemContainer$1 : _d;
585
- return function Dir(_a) {
586
- var _b, _c;
587
- var node = _a.node,
588
- depth = _a.depth,
589
- NodeList = _a.NodeList;
590
- var _d = useState(false),
591
- open = _d[0],
592
- setOpen = _d[1];
593
- //
594
- // Do not sort nodes, respect their natural order
595
- // so that sorting is done outside
596
- //
597
- // TODO: review API
598
- //
599
- var _byType = useMemo(function () {
600
- return groupBy(node.childNodes, function (node) {
601
- return node.type === 'dir' ? 'dir' : 'item';
602
- });
603
- }, [node.childNodes]);
604
- // const _byType = useSortedNodesByType(node.childNodes)
605
- return /*#__PURE__*/React.createElement(Container$3, null, /*#__PURE__*/React.createElement(Collapsible.Root, {
606
- open: open,
607
- onOpenChange: setOpen
608
- }, /*#__PURE__*/React.createElement(CollapsibleTrigger, null, /*#__PURE__*/React.createElement("div", {
609
- style: {
610
- paddingLeft: depth * 10
611
- }
612
- }, /*#__PURE__*/React.createElement(Icon, {
613
- style: {
614
- transform: open ? 'rotateZ(90deg)' : 'rotateZ(0)'
615
- },
616
- path: mdiChevronRight,
617
- size: "20px"
618
- }), /*#__PURE__*/React.createElement(Icon, {
619
- path: open ? mdiFolderOpen : mdiFolder,
620
- size: "20px"
621
- })), /*#__PURE__*/React.createElement(DirLabel, {
622
- node: node,
623
- depth: depth,
624
- open: open
625
- })), /*#__PURE__*/React.createElement(CollapsibleContent$1, null, ((_b = _byType.dir) === null || _b === void 0 ? void 0 : _b.length) > 0 ? (/*#__PURE__*/React.createElement(DirContainer, null, /*#__PURE__*/React.createElement(NodeList, {
626
- nodes: _byType.dir,
627
- depth: depth + 1
628
- }))) : null, ((_c = _byType.item) === null || _c === void 0 ? void 0 : _c.length) > 0 ? (/*#__PURE__*/React.createElement(ItemContainer, null, /*#__PURE__*/React.createElement(NodeList, {
629
- nodes: _byType.item,
630
- depth: depth + 1
631
- }))) : null, Object.keys(_byType).length === 0 ? (/*#__PURE__*/React.createElement(EmptyNodeList, null, "N\xE3o h\xE1 conte\xFAdo")) : null)));
632
- };
633
- }
634
- var templateObject_1$4$1, templateObject_2$3$1, templateObject_3$3, templateObject_4$2;
635
- var DirNavContext = /*#__PURE__*/createContext({
636
- onSelectItem: undefined
637
- });
638
- function Item$1(_a) {
639
- var node = _a.node,
640
- depth = _a.depth;
641
- var onSelectItem = useContext(DirNavContext).onSelectItem;
642
- var onClick = useMemo(function () {
643
- return typeof onSelectItem === 'function' ? function () {
644
- return onSelectItem(node);
645
- } : undefined;
646
- }, [onSelectItem, node]);
647
- return /*#__PURE__*/React.createElement("div", {
648
- style: {
649
- paddingLeft: depth * 10
650
- }
651
- }, /*#__PURE__*/React.createElement(Button, {
652
- style: {
653
- width: '100%',
654
- justifyContent: 'flex-start',
655
- textAlign: 'left'
656
- },
657
- type: "Button",
658
- radius: "none",
659
- onClick: onClick
660
- }, /*#__PURE__*/React.createElement(TextEllipsis, null, node.label)));
661
- }
662
- function makeDirTree(config) {
663
- var _a;
664
- var Dir = makeDir(config);
665
- return makeTreeRenderer({
666
- components: {
667
- dir: Dir,
668
- item: ((_a = config === null || config === void 0 ? void 0 : config.components) === null || _a === void 0 ? void 0 : _a.Item) || Item$1
669
- }
670
- });
671
- }
672
- var HeaderContainer = styled.div(templateObject_1$3$1 || (templateObject_1$3$1 = __makeTemplateObject$1(["\n background-color: var(--dir-nav-surface-color);\n padding: var(--dir-nav-base-padding);\n border-bottom: 1px solid var(--dir-nav-separator-color);\n height: var(--dir-nav-section-header-height);\n flex-shrink: 0;\n flex-grow: 0;\n\n display: flex;\n flex-direction: column;\n align-items: stretch;\n justify-content: center;\n box-sizing: border-box;\n"], ["\n background-color: var(--dir-nav-surface-color);\n padding: var(--dir-nav-base-padding);\n border-bottom: 1px solid var(--dir-nav-separator-color);\n height: var(--dir-nav-section-header-height);\n flex-shrink: 0;\n flex-grow: 0;\n\n display: flex;\n flex-direction: column;\n align-items: stretch;\n justify-content: center;\n box-sizing: border-box;\n"])));
673
- var ContentContainer = styled.div(templateObject_2$2$1 || (templateObject_2$2$1 = __makeTemplateObject$1(["\n overflow: auto;\n flex-grow: 1;\n flex-shrink: 1;\n background-color: var(--dir-nav-background-color);\n"], ["\n overflow: auto;\n flex-grow: 1;\n flex-shrink: 1;\n background-color: var(--dir-nav-background-color);\n"])));
674
- function NavSection(_a) {
675
- var header = _a.header,
676
- children = _a.children;
677
- return /*#__PURE__*/React.createElement(Flex, {
678
- direction: "column",
679
- height: "100%"
680
- }, /*#__PURE__*/React.createElement(HeaderContainer, null, header), /*#__PURE__*/React.createElement(ContentContainer, null, children));
681
- }
682
- var templateObject_1$3$1, templateObject_2$2$1;
683
- var SingleChildBadge = styled.div(templateObject_1$2$2 || (templateObject_1$2$2 = __makeTemplateObject$1(["\n font-size: var(--font-size-1);\n background-color: var(--color-surface);\n color: var(--gray-12);\n padding-left: var(--space-2);\n padding-right: var(--space-2);\n height: var(--space-5);\n\n display: flex;\n align-items: center;\n border-radius: 4px;\n border: 1px solid var(--gray-5);\n"], ["\n font-size: var(--font-size-1);\n background-color: var(--color-surface);\n color: var(--gray-12);\n padding-left: var(--space-2);\n padding-right: var(--space-2);\n height: var(--space-5);\n\n display: flex;\n align-items: center;\n border-radius: 4px;\n border: 1px solid var(--gray-5);\n"])));
684
- function makeDirSection(config) {
685
- var DirTree = makeDirTree(config);
686
- return function DirSection(_a) {
687
- var _b;
688
- var node = _a.node,
689
- tree = _a.tree;
690
- var childNodes = tree.childIds(node.id).map(function (id) {
691
- return tree.node(id);
692
- });
693
- var _c = useState(((_b = childNodes[0]) === null || _b === void 0 ? void 0 : _b.id) || null),
694
- tabId = _c[0],
695
- setTabId = _c[1];
696
- return /*#__PURE__*/React.createElement(NavSection, {
697
- header: /*#__PURE__*/React.createElement(Flex, {
698
- direction: "row",
699
- alignItems: "center",
700
- justifyContent: "space-between",
701
- gap: "10px"
702
- }, /*#__PURE__*/React.createElement(Heading, {
703
- as: "h2",
704
- size: "5",
705
- style: {
706
- // maxWidth: '60%',
707
- color: 'var(--accent-9)'
708
- }
709
- }, /*#__PURE__*/React.createElement(TextEllipsis, {
710
- maxLines: 2
711
- }, node.label)), childNodes.length === 1 ? (/*#__PURE__*/React.createElement(SingleChildBadge, null, childNodes[0].label)) : (/*#__PURE__*/React.createElement(Select.Root, {
712
- size: "1",
713
- value: tabId,
714
- onValueChange: setTabId
715
- }, /*#__PURE__*/React.createElement(Select.Trigger, null), /*#__PURE__*/React.createElement(Select.Content, null, childNodes.map(function (childNode) {
716
- return /*#__PURE__*/React.createElement(Select.Item, {
717
- key: "".concat(node.id, "_").concat(childNode.id),
718
- value: childNode.id
719
- }, childNode.label);
720
- })))))
721
- }, /*#__PURE__*/React.createElement(DirTree, {
722
- tree: tree,
723
- rootNodeId: tabId
724
- }));
725
- };
726
- }
727
- var templateObject_1$2$2;
728
- var index = optionsIndexer({
729
- getOptionSearchCorpus: function getOptionSearchCorpus(option) {
730
- return [option.label, option.value, option.keywords].flat(1).filter(Boolean).join(' ');
731
- }
732
- // getOptionSearchCorpus: (option)
733
- });
734
- var DefaultItemContainer = styled.div(templateObject_1$1$2 || (templateObject_1$1$2 = __makeTemplateObject$1([""], [""])));
735
- var UsageInstructions = styled.div(templateObject_2$1$1 || (templateObject_2$1$1 = __makeTemplateObject$1(["\n padding: calc(1.5 * var(--dir-nav-base-padding));\n text-align: center;\n font-size: 0.9rem;\n"], ["\n padding: calc(1.5 * var(--dir-nav-base-padding));\n text-align: center;\n font-size: 0.9rem;\n"])));
736
- function makeSearchSection(config) {
737
- var _a = (config === null || config === void 0 ? void 0 : config.components) || {},
738
- _b = _a.ItemContainer,
739
- ItemContainer = _b === void 0 ? DefaultItemContainer : _b,
740
- _c = _a.Item,
741
- Item$1$1 = _c === void 0 ? Item$1 : _c;
742
- return function SearchSection(_a) {
743
- var tree = _a.tree;
744
- var _b = useState(''),
745
- textSearch = _b[0],
746
- setTextSearch = _b[1];
747
- var queryInputRef = useRef(null);
748
- var search = useMemo(function () {
749
- return index(tree.nodeArray().filter(function (node) {
750
- return node.type === 'item';
751
- }).map(function (node) {
752
- return {
753
- value: node.id,
754
- label: node.label,
755
- keywords: node.keywords
756
- };
757
- }));
758
- }, [tree]);
759
- var searchResults = useMemo(function () {
760
- var nodesById = tree.nodesById();
761
- return search(textSearch).map(function (option) {
762
- return nodesById[option.value];
763
- });
764
- }, [search, textSearch]);
765
- return /*#__PURE__*/React.createElement(NavSection, {
766
- header: /*#__PURE__*/React.createElement(TextInput, {
767
- ref: queryInputRef,
768
- value: textSearch,
769
- onSetValue: setTextSearch,
770
- validate: false,
771
- placeholder: "Pesquisar indicadores"
772
- })
773
- }, textSearch && (searchResults.length > 0 ? (/*#__PURE__*/React.createElement(ItemContainer, null, search(textSearch).map(function (option, index) {
774
- return /*#__PURE__*/React.createElement(Item$1$1, {
775
- key: index,
776
- node: tree.node(option.value),
777
- depth: 0,
778
- textSearch: textSearch
779
- });
780
- }))) : (/*#__PURE__*/React.createElement(UsageInstructions, null, /*#__PURE__*/React.createElement(Flex, {
781
- direction: "column",
782
- gap: "10px",
783
- alignItems: "center"
784
- }, /*#__PURE__*/React.createElement("div", null, "N\xE3o h\xE1 resultados correspondentes \xE0 sua busca"), /*#__PURE__*/React.createElement(Button, {
785
- size: "1",
786
- variant: "ghost",
787
- type: "button",
788
- onClick: function onClick() {
789
- var _a;
790
- (_a = queryInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
791
- setTextSearch('');
792
- }
793
- }, "Limpar busca ", /*#__PURE__*/React.createElement(Icon, {
794
- path: mdiClose,
795
- size: "16px"
796
- })))))), !textSearch && (/*#__PURE__*/React.createElement(UsageInstructions, null, "Pesquise por indicadores digitando termos de interesse, ou navegue pelos temas nas abas \xE0 esquerda.")));
797
- // return (
798
- // <Flex direction="column">
799
- // </Flex>
800
- // )
801
- };
802
- }
803
- var templateObject_1$1$2, templateObject_2$1$1;
804
- var IconTabTrigger = styled(Tabs.Trigger)(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject$1(["\n padding: 0;\n border: none;\n\n width: var(--dir-nav-tab-button-size);\n height: var(--dir-nav-tab-button-size);\n flex-shrink: 0;\n\n background-color: var(--dir-nav-surface-color);\n\n transition:\n color 0.3s ease,\n background-color 0.3s ease;\n\n border-bottom: solid 1px var(--gray-7);\n\n color: var(--accent-9);\n\n &:hover,\n &:focus {\n background-color: var(--accent-5);\n }\n\n &[data-state='active'] {\n background-color: var(--accent-9);\n color: white;\n cursor: default;\n }\n\n > div {\n cursor: pointer;\n\n width: var(--dir-nav-tab-button-size);\n height: var(--dir-nav-tab-button-size);\n display: flex;\n align-items: center;\n justify-content: center;\n\n svg {\n height: calc(0.6 * var(--dir-nav-tab-button-size));\n width: calc(0.6 * var(--dir-nav-tab-button-size));\n }\n }\n"], ["\n padding: 0;\n border: none;\n\n width: var(--dir-nav-tab-button-size);\n height: var(--dir-nav-tab-button-size);\n flex-shrink: 0;\n\n background-color: var(--dir-nav-surface-color);\n\n transition:\n color 0.3s ease,\n background-color 0.3s ease;\n\n border-bottom: solid 1px var(--gray-7);\n\n color: var(--accent-9);\n\n &:hover,\n &:focus {\n background-color: var(--accent-5);\n }\n\n &[data-state='active'] {\n background-color: var(--accent-9);\n color: white;\n cursor: default;\n }\n\n > div {\n cursor: pointer;\n\n width: var(--dir-nav-tab-button-size);\n height: var(--dir-nav-tab-button-size);\n display: flex;\n align-items: center;\n justify-content: center;\n\n svg {\n height: calc(0.6 * var(--dir-nav-tab-button-size));\n width: calc(0.6 * var(--dir-nav-tab-button-size));\n }\n }\n"])));
805
- var TabsRoot = styled(Tabs.Root)(templateObject_2$5 || (templateObject_2$5 = __makeTemplateObject$1(["\n > * {\n height: 100%;\n }\n"], ["\n > * {\n height: 100%;\n }\n"])));
806
- function defaultGetNodeIcon(node) {
807
- return /*#__PURE__*/React.createElement(Icon, {
808
- path: mdiFolderOutline,
809
- size: "30px"
810
- });
811
- }
812
- function DefaultEmptySection() {
813
- return /*#__PURE__*/React.createElement(NavSection, {
814
- header: /*#__PURE__*/React.createElement("div", null, null)
815
- }, null);
816
- }
817
- function makeDirNav(config) {
818
- if (config === void 0) {
819
- config = {};
820
- }
821
- var DirSection = makeDirSection(config);
822
- var SearchSection = makeSearchSection(config);
823
- // const EmptySection = config.components?.EmptySection || DefaultEmptySection
824
- return function DirNav(_a) {
825
- var items = _a.items,
826
- _b = _a.getNodeIcon,
827
- getNodeIcon = _b === void 0 ? defaultGetNodeIcon : _b,
828
- _c = _a.sideBarBottom,
829
- sideBarBottom = _c === void 0 ? null : _c,
830
- _d = _a.style,
831
- style = _d === void 0 ? {} : _d,
832
- onSelectItem = _a.onSelectItem;
833
- __rest$1(_a, ["items", "getNodeIcon", "sideBarBottom", "style", "onSelectItem"]);
834
- var tree = useMemo(function () {
835
- var paths = items.map(function (item) {
836
- return item.path;
837
- }).filter(function (path) {
838
- return typeof path === 'string' && path !== '';
839
- });
840
- var dirNodes = nodesFromPaths(paths);
841
- return treeModel()(__spreadArray$1(__spreadArray$1([], dirNodes.map(function (node) {
842
- return _assign$1(_assign$1({}, node), {
843
- type: 'dir'
844
- });
845
- }), true), items.map(function (item) {
846
- return _assign$1(_assign$1({}, item), {
847
- parentId: item.path ? nodeIdFromPath(item.path) : null,
848
- type: 'item'
849
- });
850
- })));
851
- }, [items]);
852
- return /*#__PURE__*/React.createElement(DirNavContext.Provider, {
853
- value: {
854
- onSelectItem: onSelectItem
855
- }
856
- }, /*#__PURE__*/React.createElement(TabsRoot, {
857
- orientation: "vertical",
858
- defaultValue: "_search",
859
- style: _assign$1(_assign$1({}, style), {
860
- height: '100%',
861
- '--dir-nav-section-header-height': '80px',
862
- '--dir-nav-tab-button-size': '60px',
863
- '--dir-nav-surface-color': 'var(--accent-2)',
864
- '--dir-nav-background-color': 'var(--accent-4)',
865
- '--dir-nav-separator-color': 'var(--accent-5)',
866
- '--dir-nav-base-padding': '10px'
867
- })
868
- }, /*#__PURE__*/React.createElement(Flex, {
869
- direction: "row",
870
- gap: "0",
871
- height: "100%",
872
- width: "100%"
873
- }, /*#__PURE__*/React.createElement(Tabs.List, {
874
- asChild: true
875
- }, /*#__PURE__*/React.createElement(Flex, {
876
- direction: "column",
877
- gap: "0",
878
- style: {
879
- flexGrow: 0,
880
- flexShrink: 0,
881
- borderRight: '1px solid var(--gray-5)',
882
- backgroundColor: 'var(--dir-nav-surface-color)'
883
- },
884
- width: "var(--dir-nav-tab-button-size)"
885
- }, items.length > 0 ? (/*#__PURE__*/React.createElement(IconTabTrigger, {
886
- value: "_search",
887
- style: {
888
- height: 'var(--dir-nav-section-header-height)'
889
- }
890
- }, /*#__PURE__*/React.createElement(Tooltip, {
891
- side: "right",
892
- content: "Busca"
893
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Icon, {
894
- path: mdiMagnify
895
- }))))) : null, tree.rootNodeIds().map(function (id) {
896
- return /*#__PURE__*/React.createElement(IconTabTrigger, {
897
- key: id,
898
- value: id
899
- }, /*#__PURE__*/React.createElement(Tooltip, {
900
- side: "right",
901
- content: tree.node(id).label
902
- }, /*#__PURE__*/React.createElement("div", null, getNodeIcon(tree.node(id)) || tree.node(id).label)));
903
- }), sideBarBottom)), /*#__PURE__*/React.createElement("div", {
904
- style: {
905
- height: '100%',
906
- flexGrow: 1,
907
- flexShrink: 1
908
- }
909
- }, items.length > 0 ? (/*#__PURE__*/React.createElement(Tabs.Content, {
910
- value: "_search",
911
- style: {
912
- height: '100%',
913
- width: '100%'
914
- }
915
- }, /*#__PURE__*/React.createElement(SearchSection, {
916
- tree: tree
917
- }))) : (/*#__PURE__*/React.createElement(DefaultEmptySection, null)), tree.rootNodeIds().map(function (id) {
918
- return /*#__PURE__*/React.createElement(Tabs.Content, {
919
- key: id,
920
- value: id,
921
- style: {
922
- height: '100%',
923
- width: '100%'
924
- }
925
- }, /*#__PURE__*/React.createElement(DirSection, {
926
- node: tree.node(id),
927
- tree: tree
928
- }));
929
- })))));
930
- };
931
- }
932
- makeDirNav();
933
- var templateObject_1$7, templateObject_2$5;
934
-
935
- var CollapsibleContent_slideDown = keyframes(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject$2(["\n from {\n height: 0;\n }\n to {\n height: var(--radix-collapsible-content-height);\n }\n"], ["\n from {\n height: 0;\n }\n to {\n height: var(--radix-collapsible-content-height);\n }\n"])));
936
- var CollapsibleContent_slideUp = keyframes(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject$2(["\n from {\n height: var(--radix-collapsible-content-height);\n }\n to {\n height: 0;\n }\n"], ["\n from {\n height: var(--radix-collapsible-content-height);\n }\n to {\n height: 0;\n }\n"])));
937
- var CollapsibleContent = styled(Collapsible.Content)(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject$2(["\n overflow: hidden;\n &[data-state='open'] {\n animation: ", " 100ms ease-out;\n }\n &[data-state='closed'] {\n animation: ", " 100ms ease-out;\n }\n"], ["\n overflow: hidden;\n &[data-state='open'] {\n animation: ", " 100ms ease-out;\n }\n &[data-state='closed'] {\n animation: ", " 100ms ease-out;\n }\n"])), CollapsibleContent_slideDown, CollapsibleContent_slideUp);
938
- var templateObject_1$4, templateObject_2$4, templateObject_3$2;
513
+ var CollapsibleContent_slideDown = keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n from {\n height: 0;\n }\n to {\n height: var(--radix-collapsible-content-height);\n }\n"], ["\n from {\n height: 0;\n }\n to {\n height: var(--radix-collapsible-content-height);\n }\n"])));
514
+ var CollapsibleContent_slideUp = keyframes(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n from {\n height: var(--radix-collapsible-content-height);\n }\n to {\n height: 0;\n }\n"], ["\n from {\n height: var(--radix-collapsible-content-height);\n }\n to {\n height: 0;\n }\n"])));
515
+ var CollapsibleContent = styled(Collapsible.Content)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n overflow: hidden;\n &[data-state='open'] {\n animation: ", " 100ms ease-out;\n }\n &[data-state='closed'] {\n animation: ", " 100ms ease-out;\n }\n"], ["\n overflow: hidden;\n &[data-state='open'] {\n animation: ", " 100ms ease-out;\n }\n &[data-state='closed'] {\n animation: ", " 100ms ease-out;\n }\n"])), CollapsibleContent_slideDown, CollapsibleContent_slideUp);
516
+ var templateObject_1, templateObject_2, templateObject_3;
939
517
 
940
518
  var REMARK_PLUGINS = [].concat(_toConsumableArray(MARKDOWN_DEFAULT_REMARK_PLUGINS), [remarkMath]);
941
519
  var REHYPE_PLUGINS = [].concat(_toConsumableArray(MARKDOWN_DEFAULT_REHYPE_PLUGINS), [rehypeKatex]);
@@ -1021,15 +599,15 @@ function ViewConfTabs(_ref) {
1021
599
  }).filter(Boolean);
1022
600
  }, [viewSpec]);
1023
601
  var dialogs = useDialogs();
1024
- return /*#__PURE__*/React.createElement(Tabs$1.Root, {
602
+ return /*#__PURE__*/React.createElement(Tabs.Root, {
1025
603
  defaultValue: ((_enabledTabs$ = enabledTabs[0]) === null || _enabledTabs$ === void 0 ? void 0 : _enabledTabs$.id) || null
1026
604
  }, /*#__PURE__*/React.createElement(Flex, {
1027
605
  direction: "row",
1028
606
  gap: "0"
1029
- }, /*#__PURE__*/React.createElement(Tabs$1.List, {
607
+ }, /*#__PURE__*/React.createElement(Tabs.List, {
1030
608
  size: "1"
1031
609
  }, enabledTabs.map(function (tab) {
1032
- return /*#__PURE__*/React.createElement(Tabs$1.Trigger, {
610
+ return /*#__PURE__*/React.createElement(Tabs.Trigger, {
1033
611
  key: tab.id,
1034
612
  value: tab.id
1035
613
  }, /*#__PURE__*/React.createElement(Tooltip, {
@@ -1144,7 +722,7 @@ function ViewConfTabs(_ref) {
1144
722
  return Boolean(value);
1145
723
  }));
1146
724
  var tabConfValue = immediateViewConf[tab.id];
1147
- return /*#__PURE__*/React.createElement(Tabs$1.Content, {
725
+ return /*#__PURE__*/React.createElement(Tabs.Content, {
1148
726
  key: tab.id,
1149
727
  value: tab.id
1150
728
  }, /*#__PURE__*/React.createElement(Box, {
@@ -1171,7 +749,7 @@ function ViewConfTabs(_ref) {
1171
749
 
1172
750
  var _excluded$3 = ["textSearch", "content", "maxLines"];
1173
751
  var _templateObject$3, _templateObject2$2;
1174
- var Container$2 = styled(Box)(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n --view-control-base-padding: 12px;\n box-shadow:\n rgba(0, 0, 0, 0.12) 0px 1px 3px,\n rgba(0, 0, 0, 0.24) 0px 1px 2px;\n\n border-radius: 2px;\n background-color: var(--redus-bege, white);\n // background-color: var(--accent-4, white);\n"])));
752
+ var Container = styled(Box)(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n --view-control-base-padding: 12px;\n box-shadow:\n rgba(0, 0, 0, 0.12) 0px 1px 3px,\n rgba(0, 0, 0, 0.24) 0px 1px 2px;\n\n border-radius: 2px;\n background-color: var(--redus-bege, white);\n // background-color: var(--accent-4, white);\n"])));
1175
753
  var Summary = styled.div(_templateObject2$2 || (_templateObject2$2 = _taggedTemplateLiteral(["\n // background-color: var(--redus-bege, white);\n background-color: ", ";\n padding: 0;\n\n transition: background-color 0.1s ease-out;\n\n display: flex;\n border: none;\n text-align: left;\n width: 100%;\n\n cursor: pointer;\n\n &:hover {\n // background-color: color-mix(in srgb, var(--redus-bege) 80%, white);\n background-color: ", ";\n }\n\n &:active {\n filter: brightness(96%);\n }\n"])), function (_ref) {
1176
754
  var $active = _ref.$active;
1177
755
  return $active ? 'var(--redus-bege, white)' : 'var(--accent-2)';
@@ -1238,7 +816,7 @@ function ViewControl(_ref8) {
1238
816
  }, [active, deactivateView, setView]);
1239
817
  return /*#__PURE__*/React.createElement(Collapsible.Root, {
1240
818
  open: configurable === true && active
1241
- }, /*#__PURE__*/React.createElement(Container$2, null, /*#__PURE__*/React.createElement(Summary, {
819
+ }, /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(Summary, {
1242
820
  type: "button",
1243
821
  role: "button",
1244
822
  style: style,
@@ -1706,7 +1284,7 @@ function LeftPanel(_ref) {
1706
1284
  // variant="surface"
1707
1285
  }, /*#__PURE__*/React.createElement(Tooltip, {
1708
1286
  content: open ? 'Fechar painel' : 'Abrir painel'
1709
- }, /*#__PURE__*/React.createElement(Icon$1, {
1287
+ }, /*#__PURE__*/React.createElement(Icon, {
1710
1288
  style: {
1711
1289
  transition: 'transform .2s ease-out',
1712
1290
  transform: "rotateZ(".concat(open ? '0' : '180', "deg)")
@@ -1803,7 +1381,7 @@ function LeftPanel(_ref) {
1803
1381
  }
1804
1382
  }, _callee);
1805
1383
  }))
1806
- }, /*#__PURE__*/React.createElement(Icon$1, {
1384
+ }, /*#__PURE__*/React.createElement(Icon, {
1807
1385
  path: mdiShareVariantOutline,
1808
1386
  size: "24px"
1809
1387
  })))
@@ -1880,7 +1458,7 @@ var ViewLayoutSortable = makeSortableMultiList({
1880
1458
  borderBottomLeftRadius: DRAG_HANDLE_BORDER_RADIUS,
1881
1459
  height: CONTROL_HEIGHT
1882
1460
  }
1883
- }), /*#__PURE__*/React.createElement(Icon$1, {
1461
+ }), /*#__PURE__*/React.createElement(Icon, {
1884
1462
  path: mdiDragVertical,
1885
1463
  size: "24px"
1886
1464
  })), /*#__PURE__*/React.createElement(Flex, {
@@ -2001,7 +1579,7 @@ function ViewLayoutPopover(_ref) {
2001
1579
  return /*#__PURE__*/React.createElement(Popover.Root, null, /*#__PURE__*/React.createElement(Popover.Trigger, null, /*#__PURE__*/React.createElement(Button, _extends({
2002
1580
  variant: activeViewCount > 0 ? 'solid' : 'soft',
2003
1581
  size: "1"
2004
- }, props), /*#__PURE__*/React.createElement(Icon$1, {
1582
+ }, props), /*#__PURE__*/React.createElement(Icon, {
2005
1583
  path: mdiLayers,
2006
1584
  size: "16px"
2007
1585
  }), " Camadas ativas", ' ', activeViewCount ? "(".concat(activeViewCount, ")") : null)), /*#__PURE__*/React.createElement(Popover.Content, {
@@ -2025,837 +1603,12 @@ function ViewLayoutPopover(_ref) {
2025
1603
  }, "Nenhuma camada ativa"), /*#__PURE__*/React.createElement(Popover.Close, null, /*#__PURE__*/React.createElement(IconButton, {
2026
1604
  size: "1",
2027
1605
  variant: "ghost"
2028
- }, /*#__PURE__*/React.createElement(Icon$1, {
1606
+ }, /*#__PURE__*/React.createElement(Icon, {
2029
1607
  path: mdiClose,
2030
1608
  size: "16px"
2031
1609
  }))))));
2032
1610
  }
2033
1611
 
2034
- function sortLayers(layers, _a) {
2035
- var existingLayers = _a.existingLayers;
2036
- var existingLayersById = existingLayers ? Object.fromEntries(existingLayers.map(function (layer) {
2037
- return [layer.id, layer];
2038
- })) : {};
2039
- //
2040
- // Apply ordering to layers
2041
- //
2042
- // About layer ordering:
2043
- // - Later in the list → Rendered on top (higher z-index).
2044
- // - Earlier in the list → Rendered below.
2045
- //
2046
- return layers.map(function (layer, index) {
2047
- return __assign(__assign({}, layer), {
2048
- //
2049
- // Allow for zIndex overriding
2050
- // In case no zIndex is set, respect the order in which
2051
- // layers were provided.
2052
- //
2053
- // Layers that come after are rendered on top of previous layers
2054
- //
2055
- zIndex: typeof layer.zIndex === 'number' ? layer.zIndex : index
2056
- });
2057
- })
2058
- //
2059
- // Order layers in ascending zIndex order, so that
2060
- // layers with higher zIndex are rendered later and on top of
2061
- // previous ones
2062
- //
2063
- .sort(function (layerA, layerB) {
2064
- return layerA.zIndex >= layerB.zIndex ? 1 : -1;
2065
- }).map(function (layer, index, sortedLayers) {
2066
- if (index === sortedLayers.length - 1) {
2067
- // is last layer
2068
- return layer;
2069
- } else {
2070
- var beforeId = sortedLayers[index + 1].id;
2071
- //
2072
- // If the layer this layer should be placed before exists,
2073
- // set beforeId. Otherwise, ignore beforeId.
2074
- //
2075
- // This handles the scenario in which layers are being added
2076
- // simultaneously
2077
- //
2078
- return existingLayersById[beforeId] ? __assign(__assign({}, layer), {
2079
- beforeId: beforeId
2080
- }) : layer;
2081
- }
2082
- });
2083
- }
2084
- function getSrcLayer(parsed, layerId) {
2085
- return parsed.layers.find(function (layer) {
2086
- return layer.id === layerId;
2087
- }) || null;
2088
- }
2089
- /**
2090
- * Given a layerId, attempts to retrieve the source mapView
2091
- *
2092
- * @param {MapViewsParseResult} parsed [description]
2093
- * @param {string} layerId [description]
2094
- * @param {[type]} [description]
2095
- * @return {MapView} [description]
2096
- */
2097
- function getSrcViewByLayerId(parsed, layerId) {
2098
- var layer = getSrcLayer(parsed, layerId);
2099
- return layer ? parsed.srcMapViews.find(function (view) {
2100
- return view.id === layer.viewId;
2101
- }) || null : null;
2102
- }
2103
- function augmentFeature(parsed, feature) {
2104
- //
2105
- // Augment the feature with the mapView property
2106
- //
2107
- var mapView = getSrcViewByLayerId(parsed, feature.layer.id);
2108
- var layer = getSrcLayer(parsed, feature.layer.id);
2109
- return __assign(__assign({}, feature), {
2110
- layer: layer,
2111
- mapView: mapView
2112
- });
2113
- }
2114
- function parseMapViews(orderedViews, _a) {
2115
- var _b = _a === void 0 ? {} : _a,
2116
- existingLayers = _b.existingLayers;
2117
- var parsed = orderedViews.reduce(function (acc, _a) {
2118
- var viewId = _a.id,
2119
- sources = _a.sources,
2120
- layers = _a.layers;
2121
- var _sources = isPlainObject$1(sources) ? Object.entries(sources).reduce(function (acc, _a) {
2122
- var sourceRelativeId = _a[0],
2123
- source = _a[1];
2124
- return !source ? acc : __spreadArray$2(__spreadArray$2([], acc, true), [__assign(__assign({}, source), {
2125
- viewId: viewId,
2126
- id: source.absoluteId ? source.absoluteId : "".concat(viewId, "__").concat(sourceRelativeId)
2127
- })], false);
2128
- }, []) : [];
2129
- var _b = isPlainObject$1(layers) ? Object.entries(layers).reduce(function (acc, _a) {
2130
- var layerRelativeId = _a[0],
2131
- layer = _a[1];
2132
- if (!layer) {
2133
- return acc;
2134
- }
2135
- var layerId = layer.absoluteId ? layer.absoluteId : "".concat(viewId, "__").concat(layerRelativeId);
2136
- return {
2137
- interactiveLayerIds: layer.interactive ? __spreadArray$2(__spreadArray$2([], acc.interactiveLayerIds, true), [layerId], false) : acc.interactiveLayerIds,
2138
- _layers: __spreadArray$2(__spreadArray$2([], acc._layers, true), [__assign(__assign({}, layer), {
2139
- viewId: viewId,
2140
- id: layerId,
2141
- source: layer.absoluteSourceId ? layer.absoluteSourceId : "".concat(viewId, "__").concat(layer.source)
2142
- })], false)
2143
- };
2144
- }, {
2145
- interactiveLayerIds: [],
2146
- _layers: []
2147
- }) : {
2148
- _layers: [],
2149
- interactiveLayerIds: []
2150
- },
2151
- _layers = _b._layers,
2152
- interactiveLayerIds = _b.interactiveLayerIds;
2153
- return {
2154
- sources: __spreadArray$2(__spreadArray$2([], acc.sources, true), _sources, true),
2155
- layers: __spreadArray$2(__spreadArray$2([], acc.layers, true), _layers, true),
2156
- interactiveLayerIds: __spreadArray$2(__spreadArray$2([], acc.interactiveLayerIds, true), interactiveLayerIds, true)
2157
- };
2158
- }, {
2159
- sources: [],
2160
- layers: [],
2161
- interactiveLayerIds: []
2162
- });
2163
- return {
2164
- srcMapViews: orderedViews,
2165
- sources: uniqBy(parsed.sources, 'id'),
2166
- layers: sortLayers(uniqBy(parsed.layers, 'id'), {
2167
- existingLayers: existingLayers
2168
- }),
2169
- interactiveLayerIds: uniq(parsed.interactiveLayerIds)
2170
- };
2171
- }
2172
-
2173
- // import { mergeRefs } from 'react-merge-refs'
2174
- //
2175
- // Augment mouse events with info from original view
2176
- //
2177
- var VIEW_AUGMENTED_EVENT_HANDLERS = ['onMouseDown', 'onMouseUp', 'onMouseOver',
2178
- //
2179
- // There is no notion of mouseenter/mouseleave
2180
- // in maplibre.gl
2181
- //
2182
- // https://github.com/mapbox/mapbox-gl-js/issues/10594
2183
- // https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapEventType/#mouseout
2184
- //
2185
- // 'onMouseEnter',
2186
- // 'onMouseLeave',
2187
- 'onMouseMove', 'onMouseOut', 'onClick', 'onDblClick', 'onContextMenu'];
2188
- function useViewAugmentedEventHandlers(props, parsedMapViews) {
2189
- var handlers = Object.fromEntries(VIEW_AUGMENTED_EVENT_HANDLERS.map(function (handlerName) {
2190
- return typeof props[handlerName] === 'function' ? [handlerName, function (evt) {
2191
- var _a;
2192
- return props[handlerName](__assign(__assign({}, evt), {
2193
- features: (_a = evt.features) === null || _a === void 0 ? void 0 : _a.map(function (feat) {
2194
- return augmentFeature(parsedMapViews, feat);
2195
- })
2196
- }));
2197
- }] : null;
2198
- }).filter(Boolean));
2199
- return handlers;
2200
- }
2201
- var LayeredMap = /*#__PURE__*/forwardRef(function LayeredMapInner(_a, layeredMapRef) {
2202
- var views = _a.views,
2203
- _b = _a.interactiveLayerIds,
2204
- interactiveLayerIdsInput = _b === void 0 ? [] : _b,
2205
- children = _a.children;
2206
- _a.hover;
2207
- var mapProps = __rest$2(_a, ["views", "interactiveLayerIds", "children", "hover"]);
2208
- var mapRef = useRef(null);
2209
- //
2210
- // Parse sources, layers and interactiveLayerIds from
2211
- // views spec
2212
- //
2213
- var parsed = useMemo(function () {
2214
- var _a;
2215
- return views ? parseMapViews(views, {
2216
- existingLayers: mapRef.current ? ((_a = mapRef.current.getStyle()) === null || _a === void 0 ? void 0 : _a.layers) || null : null
2217
- }) : {
2218
- srcMapViews: [],
2219
- sources: [],
2220
- layers: [],
2221
- interactiveLayerIds: []
2222
- };
2223
- }, [views, mapRef.current]);
2224
- var evtHandlers = useViewAugmentedEventHandlers(mapProps, parsed);
2225
- useImperativeHandle(layeredMapRef, function () {
2226
- return {
2227
- map: mapRef.current,
2228
- augmentFeature: augmentFeature.bind(null, parsed),
2229
- getSrcViewByLayerId: getSrcViewByLayerId.bind(null, parsed),
2230
- getSrcLayer: getSrcLayer.bind(null, parsed)
2231
- };
2232
- }, [mapRef.current, parsed]);
2233
- return /*#__PURE__*/React.createElement(Map, __assign({
2234
- ref: mapRef,
2235
- interactiveLayerIds: __spreadArray$2(__spreadArray$2([], interactiveLayerIdsInput, true), parsed.interactiveLayerIds, true)
2236
- }, mapProps, evtHandlers), children, parsed.sources.map(function (_a) {
2237
- var id = _a.id;
2238
- _a.viewId;
2239
- var source = __rest$2(_a, ["id", "viewId"]);
2240
- return /*#__PURE__*/React.createElement(Source, __assign({
2241
- key: id,
2242
- id: id
2243
- }, source));
2244
- }), parsed.layers.map(function (_a) {
2245
- var id = _a.id,
2246
- layer = __rest$2(_a, ["id"]);
2247
- return /*#__PURE__*/React.createElement(Layer, __assign({
2248
- key: id,
2249
- id: id
2250
- }, layer));
2251
- }));
2252
- });
2253
- var Container$1 = styled.div(templateObject_1$2$1 || (templateObject_1$2$1 = __makeTemplateObject$2(["\n pointer-events: none;\n position: absolute;\n z-index: 2;\n\n background: rgba(0, 0, 0, 0.5);\n border-radius: 16px;\n box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);\n backdrop-filter: blur(5px);\n -webkit-backdrop-filter: blur(5px);\n border: 1px solid rgba(0, 0, 0, 0.3);\n\n // background-color: black;\n color: white;\n border-radius: 5px;\n font-size: 0.9rem;\n\n max-width: 300px;\n\n hyphens: auto;\n word-break: break-word; /* Avoids overflow */\n overflow-wrap: break-word; /* Ensures long words break */\n white-space: normal;\n"], ["\n pointer-events: none;\n position: absolute;\n z-index: 2;\n\n background: rgba(0, 0, 0, 0.5);\n border-radius: 16px;\n box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);\n backdrop-filter: blur(5px);\n -webkit-backdrop-filter: blur(5px);\n border: 1px solid rgba(0, 0, 0, 0.3);\n\n // background-color: black;\n color: white;\n border-radius: 5px;\n font-size: 0.9rem;\n\n max-width: 300px;\n\n hyphens: auto;\n word-break: break-word; /* Avoids overflow */\n overflow-wrap: break-word; /* Ensures long words break */\n white-space: normal;\n"])));
2254
- var DataSectionHeading = styled.h3(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject$2(["\n margin: 0;\n line-height: 1.2;\n font-size: 1rem;\n"], ["\n margin: 0;\n line-height: 1.2;\n font-size: 1rem;\n"])));
2255
- var DataSectionContainer = styled(Flex)(templateObject_3$1 || (templateObject_3$1 = __makeTemplateObject$2(["\n padding: 15px 10px;\n"], ["\n padding: 15px 10px;\n"])));
2256
- var EntriesList = styled.ul(templateObject_4$1 || (templateObject_4$1 = __makeTemplateObject$2(["\n padding: 0;\n list-style: none;\n margin-bottom: 0;\n > li + li {\n margin-top: 4px;\n }\n // padding: 10px;\n"], ["\n padding: 0;\n list-style: none;\n margin-bottom: 0;\n > li + li {\n margin-top: 4px;\n }\n // padding: 10px;\n"])));
2257
- function DataSection(_a) {
2258
- var title = _a.title,
2259
- entries = _a.entries,
2260
- props = __rest$2(_a, ["title", "entries"]);
2261
- return entries.length > 0 && (/*#__PURE__*/React.createElement(DataSectionContainer, __assign({
2262
- direction: "column",
2263
- gap: "10px"
2264
- }, props), title && /*#__PURE__*/React.createElement(DataSectionHeading, null, title), /*#__PURE__*/React.createElement(EntriesList, null, entries.map(function (_a, index) {
2265
- var label = _a[0],
2266
- value = _a[1];
2267
- return /*#__PURE__*/React.createElement("li", {
2268
- key: index
2269
- }, typeof label === 'string' ? /*#__PURE__*/React.createElement("span", null, label, ": ") : label, typeof value === 'string' ? (/*#__PURE__*/React.createElement("span", {
2270
- style: {
2271
- fontWeight: 'bold'
2272
- }
2273
- }, value)) : value);
2274
- }))));
2275
- }
2276
- function HoverTooltip(_a) {
2277
- var position = _a.position,
2278
- children = _a.children,
2279
- dataSections = _a.dataSections,
2280
- _b = _a.style,
2281
- style = _b === void 0 ? {} : _b;
2282
- return /*#__PURE__*/React.createElement(Container$1, {
2283
- style: __assign({
2284
- left: position[0] + 15,
2285
- top: position[1] - 20
2286
- }, style)
2287
- }, Array.isArray(dataSections) && dataSections.length > 0 && (/*#__PURE__*/React.createElement(Flex, {
2288
- direction: "column"
2289
- }, dataSections.map(function (section, index) {
2290
- return /*#__PURE__*/React.createElement(React.Fragment, {
2291
- key: index
2292
- }, /*#__PURE__*/React.createElement(DataSection, __assign({}, section)), index === dataSections.length - 1 ? null : (/*#__PURE__*/React.createElement("div", {
2293
- style: {
2294
- width: '100%',
2295
- margin: 0,
2296
- borderBottom: '1px solid currentColor'
2297
- // marginBottom: 'none',
2298
- }
2299
- })));
2300
- }))), children);
2301
- }
2302
- var templateObject_1$2$1, templateObject_2$3, templateObject_3$1, templateObject_4$1;
2303
- function syncMaps(mainMap, targetMap, _a) {
2304
- var centerOffsetPixels = _a.centerOffsetPixels;
2305
- var center = mainMap.getCenter();
2306
- var zoom = mainMap.getZoom();
2307
- var bearing = mainMap.getBearing();
2308
- var pitch = mainMap.getPitch();
2309
- if (!centerOffsetPixels || !mainMap || !targetMap) {
2310
- console.warn('could not sync maps, missing centerOffsetPixels || mainMap || targetMap');
2311
- return;
2312
- }
2313
- // Convert the center to a pixel point
2314
- var centerPoint = mainMap.project(center);
2315
- // Apply the offset
2316
- var offsetPoint = {
2317
- x: centerPoint.x + centerOffsetPixels.x,
2318
- y: centerPoint.y + centerOffsetPixels.y
2319
- };
2320
- // Convert the offset pixel back to a lngLat
2321
- var newCenter = mainMap.unproject(offsetPoint);
2322
- // Move the mini-map to the new center
2323
- targetMap.jumpTo({
2324
- center: newCenter,
2325
- zoom: zoom,
2326
- bearing: bearing,
2327
- pitch: pitch
2328
- });
2329
- }
2330
- function useSyncedMaps(mainMapRef, otherMapRef, options, deps) {
2331
- useEffect(function () {
2332
- var _a, _b;
2333
- var mainMap = (_a = mainMapRef.current) === null || _a === void 0 ? void 0 : _a.getMap();
2334
- var otherMap = (_b = otherMapRef.current) === null || _b === void 0 ? void 0 : _b.getMap();
2335
- if (!mainMap || !otherMap) {
2336
- return;
2337
- }
2338
- var _syncMainToOther = function _syncMainToOther() {
2339
- syncMaps(mainMap, otherMap, options);
2340
- };
2341
- mainMap.on('move', _syncMainToOther);
2342
- _syncMainToOther();
2343
- // const _syncOtherToMain = () => {
2344
- // syncMaps(otherMap, mainMap, options)
2345
- // }
2346
- // otherMap.on('move', _syncOtherToMain)
2347
- return function () {
2348
- mainMap.off('move', _syncMainToOther);
2349
- // otherMap.off('move', _syncOtherToMain)
2350
- };
2351
- }, __spreadArray$2(__spreadArray$2([], deps, true), [options], false));
2352
- }
2353
- function getCenterOffsetPixels(mainMapContainer, targetMapContainer) {
2354
- var mainRect = mainMapContainer.getBoundingClientRect();
2355
- var targetRect = targetMapContainer.getBoundingClientRect();
2356
- var mainCenter = {
2357
- x: mainRect.left + mainRect.width / 2,
2358
- y: mainRect.top + mainRect.height / 2
2359
- };
2360
- var targetCenter = {
2361
- x: targetRect.left + targetRect.width / 2,
2362
- y: targetRect.top + targetRect.height / 2
2363
- };
2364
- return {
2365
- x: targetCenter.x - mainCenter.x,
2366
- y: targetCenter.y - mainCenter.y
2367
- };
2368
- }
2369
- var MapWindow = /*#__PURE__*/forwardRef(function MapWindowInner(_a, externalRef) {
2370
- var externalOnLoad = _a.onLoad,
2371
- mapProps = __rest$2(_a, ["onLoad"]);
2372
- var mapRef = /*#__PURE__*/createRef(null);
2373
- var mergedRef = mergeRefs([externalRef, mapRef]);
2374
- var _b = useState(null),
2375
- centerOffsetPixels = _b[0],
2376
- setCenterOffsetPixels = _b[1];
2377
- var _c = useState(false),
2378
- mapReady = _c[0],
2379
- setMapReady = _c[1];
2380
- var parentMapRef = useMap();
2381
- console.log('parentMapRef', parentMapRef);
2382
- useSyncedMaps(parentMapRef, mapRef, {
2383
- centerOffsetPixels: centerOffsetPixels
2384
- }, [centerOffsetPixels, mapReady]);
2385
- var _onLoad = useCallback(function (e) {
2386
- var _a, _b, _c, _d, _e;
2387
- var parentMap = (_a = parentMapRef.current) === null || _a === void 0 ? void 0 : _a.getMap();
2388
- var parentEl = (_c = (_b = parentMapRef.current) === null || _b === void 0 ? void 0 : _b.getContainer) === null || _c === void 0 ? void 0 : _c.call(_b);
2389
- var selfMap = e.target;
2390
- var selfEl = (_e = (_d = e.target) === null || _d === void 0 ? void 0 : _d.getContainer) === null || _e === void 0 ? void 0 : _e.call(_d);
2391
- //
2392
- // TODO: probably we need to check for parentMap load event as well.
2393
- //
2394
- if (!parentMap || !selfMap || !parentEl || !selfEl) {
2395
- console.log('MISSING', {
2396
- parentMap: parentMap,
2397
- selfMap: selfMap,
2398
- parentEl: parentEl,
2399
- selfEl: selfEl
2400
- });
2401
- return;
2402
- }
2403
- setCenterOffsetPixels(getCenterOffsetPixels(parentEl, selfEl));
2404
- setMapReady(true);
2405
- if (typeof externalOnLoad === 'function') {
2406
- externalOnLoad(e);
2407
- }
2408
- }, [setCenterOffsetPixels, setMapReady]);
2409
- return /*#__PURE__*/React.createElement(Map, __assign({
2410
- attributionControl: false
2411
- }, mapProps, {
2412
- onLoad: _onLoad,
2413
- ref: mergedRef
2414
- }));
2415
- });
2416
- var GhostCursor = styled.div(templateObject_1$1$1 || (templateObject_1$1$1 = __makeTemplateObject$2(["\n --synced-maps-ghost-cursor-size: 24px;\n position: absolute;\n\n height: 0;\n width: 0;\n color: inherit;\n\n &::before {\n content: '';\n display: block;\n background-color: currentColor;\n width: 1px;\n height: var(--synced-maps-ghost-cursor-size);\n position: absolute;\n top: calc(-1 * (var(--synced-maps-ghost-cursor-size) / 2));\n left: 0;\n }\n\n &::after {\n content: '';\n display: block;\n background-color: currentColor;\n height: 1px;\n width: var(--synced-maps-ghost-cursor-size);\n position: absolute;\n left: calc(-1 * (var(--synced-maps-ghost-cursor-size) / 2));\n top: 0;\n }\n"], ["\n --synced-maps-ghost-cursor-size: 24px;\n position: absolute;\n\n height: 0;\n width: 0;\n color: inherit;\n\n &::before {\n content: '';\n display: block;\n background-color: currentColor;\n width: 1px;\n height: var(--synced-maps-ghost-cursor-size);\n position: absolute;\n top: calc(-1 * (var(--synced-maps-ghost-cursor-size) / 2));\n left: 0;\n }\n\n &::after {\n content: '';\n display: block;\n background-color: currentColor;\n height: 1px;\n width: var(--synced-maps-ghost-cursor-size);\n position: absolute;\n left: calc(-1 * (var(--synced-maps-ghost-cursor-size) / 2));\n top: 0;\n }\n"])));
2417
- var templateObject_1$1$1;
2418
- function parseHoverInfo(index, event) {
2419
- return {
2420
- index: index,
2421
- point: [event.point.x, event.point.y],
2422
- coordinates: [event.lngLat.lng, event.lngLat.lat],
2423
- event: event
2424
- };
2425
- }
2426
- var SingleMapContainer = styled.div(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject$2([""], [""])));
2427
- function makeSyncedMaps(_a) {
2428
- var components = _a.components;
2429
- var MapComponent = components.Map;
2430
- return /*#__PURE__*/forwardRef(function SyncedMaps(_a, ref) {
2431
- var maps = _a.maps,
2432
- style = _a.style,
2433
- initialViewState = _a.initialViewState,
2434
- children = _a.children,
2435
- getTooltip = _a.tooltip,
2436
- baseMapProps = __rest$2(_a, ["maps", "style", "initialViewState", "children", "tooltip"]);
2437
- var _b = useRefByKey(),
2438
- mapInstanceRefs = _b[0],
2439
- setMapInstanceRef = _b[1];
2440
- var containerRef = useRef(null);
2441
- var _c = useState(initialViewState),
2442
- viewState = _c[0],
2443
- setViewState = _c[1];
2444
- var onSyncMove = useCallback(function (evt) {
2445
- return setViewState(evt.viewState);
2446
- }, []);
2447
- var _d = useState(false),
2448
- isDragging = _d[0],
2449
- setIsDragging = _d[1];
2450
- var onDragStart = useCallback(function () {
2451
- return setIsDragging(true);
2452
- }, [setIsDragging]);
2453
- var onDragEnd = useCallback(function () {
2454
- return setIsDragging(false);
2455
- }, [setIsDragging]);
2456
- var _e = useState(null),
2457
- hoverInfo = _e[0],
2458
- setHoverInfo = _e[1];
2459
- var _f = useState(null),
2460
- tooltips = _f[0],
2461
- setTooltips = _f[1];
2462
- var _onMouseMove = useCallback(function (index, event) {
2463
- var nextHoverInfo = parseHoverInfo(index, event);
2464
- setHoverInfo(nextHoverInfo);
2465
- setTooltips(typeof getTooltip === 'function' ? maps.map(function (_a, index) {
2466
- var _b = _a.tooltip,
2467
- tooltip = _b === void 0 ? true : _b;
2468
- if (!tooltip) {
2469
- return null;
2470
- }
2471
- return getTooltip(nextHoverInfo, mapInstanceRefs[index]) || null;
2472
- }) : null);
2473
- }, [maps]);
2474
- //
2475
- // Expose map instances
2476
- //
2477
- useImperativeHandle(ref, function () {
2478
- return {
2479
- mapInstances: mapInstanceRefs
2480
- };
2481
- }, [mapInstanceRefs]);
2482
- return /*#__PURE__*/React.createElement(Flex, {
2483
- ref: containerRef,
2484
- direction: "row",
2485
- style: __assign({
2486
- position: 'relative'
2487
- }, style || {})
2488
- }, maps.map(function (mapProps, index) {
2489
- return /*#__PURE__*/React.createElement(SingleMapContainer, {
2490
- key: mapProps.id || index,
2491
- style: {
2492
- position: 'absolute',
2493
- top: 0,
2494
- height: '100%',
2495
- left: "calc(".concat(index, " * (100% / ").concat(maps.length, "))"),
2496
- width: "calc(100% / ".concat(maps.length, ")")
2497
- }
2498
- }, !isDragging && hoverInfo && hoverInfo.index !== index ? (/*#__PURE__*/React.createElement(GhostCursor, {
2499
- style: {
2500
- position: 'absolute',
2501
- left: hoverInfo.point[0],
2502
- top: hoverInfo.point[1],
2503
- zIndex: 2
2504
- }
2505
- })) : null, !isDragging && Array.isArray(tooltips) && tooltips[index], /*#__PURE__*/React.createElement(MapComponent, __assign({
2506
- ref: setMapInstanceRef(index),
2507
- cursor: isDragging ? 'grabbing' : 'default'
2508
- }, baseMapProps, mapProps, viewState || {}, {
2509
- style: __assign(__assign({}, mapProps.style || {}), {
2510
- position: 'absolute',
2511
- top: 0,
2512
- left: 0,
2513
- width: '100%',
2514
- height: '100%'
2515
- }),
2516
- onMove: onSyncMove,
2517
- onDragStart: onDragStart,
2518
- onDragEnd: onDragEnd,
2519
- onMouseMove: function onMouseMove(event) {
2520
- return _onMouseMove(index, event);
2521
- },
2522
- //
2523
- // There is no notion of mouseenter/mouseleave
2524
- // in maplibre.gl.
2525
- //
2526
- // Use onMouseOut instead
2527
- //
2528
- // https://github.com/mapbox/mapbox-gl-js/issues/10594
2529
- // https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapEventType/#mouseout
2530
- //
2531
- onMouseOut: function onMouseOut() {
2532
- setHoverInfo(null);
2533
- setTooltips(null);
2534
- }
2535
- })));
2536
- }), children);
2537
- });
2538
- }
2539
- makeSyncedMaps({
2540
- components: {
2541
- Map: Map
2542
- }
2543
- });
2544
- var templateObject_1$3;
2545
- var DEFAULT_OPTIONS = {
2546
- padding: {
2547
- top: 60,
2548
- bottom: 60,
2549
- left: 60,
2550
- right: 60
2551
- }
2552
- };
2553
- function fitGeometry(map, geo, options) {
2554
- if (options === void 0) {
2555
- options = DEFAULT_OPTIONS;
2556
- }
2557
- var bounds = bbox(geo);
2558
- return map.fitBounds([[bounds[0], bounds[1]], [bounds[2], bounds[3]]], __assign(__assign({}, DEFAULT_OPTIONS), options));
2559
- }
2560
-
2561
- var _assign = function __assign() {
2562
- _assign = Object.assign || function __assign(t) {
2563
- for (var s, i = 1, n = arguments.length; i < n; i++) {
2564
- s = arguments[i];
2565
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
2566
- }
2567
- return t;
2568
- };
2569
- return _assign.apply(this, arguments);
2570
- };
2571
- function __rest(s, e) {
2572
- var t = {};
2573
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2574
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2575
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2576
- }
2577
- return t;
2578
- }
2579
- function __spreadArray(to, from, pack) {
2580
- for (var i = 0, l = from.length, ar; i < l; i++) {
2581
- if (ar || !(i in from)) {
2582
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
2583
- ar[i] = from[i];
2584
- }
2585
- }
2586
- return to.concat(ar || Array.prototype.slice.call(from));
2587
- }
2588
- function __makeTemplateObject(cooked, raw) {
2589
- if (Object.defineProperty) {
2590
- Object.defineProperty(cooked, "raw", {
2591
- value: raw
2592
- });
2593
- } else {
2594
- cooked.raw = raw;
2595
- }
2596
- return cooked;
2597
- }
2598
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
2599
- var e = new Error(message);
2600
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2601
- };
2602
- var LegendTitle = styled.h3(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n margin: 0;\n font-size: 0.9rem;\n line-height: 1.3;\n"], ["\n margin: 0;\n font-size: 0.9rem;\n line-height: 1.3;\n"])));
2603
- var LegendUnit = styled.span(templateObject_2$2 || (templateObject_2$2 = __makeTemplateObject(["\n font-size: 0.8rem;\n"], ["\n font-size: 0.8rem;\n"])));
2604
- function LegendLayout(_a) {
2605
- var title = _a.title,
2606
- unit = _a.unit,
2607
- children = _a.children,
2608
- _b = _a.direction,
2609
- direction = _b === void 0 ? 'column' : _b,
2610
- props = __rest(_a, ["title", "unit", "children", "direction"]);
2611
- return /*#__PURE__*/React.createElement(Flex, _assign({
2612
- direction: direction,
2613
- gap: "10px",
2614
- maxWidth: "300px"
2615
- }, props), (title || unit) && (/*#__PURE__*/React.createElement("div", {
2616
- style: {
2617
- maxWidth: direction === 'row' ? '50%' : 'none'
2618
- }
2619
- }, title && /*#__PURE__*/React.createElement(LegendTitle, null, title), unit && /*#__PURE__*/React.createElement(LegendUnit, null, "(", unit, ")"))), /*#__PURE__*/React.createElement(Flex, {
2620
- direction: "column",
2621
- justifyContent: "center",
2622
- style: {
2623
- flexGrow: 1
2624
- }
2625
- }, children));
2626
- }
2627
- var templateObject_1$2, templateObject_2$2;
2628
- var ColorDisplay = styled.div(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n background-color: var(--background-color);\n height: var(--color-legend-square-size, 20px);\n width: var(--color-legend-square-size, 20px);\n"], ["\n background-color: var(--background-color);\n height: var(--color-legend-square-size, 20px);\n width: var(--color-legend-square-size, 20px);\n"])));
2629
- var ItemLabel = styled.div(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n font-size: var(--color-legend-item-font-size, 0.9rem);\n line-height: 1.2;\n display: flex;\n align-items: center;\n"], ["\n font-size: var(--color-legend-item-font-size, 0.9rem);\n line-height: 1.2;\n display: flex;\n align-items: center;\n"])));
2630
- var STYLES_BY_SIZE = {
2631
- '1': {
2632
- '--color-legend-square-size': '14px',
2633
- '--color-legend-item-font-size': '0.8rem'
2634
- },
2635
- '2': {
2636
- '--color-legend-square-size': '20px',
2637
- '--color-legend-item-font-size': '0.9rem'
2638
- }
2639
- };
2640
- function ColorLegendItems(_a) {
2641
- var items = _a.items,
2642
- _b = _a.size,
2643
- size = _b === void 0 ? '2' : _b,
2644
- props = __rest(_a, ["items", "size"]);
2645
- return /*#__PURE__*/React.createElement(Flex, _assign({
2646
- direction: "column",
2647
- gap: "2px"
2648
- }, props), items.map(function (item, index) {
2649
- return /*#__PURE__*/React.createElement(Flex, {
2650
- key: item.id || index,
2651
- direction: "row",
2652
- alignItems: "center",
2653
- gap: size === '1' ? '8px' : '10px',
2654
- style: _assign(_assign({}, STYLES_BY_SIZE[size]), {
2655
- '--background-color': item.color
2656
- })
2657
- }, /*#__PURE__*/React.createElement(ColorDisplay, {
2658
- style: {
2659
- border: item.color === 'transparent' ? '1px dotted #555555' : '1px solid var(--background-color)'
2660
- }
2661
- }), /*#__PURE__*/React.createElement(ItemLabel, null, item.label));
2662
- }));
2663
- }
2664
- function ColorLegend(_a) {
2665
- var title = _a.title,
2666
- unit = _a.unit,
2667
- items = _a.items,
2668
- size = _a.size,
2669
- props = __rest(_a, ["title", "unit", "items", "size"]);
2670
- return /*#__PURE__*/React.createElement(LegendLayout, _assign({
2671
- title: title,
2672
- unit: unit
2673
- }, props), /*#__PURE__*/React.createElement(ColorLegendItems, {
2674
- items: items,
2675
- size: size
2676
- }));
2677
- }
2678
- var templateObject_1$1, templateObject_2$1;
2679
- var DEFAULT_FORMAT_OPTIONS = {
2680
- below: 'Abaixo de ${0}',
2681
- above: 'Acima de ${0}',
2682
- between: '${0} - ${1}',
2683
- number: [undefined, {}]
2684
- };
2685
- function parseStepsToItems(steps, options) {
2686
- if (options === void 0) {
2687
- options = DEFAULT_FORMAT_OPTIONS;
2688
- }
2689
- options = _assign(_assign({}, DEFAULT_FORMAT_OPTIONS), options);
2690
- var defaultColor = steps[0],
2691
- rest = steps.slice(1);
2692
- var castOptions = {
2693
- type: 'string',
2694
- number: options.number
2695
- };
2696
- var _cast = cast.bind(null, castOptions);
2697
- var defaultMax = rest[0];
2698
- var defaultMaxStr = _cast(defaultMax);
2699
- return __spreadArray([{
2700
- color: defaultColor,
2701
- max: defaultMax,
2702
- maxStr: defaultMaxStr,
2703
- label: typeof options.below === 'string' ? interpolate(options.below, defaultMaxStr) : typeof options.below === 'function' ? options.below(defaultMaxStr) : options.below
2704
- }], chunk(rest, 2).map(function (_a, index, arr) {
2705
- var min = _a[0],
2706
- color = _a[1];
2707
- var minStr = _cast(min);
2708
- var maxStr = index < arr.length - 1 ? _cast(arr[index + 1][0]) : null;
2709
- return {
2710
- min: min,
2711
- minStr: minStr,
2712
- maxStr: maxStr,
2713
- color: color,
2714
- label: index < arr.length - 1 ? typeof options.between === 'string' ? interpolate(options.between, [minStr, maxStr]) : options.between(minStr, maxStr) : typeof options.above === 'string' ? interpolate(options.above, minStr) : typeof options.above === 'function' ? options.above(minStr) : options.above
2715
- };
2716
- })).reverse();
2717
- }
2718
- function SequentialColorLegend(_a) {
2719
- var format = _a.format,
2720
- steps = _a.steps,
2721
- props = __rest(_a, ["format", "steps"]);
2722
- var items = useMemo(function () {
2723
- return parseStepsToItems(steps, format);
2724
- }, [steps]);
2725
- return /*#__PURE__*/React.createElement(ColorLegend, _assign({
2726
- items: items
2727
- }, props));
2728
- }
2729
- function ThresholdColorLegend(_a) {
2730
- var steps = _a.steps,
2731
- format = _a.format,
2732
- props = __rest(_a, ["steps", "format"]);
2733
- var items = useMemo(function () {
2734
- var parsed = parseStepsToItems(steps, format);
2735
- return parsed.map(function (item, index, all) {
2736
- return index === all.length - 1 ? _assign(_assign({}, item), {
2737
- label: null
2738
- }) : _assign(_assign({}, item), {
2739
- label: (/*#__PURE__*/React.createElement("div", {
2740
- style: {
2741
- transform: 'translateY(calc(50% + 1px))'
2742
- // background: 'steelblue',
2743
- }
2744
- }, item.minStr))
2745
- });
2746
- });
2747
- }, [steps]);
2748
- return /*#__PURE__*/React.createElement(ColorLegend, _assign({
2749
- items: items
2750
- }, props));
2751
- }
2752
- var Container = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding-right: calc(var(--proportional-symbol-legend-label-width) + 10px);\n // background-color: green;\n"], ["\n padding-right: calc(var(--proportional-symbol-legend-label-width) + 10px);\n // background-color: green;\n"
2753
- //
2754
- // All positioning is relative to this container
2755
- //
2756
- ])));
2757
- //
2758
- // All positioning is relative to this container
2759
- //
2760
- var PositionContainer = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n box-sizing: border-box;\n // background-color: red;\n"], ["\n position: relative;\n box-sizing: border-box;\n // background-color: red;\n"])));
2761
- var CircleSymbol = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n z-index: 2;\n box-sizing: border-box;\n position: absolute;\n bottom: 0;\n left: 50%;\n transform: translateX(-50%);\n border-radius: 100%;\n\n border: 1px solid black;\n\n width: var(--proportional-symbol-legend-item-size);\n height: var(--proportional-symbol-legend-item-size);\n"], ["\n z-index: 2;\n box-sizing: border-box;\n position: absolute;\n bottom: 0;\n left: 50%;\n transform: translateX(-50%);\n border-radius: 100%;\n\n border: 1px solid black;\n\n width: var(--proportional-symbol-legend-item-size);\n height: var(--proportional-symbol-legend-item-size);\n"])));
2762
- var CircleLabel = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n z-index: 1;\n font-size: 0.7rem;\n position: absolute;\n\n bottom: var(--proportional-symbol-legend-item-size);\n left: calc(100% + 10px);\n\n transform: translateY(70%);\n\n width: var(--proportional-symbol-legend-label-width);\n // background-color: blue;\n text-align: right;\n white-space: nowrap;\n\n &::before {\n position: absolute;\n content: '';\n display: block;\n width: calc((var(--proportional-symbol-legend-max-size) / 2) + 5px);\n border-bottom: 1px dotted #555555;\n right: calc(100% + 5px);\n bottom: calc(70% - 1px);\n }\n"], ["\n z-index: 1;\n font-size: 0.7rem;\n position: absolute;\n\n bottom: var(--proportional-symbol-legend-item-size);\n left: calc(100% + 10px);\n\n transform: translateY(70%);\n\n width: var(--proportional-symbol-legend-label-width);\n // background-color: blue;\n text-align: right;\n white-space: nowrap;\n\n &::before {\n position: absolute;\n content: '';\n display: block;\n width: calc((var(--proportional-symbol-legend-max-size) / 2) + 5px);\n border-bottom: 1px dotted #555555;\n right: calc(100% + 5px);\n bottom: calc(70% - 1px);\n }\n"])));
2763
- function Circle(_a) {
2764
- var style = _a.style,
2765
- label = _a.label;
2766
- return /*#__PURE__*/React.createElement("div", {
2767
- style: style
2768
- }, /*#__PURE__*/React.createElement(CircleSymbol, null), /*#__PURE__*/React.createElement(CircleLabel, null, label));
2769
- }
2770
- var DEFAULT_SIZE_MAX = 60;
2771
- var DEFAULT_SIZE_MIN = 15;
2772
- function ProportionalSymbolLegendItems(_a) {
2773
- var _b = _a.labelWidth,
2774
- labelWidth = _b === void 0 ? 20 : _b,
2775
- _c = _a.sizeMax,
2776
- sizeMax = _c === void 0 ? DEFAULT_SIZE_MAX : _c,
2777
- _d = _a.sizeMin,
2778
- sizeMin = _d === void 0 ? DEFAULT_SIZE_MIN : _d,
2779
- min = _a.min,
2780
- max = _a.max,
2781
- _e = _a.steps,
2782
- steps = _e === void 0 ? 4 : _e,
2783
- numberFormat = _a.numberFormat,
2784
- labelUnit = _a.labelUnit;
2785
- var sizeScale = useMemo(function () {
2786
- return scaleLinear([sizeMin, sizeMax]).domain([0, steps - 1]);
2787
- }, [sizeMin, sizeMax, steps]);
2788
- var valueScale = useMemo(function () {
2789
- return scaleLinear([min, max]).domain([0, steps - 1]);
2790
- }, [min, max, steps]);
2791
- var formatNumber = useCallback(function (number) {
2792
- if (numberFormat) {
2793
- return new Intl.NumberFormat(numberFormat[0], numberFormat[1]).format(number);
2794
- } else {
2795
- return new Intl.NumberFormat().format(number);
2796
- }
2797
- }, [numberFormat]);
2798
- var items = useMemo(function () {
2799
- return range(0, steps).reverse().map(function (step) {
2800
- return {
2801
- size: sizeScale(step),
2802
- value: valueScale(step),
2803
- label: [formatNumber(valueScale(step)), labelUnit].filter(Boolean).join(' ')
2804
- };
2805
- });
2806
- }, [steps, formatNumber, valueScale, sizeScale]);
2807
- return /*#__PURE__*/React.createElement(Container, {
2808
- style: {
2809
- '--proportional-symbol-legend-label-width': "".concat(labelWidth, "px")
2810
- }
2811
- }, /*#__PURE__*/React.createElement(PositionContainer, {
2812
- style: {
2813
- '--proportional-symbol-legend-max-size': "".concat(sizeMax, "px"),
2814
- width: sizeMax,
2815
- height: sizeMax
2816
- }
2817
- }, items.map(function (item) {
2818
- return /*#__PURE__*/React.createElement(Circle, {
2819
- key: item.value,
2820
- style: {
2821
- '--proportional-symbol-legend-item-size': "".concat(item.size, "px")
2822
- },
2823
- label: item.label
2824
- });
2825
- })));
2826
- }
2827
- function ProportionalSymbolLegend(_a) {
2828
- var title = _a.title,
2829
- unit = _a.unit,
2830
- style = _a.style,
2831
- maxWidth = _a.maxWidth,
2832
- maxHeight = _a.maxHeight,
2833
- props = __rest(_a, ["title", "unit", "style", "maxWidth", "maxHeight"]);
2834
- return /*#__PURE__*/React.createElement(LegendLayout, {
2835
- title: title,
2836
- unit: unit,
2837
- style: style,
2838
- maxWidth: maxWidth,
2839
- maxHeight: maxHeight
2840
- }, /*#__PURE__*/React.createElement(ProportionalSymbolLegendItems, _assign({}, props)));
2841
- }
2842
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
2843
- var LEGENDS = {
2844
- ColorLegend: ColorLegend,
2845
- ThresholdColorLegend: ThresholdColorLegend,
2846
- SequentialColorLegend: SequentialColorLegend,
2847
- ProportionalSymbolLegend: ProportionalSymbolLegend
2848
- };
2849
- function Legend(_a) {
2850
- var type = _a.type,
2851
- props = __rest(_a, ["type"]);
2852
- var Component = LEGENDS[type];
2853
- if (!Component) {
2854
- throw new Error("Unrecognized legend type ".concat(type));
2855
- }
2856
- return /*#__PURE__*/React.createElement(Component, _assign({}, props));
2857
- }
2858
-
2859
1612
  var worker = typeof Worker !== 'undefined' && new Worker(new URL('./GeoReDUSWorker.worker.js', import.meta.url), {
2860
1613
  type: 'module'
2861
1614
  });
@@ -5315,7 +4068,7 @@ function _reverseByKScheme(scheme, defaultColor) {
5315
4068
  defaultColor = DEFAULT_NULL_COLOR;
5316
4069
  }
5317
4070
  var scalesByK = Array.from(scheme, function (d) {
5318
- return Array.isArray(d) ? __spreadArray$2([], d, true).reverse() : null;
4071
+ return Array.isArray(d) ? __spreadArray([], d, true).reverse() : null;
5319
4072
  });
5320
4073
  var minK = scalesByK.findIndex(function (v) {
5321
4074
  return v !== null;
@@ -6146,7 +4899,7 @@ function cem_escolas_2022(config, allViewSpecs, context) {
6146
4899
  download: downloadResolver({
6147
4900
  fileNameBase: ['$template', '${0}_${1}_georedus_edu', [VARIABLE_ID, ['$get', 'municipioId']]],
6148
4901
  mainVariableId: VARIABLE_ID,
6149
- availableVariableIds: uniqBy$1(allViewSpecs.filter(function (spec) {
4902
+ availableVariableIds: uniqBy(allViewSpecs.filter(function (spec) {
6150
4903
  return Boolean(spec.variable_id);
6151
4904
  }).map(function (spec) {
6152
4905
  return {
@@ -6371,7 +5124,7 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
6371
5124
  console.warn("found variable without source source_table_id, will ignore ".concat(variable_id));
6372
5125
  return null;
6373
5126
  }
6374
- var variants = uniqBy$1(allViewSpecs.filter(function (otherViewSpec) {
5127
+ var variants = uniqBy(allViewSpecs.filter(function (otherViewSpec) {
6375
5128
  return otherViewSpec.indicator_id === indicator_id;
6376
5129
  }), function (viewSpec) {
6377
5130
  return viewSpec.variable_id;
@@ -7135,7 +5888,7 @@ function cem_saude_2024(viewSpec, allViewSpecs, context) {
7135
5888
  download: downloadResolver({
7136
5889
  fileNameBase: ['$template', '${0}_${1}_georedus_saude', [VARIABLE_ID, ['$get', 'municipioId']]],
7137
5890
  mainVariableId: VARIABLE_ID,
7138
- availableVariableIds: uniqBy$1(allViewSpecs.filter(function (spec) {
5891
+ availableVariableIds: uniqBy(allViewSpecs.filter(function (spec) {
7139
5892
  return Boolean(spec.variable_id);
7140
5893
  }).map(function (spec) {
7141
5894
  return {
@@ -7324,7 +6077,7 @@ function resolveViewSpecs(viewSpecsInput, context) {
7324
6077
  //
7325
6078
  // Group viewSpecsInput by collection_id
7326
6079
  //
7327
- var byCollectionId = groupBy$1(viewSpecsInput, function (viewSpec) {
6080
+ var byCollectionId = groupBy(viewSpecsInput, function (viewSpec) {
7328
6081
  return viewSpec.collection_id || NO_COLLECTION;
7329
6082
  });
7330
6083
  var parsedSpecs = Object.entries(byCollectionId).flatMap(function (_a) {
@@ -7342,7 +6095,7 @@ function resolveViewSpecs(viewSpecsInput, context) {
7342
6095
  // or no view spec
7343
6096
  .filter(Boolean);
7344
6097
  });
7345
- return uniqBy$1(parsedSpecs, function (viewSpec) {
6098
+ return uniqBy(parsedSpecs, function (viewSpec) {
7346
6099
  return viewSpec.id;
7347
6100
  });
7348
6101
  }
@@ -7364,7 +6117,7 @@ function viewConfReducer(state, action) {
7364
6117
  // Insert or update viewConf
7365
6118
  layout: state.layout.map(function (list, listIndex) {
7366
6119
  return __assign(__assign({}, list), {
7367
- items: listIndex === layoutIndex_1 ? uniqBy$1(__spreadArray$2(__spreadArray$2([], list.items, true), [{
6120
+ items: listIndex === layoutIndex_1 ? uniqBy(__spreadArray(__spreadArray([], list.items, true), [{
7368
6121
  id: viewConf_1.id
7369
6122
  }], false), function (item) {
7370
6123
  return item.id;
@@ -7582,7 +6335,7 @@ function _parseGeoFileMetadata() {
7582
6335
  case 2:
7583
6336
  contents = _context2.sent;
7584
6337
  geoJson = JSON.parse(contents);
7585
- geometryTypes = geoJson.type === 'FeatureCollection' ? uniq$1((geoJson.features || []).map(function (feature) {
6338
+ geometryTypes = geoJson.type === 'FeatureCollection' ? uniq((geoJson.features || []).map(function (feature) {
7586
6339
  var _feature$geometry;
7587
6340
  return (_feature$geometry = feature.geometry) === null || _feature$geometry === void 0 ? void 0 : _feature$geometry.type;
7588
6341
  })).filter(Boolean) : [];
@@ -8265,7 +7018,7 @@ function GeoReDUSInner(_ref) {
8265
7018
  payload: views[0].id
8266
7019
  });
8267
7020
  }
8268
- }, /*#__PURE__*/React.createElement(Icon$1, {
7021
+ }, /*#__PURE__*/React.createElement(Icon, {
8269
7022
  path: mdiClose,
8270
7023
  size: "20px"
8271
7024
  }))), /*#__PURE__*/React.createElement(EvenSpacedList, {