@flexkit/studio 0.2.33 → 0.2.35

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 (124) hide show
  1. package/dist/chat-page-IR4RF46H.js +4 -0
  2. package/dist/chat-page-IR4RF46H.js.map +1 -0
  3. package/dist/{chunk-RLVHUIFC.js → chunk-7N3LTSVX.js} +2 -2
  4. package/dist/{chunk-RLVHUIFC.js.map → chunk-7N3LTSVX.js.map} +1 -1
  5. package/dist/chunk-BTH7HU5Y.js +2 -0
  6. package/dist/chunk-BTH7HU5Y.js.map +1 -0
  7. package/dist/chunk-DEG7QP5C.js +30 -0
  8. package/dist/chunk-DEG7QP5C.js.map +1 -0
  9. package/dist/{chunk-K3HW6YWS.js → chunk-EUWIIL3X.js} +2 -2
  10. package/dist/{chunk-K3HW6YWS.js.map → chunk-EUWIIL3X.js.map} +1 -1
  11. package/dist/{chunk-HSGUVQXU.js → chunk-FJRDLP7V.js} +8 -8
  12. package/dist/{chunk-HSGUVQXU.js.map → chunk-FJRDLP7V.js.map} +1 -1
  13. package/dist/chunk-G5N6HEPW.js +2 -0
  14. package/dist/chunk-G5N6HEPW.js.map +1 -0
  15. package/dist/chunk-J6EGNRRT.js +7 -0
  16. package/dist/{chunk-VUZ7GHSO.js.map → chunk-J6EGNRRT.js.map} +1 -1
  17. package/dist/chunk-KEGJNZLW.js +378 -0
  18. package/dist/chunk-KEGJNZLW.js.map +1 -0
  19. package/dist/chunk-PMLDA2FF.js +2 -0
  20. package/dist/chunk-PMLDA2FF.js.map +1 -0
  21. package/dist/chunk-PWGLA33F.js +3 -0
  22. package/dist/chunk-PWGLA33F.js.map +1 -0
  23. package/dist/chunk-PZWEC6KD.js +2 -0
  24. package/dist/chunk-PZWEC6KD.js.map +1 -0
  25. package/dist/{chunk-UB22GYFK.js → chunk-Q4CWQHBJ.js} +2 -2
  26. package/dist/{chunk-UB22GYFK.js.map → chunk-Q4CWQHBJ.js.map} +1 -1
  27. package/dist/{chunk-U5XZWEPO.js → chunk-R6DPAMLC.js} +3 -3
  28. package/dist/{chunk-U5XZWEPO.js.map → chunk-R6DPAMLC.js.map} +1 -1
  29. package/dist/{chunk-DHE6PO3V.js → chunk-RAUQCO6W.js} +2 -2
  30. package/dist/{chunk-DHE6PO3V.js.map → chunk-RAUQCO6W.js.map} +1 -1
  31. package/dist/{chunk-RFUMT6ZR.js → chunk-RFKMFD2O.js} +2 -2
  32. package/dist/{chunk-RFUMT6ZR.js.map → chunk-RFKMFD2O.js.map} +1 -1
  33. package/dist/chunk-RULCANNM.js +7 -0
  34. package/dist/chunk-RULCANNM.js.map +1 -0
  35. package/dist/{chunk-6I7D2JBA.js → chunk-TI3EHLRE.js} +3 -3
  36. package/dist/{chunk-6I7D2JBA.js.map → chunk-TI3EHLRE.js.map} +1 -1
  37. package/dist/{chunk-S26WK6RF.js → chunk-VFV44YZB.js} +2 -2
  38. package/dist/{chunk-S26WK6RF.js.map → chunk-VFV44YZB.js.map} +1 -1
  39. package/dist/chunk-W7JDZHCV.js +2 -0
  40. package/dist/chunk-W7JDZHCV.js.map +1 -0
  41. package/dist/{chunk-7ODGH7G2.js → chunk-WU2KCXBC.js} +2 -2
  42. package/dist/{chunk-7ODGH7G2.js.map → chunk-WU2KCXBC.js.map} +1 -1
  43. package/dist/chunk-XYE6ZAUB.js +2 -0
  44. package/dist/{chunk-S7VNSSIK.js.map → chunk-XYE6ZAUB.js.map} +1 -1
  45. package/dist/chunk-ZMONKGWJ.js +4 -0
  46. package/dist/{chunk-2MVQXXY7.js.map → chunk-ZMONKGWJ.js.map} +1 -1
  47. package/dist/{chunk-YKM3FUGK.js → chunk-ZRTWLY77.js} +3 -3
  48. package/dist/{chunk-YKM3FUGK.js.map → chunk-ZRTWLY77.js.map} +1 -1
  49. package/dist/entry-NQRN7SWV.js +2 -0
  50. package/dist/{entry-ROTT3ZDN.js.map → entry-NQRN7SWV.js.map} +1 -1
  51. package/dist/index.css +43 -0
  52. package/dist/index.d.ts +5 -1
  53. package/dist/index.js +8 -8
  54. package/dist/index.js.map +1 -1
  55. package/dist/list-7SCWJXUE.js +3 -0
  56. package/dist/{list-N4E3VXM5.js.map → list-7SCWJXUE.js.map} +1 -1
  57. package/dist/list-RPIG75US.js +2 -0
  58. package/dist/{list-RCTHBJOK.js.map → list-RPIG75US.js.map} +1 -1
  59. package/dist/pages-KXERA5Z6.js +5 -0
  60. package/dist/{pages-XUJGIHQI.js.map → pages-KXERA5Z6.js.map} +1 -1
  61. package/dist/plugin-pages-NXA4BT7Y.js +2 -0
  62. package/dist/{plugin-pages-FEQILAQR.js.map → plugin-pages-NXA4BT7Y.js.map} +1 -1
  63. package/dist/project-selector-SA6UUVBK.js +2 -0
  64. package/dist/project-selector-SA6UUVBK.js.map +1 -0
  65. package/dist/record-links-RTMCYEPM.js +2 -0
  66. package/dist/{record-links-HO4SEHOA.js.map → record-links-RTMCYEPM.js.map} +1 -1
  67. package/dist/{root-GQL3P63Z.js → root-6H6K3YQF.js} +3 -3
  68. package/dist/{root-GQL3P63Z.js.map → root-6H6K3YQF.js.map} +1 -1
  69. package/dist/root-IBZPU2D4.js +23 -0
  70. package/dist/{root-MLEJUEMJ.js.map → root-IBZPU2D4.js.map} +1 -1
  71. package/dist/{root-CCUROZVR.js → root-MBFQXX4E.js} +2 -2
  72. package/dist/{root-CCUROZVR.js.map → root-MBFQXX4E.js.map} +1 -1
  73. package/dist/root-TSZ3CSJU.js +14 -0
  74. package/dist/root-TSZ3CSJU.js.map +1 -0
  75. package/dist/{root-VA3E6HEY.js → root-TZIXWEZO.js} +2 -2
  76. package/dist/{root-VA3E6HEY.js.map → root-TZIXWEZO.js.map} +1 -1
  77. package/dist/{root-KXY4A6DW.js → root-W5ZPSNQ2.js} +2 -2
  78. package/dist/{root-KXY4A6DW.js.map → root-W5ZPSNQ2.js.map} +1 -1
  79. package/dist/{search-YY4GQQRM.js → search-ZLEYFT3T.js} +2 -2
  80. package/dist/{search-YY4GQQRM.js.map → search-ZLEYFT3T.js.map} +1 -1
  81. package/dist/skills-pages-RPMWIBLS.js +2 -0
  82. package/dist/{skills-pages-SAOZTUOH.js.map → skills-pages-RPMWIBLS.js.map} +1 -1
  83. package/dist/source-VYWE5EB5.js +2 -0
  84. package/dist/{source-2S24MZ5D.js.map → source-VYWE5EB5.js.map} +1 -1
  85. package/dist/{spec-renderer-ZSIVMKVE.js → spec-renderer-Z6GVHLFU.js} +2 -2
  86. package/dist/{spec-renderer-ZSIVMKVE.js.map → spec-renderer-Z6GVHLFU.js.map} +1 -1
  87. package/dist/ui.js +1 -1
  88. package/package.json +4 -4
  89. package/dist/chat-page-LR7XC2US.js +0 -4
  90. package/dist/chat-page-LR7XC2US.js.map +0 -1
  91. package/dist/chunk-2MVQXXY7.js +0 -4
  92. package/dist/chunk-3SY46ERM.js +0 -2
  93. package/dist/chunk-3SY46ERM.js.map +0 -1
  94. package/dist/chunk-4PUMSUJL.js +0 -30
  95. package/dist/chunk-4PUMSUJL.js.map +0 -1
  96. package/dist/chunk-C3OHXPJV.js +0 -2
  97. package/dist/chunk-C3OHXPJV.js.map +0 -1
  98. package/dist/chunk-CFYO546Y.js +0 -378
  99. package/dist/chunk-CFYO546Y.js.map +0 -1
  100. package/dist/chunk-ERDARDGB.js +0 -2
  101. package/dist/chunk-ERDARDGB.js.map +0 -1
  102. package/dist/chunk-L5T56MRH.js +0 -7
  103. package/dist/chunk-L5T56MRH.js.map +0 -1
  104. package/dist/chunk-NFEQBTIW.js +0 -2
  105. package/dist/chunk-NFEQBTIW.js.map +0 -1
  106. package/dist/chunk-S7VNSSIK.js +0 -2
  107. package/dist/chunk-VUZ7GHSO.js +0 -7
  108. package/dist/chunk-XMOSCJOI.js +0 -2
  109. package/dist/chunk-XMOSCJOI.js.map +0 -1
  110. package/dist/chunk-YDVO6XWD.js +0 -2
  111. package/dist/chunk-YDVO6XWD.js.map +0 -1
  112. package/dist/entry-ROTT3ZDN.js +0 -2
  113. package/dist/list-N4E3VXM5.js +0 -3
  114. package/dist/list-RCTHBJOK.js +0 -2
  115. package/dist/pages-XUJGIHQI.js +0 -5
  116. package/dist/plugin-pages-FEQILAQR.js +0 -2
  117. package/dist/project-selector-U64ROZ5D.js +0 -2
  118. package/dist/project-selector-U64ROZ5D.js.map +0 -1
  119. package/dist/record-links-HO4SEHOA.js +0 -2
  120. package/dist/root-BUXIQKA5.js +0 -14
  121. package/dist/root-BUXIQKA5.js.map +0 -1
  122. package/dist/root-MLEJUEMJ.js +0 -23
  123. package/dist/skills-pages-SAOZTUOH.js +0 -2
  124. package/dist/source-2S24MZ5D.js +0 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apps/ai/agent/chat-list.tsx"],"names":["useAgentBasePath","location","useLocation","marker","index","useDebouncedValue","value","delayMs","debounced","setDebounced","useState","useEffect","timeout","getChatGroupLabel","chat","timestamp","now","startOfToday","groupChats","chats","groups","label","group","candidate","ChatListItem","active","api","onChanged","onDeleted","onOpen","dialog","setDialog","title","setTitle","isMutating","startMutation","useTransition","handleRename","handleDelete","jsxs","jsx","DropdownMenu","DropdownMenuTrigger","Button","MoreHorizontalIcon","DropdownMenuContent","DropdownMenuItem","PencilIcon","Trash2Icon","Dialog","open","DialogContent","DialogHeader","DialogTitle","Input","event","DialogFooter","SearchResults","projectId","query","data","isLoading","useSWR","paths","fetcher","LoaderCircle","result","AgentChatsSection","useProjectApi","navigate","useNavigate","globalMutate","useSWRConfig","activeChatId","mutate","setSize","size","useSWRInfinite","pageIndex","previousPage","activeChatDetail","useMemo","listed","page","generatedTitle","hasMore","chatApi","chatProjectId","openChat","chatId","handleDeleted","MessageSquareIcon"],"mappings":"gkBAwBO,SAASA,EAAAA,EAA2B,CACzC,IAAMC,CAAAA,CAAWC,WAAAA,EAAY,CACvBC,CAAAA,CAAS,QAAA,CACTC,CAAAA,CAAQH,CAAAA,CAAS,QAAA,CAAS,OAAA,CAAQE,CAAM,CAAA,CAE9C,OAAIC,CAAAA,GAAU,EAAA,CACL,CAA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O,CAAA,CAC7B,SAAA,CAAW,IAAMgB,CAAAA,CAAc5E,CAAAA,CAAK,EAAE,CAAA,CACtC,MAAA,CAAQ,IAAM0E,CAAAA,CAAS1E,CAAAA,CAAK,EAAE,CAAA,CAAA,CAHzBA,CAAAA,CAAK,EAIZ,CACD,CAAA,CACH,CAAA,CAAA,CAAA,CAdQQ,CAAAA,CAAM,KAehB,CACD,CAAA,CACAuC,GAAAA,CACCtB,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,sFAAA,CACb,QAAA,CAAA,CAAAC,GAAAA,CAACyB,YAAAA,CAAA,CAAa,SAAA,CAAU,6BAAA,CAA8B,CAAA,CAAE,yBAAA,CAAA,CAE1D,CAAA,CACE,IAAA,CACH,CAACJ,GAAAA,EAAa1C,CAAAA,CAAM,MAAA,GAAW,CAAA,CAC9BoB,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,iHAAA,CACb,QAAA,CAAA,CAAAC,GAAAA,CAACmD,iBAAAA,CAAA,CAAkB,SAAA,CAAU,WAAA,CAAY,CAAA,CACzCnD,GAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,oDAAA,CAAkD,CAAA,CAAA,CAC1D,CAAA,CACE,IAAA,CACH6C,CAAAA,CACC7C,GAAAA,CAACG,CAAAA,CAAA,CAAO,SAAA,CAAU,WAAA,CAAY,IAAA,CAAK,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAS,IAAG,CAAQgC,CAAAA,CAAQC,CAAAA,CAAO,CAAC,EAAA,CAAA,CAAG,QAAA,CAAA,WAAA,CAE/F,CAAA,CACE,IAAA,CAAA,CACN,CAAA,CAEJ,CAEJ","file":"chunk-RFUMT6ZR.js","sourcesContent":["import type { JSX } from 'react';\nimport { useEffect, useMemo, useState, useTransition } from 'react';\nimport { LoaderCircle, MessageSquareIcon, MoreHorizontalIcon, PencilIcon, Trash2Icon } from 'lucide-react';\nimport { useLocation, useNavigate } from 'react-router-dom';\nimport useSWR, { useSWRConfig } from 'swr';\nimport useSWRInfinite from 'swr/infinite';\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n Input,\n} from '../../../ui';\nimport { fetcher, paths, type ApiClient } from '../api';\nimport { useProjectApi } from '../replay';\nimport type { AgentChat, AgentChatDetail, AgentChatSearchResult, AgentChatsList } from '../types';\n\n/** Returns the absolute route prefix of the agent app (`.../ai/agent`). */\nexport function useAgentBasePath(): string {\n const location = useLocation();\n const marker = '/agent';\n const index = location.pathname.indexOf(marker);\n\n if (index === -1) {\n return `${location.pathname.replace(/\\/$/, '')}/agent`;\n }\n\n return location.pathname.slice(0, index + marker.length);\n}\n\nexport function useDebouncedValue(value: string, delayMs: number): string {\n const [debounced, setDebounced] = useState(value);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => {\n setDebounced(value);\n }, delayMs);\n\n return () => {\n window.clearTimeout(timeout);\n };\n }, [delayMs, value]);\n\n return debounced;\n}\n\nfunction getChatGroupLabel(chat: AgentChat): string {\n const timestamp = new Date(chat.lastMessageAt ?? chat.updatedAt).getTime();\n const now = new Date();\n const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();\n\n if (timestamp >= startOfToday) {\n return 'Today';\n }\n\n if (timestamp >= startOfToday - 86_400_000) {\n return 'Yesterday';\n }\n\n if (timestamp >= startOfToday - 7 * 86_400_000) {\n return 'Previous 7 days';\n }\n\n return 'Older';\n}\n\nfunction groupChats(chats: AgentChat[]): { chats: AgentChat[]; label: string }[] {\n const groups: { chats: AgentChat[]; label: string }[] = [];\n\n for (const chat of chats) {\n const label = getChatGroupLabel(chat);\n const group = groups.find((candidate) => candidate.label === label);\n\n if (group) {\n group.chats.push(chat);\n } else {\n groups.push({ chats: [chat], label });\n }\n }\n\n return groups;\n}\n\nfunction ChatListItem({\n active,\n api,\n chat,\n onChanged,\n onDeleted,\n onOpen,\n}: {\n active: boolean;\n api: ApiClient;\n chat: AgentChat;\n onChanged: () => void;\n onDeleted: () => void;\n onOpen: () => void;\n}): JSX.Element {\n const [dialog, setDialog] = useState<'rename' | 'delete' | null>(null);\n const [title, setTitle] = useState(chat.title ?? '');\n const [isMutating, startMutation] = useTransition();\n const label = chat.title?.trim() || 'New chat';\n\n function handleRename(): void {\n startMutation(async () => {\n await api.renameAgentChat(chat.id, title.trim());\n setDialog(null);\n onChanged();\n });\n }\n\n function handleDelete(): void {\n startMutation(async () => {\n await api.deleteAgentChat(chat.id);\n setDialog(null);\n onDeleted();\n });\n }\n\n return (\n <div\n className={`fk:group/chat fk:flex fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 ${\n active ? 'fk:bg-sidebar-accent' : 'fk:hover:bg-accent/60'\n } fk:corner-squircle`}\n >\n <button\n className=\"fk:min-w-0 fk:flex-1 fk:truncate fk:px-2 fk:py-1.5 fk:text-left fk:text-sm\"\n title={label}\n type=\"button\"\n onClick={onOpen}\n >\n {label}\n </button>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n className=\"fk:size-6 fk:shrink-0 fk:opacity-0 fk:group-hover/chat:opacity-100 fk:data-[state=open]:opacity-100\"\n size=\"icon\"\n variant=\"ghost\"\n >\n <MoreHorizontalIcon className=\"fk:size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\">\n <DropdownMenuItem\n onClick={() => {\n setTitle(chat.title ?? '');\n setDialog('rename');\n }}\n >\n <PencilIcon className=\"fk:size-4\" />\n Rename\n </DropdownMenuItem>\n <DropdownMenuItem className=\"fk:text-destructive\" onClick={() => setDialog('delete')}>\n <Trash2Icon className=\"fk:size-4\" />\n Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n <Dialog open={dialog === 'rename'} onOpenChange={(open) => setDialog(open ? 'rename' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Rename chat</DialogTitle>\n </DialogHeader>\n <Input value={title} onChange={(event) => setTitle(event.target.value)} placeholder=\"Chat title\" />\n <DialogFooter>\n <Button disabled={isMutating || !title.trim()} size=\"sm\" onClick={handleRename}>\n {isMutating ? 'Saving...' : 'Save'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n <Dialog open={dialog === 'delete'} onOpenChange={(open) => setDialog(open ? 'delete' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Delete chat?</DialogTitle>\n </DialogHeader>\n <p className=\"fk:text-sm fk:text-muted-foreground\">\n &ldquo;{label}&rdquo; and its messages will be permanently deleted.\n </p>\n <DialogFooter>\n <Button disabled={isMutating} size=\"sm\" variant=\"destructive\" onClick={handleDelete}>\n {isMutating ? 'Deleting...' : 'Delete'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n );\n}\n\nfunction SearchResults({\n onOpen,\n projectId,\n query,\n}: {\n onOpen: (_chatId: string) => void;\n projectId: string;\n query: string;\n}): JSX.Element {\n const { data, isLoading } = useSWR<{ results: AgentChatSearchResult[] }>(\n paths(projectId).agentChatSearch(query),\n fetcher,\n { keepPreviousData: true }\n );\n\n if (isLoading && !data) {\n return (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Searching...\n </div>\n );\n }\n\n if (!data?.results.length) {\n return <p className=\"fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">No matching chats.</p>;\n }\n\n return (\n <div className=\"fk:space-y-1\">\n {data.results.map((result) => (\n <button\n className=\"fk:block fk:w-full fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:hover:bg-accent/60 fk:corner-squircle\"\n key={result.messageId}\n type=\"button\"\n onClick={() => onOpen(result.chatId)}\n >\n <span className=\"fk:block fk:truncate fk:text-sm\">{result.chatTitle?.trim() || 'New chat'}</span>\n <span className=\"fk:block fk:truncate fk:text-xs fk:text-muted-foreground\">{result.snippet}</span>\n </button>\n ))}\n </div>\n );\n}\n\n/**\n * ChatGPT-style chats section embedded in the AI sidebar: new chat button and\n * the user's recent chats grouped by date with rename/delete. When `query` is\n * set, the recent list is replaced by hybrid keyword + semantic search results.\n * Rendered inside the app layout route, so relative navigation resolves\n * against the app root (`agent`, `agent/chats/:chatId`).\n */\nexport function AgentChatsSection({ query }: { query: string }): JSX.Element | null {\n const { api, projectId } = useProjectApi();\n const navigate = useNavigate();\n const location = useLocation();\n const { mutate: globalMutate } = useSWRConfig();\n const activeChatId = /\\/agent\\/chats\\/([^/]+)/.exec(location.pathname)?.[1];\n const { data, isLoading, mutate, setSize, size } = useSWRInfinite<AgentChatsList>(\n (pageIndex, previousPage: AgentChatsList | null) => {\n if (!projectId || (previousPage && !previousPage.hasMore)) {\n return null;\n }\n\n return paths(projectId).agentChats(pageIndex * 30);\n },\n fetcher,\n { revalidateFirstPage: true }\n );\n const { data: activeChatDetail } = useSWR<AgentChatDetail>(\n projectId && activeChatId ? paths(projectId).agentChat(activeChatId) : null,\n fetcher\n );\n const chats = useMemo(() => {\n const listed = (data ?? []).flatMap((page) => page.chats);\n const generatedTitle = activeChatDetail?.chat.title?.trim();\n\n if (!activeChatId || !generatedTitle) {\n return listed;\n }\n\n return listed.map((chat) => {\n if (chat.id !== activeChatId || chat.title?.trim()) {\n return chat;\n }\n\n return { ...chat, title: generatedTitle };\n });\n }, [activeChatDetail?.chat.title, activeChatId, data]);\n const hasMore = data?.[data.length - 1]?.hasMore ?? false;\n const groups = useMemo(() => groupChats(chats), [chats]);\n\n // Refresh the list when the user lands on a chat (new chats, fresh titles).\n useEffect(() => {\n void mutate();\n }, [activeChatId, mutate]);\n\n if (!projectId || !api) {\n return null;\n }\n\n const chatApi = api;\n const chatProjectId = projectId;\n\n function openChat(chatId: string): void {\n navigate(`agent/chats/${chatId}`);\n }\n\n function handleDeleted(chatId: string): void {\n void mutate();\n\n if (chatId === activeChatId) {\n navigate('agent');\n } else {\n // Drop the cached detail so a re-open does not show stale data.\n void globalMutate(paths(chatProjectId).agentChat(chatId), undefined, { revalidate: false });\n }\n }\n\n return (\n <div className=\"fk:space-y-2\">\n {query ? (\n <SearchResults projectId={chatProjectId} query={query} onOpen={openChat} />\n ) : (\n <div className=\"fk:space-y-3\">\n {groups.map((group) => (\n <div key={group.label}>\n <p className=\"fk:px-2 fk:pb-1 fk:text-xs fk:font-medium fk:text-muted-foreground\">{group.label}</p>\n <div className=\"fk:space-y-0.5\">\n {group.chats.map((chat) => (\n <ChatListItem\n active={chat.id === activeChatId}\n api={chatApi}\n chat={chat}\n key={chat.id}\n onChanged={() => void mutate()}\n onDeleted={() => handleDeleted(chat.id)}\n onOpen={() => openChat(chat.id)}\n />\n ))}\n </div>\n </div>\n ))}\n {isLoading ? (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Loading recent chats...\n </div>\n ) : null}\n {!isLoading && chats.length === 0 ? (\n <div className=\"fk:flex fk:flex-col fk:items-center fk:gap-2 fk:px-2 fk:py-6 fk:text-center fk:text-xs fk:text-muted-foreground\">\n <MessageSquareIcon className=\"fk:size-5\" />\n <span>No chats yet. Start a conversation with the agent.</span>\n </div>\n ) : null}\n {hasMore ? (\n <Button className=\"fk:w-full\" size=\"sm\" variant=\"ghost\" onClick={() => void setSize(size + 1)}>\n Load more\n </Button>\n ) : null}\n </div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/apps/ai/agent/chat-list.tsx"],"names":["useAgentBasePath","location","useLocation","marker","index","useDebouncedValue","value","delayMs","debounced","setDebounced","useState","useEffect","timeout","getChatGroupLabel","chat","timestamp","now","startOfToday","groupChats","chats","groups","label","group","candidate","ChatListItem","active","api","onChanged","onDeleted","onOpen","dialog","setDialog","title","setTitle","isMutating","startMutation","useTransition","handleRename","handleDelete","jsxs","jsx","DropdownMenu","DropdownMenuTrigger","Button","MoreHorizontalIcon","DropdownMenuContent","DropdownMenuItem","PencilIcon","Trash2Icon","Dialog","open","DialogContent","DialogHeader","DialogTitle","Input","event","DialogFooter","SearchResults","projectId","query","data","isLoading","useSWR","paths","fetcher","LoaderCircle","result","AgentChatsSection","useProjectApi","navigate","useNavigate","globalMutate","useSWRConfig","activeChatId","mutate","setSize","size","useSWRInfinite","pageIndex","previousPage","activeChatDetail","useMemo","listed","page","generatedTitle","hasMore","chatApi","chatProjectId","openChat","chatId","handleDeleted","MessageSquareIcon"],"mappings":"gkBAwBO,SAASA,EAAAA,EAA2B,CACzC,IAAMC,CAAAA,CAAWC,WAAAA,EAAY,CACvBC,CAAAA,CAAS,QAAA,CACTC,CAAAA,CAAQH,CAAAA,CAAS,QAAA,CAAS,OAAA,CAAQE,CAAM,CAAA,CAE9C,OAAIC,CAAAA,GAAU,EAAA,CACL,CAAA,EAAGH,CAAAA,CAAS,SAAS,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAC,CAAA,MAAA,CAAA,CAGzCA,CAAAA,CAAS,QAAA,CAAS,KAAA,CAAM,CAAA,CAAGG,CAAAA,CAAQD,CAAAA,CAAO,MAAM,CACzD,CAEO,SAASE,EAAAA,CAAkBC,CAAAA,CAAeC,CAAAA,CAAyB,CACxE,GAAM,CAACC,CAAAA,CAAWC,CAAY,CAAA,CAAIC,QAAAA,CAASJ,CAAK,CAAA,CAEhD,OAAAK,SAAAA,CAAU,IAAM,CACd,IAAMC,CAAAA,CAAU,MAAA,CAAO,UAAA,CAAW,IAAM,CACtCH,CAAAA,CAAaH,CAAK,EACpB,CAAA,CAAGC,CAAO,CAAA,CAEV,OAAO,IAAM,CACX,MAAA,CAAO,YAAA,CAAaK,CAAO,EAC7B,CACF,CAAA,CAAG,CAACL,CAAAA,CAASD,CAAK,CAAC,CAAA,CAEZE,CACT,CAEA,SAASK,CAAAA,CAA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iBAAAA,CAAA,CAAkB,SAAA,CAAU,WAAA,CAAY,CAAA,CACzCnD,GAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,oDAAA,CAAkD,CAAA,CAAA,CAC1D,CAAA,CACE,IAAA,CACH6C,CAAAA,CACC7C,GAAAA,CAACG,CAAAA,CAAA,CAAO,SAAA,CAAU,WAAA,CAAY,IAAA,CAAK,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAS,IAAG,CAAQgC,CAAAA,CAAQC,CAAAA,CAAO,CAAC,EAAA,CAAA,CAAG,QAAA,CAAA,WAAA,CAE/F,CAAA,CACE,IAAA,CAAA,CACN,CAAA,CAEJ,CAEJ","file":"chunk-RFKMFD2O.js","sourcesContent":["import type { JSX } from 'react';\nimport { useEffect, useMemo, useState, useTransition } from 'react';\nimport { LoaderCircle, MessageSquareIcon, MoreHorizontalIcon, PencilIcon, Trash2Icon } from 'lucide-react';\nimport { useLocation, useNavigate } from 'react-router-dom';\nimport useSWR, { useSWRConfig } from 'swr';\nimport useSWRInfinite from 'swr/infinite';\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n Input,\n} from '../../../ui';\nimport { fetcher, paths, type ApiClient } from '../api';\nimport { useProjectApi } from '../replay';\nimport type { AgentChat, AgentChatDetail, AgentChatSearchResult, AgentChatsList } from '../types';\n\n/** Returns the absolute route prefix of the agent app (`.../ai/agent`). */\nexport function useAgentBasePath(): string {\n const location = useLocation();\n const marker = '/agent';\n const index = location.pathname.indexOf(marker);\n\n if (index === -1) {\n return `${location.pathname.replace(/\\/$/, '')}/agent`;\n }\n\n return location.pathname.slice(0, index + marker.length);\n}\n\nexport function useDebouncedValue(value: string, delayMs: number): string {\n const [debounced, setDebounced] = useState(value);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => {\n setDebounced(value);\n }, delayMs);\n\n return () => {\n window.clearTimeout(timeout);\n };\n }, [delayMs, value]);\n\n return debounced;\n}\n\nfunction getChatGroupLabel(chat: AgentChat): string {\n const timestamp = new Date(chat.lastMessageAt ?? chat.updatedAt).getTime();\n const now = new Date();\n const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();\n\n if (timestamp >= startOfToday) {\n return 'Today';\n }\n\n if (timestamp >= startOfToday - 86_400_000) {\n return 'Yesterday';\n }\n\n if (timestamp >= startOfToday - 7 * 86_400_000) {\n return 'Previous 7 days';\n }\n\n return 'Older';\n}\n\nfunction groupChats(chats: AgentChat[]): { chats: AgentChat[]; label: string }[] {\n const groups: { chats: AgentChat[]; label: string }[] = [];\n\n for (const chat of chats) {\n const label = getChatGroupLabel(chat);\n const group = groups.find((candidate) => candidate.label === label);\n\n if (group) {\n group.chats.push(chat);\n } else {\n groups.push({ chats: [chat], label });\n }\n }\n\n return groups;\n}\n\nfunction ChatListItem({\n active,\n api,\n chat,\n onChanged,\n onDeleted,\n onOpen,\n}: {\n active: boolean;\n api: ApiClient;\n chat: AgentChat;\n onChanged: () => void;\n onDeleted: () => void;\n onOpen: () => void;\n}): JSX.Element {\n const [dialog, setDialog] = useState<'rename' | 'delete' | null>(null);\n const [title, setTitle] = useState(chat.title ?? '');\n const [isMutating, startMutation] = useTransition();\n const label = chat.title?.trim() || 'New chat';\n\n function handleRename(): void {\n startMutation(async () => {\n await api.renameAgentChat(chat.id, title.trim());\n setDialog(null);\n onChanged();\n });\n }\n\n function handleDelete(): void {\n startMutation(async () => {\n await api.deleteAgentChat(chat.id);\n setDialog(null);\n onDeleted();\n });\n }\n\n return (\n <div\n className={`fk:group/chat fk:flex fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 ${\n active ? 'fk:bg-sidebar-accent' : 'fk:hover:bg-accent/60'\n } fk:corner-squircle`}\n >\n <button\n className=\"fk:min-w-0 fk:flex-1 fk:truncate fk:px-2 fk:py-1.5 fk:text-left fk:text-sm\"\n title={label}\n type=\"button\"\n onClick={onOpen}\n >\n {label}\n </button>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n className=\"fk:size-6 fk:shrink-0 fk:opacity-0 fk:group-hover/chat:opacity-100 fk:data-[state=open]:opacity-100\"\n size=\"icon\"\n variant=\"ghost\"\n >\n <MoreHorizontalIcon className=\"fk:size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\">\n <DropdownMenuItem\n onClick={() => {\n setTitle(chat.title ?? '');\n setDialog('rename');\n }}\n >\n <PencilIcon className=\"fk:size-4\" />\n Rename\n </DropdownMenuItem>\n <DropdownMenuItem className=\"fk:text-destructive\" onClick={() => setDialog('delete')}>\n <Trash2Icon className=\"fk:size-4\" />\n Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n <Dialog open={dialog === 'rename'} onOpenChange={(open) => setDialog(open ? 'rename' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Rename chat</DialogTitle>\n </DialogHeader>\n <Input value={title} onChange={(event) => setTitle(event.target.value)} placeholder=\"Chat title\" />\n <DialogFooter>\n <Button disabled={isMutating || !title.trim()} size=\"sm\" onClick={handleRename}>\n {isMutating ? 'Saving...' : 'Save'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n <Dialog open={dialog === 'delete'} onOpenChange={(open) => setDialog(open ? 'delete' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Delete chat?</DialogTitle>\n </DialogHeader>\n <p className=\"fk:text-sm fk:text-muted-foreground\">\n &ldquo;{label}&rdquo; and its messages will be permanently deleted.\n </p>\n <DialogFooter>\n <Button disabled={isMutating} size=\"sm\" variant=\"destructive\" onClick={handleDelete}>\n {isMutating ? 'Deleting...' : 'Delete'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n );\n}\n\nfunction SearchResults({\n onOpen,\n projectId,\n query,\n}: {\n onOpen: (_chatId: string) => void;\n projectId: string;\n query: string;\n}): JSX.Element {\n const { data, isLoading } = useSWR<{ results: AgentChatSearchResult[] }>(\n paths(projectId).agentChatSearch(query),\n fetcher,\n { keepPreviousData: true }\n );\n\n if (isLoading && !data) {\n return (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Searching...\n </div>\n );\n }\n\n if (!data?.results.length) {\n return <p className=\"fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">No matching chats.</p>;\n }\n\n return (\n <div className=\"fk:space-y-1\">\n {data.results.map((result) => (\n <button\n className=\"fk:block fk:w-full fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:hover:bg-accent/60 fk:corner-squircle\"\n key={result.messageId}\n type=\"button\"\n onClick={() => onOpen(result.chatId)}\n >\n <span className=\"fk:block fk:truncate fk:text-sm\">{result.chatTitle?.trim() || 'New chat'}</span>\n <span className=\"fk:block fk:truncate fk:text-xs fk:text-muted-foreground\">{result.snippet}</span>\n </button>\n ))}\n </div>\n );\n}\n\n/**\n * ChatGPT-style chats section embedded in the AI sidebar: new chat button and\n * the user's recent chats grouped by date with rename/delete. When `query` is\n * set, the recent list is replaced by hybrid keyword + semantic search results.\n * Rendered inside the app layout route, so relative navigation resolves\n * against the app root (`agent`, `agent/chats/:chatId`).\n */\nexport function AgentChatsSection({ query }: { query: string }): JSX.Element | null {\n const { api, projectId } = useProjectApi();\n const navigate = useNavigate();\n const location = useLocation();\n const { mutate: globalMutate } = useSWRConfig();\n const activeChatId = /\\/agent\\/chats\\/([^/]+)/.exec(location.pathname)?.[1];\n const { data, isLoading, mutate, setSize, size } = useSWRInfinite<AgentChatsList>(\n (pageIndex, previousPage: AgentChatsList | null) => {\n if (!projectId || (previousPage && !previousPage.hasMore)) {\n return null;\n }\n\n return paths(projectId).agentChats(pageIndex * 30);\n },\n fetcher,\n { revalidateFirstPage: true }\n );\n const { data: activeChatDetail } = useSWR<AgentChatDetail>(\n projectId && activeChatId ? paths(projectId).agentChat(activeChatId) : null,\n fetcher\n );\n const chats = useMemo(() => {\n const listed = (data ?? []).flatMap((page) => page.chats);\n const generatedTitle = activeChatDetail?.chat.title?.trim();\n\n if (!activeChatId || !generatedTitle) {\n return listed;\n }\n\n return listed.map((chat) => {\n if (chat.id !== activeChatId || chat.title?.trim()) {\n return chat;\n }\n\n return { ...chat, title: generatedTitle };\n });\n }, [activeChatDetail?.chat.title, activeChatId, data]);\n const hasMore = data?.[data.length - 1]?.hasMore ?? false;\n const groups = useMemo(() => groupChats(chats), [chats]);\n\n // Refresh the list when the user lands on a chat (new chats, fresh titles).\n useEffect(() => {\n void mutate();\n }, [activeChatId, mutate]);\n\n if (!projectId || !api) {\n return null;\n }\n\n const chatApi = api;\n const chatProjectId = projectId;\n\n function openChat(chatId: string): void {\n navigate(`agent/chats/${chatId}`);\n }\n\n function handleDeleted(chatId: string): void {\n void mutate();\n\n if (chatId === activeChatId) {\n navigate('agent');\n } else {\n // Drop the cached detail so a re-open does not show stale data.\n void globalMutate(paths(chatProjectId).agentChat(chatId), undefined, { revalidate: false });\n }\n }\n\n return (\n <div className=\"fk:space-y-2\">\n {query ? (\n <SearchResults projectId={chatProjectId} query={query} onOpen={openChat} />\n ) : (\n <div className=\"fk:space-y-3\">\n {groups.map((group) => (\n <div key={group.label}>\n <p className=\"fk:px-2 fk:pb-1 fk:text-xs fk:font-medium fk:text-muted-foreground\">{group.label}</p>\n <div className=\"fk:space-y-0.5\">\n {group.chats.map((chat) => (\n <ChatListItem\n active={chat.id === activeChatId}\n api={chatApi}\n chat={chat}\n key={chat.id}\n onChanged={() => void mutate()}\n onDeleted={() => handleDeleted(chat.id)}\n onOpen={() => openChat(chat.id)}\n />\n ))}\n </div>\n </div>\n ))}\n {isLoading ? (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Loading recent chats...\n </div>\n ) : null}\n {!isLoading && chats.length === 0 ? (\n <div className=\"fk:flex fk:flex-col fk:items-center fk:gap-2 fk:px-2 fk:py-6 fk:text-center fk:text-xs fk:text-muted-foreground\">\n <MessageSquareIcon className=\"fk:size-5\" />\n <span>No chats yet. Start a conversation with the agent.</span>\n </div>\n ) : null}\n {hasMore ? (\n <Button className=\"fk:w-full\" size=\"sm\" variant=\"ghost\" onClick={() => void setSize(size + 1)}>\n Load more\n </Button>\n ) : null}\n </div>\n )}\n </div>\n );\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import'./index.css';import {t,j as j$1,e as e$3,g as g$2,h as h$1}from'./chunk-A4DPLZZF.js';import {a as a$1,b as b$2,d}from'./chunk-G5N6HEPW.js';import {l,p,q,c as c$3,d as d$2,e as e$2,f,g as g$1,h,j,k as k$1,i,m,n,b as b$3}from'./chunk-5JUG4BEF.js';import {a as a$3,d as d$1,c as c$2,e as e$1,g,k,l as l$1,p as p$1,s}from'./chunk-S7Z6KKIN.js';import {b as b$1}from'./chunk-U45E5X3H.js';import {a as a$2,b,c as c$1,e}from'./chunk-N33S7BSG.js';import {a,c}from'./chunk-X3SHNHHM.js';import {BrainIcon,ChevronDownIcon,XCircleIcon,CheckCircleIcon,CircleIcon,ClockIcon,SquareArrowOutUpRight,CheckIcon,GripVerticalIcon,XIcon,PanelLeftIcon,Info,X,Loader2Icon,OctagonXIcon,TriangleAlertIcon,InfoIcon,CircleCheckIcon,CopyIcon,ArrowDownIcon,DownloadIcon,ChevronLeftIcon,ChevronRightIcon,ImageIcon,Monitor,PlusIcon,ArrowUpIcon,SquareIcon,BookIcon,LoaderIcon,MicIcon,WrenchIcon,FileTextIcon,VideoIcon,PaperclipIcon,GlobeIcon,Music2Icon}from'lucide-react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import*as H from'react';import {createContext,memo,useMemo,useRef,useState,useEffect,useCallback,useContext,Children,isValidElement}from'react';import {Collapsible,Slot,Checkbox,Popover,Dialog,Tabs,Toggle,ToggleGroup,HoverCard}from'radix-ui';import {FormProvider,Controller,useFormContext,useFormState}from'react-hook-form';import*as xe from'react-resizable-panels';import {NavLink}from'react-router-dom';import {cva}from'class-variance-authority';import {groupBy}from'ramda';import {iconNames,DynamicIcon}from'lucide-react/dynamic';import {Drawer}from'@base-ui/react/drawer';import {Toaster}from'sonner';export{toast as ma}from'sonner';import {createHighlighter}from'shiki';import {StickToBottom,useStickToBottomContext}from'use-stick-to-bottom';import {cjk}from'@streamdown/cjk';import {code}from'@streamdown/code';import {math}from'@streamdown/math';import {mermaid}from'@streamdown/mermaid';import {Streamdown}from'streamdown';import {nanoid}from'nanoid';import {useControllableState}from'@radix-ui/react-use-controllable-state';import {motion}from'motion/react';function Wr({href:e,children:t}){return jsx(c,{asChild:true,className:"fk:h-6 fk:px-1! fk:py-0 fk:text-sm fk:font-light fk:text-link",size:"sm",variant:"link",children:jsxs("a",{href:e,target:"_blank",children:[t," ",jsx(SquareArrowOutUpRight,{className:"fk:size-3",strokeWidth:3})]})})}var Qr=FormProvider,Fo=H.createContext({}),en=({...e})=>jsx(Fo.Provider,{value:{name:e.name},children:jsx(Controller,{...e})}),Xe=()=>{let e=H.useContext(Fo),t=H.useContext(Vo),{getFieldState:o}=useFormContext(),r=useFormState({name:e.name}),a=o(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:s}=t;return {id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...a}},Vo=H.createContext({});function tn({className:e,...t}){let o=H.useId();return jsx(Vo.Provider,{value:{id:o},children:jsx("div",{"data-slot":"form-item",className:a("fk:grid fk:gap-2",e),...t})})}function on({className:e,...t}){let{error:o,formItemId:r}=Xe();return jsx(a$1,{"data-slot":"form-label","data-error":!!o,className:a("fk:data-[error=true]:text-destructive",e),htmlFor:r,...t})}function rn({...e}){let{error:t,formItemId:o,formDescriptionId:r,formMessageId:a}=Xe();return jsx(Slot.Root,{"data-slot":"form-control",id:o,"aria-describedby":t?`${r} ${a}`:`${r}`,"aria-invalid":!!t,...e})}function nn({className:e,...t}){let{formDescriptionId:o}=Xe();return jsx("p",{"data-slot":"form-description",id:o,className:a("fk:text-sm fk:text-muted-foreground",e),...t})}function an({className:e,...t}){let{error:o,formMessageId:r}=Xe(),a$1=o?String(o?.message??""):t.children;return a$1?jsx("p",{"data-slot":"form-message",id:r,className:a("fk:text-sm fk:text-destructive",e),...t,children:a$1}):null}function ln({className:e,...t}){return jsx(Checkbox.Root,{"data-slot":"checkbox",className:a("fk:peer fk:size-4 fk:shrink-0 fk:rounded-[4px] fk:border fk:border-input fk:shadow-xs fk:transition-shadow fk:outline-none fk:focus-visible:border-ring fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:disabled:cursor-not-allowed fk:disabled:opacity-50 fk:aria-invalid:border-destructive fk:aria-invalid:ring-destructive/20 fk:data-[state=checked]:border-primary fk:data-[state=checked]:bg-primary fk:data-[state=checked]:text-primary-foreground fk:dark:bg-input/30 fk:dark:aria-invalid:ring-destructive/40 fk:dark:data-[state=checked]:bg-primary fk:corner-squircle",e),...t,children:jsx(Checkbox.Indicator,{"data-slot":"checkbox-indicator",className:"fk:grid fk:place-content-center fk:text-current fk:transition-none",children:jsx(CheckIcon,{className:"fk:size-3.5"})})})}function ue({...e}){return jsx(Collapsible.Root,{"data-slot":"collapsible",...e})}function me({...e}){return jsx(Collapsible.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function ke({...e}){return jsx(Collapsible.CollapsibleContent,{"data-slot":"collapsible-content",...e})}function fn({...e}){return jsx(Popover.Root,{"data-slot":"popover",...e})}function pn({...e}){return jsx(Popover.Trigger,{"data-slot":"popover-trigger",...e})}function cn({className:e,align:t="center",sideOffset:o=4,...r}){return jsx(Popover.Portal,{children:jsx(Popover.Content,{"data-slot":"popover-content",align:t,sideOffset:o,className:a("fk:z-50 fk:w-72 fk:origin-(--radix-popover-content-transform-origin) fk:rounded-md fk:border fk:bg-popover fk:p-4 fk:text-popover-foreground fk:shadow-md fk:outline-hidden fk:data-[side=bottom]:slide-in-from-top-2 fk:data-[side=left]:slide-in-from-right-2 fk:data-[side=right]:slide-in-from-left-2 fk:data-[side=top]:slide-in-from-bottom-2 fk:data-[state=closed]:animate-out fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:zoom-out-95 fk:data-[state=open]:animate-in fk:data-[state=open]:fade-in-0 fk:data-[state=open]:zoom-in-95 fk:corner-squircle",e),...r})})}function dn({...e}){return jsx(Popover.Anchor,{"data-slot":"popover-anchor",...e})}function mn({className:e,...t}){return jsx(xe.Group,{"data-slot":"resizable-panel-group",className:a("fk:flex fk:h-full fk:w-full fk:aria-[orientation=vertical]:flex-col",e),...t})}function kn({...e}){return jsx(xe.Panel,{"data-slot":"resizable-panel",...e})}function gn({withHandle:e,className:t,...o}){return jsx(xe.Separator,{"data-slot":"resizable-handle",className:a("fk:relative fk:flex fk:w-px fk:items-center fk:justify-center fk:bg-border fk:after:absolute fk:after:inset-y-0 fk:after:left-1/2 fk:after:w-1 fk:after:-translate-x-1/2 fk:focus-visible:ring-1 fk:focus-visible:ring-ring fk:focus-visible:ring-offset-1 fk:focus-visible:outline-hidden fk:aria-[orientation=horizontal]:h-px fk:aria-[orientation=horizontal]:w-full fk:aria-[orientation=horizontal]:after:left-0 fk:aria-[orientation=horizontal]:after:h-1 fk:aria-[orientation=horizontal]:after:w-full fk:aria-[orientation=horizontal]:after:translate-x-0 fk:aria-[orientation=horizontal]:after:-translate-y-1/2 fk:[&[aria-orientation=horizontal]>div]:rotate-90",t),...o,children:e&&jsx("div",{className:"fk:z-10 fk:flex fk:h-8 fk:w-3 fk:items-center fk:justify-center fk:rounded-xs fk:border fk:bg-border fk:corner-squircle",children:jsx(GripVerticalIcon,{className:"fk:size-2.5"})})})}function Yt({...e}){return jsx(Dialog.Root,{"data-slot":"sheet",...e})}function hn({...e}){return jsx(Dialog.Trigger,{"data-slot":"sheet-trigger",...e})}function vn({...e}){return jsx(Dialog.Close,{"data-slot":"sheet-close",...e})}function Oo({...e}){return jsx(Dialog.Portal,{"data-slot":"sheet-portal",...e})}function _o({className:e,...t}){return jsx(Dialog.Overlay,{"data-slot":"sheet-overlay",className:a("fk:fixed fk:inset-0 fk:z-50 fk:bg-black/50 fk:data-[state=closed]:animate-out fk:data-[state=closed]:fade-out-0 fk:data-[state=open]:animate-in fk:data-[state=open]:fade-in-0",e),...t})}function Qt({className:e,children:t,side:o="right",showCloseButton:r=true,...a$1}){return jsxs(Oo,{children:[jsx(_o,{}),jsxs(Dialog.Content,{"data-slot":"sheet-content",className:a("fk:fixed fk:z-50 fk:flex fk:flex-col fk:gap-4 fk:bg-background fk:shadow-lg fk:transition fk:ease-in-out fk:data-[state=closed]:animate-out fk:data-[state=closed]:duration-300 fk:data-[state=open]:animate-in fk:data-[state=open]:duration-500",o==="right"&&"fk:inset-y-0 fk:right-0 fk:h-full fk:w-3/4 fk:border-l fk:data-[state=closed]:slide-out-to-right fk:data-[state=open]:slide-in-from-right fk:sm:max-w-sm",o==="left"&&"fk:inset-y-0 fk:left-0 fk:h-full fk:w-3/4 fk:border-r fk:data-[state=closed]:slide-out-to-left fk:data-[state=open]:slide-in-from-left fk:sm:max-w-sm",o==="top"&&"fk:inset-x-0 fk:top-0 fk:h-auto fk:border-b fk:data-[state=closed]:slide-out-to-top fk:data-[state=open]:slide-in-from-top",o==="bottom"&&"fk:inset-x-0 fk:bottom-0 fk:h-auto fk:border-t fk:data-[state=closed]:slide-out-to-bottom fk:data-[state=open]:slide-in-from-bottom",e),...a$1,children:[t,r&&jsxs(Dialog.Close,{className:"fk:absolute fk:top-4 fk:right-4 fk:rounded-xs fk:opacity-70 fk:ring-offset-background fk:transition-opacity fk:hover:opacity-100 fk:focus:ring-2 fk:focus:ring-ring fk:focus:ring-offset-2 fk:focus:outline-hidden fk:disabled:pointer-events-none fk:data-[state=open]:bg-secondary fk:corner-squircle",children:[jsx(XIcon,{className:"fk:size-4"}),jsx("span",{className:"fk:sr-only",children:"Close"})]})]})]})}function eo({className:e,...t}){return jsx("div",{"data-slot":"sheet-header",className:a("fk:flex fk:flex-col fk:gap-1.5 fk:p-4",e),...t})}function xn({className:e,...t}){return jsx("div",{"data-slot":"sheet-footer",className:a("fk:mt-auto fk:flex fk:flex-col fk:gap-2 fk:p-4",e),...t})}function to({className:e,...t}){return jsx(Dialog.Title,{"data-slot":"sheet-title",className:a("fk:font-semibold fk:text-foreground",e),...t})}function oo({className:e,...t}){return jsx(Dialog.Description,{"data-slot":"sheet-description",className:a("fk:text-sm fk:text-muted-foreground",e),...t})}var ro=768;function Uo(){let[e,t]=H.useState(void 0);return H.useEffect(()=>{let o=window.matchMedia(`(max-width: ${ro-1}px)`),r=()=>{t(window.innerWidth<ro);};return o.addEventListener("change",r),t(window.innerWidth<ro),()=>o.removeEventListener("change",r)},[]),!!e}var $o="flexkit:sidebar:state";function yn(){return document.cookie.split("; ").find(e=>e.startsWith(`${$o}=`))?.split("=")[1]!=="false"}var wn=3600*24*7,Tn="16rem",Sn="18rem",In="2rem",Nn="b",Wo=H.createContext(null);function Ye(){let e=H.useContext(Wo);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function Rn({defaultOpen:e=true,open:t,onOpenChange:o,className:r,style:a$1,children:s,...i}){let l=Uo(),[f,p]=H.useState(false),[u,k]=H.useState(e),g=t??u,T=H.useCallback(d=>{let v=typeof d=="function"?d(g):d;o?o(v):k(v),document.cookie=`${$o}=${v}; path=/; max-age=${wn}`;},[o,g]),b=H.useCallback(()=>l?p(d=>!d):T(d=>!d),[l,T,p]);H.useEffect(()=>{let d=v=>{v.key===Nn&&(v.metaKey||v.ctrlKey)&&(v.preventDefault(),b());};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[b]);let P=g?"expanded":"collapsed",y=H.useMemo(()=>({state:P,open:g,setOpen:T,isMobile:l,openMobile:f,setOpenMobile:p,toggleSidebar:b}),[P,g,T,l,f,p,b]);return jsx(Wo.Provider,{value:y,children:jsx(a$2,{delayDuration:0,children:jsx("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":Tn,"--sidebar-width-icon":In,...a$1},className:a("fk:group/sidebar-wrapper fk:flex fk:w-full fk:has-data-[variant=inset]:bg-sidebar fk:overflow-hidden",r),...i,children:s})})})}function no({side:e="left",variant:t="sidebar",collapsible:o="offcanvas",className:r,children:a$1,...s}){let{isMobile:i,state:l,openMobile:f,setOpenMobile:p}=Ye();return o==="none"?jsx("div",{"data-slot":"sidebar",className:a("fk:flex fk:h-full fk:w-(--sidebar-width) fk:flex-col fk:bg-sidebar fk:text-sidebar-foreground",r),...s,children:a$1}):i?jsx(Yt,{open:f,onOpenChange:p,...s,children:jsxs(Qt,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"fk:w-(--sidebar-width) fk:bg-sidebar fk:p-0 fk:text-sidebar-foreground fk:[&>button]:hidden",style:{"--sidebar-width":Sn},side:e,children:[jsxs(eo,{className:"fk:sr-only",children:[jsx(to,{children:"Sidebar"}),jsx(oo,{children:"Displays the mobile sidebar."})]}),jsx("div",{className:"fk:flex fk:h-full fk:w-full fk:flex-col",children:a$1})]})}):jsxs("div",{className:"fk:group fk:peer flexkit-sidebar-desktop-block fk:text-sidebar-foreground","data-state":l,"data-collapsible":l==="collapsed"?o:"","data-variant":t,"data-side":e,"data-slot":"sidebar",children:[jsx("div",{"data-slot":"sidebar-gap",className:a("fk:relative fk:w-(--sidebar-width) fk:bg-transparent fk:transition-[width] fk:duration-200 fk:ease-linear","fk:group-data-[collapsible=offcanvas]:w-0","fk:group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"fk:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"fk:group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),jsx("div",{"data-slot":"sidebar-container",className:a("fk:relative fk:inset-y-0 fk:z-10 flexkit-sidebar-desktop-flex fk:h-[calc(100svh-3.5rem)] fk:w-(--sidebar-width) fk:transition-[left,right,width] fk:duration-200 fk:ease-linear",e==="left"?"fk:left-0 fk:group-data-[collapsible=offcanvas]:-left-(--sidebar-width)":"fk:right-0 k:group-data-[collapsible=offcanvas]:-right-(--sidebar-width)",t==="floating"||t==="inset"?"fk:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)] fk:group-data-[side=left]:border-r":"fk:group-data-[collapsible=icon]:w-(--sidebar-width-icon) fk:group-data-[side=left]:border-r fk:group-data-[side=right]:border-l",r),...s,children:jsx("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"fk:flex fk:h-full fk:w-full fk:flex-col fk:bg-sidebar fk:group-data-[variant=floating]:rounded-lg fk:group-data-[variant=floating]:border fk:group-data-[variant=floating]:border-sidebar-border fk:group-data-[variant=floating]:shadow-sm",children:a$1})})]})}function Mn({className:e,onClick:t,...o}){let{toggleSidebar:r}=Ye();return jsxs(c,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:a("fk:size-7",e),onClick:a=>{t?.(a),r();},...o,children:[jsx(PanelLeftIcon,{}),jsx("span",{className:"fk:sr-only",children:"Toggle Sidebar"})]})}function ao({className:e,...t}){let{toggleSidebar:o}=Ye();return jsx("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:o,title:"Toggle Sidebar",className:a("fk:absolute fk:inset-y-0 fk:z-20 flexkit-sidebar-sm-flex fk:w-4 fk:-translate-x-1/2 fk:transition-all fk:ease-linear fk:group-data-[side=left]:-right-4 fk:group-data-[side=right]:left-0 fk:after:absolute fk:after:inset-y-0 fk:after:left-1/2 fk:after:w-[2px] fk:hover:after:bg-sidebar-border","fk:in-data-[side=left]:cursor-w-resize fk:in-data-[side=right]:cursor-e-resize","fk:[[data-side=left][data-state=collapsed]_&]:cursor-e-resize fk:[[data-side=right][data-state=collapsed]_&]:cursor-w-resize","fk:group-data-[collapsible=offcanvas]:translate-x-0 fk:group-data-[collapsible=offcanvas]:after:left-full fk:hover:group-data-[collapsible=offcanvas]:bg-sidebar","fk:[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","fk:[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})}function An({className:e,...t}){return jsx("main",{"data-slot":"sidebar-inset",className:a("fk:relative fk:flex fk:flex-1 fk:flex-col fk:bg-background fk:overflow-hidden fk:peer-data-[variant=inset]:h-[calc(100svh-3.625rem)]",e),...t})}function so({className:e,...t}){return jsx("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:a("fk:flex fk:min-h-0 fk:flex-1 fk:flex-col fk:overflow-auto fk:group-data-[collapsible=icon]:overflow-hidden",e),...t})}function ct({className:e,...t}){return jsx("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:a("fk:relative fk:flex fk:w-full fk:min-w-0 fk:flex-col fk:p-2",e),...t})}function io({className:e,asChild:t=false,...o}){let r=t?Slot.Root:"div";return jsx(r,{"data-slot":"sidebar-group-label","data-sidebar":"group-label",className:a("fk:flex fk:h-8 fk:shrink-0 fk:items-center fk:rounded-md fk:px-2 fk:text-xs fk:font-medium fk:text-sidebar-foreground/70 fk:ring-sidebar-ring fk:outline-hidden fk:transition-[margin,opacity] fk:duration-200 fk:ease-linear fk:focus-visible:ring-2 fk:[&>svg]:size-4 fk:[&>svg]:shrink-0 fk:corner-squircle","fk:group-data-[collapsible=icon]:-mt-8 fk:group-data-[collapsible=icon]:opacity-0",e),...o})}function Dn({className:e,...t}){return jsx("div",{"data-slot":"sidebar-group-content","data-sidebar":"group-content",className:a("fk:w-full fk:text-sm",e),...t})}function dt({className:e,...t}){return jsx("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:a("fk:flex fk:w-full fk:min-w-0 fk:flex-col fk:gap-1",e),...t})}function ut({className:e,...t}){return jsx("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:a("fk:group/menu-item fk:relative",e),...t})}var Ln=cva("fk:peer/menu-button fk:flex fk:w-full fk:items-center fk:gap-2 fk:overflow-hidden fk:rounded-md fk:p-2 fk:text-left fk:text-sm fk:ring-sidebar-ring fk:outline-hidden fk:transition-[width,height,padding] fk:group-has-data-[sidebar=menu-action]/menu-item:pr-8 fk:group-data-[collapsible=icon]:size-8! fk:group-data-[collapsible=icon]:p-2! fk:hover:bg-sidebar-accent fk:hover:text-sidebar-accent-foreground fk:focus-visible:ring-2 fk:active:bg-sidebar-accent fk:active:text-sidebar-accent-foreground fk:disabled:pointer-events-none fk:disabled:opacity-50 fk:aria-disabled:pointer-events-none fk:aria-disabled:opacity-50 fk:data-[active=true]:bg-sidebar-accent fk:data-[active=true]:font-medium fk:data-[active=true]:text-sidebar-accent-foreground fk:data-[state=open]:hover:bg-sidebar-accent fk:data-[state=open]:hover:text-sidebar-accent-foreground fk:[&>span:last-child]:truncate fk:[&>svg]:size-4 fk:[&>svg]:shrink-0 fk:corner-squircle",{variants:{variant:{default:"fk:hover:bg-sidebar-accent fk:hover:text-sidebar-accent-foreground",outline:"fk:bg-background fk:shadow-[0_0_0_1px_hsl(var(--sidebar-border))] fk:hover:bg-sidebar-accent fk:hover:text-sidebar-accent-foreground fk:hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"fk:h-8 fk:text-sm",sm:"fk:h-7 fk:text-xs",lg:"fk:h-12 fk:text-sm fk:group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function mt({asChild:e$1=false,isActive:t=false,variant:o="default",size:r="default",tooltip:a$1,className:s,...i}){let l=e$1?Slot.Root:"button",{isMobile:f,state:p}=Ye(),u=jsx(l,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":r,"data-active":t,className:a(Ln({variant:o,size:r}),s),...i});return a$1?(typeof a$1=="string"&&(a$1={children:a$1}),jsxs(b,{children:[jsx(c$1,{asChild:true,children:u}),jsx(e,{side:"right",align:"center",hidden:p!=="collapsed"||f,...a$1})]})):u}function Xo(e){return e.trim().replace(/([a-z])([A-Z0-9])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var Bn="dock";function zn(e){return e.replace(/(^|-)([a-z0-9])/g,(t,o,r)=>r.toUpperCase())}function Ko(e){let t=new Set(e),o=new Map;for(let a of e){let s=zn(a);o.has(s)||o.set(s,a);}let r=a=>{let s=a.trim();if(t.has(s))return s;let i=o.get(s);if(i)return i;let l=Xo(s);return t.has(l)?l:void 0};return (a,s)=>{if(a){let i=r(a);if(i)return i}if(s){let i=Xo(s),f=[i,`${i}s`,i.endsWith("s")?i.slice(0,-1):""].filter(Boolean).find(p=>t.has(p));if(f)return f}return Bn}}var Fn=Ko(iconNames);function Vn(e,t){return Fn(e,t)}function lo({name:e,fallbackFor:t,className:o="fk:h-4 fk:w-4",strokeWidth:r=2}){return jsx(DynamicIcon,{className:o,fallback:()=>jsx("span",{"aria-hidden":true,className:`fk:inline-block ${o}`}),name:Vn(e,t),strokeWidth:r})}var jo=NavLink;function _n({className:e,menuGroups:t,schema:o}){let r=o.filter(i=>i.menu?.hidden!==true),a=groupBy(i=>i.menu?.group&&t?.find(l=>l.name===i.menu?.group)?.name||"ungrouped",r),s=t?.filter(i=>a[i.name]?.length);return jsxs(no,{className:e,collapsible:"icon",variant:"inset",children:[jsxs(so,{children:[s?.map(i=>jsxs(ct,{children:[jsx(io,{children:i.title}),jsx(dt,{children:a[i.name]?.map(l=>jsx(ut,{children:jsx(mt,{asChild:true,isActive:location.pathname.includes(`/list/${l.plural}`),tooltip:kt(l.menu?.label??l.plural),children:jsxs(jo,{to:`list/${l.plural}`,children:[jsx(lo,{className:"fk:h-4 fk:w-4 fk:mr-2",fallbackFor:l.name,name:l.menu?.icon}),jsx("span",{children:kt(l.menu?.label??l.plural)})]})})},l.plural))})]},i.name)),jsx(ct,{children:jsx(dt,{children:a.ungrouped?.map(i=>jsx(ut,{children:jsx(mt,{asChild:true,isActive:location.pathname.includes(`/list/${i.plural}`),tooltip:kt(i.menu?.label??i.plural),children:jsxs(jo,{to:`list/${i.plural}`,children:[jsx(lo,{className:"fk:h-4 fk:w-4 fk:mr-2",fallbackFor:i.name,name:i.menu?.icon}),jsx("span",{children:kt(i.menu?.label??i.plural)})]})})},i.plural))})})]}),jsx(ao,{})]})}function kt(e){let t=e.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1).trim()}function Un({className:e,containerClassName:t,onScroll:o,ref:r,...a$1}){return jsx("div",{ref:r,"data-slot":"table-container",className:a("fk:relative fk:h-full fk:w-full fk:min-w-0 fk:overflow-auto fk:rounded-t-md fk:border-border fk:border fk:corner-squircle",t),onScroll:o,children:jsx("table",{"data-slot":"table",className:a("fk:w-full fk:caption-bottom fk:text-sm",e),...a$1})})}function qn({className:e,...t}){return jsx("thead",{"data-slot":"table-header",className:a("fk:[&_tr]:border-b fk:bg-muted fk:dark:bg-muted",e),...t})}function $n({className:e,...t}){return jsx("tbody",{"data-slot":"table-body",className:a("fk:[&_tr:last-child]:border-0",e),...t})}function Wn({className:e,...t}){return jsx("tfoot",{"data-slot":"table-footer",className:a("fk:border-t fk:bg-muted/50 fk:font-medium fk:[&>tr]:last:border-b-0",e),...t})}function Xn({className:e,...t}){return jsx("tr",{"data-slot":"table-row",className:a("fk:border-b fk:transition-colors fk:hover:bg-muted/50 fk:has-aria-expanded:bg-muted/50 fk:data-[state=selected]:bg-muted",e),...t})}function Kn({className:e,...t}){return jsx("th",{"data-slot":"table-head",className:a("fk:h-10 fk:px-4 fk:text-left fk:align-middle fk:font-medium fk:whitespace-nowrap fk:text-foreground fk:[&:has([role=checkbox])]:pr-0 fk:*:[[role=checkbox]]:translate-y-[2px]",e),...t})}function Jn({className:e,...t}){return jsx("td",{"data-slot":"table-cell",className:a("fk:px-4 fk:py-1 fk:align-middle fk:whitespace-nowrap fk:[&:has([role=checkbox])]:pr-0 fk:*:[[role=checkbox]]:translate-y-[2px]",e),...t})}function jn({className:e,...t}){return jsx("caption",{"data-slot":"table-caption",className:a("fk:mt-4 fk:pb-2 fk:text-sm fk:text-muted-foreground",e),...t})}function Yn({className:e,orientation:t="horizontal",...o}){return jsx(Tabs.Root,{"data-slot":"tabs","data-orientation":t,orientation:t,className:a("fk:group/tabs fk:flex fk:data-[orientation=horizontal]:flex-col",e),...o})}var Qn=cva("fk:group/tabs-list fk:inline-flex fk:w-fit fk:items-center fk:justify-center fk:rounded-lg fk:text-muted-foreground fk:group-data-[orientation=horizontal]/tabs:h-9 fk:group-data-[orientation=vertical]/tabs:h-fit fk:group-data-[orientation=vertical]/tabs:flex-col fk:data-[variant=line]:rounded-none fk:corner-squircle",{variants:{variant:{default:"fk:bg-muted",line:"fk:gap-1 fk:bg-transparent"}},defaultVariants:{variant:"default"}});function ea({className:e,variant:t="default",...o}){return jsx(Tabs.List,{"data-slot":"tabs-list","data-variant":t,className:a(Qn({variant:t}),e),...o})}function ta({className:e,type:t="button",...o}){return jsx(Tabs.Trigger,{"data-slot":"tabs-trigger",type:t,className:a("fk:relative fk:inline-flex fk:h-[calc(100%-1px)] fk:flex-1 fk:items-center fk:justify-center fk:gap-1.5 fk:rounded-md fk:border fk:border-transparent! fk:px-4 fk:py-1 fk:text-sm fk:font-medium fk:whitespace-nowrap fk:text-foreground/60 fk:transition-all fk:group-data-[orientation=vertical]/tabs:w-full fk:group-data-[orientation=vertical]/tabs:justify-start fk:hover:text-foreground fk:focus-visible:border-ring! fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:focus-visible:outline-1 fk:focus-visible:outline-ring fk:disabled:pointer-events-none fk:disabled:opacity-50 fk:group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm fk:group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none fk:dark:text-muted-foreground fk:dark:hover:text-foreground fk:[&_svg]:pointer-events-none fk:[&_svg]:shrink-0 fk:[&_svg:not([class*='size-'])]:size-4 fk:corner-squircle","fk:group-data-[variant=line]/tabs-list:bg-transparent fk:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent fk:dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent! fk:dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","fk:data-[state=active]:bg-background fk:data-[state=active]:text-foreground fk:dark:data-[state=active]:bg-muted-foreground/10 fk:dark:data-[state=active]:text-foreground fk:data-[state=active]:scale-[1.05]","fk:after:absolute fk:after:bg-foreground fk:after:opacity-0 fk:after:transition-opacity fk:group-data-[orientation=horizontal]/tabs:after:inset-x-0 fk:group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] fk:group-data-[orientation=horizontal]/tabs:after:h-0.5 fk:group-data-[orientation=vertical]/tabs:after:inset-y-0 fk:group-data-[orientation=vertical]/tabs:after:-right-1 fk:group-data-[orientation=vertical]/tabs:after:w-0.5 fk:group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...o})}function oa({className:e,...t}){return jsx(Tabs.Content,{"data-slot":"tabs-content",className:a("fk:flex-1 fk:outline-none fk:flex fk:flex-col",e),...t})}var ht=cva("fk:inline-flex fk:items-center fk:justify-center fk:gap-2 fk:rounded-md fk:text-sm fk:font-medium fk:whitespace-nowrap fk:transition-[color,box-shadow] fk:outline-none fk:hover:bg-muted fk:hover:text-muted-foreground fk:focus-visible:border-ring fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:disabled:pointer-events-none fk:disabled:opacity-50 fk:aria-invalid:border-destructive fk:aria-invalid:ring-destructive/20 fk:data-[state=on]:bg-accent fk:data-[state=on]:text-accent-foreground fk:dark:aria-invalid:ring-destructive/40 fk:[&_svg]:pointer-events-none fk:[&_svg]:shrink-0 fk:[&_svg:not([class*='size-'])]:size-4 fk:corner-squircle",{variants:{variant:{default:"fk:bg-transparent",outline:"fk:border fk:border-input fk:bg-transparent fk:shadow-xs fk:hover:bg-accent fk:hover:text-accent-foreground"},size:{default:"fk:h-9 fk:min-w-9 fk:px-2",sm:"fk:h-8 fk:min-w-8 fk:px-1.5",lg:"fk:h-10 fk:min-w-10 fk:px-2.5"}},defaultVariants:{variant:"default",size:"default"}});function aa({className:e,variant:t,size:o,...r}){return jsx(Toggle.Root,{"data-slot":"toggle",className:a(ht({variant:t,size:o,className:e})),...r})}var Yo=H.createContext({size:"default",variant:"default",spacing:0});function ia({className:e,variant:t,size:o,spacing:r=0,children:a$1,...s}){return jsx(ToggleGroup.Root,{"data-slot":"toggle-group","data-variant":t,"data-size":o,"data-spacing":r,style:{"--gap":r},className:a("fk:group/toggle-group fk:flex fk:w-fit fk:items-center fk:gap-[--spacing(var(--gap))] fk:rounded-md fk:data-[spacing=default]:data-[variant=outline]:shadow-xs fk:corner-squircle",e),...s,children:jsx(Yo.Provider,{value:{variant:t,size:o,spacing:r},children:a$1})})}function la({className:e,children:t,variant:o,size:r,...a$1}){let s=H.useContext(Yo);return jsx(ToggleGroup.Item,{"data-slot":"toggle-group-item","data-variant":s.variant||o,"data-size":s.size||r,"data-spacing":s.spacing,className:a(ht({variant:s.variant||o,size:s.size||r}),"fk:w-auto fk:min-w-0 fk:shrink-0 fk:px-3 fk:focus:z-10 fk:focus-visible:z-10","fk:data-[spacing=0]:rounded-none fk:data-[spacing=0]:shadow-none fk:data-[spacing=0]:first:rounded-l-md fk:data-[spacing=0]:last:rounded-r-md fk:data-[spacing=0]:data-[variant=outline]:border-l-0 fk:data-[spacing=0]:data-[variant=outline]:first:border-l",e),...a$1,children:t})}function Qo(){return jsx(e,{className:"fk:max-w-64 fk:p-3",children:jsxs("div",{className:"fk:flex fk:gap-2.5",children:[jsx(Info,{className:"fk:mt-0.5 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-70"}),jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("p",{className:"fk:text-sm fk:font-semibold fk:leading-none",children:"Insufficient permissions"}),jsx("p",{className:"fk:text-xs fk:opacity-70 fk:leading-snug",children:"Your member role cannot perform this action"})]})]})})}function pa({disabled:e,children:t}){return e?jsx(a$2,{children:jsxs(b,{children:[jsx(c$1,{asChild:true,children:jsx("span",{className:"fk:inline-flex",children:t})}),jsx(Qo,{})]})}):jsx(Fragment,{children:t})}var er=H.createContext(null);function da(){let e=H.useContext(er);if(!e)throw new Error("useDrawer must be used within a Drawer.");return e}function tr({modal:e=true,swipeDirection:t="right",...o}){let r=H.useMemo(()=>({modal:e,swipeDirection:t}),[e,t]);return jsx(er.Provider,{value:r,children:jsx(Drawer.Root,{"data-slot":"drawer",modal:e,swipeDirection:t,...o})})}function ua({...e}){return jsx(Drawer.Portal,{"data-slot":"drawer-portal",...e})}function ma({className:e,...t}){return jsx(Drawer.Backdrop,{"data-slot":"drawer-overlay",className:a("fk:fixed fk:inset-0 fk:z-50 fk:min-h-dvh fk:bg-overlay/75 fk:backdrop-blur-[1px] fk:select-none","fk:opacity-[max(var(--drawer-overlay-min-opacity,0),calc(1-var(--drawer-swipe-progress)))] fk:transition-opacity fk:duration-450 fk:ease-[cubic-bezier(0.32,0.72,0,1)]","fk:data-starting-style:opacity-0 fk:data-ending-style:pointer-events-none fk:data-ending-style:opacity-0 fk:data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] fk:data-swiping:duration-0","fk:supports-[-webkit-touch-callout:none]:absolute",e),...t})}function or({className:e,children:t,...o}){let{modal:r,swipeDirection:a$1}=da(),s=a$1==="down"||a$1==="up"?"y":"x";return jsxs(ua,{children:[r===true?jsx(ma,{}):null,jsx(Drawer.Viewport,{"data-slot":"drawer-viewport","data-modal":r,className:"fk:pointer-events-none fk:fixed fk:inset-0 fk:z-50 fk:select-none fk:data-[modal=true]:pointer-events-auto",children:jsx(Drawer.Popup,{"data-slot":"drawer-popup","data-swipe-axis":s,className:a("fk:group/drawer-popup fk:pointer-events-auto fk:fixed fk:z-50 fk:m-(--drawer-inset,0px) fk:flex fk:h-(--drawer-content-height) fk:max-h-(--drawer-content-max-height,none) fk:min-h-0 fk:w-(--drawer-content-width,auto) fk:transform-[translate3d(var(--translate-x,0px),var(--translate-y,0px),0)_scale(var(--stack-scale))] fk:flex-col fk:bg-background fk:transition-[transform,height,opacity,filter] fk:duration-450 fk:ease-[cubic-bezier(0.22,1,0.36,1)] fk:will-change-transform fk:outline-none fk:select-none fk:[interpolate-size:allow-keywords]","fk:data-nested-drawer-open:overflow-hidden fk:data-nested-drawer-open:brightness-90","fk:after:pointer-events-none fk:after:absolute fk:after:bg-(--drawer-bleed-background,var(--background)) fk:data-[swipe-axis=x]:after:inset-y-0 fk:data-[swipe-axis=x]:after:w-(--bleed) fk:data-[swipe-axis=y]:after:inset-x-0 fk:data-[swipe-axis=y]:after:h-(--bleed) fk:data-[swipe-direction=down]:after:top-full fk:data-[swipe-direction=left]:after:right-full fk:data-[swipe-direction=right]:after:left-full fk:data-[swipe-direction=up]:after:bottom-full","fk:[--drawer-content-height:var(--drawer-height,auto)] fk:data-[swipe-axis=x]:[--drawer-content-width:clamp(40vw,95vw,60rem)] fk:data-[swipe-axis=y]:[--drawer-content-max-height:calc(100dvh-6rem)]","fk:[--bleed:3rem] fk:[--peek:40%] fk:[--stack-room:max(0px,calc(100vw-100%))] fk:[--stack-gap:min(var(--peek),calc(var(--stack-room)/max(1,var(--stack-levels,1))))] fk:[--stack-step:0.02] fk:[--stack-height:var(--drawer-frontmost-height,var(--drawer-height,0px))] fk:[--stack-peek-offset:max(0px,calc((var(--nested-drawers)-var(--stack-progress))*var(--stack-gap)))] fk:[--stack-progress:clamp(0,var(--drawer-swipe-progress),1)] fk:[--stack-scale-base:max(0,calc(1-(var(--nested-drawers)*var(--stack-step))))] fk:[--stack-scale:clamp(0,calc(var(--stack-scale-base)+(var(--stack-step)*var(--stack-progress))),1)] fk:[--stack-shrink:calc(1-var(--stack-scale))]","fk:data-ending-style:transform-(--closed-transform) fk:data-ending-style:opacity-[0.9999] fk:data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] fk:data-nested-drawer-swiping:duration-0 fk:data-ending-style:data-nested-drawer-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)] fk:data-starting-style:transform-(--closed-transform) fk:data-swiping:duration-0 fk:data-ending-style:data-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)]","fk:data-[swipe-axis=y]:inset-x-0 fk:data-[swipe-axis=y]:data-nested-drawer-open:h-(--stack-height)","fk:data-[swipe-axis=x]:inset-y-0","fk:data-[swipe-direction=down]:bottom-0 fk:data-[swipe-direction=down]:origin-bottom fk:data-[swipe-direction=down]:rounded-t-[20px] fk:data-[swipe-direction=down]:border-t fk:data-[swipe-direction=down]:[--closed-transform:translate3d(0,calc(100%+var(--drawer-inset,0px)+2px),0)] fk:data-[swipe-direction=down]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)-var(--stack-peek-offset)-(var(--stack-shrink)*var(--stack-height)))]","fk:data-[swipe-direction=up]:top-0 fk:data-[swipe-direction=up]:origin-top fk:data-[swipe-direction=up]:rounded-b-[20px] fk:data-[swipe-direction=up]:border-b fk:data-[swipe-direction=up]:[--closed-transform:translate3d(0,calc(-100%-var(--drawer-inset,0px)-2px),0)] fk:data-[swipe-direction=up]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)+var(--stack-peek-offset)+(var(--stack-shrink)*var(--stack-height)))]","fk:data-[swipe-direction=left]:left-0 fk:data-[swipe-direction=left]:origin-left fk:data-[swipe-direction=left]:rounded-r-[20px] fk:data-[swipe-direction=left]:border-r fk:data-[swipe-direction=left]:[--closed-transform:translate3d(calc(-100%-var(--drawer-inset,0px)-2px),0,0)] fk:data-[swipe-direction=left]:[--translate-x:calc(var(--drawer-swipe-movement-x)+var(--stack-peek-offset)+(var(--stack-shrink)*100%))]","fk:data-[swipe-direction=right]:right-0 fk:data-[swipe-direction=right]:origin-right fk:data-[swipe-direction=right]:rounded-l-[20px] fk:data-[swipe-direction=right]:border-l fk:data-[swipe-direction=right]:[--closed-transform:translate3d(calc(100%+var(--drawer-inset,0px)+2px),0,0)] fk:data-[swipe-direction=right]:[--translate-x:calc(var(--drawer-swipe-movement-x)-var(--stack-peek-offset)-(var(--stack-shrink)*100%))]","fk:corner-squircle fk:shadow-2xl",e),...o,children:jsx(Drawer.Content,{"data-slot":"drawer-content",className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col fk:overflow-hidden fk:overscroll-contain fk:rounded-[inherit] fk:select-text fk:group-data-swiping/drawer-popup:select-none",children:t})})})]})}function rr({className:e,...t}){return jsx("div",{"data-slot":"drawer-header",className:a("fk:flex fk:shrink-0 fk:gap-2.5 fk:p-4 fk:group-data-[swipe-axis=y]/drawer-popup:text-center fk:md:text-left",e),...t})}function nr({className:e,...t}){return jsx(Drawer.Title,{"data-slot":"drawer-title",className:a("fk:flex fk:items-center fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",e),...t})}function ar({className:e,...t}){return jsx(Drawer.Description,{"data-slot":"drawer-description",className:a("fk:text-sm fk:text-muted-foreground",e),...t})}var ir=createContext(1);function Sf({children:e,size:t}){return jsx(ir.Provider,{value:Math.max(1,t),children:e})}function lr({actions:e,beforeClose:t$1,children:o,depth:r,forceClose:a=false,isFocused:s,nested:i,onFormChange:l$1,onClose:f,panel:p,title:u}){let[k,g]=useState(false),b={"--stack-levels":useContext(ir)-1},P=useCallback(()=>a||!(t$1?t$1():true)?false:(g(false),true),[t$1,a]);return useEffect(()=>{a&&g(false);},[a]),useEffect(()=>{g(true);},[]),jsx(tr,{disablePointerDismissal:true,onOpenChange:(y,d)=>{!y&&!P()&&d.cancel();},onOpenChangeComplete:y=>{y||f();},open:k,swipeDirection:"right",children:jsxs(or,{style:b,children:[jsxs(rr,{className:"fk:px-10",children:[jsx(nr,{className:"fk:w-full",children:u||jsx(t,{className:"fk:h-5 fk:w-[120px]"})}),jsx(ar,{className:"fk:sr-only",children:u||"Loading form"}),e,jsxs(c,{className:"",onClick:()=>{P();},size:"icon",variant:"ghost",children:[jsx(X,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Close"})]})]}),jsx(l,{}),jsx("div",{className:"fk:min-h-0 fk:flex-1 fk:px-10 fk:pt-6 fk:overflow-y-auto fk:pb-16",children:o}),p,i]})})}var Na=({richColors:e=true,style:t,...o})=>{let{theme:r="system"}=b$1();return jsx(Toaster,{theme:r,richColors:e,className:"toaster group",icons:{success:jsx(CircleCheckIcon,{className:"fk:size-4"}),info:jsx(InfoIcon,{className:"fk:size-4"}),warning:jsx(TriangleAlertIcon,{className:"fk:size-4"}),error:jsx(OctagonXIcon,{className:"fk:size-4"}),loading:jsx(Loader2Icon,{className:"fk:size-4 fk:animate-spin"})},style:{"--normal-bg":"hsl(var(--popover))","--normal-text":"hsl(var(--popover-foreground))","--normal-border":"hsl(var(--border))","--border-radius":"var(--radius)",...t},...o})};function et({...e}){return jsx(HoverCard.Root,{"data-slot":"hover-card",...e})}function tt({...e}){return jsx(HoverCard.Trigger,{"data-slot":"hover-card-trigger",...e})}function ot({className:e,align:t="center",sideOffset:o=4,...r}){return jsx(HoverCard.Portal,{"data-slot":"hover-card-portal",children:jsx(HoverCard.Content,{"data-slot":"hover-card-content",align:t,sideOffset:o,className:a("fk:z-50 fk:w-64 fk:origin-(--radix-hover-card-content-transform-origin) fk:rounded-md fk:border fk:bg-popover fk:p-4 fk:text-popover-foreground fk:shadow-md fk:outline-hidden fk:data-[side=bottom]:slide-in-from-top-2 fk:data-[side=left]:slide-in-from-right-2 fk:data-[side=right]:slide-in-from-left-2 fk:data-[side=top]:slide-in-from-bottom-2 fk:data-[state=closed]:animate-out fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:zoom-out-95 fk:data-[state=open]:animate-in fk:data-[state=open]:fade-in-0 fk:data-[state=open]:zoom-in-95 fk:corner-squircle",e),...r})})}function uo({className:e,...t}){return jsx(Loader2Icon,{role:"status","aria-label":"Loading",className:a("fk:size-4 fk:animate-spin",e),...t})}function mo({className:e,...t}){return jsx("div",{"data-slot":"input-group",role:"group",className:a("fk:group/input-group fk:border-input fk:dark:bg-input/30 fk:shadow-xs fk:relative fk:flex fk:w-full fk:items-center fk:rounded-lg fk:border fk:outline-none fk:transition-[color,box-shadow] fk:corner-squircle","fk:h-9 fk:has-[>textarea]:h-auto","fk:has-[>[data-align=inline-start]]:[&>input]:pl-2","fk:has-[>[data-align=inline-end]]:[&>input]:pr-2","fk:has-[>[data-align=block-start]]:h-auto fk:has-[>[data-align=block-start]]:flex-col fk:has-[>[data-align=block-start]]:[&>input]:pb-3","fk:has-[>[data-align=block-end]]:h-auto fk:has-[>[data-align=block-end]]:flex-col fk:has-[>[data-align=block-end]]:[&>input]:pt-3","fk:has-[[data-slot=input-group-control]:focus-visible]:ring-ring fk:has-[[data-slot=input-group-control]:focus-visible]:ring-1","fk:has-[[data-slot][aria-invalid=true]]:ring-destructive/20 fk:has-[[data-slot][aria-invalid=true]]:border-destructive fk:dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",e),...t})}var Aa=cva("fk:text-muted-foreground fk:flex fk:h-auto fk:cursor-text fk:select-none fk:items-center fk:justify-center fk:gap-2 fk:py-1.5 fk:text-sm fk:font-medium fk:group-data-[disabled=true]/input-group:opacity-50 fk:[&>kbd]:rounded-[calc(var(--radius)-5px)] fk:[&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"fk:order-first fk:pl-3 fk:has-[>button]:ml-[-0.45rem] fk:has-[>kbd]:ml-[-0.35rem]","inline-end":"fk:order-last fk:pr-3 fk:has-[>button]:mr-[-0.4rem] fk:has-[>kbd]:mr-[-0.35rem]","block-start":"fk:[.border-b]:pb-3 fk:order-first fk:w-full fk:justify-start fk:px-3 fk:pt-3 fk:group-has-[>input]/input-group:pt-2.5","block-end":"fk:[.border-t]:pt-3 fk:order-last fk:w-full fk:justify-start fk:px-3 fk:pb-3 fk:group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function Ct({className:e,align:t="inline-start",...o}){return jsx("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:a(Aa({align:t}),e),onClick:r=>{r.target.closest("button")||r.currentTarget.parentElement?.querySelector("input")?.focus();},...o})}var Da=cva("fk:flex fk:items-center fk:gap-2 fk:text-sm fk:shadow-none",{variants:{size:{xs:"fk:h-6 fk:gap-1 fk:rounded-[calc(var(--radius)-5px)] fk:px-2 fk:has-[>svg]:px-2 fk:[&>svg:not([class*=size-])]:size-3.5 fk:corner-squircle",sm:"fk:h-8 fk:gap-1.5 fk:rounded-lg fk:px-2.5 fk:has-[>svg]:px-2.5 fk:corner-squircle","icon-xs":"fk:size-6 fk:rounded-[calc(var(--radius)-5px)] fk:p-0 fk:has-[>svg]:p-0 fk:corner-squircle","icon-sm":"fk:size-8 fk:p-0 fk:has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function yt({className:e,type:t="button",variant:o="ghost",size:r="xs",...a$1}){return jsx(c,{type:t,"data-size":r,variant:o,className:a(Da({size:r}),e),...a$1})}function La({className:e,...t}){return jsx("span",{className:a("fk:text-muted-foreground fk:flex fk:items-center fk:gap-2 fk:text-sm fk:[&_svg:not([class*=size-])]:size-4 fk:[&_svg]:pointer-events-none",e),...t})}function Ba({className:e,...t}){return jsx(b$2,{"data-slot":"input-group-control",className:a("fk:flex-1 fk:rounded-none fk:border-0 fk:bg-transparent fk:shadow-none fk:focus-visible:ring-0 fk:dark:bg-transparent fk:corner-squircle",e),...t})}function ko({className:e,...t}){return jsx(d,{"data-slot":"input-group-control",className:a("fk:flex-1 fk:resize-none fk:rounded-none fk:border-0 fk:bg-transparent fk:py-3 fk:shadow-none fk:focus-visible:ring-0 fk:dark:bg-transparent fk:corner-squircle",e),...t})}var qa={audio:Music2Icon,document:FileTextIcon,image:ImageIcon,source:GlobeIcon,unknown:PaperclipIcon,video:VideoIcon},$a=e=>{if(e.type==="source-document")return "source";let t=e.mediaType??"";return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("application/")||t.startsWith("text/")?"document":"unknown"},Wa=e=>{if(e.type==="source-document")return e.title||e.filename||"Source";let t=$a(e);return e.filename||(t==="image"?"Image":"Attachment")},Xa=(e,t,o)=>o?jsx("img",{alt:t||"Image",className:"fk:size-full fk:object-cover",height:96,src:e,width:96}):jsx("img",{alt:t||"Image",className:"fk:size-full fk:rounded fk:object-cover fk:corner-squircle",height:20,src:e,width:20}),dr=createContext(null),Ka=createContext(null),ep=()=>useContext(dr)??{variant:"grid"},go=()=>{let e=useContext(Ka);if(!e)throw new Error("Attachment components must be used within <Attachment>");return e},tp=({variant:e="grid",className:t,children:o,...r})=>{let a$1=useMemo(()=>({variant:e}),[e]);return jsx(dr.Provider,{value:a$1,children:jsx("div",{className:a("fk:flex fk:items-start",e==="list"?"fk:flex-col fk:gap-2":"fk:flex-wrap fk:gap-2",e==="grid"&&"fk:ml-auto fk:w-fit",t),...r,children:o})})};var op=({fallbackIcon:e,className:t,...o})=>{let{data:r,mediaCategory:a$1,variant:s}=go(),i=s==="inline"?"fk:size-3":"fk:size-4",l=p=>jsx(p,{className:a(i,"fk:text-muted-foreground")}),f=()=>{if(a$1==="image"&&r.type==="file"&&r.url)return Xa(r.url,r.filename,s==="grid");if(a$1==="video"&&r.type==="file"&&r.url)return jsx("video",{className:"fk:size-full fk:object-cover",muted:true,src:r.url});let p=qa[a$1];return e??l(p)};return jsx("div",{className:a("fk:flex fk:shrink-0 fk:items-center fk:justify-center fk:overflow-hidden",s==="grid"&&"fk:size-full fk:bg-muted",s==="inline"&&"fk:size-5 fk:rounded fk:bg-background fk:corner-squircle",s==="list"&&"fk:size-12 fk:rounded fk:bg-muted fk:corner-squircle",t),...o,children:f()})},rp=({showMediaType:e=false,className:t,...o})=>{let{data:r,variant:a$1}=go(),s=Wa(r);return a$1==="grid"?null:jsxs("div",{className:a("fk:min-w-0 fk:flex-1",t),...o,children:[jsx("span",{className:"fk:block fk:truncate",children:s}),e&&r.mediaType&&jsx("span",{className:"fk:block fk:truncate fk:text-muted-foreground fk:text-xs",children:r.mediaType})]})},np=({label:e="Remove",className:t,children:o,...r})=>{let{onRemove:a$1,variant:s}=go(),i=useCallback(l=>{l.stopPropagation(),a$1?.();},[a$1]);return a$1?jsxs(c,{"aria-label":e,className:a(s==="grid"&&["fk:absolute fk:top-2 fk:right-2 fk:size-6 fk:rounded-full fk:p-0 fk:corner-squircle","fk:bg-background/80 fk:backdrop-blur-sm","fk:opacity-0 fk:transition-opacity fk:group-hover:opacity-100","fk:hover:bg-background","fk:[&>svg]:size-3"],s==="inline"&&["fk:size-5 fk:rounded fk:p-0 fk:corner-squircle","fk:opacity-0 fk:transition-opacity fk:group-hover:opacity-100","fk:[&>svg]:size-2.5"],s==="list"&&["fk:size-8 fk:shrink-0 fk:rounded fk:p-0 fk:corner-squircle","fk:[&>svg]:size-4"],t),onClick:i,type:"button",variant:"ghost",...r,children:[o??jsx(XIcon,{}),jsx("span",{className:"fk:sr-only",children:e})]}):null},ap=({openDelay:e=0,closeDelay:t=0,...o})=>jsx(et,{closeDelay:t,openDelay:e,...o}),sp=e=>jsx(tt,{...e}),ip=({align:e="start",className:t,...o})=>jsx(ot,{align:e,className:a("fk:w-auto fk:p-2",t),...o}),lp=({className:e,children:t,...o})=>jsx("div",{className:a("fk:flex fk:items-center fk:justify-center fk:p-4 fk:text-muted-foreground fk:text-sm",e),...o,children:t??"No attachments"});var os=e=>e&&e&1,rs=e=>e&&e&2,ns=e=>e&&e&4,as=e=>e.map((t,o)=>({key:`line-${o}`,tokens:t.map((r,a)=>({key:`line-${o}-${a}`,token:r}))})),ss=({token:e})=>jsx("span",{className:"fk:dark:bg-(--shiki-dark-bg)! fk:dark:text-(--shiki-dark)!",style:{backgroundColor:e.bgColor,color:e.color,fontStyle:os(e.fontStyle)?"italic":void 0,fontWeight:rs(e.fontStyle)?"bold":void 0,textDecoration:ns(e.fontStyle)?"underline":void 0,...e.htmlStyle},children:e.content}),is=a("fk:block","fk:before:content-[counter(line)]","fk:before:inline-block","fk:before:[counter-increment:line]","fk:before:w-8","fk:before:mr-4","fk:before:text-right","fk:before:text-muted-foreground/50","fk:before:font-mono","fk:before:select-none"),ls=({keyedLine:e,showLineNumbers:t})=>jsx("span",{className:t?is:"fk:block",children:e.tokens.length===0?`
2
+ `:e.tokens.map(({token:o,key:r})=>jsx(ss,{token:o},r))}),xr=createContext({code:""}),mr=new Map,kr=new Map,we=new Map,fs=(e,t)=>{let o=e.slice(0,100),r=e.length>100?e.slice(-100):"";return `${t}:${e.length}:${o}:${r}`},ps=e=>{let t=mr.get(e);if(t)return t;let o=createHighlighter({langs:[e],themes:["github-light","github-dark"]});return mr.set(e,o),o},cs=e=>({bg:"transparent",fg:"inherit",tokens:e.split(`
3
+ `).map(t=>t===""?[]:[{color:"inherit",content:t}])}),gr=(e,t,o)=>{let r=fs(e,t),a=kr.get(r);return a||(o&&(we.has(r)||we.set(r,new Set),we.get(r)?.add(o)),ps(t).then(s=>{let l=s.getLoadedLanguages().includes(t)?t:"text",f=s.codeToTokens(e,{lang:l,themes:{dark:"github-dark",light:"github-light"}}),p={bg:f.bg??"transparent",fg:f.fg??"inherit",tokens:f.tokens};kr.set(r,p);let u=we.get(r);if(u){for(let k of u)k(p);we.delete(r);}}).catch(s=>{console.error("Failed to highlight code:",s),we.delete(r);}),null)},Pr=memo(({tokenized:e,showLineNumbers:t,className:o})=>{let r=useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]),a$1=useMemo(()=>as(e.tokens),[e.tokens]);return jsx("pre",{className:a("fk:dark:bg-(--shiki-dark-bg)! fk:dark:text-(--shiki-dark)! fk:m-0 fk:p-4 fk:text-sm",o),style:r,children:jsx("code",{className:a("fk:font-mono fk:text-sm",t&&"fk:[counter-increment:line_0] fk:[counter-reset:line]"),children:a$1.map(s=>jsx(ls,{keyedLine:s,showLineNumbers:t},s.key))})})},(e,t)=>e.tokenized===t.tokenized&&e.showLineNumbers===t.showLineNumbers&&e.className===t.className);Pr.displayName="CodeBlockBody";var ds=({className:e,language:t,style:o,...r})=>jsx("div",{className:a("fk:group fk:relative fk:w-full fk:overflow-hidden fk:rounded-md fk:border fk:bg-background fk:text-foreground fk:corner-squircle",e),"data-language":t,style:{containIntrinsicSize:"auto 200px",contentVisibility:"auto",...o},...r}),bp=({children:e,className:t,...o})=>jsx("div",{className:a("fk:flex fk:items-center fk:justify-between fk:border-b fk:bg-muted/80 fk:px-3 fk:py-2 fk:text-muted-foreground fk:text-xs",t),...o,children:e}),hp=({children:e,className:t,...o})=>jsx("div",{className:a("fk:flex fk:items-center fk:gap-2",t),...o,children:e}),vp=({children:e,className:t,...o})=>jsx("span",{className:a("fk:font-mono",t),...o,children:e}),xp=({children:e,className:t,...o})=>jsx("div",{className:a("fk:-my-1 fk:-mr-1 fk:flex fk:items-center fk:gap-2",t),...o,children:e}),us=({code:e,language:t,showLineNumbers:o=false})=>{let r=useMemo(()=>cs(e),[e]),a=useMemo(()=>gr(e,t)??r,[e,t,r]),[s,i]=useState(null),l=useRef({code:e,language:t});return (l.current.code!==e||l.current.language!==t)&&(l.current={code:e,language:t},i(null)),useEffect(()=>{let p=false;return gr(e,t,u=>{p||i(u);}),()=>{p=true;}},[e,t]),jsx("div",{className:"fk:relative fk:overflow-auto",children:jsx(Pr,{showLineNumbers:o,tokenized:s??a})})},wt=({code:e,language:t,showLineNumbers:o=false,className:r,children:a,...s})=>{let i=useMemo(()=>({code:e}),[e]);return jsx(xr.Provider,{value:i,children:jsxs(ds,{className:r,language:t,...s,children:[a,jsx(us,{code:e,language:t,showLineNumbers:o})]})})},Pp=({onCopy:e,onError:t,timeout:o=2e3,children:r,className:a$1,...s})=>{let[i,l]=useState(false),f=useRef(0),{code:p}=useContext(xr),u=useCallback(async()=>{if(typeof window>"u"||!navigator?.clipboard?.writeText){t?.(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(p),l(!0),e?.(),f.current=window.setTimeout(()=>l(!1),o));}catch(g){t?.(g);}},[p,e,t,o,i]);useEffect(()=>()=>{window.clearTimeout(f.current);},[]);let k=i?CheckIcon:CopyIcon;return jsx(c,{className:a("fk:shrink-0",a$1),onClick:u,size:"icon",variant:"ghost",...s,children:r??jsx(k,{size:14})})},Cp=e=>jsx(a$3,{...e}),yp=({className:e,...t})=>jsx(d$1,{className:a("fk:h-7 fk:border-none fk:bg-transparent fk:px-2 fk:text-xs fk:shadow-none",e),size:"sm",...t}),wp=e=>jsx(c$2,{...e}),Tp=({align:e="end",...t})=>jsx(e$1,{align:e,...t}),Sp=e=>jsx(g,{...e});var Bp=({className:e,...t})=>jsx(StickToBottom,{className:a("fk:relative fk:flex-1 fk:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),zp=({className:e,...t})=>jsx(StickToBottom.Content,{className:a("fk:flex fk:flex-col fk:gap-8 fk:p-4",e),...t}),Ep=({className:e,title:t="No messages yet",description:o="Start a conversation to see messages here",icon:r,children:a$1,...s})=>jsx("div",{className:a("fk:flex fk:size-full fk:flex-col fk:items-center fk:justify-center fk:gap-3 fk:p-8 fk:text-center",e),...s,children:a$1??jsxs(Fragment,{children:[r&&jsx("div",{className:"fk:text-muted-foreground",children:r}),jsxs("div",{className:"fk:space-y-1",children:[jsx("h3",{className:"fk:font-medium fk:text-sm",children:t}),o&&jsx("p",{className:"fk:text-muted-foreground fk:text-sm",children:o})]})]})}),Hp=({className:e,...t})=>{let{isAtBottom:o,scrollToBottom:r}=useStickToBottomContext(),a$1=useCallback(()=>{r();},[r]);return !o&&jsx(c,{className:a("fk:absolute fk:bottom-4 fk:left-[50%] fk:translate-x-[-50%] fk:rounded-full fk:dark:bg-background fk:dark:hover:bg-muted fk:corner-squircle",e),onClick:a$1,size:"icon",type:"button",variant:"outline",...t,children:jsx(ArrowDownIcon,{className:"fk:size-4"})})},hs=e=>e.parts.filter(t=>t.type==="text").map(t=>t.text).join(""),Tr=e=>`**${e.role.charAt(0).toUpperCase()+e.role.slice(1)}:** ${hs(e)}`,vs=(e,t=Tr)=>e.map((o,r)=>t(o,r)).join(`
4
+
5
+ `),Fp=({messages:e,filename:t="conversation.md",formatMessage:o=Tr,className:r,children:a$1,...s})=>{let i=useCallback(()=>{let l=vs(e,o),f=new Blob([l],{type:"text/markdown"}),p=URL.createObjectURL(f),u=document.createElement("a");u.href=p,u.download=t,document.body.append(u),u.click(),u.remove(),URL.revokeObjectURL(p);},[e,t,o]);return jsx(c,{className:a("fk:absolute fk:top-4 fk:right-4 fk:rounded-full fk:dark:bg-background fk:dark:hover:bg-muted fk:corner-squircle",r),onClick:i,size:"icon",type:"button",variant:"outline",...s,children:a$1??jsx(DownloadIcon,{className:"fk:size-4"})})};var Yp=({className:e,from:t,...o})=>jsx("div",{className:a("fk:group fk:flex fk:w-full fk:max-w-[95%] fk:flex-col fk:gap-2",t==="user"?"fk:is-user fk:ml-auto fk:justify-end":"fk:is-assistant",e),...o}),Qp=({children:e,className:t,...o})=>jsx("div",{className:a("fk:is-user:dark fk:flex fk:w-fit fk:min-w-0 fk:max-w-full fk:flex-col fk:gap-2 fk:overflow-hidden fk:text-sm","fk:group-[.is-user]:ml-auto fk:group-[.is-user]:rounded-lg fk:group-[.is-user]:bg-secondary fk:group-[.is-user]:px-4 fk:group-[.is-user]:py-3 fk:group-[.is-user]:text-foreground","fk:group-[.is-assistant]:text-foreground",t),...o,children:e}),ec=({className:e,children:t,...o})=>jsx("div",{className:a("fk:flex fk:items-center fk:gap-1",e),...o,children:t}),tc=({tooltip:e$1,children:t,label:o,variant:r="ghost",size:a="icon-sm",...s})=>{let i=jsxs(c,{size:a,type:"button",variant:r,...s,children:[t,jsx("span",{className:"fk:sr-only",children:o||e$1})]});return e$1?jsx(a$2,{children:jsxs(b,{children:[jsx(c$1,{asChild:true,children:i}),jsx(e,{children:jsx("p",{children:e$1})})]})}):i},Nr=createContext(null),nt=()=>{let e=useContext(Nr);if(!e)throw new Error("MessageBranch components must be used within MessageBranch");return e},oc=({defaultBranch:e=0,onBranchChange:t,className:o,...r})=>{let[a$1,s]=useState(e),[i,l]=useState([]),f=useCallback(g=>{s(g),t?.(g);},[t]),p=useCallback(()=>{let g=a$1>0?a$1-1:i.length-1;f(g);},[a$1,i.length,f]),u=useCallback(()=>{let g=a$1<i.length-1?a$1+1:0;f(g);},[a$1,i.length,f]),k=useMemo(()=>({branches:i,currentBranch:a$1,goToNext:u,goToPrevious:p,setBranches:l,totalBranches:i.length}),[i,a$1,u,p]);return jsx(Nr.Provider,{value:k,children:jsx("div",{className:a("fk:grid fk:w-full fk:gap-2 fk:[&>div]:pb-0",o),...r})})},rc=({children:e,...t})=>{let{currentBranch:o,setBranches:r,branches:a$1}=nt(),s=useMemo(()=>Array.isArray(e)?e:[e],[e]);return useEffect(()=>{a$1.length!==s.length&&r(s);},[s,a$1,r]),s.map((i,l)=>jsx("div",{className:a("fk:grid fk:gap-2 fk:overflow-hidden fk:[&>div]:pb-0",l===o?"fk:block":"fk:hidden"),...t,children:i},i.key))},nc=({className:e,...t})=>{let{totalBranches:o}=nt();return o<=1?null:jsx(p,{className:a("fk:[&>*:not(:first-child)]:rounded-l-md fk:[&>*:not(:last-child)]:rounded-r-md",e),orientation:"horizontal",...t})},ac=({children:e,...t})=>{let{goToPrevious:o,totalBranches:r}=nt();return jsx(c,{"aria-label":"Previous branch",disabled:r<=1,onClick:o,size:"icon-sm",type:"button",variant:"ghost",...t,children:e??jsx(ChevronLeftIcon,{size:14})})},sc=({children:e,...t})=>{let{goToNext:o,totalBranches:r}=nt();return jsx(c,{"aria-label":"Next branch",disabled:r<=1,onClick:o,size:"icon-sm",type:"button",variant:"ghost",...t,children:e??jsx(ChevronRightIcon,{size:14})})},ic=({className:e,...t})=>{let{currentBranch:o,totalBranches:r}=nt();return jsxs(q,{className:a("fk:border-none fk:bg-transparent fk:text-muted-foreground fk:shadow-none",e),...t,children:[o+1," of ",r]})},Ds={cjk:cjk,code:code,math:math,mermaid:mermaid},Ls=memo(({className:e,...t})=>jsx(Streamdown,{className:a("fk:size-full fk:[&>*:first-child]:mt-0 fk:[&>*:last-child]:mb-0",e),plugins:Ds,prefix:"fk",...t}),(e,t)=>e.children===t.children&&t.isAnimating===e.isAnimating);Ls.displayName="MessageResponse";var lc=({className:e,children:t,...o})=>jsx("div",{className:a("fk:mt-4 fk:flex fk:w-full fk:items-center fk:justify-between fk:gap-4",e),...o,children:t});var mc=e=>jsx(k,{...e}),kc=e=>jsx(l$1,{...e}),gc=({className:e,children:t,title:o="Model Selector",...r})=>jsxs(p$1,{"aria-describedby":void 0,className:a("fk:outline! fk:border-none! fk:p-0 fk:outline-border! fk:outline-solid!",e),...r,children:[jsx(s,{className:"fk:sr-only",children:o}),jsx(c$3,{className:"fk:**:data-[slot=command-input-wrapper]:h-auto",children:t})]}),bc=e=>jsx(d$2,{...e}),hc=({className:e,...t})=>jsx(e$2,{className:a("fk:h-auto fk:py-3.5",e),...t}),vc=e=>jsx(f,{...e}),xc=e=>jsx(g$1,{...e}),Pc=e=>jsx(h,{...e}),Cc=e=>jsx(j,{...e}),yc=e=>jsx(k$1,{...e}),wc=e=>jsx(i,{...e}),Tc=({provider:e,className:t,...o})=>jsx("img",{...o,alt:`${e} logo`,className:a("fk:size-3 fk:dark:invert",t),height:12,src:`https://models.dev/logos/${e}.svg`,width:12}),Sc=({className:e,...t})=>jsx("div",{className:a("fk:flex fk:shrink-0 fk:items-center fk:-space-x-1 fk:[&>img]:rounded-full fk:[&>img]:bg-background fk:[&>img]:p-px fk:[&>img]:ring-1 fk:dark:[&>img]:bg-foreground",e),...t}),Ic=({className:e,...t})=>jsx("span",{className:a("fk:flex-1 fk:truncate fk:text-left",e),...t});var Es=cva("fk:group/attachment fk:relative fk:flex fk:w-fit fk:max-w-full fk:min-w-0 fk:shrink-0 fk:flex-wrap fk:rounded-xl fk:border fk:bg-card fk:text-card-foreground fk:transition-colors fk:focus-within:ring-1 fk:focus-within:ring-ring/50 fk:has-[>a,>button]:hover:bg-muted/50 fk:data-[state=error]:border-destructive/30 fk:data-[state=idle]:border-dashed fk:corner-squircle",{variants:{size:{default:"fk:gap-2 fk:text-sm fk:has-data-[slot=attachment-content]:px-2.5 fk:has-data-[slot=attachment-content]:py-2 fk:has-data-[slot=attachment-media]:p-2",sm:"fk:gap-2.5 fk:text-xs fk:has-data-[slot=attachment-content]:px-2 fk:has-data-[slot=attachment-content]:py-1.5 fk:has-data-[slot=attachment-media]:p-1.5",xs:"fk:gap-1.5 fk:rounded-lg fk:text-xs fk:has-data-[slot=attachment-content]:px-1.5 fk:has-data-[slot=attachment-content]:py-1 fk:has-data-[slot=attachment-media]:p-1"},orientation:{horizontal:"fk:min-w-40 fk:items-center",vertical:"fk:w-24 fk:flex-col fk:has-data-[slot=attachment-content]:w-30"}}});function vo({className:e,state:t="done",size:o="default",orientation:r="horizontal",...a$1}){return jsx("div",{"data-slot":"attachment","data-state":t,"data-size":o,"data-orientation":r,className:a(Es({size:o,orientation:r}),e),...a$1})}var Hs=cva("fk:relative fk:flex fk:aspect-square fk:w-10 fk:shrink-0 fk:items-center fk:justify-center fk:overflow-hidden fk:rounded-lg fk:bg-muted fk:text-foreground fk:group-data-[orientation=vertical]/attachment:w-full fk:group-data-[size=sm]/attachment:w-8 fk:group-data-[size=xs]/attachment:w-7 fk:group-data-[size=xs]/attachment:rounded-md fk:group-data-[state=error]/attachment:bg-destructive/10 fk:group-data-[state=error]/attachment:text-destructive fk:group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! fk:[&_svg]:pointer-events-none fk:[&_svg:not([class*=size-])]:size-4 fk:group-data-[orientation=vertical]/attachment:[&_svg:not([class*=size-])]:size-6 fk:group-data-[size=xs]/attachment:[&_svg:not([class*=size-])]:size-3.5 fk:corner-squircle",{variants:{variant:{icon:"",image:"fk:opacity-60 fk:group-data-[state=done]/attachment:opacity-100 fk:group-data-[state=idle]/attachment:opacity-100 fk:*:[img]:aspect-square fk:*:[img]:w-full fk:*:[img]:object-cover"}},defaultVariants:{variant:"icon"}});function xo({className:e,variant:t="icon",...o}){return jsx("div",{"data-slot":"attachment-media","data-variant":t,className:a(Hs({variant:t}),e),...o})}function Po({className:e,...t}){return jsx("div",{"data-slot":"attachment-content",className:a("fk:max-w-full fk:min-w-0 fk:flex-1 fk:leading-tight fk:group-data-[orientation=vertical]/attachment:px-1",e),...t})}function Co({className:e,...t}){return jsx("span",{"data-slot":"attachment-title",className:a("fk:block fk:max-w-full fk:min-w-0 fk:truncate fk:font-medium fk:group-data-[state=processing]/attachment:shimmer fk:group-data-[state=uploading]/attachment:shimmer",e),...t})}function Fs({className:e,...t}){return jsx("span",{"data-slot":"attachment-description",className:a("fk:mt-0.5 fk:block fk:min-w-0 fk:truncate fk:text-xs fk:text-muted-foreground fk:group-data-[state=error]/attachment:text-destructive/80","fk:max-w-full",e),...t})}function yo({className:e,...t}){return jsx("div",{"data-slot":"attachment-actions",className:a("fk:relative fk:z-20 fk:flex fk:shrink-0 fk:items-center fk:group-data-[orientation=vertical]/attachment:absolute fk:group-data-[orientation=vertical]/attachment:top-3 fk:group-data-[orientation=vertical]/attachment:right-3 fk:group-data-[orientation=vertical]/attachment:gap-1",e),...t})}function wo({className:e,variant:t,size:o="icon-xs",...r}){return jsx(c,{"data-slot":"attachment-action",variant:t??"ghost",size:o,className:a(e),...r})}function Vs({className:e,asChild:t=false,type:o,...r}){let a$1=t?Slot.Root:"button";return jsx(a$1,{"data-slot":"attachment-trigger",type:t?void 0:o??"button",className:a("fk:absolute fk:inset-0 fk:z-10 fk:outline-none",e),...r})}function Gs({className:e,...t}){return jsx("div",{"data-slot":"attachment-group",className:a("fk:flex fk:min-w-0 fk:scroll-fade-x fk:snap-x fk:snap-mandatory fk:scroll-px-1 fk:gap-3 fk:overflow-x-auto fk:overscroll-x-contain fk:py-1 fk:*:data-[slot=attachment]:flex-none fk:*:data-[slot=attachment]:snap-start",e),...t})}var Ks=async e=>{try{let o=await(await fetch(e)).blob();return new Promise(r=>{let a=new FileReader;a.onloadend=()=>r(a.result),a.onerror=()=>r(null),a.readAsDataURL(o);})}catch{return null}},Js=async()=>{if(typeof navigator>"u"||!navigator.mediaDevices?.getDisplayMedia)return null;let e=null,t=document.createElement("video");t.muted=true,t.playsInline=true;try{e=await navigator.mediaDevices.getDisplayMedia({audio:!1,video:!0}),t.srcObject=e,await new Promise((f,p)=>{t.onloadedmetadata=()=>f(),t.onerror=()=>p(new Error("Failed to load screen stream"));}),await t.play();let o=t.videoWidth,r=t.videoHeight;if(!o||!r)return null;let a=document.createElement("canvas");a.width=o,a.height=r;let s=a.getContext("2d");if(!s)return null;s.drawImage(t,0,0,o,r);let i=await new Promise(f=>{a.toBlob(f,"image/png");});if(!i)return null;let l=new Date().toISOString().replaceAll(/[:.]/g,"-").replace("T","_").replace("Z","");return new File([i],`screenshot-${l}.png`,{lastModified:Date.now(),type:"image/png"})}finally{if(e)for(let o of e.getTracks())o.stop();t.pause(),t.srcObject=null;}},So=createContext(null),Io=createContext(null),Kc=()=>{let e=useContext(So);if(!e)throw new Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");return e},Dr=()=>useContext(So),Jc=()=>{let e=useContext(Io);if(!e)throw new Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");return e},js=()=>useContext(Io),jc=({initialInput:e="",children:t})=>{let[o,r]=useState(e),a=useCallback(()=>r(""),[]),[s,i]=useState([]),l=useRef(null),f=useRef(()=>{}),p=useCallback(d=>{let v=Array.from(d);v.length!==0&&i(E=>[...E,...v.map(M=>({filename:M.name,id:nanoid(),mediaType:M.type,type:"file",url:URL.createObjectURL(M)}))]);},[]),u=useCallback(d=>{i(v=>{let E=v.find(M=>M.id===d);return E?.url&&URL.revokeObjectURL(E.url),v.filter(M=>M.id!==d)});},[]),k=useCallback(()=>{i(d=>{for(let v of d)v.url&&URL.revokeObjectURL(v.url);return []});},[]),g=useRef(s);useEffect(()=>{g.current=s;},[s]),useEffect(()=>()=>{for(let d of g.current)d.url&&URL.revokeObjectURL(d.url);},[]);let T=useCallback(()=>{f.current?.();},[]),b=useMemo(()=>({add:p,clear:k,fileInputRef:l,files:s,openFileDialog:T,remove:u}),[s,p,u,k,T]),P=useCallback((d,v)=>{l.current=d.current,f.current=v;},[]),y=useMemo(()=>({__registerFileInput:P,attachments:b,textInput:{clear:a,setInput:r,value:o}}),[o,a,b,P]);return jsx(So.Provider,{value:y,children:jsx(Io.Provider,{value:b,children:t})})},Lr=createContext(null),It=()=>{let e=js(),o=useContext(Lr)??e;if(!o)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return o},Br=createContext(null),Zc=()=>{let e=useContext(Br);if(!e)throw new Error("usePromptInputReferencedSources must be used within a LocalReferencedSourcesContext.Provider");return e},Yc=({label:e="Add photos or files",onSelect:t,...o})=>{let r=It(),a=useCallback(s=>{t?.(s),!s.defaultPrevented&&r.openFileDialog();},[r,t]);return jsxs(j$1,{...o,onSelect:a,children:[jsx(ImageIcon,{className:"fk:mr-2 fk:size-4"})," ",e]})},Qc=({label:e="Take screenshot",onSelect:t,...o})=>{let r=It(),a=useCallback(async s=>{if(t?.(s),!s.defaultPrevented)try{let i=await Js();i&&r.add([i]);}catch(i){if(i instanceof DOMException&&(i.name==="NotAllowedError"||i.name==="AbortError"))return;throw i}},[t,r]);return jsxs(j$1,{...o,onSelect:a,children:[jsx(Monitor,{className:"fk:mr-2 fk:size-4"}),e]})},ed=({className:e,accept:t,multiple:o,globalDrop:r,syncHiddenInput:a$1,maxFiles:s,maxFileSize:i,onError:l,onSubmit:f,children:p,...u})=>{let k=Dr(),g=!!k,T=useRef(null),b=useRef(null),[P,y]=useState([]),d=g?k.attachments.files:P,[v,E]=useState([]),M=useRef(d);useEffect(()=>{M.current=d;},[d]);let Me=useCallback(()=>{T.current?.click();},[]),W=useCallback(m=>!t||t.trim()===""?true:t.split(",").map(h=>h.trim()).filter(Boolean).some(h=>{if(h.startsWith("."))return m.name.toLowerCase().endsWith(h.toLowerCase());if(h.endsWith("/*")){let S=h.slice(0,-1);return m.type.startsWith(S)}return m.type===h}),[t]),st=useCallback(m=>{let x=Array.from(m),h=x.filter(Q=>W(Q));if(x.length&&h.length===0){l?.({code:"accept",message:"No files match the accepted types."});return}let S=Q=>i?Q.size<=i:true,G=h.filter(S);if(h.length>0&&G.length===0){l?.({code:"max_file_size",message:"All files exceed the maximum size."});return}y(Q=>{let L=typeof s=="number"?Math.max(0,s-Q.length):void 0,he=typeof L=="number"?G.slice(0,L):G;typeof L=="number"&&G.length>L&&l?.({code:"max_files",message:"Too many files. Some were not added."});let ve=[];for(let Nt of he)ve.push({filename:Nt.name,id:nanoid(),mediaType:Nt.type,type:"file",url:URL.createObjectURL(Nt)});return [...Q,...ve]});},[W,s,i,l]),se=useCallback(m=>y(x=>{let h=x.find(S=>S.id===m);return h?.url&&URL.revokeObjectURL(h.url),x.filter(S=>S.id!==m)}),[]),J=useCallback(m=>{let x=Array.from(m),h=x.filter(ve=>W(ve));if(x.length&&h.length===0){l?.({code:"accept",message:"No files match the accepted types."});return}let S=ve=>i?ve.size<=i:true,G=h.filter(S);if(h.length>0&&G.length===0){l?.({code:"max_file_size",message:"All files exceed the maximum size."});return}let Q=d.length,L=typeof s=="number"?Math.max(0,s-Q):void 0,he=typeof L=="number"?G.slice(0,L):G;typeof L=="number"&&G.length>L&&l?.({code:"max_files",message:"Too many files. Some were not added."}),he.length>0&&k?.attachments.add(he);},[W,i,s,l,d.length,k]),j=useCallback(()=>g?k?.attachments.clear():y(m=>{for(let x of m)x.url&&URL.revokeObjectURL(x.url);return []}),[g,k]),Z=useCallback(()=>E([]),[]),F=g?J:st,Ae=g?k.attachments.remove:se,it=g?k.attachments.openFileDialog:Me,De=useCallback(()=>{j(),Z();},[j,Z]);useEffect(()=>{g&&k.__registerFileInput(T,()=>T.current?.click());},[g,k]),useEffect(()=>{a$1&&T.current&&d.length===0&&(T.current.value="");},[d,a$1]),useEffect(()=>{let m=b.current;if(!m||r)return;let x=S=>{S.dataTransfer?.types?.includes("Files")&&S.preventDefault();},h=S=>{S.dataTransfer?.types?.includes("Files")&&S.preventDefault(),S.dataTransfer?.files&&S.dataTransfer.files.length>0&&F(S.dataTransfer.files);};return m.addEventListener("dragover",x),m.addEventListener("drop",h),()=>{m.removeEventListener("dragover",x),m.removeEventListener("drop",h);}},[F,r]),useEffect(()=>{if(!r)return;let m=h=>{h.dataTransfer?.types?.includes("Files")&&h.preventDefault();},x=h=>{h.dataTransfer?.types?.includes("Files")&&h.preventDefault(),h.dataTransfer?.files&&h.dataTransfer.files.length>0&&F(h.dataTransfer.files);};return document.addEventListener("dragover",m),document.addEventListener("drop",x),()=>{document.removeEventListener("dragover",m),document.removeEventListener("drop",x);}},[F,r]),useEffect(()=>()=>{if(!g)for(let m of M.current)m.url&&URL.revokeObjectURL(m.url);},[g]);let lt=useCallback(m=>{m.currentTarget.files&&F(m.currentTarget.files),m.currentTarget.value="";},[F]),D=useMemo(()=>({add:F,clear:j,fileInputRef:T,files:d.map(m=>({...m,id:m.id})),openFileDialog:it,remove:Ae}),[d,F,Ae,j,it]),ft=useMemo(()=>({add:m=>{let x=Array.isArray(m)?m:[m];E(h=>[...h,...x.map(S=>({...S,id:nanoid()}))]);},clear:Z,remove:m=>{E(x=>x.filter(h=>h.id!==m));},sources:v}),[v,Z]),ie=useCallback(async m=>{m.preventDefault();let x=m.currentTarget,h=g?k.textInput.value:new FormData(x).get("message")||"";g||x.reset();try{let S=await Promise.all(d.map(async({id:Q,...L})=>{if(L.url?.startsWith("blob:")){let he=await Ks(L.url);return {...L,url:he??L.url}}return L})),G=f({files:S,text:h},m);if(G instanceof Promise)try{await G,De(),g&&k.textInput.clear();}catch{}else De(),g&&k.textInput.clear();}catch{}},[g,k,d,f,De]),Y=jsxs(Fragment,{children:[jsx("input",{accept:t,"aria-label":"Upload files",className:"fk:hidden",multiple:o,onChange:lt,ref:T,title:"Upload files",type:"file"}),jsx("form",{className:a("fk:w-full",e),onSubmit:ie,ref:b,...u,children:jsx(mo,{className:"fk:overflow-hidden fk:rounded-3xl",children:p})})]}),Le=jsx(Br.Provider,{value:ft,children:Y});return jsx(Lr.Provider,{value:D,children:Le})},td=({className:e,...t})=>jsx("div",{className:a("fk:contents",e),...t}),od=({onChange:e,onKeyDown:t,className:o,placeholder:r="What would you like to know?",...a$1})=>{let s=Dr(),i=It(),[l,f]=useState(false),p=useCallback(b=>{if(t?.(b),!b.defaultPrevented){if(b.key==="Enter"){if(l||b.nativeEvent.isComposing||b.shiftKey)return;b.preventDefault();let{form:P}=b.currentTarget;if(P?.querySelector('button[type="submit"]')?.disabled)return;P?.requestSubmit();}if(b.key==="Backspace"&&b.currentTarget.value===""&&i.files.length>0){b.preventDefault();let P=i.files[i.files.length-1];P&&i.remove(P.id);}}},[t,l,i]),u=useCallback(b=>{let P=b.clipboardData?.items;if(!P)return;let y=[];for(let d of Array.from(P))if(d.kind==="file"){let v=d.getAsFile();v&&y.push(v);}y.length>0&&(b.preventDefault(),i.add(y));},[i]),k=useCallback(()=>f(false),[]),g=useCallback(()=>f(true),[]),T=s?{onChange:b=>{s.textInput.setInput(b.currentTarget.value),e?.(b);},value:s.textInput.value}:{onChange:e};return jsx(ko,{className:a("fk:field-sizing-content fk:max-h-48 fk:min-h-16 fk:p-3",o),name:"message",onCompositionEnd:k,onCompositionStart:g,onKeyDown:p,onPaste:u,placeholder:r,...a$1,...T})},Mr=e=>!!(e.url&&e.mediaType?.startsWith("image/")),Zs=()=>{let e=It();return e.files.map(t=>{let o=t.filename??"Attachment";return jsxs(vo,{size:"sm",children:[jsx(xo,{variant:Mr(t)?"image":"icon",children:Mr(t)?jsx("img",{alt:o,src:t.url}):jsx(FileTextIcon,{})}),jsx(Po,{children:jsx(Co,{children:o})}),jsx(yo,{children:jsx(wo,{"aria-label":`Remove ${o}`,onClick:()=>e.remove(t.id),children:jsx(XIcon,{})})})]},t.id)})},rd=({className:e,children:t,...o})=>jsx(Ct,{align:"block-start",className:a("fk:flex-wrap fk:gap-1",e),...o,children:t??jsx(Zs,{})}),nd=({className:e,...t})=>jsx(Ct,{align:"block-end",className:a("fk:justify-between fk:gap-1",e),...t}),ad=({className:e,...t})=>jsx("div",{className:a("fk:flex fk:min-w-0 fk:items-center fk:gap-1",e),...t}),Ys=({variant:e$1="ghost",className:t,size:o,tooltip:r,...a$1})=>{let s=o??(Children.count(a$1.children)>1?"sm":"icon-sm"),i=jsx(yt,{className:a(t),size:s,type:"button",variant:e$1,...a$1});if(!r)return i;let l=typeof r=="string"?r:r.content,f=typeof r=="string"?void 0:r.shortcut,p=typeof r=="string"?"top":r.side??"top";return jsxs(b,{children:[jsx(c$1,{asChild:true,children:i}),jsxs(e,{side:p,children:[l,f&&jsx("span",{className:"fk:ml-2 fk:text-muted-foreground",children:f})]})]})},sd=e=>jsx(e$3,{...e}),id=({className:e,children:t,size:o="icon-sm",variant:r="outline",...a$1})=>jsx(g$2,{asChild:true,children:jsx(Ys,{className:a("fk:rounded-full",e),size:o,variant:r,...a$1,children:t??jsx(PlusIcon,{className:"fk:size-4"})})}),ld=({className:e,onCloseAutoFocus:t,...o})=>jsx(h$1,{align:"start",className:a(e),onCloseAutoFocus:r=>{t?.(r),!r.defaultPrevented&&r.preventDefault();},...o}),fd=({className:e,...t})=>jsx(j$1,{className:a(e),...t}),pd=({className:e,variant:t="default",size:o="icon-sm",status:r,onStop:a$1,onClick:s,children:i,...l})=>{let f=r==="submitted"||r==="streaming",p=jsx(ArrowUpIcon,{className:"fk:size-4"});r==="submitted"?p=jsx(uo,{}):r==="streaming"?p=jsx(SquareIcon,{className:"fk:size-4"}):r==="error"&&(p=jsx(XIcon,{className:"fk:size-4"}));let u=useCallback(k=>{if(f&&a$1){k.preventDefault(),a$1();return}s?.(k);},[f,a$1,s]);return jsx(yt,{"aria-label":f?"Stop":"Submit",className:a("fk:rounded-full",e),onClick:u,size:o,type:f&&a$1?"button":"submit",variant:t,...l,children:i??p})},cd=e=>jsx(a$3,{...e}),dd=({className:e,...t})=>jsx(d$1,{className:a("fk:border-none fk:bg-transparent fk:font-medium fk:text-muted-foreground fk:shadow-none fk:transition-colors","fk:hover:bg-accent fk:hover:text-foreground fk:aria-expanded:bg-accent fk:aria-expanded:text-foreground",e),...t}),ud=({className:e,...t})=>jsx(e$1,{className:a(e),...t}),md=({className:e,...t})=>jsx(g,{className:a(e),...t}),kd=({className:e,...t})=>jsx(c$2,{className:a(e),...t}),gd=({openDelay:e=0,closeDelay:t=0,...o})=>jsx(et,{closeDelay:t,openDelay:e,...o}),bd=e=>jsx(tt,{...e}),hd=({align:e="start",...t})=>jsx(ot,{align:e,...t}),vd=({className:e,...t})=>jsx("div",{className:a(e),...t}),xd=({className:e,...t})=>jsx("div",{className:a(e),...t}),Pd=({className:e,...t})=>jsx("h3",{className:a("fk:mb-2 fk:px-3 fk:font-medium fk:text-muted-foreground fk:text-xs",e),...t}),Cd=({className:e,...t})=>jsx("div",{className:a("fk:space-y-1",e),...t}),yd=({className:e,...t})=>jsx("div",{className:a("fk:flex fk:items-center fk:gap-2 fk:px-3 fk:py-2 fk:text-xs fk:hover:bg-accent",e),...t}),wd=({className:e,...t})=>jsx(c$3,{className:a(e),...t}),Td=({className:e,...t})=>jsx(e$2,{className:a(e),...t}),Sd=({className:e,...t})=>jsx(f,{className:a(e),...t}),Id=({className:e,...t})=>jsx(g$1,{className:a(e),...t}),Nd=({className:e,...t})=>jsx(h,{className:a(e),...t}),Rd=({className:e,...t})=>jsx(j,{className:a(e),...t}),Md=({className:e,...t})=>jsx(i,{className:a(e),...t});var zr=new Map,ri=e=>{let t=zr.get(e);return t||(t=motion.create(e),zr.set(e,t)),t},ni=({children:e,as:t="p",className:o,duration:r=2,spread:a$1=2})=>{let s=ri(t),i=useMemo(()=>(e?.length??0)*a$1,[e,a$1]);return jsx(s,{animate:{backgroundPosition:"0% center"},className:a("fk:relative fk:inline-block fk:bg-[length:250%_100%,auto] fk:bg-clip-text fk:text-transparent","fk:[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] fk:[background-repeat:no-repeat,padding-box]",o),initial:{backgroundPosition:"100% center"},style:{"--spread":`${i}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{duration:r,ease:"linear",repeat:Number.POSITIVE_INFINITY},children:e})},No=memo(ni);var Fr=createContext(null),hi=()=>{let e=useContext(Fr);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},vi=1e3,xi=1e3,Pi=memo(({className:e,isStreaming:t=false,open:o,defaultOpen:r,onOpenChange:a$1,duration:s,children:i,...l})=>{let f=r??t,p=r===false,[u,k]=useControllableState({defaultProp:f,onChange:a$1,prop:o}),[g,T]=useControllableState({defaultProp:void 0,prop:s}),b=useRef(t),[P,y]=useState(false),d=useRef(null);useEffect(()=>{t?(b.current=true,d.current===null&&(d.current=Date.now())):d.current!==null&&(T(Math.ceil((Date.now()-d.current)/xi)),d.current=null);},[t,T]),useEffect(()=>{t&&!u&&!p&&k(true);},[t,u,k,p]),useEffect(()=>{if(b.current&&!t&&u&&!P){let M=setTimeout(()=>{k(false),y(true);},vi);return ()=>clearTimeout(M)}},[t,u,k,P]);let v=useCallback(M=>{k(M);},[k]),E=useMemo(()=>({duration:g,isOpen:u,isStreaming:t,setIsOpen:k}),[g,u,t,k]);return jsx(Fr.Provider,{value:E,children:jsx(ue,{className:a("fk:not-prose fk:mb-4",e),onOpenChange:v,open:u,...l,children:i})})}),Ci=(e,t)=>e||t===0?jsx(No,{duration:1,children:"Thinking..."}):t===void 0?jsx("p",{children:"Thought for a few seconds"}):jsxs("p",{children:["Thought for ",t," seconds"]}),yi=memo(({className:e,children:t,getThinkingMessage:o=Ci,...r})=>{let{isStreaming:a$1,isOpen:s,duration:i}=hi();return jsx(me,{className:a("fk:flex fk:w-full fk:items-center fk:gap-2 fk:text-muted-foreground fk:text-sm fk:transition-colors fk:hover:text-foreground",e),...r,children:t??jsxs(Fragment,{children:[jsx(BrainIcon,{className:"fk:size-4"}),o(a$1,i),jsx(ChevronDownIcon,{className:a("fk:size-4 fk:transition-transform",s?"fk:rotate-180":"fk:rotate-0")})]})})}),wi={cjk:cjk,code:code,math:math,mermaid:mermaid},Ti=memo(({className:e,children:t,...o})=>jsx(ke,{className:a("fk:mt-4 fk:text-sm","fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:slide-out-to-top-2 fk:data-[state=open]:slide-in-from-top-2 fk:text-muted-foreground fk:outline-none fk:data-[state=closed]:animate-out fk:data-[state=open]:animate-in",e),...o,children:jsx(Streamdown,{plugins:wi,children:t})}));Pi.displayName="Reasoning";yi.displayName="ReasoningTrigger";Ti.displayName="ReasoningContent";var eu=({className:e,...t})=>jsx(ue,{className:a("fk:not-prose fk:mb-4 fk:text-primary fk:text-xs",e),...t}),tu=({className:e,count:t,children:o,...r})=>jsx(me,{className:a("fk:flex fk:items-center fk:gap-2",e),...r,children:o??jsxs(Fragment,{children:[jsxs("p",{className:"fk:font-medium",children:["Used ",t," sources"]}),jsx(ChevronDownIcon,{className:"fk:h-4 fk:w-4"})]})}),ou=({className:e,...t})=>jsx(ke,{className:a("fk:mt-3 fk:flex fk:w-fit fk:flex-col fk:gap-2","fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:slide-out-to-top-2 fk:data-[state=open]:slide-in-from-top-2 fk:outline-none fk:data-[state=closed]:animate-out fk:data-[state=open]:animate-in",e),...t}),ru=({href:e,title:t,children:o,...r})=>jsx("a",{className:"fk:flex fk:items-center fk:gap-2",href:e,rel:"noreferrer",target:"_blank",...r,children:o??jsxs(Fragment,{children:[jsx(BookIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:block fk:font-medium",children:t})]})});var Di=6e4;function Li(){return typeof window<"u"&&"MediaRecorder"in window&&typeof navigator<"u"&&"mediaDevices"in navigator&&typeof navigator.mediaDevices.getUserMedia=="function"}function Bi(){return ["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(t=>MediaRecorder.isTypeSupported(t))}function Or(e,t){return e instanceof DOMException&&(e.name==="NotAllowedError"||e.name==="PermissionDeniedError")?new Error("Microphone permission was denied. Enable the microphone to dictate."):e instanceof DOMException&&e.name==="NotFoundError"?new Error("No microphone was found."):e instanceof Error?e:new Error(t)}function zi(e){return e instanceof Error&&e.name==="AbortError"}function Ei(e,t,o){return e?o?"Cancel transcription":t?"Stop recording":"Dictate":"Dictation is not available in this browser."}var cu=({className:e$1,disabled:t,onAudioRecorded:o,onError:r,onTranscriptionChange:a$1,size:s="icon-sm",variant:i="ghost",...l})=>{let[f,p]=useState(false),[u,k]=useState(false),[g,T]=useState(false),b$1=useRef(null),P=useRef(null),y=useRef([]),d=useRef(null),v=useRef(null),E=useRef(false),M=useRef(!!t),Me=useRef(o),W=useRef(r),st=useRef(a$1);M.current=!!t,Me.current=o,W.current=r,st.current=a$1,useEffect(()=>{T(Li());},[]);let se=useCallback(()=>{if(P.current){for(let D of P.current.getTracks())D.stop();P.current=null;}},[]),J=useCallback(()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null);},[]),j=useCallback(()=>{J(),b$1.current?.state==="recording"&&b$1.current.stop(),p(false);},[J]),Z=useCallback(()=>{v.current?.abort(),v.current=null,k(false);},[]),F=useCallback(()=>{Z(),J();let D=b$1.current;D?.state==="recording"&&(E.current=true,D.stop()),p(false),se();},[Z,J,se]),Ae=useCallback(async()=>{if(!M.current){if(!Me.current){W.current?.(new Error("Dictation is not configured."));return}try{let D=await navigator.mediaDevices.getUserMedia({audio:!0});if(M.current){for(let Y of D.getTracks())Y.stop();return}P.current=D;let ft=Bi(),ie=ft?new MediaRecorder(D,{mimeType:ft}):new MediaRecorder(D);y.current=[],ie.ondataavailable=Y=>{Y.data.size>0&&y.current.push(Y.data);},ie.onstop=async()=>{if(se(),J(),p(!1),E.current){E.current=!1,y.current=[];return}let Y=new Blob(y.current,{type:ie.mimeType||"audio/webm"});if(Y.size===0)return;let Le=new AbortController;v.current=Le,k(!0);try{let m=Me.current;if(!m)return;let x=await m(Y,Le.signal);x&&st.current?.(x);}catch(m){if(zi(m))return;W.current?.(Or(m,"Transcription failed."));}finally{v.current===Le&&(v.current=null,k(!1));}},ie.onerror=()=>{p(!1),se(),J(),W.current?.(new Error("Recording failed. Try again."));},b$1.current=ie,ie.start(250),p(!0),d.current=window.setTimeout(()=>{j();},Di);}catch(D){p(false),se(),W.current?.(Or(D,"Could not start the microphone."));}}},[J,se,j]);useEffect(()=>{t&&F();},[F,t]),useEffect(()=>()=>{F();},[F]);let it=useCallback(()=>{if(u){Z();return}if(f){j();return}Ae();},[Z,f,u,Ae,j]),De=t||!g||!o,lt=Ei(g&&!!o,f,u);return jsxs(b,{children:[jsx(c$1,{asChild:true,children:jsxs("span",{className:"fk:relative fk:inline-flex fk:items-center fk:justify-center",children:[f?[0,1,2].map(D=>jsx("span",{className:"fk:absolute fk:inset-0 fk:animate-ping fk:rounded-full fk:border-2 fk:border-red-400/30 fk:corner-squircle",style:{animationDelay:`${String(D*.3)}s`,animationDuration:"2s"}},D)):null,jsxs(c,{"aria-label":lt,"aria-pressed":f,size:s,variant:f?"destructive":i,...l,className:a("fk:relative fk:z-10 fk:rounded-full fk:dark:hover:bg-accent fk:corner-squircle",e$1),disabled:De,onClick:it,type:"button",children:[u?jsx(LoaderIcon,{className:"fk:size-4 fk:animate-spin"}):null,!u&&f?jsx(SquareIcon,{className:"fk:size-4"}):null,u||f?null:jsx(MicIcon,{className:"fk:size-5"})]})]})}),jsx(e,{children:lt})]})};var hu=({className:e,children:t,...o})=>jsxs(m,{className:"fk:w-full fk:overflow-x-auto fk:whitespace-nowrap",...o,children:[jsx("div",{className:a("fk:flex fk:w-max fk:flex-nowrap fk:items-center fk:gap-2",e),children:t}),jsx(n,{className:"fk:hidden",orientation:"horizontal"})]}),vu=({suggestion:e,onClick:t,className:o,variant:r="outline",size:a$1="sm",children:s,...i})=>{let l=useCallback(()=>{t?.(e);},[t,e]);return jsx(c,{className:a("fk:cursor-pointer fk:rounded-full fk:px-4 fk:corner-squircle",o),onClick:l,size:a$1,type:"button",variant:r,...i,children:s||e})};var Nu=({className:e,...t})=>jsx(ue,{className:a("fk:group fk:not-prose fk:mb-4 fk:w-full fk:rounded-md fk:border fk:corner-squircle",e),...t}),Ui={"approval-requested":"Awaiting Approval","approval-responded":"Responded","input-available":"Running","input-streaming":"Pending","output-available":"Completed","output-denied":"Denied","output-error":"Error"},qi={"approval-requested":jsx(ClockIcon,{className:"fk:size-4 fk:text-yellow-600"}),"approval-responded":jsx(CheckCircleIcon,{className:"fk:size-4 fk:text-blue-600"}),"input-available":jsx(ClockIcon,{className:"fk:size-4 fk:animate-pulse"}),"input-streaming":jsx(CircleIcon,{className:"fk:size-4"}),"output-available":jsx(CheckCircleIcon,{className:"fk:size-4 fk:text-green-600"}),"output-denied":jsx(XCircleIcon,{className:"fk:size-4 fk:text-orange-600"}),"output-error":jsx(XCircleIcon,{className:"fk:size-4 fk:text-red-600"})},$i=e=>jsxs(b$3,{className:"fk:gap-1.5 fk:py-px fk:rounded-full fk:text-xs fk:corner-squircle",variant:"secondary",children:[qi[e],Ui[e]]}),Ru=({className:e,title:t,type:o,state:r,toolName:a$1,...s})=>{let i=o==="dynamic-tool"?a$1:o.split("-").slice(1).join("-");return jsxs(me,{className:a("fk:flex fk:w-full fk:items-center fk:justify-between fk:gap-4 fk:px-3 fk:py-2",e),...s,children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(WrenchIcon,{className:"fk:size-4 fk:text-muted-foreground"}),jsx("span",{className:"fk:font-medium fk:text-sm",children:t??i}),$i(r)]}),jsx(ChevronDownIcon,{className:"fk:size-4 fk:text-muted-foreground fk:transition-transform fk:group-data-[state=open]:rotate-180"})]})},Mu=({className:e,...t})=>jsx(ke,{className:a("fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:slide-out-to-top-2 fk:data-[state=open]:slide-in-from-top-2 fk:space-y-4 fk:p-4 fk:text-popover-foreground fk:outline-none fk:data-[state=closed]:animate-out fk:data-[state=open]:animate-in",e),...t}),Au=({className:e,input:t,...o})=>jsxs("div",{className:a("fk:space-y-2 fk:overflow-hidden",e),...o,children:[jsx("h4",{className:"fk:font-medium fk:text-muted-foreground fk:text-xs fk:uppercase fk:tracking-wide",children:"Parameters"}),jsx("div",{className:"fk:rounded-md fk:bg-muted/50 fk:corner-squircle",children:jsx(wt,{code:JSON.stringify(t,null,2),language:"json"})})]}),Du=({className:e,output:t,errorText:o,...r})=>{if(!(t||o))return null;let a$1=jsx("div",{children:t});return typeof t=="object"&&!isValidElement(t)?a$1=jsx(wt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(a$1=jsx(wt,{code:t,language:"json"})),jsxs("div",{className:a("fk:space-y-2",e),...r,children:[jsx("h4",{className:"fk:font-medium fk:text-muted-foreground fk:text-xs fk:uppercase fk:tracking-wide",children:o?"Error":"Result"}),jsxs("div",{className:a("fk:overflow-x-auto fk:rounded-md fk:text-xs fk:[&_table]:w-full fk:corner-squircle",o?"fk:bg-destructive/10 fk:text-destructive":"fk:bg-muted/50 fk:text-foreground"),children:[o&&jsx("div",{children:o}),a$1]})]})};
6
+ export{Wn as $,Hp as $a,id as $b,vn as A,ep as Aa,Sc as Ab,yi as Ac,Oo as B,go as Ba,Ic as Bb,Ti as Bc,_o as C,tp as Ca,vo as Cb,eu as Cc,Qt as D,op as Da,xo as Db,tu as Dc,eo as E,rp as Ea,Po as Eb,ou as Ec,xn as F,np as Fa,Co as Fb,ru as Fc,to as G,ap as Ga,Fs as Gb,cu as Gc,oo as H,sp as Ha,yo as Hb,hu as Hc,yn as I,ip as Ia,wo as Ib,vu as Ic,Ye as J,lp as Ja,Vs as Jb,Nu as Jc,Rn as K,gr as Ka,Gs as Kb,$i as Kc,no as L,ds as La,Kc as Lb,Ru as Lc,Mn as M,bp as Ma,Jc as Mb,Mu as Mc,ao as N,hp as Na,jc as Nb,Au as Nc,An as O,vp as Oa,It as Ob,Du as Oc,so as P,xp as Pa,Br as Pb,ct as Q,us as Qa,Zc as Qb,io as R,wt as Ra,Yc as Rb,Dn as S,Pp as Sa,Qc as Sb,dt as T,Cp as Ta,ed as Tb,ut as U,yp as Ua,td as Ub,mt as V,wp as Va,od as Vb,lo as W,Tp as Wa,rd as Wb,_n as X,Sp as Xa,nd as Xb,Un as Y,Bp as Ya,ad as Yb,qn as Z,zp as Za,Ys as Zb,$n as _,Ep as _a,sd as _b,ht as a,Xn as aa,vs as ab,ld as ac,aa as b,Kn as ba,Fp as bb,fd as bc,ia as c,Jn as ca,Yp as cb,pd as cc,la as d,jn as da,Qp as db,cd as dc,Wr as e,Yn as ea,ec as eb,dd as ec,Qr as f,ea as fa,tc as fb,ud as fc,en as g,ta as ga,oc as gb,md as gc,Xe as h,oa as ha,rc as hb,kd as hc,tn as i,Qo as ia,nc as ib,gd as ic,on as j,pa as ja,ac as jb,bd as jc,rn as k,Sf as ka,sc as kb,hd as kc,nn as l,lr as la,ic as lb,vd as lc,an as m,Ls as mb,xd as mc,ln as n,Na as na,lc as nb,Pd as nc,ue as o,et as oa,mc as ob,Cd as oc,me as p,tt as pa,kc as pb,yd as pc,ke as q,ot as qa,gc as qb,wd as qc,fn as r,uo as ra,bc as rb,Td as rc,pn as s,mo as sa,hc as sb,Sd as sc,cn as t,Ct as ta,vc as tb,Id as tc,dn as u,yt as ua,xc as ub,Nd as uc,mn as v,La as va,Pc as vb,Rd as vc,kn as w,Ba as wa,Cc as wb,Md as wc,gn as x,ko as xa,yc as xb,No as xc,Yt as y,$a as ya,wc as yb,hi as yc,hn as z,Wa as za,Tc as zb,Pi as zc};//# sourceMappingURL=chunk-RULCANNM.js.map
7
+ //# sourceMappingURL=chunk-RULCANNM.js.map