function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _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) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // @ts-nocheck import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react'; import { ConfigProvider, Descriptions, Modal, Tabs, CropperImage, AttachImage, VideoPlayer, BtnGroup, RelatedImage } from '@zhst/meta'; import classNames from 'classnames'; import { get, isEmpty, pick } from '@zhst/func'; import Navigation from "./components/navigation"; import CombineImage from "./components/CombineImage"; import "./index.less"; import { jsx as _jsx } from "react/jsx-runtime"; import { Fragment as _Fragment } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; var DescriptionsItem = Descriptions.Item; export var componentPrefix = 'zhst-image'; // 对比图模式、场景图模式、视频模式 var initialStyle = { fontSize: '12px' }; var BigImageModal = /*#__PURE__*/forwardRef(function (props, ref) { var _props$title = props.title, title = _props$title === void 0 ? '-' : _props$title, width = props.width, open = props.open, children = props.children, onCancel = props.onCancel, activeTab = props.activeTab, _props$attributeList = props.attributeList, attributeList = _props$attributeList === void 0 ? [] : _props$attributeList, _props$isRelated = props.isRelated, isRelated = _props$isRelated === void 0 ? false : _props$isRelated, _props$tabs = props.tabs, tabs = _props$tabs === void 0 ? {} : _props$tabs, _props$footer = props.footer, footer = _props$footer === void 0 ? null : _props$footer, _props$dataSource = props.dataSource, dataSource = _props$dataSource === void 0 ? {} : _props$dataSource, onTabChange = props.onTabChange, compareImageProps = props.compareImageProps, showNavigation = props.showNavigation, modalProps = props.modalProps, cropperImageProps = props.cropperImageProps, prevButtonProps = props.prevButtonProps, onPrevButtonClick = props.onPrevButtonClick, onNextButtonClick = props.onNextButtonClick, nextButtonProps = props.nextButtonProps, tabsProps = props.tabsProps, btnGroupProps = props.btnGroupProps, descriptionsProps = props.descriptionsProps, relatedImageProps = props.relatedImageProps, theme = props.theme; var combineImageRef = useRef(null); var videoPlayerRef = useRef(null); var modalRef = useRef(null); // ========================== 头切换 ========================= var _useState = useState(activeTab || get(tabsProps, 'data[0].key')), _useState2 = _slicedToArray(_useState, 2), tab = _useState2[0], setTab = _useState2[1]; var _useState3 = useState('related'), _useState4 = _slicedToArray(_useState3, 2), activeKey = _useState4[0], setActiveKey = _useState4[1]; // ========================= 预览切换下标 ========================= var _useState5 = useState('auto'), _useState6 = _slicedToArray(_useState5, 2), cropType = _useState6[0], setCropType = _useState6[1]; var cropBtnDataSource = [{ key: 'close', icon: 'icon-danchuangguanbi', title: '退出' }, { key: 'auto', icon: 'icon-zidong', title: '智能框选' }, { key: 'custom', icon: 'icon-shoudong', title: '手动框选' }]; var handleCropBtnClick = function handleCropBtnClick(v) { setCropType(v); }; var defaultTabsProps = !isEmpty(tabs) ? tabs : { items: [{ label: '对比图模式', key: 'COMPATER', children: /*#__PURE__*/_jsx(CombineImage, _objectSpread({ ref: combineImageRef, data: pick(dataSource, 'compaterImage', 'imgSummary', 'imageKey', 'score') }, compareImageProps)) }, { label: '场景图模式', key: 'NORMAL', children: /*#__PURE__*/_jsx("div", { style: { display: 'flex', justifyContent: 'center', width: '100%' }, children: /*#__PURE__*/_jsx("div", { style: { width: '85%', height: '500px' }, children: /*#__PURE__*/_jsxs(CropperImage, _objectSpread(_objectSpread({ type: "rect", odList: get(dataSource, 'odRect', []) }, cropperImageProps), {}, { children: [!(cropperImageProps !== null && cropperImageProps !== void 0 && cropperImageProps.editAble) && /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(AttachImage, { data: [{ label: '测试', url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png' }] }), /*#__PURE__*/_jsx("div", { style: { position: 'absolute', right: '24px', bottom: '24px', fontSize: '18px', color: 'red', cursor: 'default' }, children: "\u4EBA\u8138\u8D28\u91CF\u5206\uFF1A".concat(Number(cropperImageProps === null || cropperImageProps === void 0 ? void 0 : cropperImageProps.score).toFixed(2)) })] }), (cropperImageProps === null || cropperImageProps === void 0 ? void 0 : cropperImageProps.showEditTools) && /*#__PURE__*/_jsx(BtnGroup, _objectSpread({ circle: true, style: { position: 'absolute', top: 0, right: 0 }, dataSource: cropBtnDataSource, onClick: handleCropBtnClick, selectKey: cropType }, btnGroupProps))] })) }) }) }] }; // 暴露 ref 实例 useImperativeHandle(ref, function () { return { ref: ref, tab: tab, setTab: setTab, modalRef: modalRef, activeKey: activeKey, setActiveKey: setActiveKey, videoPlayerRef: videoPlayerRef, combineImageRef: combineImageRef }; }); return /*#__PURE__*/_jsxs(Modal, _objectSpread(_objectSpread({ destroyOnClose: true, width: width, open: open, ref: modalRef, footer: footer, className: componentPrefix, title: title, onCancel: onCancel }, modalProps), {}, { children: [/*#__PURE__*/_jsxs("div", { style: { marginTop: '16px' }, children: [/*#__PURE__*/_jsx(ConfigProvider, { theme: _objectSpread({ token: { colorTextSecondary: 'rgba(0,0,0,0.45)' }, components: { Descriptions: { titleMarginBottom: '20px', viewBg: '#f6f6f6', titleColor: 'rgba(0,0,0,0.45)', colorTextLabel: 'rgba(0,0,0,0.45)', contentColor: 'rgba(0,0,0,0.88)' } } }, theme), children: attributeList.map(function (descriptions) { var _descriptions$childre; return /*#__PURE__*/_jsx(Descriptions, _objectSpread(_objectSpread({ title: /*#__PURE__*/_jsx("p", { style: { margin: '12px 0 0', fontSize: initialStyle.fontSize }, children: descriptions.title }), column: 8, style: { padding: '0 64px' } }, descriptionsProps), {}, { children: descriptions === null || descriptions === void 0 || (_descriptions$childre = descriptions.children) === null || _descriptions$childre === void 0 ? void 0 : _descriptions$childre.map(function (item) { return /*#__PURE__*/_jsx(DescriptionsItem, { label: item.label, span: 1, contentStyle: { fontSize: initialStyle.fontSize }, labelStyle: { fontSize: initialStyle.fontSize }, children: item.children }, item.key); }) }), descriptions.title); }) }), /*#__PURE__*/_jsxs("div", { className: classNames("".concat(componentPrefix, "-view-container")), children: [/*#__PURE__*/_jsx(Tabs, _objectSpread(_objectSpread({ activeKey: tab, centered: true, destroyInactiveTabPane: true, onChange: function onChange(v) { setTab(function (pre) { onTabChange === null || onTabChange === void 0 || onTabChange(v, pre); return v; }); }, tabBarStyle: { fontSize: '18px', fontWeight: 'bold' } }, defaultTabsProps), tabsProps)), tab === 'VIDEO' && /*#__PURE__*/_jsx(VideoPlayer, { ref: videoPlayerRef, url: dataSource === null || dataSource === void 0 ? void 0 : dataSource.flvUrl }), /*#__PURE__*/_jsx(Navigation, _objectSpread({ className: classNames("".concat(componentPrefix, "-view-container__nav"), (prevButtonProps === null || prevButtonProps === void 0 ? void 0 : prevButtonProps.disabled) && "".concat(componentPrefix, "-view-container__nav--disabled"), "".concat(componentPrefix, "-view-container__nav--left")), prev: true, show: showNavigation, onClick: onPrevButtonClick }, prevButtonProps)), /*#__PURE__*/_jsx(Navigation, _objectSpread({ className: classNames("".concat(componentPrefix, "-view-container__nav"), (nextButtonProps === null || nextButtonProps === void 0 ? void 0 : nextButtonProps.disabled) && "".concat(componentPrefix, "-view-container__nav--disabled"), "".concat(componentPrefix, "-view-container__nav--right")), next: true, show: showNavigation, onClick: onNextButtonClick }, nextButtonProps)), isRelated && /*#__PURE__*/_jsx("div", { style: { margin: '24px 0' }, children: /*#__PURE__*/_jsx(RelatedImage, _objectSpread({}, relatedImageProps)) })] })] }), children] })); }); export default BigImageModal;