"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Select = void 0;
const cn_ui_1 = require("@cainiaofe/cn-ui");
const react_1 = __importStar(require("react"));
const mapStatus_1 = require("../../mapStatus.js");
const { connect, useFieldSchema, mapProps } = cn_ui_1.formilyReact;
exports.Select = connect((props) => {
    var _a, _b, _c, _d;
    const fieldSchema = useFieldSchema();
    const ComponentUI = (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.cnLowCodeUtils) === null || _a === void 0 ? void 0 : _a.filterItem) === null || _b === void 0 ? void 0 : _b.getRunTimeItem) === null || _c === void 0 ? void 0 : _c.call(_b, 'Select');
    if (!(ComponentUI === null || ComponentUI === void 0 ? void 0 : ComponentUI.formComponent)) {
        return null;
    }
    (0, react_1.useEffect)(() => {
        const dom = document.querySelector('#cn-ui-page-scroll-container > div.cn-next-overlay-wrapper.v2.opened > div > span');
        if (dom) {
            dom.click();
        }
    }, []);
    // 解决低码中绑定数据源时，由于异步加载导致dataSource为空的问题
    const dataSource = (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.enum) || ((_d = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component-props']) === null || _d === void 0 ? void 0 : _d.dataSource) || [];
    const extraProps = {};
    if (dataSource.length > 0) {
        extraProps.dataSource = dataSource;
    }
    const FormComponent = ComponentUI.formComponent;
    return (react_1.default.createElement(FormComponent, { ...extraProps, ...props, className: "cn-ai-table-schema-field__item--full-width", popupContainer: document.getElementById(fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name) }));
}, mapProps(mapStatus_1.mapStatus, {
    dataSource: true,
}));
exports.Select.displayName = 'CnAsyncSelcet';
