@eka-care/apollo-assist 0.1.45-dev.0 → 0.1.45-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/widget.js +2 -2
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -346,7 +346,7 @@ You might need to use a local HTTP server (instead of file://): https://react.de
|
|
|
346
346
|
JSZip uses the library pako released under the MIT license :
|
|
347
347
|
https://github.com/nodeca/pako/blob/main/LICENSE
|
|
348
348
|
*/var hy;function tI(){return hy||(hy=1,function(n,a){(function(i){n.exports=i()})(function(){return function i(l,u,f){function c(g,A){if(!u[g]){if(!l[g]){var m=typeof Yu=="function"&&Yu;if(!A&&m)return m(g,!0);if(d)return d(g,!0);var y=new Error("Cannot find module '"+g+"'");throw y.code="MODULE_NOT_FOUND",y}var E=u[g]={exports:{}};l[g][0].call(E.exports,function(C){var x=l[g][1][C];return c(x||C)},E,E.exports,i,l,u,f)}return u[g].exports}for(var d=typeof Yu=="function"&&Yu,p=0;p<f.length;p++)c(f[p]);return c}({1:[function(i,l,u){var f=i("./utils"),c=i("./support"),d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";u.encode=function(p){for(var g,A,m,y,E,C,x,w=[],v=0,D=p.length,B=D,z=f.getTypeOf(p)!=="string";v<p.length;)B=D-v,m=z?(g=p[v++],A=v<D?p[v++]:0,v<D?p[v++]:0):(g=p.charCodeAt(v++),A=v<D?p.charCodeAt(v++):0,v<D?p.charCodeAt(v++):0),y=g>>2,E=(3&g)<<4|A>>4,C=1<B?(15&A)<<2|m>>6:64,x=2<B?63&m:64,w.push(d.charAt(y)+d.charAt(E)+d.charAt(C)+d.charAt(x));return w.join("")},u.decode=function(p){var g,A,m,y,E,C,x=0,w=0,v="data:";if(p.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var D,B=3*(p=p.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(p.charAt(p.length-1)===d.charAt(64)&&B--,p.charAt(p.length-2)===d.charAt(64)&&B--,B%1!=0)throw new Error("Invalid base64 input, bad content length.");for(D=c.uint8array?new Uint8Array(0|B):new Array(0|B);x<p.length;)g=d.indexOf(p.charAt(x++))<<2|(y=d.indexOf(p.charAt(x++)))>>4,A=(15&y)<<4|(E=d.indexOf(p.charAt(x++)))>>2,m=(3&E)<<6|(C=d.indexOf(p.charAt(x++))),D[w++]=g,E!==64&&(D[w++]=A),C!==64&&(D[w++]=m);return D}},{"./support":30,"./utils":32}],2:[function(i,l,u){var f=i("./external"),c=i("./stream/DataWorker"),d=i("./stream/Crc32Probe"),p=i("./stream/DataLengthProbe");function g(A,m,y,E,C){this.compressedSize=A,this.uncompressedSize=m,this.crc32=y,this.compression=E,this.compressedContent=C}g.prototype={getContentWorker:function(){var A=new c(f.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new p("data_length")),m=this;return A.on("end",function(){if(this.streamInfo.data_length!==m.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),A},getCompressedWorker:function(){return new c(f.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},g.createWorkerFrom=function(A,m,y){return A.pipe(new d).pipe(new p("uncompressedSize")).pipe(m.compressWorker(y)).pipe(new p("compressedSize")).withStreamInfo("compression",m)},l.exports=g},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(i,l,u){var f=i("./stream/GenericWorker");u.STORE={magic:"\0\0",compressWorker:function(){return new f("STORE compression")},uncompressWorker:function(){return new f("STORE decompression")}},u.DEFLATE=i("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(i,l,u){var f=i("./utils"),c=function(){for(var d,p=[],g=0;g<256;g++){d=g;for(var A=0;A<8;A++)d=1&d?3988292384^d>>>1:d>>>1;p[g]=d}return p}();l.exports=function(d,p){return d!==void 0&&d.length?f.getTypeOf(d)!=="string"?function(g,A,m,y){var E=c,C=y+m;g^=-1;for(var x=y;x<C;x++)g=g>>>8^E[255&(g^A[x])];return-1^g}(0|p,d,d.length,0):function(g,A,m,y){var E=c,C=y+m;g^=-1;for(var x=y;x<C;x++)g=g>>>8^E[255&(g^A.charCodeAt(x))];return-1^g}(0|p,d,d.length,0):0}},{"./utils":32}],5:[function(i,l,u){u.base64=!1,u.binary=!1,u.dir=!1,u.createFolders=!0,u.date=null,u.compression=null,u.compressionOptions=null,u.comment=null,u.unixPermissions=null,u.dosPermissions=null},{}],6:[function(i,l,u){var f=null;f=typeof Promise!="undefined"?Promise:i("lie"),l.exports={Promise:f}},{lie:37}],7:[function(i,l,u){var f=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Uint32Array!="undefined",c=i("pako"),d=i("./utils"),p=i("./stream/GenericWorker"),g=f?"uint8array":"array";function A(m,y){p.call(this,"FlateWorker/"+m),this._pako=null,this._pakoAction=m,this._pakoOptions=y,this.meta={}}u.magic="\b\0",d.inherits(A,p),A.prototype.processChunk=function(m){this.meta=m.meta,this._pako===null&&this._createPako(),this._pako.push(d.transformTo(g,m.data),!1)},A.prototype.flush=function(){p.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},A.prototype.cleanUp=function(){p.prototype.cleanUp.call(this),this._pako=null},A.prototype._createPako=function(){this._pako=new c[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var m=this;this._pako.onData=function(y){m.push({data:y,meta:m.meta})}},u.compressWorker=function(m){return new A("Deflate",m)},u.uncompressWorker=function(){return new A("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(i,l,u){function f(E,C){var x,w="";for(x=0;x<C;x++)w+=String.fromCharCode(255&E),E>>>=8;return w}function c(E,C,x,w,v,D){var B,z,P=E.file,N=E.compression,Z=D!==g.utf8encode,ie=d.transformTo("string",D(P.name)),F=d.transformTo("string",g.utf8encode(P.name)),K=P.comment,re=d.transformTo("string",D(K)),Q=d.transformTo("string",g.utf8encode(K)),q=F.length!==P.name.length,I=Q.length!==K.length,ue="",fe="",ce="",le=P.dir,ne=P.date,T={crc32:0,compressedSize:0,uncompressedSize:0};C&&!x||(T.crc32=E.crc32,T.compressedSize=E.compressedSize,T.uncompressedSize=E.uncompressedSize);var _=0;C&&(_|=8),Z||!q&&!I||(_|=2048);var V=0,U=0;le&&(V|=16),v==="UNIX"?(U=798,V|=function(be,Be){var Ke=be;return be||(Ke=Be?16893:33204),(65535&Ke)<<16}(P.unixPermissions,le)):(U=20,V|=function(be){return 63&(be||0)}(P.dosPermissions)),B=ne.getUTCHours(),B<<=6,B|=ne.getUTCMinutes(),B<<=5,B|=ne.getUTCSeconds()/2,z=ne.getUTCFullYear()-1980,z<<=4,z|=ne.getUTCMonth()+1,z<<=5,z|=ne.getUTCDate(),q&&(fe=f(1,1)+f(A(ie),4)+F,ue+="up"+f(fe.length,2)+fe),I&&(ce=f(1,1)+f(A(re),4)+Q,ue+="uc"+f(ce.length,2)+ce);var he="";return he+=`
|
|
349
|
-
\0`,he+=f(_,2),he+=N.magic,he+=f(B,2),he+=f(z,2),he+=f(T.crc32,4),he+=f(T.compressedSize,4),he+=f(T.uncompressedSize,4),he+=f(ie.length,2),he+=f(ue.length,2),{fileRecord:m.LOCAL_FILE_HEADER+he+ie+ue,dirRecord:m.CENTRAL_FILE_HEADER+f(U,2)+he+f(re.length,2)+"\0\0\0\0"+f(V,4)+f(w,4)+ie+ue+re}}var d=i("../utils"),p=i("../stream/GenericWorker"),g=i("../utf8"),A=i("../crc32"),m=i("../signature");function y(E,C,x,w){p.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=C,this.zipPlatform=x,this.encodeFileName=w,this.streamFiles=E,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}d.inherits(y,p),y.prototype.push=function(E){var C=E.meta.percent||0,x=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(E):(this.bytesWritten+=E.data.length,p.prototype.push.call(this,{data:E.data,meta:{currentFile:this.currentFile,percent:x?(C+100*(x-w-1))/x:100}}))},y.prototype.openedSource=function(E){this.currentSourceOffset=this.bytesWritten,this.currentFile=E.file.name;var C=this.streamFiles&&!E.file.dir;if(C){var x=c(E,C,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:x.fileRecord,meta:{percent:0}})}else this.accumulate=!0},y.prototype.closedSource=function(E){this.accumulate=!1;var C=this.streamFiles&&!E.file.dir,x=c(E,C,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(x.dirRecord),C)this.push({data:function(w){return m.DATA_DESCRIPTOR+f(w.crc32,4)+f(w.compressedSize,4)+f(w.uncompressedSize,4)}(E),meta:{percent:100}});else for(this.push({data:x.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},y.prototype.flush=function(){for(var E=this.bytesWritten,C=0;C<this.dirRecords.length;C++)this.push({data:this.dirRecords[C],meta:{percent:100}});var x=this.bytesWritten-E,w=function(v,D,B,z,P){var N=d.transformTo("string",P(z));return m.CENTRAL_DIRECTORY_END+"\0\0\0\0"+f(v,2)+f(v,2)+f(D,4)+f(B,4)+f(N.length,2)+N}(this.dirRecords.length,x,E,this.zipComment,this.encodeFileName);this.push({data:w,meta:{percent:100}})},y.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},y.prototype.registerPrevious=function(E){this._sources.push(E);var C=this;return E.on("data",function(x){C.processChunk(x)}),E.on("end",function(){C.closedSource(C.previous.streamInfo),C._sources.length?C.prepareNextSource():C.end()}),E.on("error",function(x){C.error(x)}),this},y.prototype.resume=function(){return!!p.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},y.prototype.error=function(E){var C=this._sources;if(!p.prototype.error.call(this,E))return!1;for(var x=0;x<C.length;x++)try{C[x].error(E)}catch(w){}return!0},y.prototype.lock=function(){p.prototype.lock.call(this);for(var E=this._sources,C=0;C<E.length;C++)E[C].lock()},l.exports=y},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(i,l,u){var f=i("../compressions"),c=i("./ZipFileWorker");u.generateWorker=function(d,p,g){var A=new c(p.streamFiles,g,p.platform,p.encodeFileName),m=0;try{d.forEach(function(y,E){m++;var C=function(D,B){var z=D||B,P=f[z];if(!P)throw new Error(z+" is not a valid compression method !");return P}(E.options.compression,p.compression),x=E.options.compressionOptions||p.compressionOptions||{},w=E.dir,v=E.date;E._compressWorker(C,x).withStreamInfo("file",{name:y,dir:w,date:v,comment:E.comment||"",unixPermissions:E.unixPermissions,dosPermissions:E.dosPermissions}).pipe(A)}),A.entriesCount=m}catch(y){A.error(y)}return A}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(i,l,u){function f(){if(!(this instanceof f))return new f;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var c=new f;for(var d in this)typeof this[d]!="function"&&(c[d]=this[d]);return c}}(f.prototype=i("./object")).loadAsync=i("./load"),f.support=i("./support"),f.defaults=i("./defaults"),f.version="3.10.1",f.loadAsync=function(c,d){return new f().loadAsync(c,d)},f.external=i("./external"),l.exports=f},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(i,l,u){var f=i("./utils"),c=i("./external"),d=i("./utf8"),p=i("./zipEntries"),g=i("./stream/Crc32Probe"),A=i("./nodejsUtils");function m(y){return new c.Promise(function(E,C){var x=y.decompressed.getContentWorker().pipe(new g);x.on("error",function(w){C(w)}).on("end",function(){x.streamInfo.crc32!==y.decompressed.crc32?C(new Error("Corrupted zip : CRC32 mismatch")):E()}).resume()})}l.exports=function(y,E){var C=this;return E=f.extend(E||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:d.utf8decode}),A.isNode&&A.isStream(y)?c.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):f.prepareContent("the loaded zip file",y,!0,E.optimizedBinaryString,E.base64).then(function(x){var w=new p(E);return w.load(x),w}).then(function(x){var w=[c.Promise.resolve(x)],v=x.files;if(E.checkCRC32)for(var D=0;D<v.length;D++)w.push(m(v[D]));return c.Promise.all(w)}).then(function(x){for(var w=x.shift(),v=w.files,D=0;D<v.length;D++){var B=v[D],z=B.fileNameStr,P=f.resolve(B.fileNameStr);C.file(P,B.decompressed,{binary:!0,optimizedBinaryString:!0,date:B.date,dir:B.dir,comment:B.fileCommentStr.length?B.fileCommentStr:null,unixPermissions:B.unixPermissions,dosPermissions:B.dosPermissions,createFolders:E.createFolders}),B.dir||(C.file(P).unsafeOriginalName=z)}return w.zipComment.length&&(C.comment=w.zipComment),C})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(i,l,u){var f=i("../utils"),c=i("../stream/GenericWorker");function d(p,g){c.call(this,"Nodejs stream input adapter for "+p),this._upstreamEnded=!1,this._bindStream(g)}f.inherits(d,c),d.prototype._bindStream=function(p){var g=this;(this._stream=p).pause(),p.on("data",function(A){g.push({data:A,meta:{percent:0}})}).on("error",function(A){g.isPaused?this.generatedError=A:g.error(A)}).on("end",function(){g.isPaused?g._upstreamEnded=!0:g.end()})},d.prototype.pause=function(){return!!c.prototype.pause.call(this)&&(this._stream.pause(),!0)},d.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},l.exports=d},{"../stream/GenericWorker":28,"../utils":32}],13:[function(i,l,u){var f=i("readable-stream").Readable;function c(d,p,g){f.call(this,p),this._helper=d;var A=this;d.on("data",function(m,y){A.push(m)||A._helper.pause(),g&&g(y)}).on("error",function(m){A.emit("error",m)}).on("end",function(){A.push(null)})}i("../utils").inherits(c,f),c.prototype._read=function(){this._helper.resume()},l.exports=c},{"../utils":32,"readable-stream":16}],14:[function(i,l,u){l.exports={isNode:typeof Buffer!="undefined",newBufferFrom:function(f,c){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(f,c);if(typeof f=="number")throw new Error('The "data" argument must not be a number');return new Buffer(f,c)},allocBuffer:function(f){if(Buffer.alloc)return Buffer.alloc(f);var c=new Buffer(f);return c.fill(0),c},isBuffer:function(f){return Buffer.isBuffer(f)},isStream:function(f){return f&&typeof f.on=="function"&&typeof f.pause=="function"&&typeof f.resume=="function"}}},{}],15:[function(i,l,u){function f(P,N,Z){var ie,F=d.getTypeOf(N),K=d.extend(Z||{},A);K.date=K.date||new Date,K.compression!==null&&(K.compression=K.compression.toUpperCase()),typeof K.unixPermissions=="string"&&(K.unixPermissions=parseInt(K.unixPermissions,8)),K.unixPermissions&&16384&K.unixPermissions&&(K.dir=!0),K.dosPermissions&&16&K.dosPermissions&&(K.dir=!0),K.dir&&(P=v(P)),K.createFolders&&(ie=w(P))&&D.call(this,ie,!0);var re=F==="string"&&K.binary===!1&&K.base64===!1;Z&&Z.binary!==void 0||(K.binary=!re),(N instanceof m&&N.uncompressedSize===0||K.dir||!N||N.length===0)&&(K.base64=!1,K.binary=!0,N="",K.compression="STORE",F="string");var Q=null;Q=N instanceof m||N instanceof p?N:C.isNode&&C.isStream(N)?new x(P,N):d.prepareContent(P,N,K.binary,K.optimizedBinaryString,K.base64);var q=new y(P,Q,K);this.files[P]=q}var c=i("./utf8"),d=i("./utils"),p=i("./stream/GenericWorker"),g=i("./stream/StreamHelper"),A=i("./defaults"),m=i("./compressedObject"),y=i("./zipObject"),E=i("./generate"),C=i("./nodejsUtils"),x=i("./nodejs/NodejsStreamInputAdapter"),w=function(P){P.slice(-1)==="/"&&(P=P.substring(0,P.length-1));var N=P.lastIndexOf("/");return 0<N?P.substring(0,N):""},v=function(P){return P.slice(-1)!=="/"&&(P+="/"),P},D=function(P,N){return N=N!==void 0?N:A.createFolders,P=v(P),this.files[P]||f.call(this,P,null,{dir:!0,createFolders:N}),this.files[P]};function B(P){return Object.prototype.toString.call(P)==="[object RegExp]"}var z={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(P){var N,Z,ie;for(N in this.files)ie=this.files[N],(Z=N.slice(this.root.length,N.length))&&N.slice(0,this.root.length)===this.root&&P(Z,ie)},filter:function(P){var N=[];return this.forEach(function(Z,ie){P(Z,ie)&&N.push(ie)}),N},file:function(P,N,Z){if(arguments.length!==1)return P=this.root+P,f.call(this,P,N,Z),this;if(B(P)){var ie=P;return this.filter(function(K,re){return!re.dir&&ie.test(K)})}var F=this.files[this.root+P];return F&&!F.dir?F:null},folder:function(P){if(!P)return this;if(B(P))return this.filter(function(F,K){return K.dir&&P.test(F)});var N=this.root+P,Z=D.call(this,N),ie=this.clone();return ie.root=Z.name,ie},remove:function(P){P=this.root+P;var N=this.files[P];if(N||(P.slice(-1)!=="/"&&(P+="/"),N=this.files[P]),N&&!N.dir)delete this.files[P];else for(var Z=this.filter(function(F,K){return K.name.slice(0,P.length)===P}),ie=0;ie<Z.length;ie++)delete this.files[Z[ie].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(P){var N,Z={};try{if((Z=d.extend(P||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:c.utf8encode})).type=Z.type.toLowerCase(),Z.compression=Z.compression.toUpperCase(),Z.type==="binarystring"&&(Z.type="string"),!Z.type)throw new Error("No output type specified.");d.checkSupport(Z.type),Z.platform!=="darwin"&&Z.platform!=="freebsd"&&Z.platform!=="linux"&&Z.platform!=="sunos"||(Z.platform="UNIX"),Z.platform==="win32"&&(Z.platform="DOS");var ie=Z.comment||this.comment||"";N=E.generateWorker(this,Z,ie)}catch(F){(N=new p("error")).error(F)}return new g(N,Z.type||"string",Z.mimeType)},generateAsync:function(P,N){return this.generateInternalStream(P).accumulate(N)},generateNodeStream:function(P,N){return(P=P||{}).type||(P.type="nodebuffer"),this.generateInternalStream(P).toNodejsStream(N)}};l.exports=z},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(i,l,u){l.exports=i("stream")},{stream:void 0}],17:[function(i,l,u){var f=i("./DataReader");function c(d){f.call(this,d);for(var p=0;p<this.data.length;p++)d[p]=255&d[p]}i("../utils").inherits(c,f),c.prototype.byteAt=function(d){return this.data[this.zero+d]},c.prototype.lastIndexOfSignature=function(d){for(var p=d.charCodeAt(0),g=d.charCodeAt(1),A=d.charCodeAt(2),m=d.charCodeAt(3),y=this.length-4;0<=y;--y)if(this.data[y]===p&&this.data[y+1]===g&&this.data[y+2]===A&&this.data[y+3]===m)return y-this.zero;return-1},c.prototype.readAndCheckSignature=function(d){var p=d.charCodeAt(0),g=d.charCodeAt(1),A=d.charCodeAt(2),m=d.charCodeAt(3),y=this.readData(4);return p===y[0]&&g===y[1]&&A===y[2]&&m===y[3]},c.prototype.readData=function(d){if(this.checkOffset(d),d===0)return[];var p=this.data.slice(this.zero+this.index,this.zero+this.index+d);return this.index+=d,p},l.exports=c},{"../utils":32,"./DataReader":18}],18:[function(i,l,u){var f=i("../utils");function c(d){this.data=d,this.length=d.length,this.index=0,this.zero=0}c.prototype={checkOffset:function(d){this.checkIndex(this.index+d)},checkIndex:function(d){if(this.length<this.zero+d||d<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+d+"). Corrupted zip ?")},setIndex:function(d){this.checkIndex(d),this.index=d},skip:function(d){this.setIndex(this.index+d)},byteAt:function(){},readInt:function(d){var p,g=0;for(this.checkOffset(d),p=this.index+d-1;p>=this.index;p--)g=(g<<8)+this.byteAt(p);return this.index+=d,g},readString:function(d){return f.transformTo("string",this.readData(d))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var d=this.readInt(4);return new Date(Date.UTC(1980+(d>>25&127),(d>>21&15)-1,d>>16&31,d>>11&31,d>>5&63,(31&d)<<1))}},l.exports=c},{"../utils":32}],19:[function(i,l,u){var f=i("./Uint8ArrayReader");function c(d){f.call(this,d)}i("../utils").inherits(c,f),c.prototype.readData=function(d){this.checkOffset(d);var p=this.data.slice(this.zero+this.index,this.zero+this.index+d);return this.index+=d,p},l.exports=c},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(i,l,u){var f=i("./DataReader");function c(d){f.call(this,d)}i("../utils").inherits(c,f),c.prototype.byteAt=function(d){return this.data.charCodeAt(this.zero+d)},c.prototype.lastIndexOfSignature=function(d){return this.data.lastIndexOf(d)-this.zero},c.prototype.readAndCheckSignature=function(d){return d===this.readData(4)},c.prototype.readData=function(d){this.checkOffset(d);var p=this.data.slice(this.zero+this.index,this.zero+this.index+d);return this.index+=d,p},l.exports=c},{"../utils":32,"./DataReader":18}],21:[function(i,l,u){var f=i("./ArrayReader");function c(d){f.call(this,d)}i("../utils").inherits(c,f),c.prototype.readData=function(d){if(this.checkOffset(d),d===0)return new Uint8Array(0);var p=this.data.subarray(this.zero+this.index,this.zero+this.index+d);return this.index+=d,p},l.exports=c},{"../utils":32,"./ArrayReader":17}],22:[function(i,l,u){var f=i("../utils"),c=i("../support"),d=i("./ArrayReader"),p=i("./StringReader"),g=i("./NodeBufferReader"),A=i("./Uint8ArrayReader");l.exports=function(m){var y=f.getTypeOf(m);return f.checkSupport(y),y!=="string"||c.uint8array?y==="nodebuffer"?new g(m):c.uint8array?new A(f.transformTo("uint8array",m)):new d(f.transformTo("array",m)):new p(m)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(i,l,u){u.LOCAL_FILE_HEADER="PK",u.CENTRAL_FILE_HEADER="PK",u.CENTRAL_DIRECTORY_END="PK",u.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",u.ZIP64_CENTRAL_DIRECTORY_END="PK",u.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(i,l,u){var f=i("./GenericWorker"),c=i("../utils");function d(p){f.call(this,"ConvertWorker to "+p),this.destType=p}c.inherits(d,f),d.prototype.processChunk=function(p){this.push({data:c.transformTo(this.destType,p.data),meta:p.meta})},l.exports=d},{"../utils":32,"./GenericWorker":28}],25:[function(i,l,u){var f=i("./GenericWorker"),c=i("../crc32");function d(){f.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}i("../utils").inherits(d,f),d.prototype.processChunk=function(p){this.streamInfo.crc32=c(p.data,this.streamInfo.crc32||0),this.push(p)},l.exports=d},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(i,l,u){var f=i("../utils"),c=i("./GenericWorker");function d(p){c.call(this,"DataLengthProbe for "+p),this.propName=p,this.withStreamInfo(p,0)}f.inherits(d,c),d.prototype.processChunk=function(p){if(p){var g=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=g+p.data.length}c.prototype.processChunk.call(this,p)},l.exports=d},{"../utils":32,"./GenericWorker":28}],27:[function(i,l,u){var f=i("../utils"),c=i("./GenericWorker");function d(p){c.call(this,"DataWorker");var g=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,p.then(function(A){g.dataIsReady=!0,g.data=A,g.max=A&&A.length||0,g.type=f.getTypeOf(A),g.isPaused||g._tickAndRepeat()},function(A){g.error(A)})}f.inherits(d,c),d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this.data=null},d.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,f.delay(this._tickAndRepeat,[],this)),!0)},d.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(f.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},d.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var p=null,g=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":p=this.data.substring(this.index,g);break;case"uint8array":p=this.data.subarray(this.index,g);break;case"array":case"nodebuffer":p=this.data.slice(this.index,g)}return this.index=g,this.push({data:p,meta:{percent:this.max?this.index/this.max*100:0}})},l.exports=d},{"../utils":32,"./GenericWorker":28}],28:[function(i,l,u){function f(c){this.name=c||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}f.prototype={push:function(c){this.emit("data",c)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(c){this.emit("error",c)}return!0},error:function(c){return!this.isFinished&&(this.isPaused?this.generatedError=c:(this.isFinished=!0,this.emit("error",c),this.previous&&this.previous.error(c),this.cleanUp()),!0)},on:function(c,d){return this._listeners[c].push(d),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(c,d){if(this._listeners[c])for(var p=0;p<this._listeners[c].length;p++)this._listeners[c][p].call(this,d)},pipe:function(c){return c.registerPrevious(this)},registerPrevious:function(c){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=c.streamInfo,this.mergeStreamInfo(),this.previous=c;var d=this;return c.on("data",function(p){d.processChunk(p)}),c.on("end",function(){d.end()}),c.on("error",function(p){d.error(p)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var c=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),c=!0),this.previous&&this.previous.resume(),!c},flush:function(){},processChunk:function(c){this.push(c)},withStreamInfo:function(c,d){return this.extraStreamInfo[c]=d,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var c in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,c)&&(this.streamInfo[c]=this.extraStreamInfo[c])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var c="Worker "+this.name;return this.previous?this.previous+" -> "+c:c}},l.exports=f},{}],29:[function(i,l,u){var f=i("../utils"),c=i("./ConvertWorker"),d=i("./GenericWorker"),p=i("../base64"),g=i("../support"),A=i("../external"),m=null;if(g.nodestream)try{m=i("../nodejs/NodejsStreamOutputAdapter")}catch(C){}function y(C,x){return new A.Promise(function(w,v){var D=[],B=C._internalType,z=C._outputType,P=C._mimeType;C.on("data",function(N,Z){D.push(N),x&&x(Z)}).on("error",function(N){D=[],v(N)}).on("end",function(){try{var N=function(Z,ie,F){switch(Z){case"blob":return f.newBlob(f.transformTo("arraybuffer",ie),F);case"base64":return p.encode(ie);default:return f.transformTo(Z,ie)}}(z,function(Z,ie){var F,K=0,re=null,Q=0;for(F=0;F<ie.length;F++)Q+=ie[F].length;switch(Z){case"string":return ie.join("");case"array":return Array.prototype.concat.apply([],ie);case"uint8array":for(re=new Uint8Array(Q),F=0;F<ie.length;F++)re.set(ie[F],K),K+=ie[F].length;return re;case"nodebuffer":return Buffer.concat(ie);default:throw new Error("concat : unsupported type '"+Z+"'")}}(B,D),P);w(N)}catch(Z){v(Z)}D=[]}).resume()})}function E(C,x,w){var v=x;switch(x){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=x,this._mimeType=w,f.checkSupport(v),this._worker=C.pipe(new c(v)),C.lock()}catch(D){this._worker=new d("error"),this._worker.error(D)}}E.prototype={accumulate:function(C){return y(this,C)},on:function(C,x){var w=this;return C==="data"?this._worker.on(C,function(v){x.call(w,v.data,v.meta)}):this._worker.on(C,function(){f.delay(x,arguments,w)}),this},resume:function(){return f.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(C){if(f.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new m(this,{objectMode:this._outputType!=="nodebuffer"},C)}},l.exports=E},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(i,l,u){if(u.base64=!0,u.array=!0,u.string=!0,u.arraybuffer=typeof ArrayBuffer!="undefined"&&typeof Uint8Array!="undefined",u.nodebuffer=typeof Buffer!="undefined",u.uint8array=typeof Uint8Array!="undefined",typeof ArrayBuffer=="undefined")u.blob=!1;else{var f=new ArrayBuffer(0);try{u.blob=new Blob([f],{type:"application/zip"}).size===0}catch(d){try{var c=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);c.append(f),u.blob=c.getBlob("application/zip").size===0}catch(p){u.blob=!1}}}try{u.nodestream=!!i("readable-stream").Readable}catch(d){u.nodestream=!1}},{"readable-stream":16}],31:[function(i,l,u){for(var f=i("./utils"),c=i("./support"),d=i("./nodejsUtils"),p=i("./stream/GenericWorker"),g=new Array(256),A=0;A<256;A++)g[A]=252<=A?6:248<=A?5:240<=A?4:224<=A?3:192<=A?2:1;g[254]=g[254]=1;function m(){p.call(this,"utf-8 decode"),this.leftOver=null}function y(){p.call(this,"utf-8 encode")}u.utf8encode=function(E){return c.nodebuffer?d.newBufferFrom(E,"utf-8"):function(C){var x,w,v,D,B,z=C.length,P=0;for(D=0;D<z;D++)(64512&(w=C.charCodeAt(D)))==55296&&D+1<z&&(64512&(v=C.charCodeAt(D+1)))==56320&&(w=65536+(w-55296<<10)+(v-56320),D++),P+=w<128?1:w<2048?2:w<65536?3:4;for(x=c.uint8array?new Uint8Array(P):new Array(P),D=B=0;B<P;D++)(64512&(w=C.charCodeAt(D)))==55296&&D+1<z&&(64512&(v=C.charCodeAt(D+1)))==56320&&(w=65536+(w-55296<<10)+(v-56320),D++),w<128?x[B++]=w:(w<2048?x[B++]=192|w>>>6:(w<65536?x[B++]=224|w>>>12:(x[B++]=240|w>>>18,x[B++]=128|w>>>12&63),x[B++]=128|w>>>6&63),x[B++]=128|63&w);return x}(E)},u.utf8decode=function(E){return c.nodebuffer?f.transformTo("nodebuffer",E).toString("utf-8"):function(C){var x,w,v,D,B=C.length,z=new Array(2*B);for(x=w=0;x<B;)if((v=C[x++])<128)z[w++]=v;else if(4<(D=g[v]))z[w++]=65533,x+=D-1;else{for(v&=D===2?31:D===3?15:7;1<D&&x<B;)v=v<<6|63&C[x++],D--;1<D?z[w++]=65533:v<65536?z[w++]=v:(v-=65536,z[w++]=55296|v>>10&1023,z[w++]=56320|1023&v)}return z.length!==w&&(z.subarray?z=z.subarray(0,w):z.length=w),f.applyFromCharCode(z)}(E=f.transformTo(c.uint8array?"uint8array":"array",E))},f.inherits(m,p),m.prototype.processChunk=function(E){var C=f.transformTo(c.uint8array?"uint8array":"array",E.data);if(this.leftOver&&this.leftOver.length){if(c.uint8array){var x=C;(C=new Uint8Array(x.length+this.leftOver.length)).set(this.leftOver,0),C.set(x,this.leftOver.length)}else C=this.leftOver.concat(C);this.leftOver=null}var w=function(D,B){var z;for((B=B||D.length)>D.length&&(B=D.length),z=B-1;0<=z&&(192&D[z])==128;)z--;return z<0||z===0?B:z+g[D[z]]>B?z:B}(C),v=C;w!==C.length&&(c.uint8array?(v=C.subarray(0,w),this.leftOver=C.subarray(w,C.length)):(v=C.slice(0,w),this.leftOver=C.slice(w,C.length))),this.push({data:u.utf8decode(v),meta:E.meta})},m.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:u.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},u.Utf8DecodeWorker=m,f.inherits(y,p),y.prototype.processChunk=function(E){this.push({data:u.utf8encode(E.data),meta:E.meta})},u.Utf8EncodeWorker=y},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(i,l,u){var f=i("./support"),c=i("./base64"),d=i("./nodejsUtils"),p=i("./external");function g(x){return x}function A(x,w){for(var v=0;v<x.length;++v)w[v]=255&x.charCodeAt(v);return w}i("setimmediate"),u.newBlob=function(x,w){u.checkSupport("blob");try{return new Blob([x],{type:w})}catch(D){try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(x),v.getBlob(w)}catch(B){throw new Error("Bug : can't construct the Blob.")}}};var m={stringifyByChunk:function(x,w,v){var D=[],B=0,z=x.length;if(z<=v)return String.fromCharCode.apply(null,x);for(;B<z;)w==="array"||w==="nodebuffer"?D.push(String.fromCharCode.apply(null,x.slice(B,Math.min(B+v,z)))):D.push(String.fromCharCode.apply(null,x.subarray(B,Math.min(B+v,z)))),B+=v;return D.join("")},stringifyByChar:function(x){for(var w="",v=0;v<x.length;v++)w+=String.fromCharCode(x[v]);return w},applyCanBeUsed:{uint8array:function(){try{return f.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch(x){return!1}}(),nodebuffer:function(){try{return f.nodebuffer&&String.fromCharCode.apply(null,d.allocBuffer(1)).length===1}catch(x){return!1}}()}};function y(x){var w=65536,v=u.getTypeOf(x),D=!0;if(v==="uint8array"?D=m.applyCanBeUsed.uint8array:v==="nodebuffer"&&(D=m.applyCanBeUsed.nodebuffer),D)for(;1<w;)try{return m.stringifyByChunk(x,v,w)}catch(B){w=Math.floor(w/2)}return m.stringifyByChar(x)}function E(x,w){for(var v=0;v<x.length;v++)w[v]=x[v];return w}u.applyFromCharCode=y;var C={};C.string={string:g,array:function(x){return A(x,new Array(x.length))},arraybuffer:function(x){return C.string.uint8array(x).buffer},uint8array:function(x){return A(x,new Uint8Array(x.length))},nodebuffer:function(x){return A(x,d.allocBuffer(x.length))}},C.array={string:y,array:g,arraybuffer:function(x){return new Uint8Array(x).buffer},uint8array:function(x){return new Uint8Array(x)},nodebuffer:function(x){return d.newBufferFrom(x)}},C.arraybuffer={string:function(x){return y(new Uint8Array(x))},array:function(x){return E(new Uint8Array(x),new Array(x.byteLength))},arraybuffer:g,uint8array:function(x){return new Uint8Array(x)},nodebuffer:function(x){return d.newBufferFrom(new Uint8Array(x))}},C.uint8array={string:y,array:function(x){return E(x,new Array(x.length))},arraybuffer:function(x){return x.buffer},uint8array:g,nodebuffer:function(x){return d.newBufferFrom(x)}},C.nodebuffer={string:y,array:function(x){return E(x,new Array(x.length))},arraybuffer:function(x){return C.nodebuffer.uint8array(x).buffer},uint8array:function(x){return E(x,new Uint8Array(x.length))},nodebuffer:g},u.transformTo=function(x,w){if(w=w||"",!x)return w;u.checkSupport(x);var v=u.getTypeOf(w);return C[v][x](w)},u.resolve=function(x){for(var w=x.split("/"),v=[],D=0;D<w.length;D++){var B=w[D];B==="."||B===""&&D!==0&&D!==w.length-1||(B===".."?v.pop():v.push(B))}return v.join("/")},u.getTypeOf=function(x){return typeof x=="string"?"string":Object.prototype.toString.call(x)==="[object Array]"?"array":f.nodebuffer&&d.isBuffer(x)?"nodebuffer":f.uint8array&&x instanceof Uint8Array?"uint8array":f.arraybuffer&&x instanceof ArrayBuffer?"arraybuffer":void 0},u.checkSupport=function(x){if(!f[x.toLowerCase()])throw new Error(x+" is not supported by this platform")},u.MAX_VALUE_16BITS=65535,u.MAX_VALUE_32BITS=-1,u.pretty=function(x){var w,v,D="";for(v=0;v<(x||"").length;v++)D+="\\x"+((w=x.charCodeAt(v))<16?"0":"")+w.toString(16).toUpperCase();return D},u.delay=function(x,w,v){setImmediate(function(){x.apply(v||null,w||[])})},u.inherits=function(x,w){function v(){}v.prototype=w.prototype,x.prototype=new v},u.extend=function(){var x,w,v={};for(x=0;x<arguments.length;x++)for(w in arguments[x])Object.prototype.hasOwnProperty.call(arguments[x],w)&&v[w]===void 0&&(v[w]=arguments[x][w]);return v},u.prepareContent=function(x,w,v,D,B){return p.Promise.resolve(w).then(function(z){return f.blob&&(z instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(z))!==-1)&&typeof FileReader!="undefined"?new p.Promise(function(P,N){var Z=new FileReader;Z.onload=function(ie){P(ie.target.result)},Z.onerror=function(ie){N(ie.target.error)},Z.readAsArrayBuffer(z)}):z}).then(function(z){var P=u.getTypeOf(z);return P?(P==="arraybuffer"?z=u.transformTo("uint8array",z):P==="string"&&(B?z=c.decode(z):v&&D!==!0&&(z=function(N){return A(N,f.uint8array?new Uint8Array(N.length):new Array(N.length))}(z))),z):p.Promise.reject(new Error("Can't read the data of '"+x+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(i,l,u){var f=i("./reader/readerFor"),c=i("./utils"),d=i("./signature"),p=i("./zipEntry"),g=i("./support");function A(m){this.files=[],this.loadOptions=m}A.prototype={checkSignature:function(m){if(!this.reader.readAndCheckSignature(m)){this.reader.index-=4;var y=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+c.pretty(y)+", expected "+c.pretty(m)+")")}},isSignature:function(m,y){var E=this.reader.index;this.reader.setIndex(m);var C=this.reader.readString(4)===y;return this.reader.setIndex(E),C},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var m=this.reader.readData(this.zipCommentLength),y=g.uint8array?"uint8array":"array",E=c.transformTo(y,m);this.zipComment=this.loadOptions.decodeFileName(E)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var m,y,E,C=this.zip64EndOfCentralSize-44;0<C;)m=this.reader.readInt(2),y=this.reader.readInt(4),E=this.reader.readData(y),this.zip64ExtensibleData[m]={id:m,length:y,value:E}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var m,y;for(m=0;m<this.files.length;m++)y=this.files[m],this.reader.setIndex(y.localHeaderOffset),this.checkSignature(d.LOCAL_FILE_HEADER),y.readLocalPart(this.reader),y.handleUTF8(),y.processAttributes()},readCentralDir:function(){var m;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(d.CENTRAL_FILE_HEADER);)(m=new p({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(m);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var m=this.reader.lastIndexOfSignature(d.CENTRAL_DIRECTORY_END);if(m<0)throw this.isSignature(0,d.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(m);var y=m;if(this.checkSignature(d.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===c.MAX_VALUE_16BITS||this.diskWithCentralDirStart===c.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===c.MAX_VALUE_16BITS||this.centralDirRecords===c.MAX_VALUE_16BITS||this.centralDirSize===c.MAX_VALUE_32BITS||this.centralDirOffset===c.MAX_VALUE_32BITS){if(this.zip64=!0,(m=this.reader.lastIndexOfSignature(d.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(m),this.checkSignature(d.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,d.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(d.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(d.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var E=this.centralDirOffset+this.centralDirSize;this.zip64&&(E+=20,E+=12+this.zip64EndOfCentralSize);var C=y-E;if(0<C)this.isSignature(y,d.CENTRAL_FILE_HEADER)||(this.reader.zero=C);else if(C<0)throw new Error("Corrupted zip: missing "+Math.abs(C)+" bytes.")},prepareReader:function(m){this.reader=f(m)},load:function(m){this.prepareReader(m),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},l.exports=A},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(i,l,u){var f=i("./reader/readerFor"),c=i("./utils"),d=i("./compressedObject"),p=i("./crc32"),g=i("./utf8"),A=i("./compressions"),m=i("./support");function y(E,C){this.options=E,this.loadOptions=C}y.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(E){var C,x;if(E.skip(22),this.fileNameLength=E.readInt(2),x=E.readInt(2),this.fileName=E.readData(this.fileNameLength),E.skip(x),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((C=function(w){for(var v in A)if(Object.prototype.hasOwnProperty.call(A,v)&&A[v].magic===w)return A[v];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+c.pretty(this.compressionMethod)+" unknown (inner file : "+c.transformTo("string",this.fileName)+")");this.decompressed=new d(this.compressedSize,this.uncompressedSize,this.crc32,C,E.readData(this.compressedSize))},readCentralPart:function(E){this.versionMadeBy=E.readInt(2),E.skip(2),this.bitFlag=E.readInt(2),this.compressionMethod=E.readString(2),this.date=E.readDate(),this.crc32=E.readInt(4),this.compressedSize=E.readInt(4),this.uncompressedSize=E.readInt(4);var C=E.readInt(2);if(this.extraFieldsLength=E.readInt(2),this.fileCommentLength=E.readInt(2),this.diskNumberStart=E.readInt(2),this.internalFileAttributes=E.readInt(2),this.externalFileAttributes=E.readInt(4),this.localHeaderOffset=E.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");E.skip(C),this.readExtraFields(E),this.parseZIP64ExtraField(E),this.fileComment=E.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var E=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),E==0&&(this.dosPermissions=63&this.externalFileAttributes),E==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var E=f(this.extraFields[1].value);this.uncompressedSize===c.MAX_VALUE_32BITS&&(this.uncompressedSize=E.readInt(8)),this.compressedSize===c.MAX_VALUE_32BITS&&(this.compressedSize=E.readInt(8)),this.localHeaderOffset===c.MAX_VALUE_32BITS&&(this.localHeaderOffset=E.readInt(8)),this.diskNumberStart===c.MAX_VALUE_32BITS&&(this.diskNumberStart=E.readInt(4))}},readExtraFields:function(E){var C,x,w,v=E.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});E.index+4<v;)C=E.readInt(2),x=E.readInt(2),w=E.readData(x),this.extraFields[C]={id:C,length:x,value:w};E.setIndex(v)},handleUTF8:function(){var E=m.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=g.utf8decode(this.fileName),this.fileCommentStr=g.utf8decode(this.fileComment);else{var C=this.findExtraFieldUnicodePath();if(C!==null)this.fileNameStr=C;else{var x=c.transformTo(E,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(x)}var w=this.findExtraFieldUnicodeComment();if(w!==null)this.fileCommentStr=w;else{var v=c.transformTo(E,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var E=this.extraFields[28789];if(E){var C=f(E.value);return C.readInt(1)!==1||p(this.fileName)!==C.readInt(4)?null:g.utf8decode(C.readData(E.length-5))}return null},findExtraFieldUnicodeComment:function(){var E=this.extraFields[25461];if(E){var C=f(E.value);return C.readInt(1)!==1||p(this.fileComment)!==C.readInt(4)?null:g.utf8decode(C.readData(E.length-5))}return null}},l.exports=y},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(i,l,u){function f(C,x,w){this.name=C,this.dir=w.dir,this.date=w.date,this.comment=w.comment,this.unixPermissions=w.unixPermissions,this.dosPermissions=w.dosPermissions,this._data=x,this._dataBinary=w.binary,this.options={compression:w.compression,compressionOptions:w.compressionOptions}}var c=i("./stream/StreamHelper"),d=i("./stream/DataWorker"),p=i("./utf8"),g=i("./compressedObject"),A=i("./stream/GenericWorker");f.prototype={internalStream:function(C){var x=null,w="string";try{if(!C)throw new Error("No output type specified.");var v=(w=C.toLowerCase())==="string"||w==="text";w!=="binarystring"&&w!=="text"||(w="string"),x=this._decompressWorker();var D=!this._dataBinary;D&&!v&&(x=x.pipe(new p.Utf8EncodeWorker)),!D&&v&&(x=x.pipe(new p.Utf8DecodeWorker))}catch(B){(x=new A("error")).error(B)}return new c(x,w,"")},async:function(C,x){return this.internalStream(C).accumulate(x)},nodeStream:function(C,x){return this.internalStream(C||"nodebuffer").toNodejsStream(x)},_compressWorker:function(C,x){if(this._data instanceof g&&this._data.compression.magic===C.magic)return this._data.getCompressedWorker();var w=this._decompressWorker();return this._dataBinary||(w=w.pipe(new p.Utf8EncodeWorker)),g.createWorkerFrom(w,C,x)},_decompressWorker:function(){return this._data instanceof g?this._data.getContentWorker():this._data instanceof A?this._data:new d(this._data)}};for(var m=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],y=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},E=0;E<m.length;E++)f.prototype[m[E]]=y;l.exports=f},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(i,l,u){(function(f){var c,d,p=f.MutationObserver||f.WebKitMutationObserver;if(p){var g=0,A=new p(C),m=f.document.createTextNode("");A.observe(m,{characterData:!0}),c=function(){m.data=g=++g%2}}else if(f.setImmediate||f.MessageChannel===void 0)c="document"in f&&"onreadystatechange"in f.document.createElement("script")?function(){var x=f.document.createElement("script");x.onreadystatechange=function(){C(),x.onreadystatechange=null,x.parentNode.removeChild(x),x=null},f.document.documentElement.appendChild(x)}:function(){setTimeout(C,0)};else{var y=new f.MessageChannel;y.port1.onmessage=C,c=function(){y.port2.postMessage(0)}}var E=[];function C(){var x,w;d=!0;for(var v=E.length;v;){for(w=E,E=[],x=-1;++x<v;)w[x]();v=E.length}d=!1}l.exports=function(x){E.push(x)!==1||d||c()}}).call(this,typeof $t!="undefined"?$t:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],37:[function(i,l,u){var f=i("immediate");function c(){}var d={},p=["REJECTED"],g=["FULFILLED"],A=["PENDING"];function m(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=A,this.queue=[],this.outcome=void 0,v!==c&&x(this,v)}function y(v,D,B){this.promise=v,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof B=="function"&&(this.onRejected=B,this.callRejected=this.otherCallRejected)}function E(v,D,B){f(function(){var z;try{z=D(B)}catch(P){return d.reject(v,P)}z===v?d.reject(v,new TypeError("Cannot resolve promise with itself")):d.resolve(v,z)})}function C(v){var D=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof D=="function")return function(){D.apply(v,arguments)}}function x(v,D){var B=!1;function z(Z){B||(B=!0,d.reject(v,Z))}function P(Z){B||(B=!0,d.resolve(v,Z))}var N=w(function(){D(P,z)});N.status==="error"&&z(N.value)}function w(v,D){var B={};try{B.value=v(D),B.status="success"}catch(z){B.status="error",B.value=z}return B}(l.exports=m).prototype.finally=function(v){if(typeof v!="function")return this;var D=this.constructor;return this.then(function(B){return D.resolve(v()).then(function(){return B})},function(B){return D.resolve(v()).then(function(){throw B})})},m.prototype.catch=function(v){return this.then(null,v)},m.prototype.then=function(v,D){if(typeof v!="function"&&this.state===g||typeof D!="function"&&this.state===p)return this;var B=new this.constructor(c);return this.state!==A?E(B,this.state===g?v:D,this.outcome):this.queue.push(new y(B,v,D)),B},y.prototype.callFulfilled=function(v){d.resolve(this.promise,v)},y.prototype.otherCallFulfilled=function(v){E(this.promise,this.onFulfilled,v)},y.prototype.callRejected=function(v){d.reject(this.promise,v)},y.prototype.otherCallRejected=function(v){E(this.promise,this.onRejected,v)},d.resolve=function(v,D){var B=w(C,D);if(B.status==="error")return d.reject(v,B.value);var z=B.value;if(z)x(v,z);else{v.state=g,v.outcome=D;for(var P=-1,N=v.queue.length;++P<N;)v.queue[P].callFulfilled(D)}return v},d.reject=function(v,D){v.state=p,v.outcome=D;for(var B=-1,z=v.queue.length;++B<z;)v.queue[B].callRejected(D);return v},m.resolve=function(v){return v instanceof this?v:d.resolve(new this(c),v)},m.reject=function(v){var D=new this(c);return d.reject(D,v)},m.all=function(v){var D=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var B=v.length,z=!1;if(!B)return this.resolve([]);for(var P=new Array(B),N=0,Z=-1,ie=new this(c);++Z<B;)F(v[Z],Z);return ie;function F(K,re){D.resolve(K).then(function(Q){P[re]=Q,++N!==B||z||(z=!0,d.resolve(ie,P))},function(Q){z||(z=!0,d.reject(ie,Q))})}},m.race=function(v){var D=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var B=v.length,z=!1;if(!B)return this.resolve([]);for(var P=-1,N=new this(c);++P<B;)Z=v[P],D.resolve(Z).then(function(ie){z||(z=!0,d.resolve(N,ie))},function(ie){z||(z=!0,d.reject(N,ie))});var Z;return N}},{immediate:36}],38:[function(i,l,u){var f={};(0,i("./lib/utils/common").assign)(f,i("./lib/deflate"),i("./lib/inflate"),i("./lib/zlib/constants")),l.exports=f},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(i,l,u){var f=i("./zlib/deflate"),c=i("./utils/common"),d=i("./utils/strings"),p=i("./zlib/messages"),g=i("./zlib/zstream"),A=Object.prototype.toString,m=0,y=-1,E=0,C=8;function x(v){if(!(this instanceof x))return new x(v);this.options=c.assign({level:y,method:C,chunkSize:16384,windowBits:15,memLevel:8,strategy:E,to:""},v||{});var D=this.options;D.raw&&0<D.windowBits?D.windowBits=-D.windowBits:D.gzip&&0<D.windowBits&&D.windowBits<16&&(D.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var B=f.deflateInit2(this.strm,D.level,D.method,D.windowBits,D.memLevel,D.strategy);if(B!==m)throw new Error(p[B]);if(D.header&&f.deflateSetHeader(this.strm,D.header),D.dictionary){var z;if(z=typeof D.dictionary=="string"?d.string2buf(D.dictionary):A.call(D.dictionary)==="[object ArrayBuffer]"?new Uint8Array(D.dictionary):D.dictionary,(B=f.deflateSetDictionary(this.strm,z))!==m)throw new Error(p[B]);this._dict_set=!0}}function w(v,D){var B=new x(D);if(B.push(v,!0),B.err)throw B.msg||p[B.err];return B.result}x.prototype.push=function(v,D){var B,z,P=this.strm,N=this.options.chunkSize;if(this.ended)return!1;z=D===~~D?D:D===!0?4:0,typeof v=="string"?P.input=d.string2buf(v):A.call(v)==="[object ArrayBuffer]"?P.input=new Uint8Array(v):P.input=v,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new c.Buf8(N),P.next_out=0,P.avail_out=N),(B=f.deflate(P,z))!==1&&B!==m)return this.onEnd(B),!(this.ended=!0);P.avail_out!==0&&(P.avail_in!==0||z!==4&&z!==2)||(this.options.to==="string"?this.onData(d.buf2binstring(c.shrinkBuf(P.output,P.next_out))):this.onData(c.shrinkBuf(P.output,P.next_out)))}while((0<P.avail_in||P.avail_out===0)&&B!==1);return z===4?(B=f.deflateEnd(this.strm),this.onEnd(B),this.ended=!0,B===m):z!==2||(this.onEnd(m),!(P.avail_out=0))},x.prototype.onData=function(v){this.chunks.push(v)},x.prototype.onEnd=function(v){v===m&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=c.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},u.Deflate=x,u.deflate=w,u.deflateRaw=function(v,D){return(D=D||{}).raw=!0,w(v,D)},u.gzip=function(v,D){return(D=D||{}).gzip=!0,w(v,D)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(i,l,u){var f=i("./zlib/inflate"),c=i("./utils/common"),d=i("./utils/strings"),p=i("./zlib/constants"),g=i("./zlib/messages"),A=i("./zlib/zstream"),m=i("./zlib/gzheader"),y=Object.prototype.toString;function E(x){if(!(this instanceof E))return new E(x);this.options=c.assign({chunkSize:16384,windowBits:0,to:""},x||{});var w=this.options;w.raw&&0<=w.windowBits&&w.windowBits<16&&(w.windowBits=-w.windowBits,w.windowBits===0&&(w.windowBits=-15)),!(0<=w.windowBits&&w.windowBits<16)||x&&x.windowBits||(w.windowBits+=32),15<w.windowBits&&w.windowBits<48&&(15&w.windowBits)==0&&(w.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new A,this.strm.avail_out=0;var v=f.inflateInit2(this.strm,w.windowBits);if(v!==p.Z_OK)throw new Error(g[v]);this.header=new m,f.inflateGetHeader(this.strm,this.header)}function C(x,w){var v=new E(w);if(v.push(x,!0),v.err)throw v.msg||g[v.err];return v.result}E.prototype.push=function(x,w){var v,D,B,z,P,N,Z=this.strm,ie=this.options.chunkSize,F=this.options.dictionary,K=!1;if(this.ended)return!1;D=w===~~w?w:w===!0?p.Z_FINISH:p.Z_NO_FLUSH,typeof x=="string"?Z.input=d.binstring2buf(x):y.call(x)==="[object ArrayBuffer]"?Z.input=new Uint8Array(x):Z.input=x,Z.next_in=0,Z.avail_in=Z.input.length;do{if(Z.avail_out===0&&(Z.output=new c.Buf8(ie),Z.next_out=0,Z.avail_out=ie),(v=f.inflate(Z,p.Z_NO_FLUSH))===p.Z_NEED_DICT&&F&&(N=typeof F=="string"?d.string2buf(F):y.call(F)==="[object ArrayBuffer]"?new Uint8Array(F):F,v=f.inflateSetDictionary(this.strm,N)),v===p.Z_BUF_ERROR&&K===!0&&(v=p.Z_OK,K=!1),v!==p.Z_STREAM_END&&v!==p.Z_OK)return this.onEnd(v),!(this.ended=!0);Z.next_out&&(Z.avail_out!==0&&v!==p.Z_STREAM_END&&(Z.avail_in!==0||D!==p.Z_FINISH&&D!==p.Z_SYNC_FLUSH)||(this.options.to==="string"?(B=d.utf8border(Z.output,Z.next_out),z=Z.next_out-B,P=d.buf2string(Z.output,B),Z.next_out=z,Z.avail_out=ie-z,z&&c.arraySet(Z.output,Z.output,B,z,0),this.onData(P)):this.onData(c.shrinkBuf(Z.output,Z.next_out)))),Z.avail_in===0&&Z.avail_out===0&&(K=!0)}while((0<Z.avail_in||Z.avail_out===0)&&v!==p.Z_STREAM_END);return v===p.Z_STREAM_END&&(D=p.Z_FINISH),D===p.Z_FINISH?(v=f.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===p.Z_OK):D!==p.Z_SYNC_FLUSH||(this.onEnd(p.Z_OK),!(Z.avail_out=0))},E.prototype.onData=function(x){this.chunks.push(x)},E.prototype.onEnd=function(x){x===p.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=c.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},u.Inflate=E,u.inflate=C,u.inflateRaw=function(x,w){return(w=w||{}).raw=!0,C(x,w)},u.ungzip=C},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(i,l,u){var f=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Int32Array!="undefined";u.assign=function(p){for(var g=Array.prototype.slice.call(arguments,1);g.length;){var A=g.shift();if(A){if(typeof A!="object")throw new TypeError(A+"must be non-object");for(var m in A)A.hasOwnProperty(m)&&(p[m]=A[m])}}return p},u.shrinkBuf=function(p,g){return p.length===g?p:p.subarray?p.subarray(0,g):(p.length=g,p)};var c={arraySet:function(p,g,A,m,y){if(g.subarray&&p.subarray)p.set(g.subarray(A,A+m),y);else for(var E=0;E<m;E++)p[y+E]=g[A+E]},flattenChunks:function(p){var g,A,m,y,E,C;for(g=m=0,A=p.length;g<A;g++)m+=p[g].length;for(C=new Uint8Array(m),g=y=0,A=p.length;g<A;g++)E=p[g],C.set(E,y),y+=E.length;return C}},d={arraySet:function(p,g,A,m,y){for(var E=0;E<m;E++)p[y+E]=g[A+E]},flattenChunks:function(p){return[].concat.apply([],p)}};u.setTyped=function(p){p?(u.Buf8=Uint8Array,u.Buf16=Uint16Array,u.Buf32=Int32Array,u.assign(u,c)):(u.Buf8=Array,u.Buf16=Array,u.Buf32=Array,u.assign(u,d))},u.setTyped(f)},{}],42:[function(i,l,u){var f=i("./common"),c=!0,d=!0;try{String.fromCharCode.apply(null,[0])}catch(m){c=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(m){d=!1}for(var p=new f.Buf8(256),g=0;g<256;g++)p[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;function A(m,y){if(y<65537&&(m.subarray&&d||!m.subarray&&c))return String.fromCharCode.apply(null,f.shrinkBuf(m,y));for(var E="",C=0;C<y;C++)E+=String.fromCharCode(m[C]);return E}p[254]=p[254]=1,u.string2buf=function(m){var y,E,C,x,w,v=m.length,D=0;for(x=0;x<v;x++)(64512&(E=m.charCodeAt(x)))==55296&&x+1<v&&(64512&(C=m.charCodeAt(x+1)))==56320&&(E=65536+(E-55296<<10)+(C-56320),x++),D+=E<128?1:E<2048?2:E<65536?3:4;for(y=new f.Buf8(D),x=w=0;w<D;x++)(64512&(E=m.charCodeAt(x)))==55296&&x+1<v&&(64512&(C=m.charCodeAt(x+1)))==56320&&(E=65536+(E-55296<<10)+(C-56320),x++),E<128?y[w++]=E:(E<2048?y[w++]=192|E>>>6:(E<65536?y[w++]=224|E>>>12:(y[w++]=240|E>>>18,y[w++]=128|E>>>12&63),y[w++]=128|E>>>6&63),y[w++]=128|63&E);return y},u.buf2binstring=function(m){return A(m,m.length)},u.binstring2buf=function(m){for(var y=new f.Buf8(m.length),E=0,C=y.length;E<C;E++)y[E]=m.charCodeAt(E);return y},u.buf2string=function(m,y){var E,C,x,w,v=y||m.length,D=new Array(2*v);for(E=C=0;E<v;)if((x=m[E++])<128)D[C++]=x;else if(4<(w=p[x]))D[C++]=65533,E+=w-1;else{for(x&=w===2?31:w===3?15:7;1<w&&E<v;)x=x<<6|63&m[E++],w--;1<w?D[C++]=65533:x<65536?D[C++]=x:(x-=65536,D[C++]=55296|x>>10&1023,D[C++]=56320|1023&x)}return A(D,C)},u.utf8border=function(m,y){var E;for((y=y||m.length)>m.length&&(y=m.length),E=y-1;0<=E&&(192&m[E])==128;)E--;return E<0||E===0?y:E+p[m[E]]>y?E:y}},{"./common":41}],43:[function(i,l,u){l.exports=function(f,c,d,p){for(var g=65535&f|0,A=f>>>16&65535|0,m=0;d!==0;){for(d-=m=2e3<d?2e3:d;A=A+(g=g+c[p++]|0)|0,--m;);g%=65521,A%=65521}return g|A<<16|0}},{}],44:[function(i,l,u){l.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(i,l,u){var f=function(){for(var c,d=[],p=0;p<256;p++){c=p;for(var g=0;g<8;g++)c=1&c?3988292384^c>>>1:c>>>1;d[p]=c}return d}();l.exports=function(c,d,p,g){var A=f,m=g+p;c^=-1;for(var y=g;y<m;y++)c=c>>>8^A[255&(c^d[y])];return-1^c}},{}],46:[function(i,l,u){var f,c=i("../utils/common"),d=i("./trees"),p=i("./adler32"),g=i("./crc32"),A=i("./messages"),m=0,y=4,E=0,C=-2,x=-1,w=4,v=2,D=8,B=9,z=286,P=30,N=19,Z=2*z+1,ie=15,F=3,K=258,re=K+F+1,Q=42,q=113,I=1,ue=2,fe=3,ce=4;function le(S,ge){return S.msg=A[ge],ge}function ne(S){return(S<<1)-(4<S?9:0)}function T(S){for(var ge=S.length;0<=--ge;)S[ge]=0}function _(S){var ge=S.state,de=ge.pending;de>S.avail_out&&(de=S.avail_out),de!==0&&(c.arraySet(S.output,ge.pending_buf,ge.pending_out,de,S.next_out),S.next_out+=de,ge.pending_out+=de,S.total_out+=de,S.avail_out-=de,ge.pending-=de,ge.pending===0&&(ge.pending_out=0))}function V(S,ge){d._tr_flush_block(S,0<=S.block_start?S.block_start:-1,S.strstart-S.block_start,ge),S.block_start=S.strstart,_(S.strm)}function U(S,ge){S.pending_buf[S.pending++]=ge}function he(S,ge){S.pending_buf[S.pending++]=ge>>>8&255,S.pending_buf[S.pending++]=255&ge}function be(S,ge){var de,Y,j=S.max_chain_length,H=S.strstart,J=S.prev_length,pe=S.nice_match,$=S.strstart>S.w_size-re?S.strstart-(S.w_size-re):0,ye=S.window,Re=S.w_mask,ke=S.prev,te=S.strstart+K,ee=ye[H+J-1],we=ye[H+J];S.prev_length>=S.good_match&&(j>>=2),pe>S.lookahead&&(pe=S.lookahead);do if(ye[(de=ge)+J]===we&&ye[de+J-1]===ee&&ye[de]===ye[H]&&ye[++de]===ye[H+1]){H+=2,de++;do;while(ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&H<te);if(Y=K-(te-H),H=te-K,J<Y){if(S.match_start=ge,pe<=(J=Y))break;ee=ye[H+J-1],we=ye[H+J]}}while((ge=ke[ge&Re])>$&&--j!=0);return J<=S.lookahead?J:S.lookahead}function Be(S){var ge,de,Y,j,H,J,pe,$,ye,Re,ke=S.w_size;do{if(j=S.window_size-S.lookahead-S.strstart,S.strstart>=ke+(ke-re)){for(c.arraySet(S.window,S.window,ke,ke,0),S.match_start-=ke,S.strstart-=ke,S.block_start-=ke,ge=de=S.hash_size;Y=S.head[--ge],S.head[ge]=ke<=Y?Y-ke:0,--de;);for(ge=de=ke;Y=S.prev[--ge],S.prev[ge]=ke<=Y?Y-ke:0,--de;);j+=ke}if(S.strm.avail_in===0)break;if(J=S.strm,pe=S.window,$=S.strstart+S.lookahead,ye=j,Re=void 0,Re=J.avail_in,ye<Re&&(Re=ye),de=Re===0?0:(J.avail_in-=Re,c.arraySet(pe,J.input,J.next_in,Re,$),J.state.wrap===1?J.adler=p(J.adler,pe,Re,$):J.state.wrap===2&&(J.adler=g(J.adler,pe,Re,$)),J.next_in+=Re,J.total_in+=Re,Re),S.lookahead+=de,S.lookahead+S.insert>=F)for(H=S.strstart-S.insert,S.ins_h=S.window[H],S.ins_h=(S.ins_h<<S.hash_shift^S.window[H+1])&S.hash_mask;S.insert&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[H+F-1])&S.hash_mask,S.prev[H&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=H,H++,S.insert--,!(S.lookahead+S.insert<F)););}while(S.lookahead<re&&S.strm.avail_in!==0)}function Ke(S,ge){for(var de,Y;;){if(S.lookahead<re){if(Be(S),S.lookahead<re&&ge===m)return I;if(S.lookahead===0)break}if(de=0,S.lookahead>=F&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+F-1])&S.hash_mask,de=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart),de!==0&&S.strstart-de<=S.w_size-re&&(S.match_length=be(S,de)),S.match_length>=F)if(Y=d._tr_tally(S,S.strstart-S.match_start,S.match_length-F),S.lookahead-=S.match_length,S.match_length<=S.max_lazy_match&&S.lookahead>=F){for(S.match_length--;S.strstart++,S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+F-1])&S.hash_mask,de=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart,--S.match_length!=0;);S.strstart++}else S.strstart+=S.match_length,S.match_length=0,S.ins_h=S.window[S.strstart],S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+1])&S.hash_mask;else Y=d._tr_tally(S,0,S.window[S.strstart]),S.lookahead--,S.strstart++;if(Y&&(V(S,!1),S.strm.avail_out===0))return I}return S.insert=S.strstart<F-1?S.strstart:F-1,ge===y?(V(S,!0),S.strm.avail_out===0?fe:ce):S.last_lit&&(V(S,!1),S.strm.avail_out===0)?I:ue}function Ue(S,ge){for(var de,Y,j;;){if(S.lookahead<re){if(Be(S),S.lookahead<re&&ge===m)return I;if(S.lookahead===0)break}if(de=0,S.lookahead>=F&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+F-1])&S.hash_mask,de=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart),S.prev_length=S.match_length,S.prev_match=S.match_start,S.match_length=F-1,de!==0&&S.prev_length<S.max_lazy_match&&S.strstart-de<=S.w_size-re&&(S.match_length=be(S,de),S.match_length<=5&&(S.strategy===1||S.match_length===F&&4096<S.strstart-S.match_start)&&(S.match_length=F-1)),S.prev_length>=F&&S.match_length<=S.prev_length){for(j=S.strstart+S.lookahead-F,Y=d._tr_tally(S,S.strstart-1-S.prev_match,S.prev_length-F),S.lookahead-=S.prev_length-1,S.prev_length-=2;++S.strstart<=j&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+F-1])&S.hash_mask,de=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart),--S.prev_length!=0;);if(S.match_available=0,S.match_length=F-1,S.strstart++,Y&&(V(S,!1),S.strm.avail_out===0))return I}else if(S.match_available){if((Y=d._tr_tally(S,0,S.window[S.strstart-1]))&&V(S,!1),S.strstart++,S.lookahead--,S.strm.avail_out===0)return I}else S.match_available=1,S.strstart++,S.lookahead--}return S.match_available&&(Y=d._tr_tally(S,0,S.window[S.strstart-1]),S.match_available=0),S.insert=S.strstart<F-1?S.strstart:F-1,ge===y?(V(S,!0),S.strm.avail_out===0?fe:ce):S.last_lit&&(V(S,!1),S.strm.avail_out===0)?I:ue}function Fe(S,ge,de,Y,j){this.good_length=S,this.max_lazy=ge,this.nice_length=de,this.max_chain=Y,this.func=j}function We(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=D,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new c.Buf16(2*Z),this.dyn_dtree=new c.Buf16(2*(2*P+1)),this.bl_tree=new c.Buf16(2*(2*N+1)),T(this.dyn_ltree),T(this.dyn_dtree),T(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new c.Buf16(ie+1),this.heap=new c.Buf16(2*z+1),T(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new c.Buf16(2*z+1),T(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function rt(S){var ge;return S&&S.state?(S.total_in=S.total_out=0,S.data_type=v,(ge=S.state).pending=0,ge.pending_out=0,ge.wrap<0&&(ge.wrap=-ge.wrap),ge.status=ge.wrap?Q:q,S.adler=ge.wrap===2?0:1,ge.last_flush=m,d._tr_init(ge),E):le(S,C)}function Ct(S){var ge=rt(S);return ge===E&&function(de){de.window_size=2*de.w_size,T(de.head),de.max_lazy_match=f[de.level].max_lazy,de.good_match=f[de.level].good_length,de.nice_match=f[de.level].nice_length,de.max_chain_length=f[de.level].max_chain,de.strstart=0,de.block_start=0,de.lookahead=0,de.insert=0,de.match_length=de.prev_length=F-1,de.match_available=0,de.ins_h=0}(S.state),ge}function Mt(S,ge,de,Y,j,H){if(!S)return C;var J=1;if(ge===x&&(ge=6),Y<0?(J=0,Y=-Y):15<Y&&(J=2,Y-=16),j<1||B<j||de!==D||Y<8||15<Y||ge<0||9<ge||H<0||w<H)return le(S,C);Y===8&&(Y=9);var pe=new We;return(S.state=pe).strm=S,pe.wrap=J,pe.gzhead=null,pe.w_bits=Y,pe.w_size=1<<pe.w_bits,pe.w_mask=pe.w_size-1,pe.hash_bits=j+7,pe.hash_size=1<<pe.hash_bits,pe.hash_mask=pe.hash_size-1,pe.hash_shift=~~((pe.hash_bits+F-1)/F),pe.window=new c.Buf8(2*pe.w_size),pe.head=new c.Buf16(pe.hash_size),pe.prev=new c.Buf16(pe.w_size),pe.lit_bufsize=1<<j+6,pe.pending_buf_size=4*pe.lit_bufsize,pe.pending_buf=new c.Buf8(pe.pending_buf_size),pe.d_buf=1*pe.lit_bufsize,pe.l_buf=3*pe.lit_bufsize,pe.level=ge,pe.strategy=H,pe.method=de,Ct(S)}f=[new Fe(0,0,0,0,function(S,ge){var de=65535;for(de>S.pending_buf_size-5&&(de=S.pending_buf_size-5);;){if(S.lookahead<=1){if(Be(S),S.lookahead===0&&ge===m)return I;if(S.lookahead===0)break}S.strstart+=S.lookahead,S.lookahead=0;var Y=S.block_start+de;if((S.strstart===0||S.strstart>=Y)&&(S.lookahead=S.strstart-Y,S.strstart=Y,V(S,!1),S.strm.avail_out===0)||S.strstart-S.block_start>=S.w_size-re&&(V(S,!1),S.strm.avail_out===0))return I}return S.insert=0,ge===y?(V(S,!0),S.strm.avail_out===0?fe:ce):(S.strstart>S.block_start&&(V(S,!1),S.strm.avail_out),I)}),new Fe(4,4,8,4,Ke),new Fe(4,5,16,8,Ke),new Fe(4,6,32,32,Ke),new Fe(4,4,16,16,Ue),new Fe(8,16,32,32,Ue),new Fe(8,16,128,128,Ue),new Fe(8,32,128,256,Ue),new Fe(32,128,258,1024,Ue),new Fe(32,258,258,4096,Ue)],u.deflateInit=function(S,ge){return Mt(S,ge,D,15,8,0)},u.deflateInit2=Mt,u.deflateReset=Ct,u.deflateResetKeep=rt,u.deflateSetHeader=function(S,ge){return S&&S.state?S.state.wrap!==2?C:(S.state.gzhead=ge,E):C},u.deflate=function(S,ge){var de,Y,j,H;if(!S||!S.state||5<ge||ge<0)return S?le(S,C):C;if(Y=S.state,!S.output||!S.input&&S.avail_in!==0||Y.status===666&&ge!==y)return le(S,S.avail_out===0?-5:C);if(Y.strm=S,de=Y.last_flush,Y.last_flush=ge,Y.status===Q)if(Y.wrap===2)S.adler=0,U(Y,31),U(Y,139),U(Y,8),Y.gzhead?(U(Y,(Y.gzhead.text?1:0)+(Y.gzhead.hcrc?2:0)+(Y.gzhead.extra?4:0)+(Y.gzhead.name?8:0)+(Y.gzhead.comment?16:0)),U(Y,255&Y.gzhead.time),U(Y,Y.gzhead.time>>8&255),U(Y,Y.gzhead.time>>16&255),U(Y,Y.gzhead.time>>24&255),U(Y,Y.level===9?2:2<=Y.strategy||Y.level<2?4:0),U(Y,255&Y.gzhead.os),Y.gzhead.extra&&Y.gzhead.extra.length&&(U(Y,255&Y.gzhead.extra.length),U(Y,Y.gzhead.extra.length>>8&255)),Y.gzhead.hcrc&&(S.adler=g(S.adler,Y.pending_buf,Y.pending,0)),Y.gzindex=0,Y.status=69):(U(Y,0),U(Y,0),U(Y,0),U(Y,0),U(Y,0),U(Y,Y.level===9?2:2<=Y.strategy||Y.level<2?4:0),U(Y,3),Y.status=q);else{var J=D+(Y.w_bits-8<<4)<<8;J|=(2<=Y.strategy||Y.level<2?0:Y.level<6?1:Y.level===6?2:3)<<6,Y.strstart!==0&&(J|=32),J+=31-J%31,Y.status=q,he(Y,J),Y.strstart!==0&&(he(Y,S.adler>>>16),he(Y,65535&S.adler)),S.adler=1}if(Y.status===69)if(Y.gzhead.extra){for(j=Y.pending;Y.gzindex<(65535&Y.gzhead.extra.length)&&(Y.pending!==Y.pending_buf_size||(Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),_(S),j=Y.pending,Y.pending!==Y.pending_buf_size));)U(Y,255&Y.gzhead.extra[Y.gzindex]),Y.gzindex++;Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),Y.gzindex===Y.gzhead.extra.length&&(Y.gzindex=0,Y.status=73)}else Y.status=73;if(Y.status===73)if(Y.gzhead.name){j=Y.pending;do{if(Y.pending===Y.pending_buf_size&&(Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),_(S),j=Y.pending,Y.pending===Y.pending_buf_size)){H=1;break}H=Y.gzindex<Y.gzhead.name.length?255&Y.gzhead.name.charCodeAt(Y.gzindex++):0,U(Y,H)}while(H!==0);Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),H===0&&(Y.gzindex=0,Y.status=91)}else Y.status=91;if(Y.status===91)if(Y.gzhead.comment){j=Y.pending;do{if(Y.pending===Y.pending_buf_size&&(Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),_(S),j=Y.pending,Y.pending===Y.pending_buf_size)){H=1;break}H=Y.gzindex<Y.gzhead.comment.length?255&Y.gzhead.comment.charCodeAt(Y.gzindex++):0,U(Y,H)}while(H!==0);Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),H===0&&(Y.status=103)}else Y.status=103;if(Y.status===103&&(Y.gzhead.hcrc?(Y.pending+2>Y.pending_buf_size&&_(S),Y.pending+2<=Y.pending_buf_size&&(U(Y,255&S.adler),U(Y,S.adler>>8&255),S.adler=0,Y.status=q)):Y.status=q),Y.pending!==0){if(_(S),S.avail_out===0)return Y.last_flush=-1,E}else if(S.avail_in===0&&ne(ge)<=ne(de)&&ge!==y)return le(S,-5);if(Y.status===666&&S.avail_in!==0)return le(S,-5);if(S.avail_in!==0||Y.lookahead!==0||ge!==m&&Y.status!==666){var pe=Y.strategy===2?function($,ye){for(var Re;;){if($.lookahead===0&&(Be($),$.lookahead===0)){if(ye===m)return I;break}if($.match_length=0,Re=d._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++,Re&&(V($,!1),$.strm.avail_out===0))return I}return $.insert=0,ye===y?(V($,!0),$.strm.avail_out===0?fe:ce):$.last_lit&&(V($,!1),$.strm.avail_out===0)?I:ue}(Y,ge):Y.strategy===3?function($,ye){for(var Re,ke,te,ee,we=$.window;;){if($.lookahead<=K){if(Be($),$.lookahead<=K&&ye===m)return I;if($.lookahead===0)break}if($.match_length=0,$.lookahead>=F&&0<$.strstart&&(ke=we[te=$.strstart-1])===we[++te]&&ke===we[++te]&&ke===we[++te]){ee=$.strstart+K;do;while(ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&te<ee);$.match_length=K-(ee-te),$.match_length>$.lookahead&&($.match_length=$.lookahead)}if($.match_length>=F?(Re=d._tr_tally($,1,$.match_length-F),$.lookahead-=$.match_length,$.strstart+=$.match_length,$.match_length=0):(Re=d._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++),Re&&(V($,!1),$.strm.avail_out===0))return I}return $.insert=0,ye===y?(V($,!0),$.strm.avail_out===0?fe:ce):$.last_lit&&(V($,!1),$.strm.avail_out===0)?I:ue}(Y,ge):f[Y.level].func(Y,ge);if(pe!==fe&&pe!==ce||(Y.status=666),pe===I||pe===fe)return S.avail_out===0&&(Y.last_flush=-1),E;if(pe===ue&&(ge===1?d._tr_align(Y):ge!==5&&(d._tr_stored_block(Y,0,0,!1),ge===3&&(T(Y.head),Y.lookahead===0&&(Y.strstart=0,Y.block_start=0,Y.insert=0))),_(S),S.avail_out===0))return Y.last_flush=-1,E}return ge!==y?E:Y.wrap<=0?1:(Y.wrap===2?(U(Y,255&S.adler),U(Y,S.adler>>8&255),U(Y,S.adler>>16&255),U(Y,S.adler>>24&255),U(Y,255&S.total_in),U(Y,S.total_in>>8&255),U(Y,S.total_in>>16&255),U(Y,S.total_in>>24&255)):(he(Y,S.adler>>>16),he(Y,65535&S.adler)),_(S),0<Y.wrap&&(Y.wrap=-Y.wrap),Y.pending!==0?E:1)},u.deflateEnd=function(S){var ge;return S&&S.state?(ge=S.state.status)!==Q&&ge!==69&&ge!==73&&ge!==91&&ge!==103&&ge!==q&&ge!==666?le(S,C):(S.state=null,ge===q?le(S,-3):E):C},u.deflateSetDictionary=function(S,ge){var de,Y,j,H,J,pe,$,ye,Re=ge.length;if(!S||!S.state||(H=(de=S.state).wrap)===2||H===1&&de.status!==Q||de.lookahead)return C;for(H===1&&(S.adler=p(S.adler,ge,Re,0)),de.wrap=0,Re>=de.w_size&&(H===0&&(T(de.head),de.strstart=0,de.block_start=0,de.insert=0),ye=new c.Buf8(de.w_size),c.arraySet(ye,ge,Re-de.w_size,de.w_size,0),ge=ye,Re=de.w_size),J=S.avail_in,pe=S.next_in,$=S.input,S.avail_in=Re,S.next_in=0,S.input=ge,Be(de);de.lookahead>=F;){for(Y=de.strstart,j=de.lookahead-(F-1);de.ins_h=(de.ins_h<<de.hash_shift^de.window[Y+F-1])&de.hash_mask,de.prev[Y&de.w_mask]=de.head[de.ins_h],de.head[de.ins_h]=Y,Y++,--j;);de.strstart=Y,de.lookahead=F-1,Be(de)}return de.strstart+=de.lookahead,de.block_start=de.strstart,de.insert=de.lookahead,de.lookahead=0,de.match_length=de.prev_length=F-1,de.match_available=0,S.next_in=pe,S.input=$,S.avail_in=J,de.wrap=H,E},u.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(i,l,u){l.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(i,l,u){l.exports=function(f,c){var d,p,g,A,m,y,E,C,x,w,v,D,B,z,P,N,Z,ie,F,K,re,Q,q,I,ue;d=f.state,p=f.next_in,I=f.input,g=p+(f.avail_in-5),A=f.next_out,ue=f.output,m=A-(c-f.avail_out),y=A+(f.avail_out-257),E=d.dmax,C=d.wsize,x=d.whave,w=d.wnext,v=d.window,D=d.hold,B=d.bits,z=d.lencode,P=d.distcode,N=(1<<d.lenbits)-1,Z=(1<<d.distbits)-1;e:do{B<15&&(D+=I[p++]<<B,B+=8,D+=I[p++]<<B,B+=8),ie=z[D&N];t:for(;;){if(D>>>=F=ie>>>24,B-=F,(F=ie>>>16&255)===0)ue[A++]=65535&ie;else{if(!(16&F)){if((64&F)==0){ie=z[(65535&ie)+(D&(1<<F)-1)];continue t}if(32&F){d.mode=12;break e}f.msg="invalid literal/length code",d.mode=30;break e}K=65535&ie,(F&=15)&&(B<F&&(D+=I[p++]<<B,B+=8),K+=D&(1<<F)-1,D>>>=F,B-=F),B<15&&(D+=I[p++]<<B,B+=8,D+=I[p++]<<B,B+=8),ie=P[D&Z];n:for(;;){if(D>>>=F=ie>>>24,B-=F,!(16&(F=ie>>>16&255))){if((64&F)==0){ie=P[(65535&ie)+(D&(1<<F)-1)];continue n}f.msg="invalid distance code",d.mode=30;break e}if(re=65535&ie,B<(F&=15)&&(D+=I[p++]<<B,(B+=8)<F&&(D+=I[p++]<<B,B+=8)),E<(re+=D&(1<<F)-1)){f.msg="invalid distance too far back",d.mode=30;break e}if(D>>>=F,B-=F,(F=A-m)<re){if(x<(F=re-F)&&d.sane){f.msg="invalid distance too far back",d.mode=30;break e}if(q=v,(Q=0)===w){if(Q+=C-F,F<K){for(K-=F;ue[A++]=v[Q++],--F;);Q=A-re,q=ue}}else if(w<F){if(Q+=C+w-F,(F-=w)<K){for(K-=F;ue[A++]=v[Q++],--F;);if(Q=0,w<K){for(K-=F=w;ue[A++]=v[Q++],--F;);Q=A-re,q=ue}}}else if(Q+=w-F,F<K){for(K-=F;ue[A++]=v[Q++],--F;);Q=A-re,q=ue}for(;2<K;)ue[A++]=q[Q++],ue[A++]=q[Q++],ue[A++]=q[Q++],K-=3;K&&(ue[A++]=q[Q++],1<K&&(ue[A++]=q[Q++]))}else{for(Q=A-re;ue[A++]=ue[Q++],ue[A++]=ue[Q++],ue[A++]=ue[Q++],2<(K-=3););K&&(ue[A++]=ue[Q++],1<K&&(ue[A++]=ue[Q++]))}break}}break}}while(p<g&&A<y);p-=K=B>>3,D&=(1<<(B-=K<<3))-1,f.next_in=p,f.next_out=A,f.avail_in=p<g?g-p+5:5-(p-g),f.avail_out=A<y?y-A+257:257-(A-y),d.hold=D,d.bits=B}},{}],49:[function(i,l,u){var f=i("../utils/common"),c=i("./adler32"),d=i("./crc32"),p=i("./inffast"),g=i("./inftrees"),A=1,m=2,y=0,E=-2,C=1,x=852,w=592;function v(Q){return(Q>>>24&255)+(Q>>>8&65280)+((65280&Q)<<8)+((255&Q)<<24)}function D(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new f.Buf16(320),this.work=new f.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function B(Q){var q;return Q&&Q.state?(q=Q.state,Q.total_in=Q.total_out=q.total=0,Q.msg="",q.wrap&&(Q.adler=1&q.wrap),q.mode=C,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new f.Buf32(x),q.distcode=q.distdyn=new f.Buf32(w),q.sane=1,q.back=-1,y):E}function z(Q){var q;return Q&&Q.state?((q=Q.state).wsize=0,q.whave=0,q.wnext=0,B(Q)):E}function P(Q,q){var I,ue;return Q&&Q.state?(ue=Q.state,q<0?(I=0,q=-q):(I=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?E:(ue.window!==null&&ue.wbits!==q&&(ue.window=null),ue.wrap=I,ue.wbits=q,z(Q))):E}function N(Q,q){var I,ue;return Q?(ue=new D,(Q.state=ue).window=null,(I=P(Q,q))!==y&&(Q.state=null),I):E}var Z,ie,F=!0;function K(Q){if(F){var q;for(Z=new f.Buf32(512),ie=new f.Buf32(32),q=0;q<144;)Q.lens[q++]=8;for(;q<256;)Q.lens[q++]=9;for(;q<280;)Q.lens[q++]=7;for(;q<288;)Q.lens[q++]=8;for(g(A,Q.lens,0,288,Z,0,Q.work,{bits:9}),q=0;q<32;)Q.lens[q++]=5;g(m,Q.lens,0,32,ie,0,Q.work,{bits:5}),F=!1}Q.lencode=Z,Q.lenbits=9,Q.distcode=ie,Q.distbits=5}function re(Q,q,I,ue){var fe,ce=Q.state;return ce.window===null&&(ce.wsize=1<<ce.wbits,ce.wnext=0,ce.whave=0,ce.window=new f.Buf8(ce.wsize)),ue>=ce.wsize?(f.arraySet(ce.window,q,I-ce.wsize,ce.wsize,0),ce.wnext=0,ce.whave=ce.wsize):(ue<(fe=ce.wsize-ce.wnext)&&(fe=ue),f.arraySet(ce.window,q,I-ue,fe,ce.wnext),(ue-=fe)?(f.arraySet(ce.window,q,I-ue,ue,0),ce.wnext=ue,ce.whave=ce.wsize):(ce.wnext+=fe,ce.wnext===ce.wsize&&(ce.wnext=0),ce.whave<ce.wsize&&(ce.whave+=fe))),0}u.inflateReset=z,u.inflateReset2=P,u.inflateResetKeep=B,u.inflateInit=function(Q){return N(Q,15)},u.inflateInit2=N,u.inflate=function(Q,q){var I,ue,fe,ce,le,ne,T,_,V,U,he,be,Be,Ke,Ue,Fe,We,rt,Ct,Mt,S,ge,de,Y,j=0,H=new f.Buf8(4),J=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!Q||!Q.state||!Q.output||!Q.input&&Q.avail_in!==0)return E;(I=Q.state).mode===12&&(I.mode=13),le=Q.next_out,fe=Q.output,T=Q.avail_out,ce=Q.next_in,ue=Q.input,ne=Q.avail_in,_=I.hold,V=I.bits,U=ne,he=T,ge=y;e:for(;;)switch(I.mode){case C:if(I.wrap===0){I.mode=13;break}for(;V<16;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(2&I.wrap&&_===35615){H[I.check=0]=255&_,H[1]=_>>>8&255,I.check=d(I.check,H,2,0),V=_=0,I.mode=2;break}if(I.flags=0,I.head&&(I.head.done=!1),!(1&I.wrap)||(((255&_)<<8)+(_>>8))%31){Q.msg="incorrect header check",I.mode=30;break}if((15&_)!=8){Q.msg="unknown compression method",I.mode=30;break}if(V-=4,S=8+(15&(_>>>=4)),I.wbits===0)I.wbits=S;else if(S>I.wbits){Q.msg="invalid window size",I.mode=30;break}I.dmax=1<<S,Q.adler=I.check=1,I.mode=512&_?10:12,V=_=0;break;case 2:for(;V<16;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(I.flags=_,(255&I.flags)!=8){Q.msg="unknown compression method",I.mode=30;break}if(57344&I.flags){Q.msg="unknown header flags set",I.mode=30;break}I.head&&(I.head.text=_>>8&1),512&I.flags&&(H[0]=255&_,H[1]=_>>>8&255,I.check=d(I.check,H,2,0)),V=_=0,I.mode=3;case 3:for(;V<32;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.head&&(I.head.time=_),512&I.flags&&(H[0]=255&_,H[1]=_>>>8&255,H[2]=_>>>16&255,H[3]=_>>>24&255,I.check=d(I.check,H,4,0)),V=_=0,I.mode=4;case 4:for(;V<16;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.head&&(I.head.xflags=255&_,I.head.os=_>>8),512&I.flags&&(H[0]=255&_,H[1]=_>>>8&255,I.check=d(I.check,H,2,0)),V=_=0,I.mode=5;case 5:if(1024&I.flags){for(;V<16;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.length=_,I.head&&(I.head.extra_len=_),512&I.flags&&(H[0]=255&_,H[1]=_>>>8&255,I.check=d(I.check,H,2,0)),V=_=0}else I.head&&(I.head.extra=null);I.mode=6;case 6:if(1024&I.flags&&(ne<(be=I.length)&&(be=ne),be&&(I.head&&(S=I.head.extra_len-I.length,I.head.extra||(I.head.extra=new Array(I.head.extra_len)),f.arraySet(I.head.extra,ue,ce,be,S)),512&I.flags&&(I.check=d(I.check,ue,be,ce)),ne-=be,ce+=be,I.length-=be),I.length))break e;I.length=0,I.mode=7;case 7:if(2048&I.flags){if(ne===0)break e;for(be=0;S=ue[ce+be++],I.head&&S&&I.length<65536&&(I.head.name+=String.fromCharCode(S)),S&&be<ne;);if(512&I.flags&&(I.check=d(I.check,ue,be,ce)),ne-=be,ce+=be,S)break e}else I.head&&(I.head.name=null);I.length=0,I.mode=8;case 8:if(4096&I.flags){if(ne===0)break e;for(be=0;S=ue[ce+be++],I.head&&S&&I.length<65536&&(I.head.comment+=String.fromCharCode(S)),S&&be<ne;);if(512&I.flags&&(I.check=d(I.check,ue,be,ce)),ne-=be,ce+=be,S)break e}else I.head&&(I.head.comment=null);I.mode=9;case 9:if(512&I.flags){for(;V<16;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(_!==(65535&I.check)){Q.msg="header crc mismatch",I.mode=30;break}V=_=0}I.head&&(I.head.hcrc=I.flags>>9&1,I.head.done=!0),Q.adler=I.check=0,I.mode=12;break;case 10:for(;V<32;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}Q.adler=I.check=v(_),V=_=0,I.mode=11;case 11:if(I.havedict===0)return Q.next_out=le,Q.avail_out=T,Q.next_in=ce,Q.avail_in=ne,I.hold=_,I.bits=V,2;Q.adler=I.check=1,I.mode=12;case 12:if(q===5||q===6)break e;case 13:if(I.last){_>>>=7&V,V-=7&V,I.mode=27;break}for(;V<3;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}switch(I.last=1&_,V-=1,3&(_>>>=1)){case 0:I.mode=14;break;case 1:if(K(I),I.mode=20,q!==6)break;_>>>=2,V-=2;break e;case 2:I.mode=17;break;case 3:Q.msg="invalid block type",I.mode=30}_>>>=2,V-=2;break;case 14:for(_>>>=7&V,V-=7&V;V<32;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if((65535&_)!=(_>>>16^65535)){Q.msg="invalid stored block lengths",I.mode=30;break}if(I.length=65535&_,V=_=0,I.mode=15,q===6)break e;case 15:I.mode=16;case 16:if(be=I.length){if(ne<be&&(be=ne),T<be&&(be=T),be===0)break e;f.arraySet(fe,ue,ce,be,le),ne-=be,ce+=be,T-=be,le+=be,I.length-=be;break}I.mode=12;break;case 17:for(;V<14;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(I.nlen=257+(31&_),_>>>=5,V-=5,I.ndist=1+(31&_),_>>>=5,V-=5,I.ncode=4+(15&_),_>>>=4,V-=4,286<I.nlen||30<I.ndist){Q.msg="too many length or distance symbols",I.mode=30;break}I.have=0,I.mode=18;case 18:for(;I.have<I.ncode;){for(;V<3;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.lens[J[I.have++]]=7&_,_>>>=3,V-=3}for(;I.have<19;)I.lens[J[I.have++]]=0;if(I.lencode=I.lendyn,I.lenbits=7,de={bits:I.lenbits},ge=g(0,I.lens,0,19,I.lencode,0,I.work,de),I.lenbits=de.bits,ge){Q.msg="invalid code lengths set",I.mode=30;break}I.have=0,I.mode=19;case 19:for(;I.have<I.nlen+I.ndist;){for(;Fe=(j=I.lencode[_&(1<<I.lenbits)-1])>>>16&255,We=65535&j,!((Ue=j>>>24)<=V);){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(We<16)_>>>=Ue,V-=Ue,I.lens[I.have++]=We;else{if(We===16){for(Y=Ue+2;V<Y;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(_>>>=Ue,V-=Ue,I.have===0){Q.msg="invalid bit length repeat",I.mode=30;break}S=I.lens[I.have-1],be=3+(3&_),_>>>=2,V-=2}else if(We===17){for(Y=Ue+3;V<Y;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}V-=Ue,S=0,be=3+(7&(_>>>=Ue)),_>>>=3,V-=3}else{for(Y=Ue+7;V<Y;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}V-=Ue,S=0,be=11+(127&(_>>>=Ue)),_>>>=7,V-=7}if(I.have+be>I.nlen+I.ndist){Q.msg="invalid bit length repeat",I.mode=30;break}for(;be--;)I.lens[I.have++]=S}}if(I.mode===30)break;if(I.lens[256]===0){Q.msg="invalid code -- missing end-of-block",I.mode=30;break}if(I.lenbits=9,de={bits:I.lenbits},ge=g(A,I.lens,0,I.nlen,I.lencode,0,I.work,de),I.lenbits=de.bits,ge){Q.msg="invalid literal/lengths set",I.mode=30;break}if(I.distbits=6,I.distcode=I.distdyn,de={bits:I.distbits},ge=g(m,I.lens,I.nlen,I.ndist,I.distcode,0,I.work,de),I.distbits=de.bits,ge){Q.msg="invalid distances set",I.mode=30;break}if(I.mode=20,q===6)break e;case 20:I.mode=21;case 21:if(6<=ne&&258<=T){Q.next_out=le,Q.avail_out=T,Q.next_in=ce,Q.avail_in=ne,I.hold=_,I.bits=V,p(Q,he),le=Q.next_out,fe=Q.output,T=Q.avail_out,ce=Q.next_in,ue=Q.input,ne=Q.avail_in,_=I.hold,V=I.bits,I.mode===12&&(I.back=-1);break}for(I.back=0;Fe=(j=I.lencode[_&(1<<I.lenbits)-1])>>>16&255,We=65535&j,!((Ue=j>>>24)<=V);){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(Fe&&(240&Fe)==0){for(rt=Ue,Ct=Fe,Mt=We;Fe=(j=I.lencode[Mt+((_&(1<<rt+Ct)-1)>>rt)])>>>16&255,We=65535&j,!(rt+(Ue=j>>>24)<=V);){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}_>>>=rt,V-=rt,I.back+=rt}if(_>>>=Ue,V-=Ue,I.back+=Ue,I.length=We,Fe===0){I.mode=26;break}if(32&Fe){I.back=-1,I.mode=12;break}if(64&Fe){Q.msg="invalid literal/length code",I.mode=30;break}I.extra=15&Fe,I.mode=22;case 22:if(I.extra){for(Y=I.extra;V<Y;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.length+=_&(1<<I.extra)-1,_>>>=I.extra,V-=I.extra,I.back+=I.extra}I.was=I.length,I.mode=23;case 23:for(;Fe=(j=I.distcode[_&(1<<I.distbits)-1])>>>16&255,We=65535&j,!((Ue=j>>>24)<=V);){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if((240&Fe)==0){for(rt=Ue,Ct=Fe,Mt=We;Fe=(j=I.distcode[Mt+((_&(1<<rt+Ct)-1)>>rt)])>>>16&255,We=65535&j,!(rt+(Ue=j>>>24)<=V);){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}_>>>=rt,V-=rt,I.back+=rt}if(_>>>=Ue,V-=Ue,I.back+=Ue,64&Fe){Q.msg="invalid distance code",I.mode=30;break}I.offset=We,I.extra=15&Fe,I.mode=24;case 24:if(I.extra){for(Y=I.extra;V<Y;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.offset+=_&(1<<I.extra)-1,_>>>=I.extra,V-=I.extra,I.back+=I.extra}if(I.offset>I.dmax){Q.msg="invalid distance too far back",I.mode=30;break}I.mode=25;case 25:if(T===0)break e;if(be=he-T,I.offset>be){if((be=I.offset-be)>I.whave&&I.sane){Q.msg="invalid distance too far back",I.mode=30;break}Be=be>I.wnext?(be-=I.wnext,I.wsize-be):I.wnext-be,be>I.length&&(be=I.length),Ke=I.window}else Ke=fe,Be=le-I.offset,be=I.length;for(T<be&&(be=T),T-=be,I.length-=be;fe[le++]=Ke[Be++],--be;);I.length===0&&(I.mode=21);break;case 26:if(T===0)break e;fe[le++]=I.length,T--,I.mode=21;break;case 27:if(I.wrap){for(;V<32;){if(ne===0)break e;ne--,_|=ue[ce++]<<V,V+=8}if(he-=T,Q.total_out+=he,I.total+=he,he&&(Q.adler=I.check=I.flags?d(I.check,fe,he,le-he):c(I.check,fe,he,le-he)),he=T,(I.flags?_:v(_))!==I.check){Q.msg="incorrect data check",I.mode=30;break}V=_=0}I.mode=28;case 28:if(I.wrap&&I.flags){for(;V<32;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(_!==(4294967295&I.total)){Q.msg="incorrect length check",I.mode=30;break}V=_=0}I.mode=29;case 29:ge=1;break e;case 30:ge=-3;break e;case 31:return-4;case 32:default:return E}return Q.next_out=le,Q.avail_out=T,Q.next_in=ce,Q.avail_in=ne,I.hold=_,I.bits=V,(I.wsize||he!==Q.avail_out&&I.mode<30&&(I.mode<27||q!==4))&&re(Q,Q.output,Q.next_out,he-Q.avail_out)?(I.mode=31,-4):(U-=Q.avail_in,he-=Q.avail_out,Q.total_in+=U,Q.total_out+=he,I.total+=he,I.wrap&&he&&(Q.adler=I.check=I.flags?d(I.check,fe,he,Q.next_out-he):c(I.check,fe,he,Q.next_out-he)),Q.data_type=I.bits+(I.last?64:0)+(I.mode===12?128:0)+(I.mode===20||I.mode===15?256:0),(U==0&&he===0||q===4)&&ge===y&&(ge=-5),ge)},u.inflateEnd=function(Q){if(!Q||!Q.state)return E;var q=Q.state;return q.window&&(q.window=null),Q.state=null,y},u.inflateGetHeader=function(Q,q){var I;return Q&&Q.state?(2&(I=Q.state).wrap)==0?E:((I.head=q).done=!1,y):E},u.inflateSetDictionary=function(Q,q){var I,ue=q.length;return Q&&Q.state?(I=Q.state).wrap!==0&&I.mode!==11?E:I.mode===11&&c(1,q,ue,0)!==I.check?-3:re(Q,q,ue,ue)?(I.mode=31,-4):(I.havedict=1,y):E},u.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(i,l,u){var f=i("../utils/common"),c=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],d=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],p=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],g=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];l.exports=function(A,m,y,E,C,x,w,v){var D,B,z,P,N,Z,ie,F,K,re=v.bits,Q=0,q=0,I=0,ue=0,fe=0,ce=0,le=0,ne=0,T=0,_=0,V=null,U=0,he=new f.Buf16(16),be=new f.Buf16(16),Be=null,Ke=0;for(Q=0;Q<=15;Q++)he[Q]=0;for(q=0;q<E;q++)he[m[y+q]]++;for(fe=re,ue=15;1<=ue&&he[ue]===0;ue--);if(ue<fe&&(fe=ue),ue===0)return C[x++]=20971520,C[x++]=20971520,v.bits=1,0;for(I=1;I<ue&&he[I]===0;I++);for(fe<I&&(fe=I),Q=ne=1;Q<=15;Q++)if(ne<<=1,(ne-=he[Q])<0)return-1;if(0<ne&&(A===0||ue!==1))return-1;for(be[1]=0,Q=1;Q<15;Q++)be[Q+1]=be[Q]+he[Q];for(q=0;q<E;q++)m[y+q]!==0&&(w[be[m[y+q]]++]=q);if(Z=A===0?(V=Be=w,19):A===1?(V=c,U-=257,Be=d,Ke-=257,256):(V=p,Be=g,-1),Q=I,N=x,le=q=_=0,z=-1,P=(T=1<<(ce=fe))-1,A===1&&852<T||A===2&&592<T)return 1;for(;;){for(ie=Q-le,K=w[q]<Z?(F=0,w[q]):w[q]>Z?(F=Be[Ke+w[q]],V[U+w[q]]):(F=96,0),D=1<<Q-le,I=B=1<<ce;C[N+(_>>le)+(B-=D)]=ie<<24|F<<16|K|0,B!==0;);for(D=1<<Q-1;_&D;)D>>=1;if(D!==0?(_&=D-1,_+=D):_=0,q++,--he[Q]==0){if(Q===ue)break;Q=m[y+w[q]]}if(fe<Q&&(_&P)!==z){for(le===0&&(le=fe),N+=I,ne=1<<(ce=Q-le);ce+le<ue&&!((ne-=he[ce+le])<=0);)ce++,ne<<=1;if(T+=1<<ce,A===1&&852<T||A===2&&592<T)return 1;C[z=_&P]=fe<<24|ce<<16|N-x|0}}return _!==0&&(C[N+_]=Q-le<<24|4194304|0),v.bits=fe,0}},{"../utils/common":41}],51:[function(i,l,u){l.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(i,l,u){var f=i("../utils/common"),c=0,d=1;function p(j){for(var H=j.length;0<=--H;)j[H]=0}var g=0,A=29,m=256,y=m+1+A,E=30,C=19,x=2*y+1,w=15,v=16,D=7,B=256,z=16,P=17,N=18,Z=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ie=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],F=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],K=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],re=new Array(2*(y+2));p(re);var Q=new Array(2*E);p(Q);var q=new Array(512);p(q);var I=new Array(256);p(I);var ue=new Array(A);p(ue);var fe,ce,le,ne=new Array(E);function T(j,H,J,pe,$){this.static_tree=j,this.extra_bits=H,this.extra_base=J,this.elems=pe,this.max_length=$,this.has_stree=j&&j.length}function _(j,H){this.dyn_tree=j,this.max_code=0,this.stat_desc=H}function V(j){return j<256?q[j]:q[256+(j>>>7)]}function U(j,H){j.pending_buf[j.pending++]=255&H,j.pending_buf[j.pending++]=H>>>8&255}function he(j,H,J){j.bi_valid>v-J?(j.bi_buf|=H<<j.bi_valid&65535,U(j,j.bi_buf),j.bi_buf=H>>v-j.bi_valid,j.bi_valid+=J-v):(j.bi_buf|=H<<j.bi_valid&65535,j.bi_valid+=J)}function be(j,H,J){he(j,J[2*H],J[2*H+1])}function Be(j,H){for(var J=0;J|=1&j,j>>>=1,J<<=1,0<--H;);return J>>>1}function Ke(j,H,J){var pe,$,ye=new Array(w+1),Re=0;for(pe=1;pe<=w;pe++)ye[pe]=Re=Re+J[pe-1]<<1;for($=0;$<=H;$++){var ke=j[2*$+1];ke!==0&&(j[2*$]=Be(ye[ke]++,ke))}}function Ue(j){var H;for(H=0;H<y;H++)j.dyn_ltree[2*H]=0;for(H=0;H<E;H++)j.dyn_dtree[2*H]=0;for(H=0;H<C;H++)j.bl_tree[2*H]=0;j.dyn_ltree[2*B]=1,j.opt_len=j.static_len=0,j.last_lit=j.matches=0}function Fe(j){8<j.bi_valid?U(j,j.bi_buf):0<j.bi_valid&&(j.pending_buf[j.pending++]=j.bi_buf),j.bi_buf=0,j.bi_valid=0}function We(j,H,J,pe){var $=2*H,ye=2*J;return j[$]<j[ye]||j[$]===j[ye]&&pe[H]<=pe[J]}function rt(j,H,J){for(var pe=j.heap[J],$=J<<1;$<=j.heap_len&&($<j.heap_len&&We(H,j.heap[$+1],j.heap[$],j.depth)&&$++,!We(H,pe,j.heap[$],j.depth));)j.heap[J]=j.heap[$],J=$,$<<=1;j.heap[J]=pe}function Ct(j,H,J){var pe,$,ye,Re,ke=0;if(j.last_lit!==0)for(;pe=j.pending_buf[j.d_buf+2*ke]<<8|j.pending_buf[j.d_buf+2*ke+1],$=j.pending_buf[j.l_buf+ke],ke++,pe===0?be(j,$,H):(be(j,(ye=I[$])+m+1,H),(Re=Z[ye])!==0&&he(j,$-=ue[ye],Re),be(j,ye=V(--pe),J),(Re=ie[ye])!==0&&he(j,pe-=ne[ye],Re)),ke<j.last_lit;);be(j,B,H)}function Mt(j,H){var J,pe,$,ye=H.dyn_tree,Re=H.stat_desc.static_tree,ke=H.stat_desc.has_stree,te=H.stat_desc.elems,ee=-1;for(j.heap_len=0,j.heap_max=x,J=0;J<te;J++)ye[2*J]!==0?(j.heap[++j.heap_len]=ee=J,j.depth[J]=0):ye[2*J+1]=0;for(;j.heap_len<2;)ye[2*($=j.heap[++j.heap_len]=ee<2?++ee:0)]=1,j.depth[$]=0,j.opt_len--,ke&&(j.static_len-=Re[2*$+1]);for(H.max_code=ee,J=j.heap_len>>1;1<=J;J--)rt(j,ye,J);for($=te;J=j.heap[1],j.heap[1]=j.heap[j.heap_len--],rt(j,ye,1),pe=j.heap[1],j.heap[--j.heap_max]=J,j.heap[--j.heap_max]=pe,ye[2*$]=ye[2*J]+ye[2*pe],j.depth[$]=(j.depth[J]>=j.depth[pe]?j.depth[J]:j.depth[pe])+1,ye[2*J+1]=ye[2*pe+1]=$,j.heap[1]=$++,rt(j,ye,1),2<=j.heap_len;);j.heap[--j.heap_max]=j.heap[1],function(we,Oe){var Ge,tt,st,Xe,Rt,ht,yt=Oe.dyn_tree,M=Oe.max_code,se=Oe.stat_desc.static_tree,Me=Oe.stat_desc.has_stree,Ne=Oe.stat_desc.extra_bits,Ye=Oe.stat_desc.extra_base,ot=Oe.stat_desc.max_length,it=0;for(Xe=0;Xe<=w;Xe++)we.bl_count[Xe]=0;for(yt[2*we.heap[we.heap_max]+1]=0,Ge=we.heap_max+1;Ge<x;Ge++)ot<(Xe=yt[2*yt[2*(tt=we.heap[Ge])+1]+1]+1)&&(Xe=ot,it++),yt[2*tt+1]=Xe,M<tt||(we.bl_count[Xe]++,Rt=0,Ye<=tt&&(Rt=Ne[tt-Ye]),ht=yt[2*tt],we.opt_len+=ht*(Xe+Rt),Me&&(we.static_len+=ht*(se[2*tt+1]+Rt)));if(it!==0){do{for(Xe=ot-1;we.bl_count[Xe]===0;)Xe--;we.bl_count[Xe]--,we.bl_count[Xe+1]+=2,we.bl_count[ot]--,it-=2}while(0<it);for(Xe=ot;Xe!==0;Xe--)for(tt=we.bl_count[Xe];tt!==0;)M<(st=we.heap[--Ge])||(yt[2*st+1]!==Xe&&(we.opt_len+=(Xe-yt[2*st+1])*yt[2*st],yt[2*st+1]=Xe),tt--)}}(j,H),Ke(ye,ee,j.bl_count)}function S(j,H,J){var pe,$,ye=-1,Re=H[1],ke=0,te=7,ee=4;for(Re===0&&(te=138,ee=3),H[2*(J+1)+1]=65535,pe=0;pe<=J;pe++)$=Re,Re=H[2*(pe+1)+1],++ke<te&&$===Re||(ke<ee?j.bl_tree[2*$]+=ke:$!==0?($!==ye&&j.bl_tree[2*$]++,j.bl_tree[2*z]++):ke<=10?j.bl_tree[2*P]++:j.bl_tree[2*N]++,ye=$,ee=(ke=0)===Re?(te=138,3):$===Re?(te=6,3):(te=7,4))}function ge(j,H,J){var pe,$,ye=-1,Re=H[1],ke=0,te=7,ee=4;for(Re===0&&(te=138,ee=3),pe=0;pe<=J;pe++)if($=Re,Re=H[2*(pe+1)+1],!(++ke<te&&$===Re)){if(ke<ee)for(;be(j,$,j.bl_tree),--ke!=0;);else $!==0?($!==ye&&(be(j,$,j.bl_tree),ke--),be(j,z,j.bl_tree),he(j,ke-3,2)):ke<=10?(be(j,P,j.bl_tree),he(j,ke-3,3)):(be(j,N,j.bl_tree),he(j,ke-11,7));ye=$,ee=(ke=0)===Re?(te=138,3):$===Re?(te=6,3):(te=7,4)}}p(ne);var de=!1;function Y(j,H,J,pe){he(j,(g<<1)+(pe?1:0),3),function($,ye,Re,ke){Fe($),U($,Re),U($,~Re),f.arraySet($.pending_buf,$.window,ye,Re,$.pending),$.pending+=Re}(j,H,J)}u._tr_init=function(j){de||(function(){var H,J,pe,$,ye,Re=new Array(w+1);for($=pe=0;$<A-1;$++)for(ue[$]=pe,H=0;H<1<<Z[$];H++)I[pe++]=$;for(I[pe-1]=$,$=ye=0;$<16;$++)for(ne[$]=ye,H=0;H<1<<ie[$];H++)q[ye++]=$;for(ye>>=7;$<E;$++)for(ne[$]=ye<<7,H=0;H<1<<ie[$]-7;H++)q[256+ye++]=$;for(J=0;J<=w;J++)Re[J]=0;for(H=0;H<=143;)re[2*H+1]=8,H++,Re[8]++;for(;H<=255;)re[2*H+1]=9,H++,Re[9]++;for(;H<=279;)re[2*H+1]=7,H++,Re[7]++;for(;H<=287;)re[2*H+1]=8,H++,Re[8]++;for(Ke(re,y+1,Re),H=0;H<E;H++)Q[2*H+1]=5,Q[2*H]=Be(H,5);fe=new T(re,Z,m+1,y,w),ce=new T(Q,ie,0,E,w),le=new T(new Array(0),F,0,C,D)}(),de=!0),j.l_desc=new _(j.dyn_ltree,fe),j.d_desc=new _(j.dyn_dtree,ce),j.bl_desc=new _(j.bl_tree,le),j.bi_buf=0,j.bi_valid=0,Ue(j)},u._tr_stored_block=Y,u._tr_flush_block=function(j,H,J,pe){var $,ye,Re=0;0<j.level?(j.strm.data_type===2&&(j.strm.data_type=function(ke){var te,ee=4093624447;for(te=0;te<=31;te++,ee>>>=1)if(1&ee&&ke.dyn_ltree[2*te]!==0)return c;if(ke.dyn_ltree[18]!==0||ke.dyn_ltree[20]!==0||ke.dyn_ltree[26]!==0)return d;for(te=32;te<m;te++)if(ke.dyn_ltree[2*te]!==0)return d;return c}(j)),Mt(j,j.l_desc),Mt(j,j.d_desc),Re=function(ke){var te;for(S(ke,ke.dyn_ltree,ke.l_desc.max_code),S(ke,ke.dyn_dtree,ke.d_desc.max_code),Mt(ke,ke.bl_desc),te=C-1;3<=te&&ke.bl_tree[2*K[te]+1]===0;te--);return ke.opt_len+=3*(te+1)+5+5+4,te}(j),$=j.opt_len+3+7>>>3,(ye=j.static_len+3+7>>>3)<=$&&($=ye)):$=ye=J+5,J+4<=$&&H!==-1?Y(j,H,J,pe):j.strategy===4||ye===$?(he(j,2+(pe?1:0),3),Ct(j,re,Q)):(he(j,4+(pe?1:0),3),function(ke,te,ee,we){var Oe;for(he(ke,te-257,5),he(ke,ee-1,5),he(ke,we-4,4),Oe=0;Oe<we;Oe++)he(ke,ke.bl_tree[2*K[Oe]+1],3);ge(ke,ke.dyn_ltree,te-1),ge(ke,ke.dyn_dtree,ee-1)}(j,j.l_desc.max_code+1,j.d_desc.max_code+1,Re+1),Ct(j,j.dyn_ltree,j.dyn_dtree)),Ue(j),pe&&Fe(j)},u._tr_tally=function(j,H,J){return j.pending_buf[j.d_buf+2*j.last_lit]=H>>>8&255,j.pending_buf[j.d_buf+2*j.last_lit+1]=255&H,j.pending_buf[j.l_buf+j.last_lit]=255&J,j.last_lit++,H===0?j.dyn_ltree[2*J]++:(j.matches++,H--,j.dyn_ltree[2*(I[J]+m+1)]++,j.dyn_dtree[2*V(H)]++),j.last_lit===j.lit_bufsize-1},u._tr_align=function(j){he(j,2,3),be(j,B,re),function(H){H.bi_valid===16?(U(H,H.bi_buf),H.bi_buf=0,H.bi_valid=0):8<=H.bi_valid&&(H.pending_buf[H.pending++]=255&H.bi_buf,H.bi_buf>>=8,H.bi_valid-=8)}(j)}},{"../utils/common":41}],53:[function(i,l,u){l.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(i,l,u){(function(f){(function(c,d){if(!c.setImmediate){var p,g,A,m,y=1,E={},C=!1,x=c.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(c);w=w&&w.setTimeout?w:c,p={}.toString.call(c.process)==="[object process]"?function(z){process.nextTick(function(){D(z)})}:function(){if(c.postMessage&&!c.importScripts){var z=!0,P=c.onmessage;return c.onmessage=function(){z=!1},c.postMessage("","*"),c.onmessage=P,z}}()?(m="setImmediate$"+Math.random()+"$",c.addEventListener?c.addEventListener("message",B,!1):c.attachEvent("onmessage",B),function(z){c.postMessage(m+z,"*")}):c.MessageChannel?((A=new MessageChannel).port1.onmessage=function(z){D(z.data)},function(z){A.port2.postMessage(z)}):x&&"onreadystatechange"in x.createElement("script")?(g=x.documentElement,function(z){var P=x.createElement("script");P.onreadystatechange=function(){D(z),P.onreadystatechange=null,g.removeChild(P),P=null},g.appendChild(P)}):function(z){setTimeout(D,0,z)},w.setImmediate=function(z){typeof z!="function"&&(z=new Function(""+z));for(var P=new Array(arguments.length-1),N=0;N<P.length;N++)P[N]=arguments[N+1];var Z={callback:z,args:P};return E[y]=Z,p(y),y++},w.clearImmediate=v}function v(z){delete E[z]}function D(z){if(C)setTimeout(D,0,z);else{var P=E[z];if(P){C=!0;try{(function(N){var Z=N.callback,ie=N.args;switch(ie.length){case 0:Z();break;case 1:Z(ie[0]);break;case 2:Z(ie[0],ie[1]);break;case 3:Z(ie[0],ie[1],ie[2]);break;default:Z.apply(d,ie)}})(P)}finally{v(z),C=!1}}}}function B(z){z.source===c&&typeof z.data=="string"&&z.data.indexOf(m)===0&&D(+z.data.slice(m.length))}})(typeof self=="undefined"?f===void 0?this:f:self)}).call(this,typeof $t!="undefined"?$t:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}]},{},[10])(10)})}(Cd)),Cd.exports}var nI=tI();const rI=Gn(nI),iI=n=>et(null,null,function*(){const a=new rI;return n.forEach(l=>{a.file(l.name,l)}),yield a.generateAsync({type:"blob"})}),aI=(n,a)=>new File([n],a,{type:n.type}),py=n=>n.length>1,oI=n=>{var a;return py(n)?`uploaded_files_${Date.now()}.zip`:((a=n[0])==null?void 0:a.name)||"file"},lI=`${Yr.WEBSOCKET_URL}/ws/med-assist/session`;class sI{constructor(a){Gt(this,"ws",null);Gt(this,"config");Gt(this,"connectionState",Xn.DISCONNECTED);Gt(this,"reconnectAttempts",0);Gt(this,"maxConnectionAttempts",5);Gt(this,"maxReconnectAttempts",2);Gt(this,"connectionAttempts",0);Gt(this,"reconnectDelay",1e3);Gt(this,"eventCallbacks",new Map);Gt(this,"isReconnecting",!1);Gt(this,"pingInterval",null);Gt(this,"connectionTimeout",null);Gt(this,"currentStreamMessage",null);Gt(this,"pendingFileData",{files:[],message:"",format:void 0});var i,l,u;this.config={sessionId:a.sessionId,auth:a.auth,options:oe({connectAttempts:5,reconnectAttempts:5,reconnectDelay:1e3,pingInterval:3e4,connectionTimeout:5e3},a.options)},this.maxReconnectAttempts=((i=this.config.options)==null?void 0:i.reconnectAttempts)||5,this.maxConnectionAttempts=((l=this.config.options)==null?void 0:l.connectAttempts)||5,this.reconnectDelay=((u=this.config.options)==null?void 0:u.reconnectDelay)||1e3}connect(){return et(this,null,function*(){var a;try{if(this.isReconnecting||this.connectionState===Xn.CONNECTING){console.log("Connection already in progress, skipping from connect function");return}if(this.isConnected()){console.log("WebSocket is already connected");return}if(this.connectionAttempts>=this.maxConnectionAttempts){console.log("connection attempts exceeded",this.connectionAttempts),this.updateConnectionState(Xn.ERROR),this.triggerEvent(yn.MAX_CONNECTION_ATTEMPTS_EXCEEDED,new Error("connection attempts exceeded"));return}this.updateConnectionState(Xn.CONNECTING),this.isReconnecting=!0,this.connectionAttempts==2&&(yield this.checkSessionDetails()),this.connectionAttempts++;const i=`${lI}/${this.config.sessionId}/`;if(console.log("Connecting to WebSocket:",i,"with session ID:",this.config.sessionId),this.ws=new WebSocket(i),this.setupWebSocketHandlers(),this.connectionTimeout=setTimeout(()=>{if(this.connectionState===Xn.CONNECTING){if(console.log("Connection timeout",this.reconnectAttempts,this.maxReconnectAttempts),this.isReconnecting=!1,this.updateConnectionState(Xn.ERROR),this.reconnectAttempts>=this.maxReconnectAttempts){this.triggerEvent(yn.MAX_RECONNECTION_ATTEMPTS_EXCEEDED,new Error("Connection timeout after two retries"));return}this.cleanup(),this.triggerEvent(yn.CONNECTION_TIMEOUT_ERROR,new Error("Connection timeout"))}},((a=this.config.options)==null?void 0:a.connectionTimeout)||5e3),!this.ws)throw new Error("WebSocket not initialized")}catch(i){throw console.error("Failed to connect:",i),this.isReconnecting=!1,this.updateConnectionState(Xn.ERROR),this.triggerEvent(yn.CONNECTION_ERROR,i instanceof Error?i:new Error("Connection failed")),i}})}checkSessionDetails(){return et(this,null,function*(){try{this.isReconnecting=!1;const a=yield uy(this.config.sessionId);if(console.log("sessionDetails response",a),a)this.isReconnecting=!0;else{this.isReconnecting=!1,this.updateConnectionState(Xn.ERROR),this.triggerEvent(tn.CONNECTION_ESTABLISHED,!1),this.triggerEvent(yn.SESSION_INACTIVE,new Error(Ut.SESSION_INACTIVE.title)),this.triggerEvent(yn.START_NEW_SESSION,new Error("Session is invalid, starting new session")),this.cleanup();return}}catch(a){console.error("Error checking session details:",a),this.isReconnecting=!0}})}setupWebSocketHandlers(){this.ws&&(this.ws.onopen=()=>{console.log("WebSocket opened"),this.sendAuthMessage(),this.isReconnecting=!1,this.connectionAttempts=0,this.updateConnectionState(Xn.CONNECTED),this.startPingInterval()},this.ws.onmessage=a=>et(this,null,function*(){try{const i=JSON.parse(a.data);yield this.handleServerMessage(i)}catch(i){console.error("Failed to parse WebSocket message:",i)}}),this.ws.onclose=a=>{console.log("WebSocket closed:",a.code,a),this.handleConnectionClose(a)},this.ws.onerror=a=>{console.error("WebSocket error:",a),this.isReconnecting=!1,this.updateConnectionState(Xn.ERROR),this.triggerEvent(tn.ERROR,new Error("WebSocket error occurred"))})}handleServerMessage(a){return et(this,null,function*(){switch(a.ev){case tn.CONNECTION_ESTABLISHED:this.handleConnectionEstablished(a);break;case tn.CHAT:this.handleChatMessage(a);break;case tn.STREAM:this.handleStreamMessage(a);break;case tn.END_OF_STREAM:this.handleEndOfStreamMessage(a);break;case tn.PONG:this.handlePongMessage(a);break;case tn.SYNC:this.handleSyncMessage(a);break;case tn.ERROR:yield this.handleErrorMessage(a);break;default:console.warn("Unknown event type:",a.ev)}})}handleConnectionEstablished(a){this.triggerEvent(tn.CONNECTION_ESTABLISHED,!0)}handleChatMessage(a){console.log("Chat message received:",a),this.triggerEvent(tn.CHAT,a)}handleStreamMessage(a){var i;if(a.ct===en.TEXT&&a.data){if(a.data.progress_msg){this.triggerEvent("progress_message",a.data.progress_msg);return}a.data.text&&(this.currentStreamMessage||(this.currentStreamMessage={id:a._id,content:"",timestamp:new Date,type:"text",metadata:{isStreaming:!0}}),this.currentStreamMessage.content+=a.data.text,this.triggerEvent("stream_chunk",{content:this.currentStreamMessage.content,messageId:a._id}))}else a.ct===en.TIPS?(console.log("Tips message received:",a.data),(i=a.data.tips)!=null&&i.length&&this.triggerEvent(yn.TIPS,a.data.tips)):this.triggerEvent(tn.STREAM,a)}handleEndOfStreamMessage(a){a.ct===en.TEXT&&this.currentStreamMessage?(this.currentStreamMessage.metadata=ze(oe({},this.currentStreamMessage.metadata),{isStreaming:!1}),this.triggerEvent(tn.END_OF_STREAM,this.currentStreamMessage),this.currentStreamMessage=null):this.triggerEvent(tn.END_OF_STREAM,a)}handlePongMessage(a){this.triggerEvent(tn.PONG,a)}handleSyncMessage(a){this.triggerEvent(tn.SYNC,a)}handleErrorMessage(a){return et(this,null,function*(){this.triggerEvent(tn.ERROR,a)})}handleConnectionClose(a){if(this.cleanup(),this.updateConnectionState(Xn.DISCONNECTED),this.triggerEvent(tn.CONNECTION_ESTABLISHED,!1),a.code===1008){this.triggerEvent(yn.SESSION_EXPIRED,new Error(Ut.SESSION_EXPIRED.title));return}a.code!==1e3&&!this.isReconnecting&&a.code==1008&&this.attemptReconnect()}attemptReconnect(){if(this.isReconnecting){console.log("Reconnection already in progress, skipping from attemptReconnect function");return}console.log(`Attempting to reconnect (${this.connectionAttempts+1}/${this.maxConnectionAttempts})`),setTimeout(()=>{this.connect().catch(a=>{console.error("Reconnection failed from attemptReconnect function:",a)})},this.reconnectDelay)}sendChatMessage({message:a,tool_use_id:i,hidden:l,tool_use_params:u}){if(!this.isConnected())throw new Error("WebSocket not connected");const f={ev:Ua.CHAT,ct:en.TEXT,ts:Date.now(),_id:Date.now().toString(),data:oe(oe(oe({text:a},i&&{tool_use_id:i}),l&&{hidden:l}),u&&{tool_use_params:u})};this.sendMessage(f)}sendFileUploadRequest(){if(!this.isConnected())throw new Error("WebSocket is not connected");const a={ev:Ua.CHAT,ct:en.FILE,ts:Date.now(),_id:Date.now().toString(),data:{extension:this.pendingFileData.format}};this.sendMessage(a)}sendAuthMessage(){if(!this.isConnected())throw new Error("WebSocket is not connected");const a={ev:Ua.AUTH,_id:Date.now().toString(),ts:Date.now(),data:{token:this.config.auth.token}};this.sendMessage(a)}sendFileUploadComplete(a){var u;if(!this.isConnected())throw new Error("WebSocket is not connected");const i=(u=this.pendingFileData)==null?void 0:u.message,l={ev:Ua.CHAT,ct:en.FILE,ts:Date.now(),_id:Date.now().toString(),data:oe({url:a},i&&i.trim()&&{text:i.trim()})};this.sendMessage(l),this.clearPendingFiles()}setFilesForUpload(a,i){var f,c,d;const l=["application/pdf","image/jpeg","image/png","image/jpg","image/tiff","text/plain","text/markdown","image/heif","image/heic","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],u=a.filter(p=>l.includes(p.type))||[];this.pendingFileData.files=u,this.pendingFileData.format=u.length>1?"zip":((d=(c=(f=u[0].type)==null?void 0:f.split)==null?void 0:c.call(f,"/"))==null?void 0:d[1])||void 0,i!=null&&i.trim()&&(this.pendingFileData.message=i),console.log(`Set ${u.length} files for upload`)}clearPendingFiles(){this.pendingFileData.files=[],this.pendingFileData.message="",this.pendingFileData.format=void 0}clearStreamingState(){this.currentStreamMessage=null,console.log("Cleared streaming state")}reconnect(a,i){return et(this,null,function*(){if(!a&&this.isReconnecting){console.log("Reconnection already in progress, skipping");return}if(a&&(this.isReconnecting=!1,this.connectionAttempts=0),this.reconnectAttempts===this.maxReconnectAttempts){this.updateConnectionState(Xn.ERROR),this.triggerEvent(yn.MAX_RECONNECTION_ATTEMPTS_EXCEEDED,new Error("Maximum reconnection attempts exceeded"));return}this.reconnectAttempts++,console.log(`Initiating reconnection${i?` due to: ${i}`:""}...`),this.updateConnectionState(Xn.RECONNECTING);try{this.disconnect(),yield this.connect()}catch(l){console.error("Reconnection failed:",l),this.handleReconnectionError(l)}finally{this.isReconnecting=!1}})}handleReconnectionError(a){this.reconnectAttempts++,this.isReconnecting=!1,console.error("Reconnection error:",a),this.triggerEvent(yn.CONNECTION_ERROR,a),this.reconnectAttempts===this.maxReconnectAttempts?(this.updateConnectionState(Xn.ERROR),this.triggerEvent(yn.MAX_RECONNECTION_ATTEMPTS_EXCEEDED,new Error("Maximum reconnection attempts exceeded"))):this.attemptReconnect()}regenerateResponse(a){if(!this.isConnected())throw new Error("WebSocket is not connected");console.log("Regenerating response for:",a),this.clearStreamingState();const i={ev:Ua.CHAT,ct:en.TEXT,ts:Date.now(),_id:Date.now().toString(),data:{text:a}};this.sendMessage(i)}uploadFilesToPresignedUrl(a){return et(this,null,function*(){var u,f,c,d,p,g;console.log("hi from uploadFilesToPresignedUrl");let i=0;const l=a.filter(A=>A&&A.trim());try{if(l.length===0)throw new Error("No valid presigned URLs provided");console.log(`Uploading ${(f=(u=this.pendingFileData)==null?void 0:u.files)==null?void 0:f.length} files to ${a.length} presigned URL(s)`);let A,m;if(py(this.pendingFileData.files)){console.log("Multiple files detected, zipping before upload...");const y=yield iI(this.pendingFileData.files),E=oI(this.pendingFileData.files);A=aI(y,E),m="application/zip",console.log(`Zipped ${(d=(c=this.pendingFileData)==null?void 0:c.files)==null?void 0:d.length} files into ${E} (${(A.size/1024/1024).toFixed(2)} MB)`)}else A=(g=(p=this.pendingFileData)==null?void 0:p.files)==null?void 0:g[0],m=A.type,console.log(`Uploading single file: ${A.name} (${(A.size/1024/1024).toFixed(2)} MB)`);for(let y=0;y<l.length;y++){const E=l[y];console.log(`Uploading to URL ${y+1}/${l.length}: ${E}`);const C=yield fetch(E,{method:"PUT",body:A,headers:{"Content-Type":m,"x-ms-blob-type":"BlockBlob"}});if(!C.ok)throw new Error(`Failed to upload ${A.name} to URL ${y+1}: ${C.status} ${C.statusText}`);i++,console.log(`Successfully uploaded to URL ${y+1}/${l.length}`,C)}console.log("All file uploads completed successfully, calling sendFileUploadComplete"),this.sendFileUploadComplete(l[0])}catch(A){if(i>0){this.sendFileUploadComplete(l[0]);return}throw console.error("Error uploading files to presigned URL:",A),A}})}sendAudioData(a){if(!this.isConnected())throw new Error("WebSocket not connected");const i={ev:Ua.STREAM,ct:en.AUDIO,ts:Date.now(),_id:Date.now().toString(),data:{audio:a.audio,format:a.format}};console.log("Sending full audio data to backend:",i),this.sendMessage(i)}sendPing(){if(this.isConnected()){const a={ev:Ua.PING,ts:Date.now(),_id:Date.now().toString()};this.sendMessage(a)}}on(a,i){this.eventCallbacks.has(a)||this.eventCallbacks.set(a,new Set),this.eventCallbacks.get(a).add(i)}off(a,i){var l;i?(l=this.eventCallbacks.get(a))==null||l.delete(i):this.eventCallbacks.delete(a)}triggerEvent(a,i){const l=this.eventCallbacks.get(a);l&&l.forEach(u=>{try{u(i)}catch(f){console.error("Error in event callback:",f)}})}startPingInterval(){var a;this.pingInterval&&clearInterval(this.pingInterval),this.pingInterval=setInterval(()=>{this.sendPing()},((a=this.config.options)==null?void 0:a.pingInterval)||3e4)}isConnected(){var a;return((a=this.ws)==null?void 0:a.readyState)===WebSocket.OPEN}getConnectionState(){return this.connectionState}updateConfig(a){var i;a!=null&&a.sessionId&&(this.config.sessionId=a.sessionId),(i=a==null?void 0:a.auth)!=null&&i.token&&(this.config.auth.token=a.auth.token),console.log("WebSocket config updated:",this.config)}updateConnectionState(a){this.connectionState=a,console.log("Connection state updated:",a)}disconnect(){console.log("WebSocket disconnect called"),this.ws&&(this.ws.close(1e3,"Manual disconnect"),this.cleanup())}sendMessage(a){var i;if(((i=this.ws)==null?void 0:i.readyState)===WebSocket.OPEN)this.ws.send(JSON.stringify(a));else throw new Error("WebSocket is not open")}getConfig(){return this.config}cleanup(){this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=null),this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=null),this.clearPendingFiles(),this.clearStreamingState(),this.ws&&(this.ws.onopen=null,this.ws.onmessage=null,this.ws.onclose=null,this.ws.onerror=null,this.ws=null)}}function uI(n,a,i,l,u,f){var le;const c=G.useRef(null),d=G.useRef(0),p=G.useRef(null),g=_t(ne=>ne.setError),A=_t(ne=>ne.setShowRetryButton),m=_t(ne=>ne.setStartNewConnection),y=_t(ne=>ne.refreshSession),E=_t(ne=>ne.setSessionId),C=_t(ne=>ne.setSessionToken),x=G.useRef(!1),{setIsStreaming:w,isStreaming:v,connectionStatus:D,setConnectionStatus:B,clearResponseTimeout:z,clearStreamingTimeout:P,setLastStreamingActivity:N}=_t();G.useEffect(()=>{var T,_,V,U,he,be,Be,Ke,Ue,Fe,We,rt,Ct,Mt,S,ge,de,Y,j;if(!n||!n.sessionId||!((T=n.auth)!=null&&T.token)){console.log("No config provided",n),B(kt.CONNECTING);return}if((_=c.current)!=null&&_.isConnected()){console.log("WebSocket already connected, skipping connection");return}const ne=new sI(n);return console.log("WebSocket service created:",ne),c.current=ne,(V=c.current)==null||V.on(tn.CONNECTION_ESTABLISHED,H=>{console.log("WebSocket connection:",H),B(kt.CONNECTED),H?(A(!1),m(!1),g(null),d.current=0):(A(!0),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED))}),(U=c.current)==null||U.on(tn.PONG,H=>{}),c.current.on(tn.SYNC,H=>{}),(he=c.current)==null||he.on(tn.CHAT,H=>{if(H.ct===en.FILE&&H.data&&"urls"in H.data){const J=H.data.urls||[];J.length>0&&ne.uploadFilesToPresignedUrl(J).then(()=>{}).catch(pe=>{console.error("Failed to upload files:",pe),g(Ut.FILE_UPLOAD_FAILED)})}else if((H.ct===en.PILL||H.ct===en.MULTI||H.ct===en.DOCTOR_CARD||H.ct===en.MOBILE_VERIFICATION||H.ct===en.LAB_PACKAGE_CARD)&&H.data&&H.data.tool_use_id){if(u){const J={type:H.ct,tool_use_id:H.data.tool_use_id,data:{choices:H.data.choices,doctor_details:H.data.doctor_details,lab_packages:H.data.lab_packages,callbacks:H.data.callbacks,additional_option:H.data.additional_option,url:H.data.url,mobile_number:H.data.mobile_number}};u(J,H._id)}}else H.ct===en.TEXT&&H.data&&H.data.text&&H._id?(_t.getState().isStreaming||(w(!0),z(),g(null)),N(Date.now()),a&&a(H.data.text,H._id),setTimeout(()=>{_t.getState().isStreaming&&w(!1)},0)):H.ct===en.INLINE_TEXT&&H.data&&H.data.text&&(_t.getState().isStreaming||(w(!0),z()),N(Date.now()),f&&f(H.data.text),setTimeout(()=>{_t.getState().isStreaming&&w(!1)},0))}),(be=c.current)==null||be.on(tn.STREAM,H=>{_t.getState().isStreaming||(w(!0),z(),g(null)),N(Date.now()),H.ct===en.TEXT&&H.data&&H.data.text&&(H!=null&&H._id)&&a&&a(H.data.text,H._id)}),(Be=c.current)==null||Be.on("stream_chunk",({content:H,messageId:J})=>{v||(w(!0),z(),g(null)),N(Date.now()),a&&a(H,J)}),(Ke=c.current)==null||Ke.on(tn.END_OF_STREAM,H=>{w(!1),P(),p.current=null,i&&i("")}),(Ue=c.current)==null||Ue.on(tn.ERROR,H=>{switch(console.error("WebSocket error:",H),H.code){case vi.SESSION_INACTIVE:{A(!1),m(!0),g(Ut.SESSION_INACTIVE);break}case vi.SESSION_EXPIRED:{console.log("Session expired from useWebSocket"),I(),g(Ut.SESSION_EXPIRED);break}case vi.INVALID_EVENT:{g(Ut.INVALID_EVENT);break}case vi.INVALID_CONTENT_TYPE:{g(Ut.INVALID_CONTENT_TYPE);break}case vi.PARSING_ERROR:{d.current<2?(console.log("Retrying..."),d.current++,A(!0),g(Ut.PARSING_ERROR)):(A(!1),m(!0),d.current=0,g(Ut.ERROR_PROCESSING_MESSAGE));break}case vi.SERVER_ERROR:{A(!0),g(Ut.SERVER_ERROR);break}case vi.TIMEOUT:{g(Ut.TIMEOUT),A(!0);break}case vi.SESSION_TOKEN_MISMATCH:{g(Ut.SESSION_TOKEN_MISMATCH),A(!1),m(!0);break}default:{g({title:H.msg}),A(!0);break}}}),(Fe=c.current)==null||Fe.on(yn.SESSION_INACTIVE,H=>{console.error("Session inactive:",H),A(!1),m(!0),g(Ut.SESSION_INACTIVE)}),(We=c.current)==null||We.on("progress_message",H=>{N(Date.now()),_t.getState().isStreaming||(z(),g(null)),i&&(i(H),g(null))}),(rt=c.current)==null||rt.on(yn.TIPS,H=>{N(Date.now()),l&&l(H)}),(Ct=c.current)==null||Ct.on("message",H=>{var J;((J=H.metadata)==null?void 0:J.isStreaming)===!1&&(w(!1),P(),g(null))}),(Mt=c.current)==null||Mt.on(yn.MAX_CONNECTION_ATTEMPTS_EXCEEDED,H=>{console.log("MAX_CONNECTION_ATTEMPTS_EXCEEDED received:",H),A(!0),g(Ut.CONNECTION_ATTEMPTS_EXCEEDED)}),(S=c.current)==null||S.on(yn.MAX_RECONNECTION_ATTEMPTS_EXCEEDED,H=>{console.log("MAX_RECONNECTION_ATTEMPTS_EXCEEDED received:",H),A(!1),m(!0)}),(ge=c.current)==null||ge.on(yn.CONNECTION_TIMEOUT_ERROR,H=>{console.log("CONNECTION_TIMEOUT_ERROR received:",H),A(!0),g(Ut.CONNECTION_LOST)}),(de=c.current)==null||de.on(yn.SESSION_REFRESHED,H=>{if(console.log("SESSION_REFRESHED received:",H),H){const J=_t.getState();J.sessionId&&J.sessionToken&&(E(J.sessionId),C(J.sessionToken),c.current&&c.current.updateConfig({sessionId:J.sessionId,auth:{token:J.sessionToken}}),console.log("Session store updated after refresh"))}}),(Y=c.current)==null||Y.on(yn.START_NEW_SESSION,H=>{A(!1),m(!0),g(Ut.SESSION_INACTIVE)}),(j=c.current)==null||j.on(yn.SESSION_EXPIRED,H=>{A(!1),I(),g(Ut.SESSION_EXPIRED)}),ne.connect().catch(H=>{console.error("Failed to connect to WebSocket:",H),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED)}),()=>{c.current&&(c.current.disconnect(),c.current=null),w(!1),P(),z(),g(null),N(null),p.current=null,A(!1),m(!1),B(kt.DISCONNECTED)}},[n==null?void 0:n.sessionId,(le=n==null?void 0:n.auth)==null?void 0:le.token,B]);const Z=({message:ne,tool_use_id:T,tool_use_params:_})=>{var V;if((V=c.current)!=null&&V.isConnected())try{p.current={content:ne,tool_use_id:T,type:"text"},c.current.sendChatMessage({message:ne,tool_use_id:T,tool_use_params:_})}catch(U){console.error("Failed to send text message:",U),g(U instanceof Error?{title:U.message}:{title:"Failed to send message"})}else console.error("WebSocket not connected"),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED),A(!0)},ie=({message:ne,tool_use_id:T,tool_use_params:_})=>{var V;if((V=c.current)!=null&&V.isConnected())try{c.current.sendChatMessage({message:ne,tool_use_id:T,hidden:!0,tool_use_params:_})}catch(U){console.error("Failed to send hidden text message:",U)}else console.error("WebSocket not connected"),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED),A(!0)},F=ne=>{var T;if((T=c.current)!=null&&T.isConnected())try{x.current||(x.current=!0),p.current={content:"🎤 Voice message sent",type:"audio",audioData:ne},c.current.sendAudioData(ne),x.current=!1}catch(_){console.error("Failed to send audio data:",_),g(_ instanceof Error?{title:_.message}:{title:"Failed to send audio"})}else console.error("WebSocket not connected"),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED),A(!0)},K=()=>{c.current&&D===kt.CONNECTED&&c.current.sendFileUploadRequest()},re=(ne,T)=>{p.current={content:T||`📎 ${ne.length>1?`${ne.length} files`:"File"} uploaded`,type:"file",files:ne,message:T},c.current&&c.current.setFilesForUpload(ne,T)},Q=ne=>{c.current&&D===kt.CONNECTED&&(w(!1),c.current.regenerateResponse(ne))},q=()=>{g(null)},I=()=>et(null,null,function*(){try{c.current&&c.current.disconnect();const ne=yield y();return ne?console.log("Manual session refresh successful"):(A(!1),m(!0),g(Ut.SESSION_EXPIRED),console.log("Manual session refresh failed")),ne}catch(ne){return console.error("Error during manual session refresh:",ne),!1}}),ue=()=>et(null,null,function*(){var T;if(!((T=c.current)!=null&&T.isConnected()))return console.error("WebSocket not connected, cannot retry message"),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED),A(!0),!1;if(!p.current)return console.error("No last message to retry"),!1;const ne=p.current;try{switch(ne.type){case"text":yield Z({message:ne.content,tool_use_id:ne.tool_use_id,tool_use_params:ne.tool_use_params});break;case"audio":ne.audioData&&(yield F(ne.audioData));break;case"file":ne.files&&(yield re(ne.files,ne.message),yield K());break;default:return console.error("Unknown message type for retry:",ne.type),!1}return!0}catch(_){return console.error("Failed to retry last message:",_),g({title:"Failed to retry message. Please try again."}),!1}}),fe=()=>{var ne;return((ne=c.current)==null?void 0:ne.isConnected())||!1},ce=()=>{var ne;return((ne=c.current)==null?void 0:ne.getConnectionState())||null};return{isAudioStreaming:x.current,isConnected:fe(),connectionState:ce(),sendChatMessage:Z,sendAudioData:F,sendFileUploadRequest:K,setFilesForUpload:re,clearError:q,regenerateResponse:Q,triggerSessionRefresh:I,retryLastMessage:ue,sendHiddenChatMessage:ie,webSocketService:c.current}}/**
|
|
349
|
+
\0`,he+=f(_,2),he+=N.magic,he+=f(B,2),he+=f(z,2),he+=f(T.crc32,4),he+=f(T.compressedSize,4),he+=f(T.uncompressedSize,4),he+=f(ie.length,2),he+=f(ue.length,2),{fileRecord:m.LOCAL_FILE_HEADER+he+ie+ue,dirRecord:m.CENTRAL_FILE_HEADER+f(U,2)+he+f(re.length,2)+"\0\0\0\0"+f(V,4)+f(w,4)+ie+ue+re}}var d=i("../utils"),p=i("../stream/GenericWorker"),g=i("../utf8"),A=i("../crc32"),m=i("../signature");function y(E,C,x,w){p.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=C,this.zipPlatform=x,this.encodeFileName=w,this.streamFiles=E,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}d.inherits(y,p),y.prototype.push=function(E){var C=E.meta.percent||0,x=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(E):(this.bytesWritten+=E.data.length,p.prototype.push.call(this,{data:E.data,meta:{currentFile:this.currentFile,percent:x?(C+100*(x-w-1))/x:100}}))},y.prototype.openedSource=function(E){this.currentSourceOffset=this.bytesWritten,this.currentFile=E.file.name;var C=this.streamFiles&&!E.file.dir;if(C){var x=c(E,C,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:x.fileRecord,meta:{percent:0}})}else this.accumulate=!0},y.prototype.closedSource=function(E){this.accumulate=!1;var C=this.streamFiles&&!E.file.dir,x=c(E,C,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(x.dirRecord),C)this.push({data:function(w){return m.DATA_DESCRIPTOR+f(w.crc32,4)+f(w.compressedSize,4)+f(w.uncompressedSize,4)}(E),meta:{percent:100}});else for(this.push({data:x.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},y.prototype.flush=function(){for(var E=this.bytesWritten,C=0;C<this.dirRecords.length;C++)this.push({data:this.dirRecords[C],meta:{percent:100}});var x=this.bytesWritten-E,w=function(v,D,B,z,P){var N=d.transformTo("string",P(z));return m.CENTRAL_DIRECTORY_END+"\0\0\0\0"+f(v,2)+f(v,2)+f(D,4)+f(B,4)+f(N.length,2)+N}(this.dirRecords.length,x,E,this.zipComment,this.encodeFileName);this.push({data:w,meta:{percent:100}})},y.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},y.prototype.registerPrevious=function(E){this._sources.push(E);var C=this;return E.on("data",function(x){C.processChunk(x)}),E.on("end",function(){C.closedSource(C.previous.streamInfo),C._sources.length?C.prepareNextSource():C.end()}),E.on("error",function(x){C.error(x)}),this},y.prototype.resume=function(){return!!p.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},y.prototype.error=function(E){var C=this._sources;if(!p.prototype.error.call(this,E))return!1;for(var x=0;x<C.length;x++)try{C[x].error(E)}catch(w){}return!0},y.prototype.lock=function(){p.prototype.lock.call(this);for(var E=this._sources,C=0;C<E.length;C++)E[C].lock()},l.exports=y},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(i,l,u){var f=i("../compressions"),c=i("./ZipFileWorker");u.generateWorker=function(d,p,g){var A=new c(p.streamFiles,g,p.platform,p.encodeFileName),m=0;try{d.forEach(function(y,E){m++;var C=function(D,B){var z=D||B,P=f[z];if(!P)throw new Error(z+" is not a valid compression method !");return P}(E.options.compression,p.compression),x=E.options.compressionOptions||p.compressionOptions||{},w=E.dir,v=E.date;E._compressWorker(C,x).withStreamInfo("file",{name:y,dir:w,date:v,comment:E.comment||"",unixPermissions:E.unixPermissions,dosPermissions:E.dosPermissions}).pipe(A)}),A.entriesCount=m}catch(y){A.error(y)}return A}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(i,l,u){function f(){if(!(this instanceof f))return new f;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var c=new f;for(var d in this)typeof this[d]!="function"&&(c[d]=this[d]);return c}}(f.prototype=i("./object")).loadAsync=i("./load"),f.support=i("./support"),f.defaults=i("./defaults"),f.version="3.10.1",f.loadAsync=function(c,d){return new f().loadAsync(c,d)},f.external=i("./external"),l.exports=f},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(i,l,u){var f=i("./utils"),c=i("./external"),d=i("./utf8"),p=i("./zipEntries"),g=i("./stream/Crc32Probe"),A=i("./nodejsUtils");function m(y){return new c.Promise(function(E,C){var x=y.decompressed.getContentWorker().pipe(new g);x.on("error",function(w){C(w)}).on("end",function(){x.streamInfo.crc32!==y.decompressed.crc32?C(new Error("Corrupted zip : CRC32 mismatch")):E()}).resume()})}l.exports=function(y,E){var C=this;return E=f.extend(E||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:d.utf8decode}),A.isNode&&A.isStream(y)?c.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):f.prepareContent("the loaded zip file",y,!0,E.optimizedBinaryString,E.base64).then(function(x){var w=new p(E);return w.load(x),w}).then(function(x){var w=[c.Promise.resolve(x)],v=x.files;if(E.checkCRC32)for(var D=0;D<v.length;D++)w.push(m(v[D]));return c.Promise.all(w)}).then(function(x){for(var w=x.shift(),v=w.files,D=0;D<v.length;D++){var B=v[D],z=B.fileNameStr,P=f.resolve(B.fileNameStr);C.file(P,B.decompressed,{binary:!0,optimizedBinaryString:!0,date:B.date,dir:B.dir,comment:B.fileCommentStr.length?B.fileCommentStr:null,unixPermissions:B.unixPermissions,dosPermissions:B.dosPermissions,createFolders:E.createFolders}),B.dir||(C.file(P).unsafeOriginalName=z)}return w.zipComment.length&&(C.comment=w.zipComment),C})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(i,l,u){var f=i("../utils"),c=i("../stream/GenericWorker");function d(p,g){c.call(this,"Nodejs stream input adapter for "+p),this._upstreamEnded=!1,this._bindStream(g)}f.inherits(d,c),d.prototype._bindStream=function(p){var g=this;(this._stream=p).pause(),p.on("data",function(A){g.push({data:A,meta:{percent:0}})}).on("error",function(A){g.isPaused?this.generatedError=A:g.error(A)}).on("end",function(){g.isPaused?g._upstreamEnded=!0:g.end()})},d.prototype.pause=function(){return!!c.prototype.pause.call(this)&&(this._stream.pause(),!0)},d.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},l.exports=d},{"../stream/GenericWorker":28,"../utils":32}],13:[function(i,l,u){var f=i("readable-stream").Readable;function c(d,p,g){f.call(this,p),this._helper=d;var A=this;d.on("data",function(m,y){A.push(m)||A._helper.pause(),g&&g(y)}).on("error",function(m){A.emit("error",m)}).on("end",function(){A.push(null)})}i("../utils").inherits(c,f),c.prototype._read=function(){this._helper.resume()},l.exports=c},{"../utils":32,"readable-stream":16}],14:[function(i,l,u){l.exports={isNode:typeof Buffer!="undefined",newBufferFrom:function(f,c){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(f,c);if(typeof f=="number")throw new Error('The "data" argument must not be a number');return new Buffer(f,c)},allocBuffer:function(f){if(Buffer.alloc)return Buffer.alloc(f);var c=new Buffer(f);return c.fill(0),c},isBuffer:function(f){return Buffer.isBuffer(f)},isStream:function(f){return f&&typeof f.on=="function"&&typeof f.pause=="function"&&typeof f.resume=="function"}}},{}],15:[function(i,l,u){function f(P,N,Z){var ie,F=d.getTypeOf(N),K=d.extend(Z||{},A);K.date=K.date||new Date,K.compression!==null&&(K.compression=K.compression.toUpperCase()),typeof K.unixPermissions=="string"&&(K.unixPermissions=parseInt(K.unixPermissions,8)),K.unixPermissions&&16384&K.unixPermissions&&(K.dir=!0),K.dosPermissions&&16&K.dosPermissions&&(K.dir=!0),K.dir&&(P=v(P)),K.createFolders&&(ie=w(P))&&D.call(this,ie,!0);var re=F==="string"&&K.binary===!1&&K.base64===!1;Z&&Z.binary!==void 0||(K.binary=!re),(N instanceof m&&N.uncompressedSize===0||K.dir||!N||N.length===0)&&(K.base64=!1,K.binary=!0,N="",K.compression="STORE",F="string");var Q=null;Q=N instanceof m||N instanceof p?N:C.isNode&&C.isStream(N)?new x(P,N):d.prepareContent(P,N,K.binary,K.optimizedBinaryString,K.base64);var q=new y(P,Q,K);this.files[P]=q}var c=i("./utf8"),d=i("./utils"),p=i("./stream/GenericWorker"),g=i("./stream/StreamHelper"),A=i("./defaults"),m=i("./compressedObject"),y=i("./zipObject"),E=i("./generate"),C=i("./nodejsUtils"),x=i("./nodejs/NodejsStreamInputAdapter"),w=function(P){P.slice(-1)==="/"&&(P=P.substring(0,P.length-1));var N=P.lastIndexOf("/");return 0<N?P.substring(0,N):""},v=function(P){return P.slice(-1)!=="/"&&(P+="/"),P},D=function(P,N){return N=N!==void 0?N:A.createFolders,P=v(P),this.files[P]||f.call(this,P,null,{dir:!0,createFolders:N}),this.files[P]};function B(P){return Object.prototype.toString.call(P)==="[object RegExp]"}var z={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(P){var N,Z,ie;for(N in this.files)ie=this.files[N],(Z=N.slice(this.root.length,N.length))&&N.slice(0,this.root.length)===this.root&&P(Z,ie)},filter:function(P){var N=[];return this.forEach(function(Z,ie){P(Z,ie)&&N.push(ie)}),N},file:function(P,N,Z){if(arguments.length!==1)return P=this.root+P,f.call(this,P,N,Z),this;if(B(P)){var ie=P;return this.filter(function(K,re){return!re.dir&&ie.test(K)})}var F=this.files[this.root+P];return F&&!F.dir?F:null},folder:function(P){if(!P)return this;if(B(P))return this.filter(function(F,K){return K.dir&&P.test(F)});var N=this.root+P,Z=D.call(this,N),ie=this.clone();return ie.root=Z.name,ie},remove:function(P){P=this.root+P;var N=this.files[P];if(N||(P.slice(-1)!=="/"&&(P+="/"),N=this.files[P]),N&&!N.dir)delete this.files[P];else for(var Z=this.filter(function(F,K){return K.name.slice(0,P.length)===P}),ie=0;ie<Z.length;ie++)delete this.files[Z[ie].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(P){var N,Z={};try{if((Z=d.extend(P||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:c.utf8encode})).type=Z.type.toLowerCase(),Z.compression=Z.compression.toUpperCase(),Z.type==="binarystring"&&(Z.type="string"),!Z.type)throw new Error("No output type specified.");d.checkSupport(Z.type),Z.platform!=="darwin"&&Z.platform!=="freebsd"&&Z.platform!=="linux"&&Z.platform!=="sunos"||(Z.platform="UNIX"),Z.platform==="win32"&&(Z.platform="DOS");var ie=Z.comment||this.comment||"";N=E.generateWorker(this,Z,ie)}catch(F){(N=new p("error")).error(F)}return new g(N,Z.type||"string",Z.mimeType)},generateAsync:function(P,N){return this.generateInternalStream(P).accumulate(N)},generateNodeStream:function(P,N){return(P=P||{}).type||(P.type="nodebuffer"),this.generateInternalStream(P).toNodejsStream(N)}};l.exports=z},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(i,l,u){l.exports=i("stream")},{stream:void 0}],17:[function(i,l,u){var f=i("./DataReader");function c(d){f.call(this,d);for(var p=0;p<this.data.length;p++)d[p]=255&d[p]}i("../utils").inherits(c,f),c.prototype.byteAt=function(d){return this.data[this.zero+d]},c.prototype.lastIndexOfSignature=function(d){for(var p=d.charCodeAt(0),g=d.charCodeAt(1),A=d.charCodeAt(2),m=d.charCodeAt(3),y=this.length-4;0<=y;--y)if(this.data[y]===p&&this.data[y+1]===g&&this.data[y+2]===A&&this.data[y+3]===m)return y-this.zero;return-1},c.prototype.readAndCheckSignature=function(d){var p=d.charCodeAt(0),g=d.charCodeAt(1),A=d.charCodeAt(2),m=d.charCodeAt(3),y=this.readData(4);return p===y[0]&&g===y[1]&&A===y[2]&&m===y[3]},c.prototype.readData=function(d){if(this.checkOffset(d),d===0)return[];var p=this.data.slice(this.zero+this.index,this.zero+this.index+d);return this.index+=d,p},l.exports=c},{"../utils":32,"./DataReader":18}],18:[function(i,l,u){var f=i("../utils");function c(d){this.data=d,this.length=d.length,this.index=0,this.zero=0}c.prototype={checkOffset:function(d){this.checkIndex(this.index+d)},checkIndex:function(d){if(this.length<this.zero+d||d<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+d+"). Corrupted zip ?")},setIndex:function(d){this.checkIndex(d),this.index=d},skip:function(d){this.setIndex(this.index+d)},byteAt:function(){},readInt:function(d){var p,g=0;for(this.checkOffset(d),p=this.index+d-1;p>=this.index;p--)g=(g<<8)+this.byteAt(p);return this.index+=d,g},readString:function(d){return f.transformTo("string",this.readData(d))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var d=this.readInt(4);return new Date(Date.UTC(1980+(d>>25&127),(d>>21&15)-1,d>>16&31,d>>11&31,d>>5&63,(31&d)<<1))}},l.exports=c},{"../utils":32}],19:[function(i,l,u){var f=i("./Uint8ArrayReader");function c(d){f.call(this,d)}i("../utils").inherits(c,f),c.prototype.readData=function(d){this.checkOffset(d);var p=this.data.slice(this.zero+this.index,this.zero+this.index+d);return this.index+=d,p},l.exports=c},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(i,l,u){var f=i("./DataReader");function c(d){f.call(this,d)}i("../utils").inherits(c,f),c.prototype.byteAt=function(d){return this.data.charCodeAt(this.zero+d)},c.prototype.lastIndexOfSignature=function(d){return this.data.lastIndexOf(d)-this.zero},c.prototype.readAndCheckSignature=function(d){return d===this.readData(4)},c.prototype.readData=function(d){this.checkOffset(d);var p=this.data.slice(this.zero+this.index,this.zero+this.index+d);return this.index+=d,p},l.exports=c},{"../utils":32,"./DataReader":18}],21:[function(i,l,u){var f=i("./ArrayReader");function c(d){f.call(this,d)}i("../utils").inherits(c,f),c.prototype.readData=function(d){if(this.checkOffset(d),d===0)return new Uint8Array(0);var p=this.data.subarray(this.zero+this.index,this.zero+this.index+d);return this.index+=d,p},l.exports=c},{"../utils":32,"./ArrayReader":17}],22:[function(i,l,u){var f=i("../utils"),c=i("../support"),d=i("./ArrayReader"),p=i("./StringReader"),g=i("./NodeBufferReader"),A=i("./Uint8ArrayReader");l.exports=function(m){var y=f.getTypeOf(m);return f.checkSupport(y),y!=="string"||c.uint8array?y==="nodebuffer"?new g(m):c.uint8array?new A(f.transformTo("uint8array",m)):new d(f.transformTo("array",m)):new p(m)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(i,l,u){u.LOCAL_FILE_HEADER="PK",u.CENTRAL_FILE_HEADER="PK",u.CENTRAL_DIRECTORY_END="PK",u.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",u.ZIP64_CENTRAL_DIRECTORY_END="PK",u.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(i,l,u){var f=i("./GenericWorker"),c=i("../utils");function d(p){f.call(this,"ConvertWorker to "+p),this.destType=p}c.inherits(d,f),d.prototype.processChunk=function(p){this.push({data:c.transformTo(this.destType,p.data),meta:p.meta})},l.exports=d},{"../utils":32,"./GenericWorker":28}],25:[function(i,l,u){var f=i("./GenericWorker"),c=i("../crc32");function d(){f.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}i("../utils").inherits(d,f),d.prototype.processChunk=function(p){this.streamInfo.crc32=c(p.data,this.streamInfo.crc32||0),this.push(p)},l.exports=d},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(i,l,u){var f=i("../utils"),c=i("./GenericWorker");function d(p){c.call(this,"DataLengthProbe for "+p),this.propName=p,this.withStreamInfo(p,0)}f.inherits(d,c),d.prototype.processChunk=function(p){if(p){var g=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=g+p.data.length}c.prototype.processChunk.call(this,p)},l.exports=d},{"../utils":32,"./GenericWorker":28}],27:[function(i,l,u){var f=i("../utils"),c=i("./GenericWorker");function d(p){c.call(this,"DataWorker");var g=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,p.then(function(A){g.dataIsReady=!0,g.data=A,g.max=A&&A.length||0,g.type=f.getTypeOf(A),g.isPaused||g._tickAndRepeat()},function(A){g.error(A)})}f.inherits(d,c),d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this.data=null},d.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,f.delay(this._tickAndRepeat,[],this)),!0)},d.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(f.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},d.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var p=null,g=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":p=this.data.substring(this.index,g);break;case"uint8array":p=this.data.subarray(this.index,g);break;case"array":case"nodebuffer":p=this.data.slice(this.index,g)}return this.index=g,this.push({data:p,meta:{percent:this.max?this.index/this.max*100:0}})},l.exports=d},{"../utils":32,"./GenericWorker":28}],28:[function(i,l,u){function f(c){this.name=c||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}f.prototype={push:function(c){this.emit("data",c)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(c){this.emit("error",c)}return!0},error:function(c){return!this.isFinished&&(this.isPaused?this.generatedError=c:(this.isFinished=!0,this.emit("error",c),this.previous&&this.previous.error(c),this.cleanUp()),!0)},on:function(c,d){return this._listeners[c].push(d),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(c,d){if(this._listeners[c])for(var p=0;p<this._listeners[c].length;p++)this._listeners[c][p].call(this,d)},pipe:function(c){return c.registerPrevious(this)},registerPrevious:function(c){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=c.streamInfo,this.mergeStreamInfo(),this.previous=c;var d=this;return c.on("data",function(p){d.processChunk(p)}),c.on("end",function(){d.end()}),c.on("error",function(p){d.error(p)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var c=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),c=!0),this.previous&&this.previous.resume(),!c},flush:function(){},processChunk:function(c){this.push(c)},withStreamInfo:function(c,d){return this.extraStreamInfo[c]=d,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var c in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,c)&&(this.streamInfo[c]=this.extraStreamInfo[c])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var c="Worker "+this.name;return this.previous?this.previous+" -> "+c:c}},l.exports=f},{}],29:[function(i,l,u){var f=i("../utils"),c=i("./ConvertWorker"),d=i("./GenericWorker"),p=i("../base64"),g=i("../support"),A=i("../external"),m=null;if(g.nodestream)try{m=i("../nodejs/NodejsStreamOutputAdapter")}catch(C){}function y(C,x){return new A.Promise(function(w,v){var D=[],B=C._internalType,z=C._outputType,P=C._mimeType;C.on("data",function(N,Z){D.push(N),x&&x(Z)}).on("error",function(N){D=[],v(N)}).on("end",function(){try{var N=function(Z,ie,F){switch(Z){case"blob":return f.newBlob(f.transformTo("arraybuffer",ie),F);case"base64":return p.encode(ie);default:return f.transformTo(Z,ie)}}(z,function(Z,ie){var F,K=0,re=null,Q=0;for(F=0;F<ie.length;F++)Q+=ie[F].length;switch(Z){case"string":return ie.join("");case"array":return Array.prototype.concat.apply([],ie);case"uint8array":for(re=new Uint8Array(Q),F=0;F<ie.length;F++)re.set(ie[F],K),K+=ie[F].length;return re;case"nodebuffer":return Buffer.concat(ie);default:throw new Error("concat : unsupported type '"+Z+"'")}}(B,D),P);w(N)}catch(Z){v(Z)}D=[]}).resume()})}function E(C,x,w){var v=x;switch(x){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=x,this._mimeType=w,f.checkSupport(v),this._worker=C.pipe(new c(v)),C.lock()}catch(D){this._worker=new d("error"),this._worker.error(D)}}E.prototype={accumulate:function(C){return y(this,C)},on:function(C,x){var w=this;return C==="data"?this._worker.on(C,function(v){x.call(w,v.data,v.meta)}):this._worker.on(C,function(){f.delay(x,arguments,w)}),this},resume:function(){return f.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(C){if(f.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new m(this,{objectMode:this._outputType!=="nodebuffer"},C)}},l.exports=E},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(i,l,u){if(u.base64=!0,u.array=!0,u.string=!0,u.arraybuffer=typeof ArrayBuffer!="undefined"&&typeof Uint8Array!="undefined",u.nodebuffer=typeof Buffer!="undefined",u.uint8array=typeof Uint8Array!="undefined",typeof ArrayBuffer=="undefined")u.blob=!1;else{var f=new ArrayBuffer(0);try{u.blob=new Blob([f],{type:"application/zip"}).size===0}catch(d){try{var c=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);c.append(f),u.blob=c.getBlob("application/zip").size===0}catch(p){u.blob=!1}}}try{u.nodestream=!!i("readable-stream").Readable}catch(d){u.nodestream=!1}},{"readable-stream":16}],31:[function(i,l,u){for(var f=i("./utils"),c=i("./support"),d=i("./nodejsUtils"),p=i("./stream/GenericWorker"),g=new Array(256),A=0;A<256;A++)g[A]=252<=A?6:248<=A?5:240<=A?4:224<=A?3:192<=A?2:1;g[254]=g[254]=1;function m(){p.call(this,"utf-8 decode"),this.leftOver=null}function y(){p.call(this,"utf-8 encode")}u.utf8encode=function(E){return c.nodebuffer?d.newBufferFrom(E,"utf-8"):function(C){var x,w,v,D,B,z=C.length,P=0;for(D=0;D<z;D++)(64512&(w=C.charCodeAt(D)))==55296&&D+1<z&&(64512&(v=C.charCodeAt(D+1)))==56320&&(w=65536+(w-55296<<10)+(v-56320),D++),P+=w<128?1:w<2048?2:w<65536?3:4;for(x=c.uint8array?new Uint8Array(P):new Array(P),D=B=0;B<P;D++)(64512&(w=C.charCodeAt(D)))==55296&&D+1<z&&(64512&(v=C.charCodeAt(D+1)))==56320&&(w=65536+(w-55296<<10)+(v-56320),D++),w<128?x[B++]=w:(w<2048?x[B++]=192|w>>>6:(w<65536?x[B++]=224|w>>>12:(x[B++]=240|w>>>18,x[B++]=128|w>>>12&63),x[B++]=128|w>>>6&63),x[B++]=128|63&w);return x}(E)},u.utf8decode=function(E){return c.nodebuffer?f.transformTo("nodebuffer",E).toString("utf-8"):function(C){var x,w,v,D,B=C.length,z=new Array(2*B);for(x=w=0;x<B;)if((v=C[x++])<128)z[w++]=v;else if(4<(D=g[v]))z[w++]=65533,x+=D-1;else{for(v&=D===2?31:D===3?15:7;1<D&&x<B;)v=v<<6|63&C[x++],D--;1<D?z[w++]=65533:v<65536?z[w++]=v:(v-=65536,z[w++]=55296|v>>10&1023,z[w++]=56320|1023&v)}return z.length!==w&&(z.subarray?z=z.subarray(0,w):z.length=w),f.applyFromCharCode(z)}(E=f.transformTo(c.uint8array?"uint8array":"array",E))},f.inherits(m,p),m.prototype.processChunk=function(E){var C=f.transformTo(c.uint8array?"uint8array":"array",E.data);if(this.leftOver&&this.leftOver.length){if(c.uint8array){var x=C;(C=new Uint8Array(x.length+this.leftOver.length)).set(this.leftOver,0),C.set(x,this.leftOver.length)}else C=this.leftOver.concat(C);this.leftOver=null}var w=function(D,B){var z;for((B=B||D.length)>D.length&&(B=D.length),z=B-1;0<=z&&(192&D[z])==128;)z--;return z<0||z===0?B:z+g[D[z]]>B?z:B}(C),v=C;w!==C.length&&(c.uint8array?(v=C.subarray(0,w),this.leftOver=C.subarray(w,C.length)):(v=C.slice(0,w),this.leftOver=C.slice(w,C.length))),this.push({data:u.utf8decode(v),meta:E.meta})},m.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:u.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},u.Utf8DecodeWorker=m,f.inherits(y,p),y.prototype.processChunk=function(E){this.push({data:u.utf8encode(E.data),meta:E.meta})},u.Utf8EncodeWorker=y},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(i,l,u){var f=i("./support"),c=i("./base64"),d=i("./nodejsUtils"),p=i("./external");function g(x){return x}function A(x,w){for(var v=0;v<x.length;++v)w[v]=255&x.charCodeAt(v);return w}i("setimmediate"),u.newBlob=function(x,w){u.checkSupport("blob");try{return new Blob([x],{type:w})}catch(D){try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(x),v.getBlob(w)}catch(B){throw new Error("Bug : can't construct the Blob.")}}};var m={stringifyByChunk:function(x,w,v){var D=[],B=0,z=x.length;if(z<=v)return String.fromCharCode.apply(null,x);for(;B<z;)w==="array"||w==="nodebuffer"?D.push(String.fromCharCode.apply(null,x.slice(B,Math.min(B+v,z)))):D.push(String.fromCharCode.apply(null,x.subarray(B,Math.min(B+v,z)))),B+=v;return D.join("")},stringifyByChar:function(x){for(var w="",v=0;v<x.length;v++)w+=String.fromCharCode(x[v]);return w},applyCanBeUsed:{uint8array:function(){try{return f.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch(x){return!1}}(),nodebuffer:function(){try{return f.nodebuffer&&String.fromCharCode.apply(null,d.allocBuffer(1)).length===1}catch(x){return!1}}()}};function y(x){var w=65536,v=u.getTypeOf(x),D=!0;if(v==="uint8array"?D=m.applyCanBeUsed.uint8array:v==="nodebuffer"&&(D=m.applyCanBeUsed.nodebuffer),D)for(;1<w;)try{return m.stringifyByChunk(x,v,w)}catch(B){w=Math.floor(w/2)}return m.stringifyByChar(x)}function E(x,w){for(var v=0;v<x.length;v++)w[v]=x[v];return w}u.applyFromCharCode=y;var C={};C.string={string:g,array:function(x){return A(x,new Array(x.length))},arraybuffer:function(x){return C.string.uint8array(x).buffer},uint8array:function(x){return A(x,new Uint8Array(x.length))},nodebuffer:function(x){return A(x,d.allocBuffer(x.length))}},C.array={string:y,array:g,arraybuffer:function(x){return new Uint8Array(x).buffer},uint8array:function(x){return new Uint8Array(x)},nodebuffer:function(x){return d.newBufferFrom(x)}},C.arraybuffer={string:function(x){return y(new Uint8Array(x))},array:function(x){return E(new Uint8Array(x),new Array(x.byteLength))},arraybuffer:g,uint8array:function(x){return new Uint8Array(x)},nodebuffer:function(x){return d.newBufferFrom(new Uint8Array(x))}},C.uint8array={string:y,array:function(x){return E(x,new Array(x.length))},arraybuffer:function(x){return x.buffer},uint8array:g,nodebuffer:function(x){return d.newBufferFrom(x)}},C.nodebuffer={string:y,array:function(x){return E(x,new Array(x.length))},arraybuffer:function(x){return C.nodebuffer.uint8array(x).buffer},uint8array:function(x){return E(x,new Uint8Array(x.length))},nodebuffer:g},u.transformTo=function(x,w){if(w=w||"",!x)return w;u.checkSupport(x);var v=u.getTypeOf(w);return C[v][x](w)},u.resolve=function(x){for(var w=x.split("/"),v=[],D=0;D<w.length;D++){var B=w[D];B==="."||B===""&&D!==0&&D!==w.length-1||(B===".."?v.pop():v.push(B))}return v.join("/")},u.getTypeOf=function(x){return typeof x=="string"?"string":Object.prototype.toString.call(x)==="[object Array]"?"array":f.nodebuffer&&d.isBuffer(x)?"nodebuffer":f.uint8array&&x instanceof Uint8Array?"uint8array":f.arraybuffer&&x instanceof ArrayBuffer?"arraybuffer":void 0},u.checkSupport=function(x){if(!f[x.toLowerCase()])throw new Error(x+" is not supported by this platform")},u.MAX_VALUE_16BITS=65535,u.MAX_VALUE_32BITS=-1,u.pretty=function(x){var w,v,D="";for(v=0;v<(x||"").length;v++)D+="\\x"+((w=x.charCodeAt(v))<16?"0":"")+w.toString(16).toUpperCase();return D},u.delay=function(x,w,v){setImmediate(function(){x.apply(v||null,w||[])})},u.inherits=function(x,w){function v(){}v.prototype=w.prototype,x.prototype=new v},u.extend=function(){var x,w,v={};for(x=0;x<arguments.length;x++)for(w in arguments[x])Object.prototype.hasOwnProperty.call(arguments[x],w)&&v[w]===void 0&&(v[w]=arguments[x][w]);return v},u.prepareContent=function(x,w,v,D,B){return p.Promise.resolve(w).then(function(z){return f.blob&&(z instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(z))!==-1)&&typeof FileReader!="undefined"?new p.Promise(function(P,N){var Z=new FileReader;Z.onload=function(ie){P(ie.target.result)},Z.onerror=function(ie){N(ie.target.error)},Z.readAsArrayBuffer(z)}):z}).then(function(z){var P=u.getTypeOf(z);return P?(P==="arraybuffer"?z=u.transformTo("uint8array",z):P==="string"&&(B?z=c.decode(z):v&&D!==!0&&(z=function(N){return A(N,f.uint8array?new Uint8Array(N.length):new Array(N.length))}(z))),z):p.Promise.reject(new Error("Can't read the data of '"+x+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(i,l,u){var f=i("./reader/readerFor"),c=i("./utils"),d=i("./signature"),p=i("./zipEntry"),g=i("./support");function A(m){this.files=[],this.loadOptions=m}A.prototype={checkSignature:function(m){if(!this.reader.readAndCheckSignature(m)){this.reader.index-=4;var y=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+c.pretty(y)+", expected "+c.pretty(m)+")")}},isSignature:function(m,y){var E=this.reader.index;this.reader.setIndex(m);var C=this.reader.readString(4)===y;return this.reader.setIndex(E),C},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var m=this.reader.readData(this.zipCommentLength),y=g.uint8array?"uint8array":"array",E=c.transformTo(y,m);this.zipComment=this.loadOptions.decodeFileName(E)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var m,y,E,C=this.zip64EndOfCentralSize-44;0<C;)m=this.reader.readInt(2),y=this.reader.readInt(4),E=this.reader.readData(y),this.zip64ExtensibleData[m]={id:m,length:y,value:E}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var m,y;for(m=0;m<this.files.length;m++)y=this.files[m],this.reader.setIndex(y.localHeaderOffset),this.checkSignature(d.LOCAL_FILE_HEADER),y.readLocalPart(this.reader),y.handleUTF8(),y.processAttributes()},readCentralDir:function(){var m;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(d.CENTRAL_FILE_HEADER);)(m=new p({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(m);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var m=this.reader.lastIndexOfSignature(d.CENTRAL_DIRECTORY_END);if(m<0)throw this.isSignature(0,d.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(m);var y=m;if(this.checkSignature(d.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===c.MAX_VALUE_16BITS||this.diskWithCentralDirStart===c.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===c.MAX_VALUE_16BITS||this.centralDirRecords===c.MAX_VALUE_16BITS||this.centralDirSize===c.MAX_VALUE_32BITS||this.centralDirOffset===c.MAX_VALUE_32BITS){if(this.zip64=!0,(m=this.reader.lastIndexOfSignature(d.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(m),this.checkSignature(d.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,d.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(d.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(d.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var E=this.centralDirOffset+this.centralDirSize;this.zip64&&(E+=20,E+=12+this.zip64EndOfCentralSize);var C=y-E;if(0<C)this.isSignature(y,d.CENTRAL_FILE_HEADER)||(this.reader.zero=C);else if(C<0)throw new Error("Corrupted zip: missing "+Math.abs(C)+" bytes.")},prepareReader:function(m){this.reader=f(m)},load:function(m){this.prepareReader(m),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},l.exports=A},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(i,l,u){var f=i("./reader/readerFor"),c=i("./utils"),d=i("./compressedObject"),p=i("./crc32"),g=i("./utf8"),A=i("./compressions"),m=i("./support");function y(E,C){this.options=E,this.loadOptions=C}y.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(E){var C,x;if(E.skip(22),this.fileNameLength=E.readInt(2),x=E.readInt(2),this.fileName=E.readData(this.fileNameLength),E.skip(x),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((C=function(w){for(var v in A)if(Object.prototype.hasOwnProperty.call(A,v)&&A[v].magic===w)return A[v];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+c.pretty(this.compressionMethod)+" unknown (inner file : "+c.transformTo("string",this.fileName)+")");this.decompressed=new d(this.compressedSize,this.uncompressedSize,this.crc32,C,E.readData(this.compressedSize))},readCentralPart:function(E){this.versionMadeBy=E.readInt(2),E.skip(2),this.bitFlag=E.readInt(2),this.compressionMethod=E.readString(2),this.date=E.readDate(),this.crc32=E.readInt(4),this.compressedSize=E.readInt(4),this.uncompressedSize=E.readInt(4);var C=E.readInt(2);if(this.extraFieldsLength=E.readInt(2),this.fileCommentLength=E.readInt(2),this.diskNumberStart=E.readInt(2),this.internalFileAttributes=E.readInt(2),this.externalFileAttributes=E.readInt(4),this.localHeaderOffset=E.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");E.skip(C),this.readExtraFields(E),this.parseZIP64ExtraField(E),this.fileComment=E.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var E=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),E==0&&(this.dosPermissions=63&this.externalFileAttributes),E==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var E=f(this.extraFields[1].value);this.uncompressedSize===c.MAX_VALUE_32BITS&&(this.uncompressedSize=E.readInt(8)),this.compressedSize===c.MAX_VALUE_32BITS&&(this.compressedSize=E.readInt(8)),this.localHeaderOffset===c.MAX_VALUE_32BITS&&(this.localHeaderOffset=E.readInt(8)),this.diskNumberStart===c.MAX_VALUE_32BITS&&(this.diskNumberStart=E.readInt(4))}},readExtraFields:function(E){var C,x,w,v=E.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});E.index+4<v;)C=E.readInt(2),x=E.readInt(2),w=E.readData(x),this.extraFields[C]={id:C,length:x,value:w};E.setIndex(v)},handleUTF8:function(){var E=m.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=g.utf8decode(this.fileName),this.fileCommentStr=g.utf8decode(this.fileComment);else{var C=this.findExtraFieldUnicodePath();if(C!==null)this.fileNameStr=C;else{var x=c.transformTo(E,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(x)}var w=this.findExtraFieldUnicodeComment();if(w!==null)this.fileCommentStr=w;else{var v=c.transformTo(E,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var E=this.extraFields[28789];if(E){var C=f(E.value);return C.readInt(1)!==1||p(this.fileName)!==C.readInt(4)?null:g.utf8decode(C.readData(E.length-5))}return null},findExtraFieldUnicodeComment:function(){var E=this.extraFields[25461];if(E){var C=f(E.value);return C.readInt(1)!==1||p(this.fileComment)!==C.readInt(4)?null:g.utf8decode(C.readData(E.length-5))}return null}},l.exports=y},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(i,l,u){function f(C,x,w){this.name=C,this.dir=w.dir,this.date=w.date,this.comment=w.comment,this.unixPermissions=w.unixPermissions,this.dosPermissions=w.dosPermissions,this._data=x,this._dataBinary=w.binary,this.options={compression:w.compression,compressionOptions:w.compressionOptions}}var c=i("./stream/StreamHelper"),d=i("./stream/DataWorker"),p=i("./utf8"),g=i("./compressedObject"),A=i("./stream/GenericWorker");f.prototype={internalStream:function(C){var x=null,w="string";try{if(!C)throw new Error("No output type specified.");var v=(w=C.toLowerCase())==="string"||w==="text";w!=="binarystring"&&w!=="text"||(w="string"),x=this._decompressWorker();var D=!this._dataBinary;D&&!v&&(x=x.pipe(new p.Utf8EncodeWorker)),!D&&v&&(x=x.pipe(new p.Utf8DecodeWorker))}catch(B){(x=new A("error")).error(B)}return new c(x,w,"")},async:function(C,x){return this.internalStream(C).accumulate(x)},nodeStream:function(C,x){return this.internalStream(C||"nodebuffer").toNodejsStream(x)},_compressWorker:function(C,x){if(this._data instanceof g&&this._data.compression.magic===C.magic)return this._data.getCompressedWorker();var w=this._decompressWorker();return this._dataBinary||(w=w.pipe(new p.Utf8EncodeWorker)),g.createWorkerFrom(w,C,x)},_decompressWorker:function(){return this._data instanceof g?this._data.getContentWorker():this._data instanceof A?this._data:new d(this._data)}};for(var m=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],y=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},E=0;E<m.length;E++)f.prototype[m[E]]=y;l.exports=f},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(i,l,u){(function(f){var c,d,p=f.MutationObserver||f.WebKitMutationObserver;if(p){var g=0,A=new p(C),m=f.document.createTextNode("");A.observe(m,{characterData:!0}),c=function(){m.data=g=++g%2}}else if(f.setImmediate||f.MessageChannel===void 0)c="document"in f&&"onreadystatechange"in f.document.createElement("script")?function(){var x=f.document.createElement("script");x.onreadystatechange=function(){C(),x.onreadystatechange=null,x.parentNode.removeChild(x),x=null},f.document.documentElement.appendChild(x)}:function(){setTimeout(C,0)};else{var y=new f.MessageChannel;y.port1.onmessage=C,c=function(){y.port2.postMessage(0)}}var E=[];function C(){var x,w;d=!0;for(var v=E.length;v;){for(w=E,E=[],x=-1;++x<v;)w[x]();v=E.length}d=!1}l.exports=function(x){E.push(x)!==1||d||c()}}).call(this,typeof $t!="undefined"?$t:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],37:[function(i,l,u){var f=i("immediate");function c(){}var d={},p=["REJECTED"],g=["FULFILLED"],A=["PENDING"];function m(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=A,this.queue=[],this.outcome=void 0,v!==c&&x(this,v)}function y(v,D,B){this.promise=v,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof B=="function"&&(this.onRejected=B,this.callRejected=this.otherCallRejected)}function E(v,D,B){f(function(){var z;try{z=D(B)}catch(P){return d.reject(v,P)}z===v?d.reject(v,new TypeError("Cannot resolve promise with itself")):d.resolve(v,z)})}function C(v){var D=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof D=="function")return function(){D.apply(v,arguments)}}function x(v,D){var B=!1;function z(Z){B||(B=!0,d.reject(v,Z))}function P(Z){B||(B=!0,d.resolve(v,Z))}var N=w(function(){D(P,z)});N.status==="error"&&z(N.value)}function w(v,D){var B={};try{B.value=v(D),B.status="success"}catch(z){B.status="error",B.value=z}return B}(l.exports=m).prototype.finally=function(v){if(typeof v!="function")return this;var D=this.constructor;return this.then(function(B){return D.resolve(v()).then(function(){return B})},function(B){return D.resolve(v()).then(function(){throw B})})},m.prototype.catch=function(v){return this.then(null,v)},m.prototype.then=function(v,D){if(typeof v!="function"&&this.state===g||typeof D!="function"&&this.state===p)return this;var B=new this.constructor(c);return this.state!==A?E(B,this.state===g?v:D,this.outcome):this.queue.push(new y(B,v,D)),B},y.prototype.callFulfilled=function(v){d.resolve(this.promise,v)},y.prototype.otherCallFulfilled=function(v){E(this.promise,this.onFulfilled,v)},y.prototype.callRejected=function(v){d.reject(this.promise,v)},y.prototype.otherCallRejected=function(v){E(this.promise,this.onRejected,v)},d.resolve=function(v,D){var B=w(C,D);if(B.status==="error")return d.reject(v,B.value);var z=B.value;if(z)x(v,z);else{v.state=g,v.outcome=D;for(var P=-1,N=v.queue.length;++P<N;)v.queue[P].callFulfilled(D)}return v},d.reject=function(v,D){v.state=p,v.outcome=D;for(var B=-1,z=v.queue.length;++B<z;)v.queue[B].callRejected(D);return v},m.resolve=function(v){return v instanceof this?v:d.resolve(new this(c),v)},m.reject=function(v){var D=new this(c);return d.reject(D,v)},m.all=function(v){var D=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var B=v.length,z=!1;if(!B)return this.resolve([]);for(var P=new Array(B),N=0,Z=-1,ie=new this(c);++Z<B;)F(v[Z],Z);return ie;function F(K,re){D.resolve(K).then(function(Q){P[re]=Q,++N!==B||z||(z=!0,d.resolve(ie,P))},function(Q){z||(z=!0,d.reject(ie,Q))})}},m.race=function(v){var D=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var B=v.length,z=!1;if(!B)return this.resolve([]);for(var P=-1,N=new this(c);++P<B;)Z=v[P],D.resolve(Z).then(function(ie){z||(z=!0,d.resolve(N,ie))},function(ie){z||(z=!0,d.reject(N,ie))});var Z;return N}},{immediate:36}],38:[function(i,l,u){var f={};(0,i("./lib/utils/common").assign)(f,i("./lib/deflate"),i("./lib/inflate"),i("./lib/zlib/constants")),l.exports=f},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(i,l,u){var f=i("./zlib/deflate"),c=i("./utils/common"),d=i("./utils/strings"),p=i("./zlib/messages"),g=i("./zlib/zstream"),A=Object.prototype.toString,m=0,y=-1,E=0,C=8;function x(v){if(!(this instanceof x))return new x(v);this.options=c.assign({level:y,method:C,chunkSize:16384,windowBits:15,memLevel:8,strategy:E,to:""},v||{});var D=this.options;D.raw&&0<D.windowBits?D.windowBits=-D.windowBits:D.gzip&&0<D.windowBits&&D.windowBits<16&&(D.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var B=f.deflateInit2(this.strm,D.level,D.method,D.windowBits,D.memLevel,D.strategy);if(B!==m)throw new Error(p[B]);if(D.header&&f.deflateSetHeader(this.strm,D.header),D.dictionary){var z;if(z=typeof D.dictionary=="string"?d.string2buf(D.dictionary):A.call(D.dictionary)==="[object ArrayBuffer]"?new Uint8Array(D.dictionary):D.dictionary,(B=f.deflateSetDictionary(this.strm,z))!==m)throw new Error(p[B]);this._dict_set=!0}}function w(v,D){var B=new x(D);if(B.push(v,!0),B.err)throw B.msg||p[B.err];return B.result}x.prototype.push=function(v,D){var B,z,P=this.strm,N=this.options.chunkSize;if(this.ended)return!1;z=D===~~D?D:D===!0?4:0,typeof v=="string"?P.input=d.string2buf(v):A.call(v)==="[object ArrayBuffer]"?P.input=new Uint8Array(v):P.input=v,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new c.Buf8(N),P.next_out=0,P.avail_out=N),(B=f.deflate(P,z))!==1&&B!==m)return this.onEnd(B),!(this.ended=!0);P.avail_out!==0&&(P.avail_in!==0||z!==4&&z!==2)||(this.options.to==="string"?this.onData(d.buf2binstring(c.shrinkBuf(P.output,P.next_out))):this.onData(c.shrinkBuf(P.output,P.next_out)))}while((0<P.avail_in||P.avail_out===0)&&B!==1);return z===4?(B=f.deflateEnd(this.strm),this.onEnd(B),this.ended=!0,B===m):z!==2||(this.onEnd(m),!(P.avail_out=0))},x.prototype.onData=function(v){this.chunks.push(v)},x.prototype.onEnd=function(v){v===m&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=c.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},u.Deflate=x,u.deflate=w,u.deflateRaw=function(v,D){return(D=D||{}).raw=!0,w(v,D)},u.gzip=function(v,D){return(D=D||{}).gzip=!0,w(v,D)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(i,l,u){var f=i("./zlib/inflate"),c=i("./utils/common"),d=i("./utils/strings"),p=i("./zlib/constants"),g=i("./zlib/messages"),A=i("./zlib/zstream"),m=i("./zlib/gzheader"),y=Object.prototype.toString;function E(x){if(!(this instanceof E))return new E(x);this.options=c.assign({chunkSize:16384,windowBits:0,to:""},x||{});var w=this.options;w.raw&&0<=w.windowBits&&w.windowBits<16&&(w.windowBits=-w.windowBits,w.windowBits===0&&(w.windowBits=-15)),!(0<=w.windowBits&&w.windowBits<16)||x&&x.windowBits||(w.windowBits+=32),15<w.windowBits&&w.windowBits<48&&(15&w.windowBits)==0&&(w.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new A,this.strm.avail_out=0;var v=f.inflateInit2(this.strm,w.windowBits);if(v!==p.Z_OK)throw new Error(g[v]);this.header=new m,f.inflateGetHeader(this.strm,this.header)}function C(x,w){var v=new E(w);if(v.push(x,!0),v.err)throw v.msg||g[v.err];return v.result}E.prototype.push=function(x,w){var v,D,B,z,P,N,Z=this.strm,ie=this.options.chunkSize,F=this.options.dictionary,K=!1;if(this.ended)return!1;D=w===~~w?w:w===!0?p.Z_FINISH:p.Z_NO_FLUSH,typeof x=="string"?Z.input=d.binstring2buf(x):y.call(x)==="[object ArrayBuffer]"?Z.input=new Uint8Array(x):Z.input=x,Z.next_in=0,Z.avail_in=Z.input.length;do{if(Z.avail_out===0&&(Z.output=new c.Buf8(ie),Z.next_out=0,Z.avail_out=ie),(v=f.inflate(Z,p.Z_NO_FLUSH))===p.Z_NEED_DICT&&F&&(N=typeof F=="string"?d.string2buf(F):y.call(F)==="[object ArrayBuffer]"?new Uint8Array(F):F,v=f.inflateSetDictionary(this.strm,N)),v===p.Z_BUF_ERROR&&K===!0&&(v=p.Z_OK,K=!1),v!==p.Z_STREAM_END&&v!==p.Z_OK)return this.onEnd(v),!(this.ended=!0);Z.next_out&&(Z.avail_out!==0&&v!==p.Z_STREAM_END&&(Z.avail_in!==0||D!==p.Z_FINISH&&D!==p.Z_SYNC_FLUSH)||(this.options.to==="string"?(B=d.utf8border(Z.output,Z.next_out),z=Z.next_out-B,P=d.buf2string(Z.output,B),Z.next_out=z,Z.avail_out=ie-z,z&&c.arraySet(Z.output,Z.output,B,z,0),this.onData(P)):this.onData(c.shrinkBuf(Z.output,Z.next_out)))),Z.avail_in===0&&Z.avail_out===0&&(K=!0)}while((0<Z.avail_in||Z.avail_out===0)&&v!==p.Z_STREAM_END);return v===p.Z_STREAM_END&&(D=p.Z_FINISH),D===p.Z_FINISH?(v=f.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===p.Z_OK):D!==p.Z_SYNC_FLUSH||(this.onEnd(p.Z_OK),!(Z.avail_out=0))},E.prototype.onData=function(x){this.chunks.push(x)},E.prototype.onEnd=function(x){x===p.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=c.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},u.Inflate=E,u.inflate=C,u.inflateRaw=function(x,w){return(w=w||{}).raw=!0,C(x,w)},u.ungzip=C},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(i,l,u){var f=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Int32Array!="undefined";u.assign=function(p){for(var g=Array.prototype.slice.call(arguments,1);g.length;){var A=g.shift();if(A){if(typeof A!="object")throw new TypeError(A+"must be non-object");for(var m in A)A.hasOwnProperty(m)&&(p[m]=A[m])}}return p},u.shrinkBuf=function(p,g){return p.length===g?p:p.subarray?p.subarray(0,g):(p.length=g,p)};var c={arraySet:function(p,g,A,m,y){if(g.subarray&&p.subarray)p.set(g.subarray(A,A+m),y);else for(var E=0;E<m;E++)p[y+E]=g[A+E]},flattenChunks:function(p){var g,A,m,y,E,C;for(g=m=0,A=p.length;g<A;g++)m+=p[g].length;for(C=new Uint8Array(m),g=y=0,A=p.length;g<A;g++)E=p[g],C.set(E,y),y+=E.length;return C}},d={arraySet:function(p,g,A,m,y){for(var E=0;E<m;E++)p[y+E]=g[A+E]},flattenChunks:function(p){return[].concat.apply([],p)}};u.setTyped=function(p){p?(u.Buf8=Uint8Array,u.Buf16=Uint16Array,u.Buf32=Int32Array,u.assign(u,c)):(u.Buf8=Array,u.Buf16=Array,u.Buf32=Array,u.assign(u,d))},u.setTyped(f)},{}],42:[function(i,l,u){var f=i("./common"),c=!0,d=!0;try{String.fromCharCode.apply(null,[0])}catch(m){c=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(m){d=!1}for(var p=new f.Buf8(256),g=0;g<256;g++)p[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;function A(m,y){if(y<65537&&(m.subarray&&d||!m.subarray&&c))return String.fromCharCode.apply(null,f.shrinkBuf(m,y));for(var E="",C=0;C<y;C++)E+=String.fromCharCode(m[C]);return E}p[254]=p[254]=1,u.string2buf=function(m){var y,E,C,x,w,v=m.length,D=0;for(x=0;x<v;x++)(64512&(E=m.charCodeAt(x)))==55296&&x+1<v&&(64512&(C=m.charCodeAt(x+1)))==56320&&(E=65536+(E-55296<<10)+(C-56320),x++),D+=E<128?1:E<2048?2:E<65536?3:4;for(y=new f.Buf8(D),x=w=0;w<D;x++)(64512&(E=m.charCodeAt(x)))==55296&&x+1<v&&(64512&(C=m.charCodeAt(x+1)))==56320&&(E=65536+(E-55296<<10)+(C-56320),x++),E<128?y[w++]=E:(E<2048?y[w++]=192|E>>>6:(E<65536?y[w++]=224|E>>>12:(y[w++]=240|E>>>18,y[w++]=128|E>>>12&63),y[w++]=128|E>>>6&63),y[w++]=128|63&E);return y},u.buf2binstring=function(m){return A(m,m.length)},u.binstring2buf=function(m){for(var y=new f.Buf8(m.length),E=0,C=y.length;E<C;E++)y[E]=m.charCodeAt(E);return y},u.buf2string=function(m,y){var E,C,x,w,v=y||m.length,D=new Array(2*v);for(E=C=0;E<v;)if((x=m[E++])<128)D[C++]=x;else if(4<(w=p[x]))D[C++]=65533,E+=w-1;else{for(x&=w===2?31:w===3?15:7;1<w&&E<v;)x=x<<6|63&m[E++],w--;1<w?D[C++]=65533:x<65536?D[C++]=x:(x-=65536,D[C++]=55296|x>>10&1023,D[C++]=56320|1023&x)}return A(D,C)},u.utf8border=function(m,y){var E;for((y=y||m.length)>m.length&&(y=m.length),E=y-1;0<=E&&(192&m[E])==128;)E--;return E<0||E===0?y:E+p[m[E]]>y?E:y}},{"./common":41}],43:[function(i,l,u){l.exports=function(f,c,d,p){for(var g=65535&f|0,A=f>>>16&65535|0,m=0;d!==0;){for(d-=m=2e3<d?2e3:d;A=A+(g=g+c[p++]|0)|0,--m;);g%=65521,A%=65521}return g|A<<16|0}},{}],44:[function(i,l,u){l.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(i,l,u){var f=function(){for(var c,d=[],p=0;p<256;p++){c=p;for(var g=0;g<8;g++)c=1&c?3988292384^c>>>1:c>>>1;d[p]=c}return d}();l.exports=function(c,d,p,g){var A=f,m=g+p;c^=-1;for(var y=g;y<m;y++)c=c>>>8^A[255&(c^d[y])];return-1^c}},{}],46:[function(i,l,u){var f,c=i("../utils/common"),d=i("./trees"),p=i("./adler32"),g=i("./crc32"),A=i("./messages"),m=0,y=4,E=0,C=-2,x=-1,w=4,v=2,D=8,B=9,z=286,P=30,N=19,Z=2*z+1,ie=15,F=3,K=258,re=K+F+1,Q=42,q=113,I=1,ue=2,fe=3,ce=4;function le(S,ge){return S.msg=A[ge],ge}function ne(S){return(S<<1)-(4<S?9:0)}function T(S){for(var ge=S.length;0<=--ge;)S[ge]=0}function _(S){var ge=S.state,de=ge.pending;de>S.avail_out&&(de=S.avail_out),de!==0&&(c.arraySet(S.output,ge.pending_buf,ge.pending_out,de,S.next_out),S.next_out+=de,ge.pending_out+=de,S.total_out+=de,S.avail_out-=de,ge.pending-=de,ge.pending===0&&(ge.pending_out=0))}function V(S,ge){d._tr_flush_block(S,0<=S.block_start?S.block_start:-1,S.strstart-S.block_start,ge),S.block_start=S.strstart,_(S.strm)}function U(S,ge){S.pending_buf[S.pending++]=ge}function he(S,ge){S.pending_buf[S.pending++]=ge>>>8&255,S.pending_buf[S.pending++]=255&ge}function be(S,ge){var de,Y,j=S.max_chain_length,H=S.strstart,J=S.prev_length,pe=S.nice_match,$=S.strstart>S.w_size-re?S.strstart-(S.w_size-re):0,ye=S.window,Re=S.w_mask,ke=S.prev,te=S.strstart+K,ee=ye[H+J-1],we=ye[H+J];S.prev_length>=S.good_match&&(j>>=2),pe>S.lookahead&&(pe=S.lookahead);do if(ye[(de=ge)+J]===we&&ye[de+J-1]===ee&&ye[de]===ye[H]&&ye[++de]===ye[H+1]){H+=2,de++;do;while(ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&ye[++H]===ye[++de]&&H<te);if(Y=K-(te-H),H=te-K,J<Y){if(S.match_start=ge,pe<=(J=Y))break;ee=ye[H+J-1],we=ye[H+J]}}while((ge=ke[ge&Re])>$&&--j!=0);return J<=S.lookahead?J:S.lookahead}function Be(S){var ge,de,Y,j,H,J,pe,$,ye,Re,ke=S.w_size;do{if(j=S.window_size-S.lookahead-S.strstart,S.strstart>=ke+(ke-re)){for(c.arraySet(S.window,S.window,ke,ke,0),S.match_start-=ke,S.strstart-=ke,S.block_start-=ke,ge=de=S.hash_size;Y=S.head[--ge],S.head[ge]=ke<=Y?Y-ke:0,--de;);for(ge=de=ke;Y=S.prev[--ge],S.prev[ge]=ke<=Y?Y-ke:0,--de;);j+=ke}if(S.strm.avail_in===0)break;if(J=S.strm,pe=S.window,$=S.strstart+S.lookahead,ye=j,Re=void 0,Re=J.avail_in,ye<Re&&(Re=ye),de=Re===0?0:(J.avail_in-=Re,c.arraySet(pe,J.input,J.next_in,Re,$),J.state.wrap===1?J.adler=p(J.adler,pe,Re,$):J.state.wrap===2&&(J.adler=g(J.adler,pe,Re,$)),J.next_in+=Re,J.total_in+=Re,Re),S.lookahead+=de,S.lookahead+S.insert>=F)for(H=S.strstart-S.insert,S.ins_h=S.window[H],S.ins_h=(S.ins_h<<S.hash_shift^S.window[H+1])&S.hash_mask;S.insert&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[H+F-1])&S.hash_mask,S.prev[H&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=H,H++,S.insert--,!(S.lookahead+S.insert<F)););}while(S.lookahead<re&&S.strm.avail_in!==0)}function Ke(S,ge){for(var de,Y;;){if(S.lookahead<re){if(Be(S),S.lookahead<re&&ge===m)return I;if(S.lookahead===0)break}if(de=0,S.lookahead>=F&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+F-1])&S.hash_mask,de=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart),de!==0&&S.strstart-de<=S.w_size-re&&(S.match_length=be(S,de)),S.match_length>=F)if(Y=d._tr_tally(S,S.strstart-S.match_start,S.match_length-F),S.lookahead-=S.match_length,S.match_length<=S.max_lazy_match&&S.lookahead>=F){for(S.match_length--;S.strstart++,S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+F-1])&S.hash_mask,de=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart,--S.match_length!=0;);S.strstart++}else S.strstart+=S.match_length,S.match_length=0,S.ins_h=S.window[S.strstart],S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+1])&S.hash_mask;else Y=d._tr_tally(S,0,S.window[S.strstart]),S.lookahead--,S.strstart++;if(Y&&(V(S,!1),S.strm.avail_out===0))return I}return S.insert=S.strstart<F-1?S.strstart:F-1,ge===y?(V(S,!0),S.strm.avail_out===0?fe:ce):S.last_lit&&(V(S,!1),S.strm.avail_out===0)?I:ue}function Ue(S,ge){for(var de,Y,j;;){if(S.lookahead<re){if(Be(S),S.lookahead<re&&ge===m)return I;if(S.lookahead===0)break}if(de=0,S.lookahead>=F&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+F-1])&S.hash_mask,de=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart),S.prev_length=S.match_length,S.prev_match=S.match_start,S.match_length=F-1,de!==0&&S.prev_length<S.max_lazy_match&&S.strstart-de<=S.w_size-re&&(S.match_length=be(S,de),S.match_length<=5&&(S.strategy===1||S.match_length===F&&4096<S.strstart-S.match_start)&&(S.match_length=F-1)),S.prev_length>=F&&S.match_length<=S.prev_length){for(j=S.strstart+S.lookahead-F,Y=d._tr_tally(S,S.strstart-1-S.prev_match,S.prev_length-F),S.lookahead-=S.prev_length-1,S.prev_length-=2;++S.strstart<=j&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+F-1])&S.hash_mask,de=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart),--S.prev_length!=0;);if(S.match_available=0,S.match_length=F-1,S.strstart++,Y&&(V(S,!1),S.strm.avail_out===0))return I}else if(S.match_available){if((Y=d._tr_tally(S,0,S.window[S.strstart-1]))&&V(S,!1),S.strstart++,S.lookahead--,S.strm.avail_out===0)return I}else S.match_available=1,S.strstart++,S.lookahead--}return S.match_available&&(Y=d._tr_tally(S,0,S.window[S.strstart-1]),S.match_available=0),S.insert=S.strstart<F-1?S.strstart:F-1,ge===y?(V(S,!0),S.strm.avail_out===0?fe:ce):S.last_lit&&(V(S,!1),S.strm.avail_out===0)?I:ue}function Fe(S,ge,de,Y,j){this.good_length=S,this.max_lazy=ge,this.nice_length=de,this.max_chain=Y,this.func=j}function We(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=D,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new c.Buf16(2*Z),this.dyn_dtree=new c.Buf16(2*(2*P+1)),this.bl_tree=new c.Buf16(2*(2*N+1)),T(this.dyn_ltree),T(this.dyn_dtree),T(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new c.Buf16(ie+1),this.heap=new c.Buf16(2*z+1),T(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new c.Buf16(2*z+1),T(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function rt(S){var ge;return S&&S.state?(S.total_in=S.total_out=0,S.data_type=v,(ge=S.state).pending=0,ge.pending_out=0,ge.wrap<0&&(ge.wrap=-ge.wrap),ge.status=ge.wrap?Q:q,S.adler=ge.wrap===2?0:1,ge.last_flush=m,d._tr_init(ge),E):le(S,C)}function Ct(S){var ge=rt(S);return ge===E&&function(de){de.window_size=2*de.w_size,T(de.head),de.max_lazy_match=f[de.level].max_lazy,de.good_match=f[de.level].good_length,de.nice_match=f[de.level].nice_length,de.max_chain_length=f[de.level].max_chain,de.strstart=0,de.block_start=0,de.lookahead=0,de.insert=0,de.match_length=de.prev_length=F-1,de.match_available=0,de.ins_h=0}(S.state),ge}function Mt(S,ge,de,Y,j,H){if(!S)return C;var J=1;if(ge===x&&(ge=6),Y<0?(J=0,Y=-Y):15<Y&&(J=2,Y-=16),j<1||B<j||de!==D||Y<8||15<Y||ge<0||9<ge||H<0||w<H)return le(S,C);Y===8&&(Y=9);var pe=new We;return(S.state=pe).strm=S,pe.wrap=J,pe.gzhead=null,pe.w_bits=Y,pe.w_size=1<<pe.w_bits,pe.w_mask=pe.w_size-1,pe.hash_bits=j+7,pe.hash_size=1<<pe.hash_bits,pe.hash_mask=pe.hash_size-1,pe.hash_shift=~~((pe.hash_bits+F-1)/F),pe.window=new c.Buf8(2*pe.w_size),pe.head=new c.Buf16(pe.hash_size),pe.prev=new c.Buf16(pe.w_size),pe.lit_bufsize=1<<j+6,pe.pending_buf_size=4*pe.lit_bufsize,pe.pending_buf=new c.Buf8(pe.pending_buf_size),pe.d_buf=1*pe.lit_bufsize,pe.l_buf=3*pe.lit_bufsize,pe.level=ge,pe.strategy=H,pe.method=de,Ct(S)}f=[new Fe(0,0,0,0,function(S,ge){var de=65535;for(de>S.pending_buf_size-5&&(de=S.pending_buf_size-5);;){if(S.lookahead<=1){if(Be(S),S.lookahead===0&&ge===m)return I;if(S.lookahead===0)break}S.strstart+=S.lookahead,S.lookahead=0;var Y=S.block_start+de;if((S.strstart===0||S.strstart>=Y)&&(S.lookahead=S.strstart-Y,S.strstart=Y,V(S,!1),S.strm.avail_out===0)||S.strstart-S.block_start>=S.w_size-re&&(V(S,!1),S.strm.avail_out===0))return I}return S.insert=0,ge===y?(V(S,!0),S.strm.avail_out===0?fe:ce):(S.strstart>S.block_start&&(V(S,!1),S.strm.avail_out),I)}),new Fe(4,4,8,4,Ke),new Fe(4,5,16,8,Ke),new Fe(4,6,32,32,Ke),new Fe(4,4,16,16,Ue),new Fe(8,16,32,32,Ue),new Fe(8,16,128,128,Ue),new Fe(8,32,128,256,Ue),new Fe(32,128,258,1024,Ue),new Fe(32,258,258,4096,Ue)],u.deflateInit=function(S,ge){return Mt(S,ge,D,15,8,0)},u.deflateInit2=Mt,u.deflateReset=Ct,u.deflateResetKeep=rt,u.deflateSetHeader=function(S,ge){return S&&S.state?S.state.wrap!==2?C:(S.state.gzhead=ge,E):C},u.deflate=function(S,ge){var de,Y,j,H;if(!S||!S.state||5<ge||ge<0)return S?le(S,C):C;if(Y=S.state,!S.output||!S.input&&S.avail_in!==0||Y.status===666&&ge!==y)return le(S,S.avail_out===0?-5:C);if(Y.strm=S,de=Y.last_flush,Y.last_flush=ge,Y.status===Q)if(Y.wrap===2)S.adler=0,U(Y,31),U(Y,139),U(Y,8),Y.gzhead?(U(Y,(Y.gzhead.text?1:0)+(Y.gzhead.hcrc?2:0)+(Y.gzhead.extra?4:0)+(Y.gzhead.name?8:0)+(Y.gzhead.comment?16:0)),U(Y,255&Y.gzhead.time),U(Y,Y.gzhead.time>>8&255),U(Y,Y.gzhead.time>>16&255),U(Y,Y.gzhead.time>>24&255),U(Y,Y.level===9?2:2<=Y.strategy||Y.level<2?4:0),U(Y,255&Y.gzhead.os),Y.gzhead.extra&&Y.gzhead.extra.length&&(U(Y,255&Y.gzhead.extra.length),U(Y,Y.gzhead.extra.length>>8&255)),Y.gzhead.hcrc&&(S.adler=g(S.adler,Y.pending_buf,Y.pending,0)),Y.gzindex=0,Y.status=69):(U(Y,0),U(Y,0),U(Y,0),U(Y,0),U(Y,0),U(Y,Y.level===9?2:2<=Y.strategy||Y.level<2?4:0),U(Y,3),Y.status=q);else{var J=D+(Y.w_bits-8<<4)<<8;J|=(2<=Y.strategy||Y.level<2?0:Y.level<6?1:Y.level===6?2:3)<<6,Y.strstart!==0&&(J|=32),J+=31-J%31,Y.status=q,he(Y,J),Y.strstart!==0&&(he(Y,S.adler>>>16),he(Y,65535&S.adler)),S.adler=1}if(Y.status===69)if(Y.gzhead.extra){for(j=Y.pending;Y.gzindex<(65535&Y.gzhead.extra.length)&&(Y.pending!==Y.pending_buf_size||(Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),_(S),j=Y.pending,Y.pending!==Y.pending_buf_size));)U(Y,255&Y.gzhead.extra[Y.gzindex]),Y.gzindex++;Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),Y.gzindex===Y.gzhead.extra.length&&(Y.gzindex=0,Y.status=73)}else Y.status=73;if(Y.status===73)if(Y.gzhead.name){j=Y.pending;do{if(Y.pending===Y.pending_buf_size&&(Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),_(S),j=Y.pending,Y.pending===Y.pending_buf_size)){H=1;break}H=Y.gzindex<Y.gzhead.name.length?255&Y.gzhead.name.charCodeAt(Y.gzindex++):0,U(Y,H)}while(H!==0);Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),H===0&&(Y.gzindex=0,Y.status=91)}else Y.status=91;if(Y.status===91)if(Y.gzhead.comment){j=Y.pending;do{if(Y.pending===Y.pending_buf_size&&(Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),_(S),j=Y.pending,Y.pending===Y.pending_buf_size)){H=1;break}H=Y.gzindex<Y.gzhead.comment.length?255&Y.gzhead.comment.charCodeAt(Y.gzindex++):0,U(Y,H)}while(H!==0);Y.gzhead.hcrc&&Y.pending>j&&(S.adler=g(S.adler,Y.pending_buf,Y.pending-j,j)),H===0&&(Y.status=103)}else Y.status=103;if(Y.status===103&&(Y.gzhead.hcrc?(Y.pending+2>Y.pending_buf_size&&_(S),Y.pending+2<=Y.pending_buf_size&&(U(Y,255&S.adler),U(Y,S.adler>>8&255),S.adler=0,Y.status=q)):Y.status=q),Y.pending!==0){if(_(S),S.avail_out===0)return Y.last_flush=-1,E}else if(S.avail_in===0&&ne(ge)<=ne(de)&&ge!==y)return le(S,-5);if(Y.status===666&&S.avail_in!==0)return le(S,-5);if(S.avail_in!==0||Y.lookahead!==0||ge!==m&&Y.status!==666){var pe=Y.strategy===2?function($,ye){for(var Re;;){if($.lookahead===0&&(Be($),$.lookahead===0)){if(ye===m)return I;break}if($.match_length=0,Re=d._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++,Re&&(V($,!1),$.strm.avail_out===0))return I}return $.insert=0,ye===y?(V($,!0),$.strm.avail_out===0?fe:ce):$.last_lit&&(V($,!1),$.strm.avail_out===0)?I:ue}(Y,ge):Y.strategy===3?function($,ye){for(var Re,ke,te,ee,we=$.window;;){if($.lookahead<=K){if(Be($),$.lookahead<=K&&ye===m)return I;if($.lookahead===0)break}if($.match_length=0,$.lookahead>=F&&0<$.strstart&&(ke=we[te=$.strstart-1])===we[++te]&&ke===we[++te]&&ke===we[++te]){ee=$.strstart+K;do;while(ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&ke===we[++te]&&te<ee);$.match_length=K-(ee-te),$.match_length>$.lookahead&&($.match_length=$.lookahead)}if($.match_length>=F?(Re=d._tr_tally($,1,$.match_length-F),$.lookahead-=$.match_length,$.strstart+=$.match_length,$.match_length=0):(Re=d._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++),Re&&(V($,!1),$.strm.avail_out===0))return I}return $.insert=0,ye===y?(V($,!0),$.strm.avail_out===0?fe:ce):$.last_lit&&(V($,!1),$.strm.avail_out===0)?I:ue}(Y,ge):f[Y.level].func(Y,ge);if(pe!==fe&&pe!==ce||(Y.status=666),pe===I||pe===fe)return S.avail_out===0&&(Y.last_flush=-1),E;if(pe===ue&&(ge===1?d._tr_align(Y):ge!==5&&(d._tr_stored_block(Y,0,0,!1),ge===3&&(T(Y.head),Y.lookahead===0&&(Y.strstart=0,Y.block_start=0,Y.insert=0))),_(S),S.avail_out===0))return Y.last_flush=-1,E}return ge!==y?E:Y.wrap<=0?1:(Y.wrap===2?(U(Y,255&S.adler),U(Y,S.adler>>8&255),U(Y,S.adler>>16&255),U(Y,S.adler>>24&255),U(Y,255&S.total_in),U(Y,S.total_in>>8&255),U(Y,S.total_in>>16&255),U(Y,S.total_in>>24&255)):(he(Y,S.adler>>>16),he(Y,65535&S.adler)),_(S),0<Y.wrap&&(Y.wrap=-Y.wrap),Y.pending!==0?E:1)},u.deflateEnd=function(S){var ge;return S&&S.state?(ge=S.state.status)!==Q&&ge!==69&&ge!==73&&ge!==91&&ge!==103&&ge!==q&&ge!==666?le(S,C):(S.state=null,ge===q?le(S,-3):E):C},u.deflateSetDictionary=function(S,ge){var de,Y,j,H,J,pe,$,ye,Re=ge.length;if(!S||!S.state||(H=(de=S.state).wrap)===2||H===1&&de.status!==Q||de.lookahead)return C;for(H===1&&(S.adler=p(S.adler,ge,Re,0)),de.wrap=0,Re>=de.w_size&&(H===0&&(T(de.head),de.strstart=0,de.block_start=0,de.insert=0),ye=new c.Buf8(de.w_size),c.arraySet(ye,ge,Re-de.w_size,de.w_size,0),ge=ye,Re=de.w_size),J=S.avail_in,pe=S.next_in,$=S.input,S.avail_in=Re,S.next_in=0,S.input=ge,Be(de);de.lookahead>=F;){for(Y=de.strstart,j=de.lookahead-(F-1);de.ins_h=(de.ins_h<<de.hash_shift^de.window[Y+F-1])&de.hash_mask,de.prev[Y&de.w_mask]=de.head[de.ins_h],de.head[de.ins_h]=Y,Y++,--j;);de.strstart=Y,de.lookahead=F-1,Be(de)}return de.strstart+=de.lookahead,de.block_start=de.strstart,de.insert=de.lookahead,de.lookahead=0,de.match_length=de.prev_length=F-1,de.match_available=0,S.next_in=pe,S.input=$,S.avail_in=J,de.wrap=H,E},u.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(i,l,u){l.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(i,l,u){l.exports=function(f,c){var d,p,g,A,m,y,E,C,x,w,v,D,B,z,P,N,Z,ie,F,K,re,Q,q,I,ue;d=f.state,p=f.next_in,I=f.input,g=p+(f.avail_in-5),A=f.next_out,ue=f.output,m=A-(c-f.avail_out),y=A+(f.avail_out-257),E=d.dmax,C=d.wsize,x=d.whave,w=d.wnext,v=d.window,D=d.hold,B=d.bits,z=d.lencode,P=d.distcode,N=(1<<d.lenbits)-1,Z=(1<<d.distbits)-1;e:do{B<15&&(D+=I[p++]<<B,B+=8,D+=I[p++]<<B,B+=8),ie=z[D&N];t:for(;;){if(D>>>=F=ie>>>24,B-=F,(F=ie>>>16&255)===0)ue[A++]=65535&ie;else{if(!(16&F)){if((64&F)==0){ie=z[(65535&ie)+(D&(1<<F)-1)];continue t}if(32&F){d.mode=12;break e}f.msg="invalid literal/length code",d.mode=30;break e}K=65535&ie,(F&=15)&&(B<F&&(D+=I[p++]<<B,B+=8),K+=D&(1<<F)-1,D>>>=F,B-=F),B<15&&(D+=I[p++]<<B,B+=8,D+=I[p++]<<B,B+=8),ie=P[D&Z];n:for(;;){if(D>>>=F=ie>>>24,B-=F,!(16&(F=ie>>>16&255))){if((64&F)==0){ie=P[(65535&ie)+(D&(1<<F)-1)];continue n}f.msg="invalid distance code",d.mode=30;break e}if(re=65535&ie,B<(F&=15)&&(D+=I[p++]<<B,(B+=8)<F&&(D+=I[p++]<<B,B+=8)),E<(re+=D&(1<<F)-1)){f.msg="invalid distance too far back",d.mode=30;break e}if(D>>>=F,B-=F,(F=A-m)<re){if(x<(F=re-F)&&d.sane){f.msg="invalid distance too far back",d.mode=30;break e}if(q=v,(Q=0)===w){if(Q+=C-F,F<K){for(K-=F;ue[A++]=v[Q++],--F;);Q=A-re,q=ue}}else if(w<F){if(Q+=C+w-F,(F-=w)<K){for(K-=F;ue[A++]=v[Q++],--F;);if(Q=0,w<K){for(K-=F=w;ue[A++]=v[Q++],--F;);Q=A-re,q=ue}}}else if(Q+=w-F,F<K){for(K-=F;ue[A++]=v[Q++],--F;);Q=A-re,q=ue}for(;2<K;)ue[A++]=q[Q++],ue[A++]=q[Q++],ue[A++]=q[Q++],K-=3;K&&(ue[A++]=q[Q++],1<K&&(ue[A++]=q[Q++]))}else{for(Q=A-re;ue[A++]=ue[Q++],ue[A++]=ue[Q++],ue[A++]=ue[Q++],2<(K-=3););K&&(ue[A++]=ue[Q++],1<K&&(ue[A++]=ue[Q++]))}break}}break}}while(p<g&&A<y);p-=K=B>>3,D&=(1<<(B-=K<<3))-1,f.next_in=p,f.next_out=A,f.avail_in=p<g?g-p+5:5-(p-g),f.avail_out=A<y?y-A+257:257-(A-y),d.hold=D,d.bits=B}},{}],49:[function(i,l,u){var f=i("../utils/common"),c=i("./adler32"),d=i("./crc32"),p=i("./inffast"),g=i("./inftrees"),A=1,m=2,y=0,E=-2,C=1,x=852,w=592;function v(Q){return(Q>>>24&255)+(Q>>>8&65280)+((65280&Q)<<8)+((255&Q)<<24)}function D(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new f.Buf16(320),this.work=new f.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function B(Q){var q;return Q&&Q.state?(q=Q.state,Q.total_in=Q.total_out=q.total=0,Q.msg="",q.wrap&&(Q.adler=1&q.wrap),q.mode=C,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new f.Buf32(x),q.distcode=q.distdyn=new f.Buf32(w),q.sane=1,q.back=-1,y):E}function z(Q){var q;return Q&&Q.state?((q=Q.state).wsize=0,q.whave=0,q.wnext=0,B(Q)):E}function P(Q,q){var I,ue;return Q&&Q.state?(ue=Q.state,q<0?(I=0,q=-q):(I=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?E:(ue.window!==null&&ue.wbits!==q&&(ue.window=null),ue.wrap=I,ue.wbits=q,z(Q))):E}function N(Q,q){var I,ue;return Q?(ue=new D,(Q.state=ue).window=null,(I=P(Q,q))!==y&&(Q.state=null),I):E}var Z,ie,F=!0;function K(Q){if(F){var q;for(Z=new f.Buf32(512),ie=new f.Buf32(32),q=0;q<144;)Q.lens[q++]=8;for(;q<256;)Q.lens[q++]=9;for(;q<280;)Q.lens[q++]=7;for(;q<288;)Q.lens[q++]=8;for(g(A,Q.lens,0,288,Z,0,Q.work,{bits:9}),q=0;q<32;)Q.lens[q++]=5;g(m,Q.lens,0,32,ie,0,Q.work,{bits:5}),F=!1}Q.lencode=Z,Q.lenbits=9,Q.distcode=ie,Q.distbits=5}function re(Q,q,I,ue){var fe,ce=Q.state;return ce.window===null&&(ce.wsize=1<<ce.wbits,ce.wnext=0,ce.whave=0,ce.window=new f.Buf8(ce.wsize)),ue>=ce.wsize?(f.arraySet(ce.window,q,I-ce.wsize,ce.wsize,0),ce.wnext=0,ce.whave=ce.wsize):(ue<(fe=ce.wsize-ce.wnext)&&(fe=ue),f.arraySet(ce.window,q,I-ue,fe,ce.wnext),(ue-=fe)?(f.arraySet(ce.window,q,I-ue,ue,0),ce.wnext=ue,ce.whave=ce.wsize):(ce.wnext+=fe,ce.wnext===ce.wsize&&(ce.wnext=0),ce.whave<ce.wsize&&(ce.whave+=fe))),0}u.inflateReset=z,u.inflateReset2=P,u.inflateResetKeep=B,u.inflateInit=function(Q){return N(Q,15)},u.inflateInit2=N,u.inflate=function(Q,q){var I,ue,fe,ce,le,ne,T,_,V,U,he,be,Be,Ke,Ue,Fe,We,rt,Ct,Mt,S,ge,de,Y,j=0,H=new f.Buf8(4),J=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!Q||!Q.state||!Q.output||!Q.input&&Q.avail_in!==0)return E;(I=Q.state).mode===12&&(I.mode=13),le=Q.next_out,fe=Q.output,T=Q.avail_out,ce=Q.next_in,ue=Q.input,ne=Q.avail_in,_=I.hold,V=I.bits,U=ne,he=T,ge=y;e:for(;;)switch(I.mode){case C:if(I.wrap===0){I.mode=13;break}for(;V<16;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(2&I.wrap&&_===35615){H[I.check=0]=255&_,H[1]=_>>>8&255,I.check=d(I.check,H,2,0),V=_=0,I.mode=2;break}if(I.flags=0,I.head&&(I.head.done=!1),!(1&I.wrap)||(((255&_)<<8)+(_>>8))%31){Q.msg="incorrect header check",I.mode=30;break}if((15&_)!=8){Q.msg="unknown compression method",I.mode=30;break}if(V-=4,S=8+(15&(_>>>=4)),I.wbits===0)I.wbits=S;else if(S>I.wbits){Q.msg="invalid window size",I.mode=30;break}I.dmax=1<<S,Q.adler=I.check=1,I.mode=512&_?10:12,V=_=0;break;case 2:for(;V<16;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(I.flags=_,(255&I.flags)!=8){Q.msg="unknown compression method",I.mode=30;break}if(57344&I.flags){Q.msg="unknown header flags set",I.mode=30;break}I.head&&(I.head.text=_>>8&1),512&I.flags&&(H[0]=255&_,H[1]=_>>>8&255,I.check=d(I.check,H,2,0)),V=_=0,I.mode=3;case 3:for(;V<32;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.head&&(I.head.time=_),512&I.flags&&(H[0]=255&_,H[1]=_>>>8&255,H[2]=_>>>16&255,H[3]=_>>>24&255,I.check=d(I.check,H,4,0)),V=_=0,I.mode=4;case 4:for(;V<16;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.head&&(I.head.xflags=255&_,I.head.os=_>>8),512&I.flags&&(H[0]=255&_,H[1]=_>>>8&255,I.check=d(I.check,H,2,0)),V=_=0,I.mode=5;case 5:if(1024&I.flags){for(;V<16;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.length=_,I.head&&(I.head.extra_len=_),512&I.flags&&(H[0]=255&_,H[1]=_>>>8&255,I.check=d(I.check,H,2,0)),V=_=0}else I.head&&(I.head.extra=null);I.mode=6;case 6:if(1024&I.flags&&(ne<(be=I.length)&&(be=ne),be&&(I.head&&(S=I.head.extra_len-I.length,I.head.extra||(I.head.extra=new Array(I.head.extra_len)),f.arraySet(I.head.extra,ue,ce,be,S)),512&I.flags&&(I.check=d(I.check,ue,be,ce)),ne-=be,ce+=be,I.length-=be),I.length))break e;I.length=0,I.mode=7;case 7:if(2048&I.flags){if(ne===0)break e;for(be=0;S=ue[ce+be++],I.head&&S&&I.length<65536&&(I.head.name+=String.fromCharCode(S)),S&&be<ne;);if(512&I.flags&&(I.check=d(I.check,ue,be,ce)),ne-=be,ce+=be,S)break e}else I.head&&(I.head.name=null);I.length=0,I.mode=8;case 8:if(4096&I.flags){if(ne===0)break e;for(be=0;S=ue[ce+be++],I.head&&S&&I.length<65536&&(I.head.comment+=String.fromCharCode(S)),S&&be<ne;);if(512&I.flags&&(I.check=d(I.check,ue,be,ce)),ne-=be,ce+=be,S)break e}else I.head&&(I.head.comment=null);I.mode=9;case 9:if(512&I.flags){for(;V<16;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(_!==(65535&I.check)){Q.msg="header crc mismatch",I.mode=30;break}V=_=0}I.head&&(I.head.hcrc=I.flags>>9&1,I.head.done=!0),Q.adler=I.check=0,I.mode=12;break;case 10:for(;V<32;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}Q.adler=I.check=v(_),V=_=0,I.mode=11;case 11:if(I.havedict===0)return Q.next_out=le,Q.avail_out=T,Q.next_in=ce,Q.avail_in=ne,I.hold=_,I.bits=V,2;Q.adler=I.check=1,I.mode=12;case 12:if(q===5||q===6)break e;case 13:if(I.last){_>>>=7&V,V-=7&V,I.mode=27;break}for(;V<3;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}switch(I.last=1&_,V-=1,3&(_>>>=1)){case 0:I.mode=14;break;case 1:if(K(I),I.mode=20,q!==6)break;_>>>=2,V-=2;break e;case 2:I.mode=17;break;case 3:Q.msg="invalid block type",I.mode=30}_>>>=2,V-=2;break;case 14:for(_>>>=7&V,V-=7&V;V<32;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if((65535&_)!=(_>>>16^65535)){Q.msg="invalid stored block lengths",I.mode=30;break}if(I.length=65535&_,V=_=0,I.mode=15,q===6)break e;case 15:I.mode=16;case 16:if(be=I.length){if(ne<be&&(be=ne),T<be&&(be=T),be===0)break e;f.arraySet(fe,ue,ce,be,le),ne-=be,ce+=be,T-=be,le+=be,I.length-=be;break}I.mode=12;break;case 17:for(;V<14;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(I.nlen=257+(31&_),_>>>=5,V-=5,I.ndist=1+(31&_),_>>>=5,V-=5,I.ncode=4+(15&_),_>>>=4,V-=4,286<I.nlen||30<I.ndist){Q.msg="too many length or distance symbols",I.mode=30;break}I.have=0,I.mode=18;case 18:for(;I.have<I.ncode;){for(;V<3;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.lens[J[I.have++]]=7&_,_>>>=3,V-=3}for(;I.have<19;)I.lens[J[I.have++]]=0;if(I.lencode=I.lendyn,I.lenbits=7,de={bits:I.lenbits},ge=g(0,I.lens,0,19,I.lencode,0,I.work,de),I.lenbits=de.bits,ge){Q.msg="invalid code lengths set",I.mode=30;break}I.have=0,I.mode=19;case 19:for(;I.have<I.nlen+I.ndist;){for(;Fe=(j=I.lencode[_&(1<<I.lenbits)-1])>>>16&255,We=65535&j,!((Ue=j>>>24)<=V);){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(We<16)_>>>=Ue,V-=Ue,I.lens[I.have++]=We;else{if(We===16){for(Y=Ue+2;V<Y;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(_>>>=Ue,V-=Ue,I.have===0){Q.msg="invalid bit length repeat",I.mode=30;break}S=I.lens[I.have-1],be=3+(3&_),_>>>=2,V-=2}else if(We===17){for(Y=Ue+3;V<Y;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}V-=Ue,S=0,be=3+(7&(_>>>=Ue)),_>>>=3,V-=3}else{for(Y=Ue+7;V<Y;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}V-=Ue,S=0,be=11+(127&(_>>>=Ue)),_>>>=7,V-=7}if(I.have+be>I.nlen+I.ndist){Q.msg="invalid bit length repeat",I.mode=30;break}for(;be--;)I.lens[I.have++]=S}}if(I.mode===30)break;if(I.lens[256]===0){Q.msg="invalid code -- missing end-of-block",I.mode=30;break}if(I.lenbits=9,de={bits:I.lenbits},ge=g(A,I.lens,0,I.nlen,I.lencode,0,I.work,de),I.lenbits=de.bits,ge){Q.msg="invalid literal/lengths set",I.mode=30;break}if(I.distbits=6,I.distcode=I.distdyn,de={bits:I.distbits},ge=g(m,I.lens,I.nlen,I.ndist,I.distcode,0,I.work,de),I.distbits=de.bits,ge){Q.msg="invalid distances set",I.mode=30;break}if(I.mode=20,q===6)break e;case 20:I.mode=21;case 21:if(6<=ne&&258<=T){Q.next_out=le,Q.avail_out=T,Q.next_in=ce,Q.avail_in=ne,I.hold=_,I.bits=V,p(Q,he),le=Q.next_out,fe=Q.output,T=Q.avail_out,ce=Q.next_in,ue=Q.input,ne=Q.avail_in,_=I.hold,V=I.bits,I.mode===12&&(I.back=-1);break}for(I.back=0;Fe=(j=I.lencode[_&(1<<I.lenbits)-1])>>>16&255,We=65535&j,!((Ue=j>>>24)<=V);){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(Fe&&(240&Fe)==0){for(rt=Ue,Ct=Fe,Mt=We;Fe=(j=I.lencode[Mt+((_&(1<<rt+Ct)-1)>>rt)])>>>16&255,We=65535&j,!(rt+(Ue=j>>>24)<=V);){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}_>>>=rt,V-=rt,I.back+=rt}if(_>>>=Ue,V-=Ue,I.back+=Ue,I.length=We,Fe===0){I.mode=26;break}if(32&Fe){I.back=-1,I.mode=12;break}if(64&Fe){Q.msg="invalid literal/length code",I.mode=30;break}I.extra=15&Fe,I.mode=22;case 22:if(I.extra){for(Y=I.extra;V<Y;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.length+=_&(1<<I.extra)-1,_>>>=I.extra,V-=I.extra,I.back+=I.extra}I.was=I.length,I.mode=23;case 23:for(;Fe=(j=I.distcode[_&(1<<I.distbits)-1])>>>16&255,We=65535&j,!((Ue=j>>>24)<=V);){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if((240&Fe)==0){for(rt=Ue,Ct=Fe,Mt=We;Fe=(j=I.distcode[Mt+((_&(1<<rt+Ct)-1)>>rt)])>>>16&255,We=65535&j,!(rt+(Ue=j>>>24)<=V);){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}_>>>=rt,V-=rt,I.back+=rt}if(_>>>=Ue,V-=Ue,I.back+=Ue,64&Fe){Q.msg="invalid distance code",I.mode=30;break}I.offset=We,I.extra=15&Fe,I.mode=24;case 24:if(I.extra){for(Y=I.extra;V<Y;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}I.offset+=_&(1<<I.extra)-1,_>>>=I.extra,V-=I.extra,I.back+=I.extra}if(I.offset>I.dmax){Q.msg="invalid distance too far back",I.mode=30;break}I.mode=25;case 25:if(T===0)break e;if(be=he-T,I.offset>be){if((be=I.offset-be)>I.whave&&I.sane){Q.msg="invalid distance too far back",I.mode=30;break}Be=be>I.wnext?(be-=I.wnext,I.wsize-be):I.wnext-be,be>I.length&&(be=I.length),Ke=I.window}else Ke=fe,Be=le-I.offset,be=I.length;for(T<be&&(be=T),T-=be,I.length-=be;fe[le++]=Ke[Be++],--be;);I.length===0&&(I.mode=21);break;case 26:if(T===0)break e;fe[le++]=I.length,T--,I.mode=21;break;case 27:if(I.wrap){for(;V<32;){if(ne===0)break e;ne--,_|=ue[ce++]<<V,V+=8}if(he-=T,Q.total_out+=he,I.total+=he,he&&(Q.adler=I.check=I.flags?d(I.check,fe,he,le-he):c(I.check,fe,he,le-he)),he=T,(I.flags?_:v(_))!==I.check){Q.msg="incorrect data check",I.mode=30;break}V=_=0}I.mode=28;case 28:if(I.wrap&&I.flags){for(;V<32;){if(ne===0)break e;ne--,_+=ue[ce++]<<V,V+=8}if(_!==(4294967295&I.total)){Q.msg="incorrect length check",I.mode=30;break}V=_=0}I.mode=29;case 29:ge=1;break e;case 30:ge=-3;break e;case 31:return-4;case 32:default:return E}return Q.next_out=le,Q.avail_out=T,Q.next_in=ce,Q.avail_in=ne,I.hold=_,I.bits=V,(I.wsize||he!==Q.avail_out&&I.mode<30&&(I.mode<27||q!==4))&&re(Q,Q.output,Q.next_out,he-Q.avail_out)?(I.mode=31,-4):(U-=Q.avail_in,he-=Q.avail_out,Q.total_in+=U,Q.total_out+=he,I.total+=he,I.wrap&&he&&(Q.adler=I.check=I.flags?d(I.check,fe,he,Q.next_out-he):c(I.check,fe,he,Q.next_out-he)),Q.data_type=I.bits+(I.last?64:0)+(I.mode===12?128:0)+(I.mode===20||I.mode===15?256:0),(U==0&&he===0||q===4)&&ge===y&&(ge=-5),ge)},u.inflateEnd=function(Q){if(!Q||!Q.state)return E;var q=Q.state;return q.window&&(q.window=null),Q.state=null,y},u.inflateGetHeader=function(Q,q){var I;return Q&&Q.state?(2&(I=Q.state).wrap)==0?E:((I.head=q).done=!1,y):E},u.inflateSetDictionary=function(Q,q){var I,ue=q.length;return Q&&Q.state?(I=Q.state).wrap!==0&&I.mode!==11?E:I.mode===11&&c(1,q,ue,0)!==I.check?-3:re(Q,q,ue,ue)?(I.mode=31,-4):(I.havedict=1,y):E},u.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(i,l,u){var f=i("../utils/common"),c=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],d=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],p=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],g=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];l.exports=function(A,m,y,E,C,x,w,v){var D,B,z,P,N,Z,ie,F,K,re=v.bits,Q=0,q=0,I=0,ue=0,fe=0,ce=0,le=0,ne=0,T=0,_=0,V=null,U=0,he=new f.Buf16(16),be=new f.Buf16(16),Be=null,Ke=0;for(Q=0;Q<=15;Q++)he[Q]=0;for(q=0;q<E;q++)he[m[y+q]]++;for(fe=re,ue=15;1<=ue&&he[ue]===0;ue--);if(ue<fe&&(fe=ue),ue===0)return C[x++]=20971520,C[x++]=20971520,v.bits=1,0;for(I=1;I<ue&&he[I]===0;I++);for(fe<I&&(fe=I),Q=ne=1;Q<=15;Q++)if(ne<<=1,(ne-=he[Q])<0)return-1;if(0<ne&&(A===0||ue!==1))return-1;for(be[1]=0,Q=1;Q<15;Q++)be[Q+1]=be[Q]+he[Q];for(q=0;q<E;q++)m[y+q]!==0&&(w[be[m[y+q]]++]=q);if(Z=A===0?(V=Be=w,19):A===1?(V=c,U-=257,Be=d,Ke-=257,256):(V=p,Be=g,-1),Q=I,N=x,le=q=_=0,z=-1,P=(T=1<<(ce=fe))-1,A===1&&852<T||A===2&&592<T)return 1;for(;;){for(ie=Q-le,K=w[q]<Z?(F=0,w[q]):w[q]>Z?(F=Be[Ke+w[q]],V[U+w[q]]):(F=96,0),D=1<<Q-le,I=B=1<<ce;C[N+(_>>le)+(B-=D)]=ie<<24|F<<16|K|0,B!==0;);for(D=1<<Q-1;_&D;)D>>=1;if(D!==0?(_&=D-1,_+=D):_=0,q++,--he[Q]==0){if(Q===ue)break;Q=m[y+w[q]]}if(fe<Q&&(_&P)!==z){for(le===0&&(le=fe),N+=I,ne=1<<(ce=Q-le);ce+le<ue&&!((ne-=he[ce+le])<=0);)ce++,ne<<=1;if(T+=1<<ce,A===1&&852<T||A===2&&592<T)return 1;C[z=_&P]=fe<<24|ce<<16|N-x|0}}return _!==0&&(C[N+_]=Q-le<<24|4194304|0),v.bits=fe,0}},{"../utils/common":41}],51:[function(i,l,u){l.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(i,l,u){var f=i("../utils/common"),c=0,d=1;function p(j){for(var H=j.length;0<=--H;)j[H]=0}var g=0,A=29,m=256,y=m+1+A,E=30,C=19,x=2*y+1,w=15,v=16,D=7,B=256,z=16,P=17,N=18,Z=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ie=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],F=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],K=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],re=new Array(2*(y+2));p(re);var Q=new Array(2*E);p(Q);var q=new Array(512);p(q);var I=new Array(256);p(I);var ue=new Array(A);p(ue);var fe,ce,le,ne=new Array(E);function T(j,H,J,pe,$){this.static_tree=j,this.extra_bits=H,this.extra_base=J,this.elems=pe,this.max_length=$,this.has_stree=j&&j.length}function _(j,H){this.dyn_tree=j,this.max_code=0,this.stat_desc=H}function V(j){return j<256?q[j]:q[256+(j>>>7)]}function U(j,H){j.pending_buf[j.pending++]=255&H,j.pending_buf[j.pending++]=H>>>8&255}function he(j,H,J){j.bi_valid>v-J?(j.bi_buf|=H<<j.bi_valid&65535,U(j,j.bi_buf),j.bi_buf=H>>v-j.bi_valid,j.bi_valid+=J-v):(j.bi_buf|=H<<j.bi_valid&65535,j.bi_valid+=J)}function be(j,H,J){he(j,J[2*H],J[2*H+1])}function Be(j,H){for(var J=0;J|=1&j,j>>>=1,J<<=1,0<--H;);return J>>>1}function Ke(j,H,J){var pe,$,ye=new Array(w+1),Re=0;for(pe=1;pe<=w;pe++)ye[pe]=Re=Re+J[pe-1]<<1;for($=0;$<=H;$++){var ke=j[2*$+1];ke!==0&&(j[2*$]=Be(ye[ke]++,ke))}}function Ue(j){var H;for(H=0;H<y;H++)j.dyn_ltree[2*H]=0;for(H=0;H<E;H++)j.dyn_dtree[2*H]=0;for(H=0;H<C;H++)j.bl_tree[2*H]=0;j.dyn_ltree[2*B]=1,j.opt_len=j.static_len=0,j.last_lit=j.matches=0}function Fe(j){8<j.bi_valid?U(j,j.bi_buf):0<j.bi_valid&&(j.pending_buf[j.pending++]=j.bi_buf),j.bi_buf=0,j.bi_valid=0}function We(j,H,J,pe){var $=2*H,ye=2*J;return j[$]<j[ye]||j[$]===j[ye]&&pe[H]<=pe[J]}function rt(j,H,J){for(var pe=j.heap[J],$=J<<1;$<=j.heap_len&&($<j.heap_len&&We(H,j.heap[$+1],j.heap[$],j.depth)&&$++,!We(H,pe,j.heap[$],j.depth));)j.heap[J]=j.heap[$],J=$,$<<=1;j.heap[J]=pe}function Ct(j,H,J){var pe,$,ye,Re,ke=0;if(j.last_lit!==0)for(;pe=j.pending_buf[j.d_buf+2*ke]<<8|j.pending_buf[j.d_buf+2*ke+1],$=j.pending_buf[j.l_buf+ke],ke++,pe===0?be(j,$,H):(be(j,(ye=I[$])+m+1,H),(Re=Z[ye])!==0&&he(j,$-=ue[ye],Re),be(j,ye=V(--pe),J),(Re=ie[ye])!==0&&he(j,pe-=ne[ye],Re)),ke<j.last_lit;);be(j,B,H)}function Mt(j,H){var J,pe,$,ye=H.dyn_tree,Re=H.stat_desc.static_tree,ke=H.stat_desc.has_stree,te=H.stat_desc.elems,ee=-1;for(j.heap_len=0,j.heap_max=x,J=0;J<te;J++)ye[2*J]!==0?(j.heap[++j.heap_len]=ee=J,j.depth[J]=0):ye[2*J+1]=0;for(;j.heap_len<2;)ye[2*($=j.heap[++j.heap_len]=ee<2?++ee:0)]=1,j.depth[$]=0,j.opt_len--,ke&&(j.static_len-=Re[2*$+1]);for(H.max_code=ee,J=j.heap_len>>1;1<=J;J--)rt(j,ye,J);for($=te;J=j.heap[1],j.heap[1]=j.heap[j.heap_len--],rt(j,ye,1),pe=j.heap[1],j.heap[--j.heap_max]=J,j.heap[--j.heap_max]=pe,ye[2*$]=ye[2*J]+ye[2*pe],j.depth[$]=(j.depth[J]>=j.depth[pe]?j.depth[J]:j.depth[pe])+1,ye[2*J+1]=ye[2*pe+1]=$,j.heap[1]=$++,rt(j,ye,1),2<=j.heap_len;);j.heap[--j.heap_max]=j.heap[1],function(we,Oe){var Ge,tt,st,Xe,Rt,ht,yt=Oe.dyn_tree,M=Oe.max_code,se=Oe.stat_desc.static_tree,Me=Oe.stat_desc.has_stree,Ne=Oe.stat_desc.extra_bits,Ye=Oe.stat_desc.extra_base,ot=Oe.stat_desc.max_length,it=0;for(Xe=0;Xe<=w;Xe++)we.bl_count[Xe]=0;for(yt[2*we.heap[we.heap_max]+1]=0,Ge=we.heap_max+1;Ge<x;Ge++)ot<(Xe=yt[2*yt[2*(tt=we.heap[Ge])+1]+1]+1)&&(Xe=ot,it++),yt[2*tt+1]=Xe,M<tt||(we.bl_count[Xe]++,Rt=0,Ye<=tt&&(Rt=Ne[tt-Ye]),ht=yt[2*tt],we.opt_len+=ht*(Xe+Rt),Me&&(we.static_len+=ht*(se[2*tt+1]+Rt)));if(it!==0){do{for(Xe=ot-1;we.bl_count[Xe]===0;)Xe--;we.bl_count[Xe]--,we.bl_count[Xe+1]+=2,we.bl_count[ot]--,it-=2}while(0<it);for(Xe=ot;Xe!==0;Xe--)for(tt=we.bl_count[Xe];tt!==0;)M<(st=we.heap[--Ge])||(yt[2*st+1]!==Xe&&(we.opt_len+=(Xe-yt[2*st+1])*yt[2*st],yt[2*st+1]=Xe),tt--)}}(j,H),Ke(ye,ee,j.bl_count)}function S(j,H,J){var pe,$,ye=-1,Re=H[1],ke=0,te=7,ee=4;for(Re===0&&(te=138,ee=3),H[2*(J+1)+1]=65535,pe=0;pe<=J;pe++)$=Re,Re=H[2*(pe+1)+1],++ke<te&&$===Re||(ke<ee?j.bl_tree[2*$]+=ke:$!==0?($!==ye&&j.bl_tree[2*$]++,j.bl_tree[2*z]++):ke<=10?j.bl_tree[2*P]++:j.bl_tree[2*N]++,ye=$,ee=(ke=0)===Re?(te=138,3):$===Re?(te=6,3):(te=7,4))}function ge(j,H,J){var pe,$,ye=-1,Re=H[1],ke=0,te=7,ee=4;for(Re===0&&(te=138,ee=3),pe=0;pe<=J;pe++)if($=Re,Re=H[2*(pe+1)+1],!(++ke<te&&$===Re)){if(ke<ee)for(;be(j,$,j.bl_tree),--ke!=0;);else $!==0?($!==ye&&(be(j,$,j.bl_tree),ke--),be(j,z,j.bl_tree),he(j,ke-3,2)):ke<=10?(be(j,P,j.bl_tree),he(j,ke-3,3)):(be(j,N,j.bl_tree),he(j,ke-11,7));ye=$,ee=(ke=0)===Re?(te=138,3):$===Re?(te=6,3):(te=7,4)}}p(ne);var de=!1;function Y(j,H,J,pe){he(j,(g<<1)+(pe?1:0),3),function($,ye,Re,ke){Fe($),U($,Re),U($,~Re),f.arraySet($.pending_buf,$.window,ye,Re,$.pending),$.pending+=Re}(j,H,J)}u._tr_init=function(j){de||(function(){var H,J,pe,$,ye,Re=new Array(w+1);for($=pe=0;$<A-1;$++)for(ue[$]=pe,H=0;H<1<<Z[$];H++)I[pe++]=$;for(I[pe-1]=$,$=ye=0;$<16;$++)for(ne[$]=ye,H=0;H<1<<ie[$];H++)q[ye++]=$;for(ye>>=7;$<E;$++)for(ne[$]=ye<<7,H=0;H<1<<ie[$]-7;H++)q[256+ye++]=$;for(J=0;J<=w;J++)Re[J]=0;for(H=0;H<=143;)re[2*H+1]=8,H++,Re[8]++;for(;H<=255;)re[2*H+1]=9,H++,Re[9]++;for(;H<=279;)re[2*H+1]=7,H++,Re[7]++;for(;H<=287;)re[2*H+1]=8,H++,Re[8]++;for(Ke(re,y+1,Re),H=0;H<E;H++)Q[2*H+1]=5,Q[2*H]=Be(H,5);fe=new T(re,Z,m+1,y,w),ce=new T(Q,ie,0,E,w),le=new T(new Array(0),F,0,C,D)}(),de=!0),j.l_desc=new _(j.dyn_ltree,fe),j.d_desc=new _(j.dyn_dtree,ce),j.bl_desc=new _(j.bl_tree,le),j.bi_buf=0,j.bi_valid=0,Ue(j)},u._tr_stored_block=Y,u._tr_flush_block=function(j,H,J,pe){var $,ye,Re=0;0<j.level?(j.strm.data_type===2&&(j.strm.data_type=function(ke){var te,ee=4093624447;for(te=0;te<=31;te++,ee>>>=1)if(1&ee&&ke.dyn_ltree[2*te]!==0)return c;if(ke.dyn_ltree[18]!==0||ke.dyn_ltree[20]!==0||ke.dyn_ltree[26]!==0)return d;for(te=32;te<m;te++)if(ke.dyn_ltree[2*te]!==0)return d;return c}(j)),Mt(j,j.l_desc),Mt(j,j.d_desc),Re=function(ke){var te;for(S(ke,ke.dyn_ltree,ke.l_desc.max_code),S(ke,ke.dyn_dtree,ke.d_desc.max_code),Mt(ke,ke.bl_desc),te=C-1;3<=te&&ke.bl_tree[2*K[te]+1]===0;te--);return ke.opt_len+=3*(te+1)+5+5+4,te}(j),$=j.opt_len+3+7>>>3,(ye=j.static_len+3+7>>>3)<=$&&($=ye)):$=ye=J+5,J+4<=$&&H!==-1?Y(j,H,J,pe):j.strategy===4||ye===$?(he(j,2+(pe?1:0),3),Ct(j,re,Q)):(he(j,4+(pe?1:0),3),function(ke,te,ee,we){var Oe;for(he(ke,te-257,5),he(ke,ee-1,5),he(ke,we-4,4),Oe=0;Oe<we;Oe++)he(ke,ke.bl_tree[2*K[Oe]+1],3);ge(ke,ke.dyn_ltree,te-1),ge(ke,ke.dyn_dtree,ee-1)}(j,j.l_desc.max_code+1,j.d_desc.max_code+1,Re+1),Ct(j,j.dyn_ltree,j.dyn_dtree)),Ue(j),pe&&Fe(j)},u._tr_tally=function(j,H,J){return j.pending_buf[j.d_buf+2*j.last_lit]=H>>>8&255,j.pending_buf[j.d_buf+2*j.last_lit+1]=255&H,j.pending_buf[j.l_buf+j.last_lit]=255&J,j.last_lit++,H===0?j.dyn_ltree[2*J]++:(j.matches++,H--,j.dyn_ltree[2*(I[J]+m+1)]++,j.dyn_dtree[2*V(H)]++),j.last_lit===j.lit_bufsize-1},u._tr_align=function(j){he(j,2,3),be(j,B,re),function(H){H.bi_valid===16?(U(H,H.bi_buf),H.bi_buf=0,H.bi_valid=0):8<=H.bi_valid&&(H.pending_buf[H.pending++]=255&H.bi_buf,H.bi_buf>>=8,H.bi_valid-=8)}(j)}},{"../utils/common":41}],53:[function(i,l,u){l.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(i,l,u){(function(f){(function(c,d){if(!c.setImmediate){var p,g,A,m,y=1,E={},C=!1,x=c.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(c);w=w&&w.setTimeout?w:c,p={}.toString.call(c.process)==="[object process]"?function(z){process.nextTick(function(){D(z)})}:function(){if(c.postMessage&&!c.importScripts){var z=!0,P=c.onmessage;return c.onmessage=function(){z=!1},c.postMessage("","*"),c.onmessage=P,z}}()?(m="setImmediate$"+Math.random()+"$",c.addEventListener?c.addEventListener("message",B,!1):c.attachEvent("onmessage",B),function(z){c.postMessage(m+z,"*")}):c.MessageChannel?((A=new MessageChannel).port1.onmessage=function(z){D(z.data)},function(z){A.port2.postMessage(z)}):x&&"onreadystatechange"in x.createElement("script")?(g=x.documentElement,function(z){var P=x.createElement("script");P.onreadystatechange=function(){D(z),P.onreadystatechange=null,g.removeChild(P),P=null},g.appendChild(P)}):function(z){setTimeout(D,0,z)},w.setImmediate=function(z){typeof z!="function"&&(z=new Function(""+z));for(var P=new Array(arguments.length-1),N=0;N<P.length;N++)P[N]=arguments[N+1];var Z={callback:z,args:P};return E[y]=Z,p(y),y++},w.clearImmediate=v}function v(z){delete E[z]}function D(z){if(C)setTimeout(D,0,z);else{var P=E[z];if(P){C=!0;try{(function(N){var Z=N.callback,ie=N.args;switch(ie.length){case 0:Z();break;case 1:Z(ie[0]);break;case 2:Z(ie[0],ie[1]);break;case 3:Z(ie[0],ie[1],ie[2]);break;default:Z.apply(d,ie)}})(P)}finally{v(z),C=!1}}}}function B(z){z.source===c&&typeof z.data=="string"&&z.data.indexOf(m)===0&&D(+z.data.slice(m.length))}})(typeof self=="undefined"?f===void 0?this:f:self)}).call(this,typeof $t!="undefined"?$t:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}]},{},[10])(10)})}(Cd)),Cd.exports}var nI=tI();const rI=Gn(nI),iI=n=>et(null,null,function*(){const a=new rI;return n.forEach(l=>{a.file(l.name,l)}),yield a.generateAsync({type:"blob"})}),aI=(n,a)=>new File([n],a,{type:n.type}),py=n=>n.length>1,oI=n=>{var a;return py(n)?`uploaded_files_${Date.now()}.zip`:((a=n[0])==null?void 0:a.name)||"file"},lI=`${Yr.WEBSOCKET_URL}/ws/med-assist/session`;class sI{constructor(a){Gt(this,"ws",null);Gt(this,"config");Gt(this,"connectionState",Xn.DISCONNECTED);Gt(this,"reconnectAttempts",0);Gt(this,"maxConnectionAttempts",5);Gt(this,"maxReconnectAttempts",2);Gt(this,"connectionAttempts",0);Gt(this,"reconnectDelay",1e3);Gt(this,"eventCallbacks",new Map);Gt(this,"isReconnecting",!1);Gt(this,"pingInterval",null);Gt(this,"connectionTimeout",null);Gt(this,"currentStreamMessage",null);Gt(this,"pendingFileData",{files:[],message:"",format:void 0});var i,l,u;this.config={sessionId:a.sessionId,auth:a.auth,options:oe({connectAttempts:5,reconnectAttempts:5,reconnectDelay:1e3,pingInterval:3e4,connectionTimeout:5e3},a.options)},this.maxReconnectAttempts=((i=this.config.options)==null?void 0:i.reconnectAttempts)||5,this.maxConnectionAttempts=((l=this.config.options)==null?void 0:l.connectAttempts)||5,this.reconnectDelay=((u=this.config.options)==null?void 0:u.reconnectDelay)||1e3}connect(){return et(this,null,function*(){var a;try{if(this.isReconnecting||this.connectionState===Xn.CONNECTING){console.log("Connection already in progress, skipping from connect function");return}if(this.isConnected()){console.log("WebSocket is already connected");return}if(this.connectionAttempts>=this.maxConnectionAttempts){console.log("connection attempts exceeded",this.connectionAttempts),this.updateConnectionState(Xn.ERROR),this.triggerEvent(yn.MAX_CONNECTION_ATTEMPTS_EXCEEDED,new Error("connection attempts exceeded"));return}this.updateConnectionState(Xn.CONNECTING),this.isReconnecting=!0,this.connectionAttempts==2&&(yield this.checkSessionDetails()),this.connectionAttempts++;const i=`${lI}/${this.config.sessionId}/`;if(console.log("Connecting to WebSocket:",i,"with session ID:",this.config.sessionId),this.ws=new WebSocket(i),this.setupWebSocketHandlers(),this.connectionTimeout=setTimeout(()=>{if(this.connectionState===Xn.CONNECTING){if(console.log("Connection timeout",this.reconnectAttempts,this.maxReconnectAttempts),this.isReconnecting=!1,this.updateConnectionState(Xn.ERROR),this.reconnectAttempts>=this.maxReconnectAttempts){this.triggerEvent(yn.MAX_RECONNECTION_ATTEMPTS_EXCEEDED,new Error("Connection timeout after two retries"));return}this.cleanup(),this.triggerEvent(yn.CONNECTION_TIMEOUT_ERROR,new Error("Connection timeout"))}},((a=this.config.options)==null?void 0:a.connectionTimeout)||5e3),!this.ws)throw new Error("WebSocket not initialized")}catch(i){throw console.error("Failed to connect:",i),this.isReconnecting=!1,this.updateConnectionState(Xn.ERROR),this.triggerEvent(yn.CONNECTION_ERROR,i instanceof Error?i:new Error("Connection failed")),i}})}checkSessionDetails(){return et(this,null,function*(){try{this.isReconnecting=!1;const a=yield uy(this.config.sessionId);if(console.log("sessionDetails response",a),a)this.isReconnecting=!0;else{this.isReconnecting=!1,this.updateConnectionState(Xn.ERROR),this.triggerEvent(tn.CONNECTION_ESTABLISHED,!1),this.triggerEvent(yn.SESSION_INACTIVE,new Error(Ut.SESSION_INACTIVE.title)),this.triggerEvent(yn.START_NEW_SESSION,new Error("Session is invalid, starting new session")),this.cleanup();return}}catch(a){console.error("Error checking session details:",a),this.isReconnecting=!0}})}setupWebSocketHandlers(){this.ws&&(this.ws.onopen=()=>{console.log("WebSocket opened"),this.sendAuthMessage(),this.isReconnecting=!1,this.connectionAttempts=0,this.updateConnectionState(Xn.CONNECTED),this.startPingInterval()},this.ws.onmessage=a=>et(this,null,function*(){try{const i=JSON.parse(a.data);yield this.handleServerMessage(i)}catch(i){console.error("Failed to parse WebSocket message:",i)}}),this.ws.onclose=a=>{console.log("WebSocket closed:",a.code,a),this.handleConnectionClose(a)},this.ws.onerror=a=>{console.error("WebSocket error:",a),this.isReconnecting=!1,this.updateConnectionState(Xn.ERROR),this.triggerEvent(tn.ERROR,new Error("WebSocket error occurred"))})}handleServerMessage(a){return et(this,null,function*(){switch(a.ev){case tn.CONNECTION_ESTABLISHED:this.handleConnectionEstablished(a);break;case tn.CHAT:this.handleChatMessage(a);break;case tn.STREAM:this.handleStreamMessage(a);break;case tn.END_OF_STREAM:this.handleEndOfStreamMessage(a);break;case tn.PONG:this.handlePongMessage(a);break;case tn.SYNC:this.handleSyncMessage(a);break;case tn.ERROR:yield this.handleErrorMessage(a);break;default:console.warn("Unknown event type:",a.ev)}})}handleConnectionEstablished(a){this.triggerEvent(tn.CONNECTION_ESTABLISHED,!0)}handleChatMessage(a){console.log("Chat message received:",a),this.triggerEvent(tn.CHAT,a)}handleStreamMessage(a){var i;if(a.ct===en.TEXT&&a.data){if(a.data.progress_msg){this.triggerEvent("progress_message",a.data.progress_msg);return}a.data.text&&(this.currentStreamMessage||(this.currentStreamMessage={id:a._id,content:"",timestamp:new Date,type:"text",metadata:{isStreaming:!0}}),this.currentStreamMessage.content+=a.data.text,this.triggerEvent("stream_chunk",{content:this.currentStreamMessage.content,messageId:a._id}))}else a.ct===en.TIPS?(console.log("Tips message received:",a.data),(i=a.data.tips)!=null&&i.length&&this.triggerEvent(yn.TIPS,a.data.tips)):this.triggerEvent(tn.STREAM,a)}handleEndOfStreamMessage(a){a.ct===en.TEXT&&this.currentStreamMessage?(this.currentStreamMessage.metadata=ze(oe({},this.currentStreamMessage.metadata),{isStreaming:!1}),this.triggerEvent(tn.END_OF_STREAM,this.currentStreamMessage),this.currentStreamMessage=null):this.triggerEvent(tn.END_OF_STREAM,a)}handlePongMessage(a){this.triggerEvent(tn.PONG,a)}handleSyncMessage(a){this.triggerEvent(tn.SYNC,a)}handleErrorMessage(a){return et(this,null,function*(){this.triggerEvent(tn.ERROR,a)})}handleConnectionClose(a){if(this.cleanup(),this.updateConnectionState(Xn.DISCONNECTED),this.triggerEvent(tn.CONNECTION_ESTABLISHED,!1),a.code===1008){this.triggerEvent(yn.SESSION_EXPIRED,new Error(Ut.SESSION_EXPIRED.title));return}a.code!==1e3&&!this.isReconnecting&&a.code==1008&&this.attemptReconnect()}attemptReconnect(){if(this.isReconnecting){console.log("Reconnection already in progress, skipping from attemptReconnect function");return}console.log(`Attempting to reconnect (${this.connectionAttempts+1}/${this.maxConnectionAttempts})`),setTimeout(()=>{this.connect().catch(a=>{console.error("Reconnection failed from attemptReconnect function:",a)})},this.reconnectDelay)}sendChatMessage({message:a,tool_use_id:i,hidden:l,tool_use_params:u}){if(!this.isConnected())throw new Error("WebSocket not connected");const f={ev:Ua.CHAT,ct:en.TEXT,ts:Date.now(),_id:Date.now().toString(),data:oe(oe(oe({text:a},i&&{tool_use_id:i}),l&&{hidden:l}),u&&{tool_use_params:u})};this.sendMessage(f)}sendFileUploadRequest(){if(!this.isConnected())throw new Error("WebSocket is not connected");const a={ev:Ua.CHAT,ct:en.FILE,ts:Date.now(),_id:Date.now().toString(),data:{extension:this.pendingFileData.format}};this.sendMessage(a)}sendAuthMessage(){if(!this.isConnected())throw new Error("WebSocket is not connected");const a={ev:Ua.AUTH,_id:Date.now().toString(),ts:Date.now(),data:{token:this.config.auth.token}};this.sendMessage(a)}sendFileUploadComplete(a){var u;if(!this.isConnected())throw new Error("WebSocket is not connected");const i=(u=this.pendingFileData)==null?void 0:u.message,l={ev:Ua.CHAT,ct:en.FILE,ts:Date.now(),_id:Date.now().toString(),data:oe({url:a},i&&i.trim()&&{text:i.trim()})};this.sendMessage(l),this.clearPendingFiles()}setFilesForUpload(a,i){var f,c,d;const l=["application/pdf","image/jpeg","image/jpg"],u=a.filter(p=>l.includes(p.type))||[];this.pendingFileData.files=u,this.pendingFileData.format=u.length>1?"zip":((d=(c=(f=u[0].type)==null?void 0:f.split)==null?void 0:c.call(f,"/"))==null?void 0:d[1])||void 0,i!=null&&i.trim()&&(this.pendingFileData.message=i),console.log(`Set ${u.length} files for upload`)}clearPendingFiles(){this.pendingFileData.files=[],this.pendingFileData.message="",this.pendingFileData.format=void 0}clearStreamingState(){this.currentStreamMessage=null,console.log("Cleared streaming state")}reconnect(a,i){return et(this,null,function*(){if(!a&&this.isReconnecting){console.log("Reconnection already in progress, skipping");return}if(a&&(this.isReconnecting=!1,this.connectionAttempts=0),this.reconnectAttempts===this.maxReconnectAttempts){this.updateConnectionState(Xn.ERROR),this.triggerEvent(yn.MAX_RECONNECTION_ATTEMPTS_EXCEEDED,new Error("Maximum reconnection attempts exceeded"));return}this.reconnectAttempts++,console.log(`Initiating reconnection${i?` due to: ${i}`:""}...`),this.updateConnectionState(Xn.RECONNECTING);try{this.disconnect(),yield this.connect()}catch(l){console.error("Reconnection failed:",l),this.handleReconnectionError(l)}finally{this.isReconnecting=!1}})}handleReconnectionError(a){this.reconnectAttempts++,this.isReconnecting=!1,console.error("Reconnection error:",a),this.triggerEvent(yn.CONNECTION_ERROR,a),this.reconnectAttempts===this.maxReconnectAttempts?(this.updateConnectionState(Xn.ERROR),this.triggerEvent(yn.MAX_RECONNECTION_ATTEMPTS_EXCEEDED,new Error("Maximum reconnection attempts exceeded"))):this.attemptReconnect()}regenerateResponse(a){if(!this.isConnected())throw new Error("WebSocket is not connected");console.log("Regenerating response for:",a),this.clearStreamingState();const i={ev:Ua.CHAT,ct:en.TEXT,ts:Date.now(),_id:Date.now().toString(),data:{text:a}};this.sendMessage(i)}uploadFilesToPresignedUrl(a){return et(this,null,function*(){var u,f,c,d,p,g;console.log("hi from uploadFilesToPresignedUrl");let i=0;const l=a.filter(A=>A&&A.trim());try{if(l.length===0)throw new Error("No valid presigned URLs provided");console.log(`Uploading ${(f=(u=this.pendingFileData)==null?void 0:u.files)==null?void 0:f.length} files to ${a.length} presigned URL(s)`);let A,m;if(py(this.pendingFileData.files)){console.log("Multiple files detected, zipping before upload...");const y=yield iI(this.pendingFileData.files),E=oI(this.pendingFileData.files);A=aI(y,E),m="application/zip",console.log(`Zipped ${(d=(c=this.pendingFileData)==null?void 0:c.files)==null?void 0:d.length} files into ${E} (${(A.size/1024/1024).toFixed(2)} MB)`)}else A=(g=(p=this.pendingFileData)==null?void 0:p.files)==null?void 0:g[0],m=A.type,console.log(`Uploading single file: ${A.name} (${(A.size/1024/1024).toFixed(2)} MB)`);for(let y=0;y<l.length;y++){const E=l[y];console.log(`Uploading to URL ${y+1}/${l.length}: ${E}`);const C=yield fetch(E,{method:"PUT",body:A,headers:{"Content-Type":m,"x-ms-blob-type":"BlockBlob"}});if(!C.ok)throw new Error(`Failed to upload ${A.name} to URL ${y+1}: ${C.status} ${C.statusText}`);i++,console.log(`Successfully uploaded to URL ${y+1}/${l.length}`,C)}console.log("All file uploads completed successfully, calling sendFileUploadComplete"),this.sendFileUploadComplete(l[0])}catch(A){if(i>0){this.sendFileUploadComplete(l[0]);return}throw console.error("Error uploading files to presigned URL:",A),A}})}sendAudioData(a){if(!this.isConnected())throw new Error("WebSocket not connected");const i={ev:Ua.STREAM,ct:en.AUDIO,ts:Date.now(),_id:Date.now().toString(),data:{audio:a.audio,format:a.format}};console.log("Sending full audio data to backend:",i),this.sendMessage(i)}sendPing(){if(this.isConnected()){const a={ev:Ua.PING,ts:Date.now(),_id:Date.now().toString()};this.sendMessage(a)}}on(a,i){this.eventCallbacks.has(a)||this.eventCallbacks.set(a,new Set),this.eventCallbacks.get(a).add(i)}off(a,i){var l;i?(l=this.eventCallbacks.get(a))==null||l.delete(i):this.eventCallbacks.delete(a)}triggerEvent(a,i){const l=this.eventCallbacks.get(a);l&&l.forEach(u=>{try{u(i)}catch(f){console.error("Error in event callback:",f)}})}startPingInterval(){var a;this.pingInterval&&clearInterval(this.pingInterval),this.pingInterval=setInterval(()=>{this.sendPing()},((a=this.config.options)==null?void 0:a.pingInterval)||3e4)}isConnected(){var a;return((a=this.ws)==null?void 0:a.readyState)===WebSocket.OPEN}getConnectionState(){return this.connectionState}updateConfig(a){var i;a!=null&&a.sessionId&&(this.config.sessionId=a.sessionId),(i=a==null?void 0:a.auth)!=null&&i.token&&(this.config.auth.token=a.auth.token),console.log("WebSocket config updated:",this.config)}updateConnectionState(a){this.connectionState=a,console.log("Connection state updated:",a)}disconnect(){console.log("WebSocket disconnect called"),this.ws&&(this.ws.close(1e3,"Manual disconnect"),this.cleanup())}sendMessage(a){var i;if(((i=this.ws)==null?void 0:i.readyState)===WebSocket.OPEN)this.ws.send(JSON.stringify(a));else throw new Error("WebSocket is not open")}getConfig(){return this.config}cleanup(){this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=null),this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=null),this.clearPendingFiles(),this.clearStreamingState(),this.ws&&(this.ws.onopen=null,this.ws.onmessage=null,this.ws.onclose=null,this.ws.onerror=null,this.ws=null)}}function uI(n,a,i,l,u,f){var le;const c=G.useRef(null),d=G.useRef(0),p=G.useRef(null),g=_t(ne=>ne.setError),A=_t(ne=>ne.setShowRetryButton),m=_t(ne=>ne.setStartNewConnection),y=_t(ne=>ne.refreshSession),E=_t(ne=>ne.setSessionId),C=_t(ne=>ne.setSessionToken),x=G.useRef(!1),{setIsStreaming:w,isStreaming:v,connectionStatus:D,setConnectionStatus:B,clearResponseTimeout:z,clearStreamingTimeout:P,setLastStreamingActivity:N}=_t();G.useEffect(()=>{var T,_,V,U,he,be,Be,Ke,Ue,Fe,We,rt,Ct,Mt,S,ge,de,Y,j;if(!n||!n.sessionId||!((T=n.auth)!=null&&T.token)){console.log("No config provided",n),B(kt.CONNECTING);return}if((_=c.current)!=null&&_.isConnected()){console.log("WebSocket already connected, skipping connection");return}const ne=new sI(n);return console.log("WebSocket service created:",ne),c.current=ne,(V=c.current)==null||V.on(tn.CONNECTION_ESTABLISHED,H=>{console.log("WebSocket connection:",H),B(kt.CONNECTED),H?(A(!1),m(!1),g(null),d.current=0):(A(!0),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED))}),(U=c.current)==null||U.on(tn.PONG,H=>{}),c.current.on(tn.SYNC,H=>{}),(he=c.current)==null||he.on(tn.CHAT,H=>{if(H.ct===en.FILE&&H.data&&"urls"in H.data){const J=H.data.urls||[];J.length>0&&ne.uploadFilesToPresignedUrl(J).then(()=>{}).catch(pe=>{console.error("Failed to upload files:",pe),g(Ut.FILE_UPLOAD_FAILED)})}else if((H.ct===en.PILL||H.ct===en.MULTI||H.ct===en.DOCTOR_CARD||H.ct===en.MOBILE_VERIFICATION||H.ct===en.LAB_PACKAGE_CARD)&&H.data&&H.data.tool_use_id){if(u){const J={type:H.ct,tool_use_id:H.data.tool_use_id,data:{choices:H.data.choices,doctor_details:H.data.doctor_details,lab_packages:H.data.lab_packages,callbacks:H.data.callbacks,additional_option:H.data.additional_option,url:H.data.url,mobile_number:H.data.mobile_number}};u(J,H._id)}}else H.ct===en.TEXT&&H.data&&H.data.text&&H._id?(_t.getState().isStreaming||(w(!0),z(),g(null)),N(Date.now()),a&&a(H.data.text,H._id),setTimeout(()=>{_t.getState().isStreaming&&w(!1)},0)):H.ct===en.INLINE_TEXT&&H.data&&H.data.text&&(_t.getState().isStreaming||(w(!0),z()),N(Date.now()),f&&f(H.data.text),setTimeout(()=>{_t.getState().isStreaming&&w(!1)},0))}),(be=c.current)==null||be.on(tn.STREAM,H=>{_t.getState().isStreaming||(w(!0),z(),g(null)),N(Date.now()),H.ct===en.TEXT&&H.data&&H.data.text&&(H!=null&&H._id)&&a&&a(H.data.text,H._id)}),(Be=c.current)==null||Be.on("stream_chunk",({content:H,messageId:J})=>{v||(w(!0),z(),g(null)),N(Date.now()),a&&a(H,J)}),(Ke=c.current)==null||Ke.on(tn.END_OF_STREAM,H=>{w(!1),P(),p.current=null,i&&i("")}),(Ue=c.current)==null||Ue.on(tn.ERROR,H=>{switch(console.error("WebSocket error:",H),H.code){case vi.SESSION_INACTIVE:{A(!1),m(!0),g(Ut.SESSION_INACTIVE);break}case vi.SESSION_EXPIRED:{console.log("Session expired from useWebSocket"),I(),g(Ut.SESSION_EXPIRED);break}case vi.INVALID_EVENT:{g(Ut.INVALID_EVENT);break}case vi.INVALID_CONTENT_TYPE:{g(Ut.INVALID_CONTENT_TYPE);break}case vi.PARSING_ERROR:{d.current<2?(console.log("Retrying..."),d.current++,A(!0),g(Ut.PARSING_ERROR)):(A(!1),m(!0),d.current=0,g(Ut.ERROR_PROCESSING_MESSAGE));break}case vi.SERVER_ERROR:{A(!0),g(Ut.SERVER_ERROR);break}case vi.TIMEOUT:{g(Ut.TIMEOUT),A(!0);break}case vi.SESSION_TOKEN_MISMATCH:{g(Ut.SESSION_TOKEN_MISMATCH),A(!1),m(!0);break}default:{g({title:H.msg}),A(!0);break}}}),(Fe=c.current)==null||Fe.on(yn.SESSION_INACTIVE,H=>{console.error("Session inactive:",H),A(!1),m(!0),g(Ut.SESSION_INACTIVE)}),(We=c.current)==null||We.on("progress_message",H=>{N(Date.now()),_t.getState().isStreaming||(z(),g(null)),i&&(i(H),g(null))}),(rt=c.current)==null||rt.on(yn.TIPS,H=>{N(Date.now()),l&&l(H)}),(Ct=c.current)==null||Ct.on("message",H=>{var J;((J=H.metadata)==null?void 0:J.isStreaming)===!1&&(w(!1),P(),g(null))}),(Mt=c.current)==null||Mt.on(yn.MAX_CONNECTION_ATTEMPTS_EXCEEDED,H=>{console.log("MAX_CONNECTION_ATTEMPTS_EXCEEDED received:",H),A(!0),g(Ut.CONNECTION_ATTEMPTS_EXCEEDED)}),(S=c.current)==null||S.on(yn.MAX_RECONNECTION_ATTEMPTS_EXCEEDED,H=>{console.log("MAX_RECONNECTION_ATTEMPTS_EXCEEDED received:",H),A(!1),m(!0)}),(ge=c.current)==null||ge.on(yn.CONNECTION_TIMEOUT_ERROR,H=>{console.log("CONNECTION_TIMEOUT_ERROR received:",H),A(!0),g(Ut.CONNECTION_LOST)}),(de=c.current)==null||de.on(yn.SESSION_REFRESHED,H=>{if(console.log("SESSION_REFRESHED received:",H),H){const J=_t.getState();J.sessionId&&J.sessionToken&&(E(J.sessionId),C(J.sessionToken),c.current&&c.current.updateConfig({sessionId:J.sessionId,auth:{token:J.sessionToken}}),console.log("Session store updated after refresh"))}}),(Y=c.current)==null||Y.on(yn.START_NEW_SESSION,H=>{A(!1),m(!0),g(Ut.SESSION_INACTIVE)}),(j=c.current)==null||j.on(yn.SESSION_EXPIRED,H=>{A(!1),I(),g(Ut.SESSION_EXPIRED)}),ne.connect().catch(H=>{console.error("Failed to connect to WebSocket:",H),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED)}),()=>{c.current&&(c.current.disconnect(),c.current=null),w(!1),P(),z(),g(null),N(null),p.current=null,A(!1),m(!1),B(kt.DISCONNECTED)}},[n==null?void 0:n.sessionId,(le=n==null?void 0:n.auth)==null?void 0:le.token,B]);const Z=({message:ne,tool_use_id:T,tool_use_params:_})=>{var V;if((V=c.current)!=null&&V.isConnected())try{p.current={content:ne,tool_use_id:T,type:"text"},c.current.sendChatMessage({message:ne,tool_use_id:T,tool_use_params:_})}catch(U){console.error("Failed to send text message:",U),g(U instanceof Error?{title:U.message}:{title:"Failed to send message"})}else console.error("WebSocket not connected"),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED),A(!0)},ie=({message:ne,tool_use_id:T,tool_use_params:_})=>{var V;if((V=c.current)!=null&&V.isConnected())try{c.current.sendChatMessage({message:ne,tool_use_id:T,hidden:!0,tool_use_params:_})}catch(U){console.error("Failed to send hidden text message:",U)}else console.error("WebSocket not connected"),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED),A(!0)},F=ne=>{var T;if((T=c.current)!=null&&T.isConnected())try{x.current||(x.current=!0),p.current={content:"🎤 Voice message sent",type:"audio",audioData:ne},c.current.sendAudioData(ne),x.current=!1}catch(_){console.error("Failed to send audio data:",_),g(_ instanceof Error?{title:_.message}:{title:"Failed to send audio"})}else console.error("WebSocket not connected"),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED),A(!0)},K=()=>{c.current&&D===kt.CONNECTED&&c.current.sendFileUploadRequest()},re=(ne,T)=>{p.current={content:T||`📎 ${ne.length>1?`${ne.length} files`:"File"} uploaded`,type:"file",files:ne,message:T},c.current&&c.current.setFilesForUpload(ne,T)},Q=ne=>{c.current&&D===kt.CONNECTED&&(w(!1),c.current.regenerateResponse(ne))},q=()=>{g(null)},I=()=>et(null,null,function*(){try{c.current&&c.current.disconnect();const ne=yield y();return ne?console.log("Manual session refresh successful"):(A(!1),m(!0),g(Ut.SESSION_EXPIRED),console.log("Manual session refresh failed")),ne}catch(ne){return console.error("Error during manual session refresh:",ne),!1}}),ue=()=>et(null,null,function*(){var T;if(!((T=c.current)!=null&&T.isConnected()))return console.error("WebSocket not connected, cannot retry message"),g(Ut.CONNECTION_LOST),B(kt.DISCONNECTED),A(!0),!1;if(!p.current)return console.error("No last message to retry"),!1;const ne=p.current;try{switch(ne.type){case"text":yield Z({message:ne.content,tool_use_id:ne.tool_use_id,tool_use_params:ne.tool_use_params});break;case"audio":ne.audioData&&(yield F(ne.audioData));break;case"file":ne.files&&(yield re(ne.files,ne.message),yield K());break;default:return console.error("Unknown message type for retry:",ne.type),!1}return!0}catch(_){return console.error("Failed to retry last message:",_),g({title:"Failed to retry message. Please try again."}),!1}}),fe=()=>{var ne;return((ne=c.current)==null?void 0:ne.isConnected())||!1},ce=()=>{var ne;return((ne=c.current)==null?void 0:ne.getConnectionState())||null};return{isAudioStreaming:x.current,isConnected:fe(),connectionState:ce(),sendChatMessage:Z,sendAudioData:F,sendFileUploadRequest:K,setFilesForUpload:re,clearError:q,regenerateResponse:Q,triggerSessionRefresh:I,retryLastMessage:ue,sendHiddenChatMessage:ie,webSocketService:c.current}}/**
|
|
350
350
|
* @license lucide-react v0.536.0 - ISC
|
|
351
351
|
*
|
|
352
352
|
* This source code is licensed under the ISC license.
|
|
@@ -490,7 +490,7 @@ You might need to use a local HTTP server (instead of file://): https://react.de
|
|
|
490
490
|
`},f.current()));return/^[\t ]/.test(g)&&(g=is(g.charCodeAt(0))+g.slice(1)),g=g?c+" "+g:c,i.options.closeAtx&&(g+=" "+c),p(),d(),g}J0.peek=HM;function J0(n){return n.value||""}function HM(){return"<"}V0.peek=GM;function V0(n,a,i,l){const u=ph(i),f=u==='"'?"Quote":"Apostrophe",c=i.enter("image");let d=i.enter("label");const p=i.createTracker(l);let g=p.move("![");return g+=p.move(i.safe(n.alt,oe({before:g,after:"]"},p.current()))),g+=p.move("]("),d(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(d=i.enter("destinationLiteral"),g+=p.move("<"),g+=p.move(i.safe(n.url,oe({before:g,after:">"},p.current()))),g+=p.move(">")):(d=i.enter("destinationRaw"),g+=p.move(i.safe(n.url,oe({before:g,after:n.title?" ":")"},p.current())))),d(),n.title&&(d=i.enter(`title${f}`),g+=p.move(" "+u),g+=p.move(i.safe(n.title,oe({before:g,after:u},p.current()))),g+=p.move(u),d()),g+=p.move(")"),c(),g}function GM(){return"!"}_0.peek=KM;function _0(n,a,i,l){const u=n.referenceType,f=i.enter("imageReference");let c=i.enter("label");const d=i.createTracker(l);let p=d.move("![");const g=i.safe(n.alt,oe({before:p,after:"]"},d.current()));p+=d.move(g+"]["),c();const A=i.stack;i.stack=[],c=i.enter("reference");const m=i.safe(i.associationId(n),oe({before:p,after:"]"},d.current()));return c(),i.stack=A,f(),u==="full"||!g||g!==m?p+=d.move(m+"]"):u==="shortcut"?p=p.slice(0,-1):p+=d.move("]"),p}function KM(){return"!"}Z0.peek=YM;function Z0(n,a,i){let l=n.value||"",u="`",f=-1;for(;new RegExp("(^|[^`])"+u+"([^`]|$)").test(l);)u+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++f<i.unsafe.length;){const c=i.unsafe[f],d=i.compilePattern(c);let p;if(c.atBreak)for(;p=d.exec(l);){let g=p.index;l.charCodeAt(g)===10&&l.charCodeAt(g-1)===13&&g--,l=l.slice(0,g)+" "+l.slice(p.index+1)}}return u+l+u}function YM(){return"`"}function X0(n,a){const i=Fd(n);return!!(!a.options.resourceLink&&n.url&&!n.title&&n.children&&n.children.length===1&&n.children[0].type==="text"&&(i===n.url||"mailto:"+i===n.url)&&/^[a-z][a-z+.-]+:/i.test(n.url)&&!/[\0- <>\u007F]/.test(n.url))}W0.peek=qM;function W0(n,a,i,l){const u=ph(i),f=u==='"'?"Quote":"Apostrophe",c=i.createTracker(l);let d,p;if(X0(n,i)){const A=i.stack;i.stack=[],d=i.enter("autolink");let m=c.move("<");return m+=c.move(i.containerPhrasing(n,oe({before:m,after:">"},c.current()))),m+=c.move(">"),d(),i.stack=A,m}d=i.enter("link"),p=i.enter("label");let g=c.move("[");return g+=c.move(i.containerPhrasing(n,oe({before:g,after:"]("},c.current()))),g+=c.move("]("),p(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(p=i.enter("destinationLiteral"),g+=c.move("<"),g+=c.move(i.safe(n.url,oe({before:g,after:">"},c.current()))),g+=c.move(">")):(p=i.enter("destinationRaw"),g+=c.move(i.safe(n.url,oe({before:g,after:n.title?" ":")"},c.current())))),p(),n.title&&(p=i.enter(`title${f}`),g+=c.move(" "+u),g+=c.move(i.safe(n.title,oe({before:g,after:u},c.current()))),g+=c.move(u),p()),g+=c.move(")"),d(),g}function qM(n,a,i){return X0(n,i)?"<":"["}$0.peek=JM;function $0(n,a,i,l){const u=n.referenceType,f=i.enter("linkReference");let c=i.enter("label");const d=i.createTracker(l);let p=d.move("[");const g=i.containerPhrasing(n,oe({before:p,after:"]"},d.current()));p+=d.move(g+"]["),c();const A=i.stack;i.stack=[],c=i.enter("reference");const m=i.safe(i.associationId(n),oe({before:p,after:"]"},d.current()));return c(),i.stack=A,f(),u==="full"||!g||g!==m?p+=d.move(m+"]"):u==="shortcut"?p=p.slice(0,-1):p+=d.move("]"),p}function JM(){return"["}function gh(n){const a=n.options.bullet||"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bullet`, expected `*`, `+`, or `-`");return a}function VM(n){const a=gh(n),i=n.options.bulletOther;if(!i)return a==="*"?"-":"*";if(i!=="*"&&i!=="+"&&i!=="-")throw new Error("Cannot serialize items with `"+i+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(i===a)throw new Error("Expected `bullet` (`"+a+"`) and `bulletOther` (`"+i+"`) to be different");return i}function _M(n){const a=n.options.bulletOrdered||".";if(a!=="."&&a!==")")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOrdered`, expected `.` or `)`");return a}function eE(n){const a=n.options.rule||"*";if(a!=="*"&&a!=="-"&&a!=="_")throw new Error("Cannot serialize rules with `"+a+"` for `options.rule`, expected `*`, `-`, or `_`");return a}function ZM(n,a,i,l){const u=i.enter("list"),f=i.bulletCurrent;let c=n.ordered?_M(i):gh(i);const d=n.ordered?c==="."?")":".":VM(i);let p=a&&i.bulletLastUsed?c===i.bulletLastUsed:!1;if(!n.ordered){const A=n.children?n.children[0]:void 0;if((c==="*"||c==="-")&&A&&(!A.children||!A.children[0])&&i.stack[i.stack.length-1]==="list"&&i.stack[i.stack.length-2]==="listItem"&&i.stack[i.stack.length-3]==="list"&&i.stack[i.stack.length-4]==="listItem"&&i.indexStack[i.indexStack.length-1]===0&&i.indexStack[i.indexStack.length-2]===0&&i.indexStack[i.indexStack.length-3]===0&&(p=!0),eE(i)===c&&A){let m=-1;for(;++m<n.children.length;){const y=n.children[m];if(y&&y.type==="listItem"&&y.children&&y.children[0]&&y.children[0].type==="thematicBreak"){p=!0;break}}}}p&&(c=d),i.bulletCurrent=c;const g=i.containerFlow(n,l);return i.bulletLastUsed=c,i.bulletCurrent=f,u(),g}function XM(n){const a=n.options.listItemIndent||"one";if(a!=="tab"&&a!=="one"&&a!=="mixed")throw new Error("Cannot serialize items with `"+a+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return a}function WM(n,a,i,l){const u=XM(i);let f=i.bulletCurrent||gh(i);a&&a.type==="list"&&a.ordered&&(f=(typeof a.start=="number"&&a.start>-1?a.start:1)+(i.options.incrementListMarker===!1?0:a.children.indexOf(n))+f);let c=f.length+1;(u==="tab"||u==="mixed"&&(a&&a.type==="list"&&a.spread||n.spread))&&(c=Math.ceil(c/4)*4);const d=i.createTracker(l);d.move(f+" ".repeat(c-f.length)),d.shift(c);const p=i.enter("listItem"),g=i.indentLines(i.containerFlow(n,d.current()),A);return p(),g;function A(m,y,E){return y?(E?"":" ".repeat(c))+m:(E?f:f+" ".repeat(c-f.length))+m}}function $M(n,a,i,l){const u=i.enter("paragraph"),f=i.enter("phrasing"),c=i.containerPhrasing(n,l);return f(),u(),c}const eQ=nc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function tQ(n,a,i,l){return(n.children.some(function(c){return eQ(c)})?i.containerPhrasing:i.containerFlow).call(i,n,l)}function nQ(n){const a=n.options.strong||"*";if(a!=="*"&&a!=="_")throw new Error("Cannot serialize strong with `"+a+"` for `options.strong`, expected `*`, or `_`");return a}tE.peek=rQ;function tE(n,a,i,l){const u=nQ(i),f=i.enter("strong"),c=i.createTracker(l),d=c.move(u+u);let p=c.move(i.containerPhrasing(n,oe({after:u,before:d},c.current())));const g=p.charCodeAt(0),A=ac(l.before.charCodeAt(l.before.length-1),g,u);A.inside&&(p=is(g)+p.slice(1));const m=p.charCodeAt(p.length-1),y=ac(l.after.charCodeAt(0),m,u);y.inside&&(p=p.slice(0,-1)+is(m));const E=c.move(u+u);return f(),i.attentionEncodeSurroundingInfo={after:y.outside,before:A.outside},d+p+E}function rQ(n,a,i){return i.options.strong||"*"}function iQ(n,a,i,l){return i.safe(n.value,l)}function aQ(n){const a=n.options.ruleRepetition||3;if(a<3)throw new Error("Cannot serialize rules with repetition `"+a+"` for `options.ruleRepetition`, expected `3` or more");return a}function oQ(n,a,i){const l=(eE(i)+(i.options.ruleSpaces?" ":"")).repeat(aQ(i));return i.options.ruleSpaces?l.slice(0,-1):l}const nE={blockquote:DM,break:Y0,code:UM,definition:jM,emphasis:q0,hardBreak:Y0,heading:PM,html:J0,image:V0,imageReference:_0,inlineCode:Z0,link:W0,linkReference:$0,list:ZM,listItem:WM,paragraph:$M,root:tQ,strong:tE,text:iQ,thematicBreak:oQ};function lQ(){return{enter:{table:sQ,tableData:rE,tableHeader:rE,tableRow:cQ},exit:{codeText:fQ,table:uQ,tableData:mh,tableHeader:mh,tableRow:mh}}}function sQ(n){const a=n._align;this.enter({type:"table",align:a.map(function(i){return i==="none"?null:i}),children:[]},n),this.data.inTable=!0}function uQ(n){this.exit(n),this.data.inTable=void 0}function cQ(n){this.enter({type:"tableRow",children:[]},n)}function mh(n){this.exit(n)}function rE(n){this.enter({type:"tableCell",children:[]},n)}function fQ(n){let a=this.resume();this.data.inTable&&(a=a.replace(/\\([\\|])/g,dQ));const i=this.stack[this.stack.length-1];i.type,i.value=a,this.exit(n)}function dQ(n,a){return a==="|"?a:n}function hQ(n){const a=n||{},i=a.tableCellPadding,l=a.tablePipeAlign,u=a.stringLength,f=i?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
491
491
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:y,table:c,tableCell:p,tableRow:d}};function c(E,C,x,w){return g(A(E,x,w),E.align)}function d(E,C,x,w){const v=m(E,x,w),D=g([v]);return D.slice(0,D.indexOf(`
|
|
492
492
|
`))}function p(E,C,x,w){const v=x.enter("tableCell"),D=x.enter("phrasing"),B=x.containerPhrasing(E,ze(oe({},w),{before:f,after:f}));return D(),v(),B}function g(E,C){return IM(E,{align:C,alignDelimiters:l,padding:i,stringLength:u})}function A(E,C,x){const w=E.children;let v=-1;const D=[],B=C.enter("table");for(;++v<w.length;)D[v]=m(w[v],C,x);return B(),D}function m(E,C,x){const w=E.children;let v=-1;const D=[],B=C.enter("tableRow");for(;++v<w.length;)D[v]=p(w[v],E,C,x);return B(),D}function y(E,C,x){let w=nE.inlineCode(E,C,x);return x.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function pQ(){return{exit:{taskListCheckValueChecked:iE,taskListCheckValueUnchecked:iE,paragraph:mQ}}}function gQ(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:AQ}}}function iE(n){const a=this.stack[this.stack.length-2];a.type,a.checked=n.type==="taskListCheckValueChecked"}function mQ(n){const a=this.stack[this.stack.length-2];if(a&&a.type==="listItem"&&typeof a.checked=="boolean"){const i=this.stack[this.stack.length-1];i.type;const l=i.children[0];if(l&&l.type==="text"){const u=a.children;let f=-1,c;for(;++f<u.length;){const d=u[f];if(d.type==="paragraph"){c=d;break}}c===i&&(l.value=l.value.slice(1),l.value.length===0?i.children.shift():i.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,i.position.start=Object.assign({},l.position.start)))}}this.exit(n)}function AQ(n,a,i,l){const u=n.children[0],f=typeof n.checked=="boolean"&&u&&u.type==="paragraph",c="["+(n.checked?"x":" ")+"] ",d=i.createTracker(l);f&&d.move(c);let p=nE.listItem(n,a,i,oe(oe({},l),d.current()));return f&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,g)),p;function g(A){return A+c}}function yQ(){return[ZB(),AM(),bM(),lQ(),pQ()]}function EQ(n){return{extensions:[XB(),yM(n),xM(),hQ(n),gQ()]}}const wQ={tokenize:kQ,partial:!0},aE={tokenize:IQ,partial:!0},oE={tokenize:RQ,partial:!0},lE={tokenize:DQ,partial:!0},bQ={tokenize:TQ,partial:!0},sE={name:"wwwAutolink",tokenize:vQ,previous:cE},uE={name:"protocolAutolink",tokenize:SQ,previous:fE},Si={name:"emailAutolink",tokenize:CQ,previous:dE},ri={};function xQ(){return{text:ri}}let La=48;for(;La<123;)ri[La]=Si,La++,La===58?La=65:La===91&&(La=97);ri[43]=Si,ri[45]=Si,ri[46]=Si,ri[95]=Si,ri[72]=[Si,uE],ri[104]=[Si,uE],ri[87]=[Si,sE],ri[119]=[Si,sE];function CQ(n,a,i){const l=this;let u,f;return c;function c(m){return!Ah(m)||!dE.call(l,l.previous)||yh(l.events)?i(m):(n.enter("literalAutolink"),n.enter("literalAutolinkEmail"),d(m))}function d(m){return Ah(m)?(n.consume(m),d):m===64?(n.consume(m),p):i(m)}function p(m){return m===46?n.check(bQ,A,g)(m):m===45||m===95||Jn(m)?(f=!0,n.consume(m),p):A(m)}function g(m){return n.consume(m),u=!0,p}function A(m){return f&&u&&Wn(l.previous)?(n.exit("literalAutolinkEmail"),n.exit("literalAutolink"),a(m)):i(m)}}function vQ(n,a,i){const l=this;return u;function u(c){return c!==87&&c!==119||!cE.call(l,l.previous)||yh(l.events)?i(c):(n.enter("literalAutolink"),n.enter("literalAutolinkWww"),n.check(wQ,n.attempt(aE,n.attempt(oE,f),i),i)(c))}function f(c){return n.exit("literalAutolinkWww"),n.exit("literalAutolink"),a(c)}}function SQ(n,a,i){const l=this;let u="",f=!1;return c;function c(m){return(m===72||m===104)&&fE.call(l,l.previous)&&!yh(l.events)?(n.enter("literalAutolink"),n.enter("literalAutolinkHttp"),u+=String.fromCodePoint(m),n.consume(m),d):i(m)}function d(m){if(Wn(m)&&u.length<5)return u+=String.fromCodePoint(m),n.consume(m),d;if(m===58){const y=u.toLowerCase();if(y==="http"||y==="https")return n.consume(m),p}return i(m)}function p(m){return m===47?(n.consume(m),f?g:(f=!0,p)):i(m)}function g(m){return m===null||Ju(m)||Zt(m)||za(m)||Vu(m)?i(m):n.attempt(aE,n.attempt(oE,A),i)(m)}function A(m){return n.exit("literalAutolinkHttp"),n.exit("literalAutolink"),a(m)}}function kQ(n,a,i){let l=0;return u;function u(c){return(c===87||c===119)&&l<3?(l++,n.consume(c),u):c===46&&l===3?(n.consume(c),f):i(c)}function f(c){return c===null?i(c):a(c)}}function IQ(n,a,i){let l,u,f;return c;function c(g){return g===46||g===95?n.check(lE,p,d)(g):g===null||Zt(g)||za(g)||g!==45&&Vu(g)?p(g):(f=!0,n.consume(g),c)}function d(g){return g===95?l=!0:(u=l,l=void 0),n.consume(g),c}function p(g){return u||l||!f?i(g):a(g)}}function RQ(n,a){let i=0,l=0;return u;function u(c){return c===40?(i++,n.consume(c),u):c===41&&l<i?f(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?n.check(lE,a,f)(c):c===null||Zt(c)||za(c)?a(c):(n.consume(c),u)}function f(c){return c===41&&l++,n.consume(c),u}}function DQ(n,a,i){return l;function l(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(n.consume(d),l):d===38?(n.consume(d),f):d===93?(n.consume(d),u):d===60||d===null||Zt(d)||za(d)?a(d):i(d)}function u(d){return d===null||d===40||d===91||Zt(d)||za(d)?a(d):l(d)}function f(d){return Wn(d)?c(d):i(d)}function c(d){return d===59?(n.consume(d),l):Wn(d)?(n.consume(d),c):i(d)}}function TQ(n,a,i){return l;function l(f){return n.consume(f),u}function u(f){return Jn(f)?i(f):a(f)}}function cE(n){return n===null||n===40||n===42||n===95||n===91||n===93||n===126||Zt(n)}function fE(n){return!Wn(n)}function dE(n){return!(n===47||Ah(n))}function Ah(n){return n===43||n===45||n===46||n===95||Jn(n)}function yh(n){let a=n.length,i=!1;for(;a--;){const l=n[a][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){i=!0;break}if(l._gfmAutolinkLiteralWalkedInto){i=!1;break}}return n.length>0&&!i&&(n[n.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),i}const BQ={tokenize:FQ,partial:!0};function MQ(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:NQ,continuation:{tokenize:jQ},exit:zQ}},text:{91:{name:"gfmFootnoteCall",tokenize:UQ},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:QQ,resolveTo:OQ}}}}function QQ(n,a,i){const l=this;let u=l.events.length;const f=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c;for(;u--;){const p=l.events[u][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return d;function d(p){if(!c||!c._balanced)return i(p);const g=qr(l.sliceSerialize({start:c.end,end:l.now()}));return g.codePointAt(0)!==94||!f.includes(g.slice(1))?i(p):(n.enter("gfmFootnoteCallLabelMarker"),n.consume(p),n.exit("gfmFootnoteCallLabelMarker"),a(p))}}function OQ(n,a){let i=n.length;for(;i--;)if(n[i][1].type==="labelImage"&&n[i][0]==="enter"){n[i][1];break}n[i+1][1].type="data",n[i+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},n[i+3][1].start),end:Object.assign({},n[n.length-1][1].end)},u={type:"gfmFootnoteCallMarker",start:Object.assign({},n[i+3][1].end),end:Object.assign({},n[i+3][1].end)};u.end.column++,u.end.offset++,u.end._bufferIndex++;const f={type:"gfmFootnoteCallString",start:Object.assign({},u.end),end:Object.assign({},n[n.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},f.start),end:Object.assign({},f.end)},d=[n[i+1],n[i+2],["enter",l,a],n[i+3],n[i+4],["enter",u,a],["exit",u,a],["enter",f,a],["enter",c,a],["exit",c,a],["exit",f,a],n[n.length-2],n[n.length-1],["exit",l,a]];return n.splice(i,n.length-i+1,...d),n}function UQ(n,a,i){const l=this,u=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let f=0,c;return d;function d(m){return n.enter("gfmFootnoteCall"),n.enter("gfmFootnoteCallLabelMarker"),n.consume(m),n.exit("gfmFootnoteCallLabelMarker"),p}function p(m){return m!==94?i(m):(n.enter("gfmFootnoteCallMarker"),n.consume(m),n.exit("gfmFootnoteCallMarker"),n.enter("gfmFootnoteCallString"),n.enter("chunkString").contentType="string",g)}function g(m){if(f>999||m===93&&!c||m===null||m===91||Zt(m))return i(m);if(m===93){n.exit("chunkString");const y=n.exit("gfmFootnoteCallString");return u.includes(qr(l.sliceSerialize(y)))?(n.enter("gfmFootnoteCallLabelMarker"),n.consume(m),n.exit("gfmFootnoteCallLabelMarker"),n.exit("gfmFootnoteCall"),a):i(m)}return Zt(m)||(c=!0),f++,n.consume(m),m===92?A:g}function A(m){return m===91||m===92||m===93?(n.consume(m),f++,g):g(m)}}function NQ(n,a,i){const l=this,u=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let f,c=0,d;return p;function p(C){return n.enter("gfmFootnoteDefinition")._container=!0,n.enter("gfmFootnoteDefinitionLabel"),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(C),n.exit("gfmFootnoteDefinitionLabelMarker"),g}function g(C){return C===94?(n.enter("gfmFootnoteDefinitionMarker"),n.consume(C),n.exit("gfmFootnoteDefinitionMarker"),n.enter("gfmFootnoteDefinitionLabelString"),n.enter("chunkString").contentType="string",A):i(C)}function A(C){if(c>999||C===93&&!d||C===null||C===91||Zt(C))return i(C);if(C===93){n.exit("chunkString");const x=n.exit("gfmFootnoteDefinitionLabelString");return f=qr(l.sliceSerialize(x)),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(C),n.exit("gfmFootnoteDefinitionLabelMarker"),n.exit("gfmFootnoteDefinitionLabel"),y}return Zt(C)||(d=!0),c++,n.consume(C),C===92?m:A}function m(C){return C===91||C===92||C===93?(n.consume(C),c++,A):A(C)}function y(C){return C===58?(n.enter("definitionMarker"),n.consume(C),n.exit("definitionMarker"),u.includes(f)||u.push(f),Nt(n,E,"gfmFootnoteDefinitionWhitespace")):i(C)}function E(C){return a(C)}}function jQ(n,a,i){return n.check(Wl,a,n.attempt(BQ,a,i))}function zQ(n){n.exit("gfmFootnoteDefinition")}function FQ(n,a,i){const l=this;return Nt(n,u,"gfmFootnoteDefinitionIndent",5);function u(f){const c=l.events[l.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?a(f):i(f)}}function LQ(n){let i=(n||{}).singleTilde;const l={name:"strikethrough",tokenize:f,resolveAll:u};return i==null&&(i=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function u(c,d){let p=-1;for(;++p<c.length;)if(c[p][0]==="enter"&&c[p][1].type==="strikethroughSequenceTemporary"&&c[p][1]._close){let g=p;for(;g--;)if(c[g][0]==="exit"&&c[g][1].type==="strikethroughSequenceTemporary"&&c[g][1]._open&&c[p][1].end.offset-c[p][1].start.offset===c[g][1].end.offset-c[g][1].start.offset){c[p][1].type="strikethroughSequence",c[g][1].type="strikethroughSequence";const A={type:"strikethrough",start:Object.assign({},c[g][1].start),end:Object.assign({},c[p][1].end)},m={type:"strikethroughText",start:Object.assign({},c[g][1].end),end:Object.assign({},c[p][1].start)},y=[["enter",A,d],["enter",c[g][1],d],["exit",c[g][1],d],["enter",m,d]],E=d.parser.constructs.insideSpan.null;E&&yr(y,y.length,0,_u(E,c.slice(g+1,p),d)),yr(y,y.length,0,[["exit",m,d],["enter",c[p][1],d],["exit",c[p][1],d],["exit",A,d]]),yr(c,g-1,p-g+3,y),p=g+y.length-2;break}}for(p=-1;++p<c.length;)c[p][1].type==="strikethroughSequenceTemporary"&&(c[p][1].type="data");return c}function f(c,d,p){const g=this.previous,A=this.events;let m=0;return y;function y(C){return g===126&&A[A.length-1][1].type!=="characterEscape"?p(C):(c.enter("strikethroughSequenceTemporary"),E(C))}function E(C){const x=Uo(g);if(C===126)return m>1?p(C):(c.consume(C),m++,E);if(m<2&&!i)return p(C);const w=c.exit("strikethroughSequenceTemporary"),v=Uo(C);return w._open=!v||v===2&&!!x,w._close=!x||x===2&&!!v,d(C)}}}class PQ{constructor(){this.map=[]}add(a,i,l){HQ(this,a,i,l)}consume(a){if(this.map.sort(function(f,c){return f[0]-c[0]}),this.map.length===0)return;let i=this.map.length;const l=[];for(;i>0;)i-=1,l.push(a.slice(this.map[i][0]+this.map[i][1]),this.map[i][2]),a.length=this.map[i][0];l.push(a.slice()),a.length=0;let u=l.pop();for(;u;){for(const f of u)a.push(f);u=l.pop()}this.map.length=0}}function HQ(n,a,i,l){let u=0;if(!(i===0&&l.length===0)){for(;u<n.map.length;){if(n.map[u][0]===a){n.map[u][1]+=i,n.map[u][2].push(...l);return}u+=1}n.map.push([a,i,l])}}function GQ(n,a){let i=!1;const l=[];for(;a<n.length;){const u=n[a];if(i){if(u[0]==="enter")u[1].type==="tableContent"&&l.push(n[a+1][1].type==="tableDelimiterMarker"?"left":"none");else if(u[1].type==="tableContent"){if(n[a-1][1].type==="tableDelimiterMarker"){const f=l.length-1;l[f]=l[f]==="left"?"center":"right"}}else if(u[1].type==="tableDelimiterRow")break}else u[0]==="enter"&&u[1].type==="tableDelimiterRow"&&(i=!0);a+=1}return l}function KQ(){return{flow:{null:{name:"table",tokenize:YQ,resolveAll:qQ}}}}function YQ(n,a,i){const l=this;let u=0,f=0,c;return d;function d(K){let re=l.events.length-1;for(;re>-1;){const I=l.events[re][1].type;if(I==="lineEnding"||I==="linePrefix")re--;else break}const Q=re>-1?l.events[re][1].type:null,q=Q==="tableHead"||Q==="tableRow"?N:p;return q===N&&l.parser.lazy[l.now().line]?i(K):q(K)}function p(K){return n.enter("tableHead"),n.enter("tableRow"),g(K)}function g(K){return K===124||(c=!0,f+=1),A(K)}function A(K){return K===null?i(K):nt(K)?f>1?(f=0,l.interrupt=!0,n.exit("tableRow"),n.enter("lineEnding"),n.consume(K),n.exit("lineEnding"),E):i(K):It(K)?Nt(n,A,"whitespace")(K):(f+=1,c&&(c=!1,u+=1),K===124?(n.enter("tableCellDivider"),n.consume(K),n.exit("tableCellDivider"),c=!0,A):(n.enter("data"),m(K)))}function m(K){return K===null||K===124||Zt(K)?(n.exit("data"),A(K)):(n.consume(K),K===92?y:m)}function y(K){return K===92||K===124?(n.consume(K),m):m(K)}function E(K){return l.interrupt=!1,l.parser.lazy[l.now().line]?i(K):(n.enter("tableDelimiterRow"),c=!1,It(K)?Nt(n,C,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):C(K))}function C(K){return K===45||K===58?w(K):K===124?(c=!0,n.enter("tableCellDivider"),n.consume(K),n.exit("tableCellDivider"),x):P(K)}function x(K){return It(K)?Nt(n,w,"whitespace")(K):w(K)}function w(K){return K===58?(f+=1,c=!0,n.enter("tableDelimiterMarker"),n.consume(K),n.exit("tableDelimiterMarker"),v):K===45?(f+=1,v(K)):K===null||nt(K)?z(K):P(K)}function v(K){return K===45?(n.enter("tableDelimiterFiller"),D(K)):P(K)}function D(K){return K===45?(n.consume(K),D):K===58?(c=!0,n.exit("tableDelimiterFiller"),n.enter("tableDelimiterMarker"),n.consume(K),n.exit("tableDelimiterMarker"),B):(n.exit("tableDelimiterFiller"),B(K))}function B(K){return It(K)?Nt(n,z,"whitespace")(K):z(K)}function z(K){return K===124?C(K):K===null||nt(K)?!c||u!==f?P(K):(n.exit("tableDelimiterRow"),n.exit("tableHead"),a(K)):P(K)}function P(K){return i(K)}function N(K){return n.enter("tableRow"),Z(K)}function Z(K){return K===124?(n.enter("tableCellDivider"),n.consume(K),n.exit("tableCellDivider"),Z):K===null||nt(K)?(n.exit("tableRow"),a(K)):It(K)?Nt(n,Z,"whitespace")(K):(n.enter("data"),ie(K))}function ie(K){return K===null||K===124||Zt(K)?(n.exit("data"),Z(K)):(n.consume(K),K===92?F:ie)}function F(K){return K===92||K===124?(n.consume(K),ie):ie(K)}}function qQ(n,a){let i=-1,l=!0,u=0,f=[0,0,0,0],c=[0,0,0,0],d=!1,p=0,g,A,m;const y=new PQ;for(;++i<n.length;){const E=n[i],C=E[1];E[0]==="enter"?C.type==="tableHead"?(d=!1,p!==0&&(hE(y,a,p,g,A),A=void 0,p=0),g={type:"table",start:Object.assign({},C.start),end:Object.assign({},C.end)},y.add(i,0,[["enter",g,a]])):C.type==="tableRow"||C.type==="tableDelimiterRow"?(l=!0,m=void 0,f=[0,0,0,0],c=[0,i+1,0,0],d&&(d=!1,A={type:"tableBody",start:Object.assign({},C.start),end:Object.assign({},C.end)},y.add(i,0,[["enter",A,a]])),u=C.type==="tableDelimiterRow"?2:A?3:1):u&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")?(l=!1,c[2]===0&&(f[1]!==0&&(c[0]=c[1],m=oc(y,a,f,u,void 0,m),f=[0,0,0,0]),c[2]=i)):C.type==="tableCellDivider"&&(l?l=!1:(f[1]!==0&&(c[0]=c[1],m=oc(y,a,f,u,void 0,m)),f=c,c=[f[1],i,0,0])):C.type==="tableHead"?(d=!0,p=i):C.type==="tableRow"||C.type==="tableDelimiterRow"?(p=i,f[1]!==0?(c[0]=c[1],m=oc(y,a,f,u,i,m)):c[1]!==0&&(m=oc(y,a,c,u,i,m)),u=0):u&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")&&(c[3]=i)}for(p!==0&&hE(y,a,p,g,A),y.consume(a.events),i=-1;++i<a.events.length;){const E=a.events[i];E[0]==="enter"&&E[1].type==="table"&&(E[1]._align=GQ(a.events,i))}return n}function oc(n,a,i,l,u,f){const c=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",d="tableContent";i[0]!==0&&(f.end=Object.assign({},jo(a.events,i[0])),n.add(i[0],0,[["exit",f,a]]));const p=jo(a.events,i[1]);if(f={type:c,start:Object.assign({},p),end:Object.assign({},p)},n.add(i[1],0,[["enter",f,a]]),i[2]!==0){const g=jo(a.events,i[2]),A=jo(a.events,i[3]),m={type:d,start:Object.assign({},g),end:Object.assign({},A)};if(n.add(i[2],0,[["enter",m,a]]),l!==2){const y=a.events[i[2]],E=a.events[i[3]];if(y[1].end=Object.assign({},E[1].end),y[1].type="chunkText",y[1].contentType="text",i[3]>i[2]+1){const C=i[2]+1,x=i[3]-i[2]-1;n.add(C,x,[])}}n.add(i[3]+1,0,[["exit",m,a]])}return u!==void 0&&(f.end=Object.assign({},jo(a.events,u)),n.add(u,0,[["exit",f,a]]),f=void 0),f}function hE(n,a,i,l,u){const f=[],c=jo(a.events,i);u&&(u.end=Object.assign({},c),f.push(["exit",u,a])),l.end=Object.assign({},c),f.push(["exit",l,a]),n.add(i+1,0,f)}function jo(n,a){const i=n[a],l=i[0]==="enter"?"start":"end";return i[1][l]}const JQ={name:"tasklistCheck",tokenize:_Q};function VQ(){return{text:{91:JQ}}}function _Q(n,a,i){const l=this;return u;function u(p){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?i(p):(n.enter("taskListCheck"),n.enter("taskListCheckMarker"),n.consume(p),n.exit("taskListCheckMarker"),f)}function f(p){return Zt(p)?(n.enter("taskListCheckValueUnchecked"),n.consume(p),n.exit("taskListCheckValueUnchecked"),c):p===88||p===120?(n.enter("taskListCheckValueChecked"),n.consume(p),n.exit("taskListCheckValueChecked"),c):i(p)}function c(p){return p===93?(n.enter("taskListCheckMarker"),n.consume(p),n.exit("taskListCheckMarker"),n.exit("taskListCheck"),d):i(p)}function d(p){return nt(p)?a(p):It(p)?n.check({tokenize:ZQ},a,i)(p):i(p)}}function ZQ(n,a,i){return Nt(n,l,"whitespace");function l(u){return u===null?i(u):a(u)}}function XQ(n){return Yy([xQ(),MQ(),LQ(n),KQ(),VQ()])}const WQ={};function $Q(n){const a=this,i=n||WQ,l=a.data(),u=l.micromarkExtensions||(l.micromarkExtensions=[]),f=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),c=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);u.push(XQ(i)),f.push(yQ()),c.push(EQ(i))}function pE({text:n,maxWidth:a="200px",className:i=""}){const[l,u]=G.useState(!1),f=G.useRef(null),c=G.useRef(null);return G.useEffect(()=>{const d=()=>{if(f.current&&c.current){const p=f.current.offsetWidth,g=c.current.scrollWidth;u(g>p)}};return d(),window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[n,a]),R.jsx("div",{ref:f,className:`marquee-container ${i}`,style:{maxWidth:a},title:n,children:R.jsx("span",{ref:c,className:l?"marquee-text-default":"marquee-text-normal",children:n})})}function e4({messageId:n,message:a,isBot:i=!1,onUserFeedback:l,isLastMessage:u,quickActions:f,showActions:c,isQuickActionsDisabled:d,isStreaming:p=!1,progressMessage:g,handleQuickAction:A,refreshSession:m,verificationStatus:y,handleRequestAppointment:E,clearMobileVerification:C,isRegenerating:x=!1,commonContentData:w,onContentClick:v,tips:D,onTipsExpire:B,isResponded:z=!1,files:P,feedback:N,getAvailabilityDatesForAppointment:Z,getAvailableSlotsForAppointment:ie,onLabPackageBook:F}){var U;const[K,re]=G.useState([]),[Q,q]=G.useState(N||Mn.NONE),[I,ue]=G.useState(!1);G.useEffect(()=>{w&&w.type===en.MULTI&&re([])},[w]),G.useEffect(()=>{N===Mn.DISLIKE&&u?ue(!0):ue(!1)},[N,u]);const fe=he=>{re(he)},ce=()=>{if(v&&(w!=null&&w.tool_use_id)&&w.type===en.MULTI){let he=[...K];if(w.data.additional_option===Gl.NOTA){const be=K.find(Be=>Be===Gl.NOTA);be&&(he=[be])}else if(w.data.additional_option===Gl.AOTA){const be=K.find(Be=>Be===Gl.AOTA);be&&w.data.choices&&(he=[...w.data.choices,be])}v({content:he.join(", "),tool_use_id:w.tool_use_id})}},le=he=>{l(n,he),q(he)},ne=()=>{ue(!1)},T=he=>{console.log("Selected dislike reason:",he),l(n,Mn.DISLIKE,he.value)},_=G.useMemo(()=>!a&&!g&&!p&&!(D!=null&&D.length)&&!x&&!y,[a,g,p,D,x,y]),V=!i||!_;return R.jsx("div",{className:"px-4 py-2",children:R.jsx("div",{className:`flex gap-2 ${i?"items-start":"items-start justify-end"}`,children:R.jsxs("div",{className:`${i?"flex-1 space-y-2":"max-w-[80%]"}`,children:[V&&R.jsxs("div",{className:`flex items-end gap-2 ${i?"justify-start":"justify-end"}`,children:[i&&R.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full overflow-hidden",children:R.jsx("img",{src:"./assets/indian-doctor.png",alt:"Apollo Icon",className:"w-full h-full object-cover scale-125"})}),R.jsxs("div",{className:`text-sm leading-relaxed rounded-3xl
|
|
493
|
-
${i?"rounded-bl-none text-[var(--color-foreground)] bg-[var(--color-background-primary-default)]":"rounded-br-none text-[var(--color-black-800)] bg-[var(--color-background-primary-subtle)]"}`,children:[a&&i&&R.jsx("div",{className:"markdown-content p-4",children:R.jsx(U0,{remarkPlugins:[$Q],children:a})}),a&&!i&&R.jsx("div",{className:"text-sm break-word p-4",children:a}),i&&g&&R.jsx("div",{className:"p-4 bg-gradient-to-r from-[var(--color-primary)] via-[var(--color-primary-400)] to-[var(--color-primary-600)] bg-clip-text text-transparent font-medium",children:R.jsx(U0,{children:g})}),i&&p&&!g&&R.jsx("span",{className:"animate-pulse p-4 block",children:"..."}),i&&(D==null?void 0:D.length)&&D.length>0&&R.jsx("div",{className:"px-4 pb-4",children:R.jsx(GB,{tips:D,onTipsExpire:B})}),i&&x&&R.jsx("span",{className:"p-4 text-[var(--color-primary)] animate-pulse block",children:"🔄 Regenerating..."}),i&&y&&R.jsx("div",{className:"flex items-center gap-1 p-4 text-red-500 text-sm cursor-pointer hover:underline",onClick:C,children:"Exit verification"})]})]}),P&&P.length>0&&R.jsx("div",{className:"mt-2",children:R.jsx(j0,{files:P,isPreview:!1,className:""})}),i&&w&&R.jsxs("div",{className:"flex items-end gap-2",children:[R.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full overflow-hidden",children:_&&R.jsx("img",{src:"./assets/indian-doctor.png",alt:"Apollo Icon",className:"w-full h-full object-cover scale-125"})}),w.type===en.PILL&&w.data.choices&&w.data.choices.length>0&&R.jsxs("div",{children:[R.jsx("div",{className:"text-xs text-[var(--color-muted-foreground)] mb-2 font-medium",children:z?"Option selected:":"Select an option:"}),R.jsx("div",{className:"flex flex-row gap-2 flex-wrap",children:w.data.choices.map((he,be)=>R.jsx(Ot,{variant:"outline",size:"sm",className:`justify-start text-sm font-normal border-[var(--color-primary)] h-9 rounded-lg w-fit min-w-0 ${z?"bg-gray-100 text-gray-500 cursor-not-allowed":"hover:bg-[var(--color-accent)] text-[var(--color-primary)]"}`,onClick:()=>!z&&(v==null?void 0:v({content:he,tool_use_id:w.tool_use_id})),disabled:d||z,children:R.jsx(pE,{text:he,maxWidth:"250px",className:"text-left"})},`${w.tool_use_id}-${be}`))})]}),w.type===en.MULTI&&w.data.choices&&w.data.choices.length>0&&R.jsxs("div",{className:"mt-3",children:[R.jsx("div",{className:"text-xs text-[var(--color-muted-foreground)] mb-2 font-medium",children:z?"Options selected:":"Select multiple options:"}),R.jsx(xk,{options:w.data.choices.map((he,be)=>({id:`${w.tool_use_id}-${be}`,label:he,value:he})),selectedValues:K,onSelectionChange:z?()=>{console.log("already responded")}:fe,additionalOption:w.data.additional_option,required:!1}),!z&&R.jsx(Ot,{variant:"outline",size:"sm",className:"mt-2 text-sm font-normal border-[var(--color-primary)] hover:bg-[var(--color-accent)] text-[var(--color-primary)] h-8 rounded-lg",onClick:ce,disabled:d||K.length===0,children:"Confirm"})]}),w.type===en.DOCTOR_CARD&&R.jsx(LB,{doctorDetails:w.data.doctor_details||{},callbacks:w.data.callbacks,refreshSession:m,handleRequestAppointment:E,onBook:he=>{var be,Be,Ke,Ue,Fe,We;v==null||v({content:`I want to book an appointment for ${((Be=(be=he.doctorData)==null?void 0:be.doctor)==null?void 0:Be.name)||"the doctor"} on ${he.date} for ${he.time}`,tool_use_id:w.tool_use_id,tool_use_params:{selected_date:he.date,selected_slot:he.time,doctor_id:(Ue=(Ke=he==null?void 0:he.doctorData)==null?void 0:Ke.doctor)==null?void 0:Ue.doctor_id,hospital_id:(Fe=he==null?void 0:he.doctorData)==null?void 0:Fe.hospital_id,region_id:(We=he==null?void 0:he.doctorData)==null?void 0:We.region_id}})},disabled:z,getAvailabilityDatesForAppointment:Z,getAvailableSlotsForAppointment:ie}),w.type===en.LAB_PACKAGE_CARD&&w.data.lab_packages&&w.data.lab_packages.length>0&&R.jsx(HB,{packages:w.data.lab_packages,disabled:z,onBook:he=>F==null?void 0:F(he)}),w.type===en.MOBILE_VERIFICATION&&w.data.uhids&&((U=w.data.uhids)==null?void 0:U.length)&&R.jsxs("div",{children:[R.jsx("div",{className:"text-xs text-[var(--color-muted-foreground)] mb-2 font-medium",children:z?"UHID selected:":"Select a UHID:"}),R.jsx("div",{className:"flex flex-row gap-2 flex-wrap",children:w.data.uhids.map((he,be)=>R.jsx(Ot,{variant:"outline",size:"sm",className:`justify-start text-sm font-normal border-[var(--color-primary)] h-9 rounded-lg w-fit min-w-0 ${z?"bg-gray-100 text-gray-500 cursor-not-allowed":"hover:bg-[var(--color-accent)] text-[var(--color-primary)]"}`,onClick:()=>!z&&(v==null?void 0:v({content:he.uhid,tool_use_id:w.tool_use_id})),disabled:d||z,children:R.jsx(pE,{text:`${he.fn||""} ${he.ln||""} ${he.age||""} (${he.uhid})`,maxWidth:"300px",className:"text-left"})},`${w.tool_use_id}-${be}`))})]})]}),c&&R.jsx("div",{className:"flex justify-end",children:R.jsx(BI,{actions:f,onActionClick:A,disabled:d})}),i&&!p&&n!=="1"&&!y&&u&&Q===Mn.NONE?R.jsxs("div",{className:"flex items-center gap-1 mt-3 ml-10 pb-4",children:[R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-[var(--color-muted)]",onClick:()=>le(Mn.LIKE),children:R.jsx(PA,{className:"h-3 w-3 text-black/50"})}),R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-[var(--color-muted)]",onClick:()=>le(Mn.DISLIKE),children:R.jsx(HA,{className:"h-3 w-3 text-black/50"})})]}):Q===Mn.LIKE?R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-6 w-6 pb-4 mt-3 ml-10 hover:bg-[var(--color-muted)]",disabled:!0,children:R.jsx(PA,{className:"h-3 w-3 text-primary"})}):Q===Mn.DISLIKE?R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-6 w-6 pb-4 mt-3 ml-10 hover:bg-[var(--color-muted)]",disabled:!0,children:R.jsx(HA,{className:"h-3 w-3 text-primary"})}):null,I&&R.jsx(KB,{title:"Tell us what went wrong",options:$k,onClose:ne,onOptionSelect:T})]})})})}class gE{constructor(a={}){Gt(this,"mediaRecorder",null);Gt(this,"mediaStream",null);Gt(this,"isInitialized",!1);Gt(this,"isActive",!1);Gt(this,"recordingStartTime",0);Gt(this,"autoPauseTimer",null);Gt(this,"audioChunks",[]);Gt(this,"config");Gt(this,"audioDataCallback",null);Gt(this,"errorCallback",null);Gt(this,"statusCallback",null);this.config=oe({mimeType:"audio/webm;codecs=opus",audioBitsPerSecond:128e3,maxRecordingDuration:9e5,autoPauseEnabled:!0},a)}initialize(){return et(this,null,function*(){try{if(!navigator.mediaDevices)throw new Error("Media devices API is not available. This usually means the page is not served over HTTPS or there are browser restrictions.");if(!window.MediaRecorder)throw new Error("MediaRecorder is not supported in this browser");const a=["audio/mp3","audio/ogg;codecs=opus","audio/mp4","audio/ogg","audio/wav"].filter(i=>MediaRecorder.isTypeSupported(i));if(a.length===0)throw new Error("No supported audio formats found in this browser");this.config.mimeType=a[0],console.log("Supported audio formats:",a),console.log("Selected format:",this.config.mimeType),console.log(`AudioService initialized with format: ${this.config.mimeType}`),this.isInitialized=!0}catch(a){throw new Error(`Audio initialization failed: ${a}`)}})}getInitializationStatus(){return this.isInitialized}start(a,i,l){return et(this,null,function*(){var u;if(!this.isInitialized)throw new Error("Not initialized");if(this.isActive)throw new Error("Already active");try{if(this.audioDataCallback=a,this.errorCallback=i||null,this.statusCallback=l||null,!navigator.mediaDevices)throw new Error("Media devices API is not available. This usually means the page is not served over HTTPS or there are browser restrictions.");this.mediaStream=yield navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,sampleRate:44100,channelCount:1}});let f;try{f=new MediaRecorder(this.mediaStream,{mimeType:this.config.mimeType,audioBitsPerSecond:this.config.audioBitsPerSecond})}catch(c){console.warn(`Failed to create MediaRecorder with ${this.config.mimeType}, trying without mimeType`),f=new MediaRecorder(this.mediaStream,{audioBitsPerSecond:this.config.audioBitsPerSecond}),this.config.mimeType=f.mimeType,console.log("Fallback MIME type selected:",this.config.mimeType)}if(this.mediaRecorder=f,this.mediaRecorder.state!=="inactive")throw new Error(`MediaRecorder in invalid state: ${this.mediaRecorder.state}`);this.setupMediaRecorderEvents(),this.mediaRecorder.start(),this.isActive=!0,this.recordingStartTime=Date.now(),this.audioChunks=[],this.config.autoPauseEnabled&&this.setupAutoPauseTimer(),(u=this.statusCallback)==null||u.call(this,"recording"),console.log("Audio recording started with MediaRecorder"),console.log("Using MIME type:",this.config.mimeType),console.log("MediaRecorder state:",this.mediaRecorder.state)}catch(f){throw console.error("Detailed error in start method:",f),new Error(`Failed to start: ${f}`)}})}stop(){var a,i;if(!(!this.isActive||!this.mediaRecorder))try{this.autoPauseTimer&&(clearTimeout(this.autoPauseTimer),this.autoPauseTimer=null),this.mediaRecorder.state==="recording"&&this.mediaRecorder.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(l=>l.stop()),this.mediaStream=null),this.isActive=!1,(a=this.statusCallback)==null||a.call(this,"stopped"),console.log("Audio recording stopped manually")}catch(l){(i=this.errorCallback)==null||i.call(this,new Error(`Failed to stop: ${l}`))}}cancel(){var a,i;if(!(!this.isActive||!this.mediaRecorder))try{this.autoPauseTimer&&(clearTimeout(this.autoPauseTimer),this.autoPauseTimer=null),this.audioChunks=[],this.mediaRecorder.ondataavailable=null,this.mediaRecorder.state==="recording"&&this.mediaRecorder.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(l=>l.stop()),this.mediaStream=null),this.isActive=!1,(a=this.statusCallback)==null||a.call(this,"cancelled")}catch(l){(i=this.errorCallback)==null||i.call(this,new Error(`Failed to cancel: ${l}`))}}pauseRecording(){var a,i;if(!(!this.isActive||!this.mediaRecorder))try{this.mediaRecorder.state==="recording"&&this.mediaRecorder.stop(),this.isActive=!1,(a=this.statusCallback)==null||a.call(this,"paused"),console.log("Audio recording paused automatically after 15 minutes")}catch(l){(i=this.errorCallback)==null||i.call(this,new Error(`Failed to pause recording: ${l}`))}}setupMediaRecorderEvents(){this.mediaRecorder&&(this.mediaRecorder.ondataavailable=a=>{console.log("media recorder data available"),a.data.size>0&&this.audioChunks.push(a.data)},this.mediaRecorder.onstop=()=>et(this,null,function*(){var a,i,l;try{if((a=this.audioChunks)!=null&&a.length){const u=new Blob(this.audioChunks,{type:this.config.mimeType}),f=yield this.blobToBase64(u),c=Date.now()-this.recordingStartTime,d={audio:f,format:this.config.mimeType,duration:c,timestamp:this.recordingStartTime};(i=this.audioDataCallback)==null||i.call(this,d),this.audioChunks=[]}}catch(u){console.error("Error processing recorded audio:",u),(l=this.errorCallback)==null||l.call(this,new Error(`Audio processing failed: ${u}`))}}),this.mediaRecorder.onerror=a=>{var i;console.error("MediaRecorder error:",a),(i=this.errorCallback)==null||i.call(this,new Error("MediaRecorder encountered an error"))},this.mediaRecorder.onstart=()=>{console.log("MediaRecorder started recording"),this.mediaRecorder&&(console.log("MediaRecorder state:",this.mediaRecorder.state),console.log("MediaRecorder MIME type:",this.mediaRecorder.mimeType))})}setupAutoPauseTimer(){this.autoPauseTimer&&clearTimeout(this.autoPauseTimer),this.autoPauseTimer=setTimeout(()=>{console.log("Auto-pause timer triggered after 15 minutes"),this.pauseRecording()},this.config.maxRecordingDuration)}blobToBase64(a){return new Promise((i,l)=>{const u=new FileReader;u.onload=()=>{if(typeof u.result=="string"){const f=u.result.split(",")[1];i(f)}else l(new Error("Failed to convert blob to base64"))},u.onerror=()=>l(new Error("FileReader error")),u.readAsDataURL(a)})}cleanup(){return et(this,null,function*(){this.cancel();try{this.mediaRecorder&&(this.mediaRecorder=null),this.mediaStream&&(this.mediaStream.getTracks().forEach(a=>a.stop()),this.mediaStream=null),this.isInitialized=!1,this.audioChunks=[],console.log("AudioService cleaned up")}catch(a){console.error("Error during cleanup:",a)}})}isServiceActive(){return this.isActive}isServiceInitialized(){return this.isInitialized}getConfig(){return oe({},this.config)}getCurrentDuration(){return this.isActive?Date.now()-this.recordingStartTime:0}getRemainingTime(){if(!this.isActive||!this.config.autoPauseEnabled)return 0;const a=Date.now()-this.recordingStartTime;return Math.max(0,this.config.maxRecordingDuration-a)}}function t4(){const[n,a]=G.useState(!1),[i,l]=G.useState(null),[u,f]=G.useState(0),[c,d]=G.useState(0),p=G.useRef(null),g=G.useRef(null),A=G.useCallback(()=>{g.current&&clearInterval(g.current),g.current=setInterval(()=>{if(p.current&&n){const z=p.current.getCurrentDuration(),P=p.current.getRemainingTime();f(z),d(P)}},1e3)},[n]),m=G.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=null)},[]),y=G.useCallback(z=>et(null,null,function*(){try{if(!p.current||!p.current.getInitializationStatus()){console.log("AudioService not initialized or missing, reinitializing..."),p.current&&p.current.cleanup();const P=new gE({maxRecordingDuration:2e5,autoPauseEnabled:!0,audioBitsPerSecond:128e3});yield P.initialize(),console.log("AudioService reinitialized in useAudioService"),p.current=P}l(null),f(0),d(p.current.getConfig().maxRecordingDuration),yield p.current.start(P=>{z(P),a(!1),m()},P=>{console.error("Audio error in useAudioService:",P),l(P),a(!1),m()},P=>{console.log("Audio status changed:",P),P==="recording"?(a(!0),A()):(P==="paused"||P==="stopped")&&(a(!1),m())})}catch(P){const N=P instanceof Error?P:new Error("Failed to start recording");l(N),a(!1),m()}}),[A,m]),E=G.useCallback(()=>et(null,null,function*(){try{console.log("Reinitializing AudioService..."),p.current&&p.current.cleanup();const z=new gE({maxRecordingDuration:9e5,autoPauseEnabled:!0,audioBitsPerSecond:128e3});return yield z.initialize(),console.log("AudioService reinitialized successfully"),p.current=z,l(null),!0}catch(z){return console.error("Failed to reinitialize AudioService:",z),l(z instanceof Error?z:new Error("Reinitialization failed")),!1}}),[]),C=G.useCallback(()=>{p.current&&(p.current.stop(),a(!1),m())},[m]),x=G.useCallback(()=>{p.current&&(p.current.cancel(),a(!1),m())},[m]),w=G.useCallback(()=>{l(null)},[]),v=G.useCallback(()=>{var z;return((z=p.current)==null?void 0:z.getCurrentDuration())||0},[]),D=G.useCallback(()=>{var z;return((z=p.current)==null?void 0:z.getRemainingTime())||0},[]),B=G.useCallback(()=>{m(),p.current&&p.current.cleanup()},[m]);return G.useEffect(()=>B,[B]),{isRecording:n,error:i,recordingDuration:u,remainingTime:c,start:y,stop:C,cancel:x,clearError:w,getCurrentDuration:v,getRemainingTime:D,reinitialize:E}}const n4=n=>{const a=Math.floor(n/60),i=n%60;return`${a.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`},Eh=2*1024*1024,mE=n=>{if(n===0)return"0 Bytes";const a=1024,i=["Bytes","KB","MB","GB"],l=Math.floor(Math.log(n)/Math.log(a));return parseFloat((n/Math.pow(a,l)).toFixed(2))+" "+i[l]};function r4({onSendMessage:n,onFinalAudioStream:a,onFileUpload:i,onInputChange:l,inlineText:u,placeholder:f="Message Apollo Assist...",disabled:c=!1,setError:d,mobileVerificationStatus:p}){const[g,A]=G.useState(""),[m,y]=G.useState(!1),[E,C]=G.useState(!1),[x,w]=G.useState("idle"),[v,D]=G.useState(0),[B,z]=G.useState([]),[P,N]=G.useState(null),[Z,ie]=G.useState(null),[F,K]=G.useState(!1),[re,Q]=G.useState(40),[q,I]=G.useState(!1),ue=G.useRef(null),fe=G.useRef(null),ce=G.useRef(null),le=_t(ee=>ee.connectionStatus),ne=_t(ee=>ee.isStreaming),T=_t(ee=>ee.error),{isRecording:_,error:V,recordingDuration:U,start:he,stop:be,cancel:Be,reinitialize:Ke}=t4(),{isOnline:Ue}=bd();G.useEffect(()=>()=>{ce.current&&clearInterval(ce.current)},[]),G.useEffect(()=>{if((ne||T||!c)&&K(!1),!ne&&!c&&le===kt.CONNECTED&&fe.current&&window.innerWidth&&window.innerWidth>768){const ee=setTimeout(()=>{var we;(we=fe.current)==null||we.focus()},100);return()=>clearTimeout(ee)}},[ne,T,c]),G.useEffect(()=>{u&&(A(u),w("idle"))},[u]),G.useEffect(()=>{g.trim()||(Q(40),fe.current&&(fe.current.style.height="40px"))},[g]),G.useEffect(()=>{if(fe.current&&g.trim()){const ee=fe.current;ee.style.height="auto",ee.style.overflow="hidden";const we=ee.scrollHeight,Oe=40,Ge=120,tt=Math.max(Oe,Math.min(we,Ge));ee.style.height=tt+"px",Q(tt),we>Ge?ee.style.overflow="auto":ee.style.overflow="hidden"}},[g]),G.useEffect(()=>{V&&(console.log("Audio error detected:",V),y(!1),N(V.message),ce.current&&clearInterval(ce.current))},[V,d]),G.useEffect(()=>{!c&&!ne&&(N(null),V||I(!1),V&&Ke&&!q&&(console.log("Attempting to reinitialize AudioService..."),I(!0),Ke().then(ee=>{ee?(console.log("AudioService reinitialized successfully"),N(null),I(!1)):console.log("AudioService reinitialization failed, will not retry")}).catch(ee=>{console.error("AudioService reinitialization error:",ee)})))},[c,ne,V,Ke,q]),G.useEffect(()=>{_&&D(Math.floor(U/1e3))},[U,_]),G.useEffect(()=>{E&&(m&&ge(),Y())},[E]);const Fe=()=>et(null,null,function*(){try{(yield navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(we=>we.stop()),N(null),console.log("Microphone permission granted, error cleared")}catch(ee){if(ee instanceof DOMException&&ee.name==="NotAllowedError"){console.log("Microphone permission denied");const we=yield We();console.log("Permission state:",we),we==="denied"?(console.log("Setting error:","Microphone access is blocked. You'll need to manually enable it in your browser settings."),d({title:"Microphone access is blocked.",description:"Enable it in your browser settings."})):(console.log("Setting error:","Microphone access denied. Please allow microphone permissions when prompted."),d({title:"Microphone access is denied.",description:" Please allow microphone permissions when prompted."}))}else console.error("Error checking microphone permission:",ee),d({title:"Unable to access microphone.",description:" Please check your device and try again."})}}),We=()=>et(null,null,function*(){try{return(yield navigator.permissions.query({name:"microphone"})).state}catch(ee){return console.log("Could not check permission state:",ee),"unknown"}}),rt=G.useMemo(()=>g.trim()||B.length>0,[g,B]),Ct=G.useMemo(()=>{if(p.active){if(p.active&&p.isSending&&p.stage===as.MOBILE_NUMBER)return"Sending OTP to your mobile number..."}else return null;return null},[p]),Mt=G.useMemo(()=>le!==kt.CONNECTED||!Ue?!0:T&&(T!=null&&T.title)&&le===kt.CONNECTED?(console.log("input enabled bcus of valid error"),!1):p.isSending?(console.log("input disabled bcus of mobile verification is sending"),!0):(console.log("input enabled/disabled bcus ",c,ne,F),c||ne||F),[T,le,c,ne,F,Ue,p.isSending]),S=()=>et(null,null,function*(){try{D(0),ie(null),yield he(ee=>{console.log("audio data arrived"),ie(ee),C(!0)}),ce.current=setInterval(()=>{D(ee=>ee+1)},1e3)}catch(ee){if(console.error("Error starting recording:",ee),ee instanceof Error&&ee.message.includes("Not initialized")&&!q){console.log("AudioService not initialized in startRecording, attempting reinitialization..."),I(!0);try{if(yield Ke())console.log("AudioService reinitialized in startRecording, trying again..."),yield S();else throw new Error("Failed to reinitialize AudioService")}catch(we){throw console.error("Failed to reinitialize AudioService in startRecording:",we),new Error("Audio service unavailable")}}else throw ee}}),ge=()=>{console.log("called stop recording"),ce.current&&clearInterval(ce.current),y(!1),w("processing"),be()},de=()=>{Be(),y(!1),ie(null)},Y=G.useCallback(()=>et(null,null,function*(){if(!E){console.log("isAudiostreaming is false");return}if(!Z){console.error("No audio available");return}try{K(!0),C(!1),w("transcribing");const ee=yield new Promise((we,Oe)=>{const Ge=setTimeout(()=>Oe(new Error("Timed out waiting for audio")),5e3),tt=()=>{Z?(clearTimeout(Ge),we(Z)):setTimeout(tt,100)};tt()});yield a(ee)}catch(ee){console.error("Error sending recording:",ee),d({title:"Failed to send audio message. Please try again."}),K(!1),w("idle");const we={audio:"",format:"audio/mp4",duration:0,timestamp:Date.now()};yield a(we)}}),[E]),j=()=>et(null,null,function*(){if(console.log("called handle send",ne),(g.trim()||B.length>0||E)&&!c&&!F)try{if(p.active||K(!0),g.trim()&&B.length===0&&n({content:g.trim()}),B.length>0){const ee=B.reduce((Oe,Ge)=>Oe+Ge.size,0);if(ee>Eh){d({title:`Total file size (${mE(ee)}) exceeds the ${mE(Eh)} limit. Please select smaller files.`}),z([]);return}const we=new DataTransfer;B.forEach(Oe=>we.items.add(Oe)),i(we.files,g.trim()),z([])}A(""),z([]),y(!1)}catch(ee){console.error("Error in handleSend:",ee),d({title:"Failed to send message. Please try again."})}finally{}}),H=ee=>{ee.key==="Enter"&&!ee.shiftKey&&(ee.preventDefault(),j())},J=()=>et(null,null,function*(){if(!m&&!_)try{yield Fe(),P||(y(!0),yield S())}catch(ee){if(console.error("Error starting recording:",ee),ee instanceof Error&&ee.message.includes("Not initialized")&&!q){console.log("AudioService not initialized, attempting reinitialization..."),I(!0);try{(yield Ke())?(console.log("AudioService reinitialized, trying to start recording again..."),y(!0),yield S()):d({title:"Failed to initialize audio service. Please try again."})}catch(we){console.error("Failed to reinitialize AudioService:",we),d({title:"Audio service unavailable. Please try again."})}}else d({title:"Failed to start recording. Please try again."})}else _&&(console.log("called mic click and recording is true"),ge())}),pe=()=>{var ee;(ee=ue.current)==null||ee.click()},$=ee=>{if(console.log("handleFileChange called"),ee.target.files&&ee.target.files.length>0){const we=Array.from(ee.target.files),Oe=tt=>{const st=tt.type.toLowerCase(),Rt=tt.name.toLowerCase().split(".").pop()||"";return st&&["application/pdf","image/jpeg","image/jpg","image/png","image/heic","image/heif","application/vnd.openxmlformats-officedocument.wordprocessingml.document","image/tiff","text/plain","text/markdown"].some(yt=>st.includes(yt))?!0:!st||st===""?["pdf","jpg","jpeg","png","heic","docx","tiff","txt","md"].includes(Rt):!1},Ge=we.filter(tt=>(console.log("file",tt),Oe(tt)?!0:(d({title:`File type not supported: ${tt.name}`,description:"Only PDF, images (JPG, JPEG, PNG, HEIC), documents (DOCX, TIFF), and text files (TXT, MD) are allowed."}),!1)));Ge.length>0&&z(tt=>[...tt,...Ge]),ee.target.value=""}},ye=ee=>{A(ee.target.value),l==null||l(ee.target.value)},Re=ee=>{const we=ee.currentTarget;we.style.height="auto",we.style.overflow="hidden";const Oe=we.scrollHeight,Ge=40,tt=120,st=Math.max(Ge,Math.min(Oe,tt));we.style.height=st+"px",Q(st),Oe>tt?we.style.overflow="auto":we.style.overflow="hidden"},ke=B.length>0&&!m&&!_,te=re>40||ke;return R.jsxs("div",{className:`bg-[var(--color-background)] border border-[var(--color-primary)] mx-4 flex-shrink-0 ${te?"rounded-lg px-3 py-2":"rounded-full px-2 py-0.5"} flex flex-col ${ke?"gap-2":"gap-0"}`,children:[ke&&R.jsx("div",{className:"w-full",children:R.jsx(j0,{files:B,onRemoveFile:ee=>z(we=>we.filter((Oe,Ge)=>Ge!==ee)),isPreview:!0,className:`${F?"opacity-50":""}`})}),R.jsxs("div",{className:`flex w-full gap-2 ${ke?"items-end":"items-center"}`,children:[R.jsx("input",{ref:ue,type:"file",multiple:!0,accept:".pdf,.jpg,.jpeg,.png,.heic,.docx,.tiff,.txt,.md,application/pdf,image/jpeg,image/png,image/heic,image/heif,image/tiff,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/plain,text/markdown",onChange:$,className:"hidden","data-max-size":Eh.toString()}),m||_?R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-red-600 hover:bg-red-100 flex-shrink-0",onClick:de,disabled:F,children:R.jsx(RI,{className:"h-4 w-4"})}):R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-[var(--color-accent)] flex-shrink-0",onClick:pe,disabled:Mt||(p==null?void 0:p.active),children:R.jsx(Ay,{className:"h-4 w-4 text-[var(--color-primary)]"})}),m||_?R.jsx("div",{className:"flex-1 flex items-center justify-center px-3 py-2",children:_&&R.jsxs("div",{className:"relative",children:[R.jsx("img",{src:Ak,alt:"Voice listening",className:"h-6 w-56"}),R.jsxs("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-transparent to-transparent pointer-events-none",children:[R.jsx("div",{className:"absolute left-0 top-0 w-4 h-full bg-gradient-to-r from-white to-transparent"}),R.jsx("div",{className:"absolute right-0 top-0 w-4 h-full bg-gradient-to-l from-white to-transparent"})]})]})}):R.jsx("div",{className:"relative w-full",children:R.jsx($S,{ref:fe,value:g,onChange:ye,onInput:Re,onKeyPress:H,autoFocus:!c&&le===kt.CONNECTED&&!ne&&window.innerWidth>768,placeholder:Ct||(ne||c?"Please wait for response...":F?x==="processing"?"Processing your voice...":x==="transcribing"?"Transcribing recording..":"Sending message...":f),disabled:Mt,className:"border-0 shadow-none px-0 py-2 focus-visible:ring-0 focus-visible:outline-none focus-visible:border-0 focus-visible:ring-transparent focus-visible:ring-offset-0 text-sm resize-none break-word overflow-hidden",rows:1,style:{minHeight:"40px",maxHeight:"120px",fontSize:window.innerWidth<=768?"16px":"14px"}})}),(m||_)&&R.jsx("div",{className:"flex flex-col items-end text-sm font-mono text-[var(--color-primary)]",children:R.jsx("span",{className:F?"opacity-50":"",children:n4(v)})}),m||_?R.jsx("div",{className:"flex items-center gap-2",children:R.jsx(Ot,{size:"sm",className:"h-8 w-8 p-0 bg-[var(--color-primary)] hover:bg-[var(--color-primary)]/90 flex-shrink-0 rounded-full",onClick:J,disabled:F,children:R.jsx(AI,{className:"h-4 w-4 white"})})}):R.jsx(R.Fragment,{children:rt?R.jsx(Ot,{size:"sm",className:"h-8 w-8 py-2 bg-[var(--color-primary)] hover:bg-[var(--color-primary)]/90 flex-shrink-0 rounded-full",onClick:j,disabled:Mt||F,children:F?R.jsx(ql,{className:"h-4 w-4 animate-spin text-[var(--color-primary-foreground)]"}):R.jsx(Sd,{className:"h-4 w-4 text-[var(--color-primary-foreground)]"})}):R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-[var(--color-accent)] flex-shrink-0",onClick:J,disabled:c||ne||!!P||F||(p==null?void 0:p.active),children:R.jsx(kI,{className:"h-4 w-4 text-[var(--color-primary)]"})})})]})]})}function i4({onSendMobile:n,isLoading:a=!1,error:i=null,disabled:l=!1,placeholder:u="Mobile Number"}){const[f,c]=G.useState(""),d=G.useRef(null);G.useEffect(()=>{d.current&&d.current.focus()},[]);const p=y=>{const E=y.target.value.replace(/\D/g,"");c(E)},g=()=>{l||a||f.length===10&&n({content:f})},A=y=>{y.key==="Enter"&&f.length===10&&g()},m=f.length===10;return R.jsxs("div",{className:"px-4 py-3 space-y-4",children:[R.jsxs("div",{className:"flex items-center gap-3",children:[R.jsxs(Ot,{variant:"outline",size:"sm",className:"h-12 px-3 flex items-center gap-2 border-[var(--color-border)] hover:bg-[var(--color-accent)] rounded-xl",disabled:l,children:[R.jsx("img",{src:"./assets/indian-flag.svg",alt:"Indian flag",className:"w-4 h-4 rounded-full"}),R.jsx("span",{className:"text-sm font-medium",children:"+91"})]}),R.jsx("div",{className:"flex-1",children:R.jsx(fS,{ref:d,type:"tel",value:f,onChange:p,onKeyPress:A,placeholder:a?"Sending OTP...":u,disabled:l||a,className:"h-12 rounded-xl text-base border-[var(--color-muted-foreground)] focus:border-[var(--color-primary-primary)] focus:ring-2 focus:ring-[var(--color-primary-primary)]/20 bg-[var(--color-input)]",maxLength:10})}),R.jsx(Ot,{onClick:g,disabled:!m||l||a,size:"sm",className:"h-12 w-12 p-0 bg-[var(--color-primary)] hover:bg-[var(--color-primary)]/90 rounded-lg",children:a?R.jsx(ql,{className:"h-4 w-4 animate-spin text-[var(--color-primary-foreground)]"}):R.jsx(Sd,{className:"h-4 w-4 text-[var(--color-primary-foreground)]"})})]}),i&&R.jsx("div",{className:"text-sm text-red-500 text-center",children:i})]})}function a4({mobileNumber:n,onSendOTP:a,isLoading:i=!1,error:l=null,disabled:u=!1}){const[f,c]=G.useState(""),d="min-w-[2.5rem] w-full max-w-[4rem] h-10 sm:h-12 text-center text-base sm:text-lg font-semibold border-2 border-[var(--color-border)] rounded-lg data-[active=true]:border-[var(--color-primary)] data-[active=true]:ring-2 data-[active=true]:ring-[var(--color-primary)]/20 flex-1",p=A=>{c(A),A.length===6&&a({content:A})},g=()=>{f.length===6&&a({content:f})};return R.jsxs("div",{className:"px-4 py-3 space-y-4",children:[R.jsx("div",{className:"flex items-center justify-start px-3",children:R.jsx("div",{className:"flex items-center gap-2",children:R.jsxs("span",{className:"text-sm text-[var(--color-muted-foreground)]",children:["OTP sent to ",n]})})}),R.jsxs("div",{className:"flex items-center justify-center gap-2 sm:gap-3",children:[R.jsx(jk,{maxLength:6,value:f,onChange:p,disabled:u||i,autoFocus:!0,children:R.jsxs(zk,{className:"gap-1 sm:gap-2",children:[R.jsx(To,{index:0,className:d}),R.jsx(To,{index:1,className:d}),R.jsx(To,{index:2,className:d}),R.jsx(To,{index:3,className:d}),R.jsx(To,{index:4,className:d}),R.jsx(To,{index:5,className:d})]})}),R.jsx(Ot,{onClick:g,disabled:f.length!==6||u||i,size:"sm",className:"h-10 w-10 sm:h-12 sm:w-12 p-0 bg-[var(--color-primary)] hover:bg-[var(--color-primary)]/90 rounded-full flex-shrink-0",children:i?R.jsx(ql,{className:"h-4 w-4 animate-spin text-[var(--color-primary-foreground)]"}):R.jsx(Sd,{className:"h-4 w-4 text-[var(--color-primary-foreground)]"})})]}),l&&R.jsx("div",{className:"text-sm text-red-500 text-center",children:l})]})}const wh=(n,a)=>{switch(n.error.code){case Vt.OTP_NOT_FOUND.code:return{success:!1,data:{error:{code:Vt.OTP_NOT_FOUND.code,msg:Vt.OTP_NOT_FOUND.msg}}};case Vt.INVALID_OTP.code:return{success:!1,data:{error:{code:Vt.INVALID_OTP.code,msg:Vt.INVALID_OTP.msg}}};case Vt.TOOL_ERROR.code:return{success:!1,data:{error:{code:Vt.TOOL_ERROR.code,msg:a?Vt.TOOL_ERROR.msg:Vt.INVALID_MOBILE_NUMBER.msg}}};default:return a?{success:!1,data:{error:{code:Vt.TOOL_ERROR.code,msg:Vt.TOOL_ERROR.msg}}}:{success:!1,data:{error:{code:Vt.TOOL_ERROR.code,msg:Vt.INVALID_MOBILE_NUMBER.msg}}}}},AE=(n,a,i,l)=>et(null,null,function*(){var u;try{const f=yield Fa({toolParams:oe({mobile_number:n.trim(),stage:as.MOBILE_NUMBER},l&&{lead_description:l}),wrapperOptions:{session_id:a,tool_name:Na.MOBILE_VERIFICATION,onSessionRefresh:i}});if(!f.ok){const d=yield f.json().catch(()=>({}));return(u=d==null?void 0:d.error)!=null&&u.code?wh(d,!1):{success:!1,data:{error:{msg:Vt.INVALID_MOBILE_NUMBER.msg}}}}const c=yield f.json();return c.error?{success:!1,data:{error:c.error}}:c.status==="success"?{success:!0,data:c}:{success:!1,data:{error:{msg:Vt.INVALID_MOBILE_NUMBER.msg}}}}catch(f){return console.error("Mobile verification error:",f),{success:!1,data:{error:{msg:f instanceof Error?f.message:Vt.INVALID_MOBILE_NUMBER.msg}}}}}),o4=(n,a,i,l,u)=>et(null,null,function*(){var f;try{const c=yield Fa({toolParams:oe({mobile_number:a.trim(),otp:n.trim(),stage:as.OTP},u&&{lead_description:u}),wrapperOptions:{session_id:i,tool_name:Na.MOBILE_VERIFICATION,onSessionRefresh:l}});if(u==="callback requested")return{success:!0,data:{message:"Appointment requested successfully. You will get a callback soon."}};if(!c.ok){const p=yield c.json().catch(()=>({}));return(f=p==null?void 0:p.error)!=null&&f.code?wh(p,!0):{success:!1,data:{error:{msg:Vt.INVALID_OTP.msg}}}}const d=yield c.json().catch(()=>({}));return d.status==="success"?{success:!0,data:d}:{success:!1,data:{error:{msg:Vt.INVALID_OTP.msg}}}}catch(c){return console.error("OTP verification error:",c),{success:!1,data:{error:{msg:c instanceof Error?c.message:Vt.INVALID_OTP.msg}}}}}),l4=(n,a,i)=>et(null,null,function*(){var l;try{const u=yield Fa({toolParams:{selected_uhid:n,stage:as.UHID},wrapperOptions:{session_id:a,tool_name:Na.MOBILE_VERIFICATION,onSessionRefresh:i}});if(!u.ok){const c=yield u.json().catch(()=>({}));return(l=c==null?void 0:c.error)!=null&&l.code?wh(c,!1):{success:!1,data:{error:{msg:Vt.INVALID_UHID.msg}}}}const f=yield u.json();return f.status==="success"?{success:!0,data:f}:{success:!1,data:{error:{msg:Vt.INVALID_UHID.msg}}}}catch(u){return console.error("Uhid verification error:",u),{success:!1,data:{error:{msg:Vt.INVALID_UHID.msg}}}}}),s4=(n,a,i)=>et(null,null,function*(){var l,u,f,c;if(!(n!=null&&n.doctor_id))return{success:!1,data:null};try{const d=yield Fa({toolParams:{doctor_id:n.doctor_id,hospital_id:n.hospital_id||"",region_id:n.region_id||""},wrapperOptions:{session_id:a,tool_name:Na.AVAILABILITY_DATES,onSessionRefresh:i}});if(!(d!=null&&d.ok)){const g=yield d.json();if(d.status===412&&((l=g==null?void 0:g.error)==null?void 0:l.code)==="bot_error_display"&&((u=g==null?void 0:g.error)!=null&&u.msg))return{success:!1,data:{error:{msg:(f=g==null?void 0:g.error)==null?void 0:f.msg}}};throw new Error("Failed to load availability dates")}const p=yield d.json();return(c=p==null?void 0:p.available_dates)!=null&&c.length?{success:!0,data:p}:(console.error("Available dates are not coming in response",d),{success:!1,data:null})}catch(d){return console.error("Error loading availability dates:",d),{success:!1,data:null}}}),u4=(n,a,i,l)=>et(null,null,function*(){var u,f,c,d;if(!(a!=null&&a.doctor_id)||!n)return{success:!1,data:null};try{const p=yield Fa({toolParams:{doctor_id:a.doctor_id,appointment_date:n,hospital_id:a.hospital_id||"",region_id:a.region_id||""},wrapperOptions:{session_id:i,tool_name:Na.AVAILABILITY_SLOTS,onSessionRefresh:l}});if(!(p!=null&&p.ok)){const A=yield p.json();if(p.status===412&&((u=A==null?void 0:A.error)==null?void 0:u.code)==="bot_error_display"&&((f=A==null?void 0:A.error)!=null&&f.msg))return{success:!1,data:{error:{msg:(c=A==null?void 0:A.error)==null?void 0:c.msg}}};throw new Error("Failed to load availability slots")}const g=yield p.json();return(d=g==null?void 0:g.slots)!=null&&d.length?{success:!0,data:g}:(console.error("Available slots are not coming in response",p),{success:!1,data:null})}catch(p){return console.error("Error loading slots for date:",p),{success:!1,data:null}}}),c4=(n,a,i,l)=>et(null,null,function*(){try{const u=`${Yr.BASE_API_URL}/med-assist/session/${n}/${a}`,f=yield fetch(u,{method:"PATCH",headers:{"Content-Type":"application/json","X-agent-id":Yr.X_AGENT_ID},body:JSON.stringify({feedback:i,feedback_reason:l})});if(!f.ok)throw new Error("Failed to patch feedback message");return f.json()}catch(u){throw console.error("Error patching feedback message:",u),u}});var as=(n=>(n.MOBILE_NUMBER="mobile",n.OTP="otp",n.UHID="uhid",n))(as||{});function f4({title:n="Apollo Assist",firstUserMessage:a="",className:i="",onClose:l,onStartSession:u,onExpand:f,isExpanded:c=!1,isMobile:d=!1,isLoading:p=!1,isOnline:g=!0,isFullMode:A=!1}){const[m,y]=G.useState([{id:"1",content:"Hi, I'm Apollo Assist, your personal support for all medical needs. How can I help you?",isBot:!0,isStored:!0,feedback:Mn.NONE}]),[E,C]=G.useState(null),[x,w]=G.useState(null),[v,D]=G.useState(!1),[B,z]=G.useState(!1),[P,N]=G.useState({active:!1,isSending:!1,stage:"mobile",uhids:[],tool_use_id:null,mobile_number:null}),[Z,ie]=G.useState(!1),F=G.useRef(P),K=G.useRef(!1),{connectionStatus:re,showRetryButton:Q,startNewConnection:q,error:I,clearError:ue,setError:fe,isStreaming:ce,sessionId:le,sessionToken:ne,clearSession:T,refreshSession:_,getMessagesForSession:V,addMessageToSession:U,updateMessageInSession:he,setInlineText:be,inlineText:Be,setResponseTimeoutId:Ke,clearResponseTimeout:Ue,setStreamingTimeoutId:Fe,clearStreamingTimeout:We,setLastStreamingActivity:rt,setIsBotIconAnimating:Ct}=_t();G.useEffect(()=>(!le&&!ne&&u?(u(),z(!0)):le&&ne&&et(null,null,function*(){try{const De=yield uy(le);!De.success&&!De.retry?(yield T(),yield u==null?void 0:u(!0),z(!0)):(!De.success&&De.retry&&((yield _())||(yield T(),yield u==null?void 0:u(!0))),z(!0))}catch(De){console.error("Error checking session details:",De),yield T(),yield u==null?void 0:u(!0),z(!0)}}),()=>{K.current=!0}),[]),G.useMemo(()=>{if(a!=null&&a.trim()&&B&&le&&!p&&re===kt.CONNECTED&&!ce&&!Z){const me=setTimeout(()=>{ee({content:a.trim()}),ie(!0)},0);return()=>clearTimeout(me)}},[a,B,le,re]),G.useEffect(()=>()=>{if(m.length>0&&!m[m.length-1].isStored&&le&&K.current){const me=ze(oe({},m[m.length-1]),{isStored:!0});y(De=>{const Pe=[...De];return Pe[Pe.length-1]=me,Pe}),U(le,me)}},[m]),G.useEffect(()=>{if(le||se(),D(!1),w(null),le){const me=V(le);if(me.length>0)y(me);else{const De={id:"1",content:"Hi, I'm Apollo Assist, your personal support for all medical needs. How can I help you?",isBot:!0,isStored:!0,feedback:Mn.NONE};U(le,De),y([De])}}},[le]);const Mt=G.useMemo(()=>le&&ne&&B?{sessionId:le,auth:{token:ne}}:null,[le,ne,B]),{webSocketService:S,setFilesForUpload:ge,sendFileUploadRequest:de,sendAudioData:Y,regenerateResponse:j,sendChatMessage:H,retryLastMessage:J,sendHiddenChatMessage:pe,triggerSessionRefresh:$}=uI(Mt,(me,De)=>{D(!1),w(null),y(Pe=>{var Ft,jt;const $e=Pe[Pe.length-1];if(($e==null?void 0:$e.id)===De&&($e!=null&&$e.isBot)&&(me==null?void 0:me.length)>((Ft=$e==null?void 0:$e.content)==null?void 0:Ft.length)){const ft=[...Pe];return ft[ft.length-1]=ze(oe({},$e),{content:me,isRegenerating:!1,isStored:!1}),ft}else{if(($e==null?void 0:$e.id)===De&&($e!=null&&$e.isBot)&&(me==null?void 0:me.length)<=((jt=$e==null?void 0:$e.content)==null?void 0:jt.length))return Pe;{const ft={id:De||Date.now().toString(),content:me,isBot:!0,isStored:!1,feedback:Mn.NONE};return[...Pe,ft]}}})},me=>{D(!1),w(me)},me=>{D(!1),C(me)},(me,De)=>et(null,null,function*(){var Pe,$e,Ft,jt,ft,Er,ta,Pa;if(D(!1),y(Rn=>{let On=-1;if(On=Rn.findIndex(Qt=>Qt.id==De),On!==-1&&!Rn[On].isResponded){const Qt=[...Rn];return Qt[On]=ze(oe({},Qt[On]),{commonContentData:me}),Qt}else{const Qt={id:De||Date.now().toString(),content:"",isBot:!0,commonContentData:me,isStored:!0,feedback:Mn.NONE};return U(le,Qt),[...Rn,Qt]}}),me.type==="mobile_verification"&&(($e=(Pe=me==null?void 0:me.data)==null?void 0:Pe.callbacks)!=null&&$e.tool_callback_mobile_verification))if((Ft=me==null?void 0:me.data)!=null&&Ft.mobile_number){N(Qt=>{var fn;return ze(oe({},Qt),{active:!0,isSending:!0,tool_use_id:me==null?void 0:me.tool_use_id,mobile_number:((fn=me==null?void 0:me.data)==null?void 0:fn.mobile_number)||null})}),w("Sending OTP to your mobile number...");let Rn="",On=!1;try{const Qt=yield AE((jt=me==null?void 0:me.data)==null?void 0:jt.mobile_number,le,$);Qt!=null&&Qt.success&&((ft=Qt==null?void 0:Qt.data)!=null&&ft.message)?(Rn=((Er=Qt==null?void 0:Qt.data)==null?void 0:Er.message)||"OTP sent successfully to your mobile number, please enter 6 digit OTP",On=!0):(Rn=((Pa=(ta=Qt==null?void 0:Qt.data)==null?void 0:ta.error)==null?void 0:Pa.msg)||"Failed to send OTP. Please try again.",On=!1)}catch(Qt){Rn="Failed to send OTP. Please try again.",On=!1}finally{w(null),N(Qt=>ze(oe({},Qt),{active:On,isSending:!1,stage:On?"otp":"mobile"})),y(Qt=>{const fn=[...Qt],qe=fn.length-1;if(fn.length>0&&fn[qe].isBot){const Un=`${fn[qe].content}
|
|
493
|
+
${i?"rounded-bl-none text-[var(--color-foreground)] bg-[var(--color-background-primary-default)]":"rounded-br-none text-[var(--color-black-800)] bg-[var(--color-background-primary-subtle)]"}`,children:[a&&i&&R.jsx("div",{className:"markdown-content p-4",children:R.jsx(U0,{remarkPlugins:[$Q],children:a})}),a&&!i&&R.jsx("div",{className:"text-sm break-word p-4",children:a}),i&&g&&R.jsx("div",{className:"p-4 bg-gradient-to-r from-[var(--color-primary)] via-[var(--color-primary-400)] to-[var(--color-primary-600)] bg-clip-text text-transparent font-medium",children:R.jsx(U0,{children:g})}),i&&p&&!g&&R.jsx("span",{className:"animate-pulse p-4 block",children:"..."}),i&&(D==null?void 0:D.length)&&D.length>0&&R.jsx("div",{className:"px-4 pb-4",children:R.jsx(GB,{tips:D,onTipsExpire:B})}),i&&x&&R.jsx("span",{className:"p-4 text-[var(--color-primary)] animate-pulse block",children:"🔄 Regenerating..."}),i&&y&&R.jsx("div",{className:"flex items-center gap-1 p-4 text-red-500 text-sm cursor-pointer hover:underline",onClick:C,children:"Exit verification"})]})]}),P&&P.length>0&&R.jsx("div",{className:"mt-2",children:R.jsx(j0,{files:P,isPreview:!1,className:""})}),i&&w&&R.jsxs("div",{className:"flex items-end gap-2",children:[R.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full overflow-hidden",children:_&&R.jsx("img",{src:"./assets/indian-doctor.png",alt:"Apollo Icon",className:"w-full h-full object-cover scale-125"})}),w.type===en.PILL&&w.data.choices&&w.data.choices.length>0&&R.jsxs("div",{children:[R.jsx("div",{className:"text-xs text-[var(--color-muted-foreground)] mb-2 font-medium",children:z?"Option selected:":"Select an option:"}),R.jsx("div",{className:"flex flex-row gap-2 flex-wrap",children:w.data.choices.map((he,be)=>R.jsx(Ot,{variant:"outline",size:"sm",className:`justify-start text-sm font-normal border-[var(--color-primary)] h-9 rounded-lg w-fit min-w-0 ${z?"bg-gray-100 text-gray-500 cursor-not-allowed":"hover:bg-[var(--color-accent)] text-[var(--color-primary)]"}`,onClick:()=>!z&&(v==null?void 0:v({content:he,tool_use_id:w.tool_use_id})),disabled:d||z,children:R.jsx(pE,{text:he,maxWidth:"250px",className:"text-left"})},`${w.tool_use_id}-${be}`))})]}),w.type===en.MULTI&&w.data.choices&&w.data.choices.length>0&&R.jsxs("div",{className:"mt-3",children:[R.jsx("div",{className:"text-xs text-[var(--color-muted-foreground)] mb-2 font-medium",children:z?"Options selected:":"Select multiple options:"}),R.jsx(xk,{options:w.data.choices.map((he,be)=>({id:`${w.tool_use_id}-${be}`,label:he,value:he})),selectedValues:K,onSelectionChange:z?()=>{console.log("already responded")}:fe,additionalOption:w.data.additional_option,required:!1}),!z&&R.jsx(Ot,{variant:"outline",size:"sm",className:"mt-2 text-sm font-normal border-[var(--color-primary)] hover:bg-[var(--color-accent)] text-[var(--color-primary)] h-8 rounded-lg",onClick:ce,disabled:d||K.length===0,children:"Confirm"})]}),w.type===en.DOCTOR_CARD&&R.jsx(LB,{doctorDetails:w.data.doctor_details||{},callbacks:w.data.callbacks,refreshSession:m,handleRequestAppointment:E,onBook:he=>{var be,Be,Ke,Ue,Fe,We;v==null||v({content:`I want to book an appointment for ${((Be=(be=he.doctorData)==null?void 0:be.doctor)==null?void 0:Be.name)||"the doctor"} on ${he.date} for ${he.time}`,tool_use_id:w.tool_use_id,tool_use_params:{selected_date:he.date,selected_slot:he.time,doctor_id:(Ue=(Ke=he==null?void 0:he.doctorData)==null?void 0:Ke.doctor)==null?void 0:Ue.doctor_id,hospital_id:(Fe=he==null?void 0:he.doctorData)==null?void 0:Fe.hospital_id,region_id:(We=he==null?void 0:he.doctorData)==null?void 0:We.region_id}})},disabled:z,getAvailabilityDatesForAppointment:Z,getAvailableSlotsForAppointment:ie}),w.type===en.LAB_PACKAGE_CARD&&w.data.lab_packages&&w.data.lab_packages.length>0&&R.jsx(HB,{packages:w.data.lab_packages,disabled:z,onBook:he=>F==null?void 0:F(he)}),w.type===en.MOBILE_VERIFICATION&&w.data.uhids&&((U=w.data.uhids)==null?void 0:U.length)&&R.jsxs("div",{children:[R.jsx("div",{className:"text-xs text-[var(--color-muted-foreground)] mb-2 font-medium",children:z?"UHID selected:":"Select a UHID:"}),R.jsx("div",{className:"flex flex-row gap-2 flex-wrap",children:w.data.uhids.map((he,be)=>R.jsx(Ot,{variant:"outline",size:"sm",className:`justify-start text-sm font-normal border-[var(--color-primary)] h-9 rounded-lg w-fit min-w-0 ${z?"bg-gray-100 text-gray-500 cursor-not-allowed":"hover:bg-[var(--color-accent)] text-[var(--color-primary)]"}`,onClick:()=>!z&&(v==null?void 0:v({content:he.uhid,tool_use_id:w.tool_use_id})),disabled:d||z,children:R.jsx(pE,{text:`${he.fn||""} ${he.ln||""} ${he.age||""} (${he.uhid})`,maxWidth:"300px",className:"text-left"})},`${w.tool_use_id}-${be}`))})]})]}),c&&R.jsx("div",{className:"flex justify-end",children:R.jsx(BI,{actions:f,onActionClick:A,disabled:d})}),i&&!p&&n!=="1"&&!y&&u&&Q===Mn.NONE?R.jsxs("div",{className:"flex items-center gap-1 mt-3 ml-10 pb-4",children:[R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-[var(--color-muted)]",onClick:()=>le(Mn.LIKE),children:R.jsx(PA,{className:"h-3 w-3 text-black/50"})}),R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-[var(--color-muted)]",onClick:()=>le(Mn.DISLIKE),children:R.jsx(HA,{className:"h-3 w-3 text-black/50"})})]}):Q===Mn.LIKE?R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-6 w-6 pb-4 mt-3 ml-10 hover:bg-[var(--color-muted)]",disabled:!0,children:R.jsx(PA,{className:"h-3 w-3 text-primary"})}):Q===Mn.DISLIKE?R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-6 w-6 pb-4 mt-3 ml-10 hover:bg-[var(--color-muted)]",disabled:!0,children:R.jsx(HA,{className:"h-3 w-3 text-primary"})}):null,I&&R.jsx(KB,{title:"Tell us what went wrong",options:$k,onClose:ne,onOptionSelect:T})]})})})}class gE{constructor(a={}){Gt(this,"mediaRecorder",null);Gt(this,"mediaStream",null);Gt(this,"isInitialized",!1);Gt(this,"isActive",!1);Gt(this,"recordingStartTime",0);Gt(this,"autoPauseTimer",null);Gt(this,"audioChunks",[]);Gt(this,"config");Gt(this,"audioDataCallback",null);Gt(this,"errorCallback",null);Gt(this,"statusCallback",null);this.config=oe({mimeType:"audio/webm;codecs=opus",audioBitsPerSecond:128e3,maxRecordingDuration:9e5,autoPauseEnabled:!0},a)}initialize(){return et(this,null,function*(){try{if(!navigator.mediaDevices)throw new Error("Media devices API is not available. This usually means the page is not served over HTTPS or there are browser restrictions.");if(!window.MediaRecorder)throw new Error("MediaRecorder is not supported in this browser");const a=["audio/mp3","audio/ogg;codecs=opus","audio/mp4","audio/ogg","audio/wav"].filter(i=>MediaRecorder.isTypeSupported(i));if(a.length===0)throw new Error("No supported audio formats found in this browser");this.config.mimeType=a[0],console.log("Supported audio formats:",a),console.log("Selected format:",this.config.mimeType),console.log(`AudioService initialized with format: ${this.config.mimeType}`),this.isInitialized=!0}catch(a){throw new Error(`Audio initialization failed: ${a}`)}})}getInitializationStatus(){return this.isInitialized}start(a,i,l){return et(this,null,function*(){var u;if(!this.isInitialized)throw new Error("Not initialized");if(this.isActive)throw new Error("Already active");try{if(this.audioDataCallback=a,this.errorCallback=i||null,this.statusCallback=l||null,!navigator.mediaDevices)throw new Error("Media devices API is not available. This usually means the page is not served over HTTPS or there are browser restrictions.");this.mediaStream=yield navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,sampleRate:44100,channelCount:1}});let f;try{f=new MediaRecorder(this.mediaStream,{mimeType:this.config.mimeType,audioBitsPerSecond:this.config.audioBitsPerSecond})}catch(c){console.warn(`Failed to create MediaRecorder with ${this.config.mimeType}, trying without mimeType`),f=new MediaRecorder(this.mediaStream,{audioBitsPerSecond:this.config.audioBitsPerSecond}),this.config.mimeType=f.mimeType,console.log("Fallback MIME type selected:",this.config.mimeType)}if(this.mediaRecorder=f,this.mediaRecorder.state!=="inactive")throw new Error(`MediaRecorder in invalid state: ${this.mediaRecorder.state}`);this.setupMediaRecorderEvents(),this.mediaRecorder.start(),this.isActive=!0,this.recordingStartTime=Date.now(),this.audioChunks=[],this.config.autoPauseEnabled&&this.setupAutoPauseTimer(),(u=this.statusCallback)==null||u.call(this,"recording"),console.log("Audio recording started with MediaRecorder"),console.log("Using MIME type:",this.config.mimeType),console.log("MediaRecorder state:",this.mediaRecorder.state)}catch(f){throw console.error("Detailed error in start method:",f),new Error(`Failed to start: ${f}`)}})}stop(){var a,i;if(!(!this.isActive||!this.mediaRecorder))try{this.autoPauseTimer&&(clearTimeout(this.autoPauseTimer),this.autoPauseTimer=null),this.mediaRecorder.state==="recording"&&this.mediaRecorder.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(l=>l.stop()),this.mediaStream=null),this.isActive=!1,(a=this.statusCallback)==null||a.call(this,"stopped"),console.log("Audio recording stopped manually")}catch(l){(i=this.errorCallback)==null||i.call(this,new Error(`Failed to stop: ${l}`))}}cancel(){var a,i;if(!(!this.isActive||!this.mediaRecorder))try{this.autoPauseTimer&&(clearTimeout(this.autoPauseTimer),this.autoPauseTimer=null),this.audioChunks=[],this.mediaRecorder.ondataavailable=null,this.mediaRecorder.state==="recording"&&this.mediaRecorder.stop(),this.mediaStream&&(this.mediaStream.getTracks().forEach(l=>l.stop()),this.mediaStream=null),this.isActive=!1,(a=this.statusCallback)==null||a.call(this,"cancelled")}catch(l){(i=this.errorCallback)==null||i.call(this,new Error(`Failed to cancel: ${l}`))}}pauseRecording(){var a,i;if(!(!this.isActive||!this.mediaRecorder))try{this.mediaRecorder.state==="recording"&&this.mediaRecorder.stop(),this.isActive=!1,(a=this.statusCallback)==null||a.call(this,"paused"),console.log("Audio recording paused automatically after 15 minutes")}catch(l){(i=this.errorCallback)==null||i.call(this,new Error(`Failed to pause recording: ${l}`))}}setupMediaRecorderEvents(){this.mediaRecorder&&(this.mediaRecorder.ondataavailable=a=>{console.log("media recorder data available"),a.data.size>0&&this.audioChunks.push(a.data)},this.mediaRecorder.onstop=()=>et(this,null,function*(){var a,i,l;try{if((a=this.audioChunks)!=null&&a.length){const u=new Blob(this.audioChunks,{type:this.config.mimeType}),f=yield this.blobToBase64(u),c=Date.now()-this.recordingStartTime,d={audio:f,format:this.config.mimeType,duration:c,timestamp:this.recordingStartTime};(i=this.audioDataCallback)==null||i.call(this,d),this.audioChunks=[]}}catch(u){console.error("Error processing recorded audio:",u),(l=this.errorCallback)==null||l.call(this,new Error(`Audio processing failed: ${u}`))}}),this.mediaRecorder.onerror=a=>{var i;console.error("MediaRecorder error:",a),(i=this.errorCallback)==null||i.call(this,new Error("MediaRecorder encountered an error"))},this.mediaRecorder.onstart=()=>{console.log("MediaRecorder started recording"),this.mediaRecorder&&(console.log("MediaRecorder state:",this.mediaRecorder.state),console.log("MediaRecorder MIME type:",this.mediaRecorder.mimeType))})}setupAutoPauseTimer(){this.autoPauseTimer&&clearTimeout(this.autoPauseTimer),this.autoPauseTimer=setTimeout(()=>{console.log("Auto-pause timer triggered after 15 minutes"),this.pauseRecording()},this.config.maxRecordingDuration)}blobToBase64(a){return new Promise((i,l)=>{const u=new FileReader;u.onload=()=>{if(typeof u.result=="string"){const f=u.result.split(",")[1];i(f)}else l(new Error("Failed to convert blob to base64"))},u.onerror=()=>l(new Error("FileReader error")),u.readAsDataURL(a)})}cleanup(){return et(this,null,function*(){this.cancel();try{this.mediaRecorder&&(this.mediaRecorder=null),this.mediaStream&&(this.mediaStream.getTracks().forEach(a=>a.stop()),this.mediaStream=null),this.isInitialized=!1,this.audioChunks=[],console.log("AudioService cleaned up")}catch(a){console.error("Error during cleanup:",a)}})}isServiceActive(){return this.isActive}isServiceInitialized(){return this.isInitialized}getConfig(){return oe({},this.config)}getCurrentDuration(){return this.isActive?Date.now()-this.recordingStartTime:0}getRemainingTime(){if(!this.isActive||!this.config.autoPauseEnabled)return 0;const a=Date.now()-this.recordingStartTime;return Math.max(0,this.config.maxRecordingDuration-a)}}function t4(){const[n,a]=G.useState(!1),[i,l]=G.useState(null),[u,f]=G.useState(0),[c,d]=G.useState(0),p=G.useRef(null),g=G.useRef(null),A=G.useCallback(()=>{g.current&&clearInterval(g.current),g.current=setInterval(()=>{if(p.current&&n){const z=p.current.getCurrentDuration(),P=p.current.getRemainingTime();f(z),d(P)}},1e3)},[n]),m=G.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=null)},[]),y=G.useCallback(z=>et(null,null,function*(){try{if(!p.current||!p.current.getInitializationStatus()){console.log("AudioService not initialized or missing, reinitializing..."),p.current&&p.current.cleanup();const P=new gE({maxRecordingDuration:2e5,autoPauseEnabled:!0,audioBitsPerSecond:128e3});yield P.initialize(),console.log("AudioService reinitialized in useAudioService"),p.current=P}l(null),f(0),d(p.current.getConfig().maxRecordingDuration),yield p.current.start(P=>{z(P),a(!1),m()},P=>{console.error("Audio error in useAudioService:",P),l(P),a(!1),m()},P=>{console.log("Audio status changed:",P),P==="recording"?(a(!0),A()):(P==="paused"||P==="stopped")&&(a(!1),m())})}catch(P){const N=P instanceof Error?P:new Error("Failed to start recording");l(N),a(!1),m()}}),[A,m]),E=G.useCallback(()=>et(null,null,function*(){try{console.log("Reinitializing AudioService..."),p.current&&p.current.cleanup();const z=new gE({maxRecordingDuration:9e5,autoPauseEnabled:!0,audioBitsPerSecond:128e3});return yield z.initialize(),console.log("AudioService reinitialized successfully"),p.current=z,l(null),!0}catch(z){return console.error("Failed to reinitialize AudioService:",z),l(z instanceof Error?z:new Error("Reinitialization failed")),!1}}),[]),C=G.useCallback(()=>{p.current&&(p.current.stop(),a(!1),m())},[m]),x=G.useCallback(()=>{p.current&&(p.current.cancel(),a(!1),m())},[m]),w=G.useCallback(()=>{l(null)},[]),v=G.useCallback(()=>{var z;return((z=p.current)==null?void 0:z.getCurrentDuration())||0},[]),D=G.useCallback(()=>{var z;return((z=p.current)==null?void 0:z.getRemainingTime())||0},[]),B=G.useCallback(()=>{m(),p.current&&p.current.cleanup()},[m]);return G.useEffect(()=>B,[B]),{isRecording:n,error:i,recordingDuration:u,remainingTime:c,start:y,stop:C,cancel:x,clearError:w,getCurrentDuration:v,getRemainingTime:D,reinitialize:E}}const n4=n=>{const a=Math.floor(n/60),i=n%60;return`${a.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`},Eh=2*1024*1024,mE=n=>{if(n===0)return"0 Bytes";const a=1024,i=["Bytes","KB","MB","GB"],l=Math.floor(Math.log(n)/Math.log(a));return parseFloat((n/Math.pow(a,l)).toFixed(2))+" "+i[l]};function r4({onSendMessage:n,onFinalAudioStream:a,onFileUpload:i,onInputChange:l,inlineText:u,placeholder:f="Message Apollo Assist...",disabled:c=!1,setError:d,mobileVerificationStatus:p}){const[g,A]=G.useState(""),[m,y]=G.useState(!1),[E,C]=G.useState(!1),[x,w]=G.useState("idle"),[v,D]=G.useState(0),[B,z]=G.useState([]),[P,N]=G.useState(null),[Z,ie]=G.useState(null),[F,K]=G.useState(!1),[re,Q]=G.useState(40),[q,I]=G.useState(!1),ue=G.useRef(null),fe=G.useRef(null),ce=G.useRef(null),le=_t(ee=>ee.connectionStatus),ne=_t(ee=>ee.isStreaming),T=_t(ee=>ee.error),{isRecording:_,error:V,recordingDuration:U,start:he,stop:be,cancel:Be,reinitialize:Ke}=t4(),{isOnline:Ue}=bd();G.useEffect(()=>()=>{ce.current&&clearInterval(ce.current)},[]),G.useEffect(()=>{if((ne||T||!c)&&K(!1),!ne&&!c&&le===kt.CONNECTED&&fe.current&&window.innerWidth&&window.innerWidth>768){const ee=setTimeout(()=>{var we;(we=fe.current)==null||we.focus()},100);return()=>clearTimeout(ee)}},[ne,T,c]),G.useEffect(()=>{u&&(A(u),w("idle"))},[u]),G.useEffect(()=>{g.trim()||(Q(40),fe.current&&(fe.current.style.height="40px"))},[g]),G.useEffect(()=>{if(fe.current&&g.trim()){const ee=fe.current;ee.style.height="auto",ee.style.overflow="hidden";const we=ee.scrollHeight,Oe=40,Ge=120,tt=Math.max(Oe,Math.min(we,Ge));ee.style.height=tt+"px",Q(tt),we>Ge?ee.style.overflow="auto":ee.style.overflow="hidden"}},[g]),G.useEffect(()=>{V&&(console.log("Audio error detected:",V),y(!1),N(V.message),ce.current&&clearInterval(ce.current))},[V,d]),G.useEffect(()=>{!c&&!ne&&(N(null),V||I(!1),V&&Ke&&!q&&(console.log("Attempting to reinitialize AudioService..."),I(!0),Ke().then(ee=>{ee?(console.log("AudioService reinitialized successfully"),N(null),I(!1)):console.log("AudioService reinitialization failed, will not retry")}).catch(ee=>{console.error("AudioService reinitialization error:",ee)})))},[c,ne,V,Ke,q]),G.useEffect(()=>{_&&D(Math.floor(U/1e3))},[U,_]),G.useEffect(()=>{E&&(m&&ge(),Y())},[E]);const Fe=()=>et(null,null,function*(){try{(yield navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(we=>we.stop()),N(null),console.log("Microphone permission granted, error cleared")}catch(ee){if(ee instanceof DOMException&&ee.name==="NotAllowedError"){console.log("Microphone permission denied");const we=yield We();console.log("Permission state:",we),we==="denied"?(console.log("Setting error:","Microphone access is blocked. You'll need to manually enable it in your browser settings."),d({title:"Microphone access is blocked.",description:"Enable it in your browser settings."})):(console.log("Setting error:","Microphone access denied. Please allow microphone permissions when prompted."),d({title:"Microphone access is denied.",description:" Please allow microphone permissions when prompted."}))}else console.error("Error checking microphone permission:",ee),d({title:"Unable to access microphone.",description:" Please check your device and try again."})}}),We=()=>et(null,null,function*(){try{return(yield navigator.permissions.query({name:"microphone"})).state}catch(ee){return console.log("Could not check permission state:",ee),"unknown"}}),rt=G.useMemo(()=>g.trim()||B.length>0,[g,B]),Ct=G.useMemo(()=>{if(p.active){if(p.active&&p.isSending&&p.stage===as.MOBILE_NUMBER)return"Sending OTP to your mobile number..."}else return null;return null},[p]),Mt=G.useMemo(()=>le!==kt.CONNECTED||!Ue?!0:T&&(T!=null&&T.title)&&le===kt.CONNECTED?(console.log("input enabled bcus of valid error"),!1):p.isSending?(console.log("input disabled bcus of mobile verification is sending"),!0):(console.log("input enabled/disabled bcus ",c,ne,F),c||ne||F),[T,le,c,ne,F,Ue,p.isSending]),S=()=>et(null,null,function*(){try{D(0),ie(null),yield he(ee=>{console.log("audio data arrived"),ie(ee),C(!0)}),ce.current=setInterval(()=>{D(ee=>ee+1)},1e3)}catch(ee){if(console.error("Error starting recording:",ee),ee instanceof Error&&ee.message.includes("Not initialized")&&!q){console.log("AudioService not initialized in startRecording, attempting reinitialization..."),I(!0);try{if(yield Ke())console.log("AudioService reinitialized in startRecording, trying again..."),yield S();else throw new Error("Failed to reinitialize AudioService")}catch(we){throw console.error("Failed to reinitialize AudioService in startRecording:",we),new Error("Audio service unavailable")}}else throw ee}}),ge=()=>{console.log("called stop recording"),ce.current&&clearInterval(ce.current),y(!1),w("processing"),be()},de=()=>{Be(),y(!1),ie(null)},Y=G.useCallback(()=>et(null,null,function*(){if(!E){console.log("isAudiostreaming is false");return}if(!Z){console.error("No audio available");return}try{K(!0),C(!1),w("transcribing");const ee=yield new Promise((we,Oe)=>{const Ge=setTimeout(()=>Oe(new Error("Timed out waiting for audio")),5e3),tt=()=>{Z?(clearTimeout(Ge),we(Z)):setTimeout(tt,100)};tt()});yield a(ee)}catch(ee){console.error("Error sending recording:",ee),d({title:"Failed to send audio message. Please try again."}),K(!1),w("idle");const we={audio:"",format:"audio/mp4",duration:0,timestamp:Date.now()};yield a(we)}}),[E]),j=()=>et(null,null,function*(){if(console.log("called handle send",ne),(g.trim()||B.length>0||E)&&!c&&!F)try{if(p.active||K(!0),g.trim()&&B.length===0&&n({content:g.trim()}),B.length>0){const ee=B.reduce((Oe,Ge)=>Oe+Ge.size,0);if(ee>Eh){d({title:`Total file size (${mE(ee)}) exceeds the ${mE(Eh)} limit. Please select smaller files.`}),z([]);return}const we=new DataTransfer;B.forEach(Oe=>we.items.add(Oe)),i(we.files,g.trim()),z([])}A(""),z([]),y(!1)}catch(ee){console.error("Error in handleSend:",ee),d({title:"Failed to send message. Please try again."})}finally{}}),H=ee=>{ee.key==="Enter"&&!ee.shiftKey&&(ee.preventDefault(),j())},J=()=>et(null,null,function*(){if(!m&&!_)try{yield Fe(),P||(y(!0),yield S())}catch(ee){if(console.error("Error starting recording:",ee),ee instanceof Error&&ee.message.includes("Not initialized")&&!q){console.log("AudioService not initialized, attempting reinitialization..."),I(!0);try{(yield Ke())?(console.log("AudioService reinitialized, trying to start recording again..."),y(!0),yield S()):d({title:"Failed to initialize audio service. Please try again."})}catch(we){console.error("Failed to reinitialize AudioService:",we),d({title:"Audio service unavailable. Please try again."})}}else d({title:"Failed to start recording. Please try again."})}else _&&(console.log("called mic click and recording is true"),ge())}),pe=()=>{var ee;(ee=ue.current)==null||ee.click()},$=ee=>{if(console.log("handleFileChange called"),ee.target.files&&ee.target.files.length>0){const we=Array.from(ee.target.files),Oe=tt=>{const st=tt.type.toLowerCase(),Rt=tt.name.toLowerCase().split(".").pop()||"";return st&&["application/pdf","image/jpeg","image/jpg"].some(yt=>st.includes(yt))?!0:!st||st===""?["pdf","jpg","jpeg"].includes(Rt):!1},Ge=we.filter(tt=>(console.log("file",tt),Oe(tt)?!0:(d({title:`File type not supported: ${tt.name}`,description:"Only PDF, images (JPG, JPEG) are allowed."}),!1)));Ge.length>0&&z(tt=>[...tt,...Ge]),ee.target.value=""}},ye=ee=>{A(ee.target.value),l==null||l(ee.target.value)},Re=ee=>{const we=ee.currentTarget;we.style.height="auto",we.style.overflow="hidden";const Oe=we.scrollHeight,Ge=40,tt=120,st=Math.max(Ge,Math.min(Oe,tt));we.style.height=st+"px",Q(st),Oe>tt?we.style.overflow="auto":we.style.overflow="hidden"},ke=B.length>0&&!m&&!_,te=re>40||ke;return R.jsxs("div",{className:`bg-[var(--color-background)] border border-[var(--color-primary)] mx-4 flex-shrink-0 ${te?"rounded-lg px-3 py-2":"rounded-full px-2 py-0.5"} flex flex-col ${ke?"gap-2":"gap-0"}`,children:[ke&&R.jsx("div",{className:"w-full",children:R.jsx(j0,{files:B,onRemoveFile:ee=>z(we=>we.filter((Oe,Ge)=>Ge!==ee)),isPreview:!0,className:`${F?"opacity-50":""}`})}),R.jsxs("div",{className:`flex w-full gap-2 ${ke?"items-end":"items-center"}`,children:[R.jsx("input",{ref:ue,type:"file",multiple:!0,accept:".pdf,.jpg,.jpeg,application/pdf,image/jpeg",onChange:$,className:"hidden","data-max-size":Eh.toString()}),m||_?R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-red-600 hover:bg-red-100 flex-shrink-0",onClick:de,disabled:F,children:R.jsx(RI,{className:"h-4 w-4"})}):R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-[var(--color-accent)] flex-shrink-0",onClick:pe,disabled:Mt||(p==null?void 0:p.active),children:R.jsx(Ay,{className:"h-4 w-4 text-[var(--color-primary)]"})}),m||_?R.jsx("div",{className:"flex-1 flex items-center justify-center px-3 py-2",children:_&&R.jsxs("div",{className:"relative",children:[R.jsx("img",{src:Ak,alt:"Voice listening",className:"h-6 w-56"}),R.jsxs("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-transparent to-transparent pointer-events-none",children:[R.jsx("div",{className:"absolute left-0 top-0 w-4 h-full bg-gradient-to-r from-white to-transparent"}),R.jsx("div",{className:"absolute right-0 top-0 w-4 h-full bg-gradient-to-l from-white to-transparent"})]})]})}):R.jsx("div",{className:"relative w-full",children:R.jsx($S,{ref:fe,value:g,onChange:ye,onInput:Re,onKeyPress:H,autoFocus:!c&&le===kt.CONNECTED&&!ne&&window.innerWidth>768,placeholder:Ct||(ne||c?"Please wait for response...":F?x==="processing"?"Processing your voice...":x==="transcribing"?"Transcribing recording..":"Sending message...":f),disabled:Mt,className:"border-0 shadow-none px-0 py-2 focus-visible:ring-0 focus-visible:outline-none focus-visible:border-0 focus-visible:ring-transparent focus-visible:ring-offset-0 text-sm resize-none break-word overflow-hidden",rows:1,style:{minHeight:"40px",maxHeight:"120px",fontSize:window.innerWidth<=768?"16px":"14px"}})}),(m||_)&&R.jsx("div",{className:"flex flex-col items-end text-sm font-mono text-[var(--color-primary)]",children:R.jsx("span",{className:F?"opacity-50":"",children:n4(v)})}),m||_?R.jsx("div",{className:"flex items-center gap-2",children:R.jsx(Ot,{size:"sm",className:"h-8 w-8 p-0 bg-[var(--color-primary)] hover:bg-[var(--color-primary)]/90 flex-shrink-0 rounded-full",onClick:J,disabled:F,children:R.jsx(AI,{className:"h-4 w-4 white"})})}):R.jsx(R.Fragment,{children:rt?R.jsx(Ot,{size:"sm",className:"h-8 w-8 py-2 bg-[var(--color-primary)] hover:bg-[var(--color-primary)]/90 flex-shrink-0 rounded-full",onClick:j,disabled:Mt||F,children:F?R.jsx(ql,{className:"h-4 w-4 animate-spin text-[var(--color-primary-foreground)]"}):R.jsx(Sd,{className:"h-4 w-4 text-[var(--color-primary-foreground)]"})}):R.jsx(Ot,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-[var(--color-accent)] flex-shrink-0",onClick:J,disabled:c||ne||!!P||F||(p==null?void 0:p.active),children:R.jsx(kI,{className:"h-4 w-4 text-[var(--color-primary)]"})})})]})]})}function i4({onSendMobile:n,isLoading:a=!1,error:i=null,disabled:l=!1,placeholder:u="Mobile Number"}){const[f,c]=G.useState(""),d=G.useRef(null);G.useEffect(()=>{d.current&&d.current.focus()},[]);const p=y=>{const E=y.target.value.replace(/\D/g,"");c(E)},g=()=>{l||a||f.length===10&&n({content:f})},A=y=>{y.key==="Enter"&&f.length===10&&g()},m=f.length===10;return R.jsxs("div",{className:"px-4 py-3 space-y-4",children:[R.jsxs("div",{className:"flex items-center gap-3",children:[R.jsxs(Ot,{variant:"outline",size:"sm",className:"h-12 px-3 flex items-center gap-2 border-[var(--color-border)] hover:bg-[var(--color-accent)] rounded-xl",disabled:l,children:[R.jsx("img",{src:"./assets/indian-flag.svg",alt:"Indian flag",className:"w-4 h-4 rounded-full"}),R.jsx("span",{className:"text-sm font-medium",children:"+91"})]}),R.jsx("div",{className:"flex-1",children:R.jsx(fS,{ref:d,type:"tel",value:f,onChange:p,onKeyPress:A,placeholder:a?"Sending OTP...":u,disabled:l||a,className:"h-12 rounded-xl text-base border-[var(--color-muted-foreground)] focus:border-[var(--color-primary-primary)] focus:ring-2 focus:ring-[var(--color-primary-primary)]/20 bg-[var(--color-input)]",maxLength:10})}),R.jsx(Ot,{onClick:g,disabled:!m||l||a,size:"sm",className:"h-12 w-12 p-0 bg-[var(--color-primary)] hover:bg-[var(--color-primary)]/90 rounded-lg",children:a?R.jsx(ql,{className:"h-4 w-4 animate-spin text-[var(--color-primary-foreground)]"}):R.jsx(Sd,{className:"h-4 w-4 text-[var(--color-primary-foreground)]"})})]}),i&&R.jsx("div",{className:"text-sm text-red-500 text-center",children:i})]})}function a4({mobileNumber:n,onSendOTP:a,isLoading:i=!1,error:l=null,disabled:u=!1}){const[f,c]=G.useState(""),d="min-w-[2.5rem] w-full max-w-[4rem] h-10 sm:h-12 text-center text-base sm:text-lg font-semibold border-2 border-[var(--color-border)] rounded-lg data-[active=true]:border-[var(--color-primary)] data-[active=true]:ring-2 data-[active=true]:ring-[var(--color-primary)]/20 flex-1",p=A=>{c(A),A.length===6&&a({content:A})},g=()=>{f.length===6&&a({content:f})};return R.jsxs("div",{className:"px-4 py-3 space-y-4",children:[R.jsx("div",{className:"flex items-center justify-start px-3",children:R.jsx("div",{className:"flex items-center gap-2",children:R.jsxs("span",{className:"text-sm text-[var(--color-muted-foreground)]",children:["OTP sent to ",n]})})}),R.jsxs("div",{className:"flex items-center justify-center gap-2 sm:gap-3",children:[R.jsx(jk,{maxLength:6,value:f,onChange:p,disabled:u||i,autoFocus:!0,children:R.jsxs(zk,{className:"gap-1 sm:gap-2",children:[R.jsx(To,{index:0,className:d}),R.jsx(To,{index:1,className:d}),R.jsx(To,{index:2,className:d}),R.jsx(To,{index:3,className:d}),R.jsx(To,{index:4,className:d}),R.jsx(To,{index:5,className:d})]})}),R.jsx(Ot,{onClick:g,disabled:f.length!==6||u||i,size:"sm",className:"h-10 w-10 sm:h-12 sm:w-12 p-0 bg-[var(--color-primary)] hover:bg-[var(--color-primary)]/90 rounded-full flex-shrink-0",children:i?R.jsx(ql,{className:"h-4 w-4 animate-spin text-[var(--color-primary-foreground)]"}):R.jsx(Sd,{className:"h-4 w-4 text-[var(--color-primary-foreground)]"})})]}),l&&R.jsx("div",{className:"text-sm text-red-500 text-center",children:l})]})}const wh=(n,a)=>{switch(n.error.code){case Vt.OTP_NOT_FOUND.code:return{success:!1,data:{error:{code:Vt.OTP_NOT_FOUND.code,msg:Vt.OTP_NOT_FOUND.msg}}};case Vt.INVALID_OTP.code:return{success:!1,data:{error:{code:Vt.INVALID_OTP.code,msg:Vt.INVALID_OTP.msg}}};case Vt.TOOL_ERROR.code:return{success:!1,data:{error:{code:Vt.TOOL_ERROR.code,msg:a?Vt.TOOL_ERROR.msg:Vt.INVALID_MOBILE_NUMBER.msg}}};default:return a?{success:!1,data:{error:{code:Vt.TOOL_ERROR.code,msg:Vt.TOOL_ERROR.msg}}}:{success:!1,data:{error:{code:Vt.TOOL_ERROR.code,msg:Vt.INVALID_MOBILE_NUMBER.msg}}}}},AE=(n,a,i,l)=>et(null,null,function*(){var u;try{const f=yield Fa({toolParams:oe({mobile_number:n.trim(),stage:as.MOBILE_NUMBER},l&&{lead_description:l}),wrapperOptions:{session_id:a,tool_name:Na.MOBILE_VERIFICATION,onSessionRefresh:i}});if(!f.ok){const d=yield f.json().catch(()=>({}));return(u=d==null?void 0:d.error)!=null&&u.code?wh(d,!1):{success:!1,data:{error:{msg:Vt.INVALID_MOBILE_NUMBER.msg}}}}const c=yield f.json();return c.error?{success:!1,data:{error:c.error}}:c.status==="success"?{success:!0,data:c}:{success:!1,data:{error:{msg:Vt.INVALID_MOBILE_NUMBER.msg}}}}catch(f){return console.error("Mobile verification error:",f),{success:!1,data:{error:{msg:f instanceof Error?f.message:Vt.INVALID_MOBILE_NUMBER.msg}}}}}),o4=(n,a,i,l,u)=>et(null,null,function*(){var f;try{const c=yield Fa({toolParams:oe({mobile_number:a.trim(),otp:n.trim(),stage:as.OTP},u&&{lead_description:u}),wrapperOptions:{session_id:i,tool_name:Na.MOBILE_VERIFICATION,onSessionRefresh:l}});if(u==="callback requested")return{success:!0,data:{message:"Appointment requested successfully. You will get a callback soon."}};if(!c.ok){const p=yield c.json().catch(()=>({}));return(f=p==null?void 0:p.error)!=null&&f.code?wh(p,!0):{success:!1,data:{error:{msg:Vt.INVALID_OTP.msg}}}}const d=yield c.json().catch(()=>({}));return d.status==="success"?{success:!0,data:d}:{success:!1,data:{error:{msg:Vt.INVALID_OTP.msg}}}}catch(c){return console.error("OTP verification error:",c),{success:!1,data:{error:{msg:c instanceof Error?c.message:Vt.INVALID_OTP.msg}}}}}),l4=(n,a,i)=>et(null,null,function*(){var l;try{const u=yield Fa({toolParams:{selected_uhid:n,stage:as.UHID},wrapperOptions:{session_id:a,tool_name:Na.MOBILE_VERIFICATION,onSessionRefresh:i}});if(!u.ok){const c=yield u.json().catch(()=>({}));return(l=c==null?void 0:c.error)!=null&&l.code?wh(c,!1):{success:!1,data:{error:{msg:Vt.INVALID_UHID.msg}}}}const f=yield u.json();return f.status==="success"?{success:!0,data:f}:{success:!1,data:{error:{msg:Vt.INVALID_UHID.msg}}}}catch(u){return console.error("Uhid verification error:",u),{success:!1,data:{error:{msg:Vt.INVALID_UHID.msg}}}}}),s4=(n,a,i)=>et(null,null,function*(){var l,u,f,c;if(!(n!=null&&n.doctor_id))return{success:!1,data:null};try{const d=yield Fa({toolParams:{doctor_id:n.doctor_id,hospital_id:n.hospital_id||"",region_id:n.region_id||""},wrapperOptions:{session_id:a,tool_name:Na.AVAILABILITY_DATES,onSessionRefresh:i}});if(!(d!=null&&d.ok)){const g=yield d.json();if(d.status===412&&((l=g==null?void 0:g.error)==null?void 0:l.code)==="bot_error_display"&&((u=g==null?void 0:g.error)!=null&&u.msg))return{success:!1,data:{error:{msg:(f=g==null?void 0:g.error)==null?void 0:f.msg}}};throw new Error("Failed to load availability dates")}const p=yield d.json();return(c=p==null?void 0:p.available_dates)!=null&&c.length?{success:!0,data:p}:(console.error("Available dates are not coming in response",d),{success:!1,data:null})}catch(d){return console.error("Error loading availability dates:",d),{success:!1,data:null}}}),u4=(n,a,i,l)=>et(null,null,function*(){var u,f,c,d;if(!(a!=null&&a.doctor_id)||!n)return{success:!1,data:null};try{const p=yield Fa({toolParams:{doctor_id:a.doctor_id,appointment_date:n,hospital_id:a.hospital_id||"",region_id:a.region_id||""},wrapperOptions:{session_id:i,tool_name:Na.AVAILABILITY_SLOTS,onSessionRefresh:l}});if(!(p!=null&&p.ok)){const A=yield p.json();if(p.status===412&&((u=A==null?void 0:A.error)==null?void 0:u.code)==="bot_error_display"&&((f=A==null?void 0:A.error)!=null&&f.msg))return{success:!1,data:{error:{msg:(c=A==null?void 0:A.error)==null?void 0:c.msg}}};throw new Error("Failed to load availability slots")}const g=yield p.json();return(d=g==null?void 0:g.slots)!=null&&d.length?{success:!0,data:g}:(console.error("Available slots are not coming in response",p),{success:!1,data:null})}catch(p){return console.error("Error loading slots for date:",p),{success:!1,data:null}}}),c4=(n,a,i,l)=>et(null,null,function*(){try{const u=`${Yr.BASE_API_URL}/med-assist/session/${n}/${a}`,f=yield fetch(u,{method:"PATCH",headers:{"Content-Type":"application/json","X-agent-id":Yr.X_AGENT_ID},body:JSON.stringify({feedback:i,feedback_reason:l})});if(!f.ok)throw new Error("Failed to patch feedback message");return f.json()}catch(u){throw console.error("Error patching feedback message:",u),u}});var as=(n=>(n.MOBILE_NUMBER="mobile",n.OTP="otp",n.UHID="uhid",n))(as||{});function f4({title:n="Apollo Assist",firstUserMessage:a="",className:i="",onClose:l,onStartSession:u,onExpand:f,isExpanded:c=!1,isMobile:d=!1,isLoading:p=!1,isOnline:g=!0,isFullMode:A=!1}){const[m,y]=G.useState([{id:"1",content:"Hi, I'm Apollo Assist, your personal support for all medical needs. How can I help you?",isBot:!0,isStored:!0,feedback:Mn.NONE}]),[E,C]=G.useState(null),[x,w]=G.useState(null),[v,D]=G.useState(!1),[B,z]=G.useState(!1),[P,N]=G.useState({active:!1,isSending:!1,stage:"mobile",uhids:[],tool_use_id:null,mobile_number:null}),[Z,ie]=G.useState(!1),F=G.useRef(P),K=G.useRef(!1),{connectionStatus:re,showRetryButton:Q,startNewConnection:q,error:I,clearError:ue,setError:fe,isStreaming:ce,sessionId:le,sessionToken:ne,clearSession:T,refreshSession:_,getMessagesForSession:V,addMessageToSession:U,updateMessageInSession:he,setInlineText:be,inlineText:Be,setResponseTimeoutId:Ke,clearResponseTimeout:Ue,setStreamingTimeoutId:Fe,clearStreamingTimeout:We,setLastStreamingActivity:rt,setIsBotIconAnimating:Ct}=_t();G.useEffect(()=>(!le&&!ne&&u?(u(),z(!0)):le&&ne&&et(null,null,function*(){try{const De=yield uy(le);!De.success&&!De.retry?(yield T(),yield u==null?void 0:u(!0),z(!0)):(!De.success&&De.retry&&((yield _())||(yield T(),yield u==null?void 0:u(!0))),z(!0))}catch(De){console.error("Error checking session details:",De),yield T(),yield u==null?void 0:u(!0),z(!0)}}),()=>{K.current=!0}),[]),G.useMemo(()=>{if(a!=null&&a.trim()&&B&&le&&!p&&re===kt.CONNECTED&&!ce&&!Z){const me=setTimeout(()=>{ee({content:a.trim()}),ie(!0)},0);return()=>clearTimeout(me)}},[a,B,le,re]),G.useEffect(()=>()=>{if(m.length>0&&!m[m.length-1].isStored&&le&&K.current){const me=ze(oe({},m[m.length-1]),{isStored:!0});y(De=>{const Pe=[...De];return Pe[Pe.length-1]=me,Pe}),U(le,me)}},[m]),G.useEffect(()=>{if(le||se(),D(!1),w(null),le){const me=V(le);if(me.length>0)y(me);else{const De={id:"1",content:"Hi, I'm Apollo Assist, your personal support for all medical needs. How can I help you?",isBot:!0,isStored:!0,feedback:Mn.NONE};U(le,De),y([De])}}},[le]);const Mt=G.useMemo(()=>le&&ne&&B?{sessionId:le,auth:{token:ne}}:null,[le,ne,B]),{webSocketService:S,setFilesForUpload:ge,sendFileUploadRequest:de,sendAudioData:Y,regenerateResponse:j,sendChatMessage:H,retryLastMessage:J,sendHiddenChatMessage:pe,triggerSessionRefresh:$}=uI(Mt,(me,De)=>{D(!1),w(null),y(Pe=>{var Ft,jt;const $e=Pe[Pe.length-1];if(($e==null?void 0:$e.id)===De&&($e!=null&&$e.isBot)&&(me==null?void 0:me.length)>((Ft=$e==null?void 0:$e.content)==null?void 0:Ft.length)){const ft=[...Pe];return ft[ft.length-1]=ze(oe({},$e),{content:me,isRegenerating:!1,isStored:!1}),ft}else{if(($e==null?void 0:$e.id)===De&&($e!=null&&$e.isBot)&&(me==null?void 0:me.length)<=((jt=$e==null?void 0:$e.content)==null?void 0:jt.length))return Pe;{const ft={id:De||Date.now().toString(),content:me,isBot:!0,isStored:!1,feedback:Mn.NONE};return[...Pe,ft]}}})},me=>{D(!1),w(me)},me=>{D(!1),C(me)},(me,De)=>et(null,null,function*(){var Pe,$e,Ft,jt,ft,Er,ta,Pa;if(D(!1),y(Rn=>{let On=-1;if(On=Rn.findIndex(Qt=>Qt.id==De),On!==-1&&!Rn[On].isResponded){const Qt=[...Rn];return Qt[On]=ze(oe({},Qt[On]),{commonContentData:me}),Qt}else{const Qt={id:De||Date.now().toString(),content:"",isBot:!0,commonContentData:me,isStored:!0,feedback:Mn.NONE};return U(le,Qt),[...Rn,Qt]}}),me.type==="mobile_verification"&&(($e=(Pe=me==null?void 0:me.data)==null?void 0:Pe.callbacks)!=null&&$e.tool_callback_mobile_verification))if((Ft=me==null?void 0:me.data)!=null&&Ft.mobile_number){N(Qt=>{var fn;return ze(oe({},Qt),{active:!0,isSending:!0,tool_use_id:me==null?void 0:me.tool_use_id,mobile_number:((fn=me==null?void 0:me.data)==null?void 0:fn.mobile_number)||null})}),w("Sending OTP to your mobile number...");let Rn="",On=!1;try{const Qt=yield AE((jt=me==null?void 0:me.data)==null?void 0:jt.mobile_number,le,$);Qt!=null&&Qt.success&&((ft=Qt==null?void 0:Qt.data)!=null&&ft.message)?(Rn=((Er=Qt==null?void 0:Qt.data)==null?void 0:Er.message)||"OTP sent successfully to your mobile number, please enter 6 digit OTP",On=!0):(Rn=((Pa=(ta=Qt==null?void 0:Qt.data)==null?void 0:ta.error)==null?void 0:Pa.msg)||"Failed to send OTP. Please try again.",On=!1)}catch(Qt){Rn="Failed to send OTP. Please try again.",On=!1}finally{w(null),N(Qt=>ze(oe({},Qt),{active:On,isSending:!1,stage:On?"otp":"mobile"})),y(Qt=>{const fn=[...Qt],qe=fn.length-1;if(fn.length>0&&fn[qe].isBot){const Un=`${fn[qe].content}
|
|
494
494
|
|
|
495
495
|
${Rn}`;fn[fn.length-1]=ze(oe({},fn[fn.length-1]),{content:Un}),he(le,fn[fn.length-1].id,fn[fn.length-1])}else{const ii={id:Date.now().toString(),content:Rn,isBot:!0,isStored:!0,feedback:Mn.NONE};fn.push(ii),U(le,ii)}return fn})}}else N(Rn=>ze(oe({},Rn),{active:!0,tool_use_id:me==null?void 0:me.tool_use_id}))}),me=>{be(me)}),[ye]=G.useState([{id:"doctor",label:"Help me find a doctor"},{id:"appointment",label:"I want to book appointment"},{id:"health_check",label:"I want to book health check"},{id:"international-patient_services",label:"International patient services"},{id:"emergency",label:"I have an emergency"}]),Re=G.useRef(null),ke=()=>{Re.current&&setTimeout(()=>{var me;(me=Re.current)==null||me.scrollTo({top:Re.current.scrollHeight,behavior:"smooth"})},0)};G.useEffect(()=>{ke(),ce&&(w(null),D(!1))},[m,ce]),G.useEffect(()=>{if(!ce&&le&&m.length>0){const me=m[m.length-1];if(me.isBot&&!me.isStored){const De=ze(oe({},me),{isStored:!0});y(Pe=>Pe.map(($e,Ft)=>Ft===Pe.length-1?De:$e)),U(le,De)}}},[ce,le]),G.useEffect(()=>{I&&(D(!1),Ue(),We())},[I]),G.useEffect(()=>{if(v&&!ce){const me=setTimeout(()=>{console.log("Response timeout: No response received within 30 seconds"),D(!1)},Wk);return Ke(me),()=>{clearTimeout(me),Ue()}}else Ue()},[v,ce]),G.useEffect(()=>{if(ce){rt(Date.now());const me=setTimeout(()=>{const De=_t.getState();De.isStreaming&&De.lastStreamingActivity&&Date.now()-De.lastStreamingActivity>=dy&&D(!1)},dy);return Fe(me),()=>{clearTimeout(me),We()}}else We(),rt(null)},[ce]),G.useEffect(()=>{Ct(!!x||v)},[x,v]);const te=G.useMemo(()=>re===kt.CONNECTED&&g&&!I&&!Q&&!q,[re,g,I,Q,q]);G.useEffect(()=>{F.current=P},[P]);const ee=$e=>et(null,[$e],function*({content:me,tool_use_id:De,tool_use_params:Pe}){var Ft,jt,ft,Er,ta,Pa,Rn,On,Qt,fn,qe,ii,Un,os,lc,Ha,ls,Ga,$n,ss,zo,us,Fo,cs,fs,ki,ds,hs,ps;if(!ce){if(!g){fe(Ut.OFFLINE),D(!1);return}if(re!==kt.CONNECTED){fe(Ut.CONNECTION_LOST),D(!1);return}ue(),w(null),C(null),Be&&be("");try{let He=null;if(F.current.active){if(F.current.stage==="mobile"){N(pt=>ze(oe({},pt),{isSending:!0}));const Et=F.current.mobile_number||me;He=yield AE(Et,le,$,F.current.reason),He!=null&&He.success?N(pt=>ze(oe({},pt),{isSending:!1,mobile_number:Et,stage:"otp"})):(se(),yield pe({message:((jt=(Ft=He==null?void 0:He.data)==null?void 0:Ft.error)==null?void 0:jt.msg)||"Mobile number verification failed",tool_use_id:De,tool_use_params:{mobile_number:Et}}))}else if(F.current.stage==="otp"&&F.current.mobile_number)if(He=yield o4(me,F.current.mobile_number,le,$,F.current.reason),F.current.reason==="callback requested"&&(He!=null&&He.success))yield pe({message:"Doctor is not available so User has requested for callback from hospital about the doctor availability. Meanwhie ask user if yu want's to see another doctor. User will get a callback soon.",tool_use_params:{mobile_number:F.current.mobile_number}}),se();else if(((Er=(ft=He==null?void 0:He.data)==null?void 0:ft.error)==null?void 0:Er.code)===Vt.INVALID_OTP.code)N(Et=>ze(oe({},Et),{active:!0,isSending:!1}));else if(!He.success&&((Pa=(ta=He==null?void 0:He.data)==null?void 0:ta.error)==null?void 0:Pa.code)===Vt.TOOL_ERROR.code)yield pe({message:((On=(Rn=He==null?void 0:He.data)==null?void 0:Rn.error)==null?void 0:On.msg)||Vt.TOOL_ERROR.msg,tool_use_id:De,tool_use_params:{mobile_number:F.current.mobile_number}}),se();else if(He!=null&&He.success&&((fn=(Qt=He==null?void 0:He.data)==null?void 0:Qt.uhids)!=null&&fn.length))N(Et=>{var pt;return ze(oe({},Et),{active:!0,isSending:!1,uhids:((pt=He==null?void 0:He.data)==null?void 0:pt.uhids)||[],stage:"uhid"})});else{const Et=He!=null&&He.success&&!((ii=(qe=He==null?void 0:He.data)==null?void 0:qe.uhids)!=null&&ii.length)?"Otp verification successful,but Uhids not found":`Otp verification failed ${(os=(Un=He==null?void 0:He.data)==null?void 0:Un.error)==null?void 0:os.msg}`;yield pe({message:Et,tool_use_id:De,tool_use_params:{mobile_number:F.current.mobile_number}}),se()}else if(F.current.stage==="uhid")if(He=yield l4(me,le,$),y(Et=>{const pt=[...Et];return pt[pt.length-1]=ze(oe({},pt[pt.length-1]),{isResponded:!0,isStored:!0}),he(le,pt[pt.length-1].id,pt[pt.length-1]),pt}),((Ha=(lc=He==null?void 0:He.data)==null?void 0:lc.error)==null?void 0:Ha.code)===Vt.USER_NOT_AUTHENTICATED.code)N(Et=>ze(oe({},Et),{active:!0,isSending:!1,stage:"mobile"})),yield ee({content:F.current.mobile_number||"",tool_use_id:De});else{const Et=((ls=He==null?void 0:He.data)==null?void 0:ls.status)==="success"?`Verification successful ,selected uhid: ${me}`:(($n=(Ga=He==null?void 0:He.data)==null?void 0:Ga.error)==null?void 0:$n.msg)||"Verification failed",pt=(zo=(ss=F.current)==null?void 0:ss.uhids)==null?void 0:zo.find(Lo=>(Lo==null?void 0:Lo.uhid)===me);yield H({message:Et,tool_use_id:De,tool_use_params:oe({mobile_number:F.current.mobile_number},pt&&oe({},pt))}),se()}const cn={id:Date.now().toString(),content:me,isBot:!1,originalUserMessage:me,isStored:!0};if(y(Et=>[...Et,cn]),U(le,cn),He){const Et=oe({id:(Date.now()+1).toString(),content:He!=null&&He.success?((us=He==null?void 0:He.data)==null?void 0:us.message)||"Success!":((cs=(Fo=He==null?void 0:He.data)==null?void 0:Fo.error)==null?void 0:cs.msg)||"Failed. Please try again.",isBot:!0,isStored:!0},((ki=(fs=He==null?void 0:He.data)==null?void 0:fs.uhids)==null?void 0:ki.length)&&((ds=F.current)==null?void 0:ds.tool_use_id)&&{commonContentData:{type:en.MOBILE_VERIFICATION,tool_use_id:(hs=F.current)==null?void 0:hs.tool_use_id,data:{uhids:(ps=He==null?void 0:He.data)==null?void 0:ps.uhids}}});y(pt=>[...pt,Et]),U(le,Et)}return}else{let cn=me;m.length>0&&m[m.length-1].isBot&&m[m.length-1].feedback===Mn.DISLIKE&&(cn=`User disliked the previous response. ${me}`),yield H(oe({message:cn,tool_use_id:De},Pe&&{tool_use_params:Pe}))}y(cn=>{const Et=[...cn];for(let pt=Et.length-1;pt>=0;pt--)if(Et[pt].isBot&&Et[pt].commonContentData){Et[pt]=oe(oe(ze(oe({},Et[pt]),{isResponded:!0}),Pe&&{tool_use_params:Pe}),(Pe==null?void 0:Pe.doctor_id)&&Et[pt].commonContentData&&{commonContentData:ze(oe({},Et[pt].commonContentData),{data:ze(oe({},Et[pt].commonContentData.data),{doctor_details:ze(oe({},Et[pt].commonContentData.data.doctor_details),{doctor_ids:[Pe.doctor_id]})})})}),he(le,Et[pt].id,Et[pt]);break}return Et});const gs={id:Date.now().toString(),content:me,isBot:!1,originalUserMessage:me,isStored:!0};y(cn=>[...cn,gs]),D(!0),U(le,gs)}catch(He){throw console.error("Failed to send message:",He),fe({title:"Failed to send message. Please try again."}),D(!1),He}}}),we=()=>{N({active:!0,stage:"mobile",isSending:!1,reason:"callback requested",mobile_number:F.current.mobile_number||""})},Oe=me=>et(null,null,function*(){if(!g){fe(Ut.OFFLINE),D(!1);return}if(re!==kt.CONNECTED){fe(Ut.CONNECTION_LOST),D(!1);return}C(null),y(De=>{const Pe=[...De];for(let $e=Pe.length-1;$e>=0;$e--)if(Pe[$e].isBot&&Pe[$e].commonContentData){Pe[$e]=ze(oe({},Pe[$e]),{isResponded:!0}),he(le,Pe[$e].id,Pe[$e]);break}return Pe});try{if(yield Y(me),P.active){se();return}}catch(De){throw console.error("Failed to send audio:",De),fe({title:"Failed to send audio message. Please try again."}),De}}),Ge=(me,De)=>et(null,null,function*(){if(ce)return;if(!g){fe(Ut.OFFLINE),D(!1);return}if(re!==kt.CONNECTED){fe(Ut.CONNECTION_LOST),D(!1);return}ue(),y(Ft=>{const jt=[...Ft];for(let ft=jt.length-1;ft>=0;ft--)if(jt[ft].isBot&&jt[ft].commonContentData){jt[ft]=ze(oe({},jt[ft]),{isResponded:!0}),he(le,jt[ft].id,jt[ft]);break}return jt});const Pe=Array.from(me),$e={id:Date.now().toString(),content:De||`📎 ${(Pe==null?void 0:Pe.length)>1?`${Pe.length} files`:"File"} uploaded`,isBot:!1,files:Pe,isStored:!1,feedback:Mn.NONE};y(Ft=>[...Ft,$e]);try{if(D(!0),ge(Pe,De),yield de(),U(le,$e),P.active){se();return}}catch(Ft){throw console.error("Failed to upload file:",Ft),fe({title:"Failed to upload file. Please try again."}),D(!1),Ft}}),tt=me=>et(null,null,function*(){if(ce)return;if(!g){fe(Ut.OFFLINE),D(!1);return}if(re!==kt.CONNECTED){fe(Ut.CONNECTION_LOST),D(!1);return}ue(),w(null),C(null);const De=ye.find(Pe=>Pe.id===me);if(De)try{yield ee({content:De.label})}catch(Pe){console.error("Failed to send quick action:",Pe)}}),st=me=>{if(!(me!=null&&me.link))return;window.open(me.link,"_blank")||(window.location.href=me.link)},Xe=me=>{me==="clear"&&(y([m[0]]),ue(),D(!1))},Rt=me=>et(null,null,function*(){if(!g){fe(Ut.OFFLINE),D(!1);return}if(re!==kt.CONNECTED){fe(Ut.CONNECTION_LOST),D(!1);return}const De=m.findIndex(jt=>jt.id===me);if(De===-1){console.error("Message not found for regeneration");return}const Pe=m[De];if(!Pe.isBot){console.error("Cannot regenerate user messages");return}let $e=De-1;for(;$e>=0&&m[$e].isBot;)$e--;if($e<0){console.error("No user message found for regeneration");return}const Ft=m[$e];if(!Ft.originalUserMessage){console.error("No original user message found for regeneration");return}if(!ce){ue(),w(null),y(jt=>{const ft=[...jt];return ft[De]=ze(oe({},ft[De]),{isRegenerating:!0,content:"Regenerating response..."}),ft});try{yield j(Ft.originalUserMessage),y(jt=>{const ft=[...jt];return ft[De]=ze(oe({},ft[De]),{isRegenerating:!1,content:"Regeneration not implemented in V2 yet"}),ft})}catch(jt){console.error("Failed to regenerate:",jt),y(ft=>{const Er=[...ft];return Er[De]=ze(oe({},Er[De]),{isRegenerating:!1,content:Pe.content}),Er})}}}),ht=()=>et(null,null,function*(){try{y([m[0]]),yield T(),D(!1),u==null||u(!0)}catch(me){throw console.error("Failed to start new session:",me),me}}),yt=()=>et(null,null,function*(){if(re!==kt.CONNECTED)S&&(ue(),S.reconnect(!0,"manual reconnect"));else try{(yield J())&&(ue(),D(!0))}catch(me){console.error("Failed to retry last message:",me),fe({title:"Failed to retry message. Please try again."})}}),M=()=>et(null,null,function*(){var $e,Ft;const me=`Exit ${(P==null?void 0:P.stage)||"Mobile"} verification`,De=($e=F.current)==null?void 0:$e.tool_use_id,Pe=(Ft=F.current)==null?void 0:Ft.mobile_number;yield se(),yield ee({content:me,tool_use_id:De||"",tool_use_params:{mobile_number:Pe}})}),se=()=>{N({active:!1,isSending:!1,mobile_number:null,uhids:[],tool_use_id:null,stage:"mobile"})},Me=me=>et(null,null,function*(){return yield s4(me,le,$)}),Ne=(me,De)=>et(null,null,function*(){return yield u4(me,De,le,$)}),Ye=(me,De,Pe)=>et(null,null,function*(){const $e=m.findIndex(Ft=>Ft.id===me);if($e===-1){console.error("Message not found for feedback");return}try{yield c4(le,me,De,Pe)}catch(Ft){console.error("Failed to patch feedback:",Ft)}finally{y(Ft=>{const jt=[...Ft];return jt[$e]=ze(oe({},jt[$e]),{feedback:De}),he(le,me,jt[$e]),jt})}}),ot=d?"fixed inset-0 z-[2147483647] bg-[var(--color-card)] border-border rounded-none flex flex-col h-[100dvh] w-screen py-0 gap-1 overflow-hidden":c?"fixed inset-4 z-[2147483647] bg-[var(--color-card)] border-border rounded-lg shadow-2xl flex flex-col max-h-[calc(100vh-2rem)] py-0 gap-1":`w-full max-w-sm bg-[var(--color-card)] border-border shadow-lg rounded-lg flex flex-col py-0 gap-1${i} `,it=d?"flex-1 overflow-y-auto overscroll-behavior-y-contain":c?"flex-1 min-h-0":"h-[500px]";return R.jsxs(ud,{className:ot,children:[R.jsx(DI,{title:n,onClose:l,onExpand:f,onMenuAction:Xe,isExpanded:c,isMobile:d,onStartSession:ht,connectionStatus:re,isOnline:g,isFullMode:A}),p&&R.jsx("div",{className:`${it} flex items-center justify-center p-4`,children:R.jsxs("div",{className:"text-center w-full",children:[R.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[var(--color-primary)] mx-auto mb-3"}),R.jsx("p",{className:"text-sm text-[var(--color-muted-foreground)] break-words",children:"Starting session..."})]})}),!p&&R.jsxs("div",{className:`${it} flex flex-col overflow-hidden max-h-screen`,children:[R.jsx("div",{ref:Re,className:"flex-1 min-h-0 overflow-y-auto",style:{scrollBehavior:"smooth",scrollbarWidth:"thin",scrollbarColor:"var(--color-border) transparent",overscrollBehavior:"contain",WebkitOverflowScrolling:"touch"},onTouchStart:me=>d&&me.stopPropagation(),onTouchMove:me=>d&&me.stopPropagation(),children:R.jsxs("div",{className:"min-h-full flex flex-col justify-end pb-4",children:[R.jsx("div",{className:"py-1 px-4 flex items-center justify-center",children:R.jsx("div",{className:"text-xs text-[var(--color-muted-foreground)] text-center",children:new Date().toLocaleString("en-US",{weekday:"long",hour:"2-digit",minute:"2-digit",hour12:!0})})}),R.jsxs("div",{className:"space-y-1",children:[m.map((me,De)=>R.jsx(e4,{messageId:me.id,message:me.content,isBot:me.isBot,showActions:m.length===1&&me.isBot,handleQuickAction:tt,quickActions:ye,isQuickActionsDisabled:re!==kt.CONNECTED||ce||!g,isStreaming:me.isBot&&ce&&De===m.length-1,handleRequestAppointment:we,refreshSession:$,progressMessage:me.isBot&&De===m.length-1?x:null,getAvailabilityDatesForAppointment:Me,getAvailableSlotsForAppointment:Ne,onUserFeedback:Ye,onLabPackageBook:st,tips:me.isBot&&De===m.length-1?E:null,isLastMessage:De===m.length-1,verificationStatus:P.active&&De===m.length-1,clearMobileVerification:M,onTipsExpire:()=>C(null),isRegenerating:me.isRegenerating,commonContentData:me.commonContentData,onContentClick:ee,onRegenerate:Rt,audioData:me.audioData,isResponded:me.isResponded,files:me.files,feedback:(me==null?void 0:me.feedback)||Mn.NONE},De)),v&&!ce&&R.jsx("div",{className:"px-4 py-4",children:R.jsxs("div",{className:"flex gap-2 items-start justify-center",children:[R.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full overflow-hidden",children:R.jsx("img",{src:"./assets/indian-doctor.png",alt:"Apollo Icon",className:"flex-shrink-0 w-full h-full object-cover scale-125"})}),R.jsx("div",{className:"flex-1",children:R.jsx("div",{className:"inline-flex items-center text-sm leading-relaxed p-3 rounded-3xl rounded-bl-none text-[var(--color-foreground)] bg-[var(--color-background-primary-default)]",children:R.jsx("div",{className:"flex items-center gap-1.5","aria-label":"Bot is typing",children:[0,1,2].map(me=>R.jsx("span",{className:"w-2 h-2 rounded-full bg-slate-400 animate-pulse",style:{animationDelay:`${me*150}ms`}},me))})})})]})}),x&&!ce&&R.jsx("div",{className:"px-2 py-4",children:R.jsxs("div",{className:"flex gap-1 items-start justify-center",children:[R.jsx("div",{className:"flex-shrink-0 w-6 h-6 rounded-full overflow-hidden",children:R.jsx("img",{src:"./assets/indian-doctor.png",alt:"Apollo Icon",className:"flex-shrink-0 w-6 h-6"})}),R.jsx("div",{className:"flex-1",children:R.jsx("div",{className:"text-sm leading-relaxed px-3 rounded-lg text-[var(--color-foreground)] bg-[var(--color-card)]",children:R.jsx("div",{className:"ml-2 bg-gradient-to-r from-[var(--color-primary)] via-[var(--color-primary-400)] to-[var(--color-primary-600)] bg-clip-text text-transparent font-medium",children:x})})})]})})]})]})}),!te&&R.jsx(TI,{onRetry:yt,onStartNewSession:ht,showRetryButton:Q,startNewConnection:q,clearError:ue,error:I,isConnected:re===kt.CONNECTED&&g}),(!P.active||P.stage==="uhid")&&R.jsx("div",{className:d?"pb-safe":"",children:R.jsx(r4,{onSendMessage:ee,onFinalAudioStream:Oe,inlineText:Be||"",onFileUpload:Ge,disabled:v||!!(x!=null&&x.length)||re!==kt.CONNECTED||!g,setError:fe,mobileVerificationStatus:P})}),P.active&&(P.stage==="mobile"?R.jsx(i4,{onSendMobile:ee,isLoading:P.isSending,disabled:P.isSending||v||!!(x!=null&&x.length)||re!==kt.CONNECTED||!g}):P.stage==="otp"&&P.mobile_number?R.jsx(a4,{mobileNumber:P.mobile_number,onSendOTP:ee}):null),R.jsx("div",{className:`flex items-center justify-center py-1.5 px-4 ${d?"pb-safe":""}`,children:R.jsx("div",{className:"flex items-center gap-1 text-xs text-[var(--color-muted-foreground)]",children:R.jsx("img",{src:"./assets/powered-by-eka-care.svg",alt:"eka.care",className:"h-3.5"})})})]})]})}const Qn=[];for(let n=0;n<256;++n)Qn.push((n+256).toString(16).slice(1));function d4(n,a=0){return(Qn[n[a+0]]+Qn[n[a+1]]+Qn[n[a+2]]+Qn[n[a+3]]+"-"+Qn[n[a+4]]+Qn[n[a+5]]+"-"+Qn[n[a+6]]+Qn[n[a+7]]+"-"+Qn[n[a+8]]+Qn[n[a+9]]+"-"+Qn[n[a+10]]+Qn[n[a+11]]+Qn[n[a+12]]+Qn[n[a+13]]+Qn[n[a+14]]+Qn[n[a+15]]).toLowerCase()}let bh;const h4=new Uint8Array(16);function p4(){if(!bh){if(typeof crypto=="undefined"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");bh=crypto.getRandomValues.bind(crypto)}return bh(h4)}const yE={randomUUID:typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function g4(n,a,i){var u,f,c;n=n||{};const l=(c=(f=n.random)!=null?f:(u=n.rng)==null?void 0:u.call(n))!=null?c:p4();if(l.length<16)throw new Error("Random bytes length must be >= 16");return l[6]=l[6]&15|64,l[8]=l[8]&63|128,d4(l)}function m4(n,a,i){return yE.randomUUID&&!n?yE.randomUUID():g4(n)}function EE({config:n}={}){const[a,i]=G.useState(!1),[l,u]=G.useState(!1),[f,c]=G.useState(!1),[d,p]=G.useState(!1),[g,A]=G.useState(!1),{isOnline:m}=bd(),y=_t(B=>B.setSessionId),E=_t(B=>B.setSessionToken),C=_t(B=>B.setError),x=_t(B=>B.setStartNewConnection);G.useEffect(()=>{const B=()=>{var Z;const z=window==null?void 0:window.innerWidth,P=(Z=navigator==null?void 0:navigator.userAgent)==null?void 0:Z.toLowerCase(),N=z<768||/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(P);c((n==null?void 0:n.mode)==="full"||N),A((n==null?void 0:n.mode)==="full")};return B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[]),G.useEffect(()=>{i(!0)},[]);const w=(B=!1)=>et(null,null,function*(){if(!m){console.warn("Cannot start session: user is offline");return}const z=_t.getState().sessionId,P=_t.getState().sessionToken;if(z&&P&&!B){i(!0);return}p(!0);try{console.log("Calling startSession API...");let N=localStorage.getItem("user_id");N||(N=m4(),localStorage.setItem("user_id",N));const{session_id:Z,session_token:ie}=yield Kk(N);if(!Z||!ie)throw new Error("Failed to start a new session - missing session_id or session_token");y(Z),E(ie),console.log("Session started successfully, widget opened with session:")}catch(N){console.error("Failed to start a new session:",N),C({title:N instanceof Error?N.message:"Something went wrong",description:"Please start a new session."}),x(!0)}finally{p(!1),i(!0)}}),v=()=>{n!=null&&n.onClose?n.onClose():(i(!1),u(!1))},D=()=>{u(!l)};return R.jsx("div",{children:R.jsxs(R.Fragment,{children:[(l||f)&&R.jsx("div",{className:"fixed inset-0 bg-transparent bg-opacity-50 z-40",onClick:v}),R.jsx("div",{style:{zIndex:99999},className:f?"fixed inset-0":l?"fixed inset-0 p-4":"fixed bottom-4 right-4",children:a&&R.jsx(f4,{title:"Apollo Assist",firstUserMessage:(n==null?void 0:n.firstUserMessage)||"",onClose:v,onExpand:D,isExpanded:l,isMobile:f,onStartSession:w,isLoading:d,isOnline:m,isFullMode:g})})]})})}const A4=({error:n,errorInfo:a,onRetry:i,title:l="There was a problem while loading your virtual assistant",message:u="Please try loading the chat again to fix the issue"})=>{const[f,c]=G.useState(!1);G.useEffect(()=>{console.log("error",n),console.log("errorInfo",a);const A=()=>{c(window.innerWidth<768)};return A(),window.addEventListener("resize",A),()=>window.removeEventListener("resize",A)},[]);const d=()=>{i?i():window.location.reload()},p=f?"fixed inset-0 z-[2147483647] bg-[var(--color-card)] border-border flex flex-col h-screen w-screen items-center justify-center":"fixed bottom-4 right-4 z-[2147483647] w-full max-w-sm bg-[var(--color-card)] border-border shadow-lg rounded-lg py-2 pb-4 items-center justify-center",g=f?"flex-1 min-h-0":"h-[500px]";return R.jsx("div",{className:p,children:R.jsxs("div",{className:`${g} flex flex-col items-center justify-center p-6 text-center`,children:[R.jsx("div",{children:R.jsx("img",{src:"./assets/error.png",alt:"Error Robot",className:`${f?"w-32 h-48":"w-[203px] h-[304px]"} flex-shrink-0 mx-auto aspect-[201/301]`})}),R.jsx("h1",{className:"text-md font-semibold text-gray-800 mb-3",children:l}),R.jsx("p",{className:"text-xs text-gray-600 mb-6",children:u}),R.jsx("div",{className:"space-y-3 w-full max-w-xs flex justify-center items-center",children:R.jsxs("button",{onClick:d,className:"w-fit bg-primary hover:bg-primary/80 text-white font-medium py-3 px-6 rounded-lg transition-colors duration-200 flex items-center justify-center space-x-2",children:[R.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),R.jsx("span",{children:"Reload chat"})]})})]})})};class y4 extends Kn.Component{constructor(a){super(a),this.state={hasError:!1}}static getDerivedStateFromError(a){return{hasError:!0,error:a}}componentDidCatch(a,i){console.error("ErrorBoundary caught an error:",a,i),this.setState({error:a,errorInfo:i})}render(){return this.state.hasError?this.props.fallback?this.props.fallback:R.jsx(A4,{error:this.state.error,errorInfo:this.state.errorInfo,onRetry:()=>this.setState({hasError:!1,error:void 0,errorInfo:void 0})}):this.props.children}}class E4 extends HTMLElement{constructor(){super();Gt(this,"shadowRootRef");Gt(this,"reactRoot",null);Gt(this,"container");Gt(this,"config",{});this.shadowRootRef=this.attachShadow({mode:"open"})}static get observedAttributes(){return["theme"]}setConfig(i){this.config=i}createLoadingStyles(){return`
|
|
496
496
|
:host { contain: content; }
|