UNPKG

webcom

Version:

Webcom library

17 lines 51.5 kB
/*! * Webcom. Build realtime apps. Share and sync data instantly between your clients * * Module name: Webcom * Version: 3.8.0 * Created: 2025-06-26T13:38:14.068Z * * Copyright (C) <2015-2025> Orange * * This software is confidential and proprietary information of Orange. * You shall not disclose such Confidential Information and shall use it only in * accordance with the terms of the agreement you entered into. * Unauthorized copying of this file, via any medium is strictly prohibited. * * If you are Orange employee you shall use this software in accordance with * the Orange Source Charter (http://opensource.itn.ftgroup/index.php/Orange_Source_Charter) */(()=>{var t={228:t=>{t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r},t.exports.__esModule=!0,t.exports.default=t.exports},858:t=>{t.exports=function(t){if(Array.isArray(t))return t},t.exports.__esModule=!0,t.exports.default=t.exports},646:(t,e,n)=>{var r=n(228);t.exports=function(t){if(Array.isArray(t))return r(t)},t.exports.__esModule=!0,t.exports.default=t.exports},575:t=>{t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},100:(t,e,n)=>{var r=n(489),o=n(67);function i(e,n,s){return o()?(t.exports=i=Reflect.construct,t.exports.__esModule=!0,t.exports.default=t.exports):(t.exports=i=function(t,e,n){var o=[null];o.push.apply(o,e);var i=new(Function.bind.apply(t,o));return n&&r(i,n.prototype),i},t.exports.__esModule=!0,t.exports.default=t.exports),i.apply(null,arguments)}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports},913:t=>{function e(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports},67:t=>{t.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}},t.exports.__esModule=!0,t.exports.default=t.exports},860:t=>{t.exports=function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)},t.exports.__esModule=!0,t.exports.default=t.exports},884:t=>{t.exports=function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i=[],s=!0,a=!1;try{for(n=n.call(t);!(s=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);s=!0);}catch(t){a=!0,o=t}finally{try{s||null==n.return||n.return()}finally{if(a)throw o}}return i}},t.exports.__esModule=!0,t.exports.default=t.exports},521:t=>{t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.__esModule=!0,t.exports.default=t.exports},206:t=>{t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.__esModule=!0,t.exports.default=t.exports},489:t=>{function e(n,r){return t.exports=e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},t.exports.__esModule=!0,t.exports.default=t.exports,e(n,r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},38:(t,e,n)=>{var r=n(858),o=n(884),i=n(379),s=n(521);t.exports=function(t,e){return r(t)||o(t,e)||i(t,e)||s()},t.exports.__esModule=!0,t.exports.default=t.exports},319:(t,e,n)=>{var r=n(646),o=n(860),i=n(379),s=n(206);t.exports=function(t){return r(t)||o(t)||i(t)||s()},t.exports.__esModule=!0,t.exports.default=t.exports},8:t=>{function e(n){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},379:(t,e,n)=>{var r=n(228);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}},t.exports.__esModule=!0,t.exports.default=t.exports},722:(t,e,n)=>{"use strict";n.d(e,{Yk:()=>j,ab:()=>J,hu:()=>Y,ZP:()=>z});var r=n(319),o=n.n(r),i=n(575),s=n.n(i),a=n(913),u=n.n(a),c=n(38),h=n.n(c),f=n(24),l=n(28),d=n(303),p="console",v=l.sZ.console,y=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i=function(t){return(0,d.Kn)(t)?JSON.stringify(t):(t||"undefined").toString()};if((0,d.HD)(t)){var s=0;return[t=t.replace(/%(.)/g,(function(t,e){switch(e){case"%":return"%";case"s":case"o":case"O":return i(n[s++]);case"d":case"i":case"f":return n[s++];default:return t}}))].concat(o()(n.slice(s).map(i))).join(" ")}return[t].concat(n).map(i).join(" ")};function g(t,e,n,r,o){if(!n||!r||!o){var i=e,s=function(t){return function(e){return i("[".concat(t,"] ").concat(e))}};n=n||s("INFO"),r=r||s("WARN"),o=o||s("ERR!"),e=s("LOG ")}return{log:function(){return e.call(t,y.apply(void 0,arguments))},info:function(){return n.call(t,y.apply(void 0,arguments))},warn:function(){return r.call(t,y.apply(void 0,arguments))},error:function(){return o.call(t,y.apply(void 0,arguments))}}}if((0,d.mf)(v))v=g(f.Z,v);else if((0,d.Kn)(v)&&v){var _=v,m=_.log,b=_.info,w=_.warn,k=_.error;v=g(v,m,b,w,k)}else{var x=function(t,e,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),i=3;i<r;i++)o[i-3]=arguments[i];(0,d.HD)(n)?(n="[".concat(t,"] ")+n,e.apply(void 0,[n].concat(o))):e.apply(void 0,["[".concat(t,"] "),n].concat(o))};v={log:x.bind(void 0,"LOG ",f.Z.console.log),info:x.bind(void 0,"INFO",f.Z.console.info),warn:x.bind(void 0,"WARN",f.Z.console.warn),error:x.bind(void 0,"ERR!",f.Z.console.error)}}(0,l.x$)(p,(function(){return v}),(function(t){return v=t}));var S=n(857),A=n(455),O={};function R(t,e){var n=t.length;return n>=e?t.substring(0,e):t+j.substring(0,e-n)}function T(t){return t.map((function(t){return(0,d.mf)(t)?t():t}))}var P=function(){function t(e,n,r,o){s()(this,t),this._fqdn=e,this._prefix=n;var i=e.join(".");this._count=void 0===O[i]?O[i]=0:++O[i],this.displayTimestamp=r,this.setPrefixWidth(o||8),this._log=this._emitLog.bind(this,v.log),this._info=this._emitLog.bind(this,v.info),this._warn=this._emitLog.bind(this,v.warn),this._error=this._emitLog.bind(this,v.error),this._enabled=!0}return u()(t,[{key:"fqdn",get:function(){return this._fqdn}},{key:"_emitLog",value:function(t,e){var n=this.displayTimestamp?[(new Date).toISOString()]:[];n.push(this._displayedPrefix);for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];(0,d.HD)(e)?(n.push(e),e=n.join(" "),t.apply(void 0,[e].concat(o()(T(i))))):t.apply(void 0,n.concat(o()(T([e].concat(i)))))}},{key:"setPrefixWidth",value:function(t){this._displayedPrefix="".concat(R(this._prefix,t)," #").concat(R(this._count.toString(),3))}},{key:"setLevel",value:function(t){this._enabled=t>=0,this.log=t>=z.LOG?this._log:A.ZT,this.info=t>=z.INFO?this._info:A.ZT,this.warn=t>=z.WARN?this._warn:A.ZT,this.error=t>=z.ERROR?this._error:A.ZT}},{key:"updateLevel",value:function(t){this._enabled&&this.setLevel(t)}}]),t}(),j=" ",E=!1,C=15,I=[],Z={},H={},D={},N="_leaf_";function L(t){return t?t.split("."):[]}function U(t){return{disabledDepth:W(t,D),enabledDepth:W(t,H)}}function F(t,e,n,r){for(var o=0;o<t.length;){var i=t[o++];e.hasOwnProperty(i)||(e[i]={}),e=e[i]}r&&Object.keys(e).forEach((function(t){return delete e[t]})),e._leaf_=n}function M(t,e){for(var n=0;n<t.length;){var r=t[n++];if(!e.hasOwnProperty(r))return;e=e[r]}delete e._leaf_}function W(t,e){var n=-1,r=0;do{e.hasOwnProperty(N)&&(n=r)}while(r<t.length&&(e=e[t[r++]]));return n}function q(t,e){Object.entries(t||{}).forEach((function(t){var n=h()(t,2),r=n[0],o=n[1];r===N?e(o):q(o,e)}))}function K(t,e){for(var n=[],r=0;e&&r<t.length;)e=e[t[r++]];return q(e,(function(t){return n.push(t)})),n}function B(t){E=t,I.forEach((function(t){return t.displayTimestamp=E}))}var J="LogManager",z=function(){function t(){s()(this,t)}return u()(t,null,[{key:"enable",value:function(e){(0,S.T2)([J,".enable"],arguments,(0,S.jt)(S.Z_));var n=L(e),r=U(n),o=r.enabledDepth,i=r.disabledDepth;o<=i&&(i<0&&t.disable(),F(n,H,!0,!0),M(n,D),K(n,Z).forEach((function(t){return t.setLevel(G)})))}},{key:"disable",value:function(t){(0,S.T2)([J,".disable"],arguments,(0,S.jt)(S.Z_));var e=L(t),n=U(e),r=n.enabledDepth,o=n.disabledDepth;o<=r&&(F(e,D,!0,!0),M(e,H),K(e,Z).forEach((function(t){return t.setLevel(-1)})))}},{key:"showTimestamp",value:function(){(0,S.T2)([J,".showTimestamp"],arguments),B(!0)}},{key:"hideTimestamp",value:function(){(0,S.T2)([J,".hideTimestamp"],arguments),B(!1)}},{key:"setPrefixWidth",value:function(t){(0,S.T2)([J,".setPrefixWidth"],arguments,S.Dp),t<0?t=0:t>j.length&&(t=j.length),C=t,I.forEach((function(t){return t.setPrefixWidth(C)}))}},{key:"level",get:function(){return G},set:function(t){(0,S.T2)([J,".level"],arguments,S.Dp),t>-1&&t!==G&&(I.forEach((function(e){return e.updateLevel(t)})),G=t)}},{key:"LOG",get:function(){return 4}},{key:"INFO",get:function(){return 3}},{key:"WARN",get:function(){return 2}},{key:"ERROR",get:function(){return 1}},{key:"NONE",get:function(){return 0}},{key:"debugOnCallback",value:function(t){var e=t&&t.toUpperCase();return function(t,n){return v.log("********** UPDATE ".concat(e||t.ref().pathString()," **********"),t.toString(),n?"[<<".concat(n,"]"):"")}}},{key:"debugOnCompletionCallback",value:function(t,e){var n=t&&t.toUpperCase();return function(t){return t?v.log("********** REVOKED ".concat(n," **********"),t):v.log("********** COMPLETED ".concat(n," **********")),e}}},{key:"debugOnCallbackWithCancel",value:function(e){var n=e&&e.toUpperCase();return[t.debugOnCallback(e),function(t){return v.log.apply(v,["********** COMPLETE ".concat(n," **********")].concat(o()(t?["FAILED:",t.code,t.message]:["cancelled"])))}]}}]),t}();function Y(t,e){var n=L(t),r=new P(n,e||n[n.length-1],E,C);return function(t){var e=t.fqdn;F(e,Z,t),I.push(t);var n=U(e),r=n.disabledDepth,o=n.enabledDepth;t.setLevel(o>=r?G:-1)}(r),r}var G=z.INFO},466:(t,e,n)=>{"use strict";n.d(e,{DV:()=>h,RY:()=>f});n(24);var r=n(28),o="browser",i="mobile/",s="node",a="".concat(i,"android"),u="".concat(i,"iOS"),c={browser:"b"};c[a]="a",c[u]="i",c.node="n";var h,f=!0,l="device",d=r.sZ.device;d||p(s);function p(t){d=t,f=t===o,0===t.indexOf(i),h=(c[t]||"")+"3.8.0"}(0,r.x$)(l,(function(){return d}),(function(t){return p(t)}))},28:(t,e,n)=>{"use strict";n.d(e,{HO:()=>o,sZ:()=>r,x$:()=>i});var r=n(24).Z.WebcomDependencies||{},o={};function i(t,e,n){Object.defineProperty(o,t,{enumerable:!0,get:e,set:n})}},618:(t,e,n)=>{"use strict";n.d(e,{Zi:()=>h,cv:()=>l,iK:()=>s});var r=n(24),o=n(28),i="setTimeout",s=o.sZ.setTimeout;s||(s=r.Z.setTimeout),(0,o.x$)(i,(function(){return s}),(function(t){return s=t})),r.Z.setTimeout||(r.Z.setTimeout=s),r.Z.setImmediate||(r.Z.setImmediate=s);var a="clearTimeout",u=o.sZ.clearTimeout;u||(u=r.Z.clearTimeout),(0,o.x$)(a,(function(){return u}),(function(t){return u=t})),r.Z.clearTimeout||(r.Z.clearTimeout=u),r.Z.clearImmediate||(r.Z.clearImmediate=u);var c="setInterval",h=o.sZ.setInterval;h||(h=r.Z.setInterval),(0,o.x$)(c,(function(){return h}),(function(t){return h=t}));var f="clearInterval",l=o.sZ.clearInterval;l||(l=r.Z.clearInterval),(0,o.x$)(f,(function(){return l}),(function(t){return l=t}))},286:(t,e,n)=>{"use strict";n.d(e,{h:()=>S});var r=n(38),o=n.n(r),i=n(575),s=n.n(i),a=n(913),u=n.n(a),c=n(28),h="env",f=c.sZ.env;f||(f=process.env),(0,c.x$)(h,(function(){return f}),(function(t){return f=t}));var l,d,p,v,y=(0,n(722).hu)("network.nodeProxy");function g(t){try{return new URL(t)}catch(t){return null}}!function(){if(l=g(f.http_proxy||f.HTTP_PROXY),d=g(f.https_proxy||f.HTTPS_PROXY),p=f.no_proxy||f.NO_PROXY,y.log("Node.js proxy layer set to: http_proxy='".concat(l,"'; https_proxy='").concat(d,"'; no_proxy=").concat(p)),p){var t=p.split(",");v=t.indexOf("*")<0?function(e){return t.every((function(t){return!e.origin.endsWith(t)}))}:function(){return!1}}else v=function(){return!0}}();const _=require("http");var m=n.n(_);const b=require("https");var w=n.n(b),k=n(303),x=n(857),S=function(){function t(){s()(this,t),this.readyState=0,this._headers={},this.status=0}return u()(t,[{key:"open",value:function(t,e){this._method=t,this._href=e}},{key:"setRequestHeader",value:function(t,e){this._headers[t]=e}},{key:"send",value:function(t){(0,k.mf)(this.onreadystatechange)||(0,x._y)("NodeXmlHttpRequest","missing onreadystatechange event handler"),t&&(t=Buffer.from(t),this._headers["Content-Length"]=t.length),O.call(this,t)}},{key:"getAllResponseHeaders",value:function(){return Object.entries(this._headers).reduce((function(t,e){var n=o()(e,2),r=n[0],i=n[1];return"".concat(t,"\n").concat(r,": ").concat(i)}),"")}}],[{key:"DONE",get:function(){return 4}}]),t}();function A(t){this.responseText=t.message,this._headers={},this.readyState=4,this.onreadystatechange()}function O(t){var e=this,n=function(t){var e=new URL(t);switch(e.protocol){case"http:":case"ws:":return l&&v(e)?{url:e,secure:!1,proxy:l}:{url:e,secure:!1};case"https:":case"wss:":return d&&v(e)?{url:e,secure:!0,proxy:d}:{url:e,secure:!0};default:return{url:e,secure:!1}}}(this._href),r=n.url,o=n.secure,i=n.proxy;if(i)if(o){var s=r.hostname+":443",a=m().request({protocol:i.protocol,hostname:i.hostname,port:i.port,method:"CONNECT",path:s});a.on("connect",(function(n,o){if(200===n.statusCode){var i=w().request({host:r.host,path:r.pathname+r.search+r.hash,method:e._method,agent:new(w().Agent)({socket:o})});R.call(e,i,t)}else A.call(e,new Error("Status ".concat(n.statusCode)))})),a.on("error",A.bind(this)),a.setHeader("Host",s),a.end()}else{var u=m().request({protocol:i.protocol,hostname:i.hostname,port:i.port,method:this._method,path:r.href});u.setHeader("Host",r.host),R.call(this,u,t)}else{var c=(o?w():m()).request({protocol:r.protocol,hostname:r.hostname,port:r.port,method:this._method,path:r.pathname+r.search+r.hash});c.setHeader("Host",r.host),R.call(this,c,t)}}function R(t,e){var n=this;Object.entries(this._headers).forEach((function(e){var n=o()(e,2),r=n[0],i=n[1];return t.setHeader(r,i)})),e&&t.write(e),t.on("error",A.bind(this)),t.on("response",(function(t){var r=[];t.on("data",(function(t){return r.push(t)})),t.on("error",A.bind(n)),t.on("end",(function(){n.status=t.statusCode;var o=[301,302,303,307,308].includes(n.status)&&t.headers.location;o?(n._href=o,O.call(n,e)):(n.readyState=4,n.responseText=Buffer.concat(r).toString("utf8"),n._headers=t.headers,n.onreadystatechange())}))})),t.end()}},730:(t,e)=>{"use strict";var n,r={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};r.bitArray={bitSlice:function(t,e,n){return t=r.bitArray._shiftRight(t.slice(e/32),32-(31&e)).slice(1),void 0===n?t:r.bitArray.clamp(t,n-e)},extract:function(t,e,n){var r=Math.floor(-e-n&31);return(-32&(e+n-1^e)?t[e/32|0]<<32-r^t[e/32+1|0]>>>r:t[e/32|0]>>>r)&(1<<n)-1},concat:function(t,e){if(0===t.length||0===e.length)return t.concat(e);var n=t[t.length-1],o=r.bitArray.getPartial(n);return 32===o?t.concat(e):r.bitArray._shiftRight(e,o,0|n,t.slice(0,t.length-1))},bitLength:function(t){var e,n=t.length;return 0===n?0:(e=t[n-1],32*(n-1)+r.bitArray.getPartial(e))},clamp:function(t,e){if(32*t.length<e)return t;var n=(t=t.slice(0,Math.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=r.bitArray.partial(e,t[n-1]&2147483648>>e-1,1)),t},partial:function(t,e,n){return 32===t?e:(n?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(r.bitArray.bitLength(t)!==r.bitArray.bitLength(e))return!1;var n,o=0;for(n=0;n<t.length;n++)o|=t[n]^e[n];return 0===o},_shiftRight:function(t,e,n,o){var i,s,a;for(void 0===o&&(o=[]);e>=32;e-=32)o.push(n),n=0;if(0===e)return o.concat(t);for(i=0;i<t.length;i++)o.push(n|t[i]>>>e),n=t[i]<<32-e;return s=t.length?t[t.length-1]:0,a=r.bitArray.getPartial(s),o.push(r.bitArray.partial(e+a&31,e+a>32?n:o.pop(),1)),o},_xor4:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]},byteswapM:function(t){var e,n;for(e=0;e<t.length;++e)n=t[e],t[e]=n>>>24|n>>>8&65280|(65280&n)<<8|n<<24;return t}},r.codec.utf8String={fromBits:function(t){var e,n,o="",i=r.bitArray.bitLength(t);for(e=0;e<i/8;e++)0==(3&e)&&(n=t[e/4]),o+=String.fromCharCode(n>>>8>>>8>>>8),n<<=8;return decodeURIComponent(escape(o))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,n=[],o=0;for(e=0;e<t.length;e++)o=o<<8|t.charCodeAt(e),3==(3&e)&&(n.push(o),o=0);return 3&e&&n.push(r.bitArray.partial(8*(3&e),o)),n}},r.codec.base64={_chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,n){var o,i="",s=0,a=r.codec.base64._chars,u=0,c=r.bitArray.bitLength(t);for(n&&(a=a.substr(0,62)+"-_"),o=0;6*i.length<c;)i+=a.charAt((u^t[o]>>>s)>>>26),s<6?(u=t[o]<<6-s,s+=26,o++):(u<<=6,s-=6);for(;3&i.length&&!e;)i+="=";return i},toBits:function(t,e){t=t.replace(/\s|=/g,"");var n,o,i=[],s=0,a=r.codec.base64._chars,u=0;for(e&&(a=a.substr(0,62)+"-_"),n=0;n<t.length;n++){if((o=a.indexOf(t.charAt(n)))<0)throw new r.exception.invalid("this isn't base64!");s>26?(s-=26,i.push(u^o>>>s),u=o<<32-s):u^=o<<32-(s+=6)}return 56&s&&i.push(r.bitArray.partial(56&s,u,1)),i}},r.codec.base64url={fromBits:function(t){return r.codec.base64.fromBits(t,1,1)},toBits:function(t){return r.codec.base64.toBits(t,1)}},r.hash.sha256=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},r.hash.sha256.hash=function(t){return(new r.hash.sha256).update(t).finalize()},r.hash.sha256.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=r.codec.utf8String.toBits(t));var e,n=this._buffer=r.bitArray.concat(this._buffer,t),o=this._length,i=this._length=o+r.bitArray.bitLength(t);if(i>9007199254740991)throw new r.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var s=new Uint32Array(n),a=0;for(e=512+o-(512+o&511);e<=i;e+=512)this._block(s.subarray(16*a,16*(a+1))),a+=1;n.splice(0,16*a)}else for(e=512+o-(512+o&511);e<=i;e+=512)this._block(n.splice(0,16));return this},finalize:function(){var t,e=this._buffer,n=this._h;for(t=(e=r.bitArray.concat(e,[r.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),n},_init:[],_key:[],_precompute:function(){var t,e,n=0,r=2;function o(t){return 4294967296*(t-Math.floor(t))|0}for(;n<64;r++){for(e=!0,t=2;t*t<=r;t++)if(r%t==0){e=!1;break}e&&(n<8&&(this._init[n]=o(Math.pow(r,.5))),this._key[n]=o(Math.pow(r,1/3)),n++)}},_block:function(t){var e,n,r,o,i=this._h,s=this._key,a=i[0],u=i[1],c=i[2],h=i[3],f=i[4],l=i[5],d=i[6],p=i[7];for(e=0;e<64;e++)e<16?n=t[e]:(r=t[e+1&15],o=t[e+14&15],n=t[15&e]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(o>>>17^o>>>19^o>>>10^o<<15^o<<13)+t[15&e]+t[e+9&15]|0),n=n+p+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(d^f&(l^d))+s[e],p=d,d=l,l=f,f=h+n|0,h=c,c=u,a=n+((u=a)&c^h&(u^c))+(u>>>2^u>>>13^u>>>22^u<<30^u<<19^u<<10)|0;i[0]=i[0]+a|0,i[1]=i[1]+u|0,i[2]=i[2]+c|0,i[3]=i[3]+h|0,i[4]=i[4]+f|0,i[5]=i[5]+l|0,i[6]=i[6]+d|0,i[7]=i[7]+p|0}},r.hash.sha1=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},r.hash.sha1.hash=function(t){return(new r.hash.sha1).update(t).finalize()},r.hash.sha1.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=r.codec.utf8String.toBits(t));var e,n=this._buffer=r.bitArray.concat(this._buffer,t),o=this._length,i=this._length=o+r.bitArray.bitLength(t);if(i>9007199254740991)throw new r.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var s=new Uint32Array(n),a=0;for(e=this.blockSize+o-(this.blockSize+o&this.blockSize-1);e<=i;e+=this.blockSize)this._block(s.subarray(16*a,16*(a+1))),a+=1;n.splice(0,16*a)}else for(e=this.blockSize+o-(this.blockSize+o&this.blockSize-1);e<=i;e+=this.blockSize)this._block(n.splice(0,16));return this},finalize:function(){var t,e=this._buffer,n=this._h;for(t=(e=r.bitArray.concat(e,[r.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),n},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(t,e,n,r){return t<=19?e&n|~e&r:t<=39?e^n^r:t<=59?e&n|e&r|n&r:t<=79?e^n^r:void 0},_S:function(t,e){return e<<t|e>>>32-t},_block:function(t){var e,n,r,o,i,s,a,u,c=this._h;if("undefined"!=typeof Uint32Array){u=Array(80);for(var h=0;h<16;h++)u[h]=t[h]}else u=t;for(r=c[0],o=c[1],i=c[2],s=c[3],a=c[4],e=0;e<=79;e++)e>=16&&(u[e]=this._S(1,u[e-3]^u[e-8]^u[e-14]^u[e-16])),n=this._S(5,r)+this._f(e,o,i,s)+a+u[e]+this._key[Math.floor(e/20)]|0,a=s,s=i,i=this._S(30,o),o=r,r=n;c[0]=c[0]+r|0,c[1]=c[1]+o|0,c[2]=c[2]+i|0,c[3]=c[3]+s|0,c[4]=c[4]+a|0}},t.exports&&(t.exports=r),void 0===(n=function(){return r}.apply(e,[]))||(t.exports=n)},455:(t,e,n)=>{"use strict";n.d(e,{ZT:()=>r});n(618);var r=Function.prototype},24:(t,e,n)=>{"use strict";n.d(e,{Z:()=>r});var r=function(){if("undefined"!=typeof globalThis)return globalThis;return global}()},303:(t,e,n)=>{"use strict";n.d(e,{HD:()=>s,Kn:()=>c,hj:()=>a,lk:()=>h,mf:()=>u});var r=n(8),o=n.n(r),i=n(466);function s(t){return"string"==typeof t}function a(t){return"number"==typeof t}function u(t){return"function"==typeof t}function c(t){return"object"===o()(t)}function h(){return i.RY&&(window.navigator.userAgent.match(/CriOS|Twitter for iPhone|FBAN\/FBIOS|Windows Phone/)||window.navigator.standalone)}},857:(t,e,n)=>{"use strict";n.d(e,{Dp:()=>x,O7:()=>k,Ry:()=>S,T2:()=>d,Yl:()=>w,Z_:()=>b,__:()=>y,_y:()=>l,hu:()=>c,jt:()=>v,l4:()=>g,sR:()=>m,wB:()=>R,wE:()=>A});var r=n(8),o=n.n(r),i=n(319),s=n.n(i),a=n(303),u="Webcom internal error";function c(t,e){t||l(u,e)}var h={values:[]};function f(t,e){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];Object.assign(h,{method:t,args:e||[],checkers:r})}var l=function(t,e){var n;throw new Error("".concat((n="").concat.apply(n,s()(t)),": ").concat(e))};function d(t,e){if(!h.method){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];f.apply(void 0,[t,e].concat(r))}var i=h.method,s=h.args,a=h.checkers,u=h.values;Object.assign(h,{method:void 0,args:void 0,checkers:void 0,values:[]}),s.length>a.length&&l(i,"too many arguments, ".concat(s.length," instead of ").concat(a.length)),a.forEach((function(t,e){return p(t,s[e],i,(function(t){return"argument #".concat(e+1," ").concat(t)}))})),u.forEach((function(t){var e=t.name,n=t.value;return p(t.checker,n,i,(function(t){return"".concat(e," ").concat(t)}))}))}function p(t,e,n,r){var o=t(e);o&&l(n,r(o))}function v(t){return function(e){return _("undefined")(e)&&t&&t(e)}}var y=function(t){return void 0===t?"is missing":""};function g(t){return function(e){return!(e instanceof t)&&"must be an instance of ".concat(t.name)}}function _(t){return function(e){return o()(e)!==t&&"must be a ".concat(t)}}var m=_("undefined"),b=_("string"),w=_("function"),k=_("boolean"),x=O(Number.isFinite,"must be a finite number"),S=_("object");function A(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return function(t){return e.every((function(e){return e(t)}))&&"either ".concat(e.map((function(e){return e(t)})).join(" or "))}}function O(t,e){return function(n){return!t(n)&&(e||"is not valid")}}O((function(t){return(0,a.hj)(t)&&Math.floor(t)===t}),"must be an integer");function R(t,e){return O((function(e){return t.test(e)}),e)}},113:t=>{"use strict";t.exports=require("crypto")},147:t=>{"use strict";t.exports=require("fs")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var r={};(()=>{"use strict";n.d(r,{default:()=>w});var t=n(24),e=n(575),o=n.n(e),i=n(913),s=n.n(i),a=n(38),u=n.n(a),c=n(857),h=n(722),f=n(303),l="WebcomApp",d=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o()(this,t),(0,c.T2)(["new ",l],arguments,(0,c.wB)(/^[a-z0-9](?:[-a-z0-9]{0,38}[a-z0-9])?$/),(0,c.jt)((0,c.wE)(c.Ry,c.Z_))),this._logger=(0,h.hu)("api.WebcomApp",l),this._services={},this.appId=e,this.config={},(0,f.HD)(n)&&(n=Object.keys(y).reduce((function(t,e){return t[e]={baseUrl:n},t}),{})),this._fillConfig(n),this._logger.log("Initialized %s with options %s",e,JSON.stringify(this.config))}return s()(t,[{key:"dispose",value:function(){(0,c.T2)([l,"#dispose"],arguments),Object.values(this._services).forEach((function(t){return t._dispose()})),this._services={}}},{key:"_fillConfig",value:function(t){p.call(this,t,y)}},{key:"toString",value:function(){return"".concat(this.appId,"{").concat(Object.keys(this._services).join(","),"}")}}]),t}();function p(t,e){var n=this;!function t(e,r,o,i){var s=function(t){return"".concat(l,".Configuration.").concat(i.concat(t).join("."))};r=Object.assign({},r),Object.entries(o).forEach((function(o){var a=u()(o,2),h=a[0],f=a[1];if(f instanceof Object&&!(f instanceof Array))e[h]=e[h]||{},t(e[h],r[h]||{},f,i.concat(h));else{var l=r[h],d=f[1]||function(t){return t};try{e[h]=d(void 0===l?void 0===e[h]?f.length?f[0]:f:e[h]:l)}catch(t){var p=s(h);void 0===t.value?(0,c._y)(p,t.message):(n._logger.warn("%s: %s",p,t.message),e[h]=t.value)}}delete r[h]})),Object.keys(r).forEach((function(t){return n._logger.warn("%s: unknown config key",s(t))}))}(this.config,t,e,[])}function v(t,e,n){return"".concat(n.key,":").concat(e,":").concat(function(t,e){var n=e.baseUrl;return"/".concat(n.protocol.slice(0,-1),"/").concat(n.host,"/").concat(t.appId,"/")}(t,n))}var y={},g=n(28),_="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",m=_.length;var b="Webcom",w=function(){function t(){o()(this,t),this._init.apply(this,arguments)}return s()(t,[{key:"_init",value:function(){(0,c._y)(["new ",b],"this static class cannot be instantiated")}}],[{key:"SDK_VERSION",get:function(){return"3.8.0"}},{key:"Log",get:function(){return h.ZP}},{key:"App",value:function(t,e){return new d(t,e)}},{key:"getUniqueKeyDate",value:function(t){return new Date(function(t){for(var e=t.substring(0,8),n=0,r=0;r<8;++r)n=n*m+_.indexOf(e[r]);return n}(t))}},{key:"dependencies",get:function(){return g.HO}}]),t}(),k=(0,h.hu)("api.Webcom",b),x=n(319),S=n.n(x),A=n(466);function O(t){"http:"===t.protocol&&A.RY&&"https:"===window.location.protocol&&this._logger.warn("Insecure access to a Webcom service from a secure page. Please setup your service with an https protocol.")}var R=new RegExp("^(?:([^:]+:)//)?(?:[^/@]+@)?([^/:]+(?::\\d+)?)(?:/.*)?$"),T="io.datasync.orange.com";function P(t,e){return function(n){var r=t(n);if(r)throw new Error(r);return e?e(n):n}}n(8);function j(t,e,n,r){return C(t,e,{value:n},r)}function E(t,e,n,r){return C(t,e,{get:n},r)}function C(t,e,n,r){return Object.defineProperty(t,e,Object.assign(n,{enumerable:r,configurable:!0}))}var I="some",Z="required",H="none",D=function(){function t(e,n){o()(this,t),(0,c.hu)(e===I||e===Z||e===H,"Wrong state value for a new State object: expecting 'some', 'required' or 'none'."),this.state=e,(0,c.hu)(e!==I||n&&n.webcomAuthToken,"Missing details or webcomAuthToken for a new 'some' State"),this.details=n}return s()(t,[{key:"isUnauthenticated",value:function(){return this.state===H}},{key:"isAuthenticated",value:function(){return this.state===I}},{key:"isRequired",value:function(){return this.state===Z}},{key:"isSameAs",value:function(t){return this.state===t.state&&(this.state!==I||this.details.webcomAuthToken===t.details.webcomAuthToken)}}]),t}(),N=new D(H),L=(new D(Z),function(t){return new D(I,t)});var U,F,M,W,q="Authentication";function K(t){switch((0,c.T2)([b,".avatarURL"],arguments,c.Ry),t&&t.provider){case"facebook":return"https://graph.facebook.com/".concat(t.providerUid,"/picture?type=large");case"github":return t.providerProfile.avatar_url;case"gitlab":case"google":return t.providerProfile.picture}}y.Authentication={from:[void 0,P((0,c.jt)((0,c.l4)(d)))],baseUrl:[null,function(e){if(e&&(t.Z.URL&&e instanceof URL||e.href&&e.protocol&&e.host))return e;var n=e?R.exec(e):[T,void 0,T];if(n){var r=u()(n,3),o=r[0],i=r[1],s=r[2];return i||(o="".concat(i="https:","//").concat(o)),{href:o,protocol:i,host:s}}throw new Error("cannot parse base URL: ".concat(e))}],storage:[void 0,P((0,c.jt)((0,c.wE)(c.Z_,c.Yl)))],initialState:[void 0,function(t){return t&&JSON.parse(t)}],key:[void 0,P(c.sR,(function(){return"auth"}))]},F="authentication",M=function(){var t=this._services.Authentication;if(!t){var e=this.config.Authentication.from;t=e?e.authentication:U(this),this._services.Authentication=t}return t},E(d.prototype,F,M,W);var B=n(618);function J(t){var e=t.code||"UNKNOWN_ERROR",n=t.message||JSON.stringify(t),r=new Error("".concat(e,"[").concat(n,"]"));return r.code=e,r}var z=function(){function t(){o()(this,t),this.cache_={}}return s()(t,[{key:"length",get:function(){return Object.keys(this.cache_).length}},{key:"key",value:function(t){var e=Object.keys(this.cache_);return 0<=t&&t<e.length?e[t]:null}},{key:"getItem",value:function(t){return this.cache_.hasOwnProperty(t)?this.cache_[t]:null}},{key:"setItem",value:function(t,e){this.cache_[t]=e}},{key:"removeItem",value:function(t){delete this.cache_[t]}},{key:"clear",value:function(){this.cache_={}}}]),t}(),Y="localStorage",G=g.sZ.localStorage;G||(G=t.Z.localStorage||new z),(0,g.x$)(Y,(function(){return G}),(function(t){return G=t}));var V="sessionStorage",$=g.sZ.sessionStorage;function X(t){return"webcom:"+t}$||($=t.Z.sessionStorage||null),(0,g.x$)(V,(function(){return $}),(function(t){return $=t}));var Q=s()((function t(e,n){o()(this,t);var r=e();if(r){var i=X("sentinel");r.setItem(i,""),r.removeItem(i)}function s(){return e()||(0,c._y)("JSONStorage","the ".concat(n," implementation could not be found!"))}this.set=function(t,e){if(null===e)s().removeItem(X(t));else{var n=JSON.stringify(e);s().setItem(X(t),"string"==typeof n?n:"null")}},this.get=function(t){var e=s().getItem(X(t));return e&&JSON.parse(e)},this.remove=function(t){s().removeItem(X(t))}})),tt=new Q((function(){return G}),"localStorage"),et=new Q((function(){return $}),"sessionStorage"),nt=n(730),rt=n.n(nt);function ot(t){return decodeURIComponent(t.replace(/\+/g," "))}function it(){var t=2147483648;return Math.floor(Math.random()*t).toString(36)+Math.abs(Math.floor(Math.random()*t)^Date.now()).toString(36)}function st(t){var e={};return t.replace(/^[^?]*\?/,"").split("&").forEach((function(t){var n=t.indexOf("=");if(n<0)e[ot(t)]=!0;else{var r=ot(t.substring(0,n));e[r]=ot(t.substring(n+1))}})),e}function at(t){if(!t)return"";var e=[];return Object.entries(t).forEach((function(t){var n=u()(t,2),r=n[0],o=n[1];null!=o&&((0,f.Kn)(o)&&(o=JSON.stringify(o)),e.push(encodeURIComponent(r)+"="+encodeURIComponent(o)))})),e.join("&")}function ut(t,e){var n=t.indexOf("?"),r=e?(n<0?"?":"&")+at(e):"",o=t.indexOf("#");return o<0?t+r:t.substring(0,o)+r+t.substring(o)}var ct=n(100),ht=n.n(ct);var ft="XMLHttpRequest",lt=g.sZ.XMLHttpRequest;lt||(lt=n(286).h),(0,g.x$)(ft,(function(){return lt}),(function(t){return lt=t}));var dt=(0,h.hu)("network.HttpRequest","HttpRequest"),pt="application/x-www-form-urlencoded",vt="application/json",yt="Content-Type",gt="PUT",_t="PATCH",mt="POST",bt="DELETE",wt="GET",kt=s()((function t(e,n){o()(this,t),this.name=e,this.value=n})),xt="HttpRequest",St=function(){function t(e,n){o()(this,t);for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];this.url=ut([n].concat(S()(i.filter((function(t){return t&&t.length})).map((function(t){return encodeURIComponent(t)})))).join("/"),{c:A.DV}),this.method=e.toUpperCase(),this.headers={Accept:"application/json, text/plain"}}return s()(t,[{key:"addQueryParameters",value:function(t){return this.url=ut(this.url,t),this}},{key:"addJson",value:function(t){return this.contentType=vt,this.data=t,this}},{key:"addForm",value:function(t){return this.contentType=pt,this.data=t,this}},{key:"addHeader",value:function(t){return(0,c.T2)([xt,"#addHeader"],arguments,(0,c.jt)((0,c.l4)(kt))),t&&(this.headers[t.name]=t.value),this}},{key:"readResponseHeaders",value:function(){return this.readHeaders=!0,this}},{key:"send",value:function(){var t=this;return new Promise((function(e,n){var r=null;void 0!==t.data&&[mt,gt,_t].indexOf(t.method)>=0&&((r=t.contentType===pt?at(t.data):t.contentType===vt?JSON.stringify(t.data):t.data)?t.headers[yt]=t.contentType:delete t.headers[yt]),dt.log("==> ".concat(t.method," ").concat(t.url)),Object.keys(t.headers).forEach((function(e){return dt.log(" > HEADER ".concat(e,": ").concat(t.headers[e]))})),r&&dt.log(" > DATA: ".concat(r)),t._open(r,e,(function(t){dt.log("<== ERROR: ".concat(JSON.stringify(t))),n(J(t))}))}))}},{key:"_open",value:function(t,e,n){var r=this,o=new lt,i="RESPONSE_PAYLOAD_ERROR";o.onreadystatechange=function(){if(4===o.readyState){var t=o.responseText,s=o.status;if(s>=500)n({code:i,message:"HTTP status ".concat(s)});else try{var a=t.length?JSON.parse(t):{};if(s>=400)n(a.error||a);else if(s>=200&&s<300||304===s){var u={body:a},c=u.body.error||null;c?n((0,f.Kn)(c)?c:{code:u.body.status,message:c}):(r.readHeaders&&(u.headers=function(t){var e=t.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};return e.forEach((function(t){var e=t.indexOf(": "),r=t.substring(0,e).toLowerCase();n[r]=t.substring(e+2)})),n}(o)),dt.log("<== ".concat(JSON.stringify(u))),e(u))}else n({code:i,message:"HTTP status ".concat(s)})}catch(t){n({code:i,message:"invalid response payload, not a Json content type"})}}},o.open(this.method,this.url,!0),Object.entries(this.headers).forEach((function(t){var e=u()(t,2),n=e[0],r=e[1];return o.setRequestHeader(n,r)})),o.send(t)}}]),t}();function At(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return ht()(St,[wt,t].concat(n))}function Ot(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return ht()(St,[gt,t].concat(n))}function Rt(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return ht()(St,[mt,t].concat(n))}function Tt(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return ht()(St,[bt,t].concat(n))}function Pt(t){if(t)return new kt("Authorization","Bearer ".concat(t))}var jt=function(){function t(e){o()(this,t),j(this,"name",e),this.counters_={}}return s()(t,[{key:"attach",value:function(t){this.counters_=t.counters_}},{key:"incrementCounter",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.counters_[t]=(this.counters_[t]||0)+e}},{key:"get",value:function(){return Object.assign({},this.counters_)}}]),t}(),Et=new jt("deprecated"),Ct=n(455);function It(t,e,n,r){r=r&&r.concat(": ")||"",n=n?"use ".concat(n," instead"):"it should no longer be used",t.warn("".concat(r).concat(e," is deprecated, ").concat(n,".")),Et.incrementCounter(e)}j(h.ZP,"showDeprecations",(function(){(0,c.T2)([h.ab,"showDeprecations"],arguments),Zt=It})),j(h.ZP,"hideDeprecations",(function(){(0,c.T2)([h.ab,"hideDeprecations"],arguments),Zt=Ct.ZT}));var Zt=It;j(w,"Authentication",{avatarURL:K}),E(w,"avatarURL",(function(){return Zt(k,"Webcom.avatarURL","Webcom.Authentication.avatarURL"),K}));var Ht={code:"USER_DENIED",message:"The user aborted authentication"},Dt={facebook:{height:650,width:680},google:{height:460,width:490},github:{height:760,width:340},gitlab:{height:710,width:800},orange:{height:700,width:1e3},mobileconnectOFR:{height:540,width:700}},Nt={menubar:0,location:0,resizable:0,scrollbars:1,status:0,dialog:1,width:700,height:375};function Lt(t,e){var n=t.config.Authentication;return(0,f.HD)(n.storage)?n.storage:v(t,"state",n)+e}function Ut(t,e,n){(0,B.iK)((function(){return t(e,n)}))}function Ft(){return A.RY&&(et.get(this._oauthSessionKey)||tt.get(this._oauthSessionKey))}var Mt=function(){function t(e){o()(this,t),this._logger=(0,h.hu)("api.Authentication",q),this._logger.log("Initializing with options ".concat(JSON.stringify(e.config.Authentication))),this._app=e,this._init(e)}return s()(t,[{key:"_init",value:function(t){var e=t.config.Authentication;O.call(this,e.baseUrl);var n=this._logger._count;this._currentState=function(t){try{return new D(t.state,t.details)}catch(t){return N}}(function(t,e){var n=t.config.Authentication;return n.initialState||((0,f.mf)(n.storage)?{}:tt.get(Lt(t,e)))}(t,n)),this._authStateSetter=function(t,e){var n=t.config.Authentication;if((0,f.mf)(n.storage))return function(t){return n.storage(JSON.stringify(t))};var r=Lt(t,e);return function(t){return t&&!t.isUnauthenticated()?tt.set(r,t):tt.remove(r)}}(t,n),this._oauthSessionKey=v(t,"ongoing",e)+n,this.isAuthContextual=!1,this._firstSubscriptions=[],this._lastSubscriptions=[],this._authRoute="".concat(e.baseUrl.href,"/auth/v2/").concat(t.appId),this._resumeAuthState(),this._logger.log("Initialized for appId %s",t.appId)}},{key:"_dispose",value:function(){}},{key:"currentState",get:function(){return this._currentState},set:function(t){this._currentState.isSameAs(t)||(this._currentState=function(t){if(t.isAuthenticated()){var e=Object.assign({},t.details);return delete e.extra,L(e)}return t}(t),this._authStateSetter(this._currentState),this._notifyErrorOrAuthStateChanged(null,t))}},{key:"_resumeAuthState",value:function(){var t=this;if(A.RY)if("popup"===tt.get(this._oauthSessionKey))document.body.style.display="none",tt.set(this._oauthSessionKey,st(location.search).__wcsession),window.close();else{var e=et.get(this._oauthSessionKey);if(e){var n=st(location.search).__wcsession;if(n)return void(this._oauthSessionPromise=this.resumeSession(n,e).finally((function(){delete t._oauthSessionPromise,et.remove(t._oauthSessionKey)})).catch(Ct.ZT));et.remove(this._oauthSessionKey)}}this._logger.info("Authentication state resumed: %s",this.currentState.state),this._logger.log("Authentication details are: %o",this.currentState.details)}},{key:"getAccountDetails",value:function(){var t=[q,"#removeIdentity"];try{(0,c.T2)(t,arguments);var e=this._getCurrentAuthenticationDetails(t);return this._httpGet("accounts",e.uid).addHeader(Pt(e.webcomAuthToken)).send().then((function(t){for(var e={},n=0,r=Object.entries(t.body);n<r.length;n++){var o=u()(r[n],2),i=o[0],s=o[1];switch(i){case"providers":for(var a={},c=0,h=Object.entries(s);c<h.length;c++){var f=u()(h[c],2),l=f[0],d=f[1];a[l]=Object.keys(d)}e.identities=a;break;case"createdOn":e[i]=new Date(s);break;default:e[i]=s}}return e}))}catch(t){return Promise.reject(t)}}},{key:"subscribe",value:function(t,e){return(0,c.T2)([q,"#subscribe"],arguments,c.Yl,(0,c.jt)(c.O7)),e?this._firstSubscriptions.push(t):this._lastSubscriptions.push(t),Ft.call(this)?this._logger.log("Notification not sent, because an OAuth authentication is ongoing."):Ut(t,null,this.currentState),t}},{key:"unsubscribe",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;(0,c.T2)([q,"#unsubscribe"],arguments,(0,c.jt)(c.Yl),(0,c.jt)(c.O7));var n=this._firstSubscriptions.length+this._lastSubscriptions.length,r=function(e){return t&&t!==e};return!1!==e&&(this._firstSubscriptions=this._firstSubscriptions.filter(r)),!0!==e&&(this._lastSubscriptions=this._lastSubscriptions.filter(r)),n-this._firstSubscriptions.length-this._lastSubscriptions.length}},{key:"_notifyErrorOrAuthStateChanged",value:function(t,e){this._firstSubscriptions.concat(this._lastSubscriptions).forEach((function(n){return Ut(n,t,e)}))}},{key:"authenticationRevoked",value:function(t,e){(0,c.T2)([q,"#authenticationRevoked"],arguments,(0,c.l4)(D),c.Z_);var n=new Error("Authentication was revoked by the server: ".concat(e));n.code="AUTH_REVOKED",this._notifyErrorOrAuthStateChanged(n,null),this.currentState=t}},{key:"resumeSession",value:function(t,e){return(0,c.T2)("AuthenticationImpl#resumeSession",arguments,c.Z_,c.Z_),this._logger.info("fetching authentication state from an ongoing OAuth2 session..."),Rt(this._authRoute,"session").addJson({sessionKey:t,requestKey:e}).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}},{key:"_extendHttpRequest",value:function(t){var e=this,n=t;return n.addAuthContext=function(){var n=e._contextAuthToken();return n?t.addHeader(Pt(n)):t},n}},{key:"_httpGet",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._extendHttpRequest(At.apply(void 0,[this._authRoute].concat(e)))}},{key:"_httpPost",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._extendHttpRequest(Rt.apply(void 0,[this._authRoute].concat(e)))}},{key:"_httpPut",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._extendHttpRequest(Ot.apply(void 0,[this._authRoute].concat(e)))}},{key:"_httpDelete",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._extendHttpRequest(Tt.apply(void 0,[this._authRoute].concat(e)))}},{key:"_updateStateFromHttpResponse",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(t){return t};return function(n){var r=e(n).body,o=r.token,i=r.user;if(o)return i.webcomAuthToken=o,t.currentState=L(i),new Promise((function(t){return(0,B.iK)((function(){return t(i)}))}));throw J({code:"UNEXPECTED_RESPONSE",message:"the 'token' property is missing."})}}},{key:"_notifyErrorFromHttpResponse",value:function(t){throw this._notifyErrorOrAuthStateChanged(t,null),t}},{key:"useCurrentContextForNextAuthOperation",value:function(){(0,c.T2)([q,"#useCurrentContextForNextAuthOperation"],arguments),this.isAuthContextual=!0}},{key:"useNewContextForNextAuthOperation",value:function(){(0,c.T2)([q,"#useNewContextForNextAuthOperation"],arguments),this.isAuthContextual=!1}},{key:"_contextAuthToken",value:function(){var t=this.isAuthContextual?this.currentState.details:null;return this.isAuthContextual=!1,t&&t.webcomAuthToken}},{key:"signInWithToken",value:function(t){try{return(0,c.T2)([q,"#signInWithToken"],arguments,c.Z_),this._httpGet("decode").addHeader(Pt(t)).send().then(this._updateStateFromHttpResponse((function(e){var n=e.body;return{body:{token:t,user:n.data}}})),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"signInAsGuest",value:function(){try{return(0,c.T2)([q,"#signInAsGuest"],arguments),this._httpPost("anonymous","signin").addAuthContext().send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"signInWithCredentials",value:function(t,e){try{return(0,c.T2)([q,"#signInWithCredentials"],arguments,c.Z_,c.Ry),this._httpPost(t,"signin").addAuthContext().addJson(e).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"sendOtp",value:function(t,e,n){try{return(0,c.T2)([q,"#sendOtp"],arguments,c.Z_,c.Z_,(0,c.jt)(c.Ry)),this._httpPost(t,"otps").addQueryParameters(n).addJson(e).send().then((function(t){return t.body}))}catch(t){return Promise.reject(t)}}},{key:"signInWithCustomProvider",value:function(t,e){try{return(0,c.T2)([q,"#signInWithCustomProvider"],arguments,c.Z_,c.Z_),this._httpPost("custom.".concat(t),"signin").addAuthContext().addForm({token:e}).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"signInWithOAuth",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{(0,c.T2)([q,"#signInWithOAuth"],arguments,c.Z_,(0,c.jt)(c.Ry)),e.mode=e.mode||"popup";var n=e.mode;return"code"===n?this._loginViaOAuthCode(t,e):this._loginViaOAuth(t,e)}catch(t){return Promise.reject(t)}}},{key:"signInWithWassup",value:function(t){try{return(0,c.T2)([q,"#signInWithWassup"],arguments,c.Ry),this._httpPost("wassup","signin").addAuthContext().addForm(t).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"signOut",value:function(){try{return(0,c.T2)([q,"#signOut"],arguments),this.currentState=N,new Promise((function(t){return(0,B.iK)((function(){return t()}))}))}catch(t){return Promise.reject(t)}}},{key:"_loginViaOAuthCode",value:function(t,e){return e.code&&e.state||this._logger.warn("authWithOAuth(): options.code or options.state is missing!"),this._httpGet(t,"callback").addQueryParameters(e).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}},{key:"_loginViaOAuth",value:function(t,e){if(Ft.call(this))return this._oauthSessionPromise||Promise.reject(J({code:"ONGOING_OAUTH",message:"An OAuth authentication is already ongoing"}));var n=!A.RY||"redirect"===e.mode||f.lk();e.token=this._contextAuthToken(),e.mode="redirect",!e.to&&A.RY&&(e.to=location.href.replace(/[?&]__wcsession=[^&]+/,"")),!e.from&&A.RY&&(e.from=it()+it()+it()+it());var r,o,i=e.from;e.from=(r=i,o=!0,rt().codec.base64.fromBits(rt().hash.sha256.hash(r),!1,o)),e.pm="2";var s=e.popupFeatures||{};delete e.popupFeatures;var a=ut("".concat(this._authRoute,"/").concat(t,"/signin"),e);if(!n)return this._oauthLoginViaPopup(t,s,a,i);try{return A.RY&&(et.set(this._oauthSessionKey,i),document.location=a),Promise.resolve(a)}catch(t){return Promise.reject(t)}}},{key:"_oauthLoginViaPopup",value:function(t,e,n,r){var o=this,i=Object.assign({},Nt,Dt[t],e),s=i.target||"_blank";delete i.target;var a=window.open(n,s,Object.entries(i).map((function(t){var e=u()(t,2),n=e[0],r=e[1];return"".concat(n,"=").concat(r)})).join(","));return new Promise((function(t,e){if(a){tt.set(o._oauthSessionKey,"popup");var i=function(){a.close(),tt.remove(o._oauthSessionKey)};window.addEventListener("beforeunload",i);var s=(0,B.Zi)((function(){if(a.closed){(0,B.cv)(s),window.removeEventListener("beforeunload",i);var n=tt.get(o._oauthSessionKey);i(),"popup"===n?e(J(Ht)):t(o.resumeSession(n,r))}}),250)}else e(J(function(t){return{code:"POPUP_FAILED",message:"Could not open popup at ".concat(t)}}(n)))}))}},{key:"addIdentity",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{return(0,c.T2)([q,"#addIdentity"],arguments,c.Z_,c.Ry,(0,c.jt)(c.Ry)),this._httpPost(t,"identities").addAuthContext().addQueryParameters(n).addJson(e).send().then((function(t){return t.body}))}catch(t){return Promise.reject(t)}}},{key:"removeIdentity",value:function(){var t=[q,"#removeIdentity"];try{(0,c.T2)(t,arguments);var e=this._getCurrentAuthenticationDetails(t);return this._httpDelete(e.provider,"identities",e.providerUid).addHeader(Pt(e.webcomAuthToken)).send().then((function(){}))}catch(t){return Promise.reject(t)}}},{key:"removeAccount",value:function(){var t=[q,"#removeAccount"];try{(0,c.T2)(t,arguments);var e=this._getCurrentAuthenticationDetails(t);return this._httpDelete("accounts",e.uid).addHeader(Pt(e.webcomAuthToken)).send().then((function(){}))}catch(t){return Promise.reject(t)}}},{key:"verifyIdentity",value:function(t,e,n){try{return(0,c.T2)([q,"#verifyIdentity"],arguments,c.Z_,c.Z_,c.Ry),n.auth&&(n.challenge=n.auth.verificationPending,delete n.auth),this._httpPost(t,"identities",e,"verify").addAuthContext().addJson(n).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"updateIdentityProfile",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=[q,"#updateIdentityProfile"];try{(0,c.T2)(n,arguments,c.__,(0,c.jt)(c.Z_));var r=this._getCurrentAuthenticationDetails(n);return this._httpPut(r.provider,"identities",r.providerUid,"providerProfile",e).addHeader(Pt(r.webcomAuthToken)).addJson(t).send().then((function(t){return t.body}))}catch(t){return Promise.reject(t)}}},{key:"_getCurrentAuthenticationDetails",value:function(t){var e;if(!this.currentState.isAuthenticated())throw J({code:"AUTH_MISSING",message:"".concat((e="").concat.apply(e,S()(t))," failed: needs to be authenticated")});return this.currentState.details}},{key:"updatePassword",value:function(t,e,n){try{return(0,c.T2)([q,"#updatePassword"],arguments,c.Z_,c.Z_,c.Z_),this._httpPut("password","identities",t,"password").addForm({password:e,newPassword:n}).send().then((function(t){return t.body}))}catch(t){return Promise.reject(t)}}},{key:"sendPasswordResetCode",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{return(0,c.T2)([q,"#sendPasswordRe