@gobolt/genesis 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -74898,11 +74898,96 @@ const ThinkingIndicator = () => /* @__PURE__ */ jsxs(ThinkingDots, { children: [
74898
74898
  /* @__PURE__ */ jsx("div", { className: "dot dot-2" }),
74899
74899
  /* @__PURE__ */ jsx("div", { className: "dot dot-3" })
74900
74900
  ] });
74901
- const Message$1 = ({ message: message2, handle, isThinking = false }) => {
74901
+ const DataTable = styled.table`
74902
+ width: 100%;
74903
+ border-collapse: collapse;
74904
+ margin-top: 10px;
74905
+ font-size: 14px;
74906
+ `;
74907
+ styled.th`
74908
+ background-color: #f8f9fa;
74909
+ padding: 8px;
74910
+ text-align: left;
74911
+ border-bottom: 1px solid #ddd;
74912
+ font-weight: 600;
74913
+ `;
74914
+ styled.td`
74915
+ padding: 8px;
74916
+ border-bottom: 1px solid #ddd;
74917
+ `;
74918
+ styled.tr`
74919
+ &:hover {
74920
+ background-color: #f5f5f5;
74921
+ }
74922
+ `;
74923
+ const DataContainer = styled.div`
74924
+ margin-top: 10px;
74925
+ `;
74926
+ const Message$1 = ({
74927
+ message: message2,
74928
+ handle,
74929
+ isThinking = false,
74930
+ data
74931
+ }) => {
74902
74932
  const isBot = handle === "bot";
74933
+ const renderData = () => {
74934
+ if (!data || data.length === 0) return null;
74935
+ const isProposalData = (item) => "title" in item && "proposal_json" in item;
74936
+ const isOwnerCountData = (item) => "owner_email" in item && "proposal_count" in item;
74937
+ const isMonthlyCountData = (item) => "creation_month" in item && "proposal_count" in item;
74938
+ if (isProposalData(data[0])) {
74939
+ return /* @__PURE__ */ jsx(DataContainer, { children: /* @__PURE__ */ jsxs(DataTable, { children: [
74940
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
74941
+ /* @__PURE__ */ jsx("th", { children: "Title" }),
74942
+ /* @__PURE__ */ jsx("th", { children: "Created At" }),
74943
+ /* @__PURE__ */ jsx("th", { children: "Updated At" })
74944
+ ] }) }),
74945
+ /* @__PURE__ */ jsx("tbody", { children: data.map((proposal, index2) => /* @__PURE__ */ jsxs("tr", { children: [
74946
+ /* @__PURE__ */ jsx("td", { children: proposal.title }),
74947
+ /* @__PURE__ */ jsx("td", { children: new Date(proposal.created_at).toLocaleDateString() }),
74948
+ /* @__PURE__ */ jsx("td", { children: new Date(proposal.updated_at).toLocaleDateString() })
74949
+ ] }, proposal.id || index2)) })
74950
+ ] }) });
74951
+ }
74952
+ if (isOwnerCountData(data[0])) {
74953
+ return /* @__PURE__ */ jsx(DataContainer, { children: /* @__PURE__ */ jsxs(DataTable, { children: [
74954
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
74955
+ /* @__PURE__ */ jsx("th", { children: "Owner Email" }),
74956
+ /* @__PURE__ */ jsx("th", { children: "Number of Proposals" })
74957
+ ] }) }),
74958
+ /* @__PURE__ */ jsx("tbody", { children: data.map((row2, index2) => /* @__PURE__ */ jsxs("tr", { children: [
74959
+ /* @__PURE__ */ jsx("td", { children: row2.owner_email }),
74960
+ /* @__PURE__ */ jsx("td", { children: row2.proposal_count })
74961
+ ] }, index2)) })
74962
+ ] }) });
74963
+ }
74964
+ if (isMonthlyCountData(data[0])) {
74965
+ return /* @__PURE__ */ jsx(DataContainer, { children: /* @__PURE__ */ jsxs(DataTable, { children: [
74966
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
74967
+ /* @__PURE__ */ jsx("th", { children: "Month" }),
74968
+ /* @__PURE__ */ jsx("th", { children: "Number of Proposals" })
74969
+ ] }) }),
74970
+ /* @__PURE__ */ jsx("tbody", { children: data.map((row2, index2) => /* @__PURE__ */ jsxs("tr", { children: [
74971
+ /* @__PURE__ */ jsx("td", { children: new Date(2024, row2.creation_month - 1).toLocaleString(
74972
+ "default",
74973
+ { month: "long" }
74974
+ ) }),
74975
+ /* @__PURE__ */ jsx("td", { children: row2.proposal_count })
74976
+ ] }, index2)) })
74977
+ ] }) });
74978
+ }
74979
+ return /* @__PURE__ */ jsx(DataContainer, { children: /* @__PURE__ */ jsxs(DataTable, { children: [
74980
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: Object.keys(data[0]).map((key) => /* @__PURE__ */ jsx("th", { children: key }, key)) }) }),
74981
+ /* @__PURE__ */ jsx("tbody", { children: data.map((row2, index2) => /* @__PURE__ */ jsx("tr", { children: Object.values(row2).map((value2, i) => /* @__PURE__ */ jsx("td", { children: JSON.stringify(value2) }, i)) }, index2)) })
74982
+ ] }) });
74983
+ };
74903
74984
  return /* @__PURE__ */ jsxs(MessageContainer, { $isBot: isBot, children: [
74904
74985
  /* @__PURE__ */ jsx(IconContainer, { children: isBot ? /* @__PURE__ */ jsx(BotIcon, {}) : /* @__PURE__ */ jsx(UserIcon, {}) }),
74905
- /* @__PURE__ */ jsx(TextContainer, { $isBot: isBot, children: isThinking ? /* @__PURE__ */ jsx(ThinkingIndicator, {}) : handle === "bot" ? /* @__PURE__ */ jsx(Markdown, { children: message2 }) : /* @__PURE__ */ jsx(MessageText, { children: message2 }) })
74986
+ /* @__PURE__ */ jsx(TextContainer, { $isBot: isBot, children: isThinking || message2 === PROCESSING_MESSAGE ? /* @__PURE__ */ jsx(ThinkingIndicator, {}) : handle === "bot" ? /* @__PURE__ */ jsxs(Fragment, { children: [
74987
+ /* @__PURE__ */ jsx(Markdown, { children: message2 }),
74988
+ data && renderData(),
74989
+ message2 === PROCESSING_MESSAGE && /* @__PURE__ */ jsx(ThinkingIndicator, {})
74990
+ ] }) : /* @__PURE__ */ jsx(MessageText, { children: message2 }) })
74906
74991
  ] });
74907
74992
  };
74908
74993
  const getStateColors = (colors2, type4, state) => {
@@ -75314,69 +75399,468 @@ const Typography = ({
75314
75399
  }
75315
75400
  );
75316
75401
  };
