@flexkit/studio 0.0.34 → 0.0.36
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.
- package/dist/asset-3XMRPTA5.js +2 -0
- package/dist/{asset-ZVPFS73O.js.map → asset-3XMRPTA5.js.map} +1 -1
- package/dist/astro.js +2 -2
- package/dist/{chunk-JAARDXQZ.js → chunk-3VOTTOJT.js} +2 -2
- package/dist/{chunk-JAARDXQZ.js.map → chunk-3VOTTOJT.js.map} +1 -1
- package/dist/chunk-5I7Q5ODB.js +2 -0
- package/dist/chunk-5I7Q5ODB.js.map +1 -0
- package/dist/chunk-6NRQMG26.js +2 -0
- package/dist/chunk-6NRQMG26.js.map +1 -0
- package/dist/{chunk-VHNQDP7Q.js → chunk-6V73336R.js} +10 -3
- package/dist/{chunk-OEWYLKO7.js → chunk-7BOX7HHO.js} +2 -2
- package/dist/{chunk-OEWYLKO7.js.map → chunk-7BOX7HHO.js.map} +1 -1
- package/dist/chunk-7JFLGBWE.js +2 -0
- package/dist/{chunk-F2ILIHAU.js.map → chunk-7JFLGBWE.js.map} +1 -1
- package/dist/chunk-7ZJN4MWQ.js +2 -0
- package/dist/chunk-7ZJN4MWQ.js.map +1 -0
- package/dist/{chunk-XFY7MZJN.js → chunk-AICNS7KW.js} +2 -2
- package/dist/{chunk-XFY7MZJN.js.map → chunk-AICNS7KW.js.map} +1 -1
- package/dist/chunk-FLT6RWXH.js +2 -0
- package/dist/{chunk-GFDWGYUR.js.map → chunk-FLT6RWXH.js.map} +1 -1
- package/dist/{chunk-FVFRTCEB.js → chunk-GBM7VKFS.js} +2 -2
- package/dist/{chunk-FVFRTCEB.js.map → chunk-GBM7VKFS.js.map} +1 -1
- package/dist/chunk-HDOIOXMP.js +2 -0
- package/dist/chunk-HDOIOXMP.js.map +1 -0
- package/dist/chunk-HMMBYXYA.js +2 -0
- package/dist/{chunk-JCHD4EGB.js.map → chunk-HMMBYXYA.js.map} +1 -1
- package/dist/chunk-IRY4KWB5.js +2 -0
- package/dist/chunk-IRY4KWB5.js.map +1 -0
- package/dist/{chunk-AEBTHXEP.js → chunk-JKHUO27E.js} +2 -2
- package/dist/{chunk-AEBTHXEP.js.map → chunk-JKHUO27E.js.map} +1 -1
- package/dist/{chunk-CCI3FGPF.js → chunk-PENRGDNC.js} +2 -2
- package/dist/{chunk-CCI3FGPF.js.map → chunk-PENRGDNC.js.map} +1 -1
- package/dist/{chunk-E7G46743.js → chunk-POQX5GIA.js} +2 -2
- package/dist/{chunk-VUAFNQK7.js → chunk-QOX3QNMM.js} +2 -2
- package/dist/{chunk-VUAFNQK7.js.map → chunk-QOX3QNMM.js.map} +1 -1
- package/dist/{chunk-KGYH74NA.js → chunk-QVBNGGOE.js} +2 -2
- package/dist/{chunk-KGYH74NA.js.map → chunk-QVBNGGOE.js.map} +1 -1
- package/dist/{chunk-D62TAYLI.js → chunk-S6MOM5G3.js} +2 -2
- package/dist/chunk-S6MOM5G3.js.map +1 -0
- package/dist/{chunk-MGXHZDFZ.js → chunk-UGRS4FEI.js} +2 -2
- package/dist/{chunk-MGXHZDFZ.js.map → chunk-UGRS4FEI.js.map} +1 -1
- package/dist/{chunk-YW2EEXMV.js → chunk-USNXQOMJ.js} +2 -2
- package/dist/{chunk-YW2EEXMV.js.map → chunk-USNXQOMJ.js.map} +1 -1
- package/dist/{chunk-N2T6MKPV.js → chunk-UWMJBBTY.js} +2 -2
- package/dist/{chunk-N2T6MKPV.js.map → chunk-UWMJBBTY.js.map} +1 -1
- package/dist/chunk-W3Z33ETA.js +2 -0
- package/dist/chunk-W3Z33ETA.js.map +1 -0
- package/dist/{chunk-7GBAYC7G.js → chunk-YSLN4XT6.js} +2 -2
- package/dist/{chunk-7GBAYC7G.js.map → chunk-YSLN4XT6.js.map} +1 -1
- package/dist/datetime-C55QQQJK.js +2 -0
- package/dist/{datetime-DDEWTNLB.js.map → datetime-C55QQQJK.js.map} +1 -1
- package/dist/editor-NZLXIOE7.js +2 -0
- package/dist/{editor-HAYTKNMY.js.map → editor-NZLXIOE7.js.map} +1 -1
- package/dist/index.css +36 -33
- package/dist/index.d.ts +4 -4
- package/dist/index.js +126 -130
- package/dist/index.js.map +1 -1
- package/dist/logo-MU7MGYDH.js +3 -0
- package/dist/logo-MU7MGYDH.js.map +1 -0
- package/dist/nextjs.js +2 -2
- package/dist/{project-selector-X6YVZYKL.js → project-selector-GQ24PVO6.js} +2 -2
- package/dist/{project-selector-X6YVZYKL.js.map → project-selector-GQ24PVO6.js.map} +1 -1
- package/dist/search-XKG5A7XM.js +2 -0
- package/dist/{search-KIII5N7I.js.map → search-XKG5A7XM.js.map} +1 -1
- package/dist/select-SO3DICYX.js +2 -0
- package/dist/{select-H3JHOCWR.js.map → select-SO3DICYX.js.map} +1 -1
- package/dist/switch-SU3OIXL6.js +2 -0
- package/dist/{switch-TACKLQJH.js.map → switch-SU3OIXL6.js.map} +1 -1
- package/dist/tanstack-start.js +2 -2
- package/dist/text-FZSI6W5I.js +2 -0
- package/dist/{text-M3DRK7LU.js.map → text-FZSI6W5I.js.map} +1 -1
- package/dist/text-QXGOD2KW.js +2 -0
- package/dist/{text-SQXG7XJT.js.map → text-QXGOD2KW.js.map} +1 -1
- package/dist/textarea-INLURFNU.js +2 -0
- package/dist/{textarea-YF4K2VBM.js.map → textarea-INLURFNU.js.map} +1 -1
- package/dist/tools.js +1 -1
- package/dist/{types.d-9Gbw_A9L.d.ts → types.d-CPIuPrvL.d.ts} +5 -2
- package/dist/ui.d.ts +20 -7
- package/dist/ui.js +5 -5
- package/dist/ui.js.map +1 -1
- package/dist/user-nav-LSEOOH4E.js +2 -0
- package/dist/{user-nav-6UKDSUF3.js.map → user-nav-LSEOOH4E.js.map} +1 -1
- package/package.json +2 -1
- package/dist/asset-ZVPFS73O.js +0 -2
- package/dist/chunk-2FFSI7IK.js +0 -2
- package/dist/chunk-2FFSI7IK.js.map +0 -1
- package/dist/chunk-D62TAYLI.js.map +0 -1
- package/dist/chunk-EYGOJ2ZN.js +0 -2
- package/dist/chunk-EYGOJ2ZN.js.map +0 -1
- package/dist/chunk-F2ILIHAU.js +0 -2
- package/dist/chunk-FPH4YETF.js +0 -2
- package/dist/chunk-FPH4YETF.js.map +0 -1
- package/dist/chunk-GFDWGYUR.js +0 -2
- package/dist/chunk-JCHD4EGB.js +0 -2
- package/dist/chunk-KHPTVIYT.js +0 -2
- package/dist/chunk-KHPTVIYT.js.map +0 -1
- package/dist/chunk-PXB5QSHN.js +0 -2
- package/dist/chunk-PXB5QSHN.js.map +0 -1
- package/dist/chunk-XU2JGXYC.js +0 -2
- package/dist/chunk-XU2JGXYC.js.map +0 -1
- package/dist/datetime-DDEWTNLB.js +0 -2
- package/dist/editor-HAYTKNMY.js +0 -2
- package/dist/logo-B6ZKLGM7.js +0 -3
- package/dist/logo-B6ZKLGM7.js.map +0 -1
- package/dist/search-KIII5N7I.js +0 -2
- package/dist/select-H3JHOCWR.js +0 -2
- package/dist/switch-TACKLQJH.js +0 -2
- package/dist/text-M3DRK7LU.js +0 -2
- package/dist/text-SQXG7XJT.js +0 -2
- package/dist/textarea-YF4K2VBM.js +0 -2
- package/dist/user-nav-6UKDSUF3.js +0 -2
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import'./index.css';import {a as a$3}from'./chunk-N2T6MKPV.js';import {a as a$2}from'./chunk-MGXHZDFZ.js';import {a as a$b}from'./chunk-D4XLXU2H.js';import {a as a$d}from'./chunk-D62TAYLI.js';import {a as a$a}from'./chunk-JAARDXQZ.js';import {a,b as b$7}from'./chunk-FPH4YETF.js';import {a as a$e}from'./chunk-AEBTHXEP.js';import {a as a$c}from'./chunk-CCI3FGPF.js';import'./chunk-F2ILIHAU.js';import {h,i,j,k,l,n,o,p,s,t,q,u,x as x$1,f as f$3,c as c$8,d as d$3,g as g$3}from'./chunk-PXB5QSHN.js';import {a as a$7}from'./chunk-7GBAYC7G.js';import'./chunk-OEWYLKO7.js';import {a as a$8,b as b$5,c as c$4,e as e$3}from'./chunk-YW2EEXMV.js';import {d as d$2,c as c$2,e as e$4,b as b$9,a as a$i,f as f$4}from'./chunk-JH4MVD36.js';export{c as useAppContext,d as useAppDispatch,f as useSearch}from'./chunk-JH4MVD36.js';import {w,x,c as c$5,b as b$6,n as n$1,p as p$1,q as q$1,s as s$1,u as u$1,t as t$1,r}from'./chunk-KHPTVIYT.js';import {a as a$5,d as d$1,c as c$1,e as e$1,b as b$2,f as f$1,g as g$1}from'./chunk-XU2JGXYC.js';import {b,a as a$j}from'./chunk-WJ4ORIXF.js';export{b as useAuth}from'./chunk-WJ4ORIXF.js';import {c as c$3,e as e$2,f as f$2,g as g$2,h as h$2,m,a as a$h,l as l$1,i as i$2,b as b$b,r as r$1}from'./chunk-JCHD4EGB.js';import {d,a as a$f,b as b$8,e as e$5,c as c$7}from'./chunk-LIV5RBWJ.js';export{a as assetSchema,b as tagSchema,d as useConfig}from'./chunk-LIV5RBWJ.js';import {b as b$4,c as c$6,a as a$l}from'./chunk-WDRCARCP.js';export{b as IMAGES_BASE_URL}from'./chunk-WDRCARCP.js';import {b as b$3,a as a$9}from'./chunk-EYGOJ2ZN.js';import {a as a$g,b as b$a}from'./chunk-WIUPQHZ5.js';import {a as a$4}from'./chunk-GFDWGYUR.js';import {a as a$6}from'./chunk-VUAFNQK7.js';export{a as DefaultValueSwitch}from'./chunk-VUAFNQK7.js';import'./chunk-KGYH74NA.js';import {b as b$1,c,e,f,h as h$1,g,i as i$1,j as j$1,a as a$k}from'./chunk-FVFRTCEB.js';import {a as a$1}from'./chunk-O2QMYUPS.js';import*as Lo from'react';import {lazy,createContext,memo,forwardRef,useMemo,useState,useRef,useEffect,useImperativeHandle,createElement,useId,useCallback,useContext,Fragment as Fragment$1,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 {find,propEq,equals,uniqBy,prop,map,uniq,omit,pick,toPairs,props}from'ramda';import ic,{useSWRConfig}from'swr';import {Text,CheckSquare,Heading1,Heading2,Heading3,List,ListOrdered,TextQuote,Code,ImageIcon,Youtube,Twitter,AlertTriangle,Image,Upload,Search,File,Ellipsis,Download,Copy,RefreshCwOff,Maximize2,X,Calendar,ChevronsUpDown,Link,TextIcon,ChevronDown,Check,Trash,SigmaIcon,BoldIcon,ItalicIcon,UnderlineIcon,StrikethroughIcon,CodeIcon,ChevronLeftIcon,ChevronRightIcon,ChevronDownIcon,ArrowUp,ArrowDown,TrashIcon,RefreshCcwDot,CheckCheck,ArrowDownWideNarrow,WrapText,StepForward,Trash2,AlertCircle,CirclePlus,PencilIcon,Trash2Icon,Settings2,RefreshCw,Loader2,MoreHorizontal,Settings,Wrench,PackageCheck,PackageX,Moon,Sun,Monitor,Mail,LoaderCircle}from'lucide-react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useForm}from'react-hook-form';import*as vo from'zod';import {z}from'zod';import {zodResolver}from'@hookform/resolvers/zod';import {cva}from'class-variance-authority';import {gql,NetworkStatus,ApolloClient,InMemoryCache,defaultDataIdFromObject,from,HttpLink}from'@apollo/client';export{gql}from'@apollo/client';import {useLazyQuery,useApolloClient,useMutation,useQuery,ApolloProvider}from'@apollo/client/react';import {ErrorLink}from'@apollo/client/link/error';import {ServerError,CombinedGraphQLErrors,CombinedProtocolErrors}from'@apollo/client/errors';import {Popover,AlertDialog}from'radix-ui';import {toast}from'sonner';import {v4}from'uuid';import $r from'bytes';import {defaultStyles,FileIcon}from'react-file-icon';import {format}from'date-fns';import {getDefaultClassNames,DayPicker}from'react-day-picker';import {createSuggestionItems,Command,renderItems,EditorRoot,EditorContent,EditorCommand,EditorCommandEmpty,EditorCommandList,EditorCommandItem,ImageResizer,handleImageDrop,handleImagePaste,handleCommandNavigation,useEditor,removeAIHighlight,EditorBubble,EditorBubbleItem,addAIHighlight,getPrevText}from'novel';import {useDebouncedCallback}from'use-debounce';import {useCompletion}from'@ai-sdk/react';import Hd from'react-markdown';import {useReactTable,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 ho(){let[e,t]=useState(false),{theme:n,setTheme:o}=b$b();return useEffect(()=>{t(true);},[]),e?jsxs(c$8,{size:"sm",type:"single",value:n,children:[jsx(d$3,{"aria-label":"Set dark mode",onClick:()=>{o("dark");},value:"dark",children:jsx(Moon,{className:"fk:h-4 fk:w-4"})}),jsx(d$3,{"aria-label":"Set light mode",onClick:()=>{o("light");},value:"light",children:jsx(Sun,{className:"fk:h-4 fk:w-4"})}),jsx(d$3,{"aria-label":"Set system mode",onClick:()=>{o("system");},value:"system",children:jsx(Monitor,{className:"fk:h-4 fk:w-4"})})]}):null}function yo(){let{resolvedTheme:e}=b$b();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 oc=cva("fk:relative fk:w-full fk:rounded-lg fk:border fk:px-4 fk:py-3 fk:[&>svg~*]:pl-7 fk:[&>svg+div]:translate-y-[-3px] fk:[&>svg]:absolute fk:[&>svg]:left-4 fk:[&>svg]:top-4 fk:[&>svg]:text-foreground",{variants:{variant:{default:"fk:bg-card fk:text-card-foreground",destructive:"fk:border-none fk:text-destructive fk:bg-destructive-foreground fk:[&>svg]:text-destructive"}},defaultVariants:{variant:"default"}});function ye({className:e,variant:t,...n}){return jsx("div",{"data-slot":"alert",role:"alert",className:a$1(oc({variant:t}),e),...n})}function qe({className:e,...t}){return jsx("div",{"data-slot":"alert-title",className:a$1("fk:col-start-2 fk:line-clamp-1 fk:min-h-4 fk:font-medium fk:tracking-tight",e),...t})}function ve({className:e,...t}){return jsx("div",{"data-slot":"alert-description",className:a$1("fk:text-sm fk:[&_p]:leading-relaxed",e),...t})}var fc=vo.object({email:vo.email({error:"Please enter a valid email address"})});function fr({projectId:e$1,setIsEmailLogin:t}){let[n,o]=useState(false),[r,i]=useState(false),{mutate:s}=useSWRConfig(),a=useForm({resolver:zodResolver(fc),defaultValues:{email:""}}),c$1=new URL(c$6(e$1).loginOtpSend,a$l),{data:l,error:u,isLoading:f}=ic(r?c$1.href:null,h=>fetch(h,{method:"POST",mode:"cors",body:JSON.stringify({email:a.getValues("email")})}).then(v=>v.json()),{revalidateIfStale:false,revalidateOnFocus:false,revalidateOnReconnect:false,shouldRetryOnError:false}),m=l&&"error"in l&&l.error.code,p=l&&"token"in l,d=l&&"token"in l?l.token:"";useEffect(()=>{if(!p)return;let h=0,v=setInterval(()=>{if(h>100){clearInterval(v),o(true);return}let y=new URL(c$6(e$1).loginOtpConfirm,a$l),b="/api/flexkit/set-token";fetch(`${y.href}?email=${encodeURIComponent(a.getValues("email"))}&token=${encodeURIComponent(d)}`).then(E=>{E.status===200&&E.json().then(A=>{fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sid:A.sid})}).then(()=>{window.location.reload();}).catch(()=>{});}).catch(()=>{});}).catch(()=>{}),h++;},3e3);return ()=>{clearInterval(v);}},[a,p,e$1,d]);function g$1(){o(false),i(true),s(c$1.href);}return jsx("div",{className:"fk:w-full",children:p?jsx(ye,{className:"fk:dark:bg-foreground fk:dark:text-background",variant:"default",children:jsxs(ve,{children:["Keep this window open and in a new tab open the link we just sent to:"," ",jsx("strong",{children:a.getValues("email")})," (",jsx(b$3,{className:"fk:p-0 fk:hover:underline fk:text-link",onClick:()=>{window.location.reload();},variant:"link",children:"undo"}),")"]})}):jsx(b$1,{...a,children:jsxs("form",{onSubmit:h=>{a.handleSubmit(g$1)(h);},className:"fk:w-full fk:space-y-3 fk:mb-10",children:[m==="not_exists"&&jsx(ye,{variant:"destructive",children:jsxs(ve,{children:["There is no Flexkit account associated with this email address."," ",jsx("a",{className:"fk:text-black/90 fk:dark:text-white/90 fk:underline",href:`https://flexkit.io/signup/email?email=${encodeURIComponent(a.getValues("email"))}`,children:"Sign up?"})]})}),m==="unknown_error"||u?jsx(ye,{variant:"destructive",children:jsxs(ve,{children:["There was an unknown error, please"," ",jsx(b$3,{className:"fk:p-0 fk:hover:underline",onClick:()=>{window.location.reload();},variant:"link",children:"try again"}),"."," "]})}):null,n?jsx(ye,{variant:"destructive",children:jsxs(ve,{children:["The email verification link may have expired. Please"," ",jsx(b$3,{className:"fk:p-0 fk:hover:underline",onClick:()=>{window.location.reload();},variant:"link",children:"try again"}),"."]})}):null,jsx(c,{control:a.control,defaultValue:"",name:"email",render:({field:h})=>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",...h})}),jsx(i$1,{})]})}),jsxs(b$3,{"aria-disabled":f,className:"fk:w-full",type:"submit",disabled:!!f,children:[f?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 ps({projectId:e}){let{projects:t}=d(),[n,o]=useState(t.find(g=>g.projectId===e)??t[0]),[r,i]=useState(false),{data:s,error:a,isLoading:c}=ic(c$6(e).authProviders,g=>fetch(g,{mode:"cors"}).then(h=>h.json())),[l,u]=b(),f=new Date().getFullYear(),m=useLocation(),p=m.state?.from?.pathname??m.pathname,d$2=p.includes(n.projectId)?`${location.origin}${p}`:`${location.origin}${b$a(n.basePath,n.projectId)}`;if(a)throw new Error("Error fetching auth providers");return c||l||!s?jsx(yo,{}):u.user?.id?jsx(Navigate,{replace:true,state:{from:m},to:n.basePath}):jsxs(Fragment,{children:[jsxs("div",{className:"fk:container fk:relative fk:h-[calc(100vh-3rem)] fk:flex fk:items-center fk:justify-center fk:lg:px-0",children:[jsx("div",{className:"fk:w-full fk:lg:p-8",children:jsxs("div",{className:"fk:mx-auto fk:flex fk:flex-col fk:justify-center fk:sm: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$k,{className:"fk:text-sm fk:font-normal fk:text-left fk:text-muted-foreground",htmlFor:"project",children:"Select project"}),jsxs(a$5,{defaultValue:n.projectId,onValueChange:g=>{o(t.find(h=>h.projectId===g)??t[0]);},children:[jsx(d$1,{className:"fk:mb-4 fk:w-full fk:h-9 fk:py-1",id:"project",children:jsx(c$1,{"aria-label":n.title,children:n.title})}),jsx(e$1,{children:t.map(g=>jsx(g$1,{value:g.projectId,children:g.title},g.projectId))})]})]}):null,r?jsx(fr,{projectId:e,setIsEmailLogin:i}):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:[s.providers.map(g=>jsx(b$3,{asChild:true,className:`fk:${g.button.color} fk:${g.button.backgroundColor} fk:hover:${g.button.colorHover} fk:hover:${g.button.backgroundColorHover}`,type:"button",variant:g.button.variant,children:jsxs("a",{href:gc({url:g.url,projectId:n.projectId,basePath:"/api/flexkit/get-token",fromPath:d$2}),children:[g.button.iconUrl?jsx("img",{alt:g.title,className:"fk:w-[20px] fk:h-[20px] fk:mr-2",src:g.button.iconUrl}):null,g.title]})},g.name)),jsx(b$3,{className:"fk:mt-4! fk:text-sm fk:text-center fk:text-link",onClick:()=>{i(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-28",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 fk:after:content-['|'] fk:after:pl-6",children:jsx("a",{className:"fk:underline-offset-4 fk:hover:text-primary",href:"https://www.flexkit.io",children:"flexkit.io"})}),jsx("li",{className:"fk:pr-6 fk:after:content-['|'] fk:after:pl-6",children:jsx("a",{className:"fk:underline-offset-4 fk:hover:text-primary",href:"https://www.flexkit.io/docs",children:"Docs"})}),jsx("li",{className:"",children:jsx("a",{className:"fk:underline-offset-4 fk:hover:text-primary",href:"https://www.flexkit.io/privacy-policy",children:"Privacy Policy"})})]})]})]})}),jsx("div",{className:"fk:hidden fk:text-white! fk:bg-bitbucket! fk:hover:bg-bitbucket-hover!"}),jsx("div",{className:"fk:hidden fk:bg-github! fk:hover:bg-github-hover!"}),jsx("div",{className:"fk:hidden fk:text-muted-foreground! fk:bg-white! fk:hover: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 fk:dark: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 ",f]})]}),jsx(ho,{})]})})]})}function gc({projectId:e,url:t,basePath:n,fromPath:o}){let r=new URLSearchParams;return r.set("origin",`${location.origin}${n}`),r.set("projectId",e),r.set("redirect",o),`${t}?${r.toString()}`}var kc=["PROJECT_PAUSED","PROJECT_NOT_FOUND","READ_ONLY_MODE","UNKNOWN_ERROR"],hc={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"},bo=class e extends Error{code;constructor(t,n){super(n??hc[t]),this.name="FlexkitError",this.code=t,Object.setPrototypeOf&&Object.setPrototypeOf(this,new.target.prototype);}static from(t,n){return new e(t,n)}};function dr(e){if(!(e instanceof Error))return false;let t=e.code;return typeof t!="string"?false:kc.includes(t)}function gs(e){if(dr(e))return e.code}var yc={developer:true,owner:true};function ks(e){return !!(e&&yc[e])}function hs(e){return `/api/flexkit/${e}/tools/dev-connect/tick`}var mr=2e3,bc=1e4,pr=false;async function Cc(e){try{let t=await fetch(e,{credentials:"same-origin",method:"POST"});if(t.status!==200)return !1;let n=await t.json();return typeof n.job=="string"&&n.job.length>0}catch{return false}}function ys({projectId:e,role:t}){return useEffect(()=>{if(!ks(t)||!e)return;let n=false,o=mr,r,i=hs(e);function s(l){n||document.hidden||(r!==void 0&&window.clearTimeout(r),r=window.setTimeout(()=>{a();},l));}async function a(){if(n||document.hidden)return;if(pr){s(o);return}pr=true;let l=await Cc(i);pr=false,l?o=mr:o=Math.min(o*2,bc),s(o);}function c(){if(document.hidden){r!==void 0&&(window.clearTimeout(r),r=void 0);return}o=mr,a();}return a(),document.addEventListener("visibilitychange",c),()=>{n=true,document.removeEventListener("visibilitychange",c),r!==void 0&&window.clearTimeout(r);}},[e,t]),null}function ws({apps:e,version:t}){let[n,o]=useState(0),[r,i]=useState(e),[s,a]=useState([]),c=useRef(null),l=useLocation(),{projectId:u}=useParams(),f=e.find(p=>l.pathname.includes(`/${u}/${p.name}`))?.name,m$1=e.find(p=>l.pathname.includes(`/${u}/${p.name}`))?.name??e[0]?.name;return useEffect(()=>{if(c.current===null)return;let p=new ResizeObserver(()=>{o(c.current?.offsetHeight??0);});return p.observe(c.current),function(){p.disconnect();}},[f]),useEffect(()=>{let p=Math.floor(n/48)-2,d=e.slice(0,p);if(!d.find(h=>h.name===m$1)){let h=e.find(v=>v.name===m$1);d.pop(),h&&d.push(h);}let g=e.filter(h=>!d.includes(h));i(d),a(g);},[e,m$1,n]),f===void 0&&m$1?jsx(Navigate,{to:`${l.pathname}/${m$1}`}):jsx(a$8,{children:jsxs("div",{className:"fk:flex fk:flex-col fk:h-full fk:w-12 fk:bg-muted",ref:c,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$4,{asChild:true,className:"fk:h-12 fk:p-2 fk:rounded-none fk:border-2 fk:border-transparent! fk:data-[state=active]:border-l-foreground! fk:focus-visible:outline-hidden fk:focus-visible:ring-0 fk:focus-visible:ring-offset-0 fk:focus-visible:border-2! fk:focus-visible:border-ring! fk:focus-visible:rounded-xs",children:jsx(NavLink,{className:"fk:text-muted-foreground fk:aria-[current]:text-foreground fk:aria-[current]:bg-background fk:aria-[current]:border-l-white!",to:p.name,children:p.icon})}),jsx(e$3,{side:"right",children:jsx("p",{children:p.title})})]})},p.name))}),s.length>0&&jsxs(c$3,{children:[jsx(b$5,{children:jsx(e$2,{asChild:true,children:jsxs(c$4,{className:"fk:flex fk: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-hidden fk:focus-visible:border-2 fk:focus-visible:border-ring fk:focus-visible:rounded-xs",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$3,{side:"right",children:jsx("p",{children:"Additional apps"})})]})})}),jsx(f$2,{align:"start",className:"fk:w-56",side:"right",children:s.map(p=>jsx(h$2,{asChild:true,children:jsx(NavLink,{to:p.name,children:p.title})},p.name))})]})]}),jsxs(c$3,{children:[jsx(b$5,{children:jsx(e$2,{asChild:true,children:jsxs(c$4,{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-hidden fk:focus-visible:border-2 fk:focus-visible:border-ring fk:focus-visible:rounded-xs",children:[jsx(Settings,{className:"fk:w-5 fk:h-5",strokeWidth:1.5}),jsx("span",{className:"fk:sr-only",children:"Settings menu"}),jsx(e$3,{side:"right",children:jsx("p",{children:"Settings menu"})})]})})}),jsxs(f$2,{align:"start",className:"fk:w-60",side:"right",children:[jsx(h$2,{asChild:true,children:jsxs(Link$1,{to:`https://flexkit.io/dashboard/*/${u}`,target:"_blank",rel:"noopener noreferrer",children:[jsx(Wrench,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Manage project"})]})}),jsx(m,{}),jsx(h$2,{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 Pc={"navbar.logo":lazy(()=>import('./logo-B6ZKLGM7.js').then(({Logo:e})=>({default:e}))),"navbar.projectSelector":lazy(()=>import('./project-selector-X6YVZYKL.js').then(({ProjectSelector:e})=>({default:e}))),"navbar.search":lazy(()=>import('./search-KIII5N7I.js').then(({Search:e})=>({default:e}))),"navbar.userNav":lazy(()=>import('./user-nav-6UKDSUF3.js').then(({UserNav:e})=>({default:e}))),"formFields.switch":lazy(()=>import('./switch-TACKLQJH.js').then(({Switch:e})=>({default:e}))),"formFields.text":lazy(()=>import('./text-M3DRK7LU.js').then(({Text:e})=>({default:e}))),"formFields.textarea":lazy(()=>import('./textarea-YF4K2VBM.js').then(({Textarea:e})=>({default:e}))),"previewFields.boolean":lazy(()=>import('./boolean-MTD44LXP.js').then(({Boolean:e})=>({default:e}))),"previewFields.asset":lazy(()=>import('./asset-ZVPFS73O.js').then(({Asset:e})=>({default:e}))),"previewFields.text":lazy(()=>import('./text-SQXG7XJT.js').then(({Text:e})=>({default:e}))),"previewFields.editor":lazy(()=>import('./editor-HAYTKNMY.js').then(({Editor:e})=>({default:e}))),"previewFields.datetime":lazy(()=>import('./datetime-DDEWTNLB.js').then(({DateTime:e})=>({default:e}))),"previewFields.select":lazy(()=>import('./select-H3JHOCWR.js').then(({Select:e})=>({default:e})))};function Ln(e){let{getContributionPointConfig:t}=d(),[n,...o]=e.split("."),r=Pc[e],i=t(n,o);return i?.length>0?i[0]?.component:r}function Ss({projectId:e,projects:t}){let{resolvedTheme:n}=b$b(),o=Ln("navbar.logo"),r=Ln("navbar.projectSelector"),i=Ln("navbar.search"),s=Ln("navbar.userNav"),a=t.find(m=>m.projectId===e)??t[0],{basePath:c,schema:l}=a,u=useNavigate();function f(m){startTransition(()=>{u(b$a(c,e,"desk","list",m.entityNamePlural)+`?id=${m.entityId}`);});}return jsxs("div",{className:"fk:flex fk:basis-14 fk:min-h-14 fk:px-3 fk:gap-x-4 fk:border-b fk:border-border fk:z-30",children:[jsx(Suspense,{fallback:null,children:jsx(o,{theme:n,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(i,{onSelect:f,projectId:e,schema:l},e)})]}),jsx("div",{className:"fk:flex fk:items-center",children:jsx(Suspense,{fallback:null,children:jsx(s,{projectId:e})})})]})}function Es({version:e}){let{contributions:t,projects:n}=d(),[o,r]=b(),{projectId:i}=useParams(),s=find(propEq(i??"","projectId"))(n);if(!s)throw new bo("PROJECT_NOT_FOUND");let{scopes:a}=s,{apps:c}=t,l=d$2(),u=useLocation();return useEffect(()=>{if(a){let f=a.find(p=>p.isDefault)||a[0],m="";typeof localStorage<"u"&&(m=localStorage.getItem(`${a$i}${i}`)??""),l({type:"setScope",payload:{projectId:i,scope:m||f.name}});}},[u]),o?jsx(yo,{}):r.user?.id?jsxs(Fragment,{children:[jsxs("div",{className:"fk:flex fk:flex-col fk:h-full flexkit-studio","vaul-drawer-wrapper":"",children:[jsx(Ss,{projectId:i??"",projects:n}),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(ws,{apps:c,version:e}),jsx(Outlet,{})]})]}),jsx(f$3,{}),jsx(ys,{projectId:i??"",role:r.user.role})]}):jsx(ps,{projectId:i??""})}function Ns(e){return e?"cause"in e:false}function Xt(e){if(!e)return null;if(ServerError.is(e))return e;if(Ns(e)){let t=e.cause;if(ServerError.is(t))return t}return null}function Ds(e){if(!e||typeof e!="object")return null;let{message:t}=e;return typeof t=="string"?t:null}function Wt(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function wo(e){if(!e)return null;let t=Rs(e).filter(n=>!qc(n));return t.length===0?null:["The deployed schema is out of sync with your local Flexkit schema.","Run `flexkit deploy` using the CLI to apply your latest schema changes.",...t.map(n=>`- ${n}`)].join(`
|
|
2
|
-
`)}function
|
|
1
|
+
import'./index.css';import {a as a$2}from'./chunk-UWMJBBTY.js';import {a as a$1}from'./chunk-UGRS4FEI.js';import {a as a$b}from'./chunk-D4XLXU2H.js';import {a as a$d}from'./chunk-S6MOM5G3.js';import {a as a$a}from'./chunk-3VOTTOJT.js';import {a,b as b$7}from'./chunk-5I7Q5ODB.js';import {a as a$e}from'./chunk-JKHUO27E.js';import {a as a$c}from'./chunk-PENRGDNC.js';import'./chunk-7JFLGBWE.js';import {e,f,g,k,l,m,n,o,q,r,s,t,v,w as w$1,z as z$1,A,x as x$1,B,E,i as i$2,c as c$8,d as d$3,j as j$1}from'./chunk-7ZJN4MWQ.js';import {a as a$6}from'./chunk-YSLN4XT6.js';import'./chunk-7BOX7HHO.js';import {a as a$7,b as b$5,c as c$4,e as e$4}from'./chunk-USNXQOMJ.js';import {d as d$2,c as c$2,e as e$5,b as b$9,a as a$i,f as f$4}from'./chunk-JH4MVD36.js';export{c as useAppContext,d as useAppDispatch,f as useSearch}from'./chunk-JH4MVD36.js';import {w,x,c as c$5,b as b$6,n as n$1,p,q as q$1,s as s$1,u,t as t$1,r as r$1}from'./chunk-W3Z33ETA.js';import {a as a$4,d as d$1,c as c$1,e as e$2,b as b$2,f as f$2,g as g$2}from'./chunk-HDOIOXMP.js';import {b,a as a$j}from'./chunk-WJ4ORIXF.js';export{b as useAuth}from'./chunk-WJ4ORIXF.js';import {c as c$3,e as e$3,f as f$3,g as g$3,h as h$1,m as m$1,a as a$h,l as l$1,i as i$1,b as b$b,r as r$2}from'./chunk-HMMBYXYA.js';import {d,a as a$f,b as b$8,e as e$6,c as c$7}from'./chunk-LIV5RBWJ.js';export{a as assetSchema,b as tagSchema,d as useConfig}from'./chunk-LIV5RBWJ.js';import {b as b$4,c as c$6,a as a$l}from'./chunk-WDRCARCP.js';export{b as IMAGES_BASE_URL}from'./chunk-WDRCARCP.js';import {b as b$3,a as a$9}from'./chunk-6NRQMG26.js';import {a as a$g,b as b$a}from'./chunk-WIUPQHZ5.js';import {a as a$3}from'./chunk-FLT6RWXH.js';import {a as a$5}from'./chunk-QOX3QNMM.js';export{a as DefaultValueSwitch}from'./chunk-QOX3QNMM.js';import'./chunk-QVBNGGOE.js';import {b as b$1,c,e as e$1,f as f$1,h,g as g$1,i,j,a as a$k}from'./chunk-GBM7VKFS.js';import {a as a$8}from'./chunk-O2QMYUPS.js';import*as Io from'react';import {lazy,createContext,memo,forwardRef,useMemo,useState,useRef,useEffect,useImperativeHandle,createElement,useId,useCallback,useContext,Fragment as Fragment$1,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 {find,propEq,equals,uniqBy,prop,map,uniq,omit,pick,toPairs,props}from'ramda';import oc,{useSWRConfig}from'swr';import {Text,CheckSquare,Heading1,Heading2,Heading3,List,ListOrdered,TextQuote,Code,ImageIcon,Youtube,Twitter,AlertTriangle,Image,Upload,Search,File,Ellipsis,Download,Copy,RefreshCwOff,Maximize2,X,Calendar,ChevronsUpDown,Link,TextIcon,ChevronDown,Check,Trash,SigmaIcon,BoldIcon,ItalicIcon,UnderlineIcon,StrikethroughIcon,CodeIcon,ChevronLeftIcon,ChevronRightIcon,ChevronDownIcon,ArrowUp,ArrowDown,TrashIcon,RefreshCcwDot,CheckCheck,ArrowDownWideNarrow,WrapText,StepForward,Trash2,AlertCircle,CirclePlus,PencilIcon,Trash2Icon,Settings2,RefreshCw,Loader2,MoreHorizontal,Settings,Wrench,PackageCheck,PackageX,Moon,Sun,Monitor,Mail,LoaderCircle}from'lucide-react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useForm}from'react-hook-form';import*as vo from'zod';import {z}from'zod';import {zodResolver}from'@hookform/resolvers/zod';import {gql,NetworkStatus,ApolloClient,InMemoryCache,defaultDataIdFromObject,from,HttpLink}from'@apollo/client';export{gql}from'@apollo/client';import {useLazyQuery,useApolloClient,useMutation,useQuery,ApolloProvider}from'@apollo/client/react';import {ErrorLink}from'@apollo/client/link/error';import {ServerError,CombinedGraphQLErrors,CombinedProtocolErrors}from'@apollo/client/errors';import {Popover,AlertDialog}from'radix-ui';import {toast}from'sonner';import {v4}from'uuid';import _r from'bytes';import {defaultStyles,FileIcon}from'react-file-icon';import {format}from'date-fns';import {getDefaultClassNames,DayPicker}from'react-day-picker';import {createSuggestionItems,Command,renderItems,EditorRoot,EditorContent,EditorCommand,EditorCommandEmpty,EditorCommandList,EditorCommandItem,ImageResizer,handleImageDrop,handleImagePaste,handleCommandNavigation,useEditor,removeAIHighlight,EditorBubble,EditorBubbleItem,addAIHighlight,getPrevText}from'novel';import {useDebouncedCallback}from'use-debounce';import {useCompletion}from'@ai-sdk/react';import zd from'react-markdown';import {useReactTable,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 ho(){let[e,t]=useState(false),{theme:n,setTheme:o}=b$b();return useEffect(()=>{t(true);},[]),e?jsxs(c$8,{size:"sm",type:"single",value:n,children:[jsx(d$3,{"aria-label":"Set dark mode",onClick:()=>{o("dark");},value:"dark",children:jsx(Moon,{className:"fk:h-4 fk:w-4"})}),jsx(d$3,{"aria-label":"Set light mode",onClick:()=>{o("light");},value:"light",children:jsx(Sun,{className:"fk:h-4 fk:w-4"})}),jsx(d$3,{"aria-label":"Set system mode",onClick:()=>{o("system");},value:"system",children:jsx(Monitor,{className:"fk:h-4 fk:w-4"})})]}):null}function yo(){let{resolvedTheme:e}=b$b();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 cc=vo.object({email:vo.email({error:"Please enter a valid email address"})});function cr({projectId:e$2,setIsEmailLogin:t}){let[n,o]=useState(false),[r,i$1]=useState(false),{mutate:s}=useSWRConfig(),l=useForm({resolver:zodResolver(cc),defaultValues:{email:""}}),c$1=new URL(c$6(e$2).loginOtpSend,a$l),{data:a,error:u,isLoading:d}=oc(r?c$1.href:null,h=>fetch(h,{method:"POST",mode:"cors",body:JSON.stringify({email:l.getValues("email")})}).then(y=>y.json()),{revalidateIfStale:false,revalidateOnFocus:false,revalidateOnReconnect:false,shouldRetryOnError:false}),f=a&&"error"in a&&a.error.code,m=a&&"token"in a,p=a&&"token"in a?a.token:"";useEffect(()=>{if(!m)return;let h=0,y=setInterval(()=>{if(h>100){clearInterval(y),o(true);return}let v=new URL(c$6(e$2).loginOtpConfirm,a$l),b="/api/flexkit/set-token";fetch(`${v.href}?email=${encodeURIComponent(l.getValues("email"))}&token=${encodeURIComponent(p)}`).then(x=>{x.status===200&&x.json().then(A=>{fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sid:A.sid})}).then(()=>{window.location.reload();}).catch(()=>{});}).catch(()=>{});}).catch(()=>{}),h++;},3e3);return ()=>{clearInterval(y);}},[l,m,e$2,p]);function g$2(){o(false),i$1(true),s(c$1.href);}return jsx("div",{className:"fk:w-full",children:m?jsx(e,{className:"fk:dark:bg-foreground fk:dark:text-background",variant:"default",children:jsxs(g,{children:["Keep this window open and in a new tab open the link we just sent to:"," ",jsx("strong",{children:l.getValues("email")})," (",jsx(b$3,{className:"fk:p-0 fk:hover:underline fk:text-link",onClick:()=>{window.location.reload();},variant:"link",children:"undo"}),")"]})}):jsx(b$1,{...l,children:jsxs("form",{onSubmit:h=>{l.handleSubmit(g$2)(h);},className:"fk:w-full fk:space-y-3 fk:mb-10",children:[f==="not_exists"&&jsx(e,{variant:"destructive",children:jsxs(g,{children:["There is no Flexkit account associated with this email address."," ",jsx("a",{className:"fk:text-black/90 fk:dark:text-white/90 fk:underline",href:`https://flexkit.io/signup/email?email=${encodeURIComponent(l.getValues("email"))}`,children:"Sign up?"})]})}),f==="unknown_error"||u?jsx(e,{variant:"destructive",children:jsxs(g,{children:["There was an unknown error, please"," ",jsx(b$3,{className:"fk:p-0 fk:hover:underline",onClick:()=>{window.location.reload();},variant:"link",children:"try again"}),"."," "]})}):null,n?jsx(e,{variant:"destructive",children:jsxs(g,{children:["The email verification link may have expired. Please"," ",jsx(b$3,{className:"fk:p-0 fk:hover:underline",onClick:()=>{window.location.reload();},variant:"link",children:"try again"}),"."]})}):null,jsx(c,{control:l.control,defaultValue:"",name:"email",render:({field:h})=>jsxs(e$1,{children:[jsx(g$1,{children:jsx(a$6,{"aria-label":"Email Address",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"w-full",placeholder:"Email Address",spellCheck:false,type:"email",...h})}),jsx(i,{})]})}),jsxs(b$3,{"aria-disabled":d,className:"fk:w-full",type:"submit",disabled:!!d,children:[d?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 ms({projectId:e}){let{projects:t}=d(),[n,o]=useState(t.find(g=>g.projectId===e)??t[0]),[r,i]=useState(false),{data:s,error:l,isLoading:c}=oc(c$6(e).authProviders,g=>fetch(g,{mode:"cors"}).then(h=>h.json())),[a,u]=b(),d$2=new Date().getFullYear(),f=useLocation(),m=f.state?.from?.pathname??f.pathname,p=m.includes(n.projectId)?`${location.origin}${m}`:`${location.origin}${b$a(n.basePath,n.projectId)}`;if(l)throw new Error("Error fetching auth providers");return c||a||!s?jsx(yo,{}):u.user?.id?jsx(Navigate,{replace:true,state:{from:f},to:n.basePath}):jsxs(Fragment,{children:[jsxs("div",{className:"fk:container fk:relative fk:h-[calc(100vh-3rem)] fk:flex fk:items-center fk:justify-center fk:lg:px-0",children:[jsx("div",{className:"fk:w-full fk:lg:p-8",children:jsxs("div",{className:"fk:mx-auto fk:flex fk:flex-col fk:justify-center fk:sm: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$k,{className:"fk:text-sm fk:font-normal fk:text-left fk:text-muted-foreground",htmlFor:"project",children:"Select project"}),jsxs(a$4,{defaultValue:n.projectId,onValueChange:g=>{o(t.find(h=>h.projectId===g)??t[0]);},children:[jsx(d$1,{className:"fk:mb-4 fk:w-full fk:h-9 fk:py-1",id:"project",children:jsx(c$1,{"aria-label":n.title,children:n.title})}),jsx(e$2,{children:t.map(g=>jsx(g$2,{value:g.projectId,children:g.title},g.projectId))})]})]}):null,r?jsx(cr,{projectId:e,setIsEmailLogin:i}):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:[s.providers.map(g=>jsx(b$3,{asChild:true,className:`fk:${g.button.color} fk:${g.button.backgroundColor} fk:hover:${g.button.colorHover} fk:hover:${g.button.backgroundColorHover}`,type:"button",variant:g.button.variant,children:jsxs("a",{href:mc({url:g.url,projectId:n.projectId,basePath:"/api/flexkit/get-token",fromPath:p}),children:[g.button.iconUrl?jsx("img",{alt:g.title,className:"fk:w-[20px] fk:h-[20px] fk:mr-2",src:g.button.iconUrl}):null,g.title]})},g.name)),jsx(b$3,{className:"fk:mt-4! fk:text-sm fk:text-center fk:text-link",onClick:()=>{i(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-28",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 fk:after:content-['|'] fk:after:pl-6",children:jsx("a",{className:"fk:underline-offset-4 fk:hover:text-primary",href:"https://www.flexkit.io",children:"flexkit.io"})}),jsx("li",{className:"fk:pr-6 fk:after:content-['|'] fk:after:pl-6",children:jsx("a",{className:"fk:underline-offset-4 fk:hover:text-primary",href:"https://www.flexkit.io/docs",children:"Docs"})}),jsx("li",{className:"",children:jsx("a",{className:"fk:underline-offset-4 fk:hover:text-primary",href:"https://www.flexkit.io/privacy-policy",children:"Privacy Policy"})})]})]})]})}),jsx("div",{className:"fk:hidden fk:text-white! fk:bg-bitbucket! fk:hover:bg-bitbucket-hover!"}),jsx("div",{className:"fk:hidden fk:bg-github! fk:hover:bg-github-hover!"}),jsx("div",{className:"fk:hidden fk:text-muted-foreground! fk:bg-white! fk:hover: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 fk:dark: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 ",d$2]})]}),jsx(ho,{})]})})]})}function mc({projectId:e,url:t,basePath:n,fromPath:o}){let r=new URLSearchParams;return r.set("origin",`${location.origin}${n}`),r.set("projectId",e),r.set("redirect",o),`${t}?${r.toString()}`}var pc=["PROJECT_PAUSED","PROJECT_NOT_FOUND","READ_ONLY_MODE","UNKNOWN_ERROR"],gc={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"},bo=class e extends Error{code;constructor(t,n){super(n??gc[t]),this.name="FlexkitError",this.code=t,Object.setPrototypeOf&&Object.setPrototypeOf(this,new.target.prototype);}static from(t,n){return new e(t,n)}};function ur(e){if(!(e instanceof Error))return false;let t=e.code;return typeof t!="string"?false:pc.includes(t)}function ps(e){if(ur(e))return e.code}var kc={developer:true,owner:true};function gs(e){return !!(e&&kc[e])}function ks(e){return `/api/flexkit/${e}/tools/dev-connect/tick`}var fr=2e3,yc=1e4,dr=false;async function vc(e){try{let t=await fetch(e,{credentials:"same-origin",method:"POST"});if(t.status!==200)return !1;let n=await t.json();return typeof n.job=="string"&&n.job.length>0}catch{return false}}function hs({projectId:e,role:t}){return useEffect(()=>{if(!gs(t)||!e)return;let n=false,o=fr,r,i=ks(e);function s(a){n||document.hidden||(r!==void 0&&window.clearTimeout(r),r=window.setTimeout(()=>{l();},a));}async function l(){if(n||document.hidden)return;if(dr){s(o);return}dr=true;let a=await vc(i);dr=false,a?o=fr:o=Math.min(o*2,yc),s(o);}function c(){if(document.hidden){r!==void 0&&(window.clearTimeout(r),r=void 0);return}o=fr,l();}return l(),document.addEventListener("visibilitychange",c),()=>{n=true,document.removeEventListener("visibilitychange",c),r!==void 0&&window.clearTimeout(r);}},[e,t]),null}function Cs({apps:e,version:t}){let[n,o]=useState(0),[r,i]=useState(e),[s,l]=useState([]),c=useRef(null),a=useLocation(),{projectId:u}=useParams(),d=e.find(m=>a.pathname.includes(`/${u}/${m.name}`))?.name,f=e.find(m=>a.pathname.includes(`/${u}/${m.name}`))?.name??e[0]?.name;return useEffect(()=>{if(c.current===null)return;let m=new ResizeObserver(()=>{o(c.current?.offsetHeight??0);});return m.observe(c.current),function(){m.disconnect();}},[d]),useEffect(()=>{let m=Math.floor(n/48)-2,p=e.slice(0,m);if(!p.find(h=>h.name===f)){let h=e.find(y=>y.name===f);p.pop(),h&&p.push(h);}let g=e.filter(h=>!p.includes(h));i(p),l(g);},[e,f,n]),d===void 0&&f?jsx(Navigate,{to:`${a.pathname}/${f}`}):jsx(a$7,{children:jsxs("div",{className:"fk:flex fk:flex-col fk:h-full fk:w-12 fk:bg-muted",ref:c,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(m=>jsx(b$3,{asChild:true,className:"fk:h-12 fk:w-12",variant:"ghost",children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,className:"fk:h-12 fk:p-2 fk:rounded-none fk:border-2 fk:border-transparent! fk:data-[state=active]:border-l-foreground! fk:focus-visible:outline-hidden fk:focus-visible:ring-0 fk:focus-visible:ring-offset-0 fk:focus-visible:border-2! fk:focus-visible:border-ring! fk:focus-visible:rounded-xs fk:corner-squircle",children:jsx(NavLink,{className:"fk:text-muted-foreground fk:aria-[current]:text-foreground fk:aria-[current]:bg-background fk:aria-[current]:border-l-white!",to:m.name,children:m.icon})}),jsx(e$4,{side:"right",children:jsx("p",{children:m.title})})]})},m.name))}),s.length>0&&jsxs(c$3,{children:[jsx(b$5,{children:jsx(e$3,{asChild:true,children:jsxs(c$4,{className:"fk:flex fk: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-hidden fk:focus-visible:border-2 fk:focus-visible:border-ring fk:focus-visible:rounded-xs",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$4,{side:"right",children:jsx("p",{children:"Additional apps"})})]})})}),jsx(f$3,{align:"start",className:"fk:w-56",side:"right",children:s.map(m=>jsx(h$1,{asChild:true,children:jsx(NavLink,{to:m.name,children:m.title})},m.name))})]})]}),jsxs(c$3,{children:[jsx(b$5,{children:jsx(e$3,{asChild:true,children:jsxs(c$4,{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-hidden fk:focus-visible:border-2 fk:focus-visible:border-ring fk:focus-visible:rounded-xs",children:[jsx(Settings,{className:"fk:w-5 fk:h-5",strokeWidth:1.5}),jsx("span",{className:"fk:sr-only",children:"Settings menu"}),jsx(e$4,{side:"right",children:jsx("p",{children:"Settings menu"})})]})})}),jsxs(f$3,{align:"start",className:"fk:w-60",side:"right",children:[jsx(h$1,{asChild:true,children:jsxs(Link$1,{to:`https://flexkit.io/dashboard/*/${u}`,target:"_blank",rel:"noopener noreferrer",children:[jsx(Wrench,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Manage project"})]})}),jsx(m$1,{}),jsx(h$1,{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 Fc={"navbar.logo":lazy(()=>import('./logo-MU7MGYDH.js').then(({Logo:e})=>({default:e}))),"navbar.projectSelector":lazy(()=>import('./project-selector-GQ24PVO6.js').then(({ProjectSelector:e})=>({default:e}))),"navbar.search":lazy(()=>import('./search-XKG5A7XM.js').then(({Search:e})=>({default:e}))),"navbar.userNav":lazy(()=>import('./user-nav-LSEOOH4E.js').then(({UserNav:e})=>({default:e}))),"formFields.switch":lazy(()=>import('./switch-SU3OIXL6.js').then(({Switch:e})=>({default:e}))),"formFields.text":lazy(()=>import('./text-FZSI6W5I.js').then(({Text:e})=>({default:e}))),"formFields.textarea":lazy(()=>import('./textarea-INLURFNU.js').then(({Textarea:e})=>({default:e}))),"previewFields.boolean":lazy(()=>import('./boolean-MTD44LXP.js').then(({Boolean:e})=>({default:e}))),"previewFields.asset":lazy(()=>import('./asset-3XMRPTA5.js').then(({Asset:e})=>({default:e}))),"previewFields.text":lazy(()=>import('./text-QXGOD2KW.js').then(({Text:e})=>({default:e}))),"previewFields.editor":lazy(()=>import('./editor-NZLXIOE7.js').then(({Editor:e})=>({default:e}))),"previewFields.datetime":lazy(()=>import('./datetime-C55QQQJK.js').then(({DateTime:e})=>({default:e}))),"previewFields.select":lazy(()=>import('./select-SO3DICYX.js').then(({Select:e})=>({default:e})))};function Pn(e){let{getContributionPointConfig:t}=d(),[n,...o]=e.split("."),r=Fc[e],i=t(n,o);return i?.length>0?i[0]?.component:r}function Ss({projectId:e,projects:t}){let{resolvedTheme:n}=b$b(),o=Pn("navbar.logo"),r=Pn("navbar.projectSelector"),i=Pn("navbar.search"),s=Pn("navbar.userNav"),l=t.find(f=>f.projectId===e)??t[0],{basePath:c,schema:a}=l,u=useNavigate();function d(f){startTransition(()=>{u(b$a(c,e,"desk","list",f.entityNamePlural)+`?id=${f.entityId}`);});}return jsxs("div",{className:"fk:flex fk:basis-14 fk:min-h-14 fk:px-3 fk:gap-x-4 fk:border-b fk:border-border fk:z-30",children:[jsx(Suspense,{fallback:null,children:jsx(o,{theme:n,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(i,{onSelect:d,projectId:e,schema:a},e)})]}),jsx("div",{className:"fk:flex fk:items-center",children:jsx(Suspense,{fallback:null,children:jsx(s,{projectId:e})})})]})}function xs({version:e}){let{contributions:t,projects:n}=d(),[o,r]=b(),{projectId:i}=useParams(),s=find(propEq(i??"","projectId"))(n);if(!s)throw new bo("PROJECT_NOT_FOUND");let{scopes:l}=s,{apps:c}=t,a=d$2(),u=useLocation();return useEffect(()=>{if(l){let d=l.find(m=>m.isDefault)||l[0],f="";typeof localStorage<"u"&&(f=localStorage.getItem(`${a$i}${i}`)??""),a({type:"setScope",payload:{projectId:i,scope:f||d.name}});}},[u]),o?jsx(yo,{}):r.user?.id?jsxs(Fragment,{children:[jsxs("div",{className:"fk:flex fk:flex-col fk:h-full flexkit-studio","vaul-drawer-wrapper":"",children:[jsx(Ss,{projectId:i??"",projects:n}),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(Cs,{apps:c,version:e}),jsx(Outlet,{})]})]}),jsx(i$2,{}),jsx(hs,{projectId:i??"",role:r.user.role})]}):jsx(ms,{projectId:i??""})}function Ts(e){return e?"cause"in e:false}function Xt(e){if(!e)return null;if(ServerError.is(e))return e;if(Ts(e)){let t=e.cause;if(ServerError.is(t))return t}return null}function Ns(e){if(!e||typeof e!="object")return null;let{message:t}=e;return typeof t=="string"?t:null}function Wt(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function wo(e){if(!e)return null;let t=Fs(e).filter(n=>!qc(n));return t.length===0?null:["The deployed schema is out of sync with your local Flexkit schema.","Run `flexkit deploy` using the CLI to apply your latest schema changes.",...t.map(n=>`- ${n}`)].join(`
|
|
2
|
+
`)}function Ds(e,t){return e?Fs(e).some(n=>n.includes(`Cannot query field "${t}"`)):false}function Fs(e){if(CombinedGraphQLErrors.is(e))return e.errors.filter(As).map(({message:r})=>r);let t=Ns(e);if(t&&Mn(t))return [t];let n=Xt(e);if(n?.statusCode!==400)return [];let o=Wt(n.bodyText)??zc(n)??jc(e);return o?Array.isArray(o.errors)?o.errors.filter(As).map(r=>r.message):typeof o.message=="string"&&Mn(o.message)?[o.message]:typeof o.error=="string"&&Mn(o.error)?[o.error]:[]:[]}function zc(e){let{result:t}=e;return !t||typeof t!="object"?null:t}function jc(e){if(!Ts(e))return null;let{cause:t}=e,n=Ns(t);if(n&&Mn(n))return {message:n};if(!t||typeof t!="object")return null;let{result:o}=t;return o&&typeof o=="object"?o:null}function As(e){if(!e||typeof e!="object")return false;let{extensions:t,message:n}=e;return t?.code==="GRAPHQL_VALIDATION_FAILED"&&typeof n=="string"?true:typeof n=="string"&&Mn(n)}function Mn(e){return e.startsWith("Cannot query field ")||e.startsWith("Unknown type ")||e.startsWith('Cannot query field "')||e.includes("GRAPHQL_VALIDATION_FAILED")}function qc(e){return /Cannot query field "[_A-Za-z][_0-9A-Za-z]*Total" on type "Query"/.test(e)}var nu=ApolloProvider,Ls=createContext(void 0);function Kt(){let e=useContext(Ls);if(!e)throw new Error("useGraphQLError must be used within GraphQLProvider");return e}function ou(e){return new ErrorLink(({error:t})=>{let n=wo(t);if(n){e(n);return}CombinedGraphQLErrors.is(t)?t.errors.forEach(({message:r,locations:i,path:s})=>{console.warn(`[GraphQL error]: Message: ${r}, Location: ${i}, Path: ${s}`);}):CombinedProtocolErrors.is(t)&&t.errors.forEach(({message:r,extensions:i})=>{console.warn(`[Protocol error]: Message: ${r}, Extensions: ${JSON.stringify(i)}`);});let o=Xt(t);if(o?.statusCode===400){let r=Wt(o.bodyText),i=null;if(r&&typeof r=="object"){let{error:s,errors:l,message:c}=r;if(typeof c=="string")i=c;else if(Array.isArray(l)){let[a]=l;if(a&&typeof a.message=="string"){let{message:u}=a;i=u;}}else typeof s=="string"?i=s:i=JSON.stringify(r);}else i=o.bodyText;e(i??"There is an error in your Flexkit schema (flexkit.config.ts).");}if(o){console.warn(`[Network error]: ${o.message}`);return}t&&console.warn(`[Network error]: ${t.message}`);})}function ru(e,t){return from([ou(t),new HttpLink({uri:`/api/flexkit/${e}/graphql`})])}function iu(e,t){return new ApolloClient({link:ru(e??"",t),cache:new InMemoryCache({dataIdFromObject:n=>n._id?n._id:defaultDataIdFromObject(n)})})}function Ps({children:e}){let{currentProjectId:t}=d(),[n,o]=useState(null),r=useMemo(()=>({schemaErrorMessage:n,setSchemaErrorMessage:o}),[n]),i=useMemo(()=>iu(t,o),[t]);return jsx(Ls.Provider,{value:r,children:jsx(nu,{client:i,children:e})})}function Ms({...e}){return jsx(AlertDialog.Root,{"data-slot":"alert-dialog",...e})}function gr({...e}){return jsx(AlertDialog.Portal,{"data-slot":"alert-dialog-portal",...e})}function su({className:e,...t}){return jsx(AlertDialog.Overlay,{"data-slot":"alert-dialog-overlay",className:a$8("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...t})}function _s({className:e,size:t="default",...n}){return jsxs(gr,{children:[jsx(su,{}),jsx(AlertDialog.Content,{"data-slot":"alert-dialog-content","data-size":t,className:a$8("fk:group/alert-dialog-content fk:fixed fk:top-[50%] fk:left-[50%] fk:z-50 fk:grid fk:w-full fk:max-w-[calc(100%-2rem)] fk:translate-x-[-50%] fk:translate-y-[-50%] fk:gap-4 fk:rounded-lg fk:border fk:bg-background fk:p-6 fk:shadow-lg fk:duration-200 fk:data-[size=sm]:max-w-xs fk:data-[state=closed]:animate-out fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:zoom-out-95 fk:data-[state=open]:animate-in fk:data-[state=open]:fade-in-0 fk:data-[state=open]:zoom-in-95 fk:data-[size=default]:sm:max-w-lg fk:corner-squircle",e),...n})]})}function $s({className:e,...t}){return jsx("div",{"data-slot":"alert-dialog-header",className:a$8("fk:grid fk:grid-rows-[auto_1fr] fk:place-items-center fk:gap-1.5 fk:text-center fk:has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] fk:has-data-[slot=alert-dialog-media]:gap-x-6 fk:sm:group-data-[size=default]/alert-dialog-content:place-items-start fk:sm:group-data-[size=default]/alert-dialog-content:text-left fk:sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function Os({className:e,...t}){return jsx("div",{"data-slot":"alert-dialog-footer",className:a$8("fk:flex fk:flex-col-reverse fk:gap-2 fk:group-data-[size=sm]/alert-dialog-content:grid fk:group-data-[size=sm]/alert-dialog-content:grid-cols-2 fk:sm:flex-row fk:sm:justify-end",e),...t})}function Vs({className:e,...t}){return jsx(AlertDialog.Title,{"data-slot":"alert-dialog-title",className:a$8("fk:text-lg fk:font-semibold fk:sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function Bs({className:e,...t}){return jsx(AlertDialog.Description,{"data-slot":"alert-dialog-description",className:a$8("fk:text-sm fk:text-muted-foreground",e),...t})}function zs({className:e,variant:t="default",size:n="default",...o}){return jsx(b$3,{variant:t,size:n,asChild:true,children:jsx(AlertDialog.Action,{"data-slot":"alert-dialog-action",className:a$8(e),...o})})}function js({className:e,variant:t="outline",size:n="default",...o}){return jsx(b$3,{variant:t,size:n,asChild:true,children:jsx(AlertDialog.Cancel,{"data-slot":"alert-dialog-cancel",className:a$8(e),...o})})}function _n({options:e}){let[t,n]=useState(false),[o,r]=useState(false),[i,s]=useState(false);useEffect(()=>{n(true);},[]);function l(){n(false),i||e.dialogActionCancel?.(),i&&s(false);}async function c(){r(true),s(true),n(false),await new Promise(a=>{globalThis.setTimeout(a,150);});try{let a=e.dialogActionSubmit?.();a&&typeof a.then=="function"&&await a;}finally{r(false);}}return jsx(Ms,{onOpenChange:l,open:t,children:jsx(gr,{children:jsxs(_s,{className:"sm:max-w-[425px]",children:[jsxs($s,{children:[jsx(Vs,{children:e.dialogTitle}),jsx(Bs,{children:e.dialogMessage})]}),jsxs(Os,{children:[jsx(js,{disabled:o,onClick:l,children:e.dialogCancelTitle}),jsxs(zs,{className:a$9({variant:e.isDestructive?"destructive":"default"}),disabled:o,onClick:c,children:[o?jsx(Loader2,{className:"fk:h-4 fk:w-4 fk:mr-2 fk:animate-spin"}):null,e.dialogActionLabel]})]})]})})})}var Js=createContext([]),Gs=createContext(()=>{});function fu(e,t){let n=t.type;switch(t._id||(t._id=Date.now().toString()),n){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(o=>o._id!==t._id);default:throw Error(`Unknown action: ${n}`)}}function Qs({children:e}){let[t,n]=useReducer(fu,[]);return jsx(Js.Provider,{value:t,children:jsx(Gs.Provider,{value:n,children:e})})}function Xs(){return useContext(Js)}function me(){return useContext(Gs)}function St(){let[e,t]=useState(false),[n,o]=useState(gql`
|
|
3
3
|
mutation updateEntity($any: Any) {
|
|
4
4
|
any
|
|
5
5
|
}
|
|
6
|
-
`),[r,i]=useState({}),[s,{data:
|
|
6
|
+
`),[r,i]=useState({}),[s,{data:l,loading:c,error:a}]=useMutation(n,r),u=Xt(a),{isProjectDisabled:d,isProjectReadOnly:f}=(()=>{if(u?.statusCode===403){let m=Wt(u.bodyText);if(m&&typeof m.code=="string"){if(m.code==="PROJECT_PAUSED")return {isProjectDisabled:true,isProjectReadOnly:false};if(m.code==="READ_ONLY_MODE")return {isProjectDisabled:false,isProjectReadOnly:true}}return {isProjectDisabled:true,isProjectReadOnly:false}}return {isProjectDisabled:false,isProjectReadOnly:false}})();return useEffect(()=>{e&&(s(),t(false));},[e,s]),[t,o,i,{data:l,loading:c,error:a,isProjectDisabled:d,isProjectReadOnly:f}]}function ye(e){return e.dataType==="asset"?"global":e.scope}function Vn(e){if(!e)return {};let t={};for(let[n,o]of Object.entries(e))t[n]=o?.value;return t}function xt(e,t){return typeof e=="function"?!!e(t):e===true}function yr(e){return e===true}var xo=25,ku=3,Ks=3,hu=["id","string"],yu=["date","datetime","duration","time"],Cr=`_id
|
|
7
7
|
originalFilename
|
|
8
8
|
mimeType
|
|
9
9
|
path
|
|
@@ -11,19 +11,19 @@ import'./index.css';import {a as a$3}from'./chunk-N2T6MKPV.js';import {a as a$2}
|
|
|
11
11
|
size
|
|
12
12
|
height
|
|
13
13
|
width
|
|
14
|
-
lqip`,
|
|
14
|
+
lqip`,wr=`_id
|
|
15
15
|
originalFilename
|
|
16
16
|
mimeType
|
|
17
17
|
path
|
|
18
18
|
url
|
|
19
19
|
size
|
|
20
20
|
height
|
|
21
|
-
width`,
|
|
21
|
+
width`,vu=`_id
|
|
22
22
|
path
|
|
23
|
-
url`;function Bn(e){return e?
|
|
23
|
+
url`;function Bn(e){return e?ye(e)==="relationship"&&e.relationship?.mode==="multiple"&&e.relationship.entity==="_asset":false}function Sr(e,t){return !e||!Bn(e)?false:t?.name!==b$8.name||e.name!=="assets"}function Eo(e){return e?.dataType==="asset"||e?.inputType==="asset"}function Ao(e){let t=e,n=t?.edges??[],o=t?.aggregate?.count?.nodes??n.length;return n.reduce((r,i,s)=>(i.node&&r.push({...i.node,sortOrder:i.properties?.sortOrder??s,totalCount:o}),r),[]).sort((r,i)=>(r.sortOrder??Number.MAX_SAFE_INTEGER)-(i.sortOrder??Number.MAX_SAFE_INTEGER))}function zn(e){return e.reduce((t,n,o)=>n._id?{...t,[n._id]:n.sortOrder??o}:t,{})}function Et(e){return Array.isArray(e)?e[0]??null:e??null}function bu(e,t){return t?vu:e?Cr:wr}function Zs(e,t=true,n=true,o=xo,r=false){let i=t?` properties {
|
|
24
24
|
sortOrder
|
|
25
25
|
}
|
|
26
|
-
`:"",s=
|
|
26
|
+
`:"",s=bu(n,r),l=t?`(first: ${o}, sort: [{ edge: { sortOrder: ASC } }])`:`(first: ${o})`;return ` ${e}Connection${l} {
|
|
27
27
|
aggregate {
|
|
28
28
|
count {
|
|
29
29
|
nodes
|
|
@@ -35,29 +35,29 @@ import'./index.css';import {a as a$3}from'./chunk-N2T6MKPV.js';import {a as a$2}
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
`}function
|
|
38
|
+
`}function Ys(e){return e?.aggregate?.count?.nodes??0}function ea(e,t){let n=e[`${t}Total`];return typeof n=="number"?n:Ys(e[`${t}Connection`])}function xr(e,t=""){return ` ${e}Connection${t} {
|
|
39
39
|
aggregate {
|
|
40
40
|
count {
|
|
41
41
|
nodes
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
`}function
|
|
46
|
-
`:
|
|
45
|
+
`}function Cu(e,t,n){return t?n==="total"?` ${e}Total
|
|
46
|
+
`:xr(e,"(where: $where)"):""}function wu(e,t,n,o=false){if(!e)return "";let r=t==="default"?"":`${t}
|
|
47
47
|
`;if(Eo(e))return o?` ${e.name} {
|
|
48
48
|
_id
|
|
49
49
|
path
|
|
50
50
|
url
|
|
51
51
|
}
|
|
52
52
|
`:` ${e.name} {
|
|
53
|
-
${
|
|
53
|
+
${Cr}
|
|
54
54
|
}
|
|
55
|
-
`;if(
|
|
55
|
+
`;if(ye(e)==="local")return ` ${e.name} {
|
|
56
56
|
_id
|
|
57
57
|
default
|
|
58
58
|
${r}}
|
|
59
|
-
`;if(
|
|
60
|
-
`;let s=find(propEq(e.relationship?.entity,"name"))(n),
|
|
59
|
+
`;if(ye(e)==="relationship"){let i=e.relationship?.field;if(!i)return ` ${e.name}
|
|
60
|
+
`;let s=find(propEq(e.relationship?.entity,"name"))(n),l=find(propEq(i,"name"))(s?.attributes??[]),c=l&&ye(l)==="local"?`{
|
|
61
61
|
_id
|
|
62
62
|
default
|
|
63
63
|
${r}}
|
|
@@ -66,18 +66,18 @@ import'./index.css';import {a as a$3}from'./chunk-N2T6MKPV.js';import {a as a$2}
|
|
|
66
66
|
`:` ${e.name} (limit: 3, offset: 0) {
|
|
67
67
|
${i} ${c}}
|
|
68
68
|
`}return ` ${e.name}
|
|
69
|
-
`}function
|
|
69
|
+
`}function Su(e,t,n){return e?.attributes.reduce((o,r)=>{let i=t==="default"?"":`${t}
|
|
70
70
|
`;if(Eo(r))return `${o}
|
|
71
71
|
${r.name} {
|
|
72
|
-
${
|
|
72
|
+
${wr}
|
|
73
73
|
}
|
|
74
|
-
`;if(
|
|
74
|
+
`;if(ye(r)==="local")return `${o}
|
|
75
75
|
${r.name} {
|
|
76
76
|
_id
|
|
77
77
|
default
|
|
78
78
|
${i}
|
|
79
79
|
}
|
|
80
|
-
`;if(
|
|
80
|
+
`;if(ye(r)==="relationship"){let s=find(propEq(r.relationship?.entity,"name"))(n),l=find(propEq(r.relationship?.field,"name"))(s?.attributes??[]),c=ye(l)==="local"?`{
|
|
81
81
|
_id
|
|
82
82
|
default
|
|
83
83
|
${i}}
|
|
@@ -85,25 +85,25 @@ import'./index.css';import {a as a$3}from'./chunk-N2T6MKPV.js';import {a as a$2}
|
|
|
85
85
|
${r.name} {
|
|
86
86
|
${r.relationship.field} ${c}}
|
|
87
87
|
`;if(r.relationship?.field)return `${o}
|
|
88
|
-
${r.name} (limit: ${
|
|
88
|
+
${r.name} (limit: ${Ks}, offset: 0) {
|
|
89
89
|
${r.relationship.field} ${c}}
|
|
90
90
|
`}return `${o}
|
|
91
91
|
${r.name}
|
|
92
|
-
`},"")??""}function
|
|
93
|
-
`),
|
|
94
|
-
${
|
|
92
|
+
`},"")??""}function xu(e){let t={};for(let n of e)t[n.name]=n;return t}function vr(e){return e?e.name==="url"?true:!(yr(e.hidden)||e.name==="lqip"):false}function Eu(e,t){if(!Array.isArray(e)||e.length===0)return;let[n]=e;if(!n||typeof n!="object")return;let[o]=Object.keys(n);if(!o||["_id","_createdAt","_updatedAt"].includes(o))return;let r=t?.attributes.find(i=>i.name===o);if(!(!r||ye(r)!=="global"||r.dataType==="asset"))return {NOT:{[o]:{eq:null}}}}function jn(e,t,n,o){let r=o?.selection??"full",i=r==="display"?"list":r,s=o?.includeCount??true,l=o?.countMode??"aggregate",c="(where: $where, limit: $limit, offset: $offset, sort: $sort)",a=rt(n,e),u=a?.name??e,d=e$5(a),f=r==="display"?d?[d]:[]:a?.attributes??[],m=xu(f),p=`$where: ${u}Where, $limit: Int, $offset: Int, $sort: [${u}Sort!]`,g=o?.operationName??`Get${ot(e)}`;if(!a)throw new Error(`Entity '${u}' not found in the schema`);if(f.length===0)throw new Error(`Entity '${u}' has no attributes defined in the schema`);let h=Ae("global",f).filter(T=>T==="_updatedAt"?false:i==="list"?r==="display"||vr(m[T]):true).join(`
|
|
93
|
+
`),y=qn(f).filter(T=>i!=="list"||r==="display"||vr(m[T])),v=Ae(["local"],f).filter(T=>i!=="list"?true:r==="display"||vr(m[T])),b=v.reduce((T,P)=>`${T}
|
|
94
|
+
${P} {
|
|
95
95
|
_id
|
|
96
96
|
default
|
|
97
97
|
}
|
|
98
|
-
`,""),
|
|
99
|
-
${
|
|
98
|
+
`,""),x=v.reduce((T,P)=>`${T}
|
|
99
|
+
${P} {
|
|
100
100
|
_id
|
|
101
101
|
default
|
|
102
102
|
${t}
|
|
103
103
|
}
|
|
104
|
-
`,""),
|
|
104
|
+
`,""),A=t==="default"?b:x,I=`_id
|
|
105
105
|
path
|
|
106
|
-
url`;
|
|
106
|
+
url`;i!=="list"&&(I=`_id
|
|
107
107
|
originalFilename
|
|
108
108
|
mimeType
|
|
109
109
|
path
|
|
@@ -111,157 +111,157 @@ import'./index.css';import {a as a$3}from'./chunk-N2T6MKPV.js';import {a as a$2}
|
|
|
111
111
|
size
|
|
112
112
|
height
|
|
113
113
|
width
|
|
114
|
-
lqip`);let
|
|
115
|
-
${
|
|
116
|
-
${
|
|
114
|
+
lqip`);let N=y.reduce((T,P)=>`${T}
|
|
115
|
+
${P} {
|
|
116
|
+
${I}
|
|
117
117
|
}
|
|
118
|
-
`,""),
|
|
119
|
-
${
|
|
120
|
-
${
|
|
118
|
+
`,""),B=f.filter(T=>ye(T)==="relationship").reduce((T,P)=>{if(i==="list"&&r!=="display"&&yr(P.hidden))return T;if(Bn(P))return `${T}
|
|
119
|
+
${Zs(P.name,Sr(P,a),i!=="list",i==="list"?ku:xo,i==="list")}`;let j=find(propEq(P.relationship?.entity,"name"))(n);if(i==="list"){let U=e$5(j),X=wu(U,t,n,true),Y=P.relationship?.mode==="single"?1:3;return `${T}
|
|
120
|
+
${P.name} (limit: ${Y}, offset: 0) {
|
|
121
121
|
_id
|
|
122
|
-
${
|
|
123
|
-
`}let
|
|
124
|
-
${
|
|
125
|
-
`},"");return {queryEntityName:e,query:`query ${
|
|
126
|
-
`+
|
|
122
|
+
${X} }
|
|
123
|
+
`}let F=Su(j,t,n);return `${xr(P.name).trim()}${T}
|
|
124
|
+
${P.name} (limit: 25, offset: 0) { _id ${F}}
|
|
125
|
+
`},"");return {queryEntityName:e,query:`query ${g}(${p}) {
|
|
126
|
+
`+Cu(e,s,l)+` ${e}${c} {
|
|
127
127
|
_id
|
|
128
128
|
_updatedAt
|
|
129
|
-
${
|
|
129
|
+
${h} ${A} ${N} ${B}}
|
|
130
130
|
}
|
|
131
|
-
`}}function To(e,t,n,o){let i=rt(o,e)?.attributes??[];if(i.length===0)return {count:0,results:[]};let s=
|
|
131
|
+
`}}function To(e,t,n,o){let i=rt(o,e)?.attributes??[];if(i.length===0)return {count:0,results:[]};let s=ea(n,e),l=n[e],c=(u,d)=>{let f=d.name;return u.slice(0,3).map(m=>{if(ye(d)!=="local")return m[f];let p=Et(m[f]);return p?.[t]??p?.default}).join(", ")},a=l.map(u=>{let{_id:d}=u,f=typeof u._updatedAt=="string"?u._updatedAt:"",m=Ae("global",i).filter(y=>y!=="_updatedAt").reduce((y,v)=>({...y,[v]:u[v]}),{}),p=Ae("local",i).reduce((y,v)=>{let b=Et(u[v]);return {...y,[v]:b?.[t]?b[t]:b?.default}},{}),g=qn(i).reduce((y,v)=>({...y,[v]:Et(u[v])}),{}),h=Ae(["relationship"],i).reduce((y,v)=>{let b=find(propEq(v,"name"))(i),x=b.relationship?.entity??"",A=find(propEq(x,"name"))(o),I=e$5(A),N=u[v];if(Bn(b)){let j=Ao(u[`${v}Connection`]);return {...y,[v]:j}}if(!I)throw new Error(`There is an error in the schema for the relationship attribute "${v}"`);let $=I.name,B=ye(I);if(b.relationship?.mode==="multiple"){let j=Array.isArray(N)?N:[];return {...y,[v]:c(j,I)}}let T=Et(N);if(B==="global")return {...y,[v]:T?.[$]};let P=Et(T?.[$]);return {...y,[v]:P?.[t]??P?.default}},{});return {_id:d,...m,...p,...g,...h,_updatedAt:f}});return {count:s,results:a}}function ta(e,t,n,o){let i=rt(o,e)?.attributes??[];if(i.length===0)return {count:0,results:[]};let s=ea(n,e),c=n[e].map(a=>{let u=Ae("global",i).reduce((p,g)=>({...p,[g]:{value:a[g],disabled:false,scope:"default",_id:""}}),{}),d=Ae("local",i).reduce((p,g)=>{let h=find(propEq(g,"name"))(i),y=Et(a[g]);return {...p,[g]:{value:y?Au(y,t):null,disabled:!!(y&&y[t]===null&&ye(h)==="local"&&t!=="default"),scope:t,_id:y?y._id:null}}},{}),f=qn(i).reduce((p,g)=>({...p,[g]:{value:Et(a[g]),disabled:false,scope:"default",_id:""}}),{}),m=Ae(["relationship"],i).reduce((p,g)=>{let h=find(propEq(g,"name"))(i),y=a[g],v=h.relationship?.mode==="single"?Et(y):y,b=v?._id,x=Ys(a[`${g}Connection`]);if(Bn(h)){let A=Ao(a[`${g}Connection`]);return {...p,[g]:{count:x,_id:b,knownAssetSortOrders:zn(A),value:A,disabled:false,scope:t}}}return {...p,[g]:{count:x,_id:b,value:v,disabled:false,scope:t}}},{});return {...u,...d,...f,...m}});return {count:s,results:c}}function Au(e,t){return Array.isArray(e)?e.reduce((n,o)=>{if(o[t]??o.default){let r={_id:o._id,disabled:o.scope===null&&t!=="default",scope:t,value:o[t]??o.default};n.push(r);}return n},[]):e[t]??e.default??null}function Er(e,t,n,o,r,i,s){let l=rt(o,e),c=l?.name??e,a=l?.attributes??[],u=Jn(e);if(a.length===0)return "";let d=na(a,i,s?.currentUser),f=oa(a,d),m=Du(t,a,d,n),p=Tu(a,r,d),g=Fu(a,r,d),h=e,y=s?.responseFields??ia(o,e,n);return `mutation ${`Update${ot(e)}`}($where: ${c}Where) {
|
|
132
132
|
update${u}(
|
|
133
133
|
where: $where
|
|
134
|
-
update: {${
|
|
134
|
+
update: {${f}${m}${p}${g}
|
|
135
135
|
}
|
|
136
136
|
) {
|
|
137
137
|
${h} {
|
|
138
138
|
_id
|
|
139
|
-
${
|
|
139
|
+
${y} }
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
`}function
|
|
142
|
+
`}function na(e,t,n){let o=Vn(t),r=e.map(s=>xt(s.readOnly,{record:o,value:o[s.name],currentUser:n})?s.name:"").filter(Boolean),i=omit(r,t);return pick(e.map(s=>s.name),i)}function Ae(e,t){return Array.isArray(e)?e.reduce((o,r)=>o.concat(Ae(r,t)),[]):t.filter(o=>ye(o)===e&&o.inputType!=="asset").map(o=>o.name)}function qn(e){return e.filter(Eo).map(n=>n.name)}function oa(e,t,n="update"){let o=pick(Ae("global",e),t);return toPairs(o).reduce((i,[s,l])=>{let c=find(propEq(s,"name"))(e),a=Array.isArray(l?.value)?null:l?.value??null,u=Ar(c.dataType,a);return n==="create"&&(u===null||u==="")?i:n==="update"?`${i}
|
|
143
143
|
${s}: { set: ${u} }`:`${i}
|
|
144
|
-
${s}: ${u}`},"")}function
|
|
144
|
+
${s}: ${u}`},"")}function br(e){return !e?._id||!e.path?"":e._id}function Tu(e,t,n){let o=pick(qn(e),n);return toPairs(o).reduce((s,[l,c])=>{let a=br(c.value),u=br(t[l]?.value);if(a===u)return s;let d=u?` {
|
|
145
145
|
disconnect: [{
|
|
146
146
|
where: {
|
|
147
147
|
node: {
|
|
148
|
-
_id: { eq: ${
|
|
148
|
+
_id: { eq: ${Ee(u)} }
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
}]
|
|
152
152
|
}
|
|
153
|
-
`:"",
|
|
153
|
+
`:"",f=a?` {
|
|
154
154
|
connect: [{
|
|
155
155
|
where: {
|
|
156
156
|
node: {
|
|
157
|
-
_id: { eq: ${
|
|
157
|
+
_id: { eq: ${Ee(a)} }
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
}]
|
|
161
161
|
}
|
|
162
162
|
`:"";return `${s}
|
|
163
|
-
${
|
|
164
|
-
${
|
|
163
|
+
${l}: [
|
|
164
|
+
${d}${f} ]`},"")}function Nu(e,t){let n=pick(qn(e),t);return toPairs(n).reduce((i,[s,l])=>{let c=br(l.value);return c?`${i}
|
|
165
165
|
${s}: {
|
|
166
166
|
connect: [{
|
|
167
167
|
where: {
|
|
168
168
|
node: {
|
|
169
|
-
_id: { eq: ${
|
|
169
|
+
_id: { eq: ${Ee(c)} }
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}]
|
|
173
|
-
}`:i},"")}function
|
|
173
|
+
}`:i},"")}function Du(e,t,n,o){let r=pick(Ae("local",t),n);return toPairs(r).reduce((l,[c,a])=>{let u=find(propEq(c,"name"))(t),{dataType:d}=u,f=a.disabled||Array.isArray(a.value)?"null":Ar(d,a.value);return a._id?`${l}
|
|
174
174
|
${c}: [{
|
|
175
175
|
update: {
|
|
176
176
|
node: {
|
|
177
|
-
${o}: { set: ${
|
|
177
|
+
${o}: { set: ${f} }
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
}]`:
|
|
180
|
+
}]`:a.disabled||Array.isArray(a.value)||a.value===void 0||a.value===null||a.value===""||f===null||f===""?l:`${l}
|
|
181
181
|
${c}: [{
|
|
182
182
|
create: {
|
|
183
183
|
node: {
|
|
184
|
-
_id: ${
|
|
185
|
-
_type: "${
|
|
186
|
-
${o}: ${
|
|
184
|
+
_id: ${Ee(`${e}:${c}`)}
|
|
185
|
+
_type: "${d}"
|
|
186
|
+
${o}: ${f}
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
}]`},"")}function
|
|
189
|
+
}]`},"")}function Fu(e,t,n){let o=pick(Ae("relationship",e),n);return toPairs(o).reduce((s,[l,c])=>{let a=find(propEq(l,"name"))(e),{inputType:u,relationship:d}=a;if(u==="relationship"&&d?.mode==="single"){let f=t[l]._id??"",m=c._id??"";if(f===m)return s;let p=f?` {
|
|
190
190
|
disconnect: [{
|
|
191
191
|
where: {
|
|
192
192
|
node: {
|
|
193
|
-
_id: { eq: ${
|
|
193
|
+
_id: { eq: ${Ee(f)} }
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
}]
|
|
197
197
|
}
|
|
198
|
-
`:"",g=
|
|
198
|
+
`:"",g=m?` {
|
|
199
199
|
connect: [{
|
|
200
200
|
where: {
|
|
201
201
|
node: {
|
|
202
|
-
_id: { eq: ${
|
|
202
|
+
_id: { eq: ${Ee(m)} }
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
}]
|
|
206
206
|
}
|
|
207
207
|
`:"";return `${s}
|
|
208
|
-
${
|
|
209
|
-
${
|
|
208
|
+
${l}: [
|
|
209
|
+
${p}${g} ]`}if(u==="relationship"&&d?.mode==="multiple"){if(d.entity==="_asset")return `${s}${Ru(l,t[l],c)}`;let f=uniq(c.relationships?.disconnect??[]).filter(Boolean),p=(c.relationships?.connect??[]).map(y=>Ee(y._id)).join(", "),g=f.length?` {
|
|
210
210
|
disconnect: [
|
|
211
|
-
${
|
|
211
|
+
${f.map(y=>` {
|
|
212
212
|
where: {
|
|
213
213
|
node: {
|
|
214
|
-
_id: { eq: ${
|
|
214
|
+
_id: { eq: ${Ee(y)} }
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
`).join("")} ]
|
|
219
219
|
}
|
|
220
|
-
`:"",h=
|
|
220
|
+
`:"",h=p?` {
|
|
221
221
|
connect: [{
|
|
222
222
|
where: {
|
|
223
223
|
node: {
|
|
224
|
-
_id: { in: [${
|
|
224
|
+
_id: { in: [${p}] }
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
}]
|
|
228
228
|
}
|
|
229
229
|
`:"";return !g&&!h?s:`${s}
|
|
230
|
-
${
|
|
230
|
+
${l}: [
|
|
231
231
|
${g}${h} ]`}return `${s}
|
|
232
|
-
`},"")}function
|
|
232
|
+
`},"")}function Ru(e,t,n){let r=(n.relationships?.connect??[]).map((m,p)=>({...m,sortOrder:m.sortOrder??p})),i=r.map(m=>m._id),s={...Iu(t),...t?.knownAssetSortOrders??{},...n.knownAssetSortOrders??{}},l=uniq(n.relationships?.disconnect??[]).filter(m=>m&&!i.includes(m)),c=r.filter(m=>s[m._id]===void 0),a=r.filter(m=>{let p=s[m._id];return p!==void 0&&p!==m.sortOrder}),u=Lu(l),d=Pu(c),f=Mu(a);return !u&&!d&&!f?"":`
|
|
233
233
|
${e}: [
|
|
234
|
-
${u}${
|
|
234
|
+
${u}${d}${f} ]`}function Iu(e){let t=e?.value;return Array.isArray(t)?t.reduce((n,o,r)=>{if(typeof o!="object"||!o||!("_id"in o))return n;let{_id:i}=o;if(typeof i!="string"||i.length===0)return n;let s="sortOrder"in o&&typeof o.sortOrder=="number"?o.sortOrder:r;return {...n,[i]:s}},{}):{}}function Lu(e){return e.length===0?"":` {
|
|
235
235
|
disconnect: [
|
|
236
236
|
${e.reduce((n,o)=>`${n} {
|
|
237
|
-
where: { node: { _id: { eq: ${
|
|
237
|
+
where: { node: { _id: { eq: ${Ee(o)} } } }
|
|
238
238
|
}
|
|
239
239
|
`,"")} ]
|
|
240
240
|
}
|
|
241
|
-
`}function
|
|
241
|
+
`}function Pu(e){return e.length===0?"":` {
|
|
242
242
|
connect: [
|
|
243
|
-
${
|
|
243
|
+
${ra(e)} ]
|
|
244
244
|
}
|
|
245
|
-
`}function
|
|
246
|
-
where: { node: { _id: { eq: ${
|
|
245
|
+
`}function ra(e){return e.reduce((t,n,o)=>{let r=n.sortOrder??o;return `${t} {
|
|
246
|
+
where: { node: { _id: { eq: ${Ee(n._id)} } } }
|
|
247
247
|
edge: { sortOrder: ${r} }
|
|
248
248
|
}
|
|
249
|
-
`},"")}function
|
|
249
|
+
`},"")}function Mu(e){return e.length===0?"":e.reduce((n,o,r)=>{let i=o.sortOrder??r;return `${n} {
|
|
250
250
|
update: {
|
|
251
|
-
where: { node: { _id: { eq: ${
|
|
251
|
+
where: { node: { _id: { eq: ${Ee(o._id)} } } }
|
|
252
252
|
edge: { sortOrder: { set: ${i} } }
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
-
`},"")}function
|
|
256
|
-
`,"");return c+=s.reduce((
|
|
255
|
+
`},"")}function Ar(e,t){return yu.includes(e)?t?.toString()?Ee(t.toString()):null:hu.includes(e)?t==null?null:Ee(t.toString()):t==null||t===""?null:t.toString()}function Ee(e){return JSON.stringify(e)}function ia(e,t,n){let o=rt(e,t),r=o?.attributes??[],i=Ae("global",r),s=Ae("local",r),l=Ae("relationship",r),c=i.reduce((a,u)=>`${a}${u}
|
|
256
|
+
`,"");return c+=s.reduce((a,u)=>`${a} ${u} {
|
|
257
257
|
_id
|
|
258
258
|
${n}
|
|
259
259
|
}
|
|
260
|
-
`,""),c+=
|
|
260
|
+
`,""),c+=l.reduce((a,u)=>{let d=find(propEq(u,"name"))(r),f=d?.relationship?.mode??"single";if(Bn(d))return `${a}${Zs(u,Sr(d,o))}`;let m=d?.relationship?.entity??"",g=find(propEq(m,"name"))(e)?.attributes??[],h=d?.relationship?.field??"[invalid_relationship_field_name_in_schema]",y=find(propEq(h,"name"))(g),v=ye(y),b="";if(f==="single"&&(v==="global"&&(b=` ${u} {
|
|
261
261
|
_id
|
|
262
262
|
${h}
|
|
263
263
|
}
|
|
264
|
-
`),
|
|
264
|
+
`),v==="local"&&(b=` ${u} {
|
|
265
265
|
_id
|
|
266
266
|
${h} {
|
|
267
267
|
_id
|
|
@@ -269,27 +269,27 @@ ${sa(e)} ]
|
|
|
269
269
|
${n}
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
`)),
|
|
272
|
+
`)),f==="multiple"&&g.length){let x=g.reduce((A,I)=>{if(ye(I)==="local")return `${A} ${I.name} {
|
|
273
273
|
_id
|
|
274
274
|
default
|
|
275
275
|
${n}
|
|
276
276
|
}
|
|
277
|
-
`;if(
|
|
278
|
-
|
|
277
|
+
`;if(ye(I)==="relationship"){let N=n==="default"?"":`${n}
|
|
278
|
+
`,$=find(propEq(I.relationship?.entity,"name"))(e),B=find(propEq(I.relationship?.field,"name"))($?.attributes??[]),T=ye(B)==="local"?`{
|
|
279
279
|
_id
|
|
280
280
|
default
|
|
281
281
|
${N}}
|
|
282
|
-
`:"";if(
|
|
283
|
-
${
|
|
284
|
-
`;if(
|
|
285
|
-
${
|
|
286
|
-
`}return Eo(
|
|
287
|
-
${
|
|
282
|
+
`:"";if(I.relationship?.mode==="single")return `${A} ${I.name} {
|
|
283
|
+
${I.relationship.field} ${T}}
|
|
284
|
+
`;if(I.relationship?.field)return `${A} ${I.name} (limit: ${Ks}, offset: 0) {
|
|
285
|
+
${I.relationship.field} ${T}}
|
|
286
|
+
`}return Eo(I)?`${A} ${I.name} {
|
|
287
|
+
${wr}
|
|
288
288
|
}
|
|
289
|
-
`:`${A} ${
|
|
290
|
-
`},"");b=
|
|
291
|
-
${
|
|
292
|
-
`;}return `${
|
|
289
|
+
`:`${A} ${I.name}
|
|
290
|
+
`},"");b=xr(u)+` ${u} (limit: 25, offset: 0) {
|
|
291
|
+
${x} }
|
|
292
|
+
`;}return `${a}${b}`},""),c}function Hn(e,t,n){let o=typeof n=="string"?[n]:[...n],r=find(propEq(e,"name"))(t),i=r?.attributes??[],s=Jn(r?.plural??""),l=_u(i,o),c=`Delete${ot(r?.plural??e)}`;return e==="_asset"?`mutation ${c}($where: ${e}Where) {
|
|
293
293
|
delete_assets(
|
|
294
294
|
where: $where
|
|
295
295
|
) {
|
|
@@ -300,70 +300,70 @@ ${E} }
|
|
|
300
300
|
`:`mutation ${c}($where: ${e}Where) {
|
|
301
301
|
delete${s}(
|
|
302
302
|
where: $where
|
|
303
|
-
${
|
|
304
|
-
${
|
|
303
|
+
${l?` delete: {
|
|
304
|
+
${l}
|
|
305
305
|
}
|
|
306
306
|
`:""} ) {
|
|
307
307
|
nodesDeleted
|
|
308
308
|
relationshipsDeleted
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
|
-
`}function
|
|
311
|
+
`}function Un(e){let t=typeof e=="string"?[e]:[...e];return t.length===1?{_id:{eq:t[0]}}:{_id:{in:t}}}function _u(e,t){return Ae("local",e).reduce((r,i)=>{let s=t.map(c=>Ee(`${c}:${i}`)).join(", "),l=t.length===1?`_id: { eq: ${s} }`:`_id: { in: [${s}] }`;return `${r}
|
|
312
312
|
${i}: [{
|
|
313
313
|
where: {
|
|
314
314
|
node: {
|
|
315
|
-
${
|
|
315
|
+
${l}
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
}]`},"")}function
|
|
319
|
-
create${
|
|
318
|
+
}]`},"")}function Tr(e,t,n,o,r){let i=rt(t,e),s=i?.attributes??[],l=Jn(i?.plural??"");if(s.length===0)return "";let c=na(s,n,r?.currentUser),a=oa(s,c,"create"),u=$u(s,c,"default",o),d=Nu(s,c),f=Ou(s,c),m=e,p=ia(t,m,"default");return `mutation ${`Create${ot(e)}`} {
|
|
319
|
+
create${l}(
|
|
320
320
|
input: [{
|
|
321
|
-
_id: ${
|
|
321
|
+
_id: ${Ee(o)} ${a} ${u}
|
|
322
|
+
${d}
|
|
322
323
|
${f}
|
|
323
|
-
${m}
|
|
324
324
|
}]
|
|
325
325
|
) {
|
|
326
|
-
${
|
|
326
|
+
${m} {
|
|
327
327
|
_id
|
|
328
|
-
${
|
|
328
|
+
${p} }
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
`}function
|
|
331
|
+
`}function $u(e,t,n,o){let r=pick(Ae("local",e),t);return toPairs(r).reduce((l,[c,a])=>{if(a?.value===void 0||a.value===null||a.value==="")return l;let u=find(propEq(c,"name"))(e),d=Array.isArray(a.value)?"null":Ar(u.dataType,a.value);return `${l}
|
|
332
332
|
${c}: {
|
|
333
333
|
create: [{
|
|
334
334
|
node: {
|
|
335
|
-
_id: ${
|
|
335
|
+
_id: ${Ee(`${o}:${c}`)}
|
|
336
336
|
_type: "${u.dataType}"
|
|
337
|
-
${n}: ${
|
|
337
|
+
${n}: ${d}
|
|
338
338
|
}
|
|
339
339
|
}]
|
|
340
|
-
}`},"")}function
|
|
340
|
+
}`},"")}function Ou(e,t){let n=pick(Ae("relationship",e),t);return toPairs(n).reduce((i,[s,l])=>{let c=find(propEq(s,"name"))(e),{inputType:a,relationship:u}=c;if(a==="relationship"&&u?.mode==="single"){if(!l._id)return i;let m=`connect: [{
|
|
341
341
|
where: {
|
|
342
342
|
node: {
|
|
343
|
-
_id: { eq: ${
|
|
343
|
+
_id: { eq: ${Ee(l._id)} }
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
}]
|
|
347
347
|
`;return `${i}
|
|
348
348
|
${s}: {
|
|
349
|
-
${
|
|
349
|
+
${m} }`}let d=a==="relationship"&&u?.mode==="multiple",f=Array.isArray(l.relationships?.connect)&&l.relationships.connect.length>0;if(d&&f){let m=l.relationships?.connect??[];if(u?.entity==="_asset"){let h=ra(m.map((y,v)=>({...y,sortOrder:y.sortOrder??v})));return `${i}
|
|
350
350
|
${s}: {
|
|
351
351
|
connect: [
|
|
352
352
|
${h} ]
|
|
353
|
-
}`}let
|
|
353
|
+
}`}let p=m.map(h=>Ee(h._id)).join(", "),g=p?`connect: {
|
|
354
354
|
where: {
|
|
355
355
|
node: {
|
|
356
|
-
_id: { in: [${
|
|
356
|
+
_id: { in: [${p}] }
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
`:"";return `${i}
|
|
361
361
|
${s}: {
|
|
362
362
|
${g} }`}return `${i}
|
|
363
|
-
`},"")}function
|
|
363
|
+
`},"")}function sa({relatedEntityName:e,scope:t,schema:n}){let r=find(propEq(e,"name"))(n)?.plural??"";return r?jn(r,t,n,{selection:"list",operationName:`GetRelated${ot(r)}`}):{queryEntityName:"",query:""}}function aa({attributeName:e,entityName:t,entityNamePlural:n,schema:o}){let r=rt(o,n),i=find(propEq(e,"name"))(r?.attributes??[]),s=Sr(i,r),l=s?` properties {
|
|
364
364
|
sortOrder
|
|
365
365
|
}
|
|
366
|
-
`:"",c=s?"(first: $first, sort: [{ edge: { sortOrder: ASC } }])":"(first: $first)",
|
|
366
|
+
`:"",c=s?"(first: $first, sort: [{ edge: { sortOrder: ASC } }])":"(first: $first)",a=`Get${ot(t)}AssetConnection`;return {queryEntityName:n,query:`query ${a}($where: ${t}Where, $first: Int) {
|
|
367
367
|
${n}(where: $where) {
|
|
368
368
|
${e}Connection${c} {
|
|
369
369
|
aggregate {
|
|
@@ -372,29 +372,25 @@ ${h} ]
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
edges {
|
|
375
|
-
`+
|
|
376
|
-
${
|
|
375
|
+
`+l+` node {
|
|
376
|
+
${Cr}
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
`}}var Jn=e=>e.charAt(0).toUpperCase()+e.slice(1);function ot(e){let t=e.split(/[^0-9A-Za-z]+/).filter(Boolean).map(Jn).join("");return t?/^[A-Za-z_]/.test(t)?t:`Entity${t}`:"Entity"}function rt(e,t){return t==="_assets"?a$f:find(propEq(t,"plural"))(e)}function
|
|
382
|
+
`}}var Jn=e=>e.charAt(0).toUpperCase()+e.slice(1);function ot(e){let t=e.split(/[^0-9A-Za-z]+/).filter(Boolean).map(Jn).join("");return t?/^[A-Za-z_]/.test(t)?t:`Entity${t}`:"Entity"}function rt(e,t){return t==="_assets"?a$f:find(propEq(t,"plural"))(e)}function la(e,t,n){if(!e||typeof e!="object")return {};let o=rt(n,t);if(!o)return {};let r=`update${Jn(t)}`,i=e[r];if(!i||typeof i!="object")return {};let s=i[t],l=Array.isArray(s)?s[0]:void 0;return !l||typeof l!="object"?{}:o.attributes.reduce((c,a)=>{if(ye(a)!=="local")return c;let d=Et(l[a.name])?._id;return typeof d!="string"||d.length===0?c:{...c,[a.name]:d}},{})}var No=null,Nr=new Set,ca=[],Dr=new Set,Fr=new Set,Rr=new Set;function Ke(e,t){if(e==="_asset"||e==="_assets")return `Get${ot(a$f.plural)}`;let n=t.find(i=>i.plural===e),o=t.find(i=>i.name===e),r=n?.plural??o?.plural??e;return `Get${ot(r)}`}function ua(e){return Dr.add(e),()=>{Dr.delete(e);}}function fa(e){return Fr.add(e),()=>{Fr.delete(e);}}function da(e){return Rr.add(e),()=>{Rr.delete(e);}}function Do(e,t,n){let o=new Set(n.filter(Boolean));if(o.size>0)for(let r of Fr)r(t,o);return At(e,t)}function ma(e,t){let n=t.filter(o=>!!o._id);if(n.length!==0)for(let o of Rr)o(e,n);}function At(e,t){return Nr.add(t),new Promise((n,o)=>{ca.push({resolve:n,reject:o}),No&&clearTimeout(No),No=setTimeout(()=>{let r=new Set(Nr),i=ca.splice(0);Nr.clear(),No=null,Promise.all([...Dr].map(s=>Promise.resolve(s(r)))).then(()=>{for(let{resolve:s}of i)s();}).catch(s=>{console.error("Error refreshing entity lists:",s);for(let{reject:l}of i)l(s);});},50);})}function Ir({action:e}){let{projects:t,currentProjectId:n}=d(),{schema:o}=find(propEq(n??"","projectId"))(t),r=useApolloClient(),[i,s,l]=St(),c=me(),a=useRef(false),u=Array.isArray(e.payload.entityId)?e.payload.entityId:[e.payload.entityId],d$1=e.payload.entityName==="_asset"?"asset":e.payload.entityName.toLowerCase(),f=!!e.payload.silent,m=u.length>1;if(useEffect(()=>{!f||a.current||(a.current=true,g());},[f]),f)return jsx(Fragment,{});let p={dialogTitle:m?`Delete ${u.length} ${d$1}s`:`Delete ${d$1}`,dialogMessage:m?`Are you sure you want to delete the selected ${d$1}s? They will be deleted permanently.`:`Are you sure you want to delete the selected ${d$1}? The item will be deleted permanently.`,dialogCancelTitle:"Cancel",dialogActionLabel:"Delete",isDestructive:true,dialogActionSubmit:()=>g()};function g(){let h=Hn(e.payload.entityName,o,u);return new Promise((y,v)=>{s(gql`
|
|
383
383
|
${h}
|
|
384
|
-
`),a({variables:{where:qn(u)},update(b){for(let E of u)b.evict({id:E});},onCompleted:()=>{toast.success(p?"Items successfully deleted.":"Item successfully deleted."),Do(r,Ke(e.payload.entityName,o),u),c({type:"Dismiss",_id:e._id,payload:{}}),v();},onError:b=>{y(b);}}),i(true);})}return jsx(_n,{options:d$1})}var ha=createContext({isDirty:false,setIsDirty:e=>{}}),ya=({children:e})=>{let[t,n]=useState(false),o=useMemo(()=>({isDirty:t,setIsDirty:i=>{n(i);}}),[t,n]);return jsx(ha.Provider,{value:o,children:e})};function yn(){return useContext(ha)}function Lr(e,t){return !t||t.length===0||e===void 0?true:e.some(n=>t.includes(n))}function vn(e,t){return e.filter(n=>Lr(t,n.spaces))}function ef(e,t){return e.filter(n=>Lr(t,n.spaces)).map(n=>({...n,attributes:vn(n.attributes,t)}))}var va=["image/jpeg","image/png","image/webp","image/vnd.microsoft.icon","image/bmp","image/gif","image/tiff","image/svg+xml","image/avif","image/heic","image/heif","image/heic-sequence","image/heif-sequence","image/apng","audio/aac","audio/mpeg","audio/wav","audio/webm","audio/midi","audio/x-midi","audio/ogg","video/x-msvideo","video/mp4","video/mpeg","video/webm","video/quicktime","video/ogg","video/mp2t","video/3gpp","video/3gpp2","application/x-7z-compressed","application/zip","application/vnd.amazon.ebook","application/octet-stream","application/epub+zip","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-fontobject","application/gzip","application/x-gzip","application/java-archive","application/json","application/ld+json","text/javascript","application/vnd.oasis.opendocument.presentation","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.text","application/ogg","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.rar","application/x-tar","application/vnd.visio","application/xhtml+xml","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/xml"];function of(e,t){if(!e.type)return true;let n=t?t.split(",").map(o=>o.trim()).filter(Boolean):va;return n.length===0?true:n.some(o=>o.endsWith("/*")?e.type.startsWith(o.slice(0,-1)):e.type===o)}async function Mr(e,t){let n=new URLSearchParams({filename:e.name}),o=await fetch(`${c$6(t).assets}?${n.toString()}`,{method:"POST",headers:{"Content-Type":e.type||"application/octet-stream"},body:e});if(!o.ok)throw new Error(`Upload failed for ${e.name}`);let r=await o.json(),i={_id:r._id,path:r.path??"",originalFilename:r.originalFilename??e.name,size:r.size??e.size,mimeType:r.mimeType??e.type,lqip:r.lqip??"",width:r.width??0,height:r.height??0};return {pathname:i.path,lqip:i.lqip||void 0,originalFilename:i.originalFilename,size:i.size,mimeType:i.mimeType,width:i.width||void 0,height:i.height||void 0,_id:i._id,asset:i}}async function ba(e,t){let{projectId:n,accept:o,maxBytes:r=4*1024*1024,onUploadStart:i}=t,s=[];for(let a of Array.from(e)){if(a.size>r){toast.error(`File size too big (max ${(r/(1024*1024)).toFixed(0)}MB): ${a.name}`);continue}if(!of(a,o)){toast.error(`Unsupported file type: ${a.name}`);continue}s.push(a);}if(s.length===0)return [];i?.();try{let a=await Promise.all(s.map(async c=>Mr(c,n)));return a.length>0&&toast.success(`Uploaded ${a.length} file${a.length>1?"s":""}`),a}catch(a){return console.error(a),toast.error("Upload failed. Please try again."),[]}}async function rf(e){let{accept:t,multiple:n=true}=e,o=document.createElement("input");o.type="file",o.accept=t??va.join(","),o.multiple=n,o.style.display="none",document.body.appendChild(o);try{let r=await new Promise(i=>{o.addEventListener("change",()=>i(o.files),{once:!0}),o.addEventListener("cancel",()=>i(null),{once:!0}),o.click();});return !r||r.length===0?[]:ba(r,e)}finally{document.body.removeChild(o);}}function Gn(){let e=useApolloClient();return useCallback(async t=>{let n=t.files?await ba(t.files,t):await rf(t);return n.length>0&&await At(e,"GetAssets").catch(o=>{console.error("Error refreshing asset lists after upload:",o);}),n},[e])}function bn(e,t,n){useEffect(()=>{function o(r){if(e.current&&!e.current.contains(r.target)){if(n){let i=Array.from(document.querySelectorAll(n));for(let s of i)if(s.contains(r.target))return}t(false);}}return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o);}},[t,e,n]),useEffect(()=>{function o(r){if(e.current&&!e.current.contains(r.target)){if(n){let i=Array.from(document.querySelectorAll(n));for(let s of i)if(s.contains(r.target))return}t(false);}}return document.addEventListener("focusin",o),()=>{document.removeEventListener("mousedown",o);}},[t,e]);}function Na({control:e$1,entityId:t,fieldSchema:n$1,getValues:o,readOnly:r,setValue:i}){let{name:s,label:a,options:c$1}=n$1,{projectId:l$1}=useParams(),u=pe(),f$1=d$2(),{relationships:m$1}=c$2(),[p,d]=useState(false),g$1=useRef(null),h=useRef(null),v=useRef(null),[y,b]=useState(null),[E,A]=useState(false),[F,N]=useState(false),S=useId(),D=useId();bn(h,d,"[data-radix-popper-content-wrapper]"),useEffect(()=>{let C=m$1[D]?.connect;if(!C||v.current===C._id)return;let k=hf(C.value);if(!k)return;let _=o(s);v.current=C._id,b(null),i(s,{..._,value:k});},[o,s,D,m$1,i]);function $(C){if(!C)return;let k={"application/pdf":"pdf","application/zip":"zip","application/x-zip-compressed":"zip","application/json":"json","text/csv":"csv","text/plain":"txt","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","application/vnd.apple.keynote":"key","application/vnd.apple.numbers":"numbers","application/vnd.apple.pages":"pages","application/x-7z-compressed":"7z","application/x-rar-compressed":"rar","application/xml":"xml","video/mp4":"mp4","video/quicktime":"mov","audio/mpeg":"mp3","audio/wav":"wav"};if(k[C])return k[C];let _=C.split("/");if(_.length===2){let[,U]=_;return U.includes("svg")?"svg":U.toLowerCase()}}function O(C,k){if(C&&C.includes(".")){let U=C.split(".").pop();if(U)return U.toLowerCase()}let _=$(k);return _||"file"}async function V(C,k){if(r||!C)return;let _=$r("4MB");if(C.size>(_??0)){toast.error("File size too big (max 4MB)");return}let U=C.type.startsWith("image/");if(v.current=null,U){let W=new FileReader;W.onload=se=>{b(se.target?.result);},W.readAsDataURL(C);}else b(null);N(true);try{let W=await Mr(C,l$1);i(s,{...o(s),value:W.asset});}catch(W){console.error(W),b(null),i(s,{...o(s),value:{_id:k?.value?._id}});}finally{N(false);}}function R(C){r||(C.stopPropagation(),v.current=null,i(s,{...o(s),_id:"",value:{_id:o(s)?.value?._id}}));}function B(C,k){C.stopPropagation(),k?.value&&typeof k.value=="object"&&"path"in k.value&&navigator.clipboard.writeText(`${b$4}${k.value.path}`);}function Z(C){C.preventDefault(),C.stopPropagation(),!r&&g$1.current?.click();}function te(C){if(C.preventDefault(),C.stopPropagation(),r)return;d(false);let k=o(s)?.value,_=v.current??yf(k),U=_?{_id:_,value:k}:void 0;f$1({type:"setRelationship",payload:{[D]:{connect:U,disconnect:[]}}}),window.setTimeout(()=>{u({type:"EditRelationship",payload:{assetAccept:c$1?.accept,connectedEntitiesCount:0,entityId:t,entityName:"_asset",initialAssetPath:k?.path,initialConnection:U,relationshipId:D,mode:"single"}});},0);}function M(C,k){C.stopPropagation(),k?.value&&typeof k.value=="object"&&"path"in k.value&&window.open(`${b$4}${k.value.path}?download=1`,"_blank");}return jsx(c,{control:e$1,name:s,render:({field:C})=>jsxs(e,{children:[jsx(f,{htmlFor:S,children:a}),c$1?.comment?jsx(h$1,{children:c$1.comment}):null,jsx(g,{className:"fk:flex fk:flex-col fk:w-full fk:min-h-[2.5rem] fk:text-sm",children:jsxs("div",{"aria-controls":`image-dropdown-${s}`,"aria-expanded":p,className:`fk:relative fk:flex fk:w-full fk:items-start fk:space-x-2 fk:rounded-md fk:border fk:overflow-hidden fk:focus-visible:outline-hidden fk:ring-offset-background fk:focus-visible:ring-2 fk:focus-visible:ring-ring fk:focus-visible:ring-offset-2 ${p?"fk:outline-hidden fk:ring-2 fk:ring-ring fk:ring-offset-2":""} ${E?"fk:border-dashed fk:border-2 fk:border-emerald-500 fk:bg-green-50":"fk:border-input fk:bg-background"}`,onClick:k=>{k.preventDefault(),k.stopPropagation(),h.current?.focus(),h.current?.click(),d(true);},onKeyDown:k=>{k.key==="Enter"&&d(true),k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),h.current?.blur(),d(false));},onDragOver:k=>{r||(k.preventDefault(),k.stopPropagation(),A(true));},onDragEnter:k=>{r||(k.preventDefault(),k.stopPropagation(),A(true));},onDragLeave:k=>{r||(k.preventDefault(),k.stopPropagation(),A(false));},onDrop:k=>{if(k.preventDefault(),k.stopPropagation(),A(false),r)return;let _=k.dataTransfer.files&&k.dataTransfer.files[0];V(_,C.value);},ref:h,role:"combobox",tabIndex:0,children:[jsxs("div",{className:"fk:flex fk:w-full fk:space-x-2",children:[!C.value?.value?.path&&!y?jsxs("div",{className:"fk:flex fk:h-9 fk:w-full fk:px-3 fk:pt-0.5 fk:items-center",children:[jsxs("div",{className:"fk:flex fk:h-full fk:items-center fk:text-muted-foreground fk:text-sm fk:font-light",children:[jsx(Image,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Drag or paste file here"]}),jsxs(b$3,{className:"fk:ml-auto fk:h-7 fk:rounded-sm fk:text-muted-foreground",disabled:r,id:S,onClick:Z,variant:"ghost",children:[jsx(Upload,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Upload"]}),jsxs(b$3,{className:"fk:ml-2 fk:h-7 fk:rounded-sm fk:text-muted-foreground",disabled:r,onClick:te,variant:"ghost",children:[jsx(Search,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Select"]})]}):null,C.value?.value?.path&&!p?jsxs("div",{className:"fk:flex fk:h-9 fk:w-full fk:px-3 fk:pt-0.5 fk:items-center",children:[(()=>{let k=C.value?.value,_=k?.mimeType,U=k?.path||"";if(!!(_&&_.startsWith("image/")||/\.(png|jpe?g|gif|webp|avif|svg)$/i.test(U)))return jsx("img",{className:"fk:w-8 fk:h-8 fk:mr-2 fk:rounded-sm fk:object-scale-down",src:`${b$4}${k.path}?w=128&h=128&f=webp`,alt:"Uploaded"});let se=O(k.originalFilename,k.mimeType),oe=defaultStyles[se];return jsx("div",{className:"fk:w-8 fk:h-8 fk:mr-2 fk:rounded-sm fk:bg-transparent fk:flex fk:items-center fk:justify-center fk:[&>svg]:h-full fk:[&>svg]:w-auto",children:jsx(FileIcon,{extension:se,...oe||{}})})})(),$r((C.value?.value).size),jsx("span",{className:"fk:block fk:w-px fk:h-5 fk:mx-2 fk:bg-border"}),(C.value?.value).mimeType,(C.value?.value).width&&(C.value?.value).height?jsxs(Fragment,{children:[jsx("span",{className:"fk:block fk:w-px fk:h-5 fk:mx-2 fk:bg-border"}),(C.value?.value).width,"x",(C.value?.value).height,"px"]}):null]}):null,!C.value?.value?.path&&y&&jsxs("div",{className:"fk:flex fk:h-9 fk:w-full fk:px-3 fk:pt-0.5 fk:items-center",children:[jsx("img",{src:y,alt:"Preview",className:"fk:mr-2 fk:mt-0.5 fk:rounded-sm fk:h-7 fk:w-7 rounded-md object-cover"}),"Loading image..."]}),!C.value?.value?.path&&!y&&F?jsxs("div",{className:"fk:flex fk:h-9 fk:w-full fk:px-3 fk:pt-0.5 fk:items-center",children:[jsx("div",{className:"fk:w-7 fk:h-7 fk:mr-2 fk:rounded-sm fk:bg-muted fk:flex fk:items-center fk:justify-center",children:jsx(File,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground"})}),"Uploading file..."]}):null,C.value?.value?.path?jsx("div",{className:"fk:absolute fk:top-0 fk:right-10",children:jsxs(c$3,{modal:false,children:[jsx(a$8,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(e$2,{asChild:true,children:jsx(b$3,{className:"fk:h-8 fk:w-8 fk:ml-auto fk:mt-[0.1875rem] fk:rounded-sm",onClick:k=>{k.stopPropagation();},onPointerDown:k=>{k.stopPropagation();},size:"icon",variant:"ghost",children:jsx(Ellipsis,{className:"fk:h-4 fk:w-4"})})})}),jsx(e$3,{children:jsx("p",{children:"Show actions"})})]})}),jsxs(f$2,{className:"fk:w-48",children:[jsxs(g$2,{children:[jsxs(h$2,{disabled:r,onClick:Z,children:[jsx(Upload,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Upload"})]}),jsxs(h$2,{disabled:r,onClick:te,children:[jsx(Image,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Select asset"})]})]}),jsx(m,{}),jsxs(g$2,{children:[jsxs(h$2,{onClick:k=>M(k,C.value),children:[jsx(Download,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Download"})]}),jsxs(h$2,{onClick:k=>B(k,C.value),children:[jsx(Copy,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Copy URL"})]})]}),jsx(m,{}),jsxs(h$2,{disabled:r,onClick:R,children:[jsx(RefreshCwOff,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Clear field"})]})]})]})}):null,jsx(Fragment,{children:!p&&(C.value?.value?.path||y)?jsx(a$8,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:absolute fk:right-[0.1875rem] fk:top-[0.1875rem] fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground",onKeyDown:k=>{k.key==="Enter"&&(h.current?.focus(),h.current?.click());},size:"icon",variant:"ghost",children:jsx(Maximize2,{className:"fk:h-4 fk:w-4"})})}),jsx(e$3,{children:jsx("p",{children:"Expand field"})})]})}):null}),p&&(C.value?.value?.path||y)?jsx(a$8,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:absolute fk:right-[0.1875rem] fk:top-[0.1875rem] fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground",onClick:k=>{k.preventDefault(),k.stopPropagation(),h.current?.blur(),d(false);},onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),k.stopPropagation(),h.current?.blur(),d(false));},size:"icon",variant:"ghost",children:jsx(X,{className:"fk:h-4 fk:w-4"})})}),jsx(e$3,{children:jsx("p",{children:"Close"})})]})}):null]}),jsx(l,{className:"fk:w-full fk:space-y-2 fk:ml-0!",onOpenChange:d,open:p&&(!!C.value?.value?.path||!!y),children:jsx(n,{className:"fk:w-full",children:jsx("div",{className:"fk:flex fk:w-full fk:h-[30vh]",id:`image-dropdown-${s}`,children:C.value?.value?.path?(()=>{let k=C.value?.value,_=k?.mimeType,U=k?.path||"";if(!!(_&&_.startsWith("image/")||/\.(png|jpe?g|gif|webp|avif|svg)$/i.test(U)))return jsx("img",{className:"fk:w-full fk:rounded-md fk:object-scale-down",src:`${b$4}${k.path}?w=624&h=624&f=webp`,alt:"Uploaded"});let se=O(k.originalFilename,k.mimeType),oe=defaultStyles[se];return jsxs("div",{className:"fk:w-full fk:h-full fk:rounded-md fk:bg-muted/40 fk:flex fk:flex-col fk:items-center fk:justify-center fk:text-muted-foreground",children:[jsx("div",{className:"fk:w-16 fk:h-16 fk:rounded-sm fk:bg-transparent fk:flex fk:items-center fk:justify-center fk:[&>svg]:h-full fk:[&>svg]:w-auto",children:jsx(FileIcon,{extension:se,...oe||{}})}),jsxs("div",{className:"fk:mt-3 fk:text-sm",children:[k.originalFilename||"File"," \xB7 ",$r(k.size)," \xB7 ",k.mimeType]}),jsx("div",{className:"fk:mt-1 fk:text-xs",children:"Preview not available"})]})})():null})})}),F?jsx("div",{className:"fk:absolute fk:m-0! fk:top-0 fk:left-0 fk:right-0 fk:bottom-0 fk:w-full fk:bg-muted-foreground/5 fk:overflow-hidden",children:jsx("div",{className:"fk:animate-progress fk:w-full fk:h-full fk:bg-muted-foreground/10"})}):null]})}),jsx("input",{accept:c$1?.accept?c$1.accept:"image/*",className:"fk:hidden",disabled:r,id:`file-upload-${s}`,onChange:k=>{let _=k.currentTarget.files&&k.currentTarget.files[0];V(_,C.value);},ref:g$1,type:"file"}),jsx(i$1,{})]})})}function hf(e){if(!e||typeof e!="object"||!("_id"in e)||!("path"in e))return null;let t=e;return {_id:String(t._id??""),path:String(t.path??""),originalFilename:String(t.originalFilename??""),size:Number(t.size??0),mimeType:String(t.mimeType??""),lqip:String(t.lqip??""),width:Number(t.width??0),height:Number(t.height??0)}}function yf(e){return !e?._id||e._id.includes(":")?"":e._id}function Da({control:e$1,fieldSchema:t,readOnly:n,setValue:o}){let{name:r,label:i,options:s,dataType:a}=t,c$1=useId();function l(f,m){let p=f.currentTarget.value,d;p===""?d="":(d=a==="float"?parseFloat(p):parseInt(p,10),isNaN(d)&&(d="")),o(r,{...m,value:d});}function u(f,m){o(r,{...m,disabled:f});}return jsx(c,{control:e$1,name:r,render:({field:f$1})=>jsxs(e,{children:[jsx(f,{htmlFor:c$1,children:i}),s?.comment?jsx(h$1,{children:s.comment}):null,jsx(g,{children:jsx(a$7,{className:"fk:w-full fk:mt-0.75",disabled:n||f$1.value?.disabled,id:c$1,...f$1,onChange:m=>{l(m,f$1.value);},step:a==="float"?"any":"1",type:"number",value:f$1.value?.value??""})}),jsx(a$6,{checked:f$1.value?.disabled??false,disabled:n,onChange:m=>{u(m,f$1.value);},scope:f$1.value?.scope}),jsx(i$1,{})]})})}function Cn({...e}){return jsx(Popover.Root,{"data-slot":"popover",...e})}function wn({...e}){return jsx(Popover.Trigger,{"data-slot":"popover-trigger",...e})}function Bt({className:e,align:t="center",sideOffset:n=4,...o}){return jsx(Popover.Portal,{children:jsx(Popover.Content,{"data-slot":"popover-content",align:t,sideOffset:n,className:a$1("fk:z-50 fk:w-72 fk:origin-(--radix-popover-content-transform-origin) fk:rounded-md fk:border fk:bg-popover fk:p-4 fk:text-popover-foreground fk:shadow-md fk:outline-hidden fk:data-[side=bottom]:slide-in-from-top-2 fk:data-[side=left]:slide-in-from-right-2 fk:data-[side=right]:slide-in-from-left-2 fk:data-[side=top]:slide-in-from-bottom-2 fk:data-[state=closed]:animate-out fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:zoom-out-95 fk:data-[state=open]:animate-in fk:data-[state=open]:fade-in-0 fk:data-[state=open]:zoom-in-95",e),...o})})}function Ra({className:e,classNames:t,showOutsideDays:n=true,captionLayout:o="label",buttonVariant:r="ghost",formatters:i,components:s,...a}){let c=getDefaultClassNames();return jsx(DayPicker,{showOutsideDays:n,className:a$1("fk:group/calendar fk:bg-background fk:p-3 fk:[--cell-size:--spacing(8)] fk:in-data-[slot=card-content]:bg-transparent fk:in-data-[slot=popover-content]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:o,formatters:{formatMonthDropdown:l=>l.toLocaleString("default",{month:"short"}),...i},classNames:{root:a$1("w-fit",c.root),months:a$1("fk:relative fk:flex fk:flex-col fk:gap-4 fk:md:flex-row",c.months),month:a$1("fk:flex fk:w-full fk:flex-col fk:gap-4",c.month),nav:a$1("fk:absolute fk:inset-x-0 fk:top-0 fk:flex fk:w-full fk:items-center fk:justify-between fk:gap-1",c.nav),button_previous:a$1(a$9({variant:r}),"fk:size-(--cell-size) fk:p-0 fk:select-none fk:aria-disabled:opacity-50",c.button_previous),button_next:a$1(a$9({variant:r}),"fk:size-(--cell-size) fk:p-0 fk:select-none fk:aria-disabled:opacity-50",c.button_next),month_caption:a$1("fk:flex fk:h-(--cell-size) fk:w-full fk:items-center fk:justify-center fk:px-(--cell-size)",c.month_caption),dropdowns:a$1("fk:flex fk:h-(--cell-size) fk:w-full fk:items-center fk:justify-center fk:gap-1.5 fk:text-sm fk:font-medium",c.dropdowns),dropdown_root:a$1("fk:relative fk:rounded-md fk:border fk:border-input fk:shadow-xs fk:has-focus:border-ring fk:has-focus:ring-[3px] fk:has-focus:ring-ring/50",c.dropdown_root),dropdown:a$1("fk:absolute fk:inset-0 fk:bg-popover fk:opacity-0",c.dropdown),caption_label:a$1("fk:font-medium fk:select-none",o==="label"?"fk:text-sm":"fk:flex fk:h-8 fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 fk:pl-2 fk:text-sm fk:[&>svg]:size-3.5 fk:[&>svg]:text-muted-foreground",c.caption_label),table:"fk:w-full fk:border-collapse",weekdays:a$1("fk:flex",c.weekdays),weekday:a$1("fk:flex-1 fk:rounded-md fk:text-[0.8rem] fk:font-normal fk:text-muted-foreground fk:select-none",c.weekday),week:a$1("fk:mt-2 fk:flex fk:w-full",c.week),week_number_header:a$1("fk:w-(--cell-size) fk:select-none",c.week_number_header),week_number:a$1("fk:text-[0.8rem] fk:text-muted-foreground fk:select-none",c.week_number),day:a$1("fk:group/day fk:relative fk:aspect-square fk:h-full fk:w-full fk:p-0 fk:text-center fk:select-none fk:[&:last-child[data-selected=true]_button]:rounded-r-md",a.showWeekNumber?"fk:[&:nth-child(2)[data-selected=true]_button]:rounded-l-md":"fk:[&:first-child[data-selected=true]_button]:rounded-l-md",c.day),range_start:a$1("fk:rounded-l-md fk:bg-accent",c.range_start),range_middle:a$1("fk:rounded-none",c.range_middle),range_end:a$1("fk:rounded-r-md fk:bg-accent",c.range_end),today:a$1("fk:rounded-md fk:bg-accent fk:text-accent-foreground fk:data-[selected=true]:rounded-none",c.today),outside:a$1("fk:text-muted-foreground fk:aria-selected:text-muted-foreground",c.outside),disabled:a$1("fk:text-muted-foreground fk:opacity-50",c.disabled),hidden:a$1("invisible",c.hidden),...t},components:{Root:({className:l,rootRef:u,...f})=>jsx("div",{"data-slot":"calendar",ref:u,className:a$1(l),...f}),Chevron:({className:l,orientation:u,...f})=>u==="left"?jsx(ChevronLeftIcon,{className:a$1("size-4",l),...f}):u==="right"?jsx(ChevronRightIcon,{className:a$1("size-4",l),...f}):jsx(ChevronDownIcon,{className:a$1("size-4",l),...f}),DayButton:Ef,WeekNumber:({children:l,...u})=>jsx("td",{...u,children:jsx("div",{className:"fk:flex fk:size-(--cell-size) fk:items-center fk:justify-center fk:text-center",children:l})}),...s},...a})}function Ef({className:e,day:t,modifiers:n,...o}){let r=getDefaultClassNames(),i=Lo.useRef(null);return Lo.useEffect(()=>{n.focused&&i.current?.focus();},[n.focused]),jsx(b$3,{ref:i,variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:a$1("fk:flex fk:aspect-square fk:size-auto fk:w-full fk:min-w-(--cell-size) fk:flex-col fk:gap-1 fk:leading-none fk:font-normal fk:group-data-[focused=true]/day:relative fk:group-data-[focused=true]/day:z-10 fk:group-data-[focused=true]/day:border-ring fk:group-data-[focused=true]/day:ring-[3px] fk:group-data-[focused=true]/day:ring-ring/50 fk:data-[range-end=true]:rounded-md fk:data-[range-end=true]:rounded-r-md fk:data-[range-end=true]:bg-primary fk:data-[range-end=true]:text-primary-foreground fk:data-[range-middle=true]:rounded-none fk:data-[range-middle=true]:bg-accent fk:data-[range-middle=true]:text-accent-foreground fk:data-[range-start=true]:rounded-md fk:data-[range-start=true]:rounded-l-md fk:data-[range-start=true]:bg-primary fk:data-[range-start=true]:text-primary-foreground fk:data-[selected-single=true]:bg-primary fk:data-[selected-single=true]:text-primary-foreground fk:dark:hover:text-accent-foreground fk:[&>span]:text-xs fk:[&>span]:opacity-70",r.day,e),...o})}function Pa({control:e$1,fieldSchema:t,getValues:n,readOnly:o,setValue:r}){let{name:i,label:s,options:a}=t,c$1=useId();function l(m,p){r(i,{...p,value:m?m.toISOString():""});}function u(m,p){r(i,{...p,disabled:m});}function f$1(m){m.preventDefault(),r(i,{...n(i),value:void 0});}return jsx(c,{control:e$1,name:i,render:({field:m})=>jsxs(e,{onKeyDown:p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation());},children:[jsx(f,{htmlFor:c$1,children:s}),a?.comment?jsx(h$1,{children:a.comment}):null,jsx(g,{children:jsxs(Cn,{children:[jsx(wn,{asChild:true,children:jsx(b$3,{className:a$1("fk:w-full fk:justify-start fk:h-10 fk:text-left fk:font-normal fk:hover:bg-transparent fk:relative",!m.value?.value&&"fk:text-muted-foreground"),disabled:o||m.value?.disabled,id:c$1,variant:"outline",children:jsxs("div",{className:"fk:flex fk:items-center fk:w-full",children:[jsx("span",{className:"fk:grow",children:m.value?.value?format(new Date(m.value.value),"PPP")+" at "+format(new Date(m.value.value),"HH:mm"):"Pick a date and time"}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-1",children:[m.value?.value&&jsx("span",{className:"fk:p-2 fk:text-muted-foreground fk:hover:text-accent-foreground fk:cursor-pointer",onClick:p=>{p.stopPropagation(),f$1(p);},role:"button","aria-label":"Clear date",children:jsx(X,{className:"fk:h-4 fk:w-4"})}),jsx(Calendar,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground fk:hover:text-accent-foreground"})]})]})})}),jsxs(Bt,{className:"fk:w-auto fk:p-0",align:"start",children:[jsx(Ra,{mode:"single",selected:m.value?.value?new Date(m.value.value):void 0,onSelect:p=>l(p,m.value),initialFocus:true}),jsxs("div",{className:"fk:p-3 fk:border-t fk:border-border",children:[jsx("label",{htmlFor:"time",className:"fk:text-sm fk:font-medium",children:"Time"}),jsx(a$7,{className:"fk:mt-1 fk:w-[90px]",id:"time",onChange:p=>{let d=p.target.value,[g,h]=d.split(":"),v=m.value?.value?new Date(m.value.value):new Date;v.setHours(parseInt(g)),v.setMinutes(parseInt(h)),r(i,{...m.value,value:v.toISOString()});},type:"time",value:m.value?.value?format(new Date(m.value.value),"HH:mm"):""})]})]})]})}),jsx(a$6,{checked:m.value?.disabled??false,disabled:o,onChange:p=>{u(p,m.value);},scope:m.value?.scope}),jsx(i$1,{})]})})}function Ve(e){return e??null}var Vr=createSuggestionItems([{title:"Text",description:"Just start typing with plain text.",searchTerms:["p","paragraph"],icon:jsx(Text,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").run();}},{title:"To-do List",description:"Track tasks with a to-do list.",searchTerms:["todo","task","list","check","checkbox"],icon:jsx(CheckSquare,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run();}},{title:"Heading 1",description:"Big section heading.",searchTerms:["title","big","large"],icon:jsx(Heading1,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:1}).run();}},{title:"Heading 2",description:"Medium section heading.",searchTerms:["subtitle","medium"],icon:jsx(Heading2,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:2}).run();}},{title:"Heading 3",description:"Small section heading.",searchTerms:["subtitle","small"],icon:jsx(Heading3,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:3}).run();}},{title:"Bullet List",description:"Create a simple bullet list.",searchTerms:["unordered","point"],icon:jsx(List,{size:18}),command:({editor:e,range:t})=>{let n=Ve(e);n&&n.chain().focus().deleteRange(t).toggleBulletList().run();}},{title:"Numbered List",description:"Create a list with numbering.",searchTerms:["ordered"],icon:jsx(ListOrdered,{size:18}),command:({editor:e,range:t})=>{let n=Ve(e);n&&n.chain().focus().deleteRange(t).toggleOrderedList().run();}},{title:"Quote",description:"Capture a quote.",searchTerms:["blockquote"],icon:jsx(TextQuote,{size:18}),command:({editor:e,range:t})=>{let n=Ve(e);n&&n.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").toggleBlockquote().run();}},{title:"Code",description:"Capture a code snippet.",searchTerms:["codeblock"],icon:jsx(Code,{size:18}),command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()},{title:"Image",description:"Upload an image from your computer.",searchTerms:["photo","picture","media"],icon:jsx(ImageIcon,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();let n=document.createElement("input");n.type="file",n.accept="image/*",n.onchange=async()=>{n.files?.length;},n.click();}},{title:"Youtube",description:"Embed a Youtube video.",searchTerms:["video","youtube","embed"],icon:jsx(Youtube,{size:18}),command:({editor:e,range:t})=>{let n=prompt("Please enter Youtube Video Link");new RegExp(/^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/).test(n??"")?e.chain().focus().deleteRange(t).setYoutubeVideo({src:n??""}).run():n!==null&&alert("Please enter a correct Youtube Video Link");}},{title:"Twitter",description:"Embed a Tweet.",searchTerms:["twitter","embed"],icon:jsx(Twitter,{size:18}),command:({editor:e,range:t})=>{let n=prompt("Please enter Twitter Link");new RegExp(/^https?:\/\/(www\.)?x\.com\/([a-zA-Z0-9_]{1,15})(\/status\/(\d+))?(\/\S*)?$/).test(n??"")?e.chain().focus().deleteRange(t).setTweet({src:n??""}).run():n!==null&&alert("Please enter a correct Twitter Link");}}]),Ia=Command.configure({suggestion:{items:()=>Vr,render:renderItems}});var Ma=[{name:"Default",color:"var(--novel-black)"},{name:"Purple",color:"#9333EA"},{name:"Red",color:"#E00000"},{name:"Yellow",color:"#EAB308"},{name:"Blue",color:"#2563EB"},{name:"Green",color:"#008A00"},{name:"Orange",color:"#FFA500"},{name:"Pink",color:"#BA4081"},{name:"Gray",color:"#A8A29E"}],_a=[{name:"Default",color:"var(--novel-highlight-default)"},{name:"Purple",color:"var(--novel-highlight-purple)"},{name:"Red",color:"var(--novel-highlight-red)"},{name:"Yellow",color:"var(--novel-highlight-yellow)"},{name:"Blue",color:"var(--novel-highlight-blue)"},{name:"Green",color:"var(--novel-highlight-green)"},{name:"Orange",color:"var(--novel-highlight-orange)"},{name:"Pink",color:"var(--novel-highlight-pink)"},{name:"Gray",color:"var(--novel-highlight-gray)"}],$a=({open:e,onOpenChange:t})=>{let{editor:n}=useEditor();if(!n)return null;let o=Ma.find(({color:i})=>n.isActive("textStyle",{color:i})),r=_a.find(({color:i})=>n.isActive("highlight",{color:i}));return jsxs(Cn,{modal:true,open:e,onOpenChange:t,children:[jsx(wn,{asChild:true,children:jsxs(b$3,{size:"sm",className:"fk:gap-2 fk:rounded-none",variant:"ghost",children:[jsx("span",{className:"fk:rounded-xs fk:px-1",style:{color:o?.color,backgroundColor:r?.color},children:"A"}),jsx(ChevronDown,{className:"fk:h-4 fk:w-4"})]})}),jsxs(Bt,{sideOffset:5,className:"fk:my-1 fk:flex fk:max-h-80 fk:w-48 fk:flex-col fk:overflow-hidden fk:overflow-y-auto fk:rounded-sm fk:border fk:p-1 fk:shadow-xl ",align:"start",children:[jsxs("div",{className:"fk:flex fk:flex-col",children:[jsx("div",{className:"fk:my-1 fk:px-2 fk:text-sm fk:font-semibold fk:text-muted-foreground",children:"Color"}),Ma.map(({name:i,color:s})=>jsx(EditorBubbleItem,{onSelect:()=>{n.commands.unsetColor(),i!=="Default"&&n.chain().focus().setColor(s||"").run(),t(false);},className:"fk:flex fk:cursor-pointer fk:items-center fk:justify-between fk:px-2 fk:py-1 fk:text-sm fk:hover:bg-muted",children:jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx("div",{className:"fk:rounded-xs fk:border fk:px-2 fk:py-px fk:font-medium",style:{color:s},children:"A"}),jsx("span",{children:i})]})},i))]}),jsxs("div",{children:[jsx("div",{className:"fk:my-1 fk:px-2 fk:text-sm fk:font-semibold fk:text-muted-foreground",children:"Background"}),_a.map(({name:i,color:s})=>jsxs(EditorBubbleItem,{onSelect:()=>{n.commands.unsetHighlight(),i!=="Default"&&n.chain().focus().setHighlight({color:s}).run(),t(false);},className:"fk:flex fk:cursor-pointer fk:items-center fk:justify-between fk:px-2 fk:py-1 fk:text-sm fk:hover:bg-muted",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx("div",{className:"fk:rounded-xs fk:border fk:px-2 fk:py-px fk:font-medium",style:{backgroundColor:s},children:"A"}),jsx("span",{children:i})]}),n.isActive("highlight",{color:s})&&jsx(Check,{className:"fk:h-4 fk:w-4"})]},i))]})]})]})};function Zf(e){try{return new URL(e),!0}catch{return false}}function Yf(e){if(Zf(e))return e;try{if(e.includes(".")&&!e.includes(" "))return new URL(`https://${e}`).toString()}catch{return null}}var Va=({open:e,onOpenChange:t})=>{let n=useRef(null),{editor:o}=useEditor();return useEffect(()=>{n.current?.focus();}),o?jsxs(Popover.Root,{modal:true,open:e,onOpenChange:t,children:[jsx(Popover.Trigger,{asChild:true,children:jsxs(b$3,{size:"sm",variant:"ghost",className:"fk:gap-2 fk:rounded-none fk:border-none",children:[jsx("p",{className:"fk:text-base",children:"\u2197"}),jsx("p",{className:a$1("fk:underline fk:decoration-stone-400 fk:underline-offset-4",{"fk:text-blue-500":o.isActive("link")}),children:"Link"})]})}),jsx(Bt,{align:"start",className:"fk:w-60 fk:p-0",sideOffset:10,children:jsxs("form",{onSubmit:r=>{let i=r.currentTarget;r.preventDefault();let s=i[0],a=Yf(s.value);a&&(o.chain().focus().setLink({href:a}).run(),t(false));},className:"fk:flex fk:p-1",children:[jsx("input",{ref:n,type:"text",placeholder:"Paste a link",className:"fk:flex-1 fk:bg-background fk:p-1 fk:text-sm fk:outline-hidden",defaultValue:o.getAttributes("link").href||""}),o.getAttributes("link").href?jsx(b$3,{size:"icon",variant:"outline",type:"button",className:"fk:flex fk:h-8 fk:items-center fk:rounded-xs fk:p-1 fk:text-red-600 fk:transition-all fk:hover:bg-red-100 fk:dark:hover:bg-red-800",onClick:()=>{o.chain().focus().unsetLink().run(),n.current&&(n.current.value=""),t(false);},children:jsx(Trash,{className:"fk:h-4 fk:w-4"})}):jsx(b$3,{size:"icon",className:"fk:h-8",children:jsx(Check,{className:"fk:h-4 fk:w-4"})})]})})]}):null};var za=[{name:"Text",icon:TextIcon,command:e=>e?.chain().focus().clearNodes().run(),isActive:e=>e!=null&&e.isActive("paragraph")&&!e.isActive("bulletList")&&!e.isActive("orderedList")},{name:"Heading 1",icon:Heading1,command:e=>{let t=Ve(e);t&&t.chain().focus().clearNodes().toggleHeading({level:1}).run();},isActive:e=>e!=null&&e.isActive("heading",{level:1})},{name:"Heading 2",icon:Heading2,command:e=>{let t=Ve(e);t&&t.chain().focus().clearNodes().toggleHeading({level:2}).run();},isActive:e=>e!=null&&e.isActive("heading",{level:2})},{name:"Heading 3",icon:Heading3,command:e=>{let t=Ve(e);t&&t.chain().focus().clearNodes().toggleHeading({level:3}).run();},isActive:e=>e!=null&&e.isActive("heading",{level:3})},{name:"To-do List",icon:CheckSquare,command:e=>e?.chain().focus().clearNodes().toggleTaskList().run(),isActive:e=>e!=null&&e.isActive("taskItem")},{name:"Bullet List",icon:ListOrdered,command:e=>{let t=Ve(e);t&&t.chain().focus().clearNodes().toggleBulletList().run();},isActive:e=>e!=null&&e.isActive("bulletList")},{name:"Numbered List",icon:ListOrdered,command:e=>{let t=Ve(e);t&&t.chain().focus().clearNodes().toggleOrderedList().run();},isActive:e=>e!=null&&e.isActive("orderedList")},{name:"Quote",icon:TextQuote,command:e=>{let t=Ve(e);t&&t.chain().focus().clearNodes().toggleBlockquote().run();},isActive:e=>e!=null&&e.isActive("blockquote")},{name:"Code",icon:Code,command:e=>e?.chain().focus().clearNodes().toggleCodeBlock().run(),isActive:e=>e!=null&&e.isActive("codeBlock")}],ja=({open:e,onOpenChange:t})=>{let{editor:n}=useEditor();if(!n)return null;let o=za.filter(r=>r.isActive(n)).pop()??{name:"Multiple"};return jsxs(Popover.Root,{modal:true,open:e,onOpenChange:t,children:[jsx(Popover.Trigger,{asChild:true,className:"fk:gap-2 fk:rounded-none fk:border-none fk:hover:bg-muted fk:focus:ring-0",children:jsxs(b$3,{size:"sm",variant:"ghost",className:"fk:gap-2",children:[jsx("span",{className:"fk:whitespace-nowrap fk:text-sm",children:o.name}),jsx(ChevronDown,{className:"fk:h-4 fk:w-4"})]})}),jsx(Popover.Content,{sideOffset:5,align:"start",className:"fk:w-48 fk:p-1",children:za.map(r=>jsxs(EditorBubbleItem,{onSelect:i=>{r.command(i),t(false);},className:"fk:flex fk:cursor-pointer fk:items-center fk:justify-between fk:rounded-xs fk:px-2 fk:py-1 fk:text-sm fk:hover:bg-muted",children:[jsxs("div",{className:"fk:flex fk:items-center fk:space-x-2",children:[jsx("div",{className:"fk:rounded-xs fk:border fk:p-1",children:jsx(r.icon,{className:"fk:h-3 fk:w-3"})}),jsx("span",{children:r.name})]}),o.name===r.name&&jsx(Check,{className:"fk:h-4 fk:w-4"})]},r.name))})]})};var Ua=()=>{let{editor:e}=useEditor();return e?jsx(b$3,{variant:"ghost",size:"sm",className:"fk:rounded-none fk:w-12",onClick:t=>{if(e.isActive("math"))e.chain().focus().unsetLatex().run();else {let{from:n,to:o}=e.state.selection,r=e.state.doc.textBetween(n,o);if(!r)return;e.chain().focus().setLatex({latex:r}).run();}},children:jsx(SigmaIcon,{className:a$1("fk:size-4",{"fk:text-blue-500":e.isActive("math")}),strokeWidth:2.3})}):null};var qa=()=>{let{editor:e}=useEditor();return e?jsx("div",{className:"fk:flex",children:[{name:"bold",isActive:n=>n!=null&&n.isActive("bold"),command:n=>{let o=Ve(n);o&&o.chain().focus().toggleBold().run();},icon:BoldIcon},{name:"italic",isActive:n=>n!=null&&n.isActive("italic"),command:n=>{let o=Ve(n);o&&o.chain().focus().toggleItalic().run();},icon:ItalicIcon},{name:"underline",isActive:n=>n!=null&&n.isActive("underline"),command:n=>n?.chain().focus().toggleUnderline().run(),icon:UnderlineIcon},{name:"strike",isActive:n=>n!=null&&n.isActive("strike"),command:n=>{let o=Ve(n);o&&o.chain().focus().toggleStrike().run();},icon:StrikethroughIcon},{name:"code",isActive:n=>n!=null&&n.isActive("code"),command:n=>{let o=Ve(n);o&&o.chain().focus().toggleCode().run();},icon:CodeIcon}].map(n=>jsx(EditorBubbleItem,{onSelect:o=>{n.command(o);},children:jsx(b$3,{size:"sm",className:"fk:rounded-none",onClick:o=>o.preventDefault(),variant:"ghost",children:jsx(n.icon,{className:a$1("fk:h-4 fk:w-4",{"fk:text-blue-500":n.isActive(e)})})})},n.name))}):null};function Qn({className:e}){return jsxs("svg",{width:"469",height:"469",viewBox:"0 0 469 469",fill:"none",xmlns:"http://www.w3.org/2000/svg",shapeRendering:"geometricPrecision",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",className:e,children:[jsx("title",{children:"Magic AI icon"}),jsx("path",{d:"M237.092 62.3004L266.754 71.4198C267.156 71.5285 267.51 71.765 267.765 72.0934C268.02 72.4218 268.161 72.8243 268.166 73.2399C268.172 73.6555 268.042 74.0616 267.796 74.3967C267.55 74.7318 267.201 74.9777 266.803 75.097L237.141 84.3145C236.84 84.4058 236.566 84.5699 236.344 84.7922C236.121 85.0146 235.957 85.2883 235.866 85.5893L226.747 115.252C226.638 115.653 226.401 116.008 226.073 116.263C225.745 116.517 225.342 116.658 224.926 116.664C224.511 116.669 224.105 116.539 223.77 116.293C223.435 116.047 223.189 115.699 223.069 115.301L213.852 85.6383C213.761 85.3374 213.597 85.0636 213.374 84.8412C213.152 84.6189 212.878 84.4548 212.577 84.3635L182.914 75.2441C182.513 75.1354 182.158 74.8989 181.904 74.5705C181.649 74.2421 181.508 73.8396 181.503 73.424C181.497 73.0084 181.627 72.6023 181.873 72.2672C182.119 71.9321 182.467 71.6863 182.865 71.5669L212.528 62.3494C212.829 62.2582 213.103 62.0941 213.325 61.8717C213.547 61.6494 213.712 61.3756 213.803 61.0747L222.922 31.4121C223.031 31.0109 223.267 30.656 223.596 30.4013C223.924 30.1465 224.327 30.0057 224.742 30.0002C225.158 29.9946 225.564 30.1247 225.899 30.3706C226.234 30.6165 226.48 30.9649 226.599 31.363L235.817 61.0257C235.908 61.3266 236.072 61.6003 236.295 61.8227C236.517 62.0451 236.791 62.2091 237.092 62.3004Z",fill:"currentColor"}),jsx("path",{d:"M155.948 155.848L202.771 168.939C203.449 169.131 204.045 169.539 204.47 170.101C204.895 170.663 205.125 171.348 205.125 172.052C205.125 172.757 204.895 173.442 204.47 174.004C204.045 174.566 203.449 174.974 202.771 175.166L155.899 188.06C155.361 188.209 154.87 188.496 154.475 188.891C154.079 189.286 153.793 189.777 153.644 190.316L140.553 237.138C140.361 237.816 139.953 238.413 139.391 238.838C138.829 239.262 138.144 239.492 137.44 239.492C136.735 239.492 136.05 239.262 135.488 238.838C134.927 238.413 134.519 237.816 134.327 237.138L121.432 190.267C121.283 189.728 120.997 189.237 120.601 188.842C120.206 188.446 119.715 188.16 119.177 188.011L72.3537 174.92C71.676 174.728 71.0795 174.32 70.6547 173.759C70.2299 173.197 70 172.512 70 171.807C70 171.103 70.2299 170.418 70.6547 169.856C71.0795 169.294 71.676 168.886 72.3537 168.694L119.226 155.799C119.764 155.65 120.255 155.364 120.65 154.969C121.046 154.573 121.332 154.082 121.481 153.544L134.572 106.721C134.764 106.043 135.172 105.447 135.734 105.022C136.295 104.597 136.981 104.367 137.685 104.367C138.389 104.367 139.075 104.597 139.637 105.022C140.198 105.447 140.606 106.043 140.798 106.721L153.693 153.593C153.842 154.131 154.128 154.622 154.524 155.018C154.919 155.413 155.41 155.699 155.948 155.848Z",fill:"currentColor"}),jsx("path",{d:"M386.827 289.992C404.33 292.149 403.84 305.828 386.876 307.299C346.623 310.829 298.869 316.271 282.199 360.005C274.844 379.192 269.942 403.2 267.49 432.029C267.427 432.846 267.211 433.626 266.856 434.319C266.501 435.012 266.015 435.602 265.431 436.05C254.988 444.041 251.212 434.186 250.183 425.606C239.2 332.353 214.588 316.909 124.668 306.122C123.892 306.031 123.151 305.767 122.504 305.35C121.857 304.933 121.322 304.375 120.942 303.72C116.399 295.679 119.324 291.038 129.718 289.796C224.688 278.47 236.062 262.83 250.183 169.331C252.177 156.355 257.259 154.083 265.431 162.516C266.51 163.593 267.202 165.099 267.392 166.782C279.257 258.564 293.328 278.617 386.827 289.992Z",fill:"currentColor"})]})}var Cd=()=>jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-0.5",children:[jsx("div",{className:"fk:h-1.5 fk:w-1.5 fk:animate-bounce fk:rounded-full fk:bg-pink-500 [animation-delay:-0.3s]"}),jsx("div",{className:"fk:h-1.5 fk:w-1.5 fk:animate-bounce fk:rounded-full fk:bg-pink-600 [animation-delay:-0.15s]"}),jsx("div",{className:"fk:h-1.5 fk:w-1.5 fk:animate-bounce fk:rounded-full fk:bg-pink-600"})]}),Ja=Cd;function Hr({completion:e,onDiscard:t}){let{editor:n}=useEditor();return n?jsxs(Fragment,{children:[jsxs(s$1,{children:[jsxs(u$1,{className:"fk:gap-2 fk:px-4",value:"replace",onSelect:()=>{let{selection:o}=n.view.state;n.chain().focus().insertContentAt({from:o.from,to:o.to},e).run();},children:[jsx(Check,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground"}),"Replace selection"]}),jsxs(u$1,{className:"fk:gap-2 fk:px-4",value:"insert",onSelect:()=>{let{selection:o}=n.view.state;n.chain().focus().insertContentAt(o.to+1,e).run();},children:[jsx(TextQuote,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground"}),"Insert below"]})]}),jsx(t$1,{}),jsx(s$1,{children:jsxs(u$1,{onSelect:t,value:"thrash",className:"fk:gap-2 fk:px-4",children:[jsx(TrashIcon,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground"}),"Discard"]})})]}):null}var Md=[{value:"improve",label:"Improve writing",icon:RefreshCcwDot},{value:"fix",label:"Fix grammar",icon:CheckCheck},{value:"shorter",label:"Make shorter",icon:ArrowDownWideNarrow},{value:"longer",label:"Make longer",icon:WrapText}];function qr({onSelect:e}){let{editor:t}=useEditor();return t?jsxs(Fragment,{children:[jsx(s$1,{heading:"Edit or review selection",children:Md.map(n=>jsxs(u$1,{onSelect:o=>{let r=t.state.selection.content(),i=t.storage.markdown.serializer.serialize(r.content);e(i,o);},className:"fk:flex fk:gap-2 fk:px-4",value:n.value,children:[jsx(n.icon,{className:"fk:h-4 fk:w-4 fk:text-foreground"}),n.label]},n.value))}),jsx(t$1,{}),jsx(s$1,{heading:"Use AI to do more",children:jsxs(u$1,{onSelect:()=>{let n=t.state.selection.from,o=getPrevText(t,n);e(o,"continue");},value:"continue",className:"fk:gap-2 fk:px-4",children:[jsx(StepForward,{className:"fk:h-4 fk:w-4 fk:text-foreground"}),"Continue writing"]})})]}):null}function Qa({onOpenChange:e}){let{editor:t}=useEditor(),[n,o]=useState(""),{projectId:r}=useParams(),{completion:i,complete:s,isLoading:a}=useCompletion({api:c$6(r).completion,fetch:async(l,u)=>{let f=await fetch(l,u);if(f.status===429)throw toast.error("You have reached your request limit for the day."),new Error("FK_AI_RATE_LIMIT");return f},onError:l=>{l.message!=="FK_AI_RATE_LIMIT"&&toast.error(l.message);}}),c=i.length>0;return t?jsxs(n$1,{className:"fk:w-[350px]",children:[c&&jsx("div",{className:"fk:flex fk:max-h-[400px]",children:jsx(w,{children:jsx("div",{className:"fk:prose fk:p-2 fk:px-4 fk:prose-sm",children:jsx(Hd,{children:i})})})}),a&&jsxs("div",{className:"fk:flex fk:h-12 fk:w-full fk:items-center fk:px-4 fk:text-sm fk:font-medium fk:text-muted-foreground fk:text-pink-600",children:[jsx(Qn,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:shrink-0 "}),"AI is thinking",jsx("div",{className:"fk:ml-2 fk:mt-1",children:jsx(Ja,{})})]}),!a&&jsxs(Fragment,{children:[jsxs("div",{className:"fk:relative",children:[jsx(p$1,{value:n,onValueChange:o,autoFocus:true,placeholder:c?"Tell AI what to do next":"Ask AI to edit or generate...",onFocus:()=>addAIHighlight(t)}),jsx(b$3,{size:"icon",className:"fk:absolute fk:right-2 fk:top-1/2 fk:h-6 w-6 fk:-translate-y-1/2 fk:rounded-full fk:bg-pink-600 fk:hover:bg-pink-800",onClick:()=>{if(i)return s(i,{body:{option:"zap",command:n}}).then(()=>o(""));let l=t.state.selection.content(),u=t.storage.markdown.serializer.serialize(l.content);s(u,{body:{option:"zap",command:n}}).then(()=>o(""));},children:jsx(ArrowUp,{className:"fk:h-4 fk:w-4"})})]}),jsx(q$1,{children:c?jsx(Hr,{onDiscard:()=>{t.chain().unsetHighlight().focus().run(),e(false);},completion:i}):jsx(qr,{onSelect:(l,u)=>s(l,{body:{option:u}})})})]})]}):null}function Gr({children:e,open:t,onOpenChange:n}){let{editor:o}=useEditor();return useEffect(()=>{o&&(t||removeAIHighlight(o));},[o,t]),o?jsxs(EditorBubble,{tippyOptions:{placement:t?"bottom-start":"top",onHidden:()=>{n(false),o.chain().unsetHighlight().run();}},className:"fk:flex fk:w-fit fk:max-w-[90vw] fk:overflow-hidden fk:rounded-md fk:border fk:border-muted fk:bg-background fk:shadow-xl",children:[t&&jsx(Qa,{open:t,onOpenChange:n}),!t&&jsxs(Fragment$1,{children:[jsxs(b$3,{className:"fk:gap-1 fk:rounded-none fk:text-pink-600",variant:"ghost",onClick:r=>{r.preventDefault(),n(true);},size:"sm",children:[jsx(Qn,{className:"fk:h-5 fk:w-5"}),"Ask AI"]}),e]})]}):null}var am=[...a,Ia];function Wa(e){if(!e||typeof e!="object")return false;let t=e;return !(typeof t.type!="string"&&typeof t.type<"u"||!Array.isArray(t.content)&&typeof t.content<"u")}function lm(e){if(typeof e=="string"){let t=e.trim();if(!t)return;try{let n=JSON.parse(t);if(Wa(n))return n}catch{return}}if(Wa(e))return e}function Qr({control:e$1,defaultValue:t,fieldSchema:n,readOnly:o,setValue:r}){let{name:i,label:s,options:a}=n,[c$1,l]=useState(false),[u,f$1]=useState(false),[m,p]=useState(false),[d,g$1]=useState(false),h=useDebouncedCallback((b,E)=>{let A=b.getJSON();r(i,{...E,value:JSON.stringify(A)});},300);function v(b,E){r(i,{...E,disabled:b});}let y=b=>(console.log("Image uploader not yet implemented",b),Promise.resolve("https://via.placeholder.com/150"));return jsx(c,{control:e$1,name:i,render:({field:b})=>jsxs(e,{children:[jsx(f,{children:s}),a?.comment?jsx(h$1,{children:a.comment}):null,jsx(g,{children:jsx(EditorRoot,{children:jsxs(EditorContent,{className:"fk:relative fk:w-full fk:max-w-5xl fk:rounded-md fk:border fk:border-input fk:ring-offset-background fk:focus-within:outline-hidden fk:focus-within:ring-2 fk:focus-within:ring-ring fk:focus-within:ring-offset-2",editable:!o&&!b.value?.disabled,editorProps:{handleDOMEvents:{keydown:(E,A)=>handleCommandNavigation(A)},handlePaste:(E,A)=>handleImagePaste(E,A,y),handleDrop:(E,A,F,N)=>handleImageDrop(E,A,N,y),attributes:{class:"fk:prose prose-lg fk:dark:prose-invert fk:prose-headings:font-title fk:min-h-[150px] fk:font-default fk:rounded-md fk:focus:outline-hidden fk:max-w-full fk:bg-background "}},extensions:am,initialContent:lm(b.value?.value??t.value),immediatelyRender:true,onUpdate:({editor:E})=>{h(E,b.value);},slotAfter:jsx(ImageResizer,{}),children:[jsxs(EditorCommand,{className:"fk:z-50 fk:h-auto fk:max-h-[330px] fk:overflow-y-auto fk:rounded-md fk:border fk:border-muted fk:bg-background fk:px-1 fk:py-2 fk:shadow-md fk:transition-all fk:pointer-events-auto",children:[jsx(EditorCommandEmpty,{className:"fk:px-2 fk:text-muted-foreground",children:"No results"}),jsx(EditorCommandList,{children:Vr.map(E=>jsxs(EditorCommandItem,{value:E.title,onCommand:A=>E.command?.(A),className:"fk:flex fk:w-full fk:items-center fk:space-x-2 fk:rounded-md fk:px-2 fk:py-1 fk:text-left fk:text-sm fk:hover:bg-muted fk:aria-selected:bg-muted",children:[jsx("div",{className:"fk:flex fk:h-10 fk:w-10 fk:items-center fk:justify-center fk:rounded-md fk:border fk:border-muted fk:bg-background",children:E.icon}),jsxs("div",{children:[jsx("p",{className:"fk:font-medium",children:E.title}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:E.description})]})]},E.title))})]}),jsxs(Gr,{open:c$1,onOpenChange:l,children:[jsx(c$5,{orientation:"vertical"}),jsx(ja,{open:u,onOpenChange:f$1}),jsx(c$5,{orientation:"vertical"}),jsx(Va,{open:m,onOpenChange:p}),jsx(c$5,{orientation:"vertical"}),jsx(Ua,{}),jsx(c$5,{orientation:"vertical"}),jsx(qa,{}),jsx(c$5,{orientation:"vertical"}),jsx($a,{open:d,onOpenChange:g$1})]})]},`${i}:${b.value?.scope??t.scope}:${String(b.value?.disabled??t.disabled)}`)})}),jsx(a$6,{checked:b.value?.disabled??false,disabled:o,onChange:E=>{v(E,b.value);},scope:b.value?.scope}),jsx(i$1,{})]})})}var ym=So;function Zr({control:e$1,defaultValue:t,entityId:n$1,entityName:o,entityNamePlural:r,fieldSchema:i,readOnly:s,schema:a,setValue:c$1}){let{name:l$1,label:u,options:f$1,relationship:m}=i,{projectId:p}=useParams(),d=pe(),g$1=d$2(),{relationships:h}=c$2(),v=Gn(),y=useId(),b=useId(),E=useRef(null),A=useRef([]),F=useRef(null),N=useRef([]),S=useRef(""),D=useRef(t.knownAssetSortOrders??{}),[$,O]=useState(false),V=useMemo(()=>Cm(t.value),[t.value]),[R,B]=useState(V),[Z,te]=useState(()=>Object.keys(t.knownAssetSortOrders??zn(V)).length),[M,C]=useState(()=>Math.max(t.count??0,V[0]?.totalCount??0,V.length)),k=useMemo(()=>ca({attributeName:l$1,entityName:o,entityNamePlural:r,schema:a}),[o,r,l$1,a]),[_,{loading:U}]=useLazyQuery(gql`
|
|
384
|
+
`),l({variables:{where:Un(u)},update(b){for(let x of u)b.evict({id:x});},onCompleted:()=>{toast.success(m?"Items successfully deleted.":"Item successfully deleted."),Do(r,Ke(e.payload.entityName,o),u),c({type:"Dismiss",_id:e._id,payload:{}}),y();},onError:b=>{v(b);}}),i(true);})}return jsx(_n,{options:p})}var ga=createContext({isDirty:false,setIsDirty:e=>{}}),ka=({children:e})=>{let[t,n]=useState(false),o=useMemo(()=>({isDirty:t,setIsDirty:i=>{n(i);}}),[t,n]);return jsx(ga.Provider,{value:o,children:e})};function bn(){return useContext(ga)}function Lr(e,t){return !t||t.length===0||e===void 0?true:e.some(n=>t.includes(n))}function Cn(e,t){return e.filter(n=>Lr(t,n.spaces))}function Zu(e,t){return e.filter(n=>Lr(t,n.spaces)).map(n=>({...n,attributes:Cn(n.attributes,t)}))}var ha=["image/jpeg","image/png","image/webp","image/vnd.microsoft.icon","image/bmp","image/gif","image/tiff","image/svg+xml","image/avif","image/heic","image/heif","image/heic-sequence","image/heif-sequence","image/apng","audio/aac","audio/mpeg","audio/wav","audio/webm","audio/midi","audio/x-midi","audio/ogg","video/x-msvideo","video/mp4","video/mpeg","video/webm","video/quicktime","video/ogg","video/mp2t","video/3gpp","video/3gpp2","application/x-7z-compressed","application/zip","application/vnd.amazon.ebook","application/octet-stream","application/epub+zip","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-fontobject","application/gzip","application/x-gzip","application/java-archive","application/json","application/ld+json","text/javascript","application/vnd.oasis.opendocument.presentation","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.text","application/ogg","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.rar","application/x-tar","application/vnd.visio","application/xhtml+xml","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/xml"];function tf(e,t){if(!e.type)return true;let n=t?t.split(",").map(o=>o.trim()).filter(Boolean):ha;return n.length===0?true:n.some(o=>o.endsWith("/*")?e.type.startsWith(o.slice(0,-1)):e.type===o)}async function Pr(e,t){let n=new URLSearchParams({filename:e.name}),o=await fetch(`${c$6(t).assets}?${n.toString()}`,{method:"POST",headers:{"Content-Type":e.type||"application/octet-stream"},body:e});if(!o.ok)throw new Error(`Upload failed for ${e.name}`);let r=await o.json(),i={_id:r._id,path:r.path??"",originalFilename:r.originalFilename??e.name,size:r.size??e.size,mimeType:r.mimeType??e.type,lqip:r.lqip??"",width:r.width??0,height:r.height??0};return {pathname:i.path,lqip:i.lqip||void 0,originalFilename:i.originalFilename,size:i.size,mimeType:i.mimeType,width:i.width||void 0,height:i.height||void 0,_id:i._id,asset:i}}async function ya(e,t){let{projectId:n,accept:o,maxBytes:r=4*1024*1024,onUploadStart:i}=t,s=[];for(let l of Array.from(e)){if(l.size>r){toast.error(`File size too big (max ${(r/(1024*1024)).toFixed(0)}MB): ${l.name}`);continue}if(!tf(l,o)){toast.error(`Unsupported file type: ${l.name}`);continue}s.push(l);}if(s.length===0)return [];i?.();try{let l=await Promise.all(s.map(async c=>Pr(c,n)));return l.length>0&&toast.success(`Uploaded ${l.length} file${l.length>1?"s":""}`),l}catch(l){return console.error(l),toast.error("Upload failed. Please try again."),[]}}async function nf(e){let{accept:t,multiple:n=true}=e,o=document.createElement("input");o.type="file",o.accept=t??ha.join(","),o.multiple=n,o.style.display="none",document.body.appendChild(o);try{let r=await new Promise(i=>{o.addEventListener("change",()=>i(o.files),{once:!0}),o.addEventListener("cancel",()=>i(null),{once:!0}),o.click();});return !r||r.length===0?[]:ya(r,e)}finally{document.body.removeChild(o);}}function Gn(){let e=useApolloClient();return useCallback(async t=>{let n=t.files?await ya(t.files,t):await nf(t);return n.length>0&&await At(e,"GetAssets").catch(o=>{console.error("Error refreshing asset lists after upload:",o);}),n},[e])}function wn(e,t,n){useEffect(()=>{function o(r){if(e.current&&!e.current.contains(r.target)){if(n){let i=Array.from(document.querySelectorAll(n));for(let s of i)if(s.contains(r.target))return}t(false);}}return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o);}},[t,e,n]),useEffect(()=>{function o(r){if(e.current&&!e.current.contains(r.target)){if(n){let i=Array.from(document.querySelectorAll(n));for(let s of i)if(s.contains(r.target))return}t(false);}}return document.addEventListener("focusin",o),()=>{document.removeEventListener("mousedown",o);}},[t,e]);}function Aa({control:e,entityId:t,fieldSchema:n,getValues:o$1,readOnly:r,setValue:i$1}){let{name:s,label:l,options:c$1}=n,{projectId:a}=useParams(),u=me(),d=d$2(),{relationships:f}=c$2(),[m,p]=useState(false),g=useRef(null),h$2=useRef(null),y=useRef(null),[v,b]=useState(null),[x,A]=useState(false),[I,N]=useState(false),$=useId(),B=useId();wn(h$2,p,"[data-radix-popper-content-wrapper]"),useEffect(()=>{let C=f[B]?.connect;if(!C||y.current===C._id)return;let k=gf(C.value);if(!k)return;let V=o$1(s);y.current=C._id,b(null),i$1(s,{...V,value:k});},[o$1,s,B,f,i$1]);function T(C){if(!C)return;let k={"application/pdf":"pdf","application/zip":"zip","application/x-zip-compressed":"zip","application/json":"json","text/csv":"csv","text/plain":"txt","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","application/vnd.apple.keynote":"key","application/vnd.apple.numbers":"numbers","application/vnd.apple.pages":"pages","application/x-7z-compressed":"7z","application/x-rar-compressed":"rar","application/xml":"xml","video/mp4":"mp4","video/quicktime":"mov","audio/mpeg":"mp3","audio/wav":"wav"};if(k[C])return k[C];let V=C.split("/");if(V.length===2){let[,q]=V;return q.includes("svg")?"svg":q.toLowerCase()}}function P(C,k){if(C&&C.includes(".")){let q=C.split(".").pop();if(q)return q.toLowerCase()}let V=T(k);return V||"file"}async function j(C,k){if(r||!C)return;let V=_r("4MB");if(C.size>(V??0)){toast.error("File size too big (max 4MB)");return}let q=C.type.startsWith("image/");if(y.current=null,q){let W=new FileReader;W.onload=se=>{b(se.target?.result);},W.readAsDataURL(C);}else b(null);N(true);try{let W=await Pr(C,a);i$1(s,{...o$1(s),value:W.asset});}catch(W){console.error(W),b(null),i$1(s,{...o$1(s),value:{_id:k?.value?._id}});}finally{N(false);}}function F(C){r||(C.stopPropagation(),y.current=null,i$1(s,{...o$1(s),_id:"",value:{_id:o$1(s)?.value?._id}}));}function U(C,k){C.stopPropagation(),k?.value&&typeof k.value=="object"&&"path"in k.value&&navigator.clipboard.writeText(`${b$4}${k.value.path}`);}function X$1(C){C.preventDefault(),C.stopPropagation(),!r&&g.current?.click();}function Y(C){if(C.preventDefault(),C.stopPropagation(),r)return;p(false);let k=o$1(s)?.value,V=y.current??kf(k),q=V?{_id:V,value:k}:void 0;d({type:"setRelationship",payload:{[B]:{connect:q,disconnect:[]}}}),window.setTimeout(()=>{u({type:"EditRelationship",payload:{assetAccept:c$1?.accept,connectedEntitiesCount:0,entityId:t,entityName:"_asset",initialAssetPath:k?.path,initialConnection:q,relationshipId:B,mode:"single"}});},0);}function L(C,k){C.stopPropagation(),k?.value&&typeof k.value=="object"&&"path"in k.value&&window.open(`${b$4}${k.value.path}?download=1`,"_blank");}return jsx(c,{control:e,name:s,render:({field:C})=>jsxs(e$1,{children:[jsx(f$1,{htmlFor:$,children:l}),c$1?.comment?jsx(h,{children:c$1.comment}):null,jsx(g$1,{className:"fk:flex fk:flex-col fk:w-full fk:min-h-[2.5rem] fk:text-sm",children:jsxs("div",{"aria-controls":`image-dropdown-${s}`,"aria-expanded":m,className:`fk:relative fk:flex fk:w-full fk:items-start fk:space-x-2 fk:rounded-md fk:border fk:overflow-hidden fk:focus-visible:outline-hidden fk:ring-offset-background fk:focus-visible:ring-2 fk:focus-visible:ring-ring fk:focus-visible:ring-offset-2 ${m?"fk:outline-hidden fk:ring-2 fk:ring-ring fk:ring-offset-2":""} ${x?"fk:border-dashed fk:border-2 fk:border-emerald-500 fk:bg-green-50":"fk:border-input fk:bg-background"} fk:corner-squircle`,onClick:k=>{k.preventDefault(),k.stopPropagation(),h$2.current?.focus(),h$2.current?.click(),p(true);},onKeyDown:k=>{k.key==="Enter"&&p(true),k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),h$2.current?.blur(),p(false));},onDragOver:k=>{r||(k.preventDefault(),k.stopPropagation(),A(true));},onDragEnter:k=>{r||(k.preventDefault(),k.stopPropagation(),A(true));},onDragLeave:k=>{r||(k.preventDefault(),k.stopPropagation(),A(false));},onDrop:k=>{if(k.preventDefault(),k.stopPropagation(),A(false),r)return;let V=k.dataTransfer.files&&k.dataTransfer.files[0];j(V,C.value);},ref:h$2,role:"combobox",tabIndex:0,children:[jsxs("div",{className:"fk:flex fk:w-full fk:space-x-2",children:[!C.value?.value?.path&&!v?jsxs("div",{className:"fk:flex fk:h-9 fk:w-full fk:px-3 fk:pt-0.5 fk:items-center",children:[jsxs("div",{className:"fk:flex fk:h-full fk:items-center fk:text-muted-foreground fk:text-sm fk:font-light",children:[jsx(Image,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Drag or paste file here"]}),jsxs(b$3,{className:"fk:ml-auto fk:h-7 fk:rounded-sm fk:text-muted-foreground fk:corner-squircle",disabled:r,id:$,onClick:X$1,variant:"ghost",children:[jsx(Upload,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Upload"]}),jsxs(b$3,{className:"fk:ml-2 fk:h-7 fk:rounded-sm fk:text-muted-foreground fk:corner-squircle",disabled:r,onClick:Y,variant:"ghost",children:[jsx(Search,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Select"]})]}):null,C.value?.value?.path&&!m?jsxs("div",{className:"fk:flex fk:h-9 fk:w-full fk:px-3 fk:pt-0.5 fk:items-center",children:[(()=>{let k=C.value?.value,V=k?.mimeType,q=k?.path||"";if(!!(V&&V.startsWith("image/")||/\.(png|jpe?g|gif|webp|avif|svg)$/i.test(q)))return jsx("img",{className:"fk:w-8 fk:h-8 fk:mr-2 fk:rounded-sm fk:object-scale-down fk:corner-squircle",src:`${b$4}${k.path}?w=128&h=128&f=webp`,alt:"Uploaded"});let se=P(k.originalFilename,k.mimeType),ee=defaultStyles[se];return jsx("div",{className:"fk:w-8 fk:h-8 fk:mr-2 fk:rounded-sm fk:bg-transparent fk:flex fk:items-center fk:justify-center fk:[&>svg]:h-full fk:[&>svg]:w-auto fk:corner-squircle",children:jsx(FileIcon,{extension:se,...ee||{}})})})(),_r((C.value?.value).size),jsx("span",{className:"fk:block fk:w-px fk:h-5 fk:mx-2 fk:bg-border"}),(C.value?.value).mimeType,(C.value?.value).width&&(C.value?.value).height?jsxs(Fragment,{children:[jsx("span",{className:"fk:block fk:w-px fk:h-5 fk:mx-2 fk:bg-border"}),(C.value?.value).width,"x",(C.value?.value).height,"px"]}):null]}):null,!C.value?.value?.path&&v&&jsxs("div",{className:"fk:flex fk:h-9 fk:w-full fk:px-3 fk:pt-0.5 fk:items-center",children:[jsx("img",{src:v,alt:"Preview",className:"fk:mr-2 fk:mt-0.5 fk:rounded-sm fk:h-7 fk:w-7 rounded-md object-cover fk:corner-squircle"}),"Loading image..."]}),!C.value?.value?.path&&!v&&I?jsxs("div",{className:"fk:flex fk:h-9 fk:w-full fk:px-3 fk:pt-0.5 fk:items-center",children:[jsx("div",{className:"fk:w-7 fk:h-7 fk:mr-2 fk:rounded-sm fk:bg-muted fk:flex fk:items-center fk:justify-center fk:corner-squircle",children:jsx(File,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground"})}),"Uploading file..."]}):null,C.value?.value?.path?jsx("div",{className:"fk:absolute fk:top-0 fk:right-10",children:jsxs(c$3,{modal:false,children:[jsx(a$7,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(e$3,{asChild:true,children:jsx(b$3,{className:"fk:h-8 fk:w-8 fk:ml-auto fk:mt-[0.1875rem] fk:rounded-sm fk:corner-squircle",onClick:k=>{k.stopPropagation();},onPointerDown:k=>{k.stopPropagation();},size:"icon",variant:"ghost",children:jsx(Ellipsis,{className:"fk:h-4 fk:w-4"})})})}),jsx(e$4,{children:jsx("p",{children:"Show actions"})})]})}),jsxs(f$3,{className:"fk:w-48",children:[jsxs(g$3,{children:[jsxs(h$1,{disabled:r,onClick:X$1,children:[jsx(Upload,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Upload"})]}),jsxs(h$1,{disabled:r,onClick:Y,children:[jsx(Image,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Select asset"})]})]}),jsx(m$1,{}),jsxs(g$3,{children:[jsxs(h$1,{onClick:k=>L(k,C.value),children:[jsx(Download,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Download"})]}),jsxs(h$1,{onClick:k=>U(k,C.value),children:[jsx(Copy,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Copy URL"})]})]}),jsx(m$1,{}),jsxs(h$1,{disabled:r,onClick:F,children:[jsx(RefreshCwOff,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Clear field"})]})]})]})}):null,jsx(Fragment,{children:!m&&(C.value?.value?.path||v)?jsx(a$7,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:absolute fk:right-[0.1875rem] fk:top-[0.1875rem] fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground fk:corner-squircle",onKeyDown:k=>{k.key==="Enter"&&(h$2.current?.focus(),h$2.current?.click());},size:"icon",variant:"ghost",children:jsx(Maximize2,{className:"fk:h-4 fk:w-4"})})}),jsx(e$4,{children:jsx("p",{children:"Expand field"})})]})}):null}),m&&(C.value?.value?.path||v)?jsx(a$7,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:absolute fk:right-[0.1875rem] fk:top-[0.1875rem] fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground fk:corner-squircle",onClick:k=>{k.preventDefault(),k.stopPropagation(),h$2.current?.blur(),p(false);},onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),k.stopPropagation(),h$2.current?.blur(),p(false));},size:"icon",variant:"ghost",children:jsx(X,{className:"fk:h-4 fk:w-4"})})}),jsx(e$4,{children:jsx("p",{children:"Close"})})]})}):null]}),jsx(o,{className:"fk:w-full fk:space-y-2 fk:ml-0!",onOpenChange:p,open:m&&(!!C.value?.value?.path||!!v),children:jsx(q,{className:"fk:w-full",children:jsx("div",{className:"fk:flex fk:w-full fk:h-[30vh]",id:`image-dropdown-${s}`,children:C.value?.value?.path?(()=>{let k=C.value?.value,V=k?.mimeType,q=k?.path||"";if(!!(V&&V.startsWith("image/")||/\.(png|jpe?g|gif|webp|avif|svg)$/i.test(q)))return jsx("img",{className:"fk:w-full fk:rounded-md fk:object-scale-down fk:corner-squircle",src:`${b$4}${k.path}?w=624&h=624&f=webp`,alt:"Uploaded"});let se=P(k.originalFilename,k.mimeType),ee=defaultStyles[se];return jsxs("div",{className:"fk:w-full fk:h-full fk:rounded-md fk:bg-muted/40 fk:flex fk:flex-col fk:items-center fk:justify-center fk:text-muted-foreground fk:corner-squircle",children:[jsx("div",{className:"fk:w-16 fk:h-16 fk:rounded-sm fk:bg-transparent fk:flex fk:items-center fk:justify-center fk:[&>svg]:h-full fk:[&>svg]:w-auto fk:corner-squircle",children:jsx(FileIcon,{extension:se,...ee||{}})}),jsxs("div",{className:"fk:mt-3 fk:text-sm",children:[k.originalFilename||"File"," \xB7 ",_r(k.size)," \xB7 ",k.mimeType]}),jsx("div",{className:"fk:mt-1 fk:text-xs",children:"Preview not available"})]})})():null})})}),I?jsx("div",{className:"fk:absolute fk:m-0! fk:top-0 fk:left-0 fk:right-0 fk:bottom-0 fk:w-full fk:bg-muted-foreground/5 fk:overflow-hidden",children:jsx("div",{className:"fk:animate-progress fk:w-full fk:h-full fk:bg-muted-foreground/10"})}):null]})}),jsx("input",{accept:c$1?.accept?c$1.accept:"image/*",className:"fk:hidden",disabled:r,id:`file-upload-${s}`,onChange:k=>{let V=k.currentTarget.files&&k.currentTarget.files[0];j(V,C.value);},ref:g,type:"file"}),jsx(i,{})]})})}function gf(e){if(!e||typeof e!="object"||!("_id"in e)||!("path"in e))return null;let t=e;return {_id:String(t._id??""),path:String(t.path??""),originalFilename:String(t.originalFilename??""),size:Number(t.size??0),mimeType:String(t.mimeType??""),lqip:String(t.lqip??""),width:Number(t.width??0),height:Number(t.height??0)}}function kf(e){return !e?._id||e._id.includes(":")?"":e._id}function Ta({control:e,fieldSchema:t,readOnly:n,setValue:o}){let{name:r,label:i$1,options:s,dataType:l}=t,c$1=useId();function a(d,f){let m=d.currentTarget.value,p;m===""?p="":(p=l==="float"?parseFloat(m):parseInt(m,10),isNaN(p)&&(p="")),o(r,{...f,value:p});}function u(d,f){o(r,{...f,disabled:d});}return jsx(c,{control:e,name:r,render:({field:d})=>jsxs(e$1,{children:[jsx(f$1,{htmlFor:c$1,children:i$1}),s?.comment?jsx(h,{children:s.comment}):null,jsx(g$1,{children:jsx(a$6,{className:"fk:w-full fk:mt-0.75",disabled:n||d.value?.disabled,id:c$1,...d,onChange:f=>{a(f,d.value);},step:l==="float"?"any":"1",type:"number",value:d.value?.value??""})}),jsx(a$5,{checked:d.value?.disabled??false,disabled:n,onChange:f=>{u(f,d.value);},scope:d.value?.scope}),jsx(i,{})]})})}function Da({className:e,classNames:t,showOutsideDays:n=true,captionLayout:o="label",buttonVariant:r="ghost",formatters:i,components:s,...l}){let c=getDefaultClassNames();return jsx(DayPicker,{showOutsideDays:n,className:a$8("fk:group/calendar fk:bg-background fk:p-3 fk:[--cell-size:--spacing(8)] fk:in-data-[slot=card-content]:bg-transparent fk:in-data-[slot=popover-content]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:o,formatters:{formatMonthDropdown:a=>a.toLocaleString("default",{month:"short"}),...i},classNames:{root:a$8("w-fit",c.root),months:a$8("fk:relative fk:flex fk:flex-col fk:gap-4 fk:md:flex-row",c.months),month:a$8("fk:flex fk:w-full fk:flex-col fk:gap-4",c.month),nav:a$8("fk:absolute fk:inset-x-0 fk:top-0 fk:flex fk:w-full fk:items-center fk:justify-between fk:gap-1",c.nav),button_previous:a$8(a$9({variant:r}),"fk:size-(--cell-size) fk:p-0 fk:select-none fk:aria-disabled:opacity-50",c.button_previous),button_next:a$8(a$9({variant:r}),"fk:size-(--cell-size) fk:p-0 fk:select-none fk:aria-disabled:opacity-50",c.button_next),month_caption:a$8("fk:flex fk:h-(--cell-size) fk:w-full fk:items-center fk:justify-center fk:px-(--cell-size)",c.month_caption),dropdowns:a$8("fk:flex fk:h-(--cell-size) fk:w-full fk:items-center fk:justify-center fk:gap-1.5 fk:text-sm fk:font-medium",c.dropdowns),dropdown_root:a$8("fk:relative fk:rounded-md fk:border fk:border-input fk:shadow-xs fk:has-focus:border-ring fk:has-focus:ring-[3px] fk:has-focus:ring-ring/50 fk:corner-squircle",c.dropdown_root),dropdown:a$8("fk:absolute fk:inset-0 fk:bg-popover fk:opacity-0",c.dropdown),caption_label:a$8("fk:font-medium fk:select-none",o==="label"?"fk:text-sm":"fk:flex fk:h-8 fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 fk:pl-2 fk:text-sm fk:[&>svg]:size-3.5 fk:[&>svg]:text-muted-foreground fk:corner-squircle",c.caption_label),table:"fk:w-full fk:border-collapse",weekdays:a$8("fk:flex",c.weekdays),weekday:a$8("fk:flex-1 fk:rounded-md fk:text-[0.8rem] fk:font-normal fk:text-muted-foreground fk:select-none fk:corner-squircle",c.weekday),week:a$8("fk:mt-2 fk:flex fk:w-full",c.week),week_number_header:a$8("fk:w-(--cell-size) fk:select-none",c.week_number_header),week_number:a$8("fk:text-[0.8rem] fk:text-muted-foreground fk:select-none",c.week_number),day:a$8("fk:group/day fk:relative fk:aspect-square fk:h-full fk:w-full fk:p-0 fk:text-center fk:select-none fk:[&:last-child[data-selected=true]_button]:rounded-r-md",l.showWeekNumber?"fk:[&:nth-child(2)[data-selected=true]_button]:rounded-l-md":"fk:[&:first-child[data-selected=true]_button]:rounded-l-md",c.day),range_start:a$8("fk:rounded-l-md fk:bg-accent fk:corner-squircle",c.range_start),range_middle:a$8("fk:rounded-none fk:corner-squircle",c.range_middle),range_end:a$8("fk:rounded-r-md fk:bg-accent fk:corner-squircle",c.range_end),today:a$8("fk:rounded-md fk:bg-accent fk:text-accent-foreground fk:data-[selected=true]:rounded-none fk:corner-squircle",c.today),outside:a$8("fk:text-muted-foreground fk:aria-selected:text-muted-foreground",c.outside),disabled:a$8("fk:text-muted-foreground fk:opacity-50",c.disabled),hidden:a$8("invisible",c.hidden),...t},components:{Root:({className:a,rootRef:u,...d})=>jsx("div",{"data-slot":"calendar",ref:u,className:a$8(a),...d}),Chevron:({className:a,orientation:u,...d})=>u==="left"?jsx(ChevronLeftIcon,{className:a$8("size-4",a),...d}):u==="right"?jsx(ChevronRightIcon,{className:a$8("size-4",a),...d}):jsx(ChevronDownIcon,{className:a$8("size-4",a),...d}),DayButton:Sf,WeekNumber:({children:a,...u})=>jsx("td",{...u,children:jsx("div",{className:"fk:flex fk:size-(--cell-size) fk:items-center fk:justify-center fk:text-center",children:a})}),...s},...l})}function Sf({className:e,day:t,modifiers:n,...o}){let r=getDefaultClassNames(),i=Io.useRef(null);return Io.useEffect(()=>{n.focused&&i.current?.focus();},[n.focused]),jsx(b$3,{ref:i,variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:a$8("fk:flex fk:aspect-square fk:size-auto fk:w-full fk:min-w-(--cell-size) fk:flex-col fk:gap-1 fk:leading-none fk:font-normal fk:group-data-[focused=true]/day:relative fk:group-data-[focused=true]/day:z-10 fk:group-data-[focused=true]/day:border-ring fk:group-data-[focused=true]/day:ring-[3px] fk:group-data-[focused=true]/day:ring-ring/50 fk:data-[range-end=true]:rounded-md fk:data-[range-end=true]:rounded-r-md fk:data-[range-end=true]:bg-primary fk:data-[range-end=true]:text-primary-foreground fk:data-[range-middle=true]:rounded-none fk:data-[range-middle=true]:bg-accent fk:data-[range-middle=true]:text-accent-foreground fk:data-[range-start=true]:rounded-md fk:data-[range-start=true]:rounded-l-md fk:data-[range-start=true]:bg-primary fk:data-[range-start=true]:text-primary-foreground fk:data-[selected-single=true]:bg-primary fk:data-[selected-single=true]:text-primary-foreground fk:dark:hover:text-accent-foreground fk:[&>span]:text-xs fk:[&>span]:opacity-70",r.day,e),...o})}function Fa({control:e,fieldSchema:t$1,getValues:n,readOnly:o,setValue:r$1}){let{name:i$1,label:s$1,options:l}=t$1,c$1=useId();function a(f,m){r$1(i$1,{...m,value:f?f.toISOString():""});}function u(f,m){r$1(i$1,{...m,disabled:f});}function d(f){f.preventDefault(),r$1(i$1,{...n(i$1),value:void 0});}return jsx(c,{control:e,name:i$1,render:({field:f})=>jsxs(e$1,{onKeyDown:m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation());},children:[jsx(f$1,{htmlFor:c$1,children:s$1}),l?.comment?jsx(h,{children:l.comment}):null,jsx(g$1,{children:jsxs(r,{children:[jsx(s,{asChild:true,children:jsx(b$3,{className:a$8("fk:w-full fk:justify-start fk:h-10 fk:text-left fk:font-normal fk:hover:bg-transparent fk:relative",!f.value?.value&&"fk:text-muted-foreground"),disabled:o||f.value?.disabled,id:c$1,variant:"outline",children:jsxs("div",{className:"fk:flex fk:items-center fk:w-full",children:[jsx("span",{className:"fk:grow",children:f.value?.value?format(new Date(f.value.value),"PPP")+" at "+format(new Date(f.value.value),"HH:mm"):"Pick a date and time"}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-1",children:[f.value?.value&&jsx("span",{className:"fk:p-2 fk:text-muted-foreground fk:hover:text-accent-foreground fk:cursor-pointer",onClick:m=>{m.stopPropagation(),d(m);},role:"button","aria-label":"Clear date",children:jsx(X,{className:"fk:h-4 fk:w-4"})}),jsx(Calendar,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground fk:hover:text-accent-foreground"})]})]})})}),jsxs(t,{className:"fk:w-auto fk:p-0",align:"start",children:[jsx(Da,{mode:"single",selected:f.value?.value?new Date(f.value.value):void 0,onSelect:m=>a(m,f.value),initialFocus:true}),jsxs("div",{className:"fk:p-3 fk:border-t fk:border-border",children:[jsx("label",{htmlFor:"time",className:"fk:text-sm fk:font-medium",children:"Time"}),jsx(a$6,{className:"fk:mt-1 fk:w-[90px]",id:"time",onChange:m=>{let p=m.target.value,[g,h]=p.split(":"),y=f.value?.value?new Date(f.value.value):new Date;y.setHours(parseInt(g)),y.setMinutes(parseInt(h)),r$1(i$1,{...f.value,value:y.toISOString()});},type:"time",value:f.value?.value?format(new Date(f.value.value),"HH:mm"):""})]})]})]})}),jsx(a$5,{checked:f.value?.disabled??false,disabled:o,onChange:m=>{u(m,f.value);},scope:f.value?.scope}),jsx(i,{})]})})}function Oe(e){return e??null}var Or=createSuggestionItems([{title:"Text",description:"Just start typing with plain text.",searchTerms:["p","paragraph"],icon:jsx(Text,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").run();}},{title:"To-do List",description:"Track tasks with a to-do list.",searchTerms:["todo","task","list","check","checkbox"],icon:jsx(CheckSquare,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run();}},{title:"Heading 1",description:"Big section heading.",searchTerms:["title","big","large"],icon:jsx(Heading1,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:1}).run();}},{title:"Heading 2",description:"Medium section heading.",searchTerms:["subtitle","medium"],icon:jsx(Heading2,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:2}).run();}},{title:"Heading 3",description:"Small section heading.",searchTerms:["subtitle","small"],icon:jsx(Heading3,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:3}).run();}},{title:"Bullet List",description:"Create a simple bullet list.",searchTerms:["unordered","point"],icon:jsx(List,{size:18}),command:({editor:e,range:t})=>{let n=Oe(e);n&&n.chain().focus().deleteRange(t).toggleBulletList().run();}},{title:"Numbered List",description:"Create a list with numbering.",searchTerms:["ordered"],icon:jsx(ListOrdered,{size:18}),command:({editor:e,range:t})=>{let n=Oe(e);n&&n.chain().focus().deleteRange(t).toggleOrderedList().run();}},{title:"Quote",description:"Capture a quote.",searchTerms:["blockquote"],icon:jsx(TextQuote,{size:18}),command:({editor:e,range:t})=>{let n=Oe(e);n&&n.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").toggleBlockquote().run();}},{title:"Code",description:"Capture a code snippet.",searchTerms:["codeblock"],icon:jsx(Code,{size:18}),command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()},{title:"Image",description:"Upload an image from your computer.",searchTerms:["photo","picture","media"],icon:jsx(ImageIcon,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();let n=document.createElement("input");n.type="file",n.accept="image/*",n.onchange=async()=>{n.files?.length;},n.click();}},{title:"Youtube",description:"Embed a Youtube video.",searchTerms:["video","youtube","embed"],icon:jsx(Youtube,{size:18}),command:({editor:e,range:t})=>{let n=prompt("Please enter Youtube Video Link");new RegExp(/^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/).test(n??"")?e.chain().focus().deleteRange(t).setYoutubeVideo({src:n??""}).run():n!==null&&alert("Please enter a correct Youtube Video Link");}},{title:"Twitter",description:"Embed a Tweet.",searchTerms:["twitter","embed"],icon:jsx(Twitter,{size:18}),command:({editor:e,range:t})=>{let n=prompt("Please enter Twitter Link");new RegExp(/^https?:\/\/(www\.)?x\.com\/([a-zA-Z0-9_]{1,15})(\/status\/(\d+))?(\/\S*)?$/).test(n??"")?e.chain().focus().deleteRange(t).setTweet({src:n??""}).run():n!==null&&alert("Please enter a correct Twitter Link");}}]),Ra=Command.configure({suggestion:{items:()=>Or,render:renderItems}});var La=[{name:"Default",color:"var(--novel-black)"},{name:"Purple",color:"#9333EA"},{name:"Red",color:"#E00000"},{name:"Yellow",color:"#EAB308"},{name:"Blue",color:"#2563EB"},{name:"Green",color:"#008A00"},{name:"Orange",color:"#FFA500"},{name:"Pink",color:"#BA4081"},{name:"Gray",color:"#A8A29E"}],Pa=[{name:"Default",color:"var(--novel-highlight-default)"},{name:"Purple",color:"var(--novel-highlight-purple)"},{name:"Red",color:"var(--novel-highlight-red)"},{name:"Yellow",color:"var(--novel-highlight-yellow)"},{name:"Blue",color:"var(--novel-highlight-blue)"},{name:"Green",color:"var(--novel-highlight-green)"},{name:"Orange",color:"var(--novel-highlight-orange)"},{name:"Pink",color:"var(--novel-highlight-pink)"},{name:"Gray",color:"var(--novel-highlight-gray)"}],Ma=({open:e,onOpenChange:t$1})=>{let{editor:n}=useEditor();if(!n)return null;let o=La.find(({color:i})=>n.isActive("textStyle",{color:i})),r$1=Pa.find(({color:i})=>n.isActive("highlight",{color:i}));return jsxs(r,{modal:true,open:e,onOpenChange:t$1,children:[jsx(s,{asChild:true,children:jsxs(b$3,{size:"sm",className:"fk:gap-2 fk:rounded-none fk:corner-squircle",variant:"ghost",children:[jsx("span",{className:"fk:rounded-xs fk:px-1 fk:corner-squircle",style:{color:o?.color,backgroundColor:r$1?.color},children:"A"}),jsx(ChevronDown,{className:"fk:h-4 fk:w-4"})]})}),jsxs(t,{sideOffset:5,className:"fk:my-1 fk:flex fk:max-h-80 fk:w-48 fk:flex-col fk:overflow-hidden fk:overflow-y-auto fk:rounded-sm fk:border fk:p-1 fk:shadow-xl fk:corner-squircle",align:"start",children:[jsxs("div",{className:"fk:flex fk:flex-col",children:[jsx("div",{className:"fk:my-1 fk:px-2 fk:text-sm fk:font-semibold fk:text-muted-foreground",children:"Color"}),La.map(({name:i,color:s})=>jsx(EditorBubbleItem,{onSelect:()=>{n.commands.unsetColor(),i!=="Default"&&n.chain().focus().setColor(s||"").run(),t$1(false);},className:"fk:flex fk:cursor-pointer fk:items-center fk:justify-between fk:px-2 fk:py-1 fk:text-sm fk:hover:bg-muted",children:jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx("div",{className:"fk:rounded-xs fk:border fk:px-2 fk:py-px fk:font-medium fk:corner-squircle",style:{color:s},children:"A"}),jsx("span",{children:i})]})},i))]}),jsxs("div",{children:[jsx("div",{className:"fk:my-1 fk:px-2 fk:text-sm fk:font-semibold fk:text-muted-foreground",children:"Background"}),Pa.map(({name:i,color:s})=>jsxs(EditorBubbleItem,{onSelect:()=>{n.commands.unsetHighlight(),i!=="Default"&&n.chain().focus().setHighlight({color:s}).run(),t$1(false);},className:"fk:flex fk:cursor-pointer fk:items-center fk:justify-between fk:px-2 fk:py-1 fk:text-sm fk:hover:bg-muted",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx("div",{className:"fk:rounded-xs fk:border fk:px-2 fk:py-px fk:font-medium fk:corner-squircle",style:{backgroundColor:s},children:"A"}),jsx("span",{children:i})]}),n.isActive("highlight",{color:s})&&jsx(Check,{className:"fk:h-4 fk:w-4"})]},i))]})]})]})};function Wf(e){try{return new URL(e),!0}catch{return false}}function Kf(e){if(Wf(e))return e;try{if(e.includes(".")&&!e.includes(" "))return new URL(`https://${e}`).toString()}catch{return null}}var $a=({open:e,onOpenChange:t$1})=>{let n=useRef(null),{editor:o}=useEditor();return useEffect(()=>{n.current?.focus();}),o?jsxs(Popover.Root,{modal:true,open:e,onOpenChange:t$1,children:[jsx(Popover.Trigger,{asChild:true,children:jsxs(b$3,{size:"sm",variant:"ghost",className:"fk:gap-2 fk:rounded-none fk:border-none fk:corner-squircle",children:[jsx("p",{className:"fk:text-base",children:"\u2197"}),jsx("p",{className:a$8("fk:underline fk:decoration-stone-400 fk:underline-offset-4",{"fk:text-blue-500":o.isActive("link")}),children:"Link"})]})}),jsx(t,{align:"start",className:"fk:w-60 fk:p-0",sideOffset:10,children:jsxs("form",{onSubmit:r=>{let i=r.currentTarget;r.preventDefault();let s=i[0],l=Kf(s.value);l&&(o.chain().focus().setLink({href:l}).run(),t$1(false));},className:"fk:flex fk:p-1",children:[jsx("input",{ref:n,type:"text",placeholder:"Paste a link",className:"fk:flex-1 fk:bg-background fk:p-1 fk:text-sm fk:outline-hidden",defaultValue:o.getAttributes("link").href||""}),o.getAttributes("link").href?jsx(b$3,{size:"icon",variant:"outline",type:"button",className:"fk:flex fk:h-8 fk:items-center fk:rounded-xs fk:p-1 fk:text-red-600 fk:transition-all fk:hover:bg-red-100 fk:dark:hover:bg-red-800 fk:corner-squircle",onClick:()=>{o.chain().focus().unsetLink().run(),n.current&&(n.current.value=""),t$1(false);},children:jsx(Trash,{className:"fk:h-4 fk:w-4"})}):jsx(b$3,{size:"icon",className:"fk:h-8",children:jsx(Check,{className:"fk:h-4 fk:w-4"})})]})})]}):null};var Va=[{name:"Text",icon:TextIcon,command:e=>e?.chain().focus().clearNodes().run(),isActive:e=>e!=null&&e.isActive("paragraph")&&!e.isActive("bulletList")&&!e.isActive("orderedList")},{name:"Heading 1",icon:Heading1,command:e=>{let t=Oe(e);t&&t.chain().focus().clearNodes().toggleHeading({level:1}).run();},isActive:e=>e!=null&&e.isActive("heading",{level:1})},{name:"Heading 2",icon:Heading2,command:e=>{let t=Oe(e);t&&t.chain().focus().clearNodes().toggleHeading({level:2}).run();},isActive:e=>e!=null&&e.isActive("heading",{level:2})},{name:"Heading 3",icon:Heading3,command:e=>{let t=Oe(e);t&&t.chain().focus().clearNodes().toggleHeading({level:3}).run();},isActive:e=>e!=null&&e.isActive("heading",{level:3})},{name:"To-do List",icon:CheckSquare,command:e=>e?.chain().focus().clearNodes().toggleTaskList().run(),isActive:e=>e!=null&&e.isActive("taskItem")},{name:"Bullet List",icon:ListOrdered,command:e=>{let t=Oe(e);t&&t.chain().focus().clearNodes().toggleBulletList().run();},isActive:e=>e!=null&&e.isActive("bulletList")},{name:"Numbered List",icon:ListOrdered,command:e=>{let t=Oe(e);t&&t.chain().focus().clearNodes().toggleOrderedList().run();},isActive:e=>e!=null&&e.isActive("orderedList")},{name:"Quote",icon:TextQuote,command:e=>{let t=Oe(e);t&&t.chain().focus().clearNodes().toggleBlockquote().run();},isActive:e=>e!=null&&e.isActive("blockquote")},{name:"Code",icon:Code,command:e=>e?.chain().focus().clearNodes().toggleCodeBlock().run(),isActive:e=>e!=null&&e.isActive("codeBlock")}],Ba=({open:e,onOpenChange:t})=>{let{editor:n}=useEditor();if(!n)return null;let o=Va.filter(r=>r.isActive(n)).pop()??{name:"Multiple"};return jsxs(Popover.Root,{modal:true,open:e,onOpenChange:t,children:[jsx(Popover.Trigger,{asChild:true,className:"fk:gap-2 fk:rounded-none fk:border-none fk:hover:bg-muted fk:focus:ring-0 fk:corner-squircle",children:jsxs(b$3,{size:"sm",variant:"ghost",className:"fk:gap-2",children:[jsx("span",{className:"fk:whitespace-nowrap fk:text-sm",children:o.name}),jsx(ChevronDown,{className:"fk:h-4 fk:w-4"})]})}),jsx(Popover.Content,{sideOffset:5,align:"start",className:"fk:w-48 fk:p-1",children:Va.map(r=>jsxs(EditorBubbleItem,{onSelect:i=>{r.command(i),t(false);},className:"fk:flex fk:cursor-pointer fk:items-center fk:justify-between fk:rounded-xs fk:px-2 fk:py-1 fk:text-sm fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:space-x-2",children:[jsx("div",{className:"fk:rounded-xs fk:border fk:p-1 fk:corner-squircle",children:jsx(r.icon,{className:"fk:h-3 fk:w-3"})}),jsx("span",{children:r.name})]}),o.name===r.name&&jsx(Check,{className:"fk:h-4 fk:w-4"})]},r.name))})]})};var ja=()=>{let{editor:e}=useEditor();return e?jsx(b$3,{variant:"ghost",size:"sm",className:"fk:rounded-none fk:w-12 fk:corner-squircle",onClick:t=>{if(e.isActive("math"))e.chain().focus().unsetLatex().run();else {let{from:n,to:o}=e.state.selection,r=e.state.doc.textBetween(n,o);if(!r)return;e.chain().focus().setLatex({latex:r}).run();}},children:jsx(SigmaIcon,{className:a$8("fk:size-4",{"fk:text-blue-500":e.isActive("math")}),strokeWidth:2.3})}):null};var qa=()=>{let{editor:e}=useEditor();return e?jsx("div",{className:"fk:flex",children:[{name:"bold",isActive:n=>n!=null&&n.isActive("bold"),command:n=>{let o=Oe(n);o&&o.chain().focus().toggleBold().run();},icon:BoldIcon},{name:"italic",isActive:n=>n!=null&&n.isActive("italic"),command:n=>{let o=Oe(n);o&&o.chain().focus().toggleItalic().run();},icon:ItalicIcon},{name:"underline",isActive:n=>n!=null&&n.isActive("underline"),command:n=>n?.chain().focus().toggleUnderline().run(),icon:UnderlineIcon},{name:"strike",isActive:n=>n!=null&&n.isActive("strike"),command:n=>{let o=Oe(n);o&&o.chain().focus().toggleStrike().run();},icon:StrikethroughIcon},{name:"code",isActive:n=>n!=null&&n.isActive("code"),command:n=>{let o=Oe(n);o&&o.chain().focus().toggleCode().run();},icon:CodeIcon}].map(n=>jsx(EditorBubbleItem,{onSelect:o=>{n.command(o);},children:jsx(b$3,{size:"sm",className:"fk:rounded-none fk:corner-squircle",onClick:o=>o.preventDefault(),variant:"ghost",children:jsx(n.icon,{className:a$8("fk:h-4 fk:w-4",{"fk:text-blue-500":n.isActive(e)})})})},n.name))}):null};function Qn({className:e}){return jsxs("svg",{width:"469",height:"469",viewBox:"0 0 469 469",fill:"none",xmlns:"http://www.w3.org/2000/svg",shapeRendering:"geometricPrecision",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",className:e,children:[jsx("title",{children:"Magic AI icon"}),jsx("path",{d:"M237.092 62.3004L266.754 71.4198C267.156 71.5285 267.51 71.765 267.765 72.0934C268.02 72.4218 268.161 72.8243 268.166 73.2399C268.172 73.6555 268.042 74.0616 267.796 74.3967C267.55 74.7318 267.201 74.9777 266.803 75.097L237.141 84.3145C236.84 84.4058 236.566 84.5699 236.344 84.7922C236.121 85.0146 235.957 85.2883 235.866 85.5893L226.747 115.252C226.638 115.653 226.401 116.008 226.073 116.263C225.745 116.517 225.342 116.658 224.926 116.664C224.511 116.669 224.105 116.539 223.77 116.293C223.435 116.047 223.189 115.699 223.069 115.301L213.852 85.6383C213.761 85.3374 213.597 85.0636 213.374 84.8412C213.152 84.6189 212.878 84.4548 212.577 84.3635L182.914 75.2441C182.513 75.1354 182.158 74.8989 181.904 74.5705C181.649 74.2421 181.508 73.8396 181.503 73.424C181.497 73.0084 181.627 72.6023 181.873 72.2672C182.119 71.9321 182.467 71.6863 182.865 71.5669L212.528 62.3494C212.829 62.2582 213.103 62.0941 213.325 61.8717C213.547 61.6494 213.712 61.3756 213.803 61.0747L222.922 31.4121C223.031 31.0109 223.267 30.656 223.596 30.4013C223.924 30.1465 224.327 30.0057 224.742 30.0002C225.158 29.9946 225.564 30.1247 225.899 30.3706C226.234 30.6165 226.48 30.9649 226.599 31.363L235.817 61.0257C235.908 61.3266 236.072 61.6003 236.295 61.8227C236.517 62.0451 236.791 62.2091 237.092 62.3004Z",fill:"currentColor"}),jsx("path",{d:"M155.948 155.848L202.771 168.939C203.449 169.131 204.045 169.539 204.47 170.101C204.895 170.663 205.125 171.348 205.125 172.052C205.125 172.757 204.895 173.442 204.47 174.004C204.045 174.566 203.449 174.974 202.771 175.166L155.899 188.06C155.361 188.209 154.87 188.496 154.475 188.891C154.079 189.286 153.793 189.777 153.644 190.316L140.553 237.138C140.361 237.816 139.953 238.413 139.391 238.838C138.829 239.262 138.144 239.492 137.44 239.492C136.735 239.492 136.05 239.262 135.488 238.838C134.927 238.413 134.519 237.816 134.327 237.138L121.432 190.267C121.283 189.728 120.997 189.237 120.601 188.842C120.206 188.446 119.715 188.16 119.177 188.011L72.3537 174.92C71.676 174.728 71.0795 174.32 70.6547 173.759C70.2299 173.197 70 172.512 70 171.807C70 171.103 70.2299 170.418 70.6547 169.856C71.0795 169.294 71.676 168.886 72.3537 168.694L119.226 155.799C119.764 155.65 120.255 155.364 120.65 154.969C121.046 154.573 121.332 154.082 121.481 153.544L134.572 106.721C134.764 106.043 135.172 105.447 135.734 105.022C136.295 104.597 136.981 104.367 137.685 104.367C138.389 104.367 139.075 104.597 139.637 105.022C140.198 105.447 140.606 106.043 140.798 106.721L153.693 153.593C153.842 154.131 154.128 154.622 154.524 155.018C154.919 155.413 155.41 155.699 155.948 155.848Z",fill:"currentColor"}),jsx("path",{d:"M386.827 289.992C404.33 292.149 403.84 305.828 386.876 307.299C346.623 310.829 298.869 316.271 282.199 360.005C274.844 379.192 269.942 403.2 267.49 432.029C267.427 432.846 267.211 433.626 266.856 434.319C266.501 435.012 266.015 435.602 265.431 436.05C254.988 444.041 251.212 434.186 250.183 425.606C239.2 332.353 214.588 316.909 124.668 306.122C123.892 306.031 123.151 305.767 122.504 305.35C121.857 304.933 121.322 304.375 120.942 303.72C116.399 295.679 119.324 291.038 129.718 289.796C224.688 278.47 236.062 262.83 250.183 169.331C252.177 156.355 257.259 154.083 265.431 162.516C266.51 163.593 267.202 165.099 267.392 166.782C279.257 258.564 293.328 278.617 386.827 289.992Z",fill:"currentColor"})]})}var vd=()=>jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-0.5",children:[jsx("div",{className:"fk:h-1.5 fk:w-1.5 fk:animate-bounce fk:rounded-full fk:bg-pink-500 [animation-delay:-0.3s] fk:corner-squircle"}),jsx("div",{className:"fk:h-1.5 fk:w-1.5 fk:animate-bounce fk:rounded-full fk:bg-pink-600 [animation-delay:-0.15s] fk:corner-squircle"}),jsx("div",{className:"fk:h-1.5 fk:w-1.5 fk:animate-bounce fk:rounded-full fk:bg-pink-600 fk:corner-squircle"})]}),Ha=vd;function jr({completion:e,onDiscard:t}){let{editor:n}=useEditor();return n?jsxs(Fragment,{children:[jsxs(s$1,{children:[jsxs(u,{className:"fk:gap-2 fk:px-4",value:"replace",onSelect:()=>{let{selection:o}=n.view.state;n.chain().focus().insertContentAt({from:o.from,to:o.to},e).run();},children:[jsx(Check,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground"}),"Replace selection"]}),jsxs(u,{className:"fk:gap-2 fk:px-4",value:"insert",onSelect:()=>{let{selection:o}=n.view.state;n.chain().focus().insertContentAt(o.to+1,e).run();},children:[jsx(TextQuote,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground"}),"Insert below"]})]}),jsx(t$1,{}),jsx(s$1,{children:jsxs(u,{onSelect:t,value:"thrash",className:"fk:gap-2 fk:px-4",children:[jsx(TrashIcon,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground"}),"Discard"]})})]}):null}var Ld=[{value:"improve",label:"Improve writing",icon:RefreshCcwDot},{value:"fix",label:"Fix grammar",icon:CheckCheck},{value:"shorter",label:"Make shorter",icon:ArrowDownWideNarrow},{value:"longer",label:"Make longer",icon:WrapText}];function Hr({onSelect:e}){let{editor:t}=useEditor();return t?jsxs(Fragment,{children:[jsx(s$1,{heading:"Edit or review selection",children:Ld.map(n=>jsxs(u,{onSelect:o=>{let r=t.state.selection.content(),i=t.storage.markdown.serializer.serialize(r.content);e(i,o);},className:"fk:flex fk:gap-2 fk:px-4",value:n.value,children:[jsx(n.icon,{className:"fk:h-4 fk:w-4 fk:text-foreground"}),n.label]},n.value))}),jsx(t$1,{}),jsx(s$1,{heading:"Use AI to do more",children:jsxs(u,{onSelect:()=>{let n=t.state.selection.from,o=getPrevText(t,n);e(o,"continue");},value:"continue",className:"fk:gap-2 fk:px-4",children:[jsx(StepForward,{className:"fk:h-4 fk:w-4 fk:text-foreground"}),"Continue writing"]})})]}):null}function Ja({onOpenChange:e}){let{editor:t}=useEditor(),[n,o]=useState(""),{projectId:r}=useParams(),{completion:i,complete:s,isLoading:l}=useCompletion({api:c$6(r).completion,fetch:async(a,u)=>{let d=await fetch(a,u);if(d.status===429)throw toast.error("You have reached your request limit for the day."),new Error("FK_AI_RATE_LIMIT");return d},onError:a=>{a.message!=="FK_AI_RATE_LIMIT"&&toast.error(a.message);}}),c=i.length>0;return t?jsxs(n$1,{className:"fk:w-[350px]",children:[c&&jsx("div",{className:"fk:flex fk:max-h-[400px]",children:jsx(w,{children:jsx("div",{className:"fk:prose fk:p-2 fk:px-4 fk:prose-sm",children:jsx(zd,{children:i})})})}),l&&jsxs("div",{className:"fk:flex fk:h-12 fk:w-full fk:items-center fk:px-4 fk:text-sm fk:font-medium fk:text-muted-foreground fk:text-pink-600",children:[jsx(Qn,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:shrink-0 "}),"AI is thinking",jsx("div",{className:"fk:ml-2 fk:mt-1",children:jsx(Ha,{})})]}),!l&&jsxs(Fragment,{children:[jsxs("div",{className:"fk:relative",children:[jsx(p,{value:n,onValueChange:o,autoFocus:true,placeholder:c?"Tell AI what to do next":"Ask AI to edit or generate...",onFocus:()=>addAIHighlight(t)}),jsx(b$3,{size:"icon",className:"fk:absolute fk:right-2 fk:top-1/2 fk:h-6 w-6 fk:-translate-y-1/2 fk:rounded-full fk:bg-pink-600 fk:hover:bg-pink-800 fk:corner-squircle",onClick:()=>{if(i)return s(i,{body:{option:"zap",command:n}}).then(()=>o(""));let a=t.state.selection.content(),u=t.storage.markdown.serializer.serialize(a.content);s(u,{body:{option:"zap",command:n}}).then(()=>o(""));},children:jsx(ArrowUp,{className:"fk:h-4 fk:w-4"})})]}),jsx(q$1,{children:c?jsx(jr,{onDiscard:()=>{t.chain().unsetHighlight().focus().run(),e(false);},completion:i}):jsx(Hr,{onSelect:(a,u)=>s(a,{body:{option:u}})})})]})]}):null}function Jr({children:e,open:t,onOpenChange:n}){let{editor:o}=useEditor();return useEffect(()=>{o&&(t||removeAIHighlight(o));},[o,t]),o?jsxs(EditorBubble,{tippyOptions:{placement:t?"bottom-start":"top",onHidden:()=>{n(false),o.chain().unsetHighlight().run();}},className:"fk:flex fk:w-fit fk:max-w-[90vw] fk:overflow-hidden fk:rounded-md fk:border fk:border-muted fk:bg-background fk:shadow-xl fk:corner-squircle",children:[t&&jsx(Ja,{open:t,onOpenChange:n}),!t&&jsxs(Fragment$1,{children:[jsxs(b$3,{className:"fk:gap-1 fk:rounded-none fk:text-pink-600 fk:corner-squircle",variant:"ghost",onClick:r=>{r.preventDefault(),n(true);},size:"sm",children:[jsx(Qn,{className:"fk:h-5 fk:w-5"}),"Ask AI"]}),e]})]}):null}var im=[...a,Ra];function Qa(e){if(!e||typeof e!="object")return false;let t=e;return !(typeof t.type!="string"&&typeof t.type<"u"||!Array.isArray(t.content)&&typeof t.content<"u")}function sm(e){if(typeof e=="string"){let t=e.trim();if(!t)return;try{let n=JSON.parse(t);if(Qa(n))return n}catch{return}}if(Qa(e))return e}function Gr({control:e,defaultValue:t,fieldSchema:n,readOnly:o,setValue:r}){let{name:i$1,label:s,options:l}=n,[c$1,a]=useState(false),[u,d]=useState(false),[f,m]=useState(false),[p,g]=useState(false),h$1=useDebouncedCallback((b,x)=>{let A=b.getJSON();r(i$1,{...x,value:JSON.stringify(A)});},300);function y(b,x){r(i$1,{...x,disabled:b});}let v=b=>(console.log("Image uploader not yet implemented",b),Promise.resolve("https://via.placeholder.com/150"));return jsx(c,{control:e,name:i$1,render:({field:b})=>jsxs(e$1,{children:[jsx(f$1,{children:s}),l?.comment?jsx(h,{children:l.comment}):null,jsx(g$1,{children:jsx(EditorRoot,{children:jsxs(EditorContent,{className:"fk:relative fk:w-full fk:max-w-5xl fk:rounded-md fk:border fk:border-input fk:ring-offset-background fk:focus-within:outline-hidden fk:focus-within:ring-2 fk:focus-within:ring-ring fk:focus-within:ring-offset-2 fk:corner-squircle",editable:!o&&!b.value?.disabled,editorProps:{handleDOMEvents:{keydown:(x,A)=>handleCommandNavigation(A)},handlePaste:(x,A)=>handleImagePaste(x,A,v),handleDrop:(x,A,I,N)=>handleImageDrop(x,A,N,v),attributes:{class:"fk:prose prose-lg fk:dark:prose-invert fk:prose-headings:font-title fk:min-h-[150px] fk:font-default fk:rounded-md fk:corner-squirclefk:focus:outline-hidden fk:max-w-full fk:bg-background "}},extensions:im,initialContent:sm(b.value?.value??t.value),immediatelyRender:true,onUpdate:({editor:x})=>{h$1(x,b.value);},slotAfter:jsx(ImageResizer,{}),children:[jsxs(EditorCommand,{className:"fk:z-50 fk:h-auto fk:max-h-[330px] fk:overflow-y-auto fk:rounded-md fk:border fk:border-muted fk:bg-background fk:px-1 fk:py-2 fk:shadow-md fk:transition-all fk:pointer-events-auto fk:corner-squircle",children:[jsx(EditorCommandEmpty,{className:"fk:px-2 fk:text-muted-foreground",children:"No results"}),jsx(EditorCommandList,{children:Or.map(x=>jsxs(EditorCommandItem,{value:x.title,onCommand:A=>x.command?.(A),className:"fk:flex fk:w-full fk:items-center fk:space-x-2 fk:rounded-md fk:px-2 fk:py-1 fk:text-left fk:text-sm fk:hover:bg-muted fk:aria-selected:bg-muted fk:corner-squircle",children:[jsx("div",{className:"fk:flex fk:h-10 fk:w-10 fk:items-center fk:justify-center fk:rounded-md fk:border fk:border-muted fk:bg-background fk:corner-squircle",children:x.icon}),jsxs("div",{children:[jsx("p",{className:"fk:font-medium",children:x.title}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:x.description})]})]},x.title))})]}),jsxs(Jr,{open:c$1,onOpenChange:a,children:[jsx(c$5,{orientation:"vertical"}),jsx(Ba,{open:u,onOpenChange:d}),jsx(c$5,{orientation:"vertical"}),jsx($a,{open:f,onOpenChange:m}),jsx(c$5,{orientation:"vertical"}),jsx(ja,{}),jsx(c$5,{orientation:"vertical"}),jsx(qa,{}),jsx(c$5,{orientation:"vertical"}),jsx(Ma,{open:p,onOpenChange:g})]})]},`${i$1}:${b.value?.scope??t.scope}:${String(b.value?.disabled??t.disabled)}`)})}),jsx(a$5,{checked:b.value?.disabled??false,disabled:o,onChange:x=>{y(x,b.value);},scope:b.value?.scope}),jsx(i,{})]})})}var km=xo;function Kr({control:e,defaultValue:t,entityId:n,entityName:o$1,entityNamePlural:r,fieldSchema:i$1,readOnly:s,schema:l,setValue:c$1}){let{name:a,label:u,options:d,relationship:f}=i$1,{projectId:m}=useParams(),p=me(),g=d$2(),{relationships:h$1}=c$2(),y=Gn(),v=useId(),b=useId(),x=useRef(null),A=useRef([]),I=useRef(null),N=useRef([]),$=useRef(""),B=useRef(t.knownAssetSortOrders??{}),[T,P]=useState(false),j=useMemo(()=>vm(t.value),[t.value]),[F,U]=useState(j),[X$1,Y]=useState(()=>Object.keys(t.knownAssetSortOrders??zn(j)).length),[L,C]=useState(()=>Math.max(t.count??0,j[0]?.totalCount??0,j.length)),k=useMemo(()=>aa({attributeName:a,entityName:o$1,entityNamePlural:r,schema:l}),[o$1,r,a,l]),[V,{loading:q$1}]=useLazyQuery(gql`
|
|
385
385
|
${k.query}
|
|
386
|
-
`);bn(E,O),useEffect(()=>{let L=Nt(V);A.current=V.map(Y=>Y._id),N.current=[];let G={...t.knownAssetSortOrders??{},...zn(V)};D.current=G,te(Object.keys(G).length),C(Math.max(t.count??0,V[0]?.totalCount??0,V.length)),B(Y=>{let j=Nt(Y);return L===""&&j!==""&&S.current===j||j===L?Y:(S.current=L,V)});},[t.count,t.knownAssetSortOrders,V]),useEffect(()=>{let L=h[b]?.connect;if(!L)return;let G=L.map((x,P)=>el(x.value,x.sortOrder??P)).filter(x=>!!x),Y=Nt(G),j=Nt(R),ee=F.current;ee===j&&Y!==ee||(F.current=null,Y!==j&&B(G));},[b,h,R]),useEffect(()=>{let L=Nt(R);if(S.current===L)return;let G=R.map((ee,x)=>({_id:ee._id,sortOrder:x,value:{...ee,sortOrder:x}})),Y=R.map(ee=>ee._id),j=N.current.filter(ee=>!Y.includes(ee));S.current=L,g$1({type:"setRelationship",payload:{[b]:{connect:G,disconnect:j}}}),c$1(l$1,{...t,knownAssetSortOrders:D.current,relationships:{connect:G,disconnect:j},value:R});},[g$1,t,l$1,b,R,c$1]);let W=Math.max(M,Z),se=!!n$1&&W>Z,oe=useCallback(()=>{if(!n$1||U||!se)return;let L=Z+ym;_({variables:{where:{_id:{eq:n$1}},first:L}}).then(G=>{let Y=G.data?.[r],ee=(Array.isArray(Y)?Y[0]:void 0)?.[`${l$1}Connection`],x=Ao(ee),P=x[0]?.totalCount;if(typeof P=="number"&&C(P),x.length===0){C(Z);return}let H=Object.keys(D.current).length,le={...D.current,...zn(x)},ce=Object.keys(le).length;D.current=le,te(ce),(x.length<L||ce<=H)&&C(ce);for(let Q of x)A.current.includes(Q._id)||(A.current=[...A.current,Q._id]);B(Q=>{let on=new Set(Q.map(lo=>lo._id)),rn=new Set(N.current),Fn=x.filter(lo=>!on.has(lo._id)&&!rn.has(lo._id));if(Fn.length===0)return S.current="",[...Q];let Li=[...Q,...Fn];return F.current=Nt(Li),Li});}).catch(G=>{console.error("Error fetching more assets:",G);});},[n$1,r,_,se,U,Z,l$1]);function J(L){L.preventDefault(),L.stopPropagation(),!s&&d({type:"EditRelationship",payload:{connectedEntitiesCount:Math.max(R.length,W),entityName:m?.entity??"_asset",entityId:n$1,relationshipId:b,mode:"multiple",assetAccept:f$1?.accept}});}async function ae(L){if(L.preventDefault(),L.stopPropagation(),s)return;let G=await v({projectId:p,accept:f$1?.accept??"image/*",multiple:true,maxBytes:4*1024*1024});B(Y=>{let j=new Set(Y.map(P=>P._id)),ee=G.map((P,H)=>({...P.asset,sortOrder:Y.length+H})).filter(P=>!j.has(P._id)),x=Wr([...Y,...ee]);return F.current=Nt(x),x});}function ke(L){B(G=>{let Y=Wr(G.filter(j=>j._id!==L));return A.current.includes(L)&&!N.current.includes(L)&&(N.current=[...N.current,L]),F.current=Nt(Y),Y});}function z(L,G){B(Y=>{let j=Y.findIndex(le=>le._id===L),ee=j+G;if(j<0||ee<0||ee>=Y.length)return Y;let x=[...Y],[P]=x.splice(j,1);if(!P)return Y;x.splice(ee,0,P);let H=Wr(x);return F.current=Nt(H),H});}let q=Math.max(R.length,W),he=R.slice(0,8);return jsx(c,{control:e$1,defaultValue:t,name:l$1,render:()=>jsxs(e,{children:[jsx(f,{htmlFor:y,children:u}),f$1?.comment?jsx(h$1,{children:f$1.comment}):null,jsx(g,{className:"fk:flex fk:flex-col fk:w-full fk:min-h-9.5 fk:text-sm",children:jsx("div",{"aria-controls":`asset-relationship-dropdown-${l$1}`,"aria-expanded":$,className:`fk:relative fk:flex fk:w-full fk:items-start fk:space-x-2 fk:rounded-md fk:border fk:border-input fk:bg-background fk:px-2.5 fk:py-0.5 fk:focus-visible:outline-hidden fk:ring-offset-background fk:focus-visible:ring-2 fk:focus-visible:ring-ring fk:focus-visible:ring-offset-2 ${$?"fk:outline-hidden fk:ring-2 fk:ring-ring fk:ring-offset-2":""}`,onClick:L=>{L.preventDefault(),L.stopPropagation(),E.current?.focus(),O(true);},ref:E,role:"combobox",tabIndex:0,children:jsxs("div",{className:"fk:flex fk:w-full fk:flex-col",children:[jsxs("div",{className:"fk:flex fk:w-full fk:items-center fk:gap-2 fk:pr-9",children:[$&&R.length>0?jsxs("div",{className:"fk:flex fk:h-9 fk:items-center fk:text-muted-foreground",children:[q," ",q===1?"asset":"assets",se?` (${R.length} loaded)`:""," selected"]}):R.length>0?jsxs("div",{className:"fk:flex fk:min-h-9 fk:flex-wrap fk:gap-2",children:[he.map(L=>jsx(vm,{asset:L},L._id)),!$&&q>8?jsxs("div",{className:"fk:flex fk:h-9 fk:w-9 fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted fk:text-xs fk:text-muted-foreground",children:["+",q-8]}):null]}):jsxs("div",{className:"fk:flex fk:h-9 fk:items-center fk:text-muted-foreground",children:[jsx(Image,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Select or upload assets"]}),jsx(a$8,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:absolute fk:right-0.75 fk:top-0.75 fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground",id:y,onClick:L=>{L.preventDefault(),L.stopPropagation(),O(G=>!G);},size:"icon",variant:"ghost",children:$?jsx(X,{className:"fk:h-4 fk:w-4"}):jsx(Maximize2,{className:"fk:h-4 fk:w-4"})})}),jsx(e$3,{children:jsx("p",{children:$?"Close":"Expand field"})})]})})]}),jsx(l,{className:"fk:w-full fk:space-y-2 fk:ml-0!",onOpenChange:O,open:$,children:jsx(n,{className:"fk:w-full",children:jsxs("div",{className:"fk:flex fk:h-[350px] fk:flex-col fk:gap-3",id:`asset-relationship-dropdown-${l$1}`,children:[jsxs("div",{className:"fk:flex fk:gap-2",children:[jsxs(b$3,{className:"fk:h-8",disabled:s,onClick:J,variant:"outline",children:[jsx(Link,{className:"fk:h-4 fk:w-4 fk:mr-2"}),"Select assets"]}),jsxs(b$3,{className:"fk:h-8",disabled:s,onClick:L=>{ae(L);},variant:"outline",children:[jsx(Upload,{className:"fk:h-4 fk:w-4 fk:mr-2"}),"Upload assets"]})]}),R.length>0?jsxs(w,{className:"fk:min-h-0 fk:flex-1",children:[jsx("div",{className:"fk:grid fk:grid-cols-[repeat(auto-fill,minmax(8rem,1fr))] fk:gap-3 fk:pr-3",children:R.map((L,G)=>jsx(bm,{asset:L,index:G,isFirst:G===0,isLast:G===R.length-1,moveAsset:z,readOnly:s,removeAsset:ke},L._id))}),se?jsx("div",{className:"fk:flex fk:justify-center fk:py-3 fk:pr-3",children:jsx(b$3,{className:"fk:h-8",disabled:U,onClick:L=>{L.preventDefault(),L.stopPropagation(),oe();},type:"button",variant:"outline",children:U?"Loading\u2026":`Load more (${Z} of ${W})`})}):null]}):null]})})})]})})}),jsx(i$1,{})]})})}function vm({asset:e}){return tl(e)?jsx("img",{alt:e.originalFilename||"Asset",className:"fk:h-9 fk:w-9 fk:rounded-sm fk:bg-muted fk:object-cover",src:`${b$4}${e.path}?w=128&h=128&f=webp`}):jsx("div",{className:"fk:flex fk:h-9 fk:w-9 fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted",children:jsx(Image,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground"})})}function bm({asset:e,index:t,isFirst:n,isLast:o,moveAsset:r,readOnly:i,removeAsset:s}){return jsxs("div",{className:"fk:relative fk:rounded-md fk:border fk:border-input fk:bg-background fk:p-2",children:[jsx("div",{className:"fk:aspect-square fk:overflow-hidden fk:rounded-sm fk:bg-muted",children:tl(e)?jsx("img",{alt:e.originalFilename||"Asset",className:"fk:h-full fk:w-full fk:object-cover",src:`${b$4}${e.path}?w=320&h=320&f=webp`}):jsx("div",{className:"fk:flex fk:h-full fk:w-full fk:items-center fk:justify-center",children:jsx(Image,{className:"fk:h-8 fk:w-8 fk:text-muted-foreground"})})}),jsxs("div",{className:"fk:mt-2 fk:truncate fk:text-xs",title:e.originalFilename,children:[t+1,". ",e.originalFilename||e.path]}),jsxs("div",{className:"fk:mt-2 fk:flex fk:gap-1",children:[jsx(b$3,{className:"fk:h-7 fk:w-7",disabled:i||n,onClick:()=>r(e._id,-1),size:"icon",type:"button",variant:"ghost",children:jsx(ArrowUp,{className:"fk:h-3.5 fk:w-3.5"})}),jsx(b$3,{className:"fk:h-7 fk:w-7",disabled:i||o,onClick:()=>r(e._id,1),size:"icon",type:"button",variant:"ghost",children:jsx(ArrowDown,{className:"fk:h-3.5 fk:w-3.5"})}),jsx(b$3,{className:"fk:ml-auto fk:h-7 fk:w-7",disabled:i,onClick:()=>s(e._id),size:"icon",type:"button",variant:"ghost",children:jsx(X,{className:"fk:h-3.5 fk:w-3.5"})})]})]})}function Cm(e){return Array.isArray(e)?e.map((t,n)=>el(t,n)).filter(t=>!!t).sort((t,n)=>(t.sortOrder??Number.MAX_SAFE_INTEGER)-(n.sortOrder??Number.MAX_SAFE_INTEGER)):[]}function Nt(e){return e.map((t,n)=>`${t._id}:${t.sortOrder??n}`).join("|")}function Wr(e){return e.map((t,n)=>({...t,sortOrder:n}))}function el(e,t){if(!e||typeof e!="object"||!("_id"in e)||!("path"in e))return null;let n=e;return {_id:String(n._id??""),path:String(n.path??""),originalFilename:String(n.originalFilename??""),size:Number(n.size??0),mimeType:String(n.mimeType??""),lqip:String(n.lqip??""),width:Number(n.width??0),height:Number(n.height??0),sortOrder:n.sortOrder??t,totalCount:typeof n.totalCount=="number"?n.totalCount:void 0}}function tl(e){return !!(e.mimeType&&e.mimeType.startsWith("image/")||/\.(png|jpe?g|gif|webp|avif|svg)$/i.test(e.path))}function ol({value:e}){return !e||!e.split(",").length?null:jsx("div",{className:"fk:flex fk:flex-wrap fk:gap-1 fk:max-w-full truncate",children:e.split(",").map(t=>jsx(b$6,{className:"fk:px-2.5 fk:py-0 fk:font-normal fk:text-[0.6875rem] fk:leading-4",variant:"secondary",children:t},t))})}function zo({column:e,title:t,className:n}){if(!e.getCanSort())return jsx("div",{className:a$1("fk:flex fk:items-center",n),children:t});let o=e.getIsSorted()==="asc",r=e.getIsSorted()==="desc";return jsxs("div",{className:a$1("fk:flex fk:w-full fk:items-center fk:justify-between fk:gap-1",n),children:[jsx("span",{className:"fk:truncate",children:t}),jsxs(c$3,{children:[jsx(e$2,{asChild:true,children:jsx("button",{"aria-label":`Sort ${t}`,className:"fk:inline-flex fk:shrink-0 fk:items-center fk:justify-center fk:rounded-sm fk:p-0.5 fk:text-muted-foreground fk:outline-hidden fk:hover:bg-accent fk:hover:text-accent-foreground fk:focus-visible:ring-1 fk:focus-visible:ring-ring",type:"button",children:jsx(ChevronDown,{className:"fk:h-3.5 fk:w-3.5"})})}),jsxs(f$2,{align:"end",className:"fk:w-44",children:[jsxs(h$2,{"aria-checked":o,className:a$1(o&&"fk:bg-accent fk:text-accent-foreground"),onSelect:()=>{if(o){e.clearSorting();return}e.toggleSorting(false);},role:"menuitemcheckbox",children:[jsx(ArrowUp,{className:a$1("fk:h-4 fk:w-4",o&&"fk:text-white")}),"Sort Ascending"]}),jsxs(h$2,{"aria-checked":r,className:a$1(r&&"fk:bg-accent fk:text-accent-foreground"),onSelect:()=>{if(r){e.clearSorting();return}e.toggleSorting(true);},role:"menuitemcheckbox",children:[jsx(ArrowDown,{className:a$1("fk:h-4 fk:w-4",r&&"fk:text-white")}),"Sort Descending"]})]})]})]})}var Em=new Set(["text","number","datetime","switch","select"]);function Yn({attributesSchema:e,checkboxSelect:t,actionsComponent:n,enableColumnSorting:o=false}){let{getContributionPointConfig:r}=d(),[,i]=b(),s=vn(e,i.user?.spaces),a={datetime:"datetime",editor:"editor",asset:"asset",number:"text",relationship:"text",select:"select",switch:"boolean",text:"text",textarea:"text"},c={boolean:a$b,date:a$a,datetime:a$e,editor:b$7,asset:a$d,number:a$a,relationship:a$a,select:a$c,switch:a$b,text:a$a,textarea:a$a,tags:ol},l=s.map(d=>{if(d.name==="_updatedAt")return null;let g=(d.inputType==="relationship"&&d.relationship?.entity==="_asset"?"asset":void 0)??d.previewType??a[d.inputType],h=r("previewFields",[g])?.[0]?.component??c[g]??c.text;if(d.hidden===true)return null;let v=g==="tags",y=o&&d.scope==="global"&&Em.has(d.inputType);return {accessorKey:d.name,filterFn:(b,E,A)=>v?true:(Array.isArray(A)?A:[A]).includes(b.getValue(E)),header:({column:b})=>y?jsx(zo,{column:b,title:d.label}):jsx("div",{className:"fk:flex fk:items-center",children:d.label}),cell:({row:b})=>{let E=h;return g==="select"?jsx(E,{value:b.getValue(d.name),options:d.options}):g==="assetPreviewField"?jsx(E,{value:b.original}):jsx(E,{value:b.getValue(d.name)})},enableSorting:y,enableHiding:true,meta:{label:d.label},size:d.options?.size??150}}).filter(d=>d!==null),u={id:"actions",cell:({row:d})=>n?n(d):null,size:80},f={accessorKey:"_updatedAt",header:({column:d})=>o?jsx(zo,{column:d,title:"Updated At"}):jsx("div",{className:"fk:flex fk:items-center",children:"Updated At"}),cell:({row:d})=>jsx(a$e,{value:d.getValue("_updatedAt")}),enableSorting:o,enableHiding:false,meta:{label:"Updated At"},size:220},m={id:"select",cell:({row:d,table:g})=>jsx(j$1,{"aria-label":"Select row",checked:d.getIsSelected(),onCheckedChange:h=>{g.toggleAllPageRowsSelected(false),d.toggleSelected(!!h);}}),enableSorting:false,enableHiding:false,size:50},p={id:"select",header:({table:d})=>jsx(j$1,{className:"fk:dark:bg-white/15","aria-label":"Select all",checked:d.getIsAllPageRowsSelected()||d.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:g=>{d.toggleAllPageRowsSelected(!!g);}}),cell:({row:d})=>jsx(j$1,{"aria-label":"Select row",checked:d.getIsSelected(),onCheckedChange:g=>{d.toggleSelected(!!g);}}),enableSorting:false,enableHiding:false,size:50};return [...t==="single"?[m]:[],...t==="multiple"?[p]:[],...n?[u]:[],...l,f]}var Im=36,Lm=15,il=40;function ll(e){if(!e)return;let t=e.split(/\s+/);if(t.includes("fk:h-20"))return 80;if(t.includes("fk:h-10"))return 40;if(t.includes("fk:h-9"))return 36}function Mm(e,t){return e??ll(t)??Im}function _m(e){return Math.max(600,e)}function eo({classNames:e,columns:t$1,data:n,entityName:o$1,hasMore:r=false,initialSelectionState:i,isLoadingMore:s$1=false,onEntitySelectionChange:a,onLoadMore:c,onScroll:l,onSortingChange:u$1,pageSize:f,rowHeightEstimate:m,rowAdditionState:p$1,rowDeletionState:d,scrollToTopKey:g,sorting:h,toolbarComponent:v}){let y=useRef(null),{schemaErrorMessage:b}=Kt(),[E,A]=useState(i??{}),[F,N]=useState({}),[S,D]=useState([]),[$,O]=useState([]),V=h??$;useEffect(()=>{y.current?.scrollTo({top:0});},[o$1,g]),useEffect(()=>{if(!i)return;let z=Object.keys(E).sort().join(","),q=Object.keys(i).sort().join(",");z!==q&&A(i);},[i,E]);function R(z){if(u$1){u$1(z);return}O(z);}let B=useReactTable({data:n,columns:t$1,state:{sorting:V,columnVisibility:F,rowSelection:E,columnFilters:S},initialState:{pagination:{pageSize:f??50}},enableRowSelection:true,onRowSelectionChange:ae,onSortingChange:R,onColumnFiltersChange:D,onColumnVisibilityChange:N,getCoreRowModel:getCoreRowModel(),getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),getSortedRowModel:getSortedRowModel(),getRowId:z=>z._id,manualFiltering:true,manualPagination:true,manualSorting:true,meta:{getRowBackground:z=>Om(z,d,p$1)}}),{rows:Z}=B.getRowModel(),te=Mm(m,e?.row),M=ll(e?.row)!=null,C=useVirtualizer({count:Z.length,estimateSize:()=>te,getItemKey:z=>Z[z]?.id??z,getScrollElement:()=>y.current,overscan:Lm,scrollMargin:il}),k=C.getVirtualItems(),{paddingTop:_,paddingBottom:U}=$m(k,C.getTotalSize(),il),W=useRef(c),se=useRef(r),oe=useRef(s$1);W.current=c,se.current=r,oe.current=s$1;let J=useCallback(z=>{if(!W.current||!se.current||oe.current)return;let q=z??y.current;if(!q)return;let{scrollHeight:he,scrollTop:L,clientHeight:G}=q;he-L-G>=_m(G)||(oe.current=true,W.current());},[]);useEffect(()=>{J();},[J,Z.length,r,s$1]);function ae(z){let q=Object.keys(typeof z=="function"?z(E):z);A(z),a?.(q);}function ke(z){l?.(z),J(z.currentTarget);}return b?jsx(Fragment,{}):jsxs("div",{className:a$1("fk:flex fk:h-full fk:min-h-0 fk:w-full fk:min-w-0 fk:flex-col fk:gap-4",e?.wrapper),children:[v&&v(B),jsx("div",{className:"fk:relative fk:min-h-0 fk:min-w-0 fk:flex-1 fk:-mb-px",children:jsx(a$8,{delayDuration:400,children:jsxs(o,{className:a$1("fk:grid fk:pb-20",e?.table),containerClassName:e?.tableContainer,onScroll:ke,ref:y,children:[jsx(p,{className:"fk:sticky fk:top-0 fk:z-20 fk:grid",children:B.getHeaderGroups().map(z=>jsx(s,{className:"fk:flex fk:w-full",children:z.headers.map(q=>jsxs(t,{className:a$1("fk:flex fk:items-center",q.column.id==="actions"&&"fk:pl-0"),colSpan:q.colSpan,style:q.getSize()?{width:`${q.getSize().toString()}px`}:{},children:[q.isPlaceholder?null:flexRender(q.column.columnDef.header,q.getContext()),s$1?jsx("div",{"aria-hidden":true,className:"fk:pointer-events-none fk:absolute fk:top-10.25 fk:right-px fk:left-px fk:z-20 fk:h-0.5 fk:overflow-hidden fk:opacity-4",children:jsx("div",{className:"fk:animate-progress fk:h-full fk:w-full fk:bg-foreground"})}):null]},q.id))},z.id))}),jsx(q,{className:"fk:grid fk:relative",children:Z.length===0?jsx(s,{children:jsx(u,{className:"fk:h-24 fk:text-center",colSpan:t$1.length,children:"No results."})}):jsxs(Fragment,{children:[_>0?jsx(sl,{height:_}):null,k.map(z=>{let q=Z[z.index];return jsx(s,{className:a$1(B.options.meta.getRowBackground(q),"fk:flex fk:w-full fk:overflow-hidden fk:transition-none",!M&&m==null&&"fk:h-9",e?.row),"data-index":z.index,"data-state":q.getIsSelected()&&"selected",style:{height:`${te.toString()}px`},children:q.getVisibleCells().map(he=>jsx(u,{className:a$1("fk:flex fk:items-center fk:truncate",he.column.id==="actions"&&"fk:pl-1!"),style:{width:he.column.getSize()},children:flexRender(he.column.columnDef.cell,he.getContext())},he.id))},z.key)}),U>0?jsx(sl,{height:U}):null]})})]})})})]})}function $m(e,t,n){if(e.length===0)return {paddingTop:0,paddingBottom:0};let o=e[0]?.start??0,r=e[e.length-1]?.end??0;return {paddingTop:Math.max(0,o-n),paddingBottom:Math.max(0,t-(r-n))}}function sl({height:e}){return jsx("tr",{"aria-hidden":true,className:"fk:pointer-events-none fk:border-0",style:{display:"block",height:`${e.toString()}px`},children:jsx("td",{className:"fk:p-0 fk:border-0"})})}function Om(e,t,n){return t?.includes(e.original._id)?"fk:bg-row-removed fk:hover:bg-row-removed-hover":n?.some(o=>o._id===e.original._id)?"fk:bg-row-added fk:hover:bg-row-added-hover":""}function cl({action:e,row:t}){let n=t.original._id;function o(){e(n);}return jsx("div",{className:"fk:flex fk:items-center",children:jsxs(b$3,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1",onClick:o,variant:"ghost",children:[jsx(Trash2,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Delete"})]})})}var Km=25;function ni({control:e$1,defaultScope:t,defaultValue:n$1,entityId:o,entityName:r,fieldSchema:i,readOnly:s,schema:a,scope:c$1,setValue:l$1}){let[u,f$1]=useState(false),m=useRef(null);bn(m,f$1);let[p,d]=useState([]),{name:g$1,label:h,options:v,relationship:y}=i,b=y?.entity??g$1,E=pe(),A=d$2(),{relationships:F}=c$2(),N=useId(),S=useId(),D=find(propEq(b,"name"))(a),$=D?.attributes??[],V=find(propEq(r,"name"))(a)?.name??"",R,B=$.find(x=>x.relationship?.entity===V);B&&(R=B.name);let Z=e$4(D)?.name??"",te=useMemo(()=>n$1.value?Ym({data:n$1.value,defaultScope:t,relationshipEntitySchema:D,scope:c$1}):[],[t,n$1,Z,D,c$1]),M=la({relatedEntityName:b,scope:c$1,schema:a}),k=p.length?p.slice(0,12).map(x=>x[Z]):[],_=Math.max(p.length,n$1.count??0)>k.length,[U,{loading:W,data:se}]=useLazyQuery(gql`
|
|
387
|
-
${
|
|
388
|
-
`),oe=Yn({attributesSchema:D?.attributes??[],actionsComponent:s?void 0:x=>Zm({appDispatch:A,relationshipId:S,relationships:F,row:x,setRows:d})});useEffect(()=>{d(te),n$1.value!==""&&A({type:"setRelationship",payload:{[S]:{connect:[],disconnect:[]}}});},[A,se,te,S,n$1,c$1]),useEffect(()=>{l$1(g$1,{...n$1,relationships:F[S]});},[n$1,F,S,l$1,g$1]),useEffect(()=>{let P=(F[S]?.connect??[]).map(({value:H})=>H);d(uniqBy(prop("_id"),[...P,...te]));},[se,n$1.count,te,F,S]);let J=F[S]?.connect??[],ae=F[S]?.disconnect??[],ke=new Set(te.map(x=>x._id)),z=new Set(ae),q=J.filter(x=>!ke.has(x._id)||z.has(x._id)).length,he=ae.length,L=n$1.count??0,G=Math.max(0,Math.max(L,te.length)+q-he),Y=L>0&&p.length>0&&p.length<L,j=useCallback(()=>{W||U({variables:{limit:Km,offset:p.length,where:R?{[R]:{some:{_id:{eq:o}}}}:{}}}).then(({data:x})=>{if(!x)return;let P=To(D?.plural??"",c$1,x,a);d(uniqBy(prop("_id"),[...te,...P.results]));}).catch(x=>{console.error("Error fetching more data:",x);});},[R,o,U,te,W,D?.plural,p.length,a,c$1]);function ee(x){x.preventDefault(),!s&&E({type:"EditRelationship",payload:{connectedEntitiesCount:te.length,connectionName:R,entityName:b,entityId:o,relationshipId:S,mode:y?.mode??"multiple"}});}return jsx(c,{control:e$1,defaultValue:n$1,name:g$1,render:()=>jsxs(e,{className:"fk:min-w-0",children:[jsx(f,{htmlFor:N,children:h}),v?.comment?jsx(h$1,{children:v.comment}):null,jsx(g,{className:"fk:flex fk:flex-col fk:w-full fk:min-w-0 fk:min-h-9.5 fk:pl-3 fk:pr-3 fk:py-0.5 fk:text-sm",children:jsx("div",{"aria-controls":`relationship-dropdown-${g$1}`,"aria-expanded":u,className:`fk:relative fk:flex fk:w-full fk:min-w-0 fk:items-start fk:space-x-2 fk:rounded-md fk:border fk:border-input fk:bg-background fk:focus-visible:outline-hidden fk:ring-offset-background fk:focus-visible:ring-2 fk:focus-visible:ring-ring fk:focus-visible:ring-offset-2 ${u?"fk:outline-hidden fk:ring-2 fk:ring-ring fk:ring-offset-2":""}`,onClick:x=>{x.preventDefault(),x.stopPropagation(),m.current?.focus(),m.current?.click(),f$1(true);},onKeyDown:x=>{x.key==="Enter"&&f$1(true),x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),m.current?.blur(),f$1(false));},ref:m,role:"combobox",tabIndex:0,children:jsxs("div",{className:"fk:flex fk:w-full fk:min-w-0 fk:flex-col",children:[jsxs("div",{className:"fk:flex fk:w-full fk:min-w-0 fk:items-start fk:gap-2",children:[u?jsxs(b$3,{className:"fk:h-8 fk:mr-auto fk:mt-[0.1875rem]",disabled:s,onClick:ee,variant:"outline",children:[jsx(Link,{className:"fk:h-4 fk:w-4 fk:mr-2"})," Link to a record from"," ",D?.menu?.label??D?.plural]}):jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-wrap fk:grow fk:overflow-hidden fk:pb-1.5",children:[k.map(x=>jsx(b$6,{className:"fk:mr-2 fk:mt-1.5 fk:max-w-60 fk:justify-start fk:rounded-xs",title:x,variant:"secondary",children:jsx("span",{className:"fk:min-w-0 fk:truncate",children:x})},x)),_?jsx(b$6,{className:"fk:mr-2 fk:mt-1.5 fk:rounded-xs",variant:"secondary",children:"\u2026"}):null]}),jsxs("div",{className:"fk:mt-[0.1875rem] fk:ml-auto fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[u?jsxs("span",{className:"fk:text-sm fk:font-normal fk:text-muted-foreground",children:[G.toLocaleString()," ",G===1?"record":"records"]}):null,u?jsx(a$8,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground",onClick:x=>{x.preventDefault(),x.stopPropagation(),m.current?.blur(),f$1(false);},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),x.stopPropagation(),m.current?.blur(),f$1(false));},size:"icon",variant:"ghost",children:jsx(X,{className:"fk:h-4 fk:w-4"})})}),jsx(e$3,{children:jsx("p",{children:"Close"})})]})}):jsx(a$8,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground",id:N,onKeyDown:x=>{x.key==="Enter"&&(m.current?.focus(),m.current?.click());},size:"icon",variant:"ghost",children:jsx(Maximize2,{className:"fk:h-4 fk:w-4"})})}),jsx(e$3,{children:jsx("p",{children:"Expand field"})})]})})]})]}),jsx(l,{className:"fk:w-full fk:min-w-0 fk:space-y-2 fk:ml-0!",onOpenChange:f$1,open:u,children:jsx(n,{className:"fk:w-full fk:min-w-0",children:jsx("div",{className:"fk:mt-3 fk:mb-2 fk:w-full fk:min-w-0",id:`relationship-dropdown-${g$1}`,children:jsx(eo,{classNames:{wrapper:"fk:h-[17.5rem] fk:min-h-0 fk:min-w-0 fk:gap-0",table:"fk:pb-0"},columns:oe,data:p,entityName:r,hasMore:Y,isLoadingMore:W&&p.length>0,onLoadMore:j,rowAdditionState:F[S]?.connect,rowDeletionState:F[S]?.disconnect})})})})]})})}),jsx(i$1,{})]})})}function Zm({appDispatch:e,relationshipId:t,relationships:n,row:o,setRows:r}){function i(s){let a=n[t]?.connect??[],c=typeof find(propEq(s,"_id"),a)=="object",l=n[t]?.disconnect?.includes(s),u=c?n[t]?.disconnect??[]:uniq([...n[t]?.disconnect??[],s]);c&&r(f=>f.filter(m=>m._id!==s)),e({type:"setRelationship",payload:{[t]:{connect:a.filter(f=>f._id!==s),disconnect:l?n[t]?.disconnect?.filter(f=>f!==s)??[]:u}}});}return jsx(cl,{action:i,row:o})}function Ym({data:e,defaultScope:t,relationshipEntitySchema:n,scope:o}){if(!Array.isArray(e))return [];let r=i=>{let a=find(propEq(i.__typename,"name"))(n?.attributes??[])?.relationship?.field??"";if(a){let c=i[a],l=Array.isArray(c)?c[0]:c;return l&&typeof l=="object"?l[o]??l[t]??"":l}return i[o]??i[t]};return e.map(i=>map(s=>{if(Array.isArray(s)){let a=s;return a.length===0?"":a.length===1?r(a[0]):a.slice(0,3).map(r).join(", ")}return s&&typeof s!="string"&&s.__typename?r(s):s},i))}function oi({control:e$1,defaultScope:t,defaultValue:n,entityId:o,fieldSchema:r,getValues:i,readOnly:s,schema:a,scope:c$1,setValue:l}){let[u,f$1]=useState(false),{name:m,label:p,options:d,relationship:g$1}=r,h=g$1?.entity??m,v=pe(),y=d$2(),b=useId(),{relationships:E}=c$2(),A=useId(),F=find(propEq(h,"name"))(a),N=e$4(F)?.name;useEffect(()=>{let $=n.value;if($===""||typeof $=="boolean"||typeof $=="number")return;let O={_id:String(n._id),value:$},V={type:"setRelationship",payload:{[A]:{connect:O,disconnect:[]}}};y(V);},[y,A,n,c$1]),useEffect(()=>{l(m,{...i(m),...E[A]?.connect??""});},[n,m,E,A,l]);function S($){$.preventDefault(),!s&&v({type:"EditRelationship",payload:{connectedEntitiesCount:0,entityName:h,entityId:o,relationshipId:A,mode:g$1?.mode??"single"}});}function D($){if(s)return;let O={type:"setRelationship",payload:{[A]:{connect:[],disconnect:[]}}};$.preventDefault(),y(O),l(m,{...i(m),_id:"",value:void 0});}return jsx(c,{control:e$1,defaultValue:n,name:m,render:({field:$})=>{let O=$.value?.value,V="";if(N&&O&&typeof O=="object"&&!Array.isArray(O)&&O[N]){let R=O[N],B=Array.isArray(R)?R[0]:R;typeof B=="string"?V=B:V=B?.[c$1]??B?.[t]??"";}return jsxs(e,{children:[jsx(f,{htmlFor:b,children:p}),d?.comment?jsx(h$1,{children:d.comment}):null,jsx(g,{className:"fk:flex fk:w-full fk:items-center fk:space-x-2",children:jsxs("div",{className:`fk:relative fk:flex fk:w-full fk:items-start fk:space-x-2 fk:rounded-md fk:border fk:border-input fk:bg-background fk:ring-offset-background ${u?"fk:outline-hidden fk:ring-2 fk:ring-ring fk:ring-offset-2":""}`,children:[jsx(a$7,{className:"fk:h-9.5 fk:py-1.75 fk:caret-transparent fk:border-0 fk:focus-visible:ring-0 fk:focus-visible:ring-offset-0",disabled:s,id:b,onBlur:()=>{f$1(false);},onClick:S,onFocus:()=>{f$1(true);},onKeyDown:R=>{R.key==="Enter"&&S(R);},readOnly:true,type:"text",value:V}),V?jsx(a$8,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:absolute fk:right-10 fk:top-0.75 fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground",disabled:s,onClick:D,size:"icon",variant:"ghost",children:jsx(X,{className:"fk:h-4 fk:w-4"})})}),jsx(e$3,{children:jsx("p",{children:"Clear"})})]})}):null,jsx(a$8,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:absolute fk:right-0.75 fk:top-0.75 fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground",disabled:s,onClick:S,size:"icon",variant:"ghost",children:jsx(ChevronsUpDown,{className:"fk:h-4 fk:w-4"})})}),jsx(e$3,{children:jsx("p",{children:"Open"})})]})})]})}),jsx(i$1,{})]})}})}function ri(e){let{fieldSchema:t}=e,{relationship:n}=t;if(n?.mode==="single")return jsx(oi,{...e});if(n?.mode==="multiple"){if(n.entity==="_asset")return jsx(Zr,{...e});let o={relationshipEntityName:t.relationship?.entity,...e};return jsx(ni,{...o})}return jsxs(ye,{variant:"destructive",children:[jsx(AlertTriangle,{className:"h-4 w-4"}),jsx(qe,{children:"Error"}),jsx(ve,{children:'Incorrect "mode" for relationship field. It should be "single" or "multiple". Please check the schema configuration.'})]})}var kl="flexkit-select-option:";function ii(e){return `${kl}${encodeURIComponent(e)}`}function ap(e){return decodeURIComponent(e.slice(kl.length))}function hl({control:e$2,fieldSchema:t,readOnly:n,setValue:o}){let{name:r,label:i,options:s}=t;function a(l,u){let m=t.dataType==="int"&&!isNaN(Number(l))?Number(l):l;o(r,{...u,value:m});}function c$2(l,u){o(r,{...u,disabled:l});}return jsx(c,{control:e$2,name:r,render:({field:l})=>jsxs(e,{children:[jsx(f,{children:i}),s?.comment?jsx(h$1,{children:s.comment}):null,jsxs(a$5,{defaultValue:l.value?.value===void 0||l.value.value===null?void 0:ii(String(l.value.value)),disabled:n||l.value?.disabled,onValueChange:u=>{a(ap(u),l.value);},children:[jsx(g,{children:jsx(d$1,{children:jsx(c$1,{placeholder:s?.placeholder})})}),jsx(e$1,{children:s?.list?.map(u=>"groupLabel"in u?jsxs(b$2,{children:[jsx(f$1,{children:u.groupLabel}),u.items.map(f=>jsx(g$1,{value:ii(f.value),children:f.label},f.label))]},u.groupLabel):jsx(g$1,{value:ii(u.value),children:u.label},u.label))})]}),jsx(a$6,{checked:l.value?.disabled??false,disabled:n,onChange:u=>{c$2(u,l.value);},scope:l.value?.scope}),jsx(i$1,{})]})})}function li({inputType:e,label:t}){return jsxs(ye,{variant:"destructive",children:[jsx(AlertTriangle,{className:"h-4 w-4"}),jsx(qe,{children:"Error"}),jsx(ve,{children:`Incorrect inputType: "${e}" for the "${t}" attribute. Please check the schema configuration.`})]})}var tn="all",ci={name:"all",title:"All fields"};function up(e){return typeof e.group=="string"?[e.group]:Array.isArray(e.group)?e.group:[]}function ui(e,t){return t==="all"?true:up(e).includes(t)}function fi(e,t){return t.length===0?true:t.some(n=>ui(e,n.name))}function di(e,t){if(!e||e.length===0)return [];let n=e.find(s=>s.name==="all"),o=e.filter(s=>s.name!=="all");return [{...ci,...n},...o].filter(s=>!St(s.hidden,t))}function mi(e){let t=e.find(o=>o.default);if(t)return t.name;let n=e.find(o=>o.name!=="all");return n?n.name:"all"}function wp(e,t){let n=e.dataType==="asset"||e.scope==="relationship"?"":e.defaultValue??"";return {disabled:false,scope:t,value:n}}function xp({currentScope:e,defaultScope:t,entityId:n,entityName:o,entityNamePlural:r,formData:i$1,schema:s,setIsDirty:a,onSubmit:c},l){let u=find(propEq(o,"name"))(s),[,f]=b(),m=f.user?.spaces,p=useMemo(()=>vn(u?.attributes??[],m),[u,m]),d$1=useMemo(()=>i$1||p.reduce((M,C)=>({...M,[C.name]:wp(C,t)}),{}),[t,i$1,p]),h$1=useForm({defaultValues:d$1,resolver:async(M,C,k)=>{let _=Vn(M),U=di(u?.groups,{record:_,value:_,currentUser:f.user}),W={};for(let oe of p){if(typeof oe.validation>"u")continue;let J={record:_,value:_[oe.name],currentUser:f.user};St(oe.hidden,J)||St(oe.readOnly,J)||fi(oe,U)&&(W[oe.name]=z.object({value:oe.validation(z).or(z.any().refine(()=>false,{error:oe.label?`${oe.label} is required`:"Required field"}))}));}return zodResolver(z.object(W))(M,C,k)},values:i$1,mode:"onBlur",criteriaMode:"all"}),{control:v,getValues:y,handleSubmit:b$2,setValue:E,watch:A,trigger:F}=h$1,N=A(),S=Vn(N),D=useMemo(()=>di(u?.groups,{record:S,value:S,currentUser:f.user}),[f.user,u?.groups,S]),[$,O]=useState(()=>mi(D)),{getContributionPointConfig:V}=d(),R=useRef(i$1),B=useRef(false);useEffect(()=>{B.current||(R.current=i$1);},[i$1]);let Z={datetime:Pa,editor:Qr,asset:Na,number:Da,relationship:ri,select:hl,switch:a$4,text:a$3,textarea:a$2};if(useImperativeHandle(l,()=>({submit(){F().then(()=>{b$2(()=>{let M=y();B.current=true,R.current=M,a(false),c(M,i$1);})();});},hasErrors(){B.current=false,R.current=i$1,a(true);},hasDataChanged(){return vl(y(),R.current)},markAsSaved(){B.current=true,R.current=y(),a(false);},applyLocalAttributeIds(M){let C=y(),k={...C};for(let[_,U]of Object.entries(M)){let W=C[_];!W||W._id||!U||(k[_]={...W,_id:U});}B.current=true,R.current=k;for(let[_,U]of Object.entries(k))U!==C[_]&&E(_,U,{shouldDirty:false,shouldTouch:false,shouldValidate:false});a(false);}})),useEffect(()=>{let M=A(()=>{a(vl(y(),R.current));});return ()=>{M.unsubscribe();}},[i$1,y,a,A]),useEffect(()=>{D.length!==0&&(D.some(M=>M.name===$)||O(mi(D)));},[$,D]),!u||u.attributes.length===0)return jsxs(ye,{variant:"destructive",children:[jsx(AlertTriangle,{className:"fk:h-4 fk:w-4"}),jsx(qe,{children:"Error"}),jsxs(ve,{children:["No attributes found in the schema for entity ",jsx("strong",{children:o})]})]});let te=M=>{if(M.name==="_id")return null;let C={record:S,value:S[M.name],currentUser:f.user};if(St(M.hidden,C))return null;let k=St(M.readOnly,C),_=V("formFields",[M.inputType])?.[0]?.component??Z[M.inputType];return _?createElement(_,{key:M.name,control:v,defaultScope:t,defaultValue:d$1[M.name],entityId:n,entityName:o,entityNamePlural:r,fieldSchema:M,getValues:y,readOnly:k,schema:s,scope:e,setValue:E}):jsx(li,{inputType:M.inputType,label:M.label},M.name)};return jsx(b$1,{...h$1,children:jsx("form",{className:"fk:flex fk:flex-col fk:gap-5",onSubmit:M=>{M.preventDefault();},children:D.length>0?jsxs(h,{onValueChange:O,value:$,children:[jsx("div",{className:"fk:sticky fk:top-0 fk:z-10 fk:bg-background fk:py-1 fk:mb-6",children:jsxs(w,{className:"fk:w-full fk:**:data-[slot=scroll-area-viewport]:h-auto fk:[&_[data-slot=scroll-area-scrollbar][data-orientation=vertical]]:hidden",children:[jsx(i,{className:"fk:h-9 fk:w-max fk:flex-nowrap fk:justify-start fk:border fk:border-border",children:D.map(M=>jsxs(j,{className:"fk:shrink-0 fk:px-4 fk:dark:data-[state=active]:border-transparent! fk:dark:data-[state=active]:bg-background",value:M.name,children:[M.icon,M.title]},M.name))}),jsx(x,{orientation:"horizontal"})]})}),jsx(k,{className:"fk:gap-8",value:$,children:p.map(M=>{if(!fi(M,D))return null;let C=ui(M,$),k=te(M);return k?jsx("div",{className:C?void 0:"fk:hidden",children:k},M.name):null})})]}):p.map(M=>te(M))})})}var Xo=memo(forwardRef(xp));function vl(e,t){if(!t)return Object.keys(e).some(s=>e[s]?.value!==""&&e[s]?.value!==void 0);let n=s=>typeof s=="object"&&s!==null?"path"in s?s.path:"_id"in s?s._id:"":s??"",o=(s,a)=>s<a?-1:1,r=Object.keys(t).sort((s,a)=>o(s,a)).filter(s=>s!=="_updatedAt").reduce((s,a)=>({...s,[a]:{value:n(t[a].value),disabled:t[a].disabled,relationships:t[a].relationships}}),{}),i=Object.keys(e).sort((s,a)=>o(s,a)).filter(s=>s!=="_updatedAt").reduce((s,a)=>({...s,[a]:{value:n(e[a]?.value),disabled:e[a]?.disabled??false,relationships:Object.keys(e[a]?.relationships?.connect??{}).length||e[a]?.relationships?.disconnect?.length?e[a]?.relationships:void 0}}),{});return !equals(r,i)}function bl(e){return e?e!=="viewer":true}function Ft(){let[,e]=b();return bl(e.user?.role)}function hi({action:e,depth:t,isFocused:n}){let{entityName:o}=e.payload,r=useRef(null),i=Ft(),[,s]=b(),{projects:a,currentProjectId:c}=d(),{schema:l,scopes:u}=find(propEq(c??"","projectId"))(a),f=u?.find(R=>R.isDefault)?.name??"default",p=find(propEq(o,"name"))(l)?.plural??o,{scope:d$1}=c$2(),g=pe(),h=useApolloClient(),[v,y,b$1,E]=xt(),{isDirty:A,setIsDirty:F}=yn(),[N,S]=useState(false);useEffect(()=>{E.error&&r.current?.hasErrors();},[E.error]);function D(){return A?(g({type:"AlertDialog",_id:"unsavedChanges",payload:{options:{dialogTitle:"Unsaved Changes",dialogMessage:"Are you sure you want to leave? There are unsaved changes. If you leave, your changes will be lost.",dialogCancelTitle:"Stay Here",dialogActionLabel:"Discard Changes",dialogActionCancel:()=>{g({type:"Dismiss",_id:"unsavedChanges",payload:{}});},dialogActionSubmit:()=>{F(false),g({type:"Dismiss",_id:"unsavedChanges",payload:{}}),S(true);}}}}),false):true}let $=useCallback(R=>{g({type:"Dismiss",_id:R,payload:{}});},[g]),O=useCallback(()=>{r.current?.submit();},[r]),V=useCallback(R=>{let B=v4(),Z=Nr(p,l,R,B,{currentUser:s.user});y(gql`
|
|
389
|
-
${
|
|
390
|
-
`),b$1({onCompleted:()=>{At(h,Ke(
|
|
391
|
-
${
|
|
392
|
-
`,[N.query]),D=jn(e,n,t,{selection:i,includeCount:false}),$=useMemo(()=>gql`
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
`),A({variables:{where:{_id:{eq:o}}},onCompleted:z=>{i.current?.applyLocalAttributeIds(ua(z,r,c)),At(y,Ke(r,c)),toast.success("Your changes have been saved.");}}),b$1(true);},[y,O.user,d$3,o,r,b$1,c,E,A]),_=C,U=_.length>0,W=M&&!U;function se(J,ae){let ke=e$4(J),z=ke?.name,q=ke?.relationship?.field!==void 0;if(!ae.length||!z)return "";if(!q||!ke?.relationship?.field)return ae[0][z]?.value;let he=ae[0][z]?.value?.[ke.relationship.field],L=Array.isArray(he)?he[0]:he;if(L&&typeof L=="object"){let G=L;return G[d$3]??G.default??""}return L??""}let oe=U&&f?se(f,_):"";return jsx(g$3,{actions:jsxs(Fragment,{children:[l&&l.length>1?jsxs(a$5,{onValueChange:J=>{te(J);},value:d$3,children:[jsxs(d$1,{className:"fk:w-[12rem] fk:h-9",id:"project",children:[jsx("span",{className:"fk:text-muted-foreground",children:"Scope:\xA0"}),jsx(c$1,{children:find(propEq(d$3,"name"))(l).label})]}),jsx(e$1,{children:l.map(J=>jsx(g$1,{value:J.name,children:J.label},J.name))})]}):null,jsx(bi,{handleSave:Z,isLoading:F.loading})]}),beforeClose:R,depth:t,forceClose:D,isFocused:n,onClose:()=>{B(e._id);},onFormChange:()=>{},title:oe,children:W||!U?jsx(Ci,{}):jsxs(Fragment,{children:[F.isProjectReadOnly?jsx(Tl,{}):null,jsx(Xo,{currentScope:d$3,defaultScope:u,entityId:o,entityName:m,entityNamePlural:r,formData:_[0],onSubmit:k,ref:i,schema:c,setIsDirty:V})]})})}var Ml=25;function Kp(e){return e.map(t=>({...t,cell:()=>jsx(r$1,{className:"fk:h-4 fk:w-full",style:{marginTop:"7px",marginBottom:"6px"}})}))}function Ti({action:e,depth:t,isFocused:n}){let o=pe(),r=d$2(),{relationships:i,scope:s}=c$2(),{assetAccept:a,connectedEntitiesCount:c,connectionName:l,entityId:u,entityName:f,initialAssetPath:m,initialConnection:p,mode:d$1,relationshipId:g}=e.payload,{projects:h,currentProjectId:v}=d(),{schema:y}=find(propEq(v??"","projectId"))(h),b=find(propEq(f,"name"))(y),E=b?.plural??"",A=i[g],F=Gn(),N=f==="_asset",S=N?"asset":b?.menu?.label??f.toLowerCase(),D=N&&d$1==="single"?"Select asset":`Select ${N?"assets":S}`,$=d$1==="single"?"Upload asset":"Upload assets",[O,V]=useState([]),R=[];if(p)R=[{id:p._id,value:p.value}];else if(A?.connect){let P=A.connect;R=[{id:P._id,value:P.value}];}let B=d$1==="single"?R:A?.connect?.map(P=>({id:P._id,value:P.value}))||[],[Z,te]=useState(B),M=useMemo(()=>{let P=[];return N&&P.push({NOT:{path:{eq:null}}}),d$1==="multiple"&&l&&u&&P.push({[l]:{none:{_id:{eq:u}}}}),O.length>0&&P.push({OR:O.map(H=>({_id:{eq:H._id}}))}),P.length===0?{}:P.length===1?P[0]:{AND:P}},[l,u,N,d$1,O]),{count:C,data:k,fetchMore:_,isLoading:U,isLoadingMore:W}=ro({entityNamePlural:E,schema:y,scope:s,variables:{offset:0,limit:Ml,where:M,sort:[{_updatedAt:"DESC"},{_id:"DESC"}]},selection:"list"}),se=!!k?.length,oe=U&&!se,J=k?.length??0,ae=C-c,ke=ae>0&&J>0&&J<ae,z=Yn({attributesSchema:b?.attributes??[],checkboxSelect:d$1}),q=Array(5).fill({}),he=Kp(z);useEffect(()=>{if(d$1!=="single"||Z.length>0||!m||!k?.length)return;let P=k.find(H=>H.path===m);!P?._id||typeof P._id!="string"||te([{id:P._id,value:P}]);},[k,m,d$1,Z.length]);let L=useCallback(P=>{o({type:"Dismiss",_id:P,payload:{}});},[o]),G=useCallback(()=>{_({variables:{offset:0,limit:Ml,where:M}});},[M,_]);function Y(){let P;if(d$1==="single"){let[H]=Z;P={_id:H?.id??"",value:H?.value??null};}d$1==="multiple"&&(P=Z?.map((H,le)=>({_id:H.id??"",...N?{sortOrder:le}:{},value:H.value}))),r({type:"setRelationship",payload:{[g]:{connect:P,disconnect:A?.disconnect??[]}}}),L(e._id);}function j(P){if(d$1==="multiple"){te(le=>{let ce=new Map(le.map(Q=>[Q.id,Q]));return P.map(Q=>{if(ce.has(Q))return ce.get(Q);let on=k?.find(rn=>rn._id===Q);return {id:Q,value:on}})});return}let H=P[P.length-1];te(H?le=>{if(le.length===1&&le[0].id===H)return le;let ce=k?.find(Q=>Q._id===H);return [{id:H,value:ce}]}:[]);}function ee(){o({type:"AddEntity",payload:{entityName:f}});}async function x(){let P=await F({projectId:v,accept:a??"image/*",multiple:d$1==="multiple",maxBytes:4194304});te(H=>{if(d$1==="single"){let[Q]=P;return Q?[{id:Q._id,value:Q.asset}]:H}let le=new Set(H.map(Q=>Q.id)),ce=P.filter(Q=>!le.has(Q._id)).map(Q=>({id:Q._id,value:Q.asset}));return [...H,...ce]});}return jsx(g$3,{actions:jsxs(Fragment,{children:[jsx(b$3,{className:"fk:px-8",onClick:()=>{Y();},variant:"default",children:"Select"}),N?null:jsx(b$3,{className:"fk:px-8",onClick:()=>{ee();},variant:"outline",children:`Create ${S}`}),N?jsxs(b$3,{className:"fk:px-8",onClick:()=>{x();},variant:"outline",children:[jsx(Upload,{className:"fk:mr-2 fk:h-4 fk:w-4"}),$]}):null]}),depth:t,isFocused:n,onClose:()=>{L(e._id);},title:D,children:jsx("div",{className:"fk:h-[calc(100vh-10rem)] fk:min-h-0",children:jsx(eo,{columns:oe?he:z,data:oe?q:k??[],entityName:b?.name??"",hasMore:ke,initialSelectionState:Z?.reduce((P,H)=>({...P,...H.id?{[H.id]:true}:{}}),{}),isLoadingMore:W,onEntitySelectionChange:j,onLoadMore:G,toolbarComponent:()=>jsx(Zp,{entityNamePlural:E,projectId:v??"",setSearchResultIds:V})})})})}function Zp({entityNamePlural:e,projectId:t,setSearchResultIds:n}){let[o,r]=useState(""),i=useMemo(()=>({searchRequests:{searches:[{collection:e}]},commonParams:{q:""}}),[e]),[s,a]=useState(i),{results:c,isLoading:l}=f$4(t,s),u=useRef(null),f=useMemo(()=>Yp(p=>{a({...i,commonParams:{q:p}});},300),[i]);useEffect(()=>{if(c){let p=JSON.stringify(c.map(g=>g._id).sort()),d=u.current?JSON.stringify(u.current.map(g=>g._id).sort()):"";p!==d&&(u.current=[...c],n(c.map(g=>({_id:g._id}))));}},[c,n]);function m(p){let{value:d}=p.target;r(d),f(d);}return jsxs("div",{className:"fk:relative fk:w-full",children:[l?jsx(LoaderCircle,{className:"fk:absolute fk:left-4 fk:top-3 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50 fk:animate-spin"}):jsx(Search,{className:"fk:absolute fk:left-4 fk:top-3 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50"}),jsx(a$7,{className:"fk:w-full fk:pl-11!",onChange:m,placeholder:"Search",value:o})]})}function Yp(e,t=300){let n;return (...o)=>{clearTimeout(n),n=setTimeout(()=>e(...o),t);}}function $l(){let e=Ws(),t=e.filter(o=>["AddEntity","EditEntity","EditRelationship"].some(r=>r===o.type)),n=t[t.length-1]?._id;return jsx(Fragment,{children:e.map(o=>{switch(o.type){case "AlertDialog":{let{payload:r}=o;return jsx(_n,{options:r.options},o._id)}case "DeleteEntity":return jsx(Ir,{action:o},o._id);case "AddEntity":return jsx(hi,{action:o,depth:t.length-1,isFocused:o._id===n},o._id);case "EditEntity":return jsx(Si,{action:o,depth:t.length-1,isFocused:o._id===n},o._id);case "EditRelationship":return jsx(Ti,{action:o,depth:t.length-1,isFocused:o._id===n},o._id);default:return null}})})}function Ol({config:e}){let[t]=e,{basePath:n,projectId:o}=t,r=a$g(n);return window.location.pathname===r&&(window.location.href=b$a(r,o)),jsx(a$j,{children:jsx(c$7,{config:e,children:jsxs(Ms,{children:[jsx(ya,{children:jsx($l,{})}),jsx(Outlet,{})]})})})}function Vl(){let e=useRouteError(),t=new Date().getFullYear();function n(){return isRouteErrorResponse(e)?e.status===404?jsxs(Fragment,{children:[jsx("h1",{className:"fk:mb-4 fk:text-7xl fk:text-center fk:font-bold fk:tracking-tight",children:"404"}),jsx("p",{className:"fk:mt-2 fk:mb-2 fk:text-base fk:text-center fk:text-muted-foreground",children:"Page not found"})]}):jsxs(Fragment,{children:[jsx("h1",{className:"fk:mb-4 fk:text-4xl fk:text-center fk:font-bold fk:tracking-tight",children:"Oops!"}),jsx("p",{className:"fk:mt-2 fk:mb-2 fk:text-base fk:text-center fk:text-muted-foreground",children:"Sorry, an unexpected error has occurred:"}),jsx("p",{className:"fk:text-base fk:text-center",children:jsx("i",{children:e.statusText})})]}):dr(e)?gs(e)==="PROJECT_NOT_FOUND"?jsxs(Fragment,{children:[jsx("h1",{className:"fk:mb-4 fk:text-4xl fk:text-center fk:font-bold fk:tracking-tight",children:"Project not found"}),jsx("p",{className:"fk:mt-2 fk:mb-2 fk:text-base fk:text-center fk:text-muted-foreground",children:"The requested project ID was not found"})]}):jsxs(Fragment,{children:[jsx("h1",{className:"fk:mb-4 fk:text-4xl fk:text-center fk:font-bold fk:tracking-tight",children:"Oops!"}),jsx("p",{className:"fk:mt-2 fk:mb-2 fk:text-base fk:text-center fk:text-muted-foreground",children:"Sorry, an unexpected error has occurred. Please try again."})]}):e instanceof Error?jsxs(Fragment,{children:[jsx("h1",{className:"fk:mb-4 fk:text-4xl fk:text-center fk:font-bold fk:tracking-tight",children:"Oops!"}),jsx("p",{className:"fk:mt-2 fk:mb-2 fk:text-base fk:text-center fk:text-muted-foreground",children:"Sorry, an unexpected error has occurred:"}),jsx("p",{className:"fk:text-base fk:text-center",children:jsx("i",{children:e.message})})]}):null}return jsxs(Fragment,{children:[jsx("div",{className:"fk:container fk:relative fk:h-[calc(100vh-3rem)] fk:flex fk:items-center fk:justify-center fk:lg:px-0",children:jsx("div",{className:"fk:w-full fk:lg:p-8",children:jsx("div",{className:"fk:mx-auto fk:flex fk:w-full fk:flex-col fk:justify-center fk:sm:w-[350px]",children:n()})})}),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 fk:dark: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 ",t]})]}),jsx(ho,{})]})})]})}function Di(){let e=useRouteError(),t=e instanceof Error?e.message:"An unexpected error has occurred. Please try refreshing the page.";return jsxs(ye,{variant:"destructive",children:[jsx(AlertCircle,{className:"fk:h-4 fk:w-4"}),jsx(qe,{children:"Error"}),jsx(ve,{children:t})]})}var pg=RouterProvider;function gg({config:e}){let[t,n]=useState(false),o=debug("core:flexkit-studio"),r=Array.isArray(e)?e.map(u=>Bl(u)):[Bl(e)],[i]=r,s=a$g(i?.basePath),a=e$5(r);if(useEffect(()=>{n(true);},[]),!t)return null;let c=[{path:s,element:jsx(Ol,{config:r}),errorElement:jsx(Vl,{}),children:[{path:":projectId",element:jsx(Es,{version:{current:"1.0.0",latest:"1.0.0",isCurrent:true}}),children:a.map(u=>({path:u.name,element:u.component,errorElement:jsx(Di,{}),children:u.routes?.map(f=>({path:f.path,element:f.component,errorElement:jsx(Di,{}),children:f.children?.map(m=>({path:m.path,element:m.component}))}))}))}]}],l=createBrowserRouter(c);return o("Init Studio"),jsx(a$h,{attribute:"class",defaultTheme:"system",disableTransitionOnChange:true,enableSystem:true,children:jsx(b$9,{children:jsx(Xs,{children:jsx(pg,{router:l})})})})}function Bl(e){return {basePath:a$g(e.basePath),menuGroups:e.menuGroups??[],icon:e.icon,extensions:e.extensions,projectId:e.projectId,title:e.title,schema:e.schema,scopes:e.scopes}}function hg(){return jsxs(ye,{variant:"destructive",children:[jsx(AlertCircle,{className:"fk:h-4 fk:w-4"}),jsx(qe,{children:"Project Paused"}),jsxs(ve,{children:["This project has been paused. To troubleshoot this error, please"," ",jsx("a",{className:"fk:text-blue-500 fk:underline",href:"https://flexkit.io/docs/errors/project-paused",target:"_blank",rel:"noopener noreferrer",children:"follow these steps"}),"."]})]})}function vg(){let{schemaErrorMessage:e}=Kt();if(!e)return jsx(Fragment,{});let[t,n,...o]=e.split(`
|
|
397
|
-
`);return jsxs(ye,{className:"fk:mb-4",variant:"destructive",children:[jsx(AlertCircle,{className:"fk:h-4 fk:w-4"}),jsx(qe,{children:"Schema mismatch"}),jsxs(ve,{children:[jsx("p",{children:t}),n?jsx("p",{className:"fk:mt-1",children:n}):null,o.length>0?jsx("ul",{className:"fk:mt-2 fk:list-disc fk:pl-4",children:o.map(r=>jsx("li",{children:r.replace(/^- /,"")},r))}):null]})]})}function Cg(e){return e}function wg(e){return e}function xg(e,t){if(e.dataType==="asset"&&e.scope!==void 0&&e.scope!=="global")throw new Error(`Attribute "${e.name}" in entity "${t}" uses dataType "asset" but scope "${e.scope}". Asset attributes must use scope "global" or omit scope.`)}function Sg(e){return e.dataType!=="asset"?e:{...e,scope:"global"}}function Eg(e){let t=e.display?e.attributes.find(n=>n.name===e.display):e.attributes[0];if(e.display&&!t)throw new Error(`Entity "${e.name}" sets display to "${e.display}", but no attribute has that name.`);if(!(!t||(t.spaces??[]).length===0))throw new Error(`Entity "${e.name}" cannot use space-bound attribute "${t.name}" as its display field.`)}function Hl(e){return e.attributes.forEach(t=>{xg(t,e.name);}),Eg(e),{...e,attributes:e.attributes.map(Sg)}}function Ag(e){return Hl(e)}function Dg(e){let t=useApolloClient(),{currentProjectSchema:n}=d();return useCallback(async()=>{n&&await At(t,Ke(e,n));},[t,e,n])}function Rg(e){let{currentProjectSchema:t}=d();return useCallback(n=>{t&&ga(Ke(e,t),n);},[e,t])}function Lg({column:e,title:t,options:n}){let o=new Set(e?.getFilterValue());return jsxs(Cn,{children:[jsx(wn,{asChild:true,children:jsxs(b$3,{variant:"outline",size:"sm",className:"fk:h-8 fk:border-dashed",children:[jsx(CirclePlus,{className:"fk:mr-2 fk:h-4 fk:w-4"}),t,o?.size>0&&jsxs(Fragment,{children:[jsx(c$5,{orientation:"vertical",className:"fk:mx-2 fk:h-4"}),jsx(b$6,{variant:"secondary",className:"fk:rounded-xs fk:px-1 fk:font-normal fk:lg:hidden",children:o.size}),jsx("div",{className:"fk:space-x-1 fk:lg:flex",children:o.size>2?jsxs(b$6,{variant:"secondary",className:"fk:rounded-xs fk:px-1 fk:font-normal",children:[o.size," selected"]}):n.filter(r=>o.has(r.value)).map(r=>jsx(b$6,{variant:"secondary",className:"fk:rounded-xs fk:px-1 fk:font-normal",children:r.label},r.value))})]})]})}),jsx(Bt,{className:"fk:w-50 fk:p-0",align:"start",children:jsxs(n$1,{children:[jsx(p$1,{placeholder:t}),jsxs(q$1,{children:[jsx(r,{children:"No results found."}),jsx(s$1,{children:n.map(r=>{let i=o.has(r.value);return jsxs(u$1,{onSelect:()=>{i?o.delete(r.value):o.add(r.value);let s=Array.from(o);e?.setFilterValue(s.length?s:void 0);},children:[jsx("div",{className:a$1("fk:mr-2 fk:flex fk:h-4 fk:w-4 fk:items-center fk:justify-center fk:rounded-xs fk:border fk:border-primary",i?"fk:bg-primary fk:text-primary-foreground":"fk:opacity-50 fk:[&_svg]:invisible"),children:jsx(Check,{className:a$1("fk:size-3.5",i?"fk:text-primary-foreground":"fk:text-muted-foreground")})}),r.icon&&jsx(r.icon,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:text-muted-foreground"}),jsx("span",{children:r.label})]},r.value)})}),o.size>0&&jsxs(Fragment,{children:[jsx(t$1,{}),jsx(s$1,{children:jsx(u$1,{onSelect:()=>e?.setFilterValue(void 0),className:"fk:justify-center fk:text-center",children:"Clear filters"})})]})]})]})})]})}function _g({entityName:e,entityNamePlural:t,row:n,options:o={canDelete:true,canEdit:true}}){let r=pe(),i=Ft(),s=n.original._id,a=(o.canDelete??true)&&i,c=o.canEdit??true;function l(){r({type:"EditEntity",payload:{entityId:s,entityNamePlural:t}});}function u(){r({type:"DeleteEntity",payload:{entityId:s,entityName:e}});}return jsxs("div",{className:"fk:flex",children:[c&&jsxs(b$3,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1",onClick:l,variant:"ghost",children:[jsx(PencilIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Edit"})]}),a&&!c&&jsxs(b$3,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1",onClick:u,variant:"ghost",children:[jsx(Trash2Icon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Delete"})]}),c&&a&&jsxs(c$3,{children:[jsx(e$2,{asChild:true,children:jsxs(b$3,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0",variant:"ghost",children:[jsx(Ellipsis,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Additional actions"})]})}),jsxs(f$2,{align:"end",className:"w-[160px]",children:[jsxs(h$2,{onClick:l,children:[jsx(PencilIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Edit"]}),jsx(m,{}),jsxs(h$2,{className:"fk:text-destructive",onClick:u,children:[jsx(Trash2Icon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete"]})]})]})]})}function Ri({table:e}){let[t]=e.getState().sorting;if(!t)return null;let o=e.getColumn(t.id)?.columnDef.meta?.label??t.id,r=t.desc?"desc":"asc";return jsxs(b$3,{"aria-label":`Clear sorting by ${o}`,className:"fk:h-8 fk:px-2 fk:lg:px-3 fk:text-success fk:border-none",onClick:()=>{e.resetSorting();},size:"sm",variant:"outline",children:["Sorted by ",o," ",r,jsx(X,{className:"fk:ml-1 fk:h-4 fk:w-4"})]})}function Ii({table:e}){return jsxs(c$3,{children:[jsx(e$2,{asChild:true,children:jsxs(b$3,{className:"fk:hidden fk:h-8 fk:lg:flex",size:"sm",variant:"outline",children:[jsx(Settings2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"View"]})}),jsxs(f$2,{align:"end",className:"fk:w-[150px]",children:[jsx(l$1,{children:"Toggle columns"}),jsx(m,{}),e.getAllColumns().filter(t=>typeof t.accessorFn<"u"&&t.getCanHide()).map(t=>jsx(i$2,{checked:t.getIsVisible(),className:"capitalize",onCheckedChange:n=>{t.toggleVisibility(!!n);},children:t.id},t.id))]})]})}function Gg({entityName:e,isReloading:t=false,onReload:n,table:o}){let r=pe(),i=d$2(),s=c$2(),a=useApolloClient(),{projects:c,currentProjectId:l}=d(),{schema:u,scopes:f}=find(propEq(l??"","projectId"))(c),[m,p,d$3]=xt(),[g,h]=useState(false),v=Ft(),y=o.getSelectedRowModel().rows.map(N=>N.original._id);function b(){r({type:"AddEntity",payload:{entityName:e}});}function E(N){i({type:"setScope",payload:{projectId:l,scope:N}});}async function A(N){if(N.length===0)return;let S=Un(e,u,N);await new Promise((D,$)=>{p(gql`
|
|
398
|
-
${S}
|
|
399
|
-
`),d$3({variables:{where:qn(N)},update(O){for(let V of N)O.evict({id:V});},onCompleted:()=>{D();},onError:O=>{$(O);}}),m(true);});}function F(){let N=e==="_asset"?"asset":e.toLowerCase();r({type:"AlertDialog",payload:{options:{dialogTitle:`Delete ${y.length} ${N}${y.length>1?"s":""}`,dialogMessage:y.length>1?`Are you sure you want to delete the selected ${N}s? They will be deleted permanently.`:`Are you sure you want to delete the selected ${N}? The item will be deleted permanently.`,dialogCancelTitle:"Cancel",dialogActionLabel:"Delete",isDestructive:true,dialogActionSubmit:async()=>{h(true);try{let S=[...y];await A(S),o.resetRowSelection(),await Do(a,Ke(e,u),S),toast.success(S.length>1?"Items successfully deleted.":"Item successfully deleted.");}catch{toast.error("Failed to delete selected items.");}finally{h(false);}},dialogActionCancel:()=>{}}}});}return jsxs("div",{className:"fk:flex fk:items-center fk:justify-between",children:[jsxs("div",{className:"fk:flex fk:flex-1 fk:items-center fk:space-x-2",children:[f&&f.length>0?jsxs(a$5,{defaultValue:s.scope,onValueChange:N=>{E(N);},value:s.scope,children:[jsxs(d$1,{className:"fk:w-48!",id:"project",size:"sm",children:[jsx("span",{className:"fk:text-muted-foreground",children:"Scope:"}),jsx(c$1,{children:(find(propEq(s.scope??"","name"))(f)||null)?.label})]}),jsx(e$1,{children:f.map(N=>jsx(g$1,{value:N.name,children:N.label},N.name))})]}):null,jsx(Ii,{table:o}),n?jsx(b$3,{"aria-label":"Reload",className:"fk:h-8",disabled:g||t,onClick:n,size:"icon-sm",variant:"outline",children:jsx(RefreshCw,{className:t?"fk:animate-spin":void 0})}):null,jsx(Ri,{table:o})]}),y.length>0?jsx(x$1,{disabled:!v,children:jsxs(b$3,{className:"fk:h-8 fk:mr-2 fk:lg:flex",disabled:g||!v,onClick:F,size:"sm",variant:"destructive",children:[g?jsx(Loader2,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):jsx(Trash2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete (",y.length,")"]})}):null,jsx(x$1,{disabled:!v,children:jsx(b$3,{className:"fk:ml-auto fk:h-8 fk:lg:flex",disabled:g||!v,onClick:b,size:"sm",variant:"default",children:"Create"})})]})}export{ci as ALL_FIELDS_GROUP,tn as ALL_FIELDS_GROUP_NAME,eo as DataTable,zo as DataTableColumnHeader,Lg as DataTableFacetedFilter,_g as DataTableRowActions,Ri as DataTableSortedBy,Gg as DataTableToolbar,Ii as DataTableViewOptions,gg as FlexkitStudio,hg as ProjectDisabled,vg as SchemaError,Lr as canAccessSpaces,bl as canMutateData,Cg as defineConfig,Ag as defineEntity,wg as defineExtension,vn as filterAttributesForSpaces,ef as filterEntitiesForSpaces,Nr as getEntityCreateMutation,Un as getEntityDeleteMutation,qn as getEntityDeleteWhere,jn as getEntityQuery,rt as getEntitySchema,Ar as getEntityUpdateMutation,Tu as getSortNotNullWhere,Ft as useCanMutate,pe as useDispatch,xt as useEntityMutation,ro as useEntityQuery,Kt as useGraphQLError,Yn as useGridColumnsDefinition,Rg as usePatchEntityList,Dg as useRefreshEntityList,Gn as useUploadAssets};//# sourceMappingURL=index.js.map
|
|
386
|
+
`);wn(x,P),useEffect(()=>{let M=Nt(j);A.current=j.map(O=>O._id),N.current=[];let J={...t.knownAssetSortOrders??{},...zn(j)};B.current=J,Y(Object.keys(J).length),C(Math.max(t.count??0,j[0]?.totalCount??0,j.length)),U(O=>{let G=Nt(O);return M===""&&G!==""&&$.current===G||G===M?O:($.current=M,j)});},[t.count,t.knownAssetSortOrders,j]),useEffect(()=>{let M=h$1[b]?.connect;if(!M)return;let J=M.map((E,D)=>Za(E.value,E.sortOrder??D)).filter(E=>!!E),O=Nt(J),G=Nt(F),Q=I.current;Q===G&&O!==Q||(I.current=null,O!==G&&U(J));},[b,h$1,F]),useEffect(()=>{let M=Nt(F);if($.current===M)return;let J=F.map((Q,E)=>({_id:Q._id,sortOrder:E,value:{...Q,sortOrder:E}})),O=F.map(Q=>Q._id),G=N.current.filter(Q=>!O.includes(Q));$.current=M,g({type:"setRelationship",payload:{[b]:{connect:J,disconnect:G}}}),c$1(a,{...t,knownAssetSortOrders:B.current,relationships:{connect:J,disconnect:G},value:F});},[g,t,a,b,F,c$1]);let W=Math.max(L,X$1),se=!!n&&W>X$1,ee=useCallback(()=>{if(!n||q$1||!se)return;let M=X$1+km;V({variables:{where:{_id:{eq:n}},first:M}}).then(J=>{let O=J.data?.[r],Q=(Array.isArray(O)?O[0]:void 0)?.[`${a}Connection`],E=Ao(Q),D=E[0]?.totalCount;if(typeof D=="number"&&C(D),E.length===0){C(X$1);return}let S=Object.keys(B.current).length,z={...B.current,...zn(E)},oe=Object.keys(z).length;B.current=z,Y(oe),(E.length<M||oe<=S)&&C(oe);for(let te of E)A.current.includes(te._id)||(A.current=[...A.current,te._id]);U(te=>{let on=new Set(te.map(lo=>lo._id)),rn=new Set(N.current),Ii=E.filter(lo=>!on.has(lo._id)&&!rn.has(lo._id));if(Ii.length===0)return $.current="",[...te];let Li=[...te,...Ii];return I.current=Nt(Li),Li});}).catch(J=>{console.error("Error fetching more assets:",J);});},[n,r,V,se,q$1,X$1,a]);function H(M){M.preventDefault(),M.stopPropagation(),!s&&p({type:"EditRelationship",payload:{connectedEntitiesCount:Math.max(F.length,W),entityName:f?.entity??"_asset",entityId:n,relationshipId:b,mode:"multiple",assetAccept:d?.accept}});}async function ce(M){if(M.preventDefault(),M.stopPropagation(),s)return;let J=await y({projectId:m,accept:d?.accept??"image/*",multiple:true,maxBytes:4*1024*1024});U(O=>{let G=new Set(O.map(D=>D._id)),Q=J.map((D,S)=>({...D.asset,sortOrder:O.length+S})).filter(D=>!G.has(D._id)),E=Xr([...O,...Q]);return I.current=Nt(E),E});}function ge(M){U(J=>{let O=Xr(J.filter(G=>G._id!==M));return A.current.includes(M)&&!N.current.includes(M)&&(N.current=[...N.current,M]),I.current=Nt(O),O});}function ae(M,J){U(O=>{let G=O.findIndex(z=>z._id===M),Q=G+J;if(G<0||Q<0||Q>=O.length)return O;let E=[...O],[D]=E.splice(G,1);if(!D)return O;E.splice(Q,0,D);let S=Xr(E);return I.current=Nt(S),S});}let Be=Math.max(F.length,W),He=F.slice(0,8);return jsx(c,{control:e,defaultValue:t,name:a,render:()=>jsxs(e$1,{children:[jsx(f$1,{htmlFor:v,children:u}),d?.comment?jsx(h,{children:d.comment}):null,jsx(g$1,{className:"fk:flex fk:flex-col fk:w-full fk:min-h-9.5 fk:text-sm",children:jsx("div",{"aria-controls":`asset-relationship-dropdown-${a}`,"aria-expanded":T,className:`fk:relative fk:flex fk:w-full fk:items-start fk:space-x-2 fk:rounded-md fk:border fk:border-input fk:bg-background fk:px-2.5 fk:py-0.5 fk:focus-visible:outline-hidden fk:ring-offset-background fk:focus-visible:ring-2 fk:focus-visible:ring-ring fk:focus-visible:ring-offset-2 ${T?"fk:outline-hidden fk:ring-2 fk:ring-ring fk:ring-offset-2":""} fk:corner-squircle`,onClick:M=>{M.preventDefault(),M.stopPropagation(),x.current?.focus(),P(true);},ref:x,role:"combobox",tabIndex:0,children:jsxs("div",{className:"fk:flex fk:w-full fk:flex-col",children:[jsxs("div",{className:"fk:flex fk:w-full fk:items-center fk:gap-2 fk:pr-9",children:[T&&F.length>0?jsxs("div",{className:"fk:flex fk:h-9 fk:items-center fk:text-muted-foreground",children:[Be," ",Be===1?"asset":"assets",se?` (${F.length} loaded)`:""," selected"]}):F.length>0?jsxs("div",{className:"fk:flex fk:min-h-9 fk:flex-wrap fk:gap-2",children:[He.map(M=>jsx(hm,{asset:M},M._id)),!T&&Be>8?jsxs("div",{className:"fk:flex fk:h-9 fk:w-9 fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted fk:text-xs fk:text-muted-foreground fk:corner-squircle",children:["+",Be-8]}):null]}):jsxs("div",{className:"fk:flex fk:h-9 fk:items-center fk:text-muted-foreground",children:[jsx(Image,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Select or upload assets"]}),jsx(a$7,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:absolute fk:right-0.75 fk:top-0.75 fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground fk:corner-squircle",id:v,onClick:M=>{M.preventDefault(),M.stopPropagation(),P(J=>!J);},size:"icon",variant:"ghost",children:T?jsx(X,{className:"fk:h-4 fk:w-4"}):jsx(Maximize2,{className:"fk:h-4 fk:w-4"})})}),jsx(e$4,{children:jsx("p",{children:T?"Close":"Expand field"})})]})})]}),jsx(o,{className:"fk:w-full fk:space-y-2 fk:ml-0!",onOpenChange:P,open:T,children:jsx(q,{className:"fk:w-full",children:jsxs("div",{className:"fk:flex fk:h-[350px] fk:flex-col fk:gap-3",id:`asset-relationship-dropdown-${a}`,children:[jsxs("div",{className:"fk:flex fk:gap-2",children:[jsxs(b$3,{className:"fk:h-8",disabled:s,onClick:H,variant:"outline",children:[jsx(Link,{className:"fk:h-4 fk:w-4 fk:mr-2"}),"Select assets"]}),jsxs(b$3,{className:"fk:h-8",disabled:s,onClick:M=>{ce(M);},variant:"outline",children:[jsx(Upload,{className:"fk:h-4 fk:w-4 fk:mr-2"}),"Upload assets"]})]}),F.length>0?jsxs(w,{className:"fk:min-h-0 fk:flex-1",children:[jsx("div",{className:"fk:grid fk:grid-cols-[repeat(auto-fill,minmax(8rem,1fr))] fk:gap-3 fk:pr-3",children:F.map((M,J)=>jsx(ym,{asset:M,index:J,isFirst:J===0,isLast:J===F.length-1,moveAsset:ae,readOnly:s,removeAsset:ge},M._id))}),se?jsx("div",{className:"fk:flex fk:justify-center fk:py-3 fk:pr-3",children:jsx(b$3,{className:"fk:h-8",disabled:q$1,onClick:M=>{M.preventDefault(),M.stopPropagation(),ee();},type:"button",variant:"outline",children:q$1?"Loading\u2026":`Load more (${X$1} of ${W})`})}):null]}):null]})})})]})})}),jsx(i,{})]})})}function hm({asset:e}){return Ya(e)?jsx("img",{alt:e.originalFilename||"Asset",className:"fk:h-9 fk:w-9 fk:rounded-sm fk:bg-muted fk:object-cover fk:corner-squircle",src:`${b$4}${e.path}?w=128&h=128&f=webp`}):jsx("div",{className:"fk:flex fk:h-9 fk:w-9 fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted fk:corner-squircle",children:jsx(Image,{className:"fk:h-4 fk:w-4 fk:text-muted-foreground"})})}function ym({asset:e,index:t,isFirst:n,isLast:o,moveAsset:r,readOnly:i,removeAsset:s}){return jsxs("div",{className:"fk:relative fk:rounded-md fk:border fk:border-input fk:bg-background fk:p-2 fk:corner-squircle",children:[jsx("div",{className:"fk:aspect-square fk:overflow-hidden fk:rounded-sm fk:bg-muted fk:corner-squircle",children:Ya(e)?jsx("img",{alt:e.originalFilename||"Asset",className:"fk:h-full fk:w-full fk:object-cover",src:`${b$4}${e.path}?w=320&h=320&f=webp`}):jsx("div",{className:"fk:flex fk:h-full fk:w-full fk:items-center fk:justify-center",children:jsx(Image,{className:"fk:h-8 fk:w-8 fk:text-muted-foreground"})})}),jsxs("div",{className:"fk:mt-2 fk:truncate fk:text-xs",title:e.originalFilename,children:[t+1,". ",e.originalFilename||e.path]}),jsxs("div",{className:"fk:mt-2 fk:flex fk:gap-1",children:[jsx(b$3,{className:"fk:h-7 fk:w-7",disabled:i||n,onClick:()=>r(e._id,-1),size:"icon",type:"button",variant:"ghost",children:jsx(ArrowUp,{className:"fk:h-3.5 fk:w-3.5"})}),jsx(b$3,{className:"fk:h-7 fk:w-7",disabled:i||o,onClick:()=>r(e._id,1),size:"icon",type:"button",variant:"ghost",children:jsx(ArrowDown,{className:"fk:h-3.5 fk:w-3.5"})}),jsx(b$3,{className:"fk:ml-auto fk:h-7 fk:w-7",disabled:i,onClick:()=>s(e._id),size:"icon",type:"button",variant:"ghost",children:jsx(X,{className:"fk:h-3.5 fk:w-3.5"})})]})]})}function vm(e){return Array.isArray(e)?e.map((t,n)=>Za(t,n)).filter(t=>!!t).sort((t,n)=>(t.sortOrder??Number.MAX_SAFE_INTEGER)-(n.sortOrder??Number.MAX_SAFE_INTEGER)):[]}function Nt(e){return e.map((t,n)=>`${t._id}:${t.sortOrder??n}`).join("|")}function Xr(e){return e.map((t,n)=>({...t,sortOrder:n}))}function Za(e,t){if(!e||typeof e!="object"||!("_id"in e)||!("path"in e))return null;let n=e;return {_id:String(n._id??""),path:String(n.path??""),originalFilename:String(n.originalFilename??""),size:Number(n.size??0),mimeType:String(n.mimeType??""),lqip:String(n.lqip??""),width:Number(n.width??0),height:Number(n.height??0),sortOrder:n.sortOrder??t,totalCount:typeof n.totalCount=="number"?n.totalCount:void 0}}function Ya(e){return !!(e.mimeType&&e.mimeType.startsWith("image/")||/\.(png|jpe?g|gif|webp|avif|svg)$/i.test(e.path))}function tl({value:e}){return !e||!e.split(",").length?null:jsx("div",{className:"fk:flex fk:flex-wrap fk:gap-1 fk:max-w-full truncate",children:e.split(",").map(t=>jsx(b$6,{className:"fk:px-2.5 fk:py-0 fk:font-normal fk:text-[0.6875rem] fk:leading-4",variant:"secondary",children:t},t))})}function Vo({column:e,title:t,className:n}){if(!e.getCanSort())return jsx("div",{className:a$8("fk:flex fk:items-center",n),children:t});let o=e.getIsSorted()==="asc",r=e.getIsSorted()==="desc";return jsxs("div",{className:a$8("fk:flex fk:w-full fk:items-center fk:justify-between fk:gap-1",n),children:[jsx("span",{className:"fk:truncate",children:t}),jsxs(c$3,{children:[jsx(e$3,{asChild:true,children:jsx("button",{"aria-label":`Sort ${t}`,className:"fk:inline-flex fk:shrink-0 fk:items-center fk:justify-center fk:rounded-sm fk:p-0.5 fk:text-muted-foreground fk:outline-hidden fk:hover:bg-accent fk:hover:text-accent-foreground fk:focus-visible:ring-1 fk:focus-visible:ring-ring fk:corner-squircle",type:"button",children:jsx(ChevronDown,{className:"fk:h-3.5 fk:w-3.5"})})}),jsxs(f$3,{align:"end",className:"fk:w-44",children:[jsxs(h$1,{"aria-checked":o,className:a$8(o&&"fk:bg-accent fk:text-accent-foreground"),onSelect:()=>{if(o){e.clearSorting();return}e.toggleSorting(false);},role:"menuitemcheckbox",children:[jsx(ArrowUp,{className:a$8("fk:h-4 fk:w-4",o&&"fk:text-white")}),"Sort Ascending"]}),jsxs(h$1,{"aria-checked":r,className:a$8(r&&"fk:bg-accent fk:text-accent-foreground"),onSelect:()=>{if(r){e.clearSorting();return}e.toggleSorting(true);},role:"menuitemcheckbox",children:[jsx(ArrowDown,{className:a$8("fk:h-4 fk:w-4",r&&"fk:text-white")}),"Sort Descending"]})]})]})]})}var Sm=new Set(["text","number","datetime","switch","select"]);function Yn({attributesSchema:e,checkboxSelect:t,actionsComponent:n,enableColumnSorting:o=false}){let{getContributionPointConfig:r}=d(),[,i]=b(),s=Cn(e,i.user?.spaces),l={datetime:"datetime",editor:"editor",asset:"asset",number:"text",relationship:"text",select:"select",switch:"boolean",text:"text",textarea:"text"},c={boolean:a$b,date:a$a,datetime:a$e,editor:b$7,asset:a$d,number:a$a,relationship:a$a,select:a$c,switch:a$b,text:a$a,textarea:a$a,tags:tl},a=s.map(p=>{if(p.name==="_updatedAt")return null;let g=(p.inputType==="relationship"&&p.relationship?.entity==="_asset"?"asset":void 0)??p.previewType??l[p.inputType],h=r("previewFields",[g])?.[0]?.component??c[g]??c.text;if(p.hidden===true)return null;let y=g==="tags",v=o&&p.scope==="global"&&Sm.has(p.inputType);return {accessorKey:p.name,filterFn:(b,x,A)=>y?true:(Array.isArray(A)?A:[A]).includes(b.getValue(x)),header:({column:b})=>v?jsx(Vo,{column:b,title:p.label}):jsx("div",{className:"fk:flex fk:items-center",children:p.label}),cell:({row:b})=>{let x=h;return g==="select"?jsx(x,{value:b.getValue(p.name),options:p.options}):g==="assetPreviewField"?jsx(x,{value:b.original}):jsx(x,{value:b.getValue(p.name)})},enableSorting:v,enableHiding:true,meta:{label:p.label},size:p.options?.size??150}}).filter(p=>p!==null),u={id:"actions",cell:({row:p})=>n?n(p):null,size:80},d$1={accessorKey:"_updatedAt",header:({column:p})=>o?jsx(Vo,{column:p,title:"Updated At"}):jsx("div",{className:"fk:flex fk:items-center",children:"Updated At"}),cell:({row:p})=>jsx(a$e,{value:p.getValue("_updatedAt")}),enableSorting:o,enableHiding:false,meta:{label:"Updated At"},size:220},f={id:"select",cell:({row:p,table:g})=>jsx(j,{"aria-label":"Select row",checked:p.getIsSelected(),onCheckedChange:h=>{g.toggleAllPageRowsSelected(false),p.toggleSelected(!!h);}}),enableSorting:false,enableHiding:false,size:50},m={id:"select",header:({table:p})=>jsx(j,{className:"fk:dark:bg-white/15","aria-label":"Select all",checked:p.getIsAllPageRowsSelected()||p.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:g=>{p.toggleAllPageRowsSelected(!!g);}}),cell:({row:p})=>jsx(j,{"aria-label":"Select row",checked:p.getIsSelected(),onCheckedChange:g=>{p.toggleSelected(!!g);}}),enableSorting:false,enableHiding:false,size:50};return [...t==="single"?[f]:[],...t==="multiple"?[m]:[],...n?[u]:[],...a,d$1]}function nl({scrollHeight:e,scrollTop:t,clientHeight:n}){if(n<=0)return false;let o=t>0?Math.max(600,n):1;return e-t-n<o}var Fm=36,Rm=15,Im=2,il=40;function ll(e){if(!e)return;let t=e.split(/\s+/);if(t.includes("fk:h-20"))return 80;if(t.includes("fk:h-10"))return 40;if(t.includes("fk:h-9"))return 36}function Lm(e,t){return e??ll(t)??Fm}function eo({classNames:e,columns:t,data:n,entityName:o,hasMore:r=false,initialSelectionState:i,isLoadingMore:s=false,onEntitySelectionChange:l,onLoadMore:c,onScroll:a,onSortingChange:u,pageSize:d,rowHeightEstimate:f,rowAdditionState:m,rowDeletionState:p,scrollToTopKey:g,sorting:h,toolbarComponent:y}){let v$1=useRef(null),{schemaErrorMessage:b}=Kt(),[x,A$1]=useState(i??{}),[I,N]=useState({}),[$,B$1]=useState([]),[T,P]=useState([]),j=h??T;useEffect(()=>{v$1.current?.scrollTo({top:0,left:0});},[o,g]),useEffect(()=>{if(!i)return;let S=Object.keys(x).sort().join(","),z=Object.keys(i).sort().join(",");S!==z&&A$1(i);},[i,x]);function F(S){if(u){u(S);return}P(S);}let U=useReactTable({data:n,columns:t,state:{sorting:j,columnVisibility:I,rowSelection:x,columnFilters:$},initialState:{pagination:{pageSize:d??50}},enableRowSelection:true,onRowSelectionChange:E,onSortingChange:F,onColumnFiltersChange:B$1,onColumnVisibilityChange:N,getCoreRowModel:getCoreRowModel(),getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),getSortedRowModel:getSortedRowModel(),getRowId:S=>S._id,manualFiltering:true,manualPagination:true,manualSorting:true,meta:{getRowBackground:S=>Mm(S,p,m)}}),{rows:X}=U.getRowModel(),Y=Lm(f,e?.row),L=ll(e?.row)!=null,C=useVirtualizer({count:X.length,estimateSize:()=>Y,getItemKey:S=>X[S]?.id??S,getScrollElement:()=>v$1.current,overscan:Rm,scrollMargin:il}),k=U.getVisibleLeafColumns(),V=U.getHeaderGroups(),q=V.length===1,W=useVirtualizer({horizontal:true,count:k.length,estimateSize:S=>k[S].getSize(),getItemKey:S=>k[S].id,getScrollElement:()=>v$1.current,overscan:Im,enabled:q}),se=JSON.stringify(k.map(S=>[S.id,S.getSize()]));useEffect(()=>{W.measure();},[se,W]);let ee=W.getVirtualItems(),H=q?ee[0]?.index??0:0,ce=q?(ee[ee.length-1]?.index??-1)+1:k.length,ge=q?ee[0]?.start??0:0,ae=q?Math.max(0,W.getTotalSize()-(ee[ee.length-1]?.end??0)):0,Be=C.getVirtualItems(),{paddingTop:He,paddingBottom:M}=Pm(Be,C.getTotalSize(),il),J=useRef(c),O=useRef(r),G=useRef(s);J.current=c,O.current=r,G.current=s;let Q=useCallback(S=>{if(!J.current||!O.current||G.current)return;let z=S??v$1.current;z&&nl(z)&&(G.current=true,J.current());},[]);useEffect(()=>{Q();},[Q,X.length,r,s]);function E(S){let z=Object.keys(typeof S=="function"?S(x):S);A$1(S),l?.(z);}function D(S){a?.(S),Q(S.currentTarget);}return b?jsx(Fragment,{}):jsxs("div",{className:a$8("fk:flex fk:h-full fk:min-h-0 fk:w-full fk:min-w-0 fk:flex-col fk:gap-4",e?.wrapper),children:[y&&y(U),jsx("div",{className:"fk:relative fk:min-h-0 fk:min-w-0 fk:flex-1 fk:-mb-px",children:jsx(a$7,{delayDuration:400,children:jsxs(v,{className:a$8("fk:grid fk:pb-20",e?.table),"aria-colcount":k.length,style:{minWidth:U.getTotalSize()},containerClassName:e?.tableContainer,onScroll:D,ref:v$1,children:[jsx(w$1,{className:"fk:sticky fk:top-0 fk:z-20 fk:grid",children:V.map(S=>jsxs(z$1,{className:"fk:flex fk:w-full",children:[ge>0?jsx(qo,{width:ge,header:true}):null,(q?S.headers.slice(H,ce):S.headers).map((z,oe)=>jsxs(A,{"aria-colindex":q?H+oe+1:void 0,className:a$8("fk:flex fk:shrink-0 fk:items-center",z.column.id==="actions"&&"fk:pl-0"),colSpan:z.colSpan,style:z.getSize()?{width:`${z.getSize().toString()}px`}:{},children:[z.isPlaceholder?null:flexRender(z.column.columnDef.header,z.getContext()),s?jsx("div",{"aria-hidden":true,className:"fk:pointer-events-none fk:absolute fk:top-10.25 fk:right-px fk:left-px fk:z-20 fk:h-0.5 fk:overflow-hidden fk:opacity-4",children:jsx("div",{className:"fk:animate-progress fk:h-full fk:w-full fk:bg-foreground"})}):null]},z.id)),ae>0?jsx(qo,{width:ae,header:true}):null]},S.id))}),jsx(x$1,{className:"fk:grid fk:relative",children:X.length===0?jsx(z$1,{children:jsx(B,{className:"fk:h-24 fk:text-center",colSpan:t.length,children:"No results."})}):jsxs(Fragment,{children:[He>0?jsx(sl,{height:He}):null,Be.map(S=>{let z=X[S.index];return jsxs(z$1,{className:a$8(U.options.meta.getRowBackground(z),"fk:flex fk:w-full fk:overflow-hidden fk:transition-none",!L&&f==null&&"fk:h-9",e?.row),"data-index":S.index,"data-state":z.getIsSelected()&&"selected",style:{height:`${Y.toString()}px`},children:[ge>0?jsx(qo,{width:ge}):null,z.getVisibleCells().slice(H,ce).map((oe,te)=>jsx(B,{className:a$8("fk:flex fk:shrink-0 fk:items-center fk:truncate",oe.column.id==="actions"&&"fk:pl-1!"),"aria-colindex":H+te+1,style:{width:oe.column.getSize()},children:flexRender(oe.column.columnDef.cell,oe.getContext())},oe.id)),ae>0?jsx(qo,{width:ae}):null]},S.key)}),M>0?jsx(sl,{height:M}):null]})})]})})})]})}function Pm(e,t,n){if(e.length===0)return {paddingTop:0,paddingBottom:0};let o=e[0]?.start??0,r=e[e.length-1]?.end??0;return {paddingTop:Math.max(0,o-n),paddingBottom:Math.max(0,t-(r-n))}}function qo({width:e,header:t=false}){return jsx(t?"th":"td",{"aria-hidden":true,style:{width:e,flexShrink:0,padding:0,border:0}})}function sl({height:e}){return jsx("tr",{"aria-hidden":true,className:"fk:pointer-events-none fk:border-0",style:{display:"block",height:`${e.toString()}px`},children:jsx("td",{className:"fk:p-0 fk:border-0"})})}function Mm(e,t,n){return t?.includes(e.original._id)?"fk:bg-row-removed fk:hover:bg-row-removed-hover":n?.some(o=>o._id===e.original._id)?"fk:bg-row-added fk:hover:bg-row-added-hover":""}function cl({action:e,row:t}){let n=t.original._id;function o(){e(n);}return jsx("div",{className:"fk:flex fk:items-center",children:jsxs(b$3,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1",onClick:o,variant:"ghost",children:[jsx(Trash2,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Delete"})]})})}var Qm=25;function ei({control:e,defaultScope:t,defaultValue:n,entityId:o$1,entityName:r,fieldSchema:i$1,readOnly:s,schema:l,scope:c$1,setValue:a}){let[u,d]=useState(false),f=useRef(null);wn(f,d);let[m,p]=useState([]),{name:g,label:h$1,options:y,relationship:v}=i$1,b=v?.entity??g,x=me(),A=d$2(),{relationships:I}=c$2(),N=useId(),$=useId(),B=find(propEq(b,"name"))(l),T=B?.attributes??[],j=find(propEq(r,"name"))(l)?.name??"",F,U=T.find(E=>E.relationship?.entity===j);U&&(F=U.name);let X$1=e$5(B)?.name??"",Y=useMemo(()=>n.value?Wm({data:n.value,defaultScope:t,relationshipEntitySchema:B,scope:c$1}):[],[t,n,X$1,B,c$1]),L=sa({relatedEntityName:b,scope:c$1,schema:l}),k=m.length?m.slice(0,12).map(E=>E[X$1]):[],V=Math.max(m.length,n.count??0)>k.length,[q$1,{loading:W,data:se}]=useLazyQuery(gql`
|
|
387
|
+
${L.query}
|
|
388
|
+
`),ee=Yn({attributesSchema:B?.attributes??[],actionsComponent:s?void 0:E=>Xm({appDispatch:A,relationshipId:$,relationships:I,row:E,setRows:p})});useEffect(()=>{p(Y),n.value!==""&&A({type:"setRelationship",payload:{[$]:{connect:[],disconnect:[]}}});},[A,se,Y,$,n,c$1]),useEffect(()=>{a(g,{...n,relationships:I[$]});},[n,I,$,a,g]),useEffect(()=>{let D=(I[$]?.connect??[]).map(({value:S})=>S);p(uniqBy(prop("_id"),[...D,...Y]));},[se,n.count,Y,I,$]);let H=I[$]?.connect??[],ce=I[$]?.disconnect??[],ge=new Set(Y.map(E=>E._id)),ae=new Set(ce),Be=H.filter(E=>!ge.has(E._id)||ae.has(E._id)).length,He=ce.length,M=n.count??0,J=Math.max(0,Math.max(M,Y.length)+Be-He),O=M>0&&m.length>0&&m.length<M,G=useCallback(()=>{W||q$1({variables:{limit:Qm,offset:m.length,where:F?{[F]:{some:{_id:{eq:o$1}}}}:{}}}).then(({data:E})=>{if(!E)return;let D=To(B?.plural??"",c$1,E,l);p(uniqBy(prop("_id"),[...Y,...D.results]));}).catch(E=>{console.error("Error fetching more data:",E);});},[F,o$1,q$1,Y,W,B?.plural,m.length,l,c$1]);function Q(E){E.preventDefault(),!s&&x({type:"EditRelationship",payload:{connectedEntitiesCount:Y.length,connectionName:F,entityName:b,entityId:o$1,relationshipId:$,mode:v?.mode??"multiple"}});}return jsx(c,{control:e,defaultValue:n,name:g,render:()=>jsxs(e$1,{className:"fk:min-w-0",children:[jsx(f$1,{htmlFor:N,children:h$1}),y?.comment?jsx(h,{children:y.comment}):null,jsx(g$1,{className:"fk:flex fk:flex-col fk:w-full fk:min-w-0 fk:min-h-9.5 fk:pl-3 fk:pr-3 fk:py-0.5 fk:text-sm",children:jsx("div",{"aria-controls":`relationship-dropdown-${g}`,"aria-expanded":u,className:`fk:relative fk:flex fk:w-full fk:min-w-0 fk:items-start fk:space-x-2 fk:rounded-md fk:border fk:border-input fk:bg-background fk:focus-visible:outline-hidden fk:ring-offset-background fk:focus-visible:ring-2 fk:focus-visible:ring-ring fk:focus-visible:ring-offset-2 ${u?"fk:outline-hidden fk:ring-2 fk:ring-ring fk:ring-offset-2":""} fk:corner-squircle`,onClick:E=>{E.preventDefault(),E.stopPropagation(),f.current?.focus(),f.current?.click(),d(true);},onKeyDown:E=>{E.key==="Enter"&&d(true),E.key==="Escape"&&(E.preventDefault(),E.stopPropagation(),f.current?.blur(),d(false));},ref:f,role:"combobox",tabIndex:0,children:jsxs("div",{className:"fk:flex fk:w-full fk:min-w-0 fk:flex-col",children:[jsxs("div",{className:"fk:flex fk:w-full fk:min-w-0 fk:items-start fk:gap-2",children:[u?jsxs(b$3,{className:"fk:h-8 fk:mr-auto fk:mt-[0.1875rem]",disabled:s,onClick:Q,variant:"outline",children:[jsx(Link,{className:"fk:h-4 fk:w-4 fk:mr-2"})," Link to a record from"," ",B?.menu?.label??B?.plural]}):jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-wrap fk:grow fk:overflow-hidden fk:pb-1.5",children:[k.map(E=>jsx(b$6,{className:"fk:mr-2 fk:mt-1.5 fk:max-w-60 fk:justify-start fk:rounded-xs fk:corner-squircle",title:E,variant:"secondary",children:jsx("span",{className:"fk:min-w-0 fk:truncate",children:E})},E)),V?jsx(b$6,{className:"fk:mr-2 fk:mt-1.5 fk:rounded-xs fk:corner-squircle",variant:"secondary",children:"\u2026"}):null]}),jsxs("div",{className:"fk:mt-[0.1875rem] fk:ml-auto fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[u?jsxs("span",{className:"fk:text-sm fk:font-normal fk:text-muted-foreground",children:[J.toLocaleString()," ",J===1?"record":"records"]}):null,u?jsx(a$7,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground fk:corner-squircle",onClick:E=>{E.preventDefault(),E.stopPropagation(),f.current?.blur(),d(false);},onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),E.stopPropagation(),f.current?.blur(),d(false));},size:"icon",variant:"ghost",children:jsx(X,{className:"fk:h-4 fk:w-4"})})}),jsx(e$4,{children:jsx("p",{children:"Close"})})]})}):jsx(a$7,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground fk:corner-squircle",id:N,onKeyDown:E=>{E.key==="Enter"&&(f.current?.focus(),f.current?.click());},size:"icon",variant:"ghost",children:jsx(Maximize2,{className:"fk:h-4 fk:w-4"})})}),jsx(e$4,{children:jsx("p",{children:"Expand field"})})]})})]})]}),jsx(o,{className:"fk:w-full fk:min-w-0 fk:space-y-2 fk:ml-0!",onOpenChange:d,open:u,children:jsx(q,{className:"fk:w-full fk:min-w-0",children:jsx("div",{className:"fk:mt-3 fk:mb-2 fk:w-full fk:min-w-0",id:`relationship-dropdown-${g}`,children:jsx(eo,{classNames:{wrapper:"fk:h-[17.5rem] fk:min-h-0 fk:min-w-0 fk:gap-0",table:"fk:pb-0"},columns:ee,data:m,entityName:r,hasMore:O,isLoadingMore:W&&m.length>0,onLoadMore:G,rowAdditionState:I[$]?.connect,rowDeletionState:I[$]?.disconnect})})})})]})})}),jsx(i,{})]})})}function Xm({appDispatch:e,relationshipId:t,relationships:n,row:o,setRows:r}){function i(s){let l=n[t]?.connect??[],c=typeof find(propEq(s,"_id"),l)=="object",a=n[t]?.disconnect?.includes(s),u=c?n[t]?.disconnect??[]:uniq([...n[t]?.disconnect??[],s]);c&&r(d=>d.filter(f=>f._id!==s)),e({type:"setRelationship",payload:{[t]:{connect:l.filter(d=>d._id!==s),disconnect:a?n[t]?.disconnect?.filter(d=>d!==s)??[]:u}}});}return jsx(cl,{action:i,row:o})}function Wm({data:e,defaultScope:t,relationshipEntitySchema:n,scope:o}){if(!Array.isArray(e))return [];let r=i=>{let l=find(propEq(i.__typename,"name"))(n?.attributes??[])?.relationship?.field??"";if(l){let c=i[l],a=Array.isArray(c)?c[0]:c;return a&&typeof a=="object"?a[o]??a[t]??"":a}return i[o]??i[t]};return e.map(i=>map(s=>{if(Array.isArray(s)){let l=s;return l.length===0?"":l.length===1?r(l[0]):l.slice(0,3).map(r).join(", ")}return s&&typeof s!="string"&&s.__typename?r(s):s},i))}function ti({control:e,defaultScope:t,defaultValue:n,entityId:o,fieldSchema:r,getValues:i$1,readOnly:s,schema:l,scope:c$1,setValue:a}){let[u,d]=useState(false),{name:f,label:m,options:p,relationship:g}=r,h$1=g?.entity??f,y=me(),v=d$2(),b=useId(),{relationships:x}=c$2(),A=useId(),I=find(propEq(h$1,"name"))(l),N=e$5(I)?.name;useEffect(()=>{let T=n.value;if(T===""||typeof T=="boolean"||typeof T=="number")return;let P={_id:String(n._id),value:T},j={type:"setRelationship",payload:{[A]:{connect:P,disconnect:[]}}};v(j);},[v,A,n,c$1]),useEffect(()=>{a(f,{...i$1(f),...x[A]?.connect??""});},[n,f,x,A,a]);function $(T){T.preventDefault(),!s&&y({type:"EditRelationship",payload:{connectedEntitiesCount:0,entityName:h$1,entityId:o,relationshipId:A,mode:g?.mode??"single"}});}function B(T){if(s)return;let P={type:"setRelationship",payload:{[A]:{connect:[],disconnect:[]}}};T.preventDefault(),v(P),a(f,{...i$1(f),_id:"",value:void 0});}return jsx(c,{control:e,defaultValue:n,name:f,render:({field:T})=>{let P=T.value?.value,j="";if(N&&P&&typeof P=="object"&&!Array.isArray(P)&&P[N]){let F=P[N],U=Array.isArray(F)?F[0]:F;typeof U=="string"?j=U:j=U?.[c$1]??U?.[t]??"";}return jsxs(e$1,{children:[jsx(f$1,{htmlFor:b,children:m}),p?.comment?jsx(h,{children:p.comment}):null,jsx(g$1,{className:"fk:flex fk:w-full fk:items-center fk:space-x-2",children:jsxs("div",{className:`fk:relative fk:flex fk:w-full fk:items-start fk:space-x-2 fk:rounded-md fk:border fk:border-input fk:bg-background fk:ring-offset-background ${u?"fk:outline-hidden fk:ring-2 fk:ring-ring fk:ring-offset-2":""} fk:corner-squircle`,children:[jsx(a$6,{className:"fk:h-9.5 fk:py-1.75 fk:caret-transparent fk:border-0 fk:focus-visible:ring-0 fk:focus-visible:ring-offset-0",disabled:s,id:b,onBlur:()=>{d(false);},onClick:$,onFocus:()=>{d(true);},onKeyDown:F=>{F.key==="Enter"&&$(F);},readOnly:true,type:"text",value:j}),j?jsx(a$7,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:absolute fk:right-10 fk:top-0.75 fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground fk:corner-squircle",disabled:s,onClick:B,size:"icon",variant:"ghost",children:jsx(X,{className:"fk:h-4 fk:w-4"})})}),jsx(e$4,{children:jsx("p",{children:"Clear"})})]})}):null,jsx(a$7,{children:jsxs(b$5,{children:[jsx(c$4,{asChild:true,children:jsx(b$3,{className:"fk:absolute fk:right-0.75 fk:top-0.75 fk:h-8 fk:w-8 fk:rounded-sm fk:text-muted-foreground fk:corner-squircle",disabled:s,onClick:$,size:"icon",variant:"ghost",children:jsx(ChevronsUpDown,{className:"fk:h-4 fk:w-4"})})}),jsx(e$4,{children:jsx("p",{children:"Open"})})]})})]})}),jsx(i,{})]})}})}function ni(e$1){let{fieldSchema:t}=e$1,{relationship:n}=t;if(n?.mode==="single")return jsx(ti,{...e$1});if(n?.mode==="multiple"){if(n.entity==="_asset")return jsx(Kr,{...e$1});let o={relationshipEntityName:t.relationship?.entity,...e$1};return jsx(ei,{...o})}return jsxs(e,{variant:"destructive",children:[jsx(AlertTriangle,{className:"h-4 w-4"}),jsx(f,{children:"Error"}),jsx(g,{children:'Incorrect "mode" for relationship field. It should be "single" or "multiple". Please check the schema configuration.'})]})}var kl="flexkit-select-option:";function oi(e){return `${kl}${encodeURIComponent(e)}`}function rp(e){return decodeURIComponent(e.slice(kl.length))}function hl({control:e,fieldSchema:t,readOnly:n,setValue:o}){let{name:r,label:i$1,options:s}=t;function l(a,u){let f=t.dataType==="int"&&!isNaN(Number(a))?Number(a):a;o(r,{...u,value:f});}function c$2(a,u){o(r,{...u,disabled:a});}return jsx(c,{control:e,name:r,render:({field:a})=>jsxs(e$1,{children:[jsx(f$1,{children:i$1}),s?.comment?jsx(h,{children:s.comment}):null,jsxs(a$4,{defaultValue:a.value?.value===void 0||a.value.value===null?void 0:oi(String(a.value.value)),disabled:n||a.value?.disabled,onValueChange:u=>{l(rp(u),a.value);},children:[jsx(g$1,{children:jsx(d$1,{children:jsx(c$1,{placeholder:s?.placeholder})})}),jsx(e$2,{children:s?.list?.map(u=>"groupLabel"in u?jsxs(b$2,{children:[jsx(f$2,{children:u.groupLabel}),u.items.map(d=>jsx(g$2,{value:oi(d.value),children:d.label},d.label))]},u.groupLabel):jsx(g$2,{value:oi(u.value),children:u.label},u.label))})]}),jsx(a$5,{checked:a.value?.disabled??false,disabled:n,onChange:u=>{c$2(u,a.value);},scope:a.value?.scope}),jsx(i,{})]})})}function si({inputType:e$1,label:t}){return jsxs(e,{variant:"destructive",children:[jsx(AlertTriangle,{className:"h-4 w-4"}),jsx(f,{children:"Error"}),jsx(g,{children:`Incorrect inputType: "${e$1}" for the "${t}" attribute. Please check the schema configuration.`})]})}var tn="all",ai={name:"all",title:"All fields"};function ap(e){return typeof e.group=="string"?[e.group]:Array.isArray(e.group)?e.group:[]}function li(e,t){return t==="all"?true:ap(e).includes(t)}function ci(e,t){return t.length===0?true:t.some(n=>li(e,n.name))}function ui(e,t){if(!e||e.length===0)return [];let n=e.find(s=>s.name==="all"),o=e.filter(s=>s.name!=="all");return [{...ai,...n},...o].filter(s=>!xt(s.hidden,t))}function fi(e){let t=e.find(o=>o.default);if(t)return t.name;let n=e.find(o=>o.name!=="all");return n?n.name:"all"}function vp(e,t){let n=e.dataType==="asset"||e.scope==="relationship"?"":e.defaultValue??"";return {disabled:false,scope:t,value:n}}function bp({currentScope:e$1,defaultScope:t,entityId:n$1,entityName:o,entityNamePlural:r,formData:i,schema:s,setIsDirty:l$1,onSubmit:c},a){let u=find(propEq(o,"name"))(s),[,d$1]=b(),f$1=d$1.user?.spaces,m$1=useMemo(()=>Cn(u?.attributes??[],f$1),[u,f$1]),p=useMemo(()=>i||m$1.reduce((L,C)=>({...L,[C.name]:vp(C,t)}),{}),[t,i,m$1]),h=useForm({defaultValues:p,resolver:async(L,C,k)=>{let V=Vn(L),q=ui(u?.groups,{record:V,value:V,currentUser:d$1.user}),W={};for(let ee of m$1){if(typeof ee.validation>"u")continue;let H={record:V,value:V[ee.name],currentUser:d$1.user};xt(ee.hidden,H)||xt(ee.readOnly,H)||ci(ee,q)&&(W[ee.name]=z.object({value:ee.validation(z).or(z.any().refine(()=>false,{error:ee.label?`${ee.label} is required`:"Required field"}))}));}return zodResolver(z.object(W))(L,C,k)},values:i,mode:"onBlur",criteriaMode:"all"}),{control:y,getValues:v,handleSubmit:b$2,setValue:x$1,watch:A,trigger:I}=h,N=A(),$=Vn(N),B=useMemo(()=>ui(u?.groups,{record:$,value:$,currentUser:d$1.user}),[d$1.user,u?.groups,$]),[T,P]=useState(()=>fi(B)),{getContributionPointConfig:j}=d(),F=useRef(i),U=useRef(false);useEffect(()=>{U.current||(F.current=i);},[i]);let X={datetime:Fa,editor:Gr,asset:Aa,number:Ta,relationship:ni,select:hl,switch:a$3,text:a$2,textarea:a$1};if(useImperativeHandle(a,()=>({submit(){I().then(()=>{b$2(()=>{let L=v();U.current=true,F.current=L,l$1(false),c(L,i);})();});},hasErrors(){U.current=false,F.current=i,l$1(true);},hasDataChanged(){return vl(v(),F.current)},markAsSaved(){U.current=true,F.current=v(),l$1(false);},applyLocalAttributeIds(L){let C=v(),k={...C};for(let[V,q]of Object.entries(L)){let W=C[V];!W||W._id||!q||(k[V]={...W,_id:q});}U.current=true,F.current=k;for(let[V,q]of Object.entries(k))q!==C[V]&&x$1(V,q,{shouldDirty:false,shouldTouch:false,shouldValidate:false});l$1(false);}})),useEffect(()=>{let L=A(()=>{l$1(vl(v(),F.current));});return ()=>{L.unsubscribe();}},[i,v,l$1,A]),useEffect(()=>{B.length!==0&&(B.some(L=>L.name===T)||P(fi(B)));},[T,B]),!u||u.attributes.length===0)return jsxs(e,{variant:"destructive",children:[jsx(AlertTriangle,{className:"fk:h-4 fk:w-4"}),jsx(f,{children:"Error"}),jsxs(g,{children:["No attributes found in the schema for entity ",jsx("strong",{children:o})]})]});let Y=L=>{if(L.name==="_id")return null;let C={record:$,value:$[L.name],currentUser:d$1.user};if(xt(L.hidden,C))return null;let k=xt(L.readOnly,C),V=j("formFields",[L.inputType])?.[0]?.component??X[L.inputType];return V?createElement(V,{key:L.name,control:y,defaultScope:t,defaultValue:p[L.name],entityId:n$1,entityName:o,entityNamePlural:r,fieldSchema:L,getValues:v,readOnly:k,schema:s,scope:e$1,setValue:x$1}):jsx(si,{inputType:L.inputType,label:L.label},L.name)};return jsx(b$1,{...h,children:jsx("form",{className:"fk:flex fk:flex-col fk:gap-5",onSubmit:L=>{L.preventDefault();},children:B.length>0?jsxs(k,{onValueChange:P,value:T,children:[jsx("div",{className:"fk:sticky fk:top-0 fk:z-10 fk:bg-background fk:py-1 fk:mb-6",children:jsxs(w,{className:"fk:w-full fk:**:data-[slot=scroll-area-viewport]:h-auto fk:[&_[data-slot=scroll-area-scrollbar][data-orientation=vertical]]:hidden fk:**:data-[slot=scroll-area-viewport]:p-1 fk:**:data-[slot=scroll-area-viewport]:-ml-1 fk:**:data-[slot=scroll-area-viewport]:-mt-1",children:[jsx(l,{className:"fk:h-9 fk:w-max fk:flex-nowrap fk:justify-start",children:B.map(L=>jsxs(m,{value:L.name,children:[L.icon,L.title]},L.name))}),jsx(x,{orientation:"horizontal"})]})}),jsx(n,{className:"fk:gap-8",value:T,children:m$1.map(L=>{if(!ci(L,B))return null;let C=li(L,T),k=Y(L);return k?jsx("div",{className:C?void 0:"fk:hidden",children:k},L.name):null})})]}):m$1.map(L=>Y(L))})})}var Qo=memo(forwardRef(bp));function vl(e,t){if(!t)return Object.keys(e).some(s=>e[s]?.value!==""&&e[s]?.value!==void 0);let n=s=>typeof s=="object"&&s!==null?"path"in s?s.path:"_id"in s?s._id:"":s??"",o=(s,l)=>s<l?-1:1,r=Object.keys(t).sort((s,l)=>o(s,l)).filter(s=>s!=="_updatedAt").reduce((s,l)=>({...s,[l]:{value:n(t[l].value),disabled:t[l].disabled,relationships:t[l].relationships}}),{}),i=Object.keys(e).sort((s,l)=>o(s,l)).filter(s=>s!=="_updatedAt").reduce((s,l)=>({...s,[l]:{value:n(e[l]?.value),disabled:e[l]?.disabled??false,relationships:Object.keys(e[l]?.relationships?.connect??{}).length||e[l]?.relationships?.disconnect?.length?e[l]?.relationships:void 0}}),{});return !equals(r,i)}function bl(e){return e?e!=="viewer":true}function Ft(){let[,e]=b();return bl(e.user?.role)}function gi({action:e,depth:t,isFocused:n}){let{entityName:o}=e.payload,r=useRef(null),i=Ft(),[,s]=b(),{projects:l,currentProjectId:c}=d(),{schema:a,scopes:u}=find(propEq(c??"","projectId"))(l),d$1=u?.find(F=>F.isDefault)?.name??"default",m=find(propEq(o,"name"))(a)?.plural??o,{scope:p}=c$2(),g=me(),h=useApolloClient(),[y,v,b$1,x]=St(),{isDirty:A,setIsDirty:I}=bn(),[N,$]=useState(false);useEffect(()=>{x.error&&r.current?.hasErrors();},[x.error]);function B(){return A?(g({type:"AlertDialog",_id:"unsavedChanges",payload:{options:{dialogTitle:"Unsaved Changes",dialogMessage:"Are you sure you want to leave? There are unsaved changes. If you leave, your changes will be lost.",dialogCancelTitle:"Stay Here",dialogActionLabel:"Discard Changes",dialogActionCancel:()=>{g({type:"Dismiss",_id:"unsavedChanges",payload:{}});},dialogActionSubmit:()=>{I(false),g({type:"Dismiss",_id:"unsavedChanges",payload:{}}),$(true);}}}}),false):true}let T=useCallback(F=>{g({type:"Dismiss",_id:F,payload:{}});},[g]),P=useCallback(()=>{r.current?.submit();},[r]),j=useCallback(F=>{let U=v4(),X=Tr(m,a,F,U,{currentUser:s.user});v(gql`
|
|
389
|
+
${X}
|
|
390
|
+
`),b$1({onCompleted:()=>{At(h,Ke(m,a)),T(e._id),toast.success("Your changes have been saved.");}}),y(true);},[e._id,h,s.user,m,T,y,a,v,b$1]);return jsx(j$1,{actions:jsx(E,{disabled:!i,children:jsxs(b$3,{className:"fk:px-8 fk:min-w-32",disabled:!i,onClick:()=>{P();},variant:"default",children:[x.loading?jsx(Loader2,{className:"fk:h-4 fk:w-4 fk:mr-2 fk:animate-spin"}):null,"Save"]})}),beforeClose:B,depth:t,forceClose:N,isFocused:n,onClose:()=>{T(e._id);},title:`Add ${o}`,children:jsx(Qo,{currentScope:p,defaultScope:d$1,entityName:o,entityNamePlural:m,onSubmit:j,ref:r,schema:a,setIsDirty:I})})}function ro({entityNamePlural:e,schema:t,scope:n,variables:o,isForm:r,selection:i="full",includeCount:s=true}){let[l,c]=useState({count:0,results:[]}),[a,u]=useState(false),[d,f]=useState(false),[m,p]=useState(null),g=useRef(false),h=useRef(false),y=useRef(0),v=useRef(null),b=useRef(null),x=`${e}Total`,A=rt(t,e),N=o?.where===void 0&&(A?.spaces?.length??0)===0&&(m?.field!==x||m.schema!==t)?"total":"aggregate",$=useMemo(()=>gql(jn(e,n,t,{selection:i,countMode:N,includeCount:s}).query),[e,n,t,i,N,s]),B=useMemo(()=>gql(jn(e,n,t,{selection:i,includeCount:false}).query),[e,n,t,i]),{schemaErrorMessage:T,setSchemaErrorMessage:P}=Kt(),{loading:j,data:F,fetchMore:U,refetch:X,error:Y,networkStatus:L}=useQuery($,{variables:o,notifyOnNetworkStatusChange:true}),C=useRef(U),k=useRef(X),V=useRef(B),q=useRef(L),W=useRef(o);C.current=U,k.current=X,V.current=B,W.current=o;let se=s&&Ds(Y,x),ee=N==="total"&&se,H=se?void 0:Y,ce=se&&!F?.[e],ge=Xt(H),ae=wo(H),{isProjectDisabled:Be,isProjectReadOnly:He}=(()=>{if(ge?.statusCode===403){let O=Wt(ge.bodyText);if(O&&typeof O.code=="string"){if(O.code==="PROJECT_PAUSED")return {isProjectDisabled:true,isProjectReadOnly:false};if(O.code==="READ_ONLY_MODE")return {isProjectDisabled:false,isProjectReadOnly:true}}return {isProjectDisabled:true,isProjectReadOnly:false}}return {isProjectDisabled:false,isProjectReadOnly:false}})();useEffect(()=>{ee&&p({field:x,schema:t});},[t,ee,x]);let M=useCallback(O=>{if(g.current||h.current)return;g.current=true,u(true);let{limit:G}=O.variables,Q=y.current;C.current({...O,query:V.current,variables:{...W.current,...O.variables,offset:Q,limit:G}}).then(({data:E})=>{let D=oo({data:E,entityNamePlural:e,isForm:r,schema:t,scope:n}),S=D.results.length;y.current=Q+(S===0?0:Math.min(S,G)),c(z=>{let oe=uniqBy(prop("_id"),[...z.results,...D.results]);return oe.length===z.results.length?{count:z.results.length,results:z.results}:{count:D.count||z.count,results:oe}});}).catch(E=>{console.error("Error fetching more data:",E);}).finally(()=>{g.current=false,u(false);});},[e,r,t,n]),J=useCallback(O=>{if(h.current)return Promise.resolve();let G=O?.preserve===true;return h.current=true,g.current=false,u(false),G||(v.current=null,b.current=null,y.current=0,f(true),c({count:0,results:[]})),k.current().then(({data:Q})=>{let E=JSON.stringify({entityNamePlural:e,scope:n,selection:i,includeCount:s,variables:o}),D=oo({data:Q,entityNamePlural:e,isForm:r,schema:t,scope:n});v.current=E,b.current=null,y.current=Ko(o)+D.results.length,c(D);}).catch(Q=>{console.error("Error reloading data:",Q);}).finally(()=>{h.current=false,f(false);})},[e,r,t,n,i,s,o]);return useEffect(()=>{if(ae){P(ae);return}F&&T&&!H&&P(null);},[F,H,T,ae,P]),useEffect(()=>{if(H||ae||ce)return;let O=JSON.stringify({entityNamePlural:e,scope:n,selection:i,includeCount:s,variables:o});if(v.current===O)return;if(j&&b.current!==O){b.current=O,y.current=0,c({count:0,results:[]});return}if(j)return;let G=oo({data:F,entityNamePlural:e,isForm:r,schema:t,scope:n});v.current=O,b.current=null,y.current=Ko(o)+G.results.length,c(G);},[F,H,e,r,j,ce,t,ae,n,i,s,o]),useEffect(()=>{let O=q.current;if(q.current=L,H||ae||h.current||ce||O!==NetworkStatus.refetch||L!==NetworkStatus.ready||!F)return;let G=JSON.stringify({entityNamePlural:e,scope:n,selection:i,includeCount:s,variables:o}),Q=oo({data:F,entityNamePlural:e,isForm:r,schema:t,scope:n});v.current=G,b.current=null,y.current=Ko(o)+Q.results.length,c(Q);},[F,H,e,r,ce,L,t,ae,n,i,s,o]),useEffect(()=>{if(r)return;let O=`Get${ot(e)}`,G=ua(D=>{if(!(!D.has(O)||g.current||h.current))return k.current().then(({data:S})=>{let z=JSON.stringify({entityNamePlural:e,scope:n,selection:i,includeCount:s,variables:o}),oe=oo({data:S,entityNamePlural:e,isForm:r,schema:t,scope:n});v.current=z,b.current=null,y.current=Ko(o)+oe.results.length,c(oe);}).catch(S=>{console.error("Error soft-refreshing entity list:",S);})}),Q=fa((D,S)=>{D===O&&c(z=>{let oe=z.results.filter(on=>{let rn=typeof on._id=="string"?on._id:void 0;return !rn||!S.has(rn)}),te=z.results.length-oe.length;return te===0?z:{count:Math.max(0,z.count-te),results:oe}});}),E=da((D,S)=>{D===O&&c(z=>Lp(z,S,o?.sort));});return ()=>{G(),Q(),E();}},[e,r,t,n,i,s,o]),{isLoading:j&&L!==NetworkStatus.refetch||d||ce,isLoadingMore:a,fetchMore:M,reload:J,count:l.count,data:l.results,isProjectDisabled:Be,isProjectReadOnly:He,schemaErrorMessage:T}}function Ko(e){let t=e?.offset;return typeof t=="number"&&Number.isFinite(t)?t:0}function oo(e){let t=e.entityNamePlural;return e.data?.[t]?e.isForm?ta(e.entityNamePlural,e.scope,e.data,e.schema):To(e.entityNamePlural,e.scope,e.data,e.schema):{count:0,results:[]}}function Lp(e,t,n){let o=new Map(t.map(s=>[s._id,s])),r=false,i=e.results.map(s=>{let l=typeof s._id=="string"?s._id:void 0;if(!l)return s;let c=o.get(l);return c?(r=true,{...s,...c.attributes}):s});return r?{count:e.count,results:Pp(i,n)}:e}function Pp(e,t){if(!Array.isArray(t)||t.length===0)return e;let[n]=t;if(!n||typeof n!="object")return e;let[o]=Object.entries(n),[r,i]=o??[];if(!r||i!=="ASC"&&i!=="DESC")return e;let s=i==="DESC"?-1:1;return [...e].sort((l,c)=>{let a=l[r],u=c[r],d=typeof a=="string"?a:"",f=typeof u=="string"?u:"";return d.localeCompare(f)*s})}function Tl(){return jsxs(e,{className:"fk:mb-4",variant:"destructive",children:[jsx(AlertCircle,{className:"fk:h-4 fk:w-4"}),jsx(f,{children:"Read Only Mode"}),jsxs(g,{children:["This project is currently in read only mode and changes cannot be saved. To troubleshoot this error, please"," ",jsx("a",{className:"fk:text-blue-500 fk:underline",href:"https://flexkit.io/docs/errors/read-only-mode",target:"_blank",rel:"noopener noreferrer",children:"follow these steps"}),"."]})]})}function yi({handleSave:e,isLoading:t}){let{isDirty:n}=bn(),o=Ft();return jsx(E,{disabled:!o,children:jsxs(b$3,{className:"fk:px-8 fk:min-w-32",disabled:!n||!o,onClick:()=>{e();},variant:"default",children:[t?jsx(Loader2,{className:"fk:h-4 fk:w-4 fk:mr-2 fk:animate-spin"}):null,"Save"]})})}function vi(){return jsx(Fragment,{children:Array.from({length:10},(t,n)=>n++).map(t=>jsxs("div",{className:"fk:mt-3 fk:mb-6.5",children:[jsx(r$2,{className:"fk:w-full fk:h-[45px]"}),jsxs("div",{className:"fk:flex fk:mt-2 fk:ml-4",children:[jsx(r$2,{className:"fk:w-5 fk:mr-2"}),jsx(r$2,{className:"fk:w-[140px] fk:h-[20px]"})]})]},t))})}function wi({action:e,depth:t,isFocused:n}){let{entityId:o,entityNamePlural:r}=e.payload,i=useRef(null),{projects:s,currentProjectId:l}=d(),{schema:c,scopes:a}=useCallback(()=>find(propEq(l??"","projectId"))(s),[l,s])(),u=a?.find(H=>H.isDefault)?.name??"default",d$3=find(propEq(r,"plural"))(c),f=d$3?.name??r,{scope:m}=c$2(),[p,g]=useState(m),h=me(),y=d$2(),v=useApolloClient(),[b$1,x,A,I]=St(),{isDirty:N,setIsDirty:$}=bn(),[B,T]=useState(false),[,P]=b(),j=useCallback(H=>{$(H);},[$]);useEffect(()=>{I.error&&i.current?.hasErrors();},[I.error]);let F=useCallback(()=>N?(h({type:"AlertDialog",_id:"unsavedChanges",payload:{options:{dialogTitle:"Unsaved Changes",dialogMessage:"Are you sure you want to leave? There are unsaved changes. If you leave, your changes will be lost.",dialogCancelTitle:"Stay Here",dialogActionLabel:"Discard Changes",dialogActionCancel:()=>{h({type:"Dismiss",_id:"unsavedChanges",payload:{}});},dialogActionSubmit:()=>{$(false),h({type:"Dismiss",_id:"unsavedChanges",payload:{}}),T(true);}}}}),false):true,[h,N,$]),U=useCallback(H=>{h({type:"Dismiss",_id:H,payload:{}});},[h]),X=useCallback(()=>{i.current?.submit();},[i]);function Y(H){if(N){h({type:"AlertDialog",_id:"unsavedChanges",payload:{options:{dialogTitle:"Unsaved Changes",dialogMessage:"You have unsaved changes. Switching scopes will discard them.",dialogCancelTitle:"Stay Here",dialogActionLabel:"Discard Changes",dialogActionCancel:()=>{g(p),h({type:"Dismiss",_id:"unsavedChanges",payload:{}});},dialogActionSubmit:()=>{h({type:"Dismiss",_id:"unsavedChanges",payload:{}}),g(H),y({type:"setScope",payload:{projectId:l,scope:H}});}}}});return}g(H),y({type:"setScope",payload:{projectId:l,scope:H}});}let{isLoading:L,data:C}=ro({entityNamePlural:r,schema:c,scope:p,variables:{where:{_id:{eq:o}}},isForm:true,includeCount:false}),k=useCallback((H,ce)=>{if(!ce)return;let ge=Er(r,o,p,c,ce,H,{currentUser:P.user});x(gql`
|
|
391
|
+
${ge}
|
|
392
|
+
`),A({variables:{where:{_id:{eq:o}}},onCompleted:ae=>{i.current?.applyLocalAttributeIds(la(ae,r,c)),At(v,Ke(r,c)),toast.success("Your changes have been saved.");}}),b$1(true);},[v,P.user,p,o,r,b$1,c,x,A]),V=C,q=V.length>0,W=L&&!q;function se(H,ce){let ge=e$5(H),ae=ge?.name,Be=ge?.relationship?.field!==void 0;if(!ce.length||!ae)return "";if(!Be||!ge?.relationship?.field)return ce[0][ae]?.value;let He=ce[0][ae]?.value?.[ge.relationship.field],M=Array.isArray(He)?He[0]:He;if(M&&typeof M=="object"){let J=M;return J[p]??J.default??""}return M??""}let ee=q&&d$3?se(d$3,V):"";return jsx(j$1,{actions:jsxs(Fragment,{children:[a&&a.length>1?jsxs(a$4,{onValueChange:H=>{Y(H);},value:p,children:[jsxs(d$1,{className:"fk:w-[12rem] fk:h-9",id:"project",children:[jsx("span",{className:"fk:text-muted-foreground",children:"Scope:\xA0"}),jsx(c$1,{children:find(propEq(p,"name"))(a).label})]}),jsx(e$2,{children:a.map(H=>jsx(g$2,{value:H.name,children:H.label},H.name))})]}):null,jsx(yi,{handleSave:X,isLoading:I.loading})]}),beforeClose:F,depth:t,forceClose:B,isFocused:n,onClose:()=>{U(e._id);},onFormChange:()=>{},title:ee,children:W||!q?jsx(vi,{}):jsxs(Fragment,{children:[I.isProjectReadOnly?jsx(Tl,{}):null,jsx(Qo,{currentScope:p,defaultScope:u,entityId:o,entityName:f,entityNamePlural:r,formData:V[0],onSubmit:k,ref:i,schema:c,setIsDirty:j})]})})}var Ml=25;function Qp(e){return e.map(t=>({...t,cell:()=>jsx(r$2,{className:"fk:h-4 fk:w-full",style:{marginTop:"7px",marginBottom:"6px"}})}))}function Ei({action:e,depth:t,isFocused:n}){let o=me(),r=d$2(),{relationships:i,scope:s}=c$2(),{assetAccept:l,connectedEntitiesCount:c,connectionName:a,entityId:u,entityName:d$1,initialAssetPath:f,initialConnection:m,mode:p,relationshipId:g}=e.payload,{projects:h,currentProjectId:y}=d(),{schema:v}=find(propEq(y??"","projectId"))(h),b=find(propEq(d$1,"name"))(v),x=b?.plural??"",A=i[g],I=Gn(),N=d$1==="_asset",$=N?"asset":b?.menu?.label??d$1.toLowerCase(),B=N&&p==="single"?"Select asset":`Select ${N?"assets":$}`,T=p==="single"?"Upload asset":"Upload assets",[P,j]=useState([]),F=[];if(m)F=[{id:m._id,value:m.value}];else if(A?.connect){let D=A.connect;F=[{id:D._id,value:D.value}];}let U=p==="single"?F:A?.connect?.map(D=>({id:D._id,value:D.value}))||[],[X,Y]=useState(U),L=useMemo(()=>{let D=[];return N&&D.push({NOT:{path:{eq:null}}}),p==="multiple"&&a&&u&&D.push({[a]:{none:{_id:{eq:u}}}}),P.length>0&&D.push({OR:P.map(S=>({_id:{eq:S._id}}))}),D.length===0?{}:D.length===1?D[0]:{AND:D}},[a,u,N,p,P]),{count:C,data:k,fetchMore:V,isLoading:q,isLoadingMore:W}=ro({entityNamePlural:x,schema:v,scope:s,variables:{offset:0,limit:Ml,where:L,sort:[{_updatedAt:"DESC"},{_id:"DESC"}]},selection:"list"}),se=!!k?.length,ee=q&&!se,H=k?.length??0,ce=C-c,ge=ce>0&&H>0&&H<ce,ae=Yn({attributesSchema:b?.attributes??[],checkboxSelect:p}),Be=Array(5).fill({}),He=Qp(ae);useEffect(()=>{if(p!=="single"||X.length>0||!f||!k?.length)return;let D=k.find(S=>S.path===f);!D?._id||typeof D._id!="string"||Y([{id:D._id,value:D}]);},[k,f,p,X.length]);let M=useCallback(D=>{o({type:"Dismiss",_id:D,payload:{}});},[o]),J=useCallback(()=>{V({variables:{offset:0,limit:Ml,where:L}});},[L,V]);function O(){let D;if(p==="single"){let[S]=X;D={_id:S?.id??"",value:S?.value??null};}p==="multiple"&&(D=X?.map((S,z)=>({_id:S.id??"",...N?{sortOrder:z}:{},value:S.value}))),r({type:"setRelationship",payload:{[g]:{connect:D,disconnect:A?.disconnect??[]}}}),M(e._id);}function G(D){if(p==="multiple"){Y(z=>{let oe=new Map(z.map(te=>[te.id,te]));return D.map(te=>{if(oe.has(te))return oe.get(te);let on=k?.find(rn=>rn._id===te);return {id:te,value:on}})});return}let S=D[D.length-1];Y(S?z=>{if(z.length===1&&z[0].id===S)return z;let oe=k?.find(te=>te._id===S);return [{id:S,value:oe}]}:[]);}function Q(){o({type:"AddEntity",payload:{entityName:d$1}});}async function E(){let D=await I({projectId:y,accept:l??"image/*",multiple:p==="multiple",maxBytes:4194304});Y(S=>{if(p==="single"){let[te]=D;return te?[{id:te._id,value:te.asset}]:S}let z=new Set(S.map(te=>te.id)),oe=D.filter(te=>!z.has(te._id)).map(te=>({id:te._id,value:te.asset}));return [...S,...oe]});}return jsx(j$1,{actions:jsxs(Fragment,{children:[jsx(b$3,{className:"fk:px-8",onClick:()=>{O();},variant:"default",children:"Select"}),N?null:jsx(b$3,{className:"fk:px-8",onClick:()=>{Q();},variant:"outline",children:`Create ${$}`}),N?jsxs(b$3,{className:"fk:px-8",onClick:()=>{E();},variant:"outline",children:[jsx(Upload,{className:"fk:mr-2 fk:h-4 fk:w-4"}),T]}):null]}),depth:t,isFocused:n,onClose:()=>{M(e._id);},title:B,children:jsx("div",{className:"fk:h-[calc(100vh-10rem)] fk:min-h-0",children:jsx(eo,{columns:ee?He:ae,data:ee?Be:k??[],entityName:b?.name??"",hasMore:ge,initialSelectionState:X?.reduce((D,S)=>({...D,...S.id?{[S.id]:true}:{}}),{}),isLoadingMore:W,onEntitySelectionChange:G,onLoadMore:J,toolbarComponent:()=>jsx(Xp,{entityNamePlural:x,projectId:y??"",setSearchResultIds:j})})})})}function Xp({entityNamePlural:e,projectId:t,setSearchResultIds:n}){let[o,r]=useState(""),i=useMemo(()=>({searchRequests:{searches:[{collection:e}]},commonParams:{q:""}}),[e]),[s,l]=useState(i),{results:c,isLoading:a}=f$4(t,s),u=useRef(null),d=useMemo(()=>Wp(m=>{l({...i,commonParams:{q:m}});},300),[i]);useEffect(()=>{if(c){let m=JSON.stringify(c.map(g=>g._id).sort()),p=u.current?JSON.stringify(u.current.map(g=>g._id).sort()):"";m!==p&&(u.current=[...c],n(c.map(g=>({_id:g._id}))));}},[c,n]);function f(m){let{value:p}=m.target;r(p),d(p);}return jsxs("div",{className:"fk:relative fk:w-full",children:[a?jsx(LoaderCircle,{className:"fk:absolute fk:left-4 fk:top-3 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50 fk:animate-spin"}):jsx(Search,{className:"fk:absolute fk:left-4 fk:top-3 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50"}),jsx(a$6,{className:"fk:w-full fk:pl-11!",onChange:f,placeholder:"Search",value:o})]})}function Wp(e,t=300){let n;return (...o)=>{clearTimeout(n),n=setTimeout(()=>e(...o),t);}}function $l(){let e=Xs(),t=e.filter(o=>["AddEntity","EditEntity","EditRelationship"].some(r=>r===o.type)),n=t[t.length-1]?._id;return jsx(Fragment,{children:e.map(o=>{switch(o.type){case "AlertDialog":{let{payload:r}=o;return jsx(_n,{options:r.options},o._id)}case "DeleteEntity":return jsx(Ir,{action:o},o._id);case "AddEntity":return jsx(gi,{action:o,depth:t.length-1,isFocused:o._id===n},o._id);case "EditEntity":return jsx(wi,{action:o,depth:t.length-1,isFocused:o._id===n},o._id);case "EditRelationship":return jsx(Ei,{action:o,depth:t.length-1,isFocused:o._id===n},o._id);default:return null}})})}function Ol({config:e}){let[t]=e,{basePath:n,projectId:o}=t,r=a$g(n);return window.location.pathname===r&&(window.location.href=b$a(r,o)),jsx(a$j,{children:jsx(c$7,{config:e,children:jsxs(Ps,{children:[jsx(ka,{children:jsx($l,{})}),jsx(Outlet,{})]})})})}function Vl(){let e=useRouteError(),t=new Date().getFullYear();function n(){return isRouteErrorResponse(e)?e.status===404?jsxs(Fragment,{children:[jsx("h1",{className:"fk:mb-4 fk:text-7xl fk:text-center fk:font-bold fk:tracking-tight",children:"404"}),jsx("p",{className:"fk:mt-2 fk:mb-2 fk:text-base fk:text-center fk:text-muted-foreground",children:"Page not found"})]}):jsxs(Fragment,{children:[jsx("h1",{className:"fk:mb-4 fk:text-4xl fk:text-center fk:font-bold fk:tracking-tight",children:"Oops!"}),jsx("p",{className:"fk:mt-2 fk:mb-2 fk:text-base fk:text-center fk:text-muted-foreground",children:"Sorry, an unexpected error has occurred:"}),jsx("p",{className:"fk:text-base fk:text-center",children:jsx("i",{children:e.statusText})})]}):ur(e)?ps(e)==="PROJECT_NOT_FOUND"?jsxs(Fragment,{children:[jsx("h1",{className:"fk:mb-4 fk:text-4xl fk:text-center fk:font-bold fk:tracking-tight",children:"Project not found"}),jsx("p",{className:"fk:mt-2 fk:mb-2 fk:text-base fk:text-center fk:text-muted-foreground",children:"The requested project ID was not found"})]}):jsxs(Fragment,{children:[jsx("h1",{className:"fk:mb-4 fk:text-4xl fk:text-center fk:font-bold fk:tracking-tight",children:"Oops!"}),jsx("p",{className:"fk:mt-2 fk:mb-2 fk:text-base fk:text-center fk:text-muted-foreground",children:"Sorry, an unexpected error has occurred. Please try again."})]}):e instanceof Error?jsxs(Fragment,{children:[jsx("h1",{className:"fk:mb-4 fk:text-4xl fk:text-center fk:font-bold fk:tracking-tight",children:"Oops!"}),jsx("p",{className:"fk:mt-2 fk:mb-2 fk:text-base fk:text-center fk:text-muted-foreground",children:"Sorry, an unexpected error has occurred:"}),jsx("p",{className:"fk:text-base fk:text-center",children:jsx("i",{children:e.message})})]}):null}return jsxs(Fragment,{children:[jsx("div",{className:"fk:container fk:relative fk:h-[calc(100vh-3rem)] fk:flex fk:items-center fk:justify-center fk:lg:px-0",children:jsx("div",{className:"fk:w-full fk:lg:p-8",children:jsx("div",{className:"fk:mx-auto fk:flex fk:w-full fk:flex-col fk:justify-center fk:sm:w-[350px]",children:n()})})}),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 fk:dark: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 ",t]})]}),jsx(ho,{})]})})]})}function Ti(){let e$1=useRouteError(),t=e$1 instanceof Error?e$1.message:"An unexpected error has occurred. Please try refreshing the page.";return jsxs(e,{variant:"destructive",children:[jsx(AlertCircle,{className:"fk:h-4 fk:w-4"}),jsx(f,{children:"Error"}),jsx(g,{children:t})]})}var fg=RouterProvider;function dg({config:e}){let[t,n]=useState(false),o=debug("core:flexkit-studio"),r=Array.isArray(e)?e.map(u=>Bl(u)):[Bl(e)],[i]=r,s=a$g(i?.basePath),l=e$6(r);if(useEffect(()=>{n(true);},[]),!t)return null;let c=[{path:s,element:jsx(Ol,{config:r}),errorElement:jsx(Vl,{}),children:[{path:":projectId",element:jsx(xs,{version:{current:"1.0.0",latest:"1.0.0",isCurrent:true}}),children:l.map(u=>({path:u.name,element:u.component,errorElement:jsx(Ti,{}),children:u.routes?.map(d=>({path:d.path,element:d.component,errorElement:jsx(Ti,{}),children:d.children?.map(f=>({path:f.path,element:f.component}))}))}))}]}],a=createBrowserRouter(c);return o("Init Studio"),jsx(a$h,{attribute:"class",defaultTheme:"system",disableTransitionOnChange:true,enableSystem:true,children:jsx(b$9,{children:jsx(Qs,{children:jsx(fg,{router:a})})})})}function Bl(e){return {basePath:a$g(e.basePath),menuGroups:e.menuGroups??[],icon:e.icon,extensions:e.extensions,projectId:e.projectId,title:e.title,schema:e.schema,scopes:e.scopes}}function pg(){return jsxs(e,{variant:"destructive",children:[jsx(AlertCircle,{className:"fk:h-4 fk:w-4"}),jsx(f,{children:"Project Paused"}),jsxs(g,{children:["This project has been paused. To troubleshoot this error, please"," ",jsx("a",{className:"fk:text-blue-500 fk:underline",href:"https://flexkit.io/docs/errors/project-paused",target:"_blank",rel:"noopener noreferrer",children:"follow these steps"}),"."]})]})}function kg(){let{schemaErrorMessage:e$1}=Kt();if(!e$1)return jsx(Fragment,{});let[t,n,...o]=e$1.split(`
|
|
393
|
+
`);return jsxs(e,{className:"fk:mb-4",variant:"destructive",children:[jsx(AlertCircle,{className:"fk:h-4 fk:w-4"}),jsx(f,{children:"Schema mismatch"}),jsxs(g,{children:[jsx("p",{children:t}),n?jsx("p",{className:"fk:mt-1",children:n}):null,o.length>0?jsx("ul",{className:"fk:mt-2 fk:list-disc fk:pl-4",children:o.map(r=>jsx("li",{children:r.replace(/^- /,"")},r))}):null]})]})}function yg(e){return e}function vg(e){return e}function bg(e,t){if(e.dataType==="asset"&&e.scope!==void 0&&e.scope!=="global")throw new Error(`Attribute "${e.name}" in entity "${t}" uses dataType "asset" but scope "${e.scope}". Asset attributes must use scope "global" or omit scope.`)}function Cg(e){return e.dataType!=="asset"?e:{...e,scope:"global"}}function wg(e){let t=e.display?e.attributes.find(n=>n.name===e.display):e.attributes[0];if(e.display&&!t)throw new Error(`Entity "${e.name}" sets display to "${e.display}", but no attribute has that name.`);if(!(!t||(t.spaces??[]).length===0))throw new Error(`Entity "${e.name}" cannot use space-bound attribute "${t.name}" as its display field.`)}function ql(e){return e.attributes.forEach(t=>{bg(t,e.name);}),wg(e),{...e,attributes:e.attributes.map(Cg)}}function Sg(e){return ql(e)}function Ag(e){let t=useApolloClient(),{currentProjectSchema:n}=d();return useCallback(async()=>{n&&await At(t,Ke(e,n));},[t,e,n])}function Ng(e){let{currentProjectSchema:t}=d();return useCallback(n=>{t&&ma(Ke(e,t),n);},[e,t])}function Rg({column:e,title:t$2,options:n}){let o=new Set(e?.getFilterValue());return jsxs(r,{children:[jsx(s,{asChild:true,children:jsxs(b$3,{variant:"outline",size:"sm",className:"fk:h-8 fk:border-dashed",children:[jsx(CirclePlus,{className:"fk:mr-2 fk:h-4 fk:w-4"}),t$2,o?.size>0&&jsxs(Fragment,{children:[jsx(c$5,{orientation:"vertical",className:"fk:mx-2 fk:h-4"}),jsx(b$6,{variant:"secondary",className:"fk:rounded-xs fk:px-1 fk:font-normal fk:lg:hidden fk:corner-squircle",children:o.size}),jsx("div",{className:"fk:space-x-1 fk:lg:flex",children:o.size>2?jsxs(b$6,{variant:"secondary",className:"fk:rounded-xs fk:px-1 fk:font-normal fk:corner-squircle",children:[o.size," selected"]}):n.filter(r=>o.has(r.value)).map(r=>jsx(b$6,{variant:"secondary",className:"fk:rounded-xs fk:px-1 fk:font-normal fk:corner-squircle",children:r.label},r.value))})]})]})}),jsx(t,{className:"fk:w-50 fk:p-0",align:"start",children:jsxs(n$1,{children:[jsx(p,{placeholder:t$2}),jsxs(q$1,{children:[jsx(r$1,{children:"No results found."}),jsx(s$1,{children:n.map(r=>{let i=o.has(r.value);return jsxs(u,{onSelect:()=>{i?o.delete(r.value):o.add(r.value);let s=Array.from(o);e?.setFilterValue(s.length?s:void 0);},children:[jsx("div",{className:a$8("fk:mr-2 fk:flex fk:h-4 fk:w-4 fk:items-center fk:justify-center fk:rounded-xs fk:border fk:border-primary fk:corner-squircle",i?"fk:bg-primary fk:text-primary-foreground":"fk:opacity-50 fk:[&_svg]:invisible"),children:jsx(Check,{className:a$8("fk:size-3.5",i?"fk:text-primary-foreground":"fk:text-muted-foreground")})}),r.icon&&jsx(r.icon,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:text-muted-foreground"}),jsx("span",{children:r.label})]},r.value)})}),o.size>0&&jsxs(Fragment,{children:[jsx(t$1,{}),jsx(s$1,{children:jsx(u,{onSelect:()=>e?.setFilterValue(void 0),className:"fk:justify-center fk:text-center",children:"Clear filters"})})]})]})]})})]})}function Lg({entityName:e,entityNamePlural:t,row:n,options:o={canDelete:true,canEdit:true}}){let r=me(),i=Ft(),s=n.original._id,l=(o.canDelete??true)&&i,c=o.canEdit??true;function a(){r({type:"EditEntity",payload:{entityId:s,entityNamePlural:t}});}function u(){r({type:"DeleteEntity",payload:{entityId:s,entityName:e}});}return jsxs("div",{className:"fk:flex",children:[c&&jsxs(b$3,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1",onClick:a,variant:"ghost",children:[jsx(PencilIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Edit"})]}),l&&!c&&jsxs(b$3,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1",onClick:u,variant:"ghost",children:[jsx(Trash2Icon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Delete"})]}),c&&l&&jsxs(c$3,{children:[jsx(e$3,{asChild:true,children:jsxs(b$3,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0",variant:"ghost",children:[jsx(Ellipsis,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Additional actions"})]})}),jsxs(f$3,{align:"end",className:"w-[160px]",children:[jsxs(h$1,{onClick:a,children:[jsx(PencilIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Edit"]}),jsx(m$1,{}),jsxs(h$1,{className:"fk:text-destructive",onClick:u,children:[jsx(Trash2Icon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete"]})]})]})]})}function Di({table:e}){let[t]=e.getState().sorting;if(!t)return null;let o=e.getColumn(t.id)?.columnDef.meta?.label??t.id,r=t.desc?"desc":"asc";return jsxs(b$3,{"aria-label":`Clear sorting by ${o}`,className:"fk:h-8 fk:px-2 fk:lg:px-3 fk:text-success fk:border-none",onClick:()=>{e.resetSorting();},size:"sm",variant:"outline",children:["Sorted by ",o," ",r,jsx(X,{className:"fk:ml-1 fk:h-4 fk:w-4"})]})}function Ri({table:e}){return jsxs(c$3,{children:[jsx(e$3,{asChild:true,children:jsxs(b$3,{className:"fk:hidden fk:h-8 fk:lg:flex",size:"sm",variant:"outline",children:[jsx(Settings2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"View"]})}),jsxs(f$3,{align:"end",className:"fk:w-[150px]",children:[jsx(l$1,{children:"Toggle columns"}),jsx(m$1,{}),e.getAllColumns().filter(t=>typeof t.accessorFn<"u"&&t.getCanHide()).map(t=>jsx(i$1,{checked:t.getIsVisible(),className:"capitalize",onCheckedChange:n=>{t.toggleVisibility(!!n);},children:t.id},t.id))]})]})}function Hg({entityName:e,isReloading:t=false,onReload:n,table:o}){let r=me(),i=d$2(),s=c$2(),l=useApolloClient(),{projects:c,currentProjectId:a}=d(),{schema:u,scopes:d$3}=find(propEq(a??"","projectId"))(c),[f,m,p]=St(),[g,h]=useState(false),y=Ft(),v=o.getSelectedRowModel().rows.map(N=>N.original._id);function b(){r({type:"AddEntity",payload:{entityName:e}});}function x(N){i({type:"setScope",payload:{projectId:a,scope:N}});}async function A(N){if(N.length===0)return;let $=Hn(e,u,N);await new Promise((B,T)=>{m(gql`
|
|
394
|
+
${$}
|
|
395
|
+
`),p({variables:{where:Un(N)},update(P){for(let j of N)P.evict({id:j});},onCompleted:()=>{B();},onError:P=>{T(P);}}),f(true);});}function I(){let N=e==="_asset"?"asset":e.toLowerCase();r({type:"AlertDialog",payload:{options:{dialogTitle:`Delete ${v.length} ${N}${v.length>1?"s":""}`,dialogMessage:v.length>1?`Are you sure you want to delete the selected ${N}s? They will be deleted permanently.`:`Are you sure you want to delete the selected ${N}? The item will be deleted permanently.`,dialogCancelTitle:"Cancel",dialogActionLabel:"Delete",isDestructive:true,dialogActionSubmit:async()=>{h(true);try{let $=[...v];await A($),o.resetRowSelection(),await Do(l,Ke(e,u),$),toast.success($.length>1?"Items successfully deleted.":"Item successfully deleted.");}catch{toast.error("Failed to delete selected items.");}finally{h(false);}},dialogActionCancel:()=>{}}}});}return jsxs("div",{className:"fk:flex fk:items-center fk:justify-between",children:[jsxs("div",{className:"fk:flex fk:flex-1 fk:items-center fk:space-x-2",children:[d$3&&d$3.length>0?jsxs(a$4,{defaultValue:s.scope,onValueChange:N=>{x(N);},value:s.scope,children:[jsxs(d$1,{className:"fk:w-48!",id:"project",size:"sm",children:[jsx("span",{className:"fk:text-muted-foreground",children:"Scope:"}),jsx(c$1,{children:(find(propEq(s.scope??"","name"))(d$3)||null)?.label})]}),jsx(e$2,{children:d$3.map(N=>jsx(g$2,{value:N.name,children:N.label},N.name))})]}):null,jsx(Ri,{table:o}),n?jsx(b$3,{"aria-label":"Reload",className:"fk:h-8",disabled:g||t,onClick:n,size:"icon-sm",variant:"outline",children:jsx(RefreshCw,{className:t?"fk:animate-spin":void 0})}):null,jsx(Di,{table:o})]}),v.length>0?jsx(E,{disabled:!y,children:jsxs(b$3,{className:"fk:h-8 fk:mr-2 fk:lg:flex",disabled:g||!y,onClick:I,size:"sm",variant:"destructive",children:[g?jsx(Loader2,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):jsx(Trash2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete (",v.length,")"]})}):null,jsx(E,{disabled:!y,children:jsx(b$3,{className:"fk:ml-auto fk:h-8 fk:lg:flex",disabled:g||!y,onClick:b,size:"sm",variant:"default",children:"Create"})})]})}export{ai as ALL_FIELDS_GROUP,tn as ALL_FIELDS_GROUP_NAME,eo as DataTable,Vo as DataTableColumnHeader,Rg as DataTableFacetedFilter,Lg as DataTableRowActions,Di as DataTableSortedBy,Hg as DataTableToolbar,Ri as DataTableViewOptions,dg as FlexkitStudio,pg as ProjectDisabled,kg as SchemaError,Lr as canAccessSpaces,bl as canMutateData,yg as defineConfig,Sg as defineEntity,vg as defineExtension,Cn as filterAttributesForSpaces,Zu as filterEntitiesForSpaces,Tr as getEntityCreateMutation,Hn as getEntityDeleteMutation,Un as getEntityDeleteWhere,jn as getEntityQuery,rt as getEntitySchema,Er as getEntityUpdateMutation,Eu as getSortNotNullWhere,Ft as useCanMutate,me as useDispatch,St as useEntityMutation,ro as useEntityQuery,Kt as useGraphQLError,Yn as useGridColumnsDefinition,Ng as usePatchEntityList,Ag as useRefreshEntityList,Gn as useUploadAssets};//# sourceMappingURL=index.js.map
|
|
400
396
|
//# sourceMappingURL=index.js.map
|