// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
parcelRequire = (function (modules, cache, entry, globalName) {
  // Save the require from previous bundle to this closure if any
  var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
  var nodeRequire = typeof require === 'function' && require;

  function newRequire(name, jumped) {
    if (!cache[name]) {
      if (!modules[name]) {
        // if we cannot find the module within our internal map or
        // cache jump to the current global require ie. the last bundle
        // that was added to the page.
        var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
        if (!jumped && currentRequire) {
          return currentRequire(name, true);
        }

        // If there are other bundles on this page the require from the
        // previous one is saved to 'previousRequire'. Repeat this as
        // many times as there are bundles until the module is found or
        // we exhaust the require chain.
        if (previousRequire) {
          return previousRequire(name, true);
        }

        // Try the node require function if it exists.
        if (nodeRequire && typeof name === 'string') {
          return nodeRequire(name);
        }

        var err = new Error('Cannot find module \'' + name + '\'');
        err.code = 'MODULE_NOT_FOUND';
        throw err;
      }

      localRequire.resolve = resolve;
      localRequire.cache = {};

      var module = cache[name] = new newRequire.Module(name);

      modules[name][0].call(module.exports, localRequire, module, module.exports, this);
    }

    return cache[name].exports;

    function localRequire(x){
      return newRequire(localRequire.resolve(x));
    }

    function resolve(x){
      return modules[name][1][x] || x;
    }
  }

  function Module(moduleName) {
    this.id = moduleName;
    this.bundle = newRequire;
    this.exports = {};
  }

  newRequire.isParcelRequire = true;
  newRequire.Module = Module;
  newRequire.modules = modules;
  newRequire.cache = cache;
  newRequire.parent = previousRequire;
  newRequire.register = function (id, exports) {
    modules[id] = [function (require, module) {
      module.exports = exports;
    }, {}];
  };

  var error;
  for (var i = 0; i < entry.length; i++) {
    try {
      newRequire(entry[i]);
    } catch (e) {
      // Save first error but execute all entries
      if (!error) {
        error = e;
      }
    }
  }

  if (entry.length) {
    // Expose entry point to Node, AMD or browser globals
    // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
    var mainExports = newRequire(entry[entry.length - 1]);

    // CommonJS
    if (typeof exports === "object" && typeof module !== "undefined") {
      module.exports = mainExports;

    // RequireJS
    } else if (typeof define === "function" && define.amd) {
     define(function () {
       return mainExports;
     });

    // <script>
    } else if (globalName) {
      this[globalName] = mainExports;
    }
  }

  // Override the current require with this new one
  parcelRequire = newRequire;

  if (error) {
    // throw error from earlier, _after updating parcelRequire_
    throw error;
  }

  return newRequire;
})({"renderer/polyfills/browser.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.shell = exports.settings = exports.remote = exports.log = exports.ipcRenderer = exports.i18NextBackendOptions = exports.i18NextBackend = exports.clipboard = void 0;
const browser = {
  clipboard: {
    writeText: text => navigator.clipboard.writeText(text)
  },
  shell: {
    openExternal: url => window.open(url, '')
  },
  remote: {
    getCurrentWindow: () => ({
      getSize: () => [window.innerWidth, window.innerHeight]
    })
  },
  ipcRenderer: {
    on: evt => {
      console.warn(`Cannot listen for IPC event ${evt} in browser context`); // eslint-disable-line no-console
    }
  },

  fs: null,
  util: null
};
class BrowserSettings {
  has(key) {
    return this.get(key) !== null;
  }
  set(key, val) {
    return localStorage.setItem(key, JSON.stringify(val));
  }
  get(key) {
    return JSON.parse(localStorage.getItem(key));
  }
  getSync(key) {
    return this.get(key);
  }
}
const log = console; // eslint-disable-line no-console
exports.log = log;
const settings = new BrowserSettings();
exports.settings = settings;
const {
  clipboard,
  shell,
  remote,
  ipcRenderer
} = browser;
exports.ipcRenderer = ipcRenderer;
exports.remote = remote;
exports.shell = shell;
exports.clipboard = clipboard;
const i18NextBackend = require('i18next-chained-backend').default;
exports.i18NextBackend = i18NextBackend;
const i18NextBackendOptions = {
  backends: [require('i18next-localstorage-backend').default, require('i18next-http-backend').default],
  backendOptions: [{}, {
    loadPath: './locales/{{lng}}/{{ns}}.json'
  }]
};
exports.i18NextBackendOptions = i18NextBackendOptions;
},{}],"renderer/polyfills/electron.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "clipboard", {
  enumerable: true,
  get: function () {
    return _electron.clipboard;
  }
});
Object.defineProperty(exports, "fs", {
  enumerable: true,
  get: function () {
    return _fs.default;
  }
});
Object.defineProperty(exports, "i18NextBackend", {
  enumerable: true,
  get: function () {
    return _i18nextNodeFsBackend.default;
  }
});
exports.i18NextBackendOptions = void 0;
Object.defineProperty(exports, "ipcRenderer", {
  enumerable: true,
  get: function () {
    return _electron.ipcRenderer;
  }
});
Object.defineProperty(exports, "log", {
  enumerable: true,
  get: function () {
    return _electronLog.default;
  }
});
Object.defineProperty(exports, "remote", {
  enumerable: true,
  get: function () {
    return _electron.remote;
  }
});
Object.defineProperty(exports, "settings", {
  enumerable: true,
  get: function () {
    return _electronSettings.default;
  }
});
Object.defineProperty(exports, "shell", {
  enumerable: true,
  get: function () {
    return _electron.shell;
  }
});
Object.defineProperty(exports, "util", {
  enumerable: true,
  get: function () {
    return _util.default;
  }
});
var _path = _interopRequireDefault(require("path"));
var _electron = require("electron");
var _electronLog = _interopRequireDefault(require("electron-log"));
var _electronSettings = _interopRequireDefault(require("electron-settings"));
var _i18nextNodeFsBackend = _interopRequireDefault(require("i18next-node-fs-backend"));
var _fs = _interopRequireDefault(require("fs"));
var _util = _interopRequireDefault(require("util"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const i18NextBackendOptions = {
  loadPath: _path.default.join(__dirname, 'locales/{{lng}}/{{ns}}.json'),
  addPath: _path.default.join(__dirname, 'locales/{{lng}}/{{ns}}.json'),
  jsonIndent: 2
};
exports.i18NextBackendOptions = i18NextBackendOptions;
},{}],"renderer/polyfills/index.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.util = exports.shell = exports.settings = exports.remote = exports.log = exports.ipcRenderer = exports.i18NextBackendOptions = exports.i18NextBackend = exports.fs = exports.clipboard = void 0;
let log, settings, clipboard, shell, remote, ipcRenderer, i18NextBackend, i18NextBackendOptions, fs, util;
exports.util = util;
exports.fs = fs;
exports.i18NextBackendOptions = i18NextBackendOptions;
exports.i18NextBackend = i18NextBackend;
exports.ipcRenderer = ipcRenderer;
exports.remote = remote;
exports.shell = shell;
exports.clipboard = clipboard;
exports.settings = settings;
exports.log = log;
function buildForBrowser() {
  if (process.env.BUILD_BROWSER) {
    return true;
  }
  if (typeof navigator !== 'undefined' && !/electron/i.test(navigator.userAgent)) {
    return true;
  }
  return false;
}
if (buildForBrowser()) {
  ({
    log,
    settings,
    clipboard,
    shell,
    remote,
    ipcRenderer,
    i18NextBackend,
    i18NextBackendOptions,
    fs,
    util
  } = require('./browser'));
  exports.log = log, exports.settings = settings, exports.clipboard = clipboard, exports.shell = shell, exports.remote = remote, exports.ipcRenderer = ipcRenderer, exports.i18NextBackend = i18NextBackend, exports.i18NextBackendOptions = i18NextBackendOptions, exports.fs = fs, exports.util = util;
} else {
  ({
    log,
    settings,
    clipboard,
    shell,
    remote,
    ipcRenderer,
    i18NextBackend,
    i18NextBackendOptions,
    fs,
    util
  } = require('./electron'));
  exports.log = log, exports.settings = settings, exports.clipboard = clipboard, exports.shell = shell, exports.remote = remote, exports.ipcRenderer = ipcRenderer, exports.i18NextBackend = i18NextBackend, exports.i18NextBackendOptions = i18NextBackendOptions, exports.fs = fs, exports.util = util;
}
},{"./browser":"renderer/polyfills/browser.js","./electron":"renderer/polyfills/electron.js"}],"../gui-common/configs/app.config.default.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
exports.getI18NextOptions = getI18NextOptions;
const config = {
  platform: process.platform,
  languages: ['en', 'de', 'ru', 'ja', 'zh-CN', 'ko', 'hi', 'kn', 'ml-IN', 'pa-IN', 'te', 'pt-BR', 'it'],
  namespace: 'translation'
};
function getI18NextOptions(settings, config, backend) {
  return {
    backend,
    // debug: true,
    // saveMissing: true,
    interpolation: {
      escapeValue: false
    },
    lng: settings && settings.getSync('PREFERRED_LANGUAGE', 'en') || 'en',
    fallbackLng: config.fallbackLng,
    whitelist: config.languages,
    react: {
      wait: false
    }
  };
}
var _default = config;
exports.default = _default;
},{}],"configs/app.config.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _appConfig = _interopRequireDefault(require("../../gui-common/configs/app.config.default"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = _appConfig.default;
exports.default = _default;
},{"../../gui-common/configs/app.config.default":"../gui-common/configs/app.config.default.js"}],"shared/settings.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.SET_SAVED_GESTURES = exports.SESSION_SERVER_TYPE = exports.SESSION_SERVER_PARAMS = exports.SERVER_ARGS = exports.SAVE_GLOBAL_VARS = exports.SAVED_SESSIONS = exports.SAVED_FRAMEWORK = exports.PRESETS = exports.DEFAULT_SETTINGS = void 0;
exports.getSetting = getSetting;
exports.setSetting = setSetting;
var _polyfills = require("../renderer/polyfills");
const PRESETS = 'presets';
exports.PRESETS = PRESETS;
const SAVED_SESSIONS = 'SAVED_SESSIONS';
exports.SAVED_SESSIONS = SAVED_SESSIONS;
const SET_SAVED_GESTURES = 'SET_SAVED_GESTURES';
exports.SET_SAVED_GESTURES = SET_SAVED_GESTURES;
const SERVER_ARGS = 'SERVER_ARGS';
exports.SERVER_ARGS = SERVER_ARGS;
const SESSION_SERVER_PARAMS = 'SESSION_SERVER_PARAMS';
exports.SESSION_SERVER_PARAMS = SESSION_SERVER_PARAMS;
const SESSION_SERVER_TYPE = 'SESSION_SERVER_TYPE';
exports.SESSION_SERVER_TYPE = SESSION_SERVER_TYPE;
const SAVED_FRAMEWORK = 'SAVED_FRAMEWORK';
exports.SAVED_FRAMEWORK = SAVED_FRAMEWORK;
const SAVE_GLOBAL_VARS = 'SAVE_GLOBAL_VARS';
exports.SAVE_GLOBAL_VARS = SAVE_GLOBAL_VARS;
const DEFAULT_SETTINGS = {
  [PRESETS]: {},
  [SAVED_SESSIONS]: [],
  [SET_SAVED_GESTURES]: [],
  [SERVER_ARGS]: null,
  [SESSION_SERVER_PARAMS]: null,
  [SESSION_SERVER_TYPE]: null,
  [SAVED_FRAMEWORK]: 'java',
  [SAVE_GLOBAL_VARS]: []
};
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
async function getSetting(setting) {
  if (await _polyfills.settings.has(setting)) {
    return await _polyfills.settings.get(setting);
  }
  return DEFAULT_SETTINGS[setting];
}
async function setSetting(setting, value) {
  await _polyfills.settings.set(setting, value);
}
var _default = _polyfills.settings;
exports.default = _default;
},{"../renderer/polyfills":"renderer/polyfills/index.js"}],"configs/i18next.config.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _i18next = _interopRequireDefault(require("i18next"));
var _polyfills = require("../renderer/polyfills");
var _app = _interopRequireDefault(require("./app.config"));
var _settings = _interopRequireDefault(require("../shared/settings"));
var _appConfig = require("../../gui-common/configs/app.config.default");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const i18nextOptions = (0, _appConfig.getI18NextOptions)(_settings.default, _app.default, _polyfills.i18NextBackendOptions);
if (!_i18next.default.isInitialized) {
  _i18next.default.use(_polyfills.i18NextBackend).init(i18nextOptions);
}
var _default = _i18next.default;
exports.default = _default;
},{"../renderer/polyfills":"renderer/polyfills/index.js","./app.config":"configs/app.config.js","../shared/settings":"shared/settings.js","../../gui-common/configs/app.config.default":"../gui-common/configs/app.config.default.js"}],"../gui-common/debug.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.installExtensions = installExtensions;
const isDev = process.env.NODE_ENV === 'development';
async function installExtensions() {
  if (isDev) {
    const installer = require('electron-devtools-installer'); // eslint-disable-line global-require
    const {
      app
    } = require('electron');
    const {
      REACT_DEVELOPER_TOOLS,
      REDUX_DEVTOOLS
    } = installer;
    const opts = {
      forceDownload: !!process.env.UPGRADE_EXTENSIONS,
      loadExtensionOptions: {
        allowFileAccess: true
      }
    };
    await app.whenReady();
    try {
      await installer.default([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS], opts);
    } catch (e) {
      console.warn(`Error installing extension: ${e}`);
    }
  }
}
},{}],"../gui-common/windows.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.setupMainWindow = setupMainWindow;
function setupMainWindow({
  splashWindow,
  splashUrl,
  mainWindow,
  mainUrl,
  isDev,
  Menu,
  i18n,
  rebuildMenus,
  settings,
  webContents,
  shouldShowFileMenu = false
}) {
  if (splashWindow) {
    splashWindow.loadURL(splashUrl);
    splashWindow.show();
  }
  mainWindow.loadURL(mainUrl);
  mainWindow.webContents.on('did-finish-load', () => {
    if (splashWindow) {
      splashWindow.destroy();
    }
    mainWindow.show();
    mainWindow.focus();
    if (isDev) {
      mainWindow.openDevTools();
    }
  });
  mainWindow.on('closed', () => {
    mainWindow = null;
  });
  mainWindow.webContents.on('context-menu', (e, props) => {
    const {
      x,
      y
    } = props;
    Menu.buildFromTemplate([{
      label: i18n.t('Inspect element'),
      click() {
        mainWindow.inspectElement(x, y);
      }
    }]).popup(mainWindow);
  });
  i18n.on('languageChanged', async languageCode => {
    rebuildMenus(null, shouldShowFileMenu);
    await settings.set('PREFERRED_LANGUAGE', languageCode);
    webContents.getAllWebContents().forEach(wc => {
      wc.send('appium-language-changed', {
        language: languageCode
      });
    });
  });
  rebuildMenus(mainWindow, shouldShowFileMenu);
}
},{}],"../gui-common/util.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.checkUpdate = checkUpdate;
exports.getAutoUpdaterFeedUrl = getAutoUpdaterFeedUrl;
exports.makeOpenBrowserWindow = makeOpenBrowserWindow;
exports.makeSetSavedEnv = makeSetSavedEnv;
exports.setUpAutoUpdater = setUpAutoUpdater;
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const isDev = process.env.NODE_ENV === 'development';
function getAutoUpdaterFeedUrl(version, baseFeedUrl) {
  let platform = process.platform;
  if (platform.toLowerCase() === 'linux') {
    platform = 'AppImage';
  }
  return `${baseFeedUrl}/update/${platform}/${version}`;
}
async function checkUpdate({
  request,
  getFeedUrl,
  semver,
  currentVersion
}) {
  try {
    // The response is like (macOS):
    // {  "name":"v1.15.0-1",
    //    "notes":"* Bump up Appium to v1.15.0",
    //    "pub_date":"2019-10-04T04:40:37Z",
    //    "url":"https://github.com/appium/appium-desktop/releases/download/v1.15.0-1/Appium-1.15.0-1-mac.zip"}
    const res = await request.get(getFeedUrl(currentVersion));
    if (res) {
      const j = JSON.parse(res);
      if (semver.lt(currentVersion, j.name)) {
        return j;
      }
    }
  } catch (ign) {}
  return false;
}
function setUpAutoUpdater({
  request,
  getFeedUrl,
  semver,
  autoUpdater,
  app,
  moment,
  i18n,
  env,
  dialog,
  B
}) {
  autoUpdater.setFeedURL(getFeedUrl(app.getVersion()));

  /**
   * Check for new updates
   */
  const checkNewUpdates = async function (fromMenu) {
    // autoupdate.checkForUpdates always downloads updates immediately
    // This method (getUpdate) let's us take a peek to see if there is an update
    // available before calling .checkForUpdates
    if (process.env.RUNNING_IN_SPECTRON) {
      return;
    }
    const update = await checkUpdate({
      request,
      getFeedUrl,
      semver,
      currentVersion: app.getVersion()
    });
    if (update) {
      let {
        name,
        notes,
        pub_date: pubDate
      } = update;
      pubDate = moment(pubDate).format(i18n.t('datetimeFormat'));
      let detail = i18n.t('updateDetails', {
        pubDate,
        notes: notes.replace('*', '\n*')
      });
      if (env.NO_AUTO_UPDATE) {
        detail += `\n\nhttps://www.github.com/appium/appium-desktop/releases/latest`;
      }

      // Ask user if they wish to install now or later
      if (!process.env.RUNNING_IN_SPECTRON) {
        dialog.showMessageBox({
          type: 'info',
          buttons: env.NO_AUTO_UPDATE ? [i18n.t('OK')] : [i18n.t('Install Now'), i18n.t('Install Later')],
          message: i18n.t('appiumIsAvailable', {
            name
          }),
          detail
        }, response => {
          if (response === 0) {
            // If they say yes, get the updates now
            if (!env.NO_AUTO_UPDATE) {
              autoUpdater.checkForUpdates();
            }
          }
        });
      }
    } else {
      if (fromMenu) {
        autoUpdater.emit('update-not-available');
      } else {
        // If no updates found check for updates every hour
        await B.delay(60 * 60 * 1000);
        checkNewUpdates();
      }
    }
  };

  // Inform user when the download is starting and that they'll be notified again when it is complete
  autoUpdater.on('update-available', () => {
    dialog.showMessageBox({
      type: 'info',
      buttons: [i18n.t('OK')],
      message: i18n.t('Update Download Started'),
      detail: i18n.t('updateIsBeingDownloaded')
    });
  });

  // Handle the unusual case where we checked the updates endpoint, found an update
  // but then after calling 'checkForUpdates', nothing was there
  autoUpdater.on('update-not-available', () => {
    dialog.showMessageBox({
      type: 'info',
      buttons: [i18n.t('OK')],
      message: i18n.t('No update available'),
      detail: i18n.t('Appium Desktop is up-to-date')
    });
  });

  // When it's done, ask if user want to restart now or later
  autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
    dialog.showMessageBox({
      type: 'info',
      buttons: [i18n.t('Restart Now'), i18n.t('Later')],
      message: i18n.t('Update Downloaded'),
      detail: i18n.t('updateIsDownloaded', {
        releaseName
      })
    }, response => {
      // If they say yes, restart now
      if (response === 0) {
        autoUpdater.quitAndInstall();
      }
    });
  });

  // Handle error case
  autoUpdater.on('error', message => {
    dialog.showMessageBox({
      type: 'error',
      message: i18n.t('Could not download update'),
      detail: i18n.t('updateDownloadFailed', {
        message
      })
    });
  });
  return checkNewUpdates;
}
function makeOpenBrowserWindow({
  BrowserWindow,
  Menu,
  i18n
}) {
  return (route, opts) => {
    const defaultOpts = {
      width: 1080,
      minWidth: 1080,
      height: 570,
      minHeight: 570,
      backgroundColor: '#f2f2f2',
      frame: 'customButtonsOnHover',
      webPreferences: {
        devTools: true,
        nodeIntegration: true,
        contextIsolation: false,
        enableRemoteModule: true
      }
    };
    let win = new BrowserWindow({
      ...defaultOpts,
      ...opts
    });
    let htmlPath = _path.default.resolve(__dirname, 'index.html');

    // on Windows we'll get backslashes, but we don't want these for a browser URL, so replace
    htmlPath = htmlPath.replace('\\', '/');
    htmlPath += `#/${route}`;
    win.loadURL(`file://${htmlPath}`);
    win.show();

    // If it's dev, go ahead and open up the dev tools automatically
    if (isDev) {
      win.openDevTools();
    }

    // Make 'devTools' available on right click
    win.webContents.on('context-menu', (e, props) => {
      const {
        x,
        y
      } = props;
      Menu.buildFromTemplate([{
        label: i18n.t('Inspect element'),
        click() {
          win.inspectElement(x, y);
        }
      }]).popup(win);
    });
    return win;
  };
}

