@flexkit/studio 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import'./index.css';import {c}from'./chunk-7YBJLUUE.js';import {createContext,useReducer,useContext,useMemo}from'react';import {jsx}from'react/jsx-runtime';import {path,has,find,propEq}from'ramda';import {useParams}from'react-router-dom';import k from'swr';var J="core.context.scope:",E={breadcrumbs:[],isRouteLoading:false,pageTitle:"",scope:"",relationships:{}},w=createContext(E),v=createContext(()=>{});function U(t,o){let{type:n,payload:e}=o;switch(n){case "setScope":return typeof localStorage<"u"&&e.projectId&&localStorage.setItem(`${J}${e.projectId}`,e.scope),{...t,scope:e.scope};case "setRelationship":return {...t,relationships:{...t.relationships,...e}};default:throw Error(`Unknown action: ${n}`)}}function Q({children:t}){let[o,n]=useReducer(U,E);return jsx(w.Provider,{value:o,children:jsx(v.Provider,{value:n,children:t})})}function I(){return useContext(w)}function Z(){return useContext(v)}var h={name:"_asset",plural:"_assets",menu:{hidden:true},attributes:[{name:"path",label:"Asset",scope:"global",options:{size:140},isEditable:true,dataType:"string",inputType:"text",previewType:"assetPreviewField",defaultValue:""},{name:"originalFilename",label:"Filename",scope:"global",options:{size:280},isEditable:true,dataType:"string",inputType:"text",previewType:"text",isPrimary:true,defaultValue:""},{name:"size",label:"Size",scope:"global",options:{size:120},isEditable:true,dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"width",label:"Width",scope:"global",options:{size:80},isEditable:true,dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"height",label:"Height",scope:"global",options:{size:80},isEditable:true,dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"mimeType",label:"Mime Type",scope:"global",options:{size:160},isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"lqip",label:"lqip",scope:"global",isHidden:true,isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"_updatedAt",label:"Last Updated",scope:"global",options:{size:140},isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"tags",label:"Tags",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",previewType:"tags",options:{size:300},relationship:{mode:"multiple",field:"name",entity:"_tag"}}]};var T={name:"_tag",plural:"_tags",menu:{hidden:true},attributes:[{name:"name",label:"Tag Name",scope:"global",options:{size:220},isEditable:true,dataType:"string",inputType:"text",previewType:"text",isPrimary:true,defaultValue:""},{name:"_updatedAt",label:"Last Updated",scope:"global",options:{size:140},isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"assets",label:"Assets",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",relationship:{mode:"multiple",field:"originalFilename",entity:"_asset"}}]};var N=createContext({contributions:{apps:[]},currentProjectId:void 0,currentProjectSchema:[],getContributionPointConfig:()=>[],plugins:[],projects:[]}),b=t=>Object.prototype.hasOwnProperty.call(t,"projectId"),C=t=>Object.prototype.hasOwnProperty.call(t,"contributes");function lt({config:t,children:o}){let{projectId:n}=useParams(),e=useMemo(()=>{let i=s=>[...s.filter(l=>l.name!==h.name&&l.name!==T.name),h,T];return t.map(s=>({...s,schema:i(s.schema)}))},[t]),r=useMemo(()=>m(["plugins"],e),[e]),u=useMemo(()=>m(["plugins"],e.filter(i=>i.projectId===n)),[e,n]),c=r.filter(i=>!b(i)&&C(i)),p=u.filter(i=>!b(i)&&C(i)),a=useMemo(()=>({contributions:{apps:x("apps",[],p)},currentProjectId:n,currentProjectSchema:e.find(i=>i.projectId===n)?.schema??[],getContributionPointConfig:(i,s=[])=>x(i,s,p),plugins:c,projects:r.filter(i=>b(i))}),[c,n,p,r]);return jsx(N.Provider,{value:{...a,contributions:{...a.contributions,apps:a.contributions.apps}},children:o})}function V(){return useContext(N)}function m(t,o){return Array.isArray(o)?o.reduce((n,e)=>path(t,e)?[...n,e,...m(t,path(t,e)??[])]:[...n,e],[]):[o]}function x(t,o=[],n){let e=["contributes",t,...o];return m(e.flat(),n).filter(r=>has("component",r))}function ut(t){let n=m(["plugins"],t).filter(e=>!b(e)&&C(e));return x("apps",[],n)}function bt(t,o){let{scope:n}=I(),{projects:e,currentProjectId:r}=V(),{schema:u,scopes:c$1}=find(propEq(r??"","projectId"))(e),p=c$1?.find(g=>g.isDefault)?.name??"default",a=o?.commonParams.q?JSON.stringify(o):null,{data:i,error:s,isLoading:d}=k(a,()=>fetch(c(t).search,{headers:{"Content-Type":"application/json"},body:JSON.stringify(o),method:"POST",mode:"cors"}).then(g=>g.json()));return {results:G(i?.results??[],t,u,n,p)??[],error:s,isLoading:d}}function B(t){return t.find(o=>o.isPrimary)?.name??t[0]?.name}function G(t,o,n,e,r){return t?.filter(u=>u?.hits?.length>0).map(u=>{let c=u,p=c.collection.replace(`${o}_`,"").replace(/_\d+$/,""),a=find(propEq(p,"plural"))(n);if(!a)return [];let i=B(a?.attributes??[]),s=a?.name??p;return c.hits.map(({document:d})=>{let l=d[i],F=(l&&typeof l!="string"?l[e]??l[r]:null)??d[i],L=Object.entries(d).reduce((O,[y,f])=>{if(y!==i&&y!=="id"&&y!=="_updatedAt"){let $=typeof f!="string"?f[e]??f[r]:f;O[y]=$;}return O},{});return {_id:d.id,_entityName:s,_entityNamePlural:p,[i]:F,...L}})}).flat()}export{J as a,Q as b,I as c,Z as d,h as e,T as f,lt as g,V as h,ut as i,bt as j};//# sourceMappingURL=chunk-MOR653JA.js.map
2
- //# sourceMappingURL=chunk-MOR653JA.js.map
1
+ import'./index.css';import {c}from'./chunk-7YBJLUUE.js';import {createContext,useReducer,useContext,useMemo}from'react';import {jsx}from'react/jsx-runtime';import {path,has,find,propEq}from'ramda';import {useParams}from'react-router-dom';import k from'swr';var J="core.context.scope:",E={breadcrumbs:[],isRouteLoading:false,pageTitle:"",scope:"",relationships:{}},w=createContext(E),v=createContext(()=>{});function U(t,o){let{type:n,payload:e}=o;switch(n){case "setScope":return typeof localStorage<"u"&&e.projectId&&localStorage.setItem(`${J}${e.projectId}`,e.scope),{...t,scope:e.scope};case "setRelationship":return {...t,relationships:{...t.relationships,...e}};default:throw Error(`Unknown action: ${n}`)}}function Q({children:t}){let[o,n]=useReducer(U,E);return jsx(w.Provider,{value:o,children:jsx(v.Provider,{value:n,children:t})})}function I(){return useContext(w)}function Z(){return useContext(v)}var h={name:"_asset",plural:"_assets",menu:{hidden:true},attributes:[{name:"path",label:"Asset",scope:"global",options:{size:140},isEditable:true,dataType:"string",inputType:"text",previewType:"assetPreviewField",defaultValue:""},{name:"originalFilename",label:"Filename",scope:"global",options:{size:280},isEditable:true,dataType:"string",inputType:"text",previewType:"text",isPrimary:true,defaultValue:""},{name:"size",label:"Size",scope:"global",options:{size:120},isEditable:true,dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"width",label:"Width",scope:"global",options:{size:80},isEditable:true,dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"height",label:"Height",scope:"global",options:{size:80},isEditable:true,dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"mimeType",label:"Mime Type",scope:"global",options:{size:160},isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"lqip",label:"lqip",scope:"global",isHidden:true,isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"_updatedAt",label:"Last Updated",scope:"global",options:{size:140},isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"tags",label:"Tags",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",previewType:"tags",options:{size:300},relationship:{mode:"multiple",field:"name",entity:"_tag"}}]};var T={name:"_tag",plural:"_tags",menu:{hidden:true},attributes:[{name:"name",label:"Tag Name",scope:"global",options:{size:220},isEditable:true,dataType:"string",inputType:"text",previewType:"text",isPrimary:true,defaultValue:""},{name:"_updatedAt",label:"Last Updated",scope:"global",options:{size:140},isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"assets",label:"Assets",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",relationship:{mode:"multiple",field:"originalFilename",entity:"_asset"}}]};var N=createContext({contributions:{apps:[]},currentProjectId:void 0,currentProjectSchema:[],getContributionPointConfig:()=>[],plugins:[],projects:[]}),b=t=>Object.prototype.hasOwnProperty.call(t,"projectId"),C=t=>Object.prototype.hasOwnProperty.call(t,"contributes");function lt({config:t,children:o}){let{projectId:n}=useParams(),e=useMemo(()=>{let i=s=>[...s.filter(l=>l.name!==h.name&&l.name!==T.name),h,T];return t.map(s=>({...s,schema:i(s.schema)}))},[t]),r=useMemo(()=>m(["plugins"],e),[e]),u=useMemo(()=>m(["plugins"],e.filter(i=>i.projectId===n)),[e,n]),c=r.filter(i=>!b(i)&&C(i)),p=u.filter(i=>!b(i)&&C(i)),a=useMemo(()=>({contributions:{apps:x("apps",[],p)},currentProjectId:n,currentProjectSchema:e.find(i=>i.projectId===n)?.schema??[],getContributionPointConfig:(i,s=[])=>x(i,s,p),plugins:c,projects:r.filter(i=>b(i))}),[c,n,p,r]);return jsx(N.Provider,{value:{...a,contributions:{...a.contributions,apps:a.contributions.apps}},children:o})}function V(){return useContext(N)}function m(t,o){return Array.isArray(o)?o.reduce((n,e)=>path(t,e)?[...n,e,...m(t,path(t,e)??[])]:[...n,e],[]):[o]}function x(t,o=[],n){let e=["contributes",t,...o];return m(e.flat(),n).filter(r=>has("component",r))}function ut(t){let n=m(["plugins"],t).filter(e=>!b(e)&&C(e));return x("apps",[],n)}function bt(t,o){let{scope:n}=I(),{projects:e,currentProjectId:r}=V(),{schema:u,scopes:c$1}=find(propEq(r??"","projectId"))(e),p=c$1?.find(g=>g.isDefault)?.name??"default",a=o?.commonParams.q?JSON.stringify(o):null,{data:i,error:s,isLoading:d}=k(a,()=>fetch(c(t).search,{headers:{"Content-Type":"application/json"},body:JSON.stringify(o),method:"POST",mode:"cors"}).then(g=>g.json()));return {results:G(i?.results??[],t,u,n,p)??[],error:s,isLoading:d}}function B(t){return t.find(o=>o.isPrimary)?.name??t[0]?.name}function G(t,o,n,e,r){return t?.filter(u=>u?.hits?.length>0).map(u=>{let c=u,p=c.collection.replace(`${o}_`,"").replace(/_\d+$/,""),a=find(propEq(p,"plural"))(n);if(!a)return [];let i=B(a?.attributes??[]),s=a?.name??p;return c.hits.map(({document:d})=>{let l=d[i],F=(l&&typeof l!="string"?l[e]??l[r]:null)??d[i],L=Object.entries(d).reduce((O,[y,f])=>{if(y!==i&&y!=="id"&&y!=="_updatedAt"){let $=typeof f!="string"?f[e]??f[r]:f;O[y]=$;}return O},{});return {_id:d.id,_entityName:s,_entityNamePlural:p,[i]:F,...L}})}).flat()}export{J as a,Q as b,I as c,Z as d,h as e,T as f,lt as g,V as h,ut as i,bt as j};//# sourceMappingURL=chunk-7DMOGZE6.js.map
2
+ //# sourceMappingURL=chunk-7DMOGZE6.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/app-context.tsx","../src/entities/assets-schema.ts","../src/entities/tags-schema.ts","../src/core/config/config-context.tsx","../src/core/use-search.tsx"],"names":["SCOPE_STORAGE_KEY","initialState","AppContext","createContext","AppDispatchContext","reducer","state","action","type","payload","AppProvider","children","dispatch","useReducer","jsx","useAppContext","useContext","useAppDispatch","assetSchema","tagSchema","ConfigContext","hasProjectIdProperty","configItem","hasContributesProperty","ConfigProvider","config","currentProjectId","useParams","enhancedConfig","useMemo","upsertReservedEntities","schema","entity","project","globalFlattenedConfig","flattenConfigByProperty","currentProjectFlattenedConfig","item","allPlugins","currentProjectPlugins","globalConfig","_getContributionPointConfig","contributionPoint","subPath","useConfig","property","acc","curr","path","pathArray","has","getApps","plugins","useSearch","projectId","searchRequest","scope","projects","scopes","find","propEq","defaultScope","s","swrKey","data","error","isLoading","useSWR","apiPaths","res","mapResults","getPrimaryAttributeName","schemaAttributes","attr","results","result","entityNamePlural","entitySchema","primaryAttributeName","entityName","document","primaryAttribute","primaryAttributeValue","attributes","key","value","scopedValue"],"mappings":"iQAMO,IAAMA,CAAAA,CAAoB,sBAE3BC,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.js","sourcesContent":["'use client';\n\nimport { createContext, useContext, useReducer } from 'react';\nimport type { Dispatch, ReactNode } from 'react';\nimport type { ActionSetRelationship, ActionSetScope, AppContextType } from './types';\n\nexport const SCOPE_STORAGE_KEY = 'core.context.scope:';\n\nconst initialState = {\n breadcrumbs: [],\n isRouteLoading: false,\n pageTitle: '',\n scope: '',\n relationships: {},\n};\n\nconst AppContext = createContext<AppContextType>(initialState);\n\nconst AppDispatchContext = createContext<Dispatch<ActionSetRelationship | ActionSetScope>>(() => {\n /* void */\n});\n\nfunction reducer(state: AppContextType, action: ActionSetRelationship | ActionSetScope): AppContextType {\n const { type, payload } = action;\n\n switch (type) {\n case 'setScope':\n if (typeof localStorage !== 'undefined' && payload.projectId) {\n localStorage.setItem(`${SCOPE_STORAGE_KEY}${payload.projectId}`, payload.scope);\n }\n\n return {\n ...state,\n scope: payload.scope,\n };\n case 'setRelationship':\n return {\n ...state,\n relationships: { ...state.relationships, ...payload },\n };\n default:\n throw Error(`Unknown action: ${type as string}`);\n }\n}\n\nexport function AppProvider({ children }: { children: ReactNode }): JSX.Element {\n const [state, dispatch] = useReducer(reducer, initialState);\n\n return (\n <AppContext.Provider value={state}>\n <AppDispatchContext.Provider value={dispatch}>{children}</AppDispatchContext.Provider>\n </AppContext.Provider>\n );\n}\n\nexport function useAppContext(): AppContextType {\n return useContext(AppContext);\n}\n\nexport function useAppDispatch(): Dispatch<ActionSetRelationship | ActionSetScope> {\n return useContext(AppDispatchContext);\n}\n","import type { Entity } from '../core/types';\n\nexport const assetSchema: Entity = {\n name: '_asset',\n plural: '_assets',\n menu: {\n hidden: true,\n },\n attributes: [\n {\n name: 'path',\n label: 'Asset',\n scope: 'global',\n options: {\n size: 140,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'assetPreviewField',\n defaultValue: '',\n },\n {\n name: 'originalFilename',\n label: 'Filename',\n scope: 'global',\n options: {\n size: 280,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n isPrimary: true,\n defaultValue: '',\n },\n {\n name: 'size',\n label: 'Size',\n scope: 'global',\n options: {\n size: 120,\n },\n isEditable: true,\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'width',\n label: 'Width',\n scope: 'global',\n options: {\n size: 80,\n },\n isEditable: true,\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'height',\n label: 'Height',\n scope: 'global',\n options: {\n size: 80,\n },\n isEditable: true,\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'mimeType',\n label: 'Mime Type',\n scope: 'global',\n options: {\n size: 160,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'lqip',\n label: 'lqip',\n scope: 'global',\n isHidden: true,\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: '_updatedAt',\n label: 'Last Updated',\n scope: 'global',\n options: {\n size: 140,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'tags',\n label: 'Tags',\n scope: 'relationship',\n dataType: 'string',\n inputType: 'relationship',\n defaultValue: '',\n previewType: 'tags',\n options: {\n size: 300,\n },\n relationship: {\n mode: 'multiple',\n field: 'name',\n entity: '_tag',\n },\n },\n ],\n};\n","import type { Entity } from '../core/types';\n\nexport const tagSchema: Entity = {\n name: '_tag',\n plural: '_tags',\n menu: {\n hidden: true,\n },\n attributes: [\n {\n name: 'name',\n label: 'Tag Name',\n scope: 'global',\n options: {\n size: 220,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n isPrimary: true,\n defaultValue: '',\n },\n {\n name: '_updatedAt',\n label: 'Last Updated',\n scope: 'global',\n options: {\n size: 140,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'assets',\n label: 'Assets',\n scope: 'relationship',\n dataType: 'string',\n inputType: 'relationship',\n defaultValue: '',\n relationship: {\n mode: 'multiple',\n field: 'originalFilename',\n entity: '_asset',\n },\n },\n ],\n};\n","'use client';\n\nimport { createContext, useContext, useMemo } from 'react';\nimport { has, path } from 'ramda';\nimport { useParams } from 'react-router-dom';\nimport { assetSchema } from '../../entities/assets-schema';\nimport { tagSchema } from '../../entities/tags-schema';\nimport type { AppOptions, PluginOptions, ProjectOptions } from './types';\nimport type { Entity } from '../types';\n\ntype Contributes = NonNullable<PluginOptions['contributes']>;\nexport interface ConfigContext {\n contributions: {\n apps: AppOptions[] | [];\n };\n currentProjectId?: string;\n currentProjectSchema: Entity[];\n getContributionPointConfig: <T extends keyof Contributes>(\n contributionPoint: T,\n subPath?: string[]\n ) => Contributes[T][] | [];\n plugins: PluginOptions[];\n projects: ProjectOptions[];\n}\n\nconst ConfigContext = createContext<ConfigContext>({\n contributions: {\n apps: [],\n },\n currentProjectId: undefined,\n currentProjectSchema: [],\n getContributionPointConfig: () => [],\n plugins: [] as PluginOptions[],\n projects: [] as ProjectOptions[],\n});\nconst hasProjectIdProperty = (configItem: ProjectOptions | PluginOptions): boolean =>\n Object.prototype.hasOwnProperty.call(configItem, 'projectId');\nconst hasContributesProperty = (configItem: ProjectOptions | PluginOptions): boolean =>\n Object.prototype.hasOwnProperty.call(configItem, 'contributes');\n\nexport function ConfigProvider({\n config,\n children,\n}: {\n config: ProjectOptions[];\n children: React.ReactNode;\n}): JSX.Element {\n /**\n * Getting the projectId from the URL via react-router-dom's useParams hook triggers a rerender of this Context\n * every time the URL changes.\n */\n const { projectId: currentProjectId } = useParams<{ projectId: string }>();\n const enhancedConfig = useMemo(() => {\n const upsertReservedEntities = (schema: Entity[]): Entity[] => {\n const withoutReserved = schema.filter(\n (entity) => entity.name !== assetSchema.name && entity.name !== tagSchema.name\n );\n\n return [...withoutReserved, assetSchema, tagSchema];\n };\n\n return config.map((project) => ({\n ...project,\n schema: upsertReservedEntities(project.schema),\n }));\n }, [config]);\n\n const globalFlattenedConfig = useMemo(() => flattenConfigByProperty(['plugins'], enhancedConfig), [enhancedConfig]);\n const currentProjectFlattenedConfig = useMemo(\n () =>\n flattenConfigByProperty(\n ['plugins'],\n enhancedConfig.filter((item) => item.projectId === currentProjectId)\n ),\n [enhancedConfig, currentProjectId]\n );\n const allPlugins = globalFlattenedConfig.filter(\n (item: ProjectOptions | PluginOptions) => !hasProjectIdProperty(item) && hasContributesProperty(item)\n ) as PluginOptions[];\n const currentProjectPlugins = currentProjectFlattenedConfig.filter(\n (item: ProjectOptions | PluginOptions) => !hasProjectIdProperty(item) && hasContributesProperty(item)\n ) as PluginOptions[];\n\n const globalConfig = useMemo(\n () => ({\n contributions: {\n apps: _getContributionPointConfig('apps', [], currentProjectPlugins),\n },\n currentProjectId,\n currentProjectSchema: enhancedConfig.find((item) => item.projectId === currentProjectId)?.schema ?? [],\n getContributionPointConfig: <T extends keyof Contributes>(\n contributionPoint: T,\n subPath: string[] = []\n ): Contributes[T][] =>\n _getContributionPointConfig(contributionPoint, subPath, currentProjectPlugins) as Contributes[T][],\n plugins: allPlugins,\n projects: globalFlattenedConfig.filter((item: ProjectOptions | PluginOptions) =>\n hasProjectIdProperty(item)\n ) as ProjectOptions[],\n }),\n [allPlugins, currentProjectId, currentProjectPlugins, globalFlattenedConfig]\n );\n\n return (\n <ConfigContext.Provider\n value={{\n ...globalConfig,\n contributions: {\n ...globalConfig.contributions,\n apps: globalConfig.contributions.apps as AppOptions[] | [],\n },\n }}\n >\n {children}\n </ConfigContext.Provider>\n );\n}\n\nexport function useConfig(): ConfigContext {\n return useContext(ConfigContext);\n}\n\nfunction flattenConfigByProperty(\n property: string[],\n config: (ProjectOptions | PluginOptions)[]\n): (ProjectOptions | PluginOptions)[] | [] {\n if (!Array.isArray(config)) {\n return [config];\n }\n\n return config.reduce<(ProjectOptions | PluginOptions)[]>((acc, curr) => {\n if (path(property, curr)) {\n return [...acc, curr, ...flattenConfigByProperty(property, path(property, curr) ?? [])];\n }\n\n return [...acc, curr];\n }, []);\n}\n\nfunction _getContributionPointConfig<T extends keyof Contributes>(\n contributionPoint: T,\n subPath: string[] = [],\n config: PluginOptions[]\n): Contributes[T] {\n const pathArray = ['contributes', contributionPoint, ...subPath];\n\n return flattenConfigByProperty(pathArray.flat(), config).filter((item) => has('component', item)) as Contributes[T];\n}\n\nexport function getApps(config: ProjectOptions[]): AppOptions[] | [] {\n const flattenedConfig = flattenConfigByProperty(['plugins'], config);\n const plugins = flattenedConfig.filter(\n (item: ProjectOptions | PluginOptions) => !hasProjectIdProperty(item) && hasContributesProperty(item)\n ) as PluginOptions[];\n return _getContributionPointConfig('apps', [], plugins) as AppOptions[] | [];\n}\n","import useSWR from 'swr';\nimport { find, propEq } from 'ramda';\nimport { apiPaths } from './api-paths';\nimport { useAppContext } from './app-context';\nimport { useConfig } from './config/config-context';\nimport type { SingleProject } from './config/types';\nimport type {\n Attribute,\n Entity,\n RawResultItem,\n RawSearchResultItems,\n SearchRequestProps,\n SearchResultItem,\n} from './types';\n\nexport function useSearch(\n projectId: string,\n searchRequest: SearchRequestProps | null\n): { results: SearchResultItem[] | []; error: Error; isLoading: boolean } {\n const { scope } = useAppContext();\n const { projects, currentProjectId } = useConfig();\n const { schema, scopes } = find(propEq(currentProjectId ?? '', 'projectId'))(projects) as SingleProject;\n const defaultScope = scopes?.find((s) => s.isDefault)?.name ?? 'default';\n const swrKey = searchRequest?.commonParams.q ? JSON.stringify(searchRequest) : null;\n const { data, error, isLoading } = useSWR(swrKey, () =>\n fetch(apiPaths(projectId).search, {\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(searchRequest),\n method: 'POST',\n mode: 'cors',\n }).then((res) => res.json() as Promise<{ results: RawSearchResultItems }>)\n );\n const results = mapResults(data?.results ?? [], projectId, schema, scope, defaultScope);\n\n return { results: results ?? [], error, isLoading };\n}\n\n/**\n * Find the name of the attribute of an entity with isPrimary === true.\n * The value of that attribute is returned as the value for the relationship attribute\n */\nfunction getPrimaryAttributeName(schemaAttributes: Attribute[]): string {\n return schemaAttributes.find((attr) => attr.isPrimary)?.name ?? schemaAttributes[0]?.name;\n}\n\nfunction mapResults(\n results: RawSearchResultItems | undefined,\n projectId: string,\n schema: Entity[],\n scope: string,\n defaultScope: string\n): SearchResultItem[] | undefined {\n return results\n ?.filter((result) => (result as RawResultItem)?.hits?.length > 0)\n .map((result) => {\n const item = result as RawResultItem;\n const entityNamePlural = item.collection.replace(`${projectId}_`, '').replace(/_\\d+$/, '');\n const entitySchema = find<Entity>(propEq(entityNamePlural, 'plural'))(schema);\n\n if (!entitySchema) {\n return [];\n }\n\n const primaryAttributeName = getPrimaryAttributeName(entitySchema?.attributes ?? []);\n const entityName = entitySchema?.name ?? entityNamePlural;\n\n // iterate over the hits and return an object with the primary attribute value first and then the rest of the attributes.\n return item.hits.map(({ document }) => {\n const primaryAttribute = document[primaryAttributeName];\n const scopedPrimaryAttribute =\n primaryAttribute && typeof primaryAttribute !== 'string'\n ? (primaryAttribute[scope] ?? primaryAttribute[defaultScope])\n : null;\n const primaryAttributeValue = scopedPrimaryAttribute ?? document[primaryAttributeName];\n const attributes = Object.entries(document).reduce(\n (acc: Omit<SearchResultItem, '_id' | '_entityName' | '_entityNamePlural'>, [key, value]) => {\n if (key !== primaryAttributeName && key !== 'id' && key !== '_updatedAt') {\n const scopedValue = typeof value !== 'string' ? (value[scope] ?? value[defaultScope]) : value;\n\n acc[key] = scopedValue;\n }\n\n return acc;\n },\n {}\n );\n\n return {\n _id: document.id,\n _entityName: entityName,\n _entityNamePlural: entityNamePlural,\n [primaryAttributeName]: primaryAttributeValue as string,\n ...attributes,\n };\n });\n })\n .flat();\n}\n"]}
1
+ {"version":3,"sources":["../src/core/app-context.tsx","../src/entities/assets-schema.ts","../src/entities/tags-schema.ts","../src/core/config/config-context.tsx","../src/core/use-search.tsx"],"names":["SCOPE_STORAGE_KEY","initialState","AppContext","createContext","AppDispatchContext","reducer","state","action","type","payload","AppProvider","children","dispatch","useReducer","jsx","useAppContext","useContext","useAppDispatch","assetSchema","tagSchema","ConfigContext","hasProjectIdProperty","configItem","hasContributesProperty","ConfigProvider","config","currentProjectId","useParams","enhancedConfig","useMemo","upsertReservedEntities","schema","entity","project","globalFlattenedConfig","flattenConfigByProperty","currentProjectFlattenedConfig","item","allPlugins","currentProjectPlugins","globalConfig","_getContributionPointConfig","contributionPoint","subPath","useConfig","property","acc","curr","path","pathArray","has","getApps","plugins","useSearch","projectId","searchRequest","scope","projects","scopes","find","propEq","defaultScope","s","swrKey","data","error","isLoading","useSWR","apiPaths","res","mapResults","getPrimaryAttributeName","schemaAttributes","attr","results","result","entityNamePlural","entitySchema","primaryAttributeName","entityName","document","primaryAttribute","primaryAttributeValue","attributes","key","value","scopedValue"],"mappings":"iQAMO,IAAMA,CAAAA,CAAoB,sBAE3BC,CAAAA,CAAe,CACnB,WAAA,CAAa,EAAC,CACd,cAAA,CAAgB,KAAA,CAChB,SAAA,CAAW,GACX,KAAA,CAAO,EAAA,CACP,aAAA,CAAe,EACjB,CAAA,CAEMC,CAAAA,CAAaC,aAAAA,CAA8BF,CAAY,CAAA,CAEvDG,CAAAA,CAAqBD,aAAAA,CAAgE,IAAM,CAEjG,CAAC,EAED,SAASE,EAAQC,CAAAA,CAAuBC,CAAAA,CAAgE,CACtG,GAAM,CAAE,IAAA,CAAAC,CAAAA,CAAM,OAAA,CAAAC,CAAQ,CAAA,CAAIF,CAAAA,CAE1B,OAAQC,CAAAA,EACN,KAAK,UAAA,CACH,OAAI,OAAO,YAAA,CAAiB,GAAA,EAAeC,CAAAA,CAAQ,SAAA,EACjD,YAAA,CAAa,OAAA,CAAQ,CAAA,EAAGT,CAAiB,GAAGS,CAAAA,CAAQ,SAAS,CAAA,CAAA,CAAIA,CAAAA,CAAQ,KAAK,CAAA,CAGzE,CACL,GAAGH,EACH,KAAA,CAAOG,CAAAA,CAA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,CAC1C,CAAClC,CAAAA,CAA0E,CAACsC,CAAAA,CAAKC,CAAK,CAAA,GAAM,CAC1F,GAAID,CAAAA,GAAQN,CAAAA,EAAwBM,CAAAA,GAAQ,IAAA,EAAQA,CAAAA,GAAQ,aAAc,CACxE,IAAME,CAAAA,CAAc,OAAOD,CAAAA,EAAU,QAAA,CAAYA,CAAAA,CAAM7B,CAAK,GAAK6B,CAAAA,CAAMxB,CAAY,CAAA,CAAKwB,CAAAA,CAExFvC,CAAAA,CAAIsC,CAAG,CAAA,CAAIE,EACb,CAEA,OAAOxC,CACT,CAAA,CACA,EACF,CAAA,CAEA,OAAO,CACL,IAAKkC,CAAAA,CAAS,EAAA,CACd,WAAA,CAAaD,CAAAA,CACb,iBAAA,CAAmBH,CAAAA,CACnB,CAACE,CAAoB,EAAGI,CAAAA,CACxB,GAAGC,CACL,CACF,CAAC,CACH,CAAC,CAAA,CACA,MACL","file":"chunk-7DMOGZE6.js","sourcesContent":["'use client';\n\nimport { createContext, useContext, useReducer } from 'react';\nimport type { Dispatch, ReactNode } from 'react';\nimport type { ActionSetRelationship, ActionSetScope, AppContextType } from './types';\n\nexport const SCOPE_STORAGE_KEY = 'core.context.scope:';\n\nconst initialState = {\n breadcrumbs: [],\n isRouteLoading: false,\n pageTitle: '',\n scope: '',\n relationships: {},\n};\n\nconst AppContext = createContext<AppContextType>(initialState);\n\nconst AppDispatchContext = createContext<Dispatch<ActionSetRelationship | ActionSetScope>>(() => {\n /* void */\n});\n\nfunction reducer(state: AppContextType, action: ActionSetRelationship | ActionSetScope): AppContextType {\n const { type, payload } = action;\n\n switch (type) {\n case 'setScope':\n if (typeof localStorage !== 'undefined' && payload.projectId) {\n localStorage.setItem(`${SCOPE_STORAGE_KEY}${payload.projectId}`, payload.scope);\n }\n\n return {\n ...state,\n scope: payload.scope,\n };\n case 'setRelationship':\n return {\n ...state,\n relationships: { ...state.relationships, ...payload },\n };\n default:\n throw Error(`Unknown action: ${type as string}`);\n }\n}\n\nexport function AppProvider({ children }: { children: ReactNode }): JSX.Element {\n const [state, dispatch] = useReducer(reducer, initialState);\n\n return (\n <AppContext.Provider value={state}>\n <AppDispatchContext.Provider value={dispatch}>{children}</AppDispatchContext.Provider>\n </AppContext.Provider>\n );\n}\n\nexport function useAppContext(): AppContextType {\n return useContext(AppContext);\n}\n\nexport function useAppDispatch(): Dispatch<ActionSetRelationship | ActionSetScope> {\n return useContext(AppDispatchContext);\n}\n","import type { Entity } from '../core/types';\n\nexport const assetSchema: Entity = {\n name: '_asset',\n plural: '_assets',\n menu: {\n hidden: true,\n },\n attributes: [\n {\n name: 'path',\n label: 'Asset',\n scope: 'global',\n options: {\n size: 140,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'assetPreviewField',\n defaultValue: '',\n },\n {\n name: 'originalFilename',\n label: 'Filename',\n scope: 'global',\n options: {\n size: 280,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n isPrimary: true,\n defaultValue: '',\n },\n {\n name: 'size',\n label: 'Size',\n scope: 'global',\n options: {\n size: 120,\n },\n isEditable: true,\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'width',\n label: 'Width',\n scope: 'global',\n options: {\n size: 80,\n },\n isEditable: true,\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'height',\n label: 'Height',\n scope: 'global',\n options: {\n size: 80,\n },\n isEditable: true,\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'mimeType',\n label: 'Mime Type',\n scope: 'global',\n options: {\n size: 160,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'lqip',\n label: 'lqip',\n scope: 'global',\n isHidden: true,\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: '_updatedAt',\n label: 'Last Updated',\n scope: 'global',\n options: {\n size: 140,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'tags',\n label: 'Tags',\n scope: 'relationship',\n dataType: 'string',\n inputType: 'relationship',\n defaultValue: '',\n previewType: 'tags',\n options: {\n size: 300,\n },\n relationship: {\n mode: 'multiple',\n field: 'name',\n entity: '_tag',\n },\n },\n ],\n};\n","import type { Entity } from '../core/types';\n\nexport const tagSchema: Entity = {\n name: '_tag',\n plural: '_tags',\n menu: {\n hidden: true,\n },\n attributes: [\n {\n name: 'name',\n label: 'Tag Name',\n scope: 'global',\n options: {\n size: 220,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n isPrimary: true,\n defaultValue: '',\n },\n {\n name: '_updatedAt',\n label: 'Last Updated',\n scope: 'global',\n options: {\n size: 140,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'assets',\n label: 'Assets',\n scope: 'relationship',\n dataType: 'string',\n inputType: 'relationship',\n defaultValue: '',\n relationship: {\n mode: 'multiple',\n field: 'originalFilename',\n entity: '_asset',\n },\n },\n ],\n};\n","'use client';\n\nimport { createContext, useContext, useMemo } from 'react';\nimport { has, path } from 'ramda';\nimport { useParams } from 'react-router-dom';\nimport { assetSchema } from '../../entities/assets-schema';\nimport { tagSchema } from '../../entities/tags-schema';\nimport type { AppOptions, PluginOptions, ProjectOptions } from './types';\nimport type { Entity } from '../types';\n\ntype Contributes = NonNullable<PluginOptions['contributes']>;\nexport interface ConfigContext {\n contributions: {\n apps: AppOptions[] | [];\n };\n currentProjectId?: string;\n currentProjectSchema: Entity[];\n getContributionPointConfig: <T extends keyof Contributes>(\n contributionPoint: T,\n subPath?: string[]\n ) => Contributes[T][] | [];\n plugins: PluginOptions[];\n projects: ProjectOptions[];\n}\n\nconst ConfigContext = createContext<ConfigContext>({\n contributions: {\n apps: [],\n },\n currentProjectId: undefined,\n currentProjectSchema: [],\n getContributionPointConfig: () => [],\n plugins: [] as PluginOptions[],\n projects: [] as ProjectOptions[],\n});\nconst hasProjectIdProperty = (configItem: ProjectOptions | PluginOptions): boolean =>\n Object.prototype.hasOwnProperty.call(configItem, 'projectId');\nconst hasContributesProperty = (configItem: ProjectOptions | PluginOptions): boolean =>\n Object.prototype.hasOwnProperty.call(configItem, 'contributes');\n\nexport function ConfigProvider({\n config,\n children,\n}: {\n config: ProjectOptions[];\n children: React.ReactNode;\n}): JSX.Element {\n /**\n * Getting the projectId from the URL via react-router-dom's useParams hook triggers a rerender of this Context\n * every time the URL changes.\n */\n const { projectId: currentProjectId } = useParams<{ projectId: string }>();\n const enhancedConfig = useMemo(() => {\n const upsertReservedEntities = (schema: Entity[]): Entity[] => {\n const withoutReserved = schema.filter(\n (entity) => entity.name !== assetSchema.name && entity.name !== tagSchema.name\n );\n\n return [...withoutReserved, assetSchema, tagSchema];\n };\n\n return config.map((project) => ({\n ...project,\n schema: upsertReservedEntities(project.schema),\n }));\n }, [config]);\n\n const globalFlattenedConfig = useMemo(() => flattenConfigByProperty(['plugins'], enhancedConfig), [enhancedConfig]);\n const currentProjectFlattenedConfig = useMemo(\n () =>\n flattenConfigByProperty(\n ['plugins'],\n enhancedConfig.filter((item) => item.projectId === currentProjectId)\n ),\n [enhancedConfig, currentProjectId]\n );\n const allPlugins = globalFlattenedConfig.filter(\n (item: ProjectOptions | PluginOptions) => !hasProjectIdProperty(item) && hasContributesProperty(item)\n ) as PluginOptions[];\n const currentProjectPlugins = currentProjectFlattenedConfig.filter(\n (item: ProjectOptions | PluginOptions) => !hasProjectIdProperty(item) && hasContributesProperty(item)\n ) as PluginOptions[];\n\n const globalConfig = useMemo(\n () => ({\n contributions: {\n apps: _getContributionPointConfig('apps', [], currentProjectPlugins),\n },\n currentProjectId,\n currentProjectSchema: enhancedConfig.find((item) => item.projectId === currentProjectId)?.schema ?? [],\n getContributionPointConfig: <T extends keyof Contributes>(\n contributionPoint: T,\n subPath: string[] = []\n ): Contributes[T][] =>\n _getContributionPointConfig(contributionPoint, subPath, currentProjectPlugins) as Contributes[T][],\n plugins: allPlugins,\n projects: globalFlattenedConfig.filter((item: ProjectOptions | PluginOptions) =>\n hasProjectIdProperty(item)\n ) as ProjectOptions[],\n }),\n [allPlugins, currentProjectId, currentProjectPlugins, globalFlattenedConfig]\n );\n\n return (\n <ConfigContext.Provider\n value={{\n ...globalConfig,\n contributions: {\n ...globalConfig.contributions,\n apps: globalConfig.contributions.apps as AppOptions[] | [],\n },\n }}\n >\n {children}\n </ConfigContext.Provider>\n );\n}\n\nexport function useConfig(): ConfigContext {\n return useContext(ConfigContext);\n}\n\nfunction flattenConfigByProperty(\n property: string[],\n config: (ProjectOptions | PluginOptions)[]\n): (ProjectOptions | PluginOptions)[] | [] {\n if (!Array.isArray(config)) {\n return [config];\n }\n\n return config.reduce<(ProjectOptions | PluginOptions)[]>((acc, curr) => {\n if (path(property, curr)) {\n return [...acc, curr, ...flattenConfigByProperty(property, path(property, curr) ?? [])];\n }\n\n return [...acc, curr];\n }, []);\n}\n\nfunction _getContributionPointConfig<T extends keyof Contributes>(\n contributionPoint: T,\n subPath: string[] = [],\n config: PluginOptions[]\n): Contributes[T] {\n const pathArray = ['contributes', contributionPoint, ...subPath];\n\n return flattenConfigByProperty(pathArray.flat(), config).filter((item) => has('component', item)) as Contributes[T];\n}\n\nexport function getApps(config: ProjectOptions[]): AppOptions[] | [] {\n const flattenedConfig = flattenConfigByProperty(['plugins'], config);\n const plugins = flattenedConfig.filter(\n (item: ProjectOptions | PluginOptions) => !hasProjectIdProperty(item) && hasContributesProperty(item)\n ) as PluginOptions[];\n return _getContributionPointConfig('apps', [], plugins) as AppOptions[] | [];\n}\n","'use client';\n\nimport useSWR from 'swr';\nimport { find, propEq } from 'ramda';\nimport { apiPaths } from './api-paths';\nimport { useAppContext } from './app-context';\nimport { useConfig } from './config/config-context';\nimport type { SingleProject } from './config/types';\nimport type {\n Attribute,\n Entity,\n RawResultItem,\n RawSearchResultItems,\n SearchRequestProps,\n SearchResultItem,\n} from './types';\n\nexport function useSearch(\n projectId: string,\n searchRequest: SearchRequestProps | null\n): { results: SearchResultItem[] | []; error: Error; isLoading: boolean } {\n const { scope } = useAppContext();\n const { projects, currentProjectId } = useConfig();\n const { schema, scopes } = find(propEq(currentProjectId ?? '', 'projectId'))(projects) as SingleProject;\n const defaultScope = scopes?.find((s) => s.isDefault)?.name ?? 'default';\n const swrKey = searchRequest?.commonParams.q ? JSON.stringify(searchRequest) : null;\n const { data, error, isLoading } = useSWR(swrKey, () =>\n fetch(apiPaths(projectId).search, {\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(searchRequest),\n method: 'POST',\n mode: 'cors',\n }).then((res) => res.json() as Promise<{ results: RawSearchResultItems }>)\n );\n const results = mapResults(data?.results ?? [], projectId, schema, scope, defaultScope);\n\n return { results: results ?? [], error, isLoading };\n}\n\n/**\n * Find the name of the attribute of an entity with isPrimary === true.\n * The value of that attribute is returned as the value for the relationship attribute\n */\nfunction getPrimaryAttributeName(schemaAttributes: Attribute[]): string {\n return schemaAttributes.find((attr) => attr.isPrimary)?.name ?? schemaAttributes[0]?.name;\n}\n\nfunction mapResults(\n results: RawSearchResultItems | undefined,\n projectId: string,\n schema: Entity[],\n scope: string,\n defaultScope: string\n): SearchResultItem[] | undefined {\n return results\n ?.filter((result) => (result as RawResultItem)?.hits?.length > 0)\n .map((result) => {\n const item = result as RawResultItem;\n const entityNamePlural = item.collection.replace(`${projectId}_`, '').replace(/_\\d+$/, '');\n const entitySchema = find<Entity>(propEq(entityNamePlural, 'plural'))(schema);\n\n if (!entitySchema) {\n return [];\n }\n\n const primaryAttributeName = getPrimaryAttributeName(entitySchema?.attributes ?? []);\n const entityName = entitySchema?.name ?? entityNamePlural;\n\n // iterate over the hits and return an object with the primary attribute value first and then the rest of the attributes.\n return item.hits.map(({ document }) => {\n const primaryAttribute = document[primaryAttributeName];\n const scopedPrimaryAttribute =\n primaryAttribute && typeof primaryAttribute !== 'string'\n ? (primaryAttribute[scope] ?? primaryAttribute[defaultScope])\n : null;\n const primaryAttributeValue = scopedPrimaryAttribute ?? document[primaryAttributeName];\n const attributes = Object.entries(document).reduce(\n (acc: Omit<SearchResultItem, '_id' | '_entityName' | '_entityNamePlural'>, [key, value]) => {\n if (key !== primaryAttributeName && key !== 'id' && key !== '_updatedAt') {\n const scopedValue = typeof value !== 'string' ? (value[scope] ?? value[defaultScope]) : value;\n\n acc[key] = scopedValue;\n }\n\n return acc;\n },\n {}\n );\n\n return {\n _id: document.id,\n _entityName: entityName,\n _entityNamePlural: entityNamePlural,\n [primaryAttributeName]: primaryAttributeValue as string,\n ...attributes,\n };\n });\n })\n .flat();\n}\n"]}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import'./index.css';import {a as a$3}from'./chunk-HIMN6EYJ.js';import {a as a$a}from'./chunk-M6EIBKCQ.js';import {a as a$b}from'./chunk-D5N42D57.js';import {a as a$9}from'./chunk-4PHVU7DD.js';import {a as a$2,b as b$7}from'./chunk-HC5NUUAJ.js';import {a as a$c}from'./chunk-5ES3TTSY.js';import {e as e$3,f as f$1,g as g$2,j,k as k$1,h as h$3,l as l$1,c as c$6,d as d$3}from'./chunk-5MTVN77Y.js';import {a as a$8,b as b$5,c as c$3,e as e$1}from'./chunk-RMSYYUQM.js';import {a as a$6,d,c as c$1,g as g$1,b as b$1,h as h$2,i}from'./chunk-2RBOTHKE.js';import {h,d as d$2,c as c$4,e as e$4,i as i$2,b as b$8,a as a$e,g as g$3,f as f$2,j as j$1}from'./chunk-MOR653JA.js';export{e as assetSchema,f as tagSchema,c as useAppContext,d as useAppDispatch,h as useConfig,j as useSearch}from'./chunk-MOR653JA.js';import {b as b$6,m,v,o,p as p$1,r,t,s,q}from'./chunk-ZOBZU47M.js';import {b as b$9,a as a$f}from'./chunk-NJN7EGGK.js';export{b as useAuth}from'./chunk-NJN7EGGK.js';import {a as a$1,b as b$3,c as c$2,d as d$1,k,e as e$2,l,p,o as o$1,m as m$1,r as r$1}from'./chunk-64KAF6GA.js';import {b as b$4,c as c$5,a as a$h}from'./chunk-7YBJLUUE.js';export{b as IMAGES_BASE_URL}from'./chunk-7YBJLUUE.js';import {a as a$5}from'./chunk-OOYWOWHR.js';import {a as a$4}from'./chunk-2WWU4XFO.js';import {a as a$7}from'./chunk-OX6FVDUT.js';import {b as b$2,a as a$d}from'./chunk-AYKEFG4H.js';export{b as DefaultValueSwitch}from'./chunk-AYKEFG4H.js';import {b,c,e,f,h as h$1,g,i as i$1,a as a$g}from'./chunk-OTQ3BR2A.js';import {a}from'./chunk-AXB7FQV2.js';import*as vt from'react';import {lazy,createContext,memo,forwardRef,useMemo,useImperativeHandle,useEffect,createElement,useId,useState,useRef,useCallback,Fragment as Fragment$1,useContext,useReducer,Suspense,startTransition}from'react';import {debug}from'debug';import {useParams,createBrowserRouter,RouterProvider,useRouteError,useLocation,Outlet,useNavigate,Navigate,NavLink,Link as Link$1,isRouteErrorResponse}from'react-router-dom';export{Outlet,useLocation,useParams}from'react-router-dom';import {ThemeProvider,useTheme}from'next-themes';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {find,propEq,equals,uniqBy,prop,map,filter,uniq,omit,pick,toPairs,props}from'ramda';import as,{useSWRConfig}from'swr';import {Text,CheckSquare,Heading1,Heading2,Heading3,List,ListOrdered,TextQuote,Code,ImageIcon,Youtube,Twitter,AlertTriangle,Image as Image$1,Upload,Search,File,Ellipsis,Download,Copy,RefreshCwOff,Maximize2,X as X$1,Calendar,ChevronsUpDown,Link,TextIcon,ChevronDown,Check,Trash,SigmaIcon,BoldIcon,ItalicIcon,UnderlineIcon,StrikethroughIcon,CodeIcon,ChevronLeftIcon,ChevronRightIcon,ChevronDownIcon,ArrowUp,TrashIcon,RefreshCcwDot,CheckCheck,ArrowDownWideNarrow,WrapText,StepForward,Trash2,AlertCircle,CirclePlus,Pencil,Settings2,Loader2,MoreHorizontal,Settings,Wrench,PackageCheck,PackageX,Moon,Sun,Monitor,Mail,LoaderCircle}from'lucide-react';import {useForm}from'react-hook-form';import*as So from'zod';import {z as z$1}from'zod';import {zodResolver}from'@hookform/resolvers/zod';import {cva}from'class-variance-authority';import {toast,Toaster}from'sonner';import {gql,ApolloClient,InMemoryCache,defaultDataIdFromObject,from,HttpLink}from'@apollo/client';export{gql}from'@apollo/client';import {useLazyQuery,useMutation,useQuery,useApolloClient,ApolloProvider}from'@apollo/client/react';import {ErrorLink}from'@apollo/client/link/error';import {ServerError,CombinedGraphQLErrors,CombinedProtocolErrors}from'@apollo/client/errors';import*as z from'@radix-ui/react-alert-dialog';import {v4}from'uuid';import {Drawer}from'vaul';import _n from'bytes';import {defaultStyles,FileIcon}from'react-file-icon';import*as Io from'@radix-ui/react-collapsible';import {format}from'date-fns';import*as Ge from'@radix-ui/react-popover';import {Popover,PopoverTrigger}from'@radix-ui/react-popover';import {getDefaultClassNames,DayPicker}from'react-day-picker';import {createSuggestionItems,Command,renderItems,EditorRoot,EditorContent,handleImageDrop,handleImagePaste,handleCommandNavigation,EditorCommand,EditorCommandEmpty,EditorCommandList,EditorCommandItem,ImageResizer,useEditor,removeAIHighlight,EditorBubble,EditorBubbleItem,addAIHighlight,getPrevText}from'novel';import {useDebouncedCallback}from'use-debounce';import {useCompletion}from'@ai-sdk/react';import Sf from'react-markdown';import {useReactTable,getFacetedUniqueValues,getFacetedRowModel,getSortedRowModel,getPaginationRowModel,getFilteredRowModel,getCoreRowModel,flexRender}from'@tanstack/react-table';export{flexRender,getCoreRowModel,getFacetedRowModel,getFacetedUniqueValues,getFilteredRowModel,getPaginationRowModel,getSortedRowModel,useReactTable}from'@tanstack/react-table';import {useVirtualizer}from'@tanstack/react-virtual';export{useVirtualizer}from'@tanstack/react-virtual';function Qr({children:e,...t}){let[o,n]=useState(false);return useEffect(()=>{n(true);},[]),o?jsx(ThemeProvider,{...t,children:e}):jsx(Fragment,{children:e})}function xo(){let[e,t]=useState(false),{theme:o,setTheme:n}=useTheme();return useEffect(()=>{t(true);},[]),e?jsxs(c$6,{size:"sm",type:"single",value:o,children:[jsx(d$3,{"aria-label":"Set dark mode",onClick:()=>{n("dark");},value:"dark",children:jsx(Moon,{className:"fk-h-4 fk-w-4"})}),jsx(d$3,{"aria-label":"Set light mode",onClick:()=>{n("light");},value:"light",children:jsx(Sun,{className:"fk-h-4 fk-w-4"})}),jsx(d$3,{"aria-label":"Set system mode",onClick:()=>{n("system");},value:"system",children:jsx(Monitor,{className:"fk-h-4 fk-w-4"})})]}):null}function Eo(){let{resolvedTheme:e}=useTheme();return jsx("div",{className:"fk-flex fk-w-full fk-h-full fk-justify-center fk-items-center fk-bg-background",children:jsxs("div",{className:"fk-flex fk-flex-col fk-items-center",children:[e==="dark"?jsxs("svg",{className:"fk-h-8 fk-w-8 fk-animate-bounce",fill:"none",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"#020817"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"white"})]}):jsxs("svg",{className:"fk-h-8 fk-w-8 fk-animate-bounce",fill:"none",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"white"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"#020817"})]}),jsx("div",{className:"fk-text-foreground fk-text-center fk-mt-4 fk-animate-pulse",children:"Loading..."})]})})}var rs=cva("fk-relative fk-w-full fk-rounded-lg fk-border fk-p-4 [&>svg~*]:fk-pl-7 [&>svg+div]:fk-translate-y-[-3px] [&>svg]:fk-absolute [&>svg]:fk-left-4 [&>svg]:fk-top-4 [&>svg]:fk-text-foreground",{variants:{variant:{default:"fk-bg-background fk-text-foreground",destructive:"fk-border-none fk-text-destructive fk-bg-destructive-foreground [&>svg]:fk-text-destructive",success:"fk-border-none fk-text-success fk-bg-success-foreground [&>svg]:fk-text-success"}},defaultVariants:{variant:"default"}}),X=vt.forwardRef(({className:e,variant:t,...o},n)=>jsx("div",{className:a(rs({variant:t}),e),ref:n,role:"alert",...o}));X.displayName="Alert";var le=vt.forwardRef(({className:e,...t},o)=>jsx("h5",{className:a("fk-mb-1 fk-font-medium fk-leading-none fk-tracking-tight",e),ref:o,...t}));le.displayName="AlertTitle";var G=vt.forwardRef(({className:e,...t},o)=>jsx("div",{className:a("fk-text-sm [&_p]:fk-leading-relaxed",e),ref:o,...t}));G.displayName="AlertDescription";var us=So.object({email:So.string().email({message:"Please enter a valid email address"})});function ln({projectId:e$1,setIsEmailLogin:t}){let[o,n]=useState(false),[r,a]=useState(false),{mutate:i}=useSWRConfig(),s=useForm({resolver:zodResolver(us),defaultValues:{email:""}}),m=new URL(c$5(e$1).loginOtpSend,a$h),{data:l,error:c$1,isLoading:u}=as(r?m.href:null,g=>fetch(g,{method:"POST",mode:"cors",body:JSON.stringify({email:s.getValues("email")})}).then(h=>h.json()),{revalidateIfStale:false,revalidateOnFocus:false,revalidateOnReconnect:false,shouldRetryOnError:false}),f=l&&"error"in l&&l.error.code,p=l&&"token"in l,k=l&&"token"in l?l.token:"";useEffect(()=>{if(!p)return;let g=0,h=setInterval(()=>{if(g>100){clearInterval(h),n(true);return}let b=new URL(c$5(e$1).loginOtpConfirm,a$h),D="/api/flexkit/set-token";fetch(`${b.href}?email=${s.getValues("email")}&token=${k}`).then(x=>{x.status===200&&x.json().then(A=>{fetch(D,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sid:A.sid})}).then(()=>{window.location.reload();}).catch(()=>{});}).catch(()=>{});}).catch(()=>{}),g++;},3e3);return ()=>{clearInterval(h);}},[s,p,e$1,k]);function d(){n(false),a(true),i(m.href);}return jsx("div",{className:"fk-w-full",children:p?jsx(X,{variant:"success",children:jsxs(G,{children:["Keep this window open and in a new tab open the link we just sent to:"," ",jsx("strong",{children:s.getValues("email")})," (",jsx(b$3,{className:"fk-p-0 hover:fk-underline dark:fk-text-background",onClick:()=>{window.location.reload();},variant:"link",children:"undo"}),")"]})}):jsx(b,{...s,children:jsxs("form",{onSubmit:g=>{s.handleSubmit(d)(g);},className:"fk-w-full fk-space-y-3 fk-mb-10",children:[f==="not_exists"&&jsx(X,{variant:"destructive",children:jsxs(G,{children:["There is no Flexkit account associated with this email address."," ",jsx("a",{className:"fk-text-black/90 dark:fk-text-white/90 fk-underline",href:`https://flexkit.io/signup/email?email=${s.getValues("email")}`,children:"Sign up?"})]})}),f==="unknown_error"||c$1?jsx(X,{variant:"destructive",children:jsxs(G,{children:["There was an unknown error, please"," ",jsx(b$3,{className:"fk-p-0 hover:fk-underline",onClick:()=>{window.location.reload();},variant:"link",children:"Try again"}),"."," "]})}):null,o?jsx(X,{variant:"destructive",children:jsxs(G,{children:["The email verification link may have expired. Please"," ",jsx(b$3,{className:"fk-p-0 hover:fk-underline",onClick:()=>{window.location.reload();},variant:"link",children:"try again"}),"."]})}):null,jsx(c,{control:s.control,defaultValue:"",name:"email",render:({field:g$1})=>jsxs(e,{children:[jsx(g,{children:jsx(a$7,{"aria-label":"Email Address",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"w-full",placeholder:"Email Address",spellCheck:false,type:"email",...g$1})}),jsx(i$1,{})]})}),jsxs(b$3,{"aria-disabled":u,className:"fk-w-full",type:"submit",disabled:!!u,children:[u?jsx(Loader2,{className:"fk-h-5 fk-w-5 fk-mr-2 fk-animate-spin"}):jsx(Mail,{className:"fk-w-5 fk-h-5 fk-mr-2"}),"Continue with Email"]}),jsx(b$3,{className:"fk-w-full fk-text-link",onClick:()=>{t(false);},variant:"link",children:"\u2190 Other Login options"})]})})})}function Wr({projectId:e}){let{projects:t}=h(),[o,n]=useState(t.find(d=>d.projectId===e)??t[0]),[r,a]=useState(false),{data:i$1,error:s,isLoading:m}=as(c$5(e).authProviders,d=>fetch(d,{mode:"cors"}).then(g=>g.json())),[l,c]=b$9(),u=new Date().getFullYear(),f=useLocation(),p=f.state?.from?.pathname??f.pathname,k=p.includes(o.projectId)?`${location.origin}${p}`:`${location.origin}${o.basePath}/${o.projectId}`;if(s)throw new Error("Error fetching auth providers");return m||l||!i$1?jsx(Eo,{}):c.user?.id?jsx(Navigate,{replace:true,state:{from:f},to:o.basePath}):jsxs(Fragment,{children:[jsxs("div",{className:"fk-container fk-relative fk-h-[calc(100vh-3rem)] fk-flex fk-items-center fk-justify-center lg:fk-px-0",children:[jsx("div",{className:"fk-w-full lg:fk-p-8",children:jsxs("div",{className:"fk-mx-auto fk-flex fk-flex-col fk-justify-center sm:fk-w-[350px]",children:[jsx("h1",{className:"fk-mb-4 fk-text-2xl fk-text-center fk-font-medium fk-tracking-tight",children:"Login to Flexkit Studio"}),t.length>1?jsxs("div",{className:"fk-flex-col fk-space-y-2 fk-mb-3",children:[jsx(a$g,{className:"fk-text-sm fk-font-normal fk-text-left fk-text-muted-foreground",htmlFor:"project",children:"Select project"}),jsxs(a$6,{defaultValue:o.projectId,onValueChange:d=>{n(t.find(g=>g.projectId===d)??t[0]);},children:[jsx(d,{className:"fk-mb-4 fk-w-full fk-h-9 fk-py-1",id:"project",children:jsx(c$1,{"aria-label":o.title,children:o.title})}),jsx(g$1,{children:t.map(d=>jsx(i,{value:d.projectId,children:d.title},d.projectId))})]})]}):null,r?jsx(ln,{projectId:e,setIsEmailLogin:a}):jsxs(Fragment,{children:[jsx("p",{className:"fk-mt-2 fk-mb-2 fk-text-sm fk-text-left fk-text-muted-foreground",children:"Choose login provider"}),jsxs("div",{className:"fk-flex fk-flex-col fk-space-y-6",children:[i$1.providers.map(d=>jsx(b$3,{asChild:true,className:`${d.button.color} ${d.button.backgroundColor} hover:${d.button.colorHover} hover:${d.button.backgroundColorHover}`,type:"button",variant:d.button.variant,children:jsxs("a",{href:ks({url:d.url,projectId:o.projectId,basePath:"/api/flexkit/get-token",fromPath:k}),children:[d.button.iconUrl?jsx("img",{alt:d.title,className:"fk-w-[20px] fk-h-[20px] fk-mr-2",src:d.button.iconUrl}):null,d.title]})},d.name)),jsx(b$3,{className:"!fk-mt-4 fk-text-sm fk-text-center fk-text-link",onClick:()=>{a(true);},variant:"link",children:"Continue with Email \u2192"})]})]}),jsxs("div",{className:"fk-flex fk-flex-col fk-items-center fk-pt-8",children:[jsxs("svg",{className:"fk-w-[7rem]",fill:"none",viewBox:"0 0 191 42",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M59.2923 38.5263H52.7518V19.433H49.5653V12.9332H52.7518V11.7145C52.7518 10.1373 53.0471 8.65569 53.638 7.26967C54.245 5.88368 55.0677 4.68089 56.1058 3.66131C57.16 2.62579 58.3817 1.81331 59.7713 1.22386C61.1609 0.618477 62.6464 0.315788 64.2276 0.315788H69.1388V6.81564H64.2276C63.5247 6.81564 62.8698 6.9431 62.2628 7.19798C61.6719 7.43696 61.1528 7.77948 60.7057 8.22554C60.2746 8.65569 59.9311 9.17344 59.6756 9.77882C59.4201 10.3683 59.2923 11.0135 59.2923 11.7145V12.9332H67.3182V19.433H59.2923V38.5263Z",fill:"currentColor"}),jsx("path",{d:"M78.6099 38.5263H71.9802V0.315788H78.6099V38.5263Z",fill:"currentColor"}),jsx("path",{d:"M93.8922 32.3923C94.146 32.4723 94.3998 32.5283 94.6536 32.5604C94.9074 32.5765 95.1615 32.5842 95.4153 32.5842C96.0497 32.5842 96.6606 32.4964 97.2476 32.3203C97.8346 32.1445 98.3817 31.8966 98.8896 31.5768C99.4131 31.2409 99.8732 30.841 100.27 30.3772C100.682 29.8973 101.015 29.3695 101.269 28.7937L106.029 33.616C105.426 34.4797 104.728 35.2553 103.934 35.9432C103.157 36.6308 102.308 37.2145 101.388 37.6944C100.484 38.1743 99.5241 38.534 98.5089 38.7741C97.5094 39.03 96.4782 39.1579 95.4153 39.1579C93.6225 39.1579 91.933 38.822 90.3465 38.1502C88.7759 37.4784 87.3957 36.5427 86.2058 35.3434C85.0319 34.1438 84.1038 32.7202 83.4218 31.0729C82.7395 29.4095 82.3983 27.5862 82.3983 25.6029C82.3983 23.5717 82.7395 21.7164 83.4218 20.037C84.1038 18.3576 85.0319 16.9262 86.2058 15.7426C87.3957 14.5591 88.7759 13.6394 90.3465 12.9836C91.933 12.3279 93.6225 12 95.4153 12C96.4782 12 97.5173 12.128 98.5325 12.3839C99.548 12.6398 100.508 13.0076 101.412 13.4875C102.332 13.9673 103.189 14.5591 103.982 15.2628C104.775 15.9505 105.473 16.7263 106.076 17.5899L93.8922 32.3923ZM97.2237 18.8854C96.9224 18.7735 96.6208 18.7015 96.3195 18.6695C96.0338 18.6375 95.7325 18.6215 95.4153 18.6215C94.5267 18.6215 93.6859 18.7895 92.8927 19.1253C92.1154 19.4452 91.4334 19.9091 90.8461 20.5168C90.2751 21.1246 89.823 21.8603 89.4898 22.724C89.1566 23.5717 88.9902 24.5313 88.9902 25.6029C88.9902 25.8428 88.9981 26.1147 89.0138 26.4186C89.0457 26.7225 89.0852 27.0344 89.133 27.3543C89.1965 27.6582 89.2679 27.9541 89.347 28.2419C89.4263 28.5298 89.5296 28.7858 89.6565 29.0097L97.2237 18.8854Z",fill:"currentColor"}),jsx("path",{d:"M132.911 38.5263H124.926L119.833 30.6401L114.693 38.5263H106.707L116.055 25.3265L106.707 12.6316H114.693L119.833 20.0129L124.926 12.6316H132.911L123.539 25.3265L132.911 38.5263Z",fill:"currentColor"}),jsx("path",{d:"M143.002 38.5263H136.383V0.315788H143.002V24.0898L151.557 12.9976H159.114L150.57 23.6485L159.114 38.5263H151.557L146.335 29.2367L143.002 34.0243V38.5263Z",fill:"currentColor"}),jsx("path",{d:"M169.848 5.93416C169.848 6.54038 169.727 7.10672 169.486 7.63317C169.262 8.15962 168.949 8.62224 168.547 9.02108C168.146 9.40396 167.672 9.71505 167.126 9.95433C166.596 10.1777 166.026 10.2893 165.416 10.2893C164.806 10.2893 164.228 10.1777 163.682 9.95433C163.152 9.71505 162.686 9.40396 162.285 9.02108C161.9 8.62224 161.586 8.15962 161.346 7.63317C161.121 7.10672 161.008 6.54038 161.008 5.93416C161.008 5.34388 161.121 4.78553 161.346 4.25908C161.586 3.71666 161.9 3.25403 162.285 2.87115C162.686 2.47232 163.152 2.16124 163.682 1.93789C164.228 1.6986 164.806 1.57895 165.416 1.57895C166.026 1.57895 166.596 1.6986 167.126 1.93789C167.672 2.16124 168.146 2.47232 168.547 2.87115C168.949 3.25403 169.262 3.71666 169.486 4.25908C169.727 4.78553 169.848 5.34388 169.848 5.93416ZM168.716 38.5263H162.092V12.8977H168.716V38.5263Z",fill:"currentColor"}),jsx("path",{d:"M186.938 38.5263C185.368 38.5263 183.892 38.2319 182.512 37.6429C181.131 37.0378 179.918 36.2178 178.871 35.183C177.839 34.1323 177.022 32.9145 176.419 31.5294C175.832 30.1442 175.539 28.6635 175.539 27.0874V19.4932H172.374V12.9976H175.539V0.315788H182.012V12.9976H189.106V19.4932H182.012V27.0874C182.012 27.772 182.139 28.4168 182.393 29.0218C182.646 29.6108 182.996 30.1282 183.44 30.574C183.884 31.0198 184.408 31.378 185.01 31.6487C185.613 31.9034 186.256 32.0308 186.938 32.0308H189.106V38.5263H186.938Z",fill:"currentColor"}),jsx("path",{d:"M19.8893 2.21053C34.8062 2.21053 39.7785 7.18421 39.7785 22.1053C39.7785 37.0263 34.8062 42 19.8893 42C4.97231 42 0 37.0263 0 22.1053C0 7.18421 4.97231 2.21053 19.8893 2.21053ZM14.7093 10.1053H7.26116L15.9804 21.9654L7.26116 34.2973H14.7093L17.4445 30.1161V14.0271L14.7093 10.1053ZM32.285 10.1053H24.8237L21.7835 14.4979V29.5995L24.8237 34.2973H32.285L23.528 21.9654L32.285 10.1053Z",fill:"currentColor"})]}),jsxs("ul",{className:"fk-flex fk-w-full fk-mt-4 fk-justify-center fk-text-xs fk-text-muted-foreground",children:[jsx("li",{className:"fk-pr-6 after:fk-content-['|'] after:fk-pl-6",children:jsx("a",{className:"fk-underline-offset-4 hover:fk-text-primary",href:"https://www.flexkit.io",children:"flexkit.io"})}),jsx("li",{className:"fk-pr-6 after:fk-content-['|'] after:fk-pl-6",children:jsx("a",{className:"fk-underline-offset-4 hover:fk-text-primary",href:"https://www.flexkit.io/docs",children:"Docs"})}),jsx("li",{className:"",children:jsx("a",{className:"fk-underline-offset-4 hover:fk-text-primary",href:"https://www.flexkit.io/privacy-policy",children:"Privacy Policy"})})]})]})]})}),jsx("div",{className:"fk-hidden !fk-text-white !fk-bg-bitbucket hover:!fk-bg-bitbucket-hover"}),jsx("div",{className:"fk-hidden !fk-bg-github hover:!fk-bg-github-hover"}),jsx("div",{className:"fk-hidden !fk-text-muted-foreground !fk-bg-white hover:!fk-bg-accent"})]}),jsx("div",{className:"fk-flex fk-justify-center fk-items-center fk-h-12 fk-text-xs fk-text-muted-foreground fk-border-t fk-border-accent",children:jsxs("div",{className:"fk-container fk-flex",children:[jsxs("div",{className:"fk-flex fk-items-center fk-mr-auto",children:[jsxs("svg",{className:"fk-h-5 fk-w-5 fk-mr-3 fk-text-black dark:fk-text-white",fill:"none",height:"48",viewBox:"0 0 48 48",width:"48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"none"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"currentColor"})]}),jsxs("p",{className:"fk-flex fk-items-center",children:["\xA9 ",u]})]}),jsx(xo,{})]})})]})}function ks({projectId:e,url:t,basePath:o,fromPath:n}){let r=new URLSearchParams;return r.set("origin",`${location.origin}${o}`),r.set("projectId",e),r.set("redirect",n),`${t}?${r.toString()}`}var hs=["PROJECT_PAUSED","PROJECT_NOT_FOUND","READ_ONLY_MODE","UNKNOWN_ERROR"],ys={PROJECT_PAUSED:"This project has been paused.",PROJECT_NOT_FOUND:"The requested project ID was not found",READ_ONLY_MODE:"This project is currently in read only mode and changes cannot be saved",UNKNOWN_ERROR:"Sorry, an unexpected error has occurred. Please try again"},Do=class e extends Error{code;constructor(t,o){super(o??ys[t]),this.name="FlexkitError",this.code=t,Object.setPrototypeOf&&Object.setPrototypeOf(this,new.target.prototype);}static from(t,o){return new e(t,o)}};function cn(e){if(!(e instanceof Error))return false;let t=e.code;return typeof t!="string"?false:hs.includes(t)}function Zr(e){if(cn(e))return e.code}function Yr({...e}){let{theme:t="system"}=useTheme();return jsx(Toaster,{className:"toaster fk-group",theme:t,toastOptions:{classNames:{toast:"group toast group-[.toaster]:fk-bg-background group-[.toaster]:fk-text-foreground group-[.toaster]:fk-border-border group-[.toaster]:fk-shadow-lg",description:"group-[.toast]:fk-text-muted-foreground",actionButton:"group-[.toast]:fk-bg-primary group-[.toast]:fk-text-primary-foreground",cancelButton:"group-[.toast]:fk-bg-muted group-[.toast]:fk-text-muted-foreground",success:"group-[.toaster]:!fk-bg-emerald-500 group-[.toaster]:!fk-border-emerald-500 group-[.toaster]:!fk-text-white"}},...e})}function oi({apps:e,version:t}){let[o,n]=useState(0),[r,a]=useState(e),[i,s]=useState([]),m=useRef(null),l$1=useLocation(),{projectId:c}=useParams(),u=e.find(p=>l$1.pathname.includes(`/${c}/${p.name}`))?.name,f=e.find(p=>l$1.pathname.includes(`/${c}/${p.name}`))?.name??e[0]?.name;return useEffect(()=>{if(m.current===null)return;let p=new ResizeObserver(()=>{n(m.current?.offsetHeight??0);});return p.observe(m.current),function(){p.disconnect();}},[u]),useEffect(()=>{let p=Math.floor(o/48)-2,k=e.slice(0,p);if(!k.find(g=>g.name===f)){let g=e.find(h=>h.name===f);k.pop(),g&&k.push(g);}let d=e.filter(g=>!k.includes(g));a(k),s(d);},[e,f,o]),u===void 0&&f?jsx(Navigate,{to:`${l$1.pathname}/${f}`}):jsx(a$8,{children:jsxs("div",{className:"fk-flex fk-flex-col fk-h-full fk-w-12 fk-bg-muted",ref:m,children:[jsxs("div",{className:"fk-grow",children:[jsx("div",{className:"fk-grid fk-grid-cols-1 fk-w-12 fk-h-auto",children:r.map(p=>jsx(b$3,{asChild:true,className:"fk-h-12 fk-w-12",variant:"ghost",children:jsxs(b$5,{children:[jsx(c$3,{asChild:true,className:"fk-h-12 fk-p-2 fk-rounded-none fk-border-2 fk-border-transparent data-[state=active]:fk-border-l-current focus-visible:fk-outline-none focus-visible:fk-ring-0 focus-visible:fk-ring-offset-0 focus-visible:fk-border-2 focus-visible:fk-border-ring focus-visible:fk-rounded-sm",children:jsx(NavLink,{className:"fk-text-muted-foreground aria-[current]:fk-text-foreground aria-[current]:fk-bg-background aria-[current]:fk-border-l-white",to:p.name,children:p.icon})}),jsx(e$1,{side:"right",children:jsx("p",{children:p.title})})]})},p.name))}),i.length>0&&jsxs(c$2,{children:[jsx(b$5,{children:jsx(d$1,{asChild:true,children:jsxs(c$3,{className:"fk-flex justify-center fk-items-center fk-h-12 fk-w-12 p-0 fk-data-[state=open]:bg-muted fk-text-muted-foreground fk-transition-colors fk-focus-visible:outline-none fk-focus-visible:border-2 fk-focus-visible:border-ring fk-focus-visible:rounded-sm",children:[jsx(MoreHorizontal,{className:"fk-w-5 fk-h-5",strokeWidth:1.5}),jsx("span",{className:"fk-sr-only",children:"View additional apps"}),jsx(e$1,{side:"right",children:jsx("p",{children:"Additional apps"})})]})})}),jsx(k,{align:"start",className:"fk-w-56",side:"right",children:i.map(p=>jsx(l,{asChild:true,children:jsx(NavLink,{to:p.name,children:p.title})},p.name))})]})]}),jsxs(c$2,{children:[jsx(b$5,{children:jsx(d$1,{asChild:true,children:jsxs(c$3,{className:"fk-flex fk-justify-center fk-items-center fk-h-12 fk-w-12 fk-p-0 fk-data-[state=open]:bg-muted fk-text-muted-foreground fk-transition-colors fk-focus-visible:outline-none fk-focus-visible:border-2 fk-focus-visible:border-ring fk-focus-visible:rounded-sm",children:[jsx(Settings,{className:"fk-w-5 fk-h-5",strokeWidth:1.5}),jsx("span",{className:"fk-sr-only",children:"Settings menu"}),jsx(e$1,{side:"right",children:jsx("p",{children:"Settings menu"})})]})})}),jsxs(k,{align:"start",className:"fk-w-60",side:"right",children:[jsx(l,{asChild:true,children:jsxs(Link$1,{to:`https://flexkit.io/dashboard/*/${c}`,target:"_blank",rel:"noopener noreferrer",children:[jsx(Wrench,{className:"fk-mr-2 fk-h-4 fk-w-4"}),jsx("span",{children:"Manage project"})]})}),jsx(p,{}),jsx(l,{disabled:t.isCurrent,onSelect:()=>{t.isCurrent;},children:t.isCurrent?jsxs(Fragment,{children:[jsx(PackageCheck,{className:"fk-mr-2 fk-h-4 fk-w-4"}),jsxs("span",{children:["Version ",t.current]})]}):jsxs(Fragment,{children:[jsx(PackageX,{className:"fk-mr-2 fk-h-4 fk-w-4"}),jsxs("span",{children:["Version ",t.current,".",jsx("br",{}),"Upgrade to ",t.latest]})]})})]})]})]})})}var Rs={"navbar.logo":lazy(()=>import('./logo-LB22KTDD.js').then(({Logo:e})=>({default:e}))),"navbar.projectSelector":lazy(()=>import('./project-selector-4G4WL2XQ.js').then(({ProjectSelector:e})=>({default:e}))),"navbar.search":lazy(()=>import('./search-CKPEOD77.js').then(({Search:e})=>({default:e}))),"navbar.userNav":lazy(()=>import('./user-nav-5LW5USDZ.js').then(({UserNav:e})=>({default:e}))),"formFields.switch":lazy(()=>import('./switch-FU7XZ34K.js').then(({Switch:e})=>({default:e}))),"formFields.text":lazy(()=>import('./text-DFG6LLN6.js').then(({Text:e})=>({default:e}))),"formFields.textarea":lazy(()=>import('./textarea-XFHA5IEI.js').then(({Textarea:e})=>({default:e}))),"previewFields.boolean":lazy(()=>import('./boolean-3ZHXDPHB.js').then(({Boolean:e})=>({default:e}))),"previewFields.asset":lazy(()=>import('./asset-65455B7V.js').then(({Asset:e})=>({default:e}))),"previewFields.text":lazy(()=>import('./text-LNFBPXBT.js').then(({Text:e})=>({default:e}))),"previewFields.editor":lazy(()=>import('./editor-ZLTDOUPT.js').then(({Editor:e})=>({default:e}))),"previewFields.datetime":lazy(()=>import('./datetime-XX4YBITU.js').then(({DateTime:e})=>({default:e})))};function Jt(e){let{getContributionPointConfig:t}=h(),[o,...n]=e.split("."),r=Rs[e],a=t(o,n);return a?.length>0?a[0]?.component:r}function ri({projectId:e,projects:t}){let{resolvedTheme:o}=useTheme(),n=Jt("navbar.logo"),r=Jt("navbar.projectSelector"),a=Jt("navbar.search"),i=Jt("navbar.userNav"),s=t.find(f=>f.projectId===e)??t[0],{basePath:m,schema:l}=s,c=useNavigate();function u(f){startTransition(()=>{c(`${m}/${e}/desk/list/${f.entityNamePlural}?id=${f.entityId}`);});}return jsxs("div",{className:"fk-flex fk-basis-14 fk-min-h-[3.5rem] fk-px-3 fk-gap-x-4 fk-border-b fk-border-border fk-z-20",children:[jsx(Suspense,{fallback:null,children:jsx(n,{theme:o,title:"Flexkit Studio"})}),jsxs("div",{className:"fk-flex fk-grow fk-shrink fk-items-center fk-gap-x-4 px-4",children:[jsx(Suspense,{fallback:null,children:jsx(r,{projectId:e,projects:t})}),jsx(Suspense,{fallback:null,children:jsx(a,{onSelect:u,projectId:e,schema:l})})]}),jsx("div",{className:"fk-flex fk-items-center",children:jsx(Suspense,{fallback:null,children:jsx(i,{projectId:e})})})]})}function ii({version:e}){let{contributions:t,projects:o}=h(),[n,r]=b$9(),{projectId:a}=useParams(),i=find(propEq(a??"","projectId"))(o);if(!i)throw new Do("PROJECT_NOT_FOUND");let{scopes:s}=i,{apps:m}=t,l=d$2(),c=useLocation();return useEffect(()=>{if(s){let u=s.find(p=>p.isDefault)||s[0],f="";typeof localStorage<"u"&&(f=localStorage.getItem(`${a$e}${a}`)??""),l({type:"setScope",payload:{projectId:a,scope:f||u.name}});}},[c]),n?jsx(Eo,{}):r.user?.id?jsxs(Fragment,{children:[jsxs("div",{className:"fk-flex fk-flex-col fk-h-full flexkit-studio","vaul-drawer-wrapper":"",children:[jsx(ri,{projectId:a??"",projects:o}),jsxs("div",{className:"fk-flex fk-h-full fk-max-h-[calc(100%-3.5rem)] fk-border-t fk-border-border fk-grow shrink",children:[jsx(oi,{apps:m,version:e}),jsx(Outlet,{})]})]}),jsx(Yr,{})]}):jsx(Wr,{projectId:a??""})}function js(e){return e?"cause"in e:false}function Rt(e){if(!e)return null;if(ServerError.is(e))return e;if(js(e)){let t=e.cause;if(ServerError.is(t))return t}return null}function It(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}var li=createContext(void 0);function un(){let e=useContext(li);if(!e)throw new Error("useGraphQLError must be used within GraphQLProvider");return e}function nl(e){return new ErrorLink(({error:t})=>{CombinedGraphQLErrors.is(t)?t.errors.forEach(({message:n,locations:r,path:a})=>{console.log(`[GraphQL error]: Message: ${n}, Location: ${r}, Path: ${a}`);}):CombinedProtocolErrors.is(t)&&t.errors.forEach(({message:n,extensions:r})=>{console.log(`[Protocol error]: Message: ${n}, Extensions: ${JSON.stringify(r)}`);});let o=Rt(t);if(o?.statusCode===400){let n=It(o.bodyText),r=null;if(n&&typeof n=="object")if(typeof n.message=="string")r=n.message;else if(Array.isArray(n.errors)){let i=n.errors[0];i&&typeof i.message=="string"&&(r=i.message);}else typeof n.error=="string"?r=n.error:r=JSON.stringify(n);else r=o.bodyText;e(r??"There is an error in your Flexkit schema (flexkit.config.ts).");}if(o){console.log(`[Network error]: ${o.message}`);return}t&&console.log(`[Network error]: ${t.message}`);})}function rl(e,t){return from([nl(t),new HttpLink({uri:`/api/flexkit/${e}/graphql`})])}function il(e,t){return new ApolloClient({link:rl(e??"",t),cache:new InMemoryCache({dataIdFromObject:o=>o._id?o._id:defaultDataIdFromObject(o)})})}function ci({children:e}){let{currentProjectId:t}=h(),[o,n]=useState(null),r=useMemo(()=>({schemaErrorMessage:o,setSchemaErrorMessage:n}),[o]);return jsx(li.Provider,{value:r,children:jsx(ApolloProvider,{client:il(t,n),children:e})})}var fi=z.Root;var pn=z.Portal,mi=vt.forwardRef(({className:e,...t},o)=>jsx(z.Overlay,{className:a("fk-fixed fk-inset-0 fk-z-50 fk-bg-overlay/75 fk-backdrop-blur-[1px] fk- data-[state=open]:fk-animate-in data-[state=closed]:fk-animate-out data-[state=closed]:fk-fade-out-0 data-[state=open]:fk-fade-in-0",e),...t,ref:o}));mi.displayName=z.Overlay.displayName;var dn=vt.forwardRef(({className:e,...t},o)=>jsxs(pn,{children:[jsx(mi,{}),jsx(z.Content,{className:a("fk-fixed fk-left-[50%] fk-top-[50%] fk-z-50 fk-grid fk-w-full fk-max-w-lg fk-translate-x-[-50%] fk-translate-y-[-50%] fk-gap-4 fk-border fk-bg-background fk-p-6 fk-shadow-lg fk-duration-200 data-[state=open]:fk-animate-in data-[state=closed]:fk-animate-out data-[state=closed]:fk-fade-out-0 data-[state=open]:fk-fade-in-0 data-[state=closed]:fk-zoom-out-95 data-[state=open]:fk-zoom-in-95 data-[state=closed]:fk-slide-out-to-left-1/2 data-[state=closed]:fk-slide-out-to-top-[48%] data-[state=open]:fk-slide-in-from-left-1/2 data-[state=open]:fk-slide-in-from-top-[48%] sm:fk-rounded-lg",e),ref:o,...t})]}));dn.displayName=z.Content.displayName;function gn({className:e,...t}){return jsx("div",{className:a("fk-flex fk-flex-col fk-space-y-2 fk-text-center sm:fk-text-left",e),...t})}gn.displayName="AlertDialogHeader";function kn({className:e,...t}){return jsx("div",{className:a("fk-flex fk-flex-col-reverse sm:fk-flex-row sm:fk-justify-end sm:fk-space-x-2",e),...t})}kn.displayName="AlertDialogFooter";var hn=vt.forwardRef(({className:e,...t},o)=>jsx(z.Title,{className:a("fk-text-lg fk-font-semibold",e),ref:o,...t}));hn.displayName=z.Title.displayName;var yn=vt.forwardRef(({className:e,...t},o)=>jsx(z.Description,{className:a("fk-text-sm fk-text-muted-foreground",e),ref:o,...t}));yn.displayName=z.Description.displayName;var vn=vt.forwardRef(({className:e,...t},o)=>jsx(z.Action,{className:a(a$1(),e),ref:o,...t}));vn.displayName=z.Action.displayName;var bn=vt.forwardRef(({className:e,...t},o)=>jsx(z.Cancel,{className:a(a$1({variant:"outline"}),"fk-mt-2 sm:fk-mt-0",e),ref:o,...t}));bn.displayName=z.Cancel.displayName;function Xt({options:e}){let[t,o]=useState(false),[n,r]=useState(false),[a,i]=useState(false);useEffect(()=>{o(true);},[]);function s(){o(false),a||e.dialogActionCancel?.(),a&&i(false);}async function m(){r(true);try{let l=e.dialogActionSubmit?.();l&&typeof l.then=="function"&&await l;}finally{i(true),o(false),r(false);}}return jsx(fi,{onOpenChange:s,open:t,children:jsx(pn,{children:jsxs(dn,{className:"sm:max-w-[425px]",children:[jsxs(gn,{children:[jsx(hn,{children:e.dialogTitle}),jsx(yn,{children:e.dialogMessage})]}),jsxs(kn,{children:[jsx(bn,{disabled:n,onClick:s,children:e.dialogCancelTitle}),jsxs(vn,{className:a$1({variant:e.isDestructive?"destructive":"default"}),disabled:n,onClick:m,children:[n?jsx(Loader2,{className:"fk-h-4 fk-w-4 fk-mr-2 fk-animate-spin"}):null,e.dialogActionLabel]})]})]})})})}var gi=createContext([]),ki=createContext(()=>{});function fl(e,t){let o=t.type;switch(t._id||(t._id=Date.now().toString()),o){case "DeleteEntity":return uniqBy(props(["type","_id"]),[...e,t]);case "AddEntity":return uniqBy(props(["type","_id"]),[...e,t]);case "EditEntity":return uniqBy(props(["type","_id"]),[...e,t]);case "EditRelationship":return uniqBy(props(["type","_id"]),[...e,t]);case "AlertDialog":return uniqBy(props(["type","_id"]),[...e,t]);case "Dismiss":return e.filter(n=>n._id!==t._id);default:throw Error(`Unknown action: ${o}`)}}function hi({children:e}){let[t,o]=useReducer(fl,[]);return jsx(gi.Provider,{value:t,children:jsx(ki.Provider,{value:o,children:e})})}function yi(){return useContext(gi)}function fe(){return useContext(ki)}var pl=["id","string"],dl=["date","datetime","duration","time"];function Zt(e,t,o){let n="(where: $where, options: $options)",r=wt(o,e),a=r?.name??e,i=r?.attributes??[],s=`$where: ${a}Where, $options: ${a}Options`;if(!r)throw new Error(`Entity '${a}' not found in the schema`);if(i.length===0)throw new Error(`Entity '${a}' has no attributes defined in the schema`);let m=W("global",i).join(`
1
+ import'./index.css';import {a as a$3}from'./chunk-HIMN6EYJ.js';import {a as a$a}from'./chunk-M6EIBKCQ.js';import {a as a$b}from'./chunk-D5N42D57.js';import {a as a$9}from'./chunk-4PHVU7DD.js';import {a as a$2,b as b$7}from'./chunk-HC5NUUAJ.js';import {a as a$c}from'./chunk-5ES3TTSY.js';import {e as e$3,f as f$1,g as g$2,j,k as k$1,h as h$3,l as l$1,c as c$6,d as d$3}from'./chunk-5MTVN77Y.js';import {a as a$8,b as b$5,c as c$3,e as e$1}from'./chunk-RMSYYUQM.js';import {a as a$6,d,c as c$1,g as g$1,b as b$1,h as h$2,i}from'./chunk-2RBOTHKE.js';import {h,d as d$2,c as c$4,e as e$4,i as i$2,b as b$8,a as a$e,g as g$3,f as f$2,j as j$1}from'./chunk-7DMOGZE6.js';export{e as assetSchema,f as tagSchema,c as useAppContext,d as useAppDispatch,h as useConfig,j as useSearch}from'./chunk-7DMOGZE6.js';import {b as b$6,m,v,o,p as p$1,r,t,s,q}from'./chunk-ZOBZU47M.js';import {b as b$9,a as a$f}from'./chunk-NJN7EGGK.js';export{b as useAuth}from'./chunk-NJN7EGGK.js';import {a as a$1,b as b$3,c as c$2,d as d$1,k,e as e$2,l,p,o as o$1,m as m$1,r as r$1}from'./chunk-64KAF6GA.js';import {b as b$4,c as c$5,a as a$h}from'./chunk-7YBJLUUE.js';export{b as IMAGES_BASE_URL}from'./chunk-7YBJLUUE.js';import {a as a$5}from'./chunk-OOYWOWHR.js';import {a as a$4}from'./chunk-2WWU4XFO.js';import {a as a$7}from'./chunk-OX6FVDUT.js';import {b as b$2,a as a$d}from'./chunk-AYKEFG4H.js';export{b as DefaultValueSwitch}from'./chunk-AYKEFG4H.js';import {b,c,e,f,h as h$1,g,i as i$1,a as a$g}from'./chunk-OTQ3BR2A.js';import {a}from'./chunk-AXB7FQV2.js';import*as vt from'react';import {lazy,createContext,memo,forwardRef,useMemo,useImperativeHandle,useEffect,createElement,useId,useState,useRef,useCallback,Fragment as Fragment$1,useContext,useReducer,Suspense,startTransition}from'react';import {debug}from'debug';import {useParams,createBrowserRouter,RouterProvider,useRouteError,useLocation,Outlet,useNavigate,Navigate,NavLink,Link as Link$1,isRouteErrorResponse}from'react-router-dom';export{Outlet,useLocation,useParams}from'react-router-dom';import {ThemeProvider,useTheme}from'next-themes';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {find,propEq,equals,uniqBy,prop,map,filter,uniq,omit,pick,toPairs,props}from'ramda';import as,{useSWRConfig}from'swr';import {Text,CheckSquare,Heading1,Heading2,Heading3,List,ListOrdered,TextQuote,Code,ImageIcon,Youtube,Twitter,AlertTriangle,Image as Image$1,Upload,Search,File,Ellipsis,Download,Copy,RefreshCwOff,Maximize2,X as X$1,Calendar,ChevronsUpDown,Link,TextIcon,ChevronDown,Check,Trash,SigmaIcon,BoldIcon,ItalicIcon,UnderlineIcon,StrikethroughIcon,CodeIcon,ChevronLeftIcon,ChevronRightIcon,ChevronDownIcon,ArrowUp,TrashIcon,RefreshCcwDot,CheckCheck,ArrowDownWideNarrow,WrapText,StepForward,Trash2,AlertCircle,CirclePlus,Pencil,Settings2,Loader2,MoreHorizontal,Settings,Wrench,PackageCheck,PackageX,Moon,Sun,Monitor,Mail,LoaderCircle}from'lucide-react';import {useForm}from'react-hook-form';import*as So from'zod';import {z as z$1}from'zod';import {zodResolver}from'@hookform/resolvers/zod';import {cva}from'class-variance-authority';import {toast,Toaster}from'sonner';import {gql,ApolloClient,InMemoryCache,defaultDataIdFromObject,from,HttpLink}from'@apollo/client';export{gql}from'@apollo/client';import {useLazyQuery,useMutation,useQuery,useApolloClient,ApolloProvider}from'@apollo/client/react';import {ErrorLink}from'@apollo/client/link/error';import {ServerError,CombinedGraphQLErrors,CombinedProtocolErrors}from'@apollo/client/errors';import*as z from'@radix-ui/react-alert-dialog';import {v4}from'uuid';import {Drawer}from'vaul';import _n from'bytes';import {defaultStyles,FileIcon}from'react-file-icon';import*as Io from'@radix-ui/react-collapsible';import {format}from'date-fns';import*as Ge from'@radix-ui/react-popover';import {Popover,PopoverTrigger}from'@radix-ui/react-popover';import {getDefaultClassNames,DayPicker}from'react-day-picker';import {createSuggestionItems,Command,renderItems,EditorRoot,EditorContent,handleImageDrop,handleImagePaste,handleCommandNavigation,EditorCommand,EditorCommandEmpty,EditorCommandList,EditorCommandItem,ImageResizer,useEditor,removeAIHighlight,EditorBubble,EditorBubbleItem,addAIHighlight,getPrevText}from'novel';import {useDebouncedCallback}from'use-debounce';import {useCompletion}from'@ai-sdk/react';import Sf from'react-markdown';import {useReactTable,getFacetedUniqueValues,getFacetedRowModel,getSortedRowModel,getPaginationRowModel,getFilteredRowModel,getCoreRowModel,flexRender}from'@tanstack/react-table';export{flexRender,getCoreRowModel,getFacetedRowModel,getFacetedUniqueValues,getFilteredRowModel,getPaginationRowModel,getSortedRowModel,useReactTable}from'@tanstack/react-table';import {useVirtualizer}from'@tanstack/react-virtual';export{useVirtualizer}from'@tanstack/react-virtual';function Qr({children:e,...t}){let[o,n]=useState(false);return useEffect(()=>{n(true);},[]),o?jsx(ThemeProvider,{...t,children:e}):jsx(Fragment,{children:e})}function xo(){let[e,t]=useState(false),{theme:o,setTheme:n}=useTheme();return useEffect(()=>{t(true);},[]),e?jsxs(c$6,{size:"sm",type:"single",value:o,children:[jsx(d$3,{"aria-label":"Set dark mode",onClick:()=>{n("dark");},value:"dark",children:jsx(Moon,{className:"fk-h-4 fk-w-4"})}),jsx(d$3,{"aria-label":"Set light mode",onClick:()=>{n("light");},value:"light",children:jsx(Sun,{className:"fk-h-4 fk-w-4"})}),jsx(d$3,{"aria-label":"Set system mode",onClick:()=>{n("system");},value:"system",children:jsx(Monitor,{className:"fk-h-4 fk-w-4"})})]}):null}function Eo(){let{resolvedTheme:e}=useTheme();return jsx("div",{className:"fk-flex fk-w-full fk-h-full fk-justify-center fk-items-center fk-bg-background",children:jsxs("div",{className:"fk-flex fk-flex-col fk-items-center",children:[e==="dark"?jsxs("svg",{className:"fk-h-8 fk-w-8 fk-animate-bounce",fill:"none",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"#020817"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"white"})]}):jsxs("svg",{className:"fk-h-8 fk-w-8 fk-animate-bounce",fill:"none",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"white"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"#020817"})]}),jsx("div",{className:"fk-text-foreground fk-text-center fk-mt-4 fk-animate-pulse",children:"Loading..."})]})})}var rs=cva("fk-relative fk-w-full fk-rounded-lg fk-border fk-p-4 [&>svg~*]:fk-pl-7 [&>svg+div]:fk-translate-y-[-3px] [&>svg]:fk-absolute [&>svg]:fk-left-4 [&>svg]:fk-top-4 [&>svg]:fk-text-foreground",{variants:{variant:{default:"fk-bg-background fk-text-foreground",destructive:"fk-border-none fk-text-destructive fk-bg-destructive-foreground [&>svg]:fk-text-destructive",success:"fk-border-none fk-text-success fk-bg-success-foreground [&>svg]:fk-text-success"}},defaultVariants:{variant:"default"}}),X=vt.forwardRef(({className:e,variant:t,...o},n)=>jsx("div",{className:a(rs({variant:t}),e),ref:n,role:"alert",...o}));X.displayName="Alert";var le=vt.forwardRef(({className:e,...t},o)=>jsx("h5",{className:a("fk-mb-1 fk-font-medium fk-leading-none fk-tracking-tight",e),ref:o,...t}));le.displayName="AlertTitle";var G=vt.forwardRef(({className:e,...t},o)=>jsx("div",{className:a("fk-text-sm [&_p]:fk-leading-relaxed",e),ref:o,...t}));G.displayName="AlertDescription";var us=So.object({email:So.string().email({message:"Please enter a valid email address"})});function ln({projectId:e$1,setIsEmailLogin:t}){let[o,n]=useState(false),[r,a]=useState(false),{mutate:i}=useSWRConfig(),s=useForm({resolver:zodResolver(us),defaultValues:{email:""}}),m=new URL(c$5(e$1).loginOtpSend,a$h),{data:l,error:c$1,isLoading:u}=as(r?m.href:null,g=>fetch(g,{method:"POST",mode:"cors",body:JSON.stringify({email:s.getValues("email")})}).then(h=>h.json()),{revalidateIfStale:false,revalidateOnFocus:false,revalidateOnReconnect:false,shouldRetryOnError:false}),f=l&&"error"in l&&l.error.code,p=l&&"token"in l,k=l&&"token"in l?l.token:"";useEffect(()=>{if(!p)return;let g=0,h=setInterval(()=>{if(g>100){clearInterval(h),n(true);return}let b=new URL(c$5(e$1).loginOtpConfirm,a$h),D="/api/flexkit/set-token";fetch(`${b.href}?email=${s.getValues("email")}&token=${k}`).then(x=>{x.status===200&&x.json().then(A=>{fetch(D,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sid:A.sid})}).then(()=>{window.location.reload();}).catch(()=>{});}).catch(()=>{});}).catch(()=>{}),g++;},3e3);return ()=>{clearInterval(h);}},[s,p,e$1,k]);function d(){n(false),a(true),i(m.href);}return jsx("div",{className:"fk-w-full",children:p?jsx(X,{variant:"success",children:jsxs(G,{children:["Keep this window open and in a new tab open the link we just sent to:"," ",jsx("strong",{children:s.getValues("email")})," (",jsx(b$3,{className:"fk-p-0 hover:fk-underline dark:fk-text-background",onClick:()=>{window.location.reload();},variant:"link",children:"undo"}),")"]})}):jsx(b,{...s,children:jsxs("form",{onSubmit:g=>{s.handleSubmit(d)(g);},className:"fk-w-full fk-space-y-3 fk-mb-10",children:[f==="not_exists"&&jsx(X,{variant:"destructive",children:jsxs(G,{children:["There is no Flexkit account associated with this email address."," ",jsx("a",{className:"fk-text-black/90 dark:fk-text-white/90 fk-underline",href:`https://flexkit.io/signup/email?email=${s.getValues("email")}`,children:"Sign up?"})]})}),f==="unknown_error"||c$1?jsx(X,{variant:"destructive",children:jsxs(G,{children:["There was an unknown error, please"," ",jsx(b$3,{className:"fk-p-0 hover:fk-underline",onClick:()=>{window.location.reload();},variant:"link",children:"Try again"}),"."," "]})}):null,o?jsx(X,{variant:"destructive",children:jsxs(G,{children:["The email verification link may have expired. Please"," ",jsx(b$3,{className:"fk-p-0 hover:fk-underline",onClick:()=>{window.location.reload();},variant:"link",children:"try again"}),"."]})}):null,jsx(c,{control:s.control,defaultValue:"",name:"email",render:({field:g$1})=>jsxs(e,{children:[jsx(g,{children:jsx(a$7,{"aria-label":"Email Address",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"w-full",placeholder:"Email Address",spellCheck:false,type:"email",...g$1})}),jsx(i$1,{})]})}),jsxs(b$3,{"aria-disabled":u,className:"fk-w-full",type:"submit",disabled:!!u,children:[u?jsx(Loader2,{className:"fk-h-5 fk-w-5 fk-mr-2 fk-animate-spin"}):jsx(Mail,{className:"fk-w-5 fk-h-5 fk-mr-2"}),"Continue with Email"]}),jsx(b$3,{className:"fk-w-full fk-text-link",onClick:()=>{t(false);},variant:"link",children:"\u2190 Other Login options"})]})})})}function Wr({projectId:e}){let{projects:t}=h(),[o,n]=useState(t.find(d=>d.projectId===e)??t[0]),[r,a]=useState(false),{data:i$1,error:s,isLoading:m}=as(c$5(e).authProviders,d=>fetch(d,{mode:"cors"}).then(g=>g.json())),[l,c]=b$9(),u=new Date().getFullYear(),f=useLocation(),p=f.state?.from?.pathname??f.pathname,k=p.includes(o.projectId)?`${location.origin}${p}`:`${location.origin}${o.basePath}/${o.projectId}`;if(s)throw new Error("Error fetching auth providers");return m||l||!i$1?jsx(Eo,{}):c.user?.id?jsx(Navigate,{replace:true,state:{from:f},to:o.basePath}):jsxs(Fragment,{children:[jsxs("div",{className:"fk-container fk-relative fk-h-[calc(100vh-3rem)] fk-flex fk-items-center fk-justify-center lg:fk-px-0",children:[jsx("div",{className:"fk-w-full lg:fk-p-8",children:jsxs("div",{className:"fk-mx-auto fk-flex fk-flex-col fk-justify-center sm:fk-w-[350px]",children:[jsx("h1",{className:"fk-mb-4 fk-text-2xl fk-text-center fk-font-medium fk-tracking-tight",children:"Login to Flexkit Studio"}),t.length>1?jsxs("div",{className:"fk-flex-col fk-space-y-2 fk-mb-3",children:[jsx(a$g,{className:"fk-text-sm fk-font-normal fk-text-left fk-text-muted-foreground",htmlFor:"project",children:"Select project"}),jsxs(a$6,{defaultValue:o.projectId,onValueChange:d=>{n(t.find(g=>g.projectId===d)??t[0]);},children:[jsx(d,{className:"fk-mb-4 fk-w-full fk-h-9 fk-py-1",id:"project",children:jsx(c$1,{"aria-label":o.title,children:o.title})}),jsx(g$1,{children:t.map(d=>jsx(i,{value:d.projectId,children:d.title},d.projectId))})]})]}):null,r?jsx(ln,{projectId:e,setIsEmailLogin:a}):jsxs(Fragment,{children:[jsx("p",{className:"fk-mt-2 fk-mb-2 fk-text-sm fk-text-left fk-text-muted-foreground",children:"Choose login provider"}),jsxs("div",{className:"fk-flex fk-flex-col fk-space-y-6",children:[i$1.providers.map(d=>jsx(b$3,{asChild:true,className:`${d.button.color} ${d.button.backgroundColor} hover:${d.button.colorHover} hover:${d.button.backgroundColorHover}`,type:"button",variant:d.button.variant,children:jsxs("a",{href:ks({url:d.url,projectId:o.projectId,basePath:"/api/flexkit/get-token",fromPath:k}),children:[d.button.iconUrl?jsx("img",{alt:d.title,className:"fk-w-[20px] fk-h-[20px] fk-mr-2",src:d.button.iconUrl}):null,d.title]})},d.name)),jsx(b$3,{className:"!fk-mt-4 fk-text-sm fk-text-center fk-text-link",onClick:()=>{a(true);},variant:"link",children:"Continue with Email \u2192"})]})]}),jsxs("div",{className:"fk-flex fk-flex-col fk-items-center fk-pt-8",children:[jsxs("svg",{className:"fk-w-[7rem]",fill:"none",viewBox:"0 0 191 42",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M59.2923 38.5263H52.7518V19.433H49.5653V12.9332H52.7518V11.7145C52.7518 10.1373 53.0471 8.65569 53.638 7.26967C54.245 5.88368 55.0677 4.68089 56.1058 3.66131C57.16 2.62579 58.3817 1.81331 59.7713 1.22386C61.1609 0.618477 62.6464 0.315788 64.2276 0.315788H69.1388V6.81564H64.2276C63.5247 6.81564 62.8698 6.9431 62.2628 7.19798C61.6719 7.43696 61.1528 7.77948 60.7057 8.22554C60.2746 8.65569 59.9311 9.17344 59.6756 9.77882C59.4201 10.3683 59.2923 11.0135 59.2923 11.7145V12.9332H67.3182V19.433H59.2923V38.5263Z",fill:"currentColor"}),jsx("path",{d:"M78.6099 38.5263H71.9802V0.315788H78.6099V38.5263Z",fill:"currentColor"}),jsx("path",{d:"M93.8922 32.3923C94.146 32.4723 94.3998 32.5283 94.6536 32.5604C94.9074 32.5765 95.1615 32.5842 95.4153 32.5842C96.0497 32.5842 96.6606 32.4964 97.2476 32.3203C97.8346 32.1445 98.3817 31.8966 98.8896 31.5768C99.4131 31.2409 99.8732 30.841 100.27 30.3772C100.682 29.8973 101.015 29.3695 101.269 28.7937L106.029 33.616C105.426 34.4797 104.728 35.2553 103.934 35.9432C103.157 36.6308 102.308 37.2145 101.388 37.6944C100.484 38.1743 99.5241 38.534 98.5089 38.7741C97.5094 39.03 96.4782 39.1579 95.4153 39.1579C93.6225 39.1579 91.933 38.822 90.3465 38.1502C88.7759 37.4784 87.3957 36.5427 86.2058 35.3434C85.0319 34.1438 84.1038 32.7202 83.4218 31.0729C82.7395 29.4095 82.3983 27.5862 82.3983 25.6029C82.3983 23.5717 82.7395 21.7164 83.4218 20.037C84.1038 18.3576 85.0319 16.9262 86.2058 15.7426C87.3957 14.5591 88.7759 13.6394 90.3465 12.9836C91.933 12.3279 93.6225 12 95.4153 12C96.4782 12 97.5173 12.128 98.5325 12.3839C99.548 12.6398 100.508 13.0076 101.412 13.4875C102.332 13.9673 103.189 14.5591 103.982 15.2628C104.775 15.9505 105.473 16.7263 106.076 17.5899L93.8922 32.3923ZM97.2237 18.8854C96.9224 18.7735 96.6208 18.7015 96.3195 18.6695C96.0338 18.6375 95.7325 18.6215 95.4153 18.6215C94.5267 18.6215 93.6859 18.7895 92.8927 19.1253C92.1154 19.4452 91.4334 19.9091 90.8461 20.5168C90.2751 21.1246 89.823 21.8603 89.4898 22.724C89.1566 23.5717 88.9902 24.5313 88.9902 25.6029C88.9902 25.8428 88.9981 26.1147 89.0138 26.4186C89.0457 26.7225 89.0852 27.0344 89.133 27.3543C89.1965 27.6582 89.2679 27.9541 89.347 28.2419C89.4263 28.5298 89.5296 28.7858 89.6565 29.0097L97.2237 18.8854Z",fill:"currentColor"}),jsx("path",{d:"M132.911 38.5263H124.926L119.833 30.6401L114.693 38.5263H106.707L116.055 25.3265L106.707 12.6316H114.693L119.833 20.0129L124.926 12.6316H132.911L123.539 25.3265L132.911 38.5263Z",fill:"currentColor"}),jsx("path",{d:"M143.002 38.5263H136.383V0.315788H143.002V24.0898L151.557 12.9976H159.114L150.57 23.6485L159.114 38.5263H151.557L146.335 29.2367L143.002 34.0243V38.5263Z",fill:"currentColor"}),jsx("path",{d:"M169.848 5.93416C169.848 6.54038 169.727 7.10672 169.486 7.63317C169.262 8.15962 168.949 8.62224 168.547 9.02108C168.146 9.40396 167.672 9.71505 167.126 9.95433C166.596 10.1777 166.026 10.2893 165.416 10.2893C164.806 10.2893 164.228 10.1777 163.682 9.95433C163.152 9.71505 162.686 9.40396 162.285 9.02108C161.9 8.62224 161.586 8.15962 161.346 7.63317C161.121 7.10672 161.008 6.54038 161.008 5.93416C161.008 5.34388 161.121 4.78553 161.346 4.25908C161.586 3.71666 161.9 3.25403 162.285 2.87115C162.686 2.47232 163.152 2.16124 163.682 1.93789C164.228 1.6986 164.806 1.57895 165.416 1.57895C166.026 1.57895 166.596 1.6986 167.126 1.93789C167.672 2.16124 168.146 2.47232 168.547 2.87115C168.949 3.25403 169.262 3.71666 169.486 4.25908C169.727 4.78553 169.848 5.34388 169.848 5.93416ZM168.716 38.5263H162.092V12.8977H168.716V38.5263Z",fill:"currentColor"}),jsx("path",{d:"M186.938 38.5263C185.368 38.5263 183.892 38.2319 182.512 37.6429C181.131 37.0378 179.918 36.2178 178.871 35.183C177.839 34.1323 177.022 32.9145 176.419 31.5294C175.832 30.1442 175.539 28.6635 175.539 27.0874V19.4932H172.374V12.9976H175.539V0.315788H182.012V12.9976H189.106V19.4932H182.012V27.0874C182.012 27.772 182.139 28.4168 182.393 29.0218C182.646 29.6108 182.996 30.1282 183.44 30.574C183.884 31.0198 184.408 31.378 185.01 31.6487C185.613 31.9034 186.256 32.0308 186.938 32.0308H189.106V38.5263H186.938Z",fill:"currentColor"}),jsx("path",{d:"M19.8893 2.21053C34.8062 2.21053 39.7785 7.18421 39.7785 22.1053C39.7785 37.0263 34.8062 42 19.8893 42C4.97231 42 0 37.0263 0 22.1053C0 7.18421 4.97231 2.21053 19.8893 2.21053ZM14.7093 10.1053H7.26116L15.9804 21.9654L7.26116 34.2973H14.7093L17.4445 30.1161V14.0271L14.7093 10.1053ZM32.285 10.1053H24.8237L21.7835 14.4979V29.5995L24.8237 34.2973H32.285L23.528 21.9654L32.285 10.1053Z",fill:"currentColor"})]}),jsxs("ul",{className:"fk-flex fk-w-full fk-mt-4 fk-justify-center fk-text-xs fk-text-muted-foreground",children:[jsx("li",{className:"fk-pr-6 after:fk-content-['|'] after:fk-pl-6",children:jsx("a",{className:"fk-underline-offset-4 hover:fk-text-primary",href:"https://www.flexkit.io",children:"flexkit.io"})}),jsx("li",{className:"fk-pr-6 after:fk-content-['|'] after:fk-pl-6",children:jsx("a",{className:"fk-underline-offset-4 hover:fk-text-primary",href:"https://www.flexkit.io/docs",children:"Docs"})}),jsx("li",{className:"",children:jsx("a",{className:"fk-underline-offset-4 hover:fk-text-primary",href:"https://www.flexkit.io/privacy-policy",children:"Privacy Policy"})})]})]})]})}),jsx("div",{className:"fk-hidden !fk-text-white !fk-bg-bitbucket hover:!fk-bg-bitbucket-hover"}),jsx("div",{className:"fk-hidden !fk-bg-github hover:!fk-bg-github-hover"}),jsx("div",{className:"fk-hidden !fk-text-muted-foreground !fk-bg-white hover:!fk-bg-accent"})]}),jsx("div",{className:"fk-flex fk-justify-center fk-items-center fk-h-12 fk-text-xs fk-text-muted-foreground fk-border-t fk-border-accent",children:jsxs("div",{className:"fk-container fk-flex",children:[jsxs("div",{className:"fk-flex fk-items-center fk-mr-auto",children:[jsxs("svg",{className:"fk-h-5 fk-w-5 fk-mr-3 fk-text-black dark:fk-text-white",fill:"none",height:"48",viewBox:"0 0 48 48",width:"48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"none"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"currentColor"})]}),jsxs("p",{className:"fk-flex fk-items-center",children:["\xA9 ",u]})]}),jsx(xo,{})]})})]})}function ks({projectId:e,url:t,basePath:o,fromPath:n}){let r=new URLSearchParams;return r.set("origin",`${location.origin}${o}`),r.set("projectId",e),r.set("redirect",n),`${t}?${r.toString()}`}var hs=["PROJECT_PAUSED","PROJECT_NOT_FOUND","READ_ONLY_MODE","UNKNOWN_ERROR"],ys={PROJECT_PAUSED:"This project has been paused.",PROJECT_NOT_FOUND:"The requested project ID was not found",READ_ONLY_MODE:"This project is currently in read only mode and changes cannot be saved",UNKNOWN_ERROR:"Sorry, an unexpected error has occurred. Please try again"},Do=class e extends Error{code;constructor(t,o){super(o??ys[t]),this.name="FlexkitError",this.code=t,Object.setPrototypeOf&&Object.setPrototypeOf(this,new.target.prototype);}static from(t,o){return new e(t,o)}};function cn(e){if(!(e instanceof Error))return false;let t=e.code;return typeof t!="string"?false:hs.includes(t)}function Zr(e){if(cn(e))return e.code}function Yr({...e}){let{theme:t="system"}=useTheme();return jsx(Toaster,{className:"toaster fk-group",theme:t,toastOptions:{classNames:{toast:"group toast group-[.toaster]:fk-bg-background group-[.toaster]:fk-text-foreground group-[.toaster]:fk-border-border group-[.toaster]:fk-shadow-lg",description:"group-[.toast]:fk-text-muted-foreground",actionButton:"group-[.toast]:fk-bg-primary group-[.toast]:fk-text-primary-foreground",cancelButton:"group-[.toast]:fk-bg-muted group-[.toast]:fk-text-muted-foreground",success:"group-[.toaster]:!fk-bg-emerald-500 group-[.toaster]:!fk-border-emerald-500 group-[.toaster]:!fk-text-white"}},...e})}function oi({apps:e,version:t}){let[o,n]=useState(0),[r,a]=useState(e),[i,s]=useState([]),m=useRef(null),l$1=useLocation(),{projectId:c}=useParams(),u=e.find(p=>l$1.pathname.includes(`/${c}/${p.name}`))?.name,f=e.find(p=>l$1.pathname.includes(`/${c}/${p.name}`))?.name??e[0]?.name;return useEffect(()=>{if(m.current===null)return;let p=new ResizeObserver(()=>{n(m.current?.offsetHeight??0);});return p.observe(m.current),function(){p.disconnect();}},[u]),useEffect(()=>{let p=Math.floor(o/48)-2,k=e.slice(0,p);if(!k.find(g=>g.name===f)){let g=e.find(h=>h.name===f);k.pop(),g&&k.push(g);}let d=e.filter(g=>!k.includes(g));a(k),s(d);},[e,f,o]),u===void 0&&f?jsx(Navigate,{to:`${l$1.pathname}/${f}`}):jsx(a$8,{children:jsxs("div",{className:"fk-flex fk-flex-col fk-h-full fk-w-12 fk-bg-muted",ref:m,children:[jsxs("div",{className:"fk-grow",children:[jsx("div",{className:"fk-grid fk-grid-cols-1 fk-w-12 fk-h-auto",children:r.map(p=>jsx(b$3,{asChild:true,className:"fk-h-12 fk-w-12",variant:"ghost",children:jsxs(b$5,{children:[jsx(c$3,{asChild:true,className:"fk-h-12 fk-p-2 fk-rounded-none fk-border-2 fk-border-transparent data-[state=active]:fk-border-l-current focus-visible:fk-outline-none focus-visible:fk-ring-0 focus-visible:fk-ring-offset-0 focus-visible:fk-border-2 focus-visible:fk-border-ring focus-visible:fk-rounded-sm",children:jsx(NavLink,{className:"fk-text-muted-foreground aria-[current]:fk-text-foreground aria-[current]:fk-bg-background aria-[current]:fk-border-l-white",to:p.name,children:p.icon})}),jsx(e$1,{side:"right",children:jsx("p",{children:p.title})})]})},p.name))}),i.length>0&&jsxs(c$2,{children:[jsx(b$5,{children:jsx(d$1,{asChild:true,children:jsxs(c$3,{className:"fk-flex justify-center fk-items-center fk-h-12 fk-w-12 p-0 fk-data-[state=open]:bg-muted fk-text-muted-foreground fk-transition-colors fk-focus-visible:outline-none fk-focus-visible:border-2 fk-focus-visible:border-ring fk-focus-visible:rounded-sm",children:[jsx(MoreHorizontal,{className:"fk-w-5 fk-h-5",strokeWidth:1.5}),jsx("span",{className:"fk-sr-only",children:"View additional apps"}),jsx(e$1,{side:"right",children:jsx("p",{children:"Additional apps"})})]})})}),jsx(k,{align:"start",className:"fk-w-56",side:"right",children:i.map(p=>jsx(l,{asChild:true,children:jsx(NavLink,{to:p.name,children:p.title})},p.name))})]})]}),jsxs(c$2,{children:[jsx(b$5,{children:jsx(d$1,{asChild:true,children:jsxs(c$3,{className:"fk-flex fk-justify-center fk-items-center fk-h-12 fk-w-12 fk-p-0 fk-data-[state=open]:bg-muted fk-text-muted-foreground fk-transition-colors fk-focus-visible:outline-none fk-focus-visible:border-2 fk-focus-visible:border-ring fk-focus-visible:rounded-sm",children:[jsx(Settings,{className:"fk-w-5 fk-h-5",strokeWidth:1.5}),jsx("span",{className:"fk-sr-only",children:"Settings menu"}),jsx(e$1,{side:"right",children:jsx("p",{children:"Settings menu"})})]})})}),jsxs(k,{align:"start",className:"fk-w-60",side:"right",children:[jsx(l,{asChild:true,children:jsxs(Link$1,{to:`https://flexkit.io/dashboard/*/${c}`,target:"_blank",rel:"noopener noreferrer",children:[jsx(Wrench,{className:"fk-mr-2 fk-h-4 fk-w-4"}),jsx("span",{children:"Manage project"})]})}),jsx(p,{}),jsx(l,{disabled:t.isCurrent,onSelect:()=>{t.isCurrent;},children:t.isCurrent?jsxs(Fragment,{children:[jsx(PackageCheck,{className:"fk-mr-2 fk-h-4 fk-w-4"}),jsxs("span",{children:["Version ",t.current]})]}):jsxs(Fragment,{children:[jsx(PackageX,{className:"fk-mr-2 fk-h-4 fk-w-4"}),jsxs("span",{children:["Version ",t.current,".",jsx("br",{}),"Upgrade to ",t.latest]})]})})]})]})]})})}var Rs={"navbar.logo":lazy(()=>import('./logo-LB22KTDD.js').then(({Logo:e})=>({default:e}))),"navbar.projectSelector":lazy(()=>import('./project-selector-4G4WL2XQ.js').then(({ProjectSelector:e})=>({default:e}))),"navbar.search":lazy(()=>import('./search-JJI6BIRU.js').then(({Search:e})=>({default:e}))),"navbar.userNav":lazy(()=>import('./user-nav-5LW5USDZ.js').then(({UserNav:e})=>({default:e}))),"formFields.switch":lazy(()=>import('./switch-FU7XZ34K.js').then(({Switch:e})=>({default:e}))),"formFields.text":lazy(()=>import('./text-DFG6LLN6.js').then(({Text:e})=>({default:e}))),"formFields.textarea":lazy(()=>import('./textarea-XFHA5IEI.js').then(({Textarea:e})=>({default:e}))),"previewFields.boolean":lazy(()=>import('./boolean-3ZHXDPHB.js').then(({Boolean:e})=>({default:e}))),"previewFields.asset":lazy(()=>import('./asset-65455B7V.js').then(({Asset:e})=>({default:e}))),"previewFields.text":lazy(()=>import('./text-LNFBPXBT.js').then(({Text:e})=>({default:e}))),"previewFields.editor":lazy(()=>import('./editor-ZLTDOUPT.js').then(({Editor:e})=>({default:e}))),"previewFields.datetime":lazy(()=>import('./datetime-XX4YBITU.js').then(({DateTime:e})=>({default:e})))};function Jt(e){let{getContributionPointConfig:t}=h(),[o,...n]=e.split("."),r=Rs[e],a=t(o,n);return a?.length>0?a[0]?.component:r}function ri({projectId:e,projects:t}){let{resolvedTheme:o}=useTheme(),n=Jt("navbar.logo"),r=Jt("navbar.projectSelector"),a=Jt("navbar.search"),i=Jt("navbar.userNav"),s=t.find(f=>f.projectId===e)??t[0],{basePath:m,schema:l}=s,c=useNavigate();function u(f){startTransition(()=>{c(`${m}/${e}/desk/list/${f.entityNamePlural}?id=${f.entityId}`);});}return jsxs("div",{className:"fk-flex fk-basis-14 fk-min-h-[3.5rem] fk-px-3 fk-gap-x-4 fk-border-b fk-border-border fk-z-20",children:[jsx(Suspense,{fallback:null,children:jsx(n,{theme:o,title:"Flexkit Studio"})}),jsxs("div",{className:"fk-flex fk-grow fk-shrink fk-items-center fk-gap-x-4 px-4",children:[jsx(Suspense,{fallback:null,children:jsx(r,{projectId:e,projects:t})}),jsx(Suspense,{fallback:null,children:jsx(a,{onSelect:u,projectId:e,schema:l})})]}),jsx("div",{className:"fk-flex fk-items-center",children:jsx(Suspense,{fallback:null,children:jsx(i,{projectId:e})})})]})}function ii({version:e}){let{contributions:t,projects:o}=h(),[n,r]=b$9(),{projectId:a}=useParams(),i=find(propEq(a??"","projectId"))(o);if(!i)throw new Do("PROJECT_NOT_FOUND");let{scopes:s}=i,{apps:m}=t,l=d$2(),c=useLocation();return useEffect(()=>{if(s){let u=s.find(p=>p.isDefault)||s[0],f="";typeof localStorage<"u"&&(f=localStorage.getItem(`${a$e}${a}`)??""),l({type:"setScope",payload:{projectId:a,scope:f||u.name}});}},[c]),n?jsx(Eo,{}):r.user?.id?jsxs(Fragment,{children:[jsxs("div",{className:"fk-flex fk-flex-col fk-h-full flexkit-studio","vaul-drawer-wrapper":"",children:[jsx(ri,{projectId:a??"",projects:o}),jsxs("div",{className:"fk-flex fk-h-full fk-max-h-[calc(100%-3.5rem)] fk-border-t fk-border-border fk-grow shrink",children:[jsx(oi,{apps:m,version:e}),jsx(Outlet,{})]})]}),jsx(Yr,{})]}):jsx(Wr,{projectId:a??""})}function js(e){return e?"cause"in e:false}function Rt(e){if(!e)return null;if(ServerError.is(e))return e;if(js(e)){let t=e.cause;if(ServerError.is(t))return t}return null}function It(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}var li=createContext(void 0);function un(){let e=useContext(li);if(!e)throw new Error("useGraphQLError must be used within GraphQLProvider");return e}function nl(e){return new ErrorLink(({error:t})=>{CombinedGraphQLErrors.is(t)?t.errors.forEach(({message:n,locations:r,path:a})=>{console.log(`[GraphQL error]: Message: ${n}, Location: ${r}, Path: ${a}`);}):CombinedProtocolErrors.is(t)&&t.errors.forEach(({message:n,extensions:r})=>{console.log(`[Protocol error]: Message: ${n}, Extensions: ${JSON.stringify(r)}`);});let o=Rt(t);if(o?.statusCode===400){let n=It(o.bodyText),r=null;if(n&&typeof n=="object")if(typeof n.message=="string")r=n.message;else if(Array.isArray(n.errors)){let i=n.errors[0];i&&typeof i.message=="string"&&(r=i.message);}else typeof n.error=="string"?r=n.error:r=JSON.stringify(n);else r=o.bodyText;e(r??"There is an error in your Flexkit schema (flexkit.config.ts).");}if(o){console.log(`[Network error]: ${o.message}`);return}t&&console.log(`[Network error]: ${t.message}`);})}function rl(e,t){return from([nl(t),new HttpLink({uri:`/api/flexkit/${e}/graphql`})])}function il(e,t){return new ApolloClient({link:rl(e??"",t),cache:new InMemoryCache({dataIdFromObject:o=>o._id?o._id:defaultDataIdFromObject(o)})})}function ci({children:e}){let{currentProjectId:t}=h(),[o,n]=useState(null),r=useMemo(()=>({schemaErrorMessage:o,setSchemaErrorMessage:n}),[o]);return jsx(li.Provider,{value:r,children:jsx(ApolloProvider,{client:il(t,n),children:e})})}var fi=z.Root;var pn=z.Portal,mi=vt.forwardRef(({className:e,...t},o)=>jsx(z.Overlay,{className:a("fk-fixed fk-inset-0 fk-z-50 fk-bg-overlay/75 fk-backdrop-blur-[1px] fk- data-[state=open]:fk-animate-in data-[state=closed]:fk-animate-out data-[state=closed]:fk-fade-out-0 data-[state=open]:fk-fade-in-0",e),...t,ref:o}));mi.displayName=z.Overlay.displayName;var dn=vt.forwardRef(({className:e,...t},o)=>jsxs(pn,{children:[jsx(mi,{}),jsx(z.Content,{className:a("fk-fixed fk-left-[50%] fk-top-[50%] fk-z-50 fk-grid fk-w-full fk-max-w-lg fk-translate-x-[-50%] fk-translate-y-[-50%] fk-gap-4 fk-border fk-bg-background fk-p-6 fk-shadow-lg fk-duration-200 data-[state=open]:fk-animate-in data-[state=closed]:fk-animate-out data-[state=closed]:fk-fade-out-0 data-[state=open]:fk-fade-in-0 data-[state=closed]:fk-zoom-out-95 data-[state=open]:fk-zoom-in-95 data-[state=closed]:fk-slide-out-to-left-1/2 data-[state=closed]:fk-slide-out-to-top-[48%] data-[state=open]:fk-slide-in-from-left-1/2 data-[state=open]:fk-slide-in-from-top-[48%] sm:fk-rounded-lg",e),ref:o,...t})]}));dn.displayName=z.Content.displayName;function gn({className:e,...t}){return jsx("div",{className:a("fk-flex fk-flex-col fk-space-y-2 fk-text-center sm:fk-text-left",e),...t})}gn.displayName="AlertDialogHeader";function kn({className:e,...t}){return jsx("div",{className:a("fk-flex fk-flex-col-reverse sm:fk-flex-row sm:fk-justify-end sm:fk-space-x-2",e),...t})}kn.displayName="AlertDialogFooter";var hn=vt.forwardRef(({className:e,...t},o)=>jsx(z.Title,{className:a("fk-text-lg fk-font-semibold",e),ref:o,...t}));hn.displayName=z.Title.displayName;var yn=vt.forwardRef(({className:e,...t},o)=>jsx(z.Description,{className:a("fk-text-sm fk-text-muted-foreground",e),ref:o,...t}));yn.displayName=z.Description.displayName;var vn=vt.forwardRef(({className:e,...t},o)=>jsx(z.Action,{className:a(a$1(),e),ref:o,...t}));vn.displayName=z.Action.displayName;var bn=vt.forwardRef(({className:e,...t},o)=>jsx(z.Cancel,{className:a(a$1({variant:"outline"}),"fk-mt-2 sm:fk-mt-0",e),ref:o,...t}));bn.displayName=z.Cancel.displayName;function Xt({options:e}){let[t,o]=useState(false),[n,r]=useState(false),[a,i]=useState(false);useEffect(()=>{o(true);},[]);function s(){o(false),a||e.dialogActionCancel?.(),a&&i(false);}async function m(){r(true);try{let l=e.dialogActionSubmit?.();l&&typeof l.then=="function"&&await l;}finally{i(true),o(false),r(false);}}return jsx(fi,{onOpenChange:s,open:t,children:jsx(pn,{children:jsxs(dn,{className:"sm:max-w-[425px]",children:[jsxs(gn,{children:[jsx(hn,{children:e.dialogTitle}),jsx(yn,{children:e.dialogMessage})]}),jsxs(kn,{children:[jsx(bn,{disabled:n,onClick:s,children:e.dialogCancelTitle}),jsxs(vn,{className:a$1({variant:e.isDestructive?"destructive":"default"}),disabled:n,onClick:m,children:[n?jsx(Loader2,{className:"fk-h-4 fk-w-4 fk-mr-2 fk-animate-spin"}):null,e.dialogActionLabel]})]})]})})})}var gi=createContext([]),ki=createContext(()=>{});function fl(e,t){let o=t.type;switch(t._id||(t._id=Date.now().toString()),o){case "DeleteEntity":return uniqBy(props(["type","_id"]),[...e,t]);case "AddEntity":return uniqBy(props(["type","_id"]),[...e,t]);case "EditEntity":return uniqBy(props(["type","_id"]),[...e,t]);case "EditRelationship":return uniqBy(props(["type","_id"]),[...e,t]);case "AlertDialog":return uniqBy(props(["type","_id"]),[...e,t]);case "Dismiss":return e.filter(n=>n._id!==t._id);default:throw Error(`Unknown action: ${o}`)}}function hi({children:e}){let[t,o]=useReducer(fl,[]);return jsx(gi.Provider,{value:t,children:jsx(ki.Provider,{value:o,children:e})})}function yi(){return useContext(gi)}function fe(){return useContext(ki)}var pl=["id","string"],dl=["date","datetime","duration","time"];function Zt(e,t,o){let n="(where: $where, options: $options)",r=wt(o,e),a=r?.name??e,i=r?.attributes??[],s=`$where: ${a}Where, $options: ${a}Options`;if(!r)throw new Error(`Entity '${a}' not found in the schema`);if(i.length===0)throw new Error(`Entity '${a}' has no attributes defined in the schema`);let m=W("global",i).join(`
2
2
  `),l=Fo(i),c=W(["local"],i),u=c.reduce((h,b)=>`${h}
3
3
  ${b} {
4
4
  _id
@@ -1,2 +1,2 @@
1
- import'./index.css';import {j}from'./chunk-MOR653JA.js';import {m,v,q,p,r,t,b}from'./chunk-ZOBZU47M.js';import'./chunk-7YBJLUUE.js';import {a}from'./chunk-AXB7FQV2.js';import {useState,useMemo,useRef}from'react';import {LoaderCircle,Search,X}from'lucide-react';import {Command}from'cmdk';import {useNavigate}from'react-router-dom';import {jsxs,jsx}from'react/jsx-runtime';var z=f=>({searchRequests:{searches:f.filter(a=>a.attributes.some(i=>i.isSearchable)).map(a=>a.plural).map(a=>({collection:a}))},commonParams:{q:""}});function Y({onSelect:f,searchPlaceholder:k="Search...",noResultsMsg:a$1="Nothing found",className:i,onSearchChange:u,projectId:P,schema:d}){let[I,o]=useState(false),[p$1,h]=useState(""),l=useMemo(()=>z(d),[d]),[R,g]=useState(l),r$1=useRef(null),{results:y,isLoading:E}=j(P,R),L=useNavigate();function B(e){h(e),e.length>0&&(o(true),g({...l,commonParams:{q:e}})),e.length===0&&o(false),u&&u(e);}function _(){h(""),o(false),g(l),r$1.current&&(r$1.current.value="");let e=new URL(window.location.href);e.searchParams.has("id")&&(e.searchParams.delete("id"),L(e.pathname+e.search));}return jsxs(m,{className:"fk-relative fk-overflow-visible fk-h-auto",onBlur:()=>{setTimeout(()=>{o(false);},300);},onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),o(false));},shouldFilter:false,children:[jsxs("div",{className:a("fk-flex fk-items-center fk-border fk-border-border fk-rounded-md fk-px-3 fk-h-9 md:fk-w-[100px] lg:fk-w-[300px] fk-ring-offset-background","focus-within:fk-outline-none focus-within:fk-ring-2 focus-within:fk-ring-ring focus-within:fk-ring-offset-2"),children:[E?jsx(LoaderCircle,{className:"fk-mr-2 fk-h-4 fk-w-4 fk-shrink-0 fk-opacity-50 fk-animate-spin"}):jsx(Search,{className:"fk-mr-2 fk-h-4 fk-w-4 fk-shrink-0 fk-opacity-50"}),jsx(Command.Input,{className:a("fk-flex fk-h-9 fk-w-full fk-rounded-md fk-bg-transparent fk-py-1 fk-text-sm fk-outline-none placeholder:fk-text-muted-foreground disabled:fk-cursor-not-allowed disabled:fk-opacity-50",i),placeholder:k,onMouseDown:()=>{(r$1.current?.value.length??0)>0&&o(true);},onValueChange:B,ref:r$1,value:p$1}),p$1&&jsx("button",{className:"fk-flex fk-items-center fk-justify-center fk-ml-2 fk-text-muted-foreground hover:fk-text-foreground",onClick:_,type:"button",children:jsx(X,{className:"fk-h-4 fk-w-4"})})]}),jsx("div",{className:"fk-relative fk-max-w-[600px]",children:jsx("div",{className:a("fk-mt-1 fk-animate-in fk-fade-in-0 fk-zoom-in-95 fk-absolute fk-top-0 fk-z-10 fk-w-full fk-rounded-md fk-bg-popover fk-outline-none fk-drop-shadow-md fk-border fk-border-border",I?"fk-block":"fk-hidden"),children:jsxs(v,{className:"fk-max-h-[220px] fk-overflow-auto",children:[jsx(q,{children:a$1}),jsx(p,{children:jsxs(r,{children:[y.length>0&&jsx(t,{className:"fk-hidden",value:"-"}),y.map(e=>jsxs(t,{className:"fk-flex",value:e._id,onSelect:M=>{f({entityName:e._entityName,entityNamePlural:e._entityNamePlural,entityId:M});},children:[jsx("span",{className:"fk-basis-full",children:e[Object.keys(e)[3]]}),jsx(b,{className:"fk-py-px fk-text-[0.6875rem] fk-leading-3 fk-bg-teal-400",children:e._entityName})]},e._id))]})})]})})})]})}export{Y as Search};//# sourceMappingURL=search-CKPEOD77.js.map
2
- //# sourceMappingURL=search-CKPEOD77.js.map
1
+ import'./index.css';import {j}from'./chunk-7DMOGZE6.js';import {m,v,q,p,r,t,b}from'./chunk-ZOBZU47M.js';import'./chunk-7YBJLUUE.js';import {a}from'./chunk-AXB7FQV2.js';import {useState,useMemo,useRef}from'react';import {LoaderCircle,Search,X}from'lucide-react';import {Command}from'cmdk';import {useNavigate}from'react-router-dom';import {jsxs,jsx}from'react/jsx-runtime';var z=f=>({searchRequests:{searches:f.filter(a=>a.attributes.some(i=>i.isSearchable)).map(a=>a.plural).map(a=>({collection:a}))},commonParams:{q:""}});function Y({onSelect:f,searchPlaceholder:k="Search...",noResultsMsg:a$1="Nothing found",className:i,onSearchChange:u,projectId:P,schema:d}){let[I,o]=useState(false),[p$1,h]=useState(""),l=useMemo(()=>z(d),[d]),[R,g]=useState(l),r$1=useRef(null),{results:y,isLoading:E}=j(P,R),L=useNavigate();function B(e){h(e),e.length>0&&(o(true),g({...l,commonParams:{q:e}})),e.length===0&&o(false),u&&u(e);}function _(){h(""),o(false),g(l),r$1.current&&(r$1.current.value="");let e=new URL(window.location.href);e.searchParams.has("id")&&(e.searchParams.delete("id"),L(e.pathname+e.search));}return jsxs(m,{className:"fk-relative fk-overflow-visible fk-h-auto",onBlur:()=>{setTimeout(()=>{o(false);},300);},onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),o(false));},shouldFilter:false,children:[jsxs("div",{className:a("fk-flex fk-items-center fk-border fk-border-border fk-rounded-md fk-px-3 fk-h-9 md:fk-w-[100px] lg:fk-w-[300px] fk-ring-offset-background","focus-within:fk-outline-none focus-within:fk-ring-2 focus-within:fk-ring-ring focus-within:fk-ring-offset-2"),children:[E?jsx(LoaderCircle,{className:"fk-mr-2 fk-h-4 fk-w-4 fk-shrink-0 fk-opacity-50 fk-animate-spin"}):jsx(Search,{className:"fk-mr-2 fk-h-4 fk-w-4 fk-shrink-0 fk-opacity-50"}),jsx(Command.Input,{className:a("fk-flex fk-h-9 fk-w-full fk-rounded-md fk-bg-transparent fk-py-1 fk-text-sm fk-outline-none placeholder:fk-text-muted-foreground disabled:fk-cursor-not-allowed disabled:fk-opacity-50",i),placeholder:k,onMouseDown:()=>{(r$1.current?.value.length??0)>0&&o(true);},onValueChange:B,ref:r$1,value:p$1}),p$1&&jsx("button",{className:"fk-flex fk-items-center fk-justify-center fk-ml-2 fk-text-muted-foreground hover:fk-text-foreground",onClick:_,type:"button",children:jsx(X,{className:"fk-h-4 fk-w-4"})})]}),jsx("div",{className:"fk-relative fk-max-w-[600px]",children:jsx("div",{className:a("fk-mt-1 fk-animate-in fk-fade-in-0 fk-zoom-in-95 fk-absolute fk-top-0 fk-z-10 fk-w-full fk-rounded-md fk-bg-popover fk-outline-none fk-drop-shadow-md fk-border fk-border-border",I?"fk-block":"fk-hidden"),children:jsxs(v,{className:"fk-max-h-[220px] fk-overflow-auto",children:[jsx(q,{children:a$1}),jsx(p,{children:jsxs(r,{children:[y.length>0&&jsx(t,{className:"fk-hidden",value:"-"}),y.map(e=>jsxs(t,{className:"fk-flex",value:e._id,onSelect:M=>{f({entityName:e._entityName,entityNamePlural:e._entityNamePlural,entityId:M});},children:[jsx("span",{className:"fk-basis-full",children:e[Object.keys(e)[3]]}),jsx(b,{className:"fk-py-px fk-text-[0.6875rem] fk-leading-3 fk-bg-teal-400",children:e._entityName})]},e._id))]})})]})})})]})}export{Y as Search};//# sourceMappingURL=search-JJI6BIRU.js.map
2
+ //# sourceMappingURL=search-JJI6BIRU.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ui/components/search.tsx"],"names":["getBaseSearchRequest","schema","entity","attr","collection","Search","onSelect","searchPlaceholder","noResultsMsg","className","onSearchChange","projectId","isOpen","setIsOpen","useState","inputValue","setInputValue","searchRequest","useMemo","searchQuery","setSearchQuery","inputRef","useRef","results","isLoading","useSearch","navigate","useNavigate","handleOnSearchChange","q","handleClear","url","jsxs","Command","cn","jsx","LoaderCircle","SearchIcon","CommandPrimitive","XIcon","ScrollArea","CommandEmpty","CommandList","CommandGroup","CommandItem","item","entityId","Badge"],"mappings":"oXAoCA,IAAMA,CAAAA,CAAwBC,IAKrB,CACL,cAAA,CAAgB,CACd,QAAA,CANgBA,CAAAA,CACjB,MAAA,CAAQC,GAAWA,CAAAA,CAAO,UAAA,CAAW,IAAA,CAAMC,CAAAA,EAASA,CAAAA,CAAK,YAAY,CAAC,CAAA,CACtE,GAAA,CAAKD,CAAAA,EAAWA,CAAAA,CAAO,MAAM,CAAA,CAIN,IAAKE,CAAAA,GAAgB,CACzC,WAAAA,CACF,CAAA,CAAE,CACJ,CAAA,CACA,YAAA,CAAc,CACZ,CAAA,CAAG,EACL,CACF,GAGK,SAASC,CAAAA,CAAO,CACrB,QAAA,CAAAC,CAAAA,CACA,iBAAA,CAAAC,EAAoB,WAAA,CACpB,YAAA,CAAAC,GAAAA,CAAe,eAAA,CACf,SAAA,CAAAC,CAAAA,CACA,eAAAC,CAAAA,CACA,SAAA,CAAAC,EACA,MAAA,CAAAV,CACF,EAA6B,CAC3B,GAAM,CAACW,CAAAA,CAAQC,CAAS,CAAA,CAAIC,SAAS,KAAK,CAAA,CACpC,CAACC,GAAAA,CAAYC,CAAa,CAAA,CAAIF,SAAS,EAAE,CAAA,CACzCG,CAAAA,CAAgBC,OAAAA,CAAQ,IAAMlB,CAAAA,CAAqBC,CAAM,CAAA,CAAG,CAACA,CAAM,CAAC,CAAA,CACpE,CAACkB,CAAAA,CAAaC,CAAc,CAAA,CAAIN,QAAAA,CAASG,CAAa,CAAA,CACtDI,IAAWC,MAAAA,CAAyB,IAAI,EACxC,CAAE,OAAA,CAAAC,EAAS,SAAA,CAAAC,CAAU,CAAA,CAAIC,CAAAA,CAAUd,CAAAA,CAAWQ,CAAW,EACzDO,CAAAA,CAAWC,WAAAA,GAEjB,SAASC,CAAAA,CAAqBC,EAAiB,CAC7Cb,CAAAA,CAAca,CAAC,CAAA,C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AWC,CAAAA,EAAa,CACtBxC,EAAS,CAAE,UAAA,CAAYuC,CAAAA,CAAK,WAAA,CAAa,gBAAA,CAAkBA,CAAAA,CAAK,kBAAmB,QAAA,CAAAC,CAAS,CAAC,EAC/F,CAAA,CAEA,QAAA,CAAA,CAAAX,IAAC,MAAA,CAAA,CAAK,SAAA,CAAU,eAAA,CAAiB,QAAA,CAAAU,CAAAA,CAAK,MAAA,CAAO,KAAKA,CAAI,CAAA,CAAE,CAAC,CAAC,CAAA,CAAE,EAC5DV,GAAAA,CAACY,CAAAA,CAAA,CAAM,SAAA,CAAU,0DAAA,CACd,QAAA,CAAAF,EAAK,WAAA,CACR,CAAA,CAAA,CAAA,CATKA,CAAAA,CAAK,GAUZ,CACD,CAAA,CAAA,CACH,EACF,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CACF,CAAA,CAAA,CACF,CAEJ","file":"search-CKPEOD77.js","sourcesContent":["'use client';\n\nimport { useRef, useState, useMemo } from 'react';\nimport { LoaderCircle, Search as SearchIcon, X as XIcon } from 'lucide-react';\nimport { Command as CommandPrimitive } from 'cmdk';\nimport { useNavigate } from 'react-router-dom';\nimport { useSearch } from '../../core/use-search';\nimport { cn } from '../lib/utils';\nimport { Badge } from '../primitives/badge';\nimport { Command, CommandEmpty, CommandGroup, CommandItem, CommandList } from '../primitives/command';\nimport { ScrollArea } from '../primitives/scroll-area';\nimport type { Entity, SearchRequestProps } from '../../core/types';\n\nexport type ComboBoxItemType = {\n value: string;\n label: string;\n};\n\nexport interface SearchProps {\n onSelect: ({\n entityName,\n entityNamePlural,\n entityId,\n }: {\n entityName: string;\n entityNamePlural: string;\n entityId: string;\n }) => void;\n searchPlaceholder?: string;\n noResultsMsg?: string;\n className?: string;\n onSearchChange?: (e: string) => void;\n projectId: string;\n schema: Entity[];\n}\n\nconst getBaseSearchRequest = (schema: Entity[]): SearchRequestProps => {\n const collections = schema\n .filter((entity) => entity.attributes.some((attr) => attr.isSearchable))\n .map((entity) => entity.plural);\n\n return {\n searchRequests: {\n searches: collections.map((collection) => ({\n collection,\n })),\n },\n commonParams: {\n q: '',\n },\n };\n};\n\nexport function Search({\n onSelect,\n searchPlaceholder = 'Search...',\n noResultsMsg = 'Nothing found',\n className,\n onSearchChange,\n projectId,\n schema,\n}: SearchProps): JSX.Element {\n const [isOpen, setIsOpen] = useState(false);\n const [inputValue, setInputValue] = useState('');\n const searchRequest = useMemo(() => getBaseSearchRequest(schema), [schema]);\n const [searchQuery, setSearchQuery] = useState(searchRequest);\n const inputRef = useRef<HTMLInputElement>(null);\n const { results, isLoading } = useSearch(projectId, searchQuery);\n const navigate = useNavigate();\n\n function handleOnSearchChange(q: string): void {\n setInputValue(q);\n // TODO: Add debounce\n if (q.length > 0) {\n setIsOpen(true);\n setSearchQuery({ ...searchRequest, commonParams: { q } });\n }\n\n if (q.length === 0) setIsOpen(false);\n\n if (onSearchChange) {\n onSearchChange(q);\n }\n }\n\n function handleClear(): void {\n setInputValue('');\n setIsOpen(false);\n setSearchQuery(searchRequest);\n\n if (inputRef.current) {\n inputRef.current.value = '';\n }\n\n // Remove id from URL if present\n const url = new URL(window.location.href);\n\n if (url.searchParams.has('id')) {\n url.searchParams.delete('id');\n navigate(url.pathname + url.search);\n }\n }\n\n // TODO: handle error\n\n return (\n <Command\n className=\"fk-relative fk-overflow-visible fk-h-auto\"\n onBlur={() => {\n // close after a delay to allow any click event from the results list to be handled\n setTimeout(() => {\n setIsOpen(false);\n }, 300);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n setIsOpen(false);\n }\n }}\n shouldFilter={false}\n >\n <div\n className={cn(\n 'fk-flex fk-items-center fk-border fk-border-border fk-rounded-md fk-px-3 fk-h-9 md:fk-w-[100px] lg:fk-w-[300px] fk-ring-offset-background',\n 'focus-within:fk-outline-none focus-within:fk-ring-2 focus-within:fk-ring-ring focus-within:fk-ring-offset-2'\n )}\n >\n {isLoading ? (\n <LoaderCircle className=\"fk-mr-2 fk-h-4 fk-w-4 fk-shrink-0 fk-opacity-50 fk-animate-spin\" />\n ) : (\n <SearchIcon className=\"fk-mr-2 fk-h-4 fk-w-4 fk-shrink-0 fk-opacity-50\" />\n )}\n <CommandPrimitive.Input\n className={cn(\n 'fk-flex fk-h-9 fk-w-full fk-rounded-md fk-bg-transparent fk-py-1 fk-text-sm fk-outline-none placeholder:fk-text-muted-foreground disabled:fk-cursor-not-allowed disabled:fk-opacity-50',\n className\n )}\n placeholder={searchPlaceholder}\n onMouseDown={() => {\n if ((inputRef.current?.value.length ?? 0) > 0) setIsOpen(true);\n }}\n onValueChange={handleOnSearchChange}\n ref={inputRef}\n value={inputValue}\n />\n {inputValue && (\n <button\n className=\"fk-flex fk-items-center fk-justify-center fk-ml-2 fk-text-muted-foreground hover:fk-text-foreground\"\n onClick={handleClear}\n type=\"button\"\n >\n <XIcon className=\"fk-h-4 fk-w-4\" />\n </button>\n )}\n </div>\n <div className=\"fk-relative fk-max-w-[600px]\">\n <div\n className={cn(\n 'fk-mt-1 fk-animate-in fk-fade-in-0 fk-zoom-in-95 fk-absolute fk-top-0 fk-z-10 fk-w-full fk-rounded-md fk-bg-popover fk-outline-none fk-drop-shadow-md fk-border fk-border-border',\n isOpen ? 'fk-block' : 'fk-hidden'\n )}\n >\n <ScrollArea className=\"fk-max-h-[220px] fk-overflow-auto\">\n <CommandEmpty>{noResultsMsg}</CommandEmpty>\n <CommandList>\n <CommandGroup>\n {results.length > 0 && <CommandItem className=\"fk-hidden\" value=\"-\" />}\n {results.map((item) => (\n <CommandItem\n className=\"fk-flex\"\n key={item._id}\n value={item._id}\n onSelect={(entityId) => {\n onSelect({ entityName: item._entityName, entityNamePlural: item._entityNamePlural, entityId });\n }}\n >\n <span className=\"fk-basis-full\">{item[Object.keys(item)[3]]}</span>\n <Badge className=\"fk-py-px fk-text-[0.6875rem] fk-leading-3 fk-bg-teal-400\">\n {item._entityName}\n </Badge>\n </CommandItem>\n ))}\n </CommandGroup>\n </CommandList>\n </ScrollArea>\n </div>\n </div>\n </Command>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/ui/components/search.tsx"],"names":["getBaseSearchRequest","schema","entity","attr","collection","Search","onSelect","searchPlaceholder","noResultsMsg","className","onSearchChange","projectId","isOpen","setIsOpen","useState","inputValue","setInputValue","searchRequest","useMemo","searchQuery","setSearchQuery","inputRef","useRef","results","isLoading","useSearch","navigate","useNavigate","handleOnSearchChange","q","handleClear","url","jsxs","Command","cn","jsx","LoaderCircle","SearchIcon","CommandPrimitive","XIcon","ScrollArea","CommandEmpty","CommandList","CommandGroup","CommandItem","item","entityId","Badge"],"mappings":"oXAoCA,IAAMA,CAAAA,CAAwBC,IAKrB,CACL,cAAA,CAAgB,CACd,QAAA,CANgBA,CAAAA,CACjB,MAAA,CAAQC,GAAWA,CAAAA,CAAO,UAAA,CAAW,IAAA,CAAMC,CAAAA,EAASA,CAAAA,CAAK,YAAY,CAAC,CAAA,CACtE,GAAA,CAAKD,CAAAA,EAAWA,CAAAA,CAAO,MAAM,CAAA,CAIN,IAAKE,CAAAA,GAAgB,CACzC,WAAAA,CACF,CAAA,CAAE,CACJ,CAAA,CACA,YAAA,CAAc,CACZ,CAAA,CAAG,EACL,CACF,GAGK,SAASC,CAAAA,CAAO,CACrB,QAAA,CAAAC,CAAAA,CACA,iBAAA,CAAAC,EAAoB,WAAA,CACpB,YAAA,CAAAC,GAAAA,CAAe,eAAA,CACf,SAAA,CAAAC,CAAAA,CACA,eAAAC,CAAAA,CACA,SAAA,CAAAC,EACA,MAAA,CAAAV,CACF,EAA6B,CAC3B,GAAM,CAACW,CAAAA,CAAQC,CAAS,CAAA,CAAIC,SAAS,KAAK,CAAA,CACpC,CAACC,GAAAA,CAAYC,CAAa,CAAA,CAAIF,SAAS,EAAE,CAAA,CACzCG,CAAAA,CAAgBC,OAAAA,CAAQ,IAAMlB,CAAAA,CAAqBC,CAAM,CAAA,CAAG,CAACA,CAAM,CAAC,CAAA,CACpE,CAACkB,CAAAA,CAAaC,C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QAAA,CAAA,CAAApB,CAAAA,CAAQ,MAAA,CAAS,CAAA,EAAKY,GAAAA,CAACS,CAAAA,CAAA,CAAY,SAAA,CAAU,WAAA,CAAY,KAAA,CAAM,GAAA,CAAI,CAAA,CACnErB,CAAAA,CAAQ,IAAKsB,CAAAA,EACZb,IAAAA,CAACY,CAAAA,CAAA,CACC,SAAA,CAAU,SAAA,CAEV,MAAOC,CAAAA,CAAK,GAAA,CACZ,SAAWC,CAAAA,EAAa,CACtBxC,EAAS,CAAE,UAAA,CAAYuC,CAAAA,CAAK,WAAA,CAAa,gBAAA,CAAkBA,CAAAA,CAAK,kBAAmB,QAAA,CAAAC,CAAS,CAAC,EAC/F,CAAA,CAEA,QAAA,CAAA,CAAAX,IAAC,MAAA,CAAA,CAAK,SAAA,CAAU,eAAA,CAAiB,QAAA,CAAAU,CAAAA,CAAK,MAAA,CAAO,KAAKA,CAAI,CAAA,CAAE,CAAC,CAAC,CAAA,CAAE,EAC5DV,GAAAA,CAACY,CAAAA,CAAA,CAAM,SAAA,CAAU,0DAAA,CACd,QAAA,CAAAF,EAAK,WAAA,CACR,CAAA,CAAA,CAAA,CATKA,CAAAA,CAAK,GAUZ,CACD,CAAA,CAAA,CACH,EACF,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CACF,CAAA,CAAA,CACF,CAEJ","file":"search-JJI6BIRU.js","sourcesContent":["'use client';\n\nimport { useRef, useState, useMemo } from 'react';\nimport { LoaderCircle, Search as SearchIcon, X as XIcon } from 'lucide-react';\nimport { Command as CommandPrimitive } from 'cmdk';\nimport { useNavigate } from 'react-router-dom';\nimport { useSearch } from '../../core/use-search';\nimport { cn } from '../lib/utils';\nimport { Badge } from '../primitives/badge';\nimport { Command, CommandEmpty, CommandGroup, CommandItem, CommandList } from '../primitives/command';\nimport { ScrollArea } from '../primitives/scroll-area';\nimport type { Entity, SearchRequestProps } from '../../core/types';\n\nexport type ComboBoxItemType = {\n value: string;\n label: string;\n};\n\nexport interface SearchProps {\n onSelect: ({\n entityName,\n entityNamePlural,\n entityId,\n }: {\n entityName: string;\n entityNamePlural: string;\n entityId: string;\n }) => void;\n searchPlaceholder?: string;\n noResultsMsg?: string;\n className?: string;\n onSearchChange?: (e: string) => void;\n projectId: string;\n schema: Entity[];\n}\n\nconst getBaseSearchRequest = (schema: Entity[]): SearchRequestProps => {\n const collections = schema\n .filter((entity) => entity.attributes.some((attr) => attr.isSearchable))\n .map((entity) => entity.plural);\n\n return {\n searchRequests: {\n searches: collections.map((collection) => ({\n collection,\n })),\n },\n commonParams: {\n q: '',\n },\n };\n};\n\nexport function Search({\n onSelect,\n searchPlaceholder = 'Search...',\n noResultsMsg = 'Nothing found',\n className,\n onSearchChange,\n projectId,\n schema,\n}: SearchProps): JSX.Element {\n const [isOpen, setIsOpen] = useState(false);\n const [inputValue, setInputValue] = useState('');\n const searchRequest = useMemo(() => getBaseSearchRequest(schema), [schema]);\n const [searchQuery, setSearchQuery] = useState(searchRequest);\n const inputRef = useRef<HTMLInputElement>(null);\n const { results, isLoading } = useSearch(projectId, searchQuery);\n const navigate = useNavigate();\n\n function handleOnSearchChange(q: string): void {\n setInputValue(q);\n // TODO: Add debounce\n if (q.length > 0) {\n setIsOpen(true);\n setSearchQuery({ ...searchRequest, commonParams: { q } });\n }\n\n if (q.length === 0) setIsOpen(false);\n\n if (onSearchChange) {\n onSearchChange(q);\n }\n }\n\n function handleClear(): void {\n setInputValue('');\n setIsOpen(false);\n setSearchQuery(searchRequest);\n\n if (inputRef.current) {\n inputRef.current.value = '';\n }\n\n // Remove id from URL if present\n const url = new URL(window.location.href);\n\n if (url.searchParams.has('id')) {\n url.searchParams.delete('id');\n navigate(url.pathname + url.search);\n }\n }\n\n // TODO: handle error\n\n return (\n <Command\n className=\"fk-relative fk-overflow-visible fk-h-auto\"\n onBlur={() => {\n // close after a delay to allow any click event from the results list to be handled\n setTimeout(() => {\n setIsOpen(false);\n }, 300);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n setIsOpen(false);\n }\n }}\n shouldFilter={false}\n >\n <div\n className={cn(\n 'fk-flex fk-items-center fk-border fk-border-border fk-rounded-md fk-px-3 fk-h-9 md:fk-w-[100px] lg:fk-w-[300px] fk-ring-offset-background',\n 'focus-within:fk-outline-none focus-within:fk-ring-2 focus-within:fk-ring-ring focus-within:fk-ring-offset-2'\n )}\n >\n {isLoading ? (\n <LoaderCircle className=\"fk-mr-2 fk-h-4 fk-w-4 fk-shrink-0 fk-opacity-50 fk-animate-spin\" />\n ) : (\n <SearchIcon className=\"fk-mr-2 fk-h-4 fk-w-4 fk-shrink-0 fk-opacity-50\" />\n )}\n <CommandPrimitive.Input\n className={cn(\n 'fk-flex fk-h-9 fk-w-full fk-rounded-md fk-bg-transparent fk-py-1 fk-text-sm fk-outline-none placeholder:fk-text-muted-foreground disabled:fk-cursor-not-allowed disabled:fk-opacity-50',\n className\n )}\n placeholder={searchPlaceholder}\n onMouseDown={() => {\n if ((inputRef.current?.value.length ?? 0) > 0) setIsOpen(true);\n }}\n onValueChange={handleOnSearchChange}\n ref={inputRef}\n value={inputValue}\n />\n {inputValue && (\n <button\n className=\"fk-flex fk-items-center fk-justify-center fk-ml-2 fk-text-muted-foreground hover:fk-text-foreground\"\n onClick={handleClear}\n type=\"button\"\n >\n <XIcon className=\"fk-h-4 fk-w-4\" />\n </button>\n )}\n </div>\n <div className=\"fk-relative fk-max-w-[600px]\">\n <div\n className={cn(\n 'fk-mt-1 fk-animate-in fk-fade-in-0 fk-zoom-in-95 fk-absolute fk-top-0 fk-z-10 fk-w-full fk-rounded-md fk-bg-popover fk-outline-none fk-drop-shadow-md fk-border fk-border-border',\n isOpen ? 'fk-block' : 'fk-hidden'\n )}\n >\n <ScrollArea className=\"fk-max-h-[220px] fk-overflow-auto\">\n <CommandEmpty>{noResultsMsg}</CommandEmpty>\n <CommandList>\n <CommandGroup>\n {results.length > 0 && <CommandItem className=\"fk-hidden\" value=\"-\" />}\n {results.map((item) => (\n <CommandItem\n className=\"fk-flex\"\n key={item._id}\n value={item._id}\n onSelect={(entityId) => {\n onSelect({ entityName: item._entityName, entityNamePlural: item._entityNamePlural, entityId });\n }}\n >\n <span className=\"fk-basis-full\">{item[Object.keys(item)[3]]}</span>\n <Badge className=\"fk-py-px fk-text-[0.6875rem] fk-leading-3 fk-bg-teal-400\">\n {item._entityName}\n </Badge>\n </CommandItem>\n ))}\n </CommandGroup>\n </CommandList>\n </ScrollArea>\n </div>\n </div>\n </Command>\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flexkit/studio",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Flexkit Studio - Build custom internal tools like PIMs, CRMs, and ERPs with a flexible React UI and a graph-backed API",
5
5
  "keywords": [
6
6
  "flexkit",
@@ -131,7 +131,7 @@
131
131
  "react-resizable-panels": "^3.0.6",
132
132
  "react-router-dom": "^6.21.0",
133
133
  "sonner": "^1.4.3",
134
- "swr": "^2.2.4",
134
+ "swr": "2.2.5",
135
135
  "tailwind-merge": "^2.0.0",
136
136
  "tiptap-markdown": "0.8.10",
137
137
  "use-debounce": "10.0.3",