"use strict";
/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
(self["webpackChunknocode_component"] = self["webpackChunknocode_component"] || []).push([[780],{

/***/ "./src/control/hooks/useAttachmentHooks.ts":
/*!*************************************************!*\
  !*** ./src/control/hooks/useAttachmentHooks.ts ***!
  \*************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_keys__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/keys */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/keys.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_keys__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_keys__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_symbols__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_symbols__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_get_own_property_symbols__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptor__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptor__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptors__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptors__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_define_properties__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/define-properties */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/define-properties.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_define_properties__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_define_properties__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_define_property__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/define-property */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/define-property.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_define_property__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_define_property__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _babel_runtime_corejs3_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @babel/runtime-corejs3/helpers/slicedToArray */ \"../../node_modules/@babel/runtime-corejs3/helpers/esm/slicedToArray.js\");\n/* harmony import */ var _babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @babel/runtime-corejs3/helpers/toConsumableArray */ \"../../node_modules/@babel/runtime-corejs3/helpers/esm/toConsumableArray.js\");\n/* harmony import */ var _babel_runtime_corejs3_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @babel/runtime-corejs3/helpers/defineProperty */ \"../../node_modules/@babel/runtime-corejs3/helpers/esm/defineProperty.js\");\n/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! core-js/modules/es.function.name.js */ \"../../node_modules/core-js/modules/es.function.name.js\");\n/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_9__);\n/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"../../node_modules/core-js/modules/es.object.to-string.js\");\n/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_10__);\n/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"../../node_modules/core-js/modules/web.dom-collections.for-each.js\");\n/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_11__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_includes__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/includes */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/includes.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_includes__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_includes__WEBPACK_IMPORTED_MODULE_13__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/concat */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/concat.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_14__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_reduce__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/reduce */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/reduce.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_reduce__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_reduce__WEBPACK_IMPORTED_MODULE_15__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_map__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/map */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/map.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_map__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_map__WEBPACK_IMPORTED_MODULE_16__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/map */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/map.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_17__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/values */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/values.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_18__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/filter */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/filter.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_12__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_find__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/find */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/find.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_find__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_find__WEBPACK_IMPORTED_MODULE_19__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_instance_replace_all__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js/instance/replace-all */ \"../../node_modules/@babel/runtime-corejs3/core-js/instance/replace-all.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_instance_replace_all__WEBPACK_IMPORTED_MODULE_20___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_instance_replace_all__WEBPACK_IMPORTED_MODULE_20__);\n/* harmony import */ var kd_libs_react__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! kd_libs/react */ \"webpack/container/remote/kd_libs/react\");\n/* harmony import */ var kd_libs_react__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(kd_libs_react__WEBPACK_IMPORTED_MODULE_21__);\n/* harmony import */ var _utils_context__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! @/utils/context */ \"./src/utils/context.ts\");\n/* harmony import */ var _useFieldProps__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./useFieldProps */ \"./src/control/hooks/useFieldProps.tsx\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! @/utils */ \"./src/utils/index.ts\");\n/* harmony import */ var _utils_attachmentUtils__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! @/utils/attachmentUtils */ \"./src/utils/attachmentUtils.ts\");\n/* harmony import */ var _utils_attachmentPreviewUtils__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! @/utils/attachmentPreviewUtils */ \"./src/utils/attachmentPreviewUtils.ts\");\n/* harmony import */ var _base_web_AttachmentPreviewer_AttachmentPreviewerConst__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! @/base/web/AttachmentPreviewer/AttachmentPreviewerConst */ \"./src/base/web/AttachmentPreviewer/AttachmentPreviewerConst.ts\");\n/* harmony import */ var _base_hooks_useDebounce__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! @/base/hooks/useDebounce */ \"./src/base/hooks/useDebounce.ts\");\n\n\n\n\n\n\n\n\n\n\n\n\nfunction ownKeys(e, r) { var t = _babel_runtime_corejs3_core_js_stable_object_keys__WEBPACK_IMPORTED_MODULE_0___default()(e); if ((_babel_runtime_corejs3_core_js_stable_object_get_own_property_symbols__WEBPACK_IMPORTED_MODULE_1___default())) { var o = _babel_runtime_corejs3_core_js_stable_object_get_own_property_symbols__WEBPACK_IMPORTED_MODULE_1___default()(e); r && (o = _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_12___default()(o).call(o, function (r) { return _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptor__WEBPACK_IMPORTED_MODULE_2___default()(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0,_babel_runtime_corejs3_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(e, r, t[r]); }) : (_babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptors__WEBPACK_IMPORTED_MODULE_3___default()) ? _babel_runtime_corejs3_core_js_stable_object_define_properties__WEBPACK_IMPORTED_MODULE_4___default()(e, _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptors__WEBPACK_IMPORTED_MODULE_3___default()(t)) : ownKeys(Object(t)).forEach(function (r) { _babel_runtime_corejs3_core_js_stable_object_define_property__WEBPACK_IMPORTED_MODULE_5___default()(e, r, _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptor__WEBPACK_IMPORTED_MODULE_2___default()(t, r)); }); } return e; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar ATTACHMENT_ACTION = \"\".concat(window.__domainurl__ || '', \"nocode/v2/nocode_sys/attachment\");\n// 拼接免登分享ID\nvar getFullUrl = function getFullUrl(path) {\n  var _context;\n  var str = _babel_runtime_corejs3_core_js_stable_instance_includes__WEBPACK_IMPORTED_MODULE_13___default()(path).call(path, '?') ? '&' : '?';\n  var shareParam = window.NOCODE_SHARE_ID ? _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_14___default()(_context = \"\".concat(str, \"noCodeShareId=\")).call(_context, window.NOCODE_SHARE_ID) : '';\n  return (0,_utils__WEBPACK_IMPORTED_MODULE_24__.getUrlWithDataCenter)(path + shareParam);\n};\nvar formateDataList = function formateDataList(list, oldData, model) {\n  var mapData = _babel_runtime_corejs3_core_js_stable_instance_reduce__WEBPACK_IMPORTED_MODULE_15___default()(list).call(list, function (result, item) {\n    return result.set(item.uid, _objectSpread(_objectSpread({}, item), {}, {\n      name: model.getControlText(item.name)\n    })); // 缓存已经上传成功的列表\n  }, new (_babel_runtime_corejs3_core_js_stable_map__WEBPACK_IMPORTED_MODULE_16___default())());\n  var newData = oldData.length ? _babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_17___default()(oldData).call(oldData, function (item) {\n    return mapData.get(item.uid) || item;\n  }) : (0,_babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(_babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_18___default()(mapData).call(mapData));\n  return {\n    newData: newData,\n    mapData: mapData\n  };\n};\nvar useAttachmentHooks = function useAttachmentHooks(_ref) {\n  var _context6, _context7, _context8, _context9;\n  var controlMeta = _ref.controlMeta,\n    cellValue = _ref.value,\n    onChange = _ref.onChange,\n    uploadAttachmentVerify = _ref.uploadAttachmentVerify,\n    showInfo = _ref.showInfo,\n    invokeData = _ref.invokeData,\n    _ref$rowIndex = _ref.rowIndex,\n    rowIndex = _ref$rowIndex === void 0 ? -1 : _ref$rowIndex;\n  // console.log('useAttachmentHooks', cellValue)\n  var _useContext = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useContext)(_utils_context__WEBPACK_IMPORTED_MODULE_22__.KDContext),\n    model = _useContext.model;\n  var _useFieldProps = (0,_useFieldProps__WEBPACK_IMPORTED_MODULE_23__.useFieldProps)(controlMeta),\n    readonly = _useFieldProps.readonly,\n    disabled = _useFieldProps.disabled,\n    hidden = _useFieldProps.hidden,\n    required = _useFieldProps.required,\n    rules = _useFieldProps.rules;\n  var _useState = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useState)(formateDataList(cellValue || [], [], model).newData),\n    _useState2 = (0,_babel_runtime_corejs3_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_6__[\"default\"])(_useState, 2),\n    datas = _useState2[0],\n    setDatas = _useState2[1]; // 文件列表\n  // const [labelText, setLabelText] = useState('') // 控件标题\n  var pageId = controlMeta.pageId,\n    id = controlMeta.id,\n    uploadNum = controlMeta.uploadNum,\n    fileMaxSize = controlMeta.fileMaxSize,\n    uploadModel = controlMeta.uploadModel,\n    _controlMeta$attachme = controlMeta.attachmentFileType,\n    attachmentFileType = _controlMeta$attachme === void 0 ? '' : _controlMeta$attachme,\n    displayCount = controlMeta.displayCount,\n    uploadPrompt = controlMeta.uploadPrompt,\n    buttonText = controlMeta.buttonText;\n  var fieldRef = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useRef)(null); // 控件外部容器，用户显示错误信息\n  var uploadRef = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useRef)(formateDataList(cellValue || [], [], model).mapData); // 缓存上传成功的列表\n\n  var beforeAsyn = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useCallback)(function (list) {\n    // [{\"key\":\"attachmentpanel\",\"methodName\":\"beforeUpload\",\"args\":[[{\"uid\":\"rc-upload-1665492200338-3\",\"name\":\"nginx路由配置.docx\",\"size\":17445,\"type\":\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"}]],\"postData\":[{},[]]}]\n    var args = [];\n    list.forEach(function (item) {\n      if ((0,_utils_attachmentUtils__WEBPACK_IMPORTED_MODULE_25__.checkAttachmentType)(item, attachmentFileType) && !(0,_utils_attachmentUtils__WEBPACK_IMPORTED_MODULE_25__.checkSize)(item, fileMaxSize) && !(0,_utils_attachmentUtils__WEBPACK_IMPORTED_MODULE_25__.checkEmpty)(item)) {\n        args.push({\n          uid: item.uid,\n          name: item.name,\n          size: item.size,\n          type: item.type\n        });\n      }\n    });\n    model.batchInvoke('beforeUpload', pageId, id, [args], []);\n  }, [pageId, id]);\n\n  // 同步上传成功内容到服务端\n  var updateDatas = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useCallback)(function (files) {\n    model.batchInvoke('updateValue', pageId, '', [], [{}, [{\n      k: id,\n      r: rowIndex,\n      v: files\n    }]]);\n  }, [rowIndex, pageId, id]);\n  var debounceUpdateValue = (0,_base_hooks_useDebounce__WEBPACK_IMPORTED_MODULE_28__[\"default\"])(updateDatas);\n\n  // 上传前执行\n  var beforeUpload = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useCallback)(function (file, list) {\n    // console.log('beforeUpload', file.name)\n    var result = uploadAttachmentVerify(file, list, controlMeta);\n    if (result) beforeAsyn(list);\n    return result;\n  }, [beforeAsyn, uploadAttachmentVerify]);\n\n  // change事件, 更新\n  var handleChange = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useCallback)(function (_ref2) {\n    var file = _ref2.file,\n      fileList = _ref2.fileList;\n    var errText = required && fileList.length === 0 ? '值不能为空' : '';\n    fieldRef.current.setValidateMessage(errText);\n    var newList = _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_12___default()(fileList).call(fileList, function (item) {\n      return item.status !== 'notStart';\n    });\n    if (file.status === 'done' && file.response.status) {\n      var lastModified = file.lastModified,\n        uid = file.uid,\n        name = file.name,\n        type = file.type,\n        size = file.size;\n      var param = {\n        status: 'success',\n        url: file.response.data.url,\n        uploadTime: Date.now()\n      };\n      var _info = _objectSpread({\n        lastModified: lastModified,\n        uid: uid,\n        name: name,\n        type: type,\n        size: size\n      }, param);\n      uploadRef.current.set(file.uid, _info);\n      var uploadList = _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_12___default()(newList).call(newList, function (item) {\n        return item.status === 'uploading';\n      });\n      console.log('onChange', uploadRef.current.size, newList.length, uploadList.length);\n      if (uploadList.length === 0) {\n        if (onChange) {\n          var _context2;\n          // 附件单据体内需要使用单据体提供onchange事件\n          onChange((0,_babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(_babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_18___default()(_context2 = uploadRef.current).call(_context2)));\n        } else {\n          var _context3;\n          debounceUpdateValue((0,_babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(_babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_18___default()(_context3 = uploadRef.current).call(_context3)));\n        }\n      }\n    } else if (file.status === 'error' || file.status === 'done' && !(file !== null && file !== void 0 && file.response.status)) {\n      showInfo(\"\".concat(file.name, \"\\u4E0A\\u4F20\\u5931\\u8D25\\uFF0C\\u8BF7\\u91CD\\u65B0\\u4E0A\\u4F20\"));\n      // [{\"key\":\"attachmentfield\",\"methodName\":\"uploadResult\",\"args\":[[{\"uid\":\"rc-upload-1687763956534-51\",\"description\":\"禁止上传非法文件。\",\"status\":\"error\"}]],\"postData\":[{},[]]}]\n      model.batchInvoke('uploadResult', pageId, id, [[{\n        uid: file.uid,\n        description: '禁止上传非法文件。',\n        status: 'error'\n      }]], [{}, []]);\n    }\n    setDatas(newList);\n  }, [onChange, required, pageId, id, debounceUpdateValue, showInfo]);\n\n  // 下载\n  var onDownload = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useCallback)(function (info) {\n    var _context4;\n    var config = model.getConfig(pageId);\n    var file = uploadRef.current.get(info.uid);\n    var options = {\n      params: '1',\n      appId: config.appId,\n      fId: config.formId,\n      fileName: file.name\n    };\n    var url = _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_14___default()(_context4 = \"\".concat(getFullUrl(file.url), \"&kd_cs_ticket=\")).call(_context4, model.Global.token);\n    (0,_utils__WEBPACK_IMPORTED_MODULE_24__.downloadFile)(url, options);\n  }, [pageId]);\n\n  // 删除\n  var handleRemove = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useCallback)(function (file) {\n    if (!(datas !== null && datas !== void 0 && datas.length)) return false;\n    var newData = _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_12___default()(datas).call(datas, function (item) {\n      return item.uid !== file.uid;\n    });\n    if (required && !newData.length) {\n      fieldRef.current.setValidateMessage('值不能为空');\n    }\n    // const newFile = uploadRef.current.get(file.uid) // 上传成功列表\n    // if (newFile) { // 上传成功文件,更新postData\n    // }\n    model.batchInvoke('beforeRemove', pageId, id, [{\n      uid: file.uid\n    }], []);\n    setDatas(newData);\n    return true;\n  }, [datas, onChange, pageId, id, required]);\n\n  // 修改文件名\n  var onChangeFileName = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useCallback)(function (info) {\n    var file = _babel_runtime_corejs3_core_js_stable_instance_find__WEBPACK_IMPORTED_MODULE_19___default()(datas).call(datas, function (item) {\n      return item.uid === info.uid;\n    });\n    file.name = info.name;\n    if (file.status === 'success') {\n      // 若已经上传成功，需要同时更新缓存\n      var obj = uploadRef.current.get(info.uid);\n      obj.name = info.name;\n      uploadRef.current.set(info.uid, obj);\n      // debounceUpdateValue([...uploadRef.current.values()])\n      model.batchInvoke('rename', pageId, id, [info.uid, info.name, rowIndex], [{}, []]);\n      if (onChange) {\n        var _context5;\n        onChange((0,_babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(_babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_18___default()(_context5 = uploadRef.current).call(_context5)));\n      }\n    }\n    setDatas((0,_babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(datas));\n  }, [datas, onChange, rowIndex, pageId, id]);\n\n  // useEffect(() => {\n  //   const label = !displayCount || readonly || disabled ? '' : `(${uploadRef.current.size}/${uploadNum?.max || 1})`\n  //   setLabelText(label)\n  // }, [displayCount, readonly, disabled, uploadNum, datas])\n\n  // 监听系统U指令-回调\n  var updateValue = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useCallback)(function (info) {\n    var _info$v;\n    // console.log('updateValue', info)\n    if (!Array.isArray(info.v) || Array.isArray(info.v) && !(info !== null && info !== void 0 && (_info$v = info.v) !== null && _info$v !== void 0 && _info$v.length)) {\n      uploadRef.current = new (_babel_runtime_corejs3_core_js_stable_map__WEBPACK_IMPORTED_MODULE_16___default())();\n      setDatas([]);\n      return;\n    }\n    setDatas(function (prevData) {\n      var _formateDataList = formateDataList(info.v, prevData, model),\n        newData = _formateDataList.newData,\n        mapData = _formateDataList.mapData;\n      uploadRef.current = mapData;\n      return newData;\n    });\n  }, [setDatas]);\n  (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useEffect)(function () {\n    // console.log('cellvalue', cellValue)\n    cellValue && updateValue({\n      k: id,\n      v: cellValue\n    });\n  }, [cellValue]);\n\n  /**\n   * 控件内部指令\n   */\n  var controlMethod = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useCallback)(function (info) {\n    var _ref3 = (info === null || info === void 0 ? void 0 : info[0]) || {},\n      args = _ref3.args,\n      methodname = _ref3.methodname;\n    switch (methodname) {\n      case 'beforeRemove':\n        // 删除\n        if (args[0].canRemove) {\n          var files = [];\n          uploadRef.current.forEach(function (item, key) {\n            var lastModified = item.lastModified,\n              name = item.name,\n              size = item.size,\n              status = item.status,\n              type = item.type,\n              uid = item.uid,\n              url = item.url,\n              uploadTime = item.uploadTime;\n            if (key === args[0].uid) {\n              files.push({\n                lastModified: lastModified,\n                name: name,\n                size: size,\n                status: status,\n                type: type,\n                uid: uid,\n                url: url,\n                uploadTime: uploadTime,\n                delete: true\n              });\n            } else {\n              files.push({\n                lastModified: lastModified,\n                name: name,\n                size: size,\n                status: status,\n                type: type,\n                uid: uid,\n                url: url,\n                uploadTime: uploadTime\n              });\n            }\n          });\n          // 统一出口\n          // model.batchInvoke('updateValue', pageId, '', [], [{}, [{ k: id, v: files }]])\n          debounceUpdateValue(files);\n          uploadRef.current.delete(args[0].uid);\n        }\n        break;\n    }\n  }, [debounceUpdateValue]);\n  (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useEffect)(function () {\n    invokeData && controlMethod(invokeData);\n  }, [invokeData]);\n  model.useUpdateControlStates(controlMeta, updateValue);\n  model.useInvokeControlMethod(controlMeta, controlMethod);\n\n  // console.log('KDAttachment', controlMeta)\n  // 提示文案\n  var notice = uploadPrompt ? _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_14___default()(_context6 = _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_14___default()(_context7 = _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_14___default()(_context8 = \"\\u8BF7\\u4E0A\\u4F20\\u5C0F\\u4E8E\".concat(fileMaxSize, \"M\\u7684\")).call(_context8, attachmentFileType === null || attachmentFileType === void 0 ? void 0 : _babel_runtime_corejs3_core_js_instance_replace_all__WEBPACK_IMPORTED_MODULE_20___default()(attachmentFileType).call(attachmentFileType, '.', ''), \"\\u6587\\u4EF6\\uFF0C\\u6587\\u4EF6\\u4E2A\\u6570\\u4E0D\\u5C11\\u4E8E\")).call(_context7, (uploadNum === null || uploadNum === void 0 ? void 0 : uploadNum.min) || 0, \"\\u4E2A\\uFF0C\\u4E0D\\u591A\\u4E8E\")).call(_context6, (uploadNum === null || uploadNum === void 0 ? void 0 : uploadNum.max) || 1, \"\\u4E2A\") : '';\n  // 上传数量\n  var labelText = !displayCount || readonly || disabled ? '' : _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_14___default()(_context9 = \"(\".concat(uploadRef.current.size, \"/\")).call(_context9, (uploadNum === null || uploadNum === void 0 ? void 0 : uploadNum.max) || 1, \")\");\n\n  // 处理previewurl\n  var handledDatas = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useMemo)(function () {\n    var config = model.getConfig(pageId);\n    var appId = config.appId,\n      formId = config.formId;\n    if (!(datas !== null && datas !== void 0 && datas.length)) return [];\n    return _babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_17___default()(datas).call(datas, function (item) {\n      // excel不加shareId，内部fetchControlData时会加\n      item.previewurl = (0,_utils_attachmentPreviewUtils__WEBPACK_IMPORTED_MODULE_26__.getSecureUrl)({\n        url: item.previewurl,\n        pageId: pageId,\n        appId: appId,\n        formId: formId,\n        ticket: model.Global.token,\n        needShareId: !_babel_runtime_corejs3_core_js_stable_instance_includes__WEBPACK_IMPORTED_MODULE_13___default()(_base_web_AttachmentPreviewer_AttachmentPreviewerConst__WEBPACK_IMPORTED_MODULE_27__.ATTACHMENT_PREVIEW_EXCEL).call(_base_web_AttachmentPreviewer_AttachmentPreviewerConst__WEBPACK_IMPORTED_MODULE_27__.ATTACHMENT_PREVIEW_EXCEL, item.type)\n      });\n      return item;\n    });\n  }, [datas, pageId]);\n  var previewType = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_21__.useMemo)(function () {\n    var _model$getConfig;\n    var _ref4 = (model === null || model === void 0 || (_model$getConfig = model.getConfig) === null || _model$getConfig === void 0 ? void 0 : _model$getConfig.call(model)) || {},\n      attPreview = _ref4.attPreview;\n    var _ref5 = attPreview || {},\n      previewType = _ref5.previewType;\n    return previewType || '0';\n  }, []);\n  return {\n    action: getFullUrl(ATTACHMENT_ACTION),\n    handledDatas: handledDatas,\n    disabled: disabled,\n    readonly: readonly,\n    buttonText: buttonText,\n    uploadModel: uploadModel,\n    handleChange: handleChange,\n    onDownload: onDownload,\n    onChangeFileName: onChangeFileName,\n    beforeUpload: beforeUpload,\n    handleRemove: handleRemove,\n    attachmentFileType: attachmentFileType,\n    uploadNum: uploadNum,\n    notice: notice,\n    previewType: previewType,\n    labelText: labelText,\n    required: required,\n    hidden: hidden,\n    fieldRef: fieldRef,\n    datas: datas,\n    rules: rules\n  };\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (useAttachmentHooks);\n\n//# sourceURL=webpack://nocode-component/./src/control/hooks/useAttachmentHooks.ts?");

