"use strict";
((typeof self !== 'undefined' ? self : this)["webpackChunklib"] = (typeof self !== 'undefined' ? self : this)["webpackChunklib"] || []).push([[358],{

/***/ 1462:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7658);
/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _utils_eventbus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6587);
/* harmony import */ var _utils_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7623);
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3288);
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ramda__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(8180);





const baseMixin = {
  data() {
    return {
      updateValue: 0,
      widgetId: "widget-" + Math.random().toString(15).slice(2, 15)
    };
  },
  mixins: [_utils_common__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z],
  props: {
    field: {
      type: Object,
      default: () => ({})
    },
    schema: {
      type: Object,
      default: () => ({})
    },
    values: {
      type: Object,
      default: () => ({})
    },
    colors: {
      type: Object,
      default: () => ({})
    },
    fieldErrors: {
      type: Object,
      default: () => ({})
    },
    hideFields: {
      type: Object,
      default: () => ({})
    },
    isDark: {
      type: Boolean,
      default: false
    },
    form: {
      type: Object,
      default: () => ({})
    }
  },
  inject: ["formId", "dependencies", "regExpFields", "isDeepValues", "flatFields", "context"],
  computed: {
    value: {
      get() {
        this.updateValue++; // 强制更新
        let friendValue = {
          value: this.isDeepValues ? this.deepPick(this.field.name.split("."), this.values) : this.friendValue()
        };
        return friendValue.value;
      },
      set(value) {
        let emitValue = this.beforeChange(value);
        this.changeValue(emitValue);
      }
    }
  },
  created() {
    this.load();
  },
  methods: {
    actionEmit(type, arg) {
      if (arg) {
        let msg = {
          type,
          arg
        };
        _utils_eventbus__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z.$emit(`${this.formId}:action`, msg);
      }
    },
    load() {
      this.setFieldAttr();
      this.pickHideFields();
      this.pickDependencies();
      this.pickRegExp();
      this.loadCompleteDispatch();
      this.pickFlatField();
    },
    pickFlatField() {
      if (!this.field.name) return;
      this.flatFields[this.field.name] = this.field;
    },
    loadCompleteDispatch() {
      // 隐藏字段需要立马派发，不然视觉体验不友好
      for (let key in this.hideFields) this.dispatchHide(key);
      // 等所有字段都渲染完成在派发options依赖
      if (this.context.loadDebounce) clearTimeout(this.context.loadDebounce);
      this.context.loadDebounce = setTimeout(() => {
        for (let key in this.dependencies) this.dispatchOptions(key);
        this.context.loadCompleted = true;
      }, 500);
    },
    setFieldAttr() {
      const defaultFieldAttr = this.defaultFieldAttr();
      let fieldAttr = (0,ramda__WEBPACK_IMPORTED_MODULE_3__.mergeDeepRight)(defaultFieldAttr, this.field);
      for (const [key, value] of Object.entries(fieldAttr)) this.field[key] = value;
    },
    defaultFieldAttr() {
      return {};
    },
    beforeChange(value) {
      return this.schema.type == "number" ? parseFloat(value) ? parseFloat(value) : value : value;
    },
    changeValue(value) {
      this.updateValue++;
      this.$emit('changeValue', this.field.name, this.schema, value, this.field);
    },
    friendValue() {
      // 做一些友好值处理
      let friendValue = null;
      let value = this.values[this.field.name];
      try {
        switch (this.schema.type) {
          case "array":
            friendValue = Array.isArray(value) ? value : (0,_utils__WEBPACK_IMPORTED_MODULE_4__/* .strToObj */ .Vq)(value);
            break;
          case "number":
            friendValue = (0,ramda__WEBPACK_IMPORTED_MODULE_3__.type)(value) == "Number" ? value : parseFloat(value);
            break;
          case "datetime":
            friendValue = new Date(value);
            break;
          case "boolean":
            friendValue = (0,ramda__WEBPACK_IMPORTED_MODULE_3__.type)(value) == "Boolean" ? value : value ? Boolean(value) : false;
            break;
          case "integer":
            friendValue = (0,ramda__WEBPACK_IMPORTED_MODULE_3__.type)(value) == "Number" ? value : value ? parseInt(value) : value;
            break;
        }
        if (friendValue) this.values[this.field.name] = friendValue; // 有友好值，需要更新
      } catch (e) {
        console.error(`转换友好值错了：${e}`);
      }
      return friendValue || value;
    },
    // 字段依赖隐藏
    pickHideFields() {
      const hideRely = this.field.hideRely;
      if (!hideRely) return; // 若不存在依赖，则无需收集
      const hideFields = Array.isArray(hideRely) ? hideRely : (0,ramda__WEBPACK_IMPORTED_MODULE_3__.type)(hideRely) == "String" ? [hideRely] : [];
      hideFields.map(hideItem => {
        let splitHideExp = hideItem.split("==");
        if (splitHideExp.length != 2) return;
        let relyKey = splitHideExp[0].trim();
        let relyValue = splitHideExp[1].trim();
        if (!this.hideFields[relyKey]) this.hideFields[relyKey] = [];
        // 必须全部遍历，以应对依赖先后关系
        for (let key in this.hideFields) {
          // 已存在则不需要重新收集
          let hasExit = this.hideFields[key].find(item => {
            if (item.key == relyKey && item.value == relyValue && item.name == this.field.name) {
              // 必须重新赋值，因为form的地址已经变了
              item.field = this.field;
              return true;
            }
          });
          if (hasExit) return;
        }
        this.hideFields[relyKey].push({
          name: this.field.name,
          key: relyKey,
          value: relyValue,
          field: this.field
        });
      });
    },
    // 收集依赖关系
    async pickDependencies() {
      if (!this.field.hasOwnProperty("dict") || this.field.length == 0) return;
      if (typeof this.field.dict == "string" && (0,_utils__WEBPACK_IMPORTED_MODULE_4__/* .isUrl */ .CB)(this.field.dict)) {
        // dict字段是url则直接获取数据，并赋值给options     
        const {
          method,
          respProp,
          params,
          pickValues
        } = this.field.dictConfig;
        pickValues.map(key => {
          if (this.values[key] != undefined) params[key] = this.values[key];
        });
        const response = await (0,_utils__WEBPACK_IMPORTED_MODULE_4__/* .axios */ .od)(this.field.dict, params, method);
        const options = this.deepPick(respProp.split("."), response);
        if (Array.isArray(options) && options.length > 0) this.field.options = options;
        if (this.field.defaultOption >= 0 && this.field.options.length > 0) {
          let option = options[this.field.defaultOption];
          this.values[this.field.name] = typeof option == "object" ? option[this.field.defaultProp.value] : option;
        }
      } else if (Object.keys(this.field.dict).length > 0) {
        for (let key in this.field.dict) {
          let dictItem = this.field.dict[key];
          let dictKeyVal = key.split("==");
          let relyKey = dictKeyVal[0].trim();
          let relyValue = dictKeyVal[1].trim();
          // 赋值初始值
          if (!this.dependencies[relyKey]) this.dependencies[relyKey] = [];
          // 已存在就无需重复添加
          let hasExit = this.dependencies[relyKey].find(item => {
            if (item.keyValue == relyValue && item.name == this.field.name) {
              // 必须重新赋值，因为form的地址已经变了
              item.field = this.field;
              return true;
            }
          });
          if (!hasExit) {
            this.dependencies[relyKey].push({
              name: this.field.name,
              beRelyKey: relyKey,
              keyValue: relyValue,
              dictValue: dictItem,
              field: this.field,
              type: this.schema.type,
              options: JSON.parse(JSON.stringify(this.field.options))
            });
          }
        }
      }
    },
    // 收集表达式依赖
    pickRegExp() {
      const regExp = this.field.regExp;
      if (!regExp) return;
      regExp.map(regItem => {
        const {
          relyName
        } = regItem;
        if (!this.regExpFields[relyName]) this.regExpFields[relyName] = [];
        if (this.regExpFields[relyName].find(item => item.childrenName == this.field.name && item.relyName == regItem.relyName)) return; // 确保只收取一个表达式，
        // 正式收集
        this.regExpFields[relyName].push({
          ...regItem,
          childrenName: this.field.name,
          field: this.field
        });
      });
    }
  }
};
/* harmony default export */ __webpack_exports__.Z = (baseMixin);

