import React__default from 'react';
import { Row, Col, Checkbox, Tooltip, Popover } from 'antd';
import IconFont from './IconFont/index.js';
import { I as ImageCard, S as SingleColumnCard, B as BaseCard } from './index-dd375369.js';
import { _ as _extends } from './_rollupPluginBabelHelpers-736b301a.js';
import CaptureBox from './CaptureCard/index.js';
import { Dict } from '@zenview/micro-basic-library';

/**
 * @desc 单列卡片
 * @param {boolean} active 是否选中
 * @param {function} click 回调
 * @param {array} data 卡片数据
 */
const BaseIconCard = props => {
  const {
    click,
    icon,
    data,
    title,
    className = '',
    style
  } = props;
  return /*#__PURE__*/React__default.createElement("div", {
    className: `lm-base-icon-card ${className}`,
    style: style,
    onClick: () => click && click()
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "lm-base-icon-box"
  }, /*#__PURE__*/React__default.createElement(IconFont, {
    type: icon
  })), /*#__PURE__*/React__default.createElement("div", {
    className: "lm-base-icon-card-content"
  }, title && /*#__PURE__*/React__default.createElement("div", {
    title: title.info,
    className: "lm-base-icon-card-content-title"
  }, /*#__PURE__*/React__default.createElement(IconFont, {
    type: title.icon
  }), /*#__PURE__*/React__default.createElement("span", {
    className: "lm-base-icon-card-content-label",
    title: title.label
  }, title.label)), /*#__PURE__*/React__default.createElement(Row, {
    className: "lm-base-icon-card-content-view"
  }, data.map((v, k) => {
    return /*#__PURE__*/React__default.createElement(Col, {
      key: k,
      span: "12"
    }, /*#__PURE__*/React__default.createElement(Card.CardInfo, {
      icon: v.icon,
      label: v.label,
      info: v.info
    }));
  }))));
};

/**
 * @desc 俩列单图卡片
 * @param {boolean} active 是否选中
 * @param {function} click 回调
 * @param {array} data 卡片转换数据
 * @param {array} sourceData 卡片源数据
 * @param {node} children 卡片信息
 * @param {node} footer 底部拓展
 */
const TwoColumnCard = props => {
  let {
    active = false,
    click,
    children,
    footer,
    sourceData,
    className = ''
  } = props;
  return /*#__PURE__*/React__default.createElement("div", {
    className: `lm-two-column-card ${className} ${active ? 'active' : ''} ${footer ? 'has-footer' : ''}`,
    onClick: () => click && click(sourceData)
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "lm-two-column-card-header"
  }, /*#__PURE__*/React__default.createElement(ImageCard, props), /*#__PURE__*/React__default.createElement("div", {
    className: "lm-two-column-card-info"
  }, children)), footer);
};

/**
 * @desc 人员档案卡片
 * @param {array} data 卡片数据 [{infos:[info,icon],label?}]
 * @param {string} icon 图标
 * @param {string} info 信息
 * @param {func} onFollow 关注回调
 * @param {func} onRelation 关联回调
 * @param {node} children 子组件
 */