// Sets the environment variables to a combination of process.env and whatever
// the user saved
function makeSetSavedEnv(settings) {
  return async () => {
    const savedEnv = await settings.get('ENV');
    process.env = {
      ...process.env,
      ...(savedEnv || {})
    };
  };
}
},{}],"main/auto-updater/config.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
exports.getFeedUrl = getFeedUrl;
var _util = require("../../../gui-common/util");
const baseFeedUrl = `https://appium-inspector-hazel.vercel.app`;
function getFeedUrl(version) {
  return (0, _util.getAutoUpdaterFeedUrl)(version, baseFeedUrl);
}
var _default = {
  baseFeedUrl,
  getFeedUrl
};
exports.default = _default;
},{"../../../gui-common/util":"../gui-common/util.js"}],"../env/.env-dev.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _default = {};
exports.default = _default;
},{}],"env.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
let env = {};
if (typeof _ENV_ === 'undefined') {
  env = require('../env/.env-dev');
} else {
  env = _ENV_; // eslint-disable-line no-undef
}
var _default = env;
exports.default = _default;
},{"../env/.env-dev":"../env/.env-dev.js"}],"main/auto-updater/index.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.checkNewUpdates = void 0;
var _electron = require("electron");
var _requestPromise = _interopRequireDefault(require("request-promise"));
var _moment = _interopRequireDefault(require("moment"));
var _bluebird = _interopRequireDefault(require("bluebird"));
var _semver = _interopRequireDefault(require("semver"));
var _config = require("./config");
var _lodash = _interopRequireDefault(require("lodash"));
var _env = _interopRequireDefault(require("../../env"));
var _i18next = _interopRequireDefault(require("../../configs/i18next.config"));
var _util = require("../../../gui-common/util");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
 * Auto Updater
 *
 * Similar to https://electronjs.org/docs/api/auto-updater#events
 * See https://electronjs.org/docs/tutorial/updates for documentation
 */

