@bikdotai/bik-component-library 0.0.840-tools-beta.2 → 0.0.840-tools-beta.4

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.
@@ -1,7 +1,7 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),Z=require("../../../assets/icons/delete.svg.js"),G=require("../../../assets/icons/edit.svg.js"),H=require("../../../assets/icons/plus.svg.js"),u=require("react"),T=require("styled-components"),a=require("../../TypographyStyle.js"),i=require("../../../constants/Theme.js"),s=require("../AgentBuilder.styled.js"),x=require("../utils/sourceIcons.js"),ee=require("./MentionPicker.js"),F=require("../../dropdown/Dropdown.js"),N=require("../../dropdown/utils.js"),ne=require("../../button/Button.js"),oe=require("../../states-modal/DeleteConfirmationModal.js"),te=d=>d&&typeof d=="object"&&"default"in d?d:{default:d},k=te(T),V="__bik_create_new__",le=({title:d,helper:L,items:h,addableOptions:y,onAdd:b,onRemove:m,dataTestPrefix:t,emptyText:K,createOption:o,onConfigure:B,sourceGroups:p,mentionItems:_,actionSources:w,confirmDelete:f})=>{const[S,c]=u.useState(!1),[q,v]=u.useState(null),[U,g]=u.useState(null),j=!!p&&p.length>0,$=p?.find(e=>e.source===U),l=_!==void 0,A=u.useRef(null),D=u.useRef(null),[C,I]=u.useState(null);u.useEffect(()=>{if(!l||!S)return;const e=R=>{const z=R.target;!A.current?.contains(z)&&!D.current?.contains(z)&&c(!1)},r=R=>{R.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",r),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",r)}},[l,S]);const P=j?l||h.length>0:l||y.length>0||!!o&&h.length>0,J=h.length===0&&!!o&&!j&&!l,O=!!w&&w.length>0,Q=(j||O)&&h.length===0,X=()=>{if(l){I(null),c(e=>!e);return}if(j){g(null),c(e=>!e);return}if(y.length===0&&o){o.onSelect();return}c(e=>!e)},Y=()=>h.map(e=>{const r=e.onConfigure??(B?()=>B(e.id):void 0);return n.jsxs(s.SelectableRow,{"data-test":`${t}-row-${e.id}`,children:[x.renderSourceIcon(e.icon),n.jsx(s.RowText,{children:n.jsx(a.BodySecondary,{numberOfLines:1,color:i.COLORS.content.primary,children:e.label})}),n.jsxs(s.RowActions,{children:[r&&n.jsx(s.RowMenuButton,{"data-test":`${t}-edit-${e.id}`,"aria-label":`Edit ${e.label}`,onClick:r,children:n.jsx(G.default,{width:16,height:16,color:i.COLORS.content.secondary})}),r&&n.jsx(s.RowActionDivider,{"aria-hidden":!0}),n.jsx(s.RowMenuButton,{"data-test":`${t}-delete-${e.id}`,"aria-label":`Delete ${e.label}`,onClick:()=>f?v(e.id):m(e.id),children:n.jsx(Z.default,{width:16,height:16,color:i.COLORS.content.secondary})})]})]},e.id)}),E=o?[...y,{label:o.label,value:V,searchKey:o.label,customComponent:n.jsx("div",{style:{width:"100%",textAlign:"center",color:i.COLORS.content.brand,fontFamily:"Inter",fontSize:14,fontWeight:600},children:o.label})}]:y,M=l?n.jsx(ee.MentionPicker,{items:_??[],query:"",activeIndex:0,initialSource:C??void 0,onSelect:e=>{c(!1),b(String(e.id))},onClose:()=>c(!1),onCreateSubAgent:o?()=>{c(!1),o.onSelect()}:void 0,toolActions:O?w?.map(e=>({...e,onSelect:()=>{c(!1),e.onSelect()}})):void 0},C??"__root__"):null;return n.jsxs(s.SideSection,{children:[n.jsxs(s.SideSectionHeader,{children:[n.jsx(a.TitleSmall,{color:i.COLORS.content.primary,children:d}),P&&n.jsxs(re,{ref:A,children:[n.jsx(s.AddIconButton,{"data-test":`${t}-add`,onClick:X,"aria-label":`Add ${d}`,children:n.jsx(H.default,{width:20,height:20,color:i.COLORS.content.brand})}),l&&S&&C===null&&n.jsx(W,{"data-test":`${t}-picker`,children:M})]})]}),L&&n.jsx(a.BodyCaption,{color:i.COLORS.content.secondary,children:L}),Q?n.jsxs(ce,{ref:l?D:void 0,children:[n.jsxs(s.SourceButtonRow,{"data-test":`${t}-sources`,children:[p?.map(e=>n.jsxs(s.SourceButton,{type:"button","data-test":`${t}-source-${e.source}`,onClick:()=>{if(e.connected===!1){e.onConnect?.();return}if(l){I(e.source),c(!0);return}g(e.source)},children:[x.renderSourceIcon(x.SOURCE_ICONS[e.source],-4),n.jsx(a.BodySecondary,{color:i.COLORS.content.primary,children:e.label}),e.connected===!1&&n.jsx(a.BodySecondary,{color:i.COLORS.content.brand,children:"Connect"})]},e.source)),w?.map(e=>n.jsxs(s.SourceButton,{type:"button","data-test":`${t}-action-${e.source}`,onClick:e.onSelect,children:[x.renderSourceIcon(e.icon,-4),n.jsx(a.BodySecondary,{color:i.COLORS.content.primary,children:e.label})]},e.source))]}),l&&S&&C!==null&&n.jsx(W,{$align:"left","data-test":`${t}-picker`,children:M}),!l&&$&&n.jsx(F.Dropdown,{"data-test":`${t}-dropdown`,size:"small",width:"100%",isSearchable:!0,placeHolder:`Search ${$.label} tools`,options:$.options,onSelect:e=>{const r=N.unwrapDropdownValue(e);g(null),c(!1),r&&b(r)}})]}):n.jsxs(n.Fragment,{children:[!l&&S&&E.length>0&&n.jsx(F.Dropdown,{"data-test":`${t}-dropdown`,size:"small",width:"100%",isSearchable:!0,placeHolder:`Select ${d.toLowerCase()}`,options:E,onSelect:e=>{const r=N.unwrapDropdownValue(e);c(!1),r&&(r===V?o?.onSelect():b(r))}}),h.length===0&&!S?n.jsxs(n.Fragment,{children:[n.jsx(a.BodyCaption,{color:i.COLORS.content.placeholder,children:K}),J&&o&&n.jsx(ne.Button,{"data-test":`${t}-create`,buttonType:"secondary",size:"small",matchParentWidth:!0,LeadingIcon:H.default,buttonText:o.label,onClick:o.onSelect})]}):Y()]}),f&&q&&n.jsx(oe.DeleteConfirmationModal,{"data-test":`${t}-delete-confirm`,header:`Delete this ${f.noun}?`,subHeader:`Deleting this ${f.noun} will also remove it from your instructions, wherever it's referenced.`,confirmationText:"Delete",zIndex:f.zIndex,onDeleteConfirmed:()=>{m(q),v(null)},onCancelClicked:()=>v(null)})]})},re=k.default.div`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),Z=require("../../../assets/icons/delete.svg.js"),T=require("../../../assets/icons/edit.svg.js"),H=require("../../../assets/icons/plus.svg.js"),a=require("react"),G=require("styled-components"),u=require("../../TypographyStyle.js"),s=require("../../../constants/Theme.js"),d=require("../AgentBuilder.styled.js"),x=require("../utils/sourceIcons.js"),ee=require("./MentionPicker.js"),F=require("../../dropdown/Dropdown.js"),N=require("../../dropdown/utils.js"),ne=require("../../button/Button.js"),oe=require("../../states-modal/DeleteConfirmationModal.js"),te=i=>i&&typeof i=="object"&&"default"in i?i:{default:i},k=te(G),V="__bik_create_new__",ce=({title:i,helper:L,items:h,addableOptions:C,onAdd:b,onRemove:m,dataTestPrefix:c,emptyText:K,createOption:t,onConfigure:B,sourceGroups:S,mentionItems:_,actionSources:j,confirmDelete:y})=>{const[f,l]=a.useState(!1),[q,v]=a.useState(null),[U,g]=a.useState(null),p=!!S&&S.length>0,$=S?.find(e=>e.source===U),r=_!==void 0,O=a.useRef(null),A=a.useRef(null),[w,D]=a.useState(null);a.useEffect(()=>{if(!r||!f)return;const e=R=>{const z=R.target;!O.current?.contains(z)&&!A.current?.contains(z)&&l(!1)},o=R=>{R.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",o)}},[r,f]);const P=p?r||h.length>0:r||C.length>0||!!t&&h.length>0,J=h.length===0&&!!t&&!p&&!r,I=!!j&&j.length>0,Q=(p||I)&&h.length===0,X=()=>{if(r){D(null),l(e=>!e);return}if(p){g(null),l(e=>!e);return}if(C.length===0&&t){t.onSelect();return}l(e=>!e)},Y=()=>h.map(e=>{const o=e.onConfigure??(B?()=>B(e.id):void 0);return n.jsxs(d.SelectableRow,{"data-test":`${c}-row-${e.id}`,children:[x.renderSourceIcon(e.icon),n.jsx(d.RowText,{children:n.jsx(u.BodySecondary,{numberOfLines:1,color:s.COLORS.content.primary,children:e.label})}),n.jsxs(d.RowActions,{children:[o&&n.jsx(d.RowMenuButton,{"data-test":`${c}-edit-${e.id}`,"aria-label":`Edit ${e.label}`,onClick:o,children:n.jsx(T.default,{width:16,height:16,color:s.COLORS.content.secondary})}),o&&n.jsx(d.RowActionDivider,{"aria-hidden":!0}),n.jsx(d.RowMenuButton,{"data-test":`${c}-delete-${e.id}`,"aria-label":`Delete ${e.label}`,onClick:()=>y?v(e.id):m(e.id),children:n.jsx(Z.default,{width:16,height:16,color:s.COLORS.content.secondary})})]})]},e.id)}),E=t?[...C,{label:t.label,value:V,searchKey:t.label,customComponent:n.jsx("div",{style:{width:"100%",textAlign:"center",color:s.COLORS.content.brand,fontFamily:"Inter",fontSize:14,fontWeight:600},children:t.label})}]:C,M=r?n.jsx(ee.MentionPicker,{items:_??[],query:"",activeIndex:0,initialSource:w??void 0,onSelect:e=>{l(!1),b(String(e.id))},onClose:()=>l(!1),onCreateSubAgent:t?()=>{l(!1),t.onSelect()}:void 0,toolActions:I?j?.map(e=>({...e,onSelect:()=>{l(!1),e.onSelect()}})):void 0,integrationStatus:Object.fromEntries((S??[]).filter(e=>e.connected!==void 0).map(e=>[e.source,e.connected])),onConnectIntegration:e=>{l(!1),S?.find(o=>o.source===e)?.onConnect?.()}},w??"__root__"):null;return n.jsxs(d.SideSection,{children:[n.jsxs(d.SideSectionHeader,{children:[n.jsx(u.TitleSmall,{color:s.COLORS.content.primary,children:i}),P&&n.jsxs(le,{ref:O,children:[n.jsx(d.AddIconButton,{"data-test":`${c}-add`,onClick:X,"aria-label":`Add ${i}`,children:n.jsx(H.default,{width:20,height:20,color:s.COLORS.content.brand})}),r&&f&&w===null&&n.jsx(W,{"data-test":`${c}-picker`,children:M})]})]}),L&&n.jsx(u.BodyCaption,{color:s.COLORS.content.secondary,children:L}),Q?n.jsxs(re,{ref:r?A:void 0,children:[n.jsxs(d.SourceButtonRow,{"data-test":`${c}-sources`,children:[S?.map(e=>n.jsxs(d.SourceButton,{type:"button","data-test":`${c}-source-${e.source}`,onClick:()=>{if(e.connected===!1){e.onConnect?.();return}if(r){D(e.source),l(!0);return}g(e.source)},children:[x.renderSourceIcon(x.SOURCE_ICONS[e.source],-4),n.jsx(u.BodySecondary,{color:s.COLORS.content.primary,children:e.label}),e.connected===!1&&n.jsx(u.BodySecondary,{color:s.COLORS.content.brand,children:"Connect"})]},e.source)),j?.map(e=>n.jsxs(d.SourceButton,{type:"button","data-test":`${c}-action-${e.source}`,onClick:e.connected===!1?()=>e.onConnect?.():e.onSelect,children:[x.renderSourceIcon(e.icon,-4),n.jsx(u.BodySecondary,{color:s.COLORS.content.primary,children:e.label}),e.connected===!1&&n.jsx(u.BodySecondary,{color:s.COLORS.content.brand,children:"Connect"})]},e.source))]}),r&&f&&w!==null&&n.jsx(W,{$align:"left","data-test":`${c}-picker`,children:M}),!r&&$&&n.jsx(F.Dropdown,{"data-test":`${c}-dropdown`,size:"small",width:"100%",isSearchable:!0,placeHolder:`Search ${$.label} tools`,options:$.options,onSelect:e=>{const o=N.unwrapDropdownValue(e);g(null),l(!1),o&&b(o)}})]}):n.jsxs(n.Fragment,{children:[!r&&f&&E.length>0&&n.jsx(F.Dropdown,{"data-test":`${c}-dropdown`,size:"small",width:"100%",isSearchable:!0,placeHolder:`Select ${i.toLowerCase()}`,options:E,onSelect:e=>{const o=N.unwrapDropdownValue(e);l(!1),o&&(o===V?t?.onSelect():b(o))}}),h.length===0&&!f?n.jsxs(n.Fragment,{children:[n.jsx(u.BodyCaption,{color:s.COLORS.content.placeholder,children:K}),J&&t&&n.jsx(ne.Button,{"data-test":`${c}-create`,buttonType:"secondary",size:"small",matchParentWidth:!0,LeadingIcon:H.default,buttonText:t.label,onClick:t.onSelect})]}):Y()]}),y&&q&&n.jsx(oe.DeleteConfirmationModal,{"data-test":`${c}-delete-confirm`,header:`Delete this ${y.noun}?`,subHeader:`Deleting this ${y.noun} will also remove it from your instructions, wherever it's referenced.`,confirmationText:"Delete",zIndex:y.zIndex,onDeleteConfirmed:()=>{m(q),v(null)},onCancelClicked:()=>v(null)})]})},le=k.default.div`
2
2
  position: relative;
3
3
  display: flex;
4
- `,ce=k.default.div`
4
+ `,re=k.default.div`
5
5
  position: relative;
6
6
  display: flex;
7
7
  flex-direction: column;
@@ -9,7 +9,7 @@
9
9
  `,W=k.default.div`
10
10
  position: absolute;
11
11
  top: calc(100% + 4px);
12
- ${d=>d.$align==="left"?"left: 0;":"right: 0;"}
12
+ ${i=>i.$align==="left"?"left: 0;":"right: 0;"}
13
13
  z-index: 30;
