import { Dict } from '@zenview/micro-basic-library';
import base64 from './base64'
const  { znqjimg, qjimg, zpjimg, mjimg, dzimg, dbimg, wifiimg, clzpjimg, xfsimg, znjgimg, wgsbimg, menciimg } = base64;

const qtimg = znqjimg; // 其他
// const { Dict } = window;
const { znxj, qj, db, wifi, mj, wgsb, dz, xfs, znjg, qt } = Dict.device;
const { ptjk, rlzp, zpj, clzpj, qmbzpj, ydjc, qtzp, menci } = Dict.device;

/**根据设备类型和状态获取设备展示图标 */
export const getCameraTypeIcon = (type, status) => {
  const onLine = status * 1 === 1;
  let option = {};
  if (znxj.value.includes(type)) {
    option.url = znqjimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_Smart';
  }
  if (qj.value.includes(type)) {
    option.url = qjimg;
    option.color = !onLine ? '#ccc' : 'rgba(43, 153, 255, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_Ball';
  }
  if (zpj.value.includes(type)) {
    option.url = zpjimg;
    option.color = !onLine ? '#ccc' : 'rgba(193, 100, 207, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_Gun';
  }
  if (db.value.includes(type)) {
    option.url = dbimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_Phone';
  }
  if (mj.value.includes(type)) {
    option.url = mjimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_Door';
  }
  // if (zj.value == type) {
  //   option.url = zjimg;
  //   option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
  //   option.bgColor = !onLine ? '#ccc' : '#17bc84';
  //   option.icon = "icon-S_Point_Car";
  // }
  if (wifi.value.includes(type)) {
    option.url = wifiimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Bar_Wifi';
  }
  if (clzpj.value.includes(type)) {
    option.url = clzpjimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_Car';
  }
  if (wgsb.value.includes(type)) {
    option.url = wgsbimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_Wifi';
  }
  if (dz.value.includes(type)) {
    option.url = dzimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_Car';
  }
  if (xfs.value.includes(type)) {
    option.url = xfsimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Device_firehydrant';
  }
  if (znjg.value.includes(type)) {
    option.url = znjgimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Device_welllid';
  }
  if (qt.value.includes(type)) {
    option.url = qtimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_Smart';
  }
  if (ptjk.value.includes(type)) {
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_Camera';
  }
  if (rlzp.value.includes(type)) {
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Camera_FaceCamera';
  }
  if (qmbzpj.value.includes(type)) {
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Camera_AllCamera';
  }
  if (ydjc.value.includes(type)) {
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Camera_MovingCamera';
  }
  if (qtzp.value.includes(type)) {
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_CameraSmart';
  }

  if (menci.value === type) {
    option.url = menciimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-menci';
  }

  if (Object.keys(option).length === 0) {
    console.debug('未获取到设备类型！返回默认');
    option.url = znqjimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#29CCCC';
    option.icon = 'icon-S_Point_CameraSmart';
  }
  option.isOnline = onLine;
  return option;
};

/**根据设备类型和状态获取图标和对应颜色及方向颜色，图上研判 */
export const getCameraIconColor = (type, status) => {
  const onLine = status * 1 === 1;
  let option = {};
  if (znxj.value.includes(type)) {
    //智能枪机
    option.url = znqjimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#23C33D';
    option.icon = 'icon-S_Point_Smart';
    option.shadowColor = '#318568';
  }
  if (qj.value.includes(type)) {
    //球机
    option.url = qjimg;
    option.color = !onLine ? '#ccc' : 'rgba(43, 153, 255, 1)';
    option.bgColor = !onLine ? '#ccc' : '#C752D1';
    option.icon = 'icon-S_Point_Ball';
    option.shadowColor = '#B81B6B';
  }
  if (zpj.value.includes(type)) {
    //人像抓拍机
    option.url = zpjimg;
    option.color = !onLine ? '#ccc' : 'rgba(193, 100, 207, 1)';
    option.bgColor = !onLine ? '#ccc' : '#0FB2DA';
    option.icon = 'icon-S_Camera_FaceCamera';
    option.shadowColor = '#1E619E';
  }
  if (db.value.includes(type)) {
    //单兵
    option.url = dbimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#ACC730';
    option.icon = 'icon-S_Point_Phone';
    option.shadowColor = '#A7781D';
  }
  if (mj.value.includes(type)) {
    //门禁
    option.url = mjimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#FFD200';
    option.icon = 'icon-S_Point_Door';
    option.shadowColor = '#A7781D';
  }
  // if (zj.value == type) {//闸机
  //   option.url = zjimg;
  //   option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
  //   option.bgColor = !onLine ? '#ccc' : '#17bc84';
  //   option.icon = "icon-S_Point_Car";
  // }
  if (wifi.value.includes(type)) {
    //wifi探针
    option.url = wifiimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#FC3EA9';
    option.icon = 'icon-S_Bar_Wifi';
    option.shadowColor = '#A7781D';
  }
  if (clzpj.value.includes(type)) {
    //车辆抓拍机
    option.url = clzpjimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#F29D09';
    option.icon = 'icon-S_Camera_CarBayonet';
    option.shadowColor = '#A7781D';
  }
  if (Object.keys(option).length === 0) {
    console.debug('未获取到设备类型！返回默认');
    option.url = znqjimg;
    option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
    option.bgColor = !onLine ? '#ccc' : '#17bc84';
    option.icon = 'icon-S_Point_CameraSmart';
  }
  option.isOnline = onLine;
  return option;
};

export const getCameraTypeIconWithType = (type) => {
  let option = {};
  if (znxj.value.includes(type)) {
    option.url = znqjimg;
    option.icon = 'icon-S_Point_Smart';
  }
  if (qj.value.includes(type)) {
    option.url = qjimg;
    option.icon = 'icon-S_Point_Ball';
  }
  if (zpj.value.includes(type)) {
    option.url = zpjimg;
    option.icon = 'icon-S_Point_Gun';
  }
  if (db.value.includes(type)) {
    option.url = dbimg;
    option.icon = 'icon-S_Point_Phone';
  }
  if (mj.value.includes(type)) {
    option.url = mjimg;
    option.icon = 'icon-S_Point_Door';
  }
  // if (zj.value == type) {
  //   option.url = zjimg;
  //   option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
  //   option.bgColor = !onLine ? '#ccc' : '#29CCCC';
  //   option.icon = "icon-S_Point_Car";
  // }
  if (wifi.value.includes(type)) {
    option.url = wifiimg;
    option.icon = 'icon-S_Point_Wifi';
  }
  if (clzpj.value.includes(type)) {
    option.url = clzpjimg;
    option.icon = 'icon-S_Point_Car';
  }
};

export function getDomIconFont(type, className = '') {
  return `<i tabindex="-1" class="anticon ${className}"><svg width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><use xlink:href="#${type}"></use></svg></i>`;
}