const isDev = process.env.NODE_ENV === 'development';
const runningLocally = isDev || process.env.RUNNING_LOCALLY;
let checkNewUpdates = _lodash.default.noop;
exports.checkNewUpdates = checkNewUpdates;
if (!runningLocally && !process.env.RUNNING_IN_SPECTRON) {
  // put autoupdater in try block so that it doesn't break if autoupdater doesn't work
  try {
    exports.checkNewUpdates = checkNewUpdates = (0, _util.setUpAutoUpdater)({
      request: _requestPromise.default,
      getFeedUrl: _config.getFeedUrl,
      semver: _semver.default,
      autoUpdater: _electron.autoUpdater,
      app: _electron.app,
      moment: _moment.default,
      i18n: _i18next.default,
      env: _env.default,
      dialog: _electron.dialog,
      B: _bluebird.default
    });
  } catch (e) {}
}
},{"./config":"main/auto-updater/config.js","../../env":"env.js","../../configs/i18next.config":"configs/i18next.config.js","../../../gui-common/util":"../gui-common/util.js"}],"main/helpers.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.APPIUM_SESSION_EXTENSION = void 0;
exports.getAppiumSessionFilePath = getAppiumSessionFilePath;
exports.getSaveableState = getSaveableState;
const APPIUM_SESSION_FILE_VERSION = '1.0';
function getAppiumSessionFilePath(argv, isPackaged, isDev) {
  if (isDev) {
    // do not use file launcher in dev mode because argv is different
    // then it is in production
    return false;
  }
  if (process.platform === 'darwin' && !isDev) {
    // packaged macOS apps do not receive args from process.argv, they
    // receive the filepath argument from the `electron.app.on('open-file', cb)` event
    return false;
  }
  const argvIndex = isPackaged ? 1 : 2;
  return argv[argvIndex];
}

