@flexkit/studio 0.2.30 → 0.2.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/{chat-page-5HRMQQRO.js → chat-page-7UB3BMBF.js} +3 -3
  2. package/dist/{chat-page-5HRMQQRO.js.map → chat-page-7UB3BMBF.js.map} +1 -1
  3. package/dist/{chunk-K2VO74FW.js → chunk-2NQ2RZ2M.js} +3 -3
  4. package/dist/{chunk-K2VO74FW.js.map → chunk-2NQ2RZ2M.js.map} +1 -1
  5. package/dist/{chunk-5D6JCGLZ.js → chunk-5AJXR47U.js} +2 -2
  6. package/dist/{chunk-5D6JCGLZ.js.map → chunk-5AJXR47U.js.map} +1 -1
  7. package/dist/{chunk-EC3SJ4NQ.js → chunk-AY2RXJWS.js} +2 -2
  8. package/dist/{chunk-EC3SJ4NQ.js.map → chunk-AY2RXJWS.js.map} +1 -1
  9. package/dist/{chunk-MNFVAW2B.js → chunk-GSGPULRL.js} +2 -2
  10. package/dist/{chunk-MNFVAW2B.js.map → chunk-GSGPULRL.js.map} +1 -1
  11. package/dist/chunk-HZOD2HOF.js +3 -0
  12. package/dist/chunk-HZOD2HOF.js.map +1 -0
  13. package/dist/{chunk-WJRC5CQQ.js → chunk-JAPZBEBZ.js} +9 -9
  14. package/dist/chunk-JAPZBEBZ.js.map +1 -0
  15. package/dist/{chunk-6X54ZCSO.js → chunk-JWJJZVP3.js} +2 -2
  16. package/dist/{chunk-6X54ZCSO.js.map → chunk-JWJJZVP3.js.map} +1 -1
  17. package/dist/{chunk-BQWW2Q6B.js → chunk-KR27GOH6.js} +3 -3
  18. package/dist/{chunk-BQWW2Q6B.js.map → chunk-KR27GOH6.js.map} +1 -1
  19. package/dist/{chunk-A6UGAPMZ.js → chunk-MRHZN4G4.js} +2 -2
  20. package/dist/{chunk-A6UGAPMZ.js.map → chunk-MRHZN4G4.js.map} +1 -1
  21. package/dist/{chunk-WPNV6WNQ.js → chunk-NNISUDZX.js} +3 -3
  22. package/dist/{chunk-WPNV6WNQ.js.map → chunk-NNISUDZX.js.map} +1 -1
  23. package/dist/{chunk-CR3UGX4V.js → chunk-ONB3FWK5.js} +2 -2
  24. package/dist/{chunk-CR3UGX4V.js.map → chunk-ONB3FWK5.js.map} +1 -1
  25. package/dist/{chunk-E4RN4USU.js → chunk-R2O4WC3H.js} +3 -3
  26. package/dist/{chunk-E4RN4USU.js.map → chunk-R2O4WC3H.js.map} +1 -1
  27. package/dist/{chunk-LBFL34FM.js → chunk-XV7U33XQ.js} +3 -3
  28. package/dist/{chunk-LBFL34FM.js.map → chunk-XV7U33XQ.js.map} +1 -1
  29. package/dist/{entry-FXAA2IGV.js → entry-CA2QAEHN.js} +2 -2
  30. package/dist/{entry-FXAA2IGV.js.map → entry-CA2QAEHN.js.map} +1 -1
  31. package/dist/index.js +2 -2
  32. package/dist/{list-TLIH4DCX.js → list-Q2KAEJ26.js} +3 -3
  33. package/dist/{list-TLIH4DCX.js.map → list-Q2KAEJ26.js.map} +1 -1
  34. package/dist/list-UMMVRYVD.js +2 -0
  35. package/dist/list-UMMVRYVD.js.map +1 -0
  36. package/dist/pages-KZ66JVNU.js +5 -0
  37. package/dist/pages-KZ66JVNU.js.map +1 -0
  38. package/dist/{plugin-pages-Q5KRARJD.js → plugin-pages-SR2WSUKZ.js} +2 -2
  39. package/dist/{plugin-pages-Q5KRARJD.js.map → plugin-pages-SR2WSUKZ.js.map} +1 -1
  40. package/dist/record-links-3WZGSVFU.js +2 -0
  41. package/dist/{record-links-DSRYOOM5.js.map → record-links-3WZGSVFU.js.map} +1 -1
  42. package/dist/{root-IKO3UPTJ.js → root-2VBLPRG7.js} +2 -2
  43. package/dist/{root-IKO3UPTJ.js.map → root-2VBLPRG7.js.map} +1 -1
  44. package/dist/{root-IJKEEUBR.js → root-6QTQUYK4.js} +2 -2
  45. package/dist/{root-IJKEEUBR.js.map → root-6QTQUYK4.js.map} +1 -1
  46. package/dist/{root-TERO3GWT.js → root-7BUVDOMV.js} +3 -3
  47. package/dist/{root-TERO3GWT.js.map → root-7BUVDOMV.js.map} +1 -1
  48. package/dist/{root-2QWOQ2AH.js → root-FZLKYL5W.js} +3 -3
  49. package/dist/{root-2QWOQ2AH.js.map → root-FZLKYL5W.js.map} +1 -1
  50. package/dist/{root-NW5QG7W5.js → root-LFJ5BQSY.js} +3 -3
  51. package/dist/{root-NW5QG7W5.js.map → root-LFJ5BQSY.js.map} +1 -1
  52. package/dist/{root-IMTXHNCZ.js → root-OXS3QQX6.js} +2 -2
  53. package/dist/{root-IMTXHNCZ.js.map → root-OXS3QQX6.js.map} +1 -1
  54. package/dist/{search-THZV66M5.js → search-AZK3Q2KX.js} +2 -2
  55. package/dist/{search-THZV66M5.js.map → search-AZK3Q2KX.js.map} +1 -1
  56. package/dist/{skills-pages-D2QSG6WT.js → skills-pages-7IYBJ4QI.js} +2 -2
  57. package/dist/{skills-pages-D2QSG6WT.js.map → skills-pages-7IYBJ4QI.js.map} +1 -1
  58. package/dist/{source-AH4O5WGE.js → source-4BP5PJ2N.js} +2 -2
  59. package/dist/{source-AH4O5WGE.js.map → source-4BP5PJ2N.js.map} +1 -1
  60. package/package.json +1 -1
  61. package/dist/chunk-4TQ25SVS.js +0 -3
  62. package/dist/chunk-4TQ25SVS.js.map +0 -1
  63. package/dist/chunk-WJRC5CQQ.js.map +0 -1
  64. package/dist/list-DWSTP7CW.js +0 -2
  65. package/dist/list-DWSTP7CW.js.map +0 -1
  66. package/dist/pages-IXHYEUBL.js +0 -5
  67. package/dist/pages-IXHYEUBL.js.map +0 -1
  68. package/dist/record-links-DSRYOOM5.js +0 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apps/knowledge/list.tsx"],"names":["KNOWLEDGE_PAGE_SIZE","LIST_POLL_INTERVAL_MS","SEARCH_DEBOUNCE_MS","useDebouncedValue","value","delayMs","debounced","setDebounced","useState","useEffect","timer","EMPTY_BY_FILTER","KnowledgeListSkeleton","viewMode","ids","jsxs","GRID_CLASSES","jsx","id","Skeleton","useKnowledgeUploads","api","onRegistered","pending","setPending","queueRef","useRef","addFiles","files","file","problem","getKnowledgeFileProblem","toast","upload","current","result","announceRegistered","error","describeApiError","entry","AddUrlDialog","onOpenChange","open","setValue","title","setTitle","setError","isSubmitting","setIsSubmitting","close","handleSubmit","event","parsed","parseKnowledgeUrl","submitError","Dialog","next","DialogContent","DialogHeader","DialogTitle","DialogDescription","Label","Input","KNOWLEDGE_MAX_TITLE_LENGTH","DialogFooter","Button","LoaderCircle","LinkIcon","formatAdded","iso","format","HiddenBadge","Badge","ContentMatchBadge","handleRowClick","target","SourceListRow","source","actions","status","summarizeKnowledgeStatus","detailClass","TableRow","TableCell","KnowledgeTypeIcon","Link","StatusBadge","getKnowledgeKindLabel","formatFileSize","Tooltip","TooltipTrigger","TooltipContent","formatDistance","SourceActionsMenu","SourceTable","sources","Table","TableHeader","TableHead","TableBody","SourcePreview","preview","SourceCard","meta","SourceGrid","ListHeader","SidebarTrigger","Separator","List","projectId","useProjectKnowledge","navigate","useNavigate","canMutate","useCanMutate","isViewing","useIsViewing","useKnowledgeStatusFilter","search","setSearch","query","setViewMode","getStoredKnowledgeViewMode","isUrlDialogOpen","setIsUrlDialogOpen","fileInputRef","searchInputRef","isBusy","setIsBusy","getSourcesKey","pageIndex","previousPage","knowledgePaths","pages","isLoading","mutate","setSize","size","useSWRInfinite","fetcher","useMemo","page","total","hasMore","isLoadingMore","isInitialLoading","mutateRef","isKnowledgeSourceBusy","setSizeRef","PageMessage","handleFilesPicked","emptyMessage","KNOWLEDGE_FORMATS_LABEL","removed","content","Alert","AlertDescription","AssetDropZone","SearchIcon","XIcon","ToggleGroup","setStoredKnowledgeViewMode","ToggleGroupItem","ListIcon","LayoutGridIcon","PermissionTooltip","UploadIcon","KNOWLEDGE_ACCEPT","InfiniteScrollSentinel"],"mappings":"4rCAoEA,IAAMA,EAAAA,CAAsB,EAAA,CACtBC,EAAAA,CAAwB,GAAA,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iD,YAAAA,CAAA,CAAa,UAAU,2BAAA,CAA4B,CAAA,CAAE,YAAA,CAC3CjC,CAAAA,CAAO,IAAA,CAAK,QAAA,CAAA,CAAA,CAF+BA,CAAAA,CAAO,EAG/D,CACD,CAAA,CACH,CAAA,CACE,IAAA,CACHyH,CAAAA,CACAX,EAAAA,EAAW,CAACC,EAAAA,CACX/H,GAAAA,CAACuJ,CAAAA,CAAA,CAAuB,SAAA,CAAW,IAAG,CAAQhC,CAAAA,CAAStG,CAAAA,EAAYA,CAAAA,CAAU,CAAC,EAAA,CAAA,CAAG,CAAA,CAC/E,IAAA,CACH8G,EAAAA,CACCjI,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,gGAAA,CACb,QAAA,CAAA,CAAAE,GAAAA,CAACiD,YAAAA,CAAA,CAAa,SAAA,CAAU,2BAAA,CAA4B,CAAA,CACpDjD,GAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,2BAAA,CAAyB,CAAA,CAAA,CACjC,CAAA,CACE,IAAA,CAAA,CACN,CAAA,CACF,CAAA,CACF,CAAA,CACAA,GAAAA,CAACuB,EAAAA,CAAA,CACC,GAAA,CAAKnB,CAAAA,CACL,IAAA,CAAMsG,GAAAA,CACN,YAAA,CAAcC,CAAAA,CACd,YAAA,CAAc,IAAG,CAAQW,CAAAA,GAAO,CAAA,CAClC,GACF,CAEJ","file":"list-TLIH4DCX.js","sourcesContent":["import type { ChangeEvent, FormEvent, JSX, MouseEvent } from 'react';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { format, formatDistance } from 'date-fns';\nimport { LayoutGridIcon, LinkIcon, ListIcon, LoaderCircle, SearchIcon, UploadIcon, XIcon } from 'lucide-react';\nimport { Link, useNavigate } from 'react-router-dom';\nimport useSWRInfinite from 'swr/infinite';\nimport { useIsViewing } from '../../core/apps/app-active';\nimport { useCanMutate } from '../../core/permissions';\nimport {\n Alert,\n AlertDescription,\n Badge,\n Button,\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n ToggleGroup,\n ToggleGroupItem,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Input,\n Label,\n PermissionTooltip,\n Separator,\n SidebarTrigger,\n Skeleton,\n toast,\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from '../../ui';\nimport { AssetDropZone } from '../asset-manager/data-grid/asset-drop-zone';\nimport { fetcher, knowledgePaths, type KnowledgeApi } from './api';\nimport {\n formatFileSize,\n getKnowledgeFileProblem,\n getKnowledgeKindLabel,\n getStoredKnowledgeViewMode,\n isKnowledgeSourceBusy,\n KNOWLEDGE_ACCEPT,\n KNOWLEDGE_FORMATS_LABEL,\n KNOWLEDGE_MAX_TITLE_LENGTH,\n parseKnowledgeUrl,\n setStoredKnowledgeViewMode,\n summarizeKnowledgeStatus,\n type KnowledgeSource,\n type KnowledgeSourcesList,\n type KnowledgeViewMode,\n} from './knowledge';\nimport {\n announceRegistered,\n describeApiError,\n InfiniteScrollSentinel,\n KnowledgeTypeIcon,\n PageMessage,\n SourceActionsMenu,\n StatusBadge,\n useProjectKnowledge,\n} from './shared';\nimport { useKnowledgeStatusFilter } from './sidebar';\n\nconst KNOWLEDGE_PAGE_SIZE = 25;\nconst LIST_POLL_INTERVAL_MS = 3_000;\n/** Typing pauses this long before the list asks the platform; each ask now searches the documents' text too. */\nconst SEARCH_DEBOUNCE_MS = 250;\n\nfunction useDebouncedValue<T>(value: T, delayMs: number): T {\n const [debounced, setDebounced] = useState(value);\n\n useEffect(() => {\n const timer = setTimeout(() => setDebounced(value), delayMs);\n\n return () => clearTimeout(timer);\n }, [delayMs, value]);\n\n return debounced;\n}\n\nconst EMPTY_BY_FILTER = {\n failed: 'No document failed to index.',\n processing: 'No document is being indexed right now.',\n ready: 'No document is ready yet.',\n};\n\nfunction KnowledgeListSkeleton({ viewMode }: { viewMode: KnowledgeViewMode }): JSX.Element {\n const ids = ['a', 'b', 'c', 'd', 'e', 'f'];\n\n if (viewMode === 'grid') {\n return (\n <div aria-busy=\"true\" className={GRID_CLASSES}>\n <span className=\"fk:sr-only\">Loading documents</span>\n {ids.map((id) => (\n <div className=\"fk:flex fk:flex-col fk:gap-3 fk:rounded-xl fk:border fk:p-3 fk:corner-squircle\" key={id}>\n <span className=\"fk:flex fk:items-center fk:gap-2\">\n <Skeleton className=\"fk:size-6 fk:rounded-md\" />\n <Skeleton className=\"fk:h-4 fk:flex-1\" />\n </span>\n <Skeleton className=\"fk:aspect-[4/3] fk:w-full fk:rounded-lg\" />\n </div>\n ))}\n </div>\n );\n }\n\n return (\n <div aria-busy=\"true\" className=\"fk:flex fk:flex-col\">\n <span className=\"fk:sr-only\">Loading documents</span>\n {ids.map((id) => (\n <div className=\"fk:flex fk:h-12 fk:items-center fk:gap-3 fk:border-b fk:px-3\" key={id}>\n <Skeleton className=\"fk:size-6 fk:shrink-0 fk:rounded-md\" />\n <Skeleton className=\"fk:h-4 fk:w-1/3\" />\n <Skeleton className=\"fk:ml-auto fk:h-4 fk:w-16\" />\n <Skeleton className=\"fk:hidden fk:h-4 fk:w-24 fk:md:block\" />\n </div>\n ))}\n </div>\n );\n}\n\ninterface PendingUpload {\n id: string;\n name: string;\n}\n\n/** Runs file uploads one after another and reports each outcome; the list revalidates after every registration. */\nfunction useKnowledgeUploads(\n api: KnowledgeApi | null,\n onRegistered: () => void\n): {\n addFiles: (_files: File[]) => void;\n pending: PendingUpload[];\n} {\n const [pending, setPending] = useState<PendingUpload[]>([]);\n const queueRef = useRef<Promise<void>>(Promise.resolve());\n\n function addFiles(files: File[]): void {\n if (!api) {\n return;\n }\n\n for (const file of files) {\n const problem = getKnowledgeFileProblem(file);\n\n if (problem) {\n toast.error(problem);\n\n continue;\n }\n\n const upload: PendingUpload = {\n id: `${file.name}-${String(Date.now())}-${String(Math.random())}`,\n name: file.name,\n };\n\n setPending((current) => [...current, upload]);\n queueRef.current = queueRef.current\n .then(async () => {\n try {\n const result = await api.addFile(file);\n\n announceRegistered(result, file.name);\n onRegistered();\n } catch (error) {\n toast.error(describeApiError(error, `${file.name} could not be added.`));\n } finally {\n setPending((current) => current.filter((entry) => entry.id !== upload.id));\n }\n })\n .catch(() => undefined);\n }\n }\n\n return { addFiles, pending };\n}\n\nfunction AddUrlDialog({\n api,\n onOpenChange,\n onRegistered,\n open,\n}: {\n api: KnowledgeApi;\n onOpenChange: (_open: boolean) => void;\n onRegistered: () => void;\n open: boolean;\n}): JSX.Element {\n const [value, setValue] = useState('');\n const [title, setTitle] = useState('');\n const [error, setError] = useState('');\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n function close(): void {\n onOpenChange(false);\n setValue('');\n setTitle('');\n setError('');\n }\n\n async function handleSubmit(event: FormEvent<HTMLFormElement>): Promise<void> {\n event.preventDefault();\n\n const parsed = parseKnowledgeUrl(value);\n\n if ('error' in parsed) {\n setError(parsed.error);\n\n return;\n }\n\n setIsSubmitting(true);\n setError('');\n\n try {\n const result = await api.addUrl({ title: title.trim() || undefined, url: parsed.url });\n\n announceRegistered(result, parsed.url);\n onRegistered();\n close();\n } catch (submitError) {\n setError(describeApiError(submitError, 'The page could not be added.'));\n } finally {\n setIsSubmitting(false);\n }\n }\n\n return (\n <Dialog open={open} onOpenChange={(next) => (next ? onOpenChange(true) : close())}>\n <DialogContent>\n <form className=\"fk:flex fk:flex-col fk:gap-4\" onSubmit={(event) => void handleSubmit(event)}>\n <DialogHeader>\n <DialogTitle>Add a web page</DialogTitle>\n <DialogDescription>\n The page is fetched and indexed now, and again whenever you re-index it. Only public pages work.\n </DialogDescription>\n </DialogHeader>\n <div className=\"fk:flex fk:flex-col fk:gap-1.5\">\n <Label htmlFor=\"knowledge-url\">Address</Label>\n <Input\n autoFocus\n id=\"knowledge-url\"\n inputMode=\"url\"\n placeholder=\"https://example.com/help/returns\"\n value={value}\n onChange={(event) => {\n setValue(event.target.value);\n setError('');\n }}\n />\n </div>\n <div className=\"fk:flex fk:flex-col fk:gap-1.5\">\n <Label htmlFor=\"knowledge-url-title\">Title (optional)</Label>\n <Input\n id=\"knowledge-url-title\"\n maxLength={KNOWLEDGE_MAX_TITLE_LENGTH}\n placeholder=\"Defaults to the page address\"\n value={title}\n onChange={(event) => setTitle(event.target.value)}\n />\n </div>\n {error ? <p className=\"fk:text-sm fk:text-destructive\">{error}</p> : null}\n <DialogFooter>\n <Button disabled={isSubmitting} size=\"sm\" type=\"button\" variant=\"outline\" onClick={close}>\n Cancel\n </Button>\n <Button disabled={isSubmitting || !value.trim()} size=\"sm\" type=\"submit\">\n {isSubmitting ? (\n <LoaderCircle className=\"fk:size-4 fk:animate-spin\" />\n ) : (\n <LinkIcon className=\"fk:size-4\" />\n )}\n Add page\n </Button>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n );\n}\n\nconst GRID_CLASSES = 'fk:grid fk:grid-cols-[repeat(auto-fill,minmax(14rem,1fr))] fk:gap-4';\n\nfunction formatAdded(iso: string): string {\n return format(new Date(iso), 'MMM d, yyyy');\n}\n\nfunction HiddenBadge(): JSX.Element {\n return (\n <Badge className=\"fk:shrink-0 fk:corner-squircle\" variant=\"outline\">\n Hidden from agent\n </Badge>\n );\n}\n\n/** A search hit whose title does not carry the words: the text inside does. */\nfunction ContentMatchBadge(): JSX.Element {\n return (\n <Badge className=\"fk:shrink-0 fk:corner-squircle\" data-knowledge-content-match variant=\"secondary\">\n In content\n </Badge>\n );\n}\n\ninterface SourceActions {\n onOpen: (_source: KnowledgeSource) => void;\n onRemoved: (_source: KnowledgeSource) => void;\n}\n\ntype SourceItemProps = SourceActions & { source: KnowledgeSource };\n\n/**\n * A plain click on the row opens the document. Clicks that bubbled up from\n * a portal (the menu, the removal dialog), modified clicks (the title link\n * handles new tabs itself) and clicks on the row's own controls are not.\n */\nfunction handleRowClick(event: MouseEvent<HTMLElement>, open: () => void): void {\n const target = event.target as Node;\n\n if (\n event.defaultPrevented ||\n event.button !== 0 ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey ||\n !event.currentTarget.contains(target) ||\n (target as Element).closest('a, button')\n ) {\n return;\n }\n\n open();\n}\n\n/**\n * One line of the list: the type mark, the title as a real link (so it can\n * be opened in a new tab), then the status and facts in columns, like a file\n * manager. The whole row is clickable for the mouse; the link carries the\n * keyboard and assistive tech.\n */\nfunction SourceListRow({ source, ...actions }: SourceItemProps): JSX.Element {\n const status = summarizeKnowledgeStatus(source);\n // What went wrong, or what is happening, matters at every width; the passage count can wait for a wide one.\n const detailClass = status.tone === 'ready' ? 'fk:hidden fk:xl:inline' : 'fk:hidden fk:md:inline';\n\n return (\n <TableRow\n className=\"fk:h-12 fk:cursor-pointer\"\n data-knowledge-row\n onClick={(event) => handleRowClick(event, () => actions.onOpen(source))}\n >\n <TableCell className=\"fk:max-w-0 fk:w-full\">\n <span className=\"fk:flex fk:min-w-0 fk:items-center fk:gap-3\">\n <KnowledgeTypeIcon source={source} />\n <Link\n className=\"fk:truncate fk:text-sm fk:font-medium fk:hover:underline fk:underline-offset-2 fk:focus-visible:outline-none fk:focus-visible:underline\"\n to={source.id}\n >\n {source.title}\n </Link>\n {source.matchedIn === 'content' ? <ContentMatchBadge /> : null}\n {!source.agentVisible ? <HiddenBadge /> : null}\n </span>\n </TableCell>\n <TableCell className=\"fk:whitespace-nowrap\">\n <span className=\"fk:flex fk:items-center fk:gap-2\">\n <StatusBadge label={status.label} tone={status.tone} />\n <span\n className={`${detailClass} fk:max-w-64 fk:truncate fk:text-xs fk:text-muted-foreground`}\n title={status.detail}\n >\n {status.detail}\n </span>\n </span>\n </TableCell>\n <TableCell className=\"fk:hidden fk:whitespace-nowrap fk:text-muted-foreground fk:md:table-cell\">\n {getKnowledgeKindLabel(source)}\n </TableCell>\n <TableCell className=\"fk:hidden fk:whitespace-nowrap fk:text-right fk:tabular-nums fk:text-muted-foreground fk:md:table-cell\">\n {source.size === null ? '—' : formatFileSize(source.size)}\n </TableCell>\n <TableCell className=\"fk:hidden fk:whitespace-nowrap fk:text-muted-foreground fk:sm:table-cell\">\n <Tooltip>\n <TooltipTrigger asChild>\n <span>{formatAdded(source.createdAt)}</span>\n </TooltipTrigger>\n <TooltipContent>\n Updated {formatDistance(new Date(source.updatedAt), new Date(), { addSuffix: true })}\n </TooltipContent>\n </Tooltip>\n </TableCell>\n <TableCell className=\"fk:w-12 fk:pr-2 fk:text-right\">\n <SourceActionsMenu\n source={source}\n onOpen={() => actions.onOpen(source)}\n onRemoved={() => actions.onRemoved(source)}\n />\n </TableCell>\n </TableRow>\n );\n}\n\nfunction SourceTable({ sources, ...actions }: SourceActions & { sources: KnowledgeSource[] }): JSX.Element {\n return (\n <Table data-knowledge-list>\n <TableHeader>\n <TableRow className=\"fk:hover:bg-transparent\">\n <TableHead>Name</TableHead>\n <TableHead>Status</TableHead>\n <TableHead className=\"fk:hidden fk:md:table-cell\">Type</TableHead>\n <TableHead className=\"fk:hidden fk:text-right fk:md:table-cell\">Size</TableHead>\n <TableHead className=\"fk:hidden fk:sm:table-cell\">Added</TableHead>\n <TableHead className=\"fk:w-12\">\n <span className=\"fk:sr-only\">Actions</span>\n </TableHead>\n </TableRow>\n </TableHeader>\n <TableBody>\n {sources.map((source) => (\n <SourceListRow key={source.id} source={source} {...actions} />\n ))}\n </TableBody>\n </Table>\n );\n}\n\n/**\n * The card's thumbnail: the opening text of the document laid out like a\n * small page, the way a file manager shows the first page. Documents still\n * indexing, or without text, show their type mark instead.\n */\nfunction SourcePreview({ source }: { source: KnowledgeSource }): JSX.Element {\n const preview = source.preview?.trim();\n\n return (\n <div className=\"fk:relative fk:aspect-[4/3] fk:overflow-hidden fk:rounded-lg fk:bg-muted fk:corner-squircle\">\n {preview ? (\n <div\n aria-hidden\n className=\"fk:absolute fk:inset-x-4 fk:top-3 fk:bottom-0 fk:overflow-hidden fk:rounded-t-sm fk:bg-background fk:px-3 fk:pt-3 fk:shadow-sm\"\n >\n <p className=\"fk:whitespace-pre-line fk:text-[9px] fk:leading-[1.45] fk:text-foreground/80 fk:select-none\">\n {preview}\n </p>\n <span className=\"fk:pointer-events-none fk:absolute fk:inset-x-0 fk:bottom-0 fk:h-10 fk:bg-gradient-to-t fk:from-background fk:to-transparent\" />\n </div>\n ) : (\n <div className=\"fk:flex fk:h-full fk:items-center fk:justify-center\">\n <KnowledgeTypeIcon size={56} source={source} />\n </div>\n )}\n </div>\n );\n}\n\nfunction SourceCard({ source, ...actions }: SourceItemProps): JSX.Element {\n const status = summarizeKnowledgeStatus(source);\n const meta = [getKnowledgeKindLabel(source)];\n\n if (source.size !== null) {\n meta.push(formatFileSize(source.size));\n }\n\n meta.push(status.detail);\n\n // A link laid over the card opens the document (so it can be opened in a\n // new tab too); the menu button sits above it. The title tooltip lives on\n // the card itself, which does receive the pointer.\n return (\n <div\n className=\"fk:relative fk:flex fk:min-w-0 fk:flex-col fk:gap-3 fk:rounded-xl fk:border fk:bg-card fk:p-3 fk:transition-colors fk:hover:bg-accent/60 fk:has-[>a:focus-visible]:ring-2 fk:has-[>a:focus-visible]:ring-ring fk:corner-squircle\"\n data-knowledge-card\n title={source.title}\n >\n <Link\n aria-label={`Open ${source.title}`}\n className=\"fk:absolute fk:inset-0 fk:rounded-xl fk:focus-visible:outline-none fk:corner-squircle\"\n to={source.id}\n />\n <span className=\"fk:pointer-events-none fk:relative fk:flex fk:min-w-0 fk:items-center fk:gap-2\">\n <KnowledgeTypeIcon source={source} />\n <span className=\"fk:min-w-0 fk:flex-1 fk:truncate fk:text-sm fk:font-medium\">{source.title}</span>\n <span className=\"fk:pointer-events-auto fk:-my-1 fk:-mr-1.5\">\n <SourceActionsMenu\n source={source}\n onOpen={() => actions.onOpen(source)}\n onRemoved={() => actions.onRemoved(source)}\n />\n </span>\n </span>\n <span className=\"fk:pointer-events-none fk:relative\">\n <SourcePreview source={source} />\n </span>\n <span className=\"fk:pointer-events-none fk:relative fk:flex fk:min-w-0 fk:items-center fk:gap-2\">\n <StatusBadge label={status.label} tone={status.tone} />\n <span className=\"fk:min-w-0 fk:flex-1 fk:truncate fk:text-xs fk:text-muted-foreground\">{meta.join(' · ')}</span>\n {source.matchedIn === 'content' ? <ContentMatchBadge /> : null}\n {!source.agentVisible ? <HiddenBadge /> : null}\n </span>\n </div>\n );\n}\n\nfunction SourceGrid({ sources, ...actions }: SourceActions & { sources: KnowledgeSource[] }): JSX.Element {\n return (\n <div className={GRID_CLASSES} data-knowledge-grid>\n {sources.map((source) => (\n <SourceCard key={source.id} source={source} {...actions} />\n ))}\n </div>\n );\n}\n\nfunction ListHeader(): JSX.Element {\n return (\n <div className=\"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2 fk:pr-4\">\n <Tooltip>\n <TooltipTrigger asChild>\n <SidebarTrigger className=\"fk:-ml-1 fk:h-4 fk:w-4\" />\n </TooltipTrigger>\n <TooltipContent>Toggle Sidebar</TooltipContent>\n </Tooltip>\n <Separator orientation=\"vertical\" className=\"fk:h-4\" />\n <h1 className=\"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight\">Knowledge</h1>\n </div>\n );\n}\n\nexport function List(): JSX.Element {\n const { api, projectId } = useProjectKnowledge();\n const navigate = useNavigate();\n const canMutate = useCanMutate();\n const isViewing = useIsViewing();\n const status = useKnowledgeStatusFilter();\n const [search, setSearch] = useState('');\n const query = useDebouncedValue(search.trim(), SEARCH_DEBOUNCE_MS);\n const [viewMode, setViewMode] = useState<KnowledgeViewMode>(() => getStoredKnowledgeViewMode());\n const [isUrlDialogOpen, setIsUrlDialogOpen] = useState(false);\n const fileInputRef = useRef<HTMLInputElement>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const [isBusy, setIsBusy] = useState(false);\n const getSourcesKey = (pageIndex: number, previousPage: KnowledgeSourcesList | null): string | null => {\n if (!projectId || (previousPage && !previousPage.hasMore)) {\n return null;\n }\n\n return knowledgePaths(projectId).sources({\n limit: KNOWLEDGE_PAGE_SIZE,\n offset: pageIndex * KNOWLEDGE_PAGE_SIZE,\n search: query || undefined,\n status,\n });\n };\n const {\n data: pages,\n isLoading,\n mutate,\n setSize,\n size,\n } = useSWRInfinite<KnowledgeSourcesList>(getSourcesKey, fetcher, {\n // Rows that are still indexing change on their own; poll while one is in flight and the tab is in front.\n refreshInterval: isViewing && isBusy ? LIST_POLL_INTERVAL_MS : 0,\n });\n const sources = useMemo(() => pages?.flatMap((page) => page.sources) ?? [], [pages]);\n const total = pages?.[0]?.count ?? 0;\n const hasMore = pages?.[pages.length - 1]?.hasMore ?? false;\n const isLoadingMore = pages !== undefined && size > pages.length;\n const isInitialLoading = isLoading && sources.length === 0;\n const { addFiles, pending } = useKnowledgeUploads(api, () => void mutate());\n const mutateRef = useRef(mutate);\n\n mutateRef.current = mutate;\n\n // Coming back from a document page must show what changed there. The\n // infinite hook keeps serving its cached pages otherwise, whatever the\n // mount options.\n useEffect(() => {\n void mutateRef.current();\n }, []);\n\n useEffect(() => {\n setIsBusy(sources.some((source) => isKnowledgeSourceBusy(source)));\n }, [sources]);\n\n // A new search starts from its first page.\n const setSizeRef = useRef(setSize);\n\n setSizeRef.current = setSize;\n\n useEffect(() => {\n void setSizeRef.current(1);\n }, [query]);\n\n if (!projectId || !api) {\n return <PageMessage>Select a project to manage its knowledge.</PageMessage>;\n }\n\n function handleFilesPicked(event: ChangeEvent<HTMLInputElement>): void {\n const files = Array.from(event.target.files ?? []);\n\n event.target.value = '';\n addFiles(files);\n }\n\n let emptyMessage = `No documents yet. Upload ${KNOWLEDGE_FORMATS_LABEL} files, or add a public web page, and the agent will search and cite them.`;\n\n if (query) {\n emptyMessage = 'No document title or content matches your search.';\n } else if (status) {\n emptyMessage = EMPTY_BY_FILTER[status];\n }\n\n const actions: SourceActions = {\n onOpen: (source) => void navigate(source.id),\n // Drop the row at once, then let this hook refetch its pages: the global\n // list invalidation clears other caches but never revalidates an infinite hook.\n onRemoved: (removed) =>\n void mutate(\n (current) =>\n current?.map((page) => ({\n ...page,\n count: Math.max(0, page.count - 1),\n sources: page.sources.filter((entry) => entry.id !== removed.id),\n })),\n { revalidate: true }\n ),\n };\n let content: JSX.Element =\n viewMode === 'grid' ? (\n <SourceGrid sources={sources} {...actions} />\n ) : (\n <SourceTable sources={sources} {...actions} />\n );\n\n if (isInitialLoading) {\n content = <KnowledgeListSkeleton viewMode={viewMode} />;\n } else if (sources.length === 0) {\n content = (\n <Alert>\n <AlertDescription>{emptyMessage}</AlertDescription>\n </Alert>\n );\n }\n\n return (\n <main className=\"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col\">\n <ListHeader />\n <AssetDropZone disabled={!canMutate} onDropFiles={addFiles}>\n <div className=\"fk:min-h-0 fk:flex-1 fk:overflow-auto\">\n <div className=\"fk:flex fk:w-full fk:flex-col fk:gap-5 fk:py-4 fk:pl-4 fk:pr-6\">\n <div>\n <h2 className=\"fk:text-2xl fk:font-semibold\">Documents</h2>\n <p className=\"fk:mt-1 fk:text-sm fk:text-muted-foreground\">\n Policies, manuals, specs and other reference material for your team and agents. The agent searches them\n when a question needs them and cites the passage it used.\n </p>\n </div>\n <div className=\"fk:flex fk:flex-wrap fk:items-center fk:gap-3\">\n <div className=\"fk:relative fk:w-full fk:max-w-sm\">\n <SearchIcon className=\"fk:pointer-events-none fk:absolute fk:left-2.5 fk:top-1/2 fk:size-4 fk:-translate-y-1/2 fk:text-muted-foreground\" />\n <Input\n aria-label=\"Search documents\"\n className=\"fk:pl-8 fk:pr-9\"\n placeholder=\"Search by title or content…\"\n ref={searchInputRef}\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n />\n {search ? (\n <Button\n aria-label=\"Clear search\"\n className=\"fk:absolute fk:right-1.5 fk:top-1/2 fk:flex fk:size-6 fk:-translate-y-1/2 fk:items-center fk:justify-center fk:rounded-full fk:bg-transparent fk:text-muted-foreground fk:hover:bg-foreground/10 fk:hover:text-foreground fk:corner-squircle\"\n data-knowledge-clear-search\n type=\"button\"\n onClick={() => {\n setSearch('');\n searchInputRef.current?.focus();\n }}\n >\n <XIcon className=\"fk:size-4\" />\n </Button>\n ) : null}\n </div>\n {total > 0 ? (\n <span className=\"fk:text-sm fk:text-muted-foreground\">\n {total.toLocaleString()} {total === 1 ? 'document' : 'documents'}\n </span>\n ) : null}\n <div className=\"fk:ml-auto fk:flex fk:items-center fk:gap-2\">\n <ToggleGroup\n aria-label=\"Layout\"\n size=\"sm\"\n type=\"single\"\n value={viewMode}\n variant=\"outline\"\n onValueChange={(value) => {\n if (value === 'list' || value === 'grid') {\n setViewMode(value);\n setStoredKnowledgeViewMode(value);\n }\n }}\n >\n <ToggleGroupItem aria-label=\"List layout\" value=\"list\">\n <ListIcon className=\"fk:size-4\" />\n </ToggleGroupItem>\n <ToggleGroupItem aria-label=\"Grid layout\" value=\"grid\">\n <LayoutGridIcon className=\"fk:size-4\" />\n </ToggleGroupItem>\n </ToggleGroup>\n <PermissionTooltip disabled={!canMutate}>\n <Button disabled={!canMutate} size=\"sm\" variant=\"outline\" onClick={() => setIsUrlDialogOpen(true)}>\n <LinkIcon />\n Add web page\n </Button>\n </PermissionTooltip>\n <PermissionTooltip disabled={!canMutate}>\n <Button disabled={!canMutate} size=\"sm\" onClick={() => fileInputRef.current?.click()}>\n <UploadIcon />\n Upload documents\n </Button>\n </PermissionTooltip>\n <input\n accept={KNOWLEDGE_ACCEPT}\n className=\"fk:hidden\"\n multiple\n ref={fileInputRef}\n type=\"file\"\n onChange={handleFilesPicked}\n />\n </div>\n </div>\n {pending.length > 0 ? (\n <div className=\"fk:flex fk:flex-col fk:gap-1 fk:text-sm fk:text-muted-foreground\">\n {pending.map((upload) => (\n <span className=\"fk:flex fk:items-center fk:gap-2\" key={upload.id}>\n <LoaderCircle className=\"fk:size-4 fk:animate-spin\" />\n Uploading {upload.name}…\n </span>\n ))}\n </div>\n ) : null}\n {content}\n {hasMore && !isLoadingMore ? (\n <InfiniteScrollSentinel onVisible={() => void setSize((current) => current + 1)} />\n ) : null}\n {isLoadingMore ? (\n <div className=\"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-4 fk:animate-spin\" />\n <span>Loading more documents...</span>\n </div>\n ) : null}\n </div>\n </div>\n </AssetDropZone>\n <AddUrlDialog\n api={api}\n open={isUrlDialogOpen}\n onOpenChange={setIsUrlDialogOpen}\n onRegistered={() => void mutate()}\n />\n </main>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/apps/knowledge/list.tsx"],"names":["KNOWLEDGE_PAGE_SIZE","LIST_POLL_INTERVAL_MS","SEARCH_DEBOUNCE_MS","useDebouncedValue","value","delayMs","debounced","setDebounced","useState","useEffect","timer","EMPTY_BY_FILTER","KnowledgeListSkeleton","viewMode","ids","jsxs","GRID_CLASSES","jsx","id","Skeleton","useKnowledgeUploads","api","onRegistered","pending","setPending","queueRef","useRef","addFiles","files","file","problem","getKnowledgeFileProblem","toast","upload","current","result","announceRegistered","error","describeApiError","entry","AddUrlDialog","onOpenChange","open","setValue","title","setTitle","setError","isSubmitting","setIsSubmitting","close","handleSubmit","event","parsed","parseKnowledgeUrl","submitError","Dialog","next","DialogContent","DialogHeader","DialogTitle","DialogDescription","Label","Input","KNOWLEDGE_MAX_TITLE_LENGTH","DialogFooter","Button","LoaderCircle","LinkIcon","formatAdded","iso","format","HiddenBadge","Badge","ContentMatchBadge","handleRowClick","target","SourceListRow","source","actions","status","summarizeKnowledgeStatus","detailClass","TableRow","TableCell","KnowledgeTypeIcon","Link","StatusBadge","getKnowledgeKindLabel","formatFileSize","Tooltip","TooltipTrigger","TooltipContent","formatDistance","SourceActionsMenu","SourceTable","sources","Table","TableHeader","TableHead","TableBody","SourcePreview","preview","SourceCard","meta","SourceGrid","ListHeader","SidebarTrigger","Separator","List","projectId","useProjectKnowledge","navigate","useNavigate","canMutate","useCanMutate","isViewing","useIsViewing","useKnowledgeStatusFilter","search","setSearch","query","setViewMode","getStoredKnowledgeViewMode","isUrlDialogOpen","setIsUrlDialogOpen","fileInputRef","searchInputRef","isBusy","setIsBusy","getSourcesKey","pageIndex","previousPage","knowledgePaths","pages","isLoading","mutate","setSize","size","useSWRInfinite","fetcher","useMemo","page","total","hasMore","isLoadingMore","isInitialLoading","mutateRef","isKnowledgeSourceBusy","setSizeRef","PageMessage","handleFilesPicked","emptyMessage","KNOWLEDGE_FORMATS_LABEL","removed","content","Alert","AlertDescription","AssetDropZone","SearchIcon","XIcon","ToggleGroup","setStoredKnowledgeViewMode","ToggleGroupItem","ListIcon","LayoutGridIcon","PermissionTooltip","UploadIcon","KNOWLEDGE_ACCEPT","InfiniteScrollSentinel"],"mappings":"4rCAoEA,IAAMA,EAAAA,CAAsB,EAAA,CACtBC,EAAAA,CAAwB,GAAA,CAExBC,EAAAA,CAAqB,GAAA,CAE3B,SAASC,EAAAA,CAAqBC,CAAAA,CAAUC,CAAAA,CAAoB,CAC1D,GAAM,CAACC,CAAAA,CAAWC,CAAY,CAAA,CAAIC,QAAAA,CAASJ,CAAK,CAAA,CAEhD,OAAAK,SAAAA,CAAU,IAAM,CACd,IAAMC,CAAAA,CAAQ,UAAA,CAAW,IAAMH,CAAAA,CAAaH,CAAK,CAAA,CAAGC,CAAO,CAAA,CAE3D,OAAO,IAAM,YAAA,CAAaK,CAAK,CACjC,CAAA,CAAG,CAACL,CAAAA,CAASD,CAAK,CAAC,CAAA,CAEZE,CACT,CAEA,IAAMK,EAAAA,CAAkB,CACtB,MAAA,CAAQ,8BAAA,CACR,UAAA,CAAY,yCAAA,CACZ,KAAA,CAAO,2BACT,CAAA,CAEA,SAASC,EAAAA,CAAsB,CAAE,QAAA,CAAAC,GAAS,CAAA,CAAiD,CACzF,IAAMC,CAAAA,CAAM,CAAC,GAAA,CAAK,GAAA,CAAK,GAAA,CAAK,GAAA,CAAK,GAAA,CAAK,GAAG,CAAA,CAEzC,OAAID,GAAAA,GAAa,MAAA,CAEbE,IAAAA,CAAC,KAAA,CAAA,CAAI,WAAA,CAAU,MAAA,CAAO,UAAWC,EAAAA,CAC/B,QAAA,CAAA,CAAAC,GAAAA,CAAC,MAAA,CAAA,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CAAA,CAClC,GACF,CAEJ","file":"list-Q2KAEJ26.js","sourcesContent":["import type { ChangeEvent, FormEvent, JSX, MouseEvent } from 'react';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { format, formatDistance } from 'date-fns';\nimport { LayoutGridIcon, LinkIcon, ListIcon, LoaderCircle, SearchIcon, UploadIcon, XIcon } from 'lucide-react';\nimport { Link, useNavigate } from 'react-router-dom';\nimport useSWRInfinite from 'swr/infinite';\nimport { useIsViewing } from '../../core/apps/app-active';\nimport { useCanMutate } from '../../core/permissions';\nimport {\n Alert,\n AlertDescription,\n Badge,\n Button,\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n ToggleGroup,\n ToggleGroupItem,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Input,\n Label,\n PermissionTooltip,\n Separator,\n SidebarTrigger,\n Skeleton,\n toast,\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from '../../ui';\nimport { AssetDropZone } from '../asset-manager/data-grid/asset-drop-zone';\nimport { fetcher, knowledgePaths, type KnowledgeApi } from './api';\nimport {\n formatFileSize,\n getKnowledgeFileProblem,\n getKnowledgeKindLabel,\n getStoredKnowledgeViewMode,\n isKnowledgeSourceBusy,\n KNOWLEDGE_ACCEPT,\n KNOWLEDGE_FORMATS_LABEL,\n KNOWLEDGE_MAX_TITLE_LENGTH,\n parseKnowledgeUrl,\n setStoredKnowledgeViewMode,\n summarizeKnowledgeStatus,\n type KnowledgeSource,\n type KnowledgeSourcesList,\n type KnowledgeViewMode,\n} from './knowledge';\nimport {\n announceRegistered,\n describeApiError,\n InfiniteScrollSentinel,\n KnowledgeTypeIcon,\n PageMessage,\n SourceActionsMenu,\n StatusBadge,\n useProjectKnowledge,\n} from './shared';\nimport { useKnowledgeStatusFilter } from './sidebar';\n\nconst KNOWLEDGE_PAGE_SIZE = 25;\nconst LIST_POLL_INTERVAL_MS = 3_000;\n/** Typing pauses this long before the list asks the platform; each ask now searches the documents' text too. */\nconst SEARCH_DEBOUNCE_MS = 250;\n\nfunction useDebouncedValue<T>(value: T, delayMs: number): T {\n const [debounced, setDebounced] = useState(value);\n\n useEffect(() => {\n const timer = setTimeout(() => setDebounced(value), delayMs);\n\n return () => clearTimeout(timer);\n }, [delayMs, value]);\n\n return debounced;\n}\n\nconst EMPTY_BY_FILTER = {\n failed: 'No document failed to index.',\n processing: 'No document is being indexed right now.',\n ready: 'No document is ready yet.',\n};\n\nfunction KnowledgeListSkeleton({ viewMode }: { viewMode: KnowledgeViewMode }): JSX.Element {\n const ids = ['a', 'b', 'c', 'd', 'e', 'f'];\n\n if (viewMode === 'grid') {\n return (\n <div aria-busy=\"true\" className={GRID_CLASSES}>\n <span className=\"fk:sr-only\">Loading documents</span>\n {ids.map((id) => (\n <div className=\"fk:flex fk:flex-col fk:gap-3 fk:rounded-xl fk:border fk:p-3 fk:corner-squircle\" key={id}>\n <span className=\"fk:flex fk:items-center fk:gap-2\">\n <Skeleton className=\"fk:size-6 fk:rounded-md\" />\n <Skeleton className=\"fk:h-4 fk:flex-1\" />\n </span>\n <Skeleton className=\"fk:aspect-[4/3] fk:w-full fk:rounded-lg\" />\n </div>\n ))}\n </div>\n );\n }\n\n return (\n <div aria-busy=\"true\" className=\"fk:flex fk:flex-col\">\n <span className=\"fk:sr-only\">Loading documents</span>\n {ids.map((id) => (\n <div className=\"fk:flex fk:h-12 fk:items-center fk:gap-3 fk:border-b fk:px-3\" key={id}>\n <Skeleton className=\"fk:size-6 fk:shrink-0 fk:rounded-md\" />\n <Skeleton className=\"fk:h-4 fk:w-1/3\" />\n <Skeleton className=\"fk:ml-auto fk:h-4 fk:w-16\" />\n <Skeleton className=\"fk:hidden fk:h-4 fk:w-24 fk:md:block\" />\n </div>\n ))}\n </div>\n );\n}\n\ninterface PendingUpload {\n id: string;\n name: string;\n}\n\n/** Runs file uploads one after another and reports each outcome; the list revalidates after every registration. */\nfunction useKnowledgeUploads(\n api: KnowledgeApi | null,\n onRegistered: () => void\n): {\n addFiles: (_files: File[]) => void;\n pending: PendingUpload[];\n} {\n const [pending, setPending] = useState<PendingUpload[]>([]);\n const queueRef = useRef<Promise<void>>(Promise.resolve());\n\n function addFiles(files: File[]): void {\n if (!api) {\n return;\n }\n\n for (const file of files) {\n const problem = getKnowledgeFileProblem(file);\n\n if (problem) {\n toast.error(problem);\n\n continue;\n }\n\n const upload: PendingUpload = {\n id: `${file.name}-${String(Date.now())}-${String(Math.random())}`,\n name: file.name,\n };\n\n setPending((current) => [...current, upload]);\n queueRef.current = queueRef.current\n .then(async () => {\n try {\n const result = await api.addFile(file);\n\n announceRegistered(result, file.name);\n onRegistered();\n } catch (error) {\n toast.error(describeApiError(error, `${file.name} could not be added.`));\n } finally {\n setPending((current) => current.filter((entry) => entry.id !== upload.id));\n }\n })\n .catch(() => undefined);\n }\n }\n\n return { addFiles, pending };\n}\n\nfunction AddUrlDialog({\n api,\n onOpenChange,\n onRegistered,\n open,\n}: {\n api: KnowledgeApi;\n onOpenChange: (_open: boolean) => void;\n onRegistered: () => void;\n open: boolean;\n}): JSX.Element {\n const [value, setValue] = useState('');\n const [title, setTitle] = useState('');\n const [error, setError] = useState('');\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n function close(): void {\n onOpenChange(false);\n setValue('');\n setTitle('');\n setError('');\n }\n\n async function handleSubmit(event: FormEvent<HTMLFormElement>): Promise<void> {\n event.preventDefault();\n\n const parsed = parseKnowledgeUrl(value);\n\n if ('error' in parsed) {\n setError(parsed.error);\n\n return;\n }\n\n setIsSubmitting(true);\n setError('');\n\n try {\n const result = await api.addUrl({ title: title.trim() || undefined, url: parsed.url });\n\n announceRegistered(result, parsed.url);\n onRegistered();\n close();\n } catch (submitError) {\n setError(describeApiError(submitError, 'The page could not be added.'));\n } finally {\n setIsSubmitting(false);\n }\n }\n\n return (\n <Dialog open={open} onOpenChange={(next) => (next ? onOpenChange(true) : close())}>\n <DialogContent>\n <form className=\"fk:flex fk:flex-col fk:gap-4\" onSubmit={(event) => void handleSubmit(event)}>\n <DialogHeader>\n <DialogTitle>Add a web page</DialogTitle>\n <DialogDescription>\n The page is fetched and indexed now, and again whenever you re-index it. Only public pages work.\n </DialogDescription>\n </DialogHeader>\n <div className=\"fk:flex fk:flex-col fk:gap-1.5\">\n <Label htmlFor=\"knowledge-url\">Address</Label>\n <Input\n autoFocus\n id=\"knowledge-url\"\n inputMode=\"url\"\n placeholder=\"https://example.com/help/returns\"\n value={value}\n onChange={(event) => {\n setValue(event.target.value);\n setError('');\n }}\n />\n </div>\n <div className=\"fk:flex fk:flex-col fk:gap-1.5\">\n <Label htmlFor=\"knowledge-url-title\">Title (optional)</Label>\n <Input\n id=\"knowledge-url-title\"\n maxLength={KNOWLEDGE_MAX_TITLE_LENGTH}\n placeholder=\"Defaults to the page address\"\n value={title}\n onChange={(event) => setTitle(event.target.value)}\n />\n </div>\n {error ? <p className=\"fk:text-sm fk:text-destructive\">{error}</p> : null}\n <DialogFooter>\n <Button disabled={isSubmitting} size=\"sm\" type=\"button\" variant=\"outline\" onClick={close}>\n Cancel\n </Button>\n <Button disabled={isSubmitting || !value.trim()} size=\"sm\" type=\"submit\">\n {isSubmitting ? (\n <LoaderCircle className=\"fk:size-4 fk:animate-spin\" />\n ) : (\n <LinkIcon className=\"fk:size-4\" />\n )}\n Add page\n </Button>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n );\n}\n\nconst GRID_CLASSES = 'fk:grid fk:grid-cols-[repeat(auto-fill,minmax(14rem,1fr))] fk:gap-4';\n\nfunction formatAdded(iso: string): string {\n return format(new Date(iso), 'MMM d, yyyy');\n}\n\nfunction HiddenBadge(): JSX.Element {\n return (\n <Badge className=\"fk:shrink-0 fk:corner-squircle\" variant=\"outline\">\n Hidden from agent\n </Badge>\n );\n}\n\n/** A search hit whose title does not carry the words: the text inside does. */\nfunction ContentMatchBadge(): JSX.Element {\n return (\n <Badge className=\"fk:shrink-0 fk:corner-squircle\" data-knowledge-content-match variant=\"secondary\">\n In content\n </Badge>\n );\n}\n\ninterface SourceActions {\n onOpen: (_source: KnowledgeSource) => void;\n onRemoved: (_source: KnowledgeSource) => void;\n}\n\ntype SourceItemProps = SourceActions & { source: KnowledgeSource };\n\n/**\n * A plain click on the row opens the document. Clicks that bubbled up from\n * a portal (the menu, the removal dialog), modified clicks (the title link\n * handles new tabs itself) and clicks on the row's own controls are not.\n */\nfunction handleRowClick(event: MouseEvent<HTMLElement>, open: () => void): void {\n const target = event.target as Node;\n\n if (\n event.defaultPrevented ||\n event.button !== 0 ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey ||\n !event.currentTarget.contains(target) ||\n (target as Element).closest('a, button')\n ) {\n return;\n }\n\n open();\n}\n\n/**\n * One line of the list: the type mark, the title as a real link (so it can\n * be opened in a new tab), then the status and facts in columns, like a file\n * manager. The whole row is clickable for the mouse; the link carries the\n * keyboard and assistive tech.\n */\nfunction SourceListRow({ source, ...actions }: SourceItemProps): JSX.Element {\n const status = summarizeKnowledgeStatus(source);\n // What went wrong, or what is happening, matters at every width; the passage count can wait for a wide one.\n const detailClass = status.tone === 'ready' ? 'fk:hidden fk:xl:inline' : 'fk:hidden fk:md:inline';\n\n return (\n <TableRow\n className=\"fk:h-12 fk:cursor-pointer\"\n data-knowledge-row\n onClick={(event) => handleRowClick(event, () => actions.onOpen(source))}\n >\n <TableCell className=\"fk:max-w-0 fk:w-full\">\n <span className=\"fk:flex fk:min-w-0 fk:items-center fk:gap-3\">\n <KnowledgeTypeIcon source={source} />\n <Link\n className=\"fk:truncate fk:text-sm fk:font-medium fk:hover:underline fk:underline-offset-2 fk:focus-visible:outline-none fk:focus-visible:underline\"\n to={source.id}\n >\n {source.title}\n </Link>\n {source.matchedIn === 'content' ? <ContentMatchBadge /> : null}\n {!source.agentVisible ? <HiddenBadge /> : null}\n </span>\n </TableCell>\n <TableCell className=\"fk:whitespace-nowrap\">\n <span className=\"fk:flex fk:items-center fk:gap-2\">\n <StatusBadge label={status.label} tone={status.tone} />\n <span\n className={`${detailClass} fk:max-w-64 fk:truncate fk:text-xs fk:text-muted-foreground`}\n title={status.detail}\n >\n {status.detail}\n </span>\n </span>\n </TableCell>\n <TableCell className=\"fk:hidden fk:whitespace-nowrap fk:text-muted-foreground fk:md:table-cell\">\n {getKnowledgeKindLabel(source)}\n </TableCell>\n <TableCell className=\"fk:hidden fk:whitespace-nowrap fk:text-right fk:tabular-nums fk:text-muted-foreground fk:md:table-cell\">\n {source.size === null ? '—' : formatFileSize(source.size)}\n </TableCell>\n <TableCell className=\"fk:hidden fk:whitespace-nowrap fk:text-muted-foreground fk:sm:table-cell\">\n <Tooltip>\n <TooltipTrigger asChild>\n <span>{formatAdded(source.createdAt)}</span>\n </TooltipTrigger>\n <TooltipContent>\n Updated {formatDistance(new Date(source.updatedAt), new Date(), { addSuffix: true })}\n </TooltipContent>\n </Tooltip>\n </TableCell>\n <TableCell className=\"fk:w-12 fk:pr-2 fk:text-right\">\n <SourceActionsMenu\n source={source}\n onOpen={() => actions.onOpen(source)}\n onRemoved={() => actions.onRemoved(source)}\n />\n </TableCell>\n </TableRow>\n );\n}\n\nfunction SourceTable({ sources, ...actions }: SourceActions & { sources: KnowledgeSource[] }): JSX.Element {\n return (\n <Table data-knowledge-list>\n <TableHeader>\n <TableRow className=\"fk:hover:bg-transparent\">\n <TableHead>Name</TableHead>\n <TableHead>Status</TableHead>\n <TableHead className=\"fk:hidden fk:md:table-cell\">Type</TableHead>\n <TableHead className=\"fk:hidden fk:text-right fk:md:table-cell\">Size</TableHead>\n <TableHead className=\"fk:hidden fk:sm:table-cell\">Added</TableHead>\n <TableHead className=\"fk:w-12\">\n <span className=\"fk:sr-only\">Actions</span>\n </TableHead>\n </TableRow>\n </TableHeader>\n <TableBody>\n {sources.map((source) => (\n <SourceListRow key={source.id} source={source} {...actions} />\n ))}\n </TableBody>\n </Table>\n );\n}\n\n/**\n * The card's thumbnail: the opening text of the document laid out like a\n * small page, the way a file manager shows the first page. Documents still\n * indexing, or without text, show their type mark instead.\n */\nfunction SourcePreview({ source }: { source: KnowledgeSource }): JSX.Element {\n const preview = source.preview?.trim();\n\n return (\n <div className=\"fk:relative fk:aspect-[4/3] fk:overflow-hidden fk:rounded-lg fk:bg-muted fk:corner-squircle\">\n {preview ? (\n <div\n aria-hidden\n className=\"fk:absolute fk:inset-x-4 fk:top-3 fk:bottom-0 fk:overflow-hidden fk:rounded-t-sm fk:bg-background fk:px-3 fk:pt-3 fk:shadow-sm\"\n >\n <p className=\"fk:whitespace-pre-line fk:text-[9px] fk:leading-[1.45] fk:text-foreground/80 fk:select-none\">\n {preview}\n </p>\n <span className=\"fk:pointer-events-none fk:absolute fk:inset-x-0 fk:bottom-0 fk:h-10 fk:bg-gradient-to-t fk:from-background fk:to-transparent\" />\n </div>\n ) : (\n <div className=\"fk:flex fk:h-full fk:items-center fk:justify-center\">\n <KnowledgeTypeIcon size={56} source={source} />\n </div>\n )}\n </div>\n );\n}\n\nfunction SourceCard({ source, ...actions }: SourceItemProps): JSX.Element {\n const status = summarizeKnowledgeStatus(source);\n const meta = [getKnowledgeKindLabel(source)];\n\n if (source.size !== null) {\n meta.push(formatFileSize(source.size));\n }\n\n meta.push(status.detail);\n\n // A link laid over the card opens the document (so it can be opened in a\n // new tab too); the menu button sits above it. The title tooltip lives on\n // the card itself, which does receive the pointer.\n return (\n <div\n className=\"fk:relative fk:flex fk:min-w-0 fk:flex-col fk:gap-3 fk:rounded-xl fk:border fk:bg-card fk:p-3 fk:transition-colors fk:hover:bg-accent/60 fk:has-[>a:focus-visible]:ring-2 fk:has-[>a:focus-visible]:ring-ring fk:corner-squircle\"\n data-knowledge-card\n title={source.title}\n >\n <Link\n aria-label={`Open ${source.title}`}\n className=\"fk:absolute fk:inset-0 fk:rounded-xl fk:focus-visible:outline-none fk:corner-squircle\"\n to={source.id}\n />\n <span className=\"fk:pointer-events-none fk:relative fk:flex fk:min-w-0 fk:items-center fk:gap-2\">\n <KnowledgeTypeIcon source={source} />\n <span className=\"fk:min-w-0 fk:flex-1 fk:truncate fk:text-sm fk:font-medium\">{source.title}</span>\n <span className=\"fk:pointer-events-auto fk:-my-1 fk:-mr-1.5\">\n <SourceActionsMenu\n source={source}\n onOpen={() => actions.onOpen(source)}\n onRemoved={() => actions.onRemoved(source)}\n />\n </span>\n </span>\n <span className=\"fk:pointer-events-none fk:relative\">\n <SourcePreview source={source} />\n </span>\n <span className=\"fk:pointer-events-none fk:relative fk:flex fk:min-w-0 fk:items-center fk:gap-2\">\n <StatusBadge label={status.label} tone={status.tone} />\n <span className=\"fk:min-w-0 fk:flex-1 fk:truncate fk:text-xs fk:text-muted-foreground\">{meta.join(' · ')}</span>\n {source.matchedIn === 'content' ? <ContentMatchBadge /> : null}\n {!source.agentVisible ? <HiddenBadge /> : null}\n </span>\n </div>\n );\n}\n\nfunction SourceGrid({ sources, ...actions }: SourceActions & { sources: KnowledgeSource[] }): JSX.Element {\n return (\n <div className={GRID_CLASSES} data-knowledge-grid>\n {sources.map((source) => (\n <SourceCard key={source.id} source={source} {...actions} />\n ))}\n </div>\n );\n}\n\nfunction ListHeader(): JSX.Element {\n return (\n <div className=\"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2 fk:pr-4\">\n <Tooltip>\n <TooltipTrigger asChild>\n <SidebarTrigger className=\"fk:-ml-1 fk:h-4 fk:w-4\" />\n </TooltipTrigger>\n <TooltipContent>Toggle Sidebar</TooltipContent>\n </Tooltip>\n <Separator orientation=\"vertical\" className=\"fk:h-4\" />\n <h1 className=\"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight\">Knowledge</h1>\n </div>\n );\n}\n\nexport function List(): JSX.Element {\n const { api, projectId } = useProjectKnowledge();\n const navigate = useNavigate();\n const canMutate = useCanMutate();\n const isViewing = useIsViewing();\n const status = useKnowledgeStatusFilter();\n const [search, setSearch] = useState('');\n const query = useDebouncedValue(search.trim(), SEARCH_DEBOUNCE_MS);\n const [viewMode, setViewMode] = useState<KnowledgeViewMode>(() => getStoredKnowledgeViewMode());\n const [isUrlDialogOpen, setIsUrlDialogOpen] = useState(false);\n const fileInputRef = useRef<HTMLInputElement>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const [isBusy, setIsBusy] = useState(false);\n const getSourcesKey = (pageIndex: number, previousPage: KnowledgeSourcesList | null): string | null => {\n if (!projectId || (previousPage && !previousPage.hasMore)) {\n return null;\n }\n\n return knowledgePaths(projectId).sources({\n limit: KNOWLEDGE_PAGE_SIZE,\n offset: pageIndex * KNOWLEDGE_PAGE_SIZE,\n search: query || undefined,\n status,\n });\n };\n const {\n data: pages,\n isLoading,\n mutate,\n setSize,\n size,\n } = useSWRInfinite<KnowledgeSourcesList>(getSourcesKey, fetcher, {\n // Rows that are still indexing change on their own; poll while one is in flight and the tab is in front.\n refreshInterval: isViewing && isBusy ? LIST_POLL_INTERVAL_MS : 0,\n });\n const sources = useMemo(() => pages?.flatMap((page) => page.sources) ?? [], [pages]);\n const total = pages?.[0]?.count ?? 0;\n const hasMore = pages?.[pages.length - 1]?.hasMore ?? false;\n const isLoadingMore = pages !== undefined && size > pages.length;\n const isInitialLoading = isLoading && sources.length === 0;\n const { addFiles, pending } = useKnowledgeUploads(api, () => void mutate());\n const mutateRef = useRef(mutate);\n\n mutateRef.current = mutate;\n\n // Coming back from a document page must show what changed there. The\n // infinite hook keeps serving its cached pages otherwise, whatever the\n // mount options.\n useEffect(() => {\n void mutateRef.current();\n }, []);\n\n useEffect(() => {\n setIsBusy(sources.some((source) => isKnowledgeSourceBusy(source)));\n }, [sources]);\n\n // A new search starts from its first page.\n const setSizeRef = useRef(setSize);\n\n setSizeRef.current = setSize;\n\n useEffect(() => {\n void setSizeRef.current(1);\n }, [query]);\n\n if (!projectId || !api) {\n return <PageMessage>Select a project to manage its knowledge.</PageMessage>;\n }\n\n function handleFilesPicked(event: ChangeEvent<HTMLInputElement>): void {\n const files = Array.from(event.target.files ?? []);\n\n event.target.value = '';\n addFiles(files);\n }\n\n let emptyMessage = `No documents yet. Upload ${KNOWLEDGE_FORMATS_LABEL} files, or add a public web page, and the agent will search and cite them.`;\n\n if (query) {\n emptyMessage = 'No document title or content matches your search.';\n } else if (status) {\n emptyMessage = EMPTY_BY_FILTER[status];\n }\n\n const actions: SourceActions = {\n onOpen: (source) => void navigate(source.id),\n // Drop the row at once, then let this hook refetch its pages: the global\n // list invalidation clears other caches but never revalidates an infinite hook.\n onRemoved: (removed) =>\n void mutate(\n (current) =>\n current?.map((page) => ({\n ...page,\n count: Math.max(0, page.count - 1),\n sources: page.sources.filter((entry) => entry.id !== removed.id),\n })),\n { revalidate: true }\n ),\n };\n let content: JSX.Element =\n viewMode === 'grid' ? (\n <SourceGrid sources={sources} {...actions} />\n ) : (\n <SourceTable sources={sources} {...actions} />\n );\n\n if (isInitialLoading) {\n content = <KnowledgeListSkeleton viewMode={viewMode} />;\n } else if (sources.length === 0) {\n content = (\n <Alert>\n <AlertDescription>{emptyMessage}</AlertDescription>\n </Alert>\n );\n }\n\n return (\n <main className=\"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col\">\n <ListHeader />\n <AssetDropZone disabled={!canMutate} onDropFiles={addFiles}>\n <div className=\"fk:min-h-0 fk:flex-1 fk:overflow-auto\">\n <div className=\"fk:flex fk:w-full fk:flex-col fk:gap-5 fk:py-4 fk:pl-4 fk:pr-6\">\n <div>\n <h2 className=\"fk:text-2xl fk:font-semibold\">Documents</h2>\n <p className=\"fk:mt-1 fk:text-sm fk:text-muted-foreground\">\n Policies, manuals, specs and other reference material for your team and agents. The agent searches them\n when a question needs them and cites the passage it used.\n </p>\n </div>\n <div className=\"fk:flex fk:flex-wrap fk:items-center fk:gap-3\">\n <div className=\"fk:relative fk:w-full fk:max-w-sm\">\n <SearchIcon className=\"fk:pointer-events-none fk:absolute fk:left-2.5 fk:top-1/2 fk:size-4 fk:-translate-y-1/2 fk:text-muted-foreground\" />\n <Input\n aria-label=\"Search documents\"\n className=\"fk:pl-8 fk:pr-9\"\n placeholder=\"Search by title or content…\"\n ref={searchInputRef}\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n />\n {search ? (\n <Button\n aria-label=\"Clear search\"\n className=\"fk:absolute fk:right-1.5 fk:top-1/2 fk:flex fk:size-6 fk:-translate-y-1/2 fk:items-center fk:justify-center fk:rounded-full fk:bg-transparent fk:text-muted-foreground fk:hover:bg-foreground/10 fk:hover:text-foreground fk:corner-squircle\"\n data-knowledge-clear-search\n type=\"button\"\n onClick={() => {\n setSearch('');\n searchInputRef.current?.focus();\n }}\n >\n <XIcon className=\"fk:size-4\" />\n </Button>\n ) : null}\n </div>\n {total > 0 ? (\n <span className=\"fk:text-sm fk:text-muted-foreground\">\n {total.toLocaleString()} {total === 1 ? 'document' : 'documents'}\n </span>\n ) : null}\n <div className=\"fk:ml-auto fk:flex fk:items-center fk:gap-2\">\n <ToggleGroup\n aria-label=\"Layout\"\n size=\"sm\"\n type=\"single\"\n value={viewMode}\n variant=\"outline\"\n onValueChange={(value) => {\n if (value === 'list' || value === 'grid') {\n setViewMode(value);\n setStoredKnowledgeViewMode(value);\n }\n }}\n >\n <ToggleGroupItem aria-label=\"List layout\" value=\"list\">\n <ListIcon className=\"fk:size-4\" />\n </ToggleGroupItem>\n <ToggleGroupItem aria-label=\"Grid layout\" value=\"grid\">\n <LayoutGridIcon className=\"fk:size-4\" />\n </ToggleGroupItem>\n </ToggleGroup>\n <PermissionTooltip disabled={!canMutate}>\n <Button disabled={!canMutate} size=\"sm\" variant=\"outline\" onClick={() => setIsUrlDialogOpen(true)}>\n <LinkIcon />\n Add web page\n </Button>\n </PermissionTooltip>\n <PermissionTooltip disabled={!canMutate}>\n <Button disabled={!canMutate} size=\"sm\" onClick={() => fileInputRef.current?.click()}>\n <UploadIcon />\n Upload documents\n </Button>\n </PermissionTooltip>\n <input\n accept={KNOWLEDGE_ACCEPT}\n className=\"fk:hidden\"\n multiple\n ref={fileInputRef}\n type=\"file\"\n onChange={handleFilesPicked}\n />\n </div>\n </div>\n {pending.length > 0 ? (\n <div className=\"fk:flex fk:flex-col fk:gap-1 fk:text-sm fk:text-muted-foreground\">\n {pending.map((upload) => (\n <span className=\"fk:flex fk:items-center fk:gap-2\" key={upload.id}>\n <LoaderCircle className=\"fk:size-4 fk:animate-spin\" />\n Uploading {upload.name}…\n </span>\n ))}\n </div>\n ) : null}\n {content}\n {hasMore && !isLoadingMore ? (\n <InfiniteScrollSentinel onVisible={() => void setSize((current) => current + 1)} />\n ) : null}\n {isLoadingMore ? (\n <div className=\"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-4 fk:animate-spin\" />\n <span>Loading more documents...</span>\n </div>\n ) : null}\n </div>\n </div>\n </AssetDropZone>\n <AddUrlDialog\n api={api}\n open={isUrlDialogOpen}\n onOpenChange={setIsUrlDialogOpen}\n onRegistered={() => void mutate()}\n />\n </main>\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import'./index.css';import {c as c$2,a as a$1}from'./chunk-R2O4WC3H.js';import {m as m$2,a,b,d as d$2}from'./chunk-NNISUDZX.js';import'./chunk-CAZ6EUR2.js';import'./chunk-2DXR5NJV.js';import {m as m$1,d,s}from'./chunk-KR27GOH6.js';import'./chunk-V7C4EHK3.js';import {e}from'./chunk-XV7U33XQ.js';import {c}from'./chunk-XMOSCJOI.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import'./chunk-YDVO6XWD.js';import'./chunk-ERDARDGB.js';import {f,d as d$1}from'./chunk-HZOD2HOF.js';import'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {O}from'./chunk-DGIY4SKN.js';import {t}from'./chunk-SZEGGBOC.js';import {v}from'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import'./chunk-HDOIOXMP.js';import {b as b$1,c as c$1,e as e$1}from'./chunk-USNXQOMJ.js';import'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {useState,useMemo,useCallback}from'react';import {useParams,useLocation,Outlet}from'react-router-dom';import {jsx,jsxs}from'react/jsx-runtime';var m=36,pt=[{_updatedAt:"DESC"},{_id:"DESC"}];function Mt(){let{entity:t}=useParams(),{search:a$1}=useLocation(),h=new URLSearchParams(a$1).get("id"),{scope:W}=c(),{schemaErrorMessage:B}=e(),{currentProject:O$1,currentProjectId:f$1}=f(),S=O$1?.schema??[],n=m$1(S,t??""),[r,k]=useState([]),[F,H]=useState(0),[Y,Z]=useState(t);t!==Y&&(Z(t),k([]));let y=m$2({attributesSchema:n?.attributes??[],actionsComponent:o=>gt({entityName:n?.name??"",entityNamePlural:t??"",row:o}),checkboxSelect:"multiple",enableColumnSorting:true}),u=useMemo(()=>{if(r.length===0)return pt;let o=r.map(({id:p,desc:mt})=>({[p]:mt?"DESC":"ASC"}));return o.some(p=>"_id"in p)?o:[...o,{_id:"DESC"}]},[r]),b$2=useMemo(()=>{if(r.length!==0)return d(u,n)},[n,u,r.length]),$=h?{where:{_id:{eq:h}}}:{offset:0,limit:m,sort:u,...b$2?{where:b$2}:{}},{isLoading:tt,isLoadingMore:et,fetchMore:C,reload:N,count:i,data:l,isProjectDisabled:ot}=s({entityNamePlural:t??"",schema:S,scope:W,variables:$,selection:"list"});function nt(o){k(o);}let T=l?.length??0,rt=i>0&&T>0&&T<i,at=useCallback(()=>{C({variables:{offset:0,limit:m}});},[C]),it=useCallback(()=>{H(w=>w+1),(f$1?d$1(f$1):Promise.resolve()).catch(()=>{}).then(()=>N());},[f$1,N]),lt=Array(m).fill({}),st=ht(y),s$1=tt&&(l==null||l.length===0);return ot?jsx("div",{className:"fk:flex fk:flex-col fk:h-full fk:px-4 fk:pt-3",children:jsx(a,{})}):jsxs("div",{className:"fk:flex fk:flex-col fk:h-full fk:px-4 fk:pt-3",children:[jsx(b,{}),jsxs("div",{className:"fk:flex fk:items-center fk:mb-4 fk:gap-2",children:[jsxs(b$1,{children:[jsx(c$1,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:w-4 fk:h-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:h-4"}),jsx("h2",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:dt(n?.menu?.label??n?.plural??"")}),s$1?null:jsxs("span",{className:"fk:ml-auto fk:text-sm fk:font-normal fk:text-muted-foreground",children:[i.toLocaleString()," ",i===1?"record":"records"]})]}),B?null:jsx(d$2,{columns:s$1?st:y,data:s$1?lt:l??[],entityName:n?.name??"",hasMore:rt,isLoadingMore:et,pageSize:m,scrollToTopKey:F,sorting:r,onLoadMore:at,onSortingChange:nt,toolbarComponent:o=>jsx(c$2,{entityName:n?.name??"",isReloading:s$1,onReload:it,table:o})}),jsx(Outlet,{})]})}function dt(t){return t.charAt(0).toUpperCase()+t.slice(1)}function gt({entityName:t,entityNamePlural:a,row:g}){return jsx(a$1,{entityName:t,entityNamePlural:a,row:g})}function ht(t$1){return t$1.map(a=>({...a,cell:()=>jsx(t,{className:"fk:h-4 fk:w-full",style:{marginTop:"7px",marginBottom:"6px"}})}))}export{Mt as List};//# sourceMappingURL=list-UMMVRYVD.js.map