14
- `;exports.SelectableListSection=le;
14
+ `;exports.SelectableListSection=ce;
15
15
  //# sourceMappingURL=SelectableListSection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectableListSection.js","sources":["../../../../../src/components/agent-builder/components/SelectableListSection.tsx"],"sourcesContent":["import DeleteIcon from '@src/assets/icons/delete.svg';\nimport EditIcon from '@src/assets/icons/edit.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport { MentionItem } from '@src/editor';\nimport React, { useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { DeleteConfirmationModal } from '@src/components/states-modal';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAddIconButton,\n\tRowActionDivider,\n\tRowActions,\n\tRowMenuButton,\n\tRowText,\n\tSelectableRow,\n\tSideSection,\n\tSideSectionHeader,\n\tSourceButton,\n\tSourceButtonRow,\n} from '../AgentBuilder.styled';\nimport { ToolAction } from '../constants/tools';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tSourceIcon,\n} from '../utils/sourceIcons';\nimport { MentionPicker } from './MentionPicker';\n\nexport interface SelectableItem {\n\tid: string;\n\tlabel: string;\n\t/** Leading brand glyph (e.g. a tool's source icon). */\n\ticon?: SourceIcon;\n\t/**\n\t * When set, this row shows an edit (Configure) icon that calls this instead of\n\t * the section-level `onConfigure`. Use for rows that open their own drawer\n\t * (e.g. a configured Rest API / email-handover tool).\n\t */\n\tonConfigure?: () => void;\n}\n\n/** A tool source for the empty-state picker (Tools): a button → its searchable list. */\nexport interface SourceGroup {\n\tsource: string;\n\tlabel: string;\n\toptions: SingleOption[];\n\t/**\n\t * Integration connection state for this source. `false` = the store hasn't\n\t * connected it → clicking the source button calls {@link onConnect} instead of\n\t * opening its tool list. `true`/absent → opens normally.\n\t */\n\tconnected?: boolean;\n\t/** Open the connect flow for this source (used when `connected === false`). */\n\tonConnect?: () => void;\n}\n\n/** Sentinel value for the \"create new\" entry in the add dropdown. */\nconst CREATE_OPTION_VALUE = '__bik_create_new__';\n\ninterface SelectableListSectionProps {\n\ttitle: string;\n\thelper?: string;\n\titems: SelectableItem[];\n\t/**\n\t * Options shown in the add dropdown. Pass ALL items (not just unselected\n\t * ones) when re-picking an already-added item is allowed (e.g. to insert its\n\t * mention again) — the chip list still shows each item only once.\n\t */\n\taddableOptions: SingleOption[];\n\tonAdd: (id: string) => void;\n\tonRemove: (id: string) => void;\n\tdataTestPrefix: string;\n\temptyText: string;\n\t/**\n\t * Adds a \"create new\" entry at the top of the add dropdown (e.g. \"Create\n\t * sub-agent\"). Selecting it calls `onSelect` instead of `onAdd`.\n\t */\n\tcreateOption?: { label: string; onSelect: () => void };\n\t/**\n\t * When provided, each row shows an edit (Configure) icon next to Delete.\n\t * Omit for tools (Delete only).\n\t */\n\tonConfigure?: (id: string) => void;\n\t/**\n\t * Tool sources (e.g. Manifest / Shopify). When set, the empty state shows a\n\t * button per source; clicking one reveals a searchable dropdown of just that\n\t * source's options. Selecting calls `onAdd`. Takes precedence over the plain\n\t * `addableOptions` dropdown.\n\t */\n\tsourceGroups?: SourceGroup[];\n\t/**\n\t * When provided, the header \"+\" opens the same `@` reference picker used in the\n\t * Instructions editor (a {@link MentionPicker} popover) instead of the inline\n\t * select dropdown. Pass the items for THIS section only (tools OR sub-agents) —\n\t * the picker auto-drills into the single category. Selecting a row calls\n\t * `onAdd(id)`; the picker's \"Create new\" row (sub-agents) calls\n\t * `createOption.onSelect`.\n\t */\n\tmentionItems?: MentionItem[];\n\t/**\n\t * Built-in \"action\" tools (e.g. Rest API / Handover to email) that open a\n\t * config drawer via `onSelect` instead of adding a mention. Shown as\n\t * empty-state source buttons (only while no items exist, alongside\n\t * `sourceGroups`) AND as rows inside the `@` picker's Tools view.\n\t */\n\tactionSources?: ToolAction[];\n\t/**\n\t * When set, the row Delete icon opens a confirmation modal (instead of\n\t * removing immediately); `onRemove` runs only on confirm. `noun` fills the one\n\t * shared message template (\"Delete this <noun>?\" …); `zIndex` raises the modal\n\t * above a parent drawer. Omit to delete directly.\n\t */\n\tconfirmDelete?: { noun: string; zIndex?: number };\n}\n\nexport const SelectableListSection: React.FC<SelectableListSectionProps> = ({\n\ttitle,\n\thelper,\n\titems,\n\taddableOptions,\n\tonAdd,\n\tonRemove,\n\tdataTestPrefix,\n\temptyText,\n\tcreateOption,\n\tonConfigure,\n\tsourceGroups,\n\tmentionItems,\n\tactionSources,\n\tconfirmDelete,\n}) => {\n\tconst [adding, setAdding] = useState(false);\n\t// Row id awaiting delete confirmation (null = modal closed).\n\tconst [pendingDeleteId, setPendingDeleteId] = useState<string | null>(null);\n\t// Tools: which source's searchable list is open (null = just show the buttons).\n\tconst [activeSource, setActiveSource] = useState<string | null>(null);\n\tconst hasSourceGroups = !!sourceGroups && sourceGroups.length > 0;\n\tconst activeGroup = sourceGroups?.find((g) => g.source === activeSource);\n\t// When set, \"+\" opens the `@` MentionPicker popover instead of a select input.\n\tconst usePicker = mentionItems !== undefined;\n\t// Separate anchors for the header \"+\" popover and the empty-state source-button\n\t// popover — when empty both render at once, so a shared ref would misfire the\n\t// outside-click check (closing the header picker when a source row is clicked).\n\tconst headerPickerRef = useRef<HTMLDivElement>(null);\n\tconst sourcePickerRef = useRef<HTMLDivElement>(null);\n\t// Source (Shopify / Manifest) the empty-state button opened the picker into;\n\t// null when \"+\" opened it at the root source list.\n\tconst [pickerSource, setPickerSource] = useState<string | null>(null);\n\n\t// Dismiss the picker popover on outside click / Escape.\n\tuseEffect(() => {\n\t\tif (!usePicker || !adding) {\n\t\t\treturn;\n\t\t}\n\t\tconst onDocMouseDown = (e: MouseEvent) => {\n\t\t\tconst target = e.target as Node;\n\t\t\tif (\n\t\t\t\t!headerPickerRef.current?.contains(target) &&\n\t\t\t\t!sourcePickerRef.current?.contains(target)\n\t\t\t) {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tdocument.addEventListener('mousedown', onDocMouseDown);\n\t\tdocument.addEventListener('keydown', onKeyDown);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('mousedown', onDocMouseDown);\n\t\t\tdocument.removeEventListener('keydown', onKeyDown);\n\t\t};\n\t}, [usePicker, adding]);\n\n\t// Header \"+\" picks an EXISTING item (and, once some exist, re-creates via the\n\t// dropdown's footer row). With an empty list + a createOption the body shows a\n\t// dedicated \"Create new\" button instead, so the header \"+\" would be redundant.\n\t// In picker mode the \"+\" always shows (even empty) — for tools it sits next to\n\t// the empty-state source buttons; the create flow lives inside the picker.\n\tconst showAddButton = hasSourceGroups\n\t\t? usePicker || items.length > 0\n\t\t: usePicker ||\n\t\t addableOptions.length > 0 ||\n\t\t (!!createOption && items.length > 0);\n\t// Empty state offers a one-click \"Create new\" (sub-agents) rather than burying\n\t// it behind a single-item dropdown. In picker mode the \"+\" opens the picker\n\t// (with its own \"Create new\" row) instead, so skip the standalone button.\n\tconst showEmptyCreate =\n\t\titems.length === 0 && !!createOption && !hasSourceGroups && !usePicker;\n\tconst hasActionSources = !!actionSources && actionSources.length > 0;\n\t// Source buttons ONLY while no item is added — the tool sources (Manifest /\n\t// Shopify …) plus the built-in action tools (Rest API / Handover to email).\n\t// Once an item exists, adding more uses the header \"+\" → picker (the buttons\n\t// never come back); the action tools still live inside that picker.\n\tconst showSourceButtons =\n\t\t(hasSourceGroups || hasActionSources) && items.length === 0;\n\t// Nothing existing to pick → skip the 1-item dropdown and create directly.\n\tconst handleAddClick = () => {\n\t\tif (usePicker) {\n\t\t\t// Toggle the `@` reference-picker popover (rendered under the \"+\"), opened\n\t\t\t// at the root source list (no pre-drilled source).\n\t\t\tsetPickerSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (hasSourceGroups) {\n\t\t\tsetActiveSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (addableOptions.length === 0 && createOption) {\n\t\t\tcreateOption.onSelect();\n\t\t\treturn;\n\t\t}\n\t\tsetAdding((v) => !v);\n\t};\n\n\tconst renderChipRows = () =>\n\t\titems.map((item) => {\n\t\t\t// Per-item configure wins; otherwise fall back to the section-level one.\n\t\t\tconst configure =\n\t\t\t\titem.onConfigure ??\n\t\t\t\t(onConfigure ? () => onConfigure(item.id) : undefined);\n\t\t\treturn (\n\t\t\t\t<SelectableRow\n\t\t\t\t\tkey={item.id}\n\t\t\t\t\tdata-test={`${dataTestPrefix}-row-${item.id}`}\n\t\t\t\t>\n\t\t\t\t\t{renderSourceIcon(item.icon)}\n\t\t\t\t\t<RowText>\n\t\t\t\t\t\t<BodySecondary numberOfLines={1} color={COLORS.content.primary}>\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</RowText>\n\t\t\t\t\t<RowActions>\n\t\t\t\t\t\t{configure && (\n\t\t\t\t\t\t\t// Configurable rows (sub-agents, Rest API / email tools) get an\n\t\t\t\t\t\t\t// always-visible edit icon.\n\t\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-edit-${item.id}`}\n\t\t\t\t\t\t\t\taria-label={`Edit ${item.label}`}\n\t\t\t\t\t\t\t\tonClick={configure}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditIcon\n\t\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{configure && <RowActionDivider aria-hidden />}\n\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-${item.id}`}\n\t\t\t\t\t\t\taria-label={`Delete ${item.label}`}\n\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\tconfirmDelete ? setPendingDeleteId(item.id) : onRemove(item.id)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<DeleteIcon\n\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t</RowActions>\n\t\t\t\t</SelectableRow>\n\t\t\t);\n\t\t});\n\t// \"Create new\" is a brand-coloured footer row at the BOTTOM of the dropdown,\n\t// separated from the selectable items by a divider.\n\tconst dropdownOptions: SingleOption[] = createOption\n\t\t? [\n\t\t\t\t...addableOptions,\n\t\t\t\t{\n\t\t\t\t\tlabel: createOption.label,\n\t\t\t\t\tvalue: CREATE_OPTION_VALUE,\n\t\t\t\t\tsearchKey: createOption.label,\n\t\t\t\t\tcustomComponent: (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t\t\t\tcolor: COLORS.content.brand,\n\t\t\t\t\t\t\t\tfontFamily: 'Inter',\n\t\t\t\t\t\t\t\tfontSize: 14,\n\t\t\t\t\t\t\t\tfontWeight: 600,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{createOption.label}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t ]\n\t\t: addableOptions;\n\n\t// One picker instance reused by the header \"+\" and the empty-state source\n\t// buttons. `key` remounts it so a source button re-drills into its own tools\n\t// (the initial drill-in level is read once, on mount).\n\tconst pickerNode = usePicker ? (\n\t\t<MentionPicker\n\t\t\tkey={pickerSource ?? '__root__'}\n\t\t\titems={mentionItems ?? []}\n\t\t\tquery=\"\"\n\t\t\tactiveIndex={0}\n\t\t\tinitialSource={pickerSource ?? undefined}\n\t\t\tonSelect={(item) => {\n\t\t\t\tsetAdding(false);\n\t\t\t\tonAdd(String(item.id));\n\t\t\t}}\n\t\t\tonClose={() => setAdding(false)}\n\t\t\tonCreateSubAgent={\n\t\t\t\tcreateOption\n\t\t\t\t\t? () => {\n\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\tcreateOption.onSelect();\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\ttoolActions={\n\t\t\t\thasActionSources\n\t\t\t\t\t? actionSources?.map((a) => ({\n\t\t\t\t\t\t\t...a,\n\t\t\t\t\t\t\tonSelect: () => {\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\ta.onSelect();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }))\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t/>\n\t) : null;\n\n\treturn (\n\t\t<SideSection>\n\t\t\t<SideSectionHeader>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{title}</TitleSmall>\n\t\t\t\t{showAddButton && (\n\t\t\t\t\t<AddButtonWrap ref={headerPickerRef}>\n\t\t\t\t\t\t<AddIconButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-add`}\n\t\t\t\t\t\t\tonClick={handleAddClick}\n\t\t\t\t\t\t\taria-label={`Add ${title}`}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon width={20} height={20} color={COLORS.content.brand} />\n\t\t\t\t\t\t</AddIconButton>\n\t\t\t\t\t\t{usePicker && adding && pickerSource === null && (\n\t\t\t\t\t\t\t<PickerPopover data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</AddButtonWrap>\n\t\t\t\t)}\n\t\t\t</SideSectionHeader>\n\n\t\t\t{helper && (\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>{helper}</BodyCaption>\n\t\t\t)}\n\n\t\t\t{showSourceButtons ? (\n\t\t\t\t<SourcePickerAnchor ref={usePicker ? sourcePickerRef : undefined}>\n\t\t\t\t\t{/* No tools yet: one button per source (never shown once a tool exists). */}\n\t\t\t\t\t<SourceButtonRow data-test={`${dataTestPrefix}-sources`}>\n\t\t\t\t\t\t{sourceGroups?.map((g) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={g.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-source-${g.source}`}\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t// Not connected → open the connect flow instead of the tools.\n\t\t\t\t\t\t\t\t\tif (g.connected === false) {\n\t\t\t\t\t\t\t\t\t\tg.onConnect?.();\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (usePicker) {\n\t\t\t\t\t\t\t\t\t\t// Open the `@` picker drilled straight into this source's tools.\n\t\t\t\t\t\t\t\t\t\tsetPickerSource(g.source);\n\t\t\t\t\t\t\t\t\t\tsetAdding(true);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetActiveSource(g.source);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(SOURCE_ICONS[g.source], -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{g.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t{g.connected === false && (\n\t\t\t\t\t\t\t\t\t// Not connected → show \"Connect\" upfront (consistent with\n\t\t\t\t\t\t\t\t\t// the `@` picker); clicking runs the connect flow.\n\t\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.brand}>\n\t\t\t\t\t\t\t\t\t\tConnect\n\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t{/* Built-in action tools (Rest API / Handover to email) open a drawer. */}\n\t\t\t\t\t\t{actionSources?.map((a) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={a.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-action-${a.source}`}\n\t\t\t\t\t\t\t\tonClick={a.onSelect}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(a.icon, -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{a.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</SourceButtonRow>\n\n\t\t\t\t\t{/* Picker mode: clicking a source opens its tools in the `@` picker. */}\n\t\t\t\t\t{usePicker && adding && pickerSource !== null && (\n\t\t\t\t\t\t<PickerPopover $align=\"left\" data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Legacy (non-picker) mode: chosen source → its searchable tool list. */}\n\t\t\t\t\t{!usePicker && activeGroup && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Search ${activeGroup.label} tools`}\n\t\t\t\t\t\t\toptions={activeGroup.options}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetActiveSource(null);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\tonAdd(v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</SourcePickerAnchor>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t{!usePicker && adding && dropdownOptions.length > 0 && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Select ${title.toLowerCase()}`}\n\t\t\t\t\t\t\toptions={dropdownOptions}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (!v) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (v === CREATE_OPTION_VALUE) {\n\t\t\t\t\t\t\t\t\tcreateOption?.onSelect();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonAdd(v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{items.length === 0 && !adding ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.placeholder}>\n\t\t\t\t\t\t\t\t{emptyText}\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t{showEmptyCreate && createOption && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-create`}\n\t\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tLeadingIcon={PlusIcon}\n\t\t\t\t\t\t\t\t\tbuttonText={createOption.label}\n\t\t\t\t\t\t\t\t\tonClick={createOption.onSelect}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\trenderChipRows()\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t{confirmDelete && pendingDeleteId && (\n\t\t\t\t<DeleteConfirmationModal\n\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-confirm`}\n\t\t\t\t\theader={`Delete this ${confirmDelete.noun}?`}\n\t\t\t\t\tsubHeader={`Deleting this ${confirmDelete.noun} will also remove it from your instructions, wherever it's referenced.`}\n\t\t\t\t\tconfirmationText=\"Delete\"\n\t\t\t\t\tzIndex={confirmDelete.zIndex}\n\t\t\t\t\tonDeleteConfirmed={() => {\n\t\t\t\t\t\tonRemove(pendingDeleteId);\n\t\t\t\t\t\tsetPendingDeleteId(null);\n\t\t\t\t\t}}\n\t\t\t\t\tonCancelClicked={() => setPendingDeleteId(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</SideSection>\n\t);\n};\n\n// Anchors the `@`-picker popover to the header \"+\" button.\nconst AddButtonWrap = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n`;\n\n// Anchors the `@`-picker popover to the empty-state source buttons.\nconst SourcePickerAnchor = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n`;\n\n// Floating card under the trigger. Aligns to the \"+\" (right) or the source\n// buttons (left) so it stays inside the side panel.\nconst PickerPopover = styled.div<{ $align?: 'left' | 'right' }>`\n\tposition: absolute;\n\ttop: calc(100% + 4px);\n\t${(p) => (p.$align === 'left' ? 'left: 0;' : 'right: 0;')}\n\tz-index: 30;\n`;\n"],"names":["CREATE_OPTION_VALUE","SelectableListSection","title","helper","items","addableOptions","onAdd","onRemove","dataTestPrefix","emptyText","createOption","onConfigure","sourceGroups","mentionItems","actionSources","confirmDelete","adding","setAdding","useState","pendingDeleteId","setPendingDeleteId","activeSource","setActiveSource","hasSourceGroups","activeGroup","g","usePicker","headerPickerRef","useRef","sourcePickerRef","pickerSource","setPickerSource","useEffect","onDocMouseDown","e","target","onKeyDown","showAddButton","showEmptyCreate","hasActionSources","showSourceButtons","handleAddClick","v","renderChipRows","item","configure","jsxs","SelectableRow","renderSourceIcon","jsx","RowText","BodySecondary","COLORS","RowActions","RowMenuButton","EditIcon","RowActionDivider","DeleteIcon","dropdownOptions","pickerNode","MentionPicker","a","SideSection","SideSectionHeader","TitleSmall","AddButtonWrap","AddIconButton","PlusIcon","PickerPopover","BodyCaption","SourcePickerAnchor","SourceButtonRow","SourceButton","SOURCE_ICONS","Dropdown","opt","unwrapDropdownValue","Fragment","Button","DeleteConfirmationModal","styled","p"],"mappings":"iuBAiEMA,EAAsB,qBA0DfC,GAA8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Y,EACvB8B,OAAA+B,EAAAA,SAAA,CACC,SAAA,CAAA5B,MAACoB,EAAAA,YAAA,CAAY,MAAOjB,EAAAA,OAAO,QAAQ,YACjC,SAAA3C,EACF,EACC6B,GAAmB5B,GACnBuC,EAAAA,IAAC6B,GAAAA,OAAA,CACA,YAAW,GAAGtE,CAAc,UAC5B,WAAW,YACX,KAAK,QACL,iBAAgB,GAChB,YAAa2D,EAAAA,QACb,WAAYzD,EAAa,MACzB,QAASA,EAAa,QAAA,CAAA,CACvB,CAAA,CAEF,EAEAiC,EAAA,CAAe,EAEjB,EAEA5B,GAAiBI,GACjB8B,EAAAA,IAAC8B,GAAAA,wBAAA,CACA,YAAW,GAAGvE,CAAc,kBAC5B,OAAQ,eAAeO,EAAc,IAAI,IACzC,UAAW,iBAAiBA,EAAc,IAAI,yEAC9C,iBAAiB,SACjB,OAAQA,EAAc,OACtB,kBAAmB,IAAM,CACxBR,EAASY,CAAe,EACxBC,EAAmB,IAAI,CACxB,EACA,gBAAiB,IAAMA,EAAmB,IAAI,CAAA,CAAA,CAC/C,EAEF,CAEF,EAGM6C,GAAgBe,EAAAA,QAAO;AAAA;AAAA;AAAA,EAMvBV,GAAqBU,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAS5BZ,EAAgBY,EAAAA,QAAO;AAAA;AAAA;AAAA,GAGzBC,GAAOA,EAAE,SAAW,OAAS,WAAa,WAAY;AAAA;AAAA"}
