function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys.push.apply(ownKeys, Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

// import React from 'react';
import classNames from 'classnames';
import { backIcon, shareIcon } from '../../../../assets/IconBase64';
import { browserVersion, sendToAndroid, sendToIos } from '../../../../utils/androidUtil';
import { navigateTo } from '../../../../utils/commonUtil';
import './index.less';

var React = require('react');

export default function pageTitle(props) {
  var _props$data = props.data,
      data = _props$data === void 0 ? {} : _props$data,
      mode = props.mode;

  var onShare = function onShare() {
    if (browserVersion().isApp && browserVersion().ios) {
      sendToIos({
        type: 'SHARE'
      });
      return;
    }

    window.MParams && window.MParams.api && window.MParams.api.showShareModal();
  };

  var onBack = function onBack() {
    if (browserVersion().isApp && browserVersion().android) {
      sendToAndroid({
        type: 'onBack',
        params: {}
      });
      return;
    }

    if (browserVersion().isApp && browserVersion().ios) {
      sendToIos({
        type: 'BACK'
      });
      return;
    }

    navigateTo('/main/home');
  };

  return /*#__PURE__*/React.createElement("div", {
    className: "page-title-wrap"
  }, /*#__PURE__*/React.createElement("div", {
    className: classNames('header-inner', {
      fixed: mode !== 'designer'
    }),
    style: _objectSpread({
      backgroundColor: '#FFF'
    }, props.style)
  }, /*#__PURE__*/React.createElement("div", {
    className: "header-back",
    onClick: onBack
  }, /*#__PURE__*/React.createElement("img", {
    className: "back",
    alt: "back",
    src: backIcon
  })), /*#__PURE__*/React.createElement("div", {
    className: "title"
  }, data.icon && /*#__PURE__*/React.createElement("img", {
    alt: "",
    src: data.icon
  }), /*#__PURE__*/React.createElement("span", null, data.pageName)), /*#__PURE__*/React.createElement("img", {
    className: "share",
    alt: "share",
    src: shareIcon,
    onClick: onShare
  })));
}