2
+ //# sourceMappingURL=list-UMMVRYVD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/apps/desk/list.tsx"],"names":["pageSize","defaultSort","List","entityName","useParams","search","useLocation","entityId","scope","useAppContext","schemaErrorMessage","useGraphQLError","currentProject","currentProjectId","useConfig","schema","entitySchema","getEntitySchema","sorting","setSorting","useState","scrollToTopKey","setScrollToTopKey","sortedEntityName","setSortedEntityName","columnsDefinition","useGridColumnsDefinition","row","dataRowActions","graphqlSort","useMemo","primarySort","id","desc","entry","sortNotNullWhere","getSortNotNullWhere","variables","isLoading","isLoadingMore","fetchMore","reload","count","data","isProjectDisabled","useEntityQuery","handleSortingChange","updater","rowsCount","hasMore","handleLoadMore","useCallback","handleReload","key","revalidateProjectSchema","loadingData","loadingColumns","getLoadingColumns","isInitialLoading","jsx","ProjectDisabled","jsxs","SchemaError","Tooltip","TooltipTrigger","SidebarTrigger","TooltipContent","Separator","capitalize","DataTable","table","DataTableToolbar","Outlet","str","entityNamePlural","DataTableRowActions","columns","column","Skeleton"],"mappings":"+8BAkBA,IAAMA,CAAAA,CAAW,GACXC,EAAAA,CAAc,CAAC,CAAE,UAAA,CAAY,MAAO,CAAA,CAAG,CAAE,GAAA,CAAK,MAAO,CAAC,CAAA,CAErD,SAASC,EAAAA,EAAoB,CAClC,GAAM,CAAE,MAAA,CAAQC,CAAW,CAAA,CAAIC,SAAAA,EAAU,CACnC,CAAE,MAAA,CAAAC,GAAO,CAAA,CAAIC,WAAAA,GAEbC,CAAAA,CADQ,IAAI,eAAA,CAAgBF,GAAM,CAAA,CACjB,GAAA,CAAI,IAAI,CAAA,CACzB,CAAE,KAAA,CAAAG,CAAM,CAAA,CAAIC,CAAAA,GACZ,CAAE,kBAAA,CAAAC,CAAmB,CAAA,CAAIC,GAAgB,CACzC,CAAE,cAAA,CAAAC,GAAAA,CAAgB,gBAAA,CAAAC,GAAiB,CAAA,CAAIC,CAAAA,GACvCC,CAAAA,CAASH,GAAAA,EAAgB,MAAA,EAAU,EAAC,CACpCI,CAAAA,CAAeC,GAAAA,CAAgBF,CAAAA,CAAQZ,GAAc,EAAE,CAAA,CACvD,CAACe,CAAAA,CAASC,CAAU,CAAA,CAAIC,QAAAA,CAAuB,EAAE,CAAA,CACjD,CAACC,CAAAA,CAAgBC,CAAiB,CAAA,CAAIF,QAAAA,CAAS,CAAC,CAAA,CAChD,CAACG,CAAAA,CAAkBC,CAAmB,CAAA,CAAIJ,QAAAA,CAASjB,CAAU,CAAA,CAE/DA,CAAAA,GAAeoB,CAAAA,GACjBC,EAAoBrB,CAAU,CAAA,CAC9BgB,CAAAA,CAAW,EAAE,CAAA,CAAA,CAGf,IAAMM,CAAAA,CAAoBC,IAAkD,CAC1E,gBAAA,CAAkBV,CAAAA,EAAc,UAAA,EAAc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vG,EAAE,CACJ","file":"list-UMMVRYVD.js","sourcesContent":["import { JSX, useCallback, useMemo, useState } from 'react';\nimport { useLocation, useParams, Outlet } from 'react-router-dom';\nimport type { ColumnDef, Row, SortingState, Updater } from '@tanstack/react-table';\nimport { getEntitySchema, getSortNotNullWhere } from '../../graphql-client/queries';\nimport { useAppContext } from '../../core/app-context';\nimport { useConfig } from '../../core/config/config-context';\nimport { revalidateProjectSchema } from '../../core/config/use-project-schemas';\nimport { useEntityQuery } from '../../graphql-client/use-entity-query';\nimport { useGraphQLError } from '../../graphql-client/graphql-context';\nimport { ProjectDisabled } from '../../core/error/project-disabled';\nimport { SchemaError } from '../../core/error/schema-error';\nimport { DataTable } from '../../data-grid/data-table';\nimport { DataTableRowActions } from '../../data-grid/data-table-row-actions';\nimport { DataTableToolbar } from '../../data-grid/data-table-toolbar';\nimport { useGridColumnsDefinition } from '../../data-grid/columns';\nimport type { AttributeValue } from '../../graphql-client/types';\nimport { Skeleton, SidebarTrigger, Separator, Tooltip, TooltipContent, TooltipTrigger } from '../../ui';\n\nconst pageSize = 36;\nconst defaultSort = [{ _updatedAt: 'DESC' }, { _id: 'DESC' }];\n\nexport function List(): JSX.Element {\n const { entity: entityName } = useParams();\n const { search } = useLocation();\n const query = new URLSearchParams(search);\n const entityId = query.get('id');\n const { scope } = useAppContext();\n const { schemaErrorMessage } = useGraphQLError();\n const { currentProject, currentProjectId } = useConfig();\n const schema = currentProject?.schema ?? [];\n const entitySchema = getEntitySchema(schema, entityName ?? '');\n const [sorting, setSorting] = useState<SortingState>([]);\n const [scrollToTopKey, setScrollToTopKey] = useState(0);\n const [sortedEntityName, setSortedEntityName] = useState(entityName);\n\n if (entityName !== sortedEntityName) {\n setSortedEntityName(entityName);\n setSorting([]);\n }\n\n const columnsDefinition = useGridColumnsDefinition<AttributeValue, unknown>({\n attributesSchema: entitySchema?.attributes ?? [],\n actionsComponent: (row) =>\n dataRowActions({ entityName: entitySchema?.name ?? '', entityNamePlural: entityName ?? '', row }),\n checkboxSelect: 'multiple',\n enableColumnSorting: true,\n });\n\n const graphqlSort = useMemo(() => {\n if (sorting.length === 0) {\n return defaultSort;\n }\n\n const primarySort = sorting.map(({ id, desc }) => ({ [id]: desc ? 'DESC' : 'ASC' }));\n const hasIdSort = primarySort.some((entry) => '_id' in entry);\n\n if (hasIdSort) {\n return primarySort;\n }\n\n // Tie-break so offset pages stay stable when sort values collide.\n return [...primarySort, { _id: 'DESC' }];\n }, [sorting]);\n const sortNotNullWhere = useMemo(() => {\n if (sorting.length === 0) {\n return undefined;\n }\n\n return getSortNotNullWhere(graphqlSort, entitySchema);\n }, [entitySchema, graphqlSort, sorting.length]);\n\n const variables = entityId\n ? { where: { _id: { eq: entityId } } }\n : {\n offset: 0,\n limit: pageSize,\n sort: graphqlSort,\n ...(sortNotNullWhere ? { where: sortNotNullWhere } : {}),\n };\n\n const { isLoading, isLoadingMore, fetchMore, reload, count, data, isProjectDisabled } = useEntityQuery({\n entityNamePlural: entityName ?? '',\n schema,\n scope,\n variables,\n selection: 'list',\n });\n\n function handleSortingChange(updater: Updater<SortingState>): void {\n setSorting(updater);\n }\n\n const rowsCount = data?.length ?? 0;\n const hasMore = count > 0 && rowsCount > 0 && rowsCount < count;\n\n const handleLoadMore = useCallback(() => {\n fetchMore({\n variables: {\n // Offset is tracked inside useEntityQuery from page windows; value here is ignored.\n offset: 0,\n limit: pageSize,\n },\n });\n }, [fetchMore]);\n\n const handleReload = useCallback(() => {\n setScrollToTopKey((key) => key + 1);\n // Refetch the schema first, so a field deployed outside this tab (the\n // agent, the CLI) is part of the reloaded query instead of arriving after it.\n const schemaRefresh = currentProjectId ? revalidateProjectSchema(currentProjectId) : Promise.resolve();\n\n void schemaRefresh.catch(() => undefined).then(() => reload());\n }, [currentProjectId, reload]);\n\n const loadingData = Array(pageSize).fill({});\n const loadingColumns = getLoadingColumns(columnsDefinition);\n const isInitialLoading = isLoading && (data == null || data.length === 0);\n\n if (isProjectDisabled) {\n return (\n <div className=\"fk:flex fk:flex-col fk:h-full fk:px-4 fk:pt-3\">\n <ProjectDisabled />\n </div>\n );\n }\n\n return (\n <div className=\"fk:flex fk:flex-col fk:h-full fk:px-4 fk:pt-3\">\n <SchemaError />\n <div className=\"fk:flex fk:items-center fk:mb-4 fk:gap-2\">\n <Tooltip>\n <TooltipTrigger asChild>\n <SidebarTrigger className=\"fk:-ml-1 fk:w-4 fk:h-4\" />\n </TooltipTrigger>\n <TooltipContent>Toggle Sidebar</TooltipContent>\n </Tooltip>\n <Separator orientation=\"vertical\" className=\"fk:h-4\" />\n <h2 className=\"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight\">\n {capitalize(entitySchema?.menu?.label ?? entitySchema?.plural ?? '')}\n </h2>\n {!isInitialLoading ? (\n <span className=\"fk:ml-auto fk:text-sm fk:font-normal fk:text-muted-foreground\">\n {count.toLocaleString()} {count === 1 ? 'record' : 'records'}\n </span>\n ) : null}\n </div>\n {!schemaErrorMessage ? (\n <DataTable\n columns={isInitialLoading ? loadingColumns : columnsDefinition}\n data={isInitialLoading ? loadingData : (data ?? [])}\n entityName={entitySchema?.name ?? ''}\n hasMore={hasMore}\n isLoadingMore={isLoadingMore}\n pageSize={pageSize}\n scrollToTopKey={scrollToTopKey}\n sorting={sorting}\n onLoadMore={handleLoadMore}\n onSortingChange={handleSortingChange}\n toolbarComponent={(table) => (\n <DataTableToolbar\n entityName={entitySchema?.name ?? ''}\n isReloading={isInitialLoading}\n onReload={handleReload}\n table={table}\n />\n )}\n />\n ) : null}\n <Outlet />\n </div>\n );\n}\n\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\ntype DataRowActions = {\n entityName: string;\n entityNamePlural: string;\n row: Row<AttributeValue>;\n};\n\nfunction dataRowActions({ entityName, entityNamePlural, row }: DataRowActions): JSX.Element {\n return <DataTableRowActions entityName={entityName} entityNamePlural={entityNamePlural} row={row} />;\n}\n\nfunction getLoadingColumns(columns: ColumnDef<AttributeValue, unknown>[]): ColumnDef<AttributeValue, unknown>[] {\n return columns.map((column) => ({\n ...column,\n cell: () => <Skeleton className=\"fk:h-4 fk:w-full\" style={{ marginTop: '7px', marginBottom: '6px' }} />,\n }));\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import'./index.css';import {f as f$3,b as b$7,c as c$4,d as d$2,e as e$4,g as g$4}from'./chunk-CSUHZFEP.js';import {x,a,b as b$4,d,c as c$3,y,C,D,B,g as g$2,h as h$1,i,f as f$2,z,I,E,H,e as e$3,F}from'./chunk-JAPZBEBZ.js';import {a as a$5}from'./chunk-5AJXR47U.js';import {a as a$4}from'./chunk-QSTWBKPN.js';import {c as c$2,a as a$1,b as b$5,e as e$2,d as d$1,g as g$6,i as i$1,h as h$2}from'./chunk-KN7OJFEX.js';import {a as a$2}from'./chunk-54AXLGAK.js';import {b as b$8,d as d$4}from'./chunk-5LGIALCK.js';import {f,g,e as e$7,c as c$6,d as d$5}from'./chunk-U6VZY3V2.js';import'./chunk-GSGPULRL.js';import'./chunk-2NXQF2F7.js';import {c as c$1}from'./chunk-CAZ6EUR2.js';import {b}from'./chunk-V7C4EHK3.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import {f as f$4}from'./chunk-HZOD2HOF.js';import {g as g$3}from'./chunk-WPCPL2TQ.js';import {b as b$6}from'./chunk-5CVDMZUI.js';import {$,aa as aa$1,da,ea,ba as ba$1,fa,O,f as f$1,na,ha as ha$1,ia as ia$1,ja,ab,bb,db,qa,s,e as e$5,_,la as la$1,t as t$1,u,v as v$1}from'./chunk-DGIY4SKN.js';import {e,g as g$1,h,j,o,t,q,r,s as s$1,k}from'./chunk-SZEGGBOC.js';import {b as b$1,v,w,x as x$1,m,o as o$1,p,q as q$1,r as r$1,t as t$2}from'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import {a as a$3,d as d$3,c as c$5,e as e$6,g as g$5}from'./chunk-HDOIOXMP.js';import {b as b$3,c,e as e$1}from'./chunk-USNXQOMJ.js';import {b as b$2}from'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {useState,useRef,useMemo,useCallback,useEffect,useTransition,Fragment as Fragment$1,useId}from'react';import {formatDistance,format}from'date-fns';import {Ellipsis,Pencil,Trash2,Plus,ArrowLeft,LoaderCircle,Play,XIcon,TriangleAlertIcon,ZapIcon,BotIcon,Search,X,CoinsIcon,BrainIcon,Trash2Icon,LoaderCircleIcon,GraduationCapIcon,WrenchIcon,Settings2Icon,BellIcon,ClockIcon,WebhookIcon,DatabaseZapIcon,CircleCheckBigIcon,RefreshCwIcon,PlusIcon,ChevronDownIcon,LockIcon,CheckIcon,ChevronsUpDownIcon,CopyIcon,KeyRoundIcon}from'lucide-react';import {useNavigate,Link,useParams}from'react-router-dom';import {useReactTable,getCoreRowModel}from'@tanstack/react-table';import De,{useSWRConfig}from'swr';import It from'swr/infinite';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {CronExpressionParser}from'cron-parser';var Ha=[{kind:"approval_request",label:"Approval requests"},{kind:"automation_failure",label:"Automation failures"},{kind:"automation_result",label:"Automation results"},{kind:"monitor_event",label:"Chat monitors"},{kind:"question",label:"Agent questions"}];function Vo({checked:t,disabled:n,label:o,onCheckedChange:i}){let l=useId();return jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-3",children:[jsx("label",{className:"fk:text-sm",htmlFor:l,children:o}),jsx(_,{checked:t,disabled:n,id:l,onCheckedChange:i})]})}function Oo(){let{mode:t}=f$4(),{isLoaded:n,mutate:o,preferences:i}=g$6(),[l,k]=useState(false);async function f(c){k(true);try{await o(h$2(c),{optimisticData:{preferences:c},rollbackOnError:!0});}catch{qa.error("Unable to save your notification settings.");}finally{k(false);}}function v(c,p){let d=new Set(i.desktopMutedKinds);p?d.delete(c):d.add(c),f({...i,desktopMutedKinds:[...d]});}return jsxs(t$1,{children:[jsx(u,{asChild:true,children:jsx(b$2,{"aria-label":"Notification settings",className:"fk:ml-auto",size:"icon",variant:"ghost",children:jsx(Settings2Icon,{className:"fk:size-4"})})}),jsxs(v$1,{align:"end",className:"fk:w-80 fk:space-y-4",children:[jsxs("div",{className:"fk:space-y-2",children:[jsx("p",{className:"fk:text-sm fk:font-medium",children:"Desktop notifications"}),jsxs("p",{className:"fk:text-xs fk:text-muted-foreground",children:[t==="hosted"?"Shown while Studio is in the background, and while your browser runs with no Studio tab open.":"Shown while Studio is open in the background."," ","Activity always keeps every item."]}),Ha.map(({kind:c,label:p})=>jsx(Vo,{checked:!i.desktopMutedKinds.includes(c),disabled:l||!n,label:p,onCheckedChange:d=>v(c,d)},c))]}),jsxs("div",{className:"fk:space-y-2",children:[jsx("p",{className:"fk:text-sm fk:font-medium",children:"Email"}),jsx(Vo,{checked:i.approvalEmail,disabled:l||!n,label:"Approval requests I haven\u2019t read",onCheckedChange:c=>{f({...i,approvalEmail:c});}})]}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"These settings apply to every project you open."})]})]})}var Ya=[{label:"Enabled",value:"enabled"},{label:"Disabled",value:"disabled"}],Qa=[{label:"Project",value:"project"},{label:"Space",value:"space"},{label:"Personal",value:"personal"}];function es(t,n=300){let o,i=function(...l){o!==void 0&&clearTimeout(o),o=setTimeout(()=>{o=void 0,t.apply(this,l);},n);};return i.cancel=()=>{o!==void 0&&(clearTimeout(o),o=void 0);},i}function Uo({actions:t,isSearchLoading:n=false,onSearchChange:o,search:i,searchPlaceholder:l="Search automations...",table:k}){let f=k.getState().columnFilters.length>0||i.trim().length>0,v=k.getAllColumns().find(P=>P.id==="status"),c=k.getAllColumns().find(P=>P.id==="visibility"),[p,d]=useState(i),g=p.trim(),T=i.trim(),C=g.length>0&&(n||g!==T),j=useRef(o);j.current=o;let A=useMemo(()=>es(P=>{j.current(P);},300),[]);useEffect(()=>{d(i);},[i]),useEffect(()=>()=>{A.cancel();},[A]);function x(){A.cancel(),d(""),o("");}function b(){k.resetColumnFilters(),x();}return jsx("div",{className:"fk:flex fk:w-full fk:min-w-0",children:jsxs(w,{className:"fk:w-0 fk:min-w-0 fk:flex-1 fk:whitespace-nowrap fk:-ml-0.75",children:[jsxs("div",{className:"fk:flex fk:w-full fk:items-center fk:justify-between fk:gap-3 fk:p-0.75 fk:pb-2.5",children:[jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs("div",{className:"fk:relative",children:[C?jsx(LoaderCircle,{className:"fk:absolute fk:left-2 fk:top-2 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50 fk:animate-spin"}):jsx(Search,{className:"fk:absolute fk:left-2 fk:top-2 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50"}),jsx(s,{className:"fk:h-8 fk:w-37.5 fk:lg:w-70 fk:px-7 fk:text-sm",name:"search-automations",placeholder:l,value:p,onChange:P=>{let{value:F}=P.target;if(d(F),F.trim().length===0){A.cancel(),o("");return}A(F.trim());}}),p?jsx(b$2,{"aria-label":"Clear search",className:"fk:absolute fk:right-1 fk:top-1 fk:h-6 fk:w-6 fk:text-muted-foreground fk:hover:text-foreground fk:hover:bg-foreground/10 fk:cursor-pointer fk:rounded-full fk:bg-transparent fk:corner-squircle",onClick:x,type:"button",children:jsx(X,{className:"fk:h-4 fk:w-4"})}):null]}),v?jsx(a$2,{column:v,options:Ya,title:"Status"}):null,c?jsx(a$2,{column:c,options:Qa,title:"Visibility"}):null,f?jsxs(b$2,{className:"fk:h-8 fk:px-2 fk:lg:px-3",onClick:b,variant:"ghost",children:["Reset",jsx(X,{className:"fk:ml-2 fk:h-4 fk:w-4"})]}):null]}),t?jsx("div",{className:"fk:ml-auto fk:flex fk:shrink-0 fk:items-center fk:gap-3",children:t}):null]}),jsx(x$1,{orientation:"horizontal"})]})})}function Sn(t,n,o){return (o??[]).some(i=>i.toLowerCase().includes(n.trim().toLowerCase()))?1:0}function Xt({disabled:t,emptyText:n,footer:o,items:i,searchPlaceholder:l,triggerLabel:k="Attach",onToggle:f}){let[v,c]=useState(false),p$1=useRef(null);return jsxs(t$1,{open:v,onOpenChange:c,children:[jsx(u,{asChild:true,children:jsxs(b$2,{disabled:t,size:"sm",type:"button",variant:"outline",children:[k,jsx(ChevronDownIcon,{className:"fk:ml-1 fk:size-4"})]})}),jsx(v$1,{align:"end",className:"fk:w-72 fk:p-0",onOpenAutoFocus:d=>{d.preventDefault(),p$1.current?.focus({preventScroll:true});},children:jsxs(m,{filter:Sn,children:[jsx(o$1,{placeholder:l,ref:p$1}),jsxs(p,{className:"fk:max-h-72",children:[jsx(q$1,{children:n}),jsx(r$1,{children:i.map(d=>jsxs(t$2,{disabled:!!d.lockedHint,title:d.lockedHint,value:d.id,keywords:[d.label],onSelect:()=>f(d.id,!d.attached),children:[d.lockedHint?jsx(LockIcon,{className:"fk:size-4"}):jsx(CheckIcon,{className:d.attached?"fk:size-4":"fk:size-4 fk:opacity-0"}),jsx("span",{className:"fk:truncate",children:d.label}),d.badge?jsx(b$1,{className:"fk:ml-auto fk:py-0 fk:text-[10px]",variant:"secondary",children:d.badge}):null]},d.id))})]}),o]})})]})}function Xo(t){return t==="project"?"Project":"Personal"}function Tt(t,n){return t.connections.filter(o=>o.scope===n&&o.status==="connected")}function In(t,n){if(!n)return null;let o=Tt(t,n.connectionMode);return n.connectionId?o.find(i=>i.id===n.connectionId)??null:o.find(i=>i.isPrimary)??null}function Nt(t){return t?t.connectionId?`account:${t.connectionId}`:`primary:${t.connectionMode}`:""}function Pn({ariaLabel:t,disabled:n,plugin:o,scopes:i,value:l,onChange:k}){let f=[];for(let c of i){let p=Tt(o,c),d=p.find(T=>T.isPrimary),[g]=p;if(p.length===1&&g){let T=l?.connectionMode===c&&l.connectionId===g.id;f.push({choice:{connectionMode:c,connectionId:T||!g.isPrimary?g.id:null},label:`${Xo(c)} \xB7 ${g.displayName}`});continue}d&&f.push({choice:{connectionMode:c,connectionId:null},label:`Primary ${c} account (${d.displayName})`});for(let T of p)f.push({choice:{connectionMode:c,connectionId:T.id},label:`${Xo(c)} \xB7 ${T.displayName}`});}let v=Nt(l);return jsxs(a$3,{disabled:n,value:f.some(c=>Nt(c.choice)===v)?v:"",onValueChange:c=>{let p=f.find(d=>Nt(d.choice)===c);p&&k(p.choice);},children:[jsx(d$3,{"aria-label":t,className:"fk:w-fit fk:max-w-full",size:"sm",children:jsx(c$5,{placeholder:"Select account"})}),jsx(e$6,{children:f.map(c=>jsx(g$5,{value:Nt(c.choice),children:c.label},Nt(c.choice)))})]})}var wn=2;function Go(t){return t.scopes.filter(n=>n==="project"||t.allowPersonal)}function us(t){let n=Go(t),o=n.includes("personal")&&(!n.includes("project")||Tt(t,"project").length===0&&Tt(t,"personal").length>0);return {pluginId:t.id,enabled:true,connectionMode:o?"personal":"project",connectionId:null,allTools:true,selectedTools:[],deliveryEnabled:false,channels:[]}}function ds(t,n){return `${encodeURIComponent(t)}:${encodeURIComponent(n)}`}function ms(t){return decodeURIComponent(t.slice(t.indexOf(":")+1))}function ks(t){let n=t.map(ms),o=n.slice(0,wn).join(", ");return n.length>wn?`${o} +${n.length-wn} more`:o}function ps({canManage:t,disabled:n,plugin:o$1,projectId:i,usage:l,onChange:k,onRemove:f$1}){let v$1=Go(o$1),c=v$1.some(w=>Tt(o$1,w).length>0),p=v$1.includes(l.connectionMode)?{connectionMode:l.connectionMode,connectionId:l.connectionId}:null,d=In(o$1,p),{data:g,error:T}=De(d?`/api/flexkit/${i}/plugin-connections/${d.id}/tools`:null,f),C=(g?.servers??[]).flatMap(w=>w.tools.map(H=>({key:ds(w.name,H.name),entry:H}))),j$1=(g?.servers??[]).flatMap(w=>w.error?[w.error]:[]),A=l.allTools!==false,x=n||!o$1.enabled,b=w=>k({...l,allTools:false,selectedTools:w,enabled:w.length>0}),P=()=>k({...l,allTools:true,selectedTools:[],enabled:true}),F=w=>({...l,connectionMode:w.connectionMode,connectionId:w.connectionId,selectedTools:[],enabled:A}),{mutate:S}=useSWRConfig(),[_,M]=useState(false),B=async w=>{M(true);try{if(!await d$4(d$5(i),o$1,w))return;await S(`/api/flexkit/${i}/plugins`),k(F({connectionMode:w,connectionId:null}));}catch(H){qa.error(H instanceof Error?H.message:`Unable to connect ${o$1.name}.`);}finally{M(false);}},U=null;return o$1.enabled?c?p?d?T||j$1.length?U={text:j$1[0]??"Unable to load tools. Reconnect or try again.",tone:"warning"}:A?U={text:"All tools",tone:"muted"}:l.selectedTools.length===0?U={text:"No tools selected, so the agent cannot use this plugin yet.",tone:"warning"}:U={text:ks(l.selectedTools),tone:"muted"}:U={text:p.connectionId?"The selected account is no longer connected.":`The primary ${p.connectionMode} account needs reconnecting.`,tone:"warning"}:U={text:"Select an account.",tone:"warning"}:U={text:`Connect ${o$1.name} to use its tools.`,tone:"warning"}:U={text:"Disabled by project policy.",tone:"warning"},jsxs(Fragment,{children:[jsxs("div",{className:"fk:m-1.5 fk:flex fk:flex-wrap fk:items-center fk:justify-between fk:gap-x-3 fk:gap-y-2 fk:rounded-md fk:px-1.25 fk:py-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-2.5",children:[jsx(a$4,{className:"fk:size-5 fk:self-start fk:rounded",src:o$1.logoUrl}),jsxs("div",{className:"fk:min-w-0",children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:o$1.name}),jsx("p",{className:U.tone==="warning"?"fk:truncate fk:text-xs fk:text-warning":"fk:truncate fk:text-xs fk:text-muted-foreground",children:U.text}),l.connectionMode==="personal"&&l.enabled?jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Using your account makes this automation personal."}):null]})]}),jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-1.5",children:[c?jsxs(Fragment,{children:[jsx(Pn,{ariaLabel:`${o$1.name} account`,disabled:x,plugin:o$1,scopes:v$1,value:p,onChange:w=>{w.connectionMode===l.connectionMode&&w.connectionId===l.connectionId||k(F(w));}}),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsxs(b$2,{disabled:x||!d||!g,size:"sm",type:"button",variant:"outline",children:[A?"All tools":l.selectedTools.length?`Tools (${l.selectedTools.length})`:"Select tools",jsx(ChevronDownIcon,{className:"fk:ml-1 fk:size-4"})]})}),jsxs(h,{align:"end",className:"fk:max-h-80 fk:w-80 fk:overflow-y-auto",children:[jsxs(j,{className:"fk:items-start",onSelect:w=>{w.preventDefault(),A?b(C.map(H=>H.key)):P();},children:[jsx(CheckIcon,{className:A?"fk:mt-0.5 fk:size-4":"fk:mt-0.5 fk:size-4 fk:opacity-0"}),jsxs("span",{className:"fk:min-w-0",children:[jsx("span",{className:"fk:block",children:"All tools (recommended)"}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Includes tools added later. Uncheck to pick specific ones."})]})]}),jsx(o,{}),C.map(({key:w,entry:H})=>{let $=A||l.selectedTools.includes(w);return jsxs(j,{className:"fk:items-start",onSelect:he=>{he.preventDefault();let q=A?C.map(be=>be.key):l.selectedTools;b($?q.filter(be=>be!==w):[...q,w]);},children:[jsx(CheckIcon,{className:$?"fk:mt-0.5 fk:size-4":"fk:mt-0.5 fk:size-4 fk:opacity-0"}),jsxs("span",{className:"fk:min-w-0",children:[jsx("span",{className:"fk:block",children:H.name}),H.description?jsx("span",{className:"fk:line-clamp-2 fk:text-xs fk:text-muted-foreground",children:H.description}):null]})]},w)}),g&&C.length===0?jsx(j,{disabled:true,children:"This account exposes no tools."}):null]})]})]}):jsx(a$5,{busy:_||n,canManage:t,plugin:o$1,onConnect:w=>{B(w);}}),jsx(b$2,{"aria-label":`Remove ${o$1.name} from automation`,disabled:n,size:"icon",type:"button",variant:"ghost",onClick:f$1,children:jsx(Trash2Icon,{className:"fk:size-4"})})]})]}),jsx(v,{})]})}function gs({disabled:t,plugins:n,onAdd:o}){let[i,l]=useState(false),k=useRef(null);return jsxs(t$1,{open:i,onOpenChange:l,children:[jsx(u,{asChild:true,children:jsxs("button",{className:"fk:m-1.5 fk:flex fk:w-[calc(100%-0.75rem)] fk:cursor-pointer fk:items-center fk:gap-2.5 fk:rounded-md fk:px-1.25 fk:py-1.5 fk:text-left fk:text-sm fk:text-muted-foreground fk:hover:bg-muted fk:hover:text-foreground disabled:fk:cursor-not-allowed disabled:fk:opacity-50 fk:corner-squircle",disabled:t||n.length===0,type:"button",children:[jsx(PlusIcon,{className:"fk:size-5"}),"Plugin tools"]})}),jsx(v$1,{align:"start",className:"fk:w-72 fk:p-0",onOpenAutoFocus:f=>{f.preventDefault(),k.current?.focus({preventScroll:true});},children:jsxs(m,{filter:Sn,children:[jsx(o$1,{placeholder:"Search plugins\u2026",ref:k}),jsxs(p,{children:[jsx(q$1,{children:"No plugins found."}),jsx(r$1,{children:n.map(f=>jsxs(t$2,{value:f.id,keywords:[f.name],onSelect:()=>{o(f),l(false);},children:[jsx(a$4,{className:"fk:size-5 fk:rounded",src:f.logoUrl}),jsx("span",{className:"fk:truncate",children:f.name}),f.connections.some(v=>v.status==="connected")?null:jsx("span",{className:"fk:ml-auto fk:text-xs fk:text-muted-foreground",children:"Not connected"})]},f.id))})]})]})})]})}function Zo({projectId:t,value:n,disabled:o,onChange:i}){let{data:l,error:k}=De(`/api/flexkit/${t}/plugins`,f),f$1=(l?.plugins??[]).filter(p=>p.capabilities.agentTools),v=new Map(f$1.map(p=>[p.id,p])),c=f$1.filter(p=>p.enabled&&!n.some(d=>d.pluginId===p.id));return jsxs(Fragment,{children:[n.map(p=>{let d=v.get(p.pluginId);return d?jsx(ps,{disabled:o,canManage:l?.canManage??false,plugin:d,projectId:t,usage:p,onChange:g=>i(n.map(T=>T.pluginId===d.id?g:T)),onRemove:()=>i(n.filter(g=>g.pluginId!==d.id))},p.pluginId):null}),k?jsx("p",{className:"fk:mx-3 fk:text-xs fk:text-warning",role:"alert",children:"Unable to load plugins. Your existing selections are preserved."}):null,jsx(gs,{disabled:o||!l,plugins:c,onAdd:p=>i([...n,us(p)])})]})}var Kt=["slack","teams"],oa=["create","update","delete"],pa="0 * * * *",ws="0 9 * * *",As="0 9 * * 1",Is="0 9 1 * *",Ps=[{label:"Monday",value:1},{label:"Tuesday",value:2},{label:"Wednesday",value:3},{label:"Thursday",value:4},{label:"Friday",value:5},{label:"Saturday",value:6},{label:"Sunday",value:0}],Ms=Array.from({length:24},(t,n)=>({label:`${n.toString().padStart(2,"0")}:00`,value:n})),aa={automation_run:"a run of",bulk_action:"a bulk action of",schema_deploy:"a schema deployment"},sa={any:"finishes",failed:"fails",succeeded:"succeeds"},Rs=[{label:"=",value:"eq"},{label:"\u2260",value:"neq"},{label:">",value:"gt"},{label:"\u2265",value:"gte"},{label:"<",value:"lt"},{label:"\u2264",value:"lte"},{label:"contains",value:"contains"},{label:"exists",value:"exists"}],Ln=5,Dn=1440,Es=15,Mn="__any__";function Ls(t){return !t.instructions&&!t.model&&!t.name&&!t.plugins&&!t.space&&Object.keys(t.toolErrors).length===0&&Object.keys(t.triggerErrors).length===0}function ia(t){return t.some(n=>n.enabled&&n.connectionMode==="personal")}function Xe({id:t,message:n}){return n?jsxs("p",{className:"fk:flex fk:items-start fk:text-sm fk:text-warning fk:gap-1",id:t,role:"alert",children:[jsx(TriangleAlertIcon,{className:"fk:size-4 fk:shrink-0 fk:mt-0.5"}),n]}):null}function ft(){return crypto.randomUUID()}function Ds(t){return (t?.triggers??[]).map(n=>({...n,key:n.id??ft()}))}function zs(t){return t.connected&&t.connectionLabel?`While your local runtime (${t.connectionLabel}) is connected, manually running this automation uses its custom tools so you can test them.`:t.connected?"While `flexkit dev` is connected, manually running this automation uses the custom tools from your local runtime so you can test them.":t.origin?`Using ${t.origin}`:t.tools.length===0?"":"Registered in this project"}function Fs(){return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}function _s(){let t=crypto.getRandomValues(new Uint8Array(24));return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}function Bs(t){if(t===pa)return {kind:"hourly"};let n=/^0 (\d{1,2}) \* \* \*$/.exec(t);if(n)return {hour:Number(n[1]),kind:"daily"};let o=/^0 (\d{1,2}) \* \* ([0-6])$/.exec(t);return o?{day:Number(o[2]),hour:Number(o[1]),kind:"weekly"}:{kind:"custom"}}function ga(t,n,o){try{let i=CronExpressionParser.parse(t,{tz:n});return Array.from({length:o},()=>i.next().toDate())}catch{return []}}function va(t,n){return new Intl.DateTimeFormat("en-US",{day:"numeric",hour:"numeric",minute:"2-digit",month:"short",timeZone:n,weekday:"short"}).format(t)}function ha(t,n){let o=t.trim();if(!o)return "Cron expression is required";let i=o.split(/\s+/).length;if(i<5||i>6)return `Expected 5 fields (min hour day month weekday), got ${i.toString()}`;try{return CronExpressionParser.parse(o,{tz:n}),null}catch{return "Invalid cron expression"}}function js(t,n,o){let i=t.filter(k=>!k.deprecated);if(n!=="edit"||!o)return i;let l=c$4(t,o);return l?.deprecated?[l,...i.filter(k=>b$7(k)!==o)]:l?i:[{deprecated:true,effort:null,efforts:[],id:o,kind:"model",name:o},...i]}function zn(t){return `${t.teamId??""}:${t.id}`}function $s(t,n){let o={};for(let i of [...t,...n])o[zn(i)]=i;return Object.values(o)}function la(t,n){return {...t,availableChannels:t.channels,channelsLoaded:!t.connected,enabled:t.connected&&n==="edit"&&t.enabled,loadingChannels:false}}function Vs(t,n){return {slack:la(t.providers.slack,n),teams:la(t.providers.teams,n)}}function Os({channels:t,disabled:n,loading:o,onChange:i,onRefresh:l,provider:k,value:f}){let[v,c]=useState(false),[p,d]=useState(""),g=useRef(null),T=new Set(f.map(b=>b.id)),C=k==="slack"?"Slack":"Teams",j=t.filter(b=>b.name.toLowerCase().includes(p.toLowerCase()));useEffect(()=>{if(!v)return;function b(F){let{target:S}=F;!(S instanceof Node)||g.current?.contains(S)||c(false);}function P(F){F.key==="Escape"&&c(false);}return document.addEventListener("pointerdown",b),document.addEventListener("keydown",P),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",P);}},[v]);function A(b){if(T.has(b.id)){i(f.filter(P=>P.id!==b.id));return}i([...f,b]);}function x(b){i(f.filter(P=>P.id!==b));}return jsxs("div",{className:"fk:relative",ref:g,children:[jsxs(b$2,{"aria-expanded":v,className:"fk:h-auto fk:min-h-8 fk:w-full fk:max-w-100 fk:justify-between fk:bg-muted/60 fk:px-3 fk:py-1 hover:fk:border-secondary fk:dark:bg-muted/30",disabled:n,role:"combobox",type:"button",variant:"outline",onClick:()=>c(b=>!b),children:[jsx("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:gap-1",children:f.length===0?jsx("span",{className:"fk:text-muted-foreground",children:o?`Loading ${C} channels...`:`Select ${C} channels`}):f.map(b=>jsxs(b$1,{className:"fk:rounded-sm fk:bg-accent fk:text-xs fk:corner-squircle",variant:"secondary",onClick:P=>{P.stopPropagation(),x(b.id);},children:[b.name,jsx(XIcon,{className:"fk:ml-1 fk:size-3 fk:cursor-pointer"})]},zn(b)))}),jsx(ChevronsUpDownIcon,{className:"fk:size-4 fk:shrink-0 fk:opacity-50"})]}),v?jsxs("div",{className:"fk:absolute fk:z-50 fk:mt-1 fk:w-full fk:max-w-100 fk:rounded-md fk:border fk:bg-popover fk:p-0 fk:text-popover-foreground fk:shadow-md fk:corner-squircle",children:[jsx("div",{className:"fk:border-b fk:p-2",children:jsx(s,{className:"fk:h-8",placeholder:`Search ${C} channels...`,value:p,onChange:b=>d(b.target.value)})}),jsx("div",{className:"fk:max-h-56 fk:overflow-auto fk:p-1",children:j.length>0?j.map(b=>jsxs(b$2,{className:"fk:h-auto fk:w-full fk:justify-start fk:rounded-sm fk:px-2 fk:py-1.5 fk:font-normal fk:corner-squircle",type:"button",variant:"ghost",onClick:()=>A(b),children:[jsx(CheckIcon,{className:`fk:mr-2 fk:size-4 ${T.has(b.id)?"fk:opacity-100":"fk:opacity-0"}`}),b.name]},zn(b))):jsx("div",{className:"fk:px-2 fk:py-6 fk:text-center fk:text-sm fk:text-muted-foreground",children:o?"Loading channels...":"No channels found."})}),jsx("div",{className:"fk:border-t fk:border-border fk:p-2",children:jsx(b$2,{className:"fk:h-8 fk:w-full fk:justify-start fk:text-xs",disabled:o,type:"button",variant:"ghost",onClick:l,children:o?jsxs(Fragment,{children:[jsx(LoaderCircleIcon,{className:"fk:mr-2 fk:size-3 fk:animate-spin"}),"Refreshing channels..."]}):jsxs(Fragment,{children:[jsx(RefreshCwIcon,{className:"fk:mr-2 fk:size-3"}),"Refresh channels"]})})})]}):null]})}function Wt({cron:t,timezone:n}){let[o]=ga(t,n,1);return o?jsxs("span",{className:"fk:text-sm fk:text-muted-foreground",children:["Next run ",va(o,n)]}):null}function ra({onChange:t,value:n}){return jsxs(a$3,{value:n.toString(),onValueChange:o=>t(Number(o)),children:[jsx(d$3,{"aria-label":"Hour",className:"fk:h-7 fk:w-fit fk:gap-1 fk:border-transparent fk:bg-background/90 fk:px-2 fk:py-0 fk:text-sm fk:shadow-sm hover:fk:border-border",size:"sm",children:jsx(c$5,{})}),jsx(e$6,{children:Ms.map(o=>jsx(g$5,{value:o.value.toString(),children:o.label},o.value))})]})}function qs({onChange:t,value:n}){return jsxs(a$3,{value:n.toString(),onValueChange:o=>t(Number(o)),children:[jsx(d$3,{"aria-label":"Day of week",className:"fk:h-7 fk:w-fit fk:gap-1 fk:border-transparent fk:bg-background/90 fk:px-2 fk:py-0 fk:text-sm fk:shadow-sm hover:fk:border-border",size:"sm",children:jsx(c$5,{})}),jsx(e$6,{children:Ps.map(o=>jsx(g$5,{value:o.value.toString(),children:o.label},o.value))})]})}function Js({onChange:t,timezone:n,value:o}){let[i,l]=useState(false),k=useRef(null),f=ha(o,n),v=f?[]:ga(o,n,3);return useEffect(()=>{if(!i)return;function c(d){let{target:g}=d;!(g instanceof Node)||k.current?.contains(g)||l(false);}function p(d){d.key==="Escape"&&l(false);}return document.addEventListener("pointerdown",c),document.addEventListener("keydown",p),()=>{document.removeEventListener("pointerdown",c),document.removeEventListener("keydown",p);}},[i]),jsxs("div",{className:"fk:relative",ref:k,children:[jsxs(b$2,{className:"fk:h-auto fk:gap-1.5 fk:bg-background/90 fk:px-2 fk:py-1 fk:font-mono fk:font-normal fk:shadow-sm hover:fk:bg-accent",type:"button",variant:"ghost",onClick:()=>l(c=>!c),children:[o||"Set cron",jsx(ChevronDownIcon,{className:"fk:size-3.5 fk:opacity-50"})]}),i?jsxs("div",{className:"fk:absolute fk:z-50 fk:mt-1 fk:w-72 fk:rounded-md fk:border fk:bg-popover fk:p-3 fk:text-popover-foreground fk:shadow-md fk:corner-squircle",children:[jsxs("div",{className:"fk:mb-2 fk:text-xs fk:text-muted-foreground",children:["Cron expression (",n,")"]}),jsx(s,{className:`fk:h-8 fk:font-mono ${f?"fk:border-destructive focus-visible:fk:ring-destructive":""}`,value:o,onChange:c=>t(c.target.value)}),f?jsx("p",{className:"fk:mt-2 fk:text-xs fk:text-destructive",children:f}):jsxs("div",{className:"fk:mt-2 fk:space-y-0.5 fk:text-xs fk:text-muted-foreground",children:[jsx("p",{className:"fk:mb-1",children:"5 fields: min hour day month weekday"}),v.map(c=>jsx("p",{children:va(c,n)},c.toISOString()))]})]}):null]})}function Us({onChange:t,trigger:n}){let o=Bs(n.cron);return o.kind==="hourly"?jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"Every hour"}),jsx(Wt,{cron:n.cron,timezone:n.timezone})]}):o.kind==="daily"?jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"Every day at"}),jsx(ra,{value:o.hour,onChange:i=>t({...n,cron:`0 ${i.toString()} * * *`})}),jsx("span",{className:"fk:text-muted-foreground",children:n.timezone}),jsx(Wt,{cron:n.cron,timezone:n.timezone})]}):o.kind==="weekly"?jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"Every week on"}),jsx(qs,{value:o.day,onChange:i=>t({...n,cron:`0 ${o.hour.toString()} * * ${i.toString()}`})}),jsx("span",{children:"at"}),jsx(ra,{value:o.hour,onChange:i=>t({...n,cron:`0 ${i.toString()} * * ${o.day.toString()}`})}),jsx("span",{className:"fk:text-muted-foreground",children:n.timezone}),jsx(Wt,{cron:n.cron,timezone:n.timezone})]}):jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"Custom schedule"}),jsx(Js,{timezone:n.timezone,value:n.cron,onChange:i=>t({...n,cron:i})}),jsx("span",{className:"fk:text-muted-foreground",children:n.timezone}),jsx(Wt,{cron:n.cron,timezone:n.timezone})]})}function Hs({onChange:t,projectId:n,trigger:o}){let[i,l]=useState(false),[k,f]=useState(false),v=o.url??c$6(n,o.token);function c$1(p,d){navigator.clipboard.writeText(p).then(()=>{d(true),window.setTimeout(()=>d(false),1500);});}return jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"Webhook triggered"}),jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsxs(b$2,{className:"fk:h-auto fk:min-w-0 fk:max-w-60 fk:gap-1.5 fk:bg-background/90 fk:px-2 fk:py-1 fk:text-xs fk:font-normal fk:shadow-sm hover:fk:bg-accent",type:"button",variant:"ghost",onClick:()=>c$1(v,l),children:[jsx("span",{className:"fk:truncate",children:v}),i?jsx(CheckIcon,{className:"fk:size-3.5 fk:shrink-0"}):jsx(CopyIcon,{className:"fk:size-3.5 fk:shrink-0 fk:opacity-60"})]})}),jsx(e$1,{className:"fk:max-w-96 fk:break-all",children:v})]}),o.secret?jsxs(b$2,{className:"fk:h-7 fk:px-2.5 fk:text-xs",size:"sm",type:"button",variant:"outline",onClick:()=>c$1(`Bearer ${o.secret??""}`,f),children:[k?jsx(CheckIcon,{className:"fk:size-3.5"}):jsx(KeyRoundIcon,{className:"fk:size-3.5"}),"Copy auth header"]}):jsxs(b$2,{className:"fk:h-7 fk:px-2.5 fk:text-xs",size:"sm",type:"button",variant:"outline",onClick:()=>t({...o,secret:_s()}),children:[jsx(KeyRoundIcon,{className:"fk:size-3.5"}),"Generate auth header"]})]})}function Xs({entities:t,onChange:n,trigger:o}){function i(f){let v=o.events.includes(f)?o.events.filter(c=>c!==f):[...o.events,f];n({...o,events:oa.filter(c=>v.includes(c))});}function l(f){let v=o.entities.includes(f)?o.entities.filter(c=>c!==f):[...o.entities,f];n({...o,entities:v});}let k$1=o.entities.length>0?o.entities.join(", "):"All entities";return jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"On"}),jsx("div",{className:"fk:flex fk:items-center fk:gap-1",children:oa.map(f=>jsxs(b$2,{className:"fk:h-7 fk:px-2.5 fk:text-xs fk:capitalize",size:"sm",type:"button",variant:o.events.includes(f)?"secondary":"ghost",onClick:()=>i(f),children:[o.events.includes(f)?jsx(CheckIcon,{className:"fk:size-3"}):null,f]},f))}),jsx("span",{children:"of"}),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsxs(b$2,{className:"fk:h-7 fk:max-w-60 fk:px-2.5 fk:text-xs",size:"sm",type:"button",variant:"outline",children:[jsx("span",{className:"fk:truncate",children:k$1}),jsx(ChevronDownIcon,{className:"fk:size-3.5 fk:opacity-50"})]})}),jsx(h,{align:"start",className:"fk:max-h-64 fk:w-56 fk:overflow-auto",children:t.length===0?jsx(j,{disabled:true,children:"No entities found in the project schema"}):t.map(f=>jsx(k,{checked:o.entities.includes(f),onCheckedChange:()=>l(f),onSelect:v=>v.preventDefault(),children:f},f))})]})]})}function Ks({automationId:t,onChange:n,projectId:o,trigger:i}){let{data:l}=De(i.job==="schema_deploy"?null:g(o).automations({limit:100}),f),k=(l?.automations??[]).filter(f=>f.id!==t);return jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"When"}),jsxs(a$3,{value:i.job,onValueChange:f=>n({...i,automationId:f==="schema_deploy"?null:i.automationId,job:f}),children:[jsx(d$3,{className:"fk:h-7 fk:w-auto fk:text-xs",children:jsx(c$5,{})}),jsx(e$6,{children:Object.keys(aa).map(f=>jsx(g$5,{value:f,children:aa[f]},f))})]}),i.job==="schema_deploy"?null:jsxs(a$3,{value:i.automationId??(i.job==="bulk_action"?Mn:""),onValueChange:f=>n({...i,automationId:f===Mn?null:f}),children:[jsx(d$3,{className:"fk:h-7 fk:w-auto fk:max-w-60 fk:text-xs",children:jsx(c$5,{placeholder:"Choose an automation"})}),jsxs(e$6,{children:[i.job==="bulk_action"?jsx(g$5,{value:Mn,children:"any automation"}):null,k.map(f=>jsx(g$5,{value:f.id,children:f.name},f.id))]})]}),jsxs(a$3,{value:i.outcome,onValueChange:f=>n({...i,outcome:f}),children:[jsx(d$3,{className:"fk:h-7 fk:w-auto fk:text-xs",children:jsx(c$5,{})}),jsx(e$6,{children:Object.keys(sa).map(f=>jsx(g$5,{value:f,children:sa[f]},f))})]})]})}function Ws(t){let n=t.trim();return n==="true"||n==="false"?n==="true":n==="null"?null:n!==""&&Number.isFinite(Number(n))?Number(n):t}function Gs(t){return t===void 0?"":String(t)}function Zs({onChange:t,value:n}){let[o,i]=useState(()=>Gs(n));return jsx(s,{"aria-label":"Value",className:"fk:h-7 fk:w-32 fk:text-xs",placeholder:"10",value:o,onChange:l=>{i(l.target.value),t(Ws(l.target.value));}})}function Ys({onChange:t,trigger:n}){let o=useId(),{condition:i}=n;return jsxs("div",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-2 fk:text-sm",children:[jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx("span",{children:"Every"}),jsx(s,{"aria-label":"Minutes between checks",className:"fk:h-7 fk:w-16 fk:text-xs",max:Dn,min:Ln,type:"number",value:Number.isFinite(n.intervalMinutes)?n.intervalMinutes:"",onChange:l=>t({...n,intervalMinutes:Number.parseInt(l.target.value,10)})}),jsx("span",{children:"minutes, run when"}),jsxs(a$3,{value:i?"condition":"changed",onValueChange:l=>t({...n,condition:l==="changed"?null:{op:"gte",path:"",value:""}}),children:[jsx(d$3,{className:"fk:h-7 fk:w-auto fk:text-xs",children:jsx(c$5,{})}),jsxs(e$6,{children:[jsx(g$5,{value:"condition",children:"a value meets a condition"}),jsx(g$5,{value:"changed",children:"the result changes"})]})]})]}),i?jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx(s,{"aria-label":"Path in the result",className:"fk:h-7 fk:w-78 fk:font-mono fk:text-xs",placeholder:"data.ordersConnection.totalCount",value:i.path,onChange:l=>t({...n,condition:{...i,path:l.target.value}})}),jsxs(a$3,{value:i.op,onValueChange:l=>t({...n,condition:l==="exists"?{op:"exists",path:i.path}:{...i,op:l}}),children:[jsx(d$3,{className:"fk:h-7 fk:w-auto fk:text-xs",children:jsx(c$5,{})}),jsx(e$6,{children:Rs.map(l=>jsx(g$5,{value:l.value,children:l.label},l.value))})]}),i.op==="exists"?null:jsx(Zs,{value:i.value,onChange:l=>t({...n,condition:{...i,value:l}})})]}):null,jsx(e$5,{className:"fk:sr-only",htmlFor:o,children:"Read-only GraphQL query"}),jsx(la$1,{className:"fk:min-h-20 fk:font-mono fk:text-xs",id:o,placeholder:`query {
2
+ ordersConnection(where: { status: { eq: "pending" } }) { totalCount }
3
+ }`,value:n.query,onChange:l=>t({...n,query:l.target.value})})]})}function Qs({automationId:t,entities:n,errors:o,onChange:i,projectId:l,triggers:k}){let f=k.some(g=>g.type==="webhook");function v$1(g){i([...k,g]);}function c(g){v$1({cron:g,key:ft(),timezone:Fs(),type:"schedule"});}function p(g){i(k.map(T=>T.key===g.key?g:T));}function d(g){i(k.filter(T=>T.key!==g));}return jsxs("div",{className:"fk:rounded-lg fk:border fk:bg-muted/60 fk:dark:bg-muted/30 fk:corner-squircle",children:[k.map(g=>jsxs(Fragment$1,{children:[jsxs("div",{className:"fk:group fk:rounded-md fk:m-1.5 fk:p-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[g.type==="schedule"?jsx(ClockIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,g.type==="webhook"?jsx(WebhookIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,g.type==="entity"?jsx(DatabaseZapIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,g.type==="job"?jsx(CircleCheckBigIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,g.type==="poll"?jsx(RefreshCwIcon,{className:"fk:size-4 fk:shrink-0 fk:self-start fk:mt-2.5 fk:text-muted-foreground"}):null,g.type==="schedule"?jsx(Us,{trigger:g,onChange:p}):null,g.type==="webhook"?jsx(Hs,{projectId:l,trigger:g,onChange:p}):null,g.type==="entity"?jsx(Xs,{entities:n,trigger:g,onChange:p}):null,g.type==="job"?jsx(Ks,{automationId:t,projectId:l,trigger:g,onChange:p}):null,g.type==="poll"?jsx(Ys,{trigger:g,onChange:p}):null,jsx(b$2,{"aria-label":"Remove trigger",className:"fk:opacity-0 fk:group-hover:opacity-100",size:"icon",type:"button",variant:"ghost",onClick:()=>d(g.key),children:jsx(Trash2Icon,{className:"fk:size-4 fk:text-muted-foreground"})})]}),o[g.key]?jsx("div",{className:"fk:mt-1 fk:pl-7",children:jsx(Xe,{message:o[g.key]})}):null]},g.key),jsx(v,{className:"fk:h-4"})]},g.key)),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsxs(b$2,{className:`fk:h-auto fk:w-full fk:justify-start fk:gap-3 fk:px-3 fk:py-3 fk:text-muted-foreground hover:fk:bg-muted hover:fk:text-foreground ${k.length===0?"fk:rounded-lg fk:corner-squircle":"fk:rounded-none fk:rounded-b-lg fk:corner-squircle"}`,type:"button",variant:"ghost",children:[jsx(PlusIcon,{className:"fk:size-4"}),"Add Trigger"]})}),jsxs(h,{align:"start",className:"fk:w-56",children:[jsxs(q,{children:[jsxs(r,{children:[jsx(ClockIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Scheduled"]}),jsxs(s$1,{children:[jsx(j,{onClick:()=>c(pa),children:"Hourly"}),jsx(j,{onClick:()=>c(ws),children:"Daily"}),jsx(j,{onClick:()=>c(As),children:"Weekly"}),jsx(j,{onClick:()=>c(Is),children:"Custom (cron)"})]})]}),jsxs(j,{disabled:f,onClick:()=>v$1({key:ft(),secret:null,token:crypto.randomUUID(),type:"webhook"}),children:[jsx(WebhookIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Webhook Triggered"]}),jsxs(j,{onClick:()=>v$1({entities:[],events:["create"],key:ft(),type:"entity"}),children:[jsx(DatabaseZapIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Entity Events"]}),jsxs(j,{onClick:()=>v$1({automationId:null,job:"schema_deploy",key:ft(),outcome:"succeeded",type:"job"}),children:[jsx(CircleCheckBigIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Job Finished"]}),jsxs(j,{onClick:()=>v$1({condition:{op:"gte",path:"",value:""},intervalMinutes:Es,key:ft(),query:"",type:"poll",variables:null}),children:[jsx(RefreshCwIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Poll Condition"]})]})]})]})}function ei(){return jsxs("svg",{"aria-label":"Slack",className:"fk:mt-1 fk:size-3.5 fk:text-muted-foreground",fill:"currentColor",role:"img",viewBox:"0 0 127 127",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M27.2 80c0 7.3-5.9 13.2-13.2 13.2C6.7 93.2.8 87.3.8 80c0-7.3 5.9-13.2 13.2-13.2h13.2V80zm6.6 0c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2v33c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V80z"}),jsx("path",{d:"M47 27c-7.3 0-13.2-5.9-13.2-13.2C33.8 6.5 39.7.6 47 .6c7.3 0 13.2 5.9 13.2 13.2V27H47zm0 6.7c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H13.9C6.6 60.1.7 54.2.7 46.9c0-7.3 5.9-13.2 13.2-13.2H47z"}),jsx("path",{d:"M99.9 46.9c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H99.9V46.9zm-6.6 0c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V13.8C66.9 6.5 72.8.6 80.1.6c7.3 0 13.2 5.9 13.2 13.2v33.1z"}),jsx("path",{d:"M80.1 99.8c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V99.8h13.2zm0-6.6c-7.3 0-13.2-5.9-13.2-13.2 0-7.3 5.9-13.2 13.2-13.2h33.1c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H80.1z"})]})}function ti(){return jsxs("svg",{"aria-label":"Microsoft Teams",className:"fk:mt-1 fk:size-3.5 fk:text-muted-foreground",fill:"currentColor",role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{clipRule:"evenodd",d:"M15.5 5A3 3 0 0 1 14 7.599V7.5a2 2 0 0 0-2-2H9.541A3 3 0 1 1 15.5 5Zm6.25 1a2 2 0 1 1-4 0 2 2 0 0 1 4 0Zm-3.294 11.732A3.25 3.25 0 0 0 23 14.75v-4.361a.889.889 0 0 0-.889-.889h-3.879c.17.294.268.636.268 1V17c0 .248-.015.492-.044.732ZM8.169 19.5A5 5 0 0 0 17.5 17v-6.5a1 1 0 0 0-1-1H14v8a2 2 0 0 1-2 2H8.169Z",fillRule:"evenodd"}),jsx("path",{clipRule:"evenodd",d:"M1 17.5v-10a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1Zm6.75-6.75H9.5v-1.5h-5v1.5h1.75v4.75h1.5v-4.75Z",fillRule:"evenodd"})]})}function Zt(t,n,o){return t.visibility==="space"?n==="space"&&o!==null&&t.spaceId===o:t.visibility==="personal"?n==="personal":true}function ni(t,n,o){return t.visibility==="space"&&!Zt(t,n,o)}function oi(t,n){let o=t.spaceId?n[t.spaceId]:void 0;return o?`Only available on ${o} automations`:"Only available on space automations"}async function ai(t,n){try{return (await f(g(t).skill(n))).skill}catch(o){if(o instanceof e$7&&o.status===404)return null;throw o}}var ba=[{label:"Results that need attention (recommended)",value:"when_flagged"},{label:"Every finished run",value:"always"},{label:"Failures only",value:"failures"},{label:"Never",value:"never"}];function si(t){return ba.some(n=>n.value===t)}function Fn({api:t,automation:n,mode:o,onSaved:i,projectId:l}){let[k,f$1]=useState((n?.toolConfigs??[]).filter(s=>!["slack","teams"].includes(s.pluginId))),[v$1,c]=useState(n?.name??""),[p,d]=useState(n?.instructions??""),[g$1,T]=useState(n?.enabled??false),[C,j]=useState(null),[A,x]=useState(null),[b$3,P]=useState(n?.mutationPolicy??"require_approval"),[F,S]=useState(n?.toolAllowRules),[_$1,M]=useState(n?.notifyRule??"when_flagged"),[B,U]=useState(n?.notifyCreator??true),[w,H]=useState(n?.subscriberIds??[]),[$,he]=useState(n?.visibility??"project"),[q,be]=useState(n?.spaceId??null),[ye,Be]=useState(n?.skillIds??[]),[me,dt]=useState(n?.customToolNames??[]),[Ce,ze]=useState(()=>Ds(n)),[je,We]=useState(false),[Ge,$e]=useState(""),[R,N]=useState({instructions:false,name:false}),[E,ke]=useState(null),[Pt,mt]=useState(null),{mutate:$n}=useSWRConfig(),[kt,Vn]=useState(()=>({slack:n?.toolConfigs?.find(s=>s.pluginId==="slack")?.connectionId??null,teams:n?.toolConfigs?.find(s=>s.pluginId==="teams")?.connectionId??null})),Mt=useRef({}),On=useRef(null),{data:Ze,error:Ra}=De(`/api/flexkit/${l}/plugins`,f),qn=!!(Ze||Ra),Ea=g(l).tools(n?.id),{data:Ve,error:La}=De(Ea,f),{data:Da}=De(g(l).entities,f),{data:an}=De(g(l).spaces,f),{data:Rt}=De($==="personal"?null:g(l).members($==="space"?q:null),f),{data:oe}=De(g(l).skills({limit:100}),f),[,za]=g$3(),ae=b(),Fa=za.user?.spaces??[],Jn=(an?.spaces??[]).filter(s=>Fa.includes(s.code)),Et=Ve?.tools.models,Un=useMemo(()=>{let s=n?.modelId??"";return s?f$3(s,Et??[])??{effort:null,modelKey:s}:null},[n?.modelId,Et]),sn=C??Un?.modelKey??"",pt=useMemo(()=>js(Et??[],o,sn),[o,Et,sn]),Lt=sn||(pt[0]?b$7(pt[0]):""),Hn=c$4(pt,Lt),ln=d$2(Hn,A??(C===null?Un?.effort??null:null)),Xn=e$4(Hn),rn=Lt?g$4({effort:ln,modelKey:Lt},pt):"",Kn=useMemo(()=>new Set((oe?.skills??[]).map(s=>s.id)),[oe?.skills]),Ye=useMemo(()=>oe?ye.filter(s=>!Kn.has(s)).sort():[],[Kn,ye,oe]),_a=Ye.length>0?[l,"attached-skills",...Ye]:null,{data:Dt}=De(_a,()=>Promise.all(Ye.map(s=>ai(l,s)))),Qe=useMemo(()=>{let s={};for(let h of oe?.skills??[])s[h.id]=h;for(let h of Dt??[])h&&(s[h.id]=h);return s},[Dt,oe?.skills]),cn=useMemo(()=>{let s=(oe?.skills??[]).filter(y=>Zt(y,$,q)),h=new Set(s.map(y=>y.id));return [...ye.map(y=>Qe[y]).filter(y=>!y||h.has(y.id)?false:Zt(y,$,q)),...s]},[ye,Qe,oe?.skills,q,$]),Ba=useMemo(()=>{let s={};for(let h of an?.spaces??[])s[h.id]=h.label;return s},[an?.spaces]),fn=useMemo(()=>(oe?.skills??[]).filter(s=>ni(s,$,q)),[oe?.skills,q,$]),Fe=Ve?.tools.customTools,un=useMemo(()=>{let s={};for(let h of Fe?.tools??[])s[h.name]=h;return s},[Fe?.tools]),dn=useMemo(()=>{let s=Fe?.tools??[],h=new Set(s.map(y=>y.name));return [...me.filter(y=>!h.has(y)).map(y=>un[y]??{description:"",name:y}),...s]},[me,un,Fe?.tools]),Wn=Fe?zs(Fe):"";useEffect(()=>{if(!oe)return;let s=Ye.length>0&&Dt===void 0,h=new Set(s?[]:Ye.filter(m=>!Qe[m]));Be(m=>{let y=m.filter(D=>{if(h.has(D))return false;let Me=Qe[D];return Me?Zt(Me,$,q):true});return y.length===m.length?m:y});},[Dt,Qe,oe,q,Ye,$]);let et=ia(k),le=useMemo(()=>{let s={};for(let m of Ce){if(m.type==="schedule"){let y=ha(m.cron,m.timezone);y&&(s[m.key]=y);}m.type==="entity"&&m.events.length===0&&(s[m.key]="Select at least one event (create, update or delete)"),m.type==="job"&&m.job==="automation_run"&&!m.automationId&&(s[m.key]="Choose the automation whose runs start this one"),m.type==="poll"&&(!Number.isInteger(m.intervalMinutes)||m.intervalMinutes<Ln||m.intervalMinutes>Dn?s[m.key]=`Check every ${Ln.toString()} to ${Dn.toString()} minutes`:m.query.trim()?m.condition&&!m.condition.path.trim()&&(s[m.key]="Enter the path of the value to compare, e.g. data.ordersConnection.totalCount"):s[m.key]="Enter the read-only GraphQL query to check");}let h={};for(let m of Kt){let y=E?.[m];y?.enabled&&y.channels.length===0&&(h[m]=`Select at least one ${m==="slack"?"Slack":"Teams"} channel or remove the tool`);}return {instructions:p.trim()?"":"Instructions are required",model:rn?"":"Select a model",name:v$1.trim()?"":"Name is required",plugins:et&&$!=="personal"?"Personal plugin connections can only be used by a personal automation.":"",space:$==="space"&&!q?"Select a space":"",toolErrors:h,triggerErrors:s}},[rn,p,v$1,et,q,E,Ce,$]),mn=Ls(le),zt=R.name&&!!le.name,gt=R.instructions&&!!le.instructions;useEffect(()=>{let s=`${n?.id??""}:${o}`;!Ve?.tools||On.current===s||(On.current=s,ke(Vs(Ve.tools,o)));},[n?.id,o,Ve?.tools]);let Ft=useMemo(()=>({slack:Ze?.plugins.find(s=>s.id==="slack")??null,teams:Ze?.plugins.find(s=>s.id==="teams")??null}),[Ze]),kn=useMemo(()=>{let s=h=>{let m=Ft[h];return m?In(m,{connectionMode:"project",connectionId:kt[h]})?.id??null:null};return {slack:s("slack"),teams:s("teams")}},[kt,Ft]),pn=useCallback(async(s,h)=>{Mt.current[s]=h,ke(m=>m&&{...m,[s]:{...m[s],channelsLoadError:void 0,loadingChannels:true}});try{let m=await t.listChannels(s,h);if(Mt.current[s]!==h)return;let y=m.success?void 0:m.errorMessage??`Failed to load ${s==="slack"?"Slack":"Teams"} channels.`;ke(D=>D&&{...D,[s]:{...D[s],availableChannels:$s(D[s].channels,m.channels),channelsLoadError:y,channelsLoaded:!0,loadingChannels:!1}});}catch(m){if(Mt.current[s]!==h)return;let y=m instanceof Error?m.message:"Failed to load integration channels.";ke(D=>D&&{...D,[s]:{...D[s],channelsLoadError:y,channelsLoaded:true,loadingChannels:false}});}},[t]);useEffect(()=>{if(!(!E||!ae||!qn))for(let s of Kt){let h=E[s];h.connected&&!h.channelsLoaded&&!h.loadingChannels&&pn(s,kn[s]);}},[ae,pn,qn,kn,E]);async function ja(s){let h=Ft[s];if(h){mt(s);try{await b$8(t,h.id,"project");let y=(await $n(`/api/flexkit/${l}/plugins`))?.plugins.find(D=>D.id===h.id)?.connections.find(D=>D.scope==="project"&&D.isPrimary&&D.status==="connected");Vn(D=>({...D,[s]:null})),Gn(s,{connected:!0,enabled:!0,workspaceName:y?.displayName??null});}catch(m){qa.error(m instanceof Error?m.message:`Unable to connect ${h.name}.`);}finally{mt(null);}}}function _t(s,h){ke(m=>m&&{...m,[s]:{...m[s],...h}});}function $a(s,h){kt[s]!==h&&(Vn(m=>({...m,[s]:h})),Gn(s));}function Gn(s,h={}){Mt.current[s]=void 0,_t(s,{...h,availableChannels:[],channels:[],channelsLoaded:false,channelsLoadError:void 0,loadingChannels:false});}function Va(s){_t(s,{channels:[],enabled:false});}function Zn(s,h){Be(m=>h?m.includes(s)?m:[...m,s]:m.filter(y=>y!==s));}function Yn(s,h){dt(m=>h?m.includes(s)?m:[...m,s]:m.filter(y=>y!==s));}async function Oa(s){if(s.preventDefault(),!ae)return;if(!mn){N({instructions:true,name:true});return}We(true),$e("");let h=Kt.map(y=>{let D=E?.[y]??Ve?.tools.providers[y];return {channels:D?.channels??[],enabled:D?.enabled??false,pluginId:y,connectionMode:"project",connectionId:kt[y],selectedTools:[],deliveryEnabled:D?.enabled??false}}),m={customToolNames:me,enabled:g$1,instructions:p,modelId:rn,mutationPolicy:b$3,name:v$1,notifyCreator:B,notifyRule:_$1,skillIds:ye,subscriberIds:$==="personal"?[]:w,...F!==void 0?{toolAllowRules:F}:{},spaceId:$==="space"?q:null,toolConfigs:[...h,...k],triggers:Ce.map(({key:y,...D})=>D),visibility:$};try{let y=o==="create"||!n?await t.createAutomation(m):await t.updateAutomation(n.id,m);if(!y.success){$e(Array.isArray(y.errorMessage)?y.errorMessage.join(", "):y.errorMessage);return}qa.success(o==="create"||!n?"Automation created.":"Automation saved."),i(y.automation);}catch(y){$e(y instanceof Error?y.message:"Failed to save automation.");}finally{We(false);}}return jsxs("form",{className:"fk:max-w-4xl fk:space-y-8 fk:px-1 fk:mx-auto",onSubmit:s=>{Oa(s);},children:[Ge?jsx("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:text-destructive fk:corner-squircle",children:Ge}):null,jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",children:"Status"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-1",children:"Disabling an automation stops its schedules and ignores webhook calls and entity events"}),jsxs("div",{className:"fk:flex fk:h-10 fk:items-center fk:gap-2",children:[jsx(_,{checked:g$1,id:"automation-enabled",onCheckedChange:T}),jsx(e$5,{className:"fk:font-normal",htmlFor:"automation-enabled",children:g$1?"Active":"Inactive"})]})]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",htmlFor:"automation-name",children:"Name"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"Identifying label for this automation"}),jsx(s,{"aria-describedby":zt?"automation-name-error":void 0,"aria-invalid":zt,className:zt?"fk:border-destructive focus-visible:fk:ring-destructive":"",id:"automation-name",value:v$1,onBlur:()=>N(s=>({...s,name:true})),onChange:s=>c(s.target.value)}),zt?jsx(Xe,{id:"automation-name-error",message:le.name}):null]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",htmlFor:"automation-visibility",children:"Visibility"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"Who can see and manage this automation. Space automations are only visible to members of the selected space; personal automations are private to you."}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsxs(a$3,{value:$,onValueChange:s=>{et&&s!=="personal"||(he(s==="space"||s==="personal"?s:"project"),s!=="space"&&be(null));},children:[jsx(d$3,{"aria-label":"Visibility",className:"fk:w-fit",id:"automation-visibility",children:jsx(c$5,{})}),jsxs(e$6,{align:"start",children:[jsx(g$5,{disabled:et,value:"project",children:"Project"}),jsx(g$5,{disabled:et||Jn.length===0,value:"space",children:"Space"}),jsx(g$5,{value:"personal",children:"Personal"})]})]}),$==="space"?jsxs(a$3,{value:q??"",onValueChange:s=>{be(s||null);},children:[jsx(d$3,{"aria-label":"Space",className:"fk:w-fit",children:jsx(c$5,{placeholder:"Select a space"})}),jsx(e$6,{align:"start",children:Jn.map(s=>jsx(g$5,{value:s.id,children:s.label},s.id))})]}):null]}),et?jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"This automation uses a personal plugin connection, so project and space visibility are unavailable."}):null,le.plugins?jsx(Xe,{message:le.plugins}):null,$==="space"&&le.space?jsx(Xe,{message:le.space}):null]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",children:"Triggers"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"When this automation should run. Schedules run in your timezone; webhooks run when their URL is called."}),jsx(Qs,{automationId:n?.id,entities:Da?.entities??[],errors:le.triggerErrors,projectId:l,triggers:Ce,onChange:ze})]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",htmlFor:"automation-instructions",children:"Agent instructions"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"Natural-language instructions the agent follows on every run. Be specific about entities, conditions, and the expected outcome."}),jsxs("div",{children:[jsx("div",{className:`fk:rounded-t-md fk:border-x fk:border-t fk:bg-muted/60 fk:ring-offset-background focus-within:fk:ring-2 focus-within:fk:ring-ring focus-within:fk:ring-offset-2 fk:dark:bg-muted/30 ${gt?"fk:border-destructive":"fk:border-input"} fk:corner-squircle`,children:jsx(la$1,{"aria-describedby":gt?"automation-instructions-error":void 0,"aria-invalid":gt,className:"fk:flex fk:min-h-[160px] fk:max-h-[320px] fk:w-full fk:rounded-none fk:border-0 fk:bg-transparent fk:dark:bg-transparent fk:pb-11 fk:shadow-none focus-visible:fk:ring-0 focus-visible:fk:ring-offset-0 fk:mask-[linear-gradient(to_bottom,black_calc(100%-2.75rem),#0009_calc(100%-1.25rem),#0003_calc(100%-0.5rem),transparent)] fk:corner-squircle",id:"automation-instructions",placeholder:"Describe what the agent should do on each run, e.g. 'When a new Review is created, translate the text to English, run a sentiment analysis and store the result in the sentiment attribute...'",rows:8,value:p,onBlur:()=>N(s=>({...s,instructions:true})),onChange:s=>d(s.target.value)})}),jsx("div",{className:`fk:rounded-b-md fk:border-x fk:border-b fk:bg-muted/60 fk:dark:bg-muted/30 fk:px-2 fk:py-2 ${gt?"fk:border-destructive":"fk:border-input"} fk:corner-squircle`,children:jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsxs(a$3,{value:Lt,onValueChange:s=>{j(s),x(null);},children:[jsx(d$3,{"aria-label":"Model",className:"fk:w-fit fk:border-transparent fk:bg-background/90 fk:px-2.5 fk:py-0 fk:text-xs fk:shadow-sm hover:fk:border-border",size:"sm",children:jsx(c$5,{placeholder:"Select a model"})}),jsx(e$6,{align:"start",children:pt.map(s=>jsxs(g$5,{value:b$7(s),children:[s.name,s.deprecated?" (Legacy)":""]},b$7(s)))})]}),Xn.length>1&&ln?jsxs(a$3,{value:ln,onValueChange:x,children:[jsx(d$3,{"aria-label":"Reasoning effort",className:"fk:w-fit fk:border-transparent fk:bg-background/90 fk:px-2.5 fk:py-0 fk:text-xs fk:shadow-sm hover:fk:border-border",size:"sm",children:jsx(c$5,{placeholder:"Effort"})}),jsx(e$6,{align:"start",children:Xn.map(s=>jsx(g$5,{value:s.value,children:s.label},s.value))})]}):null]})})]}),gt?jsx(Xe,{id:"automation-instructions-error",message:le.instructions}):null,Ve&&le.model?jsx(Xe,{message:le.model}):null]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",htmlFor:"automation-mutation-policy",children:"Mutations"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"How data changes proposed by the agent are handled. With approval required, runs pause until a project member reviews a before/after preview in the Approvals inbox."}),jsxs(a$3,{value:b$3,onValueChange:s=>{P(s==="auto_approve"?"auto_approve":"require_approval");},children:[jsx(d$3,{"aria-label":"Mutation policy",className:"fk:w-fit",id:"automation-mutation-policy",children:jsx(c$5,{})}),jsxs(e$6,{align:"start",children:[jsx(g$5,{value:"require_approval",children:"Require approval (recommended)"}),jsx(g$5,{value:"auto_approve",children:"Auto-approve"})]})]}),b$3==="auto_approve"&&k.some(s=>s.enabled)?jsxs("p",{className:"fk:flex fk:items-start fk:gap-1 fk:text-xs fk:text-warning",role:"status",children:[jsx(TriangleAlertIcon,{className:"fk:mt-px fk:size-3.5 fk:shrink-0"}),"Plugin tools will run without review. Content the agent reads, such as emails or documents, could lead it to act on your connected accounts."]}):null,b$3==="require_approval"&&F&&F.length>0?jsxs("div",{className:"fk:space-y-2",children:[jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Always allowed plugin tools (approved with \u201Calways allow\u201D from the Approvals inbox):"}),jsx("ul",{className:"fk:space-y-1",children:F.map(s=>jsxs("li",{className:"fk:flex fk:items-center fk:justify-between fk:gap-2 fk:rounded-md fk:border fk:border-border fk:px-2.5 fk:py-1.5 fk:text-xs fk:corner-squircle",children:[jsxs("code",{children:[s.pluginId,": ",s.tool]}),jsx(b$2,{"aria-label":`Remove allow rule for ${s.pluginId} ${s.tool}`,size:"sm",type:"button",variant:"ghost",onClick:()=>S(h=>(h??[]).filter(m=>m!==s)),children:"Remove"})]},`${s.pluginId}/${s.server}/${s.tool}`))})]}):null]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",htmlFor:"automation-notify-rule",children:"Notifications"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"Approval requests and run results appear in Activity in Studio. Failures are always reported unless set to Never."}),jsxs(a$3,{value:_$1,onValueChange:s=>{si(s)&&M(s);},children:[jsx(d$3,{"aria-label":"Notify about runs",className:"fk:w-fit",id:"automation-notify-rule",children:jsx(c$5,{})}),jsx(e$6,{align:"start",children:ba.map(s=>jsx(g$5,{value:s.value,children:s.label},s.value))})]}),jsxs("div",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2",children:[jsx(_,{checked:B,id:"automation-notify-creator",onCheckedChange:U}),jsx(e$5,{className:"fk:font-normal",htmlFor:"automation-notify-creator",children:"Notify the creator"})]}),$==="personal"?null:jsxs("div",{className:"fk:space-y-2",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-2",children:[jsxs("div",{children:[jsx("p",{className:"fk:text-sm",children:"Subscribers"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Members who also get its notifications. Only owners and developers receive approval requests."})]}),jsx(Xt,{disabled:!ae||!Rt,emptyText:"No members match.",items:(Rt?.members??[]).map(s=>({attached:w.includes(s.id),id:s.id,label:s.displayName})),searchPlaceholder:"Search members\u2026",triggerLabel:"Add",onToggle:(s,h)=>H(m=>h?[...new Set([...m,s])]:m.filter(y=>y!==s))})]}),w.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:gap-1.5",children:w.map(s=>{let m=Rt?.members.find(y=>y.id===s)?.displayName??(Rt?"No longer has access":"Loading\u2026");return jsxs(b$1,{className:"fk:gap-1 fk:pr-1 fk:font-normal",variant:"secondary",children:[m,jsx("button",{"aria-label":`Remove subscriber ${m}`,className:"fk:cursor-pointer fk:rounded-sm fk:text-muted-foreground fk:hover:text-foreground disabled:fk:cursor-not-allowed fk:corner-squircle",disabled:!ae,type:"button",onClick:()=>H(y=>y.filter(D=>D!==s)),children:jsx(XIcon,{className:"fk:size-3"})})]},s)})}):null]})]}),jsxs("div",{className:"fk:space-y-4",children:[jsxs("div",{children:[jsx(e$5,{className:"fk:text-sm fk:font-medium",children:"Tools"}),jsx("p",{className:"fk:mb-3 fk:text-xs fk:text-muted-foreground",children:"Configure additional destinations and built-in capabilities for this automation."})]}),jsxs("div",{className:"fk:rounded-lg fk:border fk:bg-muted/60 fk:dark:bg-muted/30 fk:corner-squircle",children:[jsx("div",{className:"fk:rounded-t-lg fk:corner-squircle",children:jsxs("div",{className:"fk:m-1.5 fk:flex fk:items-start fk:justify-between fk:gap-3 fk:rounded-md fk:p-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:gap-3 fk:pb-0.5",children:[jsx(BrainIcon,{className:"fk:mt-1 fk:size-3.5 fk:text-muted-foreground"}),jsxs("div",{children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:"Memories"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Builds memory across runs to make automations smarter over time"})]})]}),jsx(b$1,{className:"fk:mt-1.5 fk:py-0 fk:text-[10px] fk:font-light fk:tracking-wide",variant:"secondary",children:"Always on"})]})}),jsx(v,{}),E?Kt.map(s=>{let h=E[s],m=s==="slack"?"Send to Slack":"Send to Microsoft Teams",y=s==="slack"?ei:ti,D=Ft[s];return jsxs(Fragment$1,{children:[jsxs("div",{className:"fk:m-1.5 fk:space-y-2 fk:rounded-md fk:p-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:gap-3",children:[jsx(y,{}),jsxs("div",{children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:m}),h.connected&&h.workspaceName?jsxs("p",{className:"fk:text-xs fk:text-muted-foreground",children:["Connected to ",h.workspaceName]}):null,h.connected?null:jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:Ze?.canManage===false?"Not connected. Ask a project owner or developer to connect it.":"Not connected"})]})]}),h.connected?h.enabled?jsx(b$2,{"aria-label":`Remove ${s==="slack"?"Slack":"Microsoft Teams"} from automation`,size:"icon",type:"button",variant:"ghost",onClick:()=>Va(s),children:jsx(Trash2Icon,{className:"fk:size-4 fk:text-muted-foreground"})}):jsx(b$2,{size:"sm",type:"button",variant:"outline",onClick:()=>_t(s,{enabled:true}),children:"Add"}):jsx(b$2,{disabled:!ae||!D?.enabled||!Ze?.canManage||Pt!==null,size:"sm",type:"button",variant:"outline",onClick:()=>{ja(s);},children:Pt===s?"Connecting\u2026":"Connect"})]}),h.connected&&h.enabled?jsxs("div",{className:"fk:space-y-2 fk:pl-7",children:[D&&D.connections.filter(Me=>Me.scope==="project"&&Me.status==="connected").length>1?jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:[jsx(e$5,{className:"fk:text-xs fk:font-medium",children:"Workspace"}),jsx(Pn,{ariaLabel:`${s==="slack"?"Slack":"Microsoft Teams"} workspace`,disabled:!ae,plugin:D,scopes:["project"],value:{connectionMode:"project",connectionId:kt[s]},onChange:Me=>$a(s,Me.connectionId)})]}):null,jsx(e$5,{className:"fk:mr-3 fk:text-xs fk:font-medium",children:"Channels"}),jsx(Os,{channels:h.availableChannels,disabled:h.loadingChannels||!ae,loading:h.loadingChannels,provider:s,value:h.channels,onChange:Me=>_t(s,{channels:Me}),onRefresh:()=>{pn(s,kn[s]);}}),h.channelsLoadError?jsxs("p",{className:"fk:flex fk:items-start fk:text-sm fk:text-warning fk:gap-1",children:[jsx(TriangleAlertIcon,{className:"fk:size-4 fk:shrink-0 fk:mt-0.5"}),h.channelsLoadError]}):null,!h.channelsLoadError&&le.toolErrors[s]?jsx(Xe,{message:le.toolErrors[s]}):null]}):null]}),jsx(v,{})]},s)}):La?jsx("p",{className:"fk:m-1.5 fk:p-1.5 fk:text-xs fk:text-warning",role:"alert",children:"Unable to load Slack and Microsoft Teams delivery. Reload the page to try again."}):jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:p-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircleIcon,{className:"fk:size-4 fk:animate-spin"}),"Loading tools..."]}),jsxs("div",{className:"fk:m-1.5 fk:space-y-2 fk:rounded-md fk:px-1.25 fk:py-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:gap-2.5",children:[jsx(GraduationCapIcon,{className:"fk:mt-px fk:size-5 fk:text-muted-foreground"}),jsxs("div",{children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:"Skills"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Attached skills are always loaded into the agent context. All other skills you can see stay discoverable by the agent when relevant."})]})]}),jsx(Xt,{disabled:!ae||cn.length===0&&fn.length===0,emptyText:"No skills match.",items:[...cn.map(s=>({id:s.id,label:s.name,attached:ye.includes(s.id),badge:s.source==="code"?"Code":void 0})),...fn.map(s=>({id:s.id,label:s.name,attached:false,badge:s.source==="code"?"Code":void 0,lockedHint:oi(s,Ba)}))],searchPlaceholder:"Search skills\u2026",onToggle:Zn})]}),oe&&cn.length===0&&fn.length===0?jsx("p",{className:"fk:pl-7 fk:text-xs fk:text-muted-foreground",children:"No attachable skills yet. Create them on the Skills tab."}):null,oe?.hasMore?jsxs("p",{className:"fk:pl-7 fk:text-xs fk:text-muted-foreground",children:["Showing the ",oe.skills.length," most recently updated skills. Attached skills outside this list are kept when you save."]}):null,ye.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:gap-1.5 fk:pl-7",children:ye.map(s=>{let h=Qe[s],m=h?.name??"Loading skill\u2026";return jsxs(b$1,{className:"fk:gap-1 fk:pr-1 fk:font-normal",variant:"secondary",children:[m,h?.source==="code"?jsx("span",{className:"fk:text-[10px] fk:uppercase",children:"Code"}):null,jsx("button",{"aria-label":h?`Detach ${h.name}`:"Detach skill",className:"fk:cursor-pointer fk:rounded-sm fk:text-muted-foreground fk:hover:text-foreground disabled:fk:cursor-not-allowed fk:corner-squircle",disabled:!ae,type:"button",onClick:()=>Zn(s,false),children:jsx(XIcon,{className:"fk:size-3"})})]},s)})}):null]}),jsx(v,{}),jsxs("div",{className:"fk:m-1.5 fk:space-y-2 fk:rounded-md fk:px-1.25 fk:py-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:gap-2.5",children:[jsx(WrenchIcon,{className:"fk:mt-px fk:size-5 fk:text-muted-foreground"}),jsxs("div",{children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:"Custom tools"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Attached custom tools can be called during a run. Tools you do not attach stay unavailable to this automation."}),Wn?jsx("p",{className:Fe?.connected?"fk:mt-1 fk:text-xs fk:text-warning":"fk:mt-1 fk:text-xs fk:text-muted-foreground",children:Wn}):null]})]}),jsx(Xt,{disabled:!ae||dn.length===0,emptyText:"No custom tools match.",items:dn.map(s=>({id:s.name,label:s.name,attached:me.includes(s.name)})),searchPlaceholder:"Search custom tools\u2026",onToggle:Yn})]}),Fe&&dn.length===0?jsx("p",{className:"fk:pl-7 fk:text-xs fk:text-muted-foreground",children:"No custom tools registered yet. Define them in flexkit.tools.ts, run `flexkit dev` or sync them from the Dashboard, then attach the ones this automation needs."}):null,me.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:gap-1.5 fk:pl-7",children:me.map(s=>{let m=un[s]?.name??s;return jsxs(b$1,{className:"fk:gap-1 fk:pr-1 fk:font-normal",variant:"secondary",children:[m,jsx("button",{"aria-label":`Detach ${m}`,className:"fk:cursor-pointer fk:rounded-sm fk:text-muted-foreground fk:hover:text-foreground disabled:fk:cursor-not-allowed fk:corner-squircle",disabled:!ae,type:"button",onClick:()=>Yn(s,false),children:jsx(XIcon,{className:"fk:size-3"})})]},s)})}):null]}),jsx(v,{}),jsx(Zo,{projectId:l,value:k,disabled:!ae,onChange:s=>{f$1(s),ia(s)&&(he("personal"),be(null));}})]})]}),jsxs("div",{className:"fk:flex fk:items-center fk:justify-end fk:gap-3",children:[mn?null:jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Complete the required fields to save"}),jsx(na,{disabled:!ae,children:jsx(b$2,{disabled:je||!mn||!ae,type:"submit",children:je?"Saving...":o==="create"?"Create automation":"Update automation"})})]})]})}var Na=25;function hi(t){return Math.max(600,t)}function bi(t){return t==="mine"||t==="team"}function Z({children:t}){return jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground fk:corner-squircle",children:t})}function yi(t){return t==="success"?"fk:bg-success/20 fk:text-success":t==="awaiting_approval"?"fk:bg-amber-500/20 fk:text-amber-600":t==="skipped"?"fk:bg-orange-500/20 fk:text-orange-700":"fk:bg-secondary fk:text-secondary-foreground"}function Aa({status:t}){return jsx(b$1,{className:`fk:border-none fk:h-4.75 fk:text-[0.6875rem] fk:leading-4.5 fk:tracking-wide ${yi(t)}`,variant:t==="success"?"default":"secondary",children:t==="awaiting_approval"?"awaiting approval":t})}function xi(t){if(t==="0 * * * *")return "Every hour";let n=/^0 (\d{1,2}) \* \* \*$/.exec(t);if(n)return `Every day at ${n[1].padStart(2,"0")}:00`;let o=/^0 (\d{1,2}) \* \* ([0-6])$/.exec(t);return o?`Every ${["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][Number(o[2])]??"week"} at ${o[1].padStart(2,"0")}:00`:t}function Ni(t){let n=t.triggers.map(o=>{if(o.type==="schedule")return xi(o.cron);if(o.type==="webhook")return "Webhook";if(o.type==="job")return o.job==="schema_deploy"?"After a deployment":o.job==="automation_run"?"After another automation":"After a bulk action";if(o.type==="poll")return `Poll every ${o.intervalMinutes.toString()} min`;let i=o.entities.length>0?o.entities.join(", "):"all entities";return `On ${o.events.join("/")} of ${i}`});return n.length===0?"Manual only":n.join(" \xB7 ")}function Ia(t){return t?!!(t.name.trim()&&t.instructions.trim()&&t.modelId.trim()):false}function Ti({projectId:t}){let{data:n}=De(g(t).creditBalance,f),o=n?.creditBalance;return o?jsx(b$2,{asChild:true,size:"sm",variant:"secondary",children:jsxs("a",{href:o.billingUrl,rel:"noopener noreferrer",target:"_blank",children:[jsx(CoinsIcon,{className:"fk:mr-2 fk:size-4"}),o.display," Credit"]})}):null}function Ci(t,n){let o=t.visibility??"project";return o==="space"?(t.spaceId?n.get(t.spaceId):void 0)??"Space":o==="personal"?"Personal":"Project"}var Pa="fk:sticky fk:top-0 fk:z-10 fk:[&_th]:sticky fk:[&_th]:top-0 fk:[&_th]:bg-muted";function Si(){return jsxs($,{children:[jsx(aa$1,{className:Pa,children:jsxs(da,{children:[jsx(ea,{children:"Automation"}),jsx(ea,{children:"Triggers"}),jsx(ea,{children:"Last run"}),jsx(ea,{className:"fk:text-center",children:"Runs"}),jsx(ea,{children:"Visibility"}),jsx(ea,{className:"fk:text-center",children:"Status"}),jsx(ea,{})]})}),jsx(ba$1,{children:Array.from({length:5},(t$1,n)=>jsxs(da,{children:[jsx(fa,{children:jsx(t,{className:"fk:h-4 fk:w-36"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4 fk:w-48"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4 fk:w-24"})}),jsx(fa,{className:"fk:text-center",children:jsx(t,{className:"fk:mx-auto fk:h-4 fk:w-8"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4.75 fk:w-16"})}),jsx(fa,{className:"fk:text-center",children:jsx(t,{className:"fk:mx-auto fk:h-4.75 fk:w-16"})}),jsx(fa,{className:"fk:text-right",children:jsx(t,{className:"fk:ml-auto fk:size-8"})})]},n))})]})}function Ta(t,n){let i=t.find(l=>l.id===n)?.value;return Array.isArray(i)?i.filter(l=>typeof l=="string"):[]}function wi(t){if(t.length===0)return;let n=t.map(o=>o==="enabled"?true:o==="disabled"?false:null).filter(o=>o!==null);if(n.length!==0)return n}function Ai(t){if(t.length===0)return;let n=t.filter(o=>o==="project"||o==="space"||o==="personal");if(n.length!==0)return n}function Hl(){let{api:t,projectId:n}=x(),o$1=useNavigate(),[i,l]=useState([]),[k,f$2]=useState(""),[v$1,c$1]=useState(""),p=b(),d=useRef(null),g$2=Ta(i,"status"),T=Ta(i,"visibility"),C=wi(g$2),j$1=Ai(T),A=i.length>0||k.trim().length>0,x$1=JSON.stringify({enabledFilter:C,search:k,visibilityFilter:j$1}),b$4=(N,E)=>!n||E&&E.hasMore===false?null:g(n).automations({enabled:C,limit:Na,offset:N*Na,search:k.trim()||void 0,visibility:j$1}),{data:P,isLoading:F,mutate:S,setSize:_,size:M}=It(b$4,f),{data:B}=De(n?g(n).spaces:null,f),U=useMemo(()=>new Map((B?.spaces??[]).map(N=>[N.id,N.label])),[B?.spaces]),w=P?.flatMap(N=>N.automations)??[],$$1=P?.[P.length-1]?.hasMore??false,he=P!==void 0&&M>P.length,q=P?.[0]?.count,be=F&&w.length===0,ye=useMemo(()=>[{id:"status",accessorKey:"enabled"},{id:"visibility",accessorKey:"visibility"}],[]),Be=useReactTable({columns:ye,data:w,getCoreRowModel:getCoreRowModel(),manualFiltering:true,onColumnFiltersChange:N=>{_(1),l(N);},state:{columnFilters:i}}),me=useRef(()=>{_(N=>N+1);}),dt=useRef($$1),Ce=useRef(he);me.current=()=>{_(N=>N+1);},dt.current=$$1,Ce.current=he;let ze=useCallback(N=>{if(!me.current||!dt.current||Ce.current)return;let E=N??d.current;if(!E)return;let{scrollHeight:ke,scrollTop:Pt,clientHeight:mt}=E;ke-Pt-mt>=hi(mt)||(Ce.current=true,me.current());},[]);useEffect(()=>{ze();},[ze,w.length,$$1,he,x$1]),useEffect(()=>{d.current?.scrollTo({top:0});},[x$1]);let je=useRef(k);je.current=k;let We=useCallback(N=>{N!==je.current&&(_(1),f$2(N));},[_]);if(!n||!t)return jsx(Z,{children:"Select a project to view automations."});async function Ge(N){if(c$1(""),!t)return;let E=await t.deleteAutomation(N.id);if(!E.success){c$1(Array.isArray(E.errorMessage)?E.errorMessage.join(", "):E.errorMessage);return}await S();}function $e(N){ze(N.currentTarget);}let R;return F&&w.length===0?R=jsx(Si,{}):w.length===0?R=jsx(Z,{children:A?"No results.":"No automations yet."}):R=jsxs($,{children:[jsx(aa$1,{className:Pa,children:jsxs(da,{children:[jsx(ea,{children:"Automation"}),jsx(ea,{children:"Triggers"}),jsx(ea,{children:"Last run"}),jsx(ea,{className:"fk:text-center",children:"Runs"}),jsx(ea,{children:"Visibility"}),jsx(ea,{className:"fk:text-center",children:"Status"}),jsx(ea,{})]})}),jsx(ba$1,{children:w.map(N=>jsxs(da,{className:"fk:cursor-pointer",onClick:()=>o$1(N.id),children:[jsx(fa,{children:jsx("span",{className:"fk:font-medium",children:N.name})}),jsx(fa,{className:"fk:text-muted-foreground",children:Ni(N)}),jsx(fa,{children:N.lastRunAt?formatDistance(new Date(N.lastRunAt),new Date,{addSuffix:true}):"Never"}),jsx(fa,{className:"fk:text-center",children:N.totalRuns}),jsx(fa,{children:jsx(b$1,{className:"fk:h-4.75 fk:text-[0.6875rem] fk:leading-4.5 fk:tracking-wide",variant:N.visibility==="personal"?"secondary":"outline",children:Ci(N,U)})}),jsx(fa,{className:"fk:text-center",children:jsx(b$1,{className:`fk:border-none fk:h-4.75 fk:text-[0.6875rem] fk:leading-4.5 fk:tracking-wide ${N.enabled?"fk:bg-success/20 fk:text-success":"fk:bg-secondary fk:text-secondary-foreground"}`,variant:N.enabled?"default":"secondary",children:N.enabled?"Enabled":"Disabled"})}),jsx(fa,{className:"fk:text-right",children:jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsx(b$2,{"aria-label":`Actions for ${N.name}`,size:"icon",type:"button",variant:"ghost",onClick:E=>{E.stopPropagation();},children:jsx(Ellipsis,{className:"fk:size-4"})})}),jsxs(h,{align:"end",className:"fk:w-40",children:[jsxs(j,{onClick:E=>{E.stopPropagation(),o$1(N.id);},children:[jsx(Pencil,{}),"Edit"]}),jsx(o,{}),jsxs(j,{disabled:!p,variant:"destructive",onClick:E=>{E.stopPropagation(),Ge(N);},children:[jsx(Trash2,{}),"Delete"]})]})]})})]},N.id))})]}),jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:gap-4 fk:pr-4",children:[jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsxs("div",{className:"fk:min-w-0 fk:flex-1",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:"Automations"}),!be&&q!==void 0?jsxs("span",{className:"fk:ml-auto fk:text-sm fk:font-normal fk:text-muted-foreground",children:[q.toLocaleString()," ",q===1?"automation":"automations"]}):null]}),jsxs("p",{className:"fk:mt-1 fk:text-sm fk:text-muted-foreground",children:["Agent-powered tasks that run on a schedule or when your data changes.",jsx(f$1,{href:"https://flexkit.io/docs/automations",children:"Learn more"})]})]})]}),v$1?jsx("div",{className:"fk:text-sm fk:text-destructive",children:v$1}):null,jsx(Uo,{actions:jsxs(Fragment,{children:[jsx(Ti,{projectId:n}),p?jsx(b$2,{asChild:true,className:"fk:h-8",size:"sm",children:jsxs(Link,{to:"new",children:[jsx(Plus,{className:"fk:mr-2 fk:size-4"}),"New Automation"]})}):jsx(na,{disabled:true,children:jsxs(b$2,{className:"fk:h-8",disabled:true,size:"sm",children:[jsx(Plus,{className:"fk:mr-2 fk:size-4"}),"New Automation"]})})]}),isSearchLoading:F&&k.trim().length>0,search:k,table:Be,onSearchChange:We}),jsxs("div",{className:"fk:relative fk:min-h-0 fk:min-w-0 fk:flex-1",children:[he?jsx("div",{"aria-hidden":true,className:"fk:pointer-events-none fk:absolute fk:top-0 fk:right-px fk:left-px fk:z-20 fk:h-0.5 fk:overflow-hidden fk:opacity-40",children:jsx("div",{className:"fk:animate-progress fk:h-full fk:w-full fk:bg-foreground"})}):null,jsx("div",{className:"fk:h-full fk:overflow-auto",onScroll:$e,ref:d,children:R})]})]})}function Xl(){let{api:t,projectId:n}=x(),o=useNavigate();return !n||!t?jsx(Z,{children:"Select a project to create automations."}):jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:mb-4 fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsx("div",{className:"fk:flex-1",children:jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:"New Automation"})})]}),jsx(b$2,{asChild:true,className:"fk:shrink-0 fk:w-fit",size:"sm",variant:"ghost",children:jsxs(Link,{relative:"path",to:"..",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"Automations"]})}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsx("div",{className:"fk:pb-6 fk:pr-4",children:jsx(Fn,{api:t,mode:"create",projectId:n,onSaved:()=>o("..",{relative:"path"})})})})]})}function Kl(){let{api:t,projectId:n}=x(),{automationId:o}=useParams(),i=useNavigate(),[l,k]=useTransition(),f$1=b(),{data:v$1,mutate:c$1}=De(n&&o?g(n).automation(o):null,f);if(!n||!t||!o)return jsx(Z,{children:"Select an automation."});if(!v$1?.automation)return jsx(Z,{children:"Loading automation..."});let p=t,d=Ia(v$1.automation)&&f$1,g$1=o;function T(){d&&k(async()=>{let C=await p.runAutomation(g$1);if(C.success&&C.runId){i(`runs/${C.runId}`);return}await c$1();});}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:mb-4 fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsx("div",{className:"fk:flex-1",children:jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:v$1.automation.name})})]}),jsxs("div",{className:"fk:flex fk:shrink-0 fk:flex-wrap fk:items-center fk:justify-between fk:gap-3 fk:pr-4",children:[jsx(b$2,{asChild:true,size:"sm",variant:"ghost",children:jsxs(Link,{to:"../automations",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"Automations"]})}),jsx(ha$1,{value:"settings",children:jsxs(ia$1,{children:[jsx(ja,{className:"text-xs",value:"settings",children:"Settings"}),jsx(ja,{className:"text-xs",value:"runs",children:jsx(Link,{to:"runs",children:"Runs"})})]})}),jsx(na,{disabled:!f$1,children:jsxs(b$2,{disabled:l||!d,size:"sm",onClick:T,children:[l?jsx(LoaderCircle,{className:"fk:mr-2 fk:size-4 fk:animate-spin"}):jsx(Play,{className:"fk:mr-2 fk:size-4"}),"Run now"]})})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsx("div",{className:"fk:pb-6 fk:pr-4",children:jsx(Fn,{api:t,automation:v$1.automation,mode:"edit",projectId:n,onSaved:C=>{C?c$1({automation:C},{revalidate:false}):c$1();}})})})]})}var tn=25;function Wl(){let{api:t,projectId:n}=x(),{automationId:o}=useParams(),i=useNavigate(),[l,k]=useTransition(),{data:f$1}=De(n&&o?g(n).automation(o):null,f),v$1=(B,U)=>!n||!o||U&&U.hasMore===false?null:g(n).automationRuns(o,B*tn,tn),{data:c$1,isLoading:p,mutate:d,setSize:g$1,size:T}=It(v$1,f),C=b();if(!n||!t||!o)return jsx(Z,{children:"Select an automation to view runs."});let j=t,A=Ia(f$1?.automation)&&C,x$1=o;function b$1(){A&&k(async()=>{let B=await j.runAutomation(x$1);if(B.success&&B.runId){i(B.runId);return}await d();});}let P=c$1?.flatMap(B=>B.runs)??[],S=c$1?.[c$1.length-1]?.hasMore??false,_=c$1!==void 0&&T>c$1.length;function M(){g$1(B=>B+1);}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:mb-4 fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsx("div",{className:"fk:flex-1",children:jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:f$1?.automation.name??"Automation"})})]}),jsxs("div",{className:"fk:flex fk:shrink-0 fk:flex-wrap fk:items-center fk:justify-between fk:gap-3 fk:pr-4",children:[jsx(b$2,{asChild:true,size:"sm",variant:"ghost",children:jsxs(Link,{to:"../automations",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"Automations"]})}),jsx(ha$1,{value:"runs",children:jsxs(ia$1,{children:[jsx(ja,{className:"text-xs",value:"settings",children:jsx(Link,{relative:"path",to:"..",children:"Settings"})}),jsx(ja,{className:"text-xs",value:"runs",children:"Runs"})]})}),jsx(na,{disabled:!C,children:jsxs(b$2,{disabled:l||!A,size:"sm",onClick:b$1,children:[l?jsx(LoaderCircle,{className:"fk:mr-2 fk:size-4 fk:animate-spin"}):jsx(Play,{className:"fk:mr-2 fk:size-4"}),"Run now"]})})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[jsx(Ma,{basePath:".",isLoading:p,runs:P}),S&&!_?jsx(on,{onVisible:M}):null,_?jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:"Loading more runs..."})]}):null]})})]})}function on({onVisible:t}){let n=useRef(null),o=useRef(t);return o.current=t,useEffect(()=>{let i=n.current;if(!i)return;let l=new IntersectionObserver(k=>{k.some(f=>f.isIntersecting)&&o.current();});return l.observe(i),()=>{l.disconnect();}},[]),jsx("div",{className:"fk:h-px",ref:n})}function jn(){return jsx($,{children:jsx(ba$1,{children:Array.from({length:5},(t$1,n)=>jsxs(da,{children:[jsx(fa,{className:"fk:py-2",children:jsx(t,{className:"fk:h-4 fk:w-28"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4 fk:w-20"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4.75 fk:w-16"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4 fk:w-full fk:max-w-md"})})]},n))})})}function Ma({basePath:t,isLoading:n=false,runs:o}){return n?jsx(jn,{}):o.length===0?jsx(Z,{children:"No runs found."}):jsx($,{children:jsx(ba$1,{children:o.map(i=>jsxs(da,{children:[jsx(fa,{className:"fk:py-2",children:jsx(Link,{className:"fk:font-medium hover:fk:underline",to:`${t}/${i.id}`,children:formatDistance(new Date(i.startedAt),new Date,{addSuffix:true})})}),jsx(fa,{className:"fk:text-muted-foreground",children:i.triggerType}),jsx(fa,{children:jsx(Aa,{status:i.status})}),jsx(fa,{className:"fk:max-w-md fk:truncate fk:text-muted-foreground",children:i.summary??""})]},i.id))})})}function Gl(){let{projectId:t$1}=x(),[n,o]=useState("team"),i=(x,b)=>!t$1||b&&!b.history.hasMore?null:g(t$1).runHistory(n,x*tn,tn),{data:l,isLoading:k,setSize:f$1,size:v}=It(i,f),c$1=l?.[0]?.history.metrics,p=l?.flatMap(x=>x.history.runs)??[],g$1=l?.[l.length-1]?.history.hasMore??false,T=l!==void 0&&v>l.length;if(!t$1)return jsx(Z,{children:"Select a project to view run history."});function C(){f$1(x=>x+1);}function j(x){!bi(x)||x===n||o(x);}let A=null;return k?A=jsx("div",{className:"fk:mb-6 fk:grid fk:shrink-0 fk:gap-3 fk:grid-cols-4 fk:pr-4",children:Array.from({length:4},(x,b)=>jsxs("div",{className:"fk:rounded-md fk:bg-muted/60 fk:p-4 fk:corner-squircle",children:[jsx(t,{className:"fk:h-4 fk:w-24"}),jsx(t,{className:"fk:mt-2 fk:h-8 fk:w-12"})]},b))}):c$1&&(A=jsxs("div",{className:"fk:mb-6 fk:grid fk:shrink-0 fk:gap-3 fk:grid-cols-4 fk:pr-4",children:[jsx(en,{title:"Successful 24h",value:c$1.successful24h}),jsx(en,{title:"Failed 24h",value:c$1.failed24h}),jsx(en,{title:"Successful 7d",value:c$1.successful7d}),jsx(en,{title:"Failed 7d",value:c$1.failed7d})]})),jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ha$1,{value:n,onValueChange:j,children:jsxs(ia$1,{children:[jsx(ja,{value:"team",children:"Team"}),jsx(ja,{value:"mine",children:"Mine"})]})})]}),A,jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[jsx(Ma,{basePath:"../automations",isLoading:k,runs:p.map(x=>({...x,id:`${x.automationId}/runs/${x.id}`}))}),g$1&&!T?jsx(on,{onVisible:C}):null,T?jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:"Loading more runs..."})]}):null]})})]})}var Ca=25;function Ii(t){return t==="pending"||t==="all"}function Zl(){let{api:t,projectId:n}=x(),[o,i]=useState("pending"),[l,k]=useState(null),f$1=(M,B)=>!n||B&&!B.hasMore?null:g(n).approvals({limit:Ca,offset:M*Ca,status:o==="pending"?"pending":void 0}),{data:v,isLoading:c$1,mutate:p,setSize:d$1,size:g$1}=It(f$1,f,{refreshInterval:3e4}),T=v?.flatMap(M=>M.approvals)??[],C=v?.[0]?.pendingCount??0,j=v?.[0],A=a();useEffect(()=>{j&&A(j);},[j,A]);let b=v?.[v.length-1]?.hasMore??false,P=v!==void 0&&g$1>v.length,F=T.find(M=>M.id===l)??null;if(useEffect(()=>{l===null||F!==null||c$1||v===void 0||k(null);},[v,c$1,F,l]),!n||!t)return jsx(Z,{children:"Select a project to view approvals."});function S(){d$1(M=>M+1);}function _(M){!Ii(M)||M===o||(d$1(1),i(M));}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ha$1,{value:o,onValueChange:_,children:jsxs(ia$1,{children:[jsxs(ja,{value:"pending",children:["Pending",C>0?` (${C.toString()})`:""]}),jsx(ja,{value:"all",children:"All"})]})})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[c$1?jsx(jn,{}):T.length===0?jsx(Z,{children:o==="pending"?"No proposals are waiting for approval.":"No approvals found."}):jsx($,{children:jsx(ba$1,{children:T.map(M=>jsxs(da,{className:"fk:cursor-pointer",onClick:()=>k(M.id),children:[jsx(fa,{children:jsx(b$4,{status:M.status})}),jsx(fa,{className:"fk:font-medium",children:M.operationsSummary}),jsx(fa,{className:"fk:text-muted-foreground",children:M.automationName}),jsx(fa,{className:"fk:text-muted-foreground",children:formatDistance(new Date(M.requestedAt),new Date,{addSuffix:true})}),jsx(fa,{onClick:B=>B.stopPropagation(),children:M.chatId?jsx(Link,{className:"fk:text-xs fk:text-muted-foreground hover:fk:underline",to:`../agent/chats/${M.chatId}`,children:"View chat"}):M.automationId&&M.runId?jsx(Link,{className:"fk:text-xs fk:text-muted-foreground hover:fk:underline",to:`../automations/${M.automationId}/runs/${M.runId}`,children:"View run"}):null})]},M.id))})}),b&&!P?jsx(on,{onVisible:S}):null,P?jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:"Loading more approvals..."})]}):null]})}),F?jsx(d,{api:t,approval:F,onClose:()=>k(null),onDecided:()=>{p();}},`${F.id}-${F.status}`):null]})}var Sa=25,Pi={attention:"fk:border-none fk:bg-amber-500/20 fk:text-amber-600 fk:corner-squircle",failure:"fk:border-none fk:bg-destructive/15 fk:text-destructive fk:corner-squircle",neutral:"fk:corner-squircle"};function Mi(t){return t==="needs_action"||t==="all"}function Ri(){let{mode:t}=f$4(),[n,o]=useState(()=>typeof Notification>"u"?"unsupported":Notification.permission);return n!=="default"?null:jsxs("div",{className:"fk:mb-3 fk:flex fk:items-center fk:gap-3 fk:rounded-md fk:border fk:p-3 fk:text-sm fk:corner-squircle",children:[jsx(BellIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}),jsx("span",{className:"fk:flex-1",children:"Get a desktop notification when something needs you while Studio is in the background."}),jsx(b$2,{size:"sm",variant:"outline",onClick:()=>{Notification.requestPermission().then(i=>{o(i),i==="granted"&&t==="hosted"&&i$1().catch(()=>{});});},children:"Turn on"})]})}function Yl(){let{api:t,projectId:n}=x(),o=useNavigate(),i=c$1(),[l,k]=useState("needs_action"),[f$1,v]=useState(()=>new Set),c$3=a(),p=(S,_)=>!n||_&&!_.hasMore?null:g(n).activity({filter:l,limit:Sa,offset:S*Sa}),{data:d,isLoading:g$1,mutate:T,setSize:C,size:j}=It(p,f,{refreshInterval:3e4}),A=useMemo(()=>d?.flatMap(S=>S.items)??[],[d]),x$1=d?.[d.length-1]?.hasMore??false,b=d!==void 0&&j>d.length;if(useEffect(()=>{let S=A.filter(_=>_.state==="unread").map(_=>_.id);!t||!i||S.length===0||(v(_=>new Set([..._,...S])),t.markActivityRead(S).then(()=>c$3()));},[t,i,A,c$3]),!n||!t)return jsx(Z,{children:"Select a project to view activity."});function P(S){!Mi(S)||S===l||(C(1),k(S));}function F(S){t&&t.setActivityItemState(S.id,"dismissed").catch(_=>{qa.error(_ instanceof Error?_.message:"Unable to dismiss this item.");}).finally(()=>{T();});}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ha$1,{value:l,onValueChange:P,children:jsxs(ia$1,{children:[jsx(ja,{value:"needs_action",children:"Needs attention"}),jsx(ja,{value:"all",children:"All"})]})}),jsx(Oo,{})]}),jsx(Ri,{}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[g$1?jsx(jn,{}):A.length===0?jsx(Z,{children:l==="needs_action"?"Nothing needs your attention.":"No activity yet."}):jsx($,{children:jsx(ba$1,{children:A.map(S=>{let _=c$2(S),M=a$1(S),B=b$5(S),U=e$2(S),w=d$1(S);return jsxs(da,{className:"fk:cursor-pointer",onClick:()=>o(S.id),children:[jsx(fa,{className:"fk:w-4 fk:pr-0",children:f$1.has(S.id)||S.state==="unread"?jsx("span",{"aria-label":"Unread",className:"fk:block fk:size-2 fk:rounded-full fk:bg-primary"}):null}),jsxs(fa,{children:[jsx("div",{className:"fk:font-medium",children:S.title}),S.body?jsx("div",{className:"fk:text-xs fk:text-muted-foreground",children:S.body}):null]}),jsx(fa,{children:_?jsx(b$1,{className:Pi[w],variant:w==="neutral"?"outline":"default",children:_}):null}),jsx(fa,{className:"fk:whitespace-nowrap fk:text-muted-foreground",children:formatDistance(new Date(S.createdAt),new Date,{addSuffix:true})}),jsx(fa,{className:"fk:whitespace-nowrap",onClick:H=>H.stopPropagation(),children:M&&B?jsx(Link,{className:"fk:text-xs fk:text-muted-foreground hover:fk:underline",to:`../${M}`,children:B}):null}),jsx(fa,{className:"fk:w-8",onClick:H=>H.stopPropagation(),children:U?null:jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(b$2,{"aria-label":"Dismiss",size:"icon",variant:"ghost",onClick:()=>F(S),children:jsx(XIcon,{className:"fk:size-4"})})}),jsx(e$1,{children:"Dismiss"})]})})]},S.id)})})}),x$1&&!b?jsx(on,{onVisible:()=>{C(S=>S+1);}}):null,b?jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:"Loading more activity..."})]}):null]})})]})}function Ql(){let{api:t$1,projectId:n}=x(),{itemId:o=""}=useParams(),i=a(),{data:l,error:k,isLoading:f$1,mutate:v$1}=De(n&&o?g(n).activityItem(o):null,f),c$2=l?.item,p=c$2?.approvalId??null,{data:d,mutate:g$1}=De(n&&p?g(n).approval(p):null,f),T=c$2?.state==="unread",C=c$1();if(useEffect(()=>{!t$1||!T||!C||t$1.markActivityRead([o]).then(()=>{v$1(),i();});},[t$1,T,C,o,v$1,i]),!n||!t$1)return jsx(Z,{children:"Select a project to view activity."});let j=c$2?a$1(c$2):null,A=c$2?b$5(c$2):null,x$1;return k?x$1=jsx(Z,{children:"This activity item no longer exists."}):f$1||!c$2?x$1=jsxs("div",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx(t,{className:"fk:h-4 fk:w-64"}),jsx(t,{className:"fk:h-32 fk:w-full"})]}):x$1=jsxs("div",{className:"fk:flex fk:flex-col fk:gap-6",children:[jsxs("div",{className:"fk:text-sm fk:text-muted-foreground",children:[c$2.body?`${c$2.body} \xB7 `:"",formatDistance(new Date(c$2.createdAt),new Date,{addSuffix:true})]}),d?jsx(c$3,{api:t$1,approval:d.approval,chat:d.approval.chatId!==null,onDecided:()=>{v$1(),g$1(),i();}},`${d.approval.id}-${d.approval.status}`):p?jsx(t,{className:"fk:h-32 fk:w-full"}):null]}),jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:mb-4 fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsx("div",{className:"fk:flex-1",children:jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:c$2?.title??"Activity"})})]}),jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-center fk:justify-between fk:gap-3 fk:pr-4",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(b$2,{asChild:true,"aria-label":"Back to Activity",size:"icon",variant:"ghost",children:jsx(Link,{relative:"path",to:"..",children:jsx(ArrowLeft,{className:"fk:size-4"})})})}),jsx(e$1,{children:"Back to Activity"})]}),j&&A?jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsx(Link,{to:`../${j}`,children:A})}):null]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsx("div",{className:"fk:pb-6 fk:pr-4",children:x$1})})]})}function en({title:t,value:n}){return jsxs("div",{className:"fk:rounded-md fk:bg-muted/60 fk:p-4 fk:corner-squircle",children:[jsx("div",{className:"fk:text-sm fk:text-muted-foreground",children:t}),jsx("div",{className:"fk:mt-1 fk:text-2xl fk:font-medium",children:n.toLocaleString()})]})}function er(){let{api:t,projectId:n}=x(),{automationId:o,runId:i}=useParams(),{data:l,mutate:k}=De(n&&i?g(n).run(i):null,f,{refreshInterval:P=>!P?.run||C(P.run.status)?0:y}),{data:f$1}=De(n&&o?g(n).automation(o):null,f),[v$1,c$1]=useTransition(),[p,d]=useState(false);if(useEffect(()=>{d(false);},[i]),!n||!t||!o||!i)return jsx(Z,{children:"Select a run."});let g$1=t,T=i,C$1=l?.run,j=C$1?.status==="running"&&!p;function A(){c$1(async()=>{await g$1.cancelRun(T),await k();});}function x$1(){d(true),k();}function b(){k();}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:mb-4 fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsx("div",{className:"fk:flex-1",children:jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:f$1?.automation.name??"Automation"})})]}),jsxs("div",{className:"fk:flex fk:shrink-0 fk:flex-wrap fk:items-start fk:justify-between fk:gap-3 fk:pr-4",children:[jsxs("div",{children:[jsx(b$2,{asChild:true,size:"sm",variant:"ghost",children:jsxs(Link,{relative:"path",to:"..",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"Runs"]})}),jsxs("div",{className:"fk:mt-4 fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx("h2",{className:"fk:text-sm fk:font-medium",children:C$1?`Run from ${format(new Date(C$1.startedAt),"PPpp")}`:"Loading run..."}),C$1?jsx(Aa,{status:C$1.status}):null]})]}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[C$1&&C(C$1.status)?jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:b$6()?jsx("a",{download:`transcript-${T}.json`,href:g$1.getTranscriptUrl(T),children:"Transcript"}):jsx("a",{href:g$1.getTranscriptUrl(T),rel:"noreferrer",target:"_blank",children:"Transcript"})}):null,j?jsx(b$2,{disabled:v$1,size:"sm",variant:"destructive",onClick:A,children:v$1?"Cancelling...":"Cancel run"}):null]})]}),jsxs(ab,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:[jsx(bb,{className:"fk:gap-0 fk:p-0",children:jsx("div",{className:"fk:mx-auto fk:w-full fk:max-w-5xl fk:pb-6 fk:pr-4",children:C$1?jsx(Li,{api:t,run:C$1,onRunUpdated:b,onStreamFinished:x$1}):jsx(Z,{children:"Loading run..."})})}),jsx(db,{})]})]})}function Ei(t){return t==="unavailable"?"No replay events were recorded.":t==="error"?"Unable to load run replay.":"Loading run replay..."}function Li({api:t,onRunUpdated:n,onStreamFinished:o,run:i$1}){let{projectId:l}=x(),{workflowRunId:k}=i$1,f$1=k?t.getStreamUrl(k):"",[v,c]=useState(0),[p,d]=useState(false),[g$1,T]=useState([]),[C$1,j]=useState({}),A=useRef(null),{message:x$1,status:b}=D(f$1,{decidedApprovals:C$1,recordStatus:i$1.status,resumeToken:v,suppressApprovalPause:p}),P=useMemo(()=>x$1?[x$1]:[],[x$1]),F=B(P),S=useRef(n);S.current=n;let _=useRef(o);_.current=o;let M=useMemo(()=>({onApprovalDecided:(R,N)=>{R&&N&&N!=="pending"&&j(E=>({...E,[R]:N})),!(R&&A.current===R)&&(R&&(A.current=R),d(true),c(E=>E+1),S.current?.());}}),[]),B$1=!p&&i$1.status!=="running"&&!C(i$1.status)&&(b==="paused"||i$1.status==="awaiting_approval"||g$2(x$1)),U=a(),w=C(i$1.status);useEffect(()=>{(B$1||w)&&U();},[B$1,U,w]);let H$1=g$2(x$1),$=B$1&&!H$1&&l!=null,{data:he}=De($&&l?g(l).approvals({limit:25,offset:0,runId:i$1.id,status:"pending"}):null,f,{refreshInterval:y}),q=useMemo(()=>new Set(h$1(x$1)),[x$1]),be=g$1.filter(R=>!q.has(R.id)),Be=!C(i$1.status)&&(b==="streaming"||b==="paused"),me=F.length>0||be.length>0||Be;if(useEffect(()=>{c(0),d(false),A.current=null,T([]),j({});},[i$1.id]),useEffect(()=>{let R=he?.approvals;R?.length&&T(N=>{let E=new Map(N.map(ke=>[ke.id,ke]));for(let ke of R)E.set(ke.id,ke);return [...E.values()]});},[he]),useEffect(()=>{T(R=>{if(R.length===0)return R;let N=R.filter(E=>!q.has(E.id));return N.length===R.length?R:N});},[q]),useEffect(()=>{if(!p)return;if(i$1.status==="running"){d(false);return}if(i$1.status!=="awaiting_approval")return;let R=i(x$1),N=A.current;R.length===0||N===null||R.every(E=>E!==N)&&d(false);},[x$1,i$1.status,p]),useEffect(()=>{b==="finished"&&_.current?.();},[b]),useEffect(()=>{b==="paused"&&S.current?.();},[b]),useEffect(()=>{if(i$1.status!=="awaiting_approval")return;let R=window.setInterval(()=>{S.current?.();},y);return ()=>{window.clearInterval(R);}},[i$1.status]),!k)return jsx(Z,{children:"The run has not started streaming yet."});let Ce=Be||B$1&&b!=="finished"&&b!=="error",ze=x$1?.parts[x$1.parts.length-1],je=ze?.type==="text"&&ze.state==="streaming",We=B$1?"Awaiting approval":f$2(x$1)??"Thinking",Ge=B$1||!je,$e=Ei(b);return jsx(z.Provider,{value:M,children:jsxs("div",{className:"fk:space-y-4",children:[i$1.status==="failed"&&i$1.error?jsx("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-4 fk:text-sm fk:corner-squircle",children:i$1.summary??i$1.error}):null,b==="unavailable"?jsx("div",{className:"fk:rounded-md fk:border fk:border-amber-500/30 fk:bg-amber-500/5 fk:p-4 fk:text-sm fk:corner-squircle",children:"The workflow replay is no longer available. Generated artifacts may still be available below."}):null,b==="error"&&!me?jsx("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-4 fk:text-sm fk:corner-squircle",children:"Failed to load the run stream. Try reloading the page."}):null,me?jsxs("div",{className:"fk:space-y-5 fk:rounded-md fk:bg-background fk:corner-squircle",children:[F.map(R=>jsx(Di,{api:t,message:R},R.id)),be.map(R=>jsx(I,{api:t,message:E(R)},R.id)),Ce?jsx(H,{label:We,visible:Ge}):null]}):jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:font-mono fk:text-sm fk:text-muted-foreground fk:corner-squircle",children:[b==="unavailable"||b==="error"?jsx(TriangleAlertIcon,{className:"fk:size-4"}):jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:$e})]})]})})}function Di({api:t,message:n}){let o=n.role==="user",i=n.parts.filter(l=>!e$3(l));return i.length===0?null:jsxs("div",{className:o?"fk:ml-auto fk:w-full fk:max-w-[70%]":"fk:w-full fk:min-w-0",children:[jsx("div",{className:"fk:mb-2 fk:flex fk:items-center fk:gap-2 fk:font-mono fk:text-sm fk:font-medium fk:text-primary",children:o?jsxs(Fragment,{children:[jsx(ZapIcon,{className:"fk:ml-auto fk:size-4"}),jsx("span",{children:"Trigger"})]}):jsxs(Fragment,{children:[jsx(BotIcon,{className:"fk:size-4"}),jsxs("span",{children:["Agent",n.metadata?.model?` (${n.metadata.model})`:""]})]})}),jsx("div",{className:"fk:space-y-8 fk:min-w-0",children:i.map((l,k)=>jsx(F,{api:t,part:l,partIndex:k,parts:i},k))})]})}
4
+ export{Ql as ActivityItemPage,Yl as ActivityPage,Zl as ApprovalsPage,Kl as AutomationDetailPage,Hl as AutomationsPage,Xl as CreateAutomationPage,er as RunDetailPage,Gl as RunHistoryPage,Wl as RunsPage};//# sourceMappingURL=pages-KZ66JVNU.js.map
5
+ //# sourceMappingURL=pages-KZ66JVNU.js.map