'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../utils/index.js');
var antDesignVue = require('ant-design-vue');
require('./components/cron-modal.vue.js');
require('./config/index.js');
var createNamespace = require('../../../utils/create-namespace.js');
var cronModal_vue_vue_type_script_setup_true_lang = require('./components/cron-modal.vue2.js');
var cronExpressionBuilder = require('./config/cron-expression-builder.js');

"use strict";
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{ name: "LlCronExpressionBuilder" },
  __name: "cron-expression-builder",
  props: cronExpressionBuilder.cronExpressionBuilderProps,
  emits: cronExpressionBuilder.cronExpressionBuilderEmits,
  setup(__props, { emit: __emit }) {
    const bem = createNamespace.createNamespace("cron-expression-builder");
    const props = __props;
    const emits = __emit;
    const editCronValue = vue.ref(props.value);
    const formItemContext = antDesignVue.Form.useInjectFormItemContext();
    const modalRef = vue.ref();
    vue.watch(
      () => props.value,
      (newVal) => {
        if (newVal !== editCronValue.value) {
          editCronValue.value = newVal;
        }
      }
    );
    function showConfigModal() {
      if (props.disabled) return;
      modalRef.value?.openModal();
    }
    function handleSubmit() {
      emits("change", editCronValue.value);
      emits("update:value", editCronValue.value);
      formItemContext.onFieldChange();
    }
    return (_ctx, _cache) => {
      const _component_ll_icon = vue.resolveComponent("ll-icon");
      const _component_a_input = vue.resolveComponent("a-input");
      return vue.openBlock(), vue.createElementBlock(
        "div",
        {
          class: vue.normalizeClass(vue.unref(bem).b())
        },
        [
          vue.createVNode(_component_a_input, {
            value: _ctx.value,
            "onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.value = $event),
            readonly: "",
            placeholder: _ctx.placeholder,
            bordered: _ctx.bordered,
            disabled: _ctx.disabled,
            onClick: showConfigModal
          }, {
            suffix: vue.withCtx(() => [
              vue.createVNode(_component_ll_icon, { "icon-name": "icon-cron" })
            ]),
            _: 1
            /* STABLE */
          }, 8, ["value", "placeholder", "bordered", "disabled"]),
          vue.createVNode(cronModal_vue_vue_type_script_setup_true_lang.default, {
            ref_key: "modalRef",
            ref: modalRef,
            value: editCronValue.value,
            "onUpdate:value": _cache[1] || (_cache[1] = ($event) => editCronValue.value = $event),
            "exe-start-time": _ctx.exeStartTime,
            "hide-year": _ctx.hideYear,
            remote: _ctx.remote,
            "hide-second": _ctx.hideSecond,
            onOk: handleSubmit
          }, null, 8, ["value", "exe-start-time", "hide-year", "remote", "hide-second"])
        ],
        2
        /* CLASS */
      );
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=cron-expression-builder.vue2.js.map
