import { jsx } from "react/jsx-runtime";
import "react";
import { useField, useFieldSchema } from "@tachybase/schema";
import { useTranslation } from "react-i18next";
import { SchemaSettings } from "../../application/index.mjs";
import { useDesignable } from "../../schema-component/index.mjs";
import { SchemaSettingsSelectItem } from "../../schema-settings/index.mjs";
import { CustomSchemaSettingsBlockTitleItem } from "./SchemaSettingsBlockTitleItem.mjs";
const QuickAccessLayout = {
    Grid: 'grid',
    List: 'list'
};
const ActionPanelLayout = ()=>{
    var _fieldSchema_xcomponentprops;
    const { t } = useTranslation();
    const fieldSchema = useFieldSchema();
    const field = useField();
    const { dn } = useDesignable();
    return /*#__PURE__*/ jsx(SchemaSettingsSelectItem, {
        title: t('Layout'),
        options: [
            {
                label: t('Grid'),
                value: QuickAccessLayout.Grid
            },
            {
                label: t('List'),
                value: QuickAccessLayout.List
            }
        ],
        value: (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.layout) || QuickAccessLayout.Grid,
        onChange: (value)=>{
            field.componentProps.layout = value;
            const schema = {
                'x-uid': fieldSchema['x-uid']
            };
            fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
            schema['x-component-props'] = fieldSchema['x-component-props'] || {};
            schema['x-component-props'].layout = value;
            fieldSchema['x-component-props'].layout = value;
            dn.emit('patch', {
                schema: schema
            });
            dn.refresh();
        }
    });
};
const quickAccessBlockSettings = new SchemaSettings({
    name: 'blockSettings:quickAccess',
    items: [
        {
            name: 'title',
            Component: CustomSchemaSettingsBlockTitleItem
        },
        {
            name: 'layout',
            Component: ActionPanelLayout
        },
        {
            type: 'remove',
            name: 'remove'
        }
    ]
});
export { QuickAccessLayout, quickAccessBlockSettings };
