@flexkit/studio 0.2.29 → 0.2.30

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 (65) hide show
  1. package/dist/{chat-page-UT5M3PM3.js → chat-page-5HRMQQRO.js} +3 -3
  2. package/dist/{chat-page-UT5M3PM3.js.map → chat-page-5HRMQQRO.js.map} +1 -1
  3. package/dist/{chunk-H534S4KD.js → chunk-4TQ25SVS.js} +3 -3
  4. package/dist/{chunk-H534S4KD.js.map → chunk-4TQ25SVS.js.map} +1 -1
  5. package/dist/{chunk-FRTHKTAS.js → chunk-5D6JCGLZ.js} +2 -2
  6. package/dist/{chunk-FRTHKTAS.js.map → chunk-5D6JCGLZ.js.map} +1 -1
  7. package/dist/{chunk-ZUGTNE5M.js → chunk-6X54ZCSO.js} +2 -2
  8. package/dist/{chunk-ZUGTNE5M.js.map → chunk-6X54ZCSO.js.map} +1 -1
  9. package/dist/{chunk-7AN2E6TU.js → chunk-A6UGAPMZ.js} +2 -2
  10. package/dist/{chunk-7AN2E6TU.js.map → chunk-A6UGAPMZ.js.map} +1 -1
  11. package/dist/chunk-BQWW2Q6B.js +378 -0
  12. package/dist/chunk-BQWW2Q6B.js.map +1 -0
  13. package/dist/{chunk-BIFQCOZD.js → chunk-CR3UGX4V.js} +2 -2
  14. package/dist/{chunk-BIFQCOZD.js.map → chunk-CR3UGX4V.js.map} +1 -1
  15. package/dist/{chunk-AZG72R2F.js → chunk-E4RN4USU.js} +3 -3
  16. package/dist/{chunk-AZG72R2F.js.map → chunk-E4RN4USU.js.map} +1 -1
  17. package/dist/{chunk-BRGTUEFL.js → chunk-EC3SJ4NQ.js} +2 -2
  18. package/dist/{chunk-BRGTUEFL.js.map → chunk-EC3SJ4NQ.js.map} +1 -1
  19. package/dist/{chunk-UET5IDEW.js → chunk-K2VO74FW.js} +3 -3
  20. package/dist/{chunk-UET5IDEW.js.map → chunk-K2VO74FW.js.map} +1 -1
  21. package/dist/{chunk-6A6NT3H3.js → chunk-LBFL34FM.js} +3 -3
  22. package/dist/{chunk-6A6NT3H3.js.map → chunk-LBFL34FM.js.map} +1 -1
  23. package/dist/{chunk-D3TJCUTA.js → chunk-MNFVAW2B.js} +2 -2
  24. package/dist/{chunk-D3TJCUTA.js.map → chunk-MNFVAW2B.js.map} +1 -1
  25. package/dist/{chunk-T44KNWQD.js → chunk-WJRC5CQQ.js} +4 -4
  26. package/dist/{chunk-T44KNWQD.js.map → chunk-WJRC5CQQ.js.map} +1 -1
  27. package/dist/{chunk-BSUCDQYM.js → chunk-WPNV6WNQ.js} +3 -3
  28. package/dist/{chunk-BSUCDQYM.js.map → chunk-WPNV6WNQ.js.map} +1 -1
  29. package/dist/{entry-QGRB2B7V.js → entry-FXAA2IGV.js} +2 -2
  30. package/dist/{entry-QGRB2B7V.js.map → entry-FXAA2IGV.js.map} +1 -1
  31. package/dist/index.d.ts +4 -2
  32. package/dist/index.js +2 -2
  33. package/dist/index.js.map +1 -1
  34. package/dist/{list-OPL5OO32.js → list-DWSTP7CW.js} +2 -2
  35. package/dist/{list-OPL5OO32.js.map → list-DWSTP7CW.js.map} +1 -1
  36. package/dist/{list-L6YZSBWF.js → list-TLIH4DCX.js} +3 -3
  37. package/dist/{list-L6YZSBWF.js.map → list-TLIH4DCX.js.map} +1 -1
  38. package/dist/{pages-K4XZAMXY.js → pages-IXHYEUBL.js} +3 -3
  39. package/dist/{pages-K4XZAMXY.js.map → pages-IXHYEUBL.js.map} +1 -1
  40. package/dist/{plugin-pages-RCWAF6VC.js → plugin-pages-Q5KRARJD.js} +2 -2
  41. package/dist/{plugin-pages-RCWAF6VC.js.map → plugin-pages-Q5KRARJD.js.map} +1 -1
  42. package/dist/record-links-DSRYOOM5.js +2 -0
  43. package/dist/{record-links-R7OV4VVH.js.map → record-links-DSRYOOM5.js.map} +1 -1
  44. package/dist/{root-L6Y4PSSA.js → root-2QWOQ2AH.js} +3 -3
  45. package/dist/{root-L6Y4PSSA.js.map → root-2QWOQ2AH.js.map} +1 -1
  46. package/dist/{root-36COMEVE.js → root-IJKEEUBR.js} +2 -2
  47. package/dist/{root-36COMEVE.js.map → root-IJKEEUBR.js.map} +1 -1
  48. package/dist/{root-HETKL6EN.js → root-IKO3UPTJ.js} +2 -2
  49. package/dist/{root-HETKL6EN.js.map → root-IKO3UPTJ.js.map} +1 -1
  50. package/dist/{root-3M4DIRWC.js → root-IMTXHNCZ.js} +2 -2
  51. package/dist/{root-3M4DIRWC.js.map → root-IMTXHNCZ.js.map} +1 -1
  52. package/dist/{root-R4Y6L62R.js → root-NW5QG7W5.js} +3 -3
  53. package/dist/{root-R4Y6L62R.js.map → root-NW5QG7W5.js.map} +1 -1
  54. package/dist/{root-XMZYVO37.js → root-TERO3GWT.js} +3 -3
  55. package/dist/{root-XMZYVO37.js.map → root-TERO3GWT.js.map} +1 -1
  56. package/dist/{search-UXL3U2EH.js → search-THZV66M5.js} +2 -2
  57. package/dist/{search-UXL3U2EH.js.map → search-THZV66M5.js.map} +1 -1
  58. package/dist/{skills-pages-KEXNO6DN.js → skills-pages-D2QSG6WT.js} +2 -2
  59. package/dist/{skills-pages-KEXNO6DN.js.map → skills-pages-D2QSG6WT.js.map} +1 -1
  60. package/dist/{source-CWVJGMEZ.js → source-AH4O5WGE.js} +2 -2
  61. package/dist/{source-CWVJGMEZ.js.map → source-AH4O5WGE.js.map} +1 -1
  62. package/package.json +2 -2
  63. package/dist/chunk-RZZOOPEF.js +0 -378
  64. package/dist/chunk-RZZOOPEF.js.map +0 -1
  65. package/dist/record-links-R7OV4VVH.js +0 -2
