@flexkit/studio 0.2.7 → 0.2.9

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 (59) hide show
  1. package/dist/activity-nav-button-EP6GYASE.js +2 -0
  2. package/dist/{activity-nav-button-SJW67XZE.js.map → activity-nav-button-EP6GYASE.js.map} +1 -1
  3. package/dist/chat-page-FLCLBZUX.js +4 -0
  4. package/dist/chat-page-FLCLBZUX.js.map +1 -0
  5. package/dist/{chunk-Y4Z3P43B.js → chunk-3OAEG7AE.js} +2 -2
  6. package/dist/{chunk-Y4Z3P43B.js.map → chunk-3OAEG7AE.js.map} +1 -1
  7. package/dist/{chunk-HFL6QZIF.js → chunk-753V3IWO.js} +3 -3
  8. package/dist/{chunk-HFL6QZIF.js.map → chunk-753V3IWO.js.map} +1 -1
  9. package/dist/chunk-ACS3TGGP.js +2 -0
  10. package/dist/chunk-ACS3TGGP.js.map +1 -0
  11. package/dist/{chunk-E7B5FQKW.js → chunk-CMZV7EPC.js} +3 -3
  12. package/dist/{chunk-E7B5FQKW.js.map → chunk-CMZV7EPC.js.map} +1 -1
  13. package/dist/chunk-ROCYIGFD.js +3 -0
  14. package/dist/chunk-ROCYIGFD.js.map +1 -0
  15. package/dist/{chunk-RGTJVPNH.js → chunk-S5I2UQ6Y.js} +2 -2
  16. package/dist/{chunk-RGTJVPNH.js.map → chunk-S5I2UQ6Y.js.map} +1 -1
  17. package/dist/{chunk-F47EIXR2.js → chunk-TK4UYLCV.js} +2 -2
  18. package/dist/{chunk-F47EIXR2.js.map → chunk-TK4UYLCV.js.map} +1 -1
  19. package/dist/{chunk-FEOT7BNI.js → chunk-UUC4PXUB.js} +3 -3
  20. package/dist/{chunk-FEOT7BNI.js.map → chunk-UUC4PXUB.js.map} +1 -1
  21. package/dist/{chunk-4JWGLBGC.js → chunk-VARGD74X.js} +2 -2
  22. package/dist/{chunk-4JWGLBGC.js.map → chunk-VARGD74X.js.map} +1 -1
  23. package/dist/{chunk-RKI5N2N4.js → chunk-WQUCLXMU.js} +2 -2
  24. package/dist/{chunk-RKI5N2N4.js.map → chunk-WQUCLXMU.js.map} +1 -1
  25. package/dist/chunk-Z5TZVTX3.js +8 -0
  26. package/dist/chunk-Z5TZVTX3.js.map +1 -0
  27. package/dist/index.css +31 -0
  28. package/dist/index.d.ts +27 -1
  29. package/dist/index.js +1 -1
  30. package/dist/{list-GLA2XRW2.js → list-37T3A4P7.js} +2 -2
  31. package/dist/{list-GLA2XRW2.js.map → list-37T3A4P7.js.map} +1 -1
  32. package/dist/pages-R35VNLN5.js +5 -0
  33. package/dist/pages-R35VNLN5.js.map +1 -0
  34. package/dist/{plugin-pages-5TS6D4IH.js → plugin-pages-FTCCUJBD.js} +2 -2
  35. package/dist/{plugin-pages-5TS6D4IH.js.map → plugin-pages-FTCCUJBD.js.map} +1 -1
  36. package/dist/{root-O3WHSEVY.js → root-4YLQNL62.js} +2 -2
  37. package/dist/{root-O3WHSEVY.js.map → root-4YLQNL62.js.map} +1 -1
  38. package/dist/{root-TNGHMQHM.js → root-E6BD5WNQ.js} +3 -3
  39. package/dist/{root-TNGHMQHM.js.map → root-E6BD5WNQ.js.map} +1 -1
  40. package/dist/{root-6W74NN2R.js → root-OBXJWAZN.js} +2 -2
  41. package/dist/{root-6W74NN2R.js.map → root-OBXJWAZN.js.map} +1 -1
  42. package/dist/{root-GMEW7KHI.js → root-TKWXADN7.js} +3 -3
  43. package/dist/{root-GMEW7KHI.js.map → root-TKWXADN7.js.map} +1 -1
  44. package/dist/{search-ZBGHTWVD.js → search-YS3HRU2A.js} +2 -2
  45. package/dist/{search-ZBGHTWVD.js.map → search-YS3HRU2A.js.map} +1 -1
  46. package/dist/{skills-pages-UXHYS3YQ.js → skills-pages-4UQRSKQS.js} +2 -2
  47. package/dist/{skills-pages-UXHYS3YQ.js.map → skills-pages-4UQRSKQS.js.map} +1 -1
  48. package/package.json +3 -3
  49. package/dist/activity-nav-button-SJW67XZE.js +0 -2
  50. package/dist/chat-page-6IXM63AU.js +0 -4
  51. package/dist/chat-page-6IXM63AU.js.map +0 -1
  52. package/dist/chunk-3GUFJ6KL.js +0 -2
  53. package/dist/chunk-3GUFJ6KL.js.map +0 -1
  54. package/dist/chunk-JK3IOLJZ.js +0 -3
  55. package/dist/chunk-JK3IOLJZ.js.map +0 -1
  56. package/dist/chunk-QNGDJNWD.js +0 -8
  57. package/dist/chunk-QNGDJNWD.js.map +0 -1
  58. package/dist/pages-PUJH4BYG.js +0 -3
  59. package/dist/pages-PUJH4BYG.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/data-grid/data-table-row-actions.tsx","../src/data-grid/data-table-view-options.tsx","../src/data-grid/data-table-toolbar.tsx"],"names":["DataTableRowActions","entityName","entityNamePlural","row","options","actionDispatch","useDispatch","canMutate","useCanMutate","entityId","canDelete","canEdit","handleEdit","handleDelete","jsxs","Button","jsx","PencilIcon","Trash2Icon","DropdownMenu","DropdownMenuTrigger","Ellipsis","DropdownMenuContent","DropdownMenuItem","DropdownMenuSeparator","DataTableViewOptions","table","Settings2","DropdownMenuLabel","column","DropdownMenuCheckboxItem","value","DataTableToolbar","isReloading","onReload","appDispatch","useAppDispatch","appContext","useAppContext","apolloClient","useApolloClient","currentProject","currentProjectId","useConfig","schema","scopes","runMutation","setMutation","setOptions","useEntityMutation","isDeleting","setIsDeleting","useState","selectedIds","handleCreate","handleScopeChange","deleteSelected","ids","mutation","getEntityDeleteMutation","resolve","reject","gql","getEntityDeleteWhere","cache","id","error","handleBatchDelete","itemLabel","idsToDelete","scheduleEntityListRemoval","getEntityListQueryName","toast","Select","SelectTrigger","SelectValue","find","propEq","SelectContent","scopeItem","SelectItem","RefreshCw","DataTableSortedBy","PermissionTooltip","Loader2","Trash2"],"mappings":"0rBA0BO,SAASA,EAAAA,CAA2B,CACzC,UAAA,CAAAC,CAAAA,CACA,gBAAA,CAAAC,CAAAA,CACA,GAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC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sourcesContent":["'use client';\n\nimport type { JSX } from 'react';\nimport { Ellipsis, PencilIcon, Trash2Icon } from 'lucide-react';\nimport type { Row } from '@tanstack/react-table';\nimport { Button } from '../ui/primitives/button';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../ui/primitives/dropdown-menu';\nimport { useDispatch } from '../entities/actions-context';\nimport { useCanMutate } from '../core/permissions';\n\ninterface DataTableRowActionsProps<TData> {\n entityName: string;\n entityNamePlural: string;\n row: Row<TData>;\n options?: {\n canDelete?: boolean;\n canEdit?: boolean;\n };\n}\n\nexport function DataTableRowActions<TData>({\n entityName,\n entityNamePlural,\n row,\n options = { canDelete: true, canEdit: true },\n}: DataTableRowActionsProps<TData>): JSX.Element {\n const actionDispatch = useDispatch();\n const canMutate = useCanMutate();\n // @ts-expect-error -- the DataGrid's original type doesn't know about the _id property\n const entityId = row.original._id;\n // Read-only roles keep the pencil (the drawer doubles as their read view)\n // but lose the delete affordance entirely.\n const canDelete = (options.canDelete ?? true) && canMutate;\n const canEdit = options.canEdit ?? true;\n\n function handleEdit(): void {\n actionDispatch({ type: 'EditEntity', payload: { entityId, entityNamePlural } });\n }\n\n function handleDelete(): void {\n actionDispatch({ type: 'DeleteEntity', payload: { entityId, entityName } });\n }\n\n return (\n <div className=\"fk:flex\">\n {canEdit && (\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1\" onClick={handleEdit} variant=\"ghost\">\n <PencilIcon className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Edit</span>\n </Button>\n )}\n {canDelete && !canEdit && (\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1\" onClick={handleDelete} variant=\"ghost\">\n <Trash2Icon className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Delete</span>\n </Button>\n )}\n {canEdit && canDelete && (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0\" variant=\"ghost\">\n <Ellipsis className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Additional actions</span>\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"w-[160px]\">\n <DropdownMenuItem onClick={handleEdit}>\n <PencilIcon className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n Edit\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem className=\"fk:text-destructive\" onClick={handleDelete}>\n <Trash2Icon className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n </div>\n );\n}\n","'use client';\n\nimport type { JSX } from 'react';\nimport { Settings2 } from 'lucide-react';\nimport type { Table } from '@tanstack/react-table';\nimport { Button } from '../ui/primitives/button';\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../ui/primitives/dropdown-menu';\n\ninterface DataTableViewOptionsProps<TData> {\n table: Table<TData>;\n}\n\nexport function DataTableViewOptions<TData>({ table }: DataTableViewOptionsProps<TData>): JSX.Element {\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button className=\"fk:hidden fk:h-8 fk:lg:flex\" size=\"sm\" variant=\"outline\">\n <Settings2 className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n View\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"fk:w-[150px]\">\n <DropdownMenuLabel>Toggle columns</DropdownMenuLabel>\n <DropdownMenuSeparator />\n {table\n .getAllColumns()\n .filter((column) => typeof column.accessorFn !== 'undefined' && column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n checked={column.getIsVisible()}\n className=\"capitalize\"\n key={column.id}\n onCheckedChange={(value) => {\n column.toggleVisibility(Boolean(value));\n }}\n >\n {column.id}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n","'use client';\n\nimport { useState } from 'react';\nimport type { JSX } from 'react';\nimport { find, propEq } from 'ramda';\nimport type { Table } from '@tanstack/react-table';\nimport { Loader2, RefreshCw, Trash2 } from 'lucide-react';\nimport { gql } from '@apollo/client';\nimport { useApolloClient } from '@apollo/client/react';\nimport { toast } from 'sonner';\nimport { Button } from '../ui/primitives/button';\nimport { PermissionTooltip } from '../ui/components/permission-tooltip';\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/primitives/select';\nimport { useDispatch } from '../entities/actions-context';\nimport { useAppContext, useAppDispatch } from '../core/app-context';\nimport { useCanMutate } from '../core/permissions';\nimport { useConfig } from '../core/config/config-context';\nimport { DataTableViewOptions } from './data-table-view-options';\nimport { DataTableSortedBy } from './data-table-sorted-by';\nimport { useEntityMutation } from '../graphql-client/use-entity-mutation';\nimport { getEntityDeleteMutation, getEntityDeleteWhere } from '../graphql-client/queries';\nimport { getEntityListQueryName, scheduleEntityListRemoval } from '../graphql-client/refetch-entity-lists';\n\ninterface DataTableToolbarProps<TData> {\n entityName: string;\n isReloading?: boolean;\n onReload?: () => void;\n table: Table<TData>;\n}\n\nexport function DataTableToolbar<TData>({\n entityName,\n isReloading = false,\n onReload,\n table,\n}: DataTableToolbarProps<TData>): JSX.Element {\n const actionDispatch = useDispatch();\n const appDispatch = useAppDispatch();\n const appContext = useAppContext();\n const apolloClient = useApolloClient();\n const { currentProject, currentProjectId } = useConfig();\n const schema = currentProject?.schema ?? [];\n const scopes = currentProject?.scopes;\n const [runMutation, setMutation, setOptions] = useEntityMutation();\n const [isDeleting, setIsDeleting] = useState(false);\n const canMutate = useCanMutate();\n\n // Collect selected entity ids from the table\n // @ts-expect-error -- the DataGrid's original type doesn't know about the _id property\n const selectedIds: string[] = table.getSelectedRowModel().rows.map((row) => row.original._id as string);\n\n function handleCreate(): void {\n actionDispatch({ type: 'AddEntity', payload: { entityName } });\n }\n\n function handleScopeChange(value: string): void {\n appDispatch({ type: 'setScope', payload: { projectId: currentProjectId, scope: value } });\n }\n\n async function deleteSelected(ids: string[]): Promise<void> {\n if (ids.length === 0) {\n return;\n }\n\n const mutation = getEntityDeleteMutation(entityName, schema, ids);\n\n await new Promise<void>((resolve, reject) => {\n setMutation(gql`\n ${mutation}\n `);\n\n setOptions({\n variables: { where: getEntityDeleteWhere(ids) },\n update(cache: { evict: (arg0: { id: string }) => void }) {\n for (const id of ids) {\n cache.evict({ id });\n }\n },\n onCompleted: () => {\n resolve();\n },\n onError: (error: Error) => {\n reject(error);\n },\n });\n\n runMutation(true);\n });\n }\n\n function handleBatchDelete(): void {\n const itemLabel = entityName === '_asset' ? 'asset' : entityName.toLowerCase();\n\n actionDispatch({\n type: 'AlertDialog',\n payload: {\n options: {\n dialogTitle: `Delete ${selectedIds.length} ${itemLabel}${selectedIds.length > 1 ? 's' : ''}`,\n dialogMessage:\n selectedIds.length > 1\n ? `Are you sure you want to delete the selected ${itemLabel}s? They will be deleted permanently.`\n : `Are you sure you want to delete the selected ${itemLabel}? The item will be deleted permanently.`,\n dialogCancelTitle: 'Cancel',\n dialogActionLabel: 'Delete',\n isDestructive: true,\n dialogActionSubmit: async () => {\n setIsDeleting(true);\n\n try {\n const idsToDelete = [...selectedIds];\n\n await deleteSelected(idsToDelete);\n\n table.resetRowSelection();\n // Drop rows immediately, then soft-refetch counts/pages.\n await scheduleEntityListRemoval(\n apolloClient,\n getEntityListQueryName(entityName, schema),\n idsToDelete\n );\n toast.success(idsToDelete.length > 1 ? 'Items successfully deleted.' : 'Item successfully deleted.');\n } catch {\n toast.error('Failed to delete selected items.');\n } finally {\n setIsDeleting(false);\n }\n },\n dialogActionCancel: () => {\n // no-op\n },\n },\n },\n });\n }\n\n return (\n <div className=\"fk:flex fk:items-center fk:justify-between\">\n <div className=\"fk:flex fk:flex-1 fk:items-center fk:space-x-2\">\n {scopes && scopes.length > 0 ? (\n <Select\n defaultValue={appContext.scope}\n onValueChange={(value) => {\n handleScopeChange(value);\n }}\n value={appContext.scope}\n >\n <SelectTrigger className=\"fk:w-48!\" id=\"project\" size=\"sm\">\n <span className=\"fk:text-muted-foreground\">Scope:</span>\n <SelectValue>\n {\n ((find(propEq(appContext.scope ?? '', 'name'))(scopes) as { name: string; label: string }) || null)\n ?.label\n }\n </SelectValue>\n </SelectTrigger>\n <SelectContent>\n {scopes.map((scopeItem) => (\n <SelectItem key={scopeItem.name} value={scopeItem.name}>\n {scopeItem.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n ) : null}\n <DataTableViewOptions table={table} />\n {onReload ? (\n <Button\n aria-label=\"Reload\"\n className=\"fk:h-8\"\n disabled={isDeleting || isReloading}\n onClick={onReload}\n size=\"icon-sm\"\n variant=\"outline\"\n >\n <RefreshCw className={isReloading ? 'fk:animate-spin' : undefined} />\n </Button>\n ) : null}\n <DataTableSortedBy table={table} />\n </div>\n {selectedIds.length > 0 ? (\n <PermissionTooltip disabled={!canMutate}>\n <Button\n className=\"fk:h-8 fk:mr-2 fk:lg:flex\"\n disabled={isDeleting || !canMutate}\n onClick={handleBatchDelete}\n size=\"sm\"\n variant=\"destructive\"\n >\n {isDeleting ? (\n <Loader2 className=\"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin\" />\n ) : (\n <Trash2 className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n )}\n Delete ({selectedIds.length})\n </Button>\n </PermissionTooltip>\n ) : null}\n <PermissionTooltip disabled={!canMutate}>\n <Button\n className=\"fk:ml-auto fk:h-8 fk:lg:flex\"\n disabled={isDeleting || !canMutate}\n onClick={handleCreate}\n size=\"sm\"\n variant=\"default\"\n >\n Create\n </Button>\n </PermissionTooltip>\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/data-grid/data-table-row-actions.tsx","../src/data-grid/data-table-view-options.tsx","../src/data-grid/data-table-toolbar.tsx"],"names":["DataTableRowActions","entityName","entityNamePlural","row","options","actionDispatch","useDispatch","canMutate","useCanMutate","entityId","canDelete","canEdit","handleEdit","handleDelete","jsxs","Button","jsx","PencilIcon","Trash2Icon","DropdownMenu","DropdownMenuTrigger","Ellipsis","DropdownMenuContent","DropdownMenuItem","DropdownMenuSeparator","DataTableViewOptions","table","Settings2","DropdownMenuLabel","column","DropdownMenuCheckboxItem","value","DataTableToolbar","isReloading","onReload","appDispatch","useAppDispatch","appContext","useAppContext","apolloClient","useApolloClient","currentProject","currentProjectId","useConfig","schema","scopes","runMutation","setMutation","setOptions","useEntityMutation","isDeleting","setIsDeleting","useState","selectedIds","handleCreate","handleScopeChange","deleteSelected","ids","mutation","getEntityDeleteMutation","resolve","reject","gql","getEntityDeleteWhere","cache","id","error","handleBatchDelete","itemLabel","idsToDelete","scheduleEntityListRemoval","getEntityListQueryName","toast","Select","SelectTrigger","SelectValue","find","propEq","SelectContent","scopeItem","SelectItem","RefreshCw","DataTableSortedBy","PermissionTooltip","Loader2","Trash2"],"mappings":"0rBA0BO,SAASA,EAAAA,CAA2B,CACzC,UAAA,CAAAC,CAAAA,CACA,gBAAA,CAAAC,CAAAA,CACA,GAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CAAU,CAAE,SAAA,CAAW,IAAA,CAAM,OAAA,CAAS,IAAK,CAC7C,CAAA,CAAiD,CAC/C,IAAMC,CAAAA,CAAiBC,CAAAA,EAAY,CAC7BC,CAAAA,CAAYC,CAAAA,EAAa,CAEzBC,CAAAA,CAAWN,CAAAA,CAAI,QAAA,CAAS,GAAA,CAGxBO,CAAAA,CAAAA,CAAaN,CAAAA,CAAQ,SAAA,EAAa,IAAA,GAASG,CAAAA,CAC3CI,CAAAA,CAAUP,CAAAA,CAAQ,OAAA,EAAW,IAAA,CAEnC,SAASQ,GAAAA,EAAmB,CAC1BP,CAAAA,CAAe,CAAE,IAAA,CAAM,YAAA,CAAc,OAAA,CAAS,CAAE,QAAA,CAAAI,CAAAA,CAA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EACpBrC,GAAAA,CAACmE,EAAAA,CAAA,CAAkB,QAAA,CAAU,CAAC5E,CAAAA,CAC5B,QAAA,CAAAO,KAACC,GAAAA,CAAA,CACC,UAAU,2BAAA,CACV,QAAA,CAAUmC,KAAc,CAAC3C,CAAAA,CACzB,QAAS4D,EAAAA,CACT,IAAA,CAAK,KACL,OAAA,CAAQ,aAAA,CAEP,UAAAjB,GAAAA,CACClC,GAAAA,CAACoE,OAAAA,CAAA,CAAQ,UAAU,uCAAA,CAAwC,CAAA,CAE3DpE,IAACqE,MAAAA,CAAA,CAAO,UAAU,uBAAA,CAAwB,CAAA,CAC1C,UAAA,CACOhC,CAAAA,CAAY,OAAO,GAAA,CAAA,CAC9B,CAAA,CACF,EACE,IAAA,CACJrC,GAAAA,CAACmE,GAAA,CAAkB,QAAA,CAAU,CAAC5E,CAAAA,CAC5B,SAAAS,GAAAA,CAACD,GAAAA,CAAA,CACC,SAAA,CAAU,8BAAA,CACV,SAAUmC,GAAAA,EAAc,CAAC3C,EACzB,OAAA,CAAS+C,EAAAA,CACT,KAAK,IAAA,CACL,OAAA,CAAQ,UACT,QAAA,CAAA,QAAA,CAED,CAAA,CACF,GACF,CAEJ","file":"chunk-UUC4PXUB.js","sourcesContent":["'use client';\n\nimport type { JSX } from 'react';\nimport { Ellipsis, PencilIcon, Trash2Icon } from 'lucide-react';\nimport type { Row } from '@tanstack/react-table';\nimport { Button } from '../ui/primitives/button';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../ui/primitives/dropdown-menu';\nimport { useDispatch } from '../entities/actions-context';\nimport { useCanMutate } from '../core/permissions';\n\ninterface DataTableRowActionsProps<TData> {\n entityName: string;\n entityNamePlural: string;\n row: Row<TData>;\n options?: {\n canDelete?: boolean;\n canEdit?: boolean;\n };\n}\n\nexport function DataTableRowActions<TData>({\n entityName,\n entityNamePlural,\n row,\n options = { canDelete: true, canEdit: true },\n}: DataTableRowActionsProps<TData>): JSX.Element {\n const actionDispatch = useDispatch();\n const canMutate = useCanMutate();\n // @ts-expect-error -- the DataGrid's original type doesn't know about the _id property\n const entityId = row.original._id;\n // Read-only roles keep the pencil (the drawer doubles as their read view)\n // but lose the delete affordance entirely.\n const canDelete = (options.canDelete ?? true) && canMutate;\n const canEdit = options.canEdit ?? true;\n\n function handleEdit(): void {\n actionDispatch({ type: 'EditEntity', payload: { entityId, entityNamePlural } });\n }\n\n function handleDelete(): void {\n actionDispatch({ type: 'DeleteEntity', payload: { entityId, entityName } });\n }\n\n return (\n <div className=\"fk:flex\">\n {canEdit && (\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1\" onClick={handleEdit} variant=\"ghost\">\n <PencilIcon className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Edit</span>\n </Button>\n )}\n {canDelete && !canEdit && (\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1\" onClick={handleDelete} variant=\"ghost\">\n <Trash2Icon className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Delete</span>\n </Button>\n )}\n {canEdit && canDelete && (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0\" variant=\"ghost\">\n <Ellipsis className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Additional actions</span>\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"w-[160px]\">\n <DropdownMenuItem onClick={handleEdit}>\n <PencilIcon className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n Edit\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem className=\"fk:text-destructive\" onClick={handleDelete}>\n <Trash2Icon className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n </div>\n );\n}\n","'use client';\n\nimport type { JSX } from 'react';\nimport { Settings2 } from 'lucide-react';\nimport type { Table } from '@tanstack/react-table';\nimport { Button } from '../ui/primitives/button';\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../ui/primitives/dropdown-menu';\n\ninterface DataTableViewOptionsProps<TData> {\n table: Table<TData>;\n}\n\nexport function DataTableViewOptions<TData>({ table }: DataTableViewOptionsProps<TData>): JSX.Element {\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button className=\"fk:hidden fk:h-8 fk:lg:flex\" size=\"sm\" variant=\"outline\">\n <Settings2 className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n View\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"fk:w-[150px]\">\n <DropdownMenuLabel>Toggle columns</DropdownMenuLabel>\n <DropdownMenuSeparator />\n {table\n .getAllColumns()\n .filter((column) => typeof column.accessorFn !== 'undefined' && column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n checked={column.getIsVisible()}\n className=\"capitalize\"\n key={column.id}\n onCheckedChange={(value) => {\n column.toggleVisibility(Boolean(value));\n }}\n >\n {column.id}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n","'use client';\n\nimport { useState } from 'react';\nimport type { JSX } from 'react';\nimport { find, propEq } from 'ramda';\nimport type { Table } from '@tanstack/react-table';\nimport { Loader2, RefreshCw, Trash2 } from 'lucide-react';\nimport { gql } from '@apollo/client';\nimport { useApolloClient } from '@apollo/client/react';\nimport { toast } from 'sonner';\nimport { Button } from '../ui/primitives/button';\nimport { PermissionTooltip } from '../ui/components/permission-tooltip';\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/primitives/select';\nimport { useDispatch } from '../entities/actions-context';\nimport { useAppContext, useAppDispatch } from '../core/app-context';\nimport { useCanMutate } from '../core/permissions';\nimport { useConfig } from '../core/config/config-context';\nimport { DataTableViewOptions } from './data-table-view-options';\nimport { DataTableSortedBy } from './data-table-sorted-by';\nimport { useEntityMutation } from '../graphql-client/use-entity-mutation';\nimport { getEntityDeleteMutation, getEntityDeleteWhere } from '../graphql-client/queries';\nimport { getEntityListQueryName, scheduleEntityListRemoval } from '../graphql-client/refetch-entity-lists';\n\ninterface DataTableToolbarProps<TData> {\n entityName: string;\n isReloading?: boolean;\n onReload?: () => void;\n table: Table<TData>;\n}\n\nexport function DataTableToolbar<TData>({\n entityName,\n isReloading = false,\n onReload,\n table,\n}: DataTableToolbarProps<TData>): JSX.Element {\n const actionDispatch = useDispatch();\n const appDispatch = useAppDispatch();\n const appContext = useAppContext();\n const apolloClient = useApolloClient();\n const { currentProject, currentProjectId } = useConfig();\n const schema = currentProject?.schema ?? [];\n const scopes = currentProject?.scopes;\n const [runMutation, setMutation, setOptions] = useEntityMutation();\n const [isDeleting, setIsDeleting] = useState(false);\n const canMutate = useCanMutate();\n\n // Collect selected entity ids from the table\n // @ts-expect-error -- the DataGrid's original type doesn't know about the _id property\n const selectedIds: string[] = table.getSelectedRowModel().rows.map((row) => row.original._id as string);\n\n function handleCreate(): void {\n actionDispatch({ type: 'AddEntity', payload: { entityName } });\n }\n\n function handleScopeChange(value: string): void {\n appDispatch({ type: 'setScope', payload: { projectId: currentProjectId, scope: value } });\n }\n\n async function deleteSelected(ids: string[]): Promise<void> {\n if (ids.length === 0) {\n return;\n }\n\n const mutation = getEntityDeleteMutation(entityName, schema, ids);\n\n await new Promise<void>((resolve, reject) => {\n setMutation(gql`\n ${mutation}\n `);\n\n setOptions({\n variables: { where: getEntityDeleteWhere(ids) },\n update(cache: { evict: (arg0: { id: string }) => void }) {\n for (const id of ids) {\n cache.evict({ id });\n }\n },\n onCompleted: () => {\n resolve();\n },\n onError: (error: Error) => {\n reject(error);\n },\n });\n\n runMutation(true);\n });\n }\n\n function handleBatchDelete(): void {\n const itemLabel = entityName === '_asset' ? 'asset' : entityName.toLowerCase();\n\n actionDispatch({\n type: 'AlertDialog',\n payload: {\n options: {\n dialogTitle: `Delete ${selectedIds.length} ${itemLabel}${selectedIds.length > 1 ? 's' : ''}`,\n dialogMessage:\n selectedIds.length > 1\n ? `Are you sure you want to delete the selected ${itemLabel}s? They will be deleted permanently.`\n : `Are you sure you want to delete the selected ${itemLabel}? The item will be deleted permanently.`,\n dialogCancelTitle: 'Cancel',\n dialogActionLabel: 'Delete',\n isDestructive: true,\n dialogActionSubmit: async () => {\n setIsDeleting(true);\n\n try {\n const idsToDelete = [...selectedIds];\n\n await deleteSelected(idsToDelete);\n\n table.resetRowSelection();\n // Drop rows immediately, then soft-refetch counts/pages.\n await scheduleEntityListRemoval(\n apolloClient,\n getEntityListQueryName(entityName, schema),\n idsToDelete\n );\n toast.success(idsToDelete.length > 1 ? 'Items successfully deleted.' : 'Item successfully deleted.');\n } catch {\n toast.error('Failed to delete selected items.');\n } finally {\n setIsDeleting(false);\n }\n },\n dialogActionCancel: () => {\n // no-op\n },\n },\n },\n });\n }\n\n return (\n <div className=\"fk:flex fk:items-center fk:justify-between\">\n <div className=\"fk:flex fk:flex-1 fk:items-center fk:space-x-2\">\n {scopes && scopes.length > 0 ? (\n <Select\n defaultValue={appContext.scope}\n onValueChange={(value) => {\n handleScopeChange(value);\n }}\n value={appContext.scope}\n >\n <SelectTrigger className=\"fk:w-48!\" id=\"project\" size=\"sm\">\n <span className=\"fk:text-muted-foreground\">Scope:</span>\n <SelectValue>\n {\n ((find(propEq(appContext.scope ?? '', 'name'))(scopes) as { name: string; label: string }) || null)\n ?.label\n }\n </SelectValue>\n </SelectTrigger>\n <SelectContent>\n {scopes.map((scopeItem) => (\n <SelectItem key={scopeItem.name} value={scopeItem.name}>\n {scopeItem.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n ) : null}\n <DataTableViewOptions table={table} />\n {onReload ? (\n <Button\n aria-label=\"Reload\"\n className=\"fk:h-8\"\n disabled={isDeleting || isReloading}\n onClick={onReload}\n size=\"icon-sm\"\n variant=\"outline\"\n >\n <RefreshCw className={isReloading ? 'fk:animate-spin' : undefined} />\n </Button>\n ) : null}\n <DataTableSortedBy table={table} />\n </div>\n {selectedIds.length > 0 ? (\n <PermissionTooltip disabled={!canMutate}>\n <Button\n className=\"fk:h-8 fk:mr-2 fk:lg:flex\"\n disabled={isDeleting || !canMutate}\n onClick={handleBatchDelete}\n size=\"sm\"\n variant=\"destructive\"\n >\n {isDeleting ? (\n <Loader2 className=\"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin\" />\n ) : (\n <Trash2 className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n )}\n Delete ({selectedIds.length})\n </Button>\n </PermissionTooltip>\n ) : null}\n <PermissionTooltip disabled={!canMutate}>\n <Button\n className=\"fk:ml-auto fk:h-8 fk:lg:flex\"\n disabled={isDeleting || !canMutate}\n onClick={handleCreate}\n size=\"sm\"\n variant=\"default\"\n >\n Create\n </Button>\n </PermissionTooltip>\n </div>\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
- import'./index.css';import {c,e as e$1}from'./chunk-P6BZ4QP7.js';import {f}from'./chunk-E7B5FQKW.js';import {e}from'./chunk-TYDYAOQ7.js';import {useMemo}from'react';import A from'swr';import {find,propEq}from'ramda';function T(n,i){let{scope:c$1}=c(),{currentProject:e$1}=f(),o=useMemo(()=>e$1?.schema??[],[e$1]),a=e$1?.scopes?.find(t=>t.isDefault)?.name??"default",m=i?.commonParams.q?JSON.stringify(i):null,{data:r,error:s,isLoading:y}=A(m,()=>fetch(e(n).search,{headers:{"Content-Type":"application/json"},body:JSON.stringify(i),method:"POST",mode:"cors"}).then(t=>t.json()));return {results:useMemo(()=>E(r?.results??[],n,o,c$1,a)??[],[r,a,n,o,c$1]),error:s,isLoading:y}}function E(n,i,c,e,o){return n?.filter(l=>l?.hits?.length>0).map(l=>{let a=l,m=a.collection.replace(`${i}_`,"").replace(/_\d+$/,""),r=find(propEq(m,"plural"))(c);if(!r)return [];let s=e$1(r)?.name??"",y=r?.name??m;return a.hits.map(({document:u})=>{let t=u[s],b=(t&&typeof t!="string"?t[e]??t[o]:null)??u[s],N=Object.entries(u).reduce((d,[p,f])=>{if(p!==s&&p!=="id"&&p!=="_updatedAt"){let _=typeof f!="string"?f[e]??f[o]:f;d[p]=_;}return d},{});return {_id:u.id,_entityName:y,_entityNamePlural:m,[s]:b,...N}})}).flat()}export{T as a};//# sourceMappingURL=chunk-4JWGLBGC.js.map
2
- //# sourceMappingURL=chunk-4JWGLBGC.js.map
1
+ import'./index.css';import {c,e as e$1}from'./chunk-P6BZ4QP7.js';import {f}from'./chunk-CMZV7EPC.js';import {e}from'./chunk-TYDYAOQ7.js';import {useMemo}from'react';import A from'swr';import {find,propEq}from'ramda';function T(n,i){let{scope:c$1}=c(),{currentProject:e$1}=f(),o=useMemo(()=>e$1?.schema??[],[e$1]),a=e$1?.scopes?.find(t=>t.isDefault)?.name??"default",m=i?.commonParams.q?JSON.stringify(i):null,{data:r,error:s,isLoading:y}=A(m,()=>fetch(e(n).search,{headers:{"Content-Type":"application/json"},body:JSON.stringify(i),method:"POST",mode:"cors"}).then(t=>t.json()));return {results:useMemo(()=>E(r?.results??[],n,o,c$1,a)??[],[r,a,n,o,c$1]),error:s,isLoading:y}}function E(n,i,c,e,o){return n?.filter(l=>l?.hits?.length>0).map(l=>{let a=l,m=a.collection.replace(`${i}_`,"").replace(/_\d+$/,""),r=find(propEq(m,"plural"))(c);if(!r)return [];let s=e$1(r)?.name??"",y=r?.name??m;return a.hits.map(({document:u})=>{let t=u[s],b=(t&&typeof t!="string"?t[e]??t[o]:null)??u[s],N=Object.entries(u).reduce((d,[p,f])=>{if(p!==s&&p!=="id"&&p!=="_updatedAt"){let _=typeof f!="string"?f[e]??f[o]:f;d[p]=_;}return d},{});return {_id:u.id,_entityName:y,_entityNamePlural:m,[s]:b,...N}})}).flat()}export{T as a};//# sourceMappingURL=chunk-VARGD74X.js.map
2
+ //# sourceMappingURL=chunk-VARGD74X.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/use-search.tsx"],"names":["useSearch","projectId","searchRequest","scope","useAppContext","currentProject","useConfig","schema","useMemo","defaultScope","s","swrKey","data","error","isLoading","useSWR","apiPaths","res","mapResults","results","result","item","entityNamePlural","entitySchema","find","propEq","primaryAttributeName","getDisplayAttribute","entityName","document","primaryAttribute","primaryAttributeValue","attributes","acc","key","value","scopedValue"],"mappings":"wNAWO,SAASA,EACdC,CAAAA,CACAC,CAAAA,CACwE,CACxE,GAAM,CAAE,KAAA,CAAAC,GAAM,CAAA,CAAIC,GAAc,CAC1B,CAAE,cAAA,CAAAC,GAAe,CAAA,CAAIC,CAAAA,EAAU,CAC/BC,CAAAA,CAASC,QAAQ,IAAMH,GAAAA,EAAgB,MAAA,EAAU,EAAC,CAAG,CAACA,GAAc,CAAC,EAErEI,CAAAA,CADSJ,GAAAA,EAAgB,MAAA,EACF,IAAA,CAAMK,CAAAA,EAAMA,CAAAA,CAAE,SAAS,CAAA,EAAG,MAAQ,SAAA,CACzDC,CAAAA,CAAST,CAAAA,EAAe,YAAA,CAAa,CAAA,CAAI,IAAA,CAAK,SAAA,CAAUA,CAAa,EAAI,IAAA,CACzE,CAAE,IAAA,CAAAU,CAAAA,CAAM,MAAAC,CAAAA,CAAO,SAAA,CAAAC,CAAU,CAAA,CAAIC,EAAOJ,CAAAA,CAAQ,IAChD,KAAA,CAAMK,CAAAA,CAASf,CAAS,CAAA,CAAE,MAAA,CAAQ,CAChC,QAAS,CAAE,cAAA,CAAgB,kBAAmB,CAAA,CAC9C,IAAA,CAAM,IAAA,CAAK,SAAA,CAAUC,CAAa,EAClC,MAAA,CAAQ,MAAA,CACR,IAAA,CAAM,MACR,CAAC,CAAA,CAAE,IAAA,CAAMe,CAAAA,EAAQA,EAAI,IAAA,EAAoD,CAC3E,CAAA,CAMA,OAAO,CAAE,OAAA,CALOT,OAAAA,CACd,IAAMU,CAAAA,CAA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AA,GACkDoB,CAAAA,CAASH,CAAoB,CAAA,CAC/EM,EAAa,MAAA,CAAO,OAAA,CAAQH,CAAQ,CAAA,CAAE,MAAA,CAC1C,CAACI,CAAAA,CAA0E,CAACC,EAAKC,CAAK,CAAA,GAAM,CAC1F,GAAID,CAAAA,GAAQR,CAAAA,EAAwBQ,CAAAA,GAAQ,IAAA,EAAQA,IAAQ,YAAA,CAAc,CACxE,IAAME,CAAAA,CAAc,OAAOD,CAAAA,EAAU,QAAA,CAAYA,CAAAA,CAAMhC,CAAK,CAAA,EAAKgC,CAAAA,CAAM1B,CAAY,CAAA,CAAK0B,CAAAA,CAExFF,CAAAA,CAAIC,CAAG,CAAA,CAAIE,EACb,CAEA,OAAOH,CACT,CAAA,CACA,EACF,CAAA,CAEA,OAAO,CACL,GAAA,CAAKJ,CAAAA,CAAS,EAAA,CACd,WAAA,CAAaD,CAAAA,CACb,iBAAA,CAAmBN,CAAAA,CACnB,CAACI,CAAoB,EAAGK,CAAAA,CACxB,GAAGC,CACL,CACF,CAAC,CACH,CAAC,CAAA,CACA,MACL","file":"chunk-4JWGLBGC.js","sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\nimport useSWR from 'swr';\nimport { find, propEq } from 'ramda';\nimport { apiPaths } from './api-paths';\nimport { useAppContext } from './app-context';\nimport { useConfig } from './config/config-context';\nimport { getDisplayAttribute } from './get-display-attribute';\nimport type { Entity, RawResultItem, RawSearchResultItems, SearchRequestProps, SearchResultItem } from './types';\n\nexport function useSearch(\n projectId: string,\n searchRequest: SearchRequestProps | null\n): { results: SearchResultItem[] | []; error: Error; isLoading: boolean } {\n const { scope } = useAppContext();\n const { currentProject } = useConfig();\n const schema = useMemo(() => currentProject?.schema ?? [], [currentProject]);\n const scopes = currentProject?.scopes;\n const defaultScope = scopes?.find((s) => s.isDefault)?.name ?? 'default';\n const swrKey = searchRequest?.commonParams.q ? JSON.stringify(searchRequest) : null;\n const { data, error, isLoading } = useSWR(swrKey, () =>\n fetch(apiPaths(projectId).search, {\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(searchRequest),\n method: 'POST',\n mode: 'cors',\n }).then((res) => res.json() as Promise<{ results: RawSearchResultItems }>)\n );\n const results = useMemo(\n () => mapResults(data?.results ?? [], projectId, schema, scope, defaultScope) ?? [],\n [data, defaultScope, projectId, schema, scope]\n );\n\n return { results, error, isLoading };\n}\n\nfunction mapResults(\n results: RawSearchResultItems | undefined,\n projectId: string,\n schema: Entity[],\n scope: string,\n defaultScope: string\n): SearchResultItem[] | undefined {\n return results\n ?.filter((result) => (result as RawResultItem)?.hits?.length > 0)\n .map((result) => {\n const item = result as RawResultItem;\n const entityNamePlural = item.collection.replace(`${projectId}_`, '').replace(/_\\d+$/, '');\n const entitySchema = find<Entity>(propEq(entityNamePlural, 'plural'))(schema);\n\n if (!entitySchema) {\n return [];\n }\n\n const primaryAttributeName = getDisplayAttribute(entitySchema)?.name ?? '';\n const entityName = entitySchema?.name ?? entityNamePlural;\n\n // iterate over the hits and return an object with the primary attribute value first and then the rest of the attributes.\n return item.hits.map(({ document }) => {\n const primaryAttribute = document[primaryAttributeName];\n const scopedPrimaryAttribute =\n primaryAttribute && typeof primaryAttribute !== 'string'\n ? (primaryAttribute[scope] ?? primaryAttribute[defaultScope])\n : null;\n const primaryAttributeValue = scopedPrimaryAttribute ?? document[primaryAttributeName];\n const attributes = Object.entries(document).reduce(\n (acc: Omit<SearchResultItem, '_id' | '_entityName' | '_entityNamePlural'>, [key, value]) => {\n if (key !== primaryAttributeName && key !== 'id' && key !== '_updatedAt') {\n const scopedValue = typeof value !== 'string' ? (value[scope] ?? value[defaultScope]) : value;\n\n acc[key] = scopedValue;\n }\n\n return acc;\n },\n {}\n );\n\n return {\n _id: document.id,\n _entityName: entityName,\n _entityNamePlural: entityNamePlural,\n [primaryAttributeName]: primaryAttributeValue as string,\n ...attributes,\n };\n });\n })\n .flat();\n}\n"]}
1
+ {"version":3,"sources":["../src/core/use-search.tsx"],"names":["useSearch","projectId","searchRequest","scope","useAppContext","currentProject","useConfig","schema","useMemo","defaultScope","s","swrKey","data","error","isLoading","useSWR","apiPaths","res","mapResults","results","result","item","entityNamePlural","entitySchema","find","propEq","primaryAttributeName","getDisplayAttribute","entityName","document","primaryAttribute","primaryAttributeValue","attributes","acc","key","value","scopedValue"],"mappings":"wNAWO,SAASA,EACdC,CAAAA,CACAC,CAAAA,CACwE,CACxE,GAAM,CAAE,KAAA,CAAAC,GAAM,CAAA,CAAIC,GAAc,CAC1B,CAAE,cAAA,CAAAC,GAAe,CAAA,CAAIC,CAAAA,EAAU,CAC/BC,CAAAA,CAASC,QAAQ,IAAMH,GAAAA,EAAgB,MAAA,EAAU,EAAC,CAAG,CAACA,GAAc,CAAC,EAErEI,CAAAA,CADSJ,GAAAA,EAAgB,MAAA,EACF,IAAA,CAAMK,CAAAA,EAAMA,CAAAA,CAAE,SAAS,CAAA,EAAG,MAAQ,SAAA,CACzDC,CAAAA,CAAST,CAAAA,EAAe,YAAA,CAAa,CAAA,CAAI,IAAA,CAAK,SAAA,CAAUA,CAAa,EAAI,IAAA,CACzE,CAAE,IAAA,CAAAU,CAAAA,CAAM,MAAAC,CAAAA,CAAO,SAAA,CAAAC,CAAU,CAAA,CAAIC,EAAOJ,CAAAA,CAAQ,IAChD,KAAA,CAAMK,CAAAA,CAASf,CAAS,CAAA,CAAE,MAAA,CAAQ,CAChC,QAAS,CAAE,cAAA,CAAgB,kBAAmB,CAAA,CAC9C,IAAA,CAAM,IAAA,CAAK,SAAA,CAAUC,CAAa,EAClC,MAAA,CAAQ,MAAA,CACR,IAAA,CAAM,MACR,CAAC,CAAA,CAAE,IAAA,CAAMe,CAAAA,EAAQA,EAAI,IAAA,EAAoD,CAC3E,CAAA,CAMA,OAAO,CAAE,OAAA,CALOT,OAAAA,CACd,IAAMU,CAAAA,CAAWN,CAAAA,EAAM,OAAA,EAAW,EAAC,CAAGX,CAAAA,CAAWM,CAAAA,CAAQJ,GAAAA,CAAOM,CAAY,CAA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,MAAA,CAC1C,CAACI,CAAAA,CAA0E,CAACC,EAAKC,CAAK,CAAA,GAAM,CAC1F,GAAID,CAAAA,GAAQR,CAAAA,EAAwBQ,CAAAA,GAAQ,IAAA,EAAQA,IAAQ,YAAA,CAAc,CACxE,IAAME,CAAAA,CAAc,OAAOD,CAAAA,EAAU,QAAA,CAAYA,CAAAA,CAAMhC,CAAK,CAAA,EAAKgC,CAAAA,CAAM1B,CAAY,CAAA,CAAK0B,CAAAA,CAExFF,CAAAA,CAAIC,CAAG,CAAA,CAAIE,EACb,CAEA,OAAOH,CACT,CAAA,CACA,EACF,CAAA,CAEA,OAAO,CACL,GAAA,CAAKJ,CAAAA,CAAS,EAAA,CACd,WAAA,CAAaD,CAAAA,CACb,iBAAA,CAAmBN,CAAAA,CACnB,CAACI,CAAoB,EAAGK,CAAAA,CACxB,GAAGC,CACL,CACF,CAAC,CACH,CAAC,CAAA,CACA,MACL","file":"chunk-VARGD74X.js","sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\nimport useSWR from 'swr';\nimport { find, propEq } from 'ramda';\nimport { apiPaths } from './api-paths';\nimport { useAppContext } from './app-context';\nimport { useConfig } from './config/config-context';\nimport { getDisplayAttribute } from './get-display-attribute';\nimport type { Entity, RawResultItem, RawSearchResultItems, SearchRequestProps, SearchResultItem } from './types';\n\nexport function useSearch(\n projectId: string,\n searchRequest: SearchRequestProps | null\n): { results: SearchResultItem[] | []; error: Error; isLoading: boolean } {\n const { scope } = useAppContext();\n const { currentProject } = useConfig();\n const schema = useMemo(() => currentProject?.schema ?? [], [currentProject]);\n const scopes = currentProject?.scopes;\n const defaultScope = scopes?.find((s) => s.isDefault)?.name ?? 'default';\n const swrKey = searchRequest?.commonParams.q ? JSON.stringify(searchRequest) : null;\n const { data, error, isLoading } = useSWR(swrKey, () =>\n fetch(apiPaths(projectId).search, {\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(searchRequest),\n method: 'POST',\n mode: 'cors',\n }).then((res) => res.json() as Promise<{ results: RawSearchResultItems }>)\n );\n const results = useMemo(\n () => mapResults(data?.results ?? [], projectId, schema, scope, defaultScope) ?? [],\n [data, defaultScope, projectId, schema, scope]\n );\n\n return { results, error, isLoading };\n}\n\nfunction mapResults(\n results: RawSearchResultItems | undefined,\n projectId: string,\n schema: Entity[],\n scope: string,\n defaultScope: string\n): SearchResultItem[] | undefined {\n return results\n ?.filter((result) => (result as RawResultItem)?.hits?.length > 0)\n .map((result) => {\n const item = result as RawResultItem;\n const entityNamePlural = item.collection.replace(`${projectId}_`, '').replace(/_\\d+$/, '');\n const entitySchema = find<Entity>(propEq(entityNamePlural, 'plural'))(schema);\n\n if (!entitySchema) {\n return [];\n }\n\n const primaryAttributeName = getDisplayAttribute(entitySchema)?.name ?? '';\n const entityName = entitySchema?.name ?? entityNamePlural;\n\n // iterate over the hits and return an object with the primary attribute value first and then the rest of the attributes.\n return item.hits.map(({ document }) => {\n const primaryAttribute = document[primaryAttributeName];\n const scopedPrimaryAttribute =\n primaryAttribute && typeof primaryAttribute !== 'string'\n ? (primaryAttribute[scope] ?? primaryAttribute[defaultScope])\n : null;\n const primaryAttributeValue = scopedPrimaryAttribute ?? document[primaryAttributeName];\n const attributes = Object.entries(document).reduce(\n (acc: Omit<SearchResultItem, '_id' | '_entityName' | '_entityNamePlural'>, [key, value]) => {\n if (key !== primaryAttributeName && key !== 'id' && key !== '_updatedAt') {\n const scopedValue = typeof value !== 'string' ? (value[scope] ?? value[defaultScope]) : value;\n\n acc[key] = scopedValue;\n }\n\n return acc;\n },\n {}\n );\n\n return {\n _id: document.id,\n _entityName: entityName,\n _entityNamePlural: entityNamePlural,\n [primaryAttributeName]: primaryAttributeValue as string,\n ...attributes,\n };\n });\n })\n .flat();\n}\n"]}
@@ -1,2 +1,2 @@
1
- import'./index.css';import {g as g$1,f}from'./chunk-JK3IOLJZ.js';import {a,b,c,e}from'./chunk-USNXQOMJ.js';import {b as b$1}from'./chunk-6NRQMG26.js';import {BellIcon}from'lucide-react';import {Link}from'react-router-dom';import v from'swr';import {jsx,jsxs}from'react/jsx-runtime';function g(t){let{data:o}=v(t?g$1(t).activitySummary():null,f,{refreshInterval:3e4});return o}function n(t){return t>99?"99+":t.toString()}function x({projectId:t}){let o=g(t),e$1=o?.needsActionCount??0,r=o?.unreadCount??0,f=e$1>0?`Activity: ${n(e$1)} waiting for you`:r>0?`Activity: ${n(r)} unread`:"Activity";return jsx(a,{children:jsxs(b,{children:[jsx(c,{asChild:true,children:jsx(b$1,{asChild:true,"aria-label":f,className:"fk:relative fk:h-8 fk:w-8 fk:rounded-full",size:"icon",variant:"ghost",children:jsxs(Link,{to:`/${t}/ai/activity`,children:[jsx(BellIcon,{className:"fk:size-4"}),e$1>0?jsx("span",{className:"fk:absolute fk:-right-1 fk:-top-1 fk:flex fk:h-4 fk:min-w-4 fk:items-center fk:justify-center fk:rounded-full fk:bg-amber-500 fk:px-1 fk:text-[0.625rem] fk:font-semibold fk:leading-none fk:text-white",children:n(e$1)}):r>0?jsx("span",{className:"fk:absolute fk:right-1 fk:top-1 fk:size-2 fk:rounded-full fk:bg-success"}):null]})})}),jsx(e,{children:f})]})})}export{g as a,x as b};//# sourceMappingURL=chunk-RKI5N2N4.js.map
2
- //# sourceMappingURL=chunk-RKI5N2N4.js.map
1
+ import'./index.css';import {g as g$1,f}from'./chunk-ROCYIGFD.js';import {a,b,c,e}from'./chunk-USNXQOMJ.js';import {b as b$1}from'./chunk-6NRQMG26.js';import {BellIcon}from'lucide-react';import {Link}from'react-router-dom';import v from'swr';import {jsx,jsxs}from'react/jsx-runtime';function g(t){let{data:o}=v(t?g$1(t).activitySummary():null,f,{refreshInterval:3e4});return o}function n(t){return t>99?"99+":t.toString()}function x({projectId:t}){let o=g(t),e$1=o?.needsActionCount??0,r=o?.unreadCount??0,f=e$1>0?`Activity: ${n(e$1)} waiting for you`:r>0?`Activity: ${n(r)} unread`:"Activity";return jsx(a,{children:jsxs(b,{children:[jsx(c,{asChild:true,children:jsx(b$1,{asChild:true,"aria-label":f,className:"fk:relative fk:h-8 fk:w-8 fk:rounded-full",size:"icon",variant:"ghost",children:jsxs(Link,{to:`/${t}/ai/activity`,children:[jsx(BellIcon,{className:"fk:size-4"}),e$1>0?jsx("span",{className:"fk:absolute fk:-right-1 fk:-top-1 fk:flex fk:h-4 fk:min-w-4 fk:items-center fk:justify-center fk:rounded-full fk:bg-amber-500 fk:px-1 fk:text-[0.625rem] fk:font-semibold fk:leading-none fk:text-white",children:n(e$1)}):r>0?jsx("span",{className:"fk:absolute fk:right-1 fk:top-1 fk:size-2 fk:rounded-full fk:bg-success"}):null]})})}),jsx(e,{children:f})]})})}export{g as a,x as b};//# sourceMappingURL=chunk-WQUCLXMU.js.map
2
+ //# sourceMappingURL=chunk-WQUCLXMU.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apps/ai/activity-nav-button.tsx"],"names":["useActivitySummary","projectId","data","useSWR","paths","fetcher","formatCount","count","ActivityNavButton","summary","needsAction","unread","label","jsx","TooltipProvider","jsxs","Tooltip","TooltipTrigger","Button","Link","BellIcon","TooltipContent"],"mappings":"0RAaO,SAASA,CAAAA,CAAmBC,CAAAA,CAA4D,CAC7F,GAAM,CAAE,IAAA,CAAAC,CAAK,CAAA,CAAIC,EAAwBF,CAAAA,CAAYG,GAAAA,CAAMH,CAAS,CAAA,CAAE,iBAAgB,CAAI,IAAA,CAAMI,EAAS,CACvG,eAAA,CAAiB,GACnB,CAAC,CAAA,CAED,OAAOH,CACT,CAEA,SAASI,CAAAA,CAAYC,CAAAA,CAAuB,CAC1C,OAAOA,CAAAA,CAAQ,EAAA,CAAK,KAAA,CAAQA,CAAAA,CAAM,UACpC,CAGO,SAASC,CAAAA,CAAkB,CAAE,UAAAP,CAAU,CAAA,CAAuC,CACnF,IAAMQ,EAAUT,CAAAA,CAAmBC,CAAS,CAAA,CACtCS,GAAAA,CAAcD,GAAS,gBAAA,EAAoB,CAAA,CAC3CE,CAAAA,CAASF,CAAAA,EAAS,aAAe,CAAA,CACjCG,CAAAA,CACJF,IAAc,CAAA,CACV,CAAA,UAAA,EAAaJ,EAAYI,GAAW,CAAC,CAAA,gBAAA,CAAA,CACrCC,CAAAA,CAAS,EACP,CAAA,UAAA,EAAaL,CAAAA,CAAYK,CAAM,CAAC,UAChC,UAAA,CAER,OACEE,GAAAA,CAACC,CAAAA,CAAA,CACC,QAAA,CAAAC,IAAAA,CAACC,CAAAA,CAAA,CACC,UAAAH,GAAAA,CAACI,CAAAA,CAAA,CAAe,OAAA,CAAO,KACrB,QAAA,CAAAJ,GAAAA,CAACK,GAAAA,CAAA,CAAO,QAAO,IAAA,CAAC,YAAA,CAAYN,CAAAA,CAAO,SAAA,CAAU,4CAA4C,IAAA,CAAK,MAAA,CAAO,QAAQ,OAAA,CAC3G,QAAA,CAAAG,KAACI,IAAAA,CAAA,CAAK,EAAA,CAAI,CAAA,CAAA,EAAIlB,CAAS,CAAA,YAAA,CAAA,CACrB,QAAA,CAAA,CAAAY,GAAAA,CAACO,QAAAA,CAAA,CAAS,SAAA,CAAU,WAAA,CAAY,CAAA,CAC/BV,GAAAA,CAAc,EACbG,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,yMAAA,CACb,QAAA,CAAAP,EAAYI,GAAW,CAAA,CAC1B,CAAA,CACEC,CAAAA,CAAS,EACXE,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,yEAAA,CAA0E,EACxF,IAAA,CAAA,CACN,CAAA,CACF,CAAA,CACF,CAAA,CACAA,IAACQ,CAAAA,CAAA,CAAgB,SAAAT,CAAAA,CAAM,CAAA,CAAA,CACzB,EACF,CAEJ","file":"chunk-RKI5N2N4.js","sourcesContent":["import type { JSX } from 'react';\nimport { BellIcon } from 'lucide-react';\nimport { Link } from 'react-router-dom';\nimport useSWR from 'swr';\nimport { Button } from '../../ui/primitives/button';\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/primitives/tooltip';\nimport { fetcher, paths } from './api';\nimport type { ActivitySummary } from './types';\n\n/**\n * The project's Activity badge counts. `ActivityNotifier` refreshes the same\n * SWR key on every poll, so every reader stays in sync with one request.\n */\nexport function useActivitySummary(projectId: string | undefined): ActivitySummary | undefined {\n const { data } = useSWR<ActivitySummary>(projectId ? paths(projectId).activitySummary() : null, fetcher, {\n refreshInterval: 30_000,\n });\n\n return data;\n}\n\nfunction formatCount(count: number): string {\n return count > 99 ? '99+' : count.toString();\n}\n\n/** Navbar shortcut to Activity, so pending items are visible from every app. */\nexport function ActivityNavButton({ projectId }: { projectId: string }): JSX.Element {\n const summary = useActivitySummary(projectId);\n const needsAction = summary?.needsActionCount ?? 0;\n const unread = summary?.unreadCount ?? 0;\n const label =\n needsAction > 0\n ? `Activity: ${formatCount(needsAction)} waiting for you`\n : unread > 0\n ? `Activity: ${formatCount(unread)} unread`\n : 'Activity';\n\n return (\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button asChild aria-label={label} className=\"fk:relative fk:h-8 fk:w-8 fk:rounded-full\" size=\"icon\" variant=\"ghost\">\n <Link to={`/${projectId}/ai/activity`}>\n <BellIcon className=\"fk:size-4\" />\n {needsAction > 0 ? (\n <span className=\"fk:absolute fk:-right-1 fk:-top-1 fk:flex fk:h-4 fk:min-w-4 fk:items-center fk:justify-center fk:rounded-full fk:bg-amber-500 fk:px-1 fk:text-[0.625rem] fk:font-semibold fk:leading-none fk:text-white\">\n {formatCount(needsAction)}\n </span>\n ) : unread > 0 ? (\n <span className=\"fk:absolute fk:right-1 fk:top-1 fk:size-2 fk:rounded-full fk:bg-success\" />\n ) : null}\n </Link>\n </Button>\n </TooltipTrigger>\n <TooltipContent>{label}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/apps/ai/activity-nav-button.tsx"],"names":["useActivitySummary","projectId","data","useSWR","paths","fetcher","formatCount","count","ActivityNavButton","summary","needsAction","unread","label","jsx","TooltipProvider","jsxs","Tooltip","Tooltip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CAAU,WAAA,CAAY,CAAA,CAC/BV,GAAAA,CAAc,EACbG,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,yMAAA,CACb,QAAA,CAAAP,EAAYI,GAAW,CAAA,CAC1B,CAAA,CACEC,CAAAA,CAAS,EACXE,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,yEAAA,CAA0E,EACxF,IAAA,CAAA,CACN,CAAA,CACF,CAAA,CACF,CAAA,CACAA,IAACQ,CAAAA,CAAA,CAAgB,SAAAT,CAAAA,CAAM,CAAA,CAAA,CACzB,EACF,CAEJ","file":"chunk-WQUCLXMU.js","sourcesContent":["import type { JSX } from 'react';\nimport { BellIcon } from 'lucide-react';\nimport { Link } from 'react-router-dom';\nimport useSWR from 'swr';\nimport { Button } from '../../ui/primitives/button';\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/primitives/tooltip';\nimport { fetcher, paths } from './api';\nimport type { ActivitySummary } from './types';\n\n/**\n * The project's Activity badge counts. `ActivityNotifier` refreshes the same\n * SWR key on every poll, so every reader stays in sync with one request.\n */\nexport function useActivitySummary(projectId: string | undefined): ActivitySummary | undefined {\n const { data } = useSWR<ActivitySummary>(projectId ? paths(projectId).activitySummary() : null, fetcher, {\n refreshInterval: 30_000,\n });\n\n return data;\n}\n\nfunction formatCount(count: number): string {\n return count > 99 ? '99+' : count.toString();\n}\n\n/** Navbar shortcut to Activity, so pending items are visible from every app. */\nexport function ActivityNavButton({ projectId }: { projectId: string }): JSX.Element {\n const summary = useActivitySummary(projectId);\n const needsAction = summary?.needsActionCount ?? 0;\n const unread = summary?.unreadCount ?? 0;\n const label =\n needsAction > 0\n ? `Activity: ${formatCount(needsAction)} waiting for you`\n : unread > 0\n ? `Activity: ${formatCount(unread)} unread`\n : 'Activity';\n\n return (\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button asChild aria-label={label} className=\"fk:relative fk:h-8 fk:w-8 fk:rounded-full\" size=\"icon\" variant=\"ghost\">\n <Link to={`/${projectId}/ai/activity`}>\n <BellIcon className=\"fk:size-4\" />\n {needsAction > 0 ? (\n <span className=\"fk:absolute fk:-right-1 fk:-top-1 fk:flex fk:h-4 fk:min-w-4 fk:items-center fk:justify-center fk:rounded-full fk:bg-amber-500 fk:px-1 fk:text-[0.625rem] fk:font-semibold fk:leading-none fk:text-white\">\n {formatCount(needsAction)}\n </span>\n ) : unread > 0 ? (\n <span className=\"fk:absolute fk:right-1 fk:top-1 fk:size-2 fk:rounded-full fk:bg-success\" />\n ) : null}\n </Link>\n </Button>\n </TooltipTrigger>\n <TooltipContent>{label}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n );\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import'./index.css';import {g,f as f$1,d}from'./chunk-ROCYIGFD.js';import {f,d as d$1}from'./chunk-CMZV7EPC.js';import {na,Nb,Qb,ob,oa,o,ka as ka$1,ta,_ as _$1,$,ca as ca$1,da,aa,ea,s}from'./chunk-YCCFUGWJ.js';import {b,c as c$1,h as h$1,i,k,l,j as j$1,f as f$2}from'./chunk-32ZU4MLE.js';import {b as b$1,c,e}from'./chunk-USNXQOMJ.js';import {b as b$2}from'./chunk-6NRQMG26.js';import {lazy,createContext,useCallback,useState,useRef,useEffect,useMemo,useContext,useTransition,useId,Suspense}from'react';import On,{useSWRConfig}from'swr';import {formatDistance,format}from'date-fns';import {RadarIcon,BotIcon,XIcon,XCircleIcon,LoaderCircle,CheckIcon,CloudUploadIcon,FileTextIcon,DownloadIcon,LinkIcon,MessageSquareIcon,SendIcon,CheckCircle2Icon,CircleSlashIcon,ShieldIcon,DatabaseZapIcon,MessageCircleQuestionIcon,ShieldCheckIcon,TriangleAlertIcon,PlayIcon,ArrowRightIcon,FileIcon,CornerDownRightIcon,MoveRightIcon}from'lucide-react';import {useLocation,Link}from'react-router-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {pipeJsonRender}from'@json-render/core';import {readUIMessageStream,parseJsonEventStream,uiMessageChunkSchema}from'ai';function et(){let{currentProjectId:e}=f(),{mutate:t}=useSWRConfig();return useCallback(a=>{if(!e)return;let n=g(e).approvalsCount;a?t(n,a,{revalidate:true}):t(n),t(g(e).activitySummary());},[e,t])}var Gt=5e3,Wt=150,Ae=new Set;function Yt(e){return async()=>{let t=await fetch(e,{credentials:"include",mode:"cors"});return t.status===404?"missing":t.ok?(await t.json()).approval??"missing":null}}function Kt(e,t,a=d$1){return !e||e.kind!=="schema"||e.status!=="approved"||e.error?false:e.executedAt?(a(t),false):true}function de({approvalId:e,approvalUrl:t,fetchApproval:a,projectId:n,revalidate:r=d$1,sleep:s=l=>new Promise(d=>setTimeout(d,l))}){let l=`${n}:${e}`,d=a??(t?Yt(t):null);!d||Ae.has(l)||(Ae.add(l),(async()=>{try{for(let u=0;u<Wt;u+=1){let c=null;try{c=await d();}catch{c=null;}if(c==="missing"||c!==null&&!Kt(c,n,r))return;await s(Gt);}}finally{Ae.delete(l);}})());}var an={approved:"fk:bg-success/20 fk:text-success",cancelled:"fk:bg-secondary fk:text-secondary-foreground",expired:"fk:bg-secondary fk:text-secondary-foreground",pending:"fk:bg-amber-500/20 fk:text-amber-600",rejected:"fk:bg-destructive/15 fk:text-destructive"};function rn({status:e}){return jsx(b,{className:`fk:border-none fk:h-4.75 fk:text-[0.6875rem] fk:leading-4.5 fk:tracking-wide ${an[e]}`,variant:"secondary",children:e})}function _(e){return e==null?"\u2014":typeof e=="object"?JSON.stringify(e):String(e)}function st({after:e,before:t}){let a=_(t),n=_(e);return a===n?jsx("span",{className:"fk:text-muted-foreground",children:a}):jsxs("span",{className:"fk:inline-flex fk:flex-wrap fk:items-center fk:gap-1.5",children:[jsx("span",{className:"fk:rounded fk:bg-destructive/10 fk:px-1 fk:text-destructive fk:line-through fk:corner-squircle",children:a}),jsx(MoveRightIcon,{className:"fk:size-3 fk:shrink-0 fk:text-muted-foreground"}),jsx("span",{className:"fk:rounded fk:bg-success/15 fk:px-1 fk:text-success fk:corner-squircle",children:n})]})}function sn(e){let t=e.entity??"entities",a=e.affectedCount!==null?` \xB7 ${e.affectedCount.toString()} affected`:"";return e.kind==="create"?`Create ${t}${a}`:e.kind==="update"?`Update ${t}${a}`:e.kind==="delete"?`Delete ${t}${a}`:`Mutation on ${t}${a}`}function on({operation:e}){if(e.rows.length===0)return null;let t=(e.contextColumns??[]).filter(n=>n!=="_id");if(e.kind==="delete")return jsxs(_$1,{children:[jsx($,{children:jsxs(ca$1,{children:[jsx(da,{children:"Records to delete"}),t.map(n=>jsx(da,{children:n},n))]})}),jsx(aa,{children:e.rows.map((n,r)=>jsxs(ca$1,{className:"fk:bg-destructive/5",children:[jsx(ea,{className:"fk:font-mono fk:text-xs fk:text-destructive",children:n.id??_(n.before?._id)}),t.map(s=>jsx(ea,{className:"fk:text-xs fk:text-muted-foreground",children:_(n.before?.[s])},s))]},n.id??r.toString()))})]});let a=e.columns.filter(n=>n!=="_id"&&!t.includes(n));return jsxs(_$1,{children:[jsx($,{children:jsxs(ca$1,{children:[jsx(da,{children:"ID"}),t.map(n=>jsx(da,{children:n},n)),a.map(n=>jsx(da,{children:n},n))]})}),jsx(aa,{children:e.rows.map((n,r)=>jsxs(ca$1,{children:[jsx(ea,{className:"fk:font-mono fk:text-xs fk:text-muted-foreground",children:n.id??"\u2014"}),t.map(s=>jsx(ea,{className:"fk:max-w-72 fk:text-xs fk:text-muted-foreground",children:jsx("span",{className:"fk:line-clamp-3",children:_(n.before?.[s])})},s)),a.map(s=>jsx(ea,{className:"fk:text-xs",children:e.kind==="create"?jsx("span",{className:"fk:rounded fk:bg-success/15 fk:px-1 fk:text-success fk:corner-squircle",children:_(n.after?.[s])}):jsx(st,{after:n.after?.[s],before:n.before?.[s]})},s))]},n.id??r.toString()))})]})}function ln({operations:e,plugin:t,chat:a,title:n}){return jsxs("details",{className:"fk:rounded-md fk:border fk:border-border fk:corner-squircle",children:[jsx("summary",{className:"fk:cursor-pointer fk:px-3 fk:py-2 fk:text-xs fk:font-medium fk:text-muted-foreground",children:n??(a?"Action details":t?"Plugin tool and arguments":`GraphQL documents (${e.length})`)}),jsx("div",{className:"fk:space-y-3 fk:border-t fk:border-border fk:p-3",children:e.map((r,s)=>jsxs("div",{className:"fk:space-y-2",children:[jsx("pre",{className:"fk:overflow-x-auto fk:rounded-md fk:bg-muted fk:p-3 fk:text-xs fk:corner-squircle",children:r.query}),r.variables&&Object.keys(r.variables).length>0?jsx("pre",{className:"fk:overflow-x-auto fk:rounded-md fk:bg-muted/60 fk:p-3 fk:text-xs fk:corner-squircle",children:JSON.stringify(r.variables,null,2)}):null]},s.toString()))})]})}function ot(e){if(e.kind!=="plugin")return null;let a=e.operations[0]?.query.split(`
2
+ `)[0]?.trim()?.split("/"),n=a?.at(-1),r=a?.[0];if(!n||!r||a?.length<2)return null;let s=n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").toLowerCase(),l=r.replace(/[_-]+/g," ").replace(/\b\w/g,p=>p.toUpperCase()),d=e.operations[0]?.query??"",u=/^Connection:\s*(Project|Personal)\s+—\s+(.+)$/m.exec(d);if(u?.[1]&&u[2])return {action:s,app:l,account:u[2].trim(),scope:u[1]==="Project"?"project":"personal"};let c=/^Connection:.*?([^\s<>]+@[^\s<>]+)\s*$/m.exec(d)?.[1];return {action:s,app:l,account:c}}function un(e){let t=ot(e);return t?`${t.action.charAt(0).toUpperCase()}${t.action.slice(1)} in ${t.app}`:e.kind==="exec"?"Run a sandbox command":e.kind==="schema"?e.operationsSummary.replace(/^Schema: /,""):e.kind==="automation"&&e.preview?.automation?`Create the automation \u201C${e.preview.automation.name}\u201D`:e.kind==="automation"&&e.preview?.automationChange?`Change the automation \u201C${e.preview.automationChange.name}\u201D`:e.kind==="plugin"?"Use a connected app":e.operationsSummary}function dn({operation:e}){if(e.rows.length===0)return null;let t=n=>n!=null&&n!==false,a=e.columns.filter(n=>e.rows.some(s=>t(s.before?.[n])||t(s.after?.[n]))?e.kind!=="update"?true:e.rows.some(s=>_(s.before?.[n])!==_(s.after?.[n])):false);return jsx("div",{className:"fk:overflow-x-auto fk:rounded-md fk:border fk:border-border fk:corner-squircle",children:jsxs(_$1,{className:"fk:text-xs",children:[jsx($,{children:jsxs(ca$1,{children:[jsx(da,{className:"fk:h-8",children:e.entity==="scopes"||e.entity==="spaces"||e.entity==="studio"?"Setting":"Attribute"}),a.map(n=>jsx(da,{className:"fk:h-8",children:n},n))]})}),jsx(aa,{children:e.rows.map((n,r)=>jsxs(ca$1,{children:[jsxs(ea,{className:"fk:py-1.5 fk:font-mono fk:text-[0.7rem]",children:[e.kind==="delete"?jsx("span",{className:"fk:line-through fk:text-destructive",children:n.id}):n.id,e.kind==="update"&&n.before===null?jsx(b,{className:"fk:ml-2",variant:"secondary",children:"new"}):null,e.kind==="update"&&n.after===null?jsx(b,{className:"fk:ml-2",variant:"destructive",children:"removed"}):null]}),a.map(s=>jsx(ea,{className:"fk:py-1.5",children:e.kind==="create"?jsx("span",{children:_(n.after?.[s])}):e.kind==="delete"?jsx("span",{className:"fk:text-muted-foreground",children:_(n.before?.[s])}):jsx(st,{after:n.after?.[s],before:n.before?.[s]})},s))]},n.id??r.toString()))})]})})}function fn(e){let t=e.entity??"schema";return t==="scopes"||t==="spaces"||t==="studio"?`Change ${t==="studio"?"Studio settings":t}`:e.kind==="create"?`Add entity ${t} \xB7 ${e.rows.length.toString()} attribute${e.rows.length===1?"":"s"}`:e.kind==="delete"?`Remove entity ${t}`:`Change entity ${t}`}function cn({preview:e}){let t=e.schema;return jsxs("div",{className:"fk:space-y-4",children:[t&&t.breakingChanges.length>0?jsxs("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:corner-squircle",children:[jsxs("div",{className:"fk:mb-1 fk:flex fk:items-center fk:gap-2 fk:font-medium fk:text-destructive",children:[jsx(TriangleAlertIcon,{className:"fk:size-4"}),"Breaking changes: existing data becomes inaccessible"]}),jsx("ul",{className:"fk:list-disc fk:pl-5 fk:text-destructive",children:t.breakingChanges.map(a=>jsx("li",{children:a},a))})]}):null,t&&t.warnings.length>0?jsx("div",{className:"fk:rounded-md fk:border fk:border-amber-500/40 fk:bg-amber-500/10 fk:p-3 fk:text-sm fk:corner-squircle",children:jsx("ul",{className:"fk:list-disc fk:pl-5",children:t.warnings.map(a=>jsx("li",{children:a},a))})}):null,e.operations.map((a,n)=>jsxs("div",{className:"fk:space-y-2",children:[jsx("div",{className:`fk:text-sm fk:font-medium ${a.kind==="delete"?"fk:text-destructive":""}`,children:fn(a)}),jsx(dn,{operation:a})]},`${a.entity??""}-${n.toString()}`)),e.operations.length===0?jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-3 fk:text-xs fk:text-muted-foreground fk:corner-squircle",children:"No visible entity changes. Review the operations below."}):null]})}function pn(e,t){return e.id===t.id&&e.status===t.status&&e.decidedAt===t.decidedAt&&e.decidedBy===t.decidedBy&&e.executedAt===t.executedAt&&e.error===t.error&&e.reason===t.reason&&e.expiresAt===t.expiresAt&&e.operationsSummary===t.operationsSummary&&e.affectedCount===t.affectedCount&&JSON.stringify(e.preview)===JSON.stringify(t.preview)}function it({api:e,approval:t,onDecided:a}){let[n,r]=useState(t),[s,l]=useState(t),[d,u]=useState(""),[c,p]=useTransition(),[m,b]=useState(false),[y,f]=useState(false),[k,A]=useState(""),C=et();t!==s&&(l(t),pn(t,s)||n.id===t.id&&n.status!=="pending"&&t.status==="pending"||r(t));function P(x){r(x),C(),x.kind==="schema"&&x.status==="approved"&&de({approvalId:x.id,approvalUrl:g(x.projectId).approval(x.id),projectId:x.projectId}),a?.(x);}function K({approved:x,automationEdits:T,force:X=false,reason:D,remember:ge=false}){p(async()=>{u("");try{let R=await e.decideApproval(n.id,{approved:x,...T?{automationEdits:T}:{},force:X,reason:D,remember:ge});if(R.errorCode==="stale_preview"){f(!0),R.approval&&r(R.approval);return}if(f(!1),b(!1),R.approval?P(R.approval):R.success?P({...n,decidedAt:n.decidedAt??new Date().toISOString(),reason:D??n.reason,status:x?"approved":"rejected"}):R.errorCode==="already_decided"&&a?.(n),!R.success&&(R.errorCode!=="already_decided"||!R.approval)){let Z=Array.isArray(R.errorMessage)?R.errorMessage.join(", "):R.errorMessage;u(Z||"Failed to submit the decision.");}}catch(R){u(R instanceof Error?R.message:"Failed to submit the decision.");}});}return {approval:n,decide:K,errorMessage:d,isDeciding:c,isPending:n.status==="pending",isRejectDialogOpen:m,isStale:y,rejectReason:k,setIsRejectDialogOpen:b,setRejectReason:A}}function lt({allowRemember:e=false,askForRejectionReason:t,decide:a,isDeciding:n,isRejectDialogOpen:r,isStale:s,rejectReason:l$1,setIsRejectDialogOpen:d,setRejectReason:u,variant:c}){let p=c==="header",m=p?"fk:px-8 fk:min-w-32":void 0,b=p?"default":"sm",[y,f]=useState(false),k$1=useId();return jsxs(Fragment,{children:[jsxs("div",{className:"fk:flex fk:flex-nowrap fk:items-center fk:gap-2",children:[jsxs(b$2,{className:m,disabled:n,size:b,onClick:()=>a({approved:true,force:s,remember:e&&y}),children:[n?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):jsx(CheckIcon,{className:"fk:size-4"}),s?"Approve anyway":"Approve"]}),jsxs(b$2,{className:m,disabled:n,size:b,variant:"outline",onClick:()=>{t?(u(""),d(true)):a({approved:false});},children:[jsx(XIcon,{className:"fk:size-4"}),"Reject"]}),e?jsxs("label",{className:"fk:ml-1 fk:flex fk:cursor-pointer fk:items-center fk:gap-1.5 fk:whitespace-nowrap fk:text-xs fk:text-muted-foreground",htmlFor:k$1,children:[jsx(o,{checked:y,id:k$1,onCheckedChange:A=>f(A===true)}),"Always allow this tool for this automation"]}):null]}),t?jsx(c$1,{open:r,onOpenChange:d,children:jsxs(h$1,{children:[jsxs(i,{children:[jsx(k,{children:"Reject this proposal?"}),jsx(l,{children:"The mutation will not be executed. The agent receives your reason and can adapt its plan."})]}),jsx(ka$1,{placeholder:"Optional reason for the agent...",value:l$1,onChange:A=>u(A.target.value)}),jsxs(j$1,{children:[jsx(b$2,{disabled:n,size:"sm",variant:"outline",onClick:()=>d(false),children:"Cancel"}),jsxs(b$2,{disabled:n,size:"sm",variant:"destructive",onClick:()=>a({approved:false,reason:l$1.trim()||void 0}),children:[n?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):jsx(ArrowRightIcon,{className:"fk:size-4"}),"Reject proposal"]})]})]})}):null]})}var mn={always:"Every finished run",failures:"Failures only",never:"Never",when_flagged:"Results that need attention"};function kn(e){return e.visibility==="personal"?"Only you":e.visibility==="space"?`Space: ${e.spaceLabel??"unknown"}`:"Everyone in the project"}function gn({approval:e,instructions:t,isPending:a,proposal:n,onInstructionsChange:r}){let s=useId(),l=e.createdAutomation??null,d=[...n.replacesMonitor?[{label:"Replaces",value:`The monitor \u201C${n.replacesMonitor}\u201D, which stops once this exists`}]:[],{label:"Runs",value:n.triggers.join(`
3
+ `)},{label:"Visible to",value:kn(n)},{label:"Data changes",value:n.mutationPolicy==="auto_approve"?"Applied without review":"Wait for approval"},{label:"Notifications",value:`${mn[n.notifyRule]}${n.notifyCreator?", to you":""}${n.subscribers.length>0?` and ${n.subscribers.join(", ")}`:""}`},...n.plugins.length>0?[{label:"Plugins",value:n.plugins.map(u=>[u.account?`${u.name} as ${u.account}`:u.name,u.deliveryChannels.length>0?`posting to ${u.deliveryChannels.join(", ")}`:""].filter(Boolean).join(", ")).join(`
4
+ `)}]:[],...n.skills.length>0?[{label:"Skills",value:n.skills.join(", ")}]:[],...n.customTools.length>0?[{label:"Custom tools",value:n.customTools.join(", ")}]:[],{label:"Model",value:n.modelLabel}];return jsxs("div",{className:"fk:space-y-4",children:[n.mutationPolicy==="auto_approve"?jsxs("div",{className:"fk:flex fk:items-start fk:gap-2 fk:rounded-md fk:border fk:border-amber-500/40 fk:bg-amber-500/10 fk:p-3 fk:text-sm fk:corner-squircle",role:"status",children:[jsx(TriangleAlertIcon,{className:"fk:mt-0.5 fk:size-4 fk:shrink-0 fk:text-amber-600"}),jsxs("span",{children:["Every run will change data",n.plugins.length>0?" and call these plugins":""," without asking anyone first. Reject and ask for review if that is not what you want."]})]}):null,jsx("dl",{className:"fk:grid fk:grid-cols-[max-content_1fr] fk:gap-x-4 fk:gap-y-1.5 fk:text-sm",children:d.map(u=>jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:text-muted-foreground",children:u.label}),jsx("dd",{className:"fk:whitespace-pre-line",children:u.value})]},u.label))}),jsxs("div",{className:"fk:space-y-1.5",children:[jsx("label",{className:"fk:text-sm fk:font-medium",htmlFor:s,children:"Instructions"}),a&&r?jsxs(Fragment,{children:[jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"The automation never sees this chat, so these instructions are all it has to go on. Edit them before creating it."}),jsx(ka$1,{className:"fk:min-h-40 fk:text-sm",id:s,value:t,onChange:u=>r(u.target.value)})]}):jsx("p",{className:"fk:whitespace-pre-wrap fk:rounded-md fk:border fk:p-3 fk:text-sm fk:corner-squircle",id:s,children:t})]}),l?jsxs("div",{className:"fk:flex fk:flex-wrap fk:gap-2",children:[jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsx(Link,{to:`/${e.projectId}/ai/automations/${l.automationId}`,children:"Open the automation"})}),l.runId?jsx(b$2,{asChild:true,size:"sm",variant:"ghost",children:jsx(Link,{to:`/${e.projectId}/ai/automations/${l.automationId}/runs/${l.runId}`,children:"View its first run"})}):null]}):null]})}function vn({approval:e,change:t}){let a=t.changes.filter(r=>r.field!=="instructions"),n=t.changes.find(r=>r.field==="instructions");return jsxs("div",{className:"fk:space-y-4",children:[a.length>0?jsx("dl",{className:"fk:grid fk:grid-cols-[max-content_1fr] fk:gap-x-4 fk:gap-y-2 fk:text-sm",children:a.map(r=>jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:text-muted-foreground",children:r.label}),jsxs("dd",{className:"fk:space-y-0.5",children:[jsx("div",{className:"fk:whitespace-pre-line fk:text-muted-foreground fk:line-through",children:r.before}),jsx("div",{className:"fk:whitespace-pre-line",children:r.after})]})]},r.field))}):null,n?jsx("div",{className:"fk:grid fk:gap-3 fk:md:grid-cols-2",children:[{label:"Current instructions",muted:true,text:n.before},{label:"New instructions",muted:false,text:n.after}].map(r=>jsxs("div",{className:"fk:min-w-0 fk:space-y-1.5",children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:r.label}),jsx("p",{className:`fk:whitespace-pre-wrap fk:rounded-md fk:border fk:p-3 fk:text-sm fk:corner-squircle${r.muted?" fk:text-muted-foreground":""}`,children:r.text})]},r.label))}):null,jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsx(Link,{to:`/${e.projectId}/ai/automations/${t.automationId}`,children:"Open the automation"})})]})}function ut({decide:e,instructions:t,isDeciding:a,proposal:n}){let r=t.trim(),s=r!==n.instructions.trim()?{instructions:r}:{};return jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsxs(b$2,{disabled:a||r.length===0,size:"sm",variant:n.runOnceAfterCreate?"outline":"default",onClick:()=>e({approved:true,automationEdits:{...s,runOnce:false}}),children:[a?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):jsx(CheckIcon,{className:"fk:size-4"}),"Create"]}),jsxs(b$2,{disabled:a||r.length===0,size:"sm",variant:n.runOnceAfterCreate?"default":"outline",onClick:()=>e({approved:true,automationEdits:{...s,runOnce:true}}),children:[jsx(PlayIcon,{className:"fk:size-4"}),"Create and run once now"]}),jsxs(b$2,{disabled:a,size:"sm",variant:"outline",onClick:()=>e({approved:false}),children:[jsx(XIcon,{className:"fk:size-4"}),"Reject"]})]})}function dt({approval:e,automationInstructions:t,chat:a,errorMessage:n,isPending:r,isStale:s,onAutomationInstructionsChange:l}){let{preview:d}=e,u=a?ot(e):null;return jsxs("div",{className:"fk:min-w-0 fk:max-w-full fk:space-y-4",children:[jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx(rn,{status:e.status}),e.kind==="schema"?jsx(b,{variant:"outline",children:"Schema change"}):null,e.kind==="automation"?jsx(b,{variant:"outline",children:d?.automationChange?"Automation change":"New automation"}):null,jsx("span",{className:"fk:text-sm fk:font-medium",children:a?un(e):e.operationsSummary})]}),jsxs("div",{className:"fk:text-xs fk:text-muted-foreground",children:[e.automationName?`${e.automationName} \xB7 `:"","requested ",formatDistance(new Date(e.requestedAt),new Date,{addSuffix:true}),r?` \xB7 expires ${formatDistance(new Date(e.expiresAt),new Date,{addSuffix:true})}`:"",e.decidedAt?` \xB7 decided ${format(new Date(e.decidedAt),"PPpp")}`:""]}),s?jsxs("div",{className:"fk:flex fk:items-start fk:gap-2 fk:rounded-md fk:border fk:border-amber-500/40 fk:bg-amber-500/10 fk:p-3 fk:text-sm fk:corner-squircle",children:[jsx(TriangleAlertIcon,{className:"fk:mt-0.5 fk:size-4 fk:shrink-0 fk:text-amber-600"}),jsx("span",{children:"The affected data changed since this proposal was created. The preview below has been refreshed \u2014 review it and approve again to proceed."})]}):null,e.kind==="automation"&&d?.automation?jsx(gn,{approval:e,instructions:t??d.automation.instructions,isPending:r,proposal:d.automation,onInstructionsChange:l}):e.kind==="automation"&&d?.automationChange?jsx(vn,{approval:e,change:d.automationChange}):e.kind==="schema"&&d?jsx(cn,{preview:d}):d&&d.operations.length>0?jsx("div",{className:"fk:space-y-4",children:d.operations.map((c,p)=>jsxs("div",{className:"fk:space-y-2",children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:sn(c)}),c.kind==="delete"&&c.affectedCount!==null?jsxs("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:text-destructive fk:corner-squircle",children:[c.affectedCount.toString()," record",c.affectedCount===1?"":"s"," will be permanently deleted."]}):null,jsx(on,{operation:c}),c.truncated?jsxs("div",{className:"fk:text-xs fk:text-muted-foreground",children:["Preview limited to the first ",c.rows.length.toString()," rows."]}):null]},p.toString()))}):jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-3 fk:text-xs fk:text-muted-foreground fk:corner-squircle",children:a?u?`This action uses ${u.scope==="project"?"the project's":"your"} ${u.app} account${u.account?` (${u.account})`:""}. Check the details before deciding.`:"The assistant wants to make this change. Check the details before deciding.":e.kind==="plugin"?"Review the account, tool, and arguments before allowing this external call.":e.kind==="exec"?"This command runs inside the run's ephemeral sandbox but may send data out or reach other hosts. Review the command line before allowing it.":"No structured preview is available for this proposal. Review the raw GraphQL documents below."}),e.kind==="automation"?null:jsx(ln,{chat:a,operations:e.operations,plugin:e.kind==="plugin"||e.kind==="exec",title:e.kind==="exec"?"Command and options":e.kind==="schema"?"Operations":void 0}),e.reason?jsxs("div",{className:"fk:text-sm",children:[jsx("span",{className:"fk:font-medium",children:"Reason:"})," ",e.reason]}):null,e.error?jsxs("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:corner-squircle",children:["Execution failed: ",e.error]}):null,e.executedAt&&!e.error?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:text-sm fk:text-success",children:[jsx(CheckIcon,{className:"fk:size-4"}),"Executed ",format(new Date(e.executedAt),"PPpp")]}):null,n?jsx("div",{className:"fk:text-sm fk:text-destructive",children:n}):null]})}function ft({api:e,approval:t,chat:a,onDecided:n}){let{approval:r,decide:s,errorMessage:l,isDeciding:d,isPending:u,isRejectDialogOpen:c,isStale:p,rejectReason:m,setIsRejectDialogOpen:b,setRejectReason:y}=it({api:e,approval:t,onDecided:n}),f=r.kind==="automation"?r.preview?.automation??null:null,[k,A]=useState(f?.instructions??"");return jsxs(Fragment,{children:[jsx(dt,{approval:r,automationInstructions:f?k:void 0,chat:a,errorMessage:l,isPending:u,isStale:p,onAutomationInstructionsChange:f?A:void 0}),u&&f?jsx("div",{className:"fk:mt-4",children:jsx(ut,{decide:s,instructions:k,isDeciding:d,proposal:f})}):u?jsx("div",{className:"fk:mt-4",children:jsx(lt,{allowRemember:!a&&r.kind==="plugin"&&!!r.automationId,askForRejectionReason:!a,decide:s,isDeciding:d,isRejectDialogOpen:c,isStale:p,rejectReason:m,setIsRejectDialogOpen:b,setRejectReason:y,variant:"inline"})}):null]})}function nr({api:e,approval:t,onClose:a,onDecided:n}){let{approval:r,decide:s,errorMessage:l,isDeciding:d,isPending:u,isRejectDialogOpen:c,isStale:p,rejectReason:m,setIsRejectDialogOpen:b,setRejectReason:y}=it({api:e,approval:t,onDecided:n}),f=r.kind==="automation"?r.preview?.automation??null:null,[k,A]=useState(f?.instructions??"");return jsx(na,{actions:u&&f?jsx(ut,{decide:s,instructions:k,isDeciding:d,proposal:f}):u?jsx(lt,{allowRemember:r.kind==="plugin"&&!!r.automationId,askForRejectionReason:true,decide:s,isDeciding:d,isRejectDialogOpen:c,isStale:p,rejectReason:m,setIsRejectDialogOpen:b,setRejectReason:y,variant:"header"}):null,depth:0,isFocused:true,onClose:a,title:f?"Automation proposal":r.preview?.automationChange?"Automation change":"Mutation proposal",children:jsx(dt,{approval:r,automationInstructions:f?k:void 0,chat:false,errorMessage:l,isPending:u,isStale:p,onAutomationInstructionsChange:f?A:void 0})})}var yn="Approved by Flexkit Jev policy",hn="Approved by automation tool allow rule",bn=new Set(["data-create-sandbox","data-execute-graphql","data-load-skill","data-plan","data-plugin-call","data-run-command","data-search-schema","data-update-memory","data-validate-graphql","data-web-search"]);function te(e){return bn.has(e)}function h(e){return e.data}function Te(e){return !e.decidedBy&&!!(e.reason?.startsWith(yn)||e.reason?.startsWith(hn))}function H(e,t=72){let a=e.trim();if(a.length<=t)return a;let n=a.slice(0,t),r=n.lastIndexOf(" ");return `${(r>=Math.floor(t*.6)?n.slice(0,r):n).trimEnd()}\u2026`}function xn(e){return e.replace(/^#{1,6}\s+/,"").replace(/^(?:[-*+]|\d+[.)])\s+/,"").replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(\*|_)(.*?)\1/g,"$2").replace(/`([^`]*)`/g,"$1").replace(/[*_`#>]/g,"").replace(/\s+/g," ").trim().replace(/[.:]+$/,"")}function wn(e){let t=e.lastIndexOf(`
5
+ `),a=-1,n=/[.!?](?=\s)/g,r;for(;(r=n.exec(e))!==null;)a=r.index;let s=Math.max(t,a);return s<0?"":e.slice(0,s+1)}function An(e,t){let n=(wn(e)).split(/\r?\n/).map(u=>u.trim()).filter(Boolean),r=n[n.length-1];if(!r)return null;let l=/^\*\*(.+?)\*\*:?$/.exec(r)?.[1]??/^#{1,6}\s+(.+)$/.exec(r)?.[1]??/^(.+?[.!?])(?:\s|$)/.exec(r)?.[1]??r,d=xn(l);return !d||/^reasoning$/i.test(d)?null:H(d)}function ct(e){return e.replace(/[_-]+/g," ").trim()}function Rn(e){if(e.type==="data-load-skill"){let t=h(e);return t.status!=="loading"?null:t.skillName?H(`Loading skill "${t.skillName}"`):"Loading skill"}if(e.type==="data-search-schema")return h(e).status==="loading"?"Searching schema":null;if(e.type==="data-validate-graphql")return h(e).status==="loading"?"Validating GraphQL query":null;if(e.type==="data-execute-graphql"){let t=h(e);return t.status!=="loading"?null:t.operationType==="mutation"?"Executing GraphQL mutation":"Executing GraphQL query"}if(e.type==="data-update-memory")return h(e).status==="loading"?"Updating memory":null;if(e.type==="data-web-search"){let t=h(e);return t.status!=="loading"?null:t.query?H(`Searching the web for "${t.query}"`):"Searching the web"}if(e.type==="data-run-command"){let t=h(e);return ["executing","running","waiting"].includes(t.status)?H(`Running ${[t.command,...t.args].join(" ")}`):null}if(e.type==="data-create-sandbox")return h(e).status==="loading"?"Creating sandbox":null;if(e.type==="data-plugin-call"){let t=h(e);return t.status!=="loading"?null:H(`Calling ${t.pluginId}: ${ct(t.tool)}`)}if(e.type==="data-subtask"){let t=h(e);return t.status==="running"?H(`Running subtask: ${t.title}`):null}return null}var Sn=new Set(["data-execute-graphql","data-search-schema","data-validate-graphql"]);function fe(e){if(!te(e.type)||e.type==="data-plan"||Sn.has(e.type))return null;let t=h(e);if(t.status!=="error")return null;if(t.error?.message)return t.error.message;switch(e.type){case "data-web-search":return "Failed to search the web";case "data-run-command":return `Command failed: ${String(t.command??"")}`.trim();case "data-create-sandbox":return "Failed to create sandbox";case "data-load-skill":return "Failed to load skill";case "data-update-memory":return "Failed to update memory";case "data-plugin-call":return `Plugin call failed: ${String(t.pluginId??"")}: ${ct(String(t.tool??""))}`;default:return "The tool call failed"}}function ce(e){if(e.type==="step-start"||e.type==="reasoning")return true;if(te(e.type))return fe(e)===null;if(e.type==="data-mutation-approval"){let t=h(e);return Te(t)&&t.status!=="error"}return false}function ee(e){if(!e)return null;for(let t=e.parts.length-1;t>=0;t--){let a=e.parts[t];if(a?.type!=="data-plan")continue;let n=h(a),r=n.steps.findIndex(s=>s.status==="in_progress");return r<0?null:H(`Step ${(r+1).toString()} of ${n.steps.length.toString()}: ${n.steps[r].step}`)}return null}function Nn(e){if(!e)return null;for(let t=e.parts.length-1;t>=0;t--){let a=e.parts[t];if(!(!a||a.type==="step-start"))return a.type==="reasoning"?a.state==="streaming"?An(a.text)??ee(e):ee(e):a.type==="data-mutation-approval"?h(a).status==="pending"?"Awaiting approval":ee(e):a.type==="data-user-question"?h(a).status==="pending"?"Waiting for your answer":ee(e):a.type==="text"?null:Rn(a)??ee(e)}return null}function De(e){return e?e.parts.some(t=>t.type!=="data-mutation-approval"?false:h(t).status==="pending"):false}function Ie(e,t={}){let a=false,n=[];for(let r of e.parts){if(r.type!=="data-mutation-approval"){n.push(r);continue}let s=h(r);if(s.status!=="pending"){n.push(r);continue}a=true;let l=t[s.approvalId];l&&l!=="pending"&&n.push({...r,data:{...s,status:l}});}return a?{...e,parts:n}:e}function pt(e,t){if(!e)return [];let a=[],n=t?.pendingOnly??false;for(let r of e.parts){if(r.type!=="data-mutation-approval")continue;let s=h(r);n&&s.status!=="pending"||a.push(s.approvalId);}return a}function Cn(e){return pt(e,{pendingOnly:true})}function Me(e){return !!e?.parts.some(t=>t.type==="data-user-question"&&h(t).status==="pending")}function mt(e){return e.map(()=>({other:"",selected:[]}))}function kt(e,t,a){return e.multiSelect?{...t,selected:t.selected.includes(a)?t.selected.filter(n=>n!==a):[...t.selected,a]}:{other:"",selected:[a]}}function gt(e,t,a){return e.multiSelect?{...t,other:a}:{other:a,selected:a.trim()?[]:t.selected}}function vt(e){let t=[];for(let a of e){let n=a.other.trim();if(a.selected.length===0&&!n)return null;t.push(n?{other:n,selected:a.selected}:{selected:a.selected});}return t}function yt(e){return e&&[...e.selected,...e.other?[`\u201C${e.other}\u201D`]:[]].join(", ")||"\u2014"}var ht=20*1024*1024,pr=10,xt=new Set(["css","csv","gif","gql","graphql","htm","html","jpeg","jpg","js","json","jsx","log","markdown","md","mjs","ndjson","pdf","png","py","sql","ts","tsv","tsx","txt","webp","xml","yaml","yml"]),wt=new Set(["application/pdf","image/gif","image/jpeg","image/png","image/webp"]),mr=[...[...xt].map(e=>`.${e}`),...wt].join(",");function At(e){let t=e.lastIndexOf(".");return t<=0?"":e.slice(t+1).toLowerCase()}function In(e){let t=At(e.name);return (t?xt.has(t):wt.has(e.type))?e.size===0?`"${e.name}" is empty.`:e.size>ht?`"${e.name}" exceeds the ${String(Math.round(ht/(1024*1024)))} MB limit.`:null:`"${e.name}" is not supported. Attach images, PDFs, or text files.`}async function Mn(e){let a=await(await fetch(e.url)).blob();return new File([a],e.filename??"file",{type:e.mediaType||a.type})}function kr(e,t){let{attachments:a}=Nb(),n=useRef({}),[,r]=useState(0),s=useCallback(()=>r(c=>c+1),[]),l=useRef(a.remove);l.current=a.remove;let d=useRef(t);d.current=t,useEffect(()=>{let c=new Set(a.files.map(p=>p.id));for(let[p,m]of Object.entries(n.current))c.has(p)||(m.controller.abort(),delete n.current[p]);for(let p of a.files){if(n.current[p.id])continue;let m=new AbortController,b={controller:m,status:"uploading"};n.current[p.id]=b,(async()=>{try{let y=await Mn(p),f=In(y);if(f)throw new Error(f);let k=await e.uploadAgentChatAttachment(y,m.signal);if(m.signal.aborted)return;b.attachment=k,b.status="done";}catch(y){if(m.signal.aborted)return;b.status="error",delete n.current[p.id],l.current(p.id),d.current(y instanceof Error?y.message:"The file could not be uploaded.");}finally{s();}})();}s();},[e,a.files,s]);let u=Object.values(n.current).some(c=>c.status==="uploading");return {getUploaded:c=>c.map(p=>n.current[p]?.attachment).filter(p=>!!p),isUploading:u,isUploadingFile:c=>n.current[c]?.status==="uploading"}}function $e(e){return !!e?.startsWith("image/")}function Rt({image:e,onClose:t}){return jsx(c$1,{onOpenChange:a=>a?void 0:t(),open:e!==null,children:jsxs(h$1,{className:"fk:h-dvh fk:w-dvw fk:max-w-none fk:sm:max-w-none fk:rounded-none fk:border-0 fk:bg-black/90 fk:p-4 fk:shadow-none fk:flex fk:items-center fk:justify-center fk:corner-squircle",showCloseButton:false,children:[jsx(k,{className:"fk:sr-only",children:e?.filename??"Image preview"}),e?jsx("img",{alt:e.filename,className:"fk:block fk:h-auto fk:w-auto fk:max-h-full fk:max-w-full fk:object-contain",src:e.url}):null,jsx(f$2,{"aria-label":"Close preview",className:"fk:absolute fk:top-4 fk:right-4 fk:flex fk:size-9 fk:items-center fk:justify-center fk:rounded-full fk:bg-white/10 fk:text-white fk:transition-colors fk:hover:bg-white/20 fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-white/60 fk:corner-squircle",children:jsx(XIcon,{className:"fk:size-5"})})]})})}function St({label:e,onRemove:t}){return jsx("button",{"aria-label":e,className:"fk:absolute fk:top-1 fk:right-1 fk:z-10 fk:flex fk:size-5 fk:items-center fk:justify-center fk:rounded-full fk:border fk:border-border fk:bg-background fk:text-foreground fk:shadow-sm fk:transition-colors fk:hover:bg-accent fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring fk:corner-squircle",onClick:a=>{a.stopPropagation(),t();},type:"button",children:jsx(XIcon,{className:"fk:size-3"})})}function Nt({image:e,isUploading:t=false,onOpen:a,onRemove:n,sizeClassName:r}){return jsxs("div",{className:`fk:relative fk:shrink-0 fk:overflow-hidden fk:rounded-xl fk:bg-muted ${r} fk:corner-squircle`,children:[jsx("button",{"aria-label":`Preview ${e.filename}`,className:"fk:block fk:size-full fk:cursor-zoom-in fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring",onClick:a,type:"button",children:jsx("img",{alt:e.filename,className:"fk:size-full fk:object-cover",src:e.url})}),t?jsx("div",{className:"fk:pointer-events-none fk:absolute fk:inset-0 fk:flex fk:items-center fk:justify-center fk:bg-background/60",children:jsx(ta,{className:"fk:size-4"})}):null,n?jsx(St,{label:`Remove ${e.filename}`,onRemove:n}):null]})}function En(e,t){let a=At(e);if(a)return a.toUpperCase();let n=t?.split("/")[1]?.split("+")[0];return n?n.toUpperCase():"FILE"}function Ct({file:e,href:t,isUploading:a=false,onRemove:n}){let r=jsxs(Fragment,{children:[jsx("div",{className:"fk:flex fk:size-10 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-lg fk:bg-muted fk:text-muted-foreground fk:corner-squircle",children:a?jsx(ta,{className:"fk:size-4"}):jsx(FileIcon,{className:"fk:size-5"})}),jsxs("div",{className:"fk:min-w-0 fk:pr-4 fk:text-left",children:[jsx("div",{className:"fk:truncate fk:text-sm fk:font-medium fk:text-foreground",children:e.filename}),jsx("div",{className:"fk:truncate fk:text-xs fk:text-muted-foreground",children:En(e.filename,e.mediaType)})]})]}),s="fk:flex fk:h-14 fk:max-w-64 fk:items-center fk:gap-2.5 fk:rounded-xl fk:border fk:border-border fk:bg-background fk:px-2 fk:corner-squircle";return jsxs("div",{className:"fk:relative fk:shrink-0",children:[t?jsx("a",{className:`${s} fk:transition-colors fk:hover:bg-accent/50 fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring`,href:t,rel:"noreferrer",target:"_blank",children:r}):jsx("div",{className:s,children:r}),n?jsx(St,{label:`Remove ${e.filename}`,onRemove:n}):null]})}function gr({uploads:e}){let t=Qb(),[a,n]=useState(null);return t.files.length===0?null:jsxs(Fragment,{children:[jsx("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:t.files.map(r=>{if($e(r.mediaType)&&r.url){let s={filename:r.filename??"Image",url:r.url};return jsx(Nt,{image:s,isUploading:e.isUploadingFile(r.id),onOpen:()=>n(s),onRemove:()=>t.remove(r.id),sizeClassName:"fk:size-14"},r.id)}return jsx(Ct,{file:{filename:r.filename??"file",mediaType:r.mediaType},isUploading:e.isUploadingFile(r.id),onRemove:()=>t.remove(r.id)},r.id)})}),jsx(Rt,{image:a,onClose:()=>n(null)})]})}function vr(e){return Array.isArray(e)?e.filter(t=>t.type==="file"&&typeof t.url=="string").map(t=>({filename:t.filename??"file",mediaType:t.mediaType??"application/octet-stream",sizeBytes:t.sizeBytes??0,url:t.url??""})):[]}function Pt({attachments:e}){let[t,a]=useState(null);if(e.length===0)return null;let n=e.filter(s=>$e(s.mediaType)),r=e.filter(s=>!$e(s.mediaType));return jsxs("div",{className:"fk:flex fk:flex-col fk:items-end fk:gap-2",children:[n.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:justify-end fk:gap-2",children:n.map(s=>jsx(Nt,{image:s,onOpen:()=>a(s),sizeClassName:"fk:size-24"},s.url))}):null,jsx(Rt,{image:t,onClose:()=>a(null)}),r.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:justify-end fk:gap-2",children:r.map(s=>jsx(Ct,{file:s,href:s.url},s.url))}):null]})}function Nr(e){let t=(Array.isArray(e.parts)?e.parts:[]).find(a=>a.type==="data-monitor-event");return t&&typeof t.data=="object"&&t.data!==null?t.data:null}function It({data:e,error:t}){let a=e.total-e.events.length;return jsxs("div",{className:"fk:mr-auto fk:w-full fk:max-w-[85%] fk:space-y-1.5 fk:rounded-lg fk:border fk:border-border fk:bg-muted/40 fk:px-3.5 fk:py-2.5 fk:text-sm fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:text-xs fk:text-muted-foreground",children:[jsx(RadarIcon,{className:"fk:size-3.5 fk:shrink-0"}),jsxs("span",{className:"fk:truncate",children:["Monitor \xB7 ",e.description]})]}),jsxs("ul",{className:"fk:space-y-0.5",children:[e.events.map(n=>jsx("li",{children:n.summary},n.id)),a>0?jsxs("li",{className:"fk:text-muted-foreground",children:["\u2026and ",a.toString()," more"]}):null]}),t?jsx("p",{className:"fk:text-xs fk:text-destructive",children:t}):null]})}function Cr({api:e$1,chatId:t,onTurnIntoAutomation:a,projectId:n,sending:r=false}){let{data:s,mutate:l}=On(g(n).agentChat(t),f$1,{revalidateOnMount:false}),[d,u]=useState(null),c$1=s?.monitors??[];if(c$1.length===0)return null;async function p(m){u(m.id);try{await e$1.stopAgentChatMonitor(t,m.id),await l();}catch{oa.error("Unable to stop the monitor.");}finally{u(null);}}return jsx("div",{className:"fk:mx-auto fk:mb-2 fk:flex fk:max-w-4xl fk:flex-wrap fk:gap-2",children:c$1.map(m=>jsxs("div",{className:"fk:flex fk:max-w-full fk:items-center fk:gap-2 fk:rounded-full fk:border fk:border-border fk:py-1 fk:pl-3 fk:pr-1 fk:text-xs fk:text-muted-foreground",children:[jsx(RadarIcon,{className:"fk:size-3.5 fk:shrink-0 fk:animate-pulse"}),jsxs("span",{className:"fk:truncate",children:["Watching: ",m.description," \xB7 expires ",formatDistance(new Date(m.expiresAt),new Date,{addSuffix:true})]}),a&&m.sourceType&&m.sourceType!=="job"?jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(b$2,{"aria-label":`Turn ${m.description} into an automation`,className:"fk:size-6 fk:rounded-full",disabled:r,size:"icon",variant:"ghost",onClick:()=>a(m),children:jsx(BotIcon,{className:"fk:size-3.5"})})}),jsx(e,{children:"Turn into automation"})]}):null,jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(b$2,{"aria-label":`Stop watching ${m.description}`,className:"fk:size-6 fk:rounded-full",disabled:d===m.id,size:"icon",variant:"ghost",onClick:()=>{p(m);},children:jsx(XIcon,{className:"fk:size-3.5"})})}),jsx(e,{children:"Stop watching"})]})]},m.id))})}var W=class extends Error{},pe=class extends Error{};function Mt({url:e,signal:t,state:a,onState:n,wake:r,fetchStream:s=fetch,retryMs:l=2e3}){let d=0,u=0,c=new TransformStream,p=c.writable.getWriter(),m=new AbortController;p.closed.catch(k=>m.abort(k));let b=()=>{m.abort(t.reason),p.abort(t.reason).catch(()=>{});};t.addEventListener("abort",b,{once:true}),t.aborted&&b();let y=()=>new Promise(k=>{let A=()=>{clearTimeout(C),m.signal.removeEventListener("abort",A),r?.removeEventListener("wake",A),k();},C=setTimeout(A,l);m.signal.addEventListener("abort",A,{once:true}),r?.addEventListener("wake",A,{once:true}),m.signal.aborted&&A();});async function f(){try{for(await p.write({type:"start"});!m.signal.aborted;){try{let k=await s(`${e}${e.includes("?")?"&":"?"}wire=2&startIndex=${d}`,{credentials:"include",signal:m.signal});if(k.status===404){n("unavailable"),await p.close();return}if(k.status===401||k.status===403)throw new pe("Stream access denied");if(!k.ok||!k.body)throw new Error(`Stream request failed: ${k.status}`);if(k.headers.get("x-flexkit-stream-version")!=="2")throw await k.body.cancel(),new W("Backend uses legacy replay");n("streaming");let A=k.body.pipeThrough(new TextDecoderStream).getReader(),C="",P=!1;try{for(;!m.signal.aborted;){let{value:K,done:x}=await A.read();if(x)break;C+=K;let T;for(;(T=C.indexOf(`
6
+ `))>=0;){let X=C.slice(0,T);if(C=C.slice(T+1),!X)continue;let D=JSON.parse(X);if(!Number.isSafeInteger(D.index)||D.index<0)throw new Error("Invalid replay cursor");if(!(D.index<d)){if(D.index!==d)throw new Error("Replay cursor gap");D.chunk&&await p.write(D.chunk),d=D.index+1,u=0,D.chunk?.type==="finish"&&D.chunk.messageMetadata?.flexkitTerminal&&(P=!0);}}if(C.length>2e6)throw new Error("Oversized replay frame");if(P)break}}finally{await A.cancel().catch(()=>{}),A.releaseLock();}if(P||a().terminal&&!C){await p.write({type:"finish"}),await p.close(),n("finished");return}}catch(k){if(m.signal.aborted||k instanceof W||k instanceof pe||++u>=5)throw k}do n(a().paused?"paused":"streaming"),await y();while(!m.signal.aborted&&a().paused&&!a().terminal)}}catch(k){await p.abort(k).catch(()=>{});}finally{t.removeEventListener("abort",b),p.releaseLock();}}return f(),pipeJsonRender(c.readable)}var qn={pending:"Waiting for an answer.",cancelled:"The turn was stopped before you answered.",dismissed:"You skipped these questions.",expired:"Nobody answered in time."};function Bn({description:e,label:t,multiSelect:a,onClick:n,selected:r}){return jsxs("button",{"aria-checked":r,className:`fk:flex fk:w-full fk:items-start fk:gap-2.5 fk:rounded-lg fk:border fk:px-3 fk:py-2 fk:text-left fk:transition-colors fk:corner-squircle ${r?"fk:border-primary fk:bg-primary/5":"fk:border-border fk:hover:bg-muted/60"}`,onClick:n,role:a?"checkbox":"radio",type:"button",children:[jsx("span",{className:`fk:mt-0.5 fk:flex fk:size-4 fk:shrink-0 fk:items-center fk:justify-center fk:border ${a?"fk:rounded-sm":"fk:rounded-full"} ${r?"fk:border-primary fk:bg-primary fk:text-primary-foreground":"fk:border-muted-foreground/50"}`,children:r?jsx(CheckIcon,{className:"fk:size-3"}):null}),jsxs("span",{className:"fk:min-w-0",children:[jsx("span",{className:"fk:block fk:text-sm fk:font-medium",children:t}),e?jsx("span",{className:"fk:block fk:text-xs fk:text-muted-foreground",children:e}):null]})]})}function Qn({disabled:e,draft:t,onChange:a,question:n}){return jsxs("fieldset",{className:"fk:space-y-2",disabled:e,children:[jsxs("legend",{className:"fk:mb-2 fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx(b,{variant:"outline",children:n.header}),jsx("span",{className:"fk:text-sm fk:font-medium",children:n.question}),n.multiSelect?jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Pick any"}):null]}),jsxs("div",{className:"fk:space-y-1.5",role:n.multiSelect?"group":"radiogroup",children:[n.options.map(r=>jsx(Bn,{description:r.description,label:r.label,multiSelect:n.multiSelect,onClick:()=>a(kt(n,t,r.label)),selected:t.selected.includes(r.label)},r.label)),jsx(s,{"aria-label":`Your own answer to: ${n.question}`,className:"fk:h-9",maxLength:4e3,onChange:r=>a(gt(n,t,r.target.value)),placeholder:"Other \u2014 type your own answer",value:t.other})]})]})}function Jn({data:e}){return e.status==="answered"&&e.message!==void 0?jsxs("div",{className:"fk:space-y-1",children:[jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:e.questions.map(t=>t.question).join(" \xB7 ")}),jsxs("p",{className:"fk:text-sm",children:["You replied: ",jsxs("span",{className:"fk:whitespace-pre-wrap",children:["\u201C",e.message,"\u201D"]})]})]}):e.status!=="answered"?jsxs("div",{className:"fk:space-y-1",children:[jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:e.questions.map(t=>t.question).join(" \xB7 ")}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:qn[e.status]})]}):jsx("dl",{className:"fk:space-y-1.5",children:e.questions.map((t,a)=>jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-baseline fk:gap-x-2",children:[jsx("dt",{className:"fk:text-xs fk:text-muted-foreground",children:t.question}),jsx("dd",{className:"fk:text-sm fk:font-medium",children:yt(e.answers?.[a])})]},a))})}function $t({answer:e,data:t}){let[a,n]=useState(()=>mt(t.questions)),[r,s]=useState(null),[l,d]=useState(null),[u,c]=useState(""),p=t.status==="pending"&&r?r:t;if(p.status!=="pending"||!e)return jsx(Jn,{data:p});let m=vt(a);async function b(y){if(e){d(y.action),c("");try{let f=await e(t.questionId,y);f&&s({...f.answers?{answers:f.answers}:{},...f.message!==null?{message:f.message}:{},questionId:f.id,questions:f.questions,status:f.status});}catch(f){c(f instanceof Error?f.message:"Could not send the answer.");}finally{d(null);}}}return jsxs("form",{className:"fk:space-y-5",onSubmit:y=>{y.preventDefault(),m&&b({action:"answer",answers:m});},children:[t.questions.map((y,f)=>jsx(Qn,{disabled:l!==null,draft:a[f]??{other:"",selected:[]},onChange:k=>n(A=>A.map((C,P)=>P===f?k:C)),question:y},f)),u?jsx("p",{className:"fk:text-xs fk:text-destructive",children:u}):null,jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsxs(b$2,{disabled:!m||l!==null,size:"sm",type:"submit",children:[l==="answer"?jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}):null,"Submit"]}),jsxs(b$2,{disabled:l!==null,onClick:()=>{b({action:"dismiss"});},size:"sm",type:"button",variant:"ghost",children:[l==="dismiss"?jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}):null,"Skip"]}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"or reply in the chat"})]})]})}var fa=lazy(()=>import('./spec-renderer-EX7SCFWH.js').then(e=>({default:e.RunSpecPart})));function ca(e){return jsx(Suspense,{fallback:null,children:jsx(fa,{...e})})}function pa(){let{currentProjectId:e}=f();return {api:useMemo(()=>e?d(e):null,[e]),projectId:e}}var _t=5,Bt=2e3,Qt=120,ze="data-spec",Jt=createContext(null),ma=createContext(false);function ka(e){return new Promise(t=>window.setTimeout(t,e))}function ga(e){return e instanceof Error?e.name==="AbortError"||e.message.toLowerCase().includes("aborted"):false}function va(e){return e.some(t=>!ce(t))}function ya(e){let t=new Set;for(let a of e)for(let n of a.parts)n.type==="data-user-message"&&n.id&&t.add(n.id);return t}function ha(e){let t=ya(e),a=[];for(let n of e){if(n.role==="user"){t.has(n.id)||a.push(n);continue}if(n.role!=="assistant"){a.push(n);continue}let r=[],s=0,l=()=>{va(r)&&a.push({...n,id:`${n.id}-${s.toString()}`,parts:r}),s++,r=[];};for(let d of n.parts){if(d.type==="data-user-message"){let u=h(d);l(),a.push({id:d.id??crypto.randomUUID(),parts:u.parts,role:"user"});continue}r.push(d);}l();}return a}function ns(e){return useMemo(()=>ha(e),[e])}function Y(e){return e==="success"||e==="failed"||e==="cancelled"||e==="skipped"}function Xt({latestMessage:e,recordStatus:t,suppressApprovalPause:a}){return Y(t)||a||t==="running"?false:t==="awaiting_approval"?true:De(e)||Me(e)}function as(e,t){let[a,n]=useState(false),r=ba(a?e:"",t),[s,l]=useState(),[d,u]=useState("streaming"),c=useRef(t);c.current=t;let p=useRef(null);p.current||(p.current=new EventTarget);let m=p.current,b=t?.resumeToken;return useEffect(()=>{m.dispatchEvent(new Event("wake"));},[b,m]),useEffect(()=>{if(n(false),l(void 0),!e){u("unavailable");return}let y=new AbortController,f,k,A=()=>{f=void 0,k&&!y.signal.aborted&&l({...k});},C=Mt({url:e,signal:y.signal,state:()=>({terminal:Y(c.current?.recordStatus),paused:Xt({latestMessage:k,recordStatus:c.current?.recordStatus,suppressApprovalPause:c.current?.suppressApprovalPause??false})}),onState:P=>{y.signal.aborted||u(P);},wake:m});return (async()=>{try{for await(let P of readUIMessageStream({stream:C,terminateOnError:!0}))k=P,f||(f=setTimeout(A,Qt));A();}catch(P){if(y.signal.aborted)return;P instanceof W?n(true):(console.error("Run stream error",P),u("error"));}})(),()=>{y.abort(),f&&clearTimeout(f);}},[e,m]),a?r:{message:s?Ie(s,t?.decidedApprovals??{}):void 0,status:d}}function ba(e,t){let[a,n]=useState(),[r,s]=useState("streaming"),l=t?.recordStatus,d=t?.resumeToken??0,u=useRef(t?.decidedApprovals??{});u.current=t?.decidedApprovals??{};let c=useRef(t?.suppressApprovalPause??false);c.current=t?.suppressApprovalPause??false;let p=useRef(e),m=useRef(a);return m.current=a,useEffect(()=>{let b=p.current!==e;if(p.current=e,!e){n(void 0),s("unavailable");return}let y=new AbortController,f=b?void 0:m.current,k=b?0:f?.parts.length??0;if(b)n(void 0);else if(f&&(l==="running"||Y(l))){let x=Ie(f,u.current);x!==f&&(f=x,n(x));}s("streaming");let A=e.includes("?")?"&":"?",C=async()=>{let x=await fetch(`${e}${A}startIndex=0`,{credentials:"include",signal:y.signal});if(x.status===404)return "unavailable";if(!x.ok||!x.body)throw new Error(`Failed to fetch the run stream (status ${x.status.toString()})`);let T=false,D=parseJsonEventStream({schema:uiMessageChunkSchema,stream:x.body}).pipeThrough(new TransformStream({transform:(E,Ft)=>{if(!E.success)throw E.error;E.value.type==="finish"&&(T=true),Ft.enqueue(E.value);}})),ge=readUIMessageStream({onError:E=>{y.signal.aborted||console.error("Run stream chunk error",E);},stream:D}),R=null,Z=k===0,qe=(E=false)=>{y.signal.aborted||!f||!Z&&(Z=E||f.parts.length>=k,!Z)||n({...f});};try{for await(let E of ge){if(y.signal.aborted)break;f=E,R===null&&(R=window.setTimeout(()=>{R=null,qe();},Qt));}}finally{R!==null&&(window.clearTimeout(R),R=null),qe(true);}return T?"finished":"incomplete"},P=async()=>{let x=0;for(;!y.signal.aborted;){x>0&&await ka(Bt);try{let T=await C();if(y.signal.aborted)return;if(T==="unavailable"){s("unavailable");return}if(T==="finished"&&Y(l)){s("finished");return}if(Y(l)){s("finished");return}if(Xt({latestMessage:f,recordStatus:l,suppressApprovalPause:c.current})){s("paused");return}if(!(l==="running"||c.current)&&x>=_t-1){s("error");return}}catch(T){if(y.signal.aborted||ga(T))return;if(console.error("Run stream error",T),Y(l)){s("finished");return}if(!(l==="running"||c.current)&&x>=_t-1){s("error");return}}x+=1;}},K=window.setTimeout(()=>{P();},0);return ()=>{window.clearTimeout(K),y.abort("Run replay unmounted");}},[l,d,e]),{message:a,status:r}}function rs(e){return {affectedCount:e.affectedCount,approvalId:e.id,decidedBy:e.decidedBy??void 0,operationsSummary:e.operationsSummary,reason:e.reason??void 0,status:e.status}}function xa(e){let t=e.trim();return t?t.split(`
7
+ `).every(a=>/^`{3,}[\w-]*$/.test(a.trim())):false}function wa({attachments:e,text:t}){return jsxs("div",{className:"fk:ml-auto fk:flex fk:w-fit fk:max-w-[70%] fk:flex-col fk:items-end fk:gap-1",children:[jsx(Pt,{attachments:e}),t.trim()?jsx("div",{className:"fk:whitespace-pre-wrap fk:rounded-xl fk:bg-muted fk:dark:bg-white/20 fk:px-3.5 fk:py-2 fk:text-base fk:corner-squircle",children:t}):null,jsxs("span",{className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-xs fk:text-muted-foreground",children:[jsx(CornerDownRightIcon,{className:"fk:size-3 fk:shrink-0"}),"Added while the agent was working"]})]})}function ss({api:e,part:t,partIndex:a,parts:n}){if(ce(t))return null;if(te(t.type)){let r=fe(t);return r?jsx(Ra,{message:r}):null}if(t.type==="text")return xa(t.text)&&n.some(s=>s.type===ze)?null:jsx(Aa,{part:t});if(t.type==="data-generating-files")return jsx(Ta,{message:h(t)});if(t.type==="data-run-artifact")return jsx(Da,{api:e,message:h(t)});if(t.type==="data-tool-delivery")return jsx(Ia,{message:h(t)});if(t.type==="data-run-summary")return jsx(Ma,{message:h(t)});if(t.type==="data-subtask"){let r=h(t),s=r.status==="running"?`Running "${r.title}"`:r.status==="done"?`Completed "${r.title}"${typeof r.stepsUsed=="number"?` in ${r.stepsUsed.toString()} steps`:""}`:`"${r.title}" failed: ${r.error?.message??"unknown error"}`;return jsxs(j,{children:[jsxs(U,{children:[jsx(BotIcon,{className:"fk:size-3.5"}),"Subtask"]}),jsxs("div",{className:"fk:relative fk:min-h-5 fk:pl-6",children:[jsx("span",{className:"fk:absolute fk:left-0 fk:top-0",children:jsx(ke,{isError:r.status==="error",loading:r.status==="running"})}),jsx("span",{className:"fk:text-xs",children:s}),r.resultPreview?jsx("p",{className:"fk:mt-1 fk:text-xs fk:text-muted-foreground",children:r.resultPreview}):null]})]})}if(t.type==="data-mid-turn-message"){let r=h(t);return r.monitorEvent?jsx(It,{data:r.monitorEvent}):jsx(wa,{attachments:r.attachments,text:r.text})}if(t.type==="data-context-compaction"){let r=h(t);return jsxs("p",{className:"fk:text-xs fk:text-muted-foreground",children:["Earlier messages (",r.summarizedMessageCount.toString(),") were summarized to keep this conversation within the model's context. Details may need to be re-fetched."]})}if(t.type==="data-plugin-connection"){let r=h(t);return jsx(Ua,{pluginId:r.pluginId})}if(t.type==="data-suggested-prompt")return null;if(t.type==="data-turn-error"){let r=h(t);return jsxs(j,{className:"fk:border-red-700/40",children:[jsxs(U,{children:[jsx(XCircleIcon,{className:"fk:size-3.5 fk:text-red-700"}),jsx("span",{children:"Turn failed"})]}),jsx("p",{className:"fk:whitespace-pre-wrap fk:text-xs",children:r.message})]})}if(t.type==="data-mutation-approval"){let r=h(t);return Te(r)?jsx(_a,{message:r}):jsx(Ea,{api:e,message:r})}return t.type==="data-user-question"?jsx($a,{data:h(t)}):t.type==="data-bulk-graphql-action"?jsx(za,{message:h(t)}):t.type===ze?n.slice(a+1).find(s=>s.type===ze)?null:jsx(ca,{parts:n}):t.type.startsWith("data-")?jsx(ja,{part:t}):null}function Aa({part:e}){return jsx(ob,{className:"fk:min-w-0 fk:max-w-full fk:overflow-x-auto fk:text-base fk:leading-relaxed fk:text-foreground",isAnimating:e.state==="streaming",children:e.text})}function Ra({message:e}){return jsxs("div",{className:"fk:flex fk:items-start fk:gap-2 fk:rounded-xl fk:border fk:border-red-700/40 fk:bg-destructive/5 fk:px-3.5 fk:py-3 fk:text-sm fk:corner-squircle",children:[jsx(XCircleIcon,{className:"fk:mt-0.5 fk:size-3.5 fk:shrink-0 fk:text-red-700"}),jsx("span",{className:"fk:whitespace-pre-wrap fk:text-xs",children:e})]})}var Sa=1e3;function Na({text:e}){let t=useRef(typeof performance>"u"?0:performance.now()),a=()=>-(((typeof performance>"u"?0:performance.now())-t.current)%Sa),[n,r]=useState({current:e,currentDelayMs:0,key:0,previous:null,previousDelayMs:0});return useEffect(()=>{r(s=>s.current===e?s:{current:e,currentDelayMs:a(),key:s.key+1,previous:s.current,previousDelayMs:s.currentDelayMs});},[e]),jsxs("span",{className:"fk:relative fk:block fk:h-5 fk:min-w-0 fk:flex-1 fk:overflow-hidden",children:[n.previous?jsx("span",{"aria-hidden":true,className:"fk:absolute fk:inset-x-0 fk:top-0 fk:block fk:animate-roll-up-out",children:jsx("span",{className:"fk:block fk:truncate fk:shimmer fk:shimmer-duration-1000",style:{animationDelay:`${n.previousDelayMs.toString()}ms`},children:n.previous})},`previous-${n.key.toString()}`):null,jsx("span",{className:n.previous?"fk:block fk:animate-roll-up-in":"fk:block",role:"status",children:jsx("span",{className:"fk:block fk:truncate fk:shimmer fk:shimmer-duration-1000",style:{animationDelay:`${n.currentDelayMs.toString()}ms`},children:n.current})},`current-${n.key.toString()}`)]})}var Ca=1e3;function Pa(e,t){let a=Ca,[n,r]=useState(e),s=useRef(Date.now()),l=useRef(e);return l.current=e,useEffect(()=>{if(e===n)return;let d=Math.max(0,a-(Date.now()-s.current)),u=window.setTimeout(()=>{s.current=Date.now(),r(l.current);},d);return ()=>{window.clearTimeout(u);}},[n,e,a]),n}function os({label:e,visible:t}){let a=Pa(e);return jsx("div",{"aria-hidden":!t,className:`fk:flex fk:h-9 fk:items-center fk:text-sm fk:text-muted-foreground fk:transition-[opacity,visibility] fk:duration-200 ${t?"fk:visible fk:opacity-100":"fk:invisible fk:opacity-0"}`,children:jsx(Na,{text:a})})}function j({children:e,className:t=""}){return jsx("div",{className:`fk:min-w-0 fk:max-w-full fk:overflow-x-auto fk:rounded-xl fk:border fk:border-border fk:bg-background fk:px-3.5 fk:py-3 fk:text-sm ${t} fk:corner-squircle`,children:e})}function U({children:e}){return jsx("div",{className:"fk:flex fk:items-center fk:gap-2 fk:font-medium fk:text-muted-foreground",children:e})}function ke({isError:e,loading:t}){return t?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):e?jsx(XIcon,{className:"fk:size-4 fk:text-red-700"}):jsx(CheckIcon,{className:"fk:size-4"})}function Ue({error:e,icon:t,loading:a,message:n,title:r}){return jsxs(j,{children:[jsxs(U,{children:[t,r]}),jsxs("div",{className:"fk:relative fk:min-h-5 fk:pl-6",children:[jsx("span",{className:"fk:absolute fk:left-0 fk:top-0",children:jsx(ke,{isError:!!e,loading:a})}),jsx("span",{className:"fk:text-xs",children:n})]})]})}function Ta({message:e}){let t=["error","uploading","generating"].includes(e.status),a=t?e.paths.slice(0,e.paths.length-1):e.paths,n=t?e.paths[e.paths.length-1]??"":null;return jsxs(j,{children:[jsxs(U,{children:[jsx(CloudUploadIcon,{className:"fk:size-3.5"}),jsx("span",{children:e.status==="done"?"Uploaded files":"Generating files"})]}),jsxs("div",{className:"fk:space-y-1 fk:text-sm",children:[a.map((r,s)=>jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(CheckIcon,{className:"fk:size-4"}),jsx("span",{className:"fk:whitespace-pre-wrap",children:r})]},`${r}-${s.toString()}`)),typeof n=="string"?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(ke,{isError:e.status==="error",loading:e.status!=="error"}),jsx("span",{children:e.status==="error"?e.error?.message??n:n})]}):null]})]})}function Da({api:e,message:t}){let a=t.status==="done"&&t.artifactId,n=a?e.getArtifactUrl(t.artifactId??""):"",r=a?e.getArtifactUrl(t.artifactId??"",{download:true}):"",s=Oa(t.sizeBytes);return jsxs(j,{children:[jsxs(U,{children:[jsx(FileTextIcon,{className:"fk:size-3.5"}),t.status==="done"?"Published artifact":"Publishing artifact"]}),jsxs("div",{className:"fk:relative fk:min-h-5 fk:pl-6",children:[jsx("span",{className:"fk:absolute fk:left-0 fk:top-0",children:jsx(ke,{isError:t.status==="error",loading:t.status==="uploading"})}),jsxs("div",{className:"fk:min-w-0 fk:space-y-2",children:[jsxs("div",{className:"fk:min-w-0",children:[jsx("div",{className:"fk:truncate fk:font-medium",children:t.filename}),jsxs("div",{className:"fk:text-xs fk:text-muted-foreground",children:[t.status==="uploading"&&"Uploading to artifacts",t.status==="done"&&[La(t),s].filter(Boolean).join(" \xB7 "),t.status==="error"&&(t.error?.message??"Failed to publish artifact")]})]}),a?jsxs("div",{className:"fk:flex fk:flex-wrap fk:gap-2",children:[jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsx("a",{href:n,rel:"noreferrer",target:"_blank",children:"Preview"})}),jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsxs("a",{href:r,children:[jsx(DownloadIcon,{className:"fk:size-3"}),"Download"]})}),t.url?jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsxs("a",{href:t.url,rel:"noreferrer",target:"_blank",children:[jsx(LinkIcon,{className:"fk:size-3"}),"Permanent link"]})}):null]}):null]})]})]})}function Ia({message:e}){let t=e.provider==="slack"?"Slack":"Microsoft Teams",a=e.provider==="slack"?jsx(MessageSquareIcon,{className:"fk:size-3.5"}):jsx(SendIcon,{className:"fk:size-3.5"});return jsx(Ue,{error:e.error?.message,icon:a,loading:e.status==="loading",message:e.status==="error"?e.error?.message??`Failed to send result to ${e.channelName}`:`${e.status==="done"?"Sent":"Sending"} result to ${e.channelName}`,title:`${t} Delivery`})}function Ma({message:e}){let t=e.status==="success"?jsx(CheckCircle2Icon,{className:"fk:size-3.5 fk:text-green-700"}):e.status==="skipped"?jsx(CircleSlashIcon,{className:"fk:size-3.5"}):jsx(XCircleIcon,{className:"fk:size-3.5 fk:text-red-700"}),a=e.status==="success"?"Run completed":e.status==="skipped"?"Run skipped":"Run failed";return jsxs(j,{className:e.status==="failed"?"fk:border-red-700/40":"fk:border-green-700/40",children:[jsxs(U,{children:[t,jsx("span",{children:a})]}),e.status==="failed"?jsx("p",{className:"fk:whitespace-pre-wrap fk:text-xs",children:e.summary}):null]})}function Ea({api:e,message:t}){let{projectId:a}=pa(),n=useContext(Jt),r=useContext(ma),s=useRef(void 0),{data:l,error:d,isValidating:u,mutate:c}=On(a?g(a).approval(t.approvalId):null,f$1,{refreshInterval:k=>t.status!=="pending"||k?.approval?.status&&k.approval.status!=="pending"?0:Bt}),p=l?.approval?.status,m=(p??t.status)==="pending",b=l?.approval?.kind==="schema"&&l.approval.status==="approved";useEffect(()=>{!b||!a||de({approvalId:t.approvalId,approvalUrl:g(a).approval(t.approvalId),projectId:a});},[b,t.approvalId,a]),useEffect(()=>{c();},[t.status,c]),useEffect(()=>{let k=s.current;s.current=p,!(t.status!=="pending"||!p||p==="pending")&&k==="pending"&&n?.onApprovalDecided(l?.approval?.id??t.approvalId,p);},[p,l?.approval?.id,t.approvalId,t.status,n]);function y(k){k.status!=="pending"&&(s.current=k.status),c(),n?.onApprovalDecided(k.id,k.status);}let f;if(l?.approval)f=jsx(ft,{api:e,approval:l.approval,chat:r,onDecided:y},l.approval.status);else if(d&&!u){let k=d instanceof Error&&d.message?d.message:"Request failed";f=jsxs("div",{className:"fk:space-y-2",children:[jsxs("p",{className:"fk:text-xs fk:text-destructive",children:["Failed to load proposal ",t.operationsSummary,": ",k]}),jsx(b$2,{size:"sm",variant:"outline",onClick:()=>{c();},children:"Retry"})]});}else f=jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:text-xs fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}),jsxs("span",{children:["Loading proposal ",t.operationsSummary,"..."]})]});return jsxs(j,{children:[jsxs(U,{children:[r?jsx(ShieldIcon,{className:"fk:size-3.5"}):jsx(DatabaseZapIcon,{className:"fk:size-3.5"}),r?"Approval request":"Mutation approval",m?jsx(LoaderCircle,{className:"fk:ml-1 fk:size-3.5 fk:animate-spin"}):null]}),jsx("div",{className:"fk:mt-2",children:f}),t.status==="error"&&t.error?jsx("p",{className:"fk:mt-2 fk:text-xs fk:text-destructive",children:t.error.message}):null]})}function $a({data:e}){let t=useContext(Jt),a=e.questions.length>1;return jsxs(j,{children:[jsxs(U,{children:[jsx(MessageCircleQuestionIcon,{className:"fk:size-3.5"}),e.status==="pending"?a?"The agent has questions":"The agent has a question":a?"Questions":"Question"]}),jsx("div",{className:"fk:mt-3",children:jsx($t,{answer:t?.answerQuestion,data:e},e.status)})]})}function _a({message:e}){let t=e.operationsSummary.replace(/^Call /,"");return jsx(Ue,{error:e.status==="error"?e.error?.message??"The call failed.":void 0,icon:jsx(ShieldCheckIcon,{className:"fk:size-3.5"}),loading:false,message:e.status==="error"?`${t}: ${e.error?.message??"The call failed."}`:`${t} \xB7 Auto-approved by Jev`,title:"Plugin call"})}function za({message:e}){let t=[typeof e.processedItems=="number"?`${e.processedItems.toString()} processed`:"",typeof e.changedItems=="number"?`${e.changedItems.toString()} changed`:"",typeof e.failedItems=="number"?`${e.failedItems.toString()} failed`:"",typeof e.totalItems=="number"?`${e.totalItems.toString()} total`:""].filter(Boolean);return jsx(Ue,{error:e.error?.message,icon:jsx(DatabaseZapIcon,{className:"fk:size-3.5"}),loading:e.status==="loading"||e.status==="running",message:e.status==="error"?e.error?.message??`Failed bulk ${e.operationName}`:`${e.status==="done"?"Completed":"Running"} ${e.operationName}${t.length>0?` (${t.join(", ")})`:""}`,title:"Bulk GraphQL action"})}function ja({part:e}){return jsxs(j,{className:"fk:bg-muted/30",children:[jsxs(U,{children:[jsx(CheckCircle2Icon,{className:"fk:size-3.5"}),e.type.replace(/^data-/,"").replaceAll("-"," ")]}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"This run emitted a structured event that is not yet rendered by Studio."})]})}function Oa(e){if(typeof e!="number")return "";if(e<1024)return `${e.toString()} B`;let t=e/1024;return t<1024?`${t.toFixed(1)} KB`:`${(t/1024).toFixed(1)} MB`}function La(e){return e.kind==="pdf"?"PDF artifact":e.kind==="html"?"HTML artifact":"Artifact"}function Ua({pluginId:e}){let{pathname:t}=useLocation(),[a]=t.split("/ai/");return jsxs(j,{children:[jsxs("p",{className:"fk:text-sm",children:["Connect ",e," to use it in this conversation."]}),jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsxs(Link,{to:`${a}/ai/plugins/${encodeURIComponent(e)}`,children:["Connect ",e]})})]})}export{as as A,rs as B,ss as C,Ra as D,os as E,Ea as F,et as a,rn as b,ft as c,nr as d,ce as e,Nn as f,De as g,pt as h,Cn as i,Me as j,ht as k,pr as l,mr as m,kr as n,gr as o,vr as p,Pt as q,Nr as r,It as s,Cr as t,pa as u,Bt as v,Jt as w,ma as x,ns as y,Y as z};//# sourceMappingURL=chunk-Z5TZVTX3.js.map
8
+ //# sourceMappingURL=chunk-Z5TZVTX3.js.map