const PersonCard = props => {
  const {
    sourceData = {},
    data = [],
    onFollow,
    onRelation = false,
    toRelationship,
    children,
    onPersonnel
  } = props;
  const passDevice = sourceData.passDevice ? Object.values(sourceData.passDevice) : [];
  const passPlace = sourceData.passPlace ? Object.values(sourceData.passPlace) : [];
  const text = passDevice[0] ? `在"${passDevice[0]}"设备下经过` : passPlace[0] ? `在"${passPlace[0]}"出现过` : '';
  return /*#__PURE__*/React__default.createElement(TwoColumnCard, props, /*#__PURE__*/React__default.createElement("div", {
    className: "lm-persom-card-popovers"
  }, onFollow && /*#__PURE__*/React__default.createElement(Card.CardPopover, {
    key: "onFollow",
    content: sourceData.isFocus ? '取消关注' : '关注',
    icon: sourceData.isFocus ? 'icon-S_Photo_FollowYes' : 'icon-S_Photo_FollowNo',
    style: {
      color: sourceData.isFocus ? 'var(--primary)' : 'var(--icon)'
    },
    callBack: e => onFollow(sourceData, e)
  }), onRelation && /*#__PURE__*/React__default.createElement(Card.CardPopover, {
    key: "onRelation",
    style: {
      color: "var(--primary)"
    },
    content: "\u5173\u8054",
    icon: "icon-S_Bar_Linked",
    callBack: e => onRelation(sourceData, e)
  }), toRelationship && /*#__PURE__*/React__default.createElement(Card.CardPopover, {
    key: "toRelationship",
    style: {
      color: 'var(--primary)'
    },
    content: "\u5173\u7CFB\u56FE\u8C31",
    icon: "icon-S_Photo_Relationship",
    callBack: e => toRelationship(sourceData, e)
  }), onPersonnel && /*#__PURE__*/React__default.createElement(Card.CardPopover, {
    key: "onPersonnel",
    style: {
      color: 'var(--primary)'
    },
    content: "\u4EBA\u5458\u6863\u6848",
    icon: "icon-S_Edit_Avatar",
    callBack: e => onPersonnel(sourceData, e)
  })), data.map((item, i) => /*#__PURE__*/React__default.createElement(Card.PersonCardInfo, _extends({
    key: `card-info-${i}`
  }, item))), children, text && /*#__PURE__*/React__default.createElement("div", {
    title: text,
    className: "person-card-footer-info-place ellipsis"
  }, text));
};

class Similar extends React__default.Component {
  constructor(...args) {
    super(...args);
    this.onChange = e => {
      const checked = e.target.checked;
      this.props.onClick && this.props.onClick(checked, this.props.data);
    };
  }
  render() {
    const {
      data = {},
      imgUrl
    } = this.props;
    return /*#__PURE__*/React__default.createElement(CaptureBox, {
      className: "similar-card",
      hoverScale: false,
      imgUrl: imgUrl,
      score: data.score,
      checkboxItem: /*#__PURE__*/React__default.createElement(Checkbox, {
        checked: data.checked,
        onChange: this.onChange
      })
    });
  }
}

/**
 * @desc 车辆档案卡片
 * @param {array} data 卡片数据 [{infos:[info,icon],label?}]
 * @param {string} icon 图标
 * @param {string} info 信息
 * @param {func} onFollow 关注回调
 * @param {func} onRelation 关联回调
 * @param {node} children 子组件
 */
const VehicleFileCard = props => {
  const {
    sourceData = {},
    data = [],
    onFollow,
    children
  } = props;
  const passDevice = sourceData.passDevice ? Object.values(sourceData.passDevice) : [];
  const passPlace = sourceData.passPlace ? Object.values(sourceData.passPlace) : [];
  const text = passDevice[0] ? `在"${passDevice[0]}"设备下经过` : passPlace[0] ? `在"${passPlace[0]}"出现过` : "";
  return /*#__PURE__*/React__default.createElement(TwoColumnCard, props, /*#__PURE__*/React__default.createElement("div", {
    className: "lm-persom-card-popovers"
  }, onFollow && /*#__PURE__*/React__default.createElement(Card.CardPopover, {
    key: "onFollow",
    content: sourceData.hadFocus ? "取消关注" : "关注",
    icon: sourceData.hadFocus ? "icon-S_Photo_FollowYes" : "icon-S_Photo_FollowNo",
    style: {
      color: sourceData.hadFocus ? "var(--primary)" : "var(--icon)"
    },
    callBack: e => onFollow(sourceData, e)
  })), data.map((item, i) => /*#__PURE__*/React__default.createElement(Card.VehicleCardInfo, _extends({
    key: `card-info-${i}`
  }, item))), children, text && /*#__PURE__*/React__default.createElement("div", {
    title: text,
    className: "vehicle-card-footer-info-place ellipsis"
  }, text));
};