@@ -1,2 +1,2 @@
1
- import'./index.css';import {c}from'./chunk-2DXR5NJV.js';import {f}from'./chunk-H534S4KD.js';import {g}from'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {K,M,Z,Q}from'./chunk-DGIY4SKN.js';import'./chunk-SZEGGBOC.js';import'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import'./chunk-HDOIOXMP.js';import'./chunk-USNXQOMJ.js';import'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {Outlet}from'react-router-dom';import {jsxs,jsx}from'react/jsx-runtime';function P(){let[,u]=g(),{currentProject:r}=f(),c$1=r?.schema??[],p=r?.menuGroups??[],d=c(c$1,u.user?.spaces),f$1=K();return jsxs(M,{defaultOpen:f$1,children:[jsx(Z,{schema:d,menuGroups:p}),jsx(Q,{children:jsx(Outlet,{})})]})}export{P as Root};//# sourceMappingURL=root-36COMEVE.js.map
2
- //# sourceMappingURL=root-36COMEVE.js.map
1
+ import'./index.css';import {c}from'./chunk-2DXR5NJV.js';import {f}from'./chunk-4TQ25SVS.js';import {g}from'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {K,M,Z,Q}from'./chunk-DGIY4SKN.js';import'./chunk-SZEGGBOC.js';import'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import'./chunk-HDOIOXMP.js';import'./chunk-USNXQOMJ.js';import'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {Outlet}from'react-router-dom';import {jsxs,jsx}from'react/jsx-runtime';function P(){let[,u]=g(),{currentProject:r}=f(),c$1=r?.schema??[],p=r?.menuGroups??[],d=c(c$1,u.user?.spaces),f$1=K();return jsxs(M,{defaultOpen:f$1,children:[jsx(Z,{schema:d,menuGroups:p}),jsx(Q,{children:jsx(Outlet,{})})]})}export{P as Root};//# sourceMappingURL=root-IJKEEUBR.js.map
2
+ //# sourceMappingURL=root-IJKEEUBR.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apps/desk/root.tsx"],"names":["Root","auth","useAuth","currentProject","useConfig","schema","menuGroups","visibleSchema","filterEntitiesForSpaces","defaultOpen","readSidebarCookieState","jsxs","SidebarProvider","jsx","Sidebar","SidebarInset","Outlet"],"mappings":"ydAOO,SAASA,CAAAA,EAAoB,CAClC,GAAM,EAAGC,CAAI,CAAA,CAAIC,CAAAA,EAAQ,CACnB,CAAE,cAAA,CAAAC,CAAe,EAAIC,CAAAA,EAAU,CAC/BC,GAAAA,CAASF,CAAAA,EAAgB,MAAA,EAAU,EAAC,CACpCG,CAAAA,CAAaH,GAAgB,UAAA,EAAc,EAAC,CAG5CI,CAAAA,CAAgBC,CAAAA,CAAwBH,GAAAA,CAAQJ,CAAAA,CAAK,IAAA,EAAM,MAAM,CAAA,CACjEQ,GAAAA,CAAcC,CAAAA,EAAuB,CAE3C,OACEC,IAAAA,CAACC,CAAAA,CAAA,CAAgB,YAAaH,GAAAA,CAC5B,QAAA,CAAA,CAAAI,GAAAA,CAACC,CAAAA,CAAA,CAAQ,MAAA,CAAQP,CAAAA,CAAe,UAAA,CAAYD,EAAY,CAAA,CACxDO,GAAAA,CAACE,CAAAA,CAAA,CACC,SAAAF,GAAAA,CAACG,MAAAA,CAAA,EAAO,CAAA,CACV,GACF,CAEJ","file":"root-36COMEVE.js","sourcesContent":["import { JSX } from 'react';\nimport { Outlet } from 'react-router-dom';\nimport { filterEntitiesForSpaces } from '../../core/spaces';\nimport { useAuth } from '../../auth/auth-context';\nimport { useConfig } from '../../core/config/config-context';\nimport { readSidebarCookieState, Sidebar, SidebarInset, SidebarProvider } from '../../ui';\n\nexport function Root(): JSX.Element {\n const [, auth] = useAuth();\n const { currentProject } = useConfig();\n const schema = currentProject?.schema ?? [];\n const menuGroups = currentProject?.menuGroups ?? [];\n // Space-bound entities are hidden from non-members; the generated\n // @authorization rules block their data server-side either way.\n const visibleSchema = filterEntitiesForSpaces(schema, auth.user?.spaces);\n const defaultOpen = readSidebarCookieState();\n\n return (\n <SidebarProvider defaultOpen={defaultOpen}>\n <Sidebar schema={visibleSchema} menuGroups={menuGroups} />\n <SidebarInset>\n <Outlet />\n </SidebarInset>\n </SidebarProvider>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/apps/desk/root.tsx"],"names":["Root","auth","useAuth","currentProject","useConfig","schema","menuGroups","visibleSchema","filterEntitiesForSpaces","defaultOpen","readSidebarCookieState","jsxs","SidebarProvider","jsx","Sidebar","SidebarInset","Outlet"],"mappings":"ydAOO,SAASA,CAAAA,EAAoB,CAClC,GAAM,EAAGC,CAAI,CAAA,CAAIC,CAAAA,EAAQ,CACnB,CAAE,cAAA,CAAAC,CAAe,EAAIC,CAAAA,EAAU,CAC/BC,GAAAA,CAASF,CAAAA,EAAgB,MAAA,EAAU,EAAC,CACpCG,CAAAA,CAAaH,GAAgB,UAAA,EAAc,EAAC,CAG5CI,CAAAA,CAAgBC,CAAAA,CAAwBH,GAAAA,CAAQJ,CAAAA,CAAK,IAAA,EAAM,MAAM,CAAA,CACjEQ,GAAAA,CAAcC,CAAAA,EAAuB,CAE3C,OACEC,IAAAA,CAACC,CAAAA,CAAA,CAAgB,YAAaH,GAAAA,CAC5B,QAAA,CAAA,CAAAI,GAAAA,CAACC,CAAAA,CAAA,CAAQ,MAAA,CAAQP,CAAAA,CAAe,UAAA,CAAYD,EAAY,CAAA,CACxDO,GAAAA,CAACE,CAAAA,CAAA,CACC,SAAAF,GAAAA,CAACG,MAAAA,CAAA,EAAO,CAAA,CACV,GACF,CAEJ","file":"root-IJKEEUBR.js","sourcesContent":["import { JSX } from 'react';\nimport { Outlet } from 'react-router-dom';\nimport { filterEntitiesForSpaces } from '../../core/spaces';\nimport { useAuth } from '../../auth/auth-context';\nimport { useConfig } from '../../core/config/config-context';\nimport { readSidebarCookieState, Sidebar, SidebarInset, SidebarProvider } from '../../ui';\n\nexport function Root(): JSX.Element {\n const [, auth] = useAuth();\n const { currentProject } = useConfig();\n const schema = currentProject?.schema ?? [];\n const menuGroups = currentProject?.menuGroups ?? [];\n // Space-bound entities are hidden from non-members; the generated\n // @authorization rules block their data server-side either way.\n const visibleSchema = filterEntitiesForSpaces(schema, auth.user?.spaces);\n const defaultOpen = readSidebarCookieState();\n\n return (\n <SidebarProvider defaultOpen={defaultOpen}>\n <Sidebar schema={visibleSchema} menuGroups={menuGroups} />\n <SidebarInset>\n <Outlet />\n </SidebarInset>\n </SidebarProvider>\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
- import'./index.css';import {b}from'./chunk-EMFHKTAV.js';import {f}from'./chunk-H534S4KD.js';import'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {K,M,Q}from'./chunk-DGIY4SKN.js';import'./chunk-SZEGGBOC.js';import'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import'./chunk-HDOIOXMP.js';import'./chunk-USNXQOMJ.js';import'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {Outlet}from'react-router-dom';import {jsxs,jsx}from'react/jsx-runtime';function p(){let{currentProjectId:l}=f(),m=K();return l?jsxs(M,{className:"fk:h-full",defaultOpen:m,children:[jsx(b,{}),jsx(Q,{className:"fk:min-w-0",children:jsx("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:overflow-hidden fk:pl-4 fk:pt-3",children:jsx("div",{className:"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col",children:jsx(Outlet,{})})})})]}):jsx("main",{className:"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground",children:"Select a project to manage its knowledge."})}export{p as Root};//# sourceMappingURL=root-HETKL6EN.js.map
2
- //# sourceMappingURL=root-HETKL6EN.js.map
1
+ import'./index.css';import {b}from'./chunk-EMFHKTAV.js';import {f}from'./chunk-4TQ25SVS.js';import'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {K,M,Q}from'./chunk-DGIY4SKN.js';import'./chunk-SZEGGBOC.js';import'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import'./chunk-HDOIOXMP.js';import'./chunk-USNXQOMJ.js';import'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {Outlet}from'react-router-dom';import {jsxs,jsx}from'react/jsx-runtime';function p(){let{currentProjectId:l}=f(),m=K();return l?jsxs(M,{className:"fk:h-full",defaultOpen:m,children:[jsx(b,{}),jsx(Q,{className:"fk:min-w-0",children:jsx("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:overflow-hidden fk:pl-4 fk:pt-3",children:jsx("div",{className:"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col",children:jsx(Outlet,{})})})})]}):jsx("main",{className:"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground",children:"Select a project to manage its knowledge."})}export{p as Root};//# sourceMappingURL=root-IKO3UPTJ.js.map
2
+ //# sourceMappingURL=root-IKO3UPTJ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apps/knowledge/root.tsx"],"names":["Root","currentProjectId","useConfig","defaultOpen","readSidebarCookieState","jsxs","SidebarProvider","jsx","KnowledgeSidebar","SidebarInset","Outlet"],"mappings":"+cAWO,SAASA,CAAAA,EAAoB,CAClC,GAAM,CAAE,gBAAA,CAAAC,CAAiB,CAAA,CAAIC,CAAAA,EAAU,CACjCC,CAAAA,CAAcC,CAAAA,EAAuB,CAE3C,OAAKH,CAAAA,CASHI,IAAAA,CAACC,CAAAA,CAAA,CAAgB,SAAA,CAAU,WAAA,CAAY,WAAA,CAAaH,EAClD,QAAA,CAAA,CAAAI,GAAAA,CAACC,CAAAA,CAAA,EAAiB,CAAA,CAClBD,GAAAA,CAACE,CAAAA,CAAA,CAAa,SAAA,CAAU,YAAA,CACtB,QAAA,CAAAF,GAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,wFAAA,CACb,QAAA,CAAAA,IAAC,KAAA,CAAA,CAAI,SAAA,CAAU,qDAAA,CACb,QAAA,CAAAA,GAAAA,CAACG,MAAAA,CAAA,EAAO,CAAA,CACV,CAAA,CACF,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAhBEH,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,0GAAA,CAA2G,qDAE3H,CAgBN","file":"root-HETKL6EN.js","sourcesContent":["import type { JSX } from 'react';\nimport { Outlet } from 'react-router-dom';\nimport { useConfig } from '../../core/config/config-context';\nimport { readSidebarCookieState, SidebarInset, SidebarProvider } from '../../ui';\nimport { KnowledgeSidebar } from './sidebar';\n\n/**\n * The Knowledge library: documents the team adds so people can read them and\n * the agent can search and cite them. The sidebar filters the list; the list\n * and the document pages render in the inset.\n */\nexport function Root(): JSX.Element {\n const { currentProjectId } = useConfig();\n const defaultOpen = readSidebarCookieState();\n\n if (!currentProjectId) {\n return (\n <main className=\"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground\">\n Select a project to manage its knowledge.\n </main>\n );\n }\n\n return (\n <SidebarProvider className=\"fk:h-full\" defaultOpen={defaultOpen}>\n <KnowledgeSidebar />\n <SidebarInset className=\"fk:min-w-0\">\n <div className=\"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:overflow-hidden fk:pl-4 fk:pt-3\">\n <div className=\"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col\">\n <Outlet />\n </div>\n </div>\n </SidebarInset>\n </SidebarProvider>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/apps/knowledge/root.tsx"],"names":["Root","currentProjectId","useConfig","defaultOpen","readSidebarCookieState","jsxs","SidebarProvider","jsx","KnowledgeSidebar","SidebarInset","Outlet"],"mappings":"+cAWO,SAASA,CAAAA,EAAoB,CAClC,GAAM,CAAE,gBAAA,CAAAC,CAAiB,CAAA,CAAIC,CAAAA,EAAU,CACjCC,CAAAA,CAAcC,CAAAA,EAAuB,CAE3C,OAAKH,CAAAA,CASHI,IAAAA,CAACC,CAAAA,CAAA,CAAgB,SAAA,CAAU,WAAA,CAAY,WAAA,CAAaH,EAClD,QAAA,CAAA,CAAAI,GAAAA,CAACC,CAAAA,CAAA,EAAiB,CAAA,CAClBD,GAAAA,CAACE,CAAAA,CAAA,CAAa,SAAA,CAAU,YAAA,CACtB,QAAA,CAAAF,GAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,wFAAA,CACb,QAAA,CAAAA,IAAC,KAAA,CAAA,CAAI,SAAA,CAAU,qDAAA,CACb,QAAA,CAAAA,GAAAA,CAACG,MAAAA,CAAA,EAAO,CAAA,CACV,CAAA,CACF,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAhBEH,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,0GAAA,CAA2G,qDAE3H,CAgBN","file":"root-IKO3UPTJ.js","sourcesContent":["import type { JSX } from 'react';\nimport { Outlet } from 'react-router-dom';\nimport { useConfig } from '../../core/config/config-context';\nimport { readSidebarCookieState, SidebarInset, SidebarProvider } from '../../ui';\nimport { KnowledgeSidebar } from './sidebar';\n\n/**\n * The Knowledge library: documents the team adds so people can read them and\n * the agent can search and cite them. The sidebar filters the list; the list\n * and the document pages render in the inset.\n */\nexport function Root(): JSX.Element {\n const { currentProjectId } = useConfig();\n const defaultOpen = readSidebarCookieState();\n\n if (!currentProjectId) {\n return (\n <main className=\"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground\">\n Select a project to manage its knowledge.\n </main>\n );\n }\n\n return (\n <SidebarProvider className=\"fk:h-full\" defaultOpen={defaultOpen}>\n <KnowledgeSidebar />\n <SidebarInset className=\"fk:min-w-0\">\n <div className=\"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:overflow-hidden fk:pl-4 fk:pt-3\">\n <div className=\"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col\">\n <Outlet />\n </div>\n </div>\n </SidebarInset>\n </SidebarProvider>\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
- import'./index.css';import {b,c}from'./chunk-ZUGTNE5M.js';import'./chunk-T44KNWQD.js';import {a}from'./chunk-ERCVR23U.js';import'./chunk-QSTWBKPN.js';import'./chunk-5LGIALCK.js';import {g,f as f$1}from'./chunk-U6VZY3V2.js';import'./chunk-D3TJCUTA.js';import'./chunk-2NXQF2F7.js';import'./chunk-V7C4EHK3.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import {f}from'./chunk-H534S4KD.js';import'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {K,M,Q,N,S,U as U$1,s as s$1,R,V as V$1,W,X,P}from'./chunk-DGIY4SKN.js';import'./chunk-SZEGGBOC.js';import {b as b$1}from'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import'./chunk-HDOIOXMP.js';import'./chunk-USNXQOMJ.js';import'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {Outlet,useLocation,NavLink}from'react-router-dom';import {useState}from'react';import {SearchIcon,XIcon,SquarePenIcon,BellIcon,BotIcon,HistoryIcon,InboxIcon,PlugIcon}from'lucide-react';import T from'swr';import {jsxs,jsx}from'react/jsx-runtime';var U=300,s=NavLink;function V(){let{currentProjectId:a}=f(),{data:e}=T(a?g(a).approvalsCount:null,f$1,{refreshInterval:3e4}),n=e?.pendingCount??0;return n===0?null:jsx(b$1,{className:"fk:ml-auto fk:h-5 fk:min-w-5 fk:justify-center fk:rounded-full fk:bg-amber-500/20 fk:px-1.5 fk:text-[0.6875rem] fk:text-amber-600 fk:border-none fk:corner-squircle",children:n>99?"99+":n.toString()})}function F(){let{currentProjectId:a$1}=f(),e=a(a$1),n=e?.needsActionCount??0,l=n>0?n:e?.unreadCount??0;return l===0?null:jsx(b$1,{className:`fk:ml-auto fk:h-5 fk:min-w-5 fk:justify-center fk:rounded-full fk:px-1.5 fk:text-[0.6875rem] fk:border-none fk:corner-squircle ${n>0?"fk:bg-amber-500/20 fk:text-amber-600":"fk:bg-muted fk:text-muted-foreground"}`,children:l>99?"99+":l.toString()})}function B(){let e=useLocation().pathname.replace(/\/$/,""),n=e.endsWith("/ai/agent"),l=e.endsWith("/ai/runs"),P$1=e.endsWith("/ai/approvals"),R$1=e.endsWith("/ai/activity")||e.includes("/ai/activity/"),W$1=e.includes("/ai/plugins")||e.includes("/ai/skills"),L=e.includes("/ai/automations"),[d,k]=useState(""),E=b(d.trim(),U);return jsxs(N,{collapsible:"icon",variant:"inset",children:[jsx(S,{className:"fk:shrink-0 fk:pb-1.5 fk:group-data-[collapsible=icon]:hidden",children:jsxs(U$1,{className:"fk:relative",children:[jsx(SearchIcon,{className:"fk:absolute fk:left-2 fk:top-1/2 fk:size-3.5 fk:-translate-y-1/2 fk:text-muted-foreground"}),jsx(s$1,{className:"fk:h-8 fk:bg-background fk:pl-7 fk:pr-7 fk:text-sm",placeholder:"Search chats...",value:d,onChange:G=>k(G.target.value)}),d?jsx("button",{"aria-label":"Clear search",className:"fk:absolute fk:right-2 fk:top-1/2 fk:-translate-y-1/2 fk:cursor-pointer fk:text-muted-foreground fk:hover:text-foreground",type:"button",onClick:()=>k(""),children:jsx(XIcon,{className:"fk:size-3.5"})}):null]})}),jsxs(R,{children:[jsx(S,{children:jsxs(V$1,{children:[jsx(W,{children:jsx(X,{asChild:true,isActive:n,tooltip:"New chat",children:jsxs(s,{to:"agent",children:[jsx(SquarePenIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"New chat"})]})})}),jsx(W,{children:jsx(X,{asChild:true,isActive:R$1,tooltip:"Activity",children:jsxs(s,{to:"activity",children:[jsx(BellIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Activity"}),jsx(F,{})]})})}),jsx(W,{children:jsx(X,{asChild:true,isActive:L,tooltip:"Automations",children:jsxs(s,{to:"automations",children:[jsx(BotIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Automations"})]})})}),jsx(W,{children:jsx(X,{asChild:true,isActive:l,tooltip:"Run History",children:jsxs(s,{to:"runs",children:[jsx(HistoryIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Run History"})]})})}),jsx(W,{children:jsx(X,{asChild:true,isActive:P$1,tooltip:"Approvals",children:jsxs(s,{to:"approvals",children:[jsx(InboxIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Approvals"}),jsx(V,{})]})})}),jsx(W,{children:jsx(X,{asChild:true,isActive:W$1,tooltip:"Plugins",children:jsxs(s,{to:"plugins",children:[jsx(PlugIcon,{className:"fk:size-4"}),jsx("span",{children:"Plugins"})]})})})]})}),jsx(S,{className:"fk:mt-4 fk:group-data-[collapsible=icon]:hidden",children:jsx(U$1,{children:jsx(c,{query:E})})})]}),jsx(P,{})]})}function pt(){let{currentProjectId:a}=f(),e=K();return a?jsxs(M,{className:"fk:h-full",defaultOpen:e,children:[jsx(B,{}),jsx(Q,{className:"fk:min-w-0",children:jsx("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:overflow-hidden fk:pl-4 fk:pt-3",children:jsx("div",{className:"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col",children:jsx(Outlet,{})})})})]}):jsx("main",{className:"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground",children:"Select a project to manage automations and skills."})}export{pt as Root};//# sourceMappingURL=root-3M4DIRWC.js.map
2
- //# sourceMappingURL=root-3M4DIRWC.js.map
1
+ import'./index.css';import {b,c}from'./chunk-6X54ZCSO.js';import'./chunk-WJRC5CQQ.js';import {a}from'./chunk-ERCVR23U.js';import'./chunk-QSTWBKPN.js';import'./chunk-5LGIALCK.js';import {g,f as f$1}from'./chunk-U6VZY3V2.js';import'./chunk-MNFVAW2B.js';import'./chunk-2NXQF2F7.js';import'./chunk-V7C4EHK3.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import {f}from'./chunk-4TQ25SVS.js';import'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {K,M,Q,N,S,U as U$1,s as s$1,R,V as V$1,W,X,P}from'./chunk-DGIY4SKN.js';import'./chunk-SZEGGBOC.js';import {b as b$1}from'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import'./chunk-HDOIOXMP.js';import'./chunk-USNXQOMJ.js';import'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {Outlet,useLocation,NavLink}from'react-router-dom';import {useState}from'react';import {SearchIcon,XIcon,SquarePenIcon,BellIcon,BotIcon,HistoryIcon,InboxIcon,PlugIcon}from'lucide-react';import T from'swr';import {jsxs,jsx}from'react/jsx-runtime';var U=300,s=NavLink;function V(){let{currentProjectId:a}=f(),{data:e}=T(a?g(a).approvalsCount:null,f$1,{refreshInterval:3e4}),n=e?.pendingCount??0;return n===0?null:jsx(b$1,{className:"fk:ml-auto fk:h-5 fk:min-w-5 fk:justify-center fk:rounded-full fk:bg-amber-500/20 fk:px-1.5 fk:text-[0.6875rem] fk:text-amber-600 fk:border-none fk:corner-squircle",children:n>99?"99+":n.toString()})}function F(){let{currentProjectId:a$1}=f(),e=a(a$1),n=e?.needsActionCount??0,l=n>0?n:e?.unreadCount??0;return l===0?null:jsx(b$1,{className:`fk:ml-auto fk:h-5 fk:min-w-5 fk:justify-center fk:rounded-full fk:px-1.5 fk:text-[0.6875rem] fk:border-none fk:corner-squircle ${n>0?"fk:bg-amber-500/20 fk:text-amber-600":"fk:bg-muted fk:text-muted-foreground"}`,children:l>99?"99+":l.toString()})}function B(){let e=useLocation().pathname.replace(/\/$/,""),n=e.endsWith("/ai/agent"),l=e.endsWith("/ai/runs"),P$1=e.endsWith("/ai/approvals"),R$1=e.endsWith("/ai/activity")||e.includes("/ai/activity/"),W$1=e.includes("/ai/plugins")||e.includes("/ai/skills"),L=e.includes("/ai/automations"),[d,k]=useState(""),E=b(d.trim(),U);return jsxs(N,{collapsible:"icon",variant:"inset",children:[jsx(S,{className:"fk:shrink-0 fk:pb-1.5 fk:group-data-[collapsible=icon]:hidden",children:jsxs(U$1,{className:"fk:relative",children:[jsx(SearchIcon,{className:"fk:absolute fk:left-2 fk:top-1/2 fk:size-3.5 fk:-translate-y-1/2 fk:text-muted-foreground"}),jsx(s$1,{className:"fk:h-8 fk:bg-background fk:pl-7 fk:pr-7 fk:text-sm",placeholder:"Search chats...",value:d,onChange:G=>k(G.target.value)}),d?jsx("button",{"aria-label":"Clear search",className:"fk:absolute fk:right-2 fk:top-1/2 fk:-translate-y-1/2 fk:cursor-pointer fk:text-muted-foreground fk:hover:text-foreground",type:"button",onClick:()=>k(""),children:jsx(XIcon,{className:"fk:size-3.5"})}):null]})}),jsxs(R,{children:[jsx(S,{children:jsxs(V$1,{children:[jsx(W,{children:jsx(X,{asChild:true,isActive:n,tooltip:"New chat",children:jsxs(s,{to:"agent",children:[jsx(SquarePenIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"New chat"})]})})}),jsx(W,{children:jsx(X,{asChild:true,isActive:R$1,tooltip:"Activity",children:jsxs(s,{to:"activity",children:[jsx(BellIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Activity"}),jsx(F,{})]})})}),jsx(W,{children:jsx(X,{asChild:true,isActive:L,tooltip:"Automations",children:jsxs(s,{to:"automations",children:[jsx(BotIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Automations"})]})})}),jsx(W,{children:jsx(X,{asChild:true,isActive:l,tooltip:"Run History",children:jsxs(s,{to:"runs",children:[jsx(HistoryIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Run History"})]})})}),jsx(W,{children:jsx(X,{asChild:true,isActive:P$1,tooltip:"Approvals",children:jsxs(s,{to:"approvals",children:[jsx(InboxIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Approvals"}),jsx(V,{})]})})}),jsx(W,{children:jsx(X,{asChild:true,isActive:W$1,tooltip:"Plugins",children:jsxs(s,{to:"plugins",children:[jsx(PlugIcon,{className:"fk:size-4"}),jsx("span",{children:"Plugins"})]})})})]})}),jsx(S,{className:"fk:mt-4 fk:group-data-[collapsible=icon]:hidden",children:jsx(U$1,{children:jsx(c,{query:E})})})]}),jsx(P,{})]})}function pt(){let{currentProjectId:a}=f(),e=K();return a?jsxs(M,{className:"fk:h-full",defaultOpen:e,children:[jsx(B,{}),jsx(Q,{className:"fk:min-w-0",children:jsx("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:overflow-hidden fk:pl-4 fk:pt-3",children:jsx("div",{className:"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col",children:jsx(Outlet,{})})})})]}):jsx("main",{className:"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground",children:"Select a project to manage automations and skills."})}export{pt as Root};//# sourceMappingURL=root-IMTXHNCZ.js.map
2
+ //# sourceMappingURL=root-IMTXHNCZ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apps/ai/sidebar.tsx","../src/apps/ai/root.tsx"],"names":["SEARCH_DEBOUNCE_MS","NavLinkCompat","NavLink","PendingApprovalsBadge","currentProjectId","useConfig","data","useSWR","paths","fetcher","pendingCount","jsx","Badge","ActivityBadge","useActivitySummary","needsAction","count","AutomationsSidebar","pathname","useLocation","isNewChat","isRunHistory","isApprovals","isActivity","isPlugins","isAutomations","query","setQuery","useState","debouncedQuery","useDebouncedValue","jsxs","Sidebar","SidebarGroup","SidebarGroupContent","SearchIcon","Input","event","XIcon","SidebarContent","SidebarMenu","SidebarMenuItem","SidebarMenuButton","SquarePenIcon","BellIcon","BotIcon","HistoryIcon","InboxIcon","PlugIcon","AgentChatsSection","SidebarRail","Root","defaultOpen","readSidebarCookieState","SidebarProvider","SidebarInset","Outlet"],"mappings":"s+BAuBA,IAAMA,CAAAA,CAAqB,IAErBC,CAAAA,CAAgBC,OAAAA,CAKtB,SAASC,CAAAA,EAA4C,CACnD,GAAM,CAAE,gBAAA,CAAAC,CAAiB,CAAA,CAAIC,CAAAA,EAAU,CACjC,CAAE,IAAA,CAAAC,CA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WC.js","sourcesContent":["import type { JSX } from 'react';\nimport { useState } from 'react';\nimport { BellIcon, BotIcon, PlugIcon, HistoryIcon, InboxIcon, SearchIcon, SquarePenIcon, XIcon } from 'lucide-react';\nimport { NavLink, useLocation } from 'react-router-dom';\nimport useSWR from 'swr';\nimport { useConfig } from '../../core/config/config-context';\nimport {\n Badge,\n Input,\n SidebarContent,\n SidebarGroup,\n SidebarGroupContent,\n SidebarMenu,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarPanel,\n SidebarRail,\n} from '../../ui';\nimport { fetcher, paths } from './api';\nimport { useActivitySummary } from './activity-nav-button';\nimport { AgentChatsSection, useDebouncedValue } from './agent/chat-list';\nimport type { AutomationApprovals } from './types';\n\nconst SEARCH_DEBOUNCE_MS = 300;\n\nconst NavLinkCompat = NavLink as unknown as React.ComponentType<{\n children?: React.ReactNode;\n to: string;\n}>;\n\nfunction PendingApprovalsBadge(): JSX.Element | null {\n const { currentProjectId } = useConfig();\n const { data } = useSWR<AutomationApprovals>(\n currentProjectId ? paths(currentProjectId).approvalsCount : null,\n fetcher,\n { refreshInterval: 30_000 }\n );\n const pendingCount = data?.pendingCount ?? 0;\n\n if (pendingCount === 0) {\n return null;\n }\n\n return (\n <Badge className=\"fk:ml-auto fk:h-5 fk:min-w-5 fk:justify-center fk:rounded-full fk:bg-amber-500/20 fk:px-1.5 fk:text-[0.6875rem] fk:text-amber-600 fk:border-none fk:corner-squircle\">\n {pendingCount > 99 ? '99+' : pendingCount.toString()}\n </Badge>\n );\n}\n\n/** Open items that wait on the viewer; falls back to the unread count when nothing waits. */\nfunction ActivityBadge(): JSX.Element | null {\n const { currentProjectId } = useConfig();\n const data = useActivitySummary(currentProjectId);\n const needsAction = data?.needsActionCount ?? 0;\n const count = needsAction > 0 ? needsAction : (data?.unreadCount ?? 0);\n\n if (count === 0) {\n return null;\n }\n\n return (\n <Badge\n className={`fk:ml-auto fk:h-5 fk:min-w-5 fk:justify-center fk:rounded-full fk:px-1.5 fk:text-[0.6875rem] fk:border-none fk:corner-squircle ${\n needsAction > 0 ? 'fk:bg-amber-500/20 fk:text-amber-600' : 'fk:bg-muted fk:text-muted-foreground'\n }`}\n >\n {count > 99 ? '99+' : count.toString()}\n </Badge>\n );\n}\n\nexport function AutomationsSidebar(): JSX.Element {\n const location = useLocation();\n const pathname = location.pathname.replace(/\\/$/, '');\n const isNewChat = pathname.endsWith('/ai/agent');\n const isRunHistory = pathname.endsWith('/ai/runs');\n const isApprovals = pathname.endsWith('/ai/approvals');\n const isActivity = pathname.endsWith('/ai/activity') || pathname.includes('/ai/activity/');\n const isPlugins = pathname.includes('/ai/plugins') || pathname.includes('/ai/skills');\n const isAutomations = pathname.includes('/ai/automations');\n const [query, setQuery] = useState('');\n const debouncedQuery = useDebouncedValue(query.trim(), SEARCH_DEBOUNCE_MS);\n\n return (\n <SidebarPanel collapsible=\"icon\" variant=\"inset\">\n <SidebarGroup className=\"fk:shrink-0 fk:pb-1.5 fk:group-data-[collapsible=icon]:hidden\">\n <SidebarGroupContent className=\"fk:relative\">\n <SearchIcon className=\"fk:absolute fk:left-2 fk:top-1/2 fk:size-3.5 fk:-translate-y-1/2 fk:text-muted-foreground\" />\n <Input\n className=\"fk:h-8 fk:bg-background fk:pl-7 fk:pr-7 fk:text-sm\"\n placeholder=\"Search chats...\"\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n />\n {query ? (\n <button\n aria-label=\"Clear search\"\n className=\"fk:absolute fk:right-2 fk:top-1/2 fk:-translate-y-1/2 fk:cursor-pointer fk:text-muted-foreground fk:hover:text-foreground\"\n type=\"button\"\n onClick={() => setQuery('')}\n >\n <XIcon className=\"fk:size-3.5\" />\n </button>\n ) : null}\n </SidebarGroupContent>\n </SidebarGroup>\n <SidebarContent>\n <SidebarGroup>\n <SidebarMenu>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isNewChat} tooltip=\"New chat\">\n <NavLinkCompat to=\"agent\">\n <SquarePenIcon className=\"fk:h-4 fk:w-4\" strokeWidth={2} />\n <span>New chat</span>\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isActivity} tooltip=\"Activity\">\n <NavLinkCompat to=\"activity\">\n <BellIcon className=\"fk:h-4 fk:w-4\" strokeWidth={2} />\n <span>Activity</span>\n <ActivityBadge />\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isAutomations} tooltip=\"Automations\">\n <NavLinkCompat to=\"automations\">\n <BotIcon className=\"fk:h-4 fk:w-4\" strokeWidth={2} />\n <span>Automations</span>\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isRunHistory} tooltip=\"Run History\">\n <NavLinkCompat to=\"runs\">\n <HistoryIcon className=\"fk:h-4 fk:w-4\" strokeWidth={2} />\n <span>Run History</span>\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isApprovals} tooltip=\"Approvals\">\n <NavLinkCompat to=\"approvals\">\n <InboxIcon className=\"fk:h-4 fk:w-4\" strokeWidth={2} />\n <span>Approvals</span>\n <PendingApprovalsBadge />\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isPlugins} tooltip=\"Plugins\">\n <NavLinkCompat to=\"plugins\">\n <PlugIcon className=\"fk:size-4\" />\n <span>Plugins</span>\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n </SidebarMenu>\n </SidebarGroup>\n <SidebarGroup className=\"fk:mt-4 fk:group-data-[collapsible=icon]:hidden\">\n <SidebarGroupContent>\n <AgentChatsSection query={debouncedQuery} />\n </SidebarGroupContent>\n </SidebarGroup>\n </SidebarContent>\n <SidebarRail />\n </SidebarPanel>\n );\n}\n","import type { JSX } from 'react';\nimport { Outlet } from 'react-router-dom';\nimport { useConfig } from '../../core/config/config-context';\nimport { readSidebarCookieState, SidebarInset, SidebarProvider } from '../../ui';\nimport { AutomationsSidebar } from './sidebar';\n\nexport function Root(): JSX.Element {\n const { currentProjectId } = useConfig();\n const defaultOpen = readSidebarCookieState();\n\n if (!currentProjectId) {\n return (\n <main className=\"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground\">\n Select a project to manage automations and skills.\n </main>\n );\n }\n\n return (\n <SidebarProvider className=\"fk:h-full\" defaultOpen={defaultOpen}>\n <AutomationsSidebar />\n <SidebarInset className=\"fk:min-w-0\">\n <div className=\"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:overflow-hidden fk:pl-4 fk:pt-3\">\n <div className=\"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col\">\n <Outlet />\n </div>\n </div>\n </SidebarInset>\n </SidebarProvider>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/apps/ai/sidebar.tsx","../src/apps/ai/root.tsx"],"names":["SEARCH_DEBOUNCE_MS","NavLinkCompat","NavLink","PendingApprovalsBadge","currentProjectId","useConfig","data","useSWR","paths","fetcher","pendingCount","jsx","Badge","ActivityBadge","useActivitySummary","needsAction","count","AutomationsSidebar","pathname","useLocation","isNewChat","isRunHistory","isApprovals","isActivity","isPlugins","isAutomations","query","setQuery","useState","debouncedQuery","useDebouncedValue","jsxs","Sidebar","SidebarGroup","SidebarGroupContent","SearchIcon","Input","event","XIcon","SidebarContent","SidebarMenu","SidebarMenuItem","SidebarMenuButton","SquarePenIcon","BellIcon","BotIcon","HistoryIcon","InboxIcon","PlugIcon","AgentChatsSection","SidebarRail","Root","defaultOpen","readSidebarCookieState","SidebarProvider","SidebarInset","Outlet"],"mappings":"s+BAuBA,IAAMA,CAAAA,CAAqB,IAErBC,CAAAA,CAAgBC,OAAAA,CAKtB,SAASC,CAAAA,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CACF,EAhBE7C,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,0GAAA,CAA2G,8DAE3H,CAgBN","file":"root-IMTXHNCZ.js","sourcesContent":["import type { JSX } from 'react';\nimport { useState } from 'react';\nimport { BellIcon, BotIcon, PlugIcon, HistoryIcon, InboxIcon, SearchIcon, SquarePenIcon, XIcon } from 'lucide-react';\nimport { NavLink, useLocation } from 'react-router-dom';\nimport useSWR from 'swr';\nimport { useConfig } from '../../core/config/config-context';\nimport {\n Badge,\n Input,\n SidebarContent,\n SidebarGroup,\n SidebarGroupContent,\n SidebarMenu,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarPanel,\n SidebarRail,\n} from '../../ui';\nimport { fetcher, paths } from './api';\nimport { useActivitySummary } from './activity-nav-button';\nimport { AgentChatsSection, useDebouncedValue } from './agent/chat-list';\nimport type { AutomationApprovals } from './types';\n\nconst SEARCH_DEBOUNCE_MS = 300;\n\nconst NavLinkCompat = NavLink as unknown as React.ComponentType<{\n children?: React.ReactNode;\n to: string;\n}>;\n\nfunction PendingApprovalsBadge(): JSX.Element | null {\n const { currentProjectId } = useConfig();\n const { data } = useSWR<AutomationApprovals>(\n currentProjectId ? paths(currentProjectId).approvalsCount : null,\n fetcher,\n { refreshInterval: 30_000 }\n );\n const pendingCount = data?.pendingCount ?? 0;\n\n if (pendingCount === 0) {\n return null;\n }\n\n return (\n <Badge className=\"fk:ml-auto fk:h-5 fk:min-w-5 fk:justify-center fk:rounded-full fk:bg-amber-500/20 fk:px-1.5 fk:text-[0.6875rem] fk:text-amber-600 fk:border-none fk:corner-squircle\">\n {pendingCount > 99 ? '99+' : pendingCount.toString()}\n </Badge>\n );\n}\n\n/** Open items that wait on the viewer; falls back to the unread count when nothing waits. */\nfunction ActivityBadge(): JSX.Element | null {\n const { currentProjectId } = useConfig();\n const data = useActivitySummary(currentProjectId);\n const needsAction = data?.needsActionCount ?? 0;\n const count = needsAction > 0 ? needsAction : (data?.unreadCount ?? 0);\n\n if (count === 0) {\n return null;\n }\n\n return (\n <Badge\n className={`fk:ml-auto fk:h-5 fk:min-w-5 fk:justify-center fk:rounded-full fk:px-1.5 fk:text-[0.6875rem] fk:border-none fk:corner-squircle ${\n needsAction > 0 ? 'fk:bg-amber-500/20 fk:text-amber-600' : 'fk:bg-muted fk:text-muted-foreground'\n }`}\n >\n {count > 99 ? '99+' : count.toString()}\n </Badge>\n );\n}\n\nexport function AutomationsSidebar(): JSX.Element {\n const location = useLocation();\n const pathname = location.pathname.replace(/\\/$/, '');\n const isNewChat = pathname.endsWith('/ai/agent');\n const isRunHistory = pathname.endsWith('/ai/runs');\n const isApprovals = pathname.endsWith('/ai/approvals');\n const isActivity = pathname.endsWith('/ai/activity') || pathname.includes('/ai/activity/');\n const isPlugins = pathname.includes('/ai/plugins') || pathname.includes('/ai/skills');\n const isAutomations = pathname.includes('/ai/automations');\n const [query, setQuery] = useState('');\n const debouncedQuery = useDebouncedValue(query.trim(), SEARCH_DEBOUNCE_MS);\n\n return (\n <SidebarPanel collapsible=\"icon\" variant=\"inset\">\n <SidebarGroup className=\"fk:shrink-0 fk:pb-1.5 fk:group-data-[collapsible=icon]:hidden\">\n <SidebarGroupContent className=\"fk:relative\">\n <SearchIcon className=\"fk:absolute fk:left-2 fk:top-1/2 fk:size-3.5 fk:-translate-y-1/2 fk:text-muted-foreground\" />\n <Input\n className=\"fk:h-8 fk:bg-background fk:pl-7 fk:pr-7 fk:text-sm\"\n placeholder=\"Search chats...\"\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n />\n {query ? (\n <button\n aria-label=\"Clear search\"\n className=\"fk:absolute fk:right-2 fk:top-1/2 fk:-translate-y-1/2 fk:cursor-pointer fk:text-muted-foreground fk:hover:text-foreground\"\n type=\"button\"\n onClick={() => setQuery('')}\n >\n <XIcon className=\"fk:size-3.5\" />\n </button>\n ) : null}\n </SidebarGroupContent>\n </SidebarGroup>\n <SidebarContent>\n <SidebarGroup>\n <SidebarMenu>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isNewChat} tooltip=\"New chat\">\n <NavLinkCompat to=\"agent\">\n <SquarePenIcon className=\"fk:h-4 fk:w-4\" strokeWidth={2} />\n <span>New chat</span>\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isActivity} tooltip=\"Activity\">\n <NavLinkCompat to=\"activity\">\n <BellIcon className=\"fk:h-4 fk:w-4\" strokeWidth={2} />\n <span>Activity</span>\n <ActivityBadge />\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isAutomations} tooltip=\"Automations\">\n <NavLinkCompat to=\"automations\">\n <BotIcon className=\"fk:h-4 fk:w-4\" strokeWidth={2} />\n <span>Automations</span>\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isRunHistory} tooltip=\"Run History\">\n <NavLinkCompat to=\"runs\">\n <HistoryIcon className=\"fk:h-4 fk:w-4\" strokeWidth={2} />\n <span>Run History</span>\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isApprovals} tooltip=\"Approvals\">\n <NavLinkCompat to=\"approvals\">\n <InboxIcon className=\"fk:h-4 fk:w-4\" strokeWidth={2} />\n <span>Approvals</span>\n <PendingApprovalsBadge />\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton asChild isActive={isPlugins} tooltip=\"Plugins\">\n <NavLinkCompat to=\"plugins\">\n <PlugIcon className=\"fk:size-4\" />\n <span>Plugins</span>\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n </SidebarMenu>\n </SidebarGroup>\n <SidebarGroup className=\"fk:mt-4 fk:group-data-[collapsible=icon]:hidden\">\n <SidebarGroupContent>\n <AgentChatsSection query={debouncedQuery} />\n </SidebarGroupContent>\n </SidebarGroup>\n </SidebarContent>\n <SidebarRail />\n </SidebarPanel>\n );\n}\n","import type { JSX } from 'react';\nimport { Outlet } from 'react-router-dom';\nimport { useConfig } from '../../core/config/config-context';\nimport { readSidebarCookieState, SidebarInset, SidebarProvider } from '../../ui';\nimport { AutomationsSidebar } from './sidebar';\n\nexport function Root(): JSX.Element {\n const { currentProjectId } = useConfig();\n const defaultOpen = readSidebarCookieState();\n\n if (!currentProjectId) {\n return (\n <main className=\"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground\">\n Select a project to manage automations and skills.\n </main>\n );\n }\n\n return (\n <SidebarProvider className=\"fk:h-full\" defaultOpen={defaultOpen}>\n <AutomationsSidebar />\n <SidebarInset className=\"fk:min-w-0\">\n <div className=\"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:overflow-hidden fk:pl-4 fk:pt-3\">\n <div className=\"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col\">\n <Outlet />\n </div>\n </div>\n </SidebarInset>\n </SidebarProvider>\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- import'./index.css';import {a as a$3,b as b$5}from'./chunk-MLHXPTBT.js';import {b as b$4,c as c$3}from'./chunk-ELOJGLAR.js';import {e}from'./chunk-UET5IDEW.js';import {a as a$1}from'./chunk-BRGTUEFL.js';import {f as f$1,i,g as g$1,y,k,b as b$1,e as e$2,l,w,v,d,a,m,h,p,n,o as o$2,s as s$2,c as c$4,q as q$1,r as r$1,j as j$2,u,t}from'./chunk-4PUMSUJL.js';import {c as c$1}from'./chunk-2DXR5NJV.js';import {j,f as f$2}from'./chunk-6A6NT3H3.js';import {c}from'./chunk-XMOSCJOI.js';import'./chunk-HKN6BX5U.js';import'./chunk-YDVO6XWD.js';import {a as a$2}from'./chunk-ERDARDGB.js';import {f}from'./chunk-H534S4KD.js';import {g}from'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {K,M,Q,O,qa,N,R,S,s,T,V,W,X,o,P,ha,ia,ja,ka,e as e$4,$,aa,da,ea,ba,fa}from'./chunk-DGIY4SKN.js';import {e as e$3,g as g$2,h as h$1,j as j$1,q,r,s as s$1,o as o$1}from'./chunk-SZEGGBOC.js';import {v as v$1}from'./chunk-32ZU4MLE.js';import {b}from'./chunk-U45E5X3H.js';import'./chunk-HDOIOXMP.js';import {b as b$2,c as c$2,e as e$1}from'./chunk-USNXQOMJ.js';import {b as b$3}from'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {useEffect,useMemo,useRef,useState,useCallback,useReducer}from'react';import {useLocation}from'react-router-dom';import On from'graphology';import qn from'graphology-layout-forceatlas2';import Qn from'graphology-layout-forceatlas2/worker';import zn,{DEFAULT_STYLES}from'sigma';import {jsxs,jsx}from'react/jsx-runtime';import {gql}from'@apollo/client';import {useApolloClient,useQuery}from'@apollo/client/react';import {formatDistance}from'date-fns';import {SearchIcon,ChevronDownIcon,LoaderCircleIcon,PlayIcon,ScanIcon,ExpandIcon,EyeOffIcon,EraserIcon,XIcon,SquareArrowOutUpRightIcon}from'lucide-react';import {closeBrackets,closeBracketsKeymap}from'@codemirror/autocomplete';import {history,defaultKeymap,historyKeymap,indentWithTab}from'@codemirror/commands';import {foldGutter,indentOnInput,bracketMatching,foldKeymap}from'@codemirror/language';import {Compartment,EditorState,Prec}from'@codemirror/state';import {EditorView,lineNumbers,highlightActiveLineGutter,highlightSpecialChars,drawSelection,dropCursor,highlightActiveLine,keymap,placeholder}from'@codemirror/view';import {graphql,updateSchema}from'cm6-graphql';import {getIntrospectionQuery,buildClientSchema}from'graphql';import {useDebounce}from'use-debounce';function Ae(e){return Math.min(2e4,2e3+e*9)}function Zt({mean:e,max:t,diagonal:n}){let r=Math.max(.05,n*.0015);return e<r&&t<r*20}var Hn=40,jn=400,Bn=1200,Xn=2;function Fn(e){return 5+Math.min(10,Math.sqrt(e)*2)}function nn(e){return Hn*(.8+Math.sqrt(e)*.6)}function rn(e,t,n){let r=Math.random()*Math.PI*2;return Array.from({length:t},(i,s)=>{let o=r+s/t*Math.PI*2+Math.random()*.3,d=n*(.9+Math.random()*.2);return {x:e.x+Math.cos(o)*d,y:e.y+Math.sin(o)*d}})}function on(e,t){return !Number.isNaN(e.getNodeAttribute(t,"x"))}function $n(e,t){if(t.length===0)return {center:{x:0,y:0},reach:0};let n=t.reduce((i,s)=>({x:i.x+e.getNodeAttribute(s,"x"),y:i.y+e.getNodeAttribute(s,"y")}),{x:0,y:0});n.x/=t.length,n.y/=t.length;let r=t.reduce((i,s)=>Math.max(i,Math.hypot(e.getNodeAttribute(s,"x")-n.x,e.getNodeAttribute(s,"y")-n.y)),0);return {center:n,reach:r}}function Jn(e,t){let n=new Map;t.forEach(r=>{let i=e.neighbors(r).find(s=>!t.has(s)&&on(e,s))??null;n.set(i,[...n.get(i)??[],r]);}),n.forEach((r,i)=>{let s;if(i){let o={x:e.getNodeAttribute(i,"x"),y:e.getNodeAttribute(i,"y")};s=rn(o,r.length,nn(r.length));}else {let o=e.nodes().filter(S=>!t.has(S)&&on(e,S)),d=$n(e,o);s=rn(d.center,r.length,d.reach+nn(r.length));}s.forEach((o,d)=>e.mergeNodeAttributes(r[d],o));});}var Ke=class{constructor(t){this.graph=t;this.positions=new Float64Array(t.order*2);let n=0;this.graph.forEachNode((r,i)=>{this.positions[n]=i.x,this.positions[n+1]=i.y,n+=2;});}positions;measure(){let{graph:t,positions:n}=this,r=0,i=0,s=0,o=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,S=Number.NEGATIVE_INFINITY,T=Number.NEGATIVE_INFINITY,y=0;return t.forEachNode((c,a)=>{let{x:h,y:g}=a;if(y+1<n.length&&!a.fixed){let N=Math.hypot(h-n[y],g-n[y+1]);r+=N,i=Math.max(i,N),s+=1;}n[y]=h,n[y+1]=g,y+=2,o=Math.min(o,h),d=Math.min(d,g),S=Math.max(S,h),T=Math.max(T,g);}),{mean:s>0?r/s:0,max:i,diagonal:t.order>0?Math.hypot(S-o,T-d):0}}};function Yn(e,t,n){let r=false,i=new Set,s=e.order>0;return e.forEachNode(o=>{t.nodes[o]||(e.dropNode(o),r=true);}),Object.values(t.nodes).forEach(o=>{if(e.hasNode(o.key)){e.getNodeAttribute(o.key,"label")!==o.label&&e.setNodeAttribute(o.key,"label",o.label);return}e.addNode(o.key,{entity:o.entity,label:o.label,color:n[o.entity]??"#71717a",size:5,x:Number.NaN,y:Number.NaN}),i.add(o.key),r=true;}),e.forEachEdge(o=>{t.edges[o]||(e.dropEdge(o),r=true);}),Object.values(t.edges).forEach(o=>{e.hasEdge(o.key)||(e.addEdgeWithKey(o.key,o.source,o.target,{size:1}),r=true);}),Jn(e,i),r&&e.forEachNode(o=>{e.setNodeAttribute(o,"size",Fn(e.degree(o)));}),{changed:r,added:i,hadNodes:s}}function sn({scene:e,colors:t,theme:n,apiRef:r,onSelect:i,onContextMenu:s,onExpand:o,onPin:d,onLayoutChange:S}){let T=useRef(null),y=useRef(null),c=useRef(null),a=useRef(null),h=useRef(null),g=useRef(null),N=useRef(null),f=useRef(null),u=useRef(null),l=useRef(new Set),p=useRef(e.pinned);p.current=e.pinned;let M=useRef({key:null,nodes:[]}),w=useRef({onSelect:i,onContextMenu:s,onExpand:o,onPin:d,onLayoutChange:S}),[F,D]=useState(0);w.current={onSelect:i,onContextMenu:s,onExpand:o,onPin:d,onLayoutChange:S},y.current||(y.current=new On({type:"undirected",multi:true}));let E=useCallback(()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null),f.current!==null&&(window.clearInterval(f.current),f.current=null),a.current&&(a.current.kill(),a.current=null,u.current=null,w.current.onLayoutChange(false));let m=y.current;l.current.forEach(x=>{m?.hasNode(x)&&m.setNodeAttribute(x,"fixed",p.current[x]===true);}),l.current=new Set;},[]),P=useCallback((m,x=[])=>{let v=y.current;if(E(),!v||v.order===0)return;if(l.current=new Set(x.filter(C=>v.hasNode(C))),l.current.forEach(C=>v.setNodeAttribute(C,"fixed",true)),!v.someNode((C,L)=>!L.fixed)){E();return}let A=qn.inferSettings(v),G=new Qn(v,{settings:{...A,adjustSizes:true,gravity:.2,slowDown:(A.slowDown??1)*2},outputReducer:(C,L)=>{let oe=g.current;return oe&&oe.node===C&&(L.x=oe.x,L.y=oe.y),L}}),q=performance.now(),Y=new Ke(v),V=false,K=0;a.current=G,u.current=q+m,G.start(),w.current.onLayoutChange(true);let k=()=>{g.current?(u.current=performance.now()+m,h.current=window.setTimeout(k,m)):E();};h.current=window.setTimeout(k,m),f.current=window.setInterval(()=>{let C=Y.measure();if(g.current){K=0;return}V=V||C.max>0,K=V&&Zt(C)?K+1:0,K>=Xn&&performance.now()-q>=Bn&&E();},jn);},[E]),$=useCallback(m=>{let x=y.current,v=c.current;if(!x||!v)return;let A=M.current;if(v.setNodesState(A.nodes.filter(G=>x.hasNode(G)),{isNeighbour:false}),m&&x.hasNode(m)){let G=x.neighbors(m);v.setNodesState(G,{isNeighbour:true}),M.current={key:m,nodes:G};}else M.current={key:null,nodes:[]};},[]);return useEffect(()=>{let m=T.current,x=y.current;if(!m||!x)return;if(m.clientWidth===0||m.clientHeight===0){let k=new ResizeObserver(()=>{m.clientWidth>0&&m.clientHeight>0&&(k.disconnect(),D(C=>C+1));});return k.observe(m),()=>k.disconnect()}let v=n==="dark",A=new zn(x,m,{customNodeState:{isNeighbour:false},customEdgeState:{},customGraphState:{isDense:x.order>300,isZoomedIn:false},settings:{allowInvalidContainer:true,itemSizesReference:"screen",enableNodeDrag:true,renderEdgeLabels:false,labelRenderedSizeThreshold:7,labelDensity:.1,labelGridCellSize:80},styles:{nodes:[{...DEFAULT_STYLES.nodes,size:{whenState:"isHighlighted",then:k=>k.size+5,else:{whenState:"isHovered",then:k=>k.size+2,else:{attribute:"size"}}},cursor:"pointer",labelColor:v?"#e4e4e7":"#18181b",labelSize:12,labelFont:"ui-sans-serif, system-ui, sans-serif",labelVisibility:(k,C,L)=>C.isHovered||C.isHighlighted?"visible":L.isDense&&!L.isZoomedIn&&!C.isNeighbour?"hidden":"auto",backdropColor:v?"#27272a":"#ffffff",backdropShadowColor:v?"rgba(0, 0, 0, 0.6)":"rgba(0, 0, 0, 0.25)"}],edges:[{...DEFAULT_STYLES.edges,color:v?"#3f3f46":"#d4d4d8",size:1}]}});c.current=A,A.on("clickNode",({node:k})=>{w.current.onSelect(k);}),A.on("clickStage",()=>{w.current.onSelect(null);}),A.on("doubleClickNode",({node:k,event:C})=>{C.preventSigmaDefault(),w.current.onExpand(k);}),A.on("rightClickNode",({node:k,event:C})=>{C.preventSigmaDefault();let L=C.original;L.preventDefault(),w.current.onSelect(k),w.current.onContextMenu(k,{x:L.clientX,y:L.clientY});}),A.on("enterNode",({node:k})=>$(k)),A.on("leaveNode",()=>$(null));let G=k=>{let C=new Set([k,...x.neighbors(k)]);return x.nodes().filter(L=>L===k||!C.has(L))};A.on("nodeDragStart",({node:k})=>{g.current={node:k,x:x.getNodeAttribute(k,"x"),y:x.getNodeAttribute(k,"y")},x.size>0?(P(Ae(x.order),G(k)),N.current=a.current):(E(),x.setNodeAttribute(k,"fixed",true));}),A.on("nodeDrag",({node:k})=>{g.current?.node===k&&(g.current.x=x.getNodeAttribute(k,"x"),g.current.y=x.getNodeAttribute(k,"y"));}),A.on("nodeDragEnd",({node:k})=>{let C=g.current!==null&&a.current!==null&&a.current===N.current;g.current=null,N.current=null,w.current.onPin(k),C&&P(Ae(x.order),G(k));});let q=A.getCamera(),Y=({ratio:k})=>{let C=k<.45;A.getGraphState().isZoomedIn!==C&&A.setGraphState({isZoomedIn:C});};q.on("updated",Y);let V=k=>k.preventDefault();m.addEventListener("contextmenu",V);let K=new ResizeObserver(()=>{m.clientWidth>0&&m.clientHeight>0&&(A.resize(),A.scheduleRefresh());});return K.observe(m),r.current={fit:()=>{q.reset({duration:300});}},()=>{K.disconnect(),q.off("updated",Y),m.removeEventListener("contextmenu",V),r.current=null,c.current=null,M.current={key:null,nodes:[]},A.kill();}},[n,F,r,P,E,$]),useEffect(()=>{let m=y.current;if(!m)return;E();let{changed:x,added:v,hadNodes:A}=Yn(m,e,t);if(!x)return;if(c.current?.setGraphState({isDense:m.order>300}),$(m.hasNode(M.current.key??"")?M.current.key:null),m.size===0){E();return}let G=A&&v.size>0?m.nodes().filter(q=>!v.has(q)):[];P(Ae(G.length>0?v.size:m.order),G);},[e.version]),useEffect(()=>{let m=y.current;m&&m.forEachNode((x,v)=>{m.setNodeAttribute(x,"color",t[v.entity]??"#71717a");});},[t]),useEffect(()=>{let m=y.current,x=c.current;if(!m||!x)return;let v=new Set(e.hiddenEntities),A=false;m.forEachNode((G,q)=>{x.setNodeState(G,{isHidden:v.has(q.entity),isHighlighted:G===e.selected});let Y=e.pinned[G]===true||l.current.has(G);(q.fixed??false)!==Y&&(m.setNodeAttribute(G,"fixed",Y),A=true);}),A&&u.current!==null&&P(Math.max(500,u.current-performance.now()),[...l.current]),m.forEachEdge((G,q,Y,V)=>{x.setEdgeState(G,{isHidden:v.has(m.getNodeAttribute(Y,"entity"))||v.has(m.getNodeAttribute(V,"entity"))});});},[e.hiddenEntities,e.selected,e.pinned,e.version,F,n,P]),useEffect(()=>E,[E]),jsx("div",{className:"fk:h-full fk:w-full fk:min-h-0",ref:T})}function an({menu:e,relationships:t,isPinned:n,onClose:r$1,onExpandAll:i,onExpandAttribute:s,onHide:o,onHideOthers:d,onTogglePin:S,onOpenRecord:T}){let y=e?.key??"";return jsxs(e$3,{onOpenChange:c=>{c||r$1();},open:e!==null,children:[jsx(g$2,{asChild:true,children:jsx("span",{"aria-hidden":"true",className:"fk:fixed fk:size-0",style:{left:e?.x??0,top:e?.y??0}})}),jsxs(h$1,{align:"start",className:"fk:w-52","data-testid":"graph-context-menu",side:"bottom",children:[jsx(j$1,{onSelect:()=>i(y),children:"Expand all"}),t.length>0?jsxs(q,{children:[jsx(r,{children:"Expand"}),jsx(s$1,{className:"fk:max-h-80 fk:overflow-y-auto",children:t.map(c=>jsx(j$1,{onSelect:()=>s(y,c),children:c.label},c.name))})]}):null,jsx(o$1,{}),jsx(j$1,{onSelect:()=>o(y),children:"Hide"}),jsx(j$1,{onSelect:()=>d(y),children:"Hide others"}),jsx(j$1,{onSelect:()=>S(y),children:n?"Unpin position":"Pin position"}),jsx(o$1,{}),jsx(j$1,{onSelect:()=>T(y),children:"Open record"})]})]})}var Ve={nodes:{},edges:{},counts:{},fetched:{},hiddenEntities:[],pinned:{},selected:null,notice:null,version:0};function Un(e,t){if(!t)return e;let n={...e};return Object.entries(t).forEach(([r,i])=>{n[r]={...n[r],...i};}),n}function Vn(e,t){if(!t)return e;let n={...e};return Object.entries(t).forEach(([r,i])=>{let s={...n[r]};Object.entries(i).forEach(([o,d])=>{s[o]=Math.max(s[o]??0,d);}),n[r]=s;}),n}function ln(e,t){let n=Object.fromEntries(Object.entries(e.nodes).filter(([s])=>!t.has(s))),r=Object.fromEntries(Object.entries(e.edges).filter(([,s])=>!t.has(s.source)&&!t.has(s.target))),i=Object.fromEntries(Object.entries(e.pinned).filter(([s])=>!t.has(s)));return {...e,nodes:n,edges:r,pinned:i,selected:e.selected&&t.has(e.selected)?null:e.selected,version:e.version+1}}function un(e,t){switch(t.type){case "merge":{let n={...e.nodes},r=Object.keys(n).length,i=0;t.data.nodes.forEach(o=>{let d=n[o.key];if(d){d.label===d.id&&o.label!==o.id&&(n[o.key]={...d,label:o.label});return}if(r>=c$4){i+=1;return}n[o.key]=o,r+=1;});let s={...e.edges};return t.data.edges.forEach(o=>{n[o.source]&&n[o.target]&&(s[o.key]=o);}),{...e,nodes:n,edges:s,counts:Un(e.counts,t.data.counts),fetched:Vn(e.fetched,t.fetched),notice:i>0?`The canvas holds ${c$4.toLocaleString()} nodes at most; ${i.toLocaleString()} were left out. Hide some nodes to make room.`:e.notice,version:e.version+1}}case "remove":return ln(e,new Set(t.keys));case "keepOnly":{let n=new Set(t.keys);return ln(e,new Set(Object.keys(e.nodes).filter(r=>!n.has(r))))}case "clear":return {...Ve,hiddenEntities:e.hiddenEntities,version:e.version+1};case "toggleEntity":return {...e,hiddenEntities:e.hiddenEntities.includes(t.entity)?e.hiddenEntities.filter(n=>n!==t.entity):[...e.hiddenEntities,t.entity]};case "select":return e.selected===t.key?e:{...e,selected:t.key};case "togglePin":{let n={...e.pinned};return n[t.key]?delete n[t.key]:n[t.key]=true,{...e,pinned:n}}case "notice":return {...e,notice:t.message};default:return e}}function cn(e){return Object.values(e.nodes).reduce((t,n)=>(t[n.entity]=(t[n.entity]??0)+1,t),{})}function dn(e,t){return Object.values(e.edges).reduce((n,r)=>(r.source===t?n[r.sourceAttribute]=(n[r.sourceAttribute]??0)+1:r.target===t&&(n[r.targetAttribute]=(n[r.targetAttribute]??0)+1),n),{})}function fn(e,t){return Object.values(e.edges).flatMap(n=>n.source===t?[n.target]:n.target===t?[n.source]:[])}function or(e){let[t,n,r]=[1,3,5].map(s=>{let o=parseInt(e.slice(s,s+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*r>.3?"#0a0a0a":"#ffffff"}function gn({node:e,schema:t,scope:n$1,scene:r,colors:i,isLoading:s,onClose:o,onOpenRecord:d,onExpandAll:S,onExpandAttribute:T,onHide:y}){let c=g$1(t,e.entity),a=useMemo(()=>gql(c?p({entity:c,scope:n$1}):"query GraphDetails { __typename }"),[c,n$1]),h$1=useMemo(()=>gql(c?n({entity:c}):"query GraphCounts { __typename }"),[c]),g=useQuery(a,{variables:{id:e.id},skip:!c}),N=useQuery(h$1,{variables:{id:e.id},skip:!c}),f=c?g.data?.[c.plural]?.[0]:void 0,u=c?N.data?.[c.plural]?.[0]:void 0,l=useMemo(()=>dn(r,e.key),[r,e.key]),p$1=c?e$2(c):[],M=c?o$2(c):[],w=f?._updatedAt?new Date(f._updatedAt):null,F=i[e.entity]??"#71717a";return jsxs("aside",{"aria-label":"Selected record",className:"fk:flex fk:w-72 fk:shrink-0 fk:flex-col fk:gap-5 fk:overflow-y-auto fk:border-l fk:bg-background fk:p-4 fk:text-sm","data-testid":"graph-inspector",children:[jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-2",children:[jsx("span",{className:"fk:inline-flex fk:items-center fk:rounded-full fk:px-2 fk:py-0.5 fk:text-xs fk:font-medium",style:{backgroundColor:F,color:or(F)},children:c?h(c):e.entity}),jsx(b$3,{"aria-label":"Close",className:"fk:size-7",onClick:o,size:"icon",variant:"ghost",children:jsx(XIcon,{className:"fk:size-4"})})]}),jsx("h2",{className:"fk:text-base fk:font-semibold fk:leading-snug fk:break-words",children:e.label}),jsxs("div",{className:"fk:flex fk:gap-1.5",children:[jsxs(b$3,{onClick:()=>d(e.key),size:"xs",children:[jsx(SquareArrowOutUpRightIcon,{}),"Open record"]}),jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsxs(b$3,{"aria-label":"Expand every relationship",disabled:s,onClick:()=>S(e.key),size:"xs",variant:"outline",children:[s?jsx(LoaderCircleIcon,{className:"fk:animate-spin"}):jsx(ExpandIcon,{}),"Expand"]})}),jsx(e$1,{children:"Load the first related records of every relationship"})]}),jsxs(b$3,{"aria-label":"Hide this node",onClick:()=>y(e.key),size:"xs",variant:"outline",children:[jsx(EyeOffIcon,{}),"Hide"]})]})]}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("h3",{className:"fk:text-xs fk:font-medium fk:text-muted-foreground",children:"Attributes"}),g.loading&&!f?jsx("span",{className:"fk:text-muted-foreground",children:"Loading\u2026"}):jsxs("dl",{className:"fk:grid fk:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] fk:gap-x-3 fk:gap-y-1.5",children:[M.map(D=>jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:truncate fk:text-muted-foreground",title:D.label,children:D.label}),jsx("dd",{className:"fk:min-w-0 fk:break-words",children:f&&s$2(f[D.name],n$1)||"\u2014"})]},D.name)),w?jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:text-muted-foreground",children:"Updated"}),jsx("dd",{children:formatDistance(w,new Date,{addSuffix:true})})]}):null]})]}),p$1.length>0?jsxs("section",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("h3",{className:"fk:mb-1 fk:text-xs fk:font-medium fk:text-muted-foreground",children:"Relationships"}),p$1.map(D=>{let E=g$1(t,D.relationship?.entity??""),P=u?.[`${D.name}Connection`]?.aggregate?.count?.nodes,$=l[D.name]??0,m=r.fetched[e.key]?.[D.name]??0,x=typeof P=="number"&&m>=P;return jsxs("div",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2 fk:shrink-0 fk:rounded-full",style:{backgroundColor:i[D.relationship?.entity??""]??"#71717a"}}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate",title:E?h(E):void 0,children:D.label}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:typeof P=="number"?`${$} of ${P.toLocaleString()}`:$}),P===0||x?null:jsx(b$3,{className:"fk:h-6 fk:px-2 fk:text-xs",disabled:s,onClick:()=>T(e.key,D),size:"xs",variant:"outline",children:m>0?"More":"Expand"})]},D.name)})]}):null]})}var kn=EditorView.theme({"&":{fontSize:"13px",height:"100%",minHeight:"0"},"&.cm-focused":{outline:"none"},".cm-scroller":{height:"100%",lineHeight:"1.6",minHeight:"0",overflow:"auto"},".cm-content":{fontSize:"13px",padding:"12px 0"},".cm-gutters":{borderRight:"1px solid transparent"}});function yn({ariaLabel:e,schema:t,theme:n,value:r,onChange:i,onRun:s}){let o=useRef(null),d=useRef(null),S=useRef(new Compartment),T=useRef(i),y=useRef(s),c=useRef(r);return T.current=i,y.current=s,c.current=r,useEffect(()=>{let a=o.current;if(!a)return;let h=new EditorView({parent:a,state:EditorState.create({doc:c.current,extensions:[lineNumbers(),highlightActiveLineGutter(),highlightSpecialChars(),history(),foldGutter(),drawSelection(),dropCursor(),indentOnInput(),bracketMatching(),closeBrackets(),highlightActiveLine(),Prec.highest(keymap.of([{key:"Mod-Enter",run:()=>(y.current(),true)}])),keymap.of([...closeBracketsKeymap,...defaultKeymap,...historyKeymap,...foldKeymap,indentWithTab]),graphql(void 0,{showErrorOnInvalidSchema:false}),EditorView.updateListener.of(g=>{g.docChanged&&T.current(g.state.doc.toString());}),EditorView.contentAttributes.of({"aria-label":e,"aria-multiline":"true",role:"textbox"}),placeholder(`query {
1
+ import'./index.css';import {a as a$3,b as b$5}from'./chunk-MLHXPTBT.js';import {b as b$4,c as c$3}from'./chunk-ELOJGLAR.js';import {e}from'./chunk-K2VO74FW.js';import {a as a$1}from'./chunk-EC3SJ4NQ.js';import {f as f$1,i,g as g$1,y,k,b as b$1,e as e$2,l,w,v,d,a,m,h,p,n,o as o$2,s as s$2,c as c$4,q as q$1,r as r$1,j as j$2,u,t}from'./chunk-4PUMSUJL.js';import {c as c$1}from'./chunk-2DXR5NJV.js';import {j,f as f$2}from'./chunk-LBFL34FM.js';import {c}from'./chunk-XMOSCJOI.js';import'./chunk-HKN6BX5U.js';import'./chunk-YDVO6XWD.js';import {a as a$2}from'./chunk-ERDARDGB.js';import {f}from'./chunk-4TQ25SVS.js';import {g}from'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {K,M,Q,O,qa,N,R,S,s,T,V,W,X,o,P,ha,ia,ja,ka,e as e$4,$,aa,da,ea,ba,fa}from'./chunk-DGIY4SKN.js';import {e as e$3,g as g$2,h as h$1,j as j$1,q,r,s as s$1,o as o$1}from'./chunk-SZEGGBOC.js';import {v as v$1}from'./chunk-32ZU4MLE.js';import {b}from'./chunk-U45E5X3H.js';import'./chunk-HDOIOXMP.js';import {b as b$2,c as c$2,e as e$1}from'./chunk-USNXQOMJ.js';import {b as b$3}from'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {useEffect,useMemo,useRef,useState,useCallback,useReducer}from'react';import {useLocation}from'react-router-dom';import On from'graphology';import qn from'graphology-layout-forceatlas2';import Qn from'graphology-layout-forceatlas2/worker';import zn,{DEFAULT_STYLES}from'sigma';import {jsxs,jsx}from'react/jsx-runtime';import {gql}from'@apollo/client';import {useApolloClient,useQuery}from'@apollo/client/react';import {formatDistance}from'date-fns';import {SearchIcon,ChevronDownIcon,LoaderCircleIcon,PlayIcon,ScanIcon,ExpandIcon,EyeOffIcon,EraserIcon,XIcon,SquareArrowOutUpRightIcon}from'lucide-react';import {closeBrackets,closeBracketsKeymap}from'@codemirror/autocomplete';import {history,defaultKeymap,historyKeymap,indentWithTab}from'@codemirror/commands';import {foldGutter,indentOnInput,bracketMatching,foldKeymap}from'@codemirror/language';import {Compartment,EditorState,Prec}from'@codemirror/state';import {EditorView,lineNumbers,highlightActiveLineGutter,highlightSpecialChars,drawSelection,dropCursor,highlightActiveLine,keymap,placeholder}from'@codemirror/view';import {graphql,updateSchema}from'cm6-graphql';import {getIntrospectionQuery,buildClientSchema}from'graphql';import {useDebounce}from'use-debounce';function Ae(e){return Math.min(2e4,2e3+e*9)}function Zt({mean:e,max:t,diagonal:n}){let r=Math.max(.05,n*.0015);return e<r&&t<r*20}var Hn=40,jn=400,Bn=1200,Xn=2;function Fn(e){return 5+Math.min(10,Math.sqrt(e)*2)}function nn(e){return Hn*(.8+Math.sqrt(e)*.6)}function rn(e,t,n){let r=Math.random()*Math.PI*2;return Array.from({length:t},(i,s)=>{let o=r+s/t*Math.PI*2+Math.random()*.3,d=n*(.9+Math.random()*.2);return {x:e.x+Math.cos(o)*d,y:e.y+Math.sin(o)*d}})}function on(e,t){return !Number.isNaN(e.getNodeAttribute(t,"x"))}function $n(e,t){if(t.length===0)return {center:{x:0,y:0},reach:0};let n=t.reduce((i,s)=>({x:i.x+e.getNodeAttribute(s,"x"),y:i.y+e.getNodeAttribute(s,"y")}),{x:0,y:0});n.x/=t.length,n.y/=t.length;let r=t.reduce((i,s)=>Math.max(i,Math.hypot(e.getNodeAttribute(s,"x")-n.x,e.getNodeAttribute(s,"y")-n.y)),0);return {center:n,reach:r}}function Jn(e,t){let n=new Map;t.forEach(r=>{let i=e.neighbors(r).find(s=>!t.has(s)&&on(e,s))??null;n.set(i,[...n.get(i)??[],r]);}),n.forEach((r,i)=>{let s;if(i){let o={x:e.getNodeAttribute(i,"x"),y:e.getNodeAttribute(i,"y")};s=rn(o,r.length,nn(r.length));}else {let o=e.nodes().filter(S=>!t.has(S)&&on(e,S)),d=$n(e,o);s=rn(d.center,r.length,d.reach+nn(r.length));}s.forEach((o,d)=>e.mergeNodeAttributes(r[d],o));});}var Ke=class{constructor(t){this.graph=t;this.positions=new Float64Array(t.order*2);let n=0;this.graph.forEachNode((r,i)=>{this.positions[n]=i.x,this.positions[n+1]=i.y,n+=2;});}positions;measure(){let{graph:t,positions:n}=this,r=0,i=0,s=0,o=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,S=Number.NEGATIVE_INFINITY,T=Number.NEGATIVE_INFINITY,y=0;return t.forEachNode((c,a)=>{let{x:h,y:g}=a;if(y+1<n.length&&!a.fixed){let N=Math.hypot(h-n[y],g-n[y+1]);r+=N,i=Math.max(i,N),s+=1;}n[y]=h,n[y+1]=g,y+=2,o=Math.min(o,h),d=Math.min(d,g),S=Math.max(S,h),T=Math.max(T,g);}),{mean:s>0?r/s:0,max:i,diagonal:t.order>0?Math.hypot(S-o,T-d):0}}};function Yn(e,t,n){let r=false,i=new Set,s=e.order>0;return e.forEachNode(o=>{t.nodes[o]||(e.dropNode(o),r=true);}),Object.values(t.nodes).forEach(o=>{if(e.hasNode(o.key)){e.getNodeAttribute(o.key,"label")!==o.label&&e.setNodeAttribute(o.key,"label",o.label);return}e.addNode(o.key,{entity:o.entity,label:o.label,color:n[o.entity]??"#71717a",size:5,x:Number.NaN,y:Number.NaN}),i.add(o.key),r=true;}),e.forEachEdge(o=>{t.edges[o]||(e.dropEdge(o),r=true);}),Object.values(t.edges).forEach(o=>{e.hasEdge(o.key)||(e.addEdgeWithKey(o.key,o.source,o.target,{size:1}),r=true);}),Jn(e,i),r&&e.forEachNode(o=>{e.setNodeAttribute(o,"size",Fn(e.degree(o)));}),{changed:r,added:i,hadNodes:s}}function sn({scene:e,colors:t,theme:n,apiRef:r,onSelect:i,onContextMenu:s,onExpand:o,onPin:d,onLayoutChange:S}){let T=useRef(null),y=useRef(null),c=useRef(null),a=useRef(null),h=useRef(null),g=useRef(null),N=useRef(null),f=useRef(null),u=useRef(null),l=useRef(new Set),p=useRef(e.pinned);p.current=e.pinned;let M=useRef({key:null,nodes:[]}),w=useRef({onSelect:i,onContextMenu:s,onExpand:o,onPin:d,onLayoutChange:S}),[F,D]=useState(0);w.current={onSelect:i,onContextMenu:s,onExpand:o,onPin:d,onLayoutChange:S},y.current||(y.current=new On({type:"undirected",multi:true}));let E=useCallback(()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null),f.current!==null&&(window.clearInterval(f.current),f.current=null),a.current&&(a.current.kill(),a.current=null,u.current=null,w.current.onLayoutChange(false));let m=y.current;l.current.forEach(x=>{m?.hasNode(x)&&m.setNodeAttribute(x,"fixed",p.current[x]===true);}),l.current=new Set;},[]),P=useCallback((m,x=[])=>{let v=y.current;if(E(),!v||v.order===0)return;if(l.current=new Set(x.filter(C=>v.hasNode(C))),l.current.forEach(C=>v.setNodeAttribute(C,"fixed",true)),!v.someNode((C,L)=>!L.fixed)){E();return}let A=qn.inferSettings(v),G=new Qn(v,{settings:{...A,adjustSizes:true,gravity:.2,slowDown:(A.slowDown??1)*2},outputReducer:(C,L)=>{let oe=g.current;return oe&&oe.node===C&&(L.x=oe.x,L.y=oe.y),L}}),q=performance.now(),Y=new Ke(v),V=false,K=0;a.current=G,u.current=q+m,G.start(),w.current.onLayoutChange(true);let k=()=>{g.current?(u.current=performance.now()+m,h.current=window.setTimeout(k,m)):E();};h.current=window.setTimeout(k,m),f.current=window.setInterval(()=>{let C=Y.measure();if(g.current){K=0;return}V=V||C.max>0,K=V&&Zt(C)?K+1:0,K>=Xn&&performance.now()-q>=Bn&&E();},jn);},[E]),$=useCallback(m=>{let x=y.current,v=c.current;if(!x||!v)return;let A=M.current;if(v.setNodesState(A.nodes.filter(G=>x.hasNode(G)),{isNeighbour:false}),m&&x.hasNode(m)){let G=x.neighbors(m);v.setNodesState(G,{isNeighbour:true}),M.current={key:m,nodes:G};}else M.current={key:null,nodes:[]};},[]);return useEffect(()=>{let m=T.current,x=y.current;if(!m||!x)return;if(m.clientWidth===0||m.clientHeight===0){let k=new ResizeObserver(()=>{m.clientWidth>0&&m.clientHeight>0&&(k.disconnect(),D(C=>C+1));});return k.observe(m),()=>k.disconnect()}let v=n==="dark",A=new zn(x,m,{customNodeState:{isNeighbour:false},customEdgeState:{},customGraphState:{isDense:x.order>300,isZoomedIn:false},settings:{allowInvalidContainer:true,itemSizesReference:"screen",enableNodeDrag:true,renderEdgeLabels:false,labelRenderedSizeThreshold:7,labelDensity:.1,labelGridCellSize:80},styles:{nodes:[{...DEFAULT_STYLES.nodes,size:{whenState:"isHighlighted",then:k=>k.size+5,else:{whenState:"isHovered",then:k=>k.size+2,else:{attribute:"size"}}},cursor:"pointer",labelColor:v?"#e4e4e7":"#18181b",labelSize:12,labelFont:"ui-sans-serif, system-ui, sans-serif",labelVisibility:(k,C,L)=>C.isHovered||C.isHighlighted?"visible":L.isDense&&!L.isZoomedIn&&!C.isNeighbour?"hidden":"auto",backdropColor:v?"#27272a":"#ffffff",backdropShadowColor:v?"rgba(0, 0, 0, 0.6)":"rgba(0, 0, 0, 0.25)"}],edges:[{...DEFAULT_STYLES.edges,color:v?"#3f3f46":"#d4d4d8",size:1}]}});c.current=A,A.on("clickNode",({node:k})=>{w.current.onSelect(k);}),A.on("clickStage",()=>{w.current.onSelect(null);}),A.on("doubleClickNode",({node:k,event:C})=>{C.preventSigmaDefault(),w.current.onExpand(k);}),A.on("rightClickNode",({node:k,event:C})=>{C.preventSigmaDefault();let L=C.original;L.preventDefault(),w.current.onSelect(k),w.current.onContextMenu(k,{x:L.clientX,y:L.clientY});}),A.on("enterNode",({node:k})=>$(k)),A.on("leaveNode",()=>$(null));let G=k=>{let C=new Set([k,...x.neighbors(k)]);return x.nodes().filter(L=>L===k||!C.has(L))};A.on("nodeDragStart",({node:k})=>{g.current={node:k,x:x.getNodeAttribute(k,"x"),y:x.getNodeAttribute(k,"y")},x.size>0?(P(Ae(x.order),G(k)),N.current=a.current):(E(),x.setNodeAttribute(k,"fixed",true));}),A.on("nodeDrag",({node:k})=>{g.current?.node===k&&(g.current.x=x.getNodeAttribute(k,"x"),g.current.y=x.getNodeAttribute(k,"y"));}),A.on("nodeDragEnd",({node:k})=>{let C=g.current!==null&&a.current!==null&&a.current===N.current;g.current=null,N.current=null,w.current.onPin(k),C&&P(Ae(x.order),G(k));});let q=A.getCamera(),Y=({ratio:k})=>{let C=k<.45;A.getGraphState().isZoomedIn!==C&&A.setGraphState({isZoomedIn:C});};q.on("updated",Y);let V=k=>k.preventDefault();m.addEventListener("contextmenu",V);let K=new ResizeObserver(()=>{m.clientWidth>0&&m.clientHeight>0&&(A.resize(),A.scheduleRefresh());});return K.observe(m),r.current={fit:()=>{q.reset({duration:300});}},()=>{K.disconnect(),q.off("updated",Y),m.removeEventListener("contextmenu",V),r.current=null,c.current=null,M.current={key:null,nodes:[]},A.kill();}},[n,F,r,P,E,$]),useEffect(()=>{let m=y.current;if(!m)return;E();let{changed:x,added:v,hadNodes:A}=Yn(m,e,t);if(!x)return;if(c.current?.setGraphState({isDense:m.order>300}),$(m.hasNode(M.current.key??"")?M.current.key:null),m.size===0){E();return}let G=A&&v.size>0?m.nodes().filter(q=>!v.has(q)):[];P(Ae(G.length>0?v.size:m.order),G);},[e.version]),useEffect(()=>{let m=y.current;m&&m.forEachNode((x,v)=>{m.setNodeAttribute(x,"color",t[v.entity]??"#71717a");});},[t]),useEffect(()=>{let m=y.current,x=c.current;if(!m||!x)return;let v=new Set(e.hiddenEntities),A=false;m.forEachNode((G,q)=>{x.setNodeState(G,{isHidden:v.has(q.entity),isHighlighted:G===e.selected});let Y=e.pinned[G]===true||l.current.has(G);(q.fixed??false)!==Y&&(m.setNodeAttribute(G,"fixed",Y),A=true);}),A&&u.current!==null&&P(Math.max(500,u.current-performance.now()),[...l.current]),m.forEachEdge((G,q,Y,V)=>{x.setEdgeState(G,{isHidden:v.has(m.getNodeAttribute(Y,"entity"))||v.has(m.getNodeAttribute(V,"entity"))});});},[e.hiddenEntities,e.selected,e.pinned,e.version,F,n,P]),useEffect(()=>E,[E]),jsx("div",{className:"fk:h-full fk:w-full fk:min-h-0",ref:T})}function an({menu:e,relationships:t,isPinned:n,onClose:r$1,onExpandAll:i,onExpandAttribute:s,onHide:o,onHideOthers:d,onTogglePin:S,onOpenRecord:T}){let y=e?.key??"";return jsxs(e$3,{onOpenChange:c=>{c||r$1();},open:e!==null,children:[jsx(g$2,{asChild:true,children:jsx("span",{"aria-hidden":"true",className:"fk:fixed fk:size-0",style:{left:e?.x??0,top:e?.y??0}})}),jsxs(h$1,{align:"start",className:"fk:w-52","data-testid":"graph-context-menu",side:"bottom",children:[jsx(j$1,{onSelect:()=>i(y),children:"Expand all"}),t.length>0?jsxs(q,{children:[jsx(r,{children:"Expand"}),jsx(s$1,{className:"fk:max-h-80 fk:overflow-y-auto",children:t.map(c=>jsx(j$1,{onSelect:()=>s(y,c),children:c.label},c.name))})]}):null,jsx(o$1,{}),jsx(j$1,{onSelect:()=>o(y),children:"Hide"}),jsx(j$1,{onSelect:()=>d(y),children:"Hide others"}),jsx(j$1,{onSelect:()=>S(y),children:n?"Unpin position":"Pin position"}),jsx(o$1,{}),jsx(j$1,{onSelect:()=>T(y),children:"Open record"})]})]})}var Ve={nodes:{},edges:{},counts:{},fetched:{},hiddenEntities:[],pinned:{},selected:null,notice:null,version:0};function Un(e,t){if(!t)return e;let n={...e};return Object.entries(t).forEach(([r,i])=>{n[r]={...n[r],...i};}),n}function Vn(e,t){if(!t)return e;let n={...e};return Object.entries(t).forEach(([r,i])=>{let s={...n[r]};Object.entries(i).forEach(([o,d])=>{s[o]=Math.max(s[o]??0,d);}),n[r]=s;}),n}function ln(e,t){let n=Object.fromEntries(Object.entries(e.nodes).filter(([s])=>!t.has(s))),r=Object.fromEntries(Object.entries(e.edges).filter(([,s])=>!t.has(s.source)&&!t.has(s.target))),i=Object.fromEntries(Object.entries(e.pinned).filter(([s])=>!t.has(s)));return {...e,nodes:n,edges:r,pinned:i,selected:e.selected&&t.has(e.selected)?null:e.selected,version:e.version+1}}function un(e,t){switch(t.type){case "merge":{let n={...e.nodes},r=Object.keys(n).length,i=0;t.data.nodes.forEach(o=>{let d=n[o.key];if(d){d.label===d.id&&o.label!==o.id&&(n[o.key]={...d,label:o.label});return}if(r>=c$4){i+=1;return}n[o.key]=o,r+=1;});let s={...e.edges};return t.data.edges.forEach(o=>{n[o.source]&&n[o.target]&&(s[o.key]=o);}),{...e,nodes:n,edges:s,counts:Un(e.counts,t.data.counts),fetched:Vn(e.fetched,t.fetched),notice:i>0?`The canvas holds ${c$4.toLocaleString()} nodes at most; ${i.toLocaleString()} were left out. Hide some nodes to make room.`:e.notice,version:e.version+1}}case "remove":return ln(e,new Set(t.keys));case "keepOnly":{let n=new Set(t.keys);return ln(e,new Set(Object.keys(e.nodes).filter(r=>!n.has(r))))}case "clear":return {...Ve,hiddenEntities:e.hiddenEntities,version:e.version+1};case "toggleEntity":return {...e,hiddenEntities:e.hiddenEntities.includes(t.entity)?e.hiddenEntities.filter(n=>n!==t.entity):[...e.hiddenEntities,t.entity]};case "select":return e.selected===t.key?e:{...e,selected:t.key};case "togglePin":{let n={...e.pinned};return n[t.key]?delete n[t.key]:n[t.key]=true,{...e,pinned:n}}case "notice":return {...e,notice:t.message};default:return e}}function cn(e){return Object.values(e.nodes).reduce((t,n)=>(t[n.entity]=(t[n.entity]??0)+1,t),{})}function dn(e,t){return Object.values(e.edges).reduce((n,r)=>(r.source===t?n[r.sourceAttribute]=(n[r.sourceAttribute]??0)+1:r.target===t&&(n[r.targetAttribute]=(n[r.targetAttribute]??0)+1),n),{})}function fn(e,t){return Object.values(e.edges).flatMap(n=>n.source===t?[n.target]:n.target===t?[n.source]:[])}function or(e){let[t,n,r]=[1,3,5].map(s=>{let o=parseInt(e.slice(s,s+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*r>.3?"#0a0a0a":"#ffffff"}function gn({node:e,schema:t,scope:n$1,scene:r,colors:i,isLoading:s,onClose:o,onOpenRecord:d,onExpandAll:S,onExpandAttribute:T,onHide:y}){let c=g$1(t,e.entity),a=useMemo(()=>gql(c?p({entity:c,scope:n$1}):"query GraphDetails { __typename }"),[c,n$1]),h$1=useMemo(()=>gql(c?n({entity:c}):"query GraphCounts { __typename }"),[c]),g=useQuery(a,{variables:{id:e.id},skip:!c}),N=useQuery(h$1,{variables:{id:e.id},skip:!c}),f=c?g.data?.[c.plural]?.[0]:void 0,u=c?N.data?.[c.plural]?.[0]:void 0,l=useMemo(()=>dn(r,e.key),[r,e.key]),p$1=c?e$2(c):[],M=c?o$2(c):[],w=f?._updatedAt?new Date(f._updatedAt):null,F=i[e.entity]??"#71717a";return jsxs("aside",{"aria-label":"Selected record",className:"fk:flex fk:w-72 fk:shrink-0 fk:flex-col fk:gap-5 fk:overflow-y-auto fk:border-l fk:bg-background fk:p-4 fk:text-sm","data-testid":"graph-inspector",children:[jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-2",children:[jsx("span",{className:"fk:inline-flex fk:items-center fk:rounded-full fk:px-2 fk:py-0.5 fk:text-xs fk:font-medium",style:{backgroundColor:F,color:or(F)},children:c?h(c):e.entity}),jsx(b$3,{"aria-label":"Close",className:"fk:size-7",onClick:o,size:"icon",variant:"ghost",children:jsx(XIcon,{className:"fk:size-4"})})]}),jsx("h2",{className:"fk:text-base fk:font-semibold fk:leading-snug fk:break-words",children:e.label}),jsxs("div",{className:"fk:flex fk:gap-1.5",children:[jsxs(b$3,{onClick:()=>d(e.key),size:"xs",children:[jsx(SquareArrowOutUpRightIcon,{}),"Open record"]}),jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsxs(b$3,{"aria-label":"Expand every relationship",disabled:s,onClick:()=>S(e.key),size:"xs",variant:"outline",children:[s?jsx(LoaderCircleIcon,{className:"fk:animate-spin"}):jsx(ExpandIcon,{}),"Expand"]})}),jsx(e$1,{children:"Load the first related records of every relationship"})]}),jsxs(b$3,{"aria-label":"Hide this node",onClick:()=>y(e.key),size:"xs",variant:"outline",children:[jsx(EyeOffIcon,{}),"Hide"]})]})]}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("h3",{className:"fk:text-xs fk:font-medium fk:text-muted-foreground",children:"Attributes"}),g.loading&&!f?jsx("span",{className:"fk:text-muted-foreground",children:"Loading\u2026"}):jsxs("dl",{className:"fk:grid fk:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] fk:gap-x-3 fk:gap-y-1.5",children:[M.map(D=>jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:truncate fk:text-muted-foreground",title:D.label,children:D.label}),jsx("dd",{className:"fk:min-w-0 fk:break-words",children:f&&s$2(f[D.name],n$1)||"\u2014"})]},D.name)),w?jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:text-muted-foreground",children:"Updated"}),jsx("dd",{children:formatDistance(w,new Date,{addSuffix:true})})]}):null]})]}),p$1.length>0?jsxs("section",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("h3",{className:"fk:mb-1 fk:text-xs fk:font-medium fk:text-muted-foreground",children:"Relationships"}),p$1.map(D=>{let E=g$1(t,D.relationship?.entity??""),P=u?.[`${D.name}Connection`]?.aggregate?.count?.nodes,$=l[D.name]??0,m=r.fetched[e.key]?.[D.name]??0,x=typeof P=="number"&&m>=P;return jsxs("div",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2 fk:shrink-0 fk:rounded-full",style:{backgroundColor:i[D.relationship?.entity??""]??"#71717a"}}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate",title:E?h(E):void 0,children:D.label}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:typeof P=="number"?`${$} of ${P.toLocaleString()}`:$}),P===0||x?null:jsx(b$3,{className:"fk:h-6 fk:px-2 fk:text-xs",disabled:s,onClick:()=>T(e.key,D),size:"xs",variant:"outline",children:m>0?"More":"Expand"})]},D.name)})]}):null]})}var kn=EditorView.theme({"&":{fontSize:"13px",height:"100%",minHeight:"0"},"&.cm-focused":{outline:"none"},".cm-scroller":{height:"100%",lineHeight:"1.6",minHeight:"0",overflow:"auto"},".cm-content":{fontSize:"13px",padding:"12px 0"},".cm-gutters":{borderRight:"1px solid transparent"}});function yn({ariaLabel:e,schema:t,theme:n,value:r,onChange:i,onRun:s}){let o=useRef(null),d=useRef(null),S=useRef(new Compartment),T=useRef(i),y=useRef(s),c=useRef(r);return T.current=i,y.current=s,c.current=r,useEffect(()=>{let a=o.current;if(!a)return;let h=new EditorView({parent:a,state:EditorState.create({doc:c.current,extensions:[lineNumbers(),highlightActiveLineGutter(),highlightSpecialChars(),history(),foldGutter(),drawSelection(),dropCursor(),indentOnInput(),bracketMatching(),closeBrackets(),highlightActiveLine(),Prec.highest(keymap.of([{key:"Mod-Enter",run:()=>(y.current(),true)}])),keymap.of([...closeBracketsKeymap,...defaultKeymap,...historyKeymap,...foldKeymap,indentWithTab]),graphql(void 0,{showErrorOnInvalidSchema:false}),EditorView.updateListener.of(g=>{g.docChanged&&T.current(g.state.doc.toString());}),EditorView.contentAttributes.of({"aria-label":e,"aria-multiline":"true",role:"textbox"}),placeholder(`query {
2
2
  \u2026
