@xinghunm/ai-chat 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -46,7 +46,10 @@ var DEFAULT_AI_CHAT_LABELS = {
46
46
  questionnaireSubmitFailed: "Failed to submit. Please try again.",
47
47
  questionnaireMultiSelectHint: "Multiple choice",
48
48
  questionnaireOtherOptionLabel: "Other",
49
- questionnaireOtherPlaceholder: "Other"
49
+ questionnaireOtherPlaceholder: "Other",
50
+ skillLoading: "Loading skills...",
51
+ skillEmpty: "No matching skills",
52
+ removeSkillAriaLabel: "Remove skill"
50
53
  };
51
54
 
52
55
  // src/lib/chat-session.ts
@@ -359,10 +362,10 @@ var createChatStore = (initialState) => createStore((set, get) => ({
359
362
  finalizeStoppedStreamingMessage: (sessionId) => {
360
363
  set((state) => finalizeStreamingMessage(state, sessionId, "stopped", true));
361
364
  },
362
- setSessionError: (sessionId, error) => {
365
+ setSessionError: (sessionId, error2) => {
363
366
  const state = get();
364
367
  set({
365
- errorBySession: { ...state.errorBySession, [sessionId]: error }
368
+ errorBySession: { ...state.errorBySession, [sessionId]: error2 }
366
369
  });
367
370
  },
368
371
  clearSessionError: (sessionId) => {
@@ -415,16 +418,28 @@ import axios from "axios";
415
418
 
416
419
  // src/api/index.ts
417
420
  var CHAT_MODELS_PATH = "/models";
421
+ var CHAT_SKILLS_PATH = "/chat/skills";
418
422
  var CHAT_TERMINATE_PATH = "/chat/terminate";
419
- var getChatModels = async (client, path = CHAT_MODELS_PATH) => {
420
- const response = await client.get(path);
423
+ var getChatModels = async (client, path = CHAT_MODELS_PATH, headers) => {
424
+ const hasHeaders = Boolean(headers && Object.keys(headers).length > 0);
425
+ const response = hasHeaders ? await client.get(path, { headers }) : await client.get(path);
421
426
  return response.data;
422
427
  };
423
- var terminateChat = async (client, sessionId, path = CHAT_TERMINATE_PATH) => {
428
+ var getChatSkills = async (client, path = CHAT_SKILLS_PATH, headers) => {
429
+ const hasHeaders = Boolean(headers && Object.keys(headers).length > 0);
430
+ const response = hasHeaders ? await client.get(path, { headers }) : await client.get(path);
431
+ return response.data;
432
+ };
433
+ var terminateChat = async (client, sessionId, path = CHAT_TERMINATE_PATH, headers) => {
434
+ const resolvedHeaders = {
435
+ ...headers ?? {},
436
+ ...sessionId ? { "X-Session-ID": sessionId } : {}
437
+ };
438
+ const hasHeaders = Object.keys(resolvedHeaders).length > 0;
424
439
  const response = await client.post(
425
440
  path,
426
441
  sessionId ? { session_id: sessionId } : {},
427
- { headers: sessionId ? { "X-Session-ID": sessionId } : void 0 }
442
+ hasHeaders ? { headers: resolvedHeaders } : void 0
428
443
  );
429
444
  return response.data;
430
445
  };
@@ -547,11 +562,11 @@ var startChatStream = async ({
547
562
  onPacket(packet);
548
563
  }
549
564
  }
550
- } catch (error) {
551
- if (error instanceof DOMException && error.name === "AbortError") {
565
+ } catch (error2) {
566
+ if (error2 instanceof DOMException && error2.name === "AbortError") {
552
567
  return;
553
568
  }
554
- const normalizedError = error instanceof Error ? error : new Error("stream error");
569
+ const normalizedError = error2 instanceof Error ? error2 : new Error("stream error");
555
570
  onError?.(normalizedError);
556
571
  throw normalizedError;
557
572
  }
@@ -560,6 +575,7 @@ var startChatStream = async ({
560
575
  // src/transport/default-chat-transport.ts
561
576
  var DEFAULT_CHAT_TRANSPORT_ENDPOINTS = {
562
577
  models: "/models",
578
+ skills: "/chat/skills",
563
579
  completions: "/chat/completions",
564
580
  terminate: "/chat/terminate"
565
581
  };
@@ -607,15 +623,18 @@ var createDefaultRequestBody = async ({
607
623
  model,
608
624
  mode,
609
625
  content,
626
+ skills,
610
627
  attachments
611
628
  }) => {
612
629
  const hasAttachments = Boolean(attachments?.length);
630
+ const skillPayload = skills?.length ? { skill: skills.length === 1 ? skills[0] : skills } : {};
613
631
  if (!hasAttachments) {
614
632
  return {
615
633
  model,
616
634
  mode,
617
635
  stream: true,
618
- messages: [{ role: "user", content }]
636
+ messages: [{ role: "user", content }],
637
+ ...skillPayload
619
638
  };
620
639
  }
621
640
  const imageParts = await Promise.all(
@@ -634,36 +653,49 @@ var createDefaultRequestBody = async ({
634
653
  model,
635
654
  mode,
636
655
  stream: true,
637
- messages: [{ role: "user", content: messageContent }]
656
+ messages: [{ role: "user", content: messageContent }],
657
+ ...skillPayload
638
658
  };
639
659
  };
640
660
  var createDefaultChatTransport = ({
641
661
  apiBaseUrl,
642
662
  authToken,
663
+ headers,
643
664
  toolExecutionPolicy,
644
665
  streamHeaders,
645
666
  resolveModels,
667
+ resolveSkills,
646
668
  buildRequestBody,
647
669
  transformStreamPacket,
648
670
  endpoints,
649
671
  axiosInstance
650
672
  }) => {
651
- const client = axiosInstance ?? axios.create({ baseURL: apiBaseUrl, headers: { Authorization: authToken } });
673
+ const client = axiosInstance ?? axios.create({
674
+ baseURL: apiBaseUrl,
675
+ headers: {
676
+ Authorization: authToken,
677
+ ...headers ?? {}
678
+ }
679
+ });
652
680
  const resolvedEndpoints = {
653
681
  ...DEFAULT_CHAT_TRANSPORT_ENDPOINTS,
654
682
  ...endpoints
655
683
  };
684
+ const resolvedHeaders = headers ?? {};
656
685
  const resolvedStreamHeaders = {
657
686
  ...createToolExecutionHeaders(toolExecutionPolicy),
687
+ ...resolvedHeaders,
658
688
  ...streamHeaders
659
689
  };
660
690
  return {
661
- getModels: () => resolveModels?.() ?? getChatModels(client, resolvedEndpoints.models),
691
+ getModels: () => resolveModels?.() ?? getChatModels(client, resolvedEndpoints.models, resolvedHeaders),
692
+ getSkills: () => resolveSkills?.() ?? getChatSkills(client, resolvedEndpoints.skills, resolvedHeaders),
662
693
  startStream: async ({
663
694
  sessionId,
664
695
  model,
665
696
  mode,
666
697
  content,
698
+ skills,
667
699
  attachments,
668
700
  signal,
669
701
  onUpdate,
@@ -680,8 +712,9 @@ var createDefaultChatTransport = ({
680
712
  model,
681
713
  mode,
682
714
  content,
715
+ skills,
683
716
  attachments
684
- }) : await createDefaultRequestBody({ model, mode, content, attachments });
717
+ }) : await createDefaultRequestBody({ model, mode, content, skills, attachments });
685
718
  await startChatStream({
686
719
  apiBaseUrl,
687
720
  endpointPath: resolvedEndpoints.completions,
@@ -706,7 +739,7 @@ var createDefaultChatTransport = ({
706
739
  }
707
740
  });
708
741
  },
709
- terminateStream: (sessionId) => terminateChat(client, sessionId, resolvedEndpoints.terminate)
742
+ terminateStream: (sessionId) => terminateChat(client, sessionId, resolvedEndpoints.terminate, resolvedHeaders)
710
743
  };
711
744
  };
712
745
 
@@ -1055,9 +1088,9 @@ var useChatMessageReveal = (message) => {
1055
1088
  }, [batchedTargetUnitCount, displayedUnitCount, isAssistantStreaming, message.role]);
1056
1089
  const settledContent = isFreshBlockActive ? contentBlocks.slice(0, -1).join("\n\n") : displayedContent;
1057
1090
  const freshContent = isFreshBlockActive ? contentBlocks[contentBlocks.length - 1] ?? "" : "";
1058
- const displayedBlocks = isAssistantStreaming && contentBlocks.length > 1 ? contentBlocks.map((content, index) => ({
1091
+ const displayedBlocks = isAssistantStreaming && contentBlocks.length > 1 ? contentBlocks.map((content, index3) => ({
1059
1092
  content,
1060
- tone: isFreshBlockActive && index === contentBlocks.length - 1 ? "fresh" : "settled"
1093
+ tone: isFreshBlockActive && index3 === contentBlocks.length - 1 ? "fresh" : "settled"
1061
1094
  })) : [
1062
1095
  {
1063
1096
  content: displayedContent,
@@ -1090,22 +1123,22 @@ var stringifyTimelineKeyPart = (value) => {
1090
1123
  }
1091
1124
  return String(value);
1092
1125
  };
1093
- var getTimelineBlockKey = (block, index) => {
1126
+ var getTimelineBlockKey = (block, index3) => {
1094
1127
  switch (block.type) {
1095
1128
  case "markdown":
1096
1129
  return null;
1097
1130
  case "notice":
1098
- return `${index}:notice:${block.tone}:${block.text}`;
1131
+ return `${index3}:notice:${block.tone}:${block.text}`;
1099
1132
  case "parameter_summary":
1100
- return `${index}:parameter_summary:${block.items.map((item) => `${item.label}:${item.value}:${item.fieldPath ?? ""}`).join("|")}`;
1133
+ return `${index3}:parameter_summary:${block.items.map((item) => `${item.label}:${item.value}:${item.fieldPath ?? ""}`).join("|")}`;
1101
1134
  case "confirmation_card":
1102
- return `${index}:confirmation_card:${block.proposal.proposalId}`;
1135
+ return `${index3}:confirmation_card:${block.proposal.proposalId}`;
1103
1136
  case "result_summary":
1104
- return `${index}:result_summary:${block.summary.summaryId}:${block.summary.status}`;
1137
+ return `${index3}:result_summary:${block.summary.summaryId}:${block.summary.status}`;
1105
1138
  case "questionnaire":
1106
- return block.questionnaire.blockKey ? `questionnaire:${block.questionnaire.blockKey}` : `${index}:questionnaire:${block.questionnaire.questionnaireId}`;
1139
+ return block.questionnaire.blockKey ? `questionnaire:${block.questionnaire.blockKey}` : `${index3}:questionnaire:${block.questionnaire.questionnaireId}`;
1107
1140
  case "custom":
1108
- return block.blockKey ? `custom:${block.blockKey}` : `${index}:custom:${block.kind}:${stringifyTimelineKeyPart(block.data)}`;
1141
+ return block.blockKey ? `custom:${block.blockKey}` : `${index3}:custom:${block.kind}:${stringifyTimelineKeyPart(block.data)}`;
1109
1142
  default:
1110
1143
  return null;
1111
1144
  }
@@ -1124,9 +1157,9 @@ var buildTimelineTextDisplay = (content, isAssistantStreaming, isFreshBlockActiv
1124
1157
  const contentBlocks = splitMarkdownBlocks(content);
1125
1158
  const settledContent = isAssistantStreaming && isFreshBlockActive && contentBlocks.length > 1 ? contentBlocks.slice(0, -1).join("\n\n") : content;
1126
1159
  const freshContent = isAssistantStreaming && isFreshBlockActive && contentBlocks.length > 1 ? contentBlocks[contentBlocks.length - 1] ?? "" : "";
1127
- const displayedBlocks = contentBlocks.length > 1 ? contentBlocks.map((blockContent, index) => ({
1160
+ const displayedBlocks = contentBlocks.length > 1 ? contentBlocks.map((blockContent, index3) => ({
1128
1161
  content: blockContent,
1129
- tone: isAssistantStreaming && isFreshBlockActive && freshContent && index === contentBlocks.length - 1 ? "fresh" : "settled"
1162
+ tone: isAssistantStreaming && isFreshBlockActive && freshContent && index3 === contentBlocks.length - 1 ? "fresh" : "settled"
1130
1163
  })) : [{ content, tone: "settled" }];
1131
1164
  return {
1132
1165
  settledContent,
@@ -1134,7 +1167,7 @@ var buildTimelineTextDisplay = (content, isAssistantStreaming, isFreshBlockActiv
1134
1167
  displayedBlocks
1135
1168
  };
1136
1169
  };
1137
- var getTimelineDisplayUnitCount = (content) => splitMarkdownBlocks(content).reduce((count, block) => count + Array.from(block).length, 0);
1170
+ var getTimelineDisplayUnitCount = (content) => splitMarkdownBlocks(content).reduce((count2, block) => count2 + Array.from(block).length, 0);
1138
1171
  var buildAnchoredTimelineSegments = ({
1139
1172
  blocks,
1140
1173
  timelineBlockAnchors,
@@ -1143,7 +1176,7 @@ var buildAnchoredTimelineSegments = ({
1143
1176
  }) => {
1144
1177
  const orderedTimelineSegments = [];
1145
1178
  const totalTimelineUnits = timelineDisplayedBlocks.reduce(
1146
- (count, block) => count + Array.from(block.content).length,
1179
+ (count2, block) => count2 + Array.from(block.content).length,
1147
1180
  0
1148
1181
  );
1149
1182
  let textCursor = 0;
@@ -1187,7 +1220,7 @@ var buildAnchoredTimelineSegments = ({
1187
1220
  };
1188
1221
  };
1189
1222
  let trailingCutoff = totalTimelineUnits;
1190
- for (const [index, block] of blocks.entries()) {
1223
+ for (const [index3, block] of blocks.entries()) {
1191
1224
  if (block.type === "markdown") {
1192
1225
  orderedTimelineSegments.push({
1193
1226
  type: "markdown",
@@ -1195,7 +1228,7 @@ var buildAnchoredTimelineSegments = ({
1195
1228
  });
1196
1229
  continue;
1197
1230
  }
1198
- const blockKey = getTimelineBlockKey(block, index);
1231
+ const blockKey = getTimelineBlockKey(block, index3);
1199
1232
  const anchor = blockKey !== null ? timelineBlockAnchors[blockKey] ?? totalTimelineUnits : totalTimelineUnits;
1200
1233
  const isBlockVisible = blockKey !== null && visibleTimelineBlockKeys?.[blockKey] ? true : anchor <= totalTimelineUnits;
1201
1234
  if (anchor > textCursor) {
@@ -1215,7 +1248,7 @@ var buildAnchoredTimelineSegments = ({
1215
1248
  orderedTimelineSegments.push({
1216
1249
  type: "block",
1217
1250
  block,
1218
- index
1251
+ index: index3
1219
1252
  });
1220
1253
  textCursor = Math.max(textCursor, anchor);
1221
1254
  }
@@ -1263,7 +1296,7 @@ var timelineAnchorReducer = (state, action) => {
1263
1296
  ([blockKey, anchor]) => state.timelineBlockAnchors[blockKey] !== anchor
1264
1297
  );
1265
1298
  const hasPreviousKeysChanged = action.currentBlockKeys.length !== state.previousBlockKeys.length || action.currentBlockKeys.some(
1266
- (blockKey, index) => state.previousBlockKeys[index] !== blockKey
1299
+ (blockKey, index3) => state.previousBlockKeys[index3] !== blockKey
1267
1300
  );
1268
1301
  if (!hasAnchorChanged && !hasPreviousKeysChanged) {
1269
1302
  return state;
@@ -1312,7 +1345,7 @@ var useTimelineBlockAnchors = ({
1312
1345
  messageRenderOrder
1313
1346
  }) => {
1314
1347
  const currentTimelineBlockKeys = useMemo3(
1315
- () => blocks.map((block, index) => getTimelineBlockKey(block, index)).filter((blockKey) => Boolean(blockKey)),
1348
+ () => blocks.map((block, index3) => getTimelineBlockKey(block, index3)).filter((blockKey) => Boolean(blockKey)),
1316
1349
  [blocks]
1317
1350
  );
1318
1351
  const timelineTextStreamLength = useMemo3(
@@ -1738,11 +1771,11 @@ var toggleMultiSelectOtherAnswer = (current, question) => {
1738
1771
  };
1739
1772
  var getTextInputValue = (answer) => typeof answer === "string" ? String(answer) : "";
1740
1773
  var getNumberInputValue = (answer) => typeof answer === "number" || typeof answer === "string" ? String(answer) : "";
1741
- var getOptionChoiceLabel = (index) => {
1742
- if (index < 26) {
1743
- return String.fromCharCode(65 + index);
1774
+ var getOptionChoiceLabel = (index3) => {
1775
+ if (index3 < 26) {
1776
+ return String.fromCharCode(65 + index3);
1744
1777
  }
1745
- return String(index + 1);
1778
+ return String(index3 + 1);
1746
1779
  };
1747
1780
  var normalizeQuestionAnswer = (question, answer, otherDraft = "") => {
1748
1781
  if (answer === void 0) {
@@ -1919,7 +1952,7 @@ var stopInputKeyPropagation = (event) => {
1919
1952
  var OptionChoice = ({
1920
1953
  questionId,
1921
1954
  optionLabel,
1922
- index,
1955
+ index: index3,
1923
1956
  isSelected,
1924
1957
  isInteractionLocked,
1925
1958
  onClick,
@@ -1933,7 +1966,7 @@ var OptionChoice = ({
1933
1966
  "aria-pressed": isSelected,
1934
1967
  "data-selected": isSelected,
1935
1968
  "data-tone": tone,
1936
- "data-testid": `question-option-${questionId}-${index}`,
1969
+ "data-testid": `question-option-${questionId}-${index3}`,
1937
1970
  onClick: (event) => {
1938
1971
  if (isInteractionLocked) {
1939
1972
  return;
@@ -1954,7 +1987,7 @@ var OptionChoice = ({
1954
1987
  onClick();
1955
1988
  },
1956
1989
  children: [
1957
- /* @__PURE__ */ jsx5(OptionChoiceMarker, { "data-selected": isSelected, children: getOptionChoiceLabel(index) }),
1990
+ /* @__PURE__ */ jsx5(OptionChoiceMarker, { "data-selected": isSelected, children: getOptionChoiceLabel(index3) }),
1958
1991
  /* @__PURE__ */ jsxs3(OptionChoiceContent, { children: [
1959
1992
  inlineInput ? null : /* @__PURE__ */ jsx5(OptionChoiceLabel, { children: optionLabel }),
1960
1993
  inlineInput
@@ -2031,8 +2064,8 @@ var QuestionnaireCardInner = ({
2031
2064
  content
2032
2065
  });
2033
2066
  setIsSubmitted(true);
2034
- } catch (error) {
2035
- setErrorMessage(error instanceof Error ? error.message : resolvedLabels.submitFailed);
2067
+ } catch (error2) {
2068
+ setErrorMessage(error2 instanceof Error ? error2.message : resolvedLabels.submitFailed);
2036
2069
  } finally {
2037
2070
  setIsSubmitting(false);
2038
2071
  }
@@ -2049,14 +2082,14 @@ var QuestionnaireCardInner = ({
2049
2082
  otherDrafts[questionToRender.id] ?? ""
2050
2083
  );
2051
2084
  return /* @__PURE__ */ jsx5(QuestionBody, { children: /* @__PURE__ */ jsxs3(OptionList, { children: [
2052
- questionToRender.options.map((option, index) => {
2085
+ questionToRender.options.map((option, index3) => {
2053
2086
  const isSelected = multiSelectDraft.selectedValues.includes(option.value);
2054
2087
  return /* @__PURE__ */ jsx5(
2055
2088
  OptionChoice,
2056
2089
  {
2057
2090
  questionId: questionToRender.id,
2058
2091
  optionLabel: option.label,
2059
- index,
2092
+ index: index3,
2060
2093
  isSelected,
2061
2094
  isInteractionLocked,
2062
2095
  onClick: () => setAnswers(
@@ -2114,14 +2147,14 @@ var QuestionnaireCardInner = ({
2114
2147
  otherDrafts[questionToRender.id] ?? ""
2115
2148
  );
2116
2149
  return /* @__PURE__ */ jsx5(QuestionBody, { children: /* @__PURE__ */ jsxs3(OptionList, { children: [
2117
- questionToRender.options.map((option, index) => {
2150
+ questionToRender.options.map((option, index3) => {
2118
2151
  const isSelected = singleSelectDraft.selectedValue === option.value;
2119
2152
  return /* @__PURE__ */ jsx5(
2120
2153
  OptionChoice,
2121
2154
  {
2122
2155
  questionId: questionToRender.id,
2123
2156
  optionLabel: option.label,
2124
- index,
2157
+ index: index3,
2125
2158
  isSelected,
2126
2159
  isInteractionLocked,
2127
2160
  onClick: () => setAnswers(
@@ -2687,20 +2720,20 @@ var areChatAttachmentsEqual = (previousAttachments, nextAttachments) => {
2687
2720
  if (previousAttachments.length !== nextAttachments.length) {
2688
2721
  return false;
2689
2722
  }
2690
- return previousAttachments.every((attachment, index) => {
2691
- const nextAttachment = nextAttachments[index];
2723
+ return previousAttachments.every((attachment, index3) => {
2724
+ const nextAttachment = nextAttachments[index3];
2692
2725
  return attachment.id === nextAttachment?.id && attachment.name === nextAttachment.name && attachment.mimeType === nextAttachment.mimeType && attachment.size === nextAttachment.size && attachment.previewUrl === nextAttachment.previewUrl;
2693
2726
  });
2694
2727
  };
2695
- var areParameterSummaryItemsEqual = (previousItems, nextItems) => previousItems.length === nextItems.length && previousItems.every((item, index) => {
2696
- const nextItem = nextItems[index];
2728
+ var areParameterSummaryItemsEqual = (previousItems, nextItems) => previousItems.length === nextItems.length && previousItems.every((item, index3) => {
2729
+ const nextItem = nextItems[index3];
2697
2730
  return item.label === nextItem?.label && item.value === nextItem.value && item.fieldPath === nextItem.fieldPath;
2698
2731
  });
2699
2732
  var areExecutionProposalsEqual = (previousProposal, nextProposal) => previousProposal.proposalId === nextProposal.proposalId && previousProposal.resourceKey === nextProposal.resourceKey && previousProposal.resourceName === nextProposal.resourceName && previousProposal.executorName === nextProposal.executorName && previousProposal.requiresConfirmation === nextProposal.requiresConfirmation && areParameterSummaryItemsEqual(previousProposal.parameterSummary, nextProposal.parameterSummary) && (previousProposal.warnings ?? []).length === (nextProposal.warnings ?? []).length && (previousProposal.warnings ?? []).every(
2700
- (warning, index) => warning === nextProposal.warnings?.[index]
2733
+ (warning, index3) => warning === nextProposal.warnings?.[index3]
2701
2734
  );
2702
- var areResultSummariesEqual = (previousSummary, nextSummary) => previousSummary.summaryId === nextSummary.summaryId && previousSummary.status === nextSummary.status && previousSummary.headline === nextSummary.headline && previousSummary.details.length === nextSummary.details.length && previousSummary.details.every((detail, index) => detail === nextSummary.details[index]);
2703
- var areStringArraysEqual = (previousValues, nextValues) => previousValues.length === nextValues.length && previousValues.every((value, index) => value === nextValues[index]);
2735
+ var areResultSummariesEqual = (previousSummary, nextSummary) => previousSummary.summaryId === nextSummary.summaryId && previousSummary.status === nextSummary.status && previousSummary.headline === nextSummary.headline && previousSummary.details.length === nextSummary.details.length && previousSummary.details.every((detail, index3) => detail === nextSummary.details[index3]);
2736
+ var areStringArraysEqual = (previousValues, nextValues) => previousValues.length === nextValues.length && previousValues.every((value, index3) => value === nextValues[index3]);
2704
2737
  var areQuestionAnswersEqual = (previousAnswer, nextAnswer) => {
2705
2738
  if (Array.isArray(previousAnswer) || Array.isArray(nextAnswer)) {
2706
2739
  return Array.isArray(previousAnswer) && Array.isArray(nextAnswer) && areStringArraysEqual(previousAnswer, nextAnswer);
@@ -2719,7 +2752,7 @@ var areQuestionAnswerMapsEqual = (previousAnswers, nextAnswers) => {
2719
2752
  return previousKeys.length === nextKeys.length && previousKeys.every((key) => areQuestionAnswersEqual(previousAnswers[key], nextAnswers[key]));
2720
2753
  };
2721
2754
  var areQuestionOptionsEqual = (previousOptions, nextOptions) => previousOptions.length === nextOptions.length && previousOptions.every(
2722
- (option, index) => option.label === nextOptions[index]?.label && option.value === nextOptions[index]?.value
2755
+ (option, index3) => option.label === nextOptions[index3]?.label && option.value === nextOptions[index3]?.value
2723
2756
  );
2724
2757
  var arePlanQuestionsEqual = (previousQuestion, nextQuestion) => {
2725
2758
  if (previousQuestion.id !== nextQuestion.id || previousQuestion.label !== nextQuestion.label || previousQuestion.required !== nextQuestion.required || previousQuestion.kind !== nextQuestion.kind) {
@@ -2751,8 +2784,8 @@ var areMessageBlocksEqual = (previousBlocks, nextBlocks) => {
2751
2784
  if (previousBlocks.length !== nextBlocks.length) {
2752
2785
  return false;
2753
2786
  }
2754
- return previousBlocks.every((block, index) => {
2755
- const nextBlock = nextBlocks[index];
2787
+ return previousBlocks.every((block, index3) => {
2788
+ const nextBlock = nextBlocks[index3];
2756
2789
  if (!nextBlock || block.type !== nextBlock.type) {
2757
2790
  return false;
2758
2791
  }
@@ -2852,23 +2885,23 @@ var ChatMessageItemView = ({
2852
2885
  settledContent
2853
2886
  });
2854
2887
  const renderMessageContent = (content) => messageRenderMode === "plain-text" ? renderPlainTextContent(content) : renderMarkdownContent(content);
2855
- const renderChatMessageBlock = (block, index) => {
2888
+ const renderChatMessageBlock = (block, index3) => {
2856
2889
  switch (block.type) {
2857
2890
  case "markdown":
2858
2891
  return /* @__PURE__ */ jsx8(
2859
2892
  ContentBlock,
2860
2893
  {
2861
- "data-testid": `chat-message-block-${index}`,
2894
+ "data-testid": `chat-message-block-${index3}`,
2862
2895
  "data-block-tone": "settled",
2863
2896
  "data-render-mode": messageRenderMode,
2864
2897
  children: renderMessageContent(block.text)
2865
2898
  },
2866
- `markdown-${index}`
2899
+ `markdown-${index3}`
2867
2900
  );
2868
2901
  case "notice":
2869
- return /* @__PURE__ */ jsx8(Fragment, { children: /* @__PURE__ */ jsx8(NoticeCard, { text: block.text, tone: block.tone }) }, `notice-${index}`);
2902
+ return /* @__PURE__ */ jsx8(Fragment, { children: /* @__PURE__ */ jsx8(NoticeCard, { text: block.text, tone: block.tone }) }, `notice-${index3}`);
2870
2903
  case "parameter_summary":
2871
- return /* @__PURE__ */ jsx8(Fragment, { children: /* @__PURE__ */ jsx8(ParameterSummaryCard, { items: block.items }) }, `parameter-summary-${index}`);
2904
+ return /* @__PURE__ */ jsx8(Fragment, { children: /* @__PURE__ */ jsx8(ParameterSummaryCard, { items: block.items }) }, `parameter-summary-${index3}`);
2872
2905
  case "confirmation_card":
2873
2906
  return /* @__PURE__ */ jsx8(Fragment, { children: /* @__PURE__ */ jsx8(
2874
2907
  ExecutionConfirmationCard,
@@ -2881,9 +2914,9 @@ var ChatMessageItemView = ({
2881
2914
  sourceMessageId: message.id
2882
2915
  }) : void 0
2883
2916
  }
2884
- ) }, `confirmation-card-${index}`);
2917
+ ) }, `confirmation-card-${index3}`);
2885
2918
  case "result_summary":
2886
- return /* @__PURE__ */ jsx8(Fragment, { children: /* @__PURE__ */ jsx8(ResultSummaryCard, { summary: block.summary }) }, `result-summary-${index}`);
2919
+ return /* @__PURE__ */ jsx8(Fragment, { children: /* @__PURE__ */ jsx8(ResultSummaryCard, { summary: block.summary }) }, `result-summary-${index3}`);
2887
2920
  case "questionnaire":
2888
2921
  return /* @__PURE__ */ jsx8(Fragment, { children: /* @__PURE__ */ jsx8(
2889
2922
  QuestionnaireCard,
@@ -2904,16 +2937,16 @@ var ChatMessageItemView = ({
2904
2937
  sourceMessageId: message.id
2905
2938
  }) : void 0
2906
2939
  }
2907
- ) }, block.questionnaire.blockKey ?? `questionnaire-${index}`);
2940
+ ) }, block.questionnaire.blockKey ?? `questionnaire-${index3}`);
2908
2941
  case "custom":
2909
2942
  return /* @__PURE__ */ jsx8(Fragment, { children: renderMessageBlock?.({
2910
2943
  block,
2911
- index,
2944
+ index: index3,
2912
2945
  message,
2913
2946
  mode,
2914
2947
  onConfirmationSubmit,
2915
2948
  onQuestionnaireSubmit
2916
- }) ?? null }, `custom-${block.kind}-${index}`);
2949
+ }) ?? null }, `custom-${block.kind}-${index3}`);
2917
2950
  default:
2918
2951
  return null;
2919
2952
  }
@@ -2925,16 +2958,16 @@ var ChatMessageItemView = ({
2925
2958
  const settledText = localTimelineTextDisplay?.settledContent ?? settledContent;
2926
2959
  const freshText = localTimelineTextDisplay?.freshContent ?? freshContent;
2927
2960
  return /* @__PURE__ */ jsxs5(Fragment2, { children: [
2928
- textBlocks.filter((block) => block.content).map((block, index) => /* @__PURE__ */ jsx8(
2961
+ textBlocks.filter((block) => block.content).map((block, index3) => /* @__PURE__ */ jsx8(
2929
2962
  ContentBlock,
2930
2963
  {
2931
2964
  "data-testid": block.tone === "fresh" ? "chat-message-fresh-block" : "chat-message-settled-block",
2932
2965
  "data-block-tone": block.tone,
2933
- "data-block-index": index,
2966
+ "data-block-index": index3,
2934
2967
  "data-render-mode": messageRenderMode,
2935
2968
  children: renderMessageContent(block.content)
2936
2969
  },
2937
- `${block.tone}-${index}`
2970
+ `${block.tone}-${index3}`
2938
2971
  )),
2939
2972
  !textBlocks.some((block) => block.content) && !settledText && !freshText && Boolean(textContent) ? /* @__PURE__ */ jsx8(
2940
2973
  ContentBlock,
@@ -2964,8 +2997,8 @@ var ChatMessageItemView = ({
2964
2997
  return [];
2965
2998
  }
2966
2999
  if (messageRenderOrder === "timeline" && hasTextContent) {
2967
- const hasAnchoredStructuredBlocks = blocks.some((block, index) => {
2968
- const blockKey = getTimelineBlockKey(block, index);
3000
+ const hasAnchoredStructuredBlocks = blocks.some((block, index3) => {
3001
+ const blockKey = getTimelineBlockKey(block, index3);
2969
3002
  return blockKey ? timelineBlockAnchors[blockKey] !== void 0 : false;
2970
3003
  });
2971
3004
  if (hasAnchoredStructuredBlocks) {
@@ -2977,13 +3010,13 @@ var ChatMessageItemView = ({
2977
3010
  });
2978
3011
  }
2979
3012
  const orderedTimelineSegments = blocks.map(
2980
- (block, index) => block.type === "markdown" ? {
3013
+ (block, index3) => block.type === "markdown" ? {
2981
3014
  type: "markdown",
2982
3015
  content: block.text
2983
3016
  } : {
2984
3017
  type: "block",
2985
3018
  block,
2986
- index
3019
+ index: index3
2987
3020
  }
2988
3021
  );
2989
3022
  if (!timelineConsumedText) {
@@ -2991,10 +3024,10 @@ var ChatMessageItemView = ({
2991
3024
  }
2992
3025
  return timelineDisplayedContent ? [...orderedTimelineSegments, { type: "text", content: timelineDisplayedContent }] : orderedTimelineSegments;
2993
3026
  }
2994
- const orderedBlocks = blocks.map((block, index) => ({
3027
+ const orderedBlocks = blocks.map((block, index3) => ({
2995
3028
  type: "block",
2996
3029
  block,
2997
- index
3030
+ index: index3
2998
3031
  }));
2999
3032
  return hasTextContent ? [...orderedBlocks, { type: "text" }] : orderedBlocks;
3000
3033
  })();
@@ -3033,7 +3066,7 @@ var ChatMessageItemView = ({
3033
3066
  ref: bodyStackRef,
3034
3067
  "data-testid": "chat-message-body-stack",
3035
3068
  "data-collapsed": isUserMessageCollapsed,
3036
- children: bodySegments.map((segment, index) => /* @__PURE__ */ jsx8(
3069
+ children: bodySegments.map((segment, index3) => /* @__PURE__ */ jsx8(
3037
3070
  ContentSegment,
3038
3071
  {
3039
3072
  "data-testid": "chat-message-content-segment",
@@ -3043,7 +3076,7 @@ var ChatMessageItemView = ({
3043
3076
  useTimelineSegmentation: true
3044
3077
  }) : renderStaticTextSegment(segment.content) : renderTextContent() : renderStaticTextSegment(segment.content)
3045
3078
  },
3046
- segment.type === "text" ? `text-${index}` : segment.type === "markdown" ? `markdown-${index}` : `${segment.block.type}-${segment.index}`
3079
+ segment.type === "text" ? `text-${index3}` : segment.type === "markdown" ? `markdown-${index3}` : `${segment.block.type}-${segment.index}`
3047
3080
  ))
3048
3081
  }
3049
3082
  ) : null,
@@ -3442,11 +3475,11 @@ var renderChatMessage = ({
3442
3475
  }
3443
3476
  );
3444
3477
  var renderErrorState = ({
3445
- error,
3478
+ error: error2,
3446
3479
  onRetry,
3447
3480
  retryButtonLabel
3448
3481
  }) => /* @__PURE__ */ jsxs7(ErrorState, { "data-testid": "chat-thread-error-state", children: [
3449
- /* @__PURE__ */ jsx10(ErrorText, { children: error }),
3482
+ /* @__PURE__ */ jsx10(ErrorText, { children: error2 }),
3450
3483
  onRetry ? /* @__PURE__ */ jsx10(ErrorActions, { children: /* @__PURE__ */ jsx10(RetryButton, { type: "button", "data-testid": "chat-thread-retry", onClick: onRetry, children: retryButtonLabel }) }) : null
3451
3484
  ] });
3452
3485
  var groupConversationTurns = (historyMessages, streamingMessage) => {
@@ -3496,7 +3529,7 @@ var ChatThreadView = ({
3496
3529
  activeSessionMode = DEFAULT_CHAT_AGENT_MODE,
3497
3530
  historyMessages,
3498
3531
  streamingMessage,
3499
- error,
3532
+ error: error2,
3500
3533
  retryButtonLabel,
3501
3534
  scrollToLatestLabel,
3502
3535
  onRetry,
@@ -3640,7 +3673,7 @@ var ChatThreadView = ({
3640
3673
  reservedSpaceFrameRef.current = null;
3641
3674
  }
3642
3675
  };
3643
- }, [latestTurn, latestUserMessageId, error, measureLatestTurnMinHeight, scrollToBottom]);
3676
+ }, [latestTurn, latestUserMessageId, error2, measureLatestTurnMinHeight, scrollToBottom]);
3644
3677
  useLayoutEffect2(() => {
3645
3678
  if (!latestTurn)
3646
3679
  return;
@@ -3743,11 +3776,11 @@ var ChatThreadView = ({
3743
3776
  onQuestionnaireSubmit,
3744
3777
  renderMessageBlock
3745
3778
  }) }, message.id)),
3746
- error ? renderErrorState({ error, onRetry, retryButtonLabel }) : null
3779
+ error2 ? renderErrorState({ error: error2, onRetry, retryButtonLabel }) : null
3747
3780
  ]
3748
3781
  }
3749
3782
  ) : null,
3750
- !latestTurn && error ? renderErrorState({ error, onRetry, retryButtonLabel }) : null
3783
+ !latestTurn && error2 ? renderErrorState({ error: error2, onRetry, retryButtonLabel }) : null
3751
3784
  ] }),
3752
3785
  isDetached ? /* @__PURE__ */ jsx10(ScrollToLatestOverlay, { children: /* @__PURE__ */ jsxs7(
3753
3786
  ScrollToLatestButton,
@@ -3774,7 +3807,7 @@ var ChatThread = () => {
3774
3807
  (s) => s.messagesBySession[s.activeSessionId ?? ""] ?? EMPTY_MESSAGES
3775
3808
  );
3776
3809
  const streamingMessage = useChatStore((s) => s.streamingMessageBySession[s.activeSessionId ?? ""]);
3777
- const error = useChatStore((s) => s.errorBySession[s.activeSessionId ?? ""]);
3810
+ const error2 = useChatStore((s) => s.errorBySession[s.activeSessionId ?? ""]);
3778
3811
  const updateQA = useChatStore((s) => s.updateQuestionnaireAnswers);
3779
3812
  const clearSessionError = useChatStore((s) => s.clearSessionError);
3780
3813
  const {
@@ -3854,7 +3887,7 @@ var ChatThread = () => {
3854
3887
  activeSessionMode,
3855
3888
  historyMessages: messages,
3856
3889
  streamingMessage,
3857
- error,
3890
+ error: error2,
3858
3891
  retryButtonLabel: labels.retryButton,
3859
3892
  scrollToLatestLabel: labels.scrollToLatest,
3860
3893
  onRetry: handleRetry,
@@ -3974,276 +4007,2860 @@ var ScrollToLatestBadge = styled9.span`
3974
4007
  `;
3975
4008
 
3976
4009
  // src/components/chat-composer/index.tsx
3977
- import { useEffect as useEffect7, useLayoutEffect as useLayoutEffect3, useRef as useRef8, useState as useState8 } from "react";
4010
+ import { useCallback as useCallback8, useEffect as useEffect8, useLayoutEffect as useLayoutEffect5, useRef as useRef11, useState as useState10 } from "react";
3978
4011
  import styled14 from "@emotion/styled";
3979
4012
 
3980
- // src/components/chat-composer/lib/chat-composer.ts
3981
- var createUserMessage = ({
3982
- sessionId,
3983
- content,
3984
- attachments,
3985
- localOnly,
3986
- createdAt,
3987
- createMessageId
3988
- }) => ({
3989
- id: createMessageId(),
3990
- sessionId,
3991
- role: "user",
3992
- content,
3993
- attachments,
3994
- localOnly,
3995
- createdAt
3996
- });
3997
- var createAssistantStreamingMessage = ({
3998
- sessionId,
3999
- createdAt,
4000
- createMessageId
4001
- }) => ({
4002
- id: createMessageId(),
4003
- sessionId,
4004
- role: "assistant",
4005
- content: "",
4006
- status: "streaming",
4007
- createdAt
4008
- });
4009
- var canSendChatMessage = ({
4010
- value,
4011
- attachmentCount = 0,
4012
- isModelsLoading,
4013
- isModelsError,
4014
- hasModels
4015
- }) => {
4016
- const hasText = Boolean(value.trim());
4017
- const hasAttachments = attachmentCount > 0;
4018
- if (!hasText && !hasAttachments)
4013
+ // ../../node_modules/.pnpm/@floating-ui+react@0.27.16_react-dom@18.3.1_react@18.3.1/node_modules/@floating-ui/react/dist/floating-ui.react.mjs
4014
+ import * as React3 from "react";
4015
+
4016
+ // ../../node_modules/.pnpm/@floating-ui+utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
4017
+ function hasWindow() {
4018
+ return typeof window !== "undefined";
4019
+ }
4020
+ function getNodeName(node) {
4021
+ if (isNode(node)) {
4022
+ return (node.nodeName || "").toLowerCase();
4023
+ }
4024
+ return "#document";
4025
+ }
4026
+ function getWindow(node) {
4027
+ var _node$ownerDocument;
4028
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
4029
+ }
4030
+ function getDocumentElement(node) {
4031
+ var _ref;
4032
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
4033
+ }
4034
+ function isNode(value) {
4035
+ if (!hasWindow()) {
4019
4036
  return false;
4020
- if (!hasText && hasAttachments)
4021
- return true;
4022
- return !isModelsLoading && !isModelsError && hasModels;
4023
- };
4024
- var shouldSubmitChatComposer = ({
4025
- key,
4026
- shiftKey,
4027
- canSend
4028
- }) => key === "Enter" && !shiftKey && canSend;
4029
- var shouldStopChatComposer = ({
4030
- key,
4031
- shiftKey,
4032
- isStreaming
4033
- }) => key === "Enter" && !shiftKey && isStreaming;
4034
- var resolveSelectedChatModel = ({
4035
- currentModel,
4036
- availableModels,
4037
- isModelsLoading
4038
- }) => {
4039
- if (!availableModels.length) {
4040
- return isModelsLoading ? currentModel : "";
4041
4037
  }
4042
- if (currentModel && availableModels.some((model) => model.id === currentModel)) {
4043
- return currentModel;
4038
+ return value instanceof Node || value instanceof getWindow(value).Node;
4039
+ }
4040
+ function isElement(value) {
4041
+ if (!hasWindow()) {
4042
+ return false;
4044
4043
  }
4045
- return availableModels[0].id;
4046
- };
4047
- var resolveSendSession = ({
4048
- activeSessionId,
4049
- selectedModel,
4050
- selectedMode,
4051
- nowIso: nowIso2,
4052
- createSessionId
4053
- }) => {
4054
- if (activeSessionId) {
4044
+ return value instanceof Element || value instanceof getWindow(value).Element;
4045
+ }
4046
+ function isHTMLElement(value) {
4047
+ if (!hasWindow()) {
4048
+ return false;
4049
+ }
4050
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
4051
+ }
4052
+ function isShadowRoot(value) {
4053
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
4054
+ return false;
4055
+ }
4056
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
4057
+ }
4058
+ var invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
4059
+ function isOverflowElement(element) {
4060
+ const {
4061
+ overflow,
4062
+ overflowX,
4063
+ overflowY,
4064
+ display
4065
+ } = getComputedStyle2(element);
4066
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
4067
+ }
4068
+ var tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]);
4069
+ function isTableElement(element) {
4070
+ return tableElements.has(getNodeName(element));
4071
+ }
4072
+ var topLayerSelectors = [":popover-open", ":modal"];
4073
+ function isTopLayer(element) {
4074
+ return topLayerSelectors.some((selector) => {
4075
+ try {
4076
+ return element.matches(selector);
4077
+ } catch (_e) {
4078
+ return false;
4079
+ }
4080
+ });
4081
+ }
4082
+ var transformProperties = ["transform", "translate", "scale", "rotate", "perspective"];
4083
+ var willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"];
4084
+ var containValues = ["paint", "layout", "strict", "content"];
4085
+ function isContainingBlock(elementOrCss) {
4086
+ const webkit = isWebKit();
4087
+ const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
4088
+ return transformProperties.some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || willChangeValues.some((value) => (css.willChange || "").includes(value)) || containValues.some((value) => (css.contain || "").includes(value));
4089
+ }
4090
+ function getContainingBlock(element) {
4091
+ let currentNode = getParentNode(element);
4092
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
4093
+ if (isContainingBlock(currentNode)) {
4094
+ return currentNode;
4095
+ } else if (isTopLayer(currentNode)) {
4096
+ return null;
4097
+ }
4098
+ currentNode = getParentNode(currentNode);
4099
+ }
4100
+ return null;
4101
+ }
4102
+ function isWebKit() {
4103
+ if (typeof CSS === "undefined" || !CSS.supports)
4104
+ return false;
4105
+ return CSS.supports("-webkit-backdrop-filter", "none");
4106
+ }
4107
+ var lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]);
4108
+ function isLastTraversableNode(node) {
4109
+ return lastTraversableNodeNames.has(getNodeName(node));
4110
+ }
4111
+ function getComputedStyle2(element) {
4112
+ return getWindow(element).getComputedStyle(element);
4113
+ }
4114
+ function getNodeScroll(element) {
4115
+ if (isElement(element)) {
4055
4116
  return {
4056
- localSessionId: activeSessionId,
4057
- sessionId: isDraftChatSessionId(activeSessionId) ? void 0 : activeSessionId
4117
+ scrollLeft: element.scrollLeft,
4118
+ scrollTop: element.scrollTop
4058
4119
  };
4059
4120
  }
4060
- const session = createDraftChatSession({
4061
- model: selectedModel,
4062
- mode: selectedMode ?? DEFAULT_CHAT_AGENT_MODE,
4063
- nowIso: nowIso2,
4064
- createSessionId
4065
- });
4066
- return { session, localSessionId: session.sessionId, sessionId: void 0 };
4067
- };
4121
+ return {
4122
+ scrollLeft: element.scrollX,
4123
+ scrollTop: element.scrollY
4124
+ };
4125
+ }
4126
+ function getParentNode(node) {
4127
+ if (getNodeName(node) === "html") {
4128
+ return node;
4129
+ }
4130
+ const result = (
4131
+ // Step into the shadow DOM of the parent of a slotted node.
4132
+ node.assignedSlot || // DOM Element detected.
4133
+ node.parentNode || // ShadowRoot detected.
4134
+ isShadowRoot(node) && node.host || // Fallback.
4135
+ getDocumentElement(node)
4136
+ );
4137
+ return isShadowRoot(result) ? result.host : result;
4138
+ }
4139
+ function getNearestOverflowAncestor(node) {
4140
+ const parentNode = getParentNode(node);
4141
+ if (isLastTraversableNode(parentNode)) {
4142
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
4143
+ }
4144
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
4145
+ return parentNode;
4146
+ }
4147
+ return getNearestOverflowAncestor(parentNode);
4148
+ }
4149
+ function getOverflowAncestors(node, list, traverseIframes) {
4150
+ var _node$ownerDocument2;
4151
+ if (list === void 0) {
4152
+ list = [];
4153
+ }
4154
+ if (traverseIframes === void 0) {
4155
+ traverseIframes = true;
4156
+ }
4157
+ const scrollableAncestor = getNearestOverflowAncestor(node);
4158
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
4159
+ const win = getWindow(scrollableAncestor);
4160
+ if (isBody) {
4161
+ const frameElement = getFrameElement(win);
4162
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
4163
+ }
4164
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
4165
+ }
4166
+ function getFrameElement(win) {
4167
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
4168
+ }
4068
4169
 
4069
- // src/components/chat-composer/hooks/use-chat-composer.ts
4070
- import { useCallback as useCallback4, useEffect as useEffect6, useRef as useRef7, useState as useState6 } from "react";
4170
+ // ../../node_modules/.pnpm/@floating-ui+react@0.27.16_react-dom@18.3.1_react@18.3.1/node_modules/@floating-ui/react/dist/floating-ui.react.utils.mjs
4171
+ import * as React from "react";
4172
+ import { useLayoutEffect as useLayoutEffect3 } from "react";
4071
4173
 
4072
- // src/components/chat-composer/hooks/use-composer-attachments.ts
4073
- import { useEffect as useEffect5, useRef as useRef6, useState as useState5 } from "react";
4074
- var SUPPORTED_IMAGE_MIME_TYPES = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/webp"]);
4075
- var MAX_COMPOSER_ATTACHMENTS = 10;
4076
- var createObjectUrl = (file) => typeof URL !== "undefined" && typeof URL.createObjectURL === "function" ? URL.createObjectURL(file) : "";
4077
- var revokeObjectUrl = (url) => {
4078
- if (url && typeof URL !== "undefined" && typeof URL.revokeObjectURL === "function") {
4079
- URL.revokeObjectURL(url);
4080
- }
4174
+ // ../../node_modules/.pnpm/@floating-ui+utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
4175
+ var min = Math.min;
4176
+ var max = Math.max;
4177
+ var round = Math.round;
4178
+ var floor = Math.floor;
4179
+ var createCoords = (v) => ({
4180
+ x: v,
4181
+ y: v
4182
+ });
4183
+ var oppositeSideMap = {
4184
+ left: "right",
4185
+ right: "left",
4186
+ bottom: "top",
4187
+ top: "bottom"
4081
4188
  };
4082
- var createAttachmentId = () => `attachment-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
4083
- var releaseComposerAttachments = (attachments) => {
4084
- attachments.forEach((attachment) => revokeObjectUrl(attachment.previewUrl));
4189
+ var oppositeAlignmentMap = {
4190
+ start: "end",
4191
+ end: "start"
4085
4192
  };
4086
- var useComposerAttachments = () => {
4087
- const [attachments, setAttachments] = useState5([]);
4088
- const attachmentsRef = useRef6([]);
4089
- useEffect5(() => {
4090
- attachmentsRef.current = attachments;
4091
- }, [attachments]);
4092
- useEffect5(
4093
- () => () => {
4094
- releaseComposerAttachments(attachmentsRef.current);
4095
- },
4096
- []
4097
- );
4098
- const appendFiles = (files) => {
4099
- const validFiles = Array.from(files).filter((file) => SUPPORTED_IMAGE_MIME_TYPES.has(file.type));
4100
- if (!validFiles.length)
4101
- return { addedCount: 0, limitExceeded: false };
4102
- const currentAttachments = attachmentsRef.current;
4103
- const remainingSlots = MAX_COMPOSER_ATTACHMENTS - currentAttachments.length;
4104
- if (remainingSlots <= 0)
4105
- return { addedCount: 0, limitExceeded: true };
4106
- const filesToAppend = validFiles.slice(0, remainingSlots);
4107
- const newAttachments = filesToAppend.map((file) => ({
4108
- id: createAttachmentId(),
4109
- file,
4110
- name: file.name,
4111
- mimeType: file.type,
4112
- size: file.size,
4113
- previewUrl: createObjectUrl(file)
4114
- }));
4115
- setAttachments((current) => [...current, ...newAttachments]);
4116
- return {
4117
- addedCount: filesToAppend.length,
4118
- limitExceeded: validFiles.length > filesToAppend.length
4119
- };
4120
- };
4121
- const removeAttachment = (attachmentId) => {
4122
- setAttachments((current) => {
4123
- const target = current.find((a) => a.id === attachmentId);
4124
- if (target)
4125
- releaseComposerAttachments([target]);
4126
- return current.filter((a) => a.id !== attachmentId);
4127
- });
4128
- };
4129
- const clearAttachments = () => {
4130
- setAttachments((current) => {
4131
- releaseComposerAttachments(current);
4132
- return [];
4133
- });
4134
- };
4135
- const takeMessageAttachments = () => {
4136
- const currentAttachments = attachmentsRef.current;
4137
- if (!currentAttachments.length) {
4193
+ function clamp(start, value, end) {
4194
+ return max(start, min(value, end));
4195
+ }
4196
+ function evaluate(value, param) {
4197
+ return typeof value === "function" ? value(param) : value;
4198
+ }
4199
+ function getSide(placement) {
4200
+ return placement.split("-")[0];
4201
+ }
4202
+ function getAlignment(placement) {
4203
+ return placement.split("-")[1];
4204
+ }
4205
+ function getOppositeAxis(axis) {
4206
+ return axis === "x" ? "y" : "x";
4207
+ }
4208
+ function getAxisLength(axis) {
4209
+ return axis === "y" ? "height" : "width";
4210
+ }
4211
+ var yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
4212
+ function getSideAxis(placement) {
4213
+ return yAxisSides.has(getSide(placement)) ? "y" : "x";
4214
+ }
4215
+ function getAlignmentAxis(placement) {
4216
+ return getOppositeAxis(getSideAxis(placement));
4217
+ }
4218
+ function getAlignmentSides(placement, rects, rtl) {
4219
+ if (rtl === void 0) {
4220
+ rtl = false;
4221
+ }
4222
+ const alignment = getAlignment(placement);
4223
+ const alignmentAxis = getAlignmentAxis(placement);
4224
+ const length = getAxisLength(alignmentAxis);
4225
+ let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
4226
+ if (rects.reference[length] > rects.floating[length]) {
4227
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
4228
+ }
4229
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
4230
+ }
4231
+ function getExpandedPlacements(placement) {
4232
+ const oppositePlacement = getOppositePlacement(placement);
4233
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
4234
+ }
4235
+ function getOppositeAlignmentPlacement(placement) {
4236
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
4237
+ }
4238
+ var lrPlacement = ["left", "right"];
4239
+ var rlPlacement = ["right", "left"];
4240
+ var tbPlacement = ["top", "bottom"];
4241
+ var btPlacement = ["bottom", "top"];
4242
+ function getSideList(side, isStart, rtl) {
4243
+ switch (side) {
4244
+ case "top":
4245
+ case "bottom":
4246
+ if (rtl)
4247
+ return isStart ? rlPlacement : lrPlacement;
4248
+ return isStart ? lrPlacement : rlPlacement;
4249
+ case "left":
4250
+ case "right":
4251
+ return isStart ? tbPlacement : btPlacement;
4252
+ default:
4138
4253
  return [];
4254
+ }
4255
+ }
4256
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
4257
+ const alignment = getAlignment(placement);
4258
+ let list = getSideList(getSide(placement), direction === "start", rtl);
4259
+ if (alignment) {
4260
+ list = list.map((side) => side + "-" + alignment);
4261
+ if (flipAlignment) {
4262
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
4139
4263
  }
4140
- const nextMessageAttachments = currentAttachments.map(({ file: _file, ...attachment }) => ({
4141
- ...attachment,
4142
- file: _file
4143
- }));
4144
- attachmentsRef.current = [];
4145
- setAttachments([]);
4146
- return nextMessageAttachments;
4264
+ }
4265
+ return list;
4266
+ }
4267
+ function getOppositePlacement(placement) {
4268
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
4269
+ }
4270
+ function expandPaddingObject(padding) {
4271
+ return {
4272
+ top: 0,
4273
+ right: 0,
4274
+ bottom: 0,
4275
+ left: 0,
4276
+ ...padding
4147
4277
  };
4278
+ }
4279
+ function getPaddingObject(padding) {
4280
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
4281
+ top: padding,
4282
+ right: padding,
4283
+ bottom: padding,
4284
+ left: padding
4285
+ };
4286
+ }
4287
+ function rectToClientRect(rect) {
4288
+ const {
4289
+ x,
4290
+ y,
4291
+ width,
4292
+ height
4293
+ } = rect;
4148
4294
  return {
4149
- attachments,
4150
- appendFiles,
4151
- removeAttachment,
4152
- clearAttachments,
4153
- takeMessageAttachments
4295
+ width,
4296
+ height,
4297
+ top: y,
4298
+ left: x,
4299
+ right: x + width,
4300
+ bottom: y + height,
4301
+ x,
4302
+ y
4154
4303
  };
4155
- };
4304
+ }
4156
4305
 
4157
- // src/components/chat-composer/hooks/use-chat-composer.ts
4158
- var nowIso = () => (/* @__PURE__ */ new Date()).toISOString();
4159
- var ATTACHMENT_NOTICE_DURATION_MS = 3e3;
4160
- var STOP_WAIT_TIMEOUT_MS = 3e3;
4161
- var resolveAccumulatedContent = (currentContent, update) => {
4162
- if (update.content !== void 0) {
4163
- return update.content;
4306
+ // ../../node_modules/.pnpm/tabbable@6.3.0/node_modules/tabbable/dist/index.esm.js
4307
+ var candidateSelectors = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"];
4308
+ var candidateSelector = /* @__PURE__ */ candidateSelectors.join(",");
4309
+ var NoElement = typeof Element === "undefined";
4310
+ var matches = NoElement ? function() {
4311
+ } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
4312
+ var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
4313
+ var _element$getRootNode;
4314
+ return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
4315
+ } : function(element) {
4316
+ return element === null || element === void 0 ? void 0 : element.ownerDocument;
4317
+ };
4318
+ var _isInert = function isInert(node, lookUp) {
4319
+ var _node$getAttribute;
4320
+ if (lookUp === void 0) {
4321
+ lookUp = true;
4322
+ }
4323
+ var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, "inert");
4324
+ var inert = inertAtt === "" || inertAtt === "true";
4325
+ var result = inert || lookUp && node && _isInert(node.parentNode);
4326
+ return result;
4327
+ };
4328
+ var isContentEditable = function isContentEditable2(node) {
4329
+ var _node$getAttribute2;
4330
+ var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable");
4331
+ return attValue === "" || attValue === "true";
4332
+ };
4333
+ var getCandidates = function getCandidates2(el, includeContainer, filter) {
4334
+ if (_isInert(el)) {
4335
+ return [];
4164
4336
  }
4165
- if (update.contentDelta) {
4166
- return currentContent + update.contentDelta;
4337
+ var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
4338
+ if (includeContainer && matches.call(el, candidateSelector)) {
4339
+ candidates.unshift(el);
4167
4340
  }
4168
- return currentContent;
4341
+ candidates = candidates.filter(filter);
4342
+ return candidates;
4169
4343
  };
4170
- var normalizeChatErrorMessage = (message, labels) => {
4171
- const trimmedMessage = message?.trim();
4172
- if (!trimmedMessage) {
4173
- return labels.genericError;
4344
+ var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
4345
+ var candidates = [];
4346
+ var elementsToCheck = Array.from(elements);
4347
+ while (elementsToCheck.length) {
4348
+ var element = elementsToCheck.shift();
4349
+ if (_isInert(element, false)) {
4350
+ continue;
4351
+ }
4352
+ if (element.tagName === "SLOT") {
4353
+ var assigned = element.assignedElements();
4354
+ var content = assigned.length ? assigned : element.children;
4355
+ var nestedCandidates = _getCandidatesIteratively(content, true, options);
4356
+ if (options.flatten) {
4357
+ candidates.push.apply(candidates, nestedCandidates);
4358
+ } else {
4359
+ candidates.push({
4360
+ scopeParent: element,
4361
+ candidates: nestedCandidates
4362
+ });
4363
+ }
4364
+ } else {
4365
+ var validCandidate = matches.call(element, candidateSelector);
4366
+ if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
4367
+ candidates.push(element);
4368
+ }
4369
+ var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
4370
+ typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
4371
+ var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
4372
+ if (shadowRoot && validShadowRoot) {
4373
+ var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
4374
+ if (options.flatten) {
4375
+ candidates.push.apply(candidates, _nestedCandidates);
4376
+ } else {
4377
+ candidates.push({
4378
+ scopeParent: element,
4379
+ candidates: _nestedCandidates
4380
+ });
4381
+ }
4382
+ } else {
4383
+ elementsToCheck.unshift.apply(elementsToCheck, element.children);
4384
+ }
4385
+ }
4174
4386
  }
4175
- if (trimmedMessage === "Failed to fetch") {
4176
- return labels.networkError;
4387
+ return candidates;
4388
+ };
4389
+ var hasTabIndex = function hasTabIndex2(node) {
4390
+ return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
4391
+ };
4392
+ var getTabIndex = function getTabIndex2(node) {
4393
+ if (!node) {
4394
+ throw new Error("No node provided");
4177
4395
  }
4178
- return trimmedMessage;
4396
+ if (node.tabIndex < 0) {
4397
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
4398
+ return 0;
4399
+ }
4400
+ }
4401
+ return node.tabIndex;
4179
4402
  };
4180
- var useChatComposer = () => {
4181
- const { transport, enableImageAttachments, labels, store } = useChatContext();
4182
- const activeSessionId = useChatStore((s) => s.activeSessionId);
4183
- const activeSession = useChatStore(
4184
- (s) => s.sessions.find((x) => x.sessionId === s.activeSessionId) ?? null
4185
- );
4186
- const preferredMode = useChatStore((s) => s.preferredMode);
4187
- const streamingSessionId = useChatStore(
4188
- (s) => s.activeSessionId && s.isStreamingBySession[s.activeSessionId] ? s.activeSessionId : null
4189
- );
4190
- const isStreaming = Boolean(streamingSessionId);
4191
- const isStopping = useChatStore((s) => {
4192
- const currentStreamingSessionId = s.activeSessionId && s.isStreamingBySession[s.activeSessionId] ? s.activeSessionId : null;
4193
- return currentStreamingSessionId ? s.isStoppingBySession[currentStreamingSessionId] ?? false : false;
4403
+ var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) {
4404
+ var tabIndex = getTabIndex(node);
4405
+ if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
4406
+ return 0;
4407
+ }
4408
+ return tabIndex;
4409
+ };
4410
+ var sortOrderedTabbables = function sortOrderedTabbables2(a, b) {
4411
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
4412
+ };
4413
+ var isInput = function isInput2(node) {
4414
+ return node.tagName === "INPUT";
4415
+ };
4416
+ var isHiddenInput = function isHiddenInput2(node) {
4417
+ return isInput(node) && node.type === "hidden";
4418
+ };
4419
+ var isDetailsWithSummary = function isDetailsWithSummary2(node) {
4420
+ var r = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
4421
+ return child.tagName === "SUMMARY";
4194
4422
  });
4195
- const createSession = useChatStore((s) => s.createSession);
4196
- const replaceSessionId = useChatStore((s) => s.replaceSessionId);
4197
- const appendMessage = useChatStore((s) => s.appendMessage);
4198
- const startStreamingMessage = useChatStore((s) => s.startStreamingMessage);
4199
- const patchStreamingMessage = useChatStore((s) => s.patchStreamingMessage);
4200
- const completeStreamingMessage = useChatStore((s) => s.completeStreamingMessage);
4201
- const requestStopStreaming = useChatStore((s) => s.requestStopStreaming);
4202
- const finalizeStoppedStreamingMessage = useChatStore((s) => s.finalizeStoppedStreamingMessage);
4203
- const setSessionError = useChatStore((s) => s.setSessionError);
4204
- const clearSessionError = useChatStore((s) => s.clearSessionError);
4205
- const setPreferredMode = useChatStore((s) => s.setPreferredMode);
4206
- const setSessionMode = useChatStore((s) => s.setSessionMode);
4207
- const [availableModels, setAvailableModels] = useState6([]);
4208
- const [isModelsLoading, setIsModelsLoading] = useState6(true);
4209
- const [isModelsError, setIsModelsError] = useState6(false);
4210
- const fetchModels = useCallback4(async () => {
4211
- setIsModelsLoading(true);
4212
- setIsModelsError(false);
4213
- try {
4214
- const modelsResponse = await transport.getModels();
4215
- setAvailableModels(modelsResponse.data);
4216
- } catch {
4217
- setIsModelsError(true);
4423
+ return r;
4424
+ };
4425
+ var getCheckedRadio = function getCheckedRadio2(nodes, form) {
4426
+ for (var i = 0; i < nodes.length; i++) {
4427
+ if (nodes[i].checked && nodes[i].form === form) {
4428
+ return nodes[i];
4429
+ }
4430
+ }
4431
+ };
4432
+ var isTabbableRadio = function isTabbableRadio2(node) {
4433
+ if (!node.name) {
4434
+ return true;
4435
+ }
4436
+ var radioScope = node.form || getRootNode(node);
4437
+ var queryRadios = function queryRadios2(name) {
4438
+ return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
4439
+ };
4440
+ var radioSet;
4441
+ if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
4442
+ radioSet = queryRadios(window.CSS.escape(node.name));
4443
+ } else {
4444
+ try {
4445
+ radioSet = queryRadios(node.name);
4446
+ } catch (err) {
4447
+ console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
4448
+ return false;
4449
+ }
4450
+ }
4451
+ var checked = getCheckedRadio(radioSet, node.form);
4452
+ return !checked || checked === node;
4453
+ };
4454
+ var isRadio = function isRadio2(node) {
4455
+ return isInput(node) && node.type === "radio";
4456
+ };
4457
+ var isNonTabbableRadio = function isNonTabbableRadio2(node) {
4458
+ return isRadio(node) && !isTabbableRadio(node);
4459
+ };
4460
+ var isNodeAttached = function isNodeAttached2(node) {
4461
+ var _nodeRoot;
4462
+ var nodeRoot = node && getRootNode(node);
4463
+ var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
4464
+ var attached = false;
4465
+ if (nodeRoot && nodeRoot !== node) {
4466
+ var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
4467
+ attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
4468
+ while (!attached && nodeRootHost) {
4469
+ var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
4470
+ nodeRoot = getRootNode(nodeRootHost);
4471
+ nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
4472
+ attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
4473
+ }
4474
+ }
4475
+ return attached;
4476
+ };
4477
+ var isZeroArea = function isZeroArea2(node) {
4478
+ var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
4479
+ return width === 0 && height === 0;
4480
+ };
4481
+ var isHidden = function isHidden2(node, _ref) {
4482
+ var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
4483
+ if (displayCheck === "full-native") {
4484
+ if ("checkVisibility" in node) {
4485
+ var visible = node.checkVisibility({
4486
+ // Checking opacity might be desirable for some use cases, but natively,
4487
+ // opacity zero elements _are_ focusable and tabbable.
4488
+ checkOpacity: false,
4489
+ opacityProperty: false,
4490
+ contentVisibilityAuto: true,
4491
+ visibilityProperty: true,
4492
+ // This is an alias for `visibilityProperty`. Contemporary browsers
4493
+ // support both. However, this alias has wider browser support (Chrome
4494
+ // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
4495
+ // we include it anyway.
4496
+ checkVisibilityCSS: true
4497
+ });
4498
+ return !visible;
4499
+ }
4500
+ }
4501
+ if (getComputedStyle(node).visibility === "hidden") {
4502
+ return true;
4503
+ }
4504
+ var isDirectSummary = matches.call(node, "details>summary:first-of-type");
4505
+ var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
4506
+ if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
4507
+ return true;
4508
+ }
4509
+ if (!displayCheck || displayCheck === "full" || // full-native can run this branch when it falls through in case
4510
+ // Element#checkVisibility is unsupported
4511
+ displayCheck === "full-native" || displayCheck === "legacy-full") {
4512
+ if (typeof getShadowRoot === "function") {
4513
+ var originalNode = node;
4514
+ while (node) {
4515
+ var parentElement = node.parentElement;
4516
+ var rootNode = getRootNode(node);
4517
+ if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
4518
+ return isZeroArea(node);
4519
+ } else if (node.assignedSlot) {
4520
+ node = node.assignedSlot;
4521
+ } else if (!parentElement && rootNode !== node.ownerDocument) {
4522
+ node = rootNode.host;
4523
+ } else {
4524
+ node = parentElement;
4525
+ }
4526
+ }
4527
+ node = originalNode;
4528
+ }
4529
+ if (isNodeAttached(node)) {
4530
+ return !node.getClientRects().length;
4531
+ }
4532
+ if (displayCheck !== "legacy-full") {
4533
+ return true;
4534
+ }
4535
+ } else if (displayCheck === "non-zero-area") {
4536
+ return isZeroArea(node);
4537
+ }
4538
+ return false;
4539
+ };
4540
+ var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
4541
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
4542
+ var parentNode = node.parentElement;
4543
+ while (parentNode) {
4544
+ if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
4545
+ for (var i = 0; i < parentNode.children.length; i++) {
4546
+ var child = parentNode.children.item(i);
4547
+ if (child.tagName === "LEGEND") {
4548
+ return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
4549
+ }
4550
+ }
4551
+ return true;
4552
+ }
4553
+ parentNode = parentNode.parentElement;
4554
+ }
4555
+ }
4556
+ return false;
4557
+ };
4558
+ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
4559
+ if (node.disabled || // we must do an inert look up to filter out any elements inside an inert ancestor
4560
+ // because we're limited in the type of selectors we can use in JSDom (see related
4561
+ // note related to `candidateSelectors`)
4562
+ _isInert(node) || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
4563
+ isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
4564
+ return false;
4565
+ }
4566
+ return true;
4567
+ };
4568
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
4569
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
4570
+ return false;
4571
+ }
4572
+ return true;
4573
+ };
4574
+ var isShadowRootTabbable = function isShadowRootTabbable2(shadowHostNode) {
4575
+ var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
4576
+ if (isNaN(tabIndex) || tabIndex >= 0) {
4577
+ return true;
4578
+ }
4579
+ return false;
4580
+ };
4581
+ var _sortByOrder = function sortByOrder(candidates) {
4582
+ var regularTabbables = [];
4583
+ var orderedTabbables = [];
4584
+ candidates.forEach(function(item, i) {
4585
+ var isScope = !!item.scopeParent;
4586
+ var element = isScope ? item.scopeParent : item;
4587
+ var candidateTabindex = getSortOrderTabIndex(element, isScope);
4588
+ var elements = isScope ? _sortByOrder(item.candidates) : element;
4589
+ if (candidateTabindex === 0) {
4590
+ isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
4591
+ } else {
4592
+ orderedTabbables.push({
4593
+ documentOrder: i,
4594
+ tabIndex: candidateTabindex,
4595
+ item,
4596
+ isScope,
4597
+ content: elements
4598
+ });
4599
+ }
4600
+ });
4601
+ return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
4602
+ sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
4603
+ return acc;
4604
+ }, []).concat(regularTabbables);
4605
+ };
4606
+ var tabbable = function tabbable2(container, options) {
4607
+ options = options || {};
4608
+ var candidates;
4609
+ if (options.getShadowRoot) {
4610
+ candidates = _getCandidatesIteratively([container], options.includeContainer, {
4611
+ filter: isNodeMatchingSelectorTabbable.bind(null, options),
4612
+ flatten: false,
4613
+ getShadowRoot: options.getShadowRoot,
4614
+ shadowRootFilter: isShadowRootTabbable
4615
+ });
4616
+ } else {
4617
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
4618
+ }
4619
+ return _sortByOrder(candidates);
4620
+ };
4621
+
4622
+ // ../../node_modules/.pnpm/@floating-ui+react@0.27.16_react-dom@18.3.1_react@18.3.1/node_modules/@floating-ui/react/dist/floating-ui.react.utils.mjs
4623
+ function isSafari() {
4624
+ return /apple/i.test(navigator.vendor);
4625
+ }
4626
+ function activeElement(doc) {
4627
+ let activeElement2 = doc.activeElement;
4628
+ while (((_activeElement = activeElement2) == null || (_activeElement = _activeElement.shadowRoot) == null ? void 0 : _activeElement.activeElement) != null) {
4629
+ var _activeElement;
4630
+ activeElement2 = activeElement2.shadowRoot.activeElement;
4631
+ }
4632
+ return activeElement2;
4633
+ }
4634
+ function contains(parent, child) {
4635
+ if (!parent || !child) {
4636
+ return false;
4637
+ }
4638
+ const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
4639
+ if (parent.contains(child)) {
4640
+ return true;
4641
+ }
4642
+ if (rootNode && isShadowRoot(rootNode)) {
4643
+ let next = child;
4644
+ while (next) {
4645
+ if (parent === next) {
4646
+ return true;
4647
+ }
4648
+ next = next.parentNode || next.host;
4649
+ }
4650
+ }
4651
+ return false;
4652
+ }
4653
+ function getDocument(node) {
4654
+ return (node == null ? void 0 : node.ownerDocument) || document;
4655
+ }
4656
+ var isClient = typeof document !== "undefined";
4657
+ var noop = function noop2() {
4658
+ };
4659
+ var index = isClient ? useLayoutEffect3 : noop;
4660
+ var SafeReact = {
4661
+ ...React
4662
+ };
4663
+ var useInsertionEffect = SafeReact.useInsertionEffect;
4664
+ var useSafeInsertionEffect = useInsertionEffect || ((fn) => fn());
4665
+ function useEffectEvent(callback) {
4666
+ const ref = React.useRef(() => {
4667
+ if (process.env.NODE_ENV !== "production") {
4668
+ throw new Error("Cannot call an event handler while rendering.");
4669
+ }
4670
+ });
4671
+ useSafeInsertionEffect(() => {
4672
+ ref.current = callback;
4673
+ });
4674
+ return React.useCallback(function() {
4675
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4676
+ args[_key] = arguments[_key];
4677
+ }
4678
+ return ref.current == null ? void 0 : ref.current(...args);
4679
+ }, []);
4680
+ }
4681
+ var getTabbableOptions = () => ({
4682
+ getShadowRoot: true,
4683
+ displayCheck: (
4684
+ // JSDOM does not support the `tabbable` library. To solve this we can
4685
+ // check if `ResizeObserver` is a real function (not polyfilled), which
4686
+ // determines if the current environment is JSDOM-like.
4687
+ typeof ResizeObserver === "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
4688
+ )
4689
+ });
4690
+ function getTabbableIn(container, dir) {
4691
+ const list = tabbable(container, getTabbableOptions());
4692
+ const len = list.length;
4693
+ if (len === 0)
4694
+ return;
4695
+ const active = activeElement(getDocument(container));
4696
+ const index3 = list.indexOf(active);
4697
+ const nextIndex = index3 === -1 ? dir === 1 ? 0 : len - 1 : index3 + dir;
4698
+ return list[nextIndex];
4699
+ }
4700
+ function getNextTabbable(referenceElement) {
4701
+ return getTabbableIn(getDocument(referenceElement).body, 1) || referenceElement;
4702
+ }
4703
+ function getPreviousTabbable(referenceElement) {
4704
+ return getTabbableIn(getDocument(referenceElement).body, -1) || referenceElement;
4705
+ }
4706
+ function isOutsideEvent(event, container) {
4707
+ const containerElement = container || event.currentTarget;
4708
+ const relatedTarget = event.relatedTarget;
4709
+ return !relatedTarget || !contains(containerElement, relatedTarget);
4710
+ }
4711
+ function disableFocusInside(container) {
4712
+ const tabbableElements = tabbable(container, getTabbableOptions());
4713
+ tabbableElements.forEach((element) => {
4714
+ element.dataset.tabindex = element.getAttribute("tabindex") || "";
4715
+ element.setAttribute("tabindex", "-1");
4716
+ });
4717
+ }
4718
+ function enableFocusInside(container) {
4719
+ const elements = container.querySelectorAll("[data-tabindex]");
4720
+ elements.forEach((element) => {
4721
+ const tabindex = element.dataset.tabindex;
4722
+ delete element.dataset.tabindex;
4723
+ if (tabindex) {
4724
+ element.setAttribute("tabindex", tabindex);
4725
+ } else {
4726
+ element.removeAttribute("tabindex");
4727
+ }
4728
+ });
4729
+ }
4730
+
4731
+ // ../../node_modules/.pnpm/@floating-ui+react@0.27.16_react-dom@18.3.1_react@18.3.1/node_modules/@floating-ui/react/dist/floating-ui.react.mjs
4732
+ import { jsx as jsx11, jsxs as jsxs8, Fragment as Fragment3 } from "react/jsx-runtime";
4733
+ import * as ReactDOM2 from "react-dom";
4734
+
4735
+ // ../../node_modules/.pnpm/@floating-ui+core@1.7.3/node_modules/@floating-ui/core/dist/floating-ui.core.mjs
4736
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
4737
+ let {
4738
+ reference,
4739
+ floating
4740
+ } = _ref;
4741
+ const sideAxis = getSideAxis(placement);
4742
+ const alignmentAxis = getAlignmentAxis(placement);
4743
+ const alignLength = getAxisLength(alignmentAxis);
4744
+ const side = getSide(placement);
4745
+ const isVertical = sideAxis === "y";
4746
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
4747
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
4748
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4749
+ let coords;
4750
+ switch (side) {
4751
+ case "top":
4752
+ coords = {
4753
+ x: commonX,
4754
+ y: reference.y - floating.height
4755
+ };
4756
+ break;
4757
+ case "bottom":
4758
+ coords = {
4759
+ x: commonX,
4760
+ y: reference.y + reference.height
4761
+ };
4762
+ break;
4763
+ case "right":
4764
+ coords = {
4765
+ x: reference.x + reference.width,
4766
+ y: commonY
4767
+ };
4768
+ break;
4769
+ case "left":
4770
+ coords = {
4771
+ x: reference.x - floating.width,
4772
+ y: commonY
4773
+ };
4774
+ break;
4775
+ default:
4776
+ coords = {
4777
+ x: reference.x,
4778
+ y: reference.y
4779
+ };
4780
+ }
4781
+ switch (getAlignment(placement)) {
4782
+ case "start":
4783
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
4784
+ break;
4785
+ case "end":
4786
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
4787
+ break;
4788
+ }
4789
+ return coords;
4790
+ }
4791
+ var computePosition = async (reference, floating, config) => {
4792
+ const {
4793
+ placement = "bottom",
4794
+ strategy = "absolute",
4795
+ middleware = [],
4796
+ platform: platform2
4797
+ } = config;
4798
+ const validMiddleware = middleware.filter(Boolean);
4799
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
4800
+ let rects = await platform2.getElementRects({
4801
+ reference,
4802
+ floating,
4803
+ strategy
4804
+ });
4805
+ let {
4806
+ x,
4807
+ y
4808
+ } = computeCoordsFromPlacement(rects, placement, rtl);
4809
+ let statefulPlacement = placement;
4810
+ let middlewareData = {};
4811
+ let resetCount = 0;
4812
+ for (let i = 0; i < validMiddleware.length; i++) {
4813
+ const {
4814
+ name,
4815
+ fn
4816
+ } = validMiddleware[i];
4817
+ const {
4818
+ x: nextX,
4819
+ y: nextY,
4820
+ data,
4821
+ reset
4822
+ } = await fn({
4823
+ x,
4824
+ y,
4825
+ initialPlacement: placement,
4826
+ placement: statefulPlacement,
4827
+ strategy,
4828
+ middlewareData,
4829
+ rects,
4830
+ platform: platform2,
4831
+ elements: {
4832
+ reference,
4833
+ floating
4834
+ }
4835
+ });
4836
+ x = nextX != null ? nextX : x;
4837
+ y = nextY != null ? nextY : y;
4838
+ middlewareData = {
4839
+ ...middlewareData,
4840
+ [name]: {
4841
+ ...middlewareData[name],
4842
+ ...data
4843
+ }
4844
+ };
4845
+ if (reset && resetCount <= 50) {
4846
+ resetCount++;
4847
+ if (typeof reset === "object") {
4848
+ if (reset.placement) {
4849
+ statefulPlacement = reset.placement;
4850
+ }
4851
+ if (reset.rects) {
4852
+ rects = reset.rects === true ? await platform2.getElementRects({
4853
+ reference,
4854
+ floating,
4855
+ strategy
4856
+ }) : reset.rects;
4857
+ }
4858
+ ({
4859
+ x,
4860
+ y
4861
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4862
+ }
4863
+ i = -1;
4864
+ }
4865
+ }
4866
+ return {
4867
+ x,
4868
+ y,
4869
+ placement: statefulPlacement,
4870
+ strategy,
4871
+ middlewareData
4872
+ };
4873
+ };
4874
+ async function detectOverflow(state, options) {
4875
+ var _await$platform$isEle;
4876
+ if (options === void 0) {
4877
+ options = {};
4878
+ }
4879
+ const {
4880
+ x,
4881
+ y,
4882
+ platform: platform2,
4883
+ rects,
4884
+ elements,
4885
+ strategy
4886
+ } = state;
4887
+ const {
4888
+ boundary = "clippingAncestors",
4889
+ rootBoundary = "viewport",
4890
+ elementContext = "floating",
4891
+ altBoundary = false,
4892
+ padding = 0
4893
+ } = evaluate(options, state);
4894
+ const paddingObject = getPaddingObject(padding);
4895
+ const altContext = elementContext === "floating" ? "reference" : "floating";
4896
+ const element = elements[altBoundary ? altContext : elementContext];
4897
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
4898
+ element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
4899
+ boundary,
4900
+ rootBoundary,
4901
+ strategy
4902
+ }));
4903
+ const rect = elementContext === "floating" ? {
4904
+ x,
4905
+ y,
4906
+ width: rects.floating.width,
4907
+ height: rects.floating.height
4908
+ } : rects.reference;
4909
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
4910
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
4911
+ x: 1,
4912
+ y: 1
4913
+ } : {
4914
+ x: 1,
4915
+ y: 1
4916
+ };
4917
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
4918
+ elements,
4919
+ rect,
4920
+ offsetParent,
4921
+ strategy
4922
+ }) : rect);
4923
+ return {
4924
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4925
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4926
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4927
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4928
+ };
4929
+ }
4930
+ var flip = function(options) {
4931
+ if (options === void 0) {
4932
+ options = {};
4933
+ }
4934
+ return {
4935
+ name: "flip",
4936
+ options,
4937
+ async fn(state) {
4938
+ var _middlewareData$arrow, _middlewareData$flip;
4939
+ const {
4940
+ placement,
4941
+ middlewareData,
4942
+ rects,
4943
+ initialPlacement,
4944
+ platform: platform2,
4945
+ elements
4946
+ } = state;
4947
+ const {
4948
+ mainAxis: checkMainAxis = true,
4949
+ crossAxis: checkCrossAxis = true,
4950
+ fallbackPlacements: specifiedFallbackPlacements,
4951
+ fallbackStrategy = "bestFit",
4952
+ fallbackAxisSideDirection = "none",
4953
+ flipAlignment = true,
4954
+ ...detectOverflowOptions
4955
+ } = evaluate(options, state);
4956
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4957
+ return {};
4958
+ }
4959
+ const side = getSide(placement);
4960
+ const initialSideAxis = getSideAxis(initialPlacement);
4961
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4962
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
4963
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4964
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4965
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4966
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4967
+ }
4968
+ const placements2 = [initialPlacement, ...fallbackPlacements];
4969
+ const overflow = await detectOverflow(state, detectOverflowOptions);
4970
+ const overflows = [];
4971
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4972
+ if (checkMainAxis) {
4973
+ overflows.push(overflow[side]);
4974
+ }
4975
+ if (checkCrossAxis) {
4976
+ const sides2 = getAlignmentSides(placement, rects, rtl);
4977
+ overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4978
+ }
4979
+ overflowsData = [...overflowsData, {
4980
+ placement,
4981
+ overflows
4982
+ }];
4983
+ if (!overflows.every((side2) => side2 <= 0)) {
4984
+ var _middlewareData$flip2, _overflowsData$filter;
4985
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4986
+ const nextPlacement = placements2[nextIndex];
4987
+ if (nextPlacement) {
4988
+ const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4989
+ if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4990
+ // overflows the main axis.
4991
+ overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
4992
+ return {
4993
+ data: {
4994
+ index: nextIndex,
4995
+ overflows: overflowsData
4996
+ },
4997
+ reset: {
4998
+ placement: nextPlacement
4999
+ }
5000
+ };
5001
+ }
5002
+ }
5003
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
5004
+ if (!resetPlacement) {
5005
+ switch (fallbackStrategy) {
5006
+ case "bestFit": {
5007
+ var _overflowsData$filter2;
5008
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
5009
+ if (hasFallbackAxisSideDirection) {
5010
+ const currentSideAxis = getSideAxis(d.placement);
5011
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
5012
+ // reading directions favoring greater width.
5013
+ currentSideAxis === "y";
5014
+ }
5015
+ return true;
5016
+ }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
5017
+ if (placement2) {
5018
+ resetPlacement = placement2;
5019
+ }
5020
+ break;
5021
+ }
5022
+ case "initialPlacement":
5023
+ resetPlacement = initialPlacement;
5024
+ break;
5025
+ }
5026
+ }
5027
+ if (placement !== resetPlacement) {
5028
+ return {
5029
+ reset: {
5030
+ placement: resetPlacement
5031
+ }
5032
+ };
5033
+ }
5034
+ }
5035
+ return {};
5036
+ }
5037
+ };
5038
+ };
5039
+ var originSides = /* @__PURE__ */ new Set(["left", "top"]);
5040
+ async function convertValueToCoords(state, options) {
5041
+ const {
5042
+ placement,
5043
+ platform: platform2,
5044
+ elements
5045
+ } = state;
5046
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
5047
+ const side = getSide(placement);
5048
+ const alignment = getAlignment(placement);
5049
+ const isVertical = getSideAxis(placement) === "y";
5050
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
5051
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
5052
+ const rawValue = evaluate(options, state);
5053
+ let {
5054
+ mainAxis,
5055
+ crossAxis,
5056
+ alignmentAxis
5057
+ } = typeof rawValue === "number" ? {
5058
+ mainAxis: rawValue,
5059
+ crossAxis: 0,
5060
+ alignmentAxis: null
5061
+ } : {
5062
+ mainAxis: rawValue.mainAxis || 0,
5063
+ crossAxis: rawValue.crossAxis || 0,
5064
+ alignmentAxis: rawValue.alignmentAxis
5065
+ };
5066
+ if (alignment && typeof alignmentAxis === "number") {
5067
+ crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
5068
+ }
5069
+ return isVertical ? {
5070
+ x: crossAxis * crossAxisMulti,
5071
+ y: mainAxis * mainAxisMulti
5072
+ } : {
5073
+ x: mainAxis * mainAxisMulti,
5074
+ y: crossAxis * crossAxisMulti
5075
+ };
5076
+ }
5077
+ var offset = function(options) {
5078
+ if (options === void 0) {
5079
+ options = 0;
5080
+ }
5081
+ return {
5082
+ name: "offset",
5083
+ options,
5084
+ async fn(state) {
5085
+ var _middlewareData$offse, _middlewareData$arrow;
5086
+ const {
5087
+ x,
5088
+ y,
5089
+ placement,
5090
+ middlewareData
5091
+ } = state;
5092
+ const diffCoords = await convertValueToCoords(state, options);
5093
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
5094
+ return {};
5095
+ }
5096
+ return {
5097
+ x: x + diffCoords.x,
5098
+ y: y + diffCoords.y,
5099
+ data: {
5100
+ ...diffCoords,
5101
+ placement
5102
+ }
5103
+ };
5104
+ }
5105
+ };
5106
+ };
5107
+ var shift = function(options) {
5108
+ if (options === void 0) {
5109
+ options = {};
5110
+ }
5111
+ return {
5112
+ name: "shift",
5113
+ options,
5114
+ async fn(state) {
5115
+ const {
5116
+ x,
5117
+ y,
5118
+ placement
5119
+ } = state;
5120
+ const {
5121
+ mainAxis: checkMainAxis = true,
5122
+ crossAxis: checkCrossAxis = false,
5123
+ limiter = {
5124
+ fn: (_ref) => {
5125
+ let {
5126
+ x: x2,
5127
+ y: y2
5128
+ } = _ref;
5129
+ return {
5130
+ x: x2,
5131
+ y: y2
5132
+ };
5133
+ }
5134
+ },
5135
+ ...detectOverflowOptions
5136
+ } = evaluate(options, state);
5137
+ const coords = {
5138
+ x,
5139
+ y
5140
+ };
5141
+ const overflow = await detectOverflow(state, detectOverflowOptions);
5142
+ const crossAxis = getSideAxis(getSide(placement));
5143
+ const mainAxis = getOppositeAxis(crossAxis);
5144
+ let mainAxisCoord = coords[mainAxis];
5145
+ let crossAxisCoord = coords[crossAxis];
5146
+ if (checkMainAxis) {
5147
+ const minSide = mainAxis === "y" ? "top" : "left";
5148
+ const maxSide = mainAxis === "y" ? "bottom" : "right";
5149
+ const min2 = mainAxisCoord + overflow[minSide];
5150
+ const max2 = mainAxisCoord - overflow[maxSide];
5151
+ mainAxisCoord = clamp(min2, mainAxisCoord, max2);
5152
+ }
5153
+ if (checkCrossAxis) {
5154
+ const minSide = crossAxis === "y" ? "top" : "left";
5155
+ const maxSide = crossAxis === "y" ? "bottom" : "right";
5156
+ const min2 = crossAxisCoord + overflow[minSide];
5157
+ const max2 = crossAxisCoord - overflow[maxSide];
5158
+ crossAxisCoord = clamp(min2, crossAxisCoord, max2);
5159
+ }
5160
+ const limitedCoords = limiter.fn({
5161
+ ...state,
5162
+ [mainAxis]: mainAxisCoord,
5163
+ [crossAxis]: crossAxisCoord
5164
+ });
5165
+ return {
5166
+ ...limitedCoords,
5167
+ data: {
5168
+ x: limitedCoords.x - x,
5169
+ y: limitedCoords.y - y,
5170
+ enabled: {
5171
+ [mainAxis]: checkMainAxis,
5172
+ [crossAxis]: checkCrossAxis
5173
+ }
5174
+ }
5175
+ };
5176
+ }
5177
+ };
5178
+ };
5179
+ var size = function(options) {
5180
+ if (options === void 0) {
5181
+ options = {};
5182
+ }
5183
+ return {
5184
+ name: "size",
5185
+ options,
5186
+ async fn(state) {
5187
+ var _state$middlewareData, _state$middlewareData2;
5188
+ const {
5189
+ placement,
5190
+ rects,
5191
+ platform: platform2,
5192
+ elements
5193
+ } = state;
5194
+ const {
5195
+ apply = () => {
5196
+ },
5197
+ ...detectOverflowOptions
5198
+ } = evaluate(options, state);
5199
+ const overflow = await detectOverflow(state, detectOverflowOptions);
5200
+ const side = getSide(placement);
5201
+ const alignment = getAlignment(placement);
5202
+ const isYAxis = getSideAxis(placement) === "y";
5203
+ const {
5204
+ width,
5205
+ height
5206
+ } = rects.floating;
5207
+ let heightSide;
5208
+ let widthSide;
5209
+ if (side === "top" || side === "bottom") {
5210
+ heightSide = side;
5211
+ widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
5212
+ } else {
5213
+ widthSide = side;
5214
+ heightSide = alignment === "end" ? "top" : "bottom";
5215
+ }
5216
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
5217
+ const maximumClippingWidth = width - overflow.left - overflow.right;
5218
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
5219
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
5220
+ const noShift = !state.middlewareData.shift;
5221
+ let availableHeight = overflowAvailableHeight;
5222
+ let availableWidth = overflowAvailableWidth;
5223
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
5224
+ availableWidth = maximumClippingWidth;
5225
+ }
5226
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
5227
+ availableHeight = maximumClippingHeight;
5228
+ }
5229
+ if (noShift && !alignment) {
5230
+ const xMin = max(overflow.left, 0);
5231
+ const xMax = max(overflow.right, 0);
5232
+ const yMin = max(overflow.top, 0);
5233
+ const yMax = max(overflow.bottom, 0);
5234
+ if (isYAxis) {
5235
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
5236
+ } else {
5237
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
5238
+ }
5239
+ }
5240
+ await apply({
5241
+ ...state,
5242
+ availableWidth,
5243
+ availableHeight
5244
+ });
5245
+ const nextDimensions = await platform2.getDimensions(elements.floating);
5246
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
5247
+ return {
5248
+ reset: {
5249
+ rects: true
5250
+ }
5251
+ };
5252
+ }
5253
+ return {};
5254
+ }
5255
+ };
5256
+ };
5257
+
5258
+ // ../../node_modules/.pnpm/@floating-ui+dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
5259
+ function getCssDimensions(element) {
5260
+ const css = getComputedStyle2(element);
5261
+ let width = parseFloat(css.width) || 0;
5262
+ let height = parseFloat(css.height) || 0;
5263
+ const hasOffset = isHTMLElement(element);
5264
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
5265
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
5266
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
5267
+ if (shouldFallback) {
5268
+ width = offsetWidth;
5269
+ height = offsetHeight;
5270
+ }
5271
+ return {
5272
+ width,
5273
+ height,
5274
+ $: shouldFallback
5275
+ };
5276
+ }
5277
+ function unwrapElement(element) {
5278
+ return !isElement(element) ? element.contextElement : element;
5279
+ }
5280
+ function getScale(element) {
5281
+ const domElement = unwrapElement(element);
5282
+ if (!isHTMLElement(domElement)) {
5283
+ return createCoords(1);
5284
+ }
5285
+ const rect = domElement.getBoundingClientRect();
5286
+ const {
5287
+ width,
5288
+ height,
5289
+ $
5290
+ } = getCssDimensions(domElement);
5291
+ let x = ($ ? round(rect.width) : rect.width) / width;
5292
+ let y = ($ ? round(rect.height) : rect.height) / height;
5293
+ if (!x || !Number.isFinite(x)) {
5294
+ x = 1;
5295
+ }
5296
+ if (!y || !Number.isFinite(y)) {
5297
+ y = 1;
5298
+ }
5299
+ return {
5300
+ x,
5301
+ y
5302
+ };
5303
+ }
5304
+ var noOffsets = /* @__PURE__ */ createCoords(0);
5305
+ function getVisualOffsets(element) {
5306
+ const win = getWindow(element);
5307
+ if (!isWebKit() || !win.visualViewport) {
5308
+ return noOffsets;
5309
+ }
5310
+ return {
5311
+ x: win.visualViewport.offsetLeft,
5312
+ y: win.visualViewport.offsetTop
5313
+ };
5314
+ }
5315
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
5316
+ if (isFixed === void 0) {
5317
+ isFixed = false;
5318
+ }
5319
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
5320
+ return false;
5321
+ }
5322
+ return isFixed;
5323
+ }
5324
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5325
+ if (includeScale === void 0) {
5326
+ includeScale = false;
5327
+ }
5328
+ if (isFixedStrategy === void 0) {
5329
+ isFixedStrategy = false;
5330
+ }
5331
+ const clientRect = element.getBoundingClientRect();
5332
+ const domElement = unwrapElement(element);
5333
+ let scale = createCoords(1);
5334
+ if (includeScale) {
5335
+ if (offsetParent) {
5336
+ if (isElement(offsetParent)) {
5337
+ scale = getScale(offsetParent);
5338
+ }
5339
+ } else {
5340
+ scale = getScale(element);
5341
+ }
5342
+ }
5343
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5344
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
5345
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
5346
+ let width = clientRect.width / scale.x;
5347
+ let height = clientRect.height / scale.y;
5348
+ if (domElement) {
5349
+ const win = getWindow(domElement);
5350
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5351
+ let currentWin = win;
5352
+ let currentIFrame = getFrameElement(currentWin);
5353
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5354
+ const iframeScale = getScale(currentIFrame);
5355
+ const iframeRect = currentIFrame.getBoundingClientRect();
5356
+ const css = getComputedStyle2(currentIFrame);
5357
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5358
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5359
+ x *= iframeScale.x;
5360
+ y *= iframeScale.y;
5361
+ width *= iframeScale.x;
5362
+ height *= iframeScale.y;
5363
+ x += left;
5364
+ y += top;
5365
+ currentWin = getWindow(currentIFrame);
5366
+ currentIFrame = getFrameElement(currentWin);
5367
+ }
5368
+ }
5369
+ return rectToClientRect({
5370
+ width,
5371
+ height,
5372
+ x,
5373
+ y
5374
+ });
5375
+ }
5376
+ function getWindowScrollBarX(element, rect) {
5377
+ const leftScroll = getNodeScroll(element).scrollLeft;
5378
+ if (!rect) {
5379
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5380
+ }
5381
+ return rect.left + leftScroll;
5382
+ }
5383
+ function getHTMLOffset(documentElement, scroll) {
5384
+ const htmlRect = documentElement.getBoundingClientRect();
5385
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5386
+ const y = htmlRect.top + scroll.scrollTop;
5387
+ return {
5388
+ x,
5389
+ y
5390
+ };
5391
+ }
5392
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5393
+ let {
5394
+ elements,
5395
+ rect,
5396
+ offsetParent,
5397
+ strategy
5398
+ } = _ref;
5399
+ const isFixed = strategy === "fixed";
5400
+ const documentElement = getDocumentElement(offsetParent);
5401
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
5402
+ if (offsetParent === documentElement || topLayer && isFixed) {
5403
+ return rect;
5404
+ }
5405
+ let scroll = {
5406
+ scrollLeft: 0,
5407
+ scrollTop: 0
5408
+ };
5409
+ let scale = createCoords(1);
5410
+ const offsets = createCoords(0);
5411
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
5412
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5413
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5414
+ scroll = getNodeScroll(offsetParent);
5415
+ }
5416
+ if (isHTMLElement(offsetParent)) {
5417
+ const offsetRect = getBoundingClientRect(offsetParent);
5418
+ scale = getScale(offsetParent);
5419
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
5420
+ offsets.y = offsetRect.y + offsetParent.clientTop;
5421
+ }
5422
+ }
5423
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5424
+ return {
5425
+ width: rect.width * scale.x,
5426
+ height: rect.height * scale.y,
5427
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5428
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5429
+ };
5430
+ }
5431
+ function getClientRects(element) {
5432
+ return Array.from(element.getClientRects());
5433
+ }
5434
+ function getDocumentRect(element) {
5435
+ const html = getDocumentElement(element);
5436
+ const scroll = getNodeScroll(element);
5437
+ const body = element.ownerDocument.body;
5438
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5439
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5440
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
5441
+ const y = -scroll.scrollTop;
5442
+ if (getComputedStyle2(body).direction === "rtl") {
5443
+ x += max(html.clientWidth, body.clientWidth) - width;
5444
+ }
5445
+ return {
5446
+ width,
5447
+ height,
5448
+ x,
5449
+ y
5450
+ };
5451
+ }
5452
+ var SCROLLBAR_MAX = 25;
5453
+ function getViewportRect(element, strategy) {
5454
+ const win = getWindow(element);
5455
+ const html = getDocumentElement(element);
5456
+ const visualViewport = win.visualViewport;
5457
+ let width = html.clientWidth;
5458
+ let height = html.clientHeight;
5459
+ let x = 0;
5460
+ let y = 0;
5461
+ if (visualViewport) {
5462
+ width = visualViewport.width;
5463
+ height = visualViewport.height;
5464
+ const visualViewportBased = isWebKit();
5465
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
5466
+ x = visualViewport.offsetLeft;
5467
+ y = visualViewport.offsetTop;
5468
+ }
5469
+ }
5470
+ const windowScrollbarX = getWindowScrollBarX(html);
5471
+ if (windowScrollbarX <= 0) {
5472
+ const doc = html.ownerDocument;
5473
+ const body = doc.body;
5474
+ const bodyStyles = getComputedStyle(body);
5475
+ const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5476
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5477
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5478
+ width -= clippingStableScrollbarWidth;
5479
+ }
5480
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5481
+ width += windowScrollbarX;
5482
+ }
5483
+ return {
5484
+ width,
5485
+ height,
5486
+ x,
5487
+ y
5488
+ };
5489
+ }
5490
+ var absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
5491
+ function getInnerBoundingClientRect(element, strategy) {
5492
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5493
+ const top = clientRect.top + element.clientTop;
5494
+ const left = clientRect.left + element.clientLeft;
5495
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5496
+ const width = element.clientWidth * scale.x;
5497
+ const height = element.clientHeight * scale.y;
5498
+ const x = left * scale.x;
5499
+ const y = top * scale.y;
5500
+ return {
5501
+ width,
5502
+ height,
5503
+ x,
5504
+ y
5505
+ };
5506
+ }
5507
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5508
+ let rect;
5509
+ if (clippingAncestor === "viewport") {
5510
+ rect = getViewportRect(element, strategy);
5511
+ } else if (clippingAncestor === "document") {
5512
+ rect = getDocumentRect(getDocumentElement(element));
5513
+ } else if (isElement(clippingAncestor)) {
5514
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5515
+ } else {
5516
+ const visualOffsets = getVisualOffsets(element);
5517
+ rect = {
5518
+ x: clippingAncestor.x - visualOffsets.x,
5519
+ y: clippingAncestor.y - visualOffsets.y,
5520
+ width: clippingAncestor.width,
5521
+ height: clippingAncestor.height
5522
+ };
5523
+ }
5524
+ return rectToClientRect(rect);
5525
+ }
5526
+ function hasFixedPositionAncestor(element, stopNode) {
5527
+ const parentNode = getParentNode(element);
5528
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5529
+ return false;
5530
+ }
5531
+ return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
5532
+ }
5533
+ function getClippingElementAncestors(element, cache) {
5534
+ const cachedResult = cache.get(element);
5535
+ if (cachedResult) {
5536
+ return cachedResult;
5537
+ }
5538
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5539
+ let currentContainingBlockComputedStyle = null;
5540
+ const elementIsFixed = getComputedStyle2(element).position === "fixed";
5541
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
5542
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5543
+ const computedStyle = getComputedStyle2(currentNode);
5544
+ const currentNodeIsContaining = isContainingBlock(currentNode);
5545
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
5546
+ currentContainingBlockComputedStyle = null;
5547
+ }
5548
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5549
+ if (shouldDropCurrentNode) {
5550
+ result = result.filter((ancestor) => ancestor !== currentNode);
5551
+ } else {
5552
+ currentContainingBlockComputedStyle = computedStyle;
5553
+ }
5554
+ currentNode = getParentNode(currentNode);
5555
+ }
5556
+ cache.set(element, result);
5557
+ return result;
5558
+ }
5559
+ function getClippingRect(_ref) {
5560
+ let {
5561
+ element,
5562
+ boundary,
5563
+ rootBoundary,
5564
+ strategy
5565
+ } = _ref;
5566
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5567
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5568
+ const firstClippingAncestor = clippingAncestors[0];
5569
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
5570
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
5571
+ accRect.top = max(rect.top, accRect.top);
5572
+ accRect.right = min(rect.right, accRect.right);
5573
+ accRect.bottom = min(rect.bottom, accRect.bottom);
5574
+ accRect.left = max(rect.left, accRect.left);
5575
+ return accRect;
5576
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
5577
+ return {
5578
+ width: clippingRect.right - clippingRect.left,
5579
+ height: clippingRect.bottom - clippingRect.top,
5580
+ x: clippingRect.left,
5581
+ y: clippingRect.top
5582
+ };
5583
+ }
5584
+ function getDimensions(element) {
5585
+ const {
5586
+ width,
5587
+ height
5588
+ } = getCssDimensions(element);
5589
+ return {
5590
+ width,
5591
+ height
5592
+ };
5593
+ }
5594
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5595
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
5596
+ const documentElement = getDocumentElement(offsetParent);
5597
+ const isFixed = strategy === "fixed";
5598
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5599
+ let scroll = {
5600
+ scrollLeft: 0,
5601
+ scrollTop: 0
5602
+ };
5603
+ const offsets = createCoords(0);
5604
+ function setLeftRTLScrollbarOffset() {
5605
+ offsets.x = getWindowScrollBarX(documentElement);
5606
+ }
5607
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5608
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5609
+ scroll = getNodeScroll(offsetParent);
5610
+ }
5611
+ if (isOffsetParentAnElement) {
5612
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5613
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
5614
+ offsets.y = offsetRect.y + offsetParent.clientTop;
5615
+ } else if (documentElement) {
5616
+ setLeftRTLScrollbarOffset();
5617
+ }
5618
+ }
5619
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
5620
+ setLeftRTLScrollbarOffset();
5621
+ }
5622
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5623
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5624
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5625
+ return {
5626
+ x,
5627
+ y,
5628
+ width: rect.width,
5629
+ height: rect.height
5630
+ };
5631
+ }
5632
+ function isStaticPositioned(element) {
5633
+ return getComputedStyle2(element).position === "static";
5634
+ }
5635
+ function getTrueOffsetParent(element, polyfill) {
5636
+ if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
5637
+ return null;
5638
+ }
5639
+ if (polyfill) {
5640
+ return polyfill(element);
5641
+ }
5642
+ let rawOffsetParent = element.offsetParent;
5643
+ if (getDocumentElement(element) === rawOffsetParent) {
5644
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
5645
+ }
5646
+ return rawOffsetParent;
5647
+ }
5648
+ function getOffsetParent(element, polyfill) {
5649
+ const win = getWindow(element);
5650
+ if (isTopLayer(element)) {
5651
+ return win;
5652
+ }
5653
+ if (!isHTMLElement(element)) {
5654
+ let svgOffsetParent = getParentNode(element);
5655
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5656
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5657
+ return svgOffsetParent;
5658
+ }
5659
+ svgOffsetParent = getParentNode(svgOffsetParent);
5660
+ }
5661
+ return win;
5662
+ }
5663
+ let offsetParent = getTrueOffsetParent(element, polyfill);
5664
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5665
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5666
+ }
5667
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5668
+ return win;
5669
+ }
5670
+ return offsetParent || getContainingBlock(element) || win;
5671
+ }
5672
+ var getElementRects = async function(data) {
5673
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5674
+ const getDimensionsFn = this.getDimensions;
5675
+ const floatingDimensions = await getDimensionsFn(data.floating);
5676
+ return {
5677
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5678
+ floating: {
5679
+ x: 0,
5680
+ y: 0,
5681
+ width: floatingDimensions.width,
5682
+ height: floatingDimensions.height
5683
+ }
5684
+ };
5685
+ };
5686
+ function isRTL(element) {
5687
+ return getComputedStyle2(element).direction === "rtl";
5688
+ }
5689
+ var platform = {
5690
+ convertOffsetParentRelativeRectToViewportRelativeRect,
5691
+ getDocumentElement,
5692
+ getClippingRect,
5693
+ getOffsetParent,
5694
+ getElementRects,
5695
+ getClientRects,
5696
+ getDimensions,
5697
+ getScale,
5698
+ isElement,
5699
+ isRTL
5700
+ };
5701
+ function rectsAreEqual(a, b) {
5702
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
5703
+ }
5704
+ function observeMove(element, onMove) {
5705
+ let io = null;
5706
+ let timeoutId;
5707
+ const root = getDocumentElement(element);
5708
+ function cleanup() {
5709
+ var _io;
5710
+ clearTimeout(timeoutId);
5711
+ (_io = io) == null || _io.disconnect();
5712
+ io = null;
5713
+ }
5714
+ function refresh(skip, threshold) {
5715
+ if (skip === void 0) {
5716
+ skip = false;
5717
+ }
5718
+ if (threshold === void 0) {
5719
+ threshold = 1;
5720
+ }
5721
+ cleanup();
5722
+ const elementRectForRootMargin = element.getBoundingClientRect();
5723
+ const {
5724
+ left,
5725
+ top,
5726
+ width,
5727
+ height
5728
+ } = elementRectForRootMargin;
5729
+ if (!skip) {
5730
+ onMove();
5731
+ }
5732
+ if (!width || !height) {
5733
+ return;
5734
+ }
5735
+ const insetTop = floor(top);
5736
+ const insetRight = floor(root.clientWidth - (left + width));
5737
+ const insetBottom = floor(root.clientHeight - (top + height));
5738
+ const insetLeft = floor(left);
5739
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5740
+ const options = {
5741
+ rootMargin,
5742
+ threshold: max(0, min(1, threshold)) || 1
5743
+ };
5744
+ let isFirstUpdate = true;
5745
+ function handleObserve(entries) {
5746
+ const ratio = entries[0].intersectionRatio;
5747
+ if (ratio !== threshold) {
5748
+ if (!isFirstUpdate) {
5749
+ return refresh();
5750
+ }
5751
+ if (!ratio) {
5752
+ timeoutId = setTimeout(() => {
5753
+ refresh(false, 1e-7);
5754
+ }, 1e3);
5755
+ } else {
5756
+ refresh(false, ratio);
5757
+ }
5758
+ }
5759
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5760
+ refresh();
5761
+ }
5762
+ isFirstUpdate = false;
5763
+ }
5764
+ try {
5765
+ io = new IntersectionObserver(handleObserve, {
5766
+ ...options,
5767
+ // Handle <iframe>s
5768
+ root: root.ownerDocument
5769
+ });
5770
+ } catch (_e) {
5771
+ io = new IntersectionObserver(handleObserve, options);
5772
+ }
5773
+ io.observe(element);
5774
+ }
5775
+ refresh(true);
5776
+ return cleanup;
5777
+ }
5778
+ function autoUpdate(reference, floating, update, options) {
5779
+ if (options === void 0) {
5780
+ options = {};
5781
+ }
5782
+ const {
5783
+ ancestorScroll = true,
5784
+ ancestorResize = true,
5785
+ elementResize = typeof ResizeObserver === "function",
5786
+ layoutShift = typeof IntersectionObserver === "function",
5787
+ animationFrame = false
5788
+ } = options;
5789
+ const referenceEl = unwrapElement(reference);
5790
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
5791
+ ancestors.forEach((ancestor) => {
5792
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
5793
+ passive: true
5794
+ });
5795
+ ancestorResize && ancestor.addEventListener("resize", update);
5796
+ });
5797
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
5798
+ let reobserveFrame = -1;
5799
+ let resizeObserver = null;
5800
+ if (elementResize) {
5801
+ resizeObserver = new ResizeObserver((_ref) => {
5802
+ let [firstEntry] = _ref;
5803
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
5804
+ resizeObserver.unobserve(floating);
5805
+ cancelAnimationFrame(reobserveFrame);
5806
+ reobserveFrame = requestAnimationFrame(() => {
5807
+ var _resizeObserver;
5808
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5809
+ });
5810
+ }
5811
+ update();
5812
+ });
5813
+ if (referenceEl && !animationFrame) {
5814
+ resizeObserver.observe(referenceEl);
5815
+ }
5816
+ resizeObserver.observe(floating);
5817
+ }
5818
+ let frameId;
5819
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5820
+ if (animationFrame) {
5821
+ frameLoop();
5822
+ }
5823
+ function frameLoop() {
5824
+ const nextRefRect = getBoundingClientRect(reference);
5825
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5826
+ update();
5827
+ }
5828
+ prevRefRect = nextRefRect;
5829
+ frameId = requestAnimationFrame(frameLoop);
5830
+ }
5831
+ update();
5832
+ return () => {
5833
+ var _resizeObserver2;
5834
+ ancestors.forEach((ancestor) => {
5835
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
5836
+ ancestorResize && ancestor.removeEventListener("resize", update);
5837
+ });
5838
+ cleanupIo == null || cleanupIo();
5839
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5840
+ resizeObserver = null;
5841
+ if (animationFrame) {
5842
+ cancelAnimationFrame(frameId);
5843
+ }
5844
+ };
5845
+ }
5846
+ var offset2 = offset;
5847
+ var shift2 = shift;
5848
+ var flip2 = flip;
5849
+ var size2 = size;
5850
+ var computePosition2 = (reference, floating, options) => {
5851
+ const cache = /* @__PURE__ */ new Map();
5852
+ const mergedOptions = {
5853
+ platform,
5854
+ ...options
5855
+ };
5856
+ const platformWithCache = {
5857
+ ...mergedOptions.platform,
5858
+ _c: cache
5859
+ };
5860
+ return computePosition(reference, floating, {
5861
+ ...mergedOptions,
5862
+ platform: platformWithCache
5863
+ });
5864
+ };
5865
+
5866
+ // ../../node_modules/.pnpm/@floating-ui+react-dom@2.1.6_react-dom@18.3.1_react@18.3.1/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5867
+ import * as React2 from "react";
5868
+ import { useLayoutEffect as useLayoutEffect4 } from "react";
5869
+ import * as ReactDOM from "react-dom";
5870
+ var isClient2 = typeof document !== "undefined";
5871
+ var noop3 = function noop4() {
5872
+ };
5873
+ var index2 = isClient2 ? useLayoutEffect4 : noop3;
5874
+ function deepEqual(a, b) {
5875
+ if (a === b) {
5876
+ return true;
5877
+ }
5878
+ if (typeof a !== typeof b) {
5879
+ return false;
5880
+ }
5881
+ if (typeof a === "function" && a.toString() === b.toString()) {
5882
+ return true;
5883
+ }
5884
+ let length;
5885
+ let i;
5886
+ let keys;
5887
+ if (a && b && typeof a === "object") {
5888
+ if (Array.isArray(a)) {
5889
+ length = a.length;
5890
+ if (length !== b.length)
5891
+ return false;
5892
+ for (i = length; i-- !== 0; ) {
5893
+ if (!deepEqual(a[i], b[i])) {
5894
+ return false;
5895
+ }
5896
+ }
5897
+ return true;
5898
+ }
5899
+ keys = Object.keys(a);
5900
+ length = keys.length;
5901
+ if (length !== Object.keys(b).length) {
5902
+ return false;
5903
+ }
5904
+ for (i = length; i-- !== 0; ) {
5905
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
5906
+ return false;
5907
+ }
5908
+ }
5909
+ for (i = length; i-- !== 0; ) {
5910
+ const key = keys[i];
5911
+ if (key === "_owner" && a.$$typeof) {
5912
+ continue;
5913
+ }
5914
+ if (!deepEqual(a[key], b[key])) {
5915
+ return false;
5916
+ }
5917
+ }
5918
+ return true;
5919
+ }
5920
+ return a !== a && b !== b;
5921
+ }
5922
+ function getDPR(element) {
5923
+ if (typeof window === "undefined") {
5924
+ return 1;
5925
+ }
5926
+ const win = element.ownerDocument.defaultView || window;
5927
+ return win.devicePixelRatio || 1;
5928
+ }
5929
+ function roundByDPR(element, value) {
5930
+ const dpr = getDPR(element);
5931
+ return Math.round(value * dpr) / dpr;
5932
+ }
5933
+ function useLatestRef(value) {
5934
+ const ref = React2.useRef(value);
5935
+ index2(() => {
5936
+ ref.current = value;
5937
+ });
5938
+ return ref;
5939
+ }
5940
+ function useFloating(options) {
5941
+ if (options === void 0) {
5942
+ options = {};
5943
+ }
5944
+ const {
5945
+ placement = "bottom",
5946
+ strategy = "absolute",
5947
+ middleware = [],
5948
+ platform: platform2,
5949
+ elements: {
5950
+ reference: externalReference,
5951
+ floating: externalFloating
5952
+ } = {},
5953
+ transform = true,
5954
+ whileElementsMounted,
5955
+ open
5956
+ } = options;
5957
+ const [data, setData] = React2.useState({
5958
+ x: 0,
5959
+ y: 0,
5960
+ strategy,
5961
+ placement,
5962
+ middlewareData: {},
5963
+ isPositioned: false
5964
+ });
5965
+ const [latestMiddleware, setLatestMiddleware] = React2.useState(middleware);
5966
+ if (!deepEqual(latestMiddleware, middleware)) {
5967
+ setLatestMiddleware(middleware);
5968
+ }
5969
+ const [_reference, _setReference] = React2.useState(null);
5970
+ const [_floating, _setFloating] = React2.useState(null);
5971
+ const setReference = React2.useCallback((node) => {
5972
+ if (node !== referenceRef.current) {
5973
+ referenceRef.current = node;
5974
+ _setReference(node);
5975
+ }
5976
+ }, []);
5977
+ const setFloating = React2.useCallback((node) => {
5978
+ if (node !== floatingRef.current) {
5979
+ floatingRef.current = node;
5980
+ _setFloating(node);
5981
+ }
5982
+ }, []);
5983
+ const referenceEl = externalReference || _reference;
5984
+ const floatingEl = externalFloating || _floating;
5985
+ const referenceRef = React2.useRef(null);
5986
+ const floatingRef = React2.useRef(null);
5987
+ const dataRef = React2.useRef(data);
5988
+ const hasWhileElementsMounted = whileElementsMounted != null;
5989
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5990
+ const platformRef = useLatestRef(platform2);
5991
+ const openRef = useLatestRef(open);
5992
+ const update = React2.useCallback(() => {
5993
+ if (!referenceRef.current || !floatingRef.current) {
5994
+ return;
5995
+ }
5996
+ const config = {
5997
+ placement,
5998
+ strategy,
5999
+ middleware: latestMiddleware
6000
+ };
6001
+ if (platformRef.current) {
6002
+ config.platform = platformRef.current;
6003
+ }
6004
+ computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
6005
+ const fullData = {
6006
+ ...data2,
6007
+ // The floating element's position may be recomputed while it's closed
6008
+ // but still mounted (such as when transitioning out). To ensure
6009
+ // `isPositioned` will be `false` initially on the next open, avoid
6010
+ // setting it to `true` when `open === false` (must be specified).
6011
+ isPositioned: openRef.current !== false
6012
+ };
6013
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
6014
+ dataRef.current = fullData;
6015
+ ReactDOM.flushSync(() => {
6016
+ setData(fullData);
6017
+ });
6018
+ }
6019
+ });
6020
+ }, [latestMiddleware, placement, strategy, platformRef, openRef]);
6021
+ index2(() => {
6022
+ if (open === false && dataRef.current.isPositioned) {
6023
+ dataRef.current.isPositioned = false;
6024
+ setData((data2) => ({
6025
+ ...data2,
6026
+ isPositioned: false
6027
+ }));
6028
+ }
6029
+ }, [open]);
6030
+ const isMountedRef = React2.useRef(false);
6031
+ index2(() => {
6032
+ isMountedRef.current = true;
6033
+ return () => {
6034
+ isMountedRef.current = false;
6035
+ };
6036
+ }, []);
6037
+ index2(() => {
6038
+ if (referenceEl)
6039
+ referenceRef.current = referenceEl;
6040
+ if (floatingEl)
6041
+ floatingRef.current = floatingEl;
6042
+ if (referenceEl && floatingEl) {
6043
+ if (whileElementsMountedRef.current) {
6044
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
6045
+ }
6046
+ update();
6047
+ }
6048
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
6049
+ const refs = React2.useMemo(() => ({
6050
+ reference: referenceRef,
6051
+ floating: floatingRef,
6052
+ setReference,
6053
+ setFloating
6054
+ }), [setReference, setFloating]);
6055
+ const elements = React2.useMemo(() => ({
6056
+ reference: referenceEl,
6057
+ floating: floatingEl
6058
+ }), [referenceEl, floatingEl]);
6059
+ const floatingStyles = React2.useMemo(() => {
6060
+ const initialStyles = {
6061
+ position: strategy,
6062
+ left: 0,
6063
+ top: 0
6064
+ };
6065
+ if (!elements.floating) {
6066
+ return initialStyles;
6067
+ }
6068
+ const x = roundByDPR(elements.floating, data.x);
6069
+ const y = roundByDPR(elements.floating, data.y);
6070
+ if (transform) {
6071
+ return {
6072
+ ...initialStyles,
6073
+ transform: "translate(" + x + "px, " + y + "px)",
6074
+ ...getDPR(elements.floating) >= 1.5 && {
6075
+ willChange: "transform"
6076
+ }
6077
+ };
6078
+ }
6079
+ return {
6080
+ position: strategy,
6081
+ left: x,
6082
+ top: y
6083
+ };
6084
+ }, [strategy, transform, elements.floating, data.x, data.y]);
6085
+ return React2.useMemo(() => ({
6086
+ ...data,
6087
+ update,
6088
+ refs,
6089
+ elements,
6090
+ floatingStyles
6091
+ }), [data, update, refs, elements, floatingStyles]);
6092
+ }
6093
+ var offset3 = (options, deps) => ({
6094
+ ...offset2(options),
6095
+ options: [options, deps]
6096
+ });
6097
+ var shift3 = (options, deps) => ({
6098
+ ...shift2(options),
6099
+ options: [options, deps]
6100
+ });
6101
+ var flip3 = (options, deps) => ({
6102
+ ...flip2(options),
6103
+ options: [options, deps]
6104
+ });
6105
+ var size3 = (options, deps) => ({
6106
+ ...size2(options),
6107
+ options: [options, deps]
6108
+ });
6109
+
6110
+ // ../../node_modules/.pnpm/@floating-ui+react@0.27.16_react-dom@18.3.1_react@18.3.1/node_modules/@floating-ui/react/dist/floating-ui.react.mjs
6111
+ var ARROW_LEFT = "ArrowLeft";
6112
+ var ARROW_RIGHT = "ArrowRight";
6113
+ var ARROW_UP = "ArrowUp";
6114
+ var ARROW_DOWN = "ArrowDown";
6115
+ var horizontalKeys = [ARROW_LEFT, ARROW_RIGHT];
6116
+ var verticalKeys = [ARROW_UP, ARROW_DOWN];
6117
+ var allKeys = [...horizontalKeys, ...verticalKeys];
6118
+ var SafeReact2 = {
6119
+ ...React3
6120
+ };
6121
+ var serverHandoffComplete = false;
6122
+ var count = 0;
6123
+ var genId = () => (
6124
+ // Ensure the id is unique with multiple independent versions of Floating UI
6125
+ // on <React 18
6126
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++
6127
+ );
6128
+ function useFloatingId() {
6129
+ const [id, setId] = React3.useState(() => serverHandoffComplete ? genId() : void 0);
6130
+ index(() => {
6131
+ if (id == null) {
6132
+ setId(genId());
6133
+ }
6134
+ }, []);
6135
+ React3.useEffect(() => {
6136
+ serverHandoffComplete = true;
6137
+ }, []);
6138
+ return id;
6139
+ }
6140
+ var useReactId = SafeReact2.useId;
6141
+ var useId = useReactId || useFloatingId;
6142
+ var devMessageSet;
6143
+ if (process.env.NODE_ENV !== "production") {
6144
+ devMessageSet = /* @__PURE__ */ new Set();
6145
+ }
6146
+ function error() {
6147
+ var _devMessageSet3;
6148
+ for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
6149
+ messages[_key2] = arguments[_key2];
6150
+ }
6151
+ const message = "Floating UI: " + messages.join(" ");
6152
+ if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
6153
+ var _devMessageSet4;
6154
+ (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
6155
+ console.error(message);
6156
+ }
6157
+ }
6158
+ function createEventEmitter() {
6159
+ const map = /* @__PURE__ */ new Map();
6160
+ return {
6161
+ emit(event, data) {
6162
+ var _map$get;
6163
+ (_map$get = map.get(event)) == null || _map$get.forEach((listener) => listener(data));
6164
+ },
6165
+ on(event, listener) {
6166
+ if (!map.has(event)) {
6167
+ map.set(event, /* @__PURE__ */ new Set());
6168
+ }
6169
+ map.get(event).add(listener);
6170
+ },
6171
+ off(event, listener) {
6172
+ var _map$get2;
6173
+ (_map$get2 = map.get(event)) == null || _map$get2.delete(listener);
6174
+ }
6175
+ };
6176
+ }
6177
+ var FloatingNodeContext = /* @__PURE__ */ React3.createContext(null);
6178
+ var FloatingTreeContext = /* @__PURE__ */ React3.createContext(null);
6179
+ var useFloatingParentNodeId = () => {
6180
+ var _React$useContext;
6181
+ return ((_React$useContext = React3.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
6182
+ };
6183
+ var useFloatingTree = () => React3.useContext(FloatingTreeContext);
6184
+ function createAttribute(name) {
6185
+ return "data-floating-ui-" + name;
6186
+ }
6187
+ var HIDDEN_STYLES = {
6188
+ border: 0,
6189
+ clip: "rect(0 0 0 0)",
6190
+ height: "1px",
6191
+ margin: "-1px",
6192
+ overflow: "hidden",
6193
+ padding: 0,
6194
+ position: "fixed",
6195
+ whiteSpace: "nowrap",
6196
+ width: "1px",
6197
+ top: 0,
6198
+ left: 0
6199
+ };
6200
+ var FocusGuard = /* @__PURE__ */ React3.forwardRef(function FocusGuard2(props, ref) {
6201
+ const [role, setRole] = React3.useState();
6202
+ index(() => {
6203
+ if (isSafari()) {
6204
+ setRole("button");
6205
+ }
6206
+ }, []);
6207
+ const restProps = {
6208
+ ref,
6209
+ tabIndex: 0,
6210
+ // Role is only for VoiceOver
6211
+ role,
6212
+ "aria-hidden": role ? void 0 : true,
6213
+ [createAttribute("focus-guard")]: "",
6214
+ style: HIDDEN_STYLES
6215
+ };
6216
+ return /* @__PURE__ */ jsx11("span", {
6217
+ ...props,
6218
+ ...restProps
6219
+ });
6220
+ });
6221
+ var PortalContext = /* @__PURE__ */ React3.createContext(null);
6222
+ var attr = /* @__PURE__ */ createAttribute("portal");
6223
+ function useFloatingPortalNode(props) {
6224
+ if (props === void 0) {
6225
+ props = {};
6226
+ }
6227
+ const {
6228
+ id,
6229
+ root
6230
+ } = props;
6231
+ const uniqueId = useId();
6232
+ const portalContext = usePortalContext();
6233
+ const [portalNode, setPortalNode] = React3.useState(null);
6234
+ const portalNodeRef = React3.useRef(null);
6235
+ index(() => {
6236
+ return () => {
6237
+ portalNode == null || portalNode.remove();
6238
+ queueMicrotask(() => {
6239
+ portalNodeRef.current = null;
6240
+ });
6241
+ };
6242
+ }, [portalNode]);
6243
+ index(() => {
6244
+ if (!uniqueId)
6245
+ return;
6246
+ if (portalNodeRef.current)
6247
+ return;
6248
+ const existingIdRoot = id ? document.getElementById(id) : null;
6249
+ if (!existingIdRoot)
6250
+ return;
6251
+ const subRoot = document.createElement("div");
6252
+ subRoot.id = uniqueId;
6253
+ subRoot.setAttribute(attr, "");
6254
+ existingIdRoot.appendChild(subRoot);
6255
+ portalNodeRef.current = subRoot;
6256
+ setPortalNode(subRoot);
6257
+ }, [id, uniqueId]);
6258
+ index(() => {
6259
+ if (root === null)
6260
+ return;
6261
+ if (!uniqueId)
6262
+ return;
6263
+ if (portalNodeRef.current)
6264
+ return;
6265
+ let container = root || (portalContext == null ? void 0 : portalContext.portalNode);
6266
+ if (container && !isNode(container))
6267
+ container = container.current;
6268
+ container = container || document.body;
6269
+ let idWrapper = null;
6270
+ if (id) {
6271
+ idWrapper = document.createElement("div");
6272
+ idWrapper.id = id;
6273
+ container.appendChild(idWrapper);
6274
+ }
6275
+ const subRoot = document.createElement("div");
6276
+ subRoot.id = uniqueId;
6277
+ subRoot.setAttribute(attr, "");
6278
+ container = idWrapper || container;
6279
+ container.appendChild(subRoot);
6280
+ portalNodeRef.current = subRoot;
6281
+ setPortalNode(subRoot);
6282
+ }, [id, root, uniqueId, portalContext]);
6283
+ return portalNode;
6284
+ }
6285
+ function FloatingPortal(props) {
6286
+ const {
6287
+ children,
6288
+ id,
6289
+ root,
6290
+ preserveTabOrder = true
6291
+ } = props;
6292
+ const portalNode = useFloatingPortalNode({
6293
+ id,
6294
+ root
6295
+ });
6296
+ const [focusManagerState, setFocusManagerState] = React3.useState(null);
6297
+ const beforeOutsideRef = React3.useRef(null);
6298
+ const afterOutsideRef = React3.useRef(null);
6299
+ const beforeInsideRef = React3.useRef(null);
6300
+ const afterInsideRef = React3.useRef(null);
6301
+ const modal = focusManagerState == null ? void 0 : focusManagerState.modal;
6302
+ const open = focusManagerState == null ? void 0 : focusManagerState.open;
6303
+ const shouldRenderGuards = (
6304
+ // The FocusManager and therefore floating element are currently open/
6305
+ // rendered.
6306
+ !!focusManagerState && // Guards are only for non-modal focus management.
6307
+ !focusManagerState.modal && // Don't render if unmount is transitioning.
6308
+ focusManagerState.open && preserveTabOrder && !!(root || portalNode)
6309
+ );
6310
+ React3.useEffect(() => {
6311
+ if (!portalNode || !preserveTabOrder || modal) {
6312
+ return;
6313
+ }
6314
+ function onFocus(event) {
6315
+ if (portalNode && isOutsideEvent(event)) {
6316
+ const focusing = event.type === "focusin";
6317
+ const manageFocus = focusing ? enableFocusInside : disableFocusInside;
6318
+ manageFocus(portalNode);
6319
+ }
6320
+ }
6321
+ portalNode.addEventListener("focusin", onFocus, true);
6322
+ portalNode.addEventListener("focusout", onFocus, true);
6323
+ return () => {
6324
+ portalNode.removeEventListener("focusin", onFocus, true);
6325
+ portalNode.removeEventListener("focusout", onFocus, true);
6326
+ };
6327
+ }, [portalNode, preserveTabOrder, modal]);
6328
+ React3.useEffect(() => {
6329
+ if (!portalNode)
6330
+ return;
6331
+ if (open)
6332
+ return;
6333
+ enableFocusInside(portalNode);
6334
+ }, [open, portalNode]);
6335
+ return /* @__PURE__ */ jsxs8(PortalContext.Provider, {
6336
+ value: React3.useMemo(() => ({
6337
+ preserveTabOrder,
6338
+ beforeOutsideRef,
6339
+ afterOutsideRef,
6340
+ beforeInsideRef,
6341
+ afterInsideRef,
6342
+ portalNode,
6343
+ setFocusManagerState
6344
+ }), [preserveTabOrder, portalNode]),
6345
+ children: [shouldRenderGuards && portalNode && /* @__PURE__ */ jsx11(FocusGuard, {
6346
+ "data-type": "outside",
6347
+ ref: beforeOutsideRef,
6348
+ onFocus: (event) => {
6349
+ if (isOutsideEvent(event, portalNode)) {
6350
+ var _beforeInsideRef$curr;
6351
+ (_beforeInsideRef$curr = beforeInsideRef.current) == null || _beforeInsideRef$curr.focus();
6352
+ } else {
6353
+ const domReference = focusManagerState ? focusManagerState.domReference : null;
6354
+ const prevTabbable = getPreviousTabbable(domReference);
6355
+ prevTabbable == null || prevTabbable.focus();
6356
+ }
6357
+ }
6358
+ }), shouldRenderGuards && portalNode && /* @__PURE__ */ jsx11("span", {
6359
+ "aria-owns": portalNode.id,
6360
+ style: HIDDEN_STYLES
6361
+ }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ jsx11(FocusGuard, {
6362
+ "data-type": "outside",
6363
+ ref: afterOutsideRef,
6364
+ onFocus: (event) => {
6365
+ if (isOutsideEvent(event, portalNode)) {
6366
+ var _afterInsideRef$curre;
6367
+ (_afterInsideRef$curre = afterInsideRef.current) == null || _afterInsideRef$curre.focus();
6368
+ } else {
6369
+ const domReference = focusManagerState ? focusManagerState.domReference : null;
6370
+ const nextTabbable = getNextTabbable(domReference);
6371
+ nextTabbable == null || nextTabbable.focus();
6372
+ (focusManagerState == null ? void 0 : focusManagerState.closeOnFocusOut) && (focusManagerState == null ? void 0 : focusManagerState.onOpenChange(false, event.nativeEvent, "focus-out"));
6373
+ }
6374
+ }
6375
+ })]
6376
+ });
6377
+ }
6378
+ var usePortalContext = () => React3.useContext(PortalContext);
6379
+ function useFloatingRootContext(options) {
6380
+ const {
6381
+ open = false,
6382
+ onOpenChange: onOpenChangeProp,
6383
+ elements: elementsProp
6384
+ } = options;
6385
+ const floatingId = useId();
6386
+ const dataRef = React3.useRef({});
6387
+ const [events] = React3.useState(() => createEventEmitter());
6388
+ const nested = useFloatingParentNodeId() != null;
6389
+ if (process.env.NODE_ENV !== "production") {
6390
+ const optionDomReference = elementsProp.reference;
6391
+ if (optionDomReference && !isElement(optionDomReference)) {
6392
+ error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
6393
+ }
6394
+ }
6395
+ const [positionReference, setPositionReference] = React3.useState(elementsProp.reference);
6396
+ const onOpenChange = useEffectEvent((open2, event, reason) => {
6397
+ dataRef.current.openEvent = open2 ? event : void 0;
6398
+ events.emit("openchange", {
6399
+ open: open2,
6400
+ event,
6401
+ reason,
6402
+ nested
6403
+ });
6404
+ onOpenChangeProp == null || onOpenChangeProp(open2, event, reason);
6405
+ });
6406
+ const refs = React3.useMemo(() => ({
6407
+ setPositionReference
6408
+ }), []);
6409
+ const elements = React3.useMemo(() => ({
6410
+ reference: positionReference || elementsProp.reference || null,
6411
+ floating: elementsProp.floating || null,
6412
+ domReference: elementsProp.reference
6413
+ }), [positionReference, elementsProp.reference, elementsProp.floating]);
6414
+ return React3.useMemo(() => ({
6415
+ dataRef,
6416
+ open,
6417
+ onOpenChange,
6418
+ elements,
6419
+ events,
6420
+ floatingId,
6421
+ refs
6422
+ }), [open, onOpenChange, elements, events, floatingId, refs]);
6423
+ }
6424
+ function useFloating2(options) {
6425
+ if (options === void 0) {
6426
+ options = {};
6427
+ }
6428
+ const {
6429
+ nodeId
6430
+ } = options;
6431
+ const internalRootContext = useFloatingRootContext({
6432
+ ...options,
6433
+ elements: {
6434
+ reference: null,
6435
+ floating: null,
6436
+ ...options.elements
6437
+ }
6438
+ });
6439
+ const rootContext = options.rootContext || internalRootContext;
6440
+ const computedElements = rootContext.elements;
6441
+ const [_domReference, setDomReference] = React3.useState(null);
6442
+ const [positionReference, _setPositionReference] = React3.useState(null);
6443
+ const optionDomReference = computedElements == null ? void 0 : computedElements.domReference;
6444
+ const domReference = optionDomReference || _domReference;
6445
+ const domReferenceRef = React3.useRef(null);
6446
+ const tree = useFloatingTree();
6447
+ index(() => {
6448
+ if (domReference) {
6449
+ domReferenceRef.current = domReference;
6450
+ }
6451
+ }, [domReference]);
6452
+ const position = useFloating({
6453
+ ...options,
6454
+ elements: {
6455
+ ...computedElements,
6456
+ ...positionReference && {
6457
+ reference: positionReference
6458
+ }
6459
+ }
6460
+ });
6461
+ const setPositionReference = React3.useCallback((node) => {
6462
+ const computedPositionReference = isElement(node) ? {
6463
+ getBoundingClientRect: () => node.getBoundingClientRect(),
6464
+ getClientRects: () => node.getClientRects(),
6465
+ contextElement: node
6466
+ } : node;
6467
+ _setPositionReference(computedPositionReference);
6468
+ position.refs.setReference(computedPositionReference);
6469
+ }, [position.refs]);
6470
+ const setReference = React3.useCallback((node) => {
6471
+ if (isElement(node) || node === null) {
6472
+ domReferenceRef.current = node;
6473
+ setDomReference(node);
6474
+ }
6475
+ if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6476
+ // `null` to support `positionReference` + an unstable `reference`
6477
+ // callback ref.
6478
+ node !== null && !isElement(node)) {
6479
+ position.refs.setReference(node);
6480
+ }
6481
+ }, [position.refs]);
6482
+ const refs = React3.useMemo(() => ({
6483
+ ...position.refs,
6484
+ setReference,
6485
+ setPositionReference,
6486
+ domReference: domReferenceRef
6487
+ }), [position.refs, setReference, setPositionReference]);
6488
+ const elements = React3.useMemo(() => ({
6489
+ ...position.elements,
6490
+ domReference
6491
+ }), [position.elements, domReference]);
6492
+ const context = React3.useMemo(() => ({
6493
+ ...position,
6494
+ ...rootContext,
6495
+ refs,
6496
+ elements,
6497
+ nodeId
6498
+ }), [position, refs, elements, nodeId, rootContext]);
6499
+ index(() => {
6500
+ rootContext.dataRef.current.floatingContext = context;
6501
+ const node = tree == null ? void 0 : tree.nodesRef.current.find((node2) => node2.id === nodeId);
6502
+ if (node) {
6503
+ node.context = context;
6504
+ }
6505
+ });
6506
+ return React3.useMemo(() => ({
6507
+ ...position,
6508
+ context,
6509
+ refs,
6510
+ elements
6511
+ }), [position, refs, elements, context]);
6512
+ }
6513
+
6514
+ // src/components/chat-composer/lib/chat-composer.ts
6515
+ var createUserMessage = ({
6516
+ sessionId,
6517
+ content,
6518
+ attachments,
6519
+ localOnly,
6520
+ createdAt,
6521
+ createMessageId
6522
+ }) => ({
6523
+ id: createMessageId(),
6524
+ sessionId,
6525
+ role: "user",
6526
+ content,
6527
+ attachments,
6528
+ localOnly,
6529
+ createdAt
6530
+ });
6531
+ var createAssistantStreamingMessage = ({
6532
+ sessionId,
6533
+ createdAt,
6534
+ createMessageId
6535
+ }) => ({
6536
+ id: createMessageId(),
6537
+ sessionId,
6538
+ role: "assistant",
6539
+ content: "",
6540
+ status: "streaming",
6541
+ createdAt
6542
+ });
6543
+ var canSendChatMessage = ({
6544
+ value,
6545
+ attachmentCount = 0,
6546
+ isModelsLoading,
6547
+ isModelsError,
6548
+ hasModels
6549
+ }) => {
6550
+ const hasText = Boolean(value.trim());
6551
+ const hasAttachments = attachmentCount > 0;
6552
+ if (!hasText && !hasAttachments)
6553
+ return false;
6554
+ if (!hasText && hasAttachments)
6555
+ return true;
6556
+ return !isModelsLoading && !isModelsError && hasModels;
6557
+ };
6558
+ var shouldSubmitChatComposer = ({
6559
+ key,
6560
+ shiftKey,
6561
+ canSend
6562
+ }) => key === "Enter" && !shiftKey && canSend;
6563
+ var shouldStopChatComposer = ({
6564
+ key,
6565
+ shiftKey,
6566
+ isStreaming
6567
+ }) => key === "Enter" && !shiftKey && isStreaming;
6568
+ var resolveSelectedChatModel = ({
6569
+ currentModel,
6570
+ availableModels,
6571
+ isModelsLoading
6572
+ }) => {
6573
+ if (!availableModels.length) {
6574
+ return isModelsLoading ? currentModel : "";
6575
+ }
6576
+ if (currentModel && availableModels.some((model) => model.id === currentModel)) {
6577
+ return currentModel;
6578
+ }
6579
+ return availableModels[0].id;
6580
+ };
6581
+ var resolveSendSession = ({
6582
+ activeSessionId,
6583
+ selectedModel,
6584
+ selectedMode,
6585
+ nowIso: nowIso2,
6586
+ createSessionId
6587
+ }) => {
6588
+ if (activeSessionId) {
6589
+ return {
6590
+ localSessionId: activeSessionId,
6591
+ sessionId: isDraftChatSessionId(activeSessionId) ? void 0 : activeSessionId
6592
+ };
6593
+ }
6594
+ const session = createDraftChatSession({
6595
+ model: selectedModel,
6596
+ mode: selectedMode ?? DEFAULT_CHAT_AGENT_MODE,
6597
+ nowIso: nowIso2,
6598
+ createSessionId
6599
+ });
6600
+ return { session, localSessionId: session.sessionId, sessionId: void 0 };
6601
+ };
6602
+
6603
+ // src/components/chat-composer/hooks/use-chat-composer.ts
6604
+ import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef10, useState as useState8 } from "react";
6605
+
6606
+ // src/components/chat-composer/hooks/use-composer-attachments.ts
6607
+ import { useEffect as useEffect6, useRef as useRef9, useState as useState7 } from "react";
6608
+ var SUPPORTED_IMAGE_MIME_TYPES = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/webp"]);
6609
+ var MAX_COMPOSER_ATTACHMENTS = 10;
6610
+ var createObjectUrl = (file) => typeof URL !== "undefined" && typeof URL.createObjectURL === "function" ? URL.createObjectURL(file) : "";
6611
+ var revokeObjectUrl = (url) => {
6612
+ if (url && typeof URL !== "undefined" && typeof URL.revokeObjectURL === "function") {
6613
+ URL.revokeObjectURL(url);
6614
+ }
6615
+ };
6616
+ var createAttachmentId = () => `attachment-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
6617
+ var releaseComposerAttachments = (attachments) => {
6618
+ attachments.forEach((attachment) => revokeObjectUrl(attachment.previewUrl));
6619
+ };
6620
+ var useComposerAttachments = () => {
6621
+ const [attachments, setAttachments] = useState7([]);
6622
+ const attachmentsRef = useRef9([]);
6623
+ useEffect6(() => {
6624
+ attachmentsRef.current = attachments;
6625
+ }, [attachments]);
6626
+ useEffect6(
6627
+ () => () => {
6628
+ releaseComposerAttachments(attachmentsRef.current);
6629
+ },
6630
+ []
6631
+ );
6632
+ const appendFiles = (files) => {
6633
+ const validFiles = Array.from(files).filter((file) => SUPPORTED_IMAGE_MIME_TYPES.has(file.type));
6634
+ if (!validFiles.length)
6635
+ return { addedCount: 0, limitExceeded: false };
6636
+ const currentAttachments = attachmentsRef.current;
6637
+ const remainingSlots = MAX_COMPOSER_ATTACHMENTS - currentAttachments.length;
6638
+ if (remainingSlots <= 0)
6639
+ return { addedCount: 0, limitExceeded: true };
6640
+ const filesToAppend = validFiles.slice(0, remainingSlots);
6641
+ const newAttachments = filesToAppend.map((file) => ({
6642
+ id: createAttachmentId(),
6643
+ file,
6644
+ name: file.name,
6645
+ mimeType: file.type,
6646
+ size: file.size,
6647
+ previewUrl: createObjectUrl(file)
6648
+ }));
6649
+ setAttachments((current) => [...current, ...newAttachments]);
6650
+ return {
6651
+ addedCount: filesToAppend.length,
6652
+ limitExceeded: validFiles.length > filesToAppend.length
6653
+ };
6654
+ };
6655
+ const removeAttachment = (attachmentId) => {
6656
+ setAttachments((current) => {
6657
+ const target = current.find((a) => a.id === attachmentId);
6658
+ if (target)
6659
+ releaseComposerAttachments([target]);
6660
+ return current.filter((a) => a.id !== attachmentId);
6661
+ });
6662
+ };
6663
+ const clearAttachments = () => {
6664
+ setAttachments((current) => {
6665
+ releaseComposerAttachments(current);
6666
+ return [];
6667
+ });
6668
+ };
6669
+ const takeMessageAttachments = () => {
6670
+ const currentAttachments = attachmentsRef.current;
6671
+ if (!currentAttachments.length) {
6672
+ return [];
6673
+ }
6674
+ const nextMessageAttachments = currentAttachments.map(({ file: _file, ...attachment }) => ({
6675
+ ...attachment,
6676
+ file: _file
6677
+ }));
6678
+ attachmentsRef.current = [];
6679
+ setAttachments([]);
6680
+ return nextMessageAttachments;
6681
+ };
6682
+ return {
6683
+ attachments,
6684
+ appendFiles,
6685
+ removeAttachment,
6686
+ clearAttachments,
6687
+ takeMessageAttachments
6688
+ };
6689
+ };
6690
+
6691
+ // src/components/chat-composer/hooks/use-chat-composer.ts
6692
+ var nowIso = () => (/* @__PURE__ */ new Date()).toISOString();
6693
+ var ATTACHMENT_NOTICE_DURATION_MS = 3e3;
6694
+ var STOP_WAIT_TIMEOUT_MS = 3e3;
6695
+ var resolveAccumulatedContent = (currentContent, update) => {
6696
+ if (update.content !== void 0) {
6697
+ return update.content;
6698
+ }
6699
+ if (update.contentDelta) {
6700
+ return currentContent + update.contentDelta;
6701
+ }
6702
+ return currentContent;
6703
+ };
6704
+ var normalizeChatErrorMessage = (message, labels) => {
6705
+ const trimmedMessage = message?.trim();
6706
+ if (!trimmedMessage) {
6707
+ return labels.genericError;
6708
+ }
6709
+ if (trimmedMessage === "Failed to fetch") {
6710
+ return labels.networkError;
6711
+ }
6712
+ return trimmedMessage;
6713
+ };
6714
+ var skillsCacheByLoader = /* @__PURE__ */ new Map();
6715
+ var getCachedSkills = (loader) => {
6716
+ if (!loader) {
6717
+ return { skills: [], resolved: false };
6718
+ }
6719
+ const cachedEntry = skillsCacheByLoader.get(loader);
6720
+ return {
6721
+ skills: cachedEntry?.skills ?? [],
6722
+ resolved: cachedEntry?.resolved ?? false
6723
+ };
6724
+ };
6725
+ var loadSkillsWithCache = async (loader) => {
6726
+ const cachedEntry = skillsCacheByLoader.get(loader);
6727
+ if (cachedEntry?.resolved) {
6728
+ return cachedEntry.skills;
6729
+ }
6730
+ if (cachedEntry?.promise) {
6731
+ return cachedEntry.promise;
6732
+ }
6733
+ const pendingPromise = loader().then((response) => {
6734
+ const nextSkills = response.skills;
6735
+ skillsCacheByLoader.set(loader, { skills: nextSkills, resolved: true });
6736
+ return nextSkills;
6737
+ }).catch((error2) => {
6738
+ skillsCacheByLoader.delete(loader);
6739
+ throw error2;
6740
+ });
6741
+ skillsCacheByLoader.set(loader, {
6742
+ skills: cachedEntry?.skills ?? [],
6743
+ resolved: false,
6744
+ promise: pendingPromise
6745
+ });
6746
+ return pendingPromise;
6747
+ };
6748
+ var useChatComposer = () => {
6749
+ const { transport, enableImageAttachments, labels, store } = useChatContext();
6750
+ const modelsLoader = transport.getModels;
6751
+ const skillsLoader = transport.getSkills;
6752
+ const activeSkillsLoaderRef = useRef10(skillsLoader);
6753
+ const activeSessionId = useChatStore((s) => s.activeSessionId);
6754
+ const activeSession = useChatStore(
6755
+ (s) => s.sessions.find((x) => x.sessionId === s.activeSessionId) ?? null
6756
+ );
6757
+ const preferredMode = useChatStore((s) => s.preferredMode);
6758
+ const streamingSessionId = useChatStore(
6759
+ (s) => s.activeSessionId && s.isStreamingBySession[s.activeSessionId] ? s.activeSessionId : null
6760
+ );
6761
+ const isStreaming = Boolean(streamingSessionId);
6762
+ const isStopping = useChatStore((s) => {
6763
+ const currentStreamingSessionId = s.activeSessionId && s.isStreamingBySession[s.activeSessionId] ? s.activeSessionId : null;
6764
+ return currentStreamingSessionId ? s.isStoppingBySession[currentStreamingSessionId] ?? false : false;
6765
+ });
6766
+ const createSession = useChatStore((s) => s.createSession);
6767
+ const replaceSessionId = useChatStore((s) => s.replaceSessionId);
6768
+ const appendMessage = useChatStore((s) => s.appendMessage);
6769
+ const startStreamingMessage = useChatStore((s) => s.startStreamingMessage);
6770
+ const patchStreamingMessage = useChatStore((s) => s.patchStreamingMessage);
6771
+ const completeStreamingMessage = useChatStore((s) => s.completeStreamingMessage);
6772
+ const requestStopStreaming = useChatStore((s) => s.requestStopStreaming);
6773
+ const finalizeStoppedStreamingMessage = useChatStore((s) => s.finalizeStoppedStreamingMessage);
6774
+ const setSessionError = useChatStore((s) => s.setSessionError);
6775
+ const clearSessionError = useChatStore((s) => s.clearSessionError);
6776
+ const setPreferredMode = useChatStore((s) => s.setPreferredMode);
6777
+ const setSessionMode = useChatStore((s) => s.setSessionMode);
6778
+ const [availableModels, setAvailableModels] = useState8([]);
6779
+ const [isModelsLoading, setIsModelsLoading] = useState8(true);
6780
+ const [isModelsError, setIsModelsError] = useState8(false);
6781
+ const [availableSkills, setAvailableSkills] = useState8(
6782
+ () => getCachedSkills(skillsLoader).skills
6783
+ );
6784
+ const [isSkillsLoading, setIsSkillsLoading] = useState8(
6785
+ () => Boolean(skillsLoader) && !getCachedSkills(skillsLoader).resolved
6786
+ );
6787
+ const fetchModels = useCallback7(async () => {
6788
+ setIsModelsLoading(true);
6789
+ setIsModelsError(false);
6790
+ try {
6791
+ const modelsResponse = await modelsLoader();
6792
+ setAvailableModels(modelsResponse.data);
6793
+ } catch {
6794
+ setIsModelsError(true);
4218
6795
  } finally {
4219
6796
  setIsModelsLoading(false);
4220
6797
  }
4221
- }, [transport]);
4222
- useEffect6(() => {
6798
+ }, [modelsLoader]);
6799
+ useEffect7(() => {
4223
6800
  void fetchModels();
4224
6801
  }, [fetchModels]);
6802
+ useEffect7(() => {
6803
+ activeSkillsLoaderRef.current = skillsLoader;
6804
+ const cachedSkills = getCachedSkills(skillsLoader);
6805
+ setAvailableSkills(cachedSkills.skills);
6806
+ setIsSkillsLoading(Boolean(skillsLoader) && !cachedSkills.resolved);
6807
+ }, [skillsLoader]);
6808
+ const fetchSkills = useCallback7(async () => {
6809
+ if (!skillsLoader) {
6810
+ setAvailableSkills([]);
6811
+ setIsSkillsLoading(false);
6812
+ return;
6813
+ }
6814
+ const cachedSkills = getCachedSkills(skillsLoader);
6815
+ if (cachedSkills.resolved) {
6816
+ setAvailableSkills(cachedSkills.skills);
6817
+ setIsSkillsLoading(false);
6818
+ return;
6819
+ }
6820
+ setIsSkillsLoading(true);
6821
+ try {
6822
+ const nextSkills = await loadSkillsWithCache(skillsLoader);
6823
+ if (activeSkillsLoaderRef.current !== skillsLoader) {
6824
+ return;
6825
+ }
6826
+ setAvailableSkills(nextSkills);
6827
+ } catch {
6828
+ if (activeSkillsLoaderRef.current !== skillsLoader) {
6829
+ return;
6830
+ }
6831
+ setAvailableSkills([]);
6832
+ } finally {
6833
+ if (activeSkillsLoaderRef.current === skillsLoader) {
6834
+ setIsSkillsLoading(false);
6835
+ }
6836
+ }
6837
+ }, [skillsLoader]);
6838
+ useEffect7(() => {
6839
+ void fetchSkills();
6840
+ }, [fetchSkills]);
4225
6841
  const hasModels = availableModels.length > 0;
4226
- const [value, setValue] = useState6("");
4227
- const [selectedModel, setSelectedModel] = useState6("");
4228
- const [selectedMode, setSelectedModeLocal] = useState6(DEFAULT_CHAT_AGENT_MODE);
4229
- const [attachmentNotice, setAttachmentNotice] = useState6(null);
6842
+ const [value, setValue] = useState8("");
6843
+ const [selectedModel, setSelectedModel] = useState8("");
6844
+ const [selectedMode, setSelectedModeLocal] = useState8(DEFAULT_CHAT_AGENT_MODE);
6845
+ const [selectedSkills, setSelectedSkills] = useState8([]);
6846
+ const [attachmentNotice, setAttachmentNotice] = useState8(null);
4230
6847
  const { attachments, appendFiles, removeAttachment, takeMessageAttachments } = useComposerAttachments();
4231
- const abortControllerBySessionRef = useRef7(/* @__PURE__ */ new Map());
4232
- const stopRequestBySessionRef = useRef7(/* @__PURE__ */ new Map());
4233
- const lastRequestBySessionRef = useRef7(/* @__PURE__ */ new Map());
4234
- useEffect6(() => {
6848
+ const abortControllerBySessionRef = useRef10(/* @__PURE__ */ new Map());
6849
+ const stopRequestBySessionRef = useRef10(/* @__PURE__ */ new Map());
6850
+ const lastRequestBySessionRef = useRef10(/* @__PURE__ */ new Map());
6851
+ useEffect7(() => {
4235
6852
  setSelectedModel(
4236
6853
  (current) => resolveSelectedChatModel({ currentModel: current, availableModels, isModelsLoading })
4237
6854
  );
4238
6855
  }, [availableModels, isModelsLoading]);
4239
- useEffect6(() => {
6856
+ useEffect7(() => {
4240
6857
  if (activeSession) {
4241
6858
  setSelectedModeLocal(activeSession.mode ?? DEFAULT_CHAT_AGENT_MODE);
4242
6859
  return;
4243
6860
  }
4244
6861
  setSelectedModeLocal(preferredMode ?? DEFAULT_CHAT_AGENT_MODE);
4245
6862
  }, [activeSession, preferredMode]);
4246
- useEffect6(() => {
6863
+ useEffect7(() => {
4247
6864
  if (!attachmentNotice)
4248
6865
  return;
4249
6866
  const timeoutId = window.setTimeout(
@@ -4260,11 +6877,11 @@ var useChatComposer = () => {
4260
6877
  window.clearTimeout(stopRequest.timeoutId);
4261
6878
  stopRequest.timeoutId = null;
4262
6879
  };
4263
- const clearStopRequest = useCallback4((sessionId) => {
6880
+ const clearStopRequest = useCallback7((sessionId) => {
4264
6881
  clearStopTimeout(sessionId);
4265
6882
  stopRequestBySessionRef.current.delete(sessionId);
4266
6883
  }, []);
4267
- const moveSessionRuntimeState = useCallback4(
6884
+ const moveSessionRuntimeState = useCallback7(
4268
6885
  (previousSessionId, nextSessionId) => {
4269
6886
  if (previousSessionId === nextSessionId) {
4270
6887
  return;
@@ -4282,7 +6899,7 @@ var useChatComposer = () => {
4282
6899
  },
4283
6900
  []
4284
6901
  );
4285
- const finalizeStop = useCallback4(
6902
+ const finalizeStop = useCallback7(
4286
6903
  (sessionId) => {
4287
6904
  const stopRequest = stopRequestBySessionRef.current.get(sessionId);
4288
6905
  if (stopRequest) {
@@ -4299,11 +6916,12 @@ var useChatComposer = () => {
4299
6916
  },
4300
6917
  [clearStopRequest, finalizeStoppedStreamingMessage]
4301
6918
  );
4302
- const runStream = useCallback4(
6919
+ const runStream = useCallback7(
4303
6920
  async ({
4304
6921
  localSessionId,
4305
6922
  sessionId,
4306
6923
  content,
6924
+ skills,
4307
6925
  attachments: attachments2,
4308
6926
  model,
4309
6927
  mode
@@ -4324,6 +6942,7 @@ var useChatComposer = () => {
4324
6942
  localSessionId,
4325
6943
  sessionId,
4326
6944
  content,
6945
+ skills,
4327
6946
  attachments: attachments2,
4328
6947
  model,
4329
6948
  mode
@@ -4336,6 +6955,7 @@ var useChatComposer = () => {
4336
6955
  model,
4337
6956
  mode,
4338
6957
  content,
6958
+ skills,
4339
6959
  attachments: attachments2,
4340
6960
  signal: abortController.signal,
4341
6961
  onSessionId: (nextSessionId) => {
@@ -4349,6 +6969,7 @@ var useChatComposer = () => {
4349
6969
  localSessionId: nextSessionId,
4350
6970
  sessionId: nextSessionId,
4351
6971
  content,
6972
+ skills,
4352
6973
  attachments: attachments2,
4353
6974
  model,
4354
6975
  mode
@@ -4420,11 +7041,13 @@ var useChatComposer = () => {
4420
7041
  store
4421
7042
  ]
4422
7043
  );
4423
- const send = useCallback4(
7044
+ const send = useCallback7(
4424
7045
  async (contentOverride, options) => {
4425
7046
  const content = (contentOverride ?? value).trim();
4426
7047
  const includeComposerAttachments = options?.includeComposerAttachments ?? true;
7048
+ const includeComposerSkills = options?.includeComposerSkills ?? true;
4427
7049
  const composerAttachmentCount = includeComposerAttachments ? attachments.length : 0;
7050
+ const messageSkills = includeComposerSkills ? selectedSkills : void 0;
4428
7051
  if (!canSendChatMessage({
4429
7052
  value: content,
4430
7053
  attachmentCount: composerAttachmentCount,
@@ -4461,14 +7084,20 @@ var useChatComposer = () => {
4461
7084
  createMessageId: () => `user-${Date.now()}`
4462
7085
  });
4463
7086
  appendMessage(localSessionId, userMessage);
4464
- if (includeComposerAttachments) {
7087
+ if (includeComposerAttachments || includeComposerSkills) {
4465
7088
  setAttachmentNotice(null);
7089
+ }
7090
+ if (includeComposerAttachments) {
4466
7091
  setValue("");
4467
7092
  }
7093
+ if (includeComposerSkills) {
7094
+ setSelectedSkills([]);
7095
+ }
4468
7096
  await runStream({
4469
7097
  localSessionId,
4470
7098
  sessionId,
4471
7099
  content,
7100
+ skills: messageSkills,
4472
7101
  attachments: messageAttachments,
4473
7102
  model: resolvedModel,
4474
7103
  mode: currentMode
@@ -4477,6 +7106,7 @@ var useChatComposer = () => {
4477
7106
  [
4478
7107
  value,
4479
7108
  attachments,
7109
+ selectedSkills,
4480
7110
  isModelsLoading,
4481
7111
  isModelsError,
4482
7112
  hasModels,
@@ -4490,7 +7120,7 @@ var useChatComposer = () => {
4490
7120
  store
4491
7121
  ]
4492
7122
  );
4493
- const stopSession = useCallback4(
7123
+ const stopSession = useCallback7(
4494
7124
  async (sessionId) => {
4495
7125
  const storeState = store.getState();
4496
7126
  const isSessionStreaming = storeState.isStreamingBySession[sessionId] ?? false;
@@ -4526,13 +7156,16 @@ var useChatComposer = () => {
4526
7156
  state: {
4527
7157
  value,
4528
7158
  attachments,
7159
+ selectedSkills,
4529
7160
  attachmentNotice,
4530
7161
  isStreaming,
4531
7162
  isStopping,
4532
7163
  selectedModel,
4533
7164
  selectedMode,
4534
7165
  availableModels,
7166
+ availableSkills,
4535
7167
  isModelsLoading,
7168
+ isSkillsLoading,
4536
7169
  isModelsError,
4537
7170
  hasModels
4538
7171
  },
@@ -4555,6 +7188,12 @@ var useChatComposer = () => {
4555
7188
  removeAttachment(attachmentId);
4556
7189
  setAttachmentNotice(null);
4557
7190
  },
7191
+ addSkill: (skill) => {
7192
+ setSelectedSkills((current) => current.includes(skill) ? current : [...current, skill]);
7193
+ },
7194
+ removeSkill: (skill) => {
7195
+ setSelectedSkills((current) => current.filter((item) => item !== skill));
7196
+ },
4558
7197
  setSelectedModel,
4559
7198
  setSelectedMode: (mode) => {
4560
7199
  setSelectedModeLocal(mode);
@@ -4569,6 +7208,7 @@ var useChatComposer = () => {
4569
7208
  }
4570
7209
  },
4571
7210
  reloadModels: () => void fetchModels(),
7211
+ reloadSkills: () => void fetchSkills(),
4572
7212
  stopSession,
4573
7213
  stop: async () => {
4574
7214
  if (!streamingSessionId)
@@ -4588,29 +7228,29 @@ var useChatComposer = () => {
4588
7228
  };
4589
7229
 
4590
7230
  // src/components/chat-composer/components/chat-composer-attachment-list.tsx
4591
- import { useState as useState7 } from "react";
7231
+ import { useState as useState9 } from "react";
4592
7232
  import styled10 from "@emotion/styled";
4593
- import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs8 } from "@emotion/react/jsx-runtime";
7233
+ import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs9 } from "@emotion/react/jsx-runtime";
4594
7234
  var ChatComposerAttachmentList = ({
4595
7235
  attachments,
4596
7236
  onRemoveAttachment
4597
7237
  }) => {
4598
- const [activeImage, setActiveImage] = useState7(null);
7238
+ const [activeImage, setActiveImage] = useState9(null);
4599
7239
  if (!attachments.length) {
4600
7240
  return null;
4601
7241
  }
4602
- return /* @__PURE__ */ jsxs8(Fragment3, { children: [
4603
- /* @__PURE__ */ jsx11(AttachmentList, { "data-testid": "chat-composer-attachment-list", children: attachments.map((attachment) => /* @__PURE__ */ jsxs8(AttachmentCard, { children: [
4604
- /* @__PURE__ */ jsx11(
7242
+ return /* @__PURE__ */ jsxs9(Fragment4, { children: [
7243
+ /* @__PURE__ */ jsx12(AttachmentList, { "data-testid": "chat-composer-attachment-list", children: attachments.map((attachment) => /* @__PURE__ */ jsxs9(AttachmentCard, { children: [
7244
+ /* @__PURE__ */ jsx12(
4605
7245
  AttachmentPreviewButton,
4606
7246
  {
4607
7247
  type: "button",
4608
7248
  "aria-label": `${attachment.name} preview`,
4609
7249
  onClick: () => setActiveImage(attachment),
4610
- children: /* @__PURE__ */ jsx11(AttachmentThumb, { src: attachment.previewUrl, alt: attachment.name })
7250
+ children: /* @__PURE__ */ jsx12(AttachmentThumb, { src: attachment.previewUrl, alt: attachment.name })
4611
7251
  }
4612
7252
  ),
4613
- /* @__PURE__ */ jsx11(
7253
+ /* @__PURE__ */ jsx12(
4614
7254
  AttachmentRemoveButton,
4615
7255
  {
4616
7256
  type: "button",
@@ -4619,11 +7259,11 @@ var ChatComposerAttachmentList = ({
4619
7259
  event.stopPropagation();
4620
7260
  onRemoveAttachment(attachment.id);
4621
7261
  },
4622
- children: /* @__PURE__ */ jsx11(CloseGlyph, { "aria-hidden": "true" })
7262
+ children: /* @__PURE__ */ jsx12(CloseGlyph, { "aria-hidden": "true" })
4623
7263
  }
4624
7264
  )
4625
7265
  ] }, attachment.id)) }),
4626
- activeImage ? /* @__PURE__ */ jsx11(
7266
+ activeImage ? /* @__PURE__ */ jsx12(
4627
7267
  ImageViewer,
4628
7268
  {
4629
7269
  src: activeImage.previewUrl,
@@ -4747,7 +7387,7 @@ var CloseGlyph = styled10.span`
4747
7387
  // src/components/chat-composer/components/chat-model-control.tsx
4748
7388
  import styled11 from "@emotion/styled";
4749
7389
  import { Select } from "@xinghunm/compass-ui";
4750
- import { jsx as jsx12, jsxs as jsxs9 } from "@emotion/react/jsx-runtime";
7390
+ import { jsx as jsx13, jsxs as jsxs10 } from "@emotion/react/jsx-runtime";
4751
7391
  var ChatModelControl = ({
4752
7392
  selectedModel,
4753
7393
  availableModels,
@@ -4758,7 +7398,7 @@ var ChatModelControl = ({
4758
7398
  onReloadModels
4759
7399
  }) => {
4760
7400
  if (isModelsError) {
4761
- return /* @__PURE__ */ jsxs9(
7401
+ return /* @__PURE__ */ jsxs10(
4762
7402
  ModelReloadButton,
4763
7403
  {
4764
7404
  type: "button",
@@ -4766,8 +7406,8 @@ var ChatModelControl = ({
4766
7406
  "aria-label": "Reload",
4767
7407
  onClick: onReloadModels,
4768
7408
  children: [
4769
- /* @__PURE__ */ jsx12("span", { children: "Failed to load models" }),
4770
- /* @__PURE__ */ jsxs9(
7409
+ /* @__PURE__ */ jsx13("span", { children: "Failed to load models" }),
7410
+ /* @__PURE__ */ jsxs10(
4771
7411
  ReloadIcon,
4772
7412
  {
4773
7413
  "data-testid": "chat-model-reload-icon",
@@ -4778,8 +7418,8 @@ var ChatModelControl = ({
4778
7418
  fill: "currentColor",
4779
7419
  xmlns: "http://www.w3.org/2000/svg",
4780
7420
  children: [
4781
- /* @__PURE__ */ jsx12("path", { d: "M895.469672 511.745197c0-146.498562-82.099856-273.805016-202.788589-338.470805l22.072715-46.630017c-4.50664-12.609179-18.382673-19.176758-30.991852-14.670118l-92.436272 33.040511c-12.609179 4.50664-19.176758 18.382673-14.670118 30.991852l33.040511 92.436272c4.50664 12.609179 18.382673 19.176758 30.991852 14.670118l24.581861-51.92972c99.069343 54.335513 166.240185 159.596881 166.240185 280.561907 0 165.56685-125.817544 301.747415-287.057855 318.14692l0 0.022513c-17.730826 0-32.105209 14.374382-32.105209 32.105209 0 17.730826 14.374382 32.105209 32.105209 32.105209 2.098801 0 4.149507-0.207731 6.135744-0.592494C744.270041 874.039593 895.469672 710.564381 895.469672 511.745197z" }),
4782
- /* @__PURE__ */ jsx12("path", { d: "M480.616222 129.23948c-0.041956 0-0.082888 0.00307-0.124843 0.00307l0-0.00307c-0.01535 0.001023-0.031722 0.00307-0.047072 0.004093-1.892093 0.010233-3.744277 0.189312-5.545296 0.5137-194.674794 18.529005-346.957083 182.459588-346.957083 381.987924 0 147.431817 83.146699 275.42798 205.097168 339.700819l-24.814152 52.419883c4.50664 12.609179 18.382673 19.176758 30.991852 14.670118l92.436272-33.040511c12.609179-4.50664 19.176758-18.382673 14.670118-30.991852l-33.040511-92.436272c-4.50664-12.609179-18.382673-19.176758-30.991852-14.670118l-21.853727 46.167482c-100.326986-53.964052-168.535461-159.920246-168.535461-281.81955 0-166.089759 126.616746-302.591643 288.588721-318.284043l0-0.014326c0.041956 0 0.082888 0.00307 0.124843 0.00307 17.730826 0 32.105209-14.374382 32.105209-32.105209C512.721431 143.613862 498.347049 129.23948 480.616222 129.23948z" })
7421
+ /* @__PURE__ */ jsx13("path", { d: "M895.469672 511.745197c0-146.498562-82.099856-273.805016-202.788589-338.470805l22.072715-46.630017c-4.50664-12.609179-18.382673-19.176758-30.991852-14.670118l-92.436272 33.040511c-12.609179 4.50664-19.176758 18.382673-14.670118 30.991852l33.040511 92.436272c4.50664 12.609179 18.382673 19.176758 30.991852 14.670118l24.581861-51.92972c99.069343 54.335513 166.240185 159.596881 166.240185 280.561907 0 165.56685-125.817544 301.747415-287.057855 318.14692l0 0.022513c-17.730826 0-32.105209 14.374382-32.105209 32.105209 0 17.730826 14.374382 32.105209 32.105209 32.105209 2.098801 0 4.149507-0.207731 6.135744-0.592494C744.270041 874.039593 895.469672 710.564381 895.469672 511.745197z" }),
7422
+ /* @__PURE__ */ jsx13("path", { d: "M480.616222 129.23948c-0.041956 0-0.082888 0.00307-0.124843 0.00307l0-0.00307c-0.01535 0.001023-0.031722 0.00307-0.047072 0.004093-1.892093 0.010233-3.744277 0.189312-5.545296 0.5137-194.674794 18.529005-346.957083 182.459588-346.957083 381.987924 0 147.431817 83.146699 275.42798 205.097168 339.700819l-24.814152 52.419883c4.50664 12.609179 18.382673 19.176758 30.991852 14.670118l92.436272-33.040511c12.609179-4.50664 19.176758-18.382673 14.670118-30.991852l-33.040511-92.436272c-4.50664-12.609179-18.382673-19.176758-30.991852-14.670118l-21.853727 46.167482c-100.326986-53.964052-168.535461-159.920246-168.535461-281.81955 0-166.089759 126.616746-302.591643 288.588721-318.284043l0-0.014326c0.041956 0 0.082888 0.00307 0.124843 0.00307 17.730826 0 32.105209-14.374382 32.105209-32.105209C512.721431 143.613862 498.347049 129.23948 480.616222 129.23948z" })
4783
7423
  ]
4784
7424
  }
4785
7425
  )
@@ -4788,11 +7428,11 @@ var ChatModelControl = ({
4788
7428
  );
4789
7429
  }
4790
7430
  if (isModelsLoading) {
4791
- return /* @__PURE__ */ jsx12(ModelBadge, { children: "Loading models..." });
7431
+ return /* @__PURE__ */ jsx13(ModelBadge, { children: "Loading models..." });
4792
7432
  }
4793
7433
  if (hasModels && selectedModel) {
4794
7434
  if (availableModels.length > 1) {
4795
- return /* @__PURE__ */ jsx12(
7435
+ return /* @__PURE__ */ jsx13(
4796
7436
  ModelSelect,
4797
7437
  {
4798
7438
  "data-testid": "chat-model-select",
@@ -4806,9 +7446,9 @@ var ChatModelControl = ({
4806
7446
  }
4807
7447
  );
4808
7448
  }
4809
- return /* @__PURE__ */ jsx12(ModelBadge, { children: selectedModel });
7449
+ return /* @__PURE__ */ jsx13(ModelBadge, { children: selectedModel });
4810
7450
  }
4811
- return /* @__PURE__ */ jsx12(ModelBadge, { children: "No model available" });
7451
+ return /* @__PURE__ */ jsx13(ModelBadge, { children: "No model available" });
4812
7452
  };
4813
7453
  var ModelBadge = styled11.span`
4814
7454
  border-radius: 999px;
@@ -4869,14 +7509,14 @@ var ModelSelect = styled11(Select)`
4869
7509
  // src/components/chat-composer/components/chat-mode-control.tsx
4870
7510
  import styled12 from "@emotion/styled";
4871
7511
  import { Select as Select2 } from "@xinghunm/compass-ui";
4872
- import { jsx as jsx13 } from "@emotion/react/jsx-runtime";
7512
+ import { jsx as jsx14 } from "@emotion/react/jsx-runtime";
4873
7513
  var ChatModeControl = ({
4874
7514
  value,
4875
7515
  disabled = false,
4876
7516
  labels,
4877
7517
  onChange
4878
7518
  }) => {
4879
- return /* @__PURE__ */ jsx13(
7519
+ return /* @__PURE__ */ jsx14(
4880
7520
  ModeSelect,
4881
7521
  {
4882
7522
  "data-testid": "chat-mode-select",
@@ -4914,8 +7554,8 @@ var ModeSelect = styled12(Select2)`
4914
7554
  // src/components/chat-composer/components/chat-send-actions.tsx
4915
7555
  import styled13 from "@emotion/styled";
4916
7556
  import { Button } from "@xinghunm/compass-ui";
4917
- import { Fragment as Fragment4, jsx as jsx14 } from "@emotion/react/jsx-runtime";
4918
- var ArrowUpIcon = () => /* @__PURE__ */ jsx14(
7557
+ import { Fragment as Fragment5, jsx as jsx15 } from "@emotion/react/jsx-runtime";
7558
+ var ArrowUpIcon = () => /* @__PURE__ */ jsx15(
4919
7559
  "svg",
4920
7560
  {
4921
7561
  "aria-hidden": "true",
@@ -4924,7 +7564,7 @@ var ArrowUpIcon = () => /* @__PURE__ */ jsx14(
4924
7564
  viewBox: "0 0 12 12",
4925
7565
  fill: "none",
4926
7566
  xmlns: "http://www.w3.org/2000/svg",
4927
- children: /* @__PURE__ */ jsx14(
7567
+ children: /* @__PURE__ */ jsx15(
4928
7568
  "path",
4929
7569
  {
4930
7570
  d: "M6 10V2M6 2L2 6M6 2L10 6",
@@ -4942,7 +7582,7 @@ var ChatSendActions = ({
4942
7582
  isStopping,
4943
7583
  onStop,
4944
7584
  onSend
4945
- }) => /* @__PURE__ */ jsx14(Fragment4, { children: isStreaming ? /* @__PURE__ */ jsx14(
7585
+ }) => /* @__PURE__ */ jsx15(Fragment5, { children: isStreaming ? /* @__PURE__ */ jsx15(
4946
7586
  StopButton,
4947
7587
  {
4948
7588
  type: "button",
@@ -4952,14 +7592,14 @@ var ChatSendActions = ({
4952
7592
  disabled: isStopping,
4953
7593
  shape: "circle",
4954
7594
  onClick: () => void onStop(),
4955
- children: isStopping ? /* @__PURE__ */ jsx14(StopSpinner, { "aria-hidden": "true", "data-testid": "chat-composer-stop-spinner" }) : /* @__PURE__ */ jsx14(StopGlyph, { "aria-hidden": "true", "data-testid": "chat-composer-stop-glyph" })
7595
+ children: isStopping ? /* @__PURE__ */ jsx15(StopSpinner, { "aria-hidden": "true", "data-testid": "chat-composer-stop-spinner" }) : /* @__PURE__ */ jsx15(StopGlyph, { "aria-hidden": "true", "data-testid": "chat-composer-stop-glyph" })
4956
7596
  }
4957
- ) : /* @__PURE__ */ jsx14(
7597
+ ) : /* @__PURE__ */ jsx15(
4958
7598
  PrimaryButton,
4959
7599
  {
4960
7600
  $canSend: canSend,
4961
7601
  type: "button",
4962
- icon: /* @__PURE__ */ jsx14(ArrowUpIcon, {}),
7602
+ icon: /* @__PURE__ */ jsx15(ArrowUpIcon, {}),
4963
7603
  "aria-label": "Send",
4964
7604
  "data-testid": "chat-composer-send",
4965
7605
  disabled: !canSend,
@@ -5048,7 +7688,7 @@ var StopSpinner = styled13.span`
5048
7688
  `;
5049
7689
 
5050
7690
  // src/components/chat-composer/index.tsx
5051
- import { jsx as jsx15, jsxs as jsxs10 } from "@emotion/react/jsx-runtime";
7691
+ import { jsx as jsx16, jsxs as jsxs11 } from "@emotion/react/jsx-runtime";
5052
7692
  var CHAT_COMPOSER_LINE_HEIGHT_PX = 20;
5053
7693
  var CHAT_COMPOSER_MAX_ROWS = 7;
5054
7694
  var CHAT_COMPOSER_PADDING_TOP_PX = 8;
@@ -5070,7 +7710,7 @@ var getExpandedComposerHeightPx = () => {
5070
7710
  Math.floor(Math.min(CHAT_COMPOSER_EXPANDED_ROWS_HEIGHT_PX, viewportLimitedHeight))
5071
7711
  );
5072
7712
  };
5073
- var PlusIcon = () => /* @__PURE__ */ jsx15(
7713
+ var PlusIcon = () => /* @__PURE__ */ jsx16(
5074
7714
  "svg",
5075
7715
  {
5076
7716
  "aria-hidden": "true",
@@ -5079,10 +7719,10 @@ var PlusIcon = () => /* @__PURE__ */ jsx15(
5079
7719
  viewBox: "0 0 16 16",
5080
7720
  fill: "none",
5081
7721
  xmlns: "http://www.w3.org/2000/svg",
5082
- children: /* @__PURE__ */ jsx15("path", { d: "M8 3v10M3 8h10", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round" })
7722
+ children: /* @__PURE__ */ jsx16("path", { d: "M8 3v10M3 8h10", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round" })
5083
7723
  }
5084
7724
  );
5085
- var ComposerExpandIcon = ({ expanded }) => /* @__PURE__ */ jsx15(
7725
+ var ComposerExpandIcon = ({ expanded }) => /* @__PURE__ */ jsx16(
5086
7726
  "svg",
5087
7727
  {
5088
7728
  "aria-hidden": "true",
@@ -5091,7 +7731,7 @@ var ComposerExpandIcon = ({ expanded }) => /* @__PURE__ */ jsx15(
5091
7731
  viewBox: "0 0 16 16",
5092
7732
  fill: "none",
5093
7733
  xmlns: "http://www.w3.org/2000/svg",
5094
- children: expanded ? /* @__PURE__ */ jsx15(
7734
+ children: expanded ? /* @__PURE__ */ jsx16(
5095
7735
  "path",
5096
7736
  {
5097
7737
  d: "M14 6h-4V2M10 6l4-4M2 10h4v4M6 10l-4 4",
@@ -5100,7 +7740,7 @@ var ComposerExpandIcon = ({ expanded }) => /* @__PURE__ */ jsx15(
5100
7740
  strokeLinecap: "round",
5101
7741
  strokeLinejoin: "round"
5102
7742
  }
5103
- ) : /* @__PURE__ */ jsx15(
7743
+ ) : /* @__PURE__ */ jsx16(
5104
7744
  "path",
5105
7745
  {
5106
7746
  d: "M10 2h4v4M14 2L9 7M6 14H2v-4M2 14l5-5",
@@ -5112,16 +7752,39 @@ var ComposerExpandIcon = ({ expanded }) => /* @__PURE__ */ jsx15(
5112
7752
  )
5113
7753
  }
5114
7754
  );
7755
+ var resolveSkillQueryMatch = (value) => {
7756
+ const matched = value.match(/(^|\s)\/([^\s/]*)$/);
7757
+ if (!matched || matched.index === void 0) {
7758
+ return null;
7759
+ }
7760
+ const start = matched.index + matched[1].length;
7761
+ return {
7762
+ query: matched[2] ?? "",
7763
+ start,
7764
+ end: value.length
7765
+ };
7766
+ };
7767
+ var replaceSkillQuery = (value, match) => {
7768
+ const before = value.slice(0, match.start).replace(/\s+$/, "");
7769
+ const after = value.slice(match.end).replace(/^\s+/, "");
7770
+ if (before && after) {
7771
+ return `${before} ${after}`;
7772
+ }
7773
+ return before || after;
7774
+ };
5115
7775
  var ChatComposerView = ({
5116
7776
  value,
5117
7777
  placeholder,
5118
7778
  attachments,
5119
7779
  attachmentNotice,
5120
7780
  attachmentLimitNotice,
7781
+ selectedSkills,
5121
7782
  selectedModel,
5122
7783
  selectedMode,
5123
7784
  availableModels,
7785
+ availableSkills,
5124
7786
  isModelsLoading,
7787
+ isSkillsLoading,
5125
7788
  isModelsError,
5126
7789
  hasModels,
5127
7790
  isStreaming,
@@ -5130,20 +7793,29 @@ var ChatComposerView = ({
5130
7793
  modeLabels,
5131
7794
  expandComposerAriaLabel,
5132
7795
  collapseComposerAriaLabel,
7796
+ skillLoadingLabel,
7797
+ skillEmptyLabel,
7798
+ removeSkillAriaLabel,
5133
7799
  onValueChange,
5134
7800
  onPickImages,
5135
7801
  onPasteImages,
5136
7802
  onRemoveAttachment,
7803
+ onAddSkill,
7804
+ onRemoveSkill,
5137
7805
  onSelectedModelChange,
5138
7806
  onSelectedModeChange,
5139
7807
  onReloadModels,
5140
7808
  onStop,
5141
7809
  onSend
5142
7810
  }) => {
5143
- const imageInputRef = useRef8(null);
5144
- const inputRef = useRef8(null);
5145
- const [isComposerExpandable, setIsComposerExpandable] = useState8(false);
5146
- const [isComposerExpanded, setIsComposerExpanded] = useState8(false);
7811
+ const imageInputRef = useRef11(null);
7812
+ const inputRef = useRef11(null);
7813
+ const [isComposerExpandable, setIsComposerExpandable] = useState10(false);
7814
+ const [isComposerExpanded, setIsComposerExpanded] = useState10(false);
7815
+ const [activeSkillNavigation, setActiveSkillNavigation] = useState10({
7816
+ queryKey: "",
7817
+ index: 0
7818
+ });
5147
7819
  const canSend = canSendChatMessage({
5148
7820
  value,
5149
7821
  attachmentCount: attachments.length,
@@ -5151,7 +7823,50 @@ var ChatComposerView = ({
5151
7823
  isModelsError,
5152
7824
  hasModels
5153
7825
  });
5154
- useLayoutEffect3(() => {
7826
+ const skillQueryMatch = resolveSkillQueryMatch(value);
7827
+ const filteredSkills = skillQueryMatch ? availableSkills.filter((skill) => {
7828
+ if (selectedSkills.includes(skill)) {
7829
+ return false;
7830
+ }
7831
+ if (skillQueryMatch.query === "") {
7832
+ return true;
7833
+ }
7834
+ return skill.toLowerCase().includes(skillQueryMatch.query.toLowerCase());
7835
+ }) : [];
7836
+ const showSkillMenu = Boolean(skillQueryMatch);
7837
+ const activeSkillQueryKey = skillQueryMatch ? `${skillQueryMatch.start}:${skillQueryMatch.end}:${skillQueryMatch.query}:${selectedSkills.join("\0")}` : "";
7838
+ const { refs, floatingStyles } = useFloating2({
7839
+ open: showSkillMenu,
7840
+ placement: "bottom-start",
7841
+ middleware: [
7842
+ offset3(8),
7843
+ flip3({ padding: 8 }),
7844
+ shift3({ padding: 8 }),
7845
+ size3({
7846
+ apply({ rects, elements, availableHeight }) {
7847
+ Object.assign(elements.floating.style, {
7848
+ width: `${rects.reference.width}px`,
7849
+ maxHeight: `${Math.min(availableHeight, 240)}px`
7850
+ });
7851
+ }
7852
+ })
7853
+ ],
7854
+ whileElementsMounted: autoUpdate
7855
+ });
7856
+ const setSkillMenuReference = useCallback8(
7857
+ (element) => {
7858
+ refs.setReference(element);
7859
+ },
7860
+ [refs]
7861
+ );
7862
+ const setSkillMenuFloating = useCallback8(
7863
+ (element) => {
7864
+ refs.setFloating(element);
7865
+ },
7866
+ [refs]
7867
+ );
7868
+ const activeSkillIndex = activeSkillNavigation.queryKey === activeSkillQueryKey ? activeSkillNavigation.index : 0;
7869
+ useLayoutEffect5(() => {
5155
7870
  const element = inputRef.current;
5156
7871
  if (!element) {
5157
7872
  return;
@@ -5171,7 +7886,43 @@ var ChatComposerView = ({
5171
7886
  setIsComposerExpanded(false);
5172
7887
  await onSend();
5173
7888
  };
7889
+ const handleSelectSkill = (skill) => {
7890
+ if (!skillQueryMatch) {
7891
+ return;
7892
+ }
7893
+ onAddSkill(skill);
7894
+ onValueChange(replaceSkillQuery(value, skillQueryMatch));
7895
+ setActiveSkillNavigation({ queryKey: "", index: 0 });
7896
+ };
5174
7897
  const handleKeyDown = (event) => {
7898
+ if (skillQueryMatch) {
7899
+ if (event.key === "ArrowDown" && filteredSkills.length > 0) {
7900
+ event.preventDefault();
7901
+ setActiveSkillNavigation({
7902
+ queryKey: activeSkillQueryKey,
7903
+ index: (activeSkillIndex + 1) % filteredSkills.length
7904
+ });
7905
+ return;
7906
+ }
7907
+ if (event.key === "ArrowUp" && filteredSkills.length > 0) {
7908
+ event.preventDefault();
7909
+ setActiveSkillNavigation({
7910
+ queryKey: activeSkillQueryKey,
7911
+ index: (activeSkillIndex - 1 + filteredSkills.length) % filteredSkills.length
7912
+ });
7913
+ return;
7914
+ }
7915
+ if (event.key === "Escape") {
7916
+ event.preventDefault();
7917
+ onValueChange(replaceSkillQuery(value, skillQueryMatch));
7918
+ return;
7919
+ }
7920
+ if (event.key === "Enter" && !event.shiftKey && filteredSkills.length > 0) {
7921
+ event.preventDefault();
7922
+ handleSelectSkill(filteredSkills[activeSkillIndex] ?? filteredSkills[0]);
7923
+ return;
7924
+ }
7925
+ }
5175
7926
  if (shouldStopChatComposer({ key: event.key, shiftKey: event.shiftKey, isStreaming })) {
5176
7927
  event.preventDefault();
5177
7928
  void onStop();
@@ -5194,105 +7945,143 @@ var ChatComposerView = ({
5194
7945
  event.preventDefault();
5195
7946
  onPasteImages(imageFiles);
5196
7947
  };
5197
- return /* @__PURE__ */ jsx15(Container2, { children: /* @__PURE__ */ jsxs10(Surface, { "data-testid": "chat-composer-surface", children: [
5198
- enableImageAttachments ? /* @__PURE__ */ jsx15(
5199
- "input",
5200
- {
5201
- ref: imageInputRef,
5202
- type: "file",
5203
- accept: "image/png,image/jpeg,image/webp",
5204
- multiple: true,
5205
- hidden: true,
5206
- "data-testid": "chat-composer-image-input",
5207
- onChange: handlePickImages
5208
- }
5209
- ) : null,
5210
- /* @__PURE__ */ jsx15(
5211
- ChatComposerAttachmentList,
5212
- {
5213
- attachments,
5214
- onRemoveAttachment
5215
- }
5216
- ),
5217
- attachmentNotice === "limit_reached" ? /* @__PURE__ */ jsx15(AttachmentNotice, { "data-testid": "chat-composer-attachment-notice", children: attachmentLimitNotice }) : null,
5218
- /* @__PURE__ */ jsxs10(InputArea, { "data-testid": "chat-composer-input-area", children: [
5219
- isComposerExpanded || isComposerExpandable ? /* @__PURE__ */ jsx15(
5220
- ComposerExpandButton,
7948
+ return /* @__PURE__ */ jsxs11(Container2, { children: [
7949
+ /* @__PURE__ */ jsxs11(Surface, { "data-testid": "chat-composer-surface", children: [
7950
+ enableImageAttachments ? /* @__PURE__ */ jsx16(
7951
+ "input",
5221
7952
  {
5222
- type: "button",
5223
- "data-testid": "chat-composer-expand-toggle",
5224
- "aria-label": isComposerExpanded ? collapseComposerAriaLabel : expandComposerAriaLabel,
5225
- "aria-expanded": isComposerExpanded,
5226
- onClick: () => setIsComposerExpanded((current) => !current),
5227
- children: /* @__PURE__ */ jsx15(ComposerExpandIcon, { expanded: isComposerExpanded })
7953
+ ref: imageInputRef,
7954
+ type: "file",
7955
+ accept: "image/png,image/jpeg,image/webp",
7956
+ multiple: true,
7957
+ hidden: true,
7958
+ "data-testid": "chat-composer-image-input",
7959
+ onChange: handlePickImages
5228
7960
  }
5229
7961
  ) : null,
5230
- /* @__PURE__ */ jsx15(
5231
- Input,
5232
- {
5233
- ref: inputRef,
5234
- "data-testid": "chat-composer-input",
5235
- "data-expanded": isComposerExpanded,
5236
- value,
5237
- onChange: (event) => onValueChange(event.target.value),
5238
- onKeyDown: handleKeyDown,
5239
- onPaste: enableImageAttachments ? handlePaste : void 0,
5240
- placeholder
5241
- }
5242
- )
5243
- ] }),
5244
- /* @__PURE__ */ jsxs10(Footer, { children: [
5245
- /* @__PURE__ */ jsx15(LeadingActions, { "data-testid": "chat-composer-leading-actions", children: enableImageAttachments ? /* @__PURE__ */ jsx15(
5246
- AttachButton,
7962
+ /* @__PURE__ */ jsx16(
7963
+ ChatComposerAttachmentList,
5247
7964
  {
5248
- type: "button",
5249
- "data-testid": "chat-composer-attach-image",
5250
- "aria-label": "Attach image",
5251
- onClick: () => imageInputRef.current?.click(),
5252
- children: /* @__PURE__ */ jsx15(PlusIcon, {})
7965
+ attachments,
7966
+ onRemoveAttachment
5253
7967
  }
5254
- ) : null }),
5255
- /* @__PURE__ */ jsxs10(TrailingActions, { "data-testid": "chat-composer-trailing-actions", children: [
5256
- /* @__PURE__ */ jsx15(
5257
- ChatModeControl,
7968
+ ),
7969
+ attachmentNotice === "limit_reached" ? /* @__PURE__ */ jsx16(AttachmentNotice, { "data-testid": "chat-composer-attachment-notice", children: attachmentLimitNotice }) : null,
7970
+ selectedSkills.length ? /* @__PURE__ */ jsx16(SkillTagList, { "data-testid": "chat-composer-skill-tags", children: selectedSkills.map((skill) => /* @__PURE__ */ jsxs11(SkillTag, { children: [
7971
+ /* @__PURE__ */ jsx16("span", { children: skill }),
7972
+ /* @__PURE__ */ jsx16(
7973
+ SkillTagRemoveButton,
5258
7974
  {
5259
- value: selectedMode,
5260
- disabled: isStreaming,
5261
- labels: modeLabels,
5262
- onChange: onSelectedModeChange
7975
+ type: "button",
7976
+ "data-testid": `chat-composer-skill-remove-${skill}`,
7977
+ "aria-label": `${removeSkillAriaLabel}: ${skill}`,
7978
+ onClick: () => onRemoveSkill(skill),
7979
+ children: "\xD7"
5263
7980
  }
5264
- ),
5265
- /* @__PURE__ */ jsx15(
5266
- ChatModelControl,
7981
+ )
7982
+ ] }, skill)) }) : null,
7983
+ /* @__PURE__ */ jsxs11(InputArea, { ref: setSkillMenuReference, "data-testid": "chat-composer-input-area", children: [
7984
+ isComposerExpanded || isComposerExpandable ? /* @__PURE__ */ jsx16(
7985
+ ComposerExpandButton,
5267
7986
  {
5268
- selectedModel,
5269
- availableModels,
5270
- isModelsLoading,
5271
- isModelsError,
5272
- hasModels,
5273
- onSelectedModelChange,
5274
- onReloadModels
7987
+ type: "button",
7988
+ "data-testid": "chat-composer-expand-toggle",
7989
+ "aria-label": isComposerExpanded ? collapseComposerAriaLabel : expandComposerAriaLabel,
7990
+ "aria-expanded": isComposerExpanded,
7991
+ onClick: () => setIsComposerExpanded((current) => !current),
7992
+ children: /* @__PURE__ */ jsx16(ComposerExpandIcon, { expanded: isComposerExpanded })
5275
7993
  }
5276
- ),
5277
- /* @__PURE__ */ jsx15(
5278
- ChatSendActions,
7994
+ ) : null,
7995
+ /* @__PURE__ */ jsx16(
7996
+ Input,
5279
7997
  {
5280
- canSend,
5281
- isStreaming,
5282
- isStopping,
5283
- onStop,
5284
- onSend: handleSend
7998
+ ref: inputRef,
7999
+ "data-testid": "chat-composer-input",
8000
+ "data-expanded": isComposerExpanded,
8001
+ value,
8002
+ onChange: (event) => onValueChange(event.target.value),
8003
+ onKeyDown: handleKeyDown,
8004
+ onPaste: enableImageAttachments ? handlePaste : void 0,
8005
+ placeholder
5285
8006
  }
5286
8007
  )
8008
+ ] }),
8009
+ /* @__PURE__ */ jsxs11(Footer, { children: [
8010
+ /* @__PURE__ */ jsx16(LeadingActions, { "data-testid": "chat-composer-leading-actions", children: enableImageAttachments ? /* @__PURE__ */ jsx16(
8011
+ AttachButton,
8012
+ {
8013
+ type: "button",
8014
+ "data-testid": "chat-composer-attach-image",
8015
+ "aria-label": "Attach image",
8016
+ onClick: () => imageInputRef.current?.click(),
8017
+ children: /* @__PURE__ */ jsx16(PlusIcon, {})
8018
+ }
8019
+ ) : null }),
8020
+ /* @__PURE__ */ jsxs11(TrailingActions, { "data-testid": "chat-composer-trailing-actions", children: [
8021
+ /* @__PURE__ */ jsx16(
8022
+ ChatModeControl,
8023
+ {
8024
+ value: selectedMode,
8025
+ disabled: isStreaming,
8026
+ labels: modeLabels,
8027
+ onChange: onSelectedModeChange
8028
+ }
8029
+ ),
8030
+ /* @__PURE__ */ jsx16(
8031
+ ChatModelControl,
8032
+ {
8033
+ selectedModel,
8034
+ availableModels,
8035
+ isModelsLoading,
8036
+ isModelsError,
8037
+ hasModels,
8038
+ onSelectedModelChange,
8039
+ onReloadModels
8040
+ }
8041
+ ),
8042
+ /* @__PURE__ */ jsx16(
8043
+ ChatSendActions,
8044
+ {
8045
+ canSend,
8046
+ isStreaming,
8047
+ isStopping,
8048
+ onStop,
8049
+ onSend: handleSend
8050
+ }
8051
+ )
8052
+ ] })
5287
8053
  ] })
5288
- ] })
5289
- ] }) });
8054
+ ] }),
8055
+ showSkillMenu ? /* @__PURE__ */ jsx16(FloatingPortal, { children: /* @__PURE__ */ jsx16(
8056
+ SkillMenu,
8057
+ {
8058
+ ref: setSkillMenuFloating,
8059
+ style: floatingStyles,
8060
+ "data-testid": "chat-composer-skill-menu",
8061
+ role: "listbox",
8062
+ children: isSkillsLoading ? /* @__PURE__ */ jsx16(SkillMenuState, { "data-testid": "chat-composer-skill-loading", children: skillLoadingLabel }) : filteredSkills.length ? filteredSkills.map((skill, index3) => /* @__PURE__ */ jsx16(
8063
+ SkillMenuItem,
8064
+ {
8065
+ type: "button",
8066
+ role: "option",
8067
+ "data-testid": `chat-composer-skill-option-${skill}`,
8068
+ "data-active": index3 === activeSkillIndex,
8069
+ "aria-selected": index3 === activeSkillIndex,
8070
+ onMouseDown: (event) => event.preventDefault(),
8071
+ onClick: () => handleSelectSkill(skill),
8072
+ children: skill
8073
+ },
8074
+ skill
8075
+ )) : /* @__PURE__ */ jsx16(SkillMenuState, { "data-testid": "chat-composer-skill-empty", children: skillEmptyLabel })
8076
+ }
8077
+ ) }) : null
8078
+ ] });
5290
8079
  };
5291
8080
  var ChatComposer = () => {
5292
8081
  const { labels, sendRef, retryRef, stopRef, enableImageAttachments } = useChatContext();
5293
8082
  const { state, actions } = useChatComposer();
5294
8083
  const { send, retry } = actions;
5295
- useEffect7(() => {
8084
+ useEffect8(() => {
5296
8085
  sendRef.current = send;
5297
8086
  retryRef.current = async (sessionId) => {
5298
8087
  retry(sessionId);
@@ -5304,18 +8093,21 @@ var ChatComposer = () => {
5304
8093
  plan: labels.modeLabelPlan,
5305
8094
  agent: labels.modeLabelAgent
5306
8095
  };
5307
- return /* @__PURE__ */ jsx15(
8096
+ return /* @__PURE__ */ jsx16(
5308
8097
  ChatComposerView,
5309
8098
  {
5310
8099
  value: state.value,
5311
8100
  attachments: state.attachments,
5312
8101
  attachmentNotice: state.attachmentNotice,
5313
8102
  attachmentLimitNotice: labels.attachmentLimitNotice,
8103
+ selectedSkills: state.selectedSkills,
5314
8104
  placeholder: labels.placeholder,
5315
8105
  selectedModel: state.selectedModel,
5316
8106
  selectedMode: state.selectedMode,
5317
8107
  availableModels: state.availableModels,
8108
+ availableSkills: state.availableSkills,
5318
8109
  isModelsLoading: state.isModelsLoading,
8110
+ isSkillsLoading: state.isSkillsLoading,
5319
8111
  isModelsError: state.isModelsError,
5320
8112
  hasModels: state.hasModels,
5321
8113
  isStreaming: state.isStreaming,
@@ -5324,10 +8116,15 @@ var ChatComposer = () => {
5324
8116
  modeLabels,
5325
8117
  expandComposerAriaLabel: labels.expandComposerAriaLabel,
5326
8118
  collapseComposerAriaLabel: labels.collapseComposerAriaLabel,
8119
+ skillLoadingLabel: labels.skillLoading,
8120
+ skillEmptyLabel: labels.skillEmpty,
8121
+ removeSkillAriaLabel: labels.removeSkillAriaLabel,
5327
8122
  onValueChange: actions.setValue,
5328
8123
  onPickImages: actions.pickImages,
5329
8124
  onPasteImages: actions.pasteImages,
5330
8125
  onRemoveAttachment: actions.removeAttachment,
8126
+ onAddSkill: actions.addSkill,
8127
+ onRemoveSkill: actions.removeSkill,
5331
8128
  onSelectedModelChange: actions.setSelectedModel,
5332
8129
  onSelectedModeChange: actions.setSelectedMode,
5333
8130
  onReloadModels: actions.reloadModels,
@@ -5369,6 +8166,32 @@ var AttachmentNotice = styled14.div`
5369
8166
  font-size: 12px;
5370
8167
  line-height: 1.4;
5371
8168
  `;
8169
+ var SkillTagList = styled14.div`
8170
+ display: flex;
8171
+ flex-wrap: wrap;
8172
+ gap: 8px;
8173
+ padding: 12px 12px 0;
8174
+ `;
8175
+ var SkillTag = styled14.span`
8176
+ display: inline-flex;
8177
+ align-items: center;
8178
+ gap: 6px;
8179
+ max-width: 100%;
8180
+ border-radius: 999px;
8181
+ padding: 8px 12px;
8182
+ background: rgba(255, 255, 255, 0.06);
8183
+ color: var(--text-primary);
8184
+ font-size: 13px;
8185
+ line-height: 1;
8186
+ `;
8187
+ var SkillTagRemoveButton = styled14.button`
8188
+ border: none;
8189
+ padding: 0;
8190
+ background: transparent;
8191
+ color: inherit;
8192
+ cursor: pointer;
8193
+ line-height: 1;
8194
+ `;
5372
8195
  var InputArea = styled14.div`
5373
8196
  grid-area: input;
5374
8197
  position: relative;
@@ -5421,6 +8244,40 @@ var Input = styled14.textarea`
5421
8244
  max-height: var(--textarea-expanded-max-height);
5422
8245
  }
5423
8246
  `;
8247
+ var SkillMenu = styled14.div`
8248
+ position: relative;
8249
+ display: flex;
8250
+ flex-direction: column;
8251
+ gap: 4px;
8252
+ max-height: 240px;
8253
+ overflow-y: auto;
8254
+ padding: 8px;
8255
+ border: 1px solid rgba(255, 255, 255, 0.12);
8256
+ border-radius: 16px;
8257
+ background: rgba(28, 28, 28, 0.98);
8258
+ box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
8259
+ z-index: 1000;
8260
+ `;
8261
+ var SkillMenuItem = styled14.button`
8262
+ width: 100%;
8263
+ border: none;
8264
+ border-radius: 12px;
8265
+ padding: 12px 14px;
8266
+ background: transparent;
8267
+ color: var(--text-primary);
8268
+ text-align: left;
8269
+ cursor: pointer;
8270
+
8271
+ &[data-active='true'],
8272
+ &:hover {
8273
+ background: rgba(255, 255, 255, 0.12);
8274
+ }
8275
+ `;
8276
+ var SkillMenuState = styled14.div`
8277
+ padding: 12px 14px;
8278
+ color: var(--text-secondary);
8279
+ font-size: 13px;
8280
+ `;
5424
8281
  var ComposerExpandButton = styled14.button`
5425
8282
  position: absolute;
5426
8283
  top: 8px;
@@ -5489,18 +8346,18 @@ import styled16 from "@emotion/styled";
5489
8346
  // src/components/chat-conversation-list/components/chat-session-item.tsx
5490
8347
  import { memo as memo2 } from "react";
5491
8348
  import styled15 from "@emotion/styled";
5492
- import { jsx as jsx16, jsxs as jsxs11 } from "@emotion/react/jsx-runtime";
8349
+ import { jsx as jsx17, jsxs as jsxs12 } from "@emotion/react/jsx-runtime";
5493
8350
  var ChatSessionItem = memo2(
5494
8351
  ({ session, isActive, modeLabel, onClick }) => {
5495
- return /* @__PURE__ */ jsx16(
8352
+ return /* @__PURE__ */ jsx17(
5496
8353
  SessionButton,
5497
8354
  {
5498
8355
  type: "button",
5499
8356
  "data-active": isActive,
5500
8357
  onClick: () => onClick(session.sessionId),
5501
- children: /* @__PURE__ */ jsxs11(SessionMeta, { children: [
5502
- /* @__PURE__ */ jsx16(SessionTitle, { children: session.title }),
5503
- /* @__PURE__ */ jsx16(ModeBadge, { children: modeLabel })
8358
+ children: /* @__PURE__ */ jsxs12(SessionMeta, { children: [
8359
+ /* @__PURE__ */ jsx17(SessionTitle, { children: session.title }),
8360
+ /* @__PURE__ */ jsx17(ModeBadge, { children: modeLabel })
5504
8361
  ] })
5505
8362
  }
5506
8363
  );
@@ -5545,7 +8402,7 @@ var ModeBadge = styled15.span`
5545
8402
  `;
5546
8403
 
5547
8404
  // src/components/chat-conversation-list/index.tsx
5548
- import { jsx as jsx17, jsxs as jsxs12 } from "@emotion/react/jsx-runtime";
8405
+ import { jsx as jsx18, jsxs as jsxs13 } from "@emotion/react/jsx-runtime";
5549
8406
  var ChatConversationList = () => {
5550
8407
  const { labels } = useChatContext();
5551
8408
  const sessions = useChatStore((s) => s.sessions);
@@ -5557,12 +8414,12 @@ var ChatConversationList = () => {
5557
8414
  plan: labels.modeLabelPlan,
5558
8415
  agent: labels.modeLabelAgent
5559
8416
  };
5560
- return /* @__PURE__ */ jsxs12(Container3, { children: [
5561
- /* @__PURE__ */ jsxs12(Toolbar, { children: [
5562
- /* @__PURE__ */ jsx17(Title3, { children: "Sessions" }),
5563
- /* @__PURE__ */ jsx17(CreateButton, { type: "button", "data-testid": "chat-create-session", onClick: startNewChat, children: labels.newChat })
8417
+ return /* @__PURE__ */ jsxs13(Container3, { children: [
8418
+ /* @__PURE__ */ jsxs13(Toolbar, { children: [
8419
+ /* @__PURE__ */ jsx18(Title3, { children: "Sessions" }),
8420
+ /* @__PURE__ */ jsx18(CreateButton, { type: "button", "data-testid": "chat-create-session", onClick: startNewChat, children: labels.newChat })
5564
8421
  ] }),
5565
- /* @__PURE__ */ jsx17(List2, { "data-testid": "chat-session-list", children: sessions.map((session) => /* @__PURE__ */ jsx17(
8422
+ /* @__PURE__ */ jsx18(List2, { "data-testid": "chat-session-list", children: sessions.map((session) => /* @__PURE__ */ jsx18(
5566
8423
  ChatSessionItem,
5567
8424
  {
5568
8425
  session,
@@ -5611,7 +8468,7 @@ var List2 = styled16.div`
5611
8468
  `;
5612
8469
 
5613
8470
  // src/components/ai-chat/index.tsx
5614
- import { Fragment as Fragment5, jsx as jsx18, jsxs as jsxs13 } from "@emotion/react/jsx-runtime";
8471
+ import { Fragment as Fragment6, jsx as jsx19, jsxs as jsxs14 } from "@emotion/react/jsx-runtime";
5615
8472
  var QuickActions = ({ renderNewChatTrigger }) => {
5616
8473
  const { labels, stopRef, store } = useChatContext();
5617
8474
  const startNewChat = useChatStore((state) => state.startNewChat);
@@ -5652,9 +8509,15 @@ var QuickActions = ({ renderNewChatTrigger }) => {
5652
8509
  startNewChat: handleStartNewChat
5653
8510
  };
5654
8511
  if (renderNewChatTrigger) {
5655
- return /* @__PURE__ */ jsx18(QuickActionsRow, { children: /* @__PURE__ */ jsx18(NewChatTriggerRenderer, { renderNewChatTrigger, triggerProps }) });
8512
+ return /* @__PURE__ */ jsx19(QuickActionsRow, { children: /* @__PURE__ */ jsx19(
8513
+ NewChatTriggerRenderer,
8514
+ {
8515
+ renderNewChatTrigger,
8516
+ triggerProps
8517
+ }
8518
+ ) });
5656
8519
  }
5657
- return /* @__PURE__ */ jsx18(QuickActionsRow, { children: /* @__PURE__ */ jsx18(
8520
+ return /* @__PURE__ */ jsx19(QuickActionsRow, { children: /* @__PURE__ */ jsx19(
5658
8521
  QuickActionButton,
5659
8522
  {
5660
8523
  type: "button",
@@ -5668,13 +8531,13 @@ var QuickActions = ({ renderNewChatTrigger }) => {
5668
8531
  var NewChatTriggerRenderer = ({
5669
8532
  renderNewChatTrigger,
5670
8533
  triggerProps
5671
- }) => /* @__PURE__ */ jsx18(Fragment5, { children: renderNewChatTrigger(triggerProps) });
8534
+ }) => /* @__PURE__ */ jsx19(Fragment6, { children: renderNewChatTrigger(triggerProps) });
5672
8535
  var AiChat = ({
5673
8536
  showConversationList = false,
5674
8537
  showNewChatButton = false,
5675
8538
  renderNewChatTrigger,
5676
8539
  ...providerProps
5677
- }) => /* @__PURE__ */ jsx18(
8540
+ }) => /* @__PURE__ */ jsx19(
5678
8541
  ConfigProvider,
5679
8542
  {
5680
8543
  theme: {
@@ -5709,12 +8572,12 @@ var AiChat = ({
5709
8572
  }
5710
8573
  }
5711
8574
  },
5712
- children: /* @__PURE__ */ jsx18(AiChatProvider, { ...providerProps, children: /* @__PURE__ */ jsxs13(Root, { "data-testid": "ai-chat", children: [
5713
- showConversationList ? /* @__PURE__ */ jsx18(ChatConversationList, {}) : null,
5714
- /* @__PURE__ */ jsxs13(Workspace, { children: [
5715
- showNewChatButton && !showConversationList ? /* @__PURE__ */ jsx18(QuickActions, { renderNewChatTrigger }) : null,
5716
- /* @__PURE__ */ jsx18(ChatThread, {}),
5717
- /* @__PURE__ */ jsx18(ChatComposer, {})
8575
+ children: /* @__PURE__ */ jsx19(AiChatProvider, { ...providerProps, children: /* @__PURE__ */ jsxs14(Root, { "data-testid": "ai-chat", children: [
8576
+ showConversationList ? /* @__PURE__ */ jsx19(ChatConversationList, {}) : null,
8577
+ /* @__PURE__ */ jsxs14(Workspace, { children: [
8578
+ showNewChatButton && !showConversationList ? /* @__PURE__ */ jsx19(QuickActions, { renderNewChatTrigger }) : null,
8579
+ /* @__PURE__ */ jsx19(ChatThread, {}),
8580
+ /* @__PURE__ */ jsx19(ChatComposer, {})
5718
8581
  ] })
5719
8582
  ] }) })
5720
8583
  }
@@ -5766,3 +8629,11 @@ export {
5766
8629
  useChatContext,
5767
8630
  useChatStore
5768
8631
  };
8632
+ /*! Bundled license information:
8633
+
8634
+ tabbable/dist/index.esm.js:
8635
+ (*!
8636
+ * tabbable 6.3.0
8637
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
8638
+ *)
8639
+ */