import { jsx } from "react/jsx-runtime";
import "react";
import { useFieldSchema, useForm } from "@tachybase/schema";
import { Button } from "antd";
import { useTranslation } from "react-i18next";
import { useDesignable } from "../../hooks/index.mjs";
const SaveDefaultValue = (props)=>{
    const { t } = useTranslation();
    const { designable, dn, refresh } = useDesignable();
    const fieldSchema = useFieldSchema();
    const form = useForm();
    if (!designable) return null;
    return /*#__PURE__*/ jsx(Button, {
        style: {
            borderColor: 'var(--colorSettings)',
            color: 'var(--colorSettings)'
        },
        type: 'dashed',
        onClick: ()=>{
            var _fieldSchema_parent_parent_parent_properties, _fieldSchema_parent_parent_parent, _fieldSchema_parent_parent, _fieldSchema_parent;
            const filterSchema = null == fieldSchema ? void 0 : null == (_fieldSchema_parent = fieldSchema.parent) ? void 0 : null == (_fieldSchema_parent_parent = _fieldSchema_parent.parent) ? void 0 : null == (_fieldSchema_parent_parent_parent = _fieldSchema_parent_parent.parent) ? void 0 : null == (_fieldSchema_parent_parent_parent_properties = _fieldSchema_parent_parent_parent.properties) ? void 0 : _fieldSchema_parent_parent_parent_properties.filter;
            if (!filterSchema) return;
            const defaultValue = form.values.filter;
            dn.emit('patch', {
                schema: {
                    'x-uid': filterSchema['x-uid'],
                    default: defaultValue
                }
            });
            dn.refresh();
            filterSchema.default = defaultValue;
        },
        children: t('Save conditions')
    });
};
export { SaveDefaultValue };