3
3
  }`),S.current.of([n==="dark"?a$3:b$5,kn])]})});return d.current=h,()=>{h.destroy(),d.current=null;}},[]),useEffect(()=>{d.current?.dispatch({effects:S.current.reconfigure([n==="dark"?a$3:b$5,kn])});},[n]),useEffect(()=>{d.current&&updateSchema(d.current,t??void 0);},[t]),useEffect(()=>{let a=d.current;!a||a.state.doc.toString()===r||a.dispatch({changes:{from:0,to:a.state.doc.length,insert:r}});},[r]),jsx("div",{className:"fk:h-full fk:min-h-0 fk:w-full","data-testid":"graph-query-editor",ref:o})}var Me=200,Rr=5,Tr=3;function bn(e){return typeof e=="object"&&e!==null&&typeof e._id=="string"}function me(e){if(Array.isArray(e))return e.flatMap(me);if(typeof e!="object"||e===null)return [];if(bn(e))return [e];let{edges:t}=e;return Array.isArray(t)?t.flatMap(n=>me(n?.node)):[]}function Mr(e,t){let n=e.endsWith("Connection")?e.slice(0,-10):e;return t.find(r=>r.plural===n)}function Gr(e,t){let n=e.endsWith("Connection")?e.slice(0,-10):e;return e$2(t).find(r=>r.name===n)}function Lr(e,t){let n=e$2(e).filter(r=>r.relationship?.entity===t);return n.length===1?n[0]:void 0}function Dr(e,t,n){let r=e.__typename;return typeof r=="string"&&g$1(n,r)||t}function Ir(e,t$1,n){let r=t(e,t$1,n);if(r!==e._id)return r;let i=Object.entries(e).find(([s,o])=>!s.startsWith("_")&&typeof o=="string"&&o.trim().length>0);return i?i[1]:e._id}function xn({data:e,schema:t,scope:n}){let r=new Map,i=new Map,s=(o,d$1)=>{let S=Dr(o,d$1,t);if(!S)return null;let T=d(S.name,o._id),y=Ir(o,S,n),c=r.get(T),a=c??{key:T,entity:S.name,id:o._id,label:y};return c?c.label===c.id&&y!==o._id&&(c.label=y):r.set(T,a),Object.entries(o).forEach(([h,g])=>{let N=Gr(h,S),f=N?g$1(t,N.relationship?.entity??""):void 0;me(g).forEach(u$1=>{let l=s(u$1,f),p=N??(l?Lr(S,l.entity):void 0);if(l&&p&&l.key!==a.key){let M=u(a,l,p);i.has(M.key)||i.set(M.key,M);}});}),a};return Object.entries(e??{}).forEach(([o,d])=>{let S=Mr(o,t);me(d).forEach(T=>s(T,S));}),{nodes:[...r.values()],edges:[...i.values()],counts:{}}}function Sn(e,t){return f$1(e).map(n=>{let r=e$2(n).slice(0,Tr).map(s=>{let o=g$1(e,s.relationship?.entity??"");return ` ${s.name}(limit: ${Rr}) {
4
4
  _id
@@ -10,5 +10,5 @@ ${i?` ${i}
10
10
  `:""}${r.join(`
11
11
  `)}
12
12
  }
