import { useMemo } from "react";
import dayjs from "dayjs";
import { useCurrentUserVariable, useDatetimeVariable, useExactDateVariable } from "../../schema-settings/index.mjs";
import { useCurrentRoleVariable } from "../../schema-settings/VariableInput/hooks/useRoleVariable.mjs";
const useBuiltInVariables = ()=>{
    const { currentUserCtx } = useCurrentUserVariable();
    const { currentRoleCtx } = useCurrentRoleVariable();
    const { datetimeCtx } = useDatetimeVariable();
    const { exactDateTimeCtx } = useExactDateVariable();
    const builtinVariables = useMemo(()=>[
            {
                name: '$user',
                ctx: currentUserCtx,
                collectionName: 'users'
            },
            {
                name: '$nRole',
                ctx: currentRoleCtx,
                collectionName: 'roles'
            },
            {
                name: 'currentUser',
                ctx: currentUserCtx,
                collectionName: 'users'
            },
            {
                name: '$nDate',
                ctx: datetimeCtx
            },
            {
                name: '$date',
                ctx: datetimeCtx
            },
            {
                name: '$nExactDate',
                ctx: exactDateTimeCtx
            },
            {
                name: '$system',
                ctx: {
                    now: ()=>dayjs().toISOString()
                }
            },
            {
                name: 'currentTime',
                ctx: ()=>dayjs().toISOString()
            }
        ], [
        currentUserCtx,
        exactDateTimeCtx
    ]);
    return {
        builtinVariables
    };
};
const useBuiltinVariables = useBuiltInVariables;
export { useBuiltinVariables as default };