// get the slice of the redux state that's needed for the .appiumsession files
function getSaveableState(reduxState) {
  return {
    version: APPIUM_SESSION_FILE_VERSION,
    caps: reduxState.caps,
    server: reduxState.server,
    serverType: reduxState.serverType,
    visibleProviders: reduxState.visibleProviders
  };
}
const APPIUM_SESSION_EXTENSION = 'appiumsession';
exports.APPIUM_SESSION_EXTENSION = APPIUM_SESSION_EXTENSION;
},{}],"../gui-common/menus.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.rebuildMenus = rebuildMenus;
var _helpers = require("../app/main/helpers");
let menuTemplates = {
  mac: {},
  other: {}
};
function languageMenu({
  config,
  i18n
}) {
  return config.languages.map(languageCode => ({
    label: i18n.t(languageCode),
    type: 'radio',
    checked: i18n.language === languageCode,
    click: () => i18n.changeLanguage(languageCode)
  }));
}
function getShowAppInfoClickAction({
  dialog,
  i18n,
  app
}) {
  return () => {
    dialog.showMessageBox({
      title: i18n.t('appiumDesktop'),
      message: i18n.t('showAppInfo', {
        appVersion: app.getVersion(),
        electronVersion: process.versions.electron,
        nodejsVersion: process.versions.node
      })
    });
  };
}
function macMenuAppium({
  dialog,
  i18n,
  app,
  checkNewUpdates,
  extraMenus
}) {
  const menu = {
    label: 'Appium',
    submenu: [{
      label: i18n.t('About Appium'),
      click: getShowAppInfoClickAction({
        dialog,
        i18n,
        app
      })
    }, {
      label: i18n.t('Check for updates'),
      click() {
        checkNewUpdates(true);
      }
    }, {
      type: 'separator'
    }, {
      label: i18n.t('Hide Appium'),
      accelerator: 'Command+H',
      selector: 'hide:'
    }, {
      label: i18n.t('Hide Others'),
      accelerator: 'Command+Shift+H',
      selector: 'hideOtherApplications:'
    }, {
      label: i18n.t('Show All'),
      selector: 'unhideAllApplications:'
    }, {
      type: 'separator'
    }, {
      label: i18n.t('Quit'),
      accelerator: 'Command+Q',
      click() {
        app.quit();
      }
    }]
  };
  for (const extraMenu of extraMenus) {
    menu.submenu.splice(extraMenu.index, 0, extraMenu.menu);
  }
  return menu;
}
function macMenuEdit({
  i18n
}) {
  return {
    label: i18n.t('Edit'),
    submenu: [{
      label: i18n.t('Undo'),
      accelerator: 'Command+Z',
      selector: 'undo:'
    }, {
      label: i18n.t('Redo'),
      accelerator: 'Shift+Command+Z',
      selector: 'redo:'
    }, {
      type: 'separator'
    }, {
      label: i18n.t('Cut'),
      accelerator: 'Command+X',
      selector: 'cut:'
    }, {
      label: i18n.t('Copy'),
      accelerator: 'Command+C',
      selector: 'copy:'
    }, {
      label: i18n.t('Paste'),
      accelerator: 'Command+V',
      selector: 'paste:'
    }, {
      label: i18n.t('Select All'),
      accelerator: 'Command+A',
      selector: 'selectAll:'
    }]
  };
}
function macMenuView({
  i18n,
  mainWindow,
  config
}) {
  const submenu = process.env.NODE_ENV === 'development' ? [{
    label: i18n.t('Reload'),
    accelerator: 'Command+R',
    click() {
      mainWindow.webContents.reload();
    }
  }, {
    label: i18n.t('Toggle Developer Tools'),
    accelerator: 'Alt+Command+I',
    click() {
      mainWindow.toggleDevTools();
    }
  }] : [];
  submenu.push({
    label: i18n.t('Toggle Full Screen'),
    accelerator: 'Ctrl+Command+F',
    click() {
      mainWindow.setFullScreen(!mainWindow.isFullScreen());
    }
  });
  submenu.push({
    label: i18n.t('Languages'),
    submenu: languageMenu({
      config,
      i18n
    })
  });
  return {
    label: i18n.t('View'),
    submenu
  };
}
function macMenuWindow({
  i18n
}) {
  return {
    label: i18n.t('Window'),
    submenu: [{
      label: i18n.t('Minimize'),
      accelerator: 'Command+M',
      selector: 'performMiniaturize:'
    }, {
      label: i18n.t('Close'),
      accelerator: 'Command+W',
      selector: 'performClose:'
    }, {
      type: 'separator'
    }, {
      label: i18n.t('Bring All to Front'),
      selector: 'arrangeInFront:'
    }]
  };
}
function macMenuHelp({
  i18n,
  shell
}) {
  return {
    label: i18n.t('Help'),
    submenu: [{
      label: i18n.t('Learn More'),
      click() {
        shell.openExternal('http://appium.io');
      }
    }, {
      label: i18n.t('Documentation'),
      click() {
        shell.openExternal('https://appium.io/documentation.html');
      }
    }, {
      label: i18n.t('Search Issues'),
      click() {
        shell.openExternal('https://github.com/appium/appium-desktop/issues');
      }
    }, {
      label: i18n.t('Add Or Improve Translations'),
      click() {
        shell.openExternal('https://crowdin.com/project/appium-desktop');
      }
    }]
  };
}
menuTemplates.mac = ({
  dialog,
  i18n,
  app,
  checkNewUpdates,
  extraMenus,
  extraFileMenus,
  mainWindow,
  config,
  shell,
  shouldShowFileMenu
}) => [macMenuAppium({
  dialog,
  i18n,
  app,
  checkNewUpdates,
  extraMenus
}), ...(shouldShowFileMenu ? [macMenuFile({
  i18n,
  mainWindow,
  dialog,
  shouldShowFileMenu,
  extraFileMenus
})] : []), macMenuEdit({
  i18n
}), macMenuView({
  i18n,
  mainWindow,
  config
}), macMenuWindow({
  i18n
}), macMenuHelp({
  i18n,
  shell
})];
async function openFileCallback(mainWindow, dialog) {
  const {
    canceled,
    filePaths
  } = await dialog.showOpenDialog({
    properties: ['openFile'],
    filters: [{
      name: 'Appium Session Files',
      extensions: [_helpers.APPIUM_SESSION_EXTENSION]
    }]
  });
  if (!canceled) {
    const filePath = filePaths[0];
    mainWindow.webContents.send('open-file', filePath);
  }
}
;
async function saveAsCallback(mainWindow, dialog, i18n) {
  const {
    canceled,
    filePath
  } = await dialog.showSaveDialog({
    title: i18n.t('saveAs'),
    filters: [{
      name: 'Appium',
      extensions: [_helpers.APPIUM_SESSION_EXTENSION]
    }]
  });
  if (!canceled) {
    mainWindow.webContents.send('save-file', filePath);
  }
}
function macMenuFile({
  i18n,
  mainWindow,
  dialog,
  extraFileMenus
}) {
  let fileSubmenu = [{
    label: i18n.t('Open'),
    accelerator: 'Command+O',
    click: () => openFileCallback(mainWindow, dialog)
  }, {
    label: i18n.t('Save'),
    accelerator: 'Command+S',
    click: () => mainWindow.webContents.send('save-file')
  }, {
    label: i18n.t('saveAs'),
    accelerator: 'Command+Shift+S',
    click: () => saveAsCallback(mainWindow, dialog, i18n)
  }];
  for (const extraMenu of extraFileMenus) {
    fileSubmenu.splice(extraMenu.index, 0, extraMenu.menu);
  }
  return {
    label: '&' + i18n.t('File'),
    submenu: fileSubmenu
  };
}
function otherMenuFile({
  i18n,
  dialog,
  app,
  mainWindow,
  checkNewUpdates,
  extraFileMenus,
  shouldShowFileMenu
}) {
  const fileSavingOperations = [{
    label: i18n.t('Open'),
    accelerator: 'Ctrl+O',
    click: () => openFileCallback(mainWindow, dialog)
  }, {
    label: i18n.t('Save'),
    accelerator: 'Ctrl+S',
    click: () => mainWindow.webContents.send('save-file')
  }, {
    label: i18n.t('saveAs'),
    accelerator: 'Ctrl+Shift+S',
    click: () => saveAsCallback(mainWindow, dialog, i18n)
  }];
  let fileSubmenu = [...(shouldShowFileMenu ? fileSavingOperations : []), {
    label: '&' + i18n.t('About Appium'),
    click: getShowAppInfoClickAction({
      dialog,
      i18n,
      app
    })
  }, {
    type: 'separator'
  }, {
    label: '&' + i18n.t('Close'),
    accelerator: 'Ctrl+W',
    click() {
      mainWindow.close();
    }
  }];
  if (shouldShowFileMenu) {
    for (const extraMenu of extraFileMenus) {
      fileSubmenu.splice(extraMenu.index, 0, extraMenu.menu);
    }
  }

  // If it's Windows, add a 'Check for Updates' menu option
  if (process.platform === 'win32') {
    fileSubmenu.splice(1, 0, {
      label: '&' + i18n.t('Check for updates'),
      click() {
        checkNewUpdates(true);
      }
    });
  }
  return {
    label: '&' + i18n.t('File'),
    submenu: fileSubmenu
  };
}
function otherMenuView({
  i18n,
  mainWindow,
  config
}) {
  const submenu = [];
  submenu.push({
    label: i18n.t('Toggle &Full Screen'),
    accelerator: 'F11',
    click() {
      mainWindow.setFullScreen(!mainWindow.isFullScreen());
    }
  });
  submenu.push({
    label: i18n.t('Languages'),
    submenu: languageMenu({
      config,
      i18n
    })
  });
  if (process.env.NODE_ENV === 'development') {
    submenu.push({
      label: '&' + i18n.t('Reload'),
      accelerator: 'Ctrl+R',
      click() {
        mainWindow.webContents.reload();
      }
    });
    submenu.push({
      label: i18n.t('Toggle &Developer Tools'),
      accelerator: 'Alt+Ctrl+I',
      click() {
        mainWindow.toggleDevTools();
      }
    });
  }
  return {
    label: '&' + i18n.t('View'),
    submenu
  };
}
function otherMenuHelp({
  i18n,
  shell
}) {
  return {
    label: i18n.t('Help'),
    submenu: [{
      label: i18n.t('Learn More'),
      click() {
        shell.openExternal('http://appium.io');
      }
    }, {
      label: i18n.t('Documentation'),
      click() {
        shell.openExternal('https://appium.io/documentation.html');
      }
    }, {
      label: i18n.t('Search Issues'),
      click() {
        shell.openExternal('https://github.com/appium/appium-desktop/issues');
      }
    }, {
      label: i18n.t('Add Or Improve Translations'),
      click() {
        shell.openExternal('https://crowdin.com/project/appium-desktop');
      }
    }]
  };
}
menuTemplates.other = ({
  mainWindow,
  i18n,
  dialog,
  app,
  checkNewUpdates,
  config,
  shell,
  shouldShowFileMenu,
  extraFileMenus
}) => [otherMenuFile({
  i18n,
  dialog,
  app,
  mainWindow,
  checkNewUpdates,
  shouldShowFileMenu,
  extraFileMenus
}), otherMenuView({
  i18n,
  mainWindow,
  config
}), otherMenuHelp({
  i18n,
  shell
})];
function rebuildMenus({
  mainWindow,
  config,
  Menu,
  dialog,
  i18n,
  app,
  checkNewUpdates,
  extraMacMenus,
  extraFileMenus,
  extraMacFileMenus,
  shell,
  shouldShowFileMenu
}) {
  if (!mainWindow) {
    return;
  }
  if (config.platform === 'darwin') {
    const template = menuTemplates.mac({
      dialog,
      i18n,
      app,
      checkNewUpdates,
      extraMenus: extraMacMenus,
      extraFileMenus: extraMacFileMenus,
      mainWindow,
      config,
      shell,
      shouldShowFileMenu
    });
    const menu = Menu.buildFromTemplate(template);
    Menu.setApplicationMenu(menu);
  } else {
    const template = menuTemplates.other({
      mainWindow,
      i18n,
      dialog,
      app,
      extraFileMenus,
      checkNewUpdates,
      config,
      shell,
      shouldShowFileMenu
    });
    const menu = Menu.buildFromTemplate(template);
    mainWindow.setMenu(menu);
  }
}
},{"../app/main/helpers":"main/helpers.js"}],"main/menus.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.rebuildMenus = rebuildMenus;
var _electron = require("electron");
var _fs = _interopRequireDefault(require("fs"));
var _autoUpdater = require("./auto-updater");
var _main = require("../main");
var _app = _interopRequireDefault(require("../configs/app.config"));
var _i18next = _interopRequireDefault(require("../configs/i18next.config"));
var _menus = require("../../gui-common/menus");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const extraMacFileMenus = [{
  index: 0,
  menu: {
    label: _i18next.default.t('New Session Window…'),
    click: _main.launchNewSessionWindow,
    accelerator: 'Command+N'
  }
}];
const extraFileMenus = [{
  index: 0,
  menu: {
    label: _i18next.default.t('&New Session Window…'),
    click: _main.launchNewSessionWindow,
    accelerator: 'Ctrl+N'
  }
}];
function rebuildMenus(mainWindow, shouldShowFileMenu) {
  (0, _menus.rebuildMenus)({
    mainWindow,
    config: _app.default,
    Menu: _electron.Menu,
    dialog: _electron.dialog,
    i18n: _i18next.default,
    app: _electron.app,
    checkNewUpdates: _autoUpdater.checkNewUpdates,
    extraMacFileMenus,
    extraFileMenus,
    extraMacMenus: [],
    shell: _electron.shell,
    fs: _fs.default,
    shouldShowFileMenu
  });
}
},{"./auto-updater":"main/auto-updater/index.js","../main":"main.js","../configs/app.config":"configs/app.config.js","../configs/i18next.config":"configs/i18next.config.js","../../gui-common/menus":"../gui-common/menus.js"}],"renderer/components/Inspector/shared.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.actionDefinitions = exports.actionArgTypes = exports.SCREENSHOT_INTERACTION_MODE = exports.RENDER_CENTROID_AS = exports.POINTER_TYPES = exports.INTERACTION_MODE = exports.DEFAULT_TAP = exports.DEFAULT_SWIPE = exports.APP_MODE = void 0;
exports.getLocators = getLocators;
exports.isUnique = isUnique;
exports.parseCoordinates = parseCoordinates;
exports.percentageToPixels = percentageToPixels;
exports.pixelsToPercentage = pixelsToPercentage;
var _xmldom = require("xmldom");
var _xpath = _interopRequireDefault(require("xpath"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function pixelsToPercentage(px, maxPixels) {
  if (!isNaN(px)) {
    return parseFloat((px / maxPixels * 100).toFixed(1), 10);
  }
}
function percentageToPixels(pct, maxPixels) {
  if (!isNaN(pct)) {
    return Math.round(maxPixels * (pct / 100));
  }
}
function parseCoordinates(element) {
  let {
    bounds,
    x,
    y,
    width,
    height
  } = element.attributes || {};
  if (bounds) {
    let boundsArray = bounds.split(/\[|\]|,/).filter(str => str !== '');
    const x1 = parseInt(boundsArray[0], 10);
    const x2 = parseInt(boundsArray[2], 10);
    const y1 = parseInt(boundsArray[1], 10);
    const y2 = parseInt(boundsArray[3], 10);
    return {
      x1,
      y1,
      x2,
      y2
    };
  } else if (x) {
    x = parseInt(x, 10);
    y = parseInt(y, 10);
    width = parseInt(width, 10);
    height = parseInt(height, 10);
    return {
      x1: x,
      y1: y,
      x2: x + width,
      y2: y + height
    };
  } else {
    return {};
  }
}
function isUnique(attrName, attrValue, sourceXML) {
  // If no sourceXML provided, assume it's unique
  if (!sourceXML) {
    return true;
  }
  const doc = new _xmldom.DOMParser().parseFromString(sourceXML);
  return _xpath.default.select(`//*[@${attrName}="${attrValue.replace(/"/g, '')}"]`, doc).length < 2;
}

// Map of the optimal strategies.
const STRATEGY_MAPPINGS = [['name', 'accessibility id'], ['content-desc', 'accessibility id'], ['id', 'id'], ['rntestid', 'id'], ['resource-id', 'id']];
function getLocators(attributes, sourceXML) {
  const res = {};
  for (let [strategyAlias, strategy] of STRATEGY_MAPPINGS) {
    const value = attributes[strategyAlias];
    if (value && isUnique(strategyAlias, value, sourceXML)) {
      res[strategy] = attributes[strategyAlias];
    }
  }
  return res;
}
const POINTER_TYPES = {
  POINTER_UP: 'pointerUp',
  POINTER_DOWN: 'pointerDown',
  PAUSE: 'pause',
  POINTER_MOVE: 'pointerMove'
};
exports.POINTER_TYPES = POINTER_TYPES;
const DEFAULT_SWIPE = {
  POINTER_NAME: 'finger1',
  DURATION_1: 0,
  DURATION_2: 750,
  BUTTON: 0,
  ORIGIN: 'viewport'
};
exports.DEFAULT_SWIPE = DEFAULT_SWIPE;
const DEFAULT_TAP = {
  POINTER_NAME: 'finger1',
  DURATION_1: 0,
  DURATION_2: 100,
  BUTTON: 0
};

// 3 Types of Centroids:
// CENTROID is the circle/square displayed on the screen
// EXPAND is the +/- circle displayed on the screen
// OVERLAP is the same as CENTROID but is only visible when clicked on +/- circle
exports.DEFAULT_TAP = DEFAULT_TAP;
const RENDER_CENTROID_AS = {
  CENTROID: 'centroid',
  EXPAND: 'expand',
  OVERLAP: 'overlap'
};
exports.RENDER_CENTROID_AS = RENDER_CENTROID_AS;
const SCREENSHOT_INTERACTION_MODE = {
  SELECT: 'select',
  SWIPE: 'swipe',
  TAP: 'tap',
  GESTURE: 'gesture'
};
exports.SCREENSHOT_INTERACTION_MODE = SCREENSHOT_INTERACTION_MODE;
const APP_MODE = {
  NATIVE: 'native',
  WEB_HYBRID: 'web_hybrid'
};
exports.APP_MODE = APP_MODE;
const actionArgTypes = {
  STRING: 'string',
  NUMBER: 'number',
  BOOLEAN: 'boolean'
};
exports.actionArgTypes = actionArgTypes;
const {
  STRING,
  NUMBER,
  BOOLEAN
} = actionArgTypes;

// Note: When adding or removing actionDefinitions, update `en/translation.json`
const actionDefinitions = {
  'Device': {
    'Execute Script': {
      'Execute': {
        methodName: 'executeScript',
        args: [['executeScriptCommand', STRING], ['jsonArgument', STRING]]
      }
    },
    'Android Activity': {
      'Start Activity': {
        methodName: 'startActivity',
        args: [['appPackage', STRING], ['appActivity', STRING], ['appWaitPackage', STRING], ['intentAction', STRING], ['intentCategory', STRING], ['intentFlags', STRING], ['optionalIntentArguments', STRING], ['dontStopAppOnReset', STRING]],
        refresh: true
      },
      'Current Activity': {
        methodName: 'getCurrentActivity'
      },
      'Current Package': {
        methodName: 'getCurrentPackage'
      }
    },
    'App': {
      'Install App': {
        methodName: 'installApp',
        args: [['appPathOrUrl', STRING]]
      },
      'Is App Installed': {
        methodName: 'isAppInstalled',
        args: [['appId', STRING]]
      },
      'Background App': {
        methodName: 'background',
        args: [['timeout', NUMBER]],
        refresh: true
      },
      'Activate App': {
        methodName: 'activateApp',
        args: [['appId', STRING]],
        refresh: true
      },
      'Terminate App': {
        methodName: 'terminateApp',
        args: [['appId', STRING]],
        refresh: true
      },
      'Reset App': {
        methodName: 'resetApp',
        refresh: true
      },
      'Remove App': {
        methodName: 'removeApp',
        args: [['appId', STRING]]
      },
      'Get App Strings': {
        methodName: 'getStrings',
        args: [['language', STRING], ['stringFile', STRING]],
        refresh: true
      }
    },
    'Clipboard': {
      'Get Clipboard': {
        methodName: 'getClipboard'
      },
      'Set Clipboard': {
        methodName: 'setClipboard',
        args: [['clipboardText', STRING], ['contentType', STRING], ['contentLabel', STRING]]
      }
    },
    'File': {
      'Push File': {
        methodName: 'pushFile',
        args: [['pathToInstallTo', STRING], ['fileContentString', STRING]]
      },
      'Pull File': {
        methodName: 'pullFile',
        args: [['pathToPullFrom', STRING]]
      },
      'Pull Folder': {
        methodName: 'pullFolder',
        args: [['folderToPullFrom', STRING]]
      }
    },
    'Interaction': {
      'Shake': {
        methodName: 'shake'
      },
      'Lock': {
        methodName: 'lock',
        args: [['seconds', NUMBER]],
        refresh: true
      },
      'Unlock': {
        methodName: 'unlock',
        refresh: true
      },
      'Is Device Locked': {
        methodName: 'isLocked'
      },
      'Rotate Device': {
        methodName: 'rotateDevice',
        args: [['x', NUMBER], ['y', NUMBER], ['radius', NUMBER], ['rotatation', NUMBER], ['touchCount', NUMBER], ['duration', NUMBER]],
        refresh: true
      }
    },
    'Keys': {
      'Press Key': {
        methodName: 'pressKeyCode',
        args: [['keyCode', NUMBER], ['metaState', NUMBER], ['flags', NUMBER]],
        refresh: true
      },
      'Long Press Key': {
        methodName: 'longPressKeyCode',
        args: [['keyCode', NUMBER], ['metaState', NUMBER], ['flags', NUMBER]],
        refresh: true
      },
      'Hide Keyboard': {
        methodName: 'hideKeyboard',
        refresh: true
      },
      'Is Keyboard Shown': {
        methodName: 'isKeyboardShown'
      }
    },
    'Network': {
      'Toggle Airplane Mode': {
        methodName: 'toggleAirplaneMode'
      },
      'Toggle Data': {
        methodName: 'toggleData'
      },
      'Toggle WiFi': {
        methodName: 'toggleWiFi'
      },
      'Toggle Location Services': {
        methodName: 'toggleLocationServices'
      },
      'Send SMS': {
        methodName: 'sendSMS',
        args: [['phoneNumber', STRING], ['text', STRING]]
      },
      'GSM Call': {
        methodName: 'gsmCall',
        args: [['phoneNumber', STRING], ['action', STRING]]
      },
      'GSM Signal': {
        methodName: 'gsmSignal',
        args: [['signalStrengh', NUMBER]]
      },
      'GSM Voice': {
        methodName: 'gsmVoice',
        args: [['state', STRING]]
      }
    },
    'Performance Data': {
      'Get Data': {
        methodName: 'getPerformanceData',
        args: [['packageName', STRING], ['dataType', STRING], ['dataReadTimeout', NUMBER]]
      },
      'Get Data Types': {
        methodName: 'getPerformanceDataTypes'
      }
    },
    'iOS Simulator': {
      'Perform Touch Id': {
        methodName: 'touchId',
        args: [['shouldMatch', BOOLEAN]],
        refresh: true
      },
      'Toggle Touch Id Enrollment': {
        methodName: 'toggleEnrollTouchId',
        args: [['shouldEnroll', BOOLEAN]]
      }
    },
    'System': {
      'Open Notifications': {
        methodName: 'openNotifications',
        refresh: true
      },
      'Get System Time': {
        methodName: 'getDeviceTime'
      },
      'Fingerprint (Android)': {
        methodName: 'fingerPrint',
        args: [['fingerPrintId', NUMBER]],
        refresh: true
      }
    }
  },
  'Session': {
    'Session Capabilities': {
      'Get Session Capabilities': {
        methodName: 'getSession'
      }
    },
    'Timeouts': {
      'Set Timeouts': {
        methodName: 'setTimeouts',
        args: [['implicitTimeout', NUMBER], ['pageLoadTimeout', NUMBER], ['scriptTimeout', NUMBER]]
      }
    },
    'Orientation': {
      'Get Orientation': {
        methodName: 'getOrientation'
      },
      'Set Orientation': {
        methodName: 'setOrientation',
        args: [['orientation', STRING]],
        refresh: true
      }
    },
    'Geolocation': {
      'Get Geolocation': {
        methodName: 'getGeoLocation'
      },
      'Set Geolocation': {
        methodName: 'setGeoLocation',
        args: [['latitude', NUMBER], ['longitude', NUMBER], ['altitude', NUMBER]]
      }
    },
    'Logs': {
      'Get Log Types': {
        methodName: 'getLogTypes'
      },
      'Get Logs': {
        methodName: 'getLogs',
        args: [['logType', STRING]]
      }
    },
    'Settings': {
      'Update Settings': {
        methodName: 'updateSettings',
        args: [['settingsJson', STRING]]
      },
      'Get Device Settings': {
        methodName: 'getSettings'
      }
    }
  },
  'Web': {
    'Navigation': {
      'Go to URL': {
        methodName: 'navigateTo',
        args: [['url', STRING]],
        refresh: true
      },
      'Get URL': {
        methodName: 'getUrl'
      },
      'Back': {
        methodName: 'back',
        refresh: true
      },
      'Forward': {
        methodName: 'forward',
        refresh: true
      },
      'Refresh': {
        methodName: 'refresh',
        refresh: true
      }
    }
  },
  'Context': {
    'Context': {
      'Get Current Context': {
        methodName: 'getContext'
      },
      'Get Context List': {
        methodName: 'getContexts'
      },
      'Set Context': {
        methodName: 'switchContext',
        args: [['name', STRING]],
        refresh: true
      }
    },
    'Window (W3C)': {
      'Get Window Handle': {
        methodName: 'getWindowHandle'
      },
      'Close Window': {
        methodName: 'closeWindow',
        refresh: true
      },
      'Switch To Window': {
        methodName: 'switchToWindow',
        args: [['handle', STRING]],
        refresh: true
      },
      'Get Window Handles': {
        methodName: 'getWindowHandles'
      },
      'New Window': {
        methodName: 'createWindow',
        args: [['type', STRING]],
        refresh: true
      }
    }
  }
};
exports.actionDefinitions = actionDefinitions;
const INTERACTION_MODE = {
  SOURCE: 'source',
  ACTIONS: 'actions',
  GESTURES: 'gestures',
  SESSION_INFO: 'sessionInfo'
};
exports.INTERACTION_MODE = INTERACTION_MODE;
},{}],"renderer/lib/client-frameworks/framework.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _shared = require("../../components/Inspector/shared");
class Framework {
  constructor(host, port, path, https, caps, filePath, cookie, requestVars) {
    this.host = host || 'localhost';
    this.port = port || 4723;
    this.path = path || '/wd/hub';
    this.caps = caps || {};
    this.filePath = filePath;
    this.cookie = cookie || 'experimentation_subject_id=imuzndu1mdjkltuwmdctndk2ys1hmtljlti1owrlnjc4yzfmosi%3d--fb98d346787f918849a9c9f856a783933b9fbe94; sensorsdata2015jssdkcross=%7b%22distinct_id%22%3a%22cwmsvtiu%22%2c%22%24device_id%22%3a%221818b7939df5b9-0e4072c3066eed-1d525635-1930176-1818b7939e01c4e%22%2c%22props%22%3a%7b%22%24latest_referrer%22%3a%22%22%2c%22%24latest_traffic_source_type%22%3a%22%e7%9b%b4%e6%8e%a5%e6%b5%81%e9%87%8f%22%2c%22%24latest_search_keyword%22%3a%22%e6%9c%aa%e5%8f%96%e5%88%b0%e5%80%bc_%e7%9b%b4%e6%8e%a5%e6%89%93%e5%bc%80%22%7d%2c%22first_id%22%3a%221818b7939df5b9-0e4072c3066eed-1d525635-1930176-1818b7939e01c4e%22%2c%22identities%22%3a%22eyikawrlbnrpdhlfy29va2llx2lkijoimtgzmgi2mmnlmwyymdqtmdc0zwuzyjiyztdlogy4ltfinti1njm1lte5mzaxnzytmtgzmgi2mmnlmjaxyzg3iiwijglkzw50axr5x2xvz2lux2lkijoiq3dnc3z0avuifq%3d%3d%22%2c%22history_login_id%22%3a%7b%22name%22%3a%22%24identity_login_id%22%2c%22value%22%3a%22cwmsvtiu%22%7d%7d; remember_token=6406f1f672e4efcd4d47d36a|2715bd37fbd1a85bf9604019b6c5e81b0a65ef56f0f58f90ddc55b6b2e7b82e73ec866863cf358339e80d0b60d7f21ddcce9ee80d47879e9a045ed8bd13beb7f; session=.ejwdyzsoajemang7pkawhcdjuazyv9duqow4o4hypdfv9jrzud2ixzswsghjpoqsdw6e0uxbpd3qyppers_jlb_6c8wxmxn73ds5azkvdz6oi5eyvuipjy30nhlb-hswqo5ftrhvezurosuog16mmx227tadoyvloyapdakbxwbzap5wxvju7fmfh0020g.zcer_g.cq9eqooxjtrerz589dhvixjvkqe; auto-ftest=eyjhbgcioijiuzuxmiisimlhdci6mty3otg5ntu1mcwizxhwijoxnjc5otaynzuwfq.eyjlbwfpbci6innozw5szwlazm9yew91ntyuy29tiiwicm9szxmiolsichjvamvjdcisinvzzxiilcjhzg1pbijdlcjuyw1lijoi5rki6zu3iiwibw9iawxlijoimtm2mdawmdawmdaifq.s7ghd-yfdtpkva1qog8f2x9-qw8j9thdpglaekvl-oz3o98gkgwpve1g1u8pig0bsihghirh_9p_4zzikizdoq; auto-ftest=eyjhbgcioijiuzuxmiisimlhdci6mty3otg5ntu1mcwizxhwijoxnjc5otaynzuwfq.eyjlbwfpbci6innozw5szwlazm9yew91ntyuy29tiiwicm9szxmiolsichjvamvjdcisinvzzxiilcjhzg1pbijdlcjuyw1lijoi5rki6zu3iiwibw9iawxlijoimtm2mdawmdawmdaifq.s7ghd-yfdtpkva1qog8f2x9-qw8j9thdpglaekvl-oz3o98gkgwpve1g1u8pig0bsihghirh_9p_4zzikizdoq; auth-token=eyjhbgcioijiuzuxmiisimlhdci6mty3otg5ntu1mcwizxhwijoxnjc5otaynzuwfq.eyjlbwfpbci6innozw5szwlazm9yew91ntyuy29tiiwicm9szxmiolsichjvamvjdcisinvzzxiilcjhzg1pbijdlcjuyw1lijoi5rki6zu3iiwibw9iawxlijoimtm2mdawmdawmdaifq.s7ghd-yfdtpkva1qog8f2x9-qw8j9thdpglaekvl-oz3o98gkgwpve1g1u8pig0bsihghirh_9p_4zzikizdoq';
    this.https = !!https;
    this.scheme = https ? 'https' : 'http';
    // this.actions = [];
    this.localVarCount = 0;
    this.assertVarCount = 0;
    this.localVarCache = {};
    this.lastAssignedVar = null;
    this.requestVars = requestVars;
    console.log('caps ========' + caps);
  }
  getTapCoordinatesFromPointerActions(pointerActions) {
    const pointerMoveAction = pointerActions[_shared.DEFAULT_TAP.POINTER_NAME][0];
    return {
      x: pointerMoveAction.x,
      y: pointerMoveAction.y
    };
  }
  getSwipeCoordinatesFromPointerActions(pointerActions) {
    const pointerMoveActionStart = pointerActions[_shared.DEFAULT_SWIPE.POINTER_NAME][0];
    const pointerMoveActionEnd = pointerActions[_shared.DEFAULT_SWIPE.POINTER_NAME][2];
    return {
      x1: pointerMoveActionStart.x,
      y1: pointerMoveActionStart.y,
      x2: pointerMoveActionEnd.x,
      y2: pointerMoveActionEnd.y
    };
  }
  get serverUrl() {
    return `${this.scheme}://${this.host}:${this.port}${this.path}`;
  }
  get name() {
    throw new Error('Must implement name getter');
  }
  get language() {
    throw new Error('Must implement language getter');
  }
  addAction(action, params) {
    this.actions.push({
      action,
      params
    });
  }
  wrapWithBoilerplate() {
    throw new Error('Must implement wrapWithBoilerplate');
  }
  indent(str, spaces) {
    let lines = str.split('\n');
    let spaceStr = '';
    for (let i = 0; i < spaces; i++) {
      spaceStr += ' ';
    }
    return lines.filter(l => !!l.trim()).map(l => `${spaceStr}${l}`).join('\n');
  }
  getActionCodeString(actions) {
    let str = '//\n';
    for (let {
      action,
      params
    } of actions) {
      const genCodeFn = `codeFor_${action}`;
      if (!this[genCodeFn]) {
        throw new Error(`Need to implement '${genCodeFn}()': ${this[genCodeFn]}`);
      }
      let code = this[genCodeFn](...params);
      if (code) {
        str += `${code}\n`;
      }
    }
    if (actions.map(element => element.action).indexOf('insertIt') === -1) {
      str += 'await driver.pause(2000);\n';
    }
    return str;
  }
  getCodeString(recordContent, includeBoilerplate = false) {
    if (includeBoilerplate) {
      return this.wrapWithBoilerplate(recordContent);
    }
    return recordContent;
  }
  // getCodeString (includeBoilerplate = false) {
  //   let str = '';
  //   for (let {action, params} of this.actions) {
  //     const genCodeFn = `codeFor_${action}`;
  //     if (!this[genCodeFn]) {
  //       throw new Error(`Need to implement '${genCodeFn}()': ${this[genCodeFn]}`);
  //     }
  //     let code = this[genCodeFn](...params);
  //     if (code) {
  //       str += `${code}\n`;
  //     }
  //   }
  //   if (includeBoilerplate) {
  //     return this.wrapWithBoilerplate(str);
  //   }
  //   return str;
  // }