/**
 * @desc 图库卡片
 * @param {array} data 卡片数据 [{info,icon,click,relateds:[{title,icon,click}]}]
 * @param {string} icon 图标
 * @param {string} info 信息
 */
const LibraryCard = props => {
  const {
    score,
    hasArchives
  } = props;
  return /*#__PURE__*/React__default.createElement(SingleColumnCard, _extends({}, props, {
    hoverScale: true,
    outChildren: /*#__PURE__*/React__default.createElement("div", {
      className: "library-card-tip"
    }, score && /*#__PURE__*/React__default.createElement("span", {
      className: "library-card-score"
    }, `${props.score >= 100 ? 99 : parseInt(props.score)}%`), hasArchives && /*#__PURE__*/React__default.createElement("span", {
      className: "library-card-aid"
    }, /*#__PURE__*/React__default.createElement(IconFont, {
      type: "icon-S_View_FilePerson"
    })))
  }), getAssociationRetrieval(props));
};

/**
 * @desc 获取关联检索图标
 */
const getIcon = data => {
  const {
    title,
    click,
    icon
  } = data;
  const clickFn = e => {
    e.stopPropagation();
    click && click(data);
  };
  return /*#__PURE__*/React__default.createElement(Tooltip, {
    key: `${icon}_${title}`,
    title: title,
    onClick: clickFn
  }, /*#__PURE__*/React__default.createElement(IconFont, {
    type: icon
  }));
};

/**
 * @desc 获取关联检索列表
 */
const getAssociationRetrieval = props => {
  let {
    relateds = []
  } = props;
  return !!relateds.length && /*#__PURE__*/React__default.createElement("div", {
    className: "library-card-search-icon"
  }, relateds.map(v => /*#__PURE__*/React__default.isValidElement(v) ? v : getIcon(v)));
};

const CardTip = ({
  hasScore,
  hasAid,
  score
}) => {
  return /*#__PURE__*/React__default.createElement("div", {
    className: "library-card-tip"
  }, hasScore && score && /*#__PURE__*/React__default.createElement("span", {
    className: "library-card-score"
  }, `${score >= 100 ? 99 : parseInt(score)}%`), hasAid && /*#__PURE__*/React__default.createElement("span", {
    className: "library-card-aid"
  }, /*#__PURE__*/React__default.createElement(IconFont, {
    type: "icon-S_View_FilePerson"
  })));
};

/**
 * 场景卡片
 * @param {*} isBase 背景图
 * @param {*} index 场景的索引
 * @param {*} sceneItem 卡片信息
 * @param {*} renderControl 操作栏(可选)
 * @param {*} renderTip 场景的系统数量标签(可选)
 */