1
+ {"version":3,"file":"SelectableListSection.js","sources":["../../../../../src/components/agent-builder/components/SelectableListSection.tsx"],"sourcesContent":["import DeleteIcon from '@src/assets/icons/delete.svg';\nimport EditIcon from '@src/assets/icons/edit.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport { MentionItem } from '@src/editor';\nimport React, { useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { DeleteConfirmationModal } from '@src/components/states-modal';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAddIconButton,\n\tRowActionDivider,\n\tRowActions,\n\tRowMenuButton,\n\tRowText,\n\tSelectableRow,\n\tSideSection,\n\tSideSectionHeader,\n\tSourceButton,\n\tSourceButtonRow,\n} from '../AgentBuilder.styled';\nimport { ToolAction } from '../constants/tools';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tSourceIcon,\n} from '../utils/sourceIcons';\nimport { MentionPicker } from './MentionPicker';\n\nexport interface SelectableItem {\n\tid: string;\n\tlabel: string;\n\t/** Leading brand glyph (e.g. a tool's source icon). */\n\ticon?: SourceIcon;\n\t/**\n\t * When set, this row shows an edit (Configure) icon that calls this instead of\n\t * the section-level `onConfigure`. Use for rows that open their own drawer\n\t * (e.g. a configured Rest API / email-handover tool).\n\t */\n\tonConfigure?: () => void;\n}\n\n/** A tool source for the empty-state picker (Tools): a button → its searchable list. */\nexport interface SourceGroup {\n\tsource: string;\n\tlabel: string;\n\toptions: SingleOption[];\n\t/**\n\t * Integration connection state for this source. `false` = the store hasn't\n\t * connected it → clicking the source button calls {@link onConnect} instead of\n\t * opening its tool list. `true`/absent → opens normally.\n\t */\n\tconnected?: boolean;\n\t/** Open the connect flow for this source (used when `connected === false`). */\n\tonConnect?: () => void;\n}\n\n/** Sentinel value for the \"create new\" entry in the add dropdown. */\nconst CREATE_OPTION_VALUE = '__bik_create_new__';\n\ninterface SelectableListSectionProps {\n\ttitle: string;\n\thelper?: string;\n\titems: SelectableItem[];\n\t/**\n\t * Options shown in the add dropdown. Pass ALL items (not just unselected\n\t * ones) when re-picking an already-added item is allowed (e.g. to insert its\n\t * mention again) — the chip list still shows each item only once.\n\t */\n\taddableOptions: SingleOption[];\n\tonAdd: (id: string) => void;\n\tonRemove: (id: string) => void;\n\tdataTestPrefix: string;\n\temptyText: string;\n\t/**\n\t * Adds a \"create new\" entry at the top of the add dropdown (e.g. \"Create\n\t * sub-agent\"). Selecting it calls `onSelect` instead of `onAdd`.\n\t */\n\tcreateOption?: { label: string; onSelect: () => void };\n\t/**\n\t * When provided, each row shows an edit (Configure) icon next to Delete.\n\t * Omit for tools (Delete only).\n\t */\n\tonConfigure?: (id: string) => void;\n\t/**\n\t * Tool sources (e.g. Manifest / Shopify). When set, the empty state shows a\n\t * button per source; clicking one reveals a searchable dropdown of just that\n\t * source's options. Selecting calls `onAdd`. Takes precedence over the plain\n\t * `addableOptions` dropdown.\n\t */\n\tsourceGroups?: SourceGroup[];\n\t/**\n\t * When provided, the header \"+\" opens the same `@` reference picker used in the\n\t * Instructions editor (a {@link MentionPicker} popover) instead of the inline\n\t * select dropdown. Pass the items for THIS section only (tools OR sub-agents) —\n\t * the picker auto-drills into the single category. Selecting a row calls\n\t * `onAdd(id)`; the picker's \"Create new\" row (sub-agents) calls\n\t * `createOption.onSelect`.\n\t */\n\tmentionItems?: MentionItem[];\n\t/**\n\t * Built-in \"action\" tools (e.g. Rest API / Handover to email) that open a\n\t * config drawer via `onSelect` instead of adding a mention. Shown as\n\t * empty-state source buttons (only while no items exist, alongside\n\t * `sourceGroups`) AND as rows inside the `@` picker's Tools view.\n\t */\n\tactionSources?: ToolAction[];\n\t/**\n\t * When set, the row Delete icon opens a confirmation modal (instead of\n\t * removing immediately); `onRemove` runs only on confirm. `noun` fills the one\n\t * shared message template (\"Delete this <noun>?\" …); `zIndex` raises the modal\n\t * above a parent drawer. Omit to delete directly.\n\t */\n\tconfirmDelete?: { noun: string; zIndex?: number };\n}\n\nexport const SelectableListSection: React.FC<SelectableListSectionProps> = ({\n\ttitle,\n\thelper,\n\titems,\n\taddableOptions,\n\tonAdd,\n\tonRemove,\n\tdataTestPrefix,\n\temptyText,\n\tcreateOption,\n\tonConfigure,\n\tsourceGroups,\n\tmentionItems,\n\tactionSources,\n\tconfirmDelete,\n}) => {\n\tconst [adding, setAdding] = useState(false);\n\t// Row id awaiting delete confirmation (null = modal closed).\n\tconst [pendingDeleteId, setPendingDeleteId] = useState<string | null>(null);\n\t// Tools: which source's searchable list is open (null = just show the buttons).\n\tconst [activeSource, setActiveSource] = useState<string | null>(null);\n\tconst hasSourceGroups = !!sourceGroups && sourceGroups.length > 0;\n\tconst activeGroup = sourceGroups?.find((g) => g.source === activeSource);\n\t// When set, \"+\" opens the `@` MentionPicker popover instead of a select input.\n\tconst usePicker = mentionItems !== undefined;\n\t// Separate anchors for the header \"+\" popover and the empty-state source-button\n\t// popover — when empty both render at once, so a shared ref would misfire the\n\t// outside-click check (closing the header picker when a source row is clicked).\n\tconst headerPickerRef = useRef<HTMLDivElement>(null);\n\tconst sourcePickerRef = useRef<HTMLDivElement>(null);\n\t// Source (Shopify / Manifest) the empty-state button opened the picker into;\n\t// null when \"+\" opened it at the root source list.\n\tconst [pickerSource, setPickerSource] = useState<string | null>(null);\n\n\t// Dismiss the picker popover on outside click / Escape.\n\tuseEffect(() => {\n\t\tif (!usePicker || !adding) {\n\t\t\treturn;\n\t\t}\n\t\tconst onDocMouseDown = (e: MouseEvent) => {\n\t\t\tconst target = e.target as Node;\n\t\t\tif (\n\t\t\t\t!headerPickerRef.current?.contains(target) &&\n\t\t\t\t!sourcePickerRef.current?.contains(target)\n\t\t\t) {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tdocument.addEventListener('mousedown', onDocMouseDown);\n\t\tdocument.addEventListener('keydown', onKeyDown);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('mousedown', onDocMouseDown);\n\t\t\tdocument.removeEventListener('keydown', onKeyDown);\n\t\t};\n\t}, [usePicker, adding]);\n\n\t// Header \"+\" picks an EXISTING item (and, once some exist, re-creates via the\n\t// dropdown's footer row). With an empty list + a createOption the body shows a\n\t// dedicated \"Create new\" button instead, so the header \"+\" would be redundant.\n\t// In picker mode the \"+\" always shows (even empty) — for tools it sits next to\n\t// the empty-state source buttons; the create flow lives inside the picker.\n\tconst showAddButton = hasSourceGroups\n\t\t? usePicker || items.length > 0\n\t\t: usePicker ||\n\t\t addableOptions.length > 0 ||\n\t\t (!!createOption && items.length > 0);\n\t// Empty state offers a one-click \"Create new\" (sub-agents) rather than burying\n\t// it behind a single-item dropdown. In picker mode the \"+\" opens the picker\n\t// (with its own \"Create new\" row) instead, so skip the standalone button.\n\tconst showEmptyCreate =\n\t\titems.length === 0 && !!createOption && !hasSourceGroups && !usePicker;\n\tconst hasActionSources = !!actionSources && actionSources.length > 0;\n\t// Source buttons ONLY while no item is added — the tool sources (Manifest /\n\t// Shopify …) plus the built-in action tools (Rest API / Handover to email).\n\t// Once an item exists, adding more uses the header \"+\" → picker (the buttons\n\t// never come back); the action tools still live inside that picker.\n\tconst showSourceButtons =\n\t\t(hasSourceGroups || hasActionSources) && items.length === 0;\n\t// Nothing existing to pick → skip the 1-item dropdown and create directly.\n\tconst handleAddClick = () => {\n\t\tif (usePicker) {\n\t\t\t// Toggle the `@` reference-picker popover (rendered under the \"+\"), opened\n\t\t\t// at the root source list (no pre-drilled source).\n\t\t\tsetPickerSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (hasSourceGroups) {\n\t\t\tsetActiveSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (addableOptions.length === 0 && createOption) {\n\t\t\tcreateOption.onSelect();\n\t\t\treturn;\n\t\t}\n\t\tsetAdding((v) => !v);\n\t};\n\n\tconst renderChipRows = () =>\n\t\titems.map((item) => {\n\t\t\t// Per-item configure wins; otherwise fall back to the section-level one.\n\t\t\tconst configure =\n\t\t\t\titem.onConfigure ??\n\t\t\t\t(onConfigure ? () => onConfigure(item.id) : undefined);\n\t\t\treturn (\n\t\t\t\t<SelectableRow\n\t\t\t\t\tkey={item.id}\n\t\t\t\t\tdata-test={`${dataTestPrefix}-row-${item.id}`}\n\t\t\t\t>\n\t\t\t\t\t{renderSourceIcon(item.icon)}\n\t\t\t\t\t<RowText>\n\t\t\t\t\t\t<BodySecondary numberOfLines={1} color={COLORS.content.primary}>\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</RowText>\n\t\t\t\t\t<RowActions>\n\t\t\t\t\t\t{configure && (\n\t\t\t\t\t\t\t// Configurable rows (sub-agents, Rest API / email tools) get an\n\t\t\t\t\t\t\t// always-visible edit icon.\n\t\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-edit-${item.id}`}\n\t\t\t\t\t\t\t\taria-label={`Edit ${item.label}`}\n\t\t\t\t\t\t\t\tonClick={configure}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditIcon\n\t\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{configure && <RowActionDivider aria-hidden />}\n\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-${item.id}`}\n\t\t\t\t\t\t\taria-label={`Delete ${item.label}`}\n\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\tconfirmDelete ? setPendingDeleteId(item.id) : onRemove(item.id)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<DeleteIcon\n\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t</RowActions>\n\t\t\t\t</SelectableRow>\n\t\t\t);\n\t\t});\n\t// \"Create new\" is a brand-coloured footer row at the BOTTOM of the dropdown,\n\t// separated from the selectable items by a divider.\n\tconst dropdownOptions: SingleOption[] = createOption\n\t\t? [\n\t\t\t\t...addableOptions,\n\t\t\t\t{\n\t\t\t\t\tlabel: createOption.label,\n\t\t\t\t\tvalue: CREATE_OPTION_VALUE,\n\t\t\t\t\tsearchKey: createOption.label,\n\t\t\t\t\tcustomComponent: (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t\t\t\tcolor: COLORS.content.brand,\n\t\t\t\t\t\t\t\tfontFamily: 'Inter',\n\t\t\t\t\t\t\t\tfontSize: 14,\n\t\t\t\t\t\t\t\tfontWeight: 600,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{createOption.label}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t ]\n\t\t: addableOptions;\n\n\t// One picker instance reused by the header \"+\" and the empty-state source\n\t// buttons. `key` remounts it so a source button re-drills into its own tools\n\t// (the initial drill-in level is read once, on mount).\n\tconst pickerNode = usePicker ? (\n\t\t<MentionPicker\n\t\t\tkey={pickerSource ?? '__root__'}\n\t\t\titems={mentionItems ?? []}\n\t\t\tquery=\"\"\n\t\t\tactiveIndex={0}\n\t\t\tinitialSource={pickerSource ?? undefined}\n\t\t\tonSelect={(item) => {\n\t\t\t\tsetAdding(false);\n\t\t\t\tonAdd(String(item.id));\n\t\t\t}}\n\t\t\tonClose={() => setAdding(false)}\n\t\t\tonCreateSubAgent={\n\t\t\t\tcreateOption\n\t\t\t\t\t? () => {\n\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\tcreateOption.onSelect();\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\ttoolActions={\n\t\t\t\thasActionSources\n\t\t\t\t\t? actionSources?.map((a) => ({\n\t\t\t\t\t\t\t...a,\n\t\t\t\t\t\t\tonSelect: () => {\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\ta.onSelect();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }))\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\t// Gate native source rows in the picker on their connected state, derived\n\t\t\t// from the source groups (which already carry connected/onConnect). This is\n\t\t\t// what makes the \"+\" dropdown show \"Connect\" for unconnected vendors,\n\t\t\t// consistent with the empty-state buttons.\n\t\t\tintegrationStatus={Object.fromEntries(\n\t\t\t\t(sourceGroups ?? [])\n\t\t\t\t\t.filter((g) => g.connected !== undefined)\n\t\t\t\t\t.map((g) => [g.source, g.connected]),\n\t\t\t)}\n\t\t\tonConnectIntegration={(source) => {\n\t\t\t\tsetAdding(false);\n\t\t\t\tsourceGroups?.find((g) => g.source === source)?.onConnect?.();\n\t\t\t}}\n\t\t/>\n\t) : null;\n\n\treturn (\n\t\t<SideSection>\n\t\t\t<SideSectionHeader>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{title}</TitleSmall>\n\t\t\t\t{showAddButton && (\n\t\t\t\t\t<AddButtonWrap ref={headerPickerRef}>\n\t\t\t\t\t\t<AddIconButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-add`}\n\t\t\t\t\t\t\tonClick={handleAddClick}\n\t\t\t\t\t\t\taria-label={`Add ${title}`}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon width={20} height={20} color={COLORS.content.brand} />\n\t\t\t\t\t\t</AddIconButton>\n\t\t\t\t\t\t{usePicker && adding && pickerSource === null && (\n\t\t\t\t\t\t\t<PickerPopover data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</AddButtonWrap>\n\t\t\t\t)}\n\t\t\t</SideSectionHeader>\n\n\t\t\t{helper && (\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>{helper}</BodyCaption>\n\t\t\t)}\n\n\t\t\t{showSourceButtons ? (\n\t\t\t\t<SourcePickerAnchor ref={usePicker ? sourcePickerRef : undefined}>\n\t\t\t\t\t{/* No tools yet: one button per source (never shown once a tool exists). */}\n\t\t\t\t\t<SourceButtonRow data-test={`${dataTestPrefix}-sources`}>\n\t\t\t\t\t\t{sourceGroups?.map((g) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={g.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-source-${g.source}`}\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t// Not connected → open the connect flow instead of the tools.\n\t\t\t\t\t\t\t\t\tif (g.connected === false) {\n\t\t\t\t\t\t\t\t\t\tg.onConnect?.();\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (usePicker) {\n\t\t\t\t\t\t\t\t\t\t// Open the `@` picker drilled straight into this source's tools.\n\t\t\t\t\t\t\t\t\t\tsetPickerSource(g.source);\n\t\t\t\t\t\t\t\t\t\tsetAdding(true);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetActiveSource(g.source);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(SOURCE_ICONS[g.source], -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{g.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t{g.connected === false && (\n\t\t\t\t\t\t\t\t\t// Not connected → show \"Connect\" upfront (consistent with\n\t\t\t\t\t\t\t\t\t// the `@` picker); clicking runs the connect flow.\n\t\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.brand}>\n\t\t\t\t\t\t\t\t\t\tConnect\n\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t{/* Built-in action tools (Rest API / Handover to email) open a drawer. */}\n\t\t\t\t\t\t{actionSources?.map((a) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={a.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-action-${a.source}`}\n\t\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\t\ta.connected === false ? () => a.onConnect?.() : a.onSelect\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(a.icon, -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{a.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t{a.connected === false && (\n\t\t\t\t\t\t\t\t\t// Not connected → \"Connect\" upfront (consistent with the\n\t\t\t\t\t\t\t\t\t// source buttons and the `@` picker).\n\t\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.brand}>\n\t\t\t\t\t\t\t\t\t\tConnect\n\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</SourceButtonRow>\n\n\t\t\t\t\t{/* Picker mode: clicking a source opens its tools in the `@` picker. */}\n\t\t\t\t\t{usePicker && adding && pickerSource !== null && (\n\t\t\t\t\t\t<PickerPopover $align=\"left\" data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Legacy (non-picker) mode: chosen source → its searchable tool list. */}\n\t\t\t\t\t{!usePicker && activeGroup && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Search ${activeGroup.label} tools`}\n\t\t\t\t\t\t\toptions={activeGroup.options}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetActiveSource(null);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\tonAdd(v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</SourcePickerAnchor>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t{!usePicker && adding && dropdownOptions.length > 0 && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Select ${title.toLowerCase()}`}\n\t\t\t\t\t\t\toptions={dropdownOptions}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (!v) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (v === CREATE_OPTION_VALUE) {\n\t\t\t\t\t\t\t\t\tcreateOption?.onSelect();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonAdd(v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{items.length === 0 && !adding ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.placeholder}>\n\t\t\t\t\t\t\t\t{emptyText}\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t{showEmptyCreate && createOption && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-create`}\n\t\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tLeadingIcon={PlusIcon}\n\t\t\t\t\t\t\t\t\tbuttonText={createOption.label}\n\t\t\t\t\t\t\t\t\tonClick={createOption.onSelect}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\trenderChipRows()\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t{confirmDelete && pendingDeleteId && (\n\t\t\t\t<DeleteConfirmationModal\n\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-confirm`}\n\t\t\t\t\theader={`Delete this ${confirmDelete.noun}?`}\n\t\t\t\t\tsubHeader={`Deleting this ${confirmDelete.noun} will also remove it from your instructions, wherever it's referenced.`}\n\t\t\t\t\tconfirmationText=\"Delete\"\n\t\t\t\t\tzIndex={confirmDelete.zIndex}\n\t\t\t\t\tonDeleteConfirmed={() => {\n\t\t\t\t\t\tonRemove(pendingDeleteId);\n\t\t\t\t\t\tsetPendingDeleteId(null);\n\t\t\t\t\t}}\n\t\t\t\t\tonCancelClicked={() => setPendingDeleteId(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</SideSection>\n\t);\n};\n\n// Anchors the `@`-picker popover to the header \"+\" button.\nconst AddButtonWrap = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n`;\n\n// Anchors the `@`-picker popover to the empty-state source buttons.\nconst SourcePickerAnchor = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n`;\n\n// Floating card under the trigger. Aligns to the \"+\" (right) or the source\n// buttons (left) so it stays inside the side panel.\nconst PickerPopover = styled.div<{ $align?: 'left' | 'right' }>`\n\tposition: absolute;\n\ttop: calc(100% + 4px);\n\t${(p) => (p.$align === 'left' ? 'left: 0;' : 'right: 0;')}\n\tz-index: 30;\n`;\n"],"names":["CREATE_OPTION_VALUE","SelectableListSection","title","helper","items","addableOptions","onAdd","onRemove","dataTestPrefix","emptyText","createOption","onConfigure","sourceGroups","mentionItems","actionSources","confirmDelete","adding","setAdding","useState","pendingDeleteId","setPendingDeleteId","activeSource","setActiveSource","hasSourceGroups","activeGroup","g","usePicker","headerPickerRef","useRef","sourcePickerRef","pickerSource","setPickerSource","useEffect","onDocMouseDown","e","target","onKeyDown","showAddButton","showEmptyCreate","hasActionSources","showSourceButtons","handleAddClick","v","renderChipRows","item","configure","jsxs","SelectableRow","renderSourceIcon","jsx","RowText","BodySecondary","COLORS","RowActions","RowMenuButton","EditIcon","RowActionDivider","DeleteIcon","dropdownOptions","pickerNode","MentionPicker","a","source","SideSection","SideSectionHeader","TitleSmall","AddButtonWrap","AddIconButton","PlusIcon","PickerPopover","BodyCaption","SourcePickerAnchor","SourceButtonRow","SourceButton","SOURCE_ICONS","Dropdown","opt","unwrapDropdownValue","Fragment","Button","DeleteConfirmationModal","styled","p"],"mappings":"iuBAiEMA,EAAsB,qBA0DfC,GAA8D,CAAC,CAC3E,MAAAC,EACA,OAAAC,EACA,MAAAC,EACA,eAAAC,EACA,MAAAC,EACA,SAAAC,EACA,eAAAC,EACA,UAA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ragment as j } from "react/jsx-runtime";
2
- import ne from "../../../assets/icons/delete.svg.js";
1
+ import { jsx as n, jsxs as d, Fragment as W } from "react/jsx-runtime";
2
+ import oe from "../../../assets/icons/delete.svg.js";
3
3
  import te from "../../../assets/icons/edit.svg.js";
4
4
  import F from "../../../assets/icons/plus.svg.js";
5
- import { useState as v, useRef as K, useEffect as le } from "react";
5
+ import { useState as b, useRef as K, useEffect as le } from "react";
6
6
  import E from "styled-components";
7
- import { TitleSmall as re, BodyCaption as U, BodySecondary as $ } from "../../TypographyStyle.js";
8
- import { COLORS as d } from "../../../constants/Theme.js";
7
+ import { TitleSmall as re, BodyCaption as U, BodySecondary as m } from "../../TypographyStyle.js";
8
+ import { COLORS as i } from "../../../constants/Theme.js";
9
9
  import { SideSection as ce, SideSectionHeader as ie, AddIconButton as de, SourceButtonRow as se, SourceButton as V, SelectableRow as ae, RowText as ue, RowActions as he, RowMenuButton as q, RowActionDivider as fe } from "../AgentBuilder.styled.js";
10
- import { renderSourceIcon as A, SOURCE_ICONS as pe } from "../utils/sourceIcons.js";
11
- import { MentionPicker as me } from "./MentionPicker.js";
10
+ import { renderSourceIcon as A, SOURCE_ICONS as me } from "../utils/sourceIcons.js";
11
+ import { MentionPicker as Se } from "./MentionPicker.js";
12
12
  import { Dropdown as J } from "../../dropdown/Dropdown.js";
13
13
  import { unwrapDropdownValue as P } from "../../dropdown/utils.js";
14
- import { Button as Se } from "../../button/Button.js";
14
+ import { Button as pe } from "../../button/Button.js";
15
15
  import { DeleteConfirmationModal as we } from "../../states-modal/DeleteConfirmationModal.js";
16
16
  const Q = "__bik_create_new__", He = ({
17
- title: u,
17
+ title: h,
18
18
  helper: _,
19
19
  items: s,
20
- addableOptions: f,
21
- onAdd: b,
20
+ addableOptions: S,
21
+ onAdd: C,
22
22
  onRemove: R,
23
- dataTestPrefix: t,
23
+ dataTestPrefix: l,
24
24
  emptyText: Y,
25
- createOption: n,
25
+ createOption: t,
26
26
  onConfigure: D,
27
- sourceGroups: p,
28
- mentionItems: B,
29
- actionSources: m,
30
- confirmDelete: h
27
+ sourceGroups: a,
28
+ mentionItems: I,
29
+ actionSources: p,
30
+ confirmDelete: f
31
31
  }) => {
32
- const [a, c] = v(!1), [I, y] = v(null), [Z, g] = v(null), S = !!p && p.length > 0, C = p?.find((e) => e.source === Z), l = B !== void 0, L = K(null), z = K(null), [w, x] = v(null);
32
+ const [u, r] = b(!1), [B, $] = b(null), [Z, g] = b(null), w = !!a && a.length > 0, y = a?.find((e) => e.source === Z), c = I !== void 0, L = K(null), z = K(null), [v, x] = b(null);
33
33
  le(() => {
34
- if (!l || !a)
34
+ if (!c || !u)
35
35
  return;
36
36
  const e = (k) => {
37
- const W = k.target;
38
- !L.current?.contains(W) && !z.current?.contains(W) && c(!1);
39
- }, r = (k) => {
40
- k.key === "Escape" && c(!1);
37
+ const N = k.target;
38
+ !L.current?.contains(N) && !z.current?.contains(N) && r(!1);
39
+ }, o = (k) => {
40
+ k.key === "Escape" && r(!1);
41
41
  };
42
- return document.addEventListener("mousedown", e), document.addEventListener("keydown", r), () => {
43
- document.removeEventListener("mousedown", e), document.removeEventListener("keydown", r);
42
+ return document.addEventListener("mousedown", e), document.addEventListener("keydown", o), () => {
43
+ document.removeEventListener("mousedown", e), document.removeEventListener("keydown", o);
44
44
  };
45
- }, [l, a]);
46
- const G = S ? l || s.length > 0 : l || f.length > 0 || !!n && s.length > 0, T = s.length === 0 && !!n && !S && !l, H = !!m && m.length > 0, O = (S || H) && s.length === 0, ee = () => {
47
- if (l) {
48
- x(null), c((e) => !e);
45
+ }, [c, u]);
46
+ const G = w ? c || s.length > 0 : c || S.length > 0 || !!t && s.length > 0, T = s.length === 0 && !!t && !w && !c, H = !!p && p.length > 0, O = (w || H) && s.length === 0, ee = () => {
47
+ if (c) {
48
+ x(null), r((e) => !e);
49
49
  return;
50
50
  }
51
- if (S) {
52
- g(null), c((e) => !e);
51
+ if (w) {
52
+ g(null), r((e) => !e);
53
53
  return;
54
54
  }
55
- if (f.length === 0 && n) {
56
- n.onSelect();
55
+ if (S.length === 0 && t) {
56
+ t.onSelect();
57
57
  return;
58
58
  }
59
- c((e) => !e);
60
- }, oe = () => s.map((e) => {
61
- const r = e.onConfigure ?? (D ? () => D(e.id) : void 0);
62
- return /* @__PURE__ */ i(
59
+ r((e) => !e);
60
+ }, ne = () => s.map((e) => {
61
+ const o = e.onConfigure ?? (D ? () => D(e.id) : void 0);
62
+ return /* @__PURE__ */ d(
63
63
  ae,
64
64
  {
65
- "data-test": `${t}-row-${e.id}`,
65
+ "data-test": `${l}-row-${e.id}`,
66
66
  children: [
67
67
  A(e.icon),
68
- /* @__PURE__ */ o(ue, { children: /* @__PURE__ */ o($, { numberOfLines: 1, color: d.content.primary, children: e.label }) }),
69
- /* @__PURE__ */ i(he, { children: [
70
- r && // Configurable rows (sub-agents, Rest API / email tools) get an
68
+ /* @__PURE__ */ n(ue, { children: /* @__PURE__ */ n(m, { numberOfLines: 1, color: i.content.primary, children: e.label }) }),
69
+ /* @__PURE__ */ d(he, { children: [
70
+ o && // Configurable rows (sub-agents, Rest API / email tools) get an
71
71
  // always-visible edit icon.
72
- /* @__PURE__ */ o(
72
+ /* @__PURE__ */ n(
73
73
  q,
74
74
  {
75
- "data-test": `${t}-edit-${e.id}`,
75
+ "data-test": `${l}-edit-${e.id}`,
76
76
  "aria-label": `Edit ${e.label}`,
77
- onClick: r,
78
- children: /* @__PURE__ */ o(
77
+ onClick: o,
78
+ children: /* @__PURE__ */ n(
79
79
  te,
80
80
  {
81
81
  width: 16,
82
82
  height: 16,
83
- color: d.content.secondary
83
+ color: i.content.secondary
84
84
  }
85
85
  )
86
86
  }
87
87
  ),
88
- r && /* @__PURE__ */ o(fe, { "aria-hidden": !0 }),
89
- /* @__PURE__ */ o(
88
+ o && /* @__PURE__ */ n(fe, { "aria-hidden": !0 }),
89
+ /* @__PURE__ */ n(
90
90
  q,
91
91
  {
92
- "data-test": `${t}-delete-${e.id}`,
92
+ "data-test": `${l}-delete-${e.id}`,
93
93
  "aria-label": `Delete ${e.label}`,
94
- onClick: () => h ? y(e.id) : R(e.id),
95
- children: /* @__PURE__ */ o(
96
- ne,
94
+ onClick: () => f ? $(e.id) : R(e.id),
95
+ children: /* @__PURE__ */ n(
96
+ oe,
97
97
  {
98
98
  width: 16,
99
99
  height: 16,
100
- color: d.content.secondary
100
+ color: i.content.secondary
101
101
  }
102
102
  )
103
103
  }
@@ -107,176 +107,185 @@ const Q = "__bik_create_new__", He = ({
107
107
  },
108
108
  e.id
109
109
  );
110
- }), M = n ? [
111
- ...f,
110
+ }), M = t ? [
111
+ ...S,
112
112
  {
113
- label: n.label,
113
+ label: t.label,
114
114
  value: Q,
115
- searchKey: n.label,
116
- customComponent: /* @__PURE__ */ o(
115
+ searchKey: t.label,
116
+ customComponent: /* @__PURE__ */ n(
117
117
  "div",
118
118
  {
119
119
  style: {
120
120
  width: "100%",
121
121
  textAlign: "center",
122
- color: d.content.brand,
122
+ color: i.content.brand,
123
123
  fontFamily: "Inter",
124
124
  fontSize: 14,
125
125
  fontWeight: 600
126
126
  },
127
- children: n.label
127
+ children: t.label
128
128
  }
129
129
  )
130
130
  }
131
- ] : f, N = l ? /* @__PURE__ */ o(
132
- me,
131
+ ] : S, j = c ? /* @__PURE__ */ n(
132
+ Se,
133
133
  {
134
- items: B ?? [],
134
+ items: I ?? [],
135
135
  query: "",
136
136
  activeIndex: 0,
137
- initialSource: w ?? void 0,
137
+ initialSource: v ?? void 0,
138
138
  onSelect: (e) => {
139
- c(!1), b(String(e.id));
139
+ r(!1), C(String(e.id));
140
140
  },
141
- onClose: () => c(!1),
142
- onCreateSubAgent: n ? () => {
143
- c(!1), n.onSelect();
141
+ onClose: () => r(!1),
142
+ onCreateSubAgent: t ? () => {
143
+ r(!1), t.onSelect();
144
144
  } : void 0,
145
- toolActions: H ? m?.map((e) => ({
145
+ toolActions: H ? p?.map((e) => ({
146
146
  ...e,
147
147
  onSelect: () => {
148
- c(!1), e.onSelect();
148
+ r(!1), e.onSelect();
149
149
  }
150
- })) : void 0
150
+ })) : void 0,
151
+ integrationStatus: Object.fromEntries(
152
+ (a ?? []).filter((e) => e.connected !== void 0).map((e) => [e.source, e.connected])
153
+ ),
154
+ onConnectIntegration: (e) => {
155
+ r(!1), a?.find((o) => o.source === e)?.onConnect?.();
156
+ }
151
157
  },
152
- w ?? "__root__"
158
+ v ?? "__root__"
153
159
  ) : null;
154
- return /* @__PURE__ */ i(ce, { children: [
155
- /* @__PURE__ */ i(ie, { children: [
156
- /* @__PURE__ */ o(re, { color: d.content.primary, children: u }),
157
- G && /* @__PURE__ */ i(ve, { ref: L, children: [
158
- /* @__PURE__ */ o(
160
+ return /* @__PURE__ */ d(ce, { children: [
161
+ /* @__PURE__ */ d(ie, { children: [
162
+ /* @__PURE__ */ n(re, { color: i.content.primary, children: h }),
163
+ G && /* @__PURE__ */ d(ve, { ref: L, children: [
164
+ /* @__PURE__ */ n(
159
165
  de,
160
166
  {
161
- "data-test": `${t}-add`,
167
+ "data-test": `${l}-add`,
162
168
  onClick: ee,
163
- "aria-label": `Add ${u}`,
164
- children: /* @__PURE__ */ o(F, { width: 20, height: 20, color: d.content.brand })
169
+ "aria-label": `Add ${h}`,
170
+ children: /* @__PURE__ */ n(F, { width: 20, height: 20, color: i.content.brand })
165
171
  }
166
172
  ),
167
- l && a && w === null && /* @__PURE__ */ o(X, { "data-test": `${t}-picker`, children: N })
173
+ c && u && v === null && /* @__PURE__ */ n(X, { "data-test": `${l}-picker`, children: j })
168
174
  ] })
169
175
  ] }),
170
- _ && /* @__PURE__ */ o(U, { color: d.content.secondary, children: _ }),
171
- O ? /* @__PURE__ */ i($e, { ref: l ? z : void 0, children: [
172
- /* @__PURE__ */ i(se, { "data-test": `${t}-sources`, children: [
173
- p?.map((e) => /* @__PURE__ */ i(
176
+ _ && /* @__PURE__ */ n(U, { color: i.content.secondary, children: _ }),
177
+ O ? /* @__PURE__ */ d(be, { ref: c ? z : void 0, children: [
178
+ /* @__PURE__ */ d(se, { "data-test": `${l}-sources`, children: [
179
+ a?.map((e) => /* @__PURE__ */ d(
174
180
  V,
175
181
  {
176
182
  type: "button",
177
- "data-test": `${t}-source-${e.source}`,
183
+ "data-test": `${l}-source-${e.source}`,
178
184
  onClick: () => {
179
185
  if (e.connected === !1) {
180
186
  e.onConnect?.();
181
187
  return;
182
188
  }
183
- if (l) {
184
- x(e.source), c(!0);
189
+ if (c) {
190
+ x(e.source), r(!0);
185
191
  return;
186
192
  }
187
193
  g(e.source);
188
194
  },
189
195
  children: [
190
- A(pe[e.source], -4),
191
- /* @__PURE__ */ o($, { color: d.content.primary, children: e.label }),
196
+ A(me[e.source], -4),
197
+ /* @__PURE__ */ n(m, { color: i.content.primary, children: e.label }),
192
198
  e.connected === !1 && // Not connected → show "Connect" upfront (consistent with
193
199
  // the `@` picker); clicking runs the connect flow.
194
- /* @__PURE__ */ o($, { color: d.content.brand, children: "Connect" })
200
+ /* @__PURE__ */ n(m, { color: i.content.brand, children: "Connect" })
195
201
  ]
196
202
  },
197
203
  e.source
198
204
  )),
199
- m?.map((e) => /* @__PURE__ */ i(
205
+ p?.map((e) => /* @__PURE__ */ d(
200
206
  V,
201
207
  {
202
208
  type: "button",
203
- "data-test": `${t}-action-${e.source}`,
204
- onClick: e.onSelect,
209
+ "data-test": `${l}-action-${e.source}`,
210
+ onClick: e.connected === !1 ? () => e.onConnect?.() : e.onSelect,
205
211
  children: [
206
212
  A(e.icon, -4),
207
- /* @__PURE__ */ o($, { color: d.content.primary, children: e.label })
213
+ /* @__PURE__ */ n(m, { color: i.content.primary, children: e.label }),
214
+ e.connected === !1 && // Not connected → "Connect" upfront (consistent with the
215
+ // source buttons and the `@` picker).
216
+ /* @__PURE__ */ n(m, { color: i.content.brand, children: "Connect" })
208
217
  ]
209
218
  },
210
219
  e.source
211
220
  ))
212
221
  ] }),
213
- l && a && w !== null && /* @__PURE__ */ o(X, { $align: "left", "data-test": `${t}-picker`, children: N }),
214
- !l && C && /* @__PURE__ */ o(
222
+ c && u && v !== null && /* @__PURE__ */ n(X, { $align: "left", "data-test": `${l}-picker`, children: j }),
223
+ !c && y && /* @__PURE__ */ n(
215
224
  J,
216
225
  {
217
- "data-test": `${t}-dropdown`,
226
+ "data-test": `${l}-dropdown`,
218
227
  size: "small",
219
228
  width: "100%",
220
229
  isSearchable: !0,
221
- placeHolder: `Search ${C.label} tools`,
222
- options: C.options,
230
+ placeHolder: `Search ${y.label} tools`,
231
+ options: y.options,
223
232
  onSelect: (e) => {
224
- const r = P(e);
225
- g(null), c(!1), r && b(r);
233
+ const o = P(e);
234
+ g(null), r(!1), o && C(o);
226
235
  }
227
236
  }
228
237
  )
229
- ] }) : /* @__PURE__ */ i(j, { children: [
230
- !l && a && M.length > 0 && /* @__PURE__ */ o(
238
+ ] }) : /* @__PURE__ */ d(W, { children: [
239
+ !c && u && M.length > 0 && /* @__PURE__ */ n(
231
240
  J,
232
241
  {
233
- "data-test": `${t}-dropdown`,
242
+ "data-test": `${l}-dropdown`,
234
243
  size: "small",
235
244
  width: "100%",
236
245
  isSearchable: !0,
237
- placeHolder: `Select ${u.toLowerCase()}`,
246
+ placeHolder: `Select ${h.toLowerCase()}`,
238
247
  options: M,
239
248
  onSelect: (e) => {
240
- const r = P(e);
241
- c(!1), r && (r === Q ? n?.onSelect() : b(r));
249
+ const o = P(e);
250
+ r(!1), o && (o === Q ? t?.onSelect() : C(o));
242
251
  }
243
252
  }
244
253
  ),
245
- s.length === 0 && !a ? /* @__PURE__ */ i(j, { children: [
246
- /* @__PURE__ */ o(U, { color: d.content.placeholder, children: Y }),
247
- T && n && /* @__PURE__ */ o(
248
- Se,
254
+ s.length === 0 && !u ? /* @__PURE__ */ d(W, { children: [
255
+ /* @__PURE__ */ n(U, { color: i.content.placeholder, children: Y }),
256
+ T && t && /* @__PURE__ */ n(
257
+ pe,
249
258
  {
250
- "data-test": `${t}-create`,
259
+ "data-test": `${l}-create`,
251
260
  buttonType: "secondary",
252
261
  size: "small",
253
262
  matchParentWidth: !0,
254
263
  LeadingIcon: F,
255
- buttonText: n.label,
256
- onClick: n.onSelect
264
+ buttonText: t.label,
265
+ onClick: t.onSelect
257
266
  }
258
267
  )
259
- ] }) : oe()
268
+ ] }) : ne()
260
269
  ] }),
261
- h && I && /* @__PURE__ */ o(
270
+ f && B && /* @__PURE__ */ n(
262
271
  we,
263
272
  {
264
- "data-test": `${t}-delete-confirm`,
265
- header: `Delete this ${h.noun}?`,
266
- subHeader: `Deleting this ${h.noun} will also remove it from your instructions, wherever it's referenced.`,
273
+ "data-test": `${l}-delete-confirm`,
274
+ header: `Delete this ${f.noun}?`,
275
+ subHeader: `Deleting this ${f.noun} will also remove it from your instructions, wherever it's referenced.`,
267
276
  confirmationText: "Delete",
268
- zIndex: h.zIndex,
277
+ zIndex: f.zIndex,
269
278
  onDeleteConfirmed: () => {
270
- R(I), y(null);
279
+ R(B), $(null);
271
280
  },
272
- onCancelClicked: () => y(null)
281
+ onCancelClicked: () => $(null)
273
282
  }
274
283
  )
275
284
  ] });
276
285
  }, ve = E.div`
277
286
  position: relative;
278
287
  display: flex;
279
- `, $e = E.div`
288
+ `, be = E.div`
280
289
  position: relative;
281
290
  display: flex;
282
291
  flex-direction: column;
@@ -284,7 +293,7 @@ const Q = "__bik_create_new__", He = ({
284
293
  `, X = E.div`
285
294
  position: absolute;
286
295
  top: calc(100% + 4px);
287
- ${(u) => u.$align === "left" ? "left: 0;" : "right: 0;"}
296
+ ${(h) => h.$align === "left" ? "left: 0;" : "right: 0;"}
288
297
  z-index: 30;
289
298
  `;
290
299
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"SelectableListSection.js","sources":["../../../../../src/components/agent-builder/components/SelectableListSection.tsx"],"sourcesContent":["import DeleteIcon from '@src/assets/icons/delete.svg';\nimport EditIcon from '@src/assets/icons/edit.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport { MentionItem } from '@src/editor';\nimport React, { useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { DeleteConfirmationModal } from '@src/components/states-modal';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAddIconButton,\n\tRowActionDivider,\n\tRowActions,\n\tRowMenuButton,\n\tRowText,\n\tSelectableRow,\n\tSideSection,\n\tSideSectionHeader,\n\tSourceButton,\n\tSourceButtonRow,\n} from '../AgentBuilder.styled';\nimport { ToolAction } from '../constants/tools';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tSourceIcon,\n} from '../utils/sourceIcons';\nimport { MentionPicker } from './MentionPicker';\n\nexport interface SelectableItem {\n\tid: string;\n\tlabel: string;\n\t/** Leading brand glyph (e.g. a tool's source icon). */\n\ticon?: SourceIcon;\n\t/**\n\t * When set, this row shows an edit (Configure) icon that calls this instead of\n\t * the section-level `onConfigure`. Use for rows that open their own drawer\n\t * (e.g. a configured Rest API / email-handover tool).\n\t */\n\tonConfigure?: () => void;\n}\n\n/** A tool source for the empty-state picker (Tools): a button → its searchable list. */\nexport interface SourceGroup {\n\tsource: string;\n\tlabel: string;\n\toptions: SingleOption[];\n\t/**\n\t * Integration connection state for this source. `false` = the store hasn't\n\t * connected it → clicking the source button calls {@link onConnect} instead of\n\t * opening its tool list. `true`/absent → opens normally.\n\t */\n\tconnected?: boolean;\n\t/** Open the connect flow for this source (used when `connected === false`). */\n\tonConnect?: () => void;\n}\n\n/** Sentinel value for the \"create new\" entry in the add dropdown. */\nconst CREATE_OPTION_VALUE = '__bik_create_new__';\n\ninterface SelectableListSectionProps {\n\ttitle: string;\n\thelper?: string;\n\titems: SelectableItem[];\n\t/**\n\t * Options shown in the add dropdown. Pass ALL items (not just unselected\n\t * ones) when re-picking an already-added item is allowed (e.g. to insert its\n\t * mention again) — the chip list still shows each item only once.\n\t */\n\taddableOptions: SingleOption[];\n\tonAdd: (id: string) => void;\n\tonRemove: (id: string) => void;\n\tdataTestPrefix: string;\n\temptyText: string;\n\t/**\n\t * Adds a \"create new\" entry at the top of the add dropdown (e.g. \"Create\n\t * sub-agent\"). Selecting it calls `onSelect` instead of `onAdd`.\n\t */\n\tcreateOption?: { label: string; onSelect: () => void };\n\t/**\n\t * When provided, each row shows an edit (Configure) icon next to Delete.\n\t * Omit for tools (Delete only).\n\t */\n\tonConfigure?: (id: string) => void;\n\t/**\n\t * Tool sources (e.g. Manifest / Shopify). When set, the empty state shows a\n\t * button per source; clicking one reveals a searchable dropdown of just that\n\t * source's options. Selecting calls `onAdd`. Takes precedence over the plain\n\t * `addableOptions` dropdown.\n\t */\n\tsourceGroups?: SourceGroup[];\n\t/**\n\t * When provided, the header \"+\" opens the same `@` reference picker used in the\n\t * Instructions editor (a {@link MentionPicker} popover) instead of the inline\n\t * select dropdown. Pass the items for THIS section only (tools OR sub-agents) —\n\t * the picker auto-drills into the single category. Selecting a row calls\n\t * `onAdd(id)`; the picker's \"Create new\" row (sub-agents) calls\n\t * `createOption.onSelect`.\n\t */\n\tmentionItems?: MentionItem[];\n\t/**\n\t * Built-in \"action\" tools (e.g. Rest API / Handover to email) that open a\n\t * config drawer via `onSelect` instead of adding a mention. Shown as\n\t * empty-state source buttons (only while no items exist, alongside\n\t * `sourceGroups`) AND as rows inside the `@` picker's Tools view.\n\t */\n\tactionSources?: ToolAction[];\n\t/**\n\t * When set, the row Delete icon opens a confirmation modal (instead of\n\t * removing immediately); `onRemove` runs only on confirm. `noun` fills the one\n\t * shared message template (\"Delete this <noun>?\" …); `zIndex` raises the modal\n\t * above a parent drawer. Omit to delete directly.\n\t */\n\tconfirmDelete?: { noun: string; zIndex?: number };\n}\n\nexport const SelectableListSection: React.FC<SelectableListSectionProps> = ({\n\ttitle,\n\thelper,\n\titems,\n\taddableOptions,\n\tonAdd,\n\tonRemove,\n\tdataTestPrefix,\n\temptyText,\n\tcreateOption,\n\tonConfigure,\n\tsourceGroups,\n\tmentionItems,\n\tactionSources,\n\tconfirmDelete,\n}) => {\n\tconst [adding, setAdding] = useState(false);\n\t// Row id awaiting delete confirmation (null = modal closed).\n\tconst [pendingDeleteId, setPendingDeleteId] = useState<string | null>(null);\n\t// Tools: which source's searchable list is open (null = just show the buttons).\n\tconst [activeSource, setActiveSource] = useState<string | null>(null);\n\tconst hasSourceGroups = !!sourceGroups && sourceGroups.length > 0;\n\tconst activeGroup = sourceGroups?.find((g) => g.source === activeSource);\n\t// When set, \"+\" opens the `@` MentionPicker popover instead of a select input.\n\tconst usePicker = mentionItems !== undefined;\n\t// Separate anchors for the header \"+\" popover and the empty-state source-button\n\t// popover — when empty both render at once, so a shared ref would misfire the\n\t// outside-click check (closing the header picker when a source row is clicked).\n\tconst headerPickerRef = useRef<HTMLDivElement>(null);\n\tconst sourcePickerRef = useRef<HTMLDivElement>(null);\n\t// Source (Shopify / Manifest) the empty-state button opened the picker into;\n\t// null when \"+\" opened it at the root source list.\n\tconst [pickerSource, setPickerSource] = useState<string | null>(null);\n\n\t// Dismiss the picker popover on outside click / Escape.\n\tuseEffect(() => {\n\t\tif (!usePicker || !adding) {\n\t\t\treturn;\n\t\t}\n\t\tconst onDocMouseDown = (e: MouseEvent) => {\n\t\t\tconst target = e.target as Node;\n\t\t\tif (\n\t\t\t\t!headerPickerRef.current?.contains(target) &&\n\t\t\t\t!sourcePickerRef.current?.contains(target)\n\t\t\t) {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tdocument.addEventListener('mousedown', onDocMouseDown);\n\t\tdocument.addEventListener('keydown', onKeyDown);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('mousedown', onDocMouseDown);\n\t\t\tdocument.removeEventListener('keydown', onKeyDown);\n\t\t};\n\t}, [usePicker, adding]);\n\n\t// Header \"+\" picks an EXISTING item (and, once some exist, re-creates via the\n\t// dropdown's footer row). With an empty list + a createOption the body shows a\n\t// dedicated \"Create new\" button instead, so the header \"+\" would be redundant.\n\t// In picker mode the \"+\" always shows (even empty) — for tools it sits next to\n\t// the empty-state source buttons; the create flow lives inside the picker.\n\tconst showAddButton = hasSourceGroups\n\t\t? usePicker || items.length > 0\n\t\t: usePicker ||\n\t\t addableOptions.length > 0 ||\n\t\t (!!createOption && items.length > 0);\n\t// Empty state offers a one-click \"Create new\" (sub-agents) rather than burying\n\t// it behind a single-item dropdown. In picker mode the \"+\" opens the picker\n\t// (with its own \"Create new\" row) instead, so skip the standalone button.\n\tconst showEmptyCreate =\n\t\titems.length === 0 && !!createOption && !hasSourceGroups && !usePicker;\n\tconst hasActionSources = !!actionSources && actionSources.length > 0;\n\t// Source buttons ONLY while no item is added — the tool sources (Manifest /\n\t// Shopify …) plus the built-in action tools (Rest API / Handover to email).\n\t// Once an item exists, adding more uses the header \"+\" → picker (the buttons\n\t// never come back); the action tools still live inside that picker.\n\tconst showSourceButtons =\n\t\t(hasSourceGroups || hasActionSources) && items.length === 0;\n\t// Nothing existing to pick → skip the 1-item dropdown and create directly.\n\tconst handleAddClick = () => {\n\t\tif (usePicker) {\n\t\t\t// Toggle the `@` reference-picker popover (rendered under the \"+\"), opened\n\t\t\t// at the root source list (no pre-drilled source).\n\t\t\tsetPickerSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (hasSourceGroups) {\n\t\t\tsetActiveSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (addableOptions.length === 0 && createOption) {\n\t\t\tcreateOption.onSelect();\n\t\t\treturn;\n\t\t}\n\t\tsetAdding((v) => !v);\n\t};\n\n\tconst renderChipRows = () =>\n\t\titems.map((item) => {\n\t\t\t// Per-item configure wins; otherwise fall back to the section-level one.\n\t\t\tconst configure =\n\t\t\t\titem.onConfigure ??\n\t\t\t\t(onConfigure ? () => onConfigure(item.id) : undefined);\n\t\t\treturn (\n\t\t\t\t<SelectableRow\n\t\t\t\t\tkey={item.id}\n\t\t\t\t\tdata-test={`${dataTestPrefix}-row-${item.id}`}\n\t\t\t\t>\n\t\t\t\t\t{renderSourceIcon(item.icon)}\n\t\t\t\t\t<RowText>\n\t\t\t\t\t\t<BodySecondary numberOfLines={1} color={COLORS.content.primary}>\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</RowText>\n\t\t\t\t\t<RowActions>\n\t\t\t\t\t\t{configure && (\n\t\t\t\t\t\t\t// Configurable rows (sub-agents, Rest API / email tools) get an\n\t\t\t\t\t\t\t// always-visible edit icon.\n\t\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-edit-${item.id}`}\n\t\t\t\t\t\t\t\taria-label={`Edit ${item.label}`}\n\t\t\t\t\t\t\t\tonClick={configure}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditIcon\n\t\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{configure && <RowActionDivider aria-hidden />}\n\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-${item.id}`}\n\t\t\t\t\t\t\taria-label={`Delete ${item.label}`}\n\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\tconfirmDelete ? setPendingDeleteId(item.id) : onRemove(item.id)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<DeleteIcon\n\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t</RowActions>\n\t\t\t\t</SelectableRow>\n\t\t\t);\n\t\t});\n\t// \"Create new\" is a brand-coloured footer row at the BOTTOM of the dropdown,\n\t// separated from the selectable items by a divider.\n\tconst dropdownOptions: SingleOption[] = createOption\n\t\t? [\n\t\t\t\t...addableOptions,\n\t\t\t\t{\n\t\t\t\t\tlabel: createOption.label,\n\t\t\t\t\tvalue: CREATE_OPTION_VALUE,\n\t\t\t\t\tsearchKey: createOption.label,\n\t\t\t\t\tcustomComponent: (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t\t\t\tcolor: COLORS.content.brand,\n\t\t\t\t\t\t\t\tfontFamily: 'Inter',\n\t\t\t\t\t\t\t\tfontSize: 14,\n\t\t\t\t\t\t\t\tfontWeight: 600,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{createOption.label}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t ]\n\t\t: addableOptions;\n\n\t// One picker instance reused by the header \"+\" and the empty-state source\n\t// buttons. `key` remounts it so a source button re-drills into its own tools\n\t// (the initial drill-in level is read once, on mount).\n\tconst pickerNode = usePicker ? (\n\t\t<MentionPicker\n\t\t\tkey={pickerSource ?? '__root__'}\n\t\t\titems={mentionItems ?? []}\n\t\t\tquery=\"\"\n\t\t\tactiveIndex={0}\n\t\t\tinitialSource={pickerSource ?? undefined}\n\t\t\tonSelect={(item) => {\n\t\t\t\tsetAdding(false);\n\t\t\t\tonAdd(String(item.id));\n\t\t\t}}\n\t\t\tonClose={() => setAdding(false)}\n\t\t\tonCreateSubAgent={\n\t\t\t\tcreateOption\n\t\t\t\t\t? () => {\n\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\tcreateOption.onSelect();\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\ttoolActions={\n\t\t\t\thasActionSources\n\t\t\t\t\t? actionSources?.map((a) => ({\n\t\t\t\t\t\t\t...a,\n\t\t\t\t\t\t\tonSelect: () => {\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\ta.onSelect();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }))\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t/>\n\t) : null;\n\n\treturn (\n\t\t<SideSection>\n\t\t\t<SideSectionHeader>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{title}</TitleSmall>\n\t\t\t\t{showAddButton && (\n\t\t\t\t\t<AddButtonWrap ref={headerPickerRef}>\n\t\t\t\t\t\t<AddIconButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-add`}\n\t\t\t\t\t\t\tonClick={handleAddClick}\n\t\t\t\t\t\t\taria-label={`Add ${title}`}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon width={20} height={20} color={COLORS.content.brand} />\n\t\t\t\t\t\t</AddIconButton>\n\t\t\t\t\t\t{usePicker && adding && pickerSource === null && (\n\t\t\t\t\t\t\t<PickerPopover data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</AddButtonWrap>\n\t\t\t\t)}\n\t\t\t</SideSectionHeader>\n\n\t\t\t{helper && (\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>{helper}</BodyCaption>\n\t\t\t)}\n\n\t\t\t{showSourceButtons ? (\n\t\t\t\t<SourcePickerAnchor ref={usePicker ? sourcePickerRef : undefined}>\n\t\t\t\t\t{/* No tools yet: one button per source (never shown once a tool exists). */}\n\t\t\t\t\t<SourceButtonRow data-test={`${dataTestPrefix}-sources`}>\n\t\t\t\t\t\t{sourceGroups?.map((g) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={g.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-source-${g.source}`}\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t// Not connected → open the connect flow instead of the tools.\n\t\t\t\t\t\t\t\t\tif (g.connected === false) {\n\t\t\t\t\t\t\t\t\t\tg.onConnect?.();\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (usePicker) {\n\t\t\t\t\t\t\t\t\t\t// Open the `@` picker drilled straight into this source's tools.\n\t\t\t\t\t\t\t\t\t\tsetPickerSource(g.source);\n\t\t\t\t\t\t\t\t\t\tsetAdding(true);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetActiveSource(g.source);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(SOURCE_ICONS[g.source], -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{g.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t{g.connected === false && (\n\t\t\t\t\t\t\t\t\t// Not connected → show \"Connect\" upfront (consistent with\n\t\t\t\t\t\t\t\t\t// the `@` picker); clicking runs the connect flow.\n\t\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.brand}>\n\t\t\t\t\t\t\t\t\t\tConnect\n\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t{/* Built-in action tools (Rest API / Handover to email) open a drawer. */}\n\t\t\t\t\t\t{actionSources?.map((a) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={a.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-action-${a.source}`}\n\t\t\t\t\t\t\t\tonClick={a.onSelect}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(a.icon, -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{a.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</SourceButtonRow>\n\n\t\t\t\t\t{/* Picker mode: clicking a source opens its tools in the `@` picker. */}\n\t\t\t\t\t{usePicker && adding && pickerSource !== null && (\n\t\t\t\t\t\t<PickerPopover $align=\"left\" data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Legacy (non-picker) mode: chosen source → its searchable tool list. */}\n\t\t\t\t\t{!usePicker && activeGroup && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Search ${activeGroup.label} tools`}\n\t\t\t\t\t\t\toptions={activeGroup.options}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetActiveSource(null);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\tonAdd(v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</SourcePickerAnchor>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t{!usePicker && adding && dropdownOptions.length > 0 && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Select ${title.toLowerCase()}`}\n\t\t\t\t\t\t\toptions={dropdownOptions}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (!v) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (v === CREATE_OPTION_VALUE) {\n\t\t\t\t\t\t\t\t\tcreateOption?.onSelect();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonAdd(v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{items.length === 0 && !adding ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.placeholder}>\n\t\t\t\t\t\t\t\t{emptyText}\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t{showEmptyCreate && createOption && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-create`}\n\t\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tLeadingIcon={PlusIcon}\n\t\t\t\t\t\t\t\t\tbuttonText={createOption.label}\n\t\t\t\t\t\t\t\t\tonClick={createOption.onSelect}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\trenderChipRows()\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t{confirmDelete && pendingDeleteId && (\n\t\t\t\t<DeleteConfirmationModal\n\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-confirm`}\n\t\t\t\t\theader={`Delete this ${confirmDelete.noun}?`}\n\t\t\t\t\tsubHeader={`Deleting this ${confirmDelete.noun} will also remove it from your instructions, wherever it's referenced.`}\n\t\t\t\t\tconfirmationText=\"Delete\"\n\t\t\t\t\tzIndex={confirmDelete.zIndex}\n\t\t\t\t\tonDeleteConfirmed={() => {\n\t\t\t\t\t\tonRemove(pendingDeleteId);\n\t\t\t\t\t\tsetPendingDeleteId(null);\n\t\t\t\t\t}}\n\t\t\t\t\tonCancelClicked={() => setPendingDeleteId(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</SideSection>\n\t);\n};\n\n// Anchors the `@`-picker popover to the header \"+\" button.\nconst AddButtonWrap = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n`;\n\n// Anchors the `@`-picker popover to the empty-state source buttons.\nconst SourcePickerAnchor = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n`;\n\n// Floating card under the trigger. Aligns to the \"+\" (right) or the source\n// buttons (left) so it stays inside the side panel.\nconst PickerPopover = styled.div<{ $align?: 'left' | 'right' }>`\n\tposition: absolute;\n\ttop: calc(100% + 4px);\n\t${(p) => (p.$align === 'left' ? 'left: 0;' : 'right: 0;')}\n\tz-index: 30;\n`;\n"],"names":["CREATE_OPTION_VALUE","SelectableListSection","title","helper","items","addableOptions","onAdd","onRemove","dataTestPrefix","emptyText","createOption","onConfigure","sourceGroups","mentionItems","actionSources","confirmDelete","adding","setAdding","useState","pendingDeleteId","setPendingDeleteId","activeSource","setActiveSource","hasSourceGroups","activeGroup","g","usePicker","headerPickerRef","useRef","sourcePickerRef","pickerSource","setPickerSource","useEffect","onDocMouseDown","e","target","onKeyDown","showAddButton","showEmptyCreate","hasActionSources","showSourceButtons","handleAddClick","v","renderChipRows","item","configure","jsxs","SelectableRow","renderSourceIcon","jsx","RowText","BodySecondary","COLORS","RowActions","RowMenuButton","EditIcon","RowActionDivider","DeleteIcon","dropdownOptions","pickerNode","MentionPicker","a","SideSection","SideSectionHeader","TitleSmall","AddButtonWrap","AddIconButton","PlusIcon","PickerPopover","BodyCaption","SourcePickerAnchor","SourceButtonRow","SourceButton","SOURCE_ICONS","Dropdown","opt","unwrapDropdownValue","Fragment","Button","DeleteConfirmationModal","styled","p"],"mappings":";;;;;;;;;;;;;;;AAiEA,MAAMA,IAAsB,sBA0DfC,KAA8D,CAAC;AAAA,EAC3E,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AACD,MAAM;AACL,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpC,CAACC,GAAiBC,CAAkB,IAAIF,EAAwB,IAAI,GAEpE,CAACG,GAAcC,CAAe,IAAIJ,EAAwB,IAAI,GAC9DK,IAAkB,CAAC,CAACX,KAAgBA,EAAa,SAAS,GAC1DY,IAAcZ,GAAc,KAAK,CAACa,MAAMA,EAAE,WAAWJ,CAAY,GAEjEK,IAAYb,MAAiB,QAI7Bc,IAAkBC,EAAuB,IAAI,GAC7CC,IAAkBD,EAAuB,IAAI,GAG7C,CAACE,GAAcC,CAAe,IAAIb,EAAwB,IAAI;AAGpE,EAAAc,GAAU,MAAM;AACf,QAAI,CAAC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AA;AAAA;AAAA,GAS5BZ,IAAgBY,EAAO;AAAA;AAAA;AAAA,GAG1B,CAACC,MAAOA,EAAE,WAAW,SAAS,aAAa,WAAY;AAAA;AAAA;"}
1
+ {"version":3,"file":"SelectableListSection.js","sources":["../../../../../src/components/agent-builder/components/SelectableListSection.tsx"],"sourcesContent":["import DeleteIcon from '@src/assets/icons/delete.svg';\nimport EditIcon from '@src/assets/icons/edit.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport { MentionItem } from '@src/editor';\nimport React, { useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { DeleteConfirmationModal } from '@src/components/states-modal';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAddIconButton,\n\tRowActionDivider,\n\tRowActions,\n\tRowMenuButton,\n\tRowText,\n\tSelectableRow,\n\tSideSection,\n\tSideSectionHeader,\n\tSourceButton,\n\tSourceButtonRow,\n} from '../AgentBuilder.styled';\nimport { ToolAction } from '../constants/tools';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tSourceIcon,\n} from '../utils/sourceIcons';\nimport { MentionPicker } from './MentionPicker';\n\nexport interface SelectableItem {\n\tid: string;\n\tlabel: string;\n\t/** Leading brand glyph (e.g. a tool's source icon). */\n\ticon?: SourceIcon;\n\t/**\n\t * When set, this row shows an edit (Configure) icon that calls this instead of\n\t * the section-level `onConfigure`. Use for rows that open their own drawer\n\t * (e.g. a configured Rest API / email-handover tool).\n\t */\n\tonConfigure?: () => void;\n}\n\n/** A tool source for the empty-state picker (Tools): a button → its searchable list. */\nexport interface SourceGroup {\n\tsource: string;\n\tlabel: string;\n\toptions: SingleOption[];\n\t/**\n\t * Integration connection state for this source. `false` = the store hasn't\n\t * connected it → clicking the source button calls {@link onConnect} instead of\n\t * opening its tool list. `true`/absent → opens normally.\n\t */\n\tconnected?: boolean;\n\t/** Open the connect flow for this source (used when `connected === false`). */\n\tonConnect?: () => void;\n}\n\n/** Sentinel value for the \"create new\" entry in the add dropdown. */\nconst CREATE_OPTION_VALUE = '__bik_create_new__';\n\ninterface SelectableListSectionProps {\n\ttitle: string;\n\thelper?: string;\n\titems: SelectableItem[];\n\t/**\n\t * Options shown in the add dropdown. Pass ALL items (not just unselected\n\t * ones) when re-picking an already-added item is allowed (e.g. to insert its\n\t * mention again) — the chip list still shows each item only once.\n\t */\n\taddableOptions: SingleOption[];\n\tonAdd: (id: string) => void;\n\tonRemove: (id: string) => void;\n\tdataTestPrefix: string;\n\temptyText: string;\n\t/**\n\t * Adds a \"create new\" entry at the top of the add dropdown (e.g. \"Create\n\t * sub-agent\"). Selecting it calls `onSelect` instead of `onAdd`.\n\t */\n\tcreateOption?: { label: string; onSelect: () => void };\n\t/**\n\t * When provided, each row shows an edit (Configure) icon next to Delete.\n\t * Omit for tools (Delete only).\n\t */\n\tonConfigure?: (id: string) => void;\n\t/**\n\t * Tool sources (e.g. Manifest / Shopify). When set, the empty state shows a\n\t * button per source; clicking one reveals a searchable dropdown of just that\n\t * source's options. Selecting calls `onAdd`. Takes precedence over the plain\n\t * `addableOptions` dropdown.\n\t */\n\tsourceGroups?: SourceGroup[];\n\t/**\n\t * When provided, the header \"+\" opens the same `@` reference picker used in the\n\t * Instructions editor (a {@link MentionPicker} popover) instead of the inline\n\t * select dropdown. Pass the items for THIS section only (tools OR sub-agents) —\n\t * the picker auto-drills into the single category. Selecting a row calls\n\t * `onAdd(id)`; the picker's \"Create new\" row (sub-agents) calls\n\t * `createOption.onSelect`.\n\t */\n\tmentionItems?: MentionItem[];\n\t/**\n\t * Built-in \"action\" tools (e.g. Rest API / Handover to email) that open a\n\t * config drawer via `onSelect` instead of adding a mention. Shown as\n\t * empty-state source buttons (only while no items exist, alongside\n\t * `sourceGroups`) AND as rows inside the `@` picker's Tools view.\n\t */\n\tactionSources?: ToolAction[];\n\t/**\n\t * When set, the row Delete icon opens a confirmation modal (instead of\n\t * removing immediately); `onRemove` runs only on confirm. `noun` fills the one\n\t * shared message template (\"Delete this <noun>?\" …); `zIndex` raises the modal\n\t * above a parent drawer. Omit to delete directly.\n\t */\n\tconfirmDelete?: { noun: string; zIndex?: number };\n}\n\nexport const SelectableListSection: React.FC<SelectableListSectionProps> = ({\n\ttitle,\n\thelper,\n\titems,\n\taddableOptions,\n\tonAdd,\n\tonRemove,\n\tdataTestPrefix,\n\temptyText,\n\tcreateOption,\n\tonConfigure,\n\tsourceGroups,\n\tmentionItems,\n\tactionSources,\n\tconfirmDelete,\n}) => {\n\tconst [adding, setAdding] = useState(false);\n\t// Row id awaiting delete confirmation (null = modal closed).\n\tconst [pendingDeleteId, setPendingDeleteId] = useState<string | null>(null);\n\t// Tools: which source's searchable list is open (null = just show the buttons).\n\tconst [activeSource, setActiveSource] = useState<string | null>(null);\n\tconst hasSourceGroups = !!sourceGroups && sourceGroups.length > 0;\n\tconst activeGroup = sourceGroups?.find((g) => g.source === activeSource);\n\t// When set, \"+\" opens the `@` MentionPicker popover instead of a select input.\n\tconst usePicker = mentionItems !== undefined;\n\t// Separate anchors for the header \"+\" popover and the empty-state source-button\n\t// popover — when empty both render at once, so a shared ref would misfire the\n\t// outside-click check (closing the header picker when a source row is clicked).\n\tconst headerPickerRef = useRef<HTMLDivElement>(null);\n\tconst sourcePickerRef = useRef<HTMLDivElement>(null);\n\t// Source (Shopify / Manifest) the empty-state button opened the picker into;\n\t// null when \"+\" opened it at the root source list.\n\tconst [pickerSource, setPickerSource] = useState<string | null>(null);\n\n\t// Dismiss the picker popover on outside click / Escape.\n\tuseEffect(() => {\n\t\tif (!usePicker || !adding) {\n\t\t\treturn;\n\t\t}\n\t\tconst onDocMouseDown = (e: MouseEvent) => {\n\t\t\tconst target = e.target as Node;\n\t\t\tif (\n\t\t\t\t!headerPickerRef.current?.contains(target) &&\n\t\t\t\t!sourcePickerRef.current?.contains(target)\n\t\t\t) {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tdocument.addEventListener('mousedown', onDocMouseDown);\n\t\tdocument.addEventListener('keydown', onKeyDown);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('mousedown', onDocMouseDown);\n\t\t\tdocument.removeEventListener('keydown', onKeyDown);\n\t\t};\n\t}, [usePicker, adding]);\n\n\t// Header \"+\" picks an EXISTING item (and, once some exist, re-creates via the\n\t// dropdown's footer row). With an empty list + a createOption the body shows a\n\t// dedicated \"Create new\" button instead, so the header \"+\" would be redundant.\n\t// In picker mode the \"+\" always shows (even empty) — for tools it sits next to\n\t// the empty-state source buttons; the create flow lives inside the picker.\n\tconst showAddButton = hasSourceGroups\n\t\t? usePicker || items.length > 0\n\t\t: usePicker ||\n\t\t addableOptions.length > 0 ||\n\t\t (!!createOption && items.length > 0);\n\t// Empty state offers a one-click \"Create new\" (sub-agents) rather than burying\n\t// it behind a single-item dropdown. In picker mode the \"+\" opens the picker\n\t// (with its own \"Create new\" row) instead, so skip the standalone button.\n\tconst showEmptyCreate =\n\t\titems.length === 0 && !!createOption && !hasSourceGroups && !usePicker;\n\tconst hasActionSources = !!actionSources && actionSources.length > 0;\n\t// Source buttons ONLY while no item is added — the tool sources (Manifest /\n\t// Shopify …) plus the built-in action tools (Rest API / Handover to email).\n\t// Once an item exists, adding more uses the header \"+\" → picker (the buttons\n\t// never come back); the action tools still live inside that picker.\n\tconst showSourceButtons =\n\t\t(hasSourceGroups || hasActionSources) && items.length === 0;\n\t// Nothing existing to pick → skip the 1-item dropdown and create directly.\n\tconst handleAddClick = () => {\n\t\tif (usePicker) {\n\t\t\t// Toggle the `@` reference-picker popover (rendered under the \"+\"), opened\n\t\t\t// at the root source list (no pre-drilled source).\n\t\t\tsetPickerSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (hasSourceGroups) {\n\t\t\tsetActiveSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (addableOptions.length === 0 && createOption) {\n\t\t\tcreateOption.onSelect();\n\t\t\treturn;\n\t\t}\n\t\tsetAdding((v) => !v);\n\t};\n\n\tconst renderChipRows = () =>\n\t\titems.map((item) => {\n\t\t\t// Per-item configure wins; otherwise fall back to the section-level one.\n\t\t\tconst configure =\n\t\t\t\titem.onConfigure ??\n\t\t\t\t(onConfigure ? () => onConfigure(item.id) : undefined);\n\t\t\treturn (\n\t\t\t\t<SelectableRow\n\t\t\t\t\tkey={item.id}\n\t\t\t\t\tdata-test={`${dataTestPrefix}-row-${item.id}`}\n\t\t\t\t>\n\t\t\t\t\t{renderSourceIcon(item.icon)}\n\t\t\t\t\t<RowText>\n\t\t\t\t\t\t<BodySecondary numberOfLines={1} color={COLORS.content.primary}>\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</RowText>\n\t\t\t\t\t<RowActions>\n\t\t\t\t\t\t{configure && (\n\t\t\t\t\t\t\t// Configurable rows (sub-agents, Rest API / email tools) get an\n\t\t\t\t\t\t\t// always-visible edit icon.\n\t\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-edit-${item.id}`}\n\t\t\t\t\t\t\t\taria-label={`Edit ${item.label}`}\n\t\t\t\t\t\t\t\tonClick={configure}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditIcon\n\t\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{configure && <RowActionDivider aria-hidden />}\n\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-${item.id}`}\n\t\t\t\t\t\t\taria-label={`Delete ${item.label}`}\n\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\tconfirmDelete ? setPendingDeleteId(item.id) : onRemove(item.id)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<DeleteIcon\n\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t</RowActions>\n\t\t\t\t</SelectableRow>\n\t\t\t);\n\t\t});\n\t// \"Create new\" is a brand-coloured footer row at the BOTTOM of the dropdown,\n\t// separated from the selectable items by a divider.\n\tconst dropdownOptions: SingleOption[] = createOption\n\t\t? [\n\t\t\t\t...addableOptions,\n\t\t\t\t{\n\t\t\t\t\tlabel: createOption.label,\n\t\t\t\t\tvalue: CREATE_OPTION_VALUE,\n\t\t\t\t\tsearchKey: createOption.label,\n\t\t\t\t\tcustomComponent: (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t\t\t\tcolor: COLORS.content.brand,\n\t\t\t\t\t\t\t\tfontFamily: 'Inter',\n\t\t\t\t\t\t\t\tfontSize: 14,\n\t\t\t\t\t\t\t\tfontWeight: 600,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{createOption.label}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t ]\n\t\t: addableOptions;\n\n\t// One picker instance reused by the header \"+\" and the empty-state source\n\t// buttons. `key` remounts it so a source button re-drills into its own tools\n\t// (the initial drill-in level is read once, on mount).\n\tconst pickerNode = usePicker ? (\n\t\t<MentionPicker\n\t\t\tkey={pickerSource ?? '__root__'}\n\t\t\titems={mentionItems ?? []}\n\t\t\tquery=\"\"\n\t\t\tactiveIndex={0}\n\t\t\tinitialSource={pickerSource ?? undefined}\n\t\t\tonSelect={(item) => {\n\t\t\t\tsetAdding(false);\n\t\t\t\tonAdd(String(item.id));\n\t\t\t}}\n\t\t\tonClose={() => setAdding(false)}\n\t\t\tonCreateSubAgent={\n\t\t\t\tcreateOption\n\t\t\t\t\t? () => {\n\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\tcreateOption.onSelect();\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\ttoolActions={\n\t\t\t\thasActionSources\n\t\t\t\t\t? actionSources?.map((a) => ({\n\t\t\t\t\t\t\t...a,\n\t\t\t\t\t\t\tonSelect: () => {\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\ta.onSelect();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }))\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\t// Gate native source rows in the picker on their connected state, derived\n\t\t\t// from the source groups (which already carry connected/onConnect). This is\n\t\t\t// what makes the \"+\" dropdown show \"Connect\" for unconnected vendors,\n\t\t\t// consistent with the empty-state buttons.\n\t\t\tintegrationStatus={Object.fromEntries(\n\t\t\t\t(sourceGroups ?? [])\n\t\t\t\t\t.filter((g) => g.connected !== undefined)\n\t\t\t\t\t.map((g) => [g.source, g.connected]),\n\t\t\t)}\n\t\t\tonConnectIntegration={(source) => {\n\t\t\t\tsetAdding(false);\n\t\t\t\tsourceGroups?.find((g) => g.source === source)?.onConnect?.();\n\t\t\t}}\n\t\t/>\n\t) : null;\n\n\treturn (\n\t\t<SideSection>\n\t\t\t<SideSectionHeader>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{title}</TitleSmall>\n\t\t\t\t{showAddButton && (\n\t\t\t\t\t<AddButtonWrap ref={headerPickerRef}>\n\t\t\t\t\t\t<AddIconButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-add`}\n\t\t\t\t\t\t\tonClick={handleAddClick}\n\t\t\t\t\t\t\taria-label={`Add ${title}`}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon width={20} height={20} color={COLORS.content.brand} />\n\t\t\t\t\t\t</AddIconButton>\n\t\t\t\t\t\t{usePicker && adding && pickerSource === null && (\n\t\t\t\t\t\t\t<PickerPopover data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</AddButtonWrap>\n\t\t\t\t)}\n\t\t\t</SideSectionHeader>\n\n\t\t\t{helper && (\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>{helper}</BodyCaption>\n\t\t\t)}\n\n\t\t\t{showSourceButtons ? (\n\t\t\t\t<SourcePickerAnchor ref={usePicker ? sourcePickerRef : undefined}>\n\t\t\t\t\t{/* No tools yet: one button per source (never shown once a tool exists). */}\n\t\t\t\t\t<SourceButtonRow data-test={`${dataTestPrefix}-sources`}>\n\t\t\t\t\t\t{sourceGroups?.map((g) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={g.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-source-${g.source}`}\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t// Not connected → open the connect flow instead of the tools.\n\t\t\t\t\t\t\t\t\tif (g.connected === false) {\n\t\t\t\t\t\t\t\t\t\tg.onConnect?.();\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (usePicker) {\n\t\t\t\t\t\t\t\t\t\t// Open the `@` picker drilled straight into this source's tools.\n\t\t\t\t\t\t\t\t\t\tsetPickerSource(g.source);\n\t\t\t\t\t\t\t\t\t\tsetAdding(true);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetActiveSource(g.source);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(SOURCE_ICONS[g.source], -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{g.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t{g.connected === false && (\n\t\t\t\t\t\t\t\t\t// Not connected → show \"Connect\" upfront (consistent with\n\t\t\t\t\t\t\t\t\t// the `@` picker); clicking runs the connect flow.\n\t\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.brand}>\n\t\t\t\t\t\t\t\t\t\tConnect\n\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t{/* Built-in action tools (Rest API / Handover to email) open a drawer. */}\n\t\t\t\t\t\t{actionSources?.map((a) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={a.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-action-${a.source}`}\n\t\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\t\ta.connected === false ? () => a.onConnect?.() : a.onSelect\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(a.icon, -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{a.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t{a.connected === false && (\n\t\t\t\t\t\t\t\t\t// Not connected → \"Connect\" upfront (consistent with the\n\t\t\t\t\t\t\t\t\t// source buttons and the `@` picker).\n\t\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.brand}>\n\t\t\t\t\t\t\t\t\t\tConnect\n\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</SourceButtonRow>\n\n\t\t\t\t\t{/* Picker mode: clicking a source opens its tools in the `@` picker. */}\n\t\t\t\t\t{usePicker && adding && pickerSource !== null && (\n\t\t\t\t\t\t<PickerPopover $align=\"left\" data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Legacy (non-picker) mode: chosen source → its searchable tool list. */}\n\t\t\t\t\t{!usePicker && activeGroup && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Search ${activeGroup.label} tools`}\n\t\t\t\t\t\t\toptions={activeGroup.options}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetActiveSource(null);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\tonAdd(v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</SourcePickerAnchor>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t{!usePicker && adding && dropdownOptions.length > 0 && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Select ${title.toLowerCase()}`}\n\t\t\t\t\t\t\toptions={dropdownOptions}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (!v) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (v === CREATE_OPTION_VALUE) {\n\t\t\t\t\t\t\t\t\tcreateOption?.onSelect();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonAdd(v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{items.length === 0 && !adding ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.placeholder}>\n\t\t\t\t\t\t\t\t{emptyText}\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t{showEmptyCreate && createOption && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-create`}\n\t\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tLeadingIcon={PlusIcon}\n\t\t\t\t\t\t\t\t\tbuttonText={createOption.label}\n\t\t\t\t\t\t\t\t\tonClick={createOption.onSelect}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\trenderChipRows()\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t{confirmDelete && pendingDeleteId && (\n\t\t\t\t<DeleteConfirmationModal\n\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-confirm`}\n\t\t\t\t\theader={`Delete this ${confirmDelete.noun}?`}\n\t\t\t\t\tsubHeader={`Deleting this ${confirmDelete.noun} will also remove it from your instructions, wherever it's referenced.`}\n\t\t\t\t\tconfirmationText=\"Delete\"\n\t\t\t\t\tzIndex={confirmDelete.zIndex}\n\t\t\t\t\tonDeleteConfirmed={() => {\n\t\t\t\t\t\tonRemove(pendingDeleteId);\n\t\t\t\t\t\tsetPendingDeleteId(null);\n\t\t\t\t\t}}\n\t\t\t\t\tonCancelClicked={() => setPendingDeleteId(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</SideSection>\n\t);\n};\n\n// Anchors the `@`-picker popover to the header \"+\" button.\nconst AddButtonWrap = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n`;\n\n// Anchors the `@`-picker popover to the empty-state source buttons.\nconst SourcePickerAnchor = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n`;\n\n// Floating card under the trigger. Aligns to the \"+\" (right) or the source\n// buttons (left) so it stays inside the side panel.\nconst PickerPopover = styled.div<{ $align?: 'left' | 'right' }>`\n\tposition: absolute;\n\ttop: calc(100% + 4px);\n\t${(p) => (p.$align === 'left' ? 'left: 0;' : 'right: 0;')}\n\tz-index: 30;\n`;\n"],"names":["CREATE_OPTION_VALUE","SelectableListSection","title","helper","items","addableOptions","onAdd","onRemove","dataTestPrefix","emptyText","createOption","onConfigure","sourceGroups","mentionItems","actionSources","confirmDelete","adding","setAdding","useState","pendingDeleteId","setPendingDeleteId","activeSource","setActiveSource","hasSourceGroups","activeGroup","g","usePicker","headerPickerRef","useRef","sourcePickerRef","pickerSource","setPickerSource","useEffect","onDocMouseDown","e","target","onKeyDown","showAddButton","showEmptyCreate","hasActionSources","showSourceButtons","handleAddClick","v","renderChipRows","item","configure","jsxs","SelectableRow","renderSourceIcon","jsx","RowText","BodySecondary","COLORS","RowActions","RowMenuButton","EditIcon","RowActionDivider","DeleteIcon","dropdownOptions","pickerNode","MentionPicker","a","source","SideSection","SideSectionHeader","TitleSmall","AddButtonWrap","AddIconButton","PlusIcon","PickerPopover","BodyCaption","SourcePickerAnchor","SourceButtonRow","SourceButton","SOURCE_ICONS","Dropdown","opt","unwrapDropdownValue","Fragment","Button","DeleteConfirmationModal","styled","p"],"mappings":";;;;;;;;;;;;;;;AAiEA,MAAMA,IAAsB,sBA0DfC,KAA8D,CAAC;AAAA,EAC3E,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AACD,MAAM;AACL,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpC,CAACC,GAAiBC,CAAkB,IAAIF,EAAwB,IAAI,GAEpE,CAACG,GAAcC,CAAe,IAAIJ,EAAwB,IAAI,GAC9DK,IAAkB,CAAC,CAACX,KAAgBA,EAAa,SAAS,GAC1DY,IAAcZ,GAAc,KAAK,CAACa,MAAMA,EAAE,WAAWJ,CAAY,GAEjEK,IAAYb,MAAiB,QAI7Bc,IAAkBC,EAAuB,IAAI,GAC7CC,IAAkBD,EAAuB,IAAI,GAG7C,CAACE,GAAcC,CAAe,IAAIb,EAAwB,IAAI;AAGpE,EAAAc,GAAU,MAAM;AACf,QAAI,CAACN,KAAa,CAACV;AAClB;AAED,UAAMiB,IAAiB,CAACC,MAAkB;AACzC,YAAMC,IAASD,EAAE;AACjB,MACC,CAACP,EAAgB,SAAS,SAASQ,CAAM,KACzC,CAACN,EAAgB,SAAS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A,EAAc,IAAI;AAAA,QAC9C,kBAAiB;AAAA,QACjB,QAAQA,EAAc;AAAA,QACtB,mBAAmB,MAAM;AACxB,UAAAR,EAASY,CAAe,GACxBC,EAAmB,IAAI;AAAA,QACxB;AAAA,QACA,iBAAiB,MAAMA,EAAmB,IAAI;AAAA,MAAA;AAAA,IAAA;AAAA,EAC/C,GAEF;AAEF,GAGM8C,KAAgBe,EAAO;AAAA;AAAA;AAAA,GAMvBV,KAAqBU,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA,GAS5BZ,IAAgBY,EAAO;AAAA;AAAA;AAAA,GAG1B,CAACC,MAAOA,EAAE,WAAW,SAAS,aAAa,WAAY;AAAA;AAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.840-tools-beta.2",
3
+ "version": "0.0.840-tools-beta.4",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",