75317
- const ChatContainer = styled.div`
75402
+ const getBackgroundColor = (colors2, disabled2, $variant) => {
75403
+ if ($variant === "simple") return "#F4F4F4";
75404
+ if (disabled2) return "#F4F4F4";
75405
+ return "#fff";
75406
+ };
75407
+ const TriggerWrapper = styled.div`
75318
75408
  display: flex;
75319
- flex-direction: column;
75409
+ align-items: center;
75410
+ justify-content: space-between;
75411
+ cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
75412
+ opacity: ${({ $disabled }) => $disabled ? 0.4 : 1};
75320
75413
  position: relative;
75321
- width: "100%";
75322
- max-width: "800px";
75323
- overflow: hidden;
75414
+ box-shadow: ${({ $variant }) => $variant === "simple" ? "none" : "0px 1px 2px 0px rgba(0, 0, 0, 0.12)"};
75415
+ transition: all 0.2s ease-in-out;
75416
+ min-height: ${({ $variant }) => $variant === "simple" ? "32px" : "40px"};
75417
+
75418
+ &:focus-visible {
75419
+ outline: none;
75420
+ }
75421
+
75422
+ &:focus {
75423
+ box-shadow:
75424
+ 0px 1px 2px 0px rgba(0, 0, 0, 0.12),
75425
+ 0 0 0 3px
75426
+ ${({ theme, $themeType = "primary" }) => theme.colors[$themeType].focussed.ringColor};
75427
+ }
75428
+
75429
+ ${({ $variant, theme, $disabled }) => {
75430
+ var _a;
75431
+ return $variant === "simple" ? `
75432
+ padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
75433
+ background: ${$disabled ? theme.colors.inputs.surface.disabled : "rgba(0, 0, 0, 0.04)"};
75434
+ border: none;
75435
+ border-radius: ${theme.borderRadius.BorderRadiusSm}px;
75436
+ min-height: ${({ $variant: $variant2 }) => $variant2 === "simple" ? "32px" : "40px"};
75437
+
75438
+ &:hover {
75439
+ border: none;
75440
+ }
75441
+ ` : `
75442
+ padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
75443
+ background: ${$disabled ? theme.colors.inputs.surface.disabled : (_a = theme.colors.surface.default) == null ? void 0 : _a.backgroundColor};
75444
+ border: 1px solid #9a9a9a;
75445
+ border-radius: ${theme.borderRadius.BorderRadiusSm}px;
75446
+ min-height: ${({ $variant: $variant2 }) => $variant2 === "simple" ? "32px" : "40px"};
75447
+
75448
+ &:hover {
75449
+ border-color: rgba(0, 0, 0, 0.2);
75450
+ }
75451
+ `;
75452
+ }}
75324
75453
  `;
75325
- const HeroContainer = styled.div`
75454
+ const ValueContainer = styled.div`
75326
75455
  display: flex;
75327
75456
  align-items: center;
75328
- justify-content: center;
75329
- opacity: ${({ $isVisible }) => $isVisible ? 1 : 0};
75330
- transition: opacity 0.3s ease;
75331
- `;
75332
- styled.h1`
75333
- font-family: "Helvetica", "Arial", sans-serif;
75334
- color: teal;
75335
- font-size: 24px;
75336
- text-align: center;
75337
- `;
75338
- const Subtitle = styled.p`
75339
- font-family: "Helvetica", "Arial", sans-serif;
75340
- color: #666;
75341
- font-size: 16px;
75342
- text-align: center;
75343
- `;
75344
- const ErrorMessage = styled(Subtitle)`
75345
- color: red;
75457
+ gap: ${({ theme }) => theme.sizing.Size2}px;
75458
+ flex: 1;
75459
+ padding: 4px 8px;
75346
75460
  `;
75347
- const InputContainer = styled.div`
75461
+ const ChevronContainer = styled.div`
75348
75462
  display: flex;
75349
- justify-content: center;
75350
75463
  align-items: center;
75351
- padding: 8px;
75352
- gap: 8px;
75464
+ justify-content: center;
75465
+ margin-right: ${({ $variant }) => $variant === "simple" ? "4px" : "4px"};
75466
+ margin-left: ${({ $variant }) => $variant === "simple" ? "4px" : "0"};
75353
75467
  `;
75354
- const ChatButton = styled(Button$1)`
75355
- display: flex;
75356
- justify-content: flex-end;
75357
- margin: 16px;
75468
+ const SelectTrigger2 = ({
75469
+ type: type4 = "primary",
75470
+ theme,
75471
+ state,
75472
+ value: value2,
75473
+ placeholder = "Select...",
75474
+ open,
75475
+ onClick,
75476
+ renderValue,
75477
+ options = [],
75478
+ disabled: disabled2 = false,
75479
+ variant = "none"
75480
+ }) => {
75481
+ const handleClick = React__default.useCallback(() => {
75482
+ if (disabled2) return;
75483
+ onClick == null ? void 0 : onClick();
75484
+ }, [disabled2, onClick]);
75485
+ const displayValue = React__default.useMemo(() => {
75486
+ if (!value2) return null;
75487
+ if (renderValue) return renderValue(value2);
75488
+ if (Array.isArray(value2)) {
75489
+ if (value2.length === 0) return null;
75490
+ const selectedLabels = value2.map(String).map((v) => {
75491
+ var _a;
75492
+ return (_a = options.find((opt) => opt.value === v)) == null ? void 0 : _a.label;
75493
+ }).filter(Boolean);
75494
+ return selectedLabels.length > 0 ? selectedLabels.join(", ") : `${value2.length} selected`;
75495
+ }
75496
+ const selectedOption = options.find((opt) => opt.value === String(value2));
75497
+ return (selectedOption == null ? void 0 : selectedOption.label) || value2.toString();
75498
+ }, [value2, renderValue, options]);
75499
+ return /* @__PURE__ */ jsxs(
75500
+ TriggerWrapper,
75501
+ {
75502
+ $themeType: type4,
75503
+ $state: state,
75504
+ onClick: handleClick,
75505
+ tabIndex: disabled2 ? -1 : 0,
75506
+ role: "button",
75507
+ $disabled: disabled2,
75508
+ $variant: variant,
75509
+ style: {
75510
+ backgroundColor: getBackgroundColor(theme, disabled2, variant)
75511
+ },
75512
+ children: [
75513
+ /* @__PURE__ */ jsx(ValueContainer, { $variant: variant, children: displayValue ? /* @__PURE__ */ jsx(Typography, { variant: "body2", color: disabled2 ? "copy-light" : "copy", children: displayValue }) : /* @__PURE__ */ jsx(
75514
+ Typography,
75515
+ {
75516
+ variant: "body2",
75517
+ color: disabled2 ? "copy-light" : "copy-light",
75518
+ children: placeholder
75519
+ }
75520
+ ) }),
75521
+ /* @__PURE__ */ jsx(ChevronContainer, { $variant: variant, children: /* @__PURE__ */ jsx(DropdownChevron, {}) })
75522
+ ]
75523
+ }
75524
+ );
75525
+ };
75526
+ const SelectWrapper = styled.div`
75527
+ position: relative;
75528
+ background-color: transparent;
75529
+ border-radius: 8px;
75530
+ width: auto;
75531
+
75532
+ ${({ $isFocused, theme, type: type4 = "primary" }) => $isFocused && `
75533
+ background-color: transparent;
75534
+ `}
75535
+
75536
+ ${({ disabled: disabled2, theme }) => disabled2 && `
75537
+ cursor: not-allowed;
75538
+
75539
+ &:hover {
75540
+ border-color: ${theme.colors.inputs.surface.border};
75541
+ }
75542
+ `}
75358
75543
  `;
