import { jsx, jsxs } from "react/jsx-runtime";
import "react";
import { useFieldSchema } from "@tachybase/schema";
import { createStyles } from "antd-style";
import classnames from "classnames";
import { withDynamicSchemaProps } from "../../../application/hoc/withDynamicSchemaProps.mjs";
import { SortableItem } from "../../common/index.mjs";
import { useDesigner, useProps } from "../../hooks/index.mjs";
import { useGetAriaLabelOfBlockItem } from "./hooks/useGetAriaLabelOfBlockItem.mjs";
function _tagged_template_literal(strings, raw) {
    if (!raw) raw = strings.slice(0);
    return Object.freeze(Object.defineProperties(strings, {
        raw: {
            value: Object.freeze(raw)
        }
    }));
}
function _templateObject() {
    const data = _tagged_template_literal([
        "\n    position: relative;\n    &:hover {\n      > .general-schema-designer {\n        display: block;\n      }\n    }\n    &.tb-form-item:hover {\n      > .general-schema-designer {\n        background: var(--colorBgSettingsHover) !important;\n        border: 0 !important;\n        top: -5px !important;\n        bottom: -5px !important;\n        left: -5px !important;\n        right: -5px !important;\n      }\n    }\n    > .general-schema-designer {\n      position: absolute;\n      z-index: 999;\n      top: 0;\n      bottom: 0;\n      left: 0;\n      right: 0;\n      display: none;\n      border: 2px solid var(--colorBorderSettingsHover);\n      pointer-events: none;\n      > .general-schema-designer-icons {\n        position: absolute;\n        right: 2px;\n        top: 2px;\n        line-height: 16px;\n        pointer-events: all;\n        .ant-space-item {\n          background-color: var(--colorSettings);\n          color: #fff;\n          line-height: 16px;\n          width: 16px;\n          padding-left: 1px;\n          align-self: stretch;\n        }\n      }\n    }\n  "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const useStyles = createStyles((param)=>{
    let { css } = param;
    return css(_templateObject());
});
const BlockItem = withDynamicSchemaProps((props)=>{
    const { className, children } = useProps(props);
    const { styles } = useStyles();
    const Designer = useDesigner();
    const fieldSchema = useFieldSchema();
    const { getAriaLabel } = useGetAriaLabelOfBlockItem(props.name);
    return /*#__PURE__*/ jsxs(SortableItem, {
        role: "button",
        "aria-label": getAriaLabel(),
        className: classnames('tb-block-item', className, styles),
        children: [
            /*#__PURE__*/ jsx(Designer, {
                ...fieldSchema['x-toolbar-props']
            }),
            children
        ]
    });
});
export { BlockItem };