  getNewLocalVar() {
    this.localVarCount++;
    return `el${this.localVarCount}`;
  }
  getVarForFind(strategy, locator) {
    const key = `${strategy}-${locator}`;
    let wasNew = false;
    if (!this.localVarCache[key]) {
      this.localVarCache[key] = this.getNewLocalVar();
      wasNew = true;
    }
    this.lastAssignedVar = this.localVarCache[key];
    return [this.localVarCache[key], wasNew];
  }
  getVarName(varName, varIndex) {
    if (varIndex || varIndex === 0) {
      return `${varName}[${varIndex}]`;
    }
    return varName;
  }
  codeFor_findAndAssign() {
    throw new Error('Need to implement codeFor_findAndAssign');
  }
  codeFor_findElement(strategy, locator) {
    let [localVar, wasNew] = this.getVarForFind(strategy, locator);
    if (!wasNew) {
      // if we've already found this element, don't print out
      // finding it again
      return '';
    }
    return this.codeFor_findAndAssign(strategy, locator, localVar);
  }
  codeFor_tap() {
    throw new Error('Need to implement codeFor_tap');
  }
  codeFor_swipe() {
    throw new Error('Need to implement codeFor_tap');
  }
}
exports.default = Framework;
},{"../../components/Inspector/shared":"renderer/components/Inspector/shared.js"}],"renderer/lib/client-frameworks/js-wdio.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _framework = _interopRequireDefault(require("./framework"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class JsWdIoFramework extends _framework.default {
  get language() {
    return 'js';
  }
  chainifyCode(code) {
    return code.replace(/let .+ = /g, '').replace(/(\n|^)(driver|el[0-9]+)\./g, '\n.').replace(/;\n/g, '\n');
  }
  wrapWithBoilerplate(code) {
    let host = JSON.stringify(this.host);
    let caps = JSON.stringify(this.caps);
    let proto = JSON.stringify(this.scheme);
    let path = JSON.stringify(this.path);
    let testName = JSON.stringify(this.filePath.split('.')[0]);
    let cookie = JSON.stringify(this.cookie);
    let requestVars = JSON.stringify(this.requestVars);
    return `// Requires the webdriverio client library
// (npm install webdriverio)
// Then paste this into a .js file and run with Node:
// node <file>.js

const wdio = require('webdriverio');
const { Interaction, assertText, setTestPlatformInfo } = require('appium-data-interaction');
jest.setTimeout(5000 * 1000);
let driver;
let errors = [];
let requestVars;
async function initial() {
  requestVars = ${requestVars};
  const caps = ${caps};
  driver = await wdio.remote({
    protocol: ${proto},
    hostname: ${host},
    port: ${this.port},
    path: ${path},
    capabilities: caps
  });
  setTestPlatformInfo('http://localhost:8888', ${cookie});
  Interaction.setCaps(caps, 'http://localhost:8084');
  await driver.pause(3000);
}

beforeAll(async () => {
    await initial();
});

afterAll( async () => {
    await driver.deleteSession();
});

afterEach(async () => {
    if (errors.length > 0) {
        let newError = new Error(errors.reduce((accumulator, currentValue) => {
            console.info(currentValue.message);
            return accumulator.message + "\\n" + currentValue.message;
        }))
        console.info(newError.message);
        errors = [];
        expect(newError).toBeUndefined();
    }
});

describe(${testName}, () => {
  ${this.indent(code, 2)}
});
`;
  }
  codeFor_executeScript( /*varNameIgnore, varIndexIgnore, args*/
  ) {
    return `/* TODO implement executeScript */`;
  }
  codeFor_addAssert(localVar, expectedTextType, expectedText) {
    let str = '';
    const error = `${localVar}Error`;
    if (expectedTextType === 'text') {
      str += `let ${error} = await assertText(${localVar}, ${JSON.stringify(expectedText)});\nif (${error}) errors.push(${error}); return;`;
    } else {
      str += `let ${localVar}Error = await assertText(${localVar}, ${expectedText});\nif (${error} errors.push(${error}); return;`;
    }
    return str;
  }
  codeFor_insertIt(insertTestCaseName) {
    let str = `it(${JSON.stringify(insertTestCaseName)}, async () => {\n\n});`;
    return str;
  }
  codeFor_findAndAssign(strategy, locator, localVar, isArray) {
    // wdio has its own way of indicating the strategy in the locator string
    switch (strategy) {
      case 'xpath':
        break;
      // xpath does not need to be updated
      case 'accessibility id':
        locator = `~${locator}`;
        break;
      case 'id':
        locator = `${locator}`;
        break;
      case 'name':
        locator = `name=${locator}`;
        break;
      case 'class name':
        locator = `${locator}`;
        break;
      case '-android uiautomator':
        locator = `android=${locator}`;
        break;
      case '-android datamatcher':
        locator = `android=${locator}`;
        break;
      case '-android viewtag':
        locator = `android=unsupported`;
        break;
      case '-ios predicate string':
        locator = `ios=${locator}`;
        break;
      case '-ios class chain':
        locator = `ios=${locator}`;
        break;
      // TODO: Handle IOS class chain properly. Not all libs support it. Or take it out
      default:
        throw new Error(`Can't handle strategy ${strategy}`);
    }
    if (isArray) {
      return `let ${localVar} = await driver.$$(${JSON.stringify(locator)});`;
    } else {
      return `let ${localVar} = await driver.$(${JSON.stringify(locator)});`;
    }
  }
  codeFor_getAppData(reponse, api) {
    return `let ${reponse} = await Interaction.getAppData('${api}');`;
  }
  codeFor_apiAutoSuit(index, requestVars, suiteVars, testId) {
    const stringVar = `suiteRequestVars${index}`;
    // 执行脚本里找到此场景对应的参数
    const suiteRequestVars = `const ${stringVar} = requestVars.find((element)=> element.key === '${testId}');`;
    // 程序中找到此场景对应的参数
    const realSuiteRequestVars = requestVars.find(element => element.key === testId);
    let params = '';
    // 程序中填的此场景的参数
    for (let i = 0; i < suiteVars.length; i++) {
      const elementSuiteVars = suiteVars[i];
      // 除去在app内获取的参数
      for (let j = 0; j < realSuiteRequestVars.value.length; j++) {
        const elementReSuReVars = realSuiteRequestVars.value[j];
        // 做对比 如果是在app内获取的参数 就去app内获取的值 否则取传进来的值
        if (elementSuiteVars.name === elementReSuReVars.name) {
          const suiteVar = `'${elementSuiteVars.name}': ${stringVar}.${elementSuiteVars.name},`;
          params += suiteVar;
        } else {
          const suiteVar = `'${elementSuiteVars.name}': ${elementSuiteVars.value},`;
          params += suiteVar;
        }
      }
    }
    return `${suiteRequestVars} \n` + `await TestPlatform.startUIAutomationTest({${params}}, ['${testId}'], '641a7505211af6db9e160825', ${stringVar}.env);`;
  }
  codeFor_click(varName, varIndex) {
    return `await ${this.getVarName(varName, varIndex)}.click();`;
  }
  codeFor_clear(varName, varIndex) {
    return `await ${this.getVarName(varName, varIndex)}.clearValue();`;
  }
  codeFor_sendKeys(varName, varIndex, text) {
    return `await ${this.getVarName(varName, varIndex)}.setValue(${JSON.stringify(text)});`;
  }
  codeFor_back() {
    return `await driver.back();`;
  }
  codeFor_tap(varNameIgnore, varIndexIgnore, pointerActions) {
    const {
      x,
      y
    } = this.getTapCoordinatesFromPointerActions(pointerActions);
    return `await driver.touchAction({actions: 'tap', x: ${x}, y: ${y}})`;
  }
  codeFor_swipe(varNameIgnore, varIndexIgnore, pointerActions) {
    const {
      x1,
      y1,
      x2,
      y2
    } = this.getSwipeCoordinatesFromPointerActions(pointerActions);
    return `await driver.touchAction([
  {action: 'press', x: ${x1}, y: ${y1}},
  {action: 'wait', ms: 2000 },
  {action: 'moveTo', x: ${x2}, y: ${y2}},
  'release'
]);`;
  }
  codeFor_getCurrentActivity() {
    return `let activityName = await driver.getCurrentActivity();`;
  }
  codeFor_getCurrentPackage() {
    return `let packageName = await driver.getCurrentPackage();`;
  }
  codeFor_installApp(varNameIgnore, varIndexIgnore, app) {
    return `await driver.installApp('${app}');`;
  }
  codeFor_isAppInstalled(varNameIgnore, varIndexIgnore, app) {
    return `let isAppInstalled = await driver.isAppInstalled("${app}");`;
  }
  codeFor_launchApp() {
    return `await driver.launchApp();`;
  }
  codeFor_background(varNameIgnore, varIndexIgnore, timeout) {
    return `await driver.background(${timeout});`;
  }
  codeFor_closeApp() {
    return `await driver.closeApp();`;
  }
  codeFor_reset() {
    return `await driver.reset();`;
  }
  codeFor_removeApp(varNameIgnore, varIndexIgnore, app) {
    return `await driver.removeApp('${app}')`;
  }
  codeFor_getStrings(varNameIgnore, varIndexIgnore, language, stringFile) {
    return `let appStrings = await driver.getStrings(${language ? `${language}, ` : ''}${stringFile ? `"${stringFile}` : ''});`;
  }
  codeFor_getClipboard(varNameIgnore, varIndexIgnore, contentType) {
    return `let clipboardText = await driver.getClipboard(${contentType ? `${contentType}, ` : ''});`;
  }
  codeFor_setClipboard(varNameIgnore, varIndexIgnore, clipboardText) {
    return `await driver.setClipboard('${clipboardText}')`;
  }
  codeFor_pressKeyCode(varNameIgnore, varIndexIgnore, keyCode, metaState, flags) {
    return `await driver.longPressKeyCode(${keyCode}, ${metaState}, ${flags});`;
  }
  codeFor_longPressKeyCode(varNameIgnore, varIndexIgnore, keyCode, metaState, flags) {
    return `await driver.longPressKeyCode(${keyCode}, ${metaState}, ${flags});`;
  }
  codeFor_hideKeyboard() {
    return `await driver.hideKeyboard();`;
  }
  codeFor_isKeyboardShown() {
    return `let isKeyboardShown = await driver.isKeyboardShown();`;
  }
  codeFor_pushFile(varNameIgnore, varIndexIgnore, pathToInstallTo, fileContentString) {
    return `await driver.pushFile('${pathToInstallTo}', '${fileContentString}');`;
  }
  codeFor_pullFile(varNameIgnore, varIndexIgnore, pathToPullFrom) {
    return `let data = await driver.pullFile('${pathToPullFrom}');`;
  }
  codeFor_pullFolder(varNameIgnore, varIndexIgnore, folderToPullFrom) {
    return `let data = await driver.pullFolder('${folderToPullFrom}');`;
  }
  codeFor_toggleAirplaneMode() {
    return `await driver.toggleAirplaneMode();`;
  }
  codeFor_toggleData() {
    return `await driver.toggleData();`;
  }
  codeFor_toggleWiFi() {
    return `await driver.toggleWiFi();`;
  }
  codeFor_toggleLocationServices() {
    return `await driver.toggleLocationServices();`;
  }
  codeFor_sendSMS(varNameIgnore, varIndexIgnore, phoneNumber, text) {
    return `await driver.sendSms("${phoneNumber}", "${text}");`;
  }
  codeFor_gsmCall(varNameIgnore, varIndexIgnore, phoneNumber, action) {
    return `await driver.gsmCall("${phoneNumber}", "${action}");`;
  }
  codeFor_gsmSignal(varNameIgnore, varIndexIgnore, signalStrength) {
    return `await driver.gsmSignal("${signalStrength}");`;
  }
  codeFor_gsmVoice(varNameIgnore, varIndexIgnore, state) {
    return `await driver.gsmVoice("${state}");`;
  }
  codeFor_shake() {
    return `await driver.shake();`;
  }
  codeFor_lock(varNameIgnore, varIndexIgnore, seconds) {
    return `await driver.lock(${seconds});`;
  }
  codeFor_unlock() {
    return `await driver.unlock();`;
  }
  codeFor_isLocked() {
    return `let isLocked = await driver.isLocked();`;
  }
  codeFor_rotateDevice(varNameIgnore, varIndexIgnore, x, y, radius, rotation, touchCount, duration) {
    return `await driver.rotateDevice(${x}, ${y}, ${radius}, ${rotation}, ${touchCount}, ${duration});`;
  }
  codeFor_getPerformanceData(varNameIgnore, varIndexIgnore, packageName, dataType, dataReadTimeout) {
    return `let performanceData = driver.getPerformanceData("${packageName}", "${dataType}", ${dataReadTimeout});`;
  }
  codeFor_getPerformanceDataTypes() {
    return `let performanceDataTypes = await driver.getPerformanceDataTypes()`;
  }
  codeFor_touchId(varNameIgnore, varIndexIgnore, match) {
    return `await driver.touchId(${match});`;
  }
  codeFor_toggleEnrollTouchId(varNameIgnore, varIndexIgnore, enroll) {
    return `await driver.toggleEnrollTouchId(${enroll});`;
  }
  codeFor_openNotifications() {
    return `await driver.openNotifications();`;
  }
  codeFor_getDeviceTime() {
    return `let time = await driver.getDeviceTime();`;
  }
  codeFor_fingerprint(varNameIgnore, varIndexIgnore, fingerprintId) {
    return `await driver.fingerprint(${fingerprintId});`;
  }
  codeFor_getSession() {
    return `let caps = await driver.getSession();`;
  }
  codeFor_setTimeouts( /*varNameIgnore, varIndexIgnore, timeoutsJson*/
  ) {
    return '/* TODO implement setTimeouts */';
  }
  codeFor_setCommandTimeout( /*varNameIgnore, varIndexIgnore, ms*/
  ) {
    return `// Not supported: setCommandTimeout`;
  }
  codeFor_getOrientation() {
    return `let orientation = await driver.getOrientation();`;
  }
  codeFor_setOrientation(varNameIgnore, varIndexIgnore, orientation) {
    return `await driver.setOrientation("${orientation}");`;
  }
  codeFor_getGeoLocation() {
    return `let location = await driver.getGeoLocation();`;
  }
  codeFor_setGeoLocation(varNameIgnore, varIndexIgnore, latitude, longitude, altitude) {
    return `await driver.setGeoLocation({latitude: ${latitude}, longitude: ${longitude}, altitude: ${altitude}});`;
  }
  codeFor_getLogTypes() {
    return `let getLogTypes = await driver.getLogTypes();`;
  }
  codeFor_getLogs(varNameIgnore, varIndexIgnore, logType) {
    return `let logs = await driver.getLogs('${logType}');`;
  }
  codeFor_updateSettings(varNameIgnore, varIndexIgnore, settingsJson) {
    return `await driver.updateSettings(${settingsJson});`;
  }
  codeFor_getSettings() {
    return `let settings = await driver.getSettings();`;
  }

  // Web

  codeFor_navigateTo(varNameIgnore, varIndexIgnore, url) {
    return `await driver.navigateTo('${url}');`;
  }
  codeFor_getUrl() {
    return `let current_url = await driver.getUrl();`;
  }
  codeFor_forward() {
    return `await driver.forward();`;
  }
  codeFor_refresh() {
    return `await driver.refresh();`;
  }

  // Context

  codeFor_getContext() {
    return `let context = await driver.getContext();`;
  }
  codeFor_getContexts() {
    return `let contexts = await driver.getContexts();`;
  }
  codeFor_switchContext(varNameIgnore, varIndexIgnore, name) {
    return `await driver.switchContext('${name}');`;
  }
}
JsWdIoFramework.readableName = 'JS - Webdriver.io';
var _default = JsWdIoFramework;
exports.default = _default;
},{"./framework":"renderer/lib/client-frameworks/framework.js"}],"main.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.launchNewSessionWindow = launchNewSessionWindow;
var _i18next = _interopRequireDefault(require("./configs/i18next.config"));
var _electron = require("electron");
var _debug = require("../gui-common/debug");
var _windows = require("../gui-common/windows");
var _menus = require("./main/menus");
var _settings = _interopRequireDefault(require("./shared/settings"));
var _helpers = require("./main/helpers");
var _path = _interopRequireDefault(require("path"));
var _fs = _interopRequireDefault(require("fs"));
var _jsWdio = _interopRequireDefault(require("./renderer/lib/client-frameworks/js-wdio"));
var _appiumDataInteraction = require("appium-data-interaction");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const {
  exec
} = require('child_process');
let mainWindow = null;
const isDev = process.env.NODE_ENV === 'development';
if (isDev) {
  require('electron-debug')(); // eslint-disable-line global-require
}