/***/ }),

/***/ "./src/control/hooks/usePictureHooks.ts":
/*!**********************************************!*\
  !*** ./src/control/hooks/usePictureHooks.ts ***!
  \**********************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_keys__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/keys */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/keys.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_keys__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_keys__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_symbols__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_symbols__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_get_own_property_symbols__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptor__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptor__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptors__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptors__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_define_properties__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/define-properties */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/define-properties.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_define_properties__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_define_properties__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_define_property__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/object/define-property */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/object/define-property.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_object_define_property__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_object_define_property__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @babel/runtime-corejs3/helpers/toConsumableArray */ \"../../node_modules/@babel/runtime-corejs3/helpers/esm/toConsumableArray.js\");\n/* harmony import */ var _babel_runtime_corejs3_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @babel/runtime-corejs3/helpers/defineProperty */ \"../../node_modules/@babel/runtime-corejs3/helpers/esm/defineProperty.js\");\n/* harmony import */ var _babel_runtime_corejs3_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @babel/runtime-corejs3/helpers/slicedToArray */ \"../../node_modules/@babel/runtime-corejs3/helpers/esm/slicedToArray.js\");\n/* harmony import */ var core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! core-js/modules/es.array.join.js */ \"../../node_modules/core-js/modules/es.array.join.js\");\n/* harmony import */ var core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_10__);\n/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! core-js/modules/es.function.name.js */ \"../../node_modules/core-js/modules/es.function.name.js\");\n/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_11__);\n/* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! core-js/modules/es.object.keys.js */ \"../../node_modules/core-js/modules/es.object.keys.js\");\n/* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_12__);\n/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"../../node_modules/core-js/modules/es.object.to-string.js\");\n/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_13__);\n/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"../../node_modules/core-js/modules/web.dom-collections.for-each.js\");\n/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_14__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/concat */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/concat.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_15__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_slice__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/slice */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/slice.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_slice__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_slice__WEBPACK_IMPORTED_MODULE_16__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_map__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/map */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/map.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_map__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_map__WEBPACK_IMPORTED_MODULE_17__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/map */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/map.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_18__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/filter */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/filter.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_9__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_sort__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/sort */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/sort.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_sort__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_sort__WEBPACK_IMPORTED_MODULE_19__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_json_stringify__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/json/stringify */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/json/stringify.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_json_stringify__WEBPACK_IMPORTED_MODULE_20___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_json_stringify__WEBPACK_IMPORTED_MODULE_20__);\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @babel/runtime-corejs3/core-js-stable/instance/values */ \"../../node_modules/@babel/runtime-corejs3/core-js-stable/instance/values.js\");\n/* harmony import */ var _babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_21__);\n/* harmony import */ var kd_libs_react__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! kd_libs/react */ \"webpack/container/remote/kd_libs/react\");\n/* harmony import */ var kd_libs_react__WEBPACK_IMPORTED_MODULE_22___default = /*#__PURE__*/__webpack_require__.n(kd_libs_react__WEBPACK_IMPORTED_MODULE_22__);\n/* harmony import */ var _control_hooks_useFieldProps__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! @/control/hooks/useFieldProps */ \"./src/control/hooks/useFieldProps.tsx\");\n/* harmony import */ var _utils_context__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! @/utils/context */ \"./src/utils/context.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! @/utils */ \"./src/utils/index.ts\");\n\n\n\n\n\n\n\n\n\nvar _context;\nfunction ownKeys(e, r) { var t = _babel_runtime_corejs3_core_js_stable_object_keys__WEBPACK_IMPORTED_MODULE_0___default()(e); if ((_babel_runtime_corejs3_core_js_stable_object_get_own_property_symbols__WEBPACK_IMPORTED_MODULE_1___default())) { var o = _babel_runtime_corejs3_core_js_stable_object_get_own_property_symbols__WEBPACK_IMPORTED_MODULE_1___default()(e); r && (o = _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_9___default()(o).call(o, function (r) { return _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptor__WEBPACK_IMPORTED_MODULE_2___default()(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0,_babel_runtime_corejs3_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(e, r, t[r]); }) : (_babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptors__WEBPACK_IMPORTED_MODULE_3___default()) ? _babel_runtime_corejs3_core_js_stable_object_define_properties__WEBPACK_IMPORTED_MODULE_4___default()(e, _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptors__WEBPACK_IMPORTED_MODULE_3___default()(t)) : ownKeys(Object(t)).forEach(function (r) { _babel_runtime_corejs3_core_js_stable_object_define_property__WEBPACK_IMPORTED_MODULE_5___default()(e, r, _babel_runtime_corejs3_core_js_stable_object_get_own_property_descriptor__WEBPACK_IMPORTED_MODULE_2___default()(t, r)); }); } return e; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n// import { uploadPictureVerify } from '@/utils/mobTools'\n\n\nvar shareParam = window.NOCODE_SHARE_ID ? \"?noCodeShareId=\".concat(window.NOCODE_SHARE_ID) : '';\nvar PICTURE_ACTION = (0,_utils__WEBPACK_IMPORTED_MODULE_25__.getUrlWithDataCenter)(_babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_15___default()(_context = \"\".concat(window.__domainurl__ || '', \"nocode/v2/nocode_sys/image\")).call(_context, shareParam));\nvar getFullUrl = function getFullUrl(baseUrl, path) {\n  var url = baseUrl + (path[0] === '/' ? _babel_runtime_corejs3_core_js_stable_instance_slice__WEBPACK_IMPORTED_MODULE_16___default()(path).call(path, 1) : path) + shareParam;\n  return (0,_utils__WEBPACK_IMPORTED_MODULE_25__.getUrlWithDataCenter)(url);\n};\nvar usePictureHooks = function usePictureHooks(_ref) {\n  var _context11;\n  var controlMeta = _ref.controlMeta,\n    value = _ref.value,\n    onChange = _ref.onChange;\n  // const { controlMeta, value, onChange } = props\n  var _useContext = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useContext)(_utils_context__WEBPACK_IMPORTED_MODULE_24__.KDContext),\n    model = _useContext.model;\n  var _useFieldProps = (0,_control_hooks_useFieldProps__WEBPACK_IMPORTED_MODULE_23__.useFieldProps)(controlMeta),\n    readonly = _useFieldProps.readonly,\n    disabled = _useFieldProps.disabled,\n    hidden = _useFieldProps.hidden,\n    required = _useFieldProps.required,\n    rules = _useFieldProps.rules;\n  var pageId = controlMeta.pageId,\n    id = controlMeta.id,\n    pictureDefValue = controlMeta.pictureDefValue,\n    imageFileType = controlMeta.imageFileType,\n    fileMaxSize = controlMeta.fileMaxSize,\n    uploadNum = controlMeta.uploadNum,\n    ops = controlMeta.ops,\n    enablePreview = controlMeta.enablePreview,\n    buttonText = controlMeta.buttonText,\n    displayCount = controlMeta.displayCount,\n    uploadPrompt = controlMeta.uploadPrompt;\n  var uploadRef = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useRef)(new (_babel_runtime_corejs3_core_js_stable_map__WEBPACK_IMPORTED_MODULE_17___default())()); // 记录每个文件上传时间\n  var fieldTitleRef = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useRef)(null); // 用于显示错误提示\n  var baseUrl = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useRef)(model.getFileServer('picture'));\n  // const titleRef = useRef(model.getControlText(controlMeta.caption))\n  // const [labelText, setLabelText] = useState('') // 文件列表\n\n  var _useState = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useState)(),\n    _useState2 = (0,_babel_runtime_corejs3_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(_useState, 2),\n    datas = _useState2[0],\n    setDatas = _useState2[1];\n\n  // 将字符串数据转成数组\n  var transformData = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useCallback)(function (info) {\n    var data = info || [];\n    try {\n      data = typeof data === 'string' ? JSON.parse(data) : data;\n    } catch (error) {\n      data = [];\n    }\n    return _babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_18___default()(data).call(data, function (item) {\n      uploadRef.current.set(item.uid, _objectSpread({}, item)); // 保存未变更的URL地址\n      var url = getFullUrl(baseUrl.current, item.url); // 变更URL\n      return _objectSpread(_objectSpread({}, item), {}, {\n        url: url\n      });\n    });\n  }, []);\n\n  // 默认值\n  (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useEffect)(function () {\n    setDatas(transformData(pictureDefValue));\n  }, [pictureDefValue]);\n\n  // change事件, 更新\n  var handleChange = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useCallback)(function (_ref2) {\n    var file = _ref2.file,\n      fileList = _ref2.fileList;\n    var errText = controlMeta.mi && fileList.length === 0 ? '值不能为空' : '';\n    fieldTitleRef.current.setValidateMessage(errText);\n    var newList = _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_9___default()(fileList).call(fileList, function (item) {\n      return item.status !== 'notStart';\n    });\n    if (file.status === 'done' && file.response.status) {\n      var _context2, _context3;\n      var uid = file.uid,\n        name = file.name,\n        size = file.size;\n      var data = {\n        url: file.response.data.url,\n        status: 'success',\n        uploadTime: Date.now()\n      };\n      uploadRef.current.set(file.uid, _objectSpread({\n        uid: uid,\n        name: name,\n        size: size\n      }, data)); // Map存储已上传的文件信息\n      // 对数据根据UID进行排序\n      uploadRef.current = new (_babel_runtime_corejs3_core_js_stable_map__WEBPACK_IMPORTED_MODULE_17___default())(_babel_runtime_corejs3_core_js_stable_instance_sort__WEBPACK_IMPORTED_MODULE_19___default()(_context2 = (0,_babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_6__[\"default\"])(uploadRef.current)).call(_context2, function (a, b) {\n        return a[0].localeCompare(b[0]);\n      }));\n      var _str = _babel_runtime_corejs3_core_js_stable_json_stringify__WEBPACK_IMPORTED_MODULE_20___default()((0,_babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_6__[\"default\"])(_babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_21___default()(_context3 = uploadRef.current).call(_context3)));\n      if (onChange) {\n        onChange(_str);\n      } else {\n        var updateData = {\n          k: id,\n          r: 0,\n          v: _str\n        };\n        var uploadList = _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_9___default()(newList).call(newList, function (item) {\n          return item.status === 'uploading';\n        });\n        // console.log('onChange', uploadRef.current.size, uploadList.length)\n        if (uploadList.length === 0) {\n          model.batchInvoke('updateValue', pageId, '', [], [{}, [updateData]]);\n        }\n      }\n      newList = _babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_18___default()(newList).call(newList, function (item) {\n        if (item.uid === uid) item.status = 'success';\n        return item;\n      });\n    }\n    setDatas((0,_babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_6__[\"default\"])(newList));\n  }, []);\n\n  // 下载\n  var onDownload = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useCallback)(function (info) {\n    var _context4, _context5;\n    var config = model.getConfig(pageId);\n    var file = uploadRef.current.get(info.uid);\n    var options = {\n      params: '1',\n      appId: config.appId,\n      fId: config.formId,\n      fileName: file.name\n    };\n    var url = _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_15___default()(_context4 = _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_15___default()(_context5 = \"\".concat(getFullUrl(baseUrl.current, file.url))).call(_context5, shareParam ? '&' : '?', \"kd_cs_ticket=\")).call(_context4, model.Global.token);\n    (0,_utils__WEBPACK_IMPORTED_MODULE_25__.downloadFile)(url, options);\n  }, []);\n\n  // 删除\n  var onRemove = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useCallback)(function (file) {\n    var newData = (datas === null || datas === void 0 ? void 0 : _babel_runtime_corejs3_core_js_stable_instance_filter__WEBPACK_IMPORTED_MODULE_9___default()(datas).call(datas, function (item) {\n      return item.uid !== file.uid;\n    })) || [];\n    var newFile = uploadRef.current.get(file.uid); // 上传成功列表\n    setDatas((0,_babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_6__[\"default\"])(newData));\n    if (newFile) {\n      var _context6;\n      // 上传成功文件,更新postData\n      uploadRef.current.delete(file.uid);\n      var _str2 = uploadRef.current.size > 0 ? _babel_runtime_corejs3_core_js_stable_json_stringify__WEBPACK_IMPORTED_MODULE_20___default()((0,_babel_runtime_corejs3_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_6__[\"default\"])(_babel_runtime_corejs3_core_js_stable_instance_values__WEBPACK_IMPORTED_MODULE_21___default()(_context6 = uploadRef.current).call(_context6))) : '';\n      if (onChange) return onChange(_str2);\n      var postValue = {\n        k: id,\n        r: 0,\n        v: _str2\n      };\n      model.batchInvoke('updateValue', pageId, '', [], [{}, [postValue]]);\n      // model.setPostData(pageId, id, str) // 走postData\n    }\n    return true;\n  }, [datas]);\n\n  // 监听系统U指令-回调\n  var updateValue = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useCallback)(function (info) {\n    if (info.v) {\n      setDatas(transformData(info.v));\n    } else {\n      uploadRef.current = new (_babel_runtime_corejs3_core_js_stable_map__WEBPACK_IMPORTED_MODULE_17___default())();\n      setDatas([]);\n    }\n  }, []);\n\n  // 侦听u指令\n  model.useUpdateControlStates(controlMeta, updateValue);\n  (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useEffect)(function () {\n    updateValue({\n      k: id,\n      v: value\n    });\n  }, [value]);\n\n  // useEffect(() => {\n  //   // updatevalue之后会U指令更新uploadRef及datas，可能会更新不及时，所以侦听datas\n  //   const label = !displayCount || readonly || disabled ? '' : `(${uploadRef.current.size}/${uploadNum?.max || 1})`\n  //   setLabelText(label)\n  // }, [displayCount, readonly, disabled, uploadNum, datas])\n\n  var limit = uploadNum || {}; // 最大/最小上传数量\n\n  // 转换\n  var typeArr = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useMemo)(function () {\n    var _context7;\n    return _babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_18___default()(_context7 = imageFileType.split(',')).call(_context7, function (item) {\n      return ops[item];\n    });\n  }, [imageFileType]);\n\n  // 可接受的图片类型\n  var accept = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useMemo)(function () {\n    return _babel_runtime_corejs3_core_js_stable_instance_map__WEBPACK_IMPORTED_MODULE_18___default()(typeArr).call(typeArr, function (item) {\n      return '.' + item;\n    }).join(',');\n  }, [typeArr]);\n  // 提示语\n  var notice = (0,kd_libs_react__WEBPACK_IMPORTED_MODULE_22__.useMemo)(function () {\n    var _context8, _context9, _context10;\n    return uploadPrompt ? _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_15___default()(_context8 = _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_15___default()(_context9 = _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_15___default()(_context10 = \"\\u8BF7\\u4E0A\\u4F20\\u5C0F\\u4E8E\".concat(fileMaxSize, \"M\\u7684\")).call(_context10, typeArr.join('、'), \"\\u6587\\u4EF6\\uFF0C\\u6587\\u4EF6\\u4E2A\\u6570\\u4E0D\\u5C11\\u4E8E\")).call(_context9, (limit === null || limit === void 0 ? void 0 : limit.min) || 0, \"\\u4E2A\\uFF0C\\u4E0D\\u591A\\u4E8E\")).call(_context8, (limit === null || limit === void 0 ? void 0 : limit.max) || 1, \"\\u4E2A\\u3002\") : '';\n  }, [uploadPrompt, fileMaxSize, typeArr, limit]);\n\n  // 显示上传数量\n  var labelText = !displayCount || readonly || disabled ? '' : _babel_runtime_corejs3_core_js_stable_instance_concat__WEBPACK_IMPORTED_MODULE_15___default()(_context11 = \"(\".concat(uploadRef.current.size, \"/\")).call(_context11, (uploadNum === null || uploadNum === void 0 ? void 0 : uploadNum.max) || 1, \")\");\n  return {\n    action: PICTURE_ACTION,\n    notice: notice,\n    labelText: labelText,\n    datas: datas || [],\n    readonly: readonly,\n    disabled: disabled,\n    hidden: hidden,\n    required: required,\n    rules: rules,\n    enablePreview: enablePreview,\n    buttonText: buttonText,\n    fieldTitleRef: fieldTitleRef,\n    baseUrl: baseUrl.current || '',\n    limit: limit,\n    accept: accept,\n    onRemove: onRemove,\n    handleChange: handleChange,\n    onDownload: onDownload\n  };\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (usePictureHooks);\n\n//# sourceURL=webpack://nocode-component/./src/control/hooks/usePictureHooks.ts?");

/***/ })

}]);