const SceneCard = ({
  isBase,
  index = 0,
  sceneItem,
  renderControl,
  renderTip
}) => {
  let placeTags = Dict.useDict('119100');
  const colorArr = [['#2D374B', '#8C919C', '#2C3443'], ['#01AF84', '#3E9B9A', '#035452'], ['#AE4358', '#E98085', '#641727'], ['#D67B12', '#D19039', '#A05700']];
  const baseColorArr = [['rgba(59, 117, 220, 1)', 'rgba(59, 117, 220, 0.4)', '#18327C'], ['rgba(102, 102, 204, 1)', 'rgba(102, 102, 204, 0.4)', '#2A2A64'], ['rgba(50, 158, 101, 1)', 'rgba(50, 158, 101, 0.4)', '#1D4A33'], ['rgba(0, 190, 249, 0.47)', 'rgba(0, 190, 249, 0.3)', '#042A48']];
  let ind = index % 4;
  let showColor = isBase ? baseColorArr[ind] : colorArr[ind];
  return /*#__PURE__*/React__default.createElement("div", {
    className: "scene-card"
  }, renderTip && renderTip(), /*#__PURE__*/React__default.createElement("div", {
    className: "scene-card-bg",
    style: {
      background: `linear-gradient(45deg, ${showColor[0]} 0%, ${isBase ? 'rgba(0,0,0,0)' : showColor[1]} 100%)`
    }
  }), isBase ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
    style: {
      background: ` url(/micro-apps/micro-dep-librarys/images/${ind + 1}.png)`
    },
    className: "scene-card-base-bg"
  }), /*#__PURE__*/React__default.createElement("div", {
    style: {
      background: `linear-gradient(45deg, ${showColor[1]} 0%, rgba(0,0,0,0) 100%)`
    },
    className: "scene-card-mask"
  })) : null, /*#__PURE__*/React__default.createElement("div", {
    className: "card-title",
    style: {
      background: showColor[2]
    }
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "card-title-tip",
    style: {
      background: showColor[2]
    }
  }), /*#__PURE__*/React__default.createElement(NormalBox, {
    className: "card-title-content"
  }, sceneItem.name)), /*#__PURE__*/React__default.createElement("div", {
    className: "card-desc"
  }, /*#__PURE__*/React__default.createElement(NormalBox, {
    title: sceneItem.describe,
    className: "card-desc-content"
  }, sceneItem.describe)), /*#__PURE__*/React__default.createElement("div", {
    className: "card-label"
  }, /*#__PURE__*/React__default.createElement(NormalBox, {
    className: "card-label-content"
  }, Array.isArray(sceneItem.tags) && sceneItem.tags.length && sceneItem.tags.slice(0, 5).map(v => {
    let item = placeTags.find(j => j.code === v);
    return /*#__PURE__*/React__default.createElement("div", {
      key: item.code,
      className: "scene-tags-item"
    }, /*#__PURE__*/React__default.createElement(IconFont, {
      type: item.icon
    }), item.label);
  }), Array.isArray(sceneItem.tags) && sceneItem.tags.length ? /*#__PURE__*/React__default.createElement(Tooltip, {
    placement: "bottom",
    title: () => {
      return /*#__PURE__*/React__default.createElement("div", {
        className: "scene-tags-item-more-tip"
      }, sceneItem.tags.map(v => {
        let item = placeTags.find(j => j.code === v);
        return /*#__PURE__*/React__default.createElement("div", {
          key: item.code,
          className: "scene-tags-item"
        }, /*#__PURE__*/React__default.createElement(IconFont, {
          type: item.icon
        }), item.label);
      }));
    }
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "scene-tags-item-more"
  }, /*#__PURE__*/React__default.createElement(IconFont, {
    type: "icon-S_Edit_More"
  }), "\u66F4\u591A")) : null)), renderControl && renderControl());
};
const NormalBox = ({
  className,
  children,
  title
}) => {
  return /*#__PURE__*/React__default.createElement("div", {
    title: title,
    className: `scene-card-normal-box ${className}`
  }, children);
};

/**
 * @desc 卡片信息
 * @param {string} info 信息
 * @param {string} icon 图标
 * @param {string} label label
 * @param {string} className 类名
 * @param {number} subStr 需要切割后前后显示得字数  默认为0不切割
 */
const CardInfo = props => {
  let {
    info,
    icon,
    label,
    className
  } = props;
  return /*#__PURE__*/React__default.createElement("div", {
    title: info,
    className: `lm-card-info ${className || ''}`
  }, label && /*#__PURE__*/React__default.createElement("div", {
    className: "title"
  }, /*#__PURE__*/React__default.createElement(IconFont, {
    type: icon
  }), label), info && /*#__PURE__*/React__default.createElement("p", {
    className: "ellipsis"
  }, info));
};

