"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    useLabelUiSchema: ()=>useLabelUiSchema,
    getDatePickerLabels: ()=>getDatePickerLabels,
    getLabelFormatValue: ()=>getLabelFormatValue
});
const external_react_namespaceObject = require("react");
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
const schema_namespaceObject = require("@tachybase/schema");
const client_namespaceObject = require("@tachybase/utils/client");
const external_antd_namespaceObject = require("antd");
const index_js_namespaceObject = require("../../../collection-manager/index.js");
const useLabelUiSchema = (collectionField, label)=>{
    const { getCollectionJoinField } = (0, index_js_namespaceObject.useCollectionManager_deprecated)();
    if (!collectionField) return;
    const labelField = getCollectionJoinField("".concat(collectionField.target, ".").concat(label));
    return null == labelField ? void 0 : labelField.uiSchema;
};
const getDatePickerLabels = (props)=>{
    const format = (0, client_namespaceObject.getDefaultFormat)(props);
    const m = (0, client_namespaceObject.str2moment)(props.value, props);
    const labels = m && m.isValid() ? m.format(format) : props.value;
    return (0, schema_namespaceObject.isArr)(labels) ? labels.join('~') : labels;
};
const getLabelFormatValue = function(labelUiSchema, value) {
    let isTag = arguments.length > 2 && void 0 !== arguments[2] && arguments[2];
    if (Array.isArray(null == labelUiSchema ? void 0 : labelUiSchema.enum) && value) {
        const opt = labelUiSchema.enum.find((option)=>option.value === value);
        if (isTag) return external_react_default().createElement(external_antd_namespaceObject.Tag, {
            color: null == opt ? void 0 : opt.color
        }, null == opt ? void 0 : opt.label);
        return null == opt ? void 0 : opt.label;
    }
    switch(null == labelUiSchema ? void 0 : labelUiSchema['x-component']){
        case 'DatePicker':
            return getDatePickerLabels({
                ...null == labelUiSchema ? void 0 : labelUiSchema['x-component-props'],
                value
            });
        default:
            return value;
    }
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
