import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE_antd_style__ from "antd-style";
import * as __WEBPACK_EXTERNAL_MODULE__application_index_mjs__ from "../../application/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__icon_index_mjs__ from "../../icon/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../schema-component/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__Block_mjs__ from "./Block.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__blockSettings_mjs__ from "./blockSettings.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    background-color: transparent;\n    border: 0;\n    height: auto;\n    box-shadow: none;\n  "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
function _templateObject1() {
    const data = _tagged_template_literal([
        "\n    margin-top: ",
        "px;\n    text-overflow: ellipsis;\n    overflow: hidden;\n  "
    ]);
    _templateObject1 = function() {
        return data;
    };
    return data;
}
const useStyles = (0, __WEBPACK_EXTERNAL_MODULE_antd_style__.createStyles)((param)=>{
    let { token, css } = param;
    return {
        action: css(_templateObject()),
        title: css(_templateObject1(), token.marginSM)
    };
});
function Button() {
    var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1;
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const icon = null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops['icon'];
    const backgroundColor = null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1['iconColor'];
    const { layout } = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__Block_mjs__.QuickAccessBlockContext);
    const { styles, cx } = useStyles();
    return layout === __WEBPACK_EXTERNAL_MODULE__blockSettings_mjs__.QuickAccessLayout.Grid ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
        title: fieldSchema.title,
        style: {
            width: '70px',
            overflow: 'hidden'
        },
        children: [
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Avatar, {
                style: {
                    backgroundColor
                },
                size: 54,
                icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__icon_index_mjs__.Icon, {
                    type: icon
                })
            }),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                className: cx(styles.title),
                children: fieldSchema.title
            })
        ]
    }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("a", {
        children: fieldSchema.title
    });
}
const QuickAccessAction = (0, __WEBPACK_EXTERNAL_MODULE__application_index_mjs__.withDynamicSchemaProps)((props)=>{
    const { className, ...others } = props;
    const { styles, cx } = useStyles();
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const Component = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useComponent)(null == props ? void 0 : props.targetComponent) || __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.Action;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Component, {
        className: cx(className, styles.action),
        ...others,
        icon: null,
        title: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Button, {}),
        confirmTitle: fieldSchema.title
    });
});
export { QuickAccessAction };