/**
 * @desc 卡片右上角气泡
 * @param {string} content 浮出卡片内容
 * @param {string} icon 图标
 * @param {string} callBack 回调
 * @param {string} data 原始数据
 * @param {ref} popRef 需要挂在的节点
 */
const CardPopover = props => {
  const {
    content,
    icon,
    callBack,
    popRef,
    style
  } = props;
  return /*#__PURE__*/React__default.createElement(Popover, {
    className: "lm-card-popover",
    placement: "left",
    content: content,
    getPopupContainer: () => popRef ? popRef.current : document.body
  }, /*#__PURE__*/React__default.createElement(IconFont, {
    style: style,
    type: icon,
    theme: "outlined",
    className: "popover-icon",
    onClick: callBack
  }));
};

/**
 * @desc 人员档案卡片信息
 * @param {array} infos 信息
 * @param {string} label label
 * @param {string} className 类名
 */
const PersonCardInfo = props => {
  let {
    infos,
    label,
    className
  } = props;
  return /*#__PURE__*/React__default.createElement("div", {
    className: `lm-card-info ${className || ''}`
  }, label && /*#__PURE__*/React__default.createElement("p", {
    className: "ellipsis title"
  }, label), infos.length > 0 && infos.map(v => v.group === 'place' ? /*#__PURE__*/React__default.createElement("div", {
    className: "ellipsis-place"
  }, v.info) : /*#__PURE__*/React__default.createElement("div", {
    key: v.icon,
    style: v.style,
    className: "ellipsis",
    title: v.info
  }, /*#__PURE__*/React__default.createElement(IconFont, {
    type: v.icon
  }), v.info ? v.info : '暂无')));
};

/**
 * @desc 车辆档案卡片信息
 * @param {array} infos 信息
 * @param {string} label label
 * @param {string} className 类名
 */
const VehicleCardInfo = props => {
  let {
    infos,
    label,
    className
  } = props;
  let newinfo = infos[0].info;
  let vehiclnumber = '';
  if (newinfo !== undefined) {
    vehiclnumber = newinfo.slice(0, 2) + '·' + newinfo.slice(2);
  } else {
    vehiclnumber = '暂无';
  }
  return /*#__PURE__*/React__default.createElement("div", {
    className: `lm-card-info plate-info ${className || ''}`
  }, label && /*#__PURE__*/React__default.createElement("p", {
    className: "ellipsis title"
  }, label), infos.length > 0 && infos.map(v => v.group ? v.group === 'plate' ? /*#__PURE__*/React__default.createElement("div", {
    style: {
      display: 'flex',
      alignItems: 'center'
    }
  }, /*#__PURE__*/React__default.createElement(IconFont, {
    type: v.icon
  }), v.type ? /*#__PURE__*/React__default.createElement("div", {
    key: v.icon,
    style: v.style,
    className: `card-plate card-plate-${v.type}`,
    title: v.info
  }, vehiclnumber) : /*#__PURE__*/React__default.createElement("span", {
    style: {
      color: 'var(--primary)'
    }
  }, vehiclnumber)) : /*#__PURE__*/React__default.createElement("div", {
    className: "ellipsis-place"
  }, v.info) : /*#__PURE__*/React__default.createElement("div", {
    key: v.icon,
    style: v.style,
    className: "ellipsis",
    title: v.info
  }, /*#__PURE__*/React__default.createElement(IconFont, {
    type: v.icon
  }), v.info)));
};
const Card = {
  CardInfo,
  CardPopover,
  PersonCardInfo,
  VehicleCardInfo,
  BaseCard,
  BaseIconCard,
  ImageCard,
  PersonCard,
  Similar,
  SingleColumnCard,
  TwoColumnCard,
  VehicleFileCard,
  LibraryCard,
  CardTips: CardTip,
  SceneCard
};

export { BaseIconCard as B, Card as C, PersonCard as P, VehicleFileCard as V, CardPopover as a };
//# sourceMappingURL=index-61c9e04b.js.map
