'use strict'
!(function(require, directRequire) {
  function a(a) {
    return e('POST', a)
  }
  function b(a) {
    return e('DELETE', a)
  }
  function c(a) {
    return e('GET', a)
  }
  function d(a) {
    let b = a.match(/\/:(\w+)\b/g) || [],
      c = [],
      d = a.replace(/\/:(\w+)\b/g, '/([^/]+)\\b') + '$'
    for (let d, e = 0; e < b.length; ++e) (d = b[e].substring(2)), c.push(d)
    return { regExp: new RegExp(d), parameters: c }
  }
  function e(a, b) {
    let c = d(b)
    return { method: a, path: b, regExp: c.regExp, parameters: c.parameters }
  }
  class f {
    constructor(a, b, c, d) {
      ;(this.name_ = a),
        (this.parameters_ = b),
        (this.method_ = c),
        (this.path_ = d)
    }
    getName() {
      return this.name_
    }
    getParameter(a) {
      return this.parameters_[a]
    }
    getParameters() {
      return this.parameters_
    }
    toString() {
      return `command: ${this.name_};\nparameters: ${JSON.stringify(
        this.parameters_
      )}`
    }
    getMethod() {
      return this.method_
    }
    getPath() {
      return this.path_
    }
    stringify() {
      let a = this.path_,
        b = this.path_.match(/\/:(\w+)\b/g)
      if (b)
        for (let c, d = 0; d < b.length; ++d)
          if (((c = b[d].substring(2)), c in this.parameters_)) {
            let e = this.parameters_[c]
            a = a.replace(b[d], '/' + e)
          } else
            throw new error.InvalidArgumentError(
              'Missing required parameter: ' + c
            )
      return a
    }
  }
  const g = {
      CLOSE: 'close',
      QUIT: 'quit',
      GET_CURRENT_URL: 'getCurrentUrl',
      GET: 'get',
      GO_BACK: 'goBack',
      GO_FORWARD: 'goForward',
      REFRESH: 'refresh',
      COMPILE: 'compile',
      GET_ACTIVE_ELEMENT: 'getActiveElement',
      FIND_ELEMENT: 'findElement',
      FIND_ELEMENTS: 'findElements',
      FIND_CHILD_ELEMENT: 'findChildElement',
      FIND_CHILD_ELEMENTS: 'findChildElements',
      CLEAR_ELEMENT: 'clearElement',
      CLICK_ELEMENT: 'clickElement',
      SEND_KEYS_TO_ELEMENT: 'sendKeysToElement',
      SUBMIT_ELEMENT: 'submitElement',
      GET_CURRENT_WINDOW_HANDLE: 'getCurrentWindowHandle',
      GET_WINDOW_HANDLES: 'getWindowHandles',
      GET_WINDOW_POSITION: 'getWindowPosition',
      SET_WINDOW_POSITION: 'setWindowPosition',
      GET_WINDOW_SIZE: 'getWindowSize',
      SET_WINDOW_SIZE: 'setWindowSize',
      MAXIMIZE_WINDOW: 'maximizeWindow',
      SWITCH_TO_WINDOW: 'switchToWindow',
      SWITCH_TO_FRAME: 'switchToFrame',
      GET_PAGE_SOURCE: 'getPageSource',
      GET_TITLE: 'getTitle',
      EXECUTE_SCRIPT: 'executeScript',
      EXECUTE_ASYNC_SCRIPT: 'executeAsyncScript',
      GET_ELEMENT_TEXT: 'getElementText',
      GET_ELEMENT_TAG_NAME: 'getElementTagName',
      IS_ELEMENT_SELECTED: 'isElementSelected',
      IS_ELEMENT_ENABLED: 'isElementEnabled',
      IS_ELEMENT_DISPLAYED: 'isElementDisplayed',
      GET_ELEMENT_LOCATION: 'getElementLocation',
      GET_ELEMENT_LOCATION_IN_VIEW: 'getElementLocationOnceScrolledIntoView',
      GET_ELEMENT_SIZE: 'getElementSize',
      GET_ELEMENT_RECT: 'getElementRect',
      GET_ELEMENT_ATTRIBUTE: 'getElementAttribute',
      GET_ELEMENT_VALUE_OF_CSS_PROPERTY: 'getElementValueOfCssProperty',
      ELEMENT_EQUALS: 'elementEquals',
      SCREENSHOT: 'screenshot',
      TAKE_ELEMENT_SCREENSHOT: 'takeElementScreenshot',
      IMPLICITLY_WAIT: 'implicitlyWait',
      SET_SCRIPT_TIMEOUT: 'setScriptTimeout',
      GET_TIMEOUT: 'getTimeout',
      SET_TIMEOUT: 'setTimeout',
      ACCEPT_ALERT: 'acceptAlert',
      DISMISS_ALERT: 'dismissAlert',
      GET_ALERT_TEXT: 'getAlertText',
      SET_ALERT_TEXT: 'setAlertValue',
      SET_ALERT_CREDENTIALS: 'setAlertCredentials',
      EXECUTE_SQL: 'executeSQL',
      GET_LOCATION: 'getLocation',
      SET_LOCATION: 'setLocation',
      GET_APP_CACHE: 'getAppCache',
      GET_APP_CACHE_STATUS: 'getStatus',
      CLEAR_APP_CACHE: 'clearAppCache',
      IS_BROWSER_ONLINE: 'isBrowserOnline',
      SET_BROWSER_ONLINE: 'setBrowserOnline',
      GET_LOCAL_STORAGE_ITEM: 'getLocalStorageItem',
      GET_LOCAL_STORAGE_KEYS: 'getLocalStorageKeys',
      SET_LOCAL_STORAGE_ITEM: 'setLocalStorageItem',
      REMOVE_LOCAL_STORAGE_ITEM: 'removeLocalStorageItem',
      CLEAR_LOCAL_STORAGE: 'clearLocalStorage',
      GET_LOCAL_STORAGE_SIZE: 'getLocalStorageSize',
      GET_SESSION_STORAGE_ITEM: 'getSessionStorageItem',
      GET_SESSION_STORAGE_KEYS: 'getSessionStorageKey',
      SET_SESSION_STORAGE_ITEM: 'setSessionStorageItem',
      REMOVE_SESSION_STORAGE_ITEM: 'removeSessionStorageItem',
      CLEAR_SESSION_STORAGE: 'clearSessionStorage',
      GET_SESSION_STORAGE_SIZE: 'getSessionStorageSize',
      SET_SCREEN_ORIENTATION: 'setScreenOrientation',
      GET_SCREEN_ORIENTATION: 'getScreenOrientation',
      CLICK: 'mouseClick',
      DOUBLE_CLICK: 'mouseDoubleClick',
      MOUSE_DOWN: 'mouseButtonDown',
      MOUSE_UP: 'mouseButtonUp',
      MOVE_TO: 'mouseMoveTo',
      SEND_KEYS_TO_ACTIVE_ELEMENT: 'sendKeysToActiveElement',
      TOUCH_SINGLE_TAP: 'touchSingleTap',
      TOUCH_DOWN: 'touchDown',
      TOUCH_UP: 'touchUp',
      TOUCH_MOVE: 'touchMove',
      TOUCH_SCROLL: 'touchScroll',
      TOUCH_DOUBLE_TAP: 'touchDoubleTap',
      TOUCH_LONG_PRESS: 'touchLongPress',
      TOUCH_FLICK: 'touchFlick',
      GET_AVAILABLE_LOG_TYPES: 'getAvailableLogTypes',
      GET_LOG: 'getLog',
      GET_SESSION_LOGS: 'getSessionLogs',
      UPLOAD_FILE: 'uploadFile',
      UPDATE_WECHATDEVTOOLS_PORT: 'updateWechatdevtoolsPort',
      WEIXINJSBRIDGE_INVOKE: 'weixinJSBridgeInvoke',
      WEIXINJSBRIDGE_ON: 'weixinJSBridgeOn',
      GET_WECHATDEVTOOLS_STORE_STATE: 'getWechatdevtoolsStoreState',
      FIND_WEBVIEW: 'findWebview',
      FIND_WEBVIEW_ELEMENT: 'findWebviewElement',
      FIND_WEBVIEW_ELEMENT_FROM_POINT: 'findWebviewElementFromPoint',
      FIND_WEBVIEW_ACTION_ELEMENT_FROM_POINT:
        'findWebviewActionElementFromPoint',
      FIND_WEBVIEW_ELEMENTS: 'findWebviewElements',
      TOUCH_CLICK_WEBVIEW_ELEMENT: 'tapWebviewElement',
      TOUCH_LONGCLICK_WEBVIEW_ELEMENT: 'longtapWebviewElement',
      TOUCH_DOWN_WEBVIEW: 'touchDownWebview',
      TOUCH_MOVE_WEBVIEW: 'touchMoveWebview',
      TOUCH_UP_WEBVIEW: 'touchUpWebview',
      TOUCH_SCROLL_WEBVIEW: 'touchScrollWebview',
      SEND_KEYS_TO_WEBVIEW_ELEMENT: 'sendKeysToWebviewElement',
      GET_WEBVIEW_ELEMENT_TAG_NAME: 'getWebviewElementTagName',
      GET_WEBVIEW_ELEMENT_ATTRIBUTE: 'getWebviewElementAttribute',
      GET_WEBVIEW_ELEMENT_LOCATION: 'getWebviewElementLocation',
      GET_WEBVIEW_ELEMENT_SIZE: 'getWebviewElementSize',
      GET_WEBVIEW_ELEMENT_VALUE_OF_CSS_PROPERTY: 'getWebviewElementCssProperty',
      GET_WEBVIEW_ELEMENT_RECT: 'getWebviewElementRect',
      GET_WEBVIEW_CONTENT_SIZE: 'getWebviewContentSize',
      GET_APPSERVICE_DATA: 'getAppServiceData',
      GET_CURRENT_PAGE_STACK: 'getCurrentPageStack',
      GET_CURRENT_PAGE_TITLE: 'getCurrentPageTitle',
      GET_CURRENT_PAGE_QUERY: 'getCurrentPageQuery',
      GET_CURRENT_HTML: 'getCurrentHtml',
      GET_SCREENSHOT: 'getScreenShot',
      REFRESH_TICKET: 'refreshTicket',
      GET_RUNTIME_INFO: 'getRuntimeInfo'
    },
    h = new Map([
      [g.GET_APP_CACHE_STATUS, c('/status')],
      [g.NEW_SESSION, a('/session')],
      [g.GET_SESSIONS, c('/sessions')],
      [g.DESCRIBE_SESSION, c('/session/:sessionId')],
      [g.QUIT, b('/session/:sessionId')],
      [g.CLOSE, b('/session/:sessionId/window')],
      [g.GET_CURRENT_WINDOW_HANDLE, c('/session/:sessionId/window_handle')],
      [g.GET_WINDOW_HANDLES, c('/session/:sessionId/window_handles')],
      [g.GET_CURRENT_URL, c('/session/:sessionId/url')],
      [g.GET, a('/session/:sessionId/url')],
      [g.GO_BACK, a('/session/:sessionId/back')],
      [g.GO_FORWARD, a('/session/:sessionId/forward')],
      [g.REFRESH, a('/session/:sessionId/refresh')],
      [g.ADD_COOKIE, a('/session/:sessionId/cookie')],
      [g.GET_ALL_COOKIES, c('/session/:sessionId/cookie')],
      [g.DELETE_ALL_COOKIES, b('/session/:sessionId/cookie')],
      [g.DELETE_COOKIE, b('/session/:sessionId/cookie/:name')],
      [g.FIND_ELEMENT, a('/session/:sessionId/element')],
      [g.FIND_ELEMENTS, a('/session/:sessionId/elements')],
      [g.GET_ACTIVE_ELEMENT, a('/session/:sessionId/element/active')],
      [g.FIND_CHILD_ELEMENT, a('/session/:sessionId/element/:id/element')],
      [g.FIND_CHILD_ELEMENTS, a('/session/:sessionId/element/:id/elements')],
      [g.CLEAR_ELEMENT, a('/session/:sessionId/element/:id/clear')],
      [g.CLICK_ELEMENT, a('/session/:sessionId/element/:id/click')],
      [g.SEND_KEYS_TO_ELEMENT, a('/session/:sessionId/element/:id/value')],
      [g.SUBMIT_ELEMENT, a('/session/:sessionId/element/:id/submit')],
      [g.GET_ELEMENT_TEXT, c('/session/:sessionId/element/:id/text')],
      [g.GET_ELEMENT_TAG_NAME, c('/session/:sessionId/element/:id/name')],
      [g.IS_ELEMENT_SELECTED, c('/session/:sessionId/element/:id/selected')],
      [g.IS_ELEMENT_ENABLED, c('/session/:sessionId/element/:id/enabled')],
      [g.IS_ELEMENT_DISPLAYED, c('/session/:sessionId/element/:id/displayed')],
      [g.GET_ELEMENT_LOCATION, c('/session/:sessionId/element/:id/location')],
      [g.GET_ELEMENT_SIZE, c('/session/:sessionId/element/:id/size')],
      [
        g.GET_ELEMENT_ATTRIBUTE,
        c('/session/:sessionId/element/:id/attribute/:name')
      ],
      [
        g.GET_ELEMENT_VALUE_OF_CSS_PROPERTY,
        c('/session/:sessionId/element/:id/css/:propertyName')
      ],
      [g.ELEMENT_EQUALS, c('/session/:sessionId/element/:id/equals/:other')],
      [
        g.TAKE_ELEMENT_SCREENSHOT,
        c('/session/:sessionId/element/:id/screenshot')
      ],
      [g.SWITCH_TO_WINDOW, a('/session/:sessionId/window')],
      [g.MAXIMIZE_WINDOW, a('/session/:sessionId/window/current/maximize')],
      [g.GET_WINDOW_POSITION, c('/session/:sessionId/window/current/position')],
      [g.SET_WINDOW_POSITION, a('/session/:sessionId/window/current/position')],
      [g.GET_WINDOW_SIZE, c('/session/:sessionId/window/current/size')],
      [g.SET_WINDOW_SIZE, a('/session/:sessionId/window/current/size')],
      [g.SWITCH_TO_FRAME, a('/session/:sessionId/frame')],
      [g.GET_PAGE_SOURCE, c('/session/:sessionId/source')],
      [g.GET_TITLE, c('/session/:sessionId/title')],
      [g.EXECUTE_SCRIPT, a('/session/:sessionId/execute')],
      [g.EXECUTE_ASYNC_SCRIPT, a('/session/:sessionId/execute_async')],
      [g.SCREENSHOT, c('/session/:sessionId/screenshot')],
      [g.GET_TIMEOUT, c('/session/:sessionId/timeouts')],
      [g.SET_TIMEOUT, a('/session/:sessionId/timeouts')],
      [g.MOVE_TO, a('/session/:sessionId/moveto')],
      [g.CLICK, a('/session/:sessionId/click')],
      [g.DOUBLE_CLICK, a('/session/:sessionId/doubleclick')],
      [g.MOUSE_DOWN, a('/session/:sessionId/buttondown')],
      [g.MOUSE_UP, a('/session/:sessionId/buttonup')],
      [g.MOVE_TO, a('/session/:sessionId/moveto')],
      [g.SEND_KEYS_TO_ACTIVE_ELEMENT, a('/session/:sessionId/keys')],
      [g.TOUCH_SINGLE_TAP, a('/session/:sessionId/touch/click')],
      [g.TOUCH_DOUBLE_TAP, a('/session/:sessionId/touch/doubleclick')],
      [g.TOUCH_DOWN, a('/session/:sessionId/touch/down')],
      [g.TOUCH_UP, a('/session/:sessionId/touch/up')],
      [g.TOUCH_MOVE, a('/session/:sessionId/touch/move')],
      [g.TOUCH_SCROLL, a('/session/:sessionId/touch/scroll')],
      [g.TOUCH_LONG_PRESS, a('/session/:sessionId/touch/longclick')],
      [g.TOUCH_FLICK, a('/session/:sessionId/touch/flick')],
      [g.ACCEPT_ALERT, a('/session/:sessionId/accept_alert')],
      [g.DISMISS_ALERT, a('/session/:sessionId/dismiss_alert')],
      [g.GET_ALERT_TEXT, c('/session/:sessionId/alert_text')],
      [g.SET_ALERT_TEXT, a('/session/:sessionId/alert_text')],
      [g.SET_ALERT_CREDENTIALS, a('/session/:sessionId/alert/credentials')],
      [g.GET_LOG, a('/session/:sessionId/log')],
      [g.GET_AVAILABLE_LOG_TYPES, c('/session/:sessionId/log/types')],
      [g.GET_SESSION_LOGS, a('/logs')],
      [g.UPLOAD_FILE, a('/session/:sessionId/file')]
    ]),
    i = new Map([
      [g.GET_ACTIVE_ELEMENT, c('/session/:sessionId/element/active')],
      [g.GET_ALERT_TEXT, c('/session/:sessionId/alert/text')],
      [g.SET_ALERT_TEXT, a('/session/:sessionId/alert/text')],
      [g.ACCEPT_ALERT, a('/session/:sessionId/alert/accept')],
      [g.DISMISS_ALERT, a('/session/:sessionId/alert/dismiss')],
      [g.GET_ELEMENT_LOCATION, c('/session/:sessionId/element/:id/rect')],
      [g.GET_ELEMENT_SIZE, c('/session/:sessionId/element/:id/rect')],
      [g.EXECUTE_SCRIPT, a('/session/:sessionId/execute/sync')],
      [g.EXECUTE_ASYNC_SCRIPT, a('/session/:sessionId/execute/async')],
      [g.MAXIMIZE_WINDOW, a('/session/:sessionId/window/maximize')],
      [g.GET_WINDOW_POSITION, c('/session/:sessionId/window/position')],
      [g.SET_WINDOW_POSITION, a('/session/:sessionId/window/position')],
      [g.GET_WINDOW_SIZE, c('/session/:sessionId/window/size')],
      [g.SET_WINDOW_SIZE, a('/session/:sessionId/window/size')],
      [g.GET_CURRENT_WINDOW_HANDLE, c('/session/:sessionId/window')],
      [g.GET_WINDOW_HANDLES, c('/session/:sessionId/window/handles')]
    ]),
    j = new Map([
      [g.GET_ELEMENT_RECT, c('/session/:sessionId/element/:id/rect')],
      [
        g.WEIXINJSBRIDGE_INVOKE,
        a('/session/:sessionId/wechatdevtools/weixinjsbridge/invoke/:api')
      ],
      [
        g.WEIXINJSBRIDGE_ON,
        c('/session/:sessionId/wechatdevtools/weixinjsbridge/on/:api')
      ],
      [
        g.GET_WECHATDEVTOOLS_STORE_STATE,
        c('/session/:sessionId/wechatdevtools/getstorestate')
      ],
      [g.FIND_WEBVIEW, a('/session/:sessionId/wechatdevtools/webview')],
      [
        g.FIND_WEBVIEW_ELEMENT,
        a('/session/:sessionId/wechatdevtools/webview/:webviewId/element')
      ],
      [
        g.FIND_WEBVIEW_ELEMENT_FROM_POINT,
        a(
          '/session/:sessionId/wechatdevtools/webview/:webviewId/elementfrompoint'
        )
      ],
      [
        g.FIND_WEBVIEW_ACTION_ELEMENT_FROM_POINT,
        a(
          '/session/:sessionId/wechatdevtools/webview/:webviewId/actionelementfrompoint'
        )
      ],
      [
        g.FIND_WEBVIEW_ELEMENTS,
        a('/session/:sessionId/wechatdevtools/webview/:webviewId/elements')
      ],
      [
        g.TOUCH_CLICK_WEBVIEW_ELEMENT,
        a('/session/:sessionId/wechatdevtools/webview/:webviewId/touch/click')
      ],
      [
        g.TOUCH_LONGCLICK_WEBVIEW_ELEMENT,
        a(
          '/session/:sessionId/wechatdevtools/webview/:webviewId/touch/longclick'
        )
      ],
      [
        g.TOUCH_DOWN_WEBVIEW,
        a('/session/:sessionId/wechatdevtools/webview/:webviewId/touch/down')
      ],
      [
        g.TOUCH_MOVE_WEBVIEW,
        a('/session/:sessionId/wechatdevtools/webview/:webviewId/touch/move')
      ],
      [
        g.TOUCH_UP_WEBVIEW,
        a('/session/:sessionId/wechatdevtools/webview/:webviewId/touch/up')
      ],
      [
        g.TOUCH_SCROLL_WEBVIEW,
        a('/session/:sessionId/wechatdevtools/webview/:webviewId/touch/scroll')
      ],
      [
        g.SEND_KEYS_TO_WEBVIEW_ELEMENT,
        a(
          '/session/:sessionId/wechatdevtools/webview/:webviewId/element/:id/value'
        )
      ],
      [
        g.GET_WEBVIEW_ELEMENT_SIZE,
        c(
          '/session/:sessionId/wechatdevtools/webview/:webviewId/element/:id/size'
        )
      ],
      [
        g.GET_WEBVIEW_ELEMENT_LOCATION,
        c(
          '/session/:sessionId/wechatdevtools/webview/:webviewId/element/:id/location'
        )
      ],
      [
        g.GET_WEBVIEW_ELEMENT_ATTRIBUTE,
        c(
          '/session/:sessionId/wechatdevtools/webview/:webviewId/element/:id/attribute/:name'
        )
      ],
      [
        g.GET_WEBVIEW_ELEMENT_TAG_NAME,
        c(
          '/session/:sessionId/wechatdevtools/webview/:webviewId/element/:id/name'
        )
      ],
      [
        g.GET_WEBVIEW_ELEMENT_VALUE_OF_CSS_PROPERTY,
        c(
          '/session/:sessionId/wechatdevtools/webview/:webviewId/element/:id/css/:propertyName'
        )
      ],
      [
        g.GET_WEBVIEW_ELEMENT_RECT,
        c(
          '/session/:sessionId/wechatdevtools/webview/:webviewId/element/:id/rect'
        )
      ],
      [
        g.GET_WEBVIEW_CONTENT_SIZE,
        c('/session/:sessionId/wechatdevtools/webview/:webviewId/content/size')
      ],
      [
        g.GET_APPSERVICE_DATA,
        c('/session/:sessionId/wechatdevtools/appservice/data')
      ],
      [
        g.GET_CURRENT_PAGE_STACK,
        c('/session/:sessionId/wechatdevtools/appservice/pagestack')
      ],
      [
        g.GET_CURRENT_PAGE_TITLE,
        c('/session/:sessionId/wechatdevtools/appservice/pagetitle')
      ],
      [
        g.GET_CURRENT_PAGE_QUERY,
        c('/session/:sessionId/wechatdevtools/appservice/pagequery')
      ],
      [
        g.GET_CURRENT_HTML,
        a('/session/:sessionId/wechatdevtools/currentwebview/html')
      ],
      [
        g.GET_SCREENSHOT,
        a('/session/:sessionId/wechatdevtools/currentwebview/screenshot')
      ],
      [g.REFRESH_TICKET, a('/session/:sessionId/wechatdevtools/refreshticket')],
      [g.COMPILE, a('/session/:sessionId/wechatdevtools/compile')],
      [
        g.GET_RUNTIME_INFO,
        c('/session/:sessionId/wechatdevtools/getruntimeinfo')
      ],
      [g.UPDATE_WECHATDEVTOOLS_PORT, c('/wechatdevtools/updateport/:port')]
    ])
  module.exports = {
    Name: g,
    Command: f,
    parse: function(a, b) {
      const c = function(c) {
        for (let d of c) {
          let c = d[0],
            e = d[1]
          if (e.method == a && e.regExp.test(b)) {
            let d = b.match(e.regExp),
              g = {}
            if (d)
              for (let a = 0, b = e.parameters.length; a < b; a++) {
                let b = e.parameters[a],
                  c = d[a + 1]
                if (!c) throw new Error('Missing required parameter: ' + b)
                g[b] = c
              }
            else if (0 < e.parameters.length)
              throw new Error('Missing required parameter')
            return new f(c, g, a, e.path)
          }
        }
      }
      return c(h) || c(i) || c(j)
    }
  }
})(require('lazyload'), require)