let openFilePath = (0, _helpers.getAppiumSessionFilePath)(process.argv, _electron.app.isPackaged, isDev);
_electron.app.on('open-file', (event, filePath) => {
  openFilePath = filePath;
});
_electron.app.on('window-all-closed', () => {
  _electron.app.quit();
});
function buildSessionWindow() {
  _appiumDataInteraction.TestPlatform.setInfo('http://localhost:8888', 'experimentation_subject_id=imuzndu1mdjkltuwmdctndk2ys1hmtljlti1owrlnjc4yzfmosi%3d--fb98d346787f918849a9c9f856a783933b9fbe94; sensorsdata2015jssdkcross=%7b%22distinct_id%22%3a%22cwmsvtiu%22%2c%22%24device_id%22%3a%221818b7939df5b9-0e4072c3066eed-1d525635-1930176-1818b7939e01c4e%22%2c%22props%22%3a%7b%22%24latest_referrer%22%3a%22%22%2c%22%24latest_traffic_source_type%22%3a%22%e7%9b%b4%e6%8e%a5%e6%b5%81%e9%87%8f%22%2c%22%24latest_search_keyword%22%3a%22%e6%9c%aa%e5%8f%96%e5%88%b0%e5%80%bc_%e7%9b%b4%e6%8e%a5%e6%89%93%e5%bc%80%22%7d%2c%22first_id%22%3a%221818b7939df5b9-0e4072c3066eed-1d525635-1930176-1818b7939e01c4e%22%2c%22identities%22%3a%22eyikawrlbnrpdhlfy29va2llx2lkijoimtgzmgi2mmnlmwyymdqtmdc0zwuzyjiyztdlogy4ltfinti1njm1lte5mzaxnzytmtgzmgi2mmnlmjaxyzg3iiwijglkzw50axr5x2xvz2lux2lkijoiq3dnc3z0avuifq%3d%3d%22%2c%22history_login_id%22%3a%7b%22name%22%3a%22%24identity_login_id%22%2c%22value%22%3a%22cwmsvtiu%22%7d%7d; remember_token=6406f1f672e4efcd4d47d36a|2715bd37fbd1a85bf9604019b6c5e81b0a65ef56f0f58f90ddc55b6b2e7b82e73ec866863cf358339e80d0b60d7f21ddcce9ee80d47879e9a045ed8bd13beb7f; session=.ejwdyzsoajemang7pkawhcdjuazyv9duqow4o4hypdfv9jrzud2ixzswsghjpoqsdw6e0uxbpd3qyppers_jlb_6c8wxmxn73ds5azkvdz6oi5eyvuipjy30nhlb-hswqo5ftrhvezurosuog16mmx227tadoyvloyapdakbxwbzap5wxvju7fmfh0020g.zcer_g.cq9eqooxjtrerz589dhvixjvkqe; auto-ftest=eyjhbgcioijiuzuxmiisimlhdci6mty3otg5ntu1mcwizxhwijoxnjc5otaynzuwfq.eyjlbwfpbci6innozw5szwlazm9yew91ntyuy29tiiwicm9szxmiolsichjvamvjdcisinvzzxiilcjhzg1pbijdlcjuyw1lijoi5rki6zu3iiwibw9iawxlijoimtm2mdawmdawmdaifq.s7ghd-yfdtpkva1qog8f2x9-qw8j9thdpglaekvl-oz3o98gkgwpve1g1u8pig0bsihghirh_9p_4zzikizdoq; auto-ftest=eyjhbgcioijiuzuxmiisimlhdci6mty3otg5ntu1mcwizxhwijoxnjc5otaynzuwfq.eyjlbwfpbci6innozw5szwlazm9yew91ntyuy29tiiwicm9szxmiolsichjvamvjdcisinvzzxiilcjhzg1pbijdlcjuyw1lijoi5rki6zu3iiwibw9iawxlijoimtm2mdawmdawmdaifq.s7ghd-yfdtpkva1qog8f2x9-qw8j9thdpglaekvl-oz3o98gkgwpve1g1u8pig0bsihghirh_9p_4zzikizdoq; auth-token=eyjhbgcioijiuzuxmiisimlhdci6mty3otg5ntu1mcwizxhwijoxnjc5otaynzuwfq.eyjlbwfpbci6innozw5szwlazm9yew91ntyuy29tiiwicm9szxmiolsichjvamvjdcisinvzzxiilcjhzg1pbijdlcjuyw1lijoi5rki6zu3iiwibw9iawxlijoimtm2mdawmdawmdaifq.s7ghd-yfdtpkva1qog8f2x9-qw8j9thdpglaekvl-oz3o98gkgwpve1g1u8pig0bsihghirh_9p_4zzikizdoq');
  const window = new _electron.BrowserWindow({
    show: false,
    width: 1280,
    height: 800,
    minWidth: 1000,
    minHeight: 800,
    titleBarStyle: 'hiddenInset',
    webPreferences: {
      nodeIntegration: true,
      contextIsolation: false,
      enableRemoteModule: true,
      additionalArguments: openFilePath ? [`filename=${openFilePath}`] : []
    }
  });
  _electron.ipcMain.on('make-request', async (event, args) => {
    const {
      requestName
    } = JSON.parse(args);
    try {
      if (requestName === 'getSuiteGroupList') {
        const response = await _appiumDataInteraction.TestPlatform.getSuiteGroupList('641a7505211af6db9e160825');
        const convertResponse = convertData(response);
        const params = {
          requestName,
          convertResponse
        };
        event.reply('receive-request', JSON.stringify(params));
      } else if (requestName === 'testSuiteList') {
        const {
          groupId,
          skip
        } = JSON.parse(args);
        const response = await _appiumDataInteraction.TestPlatform.getTestSuiteList('641a7505211af6db9e160825', groupId, skip);
        const convertResponse = {
          'total': response.data.totalNum,
          'rows': convertData(response)
        };
        const params = {
          requestName,
          convertResponse
        };
        event.reply('receive-request', JSON.stringify(params));
      } else if (requestName === 'testSuiteEnv') {
        const response = await _appiumDataInteraction.TestPlatform.getTestEnvList();
        const convertResponse = convertData(response);
        const params = {
          requestName,
          convertResponse
        };
        event.reply('receive-request', JSON.stringify(params));
      } else if (requestName === 'startUIAutomation') {
        const {
          suiteVars,
          testId,
          envId
        } = JSON.parse(args);
        const response = await _appiumDataInteraction.TestPlatform.startUIAutomationTest(suiteVars, [testId], '641a7505211af6db9e160825', envId);
        const params = {
          requestName,
          response
        };
        event.reply('receive-request', JSON.stringify(params));
      }
    } catch (e) {
      event.reply('receive-request', e);
    }
  });

  // eslint-disable-next-line require-await
  _electron.ipcMain.on('get-appdata', async (event, args) => {
    const {
      caps,
      apiPath,
      responseName
    } = JSON.parse(args);
    _appiumDataInteraction.Interaction.setCaps(caps, 'http://localhost:8084');
    try {
      let response = await _appiumDataInteraction.Interaction.getAppData(apiPath);
      const e = null;
      const params = {
        responseName,
        response,
        e
      };
      event.reply('receive-appdata', JSON.stringify(params));
    } catch (e) {
      const response = null;
      const params = {
        responseName,
        response,
        e
      };
      event.reply('receive-appdata', JSON.stringify(params));
    }
  });
  _electron.ipcMain.on('select-script', async event => {
    const options = {
      title: 'Select File',
      // 对话框标题
      buttonLabel: 'Select',
      // 按钮文本
      filters: [{
        name: 'JS Files',
        extensions: ['js']
      } // 文件类型过滤器
      ],

      properties: ['openFile'] // 属性配置
    };

    const result = await _electron.dialog.showOpenDialog(options);
    if (!result.canceled) {
      const filePath = result.filePaths[0];
      const script = _fs.default.readFileSync(filePath, 'utf-8');
      const params = {
        filePath,
        script
      };
      event.reply('send-script', JSON.stringify(params));
    }
  });

  // eslint-disable-next-line require-await
  _electron.ipcMain.on('execute-script', async (event, args) => {
    const jsonArgs = JSON.parse(args);
    const {
      newExecuteVars,
      host,
      port,
      spath,
      https,
      caps,
      cookie,
      filePath
    } = jsonArgs;
    const script = _fs.default.readFileSync(filePath, 'utf-8');
    const executeScript = new _jsWdio.default(host, port, spath, https, caps, filePath, cookie, newExecuteVars).wrapWithBoilerplate(script);
    console.log(`executeScript = ${executeScript}`);
    eval(executeScript);
  });
  _electron.ipcMain.on('save-script', (event, args) => {
    const {
      actions
    } = args;
    // const fileDir = path.join(app.getPath('userData'), '/Script');
    // const filePath = path.join(app.getPath('userData'), '/Script/' + scriptName + '.js');
    //
    // // 检查目录是否存在
    // fs.access(fileDir, fs.constants.F_OK, (err) => {
    //   if (err) {
    //     // 目录不存在 尝试创建
    //     fs.mkdir(fileDir, {recursive: true}, (err) => {
    //       if (err) {
    //         console.error(`Error creating directory: ${err}`);
    //       } else {
    //         console.log(`Directory ${fileDir} created successfully!`);
    //         fs.writeFile(filePath, actions, (err) => {});
    //       }
    //     });
    //   } else {
    //     fs.writeFile(filePath, actions, (err) => {});
    //   }
    // });
    const options = {
      title: 'Save File',
      // 对话框标题
      buttonLabel: 'Save',
      // 按钮文本
      filters: [{
        name: 'JS Files',
        extensions: ['js']
      } // 文件类型过滤器
      ]
    };

    _electron.dialog.showSaveDialog(options).then(result => {
      if (!result.canceled) {
        const filePath = result.filePath;
        _fs.default.writeFile(filePath, actions, err => {});
        console.log('保存文件路径:', filePath);
        // 在这里处理文件保存逻辑，将数据写入文件等
      } else {
        console.log('用户取消了保存操作');
      }
    }).catch(err => {
      console.error('保存文件对话框错误:', err);
    });
  });
  _electron.ipcMain.on('save-file-as', async () => {
    const {
      canceled,
      filePath
    } = await _electron.dialog.showSaveDialog(mainWindow, {
      title: 'Save Appium File',
      filters: [{
        name: 'Appium Session Files',
        extensions: [_helpers.APPIUM_SESSION_EXTENSION]
      }]
    });
    if (!canceled) {
      mainWindow.webContents.send('save-file', filePath);
    }
  });
  return window;
}
function launchAppiumServer() {
  // 启动appium server
  exec(`appium --log-level=debug --base-path='/wd/hub'`, async (error, stdout, stderr) => {
    if (error) {
      console.error(`Error executing shell script: ${error}`);
      return;
    }
    console.log('Shell script output:', stdout);
  });
}
function launchNewSessionWindow() {
  const url = `file://${__dirname}/index.html`;
  const win = buildSessionWindow();
  win.loadURL(url);
  win.show();
}
_electron.app.on('ready', async () => {
  await (0, _debug.installExtensions)();
  mainWindow = buildSessionWindow();
  const splashWindow = new _electron.BrowserWindow({
    width: 300,
    height: 300,
    minWidth: 300,
    minHeight: 300,
    frame: false
  });
  launchAppiumServer();
  (0, _windows.setupMainWindow)({
    mainWindow,
    splashWindow,
    mainUrl: `file://${__dirname}/index.html`,
    splashUrl: `file://${__dirname}/splash.html`,
    isDev,
    Menu: _electron.Menu,
    i18n: _i18next.default,
    rebuildMenus: _menus.rebuildMenus,
    settings: _settings.default,
    webContents: _electron.webContents,
    shouldShowFileMenu: true
  });
});
function convertData(originalData) {
  const convertedData = [];
  for (const originalItem of originalData.data.rows) {
    const convertedItem = {
      key: originalItem._id,
      label: originalItem.name
    };
    if (originalItem.children) {
      convertedItem.children = convertChildren(originalItem.children);
    }
    convertedData.push(convertedItem);
  }
  return convertedData;
}
function convertChildren(originalChildren) {
  const convertedChildren = [];
  for (const originalChild of originalChildren) {
    const convertedChild = {
      key: originalChild._id,
      label: originalChild.name
    };
    if (originalChild.children && originalChild.children.length > 0) {
      convertedChild.children = convertChildren(originalChild.children);
    }
    convertedChildren.push(convertedChild);
  }
  return convertedChildren;
}
},{"./configs/i18next.config":"configs/i18next.config.js","../gui-common/debug":"../gui-common/debug.js","../gui-common/windows":"../gui-common/windows.js","./main/menus":"main/menus.js","./shared/settings":"shared/settings.js","./main/helpers":"main/helpers.js","./renderer/lib/client-frameworks/js-wdio":"renderer/lib/client-frameworks/js-wdio.js"}]},{},["main.js"], null)
//# sourceMappingURL=main.js.map