75359
- const MessageList = styled.div`
75544
+ const SelectDropdown = styled.div`
75545
+ padding: 0px;
75546
+ border-radius: 0px;
75547
+ animation-duration: ${({ theme }) => `${theme.motion.veryfast}s`};
75548
+ transition: all ${({ theme }) => `${theme.motion.veryfast}s`}
75549
+ cubic-bezier(0.645, 0.045, 0.355, 1);
75550
+
75551
+ &.entering {
75552
+ opacity: 0;
75553
+ transform: scaleY(0.8);
75554
+ }
75555
+
75556
+ &.entered {
75557
+ opacity: 1;
75558
+ transform: scaleY(1);
75559
+ }
75560
+
75561
+ &.exiting {
75562
+ opacity: 0;
75563
+ transform: scaleY(0.8);
75564
+ }
75565
+ `;
75566
+ const MenuItem = styled.div`
75567
+ padding: 8px 12px;
75568
+ cursor: ${({ disabled: disabled2 }) => disabled2 ? "not-allowed" : "pointer"};
75569
+ background-color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.backgroundColor : "transparent"};
75570
+ color: ${({ $isSelected, disabled: disabled2, theme, type: type4 = "primary" }) => disabled2 ? theme.colors.inputs.onsurface.disabled : $isSelected ? theme.colors[type4].hover.color : theme.colors.onsurface.copy};
75360
75571
  display: flex;