/***/ }),

/***/ 2358:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  "default": function() { return /* binding */ ipinput; }
});

// EXTERNAL MODULE: external "vue"
var external_vue_ = __webpack_require__(748);
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-86.use[2]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[4]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Richform/src/widgets/ipinput.vue?vue&type=template&id=24e4ad26&ts=true

const _hoisted_1 = ["id"];
const _hoisted_2 = ["value", "placeholder", "onKeydown", "onInput", "onPaste"];
function render(_ctx, _cache, $props, $setup, $data, $options) {
  return (0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)("div", {
    class: "ipinput-widget",
    id: _ctx.widgetId
  }, [((0,external_vue_.openBlock)(true), (0,external_vue_.createElementBlock)(external_vue_.Fragment, null, (0,external_vue_.renderList)($data.segments, (segment, index) => {
    return (0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)("div", {
      class: "ip-segment",
      style: (0,external_vue_.normalizeStyle)({
        visibility: _ctx.field.disabled ? 'hidden' : 'visible'
      }),
      key: index
    }, [(0,external_vue_.createElementVNode)("input", {
      type: "text",
      maxlength: "3",
      class: "ip-segment-input",
      value: segment,
      placeholder: _ctx.field.placeholder,
      onKeydown: $event => $options.onInputKeydown($event, index),
      onInput: $event => $options.onInput($event, index),
      onBlur: _cache[0] || (_cache[0] = $event => $options.onInputBlur()),
      onFocus: _cache[1] || (_cache[1] = $event => $data.isFocus = true),
      onPaste: $event => $options.onPaste($event, index),
      style: (0,external_vue_.normalizeStyle)({
        color: _ctx.colors.fontColor
      })
    }, null, 44, _hoisted_2), (0,external_vue_.withDirectives)((0,external_vue_.createElementVNode)("i", null, ".", 512), [[external_vue_.vShow, index != $data.segments.length - 1]])], 4);
  }), 128))], 8, _hoisted_1);
}
;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/ipinput.vue?vue&type=template&id=24e4ad26&ts=true