13
- }`}})}function Pr(e,t){let n=me(e);return n.length>0?`${n.length} ${n.length===1?"record":"records"}`:Array.isArray(e)&&!(typeof e[0]=="object"&&e[0]!==null)?e.map(r=>s$2(r,t)).join(", "):s$2(e,t)}function Ze(e){if(Array.isArray(e))return e.flatMap(Ze);if(typeof e!="object"||e===null)return [];let{edges:t}=e;return !bn(e)&&Array.isArray(t)?t.flatMap(n=>Ze(n?.node)):[e]}function En(e,t){let n=Object.values(e??{}).flatMap(Ze),r=n.slice(0,Me),i=[];return r.forEach(s=>{Object.keys(s).forEach(o=>{o!=="__typename"&&!i.includes(o)&&i.push(o);});}),{columns:i,rows:r.map(s=>Object.fromEntries(i.map(o=>[o,Pr(s[o],t)]))),total:n.length}}function Te(e){return Array.isArray(e)?e.map(Te):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).filter(([t])=>t!=="__typename").map(([t,n])=>[t,Te(n)])):e}function et(e){return `flexkit-graph:query:${e}`}var Ge=new Map;function jr(e,t,n){let r=Ge.get(t);if(r&&r.hash===n)return r.schema;let i=e.query({query:gql(getIntrospectionQuery()),fetchPolicy:"no-cache",context:f$2}).then(s=>{if(!s.data)throw new Error("The schema could not be introspected.");return buildClientSchema(s.data)});return i.catch(()=>{Ge.get(t)?.schema===i&&Ge.delete(t);}),Ge.set(t,{hash:n,schema:i}),i}function Nn(e,t){let n=useApolloClient(),[r,i]=useState(null);return useEffect(()=>{if(!e)return;let s=false;return jr(n,e,t??"").then(o=>{s||i(o);}).catch(()=>{}),()=>{s=true;}},[n,e,t]),r}function vn({projectId:e,schemaHash:t,schema:n,scope:r,theme:i,isRunning:s,hidden:o$1,onRun:d}){let[S,T]=useState(!o$1),y=Nn(S?e:void 0,t),c=useMemo(()=>Sn(n,r),[n,r]),[a,h]=useState(()=>b$4(et(e))||c[0]?.query||""),g=useRef(a!==""),[N,f]=useState(false),[u,l]=useState("graph"),[p,M]=useState(null),w=useMemo(()=>u==="table"&&p?.data?En(p.data,r):null,[u,p,r]),F=useMemo(()=>u==="json"&&p?.data?JSON.stringify(Te(p.data),null,2):null,[u,p]);useEffect(()=>{o$1||T(true);},[o$1]),useEffect(()=>{let[E]=c;!g.current&&E&&(g.current=true,h(P=>P||E.query));},[c]),useEffect(()=>{c$3(et(e),a);},[e,a]);let D=async()=>{!a.trim()||s||M(await d(a,{append:N}));};return jsxs("section",{"aria-label":"Query",className:`fk:w-[26rem] fk:shrink-0 fk:flex-col fk:border-r fk:bg-background ${o$1?"fk:hidden":"fk:flex"}`,"data-testid":"graph-query-pane",hidden:o$1,children:[jsxs("div",{className:"fk:flex fk:h-12 fk:shrink-0 fk:items-center fk:gap-2 fk:border-b fk:pl-4 fk:pr-3",children:[jsx("span",{className:"fk:text-sm fk:font-semibold",children:"Query"}),jsxs("div",{className:"fk:ml-auto fk:flex fk:items-center fk:gap-1.5",children:[c.length>0?jsxs(e$3,{children:[jsx(g$2,{asChild:true,children:jsxs(b$3,{className:"fk:h-8",size:"sm",variant:"outline",children:["Examples",jsx(ChevronDownIcon,{className:"fk:size-3.5"})]})}),jsx(h$1,{align:"end",className:"fk:max-h-80 fk:overflow-y-auto",children:c.map(E=>jsx(j$1,{onSelect:()=>h(E.query),children:E.title},E.entity))})]}):null,jsxs(b$3,{className:"fk:h-8",disabled:s||!a.trim(),onClick:()=>{D();},size:"sm",children:[s?jsx(LoaderCircleIcon,{className:"fk:size-3.5 fk:animate-spin"}):jsx(PlayIcon,{className:"fk:size-3.5"}),"Run"]})]})]}),jsx("div",{className:"fk:min-h-0 fk:flex-1",children:jsx(yn,{ariaLabel:"GraphQL query",onChange:h,onRun:()=>{D();},schema:y,theme:i,value:a})}),jsxs(ha,{className:"fk:flex fk:max-h-[45%] fk:shrink-0 fk:flex-col fk:gap-0 fk:border-t",onValueChange:E=>l(E),value:u,children:[jsxs("div",{className:"fk:flex fk:h-11 fk:shrink-0 fk:items-center fk:gap-3 fk:px-3",children:[jsxs(ia,{children:[jsx(ja,{value:"graph",children:"Graph"}),jsx(ja,{value:"table",children:"Table"}),jsx(ja,{value:"json",children:"JSON"})]}),jsx("span",{className:"fk:ml-auto fk:truncate fk:text-xs fk:text-muted-foreground","data-testid":"graph-query-stats",children:p&&!p.error?`${p.nodes.toLocaleString()} ${p.nodes===1?"node":"nodes"} \xB7 ${p.edges.toLocaleString()} ${p.edges===1?"relationship":"relationships"} \xB7 ${p.elapsedMs.toLocaleString()} ms`:null})]}),p?.error?jsx("pre",{className:"fk:m-3 fk:mt-0 fk:max-h-40 fk:shrink-0 fk:overflow-auto fk:whitespace-pre-wrap fk:rounded-md fk:border fk:border-destructive/40 fk:bg-destructive/5 fk:p-2 fk:text-xs fk:text-destructive","data-testid":"graph-query-error",children:p.error}):null,jsxs("div",{className:"fk:min-h-0 fk:overflow-auto",children:[jsxs(ka,{className:"fk:flex fk:flex-col fk:gap-3 fk:px-3 fk:pb-3 fk:text-xs fk:text-muted-foreground",value:"graph",children:[jsxs("span",{children:["Every object with an ",jsx("code",{className:"fk:font-mono",children:"_id"})," under an entity field becomes a node; a nested relationship selection becomes a line between them."]}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(o,{checked:N,id:"graph-query-append",onCheckedChange:E=>f(E===true)}),jsx(e$4,{className:"fk:text-xs fk:font-normal",htmlFor:"graph-query-append",children:"Add to the current canvas instead of replacing it"})]})]}),jsx(ka,{className:"fk:px-3 fk:pb-3",value:"table",children:w&&w.columns.length>0?jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("div",{className:"fk:overflow-x-auto fk:rounded-md fk:border",children:jsxs($,{children:[jsx(aa,{children:jsx(da,{children:w.columns.map(E=>jsx(ea,{className:"fk:h-8 fk:text-xs",children:E},E))})}),jsx(ba,{children:w.rows.map((E,P)=>jsx(da,{children:w.columns.map($=>jsx(fa,{className:"fk:max-w-56 fk:truncate fk:py-1.5 fk:text-xs",title:E[$],children:E[$]},$))},`${E._id??""}-${P}`))})]})}),w.total>Me?jsxs("span",{className:"fk:text-xs fk:text-muted-foreground",children:["First ",Me.toLocaleString()," of ",w.total.toLocaleString()," records."]}):null]}):jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:p?.data?"The response has no rows to show.":"Run a query to see its records."})}),jsx(ka,{className:"fk:px-3 fk:pb-3",value:"json",children:F?jsx("pre",{className:"fk:overflow-auto fk:rounded-md fk:border fk:bg-muted/40 fk:p-2 fk:font-mono fk:text-xs",children:F}):jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Run a query to see its response."})})]})]})]})}var Wr=250,Zr=5;function eo(e,t){let n=t.trim();return !n||e.length===0?null:{searchRequests:{searches:e.map(r=>({collection:r.plural}))},commonParams:{q:n,limit:Zr}}}function to(e){let t=useMemo(()=>q$1(e),[e]),n=useMemo(()=>gql(t.length>0?r$1(t):"query GraphTotals { __typename }"),[t]),{data:r}=useQuery(n,{skip:t.length===0});return useMemo(()=>Object.fromEntries(t.map(i=>[i.plural,r?.[`${i.plural}Total`]]).filter(i=>typeof i[1]=="number")),[t,r])}function wn({projectId:e,entities:t,colors:n,onCanvas:r,hiddenEntities:i,onStart:s$1,onHit:o$1,onToggleEntity:d}){let[S$1,T$1]=useState(""),[y]=useDebounce(S$1,Wr),c=useMemo(()=>t.filter(l=>l.attributes.some(p=>p.searchable)),[t]),a=useMemo(()=>eo(c,y),[c,y]),{results:h$1,isLoading:g}=a$1(e,a),N$1=to(t),f=useMemo(()=>new Map(t.map(l=>[l.name,l])),[t]),u=Object.keys(r).sort();return jsxs(N,{collapsible:"icon",variant:"inset",children:[jsxs(R,{children:[jsxs(S,{className:"fk:group-data-[collapsible=icon]:hidden",children:[jsxs("div",{className:"fk:relative",children:[jsx(SearchIcon,{className:"fk:pointer-events-none fk:absolute fk:left-2 fk:top-1/2 fk:size-4 fk:-translate-y-1/2 fk:text-muted-foreground"}),jsx(s,{"aria-label":"Search records to add to the canvas",className:"fk:h-8 fk:bg-background fk:pl-8 fk:shadow-none",onChange:l=>T$1(l.target.value),placeholder:c.length>0?"Search records\u2026":"No searchable entity",disabled:c.length===0,value:S$1})]}),a?jsxs("ul",{className:"fk:mt-2 fk:flex fk:flex-col fk:gap-0.5","data-testid":"graph-search-results",children:[h$1.map(l=>{let p=f.get(l._entityName),M=l[a$2(p)?.name??""];return jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:items-center fk:gap-2 fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:text-sm fk:hover:bg-sidebar-accent",onClick:()=>o$1(l._entityName,l._id),type:"button",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n[l._entityName]??"#71717a"}}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate",children:String(M??l._id)})]})},`${l._entityName}:${l._id}`)}),!g&&h$1.length===0?jsx("li",{className:"fk:px-2 fk:py-1.5 fk:text-sm fk:text-muted-foreground",children:"Nothing found"}):null]}):null]}),jsxs(S,{children:[jsx(T,{children:"Nodes"}),jsx(V,{children:t.map(l=>jsx(W,{children:jsxs(X,{onClick:()=>s$1(l),tooltip:h(l),children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n[l.name]??"#71717a"}}),jsx("span",{className:"fk:truncate",children:h(l)}),N$1[l.plural]!==void 0?jsx("span",{className:"fk:ml-auto fk:text-xs fk:text-muted-foreground",children:N$1[l.plural]?.toLocaleString()}):null]})},l.name))})]}),u.length>0?jsxs(S,{className:"fk:group-data-[collapsible=icon]:hidden",children:[jsx(T,{children:"On canvas"}),jsx("ul",{className:"fk:flex fk:flex-col","data-testid":"graph-legend",children:u.map(l=>{let p=f.get(l),M=!i.includes(l),w=`graph-legend-${l}`;return jsxs("li",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2 fk:px-2 fk:text-sm",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n[l]??"#71717a",opacity:M?1:.35}}),jsx("label",{className:"fk:min-w-0 fk:flex-1 fk:cursor-pointer fk:truncate",htmlFor:w,children:p?h(p):l}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:r[l]?.toLocaleString()}),jsx(o,{"aria-label":`Show ${p?h(p):l}`,checked:M,id:w,onCheckedChange:()=>d(l)})]},l)})})]}):null]}),jsx(P,{})]})}function Le({label:e,icon:t,disabled:n,onClick:r}){return jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsxs(b$3,{className:"fk:h-8 fk:gap-1.5 fk:px-2.5",disabled:n,onClick:r,size:"sm",variant:"ghost",children:[t,jsx("span",{className:"fk:text-xs",children:e})]})}),jsx(e$1,{children:e})]})}function An({hasSelection:e,hasNodes:t,isLoading:n,onFit:r,onExpand:i,onHide:s,onClear:o}){return jsxs("div",{className:"fk:flex fk:items-center fk:gap-0.5 fk:rounded-lg fk:border fk:bg-background fk:p-1 fk:shadow-xs","data-testid":"graph-toolbar",children:[jsx(Le,{disabled:!t,icon:jsx(ScanIcon,{className:"fk:size-3.5"}),label:"Fit",onClick:r}),jsx(v$1,{className:"fk:mx-0.5 fk:h-4",orientation:"vertical"}),jsx(Le,{disabled:!e||n,icon:n?jsx(LoaderCircleIcon,{className:"fk:size-3.5 fk:animate-spin"}):jsx(ExpandIcon,{className:"fk:size-3.5"}),label:"Expand",onClick:i}),jsx(Le,{disabled:!e,icon:jsx(EyeOffIcon,{className:"fk:size-3.5"}),label:"Hide",onClick:s}),jsx(v$1,{className:"fk:mx-0.5 fk:h-4",orientation:"vertical"}),jsx(Le,{disabled:!t,icon:jsx(EraserIcon,{className:"fk:size-3.5"}),label:"Clear",onClick:o})]})}function Ie(e,t="The records could not be loaded."){return e instanceof Error?e.message:t}function Cn({schema:e,scope:t}){let n=useApolloClient(),[r,i]=useReducer(un,Ve),[s,o]=useState(0),d$1=useRef(0),S=useCallback(async(a,h)=>{let g="ids"in h?h.ids:void 0,N="ids"in h?h.expand:false,f="limit"in h?h.limit:g?.length;o(u=>u+1);try{let l$1=(await n.query({query:gql(l({entity:a,schema:e,scope:t,expand:N})),variables:{where:g?{_id:{in:g}}:void 0,limit:f},fetchPolicy:"network-only"})).data?.[a.plural]??[];return d$1.current+=1,i({type:"merge",data:v({records:l$1,entity:a,schema:e,scope:t}),fetched:w(l$1,a)}),l$1.map(p=>d(a.name,p._id))}catch(u){return qa.error(Ie(u)),[]}finally{o(u=>u-1);}},[n,e,t]),T=useCallback(async a=>{let h=r.nodes[a],g=h?g$1(e,h.entity):void 0;!h||!g||await S(g,{ids:[h.id],expand:true});},[S,e,r.nodes]),y=useCallback(async(a$1,h)=>{let g=r.nodes[a$1],N=g?g$1(e,g.entity):void 0;if(!g||!N)return;let f=r.fetched[a$1]?.[h.name]??0;o(u=>u+1);try{let l=(await n.query({query:gql(m({entity:N,schema:e,scope:t,attribute:h})),variables:{id:g.id,offset:f,limit:a},fetchPolicy:"network-only"})).data?.[N.plural]??[];d$1.current+=1;let p=l.reduce((M,w)=>{let F=w[h.name];return M+(Array.isArray(F)?F.length:0)},0);i({type:"merge",data:v({records:l,entity:N,schema:e,scope:t}),fetched:{[a$1]:{[h.name]:f+p}}});}catch(u){qa.error(Ie(u));}finally{o(u=>u-1);}},[n,e,t,r.fetched,r.nodes]),c=useCallback(async(a,{append:h})=>{let g=performance.now(),N;try{N=gql(a);}catch(u){return {data:null,error:Ie(u,"The query could not be parsed."),elapsedMs:0,nodes:0,edges:0}}let f=d$1.current;o(u=>u+1);try{let u=await n.query({query:N,fetchPolicy:"no-cache",errorPolicy:"all",context:f$2}),l=u.data??null,p=xn({data:l,schema:e,scope:t});return p.nodes.length>0&&(!h&&!u.error&&d$1.current===f&&i({type:"clear"}),d$1.current+=1,i({type:"merge",data:p})),{data:l,error:u.error?u.error.message:null,elapsedMs:Math.round(performance.now()-g),nodes:p.nodes.length,edges:p.edges.length}}catch(u){return {data:null,error:Ie(u,"The query failed."),elapsedMs:Math.round(performance.now()-g),nodes:0,edges:0}}finally{o(u=>u-1);}},[n,e,t]);return {state:r,dispatch:i,isLoading:s>0,loadRecords:S,expandAll:T,expandAttribute:y,runQuery:c}}function Zi(){let{currentProjectId:e$3,currentProject:t,currentProjectSchema:n}=f();useEffect(()=>{e$3&&t&&e({event:"graph_opened",projectId:e$3});},[e$3,t]);let[,r]=g(),{scope:i$1}=c(),{resolvedTheme:s}=b(),o=useLocation(),d=j(),S=s==="dark"?"dark":"light",T=t?.scopes?.find(b=>b.isDefault)?.name??"default",y$1=i$1||T,c$3=r.user?.spaces,a=useMemo(()=>c$1(n,c$3),[n,c$3]),h=useMemo(()=>f$1(a),[a]),g$2=useMemo(()=>i(a,S),[a,S]),N=Cn({schema:a,scope:y$1}),{state:f$2,dispatch:u,isLoading:l,loadRecords:p,expandAll:M$1,expandAttribute:w,runQuery:F}=N,D=useRef(null),[E,P]=useState(null),[$,m]=useState(false),[x,v]=useState("explore"),A=useRef(null),G=useMemo(()=>cn(f$2),[f$2]),q=f$2.selected?f$2.nodes[f$2.selected]:void 0,Y=E?f$2.nodes[E.key]:void 0,V=Y?g$1(a,Y.entity):void 0,K$1=Object.keys(f$2.nodes).length,k$1=Object.keys(f$2.edges).length,C=K(),L=useCallback(b=>u({type:"select",key:b}),[u]),oe=useCallback(b=>{let O=f$2.nodes[b],ie=O?g$1(a,O.entity):void 0;O&&ie&&d({type:"EditEntity",payload:{entityId:O.id,entityNamePlural:ie.plural}});},[d,a,f$2.nodes]),_e=useCallback(b=>u({type:"remove",keys:[b]}),[u]),Mn=useCallback(b=>u({type:"keepOnly",keys:[b,...fn(f$2,b)]}),[u,f$2]),Gn=useCallback(b=>u({type:"togglePin",key:b}),[u]),Ln=useCallback(b=>{f$2.pinned[b]||u({type:"togglePin",key:b});},[u,f$2.pinned]),Dn=useCallback(async(b,O)=>{let ie=g$1(a,b);if(!ie)return;let[de]=await p(ie,{ids:[O],expand:true});de&&L(de);},[p,a,L]),In=useCallback((b,O)=>{P(null),w(b,O);},[w]);return useEffect(()=>{let b=y(o.search);if(!b||A.current===o.key)return;let O=g$1(a,b.entity);if(!O||a.length===0)return;A.current=o.key;let ie=b.ids.length>0?{ids:b.ids,expand:b.ids.length<=k}:{limit:b$1};p(O,ie).then(de=>{b.ids.length===1&&de[0]&&L(de[0]);});},[o.key,o.search,a,p,L]),e$3?jsxs(M,{className:"fk:h-full",defaultOpen:C,children:[jsx(wn,{colors:g$2,entities:h,hiddenEntities:f$2.hiddenEntities,onCanvas:G,onHit:(b,O)=>{Dn(b,O);},onStart:b=>{p(b,{limit:b$1});},onToggleEntity:b=>u({type:"toggleEntity",entity:b}),projectId:e$3}),jsx(Q,{className:"fk:min-w-0",children:jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0","data-testid":"graph-app",children:[jsx(vn,{hidden:x!=="query",isRunning:l,onRun:F,projectId:e$3,schema:a,schemaHash:t?.schemaHash??null,scope:y$1,theme:S},e$3),jsxs("div",{className:"fk:relative fk:min-w-0 fk:flex-1 fk:overflow-hidden fk:bg-background",children:[jsxs("div",{className:"fk:pointer-events-none fk:absolute fk:left-3 fk:right-3 fk:top-3 fk:z-10 fk:flex fk:flex-wrap fk:items-start fk:justify-between fk:gap-2",children:[jsxs("div",{className:"fk:pointer-events-auto fk:flex fk:items-center fk:gap-2",children:[jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsx(O,{className:"fk:h-8 fk:w-8 fk:rounded-lg fk:hover:bg-transparent fk:dark:hover:bg-transparent"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(An,{hasNodes:K$1>0,hasSelection:q!==void 0,isLoading:l,onClear:()=>u({type:"clear"}),onExpand:()=>{f$2.selected&&M$1(f$2.selected);},onFit:()=>D.current?.fit(),onHide:()=>{f$2.selected&&_e(f$2.selected);}})]}),jsxs("div",{"aria-label":"View",className:"fk:pointer-events-auto fk:flex fk:items-center fk:gap-0.5 fk:rounded-lg fk:border fk:bg-background fk:p-0.5 fk:shadow-xs","data-testid":"graph-mode",role:"group",children:[jsx(b$3,{"aria-pressed":x==="explore",className:"fk:h-7 fk:px-3 fk:text-xs",onClick:()=>v("explore"),size:"sm",variant:x==="explore"?"default":"ghost",children:"Explore"}),jsx(b$3,{"aria-pressed":x==="query",className:"fk:h-7 fk:px-3 fk:text-xs",onClick:()=>v("query"),size:"sm",variant:x==="query"?"default":"ghost",children:"Query"})]})]}),K$1>0?null:jsx("div",{className:"fk:pointer-events-none fk:absolute fk:inset-0 fk:flex fk:items-center fk:justify-center fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground",children:l?"Loading records\u2026":x==="query"?"Run a query to draw its result.":"Search a record or start from an entity to draw its graph."}),jsx(sn,{apiRef:D,colors:g$2,onContextMenu:(b,O)=>P({key:b,...O}),onExpand:b=>{M$1(b);},onLayoutChange:m,onPin:Ln,onSelect:L,scene:f$2,theme:S}),jsxs("div",{className:"fk:absolute fk:bottom-3 fk:left-3 fk:flex fk:max-w-[calc(100%-1.5rem)] fk:items-center fk:gap-2 fk:rounded-lg fk:border fk:bg-background fk:px-2.5 fk:py-1.5 fk:text-xs fk:text-muted-foreground fk:shadow-xs","data-testid":"graph-status",children:[jsxs("span",{children:[K$1.toLocaleString()," ",K$1===1?"node":"nodes"," \xB7 ",k$1.toLocaleString()," ",k$1===1?"relationship":"relationships"]}),$?jsx("span",{children:"\xB7 laying out\u2026"}):null,f$2.notice?jsxs("span",{className:"fk:truncate fk:text-foreground",children:["\xB7 ",f$2.notice]}):null]}),jsx(an,{isPinned:E?f$2.pinned[E.key]===true:false,menu:E,onClose:()=>P(null),onExpandAll:b=>{M$1(b);},onExpandAttribute:In,onHide:_e,onHideOthers:Mn,onOpenRecord:oe,onTogglePin:Gn,relationships:V?e$2(V):[]})]}),q?jsx(gn,{colors:g$2,isLoading:l,node:q,onClose:()=>L(null),onExpandAll:b=>{M$1(b);},onExpandAttribute:(b,O)=>{w(b,O);},onHide:_e,onOpenRecord:oe,scene:f$2,schema:a,scope:y$1}):null]})})]}):jsx("main",{className:"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground",children:"Select a project to explore its graph."})}export{Zi as Root};//# sourceMappingURL=root-R4Y6L62R.js.map
14
- //# sourceMappingURL=root-R4Y6L62R.js.map
13
+ }`}})}function Pr(e,t){let n=me(e);return n.length>0?`${n.length} ${n.length===1?"record":"records"}`:Array.isArray(e)&&!(typeof e[0]=="object"&&e[0]!==null)?e.map(r=>s$2(r,t)).join(", "):s$2(e,t)}function Ze(e){if(Array.isArray(e))return e.flatMap(Ze);if(typeof e!="object"||e===null)return [];let{edges:t}=e;return !bn(e)&&Array.isArray(t)?t.flatMap(n=>Ze(n?.node)):[e]}function En(e,t){let n=Object.values(e??{}).flatMap(Ze),r=n.slice(0,Me),i=[];return r.forEach(s=>{Object.keys(s).forEach(o=>{o!=="__typename"&&!i.includes(o)&&i.push(o);});}),{columns:i,rows:r.map(s=>Object.fromEntries(i.map(o=>[o,Pr(s[o],t)]))),total:n.length}}function Te(e){return Array.isArray(e)?e.map(Te):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).filter(([t])=>t!=="__typename").map(([t,n])=>[t,Te(n)])):e}function et(e){return `flexkit-graph:query:${e}`}var Ge=new Map;function jr(e,t,n){let r=Ge.get(t);if(r&&r.hash===n)return r.schema;let i=e.query({query:gql(getIntrospectionQuery()),fetchPolicy:"no-cache",context:f$2}).then(s=>{if(!s.data)throw new Error("The schema could not be introspected.");return buildClientSchema(s.data)});return i.catch(()=>{Ge.get(t)?.schema===i&&Ge.delete(t);}),Ge.set(t,{hash:n,schema:i}),i}function Nn(e,t){let n=useApolloClient(),[r,i]=useState(null);return useEffect(()=>{if(!e)return;let s=false;return jr(n,e,t??"").then(o=>{s||i(o);}).catch(()=>{}),()=>{s=true;}},[n,e,t]),r}function vn({projectId:e,schemaHash:t,schema:n,scope:r,theme:i,isRunning:s,hidden:o$1,onRun:d}){let[S,T]=useState(!o$1),y=Nn(S?e:void 0,t),c=useMemo(()=>Sn(n,r),[n,r]),[a,h]=useState(()=>b$4(et(e))||c[0]?.query||""),g=useRef(a!==""),[N,f]=useState(false),[u,l]=useState("graph"),[p,M]=useState(null),w=useMemo(()=>u==="table"&&p?.data?En(p.data,r):null,[u,p,r]),F=useMemo(()=>u==="json"&&p?.data?JSON.stringify(Te(p.data),null,2):null,[u,p]);useEffect(()=>{o$1||T(true);},[o$1]),useEffect(()=>{let[E]=c;!g.current&&E&&(g.current=true,h(P=>P||E.query));},[c]),useEffect(()=>{c$3(et(e),a);},[e,a]);let D=async()=>{!a.trim()||s||M(await d(a,{append:N}));};return jsxs("section",{"aria-label":"Query",className:`fk:w-[26rem] fk:shrink-0 fk:flex-col fk:border-r fk:bg-background ${o$1?"fk:hidden":"fk:flex"}`,"data-testid":"graph-query-pane",hidden:o$1,children:[jsxs("div",{className:"fk:flex fk:h-12 fk:shrink-0 fk:items-center fk:gap-2 fk:border-b fk:pl-4 fk:pr-3",children:[jsx("span",{className:"fk:text-sm fk:font-semibold",children:"Query"}),jsxs("div",{className:"fk:ml-auto fk:flex fk:items-center fk:gap-1.5",children:[c.length>0?jsxs(e$3,{children:[jsx(g$2,{asChild:true,children:jsxs(b$3,{className:"fk:h-8",size:"sm",variant:"outline",children:["Examples",jsx(ChevronDownIcon,{className:"fk:size-3.5"})]})}),jsx(h$1,{align:"end",className:"fk:max-h-80 fk:overflow-y-auto",children:c.map(E=>jsx(j$1,{onSelect:()=>h(E.query),children:E.title},E.entity))})]}):null,jsxs(b$3,{className:"fk:h-8",disabled:s||!a.trim(),onClick:()=>{D();},size:"sm",children:[s?jsx(LoaderCircleIcon,{className:"fk:size-3.5 fk:animate-spin"}):jsx(PlayIcon,{className:"fk:size-3.5"}),"Run"]})]})]}),jsx("div",{className:"fk:min-h-0 fk:flex-1",children:jsx(yn,{ariaLabel:"GraphQL query",onChange:h,onRun:()=>{D();},schema:y,theme:i,value:a})}),jsxs(ha,{className:"fk:flex fk:max-h-[45%] fk:shrink-0 fk:flex-col fk:gap-0 fk:border-t",onValueChange:E=>l(E),value:u,children:[jsxs("div",{className:"fk:flex fk:h-11 fk:shrink-0 fk:items-center fk:gap-3 fk:px-3",children:[jsxs(ia,{children:[jsx(ja,{value:"graph",children:"Graph"}),jsx(ja,{value:"table",children:"Table"}),jsx(ja,{value:"json",children:"JSON"})]}),jsx("span",{className:"fk:ml-auto fk:truncate fk:text-xs fk:text-muted-foreground","data-testid":"graph-query-stats",children:p&&!p.error?`${p.nodes.toLocaleString()} ${p.nodes===1?"node":"nodes"} \xB7 ${p.edges.toLocaleString()} ${p.edges===1?"relationship":"relationships"} \xB7 ${p.elapsedMs.toLocaleString()} ms`:null})]}),p?.error?jsx("pre",{className:"fk:m-3 fk:mt-0 fk:max-h-40 fk:shrink-0 fk:overflow-auto fk:whitespace-pre-wrap fk:rounded-md fk:border fk:border-destructive/40 fk:bg-destructive/5 fk:p-2 fk:text-xs fk:text-destructive","data-testid":"graph-query-error",children:p.error}):null,jsxs("div",{className:"fk:min-h-0 fk:overflow-auto",children:[jsxs(ka,{className:"fk:flex fk:flex-col fk:gap-3 fk:px-3 fk:pb-3 fk:text-xs fk:text-muted-foreground",value:"graph",children:[jsxs("span",{children:["Every object with an ",jsx("code",{className:"fk:font-mono",children:"_id"})," under an entity field becomes a node; a nested relationship selection becomes a line between them."]}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(o,{checked:N,id:"graph-query-append",onCheckedChange:E=>f(E===true)}),jsx(e$4,{className:"fk:text-xs fk:font-normal",htmlFor:"graph-query-append",children:"Add to the current canvas instead of replacing it"})]})]}),jsx(ka,{className:"fk:px-3 fk:pb-3",value:"table",children:w&&w.columns.length>0?jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("div",{className:"fk:overflow-x-auto fk:rounded-md fk:border",children:jsxs($,{children:[jsx(aa,{children:jsx(da,{children:w.columns.map(E=>jsx(ea,{className:"fk:h-8 fk:text-xs",children:E},E))})}),jsx(ba,{children:w.rows.map((E,P)=>jsx(da,{children:w.columns.map($=>jsx(fa,{className:"fk:max-w-56 fk:truncate fk:py-1.5 fk:text-xs",title:E[$],children:E[$]},$))},`${E._id??""}-${P}`))})]})}),w.total>Me?jsxs("span",{className:"fk:text-xs fk:text-muted-foreground",children:["First ",Me.toLocaleString()," of ",w.total.toLocaleString()," records."]}):null]}):jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:p?.data?"The response has no rows to show.":"Run a query to see its records."})}),jsx(ka,{className:"fk:px-3 fk:pb-3",value:"json",children:F?jsx("pre",{className:"fk:overflow-auto fk:rounded-md fk:border fk:bg-muted/40 fk:p-2 fk:font-mono fk:text-xs",children:F}):jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Run a query to see its response."})})]})]})]})}var Wr=250,Zr=5;function eo(e,t){let n=t.trim();return !n||e.length===0?null:{searchRequests:{searches:e.map(r=>({collection:r.plural}))},commonParams:{q:n,limit:Zr}}}function to(e){let t=useMemo(()=>q$1(e),[e]),n=useMemo(()=>gql(t.length>0?r$1(t):"query GraphTotals { __typename }"),[t]),{data:r}=useQuery(n,{skip:t.length===0});return useMemo(()=>Object.fromEntries(t.map(i=>[i.plural,r?.[`${i.plural}Total`]]).filter(i=>typeof i[1]=="number")),[t,r])}function wn({projectId:e,entities:t,colors:n,onCanvas:r,hiddenEntities:i,onStart:s$1,onHit:o$1,onToggleEntity:d}){let[S$1,T$1]=useState(""),[y]=useDebounce(S$1,Wr),c=useMemo(()=>t.filter(l=>l.attributes.some(p=>p.searchable)),[t]),a=useMemo(()=>eo(c,y),[c,y]),{results:h$1,isLoading:g}=a$1(e,a),N$1=to(t),f=useMemo(()=>new Map(t.map(l=>[l.name,l])),[t]),u=Object.keys(r).sort();return jsxs(N,{collapsible:"icon",variant:"inset",children:[jsxs(R,{children:[jsxs(S,{className:"fk:group-data-[collapsible=icon]:hidden",children:[jsxs("div",{className:"fk:relative",children:[jsx(SearchIcon,{className:"fk:pointer-events-none fk:absolute fk:left-2 fk:top-1/2 fk:size-4 fk:-translate-y-1/2 fk:text-muted-foreground"}),jsx(s,{"aria-label":"Search records to add to the canvas",className:"fk:h-8 fk:bg-background fk:pl-8 fk:shadow-none",onChange:l=>T$1(l.target.value),placeholder:c.length>0?"Search records\u2026":"No searchable entity",disabled:c.length===0,value:S$1})]}),a?jsxs("ul",{className:"fk:mt-2 fk:flex fk:flex-col fk:gap-0.5","data-testid":"graph-search-results",children:[h$1.map(l=>{let p=f.get(l._entityName),M=l[a$2(p)?.name??""];return jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:items-center fk:gap-2 fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:text-sm fk:hover:bg-sidebar-accent",onClick:()=>o$1(l._entityName,l._id),type:"button",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n[l._entityName]??"#71717a"}}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate",children:String(M??l._id)})]})},`${l._entityName}:${l._id}`)}),!g&&h$1.length===0?jsx("li",{className:"fk:px-2 fk:py-1.5 fk:text-sm fk:text-muted-foreground",children:"Nothing found"}):null]}):null]}),jsxs(S,{children:[jsx(T,{children:"Nodes"}),jsx(V,{children:t.map(l=>jsx(W,{children:jsxs(X,{onClick:()=>s$1(l),tooltip:h(l),children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n[l.name]??"#71717a"}}),jsx("span",{className:"fk:truncate",children:h(l)}),N$1[l.plural]!==void 0?jsx("span",{className:"fk:ml-auto fk:text-xs fk:text-muted-foreground",children:N$1[l.plural]?.toLocaleString()}):null]})},l.name))})]}),u.length>0?jsxs(S,{className:"fk:group-data-[collapsible=icon]:hidden",children:[jsx(T,{children:"On canvas"}),jsx("ul",{className:"fk:flex fk:flex-col","data-testid":"graph-legend",children:u.map(l=>{let p=f.get(l),M=!i.includes(l),w=`graph-legend-${l}`;return jsxs("li",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2 fk:px-2 fk:text-sm",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n[l]??"#71717a",opacity:M?1:.35}}),jsx("label",{className:"fk:min-w-0 fk:flex-1 fk:cursor-pointer fk:truncate",htmlFor:w,children:p?h(p):l}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:r[l]?.toLocaleString()}),jsx(o,{"aria-label":`Show ${p?h(p):l}`,checked:M,id:w,onCheckedChange:()=>d(l)})]},l)})})]}):null]}),jsx(P,{})]})}function Le({label:e,icon:t,disabled:n,onClick:r}){return jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsxs(b$3,{className:"fk:h-8 fk:gap-1.5 fk:px-2.5",disabled:n,onClick:r,size:"sm",variant:"ghost",children:[t,jsx("span",{className:"fk:text-xs",children:e})]})}),jsx(e$1,{children:e})]})}function An({hasSelection:e,hasNodes:t,isLoading:n,onFit:r,onExpand:i,onHide:s,onClear:o}){return jsxs("div",{className:"fk:flex fk:items-center fk:gap-0.5 fk:rounded-lg fk:border fk:bg-background fk:p-1 fk:shadow-xs","data-testid":"graph-toolbar",children:[jsx(Le,{disabled:!t,icon:jsx(ScanIcon,{className:"fk:size-3.5"}),label:"Fit",onClick:r}),jsx(v$1,{className:"fk:mx-0.5 fk:h-4",orientation:"vertical"}),jsx(Le,{disabled:!e||n,icon:n?jsx(LoaderCircleIcon,{className:"fk:size-3.5 fk:animate-spin"}):jsx(ExpandIcon,{className:"fk:size-3.5"}),label:"Expand",onClick:i}),jsx(Le,{disabled:!e,icon:jsx(EyeOffIcon,{className:"fk:size-3.5"}),label:"Hide",onClick:s}),jsx(v$1,{className:"fk:mx-0.5 fk:h-4",orientation:"vertical"}),jsx(Le,{disabled:!t,icon:jsx(EraserIcon,{className:"fk:size-3.5"}),label:"Clear",onClick:o})]})}function Ie(e,t="The records could not be loaded."){return e instanceof Error?e.message:t}function Cn({schema:e,scope:t}){let n=useApolloClient(),[r,i]=useReducer(un,Ve),[s,o]=useState(0),d$1=useRef(0),S=useCallback(async(a,h)=>{let g="ids"in h?h.ids:void 0,N="ids"in h?h.expand:false,f="limit"in h?h.limit:g?.length;o(u=>u+1);try{let l$1=(await n.query({query:gql(l({entity:a,schema:e,scope:t,expand:N})),variables:{where:g?{_id:{in:g}}:void 0,limit:f},fetchPolicy:"network-only"})).data?.[a.plural]??[];return d$1.current+=1,i({type:"merge",data:v({records:l$1,entity:a,schema:e,scope:t}),fetched:w(l$1,a)}),l$1.map(p=>d(a.name,p._id))}catch(u){return qa.error(Ie(u)),[]}finally{o(u=>u-1);}},[n,e,t]),T=useCallback(async a=>{let h=r.nodes[a],g=h?g$1(e,h.entity):void 0;!h||!g||await S(g,{ids:[h.id],expand:true});},[S,e,r.nodes]),y=useCallback(async(a$1,h)=>{let g=r.nodes[a$1],N=g?g$1(e,g.entity):void 0;if(!g||!N)return;let f=r.fetched[a$1]?.[h.name]??0;o(u=>u+1);try{let l=(await n.query({query:gql(m({entity:N,schema:e,scope:t,attribute:h})),variables:{id:g.id,offset:f,limit:a},fetchPolicy:"network-only"})).data?.[N.plural]??[];d$1.current+=1;let p=l.reduce((M,w)=>{let F=w[h.name];return M+(Array.isArray(F)?F.length:0)},0);i({type:"merge",data:v({records:l,entity:N,schema:e,scope:t}),fetched:{[a$1]:{[h.name]:f+p}}});}catch(u){qa.error(Ie(u));}finally{o(u=>u-1);}},[n,e,t,r.fetched,r.nodes]),c=useCallback(async(a,{append:h})=>{let g=performance.now(),N;try{N=gql(a);}catch(u){return {data:null,error:Ie(u,"The query could not be parsed."),elapsedMs:0,nodes:0,edges:0}}let f=d$1.current;o(u=>u+1);try{let u=await n.query({query:N,fetchPolicy:"no-cache",errorPolicy:"all",context:f$2}),l=u.data??null,p=xn({data:l,schema:e,scope:t});return p.nodes.length>0&&(!h&&!u.error&&d$1.current===f&&i({type:"clear"}),d$1.current+=1,i({type:"merge",data:p})),{data:l,error:u.error?u.error.message:null,elapsedMs:Math.round(performance.now()-g),nodes:p.nodes.length,edges:p.edges.length}}catch(u){return {data:null,error:Ie(u,"The query failed."),elapsedMs:Math.round(performance.now()-g),nodes:0,edges:0}}finally{o(u=>u-1);}},[n,e,t]);return {state:r,dispatch:i,isLoading:s>0,loadRecords:S,expandAll:T,expandAttribute:y,runQuery:c}}function Zi(){let{currentProjectId:e$3,currentProject:t,currentProjectSchema:n}=f();useEffect(()=>{e$3&&t&&e({event:"graph_opened",projectId:e$3});},[e$3,t]);let[,r]=g(),{scope:i$1}=c(),{resolvedTheme:s}=b(),o=useLocation(),d=j(),S=s==="dark"?"dark":"light",T=t?.scopes?.find(b=>b.isDefault)?.name??"default",y$1=i$1||T,c$3=r.user?.spaces,a=useMemo(()=>c$1(n,c$3),[n,c$3]),h=useMemo(()=>f$1(a),[a]),g$2=useMemo(()=>i(a,S),[a,S]),N=Cn({schema:a,scope:y$1}),{state:f$2,dispatch:u,isLoading:l,loadRecords:p,expandAll:M$1,expandAttribute:w,runQuery:F}=N,D=useRef(null),[E,P]=useState(null),[$,m]=useState(false),[x,v]=useState("explore"),A=useRef(null),G=useMemo(()=>cn(f$2),[f$2]),q=f$2.selected?f$2.nodes[f$2.selected]:void 0,Y=E?f$2.nodes[E.key]:void 0,V=Y?g$1(a,Y.entity):void 0,K$1=Object.keys(f$2.nodes).length,k$1=Object.keys(f$2.edges).length,C=K(),L=useCallback(b=>u({type:"select",key:b}),[u]),oe=useCallback(b=>{let O=f$2.nodes[b],ie=O?g$1(a,O.entity):void 0;O&&ie&&d({type:"EditEntity",payload:{entityId:O.id,entityNamePlural:ie.plural}});},[d,a,f$2.nodes]),_e=useCallback(b=>u({type:"remove",keys:[b]}),[u]),Mn=useCallback(b=>u({type:"keepOnly",keys:[b,...fn(f$2,b)]}),[u,f$2]),Gn=useCallback(b=>u({type:"togglePin",key:b}),[u]),Ln=useCallback(b=>{f$2.pinned[b]||u({type:"togglePin",key:b});},[u,f$2.pinned]),Dn=useCallback(async(b,O)=>{let ie=g$1(a,b);if(!ie)return;let[de]=await p(ie,{ids:[O],expand:true});de&&L(de);},[p,a,L]),In=useCallback((b,O)=>{P(null),w(b,O);},[w]);return useEffect(()=>{let b=y(o.search);if(!b||A.current===o.key)return;let O=g$1(a,b.entity);if(!O||a.length===0)return;A.current=o.key;let ie=b.ids.length>0?{ids:b.ids,expand:b.ids.length<=k}:{limit:b$1};p(O,ie).then(de=>{b.ids.length===1&&de[0]&&L(de[0]);});},[o.key,o.search,a,p,L]),e$3?jsxs(M,{className:"fk:h-full",defaultOpen:C,children:[jsx(wn,{colors:g$2,entities:h,hiddenEntities:f$2.hiddenEntities,onCanvas:G,onHit:(b,O)=>{Dn(b,O);},onStart:b=>{p(b,{limit:b$1});},onToggleEntity:b=>u({type:"toggleEntity",entity:b}),projectId:e$3}),jsx(Q,{className:"fk:min-w-0",children:jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0","data-testid":"graph-app",children:[jsx(vn,{hidden:x!=="query",isRunning:l,onRun:F,projectId:e$3,schema:a,schemaHash:t?.schemaHash??null,scope:y$1,theme:S},e$3),jsxs("div",{className:"fk:relative fk:min-w-0 fk:flex-1 fk:overflow-hidden fk:bg-background",children:[jsxs("div",{className:"fk:pointer-events-none fk:absolute fk:left-3 fk:right-3 fk:top-3 fk:z-10 fk:flex fk:flex-wrap fk:items-start fk:justify-between fk:gap-2",children:[jsxs("div",{className:"fk:pointer-events-auto fk:flex fk:items-center fk:gap-2",children:[jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsx(O,{className:"fk:h-8 fk:w-8 fk:rounded-lg fk:hover:bg-transparent fk:dark:hover:bg-transparent"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(An,{hasNodes:K$1>0,hasSelection:q!==void 0,isLoading:l,onClear:()=>u({type:"clear"}),onExpand:()=>{f$2.selected&&M$1(f$2.selected);},onFit:()=>D.current?.fit(),onHide:()=>{f$2.selected&&_e(f$2.selected);}})]}),jsxs("div",{"aria-label":"View",className:"fk:pointer-events-auto fk:flex fk:items-center fk:gap-0.5 fk:rounded-lg fk:border fk:bg-background fk:p-0.5 fk:shadow-xs","data-testid":"graph-mode",role:"group",children:[jsx(b$3,{"aria-pressed":x==="explore",className:"fk:h-7 fk:px-3 fk:text-xs",onClick:()=>v("explore"),size:"sm",variant:x==="explore"?"default":"ghost",children:"Explore"}),jsx(b$3,{"aria-pressed":x==="query",className:"fk:h-7 fk:px-3 fk:text-xs",onClick:()=>v("query"),size:"sm",variant:x==="query"?"default":"ghost",children:"Query"})]})]}),K$1>0?null:jsx("div",{className:"fk:pointer-events-none fk:absolute fk:inset-0 fk:flex fk:items-center fk:justify-center fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground",children:l?"Loading records\u2026":x==="query"?"Run a query to draw its result.":"Search a record or start from an entity to draw its graph."}),jsx(sn,{apiRef:D,colors:g$2,onContextMenu:(b,O)=>P({key:b,...O}),onExpand:b=>{M$1(b);},onLayoutChange:m,onPin:Ln,onSelect:L,scene:f$2,theme:S}),jsxs("div",{className:"fk:absolute fk:bottom-3 fk:left-3 fk:flex fk:max-w-[calc(100%-1.5rem)] fk:items-center fk:gap-2 fk:rounded-lg fk:border fk:bg-background fk:px-2.5 fk:py-1.5 fk:text-xs fk:text-muted-foreground fk:shadow-xs","data-testid":"graph-status",children:[jsxs("span",{children:[K$1.toLocaleString()," ",K$1===1?"node":"nodes"," \xB7 ",k$1.toLocaleString()," ",k$1===1?"relationship":"relationships"]}),$?jsx("span",{children:"\xB7 laying out\u2026"}):null,f$2.notice?jsxs("span",{className:"fk:truncate fk:text-foreground",children:["\xB7 ",f$2.notice]}):null]}),jsx(an,{isPinned:E?f$2.pinned[E.key]===true:false,menu:E,onClose:()=>P(null),onExpandAll:b=>{M$1(b);},onExpandAttribute:In,onHide:_e,onHideOthers:Mn,onOpenRecord:oe,onTogglePin:Gn,relationships:V?e$2(V):[]})]}),q?jsx(gn,{colors:g$2,isLoading:l,node:q,onClose:()=>L(null),onExpandAll:b=>{M$1(b);},onExpandAttribute:(b,O)=>{w(b,O);},onHide:_e,onOpenRecord:oe,scene:f$2,schema:a,scope:y$1}):null]})})]}):jsx("main",{className:"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground",children:"Select a project to explore its graph."})}export{Zi as Root};//# sourceMappingURL=root-NW5QG7W5.js.map
14
+ //# sourceMappingURL=root-NW5QG7W5.js.map