import{a as Ve,f as ze}from"./chunk-AA53URW2.js";import{A as De,B as Ee,d as he,e as lr,f as K,l as Me,ma as de,na as Ae,ra as Oe,sa as He,t as ke,td as je,u as Pe,xa as Fe,z as Ne}from"./chunk-CYQ5MM66.js";var Je=he(()=>{"use strict"});var Ye=he(xe=>{"use strict";xe.byteLength=dr;xe.toByteArray=xr;xe.fromByteArray=yr;var Z=[],Y=[],hr=typeof Uint8Array<"u"?Uint8Array:Array,be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(oe=0,We=be.length;oe<We;++oe)Z[oe]=be[oe],Y[be.charCodeAt(oe)]=oe;var oe,We;Y[45]=62;Y[95]=63;function Ke(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function dr(t){var e=Ke(t),r=e[0],n=e[1];return(r+n)*3/4-n}function pr(t,e,r){return(e+r)*3/4-r}function xr(t){var e,r=Ke(t),n=r[0],o=r[1],a=new hr(pr(t,n,o)),c=0,k=o>0?n-4:n,u;for(u=0;u<k;u+=4)e=Y[t.charCodeAt(u)]<<18|Y[t.charCodeAt(u+1)]<<12|Y[t.charCodeAt(u+2)]<<6|Y[t.charCodeAt(u+3)],a[c++]=e>>16&255,a[c++]=e>>8&255,a[c++]=e&255;return o===2&&(e=Y[t.charCodeAt(u)]<<2|Y[t.charCodeAt(u+1)]>>4,a[c++]=e&255),o===1&&(e=Y[t.charCodeAt(u)]<<10|Y[t.charCodeAt(u+1)]<<4|Y[t.charCodeAt(u+2)]>>2,a[c++]=e>>8&255,a[c++]=e&255),a}function wr(t){return Z[t>>18&63]+Z[t>>12&63]+Z[t>>6&63]+Z[t&63]}function mr(t,e,r){for(var n,o=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(t[a+2]&255),o.push(wr(n));return o.join("")}function yr(t){for(var e,r=t.length,n=r%3,o=[],a=16383,c=0,k=r-n;c<k;c+=a)o.push(mr(t,c,c+a>k?k:c+a));return n===1?(e=t[r-1],o.push(Z[e>>2]+Z[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(Z[e>>10]+Z[e>>4&63]+Z[e<<2&63]+"=")),o.join("")}});var $e=he(Ue=>{"use strict";Ue.read=function(t,e,r,n,o){var a,c,k=o*8-n-1,u=(1<<k)-1,_=u>>1,S=-7,I=r?o-1:0,D=r?-1:1,B=t[e+I];for(I+=D,a=B&(1<<-S)-1,B>>=-S,S+=k;S>0;a=a*256+t[e+I],I+=D,S-=8);for(c=a&(1<<-S)-1,a>>=-S,S+=n;S>0;c=c*256+t[e+I],I+=D,S-=8);if(a===0)a=1-_;else{if(a===u)return c?NaN:(B?-1:1)*(1/0);c=c+Math.pow(2,n),a=a-_}return(B?-1:1)*c*Math.pow(2,a-n)};Ue.write=function(t,e,r,n,o,a){var c,k,u,_=a*8-o-1,S=(1<<_)-1,I=S>>1,D=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=n?0:a-1,$=n?1:-1,ce=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(k=isNaN(e)?1:0,c=S):(c=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-c))<1&&(c--,u*=2),c+I>=1?e+=D/u:e+=D*Math.pow(2,1-I),e*u>=2&&(c++,u/=2),c+I>=S?(k=0,c=S):c+I>=1?(k=(e*u-1)*Math.pow(2,o),c=c+I):(k=e*Math.pow(2,I-1)*Math.pow(2,o),c=0));o>=8;t[r+B]=k&255,B+=$,k/=256,o-=8);for(c=c<<o|k,_+=o;_>0;t[r+B]=c&255,B+=$,c/=256,_-=8);t[r+B-$]|=ce*128}});var sr=he(fe=>{"use strict";var Se=Ye(),ue=$e(),Xe=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;fe.Buffer=f;fe.SlowBuffer=Fr;fe.INSPECT_MAX_BYTES=50;var we=2147483647;fe.kMaxLength=we;f.TYPED_ARRAY_SUPPORT=gr();!f.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function gr(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}});Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function re(t){if(t>we)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,f.prototype),e}function f(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Re(t)}return Qe(t,e,r)}f.poolSize=8192;function Qe(t,e,r){if(typeof t=="string")return kr(t,e);if(ArrayBuffer.isView(t))return Er(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(ee(t,ArrayBuffer)||t&&ee(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ee(t,SharedArrayBuffer)||t&&ee(t.buffer,SharedArrayBuffer)))return Ie(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return f.from(n,e,r);var o=Ar(t);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return f.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}f.from=function(t,e,r){return Qe(t,e,r)};Object.setPrototypeOf(f.prototype,Uint8Array.prototype);Object.setPrototypeOf(f,Uint8Array);function Ze(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function vr(t,e,r){return Ze(t),t<=0?re(t):e!==void 0?typeof r=="string"?re(t).fill(e,r):re(t).fill(e):re(t)}f.alloc=function(t,e,r){return vr(t,e,r)};function Re(t){return Ze(t),re(t<0?0:Ce(t)|0)}f.allocUnsafe=function(t){return Re(t)};f.allocUnsafeSlow=function(t){return Re(t)};function kr(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=er(t,e)|0,n=re(r),o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}function _e(t){for(var e=t.length<0?0:Ce(t.length)|0,r=re(e),n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Er(t){if(ee(t,Uint8Array)){var e=new Uint8Array(t);return Ie(e.buffer,e.byteOffset,e.byteLength)}return _e(t)}function Ie(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,f.prototype),n}function Ar(t){if(f.isBuffer(t)){var e=Ce(t.length)|0,r=re(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Be(t.length)?re(0):_e(t);if(t.type==="Buffer"&&Array.isArray(t.data))return _e(t.data)}function Ce(t){if(t>=we)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+we.toString(16)+" bytes");return t|0}function Fr(t){return+t!=t&&(t=0),f.alloc(+t)}f.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==f.prototype};f.compare=function(e,r){if(ee(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),ee(r,Uint8Array)&&(r=f.from(r,r.offset,r.byteLength)),!f.isBuffer(e)||!f.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;for(var n=e.length,o=r.length,a=0,c=Math.min(n,o);a<c;++a)if(e[a]!==r[a]){n=e[a],o=r[a];break}return n<o?-1:o<n?1:0};f.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};f.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return f.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var o=f.allocUnsafe(r),a=0;for(n=0;n<e.length;++n){var c=e[n];if(ee(c,Uint8Array))a+c.length>o.length?f.from(c).copy(o,a):Uint8Array.prototype.set.call(o,c,a);else if(f.isBuffer(c))c.copy(o,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=c.length}return o};function er(t,e){if(f.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||ee(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Te(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return ar(t).length;default:if(o)return n?-1:Te(t).length;e=(""+e).toLowerCase(),o=!0}}f.byteLength=er;function br(t,e,r){var n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Mr(this,e,r);case"utf8":case"utf-8":return tr(this,e,r);case"ascii":return Br(this,e,r);case"latin1":case"binary":return Lr(this,e,r);case"base64":return Rr(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pr(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}f.prototype._isBuffer=!0;function ae(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}f.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<e;r+=2)ae(this,r,r+1);return this};f.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<e;r+=4)ae(this,r,r+3),ae(this,r+1,r+2);return this};f.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<e;r+=8)ae(this,r,r+7),ae(this,r+1,r+6),ae(this,r+2,r+5),ae(this,r+3,r+4);return this};f.prototype.toString=function(){var e=this.length;return e===0?"":arguments.length===0?tr(this,0,e):br.apply(this,arguments)};f.prototype.toLocaleString=f.prototype.toString;f.prototype.equals=function(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:f.compare(this,e)===0};f.prototype.inspect=function(){var e="",r=fe.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Xe&&(f.prototype[Xe]=f.prototype.inspect);f.prototype.compare=function(e,r,n,o,a){if(ee(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),a===void 0&&(a=this.length),r<0||n>e.length||o<0||a>this.length)throw new RangeError("out of range index");if(o>=a&&r>=n)return 0;if(o>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,o>>>=0,a>>>=0,this===e)return 0;for(var c=a-o,k=n-r,u=Math.min(c,k),_=this.slice(o,a),S=e.slice(r,n),I=0;I<u;++I)if(_[I]!==S[I]){c=_[I],k=S[I];break}return c<k?-1:k<c?1:0};function rr(t,e,r,n,o){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Be(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0)if(o)r=0;else return-1;if(typeof e=="string"&&(e=f.from(e,n)),f.isBuffer(e))return e.length===0?-1:Ge(t,e,r,n,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Ge(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function Ge(t,e,r,n,o){var a=1,c=t.length,k=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;a=2,c/=2,k/=2,r/=2}function u(B,$){return a===1?B[$]:B.readUInt16BE($*a)}var _;if(o){var S=-1;for(_=r;_<c;_++)if(u(t,_)===u(e,S===-1?0:_-S)){if(S===-1&&(S=_),_-S+1===k)return S*a}else S!==-1&&(_-=_-S),S=-1}else for(r+k>c&&(r=c-k),_=r;_>=0;_--){for(var I=!0,D=0;D<k;D++)if(u(t,_+D)!==u(e,D)){I=!1;break}if(I)return _}return-1}f.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};f.prototype.indexOf=function(e,r,n){return rr(this,e,r,n,!0)};f.prototype.lastIndexOf=function(e,r,n){return rr(this,e,r,n,!1)};function Ur(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n),n>o&&(n=o)):n=o;var a=e.length;n>a/2&&(n=a/2);for(var c=0;c<n;++c){var k=parseInt(e.substr(c*2,2),16);if(Be(k))return c;t[r+c]=k}return c}function Sr(t,e,r,n){return me(Te(e,t.length-r),t,r,n)}function _r(t,e,r,n){return me(Or(e),t,r,n)}function Ir(t,e,r,n){return me(ar(e),t,r,n)}function Tr(t,e,r,n){return me(Hr(e,t.length-r),t,r,n)}f.prototype.write=function(e,r,n,o){if(r===void 0)o="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")o=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-r;if((n===void 0||n>a)&&(n=a),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var c=!1;;)switch(o){case"hex":return Ur(this,e,r,n);case"utf8":case"utf-8":return Sr(this,e,r,n);case"ascii":case"latin1":case"binary":return _r(this,e,r,n);case"base64":return Ir(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Tr(this,e,r,n);default:if(c)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),c=!0}};f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Rr(t,e,r){return e===0&&r===t.length?Se.fromByteArray(t):Se.fromByteArray(t.slice(e,r))}function tr(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var a=t[o],c=null,k=a>239?4:a>223?3:a>191?2:1;if(o+k<=r){var u,_,S,I;switch(k){case 1:a<128&&(c=a);break;case 2:u=t[o+1],(u&192)===128&&(I=(a&31)<<6|u&63,I>127&&(c=I));break;case 3:u=t[o+1],_=t[o+2],(u&192)===128&&(_&192)===128&&(I=(a&15)<<12|(u&63)<<6|_&63,I>2047&&(I<55296||I>57343)&&(c=I));break;case 4:u=t[o+1],_=t[o+2],S=t[o+3],(u&192)===128&&(_&192)===128&&(S&192)===128&&(I=(a&15)<<18|(u&63)<<12|(_&63)<<6|S&63,I>65535&&I<1114112&&(c=I))}}c===null?(c=65533,k=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c),o+=k}return Cr(n)}var qe=4096;function Cr(t){var e=t.length;if(e<=qe)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=qe));return r}function Br(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]&127);return n}function Lr(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function Mr(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",a=e;a<r;++a)o+=jr[t[a]];return o}function Pr(t,e,r){for(var n=t.slice(e,r),o="",a=0;a<n.length-1;a+=2)o+=String.fromCharCode(n[a]+n[a+1]*256);return o}f.prototype.slice=function(e,r){var n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);var o=this.subarray(e,r);return Object.setPrototypeOf(o,f.prototype),o};function O(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUintLE=f.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||O(e,r,this.length);for(var o=this[e],a=1,c=0;++c<r&&(a*=256);)o+=this[e+c]*a;return o};f.prototype.readUintBE=f.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||O(e,r,this.length);for(var o=this[e+--r],a=1;r>0&&(a*=256);)o+=this[e+--r]*a;return o};f.prototype.readUint8=f.prototype.readUInt8=function(e,r){return e=e>>>0,r||O(e,1,this.length),this[e]};f.prototype.readUint16LE=f.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||O(e,2,this.length),this[e]|this[e+1]<<8};f.prototype.readUint16BE=f.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||O(e,2,this.length),this[e]<<8|this[e+1]};f.prototype.readUint32LE=f.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUint32BE=f.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||O(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||O(e,r,this.length);for(var o=this[e],a=1,c=0;++c<r&&(a*=256);)o+=this[e+c]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*r)),o};f.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||O(e,r,this.length);for(var o=r,a=1,c=this[e+--o];o>0&&(a*=256);)c+=this[e+--o]*a;return a*=128,c>=a&&(c-=Math.pow(2,8*r)),c};f.prototype.readInt8=function(e,r){return e=e>>>0,r||O(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};f.prototype.readInt16LE=function(e,r){e=e>>>0,r||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};f.prototype.readInt16BE=function(e,r){e=e>>>0,r||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};f.prototype.readInt32LE=function(e,r){return e=e>>>0,r||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function(e,r){return e=e>>>0,r||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readFloatLE=function(e,r){return e=e>>>0,r||O(e,4,this.length),ue.read(this,e,!0,23,4)};f.prototype.readFloatBE=function(e,r){return e=e>>>0,r||O(e,4,this.length),ue.read(this,e,!1,23,4)};f.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||O(e,8,this.length),ue.read(this,e,!0,52,8)};f.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||O(e,8,this.length),ue.read(this,e,!1,52,8)};function z(t,e,r,n,o,a){if(!f.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<a)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}f.prototype.writeUintLE=f.prototype.writeUIntLE=function(e,r,n,o){if(e=+e,r=r>>>0,n=n>>>0,!o){var a=Math.pow(2,8*n)-1;z(this,e,r,n,a,0)}var c=1,k=0;for(this[r]=e&255;++k<n&&(c*=256);)this[r+k]=e/c&255;return r+n};f.prototype.writeUintBE=f.prototype.writeUIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,n=n>>>0,!o){var a=Math.pow(2,8*n)-1;z(this,e,r,n,a,0)}var c=n-1,k=1;for(this[r+c]=e&255;--c>=0&&(k*=256);)this[r+c]=e/k&255;return r+n};f.prototype.writeUint8=f.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||z(this,e,r,1,255,0),this[r]=e&255,r+1};f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||z(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||z(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||z(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||z(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};f.prototype.writeIntLE=function(e,r,n,o){if(e=+e,r=r>>>0,!o){var a=Math.pow(2,8*n-1);z(this,e,r,n,a-1,-a)}var c=0,k=1,u=0;for(this[r]=e&255;++c<n&&(k*=256);)e<0&&u===0&&this[r+c-1]!==0&&(u=1),this[r+c]=(e/k>>0)-u&255;return r+n};f.prototype.writeIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,!o){var a=Math.pow(2,8*n-1);z(this,e,r,n,a-1,-a)}var c=n-1,k=1,u=0;for(this[r+c]=e&255;--c>=0&&(k*=256);)e<0&&u===0&&this[r+c+1]!==0&&(u=1),this[r+c]=(e/k>>0)-u&255;return r+n};f.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||z(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};f.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||z(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};f.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||z(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};f.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||z(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};f.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||z(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function nr(t,e,r,n,o,a){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ir(t,e,r,n,o){return e=+e,r=r>>>0,o||nr(t,e,r,4,34028234663852886e22,-34028234663852886e22),ue.write(t,e,r,n,23,4),r+4}f.prototype.writeFloatLE=function(e,r,n){return ir(this,e,r,!0,n)};f.prototype.writeFloatBE=function(e,r,n){return ir(this,e,r,!1,n)};function or(t,e,r,n,o){return e=+e,r=r>>>0,o||nr(t,e,r,8,17976931348623157e292,-17976931348623157e292),ue.write(t,e,r,n,52,8),r+8}f.prototype.writeDoubleLE=function(e,r,n){return or(this,e,r,!0,n)};f.prototype.writeDoubleBE=function(e,r,n){return or(this,e,r,!1,n)};f.prototype.copy=function(e,r,n,o){if(!f.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),r>=e.length&&(r=e.length),r||(r=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-r<o-n&&(o=e.length-r+n);var a=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),r),a};f.prototype.fill=function(e,r,n,o){if(typeof e=="string"){if(typeof r=="string"?(o=r,r=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!f.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){var a=e.charCodeAt(0);(o==="utf8"&&a<128||o==="latin1")&&(e=a)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var c;if(typeof e=="number")for(c=r;c<n;++c)this[c]=e;else{var k=f.isBuffer(e)?e:f.from(e,o),u=k.length;if(u===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(c=0;c<n-r;++c)this[c+r]=k[c%u]}return this};var Nr=/[^+/0-9A-Za-z-_]/g;function Dr(t){if(t=t.split("=")[0],t=t.trim().replace(Nr,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Te(t,e){e=e||1/0;for(var r,n=t.length,o=null,a=[],c=0;c<n;++c){if(r=t.charCodeAt(c),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}else if(c+1===n){(e-=3)>-1&&a.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&a.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function Or(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Hr(t,e){for(var r,n,o,a=[],c=0;c<t.length&&!((e-=2)<0);++c)r=t.charCodeAt(c),n=r>>8,o=r%256,a.push(o),a.push(n);return a}function ar(t){return Se.toByteArray(Dr(t))}function me(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function ee(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Be(t){return t!==t}var jr=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=r*16,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()});var cr=he((Zr,ye)=>{"use strict";(function(){"use strict";var t="input is invalid type",e=typeof window=="object",r=e?window:{};r.JS_SHA256_NO_WINDOW&&(e=!1);var n=!e&&typeof self=="object",o=!r.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;o?r=global:n&&(r=self);var a=!r.JS_SHA256_NO_COMMON_JS&&typeof ye=="object"&&ye.exports,c=typeof define=="function"&&define.amd,k=!r.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),_=[-2147483648,8388608,32768,128],S=[24,16,8,0],I=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],D=["hex","array","digest","arrayBuffer"],B=[];(r.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(l){return Object.prototype.toString.call(l)==="[object Array]"}),k&&(r.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(l){return typeof l=="object"&&l.buffer&&l.buffer.constructor===ArrayBuffer});var $=function(l,g){return function(U){return new N(g,!0).update(U)[l]()}},ce=function(l){var g=$("hex",l);o&&(g=X(g,l)),g.create=function(){return new N(l)},g.update=function(A){return g.create().update(A)};for(var U=0;U<D.length;++U){var v=D[U];g[v]=$(v,l)}return g},X=function(l,g){var U=Je(),v=sr().Buffer,A=g?"sha224":"sha256",y;v.from&&!r.JS_SHA256_NO_BUFFER_FROM?y=v.from:y=function(x){return new v(x)};var C=function(x){if(typeof x=="string")return U.createHash(A).update(x,"utf8").digest("hex");if(x==null)throw new Error(t);return x.constructor===ArrayBuffer&&(x=new Uint8Array(x)),Array.isArray(x)||ArrayBuffer.isView(x)||x.constructor===v?U.createHash(A).update(y(x)).digest("hex"):l(x)};return C},pe=function(l,g){return function(U,v){return new ie(U,g,!0).update(v)[l]()}},q=function(l){var g=pe("hex",l);g.create=function(A){return new ie(A,l)},g.update=function(A,y){return g.create(A).update(y)};for(var U=0;U<D.length;++U){var v=D[U];g[v]=pe(v,l)}return g};function N(l,g){g?(B[0]=B[16]=B[1]=B[2]=B[3]=B[4]=B[5]=B[6]=B[7]=B[8]=B[9]=B[10]=B[11]=B[12]=B[13]=B[14]=B[15]=0,this.blocks=B):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],l?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=l}N.prototype.update=function(l){if(!this.finalized){var g,U=typeof l;if(U!=="string"){if(U==="object"){if(l===null)throw new Error(t);if(k&&l.constructor===ArrayBuffer)l=new Uint8Array(l);else if(!Array.isArray(l)&&(!k||!ArrayBuffer.isView(l)))throw new Error(t)}else throw new Error(t);g=!0}for(var v,A=0,y,C=l.length,x=this.blocks;A<C;){if(this.hashed&&(this.hashed=!1,x[0]=this.block,this.block=x[16]=x[1]=x[2]=x[3]=x[4]=x[5]=x[6]=x[7]=x[8]=x[9]=x[10]=x[11]=x[12]=x[13]=x[14]=x[15]=0),g)for(y=this.start;A<C&&y<64;++A)x[y>>>2]|=l[A]<<S[y++&3];else for(y=this.start;A<C&&y<64;++A)v=l.charCodeAt(A),v<128?x[y>>>2]|=v<<S[y++&3]:v<2048?(x[y>>>2]|=(192|v>>>6)<<S[y++&3],x[y>>>2]|=(128|v&63)<<S[y++&3]):v<55296||v>=57344?(x[y>>>2]|=(224|v>>>12)<<S[y++&3],x[y>>>2]|=(128|v>>>6&63)<<S[y++&3],x[y>>>2]|=(128|v&63)<<S[y++&3]):(v=65536+((v&1023)<<10|l.charCodeAt(++A)&1023),x[y>>>2]|=(240|v>>>18)<<S[y++&3],x[y>>>2]|=(128|v>>>12&63)<<S[y++&3],x[y>>>2]|=(128|v>>>6&63)<<S[y++&3],x[y>>>2]|=(128|v&63)<<S[y++&3]);this.lastByteIndex=y,this.bytes+=y-this.start,y>=64?(this.block=x[16],this.start=y-64,this.hash(),this.hashed=!0):this.start=y}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},N.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var l=this.blocks,g=this.lastByteIndex;l[16]=this.block,l[g>>>2]|=_[g&3],this.block=l[16],g>=56&&(this.hashed||this.hash(),l[0]=this.block,l[16]=l[1]=l[2]=l[3]=l[4]=l[5]=l[6]=l[7]=l[8]=l[9]=l[10]=l[11]=l[12]=l[13]=l[14]=l[15]=0),l[14]=this.hBytes<<3|this.bytes>>>29,l[15]=this.bytes<<3,this.hash()}},N.prototype.hash=function(){var l=this.h0,g=this.h1,U=this.h2,v=this.h3,A=this.h4,y=this.h5,C=this.h6,x=this.h7,R=this.blocks,P,H,j,J,L,G,i,s,d,m,h;for(P=16;P<64;++P)L=R[P-15],H=(L>>>7|L<<25)^(L>>>18|L<<14)^L>>>3,L=R[P-2],j=(L>>>17|L<<15)^(L>>>19|L<<13)^L>>>10,R[P]=R[P-16]+H+R[P-7]+j<<0;for(h=g&U,P=0;P<64;P+=4)this.first?(this.is224?(s=300032,L=R[0]-1413257819,x=L-150054599<<0,v=L+24177077<<0):(s=704751109,L=R[0]-210244248,x=L-1521486534<<0,v=L+143694565<<0),this.first=!1):(H=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),j=(A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7),s=l&g,J=s^l&U^h,i=A&y^~A&C,L=x+j+i+I[P]+R[P],G=H+J,x=v+L<<0,v=L+G<<0),H=(v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10),j=(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7),d=v&l,J=d^v&g^s,i=x&A^~x&y,L=C+j+i+I[P+1]+R[P+1],G=H+J,C=U+L<<0,U=L+G<<0,H=(U>>>2|U<<30)^(U>>>13|U<<19)^(U>>>22|U<<10),j=(C>>>6|C<<26)^(C>>>11|C<<21)^(C>>>25|C<<7),m=U&v,J=m^U&l^d,i=C&x^~C&A,L=y+j+i+I[P+2]+R[P+2],G=H+J,y=g+L<<0,g=L+G<<0,H=(g>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10),j=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),h=g&U,J=h^g&v^m,i=y&C^~y&x,L=A+j+i+I[P+3]+R[P+3],G=H+J,A=l+L<<0,l=L+G<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+l<<0,this.h1=this.h1+g<<0,this.h2=this.h2+U<<0,this.h3=this.h3+v<<0,this.h4=this.h4+A<<0,this.h5=this.h5+y<<0,this.h6=this.h6+C<<0,this.h7=this.h7+x<<0},N.prototype.hex=function(){this.finalize();var l=this.h0,g=this.h1,U=this.h2,v=this.h3,A=this.h4,y=this.h5,C=this.h6,x=this.h7,R=u[l>>>28&15]+u[l>>>24&15]+u[l>>>20&15]+u[l>>>16&15]+u[l>>>12&15]+u[l>>>8&15]+u[l>>>4&15]+u[l&15]+u[g>>>28&15]+u[g>>>24&15]+u[g>>>20&15]+u[g>>>16&15]+u[g>>>12&15]+u[g>>>8&15]+u[g>>>4&15]+u[g&15]+u[U>>>28&15]+u[U>>>24&15]+u[U>>>20&15]+u[U>>>16&15]+u[U>>>12&15]+u[U>>>8&15]+u[U>>>4&15]+u[U&15]+u[v>>>28&15]+u[v>>>24&15]+u[v>>>20&15]+u[v>>>16&15]+u[v>>>12&15]+u[v>>>8&15]+u[v>>>4&15]+u[v&15]+u[A>>>28&15]+u[A>>>24&15]+u[A>>>20&15]+u[A>>>16&15]+u[A>>>12&15]+u[A>>>8&15]+u[A>>>4&15]+u[A&15]+u[y>>>28&15]+u[y>>>24&15]+u[y>>>20&15]+u[y>>>16&15]+u[y>>>12&15]+u[y>>>8&15]+u[y>>>4&15]+u[y&15]+u[C>>>28&15]+u[C>>>24&15]+u[C>>>20&15]+u[C>>>16&15]+u[C>>>12&15]+u[C>>>8&15]+u[C>>>4&15]+u[C&15];return this.is224||(R+=u[x>>>28&15]+u[x>>>24&15]+u[x>>>20&15]+u[x>>>16&15]+u[x>>>12&15]+u[x>>>8&15]+u[x>>>4&15]+u[x&15]),R},N.prototype.toString=N.prototype.hex,N.prototype.digest=function(){this.finalize();var l=this.h0,g=this.h1,U=this.h2,v=this.h3,A=this.h4,y=this.h5,C=this.h6,x=this.h7,R=[l>>>24&255,l>>>16&255,l>>>8&255,l&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255,U>>>24&255,U>>>16&255,U>>>8&255,U&255,v>>>24&255,v>>>16&255,v>>>8&255,v&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255,y>>>24&255,y>>>16&255,y>>>8&255,y&255,C>>>24&255,C>>>16&255,C>>>8&255,C&255];return this.is224||R.push(x>>>24&255,x>>>16&255,x>>>8&255,x&255),R},N.prototype.array=N.prototype.digest,N.prototype.arrayBuffer=function(){this.finalize();var l=new ArrayBuffer(this.is224?28:32),g=new DataView(l);return g.setUint32(0,this.h0),g.setUint32(4,this.h1),g.setUint32(8,this.h2),g.setUint32(12,this.h3),g.setUint32(16,this.h4),g.setUint32(20,this.h5),g.setUint32(24,this.h6),this.is224||g.setUint32(28,this.h7),l};function ie(l,g,U){var v,A=typeof l;if(A==="string"){var y=[],C=l.length,x=0,R;for(v=0;v<C;++v)R=l.charCodeAt(v),R<128?y[x++]=R:R<2048?(y[x++]=192|R>>>6,y[x++]=128|R&63):R<55296||R>=57344?(y[x++]=224|R>>>12,y[x++]=128|R>>>6&63,y[x++]=128|R&63):(R=65536+((R&1023)<<10|l.charCodeAt(++v)&1023),y[x++]=240|R>>>18,y[x++]=128|R>>>12&63,y[x++]=128|R>>>6&63,y[x++]=128|R&63);l=y}else if(A==="object"){if(l===null)throw new Error(t);if(k&&l.constructor===ArrayBuffer)l=new Uint8Array(l);else if(!Array.isArray(l)&&(!k||!ArrayBuffer.isView(l)))throw new Error(t)}else throw new Error(t);l.length>64&&(l=new N(g,!0).update(l).array());var P=[],H=[];for(v=0;v<64;++v){var j=l[v]||0;P[v]=92^j,H[v]=54^j}N.call(this,g,U),this.update(H),this.oKeyPad=P,this.inner=!0,this.sharedMemory=U}ie.prototype=new N,ie.prototype.finalize=function(){if(N.prototype.finalize.call(this),this.inner){this.inner=!1;var l=this.array();N.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(l),N.prototype.finalize.call(this)}};var V=ce();V.sha256=V,V.sha224=ce(!0),V.sha256.hmac=q(),V.sha224.hmac=q(!0),a?ye.exports=V:(r.sha256=V.sha256,r.sha224=V.sha224,c&&define(function(){return V}))})()});var ur=lr(cr(),1);var se=class extends Error{};se.prototype.name="InvalidTokenError";function Vr(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,r)=>{let n=r.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}function zr(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return Vr(e)}catch{return atob(e)}}function ge(t,e){if(typeof t!="string")throw new se("Invalid token specified: must be a string");e||(e={});let r=e.header===!0?0:1,n=t.split(".")[r];if(typeof n!="string")throw new se(`Invalid token specified: missing part #${r+1}`);let o;try{o=zr(n)}catch(a){throw new se(`Invalid token specified: invalid base64 for part #${r+1} (${a.message})`)}try{return JSON.parse(o)}catch(a){throw new se(`Invalid token specified: invalid json for part #${r+1} (${a.message})`)}}if(typeof Promise>"u")throw Error("Keycloak requires an environment that supports Promises. Make sure that you include the appropriate polyfill.");function Le(t){if(!(this instanceof Le))throw new Error("The 'Keycloak' constructor must be invoked with 'new'.");for(var e=this,r,n=[],o,a={enable:!0,callbackList:[],interval:5},c=document.getElementsByTagName("script"),k=0;k<c.length;k++)(c[k].src.indexOf("keycloak.js")!==-1||c[k].src.indexOf("keycloak.min.js")!==-1)&&c[k].src.indexOf("version=")!==-1&&(e.iframeVersion=c[k].src.substring(c[k].src.indexOf("version=")+8).split("&")[0]);var u=!0,_=G(console.info),S=G(console.warn);e.init=function(i){if(e.didInitialize)throw new Error("A 'Keycloak' instance can only be initialized once.");e.didInitialize=!0,e.authenticated=!1,o=L();var s=["default","cordova","cordova-native"];if(i&&s.indexOf(i.adapter)>-1?r=H(i.adapter):i&&typeof i.adapter=="object"?r=i.adapter:window.Cordova||window.cordova?r=H("cordova"):r=H(),i){if(typeof i.useNonce<"u"&&(u=i.useNonce),typeof i.checkLoginIframe<"u"&&(a.enable=i.checkLoginIframe),i.checkLoginIframeInterval&&(a.interval=i.checkLoginIframeInterval),i.onLoad==="login-required"&&(e.loginRequired=!0),i.responseMode)if(i.responseMode==="query"||i.responseMode==="fragment")e.responseMode=i.responseMode;else throw"Invalid value for responseMode";if(i.flow){switch(i.flow){case"standard":e.responseType="code";break;case"implicit":e.responseType="id_token token";break;case"hybrid":e.responseType="code id_token token";break;default:throw"Invalid value for flow"}e.flow=i.flow}if(i.timeSkew!=null&&(e.timeSkew=i.timeSkew),i.redirectUri&&(e.redirectUri=i.redirectUri),i.silentCheckSsoRedirectUri&&(e.silentCheckSsoRedirectUri=i.silentCheckSsoRedirectUri),typeof i.silentCheckSsoFallback=="boolean"?e.silentCheckSsoFallback=i.silentCheckSsoFallback:e.silentCheckSsoFallback=!0,typeof i.pkceMethod<"u"){if(i.pkceMethod!=="S256"&&i.pkceMethod!==!1)throw new TypeError(`Invalid value for pkceMethod', expected 'S256' or false but got ${i.pkceMethod}.`);e.pkceMethod=i.pkceMethod}else e.pkceMethod="S256";typeof i.enableLogging=="boolean"?e.enableLogging=i.enableLogging:e.enableLogging=!1,i.logoutMethod==="POST"?e.logoutMethod="POST":e.logoutMethod="GET",typeof i.scope=="string"&&(e.scope=i.scope),typeof i.acrValues=="string"&&(e.acrValues=i.acrValues),typeof i.messageReceiveTimeout=="number"&&i.messageReceiveTimeout>0?e.messageReceiveTimeout=i.messageReceiveTimeout:e.messageReceiveTimeout=1e4}e.responseMode||(e.responseMode="fragment"),e.responseType||(e.responseType="code",e.flow="standard");var d=A(),m=A();m.promise.then(function(){e.onReady&&e.onReady(e.authenticated),d.setSuccess(e.authenticated)}).catch(function(b){d.setError(b)});var h=N();function E(){var b=function(M){M||(T.prompt="none"),i&&i.locale&&(T.locale=i.locale),e.login(T).then(function(){m.setSuccess()}).catch(function(Q){m.setError(Q)})},F=function(){var M=document.createElement("iframe"),Q=e.createLoginUrl({prompt:"none",redirectUri:e.silentCheckSsoRedirectUri});M.setAttribute("src",Q),M.setAttribute("sandbox","allow-storage-access-by-user-activation allow-scripts allow-same-origin"),M.setAttribute("title","keycloak-silent-check-sso"),M.style.display="none",document.body.appendChild(M);var ne=function(W){if(!(W.origin!==window.location.origin||M.contentWindow!==W.source)){var le=g(W.data);q(le,m),document.body.removeChild(M),window.removeEventListener("message",ne)}};window.addEventListener("message",ne)},T={};switch(i.onLoad){case"check-sso":a.enable?C().then(function(){R().then(function(M){M?m.setSuccess():e.silentCheckSsoRedirectUri?F():b(!1)}).catch(function(M){m.setError(M)})}):e.silentCheckSsoRedirectUri?F():b(!1);break;case"login-required":b(!0);break;default:throw"Invalid value for onLoad"}}function p(){var b=g(window.location.href);if(b&&window.history.replaceState(window.history.state,null,b.newUrl),b&&b.valid)return C().then(function(){q(b,m)}).catch(function(F){m.setError(F)});i?i.token&&i.refreshToken?(V(i.token,i.refreshToken,i.idToken),a.enable?C().then(function(){R().then(function(F){F?(e.onAuthSuccess&&e.onAuthSuccess(),m.setSuccess(),x()):m.setSuccess()}).catch(function(F){m.setError(F)})}):e.updateToken(-1).then(function(){e.onAuthSuccess&&e.onAuthSuccess(),m.setSuccess()}).catch(function(F){e.onAuthError&&e.onAuthError(),i.onLoad?E():m.setError(F)})):i.onLoad?E():m.setSuccess():m.setSuccess()}function w(){var b=A(),F=function(){(document.readyState==="interactive"||document.readyState==="complete")&&(document.removeEventListener("readystatechange",F),b.setSuccess())};return document.addEventListener("readystatechange",F),F(),b.promise}return h.then(function(){w().then(P).then(p).catch(function(b){d.setError(b)})}),h.catch(function(b){d.setError(b)}),d.promise},e.login=function(i){return r.login(i)};function I(i){var s=null,d=window.crypto||window.msCrypto;if(d&&d.getRandomValues&&window.Uint8Array)return s=new Uint8Array(i),d.getRandomValues(s),s;s=new Array(i);for(var m=0;m<s.length;m++)s[m]=Math.floor(256*Math.random());return s}function D(i){return B(i,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")}function B(i,s){for(var d=I(i),m=new Array(i),h=0;h<i;h++)m[h]=s.charCodeAt(d[h]%s.length);return String.fromCharCode.apply(null,m)}function $(i,s){if(i!=="S256")throw new TypeError(`Invalid value for 'pkceMethod', expected 'S256' but got '${i}'.`);let d=new Uint8Array(ur.default.arrayBuffer(s));return Jr(d).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}function ce(i){var s={id_token:{acr:i}};return JSON.stringify(s)}e.createLoginUrl=function(i){var s=l(),d=l(),m=r.redirectUri(i),h={state:s,nonce:d,redirectUri:encodeURIComponent(m),loginOptions:i};i&&i.prompt&&(h.prompt=i.prompt);var E;i&&i.action=="register"?E=e.endpoints.register():E=e.endpoints.authorize();var p=i&&i.scope||e.scope;p?p.indexOf("openid")===-1&&(p="openid "+p):p="openid";var w=E+"?client_id="+encodeURIComponent(e.clientId)+"&redirect_uri="+encodeURIComponent(m)+"&state="+encodeURIComponent(s)+"&response_mode="+encodeURIComponent(e.responseMode)+"&response_type="+encodeURIComponent(e.responseType)+"&scope="+encodeURIComponent(p);if(u&&(w=w+"&nonce="+encodeURIComponent(d)),i&&i.prompt&&(w+="&prompt="+encodeURIComponent(i.prompt)),i&&i.maxAge&&(w+="&max_age="+encodeURIComponent(i.maxAge)),i&&i.loginHint&&(w+="&login_hint="+encodeURIComponent(i.loginHint)),i&&i.idpHint&&(w+="&kc_idp_hint="+encodeURIComponent(i.idpHint)),i&&i.action&&i.action!="register"&&(w+="&kc_action="+encodeURIComponent(i.action)),i&&i.locale&&(w+="&ui_locales="+encodeURIComponent(i.locale)),i&&i.acr){var b=ce(i.acr);w+="&claims="+encodeURIComponent(b)}if((i&&i.acrValues||e.acrValues)&&(w+="&acr_values="+encodeURIComponent(i.acrValues||e.acrValues)),e.pkceMethod){var F=D(96);h.pkceCodeVerifier=F;var T=$(e.pkceMethod,F);w+="&code_challenge="+T,w+="&code_challenge_method="+e.pkceMethod}return o.add(h),w},e.logout=function(i){return r.logout(i)},e.createLogoutUrl=function(i){if((i?.logoutMethod??e.logoutMethod)==="POST")return e.endpoints.logout();var d=e.endpoints.logout()+"?client_id="+encodeURIComponent(e.clientId)+"&post_logout_redirect_uri="+encodeURIComponent(r.redirectUri(i,!1));return e.idToken&&(d+="&id_token_hint="+encodeURIComponent(e.idToken)),d},e.register=function(i){return r.register(i)},e.createRegisterUrl=function(i){return i||(i={}),i.action="register",e.createLoginUrl(i)},e.createAccountUrl=function(i){var s=X(),d=void 0;return typeof s<"u"&&(d=s+"/account?referrer="+encodeURIComponent(e.clientId)+"&referrer_uri="+encodeURIComponent(r.redirectUri(i))),d},e.accountManagement=function(){return r.accountManagement()},e.hasRealmRole=function(i){var s=e.realmAccess;return!!s&&s.roles.indexOf(i)>=0},e.hasResourceRole=function(i,s){if(!e.resourceAccess)return!1;var d=e.resourceAccess[s||e.clientId];return!!d&&d.roles.indexOf(i)>=0},e.loadUserProfile=function(){var i=X()+"/account",s=new XMLHttpRequest;s.open("GET",i,!0),s.setRequestHeader("Accept","application/json"),s.setRequestHeader("Authorization","bearer "+e.token);var d=A();return s.onreadystatechange=function(){s.readyState==4&&(s.status==200?(e.profile=JSON.parse(s.responseText),d.setSuccess(e.profile)):d.setError())},s.send(),d.promise},e.loadUserInfo=function(){var i=e.endpoints.userinfo(),s=new XMLHttpRequest;s.open("GET",i,!0),s.setRequestHeader("Accept","application/json"),s.setRequestHeader("Authorization","bearer "+e.token);var d=A();return s.onreadystatechange=function(){s.readyState==4&&(s.status==200?(e.userInfo=JSON.parse(s.responseText),d.setSuccess(e.userInfo)):d.setError())},s.send(),d.promise},e.isTokenExpired=function(i){if(!e.tokenParsed||!e.refreshToken&&e.flow!="implicit")throw"Not authenticated";if(e.timeSkew==null)return _("[KEYCLOAK] Unable to determine if token is expired as timeskew is not set"),!0;var s=e.tokenParsed.exp-Math.ceil(new Date().getTime()/1e3)+e.timeSkew;if(i){if(isNaN(i))throw"Invalid minValidity";s-=i}return s<0},e.updateToken=function(i){var s=A();if(!e.refreshToken)return s.setError(),s.promise;i=i||5;var d=function(){var h=!1;if(i==-1?(h=!0,_("[KEYCLOAK] Refreshing token: forced refresh")):(!e.tokenParsed||e.isTokenExpired(i))&&(h=!0,_("[KEYCLOAK] Refreshing token: token expired")),!h)s.setSuccess(!1);else{var E="grant_type=refresh_token&refresh_token="+e.refreshToken,p=e.endpoints.token();if(n.push(s),n.length==1){var w=new XMLHttpRequest;w.open("POST",p,!0),w.setRequestHeader("Content-type","application/x-www-form-urlencoded"),w.withCredentials=!0,E+="&client_id="+encodeURIComponent(e.clientId);var b=new Date().getTime();w.onreadystatechange=function(){if(w.readyState==4)if(w.status==200){_("[KEYCLOAK] Token refreshed"),b=(b+new Date().getTime())/2;var F=JSON.parse(w.responseText);V(F.access_token,F.refresh_token,F.id_token,b),e.onAuthRefreshSuccess&&e.onAuthRefreshSuccess();for(var T=n.pop();T!=null;T=n.pop())T.setSuccess(!0)}else{S("[KEYCLOAK] Failed to refresh token"),w.status==400&&e.clearToken(),e.onAuthRefreshError&&e.onAuthRefreshError();for(var T=n.pop();T!=null;T=n.pop())T.setError(!0)}},w.send(E)}}};if(a.enable){var m=R();m.then(function(){d()}).catch(function(h){s.setError(h)})}else d();return s.promise},e.clearToken=function(){e.token&&(V(null,null,null),e.onAuthLogout&&e.onAuthLogout(),e.loginRequired&&e.login())};function X(){if(typeof e.authServerUrl<"u")return e.authServerUrl.charAt(e.authServerUrl.length-1)=="/"?e.authServerUrl+"realms/"+encodeURIComponent(e.realm):e.authServerUrl+"/realms/"+encodeURIComponent(e.realm)}function pe(){return window.location.origin?window.location.origin:window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"")}function q(i,s){var d=i.code,m=i.error,h=i.prompt,E=new Date().getTime();if(i.kc_action_status&&e.onActionUpdate&&e.onActionUpdate(i.kc_action_status),m){if(h!="none")if(i.error_description&&i.error_description==="authentication_expired")e.login(i.loginOptions);else{var p={error:m,error_description:i.error_description};e.onAuthError&&e.onAuthError(p),s&&s.setError(p)}else s&&s.setSuccess();return}else e.flow!="standard"&&(i.access_token||i.id_token)&&T(i.access_token,null,i.id_token,!0);if(e.flow!="implicit"&&d){var w="code="+d+"&grant_type=authorization_code",b=e.endpoints.token(),F=new XMLHttpRequest;F.open("POST",b,!0),F.setRequestHeader("Content-type","application/x-www-form-urlencoded"),w+="&client_id="+encodeURIComponent(e.clientId),w+="&redirect_uri="+i.redirectUri,i.pkceCodeVerifier&&(w+="&code_verifier="+i.pkceCodeVerifier),F.withCredentials=!0,F.onreadystatechange=function(){if(F.readyState==4)if(F.status==200){var M=JSON.parse(F.responseText);T(M.access_token,M.refresh_token,M.id_token,e.flow==="standard"),x()}else e.onAuthError&&e.onAuthError(),s&&s.setError()},F.send(w)}function T(M,Q,ne,W){E=(E+new Date().getTime())/2,V(M,Q,ne,E),u&&e.idTokenParsed&&e.idTokenParsed.nonce!=i.storedNonce?(_("[KEYCLOAK] Invalid nonce, clearing token"),e.clearToken(),s&&s.setError()):W&&(e.onAuthSuccess&&e.onAuthSuccess(),s&&s.setSuccess())}}function N(i){var s=A(),d;t?typeof t=="string"&&(d=t):d="keycloak.json";function m(F){F?e.endpoints={authorize:function(){return F.authorization_endpoint},token:function(){return F.token_endpoint},logout:function(){if(!F.end_session_endpoint)throw"Not supported by the OIDC server";return F.end_session_endpoint},checkSessionIframe:function(){if(!F.check_session_iframe)throw"Not supported by the OIDC server";return F.check_session_iframe},register:function(){throw'Redirection to "Register user" page not supported in standard OIDC mode'},userinfo:function(){if(!F.userinfo_endpoint)throw"Not supported by the OIDC server";return F.userinfo_endpoint}}:e.endpoints={authorize:function(){return X()+"/protocol/openid-connect/auth"},token:function(){return X()+"/protocol/openid-connect/token"},logout:function(){return X()+"/protocol/openid-connect/logout"},checkSessionIframe:function(){var T=X()+"/protocol/openid-connect/login-status-iframe.html";return e.iframeVersion&&(T=T+"?version="+e.iframeVersion),T},thirdPartyCookiesIframe:function(){var T=X()+"/protocol/openid-connect/3p-cookies/step1.html";return e.iframeVersion&&(T=T+"?version="+e.iframeVersion),T},register:function(){return X()+"/protocol/openid-connect/registrations"},userinfo:function(){return X()+"/protocol/openid-connect/userinfo"}}}if(d){var h=new XMLHttpRequest;h.open("GET",d,!0),h.setRequestHeader("Accept","application/json"),h.onreadystatechange=function(){if(h.readyState==4)if(h.status==200||ie(h)){var F=JSON.parse(h.responseText);e.authServerUrl=F["auth-server-url"],e.realm=F.realm,e.clientId=F.resource,m(null),s.setSuccess()}else s.setError()},h.send()}else{if(!t.clientId)throw"clientId missing";e.clientId=t.clientId;var E=t.oidcProvider;if(E)if(typeof E=="string"){var b;E.charAt(E.length-1)=="/"?b=E+".well-known/openid-configuration":b=E+"/.well-known/openid-configuration";var h=new XMLHttpRequest;h.open("GET",b,!0),h.setRequestHeader("Accept","application/json"),h.onreadystatechange=function(){if(h.readyState==4)if(h.status==200||ie(h)){var T=JSON.parse(h.responseText);m(T),s.setSuccess()}else s.setError()},h.send()}else m(E),s.setSuccess();else{if(!t.url){for(var p=document.getElementsByTagName("script"),w=0;w<p.length;w++)if(p[w].src.match(/.*keycloak\.js/)){t.url=p[w].src.substr(0,p[w].src.indexOf("/js/keycloak.js"));break}}if(!t.realm)throw"realm missing";e.authServerUrl=t.url,e.realm=t.realm,m(null),s.setSuccess()}}return s.promise}function ie(i){return i.status==0&&i.responseText&&i.responseURL.startsWith("file:")}function V(i,s,d,m){if(e.tokenTimeoutHandle&&(clearTimeout(e.tokenTimeoutHandle),e.tokenTimeoutHandle=null),s?(e.refreshToken=s,e.refreshTokenParsed=ge(s)):(delete e.refreshToken,delete e.refreshTokenParsed),d?(e.idToken=d,e.idTokenParsed=ge(d)):(delete e.idToken,delete e.idTokenParsed),i){if(e.token=i,e.tokenParsed=ge(i),e.sessionId=e.tokenParsed.sid,e.authenticated=!0,e.subject=e.tokenParsed.sub,e.realmAccess=e.tokenParsed.realm_access,e.resourceAccess=e.tokenParsed.resource_access,m&&(e.timeSkew=Math.floor(m/1e3)-e.tokenParsed.iat),e.timeSkew!=null&&(_("[KEYCLOAK] Estimated time difference between browser and server is "+e.timeSkew+" seconds"),e.onTokenExpired)){var h=(e.tokenParsed.exp-new Date().getTime()/1e3+e.timeSkew)*1e3;_("[KEYCLOAK] Token expires in "+Math.round(h/1e3)+" s"),h<=0?e.onTokenExpired():e.tokenTimeoutHandle=setTimeout(e.onTokenExpired,h)}}else delete e.token,delete e.tokenParsed,delete e.subject,delete e.realmAccess,delete e.resourceAccess,e.authenticated=!1}function l(){var i="0123456789abcdef",s=B(36,i).split("");s[14]="4",s[19]=i.substr(s[19]&3|8,1),s[8]=s[13]=s[18]=s[23]="-";var d=s.join("");return d}function g(i){var s=U(i);if(s){var d=o.get(s.state);return d&&(s.valid=!0,s.redirectUri=d.redirectUri,s.storedNonce=d.nonce,s.prompt=d.prompt,s.pkceCodeVerifier=d.pkceCodeVerifier,s.loginOptions=d.loginOptions),s}}function U(i){var s;switch(e.flow){case"standard":s=["code","state","session_state","kc_action_status","iss"];break;case"implicit":s=["access_token","token_type","id_token","state","session_state","expires_in","kc_action_status","iss"];break;case"hybrid":s=["access_token","token_type","id_token","code","state","session_state","expires_in","kc_action_status","iss"];break}s.push("error"),s.push("error_description"),s.push("error_uri");var d=i.indexOf("?"),m=i.indexOf("#"),h,E;if(e.responseMode==="query"&&d!==-1?(h=i.substring(0,d),E=v(i.substring(d+1,m!==-1?m:i.length),s),E.paramsString!==""&&(h+="?"+E.paramsString),m!==-1&&(h+=i.substring(m))):e.responseMode==="fragment"&&m!==-1&&(h=i.substring(0,m),E=v(i.substring(m+1),s),E.paramsString!==""&&(h+="#"+E.paramsString)),E&&E.oauthParams){if(e.flow==="standard"||e.flow==="hybrid"){if((E.oauthParams.code||E.oauthParams.error)&&E.oauthParams.state)return E.oauthParams.newUrl=h,E.oauthParams}else if(e.flow==="implicit"&&(E.oauthParams.access_token||E.oauthParams.error)&&E.oauthParams.state)return E.oauthParams.newUrl=h,E.oauthParams}}function v(i,s){for(var d=i.split("&"),m={paramsString:"",oauthParams:{}},h=0;h<d.length;h++){var E=d[h].indexOf("="),p=d[h].slice(0,E);s.indexOf(p)!==-1?m.oauthParams[p]=d[h].slice(E+1):(m.paramsString!==""&&(m.paramsString+="&"),m.paramsString+=d[h])}return m}function A(){var i={setSuccess:function(s){i.resolve(s)},setError:function(s){i.reject(s)}};return i.promise=new Promise(function(s,d){i.resolve=s,i.reject=d}),i}function y(i,s,d){var m=null,h=new Promise(function(E,p){m=setTimeout(function(){p({error:d})},s)});return Promise.race([i,h]).finally(function(){clearTimeout(m)})}function C(){var i=A();if(!a.enable||a.iframe)return i.setSuccess(),i.promise;var s=document.createElement("iframe");a.iframe=s,s.onload=function(){var h=e.endpoints.authorize();h.charAt(0)==="/"?a.iframeOrigin=pe():a.iframeOrigin=h.substring(0,h.indexOf("/",8)),i.setSuccess()};var d=e.endpoints.checkSessionIframe();s.setAttribute("src",d),s.setAttribute("sandbox","allow-storage-access-by-user-activation allow-scripts allow-same-origin"),s.setAttribute("title","keycloak-session-iframe"),s.style.display="none",document.body.appendChild(s);var m=function(h){if(!(h.origin!==a.iframeOrigin||a.iframe.contentWindow!==h.source)&&(h.data=="unchanged"||h.data=="changed"||h.data=="error")){h.data!="unchanged"&&e.clearToken();for(var E=a.callbackList.splice(0,a.callbackList.length),p=E.length-1;p>=0;--p){var w=E[p];h.data=="error"?w.setError():w.setSuccess(h.data=="unchanged")}}};return window.addEventListener("message",m,!1),i.promise}function x(){a.enable&&e.token&&setTimeout(function(){R().then(function(i){i&&x()})},a.interval*1e3)}function R(){var i=A();if(a.iframe&&a.iframeOrigin){var s=e.clientId+" "+(e.sessionId?e.sessionId:"");a.callbackList.push(i);var d=a.iframeOrigin;a.callbackList.length==1&&a.iframe.contentWindow.postMessage(s,d)}else i.setSuccess();return i.promise}function P(){var i=A();if(a.enable||e.silentCheckSsoRedirectUri){var s=document.createElement("iframe");s.setAttribute("src",e.endpoints.thirdPartyCookiesIframe()),s.setAttribute("sandbox","allow-storage-access-by-user-activation allow-scripts allow-same-origin"),s.setAttribute("title","keycloak-3p-check-iframe"),s.style.display="none",document.body.appendChild(s);var d=function(m){s.contentWindow===m.source&&(m.data!=="supported"&&m.data!=="unsupported"||(m.data==="unsupported"&&(S(`[KEYCLOAK] Your browser is blocking access to 3rd-party cookies, this means:

 - It is not possible to retrieve tokens without redirecting to the Keycloak server (a.k.a. no support for silent authentication).
 - It is not possible to automatically detect changes to the session status (such as the user logging out in another tab).

For more information see: https://www.keycloak.org/docs/latest/securing_apps/#_modern_browsers`),a.enable=!1,e.silentCheckSsoFallback&&(e.silentCheckSsoRedirectUri=!1)),document.body.removeChild(s),window.removeEventListener("message",d),i.setSuccess()))};window.addEventListener("message",d,!1)}else i.setSuccess();return y(i.promise,e.messageReceiveTimeout,"Timeout when waiting for 3rd party check iframe message.")}function H(i){if(!i||i=="default")return{login:function(p){return window.location.assign(e.createLoginUrl(p)),A().promise},logout:function(p){return K(this,null,function*(){if((p?.logoutMethod??e.logoutMethod)==="GET"){window.location.replace(e.createLogoutUrl(p));return}let b=e.createLogoutUrl(p),F=yield fetch(b,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({id_token_hint:e.idToken,client_id:e.clientId,post_logout_redirect_uri:r.redirectUri(p,!1)})});if(F.redirected){window.location.href=F.url;return}if(F.ok){window.location.reload();return}throw new Error("Logout failed, request returned an error code.")})},register:function(p){return window.location.assign(e.createRegisterUrl(p)),A().promise},accountManagement:function(){var p=e.createAccountUrl();if(typeof p<"u")window.location.href=p;else throw"Not supported by the OIDC server";return A().promise},redirectUri:function(p,w){return p&&p.redirectUri?p.redirectUri:e.redirectUri?e.redirectUri:location.href}};if(i=="cordova"){a.enable=!1;var s=function(p,w,b){return window.cordova&&window.cordova.InAppBrowser?window.cordova.InAppBrowser.open(p,w,b):window.open(p,w,b)},d=function(p){return p&&p.cordovaOptions?Object.keys(p.cordovaOptions).reduce(function(w,b){return w[b]=p.cordovaOptions[b],w},{}):{}},m=function(p){return Object.keys(p).reduce(function(w,b){return w.push(b+"="+p[b]),w},[]).join(",")},h=function(p){var w=d(p);return w.location="no",p&&p.prompt=="none"&&(w.hidden="yes"),m(w)},E=function(){return e.redirectUri||"http://localhost"};return{login:function(p){var w=A(),b=h(p),F=e.createLoginUrl(p),T=s(F,"_blank",b),M=!1,Q=!1,ne=function(){Q=!0,T.close()};return T.addEventListener("loadstart",function(W){if(W.url.indexOf(E())==0){var le=g(W.url);q(le,w),ne(),M=!0}}),T.addEventListener("loaderror",function(W){if(!M)if(W.url.indexOf(E())==0){var le=g(W.url);q(le,w),ne(),M=!0}else w.setError(),ne()}),T.addEventListener("exit",function(W){Q||w.setError({reason:"closed_by_user"})}),w.promise},logout:function(p){var w=A(),b=e.createLogoutUrl(p),F=s(b,"_blank","location=no,hidden=yes,clearcache=yes"),T;return F.addEventListener("loadstart",function(M){M.url.indexOf(E())==0&&F.close()}),F.addEventListener("loaderror",function(M){M.url.indexOf(E())==0||(T=!0),F.close()}),F.addEventListener("exit",function(M){T?w.setError():(e.clearToken(),w.setSuccess())}),w.promise},register:function(p){var w=A(),b=e.createRegisterUrl(),F=h(p),T=s(b,"_blank",F);return T.addEventListener("loadstart",function(M){if(M.url.indexOf(E())==0){T.close();var Q=g(M.url);q(Q,w)}}),w.promise},accountManagement:function(){var p=e.createAccountUrl();if(typeof p<"u"){var w=s(p,"_blank","location=no");w.addEventListener("loadstart",function(b){b.url.indexOf(E())==0&&w.close()})}else throw"Not supported by the OIDC server"},redirectUri:function(p){return E()}}}if(i=="cordova-native")return a.enable=!1,{login:function(p){var w=A(),b=e.createLoginUrl(p);return universalLinks.subscribe("keycloak",function(F){universalLinks.unsubscribe("keycloak"),window.cordova.plugins.browsertab.close();var T=g(F.url);q(T,w)}),window.cordova.plugins.browsertab.openUrl(b),w.promise},logout:function(p){var w=A(),b=e.createLogoutUrl(p);return universalLinks.subscribe("keycloak",function(F){universalLinks.unsubscribe("keycloak"),window.cordova.plugins.browsertab.close(),e.clearToken(),w.setSuccess()}),window.cordova.plugins.browsertab.openUrl(b),w.promise},register:function(p){var w=A(),b=e.createRegisterUrl(p);return universalLinks.subscribe("keycloak",function(F){universalLinks.unsubscribe("keycloak"),window.cordova.plugins.browsertab.close();var T=g(F.url);q(T,w)}),window.cordova.plugins.browsertab.openUrl(b),w.promise},accountManagement:function(){var p=e.createAccountUrl();if(typeof p<"u")window.cordova.plugins.browsertab.openUrl(p);else throw"Not supported by the OIDC server"},redirectUri:function(p){return p&&p.redirectUri?p.redirectUri:e.redirectUri?e.redirectUri:"http://localhost"}};throw"invalid adapter type: "+i}var j=function(){if(!(this instanceof j))return new j;localStorage.setItem("kc-test","test"),localStorage.removeItem("kc-test");var i=this;function s(){for(var d=new Date().getTime(),m=0;m<localStorage.length;m++){var h=localStorage.key(m);if(h&&h.indexOf("kc-callback-")==0){var E=localStorage.getItem(h);if(E)try{var p=JSON.parse(E).expires;(!p||p<d)&&localStorage.removeItem(h)}catch{localStorage.removeItem(h)}}}}i.get=function(d){if(d){var m="kc-callback-"+d,h=localStorage.getItem(m);return h&&(localStorage.removeItem(m),h=JSON.parse(h)),s(),h}},i.add=function(d){s();var m="kc-callback-"+d.state;d.expires=new Date().getTime()+60*60*1e3,localStorage.setItem(m,JSON.stringify(d))}},J=function(){if(!(this instanceof J))return new J;var i=this;i.get=function(h){if(h){var E=d("kc-callback-"+h);if(m("kc-callback-"+h,"",s(-100)),E)return JSON.parse(E)}},i.add=function(h){m("kc-callback-"+h.state,JSON.stringify(h),s(60))},i.removeItem=function(h){m(h,"",s(-100))};var s=function(h){var E=new Date;return E.setTime(E.getTime()+h*60*1e3),E},d=function(h){for(var E=h+"=",p=document.cookie.split(";"),w=0;w<p.length;w++){for(var b=p[w];b.charAt(0)==" ";)b=b.substring(1);if(b.indexOf(E)==0)return b.substring(E.length,b.length)}return""},m=function(h,E,p){var w=h+"="+E+"; expires="+p.toUTCString()+"; ";document.cookie=w}};function L(){try{return new j}catch{}return new J}function G(i){return function(){e.enableLogging&&i.apply(console,Array.prototype.slice.call(arguments))}}}function Jr(t){let e=String.fromCodePoint(...t);return btoa(e)}var te=function(t){return t[t.OnAuthError=0]="OnAuthError",t[t.OnAuthLogout=1]="OnAuthLogout",t[t.OnAuthRefreshError=2]="OnAuthRefreshError",t[t.OnAuthRefreshSuccess=3]="OnAuthRefreshSuccess",t[t.OnAuthSuccess=4]="OnAuthSuccess",t[t.OnReady=5]="OnReady",t[t.OnTokenExpired=6]="OnTokenExpired",t[t.OnActionUpdate=7]="OnActionUpdate",t}(te||{}),fr=class{constructor(e,r){this.router=e,this.keycloakAngular=r}canActivate(e,r){return K(this,null,function*(){try{return this.authenticated=yield this.keycloakAngular.isLoggedIn(),this.roles=yield this.keycloakAngular.getUserRoles(!0),yield this.isAccessAllowed(e,r)}catch(n){throw new Error("An error happened during access validation. Details:"+n)}})}},ve=(()=>{class t{constructor(){this._keycloakEvents$=new Me}bindsKeycloakEvents(){this._instance.onAuthError=r=>{this._keycloakEvents$.next({args:r,type:te.OnAuthError})},this._instance.onAuthLogout=()=>{this._keycloakEvents$.next({type:te.OnAuthLogout})},this._instance.onAuthRefreshSuccess=()=>{this._keycloakEvents$.next({type:te.OnAuthRefreshSuccess})},this._instance.onAuthRefreshError=()=>{this._keycloakEvents$.next({type:te.OnAuthRefreshError})},this._instance.onAuthSuccess=()=>{this._keycloakEvents$.next({type:te.OnAuthSuccess})},this._instance.onTokenExpired=()=>{this._keycloakEvents$.next({type:te.OnTokenExpired})},this._instance.onActionUpdate=r=>{this._keycloakEvents$.next({args:r,type:te.OnActionUpdate})},this._instance.onReady=r=>{this._keycloakEvents$.next({args:r,type:te.OnReady})}}loadExcludedUrls(r){let n=[];for(let o of r){let a;typeof o=="string"?a={urlPattern:new RegExp(o,"i"),httpMethods:[]}:a={urlPattern:new RegExp(o.url,"i"),httpMethods:o.httpMethods},n.push(a)}return n}initServiceValues({enableBearerInterceptor:r=!0,loadUserProfileAtStartUp:n=!1,bearerExcludedUrls:o=[],authorizationHeaderName:a="Authorization",bearerPrefix:c="Bearer",initOptions:k,updateMinValidity:u=20,shouldAddToken:_=()=>!0,shouldUpdateToken:S=()=>!0}){this._enableBearerInterceptor=r,this._loadUserProfileAtStartUp=n,this._authorizationHeaderName=a,this._bearerPrefix=c.trim().concat(" "),this._excludedUrls=this.loadExcludedUrls(o),this._silentRefresh=k?k.flow==="implicit":!1,this._updateMinValidity=u,this.shouldAddToken=_,this.shouldUpdateToken=S}init(){return K(this,arguments,function*(r={}){this.initServiceValues(r);let{config:n,initOptions:o}=r;this._instance=new Le(n),this.bindsKeycloakEvents();let a=yield this._instance.init(o);return a&&this._loadUserProfileAtStartUp&&(yield this.loadUserProfile()),a})}login(){return K(this,arguments,function*(r={}){yield this._instance.login(r),this._loadUserProfileAtStartUp&&(yield this.loadUserProfile())})}logout(r){return K(this,null,function*(){let n={redirectUri:r};yield this._instance.logout(n),this._userProfile=void 0})}register(){return K(this,arguments,function*(r={action:"register"}){yield this._instance.register(r)})}isUserInRole(r,n){let o;return o=this._instance.hasResourceRole(r,n),o||(o=this._instance.hasRealmRole(r)),o}getUserRoles(r=!0,n){let o=[];if(this._instance.resourceAccess&&Object.keys(this._instance.resourceAccess).forEach(a=>{if(n&&n!==a)return;let k=this._instance.resourceAccess[a].roles||[];o=o.concat(k)}),r&&this._instance.realmAccess){let a=this._instance.realmAccess.roles||[];o.push(...a)}return o}isLoggedIn(){return this._instance?this._instance.authenticated:!1}isTokenExpired(r=0){return this._instance.isTokenExpired(r)}updateToken(){return K(this,arguments,function*(r=this._updateMinValidity){if(this._silentRefresh){if(this.isTokenExpired())throw new Error("Failed to refresh the token, or the session is expired");return!0}if(!this._instance)throw new Error("Keycloak Angular library is not initialized.");try{return yield this._instance.updateToken(r)}catch{return!1}})}loadUserProfile(r=!1){return K(this,null,function*(){if(this._userProfile&&!r)return this._userProfile;if(!this._instance.authenticated)throw new Error("The user profile was not loaded as the user is not logged in.");return this._userProfile=yield this._instance.loadUserProfile()})}getToken(){return K(this,null,function*(){return this._instance.token})}getUsername(){if(!this._userProfile)throw new Error("User not logged in or user profile was not loaded.");return this._userProfile.username}clearToken(){this._instance.clearToken()}addTokenToHeader(r=new Ve){return ke(this.getToken()).pipe(Ne(n=>n?r.set(this._authorizationHeaderName,this._bearerPrefix+n):r))}getKeycloakInstance(){return this._instance}get excludedUrls(){return this._excludedUrls}get enableBearerInterceptor(){return this._enableBearerInterceptor}get keycloakEvents$(){return this._keycloakEvents$}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275prov=de({token:t,factory:t.\u0275fac})}}return t})(),Kr=(()=>{class t{constructor(r){this.keycloak=r}conditionallyUpdateToken(r){return K(this,null,function*(){return this.keycloak.shouldUpdateToken(r)?yield this.keycloak.updateToken():!0})}isUrlExcluded({method:r,url:n},{urlPattern:o,httpMethods:a}){let c=a.length===0||a.join().indexOf(r.toUpperCase())>-1,k=o.test(n);return c&&k}intercept(r,n){let{enableBearerInterceptor:o,excludedUrls:a}=this.keycloak;return!o||!this.keycloak.shouldAddToken(r)||a.findIndex(k=>this.isUrlExcluded(r,k))>-1?n.handle(r):De([ke(this.conditionallyUpdateToken(r)),Pe(this.keycloak.isLoggedIn())]).pipe(Ee(([k,u])=>u?this.handleRequestWithTokenHeader(r,n):n.handle(r)))}handleRequestWithTokenHeader(r,n){return this.keycloak.addTokenToHeader(r.headers).pipe(Ee(o=>{let a=r.clone({headers:o});return n.handle(a)}))}static{this.\u0275fac=function(n){return new(n||t)(Oe(ve))}}static{this.\u0275prov=de({token:t,factory:t.\u0275fac})}}return t})(),Yr=(()=>{class t{static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275mod=Fe({type:t})}static{this.\u0275inj=Ae({providers:[ve,{provide:ze,useClass:Kr,multi:!0}],imports:[je]})}}return t})(),ut=(()=>{class t{static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275mod=Fe({type:t})}static{this.\u0275inj=Ae({imports:[Yr]})}}return t})();var xt=(()=>{class t{constructor(){this.keycloakService=He(ve)}login(r){this.keycloakService.login(r).catch(n=>console.log(n))}logout(r){this.keycloakService.logout(r).catch(n=>console.error(n))}isLoggedIn(){return this.keycloakService.isLoggedIn()}isCompanyAdministrator(){return this.keycloakService.isUserInRole("COMPANY_ADMINISTRATOR")}isCompanyCampaignManager(){return this.keycloakService.isUserInRole("CAMPAIGN_MANAGER")}isCompanyReporter(){return this.keycloakService.isUserInRole("REPORTER")}isWhiteLabelUser(){return this.keycloakService.isUserInRole("WHITE_LABEL_USER")}canModifyCampaign(){return this.isCompanyCampaignManager()||this.isCompanyAdministrator()||this.isWhiteLabelUser()}canSeeCampaignDetails(){return this.isCompanyCampaignManager()||this.isCompanyAdministrator()||this.isCompanyReporter()||this.isWhiteLabelUser()}canSeeCompany(){return this.isCompanyAdministrator()}canCreateCompanyUser(){return this.isCompanyAdministrator()}canDeleteCompanyUser(){return this.isCompanyAdministrator()}getToken(){return this.keycloakService.getToken()}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275prov=de({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();export{fr as a,ve as b,ut as c,xt as d};