// EXTERNAL MODULE: ./src/components/Richform/src/widgets/baseMixin.ts
var baseMixin = __webpack_require__(1462);
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-86.use[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Richform/src/widgets/ipinput.vue?vue&type=script&lang=ts

/* harmony default export */ var ipinputvue_type_script_lang_ts = ({
  name: "IpInputWidget",
  mixins: [baseMixin/* default */.Z],
  computed: {},
  data() {
    return {
      isFocus: false,
      segments: ["", "", "", ""]
    };
  },
  watch: {
    ip(ip) {
      if (!ip) {
        this.segments = ["", "", "", ""];
      }
      this.syncIp(ip);
    }
  },
  methods: {
    // 定义一个规范化Schema的方法，用来为组件添加个性化的默认属性
    defaultFieldAttr() {
      return {
        placeholder: "",
        prepend: null,
        append: null,
        disabled: false
      };
    },
    getRange(el) {
      let cuRange;
      let tbRange;
      let headRange;
      let range;
      let dupRange;
      let ret = {};
      if (el.setSelectionRange) {
        // standard
        ret.begin = el.selectionStart;
        ret.end = el.selectionEnd;
        ret.result = el.value.substring(ret.begin, ret.end);
      } else if (document.getSelection()) {
        // ie
        // if (el.tagName.toLowerCase() === "input") {
        //   cuRange = document.selection.createRange();
        //   tbRange = el.createTextRange();
        //   tbRange.collapse(true);
        //   tbRange.select();
        //   headRange = document.selection.createRange();
        //   headRange.setEndPoint("EndToEnd", cuRange);
        //   ret.begin = headRange.text.length - cuRange.text.length;
        //   ret.end = headRange.text.length;
        //   ret.result = cuRange.text;
        //   cuRange.select();
        // } else if (el.tagName.toLowerCase() === "textarea") {
        //   range = document.selection.createRange();
        //   dupRange = range.duplicate();
        //   dupRange.moveToElementText(el);
        //   dupRange.setEndPoint("EndToEnd", range);
        //   ret.begin = dupRange.text.length - range.text.length;
        //   ret.end = dupRange.text.length;
        //   ret.result = range.text;
        // }
      }
      el.focus();
      return ret;
    },
    onInputKeydown(event, index) {
      let keyCode = event.keyCode || event.which;
      let value = event.target.value;
      if (keyCode === 8 || keyCode === 37) {
        // move the cursor to previous input if backspace and left arrow is pressed at the begin of one input
        if ((value.length === 0 || this.getRange(event.target).end === 0) && index > 0) {
          this.$el.getElementsByTagName("input")[index - 1].focus();
          // When jump to pre input(enter "backspace"), thr cursor should in the end.
          // before fix: 127.|0.0.0  =>   12|7.0.0.1
          // after fix: 127.|0.0.0 = >   127|.0.0.0
          // notes: "|" mean the cursor position.
          event.preventDefault();
        }
      } else if (keyCode === 39) {
        if (this.getRange(event.target).end === value.length && index < 3) {
          // move to cursor to the next input if right arrow is pressed at the end of one input
          this.$el.getElementsByTagName("input")[index + 1].focus();
        }
      }
    },
    onInput(event, index) {
      let value = event.target.value;
      event.target.value = this.segments[index];
      let segment = Number(value);
      if (isNaN(segment)) {
        return;
      } else if (value === "") {
        this.segments.splice(index, 1, "");
      } else if (segment > 255 || segment < 0) {
        // set the segment to 255 if out of ip range
        this.segments.splice(index, 1, 255);
      } else {
        this.segments.splice(index, 1, segment);
      }
      // jump to next input
      if (value.length === 3 && index < 3 || value[value.length - 1] === ".") {
        this.$el.getElementsByTagName("input")[index + 1].focus();
      }
    },
    onInputBlur() {
      this.isFocus = false;
      setTimeout(() => {
        let className = document.activeElement.className;
        if (className.indexOf("ip-segment-input") === -1) {
          if (this.onBlur) {
            this.onBlur(this.segments.join("."));
          }
        }
      }, 50);
    },
    onPaste(e, index) {
      let pasteText = e.clipboardData.getData("text/plain");
      let segments = pasteText.split(".");
      segments.forEach((segment, i) => {
        if (index + i < 4 && !isNaN(segment) && segment >= 0 && segment <= 255) {
          this.segments.splice(index + i, 1, segment);
        }
      });
      e.preventDefault();
    },
    syncIp(ip) {
      if (ip && ip.indexOf(".") !== -1) {
        ip.split(".").map((segment, index) => {
          if (isNaN(segment) || segment < 0 || segment > 255) {
            segment = 255;
          }
          this.segments.splice(index, 1, segment);
          return segment;
        });
      }
    }
  }
});
;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/ipinput.vue?vue&type=script&lang=ts
 
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-67.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-67.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-67.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-67.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Richform/src/widgets/ipinput.vue?vue&type=style&index=0&id=24e4ad26&lang=scss
// extracted by mini-css-extract-plugin

;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/ipinput.vue?vue&type=style&index=0&id=24e4ad26&lang=scss

// EXTERNAL MODULE: ./node_modules/vue-loader/dist/exportHelper.js
var exportHelper = __webpack_require__(3744);
;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/ipinput.vue




;


const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.Z)(ipinputvue_type_script_lang_ts, [['render',render]])

/* harmony default export */ var ipinput = (__exports__);

/***/ })

}]);