function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,_toPropertyKey(i.key),i)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}var WidgetPrix=(()=>_createClass(function e(t,n,i,o){_classCallCheck(this,e),this.ref=t,this.width=n.width,this.height=n.height,this.numeroSerie=i,this.instanceMethodType=o},[{key:"getPrixFromLocalStorage",value:function(i){var o=this;return new Promise(function(t,e){var n=o;o.instanceMethodType.checkIfPrixExist(function(){n.instanceMethodType.readFile(n.instanceMethodType.pathPrix+"prix.json",function(e){t(JSON.parse(e.data)[i])})},function(){e()})})}},{key:"getWidgetPrixFromServer",value:function(){var n=this,r=this;return new Promise(function(i,o){var e="".concat(protocol,"://").concat(urlBase,"/").concat(subdomain,"/?page=getProvImageText"),t={provRef:n.ref,provWidth:n.width,provHeight:n.height,numeroSerie:n.numeroSerie};new Ajax(t,e,function(e){var t,n;e.startsWith("../")?(t="".concat(protocol,"://").concat(urlBase,"/").concat(e.split("../").pop()),r.downloadImageText(t),t=r.createImage(t),n=document.createElement("div"),r.assignStyleToDiv(n),n.appendChild(t),i(n)):o("Erreur lors de la récupération de l'image",e)},function(){o("Erreur lors de la récupération de l'image")},!1)})}},{key:"createImage",value:function(e){var t=document.createElement("img");return t.src=e,t.style.width="100%",t.style.height="100%",t}},{key:"assignStyleToDiv",value:function(e){Object.assign(e.style,{position:"absolute",bottom:"0",right:"0",top:"0",zIndex:"100",display:"flex",justifyContent:"center",width:"100%",height:"100%"})}},{key:"getPrixFromScreen",value:function(e){var e=this.createImage(e),t=document.createElement("div");return this.assignStyleToDiv(t),t.appendChild(e),t}},{key:"verifyIfImageIsInStorage",value:function(e){var i=this;return new Promise(function(t,n){i.instanceMethodType.checkIfFileExists(e,function(e){t(e)},function(e){n(e)})})}},{key:"downloadImageText",value:function(t){var n=this;this.verifyIfImageIsInStorage(t).then(function(e){!1===e&&(n.instanceMethodType.downloadFile(t,function(){}),n.saveInLocalStorage(t))}).catch(function(){n.instanceMethodType.downloadFile(t),n.saveInLocalStorage(t)})}},{key:"saveInLocalStorage",value:function(e){var t=this,n=e.split("/").pop(),i=this.ref;this.instanceMethodType.createDirectory("prix"),this.instanceMethodType.checkIfPrixExist(function(){t.instanceMethodType.readFile(t.instanceMethodType.pathPrix+"prix.json",function(e){e=JSON.parse(e.data);e[i]=n,t.instanceMethodType.writeFile(t.instanceMethodType.pathPrix+"prix.json",JSON.stringify(e),function(){})})},function(){var e=JSON.stringify(_defineProperty({},i,n));t.instanceMethodType.writeFile(t.instanceMethodType.pathPrix+"prix.json",e,function(){console.log("SUCCESS WRITE FILE")})})}}],[{key:"deletePrixFromLocalStorage",value:function(e){e.checkIfPrixExist(function(){e.removeSpecificFileInStorage(e.pathPrix+"prix.json",function(){new Media(e).screenInitializedDownloadMedia(localStorage.getItem("shortLink"))})},function(){})}}]))();