(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else if(typeof exports === 'object')
		exports["Arca$Interop"] = factory();
	else
		root["Arca$Interop"] = factory();
})(self, function() {
return /******/ (function() { // webpackBootstrap
/******/ 	"use strict";
/******/ 	// The require scope
/******/ 	var __webpack_require__ = {};
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/define property getters */
/******/ 	!function() {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = function(exports, definition) {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	!function() {
/******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	!function() {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = function(exports) {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	}();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  "AnagSearchPagename": function() { return /* reexport */ AnagSearchPagename; },
  "CallWidgetAction": function() { return /* reexport */ CallWidgetAction; },
  "CallWidgetPostAction": function() { return /* reexport */ CallWidgetPostAction; },
  "CicloKind": function() { return /* reexport */ CicloKind; },
  "DocKind": function() { return /* reexport */ DocKind; },
  "DocState": function() { return /* reexport */ DocState; },
  "Event": function() { return /* reexport */ Events_namespaceObject; },
  "FormatUrlParams": function() { return /* reexport */ FormatUrlParams; },
  "GET": function() { return /* reexport */ GET; },
  "GOTO": function() { return /* reexport */ GOTO; },
  "InternalInteropResponse": function() { return /* reexport */ InternalInteropResponse; },
  "OverrideHandler": function() { return /* reexport */ OverrideHandler; },
  "POST": function() { return /* reexport */ POST; },
  "SearchPageVisibility": function() { return /* reexport */ SearchPageVisibility; },
  "SearchSectionEnum": function() { return /* reexport */ SearchSectionEnum; }
});

// NAMESPACE OBJECT: ./src/Events/index.ts
var Events_namespaceObject = {};
__webpack_require__.r(Events_namespaceObject);
__webpack_require__.d(Events_namespaceObject, {
  "Dispatch": function() { return Dispatch; },
  "Listen": function() { return Listen; }
});

;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}
;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/typeof.js
function _typeof(obj) {
  "@babel/helpers - typeof";

  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    _typeof = function _typeof(obj) {
      return typeof obj;
    };
  } else {
    _typeof = function _typeof(obj) {
      return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    };
  }

  return _typeof(obj);
}
;// CONCATENATED MODULE: ./src/Data/handler_commons.ts

function FormatUrlParams(urlParams) {
  if (!urlParams) return "";

  var f = function f(a) {
    switch (_typeof(a)) {
      case "string":
        return "\"".concat(a, "\"");

      case "boolean":
        return "".concat(a ? "true" : "false");

      case "object":
        if (a instanceof Date) {
          return "{^".concat(a.getFullYear(), "-").concat((a.getMonth() + 1).toString().padStart(2, "0"), "-").concat(a.getDate().toString().padStart(2, "0"), "}");
        }

    }

    return a;
  };

  return "?" + Object.keys(urlParams).filter(function (k) {
    return typeof urlParams[k] !== "undefined";
  }).map(function (k) {
    return "".concat(k, "=").concat(f(urlParams[k]));
  }).join("&");
}
function InternalInteropResponse(data, params) {
  window.postMessage(JSON.stringify({
    _call_id: params === null || params === void 0 ? void 0 : params._call_id,
    data: data
  }), "*");
}
;// CONCATENATED MODULE: ./src/Data/handler.prod.ts

function Handler(url, attrs, payload) {
  if (payload) return PostHandler(url, attrs, payload); // Fox intercetterà questa chiamata

  window.location.href = "arca://".concat(url).concat(FormatUrlParams(attrs));
}
function PostHandler(url, attrs, payload) {
  var form = document.createElement("form");
  form.style.display = "none";
  form.method = "post";
  form.enctype = "text/plain";
  form.action = "arca://".concat(url).concat(FormatUrlParams(attrs));
  var hiddenInput = document.createElement("input");
  hiddenInput.type = "hidden";
  hiddenInput.name = "data";
  hiddenInput.value = JSON.stringify(payload);
  form.appendChild(hiddenInput);
  document.body.appendChild(form);
  form.submit();
}
;// CONCATENATED MODULE: ./src/Data/index.ts


function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }


var Data_Handler = Handler;
var _call_id = 0;
function GET(url) {
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  var cb = arguments.length > 2 ? arguments[2] : undefined;
  params = _objectSpread(_objectSpread({}, params), {}, {
    _call_id: _call_id++
  });
  if (cb) return GET_Callback(url, params, cb);
  return GET_Promise(url, params);
}

function GET_Promise(url, params) {
  return new Promise(function (resolve) {
    manageResponseEvent(params._call_id, resolve);
    Data_Handler(url, params);
  });
}

function GET_Callback(url, params, cb) {
  if (cb) manageResponseEvent(params._call_id, cb);
  Data_Handler(url, params);
}

function POST(url, payload) {
  var params = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  var cb = arguments.length > 4 ? arguments[4] : undefined;
  params = _objectSpread(_objectSpread({}, params), {}, {
    _call_id: _call_id++
  });
  if (cb) return POST_Callback(url, params, payload, cb);
  return POST_Promise(url, params, payload);
}

function POST_Promise(url, params, payload) {
  return new Promise(function (resolve) {
    manageResponseEvent(params._call_id, resolve);
    Data_Handler(url, params, payload);
  });
}

function POST_Callback(url, params, payload, cb) {
  if (cb) manageResponseEvent(params._call_id, cb);
  Data_Handler(url, params, payload);
}

function GOTO(url) {
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  params = _objectSpread(_objectSpread({}, params), {}, {
    _call_id: _call_id++
  });
  GET_Callback(url, params, null);
}
function CallWidgetAction(actionName, param1, param2, param3, param4, param5) {
  return GET("Widget/Action/".concat(actionName), {
    param1: param1,
    param2: param2,
    param3: param3,
    param4: param4,
    param5: param5
  });
}
function CallWidgetPostAction(actionName, payload, param1, param2, param3, param4, param5) {
  return POST("Widget/PostAction/".concat(actionName), payload, {
    param1: param1,
    param2: param2,
    param3: param3,
    param4: param4,
    param5: param5
  });
}

function manageResponseEvent(_call_id, cb) {
  window.addEventListener("message", function (ev) {
    if (typeof ev.data !== "string" || !ev.data) return;

    try {
      var _payload = JSON.parse(ev.data);

      if (!_payload) return;

      if (_payload._call_id === _call_id) {
        window.removeEventListener("message", this);
        cb(_payload.data);
      }
    } catch (err) {
      console.warn("ARCA", "Received invalid payload", ev.data);
    }
  });
}

function OverrideHandler(handler) {
  Data_Handler = handler;
}

;// CONCATENATED MODULE: ./src/Events/index.ts
function Dispatch(event, parameters, targetFrameName) {
  var _document$querySelect;

  var target = targetFrameName ? typeof targetFrameName === "string" ? (_document$querySelect = document.querySelector("iframe[name=\"".concat(targetFrameName, "\"]"))) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.contentWindow : targetFrameName : window;
  target === null || target === void 0 ? void 0 : target.postMessage(JSON.stringify({
    event: event,
    parameters: parameters
  }), "*");
}
function Listen(event, cb, targetFrameName) {
  var _document$querySelect2;

  var target = targetFrameName ? typeof targetFrameName === "string" ? (_document$querySelect2 = document.querySelector("iframe[name=\"".concat(targetFrameName, "\"]"))) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.contentWindow : targetFrameName : window;
  if (!target) return null;
  target.addEventListener("message", manageListener);

  function manageListener(ev) {
    if (typeof ev.data !== "string" || !ev.data) return;

    try {
      var payload = JSON.parse(ev.data);
      if (!payload || typeof payload.event !== "string" || payload.event != event) return;
      cb(payload.parameters);
    } catch (err) {
      console.warn("ARCA", "Received invalid event payload", ev.data);
    }
  }

  function Stop() {
    target === null || target === void 0 ? void 0 : target.removeEventListener("message", manageListener);
  }

  return {
    Stop: Stop
  };
}
;// CONCATENATED MODULE: ./src/Interfaces/index.ts
var AnagSearchPagename;

(function (AnagSearchPagename) {
  AnagSearchPagename["Generale"] = "generale";
  AnagSearchPagename["Documenti"] = "documenti";
  AnagSearchPagename["Contabilita"] = "contabilita";
  AnagSearchPagename["Processi"] = "processi";
})(AnagSearchPagename || (AnagSearchPagename = {}));

var SearchSectionEnum;

(function (SearchSectionEnum) {
  SearchSectionEnum["Anagrafiche"] = "A";
  SearchSectionEnum["Menu"] = "M";
})(SearchSectionEnum || (SearchSectionEnum = {}));

var CicloKind;

(function (CicloKind) {
  CicloKind["CicloPassivo"] = "CP";
  CicloKind["CicloAttivo"] = "CA";
  CicloKind["AltriDocumenti"] = "AD";
})(CicloKind || (CicloKind = {}));

var DocKind;

(function (DocKind) {
  DocKind["Preventivo"] = "P";
  DocKind["Ordine"] = "O";
  DocKind["Bolla"] = "B";
  DocKind["Fattura"] = "F";
  DocKind["FatturaAccompagnatoria"] = "A";
  DocKind["NotaAccredito"] = "N";
  DocKind["ResoMerce"] = "M";
  DocKind["Rapportino"] = "D";
  DocKind["Generico"] = "G";
  DocKind["OrdineLavorazione"] = "L";
  DocKind["CaricoProduzione"] = "V";
  DocKind["TrasferimentoMerce"] = "T";
  DocKind["RettificaInventario"] = "R";
})(DocKind || (DocKind = {}));

var DocState;

(function (DocState) {
  DocState[DocState["DaInviare"] = 0] = "DaInviare";
  DocState[DocState["DaInviareOld"] = 1] = "DaInviareOld";
  DocState[DocState["Scartate"] = 2] = "Scartate";
  DocState[DocState["ScartateOld"] = 3] = "ScartateOld";
})(DocState || (DocState = {}));

var SearchPageVisibility;

(function (SearchPageVisibility) {
  SearchPageVisibility[SearchPageVisibility["Hidden"] = 0] = "Hidden";
  SearchPageVisibility[SearchPageVisibility["Visible"] = 1] = "Visible";
  SearchPageVisibility[SearchPageVisibility["Selected"] = 2] = "Selected";
})(SearchPageVisibility || (SearchPageVisibility = {}));
;// CONCATENATED MODULE: ./src/index.ts




/******/ 	return __webpack_exports__;
/******/ })()
;
});