"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("uuid"),r=require("lodash"),n=require("./clientStorage/index.js"),o=require("./jsonApi/index.js"),i=require("./subscriptions.js"),u=require("./api/apiCore.js"),c=require("./constants.js"),a=require("./corvaUrls.js"),p=require("./sso/index.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=s(e);function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){l.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var f={get:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u.get(e,t,r)},getWithHeaders:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u.getWithHeaders(e,t,r)},put:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return u.put(e,t,r,n)},patch:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return u.patch(e,t,r,n)},post:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u.post(e,t,r)},del:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u.del(e,t,r)}},g={get:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u.get(e,t,v({apiUrl:c.CORVA_API_URLS.DATA_API},r))},put:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return u.put(e,t,r,v({apiUrl:c.CORVA_API_URLS.DATA_API},n))},patch:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return u.patch(e,t,r,v({apiUrl:c.CORVA_API_URLS.DATA_API},n))},post:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u.post(e,t,v({apiUrl:c.CORVA_API_URLS.DATA_API},r))},del:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u.del(e,t,v({apiUrl:c.CORVA_API_URLS.DATA_API},r))}};function h(){if(window.xprops){var e,r,n,o,i,u=(null===(e=window.xprops)||void 0===e||null===(r=e.app)||void 0===r||null===(n=r.app)||void 0===n?void 0:n.id)||"unknown-app-id",c=(null===(o=window.xprops)||void 0===o||null===(i=o.app)||void 0===i?void 0:i.id)||"unknown-instance-id";return"".concat(u,":").concat(c,":").concat(t.v4())}return"non-dc-app:".concat(t.v4())}var A={subscribe:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.onDataReceive,o=void 0===n?r.noop:n,i=window[Symbol.for("socket")]||{},u=i.subscribe,c=i.unsubscribe,a=i.socket;if(!a)return console.error("Socket is not initialized!"),r.noop;var p=h(),s=v(v({},e),{},{collection:e.collection||e.dataset,appInstanceId:p});return u(s),a.on("data",(function(e){return e.appInstanceId===p&&o(e)})),function(){return c(s)}}};exports.clientStorage=n,exports.jsonApi=o,exports.subscriptions=i,exports.corvaUrls=a,exports.sso=p,exports.corvaAPI=f,exports.corvaDataAPI=g,exports.socketClient=A;
