@gobolt/genesis 0.3.5 → 0.3.7

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,484 @@ 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 getUniqueMessages = (messages2) => {
75735
+ const uniqueMessages = messages2.filter((msg, index2, self2) => {
75736
+ const duplicates = self2.filter((m) => m.id === msg.id);
75737
+ if (duplicates.length > 1) {
75738
+ if (msg.respondedBy === "ai" || msg.respondedBy === "search") return true;
75739
+ if (msg.isThinking || msg.content === PROCESSING_MESSAGE) {
75740
+ return !duplicates.some(
75741
+ (m) => m.respondedBy === "ai" || m.respondedBy === "search"
75742
+ );
75743
+ }
75744
+ return false;
75745
+ }
75746
+ return true;
75747
+ });
75748
+ return uniqueMessages;
75749
+ };
75750
+ const PROCESSING_MESSAGE = "Processing your query...";
75751
+ const PREDEFINED_QUERIES = [
75752
+ "What are the most recent proposals?",
75753
+ "How many proposals does each owner have?",
75754
+ "Show me all proposals created in the last month",
75755
+ "What are the top 5 most active proposal owners?",
75756
+ "How many proposals were created in each month of this year?"
75757
+ ];
75758
+ const ChatContainer = styled.div`
75759
+ display: flex;
75760
+ flex-direction: column;
75761
+ position: relative;
75762
+ width: "100%";
75763
+ max-width: "800px";
75764
+ //overflow: hidden;
75765
+ `;
75766
+ const HeroContainer = styled.div`
75767
+ display: flex;
75768
+ align-items: center;
75769
+ justify-content: center;
75770
+ opacity: ${({ $isVisible }) => $isVisible ? 1 : 0};
75771
+ transition: opacity 0.3s ease;
75772
+ `;
75773
+ styled.h1`
75774
+ font-family: "Helvetica", "Arial", sans-serif;
75775
+ color: teal;
75776
+ font-size: 24px;
75777
+ text-align: center;
75778
+ `;
75779
+ const Subtitle = styled.p`
75780
+ font-family: "Helvetica", "Arial", sans-serif;
75781
+ color: #666;
75782
+ font-size: 16px;
75783
+ text-align: center;
75784
+ `;
75785
+ const ErrorMessage = styled(Subtitle)`
75786
+ color: red;
75787
+ `;
75788
+ const InputContainer = styled.div`
75789
+ display: flex;
75790
+ justify-content: center;
75791
+ align-items: center;
75792
+ padding: 8px;
75793
+ gap: 8px;
75794
+ `;
75795
+ const ChatButton = styled(Button$1)`
75796
+ display: flex;
75797
+ justify-content: flex-end;
75798
+ margin: 16px;
75799
+ `;
75800
+ const MessageList = styled.div`
75801
+ display: flex;
75802
+ flex-direction: column;
75803
+ padding: 16px;
75804
+ gap: 8px;
75805
+ max-height: 400px;
75806
+ overflow-y: auto;
75807
+ `;
75808
+ const ToggleContainer = styled.div`
75809
+ display: flex;
75810
+ align-items: center;
75811
+ gap: 10px;
75812
+ margin-bottom: 15px;
75813
+ padding: 0 16px;
75814
+ `;
75815
+ const ToggleSwitch = styled.label`
75816
+ position: relative;
75817
+ display: inline-block;
75818
+ width: 60px;
75819
+ height: 34px;
75820
+ `;
75821
+ const ToggleInput = styled.input`
75822
+ opacity: 0;
75823
+ width: 0;
75824
+ height: 0;
75825
+
75826
+ &:checked + span {
75827
+ background-color: teal;
75828
+ }
75829
+
75830
+ &:checked + span:before {
75831
+ transform: translateX(26px);
75832
+ }
75833
+ `;
75834
+ const ToggleSlider = styled.span`
75835
+ position: absolute;
75836
+ cursor: pointer;
75837
+ top: 0;
75838
+ left: 0;
75839
+ right: 0;
75840
+ bottom: 0;
75841
+ background-color: #ccc;
75842
+ transition: 0.4s;
75843
+ border-radius: 34px;
75844
+
75845
+ &:before {
75846
+ position: absolute;
75847
+ content: "";
75848
+ height: 26px;
75849
+ width: 26px;
75850
+ left: 4px;
75851
+ bottom: 4px;
75852
+ background-color: white;
75853
+ transition: 0.4s;
75854
+ border-radius: 50%;
75855
+ }
75856
+ `;
75857
+ const ToggleLabel = styled.span`
75858
+ font-family: "Helvetica", "Arial", sans-serif;
75859
+ color: #666;
75860
+ font-size: 14px;
75861
+ `;
75862
+ styled(Select)`
75863
+ width: 600px;
75864
+ margin-bottom: 8px;
75865
+ margin: 26px;
75866
+ `;
75867
+ const Chat = ({
75868
+ socketUrl = "http://localhost:3000",
75869
+ isOpen = false,
75870
+ messageHistory = [],
75871
+ title = null,
75872
+ isSimulated = false,
75873
+ authToken,
75874
+ overrideStyle,
75875
+ onChange
75876
+ }) => {
75877
+ const [isChatOpen, setIsChatOpen] = useState(isOpen);
75878
+ const [message2, setMessage] = useState("");
75879
+ const [messages2, setMessages] = useState(messageHistory);
75380
75880
  const [serverStatus, setServerStatus] = useState("unknown");
75381
75881
  const [serverError, setServerError] = useState("");
75382
75882
  const socketRef = useRef(null);
@@ -75386,10 +75886,11 @@ const Chat = ({
75386
75886
  const [isLocked, setIsLocked] = useState(false);
75387
75887
  const [messageStartTime, setMessageStartTime] = useState(null);
75388
75888
  const [currentQuestion, setCurrentQuestion] = useState("");
75889
+ const [isDataQueryMode, setIsDataQueryMode] = useState(false);
75890
+ const [hasReceivedResponse, setHasReceivedResponse] = useState(false);
75891
+ const timeoutRef = useRef(null);
75389
75892
  useEffect(() => {
75390
75893
  if (isSimulated) return;
75391
- const socketUrlToUse = window.location.hostname === "localhost" && window.location.port === "6006" ? "http://localhost:3000" : socketUrl;
75392
- console.log("Connecting to socket server at:", socketUrlToUse);
75393
75894
  const validateToken = async () => {
75394
75895
  try {
75395
75896
  const response = await fetch(
@@ -75403,7 +75904,7 @@ const Chat = ({
75403
75904
  if (!response.ok) {
75404
75905
  throw new Error("Invalid token");
75405
75906
  }
75406
- socketRef.current = lookup(socketUrlToUse, {
75907
+ socketRef.current = lookup(socketUrl, {
75407
75908
  transports: ["polling", "websocket"],
75408
75909
  reconnection: true,
75409
75910
  reconnectionAttempts: 5,
@@ -75450,27 +75951,46 @@ const Chat = ({
75450
75951
  serverReadyRef.current = true;
75451
75952
  });
75452
75953
  socket.on("message", (newMessage) => {
75954
+ console.log("\n=== Received Message Event ===");
75955
+ console.log("New Message:", newMessage);
75453
75956
  setMessages((prev2) => {
75454
75957
  if (newMessage.sender === "bot") {
75455
- if (newMessage.content === "Processing your message...") {
75958
+ if (newMessage.isThinking) {
75456
75959
  const hasThinkingMessage = prev2.some((msg) => msg.isThinking);
75457
75960
  if (hasThinkingMessage) {
75961
+ console.log("Already have thinking message, skipping");
75458
75962
  return prev2;
75459
75963
  }
75964
+ console.log("Adding thinking message");
75460
75965
  return [...prev2, { ...newMessage, isThinking: true }];
75461
75966
  }
75462
75967
  const thinkingMessage = prev2.find((msg) => msg.isThinking);
75463
75968
  if (thinkingMessage) {
75969
+ console.log("Replacing thinking message with final response");
75970
+ const updatedMessage = {
75971
+ ...newMessage,
75972
+ isThinking: false,
75973
+ content: newMessage.content || newMessage.response || "No response content"
75974
+ };
75464
75975
  return prev2.map(
75465
- (msg) => msg.isThinking ? { ...newMessage, isThinking: false } : msg
75976
+ (msg) => msg.isThinking ? updatedMessage : msg
75466
75977
  );
75467
75978
  }
75468
- return [...prev2, { ...newMessage, isThinking: false }];
75979
+ console.log("Adding new bot message");
75980
+ const messageToAdd = {
75981
+ ...newMessage,
75982
+ isThinking: false,
75983
+ content: newMessage.content || newMessage.response || "No response content"
75984
+ };
75985
+ console.log("messageToAdd", messageToAdd);
75986
+ return [...prev2, messageToAdd];
75469
75987
  }
75470
75988
  const lastUserMsg = [...prev2].reverse().find((msg) => msg.sender === "user");
75471
75989
  if (lastUserMsg && lastUserMsg.content === newMessage.content) {
75990
+ console.log("Duplicate user message, skipping");
75472
75991
  return prev2;
75473
75992
  }
75993
+ console.log("Adding new user message");
75474
75994
  return [...prev2, newMessage];
75475
75995
  });
75476
75996
  setIsLocked(false);
@@ -75501,6 +76021,44 @@ const Chat = ({
75501
76021
  setIsLocked(false);
75502
76022
  }
75503
76023
  }, 2e3);
76024
+ socket.on(
76025
+ "query_data_response",
76026
+ (response2) => {
76027
+ console.log("\n=== Received Query Data Response ===");
76028
+ console.log("Response:", response2);
76029
+ setMessages((prev2) => {
76030
+ const thinkingMessage = prev2.find((msg) => msg.isThinking);
76031
+ if (!thinkingMessage) {
76032
+ console.log("No thinking message found, adding new message");
76033
+ return [
76034
+ ...prev2,
76035
+ {
76036
+ id: `bot_${Date.now()}`,
76037
+ content: response2.error || response2.response,
76038
+ sender: "bot",
76039
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76040
+ isThinking: false,
76041
+ data: response2.data,
76042
+ respondedBy: "ai"
76043
+ }
76044
+ ];
76045
+ }
76046
+ console.log("Replacing thinking message with response");
76047
+ return prev2.map(
76048
+ (msg) => msg.isThinking ? {
76049
+ id: msg.id,
76050
+ content: response2.error || response2.response,
76051
+ sender: "bot",
76052
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76053
+ isThinking: false,
76054
+ data: response2.data,
76055
+ respondedBy: "ai"
76056
+ } : msg
76057
+ );
76058
+ });
76059
+ setIsLocked(false);
76060
+ }
76061
+ );
75504
76062
  return () => {
75505
76063
  console.log("Disconnecting socket");
75506
76064
  socket.disconnect();
@@ -75543,13 +76101,14 @@ const Chat = ({
75543
76101
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
75544
76102
  };
75545
76103
  setIsLocked(true);
76104
+ setHasReceivedResponse(false);
75546
76105
  setMessageStartTime(Date.now());
75547
76106
  setCurrentQuestion(message2);
75548
76107
  setMessages((prev2) => [...prev2, userMessage]);
75549
76108
  if ((_a = socketRef.current) == null ? void 0 : _a.connected) {
75550
76109
  const botMessageId = `bot_${timestamp}`;
75551
76110
  const thinkingMessage = {
75552
- content: "",
76111
+ content: PROCESSING_MESSAGE,
75553
76112
  sender: "bot",
75554
76113
  id: botMessageId,
75555
76114
  isThinking: true,
@@ -75562,20 +76121,72 @@ const Chat = ({
75562
76121
  setIsLocked(false);
75563
76122
  return;
75564
76123
  }
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);
76124
+ if (isDataQueryMode) {
76125
+ socketRef.current.emit(
76126
+ "query_data",
76127
+ { query: message2 },
76128
+ (response) => {
76129
+ console.log("\n=== Query Data Callback Response ===");
76130
+ console.log("Response:", response);
76131
+ if (timeoutRef.current) {
76132
+ clearTimeout(timeoutRef.current);
76133
+ timeoutRef.current = null;
76134
+ }
76135
+ setHasReceivedResponse(true);
76136
+ setMessages((prev2) => {
76137
+ const thinkingMessage = prev2.find((msg) => msg.isThinking);
76138
+ if (!thinkingMessage) {
76139
+ console.log("No thinking message found, adding new message");
76140
+ return [
76141
+ ...prev2,
76142
+ {
76143
+ id: `bot_${Date.now()}`,
76144
+ content: response.error || response.response,
76145
+ sender: "bot",
76146
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76147
+ isThinking: false,
76148
+ data: response.data,
76149
+ respondedBy: "ai"
76150
+ }
76151
+ ];
76152
+ }
76153
+ console.log("Replacing thinking message with response");
76154
+ return prev2.map(
76155
+ (msg) => msg.isThinking ? {
76156
+ id: msg.id,
76157
+ content: response.error || response.response,
76158
+ sender: "bot",
76159
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
76160
+ isThinking: false,
76161
+ data: response.data,
76162
+ respondedBy: "ai"
76163
+ } : msg
76164
+ );
76165
+ });
76166
+ setIsLocked(false);
76167
+ }
76168
+ );
76169
+ timeoutRef.current = setTimeout(() => {
76170
+ if (!hasReceivedResponse) {
76171
+ setMessages((prev2) => {
76172
+ const thinkingMessage = prev2.find((msg) => msg.isThinking);
76173
+ if (thinkingMessage) {
76174
+ return prev2.map(
76175
+ (msg) => msg.isThinking ? {
76176
+ ...msg,
76177
+ content: "The query is taking longer than expected. Please try again or rephrase your question.",
76178
+ isThinking: false,
76179
+ respondedBy: "ai"
76180
+ } : msg
76181
+ );
76182
+ }
76183
+ return prev2;
76184
+ });
76185
+ setIsLocked(false);
76186
+ }
76187
+ }, 9e4);
76188
+ } else {
76189
+ socketRef.current.emit("message", userMessage);
75579
76190
  }
75580
76191
  setMessage("");
75581
76192
  };
@@ -75611,40 +76222,82 @@ const Chat = ({
75611
76222
  if (serverStatus === "error") {
75612
76223
  return /* @__PURE__ */ jsx(ErrorMessage, { children: "Network error" });
75613
76224
  }
75614
- const uniqueMessages = messages2.filter(
75615
- (msg, index2, self2) => index2 === self2.findIndex((t2) => t2.id === msg.id)
75616
- );
76225
+ const uniqueMessages = useMemo$1(() => {
76226
+ return getUniqueMessages(messages2);
76227
+ }, [messages2]);
75617
76228
  console.log("uniqueMessages", uniqueMessages);
75618
- return /* @__PURE__ */ jsxs(ChatContainer, { style: overrideStyle || {}, children: [
75619
- /* @__PURE__ */ jsx(HeroContainer, { $isVisible: !isChatOpen, children: /* @__PURE__ */ jsxs("div", { children: [
75620
- title && /* @__PURE__ */ jsx(Typography, { variant: "heading3", children: title }),
75621
- /* @__PURE__ */ jsx(Subtitle, { children: "Click the Chat Icon below to begin" }),
76229
+ useEffect(() => {
76230
+ return () => {
76231
+ if (timeoutRef.current) {
76232
+ clearTimeout(timeoutRef.current);
76233
+ }
76234
+ };
76235
+ }, []);
76236
+ return /* @__PURE__ */ jsxs(ChatContainer, { style: overrideStyle || {}, children: [
76237
+ /* @__PURE__ */ jsx(HeroContainer, { $isVisible: !isChatOpen, children: /* @__PURE__ */ jsxs("div", { children: [
76238
+ title && /* @__PURE__ */ jsx(Typography, { variant: "heading3", children: title }),
76239
+ /* @__PURE__ */ jsx(Subtitle, { children: "Click the Chat Icon below to begin" }),
75622
76240
  serverError ? /* @__PURE__ */ jsx(ErrorMessage, { children: serverError }) : null
75623
76241
  ] }) }),
75624
76242
  isChatOpen ? /* @__PURE__ */ jsxs(Fragment, { children: [
75625
76243
  /* @__PURE__ */ jsx(HeroContainer, { $isVisible: true, children: /* @__PURE__ */ jsx("div", { children: title ? /* @__PURE__ */ jsx(Typography, { variant: "heading2", children: title }) : null }) }),
76244
+ /* @__PURE__ */ jsxs(ToggleContainer, { children: [
76245
+ /* @__PURE__ */ jsxs(ToggleSwitch, { children: [
76246
+ /* @__PURE__ */ jsx(
76247
+ ToggleInput,
76248
+ {
76249
+ type: "checkbox",
76250
+ checked: isDataQueryMode,
76251
+ onChange: (e2) => setIsDataQueryMode(e2.target.checked)
76252
+ }
76253
+ ),
76254
+ /* @__PURE__ */ jsx(ToggleSlider, {})
76255
+ ] }),
76256
+ /* @__PURE__ */ jsx(ToggleLabel, { children: isDataQueryMode ? "Data Query Mode" : "Regular Chat" })
76257
+ ] }),
75626
76258
  /* @__PURE__ */ jsx(MessageList, { ref: messageListRef, children: uniqueMessages.map((msg) => /* @__PURE__ */ jsx(
75627
76259
  Message$1,
75628
76260
  {
75629
76261
  message: msg.content,
75630
76262
  handle: msg.sender,
75631
- isThinking: msg.isThinking
76263
+ isThinking: msg.isThinking,
76264
+ data: msg.data
75632
76265
  },
75633
76266
  msg.id
75634
76267
  )) }),
75635
- /* @__PURE__ */ jsxs(InputContainer, { children: [
75636
- /* @__PURE__ */ jsx(
75637
- Input2,
76268
+ /* @__PURE__ */ jsxs(Fragment, { children: [
76269
+ /* @__PURE__ */ jsxs(InputContainer, { children: [
76270
+ /* @__PURE__ */ jsx("div", { style: { width: 600 }, children: /* @__PURE__ */ jsx(
76271
+ Input2,
76272
+ {
76273
+ type: "text",
76274
+ value: message2,
76275
+ onChange: handleInputChange,
76276
+ onKeyDown: handleKeyDown,
76277
+ placeholder: isDataQueryMode ? "Ask about proposals, views, or chat questions..." : "Type a message...",
76278
+ disabled: isLocked,
76279
+ style: { width: 600 }
76280
+ }
76281
+ ) }),
76282
+ /* @__PURE__ */ jsx(Button$1, { onClick: sendMessage, disabled: isLocked, children: "Send" })
76283
+ ] }),
76284
+ isDataQueryMode && /* @__PURE__ */ jsx("div", { style: { marginTop: 8, marginLeft: 8 }, children: /* @__PURE__ */ jsx(
76285
+ Select,
75638
76286
  {
75639
- type: "text",
75640
- value: message2,
75641
- onChange: handleInputChange,
75642
- onKeyDown: handleKeyDown,
75643
- placeholder: "Type a message & press Enter or Send",
75644
- disabled: isLocked
76287
+ width: 400,
76288
+ options: PREDEFINED_QUERIES.map((query) => ({
76289
+ label: query,
76290
+ value: query
76291
+ })),
76292
+ placeholder: "Select a predefined query...",
76293
+ onChange: (selected) => {
76294
+ if (selected) {
76295
+ setMessage(selected);
76296
+ }
76297
+ },
76298
+ isSingleSelect: true
75645
76299
  }
75646
- ),
75647
- /* @__PURE__ */ jsx(Button$1, { onClick: sendMessage, disabled: isLocked, children: "Send" })
76300
+ ) })
75648
76301
  ] })
75649
76302
  ] }) : /* @__PURE__ */ jsx(ChatButton, { onClick: toggleChat, children: "Chat" })
75650
76303
  ] });
@@ -78711,338 +79364,6 @@ const SegmentedControls = ({
78711
79364
  }
78712
79365
  );
78713
79366
  };
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
79367
  const Circle2 = ({ fill = "#CF3237", dataTestId }) => /* @__PURE__ */ jsx(
79047
79368
  "svg",
79048
79369
  {