75361
- flex-direction: column;
75362
- padding: 16px;
75363
- gap: 8px;
75364
- max-height: 400px;
75365
- overflow-y: auto;
75572
+ justify-content: space-between;
75573
+ align-items: center;
75574
+ transition: all ${({ theme }) => `${theme.motion.veryfast}s`} ease-in-out;
75575
+ opacity: ${({ disabled: disabled2 }) => disabled2 ? 0.5 : 1};
75576
+
75577
+ ${({ disabled: disabled2 }) => !disabled2 && `
75578
+ &:hover {
75579
+ background-color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.backgroundColor : "rgba(0, 0, 0, 0.04)"};
75580
+ color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.color : theme.colors.onsurface["copy-dark"]};
75581
+ }
75582
+
75583
+ &:active {
75584
+ background-color: ${({ theme, type: type4 = "primary" }) => theme.colors[type4].hover.backgroundColor};
75585
+ color: ${({ theme, type: type4 = "primary" }) => theme.colors[type4].hover.color};
75586
+ }
75587
+ `}
75366
75588
  `;
75367
- const Chat = ({
75368
- socketUrl = "http://localhost:3000",
75369
- isOpen = false,
75370
- messageHistory = [],
75371
- title = null,
75372
- isSimulated = false,
75373
- authToken,
75374
- overrideStyle,
75375
- onChange
75589
+ const Select = ({
75590
+ type: type4 = TYPE.primary,
75591
+ state,
75592
+ variant = "none",
75593
+ defaultValue,
75594
+ onChange,
75595
+ size = "normal",
75596
+ width = "100%",
75597
+ value: value2,
75598
+ options = [],
75599
+ placeholder,
75600
+ selectDisplayMode = "count",
75601
+ isSingleSelect = false,
75602
+ disabled: disabled2 = false,
75603
+ ...rest
75376
75604
  }) => {
75377
- const [isChatOpen, setIsChatOpen] = useState(isOpen);
75378
- const [message2, setMessage] = useState("");
75379
- const [messages2, setMessages] = useState(messageHistory);
75605
+ const [isOpen, setIsOpen] = React__default.useState(false);
75606
+ const [isFocused, setIsFocused] = React__default.useState(false);
75607
+ const [dropdownAnimation, setDropdownAnimation] = React__default.useState("entered");
75608
+ const selectReference = React__default.useRef(null);
75609
+ const { theme } = useGenesis();
75610
+ React__default.useEffect(() => {
75611
+ const handleClickOutside = (event) => {
75612
+ if (selectReference.current && !selectReference.current.contains(event.target)) {
75613
+ handleClose();
75614
+ setIsFocused(false);
75615
+ }
75616
+ };
75617
+ if (isOpen) {
75618
+ document.addEventListener("mousedown", handleClickOutside);
75619
+ }
75620
+ return () => {
75621
+ document.removeEventListener("mousedown", handleClickOutside);
75622
+ };
75623
+ }, [isOpen]);
75624
+ const handleClose = () => {
75625
+ setDropdownAnimation("exiting");
75626
+ setTimeout(() => {
75627
+ setIsOpen(false);
75628
+ setDropdownAnimation("entered");
75629
+ }, 200);
75630
+ };
75631
+ const handleTriggerClick = () => {
75632
+ if (disabled2) return;
75633
+ setIsFocused(true);
75634
+ if (isOpen) {
75635
+ handleClose();
75636
+ } else {
75637
+ setIsOpen(true);
75638
+ setDropdownAnimation("entering");
75639
+ setTimeout(() => {
75640
+ setDropdownAnimation("entered");
75641
+ }, 0);
75642
+ }
75643
+ };
75644
+ const handleOptionSelect = (optionValue) => {
75645
+ if (disabled2) return;
75646
+ let newValue;
75647
+ if (Array.isArray(value2)) {
75648
+ const stringValue = value2.map(String);
75649
+ newValue = stringValue.includes(optionValue) ? stringValue.filter((v) => v !== optionValue) : [...stringValue, optionValue];
75650
+ } else {
75651
+ newValue = optionValue;
75652
+ }
75653
+ onChange == null ? void 0 : onChange(newValue);
75654
+ if (isSingleSelect) {
75655
+ handleClose();
75656
+ }
75657
+ };
75658
+ const getSelectModeValue = (value22) => {
75659
+ if (Array.isArray(value22)) {
75660
+ if (selectDisplayMode === "count") {
75661
+ return `${value22.length} selected`;
75662
+ }
75663
+ return value22;
75664
+ }
75665
+ return value22;
75666
+ };
75667
+ const modeValue = getSelectModeValue(value2);
75668
+ return /* @__PURE__ */ jsx("div", { style: { position: "relative", width }, children: /* @__PURE__ */ jsxs(
75669
+ SelectWrapper,
75670
+ {
75671
+ ref: selectReference,
75672
+ $isFocused: isFocused,
75673
+ type: type4,
75674
+ disabled: disabled2,
75675
+ onFocus: () => !disabled2 && setIsFocused(true),
75676
+ onBlur: () => !isOpen && setIsFocused(false),
75677
+ tabIndex: disabled2 ? -1 : 0,
75678
+ children: [
75679
+ /* @__PURE__ */ jsx(
75680
+ SelectTrigger2,
75681
+ {
75682
+ theme,
75683
+ type: type4,
75684
+ state,
75685
+ value: modeValue,
75686
+ placeholder,
75687
+ open: isOpen,
75688
+ onClick: handleTriggerClick,
75689
+ options,
75690
+ disabled: disabled2,
75691
+ variant
75692
+ }
75693
+ ),
75694
+ isOpen && !disabled2 && /* @__PURE__ */ jsx(
75695
+ SelectDropdown,
75696
+ {
75697
+ type: type4,
75698
+ state,
75699
+ className: dropdownAnimation,
75700
+ style: {
75701
+ position: "absolute",
75702
+ top: "calc(100% + 4px)",
75703
+ left: 0,
75704
+ right: 0,
75705
+ zIndex: 1e3,
75706
+ backgroundColor: "white",
75707
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
75708
+ border: "1px solid #d9d9d9",
75709
+ transformOrigin: "top"
75710
+ },
75711
+ children: options.map((option) => {
75712
+ const isSelected = Array.isArray(value2) ? value2.map(String).includes(option.value) : String(value2) === option.value;
75713
+ return /* @__PURE__ */ jsxs(
75714
+ MenuItem,
75715
+ {
75716
+ onClick: () => handleOptionSelect(option.value),
75717
+ $isSelected: isSelected,
75718
+ type: type4,
75719
+ disabled: disabled2,
75720
+ children: [
75721
+ option.label,
75722
+ isSelected && /* @__PURE__ */ jsx("span", { style: { marginLeft: "8px" }, children: "✓" })
75723
+ ]
75724
+ },
75725
+ option.value
75726
+ );
75727
+ })
75728
+ }
75729
+ )
75730
+ ]
75731
+ }
75732
+ ) });
75733
+ };
75734
+ const PROCESSING_MESSAGE = "Processing your query...";
75735
+ const PREDEFINED_QUERIES = [
75736
+ "What are the most recent proposals?",
75737
+ "How many proposals does each owner have?",
75738
+ "Show me all proposals created in the last month",
75739
+ "What are the top 5 most active proposal owners?",
75740
+ "How many proposals were created in each month of this year?"
75741
+ ];
75742
+ const ChatContainer = styled.div`
75743
+ display: flex;
75744
+ flex-direction: column;
75745
+ position: relative;
75746
+ width: "100%";
75747
+ max-width: "800px";
75748
+ //overflow: hidden;
75749
+ `;
75750
+ const HeroContainer = styled.div`
75751
+ display: flex;
75752
+ align-items: center;
75753
+ justify-content: center;
75754
+ opacity: ${({ $isVisible }) => $isVisible ? 1 : 0};
75755
+ transition: opacity 0.3s ease;
75756
+ `;
75757
+ styled.h1`
75758
+ font-family: "Helvetica", "Arial", sans-serif;
75759
+ color: teal;
75760
+ font-size: 24px;
75761
+ text-align: center;
75762
+ `;
75763
+ const Subtitle = styled.p`
75764
+ font-family: "Helvetica", "Arial", sans-serif;
75765
+ color: #666;
75766
+ font-size: 16px;
75767
+ text-align: center;
75768
+ `;
75769
+ const ErrorMessage = styled(Subtitle)`
75770
+ color: red;
75771
+ `;
75772
+ const InputContainer = styled.div`
75773
+ display: flex;
75774
+ justify-content: center;
75775
+ align-items: center;
75776
+ padding: 8px;
75777
+ gap: 8px;
75778
+ `;
75779
+ const ChatButton = styled(Button$1)`
75780
+ display: flex;
75781
+ justify-content: flex-end;
75782
+ margin: 16px;
75783
+ `;
75784
+ const MessageList = styled.div`
75785
+ display: flex;
75786
+ flex-direction: column;
75787
+ padding: 16px;
75788
+ gap: 8px;
75789
+ max-height: 400px;
75790
+ overflow-y: auto;
75791
+ `;
75792
+ const ToggleContainer = styled.div`
75793
+ display: flex;
75794
+ align-items: center;
75795
+ gap: 10px;
75796
+ margin-bottom: 15px;
75797
+ padding: 0 16px;
75798
+ `;
75799
+ const ToggleSwitch = styled.label`
75800
+ position: relative;
75801
+ display: inline-block;
75802
+ width: 60px;
75803
+ height: 34px;
75804
+ `;
75805
+ const ToggleInput = styled.input`
75806
+ opacity: 0;
75807
+ width: 0;
75808
+ height: 0;
75809
+
75810
+ &:checked + span {
75811
+ background-color: teal;
75812
+ }
75813
+
75814
+ &:checked + span:before {
75815
+ transform: translateX(26px);
75816
+ }
75817
+ `;
75818
+ const ToggleSlider = styled.span`
75819
+ position: absolute;
75820
+ cursor: pointer;
75821
+ top: 0;
75822
+ left: 0;
75823
+ right: 0;
75824
+ bottom: 0;
75825
+ background-color: #ccc;
75826
+ transition: 0.4s;
75827
+ border-radius: 34px;
75828
+
75829
+ &:before {
75830
+ position: absolute;
75831
+ content: "";
75832
+ height: 26px;
75833
+ width: 26px;
75834
+ left: 4px;
75835
+ bottom: 4px;
75836
+ background-color: white;
75837
+ transition: 0.4s;
75838
+ border-radius: 50%;
75839
+ }
75840
+ `;
75841
+ const ToggleLabel = styled.span`
75842
+ font-family: "Helvetica", "Arial", sans-serif;
75843
+ color: #666;
75844
+ font-size: 14px;
75845
+ `;
75846
+ styled(Select)`
75847
+ width: 600px;
75848
+ margin-bottom: 8px;
75849
+ margin: 26px;
75850
+ `;
75851
+ const Chat = ({
75852
+ socketUrl = "http://localhost:3000",
75853
+ isOpen = false,
75854
+ messageHistory = [],
75855
+ title = null,
75856
+ isSimulated = false,
75857
+ authToken,
75858
+ overrideStyle,
75859
+ onChange
75860
+ }) => {
75861
+ const [isChatOpen, setIsChatOpen] = useState(isOpen);
75862
+ const [message2, setMessage] = useState("");
75863
+ const [messages2, setMessages] = useState(messageHistory);
75380
75864
  const [serverStatus, setServerStatus] = useState("unknown");
75381
75865
  const [serverError, setServerError] = useState("");
75382
75866
  const socketRef = useRef(null);
@@ -75386,6 +75870,9 @@ const Chat = ({
75386
75870
  const [isLocked, setIsLocked] = useState(false);
75387
75871
  const [messageStartTime, setMessageStartTime] = useState(null);
75388
75872
  const [currentQuestion, setCurrentQuestion] = useState("");
75873
+ const [isDataQueryMode, setIsDataQueryMode] = useState(false);
75874
+ const [hasReceivedResponse, setHasReceivedResponse] = useState(false);
75875
+ const timeoutRef = useRef(null);
75389
75876
  useEffect(() => {
75390
75877
  if (isSimulated) return;
75391
75878
  const socketUrlToUse = window.location.hostname === "localhost" && window.location.port === "6006" ? "http://localhost:3000" : socketUrl;
@@ -75450,27 +75937,46 @@ const Chat = ({
75450
75937
  serverReadyRef.current = true;
75451
75938
  });
75452
75939
  socket.on("message", (newMessage) => {
75940
+ console.log("\n=== Received Message Event ===");
75941
+ console.log("New Message:", newMessage);
75453
75942
  setMessages((prev2) => {
75454
75943
  if (newMessage.sender === "bot") {
75455
- if (newMessage.content === "Processing your message...") {
75944
+ if (newMessage.isThinking) {
75456
75945
  const hasThinkingMessage = prev2.some((msg) => msg.isThinking);
75457
75946
  if (hasThinkingMessage) {
75947
+ console.log("Already have thinking message, skipping");
75458
75948
  return prev2;
75459
75949
  }
75950
+ console.log("Adding thinking message");
75460
75951
  return [...prev2, { ...newMessage, isThinking: true }];
75461
75952
  }
75462
75953
  const thinkingMessage = prev2.find((msg) => msg.isThinking);
75463
75954
  if (thinkingMessage) {
75955
+ console.log("Replacing thinking message with final response");
75956
+ const updatedMessage = {
75957
+ ...newMessage,
75958
+ isThinking: false,
75959
+ content: newMessage.content || newMessage.response || "No response content"
75960
+ };
75464
75961
  return prev2.map(
75465
- (msg) => msg.isThinking ? { ...newMessage, isThinking: false } : msg
75962
+ (msg) => msg.isThinking ? updatedMessage : msg
75466
75963
  );
75467
75964
  }
75468
- return [...prev2, { ...newMessage, isThinking: false }];
75965
+ console.log("Adding new bot message");
75966
+ const messageToAdd = {
75967
+ ...newMessage,
75968
+ isThinking: false,
75969
+ content: newMessage.content || newMessage.response || "No response content"
75970
+ };
75971
+ console.log("messageToAdd", messageToAdd);
75972
+ return [...prev2, messageToAdd];
75469
75973
  }
75470
75974
  const lastUserMsg = [...prev2].reverse().find((msg) => msg.sender === "user");
75471
75975
  if (lastUserMsg && lastUserMsg.content === newMessage.content) {
75976
+ console.log("Duplicate user message, skipping");
75472
75977
  return prev2;
75473
75978
  }
75979
+ console.log("Adding new user message");
75474
75980
  return [...prev2, newMessage];
75475
75981
  });
75476
75982
  setIsLocked(false);
@@ -75501,6 +76007,44 @@ const Chat = ({
75501
76007
  setIsLocked(false);
75502
76008
  }
75503
76009
  }, 2e3);
76010
+ socket.on(
76011
+ "query_data_response",
76012
+ (response2) => {
76013
+ console.log("\n=== Received Query Data Response ===");
76014
+ console.log("Response:", response2);
76015
+ setMessages((prev2) => {
76016
+ const thinkingMessage = prev2.find((msg) => msg.isThinking);
76017
+ if (!thinkingMessage) {
76018
+ console.log("No thinking message found, adding new message");
76019
+ return [
76020
+ ...prev2,
76021
+ {
76022
+ id: `bot_${Date.now()}`,
76023
+ content: response2.error || response2.response,
76024
+ sender: "bot",
76025
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76026
+ isThinking: false,
76027
+ data: response2.data,
76028
+ respondedBy: "ai"
76029
+ }
76030
+ ];
76031
+ }
76032
+ console.log("Replacing thinking message with response");
76033
+ return prev2.map(
76034
+ (msg) => msg.isThinking ? {
76035
+ id: msg.id,
76036
+ content: response2.error || response2.response,
76037
+ sender: "bot",
76038
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76039
+ isThinking: false,
76040
+ data: response2.data,
76041
+ respondedBy: "ai"
76042
+ } : msg
76043
+ );
76044
+ });
76045
+ setIsLocked(false);
76046
+ }
76047
+ );
75504
76048
  return () => {
75505
76049
  console.log("Disconnecting socket");
75506
76050
  socket.disconnect();
@@ -75543,13 +76087,14 @@ const Chat = ({
75543
76087
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
75544
76088
  };
75545
76089
  setIsLocked(true);
76090
+ setHasReceivedResponse(false);
75546
76091
  setMessageStartTime(Date.now());
75547
76092
  setCurrentQuestion(message2);
75548
76093
  setMessages((prev2) => [...prev2, userMessage]);
75549
76094
  if ((_a = socketRef.current) == null ? void 0 : _a.connected) {
75550
76095
  const botMessageId = `bot_${timestamp}`;
75551
76096
  const thinkingMessage = {
75552
- content: "",
76097
+ content: PROCESSING_MESSAGE,
75553
76098
  sender: "bot",
75554
76099
  id: botMessageId,
75555
76100
  isThinking: true,
@@ -75562,20 +76107,72 @@ const Chat = ({
75562
76107
  setIsLocked(false);
75563
76108
  return;
75564
76109
  }
75565
- socketRef.current.emit("message", userMessage);
75566
- if (socketRef.current.connected) {
75567
- setTimeout(() => {
75568
- setMessages(
75569
- (prev2) => prev2.map(
75570
- (msg) => msg.isThinking ? { ...msg, content: "Processing your message..." } : msg
75571
- )
75572
- );
75573
- }, 300);
75574
- setTimeout(() => {
75575
- setMessages((prev2) => prev2.filter((msg) => !msg.isThinking));
75576
- setServerError("No response from server");
75577
- setIsLocked(false);
75578
- }, 1e4);
76110
+ if (isDataQueryMode) {
76111
+ socketRef.current.emit(
76112
+ "query_data",
76113
+ { query: message2 },
76114
+ (response) => {
76115
+ console.log("\n=== Query Data Callback Response ===");
76116
+ console.log("Response:", response);
76117
+ if (timeoutRef.current) {
76118
+ clearTimeout(timeoutRef.current);
76119
+ timeoutRef.current = null;
76120
+ }
76121
+ setHasReceivedResponse(true);
76122
+ setMessages((prev2) => {
76123
+ const thinkingMessage = prev2.find((msg) => msg.isThinking);
76124
+ if (!thinkingMessage) {
76125
+ console.log("No thinking message found, adding new message");
76126
+ return [
76127
+ ...prev2,
76128
+ {
76129
+ id: `bot_${Date.now()}`,
76130
+ content: response.error || response.response,
76131
+ sender: "bot",
76132
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76133
+ isThinking: false,
76134
+ data: response.data,
76135
+ respondedBy: "ai"
76136
+ }
76137
+ ];
76138
+ }
76139
+ console.log("Replacing thinking message with response");
76140
+ return prev2.map(
76141
+ (msg) => msg.isThinking ? {
76142
+ id: msg.id,
76143
+ content: response.error || response.response,
76144
+ sender: "bot",
76145
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76146
+ isThinking: false,
76147
+ data: response.data,
76148
+ respondedBy: "ai"
76149
+ } : msg
76150
+ );
76151
+ });
76152
+ setIsLocked(false);
76153
+ }
76154
+ );
76155
+ timeoutRef.current = setTimeout(() => {
76156
+ if (!hasReceivedResponse) {
76157
+ setMessages((prev2) => {
76158
+ const thinkingMessage = prev2.find((msg) => msg.isThinking);
76159
+ if (thinkingMessage) {
76160
+ return prev2.map(
76161
+ (msg) => msg.isThinking ? {
76162
+ ...msg,
76163
+ content: "The query is taking longer than expected. Please try again or rephrase your question.",
76164
+ isThinking: false,
76165
+ respondedBy: "ai"
76166
+ } : msg
76167
+ );
76168
+ }
76169
+ return prev2;
76170
+ });
76171
+ setIsLocked(false);
76172
+ }
76173
+ }, 9e4);
76174
+ } else {
76175
+ socketRef.current.emit("message", userMessage);
75579
76176
  }
75580
76177
  setMessage("");
75581
76178
  };
@@ -75611,10 +76208,28 @@ const Chat = ({
75611
76208
  if (serverStatus === "error") {
75612
76209
  return /* @__PURE__ */ jsx(ErrorMessage, { children: "Network error" });
75613
76210
  }
75614
- const uniqueMessages = messages2.filter(
75615
- (msg, index2, self2) => index2 === self2.findIndex((t2) => t2.id === msg.id)
75616
- );
76211
+ const uniqueMessages = messages2.filter((msg, index2, self2) => {
76212
+ const duplicates = self2.filter((m) => m.id === msg.id);
76213
+ if (duplicates.length > 1) {
76214
+ if (msg.respondedBy === "ai" || msg.respondedBy === "search") return true;
76215
+ if (msg.isThinking || msg.content === PROCESSING_MESSAGE) {
76216
+ return !duplicates.some(
76217
+ (m) => m.respondedBy === "ai" || m.respondedBy === "search"
76218
+ );
76219
+ }
76220
+ return false;
76221
+ }
76222
+ return true;
76223
+ });
75617
76224
  console.log("uniqueMessages", uniqueMessages);
76225
+ console.log("messages", messages2);
76226
+ useEffect(() => {
76227
+ return () => {
76228
+ if (timeoutRef.current) {
76229
+ clearTimeout(timeoutRef.current);
76230
+ }
76231
+ };
76232
+ }, []);
75618
76233
  return /* @__PURE__ */ jsxs(ChatContainer, { style: overrideStyle || {}, children: [
75619
76234
  /* @__PURE__ */ jsx(HeroContainer, { $isVisible: !isChatOpen, children: /* @__PURE__ */ jsxs("div", { children: [
75620
76235
  title && /* @__PURE__ */ jsx(Typography, { variant: "heading3", children: title }),
@@ -75623,28 +76238,63 @@ const Chat = ({
75623
76238
  ] }) }),
75624
76239
  isChatOpen ? /* @__PURE__ */ jsxs(Fragment, { children: [
75625
76240
  /* @__PURE__ */ jsx(HeroContainer, { $isVisible: true, children: /* @__PURE__ */ jsx("div", { children: title ? /* @__PURE__ */ jsx(Typography, { variant: "heading2", children: title }) : null }) }),
76241
+ /* @__PURE__ */ jsxs(ToggleContainer, { children: [
76242
+ /* @__PURE__ */ jsxs(ToggleSwitch, { children: [
76243
+ /* @__PURE__ */ jsx(
76244
+ ToggleInput,
76245
+ {
76246
+ type: "checkbox",
76247
+ checked: isDataQueryMode,
76248
+ onChange: (e2) => setIsDataQueryMode(e2.target.checked)
76249
+ }
76250
+ ),
76251
+ /* @__PURE__ */ jsx(ToggleSlider, {})
76252
+ ] }),
76253
+ /* @__PURE__ */ jsx(ToggleLabel, { children: isDataQueryMode ? "Data Query Mode" : "Regular Chat" })
76254
+ ] }),
75626
76255
  /* @__PURE__ */ jsx(MessageList, { ref: messageListRef, children: uniqueMessages.map((msg) => /* @__PURE__ */ jsx(
75627
76256
  Message$1,
75628
76257
  {
75629
76258
  message: msg.content,
75630
76259
  handle: msg.sender,
75631
- isThinking: msg.isThinking
76260
+ isThinking: msg.isThinking,
76261
+ data: msg.data
75632
76262
  },
75633
76263
  msg.id
75634
76264
  )) }),
75635
- /* @__PURE__ */ jsxs(InputContainer, { children: [
75636
- /* @__PURE__ */ jsx(
75637
- Input2,
76265
+ /* @__PURE__ */ jsxs(Fragment, { children: [
76266
+ /* @__PURE__ */ jsxs(InputContainer, { children: [
76267
+ /* @__PURE__ */ jsx("div", { style: { width: 600 }, children: /* @__PURE__ */ jsx(
76268
+ Input2,
76269
+ {
76270
+ type: "text",
76271
+ value: message2,
76272
+ onChange: handleInputChange,
76273
+ onKeyDown: handleKeyDown,
76274
+ placeholder: isDataQueryMode ? "Ask about proposals, views, or chat questions..." : "Type a message...",
76275
+ disabled: isLocked,
76276
+ style: { width: 600 }
76277
+ }
76278
+ ) }),
76279
+ /* @__PURE__ */ jsx(Button$1, { onClick: sendMessage, disabled: isLocked, children: "Send" })
76280
+ ] }),
76281
+ isDataQueryMode && /* @__PURE__ */ jsx("div", { style: { marginTop: 8, marginLeft: 8 }, children: /* @__PURE__ */ jsx(
76282
+ Select,
75638
76283
  {
75639
- type: "text",
75640
- value: message2,
75641
- onChange: handleInputChange,
75642
- onKeyDown: handleKeyDown,
75643
- placeholder: "Type a message & press Enter or Send",
75644
- disabled: isLocked
76284
+ width: 400,
76285
+ options: PREDEFINED_QUERIES.map((query) => ({
76286
+ label: query,
76287
+ value: query
76288
+ })),
76289
+ placeholder: "Select a predefined query...",
76290
+ onChange: (selected) => {
76291
+ if (selected) {
76292
+ setMessage(selected);
76293
+ }
76294
+ },
76295
+ isSingleSelect: true
75645
76296
  }
75646
- ),
75647
- /* @__PURE__ */ jsx(Button$1, { onClick: sendMessage, disabled: isLocked, children: "Send" })
76297
+ ) })
75648
76298
  ] })
75649
76299
  ] }) : /* @__PURE__ */ jsx(ChatButton, { onClick: toggleChat, children: "Chat" })
75650
76300
  ] });
@@ -78711,338 +79361,6 @@ const SegmentedControls = ({
78711
79361
  }
78712
79362
  );
78713
79363
  };
78714
- const getBackgroundColor = (colors2, disabled2, $variant) => {
78715
- if ($variant === "simple") return "#F4F4F4";
78716
- if (disabled2) return "#F4F4F4";
78717
- return "#fff";
78718
- };
78719
- const TriggerWrapper = styled.div`
78720
- display: flex;
78721
- align-items: center;
78722
- justify-content: space-between;
78723
- cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
78724
- opacity: ${({ $disabled }) => $disabled ? 0.4 : 1};
78725
- position: relative;
78726
- box-shadow: ${({ $variant }) => $variant === "simple" ? "none" : "0px 1px 2px 0px rgba(0, 0, 0, 0.12)"};
78727
- transition: all 0.2s ease-in-out;
78728
- min-height: ${({ $variant }) => $variant === "simple" ? "32px" : "40px"};
78729
-
78730
- &:focus-visible {
78731
- outline: none;
78732
- }
78733
-
78734
- &:focus {
78735
- box-shadow:
78736
- 0px 1px 2px 0px rgba(0, 0, 0, 0.12),
78737
- 0 0 0 3px
78738
- ${({ theme, $themeType = "primary" }) => theme.colors[$themeType].focussed.ringColor};
78739
- }
78740
-
78741
- ${({ $variant, theme, $disabled }) => {
78742
- var _a;
78743
- return $variant === "simple" ? `
78744
- padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
78745
- background: ${$disabled ? theme.colors.inputs.surface.disabled : "rgba(0, 0, 0, 0.04)"};
78746
- border: none;
78747
- border-radius: ${theme.borderRadius.BorderRadiusSm}px;
78748
- min-height: ${({ $variant: $variant2 }) => $variant2 === "simple" ? "32px" : "40px"};
78749
-
78750
- &:hover {
78751
- border: none;
78752
- }
78753
- ` : `
78754
- padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
78755
- background: ${$disabled ? theme.colors.inputs.surface.disabled : (_a = theme.colors.surface.default) == null ? void 0 : _a.backgroundColor};
78756
- border: 1px solid #9a9a9a;
78757
- border-radius: ${theme.borderRadius.BorderRadiusSm}px;
78758
- min-height: ${({ $variant: $variant2 }) => $variant2 === "simple" ? "32px" : "40px"};
78759
-
78760
- &:hover {
78761
- border-color: rgba(0, 0, 0, 0.2);
78762
- }
78763
- `;
78764
- }}
78765
- `;
78766
- const ValueContainer = styled.div`
78767
- display: flex;
78768
- align-items: center;
78769
- gap: ${({ theme }) => theme.sizing.Size2}px;
78770
- flex: 1;
78771
- padding: 4px 8px;
78772
- `;
78773
- const ChevronContainer = styled.div`
78774
- display: flex;
78775
- align-items: center;
78776
- justify-content: center;
78777
- margin-right: ${({ $variant }) => $variant === "simple" ? "4px" : "4px"};
78778
- margin-left: ${({ $variant }) => $variant === "simple" ? "4px" : "0"};
78779
- `;
78780
- const SelectTrigger2 = ({
78781
- type: type4 = "primary",
78782
- theme,
78783
- state,
78784
- value: value2,
78785
- placeholder = "Select...",
78786
- open,
78787
- onClick,
78788
- renderValue,
78789
- options = [],
78790
- disabled: disabled2 = false,
78791
- variant = "none"
78792
- }) => {
78793
- const handleClick = React__default.useCallback(() => {
78794
- if (disabled2) return;
78795
- onClick == null ? void 0 : onClick();
78796
- }, [disabled2, onClick]);
78797
- const displayValue = React__default.useMemo(() => {
78798
- if (!value2) return null;
78799
- if (renderValue) return renderValue(value2);
78800
- if (Array.isArray(value2)) {
78801
- if (value2.length === 0) return null;
78802
- const selectedLabels = value2.map(String).map((v) => {
78803
- var _a;
78804
- return (_a = options.find((opt) => opt.value === v)) == null ? void 0 : _a.label;
78805
- }).filter(Boolean);
78806
- return selectedLabels.length > 0 ? selectedLabels.join(", ") : `${value2.length} selected`;
78807
- }
78808
- const selectedOption = options.find((opt) => opt.value === String(value2));
78809
- return (selectedOption == null ? void 0 : selectedOption.label) || value2.toString();
78810
- }, [value2, renderValue, options]);
78811
- return /* @__PURE__ */ jsxs(
78812
- TriggerWrapper,
78813
- {
78814
- $themeType: type4,
78815
- $state: state,
78816
- onClick: handleClick,
78817
- tabIndex: disabled2 ? -1 : 0,
78818
- role: "button",
78819
- $disabled: disabled2,
78820
- $variant: variant,
78821
- style: {
78822
- backgroundColor: getBackgroundColor(theme, disabled2, variant)
78823
- },
78824
- children: [
78825
- /* @__PURE__ */ jsx(ValueContainer, { $variant: variant, children: displayValue ? /* @__PURE__ */ jsx(Typography, { variant: "body2", color: disabled2 ? "copy-light" : "copy", children: displayValue }) : /* @__PURE__ */ jsx(
78826
- Typography,
78827
- {
78828
- variant: "body2",
78829
- color: disabled2 ? "copy-light" : "copy-light",
78830
- children: placeholder
78831
- }
78832
- ) }),
78833
- /* @__PURE__ */ jsx(ChevronContainer, { $variant: variant, children: /* @__PURE__ */ jsx(DropdownChevron, {}) })
78834
- ]
78835
- }
78836
- );
78837
- };
78838
- const SelectWrapper = styled.div`
78839
- position: relative;
78840
- background-color: transparent;
78841
- border-radius: 8px;
78842
- width: auto;
78843
-
78844
- ${({ $isFocused, theme, type: type4 = "primary" }) => $isFocused && `
78845
- background-color: transparent;
78846
- `}
78847
-
78848
- ${({ disabled: disabled2, theme }) => disabled2 && `
78849
- cursor: not-allowed;
78850
-
78851
- &:hover {
78852
- border-color: ${theme.colors.inputs.surface.border};
78853
- }
78854
- `}
78855
- `;
78856
- const SelectDropdown = styled.div`
78857
- padding: 0px;
78858
- border-radius: 0px;
78859
- animation-duration: ${({ theme }) => `${theme.motion.veryfast}s`};
78860
- transition: all ${({ theme }) => `${theme.motion.veryfast}s`}
78861
- cubic-bezier(0.645, 0.045, 0.355, 1);
78862
-
78863
- &.entering {
78864
- opacity: 0;
78865
- transform: scaleY(0.8);
78866
- }
78867
-
78868
- &.entered {
78869
- opacity: 1;
78870
- transform: scaleY(1);
78871
- }
78872
-
78873
- &.exiting {
78874
- opacity: 0;
78875
- transform: scaleY(0.8);
78876
- }
78877
- `;
78878
- const MenuItem = styled.div`
78879
- padding: 8px 12px;
78880
- cursor: ${({ disabled: disabled2 }) => disabled2 ? "not-allowed" : "pointer"};
78881
- background-color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.backgroundColor : "transparent"};
78882
- color: ${({ $isSelected, disabled: disabled2, theme, type: type4 = "primary" }) => disabled2 ? theme.colors.inputs.onsurface.disabled : $isSelected ? theme.colors[type4].hover.color : theme.colors.onsurface.copy};
78883
- display: flex;
78884
- justify-content: space-between;
78885
- align-items: center;
78886
- transition: all ${({ theme }) => `${theme.motion.veryfast}s`} ease-in-out;
78887
- opacity: ${({ disabled: disabled2 }) => disabled2 ? 0.5 : 1};
78888
-
78889
- ${({ disabled: disabled2 }) => !disabled2 && `
78890
- &:hover {
78891
- background-color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.backgroundColor : "rgba(0, 0, 0, 0.04)"};
78892
- color: ${({ $isSelected, theme, type: type4 = "primary" }) => $isSelected ? theme.colors[type4].hover.color : theme.colors.onsurface["copy-dark"]};
78893
- }
78894
-
78895
- &:active {
78896
- background-color: ${({ theme, type: type4 = "primary" }) => theme.colors[type4].hover.backgroundColor};
78897
- color: ${({ theme, type: type4 = "primary" }) => theme.colors[type4].hover.color};
78898
- }
78899
- `}
78900
- `;
78901
- const Select = ({
78902
- type: type4 = TYPE.primary,
78903
- state,
78904
- variant = "none",
78905
- defaultValue,
78906
- onChange,
78907
- size = "normal",
78908
- width = "100%",
78909
- value: value2,
78910
- options = [],
78911
- placeholder,
78912
- selectDisplayMode = "count",
78913
- isSingleSelect = false,
78914
- disabled: disabled2 = false,
78915
- ...rest
78916
- }) => {
78917
- const [isOpen, setIsOpen] = React__default.useState(false);
78918
- const [isFocused, setIsFocused] = React__default.useState(false);
78919
- const [dropdownAnimation, setDropdownAnimation] = React__default.useState("entered");
78920
- const selectReference = React__default.useRef(null);
78921
- const { theme } = useGenesis();
78922
- React__default.useEffect(() => {
78923
- const handleClickOutside = (event) => {
78924
- if (selectReference.current && !selectReference.current.contains(event.target)) {
78925
- handleClose();
78926
- setIsFocused(false);
78927
- }
78928
- };
78929
- if (isOpen) {
78930
- document.addEventListener("mousedown", handleClickOutside);
78931
- }
78932
- return () => {
78933
- document.removeEventListener("mousedown", handleClickOutside);
78934
- };
78935
- }, [isOpen]);
78936
- const handleClose = () => {
78937
- setDropdownAnimation("exiting");
78938
- setTimeout(() => {
78939
- setIsOpen(false);
78940
- setDropdownAnimation("entered");
78941
- }, 200);
78942
- };
78943
- const handleTriggerClick = () => {
78944
- if (disabled2) return;
78945
- setIsFocused(true);
78946
- if (isOpen) {
78947
- handleClose();
78948
- } else {
78949
- setIsOpen(true);
78950
- setDropdownAnimation("entering");
78951
- setTimeout(() => {
78952
- setDropdownAnimation("entered");
78953
- }, 0);
78954
- }
78955
- };
78956
- const handleOptionSelect = (optionValue) => {
78957
- if (disabled2) return;
78958
- let newValue;
78959
- if (Array.isArray(value2)) {
78960
- const stringValue = value2.map(String);
78961
- newValue = stringValue.includes(optionValue) ? stringValue.filter((v) => v !== optionValue) : [...stringValue, optionValue];
78962
- } else {
78963
- newValue = optionValue;
78964
- }
78965
- onChange == null ? void 0 : onChange(newValue);
78966
- if (isSingleSelect) {
78967
- handleClose();
78968
- }
78969
- };
78970
- const getSelectModeValue = (value22) => {
78971
- if (Array.isArray(value22)) {
78972
- if (selectDisplayMode === "count") {
78973
- return `${value22.length} selected`;
78974
- }
78975
- return value22;
78976
- }
78977
- return value22;
78978
- };
78979
- const modeValue = getSelectModeValue(value2);
78980
- return /* @__PURE__ */ jsx("div", { style: { position: "relative", width }, children: /* @__PURE__ */ jsxs(
78981
- SelectWrapper,
78982
- {
78983
- ref: selectReference,
78984
- $isFocused: isFocused,
78985
- type: type4,
78986
- disabled: disabled2,
78987
- onFocus: () => !disabled2 && setIsFocused(true),
78988
- onBlur: () => !isOpen && setIsFocused(false),
78989
- tabIndex: disabled2 ? -1 : 0,
78990
- children: [
78991
- /* @__PURE__ */ jsx(
78992
- SelectTrigger2,
78993
- {
78994
- theme,
78995
- type: type4,
78996
- state,
78997
- value: modeValue,
78998
- placeholder,
78999
- open: isOpen,
79000
- onClick: handleTriggerClick,
79001
- options,
79002
- disabled: disabled2,
79003
- variant
79004
- }
79005
- ),
79006
- isOpen && !disabled2 && /* @__PURE__ */ jsx(
79007
- SelectDropdown,
79008
- {
79009
- type: type4,
79010
- state,
79011
- className: dropdownAnimation,
79012
- style: {
79013
- position: "absolute",
79014
- top: "calc(100% + 4px)",
79015
- left: 0,
79016
- right: 0,
79017
- zIndex: 1e3,
79018
- backgroundColor: "white",
79019
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
79020
- border: "1px solid #d9d9d9",
79021
- transformOrigin: "top"
79022
- },
79023
- children: options.map((option) => {
79024
- const isSelected = Array.isArray(value2) ? value2.map(String).includes(option.value) : String(value2) === option.value;
79025
- return /* @__PURE__ */ jsxs(
79026
- MenuItem,
79027
- {
79028
- onClick: () => handleOptionSelect(option.value),
79029
- $isSelected: isSelected,
79030
- type: type4,
79031
- disabled: disabled2,
79032
- children: [
79033
- option.label,
79034
- isSelected && /* @__PURE__ */ jsx("span", { style: { marginLeft: "8px" }, children: "✓" })
79035
- ]
79036
- },
79037
- option.value
79038
- );
79039
- })
79040
- }
79041
- )
79042
- ]
79043
- }
79044
- ) });
79045
- };
79046
79364
  const Circle2 = ({ fill = "#CF3237", dataTestId }) => /* @__PURE__ */ jsx(
79047
79365
  "svg",
79048
79366
  {