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); }
import BridgeBase from "./base";
import _back from "./utils/back";
import _ready from "./utils/ready";

// 内库使用-start
import Device from "./../Device";
import Toast from "./../../components/Toast";
import LocaleUtil from "./../LocaleUtil";
// 内库使用-end

/* 测试使用-start
import { Device, Toast, LocaleUtil } from 'seedsui-react'
测试使用-end */

var Bridge = _objectSpread(_objectSpread({}, BridgeBase), {}, {
  ready: function ready(callback, options) {
    _ready(callback, options, 'browser');
  },
  back: function back(backLvl, options) {
    _back(backLvl, options, Bridge);
  },
  /**
   * 定制功能
   */
  platform: 'browser',
  // 配置鉴权
  getLocation: function getLocation() {
    var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    Bridge.getBrowserLocation(params);
  },
  // 获得版本信息
  getAppVersion: function getAppVersion() {
    return '';
  },
  // 退出到登陆页面
  logOut: function logOut() {
    console.log('logOut方法仅在app上工作');
  },
  // 打开新的窗口
  openWindow: function openWindow() {
    var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    var url = params.url;
    if (url.indexOf('h5:') === 0) url = url.replace(/^h5:/, '');else if (url.indexOf('webview:') === 0) url = url.replace(/^webview:/, '');
    if (params.target === '_self') {
      window.location.replace(url);
    }
    if (Device.device === 'pc') {
      window.open(url);
      return;
    }
    if (url) window.location.href = url;
  },
  // 关闭窗口
  closeWindow: function closeWindow() {
    window.history.go(-1);
  },
  // 返回监听
  onHistoryBack: function onHistoryBack() {
    Toast.show({
      content: LocaleUtil.locale('onHistoryBack仅可在企业微信或APP中使用', 'SeedsUI_onHistoryBack_prompt')
    });
  },
  // setTitle: '已在base中实现'
  /**
   * 扫描二维码并返回结果
   * @param {Object} params
   * @return {Object} {resultStr: ''}
   */
  scanQRCode: function scanQRCode() {
    var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    if (!this.debug) {
      Toast.show({
        content: LocaleUtil.locale('此功能仅可在微信或APP中使用', 'SeedsUI_only_app_wechat', ['scanQRCode'])
      });
      if (params.fail) params.fail({
        errMsg: "scanQRCode:".concat(LocaleUtil.locale('扫码失败', 'SeedsUI_scanCode_failed'), ", ").concat(LocaleUtil.locale('请稍后重试', 'SeedsUI_try_again_later'))
      });
      return;
    }
    setTimeout(function () {
      if (params.success) params.success({
        resultStr: '504823170310092750280333'
      });
    }, 500);
  },
  // 视频文件上传
  uploadFile: function uploadFile() {
    Toast.show({
      content: LocaleUtil.locale('uploadFile仅可在APP中使用', 'SeedsUI_uploadFile_prompt', ['uploadFile'])
    });
  }
});
export default Bridge;