diff --git a/dist/webdnn-1.2.4.tar.gz b/dist/webdnn-1.2.4.tar.gz deleted file mode 100644 index 91d149bc2..000000000 Binary files a/dist/webdnn-1.2.4.tar.gz and /dev/null differ diff --git a/dist/webdnn-1.2.5.tar.gz b/dist/webdnn-1.2.5.tar.gz new file mode 100644 index 000000000..f82ad88bf Binary files /dev/null and b/dist/webdnn-1.2.5.tar.gz differ diff --git a/dist/webdnn.d.ts b/dist/webdnn.d.ts index 751e949d4..9c81f8f77 100644 --- a/dist/webdnn.d.ts +++ b/dist/webdnn.d.ts @@ -875,6 +875,7 @@ declare module 'webdnn/descriptor_runner/descriptor_runner_webassembly' { static checkAvailability(): boolean; constructor(); init(): Promise; + private absolutePath(path); setDescriptorAndParameters(descriptor: GraphDescriptorWebassembly, parameters: ArrayBuffer): Promise; /** * Fetch graph descriptor from specified directory. @@ -925,7 +926,7 @@ declare module 'webdnn/descriptor_runner/descriptor_runner_webassembly' { [key: string]: number; }): Promise; private setPlaceholderValueWorker(dynamicBufferSize, metaBufferFillArray); - private compile(); + private compile(worker_src); private loadWeights(weightsData); getInputViews(): SymbolicFloat32Array[]; getOutputViews(): SymbolicFloat32Array[]; diff --git a/dist/webdnn.es5.js b/dist/webdnn.es5.js index 996cdefd6..ce2c8eba9 100644 --- a/dist/webdnn.es5.js +++ b/dist/webdnn.es5.js @@ -3,5 +3,5 @@ Version 1.5.6 https://localforage.github.io/localForage (c) 2013-2017 Mozilla, Apache License 2.0 -*/(function(t){e.exports=t()})(function(){return function d(p,e,t){function r(i,o){if(!e[i]){if(!p[i]){if(!o&&'function'==typeof a&&a)return a(i,!0);if(n)return n(i,!0);var s=new Error('Cannot find module \''+i+'\'');throw s.code='MODULE_NOT_FOUND',s}var c=e[i]={exports:{}};p[i][0].call(c.exports,function(t){var e=p[i][1][t];return r(e?e:t)},c,c.exports,d,p,e,t)}return e[i].exports}for(var n='function'==typeof a&&a,i=0;i=a.oldVersion&&e.createObjectStore(A)}catch(e){if('ConstraintError'===e.name)console.warn('The database "'+t.name+'" has been upgraded from version '+a.oldVersion+' to version '+a.newVersion+', but the storage "'+t.storeName+'" already exists.');else throw e}}),o.onerror=function(t){t.preventDefault(),r(o.error)},o.onsuccess=function(){a(o.result),p(t)}})}function f(e){return h(e,!1)}function _(e){return h(e,!0)}function g(e,t){if(!e.db)return!0;var a=!e.db.objectStoreNames.contains(e.storeName),r=e.versione.db.version;if(r&&(e.version!==t&&console.warn('The database "'+e.name+'" can\'t be downgraded from version '+e.db.version+' to version '+e.version+'.'),e.version=e.db.version),n||a){if(a){var o=e.db.version+1;o>e.version&&(e.version=o)}return!0}return!1}function b(t){return new P(function(a,e){var r=new FileReader;r.onerror=e,r.onloadend=function(r){var e=btoa(r.target.result||'');a({__local_forage_encoded_blob:!0,data:e,type:t.type})},r.readAsBinaryString(t)})}function m(e){var t=l(atob(e.data));return r([t],{type:e.type})}function y(e){return e&&e.__local_forage_encoded_blob}function v(e){var t=this,a=t._initReady().then(function(){var e=fe[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady});return n(a,e,e),a}function w(e){u(e);for(var t=fe[e.name],a=t.forages,r=0;r>4,u[r++]=(15&i)<<4|l>>2,u[r++]=(3&l)<<6|63&s;return d}function k(e){var t=new Uint8Array(e),a='',r;for(r=0;r>2],a+=F[(3&t[r])<<4|t[r+1]>>4],a+=F[(15&t[r+1])<<2|t[r+2]>>6],a+=F[63&t[r+2]];return 2==t.length%3?a=a.substring(0,a.length-1)+'=':1==t.length%3&&(a=a.substring(0,a.length-2)+'=='),a}function C(e,t,a,r){var n=this;e=i(e);var l=new P(function(o,i){n.ready().then(function(){void 0===t&&(t=null);var l=t,s=n._dbInfo;s.serializer.serialize(t,function(d,t){t?i(t):s.db.transaction(function(a){a.executeSql('INSERT OR REPLACE INTO '+s.storeName+' (key, value) VALUES (?, ?)',[e,d],function(){o(l)},function(e,t){i(t)})},function(t){if(t.code===t.QUOTA_ERR){if(0e?void t(null):void a.ready().then(function(){x(a._dbInfo,O,function(n,o){if(n)return r(n);try{var i=o.objectStore(a._dbInfo.storeName),l=!1,s=i.openCursor();s.onsuccess=function(){var a=s.result;return a?void(0===e?t(a.key):l?t(a.key):(l=!0,a.advance(e))):void t(null)},s.onerror=function(){r(s.error)}}catch(t){r(t)}})})['catch'](r)});return o(r,t),r},keys:function(e){var t=this,a=new P(function(e,a){t.ready().then(function(){x(t._dbInfo,O,function(r,n){if(r)return a(r);try{var o=n.objectStore(t._dbInfo.storeName),i=o.openCursor(),l=[];i.onsuccess=function(){var t=i.result;return t?void(l.push(t.key),t['continue']()):void e(l)},i.onerror=function(){a(i.error)}}catch(t){a(t)}})})['catch'](a)});return o(a,e),a}},F='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',M=/^~~local_forage_type~([^~]+)~/,U='__lfsc__:',W=U.length,j='arbf',G='blob',H='si08',V='ui08',X='uic8',Y='si16',Z='si32',K='ur16',q='ui32',Q='fl32',J='fl64',$=W+j.length,ee=Object.prototype.toString,te={serialize:function(t,a){var e='';if(t&&(e=ee.call(t)),t&&('[object ArrayBuffer]'===e||t.buffer&&'[object ArrayBuffer]'===ee.call(t.buffer))){var r=U,n;t instanceof ArrayBuffer?(n=t,r+=j):(n=t.buffer,'[object Int8Array]'===e?r+=H:'[object Uint8Array]'===e?r+=V:'[object Uint8ClampedArray]'===e?r+=X:'[object Int16Array]'===e?r+=Y:'[object Uint16Array]'===e?r+=K:'[object Int32Array]'===e?r+=Z:'[object Uint32Array]'===e?r+=q:'[object Float32Array]'===e?r+=Q:'[object Float64Array]'===e?r+=J:a(new Error('Failed to get type for BinaryArray'))),a(r+k(n))}else if('[object Blob]'===e){var o=new FileReader;o.onload=function(){var e='~~local_forage_type~'+t.type+'~'+k(this.result);a(U+G+e)},o.readAsArrayBuffer(t)}else try{a(JSON.stringify(t))}catch(r){console.error('Couldn\'t convert value into a JSON string: ',t),a(null,r)}},deserialize:function(e){if(e.substring(0,W)!==U)return JSON.parse(e);var t=e.substring($),a=e.substring(W,$),n;if(a===G&&M.test(t)){var o=t.match(M);n=o[1],t=t.substring(o[0].length)}var i=E(t);switch(a){case j:return i;case G:return r([i],{type:n});case H:return new Int8Array(i);case V:return new Uint8Array(i);case X:return new Uint8ClampedArray(i);case Y:return new Int16Array(i);case K:return new Uint16Array(i);case Z:return new Int32Array(i);case q:return new Uint32Array(i);case Q:return new Float32Array(i);case J:return new Float64Array(i);default:throw new Error('Unkown type: '+a);}},stringToBuffer:E,bufferToString:k},ae={_driver:'webSQLStorage',_initStorage:function(e){var t=this,a={db:null};if(e)for(var r in e)a[r]='string'==typeof e[r]?e[r]:e[r].toString();var n=new P(function(e,r){try{a.db=openDatabase(a.name,a.version+'',a.description,a.size)}catch(t){return r(t)}a.db.transaction(function(n){n.executeSql('CREATE TABLE IF NOT EXISTS '+a.storeName+' (id INTEGER PRIMARY KEY, key unique, value)',[],function(){t._dbInfo=a,e()},function(e,t){r(t)})})});return a.serializer=te,n},_support:function(){return'function'==typeof openDatabase}(),iterate:function(e,t){var a=this,r=new P(function(r,n){a.ready().then(function(){var o=a._dbInfo;o.db.transaction(function(a){a.executeSql('SELECT * FROM '+o.storeName,[],function(a,t){for(var n=t.rows,l=n.length,s=0;s>>16,l=0;0!==a;){l=2e3t;t++){a=t;for(var r=0;8>r;r++)a=1&a?3988292384^a>>>1:a>>>1;e[t]=a}return e}();e.exports=function(e,a,r,n){e^=-1;for(var o=n;o>>8^t[255&(e^a[o])];return-1^e}},function(t,a,r){'use strict';function n(t,a){if(65537>a&&(t.subarray&&s||!t.subarray&&l))return e.apply(null,o.shrinkBuf(t,a));for(var r='',n=0;ni;i++)d[i]=252<=i?6:248<=i?5:240<=i?4:224<=i?3:192<=i?2:1;d[254]=d[254]=1,a.string2buf=function(e){var t=e.length,a=0,r,n,l,s,d;for(s=0;sn?1:2048>n?2:65536>n?3:4;for(r=new o.Buf8(a),d=0,s=0;dn?r[d++]=n:2048>n?(r[d++]=192|n>>>6,r[d++]=128|63&n):65536>n?(r[d++]=224|n>>>12,r[d++]=128|63&n>>>6,r[d++]=128|63&n):(r[d++]=240|n>>>18,r[d++]=128|63&n>>>12,r[d++]=128|63&n>>>6,r[d++]=128|63&n);return r},a.buf2binstring=function(e){return n(e,e.length)},a.binstring2buf=function(e){for(var t=new o.Buf8(e.length),a=0,r=t.length;al){r[i++]=l;continue}if(s=d[l],4l?r[i++]=l:(l-=65536,r[i++]=55296|1023&l>>10,r[i++]=56320|1023&l)}return n(r,i)},a.utf8border=function(e,t){var a;for(t=t||e.length,t>e.length&&(t=e.length),a=t-1;0<=a&&128==(192&e[a]);)a--;return 0>a?t:0===a?t:a+d[e[a]]>t?a:t}},function(e){'use strict';e.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}},function(e){'use strict';e.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}},function(e,t,a){'use strict';function r(e){return'WebGL2RenderingContext'===e.constructor.name}function n(e){if(null===e)throw Error('Null is detected');return e}var o=this&&this.__awaiter||function(e,t,a,r){return new(a||(a=Promise))(function(n,o){function i(e){try{s(r.next(e))}catch(t){o(t)}}function l(e){try{s(r['throw'](e))}catch(t){o(t)}}function s(e){e.done?n(e.value):new a(function(t){t(e.value)}).then(i,l)}s((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,a){function r(e){return function(t){return o([e,t])}}function o(r){if(i)throw new TypeError('Generator is already executing.');for(;n;)try{if(i=1,l&&(s=l[2&r[0]?'return':r[0]?'throw':'next'])&&!(s=s.call(l,r[1])).done)return s;switch((l=0,s)&&(r=[0,s.value]),r[0]){case 0:case 1:s=r;break;case 4:return n.label++,{value:r[1],done:!1};case 5:n.label++,l=r[1],r=[0];continue;case 7:r=n.ops.pop(),n.trys.pop();continue;default:if((s=n.trys,!(s=0s[0]&&r[1]l.getConfiguration('MAX_TEXTURE_SIZE',t.getParameter(t.MAX_TEXTURE_SIZE)))}return u},e.prototype.waitForComplete=function(){return o(this,void 0,void 0,function(){var e,t,a;return i(this,function(n){switch(n.label){case 0:if(e=this.gl,!r(e))return[3,4];t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0),a=e.clientWaitSync(t,0,0),n.label=1;case 1:return a===e.CONDITION_SATISFIED||a===e.ALREADY_SIGNALED?[3,3]:[4,new Promise(function(e){return setTimeout(e,1)})];case 2:return n.sent(),a=e.clientWaitSync(t,0,0),[3,1];case 3:return e.deleteSync(t),[3,5];case 4:e.finish(),n.label=5;case 5:return[2];}})})},Object.defineProperty(e.prototype,'MAX_TEXTURE_SIZE',{get:function(){var e=l.getConfiguration('MAX_TEXTURE_SIZE',this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE));if(16384<=e)return 4096;if(8192<=e)return 4096;if(4096<=e)return 4096;throw new Error('MAX_TEXTURE_SIZE is too small: '+e)},enumerable:!0,configurable:!0}),e.IS_SAFARI=-1!==navigator.userAgent.toLowerCase().indexOf('safari')&&-1===navigator.userAgent.toLowerCase().indexOf('chrome'),e}(),d;t.default=s;var u=null},function(e,t){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var a=function(){return function(e,t){this.byteLength=e,this.backend=t}}();t.Buffer=a},function(e,t,a){'use strict';var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])};return function(t,a){function r(){this.constructor=t}e(t,a),t.prototype=null===a?Object.create(a):(r.prototype=a.prototype,new r)}}(),n=this&&this.__awaiter||function(e,t,a,r){return new(a||(a=Promise))(function(n,o){function i(e){try{s(r.next(e))}catch(t){o(t)}}function l(e){try{s(r['throw'](e))}catch(t){o(t)}}function s(e){e.done?n(e.value):new a(function(t){t(e.value)}).then(i,l)}s((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,a){function r(e){return function(t){return o([e,t])}}function o(r){if(i)throw new TypeError('Generator is already executing.');for(;n;)try{if(i=1,l&&(s=l[2&r[0]?'return':r[0]?'throw':'next'])&&!(s=s.call(l,r[1])).done)return s;switch((l=0,s)&&(r=[0,s.value]),r[0]){case 0:case 1:s=r;break;case 4:return n.label++,{value:r[1],done:!1};case 5:n.label++,l=r[1],r=[0];continue;case 7:r=n.ops.pop(),n.trys.pop();continue;default:if((s=n.trys,!(s=0s[0]&&r[1]s[0]&&r[1]s[0]&&r[1]s[0]&&r[1]s[0]&&r[1]f;f++)h[f]=e.decode_table[127&f]*c*(128>f?1:-1);for(i=new Uint8Array(t.buffer,t.byteOffset+d,p),_=o.inflate(i),g=_.length,b=new Float32Array(g),m=0;mt.windowBits&&(t.windowBits+=16),this.err=0,this.msg='',this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var a=o.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(a!==c)throw new Error(s[a]);if(t.header&&o.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n='string'==typeof t.dictionary?l.string2buf(t.dictionary):'[object ArrayBuffer]'===u.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,a=o.deflateSetDictionary(this.strm,n),a!==c)throw new Error(s[a]);this._dict_set=!0}}function n(e,t){var a=new r(t);if(a.push(e,!0),a.err)throw a.msg||s[a.err];return a.result}var o=a(26),i=a(0),l=a(11),s=a(8),d=a(12),u=Object.prototype.toString,p=4,c=0,h=1,f=2,_=-1,g=0,b=8;r.prototype.push=function(e,t){var a=this.strm,r=this.options.chunkSize,n,s;if(this.ended)return!1;s=t===~~t?t:!0===t?p:0,a.input='string'==typeof e?l.string2buf(e):'[object ArrayBuffer]'===u.call(e)?new Uint8Array(e):e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new i.Buf8(r),a.next_out=0,a.avail_out=r),n=o.deflate(a,s),n!==h&&n!==c)return this.onEnd(n),this.ended=!0,!1;(0===a.avail_out||0===a.avail_in&&(s===p||s===f))&&('string'===this.options.to?this.onData(l.buf2binstring(i.shrinkBuf(a.output,a.next_out))):this.onData(i.shrinkBuf(a.output,a.next_out)))}while((0e.avail_out&&(a=e.avail_out);0===a||(E.arraySet(e.output,t.pending_buf,t.pending_out,a,e.next_out),e.next_out+=a,t.pending_out+=a,e.total_out+=a,e.avail_out-=a,t.pending-=a,0===t.pending&&(t.pending_out=0))}function l(e,t){k._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,i(e.strm)}function d(e,t){e.pending_buf[e.pending++]=t}function u(e,t){e.pending_buf[e.pending++]=255&t>>>8,e.pending_buf[e.pending++]=255&t}function c(e,t,a,r){var n=e.avail_in;return(n>r&&(n=r),0===n)?0:(e.avail_in-=n,E.arraySet(t,e.input,e.next_in,n,a),1===e.state.wrap?e.adler=C(e.adler,t,n,a):2===e.state.wrap&&(e.adler=T(e.adler,t,n,a)),e.next_in+=n,e.total_in+=n,n)}function p(e,t){var a=e.max_chain_length,r=e.strstart,n=e.prev_length,o=e.nice_match,i=e.strstart>e.w_size-K?e.strstart-(e.w_size-K):0,l=e.window,s=e.w_mask,d=e.prev,u=e.strstart+Z,p=l[r+n-1],c=l[r+n],h,f;e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(h=t,l[h+n]!==c||l[h+n-1]!==p||l[h]!==l[r]||l[++h]!==l[r+1])continue;r+=2,h++;do;while(l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&rn){if(e.match_start=t,n=f,f>=o)break;p=l[r+n-1],c=l[r+n]}}while((t=d[t&s])>i&&0!=--a);return n<=e.lookahead?n:e.lookahead}function h(e){var t=e.w_size,a,r,n,o,i;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-K)){E.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,a=r;do n=e.head[--a],e.head[a]=n>=t?n-t:0;while(--r);r=t,a=r;do n=e.prev[--a],e.prev[a]=n>=t?n-t:0;while(--r);o+=t}if(0===e.strm.avail_in)break;if(r=c(e.strm,e.window,e.strstart+e.lookahead,o),e.lookahead+=r,e.lookahead+e.insert>=Y)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=(e.ins_h<=Y&&(e.ins_h=(e.ins_h<=Y))r=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;else if(r=k._tr_tally(e,e.strstart-e.match_start,e.match_length-Y),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Y){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=Y&&(e.ins_h=(e.ins_h<=e.match_length&&(e.strategy===N||e.match_length===Y&&4096=Y&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-Y,r=k._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Y),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=n&&(e.ins_h=(e.ins_h<=Y&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Y?(r=k._tr_tally(e,1,e.match_length-Y),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(l(e,!1),0===e.strm.avail_out))return re}return e.insert=0,t===R?(l(e,!0),0===e.strm.avail_out?oe:ie):e.last_lit&&(l(e,!1),0===e.strm.avail_out)?re:ne}function g(e,t){for(var a;;){if(0===e.lookahead&&(h(e),0===e.lookahead)){if(t===S)return re;break}if(e.match_length=0,a=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,a&&(l(e,!1),0===e.strm.avail_out))return re}return e.insert=0,t===R?(l(e,!0),0===e.strm.avail_out?oe:ie):e.last_lit&&(l(e,!1),0===e.strm.avail_out)?re:ne}function b(e,t,a,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=a,this.max_chain=r,this.func=n}function m(e){e.window_size=2*e.w_size,o(e.head),e.max_lazy_match=le[e.level].max_lazy,e.good_match=le[e.level].good_length,e.nice_match=le[e.level].nice_length,e.max_chain_length=le[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Y-1,e.match_available=0,e.ins_h=0}function y(){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=U,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 E.Buf16(2*V),this.dyn_dtree=new E.Buf16(2*(2*G+1)),this.bl_tree=new E.Buf16(2*(2*H+1)),o(this.dyn_ltree),o(this.dyn_dtree),o(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new E.Buf16(X+1),this.heap=new E.Buf16(2*j+1),o(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new E.Buf16(2*j+1),o(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 v(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=M,t=e.state,t.pending=0,t.pending_out=0,0>t.wrap&&(t.wrap=-t.wrap),t.status=t.wrap?q:te,e.adler=2===t.wrap?0:1,t.last_flush=S,k._tr_init(t),D):r(e,A)}function w(e){var t=v(e);return t===D&&m(e.state),t}function x(e,t,a,n,o,i){if(!e)return A;var l=1;if(t===O&&(t=6),0>n?(l=0,n=-n):15o||o>W||a!==U||8>n||15t||9i||i>F)return r(e,A);8===n&&(n=9);var d=new y;return e.state=d,d.strm=e,d.wrap=l,d.gzhead=null,d.w_bits=n,d.w_size=1<e.pending_buf_size-5&&(a=e.pending_buf_size-5);;){if(1>=e.lookahead){if(h(e),0===e.lookahead&&t===S)return re;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+a;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,l(e,!1),0===e.strm.avail_out))return re;if(e.strstart-e.block_start>=e.w_size-K&&(l(e,!1),0===e.strm.avail_out))return re}return e.insert=0,t===R?(l(e,!0),0===e.strm.avail_out?oe:ie):e.strstart>e.block_start&&(l(e,!1),0===e.strm.avail_out)?re:re}),new b(4,4,8,4,s),new b(4,5,16,8,s),new b(4,6,32,32,s),new b(4,4,16,16,f),new b(8,16,32,32,f),new b(8,16,128,128,f),new b(8,32,128,256,f),new b(32,128,258,1024,f),new b(32,258,258,4096,f)],t.deflateInit=function(e,t){return x(e,t,U,15,8,0)},t.deflateInit2=x,t.deflateReset=w,t.deflateResetKeep=v,t.deflateSetHeader=function(e,t){return e&&e.state?2===e.state.wrap?(e.state.gzhead=t,D):A:A},t.deflate=function(e,t){var a,l,s,p;if(!e||!e.state||t>B||0>t)return e?r(e,A):A;if(l=e.state,!e.output||!e.input&&0!==e.avail_in||l.status===ae&&t!==R)return r(e,0===e.avail_out?z:A);if(l.strm=e,a=l.last_flush,l.last_flush=t,l.status===q)if(2===l.wrap)e.adler=0,d(l,31),d(l,139),d(l,8),l.gzhead?(d(l,(l.gzhead.text?1:0)+(l.gzhead.hcrc?2:0)+(l.gzhead.extra?4:0)+(l.gzhead.name?8:0)+(l.gzhead.comment?16:0)),d(l,255&l.gzhead.time),d(l,255&l.gzhead.time>>8),d(l,255&l.gzhead.time>>16),d(l,255&l.gzhead.time>>24),d(l,9===l.level?2:l.strategy>=L||2>l.level?4:0),d(l,255&l.gzhead.os),l.gzhead.extra&&l.gzhead.extra.length&&(d(l,255&l.gzhead.extra.length),d(l,255&l.gzhead.extra.length>>8)),l.gzhead.hcrc&&(e.adler=T(e.adler,l.pending_buf,l.pending,0)),l.gzindex=0,l.status=Q):(d(l,0),d(l,0),d(l,0),d(l,0),d(l,0),d(l,9===l.level?2:l.strategy>=L||2>l.level?4:0),d(l,3),l.status=te);else{var c=U+(l.w_bits-8<<4)<<8,h=-1;h=l.strategy>=L||2>l.level?0:6>l.level?1:6===l.level?2:3,c|=h<<6,0!==l.strstart&&(c|=32),c+=31-c%31,l.status=te,u(l,c),0!==l.strstart&&(u(l,e.adler>>>16),u(l,65535&e.adler)),e.adler=1}if(l.status===Q)if(l.gzhead.extra){for(s=l.pending;l.gzindex<(65535&l.gzhead.extra.length)&&!(l.pending===l.pending_buf_size&&(l.gzhead.hcrc&&l.pending>s&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),i(e),s=l.pending,l.pending===l.pending_buf_size));)d(l,255&l.gzhead.extra[l.gzindex]),l.gzindex++;l.gzhead.hcrc&&l.pending>s&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),l.gzindex===l.gzhead.extra.length&&(l.gzindex=0,l.status=J)}else l.status=J;if(l.status===J)if(l.gzhead.name){s=l.pending;do{if(l.pending===l.pending_buf_size&&(l.gzhead.hcrc&&l.pending>s&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),i(e),s=l.pending,l.pending===l.pending_buf_size)){p=1;break}p=l.gzindexs&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),0===p&&(l.gzindex=0,l.status=$)}else l.status=$;if(l.status===$)if(l.gzhead.comment){s=l.pending;do{if(l.pending===l.pending_buf_size&&(l.gzhead.hcrc&&l.pending>s&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),i(e),s=l.pending,l.pending===l.pending_buf_size)){p=1;break}p=l.gzindexs&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),0===p&&(l.status=ee)}else l.status=ee;if(l.status===ee&&(l.gzhead.hcrc?(l.pending+2>l.pending_buf_size&&i(e),l.pending+2<=l.pending_buf_size&&(d(l,255&e.adler),d(l,255&e.adler>>8),e.adler=0,l.status=te)):l.status=te),0!==l.pending){if(i(e),0===e.avail_out)return l.last_flush=-1,D;}else if(0===e.avail_in&&n(t)<=n(a)&&t!==R)return r(e,z);if(l.status===ae&&0!==e.avail_in)return r(e,z);if(0!==e.avail_in||0!==l.lookahead||t!==S&&l.status!==ae){var f=l.strategy===L?g(l,t):l.strategy===3?_(l,t):le[l.level].func(l,t);if((f===oe||f===ie)&&(l.status=ae),f===re||f===oe)return 0===e.avail_out&&(l.last_flush=-1),D;if(f===ne&&(t===1?k._tr_align(l):t!==B&&(k._tr_stored_block(l,0,0,!1),t===3&&(o(l.head),0===l.lookahead&&(l.strstart=0,l.block_start=0,l.insert=0))),i(e),0===e.avail_out))return l.last_flush=-1,D}return t===R?0>=l.wrap?P:(2===l.wrap?(d(l,255&e.adler),d(l,255&e.adler>>8),d(l,255&e.adler>>16),d(l,255&e.adler>>24),d(l,255&e.total_in),d(l,255&e.total_in>>8),d(l,255&e.total_in>>16),d(l,255&e.total_in>>24)):(u(l,e.adler>>>16),u(l,65535&e.adler)),i(e),0=r.w_size&&(0===n&&(o(r.head),r.strstart=0,r.block_start=0,r.insert=0),p=new E.Buf8(r.w_size),E.arraySet(p,t,a-r.w_size,r.w_size,0),t=p,a=r.w_size),s=e.avail_in,d=e.next_in,u=e.input,e.avail_in=a,e.next_in=0,e.input=t,h(r);r.lookahead>=Y;){i=r.strstart,l=r.lookahead-(Y-1);do r.ins_h=(r.ins_h<e?J[e]:J[256+(e>>>7)]}function l(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=255&t>>>8}function d(e,t,a){e.bi_valid>U-a?(e.bi_buf|=65535&t<>U-e.bi_valid,e.bi_valid+=a-U):(e.bi_buf|=65535&t<>>=1,a<<=1;while(0<--t);return a>>>1}function p(e){16===e.bi_valid?(l(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}function c(e,t){var a=t.dyn_tree,r=t.max_code,o=t.stat_desc.static_tree,i=t.stat_desc.has_stree,l=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,d=t.stat_desc.max_length,u=0,p,c,n,h,_,g;for(h=0;h<=M;h++)e.bl_count[h]=0;for(a[2*e.heap[e.heap_max]+1]=0,p=e.heap_max+1;pd&&(h=d,u++),a[2*c+1]=h,!(c>r))&&(e.bl_count[h]++,_=0,c>=s&&(_=l[c-s]),g=a[2*c],e.opt_len+=g*(h+_),i&&(e.static_len+=g*(o[2*c+1]+_)));if(0!=u){do{for(h=d-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[d]--,u-=2}while(0r))&&(a[2*n+1]!==h&&(e.opt_len+=(h-a[2*n+1])*a[2*n],a[2*n+1]=h),c--)}}function h(e,t,a){var r=Array(M+1),o=0,i,l;for(i=1;i<=M;i++)r[i]=o=o+a[i-1]<<1;for(l=0;l<=t;l++){var n=e[2*l+1];0!==n&&(e[2*l]=s(r[n]++,n))}}function f(){var e=Array(M+1),t,a,r,n,i;for(r=0,n=0;nn;n++)for(te[n]=i,t=0;t<1<>=7;n=t;)q[2*t+1]=8,t++,e[8]++;for(;255>=t;)q[2*t+1]=9,t++,e[9]++;for(;279>=t;)q[2*t+1]=7,t++,e[7]++;for(;287>=t;)q[2*t+1]=8,t++,e[8]++;for(h(q,O+1,e),t=0;te.heap_len;)d=e.heap[++e.heap_len]=2>l?++l:0,a[2*d]=1,e.depth[d]=0,e.opt_len--,o&&(e.static_len-=r[2*d+1]);for(t.max_code=l,s=e.heap_len>>1;1<=s;s--)y(e,a,s);d=i;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],y(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=n,a[2*d]=a[2*s]+a[2*n],e.depth[d]=(e.depth[s]>=e.depth[n]?e.depth[s]:e.depth[n])+1,a[2*s+1]=a[2*n+1]=d,e.heap[1]=d++,y(e,a,1);while(2<=e.heap_len);e.heap[--e.heap_max]=e.heap[1],c(e,t),h(a,l,e.bl_count)}function x(e,t,a){var r=-1,o=t[1],i=0,l=7,s=4,d,n;for(0===o&&(l=138,s=3),t[2*(a+1)+1]=65535,d=0;d<=a;d++){if(n=o,o=t[2*(d+1)+1],++i=i?e.bl_tree[2*H]++:e.bl_tree[2*V]++:(n!==r&&e.bl_tree[2*n]++,e.bl_tree[2*G]++);i=0,r=n,0===o?(l=138,s=3):n===o?(l=6,s=3):(l=7,s=4)}}function E(e,t,a){var r=-1,o=t[1],i=0,l=7,s=4,p,n;for(0===o&&(l=138,s=3),p=0;p<=a;p++){if(n=o,o=t[2*(p+1)+1],++i=i?(u(e,H,e.bl_tree),d(e,i-3,3)):(u(e,V,e.bl_tree),d(e,i-11,7)):(n!==r&&(u(e,n,e.bl_tree),i--),u(e,G,e.bl_tree),d(e,i-3,2));i=0,r=n,0===o?(l=138,s=3):n===o?(l=6,s=3):(l=7,s=4)}}function k(e){var t;for(x(e,e.dyn_ltree,e.l_desc.max_code),x(e,e.dyn_dtree,e.d_desc.max_code),w(e,e.bl_desc),t=L-1;3<=t&&0===e.bl_tree[2*K[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}function C(e,t,a,r){var n;for(d(e,t-257,5),d(e,a-1,5),d(e,r-4,4),n=0;n=a;a++,t>>>=1)if(1&t&&0!==e.dyn_ltree[2*a])return R;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return B;for(a=32;a>>3,i=e.static_len+3+7>>>3,i<=o&&(o=i)):o=i=a+5,a+4<=o&&-1!==t?I(e,t,a,r):e.strategy===4||i===o?(d(e,(P<<1)+(r?1:0),3),v(e,q,Q)):(d(e,(2<<1)+(r?1:0),3),C(e,e.l_desc.max_code+1,e.d_desc.max_code+1,n+1),v(e,e.dyn_ltree,e.dyn_dtree)),_(e),r&&g(e)},t._tr_tally=function(e,t,a){return e.pending_buf[e.d_buf+2*e.last_lit]=255&t>>>8,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&a,e.last_lit++,0===t?e.dyn_ltree[2*a]++:(e.matches++,t--,e.dyn_ltree[2*($[a]+z+1)]++,e.dyn_dtree[2*i(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){d(e,P<<1,3),u(e,j,q),p(e)}},function(e,t,a){'use strict';function r(e){if(!(this instanceof r))return new r(e);this.options=i.assign({chunkSize:16384,windowBits:0,to:''},e||{});var t=this.options;t.raw&&0<=t.windowBits&&16>t.windowBits&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),0<=t.windowBits&&16>t.windowBits&&!(e&&e.windowBits)&&(t.windowBits+=32),15t.windowBits&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg='',this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var a=o.inflateInit2(this.strm,t.windowBits);if(a!==s.Z_OK)throw new Error(d[a]);this.header=new p,o.inflateGetHeader(this.strm,this.header)}function n(e,t){var a=new r(t);if(a.push(e,!0),a.err)throw a.msg||d[a.err];return a.result}var o=a(29),i=a(0),l=a(11),s=a(13),d=a(8),u=a(12),p=a(32),c=Object.prototype.toString;r.prototype.push=function(e,t){var a=this.strm,r=this.options.chunkSize,n=this.options.dictionary,d=!1,u,p,h,f,_,g;if(this.ended)return!1;p=t===~~t?t:!0===t?s.Z_FINISH:s.Z_NO_FLUSH,a.input='string'==typeof e?l.binstring2buf(e):'[object ArrayBuffer]'===c.call(e)?new Uint8Array(e):e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new i.Buf8(r),a.next_out=0,a.avail_out=r),u=o.inflate(a,s.Z_NO_FLUSH),u===s.Z_NEED_DICT&&n&&(g='string'==typeof n?l.string2buf(n):'[object ArrayBuffer]'===c.call(n)?new Uint8Array(n):n,u=o.inflateSetDictionary(this.strm,g)),u===s.Z_BUF_ERROR&&!0==d&&(u=s.Z_OK,d=!1),u!==s.Z_STREAM_END&&u!==s.Z_OK)return this.onEnd(u),this.ended=!0,!1;a.next_out&&(0===a.avail_out||u===s.Z_STREAM_END||0===a.avail_in&&(p===s.Z_FINISH||p===s.Z_SYNC_FLUSH))&&('string'===this.options.to?(h=l.utf8border(a.output,a.next_out),f=a.next_out-h,_=l.buf2string(a.output,h),a.next_out=f,a.avail_out=r-f,f&&i.arraySet(a.output,a.output,h,f,0),this.onData(_)):this.onData(i.shrinkBuf(a.output,a.next_out))),0===a.avail_in&&0===a.avail_out&&(d=!0)}while((0>>24)+(65280&e>>>8)+((65280&e)<<8)+((255&e)<<24)}function n(){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 c.Buf16(320),this.work=new c.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function i(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg='',t.wrap&&(e.adler=1&t.wrap),t.mode=T,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new c.Buf32(re),t.distcode=t.distdyn=new c.Buf32(ne),t.sane=1,t.back=-1,w):x}function l(e){var t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,i(e)):x}function s(e,t){var a,r;return e&&e.state?(r=e.state,0>t?(a=0,t=-t):(a=(t>>4)+1,48>t&&(t&=15)),t&&(8>t||15t;)e.lens[t++]=8;for(;256>t;)e.lens[t++]=9;for(;280>t;)e.lens[t++]=7;for(;288>t;)e.lens[t++]=8;for(g(b,e.lens,0,288,ie,0,e.work,{bits:9}),t=0;32>t;)e.lens[t++]=5;g(m,e.lens,0,32,le,0,e.work,{bits:5}),oe=!1}e.lencode=ie,e.lenbits=9,e.distcode=le,e.distbits=5}function p(e,t,a,r){var n=e.state,o;return null===n.window&&(n.wsize=1<=n.wsize?(c.arraySet(n.window,t,a-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):(o=n.wsize-n.wnext,o>r&&(o=r),c.arraySet(n.window,t,a-r,o,n.wnext),r-=o,r?(c.arraySet(n.window,t,a-r,r,0),n.wnext=r,n.whave=n.wsize):(n.wnext+=o,n.wnext===n.wsize&&(n.wnext=0),n.whavede;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>8,s.check=f(s.check,i,2,0),se=0,de=0,s.mode=I;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&se)<<8)+(se>>8))%31){t.msg='incorrect header check',s.mode=te;break}if((15&se)!=C){t.msg='unknown compression method',s.mode=te;break}if(se>>>=4,de-=4,we=(15&se)+8,0===s.wbits)s.wbits=we;else if(we>s.wbits){t.msg='invalid window size',s.mode=te;break}s.dmax=1<de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>8),512&s.flags&&(i[0]=255&se,i[1]=255&se>>>8,s.check=f(s.check,i,2,0)),se=0,de=0,s.mode=S;case S:for(;32>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>8,i[2]=255&se>>>16,i[3]=255&se>>>24,s.check=f(s.check,i,4,0)),se=0,de=0,s.mode=R;case R:for(;16>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>8),512&s.flags&&(i[0]=255&se,i[1]=255&se>>>8,s.check=f(s.check,i,2,0)),se=0,de=0,s.mode=B;case B:if(1024&s.flags){for(;16>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>8,s.check=f(s.check,i,2,0)),se=0,de=0}else s.head&&(s.head.extra=null);s.mode=D;case D:if(1024&s.flags&&(ce=s.length,ce>ie&&(ce=ie),ce&&(s.head&&(we=s.head.extra_len-s.length,!s.head.extra&&(s.head.extra=Array(s.head.extra_len)),c.arraySet(s.head.extra,d,ne,ce,we)),512&s.flags&&(s.check=f(s.check,d,ce,ne)),ie-=ce,ne+=ce,s.length-=ce),s.length))break inf_leave;s.length=0,s.mode=P;case P:if(2048&s.flags){if(0===ie)break inf_leave;ce=0;do we=d[ne+ce++],s.head&&we&&65536>s.length&&(s.head.name+=e(we));while(we&&ces.length&&(s.head.comment+=e(we));while(we&&cede;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>9,s.head.done=!0),t.adler=s.check=0,s.mode=L;break;case O:for(;32>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=7&de,de-=7&de,s.mode=J;break}for(;3>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=1,de-=1,3&se){case 0:s.mode=M;break;case 1:if(u(s),s.mode=V,a===v){se>>>=2,de-=2;break inf_leave}break;case 2:s.mode=j;break;case 3:t.msg='invalid block type',s.mode=te;}se>>>=2,de-=2;break;case M:for(se>>>=7&de,de-=7&de;32>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>16)){t.msg='invalid stored block lengths',s.mode=te;break}if(s.length=65535&se,se=0,de=0,s.mode=U,a===v)break inf_leave;case U:s.mode=W;case W:if(ce=s.length,ce){if(ce>ie&&(ce=ie),ce>le&&(ce=le),0===ce)break inf_leave;c.arraySet(re,d,ne,ce,oe),ie-=ce,ne+=ce,le-=ce,oe+=ce,s.length-=ce;break}s.mode=L;break;case j:for(;14>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=5,de-=5,s.ndist=(31&se)+1,se>>>=5,de-=5,s.ncode=(15&se)+4,se>>>=4,de-=4,286de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=3,de-=3}for(;19>s.have;)s.lens[l[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,Ee={bits:s.lenbits},xe=g(0,s.lens,0,19,s.lencode,0,s.work,Ee),s.lenbits=Ee.bits,xe){t.msg='invalid code lengths set',s.mode=te;break}s.have=0,s.mode=H;case H:for(;s.have>>24,ge=255&r>>>16,be=65535&r,_e<=de)break;if(0===ie)break inf_leave;ie--,se+=d[ne++]<be)se>>>=_e,de-=_e,s.lens[s.have++]=be;else{if(16===be){for(ke=_e+2;de>>=_e,de-=_e,0===s.have){t.msg='invalid bit length repeat',s.mode=te;break}we=s.lens[s.have-1],ce=3+(3&se),se>>>=2,de-=2}else if(17===be){for(ke=_e+3;de>>=_e,de-=_e,we=0,ce=3+(7&se),se>>>=3,de-=3}else{for(ke=_e+7;de>>=_e,de-=_e,we=0,ce=11+(127&se),se>>>=7,de-=7}if(s.have+ce>s.nlen+s.ndist){t.msg='invalid bit length repeat',s.mode=te;break}for(;ce--;)s.lens[s.have++]=we}}if(s.mode===te)break;if(0===s.lens[256]){t.msg='invalid code -- missing end-of-block',s.mode=te;break}if(s.lenbits=9,Ee={bits:s.lenbits},xe=g(b,s.lens,0,s.nlen,s.lencode,0,s.work,Ee),s.lenbits=Ee.bits,xe){t.msg='invalid literal/lengths set',s.mode=te;break}if(s.distbits=6,s.distcode=s.distdyn,Ee={bits:s.distbits},xe=g(m,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,Ee),s.distbits=Ee.bits,xe){t.msg='invalid distances set',s.mode=te;break}if(s.mode=V,a===v)break inf_leave;case V:s.mode=X;case X:if(6<=ie&&258<=le){t.next_out=oe,t.avail_out=le,t.next_in=ne,t.avail_in=ie,s.hold=se,s.bits=de,_(t,pe),oe=t.next_out,re=t.output,le=t.avail_out,ne=t.next_in,d=t.input,ie=t.avail_in,se=s.hold,de=s.bits,s.mode===L&&(s.back=-1);break}for(s.back=0;;){if(r=s.lencode[se&(1<>>24,ge=255&r>>>16,be=65535&r,_e<=de)break;if(0===ie)break inf_leave;ie--,se+=d[ne++]<>me)],_e=r>>>24,ge=255&r>>>16,be=65535&r,me+_e<=de)break;if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=me,de-=me,s.back+=me}if(se>>>=_e,de-=_e,s.back+=_e,s.length=be,0===ge){s.mode=Q;break}if(32&ge){s.back=-1,s.mode=L;break}if(64&ge){t.msg='invalid literal/length code',s.mode=te;break}s.extra=15&ge,s.mode=Y;case Y:if(s.extra){for(ke=s.extra;de>>=s.extra,de-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=Z;case Z:for(;;){if(r=s.distcode[se&(1<>>24,ge=255&r>>>16,be=65535&r,_e<=de)break;if(0===ie)break inf_leave;ie--,se+=d[ne++]<>me)],_e=r>>>24,ge=255&r>>>16,be=65535&r,me+_e<=de)break;if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=me,de-=me,s.back+=me}if(se>>>=_e,de-=_e,s.back+=_e,64&ge){t.msg='invalid distance code',s.mode=te;break}s.offset=be,s.extra=15&ge,s.mode=K;case K:if(s.extra){for(ke=s.extra;de>>=s.extra,de-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){t.msg='invalid distance too far back',s.mode=te;break}s.mode=q;case q:if(0===le)break inf_leave;if(ce=pe-le,s.offset>ce){if(ce=s.offset-ce,ce>s.whave&&s.sane){t.msg='invalid distance too far back',s.mode=te;break}ce>s.wnext?(ce-=s.wnext,he=s.wsize-ce):he=s.wnext-ce,ce>s.length&&(ce=s.length),fe=s.window}else fe=re,he=oe-s.offset,ce=s.length;ce>le&&(ce=le),le-=ce,s.length-=ce;do re[oe++]=fe[he++];while(--ce);0===s.length&&(s.mode=X);break;case Q:if(0===le)break inf_leave;re[oe++]=s.length,le--,s.mode=X;break;case J:if(s.wrap){for(;32>de;){if(0===ie)break inf_leave;ie--,se|=d[ne++]<de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<_&&(f+=T[n++]<<_,_+=8,f+=T[n++]<<_,_+=8),v=g[f&m];dolen:for(;;){if(w=v>>>24,f>>>=w,_-=w,w=255&v>>>16,0===w)I[i++]=65535&v;else if(16&w){x=65535&v,w&=15,w&&(_>>=w,_-=w),15>_&&(f+=T[n++]<<_,_+=8,f+=T[n++]<<_,_+=8),v=b[f&y];dodist:for(;;){if(w=v>>>24,f>>>=w,_-=w,w=255&v>>>16,16&w){if(E=65535&v,w&=15,_d){e.msg='invalid distance too far back',r.mode=t;break top}if(f>>>=w,_-=w,w=i-l,E>w){if(w=E-w,w>p&&r.sane){e.msg='invalid distance too far back',r.mode=t;break top}if(k=0,C=h,0===c){if(k+=u-w,w>3,n-=x,_-=x<<3,f&=(1<<_)-1,e.next_in=n,e.next_out=i,e.avail_in=nE&&(k=E),0==E)return _[g++]=20971520,_[g++]=20971520,m.bits=1,0;for(x=1;xI)return-1;if(0o||e===d&&S>i)return 1;for(;;){j=v-T,b[w]W?(G=z[O+b[w]],H=B[D+b[w]]):(G=96,H=0),N=1<>T)+L]=0|(j<<24|G<<16|H);while(0!==L);for(N=1<>=1;if(0===N?R=0:(R&=N-1,R+=N),w++,0==--P[v]){if(v==E)break;v=t[a+b[w]]}if(v>k&&(R&M)!==F){for(0==T&&(T=k),U+=x,C=v-T,I=1<=I));)C++,I<<=1;if(S+=1<o||e===d&&S>i)return 1;F=R&M,_[F]=0|(k<<24|C<<16|U-g)}}return 0!==R&&(_[U+R]=0|(4194304|v-T<<24)),m.bits=k,0}},function(e){'use strict';e.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}},function(e,t){'use strict';var a=this&&this.__awaiter||function(e,t,a,r){return new(a||(a=Promise))(function(n,o){function i(e){try{s(r.next(e))}catch(t){o(t)}}function l(e){try{s(r['throw'](e))}catch(t){o(t)}}function s(e){e.done?n(e.value):new a(function(t){t(e.value)}).then(i,l)}s((r=r.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,a){function r(e){return function(t){return o([e,t])}}function o(r){if(i)throw new TypeError('Generator is already executing.');for(;n;)try{if(i=1,l&&(s=l[2&r[0]?'return':r[0]?'throw':'next'])&&!(s=s.call(l,r[1])).done)return s;switch((l=0,s)&&(r=[0,s.value]),r[0]){case 0:case 1:s=r;break;case 4:return n.label++,{value:r[1],done:!1};case 5:n.label++,l=r[1],r=[0];continue;case 7:r=n.ops.pop(),n.trys.pop();continue;default:if((s=n.trys,!(s=0s[0]&&r[1]s[0]&&r[1]i;i++)if(u=l[i][a.inputs[d]],u){var p=e.inputs[d];s.push({space:i,offset:t.resolve(u.offset),size:p.length,data:p.toActual()});break}for(var c=[],d=0;di;i++)if(u=l[i][a.outputs[d]],u){var p=e.outputs[d];c.push({space:i,offset:t.resolve(u.offset),size:p.length});break}r.postMessage({type:'run',inputs:s,outputs:c})}),[2,n]})})},t)}(p.DescriptorRunner);t.default=c},function(e,t,a){'use strict';var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])};return function(t,a){function r(){this.constructor=t}e(t,a),t.prototype=null===a?Object.create(a):(r.prototype=a.prototype,new r)}}(),n=this&&this.__awaiter||function(e,t,a,r){return new(a||(a=Promise))(function(n,o){function i(e){try{s(r.next(e))}catch(t){o(t)}}function l(e){try{s(r['throw'](e))}catch(t){o(t)}}function s(e){e.done?n(e.value):new a(function(t){t(e.value)}).then(i,l)}s((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,a){function r(e){return function(t){return o([e,t])}}function o(r){if(i)throw new TypeError('Generator is already executing.');for(;n;)try{if(i=1,l&&(s=l[2&r[0]?'return':r[0]?'throw':'next'])&&!(s=s.call(l,r[1])).done)return s;switch((l=0,s)&&(r=[0,s.value]),r[0]){case 0:case 1:s=r;break;case 4:return n.label++,{value:r[1],done:!1};case 5:n.label++,l=r[1],r=[0];continue;case 7:r=n.ops.pop(),n.trys.pop();continue;default:if((s=n.trys,!(s=0s[0]&&r[1]s[0]&&r[1]s[0]&&r[1]\nusing namespace metal;\n kernel void check_compatibility(\n device uint *A[[buffer(0)]],\n uint global_index[[thread_position_in_grid]],\n uint thread_execution_width[[thread_execution_width]]\n ){\n if (global_index == 0) {\n A[0] = thread_execution_width;\n }\n }','basic'),e=this.webgpuHandler.createBuffer(new Uint32Array(1)),[4,this.webgpuHandler.executeSinglePipelineState('basic.check_compatibility',{width:1,height:1,depth:1},{width:1,height:1,depth:1},[e],!0)];case 1:if(a.sent(),t=new Uint32Array(e.contents)[0],32!=t)throw new Error('Sorry, this GPU does not compatible with WebGPU (thread_execution_width == '+t+'. See checkIncompatibleGPU method of https://github.com/mil-tokyo/webdnn/blob/master/src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.ts');return[2];}})})},t.prototype.fetchDescriptor=function(e){return n(this,void 0,void 0,function(){var t;return o(this,function(a){switch(a.label){case 0:return[4,d.default(e+'/graph_'+this.backendName+'.json')];case 1:return t=a.sent(),[2,t.json()];}})})},t.prototype.fetchParameters=function(e,t){return n(this,void 0,void 0,function(){var a;return o(this,function(r){switch(r.label){case 0:return[4,d.default(e+'/weight_'+this.backendName+'.bin')];case 1:return a=r.sent(),[2,d.readArrayBufferProgressively(a,t)];}})})},t.prototype.restoreCachedDescriptor=function(e){return n(this,void 0,void 0,function(){return o(this,function(){return[2,i.getItem(e+'_'+this.backendName+'_descriptor').catch(function(){return null})]})})},t.prototype.restoreCachedParameters=function(e,t){return n(this,void 0,void 0,function(){var a;return o(this,function(r){switch(r.label){case 0:return[4,i.getItem(e+'_'+this.backendName+'_parameters').catch(function(){return null})];case 1:return a=r.sent(),a&&t&&t(a.byteLength,a.byteLength),[2,a];}})})},t.prototype.saveCache=function(e,t,a){return n(this,void 0,void 0,function(){return o(this,function(r){switch(r.label){case 0:return[4,Promise.all([i.setItem(e+'_'+this.backendName+'_descriptor',t),i.setItem(e+'_'+this.backendName+'_parameters',a)])];case 1:return r.sent(),[2];}})})},(t.prototype.setDescriptorAndParameters=function(e,t){return n(this,void 0,void 0,function(){return o(this,function(a){switch(a.label){case 0:return this.descriptor=e,this.staticBuffer=null,this.dynamicBuffer=null,this.metaBuffers=null,this.placeholderContext=new u.default(e.placeholders),this.executionInfos=e.exec_infos,this.webgpuHandler.loadKernel(this.descriptor.kernel_source,'descriptor'),[4,this.initializeStaticBuffer(t)];case 1:return a.sent(),[4,this.initializeMetaBuffers()];case 2:return a.sent(),[4,this.setPlaceholderValue({__MAX_THREADS_PER_THREADGROUP__:_?512:1024})];case 3:return a.sent(),this.placeholderContext&&this.placeholderContext.isResolved?[4,this.initializeDynamicBuffer()]:[3,5];case 4:a.sent(),a.label=5;case 5:return[2];}})})},t.prototype.initializeStaticBuffer=function(e){return n(this,void 0,void 0,function(){var t,a,r,n,i;return o(this,function(o){switch(o.label){case 0:if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');return t=this.descriptor,a=new l.default(t.memory_layout.static.size*Float32Array.BYTES_PER_ELEMENT),this.staticBuffer=a,r=s.default(t.weight_encoding),i=(n=a).write,[4,r.decode(new Uint8Array(e))];case 1:return[4,i.apply(n,[o.sent()])];case 2:return o.sent(),[4,this.getInputViews()];case 3:return o.sent().filter(function(e){return!e.isDynamic}).forEach(function(e){e.buffer=a.bufferView.buffer}),[4,this.getOutputViews()];case 4:return o.sent().filter(function(e){return!e.isDynamic}).forEach(function(e){e.buffer=a.bufferView.buffer}),[2];}})})},t.prototype.initializeMetaBuffers=function(){return n(this,void 0,void 0,function(){var e=this,t;return o(this,function(a){switch(a.label){case 0:if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');return t=this,[4,Promise.all(this.descriptor.exec_infos.map(function(t){return n(e,void 0,void 0,function(){var e;return o(this,function(a){switch(a.label){case 0:return e=new l.default(t.meta_buffer.length*Int32Array.BYTES_PER_ELEMENT),[4,e.write(new Uint8Array(t.meta_buffer))];case 1:return a.sent(),[2,e];}})})}))];case 1:return t.metaBuffers=a.sent(),[2];}})})},t.prototype.initializeDynamicBuffer=function(){return n(this,void 0,void 0,function(){var e,t,a,r;return o(this,function(n){switch(n.label){case 0:if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');if(!this.placeholderContext)throw Error('PlaceholderContext is not initialized.');return e=this.descriptor,t=this.placeholderContext,a=t.resolve(e.memory_layout.dynamic.size),r=new l.default(a*Float32Array.BYTES_PER_ELEMENT),this.dynamicBuffer=r,[4,this.getInputViews()];case 1:return n.sent().filter(function(e){return e.isDynamic}).forEach(function(e){e.buffer=r.bufferView.buffer}),[4,this.getOutputViews()];case 2:return n.sent().filter(function(e){return e.isDynamic}).forEach(function(e){e.buffer=r.bufferView.buffer}),[2];}})})},t.prototype.setPlaceholderValue=function(e){return n(this,void 0,void 0,function(){var t=this,a,r,l,i;return o(this,function(s){switch(s.label){case 0:if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized.');if(a=this.placeholderContext,a.update(e),!a.isResolved)return[2];if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.metaBuffers)throw new Error('MetaBuffers are not initialized');return r=this.descriptor,l=this.metaBuffers,[4,this.initializeDynamicBuffer()];case 1:return s.sent(),i=this,[4,Promise.all(r.exec_infos.map(function(e,r){return n(t,void 0,void 0,function(){var t,n,i,s;return o(this,function(){for(t=new Int32Array(l[r].bufferView.buffer),n=0,i=e.unresolved_value_list;ns[0]&&r[1]=l-1)){for(;;){for(;e[d]>s&&d<=u;)d++;for(;e[u]<=s&&d<=u;)u--;if(d>=u)break;p=e[d],e[d]=e[u],e[u]=p,p=r[d],r[d]=r[u],r[u]=p}e[l-1]=e[d],e[d]=s,p=r[l-1],r[l-1]=r[d],r[d]=p,a.push([i,d]),d+1=l-1)){for(;;){for(;e[d]=s&&d<=u;)u--;if(d>=u)break;p=e[d],e[d]=e[u],e[u]=p,p=r[d],r[d]=r[u],r[u]=p}e[l-1]=e[d],e[d]=s,p=r[l-1],r[l-1]=r[d],r[d]=p,a.push([i,d]),d+1=a.oldVersion&&e.createObjectStore(A)}catch(e){if('ConstraintError'===e.name)console.warn('The database "'+t.name+'" has been upgraded from version '+a.oldVersion+' to version '+a.newVersion+', but the storage "'+t.storeName+'" already exists.');else throw e}}),o.onerror=function(t){t.preventDefault(),r(o.error)},o.onsuccess=function(){a(o.result),p(t)}})}function f(e){return h(e,!1)}function _(e){return h(e,!0)}function g(e,t){if(!e.db)return!0;var a=!e.db.objectStoreNames.contains(e.storeName),r=e.versione.db.version;if(r&&(e.version!==t&&console.warn('The database "'+e.name+'" can\'t be downgraded from version '+e.db.version+' to version '+e.version+'.'),e.version=e.db.version),n||a){if(a){var o=e.db.version+1;o>e.version&&(e.version=o)}return!0}return!1}function b(t){return new P(function(a,e){var r=new FileReader;r.onerror=e,r.onloadend=function(r){var e=btoa(r.target.result||'');a({__local_forage_encoded_blob:!0,data:e,type:t.type})},r.readAsBinaryString(t)})}function m(e){var t=l(atob(e.data));return r([t],{type:e.type})}function y(e){return e&&e.__local_forage_encoded_blob}function v(e){var t=this,a=t._initReady().then(function(){var e=fe[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady});return n(a,e,e),a}function w(e){u(e);for(var t=fe[e.name],a=t.forages,r=0;r>4,u[r++]=(15&i)<<4|l>>2,u[r++]=(3&l)<<6|63&s;return d}function k(e){var t=new Uint8Array(e),a='',r;for(r=0;r>2],a+=M[(3&t[r])<<4|t[r+1]>>4],a+=M[(15&t[r+1])<<2|t[r+2]>>6],a+=M[63&t[r+2]];return 2==t.length%3?a=a.substring(0,a.length-1)+'=':1==t.length%3&&(a=a.substring(0,a.length-2)+'=='),a}function C(e,t,a,r){var n=this;e=i(e);var l=new P(function(o,i){n.ready().then(function(){void 0===t&&(t=null);var l=t,s=n._dbInfo;s.serializer.serialize(t,function(d,t){t?i(t):s.db.transaction(function(a){a.executeSql('INSERT OR REPLACE INTO '+s.storeName+' (key, value) VALUES (?, ?)',[e,d],function(){o(l)},function(e,t){i(t)})},function(t){if(t.code===t.QUOTA_ERR){if(0e?void t(null):void a.ready().then(function(){x(a._dbInfo,O,function(n,o){if(n)return r(n);try{var i=o.objectStore(a._dbInfo.storeName),l=!1,s=i.openCursor();s.onsuccess=function(){var a=s.result;return a?void(0===e?t(a.key):l?t(a.key):(l=!0,a.advance(e))):void t(null)},s.onerror=function(){r(s.error)}}catch(t){r(t)}})})['catch'](r)});return o(r,t),r},keys:function(e){var t=this,a=new P(function(e,a){t.ready().then(function(){x(t._dbInfo,O,function(r,n){if(r)return a(r);try{var o=n.objectStore(t._dbInfo.storeName),i=o.openCursor(),l=[];i.onsuccess=function(){var t=i.result;return t?void(l.push(t.key),t['continue']()):void e(l)},i.onerror=function(){a(i.error)}}catch(t){a(t)}})})['catch'](a)});return o(a,e),a}},M='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',F=/^~~local_forage_type~([^~]+)~/,U='__lfsc__:',W=U.length,j='arbf',H='blob',G='si08',V='ui08',X='uic8',Y='si16',Z='si32',K='ur16',q='ui32',Q='fl32',J='fl64',$=W+j.length,ee=Object.prototype.toString,te={serialize:function(t,a){var e='';if(t&&(e=ee.call(t)),t&&('[object ArrayBuffer]'===e||t.buffer&&'[object ArrayBuffer]'===ee.call(t.buffer))){var r=U,n;t instanceof ArrayBuffer?(n=t,r+=j):(n=t.buffer,'[object Int8Array]'===e?r+=G:'[object Uint8Array]'===e?r+=V:'[object Uint8ClampedArray]'===e?r+=X:'[object Int16Array]'===e?r+=Y:'[object Uint16Array]'===e?r+=K:'[object Int32Array]'===e?r+=Z:'[object Uint32Array]'===e?r+=q:'[object Float32Array]'===e?r+=Q:'[object Float64Array]'===e?r+=J:a(new Error('Failed to get type for BinaryArray'))),a(r+k(n))}else if('[object Blob]'===e){var o=new FileReader;o.onload=function(){var e='~~local_forage_type~'+t.type+'~'+k(this.result);a(U+H+e)},o.readAsArrayBuffer(t)}else try{a(JSON.stringify(t))}catch(r){console.error('Couldn\'t convert value into a JSON string: ',t),a(null,r)}},deserialize:function(e){if(e.substring(0,W)!==U)return JSON.parse(e);var t=e.substring($),a=e.substring(W,$),n;if(a===H&&F.test(t)){var o=t.match(F);n=o[1],t=t.substring(o[0].length)}var i=E(t);switch(a){case j:return i;case H:return r([i],{type:n});case G:return new Int8Array(i);case V:return new Uint8Array(i);case X:return new Uint8ClampedArray(i);case Y:return new Int16Array(i);case K:return new Uint16Array(i);case Z:return new Int32Array(i);case q:return new Uint32Array(i);case Q:return new Float32Array(i);case J:return new Float64Array(i);default:throw new Error('Unkown type: '+a);}},stringToBuffer:E,bufferToString:k},ae={_driver:'webSQLStorage',_initStorage:function(e){var t=this,a={db:null};if(e)for(var r in e)a[r]='string'==typeof e[r]?e[r]:e[r].toString();var n=new P(function(e,r){try{a.db=openDatabase(a.name,a.version+'',a.description,a.size)}catch(t){return r(t)}a.db.transaction(function(n){n.executeSql('CREATE TABLE IF NOT EXISTS '+a.storeName+' (id INTEGER PRIMARY KEY, key unique, value)',[],function(){t._dbInfo=a,e()},function(e,t){r(t)})})});return a.serializer=te,n},_support:function(){return'function'==typeof openDatabase}(),iterate:function(e,t){var a=this,r=new P(function(r,n){a.ready().then(function(){var o=a._dbInfo;o.db.transaction(function(a){a.executeSql('SELECT * FROM '+o.storeName,[],function(a,t){for(var n=t.rows,l=n.length,s=0;s>>16,l=0;0!==a;){l=2e3t;t++){a=t;for(var r=0;8>r;r++)a=1&a?3988292384^a>>>1:a>>>1;e[t]=a}return e}();e.exports=function(e,a,r,n){e^=-1;for(var o=n;o>>8^t[255&(e^a[o])];return-1^e}},function(t,a,r){'use strict';function n(t,a){if(65537>a&&(t.subarray&&s||!t.subarray&&l))return e.apply(null,o.shrinkBuf(t,a));for(var r='',n=0;ni;i++)d[i]=252<=i?6:248<=i?5:240<=i?4:224<=i?3:192<=i?2:1;d[254]=d[254]=1,a.string2buf=function(e){var t=e.length,a=0,r,n,l,s,d;for(s=0;sn?1:2048>n?2:65536>n?3:4;for(r=new o.Buf8(a),d=0,s=0;dn?r[d++]=n:2048>n?(r[d++]=192|n>>>6,r[d++]=128|63&n):65536>n?(r[d++]=224|n>>>12,r[d++]=128|63&n>>>6,r[d++]=128|63&n):(r[d++]=240|n>>>18,r[d++]=128|63&n>>>12,r[d++]=128|63&n>>>6,r[d++]=128|63&n);return r},a.buf2binstring=function(e){return n(e,e.length)},a.binstring2buf=function(e){for(var t=new o.Buf8(e.length),a=0,r=t.length;al){r[i++]=l;continue}if(s=d[l],4l?r[i++]=l:(l-=65536,r[i++]=55296|1023&l>>10,r[i++]=56320|1023&l)}return n(r,i)},a.utf8border=function(e,t){var a;for(t=t||e.length,t>e.length&&(t=e.length),a=t-1;0<=a&&128==(192&e[a]);)a--;return 0>a?t:0===a?t:a+d[e[a]]>t?a:t}},function(e){'use strict';e.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}},function(e){'use strict';e.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}},function(e,t,a){'use strict';function r(e){return'WebGL2RenderingContext'===e.constructor.name}function n(e){if(null===e)throw Error('Null is detected');return e}var o=this&&this.__awaiter||function(e,t,a,r){return new(a||(a=Promise))(function(n,o){function i(e){try{s(r.next(e))}catch(t){o(t)}}function l(e){try{s(r['throw'](e))}catch(t){o(t)}}function s(e){e.done?n(e.value):new a(function(t){t(e.value)}).then(i,l)}s((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,a){function r(e){return function(t){return o([e,t])}}function o(r){if(i)throw new TypeError('Generator is already executing.');for(;n;)try{if(i=1,l&&(s=l[2&r[0]?'return':r[0]?'throw':'next'])&&!(s=s.call(l,r[1])).done)return s;switch((l=0,s)&&(r=[0,s.value]),r[0]){case 0:case 1:s=r;break;case 4:return n.label++,{value:r[1],done:!1};case 5:n.label++,l=r[1],r=[0];continue;case 7:r=n.ops.pop(),n.trys.pop();continue;default:if((s=n.trys,!(s=0s[0]&&r[1]l.getConfiguration('MAX_TEXTURE_SIZE',t.getParameter(t.MAX_TEXTURE_SIZE)))}return u},e.prototype.waitForComplete=function(){return o(this,void 0,void 0,function(){var e,t,a;return i(this,function(n){switch(n.label){case 0:if(e=this.gl,!r(e))return[3,4];t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0),a=e.clientWaitSync(t,0,0),n.label=1;case 1:return a===e.CONDITION_SATISFIED||a===e.ALREADY_SIGNALED?[3,3]:[4,new Promise(function(e){return setTimeout(e,1)})];case 2:return n.sent(),a=e.clientWaitSync(t,0,0),[3,1];case 3:return e.deleteSync(t),[3,5];case 4:e.finish(),n.label=5;case 5:return[2];}})})},Object.defineProperty(e.prototype,'MAX_TEXTURE_SIZE',{get:function(){var e=l.getConfiguration('MAX_TEXTURE_SIZE',this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE));if(16384<=e)return 4096;if(8192<=e)return 4096;if(4096<=e)return 4096;throw new Error('MAX_TEXTURE_SIZE is too small: '+e)},enumerable:!0,configurable:!0}),e.IS_SAFARI=-1!==navigator.userAgent.toLowerCase().indexOf('safari')&&-1===navigator.userAgent.toLowerCase().indexOf('chrome'),e}(),d;t.default=s;var u=null},function(e,t){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var a=function(){return function(e,t){this.byteLength=e,this.backend=t}}();t.Buffer=a},function(e,t,a){'use strict';var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])};return function(t,a){function r(){this.constructor=t}e(t,a),t.prototype=null===a?Object.create(a):(r.prototype=a.prototype,new r)}}(),n=this&&this.__awaiter||function(e,t,a,r){return new(a||(a=Promise))(function(n,o){function i(e){try{s(r.next(e))}catch(t){o(t)}}function l(e){try{s(r['throw'](e))}catch(t){o(t)}}function s(e){e.done?n(e.value):new a(function(t){t(e.value)}).then(i,l)}s((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,a){function r(e){return function(t){return o([e,t])}}function o(r){if(i)throw new TypeError('Generator is already executing.');for(;n;)try{if(i=1,l&&(s=l[2&r[0]?'return':r[0]?'throw':'next'])&&!(s=s.call(l,r[1])).done)return s;switch((l=0,s)&&(r=[0,s.value]),r[0]){case 0:case 1:s=r;break;case 4:return n.label++,{value:r[1],done:!1};case 5:n.label++,l=r[1],r=[0];continue;case 7:r=n.ops.pop(),n.trys.pop();continue;default:if((s=n.trys,!(s=0s[0]&&r[1]s[0]&&r[1]s[0]&&r[1]s[0]&&r[1]s[0]&&r[1]f;f++)h[f]=e.decode_table[127&f]*c*(128>f?1:-1);for(i=new Uint8Array(t.buffer,t.byteOffset+d,p),_=o.inflate(i),g=_.length,b=new Float32Array(g),m=0;mt.windowBits&&(t.windowBits+=16),this.err=0,this.msg='',this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var a=o.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(a!==c)throw new Error(s[a]);if(t.header&&o.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n='string'==typeof t.dictionary?l.string2buf(t.dictionary):'[object ArrayBuffer]'===u.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,a=o.deflateSetDictionary(this.strm,n),a!==c)throw new Error(s[a]);this._dict_set=!0}}function n(e,t){var a=new r(t);if(a.push(e,!0),a.err)throw a.msg||s[a.err];return a.result}var o=a(26),i=a(0),l=a(11),s=a(8),d=a(12),u=Object.prototype.toString,p=4,c=0,h=1,f=2,_=-1,g=0,b=8;r.prototype.push=function(e,t){var a=this.strm,r=this.options.chunkSize,n,s;if(this.ended)return!1;s=t===~~t?t:!0===t?p:0,a.input='string'==typeof e?l.string2buf(e):'[object ArrayBuffer]'===u.call(e)?new Uint8Array(e):e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new i.Buf8(r),a.next_out=0,a.avail_out=r),n=o.deflate(a,s),n!==h&&n!==c)return this.onEnd(n),this.ended=!0,!1;(0===a.avail_out||0===a.avail_in&&(s===p||s===f))&&('string'===this.options.to?this.onData(l.buf2binstring(i.shrinkBuf(a.output,a.next_out))):this.onData(i.shrinkBuf(a.output,a.next_out)))}while((0e.avail_out&&(a=e.avail_out);0===a||(E.arraySet(e.output,t.pending_buf,t.pending_out,a,e.next_out),e.next_out+=a,t.pending_out+=a,e.total_out+=a,e.avail_out-=a,t.pending-=a,0===t.pending&&(t.pending_out=0))}function l(e,t){k._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,i(e.strm)}function d(e,t){e.pending_buf[e.pending++]=t}function u(e,t){e.pending_buf[e.pending++]=255&t>>>8,e.pending_buf[e.pending++]=255&t}function c(e,t,a,r){var n=e.avail_in;return(n>r&&(n=r),0===n)?0:(e.avail_in-=n,E.arraySet(t,e.input,e.next_in,n,a),1===e.state.wrap?e.adler=C(e.adler,t,n,a):2===e.state.wrap&&(e.adler=T(e.adler,t,n,a)),e.next_in+=n,e.total_in+=n,n)}function p(e,t){var a=e.max_chain_length,r=e.strstart,n=e.prev_length,o=e.nice_match,i=e.strstart>e.w_size-K?e.strstart-(e.w_size-K):0,l=e.window,s=e.w_mask,d=e.prev,u=e.strstart+Z,p=l[r+n-1],c=l[r+n],h,f;e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(h=t,l[h+n]!==c||l[h+n-1]!==p||l[h]!==l[r]||l[++h]!==l[r+1])continue;r+=2,h++;do;while(l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&l[++r]===l[++h]&&rn){if(e.match_start=t,n=f,f>=o)break;p=l[r+n-1],c=l[r+n]}}while((t=d[t&s])>i&&0!=--a);return n<=e.lookahead?n:e.lookahead}function h(e){var t=e.w_size,a,r,n,o,i;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-K)){E.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,a=r;do n=e.head[--a],e.head[a]=n>=t?n-t:0;while(--r);r=t,a=r;do n=e.prev[--a],e.prev[a]=n>=t?n-t:0;while(--r);o+=t}if(0===e.strm.avail_in)break;if(r=c(e.strm,e.window,e.strstart+e.lookahead,o),e.lookahead+=r,e.lookahead+e.insert>=Y)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=(e.ins_h<=Y&&(e.ins_h=(e.ins_h<=Y))r=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;else if(r=k._tr_tally(e,e.strstart-e.match_start,e.match_length-Y),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Y){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=Y&&(e.ins_h=(e.ins_h<=e.match_length&&(e.strategy===N||e.match_length===Y&&4096=Y&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-Y,r=k._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Y),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=n&&(e.ins_h=(e.ins_h<=Y&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Y?(r=k._tr_tally(e,1,e.match_length-Y),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(l(e,!1),0===e.strm.avail_out))return re}return e.insert=0,t===R?(l(e,!0),0===e.strm.avail_out?oe:ie):e.last_lit&&(l(e,!1),0===e.strm.avail_out)?re:ne}function g(e,t){for(var a;;){if(0===e.lookahead&&(h(e),0===e.lookahead)){if(t===S)return re;break}if(e.match_length=0,a=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,a&&(l(e,!1),0===e.strm.avail_out))return re}return e.insert=0,t===R?(l(e,!0),0===e.strm.avail_out?oe:ie):e.last_lit&&(l(e,!1),0===e.strm.avail_out)?re:ne}function b(e,t,a,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=a,this.max_chain=r,this.func=n}function m(e){e.window_size=2*e.w_size,o(e.head),e.max_lazy_match=le[e.level].max_lazy,e.good_match=le[e.level].good_length,e.nice_match=le[e.level].nice_length,e.max_chain_length=le[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Y-1,e.match_available=0,e.ins_h=0}function y(){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=U,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 E.Buf16(2*V),this.dyn_dtree=new E.Buf16(2*(2*H+1)),this.bl_tree=new E.Buf16(2*(2*G+1)),o(this.dyn_ltree),o(this.dyn_dtree),o(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new E.Buf16(X+1),this.heap=new E.Buf16(2*j+1),o(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new E.Buf16(2*j+1),o(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 v(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=F,t=e.state,t.pending=0,t.pending_out=0,0>t.wrap&&(t.wrap=-t.wrap),t.status=t.wrap?q:te,e.adler=2===t.wrap?0:1,t.last_flush=S,k._tr_init(t),D):r(e,A)}function w(e){var t=v(e);return t===D&&m(e.state),t}function x(e,t,a,n,o,i){if(!e)return A;var l=1;if(t===O&&(t=6),0>n?(l=0,n=-n):15o||o>W||a!==U||8>n||15t||9i||i>M)return r(e,A);8===n&&(n=9);var d=new y;return e.state=d,d.strm=e,d.wrap=l,d.gzhead=null,d.w_bits=n,d.w_size=1<e.pending_buf_size-5&&(a=e.pending_buf_size-5);;){if(1>=e.lookahead){if(h(e),0===e.lookahead&&t===S)return re;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+a;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,l(e,!1),0===e.strm.avail_out))return re;if(e.strstart-e.block_start>=e.w_size-K&&(l(e,!1),0===e.strm.avail_out))return re}return e.insert=0,t===R?(l(e,!0),0===e.strm.avail_out?oe:ie):e.strstart>e.block_start&&(l(e,!1),0===e.strm.avail_out)?re:re}),new b(4,4,8,4,s),new b(4,5,16,8,s),new b(4,6,32,32,s),new b(4,4,16,16,f),new b(8,16,32,32,f),new b(8,16,128,128,f),new b(8,32,128,256,f),new b(32,128,258,1024,f),new b(32,258,258,4096,f)],t.deflateInit=function(e,t){return x(e,t,U,15,8,0)},t.deflateInit2=x,t.deflateReset=w,t.deflateResetKeep=v,t.deflateSetHeader=function(e,t){return e&&e.state?2===e.state.wrap?(e.state.gzhead=t,D):A:A},t.deflate=function(e,t){var a,l,s,p;if(!e||!e.state||t>B||0>t)return e?r(e,A):A;if(l=e.state,!e.output||!e.input&&0!==e.avail_in||l.status===ae&&t!==R)return r(e,0===e.avail_out?z:A);if(l.strm=e,a=l.last_flush,l.last_flush=t,l.status===q)if(2===l.wrap)e.adler=0,d(l,31),d(l,139),d(l,8),l.gzhead?(d(l,(l.gzhead.text?1:0)+(l.gzhead.hcrc?2:0)+(l.gzhead.extra?4:0)+(l.gzhead.name?8:0)+(l.gzhead.comment?16:0)),d(l,255&l.gzhead.time),d(l,255&l.gzhead.time>>8),d(l,255&l.gzhead.time>>16),d(l,255&l.gzhead.time>>24),d(l,9===l.level?2:l.strategy>=L||2>l.level?4:0),d(l,255&l.gzhead.os),l.gzhead.extra&&l.gzhead.extra.length&&(d(l,255&l.gzhead.extra.length),d(l,255&l.gzhead.extra.length>>8)),l.gzhead.hcrc&&(e.adler=T(e.adler,l.pending_buf,l.pending,0)),l.gzindex=0,l.status=Q):(d(l,0),d(l,0),d(l,0),d(l,0),d(l,0),d(l,9===l.level?2:l.strategy>=L||2>l.level?4:0),d(l,3),l.status=te);else{var c=U+(l.w_bits-8<<4)<<8,h=-1;h=l.strategy>=L||2>l.level?0:6>l.level?1:6===l.level?2:3,c|=h<<6,0!==l.strstart&&(c|=32),c+=31-c%31,l.status=te,u(l,c),0!==l.strstart&&(u(l,e.adler>>>16),u(l,65535&e.adler)),e.adler=1}if(l.status===Q)if(l.gzhead.extra){for(s=l.pending;l.gzindex<(65535&l.gzhead.extra.length)&&!(l.pending===l.pending_buf_size&&(l.gzhead.hcrc&&l.pending>s&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),i(e),s=l.pending,l.pending===l.pending_buf_size));)d(l,255&l.gzhead.extra[l.gzindex]),l.gzindex++;l.gzhead.hcrc&&l.pending>s&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),l.gzindex===l.gzhead.extra.length&&(l.gzindex=0,l.status=J)}else l.status=J;if(l.status===J)if(l.gzhead.name){s=l.pending;do{if(l.pending===l.pending_buf_size&&(l.gzhead.hcrc&&l.pending>s&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),i(e),s=l.pending,l.pending===l.pending_buf_size)){p=1;break}p=l.gzindexs&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),0===p&&(l.gzindex=0,l.status=$)}else l.status=$;if(l.status===$)if(l.gzhead.comment){s=l.pending;do{if(l.pending===l.pending_buf_size&&(l.gzhead.hcrc&&l.pending>s&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),i(e),s=l.pending,l.pending===l.pending_buf_size)){p=1;break}p=l.gzindexs&&(e.adler=T(e.adler,l.pending_buf,l.pending-s,s)),0===p&&(l.status=ee)}else l.status=ee;if(l.status===ee&&(l.gzhead.hcrc?(l.pending+2>l.pending_buf_size&&i(e),l.pending+2<=l.pending_buf_size&&(d(l,255&e.adler),d(l,255&e.adler>>8),e.adler=0,l.status=te)):l.status=te),0!==l.pending){if(i(e),0===e.avail_out)return l.last_flush=-1,D;}else if(0===e.avail_in&&n(t)<=n(a)&&t!==R)return r(e,z);if(l.status===ae&&0!==e.avail_in)return r(e,z);if(0!==e.avail_in||0!==l.lookahead||t!==S&&l.status!==ae){var f=l.strategy===L?g(l,t):l.strategy===3?_(l,t):le[l.level].func(l,t);if((f===oe||f===ie)&&(l.status=ae),f===re||f===oe)return 0===e.avail_out&&(l.last_flush=-1),D;if(f===ne&&(t===1?k._tr_align(l):t!==B&&(k._tr_stored_block(l,0,0,!1),t===3&&(o(l.head),0===l.lookahead&&(l.strstart=0,l.block_start=0,l.insert=0))),i(e),0===e.avail_out))return l.last_flush=-1,D}return t===R?0>=l.wrap?P:(2===l.wrap?(d(l,255&e.adler),d(l,255&e.adler>>8),d(l,255&e.adler>>16),d(l,255&e.adler>>24),d(l,255&e.total_in),d(l,255&e.total_in>>8),d(l,255&e.total_in>>16),d(l,255&e.total_in>>24)):(u(l,e.adler>>>16),u(l,65535&e.adler)),i(e),0=r.w_size&&(0===n&&(o(r.head),r.strstart=0,r.block_start=0,r.insert=0),p=new E.Buf8(r.w_size),E.arraySet(p,t,a-r.w_size,r.w_size,0),t=p,a=r.w_size),s=e.avail_in,d=e.next_in,u=e.input,e.avail_in=a,e.next_in=0,e.input=t,h(r);r.lookahead>=Y;){i=r.strstart,l=r.lookahead-(Y-1);do r.ins_h=(r.ins_h<e?J[e]:J[256+(e>>>7)]}function l(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=255&t>>>8}function d(e,t,a){e.bi_valid>U-a?(e.bi_buf|=65535&t<>U-e.bi_valid,e.bi_valid+=a-U):(e.bi_buf|=65535&t<>>=1,a<<=1;while(0<--t);return a>>>1}function p(e){16===e.bi_valid?(l(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}function c(e,t){var a=t.dyn_tree,r=t.max_code,o=t.stat_desc.static_tree,i=t.stat_desc.has_stree,l=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,d=t.stat_desc.max_length,u=0,p,c,n,h,_,g;for(h=0;h<=F;h++)e.bl_count[h]=0;for(a[2*e.heap[e.heap_max]+1]=0,p=e.heap_max+1;pd&&(h=d,u++),a[2*c+1]=h,!(c>r))&&(e.bl_count[h]++,_=0,c>=s&&(_=l[c-s]),g=a[2*c],e.opt_len+=g*(h+_),i&&(e.static_len+=g*(o[2*c+1]+_)));if(0!=u){do{for(h=d-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[d]--,u-=2}while(0r))&&(a[2*n+1]!==h&&(e.opt_len+=(h-a[2*n+1])*a[2*n],a[2*n+1]=h),c--)}}function h(e,t,a){var r=Array(F+1),o=0,i,l;for(i=1;i<=F;i++)r[i]=o=o+a[i-1]<<1;for(l=0;l<=t;l++){var n=e[2*l+1];0!==n&&(e[2*l]=s(r[n]++,n))}}function f(){var e=Array(F+1),t,a,r,n,i;for(r=0,n=0;nn;n++)for(te[n]=i,t=0;t<1<>=7;n=t;)q[2*t+1]=8,t++,e[8]++;for(;255>=t;)q[2*t+1]=9,t++,e[9]++;for(;279>=t;)q[2*t+1]=7,t++,e[7]++;for(;287>=t;)q[2*t+1]=8,t++,e[8]++;for(h(q,O+1,e),t=0;te.heap_len;)d=e.heap[++e.heap_len]=2>l?++l:0,a[2*d]=1,e.depth[d]=0,e.opt_len--,o&&(e.static_len-=r[2*d+1]);for(t.max_code=l,s=e.heap_len>>1;1<=s;s--)y(e,a,s);d=i;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],y(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=n,a[2*d]=a[2*s]+a[2*n],e.depth[d]=(e.depth[s]>=e.depth[n]?e.depth[s]:e.depth[n])+1,a[2*s+1]=a[2*n+1]=d,e.heap[1]=d++,y(e,a,1);while(2<=e.heap_len);e.heap[--e.heap_max]=e.heap[1],c(e,t),h(a,l,e.bl_count)}function x(e,t,a){var r=-1,o=t[1],i=0,l=7,s=4,d,n;for(0===o&&(l=138,s=3),t[2*(a+1)+1]=65535,d=0;d<=a;d++){if(n=o,o=t[2*(d+1)+1],++i=i?e.bl_tree[2*G]++:e.bl_tree[2*V]++:(n!==r&&e.bl_tree[2*n]++,e.bl_tree[2*H]++);i=0,r=n,0===o?(l=138,s=3):n===o?(l=6,s=3):(l=7,s=4)}}function E(e,t,a){var r=-1,o=t[1],i=0,l=7,s=4,p,n;for(0===o&&(l=138,s=3),p=0;p<=a;p++){if(n=o,o=t[2*(p+1)+1],++i=i?(u(e,G,e.bl_tree),d(e,i-3,3)):(u(e,V,e.bl_tree),d(e,i-11,7)):(n!==r&&(u(e,n,e.bl_tree),i--),u(e,H,e.bl_tree),d(e,i-3,2));i=0,r=n,0===o?(l=138,s=3):n===o?(l=6,s=3):(l=7,s=4)}}function k(e){var t;for(x(e,e.dyn_ltree,e.l_desc.max_code),x(e,e.dyn_dtree,e.d_desc.max_code),w(e,e.bl_desc),t=L-1;3<=t&&0===e.bl_tree[2*K[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}function C(e,t,a,r){var n;for(d(e,t-257,5),d(e,a-1,5),d(e,r-4,4),n=0;n=a;a++,t>>>=1)if(1&t&&0!==e.dyn_ltree[2*a])return R;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return B;for(a=32;a>>3,i=e.static_len+3+7>>>3,i<=o&&(o=i)):o=i=a+5,a+4<=o&&-1!==t?I(e,t,a,r):e.strategy===4||i===o?(d(e,(P<<1)+(r?1:0),3),v(e,q,Q)):(d(e,(2<<1)+(r?1:0),3),C(e,e.l_desc.max_code+1,e.d_desc.max_code+1,n+1),v(e,e.dyn_ltree,e.dyn_dtree)),_(e),r&&g(e)},t._tr_tally=function(e,t,a){return e.pending_buf[e.d_buf+2*e.last_lit]=255&t>>>8,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&a,e.last_lit++,0===t?e.dyn_ltree[2*a]++:(e.matches++,t--,e.dyn_ltree[2*($[a]+z+1)]++,e.dyn_dtree[2*i(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){d(e,P<<1,3),u(e,j,q),p(e)}},function(e,t,a){'use strict';function r(e){if(!(this instanceof r))return new r(e);this.options=i.assign({chunkSize:16384,windowBits:0,to:''},e||{});var t=this.options;t.raw&&0<=t.windowBits&&16>t.windowBits&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),0<=t.windowBits&&16>t.windowBits&&!(e&&e.windowBits)&&(t.windowBits+=32),15t.windowBits&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg='',this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var a=o.inflateInit2(this.strm,t.windowBits);if(a!==s.Z_OK)throw new Error(d[a]);this.header=new p,o.inflateGetHeader(this.strm,this.header)}function n(e,t){var a=new r(t);if(a.push(e,!0),a.err)throw a.msg||d[a.err];return a.result}var o=a(29),i=a(0),l=a(11),s=a(13),d=a(8),u=a(12),p=a(32),c=Object.prototype.toString;r.prototype.push=function(e,t){var a=this.strm,r=this.options.chunkSize,n=this.options.dictionary,d=!1,u,p,h,f,_,g;if(this.ended)return!1;p=t===~~t?t:!0===t?s.Z_FINISH:s.Z_NO_FLUSH,a.input='string'==typeof e?l.binstring2buf(e):'[object ArrayBuffer]'===c.call(e)?new Uint8Array(e):e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new i.Buf8(r),a.next_out=0,a.avail_out=r),u=o.inflate(a,s.Z_NO_FLUSH),u===s.Z_NEED_DICT&&n&&(g='string'==typeof n?l.string2buf(n):'[object ArrayBuffer]'===c.call(n)?new Uint8Array(n):n,u=o.inflateSetDictionary(this.strm,g)),u===s.Z_BUF_ERROR&&!0==d&&(u=s.Z_OK,d=!1),u!==s.Z_STREAM_END&&u!==s.Z_OK)return this.onEnd(u),this.ended=!0,!1;a.next_out&&(0===a.avail_out||u===s.Z_STREAM_END||0===a.avail_in&&(p===s.Z_FINISH||p===s.Z_SYNC_FLUSH))&&('string'===this.options.to?(h=l.utf8border(a.output,a.next_out),f=a.next_out-h,_=l.buf2string(a.output,h),a.next_out=f,a.avail_out=r-f,f&&i.arraySet(a.output,a.output,h,f,0),this.onData(_)):this.onData(i.shrinkBuf(a.output,a.next_out))),0===a.avail_in&&0===a.avail_out&&(d=!0)}while((0>>24)+(65280&e>>>8)+((65280&e)<<8)+((255&e)<<24)}function n(){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 c.Buf16(320),this.work=new c.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function i(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg='',t.wrap&&(e.adler=1&t.wrap),t.mode=T,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new c.Buf32(re),t.distcode=t.distdyn=new c.Buf32(ne),t.sane=1,t.back=-1,w):x}function l(e){var t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,i(e)):x}function s(e,t){var a,r;return e&&e.state?(r=e.state,0>t?(a=0,t=-t):(a=(t>>4)+1,48>t&&(t&=15)),t&&(8>t||15t;)e.lens[t++]=8;for(;256>t;)e.lens[t++]=9;for(;280>t;)e.lens[t++]=7;for(;288>t;)e.lens[t++]=8;for(g(b,e.lens,0,288,ie,0,e.work,{bits:9}),t=0;32>t;)e.lens[t++]=5;g(m,e.lens,0,32,le,0,e.work,{bits:5}),oe=!1}e.lencode=ie,e.lenbits=9,e.distcode=le,e.distbits=5}function p(e,t,a,r){var n=e.state,o;return null===n.window&&(n.wsize=1<=n.wsize?(c.arraySet(n.window,t,a-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):(o=n.wsize-n.wnext,o>r&&(o=r),c.arraySet(n.window,t,a-r,o,n.wnext),r-=o,r?(c.arraySet(n.window,t,a-r,r,0),n.wnext=r,n.whave=n.wsize):(n.wnext+=o,n.wnext===n.wsize&&(n.wnext=0),n.whavede;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>8,s.check=f(s.check,i,2,0),se=0,de=0,s.mode=I;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&se)<<8)+(se>>8))%31){t.msg='incorrect header check',s.mode=te;break}if((15&se)!=C){t.msg='unknown compression method',s.mode=te;break}if(se>>>=4,de-=4,we=(15&se)+8,0===s.wbits)s.wbits=we;else if(we>s.wbits){t.msg='invalid window size',s.mode=te;break}s.dmax=1<de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>8),512&s.flags&&(i[0]=255&se,i[1]=255&se>>>8,s.check=f(s.check,i,2,0)),se=0,de=0,s.mode=S;case S:for(;32>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>8,i[2]=255&se>>>16,i[3]=255&se>>>24,s.check=f(s.check,i,4,0)),se=0,de=0,s.mode=R;case R:for(;16>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>8),512&s.flags&&(i[0]=255&se,i[1]=255&se>>>8,s.check=f(s.check,i,2,0)),se=0,de=0,s.mode=B;case B:if(1024&s.flags){for(;16>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>8,s.check=f(s.check,i,2,0)),se=0,de=0}else s.head&&(s.head.extra=null);s.mode=D;case D:if(1024&s.flags&&(ce=s.length,ce>ie&&(ce=ie),ce&&(s.head&&(we=s.head.extra_len-s.length,!s.head.extra&&(s.head.extra=Array(s.head.extra_len)),c.arraySet(s.head.extra,d,ne,ce,we)),512&s.flags&&(s.check=f(s.check,d,ce,ne)),ie-=ce,ne+=ce,s.length-=ce),s.length))break inf_leave;s.length=0,s.mode=P;case P:if(2048&s.flags){if(0===ie)break inf_leave;ce=0;do we=d[ne+ce++],s.head&&we&&65536>s.length&&(s.head.name+=e(we));while(we&&ces.length&&(s.head.comment+=e(we));while(we&&cede;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>9,s.head.done=!0),t.adler=s.check=0,s.mode=L;break;case O:for(;32>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=7&de,de-=7&de,s.mode=J;break}for(;3>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=1,de-=1,3&se){case 0:s.mode=F;break;case 1:if(u(s),s.mode=V,a===v){se>>>=2,de-=2;break inf_leave}break;case 2:s.mode=j;break;case 3:t.msg='invalid block type',s.mode=te;}se>>>=2,de-=2;break;case F:for(se>>>=7&de,de-=7&de;32>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>16)){t.msg='invalid stored block lengths',s.mode=te;break}if(s.length=65535&se,se=0,de=0,s.mode=U,a===v)break inf_leave;case U:s.mode=W;case W:if(ce=s.length,ce){if(ce>ie&&(ce=ie),ce>le&&(ce=le),0===ce)break inf_leave;c.arraySet(re,d,ne,ce,oe),ie-=ce,ne+=ce,le-=ce,oe+=ce,s.length-=ce;break}s.mode=L;break;case j:for(;14>de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=5,de-=5,s.ndist=(31&se)+1,se>>>=5,de-=5,s.ncode=(15&se)+4,se>>>=4,de-=4,286de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=3,de-=3}for(;19>s.have;)s.lens[l[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,Ee={bits:s.lenbits},xe=g(0,s.lens,0,19,s.lencode,0,s.work,Ee),s.lenbits=Ee.bits,xe){t.msg='invalid code lengths set',s.mode=te;break}s.have=0,s.mode=G;case G:for(;s.have>>24,ge=255&r>>>16,be=65535&r,_e<=de)break;if(0===ie)break inf_leave;ie--,se+=d[ne++]<be)se>>>=_e,de-=_e,s.lens[s.have++]=be;else{if(16===be){for(ke=_e+2;de>>=_e,de-=_e,0===s.have){t.msg='invalid bit length repeat',s.mode=te;break}we=s.lens[s.have-1],ce=3+(3&se),se>>>=2,de-=2}else if(17===be){for(ke=_e+3;de>>=_e,de-=_e,we=0,ce=3+(7&se),se>>>=3,de-=3}else{for(ke=_e+7;de>>=_e,de-=_e,we=0,ce=11+(127&se),se>>>=7,de-=7}if(s.have+ce>s.nlen+s.ndist){t.msg='invalid bit length repeat',s.mode=te;break}for(;ce--;)s.lens[s.have++]=we}}if(s.mode===te)break;if(0===s.lens[256]){t.msg='invalid code -- missing end-of-block',s.mode=te;break}if(s.lenbits=9,Ee={bits:s.lenbits},xe=g(b,s.lens,0,s.nlen,s.lencode,0,s.work,Ee),s.lenbits=Ee.bits,xe){t.msg='invalid literal/lengths set',s.mode=te;break}if(s.distbits=6,s.distcode=s.distdyn,Ee={bits:s.distbits},xe=g(m,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,Ee),s.distbits=Ee.bits,xe){t.msg='invalid distances set',s.mode=te;break}if(s.mode=V,a===v)break inf_leave;case V:s.mode=X;case X:if(6<=ie&&258<=le){t.next_out=oe,t.avail_out=le,t.next_in=ne,t.avail_in=ie,s.hold=se,s.bits=de,_(t,pe),oe=t.next_out,re=t.output,le=t.avail_out,ne=t.next_in,d=t.input,ie=t.avail_in,se=s.hold,de=s.bits,s.mode===L&&(s.back=-1);break}for(s.back=0;;){if(r=s.lencode[se&(1<>>24,ge=255&r>>>16,be=65535&r,_e<=de)break;if(0===ie)break inf_leave;ie--,se+=d[ne++]<>me)],_e=r>>>24,ge=255&r>>>16,be=65535&r,me+_e<=de)break;if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=me,de-=me,s.back+=me}if(se>>>=_e,de-=_e,s.back+=_e,s.length=be,0===ge){s.mode=Q;break}if(32&ge){s.back=-1,s.mode=L;break}if(64&ge){t.msg='invalid literal/length code',s.mode=te;break}s.extra=15&ge,s.mode=Y;case Y:if(s.extra){for(ke=s.extra;de>>=s.extra,de-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=Z;case Z:for(;;){if(r=s.distcode[se&(1<>>24,ge=255&r>>>16,be=65535&r,_e<=de)break;if(0===ie)break inf_leave;ie--,se+=d[ne++]<>me)],_e=r>>>24,ge=255&r>>>16,be=65535&r,me+_e<=de)break;if(0===ie)break inf_leave;ie--,se+=d[ne++]<>>=me,de-=me,s.back+=me}if(se>>>=_e,de-=_e,s.back+=_e,64&ge){t.msg='invalid distance code',s.mode=te;break}s.offset=be,s.extra=15&ge,s.mode=K;case K:if(s.extra){for(ke=s.extra;de>>=s.extra,de-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){t.msg='invalid distance too far back',s.mode=te;break}s.mode=q;case q:if(0===le)break inf_leave;if(ce=pe-le,s.offset>ce){if(ce=s.offset-ce,ce>s.whave&&s.sane){t.msg='invalid distance too far back',s.mode=te;break}ce>s.wnext?(ce-=s.wnext,he=s.wsize-ce):he=s.wnext-ce,ce>s.length&&(ce=s.length),fe=s.window}else fe=re,he=oe-s.offset,ce=s.length;ce>le&&(ce=le),le-=ce,s.length-=ce;do re[oe++]=fe[he++];while(--ce);0===s.length&&(s.mode=X);break;case Q:if(0===le)break inf_leave;re[oe++]=s.length,le--,s.mode=X;break;case J:if(s.wrap){for(;32>de;){if(0===ie)break inf_leave;ie--,se|=d[ne++]<de;){if(0===ie)break inf_leave;ie--,se+=d[ne++]<_&&(f+=T[n++]<<_,_+=8,f+=T[n++]<<_,_+=8),v=g[f&m];dolen:for(;;){if(w=v>>>24,f>>>=w,_-=w,w=255&v>>>16,0===w)I[i++]=65535&v;else if(16&w){x=65535&v,w&=15,w&&(_>>=w,_-=w),15>_&&(f+=T[n++]<<_,_+=8,f+=T[n++]<<_,_+=8),v=b[f&y];dodist:for(;;){if(w=v>>>24,f>>>=w,_-=w,w=255&v>>>16,16&w){if(E=65535&v,w&=15,_d){e.msg='invalid distance too far back',r.mode=t;break top}if(f>>>=w,_-=w,w=i-l,E>w){if(w=E-w,w>p&&r.sane){e.msg='invalid distance too far back',r.mode=t;break top}if(k=0,C=h,0===c){if(k+=u-w,w>3,n-=x,_-=x<<3,f&=(1<<_)-1,e.next_in=n,e.next_out=i,e.avail_in=nE&&(k=E),0==E)return _[g++]=20971520,_[g++]=20971520,m.bits=1,0;for(x=1;xI)return-1;if(0o||e===d&&S>i)return 1;for(;;){j=v-T,b[w]W?(H=z[O+b[w]],G=B[D+b[w]]):(H=96,G=0),N=1<>T)+L]=0|(j<<24|H<<16|G);while(0!==L);for(N=1<>=1;if(0===N?R=0:(R&=N-1,R+=N),w++,0==--P[v]){if(v==E)break;v=t[a+b[w]]}if(v>k&&(R&F)!==M){for(0==T&&(T=k),U+=x,C=v-T,I=1<=I));)C++,I<<=1;if(S+=1<o||e===d&&S>i)return 1;M=R&F,_[M]=0|(k<<24|C<<16|U-g)}}return 0!==R&&(_[U+R]=0|(4194304|v-T<<24)),m.bits=k,0}},function(e){'use strict';e.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}},function(e,t){'use strict';var a=this&&this.__awaiter||function(e,t,a,r){return new(a||(a=Promise))(function(n,o){function i(e){try{s(r.next(e))}catch(t){o(t)}}function l(e){try{s(r['throw'](e))}catch(t){o(t)}}function s(e){e.done?n(e.value):new a(function(t){t(e.value)}).then(i,l)}s((r=r.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,a){function r(e){return function(t){return o([e,t])}}function o(r){if(i)throw new TypeError('Generator is already executing.');for(;n;)try{if(i=1,l&&(s=l[2&r[0]?'return':r[0]?'throw':'next'])&&!(s=s.call(l,r[1])).done)return s;switch((l=0,s)&&(r=[0,s.value]),r[0]){case 0:case 1:s=r;break;case 4:return n.label++,{value:r[1],done:!1};case 5:n.label++,l=r[1],r=[0];continue;case 7:r=n.ops.pop(),n.trys.pop();continue;default:if((s=n.trys,!(s=0s[0]&&r[1]s[0]&&r[1]'),a.firstChild.href},t.prototype.setDescriptorAndParameters=function(e,t){return n(this,void 0,void 0,function(){var a=this,r,n,i,l,u;return o(this,function(o){switch(o.label){case 0:return this.descriptor=e,this.placeholderContext=new d.default(this.descriptor.placeholders),r='object'==typeof WebAssembly?'webassembly':'asmjs',0<=window.navigator.userAgent.indexOf('iPhone OS 11_2')&&(r='asmjs'),n=this.directory+'/kernels_'+r+'.js',n=s.transformUrl(n),this.worker_entry_js_path=n,[4,fetch(this.worker_entry_js_path)];case 1:return i=o.sent(),[4,i.text()];case 2:return l=o.sent(),u=function(e,t){var r=a.absolutePath(a.directory+'/'+e),n=s.transformUrl(r);l=l.replace(t,n)},'webassembly'===r?u('kernels_webassembly.wasm','WEBDNN_URL_KERNELS_WASM'):u('kernels_asmjs.js.mem','WEBDNN_URL_KERNELS_ASMJS_MEM'),[4,this.compile(l)];case 3:return o.sent(),[4,this.loadWeights(new Uint8Array(t))];case 4:return o.sent(),[4,this.getInputViews()];case 5:return o.sent().filter(function(e){return!e.isDynamic}).forEach(function(e){e.buffer=new Float32Array(e.length).buffer}),[4,this.getOutputViews()];case 6:return o.sent().filter(function(e){return!e.isDynamic}).forEach(function(e){e.buffer=new Float32Array(e.length).buffer}),[2];}})})},t.prototype.fetchDescriptor=function(e){return n(this,void 0,void 0,function(){var t;return o(this,function(a){switch(a.label){case 0:return this.directory=e,[4,s.default(e+'/graph_'+this.backendName+'.json')];case 1:return t=a.sent(),[2,t.json()];}})})},t.prototype.fetchParameters=function(e,t){return n(this,void 0,void 0,function(){var a,r;return o(this,function(n){switch(n.label){case 0:return a=e+'/weight_'+this.backendName+'.bin',[4,s.default(a)];case 1:return r=n.sent(),[2,s.readArrayBufferProgressively(r,t)];}})})},t.prototype.restoreCachedDescriptor=function(e){return n(this,void 0,void 0,function(){return o(this,function(){return this.directory=e,[2,i.getItem(e+'_'+this.backendName+'_descriptor').catch(function(){return null})]})})},t.prototype.restoreCachedParameters=function(e,t){return n(this,void 0,void 0,function(){var a;return o(this,function(r){switch(r.label){case 0:return[4,i.getItem(e+'_'+this.backendName+'_parameters').catch(function(){return null})];case 1:return a=r.sent(),a&&t&&t(a.byteLength,a.byteLength),[2,a];}})})},t.prototype.saveCache=function(e,t,a){return n(this,void 0,void 0,function(){return o(this,function(r){switch(r.label){case 0:return[4,Promise.all([i.setItem(e+'_'+this.backendName+'_descriptor',t),i.setItem(e+'_'+this.backendName+'_parameters',a)])];case 1:return r.sent(),[2];}})})},(t.prototype.setPlaceholderValue=function(e){return n(this,void 0,void 0,function(){var t,a,r,n,i,l,s;return o(this,function(o){switch(o.label){case 0:if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized.');if(t=this.placeholderContext,t.update(e),!t.isResolved)return[2];if(!this.descriptor)throw new Error('Descriptor is not loaded');for(a=this.descriptor,r=a.unresolved_value_lists,n=[],i=function(e){var a=r[e];a.forEach(function(a){var r=t.resolve(a.placeholder);n.push(e,a.offset,r)})},l=0;li;i++)if(u=l[i][a.inputs[d]],u){var p=e.inputs[d];s.push({space:i,offset:t.resolve(u.offset),size:p.length,data:p.toActual()});break}for(var c=[],d=0;di;i++)if(u=l[i][a.outputs[d]],u){var p=e.outputs[d];c.push({space:i,offset:t.resolve(u.offset),size:p.length});break}r.postMessage({type:'run',inputs:s,outputs:c})}),[2,n]})})},t)}(p.DescriptorRunner);t.default=c},function(e,t,a){'use strict';var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])};return function(t,a){function r(){this.constructor=t}e(t,a),t.prototype=null===a?Object.create(a):(r.prototype=a.prototype,new r)}}(),n=this&&this.__awaiter||function(e,t,a,r){return new(a||(a=Promise))(function(n,o){function i(e){try{s(r.next(e))}catch(t){o(t)}}function l(e){try{s(r['throw'](e))}catch(t){o(t)}}function s(e){e.done?n(e.value):new a(function(t){t(e.value)}).then(i,l)}s((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,a){function r(e){return function(t){return o([e,t])}}function o(r){if(i)throw new TypeError('Generator is already executing.');for(;n;)try{if(i=1,l&&(s=l[2&r[0]?'return':r[0]?'throw':'next'])&&!(s=s.call(l,r[1])).done)return s;switch((l=0,s)&&(r=[0,s.value]),r[0]){case 0:case 1:s=r;break;case 4:return n.label++,{value:r[1],done:!1};case 5:n.label++,l=r[1],r=[0];continue;case 7:r=n.ops.pop(),n.trys.pop();continue;default:if((s=n.trys,!(s=0s[0]&&r[1]s[0]&&r[1]s[0]&&r[1]\nusing namespace metal;\n kernel void check_compatibility(\n device uint *A[[buffer(0)]],\n uint global_index[[thread_position_in_grid]],\n uint thread_execution_width[[thread_execution_width]]\n ){\n if (global_index == 0) {\n A[0] = thread_execution_width;\n }\n }','basic'),e=this.webgpuHandler.createBuffer(new Uint32Array(1)),[4,this.webgpuHandler.executeSinglePipelineState('basic.check_compatibility',{width:1,height:1,depth:1},{width:1,height:1,depth:1},[e],!0)];case 1:if(a.sent(),t=new Uint32Array(e.contents)[0],32!=t)throw new Error('Sorry, this GPU does not compatible with WebGPU (thread_execution_width == '+t+'. See checkIncompatibleGPU method of https://github.com/mil-tokyo/webdnn/blob/master/src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.ts');return[2];}})})},t.prototype.fetchDescriptor=function(e){return n(this,void 0,void 0,function(){var t;return o(this,function(a){switch(a.label){case 0:return[4,d.default(e+'/graph_'+this.backendName+'.json')];case 1:return t=a.sent(),[2,t.json()];}})})},t.prototype.fetchParameters=function(e,t){return n(this,void 0,void 0,function(){var a;return o(this,function(r){switch(r.label){case 0:return[4,d.default(e+'/weight_'+this.backendName+'.bin')];case 1:return a=r.sent(),[2,d.readArrayBufferProgressively(a,t)];}})})},t.prototype.restoreCachedDescriptor=function(e){return n(this,void 0,void 0,function(){return o(this,function(){return[2,i.getItem(e+'_'+this.backendName+'_descriptor').catch(function(){return null})]})})},t.prototype.restoreCachedParameters=function(e,t){return n(this,void 0,void 0,function(){var a;return o(this,function(r){switch(r.label){case 0:return[4,i.getItem(e+'_'+this.backendName+'_parameters').catch(function(){return null})];case 1:return a=r.sent(),a&&t&&t(a.byteLength,a.byteLength),[2,a];}})})},t.prototype.saveCache=function(e,t,a){return n(this,void 0,void 0,function(){return o(this,function(r){switch(r.label){case 0:return[4,Promise.all([i.setItem(e+'_'+this.backendName+'_descriptor',t),i.setItem(e+'_'+this.backendName+'_parameters',a)])];case 1:return r.sent(),[2];}})})},(t.prototype.setDescriptorAndParameters=function(e,t){return n(this,void 0,void 0,function(){return o(this,function(a){switch(a.label){case 0:return this.descriptor=e,this.staticBuffer=null,this.dynamicBuffer=null,this.metaBuffers=null,this.placeholderContext=new u.default(e.placeholders),this.executionInfos=e.exec_infos,this.webgpuHandler.loadKernel(this.descriptor.kernel_source,'descriptor'),[4,this.initializeStaticBuffer(t)];case 1:return a.sent(),[4,this.initializeMetaBuffers()];case 2:return a.sent(),[4,this.setPlaceholderValue({__MAX_THREADS_PER_THREADGROUP__:_?512:1024})];case 3:return a.sent(),this.placeholderContext&&this.placeholderContext.isResolved?[4,this.initializeDynamicBuffer()]:[3,5];case 4:a.sent(),a.label=5;case 5:return[2];}})})},t.prototype.initializeStaticBuffer=function(e){return n(this,void 0,void 0,function(){var t,a,r,n,i;return o(this,function(o){switch(o.label){case 0:if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');return t=this.descriptor,a=new l.default(t.memory_layout.static.size*Float32Array.BYTES_PER_ELEMENT),this.staticBuffer=a,r=s.default(t.weight_encoding),i=(n=a).write,[4,r.decode(new Uint8Array(e))];case 1:return[4,i.apply(n,[o.sent()])];case 2:return o.sent(),[4,this.getInputViews()];case 3:return o.sent().filter(function(e){return!e.isDynamic}).forEach(function(e){e.buffer=a.bufferView.buffer}),[4,this.getOutputViews()];case 4:return o.sent().filter(function(e){return!e.isDynamic}).forEach(function(e){e.buffer=a.bufferView.buffer}),[2];}})})},t.prototype.initializeMetaBuffers=function(){return n(this,void 0,void 0,function(){var e=this,t;return o(this,function(a){switch(a.label){case 0:if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');return t=this,[4,Promise.all(this.descriptor.exec_infos.map(function(t){return n(e,void 0,void 0,function(){var e;return o(this,function(a){switch(a.label){case 0:return e=new l.default(t.meta_buffer.length*Int32Array.BYTES_PER_ELEMENT),[4,e.write(new Uint8Array(t.meta_buffer))];case 1:return a.sent(),[2,e];}})})}))];case 1:return t.metaBuffers=a.sent(),[2];}})})},t.prototype.initializeDynamicBuffer=function(){return n(this,void 0,void 0,function(){var e,t,a,r;return o(this,function(n){switch(n.label){case 0:if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');if(!this.placeholderContext)throw Error('PlaceholderContext is not initialized.');return e=this.descriptor,t=this.placeholderContext,a=t.resolve(e.memory_layout.dynamic.size),r=new l.default(a*Float32Array.BYTES_PER_ELEMENT),this.dynamicBuffer=r,[4,this.getInputViews()];case 1:return n.sent().filter(function(e){return e.isDynamic}).forEach(function(e){e.buffer=r.bufferView.buffer}),[4,this.getOutputViews()];case 2:return n.sent().filter(function(e){return e.isDynamic}).forEach(function(e){e.buffer=r.bufferView.buffer}),[2];}})})},t.prototype.setPlaceholderValue=function(e){return n(this,void 0,void 0,function(){var t=this,a,r,l,i;return o(this,function(s){switch(s.label){case 0:if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized.');if(a=this.placeholderContext,a.update(e),!a.isResolved)return[2];if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.metaBuffers)throw new Error('MetaBuffers are not initialized');return r=this.descriptor,l=this.metaBuffers,[4,this.initializeDynamicBuffer()];case 1:return s.sent(),i=this,[4,Promise.all(r.exec_infos.map(function(e,r){return n(t,void 0,void 0,function(){var t,n,i,s;return o(this,function(){for(t=new Int32Array(l[r].bufferView.buffer),n=0,i=e.unresolved_value_list;ns[0]&&r[1]=l-1)){for(;;){for(;e[d]>s&&d<=u;)d++;for(;e[u]<=s&&d<=u;)u--;if(d>=u)break;p=e[d],e[d]=e[u],e[u]=p,p=r[d],r[d]=r[u],r[u]=p}e[l-1]=e[d],e[d]=s,p=r[l-1],r[l-1]=r[d],r[d]=p,a.push([i,d]),d+1=l-1)){for(;;){for(;e[d]=s&&d<=u;)u--;if(d>=u)break;p=e[d],e[d]=e[u],e[u]=p,p=r[d],r[d]=r[u],r[u]=p}e[l-1]=e[d],e[d]=s,p=r[l-1],r[l-1]=r[d],r[d]=p,a.push([i,d]),d+1 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar dispatch_scheduler_1 = require(\"./util/dispatch_scheduler\");\n/**\n * @protected\n */\nvar transformDelegate = function (url) { return url; };\n/**\n * Transform url generated based on current active backend\n * @param url transformed url\n * @protected\n */\nfunction transformUrl(url) {\n return transformDelegate(url);\n}\nexports.transformUrl = transformUrl;\n/**\n * Register delegate function for transform url.\n * @param delegate Delegate function which will be called with original url, and must return converted url strings.\n * @protected\n */\nfunction registerTransformUrlDelegate(delegate) {\n transformDelegate = delegate;\n}\nexports.registerTransformUrlDelegate = registerTransformUrlDelegate;\n/**\n * Fetch function. WebDNN API use this function instead of original `fetch` function.\n * FIXME\n * @param input Requested url\n * @param init Additional information about webdnnFetch\n * @param init.ignoreCache If true, cache is ignored by appending '?t=(timestamp)' to the end of request url.\n * @returns Response\n * @protected\n */\nfunction webdnnFetch(input, init) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (typeof input == 'string') {\n input = transformUrl(input) + ((init && init.ignoreCache) ? '?t=' + Date.now() : '');\n }\n else {\n input = Object.assign({}, input, {\n url: transformUrl(input.url) + ((init && init.ignoreCache) ? '?t=' + Date.now() : '')\n });\n }\n if (!(typeof input == 'string' && isXHR2WithBlobSupported())) return [3 /*break*/, 2];\n return [4 /*yield*/, fetchUsingXHR(input, init && init.progressCallback)];\n case 1:\n res = _a.sent();\n return [3 /*break*/, 4];\n case 2: return [4 /*yield*/, fetch(input, init)];\n case 3:\n res = _a.sent();\n _a.label = 4;\n case 4:\n if (!res.ok)\n throw new Error(\"Fetch returns status code \" + res.status + \": \" + res.statusText);\n return [2 /*return*/, res];\n }\n });\n });\n}\nexports.default = webdnnFetch;\n/**\n * Read `Response.body` stream as ArrayBuffer. This function provide progress information by callback.\n * @param res Response object\n * @param callback Callback function.\n * @returns ArrayBuffer\n * @protected\n */\nfunction readArrayBufferProgressively(res, callback) {\n if (!callback || !res.body)\n return res.arrayBuffer();\n var contentLength = res.headers.get('Content-Length');\n if (!contentLength)\n return res.arrayBuffer();\n var total = parseInt(contentLength);\n var buffer = new Uint8Array(total);\n var loaded = 0;\n var reader = res.body.getReader();\n var callbackScheduler = new dispatch_scheduler_1.default();\n function accumulateLoadedSize(chunk) {\n buffer.set(chunk.value, loaded);\n loaded += chunk.value.length;\n if (callback) {\n callbackScheduler.request(function () { return callback(loaded, total); });\n }\n if (loaded == total) {\n callbackScheduler.forceDispatch();\n return buffer.buffer;\n }\n else {\n return reader.read().then(accumulateLoadedSize);\n }\n }\n return reader.read().then(accumulateLoadedSize);\n}\nexports.readArrayBufferProgressively = readArrayBufferProgressively;\n/**\n * check whether XMLHttpRequest with Blob type is supported or not\n * @protected\n */\nfunction isXHR2WithBlobSupported() {\n if (!window.hasOwnProperty('ProgressEvent') || !window.hasOwnProperty('FormData')) {\n return false;\n }\n var xhr = new XMLHttpRequest();\n if (typeof xhr.responseType === 'string') {\n try {\n xhr.responseType = 'blob';\n return xhr.responseType === 'blob';\n }\n catch (e) {\n return false;\n }\n }\n else {\n return false;\n }\n}\n/**\n * fetch with XMLHttpRequest\n * @protected\n */\nfunction fetchUsingXHR(url, callback) {\n return new Promise(function (resolve, reject) {\n var req = new XMLHttpRequest();\n req.open(\"GET\", url, true);\n req.responseType = \"blob\";\n var callbackScheduler = new dispatch_scheduler_1.default();\n req.onload = function (event) {\n callbackScheduler.forceDispatch();\n var res = new Response(req.response);\n resolve(res);\n };\n req.onprogress = function (event) {\n if (callback) {\n callbackScheduler.request(function () { return callback(event.loaded, event.total); });\n }\n };\n req.onerror = function (event) {\n reject(event);\n };\n req.send(null);\n });\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/fetch.js\n// module id = 1\n// module chunks = 0","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar descriptor_runner_fallback_1 = require(\"./descriptor_runner/descriptor_runner_fallback\");\nvar descriptor_runner_webassembly_1 = require(\"./descriptor_runner/descriptor_runner_webassembly\");\nvar descriptor_runner_webgl_1 = require(\"./descriptor_runner/descriptor_runner_webgl\");\nvar descriptor_runner_webgpu_1 = require(\"./descriptor_runner/descriptor_runner_webgpu\");\nvar fetch_1 = require(\"./fetch\");\nvar Image = require(\"./image\");\nexports.Image = Image;\nvar Math = require(\"./math\");\nexports.Math = Math;\n/**\n * DEBUG flag for developing WebDNN\n * @private\n */\nvar configurations = {};\n/**\n * get configuration\n * @private\n */\nfunction getConfiguration(key, defaultValue) {\n return key in configurations ? configurations[key] : defaultValue;\n}\nexports.getConfiguration = getConfiguration;\n/**\n * set configuration\n * @private\n */\nfunction setConfiguration(key, value) {\n configurations[key] = value;\n}\nexports.setConfiguration = setConfiguration;\n/**\n * Backend constructor map\n * @private\n */\nvar descriptorRunners = {\n webgpu: descriptor_runner_webgpu_1.default,\n webgl: descriptor_runner_webgl_1.default,\n webassembly: descriptor_runner_webassembly_1.default,\n fallback: descriptor_runner_fallback_1.default\n};\n/**\n * Check each computing backend is available or not in this browser.\n * The result will be returned as [[BackendAvailability|`BackendAvailability`]] structure.\n *\n * @returns backend availability\n */\nfunction getBackendAvailability() {\n var status = {\n 'webgpu': descriptorRunners['webgpu'].checkAvailability(),\n 'webgl': descriptorRunners['webgl'].checkAvailability(),\n 'webassembly': descriptorRunners['webassembly'].checkAvailability(),\n 'fallback': descriptorRunners['fallback'].checkAvailability(),\n };\n var order = ['webgpu', 'webgl', 'webassembly', 'fallback'].filter(function (backend) { return status[backend]; });\n return {\n status: status,\n defaultOrder: order\n };\n}\nexports.getBackendAvailability = getBackendAvailability;\n/**\n * Initialize specified backend\n * @private\n */\nfunction initBackend(backendName, option) {\n return __awaiter(this, void 0, void 0, function () {\n var runner, ex_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(backendName in descriptorRunners))\n throw new Error(\"Unknown backend: \\\"\" + backendName + \"\\\"\");\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n runner = new descriptorRunners[backendName](option);\n return [4 /*yield*/, runner.init()];\n case 2:\n _a.sent();\n return [3 /*break*/, 4];\n case 3:\n ex_1 = _a.sent();\n console.warn(\"Failed to initialize \" + backendName + \" backend: \" + ex_1);\n return [2 /*return*/, null];\n case 4: return [2 /*return*/, runner];\n }\n });\n });\n}\n/**\n * Initialize descriptor runner. This function performs follow things.\n *\n * 1. Try to initialize computing backend. WebDNN will try to initialize each backend in order of\n * the result of [[getBackendAvailability|`getBackendAvailability`]].\n * If you want to modify this order, specify [[InitOption.backendOrder|`initOption.backendOrder`]] option.\n *\n * 2. Load model data based on initialized backend. Generally, DNN binary data is very large and it takes long time to load.\n * [[InitOption.progressCallback|`initOption.progressCallback`]] option provides the progress status of loading.\n *\n * ### Examples\n *\n * - Basic usage\n *\n * ```js\n * let runner = await WebDNN.load('./model');\n * ```\n *\n * - With `initOption.progressCallback` option\n *\n * ```js\n * let runner = await WebDNN.load('./model', {\n * progressCallback: (loaded, total) => console.log(`${ (loaded/total*100).toFixed(1) }% Loaded`);\n * });\n * ```\n *\n * @param directory URL of directory that contains graph descriptor files (e.g. graph_webgpu.json)\n * @param initOption Initialize option\n * @return DescriptorRunner instance, which is the interface to input/output data and run the model.\n */\nfunction load(directory, initOption) {\n if (initOption === void 0) { initOption = {}; }\n return __awaiter(this, void 0, void 0, function () {\n var _a, backendOrder, _b, backendOptions, _c, cacheStrategy, _d, saveCache, progressCallback, weightDirectory, transformUrlDelegate, backendName, runner, descriptor, parameters, fetchedDescriptor, cachedDescriptor, _e, e_1, ex_2;\n return __generator(this, function (_f) {\n switch (_f.label) {\n case 0:\n _a = initOption.backendOrder, backendOrder = _a === void 0 ? null : _a, _b = initOption.backendOptions, backendOptions = _b === void 0 ? {} : _b, _c = initOption.cacheStrategy, cacheStrategy = _c === void 0 ? 'latest' : _c, _d = initOption.saveCache, saveCache = _d === void 0 ? true : _d, progressCallback = initOption.progressCallback, weightDirectory = initOption.weightDirectory, transformUrlDelegate = initOption.transformUrlDelegate;\n if (!backendOrder)\n backendOrder = getBackendAvailability().defaultOrder;\n if (typeof backendOrder === 'string')\n backendOrder = [backendOrder];\n backendOrder = backendOrder.slice();\n if (backendOrder.indexOf('fallback') === -1)\n backendOrder.concat(['fallback']);\n fetch_1.registerTransformUrlDelegate(function (url) {\n if (weightDirectory) {\n if ((/\\.bin/).test(url)) {\n url = url.replace(directory, weightDirectory);\n }\n }\n if (transformUrlDelegate)\n url = transformUrlDelegate(url);\n return url;\n });\n _f.label = 1;\n case 1:\n if (!(backendOrder.length > 0)) return [3 /*break*/, 36];\n backendName = backendOrder.shift();\n return [4 /*yield*/, initBackend(backendName, backendOptions[backendName])];\n case 2:\n runner = _f.sent();\n if (!runner)\n return [3 /*break*/, 1];\n _f.label = 3;\n case 3:\n _f.trys.push([3, 34, , 35]);\n descriptor = void 0;\n parameters = void 0;\n fetchedDescriptor = void 0;\n cachedDescriptor = void 0;\n _e = cacheStrategy;\n switch (_e) {\n case 'latest': return [3 /*break*/, 4];\n case 'networkOnly': return [3 /*break*/, 13];\n case 'networkFirst': return [3 /*break*/, 13];\n case 'cacheOnly': return [3 /*break*/, 20];\n case 'cacheFirst': return [3 /*break*/, 20];\n }\n return [3 /*break*/, 27];\n case 4: return [4 /*yield*/, runner.fetchDescriptor(directory).catch(function () { return null; })];\n case 5:\n fetchedDescriptor = _f.sent();\n return [4 /*yield*/, runner.restoreCachedDescriptor(directory)];\n case 6:\n cachedDescriptor = _f.sent();\n if (!(cachedDescriptor && fetchedDescriptor && cachedDescriptor.converted_at === fetchedDescriptor.converted_at)) return [3 /*break*/, 8];\n descriptor = cachedDescriptor;\n return [4 /*yield*/, runner.restoreCachedParameters(directory, progressCallback)];\n case 7:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 8;\n case 8:\n if (!fetchedDescriptor) return [3 /*break*/, 10];\n descriptor = fetchedDescriptor;\n return [4 /*yield*/, runner.fetchParameters(directory, progressCallback)];\n case 9:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 10;\n case 10:\n if (!cachedDescriptor) return [3 /*break*/, 12];\n descriptor = cachedDescriptor;\n return [4 /*yield*/, runner.restoreCachedParameters(directory, progressCallback)];\n case 11:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 12;\n case 12: throw Error('Network error is occurred and no cache is exist.');\n case 13: return [4 /*yield*/, runner.fetchDescriptor(directory).catch(function () { return null; })];\n case 14:\n fetchedDescriptor = _f.sent();\n if (!fetchedDescriptor) return [3 /*break*/, 16];\n descriptor = fetchedDescriptor;\n return [4 /*yield*/, runner.fetchParameters(directory, progressCallback)];\n case 15:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 16;\n case 16:\n if (cacheStrategy === 'networkOnly')\n throw Error('Network error is occurred in \"networkOnly\" cache strategy');\n return [4 /*yield*/, runner.restoreCachedDescriptor(directory)];\n case 17:\n cachedDescriptor = _f.sent();\n if (!cachedDescriptor) return [3 /*break*/, 19];\n descriptor = cachedDescriptor;\n return [4 /*yield*/, runner.restoreCachedParameters(directory, progressCallback)];\n case 18:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 19;\n case 19: throw Error('Network error is occurred and no cache is exist.');\n case 20: return [4 /*yield*/, runner.restoreCachedDescriptor(directory)];\n case 21:\n cachedDescriptor = _f.sent();\n if (!cachedDescriptor) return [3 /*break*/, 23];\n descriptor = cachedDescriptor;\n return [4 /*yield*/, runner.restoreCachedParameters(directory, progressCallback)];\n case 22:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 23;\n case 23:\n if (cacheStrategy === 'cacheOnly')\n throw Error('No cache is exist in \"cacheOnly\" cache strategy');\n return [4 /*yield*/, runner.fetchDescriptor(directory).catch(function () { return null; })];\n case 24:\n fetchedDescriptor = _f.sent();\n if (!fetchedDescriptor) return [3 /*break*/, 26];\n descriptor = fetchedDescriptor;\n return [4 /*yield*/, runner.fetchParameters(directory, progressCallback)];\n case 25:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 26;\n case 26: throw Error('Network error is occurred and no cache is exist.');\n case 27: throw Error(\"\\\"\" + cacheStrategy + \"\\\" is not valid cache strategy name: \\\"latest\\\", \\\"networkFirst\\\", \\\"networkOnly\\\", \\\"cacheFirst\\\", \\\"cacheOnly\\\" is available.\");\n case 28:\n if (!saveCache) return [3 /*break*/, 32];\n _f.label = 29;\n case 29:\n _f.trys.push([29, 31, , 32]);\n return [4 /*yield*/, runner.saveCache(directory, descriptor, parameters)];\n case 30:\n _f.sent();\n return [3 /*break*/, 32];\n case 31:\n e_1 = _f.sent();\n return [3 /*break*/, 32];\n case 32: return [4 /*yield*/, runner.setDescriptorAndParameters(descriptor, parameters)];\n case 33:\n _f.sent();\n return [3 /*break*/, 35];\n case 34:\n ex_2 = _f.sent();\n console.warn(\"Model loading failed for \" + backendName + \" backend. Trying next backend: \" + ex_2.message);\n return [3 /*break*/, 1];\n case 35: return [2 /*return*/, runner];\n case 36: throw new Error('No backend is available');\n }\n });\n });\n}\nexports.load = load;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webdnn.js\n// module id = 2\n// module chunks = 0","/*!\n localForage -- Offline Storage, Improved\n Version 1.5.6\n https://localforage.github.io/localForage\n (c) 2013-2017 Mozilla, Apache License 2.0\n*/\n(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.localforage = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw (f.code=\"MODULE_NOT_FOUND\", f)}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o element; its readystatechange event will be fired asynchronously once it is inserted\n // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.\n var scriptEl = global.document.createElement('script');\n scriptEl.onreadystatechange = function () {\n nextTick();\n\n scriptEl.onreadystatechange = null;\n scriptEl.parentNode.removeChild(scriptEl);\n scriptEl = null;\n };\n global.document.documentElement.appendChild(scriptEl);\n };\n } else {\n scheduleDrain = function () {\n setTimeout(nextTick, 0);\n };\n }\n}\n\nvar draining;\nvar queue = [];\n//named nextTick for less confusing stack traces\nfunction nextTick() {\n draining = true;\n var i, oldQueue;\n var len = queue.length;\n while (len) {\n oldQueue = queue;\n queue = [];\n i = -1;\n while (++i < len) {\n oldQueue[i]();\n }\n len = queue.length;\n }\n draining = false;\n}\n\nmodule.exports = immediate;\nfunction immediate(task) {\n if (queue.push(task) === 1 && !draining) {\n scheduleDrain();\n }\n}\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{}],2:[function(_dereq_,module,exports){\n'use strict';\nvar immediate = _dereq_(1);\n\n/* istanbul ignore next */\nfunction INTERNAL() {}\n\nvar handlers = {};\n\nvar REJECTED = ['REJECTED'];\nvar FULFILLED = ['FULFILLED'];\nvar PENDING = ['PENDING'];\n\nmodule.exports = Promise;\n\nfunction Promise(resolver) {\n if (typeof resolver !== 'function') {\n throw new TypeError('resolver must be a function');\n }\n this.state = PENDING;\n this.queue = [];\n this.outcome = void 0;\n if (resolver !== INTERNAL) {\n safelyResolveThenable(this, resolver);\n }\n}\n\nPromise.prototype[\"catch\"] = function (onRejected) {\n return this.then(null, onRejected);\n};\nPromise.prototype.then = function (onFulfilled, onRejected) {\n if (typeof onFulfilled !== 'function' && this.state === FULFILLED ||\n typeof onRejected !== 'function' && this.state === REJECTED) {\n return this;\n }\n var promise = new this.constructor(INTERNAL);\n if (this.state !== PENDING) {\n var resolver = this.state === FULFILLED ? onFulfilled : onRejected;\n unwrap(promise, resolver, this.outcome);\n } else {\n this.queue.push(new QueueItem(promise, onFulfilled, onRejected));\n }\n\n return promise;\n};\nfunction QueueItem(promise, onFulfilled, onRejected) {\n this.promise = promise;\n if (typeof onFulfilled === 'function') {\n this.onFulfilled = onFulfilled;\n this.callFulfilled = this.otherCallFulfilled;\n }\n if (typeof onRejected === 'function') {\n this.onRejected = onRejected;\n this.callRejected = this.otherCallRejected;\n }\n}\nQueueItem.prototype.callFulfilled = function (value) {\n handlers.resolve(this.promise, value);\n};\nQueueItem.prototype.otherCallFulfilled = function (value) {\n unwrap(this.promise, this.onFulfilled, value);\n};\nQueueItem.prototype.callRejected = function (value) {\n handlers.reject(this.promise, value);\n};\nQueueItem.prototype.otherCallRejected = function (value) {\n unwrap(this.promise, this.onRejected, value);\n};\n\nfunction unwrap(promise, func, value) {\n immediate(function () {\n var returnValue;\n try {\n returnValue = func(value);\n } catch (e) {\n return handlers.reject(promise, e);\n }\n if (returnValue === promise) {\n handlers.reject(promise, new TypeError('Cannot resolve promise with itself'));\n } else {\n handlers.resolve(promise, returnValue);\n }\n });\n}\n\nhandlers.resolve = function (self, value) {\n var result = tryCatch(getThen, value);\n if (result.status === 'error') {\n return handlers.reject(self, result.value);\n }\n var thenable = result.value;\n\n if (thenable) {\n safelyResolveThenable(self, thenable);\n } else {\n self.state = FULFILLED;\n self.outcome = value;\n var i = -1;\n var len = self.queue.length;\n while (++i < len) {\n self.queue[i].callFulfilled(value);\n }\n }\n return self;\n};\nhandlers.reject = function (self, error) {\n self.state = REJECTED;\n self.outcome = error;\n var i = -1;\n var len = self.queue.length;\n while (++i < len) {\n self.queue[i].callRejected(error);\n }\n return self;\n};\n\nfunction getThen(obj) {\n // Make sure we only access the accessor once as required by the spec\n var then = obj && obj.then;\n if (obj && (typeof obj === 'object' || typeof obj === 'function') && typeof then === 'function') {\n return function appyThen() {\n then.apply(obj, arguments);\n };\n }\n}\n\nfunction safelyResolveThenable(self, thenable) {\n // Either fulfill, reject or reject with error\n var called = false;\n function onError(value) {\n if (called) {\n return;\n }\n called = true;\n handlers.reject(self, value);\n }\n\n function onSuccess(value) {\n if (called) {\n return;\n }\n called = true;\n handlers.resolve(self, value);\n }\n\n function tryToUnwrap() {\n thenable(onSuccess, onError);\n }\n\n var result = tryCatch(tryToUnwrap);\n if (result.status === 'error') {\n onError(result.value);\n }\n}\n\nfunction tryCatch(func, value) {\n var out = {};\n try {\n out.value = func(value);\n out.status = 'success';\n } catch (e) {\n out.status = 'error';\n out.value = e;\n }\n return out;\n}\n\nPromise.resolve = resolve;\nfunction resolve(value) {\n if (value instanceof this) {\n return value;\n }\n return handlers.resolve(new this(INTERNAL), value);\n}\n\nPromise.reject = reject;\nfunction reject(reason) {\n var promise = new this(INTERNAL);\n return handlers.reject(promise, reason);\n}\n\nPromise.all = all;\nfunction all(iterable) {\n var self = this;\n if (Object.prototype.toString.call(iterable) !== '[object Array]') {\n return this.reject(new TypeError('must be an array'));\n }\n\n var len = iterable.length;\n var called = false;\n if (!len) {\n return this.resolve([]);\n }\n\n var values = new Array(len);\n var resolved = 0;\n var i = -1;\n var promise = new this(INTERNAL);\n\n while (++i < len) {\n allResolver(iterable[i], i);\n }\n return promise;\n function allResolver(value, i) {\n self.resolve(value).then(resolveFromAll, function (error) {\n if (!called) {\n called = true;\n handlers.reject(promise, error);\n }\n });\n function resolveFromAll(outValue) {\n values[i] = outValue;\n if (++resolved === len && !called) {\n called = true;\n handlers.resolve(promise, values);\n }\n }\n }\n}\n\nPromise.race = race;\nfunction race(iterable) {\n var self = this;\n if (Object.prototype.toString.call(iterable) !== '[object Array]') {\n return this.reject(new TypeError('must be an array'));\n }\n\n var len = iterable.length;\n var called = false;\n if (!len) {\n return this.resolve([]);\n }\n\n var i = -1;\n var promise = new this(INTERNAL);\n\n while (++i < len) {\n resolver(iterable[i]);\n }\n return promise;\n function resolver(value) {\n self.resolve(value).then(function (response) {\n if (!called) {\n called = true;\n handlers.resolve(promise, response);\n }\n }, function (error) {\n if (!called) {\n called = true;\n handlers.reject(promise, error);\n }\n });\n }\n}\n\n},{\"1\":1}],3:[function(_dereq_,module,exports){\n(function (global){\n'use strict';\nif (typeof global.Promise !== 'function') {\n global.Promise = _dereq_(2);\n}\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"2\":2}],4:[function(_dereq_,module,exports){\n'use strict';\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction getIDB() {\n /* global indexedDB,webkitIndexedDB,mozIndexedDB,OIndexedDB,msIndexedDB */\n try {\n if (typeof indexedDB !== 'undefined') {\n return indexedDB;\n }\n if (typeof webkitIndexedDB !== 'undefined') {\n return webkitIndexedDB;\n }\n if (typeof mozIndexedDB !== 'undefined') {\n return mozIndexedDB;\n }\n if (typeof OIndexedDB !== 'undefined') {\n return OIndexedDB;\n }\n if (typeof msIndexedDB !== 'undefined') {\n return msIndexedDB;\n }\n } catch (e) {\n return;\n }\n}\n\nvar idb = getIDB();\n\nfunction isIndexedDBValid() {\n try {\n // Initialize IndexedDB; fall back to vendor-prefixed versions\n // if needed.\n if (!idb) {\n return false;\n }\n // We mimic PouchDB here;\n //\n // We test for openDatabase because IE Mobile identifies itself\n // as Safari. Oh the lulz...\n var isSafari = typeof openDatabase !== 'undefined' && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform);\n\n var hasFetch = typeof fetch === 'function' && fetch.toString().indexOf('[native code') !== -1;\n\n // Safari <10.1 does not meet our requirements for IDB support (#5572)\n // since Safari 10.1 shipped with fetch, we can use that to detect it\n return (!isSafari || hasFetch) && typeof indexedDB !== 'undefined' &&\n // some outdated implementations of IDB that appear on Samsung\n // and HTC Android devices <4.4 are missing IDBKeyRange\n // See: https://github.com/mozilla/localForage/issues/128\n // See: https://github.com/mozilla/localForage/issues/272\n typeof IDBKeyRange !== 'undefined';\n } catch (e) {\n return false;\n }\n}\n\n// Abstracts constructing a Blob object, so it also works in older\n// browsers that don't support the native Blob constructor. (i.e.\n// old QtWebKit versions, at least).\n// Abstracts constructing a Blob object, so it also works in older\n// browsers that don't support the native Blob constructor. (i.e.\n// old QtWebKit versions, at least).\nfunction createBlob(parts, properties) {\n /* global BlobBuilder,MSBlobBuilder,MozBlobBuilder,WebKitBlobBuilder */\n parts = parts || [];\n properties = properties || {};\n try {\n return new Blob(parts, properties);\n } catch (e) {\n if (e.name !== 'TypeError') {\n throw e;\n }\n var Builder = typeof BlobBuilder !== 'undefined' ? BlobBuilder : typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder : typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : WebKitBlobBuilder;\n var builder = new Builder();\n for (var i = 0; i < parts.length; i += 1) {\n builder.append(parts[i]);\n }\n return builder.getBlob(properties.type);\n }\n}\n\n// This is CommonJS because lie is an external dependency, so Rollup\n// can just ignore it.\nif (typeof Promise === 'undefined') {\n // In the \"nopromises\" build this will just throw if you don't have\n // a global promise object, but it would throw anyway later.\n _dereq_(3);\n}\nvar Promise$1 = Promise;\n\nfunction executeCallback(promise, callback) {\n if (callback) {\n promise.then(function (result) {\n callback(null, result);\n }, function (error) {\n callback(error);\n });\n }\n}\n\nfunction executeTwoCallbacks(promise, callback, errorCallback) {\n if (typeof callback === 'function') {\n promise.then(callback);\n }\n\n if (typeof errorCallback === 'function') {\n promise[\"catch\"](errorCallback);\n }\n}\n\nfunction normalizeKey(key) {\n // Cast the key to a string, as that's all we can set as a key.\n if (typeof key !== 'string') {\n console.warn(key + ' used as a key, but it is not a string.');\n key = String(key);\n }\n\n return key;\n}\n\n// Some code originally from async_storage.js in\n// [Gaia](https://github.com/mozilla-b2g/gaia).\n\nvar DETECT_BLOB_SUPPORT_STORE = 'local-forage-detect-blob-support';\nvar supportsBlobs;\nvar dbContexts;\nvar toString = Object.prototype.toString;\n\n// Transaction Modes\nvar READ_ONLY = 'readonly';\nvar READ_WRITE = 'readwrite';\n\n// Transform a binary string to an array buffer, because otherwise\n// weird stuff happens when you try to work with the binary string directly.\n// It is known.\n// From http://stackoverflow.com/questions/14967647/ (continues on next line)\n// encode-decode-image-with-base64-breaks-image (2013-04-21)\nfunction _binStringToArrayBuffer(bin) {\n var length = bin.length;\n var buf = new ArrayBuffer(length);\n var arr = new Uint8Array(buf);\n for (var i = 0; i < length; i++) {\n arr[i] = bin.charCodeAt(i);\n }\n return buf;\n}\n\n//\n// Blobs are not supported in all versions of IndexedDB, notably\n// Chrome <37 and Android <5. In those versions, storing a blob will throw.\n//\n// Various other blob bugs exist in Chrome v37-42 (inclusive).\n// Detecting them is expensive and confusing to users, and Chrome 37-42\n// is at very low usage worldwide, so we do a hacky userAgent check instead.\n//\n// content-type bug: https://code.google.com/p/chromium/issues/detail?id=408120\n// 404 bug: https://code.google.com/p/chromium/issues/detail?id=447916\n// FileReader bug: https://code.google.com/p/chromium/issues/detail?id=447836\n//\n// Code borrowed from PouchDB. See:\n// https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-adapter-idb/src/blobSupport.js\n//\nfunction _checkBlobSupportWithoutCaching(idb) {\n return new Promise$1(function (resolve) {\n var txn = idb.transaction(DETECT_BLOB_SUPPORT_STORE, READ_WRITE);\n var blob = createBlob(['']);\n txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key');\n\n txn.onabort = function (e) {\n // If the transaction aborts now its due to not being able to\n // write to the database, likely due to the disk being full\n e.preventDefault();\n e.stopPropagation();\n resolve(false);\n };\n\n txn.oncomplete = function () {\n var matchedChrome = navigator.userAgent.match(/Chrome\\/(\\d+)/);\n var matchedEdge = navigator.userAgent.match(/Edge\\//);\n // MS Edge pretends to be Chrome 42:\n // https://msdn.microsoft.com/en-us/library/hh869301%28v=vs.85%29.aspx\n resolve(matchedEdge || !matchedChrome || parseInt(matchedChrome[1], 10) >= 43);\n };\n })[\"catch\"](function () {\n return false; // error, so assume unsupported\n });\n}\n\nfunction _checkBlobSupport(idb) {\n if (typeof supportsBlobs === 'boolean') {\n return Promise$1.resolve(supportsBlobs);\n }\n return _checkBlobSupportWithoutCaching(idb).then(function (value) {\n supportsBlobs = value;\n return supportsBlobs;\n });\n}\n\nfunction _deferReadiness(dbInfo) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Create a deferred object representing the current database operation.\n var deferredOperation = {};\n\n deferredOperation.promise = new Promise$1(function (resolve) {\n deferredOperation.resolve = resolve;\n });\n\n // Enqueue the deferred operation.\n dbContext.deferredOperations.push(deferredOperation);\n\n // Chain its promise to the database readiness.\n if (!dbContext.dbReady) {\n dbContext.dbReady = deferredOperation.promise;\n } else {\n dbContext.dbReady = dbContext.dbReady.then(function () {\n return deferredOperation.promise;\n });\n }\n}\n\nfunction _advanceReadiness(dbInfo) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Dequeue a deferred operation.\n var deferredOperation = dbContext.deferredOperations.pop();\n\n // Resolve its promise (which is part of the database readiness\n // chain of promises).\n if (deferredOperation) {\n deferredOperation.resolve();\n }\n}\n\nfunction _rejectReadiness(dbInfo, err) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Dequeue a deferred operation.\n var deferredOperation = dbContext.deferredOperations.pop();\n\n // Reject its promise (which is part of the database readiness\n // chain of promises).\n if (deferredOperation) {\n deferredOperation.reject(err);\n }\n}\n\nfunction _getConnection(dbInfo, upgradeNeeded) {\n return new Promise$1(function (resolve, reject) {\n\n if (dbInfo.db) {\n if (upgradeNeeded) {\n _deferReadiness(dbInfo);\n dbInfo.db.close();\n } else {\n return resolve(dbInfo.db);\n }\n }\n\n var dbArgs = [dbInfo.name];\n\n if (upgradeNeeded) {\n dbArgs.push(dbInfo.version);\n }\n\n var openreq = idb.open.apply(idb, dbArgs);\n\n if (upgradeNeeded) {\n openreq.onupgradeneeded = function (e) {\n var db = openreq.result;\n try {\n db.createObjectStore(dbInfo.storeName);\n if (e.oldVersion <= 1) {\n // Added when support for blob shims was added\n db.createObjectStore(DETECT_BLOB_SUPPORT_STORE);\n }\n } catch (ex) {\n if (ex.name === 'ConstraintError') {\n console.warn('The database \"' + dbInfo.name + '\"' + ' has been upgraded from version ' + e.oldVersion + ' to version ' + e.newVersion + ', but the storage \"' + dbInfo.storeName + '\" already exists.');\n } else {\n throw ex;\n }\n }\n };\n }\n\n openreq.onerror = function (e) {\n e.preventDefault();\n reject(openreq.error);\n };\n\n openreq.onsuccess = function () {\n resolve(openreq.result);\n _advanceReadiness(dbInfo);\n };\n });\n}\n\nfunction _getOriginalConnection(dbInfo) {\n return _getConnection(dbInfo, false);\n}\n\nfunction _getUpgradedConnection(dbInfo) {\n return _getConnection(dbInfo, true);\n}\n\nfunction _isUpgradeNeeded(dbInfo, defaultVersion) {\n if (!dbInfo.db) {\n return true;\n }\n\n var isNewStore = !dbInfo.db.objectStoreNames.contains(dbInfo.storeName);\n var isDowngrade = dbInfo.version < dbInfo.db.version;\n var isUpgrade = dbInfo.version > dbInfo.db.version;\n\n if (isDowngrade) {\n // If the version is not the default one\n // then warn for impossible downgrade.\n if (dbInfo.version !== defaultVersion) {\n console.warn('The database \"' + dbInfo.name + '\"' + ' can\\'t be downgraded from version ' + dbInfo.db.version + ' to version ' + dbInfo.version + '.');\n }\n // Align the versions to prevent errors.\n dbInfo.version = dbInfo.db.version;\n }\n\n if (isUpgrade || isNewStore) {\n // If the store is new then increment the version (if needed).\n // This will trigger an \"upgradeneeded\" event which is required\n // for creating a store.\n if (isNewStore) {\n var incVersion = dbInfo.db.version + 1;\n if (incVersion > dbInfo.version) {\n dbInfo.version = incVersion;\n }\n }\n\n return true;\n }\n\n return false;\n}\n\n// encode a blob for indexeddb engines that don't support blobs\nfunction _encodeBlob(blob) {\n return new Promise$1(function (resolve, reject) {\n var reader = new FileReader();\n reader.onerror = reject;\n reader.onloadend = function (e) {\n var base64 = btoa(e.target.result || '');\n resolve({\n __local_forage_encoded_blob: true,\n data: base64,\n type: blob.type\n });\n };\n reader.readAsBinaryString(blob);\n });\n}\n\n// decode an encoded blob\nfunction _decodeBlob(encodedBlob) {\n var arrayBuff = _binStringToArrayBuffer(atob(encodedBlob.data));\n return createBlob([arrayBuff], { type: encodedBlob.type });\n}\n\n// is this one of our fancy encoded blobs?\nfunction _isEncodedBlob(value) {\n return value && value.__local_forage_encoded_blob;\n}\n\n// Specialize the default `ready()` function by making it dependent\n// on the current database operations. Thus, the driver will be actually\n// ready when it's been initialized (default) *and* there are no pending\n// operations on the database (initiated by some other instances).\nfunction _fullyReady(callback) {\n var self = this;\n\n var promise = self._initReady().then(function () {\n var dbContext = dbContexts[self._dbInfo.name];\n\n if (dbContext && dbContext.dbReady) {\n return dbContext.dbReady;\n }\n });\n\n executeTwoCallbacks(promise, callback, callback);\n return promise;\n}\n\n// Try to establish a new db connection to replace the\n// current one which is broken (i.e. experiencing\n// InvalidStateError while creating a transaction).\nfunction _tryReconnect(dbInfo) {\n _deferReadiness(dbInfo);\n\n var dbContext = dbContexts[dbInfo.name];\n var forages = dbContext.forages;\n\n for (var i = 0; i < forages.length; i++) {\n if (forages[i]._dbInfo.db) {\n forages[i]._dbInfo.db.close();\n forages[i]._dbInfo.db = null;\n }\n }\n\n return _getConnection(dbInfo, false).then(function (db) {\n for (var j = 0; j < forages.length; j++) {\n forages[j]._dbInfo.db = db;\n }\n })[\"catch\"](function (err) {\n _rejectReadiness(dbInfo, err);\n throw err;\n });\n}\n\n// FF doesn't like Promises (micro-tasks) and IDDB store operations,\n// so we have to do it with callbacks\nfunction createTransaction(dbInfo, mode, callback) {\n try {\n var tx = dbInfo.db.transaction(dbInfo.storeName, mode);\n callback(null, tx);\n } catch (err) {\n if (!dbInfo.db || err.name === 'InvalidStateError') {\n return _tryReconnect(dbInfo).then(function () {\n\n var tx = dbInfo.db.transaction(dbInfo.storeName, mode);\n callback(null, tx);\n });\n }\n\n callback(err);\n }\n}\n\n// Open the IndexedDB database (automatically creates one if one didn't\n// previously exist), using any options set in the config.\nfunction _initStorage(options) {\n var self = this;\n var dbInfo = {\n db: null\n };\n\n if (options) {\n for (var i in options) {\n dbInfo[i] = options[i];\n }\n }\n\n // Initialize a singleton container for all running localForages.\n if (!dbContexts) {\n dbContexts = {};\n }\n\n // Get the current context of the database;\n var dbContext = dbContexts[dbInfo.name];\n\n // ...or create a new context.\n if (!dbContext) {\n dbContext = {\n // Running localForages sharing a database.\n forages: [],\n // Shared database.\n db: null,\n // Database readiness (promise).\n dbReady: null,\n // Deferred operations on the database.\n deferredOperations: []\n };\n // Register the new context in the global container.\n dbContexts[dbInfo.name] = dbContext;\n }\n\n // Register itself as a running localForage in the current context.\n dbContext.forages.push(self);\n\n // Replace the default `ready()` function with the specialized one.\n if (!self._initReady) {\n self._initReady = self.ready;\n self.ready = _fullyReady;\n }\n\n // Create an array of initialization states of the related localForages.\n var initPromises = [];\n\n function ignoreErrors() {\n // Don't handle errors here,\n // just makes sure related localForages aren't pending.\n return Promise$1.resolve();\n }\n\n for (var j = 0; j < dbContext.forages.length; j++) {\n var forage = dbContext.forages[j];\n if (forage !== self) {\n // Don't wait for itself...\n initPromises.push(forage._initReady()[\"catch\"](ignoreErrors));\n }\n }\n\n // Take a snapshot of the related localForages.\n var forages = dbContext.forages.slice(0);\n\n // Initialize the connection process only when\n // all the related localForages aren't pending.\n return Promise$1.all(initPromises).then(function () {\n dbInfo.db = dbContext.db;\n // Get the connection or open a new one without upgrade.\n return _getOriginalConnection(dbInfo);\n }).then(function (db) {\n dbInfo.db = db;\n if (_isUpgradeNeeded(dbInfo, self._defaultConfig.version)) {\n // Reopen the database for upgrading.\n return _getUpgradedConnection(dbInfo);\n }\n return db;\n }).then(function (db) {\n dbInfo.db = dbContext.db = db;\n self._dbInfo = dbInfo;\n // Share the final connection amongst related localForages.\n for (var k = 0; k < forages.length; k++) {\n var forage = forages[k];\n if (forage !== self) {\n // Self is already up-to-date.\n forage._dbInfo.db = dbInfo.db;\n forage._dbInfo.version = dbInfo.version;\n }\n }\n });\n}\n\nfunction getItem(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.get(key);\n\n req.onsuccess = function () {\n var value = req.result;\n if (value === undefined) {\n value = null;\n }\n if (_isEncodedBlob(value)) {\n value = _decodeBlob(value);\n }\n resolve(value);\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Iterate over all items stored in database.\nfunction iterate(iterator, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.openCursor();\n var iterationNumber = 1;\n\n req.onsuccess = function () {\n var cursor = req.result;\n\n if (cursor) {\n var value = cursor.value;\n if (_isEncodedBlob(value)) {\n value = _decodeBlob(value);\n }\n var result = iterator(value, cursor.key, iterationNumber++);\n\n // when the iterator callback retuns any\n // (non-`undefined`) value, then we stop\n // the iteration immediately\n if (result !== void 0) {\n resolve(result);\n } else {\n cursor[\"continue\"]();\n }\n } else {\n resolve();\n }\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n\n return promise;\n}\n\nfunction setItem(key, value, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n var dbInfo;\n self.ready().then(function () {\n dbInfo = self._dbInfo;\n if (toString.call(value) === '[object Blob]') {\n return _checkBlobSupport(dbInfo.db).then(function (blobSupport) {\n if (blobSupport) {\n return value;\n }\n return _encodeBlob(value);\n });\n }\n return value;\n }).then(function (value) {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n\n // The reason we don't _save_ null is because IE 10 does\n // not support saving the `null` type in IndexedDB. How\n // ironic, given the bug below!\n // See: https://github.com/mozilla/localForage/issues/161\n if (value === null) {\n value = undefined;\n }\n\n var req = store.put(value, key);\n\n transaction.oncomplete = function () {\n // Cast to undefined so the value passed to\n // callback/promise is the same as what one would get out\n // of `getItem()` later. This leads to some weirdness\n // (setItem('foo', undefined) will return `null`), but\n // it's not my fault localStorage is our baseline and that\n // it's weird.\n if (value === undefined) {\n value = null;\n }\n\n resolve(value);\n };\n transaction.onabort = transaction.onerror = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction removeItem(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n // We use a Grunt task to make this safe for IE and some\n // versions of Android (including those used by Cordova).\n // Normally IE won't like `.delete()` and will insist on\n // using `['delete']()`, but we have a build step that\n // fixes this for us now.\n var req = store[\"delete\"](key);\n transaction.oncomplete = function () {\n resolve();\n };\n\n transaction.onerror = function () {\n reject(req.error);\n };\n\n // The request will be also be aborted if we've exceeded our storage\n // space.\n transaction.onabort = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction clear(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.clear();\n\n transaction.oncomplete = function () {\n resolve();\n };\n\n transaction.onabort = transaction.onerror = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction length(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.count();\n\n req.onsuccess = function () {\n resolve(req.result);\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction key(n, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n if (n < 0) {\n resolve(null);\n\n return;\n }\n\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var advanced = false;\n var req = store.openCursor();\n\n req.onsuccess = function () {\n var cursor = req.result;\n if (!cursor) {\n // this means there weren't enough keys\n resolve(null);\n\n return;\n }\n\n if (n === 0) {\n // We have the first key, return it if that's what they\n // wanted.\n resolve(cursor.key);\n } else {\n if (!advanced) {\n // Otherwise, ask the cursor to skip ahead n\n // records.\n advanced = true;\n cursor.advance(n);\n } else {\n // When we get here, we've got the nth key.\n resolve(cursor.key);\n }\n }\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.openCursor();\n var keys = [];\n\n req.onsuccess = function () {\n var cursor = req.result;\n\n if (!cursor) {\n resolve(keys);\n return;\n }\n\n keys.push(cursor.key);\n cursor[\"continue\"]();\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar asyncStorage = {\n _driver: 'asyncStorage',\n _initStorage: _initStorage,\n _support: isIndexedDBValid(),\n iterate: iterate,\n getItem: getItem,\n setItem: setItem,\n removeItem: removeItem,\n clear: clear,\n length: length,\n key: key,\n keys: keys\n};\n\nfunction isWebSQLValid() {\n return typeof openDatabase === 'function';\n}\n\n// Sadly, the best way to save binary data in WebSQL/localStorage is serializing\n// it to Base64, so this is how we store it to prevent very strange errors with less\n// verbose ways of binary <-> string data storage.\nvar BASE_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\nvar BLOB_TYPE_PREFIX = '~~local_forage_type~';\nvar BLOB_TYPE_PREFIX_REGEX = /^~~local_forage_type~([^~]+)~/;\n\nvar SERIALIZED_MARKER = '__lfsc__:';\nvar SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER.length;\n\n// OMG the serializations!\nvar TYPE_ARRAYBUFFER = 'arbf';\nvar TYPE_BLOB = 'blob';\nvar TYPE_INT8ARRAY = 'si08';\nvar TYPE_UINT8ARRAY = 'ui08';\nvar TYPE_UINT8CLAMPEDARRAY = 'uic8';\nvar TYPE_INT16ARRAY = 'si16';\nvar TYPE_INT32ARRAY = 'si32';\nvar TYPE_UINT16ARRAY = 'ur16';\nvar TYPE_UINT32ARRAY = 'ui32';\nvar TYPE_FLOAT32ARRAY = 'fl32';\nvar TYPE_FLOAT64ARRAY = 'fl64';\nvar TYPE_SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER_LENGTH + TYPE_ARRAYBUFFER.length;\n\nvar toString$1 = Object.prototype.toString;\n\nfunction stringToBuffer(serializedString) {\n // Fill the string into a ArrayBuffer.\n var bufferLength = serializedString.length * 0.75;\n var len = serializedString.length;\n var i;\n var p = 0;\n var encoded1, encoded2, encoded3, encoded4;\n\n if (serializedString[serializedString.length - 1] === '=') {\n bufferLength--;\n if (serializedString[serializedString.length - 2] === '=') {\n bufferLength--;\n }\n }\n\n var buffer = new ArrayBuffer(bufferLength);\n var bytes = new Uint8Array(buffer);\n\n for (i = 0; i < len; i += 4) {\n encoded1 = BASE_CHARS.indexOf(serializedString[i]);\n encoded2 = BASE_CHARS.indexOf(serializedString[i + 1]);\n encoded3 = BASE_CHARS.indexOf(serializedString[i + 2]);\n encoded4 = BASE_CHARS.indexOf(serializedString[i + 3]);\n\n /*jslint bitwise: true */\n bytes[p++] = encoded1 << 2 | encoded2 >> 4;\n bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;\n bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;\n }\n return buffer;\n}\n\n// Converts a buffer to a string to store, serialized, in the backend\n// storage library.\nfunction bufferToString(buffer) {\n // base64-arraybuffer\n var bytes = new Uint8Array(buffer);\n var base64String = '';\n var i;\n\n for (i = 0; i < bytes.length; i += 3) {\n /*jslint bitwise: true */\n base64String += BASE_CHARS[bytes[i] >> 2];\n base64String += BASE_CHARS[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];\n base64String += BASE_CHARS[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];\n base64String += BASE_CHARS[bytes[i + 2] & 63];\n }\n\n if (bytes.length % 3 === 2) {\n base64String = base64String.substring(0, base64String.length - 1) + '=';\n } else if (bytes.length % 3 === 1) {\n base64String = base64String.substring(0, base64String.length - 2) + '==';\n }\n\n return base64String;\n}\n\n// Serialize a value, afterwards executing a callback (which usually\n// instructs the `setItem()` callback/promise to be executed). This is how\n// we store binary data with localStorage.\nfunction serialize(value, callback) {\n var valueType = '';\n if (value) {\n valueType = toString$1.call(value);\n }\n\n // Cannot use `value instanceof ArrayBuffer` or such here, as these\n // checks fail when running the tests using casper.js...\n //\n // TODO: See why those tests fail and use a better solution.\n if (value && (valueType === '[object ArrayBuffer]' || value.buffer && toString$1.call(value.buffer) === '[object ArrayBuffer]')) {\n // Convert binary arrays to a string and prefix the string with\n // a special marker.\n var buffer;\n var marker = SERIALIZED_MARKER;\n\n if (value instanceof ArrayBuffer) {\n buffer = value;\n marker += TYPE_ARRAYBUFFER;\n } else {\n buffer = value.buffer;\n\n if (valueType === '[object Int8Array]') {\n marker += TYPE_INT8ARRAY;\n } else if (valueType === '[object Uint8Array]') {\n marker += TYPE_UINT8ARRAY;\n } else if (valueType === '[object Uint8ClampedArray]') {\n marker += TYPE_UINT8CLAMPEDARRAY;\n } else if (valueType === '[object Int16Array]') {\n marker += TYPE_INT16ARRAY;\n } else if (valueType === '[object Uint16Array]') {\n marker += TYPE_UINT16ARRAY;\n } else if (valueType === '[object Int32Array]') {\n marker += TYPE_INT32ARRAY;\n } else if (valueType === '[object Uint32Array]') {\n marker += TYPE_UINT32ARRAY;\n } else if (valueType === '[object Float32Array]') {\n marker += TYPE_FLOAT32ARRAY;\n } else if (valueType === '[object Float64Array]') {\n marker += TYPE_FLOAT64ARRAY;\n } else {\n callback(new Error('Failed to get type for BinaryArray'));\n }\n }\n\n callback(marker + bufferToString(buffer));\n } else if (valueType === '[object Blob]') {\n // Conver the blob to a binaryArray and then to a string.\n var fileReader = new FileReader();\n\n fileReader.onload = function () {\n // Backwards-compatible prefix for the blob type.\n var str = BLOB_TYPE_PREFIX + value.type + '~' + bufferToString(this.result);\n\n callback(SERIALIZED_MARKER + TYPE_BLOB + str);\n };\n\n fileReader.readAsArrayBuffer(value);\n } else {\n try {\n callback(JSON.stringify(value));\n } catch (e) {\n console.error(\"Couldn't convert value into a JSON string: \", value);\n\n callback(null, e);\n }\n }\n}\n\n// Deserialize data we've inserted into a value column/field. We place\n// special markers into our strings to mark them as encoded; this isn't\n// as nice as a meta field, but it's the only sane thing we can do whilst\n// keeping localStorage support intact.\n//\n// Oftentimes this will just deserialize JSON content, but if we have a\n// special marker (SERIALIZED_MARKER, defined above), we will extract\n// some kind of arraybuffer/binary data/typed array out of the string.\nfunction deserialize(value) {\n // If we haven't marked this string as being specially serialized (i.e.\n // something other than serialized JSON), we can just return it and be\n // done with it.\n if (value.substring(0, SERIALIZED_MARKER_LENGTH) !== SERIALIZED_MARKER) {\n return JSON.parse(value);\n }\n\n // The following code deals with deserializing some kind of Blob or\n // TypedArray. First we separate out the type of data we're dealing\n // with from the data itself.\n var serializedString = value.substring(TYPE_SERIALIZED_MARKER_LENGTH);\n var type = value.substring(SERIALIZED_MARKER_LENGTH, TYPE_SERIALIZED_MARKER_LENGTH);\n\n var blobType;\n // Backwards-compatible blob type serialization strategy.\n // DBs created with older versions of localForage will simply not have the blob type.\n if (type === TYPE_BLOB && BLOB_TYPE_PREFIX_REGEX.test(serializedString)) {\n var matcher = serializedString.match(BLOB_TYPE_PREFIX_REGEX);\n blobType = matcher[1];\n serializedString = serializedString.substring(matcher[0].length);\n }\n var buffer = stringToBuffer(serializedString);\n\n // Return the right type based on the code/type set during\n // serialization.\n switch (type) {\n case TYPE_ARRAYBUFFER:\n return buffer;\n case TYPE_BLOB:\n return createBlob([buffer], { type: blobType });\n case TYPE_INT8ARRAY:\n return new Int8Array(buffer);\n case TYPE_UINT8ARRAY:\n return new Uint8Array(buffer);\n case TYPE_UINT8CLAMPEDARRAY:\n return new Uint8ClampedArray(buffer);\n case TYPE_INT16ARRAY:\n return new Int16Array(buffer);\n case TYPE_UINT16ARRAY:\n return new Uint16Array(buffer);\n case TYPE_INT32ARRAY:\n return new Int32Array(buffer);\n case TYPE_UINT32ARRAY:\n return new Uint32Array(buffer);\n case TYPE_FLOAT32ARRAY:\n return new Float32Array(buffer);\n case TYPE_FLOAT64ARRAY:\n return new Float64Array(buffer);\n default:\n throw new Error('Unkown type: ' + type);\n }\n}\n\nvar localforageSerializer = {\n serialize: serialize,\n deserialize: deserialize,\n stringToBuffer: stringToBuffer,\n bufferToString: bufferToString\n};\n\n/*\n * Includes code from:\n *\n * base64-arraybuffer\n * https://github.com/niklasvh/base64-arraybuffer\n *\n * Copyright (c) 2012 Niklas von Hertzen\n * Licensed under the MIT license.\n */\n// Open the WebSQL database (automatically creates one if one didn't\n// previously exist), using any options set in the config.\nfunction _initStorage$1(options) {\n var self = this;\n var dbInfo = {\n db: null\n };\n\n if (options) {\n for (var i in options) {\n dbInfo[i] = typeof options[i] !== 'string' ? options[i].toString() : options[i];\n }\n }\n\n var dbInfoPromise = new Promise$1(function (resolve, reject) {\n // Open the database; the openDatabase API will automatically\n // create it for us if it doesn't exist.\n try {\n dbInfo.db = openDatabase(dbInfo.name, String(dbInfo.version), dbInfo.description, dbInfo.size);\n } catch (e) {\n return reject(e);\n }\n\n // Create our key/value table if it doesn't exist.\n dbInfo.db.transaction(function (t) {\n t.executeSql('CREATE TABLE IF NOT EXISTS ' + dbInfo.storeName + ' (id INTEGER PRIMARY KEY, key unique, value)', [], function () {\n self._dbInfo = dbInfo;\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n });\n\n dbInfo.serializer = localforageSerializer;\n return dbInfoPromise;\n}\n\nfunction getItem$1(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE key = ? LIMIT 1', [key], function (t, results) {\n var result = results.rows.length ? results.rows.item(0).value : null;\n\n // Check to see if this is serialized content we need to\n // unpack.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n resolve(result);\n }, function (t, error) {\n\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction iterate$1(iterator, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT * FROM ' + dbInfo.storeName, [], function (t, results) {\n var rows = results.rows;\n var length = rows.length;\n\n for (var i = 0; i < length; i++) {\n var item = rows.item(i);\n var result = item.value;\n\n // Check to see if this is serialized content\n // we need to unpack.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n result = iterator(result, item.key, i + 1);\n\n // void(0) prevents problems with redefinition\n // of `undefined`.\n if (result !== void 0) {\n resolve(result);\n return;\n }\n }\n\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction _setItem(key, value, callback, retriesLeft) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n // The localStorage API doesn't return undefined values in an\n // \"expected\" way, so undefined is always cast to null in all\n // drivers. See: https://github.com/mozilla/localForage/pull/42\n if (value === undefined) {\n value = null;\n }\n\n // Save the original value to pass to the callback.\n var originalValue = value;\n\n var dbInfo = self._dbInfo;\n dbInfo.serializer.serialize(value, function (value, error) {\n if (error) {\n reject(error);\n } else {\n dbInfo.db.transaction(function (t) {\n t.executeSql('INSERT OR REPLACE INTO ' + dbInfo.storeName + ' (key, value) VALUES (?, ?)', [key, value], function () {\n resolve(originalValue);\n }, function (t, error) {\n reject(error);\n });\n }, function (sqlError) {\n // The transaction failed; check\n // to see if it's a quota error.\n if (sqlError.code === sqlError.QUOTA_ERR) {\n // We reject the callback outright for now, but\n // it's worth trying to re-run the transaction.\n // Even if the user accepts the prompt to use\n // more storage on Safari, this error will\n // be called.\n //\n // Try to re-run the transaction.\n if (retriesLeft > 0) {\n resolve(_setItem.apply(self, [key, originalValue, callback, retriesLeft - 1]));\n return;\n }\n reject(sqlError);\n }\n });\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction setItem$1(key, value, callback) {\n return _setItem.apply(this, [key, value, callback, 1]);\n}\n\nfunction removeItem$1(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('DELETE FROM ' + dbInfo.storeName + ' WHERE key = ?', [key], function () {\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Deletes every item in the table.\n// TODO: Find out if this resets the AUTO_INCREMENT number.\nfunction clear$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('DELETE FROM ' + dbInfo.storeName, [], function () {\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Does a simple `COUNT(key)` to get the number of items stored in\n// localForage.\nfunction length$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n // Ahhh, SQL makes this one soooooo easy.\n t.executeSql('SELECT COUNT(key) as c FROM ' + dbInfo.storeName, [], function (t, results) {\n var result = results.rows.item(0).c;\n\n resolve(result);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Return the key located at key index X; essentially gets the key from a\n// `WHERE id = ?`. This is the most efficient way I can think to implement\n// this rarely-used (in my experience) part of the API, but it can seem\n// inconsistent, because we do `INSERT OR REPLACE INTO` on `setItem()`, so\n// the ID of each key will change every time it's updated. Perhaps a stored\n// procedure for the `setItem()` SQL would solve this problem?\n// TODO: Don't change ID on `setItem()`.\nfunction key$1(n, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT key FROM ' + dbInfo.storeName + ' WHERE id = ? LIMIT 1', [n + 1], function (t, results) {\n var result = results.rows.length ? results.rows.item(0).key : null;\n resolve(result);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT key FROM ' + dbInfo.storeName, [], function (t, results) {\n var keys = [];\n\n for (var i = 0; i < results.rows.length; i++) {\n keys.push(results.rows.item(i).key);\n }\n\n resolve(keys);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar webSQLStorage = {\n _driver: 'webSQLStorage',\n _initStorage: _initStorage$1,\n _support: isWebSQLValid(),\n iterate: iterate$1,\n getItem: getItem$1,\n setItem: setItem$1,\n removeItem: removeItem$1,\n clear: clear$1,\n length: length$1,\n key: key$1,\n keys: keys$1\n};\n\nfunction isLocalStorageValid() {\n try {\n return typeof localStorage !== 'undefined' && 'setItem' in localStorage && typeof localStorage.setItem === 'function';\n } catch (e) {\n return false;\n }\n}\n\n// Check if localStorage throws when saving an item\nfunction checkIfLocalStorageThrows() {\n var localStorageTestKey = '_localforage_support_test';\n\n try {\n localStorage.setItem(localStorageTestKey, true);\n localStorage.removeItem(localStorageTestKey);\n\n return false;\n } catch (e) {\n return true;\n }\n}\n\n// Check if localStorage is usable and allows to save an item\n// This method checks if localStorage is usable in Safari Private Browsing\n// mode, or in any other case where the available quota for localStorage\n// is 0 and there wasn't any saved items yet.\nfunction _isLocalStorageUsable() {\n return !checkIfLocalStorageThrows() || localStorage.length > 0;\n}\n\n// Config the localStorage backend, using options set in the config.\nfunction _initStorage$2(options) {\n var self = this;\n var dbInfo = {};\n if (options) {\n for (var i in options) {\n dbInfo[i] = options[i];\n }\n }\n\n dbInfo.keyPrefix = dbInfo.name + '/';\n\n if (dbInfo.storeName !== self._defaultConfig.storeName) {\n dbInfo.keyPrefix += dbInfo.storeName + '/';\n }\n\n if (!_isLocalStorageUsable()) {\n return Promise$1.reject();\n }\n\n self._dbInfo = dbInfo;\n dbInfo.serializer = localforageSerializer;\n\n return Promise$1.resolve();\n}\n\n// Remove all keys from the datastore, effectively destroying all data in\n// the app's key/value store!\nfunction clear$2(callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var keyPrefix = self._dbInfo.keyPrefix;\n\n for (var i = localStorage.length - 1; i >= 0; i--) {\n var key = localStorage.key(i);\n\n if (key.indexOf(keyPrefix) === 0) {\n localStorage.removeItem(key);\n }\n }\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Retrieve an item from the store. Unlike the original async_storage\n// library in Gaia, we don't modify return values at all. If a key's value\n// is `undefined`, we pass that value to the callback function.\nfunction getItem$2(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var result = localStorage.getItem(dbInfo.keyPrefix + key);\n\n // If a result was found, parse it from the serialized\n // string into a JS object. If result isn't truthy, the key\n // is likely undefined and we'll pass it straight to the\n // callback.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n return result;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Iterate over all items in the store.\nfunction iterate$2(iterator, callback) {\n var self = this;\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var keyPrefix = dbInfo.keyPrefix;\n var keyPrefixLength = keyPrefix.length;\n var length = localStorage.length;\n\n // We use a dedicated iterator instead of the `i` variable below\n // so other keys we fetch in localStorage aren't counted in\n // the `iterationNumber` argument passed to the `iterate()`\n // callback.\n //\n // See: github.com/mozilla/localForage/pull/435#discussion_r38061530\n var iterationNumber = 1;\n\n for (var i = 0; i < length; i++) {\n var key = localStorage.key(i);\n if (key.indexOf(keyPrefix) !== 0) {\n continue;\n }\n var value = localStorage.getItem(key);\n\n // If a result was found, parse it from the serialized\n // string into a JS object. If result isn't truthy, the\n // key is likely undefined and we'll pass it straight\n // to the iterator.\n if (value) {\n value = dbInfo.serializer.deserialize(value);\n }\n\n value = iterator(value, key.substring(keyPrefixLength), iterationNumber++);\n\n if (value !== void 0) {\n return value;\n }\n }\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Same as localStorage's key() method, except takes a callback.\nfunction key$2(n, callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var result;\n try {\n result = localStorage.key(n);\n } catch (error) {\n result = null;\n }\n\n // Remove the prefix from the key, if a key is found.\n if (result) {\n result = result.substring(dbInfo.keyPrefix.length);\n }\n\n return result;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys$2(callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var length = localStorage.length;\n var keys = [];\n\n for (var i = 0; i < length; i++) {\n var itemKey = localStorage.key(i);\n if (itemKey.indexOf(dbInfo.keyPrefix) === 0) {\n keys.push(itemKey.substring(dbInfo.keyPrefix.length));\n }\n }\n\n return keys;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Supply the number of keys in the datastore to the callback function.\nfunction length$2(callback) {\n var self = this;\n var promise = self.keys().then(function (keys) {\n return keys.length;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Remove an item from the store, nice and simple.\nfunction removeItem$2(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n localStorage.removeItem(dbInfo.keyPrefix + key);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Set a key's value and run an optional callback once the value is set.\n// Unlike Gaia's implementation, the callback function is passed the value,\n// in case you want to operate on that value only after you're sure it\n// saved, or something like that.\nfunction setItem$2(key, value, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n // Convert undefined values to null.\n // https://github.com/mozilla/localForage/pull/42\n if (value === undefined) {\n value = null;\n }\n\n // Save the original value to pass to the callback.\n var originalValue = value;\n\n return new Promise$1(function (resolve, reject) {\n var dbInfo = self._dbInfo;\n dbInfo.serializer.serialize(value, function (value, error) {\n if (error) {\n reject(error);\n } else {\n try {\n localStorage.setItem(dbInfo.keyPrefix + key, value);\n resolve(originalValue);\n } catch (e) {\n // localStorage capacity exceeded.\n // TODO: Make this a specific error/event.\n if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {\n reject(e);\n }\n reject(e);\n }\n }\n });\n });\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar localStorageWrapper = {\n _driver: 'localStorageWrapper',\n _initStorage: _initStorage$2,\n _support: isLocalStorageValid(),\n iterate: iterate$2,\n getItem: getItem$2,\n setItem: setItem$2,\n removeItem: removeItem$2,\n clear: clear$2,\n length: length$2,\n key: key$2,\n keys: keys$2\n};\n\nvar isArray = Array.isArray || function (arg) {\n return Object.prototype.toString.call(arg) === '[object Array]';\n};\n\n// Drivers are stored here when `defineDriver()` is called.\n// They are shared across all instances of localForage.\nvar DefinedDrivers = {};\n\nvar DriverSupport = {};\n\nvar DefaultDrivers = {\n INDEXEDDB: asyncStorage,\n WEBSQL: webSQLStorage,\n LOCALSTORAGE: localStorageWrapper\n};\n\nvar DefaultDriverOrder = [DefaultDrivers.INDEXEDDB._driver, DefaultDrivers.WEBSQL._driver, DefaultDrivers.LOCALSTORAGE._driver];\n\nvar LibraryMethods = ['clear', 'getItem', 'iterate', 'key', 'keys', 'length', 'removeItem', 'setItem'];\n\nvar DefaultConfig = {\n description: '',\n driver: DefaultDriverOrder.slice(),\n name: 'localforage',\n // Default DB size is _JUST UNDER_ 5MB, as it's the highest size\n // we can use without a prompt.\n size: 4980736,\n storeName: 'keyvaluepairs',\n version: 1.0\n};\n\nfunction callWhenReady(localForageInstance, libraryMethod) {\n localForageInstance[libraryMethod] = function () {\n var _args = arguments;\n return localForageInstance.ready().then(function () {\n return localForageInstance[libraryMethod].apply(localForageInstance, _args);\n });\n };\n}\n\nfunction extend() {\n for (var i = 1; i < arguments.length; i++) {\n var arg = arguments[i];\n\n if (arg) {\n for (var _key in arg) {\n if (arg.hasOwnProperty(_key)) {\n if (isArray(arg[_key])) {\n arguments[0][_key] = arg[_key].slice();\n } else {\n arguments[0][_key] = arg[_key];\n }\n }\n }\n }\n }\n\n return arguments[0];\n}\n\nvar LocalForage = function () {\n function LocalForage(options) {\n _classCallCheck(this, LocalForage);\n\n for (var driverTypeKey in DefaultDrivers) {\n if (DefaultDrivers.hasOwnProperty(driverTypeKey)) {\n var driver = DefaultDrivers[driverTypeKey];\n var driverName = driver._driver;\n this[driverTypeKey] = driverName;\n\n if (!DefinedDrivers[driverName]) {\n // we don't need to wait for the promise,\n // since the default drivers can be defined\n // in a blocking manner\n this.defineDriver(driver);\n }\n }\n }\n\n this._defaultConfig = extend({}, DefaultConfig);\n this._config = extend({}, this._defaultConfig, options);\n this._driverSet = null;\n this._initDriver = null;\n this._ready = false;\n this._dbInfo = null;\n\n this._wrapLibraryMethodsWithReady();\n this.setDriver(this._config.driver)[\"catch\"](function () {});\n }\n\n // Set any config values for localForage; can be called anytime before\n // the first API call (e.g. `getItem`, `setItem`).\n // We loop through options so we don't overwrite existing config\n // values.\n\n\n LocalForage.prototype.config = function config(options) {\n // If the options argument is an object, we use it to set values.\n // Otherwise, we return either a specified config value or all\n // config values.\n if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object') {\n // If localforage is ready and fully initialized, we can't set\n // any new configuration values. Instead, we return an error.\n if (this._ready) {\n return new Error('Can\\'t call config() after localforage ' + 'has been used.');\n }\n\n for (var i in options) {\n if (i === 'storeName') {\n options[i] = options[i].replace(/\\W/g, '_');\n }\n\n if (i === 'version' && typeof options[i] !== 'number') {\n return new Error('Database version must be a number.');\n }\n\n this._config[i] = options[i];\n }\n\n // after all config options are set and\n // the driver option is used, try setting it\n if ('driver' in options && options.driver) {\n return this.setDriver(this._config.driver);\n }\n\n return true;\n } else if (typeof options === 'string') {\n return this._config[options];\n } else {\n return this._config;\n }\n };\n\n // Used to define a custom driver, shared across all instances of\n // localForage.\n\n\n LocalForage.prototype.defineDriver = function defineDriver(driverObject, callback, errorCallback) {\n var promise = new Promise$1(function (resolve, reject) {\n try {\n var driverName = driverObject._driver;\n var complianceError = new Error('Custom driver not compliant; see ' + 'https://mozilla.github.io/localForage/#definedriver');\n\n // A driver name should be defined and not overlap with the\n // library-defined, default drivers.\n if (!driverObject._driver) {\n reject(complianceError);\n return;\n }\n\n var driverMethods = LibraryMethods.concat('_initStorage');\n for (var i = 0, len = driverMethods.length; i < len; i++) {\n var customDriverMethod = driverMethods[i];\n if (!customDriverMethod || !driverObject[customDriverMethod] || typeof driverObject[customDriverMethod] !== 'function') {\n reject(complianceError);\n return;\n }\n }\n\n var setDriverSupport = function setDriverSupport(support) {\n if (DefinedDrivers[driverName]) {\n console.info('Redefining LocalForage driver: ' + driverName);\n }\n DefinedDrivers[driverName] = driverObject;\n DriverSupport[driverName] = support;\n // don't use a then, so that we can define\n // drivers that have simple _support methods\n // in a blocking manner\n resolve();\n };\n\n if ('_support' in driverObject) {\n if (driverObject._support && typeof driverObject._support === 'function') {\n driverObject._support().then(setDriverSupport, reject);\n } else {\n setDriverSupport(!!driverObject._support);\n }\n } else {\n setDriverSupport(true);\n }\n } catch (e) {\n reject(e);\n }\n });\n\n executeTwoCallbacks(promise, callback, errorCallback);\n return promise;\n };\n\n LocalForage.prototype.driver = function driver() {\n return this._driver || null;\n };\n\n LocalForage.prototype.getDriver = function getDriver(driverName, callback, errorCallback) {\n var getDriverPromise = DefinedDrivers[driverName] ? Promise$1.resolve(DefinedDrivers[driverName]) : Promise$1.reject(new Error('Driver not found.'));\n\n executeTwoCallbacks(getDriverPromise, callback, errorCallback);\n return getDriverPromise;\n };\n\n LocalForage.prototype.getSerializer = function getSerializer(callback) {\n var serializerPromise = Promise$1.resolve(localforageSerializer);\n executeTwoCallbacks(serializerPromise, callback);\n return serializerPromise;\n };\n\n LocalForage.prototype.ready = function ready(callback) {\n var self = this;\n\n var promise = self._driverSet.then(function () {\n if (self._ready === null) {\n self._ready = self._initDriver();\n }\n\n return self._ready;\n });\n\n executeTwoCallbacks(promise, callback, callback);\n return promise;\n };\n\n LocalForage.prototype.setDriver = function setDriver(drivers, callback, errorCallback) {\n var self = this;\n\n if (!isArray(drivers)) {\n drivers = [drivers];\n }\n\n var supportedDrivers = this._getSupportedDrivers(drivers);\n\n function setDriverToConfig() {\n self._config.driver = self.driver();\n }\n\n function extendSelfWithDriver(driver) {\n self._extend(driver);\n setDriverToConfig();\n\n self._ready = self._initStorage(self._config);\n return self._ready;\n }\n\n function initDriver(supportedDrivers) {\n return function () {\n var currentDriverIndex = 0;\n\n function driverPromiseLoop() {\n while (currentDriverIndex < supportedDrivers.length) {\n var driverName = supportedDrivers[currentDriverIndex];\n currentDriverIndex++;\n\n self._dbInfo = null;\n self._ready = null;\n\n return self.getDriver(driverName).then(extendSelfWithDriver)[\"catch\"](driverPromiseLoop);\n }\n\n setDriverToConfig();\n var error = new Error('No available storage method found.');\n self._driverSet = Promise$1.reject(error);\n return self._driverSet;\n }\n\n return driverPromiseLoop();\n };\n }\n\n // There might be a driver initialization in progress\n // so wait for it to finish in order to avoid a possible\n // race condition to set _dbInfo\n var oldDriverSetDone = this._driverSet !== null ? this._driverSet[\"catch\"](function () {\n return Promise$1.resolve();\n }) : Promise$1.resolve();\n\n this._driverSet = oldDriverSetDone.then(function () {\n var driverName = supportedDrivers[0];\n self._dbInfo = null;\n self._ready = null;\n\n return self.getDriver(driverName).then(function (driver) {\n self._driver = driver._driver;\n setDriverToConfig();\n self._wrapLibraryMethodsWithReady();\n self._initDriver = initDriver(supportedDrivers);\n });\n })[\"catch\"](function () {\n setDriverToConfig();\n var error = new Error('No available storage method found.');\n self._driverSet = Promise$1.reject(error);\n return self._driverSet;\n });\n\n executeTwoCallbacks(this._driverSet, callback, errorCallback);\n return this._driverSet;\n };\n\n LocalForage.prototype.supports = function supports(driverName) {\n return !!DriverSupport[driverName];\n };\n\n LocalForage.prototype._extend = function _extend(libraryMethodsAndProperties) {\n extend(this, libraryMethodsAndProperties);\n };\n\n LocalForage.prototype._getSupportedDrivers = function _getSupportedDrivers(drivers) {\n var supportedDrivers = [];\n for (var i = 0, len = drivers.length; i < len; i++) {\n var driverName = drivers[i];\n if (this.supports(driverName)) {\n supportedDrivers.push(driverName);\n }\n }\n return supportedDrivers;\n };\n\n LocalForage.prototype._wrapLibraryMethodsWithReady = function _wrapLibraryMethodsWithReady() {\n // Add a stub for each driver API method that delays the call to the\n // corresponding driver method until localForage is ready. These stubs\n // will be replaced by the driver methods as soon as the driver is\n // loaded, so there is no performance impact.\n for (var i = 0, len = LibraryMethods.length; i < len; i++) {\n callWhenReady(this, LibraryMethods[i]);\n }\n };\n\n LocalForage.prototype.createInstance = function createInstance(options) {\n return new LocalForage(options);\n };\n\n return LocalForage;\n}();\n\n// The actual localForage object that we expose as a module or via a\n// global. It's extended by pulling in one of our other libraries.\n\n\nvar localforage_js = new LocalForage();\n\nmodule.exports = localforage_js;\n\n},{\"3\":3}]},{},[4])(4)\n});\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/localforage/dist/localforage.js\n// module id = 3\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar weight_decoder_eightbit_1 = require(\"./weight_decoder_eightbit\");\nvar weight_decoder_raw_1 = require(\"./weight_decoder_raw\");\n/**\n * @protected\n */\nfunction getWeightDecoder(name) {\n switch (name) {\n case 'raw':\n return new weight_decoder_raw_1.default();\n case 'eightbit':\n return new weight_decoder_eightbit_1.default();\n default:\n throw new Error('Unknown weight encoding');\n }\n}\nexports.default = getWeightDecoder;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/get_weight_decoder.js\n// module id = 4\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * PlaceholderContext manages the placeholders\n * @protected\n */\nvar PlaceholderContext = /** @class */ (function () {\n function PlaceholderContext(values) {\n this.values = {};\n if (values) {\n this.update(values);\n }\n }\n Object.defineProperty(PlaceholderContext.prototype, \"isResolved\", {\n get: function () {\n return Object.values(this.values).every(function (value) { return typeof value == 'number'; });\n },\n enumerable: true,\n configurable: true\n });\n PlaceholderContext.prototype.update = function (values) {\n this.values = Object.assign(this.values, values);\n };\n PlaceholderContext.prototype.resolve = function (placeholder) {\n var _this = this;\n // Literal value => return itself.\n if (typeof placeholder !== 'object')\n return placeholder;\n // Placeholder object ( { eval: string } ) => resolve\n if (Object.keys(placeholder).length == 1 && 'eval' in placeholder) {\n if (!this.isResolved)\n throw Error(\"Not all placeholders are resolved: \" + this);\n return eval('(function(placeholders){return ' + placeholder.eval + ';})')(this.values);\n }\n // Array => deep copy\n if (placeholder instanceof Array) {\n return placeholder.map(function (value) { return _this.resolve(value); });\n }\n // Object => deep copy\n return Object.entries(placeholder)\n .reduce(function (result, _a) {\n var key = _a[0], value = _a[1];\n result[key] = _this.resolve(value);\n return result;\n }, {});\n };\n PlaceholderContext.prototype.toString = function () {\n return JSON.stringify(this.values);\n };\n return PlaceholderContext;\n}());\nexports.default = PlaceholderContext;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/placeholder.js\n// module id = 5\n// module chunks = 0","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar symbolic_typed_array_1 = require(\"./symbolic_typed_array\");\n/**\n * Typed array used for input and output variables of [[webdnn.DescriptorRunner| `DescriptorRunner`]].\n * You can use `SymbolicFloat32Array` almost as same as `Float32Array`.\n *\n * To convert `SymbolicFloat32Array` into actual `Float32Array`, use [[webdnn.SymbolicFloat32Array.toActual| `toActual()`]]\n *\n * ```js\n *\n * let result = runner.outputs[0]; //runner.outputs is array of SymbolicFloat32Array\n *\n * // SymbolicFloat32Array does NOT support index access\n * console.log(result[0]);\n * >>> undefined\n *\n * // By conversion, you can access each element by index\n * console.log(result.toActual()[0]);\n * >>> 1.00 // Actual result\n * ```\n */\nvar SymbolicFloat32Array = /** @class */ (function (_super) {\n __extends(SymbolicFloat32Array, _super);\n function SymbolicFloat32Array() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n /**\n * The size in bytes of each element in the array.\n */\n _this.BYTES_PER_ELEMENT = 4;\n return _this;\n }\n /**\n * Convert SymbolicTypedArray instance into actual TypedArray instance.\n *\n * @returns actual typed array\n */\n SymbolicFloat32Array.prototype.toActual = function () {\n if (!this.buffer) {\n throw new Error('Internal buffer for this variable is not set. DescriptorRunner.setPlaceholderValue() have to be called before calling this function.');\n }\n return new Float32Array(this.buffer, this.byteOffset, this.length);\n };\n /**\n * Determines whether all the members of an array satisfy the specified test.\n * @param callbackfn A function that accepts up to three arguments. The every method calls\n * the callbackfn function for each element in array1 until the callbackfn returns false,\n * or until the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n SymbolicFloat32Array.prototype.every = function (callbackfn, thisArg) {\n return this.toActual().every(callbackfn, thisArg);\n };\n /**\n * Returns the elements of an array that meet the condition specified in a callback function.\n * @param callbackfn A function that accepts up to three arguments. The filter method calls\n * the callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n SymbolicFloat32Array.prototype.filter = function (callbackfn, thisArg) {\n return this.toActual().filter(callbackfn, thisArg);\n };\n /**\n * Returns the value of the first element in the array where predicate is true, and undefined\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found, find\n * immediately returns that element value. Otherwise, find returns undefined.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n SymbolicFloat32Array.prototype.find = function (predicate, thisArg) {\n return this.toActual().find(predicate, thisArg);\n };\n /**\n * Returns the index of the first element in the array where predicate is true, and -1\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found,\n * findIndex immediately returns that element index. Otherwise, findIndex returns -1.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n SymbolicFloat32Array.prototype.findIndex = function (predicate, thisArg) {\n return this.toActual().findIndex(predicate, thisArg);\n };\n /**\n * Performs the specified action for each element in an array.\n * @param callbackfn A function that accepts up to three arguments. forEach calls the\n * callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n SymbolicFloat32Array.prototype.forEach = function (callbackfn, thisArg) {\n return this.toActual().forEach(callbackfn, thisArg);\n };\n /**\n * Calls a defined callback function on each element of an array, and returns an array that\n * contains the results.\n * @param callbackfn A function that accepts up to three arguments. The map method calls the\n * callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n SymbolicFloat32Array.prototype.map = function (callbackfn, thisArg) {\n return this.toActual().map(callbackfn, thisArg);\n };\n SymbolicFloat32Array.prototype.reduce = function (callbackfn, initialValue) {\n return this.toActual().reduce(callbackfn, initialValue);\n };\n SymbolicFloat32Array.prototype.reduceRight = function (callbackfn, initialValue) {\n return this.toActual().reduceRight(callbackfn, initialValue);\n };\n /**\n * Reverses the elements in an Array.\n */\n SymbolicFloat32Array.prototype.reverse = function () {\n return this.toActual().reverse();\n };\n /**\n * Returns a section of an array.\n * @param start The beginning of the specified portion of the array.\n * @param end The end of the specified portion of the array.\n */\n SymbolicFloat32Array.prototype.slice = function (start, end) {\n return this.toActual().slice(start, end);\n };\n /**\n * Determines whether the specified callback function returns true for any element of an array.\n * @param callbackfn A function that accepts up to three arguments. The some method calls the\n * callbackfn function for each element in array1 until the callbackfn returns true, or until\n * the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n SymbolicFloat32Array.prototype.some = function (callbackfn, thisArg) {\n return this.toActual().some(callbackfn, thisArg);\n };\n /**\n * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements\n * at begin, inclusive, up to end, exclusive.\n * @param begin The index of the beginning of the array.\n * @param end The index of the end of the array.\n */\n SymbolicFloat32Array.prototype.subarray = function (begin, end) {\n return this.toActual().subarray(begin, end);\n };\n /** @protected */\n SymbolicFloat32Array.prototype.includes = function (searchElement, fromIndex) {\n return this.toActual().includes(searchElement, fromIndex);\n };\n /**\n * The size in bytes of each element in SymbolicFloat32Array.\n */\n SymbolicFloat32Array.BYTES_PER_ELEMENT = 4;\n return SymbolicFloat32Array;\n}(symbolic_typed_array_1.SymbolicTypedArray));\nexports.default = SymbolicFloat32Array;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/symbolic_typed_array/symbolic_float32array.js\n// module id = 6\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * `DescriptorRunner` provides interface to execute DNN model and access input and output buffers.\n */\nvar DescriptorRunner = /** @class */ (function () {\n function DescriptorRunner() {\n /**\n * For Developer:\n *\n * `DescriptorRunner` executes computation based on `GraphDescriptor`.\n *\n * Typically, DescriptorRunner takes 3 steps to execute DNN model.\n *\n * 1. Initialize static configurations\n *\n * Initialize things independent from runtime configuration.\n *\n * - `init()`\n * - `load()`\n *\n * 2. Initialize dynamic configurations\n *\n * Initialize things depend on runtime configuration such as batch size, input image size, etc.\n *\n * - `setPlaceholderValue()`\n * - `getInputViews()`\n * - `getOutputViews()`\n *\n * 3. Execute the model\n *\n * - `run()`\n *\n * You need to do step 1 and 2 only once. We recommend to call `WebDNN.prepareAll()` instead\n * to call `GraphDescriptor#load()` directly. In that method, all procedures in step 1 and 2 are performed.\n */\n /**\n * The descriptor\n */\n this.descriptor = null;\n }\n /**\n * Return `true` if this backend is available in this environment.\n * @returns {boolean}\n */\n DescriptorRunner.checkAvailability = function () {\n return false;\n };\n return DescriptorRunner;\n}());\nexports.DescriptorRunner = DescriptorRunner;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner.js\n// module id = 7\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/messages.js\n// module id = 8\n// module chunks = 0","'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It isn't worth it to make additional optimizations as in original.\n// Small size is preferable.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n\nmodule.exports = adler32;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/adler32.js\n// module id = 9\n// module chunks = 0","'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n\nmodule.exports = crc32;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/crc32.js\n// module id = 10\n// module chunks = 0","// String encode/decode helpers\n'use strict';\n\n\nvar utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safari\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new utils.Buf8(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nexports.string2buf = function (str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new utils.Buf8(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n};\n\n// Helper (used in 2 places)\nfunction buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert byte array to binary string\nexports.buf2binstring = function (buf) {\n return buf2binstring(buf, buf.length);\n};\n\n\n// Convert binary string (typed, when possible)\nexports.binstring2buf = function (str) {\n var buf = new utils.Buf8(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n};\n\n\n// convert array to string\nexports.buf2string = function (buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n};\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nexports.utf8border = function (buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/utils/strings.js\n// module id = 11\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\nmodule.exports = ZStream;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/zstream.js\n// module id = 12\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n //Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/constants.js\n// module id = 13\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/// \nvar webdnn_1 = require(\"./webdnn\");\n/**\n * @protected\n */\nfunction isWebGL2(gl) {\n return gl.constructor.name === 'WebGL2RenderingContext';\n}\nexports.isWebGL2 = isWebGL2;\n/**\n * @private\n */\nvar instance;\n/**\n * @protected\n */\nvar WebGLHandler = /** @class */ (function () {\n /**\n * WebGLHandler is singleton class and instantiate directly is forbidden (constructor is hidden).\n *\n * Since the number of GPU contexts may be limited, the handler is used as a singleton\n * and only one context is shared among multiple runners.\n */\n function WebGLHandler() {\n this.gl = checkNull(WebGLHandler.initializeContext());\n }\n WebGLHandler.getInstance = function () {\n if (!instance)\n instance = new WebGLHandler();\n return instance;\n };\n WebGLHandler.prototype.createTexture = function (textureWidth, textureHeight, internalFormat, format) {\n var gl = this.gl;\n var texture = checkNull(gl.createTexture());\n gl.activeTexture(gl.TEXTURE0 + 9); // TODO: texture unit 9 is always available?\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, textureWidth, textureHeight, 0, format, gl.FLOAT, null);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n gl.bindTexture(gl.TEXTURE_2D, null);\n return texture;\n };\n WebGLHandler.prototype.createVertexShader = function (source) {\n return this.createShader(this.gl.VERTEX_SHADER, source);\n };\n WebGLHandler.prototype.createFragmentShader = function (source) {\n return this.createShader(this.gl.FRAGMENT_SHADER, source);\n };\n WebGLHandler.prototype.createShader = function (type, source) {\n var shader = checkNull(this.gl.createShader(type));\n this.gl.shaderSource(shader, source);\n this.gl.compileShader(shader);\n if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {\n console.error(this.gl.getShaderInfoLog(shader));\n throw Error(\"Shader Compile failed: \" + this.gl.getShaderInfoLog(shader));\n }\n return shader;\n };\n WebGLHandler.prototype.createProgram = function (vertexShader, fragmentShader) {\n var program = checkNull(this.gl.createProgram());\n this.gl.attachShader(program, fragmentShader);\n this.gl.attachShader(program, vertexShader);\n this.gl.linkProgram(program);\n if (!this.gl.getProgramParameter(program, this.gl.LINK_STATUS)) {\n console.error(this.gl.getProgramInfoLog(program));\n throw Error('ShaderProgram Initialization failed.');\n }\n return program;\n };\n WebGLHandler.prototype.createArrayBuffer = function (vertexArray) {\n var buffer = checkNull(this.gl.createBuffer());\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, vertexArray, this.gl.STATIC_DRAW);\n return buffer;\n };\n WebGLHandler.prototype.createFrameBuffer = function () {\n return checkNull(this.gl.createFramebuffer());\n };\n WebGLHandler.prototype.bindArrayBuffer = function (buffer) {\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, buffer);\n };\n WebGLHandler.prototype.bindFrameBuffer = function (frameBuffer, width, height) {\n this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, frameBuffer);\n this.gl.viewport(0, 0, width, height);\n this.gl.scissor(0, 0, width, height);\n };\n WebGLHandler.prototype.useProgram = function (program) {\n this.gl.useProgram(program);\n };\n WebGLHandler.prototype.deleteTexture = function (texture) {\n this.gl.deleteTexture(texture);\n };\n WebGLHandler.initializeWebGL2Context = function (canvas) {\n if (canvas === void 0) { canvas = document.createElement('canvas'); }\n var gl;\n gl = (canvas.getContext('webgl2'));\n if (!gl)\n return null;\n if (!gl.getExtension('EXT_color_buffer_float'))\n return null;\n if (webdnn_1.getConfiguration('DEBUG', false) && !gl.getExtension('WEBGL_debug_renderer_info'))\n return null;\n return gl;\n };\n WebGLHandler.initializeWebGL1Context = function (canvas) {\n if (canvas === void 0) { canvas = document.createElement('canvas'); }\n var gl = (canvas.getContext('webgl') || canvas.getContext('experimental-webgl'));\n if (!gl)\n return null;\n if (!gl.getExtension('OES_texture_float'))\n return null;\n if (WebGLHandler.IS_SAFARI) {\n //TODO(Kiikurage)\n // Safari supports WebGL with OES_TEXTURE_FLOAT extension. However,\n // currently when WebGLRenderingContext#readPixels is called, an error is thrown.\n return null;\n }\n if (webdnn_1.getConfiguration('DEBUG', false) && !gl.getExtension('WEBGL_debug_renderer_info'))\n return null;\n return gl;\n };\n WebGLHandler.initializeContext = function () {\n var canvas = document.createElement('canvas');\n var gl;\n gl = WebGLHandler.initializeWebGL2Context(canvas);\n if (gl) {\n if (webdnn_1.getConfiguration('DEBUG', false))\n console.info('WebGL2 is enabled');\n }\n else {\n gl = WebGLHandler.initializeWebGL1Context(canvas);\n if (gl) {\n if (webdnn_1.getConfiguration('DEBUG', false))\n console.info('WebGL2 is disabled');\n }\n else {\n return null;\n }\n }\n gl.disable(gl.DEPTH_TEST);\n gl.disable(gl.STENCIL_TEST);\n gl.disable(gl.BLEND);\n gl.disable(gl.DITHER);\n gl.disable(gl.POLYGON_OFFSET_FILL);\n gl.disable(gl.SAMPLE_COVERAGE);\n gl.enable(gl.SCISSOR_TEST);\n gl.enable(gl.CULL_FACE);\n gl.cullFace(gl.BACK);\n return gl;\n };\n /**\n * Check whether WebGL is supported or not\n * @protected\n */\n WebGLHandler.checkAvailability = function () {\n if (availability === null) {\n var gl = WebGLHandler.initializeContext();\n if (!gl) {\n availability = false;\n }\n else if (webdnn_1.getConfiguration('MAX_TEXTURE_SIZE', gl.getParameter(gl.MAX_TEXTURE_SIZE)) < 4096) {\n availability = false;\n }\n else {\n availability = true;\n }\n }\n return availability;\n };\n WebGLHandler.prototype.waitForComplete = function () {\n return __awaiter(this, void 0, void 0, function () {\n var gl, sync, status_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n gl = this.gl;\n if (!isWebGL2(gl)) return [3 /*break*/, 4];\n sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);\n status_1 = gl.clientWaitSync(sync, 0, 0);\n _a.label = 1;\n case 1:\n if (!(status_1 !== gl.CONDITION_SATISFIED && status_1 !== gl.ALREADY_SIGNALED)) return [3 /*break*/, 3];\n return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 1); })];\n case 2:\n _a.sent();\n status_1 = gl.clientWaitSync(sync, 0, 0);\n return [3 /*break*/, 1];\n case 3:\n gl.deleteSync(sync);\n return [3 /*break*/, 5];\n case 4:\n gl.finish();\n _a.label = 5;\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n Object.defineProperty(WebGLHandler.prototype, \"MAX_TEXTURE_SIZE\", {\n get: function () {\n var MAX_TEXTURE_SIZE = webdnn_1.getConfiguration('MAX_TEXTURE_SIZE', this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE));\n // FIXME: In most case, MAX_TEXTURE_SIZE=4096 is the fastest (Why?).\n if (MAX_TEXTURE_SIZE >= 16384) {\n return 4096;\n }\n else if (MAX_TEXTURE_SIZE >= 8192) {\n return 4096;\n }\n else if (MAX_TEXTURE_SIZE >= 4096) {\n return 4096;\n }\n else {\n throw new Error(\"MAX_TEXTURE_SIZE is too small: \" + MAX_TEXTURE_SIZE);\n }\n },\n enumerable: true,\n configurable: true\n });\n WebGLHandler.IS_SAFARI = navigator.userAgent.toLowerCase().indexOf('safari') !== -1 && navigator.userAgent.toLowerCase().indexOf('chrome') === -1;\n return WebGLHandler;\n}());\nexports.default = WebGLHandler;\n/**\n * @private\n */\nvar availability = null;\n/**\n * @private\n */\nfunction checkNull(obj) {\n if (obj === null)\n throw Error('Null is detected');\n return obj;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webgl_handler.js\n// module id = 14\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * Abstract buffer interface. Read/write transactions are regarded as asynchronous operation.\n *\n * @protected\n */\nvar Buffer = /** @class */ (function () {\n function Buffer(byteLength, backend) {\n this.byteLength = byteLength;\n this.backend = backend;\n }\n return Buffer;\n}());\nexports.Buffer = Buffer;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer.js\n// module id = 15\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar webgpu_handler_1 = require(\"../webgpu_handler\");\nvar buffer_1 = require(\"./buffer\");\n/**\n * @protected\n */\nvar BufferWebGPU = /** @class */ (function (_super) {\n __extends(BufferWebGPU, _super);\n function BufferWebGPU(byteLength) {\n var _this = _super.call(this, byteLength, 'webgpu') || this;\n if (byteLength == 0) {\n byteLength = 4; //0 length buffer causes error\n }\n _this.handler = webgpu_handler_1.default.getInstance();\n _this.buffer = _this.handler.createBuffer(new Uint8Array(byteLength));\n _this.bufferView = new Uint8Array(_this.buffer.contents);\n return _this;\n }\n // async: there may be platforms synchronization is needed before writing\n BufferWebGPU.prototype.write = function (src, dst_offset) {\n return __awaiter(this, void 0, void 0, function () {\n var viewSameType;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handler.sync()];\n case 1:\n _a.sent();\n viewSameType = new src.constructor(this.bufferView.buffer);\n viewSameType.set(src, dst_offset);\n return [2 /*return*/];\n }\n });\n });\n };\n BufferWebGPU.prototype.read = function (dst, src_offset, length) {\n if (src_offset === void 0) { src_offset = 0; }\n return __awaiter(this, void 0, void 0, function () {\n var dstConstructor, viewSameType;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!dst)\n throw new Error('dst cannot be null');\n return [4 /*yield*/, this.handler.sync()];\n case 1:\n _a.sent();\n if (this.byteLength === 0)\n return [2 /*return*/];\n dstConstructor = dst.constructor;\n viewSameType = new dstConstructor(this.bufferView.buffer, this.bufferView.byteOffset + src_offset * dstConstructor.BYTES_PER_ELEMENT, length);\n dst.set(viewSameType);\n return [2 /*return*/];\n }\n });\n });\n };\n BufferWebGPU.prototype.getWriteView = function (offset, length, type) {\n return new type(this.bufferView.buffer, this.bufferView.byteOffset + offset * type.BYTES_PER_ELEMENT, length);\n };\n BufferWebGPU.prototype.getReadView = function (offset, length, type) {\n return new type(this.bufferView.buffer, this.bufferView.byteOffset + offset * type.BYTES_PER_ELEMENT, length);\n };\n BufferWebGPU.prototype.syncWriteViews = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/];\n });\n });\n };\n BufferWebGPU.prototype.syncReadViews = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: \n // if the user awaits promise from final kernel execution, this function call is not needed.\n return [4 /*yield*/, this.handler.sync()];\n case 1:\n // if the user awaits promise from final kernel execution, this function call is not needed.\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n return BufferWebGPU;\n}(buffer_1.Buffer));\nexports.default = BufferWebGPU;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer_webgpu.js\n// module id = 16\n// module chunks = 0","\"use strict\";\n///\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar buffer_webgpu_1 = require(\"./buffer/buffer_webgpu\");\n/**\n * @private\n */\nvar instance;\n/**\n * @protected\n */\nvar WebGPUHandler = /** @class */ (function () {\n /**\n * WebGPUHandler is singleton class and instantiate directly is forbidden (constructor is hidden).\n *\n * Since the number of GPU contexts may be limited, the handler is used as a singleton\n * and only one context is shared among multiple runners.\n */\n function WebGPUHandler() {\n this.pipelineStates = new Map();\n if (!exports.IS_WEBGPU_SUPPORTED)\n throw new Error('This browser does not support WebGPU');\n var context;\n try {\n context = document.createElement('canvas').getContext('webgpu');\n }\n catch (err) {\n throw new Error(\"During initializing WebGPURenderingContext, unexpected error is occurred: \" + err.message);\n }\n if (!context)\n throw new Error('WebGPURenderingContext initialization failed');\n this.context = context;\n this.commandQueue = context.createCommandQueue();\n this.loadKernel('kernel void sync(){}', 'basic');\n }\n WebGPUHandler.getInstance = function () {\n if (!instance)\n instance = new WebGPUHandler();\n return instance;\n };\n WebGPUHandler.prototype.createBuffer = function (arrayBuffer) {\n return this.context.createBuffer(arrayBuffer);\n };\n WebGPUHandler.prototype.loadKernel = function (librarySource, namespace) {\n if (namespace === void 0) { namespace = ''; }\n var library = this.context.createLibrary(librarySource);\n for (var _i = 0, _a = library.functionNames; _i < _a.length; _i++) {\n var name_1 = _a[_i];\n var kernelFunction = library.functionWithName(name_1);\n var pipelineStates = this.context.createComputePipelineState(kernelFunction);\n this.pipelineStates.set(namespace + '.' + name_1, pipelineStates);\n }\n };\n WebGPUHandler.prototype.createCommandBuffer = function () {\n return this.commandQueue.createCommandBuffer();\n };\n WebGPUHandler.prototype.getPipelineStateByName = function (name) {\n var state = this.pipelineStates.get(name);\n if (!state) {\n throw TypeError(\"Kernel function \\\"\" + name + \"\\\" is not loaded.\");\n }\n return state;\n };\n WebGPUHandler.prototype.executeSinglePipelineState = function (name, threadgroupsPerGrid, threadsPerThreadgroup, buffers, getCompletedPromise) {\n var commandBuffer = this.commandBuffer || (this.commandBuffer = this.createCommandBuffer());\n var commandEncoder = commandBuffer.createComputeCommandEncoder();\n commandEncoder.setComputePipelineState(this.getPipelineStateByName(name));\n for (var i = 0; i < buffers.length; i++) {\n var buffer = buffers[i];\n var wgbuf = void 0;\n if (buffer instanceof buffer_webgpu_1.default) {\n wgbuf = buffer.buffer;\n }\n else {\n // cannot perform (buffer instanceof WebGPUBuffer) currently\n wgbuf = buffer;\n }\n commandEncoder.setBuffer(wgbuf, 0, i);\n }\n commandEncoder.dispatch(threadgroupsPerGrid, threadsPerThreadgroup);\n commandEncoder.endEncoding();\n var promise = null;\n if (getCompletedPromise) {\n promise = commandBuffer.completed;\n }\n this.commandBuffer = null;\n commandBuffer.commit();\n return promise;\n };\n WebGPUHandler.prototype.sync = function () {\n return __awaiter(this, void 0, void 0, function () {\n var commandBuffer, commandEncoder, promise;\n return __generator(this, function (_a) {\n commandBuffer = this.createCommandBuffer();\n commandEncoder = commandBuffer.createComputeCommandEncoder();\n commandEncoder.setComputePipelineState(this.getPipelineStateByName('basic.sync'));\n commandEncoder.dispatch({\n width: 1,\n height: 1,\n depth: 1\n }, {\n width: 1,\n height: 1,\n depth: 1\n });\n commandEncoder.endEncoding();\n promise = commandBuffer.completed;\n commandBuffer.commit();\n return [2 /*return*/, promise];\n });\n });\n };\n return WebGPUHandler;\n}());\nexports.default = WebGPUHandler;\n/**\n * Flag whether WebGPU is supported or not\n * @protected\n */\nexports.IS_WEBGPU_SUPPORTED = 'WebGPURenderingContext' in window && 'WebGPUComputeCommandEncoder' in window;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webgpu_handler.js\n// module id = 17\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/image\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/** Don't Remove This comment block */\n/**\n * The data order\n */\nvar Order;\n(function (Order) {\n /** `[Channel, Height, Width]` format */\n Order[Order[\"CHW\"] = 0] = \"CHW\";\n /** `[Height, Width, Channel]` format */\n Order[Order[\"HWC\"] = 1] = \"HWC\";\n})(Order = exports.Order || (exports.Order = {}));\n/**\n * The color format\n */\nvar Color;\n(function (Color) {\n /** RGB format */\n Color[Color[\"RGB\"] = 0] = \"RGB\";\n /** BGR format */\n Color[Color[\"BGR\"] = 1] = \"BGR\";\n /** grey scale */\n Color[Color[\"GREY\"] = 2] = \"GREY\";\n /** RGBA format */\n Color[Color[\"RGBA\"] = 3] = \"RGBA\";\n /** BGRA format */\n Color[Color[\"BGRA\"] = 4] = \"BGRA\";\n})(Color = exports.Color || (exports.Color = {}));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/enums.js\n// module id = 18\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * Get canvas rendering context and check whether it is nonnull value.\n *\n * @param {CanvasRenderingContext2D} canvas\n * @protected\n */\nfunction getContext2D(canvas) {\n var context = canvas.getContext('2d');\n if (!context)\n throw Error('CanvasRenderingContext2D initialization failed');\n return context;\n}\nexports.getContext2D = getContext2D;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/canvas.js\n// module id = 19\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/image\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/** Don't Remove This comment block */\n/**\n * Load image of specified url\n *\n * @param {string} url the image url\n * @returns {Promise} image element\n */\nfunction loadImageByUrl(url) {\n return __awaiter(this, void 0, void 0, function () {\n var image;\n return __generator(this, function (_a) {\n image = document.createElement('img');\n return [2 /*return*/, new Promise(function (resolve, reject) {\n image.onload = resolve;\n image.onerror = reject;\n image.src = url;\n })\n .then(function () { return image; })];\n });\n });\n}\nexports.loadImageByUrl = loadImageByUrl;\n/* istanbul ignore next */\n/**\n * Load image file selected in `` element.\n *\n * @param {HTMLInputElement} input the `` element\n * @returns {Promise} image element\n */\nfunction loadImageFromFileInput(input) {\n return __awaiter(this, void 0, void 0, function () {\n var files, url;\n return __generator(this, function (_a) {\n files = input.files;\n if (!files || files.length == 0)\n throw new Error('No file is selected');\n url = URL.createObjectURL(files[0]);\n return [2 /*return*/, loadImageByUrl(url)];\n });\n });\n}\nexports.loadImageFromFileInput = loadImageFromFileInput;\n/* istanbul ignore next */\n/**\n * Load image selected in file picker dialog\n *\n * Currently, web specification not supported the case if the dialog is canceled and no file is selected. In this case,\n * the returned promise will never be resolved.\n *\n * @returns {Promise} image element\n * @protected\n */\nfunction loadImageByDialog() {\n return __awaiter(this, void 0, void 0, function () {\n var input;\n return __generator(this, function (_a) {\n input = document.createElement('input');\n input.type = 'file';\n input.accept = 'image/*';\n return [2 /*return*/, new Promise(function (resolve) {\n input.onchange = function () { return resolve(loadImageFromFileInput(input)); };\n input.click();\n })];\n });\n });\n}\nexports.loadImageByDialog = loadImageByDialog;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_source.js\n// module id = 20\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar localforage = require(\"localforage\");\nvar get_weight_decoder_1 = require(\"../decoder/get_weight_decoder\");\nvar fetch_1 = require(\"../fetch\");\nvar placeholder_1 = require(\"../placeholder\");\nvar symbolic_float32array_1 = require(\"../symbolic_typed_array/symbolic_float32array\");\nvar descriptor_runner_1 = require(\"./descriptor_runner\");\n/**\n * @private\n */\nfunction wait(duration) {\n if (duration === void 0) { duration = 10; }\n // let console.log to be displayed, and prevent freeze\n return new Promise(function (resolve) { return setTimeout(resolve, duration); });\n}\n/**\n * @protected\n */\nvar DescriptorRunnerFallback = /** @class */ (function (_super) {\n __extends(DescriptorRunnerFallback, _super);\n function DescriptorRunnerFallback() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.backendName = 'fallback';\n return _this;\n }\n DescriptorRunnerFallback.checkAvailability = function () {\n return true;\n };\n DescriptorRunnerFallback.prototype.init = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/];\n });\n });\n };\n DescriptorRunnerFallback.prototype.setDescriptorAndParameters = function (descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.setDescriptor(descriptor);\n return [4 /*yield*/, this.compile()];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.initializeStaticBuffer(parameters)];\n case 2:\n _a.sent();\n if (!(this.placeholderContext && this.placeholderContext.isResolved)) return [3 /*break*/, 4];\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 3:\n _a.sent();\n _a.label = 4;\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.fetchDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.directory = directory;\n return [4 /*yield*/, fetch_1.default(directory + \"/graph_\" + this.backendName + \".json\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, res.json()];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.fetchParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fetch_1.default(directory + \"/weight_\" + this.backendName + \".bin\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, fetch_1.readArrayBufferProgressively(res, progressCallback)];\n }\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerFallback.prototype.restoreCachedDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, localforage.getItem(directory + \"_\" + this.backendName + \"_descriptor\").catch(function () { return null; })];\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerFallback.prototype.restoreCachedParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var parameter;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, localforage.getItem(directory + \"_\" + this.backendName + \"_parameters\").catch(function () { return null; })];\n case 1:\n parameter = _a.sent();\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return [2 /*return*/, parameter];\n }\n });\n });\n };\n /**\n * save cache\n */\n DescriptorRunnerFallback.prototype.saveCache = function (directory, descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, Promise.all([\n localforage.setItem(directory + \"_\" + this.backendName + \"_descriptor\", descriptor),\n localforage.setItem(directory + \"_\" + this.backendName + \"_parameters\", parameters)\n ])];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n ;\n DescriptorRunnerFallback.prototype.setDescriptor = function (descriptor) {\n this.descriptor = descriptor;\n // reset\n this.placeholderContext = new placeholder_1.default();\n this.placeholderContext.update(descriptor.placeholders);\n this.kernelObj = null;\n this.variableMap = null;\n this.staticBuffer = null;\n this.dynamicBuffer = null;\n };\n DescriptorRunnerFallback.prototype.compile = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n return [4 /*yield*/, new Promise(function (resolve) {\n var script = document.createElement(\"script\");\n script.type = \"text/javascript\";\n if (script.readyState) {\n script.onreadystatechange = function () {\n if (script.readyState == \"loaded\" || script.readyState == \"complete\") {\n script.onreadystatechange = null;\n resolve();\n }\n };\n }\n else {\n script.onload = resolve;\n }\n script.src = fetch_1.transformUrl(_this.directory + \"/kernels_fallback.js\");\n document.getElementsByTagName(\"head\")[0].appendChild(script);\n })];\n case 1:\n _a.sent();\n this.kernelObj = window.dnn_fallback_kernel; // \"window.dnn_fallback_kernel\" is defined in \"kernels_fallback.js\"\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.initializeStaticBuffer = function (weightRawArray) {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, staticBuffer, variableMap, decoder, _a, _b;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n descriptor = this.descriptor;\n staticBuffer = new Float32Array(descriptor.memory_layout.static.size);\n this.staticBuffer = staticBuffer;\n variableMap = this.variableMap || new Map();\n this.variableMap = variableMap;\n Object.entries(descriptor.memory_layout.static.allocations)\n .forEach(function (_a) {\n var name = _a[0], allocation = _a[1];\n variableMap.set(name, new Float32Array(staticBuffer.buffer, allocation.offset * Float32Array.BYTES_PER_ELEMENT, allocation.size));\n });\n decoder = get_weight_decoder_1.default(this.descriptor.weight_encoding);\n _b = (_a = staticBuffer).set;\n return [4 /*yield*/, decoder.decode(new Uint8Array(weightRawArray))];\n case 1:\n _b.apply(_a, [_c.sent()]);\n return [4 /*yield*/, this.getInputViews()];\n case 2:\n (_c.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = staticBuffer.buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 3:\n (_c.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = staticBuffer.buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.initializeDynamicBuffer = function () {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, placeholderContext, dynamicBuffer, variableMap;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n descriptor = this.descriptor;\n placeholderContext = this.placeholderContext;\n dynamicBuffer = new Float32Array(placeholderContext.resolve(descriptor.memory_layout.dynamic.size));\n this.dynamicBuffer = dynamicBuffer;\n variableMap = this.variableMap || new Map();\n this.variableMap = variableMap;\n Object.entries(descriptor.memory_layout.dynamic.allocations)\n .forEach(function (_a) {\n var name = _a[0], allocation = _a[1];\n variableMap.set(name, new Float32Array(dynamicBuffer.buffer, placeholderContext.resolve(allocation.offset) * Float32Array.BYTES_PER_ELEMENT, placeholderContext.resolve(allocation.size)));\n });\n return [4 /*yield*/, this.getInputViews()];\n case 1:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = dynamicBuffer.buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 2:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = dynamicBuffer.buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.setPlaceholderValue = function (values) {\n return __awaiter(this, void 0, void 0, function () {\n var placeholderContext;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.placeholderContext)\n throw new Error('placeholderContext is not initialized');\n placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return [2 /*return*/];\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.run = function () {\n return __awaiter(this, void 0, void 0, function () {\n var variableMap, placeholderContext, executionInfos, startDate, lastDate, i, currentDate, executionInfo, inputs, outputs;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('placeholderContext is not initialized');\n if (!this.variableMap)\n throw new Error('Variable map is not initialized');\n if (!this.staticBuffer)\n throw new Error('StaticBuffer map is not initialized');\n if (!this.dynamicBuffer)\n throw new Error('DynamicBuffer map is not initialized');\n variableMap = this.variableMap;\n placeholderContext = this.placeholderContext;\n executionInfos = this.descriptor.exec_infos\n .map(function (executionInfo) { return placeholderContext.resolve(executionInfo); });\n startDate = Date.now();\n lastDate = Date.now();\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < executionInfos.length)) return [3 /*break*/, 5];\n currentDate = Date.now();\n if (!(currentDate - lastDate >= 1000)) return [3 /*break*/, 3];\n console.log(\"Processed \" + i + \"/\" + executionInfos.length + \" kernels in \" + (currentDate - startDate) + \" ms\");\n lastDate = currentDate;\n return [4 /*yield*/, wait()];\n case 2:\n _a.sent();\n _a.label = 3;\n case 3:\n executionInfo = executionInfos[i];\n inputs = executionInfo.inputs.map(function (name) { return variableMap.get(name); });\n outputs = executionInfo.outputs.map(function (name) { return variableMap.get(name); });\n this.kernelObj[executionInfo.entry_func_name](inputs, outputs, executionInfo.call_option);\n _a.label = 4;\n case 4:\n i++;\n return [3 /*break*/, 1];\n case 5:\n console.log(\"Processed \" + executionInfos.length + \"/\" + executionInfos.length + \" kernels in \" + (Date.now() - startDate) + \" ms\");\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.getInputViews = function () {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, allocation.offset * symbolic_float32array_1.default.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n };\n DescriptorRunnerFallback.prototype.getOutputViews = function () {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, allocation.offset * symbolic_float32array_1.default.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n };\n return DescriptorRunnerFallback;\n}(descriptor_runner_1.DescriptorRunner));\nexports.default = DescriptorRunnerFallback;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_fallback.js\n// module id = 21\n// module chunks = 0","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 22\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar pako = require(\"pako\");\n/**\n * @protected\n */\nvar WeightDecoderEightbit = /** @class */ (function () {\n function WeightDecoderEightbit() {\n }\n WeightDecoderEightbit.prototype.decode = function (data) {\n return __awaiter(this, void 0, void 0, function () {\n var decoded_arrays, total_dst_length, data_view, src_offset, dst_offset_1, body_size, scale, scaled_table, i, src_data_view, decompressed, dec_size, decoded_array, s, dst, dst_offset, i;\n return __generator(this, function (_a) {\n decoded_arrays = [];\n total_dst_length = 0;\n data_view = new DataView(data.buffer, data.byteOffset);\n src_offset = 0;\n while (src_offset < data.length) {\n dst_offset_1 = data_view.getInt32(src_offset, true);\n src_offset += 4;\n body_size = data_view.getInt32(src_offset, true);\n src_offset += 4;\n scale = data_view.getFloat32(src_offset, true);\n src_offset += 8;\n scaled_table = new Float32Array(256);\n for (i = 0; i < 256; i++) {\n scaled_table[i] = WeightDecoderEightbit.decode_table[i & 0x7F] * scale * (i < 128 ? 1.0 : -1.0);\n }\n src_data_view = new Uint8Array(data.buffer, data.byteOffset + src_offset, body_size);\n decompressed = pako.inflate(src_data_view);\n dec_size = decompressed.length;\n decoded_array = new Float32Array(dec_size);\n for (s = 0; s < dec_size; s++) {\n decoded_array[s] = scaled_table[decompressed[s]];\n }\n decoded_arrays.push(decoded_array);\n total_dst_length += dec_size;\n src_offset += body_size;\n }\n dst = new Float32Array(total_dst_length);\n dst_offset = 0;\n for (i = 0; i < decoded_arrays.length; i++) {\n dst.set(decoded_arrays[i], dst_offset);\n dst_offset += decoded_arrays[i].length;\n }\n return [2 /*return*/, dst];\n });\n });\n };\n WeightDecoderEightbit.decode_table = [0.0, 2.750000021e-06, 7.249999726e-06, 1.875000089e-05, 3.624999954e-05, 5.874999624e-05, 8.624999464e-05,\n 1.437500032e-04, 2.312500001e-04, 3.187500115e-04, 4.062500084e-04, 5.187499919e-04, 6.562499912e-04,\n 7.937499322e-04, 9.312499315e-04, 1.218750025e-03, 1.656249980e-03, 2.093750052e-03, 2.531250007e-03,\n 2.968749963e-03, 3.406249918e-03, 3.843750106e-03, 4.281249829e-03, 4.843750037e-03, 5.531250034e-03,\n 6.218749564e-03, 6.906249560e-03, 7.593749557e-03, 8.281249553e-03, 8.968749084e-03, 9.656248614e-03,\n 1.109374966e-02, 1.328125037e-02, 1.546875015e-02, 1.765624993e-02, 1.984374970e-02, 2.203124948e-02,\n 2.421874925e-02, 2.640625089e-02, 2.859375067e-02, 3.078125045e-02, 3.296874836e-02, 3.515625000e-02,\n 3.734375164e-02, 3.953124955e-02, 4.171875119e-02, 4.390624911e-02, 4.671875015e-02, 5.015625060e-02,\n 5.359374732e-02, 5.703124776e-02, 6.046874821e-02, 6.390624493e-02, 6.734374911e-02, 7.078124583e-02,\n 7.421874255e-02, 7.765624672e-02, 8.109374344e-02, 8.453124017e-02, 8.796874434e-02, 9.140624106e-02,\n 9.484373778e-02, 9.828124195e-02, 1.054687500e-01, 1.164062470e-01, 1.273437440e-01, 1.382812560e-01,\n 1.492187530e-01, 1.601562500e-01, 1.710937470e-01, 1.820312440e-01, 1.929687560e-01, 2.039062530e-01,\n 2.148437500e-01, 2.257812470e-01, 2.367187440e-01, 2.476562560e-01, 2.585937381e-01, 2.695312500e-01,\n 2.804687619e-01, 2.914062440e-01, 3.023437560e-01, 3.132812381e-01, 3.242187500e-01, 3.351562619e-01,\n 3.460937440e-01, 3.570312560e-01, 3.679687381e-01, 3.789062500e-01, 3.898437619e-01, 4.007812440e-01,\n 4.117187560e-01, 4.226562381e-01, 4.335937500e-01, 4.445312619e-01, 4.585937560e-01, 4.757812321e-01,\n 4.929687381e-01, 5.101562142e-01, 5.273437500e-01, 5.445312262e-01, 5.617187023e-01, 5.789062381e-01,\n 5.960937142e-01, 6.132812500e-01, 6.304687262e-01, 6.476562023e-01, 6.648437381e-01, 6.820312142e-01,\n 6.992186904e-01, 7.164062262e-01, 7.335937023e-01, 7.507811785e-01, 7.679687142e-01, 7.851561904e-01,\n 8.023436666e-01, 8.195312023e-01, 8.367186785e-01, 8.539061546e-01, 8.710936904e-01, 8.882811666e-01,\n 9.054686427e-01, 9.226561785e-01, 9.398436546e-01, 9.570311308e-01, 9.742186666e-01, 9.914061427e-01, 1.0,\n ];\n return WeightDecoderEightbit;\n}());\nexports.default = WeightDecoderEightbit;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/weight_decoder_eightbit.js\n// module id = 23\n// module chunks = 0","// Top level file is just a mixin of submodules & constants\n'use strict';\n\nvar assign = require('./lib/utils/common').assign;\n\nvar deflate = require('./lib/deflate');\nvar inflate = require('./lib/inflate');\nvar constants = require('./lib/zlib/constants');\n\nvar pako = {};\n\nassign(pako, deflate, inflate, constants);\n\nmodule.exports = pako;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/index.js\n// module id = 24\n// module chunks = 0","'use strict';\n\n\nvar zlib_deflate = require('./zlib/deflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\n\nvar toString = Object.prototype.toString;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nvar Z_NO_FLUSH = 0;\nvar Z_FINISH = 4;\n\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_SYNC_FLUSH = 2;\n\nvar Z_DEFAULT_COMPRESSION = -1;\n\nvar Z_DEFAULT_STRATEGY = 0;\n\nvar Z_DEFLATED = 8;\n\n/* ===========================================================================*/\n\n\n/**\n * class Deflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[deflate]],\n * [[deflateRaw]] and [[gzip]].\n **/\n\n/* internal\n * Deflate.chunks -> Array\n *\n * Chunks of output data, if [[Deflate#onData]] not overridden.\n **/\n\n/**\n * Deflate.result -> Uint8Array|Array\n *\n * Compressed result, generated by default [[Deflate#onData]]\n * and [[Deflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Deflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Deflate.err -> Number\n *\n * Error code after deflate finished. 0 (Z_OK) on success.\n * You will not need it in real life, because deflate errors\n * are possible only on wrong options or bad `onData` / `onEnd`\n * custom handlers.\n **/\n\n/**\n * Deflate.msg -> String\n *\n * Error message, if [[Deflate.err]] != 0\n **/\n\n\n/**\n * new Deflate(options)\n * - options (Object): zlib deflate options.\n *\n * Creates new deflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `level`\n * - `windowBits`\n * - `memLevel`\n * - `strategy`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw deflate\n * - `gzip` (Boolean) - create gzip wrapper\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n * - `header` (Object) - custom header for gzip\n * - `text` (Boolean) - true if compressed data believed to be text\n * - `time` (Number) - modification time, unix timestamp\n * - `os` (Number) - operation system code\n * - `extra` (Array) - array of bytes with extra data (max 65536)\n * - `name` (String) - file name (binary string)\n * - `comment` (String) - comment (binary string)\n * - `hcrc` (Boolean) - true if header crc should be added\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var deflate = new pako.Deflate({ level: 3});\n *\n * deflate.push(chunk1, false);\n * deflate.push(chunk2, true); // true -> last chunk\n *\n * if (deflate.err) { throw new Error(deflate.err); }\n *\n * console.log(deflate.result);\n * ```\n **/\nfunction Deflate(options) {\n if (!(this instanceof Deflate)) return new Deflate(options);\n\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n if (opt.raw && (opt.windowBits > 0)) {\n opt.windowBits = -opt.windowBits;\n }\n\n else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {\n opt.windowBits += 16;\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n\n if (opt.dictionary) {\n var dict;\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n // If we need to compress text, change encoding to utf8.\n dict = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n this._dict_set = true;\n }\n}\n\n/**\n * Deflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be\n * converted to utf8 byte sequence.\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with\n * new compressed chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the compression context.\n *\n * On fail call [[Deflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * array format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nDeflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var status, _mode;\n\n if (this.ended) { return false; }\n\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // If we need to compress text, change encoding to utf8.\n strm.input = strings.string2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_deflate.deflate(strm, _mode); /* no bad return value */\n\n if (status !== Z_STREAM_END && status !== Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {\n if (this.options.to === 'string') {\n this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH) {\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Deflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nDeflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Deflate#onEnd(status) -> Void\n * - status (Number): deflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called once after you tell deflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nDeflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * deflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * Compress `data` with deflate algorithm and `options`.\n *\n * Supported options are:\n *\n * - level\n * - windowBits\n * - memLevel\n * - strategy\n * - dictionary\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , data = Uint8Array([1,2,3,4,5,6,7,8,9]);\n *\n * console.log(pako.deflate(data));\n * ```\n **/\nfunction deflate(input, options) {\n var deflator = new Deflate(options);\n\n deflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (deflator.err) { throw deflator.msg || msg[deflator.err]; }\n\n return deflator.result;\n}\n\n\n/**\n * deflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate(input, options);\n}\n\n\n/**\n * gzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but create gzip wrapper instead of\n * deflate one.\n **/\nfunction gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate(input, options);\n}\n\n\nexports.Deflate = Deflate;\nexports.deflate = deflate;\nexports.deflateRaw = deflateRaw;\nexports.gzip = gzip;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/deflate.js\n// module id = 25\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar trees = require('./trees');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar msg = require('./messages');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\nvar Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\n//var Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\n//var Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\n//var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n\n/* compression levels */\n//var Z_NO_COMPRESSION = 0;\n//var Z_BEST_SPEED = 1;\n//var Z_BEST_COMPRESSION = 9;\nvar Z_DEFAULT_COMPRESSION = -1;\n\n\nvar Z_FILTERED = 1;\nvar Z_HUFFMAN_ONLY = 2;\nvar Z_RLE = 3;\nvar Z_FIXED = 4;\nvar Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\n//var Z_BINARY = 0;\n//var Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n/*============================================================================*/\n\n\nvar MAX_MEM_LEVEL = 9;\n/* Maximum value for memLevel in deflateInit2 */\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_MEM_LEVEL = 8;\n\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\nvar D_CODES = 30;\n/* number of distance codes */\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\nvar MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);\n\nvar PRESET_DICT = 0x20;\n\nvar INIT_STATE = 42;\nvar EXTRA_STATE = 69;\nvar NAME_STATE = 73;\nvar COMMENT_STATE = 91;\nvar HCRC_STATE = 103;\nvar BUSY_STATE = 113;\nvar FINISH_STATE = 666;\n\nvar BS_NEED_MORE = 1; /* block not completed, need more input or more output */\nvar BS_BLOCK_DONE = 2; /* block flush performed */\nvar BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */\nvar BS_FINISH_DONE = 4; /* finish done, accept no more input or output */\n\nvar OS_CODE = 0x03; // Unix :) . Don't detect, use this default.\n\nfunction err(strm, errorCode) {\n strm.msg = msg[errorCode];\n return errorCode;\n}\n\nfunction rank(f) {\n return ((f) << 1) - ((f) > 4 ? 9 : 0);\n}\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output goes\n * through this function so some applications may wish to modify it\n * to avoid allocating a large strm->output buffer and copying into it.\n * (See also read_buf()).\n */\nfunction flush_pending(strm) {\n var s = strm.state;\n\n //_tr_flush_bits(s);\n var len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) { return; }\n\n utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n}\n\n\nfunction flush_block_only(s, last) {\n trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n}\n\n\nfunction put_byte(s, b) {\n s.pending_buf[s.pending++] = b;\n}\n\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nfunction putShortMSB(s, b) {\n// put_byte(s, (Byte)(b >> 8));\n// put_byte(s, (Byte)(b & 0xff));\n s.pending_buf[s.pending++] = (b >>> 8) & 0xff;\n s.pending_buf[s.pending++] = b & 0xff;\n}\n\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read. All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->input buffer and copying from it.\n * (See also flush_pending()).\n */\nfunction read_buf(strm, buf, start, size) {\n var len = strm.avail_in;\n\n if (len > size) { len = size; }\n if (len === 0) { return 0; }\n\n strm.avail_in -= len;\n\n // zmemcpy(buf, strm->next_in, len);\n utils.arraySet(buf, strm.input, strm.next_in, len, start);\n if (strm.state.wrap === 1) {\n strm.adler = adler32(strm.adler, buf, len, start);\n }\n\n else if (strm.state.wrap === 2) {\n strm.adler = crc32(strm.adler, buf, len, start);\n }\n\n strm.next_in += len;\n strm.total_in += len;\n\n return len;\n}\n\n\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\nfunction longest_match(s, cur_match) {\n var chain_length = s.max_chain_length; /* max hash chain length */\n var scan = s.strstart; /* current string */\n var match; /* matched string */\n var len; /* length of current match */\n var best_len = s.prev_length; /* best match length so far */\n var nice_match = s.nice_match; /* stop if match long enough */\n var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?\n s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;\n\n var _win = s.window; // shortcut\n\n var wmask = s.w_mask;\n var prev = s.prev;\n\n /* Stop when cur_match becomes <= limit. To simplify the code,\n * we prevent matches with the string of window index 0.\n */\n\n var strend = s.strstart + MAX_MATCH;\n var scan_end1 = _win[scan + best_len - 1];\n var scan_end = _win[scan + best_len];\n\n /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n * It is easy to get rid of this optimization if necessary.\n */\n // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n /* Do not waste too much time if we already have a good match: */\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n /* Do not look for matches beyond the end of the input. This is necessary\n * to make deflate deterministic.\n */\n if (nice_match > s.lookahead) { nice_match = s.lookahead; }\n\n // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n do {\n // Assert(cur_match < s->strstart, \"no future\");\n match = cur_match;\n\n /* Skip to next match if the match length cannot increase\n * or if the match length is less than 2. Note that the checks below\n * for insufficient lookahead only occur occasionally for performance\n * reasons. Therefore uninitialized memory will be accessed, and\n * conditional jumps will be made that depend on those values.\n * However the length of the match is limited to the lookahead, so\n * the output of deflate is not affected by the uninitialized values.\n */\n\n if (_win[match + best_len] !== scan_end ||\n _win[match + best_len - 1] !== scan_end1 ||\n _win[match] !== _win[scan] ||\n _win[++match] !== _win[scan + 1]) {\n continue;\n }\n\n /* The check at best_len-1 can be removed because it will be made\n * again later. (This heuristic is not always a win.)\n * It is not necessary to compare scan[2] and match[2] since they\n * are always equal when the other bytes match, given that\n * the hash keys are equal and that HASH_BITS >= 8.\n */\n scan += 2;\n match++;\n // Assert(*scan == *match, \"match[2]?\");\n\n /* We check for insufficient lookahead only every 8th comparison;\n * the 256th check will be made at strstart+258.\n */\n do {\n /*jshint noempty:false*/\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n scan < strend);\n\n // Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n}\n\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n * At least one byte has been read, or avail_in == 0; reads are\n * performed for at least two bytes (required for the zip translate_eol\n * option -- not supported here).\n */\nfunction fill_window(s) {\n var _w_size = s.w_size;\n var p, n, m, more, str;\n\n //Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n do {\n more = s.window_size - s.lookahead - s.strstart;\n\n // JS ints have 32 bit, block below not needed\n /* Deal with !@#$% 64K limit: */\n //if (sizeof(int) <= 2) {\n // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n // more = wsize;\n //\n // } else if (more == (unsigned)(-1)) {\n // /* Very unlikely, but possible on 16 bit machine if\n // * strstart == 0 && lookahead == 1 (input done a byte at time)\n // */\n // more--;\n // }\n //}\n\n\n /* If the window is almost full and there is insufficient lookahead,\n * move the upper half to the lower one to make room in the upper half.\n */\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n\n utils.arraySet(s.window, s.window, _w_size, _w_size, 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n /* we now have strstart >= MAX_DIST */\n s.block_start -= _w_size;\n\n /* Slide the hash table (could be avoided with 32 bit values\n at the expense of memory usage). We slide even when level == 0\n to keep the hash table consistent if we switch back to level > 0\n later. (Using level 0 permanently is not an optimal usage of\n zlib, so we don't care about this pathological case.)\n */\n\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = (m >= _w_size ? m - _w_size : 0);\n } while (--n);\n\n n = _w_size;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = (m >= _w_size ? m - _w_size : 0);\n /* If n is not on any hash chain, prev[n] is garbage but\n * its value will never be used.\n */\n } while (--n);\n\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n\n /* If there was no sliding:\n * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n * more == window_size - lookahead - strstart\n * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n * => more >= window_size - 2*WSIZE + 2\n * In the BIG_MEM or MMAP case (not yet supported),\n * window_size == input_size + MIN_LOOKAHEAD &&\n * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n * Otherwise, window_size == 2*WSIZE so more >= 2.\n * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n */\n //Assert(more >= 2, \"more < 2\");\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n\n /* Initialize the hash value now that we have some input: */\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n\n /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;\n//#if MIN_MATCH != 3\n// Call update_hash() MIN_MATCH-3 more times\n//#endif\n while (s.insert) {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n * but this is not important since only literal bytes will be emitted.\n */\n\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n\n /* If the WIN_INIT bytes after the end of the current data have never been\n * written, then zero those bytes in order to avoid memory check reports of\n * the use of uninitialized (or uninitialised as Julian writes) bytes by\n * the longest match routines. Update the high water mark for the next\n * time through here. WIN_INIT is set to MAX_MATCH since the longest match\n * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n */\n// if (s.high_water < s.window_size) {\n// var curr = s.strstart + s.lookahead;\n// var init = 0;\n//\n// if (s.high_water < curr) {\n// /* Previous high water mark below current data -- zero WIN_INIT\n// * bytes or up to end of window, whichever is less.\n// */\n// init = s.window_size - curr;\n// if (init > WIN_INIT)\n// init = WIN_INIT;\n// zmemzero(s->window + curr, (unsigned)init);\n// s->high_water = curr + init;\n// }\n// else if (s->high_water < (ulg)curr + WIN_INIT) {\n// /* High water mark at or above current data, but below current data\n// * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n// * to end of window, whichever is less.\n// */\n// init = (ulg)curr + WIN_INIT - s->high_water;\n// if (init > s->window_size - s->high_water)\n// init = s->window_size - s->high_water;\n// zmemzero(s->window + s->high_water, (unsigned)init);\n// s->high_water += init;\n// }\n// }\n//\n// Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n// \"not enough room for search\");\n}\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n * This function does not insert new strings in the dictionary since\n * uncompressible data is probably not useful. This function is used\n * only for the level=0 compression option.\n * NOTE: this function should be optimized to avoid extra copying from\n * window to pending_buf.\n */\nfunction deflate_stored(s, flush) {\n /* Stored blocks are limited to 0xffff bytes, pending_buf is limited\n * to pending_buf_size, and each stored block has a 5 byte header:\n */\n var max_block_size = 0xffff;\n\n if (max_block_size > s.pending_buf_size - 5) {\n max_block_size = s.pending_buf_size - 5;\n }\n\n /* Copy as much as possible from input to output: */\n for (;;) {\n /* Fill the window as much as possible: */\n if (s.lookahead <= 1) {\n\n //Assert(s->strstart < s->w_size+MAX_DIST(s) ||\n // s->block_start >= (long)s->w_size, \"slide too late\");\n// if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||\n// s.block_start >= s.w_size)) {\n// throw new Error(\"slide too late\");\n// }\n\n fill_window(s);\n if (s.lookahead === 0 && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n\n if (s.lookahead === 0) {\n break;\n }\n /* flush the current block */\n }\n //Assert(s->block_start >= 0L, \"block gone\");\n// if (s.block_start < 0) throw new Error(\"block gone\");\n\n s.strstart += s.lookahead;\n s.lookahead = 0;\n\n /* Emit a stored block if pending_buf will be full: */\n var max_start = s.block_start + max_block_size;\n\n if (s.strstart === 0 || s.strstart >= max_start) {\n /* strstart == 0 is possible when wraparound on 16-bit machine */\n s.lookahead = s.strstart - max_start;\n s.strstart = max_start;\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n\n\n }\n /* Flush if we may have to slide, otherwise block_start may become\n * negative and the data will be gone:\n */\n if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n\n s.insert = 0;\n\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n\n if (s.strstart > s.block_start) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_NEED_MORE;\n}\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nfunction deflate_fast(s, flush) {\n var hash_head; /* head of the hash chain */\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break; /* flush the current block */\n }\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n * At this point we have always match_length < MIN_MATCH\n */\n if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n }\n if (s.match_length >= MIN_MATCH) {\n // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only\n\n /*** _tr_tally_dist(s, s.strstart - s.match_start,\n s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n\n /* Insert new strings in the hash table only if the match length\n * is not too large. This saves time but degrades compression.\n */\n if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {\n s.match_length--; /* string at strstart already in table */\n do {\n s.strstart++;\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n * always MIN_MATCH bytes ahead.\n */\n } while (--s.match_length !== 0);\n s.strstart++;\n } else\n {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;\n\n//#if MIN_MATCH != 3\n// Call UPDATE_HASH() MIN_MATCH-3 more times\n//#endif\n /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n * matter since it will be recomputed at next deflate call.\n */\n }\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s.window[s.strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nfunction deflate_slow(s, flush) {\n var hash_head; /* head of hash chain */\n var bflush; /* set if current block must be flushed */\n\n var max_insert;\n\n /* Process the input block. */\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n */\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n\n if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&\n s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n\n if (s.match_length <= 5 &&\n (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) {\n\n /* If prev_match is also MIN_MATCH, match_start is garbage\n * but we will ignore the current match anyway.\n */\n s.match_length = MIN_MATCH - 1;\n }\n }\n /* If there was a match at the previous step and the current\n * match is not better, output the previous match:\n */\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n /* Do not insert strings in hash table beyond this. */\n\n //check_match(s, s.strstart-1, s.prev_match, s.prev_length);\n\n /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,\n s.prev_length - MIN_MATCH, bflush);***/\n bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n /* Insert in hash table all strings up to the end of the match.\n * strstart-1 and strstart are already inserted. If there is not\n * enough lookahead, the last two strings are not inserted in\n * the hash table.\n */\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n } else if (s.match_available) {\n /* If there was no match at the previous position, output a\n * single literal. If there was a match but the current match\n * is longer, truncate the previous match to a single literal.\n */\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n if (bflush) {\n /*** FLUSH_BLOCK_ONLY(s, 0) ***/\n flush_block_only(s, false);\n /***/\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n /* There is no previous match to compare with, wait for\n * the next step to decide.\n */\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n //Assert (flush != Z_NO_FLUSH, \"no flush?\");\n if (s.match_available) {\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_BLOCK_DONE;\n}\n\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one. Do not maintain a hash table. (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nfunction deflate_rle(s, flush) {\n var bflush; /* set if current block must be flushed */\n var prev; /* byte at distance one to match */\n var scan, strend; /* scan goes up to strend for length of run */\n\n var _win = s.window;\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the longest run, plus one for the unrolled loop.\n */\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* See how many times the previous byte repeats */\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n /*jshint noempty:false*/\n } while (prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n //Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n }\n\n /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n if (s.match_length >= MIN_MATCH) {\n //check_match(s, s.strstart, s.strstart - 1, s.match_length);\n\n /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nfunction deflate_huff(s, flush) {\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we have a literal to write. */\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n break; /* flush the current block */\n }\n }\n\n /* Output a literal byte */\n s.match_length = 0;\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\nfunction Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n}\n\nvar configuration_table;\n\nconfiguration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast), /* 2 */\n new Config(4, 6, 32, 32, deflate_fast), /* 3 */\n\n new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow), /* 5 */\n new Config(8, 16, 128, 128, deflate_slow), /* 6 */\n new Config(8, 32, 128, 256, deflate_slow), /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow), /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */\n];\n\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nfunction lm_init(s) {\n s.window_size = 2 * s.w_size;\n\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n\n /* Set the default configuration parameters:\n */\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n}\n\n\nfunction DeflateState() {\n this.strm = null; /* pointer back to this zlib stream */\n this.status = 0; /* as the name implies */\n this.pending_buf = null; /* output still pending */\n this.pending_buf_size = 0; /* size of pending_buf */\n this.pending_out = 0; /* next pending byte to output to the stream */\n this.pending = 0; /* nb of bytes in the pending buffer */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.gzhead = null; /* gzip header information to write */\n this.gzindex = 0; /* where in extra, name, or comment */\n this.method = Z_DEFLATED; /* can only be DEFLATED */\n this.last_flush = -1; /* value of flush param for previous deflate call */\n\n this.w_size = 0; /* LZ77 window size (32K by default) */\n this.w_bits = 0; /* log2(w_size) (8..16) */\n this.w_mask = 0; /* w_size - 1 */\n\n this.window = null;\n /* Sliding window. Input bytes are read into the second half of the window,\n * and move to the first half later to keep a dictionary of at least wSize\n * bytes. With this organization, matches are limited to a distance of\n * wSize-MAX_MATCH bytes, but this ensures that IO is always\n * performed with a length multiple of the block size.\n */\n\n this.window_size = 0;\n /* Actual size of window: 2*wSize, except when the user input buffer\n * is directly used as sliding window.\n */\n\n this.prev = null;\n /* Link to older string with same hash index. To limit the size of this\n * array to 64K, this link is maintained only for the last 32K strings.\n * An index in this array is thus a window index modulo 32K.\n */\n\n this.head = null; /* Heads of the hash chains or NIL. */\n\n this.ins_h = 0; /* hash index of string to be inserted */\n this.hash_size = 0; /* number of elements in hash table */\n this.hash_bits = 0; /* log2(hash_size) */\n this.hash_mask = 0; /* hash_size-1 */\n\n this.hash_shift = 0;\n /* Number of bits by which ins_h must be shifted at each input\n * step. It must be such that after MIN_MATCH steps, the oldest\n * byte no longer takes part in the hash key, that is:\n * hash_shift * MIN_MATCH >= hash_bits\n */\n\n this.block_start = 0;\n /* Window position at the beginning of the current output block. Gets\n * negative when the window is moved backwards.\n */\n\n this.match_length = 0; /* length of best match */\n this.prev_match = 0; /* previous match */\n this.match_available = 0; /* set if previous match exists */\n this.strstart = 0; /* start of string to insert */\n this.match_start = 0; /* start of matching string */\n this.lookahead = 0; /* number of valid bytes ahead in window */\n\n this.prev_length = 0;\n /* Length of the best match at previous step. Matches not greater than this\n * are discarded. This is used in the lazy match evaluation.\n */\n\n this.max_chain_length = 0;\n /* To speed up deflation, hash chains are never searched beyond this\n * length. A higher limit improves compression ratio but degrades the\n * speed.\n */\n\n this.max_lazy_match = 0;\n /* Attempt to find a better match only when the current match is strictly\n * smaller than this value. This mechanism is used only for compression\n * levels >= 4.\n */\n // That's alias to max_lazy_match, don't use directly\n //this.max_insert_length = 0;\n /* Insert new strings in the hash table only if the match length is not\n * greater than this length. This saves time but degrades compression.\n * max_insert_length is used only for compression levels <= 3.\n */\n\n this.level = 0; /* compression level (1..9) */\n this.strategy = 0; /* favor or force Huffman coding*/\n\n this.good_match = 0;\n /* Use a faster search when the previous match is longer than this */\n\n this.nice_match = 0; /* Stop searching when current match exceeds this */\n\n /* used by trees.c: */\n\n /* Didn't use ct_data typedef below to suppress compiler warning */\n\n // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */\n // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */\n\n // Use flat array of DOUBLE size, with interleaved fata,\n // because JS does not support effective\n this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);\n this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);\n this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n\n this.l_desc = null; /* desc. for literal tree */\n this.d_desc = null; /* desc. for distance tree */\n this.bl_desc = null; /* desc. for bit length tree */\n\n //ush bl_count[MAX_BITS+1];\n this.bl_count = new utils.Buf16(MAX_BITS + 1);\n /* number of codes at each bit length for an optimal tree */\n\n //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */\n this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */\n zero(this.heap);\n\n this.heap_len = 0; /* number of elements in the heap */\n this.heap_max = 0; /* element of largest frequency */\n /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n * The same heap array is used to build all trees.\n */\n\n this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];\n zero(this.depth);\n /* Depth of each subtree used as tie breaker for trees of equal frequency\n */\n\n this.l_buf = 0; /* buffer index for literals or lengths */\n\n this.lit_bufsize = 0;\n /* Size of match buffer for literals/lengths. There are 4 reasons for\n * limiting lit_bufsize to 64K:\n * - frequencies can be kept in 16 bit counters\n * - if compression is not successful for the first block, all input\n * data is still in the window so we can still emit a stored block even\n * when input comes from standard input. (This can also be done for\n * all blocks if lit_bufsize is not greater than 32K.)\n * - if compression is not successful for a file smaller than 64K, we can\n * even emit a stored file instead of a stored block (saving 5 bytes).\n * This is applicable only for zip (not gzip or zlib).\n * - creating new Huffman trees less frequently may not provide fast\n * adaptation to changes in the input data statistics. (Take for\n * example a binary file with poorly compressible code followed by\n * a highly compressible string table.) Smaller buffer sizes give\n * fast adaptation but have of course the overhead of transmitting\n * trees more frequently.\n * - I can't count above 4\n */\n\n this.last_lit = 0; /* running index in l_buf */\n\n this.d_buf = 0;\n /* Buffer index for distances. To simplify the code, d_buf and l_buf have\n * the same number of elements. To use different lengths, an extra flag\n * array would be necessary.\n */\n\n this.opt_len = 0; /* bit length of current block with optimal trees */\n this.static_len = 0; /* bit length of current block with static trees */\n this.matches = 0; /* number of string matches in current block */\n this.insert = 0; /* bytes at end of window left to insert */\n\n\n this.bi_buf = 0;\n /* Output buffer. bits are inserted starting at the bottom (least\n * significant bits).\n */\n this.bi_valid = 0;\n /* Number of valid bits in bi_buf. All bits above the last valid bit\n * are always zero.\n */\n\n // Used for window memory init. We safely ignore it for JS. That makes\n // sense only for pointers and memory check tools.\n //this.high_water = 0;\n /* High water mark offset in window for initialized bytes -- bytes above\n * this are set to zero in order to avoid memory check warnings when\n * longest match routines access bytes past the input. This is then\n * updated to the new high water mark.\n */\n}\n\n\nfunction deflateResetKeep(strm) {\n var s;\n\n if (!strm || !strm.state) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n\n s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n /* was made negative by deflate(..., Z_FINISH); */\n }\n s.status = (s.wrap ? INIT_STATE : BUSY_STATE);\n strm.adler = (s.wrap === 2) ?\n 0 // crc32(0, Z_NULL, 0)\n :\n 1; // adler32(0, Z_NULL, 0)\n s.last_flush = Z_NO_FLUSH;\n trees._tr_init(s);\n return Z_OK;\n}\n\n\nfunction deflateReset(strm) {\n var ret = deflateResetKeep(strm);\n if (ret === Z_OK) {\n lm_init(strm.state);\n }\n return ret;\n}\n\n\nfunction deflateSetHeader(strm, head) {\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; }\n strm.state.gzhead = head;\n return Z_OK;\n}\n\n\nfunction deflateInit2(strm, level, method, windowBits, memLevel, strategy) {\n if (!strm) { // === Z_NULL\n return Z_STREAM_ERROR;\n }\n var wrap = 1;\n\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n\n if (windowBits < 0) { /* suppress zlib wrapper */\n wrap = 0;\n windowBits = -windowBits;\n }\n\n else if (windowBits > 15) {\n wrap = 2; /* write gzip wrapper instead */\n windowBits -= 16;\n }\n\n\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED ||\n windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n strategy < 0 || strategy > Z_FIXED) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n\n if (windowBits === 8) {\n windowBits = 9;\n }\n /* until 256-byte window bug fixed */\n\n var s = new DeflateState();\n\n strm.state = s;\n s.strm = strm;\n\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n\n s.window = new utils.Buf8(s.w_size * 2);\n s.head = new utils.Buf16(s.hash_size);\n s.prev = new utils.Buf16(s.w_size);\n\n // Don't need mem init magic for JS.\n //s.high_water = 0; /* nothing written to s->window yet */\n\n s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n s.pending_buf_size = s.lit_bufsize * 4;\n\n //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n //s->pending_buf = (uchf *) overlay;\n s.pending_buf = new utils.Buf8(s.pending_buf_size);\n\n // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)\n //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n s.d_buf = 1 * s.lit_bufsize;\n\n //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n s.l_buf = (1 + 2) * s.lit_bufsize;\n\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n\n return deflateReset(strm);\n}\n\nfunction deflateInit(strm, level) {\n return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n}\n\n\nfunction deflate(strm, flush) {\n var old_flush, s;\n var beg, val; // for gzip header write only\n\n if (!strm || !strm.state ||\n flush > Z_BLOCK || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;\n }\n\n s = strm.state;\n\n if (!strm.output ||\n (!strm.input && strm.avail_in !== 0) ||\n (s.status === FINISH_STATE && flush !== Z_FINISH)) {\n return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR);\n }\n\n s.strm = strm; /* just in case */\n old_flush = s.last_flush;\n s.last_flush = flush;\n\n /* Write the header */\n if (s.status === INIT_STATE) {\n\n if (s.wrap === 2) { // GZIP header\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) { // s->gzhead == Z_NULL\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n }\n else {\n put_byte(s, (s.gzhead.text ? 1 : 0) +\n (s.gzhead.hcrc ? 2 : 0) +\n (!s.gzhead.extra ? 0 : 4) +\n (!s.gzhead.name ? 0 : 8) +\n (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 0xff);\n put_byte(s, (s.gzhead.time >> 8) & 0xff);\n put_byte(s, (s.gzhead.time >> 16) & 0xff);\n put_byte(s, (s.gzhead.time >> 24) & 0xff);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, s.gzhead.os & 0xff);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 0xff);\n put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n else // DEFLATE header\n {\n var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;\n var level_flags = -1;\n\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= (level_flags << 6);\n if (s.strstart !== 0) { header |= PRESET_DICT; }\n header += 31 - (header % 31);\n\n s.status = BUSY_STATE;\n putShortMSB(s, header);\n\n /* Save the adler32 of the preset dictionary: */\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n strm.adler = 1; // adler32(0L, Z_NULL, 0);\n }\n }\n\n//#ifdef GZIP\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n\n while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n break;\n }\n }\n put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);\n s.gzindex++;\n }\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (s.gzindex === s.gzhead.extra.length) {\n s.gzindex = 0;\n s.status = NAME_STATE;\n }\n }\n else {\n s.status = NAME_STATE;\n }\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.gzindex = 0;\n s.status = COMMENT_STATE;\n }\n }\n else {\n s.status = COMMENT_STATE;\n }\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.status = HCRC_STATE;\n }\n }\n else {\n s.status = HCRC_STATE;\n }\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n }\n if (s.pending + 2 <= s.pending_buf_size) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n s.status = BUSY_STATE;\n }\n }\n else {\n s.status = BUSY_STATE;\n }\n }\n//#endif\n\n /* Flush as much pending output as possible */\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n /* Since avail_out is 0, deflate will be called again with\n * more output space, but possibly with both pending and\n * avail_in equal to zero. There won't be anything to do,\n * but this is not an error situation so make sure we\n * return OK instead of BUF_ERROR at next call of deflate:\n */\n s.last_flush = -1;\n return Z_OK;\n }\n\n /* Make sure there is something to do and avoid duplicate consecutive\n * flushes. For repeated and useless calls with Z_FINISH, we keep\n * returning Z_STREAM_END instead of Z_BUF_ERROR.\n */\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&\n flush !== Z_FINISH) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* User must not provide more input after the first FINISH: */\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* Start a new block or continue the current one.\n */\n if (strm.avail_in !== 0 || s.lookahead !== 0 ||\n (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {\n var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :\n (s.strategy === Z_RLE ? deflate_rle(s, flush) :\n configuration_table[s.level].func(s, flush));\n\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n /* avoid BUF_ERROR next call, see above */\n }\n return Z_OK;\n /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n * of deflate should use the same flush parameter to make sure\n * that the flush is complete. So we don't have to output an\n * empty block here, this will be done at next call. This also\n * ensures that for a very small output buffer, we emit at most\n * one empty block.\n */\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n trees._tr_align(s);\n }\n else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */\n\n trees._tr_stored_block(s, 0, 0, false);\n /* For a full flush, this empty block will be recognized\n * as a special marker by inflate_sync().\n */\n if (flush === Z_FULL_FLUSH) {\n /*** CLEAR_HASH(s); ***/ /* forget history */\n zero(s.head); // Fill with NIL (= 0);\n\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n return Z_OK;\n }\n }\n }\n //Assert(strm->avail_out > 0, \"bug2\");\n //if (strm.avail_out <= 0) { throw new Error(\"bug2\");}\n\n if (flush !== Z_FINISH) { return Z_OK; }\n if (s.wrap <= 0) { return Z_STREAM_END; }\n\n /* Write the trailer */\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n put_byte(s, (strm.adler >> 16) & 0xff);\n put_byte(s, (strm.adler >> 24) & 0xff);\n put_byte(s, strm.total_in & 0xff);\n put_byte(s, (strm.total_in >> 8) & 0xff);\n put_byte(s, (strm.total_in >> 16) & 0xff);\n put_byte(s, (strm.total_in >> 24) & 0xff);\n }\n else\n {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n\n flush_pending(strm);\n /* If avail_out is zero, the application will call deflate again\n * to flush the rest.\n */\n if (s.wrap > 0) { s.wrap = -s.wrap; }\n /* write the trailer only once! */\n return s.pending !== 0 ? Z_OK : Z_STREAM_END;\n}\n\nfunction deflateEnd(strm) {\n var status;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n status = strm.state.status;\n if (status !== INIT_STATE &&\n status !== EXTRA_STATE &&\n status !== NAME_STATE &&\n status !== COMMENT_STATE &&\n status !== HCRC_STATE &&\n status !== BUSY_STATE &&\n status !== FINISH_STATE\n ) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.state = null;\n\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;\n}\n\n\n/* =========================================================================\n * Initializes the compression dictionary from the given byte\n * sequence without producing any compressed output.\n */\nfunction deflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var s;\n var str, n;\n var wrap;\n var avail;\n var next;\n var input;\n var tmpDict;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n s = strm.state;\n wrap = s.wrap;\n\n if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {\n return Z_STREAM_ERROR;\n }\n\n /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n if (wrap === 1) {\n /* adler32(strm->adler, dictionary, dictLength); */\n strm.adler = adler32(strm.adler, dictionary, dictLength, 0);\n }\n\n s.wrap = 0; /* avoid computing Adler-32 in read_buf */\n\n /* if dictionary would fill window, just replace the history */\n if (dictLength >= s.w_size) {\n if (wrap === 0) { /* already empty otherwise */\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n /* use the tail */\n // dictionary = dictionary.slice(dictLength - s.w_size);\n tmpDict = new utils.Buf8(s.w_size);\n utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n /* insert dictionary into window and hash */\n avail = strm.avail_in;\n next = strm.next_in;\n input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n str = s.strstart;\n n = s.lookahead - (MIN_MATCH - 1);\n do {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK;\n}\n\n\nexports.deflateInit = deflateInit;\nexports.deflateInit2 = deflateInit2;\nexports.deflateReset = deflateReset;\nexports.deflateResetKeep = deflateResetKeep;\nexports.deflateSetHeader = deflateSetHeader;\nexports.deflate = deflate;\nexports.deflateEnd = deflateEnd;\nexports.deflateSetDictionary = deflateSetDictionary;\nexports.deflateInfo = 'pako deflate (from Nodeca project)';\n\n/* Not implemented\nexports.deflateBound = deflateBound;\nexports.deflateCopy = deflateCopy;\nexports.deflateParams = deflateParams;\nexports.deflatePending = deflatePending;\nexports.deflatePrime = deflatePrime;\nexports.deflateTune = deflateTune;\n*/\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/deflate.js\n// module id = 26\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n//var Z_FILTERED = 1;\n//var Z_HUFFMAN_ONLY = 2;\n//var Z_RLE = 3;\nvar Z_FIXED = 4;\n//var Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\nvar Z_BINARY = 0;\nvar Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n/*============================================================================*/\n\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n// From zutil.h\n\nvar STORED_BLOCK = 0;\nvar STATIC_TREES = 1;\nvar DYN_TREES = 2;\n/* The three kinds of block type */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\n/* The minimum and maximum match lengths */\n\n// From deflate.h\n/* ===========================================================================\n * Internal compression state.\n */\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\n\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\n\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\n\nvar D_CODES = 30;\n/* number of distance codes */\n\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\n\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\n\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar Buf_size = 16;\n/* size of bit buffer in bi_buf */\n\n\n/* ===========================================================================\n * Constants\n */\n\nvar MAX_BL_BITS = 7;\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\nvar END_BLOCK = 256;\n/* end of block literal code */\n\nvar REP_3_6 = 16;\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\nvar REPZ_3_10 = 17;\n/* repeat a zero length 3-10 times (3 bits of repeat count) */\n\nvar REPZ_11_138 = 18;\n/* repeat a zero length 11-138 times (7 bits of repeat count) */\n\n/* eslint-disable comma-spacing,array-bracket-spacing */\nvar extra_lbits = /* extra bits for each length code */\n [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];\n\nvar extra_dbits = /* extra bits for each distance code */\n [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];\n\nvar extra_blbits = /* extra bits for each bit length code */\n [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];\n\nvar bl_order =\n [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];\n/* eslint-enable comma-spacing,array-bracket-spacing */\n\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n// We pre-fill arrays with 0 to avoid uninitialized gaps\n\nvar DIST_CODE_LEN = 512; /* see definition of array dist_code below */\n\n// !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1\nvar static_ltree = new Array((L_CODES + 2) * 2);\nzero(static_ltree);\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nvar static_dtree = new Array(D_CODES * 2);\nzero(static_dtree);\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nvar _dist_code = new Array(DIST_CODE_LEN);\nzero(_dist_code);\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nvar _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);\nzero(_length_code);\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nvar base_length = new Array(LENGTH_CODES);\nzero(base_length);\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nvar base_dist = new Array(D_CODES);\nzero(base_dist);\n/* First normalized distance for each code (0 = distance of 1) */\n\n\nfunction StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n\n this.static_tree = static_tree; /* static tree or NULL */\n this.extra_bits = extra_bits; /* extra bits for each code or NULL */\n this.extra_base = extra_base; /* base index for extra_bits */\n this.elems = elems; /* max number of elements in the tree */\n this.max_length = max_length; /* max bit length for the codes */\n\n // show if `static_tree` has data or dummy - needed for monomorphic objects\n this.has_stree = static_tree && static_tree.length;\n}\n\n\nvar static_l_desc;\nvar static_d_desc;\nvar static_bl_desc;\n\n\nfunction TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree; /* the dynamic tree */\n this.max_code = 0; /* largest code with non zero frequency */\n this.stat_desc = stat_desc; /* the corresponding static tree */\n}\n\n\n\nfunction d_code(dist) {\n return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];\n}\n\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\nfunction put_short(s, w) {\n// put_byte(s, (uch)((w) & 0xff));\n// put_byte(s, (uch)((ush)(w) >> 8));\n s.pending_buf[s.pending++] = (w) & 0xff;\n s.pending_buf[s.pending++] = (w >>> 8) & 0xff;\n}\n\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\nfunction send_bits(s, value, length) {\n if (s.bi_valid > (Buf_size - length)) {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> (Buf_size - s.bi_valid);\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n s.bi_valid += length;\n }\n}\n\n\nfunction send_code(s, c, tree) {\n send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);\n}\n\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nfunction bi_reverse(code, len) {\n var res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nfunction bi_flush(s) {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 0xff;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n}\n\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n * above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n * array bl_count contains the frequencies for each bit length.\n * The length opt_len is updated; static_len is also updated if stree is\n * not null.\n */\nfunction gen_bitlen(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var max_code = desc.max_code;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var extra = desc.stat_desc.extra_bits;\n var base = desc.stat_desc.extra_base;\n var max_length = desc.stat_desc.max_length;\n var h; /* heap index */\n var n, m; /* iterate over the tree elements */\n var bits; /* bit length */\n var xbits; /* extra bits */\n var f; /* frequency */\n var overflow = 0; /* number of elements with bit length too large */\n\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n\n /* In a first pass, compute the optimal bit lengths (which may\n * overflow in the case of the bit length tree).\n */\n tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */\n\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1]/*.Len*/ = bits;\n /* We overwrite tree[n].Dad which is no longer needed */\n\n if (n > max_code) { continue; } /* not a leaf node */\n\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2]/*.Freq*/;\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);\n }\n }\n if (overflow === 0) { return; }\n\n // Trace((stderr,\"\\nbit length overflow\\n\"));\n /* This happens for example on obj2 and pic of the Calgary corpus */\n\n /* Find the first bit length which could increase: */\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) { bits--; }\n s.bl_count[bits]--; /* move one leaf down the tree */\n s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */\n s.bl_count[max_length]--;\n /* The brother of the overflow item also moves one step up,\n * but this does not affect bl_count[max_length]\n */\n overflow -= 2;\n } while (overflow > 0);\n\n /* Now recompute all bit lengths, scanning in increasing frequency.\n * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n * lengths instead of fixing only the wrong ones. This idea is taken\n * from 'ar' written by Haruhiko Okumura.)\n */\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) { continue; }\n if (tree[m * 2 + 1]/*.Len*/ !== bits) {\n // Trace((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;\n tree[m * 2 + 1]/*.Len*/ = bits;\n }\n n--;\n }\n }\n}\n\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n * zero code length.\n */\nfunction gen_codes(tree, max_code, bl_count)\n// ct_data *tree; /* the tree to decorate */\n// int max_code; /* largest code with non zero frequency */\n// ushf *bl_count; /* number of codes at each bit length */\n{\n var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */\n var code = 0; /* running code value */\n var bits; /* bit index */\n var n; /* code index */\n\n /* The distribution counts are first used to generate the code values\n * without bit reversal.\n */\n for (bits = 1; bits <= MAX_BITS; bits++) {\n next_code[bits] = code = (code + bl_count[bits - 1]) << 1;\n }\n /* Check that the bit counts in bl_count are consistent. The last code\n * must be all ones.\n */\n //Assert (code + bl_count[MAX_BITS]-1 == (1< length code (0..28) */\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length[code] = length;\n for (n = 0; n < (1 << extra_lbits[code]); n++) {\n _length_code[length++] = code;\n }\n }\n //Assert (length == 256, \"tr_static_init: length != 256\");\n /* Note that the length 255 (match length 258) can be represented\n * in two different ways: code 284 + 5 bits or code 285, so we\n * overwrite length_code[255] to use the best encoding:\n */\n _length_code[length - 1] = code;\n\n /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist[code] = dist;\n for (n = 0; n < (1 << extra_dbits[code]); n++) {\n _dist_code[dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: dist != 256\");\n dist >>= 7; /* from now on, all distances are divided by 128 */\n for (; code < D_CODES; code++) {\n base_dist[code] = dist << 7;\n for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {\n _dist_code[256 + dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n /* Construct the codes of the static literal tree */\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n\n n = 0;\n while (n <= 143) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree[n * 2 + 1]/*.Len*/ = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree[n * 2 + 1]/*.Len*/ = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n /* Codes 286 and 287 do not exist, but we must include them in the\n * tree construction to get a canonical Huffman tree (longest code\n * all ones)\n */\n gen_codes(static_ltree, L_CODES + 1, bl_count);\n\n /* The static distance tree is trivial: */\n for (n = 0; n < D_CODES; n++) {\n static_dtree[n * 2 + 1]/*.Len*/ = 5;\n static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);\n }\n\n // Now data ready and we can init static trees\n static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n\n //static_init_done = true;\n}\n\n\n/* ===========================================================================\n * Initialize a new block.\n */\nfunction init_block(s) {\n var n; /* iterates over tree elements */\n\n /* Initialize the trees. */\n for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }\n\n s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;\n s.opt_len = s.static_len = 0;\n s.last_lit = s.matches = 0;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nfunction bi_windup(s)\n{\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n //put_byte(s, (Byte)s->bi_buf);\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n}\n\n/* ===========================================================================\n * Copy a stored block, storing first the length and its\n * one's complement if requested.\n */\nfunction copy_block(s, buf, len, header)\n//DeflateState *s;\n//charf *buf; /* the input data */\n//unsigned len; /* its length */\n//int header; /* true if block header must be written */\n{\n bi_windup(s); /* align on byte boundary */\n\n if (header) {\n put_short(s, len);\n put_short(s, ~len);\n }\n// while (len--) {\n// put_byte(s, *buf++);\n// }\n utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);\n s.pending += len;\n}\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\nfunction smaller(tree, n, m, depth) {\n var _n2 = n * 2;\n var _m2 = m * 2;\n return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||\n (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));\n}\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nfunction pqdownheap(s, tree, k)\n// deflate_state *s;\n// ct_data *tree; /* the tree to restore */\n// int k; /* node to move down */\n{\n var v = s.heap[k];\n var j = k << 1; /* left son of k */\n while (j <= s.heap_len) {\n /* Set j to the smallest of the two sons: */\n if (j < s.heap_len &&\n smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n /* Exit if v is smaller than both sons */\n if (smaller(tree, v, s.heap[j], s.depth)) { break; }\n\n /* Exchange v with the smallest son */\n s.heap[k] = s.heap[j];\n k = j;\n\n /* And continue down the tree, setting j to the left son of k */\n j <<= 1;\n }\n s.heap[k] = v;\n}\n\n\n// inlined manually\n// var SMALLEST = 1;\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nfunction compress_block(s, ltree, dtree)\n// deflate_state *s;\n// const ct_data *ltree; /* literal tree */\n// const ct_data *dtree; /* distance tree */\n{\n var dist; /* distance of matched string */\n var lc; /* match length or unmatched char (if dist == 0) */\n var lx = 0; /* running index in l_buf */\n var code; /* the code to send */\n var extra; /* number of extra bits to send */\n\n if (s.last_lit !== 0) {\n do {\n dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);\n lc = s.pending_buf[s.l_buf + lx];\n lx++;\n\n if (dist === 0) {\n send_code(s, lc, ltree); /* send a literal byte */\n //Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n } else {\n /* Here, lc is the match length - MIN_MATCH */\n code = _length_code[lc];\n send_code(s, code + LITERALS + 1, ltree); /* send the length code */\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length[code];\n send_bits(s, lc, extra); /* send the extra length bits */\n }\n dist--; /* dist is now the match distance - 1 */\n code = d_code(dist);\n //Assert (code < D_CODES, \"bad d_code\");\n\n send_code(s, code, dtree); /* send the distance code */\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist[code];\n send_bits(s, dist, extra); /* send the extra distance bits */\n }\n } /* literal or match pair ? */\n\n /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n // \"pendingBuf overflow\");\n\n } while (lx < s.last_lit);\n }\n\n send_code(s, END_BLOCK, ltree);\n}\n\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n * and corresponding code. The length opt_len is updated; static_len is\n * also updated if stree is not null. The field max_code is set.\n */\nfunction build_tree(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var elems = desc.stat_desc.elems;\n var n, m; /* iterate over heap elements */\n var max_code = -1; /* largest code with non zero frequency */\n var node; /* new node being created */\n\n /* Construct the initial heap, with least frequent element in\n * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n * heap[0] is not used.\n */\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n\n for (n = 0; n < elems; n++) {\n if (tree[n * 2]/*.Freq*/ !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n\n } else {\n tree[n * 2 + 1]/*.Len*/ = 0;\n }\n }\n\n /* The pkzip format requires that at least one distance code exists,\n * and that at least one bit should be sent even if there is only one\n * possible code. So to avoid special checks later on we force at least\n * two codes of non zero frequency.\n */\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);\n tree[node * 2]/*.Freq*/ = 1;\n s.depth[node] = 0;\n s.opt_len--;\n\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1]/*.Len*/;\n }\n /* node is 0 or 1 so it does not have extra bits */\n }\n desc.max_code = max_code;\n\n /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n * establish sub-heaps of increasing lengths:\n */\n for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }\n\n /* Construct the Huffman tree by repeatedly combining the least two\n * frequent nodes.\n */\n node = elems; /* next internal node of the tree */\n do {\n //pqremove(s, tree, n); /* n = node of least frequency */\n /*** pqremove ***/\n n = s.heap[1/*SMALLEST*/];\n s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];\n pqdownheap(s, tree, 1/*SMALLEST*/);\n /***/\n\n m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */\n\n s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */\n s.heap[--s.heap_max] = m;\n\n /* Create a new node father of n and m */\n tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;\n\n /* and insert the new node in the heap */\n s.heap[1/*SMALLEST*/] = node++;\n pqdownheap(s, tree, 1/*SMALLEST*/);\n\n } while (s.heap_len >= 2);\n\n s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];\n\n /* At this point, the fields freq and dad are set. We can now\n * generate the bit lengths.\n */\n gen_bitlen(s, desc);\n\n /* The field len is now set, we can generate the bit codes */\n gen_codes(tree, max_code, s.bl_count);\n}\n\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nfunction scan_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n s.bl_tree[curlen * 2]/*.Freq*/ += count;\n\n } else if (curlen !== 0) {\n\n if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }\n s.bl_tree[REP_3_6 * 2]/*.Freq*/++;\n\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;\n\n } else {\n s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;\n }\n\n count = 0;\n prevlen = curlen;\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nfunction send_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n /* tree[max_code+1].Len = -1; */ /* guard already set */\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);\n\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n //Assert(count >= 3 && count <= 6, \" 3_6?\");\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nfunction build_bl_tree(s) {\n var max_blindex; /* index of last bit length code of non zero freq */\n\n /* Determine the bit length frequencies for literal and distance trees */\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n\n /* Build the bit length tree: */\n build_tree(s, s.bl_desc);\n /* opt_len now includes the length of the tree representations, except\n * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n */\n\n /* Determine the number of bit length codes to send. The pkzip format\n * requires that at least 4 bit length codes be sent. (appnote.txt says\n * 3 but the actual value used is 4.)\n */\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {\n break;\n }\n }\n /* Update opt_len to include the bit length tree and counts */\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n //Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n // s->opt_len, s->static_len));\n\n return max_blindex;\n}\n\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nfunction send_all_trees(s, lcodes, dcodes, blcodes)\n// deflate_state *s;\n// int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n var rank; /* index in bl_order */\n\n //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n // \"too many codes\");\n //Tracev((stderr, \"\\nbl counts: \"));\n send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */\n for (rank = 0; rank < blcodes; rank++) {\n //Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);\n }\n //Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */\n //Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */\n //Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n}\n\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n * a) There are no non-portable control characters belonging to the\n * \"black list\" (0..6, 14..25, 28..31).\n * b) There is at least one printable character belonging to the\n * \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n * \"gray list\" that is ignored in this detection algorithm:\n * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nfunction detect_data_type(s) {\n /* black_mask is the bit mask of black-listed bytes\n * set bits 0..6, 14..25, and 28..31\n * 0xf3ffc07f = binary 11110011111111111100000001111111\n */\n var black_mask = 0xf3ffc07f;\n var n;\n\n /* Check for non-textual (\"black-listed\") bytes. */\n for (n = 0; n <= 31; n++, black_mask >>>= 1) {\n if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {\n return Z_BINARY;\n }\n }\n\n /* Check for textual (\"white-listed\") bytes. */\n if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||\n s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n }\n\n /* There are no \"black-listed\" or \"white-listed\" bytes:\n * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n */\n return Z_BINARY;\n}\n\n\nvar static_init_done = false;\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nfunction _tr_init(s)\n{\n\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n /* Initialize the first block of the first file: */\n init_block(s);\n}\n\n\n/* ===========================================================================\n * Send a stored block\n */\nfunction _tr_stored_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */\n copy_block(s, buf, stored_len, true); /* with header */\n}\n\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nfunction _tr_align(s) {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree);\n bi_flush(s);\n}\n\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and output the encoded block to the zip file.\n */\nfunction _tr_flush_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block, or NULL if too old */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n var opt_lenb, static_lenb; /* opt_len and static_len in bytes */\n var max_blindex = 0; /* index of last bit length code of non zero freq */\n\n /* Build the Huffman trees unless a stored block is forced */\n if (s.level > 0) {\n\n /* Check if the file is binary or text */\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n\n /* Construct the literal and distance trees */\n build_tree(s, s.l_desc);\n // Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n\n build_tree(s, s.d_desc);\n // Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n /* At this point, opt_len and static_len are the total bit lengths of\n * the compressed block data, excluding the tree representations.\n */\n\n /* Build the bit length tree for the above two trees, and get the index\n * in bl_order of the last bit length code to send.\n */\n max_blindex = build_bl_tree(s);\n\n /* Determine the best encoding. Compute the block lengths in bytes. */\n opt_lenb = (s.opt_len + 3 + 7) >>> 3;\n static_lenb = (s.static_len + 3 + 7) >>> 3;\n\n // Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n // s->last_lit));\n\n if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }\n\n } else {\n // Assert(buf != (char*)0, \"lost buf\");\n opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n }\n\n if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {\n /* 4: two words for the lengths */\n\n /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n * Otherwise we can't have processed more than WSIZE input bytes since\n * the last block flush, because compression would have been\n * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n * transform a block into a stored block.\n */\n _tr_stored_block(s, buf, stored_len, last);\n\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree, static_dtree);\n\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n // Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n /* The above check is made mod 2^32, for files larger than 512 MB\n * and uLong implemented on 32 bits.\n */\n init_block(s);\n\n if (last) {\n bi_windup(s);\n }\n // Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n // s->compressed_len-7*last));\n}\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nfunction _tr_tally(s, dist, lc)\n// deflate_state *s;\n// unsigned dist; /* distance of matched string */\n// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n //var out_length, in_length, dcode;\n\n s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;\n s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;\n\n s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;\n s.last_lit++;\n\n if (dist === 0) {\n /* lc is the unmatched char */\n s.dyn_ltree[lc * 2]/*.Freq*/++;\n } else {\n s.matches++;\n /* Here, lc is the match length - MIN_MATCH */\n dist--; /* dist = match distance - 1 */\n //Assert((ush)dist < (ush)MAX_DIST(s) &&\n // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n // (ush)d_code(dist) < (ush)D_CODES, \"_tr_tally: bad match\");\n\n s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;\n s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n\n//#ifdef TRUNCATE_BLOCK\n// /* Try to guess if it is profitable to stop the current block here */\n// if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {\n// /* Compute an upper bound for the compressed length */\n// out_length = s.last_lit*8;\n// in_length = s.strstart - s.block_start;\n//\n// for (dcode = 0; dcode < D_CODES; dcode++) {\n// out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);\n// }\n// out_length >>>= 3;\n// //Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n// // s->last_lit, in_length, out_length,\n// // 100L - out_length*100L/in_length));\n// if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {\n// return true;\n// }\n// }\n//#endif\n\n return (s.last_lit === s.lit_bufsize - 1);\n /* We avoid equality with lit_bufsize because of wraparound at 64K\n * on 16 bit machines and because stored blocks are restricted to\n * 64K-1 bytes.\n */\n}\n\nexports._tr_init = _tr_init;\nexports._tr_stored_block = _tr_stored_block;\nexports._tr_flush_block = _tr_flush_block;\nexports._tr_tally = _tr_tally;\nexports._tr_align = _tr_align;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/trees.js\n// module id = 27\n// module chunks = 0","'use strict';\n\n\nvar zlib_inflate = require('./zlib/inflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar c = require('./zlib/constants');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\nvar GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = utils.assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== c.Z_OK) {\n throw new Error(msg[status]);\n }\n\n this.header = new GZheader();\n\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = strings.binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */\n\n if (status === c.Z_NEED_DICT && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = strings.string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = zlib_inflate.inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === c.Z_BUF_ERROR && allowBufError === true) {\n status = c.Z_OK;\n allowBufError = false;\n }\n\n if (status !== c.Z_STREAM_END && status !== c.Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);\n\n if (status === c.Z_STREAM_END) {\n _mode = c.Z_FINISH;\n }\n\n // Finalize on the last chunk.\n if (_mode === c.Z_FINISH) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === c.Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === c.Z_SYNC_FLUSH) {\n this.onEnd(c.Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === c.Z_OK) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 aligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction inflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg || msg[inflator.err]; }\n\n return inflator.result;\n}\n\n\n/**\n * inflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n}\n\n\n/**\n * ungzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\nexports.Inflate = Inflate;\nexports.inflate = inflate;\nexports.inflateRaw = inflateRaw;\nexports.ungzip = inflate;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/inflate.js\n// module id = 28\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar inflate_fast = require('./inffast');\nvar inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_WBITS = MAX_WBITS;\n\n\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new utils.Buf16(320); /* temporary storage for code lengths */\n this.work = new utils.Buf16(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);\n state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\nfunction inflateInit(strm) {\n return inflateInit2(strm, DEF_WBITS);\n}\n\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new utils.Buf32(512);\n distfix = new utils.Buf32(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new utils.Buf8(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n utils.arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n utils.arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n utils.arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n utils.arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\nexports.inflateReset = inflateReset;\nexports.inflateReset2 = inflateReset2;\nexports.inflateResetKeep = inflateResetKeep;\nexports.inflateInit = inflateInit;\nexports.inflateInit2 = inflateInit2;\nexports.inflate = inflate;\nexports.inflateEnd = inflateEnd;\nexports.inflateGetHeader = inflateGetHeader;\nexports.inflateSetDictionary = inflateSetDictionary;\nexports.inflateInfo = 'pako inflate (from Nodeca project)';\n\n/* Not implemented\nexports.inflateCopy = inflateCopy;\nexports.inflateGetDictionary = inflateGetDictionary;\nexports.inflateMark = inflateMark;\nexports.inflatePrime = inflatePrime;\nexports.inflateSync = inflateSync;\nexports.inflateSyncPoint = inflateSyncPoint;\nexports.inflateUndermine = inflateUndermine;\n*/\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inflate.js\n// module id = 29\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// See state defs from inflate.js\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\nmodule.exports = function inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inffast.js\n// module id = 30\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\nmodule.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inftrees.js\n// module id = 31\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\nmodule.exports = GZheader;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/gzheader.js\n// module id = 32\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @protected\n */\nvar WeightDecoderRaw = /** @class */ (function () {\n function WeightDecoderRaw() {\n }\n WeightDecoderRaw.prototype.decode = function (data) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, new Float32Array(data.buffer, data.byteOffset, data.byteLength / 4)];\n });\n });\n };\n return WeightDecoderRaw;\n}());\nexports.default = WeightDecoderRaw;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/weight_decoder_raw.js\n// module id = 33\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @private\n */\nvar NOT_SCHEDULED = -1;\n/**\n * Schedule function which is called too much frequently.\n *\n * @private\n */\nvar DispatchScheduler = /** @class */ (function () {\n function DispatchScheduler() {\n this.scheduledCallbackId = NOT_SCHEDULED;\n }\n /**\n * Register scheduled function. If already other function is scheduled, it is canceled and dispatcher will dispatch only\n * function which is registered at last.\n * @param fn scheduled function\n */\n DispatchScheduler.prototype.request = function (fn) {\n var _this = this;\n this.fn = fn;\n if (this.scheduledCallbackId == NOT_SCHEDULED) {\n this.scheduledCallbackId = requestAnimationFrame(function () { return _this.forceDispatch(); });\n }\n };\n /**\n * Dispatch scheduled function just now. If no function is scheduled, dispatcher do nothing.\n */\n DispatchScheduler.prototype.forceDispatch = function () {\n if (this.scheduledCallbackId == NOT_SCHEDULED)\n return;\n this.cancel();\n this.fn();\n };\n /**\n * Cancel scheduled function. If no function is scheduled, dispatcher do nothing.\n */\n DispatchScheduler.prototype.cancel = function () {\n if (this.scheduledCallbackId == NOT_SCHEDULED)\n return;\n cancelAnimationFrame(this.scheduledCallbackId);\n this.scheduledCallbackId = NOT_SCHEDULED;\n };\n return DispatchScheduler;\n}());\nexports.default = DispatchScheduler;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/util/dispatch_scheduler.js\n// module id = 34\n// module chunks = 0","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @protected\n */\nfunction flatten(arr) {\n var result = [];\n for (var i = 0; i < arr.length; i++) {\n var v = arr[i];\n if (v instanceof Array) {\n result.splice(result.length, 0, flatten(v));\n }\n else {\n result[result.length] = v;\n }\n }\n return result;\n}\n/**\n * @protected\n */\nvar SymbolicTypedArray = /** @class */ (function () {\n /**\n * @protected\n */\n function SymbolicTypedArray(buffer, byteOffset, length, placeholderContext) {\n if (buffer === void 0) { buffer = null; }\n if (byteOffset === void 0) { byteOffset = 0; }\n if (placeholderContext === void 0) { placeholderContext = null; }\n this.placeholderContext = placeholderContext;\n this._byteOffset = byteOffset;\n this._buffer = buffer;\n if (buffer) {\n this._length = length === undefined ? (buffer.byteLength / this.BYTES_PER_ELEMENT) : length;\n }\n else {\n if (length === undefined)\n throw Error('\"butter\" or \"length\" must be specified.');\n this._length = length;\n }\n if (this.isDynamic) {\n if (!placeholderContext) {\n throw Error('PlaceholderContext must be required when SymbolicTypedArray is initialized as dynamic buffer view.');\n }\n }\n }\n Object.defineProperty(SymbolicTypedArray.prototype, \"buffer\", {\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n get: function () {\n if (!this._buffer)\n this._buffer = new ArrayBuffer(this.byteOffset + this.byteLength);\n return this._buffer;\n },\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n set: function (buffer) {\n this._buffer = buffer;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(SymbolicTypedArray.prototype, \"byteLength\", {\n /**\n * The length in bytes of the array.\n */\n get: function () {\n return this.length * this.BYTES_PER_ELEMENT;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(SymbolicTypedArray.prototype, \"offset\", {\n /**\n * The number in this buffer. Actual offset size is `(offset * SIZE_OF_FLOAT)`.\n */\n get: function () {\n return this.byteOffset / this.BYTES_PER_ELEMENT;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(SymbolicTypedArray.prototype, \"isDynamic\", {\n /**\n * @protected\n */\n get: function () {\n return (typeof this._byteOffset !== 'number' || typeof this._length !== 'number');\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(SymbolicTypedArray.prototype, \"length\", {\n /**\n * The number of elements in this buffer. Actual byte size is `(length * SIZE_OF_FLOAT)`.\n */\n get: function () {\n if (this.isDynamic) {\n return this.placeholderContext.resolve(this._length);\n }\n else {\n return this._length;\n }\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(SymbolicTypedArray.prototype, \"byteOffset\", {\n /**\n * The offset in bytes of the array.\n */\n get: function () {\n if (this.isDynamic) {\n return this.placeholderContext.resolve(this._byteOffset);\n }\n else {\n return this._byteOffset;\n }\n },\n enumerable: true,\n configurable: true\n });\n /**\n * Returns the this object after copying a section of the array identified by start and end\n * to the same array starting at position target\n * @param target If target is negative, it is treated as length+target where length is the\n * length of the array.\n * @param start If start is negative, it is treated as length+start. If end is negative, it\n * is treated as length+end.\n * @param end If not specified, length of the this object is used as its default value.\n */\n SymbolicTypedArray.prototype.copyWithin = function (target, start, end) {\n this.toActual().copyWithin(target, start, end);\n return this;\n };\n /**\n * Returns the this object after filling the section identified by start and end with value\n * @param value value to fill array section with\n * @param start index to start filling the array at. If start is negative, it is treated as\n * length+start where length is the length of the array.\n * @param end index to stop filling the array at. If end is negative, it is treated as\n * length+end.\n */\n SymbolicTypedArray.prototype.fill = function (value, start, end) {\n this.toActual().fill(value, start, end);\n return this;\n };\n /**\n * Returns the index of the first occurrence of a value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the\n * search starts at index 0.\n */\n SymbolicTypedArray.prototype.indexOf = function (searchElement, fromIndex) {\n return this.toActual().indexOf(searchElement, fromIndex);\n };\n /**\n * Adds all the elements of an array separated by the specified separator string.\n * @param separator A string used to separate one element of an array from the next in the\n * resulting String. If omitted, the array elements are separated with a comma.\n */\n SymbolicTypedArray.prototype.join = function (separator) {\n return this.toActual().join(separator);\n };\n /**\n * Returns the index of the last occurrence of a value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the\n * search starts at index 0.\n */\n SymbolicTypedArray.prototype.lastIndexOf = function (searchElement, fromIndex) {\n return this.toActual().lastIndexOf(searchElement, fromIndex);\n };\n /**\n * Sorts an array.\n * @param compareFn The name of the function used to determine the order of the elements. If\n * omitted, the elements are sorted in ascending, ASCII character order.\n */\n SymbolicTypedArray.prototype.sort = function (compareFn) {\n this.toActual().sort(compareFn);\n return this;\n };\n SymbolicTypedArray.prototype.includes = function (searchElement, fromIndex) {\n return this.toActual().includes(searchElement, fromIndex);\n };\n /**\n * Sets a value or an array of values.\n * @param array A typed or untyped array of values to set.\n * @param offset The index in the current array at which the values are to be written.\n */\n SymbolicTypedArray.prototype.set = function (array, offset) {\n return this.toActual().set(flatten(array), offset);\n };\n /**\n * Converts a number to a string by using the current locale.\n */\n SymbolicTypedArray.prototype.toLocaleString = function () {\n return this.toActual().toLocaleString();\n };\n /**\n * Returns a string representation of an array.\n */\n SymbolicTypedArray.prototype.toString = function () {\n return this.toActual().toString();\n };\n /** @protected */\n SymbolicTypedArray.prototype[Symbol.iterator] = function () {\n return this.toActual()[Symbol.iterator]();\n };\n /**\n * Returns an iterable of key, value pairs for every entry in the array\n */\n SymbolicTypedArray.prototype.entries = function () {\n return this.toActual().entries();\n };\n /**\n * Returns an iterable of keys in the array\n */\n SymbolicTypedArray.prototype.keys = function () {\n return this.toActual().keys();\n };\n /**\n * Returns an iterable of values in the array\n */\n SymbolicTypedArray.prototype.values = function () {\n return this.toActual().values();\n };\n return SymbolicTypedArray;\n}());\nexports.SymbolicTypedArray = SymbolicTypedArray;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/symbolic_typed_array/symbolic_typed_array.js\n// module id = 35\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar localforage = require(\"localforage\");\nvar get_weight_decoder_1 = require(\"../decoder/get_weight_decoder\");\nvar fetch_1 = require(\"../fetch\");\nvar placeholder_1 = require(\"../placeholder\");\nvar symbolic_float32array_1 = require(\"../symbolic_typed_array/symbolic_float32array\");\nvar descriptor_runner_1 = require(\"./descriptor_runner\");\n/**\n * @protected\n */\nvar DescriptorRunnerWebassembly = /** @class */ (function (_super) {\n __extends(DescriptorRunnerWebassembly, _super);\n function DescriptorRunnerWebassembly() {\n var _this = _super.call(this) || this;\n _this.backendName = 'webassembly';\n _this.worker_promise_reject_func = null;\n _this.worker_initial_error = null;\n if (typeof Worker === 'undefined')\n throw new Error('WebWorker is needed for WebAssembly backend');\n if (typeof WebAssembly !== 'object') {\n console.warn('WebAssembly is not supported on this browser, trying to use asm.js code');\n }\n return _this;\n }\n DescriptorRunnerWebassembly.checkAvailability = function () {\n return 'Worker' in window;\n };\n DescriptorRunnerWebassembly.prototype.init = function () {\n if (!DescriptorRunnerWebassembly.checkAvailability())\n throw Error('WebAssembly backend is not supported in this browser.');\n //nothing to do\n return Promise.resolve();\n };\n DescriptorRunnerWebassembly.prototype.setDescriptorAndParameters = function (descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n var kernel_backend, worker_entry_js_path;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.descriptor = descriptor;\n this.placeholderContext = new placeholder_1.default(this.descriptor.placeholders);\n kernel_backend = typeof WebAssembly === 'object' ? 'webassembly' : 'asmjs';\n if (window.navigator.userAgent.indexOf('iPhone OS 11_2') >= 0) {\n // workaround for bug in webassembly\n // https://bugs.webkit.org/show_bug.cgi?id=181781\n kernel_backend = 'asmjs';\n }\n worker_entry_js_path = this.directory + \"/kernels_\" + kernel_backend + \".js\";\n worker_entry_js_path = fetch_1.transformUrl(worker_entry_js_path);\n this.worker_entry_js_path = worker_entry_js_path;\n return [4 /*yield*/, this.compile()];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.loadWeights(new Uint8Array(parameters))];\n case 2:\n _a.sent();\n return [4 /*yield*/, this.getInputViews()];\n case 3:\n //assign buffer to input/output buffer view\n (_a.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 4:\n (_a.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Fetch graph descriptor from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @protected\n */\n DescriptorRunnerWebassembly.prototype.fetchDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.directory = directory;\n return [4 /*yield*/, fetch_1.default(directory + \"/graph_\" + this.backendName + \".json\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, res.json()];\n }\n });\n });\n };\n /**\n * Fetch parameter files from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @param progressCallback callback which is called to notice the loading is progressing.\n * @protected\n */\n DescriptorRunnerWebassembly.prototype.fetchParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var weight_url, weight_fetch;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n weight_url = directory + \"/weight_\" + this.backendName + \".bin\";\n return [4 /*yield*/, fetch_1.default(weight_url)];\n case 1:\n weight_fetch = _a.sent();\n return [2 /*return*/, fetch_1.readArrayBufferProgressively(weight_fetch, progressCallback)];\n }\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebassembly.prototype.restoreCachedDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n this.directory = directory;\n return [2 /*return*/, localforage.getItem(directory + \"_\" + this.backendName + \"_descriptor\").catch(function () { return null; })];\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebassembly.prototype.restoreCachedParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var parameter;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, localforage.getItem(directory + \"_\" + this.backendName + \"_parameters\").catch(function () { return null; })];\n case 1:\n parameter = _a.sent();\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return [2 /*return*/, parameter];\n }\n });\n });\n };\n /**\n * save cache\n */\n DescriptorRunnerWebassembly.prototype.saveCache = function (directory, descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, Promise.all([\n localforage.setItem(directory + \"_\" + this.backendName + \"_descriptor\", descriptor),\n localforage.setItem(directory + \"_\" + this.backendName + \"_parameters\", parameters)\n ])];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n ;\n DescriptorRunnerWebassembly.prototype.setPlaceholderValue = function (values) {\n return __awaiter(this, void 0, void 0, function () {\n var placeholderContext, descriptor, unresolvedValueLists, metaBufferFillList, _loop_1, kernel_order, dynamicBufferSize;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return [2 /*return*/];\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n descriptor = this.descriptor;\n unresolvedValueLists = descriptor.unresolved_value_lists;\n metaBufferFillList = [];\n _loop_1 = function (kernel_order) {\n var unresolvedValueList = unresolvedValueLists[kernel_order];\n unresolvedValueList.forEach(function (offset_placeholder) {\n var resolved_value = placeholderContext.resolve(offset_placeholder.placeholder);\n metaBufferFillList.push(kernel_order, offset_placeholder.offset, resolved_value);\n });\n };\n for (kernel_order = 0; kernel_order < unresolvedValueLists.length; kernel_order++) {\n _loop_1(kernel_order);\n }\n return [4 /*yield*/, this.getInputViews()];\n case 1:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 2:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n dynamicBufferSize = this.placeholderContext.resolve(this.descriptor.memory_layout.dynamic.size);\n return [4 /*yield*/, this.setPlaceholderValueWorker(dynamicBufferSize, new Int32Array(metaBufferFillList))];\n case 3:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerWebassembly.prototype.setPlaceholderValueWorker = function (dynamicBufferSize, metaBufferFillArray) {\n if (!this.worker)\n throw Error(\"Worker is not initialized\");\n var worker = this.worker;\n return new Promise(function (resolve, reject) {\n worker.onmessage = function (event) {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n worker.postMessage({ type: 'set_dynamic_buffer', size: dynamicBufferSize, data: metaBufferFillArray });\n });\n };\n DescriptorRunnerWebassembly.prototype.compile = function () {\n var _this = this;\n var worker = new Worker(this.worker_entry_js_path);\n worker.onerror = function (event) {\n console.error(event);\n // console.error('Worker Exception: ' + event.message);\n if (_this.worker_promise_reject_func) {\n _this.worker_promise_reject_func(event);\n }\n else {\n _this.worker_initial_error = event;\n }\n };\n var promise = new Promise(function (resolve, reject) {\n // occurs when this.worker_entry_js_path is 404\n if (_this.worker_initial_error)\n return reject(_this.worker_initial_error);\n _this.worker_promise_reject_func = reject;\n worker.onmessage = function (event) {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.error(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n });\n this.worker = worker;\n return promise;\n };\n DescriptorRunnerWebassembly.prototype.loadWeights = function (weightsData) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var decoder, weight_data, worker, promise;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.worker)\n throw new Error('Worker is not initialized');\n decoder = get_weight_decoder_1.default(this.descriptor.weight_encoding);\n return [4 /*yield*/, decoder.decode(weightsData)];\n case 1:\n weight_data = _a.sent();\n worker = this.worker;\n promise = new Promise(function (resolve, reject) {\n _this.worker_promise_reject_func = reject;\n worker.onmessage = function (event) {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n worker.postMessage({ type: 'weight', data: weight_data }, [weight_data.buffer]);\n });\n return [2 /*return*/, promise];\n }\n });\n });\n };\n DescriptorRunnerWebassembly.prototype.getInputViews = function () {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, 0, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n };\n DescriptorRunnerWebassembly.prototype.getOutputViews = function () {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, 0, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n };\n DescriptorRunnerWebassembly.prototype.run = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var placeholderContext, descriptor, worker, promise;\n return __generator(this, function (_a) {\n // if (this._running) throw new Error('Calling another run() while running.');\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.worker)\n throw new Error('Worker is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error('Not all placeholder is resolved');\n placeholderContext = this.placeholderContext;\n descriptor = this.descriptor;\n worker = this.worker;\n promise = new Promise(function (resolve, reject) {\n // TODO: better way not to generate function on every run\n _this.worker_promise_reject_func = reject;\n worker.onmessage = function (event) {\n if (Array.isArray(event.data)) {\n for (var i = 0; i < event.data.length; i++) {\n _this.outputs[i].set(event.data[i]);\n }\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n var allocations = [descriptor.memory_layout.static.allocations, descriptor.memory_layout.dynamic.allocations];\n var inputs = [];\n for (var i = 0; i < descriptor.inputs.length; i++) {\n for (var allocation_space = 0; allocation_space < 2; allocation_space++) {\n var var_alloc = allocations[allocation_space][descriptor.inputs[i]];\n if (var_alloc) {\n var symAb = _this.inputs[i];\n inputs.push({\n space: allocation_space,\n offset: placeholderContext.resolve(var_alloc.offset),\n size: symAb.length,\n data: symAb.toActual()\n });\n break;\n }\n }\n }\n var outputs = [];\n for (var i = 0; i < descriptor.outputs.length; i++) {\n for (var allocation_space = 0; allocation_space < 2; allocation_space++) {\n var var_alloc = allocations[allocation_space][descriptor.outputs[i]];\n if (var_alloc) {\n var symAb = _this.outputs[i];\n outputs.push({\n space: allocation_space,\n offset: placeholderContext.resolve(var_alloc.offset),\n size: symAb.length\n });\n break;\n }\n }\n }\n worker.postMessage({ type: 'run', inputs: inputs, outputs: outputs });\n });\n return [2 /*return*/, promise];\n });\n });\n };\n return DescriptorRunnerWebassembly;\n}(descriptor_runner_1.DescriptorRunner));\nexports.default = DescriptorRunnerWebassembly;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webassembly.js\n// module id = 36\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar localforage = require(\"localforage\");\nvar buffer_webgl_1 = require(\"../buffer/buffer_webgl\");\nvar get_weight_decoder_1 = require(\"../decoder/get_weight_decoder\");\nvar fetch_1 = require(\"../fetch\");\nvar placeholder_1 = require(\"../placeholder\");\nvar symbolic_float32array_1 = require(\"../symbolic_typed_array/symbolic_float32array\");\nvar webdnn_1 = require(\"../webdnn\");\nvar webgl_handler_1 = require(\"../webgl_handler\");\nvar descriptor_runner_1 = require(\"./descriptor_runner\");\n// [x y u v] * [upper-left, lower-left, upper-right, lower-right]\n/**\n * @protected\n */\nvar vertexArray = new Float32Array([\n -1, +1,\n -1, -1,\n +1, +1,\n +1, -1,\n]);\n/**\n * @protected\n */\nvar DescriptorRunnerWebGL = /** @class */ (function (_super) {\n __extends(DescriptorRunnerWebGL, _super);\n function DescriptorRunnerWebGL() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.backendName = 'webgl';\n return _this;\n }\n DescriptorRunnerWebGL.checkAvailability = function () {\n return webgl_handler_1.default.checkAvailability();\n };\n DescriptorRunnerWebGL.prototype.init = function () {\n return __awaiter(this, void 0, void 0, function () {\n var vertexBuffer;\n return __generator(this, function (_a) {\n if (!DescriptorRunnerWebGL.checkAvailability())\n throw Error('WebGL backend is not supported in this browser.');\n this.handler = webgl_handler_1.default.getInstance();\n vertexBuffer = this.handler.createArrayBuffer(vertexArray);\n this.handler.bindArrayBuffer(vertexBuffer);\n this.buffers = new Map();\n return [2 /*return*/];\n });\n });\n };\n DescriptorRunnerWebGL.prototype.fetchDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fetch_1.default(directory + \"/graph_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \".json\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, res.json()];\n }\n });\n });\n };\n DescriptorRunnerWebGL.prototype.fetchParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fetch_1.default(directory + \"/weight_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \".bin\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, fetch_1.readArrayBufferProgressively(res, progressCallback)];\n }\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebGL.prototype.restoreCachedDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, localforage.getItem(directory + \"_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \"_descriptor\").catch(function () { return null; })];\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebGL.prototype.restoreCachedParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var parameter;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, localforage.getItem(directory + \"_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \"_parameters\").catch(function () { return null; })];\n case 1:\n parameter = _a.sent();\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return [2 /*return*/, parameter];\n }\n });\n });\n };\n /**\n * save cache\n */\n DescriptorRunnerWebGL.prototype.saveCache = function (directory, descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, Promise.all([\n localforage.setItem(directory + \"_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \"_descriptor\", descriptor),\n localforage.setItem(directory + \"_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \"_parameters\", parameters)\n ])];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n ;\n DescriptorRunnerWebGL.prototype.setDescriptorAndParameters = function (descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.setDescriptor(descriptor)];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.compile()];\n case 2:\n _a.sent();\n return [4 /*yield*/, this.initializeStaticBuffer(parameters)];\n case 3:\n _a.sent();\n if (!(this.placeholderContext && this.placeholderContext.isResolved)) return [3 /*break*/, 5];\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 4:\n _a.sent();\n _a.label = 5;\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerWebGL.prototype.initializeStaticBuffer = function (weightRawArray) {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, decoder, weight, buffers, mapping;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n descriptor = this.descriptor;\n decoder = get_weight_decoder_1.default(this.descriptor.weight_encoding);\n return [4 /*yield*/, decoder.decode(new Uint8Array(weightRawArray))];\n case 1:\n weight = _a.sent();\n buffers = this.buffers;\n mapping = descriptor.memory_layout.mapping;\n Object.entries(descriptor.memory_layout.static.allocations)\n .forEach(function (_a) {\n var name = _a[0], _b = _a[1], width = _b.width, height = _b.height, size = _b.size, channel_mode = _b.channel_mode;\n buffers.set(name, new buffer_webgl_1.default(size * Float32Array.BYTES_PER_ELEMENT, width, height, name, null, channel_mode));\n });\n Object.entries(descriptor.constants_map)\n .forEach(function (_a) {\n var name = _a[0], _b = _a[1], size = _b.size, byte_offset = _b.byte_offset;\n buffers.get(name).array.set(new Float32Array(weight.buffer, byte_offset, size));\n });\n return [4 /*yield*/, this.getInputViews()];\n case 2:\n (_a.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = buffers.get(mapping[view.name]).getWriteView(0, view.length, Float32Array).buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 3:\n (_a.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = buffers.get(mapping[view.name]).getReadView(0, view.length, Float32Array).buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerWebGL.prototype.initializeDynamicBuffer = function () {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, placeholderContext, buffers, mapping;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n if (!this.placeholderContext)\n throw Error(\"PlaceholderContext is not initialized.\");\n descriptor = this.descriptor;\n placeholderContext = this.placeholderContext;\n buffers = this.buffers;\n mapping = descriptor.memory_layout.mapping;\n Object.entries(descriptor.memory_layout.dynamic.allocations)\n .forEach(function (_a) {\n var name = _a[0], _b = _a[1], width = _b.width, height = _b.height, size = _b.size, channel_mode = _b.channel_mode;\n buffers.set(name, new buffer_webgl_1.default(placeholderContext.resolve(size) * Float32Array.BYTES_PER_ELEMENT, placeholderContext.resolve(width), placeholderContext.resolve(height), name, null, channel_mode));\n });\n return [4 /*yield*/, this.getInputViews()];\n case 1:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = buffers.get(mapping[view.name]).getWriteView(0, placeholderContext.resolve(view.length), Float32Array).buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 2:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = buffers.get(mapping[view.name]).getReadView(0, placeholderContext.resolve(view.length), Float32Array).buffer;\n });\n this.buildPipeline();\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerWebGL.prototype.setDescriptor = function (descriptor) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n this.descriptor = descriptor;\n //reset all datum depend on old descriptor\n this.placeholderContext = new placeholder_1.default(descriptor.placeholders);\n return [2 /*return*/];\n });\n });\n };\n DescriptorRunnerWebGL.prototype.compile = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var descriptor;\n return __generator(this, function (_a) {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n descriptor = this.descriptor;\n this.programs = new Map();\n this.vertexShader = this.handler.createVertexShader(\"\\n precision highp float;\\n attribute vec2 _xy;\\n void main() { \\n gl_Position = vec4(_xy, 0, 1); \\n }\\n \");\n Object.keys(descriptor.shader_sources)\n .forEach(function (name) {\n var fragmentShader = _this.handler.createFragmentShader(descriptor.shader_sources[name]);\n var program = _this.handler.createProgram(_this.vertexShader, fragmentShader);\n _this.programs.set(name, program);\n });\n return [2 /*return*/];\n });\n });\n };\n DescriptorRunnerWebGL.prototype.setPlaceholderValue = function (values) {\n return __awaiter(this, void 0, void 0, function () {\n var placeholderContext;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return [2 /*return*/];\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 1:\n _a.sent();\n // resolve placeholders in execution info\n if (Object.keys(this.descriptor.placeholders).length > 0)\n throw Error('Currently, WebGL backend doesn\\'t support Placeholder feature.');\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerWebGL.prototype.getInputViews = function () {\n var _this = this;\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n var mapping = this.descriptor.memory_layout.mapping;\n this.inputs = descriptor.inputs.map(function (name) {\n var view = new symbolic_float32array_1.default(null, 0, _this.buffers.get(mapping[name]).length, placeholderContext);\n view.name = name;\n return view;\n });\n return this.inputs;\n };\n DescriptorRunnerWebGL.prototype.getOutputViews = function () {\n var _this = this;\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n var mapping = this.descriptor.memory_layout.mapping;\n this.outputs = descriptor.outputs.map(function (name) {\n var view = new symbolic_float32array_1.default(null, 0, _this.buffers.get(mapping[name]).length, placeholderContext);\n view.name = name;\n return view;\n });\n return this.outputs;\n };\n DescriptorRunnerWebGL.prototype.buildPipeline = function () {\n var _this = this;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(\"Not all placeholders are resolved: \" + this.placeholderContext);\n var gl = this.handler.gl;\n var buffers = this.buffers;\n var mapping = this.descriptor.memory_layout.mapping;\n var referenceCount = new Map();\n this.runtimeInfo = {\n inputs: this.getInputViews().map(function (view) { return buffers.get(mapping[view.name]); }),\n outputs: this.getOutputViews().map(function (view) { return buffers.get(mapping[view.name]); }),\n programs: this.descriptor.exec_infos.map(function (execInfo) {\n // inputs\n var inputs = execInfo.inputs.map(function (input) {\n var buffer = buffers.get(mapping[input.variable_name]);\n if (!referenceCount.has(buffer))\n referenceCount.set(buffer, 0);\n referenceCount.set(buffer, referenceCount.get(buffer) + 1);\n return {\n buffer: buffer,\n uniformIndex: input.value\n };\n });\n //output\n var output = buffers.get(mapping[execInfo.output]);\n // shader\n var program = _this.programs.get(execInfo.shader_name);\n _this.handler.useProgram(program);\n // uniforms\n var uniforms = Object.keys(execInfo.uniforms).map(function (name) {\n var _a = execInfo.uniforms[name], type = _a.type, value = _a.value;\n switch (type) {\n case 'int':\n return {\n func: gl.uniform1i,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'float':\n return {\n func: gl.uniform1f,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec2':\n return {\n func: gl.uniform2fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec3':\n return {\n func: gl.uniform3fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec4':\n return {\n func: gl.uniform4fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec2':\n return {\n func: gl.uniform2iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec3':\n return {\n func: gl.uniform3iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec4':\n return {\n func: gl.uniform4iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'sampler2D':\n return {\n func: gl.uniform1i,\n args: [gl.getUniformLocation(program, name), value]\n };\n default:\n throw TypeError(\"Incompatible type for uniform parameter: \" + type);\n }\n });\n // attributes\n var xyAttribLoc = gl.getAttribLocation(program, '_xy');\n // run\n return {\n program: program,\n frameBuffer: _this.handler.createFrameBuffer(),\n name: execInfo.shader_name,\n width: output.textureWidth,\n height: output.textureHeight,\n inputs: inputs,\n output: output,\n xyAttribLoc: xyAttribLoc,\n uniforms: uniforms,\n disposable: []\n };\n })\n };\n var _loop_1 = function (runtimeProgramInfo) {\n runtimeProgramInfo.inputs.forEach(function (_a) {\n var buffer = _a.buffer;\n var count = referenceCount.get(buffer) - 1;\n if (count == 0) {\n runtimeProgramInfo.disposable.push(buffer);\n }\n referenceCount.set(buffer, count);\n });\n };\n for (var _i = 0, _a = this.runtimeInfo.programs; _i < _a.length; _i++) {\n var runtimeProgramInfo = _a[_i];\n _loop_1(runtimeProgramInfo);\n }\n };\n DescriptorRunnerWebGL.prototype.run = function () {\n return __awaiter(this, void 0, void 0, function () {\n var gl, runtimeInfo, _i, _a, buffer, records, totalElapsedTime_1, _b, _c, runtimeProgramInfo, start, _d, _e, _f, buffer, uniformIndex, _g, _h, uniform, elapsedTime, xs, _j, _k, buffer, y, summary, _l, _m, runtimeProgramInfo, _o, _p, _q, buffer, uniformIndex, _r, _s, uniform, _t, _u, buffer, _v, _w, buffer;\n return __generator(this, function (_x) {\n switch (_x.label) {\n case 0:\n // if (this._running) throw new Error('Calling another run() while running.');\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(\"Not all placeholders are resolved: \" + this.placeholderContext);\n gl = this.handler.gl;\n runtimeInfo = this.runtimeInfo;\n if (!(this.runtimeInfo.programs.length > 0)) return [3 /*break*/, 29];\n _i = 0, _a = runtimeInfo.inputs;\n _x.label = 1;\n case 1:\n if (!(_i < _a.length)) return [3 /*break*/, 4];\n buffer = _a[_i];\n return [4 /*yield*/, buffer.syncWriteViews()];\n case 2:\n _x.sent();\n _x.label = 3;\n case 3:\n _i++;\n return [3 /*break*/, 1];\n case 4:\n if (!webdnn_1.getConfiguration('DEBUG', false)) return [3 /*break*/, 18];\n records = [];\n totalElapsedTime_1 = 0;\n _b = 0, _c = runtimeInfo.programs;\n _x.label = 5;\n case 5:\n if (!(_b < _c.length)) return [3 /*break*/, 17];\n runtimeProgramInfo = _c[_b];\n start = performance.now();\n this.handler.bindFrameBuffer(runtimeProgramInfo.frameBuffer, runtimeProgramInfo.width, runtimeProgramInfo.height);\n _d = 0, _e = runtimeProgramInfo.inputs;\n _x.label = 6;\n case 6:\n if (!(_d < _e.length)) return [3 /*break*/, 9];\n _f = _e[_d], buffer = _f.buffer, uniformIndex = _f.uniformIndex;\n return [4 /*yield*/, buffer.bindToReadTexture(uniformIndex)];\n case 7:\n _x.sent();\n _x.label = 8;\n case 8:\n _d++;\n return [3 /*break*/, 6];\n case 9:\n // output\n runtimeProgramInfo.output.bindToDrawTexture();\n // shader\n this.handler.useProgram(runtimeProgramInfo.program);\n // uniforms\n for (_g = 0, _h = runtimeProgramInfo.uniforms; _g < _h.length; _g++) {\n uniform = _h[_g];\n uniform.func.apply(gl, uniform.args);\n }\n // attribute\n gl.vertexAttribPointer(runtimeProgramInfo.xyAttribLoc, 2, gl.FLOAT, true, 8, 0);\n gl.enableVertexAttribArray(runtimeProgramInfo.xyAttribLoc);\n // run\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertexArray.length / 2);\n return [4 /*yield*/, this.handler.waitForComplete()];\n case 10:\n _x.sent();\n elapsedTime = performance.now() - start;\n totalElapsedTime_1 += elapsedTime;\n xs = [];\n _j = 0, _k = runtimeProgramInfo.inputs;\n _x.label = 11;\n case 11:\n if (!(_j < _k.length)) return [3 /*break*/, 14];\n buffer = _k[_j].buffer;\n buffer.unbindFromReadTexture();\n return [4 /*yield*/, buffer.syncReadViews()];\n case 12:\n _x.sent();\n xs.push(buffer.array.slice());\n _x.label = 13;\n case 13:\n _j++;\n return [3 /*break*/, 11];\n case 14:\n runtimeProgramInfo.output.unbindFromDrawTexture();\n return [4 /*yield*/, runtimeProgramInfo.output.syncReadViews()];\n case 15:\n _x.sent();\n y = runtimeProgramInfo.output.array.slice();\n records.push({\n 'Kernel': runtimeProgramInfo.name,\n 'Elapsed time [ms]': elapsedTime,\n 'xs': xs,\n 'y': y\n });\n _x.label = 16;\n case 16:\n _b++;\n return [3 /*break*/, 5];\n case 17:\n summary = Array.from(Object.values(records.reduce(function (summary, record) {\n if (!(record['Kernel'] in summary)) {\n summary[record['Kernel']] = {\n 'Kernel': record['Kernel'],\n 'Count': 0,\n 'Elapsed time [ms]': 0,\n };\n }\n summary[record['Kernel']]['Count']++;\n summary[record['Kernel']]['Elapsed time [ms]'] += record['Elapsed time [ms]'];\n return summary;\n }, {})));\n summary.forEach(function (record) { return record['Ratio [%]'] = (record['Elapsed time [ms]'] / totalElapsedTime_1).toFixed(2); });\n console.table(records);\n console.table(summary);\n return [3 /*break*/, 25];\n case 18:\n _l = 0, _m = runtimeInfo.programs;\n _x.label = 19;\n case 19:\n if (!(_l < _m.length)) return [3 /*break*/, 25];\n runtimeProgramInfo = _m[_l];\n this.handler.bindFrameBuffer(runtimeProgramInfo.frameBuffer, runtimeProgramInfo.width, runtimeProgramInfo.height);\n _o = 0, _p = runtimeProgramInfo.inputs;\n _x.label = 20;\n case 20:\n if (!(_o < _p.length)) return [3 /*break*/, 23];\n _q = _p[_o], buffer = _q.buffer, uniformIndex = _q.uniformIndex;\n return [4 /*yield*/, buffer.bindToReadTexture(uniformIndex)];\n case 21:\n _x.sent();\n _x.label = 22;\n case 22:\n _o++;\n return [3 /*break*/, 20];\n case 23:\n // output\n runtimeProgramInfo.output.bindToDrawTexture();\n // shader\n this.handler.useProgram(runtimeProgramInfo.program);\n // uniforms\n for (_r = 0, _s = runtimeProgramInfo.uniforms; _r < _s.length; _r++) {\n uniform = _s[_r];\n uniform.func.apply(gl, uniform.args);\n }\n // attribute\n gl.vertexAttribPointer(runtimeProgramInfo.xyAttribLoc, 2, gl.FLOAT, true, 8, 0);\n gl.enableVertexAttribArray(runtimeProgramInfo.xyAttribLoc);\n // run\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertexArray.length / 2);\n // release buffers and binding\n // for (let buffer of runtimeProgramInfo.disposable) buffer.releaseGPUMemory();\n for (_t = 0, _u = runtimeProgramInfo.inputs; _t < _u.length; _t++) {\n buffer = _u[_t].buffer;\n buffer.unbindFromReadTexture();\n }\n runtimeProgramInfo.output.unbindFromDrawTexture();\n _x.label = 24;\n case 24:\n _l++;\n return [3 /*break*/, 19];\n case 25:\n _v = 0, _w = runtimeInfo.outputs;\n _x.label = 26;\n case 26:\n if (!(_v < _w.length)) return [3 /*break*/, 29];\n buffer = _w[_v];\n return [4 /*yield*/, buffer.syncReadViews()];\n case 27:\n _x.sent();\n _x.label = 28;\n case 28:\n _v++;\n return [3 /*break*/, 26];\n case 29: return [2 /*return*/];\n }\n });\n });\n };\n return DescriptorRunnerWebGL;\n}(descriptor_runner_1.DescriptorRunner));\nexports.default = DescriptorRunnerWebGL;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webgl.js\n// module id = 37\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar webgl_handler_1 = require(\"../webgl_handler\");\nvar buffer_1 = require(\"./buffer\");\n/**\n * @protected\n */\nvar BufferWebGL = /** @class */ (function (_super) {\n __extends(BufferWebGL, _super);\n function BufferWebGL(byteLength, textureWidth, textureHeight, name, array, channelMode) {\n var _this = _super.call(this, byteLength, 'webgl') || this;\n _this._texture = null;\n _this.readTextureUnitIndices = [];\n _this.isBoundToDrawFrameBuffer = false;\n _this.handler = webgl_handler_1.default.getInstance();\n _this.name = name;\n _this.channelMode = channelMode;\n switch (channelMode) {\n case 'RGBA':\n _this.elementsPerPixel = 4;\n break;\n case 'R':\n _this.elementsPerPixel = 1;\n break;\n default:\n throw Error('Unknown channel mode');\n }\n if (webgl_handler_1.isWebGL2(_this.handler.gl)) {\n switch (channelMode) {\n case 'RGBA':\n _this.textureFormat = _this.handler.gl.RGBA;\n _this.textureInternalFormat = _this.handler.gl.RGBA32F;\n _this.pixelStride = 4;\n break;\n case 'R':\n _this.textureFormat = _this.handler.gl.RED;\n _this.textureInternalFormat = _this.handler.gl.R32F;\n _this.pixelStride = 1;\n break;\n default:\n throw Error('Unknown channel mode');\n }\n }\n else {\n // In WebGL1, always RGBA channel mode is specified. If R channel mode is specified in graph descriptor,\n // other 3 channels are not used.\n _this.textureFormat = _this.handler.gl.RGBA;\n _this.textureInternalFormat = _this.handler.gl.RGBA;\n _this.pixelStride = 4;\n }\n if (_this.pixelStride < _this.elementsPerPixel)\n throw Error('elementsPerPixel must be smaller than pixelStride');\n _this.array = array || new Float32Array(_this.length);\n _this.textureWidth = textureWidth;\n _this.textureHeight = textureHeight;\n return _this;\n }\n Object.defineProperty(BufferWebGL.prototype, \"texture\", {\n get: function () {\n return this._texture;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(BufferWebGL.prototype, \"length\", {\n get: function () {\n return this.byteLength / Float32Array.BYTES_PER_ELEMENT;\n },\n enumerable: true,\n configurable: true\n });\n /**\n * Write contents onto specified position synchronously.\n *\n * @param {ArrayBufferView} src contents source buffer\n * @param {number} offset position where contents are written on\n */\n BufferWebGL.prototype.write = function (src, offset) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.array.set(src, offset);\n return [4 /*yield*/, this.syncWriteViews()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Read contents from specified position synchronously.\n *\n * @param {Float32ArrayConstructor | Int32ArrayConstructor} dst buffer where contents are written on\n * @param {number} offset position where contents are read from\n * @param {length} length contents length\n */\n BufferWebGL.prototype.read = function (dst, offset, length) {\n if (offset === void 0) { offset = 0; }\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (dst !== Float32Array)\n throw new Error('Currently, only Float32Array is supported for parameter \\'dst\\'.');\n return [4 /*yield*/, this.syncReadViews()];\n case 1:\n _a.sent();\n new Float32Array(this.array.buffer, offset * Float32Array.BYTES_PER_ELEMENT, length);\n return [2 /*return*/];\n }\n });\n });\n };\n BufferWebGL.prototype.getWriteView = function (offset, length, type) {\n return new type(this.array.buffer, offset * type.BYTES_PER_ELEMENT, length);\n };\n ;\n BufferWebGL.prototype.getReadView = function (offset, length, type) {\n return new type(this.array.buffer, offset * type.BYTES_PER_ELEMENT, length);\n };\n /**\n * Sync buffered data into memory.\n *\n * @see Buffer#getWriteView\n */\n BufferWebGL.prototype.syncWriteViews = function () {\n return __awaiter(this, void 0, void 0, function () {\n var gl, tmp, tmp2;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n gl = this.handler.gl;\n if (!this.texture)\n this.allocateTexture();\n tmp = this.pack(this.array);\n if (tmp.length != this.textureWidth * this.textureHeight * this.pixelStride) {\n tmp2 = new Float32Array(this.textureWidth * this.textureHeight * this.elementsPerPixel);\n tmp2.set(tmp, 0);\n tmp = tmp2;\n }\n return [4 /*yield*/, this.bindToReadTexture(9)];\n case 1:\n _a.sent(); //TODO: texture unit 9 is always available?\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.textureWidth, this.textureHeight, this.textureFormat, gl.FLOAT, tmp);\n this.unbindFromReadTexture();\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Sync memory data into buffer view.\n *\n * @see Buffer#getReadView\n */\n BufferWebGL.prototype.syncReadViews = function () {\n return __awaiter(this, void 0, void 0, function () {\n var gl, ELEMENT_PER_PIXEL, FORMAT, tmp;\n return __generator(this, function (_a) {\n gl = this.handler.gl;\n ELEMENT_PER_PIXEL = 4;\n FORMAT = gl.RGBA;\n tmp = new Float32Array(this.textureWidth * this.textureHeight * ELEMENT_PER_PIXEL);\n this.bindToDrawTexture();\n gl.readPixels(0, 0, this.textureWidth, this.textureHeight, FORMAT, gl.FLOAT, tmp);\n this.unbindFromDrawTexture();\n tmp = this.unpack(tmp);\n this.array.set(tmp.slice(0, this.length), 0);\n return [2 /*return*/];\n });\n });\n };\n BufferWebGL.prototype.bindToReadTexture = function (unit) {\n return __awaiter(this, void 0, void 0, function () {\n var gl;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (this.isBoundToDrawFrameBuffer)\n throw Error('This buffer is already registered as draw buffer. ' +\n 'You may forgot to unbind the binding while previous operations.');\n gl = this.handler.gl;\n if (!!this.texture) return [3 /*break*/, 2];\n this.allocateTexture();\n return [4 /*yield*/, this.syncWriteViews()];\n case 1:\n _a.sent();\n _a.label = 2;\n case 2:\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n this.readTextureUnitIndices.push(unit);\n return [2 /*return*/];\n }\n });\n });\n };\n BufferWebGL.prototype.unbindFromReadTexture = function () {\n var gl = this.handler.gl;\n for (var _i = 0, _a = this.readTextureUnitIndices; _i < _a.length; _i++) {\n var unit = _a[_i];\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n this.readTextureUnitIndices = [];\n };\n BufferWebGL.prototype.bindToDrawTexture = function () {\n if (this.readTextureUnitIndices.length > 0)\n throw Error('This buffer is already registered as read buffer. ' +\n 'You cannot bind a texture as both read and draw texture buffer at same time.');\n if (this.isBoundToDrawFrameBuffer)\n throw Error('This buffer is already registered as draw buffer. ' +\n 'You may forgot to unbind the binding while previous operations.');\n var gl = this.handler.gl;\n if (!this.texture)\n this.allocateTexture();\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0);\n this.isBoundToDrawFrameBuffer = true;\n };\n BufferWebGL.prototype.unbindFromDrawTexture = function () {\n if (!this.isBoundToDrawFrameBuffer)\n return;\n var gl = this.handler.gl;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);\n this.isBoundToDrawFrameBuffer = false;\n };\n BufferWebGL.prototype.pack = function (array) {\n var elementStride = this.pixelStride / this.elementsPerPixel;\n if (elementStride === 1) {\n return new Float32Array(array);\n }\n else {\n var result = new Float32Array(array.length * elementStride);\n for (var i = 0; i < array.length; i++)\n result[i * elementStride] = array[i];\n return result;\n }\n };\n BufferWebGL.prototype.unpack = function (array) {\n // FIXME(Kiikurage): more readable code\n var PIXEL_STRIDE = 4;\n var elementStride = PIXEL_STRIDE / this.elementsPerPixel;\n if (elementStride === 1) {\n return new Float32Array(array);\n }\n else {\n var result = new Float32Array(array.length / elementStride);\n for (var i = 0; i < array.length / elementStride; i++)\n result[i] = array[i * elementStride];\n return result;\n }\n };\n BufferWebGL.prototype.allocateTexture = function () {\n if (this.texture)\n throw Error('Texture is already allocated.');\n this._texture = this.handler.createTexture(this.textureWidth, this.textureHeight, this.textureInternalFormat, this.textureFormat);\n };\n return BufferWebGL;\n}(buffer_1.Buffer));\nexports.default = BufferWebGL;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer_webgl.js\n// module id = 38\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar localforage = require(\"localforage\");\nvar buffer_webgpu_1 = require(\"../buffer/buffer_webgpu\");\nvar get_weight_decoder_1 = require(\"../decoder/get_weight_decoder\");\nvar fetch_1 = require(\"../fetch\");\nvar placeholder_1 = require(\"../placeholder\");\nvar symbolic_float32array_1 = require(\"../symbolic_typed_array/symbolic_float32array\");\nvar webdnn_1 = require(\"../webdnn\");\nvar webgpu_handler_1 = require(\"../webgpu_handler\");\nvar descriptor_runner_1 = require(\"./descriptor_runner\");\n/**\n * Check this device is iOS devices or not.\n * @private\n */\nvar IS_IOS = navigator.userAgent.includes('iPhone') || navigator.userAgent.includes('iPad');\n/**\n * DescriptorRunner for WebGPU\n * @protected\n */\nvar DescriptorRunnerWebGPU = /** @class */ (function (_super) {\n __extends(DescriptorRunnerWebGPU, _super);\n function DescriptorRunnerWebGPU() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n /**\n * backend name\n */\n _this.backendName = 'webgpu';\n return _this;\n }\n /**\n * Return `true` if this backend is available in this environment.\n * @returns {boolean}\n */\n DescriptorRunnerWebGPU.checkAvailability = function () {\n return webgpu_handler_1.IS_WEBGPU_SUPPORTED;\n };\n /**\n * Initialize descriptor runner asynchronously\n * @returns {Promise} Promise object which is resolved when the initialization finished.\n */\n DescriptorRunnerWebGPU.prototype.init = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.webgpuHandler = webgpu_handler_1.default.getInstance();\n return [4 /*yield*/, this.checkIncompatibleGPU()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Check whether current GPU is supported or not. If it's not supported, an error is thrown.\n * @returns {Promise}\n */\n DescriptorRunnerWebGPU.prototype.checkIncompatibleGPU = function () {\n return __awaiter(this, void 0, void 0, function () {\n var buffer, threadExecutionWidth;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n /**\n * It is reported that AMD GPU crashes when performing sgemm (matrix multiplication).\n * Until this problem is solved, blocking WebGPU backend in the environment is needed.\n * API in WebGPU does not directly gives hardware information, so trying to determine hardware heuristically.\n *\n * Criteria: thread_execution_width == 32 is required\n * (on AMD FirePro D500, thread_execution_width == 64)\n *\n * @see https://github.com/mil-tokyo/webdnn/issues/286\n */\n this.webgpuHandler.loadKernel(\"\\n#include \\nusing namespace metal;\\n kernel void check_compatibility(\\n device uint *A[[buffer(0)]],\\n uint global_index[[thread_position_in_grid]],\\n uint thread_execution_width[[thread_execution_width]]\\n ){\\n if (global_index == 0) {\\n A[0] = thread_execution_width;\\n }\\n }\", 'basic');\n buffer = this.webgpuHandler.createBuffer(new Uint32Array(1));\n return [4 /*yield*/, this.webgpuHandler.executeSinglePipelineState('basic.check_compatibility', { width: 1, height: 1, depth: 1 }, { width: 1, height: 1, depth: 1 }, [buffer], true)];\n case 1:\n _a.sent();\n threadExecutionWidth = (new Uint32Array(buffer.contents))[0];\n if (threadExecutionWidth != 32) {\n throw new Error(\"Sorry, this GPU does not compatible with WebGPU (thread_execution_width == \" + threadExecutionWidth + \". See checkIncompatibleGPU method of https://github.com/mil-tokyo/webdnn/blob/master/src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.ts\");\n }\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Fetch graph descriptor from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @protected\n */\n DescriptorRunnerWebGPU.prototype.fetchDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fetch_1.default(directory + \"/graph_\" + this.backendName + \".json\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, res.json()];\n }\n });\n });\n };\n /**\n * Fetch parameter files from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @param progressCallback callback which is called to notice the loading is progressing.\n * @protected\n */\n DescriptorRunnerWebGPU.prototype.fetchParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fetch_1.default(directory + \"/weight_\" + this.backendName + \".bin\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, fetch_1.readArrayBufferProgressively(res, progressCallback)];\n }\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebGPU.prototype.restoreCachedDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, localforage.getItem(directory + \"_\" + this.backendName + \"_descriptor\").catch(function () { return null; })];\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebGPU.prototype.restoreCachedParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var parameter;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, localforage.getItem(directory + \"_\" + this.backendName + \"_parameters\").catch(function () { return null; })];\n case 1:\n parameter = _a.sent();\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return [2 /*return*/, parameter];\n }\n });\n });\n };\n /**\n * save cache\n */\n DescriptorRunnerWebGPU.prototype.saveCache = function (directory, descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, Promise.all([\n localforage.setItem(directory + \"_\" + this.backendName + \"_descriptor\", descriptor),\n localforage.setItem(directory + \"_\" + this.backendName + \"_parameters\", parameters)\n ])];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n ;\n DescriptorRunnerWebGPU.prototype.setDescriptorAndParameters = function (descriptor, parameter) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.descriptor = descriptor;\n //reset all datum depend on old descriptor\n this.staticBuffer = null;\n this.dynamicBuffer = null;\n this.metaBuffers = null;\n this.placeholderContext = new placeholder_1.default(descriptor.placeholders);\n this.executionInfos = descriptor.exec_infos;\n //compile kernels\n this.webgpuHandler.loadKernel(this.descriptor.kernel_source, 'descriptor');\n return [4 /*yield*/, this.initializeStaticBuffer(parameter)];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.initializeMetaBuffers()];\n case 2:\n _a.sent();\n return [4 /*yield*/, this.setPlaceholderValue({\n '__MAX_THREADS_PER_THREADGROUP__': IS_IOS ? 512 : 1024\n })];\n case 3:\n _a.sent();\n if (!(this.placeholderContext && this.placeholderContext.isResolved)) return [3 /*break*/, 5];\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 4:\n _a.sent();\n _a.label = 5;\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Initialize static buffers, whose size and position can be determined in compile time.\n *\n * @param {ArrayBuffer} weightRawArray constant weight buffer\n * @returns {Promise}\n */\n DescriptorRunnerWebGPU.prototype.initializeStaticBuffer = function (weightRawArray) {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, staticBuffer, decoder, _a, _b;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n descriptor = this.descriptor;\n staticBuffer = new buffer_webgpu_1.default(descriptor.memory_layout.static.size * Float32Array.BYTES_PER_ELEMENT);\n this.staticBuffer = staticBuffer;\n decoder = get_weight_decoder_1.default(descriptor.weight_encoding);\n _b = (_a = staticBuffer).write;\n return [4 /*yield*/, decoder.decode(new Uint8Array(weightRawArray))];\n case 1: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];\n case 2:\n _c.sent();\n return [4 /*yield*/, this.getInputViews()];\n case 3:\n (_c.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = staticBuffer.bufferView.buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 4:\n (_c.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = staticBuffer.bufferView.buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Initialize meta buffers, which contains metadata shared in each GPU kernel thread (ex. hyper parameters).\n * @returns {Promise}\n */\n DescriptorRunnerWebGPU.prototype.initializeMetaBuffers = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var _a;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n _a = this;\n return [4 /*yield*/, Promise.all(this.descriptor.exec_infos.map(function (executionInfo) { return __awaiter(_this, void 0, void 0, function () {\n var buffer;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n buffer = new buffer_webgpu_1.default(executionInfo.meta_buffer.length * Int32Array.BYTES_PER_ELEMENT);\n return [4 /*yield*/, buffer.write(new Uint8Array(executionInfo.meta_buffer))];\n case 1:\n _a.sent();\n return [2 /*return*/, buffer];\n }\n });\n }); }))];\n case 1:\n _a.metaBuffers = _b.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Initialize dynamic buffers, whose size and position cannot be determined without runtime-information such as input image size\n * (if it's dynamic).\n * When all placeholder is resolved, this method is automatically called.\n *\n * @returns {Promise}\n */\n DescriptorRunnerWebGPU.prototype.initializeDynamicBuffer = function () {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, placeholderContext, dynamicBufferSize, dynamicBuffer;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n if (!this.placeholderContext)\n throw Error(\"PlaceholderContext is not initialized.\");\n descriptor = this.descriptor;\n placeholderContext = this.placeholderContext;\n dynamicBufferSize = placeholderContext.resolve(descriptor.memory_layout.dynamic.size);\n dynamicBuffer = new buffer_webgpu_1.default(dynamicBufferSize * Float32Array.BYTES_PER_ELEMENT);\n this.dynamicBuffer = dynamicBuffer;\n return [4 /*yield*/, this.getInputViews()];\n case 1:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = dynamicBuffer.bufferView.buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 2:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = dynamicBuffer.bufferView.buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Set actual value into placeholder. If all placeholder is resolved,\n * [[DescriptorRunnerWebGPU#initializeDynamicBuffer|`initializeDynamicBuffer()`]] is automatically called.\n *\n * @param values mapping object of placeholder name and value\n * @returns {Promise}\n */\n DescriptorRunnerWebGPU.prototype.setPlaceholderValue = function (values) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var placeholderContext, descriptor, metaBuffers, _a;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return [2 /*return*/];\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.metaBuffers)\n throw new Error('MetaBuffers are not initialized');\n descriptor = this.descriptor;\n metaBuffers = this.metaBuffers;\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 1:\n _b.sent();\n // resolve placeholders in execution info\n _a = this;\n return [4 /*yield*/, Promise.all(descriptor.exec_infos.map(function (executionInfo, i) { return __awaiter(_this, void 0, void 0, function () {\n var bufferView, _i, _a, unresolved_value;\n return __generator(this, function (_b) {\n bufferView = new Int32Array(metaBuffers[i].bufferView.buffer);\n for (_i = 0, _a = executionInfo.unresolved_value_list; _i < _a.length; _i++) {\n unresolved_value = _a[_i];\n bufferView[unresolved_value.offset] = placeholderContext.resolve(unresolved_value.placeholder);\n }\n return [2 /*return*/, placeholderContext.resolve(executionInfo)];\n });\n }); }))];\n case 2:\n // resolve placeholders in execution info\n _a.executionInfos = _b.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Get input [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]] object\n *\n * @returns array of input [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]]\n * @deprecated Use [[webdnn.DescriptorRunner.inputs|`inputs`]] instead\n */\n DescriptorRunnerWebGPU.prototype.getInputViews = function () {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, allocation.offset * symbolic_float32array_1.default.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n };\n /**\n * Get output [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]] object\n *\n * @returns array of output [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]]\n * @deprecated Use [[webdnn.DescriptorRunner.outputs|`outputs`]] instead\n */\n DescriptorRunnerWebGPU.prototype.getOutputViews = function () {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, allocation.offset * symbolic_float32array_1.default.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n };\n /**\n * Run descriptor. You must call [[webdnn.DescriptorRunner.getInputViews|`getInputViews`]] and\n * [[webdnn.DescriptorRunner.getOutputViews|`getOutputViews`]] before calling this function.\n */\n DescriptorRunnerWebGPU.prototype.run = function () {\n return __awaiter(this, void 0, void 0, function () {\n var staticBuffer, dynamicBuffer, metaBuffers, records, totalElapsedTime_1, i, exec_info, start, elapsedTime, summary, complete_promise, i, exec_info, is_last;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.executionInfos)\n throw new Error('ExecutionInfos is not loaded');\n if (!this.staticBuffer)\n throw new Error('StaticBuffer is not initialized');\n if (!this.dynamicBuffer)\n throw new Error('DynamicBuffer is not initialized');\n if (!this.metaBuffers)\n throw new Error('MetaBuffer is not initialized');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(\"Not all placeholders are resolved: \" + this.placeholderContext);\n staticBuffer = this.staticBuffer;\n dynamicBuffer = this.dynamicBuffer;\n metaBuffers = this.metaBuffers;\n if (!webdnn_1.getConfiguration('DEBUG', false)) return [3 /*break*/, 5];\n records = [];\n totalElapsedTime_1 = 0;\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < this.executionInfos.length)) return [3 /*break*/, 4];\n exec_info = this.executionInfos[i];\n start = performance.now();\n return [4 /*yield*/, this.webgpuHandler.executeSinglePipelineState('descriptor.' + exec_info.entry_func_name, exec_info.threadgroups_per_grid, exec_info.threads_per_thread_group, [staticBuffer, dynamicBuffer, metaBuffers[i]], true)];\n case 2:\n _a.sent();\n elapsedTime = performance.now() - start;\n records.push({\n 'Kernel': exec_info.entry_func_name,\n 'Elapsed time [ms]': elapsedTime\n });\n totalElapsedTime_1 += elapsedTime;\n _a.label = 3;\n case 3:\n i++;\n return [3 /*break*/, 1];\n case 4:\n summary = Array.from(Object.values(records.reduce(function (summary, record) {\n if (!(record['Kernel'] in summary)) {\n summary[record['Kernel']] = {\n 'Kernel': record['Kernel'],\n 'Count': 0,\n 'Elapsed time [ms]': 0,\n };\n }\n summary[record['Kernel']]['Count']++;\n summary[record['Kernel']]['Elapsed time [ms]'] += record['Elapsed time [ms]'];\n return summary;\n }, {})));\n summary.forEach(function (record) { return record['Ratio [%]'] = (record['Elapsed time [ms]'] / totalElapsedTime_1).toFixed(2); });\n console.table(records);\n console.table(summary);\n return [3 /*break*/, 6];\n case 5:\n complete_promise = null;\n for (i = 0; i < this.executionInfos.length; i++) {\n exec_info = this.executionInfos[i];\n is_last = i == this.executionInfos.length - 1;\n complete_promise = this.webgpuHandler.executeSinglePipelineState('descriptor.' + exec_info.entry_func_name, exec_info.threadgroups_per_grid, exec_info.threads_per_thread_group, [staticBuffer, dynamicBuffer, metaBuffers[i]], is_last);\n }\n return [2 /*return*/, complete_promise]; //wait to finish final kernel\n case 6: return [2 /*return*/];\n }\n });\n });\n };\n return DescriptorRunnerWebGPU;\n}(descriptor_runner_1.DescriptorRunner));\nexports.default = DescriptorRunnerWebGPU;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.js\n// module id = 39\n// module chunks = 0","\"use strict\";\nfunction __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n}\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @module webdnn/image\n * @preferred\n *\n * Module `WebDNN.Image` provides basic image processing operations like follows.\n *\n * - Load image by various way (File picker dialog, url string, canvas, video, etc.)\n * - Pack image data into TypedArray\n * - Crop and resize.\n * - Show result on canvas element\n *\n */\n/** Don't Remove This comment block */\n// export * from \"./image/canvas\" // internal API\n__export(require(\"./image/enums\"));\n__export(require(\"./image/image_array\"));\n// export * from \"./image/image_data\" // internal API\n__export(require(\"./image/image_source\"));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image.js\n// module id = 40\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar canvas_1 = require(\"./canvas\");\nvar enums_1 = require(\"./enums\");\nvar image_data_1 = require(\"./image_data\");\nvar image_source_1 = require(\"./image_source\");\n/**\n * @protected\n */\nfunction flatten(arr) {\n return (arr instanceof Array) ? Array.prototype.concat.apply([], arr.map(function (arr) { return flatten(arr); })) : arr;\n}\n/**\n * @protected\n */\nfunction normalizeBiasTuple(arr) {\n if (typeof (arr) == \"number\") {\n return [arr, arr, arr, arr];\n }\n else {\n if (arr.length == 4) {\n return [arr[0], arr[1], arr[2], arr[3]];\n }\n else if (arr.length == 3) {\n return [arr[0], arr[1], arr[2], arr[0]];\n }\n else if (arr.length == 1) {\n return [arr[0], arr[0], arr[0], arr[0]];\n }\n else {\n throw new Error('bias and scale must be scalar number or array of length 1 or 3 or 4.');\n }\n }\n}\n/**\n * Get image array as `{Float32 or Int32}ArrayBufferView` from ImageData object.\n *\n * @returns {ArrayBufferView} buffer with specified type\n * @protected\n */\nfunction getImageArrayFromImageData(imageData, options) {\n if (options === void 0) { options = {}; }\n var _a = options.type, type = _a === void 0 ? Float32Array : _a, _b = options.color, color = _b === void 0 ? enums_1.Color.RGB : _b, _c = options.order, order = _c === void 0 ? enums_1.Order.HWC : _c, _d = options.bias, bias = _d === void 0 ? [0, 0, 0] : _d, _e = options.scale, scale = _e === void 0 ? [1, 1, 1] : _e;\n var bias_n = normalizeBiasTuple(bias);\n var scale_n = normalizeBiasTuple(scale);\n var width = imageData.width;\n var height = imageData.height;\n var data = imageData.data;\n var array;\n var biasR, biasG, biasB, biasA;\n var scaleR, scaleG, scaleB, scaleA;\n switch (color) {\n case enums_1.Color.RGB:\n array = new type(width * height * 3);\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2];\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(h * width + w) * 3 + 0] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 3 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 3 + 2] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n }\n }\n break;\n }\n break;\n case enums_1.Color.BGR:\n array = new type(width * height * 3);\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(h * width + w) * 3 + 0] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 3 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 3 + 2] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n }\n }\n break;\n }\n break;\n case enums_1.Color.RGBA:\n array = new type(width * height * 4);\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2], scaleA = scale_n[3];\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2], biasA = bias_n[3];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(h * width + w) * 4 + 0] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 4 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 4 + 2] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 4 + 3] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(3 * height + h) * width + w] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n }\n break;\n case enums_1.Color.BGRA:\n array = new type(width * height * 4);\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2], biasA = bias_n[3];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2], scaleA = scale_n[3];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(h * width + w) * 4 + 0] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 4 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 4 + 2] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 4 + 3] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(3 * height + h) * width + w] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n }\n break;\n case enums_1.Color.GREY:\n array = new type(width * height);\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2];\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2];\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n var r = data[(h * width + w) * 4 + 0];\n var g = data[(h * width + w) * 4 + 1];\n var b = data[(h * width + w) * 4 + 2];\n array[h * width + w] = 0.2126 * (r - biasR) / scaleR + 0.7162 * (g - biasG) / scaleG + 0.0722 * (b - biasB) / scaleB;\n }\n }\n break;\n default:\n throw Error(\"Unknown color format: \" + color);\n }\n return array;\n}\nexports.getImageArrayFromImageData = getImageArrayFromImageData;\n/**\n * Get image array from canvas element as `{Float32 or Int32}ArrayBufferView`.\n *\n * @returns {ImageData} buffer with specified type\n * @protected\n */\nfunction getImageArrayFromCanvas(canvas, options) {\n if (options === void 0) { options = {}; }\n var _a = options.type, type = _a === void 0 ? Float32Array : _a, _b = options.color, color = _b === void 0 ? enums_1.Color.RGB : _b, _c = options.order, order = _c === void 0 ? enums_1.Order.HWC : _c, _d = options.srcX, srcX = _d === void 0 ? 0 : _d, _e = options.srcY, srcY = _e === void 0 ? 0 : _e, _f = options.srcW, srcW = _f === void 0 ? canvas.width : _f, _g = options.srcH, srcH = _g === void 0 ? canvas.height : _g, _h = options.dstX, dstX = _h === void 0 ? 0 : _h, _j = options.dstY, dstY = _j === void 0 ? 0 : _j, _k = options.bias, bias = _k === void 0 ? [0, 0, 0] : _k, _l = options.scale, scale = _l === void 0 ? [1, 1, 1] : _l;\n var _m = options.dstW, dstW = _m === void 0 ? srcW : _m, _o = options.dstH, dstH = _o === void 0 ? srcH : _o;\n var imageData = image_data_1.getImageData(canvas, { srcX: srcX, srcY: srcY, srcW: srcW, srcH: srcH, dstX: dstX, dstY: dstY, dstW: dstW, dstH: dstH });\n return getImageArrayFromImageData(imageData, { type: type, color: color, order: order, bias: bias, scale: scale });\n}\nexports.getImageArrayFromCanvas = getImageArrayFromCanvas;\n/**\n * Get image array from image element as `{Float32 or Int32}ArrayBufferView`.\n *\n * @returns {ImageData} buffer with specified type\n * @protected\n */\nfunction getImageArrayFromDrawable(drawable, options) {\n if (options === void 0) { options = {}; }\n var srcW, srcH;\n if (drawable instanceof HTMLVideoElement) {\n srcW = drawable.videoWidth;\n srcH = drawable.videoHeight;\n }\n else if (drawable instanceof HTMLImageElement) {\n srcW = drawable.naturalWidth;\n srcH = drawable.naturalHeight;\n }\n else if (drawable instanceof HTMLCanvasElement) {\n return getImageArrayFromCanvas(drawable, options);\n }\n else if (drawable instanceof ImageData) {\n return getImageArrayFromImageData(drawable, options);\n }\n else\n throw TypeError('Failed to execute \"getImageDataFromDrawable(drawable, options)\": \"drawable\" must be an instanceof Drawable');\n var _a = options.type, type = _a === void 0 ? Float32Array : _a, _b = options.color, color = _b === void 0 ? enums_1.Color.RGB : _b, _c = options.order, order = _c === void 0 ? enums_1.Order.HWC : _c, _d = options.srcX, srcX = _d === void 0 ? 0 : _d, _e = options.srcY, srcY = _e === void 0 ? 0 : _e, _f = options.dstX, dstX = _f === void 0 ? 0 : _f, _g = options.dstY, dstY = _g === void 0 ? 0 : _g, _h = options.dstW, dstW = _h === void 0 ? srcW : _h, _j = options.dstH, dstH = _j === void 0 ? srcH : _j, _k = options.bias, bias = _k === void 0 ? [0, 0, 0] : _k, _l = options.scale, scale = _l === void 0 ? [1, 1, 1] : _l;\n var canvas = document.createElement('canvas');\n canvas.width = dstX + dstW;\n canvas.height = dstY + dstH;\n var context = canvas_1.getContext2D(canvas);\n context.drawImage(drawable, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);\n return getImageArrayFromCanvas(canvas, { type: type, color: color, order: order, bias: bias, scale: scale });\n}\nexports.getImageArrayFromDrawable = getImageArrayFromDrawable;\n/**\n * Create typed array by packing image data from image source with specified options.\n *\n * First, this method loads specified image resource. The behavior of this method depends on the `image` argument.\n *\n * - If `image` is an instance of `string`, it will be regarded as image url, and this method fetches that url.\n *\n * - If `image` is an instance of `HTMLInputElement`, it will be regarded as file input,\n * and this method loads the selected image file.\n *\n * - Otherwise, `image` will be regarded as drawable object.\n *\n * Then, loaded images are packed into typed array based on `options` argument.\n *\n * - The image is cropped based on [[SourceRect|`{srcX, srcY, srcW, srcH}`]].\n * As default, entire image is used.\n *\n * - The image is resized and translated into [[DestinationRect|`{dstX, dstY, dstW, dstH}`]].\n * As default, no resize and translation is performed.\n *\n * - [[ImageArrayOption.type|`options.type`]] is the type of packed typed array. As default, Float32Array is used.\n *\n * - [[ImageArrayOption.type|`options.color`]] is the color format of packed typed array. As default, [[Color.RGB|`RGB`]] is used.\n *\n * - [[ImageArrayOption.type|`options.order`]] is the data order of packed typed array. As default, [[Order.HWC|`HWC`]] is used.\n *\n * - [[ImageArrayOption.bias|`options.bias`]] is the bias value.\n * If specified, this method **subtracts** this value from original pixel value.\n *\n * - [[ImageArrayOption.scale|`options.scale`]] is the scale value. If specified, original pixel values are **divided** by this value.\n * [[ImageArrayOption.scale|`options.scale`]] and [[ImageArrayOption.bias|`options.bias`]] is used for converting pixel value `x` and\n * packed value `y` as follows:\n *\n * - `y = (x - bias) / scale`\n * - `x = y * scale + bias`\n * - Note that color order is always RGB, not BGR.\n *\n * ### Examples\n *\n * - Load image of specified url\n *\n * ```ts\n * let image = await WebDNN.Image.load('./cat.png');\n * ```\n *\n * - Load image selected in file input and resize it into 224 x 224\n *\n * ```ts\n * let input = document.querySelector('input[type=file]');\n * let image = await WebDNN.Image.load(input, { dstW: 224, dstH: 224 });\n * ```\n *\n * - Load image data from canvas, normalize it into range `[-1, 1)`. In this case, normalized value `y` can be\n * calculated from pixel value `x` as follows: `y = (x - 128) / 128`.\n *\n * ```ts\n * let canvas = document.getElementsByTagName('canvas')[0];\n * let image = await WebDNN.Image.load(canvas, { bias: [128, 128, 128], scale: [128, 128, 128] });\n * ```\n *\n * @param image please see above descriptions\n * @param options please see above descriptions.\n * @returns Created typed array\n */\nfunction getImageArray(image, options) {\n if (options === void 0) { options = {}; }\n return __awaiter(this, void 0, void 0, function () {\n var _a, _b;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n if (!(typeof image === 'string')) return [3 /*break*/, 2];\n _a = getImageArrayFromDrawable;\n return [4 /*yield*/, image_source_1.loadImageByUrl(image)];\n case 1: return [2 /*return*/, _a.apply(void 0, [_c.sent(), options])];\n case 2:\n if (!(image instanceof HTMLInputElement)) return [3 /*break*/, 4];\n _b = getImageArrayFromDrawable;\n return [4 /*yield*/, image_source_1.loadImageFromFileInput(image)];\n case 3: return [2 /*return*/, _b.apply(void 0, [_c.sent(), options])];\n case 4:\n if (image instanceof HTMLCanvasElement) {\n return [2 /*return*/, getImageArrayFromCanvas(image, options)];\n }\n else if (image instanceof HTMLImageElement || image instanceof HTMLVideoElement || image instanceof ImageData) {\n return [2 /*return*/, getImageArrayFromDrawable(image, options)];\n // FIXME: This feature is not supported for all web browsers.\n // } else if (image === null) {\n // return getImageArrayFromDrawable(await loadImageByDialog(), options);\n }\n else\n throw TypeError('Failed to execute \"getImageData(image, options)\": \"image\" must be an instance of string,' +\n ' HTMLInputElement, HTMLCanvasElement, HTMLImageElement, HTMLVideoElement, or ImageData object');\n _c.label = 5;\n case 5: return [2 /*return*/];\n }\n });\n });\n}\nexports.getImageArray = getImageArray;\n/**\n * Set image array data into canvas.\n *\n * ### Examples\n *\n * - Show DNN model's result\n *\n * ```ts\n * let runner = await WebDNN.load('./model');\n * let output = runner.outputs[0];\n *\n * await runner.run();\n *\n * WebDNN.Image.setImageArrayToCanvas(output.toActual(), 256, 256, document.getElementById('canvas'))\n * ```\n *\n * - Generally image generation model's result contains noise pixel at their edge because of convolution's padding.\n * In follow example, these noise are cut off.\n *\n * ```ts\n * WebDNN.Image.setImageArrayToCanvas(output, 256, 256, canvas, {\n * srcX: 16, srcY: 16, srcH: 256-16*2, srcW: 256-16*2, // Discard both ends 16px\n * dstW: 256, dstH: 256 // Resize cropped image into original output size.\n * });\n * ```\n *\n * @param array array which contains image data\n * @param imageW width of image\n * @param imageH height of image. The length of `array` must be `imageW * imageH * (# of channels)`\n * @param canvas destination canvas\n * @param options please see above descriptions and descriptions in [[webdnn/image.getImageArray|getImageArray()]].\n * `srcW` and `srcH` is ignored (overwritten by `imageW` and `imageH`).\n */\nfunction setImageArrayToCanvas(array, imageW, imageH, canvas, options) {\n if (options === void 0) { options = {}; }\n var _a = options.color, color = _a === void 0 ? enums_1.Color.RGB : _a, _b = options.order, order = _b === void 0 ? enums_1.Order.HWC : _b, _c = options.srcX, srcX = _c === void 0 ? 0 : _c, _d = options.srcY, srcY = _d === void 0 ? 0 : _d, _e = options.dstX, dstX = _e === void 0 ? 0 : _e, _f = options.dstY, dstY = _f === void 0 ? 0 : _f, _g = options.dstW, dstW = _g === void 0 ? canvas.width : _g, _h = options.dstH, dstH = _h === void 0 ? canvas.height : _h, _j = options.bias, bias = _j === void 0 ? [0, 0, 0] : _j, _k = options.scale, scale = _k === void 0 ? [1, 1, 1] : _k;\n var bias_n = normalizeBiasTuple(bias);\n var scale_n = normalizeBiasTuple(scale);\n var srcW = imageW, srcH = imageH;\n array = flatten(array);\n var data = new Uint8ClampedArray(srcW * srcH * 4);\n var biasR, biasG, biasB, biasA;\n var scaleR, scaleG, scaleB, scaleA;\n switch (color) {\n case enums_1.Color.RGB:\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 0] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 2] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(0 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(2 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n break;\n case enums_1.Color.BGR:\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 2] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 0] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(2 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(0 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n break;\n case enums_1.Color.RGBA:\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2], biasA = bias_n[3];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2], scaleA = scale_n[3];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 0] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 2] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(h * imageW + w) * 3 + 3] * scaleA + biasA;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(0 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(2 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(3 * imageH + h) * imageW + w] * scaleA + biasA;\n }\n }\n break;\n }\n break;\n case enums_1.Color.BGRA:\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2], biasA = bias_n[3];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2], scaleA = scale_n[3];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 4 + 2] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 4 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 4 + 0] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(h * imageW + w) * 4 + 3] * scaleA + biasA;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(2 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(0 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(3 * imageH + h) * imageW + w] * scaleA + biasA;\n }\n }\n break;\n }\n break;\n case enums_1.Color.GREY:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] =\n data[(h * imageW + w) * 4 + 1] =\n data[(h * imageW + w) * 4 + 2] = array[h * imageW + w] * scale[0] + bias[0];\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n image_data_1.setImageDataToCanvas(new ImageData(data, srcW, srcH), canvas, { srcX: srcX, srcY: srcY, srcW: srcW, srcH: srcH, dstX: dstX, dstY: dstY, dstW: dstW, dstH: dstH });\n}\nexports.setImageArrayToCanvas = setImageArrayToCanvas;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_array.js\n// module id = 41\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar canvas_1 = require(\"./canvas\");\n/**\n * @protected\n */\nfunction getImageDataFromCanvas(canvas, options) {\n if (options === void 0) { options = {}; }\n var _a = options.srcX, srcX = _a === void 0 ? 0 : _a, _b = options.srcY, srcY = _b === void 0 ? 0 : _b, _c = options.srcW, srcW = _c === void 0 ? canvas.width : _c, _d = options.srcH, srcH = _d === void 0 ? canvas.height : _d, _e = options.dstX, dstX = _e === void 0 ? 0 : _e, _f = options.dstY, dstY = _f === void 0 ? 0 : _f;\n var _g = options.dstW, dstW = _g === void 0 ? srcW : _g, _h = options.dstH, dstH = _h === void 0 ? srcH : _h;\n var imageData = canvas_1.getContext2D(canvas).getImageData(srcX, srcY, srcW, srcH);\n if (dstX !== 0 || dstY !== 0 || srcW !== dstW || srcH !== dstH) {\n imageData = cropAndResizeImageData(imageData, { dstX: dstX, dstY: dstY, dstW: dstW, dstH: dstH });\n }\n return imageData;\n}\nexports.getImageDataFromCanvas = getImageDataFromCanvas;\n/**\n * @protected\n */\nfunction getImageDataFromDrawable(drawable, options) {\n if (options === void 0) { options = {}; }\n var srcW, srcH;\n if (drawable instanceof HTMLVideoElement) {\n srcW = drawable.videoWidth;\n srcH = drawable.videoHeight;\n }\n else if (drawable instanceof HTMLImageElement) {\n srcW = drawable.naturalWidth;\n srcH = drawable.naturalHeight;\n }\n else\n throw TypeError('Failed to execute \"getImageDataFromDrawable(drawable, options)\": \"drawable\" must be an instanceof HTMLVideoElement or HTMLImageElement');\n var _a = options.srcX, srcX = _a === void 0 ? 0 : _a, _b = options.srcY, srcY = _b === void 0 ? 0 : _b, _c = options.dstX, dstX = _c === void 0 ? 0 : _c, _d = options.dstY, dstY = _d === void 0 ? 0 : _d, _e = options.dstW, dstW = _e === void 0 ? srcW : _e, _f = options.dstH, dstH = _f === void 0 ? srcH : _f;\n var canvas = document.createElement('canvas');\n canvas.width = dstX + dstW;\n canvas.height = dstY + dstH;\n var context = canvas_1.getContext2D(canvas);\n context.drawImage(drawable, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);\n return context.getImageData(0, 0, dstX + dstW, dstY + dstH);\n}\nexports.getImageDataFromDrawable = getImageDataFromDrawable;\n/**\n * Source rectangle of source image is cropped and then copied into destination rectangle of new image data\n *\n * @param {ImageData} src\n * @param {SourceRect & DestinationRect} options\n * @returns {ImageData}\n * @protected\n */\nfunction cropAndResizeImageData(src, options) {\n if (options === void 0) { options = {}; }\n var _a = options.srcX, srcX = _a === void 0 ? 0 : _a, _b = options.srcY, srcY = _b === void 0 ? 0 : _b, _c = options.srcW, srcW = _c === void 0 ? src.width : _c, _d = options.srcH, srcH = _d === void 0 ? src.height : _d, _e = options.dstX, dstX = _e === void 0 ? 0 : _e, _f = options.dstY, dstY = _f === void 0 ? 0 : _f;\n var _g = options.dstW, dstW = _g === void 0 ? srcW : _g, _h = options.dstH, dstH = _h === void 0 ? srcH : _h;\n var canvas1 = document.createElement('canvas');\n canvas1.width = srcW;\n canvas1.height = srcH;\n var context1 = canvas_1.getContext2D(canvas1);\n context1.putImageData(src, -srcX, -srcY);\n var canvas2 = document.createElement('canvas');\n canvas2.width = dstX + dstW;\n canvas2.height = dstY + dstH;\n var context2 = canvas_1.getContext2D(canvas2);\n context2.drawImage(canvas1, 0, 0, srcW, srcH, dstX, dstY, dstW, dstH);\n return context2.getImageData(0, 0, dstX + dstW, dstY + dstH);\n}\n/**\n * Return canvas `ImageData` object with specified scale.\n *\n * @param {HTMLCanvasElement | HTMLVideoElement | HTMLImageElement} image\n * @param [options] Options\n * @param {number} [options.srcX=0] left position of input clipping rect\n * @param {number} [options.srcY=0] top position of input clipping rect\n * @param {number} [options.srcW=canvas.width] width of input clipping rect\n * @param {number} [options.srcH=canvas.height] height of input clipping rect\n * @param {number} [options.dstW=options.srcW] width of output\n * @param {number} [options.dstH=options.srcH] height of output\n * @returns {ImageData}\n * @protected\n */\nfunction getImageData(image, options) {\n if (options === void 0) { options = {}; }\n if (image instanceof HTMLCanvasElement) {\n return getImageDataFromCanvas(image, options);\n }\n else if (image instanceof HTMLVideoElement || image instanceof HTMLImageElement) {\n return getImageDataFromDrawable(image, options);\n }\n else\n throw TypeError('Failed to execute \"getImageData(image, options)\": \"image\" must be an instance of HTMLCanvasElement, HTMLVideoElement, or HTMLImageElement');\n}\nexports.getImageData = getImageData;\n/**\n * @protected\n */\nfunction setImageDataToCanvas(imageData, canvas, options) {\n if (options === void 0) { options = {}; }\n var _a = options.srcX, srcX = _a === void 0 ? 0 : _a, _b = options.srcY, srcY = _b === void 0 ? 0 : _b, _c = options.srcW, srcW = _c === void 0 ? imageData.width : _c, _d = options.srcH, srcH = _d === void 0 ? imageData.height : _d, _e = options.dstX, dstX = _e === void 0 ? 0 : _e, _f = options.dstY, dstY = _f === void 0 ? 0 : _f;\n var _g = options.dstW, dstW = _g === void 0 ? srcW : _g, _h = options.dstH, dstH = _h === void 0 ? srcH : _h;\n if (srcX !== 0 || srcY !== 0 || srcW !== dstW || srcH !== dstH) {\n imageData = cropAndResizeImageData(imageData, { srcX: srcX, srcY: srcY, srcW: srcW, srcH: srcH, dstW: dstW, dstH: dstH });\n }\n canvas_1.getContext2D(canvas).putImageData(imageData, dstX, dstY);\n}\nexports.setImageDataToCanvas = setImageDataToCanvas;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_data.js\n// module id = 42\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/math\n * @preferred\n *\n * Module `WebDNN.Math` provides basic mathematics operations for pre/post-processing.\n */\n/** Don't Remove This comment block */\nfunction __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n}\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__export(require(\"./math/argsort\"));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/math.js\n// module id = 43\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/math\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/** Don't Remove This comment block */\n/**\n * Return indices of the top-K largest elements.\n * This implementation is not stable sort.\n *\n * @param {number[]|Float32Array} arr array\n * @param {number} k number of indices\n * @returns {number[]} indices of top-K largest samples\n */\nfunction argmax(arr, k) {\n // Top-k Quicksort\n if (k === void 0) { k = 1; }\n arr = arr.slice();\n var stack = [[0, arr.length]];\n var workspace = [];\n for (var i = 0; i < arr.length; i++)\n workspace[i] = i;\n while (stack.length > 0) {\n var _a = stack.pop(), from = _a[0], to = _a[1], pivot = arr[to - 1], left = from, right = to - 2, tmp = void 0;\n if (from >= to - 1)\n continue;\n while (true) {\n while (arr[left] > pivot && left <= right)\n left++;\n while (arr[right] <= pivot && left <= right)\n right--;\n if (left >= right)\n break;\n tmp = arr[left];\n arr[left] = arr[right];\n arr[right] = tmp;\n tmp = workspace[left];\n workspace[left] = workspace[right];\n workspace[right] = tmp;\n }\n arr[to - 1] = arr[left];\n arr[left] = pivot;\n tmp = workspace[to - 1];\n workspace[to - 1] = workspace[left];\n workspace[left] = tmp;\n // If partial segment contains top-K elements, append it into stack\n stack.push([from, left]); // left (=larger) segment always contains top-K elements\n if (left + 1 < k)\n stack.push([left + 1, to]);\n }\n var result = [];\n for (var i = 0; i < k; i++)\n result.push(workspace[i]);\n return result;\n}\nexports.argmax = argmax;\n/**\n * Return indices of the top-K smallest elements.\n * This implementation is not stable sort.\n *\n * @param {number[]|Float32Array|Int32Array} arr array\n * @param {number} k number of indices\n * @returns {number[]} indices of top-K smallest samples\n */\nfunction argmin(arr, k) {\n // Top-k Quicksort\n if (k === void 0) { k = 1; }\n arr = arr.slice();\n var stack = [[0, arr.length]];\n var workspace = [];\n for (var i = 0; i < arr.length; i++)\n workspace[i] = i;\n while (stack.length > 0) {\n var _a = stack.pop(), from = _a[0], to = _a[1], pivot = arr[to - 1], left = from, right = to - 2, tmp = void 0;\n if (from >= to - 1)\n continue;\n while (true) {\n while (arr[left] < pivot && left <= right)\n left++;\n while (arr[right] >= pivot && left <= right)\n right--;\n if (left >= right)\n break;\n tmp = arr[left];\n arr[left] = arr[right];\n arr[right] = tmp;\n tmp = workspace[left];\n workspace[left] = workspace[right];\n workspace[right] = tmp;\n }\n arr[to - 1] = arr[left];\n arr[left] = pivot;\n tmp = workspace[to - 1];\n workspace[to - 1] = workspace[left];\n workspace[left] = tmp;\n // If partial segment contains top-K elements, append it into stack\n stack.push([from, left]); // left (=larger) segment always contains top-K elements\n if (left + 1 < k)\n stack.push([left + 1, to]);\n }\n var result = [];\n for (var i = 0; i < k; i++)\n result.push(workspace[i]);\n return result;\n}\nexports.argmin = argmin;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/math/argsort.js\n// module id = 44\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 8a8b97be680405fd407c","webpack:///./node_modules/pako/lib/utils/common.js","webpack:///./src/descriptor_runner/fetch.js","webpack:///./src/descriptor_runner/webdnn.js","webpack:///./node_modules/localforage/dist/localforage.js","webpack:///./src/descriptor_runner/decoder/get_weight_decoder.js","webpack:///./src/descriptor_runner/placeholder.js","webpack:///./src/descriptor_runner/symbolic_typed_array/symbolic_float32array.js","webpack:///./src/descriptor_runner/descriptor_runner/descriptor_runner.js","webpack:///./node_modules/pako/lib/zlib/messages.js","webpack:///./node_modules/pako/lib/zlib/adler32.js","webpack:///./node_modules/pako/lib/zlib/crc32.js","webpack:///./node_modules/pako/lib/utils/strings.js","webpack:///./node_modules/pako/lib/zlib/zstream.js","webpack:///./node_modules/pako/lib/zlib/constants.js","webpack:///./src/descriptor_runner/webgl_handler.js","webpack:///./src/descriptor_runner/buffer/buffer.js","webpack:///./src/descriptor_runner/buffer/buffer_webgpu.js","webpack:///./src/descriptor_runner/webgpu_handler.js","webpack:///./src/descriptor_runner/image/enums.js","webpack:///./src/descriptor_runner/image/canvas.js","webpack:///./src/descriptor_runner/image/image_source.js","webpack:///./src/descriptor_runner/descriptor_runner/descriptor_runner_fallback.js","webpack:///(webpack)/buildin/global.js","webpack:///./src/descriptor_runner/decoder/weight_decoder_eightbit.js","webpack:///./node_modules/pako/index.js","webpack:///./node_modules/pako/lib/deflate.js","webpack:///./node_modules/pako/lib/zlib/deflate.js","webpack:///./node_modules/pako/lib/zlib/trees.js","webpack:///./node_modules/pako/lib/inflate.js","webpack:///./node_modules/pako/lib/zlib/inflate.js","webpack:///./node_modules/pako/lib/zlib/inffast.js","webpack:///./node_modules/pako/lib/zlib/inftrees.js","webpack:///./node_modules/pako/lib/zlib/gzheader.js","webpack:///./src/descriptor_runner/decoder/weight_decoder_raw.js","webpack:///./src/descriptor_runner/util/dispatch_scheduler.js","webpack:///./src/descriptor_runner/symbolic_typed_array/symbolic_typed_array.js","webpack:///./src/descriptor_runner/descriptor_runner/descriptor_runner_webassembly.js","webpack:///./src/descriptor_runner/descriptor_runner/descriptor_runner_webgl.js","webpack:///./src/descriptor_runner/buffer/buffer_webgl.js","webpack:///./src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.js","webpack:///./src/descriptor_runner/image.js","webpack:///./src/descriptor_runner/image/image_array.js","webpack:///./src/descriptor_runner/image/image_data.js","webpack:///./src/descriptor_runner/math.js","webpack:///./src/descriptor_runner/math/argsort.js"],"names":[],"mappings":"AAAA,cACA,2BACA,uCACA,sCACA,IACA,aACA,wCAEA,aACA,GAAC,2EACD,kBCTA,cAMA,IACA,iBAGA,mBACA,CACA,IACA,KAIA,2CAGA,aAGA,OACA,OAIA,IAzBA,eA4BA,MAGA,uBACA,GACA,kCACA,CACA,gBACA,cAGA,OAGA,iBACA,YACA,qBAA2B,UAA0B,UACrD,YAAiC,CAAe,QAChD,EAEA,aADA,QAIA,mBAAsD,wCAA+D,SAGrH,MAGA,4BC7DA,aAOA,eACA,wCACA,UANA,MACA,gCACA,gEAMA,oBACA,gDACA,aACA,SACA,QAEA,SACA,yCAGA,6BACA,QACA,cAGA,MAEA,CACA,QAGA,EACA,yBACA,UACA,eAAqB,oBACrB,QAEA,aAGA,MACA,6BACA,kBACA,SAIA,+BAHA,kBAGmB,EAAS,IAC5B,aAEA,IAEA,2BACA,eAGA,QACA,UAAkC,OAAO,IACzC,YAIA,gBACA,iBACA,WAAkC,QAAO,IACzC,MACA,OACA,cAGA,OACA,QAGA,KACA,6BACA,WAAmB,EAAS,IAC5B,aAEA,IAEA,2BACA,iBACA,WAKA,GACA,sBAEA,WACA,mBACA,oBACA,aAEA,qBACA,cACA,cACA,QAEA,cAEA,+BCpGA,aA+CA,aACA,OACA,MA2FA,YACA,oEACA,YAEA,kBACA,mBACA,mCACA,uBACA,OACA,uBACA,SACA,CACA,QAGA,KAEA,SAIA,CACA,eACA,iCACA,UACA,uBACA,2BACA,mBACA,2BACA,GACA,qCACA,UACA,IACA,0BAEA,wBAAuD,qBAA4C,MAEnG,EACA,uBACA,CACA,IACA,SACA,KACA,GAtLA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAAc,WAC5D,QAIA,iBAAwC,CAAY,QAKpD,EAIA,EAKA,eAIA,EASA,6BAZA,WACA,CACA,KA0CA,EAOA,QAtCA,aACA,uCACA,IACA,4BACA,UACA,WACA,YACA,2DAGA,WAAgD,YAChD,iDAGA,0BACA,gBACA,6BACA,GAEA,WADA,6BAEA,gBACA,OACA,eACA,MACA,SACA,gEACA,mBAEA,MACA,EACA,IAoCA,EAIA,6BA/BA,aACA,cAWA,gBACA,oBAEA,8BAAmD,OAAgC,OAEnF,GACA,QACA,kBAGA,iBAEA,OACA,WAvBA,cACA,kCACA,qBACA,YACA,oBACA,iBACA,iBACA,WACA,oBACA,wBAeA,0BC1IA,aAmFA,YACA,OACA,iBACA,kCACA,8CACA,wCAEA,qFAA0F,OAAwB,KAClH,SACA,CACA,SAEA,gBAMA,eACA,uCACA,OACA,2BACA,UACA,WACA,QACA,+CACA,aACA,MACA,4BACA,SACA,cACA,YACA,GAEA,SADA,iBAEA,GAGA,WAFA,8CACA,uCAGA,MACA,EACA,EA8BA,CA1JA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAAc,WAC5D,QACA,QACA,QACA,QACA,QACA,WACA,UACA,YACA,EAIA,OACA,GAIA,MAIA,EAIA,iBAPA,aACA,eACA,QASA,EAIA,iBAPA,aACA,CACA,QAMA,MACA,UACA,gBACA,sBACA,mBAOA,SAcA,EAIA,yBA0NA,OAlKA,aACA,YAAgC,SAChC,qCACA,2CACA,2BACA,UACA,WACA,iEAA+J,iIAE/J,+BACA,cACA,uBACA,SACA,SACA,6BACA,+DAEA,CAOA,kBANA,cAIA,oBACA,OAEA,WACA,MACA,SACA,iBACA,eACA,mBACA,UACA,OACA,GACA,oBACA,MACA,6BACA,WACA,SACA,SACA,SACA,GAEA,IACA,mBACA,yBACA,0BACA,uBAGA,oFAAkG,OAAa,KAC/G,QACA,cACA,YACA,gCACA,cACA,kCACA,sBACA,SACA,mCACA,GAEA,OADA,SAEA,qBACA,MAEA,aACA,SACA,kCACA,GAEA,OADA,SAEA,qBACA,OAEA,cACA,SACA,0CACA,IAEA,OADA,SAEA,qBACA,uBACA,0GAAmG,OAAa,KAChH,QACA,eACA,OACA,YACA,SACA,2BACA,IAEA,OADA,SAEA,qBACA,OACA,OACA,8BACA,wEACA,gCACA,eACA,OACA,YACA,SACA,mCACA,IAEA,OADA,SAEA,qBACA,uBACA,uEACA,gCACA,eACA,OACA,YACA,SACA,mCACA,IAEA,OADA,SAEA,qBACA,OACA,OACA,4BACA,iGAA8F,OAAa,KAC3G,QACA,eACA,OACA,YACA,SACA,2BACA,IAEA,OADA,SAEA,qBACA,uBACA,8EACA,4HACA,UACA,qBACA,OACA,+BACA,UACA,sBACA,IAEA,SADA,kBAEA,IAEA,WADA,iCAEA,qCACA,IAEA,SADA,kBAEA,IAGA,WAFA,sFACA,8BAEA,6BAEA,4BACA,EACA,qCC7TA,KAKA;;;;;EACA,YAAa,CAA2D,UAAwO,GAAqB,aAAa,CAA0B,yBAA0B,gBAAgB,UAAU,SAAU,CAA0C,8CAAwB,oBAAoB,gDAA8C,iCAAqC,aAAY,YAAY,mCAAmC,iBAAiB,eAAgB,sBAAsB,oBAAoB,CAA0C,sCAAY,WAAW,YAAY,QAAS,GAAG,iBAClzB,aACA,aA+CA,YACA,CACA,iBAEA,SADA,KAEA,KACA,IACA,QACA,EACA,OAEA,WACA,MACA,CACA,KA5DA,4BAEA,uBAGA,OACA,OACA,IACA,qCACA,gBACA,CAEA,+BACA,cACA,CACA,CAAG,+DACH,aACA,uBACA,wBACA,qBACA,EACA,CAAG,wEACH,oBAIA,gCACA,yCACA,CAEA,yBACA,kBACA,iBACA,IACA,6BACA,cAEA,YACA,cACA,EAEA,EAEA,GAEA,MADA,EAkBA,UACA,WACA,CACA,kBAEA,GAEA,CAAC,0FACD,cAAI,uBACJ,aAIA,aAEA,CAQA,aACA,IACA,yCAEA,oCACA,aACA,0BACA,GACA,SAEA,QAoBA,iBACA,MACA,UACA,4BACA,sCAEA,oBACA,4BACA,oCAEA,mBAcA,iBACA,aACA,IACA,MACA,GACA,IAAK,SACL,UACA,WACA,CACA,+BAEA,yCAEA,YACA,GAiCA,aAEA,YACA,uDACA,sCACA,WACA,UAEA,EAEA,eAEA,cAKA,KACA,OACA,YAEA,cAIA,KACA,OACA,aAEA,IAhBA,QAqBA,YAJA,CACA,MAEA,GAEA,wBAEA,OAEA,eACA,IACA,SACA,SACA,cACA,SAAG,SACH,UACA,UACA,OACA,CACA,SAnKA,QAEA,GAKA,KACA,eACA,8BAEA,YAcA,gCACA,kBACA,SACA,8BACA,+BACA,sCACA,gBAEA,qBACA,iCACA,YACA,yBACA,QACA,sBAGA,cACA,UAYA,qCACA,gBACA,YACA,0CACA,qBACA,gBACA,oCACA,eACA,YACA,yCACA,qBACA,eAkBA,uBACA,OACA,UACA,uCAEA,eAEA,MACA,KACG,WACH,GACA,UACA,qBACA,YACA,OACA,kBAEA,gBACA,CACA,UACA,sBACA,GACA,UACA,qBACA,YACA,OACA,kBAEA,gBACA,UAqDA,UACA,WACA,oBAGA,qBACA,aAEA,SACA,WACA,UACA,kBACA,aAEA,MACA,WACA,gBAqBA,8BAOA,CACA,OACA,aACA,OAEA,aACA,aAXA,KACA,OAEA,YACA,EAQA,OAlCA,QACA,sFAGA,6BACA,OACA,QACA,eAGA,sBACA,WACA,KACA,OAEA,SACA,SAEA,QACA,UAiBA,OACA,WACA,cAmBA,8BAEA,KACA,OAEA,aAAK,aAEL,KACA,OAEA,YACA,EACA,OA9BA,QACA,sFAGA,6BACA,OACA,QACA,eAGA,uBACA,OAEA,SACA,SAEA,MACA,QAeA,CAAS,wBACT,aAEA,aACA,2CAGA,GAAC,0FACD,cAAS,0BACT,aAIA,eAAiD,MAA0C,oCAA4D,qCA6DvJ,eAEA,GACA,QACA,SACA,WACA,UAAK,SACL,IACA,qBAEA,uHACA,6DACA,QAAuB,MAAkB,UACzC,WAEA,yBACA,KACA,CAIA,CAOA,eAEA,sBACA,GACA,OAAS,aACT,CACA,IAEA,GAEA,iBACA,CACA,wBAGA,QACA,wBAEA,YAEA,aAEA,CAMA,MALA,oCAIA,mDAMA,CAcA,aACA,aACA,YACA,qBACA,iBAAmB,EAAY,IAC/B,WAEA,cACA,QAgBA,CACA,aACA,yBACA,SACA,mBACA,+BAEA,4BAGA,GACA,mBACA,kBACA,KAEA,yBACA,iCACA,6CAGA,mBACA,sBACA,CAAK,sBACL,CACA,QACA,GAEA,aACA,OACA,uBAEA,iCACA,CAEA,MADA,QAEA,GAEA,aACA,YAGA,MAEA,gCACA,GACA,SAGA,wBAGA,oBACA,iCAGA,UACA,OAEA,KAJA,QAMA,aACA,YAGA,6BAKA,WAEA,UAEA,eACA,YAGA,6BAKA,WAEA,UAEA,eACA,2BAEA,MACA,GACA,KACA,UAEA,wBAIA,aAGA,kBAGA,sBAGA,4CACA,SACA,UACA,uBACA,WAEA,mBAEA,oBAAiB,SACjB,IACA,+KAEA,yBAEA,QACA,CAGA,wBACA,GACA,qBACA,MAEA,wBACA,KACA,QACA,IACA,CACA,GAEA,aACA,OACA,SAEA,aACA,OACA,SAEA,eACA,OACA,GAGA,iDACA,4BACA,yBAKA,iBACA,+HAGA,oBAGA,cAIA,MACA,oBACA,MACA,YAEA,UAEA,CACA,QAEA,CACA,QAEA,CACA,aACA,2BACA,UACA,cACA,iCACA,6BACA,MACA,CACA,+BACA,cAEA,MACA,IACA,qBACA,EAEA,CACA,aACA,gBACA,oBAAoC,QACpC,MAEA,CACA,aACA,aACA,2BAKA,CACA,aACA,OAEA,qCACA,oBAEA,cACA,iBAEA,OAEA,GAEA,MADA,WAKA,CACA,aACA,CAEA,oBACA,UAEA,UAAmB,MAAoB,OACvC,iBACA,qBACA,wBAIA,qCACA,WAAuB,MAAoB,OAC3C,iBAEA,IAAK,uBACL,CAEA,KADA,SAEA,EAGA,CACA,iBACA,IACA,0BACA,eACA,OAAK,SACL,WACA,wDAEA,0BACA,eACA,OAGA,GACA,IACA,CAGA,CA+fA,aAEA,OACA,kBACA,SAEA,EADA,QAGA,EACA,sBACA,IACA,qBAIA,cACA,qBAEA,qBAAe,EAAS,OACxB,cACA,sBACA,oBACA,oBAGA,mBACA,sBACA,kBAEA,KACA,QAGA,CACA,aAEA,UACA,iBACA,GAEA,QAAe,MAAkB,UAEjC,aACA,4BACA,+BACA,QAGA,WAOA,MANA,2CACK,IACL,4CAGA,OAKA,CAqQA,mBACA,OAEA,OAEA,8BACA,0BAIA,CACA,eAIA,SAEA,SACA,8CAEA,GAEA,iCACA,kGACA,CACA,IAAyB,eACzB,CACA,IACA,EAAqB,aAGrB,yBAQA,IACA,IAGA,iCAFA,KAGA,IACA,CAEA,EACA,EAAS,GACT,WAEA,GAEA,MADA,UAyJA,YACA,OAEA,+BACA,CAIA,oBAHA,2BAEA,gBACK,SACL,CACA,QACA,CAKA,CACA,YACA,aACA,qBAEA,CAuRA,eACA,gBACA,OACA,0CACA,aACA,UACA,EACA,EAEA,YACA,WAAmB,gBAAsB,OACzC,IAGA,KADA,sBAEA,UACA,uCACA,WAEA,QAOA,uBACA,EAEA,CAzwDA,6EAAoG,OAAmB,SAAE,aAAmB,4FAA8H,YAI1Q,UAEA,IACA,IACA,oCAEA,cACA,0CAEA,oBACA,uCAEA,iBACA,qCAEA,eACA,sCAEA,YAAK,SAEL,CACA,CAEA,IA4DA,+BACA,GACA,gBAoCA,sDAKA,WACA,aAMA,cA8vBA,SACA,eACA,aApdA,WACA,aAkDA,UACA,SAEA,OApDA,OACA,IAGA,MACA,YACA,aAMA,UAIA,kBAIA,YAEA,CAEA,cAEA,aAEA,KAGA,4BAIA,mBAGA,UACA,4BACA,QAIA,gBAEA,QAMmB,gBAA8B,OACjD,QACA,WAEA,6BAKA,mCAIA,kCACA,eAEA,GACA,IAAK,mBACL,UACA,0BAEA,SAGA,MAAK,mBACL,QACA,OAEA,oBAAuB,QAAoB,OAC3C,MACA,KAEA,uBACA,uBAGA,QACA,aAnfA,UACA,IAGA,IACA,GAMA,0KAEA,uCAIA,4DAKA,+BACA,+BAAK,SACL,CACA,QACA,CAOA,CA40BA,GACA,QA/UA,aACA,OAEA,0BACA,0BACA,4BACA,CACA,WAGA,SACA,+BACA,eACA,eAEA,wBACA,SAEA,YACA,SACA,MACA,SAEA,sBAKA,SACA,SAIA,cAFA,IAGA,KAEA,IAEA,sBACA,KACA,MACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAGA,MADA,WA8RA,QA1XA,aACA,OAEA,OAEA,8BACA,0BACA,4BACA,CACA,WAGA,SACA,+BACA,eAEA,6BACA,SACA,OACA,eAEA,MACA,SAEA,MACA,IAEA,sBACA,KACA,MACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,SAGA,EAkVA,QA5RA,eACA,OAEA,OAEA,8BACA,IACA,4BACA,YACA,QACA,oDAIA,YACA,IAGA,IAAS,mBACT,4BACA,CACA,WAGA,SACA,+BAMA,WACA,WAGA,kBAEA,gCAOA,CACA,eAGA,MACA,IACA,gCACA,qCACA,MACA,IACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,WA+NA,WA5NA,aACA,OAEA,OAEA,8BACA,0BACA,4BACA,CACA,WAGA,SACA,+BAMA,eACA,oCACA,CACA,GAEA,sBACA,KACA,MAIA,sBACA,qCACA,MACA,IACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,WAmLA,MAhLA,WACA,OAEA,0BACA,0BACA,4BACA,CACA,WAGA,SACA,+BACA,eAEA,+BACA,CACA,GAEA,gCACA,qCACA,MACA,IACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,WAmJA,OAhJA,WACA,OAEA,0BACA,0BACA,4BACA,CACA,WAGA,SACA,+BACA,eAEA,8BACA,KACA,OAEA,sBACA,KACA,MACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,WAoHA,IAjHA,aACA,OAEA,0BACA,OACA,YAKA,oCACA,4BACA,CACA,WAGA,SACA,+BACA,WACA,SAEA,mCACA,SAGA,qBAQA,UAKA,WAOA,MANA,OAGA,oBAZA,KAiBA,sBACA,KACA,MACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,WAwDA,KArDA,WACA,OAEA,0BACA,0BACA,4BACA,CACA,WAGA,SACA,+BACA,eACA,aAEA,2BACA,SAGA,8BAKA,OACA,mBAFA,KAIA,sBACA,KACA,MACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,SAGA,KAuBA,qEAGA,kCACA,gBAGA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,aAEA,uCAkMA,CACA,UArIA,aACA,OAEA,eAOA,+FAGA,IAGA,KAFA,cAGA,cACA,IAEA,WAEA,OACA,yBACa,KACb,0BACa,KACb,iCACa,KACb,0BACa,KACb,2BACa,KACb,0BACa,KACb,2BACa,KACb,4BACa,KACb,4BAEA,iBAIA,4CACA,KAAK,6BAEL,UAEA,+BAEA,OArIA,yCAuIA,UACA,MAEA,IACA,oBACA,SACA,QACA,aAAS,SACT,eAEA,oDACA,OAEA,CASA,EA0DA,YAzDA,WAIA,gBACA,qBAMA,iBACA,iBAEA,eAGA,sBACA,SACA,aACA,sBACA,OACA,OAIA,KACA,UACA,OACA,SACA,oBAAyC,CACzC,SACA,iBACA,cACA,iBACA,eACA,iBACA,sBACA,iBACA,eACA,iBACA,gBACA,iBACA,eACA,iBACA,gBACA,iBACA,iBACA,iBACA,iBACA,wBAEA,oBAEA,EAIA,iBAaA,qBAuSA,SACA,gBACA,aAxSA,WACA,OACA,OACA,IAGA,MACA,YACA,mCAIA,8CAGA,IACA,uDACA,KAAS,SACT,OACA,KAGA,6BACA,oHACA,GACA,UACA,GAAa,eACb,CACA,IACA,EACA,EAEA,GAEA,SADA,0BAjRA,UACA,OACA,+BAKA,CAkhBA,GACA,QAvOA,aACA,OAEA,0BACA,0BACA,SAEA,oCACA,2DACA,aACA,SAEA,SAAmC,EAAY,QAC/C,SACA,YAKA,4BAGA,8BAIA,OACA,OAGA,WAFA,KAIA,CACA,GAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,WA+LA,QAvQA,aACA,OAEA,OAEA,8BACA,0BACA,SACA,oCACA,qFACA,0CAKA,wBAGA,gBACA,IAAiB,eAEjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,WA4OA,QAtIA,eACA,4BACA,KAqIA,WAnIA,aACA,OAEA,OAEA,8BACA,0BACA,SACA,oCACA,wEACA,CACA,GAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,SAIA,EA6GA,MA5GA,WACA,OAEA,0BACA,0BACA,SACA,oCACA,sDACA,CACA,GAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,SAIA,EAwFA,OAvFA,WACA,OAEA,0BACA,0BACA,SACA,oCAEA,yEACA,sBAEA,EACA,IAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,SASA,EA2DA,IA1DA,aACA,OAEA,0BACA,0BACA,SACA,oCACA,wFACA,wCACA,KACA,IAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,WAyCA,KAtCA,WACA,OAEA,0BACA,0BACA,SACA,oCACA,6DACA,QAEA,QAAmC,WAAyB,OAC5D,0BAGA,KACA,IAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,SAGA,MAuRA,SACA,sBACA,aA5OA,WACA,OACA,KACA,KACA,YACA,aAIA,+BAEA,mCACA,qCAGA,MACA,OAGA,YACA,YAEA,gBACA,UAGA,WAzDA,UACA,IACA,mEACA,uCAAK,SACL,CACA,QACA,CAEA,CAoQA,GACA,QArKA,aACA,OAEA,gCACA,aACA,YACA,cACA,sBAQA,SAEA,IAAuB,IAAY,IACnC,sBACA,OAGA,qCAOA,iCAGA,qCAEA,SACA,OAGA,SAEA,GAEA,MADA,SAGA,EA0HA,QA/LA,aACA,OAEA,OAEA,oCACA,SACA,iCAOA,aAIA,0BADA,iBAGA,GAEA,MADA,SAGA,EAwKA,QAhDA,eACA,OAEA,OAEA,oCAGA,CACA,eAIA,SAEA,+BACA,SACA,8CACA,CACA,KAEA,aACA,wBACA,eACA,IAAqB,SAGrB,iCACA,wCAEA,KACA,IAEA,CACA,EACA,EAEA,GAEA,MADA,SAGA,EAQA,WAnEA,aACA,OAEA,OAEA,oCACA,SACA,kCACA,YAEA,GAEA,MADA,SAMA,EAmDA,MAvNA,WACA,OACA,gCACA,qBAEA,gCAA6C,IAAQ,KACrD,mBAEA,OACA,+BAGA,aAEA,GAEA,MADA,SAKA,EAoMA,OAhFA,WACA,OACA,gCACA,UACA,MAEA,GAEA,MADA,SAGA,EAuEA,IA9HA,aACA,OACA,gCACA,SACA,QACA,KACA,gBACA,MAAS,SACT,GACA,IAIA,CAIA,qCADA,UAGA,GAEA,MADA,WA6GA,KA1GA,WACA,OACA,gCACA,aACA,uBACA,OAEA,OAAuB,IAAY,IACnC,mBACA,OACA,2DAIA,SACA,QAEA,GAEA,MADA,SAGA,gCAsFA,OACA,oDAIA,EAEA,MAEA,SACA,CACA,YACA,UAGA,4EAEA,SAEA,iFACA,aACA,aACA,aAGA,mBACA,kBACA,gBACA,wBAgCA,cACA,QAGA,QADA,mCAEA,OACA,UACA,QAEA,UAIA,YAEA,eAGA,qBACA,sBAAgC,UAChC,kCACA,sBACA,UACA,uBAEA,UACA,uFACA,EAQA,CA0OA,qCAtOA,wDAGA,SACA,iBAGA,+EACA,IACA,yCAGA,oBACA,uCAGA,sDACA,IAIA,uBACA,mCAIA,UAAS,OACT,wBAEA,gBAEA,OAMA,0CACA,0BACA,IACA,SACA,aAIA,qGACA,QAIA,WAHA,0BAIA,wBAA2D,SAAS,IACpE,SACA,gBACA,wBAKA,WAJA,uBAKA,CACA,oBAEA,qCACA,QAIA,QACA,GAEA,EACA,2BACA,2CAEA,gBAGA,UAEA,KAAa,SACb,CACA,IACA,CAEA,GAEA,MADA,WAGA,+BACA,sBACA,IAEA,uCACA,iDAEA,sBAEA,MADA,WAGA,uCACA,SACA,YAEA,MADA,SAGA,+BACA,OAEA,mCACA,OACA,8BAGA,iBACA,MAEA,GAEA,MADA,WAGA,uCACA,aASA,oBACA,QAEA,cACA,UACA,WAEA,8BACA,WACA,MAEA,cACA,kBACA,aAGA,kBACA,OACA,WAEA,eACA,cAEA,4BACA,WAEA,CACA,oBACA,4DACA,YACA,UAEA,OAjBA,QAkBA,IACA,CAKA,OA9CA,KACA,UAGA,gBAEA,mDA4CA,6CAHA,UACA,SAAS,2CAGT,SACA,oBACA,cAEA,oCACA,aACA,QACA,MACA,6CACA,IACA,EAAS,sBACT,CACA,oBACA,4DACA,YACA,UAEA,UACA,qBACA,UAEA,kCACA,SACA,KAEA,iCACA,GACA,OAEA,8CACA,QACA,cAA6C,SAAS,IACtD,MACA,UACA,eAGA,QACA,QAEA,qDAKA,kBAAoD,OAAS,IAC7D,WAEA,MAEA,wCACA,OACA,SAEA,GAOA,cA/5DA,GACA,GAg6DA,EAEA,UAAc,kBACd,EAAC,oCCv3ED,aACA,qCAA8C,CAAc,WAC5D,QACA,QAGA,IAWA,UAVA,WACA,CACA,cACA,mBACA,YACA,wBACA,QACA,wBAEA,+CCjBA,aACA,qCAA8C,CAI9C,WACA,gBACA,cACA,MAEA,kBAEA,SACA,CAqCA,sDApCA,eACA,oDAAsE,OAAiC,kBACvG,EACA,EACA,cAEA,gDACA,gCACA,SACA,iCACA,OAEA,QACA,mBAEA,iDACA,UACA,6DACA,kBAAiD,yCAAiC,YAClF,OAEA,oBACA,wBAAqD,UAA6B,UAGlF,UACA,+BACA,gBACA,GAEA,cADA,YAEA,KACA,iCACA,4BACA,OACA,GACC,IACD,6BCtDA,aACA,sCACA,cACA,gBAAU,CAAgB,4CAAsC,GAAiB,WACjF,gBAAyB,2CAAuD,KAChF,sBACA,aACuB,MAAsB,aAC7C,CADA,sEAEA,MACA,CAAC,IACD,qCAA8C,CAI9C,WACA,QAoBA,iBACA,aAEA,0CAIA,KAEA,2BADA,GAOA,CAyHA,MAtIA,uCAcA,UACA,uBAEA,iMACA,OASA,iCACA,wBACA,UAQA,kCACA,wBACA,WAUA,gCACA,wBACA,SAUA,qCACA,wBACA,cAQA,mCACA,wBACA,YASA,+BACA,wBACA,QACA,kCACA,wBACA,WACA,uCACA,wBACA,gBAIA,gCACA,wBACA,SAMA,iCACA,wBACA,UASA,gCACA,wBACA,SAOA,oCACA,wBACA,aAEA,oCACA,wBACA,aAIA,sBACA,GACC,wBACD,2BCzKA,aACA,qCAA8C,CAG9C,WACA,gBACA,aAiCA,iBACA,IAKA,CAIA,qCAHA,CACA,QACA,GACC,IACD,kCCnCA,aAEA,EAUA,kMCRA,aA2BA,UAzBA,iBACA,WACA,YACA,iBAEA,SAIA,GACA,YAEA,KACA,KACA,aACK,YAEL,QACA,SACA,KAEA,OACA,2BCtBA,aAgBA,MAfA,UACA,QAEA,QAAiB,IAAS,UAC1B,CACA,cAAmB,EAAO,IAC1B,+BAEA,EACA,MAEA,CACA,QAEA,IAkBA,UAdA,iBAEA,KAIA,SAAmB,KAAS,EAF5B,IAGA,cAGA,qBACA,sBCtDA,aAmFA,eAEA,IACA,4BACA,mCAIA,0BACA,KAAiB,EAAS,IAC1B,SAEA,MACA,QAGA,CAhGA,QAQA,GACA,UAEA,GAAK,SAAwC,SAAE,SAAa,CAAsB,KAClF,GAAK,6BAAoD,GAAE,SAAa,CAA0B,IAMlG,CACA,4BAAe,EAAS,MACxB,sDACA,EACA,cAGA,EACA,wBACA,kBAGA,kBAAiB,EAAiB,IAClC,QACA,kCACA,uBACA,GACA,4CACA,OAGA,oCAIA,cAGA,cAAwB,EAAa,IACrC,QACA,kCACA,uBACA,GACA,4CACA,OAGA,MAEA,QACK,OAEL,uBACA,aACK,MAEL,wBACA,cACA,oBAGA,sBACA,cACA,qBACA,oBAIA,MACA,QAEA,EAkBA,2BACA,cACA,OAGA,EACA,2BACA,wBACA,gBAAmC,OAAS,IAC5C,WAEA,cACA,QAGA,EACA,0BACA,YAMA,eAEA,WAPA,YAOsB,EAAS,KAC/B,QAEA,WAAmB,GAAqB,OAAU,QAElD,MAEA,SAAoB,QAA0B,WAAgB,EAAU,QAGxE,uBAEA,UACA,YACA,UAIA,WAAoB,QAA0B,MAAU,QAExD,CACA,UAEA,WACA,mBACA,wBAEA,OAEA,OACA,OAQA,EACA,0BACA,IAEA,cACA,WAAyB,aAGzB,YACA,QAAkD,iBAIlD,UAIA,OAEA,YACA,0BCrKA,aA2BA,UAzBA,UAEA,YACA,kBAEA,gBAEA,gBAEA,cACA,mBAEA,iBAEA,iBAEA,WAEA,cAEA,oBAEA,aACA,gBCzBA,aAEA,UAGA,YACA,kBACA,eACA,eACA,WACA,UACA,UAKA,OACA,eACA,cACA,WACA,kBACA,gBAEA,eAIA,mBACA,eACA,qBACA,yBAGA,aACA,iBACA,QACA,UACA,qBAGA,WACA,SAEA,YAGA,aAEA,oBC/DA,aA0CA,aACA,OACA,8CAgOA,aACA,IACA,qBACA,oBACA,SA/QA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAC9C,WACA,QAGA,GAIA,EAGA,WACA,gBAWA,aACA,aACA,oBACA,CAoMA,+BAlMA,CAEA,aADA,QAEA,6CACA,YACA,SACA,iBASA,kCARA,mBACA,4DACA,sDACA,+DACA,mEACA,6DACA,oCACA,OAEA,4CACA,kCACA,gBACA,8CACA,kCACA,kBACA,wCACA,iBACA,4BACA,0BACA,uDACA,4CACA,6DAEA,qBACA,QACA,yCACA,iBACA,4BACA,0BACA,0BACA,sDACA,yCACA,4BAEA,wCACA,QACA,2CACA,iBACA,gBAGA,kCAFA,kEACA,cAEA,0CACA,kBACA,oBACA,yCACA,4BACA,eACA,6CACA,iCACA,kCACA,yBACA,MACA,oCACA,SACA,aACA,uCACA,SACA,gBACA,uCACA,KAAgC,kCAChC,cACA,yBAEA,2BAEA,0EAEA,6BAEA,OAHA,KAFA,IAMA,uCACA,KAAgC,kCAChC,qDAEA,8CAEA,uBAKA,UAEA,qDACA,6BAEA,OATA,KAFA,IAYA,gCACA,8BACA,UACA,EAEA,OADA,gDAEA,0BAGA,yBAEA,QADA,gDAEA,0BAGA,iCAGA,MAUA,mBATA,wBACA,0BACA,mBACA,oBACA,iCACA,4BACA,yBACA,wBACA,OAMA,gCACA,aACA,SAIA,6BAMA,+EACA,CACA,QACA,wCACA,uCACA,SACA,2BACA,UACA,WACA,aACA,SACA,uDACA,0BACA,WACA,MACA,2CACA,iDAAuE,qBAAyB,EAChG,QACA,GAGA,SAFA,8BACA,aAEA,GAEA,SADA,wBAEA,KACA,iBACA,SAEA,WACA,EACA,EACA,uDACA,eACA,0EAEA,sBACA,eAEA,SACA,cAEA,SACA,cAGA,sBAEA,oCACA,EACA,cAEA,yFACA,yDACC,IA9MD,EA+MA,EAGA,UACA,MAGA,oBC3QA,aACA,qCAA8C,CAK9C,WACA,gBACA,CAKA,oBAJA,MACA,kBACA,SACA,CACC,IACD,4BCdA,aACA,sCACA,cACA,gBAAU,CAAgB,4CAAsC,GAAiB,WACjF,gBAAyB,2CAAuD,KAChF,sBACA,aACuB,MAAsB,aAC7C,CADA,sEAEA,MACA,CACA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAAc,WAC5D,QACA,QAIA,iBACA,cAEA,gCACA,KAOA,MANA,UAEA,uBACA,iDACA,qDACA,WAGA,CAkEA,MA7EA,uCAYA,uCACA,IACA,4BACA,UACA,oCACA,YACA,GAKA,SAJA,2CACA,UACA,cAGA,EACA,EACA,kCACA,YAAoC,WACpC,kCACA,OACA,2BACA,UACA,WACA,MACA,mBACA,4CACA,YACA,YACA,OAEA,8BACA,0EACA,uBAGA,aACA,EACA,EACA,0CACA,oEACA,oBACA,yCACA,oEACA,oBACA,uCACA,uCACA,yBACA,CACA,SACA,EACA,EACA,sCACA,uCACA,0BACA,UACA,WAEA,yBACA,YAEA,GAGA,SAFA,YAGA,EACA,EACA,GACC,YACD,6BCvIA,aACA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAI9C,WACA,QAIA,gBAWA,aACA,2BACA,QACA,oCACA,2CACA,MACA,+CACA,SACA,SACA,gGACA,QACA,IACA,mBACA,qDACA,8BACA,qCAA6C,uBAC7C,QACA,CA8EA,+BA5EA,CAEA,aADA,QAEA,sCACA,qBACA,eACA,sCACA,KAAmC,WACnC,2BACA,yBAAoD,kBAAgB,WACpE,OACA,SACA,mCACA,wDACA,QACA,CACA,4CACA,0BACA,qBACA,gDACA,2BACA,UACA,yCAEA,oBACA,QACA,4DACA,oDACA,2BACA,6DACA,qCAAuB,MAAoB,WAC3C,OACA,WACA,oBACA,UAMA,uBACA,IACA,GACA,gBACA,oBAEA,KAKA,eAHA,8BACA,OACA,UAEA,6BACA,uCACA,SACA,0BACA,eACA,0BACA,oFACA,0BACA,OACA,SACA,QACiB,GACjB,OACA,SACA,QAEA,MACA,kBACA,YACA,UACA,IACA,EACA,EACA,GACC,IAtGD,EAuGA,EAIA,UACA,+GC3JA,aACA,qCAA8C,CAI9C,WACA,MACA,YAEA,YAEA,iBACA,KAAC,iBAGD,WACA,MACA,YAEA,YAEA,iBAEA,kBAEA,mBAEA,mBACA,MAAC,iBAA8C,0BC3B/C,aACA,qCAA8C,CAM9C,WAOA,eANA,WACA,oBACA,SACA,eACA,kDACA,yBCdA,aA4CA,aACA,uCACA,IACA,2BACA,iCACA,mCACA,GACA,WACA,YACA,KACA,kBAAuC,CAAc,QACrD,GACA,EACA,GASA,aACA,uCACA,OACA,0BACA,QACA,UACA,4BACA,sDACA,OACA,KACA,EACA,GA5EA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAO9C,WAeA,EAOA,iBAaA,EAUA,yBAeA,oBAdA,UACA,uCACA,IACA,2BACA,iCACA,gBACA,gBACA,oCACA,sBAAkD,UAA+C,KACjG,IACA,OACA,GACA,EACA,qBCrGA,aAwDA,aACA,YAA8B,WAE9B,2BAA2C,OAAsC,gBACjF,EAIA,CA/DA,sCACA,cACA,gBAAU,CAAgB,4CAAsC,GAAiB,WACjF,gBAAyB,2CAAuD,KAChF,sBACA,aACuB,MAAsB,aAC7C,CADA,sEAEA,MACA,CACA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAAc,WAC5D,QACA,OACA,OACA,OACA,OACA,OAGA,gBAUA,aAEA,0CACA,KAEA,qBADA,YAEA,CAiVA,MAtVA,sCAMA,CACA,QACA,6BACA,uCACA,yBACA,CACA,SACA,EACA,EACA,sDACA,uCACA,0BACA,UACA,WACA,eACA,yBACA,eACA,YACA,eACA,+BACA,YACA,wDACA,mBACA,qCACA,KACA,eACA,SAEA,WACA,EACA,EACA,yCACA,uCACA,IACA,4BACA,UACA,WACA,eACA,sDACA,cACA,cACA,YAEA,SACA,EACA,EACA,2CACA,uCACA,IACA,4BACA,UACA,+DACA,aACA,cACA,YAEA,oCACA,EACA,EAKA,iDACA,uCACA,yBACA,0EAAiI,OAAa,KAC9I,GACA,EACA,EAKA,mDACA,uCACA,IACA,4BACA,UACA,uFAA4I,OAAa,KACzJ,QACA,cACA,OACA,uBACA,aAEA,MACA,EACA,EAIA,uCACA,uCACA,0BACA,UACA,mCACA,kCACA,kDAEA,wBACA,GAGA,SAFA,YAGA,EACA,EAEA,wCACA,MAEA,2CACA,yCACA,6BACA,sBACA,uBACA,wBACA,IACA,gCACA,uCACA,OACA,8BACA,UACA,WACA,YACA,2BACA,4DACA,8BACA,iBACA,oBACA,0CACA,0BACA,iDACA,KAEA,IAGA,IAEA,0CACA,iEACA,cACA,QACA,GAIA,SAHA,6BACA,yBAGA,EACA,EACA,gDACA,uCACA,eACA,2BACA,UACA,WACA,YACA,2BACA,0CACA,qDACA,WACA,sCACA,UACA,oDACA,gCACA,gBACA,+EACA,MACA,+BACA,yBACA,mBACA,qBACA,uBACA,iBACA,qBACA,YACA,yBAAqD,UAAwB,SAC7E,sBACA,YACA,MACA,WACA,sBACA,GAOA,SANA,yBAAqD,UAAwB,SAC7E,sBACA,YACA,MACA,QAGA,EACA,EACA,gDACA,uCACA,WACA,2BACA,UACA,WACA,YACA,2BACA,qCACA,mCACA,uDACA,kBACA,wEACA,YACA,uCACA,UACA,qDACA,gCACA,gBACA,oGACA,OACA,WACA,qBACA,YACA,yBAAqD,UAAuB,SAC5E,sBACA,YACA,MACA,WACA,sBACA,GAOA,SANA,yBAAqD,UAAuB,SAC5E,sBACA,YACA,MACA,QAGA,EACA,EACA,6CACA,uCACA,IACA,4BACA,UACA,WACA,YACA,mCACA,uDACA,qBACA,YAEA,mBACA,mCACA,GAGA,SAFA,YAGA,EACA,EACA,4BACA,uCACA,uBACA,2BACA,UACA,WACA,YACA,2BACA,qCACA,mCACA,kDACA,4BACA,4CACA,6BACA,gDACA,8BACA,+CACA,mBACA,qCACA,0BAA2D,UAAkD,UAC7G,UACA,aACA,QACA,UACA,MACA,cACA,eACA,QACA,+EACA,OACA,OACA,gBACA,KACA,eACA,MACA,KACA,+BAA2E,UAA8B,MACzG,8BAA6E,UAA8B,MAC3G,2CACA,qBACA,MACA,GAEA,MADA,eAEA,GAGA,oFAFA,YAGA,EACA,EACA,sCACA,SACA,mBACA,gBACA,2BACA,qCACA,mCACA,oDACA,kBACA,8DACA,sEACA,2EACA,QACA,QACA,QACA,MACA,uCACA,SACA,oBACA,iBACA,2BACA,qCACA,mCACA,oDACA,kBACA,gEACA,sEACA,2EACA,QACA,QACA,QACA,OACA,IACC,sBACD,yBC7ZA,GAGA,aACA,OACA,KAAC,IAED,GAEA,0CACA,OAAC,SAED,CACA,4BACA,OAI4C,CAE5C,6BChBA,aACA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAAc,WAC5D,QAIA,gBACA,aACA,CACA,CA+DA,qCA9DA,uCACA,qCACA,0BACA,KACA,OACA,4BACA,cACA,cACA,SACA,kBACA,MACA,kBACA,MACA,oBACA,qBACA,OAA+B,EAAS,MACxC,0CAEA,oCACA,oBACA,eACA,YACA,mBAA+B,EAAc,IAC7C,WAEA,QACA,QACA,KACA,IACA,UACA,mBACA,IAA2B,MAA2B,OACtD,UACA,gBAEA,cACA,IACA,EACA,EACA,IAsBA,isDACC,IACD,6BC/GA,aAEA,WAEA,WACA,QACA,QAEA,SAEA,WAEA,6BCbA,aAuHA,aACA,+BAEA,gCACA,CACA,QACA,mBACA,iBACA,YACA,EACA,cACG,IAEH,kBAEA,eACA,+BAGA,mCACA,gCAGA,aACA,WACA,QACA,cAEA,oBACA,0BAEA,UACA,kBACA,OACA,QACA,SACA,aACA,WAGA,aACA,sBAGA,WACA,uCAGA,qBACA,IAEA,QAEA,6CACK,YACL,+DAEA,cAGA,yCAEA,QACA,sBAGA,WACA,YACA,CA8BA,CAyIA,eACA,OAEA,cAGA,aAAqB,qBAErB,cACA,MAUA,CAlXA,QACA,QACA,OACA,QACA,OAEA,uBAKA,WAGA,IACA,IACA,IAEA,KAEA,IAEA,IA6FA,EAoGA,8BACA,YACA,oBACA,YAEA,UAAmB,MAEnB,qBAGA,SArNA,UAuNA,qBACG,cACH,sCAKA,2BACA,qBAEA,SACA,IACA,iCACA,mBACA,IAEA,iBAEA,oBACA,MAIA,YAHA,cACA,sDAGA,UACA,8EAEA,+CAGA,WAAG,wCAGH,aACA,4BACA,WACA,cACA,SAIA,OACA,aACA,qBAKA,KAWA,EACA,8BACA,aACA,OAYA,EACA,6BAEA,CACA,QACA,wDAEA,qCAGA,cACA,eACA,yBACA,GAoCA,EA2CA,YACA,YACA,aAxBA,aACA,UACA,QACA,OACA,MAUA,EAWA,OAVA,aACA,UACA,QACA,QACA,yBCtXA,aAyGA,eACA,CAEA,aADA,OAGA,aACA,qBACA,GAEA,aAAoB,aAAsB,OAAqB,aAAgB,CAQ/E,CACA,aACA,SAGA,UACA,YACA,gBAEA,WAEA,4DACA,YACA,cACA,iBACA,eACA,eACA,WACA,8BAEA,IAGA,eACA,oEACA,+BACA,aACA,MAGA,eACA,iBACA,YAOA,CACA,eAGA,4BACA,qCACA,KASA,CACA,mBACA,SAEA,gBAAmB,MACnB,KAAkB,OAElB,KAGA,mCACA,aACA,6BAGA,aACA,+BAGA,gBACA,aAGA,cAWA,CACA,eACA,SACA,qBACA,aAGA,gBACA,0BACA,iCAEA,MAEA,WACA,WAMA,SACA,mBACA,OAQA,KAzBA,EACA,mBAyBA,iBAKA,OAAiC,gBAIjC,aAEA,IAWA,MACA,gBACA,eACA,mBACA,GASA,YACA,EAMA,IAEK,qCACL,kCACA,kCACA,kCACA,MAIA,aACA,OAEA,QACA,MACA,cACA,IACA,KAEA,cACA,OACA,IACA,CAAG,qBAEH,oBAGA,cACA,SAYA,CACA,aACA,SACA,eAIA,IACA,kCAoBA,6BAEA,kCACA,KACA,iBAEA,cASA,mBACA,UACA,IACA,YACA,wBACO,QAEP,KACA,IACA,IACA,YACA,wBAIO,QAEP,KACA,IACA,IACA,oBAeA,0CACA,eAGA,2BACA,6BACA,iBAGA,0DAIA,YAEA,2DAEA,sCACA,gBACA,SACA,MACA,yBASA,aAAG,sBAsCH,oBAUA,CAmGA,eACA,CAGS,OAFT,GAEA,IAMA,kBACA,IACA,oBACA,MAEA,aACA,gBAEA,KAKA,MACA,IAEA,0EACA,iDACA,yBAOA,iCAKA,0BAGA,YAKA,8CA0CA,aACA,cAEA,8DA3CA,+BAKA,8DACA,GACA,eACA,KAEA,sEACA,iDACA,yBAKS,eACT,uBACA,UAEA,oBACA,4BACA,qBAEA,mEAaA,UAOA,OACA,QACA,sBAIA,SACA,6CACA,EAEA,OACA,QAMA,8BAEA,WACA,QAMA,2BAMA,CACA,eACA,CAMS,OALT,GAEA,EAGA,IAMA,kBACA,IACA,oBACA,MAEA,aAA8B,gBAC9B,KAKA,MACA,IAEA,0EACA,iDACA,yBAMA,0BACA,4BACA,6BAEA,yBACA,gCAKA,0BAGA,OACA,wDAKA,kDAMA,oDACA,gBAOA,wDAMA,0CACA,iBACA,EACA,MAEA,yEACA,iDACA,yBAGO,gBACP,oBAMA,qBALA,mBACA,IAEA,eAGA,QACA,sBAKA,SAAK,YAOL,kCAiBA,IACA,aAEA,0DAhBA,OAGA,UACA,aACA,YACA,qBAMA,SAMA,UAGA,wDAEA,sBAEA,wCACA,EAEA,OACA,QAMA,8BAEA,WACA,QAOA,2BAOA,CACA,eACA,CAMS,YAAT,OALA,EACA,IAEA,IAOA,mBACA,IACA,qBACA,MAEA,aAA8B,gBAC9B,KAGA,mBACA,kBACA,4BACA,IACA,yCACA,KACA,WAES,2BACT,wBACA,wBACA,wBACA,MACA,uBACA,sBACA,6BAEA,UAKA,CAoBA,KAhBA,qCAEA,+BACA,2BACA,4BAKA,iCAEA,aACA,cAEA,gBAGA,QACA,sBAIA,SACA,iBACA,EAEA,OACA,QAMA,8BAEA,WACA,QAMA,2BAKA,CACA,eACA,CAES,OAAT,KAEA,IACA,kBACA,sBACA,IACA,MAEA,UACA,KAIA,CAQA,kBALA,+BACA,aACA,cACA,eAGA,QACA,sBAIA,SACA,iBACA,EAEA,OACA,QAMA,8BAEA,WACA,QAMA,2BAMA,CACA,qBACA,MACA,mBACA,gBACA,mBACA,iBACA,MAEA,CAqBA,aACA,mBAGA,WAIA,mCACA,kCACA,qCACA,2CAEA,qBACA,gBACA,cACA,WACA,iCACA,oBACA,UACA,EAGA,YACA,WACA,iBACA,mBACA,2BACA,mBACA,eACA,YACA,cACA,kBACA,OACA,0BAEA,cACA,cACA,cAEA,cAQA,sBAKA,YAMA,eAEA,gBACA,iBACA,iBACA,iBAEA,kBAOA,mBAKA,oBACA,kBACA,uBACA,gBACA,mBACA,iBAEA,mBAKA,wBAMA,sBAYA,aACA,gBAEA,kBAGA,kBAYA,6BACA,gCACA,oCACA,kBACA,kBACA,kBAEA,qBACA,iBACA,kBAGA,iCAIA,6BACA,UAEA,oBACA,gBAKA,6BACA,UAIA,kBAEA,mBAoBA,gBAEA,aAMA,eACA,kBACA,eACA,cAGA,cAIA,gBAaA,EAGA,aACA,IAEA,eACA,8BAIA,IAEA,gBACA,gBACA,gBAEA,EACA,qBAGA,iBACA,kBACA,WAEA,EACA,IACA,eAEA,eAnBA,OAsBA,aACA,OACA,KAIA,MAHA,YAEA,SAYA,uBACA,IACA,GAEA,eAEA,KACA,UAGA,GACA,OACA,IAGA,IACA,SACA,KAIA,cACA,uBACA,UACA,UAIA,QACA,UAIA,SAEA,eACA,UAEA,SACA,gBACA,OACA,uBACA,yBAEA,gBACA,mBACA,kCACA,iCAEA,0BACA,iCACA,gCAKA,2BAEA,qBAIA,2CAIA,8BAGA,wBAEA,cACA,UACA,aAEA,SACA,KAr2CA,QACA,OACA,QACA,OACA,QAOA,KACA,IAIA,IAOA,IACA,IAGA,KACA,KAUA,KAGA,IACA,IACA,IAEA,IAUA,IAKA,IAEA,IASA,IAEA,EAJA,KAMA,KAEA,SAEA,IAGA,KACA,IACA,UAEA,IAGA,KACA,KACA,KACA,MACA,OACA,OAEA,OACA,KACA,KACA,KAEmB,KA+5BnB,GAEA,aACA,EAziBA,aAIA,OAEA,MAKS,yBAJT,yBAIA,KAEA,mBASA,IACA,sBACA,MAGA,aACA,gBAGA,KAIA,eACA,sBAGA,UAEA,oCAEA,6BACA,aAEA,WACA,QACA,sBASA,yCAEA,WACA,QACA,sBAIA,SAEA,iBAEA,EAEA,OACA,QAOA,yCAEA,cACA,QAOA,2BAQA,eAycA,kBACA,kBAEA,mBACA,oBACA,qBACA,sBACA,wBACA,yBAMA,SAqxBA,cApcA,aACA,OACA,SAzyCA,GAGA,EAhBA,IAyvDA,iBACA,iBACA,qBACA,mBA9hBA,aACA,aACA,MACA,0BAEA,iBA0hBA,UApcA,aACA,OACA,IAEA,YACA,YACA,aAGA,gBAEA,SACA,kBACA,+BACA,iBAGA,0BACA,WACA,aAGA,eAEA,cACA,mBACA,MACA,QACA,SACA,KACA,6BAaA,oBACA,mBACA,oBACA,uBAEA,WACA,uBACA,0BACA,2BACA,uCACA,iBACA,YACA,OACA,gDACA,aACA,+BAEA,wCACA,iDAEA,cACA,IAIA,eArCA,OACA,OACA,OACA,OACA,mBACA,iBACA,YACA,GACA,SAGA,eA2BA,0BACA,KAEA,mBACA,UACO,EACP,UACO,EACP,YAEA,EAEA,QACA,EAA6B,iBAC7B,GAv2CA,YAy2CA,KACA,UAGA,OACA,+BACA,QAEA,wBACA,CAIA,MACA,6BACA,SAEA,mBACA,8CACA,oCACA,8CAEA,cACA,SACA,sBAIA,wBACA,iCAEA,2BACA,8CAEA,yCACA,mBACA,IAEA,SAEA,QAGA,cACA,4BACA,KAGA,UACA,kBACA,oCACA,8CAEA,cACA,SACA,wCACA,GACA,EACA,KAGA,2BACA,OAEA,0CAEA,EACA,MAAO,OAEP,wBACA,8CAEA,cACA,kBACA,IAEA,SAEA,QAGA,cACA,+BACA,KAGA,UACA,kBACA,oCACA,8CAEA,cACA,SACA,wCACA,GACA,EACA,KAGA,8BACA,OAEA,6CAEA,EACA,MAAO,OAEP,wBACA,8CAEA,cACA,UAEA,UAEA,QAGA,eACA,uBACA,oBACA,kBAEA,oBACA,uBACA,iBACA,wBACA,IAIA,cAMA,WACA,kBACA,KAOA,gBAQG,qBAPH,mCAQA,MACA,YAIA,0BACA,qBAKA,2BACA,sCACA,sBACA,oBA9jDA,EA+jDA,mBAEA,sBACA,YAEA,mBACA,OAaA,MAZA,iCAGA,QAUA,SACA,IAlnDA,IAonDA,aAEA,+BAIA,MAEA,IA3nDA,QA6nDA,MACA,6BACA,gBACA,WAIA,KACA,KACA,iBAIA,qBAHA,GAOA,OACA,OAGA,aACA,gBACA,iBACA,oBACA,qBACA,qBACA,oBACA,uBACA,wBAIA,oCACA,QAGA,gBAIA,KAAmB,qBAEnB,MACA,sBAyHA,aAvHA,WACA,IAEA,eAIA,iBACA,OACA,OACA,OACA,OACA,OACA,QACA,QAEA,QAGA,gBAEA,YACA,KAlrDA,OAwrDA,EA4FA,uBA3FA,aACA,SAEA,OACA,IACA,EACA,EACA,EACA,EACA,EAEA,YACA,MAGA,gBACA,UAEA,mCACA,UAIA,aAEA,8BAGA,WAGA,OACA,SAEA,YACA,iBACA,gBACA,WAIA,kBACA,2CACA,GACA,QAGA,YACA,aACA,YACA,QACA,qBACA,IACA,QACA,qBACA,KACA,0BACA,GAEA,qDAEA,sCAEA,gBACA,SACK,UACL,OACA,yBACA,EACA,IACA,CAWA,qBAVA,0BACA,oBACA,sBACA,iCACA,oBACA,IACA,YACA,UACA,aACA,UAYA,cASA,sDC9zDA,aAuBA,aAAoB,aAAsB,OAAqB,aAAgB,CAI/E,CAuHA,qBAEA,MACA,mBACA,kBACA,kBACA,aAGA,iCACA,OAQA,eACA,MACA,yBACA,OACA,YAIA,aACA,8BACA,GAMA,CACA,eAGA,4BACA,iCACA,SAMA,CACA,iBACA,YACA,eACA,0BACA,wBACA,qBAEA,gBACA,sBAEA,aAGA,iBACA,kBACA,GAOA,CACA,eACA,OACA,EACA,MACA,SACA,MACG,QACH,kBACA,CAKA,CACA,aACA,CACA,uBACA,iBACA,aAEG,GACH,2CACA,wBACA,cAEA,EAYA,CAGsB,eAEtB,SACA,aACA,uBACA,0BACA,wBACA,yBACA,yBACA,aAOA,EANA,IACA,EACA,EACA,EACA,QAEgB,EAAkB,KAClC,kBAMA,gCAEA,eAA0B,EAAe,IACzC,SACA,0BACA,EACA,MACA,IAEA,WAGA,OAEA,UACA,gBACA,EACA,WAEA,UACA,mBAEA,gCAGA,WAMA,QACA,SACA,EAAoC,mBACpC,MACA,+BACA,IAIA,iBACA,CAAG,OAOH,SAAyB,IAAY,MACrC,YACA,YACA,iBACA,OACA,cAEA,mCACA,WAEA,MAGA,KAUA,CAIqB,iBAErB,eACA,KACA,EACA,EAKA,QAAgB,EAAkB,KAClC,qBASA,QAAa,EAAgB,SAC7B,aACA,GAEA,iBAIA,UACA,CAKA,CACA,YACA,eAqBA,GApBA,EACA,EACA,EACA,EACA,QAiBA,IAAgB,MAAyB,EACzC,QACA,UAAe,OAA8B,KAC7C,MAQA,eAGA,OACA,IAAgB,EAAW,KAC3B,QACA,UAAe,OAA8B,KAC7C,MAIA,OACQ,QAAR,EAAwB,IACxB,iBACA,IAAe,YAAoC,EACnD,UAMA,aAAgB,EAAkB,KAClC,SAGA,QACA,EACA,iBACA,EACA,MAEA,UACA,iBACA,EACA,MAEA,UACA,iBACA,EACA,MAEA,UACA,iBACA,EACA,MAMA,eAGA,OAAa,EAAa,IAC1B,aACA,aAIA,kBACA,oBACA,qBAGA,MAKA,CACA,aACA,IAGA,SAAa,EAAa,IAAQ,qBAClC,QAAa,EAAa,IAAQ,qBAClC,QAAa,EAAc,IAAO,mBAElC,mBACA,yBACA,uBACA,CAKA,CACA,aAEA,CACA,mBACG,QAEH,4CAEA,iBACA,aACA,CAKA,CAKkB,mBAElB,CAGA,SACA,WAKA,6CACA,WACA,UAKA,CACA,mBACA,OACA,MACA,gBACA,yBACA,IAOA,CAIY,iBAEZ,aACA,aACA,OAEA,eACA,sCACA,QAGA,uBAGA,qBACA,QAGA,QAEA,IACA,SAQA,CAI2B,iBAE3B,OAGA,EAFA,EACA,EAEA,EAEA,KACA,eACA,6DACA,qBACA,SAEA,IACA,MAIA,YACA,aACA,OACA,KACA,WACA,MAEA,UACA,MAGA,KACA,WACA,KACA,WACA,MAQK,qBAGL,UACA,QAUA,CAGsB,eAEtB,SACA,uBACA,0BACA,wBACA,SAEA,IADA,EAOA,iBACA,IAEA,aAAa,EAAW,IACxB,IACA,oBAaA,wBAZA,eAGA,QAUA,6CACA,SACA,aACA,IAGA,kCAIA,UAKA,yBAAuC,EAAQ,KAAO,IAKtD,SACA,IAGA,YACA,sBACA,kBAGA,YAEA,cACA,uBAGA,4BACA,+DACA,iBAGA,eACA,UAEG,SAEH,2CAKA,GAGA,eACA,SAMA,CAImB,iBAEnB,QAEA,IAIA,OACA,IACA,IAEA,EATA,EAGA,MAOA,UACA,MAEA,gBAEA,QAAa,EAAe,SAC5B,IACA,gBAEA,UACA,MAEK,aACL,eAEK,QAEL,MAIA,gBAGA,iBAGA,QAV+B,iBAC/B,iBAEK,UAQL,EAEA,IACA,SACA,MAEK,GACL,SACA,IAGA,MACA,IAEA,EACA,CAMA,CAImB,iBAEnB,QAEA,IAIA,OACA,IACA,IAGA,EAVA,EAGA,MAQA,UACA,MAGA,KAAa,EAAe,SAC5B,IACA,gBAEA,UACA,MAEK,iBACL,IAAU,WAAmC,eAExC,YACL,OASA,eACA,iBAGA,aACA,kBAGA,KAhBA,gBACA,SAGA,aACA,iBAEK,MAUL,EACA,IACA,SACA,MAEK,GACL,SACA,IAGA,MACA,IAEA,EACA,CAMA,CACA,aACA,IAGA,gCACA,mCAGA,gBASA,aAAkC,EAAkB,MAMpD,wBALA,KAUA,8BADA,GAQA,CAGkC,mBAElC,IAMA,iBACA,WACA,WACA,KAAgB,EAAgB,IAEhC,4BAIA,qBAGA,qBAEA,EAeA,CACA,aAKA,OACA,WAGA,QAAa,EAAS,eACtB,UACA,qBAKA,iCACA,qBACA,oBAEA,eAAc,GAAc,IAC5B,OACA,qBAOA,SACA,QAGA,CAgCW,mBAEX,oBACA,GACA,WAMA,CA7gCA,QASA,KAKA,IAEA,IAUA,IACA,IAeA,KAGA,QAGA,MAGA,KAGA,SAGA,IAGA,KAQA,KAGA,IAGA,MAGA,KAGA,KAIA,GAGA,8DAGA,wEAGA,0CAcA,oEASA,KAEA,iBAIA,KAEA,YAdA,KAmBA,KAEA,YA5FA,IARA,KAsGA,KAEA,gBAEA,MAEA,gBAEA,MAgBA,GA00BA,OAz0BA,GACA,MA2gCA,WAlMA,WAIA,MACA,IAGA,wBACA,+BACA,gCAEA,qBACA,aAGA,EACA,IAKA,EA6KA,qBACA,kBA/IW,iBAEX,OAIA,IAHA,EAMA,kBACA,YArhCA,qBAyhCA,YAIA,cAUA,UAGA,uBACA,uBAMA,EAAkC,OAIlC,YAGA,WASA,MAEG,wBAxkCH,GA0kCA,0BACA,GAGA,gBA7jCA,cA8jCA,iDACA,qBAMA,YAGA,QAIA,IAKA,EA8DA,YA1DkB,eAIlB,4CACA,gDAEA,wCACA,QAEA,WAEA,kBAEA,UAEA,UAKA,gBACA,4BA0BA,sCAKA,GAMA,YAhKA,WACA,UACA,GACA,SACA,IAMA,mBC7iCA,aA4FA,aACA,+BAEA,gCACA,WACA,iBACA,KACG,IAEH,kBAIA,gCACA,kCACA,WAA+B,iCAI/B,sBACA,wBACA,4BAKA,qBAGA,iBACA,qCAIA,aACA,WACA,QACA,cAEA,oBACA,0BAEA,UACA,kBACA,OAGA,qBACA,qBAGA,kBAEA,wCACA,OA6BA,CA0MA,eACA,OAEA,cAGA,aAAqB,qBAErB,cACA,MAUA,CAzYA,QACA,QACA,OACA,QACA,QACA,OACA,QAEA,uBAgFA,SAqFA,8BACA,YACA,oBACA,yBACA,WAQA,OAPA,MACA,EAIA,UAEmB,MACnB,yCAGA,mBAEA,qBACG,iBACH,sCAKA,2BACA,qBAEA,SACA,IACA,iCACA,mBACA,IAGA,6BAEA,kBAEA,mBACA,qBACO,cACP,sCAKA,+CAIA,4BACA,YACA,KAGA,gCACA,KAKA,YAJA,cACA,cAIA,uFAEA,iBAEA,sDAEA,cACA,4BAGA,YACA,uBACqB,wCAErB,QAGA,8CAYA,4BACA,kBAGA,KAAG,8CAEH,2BACA,mBAIA,gBACA,8BACA,WACA,cACA,eAIA,YACA,4BACA,kBAKA,KAWA,EACA,8BACA,aACA,OAYA,EACA,6BAEA,OACA,OAGA,wDAEA,qCAGA,cACA,eACA,yBACA,GAyCA,EAsCA,YACA,YACA,aAnBA,aACA,UACA,QACA,OACA,MAUA,EAMA,4BC9YA,aA6FA,aACA,QACA,aACA,yBACA,aACA,IAGA,YACA,WACA,OACA,kBACA,OACA,uBACA,YACA,aACA,aAEA,YAGA,gBACA,aACA,aACA,aACA,cAGA,eACA,YAGA,cACA,cAGA,aAGA,eACA,mBACA,kBACA,gBAGA,aACA,YACA,aACA,YACA,YAEA,2BACA,2BAOA,iBACA,kBACA,eACA,YACA,WACA,EAEA,aACA,IAEA,eACA,WACA,qCACA,QACA,KACA,eAEA,YACA,cACA,aACA,SACA,aACA,YACA,SAEA,2BACA,qCAEA,iBACA,UAGA,OAEA,aACA,IAEA,eACA,WACA,cACA,UACA,UACA,EAEA,QAEA,eACA,IACA,GAGA,cACA,WAGA,MACA,OACA,IAGA,cACA,EACA,UAKA,cAGA,6BACA,qBAIA,QACA,SACA,QACA,QAEA,eACA,IACA,GAKA,cAIA,QACA,iBACA,OACA,OACA,gBAGA,WAqBA,aAEA,OACA,IAEA,sBACA,oBAGA,MACA,EAAuB,mBACvB,OAAuB,mBACvB,OAAuB,mBACvB,OAAuB,mBAEvB,mCAAuE,MAGvE,MACA,EAAsB,kBAEtB,8BAAuE,MAGvE,IACA,KAEA,GACA,qBACA,IACA,uBACA,CAgBA,CACA,mBACA,SAIA,MAHA,QAIA,gCACA,cACA,UAEA,wBAIA,aACA,+CACA,WACA,YAGA,oBACA,MACA,MAGA,mCACA,OAGA,oCACA,KACA,kBAGA,UACA,qBAAwC,gBACxC,aAAsC,UAGtC,YACA,EArWA,QACA,OACA,OACA,QACA,QAEA,MAEA,IAWA,IACA,IAOA,IACA,KAIA,KACA,KACA,IAWA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,MAOA,OAGA,IAqLA,SAAoB,GAguCpB,iBACA,kBACA,qBACA,cApvCA,WACA,OACA,KApKA,GAiLA,EAsuCA,iBACA,UAzoCA,aACA,OAYA,eAMA,GAQA,mDAzBA,IACA,GACA,GACA,MACA,GACA,GACA,MACA,GACA,GACA,GACA,SAGA,SACA,GACA,GACA,GAGA,GAEA,uBAKA,kBACA,eAGA,aACA,QAA4B,aAI5B,aACA,cACA,YACA,eACA,YACA,WACA,cACA,UAGA,KACA,MACA,MAEA,KACA,UACA,gBACA,MACA,qBACA,GACA,OACA,KAEA,aACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,yBACA,SAEA,OACA,YACA,iCAIA,MACA,KAEA,IACA,OACA,KACA,YACA,IACA,cAEA,WACA,sCACA,OACA,2BACA,QACA,KACA,eACA,OACA,+BACA,QACA,KAEA,UACA,MAEA,aACA,EACA,cAEA,4BACA,OACA,wBACA,QACA,KACA,QAEA,sBACA,SAEA,cACA,KAEA,EACA,MAEA,mBACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,MACA,0BACA,OACA,+BACA,QACA,KACA,kBACA,OACA,6BACA,QACA,KACA,GACA,mBAEA,SAEA,mBACA,YACA,iCAIA,OACA,KAEA,IAEA,OAEA,mBACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,GACA,cAEA,SAEA,mBACA,YACA,gBACA,iBACA,kCAIA,OACA,KAEA,IAEA,OAEA,mBACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,GACA,qBACA,qBAEA,GAEA,mBACA,YACA,iCAIA,OACA,KAEA,IAEA,OACA,uBAEA,aACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,GACA,YACA,cAEA,cAEA,mBACA,YACA,iCAIA,OACA,KAEA,CACA,QACA,oBAEA,QAEA,OACA,UACA,oBACA,OAA4B,QAE5B,cACA,6BACA,eAEA,kCAEA,cACA,gBAaA,mBACA,0BAEA,gBACA,OACA,SAEA,cAA6B,aAE7B,oBACA,IAEA,OACA,uBACA,IAA2B,YAC3B,cACA,EAEA,WAEA,QACA,UACA,8BAEW,iBAEX,OAKoB,GAJpB,0BAEA,gBACA,OACA,eACA,UACA,QACA,mBAEA,eACA,IAEA,OACA,uBACA,IAA2B,YAC3B,cACA,EACA,WAEA,QACA,UACA,iCAEW,iBACX,OAKoB,GAJpB,0BAEA,gBACA,OACA,eACA,UACA,QACA,sBAEA,QAEA,OACA,sBAEA,aACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,yBACA,OACA,wBACA,QACA,KAEA,IACA,KAEA,CACA,GACA,mBACA,oBAEA,yBACA,IACA,OACA,MAEA,mBACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,iBAEA,SACA,KAEA,IAEA,OACA,UAEA,eASA,SARA,cACA,eACA,aACA,cACA,UAEA,QApsBA,kBAusBA,IAEA,OACA,cAptBA,GAotBqD,WAErD,WACA,iBAEA,OACA,SAEA,OACA,OACA,KAEA,YACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,eAEA,WACA,MAGA,EACA,UAGA,KACA,OACA,UACA,MAGA,OACA,aAEA,OACA,MAEA,OACA,UACA,CACA,UAGA,KACA,OACA,UACA,SACA,uBAGA,eACA,MAEA,EACA,MAEA,iBACA,SAGA,YACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,gCACA,OACA,iCACA,QACA,KACA,aAIA,YACA,KAEA,IACA,OAAgC,WAEhC,WACA,SAEA,OACA,eACA,UACA,IAA4B,QAC5B,OAA4B,QAC5B,OAA2B,YAE3B,aAEA,wBACA,OACA,OACA,OACA,SACA,WACA,KAEA,GACA,OACA,MAEA,mBACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,mBAEA,UACA,MAEA,kBAEA,QACA,MAEA,kBAEA,QACA,MAGA,yBACA,OACA,wCACA,QACA,KAGA,QACA,IAEA,OACA,4BAEA,YACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,qBAEA,WACA,MAEA,CACA,MACA,+BAMA,iBACA,iBAEA,KAAgB,QAChB,cA54BA,4BA64BA,sBAEA,QACA,OACA,6BACA,QACA,KAEA,QACA,IAEA,OACA,mCACA,CAAiB,OACjB,kCACA,UACA,MACA,cAEA,QAAsC,OAEtC,SAA6B,YAC7B,WACA,WACA,cAEA,CACA,IAEA,MACA,SAEA,gBAEA,eACA,YAEA,WACA,SACA,IAAiC,YACjC,WACA,WACA,cACA,CAGA,IACA,SAEA,kBACA,OACA,8BACA,QACA,KACA,kBACA,SAEA,YACA,MAEA,CACA,iBAEA,WACA,SACA,IAAiC,YACjC,WACA,WACA,cACA,CAGA,CACA,SAEA,UACA,QAEA,YACA,MAEA,CACA,KAEA,WACA,SACA,IAAiC,YACjC,WACA,WACA,cACA,CAGA,CACA,SAEA,UACA,SAEA,cACA,MAEA,CACA,6BACA,OACA,8BACA,QACA,KACA,MACA,eAEA,UACA,CAGA,MAAiC,UAGjC,yBACA,OACA,yCACA,QACA,KAKA,cAEA,KAAgB,QAChB,8CAGA,sBAGA,QACA,OACA,gCACA,QACA,KAEA,eAGA,eACA,WAAgB,QAChB,sDAGA,uBAGA,QACA,OACA,0BACA,QACA,KAEA,MACA,OAAgC,WAEhC,WACA,SAEA,OACA,yBAEA,GACA,cACA,eACA,aACA,cACA,UAEA,QAEA,aACA,cACA,YACA,eACA,YACA,WACA,cACA,UAGA,OACA,mBAEA,GACA,KACA,CACe,WAAf,IACA,kCACA,UACA,MACA,cAEA,QAAkC,OAElC,SAA2B,YAC3B,WACA,WACA,cAEA,CACA,oBACA,CAGiB,IAFjB,MACA,MACA,QACA,gBACA,mBACA,gBACA,MACA,cAEA,QAAkD,UAElD,SAA6B,YAC7B,WACA,WACA,cAEA,CAEA,CACA,SAEA,SACA,QAEA,IACA,SAEA,SACA,WACA,iBAIA,GACA,OACA,KACA,UAEA,SACA,IACA,OACA,KACA,UACA,OACA,gCACA,QACA,KACA,SACA,QAEA,OACA,kBAEA,UACA,aACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,2BAEA,UACA,YAEA,gBACA,KAEA,SACA,SAEA,OACA,OAAe,OACf,oCACA,UACA,MACA,cAEA,QAAoC,OAEpC,SAA2B,YAC3B,WACA,WACA,cAEA,CACA,gBACA,CAGiB,IAFjB,MACA,MACA,QACA,iBACA,mBACA,gBACA,MACA,cAEA,QAAkD,UAElD,SAA6B,YAC7B,WACA,WACA,cAEA,CAEA,CACA,SAEA,SACA,QAEA,IACA,SAEA,SACA,eACA,OACA,0BACA,QACA,KACA,GACA,kBACA,QAEA,OACA,kBAEA,UACA,aACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,2BAEA,UACA,YAEA,gBACA,KAEA,oBACA,OACA,kCACA,QACA,KAGA,GAEA,OACA,UAAyB,YACzB,iBACA,kBACA,SACA,eACA,cACA,OACA,kCACA,QACA,KAiBA,MACA,aACA,WAGA,eAEA,cAAoC,cACpC,aACA,MAEA,KACA,eACA,YAEA,OAA0B,QAC1B,OACA,SACA,WACA,eACS,YACT,MAAiC,iBACjC,QACA,MACA,UAAyB,YACzB,sBACA,OACA,OACA,OACA,MACA,iBAEA,aACA,IAA6B,YAC7B,WAEA,WACA,cACA,CAEA,IACA,SACA,gBAEA,yBAEA,qDAGA,QAEA,mCACA,OACA,yBACA,QACA,KAEA,IACA,KAGA,CACA,GAEA,OACA,0BAEA,aACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,8BACA,OACA,2BACA,QACA,KAEA,IACA,KAGA,CACA,GAEA,QACA,QACA,GAt1CA,OAu1CA,WACA,QACA,UACA,WACA,QACA,SAEA,IAzyCA,IA0yCA,QAcA,mBACA,cACA,eACA,aACA,cACA,UAGA,sCACA,oBACA,sCACA,eAIA,kBACA,eACA,YACA,eACA,gBACA,YACA,qBACA,+DAEA,4CACA,mBACA,+BACA,4BACA,SAGA,IAn4CA,QA28CA,aAtEA,WAEA,WACA,MAGA,iBACA,MAKA,SAJA,kBAEA,cACA,QA4DA,mBAzDA,aACA,IAGA,eACA,WACA,MAGA,oBACA,SAEA,cA8CA,uBA5CA,aACA,SAEA,OACA,EACA,EAGA,cACA,WAEA,oBAKA,cACA,aAEA,YACA,SAMA,YAEA,iBAGA,uBAGA,QAWA,cAUA,kDC9/CA,aACA,MACA,GAqCA,uBACA,IACA,GACA,EACA,EACA,EACA,EAEA,EAEA,EACA,EACA,EAEA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EAEA,EACA,EACA,EACA,EAGA,IAGA,MAEA,UACA,YACA,sBACA,OACA,aACA,gBACA,4BAEA,SAEA,SACA,UACA,UACA,UACA,WACA,SACA,SACA,YACA,0BACA,oBAMA,EACA,MACA,CACA,YACA,WACA,OACA,WAGA,OAEA,KACA,MAAW,OACX,UACA,GACA,OACA,OACA,WAIA,aAEA,qBACA,GACA,WAEA,OACA,WACA,WAEA,eACA,EACA,OAGA,MACA,YACA,WACA,OACA,WAEA,OAEA,KACA,OAAe,OACf,UACA,GACA,OACA,OAEA,gBACA,MACA,WACA,GACA,WACA,WACA,EACA,WACA,WAGA,gBAEA,MACA,OACA,kCACA,YACA,IAEA,IACA,OAEA,OACA,QACA,MACA,IACA,YACA,OACA,kCACA,YACA,IAwBA,MACA,EACA,IACA,aACA,QACA,CACA,KACA,YACmB,WACnB,OACA,IACA,GAEA,UACA,WACA,MACA,SACA,CACA,KACA,YACmB,WACnB,UACA,MACA,CACA,IACA,KACA,YACqB,WACrB,OACA,IACA,GACA,CAGA,aACA,QACA,CACA,KACA,YACmB,WACnB,OACA,IACA,GAEA,MACA,cACA,cACA,cACA,QAGA,eACA,KACA,eAGA,MACA,KACA,GACA,IACA,YACA,cACA,cACA,QACe,QAEf,kBACA,KACA,eAGA,MACA,CACA,mBACA,yBACA,YACA,OACA,KACA,OACA,0BACA,YACA,IAEA,CACA,KACA,CACA,mBACA,yBACA,YACA,MACA,cAEA,GACA,KAnQA,QAoQA,IACA,KACA,OACA,gCACA,YACA,IAEA,CACA,KACA,CAAG,YAGH,KAaA,YAZA,EACA,WACA,YAGA,IACA,YACA,qCACA,oCACA,OACA,cACA,0BCpUA,aAEA,QAEA,KACA,KACA,MAGA,MACA,IACA,IAEA,EAKA,8FAKA,iGAMA,wHAIA,oGAEA,mCAEA,SAGA,OACA,IACA,QACA,IACA,IACA,IACA,IACA,IACA,IACA,IAMA,OAEA,kBAEA,mBACA,KACA,OAEA,EAbA,EACA,EACA,EACA,EACA,EAIA,MAuCA,QAAe,EAAgB,KAC/B,SAEA,QAAe,EAAa,IAC5B,QAIA,YACA,IAAqB,IAAU,MAG/B,SAFA,QAGA,MAEA,KAIA,cAMA,gBAEA,qBACA,EAEA,QAAe,EAAW,KAG1B,SAFA,SAGA,MAIA,OACA,IAAe,EAAgB,KAC/B,WACA,KACA,KACA,WAGA,kBACA,aAIA,WACA,IAAe,EAAe,IAC9B,gBAIA,WAAe,EAAa,IAC5B,IACA,mBAsCA,eACA,SACA,MAEG,IACH,OACA,OACA,IACA,OACA,MAGA,MACA,IACA,OAIA,KACA,IACA,EACA,IACA,IACA,MACA,KACA,IACA,SAGA,SACA,YACA,UAIA,GAAS,OAET,GACA,IACA,UACA,IAEA,MACA,cACA,YAGA,QACA,OAIA,QACA,MACA,KACA,IACA,EACA,oBACK,wBAGL,kBACA,EACA,SAEA,KACA,QAOA,QANA,EAEA,MAKA,cACA,IAAwB,KACxB,YACA,KAGA,mBAEA,KACA,OAIA,KAGA,OACA,MACA,KACA,aACA,OACA,QACA,QAIA,QACA,YACA,YACA,UAIA,KAIA,SACA,mBACA,CAKA,OAIA,gBAKA,uBACA,OACA,gBCnUA,aAsCA,UApCA,UAEA,WAEA,YAEA,cAEA,UAEA,aAEA,oBAWA,YAIA,gBAIA,aAEA,OACA,wBCnDA,aACA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAG9C,WACA,gBACA,aACA,CACA,CAQA,qCAPA,uCACA,yBACA,8DACA,GACA,EACA,EACA,GACC,IACD,2BCpDA,aACA,qCAA8C,CAG9C,WACA,OAMA,cACA,aACA,MACA,qBAMA,CA0BA,sCAzBA,OACA,UACA,UACA,kFAA0E,UAA8B,eAExG,GAIA,sCACA,MAEA,8BACA,cACA,KAIA,+BACA,MAEA,mDACA,0BACA,sBACA,GACC,IACD,2BCnDA,aAKA,aACA,QACA,QAAmB,QAAgB,OACnC,MACA,iBACA,2BAGA,UAGA,UACA,QAGA,CAnBA,qCAA8C,CAG9C,WAiBA,gBAIA,oBACA,CAOA,OAPgC,WAChC,UAAoC,WACpC,OAA4C,WAC5C,WACA,0BACA,mBACA,sDAGA,wBACA,IACA,uBACA,gDACA,SACA,SACA,WACA,eAGA,qGACA,CAwLA,kDApLA,eACA,aACA,4DACA,kBACA,OAIA,iBACA,MACA,SACA,EACA,cAEA,iEAIA,eACA,yBACA,iBACA,EACA,cAEA,6DAIA,eACA,6BACA,iBACA,EACA,cAEA,gEAIA,eACA,0CACA,6BACA,EACA,cAEA,6DAIA,eACA,aACA,+CAGA,cAEA,OACA,EACA,cAEA,iEAIA,eACA,aACA,+CAGA,kBAEA,WACA,EACA,cAWA,wDACA,wBACA,kBACA,IASA,kCACA,wBACA,YACA,IAOA,mCACA,wBACA,YAMA,8BACA,wBACA,OAOA,uCACA,wBACA,gBAMA,8BACA,wBACA,QACA,IACA,oCACA,wBACA,aAMA,+BACA,4BACA,OAIA,uCACA,wBACA,gBAIA,iCACA,wBACA,UAEA,yCACA,+BACA,WAIA,gCACA,wBACA,SAIA,6BACA,wBACA,MAIA,+BACA,wBACA,QACA,GACC,IACD,wCCnOA,aACA,sCACA,cACA,gBAAU,CAAgB,4CAAsC,GAAiB,WACjF,gBAAyB,2CAAuD,KAChF,sBACA,aACuB,MAAsB,aAC7C,CADA,sEAEA,MACA,CACA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAAc,WAC5D,QACA,OACA,OACA,OACA,OACA,OAIA,gBACA,aAEA,qBACA,sBACA,2CACA,4BACA,KACA,2CACA,+CAIA,MAHA,2CAEA,4EAEA,CA0aA,MAtbA,sCAaA,iBACA,OACA,6BACA,OACA,gCAEA,wEACA,SAIA,sCACA,8BACA,8DACA,qBACA,IACA,sDACA,uCACA,OACA,aACA,2BACA,UACA,WACA,eACA,mEACA,2DACA,QAGA,4DAEA,wCACA,UACA,qBACA,qCACA,2BACA,cACA,YACA,YACA,cACA,sBACA,kCACA,WACA,oBACA,YACA,EACA,+CAGA,oDAEA,wCACA,gBACA,YACA,8BACA,qBACA,YACA,eACA,qBAEA,YACA,yBAAqD,UAAwB,SAC7E,sBACA,qCACA,MACA,WACA,sBACA,GAOA,SANA,yBAAqD,UAAwB,SAC7E,sBACA,qCACA,MACA,QAGA,EACA,EAeA,yCACA,uCACA,IACA,4BACA,UACA,WACA,eACA,sDACA,cACA,cACA,YAEA,SACA,EACA,EAgBA,2CACA,uCACA,OACA,2BACA,UACA,WACA,0CACA,YACA,gBACA,cACA,YAEA,oCACA,EACA,EAKA,iDACA,uCACA,yBACA,aACA,+EAAiI,OAAa,KAC9I,GACA,EACA,EAKA,mDACA,uCACA,IACA,4BACA,UACA,uFAA4I,OAAa,KACzJ,QACA,cACA,OACA,uBACA,aAEA,MACA,EACA,EAIA,uCACA,uCACA,0BACA,UACA,mCACA,kCACA,kDAEA,wBACA,GAGA,SAFA,YAGA,EACA,EAEA,8CACA,uCACA,iBACA,2BACA,UACA,WACA,YACA,mCACA,oDACA,qBACA,aACA,WACA,mBACA,2BACA,uCACA,eACA,uBACA,kBACA,OACA,0BACA,mBACA,wBACA,SACA,EACA,IAA8C,MAA4C,OAC1F,IAEA,mBACA,qBACA,YACA,yBAAqD,UAAuB,SAC5E,sBACA,qCACA,MACA,WACA,sBACA,YACA,yBAAqD,UAAuB,SAC5E,sBACA,qCACA,MACA,2EACA,6CACA,qBACA,GAGA,SAFA,YAGA,EACA,EACA,qDACA,UACA,mBACA,wCACA,uCACA,wBACA,CACA,WAGA,mBACA,QACA,0BAEA,OACA,gBAAgC,kCAChC,QACA,EACA,iCACA,OACA,oBAA2C,MAC3C,0BACA,wBACA,gCACA,SAEA,WACA,6BAGA,gCAEA,sBACA,iCAEA,UACA,yBACA,6BACA,oDACA,CACA,WAGA,qBACA,QACA,0BAEA,OACA,EACA,GAEA,YADA,UAEA,qCACA,uCACA,OACA,WACA,2BACA,UACA,WACA,YACA,2BACA,qCACA,uBACA,gEACA,sBACA,eACA,cACA,cACA,kCACA,GACA,oDACA,CACA,WAGA,mBACA,QACA,0BAEA,OACA,gBAAgD,eAAoC,WACpF,QACA,IAEA,MACA,EACA,EACA,sCACA,SACA,mBACA,gBACA,2BACA,qCACA,mCACA,oDACA,kBACA,8DACA,sEACA,wCACA,QACA,QACA,QACA,MACA,uCACA,SACA,oBACA,iBACA,2BACA,qCACA,mCACA,oDACA,kBACA,gEACA,sEACA,wCACA,QACA,QACA,QACA,OACA,4BACA,uCACA,OACA,WACA,0BAEA,UACA,2BACA,qCACA,uBACA,yDACA,2BACA,iDACA,0BACA,kBACA,kCAEA,GACA,oDACA,0BACA,WAA2C,WAAuB,OAClE,uBAEA,SACA,GAEA,oBACA,QACA,0BAEA,MACA,wEACA,aACA,OAAmC,aAA8B,OACjE,cAAsD,IAAsB,IAC5E,gBACA,aACA,SACA,iBACA,CACA,2BACA,eACA,cAEA,aACA,KAGA,QACA,QAAmC,cAA+B,OAClE,cAAsD,IAAsB,IAC5E,gBACA,cACA,SACA,kBACA,CACA,2BACA,eAEA,SACA,KAGA,eAAwC,qBACxC,WACA,IACA,IACA,EACA,EACA,IACC,sBACD,6BCjfA,aACA,sCACA,cACA,gBAAU,CAAgB,4CAAsC,GAAiB,WACjF,gBAAyB,2CAAuD,KAChF,sBACA,aACuB,MAAsB,aAC7C,CADA,sEAEA,MACA,CACA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAAc,WAC5D,QACA,OACA,QACA,OACA,OACA,OACA,OACA,OACA,QAKA,QASA,kDACA,aAEA,0CACA,KAEA,qBADA,SAEA,CA6kBA,MAllBA,sCAMA,kBACA,mBACA,6BACA,uCACA,IACA,2BACA,OACA,gCACA,mDAKA,8BAJA,6BACA,kCACA,mCACA,QAEA,EACA,EACA,yCACA,uCACA,IACA,4BACA,UACA,gGACA,cACA,cACA,YAEA,SACA,EACA,EACA,2CACA,uCACA,IACA,4BACA,UACA,iGACA,aACA,cACA,YAEA,oCACA,EACA,EAKA,iDACA,uCACA,yBACA,4GAAuK,OAAa,KACpL,GACA,EACA,EAKA,mDACA,uCACA,IACA,4BACA,UACA,yHAAkL,OAAa,KAC/L,QACA,cACA,OACA,uBACA,aAEA,MACA,EACA,EAIA,uCACA,uCACA,0BACA,UACA,mCACA,oEACA,oFAEA,wBACA,GAGA,SAFA,YAGA,EACA,EAEA,uDACA,uCACA,0BACA,UACA,4BACA,sBACA,YACA,eACA,eACA,YACA,eACA,+BACA,YACA,wDACA,mBACA,qCACA,KACA,eACA,SAEA,WACA,EACA,EACA,gDACA,uCACA,aACA,2BACA,UACA,WACA,YACA,2BACA,0CACA,uCACA,gCACA,qBACA,cACA,cACA,0BACA,8CACA,gCACA,qDACA,0EACA,QACA,oBACA,kCACA,gCACA,kDACA,YACA,WACA,qBACA,YACA,yBAAqD,UAAwB,SAC7E,sBACA,iEACA,MACA,WACA,sBACA,GAOA,SANA,yBAAqD,UAAwB,SAC7E,sBACA,gEACA,MACA,QAGA,EACA,EACA,gDACA,uCACA,WACA,2BACA,UACA,WACA,YACA,uBACA,2CACA,+BACA,wDACA,kBACA,0BACA,0BACA,+CACA,gCACA,qDACA,2GACA,QACA,WACA,qBACA,YACA,yBAAqD,UAAuB,SAC5E,sBACA,4EACA,MACA,WACA,sBACA,GAQA,SAPA,yBAAqD,UAAuB,SAC5E,sBACA,2EACA,MACA,QACA,qBAGA,EACA,EACA,uCACA,uCACA,yBACA,CAIA,YAFA,qDACA,iBAEA,EACA,EACA,gCACA,uCACA,OACA,KACA,0BACA,UACA,2BACA,4BAUA,cATA,4BACA,uDACA,2LACA,mCACA,wCACA,+CACA,2BACA,QACA,MAEA,EACA,EACA,6CACA,uCACA,IACA,4BACA,UACA,WACA,YACA,mCACA,oDACA,qBACA,aACA,WACA,mBACA,2BACA,0CACA,+BACA,QAEA,OACA,+DACA,kEAEA,WACA,EACA,EACA,sCACA,OACA,aACA,mBACA,gBACA,2BACA,qCACA,mCACA,oDACA,kBACA,mDACA,mDACA,gDACA,UAEA,SADA,QAEA,QACA,MACA,uCACA,OACA,aACA,oBACA,iBACA,2BACA,qCACA,mCACA,oDACA,kBACA,mDACA,qDACA,gDACA,UAEA,SADA,QAEA,QACA,OACA,sCACA,OACA,cACA,2BACA,qCACA,mCACA,qEACA,sEACA,uCACA,UACA,wCACA,aACA,sBACA,4CAA8D,kBAAwC,MACtG,gDAAgE,kBAAwC,MACxG,sDAEA,+BACA,iBACA,yBACA,gBACA,oBACA,GACA,CACA,wBAEA,MAEA,eAEA,4BACA,uBAEA,2DACA,kCACA,MACA,cACA,YACA,QACA,kBAEA,gCACA,cACA,QACA,kBAEA,gCACA,aACA,QACA,mBAEA,gCACA,aACA,QACA,mBAEA,gCACA,aACA,QACA,mBAEA,gCACA,cACA,QACA,mBAEA,gCACA,cACA,QACA,mBAEA,gCACA,cACA,QACA,mBAEA,gCACA,kBACA,QACA,kBAEA,4BACA,wBAEA,gDAEA,2BAEA,aACA,CACA,gCACA,2BACA,oBACA,sBACA,cACA,SACA,SACA,cACA,WAEA,cAEA,yBACA,6BACA,SACA,kBACA,EACA,mBAEA,UACA,QACA,EACA,yBAAwD,eAAgB,OACxE,MACA,KAEA,IACA,4BACA,uCACA,yFACA,2BACA,UACA,WAEA,YACA,2BACA,qCACA,mCACA,qEACA,sEACA,sCACA,UACA,kDACA,qBACA,eACA,MACA,cACA,UACA,UACA,6BACA,KACA,eACA,MACA,GAEA,MADA,eAEA,sCACA,aACA,OACA,UACA,iBACA,MACA,oBACA,eACA,mBACA,2DACA,gBACA,eACA,MACA,cACA,8BACA,kBACA,iCACA,KACA,eACA,MACA,GAEA,MADA,eAGA,gBAEA,8CAEA,kBAAsE,cAAgB,OACtF,MACA,sBAGA,gEACA,+BAEA,sDACA,mBACA,uBACA,MACA,qBACA,QACA,KACA,aACA,eACA,OACA,eACA,eACA,SACA,6BACA,6BACA,MACA,sBACA,iBACA,OACA,IAEA,MADA,gBAEA,oBACA,oCACA,qBACA,MACA,wBACA,eACA,UACA,KACA,sBACA,KAEA,cACA,OACA,IAEA,MADA,eAEA,IAgBA,wDAfA,CAUA,MATA,6BACA,QACA,eACA,sBAGA,MACA,sDACA,sBAEA,6BAA2D,0DAA4F,EACvJ,WACA,iBACA,oBAEA,YACA,iBACA,OACA,qBACA,eACA,0DACA,gBACA,eACA,OACA,eACA,8BACA,kBACA,kCACA,MACA,eACA,OACA,IAEA,MADA,gBAGA,iBAEA,8CAEA,kBAAsE,cAAgB,OACtF,MACA,sBAGA,6DACA,+BAEA,sDAGA,YAAoE,YAAgB,OACpF,WACA,SAEA,iCACA,gCACA,OACA,IAEA,MADA,gBAEA,YACA,gBACA,OACA,eACA,UACA,UACA,6BACA,MACA,eACA,OACA,IAEA,MADA,oBAGA,WACA,EACA,EACA,IACC,sBACD,6BC1pBA,aACA,sCACA,cACA,gBAAU,CAAgB,4CAAsC,GAAiB,WACjF,gBAAyB,2CAAuD,KAChF,sBACA,aACuB,MAAsB,aAC7C,CADA,sEAEA,MACA,CACA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAAc,WAC5D,QACA,QAIA,iBACA,wBAEA,+BACA,KAOA,kBANA,OACA,4BACA,gDACA,gBACA,SACA,qBAEA,0BACA,EACA,UACA,uBACA,EACA,MACA,oBAEA,iDACA,IACA,cACA,oCACA,0CACA,sBACA,EACA,UACA,iCACA,yCACA,mBACA,EACA,MACA,oBAMA,2DACA,0CACA,mBAEA,qBACA,6BACA,qDAIA,qCAHA,UACA,iBACA,iBAEA,CA2MA,MA3PA,oDAiDA,eACA,aACA,QACA,EACA,cAEA,6DACA,eACA,qCACA,iBACA,EACA,cAQA,iDACA,uCACA,0BACA,UACA,WACA,qBACA,iBACA,sBACA,GAGA,SAFA,YAGA,EACA,EAQA,kCACA,YAAgC,WAChC,kCACA,0BACA,UACA,WACA,UACA,6BACA,kFACA,qBACA,GAIA,SAHA,yDACA,0BAGA,EACA,EACA,0CACA,oCACA,oBAEA,0CACA,oCACA,oBAMA,uCACA,uCACA,SACA,2BACA,UACA,WACA,yBACA,QACA,cACA,mCACA,2DACA,2EACA,0BACA,GAEA,+BACA,QACA,GAKA,SAJA,oGACA,cACA,6BAGA,EACA,EAMA,sCACA,uCACA,WACA,0BACA,CAUA,sBATA,KACA,MACA,+CACA,sBACA,8EACA,cACA,+BACA,gDACA,MAEA,EACA,EACA,2CACA,uCACA,IACA,4BACA,UACA,WACA,WACA,8BAEA,kJACA,UACA,qBACA,0BACA,uBACA,KACA,eACA,MACA,GAKA,yBAJA,4CACA,qCACA,aAGA,EACA,EACA,8CACA,wBACA,cAA0D,6BAAgB,OAC1E,MACA,uBACA,uCAEA,WACA,yBACA,0CACA,IACA,0CAEA,iJACA,8BAEA,+IACA,QACA,cACA,qGACA,QACA,2BACA,8CACA,SAEA,6CACA,8EACA,QACA,4BACA,8BACA,6BACA,oBACA,eAGA,8CACA,YAA2B,MAAkB,OAC7C,WACA,KAEA,QACA,gCAEA,OACA,OACA,oBACA,eAGA,8CACA,YAA2B,MAAkC,SAC7D,WACA,KAEA,QACA,wCACA,SACA,oBACA,+IACA,cACA,IACC,YACD,6BClTA,aACA,sCACA,cACA,gBAAU,CAAgB,4CAAsC,GAAiB,WACjF,gBAAyB,2CAAuD,KAChF,sBACA,aACuB,MAAsB,aAC7C,CADA,sEAEA,MACA,CACA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAAc,WAC5D,QACA,OACA,QACA,OACA,OACA,OACA,OACA,OACA,QAKA,0EAKA,qBACA,aAEA,0CAIA,KAEA,qBADA,UAMA,CAmeA,MA/eA,sCAaA,UACA,mBAKA,6BACA,uCACA,0BACA,UACA,WACA,uCACA,sBACA,4BACA,GAGA,SAFA,YAGA,EACA,EAKA,6CACA,uCACA,OACA,2BACA,UACA,WAWA,wCAAsb,kYACtb,2DACA,iFAAyH,wBAAgC,GAAG,wBAAgC,GAC5L,aACA,QACA,qCACA,GACA,sGAEA,4JAEA,WACA,EACA,EAeA,yCACA,uCACA,IACA,4BACA,UACA,8DACA,cACA,cACA,YAEA,SACA,EACA,EAgBA,2CACA,uCACA,IACA,4BACA,UACA,+DACA,aACA,cACA,YAEA,oCACA,EACA,EAKA,iDACA,uCACA,yBACA,0EAAiI,OAAa,KAC9I,GACA,EACA,EAKA,mDACA,uCACA,IACA,4BACA,UACA,uFAA4I,OAAa,KACzJ,QACA,cACA,OACA,uBACA,aAEA,MACA,EACA,EAIA,uCACA,uCACA,0BACA,UACA,mCACA,kCACA,kDAEA,wBACA,GAGA,SAFA,YAGA,EACA,EAEA,uDACA,uCACA,0BACA,UACA,WACA,eAEA,+BACA,wBACA,sBACA,6CACA,oCAEA,uEACA,sBACA,+BACA,YACA,eACA,6BACA,YACA,mCACA,uCAEA,YACA,YACA,wDACA,mBACA,qCACA,KACA,eACA,SAEA,WACA,EACA,EAOA,gDACA,uCACA,aACA,2BACA,UACA,WACA,YACA,uBACA,gDACA,oEACA,wBACA,6BACA,yBACA,qBACA,8CACA,cACA,YACA,eACA,qBACA,YACA,yBAAqD,UAAwB,SAC7E,sBACA,uBACA,MACA,WACA,sBACA,GAOA,SANA,yBAAqD,UAAwB,SAC7E,sBACA,uBACA,MACA,QAGA,EACA,EAKA,8CACA,uCACA,OACA,KACA,2BACA,UACA,WACA,YACA,uBACA,2CACA,8DAAkH,oCAClH,IACA,4BACA,UACA,WACA,0DACA,+CACA,mBACA,YACA,QAEA,MACA,EAA+B,EAC/B,SACA,GAGA,uBAFA,YAGA,EACA,EAQA,gDACA,uCACA,WACA,2BACA,UACA,WACA,YACA,uBACA,2CACA,+BACA,wDACA,kBACA,uDACA,qCACA,wBACA,wBACA,qBACA,YACA,yBAAqD,UAAuB,SAC5E,sBACA,uBACA,MACA,WACA,sBACA,GAOA,SANA,yBAAqD,UAAuB,SAC5E,sBACA,uBACA,MACA,QAGA,EACA,EAQA,6CACA,uCACA,OACA,WACA,2BACA,UACA,WACA,YACA,mCACA,oDACA,qBACA,aACA,WACA,mBACA,2BACA,qCACA,4BACA,iDACA,kBACA,oBACA,+BACA,YAEA,SACA,kDAAgH,oCAChH,WACA,0BACA,sCACA,gBAA0F,0BAAgB,OAC1G,MACA,6BAEA,wBACA,WACA,EAA+B,EAC/B,SAEA,GAGA,0BAFA,YAGA,EACA,EAOA,sCACA,SACA,mBACA,gBACA,2BACA,qCACA,mCACA,oDACA,kBACA,8DACA,sEACA,2EACA,QACA,QACA,QACA,MAOA,uCACA,SACA,oBACA,iBACA,2BACA,qCACA,mCACA,oDACA,kBACA,gEACA,sEACA,2EACA,QACA,QACA,QACA,OAKA,4BACA,uCACA,+BACA,2BACA,UACA,WACA,YACA,+BACA,yCACA,6BACA,4CACA,8BACA,6CACA,4BACA,0CACA,mCACA,qEACA,sEACA,8BACA,oBACA,qBACA,4CACA,YACA,OACA,IACA,UACA,MACA,gCACA,eACA,gCACA,+IACA,sBACA,KACA,qBACA,eACA,UACA,gBAEA,wBACA,aACA,MACA,GAEA,MADA,eAEA,GAgBA,wDAfA,CAUA,MATA,6BACA,QACA,eACA,sBAGA,MACA,sDACA,sBAEA,6BAA2D,0DAA4F,EACvJ,WACA,iBACA,mBAEA,SACA,OAAmC,wBAAgC,OACnE,WACA,kDACA,0IAEA,gBACA,YAEA,WACA,EACA,EACA,IACC,sBACD,6BCvjBA,aACA,aACA,2CACA,MACA,qCAA8C,CAc9C,WACA,SACA,IACA,KACA,0BClBA,aA4CA,aACA,4EAA6F,OAAqB,KAClH,KAGA,CACA,aACA,IACA,yBAGA,aACA,oCAEA,OACA,oCAEA,OACA,oCAGA,oBAGA,uEAMA,CACA,eACA,KAA6B,SAC7B,yKACA,mBACA,OACA,SACA,UACA,WACA,KACA,QACA,QACA,EACA,uBACA,IAIA,eAHA,2BACA,qBACA,mBAEA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCAGA,QACA,mBACA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCAKA,SACA,mBACA,IAIA,eAHA,2BACA,qBACA,mBAEA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCAGA,QACA,mBACA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCAKA,SACA,mBACA,KAIA,eAHA,kCACA,4BACA,mBAEA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCACA,oCAGA,QACA,mBACA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCACA,oCAKA,SACA,mBACA,KAIA,eAHA,kCACA,4BACA,mBAEA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCACA,oCAGA,QACA,mBACA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCACA,oCAKA,SACA,mBACA,aACA,uBACA,qBACA,aAA2B,EAAY,IACvC,cAA+B,EAAW,QAC1C,mBACA,iBACA,iBACA,kDACA,MAEA,CACA,MACA,oBAEA,6BACA,SAQA,eACA,KAA6B,SAC7B,kVACA,0DACA,8BAAuD,kDACvD,oBAAkD,+BAClD,UAQA,eACA,KAA6B,SAC7B,YACA,iBACA,sBACA,eAEA,gCACA,sBACA,iBAEA,kCACA,yBAEA,uBACA,iBAGA,wBACA,6aACA,0CACA,kBACA,aACA,YACA,yBACA,iCAA4C,+BAC5C,UA/PA,6CACA,yCACA,cAAmC,IAAM,KAA6B,QAAE,SAAY,CAAW,IAAE,CACjG,cAAkC,IAAM,KAAiC,YAAE,SAAY,CAAW,IAAE,CACpG,cAA+B,oCAAiE,KAAuB,MAAE,GAA4B,SACrJ,wBACA,OACA,EACA,yCACA,cAEsB,mBAAsB,UAAqB,MAAG,CACpE,cACA,0BACA,8CACA,gFACA,iCACA,UACA,kBAAuC,IACvC,sBAAkC,QAAS,YAC3C,kBAAkC,YAAW,GAAU,MACvD,wBAAyC,aAAc,MACvD,SACA,2EAA6G,GAAO,EAAU,QAC9H,yCAAgF,WAAiB,GAAO,KACxG,2BAAwD,WAAgB,GAAQ,IAAO,KACvF,oBAA8C,WAAgB,SAAgB,QAAO,KACrF,aACA,aAAiC,MAEjC,cACA,SAAS,SAAY,IAAa,OAAO,CAAE,QAAU,KAAW,CAChE,mBAAmC,SAAS,wBAC5C,QACA,OAzBa,wBAA6B,mBAA0B,YAAa,EAAE,UAAqB,cACxG,WAAgB,+BAAqD,6DAAoE,OAAa,KACtJ,MAwBA,qCAA8C,CAAc,WAC5D,QACA,QACA,QACA,QAGA,IAsKA,EAMA,6BAQA,EAMA,0BA4BA,EAgEA,4BAoCA,EAiCA,cApEA,aACA,YAA6B,SAC7B,qCACA,OACA,2BACA,UACA,WACA,SACA,oBACA,SACA,4DACA,gBACA,sBACA,mBACA,SACA,oEACA,gBACA,kBACA,4BAEA,qFACA,oBAMA,aAEA,4MACA,SAEA,WACA,EACA,IAmKA,wBAhIA,mBACA,KAA6B,SAC7B,6SACA,mBACA,OACA,SACA,MACA,iCACA,eACA,QACA,EACA,uBACA,IAGA,yBAFA,qBACA,mBAEA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,+BACA,kCACA,kCACA,sBAGA,IACA,mBACA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,sBACA,kCACA,kCACA,+BAKA,KACA,mBACA,IAGA,yBAFA,qBACA,mBAEA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,+BACA,kCACA,kCACA,sBAGA,IACA,mBACA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,sBACA,kCACA,kCACA,+BAKA,KACA,mBACA,KAGA,gCAFA,4BACA,mBAEA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,+BACA,kCACA,kCACA,kCAGA,OACA,mBACA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,sBACA,kCACA,kCACA,kCAKA,iBACA,mBACA,KAGA,gCAFA,4BACA,mBAEA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,+BACA,kCACA,kCACA,kCAGA,OACA,mBACA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,sBACA,kCACA,kCACA,kCAKA,iBACA,mBACA,YAA8B,OAAiB,IAC/C,WAAkC,OAAiB,IACnD,gBACA,eACA,kCACA,kBAKA,mDAAgF,kDAChF,2BCtgBA,aAMA,eACA,KAA6B,SAC7B,+KACA,6CACA,+BACA,sBAIA,4BAHA,eAAuD,sBAEvD,YAMA,eACA,KAA6B,SAC7B,YACA,iBACA,sBACA,eAEA,gCACA,sBACA,iBAGA,mCACA,+RACA,oCACA,kBACA,aACA,YACA,yBACA,oDACA,KAUA,eACA,KAA6B,SAC7B,+KACA,6CACA,oCACA,YACA,UACA,iBACA,oCACA,iCACA,kBACA,aACA,YACA,uCACA,sCACA,IAcA,CA9EA,qCAA8C,CAAc,WAC5D,QAGA,IAWA,EAGA,yBAsBA,EAQA,2BA0CA,EAGA,aAdA,aACA,QAA6B,SAC7B,kBACA,yBAEA,sDACA,wBAGA,wBACA,8IAcA,uBATA,eACA,KAA6B,SAC7B,+KACA,6CACA,iCACA,eAAuD,oCAEvD,4BACA,sCCpGA,aAIA,qCAA8C,CAAc,WAH5D,WACA,2CACA,MAEA,uBCTA,aACA,qCAA8C,CAS9C,WA0CA,EAQA,OAjDA,aAEA,KAAuB,WACvB,OACA,wBACA,SACA,OAAmB,MAAgB,OACnC,IACA,wBACA,sDACA,aAEA,WACA,cACA,MACA,kBACA,MACA,OACA,KACA,QACA,UACA,KACA,SACA,UACA,KACA,MACA,QACA,KACA,aACA,UACA,KAEA,cACA,SACA,eACA,MACA,QACA,QAAmB,EAAO,IAC1B,WACA,MACA,UAmDA,SAzCA,aAEA,KAAuB,WACvB,OACA,wBACA,SACA,OAAmB,MAAgB,OACnC,IACA,wBACA,sDACA,aAEA,WACA,cACA,MACA,kBACA,MACA,OACA,KACA,QACA,UACA,KACA,SACA,UACA,KACA,MACA,QACA,KACA,aACA,UACA,KAEA,cACA,SACA,eACA,MACA,QACA,QAAmB,EAAO,IAC1B,WACA,MACA","file":"webdnn.es5.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WebDNN\"] = factory();\n\telse\n\t\troot[\"WebDNN\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 8a8b97be680405fd407c","'use strict';\n\n\nvar TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n (typeof Uint16Array !== 'undefined') &&\n (typeof Int32Array !== 'undefined');\n\nfunction _has(obj, key) {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n\nexports.assign = function (obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n};\n\n\n// reduce buffer size, avoiding mem copy\nexports.shrinkBuf = function (buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n};\n\n\nvar fnTyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n }\n};\n\nvar fnUntyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n return [].concat.apply([], chunks);\n }\n};\n\n\n// Enable/Disable typed arrays use, for testing\n//\nexports.setTyped = function (on) {\n if (on) {\n exports.Buf8 = Uint8Array;\n exports.Buf16 = Uint16Array;\n exports.Buf32 = Int32Array;\n exports.assign(exports, fnTyped);\n } else {\n exports.Buf8 = Array;\n exports.Buf16 = Array;\n exports.Buf32 = Array;\n exports.assign(exports, fnUntyped);\n }\n};\n\nexports.setTyped(TYPED_OK);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/utils/common.js\n// module id = 0\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar dispatch_scheduler_1 = require(\"./util/dispatch_scheduler\");\n/**\n * @protected\n */\nvar transformDelegate = function (url) { return url; };\n/**\n * Transform url generated based on current active backend\n * @param url transformed url\n * @protected\n */\nfunction transformUrl(url) {\n return transformDelegate(url);\n}\nexports.transformUrl = transformUrl;\n/**\n * Register delegate function for transform url.\n * @param delegate Delegate function which will be called with original url, and must return converted url strings.\n * @protected\n */\nfunction registerTransformUrlDelegate(delegate) {\n transformDelegate = delegate;\n}\nexports.registerTransformUrlDelegate = registerTransformUrlDelegate;\n/**\n * Fetch function. WebDNN API use this function instead of original `fetch` function.\n * FIXME\n * @param input Requested url\n * @param init Additional information about webdnnFetch\n * @param init.ignoreCache If true, cache is ignored by appending '?t=(timestamp)' to the end of request url.\n * @returns Response\n * @protected\n */\nfunction webdnnFetch(input, init) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (typeof input == 'string') {\n input = transformUrl(input) + ((init && init.ignoreCache) ? '?t=' + Date.now() : '');\n }\n else {\n input = Object.assign({}, input, {\n url: transformUrl(input.url) + ((init && init.ignoreCache) ? '?t=' + Date.now() : '')\n });\n }\n if (!(typeof input == 'string' && isXHR2WithBlobSupported())) return [3 /*break*/, 2];\n return [4 /*yield*/, fetchUsingXHR(input, init && init.progressCallback)];\n case 1:\n res = _a.sent();\n return [3 /*break*/, 4];\n case 2: return [4 /*yield*/, fetch(input, init)];\n case 3:\n res = _a.sent();\n _a.label = 4;\n case 4:\n if (!res.ok)\n throw new Error(\"Fetch returns status code \" + res.status + \": \" + res.statusText);\n return [2 /*return*/, res];\n }\n });\n });\n}\nexports.default = webdnnFetch;\n/**\n * Read `Response.body` stream as ArrayBuffer. This function provide progress information by callback.\n * @param res Response object\n * @param callback Callback function.\n * @returns ArrayBuffer\n * @protected\n */\nfunction readArrayBufferProgressively(res, callback) {\n if (!callback || !res.body)\n return res.arrayBuffer();\n var contentLength = res.headers.get('Content-Length');\n if (!contentLength)\n return res.arrayBuffer();\n var total = parseInt(contentLength);\n var buffer = new Uint8Array(total);\n var loaded = 0;\n var reader = res.body.getReader();\n var callbackScheduler = new dispatch_scheduler_1.default();\n function accumulateLoadedSize(chunk) {\n buffer.set(chunk.value, loaded);\n loaded += chunk.value.length;\n if (callback) {\n callbackScheduler.request(function () { return callback(loaded, total); });\n }\n if (loaded == total) {\n callbackScheduler.forceDispatch();\n return buffer.buffer;\n }\n else {\n return reader.read().then(accumulateLoadedSize);\n }\n }\n return reader.read().then(accumulateLoadedSize);\n}\nexports.readArrayBufferProgressively = readArrayBufferProgressively;\n/**\n * check whether XMLHttpRequest with Blob type is supported or not\n * @protected\n */\nfunction isXHR2WithBlobSupported() {\n if (!window.hasOwnProperty('ProgressEvent') || !window.hasOwnProperty('FormData')) {\n return false;\n }\n var xhr = new XMLHttpRequest();\n if (typeof xhr.responseType === 'string') {\n try {\n xhr.responseType = 'blob';\n return xhr.responseType === 'blob';\n }\n catch (e) {\n return false;\n }\n }\n else {\n return false;\n }\n}\n/**\n * fetch with XMLHttpRequest\n * @protected\n */\nfunction fetchUsingXHR(url, callback) {\n return new Promise(function (resolve, reject) {\n var req = new XMLHttpRequest();\n req.open(\"GET\", url, true);\n req.responseType = \"blob\";\n var callbackScheduler = new dispatch_scheduler_1.default();\n req.onload = function (event) {\n callbackScheduler.forceDispatch();\n var res = new Response(req.response);\n resolve(res);\n };\n req.onprogress = function (event) {\n if (callback) {\n callbackScheduler.request(function () { return callback(event.loaded, event.total); });\n }\n };\n req.onerror = function (event) {\n reject(event);\n };\n req.send(null);\n });\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/fetch.js\n// module id = 1\n// module chunks = 0","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar descriptor_runner_fallback_1 = require(\"./descriptor_runner/descriptor_runner_fallback\");\nvar descriptor_runner_webassembly_1 = require(\"./descriptor_runner/descriptor_runner_webassembly\");\nvar descriptor_runner_webgl_1 = require(\"./descriptor_runner/descriptor_runner_webgl\");\nvar descriptor_runner_webgpu_1 = require(\"./descriptor_runner/descriptor_runner_webgpu\");\nvar fetch_1 = require(\"./fetch\");\nvar Image = require(\"./image\");\nexports.Image = Image;\nvar Math = require(\"./math\");\nexports.Math = Math;\n/**\n * DEBUG flag for developing WebDNN\n * @private\n */\nvar configurations = {};\n/**\n * get configuration\n * @private\n */\nfunction getConfiguration(key, defaultValue) {\n return key in configurations ? configurations[key] : defaultValue;\n}\nexports.getConfiguration = getConfiguration;\n/**\n * set configuration\n * @private\n */\nfunction setConfiguration(key, value) {\n configurations[key] = value;\n}\nexports.setConfiguration = setConfiguration;\n/**\n * Backend constructor map\n * @private\n */\nvar descriptorRunners = {\n webgpu: descriptor_runner_webgpu_1.default,\n webgl: descriptor_runner_webgl_1.default,\n webassembly: descriptor_runner_webassembly_1.default,\n fallback: descriptor_runner_fallback_1.default\n};\n/**\n * Check each computing backend is available or not in this browser.\n * The result will be returned as [[BackendAvailability|`BackendAvailability`]] structure.\n *\n * @returns backend availability\n */\nfunction getBackendAvailability() {\n var status = {\n 'webgpu': descriptorRunners['webgpu'].checkAvailability(),\n 'webgl': descriptorRunners['webgl'].checkAvailability(),\n 'webassembly': descriptorRunners['webassembly'].checkAvailability(),\n 'fallback': descriptorRunners['fallback'].checkAvailability(),\n };\n var order = ['webgpu', 'webgl', 'webassembly', 'fallback'].filter(function (backend) { return status[backend]; });\n return {\n status: status,\n defaultOrder: order\n };\n}\nexports.getBackendAvailability = getBackendAvailability;\n/**\n * Initialize specified backend\n * @private\n */\nfunction initBackend(backendName, option) {\n return __awaiter(this, void 0, void 0, function () {\n var runner, ex_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(backendName in descriptorRunners))\n throw new Error(\"Unknown backend: \\\"\" + backendName + \"\\\"\");\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n runner = new descriptorRunners[backendName](option);\n return [4 /*yield*/, runner.init()];\n case 2:\n _a.sent();\n return [3 /*break*/, 4];\n case 3:\n ex_1 = _a.sent();\n console.warn(\"Failed to initialize \" + backendName + \" backend: \" + ex_1);\n return [2 /*return*/, null];\n case 4: return [2 /*return*/, runner];\n }\n });\n });\n}\n/**\n * Initialize descriptor runner. This function performs follow things.\n *\n * 1. Try to initialize computing backend. WebDNN will try to initialize each backend in order of\n * the result of [[getBackendAvailability|`getBackendAvailability`]].\n * If you want to modify this order, specify [[InitOption.backendOrder|`initOption.backendOrder`]] option.\n *\n * 2. Load model data based on initialized backend. Generally, DNN binary data is very large and it takes long time to load.\n * [[InitOption.progressCallback|`initOption.progressCallback`]] option provides the progress status of loading.\n *\n * ### Examples\n *\n * - Basic usage\n *\n * ```js\n * let runner = await WebDNN.load('./model');\n * ```\n *\n * - With `initOption.progressCallback` option\n *\n * ```js\n * let runner = await WebDNN.load('./model', {\n * progressCallback: (loaded, total) => console.log(`${ (loaded/total*100).toFixed(1) }% Loaded`);\n * });\n * ```\n *\n * @param directory URL of directory that contains graph descriptor files (e.g. graph_webgpu.json)\n * @param initOption Initialize option\n * @return DescriptorRunner instance, which is the interface to input/output data and run the model.\n */\nfunction load(directory, initOption) {\n if (initOption === void 0) { initOption = {}; }\n return __awaiter(this, void 0, void 0, function () {\n var _a, backendOrder, _b, backendOptions, _c, cacheStrategy, _d, saveCache, progressCallback, weightDirectory, transformUrlDelegate, backendName, runner, descriptor, parameters, fetchedDescriptor, cachedDescriptor, _e, e_1, ex_2;\n return __generator(this, function (_f) {\n switch (_f.label) {\n case 0:\n _a = initOption.backendOrder, backendOrder = _a === void 0 ? null : _a, _b = initOption.backendOptions, backendOptions = _b === void 0 ? {} : _b, _c = initOption.cacheStrategy, cacheStrategy = _c === void 0 ? 'latest' : _c, _d = initOption.saveCache, saveCache = _d === void 0 ? true : _d, progressCallback = initOption.progressCallback, weightDirectory = initOption.weightDirectory, transformUrlDelegate = initOption.transformUrlDelegate;\n if (!backendOrder)\n backendOrder = getBackendAvailability().defaultOrder;\n if (typeof backendOrder === 'string')\n backendOrder = [backendOrder];\n backendOrder = backendOrder.slice();\n if (backendOrder.indexOf('fallback') === -1)\n backendOrder.concat(['fallback']);\n fetch_1.registerTransformUrlDelegate(function (url) {\n if (weightDirectory) {\n if ((/\\.bin/).test(url)) {\n url = url.replace(directory, weightDirectory);\n }\n }\n if (transformUrlDelegate)\n url = transformUrlDelegate(url);\n return url;\n });\n _f.label = 1;\n case 1:\n if (!(backendOrder.length > 0)) return [3 /*break*/, 36];\n backendName = backendOrder.shift();\n return [4 /*yield*/, initBackend(backendName, backendOptions[backendName])];\n case 2:\n runner = _f.sent();\n if (!runner)\n return [3 /*break*/, 1];\n _f.label = 3;\n case 3:\n _f.trys.push([3, 34, , 35]);\n descriptor = void 0;\n parameters = void 0;\n fetchedDescriptor = void 0;\n cachedDescriptor = void 0;\n _e = cacheStrategy;\n switch (_e) {\n case 'latest': return [3 /*break*/, 4];\n case 'networkOnly': return [3 /*break*/, 13];\n case 'networkFirst': return [3 /*break*/, 13];\n case 'cacheOnly': return [3 /*break*/, 20];\n case 'cacheFirst': return [3 /*break*/, 20];\n }\n return [3 /*break*/, 27];\n case 4: return [4 /*yield*/, runner.fetchDescriptor(directory).catch(function () { return null; })];\n case 5:\n fetchedDescriptor = _f.sent();\n return [4 /*yield*/, runner.restoreCachedDescriptor(directory)];\n case 6:\n cachedDescriptor = _f.sent();\n if (!(cachedDescriptor && fetchedDescriptor && cachedDescriptor.converted_at === fetchedDescriptor.converted_at)) return [3 /*break*/, 8];\n descriptor = cachedDescriptor;\n return [4 /*yield*/, runner.restoreCachedParameters(directory, progressCallback)];\n case 7:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 8;\n case 8:\n if (!fetchedDescriptor) return [3 /*break*/, 10];\n descriptor = fetchedDescriptor;\n return [4 /*yield*/, runner.fetchParameters(directory, progressCallback)];\n case 9:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 10;\n case 10:\n if (!cachedDescriptor) return [3 /*break*/, 12];\n descriptor = cachedDescriptor;\n return [4 /*yield*/, runner.restoreCachedParameters(directory, progressCallback)];\n case 11:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 12;\n case 12: throw Error('Network error is occurred and no cache is exist.');\n case 13: return [4 /*yield*/, runner.fetchDescriptor(directory).catch(function () { return null; })];\n case 14:\n fetchedDescriptor = _f.sent();\n if (!fetchedDescriptor) return [3 /*break*/, 16];\n descriptor = fetchedDescriptor;\n return [4 /*yield*/, runner.fetchParameters(directory, progressCallback)];\n case 15:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 16;\n case 16:\n if (cacheStrategy === 'networkOnly')\n throw Error('Network error is occurred in \"networkOnly\" cache strategy');\n return [4 /*yield*/, runner.restoreCachedDescriptor(directory)];\n case 17:\n cachedDescriptor = _f.sent();\n if (!cachedDescriptor) return [3 /*break*/, 19];\n descriptor = cachedDescriptor;\n return [4 /*yield*/, runner.restoreCachedParameters(directory, progressCallback)];\n case 18:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 19;\n case 19: throw Error('Network error is occurred and no cache is exist.');\n case 20: return [4 /*yield*/, runner.restoreCachedDescriptor(directory)];\n case 21:\n cachedDescriptor = _f.sent();\n if (!cachedDescriptor) return [3 /*break*/, 23];\n descriptor = cachedDescriptor;\n return [4 /*yield*/, runner.restoreCachedParameters(directory, progressCallback)];\n case 22:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 23;\n case 23:\n if (cacheStrategy === 'cacheOnly')\n throw Error('No cache is exist in \"cacheOnly\" cache strategy');\n return [4 /*yield*/, runner.fetchDescriptor(directory).catch(function () { return null; })];\n case 24:\n fetchedDescriptor = _f.sent();\n if (!fetchedDescriptor) return [3 /*break*/, 26];\n descriptor = fetchedDescriptor;\n return [4 /*yield*/, runner.fetchParameters(directory, progressCallback)];\n case 25:\n parameters = _f.sent();\n if (parameters)\n return [3 /*break*/, 28];\n _f.label = 26;\n case 26: throw Error('Network error is occurred and no cache is exist.');\n case 27: throw Error(\"\\\"\" + cacheStrategy + \"\\\" is not valid cache strategy name: \\\"latest\\\", \\\"networkFirst\\\", \\\"networkOnly\\\", \\\"cacheFirst\\\", \\\"cacheOnly\\\" is available.\");\n case 28:\n if (!saveCache) return [3 /*break*/, 32];\n _f.label = 29;\n case 29:\n _f.trys.push([29, 31, , 32]);\n return [4 /*yield*/, runner.saveCache(directory, descriptor, parameters)];\n case 30:\n _f.sent();\n return [3 /*break*/, 32];\n case 31:\n e_1 = _f.sent();\n return [3 /*break*/, 32];\n case 32: return [4 /*yield*/, runner.setDescriptorAndParameters(descriptor, parameters)];\n case 33:\n _f.sent();\n return [3 /*break*/, 35];\n case 34:\n ex_2 = _f.sent();\n console.warn(\"Model loading failed for \" + backendName + \" backend. Trying next backend: \" + ex_2.message);\n return [3 /*break*/, 1];\n case 35: return [2 /*return*/, runner];\n case 36: throw new Error('No backend is available');\n }\n });\n });\n}\nexports.load = load;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webdnn.js\n// module id = 2\n// module chunks = 0","/*!\n localForage -- Offline Storage, Improved\n Version 1.5.6\n https://localforage.github.io/localForage\n (c) 2013-2017 Mozilla, Apache License 2.0\n*/\n(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.localforage = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw (f.code=\"MODULE_NOT_FOUND\", f)}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o element; its readystatechange event will be fired asynchronously once it is inserted\n // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.\n var scriptEl = global.document.createElement('script');\n scriptEl.onreadystatechange = function () {\n nextTick();\n\n scriptEl.onreadystatechange = null;\n scriptEl.parentNode.removeChild(scriptEl);\n scriptEl = null;\n };\n global.document.documentElement.appendChild(scriptEl);\n };\n } else {\n scheduleDrain = function () {\n setTimeout(nextTick, 0);\n };\n }\n}\n\nvar draining;\nvar queue = [];\n//named nextTick for less confusing stack traces\nfunction nextTick() {\n draining = true;\n var i, oldQueue;\n var len = queue.length;\n while (len) {\n oldQueue = queue;\n queue = [];\n i = -1;\n while (++i < len) {\n oldQueue[i]();\n }\n len = queue.length;\n }\n draining = false;\n}\n\nmodule.exports = immediate;\nfunction immediate(task) {\n if (queue.push(task) === 1 && !draining) {\n scheduleDrain();\n }\n}\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{}],2:[function(_dereq_,module,exports){\n'use strict';\nvar immediate = _dereq_(1);\n\n/* istanbul ignore next */\nfunction INTERNAL() {}\n\nvar handlers = {};\n\nvar REJECTED = ['REJECTED'];\nvar FULFILLED = ['FULFILLED'];\nvar PENDING = ['PENDING'];\n\nmodule.exports = Promise;\n\nfunction Promise(resolver) {\n if (typeof resolver !== 'function') {\n throw new TypeError('resolver must be a function');\n }\n this.state = PENDING;\n this.queue = [];\n this.outcome = void 0;\n if (resolver !== INTERNAL) {\n safelyResolveThenable(this, resolver);\n }\n}\n\nPromise.prototype[\"catch\"] = function (onRejected) {\n return this.then(null, onRejected);\n};\nPromise.prototype.then = function (onFulfilled, onRejected) {\n if (typeof onFulfilled !== 'function' && this.state === FULFILLED ||\n typeof onRejected !== 'function' && this.state === REJECTED) {\n return this;\n }\n var promise = new this.constructor(INTERNAL);\n if (this.state !== PENDING) {\n var resolver = this.state === FULFILLED ? onFulfilled : onRejected;\n unwrap(promise, resolver, this.outcome);\n } else {\n this.queue.push(new QueueItem(promise, onFulfilled, onRejected));\n }\n\n return promise;\n};\nfunction QueueItem(promise, onFulfilled, onRejected) {\n this.promise = promise;\n if (typeof onFulfilled === 'function') {\n this.onFulfilled = onFulfilled;\n this.callFulfilled = this.otherCallFulfilled;\n }\n if (typeof onRejected === 'function') {\n this.onRejected = onRejected;\n this.callRejected = this.otherCallRejected;\n }\n}\nQueueItem.prototype.callFulfilled = function (value) {\n handlers.resolve(this.promise, value);\n};\nQueueItem.prototype.otherCallFulfilled = function (value) {\n unwrap(this.promise, this.onFulfilled, value);\n};\nQueueItem.prototype.callRejected = function (value) {\n handlers.reject(this.promise, value);\n};\nQueueItem.prototype.otherCallRejected = function (value) {\n unwrap(this.promise, this.onRejected, value);\n};\n\nfunction unwrap(promise, func, value) {\n immediate(function () {\n var returnValue;\n try {\n returnValue = func(value);\n } catch (e) {\n return handlers.reject(promise, e);\n }\n if (returnValue === promise) {\n handlers.reject(promise, new TypeError('Cannot resolve promise with itself'));\n } else {\n handlers.resolve(promise, returnValue);\n }\n });\n}\n\nhandlers.resolve = function (self, value) {\n var result = tryCatch(getThen, value);\n if (result.status === 'error') {\n return handlers.reject(self, result.value);\n }\n var thenable = result.value;\n\n if (thenable) {\n safelyResolveThenable(self, thenable);\n } else {\n self.state = FULFILLED;\n self.outcome = value;\n var i = -1;\n var len = self.queue.length;\n while (++i < len) {\n self.queue[i].callFulfilled(value);\n }\n }\n return self;\n};\nhandlers.reject = function (self, error) {\n self.state = REJECTED;\n self.outcome = error;\n var i = -1;\n var len = self.queue.length;\n while (++i < len) {\n self.queue[i].callRejected(error);\n }\n return self;\n};\n\nfunction getThen(obj) {\n // Make sure we only access the accessor once as required by the spec\n var then = obj && obj.then;\n if (obj && (typeof obj === 'object' || typeof obj === 'function') && typeof then === 'function') {\n return function appyThen() {\n then.apply(obj, arguments);\n };\n }\n}\n\nfunction safelyResolveThenable(self, thenable) {\n // Either fulfill, reject or reject with error\n var called = false;\n function onError(value) {\n if (called) {\n return;\n }\n called = true;\n handlers.reject(self, value);\n }\n\n function onSuccess(value) {\n if (called) {\n return;\n }\n called = true;\n handlers.resolve(self, value);\n }\n\n function tryToUnwrap() {\n thenable(onSuccess, onError);\n }\n\n var result = tryCatch(tryToUnwrap);\n if (result.status === 'error') {\n onError(result.value);\n }\n}\n\nfunction tryCatch(func, value) {\n var out = {};\n try {\n out.value = func(value);\n out.status = 'success';\n } catch (e) {\n out.status = 'error';\n out.value = e;\n }\n return out;\n}\n\nPromise.resolve = resolve;\nfunction resolve(value) {\n if (value instanceof this) {\n return value;\n }\n return handlers.resolve(new this(INTERNAL), value);\n}\n\nPromise.reject = reject;\nfunction reject(reason) {\n var promise = new this(INTERNAL);\n return handlers.reject(promise, reason);\n}\n\nPromise.all = all;\nfunction all(iterable) {\n var self = this;\n if (Object.prototype.toString.call(iterable) !== '[object Array]') {\n return this.reject(new TypeError('must be an array'));\n }\n\n var len = iterable.length;\n var called = false;\n if (!len) {\n return this.resolve([]);\n }\n\n var values = new Array(len);\n var resolved = 0;\n var i = -1;\n var promise = new this(INTERNAL);\n\n while (++i < len) {\n allResolver(iterable[i], i);\n }\n return promise;\n function allResolver(value, i) {\n self.resolve(value).then(resolveFromAll, function (error) {\n if (!called) {\n called = true;\n handlers.reject(promise, error);\n }\n });\n function resolveFromAll(outValue) {\n values[i] = outValue;\n if (++resolved === len && !called) {\n called = true;\n handlers.resolve(promise, values);\n }\n }\n }\n}\n\nPromise.race = race;\nfunction race(iterable) {\n var self = this;\n if (Object.prototype.toString.call(iterable) !== '[object Array]') {\n return this.reject(new TypeError('must be an array'));\n }\n\n var len = iterable.length;\n var called = false;\n if (!len) {\n return this.resolve([]);\n }\n\n var i = -1;\n var promise = new this(INTERNAL);\n\n while (++i < len) {\n resolver(iterable[i]);\n }\n return promise;\n function resolver(value) {\n self.resolve(value).then(function (response) {\n if (!called) {\n called = true;\n handlers.resolve(promise, response);\n }\n }, function (error) {\n if (!called) {\n called = true;\n handlers.reject(promise, error);\n }\n });\n }\n}\n\n},{\"1\":1}],3:[function(_dereq_,module,exports){\n(function (global){\n'use strict';\nif (typeof global.Promise !== 'function') {\n global.Promise = _dereq_(2);\n}\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"2\":2}],4:[function(_dereq_,module,exports){\n'use strict';\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction getIDB() {\n /* global indexedDB,webkitIndexedDB,mozIndexedDB,OIndexedDB,msIndexedDB */\n try {\n if (typeof indexedDB !== 'undefined') {\n return indexedDB;\n }\n if (typeof webkitIndexedDB !== 'undefined') {\n return webkitIndexedDB;\n }\n if (typeof mozIndexedDB !== 'undefined') {\n return mozIndexedDB;\n }\n if (typeof OIndexedDB !== 'undefined') {\n return OIndexedDB;\n }\n if (typeof msIndexedDB !== 'undefined') {\n return msIndexedDB;\n }\n } catch (e) {\n return;\n }\n}\n\nvar idb = getIDB();\n\nfunction isIndexedDBValid() {\n try {\n // Initialize IndexedDB; fall back to vendor-prefixed versions\n // if needed.\n if (!idb) {\n return false;\n }\n // We mimic PouchDB here;\n //\n // We test for openDatabase because IE Mobile identifies itself\n // as Safari. Oh the lulz...\n var isSafari = typeof openDatabase !== 'undefined' && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform);\n\n var hasFetch = typeof fetch === 'function' && fetch.toString().indexOf('[native code') !== -1;\n\n // Safari <10.1 does not meet our requirements for IDB support (#5572)\n // since Safari 10.1 shipped with fetch, we can use that to detect it\n return (!isSafari || hasFetch) && typeof indexedDB !== 'undefined' &&\n // some outdated implementations of IDB that appear on Samsung\n // and HTC Android devices <4.4 are missing IDBKeyRange\n // See: https://github.com/mozilla/localForage/issues/128\n // See: https://github.com/mozilla/localForage/issues/272\n typeof IDBKeyRange !== 'undefined';\n } catch (e) {\n return false;\n }\n}\n\n// Abstracts constructing a Blob object, so it also works in older\n// browsers that don't support the native Blob constructor. (i.e.\n// old QtWebKit versions, at least).\n// Abstracts constructing a Blob object, so it also works in older\n// browsers that don't support the native Blob constructor. (i.e.\n// old QtWebKit versions, at least).\nfunction createBlob(parts, properties) {\n /* global BlobBuilder,MSBlobBuilder,MozBlobBuilder,WebKitBlobBuilder */\n parts = parts || [];\n properties = properties || {};\n try {\n return new Blob(parts, properties);\n } catch (e) {\n if (e.name !== 'TypeError') {\n throw e;\n }\n var Builder = typeof BlobBuilder !== 'undefined' ? BlobBuilder : typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder : typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : WebKitBlobBuilder;\n var builder = new Builder();\n for (var i = 0; i < parts.length; i += 1) {\n builder.append(parts[i]);\n }\n return builder.getBlob(properties.type);\n }\n}\n\n// This is CommonJS because lie is an external dependency, so Rollup\n// can just ignore it.\nif (typeof Promise === 'undefined') {\n // In the \"nopromises\" build this will just throw if you don't have\n // a global promise object, but it would throw anyway later.\n _dereq_(3);\n}\nvar Promise$1 = Promise;\n\nfunction executeCallback(promise, callback) {\n if (callback) {\n promise.then(function (result) {\n callback(null, result);\n }, function (error) {\n callback(error);\n });\n }\n}\n\nfunction executeTwoCallbacks(promise, callback, errorCallback) {\n if (typeof callback === 'function') {\n promise.then(callback);\n }\n\n if (typeof errorCallback === 'function') {\n promise[\"catch\"](errorCallback);\n }\n}\n\nfunction normalizeKey(key) {\n // Cast the key to a string, as that's all we can set as a key.\n if (typeof key !== 'string') {\n console.warn(key + ' used as a key, but it is not a string.');\n key = String(key);\n }\n\n return key;\n}\n\n// Some code originally from async_storage.js in\n// [Gaia](https://github.com/mozilla-b2g/gaia).\n\nvar DETECT_BLOB_SUPPORT_STORE = 'local-forage-detect-blob-support';\nvar supportsBlobs;\nvar dbContexts;\nvar toString = Object.prototype.toString;\n\n// Transaction Modes\nvar READ_ONLY = 'readonly';\nvar READ_WRITE = 'readwrite';\n\n// Transform a binary string to an array buffer, because otherwise\n// weird stuff happens when you try to work with the binary string directly.\n// It is known.\n// From http://stackoverflow.com/questions/14967647/ (continues on next line)\n// encode-decode-image-with-base64-breaks-image (2013-04-21)\nfunction _binStringToArrayBuffer(bin) {\n var length = bin.length;\n var buf = new ArrayBuffer(length);\n var arr = new Uint8Array(buf);\n for (var i = 0; i < length; i++) {\n arr[i] = bin.charCodeAt(i);\n }\n return buf;\n}\n\n//\n// Blobs are not supported in all versions of IndexedDB, notably\n// Chrome <37 and Android <5. In those versions, storing a blob will throw.\n//\n// Various other blob bugs exist in Chrome v37-42 (inclusive).\n// Detecting them is expensive and confusing to users, and Chrome 37-42\n// is at very low usage worldwide, so we do a hacky userAgent check instead.\n//\n// content-type bug: https://code.google.com/p/chromium/issues/detail?id=408120\n// 404 bug: https://code.google.com/p/chromium/issues/detail?id=447916\n// FileReader bug: https://code.google.com/p/chromium/issues/detail?id=447836\n//\n// Code borrowed from PouchDB. See:\n// https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-adapter-idb/src/blobSupport.js\n//\nfunction _checkBlobSupportWithoutCaching(idb) {\n return new Promise$1(function (resolve) {\n var txn = idb.transaction(DETECT_BLOB_SUPPORT_STORE, READ_WRITE);\n var blob = createBlob(['']);\n txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key');\n\n txn.onabort = function (e) {\n // If the transaction aborts now its due to not being able to\n // write to the database, likely due to the disk being full\n e.preventDefault();\n e.stopPropagation();\n resolve(false);\n };\n\n txn.oncomplete = function () {\n var matchedChrome = navigator.userAgent.match(/Chrome\\/(\\d+)/);\n var matchedEdge = navigator.userAgent.match(/Edge\\//);\n // MS Edge pretends to be Chrome 42:\n // https://msdn.microsoft.com/en-us/library/hh869301%28v=vs.85%29.aspx\n resolve(matchedEdge || !matchedChrome || parseInt(matchedChrome[1], 10) >= 43);\n };\n })[\"catch\"](function () {\n return false; // error, so assume unsupported\n });\n}\n\nfunction _checkBlobSupport(idb) {\n if (typeof supportsBlobs === 'boolean') {\n return Promise$1.resolve(supportsBlobs);\n }\n return _checkBlobSupportWithoutCaching(idb).then(function (value) {\n supportsBlobs = value;\n return supportsBlobs;\n });\n}\n\nfunction _deferReadiness(dbInfo) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Create a deferred object representing the current database operation.\n var deferredOperation = {};\n\n deferredOperation.promise = new Promise$1(function (resolve) {\n deferredOperation.resolve = resolve;\n });\n\n // Enqueue the deferred operation.\n dbContext.deferredOperations.push(deferredOperation);\n\n // Chain its promise to the database readiness.\n if (!dbContext.dbReady) {\n dbContext.dbReady = deferredOperation.promise;\n } else {\n dbContext.dbReady = dbContext.dbReady.then(function () {\n return deferredOperation.promise;\n });\n }\n}\n\nfunction _advanceReadiness(dbInfo) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Dequeue a deferred operation.\n var deferredOperation = dbContext.deferredOperations.pop();\n\n // Resolve its promise (which is part of the database readiness\n // chain of promises).\n if (deferredOperation) {\n deferredOperation.resolve();\n }\n}\n\nfunction _rejectReadiness(dbInfo, err) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Dequeue a deferred operation.\n var deferredOperation = dbContext.deferredOperations.pop();\n\n // Reject its promise (which is part of the database readiness\n // chain of promises).\n if (deferredOperation) {\n deferredOperation.reject(err);\n }\n}\n\nfunction _getConnection(dbInfo, upgradeNeeded) {\n return new Promise$1(function (resolve, reject) {\n\n if (dbInfo.db) {\n if (upgradeNeeded) {\n _deferReadiness(dbInfo);\n dbInfo.db.close();\n } else {\n return resolve(dbInfo.db);\n }\n }\n\n var dbArgs = [dbInfo.name];\n\n if (upgradeNeeded) {\n dbArgs.push(dbInfo.version);\n }\n\n var openreq = idb.open.apply(idb, dbArgs);\n\n if (upgradeNeeded) {\n openreq.onupgradeneeded = function (e) {\n var db = openreq.result;\n try {\n db.createObjectStore(dbInfo.storeName);\n if (e.oldVersion <= 1) {\n // Added when support for blob shims was added\n db.createObjectStore(DETECT_BLOB_SUPPORT_STORE);\n }\n } catch (ex) {\n if (ex.name === 'ConstraintError') {\n console.warn('The database \"' + dbInfo.name + '\"' + ' has been upgraded from version ' + e.oldVersion + ' to version ' + e.newVersion + ', but the storage \"' + dbInfo.storeName + '\" already exists.');\n } else {\n throw ex;\n }\n }\n };\n }\n\n openreq.onerror = function (e) {\n e.preventDefault();\n reject(openreq.error);\n };\n\n openreq.onsuccess = function () {\n resolve(openreq.result);\n _advanceReadiness(dbInfo);\n };\n });\n}\n\nfunction _getOriginalConnection(dbInfo) {\n return _getConnection(dbInfo, false);\n}\n\nfunction _getUpgradedConnection(dbInfo) {\n return _getConnection(dbInfo, true);\n}\n\nfunction _isUpgradeNeeded(dbInfo, defaultVersion) {\n if (!dbInfo.db) {\n return true;\n }\n\n var isNewStore = !dbInfo.db.objectStoreNames.contains(dbInfo.storeName);\n var isDowngrade = dbInfo.version < dbInfo.db.version;\n var isUpgrade = dbInfo.version > dbInfo.db.version;\n\n if (isDowngrade) {\n // If the version is not the default one\n // then warn for impossible downgrade.\n if (dbInfo.version !== defaultVersion) {\n console.warn('The database \"' + dbInfo.name + '\"' + ' can\\'t be downgraded from version ' + dbInfo.db.version + ' to version ' + dbInfo.version + '.');\n }\n // Align the versions to prevent errors.\n dbInfo.version = dbInfo.db.version;\n }\n\n if (isUpgrade || isNewStore) {\n // If the store is new then increment the version (if needed).\n // This will trigger an \"upgradeneeded\" event which is required\n // for creating a store.\n if (isNewStore) {\n var incVersion = dbInfo.db.version + 1;\n if (incVersion > dbInfo.version) {\n dbInfo.version = incVersion;\n }\n }\n\n return true;\n }\n\n return false;\n}\n\n// encode a blob for indexeddb engines that don't support blobs\nfunction _encodeBlob(blob) {\n return new Promise$1(function (resolve, reject) {\n var reader = new FileReader();\n reader.onerror = reject;\n reader.onloadend = function (e) {\n var base64 = btoa(e.target.result || '');\n resolve({\n __local_forage_encoded_blob: true,\n data: base64,\n type: blob.type\n });\n };\n reader.readAsBinaryString(blob);\n });\n}\n\n// decode an encoded blob\nfunction _decodeBlob(encodedBlob) {\n var arrayBuff = _binStringToArrayBuffer(atob(encodedBlob.data));\n return createBlob([arrayBuff], { type: encodedBlob.type });\n}\n\n// is this one of our fancy encoded blobs?\nfunction _isEncodedBlob(value) {\n return value && value.__local_forage_encoded_blob;\n}\n\n// Specialize the default `ready()` function by making it dependent\n// on the current database operations. Thus, the driver will be actually\n// ready when it's been initialized (default) *and* there are no pending\n// operations on the database (initiated by some other instances).\nfunction _fullyReady(callback) {\n var self = this;\n\n var promise = self._initReady().then(function () {\n var dbContext = dbContexts[self._dbInfo.name];\n\n if (dbContext && dbContext.dbReady) {\n return dbContext.dbReady;\n }\n });\n\n executeTwoCallbacks(promise, callback, callback);\n return promise;\n}\n\n// Try to establish a new db connection to replace the\n// current one which is broken (i.e. experiencing\n// InvalidStateError while creating a transaction).\nfunction _tryReconnect(dbInfo) {\n _deferReadiness(dbInfo);\n\n var dbContext = dbContexts[dbInfo.name];\n var forages = dbContext.forages;\n\n for (var i = 0; i < forages.length; i++) {\n if (forages[i]._dbInfo.db) {\n forages[i]._dbInfo.db.close();\n forages[i]._dbInfo.db = null;\n }\n }\n\n return _getConnection(dbInfo, false).then(function (db) {\n for (var j = 0; j < forages.length; j++) {\n forages[j]._dbInfo.db = db;\n }\n })[\"catch\"](function (err) {\n _rejectReadiness(dbInfo, err);\n throw err;\n });\n}\n\n// FF doesn't like Promises (micro-tasks) and IDDB store operations,\n// so we have to do it with callbacks\nfunction createTransaction(dbInfo, mode, callback) {\n try {\n var tx = dbInfo.db.transaction(dbInfo.storeName, mode);\n callback(null, tx);\n } catch (err) {\n if (!dbInfo.db || err.name === 'InvalidStateError') {\n return _tryReconnect(dbInfo).then(function () {\n\n var tx = dbInfo.db.transaction(dbInfo.storeName, mode);\n callback(null, tx);\n });\n }\n\n callback(err);\n }\n}\n\n// Open the IndexedDB database (automatically creates one if one didn't\n// previously exist), using any options set in the config.\nfunction _initStorage(options) {\n var self = this;\n var dbInfo = {\n db: null\n };\n\n if (options) {\n for (var i in options) {\n dbInfo[i] = options[i];\n }\n }\n\n // Initialize a singleton container for all running localForages.\n if (!dbContexts) {\n dbContexts = {};\n }\n\n // Get the current context of the database;\n var dbContext = dbContexts[dbInfo.name];\n\n // ...or create a new context.\n if (!dbContext) {\n dbContext = {\n // Running localForages sharing a database.\n forages: [],\n // Shared database.\n db: null,\n // Database readiness (promise).\n dbReady: null,\n // Deferred operations on the database.\n deferredOperations: []\n };\n // Register the new context in the global container.\n dbContexts[dbInfo.name] = dbContext;\n }\n\n // Register itself as a running localForage in the current context.\n dbContext.forages.push(self);\n\n // Replace the default `ready()` function with the specialized one.\n if (!self._initReady) {\n self._initReady = self.ready;\n self.ready = _fullyReady;\n }\n\n // Create an array of initialization states of the related localForages.\n var initPromises = [];\n\n function ignoreErrors() {\n // Don't handle errors here,\n // just makes sure related localForages aren't pending.\n return Promise$1.resolve();\n }\n\n for (var j = 0; j < dbContext.forages.length; j++) {\n var forage = dbContext.forages[j];\n if (forage !== self) {\n // Don't wait for itself...\n initPromises.push(forage._initReady()[\"catch\"](ignoreErrors));\n }\n }\n\n // Take a snapshot of the related localForages.\n var forages = dbContext.forages.slice(0);\n\n // Initialize the connection process only when\n // all the related localForages aren't pending.\n return Promise$1.all(initPromises).then(function () {\n dbInfo.db = dbContext.db;\n // Get the connection or open a new one without upgrade.\n return _getOriginalConnection(dbInfo);\n }).then(function (db) {\n dbInfo.db = db;\n if (_isUpgradeNeeded(dbInfo, self._defaultConfig.version)) {\n // Reopen the database for upgrading.\n return _getUpgradedConnection(dbInfo);\n }\n return db;\n }).then(function (db) {\n dbInfo.db = dbContext.db = db;\n self._dbInfo = dbInfo;\n // Share the final connection amongst related localForages.\n for (var k = 0; k < forages.length; k++) {\n var forage = forages[k];\n if (forage !== self) {\n // Self is already up-to-date.\n forage._dbInfo.db = dbInfo.db;\n forage._dbInfo.version = dbInfo.version;\n }\n }\n });\n}\n\nfunction getItem(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.get(key);\n\n req.onsuccess = function () {\n var value = req.result;\n if (value === undefined) {\n value = null;\n }\n if (_isEncodedBlob(value)) {\n value = _decodeBlob(value);\n }\n resolve(value);\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Iterate over all items stored in database.\nfunction iterate(iterator, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.openCursor();\n var iterationNumber = 1;\n\n req.onsuccess = function () {\n var cursor = req.result;\n\n if (cursor) {\n var value = cursor.value;\n if (_isEncodedBlob(value)) {\n value = _decodeBlob(value);\n }\n var result = iterator(value, cursor.key, iterationNumber++);\n\n // when the iterator callback retuns any\n // (non-`undefined`) value, then we stop\n // the iteration immediately\n if (result !== void 0) {\n resolve(result);\n } else {\n cursor[\"continue\"]();\n }\n } else {\n resolve();\n }\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n\n return promise;\n}\n\nfunction setItem(key, value, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n var dbInfo;\n self.ready().then(function () {\n dbInfo = self._dbInfo;\n if (toString.call(value) === '[object Blob]') {\n return _checkBlobSupport(dbInfo.db).then(function (blobSupport) {\n if (blobSupport) {\n return value;\n }\n return _encodeBlob(value);\n });\n }\n return value;\n }).then(function (value) {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n\n // The reason we don't _save_ null is because IE 10 does\n // not support saving the `null` type in IndexedDB. How\n // ironic, given the bug below!\n // See: https://github.com/mozilla/localForage/issues/161\n if (value === null) {\n value = undefined;\n }\n\n var req = store.put(value, key);\n\n transaction.oncomplete = function () {\n // Cast to undefined so the value passed to\n // callback/promise is the same as what one would get out\n // of `getItem()` later. This leads to some weirdness\n // (setItem('foo', undefined) will return `null`), but\n // it's not my fault localStorage is our baseline and that\n // it's weird.\n if (value === undefined) {\n value = null;\n }\n\n resolve(value);\n };\n transaction.onabort = transaction.onerror = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction removeItem(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n // We use a Grunt task to make this safe for IE and some\n // versions of Android (including those used by Cordova).\n // Normally IE won't like `.delete()` and will insist on\n // using `['delete']()`, but we have a build step that\n // fixes this for us now.\n var req = store[\"delete\"](key);\n transaction.oncomplete = function () {\n resolve();\n };\n\n transaction.onerror = function () {\n reject(req.error);\n };\n\n // The request will be also be aborted if we've exceeded our storage\n // space.\n transaction.onabort = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction clear(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.clear();\n\n transaction.oncomplete = function () {\n resolve();\n };\n\n transaction.onabort = transaction.onerror = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction length(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.count();\n\n req.onsuccess = function () {\n resolve(req.result);\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction key(n, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n if (n < 0) {\n resolve(null);\n\n return;\n }\n\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var advanced = false;\n var req = store.openCursor();\n\n req.onsuccess = function () {\n var cursor = req.result;\n if (!cursor) {\n // this means there weren't enough keys\n resolve(null);\n\n return;\n }\n\n if (n === 0) {\n // We have the first key, return it if that's what they\n // wanted.\n resolve(cursor.key);\n } else {\n if (!advanced) {\n // Otherwise, ask the cursor to skip ahead n\n // records.\n advanced = true;\n cursor.advance(n);\n } else {\n // When we get here, we've got the nth key.\n resolve(cursor.key);\n }\n }\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.openCursor();\n var keys = [];\n\n req.onsuccess = function () {\n var cursor = req.result;\n\n if (!cursor) {\n resolve(keys);\n return;\n }\n\n keys.push(cursor.key);\n cursor[\"continue\"]();\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar asyncStorage = {\n _driver: 'asyncStorage',\n _initStorage: _initStorage,\n _support: isIndexedDBValid(),\n iterate: iterate,\n getItem: getItem,\n setItem: setItem,\n removeItem: removeItem,\n clear: clear,\n length: length,\n key: key,\n keys: keys\n};\n\nfunction isWebSQLValid() {\n return typeof openDatabase === 'function';\n}\n\n// Sadly, the best way to save binary data in WebSQL/localStorage is serializing\n// it to Base64, so this is how we store it to prevent very strange errors with less\n// verbose ways of binary <-> string data storage.\nvar BASE_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\nvar BLOB_TYPE_PREFIX = '~~local_forage_type~';\nvar BLOB_TYPE_PREFIX_REGEX = /^~~local_forage_type~([^~]+)~/;\n\nvar SERIALIZED_MARKER = '__lfsc__:';\nvar SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER.length;\n\n// OMG the serializations!\nvar TYPE_ARRAYBUFFER = 'arbf';\nvar TYPE_BLOB = 'blob';\nvar TYPE_INT8ARRAY = 'si08';\nvar TYPE_UINT8ARRAY = 'ui08';\nvar TYPE_UINT8CLAMPEDARRAY = 'uic8';\nvar TYPE_INT16ARRAY = 'si16';\nvar TYPE_INT32ARRAY = 'si32';\nvar TYPE_UINT16ARRAY = 'ur16';\nvar TYPE_UINT32ARRAY = 'ui32';\nvar TYPE_FLOAT32ARRAY = 'fl32';\nvar TYPE_FLOAT64ARRAY = 'fl64';\nvar TYPE_SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER_LENGTH + TYPE_ARRAYBUFFER.length;\n\nvar toString$1 = Object.prototype.toString;\n\nfunction stringToBuffer(serializedString) {\n // Fill the string into a ArrayBuffer.\n var bufferLength = serializedString.length * 0.75;\n var len = serializedString.length;\n var i;\n var p = 0;\n var encoded1, encoded2, encoded3, encoded4;\n\n if (serializedString[serializedString.length - 1] === '=') {\n bufferLength--;\n if (serializedString[serializedString.length - 2] === '=') {\n bufferLength--;\n }\n }\n\n var buffer = new ArrayBuffer(bufferLength);\n var bytes = new Uint8Array(buffer);\n\n for (i = 0; i < len; i += 4) {\n encoded1 = BASE_CHARS.indexOf(serializedString[i]);\n encoded2 = BASE_CHARS.indexOf(serializedString[i + 1]);\n encoded3 = BASE_CHARS.indexOf(serializedString[i + 2]);\n encoded4 = BASE_CHARS.indexOf(serializedString[i + 3]);\n\n /*jslint bitwise: true */\n bytes[p++] = encoded1 << 2 | encoded2 >> 4;\n bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;\n bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;\n }\n return buffer;\n}\n\n// Converts a buffer to a string to store, serialized, in the backend\n// storage library.\nfunction bufferToString(buffer) {\n // base64-arraybuffer\n var bytes = new Uint8Array(buffer);\n var base64String = '';\n var i;\n\n for (i = 0; i < bytes.length; i += 3) {\n /*jslint bitwise: true */\n base64String += BASE_CHARS[bytes[i] >> 2];\n base64String += BASE_CHARS[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];\n base64String += BASE_CHARS[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];\n base64String += BASE_CHARS[bytes[i + 2] & 63];\n }\n\n if (bytes.length % 3 === 2) {\n base64String = base64String.substring(0, base64String.length - 1) + '=';\n } else if (bytes.length % 3 === 1) {\n base64String = base64String.substring(0, base64String.length - 2) + '==';\n }\n\n return base64String;\n}\n\n// Serialize a value, afterwards executing a callback (which usually\n// instructs the `setItem()` callback/promise to be executed). This is how\n// we store binary data with localStorage.\nfunction serialize(value, callback) {\n var valueType = '';\n if (value) {\n valueType = toString$1.call(value);\n }\n\n // Cannot use `value instanceof ArrayBuffer` or such here, as these\n // checks fail when running the tests using casper.js...\n //\n // TODO: See why those tests fail and use a better solution.\n if (value && (valueType === '[object ArrayBuffer]' || value.buffer && toString$1.call(value.buffer) === '[object ArrayBuffer]')) {\n // Convert binary arrays to a string and prefix the string with\n // a special marker.\n var buffer;\n var marker = SERIALIZED_MARKER;\n\n if (value instanceof ArrayBuffer) {\n buffer = value;\n marker += TYPE_ARRAYBUFFER;\n } else {\n buffer = value.buffer;\n\n if (valueType === '[object Int8Array]') {\n marker += TYPE_INT8ARRAY;\n } else if (valueType === '[object Uint8Array]') {\n marker += TYPE_UINT8ARRAY;\n } else if (valueType === '[object Uint8ClampedArray]') {\n marker += TYPE_UINT8CLAMPEDARRAY;\n } else if (valueType === '[object Int16Array]') {\n marker += TYPE_INT16ARRAY;\n } else if (valueType === '[object Uint16Array]') {\n marker += TYPE_UINT16ARRAY;\n } else if (valueType === '[object Int32Array]') {\n marker += TYPE_INT32ARRAY;\n } else if (valueType === '[object Uint32Array]') {\n marker += TYPE_UINT32ARRAY;\n } else if (valueType === '[object Float32Array]') {\n marker += TYPE_FLOAT32ARRAY;\n } else if (valueType === '[object Float64Array]') {\n marker += TYPE_FLOAT64ARRAY;\n } else {\n callback(new Error('Failed to get type for BinaryArray'));\n }\n }\n\n callback(marker + bufferToString(buffer));\n } else if (valueType === '[object Blob]') {\n // Conver the blob to a binaryArray and then to a string.\n var fileReader = new FileReader();\n\n fileReader.onload = function () {\n // Backwards-compatible prefix for the blob type.\n var str = BLOB_TYPE_PREFIX + value.type + '~' + bufferToString(this.result);\n\n callback(SERIALIZED_MARKER + TYPE_BLOB + str);\n };\n\n fileReader.readAsArrayBuffer(value);\n } else {\n try {\n callback(JSON.stringify(value));\n } catch (e) {\n console.error(\"Couldn't convert value into a JSON string: \", value);\n\n callback(null, e);\n }\n }\n}\n\n// Deserialize data we've inserted into a value column/field. We place\n// special markers into our strings to mark them as encoded; this isn't\n// as nice as a meta field, but it's the only sane thing we can do whilst\n// keeping localStorage support intact.\n//\n// Oftentimes this will just deserialize JSON content, but if we have a\n// special marker (SERIALIZED_MARKER, defined above), we will extract\n// some kind of arraybuffer/binary data/typed array out of the string.\nfunction deserialize(value) {\n // If we haven't marked this string as being specially serialized (i.e.\n // something other than serialized JSON), we can just return it and be\n // done with it.\n if (value.substring(0, SERIALIZED_MARKER_LENGTH) !== SERIALIZED_MARKER) {\n return JSON.parse(value);\n }\n\n // The following code deals with deserializing some kind of Blob or\n // TypedArray. First we separate out the type of data we're dealing\n // with from the data itself.\n var serializedString = value.substring(TYPE_SERIALIZED_MARKER_LENGTH);\n var type = value.substring(SERIALIZED_MARKER_LENGTH, TYPE_SERIALIZED_MARKER_LENGTH);\n\n var blobType;\n // Backwards-compatible blob type serialization strategy.\n // DBs created with older versions of localForage will simply not have the blob type.\n if (type === TYPE_BLOB && BLOB_TYPE_PREFIX_REGEX.test(serializedString)) {\n var matcher = serializedString.match(BLOB_TYPE_PREFIX_REGEX);\n blobType = matcher[1];\n serializedString = serializedString.substring(matcher[0].length);\n }\n var buffer = stringToBuffer(serializedString);\n\n // Return the right type based on the code/type set during\n // serialization.\n switch (type) {\n case TYPE_ARRAYBUFFER:\n return buffer;\n case TYPE_BLOB:\n return createBlob([buffer], { type: blobType });\n case TYPE_INT8ARRAY:\n return new Int8Array(buffer);\n case TYPE_UINT8ARRAY:\n return new Uint8Array(buffer);\n case TYPE_UINT8CLAMPEDARRAY:\n return new Uint8ClampedArray(buffer);\n case TYPE_INT16ARRAY:\n return new Int16Array(buffer);\n case TYPE_UINT16ARRAY:\n return new Uint16Array(buffer);\n case TYPE_INT32ARRAY:\n return new Int32Array(buffer);\n case TYPE_UINT32ARRAY:\n return new Uint32Array(buffer);\n case TYPE_FLOAT32ARRAY:\n return new Float32Array(buffer);\n case TYPE_FLOAT64ARRAY:\n return new Float64Array(buffer);\n default:\n throw new Error('Unkown type: ' + type);\n }\n}\n\nvar localforageSerializer = {\n serialize: serialize,\n deserialize: deserialize,\n stringToBuffer: stringToBuffer,\n bufferToString: bufferToString\n};\n\n/*\n * Includes code from:\n *\n * base64-arraybuffer\n * https://github.com/niklasvh/base64-arraybuffer\n *\n * Copyright (c) 2012 Niklas von Hertzen\n * Licensed under the MIT license.\n */\n// Open the WebSQL database (automatically creates one if one didn't\n// previously exist), using any options set in the config.\nfunction _initStorage$1(options) {\n var self = this;\n var dbInfo = {\n db: null\n };\n\n if (options) {\n for (var i in options) {\n dbInfo[i] = typeof options[i] !== 'string' ? options[i].toString() : options[i];\n }\n }\n\n var dbInfoPromise = new Promise$1(function (resolve, reject) {\n // Open the database; the openDatabase API will automatically\n // create it for us if it doesn't exist.\n try {\n dbInfo.db = openDatabase(dbInfo.name, String(dbInfo.version), dbInfo.description, dbInfo.size);\n } catch (e) {\n return reject(e);\n }\n\n // Create our key/value table if it doesn't exist.\n dbInfo.db.transaction(function (t) {\n t.executeSql('CREATE TABLE IF NOT EXISTS ' + dbInfo.storeName + ' (id INTEGER PRIMARY KEY, key unique, value)', [], function () {\n self._dbInfo = dbInfo;\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n });\n\n dbInfo.serializer = localforageSerializer;\n return dbInfoPromise;\n}\n\nfunction getItem$1(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE key = ? LIMIT 1', [key], function (t, results) {\n var result = results.rows.length ? results.rows.item(0).value : null;\n\n // Check to see if this is serialized content we need to\n // unpack.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n resolve(result);\n }, function (t, error) {\n\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction iterate$1(iterator, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT * FROM ' + dbInfo.storeName, [], function (t, results) {\n var rows = results.rows;\n var length = rows.length;\n\n for (var i = 0; i < length; i++) {\n var item = rows.item(i);\n var result = item.value;\n\n // Check to see if this is serialized content\n // we need to unpack.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n result = iterator(result, item.key, i + 1);\n\n // void(0) prevents problems with redefinition\n // of `undefined`.\n if (result !== void 0) {\n resolve(result);\n return;\n }\n }\n\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction _setItem(key, value, callback, retriesLeft) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n // The localStorage API doesn't return undefined values in an\n // \"expected\" way, so undefined is always cast to null in all\n // drivers. See: https://github.com/mozilla/localForage/pull/42\n if (value === undefined) {\n value = null;\n }\n\n // Save the original value to pass to the callback.\n var originalValue = value;\n\n var dbInfo = self._dbInfo;\n dbInfo.serializer.serialize(value, function (value, error) {\n if (error) {\n reject(error);\n } else {\n dbInfo.db.transaction(function (t) {\n t.executeSql('INSERT OR REPLACE INTO ' + dbInfo.storeName + ' (key, value) VALUES (?, ?)', [key, value], function () {\n resolve(originalValue);\n }, function (t, error) {\n reject(error);\n });\n }, function (sqlError) {\n // The transaction failed; check\n // to see if it's a quota error.\n if (sqlError.code === sqlError.QUOTA_ERR) {\n // We reject the callback outright for now, but\n // it's worth trying to re-run the transaction.\n // Even if the user accepts the prompt to use\n // more storage on Safari, this error will\n // be called.\n //\n // Try to re-run the transaction.\n if (retriesLeft > 0) {\n resolve(_setItem.apply(self, [key, originalValue, callback, retriesLeft - 1]));\n return;\n }\n reject(sqlError);\n }\n });\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction setItem$1(key, value, callback) {\n return _setItem.apply(this, [key, value, callback, 1]);\n}\n\nfunction removeItem$1(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('DELETE FROM ' + dbInfo.storeName + ' WHERE key = ?', [key], function () {\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Deletes every item in the table.\n// TODO: Find out if this resets the AUTO_INCREMENT number.\nfunction clear$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('DELETE FROM ' + dbInfo.storeName, [], function () {\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Does a simple `COUNT(key)` to get the number of items stored in\n// localForage.\nfunction length$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n // Ahhh, SQL makes this one soooooo easy.\n t.executeSql('SELECT COUNT(key) as c FROM ' + dbInfo.storeName, [], function (t, results) {\n var result = results.rows.item(0).c;\n\n resolve(result);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Return the key located at key index X; essentially gets the key from a\n// `WHERE id = ?`. This is the most efficient way I can think to implement\n// this rarely-used (in my experience) part of the API, but it can seem\n// inconsistent, because we do `INSERT OR REPLACE INTO` on `setItem()`, so\n// the ID of each key will change every time it's updated. Perhaps a stored\n// procedure for the `setItem()` SQL would solve this problem?\n// TODO: Don't change ID on `setItem()`.\nfunction key$1(n, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT key FROM ' + dbInfo.storeName + ' WHERE id = ? LIMIT 1', [n + 1], function (t, results) {\n var result = results.rows.length ? results.rows.item(0).key : null;\n resolve(result);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT key FROM ' + dbInfo.storeName, [], function (t, results) {\n var keys = [];\n\n for (var i = 0; i < results.rows.length; i++) {\n keys.push(results.rows.item(i).key);\n }\n\n resolve(keys);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar webSQLStorage = {\n _driver: 'webSQLStorage',\n _initStorage: _initStorage$1,\n _support: isWebSQLValid(),\n iterate: iterate$1,\n getItem: getItem$1,\n setItem: setItem$1,\n removeItem: removeItem$1,\n clear: clear$1,\n length: length$1,\n key: key$1,\n keys: keys$1\n};\n\nfunction isLocalStorageValid() {\n try {\n return typeof localStorage !== 'undefined' && 'setItem' in localStorage && typeof localStorage.setItem === 'function';\n } catch (e) {\n return false;\n }\n}\n\n// Check if localStorage throws when saving an item\nfunction checkIfLocalStorageThrows() {\n var localStorageTestKey = '_localforage_support_test';\n\n try {\n localStorage.setItem(localStorageTestKey, true);\n localStorage.removeItem(localStorageTestKey);\n\n return false;\n } catch (e) {\n return true;\n }\n}\n\n// Check if localStorage is usable and allows to save an item\n// This method checks if localStorage is usable in Safari Private Browsing\n// mode, or in any other case where the available quota for localStorage\n// is 0 and there wasn't any saved items yet.\nfunction _isLocalStorageUsable() {\n return !checkIfLocalStorageThrows() || localStorage.length > 0;\n}\n\n// Config the localStorage backend, using options set in the config.\nfunction _initStorage$2(options) {\n var self = this;\n var dbInfo = {};\n if (options) {\n for (var i in options) {\n dbInfo[i] = options[i];\n }\n }\n\n dbInfo.keyPrefix = dbInfo.name + '/';\n\n if (dbInfo.storeName !== self._defaultConfig.storeName) {\n dbInfo.keyPrefix += dbInfo.storeName + '/';\n }\n\n if (!_isLocalStorageUsable()) {\n return Promise$1.reject();\n }\n\n self._dbInfo = dbInfo;\n dbInfo.serializer = localforageSerializer;\n\n return Promise$1.resolve();\n}\n\n// Remove all keys from the datastore, effectively destroying all data in\n// the app's key/value store!\nfunction clear$2(callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var keyPrefix = self._dbInfo.keyPrefix;\n\n for (var i = localStorage.length - 1; i >= 0; i--) {\n var key = localStorage.key(i);\n\n if (key.indexOf(keyPrefix) === 0) {\n localStorage.removeItem(key);\n }\n }\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Retrieve an item from the store. Unlike the original async_storage\n// library in Gaia, we don't modify return values at all. If a key's value\n// is `undefined`, we pass that value to the callback function.\nfunction getItem$2(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var result = localStorage.getItem(dbInfo.keyPrefix + key);\n\n // If a result was found, parse it from the serialized\n // string into a JS object. If result isn't truthy, the key\n // is likely undefined and we'll pass it straight to the\n // callback.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n return result;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Iterate over all items in the store.\nfunction iterate$2(iterator, callback) {\n var self = this;\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var keyPrefix = dbInfo.keyPrefix;\n var keyPrefixLength = keyPrefix.length;\n var length = localStorage.length;\n\n // We use a dedicated iterator instead of the `i` variable below\n // so other keys we fetch in localStorage aren't counted in\n // the `iterationNumber` argument passed to the `iterate()`\n // callback.\n //\n // See: github.com/mozilla/localForage/pull/435#discussion_r38061530\n var iterationNumber = 1;\n\n for (var i = 0; i < length; i++) {\n var key = localStorage.key(i);\n if (key.indexOf(keyPrefix) !== 0) {\n continue;\n }\n var value = localStorage.getItem(key);\n\n // If a result was found, parse it from the serialized\n // string into a JS object. If result isn't truthy, the\n // key is likely undefined and we'll pass it straight\n // to the iterator.\n if (value) {\n value = dbInfo.serializer.deserialize(value);\n }\n\n value = iterator(value, key.substring(keyPrefixLength), iterationNumber++);\n\n if (value !== void 0) {\n return value;\n }\n }\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Same as localStorage's key() method, except takes a callback.\nfunction key$2(n, callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var result;\n try {\n result = localStorage.key(n);\n } catch (error) {\n result = null;\n }\n\n // Remove the prefix from the key, if a key is found.\n if (result) {\n result = result.substring(dbInfo.keyPrefix.length);\n }\n\n return result;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys$2(callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var length = localStorage.length;\n var keys = [];\n\n for (var i = 0; i < length; i++) {\n var itemKey = localStorage.key(i);\n if (itemKey.indexOf(dbInfo.keyPrefix) === 0) {\n keys.push(itemKey.substring(dbInfo.keyPrefix.length));\n }\n }\n\n return keys;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Supply the number of keys in the datastore to the callback function.\nfunction length$2(callback) {\n var self = this;\n var promise = self.keys().then(function (keys) {\n return keys.length;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Remove an item from the store, nice and simple.\nfunction removeItem$2(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n localStorage.removeItem(dbInfo.keyPrefix + key);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Set a key's value and run an optional callback once the value is set.\n// Unlike Gaia's implementation, the callback function is passed the value,\n// in case you want to operate on that value only after you're sure it\n// saved, or something like that.\nfunction setItem$2(key, value, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n // Convert undefined values to null.\n // https://github.com/mozilla/localForage/pull/42\n if (value === undefined) {\n value = null;\n }\n\n // Save the original value to pass to the callback.\n var originalValue = value;\n\n return new Promise$1(function (resolve, reject) {\n var dbInfo = self._dbInfo;\n dbInfo.serializer.serialize(value, function (value, error) {\n if (error) {\n reject(error);\n } else {\n try {\n localStorage.setItem(dbInfo.keyPrefix + key, value);\n resolve(originalValue);\n } catch (e) {\n // localStorage capacity exceeded.\n // TODO: Make this a specific error/event.\n if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {\n reject(e);\n }\n reject(e);\n }\n }\n });\n });\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar localStorageWrapper = {\n _driver: 'localStorageWrapper',\n _initStorage: _initStorage$2,\n _support: isLocalStorageValid(),\n iterate: iterate$2,\n getItem: getItem$2,\n setItem: setItem$2,\n removeItem: removeItem$2,\n clear: clear$2,\n length: length$2,\n key: key$2,\n keys: keys$2\n};\n\nvar isArray = Array.isArray || function (arg) {\n return Object.prototype.toString.call(arg) === '[object Array]';\n};\n\n// Drivers are stored here when `defineDriver()` is called.\n// They are shared across all instances of localForage.\nvar DefinedDrivers = {};\n\nvar DriverSupport = {};\n\nvar DefaultDrivers = {\n INDEXEDDB: asyncStorage,\n WEBSQL: webSQLStorage,\n LOCALSTORAGE: localStorageWrapper\n};\n\nvar DefaultDriverOrder = [DefaultDrivers.INDEXEDDB._driver, DefaultDrivers.WEBSQL._driver, DefaultDrivers.LOCALSTORAGE._driver];\n\nvar LibraryMethods = ['clear', 'getItem', 'iterate', 'key', 'keys', 'length', 'removeItem', 'setItem'];\n\nvar DefaultConfig = {\n description: '',\n driver: DefaultDriverOrder.slice(),\n name: 'localforage',\n // Default DB size is _JUST UNDER_ 5MB, as it's the highest size\n // we can use without a prompt.\n size: 4980736,\n storeName: 'keyvaluepairs',\n version: 1.0\n};\n\nfunction callWhenReady(localForageInstance, libraryMethod) {\n localForageInstance[libraryMethod] = function () {\n var _args = arguments;\n return localForageInstance.ready().then(function () {\n return localForageInstance[libraryMethod].apply(localForageInstance, _args);\n });\n };\n}\n\nfunction extend() {\n for (var i = 1; i < arguments.length; i++) {\n var arg = arguments[i];\n\n if (arg) {\n for (var _key in arg) {\n if (arg.hasOwnProperty(_key)) {\n if (isArray(arg[_key])) {\n arguments[0][_key] = arg[_key].slice();\n } else {\n arguments[0][_key] = arg[_key];\n }\n }\n }\n }\n }\n\n return arguments[0];\n}\n\nvar LocalForage = function () {\n function LocalForage(options) {\n _classCallCheck(this, LocalForage);\n\n for (var driverTypeKey in DefaultDrivers) {\n if (DefaultDrivers.hasOwnProperty(driverTypeKey)) {\n var driver = DefaultDrivers[driverTypeKey];\n var driverName = driver._driver;\n this[driverTypeKey] = driverName;\n\n if (!DefinedDrivers[driverName]) {\n // we don't need to wait for the promise,\n // since the default drivers can be defined\n // in a blocking manner\n this.defineDriver(driver);\n }\n }\n }\n\n this._defaultConfig = extend({}, DefaultConfig);\n this._config = extend({}, this._defaultConfig, options);\n this._driverSet = null;\n this._initDriver = null;\n this._ready = false;\n this._dbInfo = null;\n\n this._wrapLibraryMethodsWithReady();\n this.setDriver(this._config.driver)[\"catch\"](function () {});\n }\n\n // Set any config values for localForage; can be called anytime before\n // the first API call (e.g. `getItem`, `setItem`).\n // We loop through options so we don't overwrite existing config\n // values.\n\n\n LocalForage.prototype.config = function config(options) {\n // If the options argument is an object, we use it to set values.\n // Otherwise, we return either a specified config value or all\n // config values.\n if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object') {\n // If localforage is ready and fully initialized, we can't set\n // any new configuration values. Instead, we return an error.\n if (this._ready) {\n return new Error('Can\\'t call config() after localforage ' + 'has been used.');\n }\n\n for (var i in options) {\n if (i === 'storeName') {\n options[i] = options[i].replace(/\\W/g, '_');\n }\n\n if (i === 'version' && typeof options[i] !== 'number') {\n return new Error('Database version must be a number.');\n }\n\n this._config[i] = options[i];\n }\n\n // after all config options are set and\n // the driver option is used, try setting it\n if ('driver' in options && options.driver) {\n return this.setDriver(this._config.driver);\n }\n\n return true;\n } else if (typeof options === 'string') {\n return this._config[options];\n } else {\n return this._config;\n }\n };\n\n // Used to define a custom driver, shared across all instances of\n // localForage.\n\n\n LocalForage.prototype.defineDriver = function defineDriver(driverObject, callback, errorCallback) {\n var promise = new Promise$1(function (resolve, reject) {\n try {\n var driverName = driverObject._driver;\n var complianceError = new Error('Custom driver not compliant; see ' + 'https://mozilla.github.io/localForage/#definedriver');\n\n // A driver name should be defined and not overlap with the\n // library-defined, default drivers.\n if (!driverObject._driver) {\n reject(complianceError);\n return;\n }\n\n var driverMethods = LibraryMethods.concat('_initStorage');\n for (var i = 0, len = driverMethods.length; i < len; i++) {\n var customDriverMethod = driverMethods[i];\n if (!customDriverMethod || !driverObject[customDriverMethod] || typeof driverObject[customDriverMethod] !== 'function') {\n reject(complianceError);\n return;\n }\n }\n\n var setDriverSupport = function setDriverSupport(support) {\n if (DefinedDrivers[driverName]) {\n console.info('Redefining LocalForage driver: ' + driverName);\n }\n DefinedDrivers[driverName] = driverObject;\n DriverSupport[driverName] = support;\n // don't use a then, so that we can define\n // drivers that have simple _support methods\n // in a blocking manner\n resolve();\n };\n\n if ('_support' in driverObject) {\n if (driverObject._support && typeof driverObject._support === 'function') {\n driverObject._support().then(setDriverSupport, reject);\n } else {\n setDriverSupport(!!driverObject._support);\n }\n } else {\n setDriverSupport(true);\n }\n } catch (e) {\n reject(e);\n }\n });\n\n executeTwoCallbacks(promise, callback, errorCallback);\n return promise;\n };\n\n LocalForage.prototype.driver = function driver() {\n return this._driver || null;\n };\n\n LocalForage.prototype.getDriver = function getDriver(driverName, callback, errorCallback) {\n var getDriverPromise = DefinedDrivers[driverName] ? Promise$1.resolve(DefinedDrivers[driverName]) : Promise$1.reject(new Error('Driver not found.'));\n\n executeTwoCallbacks(getDriverPromise, callback, errorCallback);\n return getDriverPromise;\n };\n\n LocalForage.prototype.getSerializer = function getSerializer(callback) {\n var serializerPromise = Promise$1.resolve(localforageSerializer);\n executeTwoCallbacks(serializerPromise, callback);\n return serializerPromise;\n };\n\n LocalForage.prototype.ready = function ready(callback) {\n var self = this;\n\n var promise = self._driverSet.then(function () {\n if (self._ready === null) {\n self._ready = self._initDriver();\n }\n\n return self._ready;\n });\n\n executeTwoCallbacks(promise, callback, callback);\n return promise;\n };\n\n LocalForage.prototype.setDriver = function setDriver(drivers, callback, errorCallback) {\n var self = this;\n\n if (!isArray(drivers)) {\n drivers = [drivers];\n }\n\n var supportedDrivers = this._getSupportedDrivers(drivers);\n\n function setDriverToConfig() {\n self._config.driver = self.driver();\n }\n\n function extendSelfWithDriver(driver) {\n self._extend(driver);\n setDriverToConfig();\n\n self._ready = self._initStorage(self._config);\n return self._ready;\n }\n\n function initDriver(supportedDrivers) {\n return function () {\n var currentDriverIndex = 0;\n\n function driverPromiseLoop() {\n while (currentDriverIndex < supportedDrivers.length) {\n var driverName = supportedDrivers[currentDriverIndex];\n currentDriverIndex++;\n\n self._dbInfo = null;\n self._ready = null;\n\n return self.getDriver(driverName).then(extendSelfWithDriver)[\"catch\"](driverPromiseLoop);\n }\n\n setDriverToConfig();\n var error = new Error('No available storage method found.');\n self._driverSet = Promise$1.reject(error);\n return self._driverSet;\n }\n\n return driverPromiseLoop();\n };\n }\n\n // There might be a driver initialization in progress\n // so wait for it to finish in order to avoid a possible\n // race condition to set _dbInfo\n var oldDriverSetDone = this._driverSet !== null ? this._driverSet[\"catch\"](function () {\n return Promise$1.resolve();\n }) : Promise$1.resolve();\n\n this._driverSet = oldDriverSetDone.then(function () {\n var driverName = supportedDrivers[0];\n self._dbInfo = null;\n self._ready = null;\n\n return self.getDriver(driverName).then(function (driver) {\n self._driver = driver._driver;\n setDriverToConfig();\n self._wrapLibraryMethodsWithReady();\n self._initDriver = initDriver(supportedDrivers);\n });\n })[\"catch\"](function () {\n setDriverToConfig();\n var error = new Error('No available storage method found.');\n self._driverSet = Promise$1.reject(error);\n return self._driverSet;\n });\n\n executeTwoCallbacks(this._driverSet, callback, errorCallback);\n return this._driverSet;\n };\n\n LocalForage.prototype.supports = function supports(driverName) {\n return !!DriverSupport[driverName];\n };\n\n LocalForage.prototype._extend = function _extend(libraryMethodsAndProperties) {\n extend(this, libraryMethodsAndProperties);\n };\n\n LocalForage.prototype._getSupportedDrivers = function _getSupportedDrivers(drivers) {\n var supportedDrivers = [];\n for (var i = 0, len = drivers.length; i < len; i++) {\n var driverName = drivers[i];\n if (this.supports(driverName)) {\n supportedDrivers.push(driverName);\n }\n }\n return supportedDrivers;\n };\n\n LocalForage.prototype._wrapLibraryMethodsWithReady = function _wrapLibraryMethodsWithReady() {\n // Add a stub for each driver API method that delays the call to the\n // corresponding driver method until localForage is ready. These stubs\n // will be replaced by the driver methods as soon as the driver is\n // loaded, so there is no performance impact.\n for (var i = 0, len = LibraryMethods.length; i < len; i++) {\n callWhenReady(this, LibraryMethods[i]);\n }\n };\n\n LocalForage.prototype.createInstance = function createInstance(options) {\n return new LocalForage(options);\n };\n\n return LocalForage;\n}();\n\n// The actual localForage object that we expose as a module or via a\n// global. It's extended by pulling in one of our other libraries.\n\n\nvar localforage_js = new LocalForage();\n\nmodule.exports = localforage_js;\n\n},{\"3\":3}]},{},[4])(4)\n});\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/localforage/dist/localforage.js\n// module id = 3\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar weight_decoder_eightbit_1 = require(\"./weight_decoder_eightbit\");\nvar weight_decoder_raw_1 = require(\"./weight_decoder_raw\");\n/**\n * @protected\n */\nfunction getWeightDecoder(name) {\n switch (name) {\n case 'raw':\n return new weight_decoder_raw_1.default();\n case 'eightbit':\n return new weight_decoder_eightbit_1.default();\n default:\n throw new Error('Unknown weight encoding');\n }\n}\nexports.default = getWeightDecoder;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/get_weight_decoder.js\n// module id = 4\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * PlaceholderContext manages the placeholders\n * @protected\n */\nvar PlaceholderContext = /** @class */ (function () {\n function PlaceholderContext(values) {\n this.values = {};\n if (values) {\n this.update(values);\n }\n }\n Object.defineProperty(PlaceholderContext.prototype, \"isResolved\", {\n get: function () {\n return Object.values(this.values).every(function (value) { return typeof value == 'number'; });\n },\n enumerable: true,\n configurable: true\n });\n PlaceholderContext.prototype.update = function (values) {\n this.values = Object.assign(this.values, values);\n };\n PlaceholderContext.prototype.resolve = function (placeholder) {\n var _this = this;\n // Literal value => return itself.\n if (typeof placeholder !== 'object')\n return placeholder;\n // Placeholder object ( { eval: string } ) => resolve\n if (Object.keys(placeholder).length == 1 && 'eval' in placeholder) {\n if (!this.isResolved)\n throw Error(\"Not all placeholders are resolved: \" + this);\n return eval('(function(placeholders){return ' + placeholder.eval + ';})')(this.values);\n }\n // Array => deep copy\n if (placeholder instanceof Array) {\n return placeholder.map(function (value) { return _this.resolve(value); });\n }\n // Object => deep copy\n return Object.entries(placeholder)\n .reduce(function (result, _a) {\n var key = _a[0], value = _a[1];\n result[key] = _this.resolve(value);\n return result;\n }, {});\n };\n PlaceholderContext.prototype.toString = function () {\n return JSON.stringify(this.values);\n };\n return PlaceholderContext;\n}());\nexports.default = PlaceholderContext;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/placeholder.js\n// module id = 5\n// module chunks = 0","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar symbolic_typed_array_1 = require(\"./symbolic_typed_array\");\n/**\n * Typed array used for input and output variables of [[webdnn.DescriptorRunner| `DescriptorRunner`]].\n * You can use `SymbolicFloat32Array` almost as same as `Float32Array`.\n *\n * To convert `SymbolicFloat32Array` into actual `Float32Array`, use [[webdnn.SymbolicFloat32Array.toActual| `toActual()`]]\n *\n * ```js\n *\n * let result = runner.outputs[0]; //runner.outputs is array of SymbolicFloat32Array\n *\n * // SymbolicFloat32Array does NOT support index access\n * console.log(result[0]);\n * >>> undefined\n *\n * // By conversion, you can access each element by index\n * console.log(result.toActual()[0]);\n * >>> 1.00 // Actual result\n * ```\n */\nvar SymbolicFloat32Array = /** @class */ (function (_super) {\n __extends(SymbolicFloat32Array, _super);\n function SymbolicFloat32Array() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n /**\n * The size in bytes of each element in the array.\n */\n _this.BYTES_PER_ELEMENT = 4;\n return _this;\n }\n /**\n * Convert SymbolicTypedArray instance into actual TypedArray instance.\n *\n * @returns actual typed array\n */\n SymbolicFloat32Array.prototype.toActual = function () {\n if (!this.buffer) {\n throw new Error('Internal buffer for this variable is not set. DescriptorRunner.setPlaceholderValue() have to be called before calling this function.');\n }\n return new Float32Array(this.buffer, this.byteOffset, this.length);\n };\n /**\n * Determines whether all the members of an array satisfy the specified test.\n * @param callbackfn A function that accepts up to three arguments. The every method calls\n * the callbackfn function for each element in array1 until the callbackfn returns false,\n * or until the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n SymbolicFloat32Array.prototype.every = function (callbackfn, thisArg) {\n return this.toActual().every(callbackfn, thisArg);\n };\n /**\n * Returns the elements of an array that meet the condition specified in a callback function.\n * @param callbackfn A function that accepts up to three arguments. The filter method calls\n * the callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n SymbolicFloat32Array.prototype.filter = function (callbackfn, thisArg) {\n return this.toActual().filter(callbackfn, thisArg);\n };\n /**\n * Returns the value of the first element in the array where predicate is true, and undefined\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found, find\n * immediately returns that element value. Otherwise, find returns undefined.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n SymbolicFloat32Array.prototype.find = function (predicate, thisArg) {\n return this.toActual().find(predicate, thisArg);\n };\n /**\n * Returns the index of the first element in the array where predicate is true, and -1\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found,\n * findIndex immediately returns that element index. Otherwise, findIndex returns -1.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n SymbolicFloat32Array.prototype.findIndex = function (predicate, thisArg) {\n return this.toActual().findIndex(predicate, thisArg);\n };\n /**\n * Performs the specified action for each element in an array.\n * @param callbackfn A function that accepts up to three arguments. forEach calls the\n * callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n SymbolicFloat32Array.prototype.forEach = function (callbackfn, thisArg) {\n return this.toActual().forEach(callbackfn, thisArg);\n };\n /**\n * Calls a defined callback function on each element of an array, and returns an array that\n * contains the results.\n * @param callbackfn A function that accepts up to three arguments. The map method calls the\n * callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n SymbolicFloat32Array.prototype.map = function (callbackfn, thisArg) {\n return this.toActual().map(callbackfn, thisArg);\n };\n SymbolicFloat32Array.prototype.reduce = function (callbackfn, initialValue) {\n return this.toActual().reduce(callbackfn, initialValue);\n };\n SymbolicFloat32Array.prototype.reduceRight = function (callbackfn, initialValue) {\n return this.toActual().reduceRight(callbackfn, initialValue);\n };\n /**\n * Reverses the elements in an Array.\n */\n SymbolicFloat32Array.prototype.reverse = function () {\n return this.toActual().reverse();\n };\n /**\n * Returns a section of an array.\n * @param start The beginning of the specified portion of the array.\n * @param end The end of the specified portion of the array.\n */\n SymbolicFloat32Array.prototype.slice = function (start, end) {\n return this.toActual().slice(start, end);\n };\n /**\n * Determines whether the specified callback function returns true for any element of an array.\n * @param callbackfn A function that accepts up to three arguments. The some method calls the\n * callbackfn function for each element in array1 until the callbackfn returns true, or until\n * the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n SymbolicFloat32Array.prototype.some = function (callbackfn, thisArg) {\n return this.toActual().some(callbackfn, thisArg);\n };\n /**\n * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements\n * at begin, inclusive, up to end, exclusive.\n * @param begin The index of the beginning of the array.\n * @param end The index of the end of the array.\n */\n SymbolicFloat32Array.prototype.subarray = function (begin, end) {\n return this.toActual().subarray(begin, end);\n };\n /** @protected */\n SymbolicFloat32Array.prototype.includes = function (searchElement, fromIndex) {\n return this.toActual().includes(searchElement, fromIndex);\n };\n /**\n * The size in bytes of each element in SymbolicFloat32Array.\n */\n SymbolicFloat32Array.BYTES_PER_ELEMENT = 4;\n return SymbolicFloat32Array;\n}(symbolic_typed_array_1.SymbolicTypedArray));\nexports.default = SymbolicFloat32Array;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/symbolic_typed_array/symbolic_float32array.js\n// module id = 6\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * `DescriptorRunner` provides interface to execute DNN model and access input and output buffers.\n */\nvar DescriptorRunner = /** @class */ (function () {\n function DescriptorRunner() {\n /**\n * For Developer:\n *\n * `DescriptorRunner` executes computation based on `GraphDescriptor`.\n *\n * Typically, DescriptorRunner takes 3 steps to execute DNN model.\n *\n * 1. Initialize static configurations\n *\n * Initialize things independent from runtime configuration.\n *\n * - `init()`\n * - `load()`\n *\n * 2. Initialize dynamic configurations\n *\n * Initialize things depend on runtime configuration such as batch size, input image size, etc.\n *\n * - `setPlaceholderValue()`\n * - `getInputViews()`\n * - `getOutputViews()`\n *\n * 3. Execute the model\n *\n * - `run()`\n *\n * You need to do step 1 and 2 only once. We recommend to call `WebDNN.prepareAll()` instead\n * to call `GraphDescriptor#load()` directly. In that method, all procedures in step 1 and 2 are performed.\n */\n /**\n * The descriptor\n */\n this.descriptor = null;\n }\n /**\n * Return `true` if this backend is available in this environment.\n * @returns {boolean}\n */\n DescriptorRunner.checkAvailability = function () {\n return false;\n };\n return DescriptorRunner;\n}());\nexports.DescriptorRunner = DescriptorRunner;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner.js\n// module id = 7\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/messages.js\n// module id = 8\n// module chunks = 0","'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It isn't worth it to make additional optimizations as in original.\n// Small size is preferable.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n\nmodule.exports = adler32;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/adler32.js\n// module id = 9\n// module chunks = 0","'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n\nmodule.exports = crc32;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/crc32.js\n// module id = 10\n// module chunks = 0","// String encode/decode helpers\n'use strict';\n\n\nvar utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safari\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new utils.Buf8(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nexports.string2buf = function (str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new utils.Buf8(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n};\n\n// Helper (used in 2 places)\nfunction buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert byte array to binary string\nexports.buf2binstring = function (buf) {\n return buf2binstring(buf, buf.length);\n};\n\n\n// Convert binary string (typed, when possible)\nexports.binstring2buf = function (str) {\n var buf = new utils.Buf8(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n};\n\n\n// convert array to string\nexports.buf2string = function (buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n};\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nexports.utf8border = function (buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/utils/strings.js\n// module id = 11\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\nmodule.exports = ZStream;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/zstream.js\n// module id = 12\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n //Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/constants.js\n// module id = 13\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/// \nvar webdnn_1 = require(\"./webdnn\");\n/**\n * @protected\n */\nfunction isWebGL2(gl) {\n return gl.constructor.name === 'WebGL2RenderingContext';\n}\nexports.isWebGL2 = isWebGL2;\n/**\n * @private\n */\nvar instance;\n/**\n * @protected\n */\nvar WebGLHandler = /** @class */ (function () {\n /**\n * WebGLHandler is singleton class and instantiate directly is forbidden (constructor is hidden).\n *\n * Since the number of GPU contexts may be limited, the handler is used as a singleton\n * and only one context is shared among multiple runners.\n */\n function WebGLHandler() {\n this.gl = checkNull(WebGLHandler.initializeContext());\n }\n WebGLHandler.getInstance = function () {\n if (!instance)\n instance = new WebGLHandler();\n return instance;\n };\n WebGLHandler.prototype.createTexture = function (textureWidth, textureHeight, internalFormat, format) {\n var gl = this.gl;\n var texture = checkNull(gl.createTexture());\n gl.activeTexture(gl.TEXTURE0 + 9); // TODO: texture unit 9 is always available?\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, textureWidth, textureHeight, 0, format, gl.FLOAT, null);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n gl.bindTexture(gl.TEXTURE_2D, null);\n return texture;\n };\n WebGLHandler.prototype.createVertexShader = function (source) {\n return this.createShader(this.gl.VERTEX_SHADER, source);\n };\n WebGLHandler.prototype.createFragmentShader = function (source) {\n return this.createShader(this.gl.FRAGMENT_SHADER, source);\n };\n WebGLHandler.prototype.createShader = function (type, source) {\n var shader = checkNull(this.gl.createShader(type));\n this.gl.shaderSource(shader, source);\n this.gl.compileShader(shader);\n if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {\n console.error(this.gl.getShaderInfoLog(shader));\n throw Error(\"Shader Compile failed: \" + this.gl.getShaderInfoLog(shader));\n }\n return shader;\n };\n WebGLHandler.prototype.createProgram = function (vertexShader, fragmentShader) {\n var program = checkNull(this.gl.createProgram());\n this.gl.attachShader(program, fragmentShader);\n this.gl.attachShader(program, vertexShader);\n this.gl.linkProgram(program);\n if (!this.gl.getProgramParameter(program, this.gl.LINK_STATUS)) {\n console.error(this.gl.getProgramInfoLog(program));\n throw Error('ShaderProgram Initialization failed.');\n }\n return program;\n };\n WebGLHandler.prototype.createArrayBuffer = function (vertexArray) {\n var buffer = checkNull(this.gl.createBuffer());\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, vertexArray, this.gl.STATIC_DRAW);\n return buffer;\n };\n WebGLHandler.prototype.createFrameBuffer = function () {\n return checkNull(this.gl.createFramebuffer());\n };\n WebGLHandler.prototype.bindArrayBuffer = function (buffer) {\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, buffer);\n };\n WebGLHandler.prototype.bindFrameBuffer = function (frameBuffer, width, height) {\n this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, frameBuffer);\n this.gl.viewport(0, 0, width, height);\n this.gl.scissor(0, 0, width, height);\n };\n WebGLHandler.prototype.useProgram = function (program) {\n this.gl.useProgram(program);\n };\n WebGLHandler.prototype.deleteTexture = function (texture) {\n this.gl.deleteTexture(texture);\n };\n WebGLHandler.initializeWebGL2Context = function (canvas) {\n if (canvas === void 0) { canvas = document.createElement('canvas'); }\n var gl;\n gl = (canvas.getContext('webgl2'));\n if (!gl)\n return null;\n if (!gl.getExtension('EXT_color_buffer_float'))\n return null;\n if (webdnn_1.getConfiguration('DEBUG', false) && !gl.getExtension('WEBGL_debug_renderer_info'))\n return null;\n return gl;\n };\n WebGLHandler.initializeWebGL1Context = function (canvas) {\n if (canvas === void 0) { canvas = document.createElement('canvas'); }\n var gl = (canvas.getContext('webgl') || canvas.getContext('experimental-webgl'));\n if (!gl)\n return null;\n if (!gl.getExtension('OES_texture_float'))\n return null;\n if (WebGLHandler.IS_SAFARI) {\n //TODO(Kiikurage)\n // Safari supports WebGL with OES_TEXTURE_FLOAT extension. However,\n // currently when WebGLRenderingContext#readPixels is called, an error is thrown.\n return null;\n }\n if (webdnn_1.getConfiguration('DEBUG', false) && !gl.getExtension('WEBGL_debug_renderer_info'))\n return null;\n return gl;\n };\n WebGLHandler.initializeContext = function () {\n var canvas = document.createElement('canvas');\n var gl;\n gl = WebGLHandler.initializeWebGL2Context(canvas);\n if (gl) {\n if (webdnn_1.getConfiguration('DEBUG', false))\n console.info('WebGL2 is enabled');\n }\n else {\n gl = WebGLHandler.initializeWebGL1Context(canvas);\n if (gl) {\n if (webdnn_1.getConfiguration('DEBUG', false))\n console.info('WebGL2 is disabled');\n }\n else {\n return null;\n }\n }\n gl.disable(gl.DEPTH_TEST);\n gl.disable(gl.STENCIL_TEST);\n gl.disable(gl.BLEND);\n gl.disable(gl.DITHER);\n gl.disable(gl.POLYGON_OFFSET_FILL);\n gl.disable(gl.SAMPLE_COVERAGE);\n gl.enable(gl.SCISSOR_TEST);\n gl.enable(gl.CULL_FACE);\n gl.cullFace(gl.BACK);\n return gl;\n };\n /**\n * Check whether WebGL is supported or not\n * @protected\n */\n WebGLHandler.checkAvailability = function () {\n if (availability === null) {\n var gl = WebGLHandler.initializeContext();\n if (!gl) {\n availability = false;\n }\n else if (webdnn_1.getConfiguration('MAX_TEXTURE_SIZE', gl.getParameter(gl.MAX_TEXTURE_SIZE)) < 4096) {\n availability = false;\n }\n else {\n availability = true;\n }\n }\n return availability;\n };\n WebGLHandler.prototype.waitForComplete = function () {\n return __awaiter(this, void 0, void 0, function () {\n var gl, sync, status_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n gl = this.gl;\n if (!isWebGL2(gl)) return [3 /*break*/, 4];\n sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);\n status_1 = gl.clientWaitSync(sync, 0, 0);\n _a.label = 1;\n case 1:\n if (!(status_1 !== gl.CONDITION_SATISFIED && status_1 !== gl.ALREADY_SIGNALED)) return [3 /*break*/, 3];\n return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 1); })];\n case 2:\n _a.sent();\n status_1 = gl.clientWaitSync(sync, 0, 0);\n return [3 /*break*/, 1];\n case 3:\n gl.deleteSync(sync);\n return [3 /*break*/, 5];\n case 4:\n gl.finish();\n _a.label = 5;\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n Object.defineProperty(WebGLHandler.prototype, \"MAX_TEXTURE_SIZE\", {\n get: function () {\n var MAX_TEXTURE_SIZE = webdnn_1.getConfiguration('MAX_TEXTURE_SIZE', this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE));\n // FIXME: In most case, MAX_TEXTURE_SIZE=4096 is the fastest (Why?).\n if (MAX_TEXTURE_SIZE >= 16384) {\n return 4096;\n }\n else if (MAX_TEXTURE_SIZE >= 8192) {\n return 4096;\n }\n else if (MAX_TEXTURE_SIZE >= 4096) {\n return 4096;\n }\n else {\n throw new Error(\"MAX_TEXTURE_SIZE is too small: \" + MAX_TEXTURE_SIZE);\n }\n },\n enumerable: true,\n configurable: true\n });\n WebGLHandler.IS_SAFARI = navigator.userAgent.toLowerCase().indexOf('safari') !== -1 && navigator.userAgent.toLowerCase().indexOf('chrome') === -1;\n return WebGLHandler;\n}());\nexports.default = WebGLHandler;\n/**\n * @private\n */\nvar availability = null;\n/**\n * @private\n */\nfunction checkNull(obj) {\n if (obj === null)\n throw Error('Null is detected');\n return obj;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webgl_handler.js\n// module id = 14\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * Abstract buffer interface. Read/write transactions are regarded as asynchronous operation.\n *\n * @protected\n */\nvar Buffer = /** @class */ (function () {\n function Buffer(byteLength, backend) {\n this.byteLength = byteLength;\n this.backend = backend;\n }\n return Buffer;\n}());\nexports.Buffer = Buffer;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer.js\n// module id = 15\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar webgpu_handler_1 = require(\"../webgpu_handler\");\nvar buffer_1 = require(\"./buffer\");\n/**\n * @protected\n */\nvar BufferWebGPU = /** @class */ (function (_super) {\n __extends(BufferWebGPU, _super);\n function BufferWebGPU(byteLength) {\n var _this = _super.call(this, byteLength, 'webgpu') || this;\n if (byteLength == 0) {\n byteLength = 4; //0 length buffer causes error\n }\n _this.handler = webgpu_handler_1.default.getInstance();\n _this.buffer = _this.handler.createBuffer(new Uint8Array(byteLength));\n _this.bufferView = new Uint8Array(_this.buffer.contents);\n return _this;\n }\n // async: there may be platforms synchronization is needed before writing\n BufferWebGPU.prototype.write = function (src, dst_offset) {\n return __awaiter(this, void 0, void 0, function () {\n var viewSameType;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.handler.sync()];\n case 1:\n _a.sent();\n viewSameType = new src.constructor(this.bufferView.buffer);\n viewSameType.set(src, dst_offset);\n return [2 /*return*/];\n }\n });\n });\n };\n BufferWebGPU.prototype.read = function (dst, src_offset, length) {\n if (src_offset === void 0) { src_offset = 0; }\n return __awaiter(this, void 0, void 0, function () {\n var dstConstructor, viewSameType;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!dst)\n throw new Error('dst cannot be null');\n return [4 /*yield*/, this.handler.sync()];\n case 1:\n _a.sent();\n if (this.byteLength === 0)\n return [2 /*return*/];\n dstConstructor = dst.constructor;\n viewSameType = new dstConstructor(this.bufferView.buffer, this.bufferView.byteOffset + src_offset * dstConstructor.BYTES_PER_ELEMENT, length);\n dst.set(viewSameType);\n return [2 /*return*/];\n }\n });\n });\n };\n BufferWebGPU.prototype.getWriteView = function (offset, length, type) {\n return new type(this.bufferView.buffer, this.bufferView.byteOffset + offset * type.BYTES_PER_ELEMENT, length);\n };\n BufferWebGPU.prototype.getReadView = function (offset, length, type) {\n return new type(this.bufferView.buffer, this.bufferView.byteOffset + offset * type.BYTES_PER_ELEMENT, length);\n };\n BufferWebGPU.prototype.syncWriteViews = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/];\n });\n });\n };\n BufferWebGPU.prototype.syncReadViews = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: \n // if the user awaits promise from final kernel execution, this function call is not needed.\n return [4 /*yield*/, this.handler.sync()];\n case 1:\n // if the user awaits promise from final kernel execution, this function call is not needed.\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n return BufferWebGPU;\n}(buffer_1.Buffer));\nexports.default = BufferWebGPU;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer_webgpu.js\n// module id = 16\n// module chunks = 0","\"use strict\";\n///\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar buffer_webgpu_1 = require(\"./buffer/buffer_webgpu\");\n/**\n * @private\n */\nvar instance;\n/**\n * @protected\n */\nvar WebGPUHandler = /** @class */ (function () {\n /**\n * WebGPUHandler is singleton class and instantiate directly is forbidden (constructor is hidden).\n *\n * Since the number of GPU contexts may be limited, the handler is used as a singleton\n * and only one context is shared among multiple runners.\n */\n function WebGPUHandler() {\n this.pipelineStates = new Map();\n if (!exports.IS_WEBGPU_SUPPORTED)\n throw new Error('This browser does not support WebGPU');\n var context;\n try {\n context = document.createElement('canvas').getContext('webgpu');\n }\n catch (err) {\n throw new Error(\"During initializing WebGPURenderingContext, unexpected error is occurred: \" + err.message);\n }\n if (!context)\n throw new Error('WebGPURenderingContext initialization failed');\n this.context = context;\n this.commandQueue = context.createCommandQueue();\n this.loadKernel('kernel void sync(){}', 'basic');\n }\n WebGPUHandler.getInstance = function () {\n if (!instance)\n instance = new WebGPUHandler();\n return instance;\n };\n WebGPUHandler.prototype.createBuffer = function (arrayBuffer) {\n return this.context.createBuffer(arrayBuffer);\n };\n WebGPUHandler.prototype.loadKernel = function (librarySource, namespace) {\n if (namespace === void 0) { namespace = ''; }\n var library = this.context.createLibrary(librarySource);\n for (var _i = 0, _a = library.functionNames; _i < _a.length; _i++) {\n var name_1 = _a[_i];\n var kernelFunction = library.functionWithName(name_1);\n var pipelineStates = this.context.createComputePipelineState(kernelFunction);\n this.pipelineStates.set(namespace + '.' + name_1, pipelineStates);\n }\n };\n WebGPUHandler.prototype.createCommandBuffer = function () {\n return this.commandQueue.createCommandBuffer();\n };\n WebGPUHandler.prototype.getPipelineStateByName = function (name) {\n var state = this.pipelineStates.get(name);\n if (!state) {\n throw TypeError(\"Kernel function \\\"\" + name + \"\\\" is not loaded.\");\n }\n return state;\n };\n WebGPUHandler.prototype.executeSinglePipelineState = function (name, threadgroupsPerGrid, threadsPerThreadgroup, buffers, getCompletedPromise) {\n var commandBuffer = this.commandBuffer || (this.commandBuffer = this.createCommandBuffer());\n var commandEncoder = commandBuffer.createComputeCommandEncoder();\n commandEncoder.setComputePipelineState(this.getPipelineStateByName(name));\n for (var i = 0; i < buffers.length; i++) {\n var buffer = buffers[i];\n var wgbuf = void 0;\n if (buffer instanceof buffer_webgpu_1.default) {\n wgbuf = buffer.buffer;\n }\n else {\n // cannot perform (buffer instanceof WebGPUBuffer) currently\n wgbuf = buffer;\n }\n commandEncoder.setBuffer(wgbuf, 0, i);\n }\n commandEncoder.dispatch(threadgroupsPerGrid, threadsPerThreadgroup);\n commandEncoder.endEncoding();\n var promise = null;\n if (getCompletedPromise) {\n promise = commandBuffer.completed;\n }\n this.commandBuffer = null;\n commandBuffer.commit();\n return promise;\n };\n WebGPUHandler.prototype.sync = function () {\n return __awaiter(this, void 0, void 0, function () {\n var commandBuffer, commandEncoder, promise;\n return __generator(this, function (_a) {\n commandBuffer = this.createCommandBuffer();\n commandEncoder = commandBuffer.createComputeCommandEncoder();\n commandEncoder.setComputePipelineState(this.getPipelineStateByName('basic.sync'));\n commandEncoder.dispatch({\n width: 1,\n height: 1,\n depth: 1\n }, {\n width: 1,\n height: 1,\n depth: 1\n });\n commandEncoder.endEncoding();\n promise = commandBuffer.completed;\n commandBuffer.commit();\n return [2 /*return*/, promise];\n });\n });\n };\n return WebGPUHandler;\n}());\nexports.default = WebGPUHandler;\n/**\n * Flag whether WebGPU is supported or not\n * @protected\n */\nexports.IS_WEBGPU_SUPPORTED = 'WebGPURenderingContext' in window && 'WebGPUComputeCommandEncoder' in window;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webgpu_handler.js\n// module id = 17\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/image\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/** Don't Remove This comment block */\n/**\n * The data order\n */\nvar Order;\n(function (Order) {\n /** `[Channel, Height, Width]` format */\n Order[Order[\"CHW\"] = 0] = \"CHW\";\n /** `[Height, Width, Channel]` format */\n Order[Order[\"HWC\"] = 1] = \"HWC\";\n})(Order = exports.Order || (exports.Order = {}));\n/**\n * The color format\n */\nvar Color;\n(function (Color) {\n /** RGB format */\n Color[Color[\"RGB\"] = 0] = \"RGB\";\n /** BGR format */\n Color[Color[\"BGR\"] = 1] = \"BGR\";\n /** grey scale */\n Color[Color[\"GREY\"] = 2] = \"GREY\";\n /** RGBA format */\n Color[Color[\"RGBA\"] = 3] = \"RGBA\";\n /** BGRA format */\n Color[Color[\"BGRA\"] = 4] = \"BGRA\";\n})(Color = exports.Color || (exports.Color = {}));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/enums.js\n// module id = 18\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * Get canvas rendering context and check whether it is nonnull value.\n *\n * @param {CanvasRenderingContext2D} canvas\n * @protected\n */\nfunction getContext2D(canvas) {\n var context = canvas.getContext('2d');\n if (!context)\n throw Error('CanvasRenderingContext2D initialization failed');\n return context;\n}\nexports.getContext2D = getContext2D;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/canvas.js\n// module id = 19\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/image\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/** Don't Remove This comment block */\n/**\n * Load image of specified url\n *\n * @param {string} url the image url\n * @returns {Promise} image element\n */\nfunction loadImageByUrl(url) {\n return __awaiter(this, void 0, void 0, function () {\n var image;\n return __generator(this, function (_a) {\n image = document.createElement('img');\n return [2 /*return*/, new Promise(function (resolve, reject) {\n image.onload = resolve;\n image.onerror = reject;\n image.src = url;\n })\n .then(function () { return image; })];\n });\n });\n}\nexports.loadImageByUrl = loadImageByUrl;\n/* istanbul ignore next */\n/**\n * Load image file selected in `` element.\n *\n * @param {HTMLInputElement} input the `` element\n * @returns {Promise} image element\n */\nfunction loadImageFromFileInput(input) {\n return __awaiter(this, void 0, void 0, function () {\n var files, url;\n return __generator(this, function (_a) {\n files = input.files;\n if (!files || files.length == 0)\n throw new Error('No file is selected');\n url = URL.createObjectURL(files[0]);\n return [2 /*return*/, loadImageByUrl(url)];\n });\n });\n}\nexports.loadImageFromFileInput = loadImageFromFileInput;\n/* istanbul ignore next */\n/**\n * Load image selected in file picker dialog\n *\n * Currently, web specification not supported the case if the dialog is canceled and no file is selected. In this case,\n * the returned promise will never be resolved.\n *\n * @returns {Promise} image element\n * @protected\n */\nfunction loadImageByDialog() {\n return __awaiter(this, void 0, void 0, function () {\n var input;\n return __generator(this, function (_a) {\n input = document.createElement('input');\n input.type = 'file';\n input.accept = 'image/*';\n return [2 /*return*/, new Promise(function (resolve) {\n input.onchange = function () { return resolve(loadImageFromFileInput(input)); };\n input.click();\n })];\n });\n });\n}\nexports.loadImageByDialog = loadImageByDialog;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_source.js\n// module id = 20\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar localforage = require(\"localforage\");\nvar get_weight_decoder_1 = require(\"../decoder/get_weight_decoder\");\nvar fetch_1 = require(\"../fetch\");\nvar placeholder_1 = require(\"../placeholder\");\nvar symbolic_float32array_1 = require(\"../symbolic_typed_array/symbolic_float32array\");\nvar descriptor_runner_1 = require(\"./descriptor_runner\");\n/**\n * @private\n */\nfunction wait(duration) {\n if (duration === void 0) { duration = 10; }\n // let console.log to be displayed, and prevent freeze\n return new Promise(function (resolve) { return setTimeout(resolve, duration); });\n}\n/**\n * @protected\n */\nvar DescriptorRunnerFallback = /** @class */ (function (_super) {\n __extends(DescriptorRunnerFallback, _super);\n function DescriptorRunnerFallback() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.backendName = 'fallback';\n return _this;\n }\n DescriptorRunnerFallback.checkAvailability = function () {\n return true;\n };\n DescriptorRunnerFallback.prototype.init = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/];\n });\n });\n };\n DescriptorRunnerFallback.prototype.setDescriptorAndParameters = function (descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.setDescriptor(descriptor);\n return [4 /*yield*/, this.compile()];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.initializeStaticBuffer(parameters)];\n case 2:\n _a.sent();\n if (!(this.placeholderContext && this.placeholderContext.isResolved)) return [3 /*break*/, 4];\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 3:\n _a.sent();\n _a.label = 4;\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.fetchDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.directory = directory;\n return [4 /*yield*/, fetch_1.default(directory + \"/graph_\" + this.backendName + \".json\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, res.json()];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.fetchParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fetch_1.default(directory + \"/weight_\" + this.backendName + \".bin\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, fetch_1.readArrayBufferProgressively(res, progressCallback)];\n }\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerFallback.prototype.restoreCachedDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, localforage.getItem(directory + \"_\" + this.backendName + \"_descriptor\").catch(function () { return null; })];\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerFallback.prototype.restoreCachedParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var parameter;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, localforage.getItem(directory + \"_\" + this.backendName + \"_parameters\").catch(function () { return null; })];\n case 1:\n parameter = _a.sent();\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return [2 /*return*/, parameter];\n }\n });\n });\n };\n /**\n * save cache\n */\n DescriptorRunnerFallback.prototype.saveCache = function (directory, descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, Promise.all([\n localforage.setItem(directory + \"_\" + this.backendName + \"_descriptor\", descriptor),\n localforage.setItem(directory + \"_\" + this.backendName + \"_parameters\", parameters)\n ])];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n ;\n DescriptorRunnerFallback.prototype.setDescriptor = function (descriptor) {\n this.descriptor = descriptor;\n // reset\n this.placeholderContext = new placeholder_1.default();\n this.placeholderContext.update(descriptor.placeholders);\n this.kernelObj = null;\n this.variableMap = null;\n this.staticBuffer = null;\n this.dynamicBuffer = null;\n };\n DescriptorRunnerFallback.prototype.compile = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n return [4 /*yield*/, new Promise(function (resolve) {\n var script = document.createElement(\"script\");\n script.type = \"text/javascript\";\n if (script.readyState) {\n script.onreadystatechange = function () {\n if (script.readyState == \"loaded\" || script.readyState == \"complete\") {\n script.onreadystatechange = null;\n resolve();\n }\n };\n }\n else {\n script.onload = resolve;\n }\n script.src = fetch_1.transformUrl(_this.directory + \"/kernels_fallback.js\");\n document.getElementsByTagName(\"head\")[0].appendChild(script);\n })];\n case 1:\n _a.sent();\n this.kernelObj = window.dnn_fallback_kernel; // \"window.dnn_fallback_kernel\" is defined in \"kernels_fallback.js\"\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.initializeStaticBuffer = function (weightRawArray) {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, staticBuffer, variableMap, decoder, _a, _b;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n descriptor = this.descriptor;\n staticBuffer = new Float32Array(descriptor.memory_layout.static.size);\n this.staticBuffer = staticBuffer;\n variableMap = this.variableMap || new Map();\n this.variableMap = variableMap;\n Object.entries(descriptor.memory_layout.static.allocations)\n .forEach(function (_a) {\n var name = _a[0], allocation = _a[1];\n variableMap.set(name, new Float32Array(staticBuffer.buffer, allocation.offset * Float32Array.BYTES_PER_ELEMENT, allocation.size));\n });\n decoder = get_weight_decoder_1.default(this.descriptor.weight_encoding);\n _b = (_a = staticBuffer).set;\n return [4 /*yield*/, decoder.decode(new Uint8Array(weightRawArray))];\n case 1:\n _b.apply(_a, [_c.sent()]);\n return [4 /*yield*/, this.getInputViews()];\n case 2:\n (_c.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = staticBuffer.buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 3:\n (_c.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = staticBuffer.buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.initializeDynamicBuffer = function () {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, placeholderContext, dynamicBuffer, variableMap;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n descriptor = this.descriptor;\n placeholderContext = this.placeholderContext;\n dynamicBuffer = new Float32Array(placeholderContext.resolve(descriptor.memory_layout.dynamic.size));\n this.dynamicBuffer = dynamicBuffer;\n variableMap = this.variableMap || new Map();\n this.variableMap = variableMap;\n Object.entries(descriptor.memory_layout.dynamic.allocations)\n .forEach(function (_a) {\n var name = _a[0], allocation = _a[1];\n variableMap.set(name, new Float32Array(dynamicBuffer.buffer, placeholderContext.resolve(allocation.offset) * Float32Array.BYTES_PER_ELEMENT, placeholderContext.resolve(allocation.size)));\n });\n return [4 /*yield*/, this.getInputViews()];\n case 1:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = dynamicBuffer.buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 2:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = dynamicBuffer.buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.setPlaceholderValue = function (values) {\n return __awaiter(this, void 0, void 0, function () {\n var placeholderContext;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.placeholderContext)\n throw new Error('placeholderContext is not initialized');\n placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return [2 /*return*/];\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.run = function () {\n return __awaiter(this, void 0, void 0, function () {\n var variableMap, placeholderContext, executionInfos, startDate, lastDate, i, currentDate, executionInfo, inputs, outputs;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('placeholderContext is not initialized');\n if (!this.variableMap)\n throw new Error('Variable map is not initialized');\n if (!this.staticBuffer)\n throw new Error('StaticBuffer map is not initialized');\n if (!this.dynamicBuffer)\n throw new Error('DynamicBuffer map is not initialized');\n variableMap = this.variableMap;\n placeholderContext = this.placeholderContext;\n executionInfos = this.descriptor.exec_infos\n .map(function (executionInfo) { return placeholderContext.resolve(executionInfo); });\n startDate = Date.now();\n lastDate = Date.now();\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < executionInfos.length)) return [3 /*break*/, 5];\n currentDate = Date.now();\n if (!(currentDate - lastDate >= 1000)) return [3 /*break*/, 3];\n console.log(\"Processed \" + i + \"/\" + executionInfos.length + \" kernels in \" + (currentDate - startDate) + \" ms\");\n lastDate = currentDate;\n return [4 /*yield*/, wait()];\n case 2:\n _a.sent();\n _a.label = 3;\n case 3:\n executionInfo = executionInfos[i];\n inputs = executionInfo.inputs.map(function (name) { return variableMap.get(name); });\n outputs = executionInfo.outputs.map(function (name) { return variableMap.get(name); });\n this.kernelObj[executionInfo.entry_func_name](inputs, outputs, executionInfo.call_option);\n _a.label = 4;\n case 4:\n i++;\n return [3 /*break*/, 1];\n case 5:\n console.log(\"Processed \" + executionInfos.length + \"/\" + executionInfos.length + \" kernels in \" + (Date.now() - startDate) + \" ms\");\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerFallback.prototype.getInputViews = function () {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, allocation.offset * symbolic_float32array_1.default.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n };\n DescriptorRunnerFallback.prototype.getOutputViews = function () {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, allocation.offset * symbolic_float32array_1.default.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n };\n return DescriptorRunnerFallback;\n}(descriptor_runner_1.DescriptorRunner));\nexports.default = DescriptorRunnerFallback;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_fallback.js\n// module id = 21\n// module chunks = 0","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 22\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar pako = require(\"pako\");\n/**\n * @protected\n */\nvar WeightDecoderEightbit = /** @class */ (function () {\n function WeightDecoderEightbit() {\n }\n WeightDecoderEightbit.prototype.decode = function (data) {\n return __awaiter(this, void 0, void 0, function () {\n var decoded_arrays, total_dst_length, data_view, src_offset, dst_offset_1, body_size, scale, scaled_table, i, src_data_view, decompressed, dec_size, decoded_array, s, dst, dst_offset, i;\n return __generator(this, function (_a) {\n decoded_arrays = [];\n total_dst_length = 0;\n data_view = new DataView(data.buffer, data.byteOffset);\n src_offset = 0;\n while (src_offset < data.length) {\n dst_offset_1 = data_view.getInt32(src_offset, true);\n src_offset += 4;\n body_size = data_view.getInt32(src_offset, true);\n src_offset += 4;\n scale = data_view.getFloat32(src_offset, true);\n src_offset += 8;\n scaled_table = new Float32Array(256);\n for (i = 0; i < 256; i++) {\n scaled_table[i] = WeightDecoderEightbit.decode_table[i & 0x7F] * scale * (i < 128 ? 1.0 : -1.0);\n }\n src_data_view = new Uint8Array(data.buffer, data.byteOffset + src_offset, body_size);\n decompressed = pako.inflate(src_data_view);\n dec_size = decompressed.length;\n decoded_array = new Float32Array(dec_size);\n for (s = 0; s < dec_size; s++) {\n decoded_array[s] = scaled_table[decompressed[s]];\n }\n decoded_arrays.push(decoded_array);\n total_dst_length += dec_size;\n src_offset += body_size;\n }\n dst = new Float32Array(total_dst_length);\n dst_offset = 0;\n for (i = 0; i < decoded_arrays.length; i++) {\n dst.set(decoded_arrays[i], dst_offset);\n dst_offset += decoded_arrays[i].length;\n }\n return [2 /*return*/, dst];\n });\n });\n };\n WeightDecoderEightbit.decode_table = [0.0, 2.750000021e-06, 7.249999726e-06, 1.875000089e-05, 3.624999954e-05, 5.874999624e-05, 8.624999464e-05,\n 1.437500032e-04, 2.312500001e-04, 3.187500115e-04, 4.062500084e-04, 5.187499919e-04, 6.562499912e-04,\n 7.937499322e-04, 9.312499315e-04, 1.218750025e-03, 1.656249980e-03, 2.093750052e-03, 2.531250007e-03,\n 2.968749963e-03, 3.406249918e-03, 3.843750106e-03, 4.281249829e-03, 4.843750037e-03, 5.531250034e-03,\n 6.218749564e-03, 6.906249560e-03, 7.593749557e-03, 8.281249553e-03, 8.968749084e-03, 9.656248614e-03,\n 1.109374966e-02, 1.328125037e-02, 1.546875015e-02, 1.765624993e-02, 1.984374970e-02, 2.203124948e-02,\n 2.421874925e-02, 2.640625089e-02, 2.859375067e-02, 3.078125045e-02, 3.296874836e-02, 3.515625000e-02,\n 3.734375164e-02, 3.953124955e-02, 4.171875119e-02, 4.390624911e-02, 4.671875015e-02, 5.015625060e-02,\n 5.359374732e-02, 5.703124776e-02, 6.046874821e-02, 6.390624493e-02, 6.734374911e-02, 7.078124583e-02,\n 7.421874255e-02, 7.765624672e-02, 8.109374344e-02, 8.453124017e-02, 8.796874434e-02, 9.140624106e-02,\n 9.484373778e-02, 9.828124195e-02, 1.054687500e-01, 1.164062470e-01, 1.273437440e-01, 1.382812560e-01,\n 1.492187530e-01, 1.601562500e-01, 1.710937470e-01, 1.820312440e-01, 1.929687560e-01, 2.039062530e-01,\n 2.148437500e-01, 2.257812470e-01, 2.367187440e-01, 2.476562560e-01, 2.585937381e-01, 2.695312500e-01,\n 2.804687619e-01, 2.914062440e-01, 3.023437560e-01, 3.132812381e-01, 3.242187500e-01, 3.351562619e-01,\n 3.460937440e-01, 3.570312560e-01, 3.679687381e-01, 3.789062500e-01, 3.898437619e-01, 4.007812440e-01,\n 4.117187560e-01, 4.226562381e-01, 4.335937500e-01, 4.445312619e-01, 4.585937560e-01, 4.757812321e-01,\n 4.929687381e-01, 5.101562142e-01, 5.273437500e-01, 5.445312262e-01, 5.617187023e-01, 5.789062381e-01,\n 5.960937142e-01, 6.132812500e-01, 6.304687262e-01, 6.476562023e-01, 6.648437381e-01, 6.820312142e-01,\n 6.992186904e-01, 7.164062262e-01, 7.335937023e-01, 7.507811785e-01, 7.679687142e-01, 7.851561904e-01,\n 8.023436666e-01, 8.195312023e-01, 8.367186785e-01, 8.539061546e-01, 8.710936904e-01, 8.882811666e-01,\n 9.054686427e-01, 9.226561785e-01, 9.398436546e-01, 9.570311308e-01, 9.742186666e-01, 9.914061427e-01, 1.0,\n ];\n return WeightDecoderEightbit;\n}());\nexports.default = WeightDecoderEightbit;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/weight_decoder_eightbit.js\n// module id = 23\n// module chunks = 0","// Top level file is just a mixin of submodules & constants\n'use strict';\n\nvar assign = require('./lib/utils/common').assign;\n\nvar deflate = require('./lib/deflate');\nvar inflate = require('./lib/inflate');\nvar constants = require('./lib/zlib/constants');\n\nvar pako = {};\n\nassign(pako, deflate, inflate, constants);\n\nmodule.exports = pako;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/index.js\n// module id = 24\n// module chunks = 0","'use strict';\n\n\nvar zlib_deflate = require('./zlib/deflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\n\nvar toString = Object.prototype.toString;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nvar Z_NO_FLUSH = 0;\nvar Z_FINISH = 4;\n\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_SYNC_FLUSH = 2;\n\nvar Z_DEFAULT_COMPRESSION = -1;\n\nvar Z_DEFAULT_STRATEGY = 0;\n\nvar Z_DEFLATED = 8;\n\n/* ===========================================================================*/\n\n\n/**\n * class Deflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[deflate]],\n * [[deflateRaw]] and [[gzip]].\n **/\n\n/* internal\n * Deflate.chunks -> Array\n *\n * Chunks of output data, if [[Deflate#onData]] not overridden.\n **/\n\n/**\n * Deflate.result -> Uint8Array|Array\n *\n * Compressed result, generated by default [[Deflate#onData]]\n * and [[Deflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Deflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Deflate.err -> Number\n *\n * Error code after deflate finished. 0 (Z_OK) on success.\n * You will not need it in real life, because deflate errors\n * are possible only on wrong options or bad `onData` / `onEnd`\n * custom handlers.\n **/\n\n/**\n * Deflate.msg -> String\n *\n * Error message, if [[Deflate.err]] != 0\n **/\n\n\n/**\n * new Deflate(options)\n * - options (Object): zlib deflate options.\n *\n * Creates new deflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `level`\n * - `windowBits`\n * - `memLevel`\n * - `strategy`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw deflate\n * - `gzip` (Boolean) - create gzip wrapper\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n * - `header` (Object) - custom header for gzip\n * - `text` (Boolean) - true if compressed data believed to be text\n * - `time` (Number) - modification time, unix timestamp\n * - `os` (Number) - operation system code\n * - `extra` (Array) - array of bytes with extra data (max 65536)\n * - `name` (String) - file name (binary string)\n * - `comment` (String) - comment (binary string)\n * - `hcrc` (Boolean) - true if header crc should be added\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var deflate = new pako.Deflate({ level: 3});\n *\n * deflate.push(chunk1, false);\n * deflate.push(chunk2, true); // true -> last chunk\n *\n * if (deflate.err) { throw new Error(deflate.err); }\n *\n * console.log(deflate.result);\n * ```\n **/\nfunction Deflate(options) {\n if (!(this instanceof Deflate)) return new Deflate(options);\n\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n if (opt.raw && (opt.windowBits > 0)) {\n opt.windowBits = -opt.windowBits;\n }\n\n else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {\n opt.windowBits += 16;\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n\n if (opt.dictionary) {\n var dict;\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n // If we need to compress text, change encoding to utf8.\n dict = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n this._dict_set = true;\n }\n}\n\n/**\n * Deflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be\n * converted to utf8 byte sequence.\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with\n * new compressed chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the compression context.\n *\n * On fail call [[Deflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * array format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nDeflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var status, _mode;\n\n if (this.ended) { return false; }\n\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // If we need to compress text, change encoding to utf8.\n strm.input = strings.string2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_deflate.deflate(strm, _mode); /* no bad return value */\n\n if (status !== Z_STREAM_END && status !== Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {\n if (this.options.to === 'string') {\n this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH) {\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Deflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nDeflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Deflate#onEnd(status) -> Void\n * - status (Number): deflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called once after you tell deflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nDeflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * deflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * Compress `data` with deflate algorithm and `options`.\n *\n * Supported options are:\n *\n * - level\n * - windowBits\n * - memLevel\n * - strategy\n * - dictionary\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , data = Uint8Array([1,2,3,4,5,6,7,8,9]);\n *\n * console.log(pako.deflate(data));\n * ```\n **/\nfunction deflate(input, options) {\n var deflator = new Deflate(options);\n\n deflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (deflator.err) { throw deflator.msg || msg[deflator.err]; }\n\n return deflator.result;\n}\n\n\n/**\n * deflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate(input, options);\n}\n\n\n/**\n * gzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but create gzip wrapper instead of\n * deflate one.\n **/\nfunction gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate(input, options);\n}\n\n\nexports.Deflate = Deflate;\nexports.deflate = deflate;\nexports.deflateRaw = deflateRaw;\nexports.gzip = gzip;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/deflate.js\n// module id = 25\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar trees = require('./trees');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar msg = require('./messages');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\nvar Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\n//var Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\n//var Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\n//var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n\n/* compression levels */\n//var Z_NO_COMPRESSION = 0;\n//var Z_BEST_SPEED = 1;\n//var Z_BEST_COMPRESSION = 9;\nvar Z_DEFAULT_COMPRESSION = -1;\n\n\nvar Z_FILTERED = 1;\nvar Z_HUFFMAN_ONLY = 2;\nvar Z_RLE = 3;\nvar Z_FIXED = 4;\nvar Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\n//var Z_BINARY = 0;\n//var Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n/*============================================================================*/\n\n\nvar MAX_MEM_LEVEL = 9;\n/* Maximum value for memLevel in deflateInit2 */\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_MEM_LEVEL = 8;\n\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\nvar D_CODES = 30;\n/* number of distance codes */\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\nvar MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);\n\nvar PRESET_DICT = 0x20;\n\nvar INIT_STATE = 42;\nvar EXTRA_STATE = 69;\nvar NAME_STATE = 73;\nvar COMMENT_STATE = 91;\nvar HCRC_STATE = 103;\nvar BUSY_STATE = 113;\nvar FINISH_STATE = 666;\n\nvar BS_NEED_MORE = 1; /* block not completed, need more input or more output */\nvar BS_BLOCK_DONE = 2; /* block flush performed */\nvar BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */\nvar BS_FINISH_DONE = 4; /* finish done, accept no more input or output */\n\nvar OS_CODE = 0x03; // Unix :) . Don't detect, use this default.\n\nfunction err(strm, errorCode) {\n strm.msg = msg[errorCode];\n return errorCode;\n}\n\nfunction rank(f) {\n return ((f) << 1) - ((f) > 4 ? 9 : 0);\n}\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output goes\n * through this function so some applications may wish to modify it\n * to avoid allocating a large strm->output buffer and copying into it.\n * (See also read_buf()).\n */\nfunction flush_pending(strm) {\n var s = strm.state;\n\n //_tr_flush_bits(s);\n var len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) { return; }\n\n utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n}\n\n\nfunction flush_block_only(s, last) {\n trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n}\n\n\nfunction put_byte(s, b) {\n s.pending_buf[s.pending++] = b;\n}\n\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nfunction putShortMSB(s, b) {\n// put_byte(s, (Byte)(b >> 8));\n// put_byte(s, (Byte)(b & 0xff));\n s.pending_buf[s.pending++] = (b >>> 8) & 0xff;\n s.pending_buf[s.pending++] = b & 0xff;\n}\n\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read. All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->input buffer and copying from it.\n * (See also flush_pending()).\n */\nfunction read_buf(strm, buf, start, size) {\n var len = strm.avail_in;\n\n if (len > size) { len = size; }\n if (len === 0) { return 0; }\n\n strm.avail_in -= len;\n\n // zmemcpy(buf, strm->next_in, len);\n utils.arraySet(buf, strm.input, strm.next_in, len, start);\n if (strm.state.wrap === 1) {\n strm.adler = adler32(strm.adler, buf, len, start);\n }\n\n else if (strm.state.wrap === 2) {\n strm.adler = crc32(strm.adler, buf, len, start);\n }\n\n strm.next_in += len;\n strm.total_in += len;\n\n return len;\n}\n\n\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\nfunction longest_match(s, cur_match) {\n var chain_length = s.max_chain_length; /* max hash chain length */\n var scan = s.strstart; /* current string */\n var match; /* matched string */\n var len; /* length of current match */\n var best_len = s.prev_length; /* best match length so far */\n var nice_match = s.nice_match; /* stop if match long enough */\n var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?\n s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;\n\n var _win = s.window; // shortcut\n\n var wmask = s.w_mask;\n var prev = s.prev;\n\n /* Stop when cur_match becomes <= limit. To simplify the code,\n * we prevent matches with the string of window index 0.\n */\n\n var strend = s.strstart + MAX_MATCH;\n var scan_end1 = _win[scan + best_len - 1];\n var scan_end = _win[scan + best_len];\n\n /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n * It is easy to get rid of this optimization if necessary.\n */\n // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n /* Do not waste too much time if we already have a good match: */\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n /* Do not look for matches beyond the end of the input. This is necessary\n * to make deflate deterministic.\n */\n if (nice_match > s.lookahead) { nice_match = s.lookahead; }\n\n // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n do {\n // Assert(cur_match < s->strstart, \"no future\");\n match = cur_match;\n\n /* Skip to next match if the match length cannot increase\n * or if the match length is less than 2. Note that the checks below\n * for insufficient lookahead only occur occasionally for performance\n * reasons. Therefore uninitialized memory will be accessed, and\n * conditional jumps will be made that depend on those values.\n * However the length of the match is limited to the lookahead, so\n * the output of deflate is not affected by the uninitialized values.\n */\n\n if (_win[match + best_len] !== scan_end ||\n _win[match + best_len - 1] !== scan_end1 ||\n _win[match] !== _win[scan] ||\n _win[++match] !== _win[scan + 1]) {\n continue;\n }\n\n /* The check at best_len-1 can be removed because it will be made\n * again later. (This heuristic is not always a win.)\n * It is not necessary to compare scan[2] and match[2] since they\n * are always equal when the other bytes match, given that\n * the hash keys are equal and that HASH_BITS >= 8.\n */\n scan += 2;\n match++;\n // Assert(*scan == *match, \"match[2]?\");\n\n /* We check for insufficient lookahead only every 8th comparison;\n * the 256th check will be made at strstart+258.\n */\n do {\n /*jshint noempty:false*/\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n scan < strend);\n\n // Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n}\n\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n * At least one byte has been read, or avail_in == 0; reads are\n * performed for at least two bytes (required for the zip translate_eol\n * option -- not supported here).\n */\nfunction fill_window(s) {\n var _w_size = s.w_size;\n var p, n, m, more, str;\n\n //Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n do {\n more = s.window_size - s.lookahead - s.strstart;\n\n // JS ints have 32 bit, block below not needed\n /* Deal with !@#$% 64K limit: */\n //if (sizeof(int) <= 2) {\n // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n // more = wsize;\n //\n // } else if (more == (unsigned)(-1)) {\n // /* Very unlikely, but possible on 16 bit machine if\n // * strstart == 0 && lookahead == 1 (input done a byte at time)\n // */\n // more--;\n // }\n //}\n\n\n /* If the window is almost full and there is insufficient lookahead,\n * move the upper half to the lower one to make room in the upper half.\n */\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n\n utils.arraySet(s.window, s.window, _w_size, _w_size, 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n /* we now have strstart >= MAX_DIST */\n s.block_start -= _w_size;\n\n /* Slide the hash table (could be avoided with 32 bit values\n at the expense of memory usage). We slide even when level == 0\n to keep the hash table consistent if we switch back to level > 0\n later. (Using level 0 permanently is not an optimal usage of\n zlib, so we don't care about this pathological case.)\n */\n\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = (m >= _w_size ? m - _w_size : 0);\n } while (--n);\n\n n = _w_size;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = (m >= _w_size ? m - _w_size : 0);\n /* If n is not on any hash chain, prev[n] is garbage but\n * its value will never be used.\n */\n } while (--n);\n\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n\n /* If there was no sliding:\n * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n * more == window_size - lookahead - strstart\n * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n * => more >= window_size - 2*WSIZE + 2\n * In the BIG_MEM or MMAP case (not yet supported),\n * window_size == input_size + MIN_LOOKAHEAD &&\n * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n * Otherwise, window_size == 2*WSIZE so more >= 2.\n * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n */\n //Assert(more >= 2, \"more < 2\");\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n\n /* Initialize the hash value now that we have some input: */\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n\n /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;\n//#if MIN_MATCH != 3\n// Call update_hash() MIN_MATCH-3 more times\n//#endif\n while (s.insert) {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n * but this is not important since only literal bytes will be emitted.\n */\n\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n\n /* If the WIN_INIT bytes after the end of the current data have never been\n * written, then zero those bytes in order to avoid memory check reports of\n * the use of uninitialized (or uninitialised as Julian writes) bytes by\n * the longest match routines. Update the high water mark for the next\n * time through here. WIN_INIT is set to MAX_MATCH since the longest match\n * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n */\n// if (s.high_water < s.window_size) {\n// var curr = s.strstart + s.lookahead;\n// var init = 0;\n//\n// if (s.high_water < curr) {\n// /* Previous high water mark below current data -- zero WIN_INIT\n// * bytes or up to end of window, whichever is less.\n// */\n// init = s.window_size - curr;\n// if (init > WIN_INIT)\n// init = WIN_INIT;\n// zmemzero(s->window + curr, (unsigned)init);\n// s->high_water = curr + init;\n// }\n// else if (s->high_water < (ulg)curr + WIN_INIT) {\n// /* High water mark at or above current data, but below current data\n// * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n// * to end of window, whichever is less.\n// */\n// init = (ulg)curr + WIN_INIT - s->high_water;\n// if (init > s->window_size - s->high_water)\n// init = s->window_size - s->high_water;\n// zmemzero(s->window + s->high_water, (unsigned)init);\n// s->high_water += init;\n// }\n// }\n//\n// Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n// \"not enough room for search\");\n}\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n * This function does not insert new strings in the dictionary since\n * uncompressible data is probably not useful. This function is used\n * only for the level=0 compression option.\n * NOTE: this function should be optimized to avoid extra copying from\n * window to pending_buf.\n */\nfunction deflate_stored(s, flush) {\n /* Stored blocks are limited to 0xffff bytes, pending_buf is limited\n * to pending_buf_size, and each stored block has a 5 byte header:\n */\n var max_block_size = 0xffff;\n\n if (max_block_size > s.pending_buf_size - 5) {\n max_block_size = s.pending_buf_size - 5;\n }\n\n /* Copy as much as possible from input to output: */\n for (;;) {\n /* Fill the window as much as possible: */\n if (s.lookahead <= 1) {\n\n //Assert(s->strstart < s->w_size+MAX_DIST(s) ||\n // s->block_start >= (long)s->w_size, \"slide too late\");\n// if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||\n// s.block_start >= s.w_size)) {\n// throw new Error(\"slide too late\");\n// }\n\n fill_window(s);\n if (s.lookahead === 0 && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n\n if (s.lookahead === 0) {\n break;\n }\n /* flush the current block */\n }\n //Assert(s->block_start >= 0L, \"block gone\");\n// if (s.block_start < 0) throw new Error(\"block gone\");\n\n s.strstart += s.lookahead;\n s.lookahead = 0;\n\n /* Emit a stored block if pending_buf will be full: */\n var max_start = s.block_start + max_block_size;\n\n if (s.strstart === 0 || s.strstart >= max_start) {\n /* strstart == 0 is possible when wraparound on 16-bit machine */\n s.lookahead = s.strstart - max_start;\n s.strstart = max_start;\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n\n\n }\n /* Flush if we may have to slide, otherwise block_start may become\n * negative and the data will be gone:\n */\n if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n\n s.insert = 0;\n\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n\n if (s.strstart > s.block_start) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_NEED_MORE;\n}\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nfunction deflate_fast(s, flush) {\n var hash_head; /* head of the hash chain */\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break; /* flush the current block */\n }\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n * At this point we have always match_length < MIN_MATCH\n */\n if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n }\n if (s.match_length >= MIN_MATCH) {\n // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only\n\n /*** _tr_tally_dist(s, s.strstart - s.match_start,\n s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n\n /* Insert new strings in the hash table only if the match length\n * is not too large. This saves time but degrades compression.\n */\n if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {\n s.match_length--; /* string at strstart already in table */\n do {\n s.strstart++;\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n * always MIN_MATCH bytes ahead.\n */\n } while (--s.match_length !== 0);\n s.strstart++;\n } else\n {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;\n\n//#if MIN_MATCH != 3\n// Call UPDATE_HASH() MIN_MATCH-3 more times\n//#endif\n /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n * matter since it will be recomputed at next deflate call.\n */\n }\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s.window[s.strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nfunction deflate_slow(s, flush) {\n var hash_head; /* head of hash chain */\n var bflush; /* set if current block must be flushed */\n\n var max_insert;\n\n /* Process the input block. */\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n */\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n\n if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&\n s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n\n if (s.match_length <= 5 &&\n (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) {\n\n /* If prev_match is also MIN_MATCH, match_start is garbage\n * but we will ignore the current match anyway.\n */\n s.match_length = MIN_MATCH - 1;\n }\n }\n /* If there was a match at the previous step and the current\n * match is not better, output the previous match:\n */\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n /* Do not insert strings in hash table beyond this. */\n\n //check_match(s, s.strstart-1, s.prev_match, s.prev_length);\n\n /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,\n s.prev_length - MIN_MATCH, bflush);***/\n bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n /* Insert in hash table all strings up to the end of the match.\n * strstart-1 and strstart are already inserted. If there is not\n * enough lookahead, the last two strings are not inserted in\n * the hash table.\n */\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n } else if (s.match_available) {\n /* If there was no match at the previous position, output a\n * single literal. If there was a match but the current match\n * is longer, truncate the previous match to a single literal.\n */\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n if (bflush) {\n /*** FLUSH_BLOCK_ONLY(s, 0) ***/\n flush_block_only(s, false);\n /***/\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n /* There is no previous match to compare with, wait for\n * the next step to decide.\n */\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n //Assert (flush != Z_NO_FLUSH, \"no flush?\");\n if (s.match_available) {\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_BLOCK_DONE;\n}\n\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one. Do not maintain a hash table. (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nfunction deflate_rle(s, flush) {\n var bflush; /* set if current block must be flushed */\n var prev; /* byte at distance one to match */\n var scan, strend; /* scan goes up to strend for length of run */\n\n var _win = s.window;\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the longest run, plus one for the unrolled loop.\n */\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* See how many times the previous byte repeats */\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n /*jshint noempty:false*/\n } while (prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n //Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n }\n\n /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n if (s.match_length >= MIN_MATCH) {\n //check_match(s, s.strstart, s.strstart - 1, s.match_length);\n\n /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nfunction deflate_huff(s, flush) {\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we have a literal to write. */\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n break; /* flush the current block */\n }\n }\n\n /* Output a literal byte */\n s.match_length = 0;\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\nfunction Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n}\n\nvar configuration_table;\n\nconfiguration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast), /* 2 */\n new Config(4, 6, 32, 32, deflate_fast), /* 3 */\n\n new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow), /* 5 */\n new Config(8, 16, 128, 128, deflate_slow), /* 6 */\n new Config(8, 32, 128, 256, deflate_slow), /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow), /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */\n];\n\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nfunction lm_init(s) {\n s.window_size = 2 * s.w_size;\n\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n\n /* Set the default configuration parameters:\n */\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n}\n\n\nfunction DeflateState() {\n this.strm = null; /* pointer back to this zlib stream */\n this.status = 0; /* as the name implies */\n this.pending_buf = null; /* output still pending */\n this.pending_buf_size = 0; /* size of pending_buf */\n this.pending_out = 0; /* next pending byte to output to the stream */\n this.pending = 0; /* nb of bytes in the pending buffer */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.gzhead = null; /* gzip header information to write */\n this.gzindex = 0; /* where in extra, name, or comment */\n this.method = Z_DEFLATED; /* can only be DEFLATED */\n this.last_flush = -1; /* value of flush param for previous deflate call */\n\n this.w_size = 0; /* LZ77 window size (32K by default) */\n this.w_bits = 0; /* log2(w_size) (8..16) */\n this.w_mask = 0; /* w_size - 1 */\n\n this.window = null;\n /* Sliding window. Input bytes are read into the second half of the window,\n * and move to the first half later to keep a dictionary of at least wSize\n * bytes. With this organization, matches are limited to a distance of\n * wSize-MAX_MATCH bytes, but this ensures that IO is always\n * performed with a length multiple of the block size.\n */\n\n this.window_size = 0;\n /* Actual size of window: 2*wSize, except when the user input buffer\n * is directly used as sliding window.\n */\n\n this.prev = null;\n /* Link to older string with same hash index. To limit the size of this\n * array to 64K, this link is maintained only for the last 32K strings.\n * An index in this array is thus a window index modulo 32K.\n */\n\n this.head = null; /* Heads of the hash chains or NIL. */\n\n this.ins_h = 0; /* hash index of string to be inserted */\n this.hash_size = 0; /* number of elements in hash table */\n this.hash_bits = 0; /* log2(hash_size) */\n this.hash_mask = 0; /* hash_size-1 */\n\n this.hash_shift = 0;\n /* Number of bits by which ins_h must be shifted at each input\n * step. It must be such that after MIN_MATCH steps, the oldest\n * byte no longer takes part in the hash key, that is:\n * hash_shift * MIN_MATCH >= hash_bits\n */\n\n this.block_start = 0;\n /* Window position at the beginning of the current output block. Gets\n * negative when the window is moved backwards.\n */\n\n this.match_length = 0; /* length of best match */\n this.prev_match = 0; /* previous match */\n this.match_available = 0; /* set if previous match exists */\n this.strstart = 0; /* start of string to insert */\n this.match_start = 0; /* start of matching string */\n this.lookahead = 0; /* number of valid bytes ahead in window */\n\n this.prev_length = 0;\n /* Length of the best match at previous step. Matches not greater than this\n * are discarded. This is used in the lazy match evaluation.\n */\n\n this.max_chain_length = 0;\n /* To speed up deflation, hash chains are never searched beyond this\n * length. A higher limit improves compression ratio but degrades the\n * speed.\n */\n\n this.max_lazy_match = 0;\n /* Attempt to find a better match only when the current match is strictly\n * smaller than this value. This mechanism is used only for compression\n * levels >= 4.\n */\n // That's alias to max_lazy_match, don't use directly\n //this.max_insert_length = 0;\n /* Insert new strings in the hash table only if the match length is not\n * greater than this length. This saves time but degrades compression.\n * max_insert_length is used only for compression levels <= 3.\n */\n\n this.level = 0; /* compression level (1..9) */\n this.strategy = 0; /* favor or force Huffman coding*/\n\n this.good_match = 0;\n /* Use a faster search when the previous match is longer than this */\n\n this.nice_match = 0; /* Stop searching when current match exceeds this */\n\n /* used by trees.c: */\n\n /* Didn't use ct_data typedef below to suppress compiler warning */\n\n // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */\n // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */\n\n // Use flat array of DOUBLE size, with interleaved fata,\n // because JS does not support effective\n this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);\n this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);\n this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n\n this.l_desc = null; /* desc. for literal tree */\n this.d_desc = null; /* desc. for distance tree */\n this.bl_desc = null; /* desc. for bit length tree */\n\n //ush bl_count[MAX_BITS+1];\n this.bl_count = new utils.Buf16(MAX_BITS + 1);\n /* number of codes at each bit length for an optimal tree */\n\n //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */\n this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */\n zero(this.heap);\n\n this.heap_len = 0; /* number of elements in the heap */\n this.heap_max = 0; /* element of largest frequency */\n /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n * The same heap array is used to build all trees.\n */\n\n this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];\n zero(this.depth);\n /* Depth of each subtree used as tie breaker for trees of equal frequency\n */\n\n this.l_buf = 0; /* buffer index for literals or lengths */\n\n this.lit_bufsize = 0;\n /* Size of match buffer for literals/lengths. There are 4 reasons for\n * limiting lit_bufsize to 64K:\n * - frequencies can be kept in 16 bit counters\n * - if compression is not successful for the first block, all input\n * data is still in the window so we can still emit a stored block even\n * when input comes from standard input. (This can also be done for\n * all blocks if lit_bufsize is not greater than 32K.)\n * - if compression is not successful for a file smaller than 64K, we can\n * even emit a stored file instead of a stored block (saving 5 bytes).\n * This is applicable only for zip (not gzip or zlib).\n * - creating new Huffman trees less frequently may not provide fast\n * adaptation to changes in the input data statistics. (Take for\n * example a binary file with poorly compressible code followed by\n * a highly compressible string table.) Smaller buffer sizes give\n * fast adaptation but have of course the overhead of transmitting\n * trees more frequently.\n * - I can't count above 4\n */\n\n this.last_lit = 0; /* running index in l_buf */\n\n this.d_buf = 0;\n /* Buffer index for distances. To simplify the code, d_buf and l_buf have\n * the same number of elements. To use different lengths, an extra flag\n * array would be necessary.\n */\n\n this.opt_len = 0; /* bit length of current block with optimal trees */\n this.static_len = 0; /* bit length of current block with static trees */\n this.matches = 0; /* number of string matches in current block */\n this.insert = 0; /* bytes at end of window left to insert */\n\n\n this.bi_buf = 0;\n /* Output buffer. bits are inserted starting at the bottom (least\n * significant bits).\n */\n this.bi_valid = 0;\n /* Number of valid bits in bi_buf. All bits above the last valid bit\n * are always zero.\n */\n\n // Used for window memory init. We safely ignore it for JS. That makes\n // sense only for pointers and memory check tools.\n //this.high_water = 0;\n /* High water mark offset in window for initialized bytes -- bytes above\n * this are set to zero in order to avoid memory check warnings when\n * longest match routines access bytes past the input. This is then\n * updated to the new high water mark.\n */\n}\n\n\nfunction deflateResetKeep(strm) {\n var s;\n\n if (!strm || !strm.state) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n\n s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n /* was made negative by deflate(..., Z_FINISH); */\n }\n s.status = (s.wrap ? INIT_STATE : BUSY_STATE);\n strm.adler = (s.wrap === 2) ?\n 0 // crc32(0, Z_NULL, 0)\n :\n 1; // adler32(0, Z_NULL, 0)\n s.last_flush = Z_NO_FLUSH;\n trees._tr_init(s);\n return Z_OK;\n}\n\n\nfunction deflateReset(strm) {\n var ret = deflateResetKeep(strm);\n if (ret === Z_OK) {\n lm_init(strm.state);\n }\n return ret;\n}\n\n\nfunction deflateSetHeader(strm, head) {\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; }\n strm.state.gzhead = head;\n return Z_OK;\n}\n\n\nfunction deflateInit2(strm, level, method, windowBits, memLevel, strategy) {\n if (!strm) { // === Z_NULL\n return Z_STREAM_ERROR;\n }\n var wrap = 1;\n\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n\n if (windowBits < 0) { /* suppress zlib wrapper */\n wrap = 0;\n windowBits = -windowBits;\n }\n\n else if (windowBits > 15) {\n wrap = 2; /* write gzip wrapper instead */\n windowBits -= 16;\n }\n\n\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED ||\n windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n strategy < 0 || strategy > Z_FIXED) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n\n if (windowBits === 8) {\n windowBits = 9;\n }\n /* until 256-byte window bug fixed */\n\n var s = new DeflateState();\n\n strm.state = s;\n s.strm = strm;\n\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n\n s.window = new utils.Buf8(s.w_size * 2);\n s.head = new utils.Buf16(s.hash_size);\n s.prev = new utils.Buf16(s.w_size);\n\n // Don't need mem init magic for JS.\n //s.high_water = 0; /* nothing written to s->window yet */\n\n s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n s.pending_buf_size = s.lit_bufsize * 4;\n\n //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n //s->pending_buf = (uchf *) overlay;\n s.pending_buf = new utils.Buf8(s.pending_buf_size);\n\n // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)\n //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n s.d_buf = 1 * s.lit_bufsize;\n\n //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n s.l_buf = (1 + 2) * s.lit_bufsize;\n\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n\n return deflateReset(strm);\n}\n\nfunction deflateInit(strm, level) {\n return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n}\n\n\nfunction deflate(strm, flush) {\n var old_flush, s;\n var beg, val; // for gzip header write only\n\n if (!strm || !strm.state ||\n flush > Z_BLOCK || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;\n }\n\n s = strm.state;\n\n if (!strm.output ||\n (!strm.input && strm.avail_in !== 0) ||\n (s.status === FINISH_STATE && flush !== Z_FINISH)) {\n return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR);\n }\n\n s.strm = strm; /* just in case */\n old_flush = s.last_flush;\n s.last_flush = flush;\n\n /* Write the header */\n if (s.status === INIT_STATE) {\n\n if (s.wrap === 2) { // GZIP header\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) { // s->gzhead == Z_NULL\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n }\n else {\n put_byte(s, (s.gzhead.text ? 1 : 0) +\n (s.gzhead.hcrc ? 2 : 0) +\n (!s.gzhead.extra ? 0 : 4) +\n (!s.gzhead.name ? 0 : 8) +\n (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 0xff);\n put_byte(s, (s.gzhead.time >> 8) & 0xff);\n put_byte(s, (s.gzhead.time >> 16) & 0xff);\n put_byte(s, (s.gzhead.time >> 24) & 0xff);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, s.gzhead.os & 0xff);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 0xff);\n put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n else // DEFLATE header\n {\n var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;\n var level_flags = -1;\n\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= (level_flags << 6);\n if (s.strstart !== 0) { header |= PRESET_DICT; }\n header += 31 - (header % 31);\n\n s.status = BUSY_STATE;\n putShortMSB(s, header);\n\n /* Save the adler32 of the preset dictionary: */\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n strm.adler = 1; // adler32(0L, Z_NULL, 0);\n }\n }\n\n//#ifdef GZIP\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n\n while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n break;\n }\n }\n put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);\n s.gzindex++;\n }\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (s.gzindex === s.gzhead.extra.length) {\n s.gzindex = 0;\n s.status = NAME_STATE;\n }\n }\n else {\n s.status = NAME_STATE;\n }\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.gzindex = 0;\n s.status = COMMENT_STATE;\n }\n }\n else {\n s.status = COMMENT_STATE;\n }\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.status = HCRC_STATE;\n }\n }\n else {\n s.status = HCRC_STATE;\n }\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n }\n if (s.pending + 2 <= s.pending_buf_size) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n s.status = BUSY_STATE;\n }\n }\n else {\n s.status = BUSY_STATE;\n }\n }\n//#endif\n\n /* Flush as much pending output as possible */\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n /* Since avail_out is 0, deflate will be called again with\n * more output space, but possibly with both pending and\n * avail_in equal to zero. There won't be anything to do,\n * but this is not an error situation so make sure we\n * return OK instead of BUF_ERROR at next call of deflate:\n */\n s.last_flush = -1;\n return Z_OK;\n }\n\n /* Make sure there is something to do and avoid duplicate consecutive\n * flushes. For repeated and useless calls with Z_FINISH, we keep\n * returning Z_STREAM_END instead of Z_BUF_ERROR.\n */\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&\n flush !== Z_FINISH) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* User must not provide more input after the first FINISH: */\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* Start a new block or continue the current one.\n */\n if (strm.avail_in !== 0 || s.lookahead !== 0 ||\n (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {\n var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :\n (s.strategy === Z_RLE ? deflate_rle(s, flush) :\n configuration_table[s.level].func(s, flush));\n\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n /* avoid BUF_ERROR next call, see above */\n }\n return Z_OK;\n /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n * of deflate should use the same flush parameter to make sure\n * that the flush is complete. So we don't have to output an\n * empty block here, this will be done at next call. This also\n * ensures that for a very small output buffer, we emit at most\n * one empty block.\n */\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n trees._tr_align(s);\n }\n else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */\n\n trees._tr_stored_block(s, 0, 0, false);\n /* For a full flush, this empty block will be recognized\n * as a special marker by inflate_sync().\n */\n if (flush === Z_FULL_FLUSH) {\n /*** CLEAR_HASH(s); ***/ /* forget history */\n zero(s.head); // Fill with NIL (= 0);\n\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n return Z_OK;\n }\n }\n }\n //Assert(strm->avail_out > 0, \"bug2\");\n //if (strm.avail_out <= 0) { throw new Error(\"bug2\");}\n\n if (flush !== Z_FINISH) { return Z_OK; }\n if (s.wrap <= 0) { return Z_STREAM_END; }\n\n /* Write the trailer */\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n put_byte(s, (strm.adler >> 16) & 0xff);\n put_byte(s, (strm.adler >> 24) & 0xff);\n put_byte(s, strm.total_in & 0xff);\n put_byte(s, (strm.total_in >> 8) & 0xff);\n put_byte(s, (strm.total_in >> 16) & 0xff);\n put_byte(s, (strm.total_in >> 24) & 0xff);\n }\n else\n {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n\n flush_pending(strm);\n /* If avail_out is zero, the application will call deflate again\n * to flush the rest.\n */\n if (s.wrap > 0) { s.wrap = -s.wrap; }\n /* write the trailer only once! */\n return s.pending !== 0 ? Z_OK : Z_STREAM_END;\n}\n\nfunction deflateEnd(strm) {\n var status;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n status = strm.state.status;\n if (status !== INIT_STATE &&\n status !== EXTRA_STATE &&\n status !== NAME_STATE &&\n status !== COMMENT_STATE &&\n status !== HCRC_STATE &&\n status !== BUSY_STATE &&\n status !== FINISH_STATE\n ) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.state = null;\n\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;\n}\n\n\n/* =========================================================================\n * Initializes the compression dictionary from the given byte\n * sequence without producing any compressed output.\n */\nfunction deflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var s;\n var str, n;\n var wrap;\n var avail;\n var next;\n var input;\n var tmpDict;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n s = strm.state;\n wrap = s.wrap;\n\n if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {\n return Z_STREAM_ERROR;\n }\n\n /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n if (wrap === 1) {\n /* adler32(strm->adler, dictionary, dictLength); */\n strm.adler = adler32(strm.adler, dictionary, dictLength, 0);\n }\n\n s.wrap = 0; /* avoid computing Adler-32 in read_buf */\n\n /* if dictionary would fill window, just replace the history */\n if (dictLength >= s.w_size) {\n if (wrap === 0) { /* already empty otherwise */\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n /* use the tail */\n // dictionary = dictionary.slice(dictLength - s.w_size);\n tmpDict = new utils.Buf8(s.w_size);\n utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n /* insert dictionary into window and hash */\n avail = strm.avail_in;\n next = strm.next_in;\n input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n str = s.strstart;\n n = s.lookahead - (MIN_MATCH - 1);\n do {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK;\n}\n\n\nexports.deflateInit = deflateInit;\nexports.deflateInit2 = deflateInit2;\nexports.deflateReset = deflateReset;\nexports.deflateResetKeep = deflateResetKeep;\nexports.deflateSetHeader = deflateSetHeader;\nexports.deflate = deflate;\nexports.deflateEnd = deflateEnd;\nexports.deflateSetDictionary = deflateSetDictionary;\nexports.deflateInfo = 'pako deflate (from Nodeca project)';\n\n/* Not implemented\nexports.deflateBound = deflateBound;\nexports.deflateCopy = deflateCopy;\nexports.deflateParams = deflateParams;\nexports.deflatePending = deflatePending;\nexports.deflatePrime = deflatePrime;\nexports.deflateTune = deflateTune;\n*/\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/deflate.js\n// module id = 26\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n//var Z_FILTERED = 1;\n//var Z_HUFFMAN_ONLY = 2;\n//var Z_RLE = 3;\nvar Z_FIXED = 4;\n//var Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\nvar Z_BINARY = 0;\nvar Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n/*============================================================================*/\n\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n// From zutil.h\n\nvar STORED_BLOCK = 0;\nvar STATIC_TREES = 1;\nvar DYN_TREES = 2;\n/* The three kinds of block type */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\n/* The minimum and maximum match lengths */\n\n// From deflate.h\n/* ===========================================================================\n * Internal compression state.\n */\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\n\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\n\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\n\nvar D_CODES = 30;\n/* number of distance codes */\n\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\n\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\n\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar Buf_size = 16;\n/* size of bit buffer in bi_buf */\n\n\n/* ===========================================================================\n * Constants\n */\n\nvar MAX_BL_BITS = 7;\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\nvar END_BLOCK = 256;\n/* end of block literal code */\n\nvar REP_3_6 = 16;\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\nvar REPZ_3_10 = 17;\n/* repeat a zero length 3-10 times (3 bits of repeat count) */\n\nvar REPZ_11_138 = 18;\n/* repeat a zero length 11-138 times (7 bits of repeat count) */\n\n/* eslint-disable comma-spacing,array-bracket-spacing */\nvar extra_lbits = /* extra bits for each length code */\n [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];\n\nvar extra_dbits = /* extra bits for each distance code */\n [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];\n\nvar extra_blbits = /* extra bits for each bit length code */\n [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];\n\nvar bl_order =\n [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];\n/* eslint-enable comma-spacing,array-bracket-spacing */\n\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n// We pre-fill arrays with 0 to avoid uninitialized gaps\n\nvar DIST_CODE_LEN = 512; /* see definition of array dist_code below */\n\n// !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1\nvar static_ltree = new Array((L_CODES + 2) * 2);\nzero(static_ltree);\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nvar static_dtree = new Array(D_CODES * 2);\nzero(static_dtree);\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nvar _dist_code = new Array(DIST_CODE_LEN);\nzero(_dist_code);\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nvar _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);\nzero(_length_code);\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nvar base_length = new Array(LENGTH_CODES);\nzero(base_length);\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nvar base_dist = new Array(D_CODES);\nzero(base_dist);\n/* First normalized distance for each code (0 = distance of 1) */\n\n\nfunction StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n\n this.static_tree = static_tree; /* static tree or NULL */\n this.extra_bits = extra_bits; /* extra bits for each code or NULL */\n this.extra_base = extra_base; /* base index for extra_bits */\n this.elems = elems; /* max number of elements in the tree */\n this.max_length = max_length; /* max bit length for the codes */\n\n // show if `static_tree` has data or dummy - needed for monomorphic objects\n this.has_stree = static_tree && static_tree.length;\n}\n\n\nvar static_l_desc;\nvar static_d_desc;\nvar static_bl_desc;\n\n\nfunction TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree; /* the dynamic tree */\n this.max_code = 0; /* largest code with non zero frequency */\n this.stat_desc = stat_desc; /* the corresponding static tree */\n}\n\n\n\nfunction d_code(dist) {\n return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];\n}\n\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\nfunction put_short(s, w) {\n// put_byte(s, (uch)((w) & 0xff));\n// put_byte(s, (uch)((ush)(w) >> 8));\n s.pending_buf[s.pending++] = (w) & 0xff;\n s.pending_buf[s.pending++] = (w >>> 8) & 0xff;\n}\n\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\nfunction send_bits(s, value, length) {\n if (s.bi_valid > (Buf_size - length)) {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> (Buf_size - s.bi_valid);\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n s.bi_valid += length;\n }\n}\n\n\nfunction send_code(s, c, tree) {\n send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);\n}\n\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nfunction bi_reverse(code, len) {\n var res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nfunction bi_flush(s) {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 0xff;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n}\n\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n * above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n * array bl_count contains the frequencies for each bit length.\n * The length opt_len is updated; static_len is also updated if stree is\n * not null.\n */\nfunction gen_bitlen(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var max_code = desc.max_code;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var extra = desc.stat_desc.extra_bits;\n var base = desc.stat_desc.extra_base;\n var max_length = desc.stat_desc.max_length;\n var h; /* heap index */\n var n, m; /* iterate over the tree elements */\n var bits; /* bit length */\n var xbits; /* extra bits */\n var f; /* frequency */\n var overflow = 0; /* number of elements with bit length too large */\n\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n\n /* In a first pass, compute the optimal bit lengths (which may\n * overflow in the case of the bit length tree).\n */\n tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */\n\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1]/*.Len*/ = bits;\n /* We overwrite tree[n].Dad which is no longer needed */\n\n if (n > max_code) { continue; } /* not a leaf node */\n\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2]/*.Freq*/;\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);\n }\n }\n if (overflow === 0) { return; }\n\n // Trace((stderr,\"\\nbit length overflow\\n\"));\n /* This happens for example on obj2 and pic of the Calgary corpus */\n\n /* Find the first bit length which could increase: */\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) { bits--; }\n s.bl_count[bits]--; /* move one leaf down the tree */\n s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */\n s.bl_count[max_length]--;\n /* The brother of the overflow item also moves one step up,\n * but this does not affect bl_count[max_length]\n */\n overflow -= 2;\n } while (overflow > 0);\n\n /* Now recompute all bit lengths, scanning in increasing frequency.\n * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n * lengths instead of fixing only the wrong ones. This idea is taken\n * from 'ar' written by Haruhiko Okumura.)\n */\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) { continue; }\n if (tree[m * 2 + 1]/*.Len*/ !== bits) {\n // Trace((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;\n tree[m * 2 + 1]/*.Len*/ = bits;\n }\n n--;\n }\n }\n}\n\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n * zero code length.\n */\nfunction gen_codes(tree, max_code, bl_count)\n// ct_data *tree; /* the tree to decorate */\n// int max_code; /* largest code with non zero frequency */\n// ushf *bl_count; /* number of codes at each bit length */\n{\n var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */\n var code = 0; /* running code value */\n var bits; /* bit index */\n var n; /* code index */\n\n /* The distribution counts are first used to generate the code values\n * without bit reversal.\n */\n for (bits = 1; bits <= MAX_BITS; bits++) {\n next_code[bits] = code = (code + bl_count[bits - 1]) << 1;\n }\n /* Check that the bit counts in bl_count are consistent. The last code\n * must be all ones.\n */\n //Assert (code + bl_count[MAX_BITS]-1 == (1< length code (0..28) */\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length[code] = length;\n for (n = 0; n < (1 << extra_lbits[code]); n++) {\n _length_code[length++] = code;\n }\n }\n //Assert (length == 256, \"tr_static_init: length != 256\");\n /* Note that the length 255 (match length 258) can be represented\n * in two different ways: code 284 + 5 bits or code 285, so we\n * overwrite length_code[255] to use the best encoding:\n */\n _length_code[length - 1] = code;\n\n /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist[code] = dist;\n for (n = 0; n < (1 << extra_dbits[code]); n++) {\n _dist_code[dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: dist != 256\");\n dist >>= 7; /* from now on, all distances are divided by 128 */\n for (; code < D_CODES; code++) {\n base_dist[code] = dist << 7;\n for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {\n _dist_code[256 + dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n /* Construct the codes of the static literal tree */\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n\n n = 0;\n while (n <= 143) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree[n * 2 + 1]/*.Len*/ = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree[n * 2 + 1]/*.Len*/ = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n /* Codes 286 and 287 do not exist, but we must include them in the\n * tree construction to get a canonical Huffman tree (longest code\n * all ones)\n */\n gen_codes(static_ltree, L_CODES + 1, bl_count);\n\n /* The static distance tree is trivial: */\n for (n = 0; n < D_CODES; n++) {\n static_dtree[n * 2 + 1]/*.Len*/ = 5;\n static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);\n }\n\n // Now data ready and we can init static trees\n static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n\n //static_init_done = true;\n}\n\n\n/* ===========================================================================\n * Initialize a new block.\n */\nfunction init_block(s) {\n var n; /* iterates over tree elements */\n\n /* Initialize the trees. */\n for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }\n\n s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;\n s.opt_len = s.static_len = 0;\n s.last_lit = s.matches = 0;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nfunction bi_windup(s)\n{\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n //put_byte(s, (Byte)s->bi_buf);\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n}\n\n/* ===========================================================================\n * Copy a stored block, storing first the length and its\n * one's complement if requested.\n */\nfunction copy_block(s, buf, len, header)\n//DeflateState *s;\n//charf *buf; /* the input data */\n//unsigned len; /* its length */\n//int header; /* true if block header must be written */\n{\n bi_windup(s); /* align on byte boundary */\n\n if (header) {\n put_short(s, len);\n put_short(s, ~len);\n }\n// while (len--) {\n// put_byte(s, *buf++);\n// }\n utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);\n s.pending += len;\n}\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\nfunction smaller(tree, n, m, depth) {\n var _n2 = n * 2;\n var _m2 = m * 2;\n return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||\n (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));\n}\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nfunction pqdownheap(s, tree, k)\n// deflate_state *s;\n// ct_data *tree; /* the tree to restore */\n// int k; /* node to move down */\n{\n var v = s.heap[k];\n var j = k << 1; /* left son of k */\n while (j <= s.heap_len) {\n /* Set j to the smallest of the two sons: */\n if (j < s.heap_len &&\n smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n /* Exit if v is smaller than both sons */\n if (smaller(tree, v, s.heap[j], s.depth)) { break; }\n\n /* Exchange v with the smallest son */\n s.heap[k] = s.heap[j];\n k = j;\n\n /* And continue down the tree, setting j to the left son of k */\n j <<= 1;\n }\n s.heap[k] = v;\n}\n\n\n// inlined manually\n// var SMALLEST = 1;\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nfunction compress_block(s, ltree, dtree)\n// deflate_state *s;\n// const ct_data *ltree; /* literal tree */\n// const ct_data *dtree; /* distance tree */\n{\n var dist; /* distance of matched string */\n var lc; /* match length or unmatched char (if dist == 0) */\n var lx = 0; /* running index in l_buf */\n var code; /* the code to send */\n var extra; /* number of extra bits to send */\n\n if (s.last_lit !== 0) {\n do {\n dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);\n lc = s.pending_buf[s.l_buf + lx];\n lx++;\n\n if (dist === 0) {\n send_code(s, lc, ltree); /* send a literal byte */\n //Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n } else {\n /* Here, lc is the match length - MIN_MATCH */\n code = _length_code[lc];\n send_code(s, code + LITERALS + 1, ltree); /* send the length code */\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length[code];\n send_bits(s, lc, extra); /* send the extra length bits */\n }\n dist--; /* dist is now the match distance - 1 */\n code = d_code(dist);\n //Assert (code < D_CODES, \"bad d_code\");\n\n send_code(s, code, dtree); /* send the distance code */\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist[code];\n send_bits(s, dist, extra); /* send the extra distance bits */\n }\n } /* literal or match pair ? */\n\n /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n // \"pendingBuf overflow\");\n\n } while (lx < s.last_lit);\n }\n\n send_code(s, END_BLOCK, ltree);\n}\n\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n * and corresponding code. The length opt_len is updated; static_len is\n * also updated if stree is not null. The field max_code is set.\n */\nfunction build_tree(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var elems = desc.stat_desc.elems;\n var n, m; /* iterate over heap elements */\n var max_code = -1; /* largest code with non zero frequency */\n var node; /* new node being created */\n\n /* Construct the initial heap, with least frequent element in\n * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n * heap[0] is not used.\n */\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n\n for (n = 0; n < elems; n++) {\n if (tree[n * 2]/*.Freq*/ !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n\n } else {\n tree[n * 2 + 1]/*.Len*/ = 0;\n }\n }\n\n /* The pkzip format requires that at least one distance code exists,\n * and that at least one bit should be sent even if there is only one\n * possible code. So to avoid special checks later on we force at least\n * two codes of non zero frequency.\n */\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);\n tree[node * 2]/*.Freq*/ = 1;\n s.depth[node] = 0;\n s.opt_len--;\n\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1]/*.Len*/;\n }\n /* node is 0 or 1 so it does not have extra bits */\n }\n desc.max_code = max_code;\n\n /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n * establish sub-heaps of increasing lengths:\n */\n for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }\n\n /* Construct the Huffman tree by repeatedly combining the least two\n * frequent nodes.\n */\n node = elems; /* next internal node of the tree */\n do {\n //pqremove(s, tree, n); /* n = node of least frequency */\n /*** pqremove ***/\n n = s.heap[1/*SMALLEST*/];\n s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];\n pqdownheap(s, tree, 1/*SMALLEST*/);\n /***/\n\n m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */\n\n s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */\n s.heap[--s.heap_max] = m;\n\n /* Create a new node father of n and m */\n tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;\n\n /* and insert the new node in the heap */\n s.heap[1/*SMALLEST*/] = node++;\n pqdownheap(s, tree, 1/*SMALLEST*/);\n\n } while (s.heap_len >= 2);\n\n s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];\n\n /* At this point, the fields freq and dad are set. We can now\n * generate the bit lengths.\n */\n gen_bitlen(s, desc);\n\n /* The field len is now set, we can generate the bit codes */\n gen_codes(tree, max_code, s.bl_count);\n}\n\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nfunction scan_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n s.bl_tree[curlen * 2]/*.Freq*/ += count;\n\n } else if (curlen !== 0) {\n\n if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }\n s.bl_tree[REP_3_6 * 2]/*.Freq*/++;\n\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;\n\n } else {\n s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;\n }\n\n count = 0;\n prevlen = curlen;\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nfunction send_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n /* tree[max_code+1].Len = -1; */ /* guard already set */\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);\n\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n //Assert(count >= 3 && count <= 6, \" 3_6?\");\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nfunction build_bl_tree(s) {\n var max_blindex; /* index of last bit length code of non zero freq */\n\n /* Determine the bit length frequencies for literal and distance trees */\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n\n /* Build the bit length tree: */\n build_tree(s, s.bl_desc);\n /* opt_len now includes the length of the tree representations, except\n * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n */\n\n /* Determine the number of bit length codes to send. The pkzip format\n * requires that at least 4 bit length codes be sent. (appnote.txt says\n * 3 but the actual value used is 4.)\n */\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {\n break;\n }\n }\n /* Update opt_len to include the bit length tree and counts */\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n //Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n // s->opt_len, s->static_len));\n\n return max_blindex;\n}\n\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nfunction send_all_trees(s, lcodes, dcodes, blcodes)\n// deflate_state *s;\n// int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n var rank; /* index in bl_order */\n\n //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n // \"too many codes\");\n //Tracev((stderr, \"\\nbl counts: \"));\n send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */\n for (rank = 0; rank < blcodes; rank++) {\n //Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);\n }\n //Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */\n //Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */\n //Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n}\n\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n * a) There are no non-portable control characters belonging to the\n * \"black list\" (0..6, 14..25, 28..31).\n * b) There is at least one printable character belonging to the\n * \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n * \"gray list\" that is ignored in this detection algorithm:\n * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nfunction detect_data_type(s) {\n /* black_mask is the bit mask of black-listed bytes\n * set bits 0..6, 14..25, and 28..31\n * 0xf3ffc07f = binary 11110011111111111100000001111111\n */\n var black_mask = 0xf3ffc07f;\n var n;\n\n /* Check for non-textual (\"black-listed\") bytes. */\n for (n = 0; n <= 31; n++, black_mask >>>= 1) {\n if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {\n return Z_BINARY;\n }\n }\n\n /* Check for textual (\"white-listed\") bytes. */\n if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||\n s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n }\n\n /* There are no \"black-listed\" or \"white-listed\" bytes:\n * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n */\n return Z_BINARY;\n}\n\n\nvar static_init_done = false;\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nfunction _tr_init(s)\n{\n\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n /* Initialize the first block of the first file: */\n init_block(s);\n}\n\n\n/* ===========================================================================\n * Send a stored block\n */\nfunction _tr_stored_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */\n copy_block(s, buf, stored_len, true); /* with header */\n}\n\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nfunction _tr_align(s) {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree);\n bi_flush(s);\n}\n\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and output the encoded block to the zip file.\n */\nfunction _tr_flush_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block, or NULL if too old */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n var opt_lenb, static_lenb; /* opt_len and static_len in bytes */\n var max_blindex = 0; /* index of last bit length code of non zero freq */\n\n /* Build the Huffman trees unless a stored block is forced */\n if (s.level > 0) {\n\n /* Check if the file is binary or text */\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n\n /* Construct the literal and distance trees */\n build_tree(s, s.l_desc);\n // Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n\n build_tree(s, s.d_desc);\n // Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n /* At this point, opt_len and static_len are the total bit lengths of\n * the compressed block data, excluding the tree representations.\n */\n\n /* Build the bit length tree for the above two trees, and get the index\n * in bl_order of the last bit length code to send.\n */\n max_blindex = build_bl_tree(s);\n\n /* Determine the best encoding. Compute the block lengths in bytes. */\n opt_lenb = (s.opt_len + 3 + 7) >>> 3;\n static_lenb = (s.static_len + 3 + 7) >>> 3;\n\n // Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n // s->last_lit));\n\n if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }\n\n } else {\n // Assert(buf != (char*)0, \"lost buf\");\n opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n }\n\n if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {\n /* 4: two words for the lengths */\n\n /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n * Otherwise we can't have processed more than WSIZE input bytes since\n * the last block flush, because compression would have been\n * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n * transform a block into a stored block.\n */\n _tr_stored_block(s, buf, stored_len, last);\n\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree, static_dtree);\n\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n // Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n /* The above check is made mod 2^32, for files larger than 512 MB\n * and uLong implemented on 32 bits.\n */\n init_block(s);\n\n if (last) {\n bi_windup(s);\n }\n // Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n // s->compressed_len-7*last));\n}\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nfunction _tr_tally(s, dist, lc)\n// deflate_state *s;\n// unsigned dist; /* distance of matched string */\n// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n //var out_length, in_length, dcode;\n\n s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;\n s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;\n\n s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;\n s.last_lit++;\n\n if (dist === 0) {\n /* lc is the unmatched char */\n s.dyn_ltree[lc * 2]/*.Freq*/++;\n } else {\n s.matches++;\n /* Here, lc is the match length - MIN_MATCH */\n dist--; /* dist = match distance - 1 */\n //Assert((ush)dist < (ush)MAX_DIST(s) &&\n // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n // (ush)d_code(dist) < (ush)D_CODES, \"_tr_tally: bad match\");\n\n s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;\n s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n\n//#ifdef TRUNCATE_BLOCK\n// /* Try to guess if it is profitable to stop the current block here */\n// if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {\n// /* Compute an upper bound for the compressed length */\n// out_length = s.last_lit*8;\n// in_length = s.strstart - s.block_start;\n//\n// for (dcode = 0; dcode < D_CODES; dcode++) {\n// out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);\n// }\n// out_length >>>= 3;\n// //Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n// // s->last_lit, in_length, out_length,\n// // 100L - out_length*100L/in_length));\n// if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {\n// return true;\n// }\n// }\n//#endif\n\n return (s.last_lit === s.lit_bufsize - 1);\n /* We avoid equality with lit_bufsize because of wraparound at 64K\n * on 16 bit machines and because stored blocks are restricted to\n * 64K-1 bytes.\n */\n}\n\nexports._tr_init = _tr_init;\nexports._tr_stored_block = _tr_stored_block;\nexports._tr_flush_block = _tr_flush_block;\nexports._tr_tally = _tr_tally;\nexports._tr_align = _tr_align;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/trees.js\n// module id = 27\n// module chunks = 0","'use strict';\n\n\nvar zlib_inflate = require('./zlib/inflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar c = require('./zlib/constants');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\nvar GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = utils.assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== c.Z_OK) {\n throw new Error(msg[status]);\n }\n\n this.header = new GZheader();\n\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = strings.binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */\n\n if (status === c.Z_NEED_DICT && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = strings.string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = zlib_inflate.inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === c.Z_BUF_ERROR && allowBufError === true) {\n status = c.Z_OK;\n allowBufError = false;\n }\n\n if (status !== c.Z_STREAM_END && status !== c.Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);\n\n if (status === c.Z_STREAM_END) {\n _mode = c.Z_FINISH;\n }\n\n // Finalize on the last chunk.\n if (_mode === c.Z_FINISH) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === c.Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === c.Z_SYNC_FLUSH) {\n this.onEnd(c.Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === c.Z_OK) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 aligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction inflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg || msg[inflator.err]; }\n\n return inflator.result;\n}\n\n\n/**\n * inflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n}\n\n\n/**\n * ungzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\nexports.Inflate = Inflate;\nexports.inflate = inflate;\nexports.inflateRaw = inflateRaw;\nexports.ungzip = inflate;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/inflate.js\n// module id = 28\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar inflate_fast = require('./inffast');\nvar inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_WBITS = MAX_WBITS;\n\n\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new utils.Buf16(320); /* temporary storage for code lengths */\n this.work = new utils.Buf16(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);\n state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\nfunction inflateInit(strm) {\n return inflateInit2(strm, DEF_WBITS);\n}\n\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new utils.Buf32(512);\n distfix = new utils.Buf32(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new utils.Buf8(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n utils.arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n utils.arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n utils.arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n utils.arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\nexports.inflateReset = inflateReset;\nexports.inflateReset2 = inflateReset2;\nexports.inflateResetKeep = inflateResetKeep;\nexports.inflateInit = inflateInit;\nexports.inflateInit2 = inflateInit2;\nexports.inflate = inflate;\nexports.inflateEnd = inflateEnd;\nexports.inflateGetHeader = inflateGetHeader;\nexports.inflateSetDictionary = inflateSetDictionary;\nexports.inflateInfo = 'pako inflate (from Nodeca project)';\n\n/* Not implemented\nexports.inflateCopy = inflateCopy;\nexports.inflateGetDictionary = inflateGetDictionary;\nexports.inflateMark = inflateMark;\nexports.inflatePrime = inflatePrime;\nexports.inflateSync = inflateSync;\nexports.inflateSyncPoint = inflateSyncPoint;\nexports.inflateUndermine = inflateUndermine;\n*/\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inflate.js\n// module id = 29\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// See state defs from inflate.js\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\nmodule.exports = function inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inffast.js\n// module id = 30\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\nmodule.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inftrees.js\n// module id = 31\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\nmodule.exports = GZheader;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/gzheader.js\n// module id = 32\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @protected\n */\nvar WeightDecoderRaw = /** @class */ (function () {\n function WeightDecoderRaw() {\n }\n WeightDecoderRaw.prototype.decode = function (data) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, new Float32Array(data.buffer, data.byteOffset, data.byteLength / 4)];\n });\n });\n };\n return WeightDecoderRaw;\n}());\nexports.default = WeightDecoderRaw;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/weight_decoder_raw.js\n// module id = 33\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @private\n */\nvar NOT_SCHEDULED = -1;\n/**\n * Schedule function which is called too much frequently.\n *\n * @private\n */\nvar DispatchScheduler = /** @class */ (function () {\n function DispatchScheduler() {\n this.scheduledCallbackId = NOT_SCHEDULED;\n }\n /**\n * Register scheduled function. If already other function is scheduled, it is canceled and dispatcher will dispatch only\n * function which is registered at last.\n * @param fn scheduled function\n */\n DispatchScheduler.prototype.request = function (fn) {\n var _this = this;\n this.fn = fn;\n if (this.scheduledCallbackId == NOT_SCHEDULED) {\n this.scheduledCallbackId = requestAnimationFrame(function () { return _this.forceDispatch(); });\n }\n };\n /**\n * Dispatch scheduled function just now. If no function is scheduled, dispatcher do nothing.\n */\n DispatchScheduler.prototype.forceDispatch = function () {\n if (this.scheduledCallbackId == NOT_SCHEDULED)\n return;\n this.cancel();\n this.fn();\n };\n /**\n * Cancel scheduled function. If no function is scheduled, dispatcher do nothing.\n */\n DispatchScheduler.prototype.cancel = function () {\n if (this.scheduledCallbackId == NOT_SCHEDULED)\n return;\n cancelAnimationFrame(this.scheduledCallbackId);\n this.scheduledCallbackId = NOT_SCHEDULED;\n };\n return DispatchScheduler;\n}());\nexports.default = DispatchScheduler;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/util/dispatch_scheduler.js\n// module id = 34\n// module chunks = 0","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @protected\n */\nfunction flatten(arr) {\n var result = [];\n for (var i = 0; i < arr.length; i++) {\n var v = arr[i];\n if (v instanceof Array) {\n result.splice(result.length, 0, flatten(v));\n }\n else {\n result[result.length] = v;\n }\n }\n return result;\n}\n/**\n * @protected\n */\nvar SymbolicTypedArray = /** @class */ (function () {\n /**\n * @protected\n */\n function SymbolicTypedArray(buffer, byteOffset, length, placeholderContext) {\n if (buffer === void 0) { buffer = null; }\n if (byteOffset === void 0) { byteOffset = 0; }\n if (placeholderContext === void 0) { placeholderContext = null; }\n this.placeholderContext = placeholderContext;\n this._byteOffset = byteOffset;\n this._buffer = buffer;\n if (buffer) {\n this._length = length === undefined ? (buffer.byteLength / this.BYTES_PER_ELEMENT) : length;\n }\n else {\n if (length === undefined)\n throw Error('\"butter\" or \"length\" must be specified.');\n this._length = length;\n }\n if (this.isDynamic) {\n if (!placeholderContext) {\n throw Error('PlaceholderContext must be required when SymbolicTypedArray is initialized as dynamic buffer view.');\n }\n }\n }\n Object.defineProperty(SymbolicTypedArray.prototype, \"buffer\", {\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n get: function () {\n if (!this._buffer)\n this._buffer = new ArrayBuffer(this.byteOffset + this.byteLength);\n return this._buffer;\n },\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n set: function (buffer) {\n this._buffer = buffer;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(SymbolicTypedArray.prototype, \"byteLength\", {\n /**\n * The length in bytes of the array.\n */\n get: function () {\n return this.length * this.BYTES_PER_ELEMENT;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(SymbolicTypedArray.prototype, \"offset\", {\n /**\n * The number in this buffer. Actual offset size is `(offset * SIZE_OF_FLOAT)`.\n */\n get: function () {\n return this.byteOffset / this.BYTES_PER_ELEMENT;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(SymbolicTypedArray.prototype, \"isDynamic\", {\n /**\n * @protected\n */\n get: function () {\n return (typeof this._byteOffset !== 'number' || typeof this._length !== 'number');\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(SymbolicTypedArray.prototype, \"length\", {\n /**\n * The number of elements in this buffer. Actual byte size is `(length * SIZE_OF_FLOAT)`.\n */\n get: function () {\n if (this.isDynamic) {\n return this.placeholderContext.resolve(this._length);\n }\n else {\n return this._length;\n }\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(SymbolicTypedArray.prototype, \"byteOffset\", {\n /**\n * The offset in bytes of the array.\n */\n get: function () {\n if (this.isDynamic) {\n return this.placeholderContext.resolve(this._byteOffset);\n }\n else {\n return this._byteOffset;\n }\n },\n enumerable: true,\n configurable: true\n });\n /**\n * Returns the this object after copying a section of the array identified by start and end\n * to the same array starting at position target\n * @param target If target is negative, it is treated as length+target where length is the\n * length of the array.\n * @param start If start is negative, it is treated as length+start. If end is negative, it\n * is treated as length+end.\n * @param end If not specified, length of the this object is used as its default value.\n */\n SymbolicTypedArray.prototype.copyWithin = function (target, start, end) {\n this.toActual().copyWithin(target, start, end);\n return this;\n };\n /**\n * Returns the this object after filling the section identified by start and end with value\n * @param value value to fill array section with\n * @param start index to start filling the array at. If start is negative, it is treated as\n * length+start where length is the length of the array.\n * @param end index to stop filling the array at. If end is negative, it is treated as\n * length+end.\n */\n SymbolicTypedArray.prototype.fill = function (value, start, end) {\n this.toActual().fill(value, start, end);\n return this;\n };\n /**\n * Returns the index of the first occurrence of a value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the\n * search starts at index 0.\n */\n SymbolicTypedArray.prototype.indexOf = function (searchElement, fromIndex) {\n return this.toActual().indexOf(searchElement, fromIndex);\n };\n /**\n * Adds all the elements of an array separated by the specified separator string.\n * @param separator A string used to separate one element of an array from the next in the\n * resulting String. If omitted, the array elements are separated with a comma.\n */\n SymbolicTypedArray.prototype.join = function (separator) {\n return this.toActual().join(separator);\n };\n /**\n * Returns the index of the last occurrence of a value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the\n * search starts at index 0.\n */\n SymbolicTypedArray.prototype.lastIndexOf = function (searchElement, fromIndex) {\n return this.toActual().lastIndexOf(searchElement, fromIndex);\n };\n /**\n * Sorts an array.\n * @param compareFn The name of the function used to determine the order of the elements. If\n * omitted, the elements are sorted in ascending, ASCII character order.\n */\n SymbolicTypedArray.prototype.sort = function (compareFn) {\n this.toActual().sort(compareFn);\n return this;\n };\n SymbolicTypedArray.prototype.includes = function (searchElement, fromIndex) {\n return this.toActual().includes(searchElement, fromIndex);\n };\n /**\n * Sets a value or an array of values.\n * @param array A typed or untyped array of values to set.\n * @param offset The index in the current array at which the values are to be written.\n */\n SymbolicTypedArray.prototype.set = function (array, offset) {\n return this.toActual().set(flatten(array), offset);\n };\n /**\n * Converts a number to a string by using the current locale.\n */\n SymbolicTypedArray.prototype.toLocaleString = function () {\n return this.toActual().toLocaleString();\n };\n /**\n * Returns a string representation of an array.\n */\n SymbolicTypedArray.prototype.toString = function () {\n return this.toActual().toString();\n };\n /** @protected */\n SymbolicTypedArray.prototype[Symbol.iterator] = function () {\n return this.toActual()[Symbol.iterator]();\n };\n /**\n * Returns an iterable of key, value pairs for every entry in the array\n */\n SymbolicTypedArray.prototype.entries = function () {\n return this.toActual().entries();\n };\n /**\n * Returns an iterable of keys in the array\n */\n SymbolicTypedArray.prototype.keys = function () {\n return this.toActual().keys();\n };\n /**\n * Returns an iterable of values in the array\n */\n SymbolicTypedArray.prototype.values = function () {\n return this.toActual().values();\n };\n return SymbolicTypedArray;\n}());\nexports.SymbolicTypedArray = SymbolicTypedArray;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/symbolic_typed_array/symbolic_typed_array.js\n// module id = 35\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar localforage = require(\"localforage\");\nvar get_weight_decoder_1 = require(\"../decoder/get_weight_decoder\");\nvar fetch_1 = require(\"../fetch\");\nvar placeholder_1 = require(\"../placeholder\");\nvar symbolic_float32array_1 = require(\"../symbolic_typed_array/symbolic_float32array\");\nvar descriptor_runner_1 = require(\"./descriptor_runner\");\n/**\n * @protected\n */\nvar DescriptorRunnerWebassembly = /** @class */ (function (_super) {\n __extends(DescriptorRunnerWebassembly, _super);\n function DescriptorRunnerWebassembly() {\n var _this = _super.call(this) || this;\n _this.backendName = 'webassembly';\n _this.worker_promise_reject_func = null;\n _this.worker_initial_error = null;\n if (typeof Worker === 'undefined')\n throw new Error('WebWorker is needed for WebAssembly backend');\n if (typeof WebAssembly !== 'object') {\n console.warn('WebAssembly is not supported on this browser, trying to use asm.js code');\n }\n return _this;\n }\n DescriptorRunnerWebassembly.checkAvailability = function () {\n return 'Worker' in window;\n };\n DescriptorRunnerWebassembly.prototype.init = function () {\n if (!DescriptorRunnerWebassembly.checkAvailability())\n throw Error('WebAssembly backend is not supported in this browser.');\n //nothing to do\n return Promise.resolve();\n };\n // https://qiita.com/sounisi5011/items/e24d0e1dfd71c5dd528e\n // helper function to transform relative path to absolute path\n // FIXME: use URL constructor. URL does not work on IE11, so polyfill is also needed to use it.\n DescriptorRunnerWebassembly.prototype.absolutePath = function (path) {\n var e = document.createElement('span');\n e.insertAdjacentHTML('beforeend', '');\n return e.firstChild.href;\n };\n DescriptorRunnerWebassembly.prototype.setDescriptorAndParameters = function (descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var kernel_backend, worker_entry_js_path, worker_src_fetch, worker_src, map_aux_file_src;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.descriptor = descriptor;\n this.placeholderContext = new placeholder_1.default(this.descriptor.placeholders);\n kernel_backend = typeof WebAssembly === 'object' ? 'webassembly' : 'asmjs';\n if (window.navigator.userAgent.indexOf('iPhone OS 11_2') >= 0) {\n // workaround for bug in webassembly\n // https://bugs.webkit.org/show_bug.cgi?id=181781\n kernel_backend = 'asmjs';\n }\n worker_entry_js_path = this.directory + \"/kernels_\" + kernel_backend + \".js\";\n worker_entry_js_path = fetch_1.transformUrl(worker_entry_js_path);\n this.worker_entry_js_path = worker_entry_js_path;\n return [4 /*yield*/, fetch(this.worker_entry_js_path)];\n case 1:\n worker_src_fetch = _a.sent();\n return [4 /*yield*/, worker_src_fetch.text()];\n case 2:\n worker_src = _a.sent();\n map_aux_file_src = function (basename, key) {\n var file_abs = _this.absolutePath(_this.directory + \"/\" + basename);\n var file_abs_transformed = fetch_1.transformUrl(file_abs); // absolute path is given\n worker_src = worker_src.replace(key, file_abs_transformed);\n };\n if (kernel_backend === 'webassembly') {\n map_aux_file_src('kernels_webassembly.wasm', 'WEBDNN_URL_KERNELS_WASM');\n }\n else {\n map_aux_file_src('kernels_asmjs.js.mem', 'WEBDNN_URL_KERNELS_ASMJS_MEM');\n }\n return [4 /*yield*/, this.compile(worker_src)];\n case 3:\n _a.sent();\n return [4 /*yield*/, this.loadWeights(new Uint8Array(parameters))];\n case 4:\n _a.sent();\n return [4 /*yield*/, this.getInputViews()];\n case 5:\n //assign buffer to input/output buffer view\n (_a.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 6:\n (_a.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Fetch graph descriptor from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @protected\n */\n DescriptorRunnerWebassembly.prototype.fetchDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.directory = directory;\n return [4 /*yield*/, fetch_1.default(directory + \"/graph_\" + this.backendName + \".json\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, res.json()];\n }\n });\n });\n };\n /**\n * Fetch parameter files from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @param progressCallback callback which is called to notice the loading is progressing.\n * @protected\n */\n DescriptorRunnerWebassembly.prototype.fetchParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var weight_url, weight_fetch;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n weight_url = directory + \"/weight_\" + this.backendName + \".bin\";\n return [4 /*yield*/, fetch_1.default(weight_url)];\n case 1:\n weight_fetch = _a.sent();\n return [2 /*return*/, fetch_1.readArrayBufferProgressively(weight_fetch, progressCallback)];\n }\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebassembly.prototype.restoreCachedDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n this.directory = directory;\n return [2 /*return*/, localforage.getItem(directory + \"_\" + this.backendName + \"_descriptor\").catch(function () { return null; })];\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebassembly.prototype.restoreCachedParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var parameter;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, localforage.getItem(directory + \"_\" + this.backendName + \"_parameters\").catch(function () { return null; })];\n case 1:\n parameter = _a.sent();\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return [2 /*return*/, parameter];\n }\n });\n });\n };\n /**\n * save cache\n */\n DescriptorRunnerWebassembly.prototype.saveCache = function (directory, descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, Promise.all([\n localforage.setItem(directory + \"_\" + this.backendName + \"_descriptor\", descriptor),\n localforage.setItem(directory + \"_\" + this.backendName + \"_parameters\", parameters)\n ])];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n ;\n DescriptorRunnerWebassembly.prototype.setPlaceholderValue = function (values) {\n return __awaiter(this, void 0, void 0, function () {\n var placeholderContext, descriptor, unresolvedValueLists, metaBufferFillList, _loop_1, kernel_order, dynamicBufferSize;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return [2 /*return*/];\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n descriptor = this.descriptor;\n unresolvedValueLists = descriptor.unresolved_value_lists;\n metaBufferFillList = [];\n _loop_1 = function (kernel_order) {\n var unresolvedValueList = unresolvedValueLists[kernel_order];\n unresolvedValueList.forEach(function (offset_placeholder) {\n var resolved_value = placeholderContext.resolve(offset_placeholder.placeholder);\n metaBufferFillList.push(kernel_order, offset_placeholder.offset, resolved_value);\n });\n };\n for (kernel_order = 0; kernel_order < unresolvedValueLists.length; kernel_order++) {\n _loop_1(kernel_order);\n }\n return [4 /*yield*/, this.getInputViews()];\n case 1:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 2:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n dynamicBufferSize = this.placeholderContext.resolve(this.descriptor.memory_layout.dynamic.size);\n return [4 /*yield*/, this.setPlaceholderValueWorker(dynamicBufferSize, new Int32Array(metaBufferFillList))];\n case 3:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerWebassembly.prototype.setPlaceholderValueWorker = function (dynamicBufferSize, metaBufferFillArray) {\n if (!this.worker)\n throw Error(\"Worker is not initialized\");\n var worker = this.worker;\n return new Promise(function (resolve, reject) {\n worker.onmessage = function (event) {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n worker.postMessage({ type: 'set_dynamic_buffer', size: dynamicBufferSize, data: metaBufferFillArray });\n });\n };\n DescriptorRunnerWebassembly.prototype.compile = function (worker_src) {\n var _this = this;\n var blob = new Blob([worker_src], { type: \"text/javascript\" });\n var blob_url = URL.createObjectURL(blob);\n var worker = new Worker(blob_url);\n worker.onerror = function (event) {\n console.error(event);\n // console.error('Worker Exception: ' + event.message);\n if (_this.worker_promise_reject_func) {\n _this.worker_promise_reject_func(event);\n }\n else {\n _this.worker_initial_error = event;\n }\n };\n var promise = new Promise(function (resolve, reject) {\n // occurs when this.worker_entry_js_path is 404\n if (_this.worker_initial_error)\n return reject(_this.worker_initial_error);\n _this.worker_promise_reject_func = reject;\n worker.onmessage = function (event) {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.error(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n });\n this.worker = worker;\n return promise;\n };\n DescriptorRunnerWebassembly.prototype.loadWeights = function (weightsData) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var decoder, weight_data, worker, promise;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.worker)\n throw new Error('Worker is not initialized');\n decoder = get_weight_decoder_1.default(this.descriptor.weight_encoding);\n return [4 /*yield*/, decoder.decode(weightsData)];\n case 1:\n weight_data = _a.sent();\n worker = this.worker;\n promise = new Promise(function (resolve, reject) {\n _this.worker_promise_reject_func = reject;\n worker.onmessage = function (event) {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n worker.postMessage({ type: 'weight', data: weight_data }, [weight_data.buffer]);\n });\n return [2 /*return*/, promise];\n }\n });\n });\n };\n DescriptorRunnerWebassembly.prototype.getInputViews = function () {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, 0, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n };\n DescriptorRunnerWebassembly.prototype.getOutputViews = function () {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, 0, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n };\n DescriptorRunnerWebassembly.prototype.run = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var placeholderContext, descriptor, worker, promise;\n return __generator(this, function (_a) {\n // if (this._running) throw new Error('Calling another run() while running.');\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.worker)\n throw new Error('Worker is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error('Not all placeholder is resolved');\n placeholderContext = this.placeholderContext;\n descriptor = this.descriptor;\n worker = this.worker;\n promise = new Promise(function (resolve, reject) {\n // TODO: better way not to generate function on every run\n _this.worker_promise_reject_func = reject;\n worker.onmessage = function (event) {\n if (Array.isArray(event.data)) {\n for (var i = 0; i < event.data.length; i++) {\n _this.outputs[i].set(event.data[i]);\n }\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n var allocations = [descriptor.memory_layout.static.allocations, descriptor.memory_layout.dynamic.allocations];\n var inputs = [];\n for (var i = 0; i < descriptor.inputs.length; i++) {\n for (var allocation_space = 0; allocation_space < 2; allocation_space++) {\n var var_alloc = allocations[allocation_space][descriptor.inputs[i]];\n if (var_alloc) {\n var symAb = _this.inputs[i];\n inputs.push({\n space: allocation_space,\n offset: placeholderContext.resolve(var_alloc.offset),\n size: symAb.length,\n data: symAb.toActual()\n });\n break;\n }\n }\n }\n var outputs = [];\n for (var i = 0; i < descriptor.outputs.length; i++) {\n for (var allocation_space = 0; allocation_space < 2; allocation_space++) {\n var var_alloc = allocations[allocation_space][descriptor.outputs[i]];\n if (var_alloc) {\n var symAb = _this.outputs[i];\n outputs.push({\n space: allocation_space,\n offset: placeholderContext.resolve(var_alloc.offset),\n size: symAb.length\n });\n break;\n }\n }\n }\n worker.postMessage({ type: 'run', inputs: inputs, outputs: outputs });\n });\n return [2 /*return*/, promise];\n });\n });\n };\n return DescriptorRunnerWebassembly;\n}(descriptor_runner_1.DescriptorRunner));\nexports.default = DescriptorRunnerWebassembly;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webassembly.js\n// module id = 36\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar localforage = require(\"localforage\");\nvar buffer_webgl_1 = require(\"../buffer/buffer_webgl\");\nvar get_weight_decoder_1 = require(\"../decoder/get_weight_decoder\");\nvar fetch_1 = require(\"../fetch\");\nvar placeholder_1 = require(\"../placeholder\");\nvar symbolic_float32array_1 = require(\"../symbolic_typed_array/symbolic_float32array\");\nvar webdnn_1 = require(\"../webdnn\");\nvar webgl_handler_1 = require(\"../webgl_handler\");\nvar descriptor_runner_1 = require(\"./descriptor_runner\");\n// [x y u v] * [upper-left, lower-left, upper-right, lower-right]\n/**\n * @protected\n */\nvar vertexArray = new Float32Array([\n -1, +1,\n -1, -1,\n +1, +1,\n +1, -1,\n]);\n/**\n * @protected\n */\nvar DescriptorRunnerWebGL = /** @class */ (function (_super) {\n __extends(DescriptorRunnerWebGL, _super);\n function DescriptorRunnerWebGL() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.backendName = 'webgl';\n return _this;\n }\n DescriptorRunnerWebGL.checkAvailability = function () {\n return webgl_handler_1.default.checkAvailability();\n };\n DescriptorRunnerWebGL.prototype.init = function () {\n return __awaiter(this, void 0, void 0, function () {\n var vertexBuffer;\n return __generator(this, function (_a) {\n if (!DescriptorRunnerWebGL.checkAvailability())\n throw Error('WebGL backend is not supported in this browser.');\n this.handler = webgl_handler_1.default.getInstance();\n vertexBuffer = this.handler.createArrayBuffer(vertexArray);\n this.handler.bindArrayBuffer(vertexBuffer);\n this.buffers = new Map();\n return [2 /*return*/];\n });\n });\n };\n DescriptorRunnerWebGL.prototype.fetchDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fetch_1.default(directory + \"/graph_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \".json\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, res.json()];\n }\n });\n });\n };\n DescriptorRunnerWebGL.prototype.fetchParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fetch_1.default(directory + \"/weight_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \".bin\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, fetch_1.readArrayBufferProgressively(res, progressCallback)];\n }\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebGL.prototype.restoreCachedDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, localforage.getItem(directory + \"_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \"_descriptor\").catch(function () { return null; })];\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebGL.prototype.restoreCachedParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var parameter;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, localforage.getItem(directory + \"_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \"_parameters\").catch(function () { return null; })];\n case 1:\n parameter = _a.sent();\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return [2 /*return*/, parameter];\n }\n });\n });\n };\n /**\n * save cache\n */\n DescriptorRunnerWebGL.prototype.saveCache = function (directory, descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, Promise.all([\n localforage.setItem(directory + \"_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \"_descriptor\", descriptor),\n localforage.setItem(directory + \"_\" + this.backendName + \"_\" + this.handler.MAX_TEXTURE_SIZE + \"_parameters\", parameters)\n ])];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n ;\n DescriptorRunnerWebGL.prototype.setDescriptorAndParameters = function (descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.setDescriptor(descriptor)];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.compile()];\n case 2:\n _a.sent();\n return [4 /*yield*/, this.initializeStaticBuffer(parameters)];\n case 3:\n _a.sent();\n if (!(this.placeholderContext && this.placeholderContext.isResolved)) return [3 /*break*/, 5];\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 4:\n _a.sent();\n _a.label = 5;\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerWebGL.prototype.initializeStaticBuffer = function (weightRawArray) {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, decoder, weight, buffers, mapping;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n descriptor = this.descriptor;\n decoder = get_weight_decoder_1.default(this.descriptor.weight_encoding);\n return [4 /*yield*/, decoder.decode(new Uint8Array(weightRawArray))];\n case 1:\n weight = _a.sent();\n buffers = this.buffers;\n mapping = descriptor.memory_layout.mapping;\n Object.entries(descriptor.memory_layout.static.allocations)\n .forEach(function (_a) {\n var name = _a[0], _b = _a[1], width = _b.width, height = _b.height, size = _b.size, channel_mode = _b.channel_mode;\n buffers.set(name, new buffer_webgl_1.default(size * Float32Array.BYTES_PER_ELEMENT, width, height, name, null, channel_mode));\n });\n Object.entries(descriptor.constants_map)\n .forEach(function (_a) {\n var name = _a[0], _b = _a[1], size = _b.size, byte_offset = _b.byte_offset;\n buffers.get(name).array.set(new Float32Array(weight.buffer, byte_offset, size));\n });\n return [4 /*yield*/, this.getInputViews()];\n case 2:\n (_a.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = buffers.get(mapping[view.name]).getWriteView(0, view.length, Float32Array).buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 3:\n (_a.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = buffers.get(mapping[view.name]).getReadView(0, view.length, Float32Array).buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerWebGL.prototype.initializeDynamicBuffer = function () {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, placeholderContext, buffers, mapping;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n if (!this.placeholderContext)\n throw Error(\"PlaceholderContext is not initialized.\");\n descriptor = this.descriptor;\n placeholderContext = this.placeholderContext;\n buffers = this.buffers;\n mapping = descriptor.memory_layout.mapping;\n Object.entries(descriptor.memory_layout.dynamic.allocations)\n .forEach(function (_a) {\n var name = _a[0], _b = _a[1], width = _b.width, height = _b.height, size = _b.size, channel_mode = _b.channel_mode;\n buffers.set(name, new buffer_webgl_1.default(placeholderContext.resolve(size) * Float32Array.BYTES_PER_ELEMENT, placeholderContext.resolve(width), placeholderContext.resolve(height), name, null, channel_mode));\n });\n return [4 /*yield*/, this.getInputViews()];\n case 1:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = buffers.get(mapping[view.name]).getWriteView(0, placeholderContext.resolve(view.length), Float32Array).buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 2:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = buffers.get(mapping[view.name]).getReadView(0, placeholderContext.resolve(view.length), Float32Array).buffer;\n });\n this.buildPipeline();\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerWebGL.prototype.setDescriptor = function (descriptor) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n this.descriptor = descriptor;\n //reset all datum depend on old descriptor\n this.placeholderContext = new placeholder_1.default(descriptor.placeholders);\n return [2 /*return*/];\n });\n });\n };\n DescriptorRunnerWebGL.prototype.compile = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var descriptor;\n return __generator(this, function (_a) {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n descriptor = this.descriptor;\n this.programs = new Map();\n this.vertexShader = this.handler.createVertexShader(\"\\n precision highp float;\\n attribute vec2 _xy;\\n void main() { \\n gl_Position = vec4(_xy, 0, 1); \\n }\\n \");\n Object.keys(descriptor.shader_sources)\n .forEach(function (name) {\n var fragmentShader = _this.handler.createFragmentShader(descriptor.shader_sources[name]);\n var program = _this.handler.createProgram(_this.vertexShader, fragmentShader);\n _this.programs.set(name, program);\n });\n return [2 /*return*/];\n });\n });\n };\n DescriptorRunnerWebGL.prototype.setPlaceholderValue = function (values) {\n return __awaiter(this, void 0, void 0, function () {\n var placeholderContext;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return [2 /*return*/];\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 1:\n _a.sent();\n // resolve placeholders in execution info\n if (Object.keys(this.descriptor.placeholders).length > 0)\n throw Error('Currently, WebGL backend doesn\\'t support Placeholder feature.');\n return [2 /*return*/];\n }\n });\n });\n };\n DescriptorRunnerWebGL.prototype.getInputViews = function () {\n var _this = this;\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n var mapping = this.descriptor.memory_layout.mapping;\n this.inputs = descriptor.inputs.map(function (name) {\n var view = new symbolic_float32array_1.default(null, 0, _this.buffers.get(mapping[name]).length, placeholderContext);\n view.name = name;\n return view;\n });\n return this.inputs;\n };\n DescriptorRunnerWebGL.prototype.getOutputViews = function () {\n var _this = this;\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n var mapping = this.descriptor.memory_layout.mapping;\n this.outputs = descriptor.outputs.map(function (name) {\n var view = new symbolic_float32array_1.default(null, 0, _this.buffers.get(mapping[name]).length, placeholderContext);\n view.name = name;\n return view;\n });\n return this.outputs;\n };\n DescriptorRunnerWebGL.prototype.buildPipeline = function () {\n var _this = this;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(\"Not all placeholders are resolved: \" + this.placeholderContext);\n var gl = this.handler.gl;\n var buffers = this.buffers;\n var mapping = this.descriptor.memory_layout.mapping;\n var referenceCount = new Map();\n this.runtimeInfo = {\n inputs: this.getInputViews().map(function (view) { return buffers.get(mapping[view.name]); }),\n outputs: this.getOutputViews().map(function (view) { return buffers.get(mapping[view.name]); }),\n programs: this.descriptor.exec_infos.map(function (execInfo) {\n // inputs\n var inputs = execInfo.inputs.map(function (input) {\n var buffer = buffers.get(mapping[input.variable_name]);\n if (!referenceCount.has(buffer))\n referenceCount.set(buffer, 0);\n referenceCount.set(buffer, referenceCount.get(buffer) + 1);\n return {\n buffer: buffer,\n uniformIndex: input.value\n };\n });\n //output\n var output = buffers.get(mapping[execInfo.output]);\n // shader\n var program = _this.programs.get(execInfo.shader_name);\n _this.handler.useProgram(program);\n // uniforms\n var uniforms = Object.keys(execInfo.uniforms).map(function (name) {\n var _a = execInfo.uniforms[name], type = _a.type, value = _a.value;\n switch (type) {\n case 'int':\n return {\n func: gl.uniform1i,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'float':\n return {\n func: gl.uniform1f,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec2':\n return {\n func: gl.uniform2fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec3':\n return {\n func: gl.uniform3fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec4':\n return {\n func: gl.uniform4fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec2':\n return {\n func: gl.uniform2iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec3':\n return {\n func: gl.uniform3iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec4':\n return {\n func: gl.uniform4iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'sampler2D':\n return {\n func: gl.uniform1i,\n args: [gl.getUniformLocation(program, name), value]\n };\n default:\n throw TypeError(\"Incompatible type for uniform parameter: \" + type);\n }\n });\n // attributes\n var xyAttribLoc = gl.getAttribLocation(program, '_xy');\n // run\n return {\n program: program,\n frameBuffer: _this.handler.createFrameBuffer(),\n name: execInfo.shader_name,\n width: output.textureWidth,\n height: output.textureHeight,\n inputs: inputs,\n output: output,\n xyAttribLoc: xyAttribLoc,\n uniforms: uniforms,\n disposable: []\n };\n })\n };\n var _loop_1 = function (runtimeProgramInfo) {\n runtimeProgramInfo.inputs.forEach(function (_a) {\n var buffer = _a.buffer;\n var count = referenceCount.get(buffer) - 1;\n if (count == 0) {\n runtimeProgramInfo.disposable.push(buffer);\n }\n referenceCount.set(buffer, count);\n });\n };\n for (var _i = 0, _a = this.runtimeInfo.programs; _i < _a.length; _i++) {\n var runtimeProgramInfo = _a[_i];\n _loop_1(runtimeProgramInfo);\n }\n };\n DescriptorRunnerWebGL.prototype.run = function () {\n return __awaiter(this, void 0, void 0, function () {\n var gl, runtimeInfo, _i, _a, buffer, records, totalElapsedTime_1, _b, _c, runtimeProgramInfo, start, _d, _e, _f, buffer, uniformIndex, _g, _h, uniform, elapsedTime, xs, _j, _k, buffer, y, summary, _l, _m, runtimeProgramInfo, _o, _p, _q, buffer, uniformIndex, _r, _s, uniform, _t, _u, buffer, _v, _w, buffer;\n return __generator(this, function (_x) {\n switch (_x.label) {\n case 0:\n // if (this._running) throw new Error('Calling another run() while running.');\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(\"Not all placeholders are resolved: \" + this.placeholderContext);\n gl = this.handler.gl;\n runtimeInfo = this.runtimeInfo;\n if (!(this.runtimeInfo.programs.length > 0)) return [3 /*break*/, 29];\n _i = 0, _a = runtimeInfo.inputs;\n _x.label = 1;\n case 1:\n if (!(_i < _a.length)) return [3 /*break*/, 4];\n buffer = _a[_i];\n return [4 /*yield*/, buffer.syncWriteViews()];\n case 2:\n _x.sent();\n _x.label = 3;\n case 3:\n _i++;\n return [3 /*break*/, 1];\n case 4:\n if (!webdnn_1.getConfiguration('DEBUG', false)) return [3 /*break*/, 18];\n records = [];\n totalElapsedTime_1 = 0;\n _b = 0, _c = runtimeInfo.programs;\n _x.label = 5;\n case 5:\n if (!(_b < _c.length)) return [3 /*break*/, 17];\n runtimeProgramInfo = _c[_b];\n start = performance.now();\n this.handler.bindFrameBuffer(runtimeProgramInfo.frameBuffer, runtimeProgramInfo.width, runtimeProgramInfo.height);\n _d = 0, _e = runtimeProgramInfo.inputs;\n _x.label = 6;\n case 6:\n if (!(_d < _e.length)) return [3 /*break*/, 9];\n _f = _e[_d], buffer = _f.buffer, uniformIndex = _f.uniformIndex;\n return [4 /*yield*/, buffer.bindToReadTexture(uniformIndex)];\n case 7:\n _x.sent();\n _x.label = 8;\n case 8:\n _d++;\n return [3 /*break*/, 6];\n case 9:\n // output\n runtimeProgramInfo.output.bindToDrawTexture();\n // shader\n this.handler.useProgram(runtimeProgramInfo.program);\n // uniforms\n for (_g = 0, _h = runtimeProgramInfo.uniforms; _g < _h.length; _g++) {\n uniform = _h[_g];\n uniform.func.apply(gl, uniform.args);\n }\n // attribute\n gl.vertexAttribPointer(runtimeProgramInfo.xyAttribLoc, 2, gl.FLOAT, true, 8, 0);\n gl.enableVertexAttribArray(runtimeProgramInfo.xyAttribLoc);\n // run\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertexArray.length / 2);\n return [4 /*yield*/, this.handler.waitForComplete()];\n case 10:\n _x.sent();\n elapsedTime = performance.now() - start;\n totalElapsedTime_1 += elapsedTime;\n xs = [];\n _j = 0, _k = runtimeProgramInfo.inputs;\n _x.label = 11;\n case 11:\n if (!(_j < _k.length)) return [3 /*break*/, 14];\n buffer = _k[_j].buffer;\n buffer.unbindFromReadTexture();\n return [4 /*yield*/, buffer.syncReadViews()];\n case 12:\n _x.sent();\n xs.push(buffer.array.slice());\n _x.label = 13;\n case 13:\n _j++;\n return [3 /*break*/, 11];\n case 14:\n runtimeProgramInfo.output.unbindFromDrawTexture();\n return [4 /*yield*/, runtimeProgramInfo.output.syncReadViews()];\n case 15:\n _x.sent();\n y = runtimeProgramInfo.output.array.slice();\n records.push({\n 'Kernel': runtimeProgramInfo.name,\n 'Elapsed time [ms]': elapsedTime,\n 'xs': xs,\n 'y': y\n });\n _x.label = 16;\n case 16:\n _b++;\n return [3 /*break*/, 5];\n case 17:\n summary = Array.from(Object.values(records.reduce(function (summary, record) {\n if (!(record['Kernel'] in summary)) {\n summary[record['Kernel']] = {\n 'Kernel': record['Kernel'],\n 'Count': 0,\n 'Elapsed time [ms]': 0,\n };\n }\n summary[record['Kernel']]['Count']++;\n summary[record['Kernel']]['Elapsed time [ms]'] += record['Elapsed time [ms]'];\n return summary;\n }, {})));\n summary.forEach(function (record) { return record['Ratio [%]'] = (record['Elapsed time [ms]'] / totalElapsedTime_1).toFixed(2); });\n console.table(records);\n console.table(summary);\n return [3 /*break*/, 25];\n case 18:\n _l = 0, _m = runtimeInfo.programs;\n _x.label = 19;\n case 19:\n if (!(_l < _m.length)) return [3 /*break*/, 25];\n runtimeProgramInfo = _m[_l];\n this.handler.bindFrameBuffer(runtimeProgramInfo.frameBuffer, runtimeProgramInfo.width, runtimeProgramInfo.height);\n _o = 0, _p = runtimeProgramInfo.inputs;\n _x.label = 20;\n case 20:\n if (!(_o < _p.length)) return [3 /*break*/, 23];\n _q = _p[_o], buffer = _q.buffer, uniformIndex = _q.uniformIndex;\n return [4 /*yield*/, buffer.bindToReadTexture(uniformIndex)];\n case 21:\n _x.sent();\n _x.label = 22;\n case 22:\n _o++;\n return [3 /*break*/, 20];\n case 23:\n // output\n runtimeProgramInfo.output.bindToDrawTexture();\n // shader\n this.handler.useProgram(runtimeProgramInfo.program);\n // uniforms\n for (_r = 0, _s = runtimeProgramInfo.uniforms; _r < _s.length; _r++) {\n uniform = _s[_r];\n uniform.func.apply(gl, uniform.args);\n }\n // attribute\n gl.vertexAttribPointer(runtimeProgramInfo.xyAttribLoc, 2, gl.FLOAT, true, 8, 0);\n gl.enableVertexAttribArray(runtimeProgramInfo.xyAttribLoc);\n // run\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertexArray.length / 2);\n // release buffers and binding\n // for (let buffer of runtimeProgramInfo.disposable) buffer.releaseGPUMemory();\n for (_t = 0, _u = runtimeProgramInfo.inputs; _t < _u.length; _t++) {\n buffer = _u[_t].buffer;\n buffer.unbindFromReadTexture();\n }\n runtimeProgramInfo.output.unbindFromDrawTexture();\n _x.label = 24;\n case 24:\n _l++;\n return [3 /*break*/, 19];\n case 25:\n _v = 0, _w = runtimeInfo.outputs;\n _x.label = 26;\n case 26:\n if (!(_v < _w.length)) return [3 /*break*/, 29];\n buffer = _w[_v];\n return [4 /*yield*/, buffer.syncReadViews()];\n case 27:\n _x.sent();\n _x.label = 28;\n case 28:\n _v++;\n return [3 /*break*/, 26];\n case 29: return [2 /*return*/];\n }\n });\n });\n };\n return DescriptorRunnerWebGL;\n}(descriptor_runner_1.DescriptorRunner));\nexports.default = DescriptorRunnerWebGL;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webgl.js\n// module id = 37\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar webgl_handler_1 = require(\"../webgl_handler\");\nvar buffer_1 = require(\"./buffer\");\n/**\n * @protected\n */\nvar BufferWebGL = /** @class */ (function (_super) {\n __extends(BufferWebGL, _super);\n function BufferWebGL(byteLength, textureWidth, textureHeight, name, array, channelMode) {\n var _this = _super.call(this, byteLength, 'webgl') || this;\n _this._texture = null;\n _this.readTextureUnitIndices = [];\n _this.isBoundToDrawFrameBuffer = false;\n _this.handler = webgl_handler_1.default.getInstance();\n _this.name = name;\n _this.channelMode = channelMode;\n switch (channelMode) {\n case 'RGBA':\n _this.elementsPerPixel = 4;\n break;\n case 'R':\n _this.elementsPerPixel = 1;\n break;\n default:\n throw Error('Unknown channel mode');\n }\n if (webgl_handler_1.isWebGL2(_this.handler.gl)) {\n switch (channelMode) {\n case 'RGBA':\n _this.textureFormat = _this.handler.gl.RGBA;\n _this.textureInternalFormat = _this.handler.gl.RGBA32F;\n _this.pixelStride = 4;\n break;\n case 'R':\n _this.textureFormat = _this.handler.gl.RED;\n _this.textureInternalFormat = _this.handler.gl.R32F;\n _this.pixelStride = 1;\n break;\n default:\n throw Error('Unknown channel mode');\n }\n }\n else {\n // In WebGL1, always RGBA channel mode is specified. If R channel mode is specified in graph descriptor,\n // other 3 channels are not used.\n _this.textureFormat = _this.handler.gl.RGBA;\n _this.textureInternalFormat = _this.handler.gl.RGBA;\n _this.pixelStride = 4;\n }\n if (_this.pixelStride < _this.elementsPerPixel)\n throw Error('elementsPerPixel must be smaller than pixelStride');\n _this.array = array || new Float32Array(_this.length);\n _this.textureWidth = textureWidth;\n _this.textureHeight = textureHeight;\n return _this;\n }\n Object.defineProperty(BufferWebGL.prototype, \"texture\", {\n get: function () {\n return this._texture;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(BufferWebGL.prototype, \"length\", {\n get: function () {\n return this.byteLength / Float32Array.BYTES_PER_ELEMENT;\n },\n enumerable: true,\n configurable: true\n });\n /**\n * Write contents onto specified position synchronously.\n *\n * @param {ArrayBufferView} src contents source buffer\n * @param {number} offset position where contents are written on\n */\n BufferWebGL.prototype.write = function (src, offset) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.array.set(src, offset);\n return [4 /*yield*/, this.syncWriteViews()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Read contents from specified position synchronously.\n *\n * @param {Float32ArrayConstructor | Int32ArrayConstructor} dst buffer where contents are written on\n * @param {number} offset position where contents are read from\n * @param {length} length contents length\n */\n BufferWebGL.prototype.read = function (dst, offset, length) {\n if (offset === void 0) { offset = 0; }\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (dst !== Float32Array)\n throw new Error('Currently, only Float32Array is supported for parameter \\'dst\\'.');\n return [4 /*yield*/, this.syncReadViews()];\n case 1:\n _a.sent();\n new Float32Array(this.array.buffer, offset * Float32Array.BYTES_PER_ELEMENT, length);\n return [2 /*return*/];\n }\n });\n });\n };\n BufferWebGL.prototype.getWriteView = function (offset, length, type) {\n return new type(this.array.buffer, offset * type.BYTES_PER_ELEMENT, length);\n };\n ;\n BufferWebGL.prototype.getReadView = function (offset, length, type) {\n return new type(this.array.buffer, offset * type.BYTES_PER_ELEMENT, length);\n };\n /**\n * Sync buffered data into memory.\n *\n * @see Buffer#getWriteView\n */\n BufferWebGL.prototype.syncWriteViews = function () {\n return __awaiter(this, void 0, void 0, function () {\n var gl, tmp, tmp2;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n gl = this.handler.gl;\n if (!this.texture)\n this.allocateTexture();\n tmp = this.pack(this.array);\n if (tmp.length != this.textureWidth * this.textureHeight * this.pixelStride) {\n tmp2 = new Float32Array(this.textureWidth * this.textureHeight * this.elementsPerPixel);\n tmp2.set(tmp, 0);\n tmp = tmp2;\n }\n return [4 /*yield*/, this.bindToReadTexture(9)];\n case 1:\n _a.sent(); //TODO: texture unit 9 is always available?\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.textureWidth, this.textureHeight, this.textureFormat, gl.FLOAT, tmp);\n this.unbindFromReadTexture();\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Sync memory data into buffer view.\n *\n * @see Buffer#getReadView\n */\n BufferWebGL.prototype.syncReadViews = function () {\n return __awaiter(this, void 0, void 0, function () {\n var gl, ELEMENT_PER_PIXEL, FORMAT, tmp;\n return __generator(this, function (_a) {\n gl = this.handler.gl;\n ELEMENT_PER_PIXEL = 4;\n FORMAT = gl.RGBA;\n tmp = new Float32Array(this.textureWidth * this.textureHeight * ELEMENT_PER_PIXEL);\n this.bindToDrawTexture();\n gl.readPixels(0, 0, this.textureWidth, this.textureHeight, FORMAT, gl.FLOAT, tmp);\n this.unbindFromDrawTexture();\n tmp = this.unpack(tmp);\n this.array.set(tmp.slice(0, this.length), 0);\n return [2 /*return*/];\n });\n });\n };\n BufferWebGL.prototype.bindToReadTexture = function (unit) {\n return __awaiter(this, void 0, void 0, function () {\n var gl;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (this.isBoundToDrawFrameBuffer)\n throw Error('This buffer is already registered as draw buffer. ' +\n 'You may forgot to unbind the binding while previous operations.');\n gl = this.handler.gl;\n if (!!this.texture) return [3 /*break*/, 2];\n this.allocateTexture();\n return [4 /*yield*/, this.syncWriteViews()];\n case 1:\n _a.sent();\n _a.label = 2;\n case 2:\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n this.readTextureUnitIndices.push(unit);\n return [2 /*return*/];\n }\n });\n });\n };\n BufferWebGL.prototype.unbindFromReadTexture = function () {\n var gl = this.handler.gl;\n for (var _i = 0, _a = this.readTextureUnitIndices; _i < _a.length; _i++) {\n var unit = _a[_i];\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n this.readTextureUnitIndices = [];\n };\n BufferWebGL.prototype.bindToDrawTexture = function () {\n if (this.readTextureUnitIndices.length > 0)\n throw Error('This buffer is already registered as read buffer. ' +\n 'You cannot bind a texture as both read and draw texture buffer at same time.');\n if (this.isBoundToDrawFrameBuffer)\n throw Error('This buffer is already registered as draw buffer. ' +\n 'You may forgot to unbind the binding while previous operations.');\n var gl = this.handler.gl;\n if (!this.texture)\n this.allocateTexture();\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0);\n this.isBoundToDrawFrameBuffer = true;\n };\n BufferWebGL.prototype.unbindFromDrawTexture = function () {\n if (!this.isBoundToDrawFrameBuffer)\n return;\n var gl = this.handler.gl;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);\n this.isBoundToDrawFrameBuffer = false;\n };\n BufferWebGL.prototype.pack = function (array) {\n var elementStride = this.pixelStride / this.elementsPerPixel;\n if (elementStride === 1) {\n return new Float32Array(array);\n }\n else {\n var result = new Float32Array(array.length * elementStride);\n for (var i = 0; i < array.length; i++)\n result[i * elementStride] = array[i];\n return result;\n }\n };\n BufferWebGL.prototype.unpack = function (array) {\n // FIXME(Kiikurage): more readable code\n var PIXEL_STRIDE = 4;\n var elementStride = PIXEL_STRIDE / this.elementsPerPixel;\n if (elementStride === 1) {\n return new Float32Array(array);\n }\n else {\n var result = new Float32Array(array.length / elementStride);\n for (var i = 0; i < array.length / elementStride; i++)\n result[i] = array[i * elementStride];\n return result;\n }\n };\n BufferWebGL.prototype.allocateTexture = function () {\n if (this.texture)\n throw Error('Texture is already allocated.');\n this._texture = this.handler.createTexture(this.textureWidth, this.textureHeight, this.textureInternalFormat, this.textureFormat);\n };\n return BufferWebGL;\n}(buffer_1.Buffer));\nexports.default = BufferWebGL;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer_webgl.js\n// module id = 38\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar localforage = require(\"localforage\");\nvar buffer_webgpu_1 = require(\"../buffer/buffer_webgpu\");\nvar get_weight_decoder_1 = require(\"../decoder/get_weight_decoder\");\nvar fetch_1 = require(\"../fetch\");\nvar placeholder_1 = require(\"../placeholder\");\nvar symbolic_float32array_1 = require(\"../symbolic_typed_array/symbolic_float32array\");\nvar webdnn_1 = require(\"../webdnn\");\nvar webgpu_handler_1 = require(\"../webgpu_handler\");\nvar descriptor_runner_1 = require(\"./descriptor_runner\");\n/**\n * Check this device is iOS devices or not.\n * @private\n */\nvar IS_IOS = navigator.userAgent.includes('iPhone') || navigator.userAgent.includes('iPad');\n/**\n * DescriptorRunner for WebGPU\n * @protected\n */\nvar DescriptorRunnerWebGPU = /** @class */ (function (_super) {\n __extends(DescriptorRunnerWebGPU, _super);\n function DescriptorRunnerWebGPU() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n /**\n * backend name\n */\n _this.backendName = 'webgpu';\n return _this;\n }\n /**\n * Return `true` if this backend is available in this environment.\n * @returns {boolean}\n */\n DescriptorRunnerWebGPU.checkAvailability = function () {\n return webgpu_handler_1.IS_WEBGPU_SUPPORTED;\n };\n /**\n * Initialize descriptor runner asynchronously\n * @returns {Promise} Promise object which is resolved when the initialization finished.\n */\n DescriptorRunnerWebGPU.prototype.init = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.webgpuHandler = webgpu_handler_1.default.getInstance();\n return [4 /*yield*/, this.checkIncompatibleGPU()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Check whether current GPU is supported or not. If it's not supported, an error is thrown.\n * @returns {Promise}\n */\n DescriptorRunnerWebGPU.prototype.checkIncompatibleGPU = function () {\n return __awaiter(this, void 0, void 0, function () {\n var buffer, threadExecutionWidth;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n /**\n * It is reported that AMD GPU crashes when performing sgemm (matrix multiplication).\n * Until this problem is solved, blocking WebGPU backend in the environment is needed.\n * API in WebGPU does not directly gives hardware information, so trying to determine hardware heuristically.\n *\n * Criteria: thread_execution_width == 32 is required\n * (on AMD FirePro D500, thread_execution_width == 64)\n *\n * @see https://github.com/mil-tokyo/webdnn/issues/286\n */\n this.webgpuHandler.loadKernel(\"\\n#include \\nusing namespace metal;\\n kernel void check_compatibility(\\n device uint *A[[buffer(0)]],\\n uint global_index[[thread_position_in_grid]],\\n uint thread_execution_width[[thread_execution_width]]\\n ){\\n if (global_index == 0) {\\n A[0] = thread_execution_width;\\n }\\n }\", 'basic');\n buffer = this.webgpuHandler.createBuffer(new Uint32Array(1));\n return [4 /*yield*/, this.webgpuHandler.executeSinglePipelineState('basic.check_compatibility', { width: 1, height: 1, depth: 1 }, { width: 1, height: 1, depth: 1 }, [buffer], true)];\n case 1:\n _a.sent();\n threadExecutionWidth = (new Uint32Array(buffer.contents))[0];\n if (threadExecutionWidth != 32) {\n throw new Error(\"Sorry, this GPU does not compatible with WebGPU (thread_execution_width == \" + threadExecutionWidth + \". See checkIncompatibleGPU method of https://github.com/mil-tokyo/webdnn/blob/master/src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.ts\");\n }\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Fetch graph descriptor from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @protected\n */\n DescriptorRunnerWebGPU.prototype.fetchDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fetch_1.default(directory + \"/graph_\" + this.backendName + \".json\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, res.json()];\n }\n });\n });\n };\n /**\n * Fetch parameter files from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @param progressCallback callback which is called to notice the loading is progressing.\n * @protected\n */\n DescriptorRunnerWebGPU.prototype.fetchParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var res;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fetch_1.default(directory + \"/weight_\" + this.backendName + \".bin\")];\n case 1:\n res = _a.sent();\n return [2 /*return*/, fetch_1.readArrayBufferProgressively(res, progressCallback)];\n }\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebGPU.prototype.restoreCachedDescriptor = function (directory) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, localforage.getItem(directory + \"_\" + this.backendName + \"_descriptor\").catch(function () { return null; })];\n });\n });\n };\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n DescriptorRunnerWebGPU.prototype.restoreCachedParameters = function (directory, progressCallback) {\n return __awaiter(this, void 0, void 0, function () {\n var parameter;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, localforage.getItem(directory + \"_\" + this.backendName + \"_parameters\").catch(function () { return null; })];\n case 1:\n parameter = _a.sent();\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return [2 /*return*/, parameter];\n }\n });\n });\n };\n /**\n * save cache\n */\n DescriptorRunnerWebGPU.prototype.saveCache = function (directory, descriptor, parameters) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, Promise.all([\n localforage.setItem(directory + \"_\" + this.backendName + \"_descriptor\", descriptor),\n localforage.setItem(directory + \"_\" + this.backendName + \"_parameters\", parameters)\n ])];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n ;\n DescriptorRunnerWebGPU.prototype.setDescriptorAndParameters = function (descriptor, parameter) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.descriptor = descriptor;\n //reset all datum depend on old descriptor\n this.staticBuffer = null;\n this.dynamicBuffer = null;\n this.metaBuffers = null;\n this.placeholderContext = new placeholder_1.default(descriptor.placeholders);\n this.executionInfos = descriptor.exec_infos;\n //compile kernels\n this.webgpuHandler.loadKernel(this.descriptor.kernel_source, 'descriptor');\n return [4 /*yield*/, this.initializeStaticBuffer(parameter)];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.initializeMetaBuffers()];\n case 2:\n _a.sent();\n return [4 /*yield*/, this.setPlaceholderValue({\n '__MAX_THREADS_PER_THREADGROUP__': IS_IOS ? 512 : 1024\n })];\n case 3:\n _a.sent();\n if (!(this.placeholderContext && this.placeholderContext.isResolved)) return [3 /*break*/, 5];\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 4:\n _a.sent();\n _a.label = 5;\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Initialize static buffers, whose size and position can be determined in compile time.\n *\n * @param {ArrayBuffer} weightRawArray constant weight buffer\n * @returns {Promise}\n */\n DescriptorRunnerWebGPU.prototype.initializeStaticBuffer = function (weightRawArray) {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, staticBuffer, decoder, _a, _b;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n descriptor = this.descriptor;\n staticBuffer = new buffer_webgpu_1.default(descriptor.memory_layout.static.size * Float32Array.BYTES_PER_ELEMENT);\n this.staticBuffer = staticBuffer;\n decoder = get_weight_decoder_1.default(descriptor.weight_encoding);\n _b = (_a = staticBuffer).write;\n return [4 /*yield*/, decoder.decode(new Uint8Array(weightRawArray))];\n case 1: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];\n case 2:\n _c.sent();\n return [4 /*yield*/, this.getInputViews()];\n case 3:\n (_c.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = staticBuffer.bufferView.buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 4:\n (_c.sent())\n .filter(function (view) { return !view.isDynamic; })\n .forEach(function (view) {\n view.buffer = staticBuffer.bufferView.buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Initialize meta buffers, which contains metadata shared in each GPU kernel thread (ex. hyper parameters).\n * @returns {Promise}\n */\n DescriptorRunnerWebGPU.prototype.initializeMetaBuffers = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var _a;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n _a = this;\n return [4 /*yield*/, Promise.all(this.descriptor.exec_infos.map(function (executionInfo) { return __awaiter(_this, void 0, void 0, function () {\n var buffer;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n buffer = new buffer_webgpu_1.default(executionInfo.meta_buffer.length * Int32Array.BYTES_PER_ELEMENT);\n return [4 /*yield*/, buffer.write(new Uint8Array(executionInfo.meta_buffer))];\n case 1:\n _a.sent();\n return [2 /*return*/, buffer];\n }\n });\n }); }))];\n case 1:\n _a.metaBuffers = _b.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Initialize dynamic buffers, whose size and position cannot be determined without runtime-information such as input image size\n * (if it's dynamic).\n * When all placeholder is resolved, this method is automatically called.\n *\n * @returns {Promise}\n */\n DescriptorRunnerWebGPU.prototype.initializeDynamicBuffer = function () {\n return __awaiter(this, void 0, void 0, function () {\n var descriptor, placeholderContext, dynamicBufferSize, dynamicBuffer;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n if (!this.placeholderContext)\n throw Error(\"PlaceholderContext is not initialized.\");\n descriptor = this.descriptor;\n placeholderContext = this.placeholderContext;\n dynamicBufferSize = placeholderContext.resolve(descriptor.memory_layout.dynamic.size);\n dynamicBuffer = new buffer_webgpu_1.default(dynamicBufferSize * Float32Array.BYTES_PER_ELEMENT);\n this.dynamicBuffer = dynamicBuffer;\n return [4 /*yield*/, this.getInputViews()];\n case 1:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = dynamicBuffer.bufferView.buffer;\n });\n return [4 /*yield*/, this.getOutputViews()];\n case 2:\n (_a.sent())\n .filter(function (view) { return view.isDynamic; })\n .forEach(function (view) {\n view.buffer = dynamicBuffer.bufferView.buffer;\n });\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Set actual value into placeholder. If all placeholder is resolved,\n * [[DescriptorRunnerWebGPU#initializeDynamicBuffer|`initializeDynamicBuffer()`]] is automatically called.\n *\n * @param values mapping object of placeholder name and value\n * @returns {Promise}\n */\n DescriptorRunnerWebGPU.prototype.setPlaceholderValue = function (values) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var placeholderContext, descriptor, metaBuffers, _a;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return [2 /*return*/];\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.metaBuffers)\n throw new Error('MetaBuffers are not initialized');\n descriptor = this.descriptor;\n metaBuffers = this.metaBuffers;\n return [4 /*yield*/, this.initializeDynamicBuffer()];\n case 1:\n _b.sent();\n // resolve placeholders in execution info\n _a = this;\n return [4 /*yield*/, Promise.all(descriptor.exec_infos.map(function (executionInfo, i) { return __awaiter(_this, void 0, void 0, function () {\n var bufferView, _i, _a, unresolved_value;\n return __generator(this, function (_b) {\n bufferView = new Int32Array(metaBuffers[i].bufferView.buffer);\n for (_i = 0, _a = executionInfo.unresolved_value_list; _i < _a.length; _i++) {\n unresolved_value = _a[_i];\n bufferView[unresolved_value.offset] = placeholderContext.resolve(unresolved_value.placeholder);\n }\n return [2 /*return*/, placeholderContext.resolve(executionInfo)];\n });\n }); }))];\n case 2:\n // resolve placeholders in execution info\n _a.executionInfos = _b.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Get input [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]] object\n *\n * @returns array of input [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]]\n * @deprecated Use [[webdnn.DescriptorRunner.inputs|`inputs`]] instead\n */\n DescriptorRunnerWebGPU.prototype.getInputViews = function () {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, allocation.offset * symbolic_float32array_1.default.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n };\n /**\n * Get output [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]] object\n *\n * @returns array of output [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]]\n * @deprecated Use [[webdnn.DescriptorRunner.outputs|`outputs`]] instead\n */\n DescriptorRunnerWebGPU.prototype.getOutputViews = function () {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n var descriptor = this.descriptor;\n var placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(function (name) {\n var allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n var view = new symbolic_float32array_1.default(null, allocation.offset * symbolic_float32array_1.default.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n };\n /**\n * Run descriptor. You must call [[webdnn.DescriptorRunner.getInputViews|`getInputViews`]] and\n * [[webdnn.DescriptorRunner.getOutputViews|`getOutputViews`]] before calling this function.\n */\n DescriptorRunnerWebGPU.prototype.run = function () {\n return __awaiter(this, void 0, void 0, function () {\n var staticBuffer, dynamicBuffer, metaBuffers, records, totalElapsedTime_1, i, exec_info, start, elapsedTime, summary, complete_promise, i, exec_info, is_last;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.executionInfos)\n throw new Error('ExecutionInfos is not loaded');\n if (!this.staticBuffer)\n throw new Error('StaticBuffer is not initialized');\n if (!this.dynamicBuffer)\n throw new Error('DynamicBuffer is not initialized');\n if (!this.metaBuffers)\n throw new Error('MetaBuffer is not initialized');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(\"Not all placeholders are resolved: \" + this.placeholderContext);\n staticBuffer = this.staticBuffer;\n dynamicBuffer = this.dynamicBuffer;\n metaBuffers = this.metaBuffers;\n if (!webdnn_1.getConfiguration('DEBUG', false)) return [3 /*break*/, 5];\n records = [];\n totalElapsedTime_1 = 0;\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < this.executionInfos.length)) return [3 /*break*/, 4];\n exec_info = this.executionInfos[i];\n start = performance.now();\n return [4 /*yield*/, this.webgpuHandler.executeSinglePipelineState('descriptor.' + exec_info.entry_func_name, exec_info.threadgroups_per_grid, exec_info.threads_per_thread_group, [staticBuffer, dynamicBuffer, metaBuffers[i]], true)];\n case 2:\n _a.sent();\n elapsedTime = performance.now() - start;\n records.push({\n 'Kernel': exec_info.entry_func_name,\n 'Elapsed time [ms]': elapsedTime\n });\n totalElapsedTime_1 += elapsedTime;\n _a.label = 3;\n case 3:\n i++;\n return [3 /*break*/, 1];\n case 4:\n summary = Array.from(Object.values(records.reduce(function (summary, record) {\n if (!(record['Kernel'] in summary)) {\n summary[record['Kernel']] = {\n 'Kernel': record['Kernel'],\n 'Count': 0,\n 'Elapsed time [ms]': 0,\n };\n }\n summary[record['Kernel']]['Count']++;\n summary[record['Kernel']]['Elapsed time [ms]'] += record['Elapsed time [ms]'];\n return summary;\n }, {})));\n summary.forEach(function (record) { return record['Ratio [%]'] = (record['Elapsed time [ms]'] / totalElapsedTime_1).toFixed(2); });\n console.table(records);\n console.table(summary);\n return [3 /*break*/, 6];\n case 5:\n complete_promise = null;\n for (i = 0; i < this.executionInfos.length; i++) {\n exec_info = this.executionInfos[i];\n is_last = i == this.executionInfos.length - 1;\n complete_promise = this.webgpuHandler.executeSinglePipelineState('descriptor.' + exec_info.entry_func_name, exec_info.threadgroups_per_grid, exec_info.threads_per_thread_group, [staticBuffer, dynamicBuffer, metaBuffers[i]], is_last);\n }\n return [2 /*return*/, complete_promise]; //wait to finish final kernel\n case 6: return [2 /*return*/];\n }\n });\n });\n };\n return DescriptorRunnerWebGPU;\n}(descriptor_runner_1.DescriptorRunner));\nexports.default = DescriptorRunnerWebGPU;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.js\n// module id = 39\n// module chunks = 0","\"use strict\";\nfunction __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n}\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @module webdnn/image\n * @preferred\n *\n * Module `WebDNN.Image` provides basic image processing operations like follows.\n *\n * - Load image by various way (File picker dialog, url string, canvas, video, etc.)\n * - Pack image data into TypedArray\n * - Crop and resize.\n * - Show result on canvas element\n *\n */\n/** Don't Remove This comment block */\n// export * from \"./image/canvas\" // internal API\n__export(require(\"./image/enums\"));\n__export(require(\"./image/image_array\"));\n// export * from \"./image/image_data\" // internal API\n__export(require(\"./image/image_source\"));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image.js\n// module id = 40\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar canvas_1 = require(\"./canvas\");\nvar enums_1 = require(\"./enums\");\nvar image_data_1 = require(\"./image_data\");\nvar image_source_1 = require(\"./image_source\");\n/**\n * @protected\n */\nfunction flatten(arr) {\n return (arr instanceof Array) ? Array.prototype.concat.apply([], arr.map(function (arr) { return flatten(arr); })) : arr;\n}\n/**\n * @protected\n */\nfunction normalizeBiasTuple(arr) {\n if (typeof (arr) == \"number\") {\n return [arr, arr, arr, arr];\n }\n else {\n if (arr.length == 4) {\n return [arr[0], arr[1], arr[2], arr[3]];\n }\n else if (arr.length == 3) {\n return [arr[0], arr[1], arr[2], arr[0]];\n }\n else if (arr.length == 1) {\n return [arr[0], arr[0], arr[0], arr[0]];\n }\n else {\n throw new Error('bias and scale must be scalar number or array of length 1 or 3 or 4.');\n }\n }\n}\n/**\n * Get image array as `{Float32 or Int32}ArrayBufferView` from ImageData object.\n *\n * @returns {ArrayBufferView} buffer with specified type\n * @protected\n */\nfunction getImageArrayFromImageData(imageData, options) {\n if (options === void 0) { options = {}; }\n var _a = options.type, type = _a === void 0 ? Float32Array : _a, _b = options.color, color = _b === void 0 ? enums_1.Color.RGB : _b, _c = options.order, order = _c === void 0 ? enums_1.Order.HWC : _c, _d = options.bias, bias = _d === void 0 ? [0, 0, 0] : _d, _e = options.scale, scale = _e === void 0 ? [1, 1, 1] : _e;\n var bias_n = normalizeBiasTuple(bias);\n var scale_n = normalizeBiasTuple(scale);\n var width = imageData.width;\n var height = imageData.height;\n var data = imageData.data;\n var array;\n var biasR, biasG, biasB, biasA;\n var scaleR, scaleG, scaleB, scaleA;\n switch (color) {\n case enums_1.Color.RGB:\n array = new type(width * height * 3);\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2];\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(h * width + w) * 3 + 0] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 3 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 3 + 2] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n }\n }\n break;\n }\n break;\n case enums_1.Color.BGR:\n array = new type(width * height * 3);\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(h * width + w) * 3 + 0] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 3 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 3 + 2] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n }\n }\n break;\n }\n break;\n case enums_1.Color.RGBA:\n array = new type(width * height * 4);\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2], scaleA = scale_n[3];\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2], biasA = bias_n[3];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(h * width + w) * 4 + 0] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 4 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 4 + 2] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 4 + 3] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(3 * height + h) * width + w] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n }\n break;\n case enums_1.Color.BGRA:\n array = new type(width * height * 4);\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2], biasA = bias_n[3];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2], scaleA = scale_n[3];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(h * width + w) * 4 + 0] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 4 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 4 + 2] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 4 + 3] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(3 * height + h) * width + w] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n }\n break;\n case enums_1.Color.GREY:\n array = new type(width * height);\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2];\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2];\n for (var h = 0; h < height; h++) {\n for (var w = 0; w < width; w++) {\n var r = data[(h * width + w) * 4 + 0];\n var g = data[(h * width + w) * 4 + 1];\n var b = data[(h * width + w) * 4 + 2];\n array[h * width + w] = 0.2126 * (r - biasR) / scaleR + 0.7162 * (g - biasG) / scaleG + 0.0722 * (b - biasB) / scaleB;\n }\n }\n break;\n default:\n throw Error(\"Unknown color format: \" + color);\n }\n return array;\n}\nexports.getImageArrayFromImageData = getImageArrayFromImageData;\n/**\n * Get image array from canvas element as `{Float32 or Int32}ArrayBufferView`.\n *\n * @returns {ImageData} buffer with specified type\n * @protected\n */\nfunction getImageArrayFromCanvas(canvas, options) {\n if (options === void 0) { options = {}; }\n var _a = options.type, type = _a === void 0 ? Float32Array : _a, _b = options.color, color = _b === void 0 ? enums_1.Color.RGB : _b, _c = options.order, order = _c === void 0 ? enums_1.Order.HWC : _c, _d = options.srcX, srcX = _d === void 0 ? 0 : _d, _e = options.srcY, srcY = _e === void 0 ? 0 : _e, _f = options.srcW, srcW = _f === void 0 ? canvas.width : _f, _g = options.srcH, srcH = _g === void 0 ? canvas.height : _g, _h = options.dstX, dstX = _h === void 0 ? 0 : _h, _j = options.dstY, dstY = _j === void 0 ? 0 : _j, _k = options.bias, bias = _k === void 0 ? [0, 0, 0] : _k, _l = options.scale, scale = _l === void 0 ? [1, 1, 1] : _l;\n var _m = options.dstW, dstW = _m === void 0 ? srcW : _m, _o = options.dstH, dstH = _o === void 0 ? srcH : _o;\n var imageData = image_data_1.getImageData(canvas, { srcX: srcX, srcY: srcY, srcW: srcW, srcH: srcH, dstX: dstX, dstY: dstY, dstW: dstW, dstH: dstH });\n return getImageArrayFromImageData(imageData, { type: type, color: color, order: order, bias: bias, scale: scale });\n}\nexports.getImageArrayFromCanvas = getImageArrayFromCanvas;\n/**\n * Get image array from image element as `{Float32 or Int32}ArrayBufferView`.\n *\n * @returns {ImageData} buffer with specified type\n * @protected\n */\nfunction getImageArrayFromDrawable(drawable, options) {\n if (options === void 0) { options = {}; }\n var srcW, srcH;\n if (drawable instanceof HTMLVideoElement) {\n srcW = drawable.videoWidth;\n srcH = drawable.videoHeight;\n }\n else if (drawable instanceof HTMLImageElement) {\n srcW = drawable.naturalWidth;\n srcH = drawable.naturalHeight;\n }\n else if (drawable instanceof HTMLCanvasElement) {\n return getImageArrayFromCanvas(drawable, options);\n }\n else if (drawable instanceof ImageData) {\n return getImageArrayFromImageData(drawable, options);\n }\n else\n throw TypeError('Failed to execute \"getImageDataFromDrawable(drawable, options)\": \"drawable\" must be an instanceof Drawable');\n var _a = options.type, type = _a === void 0 ? Float32Array : _a, _b = options.color, color = _b === void 0 ? enums_1.Color.RGB : _b, _c = options.order, order = _c === void 0 ? enums_1.Order.HWC : _c, _d = options.srcX, srcX = _d === void 0 ? 0 : _d, _e = options.srcY, srcY = _e === void 0 ? 0 : _e, _f = options.dstX, dstX = _f === void 0 ? 0 : _f, _g = options.dstY, dstY = _g === void 0 ? 0 : _g, _h = options.dstW, dstW = _h === void 0 ? srcW : _h, _j = options.dstH, dstH = _j === void 0 ? srcH : _j, _k = options.bias, bias = _k === void 0 ? [0, 0, 0] : _k, _l = options.scale, scale = _l === void 0 ? [1, 1, 1] : _l;\n var canvas = document.createElement('canvas');\n canvas.width = dstX + dstW;\n canvas.height = dstY + dstH;\n var context = canvas_1.getContext2D(canvas);\n context.drawImage(drawable, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);\n return getImageArrayFromCanvas(canvas, { type: type, color: color, order: order, bias: bias, scale: scale });\n}\nexports.getImageArrayFromDrawable = getImageArrayFromDrawable;\n/**\n * Create typed array by packing image data from image source with specified options.\n *\n * First, this method loads specified image resource. The behavior of this method depends on the `image` argument.\n *\n * - If `image` is an instance of `string`, it will be regarded as image url, and this method fetches that url.\n *\n * - If `image` is an instance of `HTMLInputElement`, it will be regarded as file input,\n * and this method loads the selected image file.\n *\n * - Otherwise, `image` will be regarded as drawable object.\n *\n * Then, loaded images are packed into typed array based on `options` argument.\n *\n * - The image is cropped based on [[SourceRect|`{srcX, srcY, srcW, srcH}`]].\n * As default, entire image is used.\n *\n * - The image is resized and translated into [[DestinationRect|`{dstX, dstY, dstW, dstH}`]].\n * As default, no resize and translation is performed.\n *\n * - [[ImageArrayOption.type|`options.type`]] is the type of packed typed array. As default, Float32Array is used.\n *\n * - [[ImageArrayOption.type|`options.color`]] is the color format of packed typed array. As default, [[Color.RGB|`RGB`]] is used.\n *\n * - [[ImageArrayOption.type|`options.order`]] is the data order of packed typed array. As default, [[Order.HWC|`HWC`]] is used.\n *\n * - [[ImageArrayOption.bias|`options.bias`]] is the bias value.\n * If specified, this method **subtracts** this value from original pixel value.\n *\n * - [[ImageArrayOption.scale|`options.scale`]] is the scale value. If specified, original pixel values are **divided** by this value.\n * [[ImageArrayOption.scale|`options.scale`]] and [[ImageArrayOption.bias|`options.bias`]] is used for converting pixel value `x` and\n * packed value `y` as follows:\n *\n * - `y = (x - bias) / scale`\n * - `x = y * scale + bias`\n * - Note that color order is always RGB, not BGR.\n *\n * ### Examples\n *\n * - Load image of specified url\n *\n * ```ts\n * let image = await WebDNN.Image.load('./cat.png');\n * ```\n *\n * - Load image selected in file input and resize it into 224 x 224\n *\n * ```ts\n * let input = document.querySelector('input[type=file]');\n * let image = await WebDNN.Image.load(input, { dstW: 224, dstH: 224 });\n * ```\n *\n * - Load image data from canvas, normalize it into range `[-1, 1)`. In this case, normalized value `y` can be\n * calculated from pixel value `x` as follows: `y = (x - 128) / 128`.\n *\n * ```ts\n * let canvas = document.getElementsByTagName('canvas')[0];\n * let image = await WebDNN.Image.load(canvas, { bias: [128, 128, 128], scale: [128, 128, 128] });\n * ```\n *\n * @param image please see above descriptions\n * @param options please see above descriptions.\n * @returns Created typed array\n */\nfunction getImageArray(image, options) {\n if (options === void 0) { options = {}; }\n return __awaiter(this, void 0, void 0, function () {\n var _a, _b;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n if (!(typeof image === 'string')) return [3 /*break*/, 2];\n _a = getImageArrayFromDrawable;\n return [4 /*yield*/, image_source_1.loadImageByUrl(image)];\n case 1: return [2 /*return*/, _a.apply(void 0, [_c.sent(), options])];\n case 2:\n if (!(image instanceof HTMLInputElement)) return [3 /*break*/, 4];\n _b = getImageArrayFromDrawable;\n return [4 /*yield*/, image_source_1.loadImageFromFileInput(image)];\n case 3: return [2 /*return*/, _b.apply(void 0, [_c.sent(), options])];\n case 4:\n if (image instanceof HTMLCanvasElement) {\n return [2 /*return*/, getImageArrayFromCanvas(image, options)];\n }\n else if (image instanceof HTMLImageElement || image instanceof HTMLVideoElement || image instanceof ImageData) {\n return [2 /*return*/, getImageArrayFromDrawable(image, options)];\n // FIXME: This feature is not supported for all web browsers.\n // } else if (image === null) {\n // return getImageArrayFromDrawable(await loadImageByDialog(), options);\n }\n else\n throw TypeError('Failed to execute \"getImageData(image, options)\": \"image\" must be an instance of string,' +\n ' HTMLInputElement, HTMLCanvasElement, HTMLImageElement, HTMLVideoElement, or ImageData object');\n _c.label = 5;\n case 5: return [2 /*return*/];\n }\n });\n });\n}\nexports.getImageArray = getImageArray;\n/**\n * Set image array data into canvas.\n *\n * ### Examples\n *\n * - Show DNN model's result\n *\n * ```ts\n * let runner = await WebDNN.load('./model');\n * let output = runner.outputs[0];\n *\n * await runner.run();\n *\n * WebDNN.Image.setImageArrayToCanvas(output.toActual(), 256, 256, document.getElementById('canvas'))\n * ```\n *\n * - Generally image generation model's result contains noise pixel at their edge because of convolution's padding.\n * In follow example, these noise are cut off.\n *\n * ```ts\n * WebDNN.Image.setImageArrayToCanvas(output, 256, 256, canvas, {\n * srcX: 16, srcY: 16, srcH: 256-16*2, srcW: 256-16*2, // Discard both ends 16px\n * dstW: 256, dstH: 256 // Resize cropped image into original output size.\n * });\n * ```\n *\n * @param array array which contains image data\n * @param imageW width of image\n * @param imageH height of image. The length of `array` must be `imageW * imageH * (# of channels)`\n * @param canvas destination canvas\n * @param options please see above descriptions and descriptions in [[webdnn/image.getImageArray|getImageArray()]].\n * `srcW` and `srcH` is ignored (overwritten by `imageW` and `imageH`).\n */\nfunction setImageArrayToCanvas(array, imageW, imageH, canvas, options) {\n if (options === void 0) { options = {}; }\n var _a = options.color, color = _a === void 0 ? enums_1.Color.RGB : _a, _b = options.order, order = _b === void 0 ? enums_1.Order.HWC : _b, _c = options.srcX, srcX = _c === void 0 ? 0 : _c, _d = options.srcY, srcY = _d === void 0 ? 0 : _d, _e = options.dstX, dstX = _e === void 0 ? 0 : _e, _f = options.dstY, dstY = _f === void 0 ? 0 : _f, _g = options.dstW, dstW = _g === void 0 ? canvas.width : _g, _h = options.dstH, dstH = _h === void 0 ? canvas.height : _h, _j = options.bias, bias = _j === void 0 ? [0, 0, 0] : _j, _k = options.scale, scale = _k === void 0 ? [1, 1, 1] : _k;\n var bias_n = normalizeBiasTuple(bias);\n var scale_n = normalizeBiasTuple(scale);\n var srcW = imageW, srcH = imageH;\n array = flatten(array);\n var data = new Uint8ClampedArray(srcW * srcH * 4);\n var biasR, biasG, biasB, biasA;\n var scaleR, scaleG, scaleB, scaleA;\n switch (color) {\n case enums_1.Color.RGB:\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 0] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 2] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(0 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(2 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n break;\n case enums_1.Color.BGR:\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 2] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 0] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(2 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(0 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n break;\n case enums_1.Color.RGBA:\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2], biasA = bias_n[3];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2], scaleA = scale_n[3];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 0] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 2] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(h * imageW + w) * 3 + 3] * scaleA + biasA;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(0 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(2 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(3 * imageH + h) * imageW + w] * scaleA + biasA;\n }\n }\n break;\n }\n break;\n case enums_1.Color.BGRA:\n biasR = bias_n[0], biasG = bias_n[1], biasB = bias_n[2], biasA = bias_n[3];\n scaleR = scale_n[0], scaleG = scale_n[1], scaleB = scale_n[2], scaleA = scale_n[3];\n switch (order) {\n case enums_1.Order.HWC:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 4 + 2] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 4 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 4 + 0] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(h * imageW + w) * 4 + 3] * scaleA + biasA;\n }\n }\n break;\n case enums_1.Order.CHW:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(2 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(0 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(3 * imageH + h) * imageW + w] * scaleA + biasA;\n }\n }\n break;\n }\n break;\n case enums_1.Color.GREY:\n for (var h = srcY; h < srcY + srcH; h++) {\n for (var w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] =\n data[(h * imageW + w) * 4 + 1] =\n data[(h * imageW + w) * 4 + 2] = array[h * imageW + w] * scale[0] + bias[0];\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n image_data_1.setImageDataToCanvas(new ImageData(data, srcW, srcH), canvas, { srcX: srcX, srcY: srcY, srcW: srcW, srcH: srcH, dstX: dstX, dstY: dstY, dstW: dstW, dstH: dstH });\n}\nexports.setImageArrayToCanvas = setImageArrayToCanvas;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_array.js\n// module id = 41\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar canvas_1 = require(\"./canvas\");\n/**\n * @protected\n */\nfunction getImageDataFromCanvas(canvas, options) {\n if (options === void 0) { options = {}; }\n var _a = options.srcX, srcX = _a === void 0 ? 0 : _a, _b = options.srcY, srcY = _b === void 0 ? 0 : _b, _c = options.srcW, srcW = _c === void 0 ? canvas.width : _c, _d = options.srcH, srcH = _d === void 0 ? canvas.height : _d, _e = options.dstX, dstX = _e === void 0 ? 0 : _e, _f = options.dstY, dstY = _f === void 0 ? 0 : _f;\n var _g = options.dstW, dstW = _g === void 0 ? srcW : _g, _h = options.dstH, dstH = _h === void 0 ? srcH : _h;\n var imageData = canvas_1.getContext2D(canvas).getImageData(srcX, srcY, srcW, srcH);\n if (dstX !== 0 || dstY !== 0 || srcW !== dstW || srcH !== dstH) {\n imageData = cropAndResizeImageData(imageData, { dstX: dstX, dstY: dstY, dstW: dstW, dstH: dstH });\n }\n return imageData;\n}\nexports.getImageDataFromCanvas = getImageDataFromCanvas;\n/**\n * @protected\n */\nfunction getImageDataFromDrawable(drawable, options) {\n if (options === void 0) { options = {}; }\n var srcW, srcH;\n if (drawable instanceof HTMLVideoElement) {\n srcW = drawable.videoWidth;\n srcH = drawable.videoHeight;\n }\n else if (drawable instanceof HTMLImageElement) {\n srcW = drawable.naturalWidth;\n srcH = drawable.naturalHeight;\n }\n else\n throw TypeError('Failed to execute \"getImageDataFromDrawable(drawable, options)\": \"drawable\" must be an instanceof HTMLVideoElement or HTMLImageElement');\n var _a = options.srcX, srcX = _a === void 0 ? 0 : _a, _b = options.srcY, srcY = _b === void 0 ? 0 : _b, _c = options.dstX, dstX = _c === void 0 ? 0 : _c, _d = options.dstY, dstY = _d === void 0 ? 0 : _d, _e = options.dstW, dstW = _e === void 0 ? srcW : _e, _f = options.dstH, dstH = _f === void 0 ? srcH : _f;\n var canvas = document.createElement('canvas');\n canvas.width = dstX + dstW;\n canvas.height = dstY + dstH;\n var context = canvas_1.getContext2D(canvas);\n context.drawImage(drawable, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);\n return context.getImageData(0, 0, dstX + dstW, dstY + dstH);\n}\nexports.getImageDataFromDrawable = getImageDataFromDrawable;\n/**\n * Source rectangle of source image is cropped and then copied into destination rectangle of new image data\n *\n * @param {ImageData} src\n * @param {SourceRect & DestinationRect} options\n * @returns {ImageData}\n * @protected\n */\nfunction cropAndResizeImageData(src, options) {\n if (options === void 0) { options = {}; }\n var _a = options.srcX, srcX = _a === void 0 ? 0 : _a, _b = options.srcY, srcY = _b === void 0 ? 0 : _b, _c = options.srcW, srcW = _c === void 0 ? src.width : _c, _d = options.srcH, srcH = _d === void 0 ? src.height : _d, _e = options.dstX, dstX = _e === void 0 ? 0 : _e, _f = options.dstY, dstY = _f === void 0 ? 0 : _f;\n var _g = options.dstW, dstW = _g === void 0 ? srcW : _g, _h = options.dstH, dstH = _h === void 0 ? srcH : _h;\n var canvas1 = document.createElement('canvas');\n canvas1.width = srcW;\n canvas1.height = srcH;\n var context1 = canvas_1.getContext2D(canvas1);\n context1.putImageData(src, -srcX, -srcY);\n var canvas2 = document.createElement('canvas');\n canvas2.width = dstX + dstW;\n canvas2.height = dstY + dstH;\n var context2 = canvas_1.getContext2D(canvas2);\n context2.drawImage(canvas1, 0, 0, srcW, srcH, dstX, dstY, dstW, dstH);\n return context2.getImageData(0, 0, dstX + dstW, dstY + dstH);\n}\n/**\n * Return canvas `ImageData` object with specified scale.\n *\n * @param {HTMLCanvasElement | HTMLVideoElement | HTMLImageElement} image\n * @param [options] Options\n * @param {number} [options.srcX=0] left position of input clipping rect\n * @param {number} [options.srcY=0] top position of input clipping rect\n * @param {number} [options.srcW=canvas.width] width of input clipping rect\n * @param {number} [options.srcH=canvas.height] height of input clipping rect\n * @param {number} [options.dstW=options.srcW] width of output\n * @param {number} [options.dstH=options.srcH] height of output\n * @returns {ImageData}\n * @protected\n */\nfunction getImageData(image, options) {\n if (options === void 0) { options = {}; }\n if (image instanceof HTMLCanvasElement) {\n return getImageDataFromCanvas(image, options);\n }\n else if (image instanceof HTMLVideoElement || image instanceof HTMLImageElement) {\n return getImageDataFromDrawable(image, options);\n }\n else\n throw TypeError('Failed to execute \"getImageData(image, options)\": \"image\" must be an instance of HTMLCanvasElement, HTMLVideoElement, or HTMLImageElement');\n}\nexports.getImageData = getImageData;\n/**\n * @protected\n */\nfunction setImageDataToCanvas(imageData, canvas, options) {\n if (options === void 0) { options = {}; }\n var _a = options.srcX, srcX = _a === void 0 ? 0 : _a, _b = options.srcY, srcY = _b === void 0 ? 0 : _b, _c = options.srcW, srcW = _c === void 0 ? imageData.width : _c, _d = options.srcH, srcH = _d === void 0 ? imageData.height : _d, _e = options.dstX, dstX = _e === void 0 ? 0 : _e, _f = options.dstY, dstY = _f === void 0 ? 0 : _f;\n var _g = options.dstW, dstW = _g === void 0 ? srcW : _g, _h = options.dstH, dstH = _h === void 0 ? srcH : _h;\n if (srcX !== 0 || srcY !== 0 || srcW !== dstW || srcH !== dstH) {\n imageData = cropAndResizeImageData(imageData, { srcX: srcX, srcY: srcY, srcW: srcW, srcH: srcH, dstW: dstW, dstH: dstH });\n }\n canvas_1.getContext2D(canvas).putImageData(imageData, dstX, dstY);\n}\nexports.setImageDataToCanvas = setImageDataToCanvas;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_data.js\n// module id = 42\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/math\n * @preferred\n *\n * Module `WebDNN.Math` provides basic mathematics operations for pre/post-processing.\n */\n/** Don't Remove This comment block */\nfunction __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n}\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__export(require(\"./math/argsort\"));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/math.js\n// module id = 43\n// module chunks = 0","\"use strict\";\n/**\n * @module webdnn/math\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/** Don't Remove This comment block */\n/**\n * Return indices of the top-K largest elements.\n * This implementation is not stable sort.\n *\n * @param {number[]|Float32Array} arr array\n * @param {number} k number of indices\n * @returns {number[]} indices of top-K largest samples\n */\nfunction argmax(arr, k) {\n // Top-k Quicksort\n if (k === void 0) { k = 1; }\n arr = arr.slice();\n var stack = [[0, arr.length]];\n var workspace = [];\n for (var i = 0; i < arr.length; i++)\n workspace[i] = i;\n while (stack.length > 0) {\n var _a = stack.pop(), from = _a[0], to = _a[1], pivot = arr[to - 1], left = from, right = to - 2, tmp = void 0;\n if (from >= to - 1)\n continue;\n while (true) {\n while (arr[left] > pivot && left <= right)\n left++;\n while (arr[right] <= pivot && left <= right)\n right--;\n if (left >= right)\n break;\n tmp = arr[left];\n arr[left] = arr[right];\n arr[right] = tmp;\n tmp = workspace[left];\n workspace[left] = workspace[right];\n workspace[right] = tmp;\n }\n arr[to - 1] = arr[left];\n arr[left] = pivot;\n tmp = workspace[to - 1];\n workspace[to - 1] = workspace[left];\n workspace[left] = tmp;\n // If partial segment contains top-K elements, append it into stack\n stack.push([from, left]); // left (=larger) segment always contains top-K elements\n if (left + 1 < k)\n stack.push([left + 1, to]);\n }\n var result = [];\n for (var i = 0; i < k; i++)\n result.push(workspace[i]);\n return result;\n}\nexports.argmax = argmax;\n/**\n * Return indices of the top-K smallest elements.\n * This implementation is not stable sort.\n *\n * @param {number[]|Float32Array|Int32Array} arr array\n * @param {number} k number of indices\n * @returns {number[]} indices of top-K smallest samples\n */\nfunction argmin(arr, k) {\n // Top-k Quicksort\n if (k === void 0) { k = 1; }\n arr = arr.slice();\n var stack = [[0, arr.length]];\n var workspace = [];\n for (var i = 0; i < arr.length; i++)\n workspace[i] = i;\n while (stack.length > 0) {\n var _a = stack.pop(), from = _a[0], to = _a[1], pivot = arr[to - 1], left = from, right = to - 2, tmp = void 0;\n if (from >= to - 1)\n continue;\n while (true) {\n while (arr[left] < pivot && left <= right)\n left++;\n while (arr[right] >= pivot && left <= right)\n right--;\n if (left >= right)\n break;\n tmp = arr[left];\n arr[left] = arr[right];\n arr[right] = tmp;\n tmp = workspace[left];\n workspace[left] = workspace[right];\n workspace[right] = tmp;\n }\n arr[to - 1] = arr[left];\n arr[left] = pivot;\n tmp = workspace[to - 1];\n workspace[to - 1] = workspace[left];\n workspace[left] = tmp;\n // If partial segment contains top-K elements, append it into stack\n stack.push([from, left]); // left (=larger) segment always contains top-K elements\n if (left + 1 < k)\n stack.push([left + 1, to]);\n }\n var result = [];\n for (var i = 0; i < k; i++)\n result.push(workspace[i]);\n return result;\n}\nexports.argmin = argmin;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/math/argsort.js\n// module id = 44\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/webdnn.js b/dist/webdnn.js index 9295adcba..6a707459e 100644 --- a/dist/webdnn.js +++ b/dist/webdnn.js @@ -3,7 +3,7 @@ Version 1.5.6 https://localforage.github.io/localForage (c) 2013-2017 Mozilla, Apache License 2.0 -*/(function(t){e.exports=t()})(function(){return function d(c,e,t){function r(i,o){if(!e[i]){if(!c[i]){if(!o&&'function'==typeof a&&a)return a(i,!0);if(n)return n(i,!0);var s=new Error('Cannot find module \''+i+'\'');throw s.code='MODULE_NOT_FOUND',s}var h=e[i]={exports:{}};c[i][0].call(h.exports,function(t){var e=c[i][1][t];return r(e?e:t)},h,h.exports,d,c,e,t)}return e[i].exports}for(var n='function'==typeof a&&a,i=0;i=a.oldVersion&&e.createObjectStore(D)}catch(e){if('ConstraintError'===e.name)console.warn('The database "'+t.name+'" has been upgraded from version '+a.oldVersion+' to version '+a.newVersion+', but the storage "'+t.storeName+'" already exists.');else throw e}}),i.onerror=function(t){t.preventDefault(),n(i.error)},i.onsuccess=function(){a(i.result),u(t)}})}function _(e){return f(e,!1)}function p(e){return f(e,!0)}function m(e,t){if(!e.db)return!0;var a=!e.db.objectStoreNames.contains(e.storeName),n=e.versione.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+'" can\'t be downgraded from version '+e.db.version+' to version '+e.version+'.'),e.version=e.db.version),r||a){if(a){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function g(t){return new A(function(a,e){var n=new FileReader;n.onerror=e,n.onloadend=function(n){var e=btoa(n.target.result||'');a({__local_forage_encoded_blob:!0,data:e,type:t.type})},n.readAsBinaryString(t)})}function b(e){var t=d(atob(e.data));return n([t],{type:e.type})}function y(e){return e&&e.__local_forage_encoded_blob}function w(e){var t=this,a=t._initReady().then(function(){var e=_e[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady});return i(a,e,e),a}function v(e){c(e);for(var t=_e[e.name],a=t.forages,n=0;n>4,c[n++]=(15&o)<<4|d>>2,c[n++]=(3&d)<<6|63&s;return l}function k(e){var t=new Uint8Array(e),a='',n;for(n=0;n>2],a+=F[(3&t[n])<<4|t[n+1]>>4],a+=F[(15&t[n+1])<<2|t[n+2]>>6],a+=F[63&t[n+2]];return 2==t.length%3?a=a.substring(0,a.length-1)+'=':1==t.length%3&&(a=a.substring(0,a.length-2)+'=='),a}function T(e,t,a,n){var i=this;e=o(e);var d=new A(function(r,o){i.ready().then(function(){void 0===t&&(t=null);var d=t,s=i._dbInfo;s.serializer.serialize(t,function(l,t){t?o(t):s.db.transaction(function(a){a.executeSql('INSERT OR REPLACE INTO '+s.storeName+' (key, value) VALUES (?, ?)',[e,l],function(){r(d)},function(e,t){o(t)})},function(t){if(t.code===t.QUOTA_ERR){if(0e?void t(null):void a.ready().then(function(){x(a._dbInfo,L,function(r,i){if(r)return n(r);try{var o=i.objectStore(a._dbInfo.storeName),d=!1,s=o.openCursor();s.onsuccess=function(){var a=s.result;return a?void(0===e?t(a.key):d?t(a.key):(d=!0,a.advance(e))):void t(null)},s.onerror=function(){n(s.error)}}catch(t){n(t)}})})['catch'](n)});return r(n,t),n},keys:function(e){var t=this,a=new A(function(e,a){t.ready().then(function(){x(t._dbInfo,L,function(n,r){if(n)return a(n);try{var i=r.objectStore(t._dbInfo.storeName),o=i.openCursor(),d=[];o.onsuccess=function(){var t=o.result;return t?void(d.push(t.key),t['continue']()):void e(d)},o.onerror=function(){a(o.error)}}catch(t){a(t)}})})['catch'](a)});return r(a,e),a}},F='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',M=/^~~local_forage_type~([^~]+)~/,W='__lfsc__:',H=W.length,j='arbf',U='blob',G='si08',X='ui08',Y='uic8',V='si16',Z='si32',K='ur16',q='ui32',Q='fl32',J='fl64',$=H+j.length,ee=Object.prototype.toString,te={serialize:function(t,a){var e='';if(t&&(e=ee.call(t)),t&&('[object ArrayBuffer]'===e||t.buffer&&'[object ArrayBuffer]'===ee.call(t.buffer))){var n=W,r;t instanceof ArrayBuffer?(r=t,n+=j):(r=t.buffer,'[object Int8Array]'===e?n+=G:'[object Uint8Array]'===e?n+=X:'[object Uint8ClampedArray]'===e?n+=Y:'[object Int16Array]'===e?n+=V:'[object Uint16Array]'===e?n+=K:'[object Int32Array]'===e?n+=Z:'[object Uint32Array]'===e?n+=q:'[object Float32Array]'===e?n+=Q:'[object Float64Array]'===e?n+=J:a(new Error('Failed to get type for BinaryArray'))),a(n+k(r))}else if('[object Blob]'===e){var i=new FileReader;i.onload=function(){var e='~~local_forage_type~'+t.type+'~'+k(this.result);a(W+U+e)},i.readAsArrayBuffer(t)}else try{a(JSON.stringify(t))}catch(n){console.error('Couldn\'t convert value into a JSON string: ',t),a(null,n)}},deserialize:function(e){if(e.substring(0,H)!==W)return JSON.parse(e);var t=e.substring($),a=e.substring(H,$),r;if(a===U&&M.test(t)){var i=t.match(M);r=i[1],t=t.substring(i[0].length)}var o=E(t);switch(a){case j:return o;case U:return n([o],{type:r});case G:return new Int8Array(o);case X:return new Uint8Array(o);case Y:return new Uint8ClampedArray(o);case V:return new Int16Array(o);case K:return new Uint16Array(o);case Z:return new Int32Array(o);case q:return new Uint32Array(o);case Q:return new Float32Array(o);case J:return new Float64Array(o);default:throw new Error('Unkown type: '+a);}},stringToBuffer:E,bufferToString:k},ae={_driver:'webSQLStorage',_initStorage:function(e){var t=this,a={db:null};if(e)for(var n in e)a[n]='string'==typeof e[n]?e[n]:e[n].toString();var r=new A(function(e,n){try{a.db=openDatabase(a.name,a.version+'',a.description,a.size)}catch(t){return n(t)}a.db.transaction(function(r){r.executeSql('CREATE TABLE IF NOT EXISTS '+a.storeName+' (id INTEGER PRIMARY KEY, key unique, value)',[],function(){t._dbInfo=a,e()},function(e,t){n(t)})})});return a.serializer=te,r},_support:function(){return'function'==typeof openDatabase}(),iterate:function(e,t){var a=this,n=new A(function(n,r){a.ready().then(function(){var o=a._dbInfo;o.db.transaction(function(a){a.executeSql('SELECT * FROM '+o.storeName,[],function(a,t){for(var r=t.rows,d=r.length,s=0;s'number'==typeof e)}update(e){this.values=Object.assign(this.values,e)}resolve(e){if('object'!=typeof e)return e;if(1==Object.keys(e).length&&'eval'in e){if(!this.isResolved)throw Error(`Not all placeholders are resolved: ${this}`);return eval('(function(placeholders){return '+e.eval+';})')(this.values)}return e instanceof Array?e.map((e)=>this.resolve(e)):Object.entries(e).reduce((e,[t,a])=>(e[t]=this.resolve(a),e),{})}toString(){return JSON.stringify(this.values)}}t.a=n},function(e,t,a){'use strict';var n=a(35);class r extends n.a{constructor(){super(...arguments),this.BYTES_PER_ELEMENT=4}toActual(){if(!this.buffer)throw new Error('Internal buffer for this variable is not set. DescriptorRunner.setPlaceholderValue() have to be called before calling this function.');return new Float32Array(this.buffer,this.byteOffset,this.length)}every(e,t){return this.toActual().every(e,t)}filter(e,t){return this.toActual().filter(e,t)}find(e,t){return this.toActual().find(e,t)}findIndex(e,t){return this.toActual().findIndex(e,t)}forEach(e,t){return this.toActual().forEach(e,t)}map(e,t){return this.toActual().map(e,t)}reduce(e,t){return this.toActual().reduce(e,t)}reduceRight(e,t){return this.toActual().reduceRight(e,t)}reverse(){return this.toActual().reverse()}slice(e,t){return this.toActual().slice(e,t)}some(e,t){return this.toActual().some(e,t)}subarray(e,t){return this.toActual().subarray(e,t)}includes(e,t){return this.toActual().includes(e,t)}}t.a=r,r.BYTES_PER_ELEMENT=4},function(e,t){'use strict';t.a=class{constructor(){this.descriptor=null}static checkAvailability(){return!1}}},function(e){'use strict';e.exports={0:'',1:'stream end',2:'need dictionary',"-1":'file error',"-2":'stream error',"-3":'data error',"-4":'insufficient memory',"-5":'buffer error',"-6":'incompatible version'}},function(e){'use strict';e.exports=function(e,t,a,r){for(var i=0|65535&e,o=0|65535&e>>>16,d=0;0!==a;){d=2e3t;t++){a=t;for(var n=0;8>n;n++)a=1&a?3988292384^a>>>1:a>>>1;e[t]=a}return e}();e.exports=function(e,a,n,r){e^=-1;for(var o=r;o>>8^t[255&(e^a[o])];return-1^e}},function(t,a,n){'use strict';function r(t,a){if(65537>a&&(t.subarray&&s||!t.subarray&&d))return e.apply(null,o.shrinkBuf(t,a));for(var n='',r=0;ri;i++)l[i]=252<=i?6:248<=i?5:240<=i?4:224<=i?3:192<=i?2:1;l[254]=l[254]=1,a.string2buf=function(e){var t=e.length,a=0,n,r,d,s,l;for(s=0;sr?1:2048>r?2:65536>r?3:4;for(n=new o.Buf8(a),l=0,s=0;lr?n[l++]=r:2048>r?(n[l++]=192|r>>>6,n[l++]=128|63&r):65536>r?(n[l++]=224|r>>>12,n[l++]=128|63&r>>>6,n[l++]=128|63&r):(n[l++]=240|r>>>18,n[l++]=128|63&r>>>12,n[l++]=128|63&r>>>6,n[l++]=128|63&r);return n},a.buf2binstring=function(e){return r(e,e.length)},a.binstring2buf=function(e){for(var t=new o.Buf8(e.length),a=0,n=t.length;ad){n[i++]=d;continue}if(s=l[d],4d?n[i++]=d:(d-=65536,n[i++]=55296|1023&d>>10,n[i++]=56320|1023&d)}return r(n,i)},a.utf8border=function(e,t){var a;for(t=t||e.length,t>e.length&&(t=e.length),a=t-1;0<=a&&128==(192&e[a]);)a--;return 0>a?t:0===a?t:a+l[e[a]]>t?a:t}},function(e){'use strict';e.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}},function(e){'use strict';e.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}},function(e,t,a){'use strict';function n(e){return'WebGL2RenderingContext'===e.constructor.name}function r(e){if(null===e)throw Error('Null is detected');return e}t.b=n;var i=a(2);let o;class d{constructor(){this.gl=r(d.initializeContext())}static getInstance(){return o||(o=new d),o}createTexture(e,t,a,n){let i=this.gl,o=r(i.createTexture());return i.activeTexture(i.TEXTURE0+9),i.bindTexture(i.TEXTURE_2D,o),i.texImage2D(i.TEXTURE_2D,0,a,e,t,0,n,i.FLOAT,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.bindTexture(i.TEXTURE_2D,null),o}createVertexShader(e){return this.createShader(this.gl.VERTEX_SHADER,e)}createFragmentShader(e){return this.createShader(this.gl.FRAGMENT_SHADER,e)}createShader(e,t){let a=r(this.gl.createShader(e));if(this.gl.shaderSource(a,t),this.gl.compileShader(a),!this.gl.getShaderParameter(a,this.gl.COMPILE_STATUS))throw console.error(this.gl.getShaderInfoLog(a)),Error('Shader Compile failed: '+this.gl.getShaderInfoLog(a));return a}createProgram(e,t){let a=r(this.gl.createProgram());if(this.gl.attachShader(a,t),this.gl.attachShader(a,e),this.gl.linkProgram(a),!this.gl.getProgramParameter(a,this.gl.LINK_STATUS))throw console.error(this.gl.getProgramInfoLog(a)),Error('ShaderProgram Initialization failed.');return a}createArrayBuffer(e){let t=r(this.gl.createBuffer());return this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t),this.gl.bufferData(this.gl.ARRAY_BUFFER,e,this.gl.STATIC_DRAW),t}createFrameBuffer(){return r(this.gl.createFramebuffer())}bindArrayBuffer(e){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e)}bindFrameBuffer(e,t,a){this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,e),this.gl.viewport(0,0,t,a),this.gl.scissor(0,0,t,a)}useProgram(e){this.gl.useProgram(e)}deleteTexture(e){this.gl.deleteTexture(e)}static initializeWebGL2Context(e=document.createElement('canvas')){let t;return t=e.getContext('webgl2'),t?t.getExtension('EXT_color_buffer_float')?Object(i.getConfiguration)('DEBUG',!1)&&!t.getExtension('WEBGL_debug_renderer_info')?null:t:null:null}static initializeWebGL1Context(e=document.createElement('canvas')){let t=e.getContext('webgl')||e.getContext('experimental-webgl');return t?t.getExtension('OES_texture_float')?d.IS_SAFARI?null:Object(i.getConfiguration)('DEBUG',!1)&&!t.getExtension('WEBGL_debug_renderer_info')?null:t:null:null}static initializeContext(){let e=document.createElement('canvas'),t;if(t=d.initializeWebGL2Context(e),t)Object(i.getConfiguration)('DEBUG',!1)&&console.info('WebGL2 is enabled');else if(t=d.initializeWebGL1Context(e),t)Object(i.getConfiguration)('DEBUG',!1)&&console.info('WebGL2 is disabled');else return null;return t.disable(t.DEPTH_TEST),t.disable(t.STENCIL_TEST),t.disable(t.BLEND),t.disable(t.DITHER),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SAMPLE_COVERAGE),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),t}static checkAvailability(){if(null===s){let e=d.initializeContext();s=!!e&&!(4096>Object(i.getConfiguration)('MAX_TEXTURE_SIZE',e.getParameter(e.MAX_TEXTURE_SIZE)))}return s}async waitForComplete(){let e=this.gl;if(n(e)){let t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0),a=e.clientWaitSync(t,0,0);for(;a!==e.CONDITION_SATISFIED&&a!==e.ALREADY_SIGNALED;)await new Promise((e)=>setTimeout(e,1)),a=e.clientWaitSync(t,0,0);e.deleteSync(t)}else e.finish()}get MAX_TEXTURE_SIZE(){let e=Object(i.getConfiguration)('MAX_TEXTURE_SIZE',this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE));if(16384<=e)return 4096;if(8192<=e)return 4096;if(4096<=e)return 4096;throw new Error(`MAX_TEXTURE_SIZE is too small: ${e}`)}}t.a=d,d.IS_SAFARI=-1!==navigator.userAgent.toLowerCase().indexOf('safari')&&-1===navigator.userAgent.toLowerCase().indexOf('chrome');let s=null},function(e,t){'use strict';t.a=class{constructor(e,t){this.byteLength=e,this.backend=t}}},function(e,t,a){'use strict';var n=a(17),r=a(15);class i extends r.a{constructor(e){super(e,'webgpu'),0==e&&(e=4),this.handler=n.b.getInstance(),this.buffer=this.handler.createBuffer(new Uint8Array(e)),this.bufferView=new Uint8Array(this.buffer.contents)}async write(e,t){await this.handler.sync();let a=new e.constructor(this.bufferView.buffer);a.set(e,t)}async read(e,t=0,a){if(!e)throw new Error('dst cannot be null');if(await this.handler.sync(),0!==this.byteLength){let n=e.constructor,r=new n(this.bufferView.buffer,this.bufferView.byteOffset+t*n.BYTES_PER_ELEMENT,a);e.set(r)}}getWriteView(e,t,a){return new a(this.bufferView.buffer,this.bufferView.byteOffset+e*a.BYTES_PER_ELEMENT,t)}getReadView(e,t,a){return new a(this.bufferView.buffer,this.bufferView.byteOffset+e*a.BYTES_PER_ELEMENT,t)}async syncWriteViews(){}async syncReadViews(){await this.handler.sync()}}t.a=i},function(e,t,a){'use strict';var n=a(16);let r;class i{constructor(){if(this.pipelineStates=new Map,!o)throw new Error('This browser does not support WebGPU');let e;try{e=document.createElement('canvas').getContext('webgpu')}catch(e){throw new Error(`During initializing WebGPURenderingContext, unexpected error is occurred: ${e.message}`)}if(!e)throw new Error('WebGPURenderingContext initialization failed');this.context=e,this.commandQueue=e.createCommandQueue(),this.loadKernel('kernel void sync(){}','basic')}static getInstance(){return r||(r=new i),r}createBuffer(e){return this.context.createBuffer(e)}loadKernel(e,t=''){let a=this.context.createLibrary(e);for(let n of a.functionNames){let e=a.functionWithName(n),r=this.context.createComputePipelineState(e);this.pipelineStates.set(t+'.'+n,r)}}createCommandBuffer(){return this.commandQueue.createCommandBuffer()}getPipelineStateByName(e){let t=this.pipelineStates.get(e);if(!t)throw TypeError(`Kernel function "${e}" is not loaded.`);return t}executeSinglePipelineState(e,t,a,r,i){let o=this.commandBuffer||(this.commandBuffer=this.createCommandBuffer()),d=o.createComputeCommandEncoder();d.setComputePipelineState(this.getPipelineStateByName(e));for(let o=0;o{t.onload=a,t.onerror=n,t.src=e}).then(()=>t)}async function n(e){let t=e.files;if(!t||0==t.length)throw new Error('No file is selected');let n=URL.createObjectURL(t[0]);return a(n)}t.b=a,t.c=n,t.a=async function(){let e=document.createElement('input');return e.type='file',e.accept='image/*',new Promise((t)=>{e.onchange=()=>t(n(e)),e.click()})}},function(e,t,a){'use strict';function n(e=10){return new Promise((t)=>setTimeout(t,e))}var r=a(3),i=a.n(r),o=a(4),d=a(1),s=a(5),l=a(6),c=a(7);class u extends c.a{constructor(){super(...arguments),this.backendName='fallback'}static checkAvailability(){return!0}async init(){}async setDescriptorAndParameters(e,t){this.setDescriptor(e),await this.compile(),await this.initializeStaticBuffer(t),this.placeholderContext&&this.placeholderContext.isResolved&&(await this.initializeDynamicBuffer())}async fetchDescriptor(e){this.directory=e;let t=await Object(d.a)(`${e}/graph_${this.backendName}.json`);return t.json()}async fetchParameters(e,t){let a=await Object(d.a)(`${e}/weight_${this.backendName}.bin`);return Object(d.b)(a,t)}async restoreCachedDescriptor(e){return r.getItem(`${e}_${this.backendName}_descriptor`).catch(()=>null)}async restoreCachedParameters(e,t){let a=await r.getItem(`${e}_${this.backendName}_parameters`).catch(()=>null);return a&&t&&t(a.byteLength,a.byteLength),a}async saveCache(e,t,a){await Promise.all([r.setItem(`${e}_${this.backendName}_descriptor`,t),r.setItem(`${e}_${this.backendName}_parameters`,a)])}setDescriptor(e){this.descriptor=e,this.placeholderContext=new s.a,this.placeholderContext.update(e.placeholders),this.kernelObj=null,this.variableMap=null,this.staticBuffer=null,this.dynamicBuffer=null}async compile(){if(!this.descriptor)throw new Error('Descriptor is not loaded');await new Promise((e)=>{let t=document.createElement('script');t.type='text/javascript',t.readyState?t.onreadystatechange=()=>{('loaded'==t.readyState||'complete'==t.readyState)&&(t.onreadystatechange=null,e())}:t.onload=e,t.src=Object(d.d)(`${this.directory}/kernels_fallback.js`),document.getElementsByTagName('head')[0].appendChild(t)}),this.kernelObj=window.dnn_fallback_kernel}async initializeStaticBuffer(e){if(!this.descriptor)throw new Error('Descriptor is not loaded');let t=this.descriptor,a=new Float32Array(t.memory_layout.static.size);this.staticBuffer=a;let n=this.variableMap||new Map;this.variableMap=n,Object.entries(t.memory_layout.static.allocations).forEach(([e,t])=>{n.set(e,new Float32Array(a.buffer,t.offset*Float32Array.BYTES_PER_ELEMENT,t.size))});let r=Object(o.a)(this.descriptor.weight_encoding);a.set((await r.decode(new Uint8Array(e)))),(await this.getInputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=a.buffer}),(await this.getOutputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=a.buffer})}async initializeDynamicBuffer(){if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext,a=new Float32Array(t.resolve(e.memory_layout.dynamic.size));this.dynamicBuffer=a;let n=this.variableMap||new Map;this.variableMap=n,Object.entries(e.memory_layout.dynamic.allocations).forEach(([e,r])=>{n.set(e,new Float32Array(a.buffer,t.resolve(r.offset)*Float32Array.BYTES_PER_ELEMENT,t.resolve(r.size)))}),(await this.getInputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=a.buffer}),(await this.getOutputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=a.buffer})}async setPlaceholderValue(e){if(!this.placeholderContext)throw new Error('placeholderContext is not initialized');let t=this.placeholderContext;t.update(e);t.isResolved&&(await this.initializeDynamicBuffer())}async run(){if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('placeholderContext is not initialized');if(!this.variableMap)throw new Error('Variable map is not initialized');if(!this.staticBuffer)throw new Error('StaticBuffer map is not initialized');if(!this.dynamicBuffer)throw new Error('DynamicBuffer map is not initialized');let e=this.variableMap,t=this.placeholderContext,a=this.descriptor.exec_infos.map((e)=>t.resolve(e)),r=Date.now(),o=Date.now();for(let t=0,i;te.get(t)),l=d.outputs.map((t)=>e.get(t));this.kernelObj[d.entry_func_name](s,l,d.call_option)}console.log(`Processed ${a.length}/${a.length} kernels in ${Date.now()-r} ms`)}getInputViews(){if(this.inputs)return this.inputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.inputs=e.inputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new l.a(null,n.offset*l.a.BYTES_PER_ELEMENT,n.size,t);return r}),this.inputs}getOutputViews(){if(this.outputs)return this.outputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.outputs=e.outputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new l.a(null,n.offset*l.a.BYTES_PER_ELEMENT,n.size,t);return r}),this.outputs}}t.a=u},function(e){var t=function(){return this}();try{t=t||Function('return this')()||(1,eval)('this')}catch(a){'object'==typeof window&&(t=window)}e.exports=t},function(e,t,a){'use strict';var n=a(24),r=a.n(n);class o{async decode(e){let t=[],a=0,r=new DataView(e.buffer,e.byteOffset),i=0;for(;ie;e++)l[e]=o.decode_table[127&e]*s*(128>e?1:-1);let c=new Uint8Array(e.buffer,e.byteOffset+i,d),u=n.inflate(c),h=u.length,f=new Float32Array(h);for(let e=0;et.windowBits&&(t.windowBits+=16),this.err=0,this.msg='',this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var a=i.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(a!==h)throw new Error(s[a]);if(t.header&&i.deflateSetHeader(this.strm,t.header),t.dictionary){var r;if(r='string'==typeof t.dictionary?d.string2buf(t.dictionary):'[object ArrayBuffer]'===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,a=i.deflateSetDictionary(this.strm,r),a!==h)throw new Error(s[a]);this._dict_set=!0}}function r(e,t){var a=new n(t);if(a.push(e,!0),a.err)throw a.msg||s[a.err];return a.result}var i=a(26),o=a(0),d=a(11),s=a(8),l=a(12),c=Object.prototype.toString,u=4,h=0,f=1,_=2,p=-1,m=0,g=8;n.prototype.push=function(e,t){var a=this.strm,n=this.options.chunkSize,r,s;if(this.ended)return!1;s=t===~~t?t:!0===t?u:0,a.input='string'==typeof e?d.string2buf(e):'[object ArrayBuffer]'===c.call(e)?new Uint8Array(e):e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new o.Buf8(n),a.next_out=0,a.avail_out=n),r=i.deflate(a,s),r!==f&&r!==h)return this.onEnd(r),this.ended=!0,!1;(0===a.avail_out||0===a.avail_in&&(s===u||s===_))&&('string'===this.options.to?this.onData(d.buf2binstring(o.shrinkBuf(a.output,a.next_out))):this.onData(o.shrinkBuf(a.output,a.next_out)))}while((0e.avail_out&&(a=e.avail_out);0===a||(E.arraySet(e.output,t.pending_buf,t.pending_out,a,e.next_out),e.next_out+=a,t.pending_out+=a,e.total_out+=a,e.avail_out-=a,t.pending-=a,0===t.pending&&(t.pending_out=0))}function d(e,t){k._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,o(e.strm)}function l(e,t){e.pending_buf[e.pending++]=t}function c(e,t){e.pending_buf[e.pending++]=255&t>>>8,e.pending_buf[e.pending++]=255&t}function u(e,t,a,n){var r=e.avail_in;return(r>n&&(r=n),0===r)?0:(e.avail_in-=r,E.arraySet(t,e.input,e.next_in,r,a),1===e.state.wrap?e.adler=T(e.adler,t,r,a):2===e.state.wrap&&(e.adler=C(e.adler,t,r,a)),e.next_in+=r,e.total_in+=r,r)}function h(e,t){var a=e.max_chain_length,n=e.strstart,r=e.prev_length,i=e.nice_match,o=e.strstart>e.w_size-K?e.strstart-(e.w_size-K):0,d=e.window,s=e.w_mask,l=e.prev,c=e.strstart+Z,u=d[n+r-1],h=d[n+r],f,_;e.prev_length>=e.good_match&&(a>>=2),i>e.lookahead&&(i=e.lookahead);do{if(f=t,d[f+r]!==h||d[f+r-1]!==u||d[f]!==d[n]||d[++f]!==d[n+1])continue;n+=2,f++;do;while(d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&nr){if(e.match_start=t,r=_,_>=i)break;u=d[n+r-1],h=d[n+r]}}while((t=l[t&s])>o&&0!=--a);return r<=e.lookahead?r:e.lookahead}function f(e){var t=e.w_size,a,r,n,i,o;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-K)){E.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,a=r;do n=e.head[--a],e.head[a]=n>=t?n-t:0;while(--r);r=t,a=r;do n=e.prev[--a],e.prev[a]=n>=t?n-t:0;while(--r);i+=t}if(0===e.strm.avail_in)break;if(r=u(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=V)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<=V&&(e.ins_h=(e.ins_h<=V))n=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;else if(n=k._tr_tally(e,e.strstart-e.match_start,e.match_length-V),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=V){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=V&&(e.ins_h=(e.ins_h<=e.match_length&&(e.strategy===P||e.match_length===V&&4096=V&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-V,n=k._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-V),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=(e.ins_h<=V&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=V?(n=k._tr_tally(e,1,e.match_length-V),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(d(e,!1),0===e.strm.avail_out))return ne}return e.insert=0,t===R?(d(e,!0),0===e.strm.avail_out?ie:oe):e.last_lit&&(d(e,!1),0===e.strm.avail_out)?ne:re}function m(e,t){for(var a;;){if(0===e.lookahead&&(f(e),0===e.lookahead)){if(t===S)return ne;break}if(e.match_length=0,a=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,a&&(d(e,!1),0===e.strm.avail_out))return ne}return e.insert=0,t===R?(d(e,!0),0===e.strm.avail_out?ie:oe):e.last_lit&&(d(e,!1),0===e.strm.avail_out)?ne:re}function g(e,t,a,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=a,this.max_chain=n,this.func=r}function b(e){e.window_size=2*e.w_size,i(e.head),e.max_lazy_match=de[e.level].max_lazy,e.good_match=de[e.level].good_length,e.nice_match=de[e.level].nice_length,e.max_chain_length=de[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=V-1,e.match_available=0,e.ins_h=0}function y(){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=W,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 E.Buf16(2*X),this.dyn_dtree=new E.Buf16(2*(2*U+1)),this.bl_tree=new E.Buf16(2*(2*G+1)),i(this.dyn_ltree),i(this.dyn_dtree),i(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new E.Buf16(Y+1),this.heap=new E.Buf16(2*j+1),i(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new E.Buf16(2*j+1),i(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 w(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=M,t=e.state,t.pending=0,t.pending_out=0,0>t.wrap&&(t.wrap=-t.wrap),t.status=t.wrap?q:te,e.adler=2===t.wrap?0:1,t.last_flush=S,k._tr_init(t),z):n(e,D)}function v(e){var t=w(e);return t===z&&b(e.state),t}function x(e,t,a,r,i,o){if(!e)return D;var d=1;if(t===L&&(t=6),0>r?(d=0,r=-r):15i||i>H||a!==W||8>r||15t||9o||o>F)return n(e,D);8===r&&(r=9);var l=new y;return e.state=l,l.strm=e,l.wrap=d,l.gzhead=null,l.w_bits=r,l.w_size=1<e.pending_buf_size-5&&(a=e.pending_buf_size-5);;){if(1>=e.lookahead){if(f(e),0===e.lookahead&&t===S)return ne;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+a;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,d(e,!1),0===e.strm.avail_out))return ne;if(e.strstart-e.block_start>=e.w_size-K&&(d(e,!1),0===e.strm.avail_out))return ne}return e.insert=0,t===R?(d(e,!0),0===e.strm.avail_out?ie:oe):e.strstart>e.block_start&&(d(e,!1),0===e.strm.avail_out)?ne:ne}),new g(4,4,8,4,s),new g(4,5,16,8,s),new g(4,6,32,32,s),new g(4,4,16,16,_),new g(8,16,32,32,_),new g(8,16,128,128,_),new g(8,32,128,256,_),new g(32,128,258,1024,_),new g(32,258,258,4096,_)],t.deflateInit=function(e,t){return x(e,t,W,15,8,0)},t.deflateInit2=x,t.deflateReset=v,t.deflateResetKeep=w,t.deflateSetHeader=function(e,t){return e&&e.state?2===e.state.wrap?(e.state.gzhead=t,z):D:D},t.deflate=function(e,t){var a,d,s,u;if(!e||!e.state||t>B||0>t)return e?n(e,D):D;if(d=e.state,!e.output||!e.input&&0!==e.avail_in||d.status===ae&&t!==R)return n(e,0===e.avail_out?N:D);if(d.strm=e,a=d.last_flush,d.last_flush=t,d.status===q)if(2===d.wrap)e.adler=0,l(d,31),l(d,139),l(d,8),d.gzhead?(l(d,(d.gzhead.text?1:0)+(d.gzhead.hcrc?2:0)+(d.gzhead.extra?4:0)+(d.gzhead.name?8:0)+(d.gzhead.comment?16:0)),l(d,255&d.gzhead.time),l(d,255&d.gzhead.time>>8),l(d,255&d.gzhead.time>>16),l(d,255&d.gzhead.time>>24),l(d,9===d.level?2:d.strategy>=O||2>d.level?4:0),l(d,255&d.gzhead.os),d.gzhead.extra&&d.gzhead.extra.length&&(l(d,255&d.gzhead.extra.length),l(d,255&d.gzhead.extra.length>>8)),d.gzhead.hcrc&&(e.adler=C(e.adler,d.pending_buf,d.pending,0)),d.gzindex=0,d.status=Q):(l(d,0),l(d,0),l(d,0),l(d,0),l(d,0),l(d,9===d.level?2:d.strategy>=O||2>d.level?4:0),l(d,3),d.status=te);else{var h=W+(d.w_bits-8<<4)<<8,f=-1;f=d.strategy>=O||2>d.level?0:6>d.level?1:6===d.level?2:3,h|=f<<6,0!==d.strstart&&(h|=32),h+=31-h%31,d.status=te,c(d,h),0!==d.strstart&&(c(d,e.adler>>>16),c(d,65535&e.adler)),e.adler=1}if(d.status===Q)if(d.gzhead.extra){for(s=d.pending;d.gzindex<(65535&d.gzhead.extra.length)&&!(d.pending===d.pending_buf_size&&(d.gzhead.hcrc&&d.pending>s&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),o(e),s=d.pending,d.pending===d.pending_buf_size));)l(d,255&d.gzhead.extra[d.gzindex]),d.gzindex++;d.gzhead.hcrc&&d.pending>s&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),d.gzindex===d.gzhead.extra.length&&(d.gzindex=0,d.status=J)}else d.status=J;if(d.status===J)if(d.gzhead.name){s=d.pending;do{if(d.pending===d.pending_buf_size&&(d.gzhead.hcrc&&d.pending>s&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),o(e),s=d.pending,d.pending===d.pending_buf_size)){u=1;break}u=d.gzindexs&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),0===u&&(d.gzindex=0,d.status=$)}else d.status=$;if(d.status===$)if(d.gzhead.comment){s=d.pending;do{if(d.pending===d.pending_buf_size&&(d.gzhead.hcrc&&d.pending>s&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),o(e),s=d.pending,d.pending===d.pending_buf_size)){u=1;break}u=d.gzindexs&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),0===u&&(d.status=ee)}else d.status=ee;if(d.status===ee&&(d.gzhead.hcrc?(d.pending+2>d.pending_buf_size&&o(e),d.pending+2<=d.pending_buf_size&&(l(d,255&e.adler),l(d,255&e.adler>>8),e.adler=0,d.status=te)):d.status=te),0!==d.pending){if(o(e),0===e.avail_out)return d.last_flush=-1,z;}else if(0===e.avail_in&&r(t)<=r(a)&&t!==R)return n(e,N);if(d.status===ae&&0!==e.avail_in)return n(e,N);if(0!==e.avail_in||0!==d.lookahead||t!==S&&d.status!==ae){var _=d.strategy===O?m(d,t):d.strategy===3?p(d,t):de[d.level].func(d,t);if((_===ie||_===oe)&&(d.status=ae),_===ne||_===ie)return 0===e.avail_out&&(d.last_flush=-1),z;if(_===re&&(t===1?k._tr_align(d):t!==B&&(k._tr_stored_block(d,0,0,!1),t===3&&(i(d.head),0===d.lookahead&&(d.strstart=0,d.block_start=0,d.insert=0))),o(e),0===e.avail_out))return d.last_flush=-1,z}return t===R?0>=d.wrap?A:(2===d.wrap?(l(d,255&e.adler),l(d,255&e.adler>>8),l(d,255&e.adler>>16),l(d,255&e.adler>>24),l(d,255&e.total_in),l(d,255&e.total_in>>8),l(d,255&e.total_in>>16),l(d,255&e.total_in>>24)):(c(d,e.adler>>>16),c(d,65535&e.adler)),o(e),0=r.w_size&&(0===n&&(i(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new E.Buf8(r.w_size),E.arraySet(u,t,a-r.w_size,r.w_size,0),t=u,a=r.w_size),s=e.avail_in,l=e.next_in,c=e.input,e.avail_in=a,e.next_in=0,e.input=t,f(r);r.lookahead>=V;){o=r.strstart,d=r.lookahead-(V-1);do r.ins_h=(r.ins_h<e?J[e]:J[256+(e>>>7)]}function d(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=255&t>>>8}function l(e,t,a){e.bi_valid>W-a?(e.bi_buf|=65535&t<>W-e.bi_valid,e.bi_valid+=a-W):(e.bi_buf|=65535&t<>>=1,a<<=1;while(0<--t);return a>>>1}function u(e){16===e.bi_valid?(d(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}function h(e,t){var a=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,d=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,l=t.stat_desc.max_length,c=0,u,h,n,_,p,m;for(_=0;_<=M;_++)e.bl_count[_]=0;for(a[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;ul&&(_=l,c++),a[2*h+1]=_,!(h>r))&&(e.bl_count[_]++,p=0,h>=s&&(p=d[h-s]),m=a[2*h],e.opt_len+=m*(_+p),o&&(e.static_len+=m*(i[2*h+1]+p)));if(0!=c){do{for(_=l-1;0===e.bl_count[_];)_--;e.bl_count[_]--,e.bl_count[_+1]+=2,e.bl_count[l]--,c-=2}while(0r))&&(a[2*n+1]!==_&&(e.opt_len+=(_-a[2*n+1])*a[2*n],a[2*n+1]=_),h--)}}function f(e,t,a){var r=Array(M+1),i=0,o,d;for(o=1;o<=M;o++)r[o]=i=i+a[o-1]<<1;for(d=0;d<=t;d++){var n=e[2*d+1];0!==n&&(e[2*d]=s(r[n]++,n))}}function _(){var e=Array(M+1),t,a,n,i,o;for(n=0,i=0;ii;i++)for(te[i]=o,t=0;t<1<>=7;i=t;)q[2*t+1]=8,t++,e[8]++;for(;255>=t;)q[2*t+1]=9,t++,e[9]++;for(;279>=t;)q[2*t+1]=7,t++,e[7]++;for(;287>=t;)q[2*t+1]=8,t++,e[8]++;for(f(q,L+1,e),t=0;te.heap_len;)l=e.heap[++e.heap_len]=2>d?++d:0,a[2*l]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=r[2*l+1]);for(t.max_code=d,s=e.heap_len>>1;1<=s;s--)y(e,a,s);l=o;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],y(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=n,a[2*l]=a[2*s]+a[2*n],e.depth[l]=(e.depth[s]>=e.depth[n]?e.depth[s]:e.depth[n])+1,a[2*s+1]=a[2*n+1]=l,e.heap[1]=l++,y(e,a,1);while(2<=e.heap_len);e.heap[--e.heap_max]=e.heap[1],h(e,t),f(a,d,e.bl_count)}function x(e,t,a){var r=-1,i=t[1],o=0,d=7,s=4,l,n;for(0===i&&(d=138,s=3),t[2*(a+1)+1]=65535,l=0;l<=a;l++){if(n=i,i=t[2*(l+1)+1],++o=o?e.bl_tree[2*G]++:e.bl_tree[2*X]++:(n!==r&&e.bl_tree[2*n]++,e.bl_tree[2*U]++);o=0,r=n,0===i?(d=138,s=3):n===i?(d=6,s=3):(d=7,s=4)}}function E(e,t,a){var r=-1,i=t[1],o=0,d=7,s=4,u,n;for(0===i&&(d=138,s=3),u=0;u<=a;u++){if(n=i,i=t[2*(u+1)+1],++o=o?(c(e,G,e.bl_tree),l(e,o-3,3)):(c(e,X,e.bl_tree),l(e,o-11,7)):(n!==r&&(c(e,n,e.bl_tree),o--),c(e,U,e.bl_tree),l(e,o-3,2));o=0,r=n,0===i?(d=138,s=3):n===i?(d=6,s=3):(d=7,s=4)}}function k(e){var t;for(x(e,e.dyn_ltree,e.l_desc.max_code),x(e,e.dyn_dtree,e.d_desc.max_code),v(e,e.bl_desc),t=O-1;3<=t&&0===e.bl_tree[2*K[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}function T(e,t,a,n){var r;for(l(e,t-257,5),l(e,a-1,5),l(e,n-4,4),r=0;r=a;a++,t>>>=1)if(1&t&&0!==e.dyn_ltree[2*a])return R;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return B;for(a=32;a>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=a+5,a+4<=i&&-1!==t?I(e,t,a,n):e.strategy===4||o===i?(l(e,(A<<1)+(n?1:0),3),w(e,q,Q)):(l(e,(2<<1)+(n?1:0),3),T(e,e.l_desc.max_code+1,e.d_desc.max_code+1,r+1),w(e,e.dyn_ltree,e.dyn_dtree)),p(e),n&&m(e)},t._tr_tally=function(e,t,a){return e.pending_buf[e.d_buf+2*e.last_lit]=255&t>>>8,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&a,e.last_lit++,0===t?e.dyn_ltree[2*a]++:(e.matches++,t--,e.dyn_ltree[2*($[a]+N+1)]++,e.dyn_dtree[2*o(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){l(e,A<<1,3),c(e,j,q),u(e)}},function(e,t,a){'use strict';function n(e){if(!(this instanceof n))return new n(e);this.options=o.assign({chunkSize:16384,windowBits:0,to:''},e||{});var t=this.options;t.raw&&0<=t.windowBits&&16>t.windowBits&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),0<=t.windowBits&&16>t.windowBits&&!(e&&e.windowBits)&&(t.windowBits+=32),15t.windowBits&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg='',this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var a=i.inflateInit2(this.strm,t.windowBits);if(a!==s.Z_OK)throw new Error(l[a]);this.header=new u,i.inflateGetHeader(this.strm,this.header)}function r(e,t){var a=new n(t);if(a.push(e,!0),a.err)throw a.msg||l[a.err];return a.result}var i=a(29),o=a(0),d=a(11),s=a(13),l=a(8),c=a(12),u=a(32),h=Object.prototype.toString;n.prototype.push=function(e,t){var a=this.strm,n=this.options.chunkSize,r=this.options.dictionary,l=!1,c,u,f,_,p,m;if(this.ended)return!1;u=t===~~t?t:!0===t?s.Z_FINISH:s.Z_NO_FLUSH,a.input='string'==typeof e?d.binstring2buf(e):'[object ArrayBuffer]'===h.call(e)?new Uint8Array(e):e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new o.Buf8(n),a.next_out=0,a.avail_out=n),c=i.inflate(a,s.Z_NO_FLUSH),c===s.Z_NEED_DICT&&r&&(m='string'==typeof r?d.string2buf(r):'[object ArrayBuffer]'===h.call(r)?new Uint8Array(r):r,c=i.inflateSetDictionary(this.strm,m)),c===s.Z_BUF_ERROR&&!0==l&&(c=s.Z_OK,l=!1),c!==s.Z_STREAM_END&&c!==s.Z_OK)return this.onEnd(c),this.ended=!0,!1;a.next_out&&(0===a.avail_out||c===s.Z_STREAM_END||0===a.avail_in&&(u===s.Z_FINISH||u===s.Z_SYNC_FLUSH))&&('string'===this.options.to?(f=d.utf8border(a.output,a.next_out),_=a.next_out-f,p=d.buf2string(a.output,f),a.next_out=_,a.avail_out=n-_,_&&o.arraySet(a.output,a.output,f,_,0),this.onData(p)):this.onData(o.shrinkBuf(a.output,a.next_out))),0===a.avail_in&&0===a.avail_out&&(l=!0)}while((0>>24)+(65280&e>>>8)+((65280&e)<<8)+((255&e)<<24)}function i(){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 h.Buf16(320),this.work=new h.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function o(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg='',t.wrap&&(e.adler=1&t.wrap),t.mode=C,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new h.Buf32(ne),t.distcode=t.distdyn=new h.Buf32(re),t.sane=1,t.back=-1,v):x}function d(e){var t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,o(e)):x}function s(e,t){var a,n;return e&&e.state?(n=e.state,0>t?(a=0,t=-t):(a=(t>>4)+1,48>t&&(t&=15)),t&&(8>t||15t;)e.lens[t++]=8;for(;256>t;)e.lens[t++]=9;for(;280>t;)e.lens[t++]=7;for(;288>t;)e.lens[t++]=8;for(m(g,e.lens,0,288,oe,0,e.work,{bits:9}),t=0;32>t;)e.lens[t++]=5;m(b,e.lens,0,32,de,0,e.work,{bits:5}),ie=!1}e.lencode=oe,e.lenbits=9,e.distcode=de,e.distbits=5}function u(e,t,a,n){var r=e.state,i;return null===r.window&&(r.wsize=1<=r.wsize?(h.arraySet(r.window,t,a-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):(i=r.wsize-r.wnext,i>n&&(i=n),h.arraySet(r.window,t,a-n,i,r.wnext),n-=i,n?(h.arraySet(r.window,t,a-n,n,0),r.wnext=n,r.whave=r.wsize):(r.wnext+=i,r.wnext===r.wsize&&(r.wnext=0),r.whavele;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>8,s.check=_(s.check,o,2,0),se=0,le=0,s.mode=I;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&se)<<8)+(se>>8))%31){t.msg='incorrect header check',s.mode=te;break}if((15&se)!=T){t.msg='unknown compression method',s.mode=te;break}if(se>>>=4,le-=4,ve=(15&se)+8,0===s.wbits)s.wbits=ve;else if(ve>s.wbits){t.msg='invalid window size',s.mode=te;break}s.dmax=1<le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>8),512&s.flags&&(o[0]=255&se,o[1]=255&se>>>8,s.check=_(s.check,o,2,0)),se=0,le=0,s.mode=S;case S:for(;32>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>8,o[2]=255&se>>>16,o[3]=255&se>>>24,s.check=_(s.check,o,4,0)),se=0,le=0,s.mode=R;case R:for(;16>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>8),512&s.flags&&(o[0]=255&se,o[1]=255&se>>>8,s.check=_(s.check,o,2,0)),se=0,le=0,s.mode=B;case B:if(1024&s.flags){for(;16>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>8,s.check=_(s.check,o,2,0)),se=0,le=0}else s.head&&(s.head.extra=null);s.mode=z;case z:if(1024&s.flags&&(he=s.length,he>oe&&(he=oe),he&&(s.head&&(ve=s.head.extra_len-s.length,!s.head.extra&&(s.head.extra=Array(s.head.extra_len)),h.arraySet(s.head.extra,l,re,he,ve)),512&s.flags&&(s.check=_(s.check,l,he,re)),oe-=he,re+=he,s.length-=he),s.length))break inf_leave;s.length=0,s.mode=A;case A:if(2048&s.flags){if(0===oe)break inf_leave;he=0;do ve=l[re+he++],s.head&&ve&&65536>s.length&&(s.head.name+=e(ve));while(ve&&hes.length&&(s.head.comment+=e(ve));while(ve&&hele;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>9,s.head.done=!0),t.adler=s.check=0,s.mode=O;break;case L:for(;32>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=7&le,le-=7&le,s.mode=J;break}for(;3>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=1,le-=1,3&se){case 0:s.mode=M;break;case 1:if(c(s),s.mode=X,a===w){se>>>=2,le-=2;break inf_leave}break;case 2:s.mode=j;break;case 3:t.msg='invalid block type',s.mode=te;}se>>>=2,le-=2;break;case M:for(se>>>=7&le,le-=7≤32>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>16)){t.msg='invalid stored block lengths',s.mode=te;break}if(s.length=65535&se,se=0,le=0,s.mode=W,a===w)break inf_leave;case W:s.mode=H;case H:if(he=s.length,he){if(he>oe&&(he=oe),he>de&&(he=de),0===he)break inf_leave;h.arraySet(ne,l,re,he,ie),oe-=he,re+=he,de-=he,ie+=he,s.length-=he;break}s.mode=O;break;case j:for(;14>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=5,le-=5,s.ndist=(31&se)+1,se>>>=5,le-=5,s.ncode=(15&se)+4,se>>>=4,le-=4,286le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=3,le-=3}for(;19>s.have;)s.lens[d[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,Ee={bits:s.lenbits},xe=m(0,s.lens,0,19,s.lencode,0,s.work,Ee),s.lenbits=Ee.bits,xe){t.msg='invalid code lengths set',s.mode=te;break}s.have=0,s.mode=G;case G:for(;s.have>>24,me=255&i>>>16,ge=65535&i,pe<=le)break;if(0===oe)break inf_leave;oe--,se+=l[re++]<ge)se>>>=pe,le-=pe,s.lens[s.have++]=ge;else{if(16===ge){for(ke=pe+2;le>>=pe,le-=pe,0===s.have){t.msg='invalid bit length repeat',s.mode=te;break}ve=s.lens[s.have-1],he=3+(3&se),se>>>=2,le-=2}else if(17===ge){for(ke=pe+3;le>>=pe,le-=pe,ve=0,he=3+(7&se),se>>>=3,le-=3}else{for(ke=pe+7;le>>=pe,le-=pe,ve=0,he=11+(127&se),se>>>=7,le-=7}if(s.have+he>s.nlen+s.ndist){t.msg='invalid bit length repeat',s.mode=te;break}for(;he--;)s.lens[s.have++]=ve}}if(s.mode===te)break;if(0===s.lens[256]){t.msg='invalid code -- missing end-of-block',s.mode=te;break}if(s.lenbits=9,Ee={bits:s.lenbits},xe=m(g,s.lens,0,s.nlen,s.lencode,0,s.work,Ee),s.lenbits=Ee.bits,xe){t.msg='invalid literal/lengths set',s.mode=te;break}if(s.distbits=6,s.distcode=s.distdyn,Ee={bits:s.distbits},xe=m(b,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,Ee),s.distbits=Ee.bits,xe){t.msg='invalid distances set',s.mode=te;break}if(s.mode=X,a===w)break inf_leave;case X:s.mode=Y;case Y:if(6<=oe&&258<=de){t.next_out=ie,t.avail_out=de,t.next_in=re,t.avail_in=oe,s.hold=se,s.bits=le,p(t,ue),ie=t.next_out,ne=t.output,de=t.avail_out,re=t.next_in,l=t.input,oe=t.avail_in,se=s.hold,le=s.bits,s.mode===O&&(s.back=-1);break}for(s.back=0;;){if(i=s.lencode[se&(1<>>24,me=255&i>>>16,ge=65535&i,pe<=le)break;if(0===oe)break inf_leave;oe--,se+=l[re++]<>be)],pe=i>>>24,me=255&i>>>16,ge=65535&i,be+pe<=le)break;if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=be,le-=be,s.back+=be}if(se>>>=pe,le-=pe,s.back+=pe,s.length=ge,0===me){s.mode=Q;break}if(32&me){s.back=-1,s.mode=O;break}if(64&me){t.msg='invalid literal/length code',s.mode=te;break}s.extra=15&me,s.mode=V;case V:if(s.extra){for(ke=s.extra;le>>=s.extra,le-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=Z;case Z:for(;;){if(i=s.distcode[se&(1<>>24,me=255&i>>>16,ge=65535&i,pe<=le)break;if(0===oe)break inf_leave;oe--,se+=l[re++]<>be)],pe=i>>>24,me=255&i>>>16,ge=65535&i,be+pe<=le)break;if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=be,le-=be,s.back+=be}if(se>>>=pe,le-=pe,s.back+=pe,64&me){t.msg='invalid distance code',s.mode=te;break}s.offset=ge,s.extra=15&me,s.mode=K;case K:if(s.extra){for(ke=s.extra;le>>=s.extra,le-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){t.msg='invalid distance too far back',s.mode=te;break}s.mode=q;case q:if(0===de)break inf_leave;if(he=ue-de,s.offset>he){if(he=s.offset-he,he>s.whave&&s.sane){t.msg='invalid distance too far back',s.mode=te;break}he>s.wnext?(he-=s.wnext,fe=s.wsize-he):fe=s.wnext-he,he>s.length&&(he=s.length),_e=s.window}else _e=ne,fe=ie-s.offset,he=s.length;he>de&&(he=de),de-=he,s.length-=he;do ne[ie++]=_e[fe++];while(--he);0===s.length&&(s.mode=Y);break;case Q:if(0===de)break inf_leave;ne[ie++]=s.length,de--,s.mode=Y;break;case J:if(s.wrap){for(;32>le;){if(0===oe)break inf_leave;oe--,se|=l[re++]<le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<p&&(_+=C[r++]<>>24,_>>>=v,p-=v,v=255&w>>>16,0===v)I[o++]=65535&w;else if(16&v){x=65535&w,v&=15,v&&(p>>=v,p-=v),15>p&&(_+=C[r++]<>>24,_>>>=v,p-=v,v=255&w>>>16,16&v){if(E=65535&w,v&=15,pl){e.msg='invalid distance too far back',n.mode=t;break top}if(_>>>=v,p-=v,v=o-d,E>v){if(v=E-v,v>u&&n.sane){e.msg='invalid distance too far back',n.mode=t;break top}if(k=0,T=f,0===h){if(k+=c-v,v>3,r-=x,p-=x<<3,_&=(1<E&&(k=E),0==E)return p[m++]=20971520,p[m++]=20971520,b.bits=1,0;for(x=1;xI)return-1;if(0i||e===l&&S>o)return 1;for(;;){j=w-C,g[v]H?(U=N[L+g[v]],G=B[z+g[v]]):(U=96,G=0),P=1<>C)+O]=0|(j<<24|U<<16|G);while(0!==O);for(P=1<>=1;if(0===P?R=0:(R&=P-1,R+=P),v++,0==--A[w]){if(w==E)break;w=t[a+g[v]]}if(w>k&&(R&M)!==F){for(0==C&&(C=k),W+=x,T=w-C,I=1<=I));)T++,I<<=1;if(S+=1<i||e===l&&S>o)return 1;F=R&M,p[F]=0|(k<<24|T<<16|W-m)}}return 0!==R&&(p[W+R]=0|(4194304|w-C<<24)),b.bits=k,0}},function(e){'use strict';e.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}},function(e,t){'use strict';t.a=class{async decode(e){return new Float32Array(e.buffer,e.byteOffset,e.byteLength/4)}}},function(e,t){'use strict';const a=-1;t.a=class{constructor(){this.scheduledCallbackId=a}request(e){this.fn=e,this.scheduledCallbackId==a&&(this.scheduledCallbackId=requestAnimationFrame(()=>this.forceDispatch()))}forceDispatch(){this.scheduledCallbackId==a||(this.cancel(),this.fn())}cancel(){this.scheduledCallbackId==a||(cancelAnimationFrame(this.scheduledCallbackId),this.scheduledCallbackId=a)}}},function(e,t){'use strict';function a(e){let t=[];for(let n=0,r;n!e.isDynamic).forEach((e)=>{e.buffer=new Float32Array(e.length).buffer}),(await this.getOutputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=new Float32Array(e.length).buffer})}async fetchDescriptor(e){this.directory=e;let t=await Object(o.a)(`${e}/graph_${this.backendName}.json`);return t.json()}async fetchParameters(e,t){let a=`${e}/weight_${this.backendName}.bin`,n=await Object(o.a)(a);return Object(o.b)(n,t)}async restoreCachedDescriptor(e){return this.directory=e,n.getItem(`${e}_${this.backendName}_descriptor`).catch(()=>null)}async restoreCachedParameters(e,t){let a=await n.getItem(`${e}_${this.backendName}_parameters`).catch(()=>null);return a&&t&&t(a.byteLength,a.byteLength),a}async saveCache(e,t,a){await Promise.all([n.setItem(`${e}_${this.backendName}_descriptor`,t),n.setItem(`${e}_${this.backendName}_parameters`,a)])}async setPlaceholderValue(e){if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized.');let t=this.placeholderContext;if(t.update(e),!t.isResolved)return;if(!this.descriptor)throw new Error('Descriptor is not loaded');let a=this.descriptor,n=a.unresolved_value_lists,r=[];for(let a=0,i;a{let n=t.resolve(e.placeholder);r.push(a,e.offset,n)});(await this.getInputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=new Float32Array(e.length).buffer}),(await this.getOutputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=new Float32Array(e.length).buffer});let i=this.placeholderContext.resolve(this.descriptor.memory_layout.dynamic.size);await this.setPlaceholderValueWorker(i,new Int32Array(r))}setPlaceholderValueWorker(e,t){if(!this.worker)throw Error('Worker is not initialized');let a=this.worker;return new Promise((n,r)=>{a.onmessage=(e)=>{0===e.data?n():(console.log(e.data),a.terminate(),r(new Error(e.data)))},a.postMessage({type:'set_dynamic_buffer',size:e,data:t})})}compile(){let e=new Worker(this.worker_entry_js_path);e.onerror=(e)=>{console.error(e),this.worker_promise_reject_func?this.worker_promise_reject_func(e):this.worker_initial_error=e};let t=new Promise((t,a)=>this.worker_initial_error?a(this.worker_initial_error):void(this.worker_promise_reject_func=a,e.onmessage=(n)=>{0===n.data?t():(console.error(n.data),e.terminate(),a(new Error(n.data)))}));return this.worker=e,t}async loadWeights(e){if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.worker)throw new Error('Worker is not initialized');let t=Object(i.a)(this.descriptor.weight_encoding),a=await t.decode(e),n=this.worker,r=new Promise((e,t)=>{this.worker_promise_reject_func=t,n.onmessage=(a)=>{0===a.data?e():(console.log(a.data),n.terminate(),t(new Error(a.data)))},n.postMessage({type:'weight',data:a},[a.buffer])});return r}getInputViews(){if(this.inputs)return this.inputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.inputs=e.inputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new s.a(null,0,n.size,t);return r}),this.inputs}getOutputViews(){if(this.outputs)return this.outputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.outputs=e.outputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new s.a(null,0,n.size,t);return r}),this.outputs}async run(){if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.worker)throw new Error('Worker is not initialized');if(!this.placeholderContext.isResolved)throw new Error('Not all placeholder is resolved');let e=this.placeholderContext,t=this.descriptor,a=this.worker,n=new Promise((n,r)=>{this.worker_promise_reject_func=r,a.onmessage=(e)=>{if(Array.isArray(e.data)){for(let t=0;tn;n++)if(r=o[n][t.inputs[a]],r){let t=this.inputs[a];d.push({space:n,offset:e.resolve(r.offset),size:t.length,data:t.toActual()});break}let s=[];for(let a=0;an;n++)if(r=o[n][t.outputs[a]],r){let t=this.outputs[a];s.push({space:n,offset:e.resolve(r.offset),size:t.length});break}a.postMessage({type:'run',inputs:d,outputs:s})});return n}}t.a=c},function(e,t,a){'use strict';var n=a(3),r=a.n(n),i=a(38),o=a(4),d=a(1),s=a(5),l=a(6),c=a(2),u=a(14),h=a(7);const f=new Float32Array([-1,1,-1,-1,1,1,1,-1]);class _ extends h.a{constructor(){super(...arguments),this.backendName='webgl'}static checkAvailability(){return u.a.checkAvailability()}async init(){if(!_.checkAvailability())throw Error('WebGL backend is not supported in this browser.');this.handler=u.a.getInstance();let e=this.handler.createArrayBuffer(f);this.handler.bindArrayBuffer(e),this.buffers=new Map}async fetchDescriptor(e){let t=await Object(d.a)(`${e}/graph_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}.json`);return t.json()}async fetchParameters(e,t){let a=await Object(d.a)(`${e}/weight_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}.bin`);return Object(d.b)(a,t)}async restoreCachedDescriptor(e){return n.getItem(`${e}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_descriptor`).catch(()=>null)}async restoreCachedParameters(e,t){let a=await n.getItem(`${e}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_parameters`).catch(()=>null);return a&&t&&t(a.byteLength,a.byteLength),a}async saveCache(e,t,a){await Promise.all([n.setItem(`${e}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_descriptor`,t),n.setItem(`${e}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_parameters`,a)])}async setDescriptorAndParameters(e,t){await this.setDescriptor(e),await this.compile(),await this.initializeStaticBuffer(t),this.placeholderContext&&this.placeholderContext.isResolved&&(await this.initializeDynamicBuffer())}async initializeStaticBuffer(e){if(!this.descriptor)throw new Error('Descriptor is not loaded');let t=this.descriptor,a=Object(o.a)(this.descriptor.weight_encoding),n=await a.decode(new Uint8Array(e)),r=this.buffers,d=t.memory_layout.mapping;Object.entries(t.memory_layout.static.allocations).forEach(([e,{width:t,height:a,size:n,channel_mode:o}])=>{r.set(e,new i.a(n*Float32Array.BYTES_PER_ELEMENT,t,a,e,null,o))}),Object.entries(t.constants_map).forEach(([e,{size:t,byte_offset:a}])=>{r.get(e).array.set(new Float32Array(n.buffer,a,t))}),(await this.getInputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=r.get(d[e.name]).getWriteView(0,e.length,Float32Array).buffer}),(await this.getOutputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=r.get(d[e.name]).getReadView(0,e.length,Float32Array).buffer})}async initializeDynamicBuffer(){if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');if(!this.placeholderContext)throw Error('PlaceholderContext is not initialized.');let e=this.descriptor,t=this.placeholderContext,a=this.buffers,n=e.memory_layout.mapping;Object.entries(e.memory_layout.dynamic.allocations).forEach(([e,{width:n,height:r,size:o,channel_mode:d}])=>{a.set(e,new i.a(t.resolve(o)*Float32Array.BYTES_PER_ELEMENT,t.resolve(n),t.resolve(r),e,null,d))}),(await this.getInputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=a.get(n[e.name]).getWriteView(0,t.resolve(e.length),Float32Array).buffer}),(await this.getOutputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=a.get(n[e.name]).getReadView(0,t.resolve(e.length),Float32Array).buffer}),this.buildPipeline()}async setDescriptor(e){this.descriptor=e,this.placeholderContext=new s.a(e.placeholders)}async compile(){if(!this.descriptor)throw new Error('Descriptor is not loaded');let e=this.descriptor;this.programs=new Map,this.vertexShader=this.handler.createVertexShader(` +*/(function(t){e.exports=t()})(function(){return function d(c,e,t){function r(i,o){if(!e[i]){if(!c[i]){if(!o&&'function'==typeof a&&a)return a(i,!0);if(n)return n(i,!0);var s=new Error('Cannot find module \''+i+'\'');throw s.code='MODULE_NOT_FOUND',s}var h=e[i]={exports:{}};c[i][0].call(h.exports,function(t){var e=c[i][1][t];return r(e?e:t)},h,h.exports,d,c,e,t)}return e[i].exports}for(var n='function'==typeof a&&a,i=0;i=a.oldVersion&&e.createObjectStore(D)}catch(e){if('ConstraintError'===e.name)console.warn('The database "'+t.name+'" has been upgraded from version '+a.oldVersion+' to version '+a.newVersion+', but the storage "'+t.storeName+'" already exists.');else throw e}}),i.onerror=function(t){t.preventDefault(),n(i.error)},i.onsuccess=function(){a(i.result),u(t)}})}function _(e){return f(e,!1)}function p(e){return f(e,!0)}function m(e,t){if(!e.db)return!0;var a=!e.db.objectStoreNames.contains(e.storeName),n=e.versione.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+'" can\'t be downgraded from version '+e.db.version+' to version '+e.version+'.'),e.version=e.db.version),r||a){if(a){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function g(t){return new z(function(a,e){var n=new FileReader;n.onerror=e,n.onloadend=function(n){var e=btoa(n.target.result||'');a({__local_forage_encoded_blob:!0,data:e,type:t.type})},n.readAsBinaryString(t)})}function b(e){var t=d(atob(e.data));return n([t],{type:e.type})}function y(e){return e&&e.__local_forage_encoded_blob}function w(e){var t=this,a=t._initReady().then(function(){var e=_e[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady});return i(a,e,e),a}function v(e){c(e);for(var t=_e[e.name],a=t.forages,n=0;n>4,c[n++]=(15&o)<<4|d>>2,c[n++]=(3&d)<<6|63&s;return l}function k(e){var t=new Uint8Array(e),a='',n;for(n=0;n>2],a+=F[(3&t[n])<<4|t[n+1]>>4],a+=F[(15&t[n+1])<<2|t[n+2]>>6],a+=F[63&t[n+2]];return 2==t.length%3?a=a.substring(0,a.length-1)+'=':1==t.length%3&&(a=a.substring(0,a.length-2)+'=='),a}function T(e,t,a,n){var i=this;e=o(e);var d=new z(function(r,o){i.ready().then(function(){void 0===t&&(t=null);var d=t,s=i._dbInfo;s.serializer.serialize(t,function(l,t){t?o(t):s.db.transaction(function(a){a.executeSql('INSERT OR REPLACE INTO '+s.storeName+' (key, value) VALUES (?, ?)',[e,l],function(){r(d)},function(e,t){o(t)})},function(t){if(t.code===t.QUOTA_ERR){if(0e?void t(null):void a.ready().then(function(){x(a._dbInfo,L,function(r,i){if(r)return n(r);try{var o=i.objectStore(a._dbInfo.storeName),d=!1,s=o.openCursor();s.onsuccess=function(){var a=s.result;return a?void(0===e?t(a.key):d?t(a.key):(d=!0,a.advance(e))):void t(null)},s.onerror=function(){n(s.error)}}catch(t){n(t)}})})['catch'](n)});return r(n,t),n},keys:function(e){var t=this,a=new z(function(e,a){t.ready().then(function(){x(t._dbInfo,L,function(n,r){if(n)return a(n);try{var i=r.objectStore(t._dbInfo.storeName),o=i.openCursor(),d=[];o.onsuccess=function(){var t=o.result;return t?void(d.push(t.key),t['continue']()):void e(d)},o.onerror=function(){a(o.error)}}catch(t){a(t)}})})['catch'](a)});return r(a,e),a}},F='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',M=/^~~local_forage_type~([^~]+)~/,W='__lfsc__:',j=W.length,U='arbf',H='blob',G='si08',X='ui08',Y='uic8',V='si16',Z='si32',K='ur16',q='ui32',Q='fl32',J='fl64',$=j+U.length,ee=Object.prototype.toString,te={serialize:function(t,a){var e='';if(t&&(e=ee.call(t)),t&&('[object ArrayBuffer]'===e||t.buffer&&'[object ArrayBuffer]'===ee.call(t.buffer))){var n=W,r;t instanceof ArrayBuffer?(r=t,n+=U):(r=t.buffer,'[object Int8Array]'===e?n+=G:'[object Uint8Array]'===e?n+=X:'[object Uint8ClampedArray]'===e?n+=Y:'[object Int16Array]'===e?n+=V:'[object Uint16Array]'===e?n+=K:'[object Int32Array]'===e?n+=Z:'[object Uint32Array]'===e?n+=q:'[object Float32Array]'===e?n+=Q:'[object Float64Array]'===e?n+=J:a(new Error('Failed to get type for BinaryArray'))),a(n+k(r))}else if('[object Blob]'===e){var i=new FileReader;i.onload=function(){var e='~~local_forage_type~'+t.type+'~'+k(this.result);a(W+H+e)},i.readAsArrayBuffer(t)}else try{a(JSON.stringify(t))}catch(n){console.error('Couldn\'t convert value into a JSON string: ',t),a(null,n)}},deserialize:function(e){if(e.substring(0,j)!==W)return JSON.parse(e);var t=e.substring($),a=e.substring(j,$),r;if(a===H&&M.test(t)){var i=t.match(M);r=i[1],t=t.substring(i[0].length)}var o=E(t);switch(a){case U:return o;case H:return n([o],{type:r});case G:return new Int8Array(o);case X:return new Uint8Array(o);case Y:return new Uint8ClampedArray(o);case V:return new Int16Array(o);case K:return new Uint16Array(o);case Z:return new Int32Array(o);case q:return new Uint32Array(o);case Q:return new Float32Array(o);case J:return new Float64Array(o);default:throw new Error('Unkown type: '+a);}},stringToBuffer:E,bufferToString:k},ae={_driver:'webSQLStorage',_initStorage:function(e){var t=this,a={db:null};if(e)for(var n in e)a[n]='string'==typeof e[n]?e[n]:e[n].toString();var r=new z(function(e,n){try{a.db=openDatabase(a.name,a.version+'',a.description,a.size)}catch(t){return n(t)}a.db.transaction(function(r){r.executeSql('CREATE TABLE IF NOT EXISTS '+a.storeName+' (id INTEGER PRIMARY KEY, key unique, value)',[],function(){t._dbInfo=a,e()},function(e,t){n(t)})})});return a.serializer=te,r},_support:function(){return'function'==typeof openDatabase}(),iterate:function(e,t){var a=this,n=new z(function(n,r){a.ready().then(function(){var o=a._dbInfo;o.db.transaction(function(a){a.executeSql('SELECT * FROM '+o.storeName,[],function(a,t){for(var r=t.rows,d=r.length,s=0;s'number'==typeof e)}update(e){this.values=Object.assign(this.values,e)}resolve(e){if('object'!=typeof e)return e;if(1==Object.keys(e).length&&'eval'in e){if(!this.isResolved)throw Error(`Not all placeholders are resolved: ${this}`);return eval('(function(placeholders){return '+e.eval+';})')(this.values)}return e instanceof Array?e.map((e)=>this.resolve(e)):Object.entries(e).reduce((e,[t,a])=>(e[t]=this.resolve(a),e),{})}toString(){return JSON.stringify(this.values)}}t.a=n},function(e,t,a){'use strict';var n=a(35);class r extends n.a{constructor(){super(...arguments),this.BYTES_PER_ELEMENT=4}toActual(){if(!this.buffer)throw new Error('Internal buffer for this variable is not set. DescriptorRunner.setPlaceholderValue() have to be called before calling this function.');return new Float32Array(this.buffer,this.byteOffset,this.length)}every(e,t){return this.toActual().every(e,t)}filter(e,t){return this.toActual().filter(e,t)}find(e,t){return this.toActual().find(e,t)}findIndex(e,t){return this.toActual().findIndex(e,t)}forEach(e,t){return this.toActual().forEach(e,t)}map(e,t){return this.toActual().map(e,t)}reduce(e,t){return this.toActual().reduce(e,t)}reduceRight(e,t){return this.toActual().reduceRight(e,t)}reverse(){return this.toActual().reverse()}slice(e,t){return this.toActual().slice(e,t)}some(e,t){return this.toActual().some(e,t)}subarray(e,t){return this.toActual().subarray(e,t)}includes(e,t){return this.toActual().includes(e,t)}}t.a=r,r.BYTES_PER_ELEMENT=4},function(e,t){'use strict';t.a=class{constructor(){this.descriptor=null}static checkAvailability(){return!1}}},function(e){'use strict';e.exports={0:'',1:'stream end',2:'need dictionary',"-1":'file error',"-2":'stream error',"-3":'data error',"-4":'insufficient memory',"-5":'buffer error',"-6":'incompatible version'}},function(e){'use strict';e.exports=function(e,t,a,r){for(var i=0|65535&e,o=0|65535&e>>>16,d=0;0!==a;){d=2e3t;t++){a=t;for(var n=0;8>n;n++)a=1&a?3988292384^a>>>1:a>>>1;e[t]=a}return e}();e.exports=function(e,a,n,r){e^=-1;for(var o=r;o>>8^t[255&(e^a[o])];return-1^e}},function(t,a,n){'use strict';function r(t,a){if(65537>a&&(t.subarray&&s||!t.subarray&&d))return e.apply(null,o.shrinkBuf(t,a));for(var n='',r=0;ri;i++)l[i]=252<=i?6:248<=i?5:240<=i?4:224<=i?3:192<=i?2:1;l[254]=l[254]=1,a.string2buf=function(e){var t=e.length,a=0,n,r,d,s,l;for(s=0;sr?1:2048>r?2:65536>r?3:4;for(n=new o.Buf8(a),l=0,s=0;lr?n[l++]=r:2048>r?(n[l++]=192|r>>>6,n[l++]=128|63&r):65536>r?(n[l++]=224|r>>>12,n[l++]=128|63&r>>>6,n[l++]=128|63&r):(n[l++]=240|r>>>18,n[l++]=128|63&r>>>12,n[l++]=128|63&r>>>6,n[l++]=128|63&r);return n},a.buf2binstring=function(e){return r(e,e.length)},a.binstring2buf=function(e){for(var t=new o.Buf8(e.length),a=0,n=t.length;ad){n[i++]=d;continue}if(s=l[d],4d?n[i++]=d:(d-=65536,n[i++]=55296|1023&d>>10,n[i++]=56320|1023&d)}return r(n,i)},a.utf8border=function(e,t){var a;for(t=t||e.length,t>e.length&&(t=e.length),a=t-1;0<=a&&128==(192&e[a]);)a--;return 0>a?t:0===a?t:a+l[e[a]]>t?a:t}},function(e){'use strict';e.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}},function(e){'use strict';e.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}},function(e,t,a){'use strict';function n(e){return'WebGL2RenderingContext'===e.constructor.name}function r(e){if(null===e)throw Error('Null is detected');return e}t.b=n;var i=a(2);let o;class d{constructor(){this.gl=r(d.initializeContext())}static getInstance(){return o||(o=new d),o}createTexture(e,t,a,n){let i=this.gl,o=r(i.createTexture());return i.activeTexture(i.TEXTURE0+9),i.bindTexture(i.TEXTURE_2D,o),i.texImage2D(i.TEXTURE_2D,0,a,e,t,0,n,i.FLOAT,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.bindTexture(i.TEXTURE_2D,null),o}createVertexShader(e){return this.createShader(this.gl.VERTEX_SHADER,e)}createFragmentShader(e){return this.createShader(this.gl.FRAGMENT_SHADER,e)}createShader(e,t){let a=r(this.gl.createShader(e));if(this.gl.shaderSource(a,t),this.gl.compileShader(a),!this.gl.getShaderParameter(a,this.gl.COMPILE_STATUS))throw console.error(this.gl.getShaderInfoLog(a)),Error('Shader Compile failed: '+this.gl.getShaderInfoLog(a));return a}createProgram(e,t){let a=r(this.gl.createProgram());if(this.gl.attachShader(a,t),this.gl.attachShader(a,e),this.gl.linkProgram(a),!this.gl.getProgramParameter(a,this.gl.LINK_STATUS))throw console.error(this.gl.getProgramInfoLog(a)),Error('ShaderProgram Initialization failed.');return a}createArrayBuffer(e){let t=r(this.gl.createBuffer());return this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t),this.gl.bufferData(this.gl.ARRAY_BUFFER,e,this.gl.STATIC_DRAW),t}createFrameBuffer(){return r(this.gl.createFramebuffer())}bindArrayBuffer(e){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e)}bindFrameBuffer(e,t,a){this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,e),this.gl.viewport(0,0,t,a),this.gl.scissor(0,0,t,a)}useProgram(e){this.gl.useProgram(e)}deleteTexture(e){this.gl.deleteTexture(e)}static initializeWebGL2Context(e=document.createElement('canvas')){let t;return t=e.getContext('webgl2'),t?t.getExtension('EXT_color_buffer_float')?Object(i.getConfiguration)('DEBUG',!1)&&!t.getExtension('WEBGL_debug_renderer_info')?null:t:null:null}static initializeWebGL1Context(e=document.createElement('canvas')){let t=e.getContext('webgl')||e.getContext('experimental-webgl');return t?t.getExtension('OES_texture_float')?d.IS_SAFARI?null:Object(i.getConfiguration)('DEBUG',!1)&&!t.getExtension('WEBGL_debug_renderer_info')?null:t:null:null}static initializeContext(){let e=document.createElement('canvas'),t;if(t=d.initializeWebGL2Context(e),t)Object(i.getConfiguration)('DEBUG',!1)&&console.info('WebGL2 is enabled');else if(t=d.initializeWebGL1Context(e),t)Object(i.getConfiguration)('DEBUG',!1)&&console.info('WebGL2 is disabled');else return null;return t.disable(t.DEPTH_TEST),t.disable(t.STENCIL_TEST),t.disable(t.BLEND),t.disable(t.DITHER),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SAMPLE_COVERAGE),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),t}static checkAvailability(){if(null===s){let e=d.initializeContext();s=!!e&&!(4096>Object(i.getConfiguration)('MAX_TEXTURE_SIZE',e.getParameter(e.MAX_TEXTURE_SIZE)))}return s}async waitForComplete(){let e=this.gl;if(n(e)){let t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0),a=e.clientWaitSync(t,0,0);for(;a!==e.CONDITION_SATISFIED&&a!==e.ALREADY_SIGNALED;)await new Promise((e)=>setTimeout(e,1)),a=e.clientWaitSync(t,0,0);e.deleteSync(t)}else e.finish()}get MAX_TEXTURE_SIZE(){let e=Object(i.getConfiguration)('MAX_TEXTURE_SIZE',this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE));if(16384<=e)return 4096;if(8192<=e)return 4096;if(4096<=e)return 4096;throw new Error(`MAX_TEXTURE_SIZE is too small: ${e}`)}}t.a=d,d.IS_SAFARI=-1!==navigator.userAgent.toLowerCase().indexOf('safari')&&-1===navigator.userAgent.toLowerCase().indexOf('chrome');let s=null},function(e,t){'use strict';t.a=class{constructor(e,t){this.byteLength=e,this.backend=t}}},function(e,t,a){'use strict';var n=a(17),r=a(15);class i extends r.a{constructor(e){super(e,'webgpu'),0==e&&(e=4),this.handler=n.b.getInstance(),this.buffer=this.handler.createBuffer(new Uint8Array(e)),this.bufferView=new Uint8Array(this.buffer.contents)}async write(e,t){await this.handler.sync();let a=new e.constructor(this.bufferView.buffer);a.set(e,t)}async read(e,t=0,a){if(!e)throw new Error('dst cannot be null');if(await this.handler.sync(),0!==this.byteLength){let n=e.constructor,r=new n(this.bufferView.buffer,this.bufferView.byteOffset+t*n.BYTES_PER_ELEMENT,a);e.set(r)}}getWriteView(e,t,a){return new a(this.bufferView.buffer,this.bufferView.byteOffset+e*a.BYTES_PER_ELEMENT,t)}getReadView(e,t,a){return new a(this.bufferView.buffer,this.bufferView.byteOffset+e*a.BYTES_PER_ELEMENT,t)}async syncWriteViews(){}async syncReadViews(){await this.handler.sync()}}t.a=i},function(e,t,a){'use strict';var n=a(16);let r;class i{constructor(){if(this.pipelineStates=new Map,!o)throw new Error('This browser does not support WebGPU');let e;try{e=document.createElement('canvas').getContext('webgpu')}catch(e){throw new Error(`During initializing WebGPURenderingContext, unexpected error is occurred: ${e.message}`)}if(!e)throw new Error('WebGPURenderingContext initialization failed');this.context=e,this.commandQueue=e.createCommandQueue(),this.loadKernel('kernel void sync(){}','basic')}static getInstance(){return r||(r=new i),r}createBuffer(e){return this.context.createBuffer(e)}loadKernel(e,t=''){let a=this.context.createLibrary(e);for(let n of a.functionNames){let e=a.functionWithName(n),r=this.context.createComputePipelineState(e);this.pipelineStates.set(t+'.'+n,r)}}createCommandBuffer(){return this.commandQueue.createCommandBuffer()}getPipelineStateByName(e){let t=this.pipelineStates.get(e);if(!t)throw TypeError(`Kernel function "${e}" is not loaded.`);return t}executeSinglePipelineState(e,t,a,r,i){let o=this.commandBuffer||(this.commandBuffer=this.createCommandBuffer()),d=o.createComputeCommandEncoder();d.setComputePipelineState(this.getPipelineStateByName(e));for(let o=0;o{t.onload=a,t.onerror=n,t.src=e}).then(()=>t)}async function n(e){let t=e.files;if(!t||0==t.length)throw new Error('No file is selected');let n=URL.createObjectURL(t[0]);return a(n)}t.b=a,t.c=n,t.a=async function(){let e=document.createElement('input');return e.type='file',e.accept='image/*',new Promise((t)=>{e.onchange=()=>t(n(e)),e.click()})}},function(e,t,a){'use strict';function n(e=10){return new Promise((t)=>setTimeout(t,e))}var r=a(3),i=a.n(r),o=a(4),d=a(1),s=a(5),l=a(6),c=a(7);class u extends c.a{constructor(){super(...arguments),this.backendName='fallback'}static checkAvailability(){return!0}async init(){}async setDescriptorAndParameters(e,t){this.setDescriptor(e),await this.compile(),await this.initializeStaticBuffer(t),this.placeholderContext&&this.placeholderContext.isResolved&&(await this.initializeDynamicBuffer())}async fetchDescriptor(e){this.directory=e;let t=await Object(d.a)(`${e}/graph_${this.backendName}.json`);return t.json()}async fetchParameters(e,t){let a=await Object(d.a)(`${e}/weight_${this.backendName}.bin`);return Object(d.b)(a,t)}async restoreCachedDescriptor(e){return r.getItem(`${e}_${this.backendName}_descriptor`).catch(()=>null)}async restoreCachedParameters(e,t){let a=await r.getItem(`${e}_${this.backendName}_parameters`).catch(()=>null);return a&&t&&t(a.byteLength,a.byteLength),a}async saveCache(e,t,a){await Promise.all([r.setItem(`${e}_${this.backendName}_descriptor`,t),r.setItem(`${e}_${this.backendName}_parameters`,a)])}setDescriptor(e){this.descriptor=e,this.placeholderContext=new s.a,this.placeholderContext.update(e.placeholders),this.kernelObj=null,this.variableMap=null,this.staticBuffer=null,this.dynamicBuffer=null}async compile(){if(!this.descriptor)throw new Error('Descriptor is not loaded');await new Promise((e)=>{let t=document.createElement('script');t.type='text/javascript',t.readyState?t.onreadystatechange=()=>{('loaded'==t.readyState||'complete'==t.readyState)&&(t.onreadystatechange=null,e())}:t.onload=e,t.src=Object(d.d)(`${this.directory}/kernels_fallback.js`),document.getElementsByTagName('head')[0].appendChild(t)}),this.kernelObj=window.dnn_fallback_kernel}async initializeStaticBuffer(e){if(!this.descriptor)throw new Error('Descriptor is not loaded');let t=this.descriptor,a=new Float32Array(t.memory_layout.static.size);this.staticBuffer=a;let n=this.variableMap||new Map;this.variableMap=n,Object.entries(t.memory_layout.static.allocations).forEach(([e,t])=>{n.set(e,new Float32Array(a.buffer,t.offset*Float32Array.BYTES_PER_ELEMENT,t.size))});let r=Object(o.a)(this.descriptor.weight_encoding);a.set((await r.decode(new Uint8Array(e)))),(await this.getInputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=a.buffer}),(await this.getOutputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=a.buffer})}async initializeDynamicBuffer(){if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext,a=new Float32Array(t.resolve(e.memory_layout.dynamic.size));this.dynamicBuffer=a;let n=this.variableMap||new Map;this.variableMap=n,Object.entries(e.memory_layout.dynamic.allocations).forEach(([e,r])=>{n.set(e,new Float32Array(a.buffer,t.resolve(r.offset)*Float32Array.BYTES_PER_ELEMENT,t.resolve(r.size)))}),(await this.getInputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=a.buffer}),(await this.getOutputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=a.buffer})}async setPlaceholderValue(e){if(!this.placeholderContext)throw new Error('placeholderContext is not initialized');let t=this.placeholderContext;t.update(e);t.isResolved&&(await this.initializeDynamicBuffer())}async run(){if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('placeholderContext is not initialized');if(!this.variableMap)throw new Error('Variable map is not initialized');if(!this.staticBuffer)throw new Error('StaticBuffer map is not initialized');if(!this.dynamicBuffer)throw new Error('DynamicBuffer map is not initialized');let e=this.variableMap,t=this.placeholderContext,a=this.descriptor.exec_infos.map((e)=>t.resolve(e)),r=Date.now(),o=Date.now();for(let t=0,i;te.get(t)),l=d.outputs.map((t)=>e.get(t));this.kernelObj[d.entry_func_name](s,l,d.call_option)}console.log(`Processed ${a.length}/${a.length} kernels in ${Date.now()-r} ms`)}getInputViews(){if(this.inputs)return this.inputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.inputs=e.inputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new l.a(null,n.offset*l.a.BYTES_PER_ELEMENT,n.size,t);return r}),this.inputs}getOutputViews(){if(this.outputs)return this.outputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.outputs=e.outputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new l.a(null,n.offset*l.a.BYTES_PER_ELEMENT,n.size,t);return r}),this.outputs}}t.a=u},function(e){var t=function(){return this}();try{t=t||Function('return this')()||(1,eval)('this')}catch(a){'object'==typeof window&&(t=window)}e.exports=t},function(e,t,a){'use strict';var n=a(24),r=a.n(n);class o{async decode(e){let t=[],a=0,r=new DataView(e.buffer,e.byteOffset),i=0;for(;ie;e++)l[e]=o.decode_table[127&e]*s*(128>e?1:-1);let c=new Uint8Array(e.buffer,e.byteOffset+i,d),u=n.inflate(c),h=u.length,f=new Float32Array(h);for(let e=0;et.windowBits&&(t.windowBits+=16),this.err=0,this.msg='',this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var a=i.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(a!==h)throw new Error(s[a]);if(t.header&&i.deflateSetHeader(this.strm,t.header),t.dictionary){var r;if(r='string'==typeof t.dictionary?d.string2buf(t.dictionary):'[object ArrayBuffer]'===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,a=i.deflateSetDictionary(this.strm,r),a!==h)throw new Error(s[a]);this._dict_set=!0}}function r(e,t){var a=new n(t);if(a.push(e,!0),a.err)throw a.msg||s[a.err];return a.result}var i=a(26),o=a(0),d=a(11),s=a(8),l=a(12),c=Object.prototype.toString,u=4,h=0,f=1,_=2,p=-1,m=0,g=8;n.prototype.push=function(e,t){var a=this.strm,n=this.options.chunkSize,r,s;if(this.ended)return!1;s=t===~~t?t:!0===t?u:0,a.input='string'==typeof e?d.string2buf(e):'[object ArrayBuffer]'===c.call(e)?new Uint8Array(e):e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new o.Buf8(n),a.next_out=0,a.avail_out=n),r=i.deflate(a,s),r!==f&&r!==h)return this.onEnd(r),this.ended=!0,!1;(0===a.avail_out||0===a.avail_in&&(s===u||s===_))&&('string'===this.options.to?this.onData(d.buf2binstring(o.shrinkBuf(a.output,a.next_out))):this.onData(o.shrinkBuf(a.output,a.next_out)))}while((0e.avail_out&&(a=e.avail_out);0===a||(E.arraySet(e.output,t.pending_buf,t.pending_out,a,e.next_out),e.next_out+=a,t.pending_out+=a,e.total_out+=a,e.avail_out-=a,t.pending-=a,0===t.pending&&(t.pending_out=0))}function d(e,t){k._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,o(e.strm)}function l(e,t){e.pending_buf[e.pending++]=t}function c(e,t){e.pending_buf[e.pending++]=255&t>>>8,e.pending_buf[e.pending++]=255&t}function u(e,t,a,n){var r=e.avail_in;return(r>n&&(r=n),0===r)?0:(e.avail_in-=r,E.arraySet(t,e.input,e.next_in,r,a),1===e.state.wrap?e.adler=T(e.adler,t,r,a):2===e.state.wrap&&(e.adler=C(e.adler,t,r,a)),e.next_in+=r,e.total_in+=r,r)}function h(e,t){var a=e.max_chain_length,n=e.strstart,r=e.prev_length,i=e.nice_match,o=e.strstart>e.w_size-K?e.strstart-(e.w_size-K):0,d=e.window,s=e.w_mask,l=e.prev,c=e.strstart+Z,u=d[n+r-1],h=d[n+r],f,_;e.prev_length>=e.good_match&&(a>>=2),i>e.lookahead&&(i=e.lookahead);do{if(f=t,d[f+r]!==h||d[f+r-1]!==u||d[f]!==d[n]||d[++f]!==d[n+1])continue;n+=2,f++;do;while(d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&d[++n]===d[++f]&&nr){if(e.match_start=t,r=_,_>=i)break;u=d[n+r-1],h=d[n+r]}}while((t=l[t&s])>o&&0!=--a);return r<=e.lookahead?r:e.lookahead}function f(e){var t=e.w_size,a,r,n,i,o;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-K)){E.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,a=r;do n=e.head[--a],e.head[a]=n>=t?n-t:0;while(--r);r=t,a=r;do n=e.prev[--a],e.prev[a]=n>=t?n-t:0;while(--r);i+=t}if(0===e.strm.avail_in)break;if(r=u(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=V)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<=V&&(e.ins_h=(e.ins_h<=V))n=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;else if(n=k._tr_tally(e,e.strstart-e.match_start,e.match_length-V),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=V){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=V&&(e.ins_h=(e.ins_h<=e.match_length&&(e.strategy===P||e.match_length===V&&4096=V&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-V,n=k._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-V),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=(e.ins_h<=V&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=V?(n=k._tr_tally(e,1,e.match_length-V),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(d(e,!1),0===e.strm.avail_out))return ne}return e.insert=0,t===R?(d(e,!0),0===e.strm.avail_out?ie:oe):e.last_lit&&(d(e,!1),0===e.strm.avail_out)?ne:re}function m(e,t){for(var a;;){if(0===e.lookahead&&(f(e),0===e.lookahead)){if(t===S)return ne;break}if(e.match_length=0,a=k._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,a&&(d(e,!1),0===e.strm.avail_out))return ne}return e.insert=0,t===R?(d(e,!0),0===e.strm.avail_out?ie:oe):e.last_lit&&(d(e,!1),0===e.strm.avail_out)?ne:re}function g(e,t,a,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=a,this.max_chain=n,this.func=r}function b(e){e.window_size=2*e.w_size,i(e.head),e.max_lazy_match=de[e.level].max_lazy,e.good_match=de[e.level].good_length,e.nice_match=de[e.level].nice_length,e.max_chain_length=de[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=V-1,e.match_available=0,e.ins_h=0}function y(){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=W,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 E.Buf16(2*X),this.dyn_dtree=new E.Buf16(2*(2*H+1)),this.bl_tree=new E.Buf16(2*(2*G+1)),i(this.dyn_ltree),i(this.dyn_dtree),i(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new E.Buf16(Y+1),this.heap=new E.Buf16(2*U+1),i(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new E.Buf16(2*U+1),i(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 w(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=M,t=e.state,t.pending=0,t.pending_out=0,0>t.wrap&&(t.wrap=-t.wrap),t.status=t.wrap?q:te,e.adler=2===t.wrap?0:1,t.last_flush=S,k._tr_init(t),A):n(e,D)}function v(e){var t=w(e);return t===A&&b(e.state),t}function x(e,t,a,r,i,o){if(!e)return D;var d=1;if(t===L&&(t=6),0>r?(d=0,r=-r):15i||i>j||a!==W||8>r||15t||9o||o>F)return n(e,D);8===r&&(r=9);var l=new y;return e.state=l,l.strm=e,l.wrap=d,l.gzhead=null,l.w_bits=r,l.w_size=1<e.pending_buf_size-5&&(a=e.pending_buf_size-5);;){if(1>=e.lookahead){if(f(e),0===e.lookahead&&t===S)return ne;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+a;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,d(e,!1),0===e.strm.avail_out))return ne;if(e.strstart-e.block_start>=e.w_size-K&&(d(e,!1),0===e.strm.avail_out))return ne}return e.insert=0,t===R?(d(e,!0),0===e.strm.avail_out?ie:oe):e.strstart>e.block_start&&(d(e,!1),0===e.strm.avail_out)?ne:ne}),new g(4,4,8,4,s),new g(4,5,16,8,s),new g(4,6,32,32,s),new g(4,4,16,16,_),new g(8,16,32,32,_),new g(8,16,128,128,_),new g(8,32,128,256,_),new g(32,128,258,1024,_),new g(32,258,258,4096,_)],t.deflateInit=function(e,t){return x(e,t,W,15,8,0)},t.deflateInit2=x,t.deflateReset=v,t.deflateResetKeep=w,t.deflateSetHeader=function(e,t){return e&&e.state?2===e.state.wrap?(e.state.gzhead=t,A):D:D},t.deflate=function(e,t){var a,d,s,u;if(!e||!e.state||t>B||0>t)return e?n(e,D):D;if(d=e.state,!e.output||!e.input&&0!==e.avail_in||d.status===ae&&t!==R)return n(e,0===e.avail_out?N:D);if(d.strm=e,a=d.last_flush,d.last_flush=t,d.status===q)if(2===d.wrap)e.adler=0,l(d,31),l(d,139),l(d,8),d.gzhead?(l(d,(d.gzhead.text?1:0)+(d.gzhead.hcrc?2:0)+(d.gzhead.extra?4:0)+(d.gzhead.name?8:0)+(d.gzhead.comment?16:0)),l(d,255&d.gzhead.time),l(d,255&d.gzhead.time>>8),l(d,255&d.gzhead.time>>16),l(d,255&d.gzhead.time>>24),l(d,9===d.level?2:d.strategy>=O||2>d.level?4:0),l(d,255&d.gzhead.os),d.gzhead.extra&&d.gzhead.extra.length&&(l(d,255&d.gzhead.extra.length),l(d,255&d.gzhead.extra.length>>8)),d.gzhead.hcrc&&(e.adler=C(e.adler,d.pending_buf,d.pending,0)),d.gzindex=0,d.status=Q):(l(d,0),l(d,0),l(d,0),l(d,0),l(d,0),l(d,9===d.level?2:d.strategy>=O||2>d.level?4:0),l(d,3),d.status=te);else{var h=W+(d.w_bits-8<<4)<<8,f=-1;f=d.strategy>=O||2>d.level?0:6>d.level?1:6===d.level?2:3,h|=f<<6,0!==d.strstart&&(h|=32),h+=31-h%31,d.status=te,c(d,h),0!==d.strstart&&(c(d,e.adler>>>16),c(d,65535&e.adler)),e.adler=1}if(d.status===Q)if(d.gzhead.extra){for(s=d.pending;d.gzindex<(65535&d.gzhead.extra.length)&&!(d.pending===d.pending_buf_size&&(d.gzhead.hcrc&&d.pending>s&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),o(e),s=d.pending,d.pending===d.pending_buf_size));)l(d,255&d.gzhead.extra[d.gzindex]),d.gzindex++;d.gzhead.hcrc&&d.pending>s&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),d.gzindex===d.gzhead.extra.length&&(d.gzindex=0,d.status=J)}else d.status=J;if(d.status===J)if(d.gzhead.name){s=d.pending;do{if(d.pending===d.pending_buf_size&&(d.gzhead.hcrc&&d.pending>s&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),o(e),s=d.pending,d.pending===d.pending_buf_size)){u=1;break}u=d.gzindexs&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),0===u&&(d.gzindex=0,d.status=$)}else d.status=$;if(d.status===$)if(d.gzhead.comment){s=d.pending;do{if(d.pending===d.pending_buf_size&&(d.gzhead.hcrc&&d.pending>s&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),o(e),s=d.pending,d.pending===d.pending_buf_size)){u=1;break}u=d.gzindexs&&(e.adler=C(e.adler,d.pending_buf,d.pending-s,s)),0===u&&(d.status=ee)}else d.status=ee;if(d.status===ee&&(d.gzhead.hcrc?(d.pending+2>d.pending_buf_size&&o(e),d.pending+2<=d.pending_buf_size&&(l(d,255&e.adler),l(d,255&e.adler>>8),e.adler=0,d.status=te)):d.status=te),0!==d.pending){if(o(e),0===e.avail_out)return d.last_flush=-1,A;}else if(0===e.avail_in&&r(t)<=r(a)&&t!==R)return n(e,N);if(d.status===ae&&0!==e.avail_in)return n(e,N);if(0!==e.avail_in||0!==d.lookahead||t!==S&&d.status!==ae){var _=d.strategy===O?m(d,t):d.strategy===3?p(d,t):de[d.level].func(d,t);if((_===ie||_===oe)&&(d.status=ae),_===ne||_===ie)return 0===e.avail_out&&(d.last_flush=-1),A;if(_===re&&(t===1?k._tr_align(d):t!==B&&(k._tr_stored_block(d,0,0,!1),t===3&&(i(d.head),0===d.lookahead&&(d.strstart=0,d.block_start=0,d.insert=0))),o(e),0===e.avail_out))return d.last_flush=-1,A}return t===R?0>=d.wrap?z:(2===d.wrap?(l(d,255&e.adler),l(d,255&e.adler>>8),l(d,255&e.adler>>16),l(d,255&e.adler>>24),l(d,255&e.total_in),l(d,255&e.total_in>>8),l(d,255&e.total_in>>16),l(d,255&e.total_in>>24)):(c(d,e.adler>>>16),c(d,65535&e.adler)),o(e),0=r.w_size&&(0===n&&(i(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new E.Buf8(r.w_size),E.arraySet(u,t,a-r.w_size,r.w_size,0),t=u,a=r.w_size),s=e.avail_in,l=e.next_in,c=e.input,e.avail_in=a,e.next_in=0,e.input=t,f(r);r.lookahead>=V;){o=r.strstart,d=r.lookahead-(V-1);do r.ins_h=(r.ins_h<e?J[e]:J[256+(e>>>7)]}function d(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=255&t>>>8}function l(e,t,a){e.bi_valid>W-a?(e.bi_buf|=65535&t<>W-e.bi_valid,e.bi_valid+=a-W):(e.bi_buf|=65535&t<>>=1,a<<=1;while(0<--t);return a>>>1}function u(e){16===e.bi_valid?(d(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}function h(e,t){var a=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,d=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,l=t.stat_desc.max_length,c=0,u,h,n,_,p,m;for(_=0;_<=M;_++)e.bl_count[_]=0;for(a[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;ul&&(_=l,c++),a[2*h+1]=_,!(h>r))&&(e.bl_count[_]++,p=0,h>=s&&(p=d[h-s]),m=a[2*h],e.opt_len+=m*(_+p),o&&(e.static_len+=m*(i[2*h+1]+p)));if(0!=c){do{for(_=l-1;0===e.bl_count[_];)_--;e.bl_count[_]--,e.bl_count[_+1]+=2,e.bl_count[l]--,c-=2}while(0r))&&(a[2*n+1]!==_&&(e.opt_len+=(_-a[2*n+1])*a[2*n],a[2*n+1]=_),h--)}}function f(e,t,a){var r=Array(M+1),i=0,o,d;for(o=1;o<=M;o++)r[o]=i=i+a[o-1]<<1;for(d=0;d<=t;d++){var n=e[2*d+1];0!==n&&(e[2*d]=s(r[n]++,n))}}function _(){var e=Array(M+1),t,a,n,i,o;for(n=0,i=0;ii;i++)for(te[i]=o,t=0;t<1<>=7;i=t;)q[2*t+1]=8,t++,e[8]++;for(;255>=t;)q[2*t+1]=9,t++,e[9]++;for(;279>=t;)q[2*t+1]=7,t++,e[7]++;for(;287>=t;)q[2*t+1]=8,t++,e[8]++;for(f(q,L+1,e),t=0;te.heap_len;)l=e.heap[++e.heap_len]=2>d?++d:0,a[2*l]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=r[2*l+1]);for(t.max_code=d,s=e.heap_len>>1;1<=s;s--)y(e,a,s);l=o;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],y(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=n,a[2*l]=a[2*s]+a[2*n],e.depth[l]=(e.depth[s]>=e.depth[n]?e.depth[s]:e.depth[n])+1,a[2*s+1]=a[2*n+1]=l,e.heap[1]=l++,y(e,a,1);while(2<=e.heap_len);e.heap[--e.heap_max]=e.heap[1],h(e,t),f(a,d,e.bl_count)}function x(e,t,a){var r=-1,i=t[1],o=0,d=7,s=4,l,n;for(0===i&&(d=138,s=3),t[2*(a+1)+1]=65535,l=0;l<=a;l++){if(n=i,i=t[2*(l+1)+1],++o=o?e.bl_tree[2*G]++:e.bl_tree[2*X]++:(n!==r&&e.bl_tree[2*n]++,e.bl_tree[2*H]++);o=0,r=n,0===i?(d=138,s=3):n===i?(d=6,s=3):(d=7,s=4)}}function E(e,t,a){var r=-1,i=t[1],o=0,d=7,s=4,u,n;for(0===i&&(d=138,s=3),u=0;u<=a;u++){if(n=i,i=t[2*(u+1)+1],++o=o?(c(e,G,e.bl_tree),l(e,o-3,3)):(c(e,X,e.bl_tree),l(e,o-11,7)):(n!==r&&(c(e,n,e.bl_tree),o--),c(e,H,e.bl_tree),l(e,o-3,2));o=0,r=n,0===i?(d=138,s=3):n===i?(d=6,s=3):(d=7,s=4)}}function k(e){var t;for(x(e,e.dyn_ltree,e.l_desc.max_code),x(e,e.dyn_dtree,e.d_desc.max_code),v(e,e.bl_desc),t=O-1;3<=t&&0===e.bl_tree[2*K[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}function T(e,t,a,n){var r;for(l(e,t-257,5),l(e,a-1,5),l(e,n-4,4),r=0;r=a;a++,t>>>=1)if(1&t&&0!==e.dyn_ltree[2*a])return R;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return B;for(a=32;a>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=a+5,a+4<=i&&-1!==t?I(e,t,a,n):e.strategy===4||o===i?(l(e,(z<<1)+(n?1:0),3),w(e,q,Q)):(l(e,(2<<1)+(n?1:0),3),T(e,e.l_desc.max_code+1,e.d_desc.max_code+1,r+1),w(e,e.dyn_ltree,e.dyn_dtree)),p(e),n&&m(e)},t._tr_tally=function(e,t,a){return e.pending_buf[e.d_buf+2*e.last_lit]=255&t>>>8,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&a,e.last_lit++,0===t?e.dyn_ltree[2*a]++:(e.matches++,t--,e.dyn_ltree[2*($[a]+N+1)]++,e.dyn_dtree[2*o(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){l(e,z<<1,3),c(e,U,q),u(e)}},function(e,t,a){'use strict';function n(e){if(!(this instanceof n))return new n(e);this.options=o.assign({chunkSize:16384,windowBits:0,to:''},e||{});var t=this.options;t.raw&&0<=t.windowBits&&16>t.windowBits&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),0<=t.windowBits&&16>t.windowBits&&!(e&&e.windowBits)&&(t.windowBits+=32),15t.windowBits&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg='',this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var a=i.inflateInit2(this.strm,t.windowBits);if(a!==s.Z_OK)throw new Error(l[a]);this.header=new u,i.inflateGetHeader(this.strm,this.header)}function r(e,t){var a=new n(t);if(a.push(e,!0),a.err)throw a.msg||l[a.err];return a.result}var i=a(29),o=a(0),d=a(11),s=a(13),l=a(8),c=a(12),u=a(32),h=Object.prototype.toString;n.prototype.push=function(e,t){var a=this.strm,n=this.options.chunkSize,r=this.options.dictionary,l=!1,c,u,f,_,p,m;if(this.ended)return!1;u=t===~~t?t:!0===t?s.Z_FINISH:s.Z_NO_FLUSH,a.input='string'==typeof e?d.binstring2buf(e):'[object ArrayBuffer]'===h.call(e)?new Uint8Array(e):e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new o.Buf8(n),a.next_out=0,a.avail_out=n),c=i.inflate(a,s.Z_NO_FLUSH),c===s.Z_NEED_DICT&&r&&(m='string'==typeof r?d.string2buf(r):'[object ArrayBuffer]'===h.call(r)?new Uint8Array(r):r,c=i.inflateSetDictionary(this.strm,m)),c===s.Z_BUF_ERROR&&!0==l&&(c=s.Z_OK,l=!1),c!==s.Z_STREAM_END&&c!==s.Z_OK)return this.onEnd(c),this.ended=!0,!1;a.next_out&&(0===a.avail_out||c===s.Z_STREAM_END||0===a.avail_in&&(u===s.Z_FINISH||u===s.Z_SYNC_FLUSH))&&('string'===this.options.to?(f=d.utf8border(a.output,a.next_out),_=a.next_out-f,p=d.buf2string(a.output,f),a.next_out=_,a.avail_out=n-_,_&&o.arraySet(a.output,a.output,f,_,0),this.onData(p)):this.onData(o.shrinkBuf(a.output,a.next_out))),0===a.avail_in&&0===a.avail_out&&(l=!0)}while((0>>24)+(65280&e>>>8)+((65280&e)<<8)+((255&e)<<24)}function i(){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 h.Buf16(320),this.work=new h.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function o(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg='',t.wrap&&(e.adler=1&t.wrap),t.mode=C,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new h.Buf32(ne),t.distcode=t.distdyn=new h.Buf32(re),t.sane=1,t.back=-1,v):x}function d(e){var t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,o(e)):x}function s(e,t){var a,n;return e&&e.state?(n=e.state,0>t?(a=0,t=-t):(a=(t>>4)+1,48>t&&(t&=15)),t&&(8>t||15t;)e.lens[t++]=8;for(;256>t;)e.lens[t++]=9;for(;280>t;)e.lens[t++]=7;for(;288>t;)e.lens[t++]=8;for(m(g,e.lens,0,288,oe,0,e.work,{bits:9}),t=0;32>t;)e.lens[t++]=5;m(b,e.lens,0,32,de,0,e.work,{bits:5}),ie=!1}e.lencode=oe,e.lenbits=9,e.distcode=de,e.distbits=5}function u(e,t,a,n){var r=e.state,i;return null===r.window&&(r.wsize=1<=r.wsize?(h.arraySet(r.window,t,a-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):(i=r.wsize-r.wnext,i>n&&(i=n),h.arraySet(r.window,t,a-n,i,r.wnext),n-=i,n?(h.arraySet(r.window,t,a-n,n,0),r.wnext=n,r.whave=r.wsize):(r.wnext+=i,r.wnext===r.wsize&&(r.wnext=0),r.whavele;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>8,s.check=_(s.check,o,2,0),se=0,le=0,s.mode=I;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&se)<<8)+(se>>8))%31){t.msg='incorrect header check',s.mode=te;break}if((15&se)!=T){t.msg='unknown compression method',s.mode=te;break}if(se>>>=4,le-=4,ve=(15&se)+8,0===s.wbits)s.wbits=ve;else if(ve>s.wbits){t.msg='invalid window size',s.mode=te;break}s.dmax=1<le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>8),512&s.flags&&(o[0]=255&se,o[1]=255&se>>>8,s.check=_(s.check,o,2,0)),se=0,le=0,s.mode=S;case S:for(;32>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>8,o[2]=255&se>>>16,o[3]=255&se>>>24,s.check=_(s.check,o,4,0)),se=0,le=0,s.mode=R;case R:for(;16>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>8),512&s.flags&&(o[0]=255&se,o[1]=255&se>>>8,s.check=_(s.check,o,2,0)),se=0,le=0,s.mode=B;case B:if(1024&s.flags){for(;16>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>8,s.check=_(s.check,o,2,0)),se=0,le=0}else s.head&&(s.head.extra=null);s.mode=A;case A:if(1024&s.flags&&(he=s.length,he>oe&&(he=oe),he&&(s.head&&(ve=s.head.extra_len-s.length,!s.head.extra&&(s.head.extra=Array(s.head.extra_len)),h.arraySet(s.head.extra,l,re,he,ve)),512&s.flags&&(s.check=_(s.check,l,he,re)),oe-=he,re+=he,s.length-=he),s.length))break inf_leave;s.length=0,s.mode=z;case z:if(2048&s.flags){if(0===oe)break inf_leave;he=0;do ve=l[re+he++],s.head&&ve&&65536>s.length&&(s.head.name+=e(ve));while(ve&&hes.length&&(s.head.comment+=e(ve));while(ve&&hele;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>9,s.head.done=!0),t.adler=s.check=0,s.mode=O;break;case L:for(;32>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=7&le,le-=7&le,s.mode=J;break}for(;3>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=1,le-=1,3&se){case 0:s.mode=M;break;case 1:if(c(s),s.mode=X,a===w){se>>>=2,le-=2;break inf_leave}break;case 2:s.mode=U;break;case 3:t.msg='invalid block type',s.mode=te;}se>>>=2,le-=2;break;case M:for(se>>>=7&le,le-=7≤32>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>16)){t.msg='invalid stored block lengths',s.mode=te;break}if(s.length=65535&se,se=0,le=0,s.mode=W,a===w)break inf_leave;case W:s.mode=j;case j:if(he=s.length,he){if(he>oe&&(he=oe),he>de&&(he=de),0===he)break inf_leave;h.arraySet(ne,l,re,he,ie),oe-=he,re+=he,de-=he,ie+=he,s.length-=he;break}s.mode=O;break;case U:for(;14>le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=5,le-=5,s.ndist=(31&se)+1,se>>>=5,le-=5,s.ncode=(15&se)+4,se>>>=4,le-=4,286le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=3,le-=3}for(;19>s.have;)s.lens[d[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,Ee={bits:s.lenbits},xe=m(0,s.lens,0,19,s.lencode,0,s.work,Ee),s.lenbits=Ee.bits,xe){t.msg='invalid code lengths set',s.mode=te;break}s.have=0,s.mode=G;case G:for(;s.have>>24,me=255&i>>>16,ge=65535&i,pe<=le)break;if(0===oe)break inf_leave;oe--,se+=l[re++]<ge)se>>>=pe,le-=pe,s.lens[s.have++]=ge;else{if(16===ge){for(ke=pe+2;le>>=pe,le-=pe,0===s.have){t.msg='invalid bit length repeat',s.mode=te;break}ve=s.lens[s.have-1],he=3+(3&se),se>>>=2,le-=2}else if(17===ge){for(ke=pe+3;le>>=pe,le-=pe,ve=0,he=3+(7&se),se>>>=3,le-=3}else{for(ke=pe+7;le>>=pe,le-=pe,ve=0,he=11+(127&se),se>>>=7,le-=7}if(s.have+he>s.nlen+s.ndist){t.msg='invalid bit length repeat',s.mode=te;break}for(;he--;)s.lens[s.have++]=ve}}if(s.mode===te)break;if(0===s.lens[256]){t.msg='invalid code -- missing end-of-block',s.mode=te;break}if(s.lenbits=9,Ee={bits:s.lenbits},xe=m(g,s.lens,0,s.nlen,s.lencode,0,s.work,Ee),s.lenbits=Ee.bits,xe){t.msg='invalid literal/lengths set',s.mode=te;break}if(s.distbits=6,s.distcode=s.distdyn,Ee={bits:s.distbits},xe=m(b,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,Ee),s.distbits=Ee.bits,xe){t.msg='invalid distances set',s.mode=te;break}if(s.mode=X,a===w)break inf_leave;case X:s.mode=Y;case Y:if(6<=oe&&258<=de){t.next_out=ie,t.avail_out=de,t.next_in=re,t.avail_in=oe,s.hold=se,s.bits=le,p(t,ue),ie=t.next_out,ne=t.output,de=t.avail_out,re=t.next_in,l=t.input,oe=t.avail_in,se=s.hold,le=s.bits,s.mode===O&&(s.back=-1);break}for(s.back=0;;){if(i=s.lencode[se&(1<>>24,me=255&i>>>16,ge=65535&i,pe<=le)break;if(0===oe)break inf_leave;oe--,se+=l[re++]<>be)],pe=i>>>24,me=255&i>>>16,ge=65535&i,be+pe<=le)break;if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=be,le-=be,s.back+=be}if(se>>>=pe,le-=pe,s.back+=pe,s.length=ge,0===me){s.mode=Q;break}if(32&me){s.back=-1,s.mode=O;break}if(64&me){t.msg='invalid literal/length code',s.mode=te;break}s.extra=15&me,s.mode=V;case V:if(s.extra){for(ke=s.extra;le>>=s.extra,le-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=Z;case Z:for(;;){if(i=s.distcode[se&(1<>>24,me=255&i>>>16,ge=65535&i,pe<=le)break;if(0===oe)break inf_leave;oe--,se+=l[re++]<>be)],pe=i>>>24,me=255&i>>>16,ge=65535&i,be+pe<=le)break;if(0===oe)break inf_leave;oe--,se+=l[re++]<>>=be,le-=be,s.back+=be}if(se>>>=pe,le-=pe,s.back+=pe,64&me){t.msg='invalid distance code',s.mode=te;break}s.offset=ge,s.extra=15&me,s.mode=K;case K:if(s.extra){for(ke=s.extra;le>>=s.extra,le-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){t.msg='invalid distance too far back',s.mode=te;break}s.mode=q;case q:if(0===de)break inf_leave;if(he=ue-de,s.offset>he){if(he=s.offset-he,he>s.whave&&s.sane){t.msg='invalid distance too far back',s.mode=te;break}he>s.wnext?(he-=s.wnext,fe=s.wsize-he):fe=s.wnext-he,he>s.length&&(he=s.length),_e=s.window}else _e=ne,fe=ie-s.offset,he=s.length;he>de&&(he=de),de-=he,s.length-=he;do ne[ie++]=_e[fe++];while(--he);0===s.length&&(s.mode=Y);break;case Q:if(0===de)break inf_leave;ne[ie++]=s.length,de--,s.mode=Y;break;case J:if(s.wrap){for(;32>le;){if(0===oe)break inf_leave;oe--,se|=l[re++]<le;){if(0===oe)break inf_leave;oe--,se+=l[re++]<p&&(_+=C[r++]<>>24,_>>>=v,p-=v,v=255&w>>>16,0===v)I[o++]=65535&w;else if(16&v){x=65535&w,v&=15,v&&(p>>=v,p-=v),15>p&&(_+=C[r++]<>>24,_>>>=v,p-=v,v=255&w>>>16,16&v){if(E=65535&w,v&=15,pl){e.msg='invalid distance too far back',n.mode=t;break top}if(_>>>=v,p-=v,v=o-d,E>v){if(v=E-v,v>u&&n.sane){e.msg='invalid distance too far back',n.mode=t;break top}if(k=0,T=f,0===h){if(k+=c-v,v>3,r-=x,p-=x<<3,_&=(1<E&&(k=E),0==E)return p[m++]=20971520,p[m++]=20971520,b.bits=1,0;for(x=1;xI)return-1;if(0i||e===l&&S>o)return 1;for(;;){U=w-C,g[v]j?(H=N[L+g[v]],G=B[A+g[v]]):(H=96,G=0),P=1<>C)+O]=0|(U<<24|H<<16|G);while(0!==O);for(P=1<>=1;if(0===P?R=0:(R&=P-1,R+=P),v++,0==--z[w]){if(w==E)break;w=t[a+g[v]]}if(w>k&&(R&M)!==F){for(0==C&&(C=k),W+=x,T=w-C,I=1<=I));)T++,I<<=1;if(S+=1<i||e===l&&S>o)return 1;F=R&M,p[F]=0|(k<<24|T<<16|W-m)}}return 0!==R&&(p[W+R]=0|(4194304|w-C<<24)),b.bits=k,0}},function(e){'use strict';e.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}},function(e,t){'use strict';t.a=class{async decode(e){return new Float32Array(e.buffer,e.byteOffset,e.byteLength/4)}}},function(e,t){'use strict';const a=-1;t.a=class{constructor(){this.scheduledCallbackId=a}request(e){this.fn=e,this.scheduledCallbackId==a&&(this.scheduledCallbackId=requestAnimationFrame(()=>this.forceDispatch()))}forceDispatch(){this.scheduledCallbackId==a||(this.cancel(),this.fn())}cancel(){this.scheduledCallbackId==a||(cancelAnimationFrame(this.scheduledCallbackId),this.scheduledCallbackId=a)}}},function(e,t){'use strict';function a(e){let t=[];for(let n=0,r;n'),a.firstChild.href}async setDescriptorAndParameters(e,t){this.descriptor=e,this.placeholderContext=new d.a(this.descriptor.placeholders);let a='object'==typeof WebAssembly?'webassembly':'asmjs';0<=window.navigator.userAgent.indexOf('iPhone OS 11_2')&&(a='asmjs');let n=`${this.directory}/kernels_${a}.js`;n=Object(o.d)(n),this.worker_entry_js_path=n;let r=await fetch(this.worker_entry_js_path),i=await r.text(),s=(e,t)=>{let a=this.absolutePath(`${this.directory}/${e}`),n=Object(o.d)(a);i=i.replace(t,n)};'webassembly'==a?s('kernels_webassembly.wasm','WEBDNN_URL_KERNELS_WASM'):s('kernels_asmjs.js.mem','WEBDNN_URL_KERNELS_ASMJS_MEM'),await this.compile(i),await this.loadWeights(new Uint8Array(t)),(await this.getInputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=new Float32Array(e.length).buffer}),(await this.getOutputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=new Float32Array(e.length).buffer})}async fetchDescriptor(e){this.directory=e;let t=await Object(o.a)(`${e}/graph_${this.backendName}.json`);return t.json()}async fetchParameters(e,t){let a=`${e}/weight_${this.backendName}.bin`,n=await Object(o.a)(a);return Object(o.b)(n,t)}async restoreCachedDescriptor(e){return this.directory=e,n.getItem(`${e}_${this.backendName}_descriptor`).catch(()=>null)}async restoreCachedParameters(e,t){let a=await n.getItem(`${e}_${this.backendName}_parameters`).catch(()=>null);return a&&t&&t(a.byteLength,a.byteLength),a}async saveCache(e,t,a){await Promise.all([n.setItem(`${e}_${this.backendName}_descriptor`,t),n.setItem(`${e}_${this.backendName}_parameters`,a)])}async setPlaceholderValue(e){if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized.');let t=this.placeholderContext;if(t.update(e),!t.isResolved)return;if(!this.descriptor)throw new Error('Descriptor is not loaded');let a=this.descriptor,n=a.unresolved_value_lists,r=[];for(let a=0,i;a{let n=t.resolve(e.placeholder);r.push(a,e.offset,n)});(await this.getInputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=new Float32Array(e.length).buffer}),(await this.getOutputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=new Float32Array(e.length).buffer});let i=this.placeholderContext.resolve(this.descriptor.memory_layout.dynamic.size);await this.setPlaceholderValueWorker(i,new Int32Array(r))}setPlaceholderValueWorker(e,t){if(!this.worker)throw Error('Worker is not initialized');let a=this.worker;return new Promise((n,r)=>{a.onmessage=(e)=>{0===e.data?n():(console.log(e.data),a.terminate(),r(new Error(e.data)))},a.postMessage({type:'set_dynamic_buffer',size:e,data:t})})}compile(e){let t=new Blob([e],{type:'text/javascript'}),a=URL.createObjectURL(t),n=new Worker(a);n.onerror=(e)=>{console.error(e),this.worker_promise_reject_func?this.worker_promise_reject_func(e):this.worker_initial_error=e};let r=new Promise((e,t)=>this.worker_initial_error?t(this.worker_initial_error):void(this.worker_promise_reject_func=t,n.onmessage=(a)=>{0===a.data?e():(console.error(a.data),n.terminate(),t(new Error(a.data)))}));return this.worker=n,r}async loadWeights(e){if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.worker)throw new Error('Worker is not initialized');let t=Object(i.a)(this.descriptor.weight_encoding),a=await t.decode(e),n=this.worker,r=new Promise((e,t)=>{this.worker_promise_reject_func=t,n.onmessage=(a)=>{0===a.data?e():(console.log(a.data),n.terminate(),t(new Error(a.data)))},n.postMessage({type:'weight',data:a},[a.buffer])});return r}getInputViews(){if(this.inputs)return this.inputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.inputs=e.inputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new s.a(null,0,n.size,t);return r}),this.inputs}getOutputViews(){if(this.outputs)return this.outputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.outputs=e.outputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new s.a(null,0,n.size,t);return r}),this.outputs}async run(){if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.worker)throw new Error('Worker is not initialized');if(!this.placeholderContext.isResolved)throw new Error('Not all placeholder is resolved');let e=this.placeholderContext,t=this.descriptor,a=this.worker,n=new Promise((n,r)=>{this.worker_promise_reject_func=r,a.onmessage=(e)=>{if(Array.isArray(e.data)){for(let t=0;tn;n++)if(r=o[n][t.inputs[a]],r){let t=this.inputs[a];d.push({space:n,offset:e.resolve(r.offset),size:t.length,data:t.toActual()});break}let s=[];for(let a=0;an;n++)if(r=o[n][t.outputs[a]],r){let t=this.outputs[a];s.push({space:n,offset:e.resolve(r.offset),size:t.length});break}a.postMessage({type:'run',inputs:d,outputs:s})});return n}}t.a=c},function(e,t,a){'use strict';var n=a(3),r=a.n(n),i=a(38),o=a(4),d=a(1),s=a(5),l=a(6),c=a(2),u=a(14),h=a(7);const f=new Float32Array([-1,1,-1,-1,1,1,1,-1]);class _ extends h.a{constructor(){super(...arguments),this.backendName='webgl'}static checkAvailability(){return u.a.checkAvailability()}async init(){if(!_.checkAvailability())throw Error('WebGL backend is not supported in this browser.');this.handler=u.a.getInstance();let e=this.handler.createArrayBuffer(f);this.handler.bindArrayBuffer(e),this.buffers=new Map}async fetchDescriptor(e){let t=await Object(d.a)(`${e}/graph_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}.json`);return t.json()}async fetchParameters(e,t){let a=await Object(d.a)(`${e}/weight_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}.bin`);return Object(d.b)(a,t)}async restoreCachedDescriptor(e){return n.getItem(`${e}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_descriptor`).catch(()=>null)}async restoreCachedParameters(e,t){let a=await n.getItem(`${e}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_parameters`).catch(()=>null);return a&&t&&t(a.byteLength,a.byteLength),a}async saveCache(e,t,a){await Promise.all([n.setItem(`${e}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_descriptor`,t),n.setItem(`${e}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_parameters`,a)])}async setDescriptorAndParameters(e,t){await this.setDescriptor(e),await this.compile(),await this.initializeStaticBuffer(t),this.placeholderContext&&this.placeholderContext.isResolved&&(await this.initializeDynamicBuffer())}async initializeStaticBuffer(e){if(!this.descriptor)throw new Error('Descriptor is not loaded');let t=this.descriptor,a=Object(o.a)(this.descriptor.weight_encoding),n=await a.decode(new Uint8Array(e)),r=this.buffers,d=t.memory_layout.mapping;Object.entries(t.memory_layout.static.allocations).forEach(([e,{width:t,height:a,size:n,channel_mode:o}])=>{r.set(e,new i.a(n*Float32Array.BYTES_PER_ELEMENT,t,a,e,null,o))}),Object.entries(t.constants_map).forEach(([e,{size:t,byte_offset:a}])=>{r.get(e).array.set(new Float32Array(n.buffer,a,t))}),(await this.getInputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=r.get(d[e.name]).getWriteView(0,e.length,Float32Array).buffer}),(await this.getOutputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=r.get(d[e.name]).getReadView(0,e.length,Float32Array).buffer})}async initializeDynamicBuffer(){if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');if(!this.placeholderContext)throw Error('PlaceholderContext is not initialized.');let e=this.descriptor,t=this.placeholderContext,a=this.buffers,n=e.memory_layout.mapping;Object.entries(e.memory_layout.dynamic.allocations).forEach(([e,{width:n,height:r,size:o,channel_mode:d}])=>{a.set(e,new i.a(t.resolve(o)*Float32Array.BYTES_PER_ELEMENT,t.resolve(n),t.resolve(r),e,null,d))}),(await this.getInputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=a.get(n[e.name]).getWriteView(0,t.resolve(e.length),Float32Array).buffer}),(await this.getOutputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=a.get(n[e.name]).getReadView(0,t.resolve(e.length),Float32Array).buffer}),this.buildPipeline()}async setDescriptor(e){this.descriptor=e,this.placeholderContext=new s.a(e.placeholders)}async compile(){if(!this.descriptor)throw new Error('Descriptor is not loaded');let e=this.descriptor;this.programs=new Map,this.vertexShader=this.handler.createVertexShader(` precision highp float; attribute vec2 _xy; void main() { @@ -20,5 +20,5 @@ using namespace metal; if (global_index == 0) { A[0] = thread_execution_width; } - }`,'basic');let e=this.webgpuHandler.createBuffer(new Uint32Array(1));await this.webgpuHandler.executeSinglePipelineState('basic.check_compatibility',{width:1,height:1,depth:1},{width:1,height:1,depth:1},[e],!0);let t=new Uint32Array(e.contents)[0];if(32!=t)throw new Error(`Sorry, this GPU does not compatible with WebGPU (thread_execution_width == ${t}. See checkIncompatibleGPU method of https://github.com/mil-tokyo/webdnn/blob/master/src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.ts`)}async fetchDescriptor(e){let t=await Object(d.a)(`${e}/graph_${this.backendName}.json`);return t.json()}async fetchParameters(e,t){let a=await Object(d.a)(`${e}/weight_${this.backendName}.bin`);return Object(d.b)(a,t)}async restoreCachedDescriptor(e){return n.getItem(`${e}_${this.backendName}_descriptor`).catch(()=>null)}async restoreCachedParameters(e,t){let a=await n.getItem(`${e}_${this.backendName}_parameters`).catch(()=>null);return a&&t&&t(a.byteLength,a.byteLength),a}async saveCache(e,t,a){await Promise.all([n.setItem(`${e}_${this.backendName}_descriptor`,t),n.setItem(`${e}_${this.backendName}_parameters`,a)])}async setDescriptorAndParameters(e,t){this.descriptor=e,this.staticBuffer=null,this.dynamicBuffer=null,this.metaBuffers=null,this.placeholderContext=new s.a(e.placeholders),this.executionInfos=e.exec_infos,this.webgpuHandler.loadKernel(this.descriptor.kernel_source,'descriptor'),await this.initializeStaticBuffer(t),await this.initializeMetaBuffers(),await this.setPlaceholderValue({__MAX_THREADS_PER_THREADGROUP__:f?512:1024}),this.placeholderContext&&this.placeholderContext.isResolved&&(await this.initializeDynamicBuffer())}async initializeStaticBuffer(e){if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');let t=this.descriptor,a=new i.a(t.memory_layout.static.size*Float32Array.BYTES_PER_ELEMENT);this.staticBuffer=a;let n=Object(o.a)(t.weight_encoding);await a.write((await n.decode(new Uint8Array(e)))),(await this.getInputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=a.bufferView.buffer}),(await this.getOutputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=a.bufferView.buffer})}async initializeMetaBuffers(){if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');this.metaBuffers=await Promise.all(this.descriptor.exec_infos.map(async(e)=>{let t=new i.a(e.meta_buffer.length*Int32Array.BYTES_PER_ELEMENT);return await t.write(new Uint8Array(e.meta_buffer)),t}))}async initializeDynamicBuffer(){if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');if(!this.placeholderContext)throw Error('PlaceholderContext is not initialized.');let e=this.descriptor,t=this.placeholderContext,a=t.resolve(e.memory_layout.dynamic.size),n=new i.a(a*Float32Array.BYTES_PER_ELEMENT);this.dynamicBuffer=n,(await this.getInputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=n.bufferView.buffer}),(await this.getOutputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=n.bufferView.buffer})}async setPlaceholderValue(e){if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized.');let t=this.placeholderContext;if(t.update(e),!t.isResolved)return;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.metaBuffers)throw new Error('MetaBuffers are not initialized');let a=this.descriptor,n=this.metaBuffers;await this.initializeDynamicBuffer(),this.executionInfos=await Promise.all(a.exec_infos.map(async(e,a)=>{let r=new Int32Array(n[a].bufferView.buffer);for(let n of e.unresolved_value_list)r[n.offset]=t.resolve(n.placeholder);return t.resolve(e)}))}getInputViews(){if(this.inputs)return this.inputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.inputs=e.inputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new l.a(null,n.offset*l.a.BYTES_PER_ELEMENT,n.size,t);return r}),this.inputs}getOutputViews(){if(this.outputs)return this.outputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.outputs=e.outputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new l.a(null,n.offset*l.a.BYTES_PER_ELEMENT,n.size,t);return r}),this.outputs}async run(){if(!this.executionInfos)throw new Error('ExecutionInfos is not loaded');if(!this.staticBuffer)throw new Error('StaticBuffer is not initialized');if(!this.dynamicBuffer)throw new Error('DynamicBuffer is not initialized');if(!this.metaBuffers)throw new Error('MetaBuffer is not initialized');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');if(!this.placeholderContext.isResolved)throw new Error(`Not all placeholders are resolved: ${this.placeholderContext}`);let e=this.staticBuffer,t=this.dynamicBuffer,a=this.metaBuffers;if(Object(c.getConfiguration)('DEBUG',!1)){let n=[],r=0;for(let o=0;o(t.Kernel in e||(e[t.Kernel]={Kernel:t.Kernel,Count:0,"Elapsed time [ms]":0}),e[t.Kernel].Count++,e[t.Kernel]['Elapsed time [ms]']+=t['Elapsed time [ms]'],e),{})));i.forEach((e)=>e['Ratio [%]']=(e['Elapsed time [ms]']/r).toFixed(2)),console.table(n),console.table(i)}else{let n=null;for(let r=0;rn(e))):e}function r(e){if('number'==typeof e)return[e,e,e,e];if(4==e.length)return[e[0],e[1],e[2],e[3]];if(3==e.length)return[e[0],e[1],e[2],e[0]];if(1==e.length)return[e[0],e[0],e[0],e[0]];throw new Error('bias and scale must be scalar number or array of length 1 or 3 or 4.')}function i(e,t={}){let{type:a=Float32Array,color:n=l.a.RGB,order:i=l.b.HWC,bias:o=[0,0,0],scale:d=[1,1,1]}=t;const s=r(o),c=r(d),u=e.width,f=e.height;let _=e.data,p,m,y,v,g,x,E,k,b;switch(n){case l.a.RGB:switch(p=new a(3*(u*f)),[x,E,k]=c,[m,y,v]=s,i){case l.b.HWC:for(let e=0;e=i-1)){for(;;){for(;e[d]>o&&d<=s;)d++;for(;e[s]<=o&&d<=s;)s--;if(d>=s)break;l=e[d],e[d]=e[s],e[s]=l,l=n[d],n[d]=n[s],n[s]=l}e[i-1]=e[d],e[d]=o,l=n[i-1],n[i-1]=n[d],n[d]=l,a.push([r,d]),d+1=i-1)){for(;;){for(;e[d]=o&&d<=s;)s--;if(d>=s)break;l=e[d],e[d]=e[s],e[s]=l,l=n[d],n[d]=n[s],n[s]=l}e[i-1]=e[d],e[d]=o,l=n[i-1],n[i-1]=n[d],n[d]=l,a.push([r,d]),d+1null)}async restoreCachedParameters(e,t){let a=await n.getItem(`${e}_${this.backendName}_parameters`).catch(()=>null);return a&&t&&t(a.byteLength,a.byteLength),a}async saveCache(e,t,a){await Promise.all([n.setItem(`${e}_${this.backendName}_descriptor`,t),n.setItem(`${e}_${this.backendName}_parameters`,a)])}async setDescriptorAndParameters(e,t){this.descriptor=e,this.staticBuffer=null,this.dynamicBuffer=null,this.metaBuffers=null,this.placeholderContext=new s.a(e.placeholders),this.executionInfos=e.exec_infos,this.webgpuHandler.loadKernel(this.descriptor.kernel_source,'descriptor'),await this.initializeStaticBuffer(t),await this.initializeMetaBuffers(),await this.setPlaceholderValue({__MAX_THREADS_PER_THREADGROUP__:f?512:1024}),this.placeholderContext&&this.placeholderContext.isResolved&&(await this.initializeDynamicBuffer())}async initializeStaticBuffer(e){if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');let t=this.descriptor,a=new i.a(t.memory_layout.static.size*Float32Array.BYTES_PER_ELEMENT);this.staticBuffer=a;let n=Object(o.a)(t.weight_encoding);await a.write((await n.decode(new Uint8Array(e)))),(await this.getInputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=a.bufferView.buffer}),(await this.getOutputViews()).filter((e)=>!e.isDynamic).forEach((e)=>{e.buffer=a.bufferView.buffer})}async initializeMetaBuffers(){if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');this.metaBuffers=await Promise.all(this.descriptor.exec_infos.map(async(e)=>{let t=new i.a(e.meta_buffer.length*Int32Array.BYTES_PER_ELEMENT);return await t.write(new Uint8Array(e.meta_buffer)),t}))}async initializeDynamicBuffer(){if(!this.descriptor)throw Error('GraphDescriptor is not loaded.');if(!this.placeholderContext)throw Error('PlaceholderContext is not initialized.');let e=this.descriptor,t=this.placeholderContext,a=t.resolve(e.memory_layout.dynamic.size),n=new i.a(a*Float32Array.BYTES_PER_ELEMENT);this.dynamicBuffer=n,(await this.getInputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=n.bufferView.buffer}),(await this.getOutputViews()).filter((e)=>e.isDynamic).forEach((e)=>{e.buffer=n.bufferView.buffer})}async setPlaceholderValue(e){if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized.');let t=this.placeholderContext;if(t.update(e),!t.isResolved)return;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.metaBuffers)throw new Error('MetaBuffers are not initialized');let a=this.descriptor,n=this.metaBuffers;await this.initializeDynamicBuffer(),this.executionInfos=await Promise.all(a.exec_infos.map(async(e,a)=>{let r=new Int32Array(n[a].bufferView.buffer);for(let n of e.unresolved_value_list)r[n.offset]=t.resolve(n.placeholder);return t.resolve(e)}))}getInputViews(){if(this.inputs)return this.inputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.inputs=e.inputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new l.a(null,n.offset*l.a.BYTES_PER_ELEMENT,n.size,t);return r}),this.inputs}getOutputViews(){if(this.outputs)return this.outputs;if(!this.descriptor)throw new Error('Descriptor is not loaded');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');let e=this.descriptor,t=this.placeholderContext;return this.outputs=e.outputs.map((a)=>{let n=e.memory_layout.static.allocations[a]||e.memory_layout.dynamic.allocations[a],r=new l.a(null,n.offset*l.a.BYTES_PER_ELEMENT,n.size,t);return r}),this.outputs}async run(){if(!this.executionInfos)throw new Error('ExecutionInfos is not loaded');if(!this.staticBuffer)throw new Error('StaticBuffer is not initialized');if(!this.dynamicBuffer)throw new Error('DynamicBuffer is not initialized');if(!this.metaBuffers)throw new Error('MetaBuffer is not initialized');if(!this.placeholderContext)throw new Error('PlaceholderContext is not initialized');if(!this.placeholderContext.isResolved)throw new Error(`Not all placeholders are resolved: ${this.placeholderContext}`);let e=this.staticBuffer,t=this.dynamicBuffer,a=this.metaBuffers;if(Object(c.getConfiguration)('DEBUG',!1)){let n=[],r=0;for(let o=0;o(t.Kernel in e||(e[t.Kernel]={Kernel:t.Kernel,Count:0,"Elapsed time [ms]":0}),e[t.Kernel].Count++,e[t.Kernel]['Elapsed time [ms]']+=t['Elapsed time [ms]'],e),{})));i.forEach((e)=>e['Ratio [%]']=(e['Elapsed time [ms]']/r).toFixed(2)),console.table(n),console.table(i)}else{let n=null;for(let r=0;rn(e))):e}function r(e){if('number'==typeof e)return[e,e,e,e];if(4==e.length)return[e[0],e[1],e[2],e[3]];if(3==e.length)return[e[0],e[1],e[2],e[0]];if(1==e.length)return[e[0],e[0],e[0],e[0]];throw new Error('bias and scale must be scalar number or array of length 1 or 3 or 4.')}function i(e,t={}){let{type:a=Float32Array,color:n=l.a.RGB,order:i=l.b.HWC,bias:o=[0,0,0],scale:d=[1,1,1]}=t;const s=r(o),c=r(d),u=e.width,f=e.height;let _=e.data,p,m,y,v,g,x,E,k,b;switch(n){case l.a.RGB:switch(p=new a(3*(u*f)),[x,E,k]=c,[m,y,v]=s,i){case l.b.HWC:for(let e=0;e=i-1)){for(;;){for(;e[d]>o&&d<=s;)d++;for(;e[s]<=o&&d<=s;)s--;if(d>=s)break;l=e[d],e[d]=e[s],e[s]=l,l=n[d],n[d]=n[s],n[s]=l}e[i-1]=e[d],e[d]=o,l=n[i-1],n[i-1]=n[d],n[d]=l,a.push([r,d]),d+1=i-1)){for(;;){for(;e[d]=o&&d<=s;)s--;if(d>=s)break;l=e[d],e[d]=e[s],e[s]=l,l=n[d],n[d]=n[s],n[s]=l}e[i-1]=e[d],e[d]=o,l=n[i-1],n[i-1]=n[d],n[d]=l,a.push([r,d]),d+1 url;\n/**\n * Transform url generated based on current active backend\n * @param url transformed url\n * @protected\n */\nexport function transformUrl(url) {\n return transformDelegate(url);\n}\n/**\n * Register delegate function for transform url.\n * @param delegate Delegate function which will be called with original url, and must return converted url strings.\n * @protected\n */\nexport function registerTransformUrlDelegate(delegate) {\n transformDelegate = delegate;\n}\n/**\n * Fetch function. WebDNN API use this function instead of original `fetch` function.\n * FIXME\n * @param input Requested url\n * @param init Additional information about webdnnFetch\n * @param init.ignoreCache If true, cache is ignored by appending '?t=(timestamp)' to the end of request url.\n * @returns Response\n * @protected\n */\nexport default async function webdnnFetch(input, init) {\n if (typeof input == 'string') {\n input = transformUrl(input) + ((init && init.ignoreCache) ? '?t=' + Date.now() : '');\n }\n else {\n input = Object.assign({}, input, {\n url: transformUrl(input.url) + ((init && init.ignoreCache) ? '?t=' + Date.now() : '')\n });\n }\n let res;\n if (typeof input == 'string' && isXHR2WithBlobSupported()) {\n res = await fetchUsingXHR(input, init && init.progressCallback);\n }\n else {\n res = await fetch(input, init);\n }\n if (!res.ok)\n throw new Error(`Fetch returns status code ${res.status}: ${res.statusText}`);\n return res;\n}\n/**\n * Read `Response.body` stream as ArrayBuffer. This function provide progress information by callback.\n * @param res Response object\n * @param callback Callback function.\n * @returns ArrayBuffer\n * @protected\n */\nexport function readArrayBufferProgressively(res, callback) {\n if (!callback || !res.body)\n return res.arrayBuffer();\n let contentLength = res.headers.get('Content-Length');\n if (!contentLength)\n return res.arrayBuffer();\n const total = parseInt(contentLength);\n let buffer = new Uint8Array(total);\n let loaded = 0;\n let reader = res.body.getReader();\n let callbackScheduler = new DispatchScheduler();\n function accumulateLoadedSize(chunk) {\n buffer.set(chunk.value, loaded);\n loaded += chunk.value.length;\n if (callback) {\n callbackScheduler.request(() => callback(loaded, total));\n }\n if (loaded == total) {\n callbackScheduler.forceDispatch();\n return buffer.buffer;\n }\n else {\n return reader.read().then(accumulateLoadedSize);\n }\n }\n return reader.read().then(accumulateLoadedSize);\n}\n/**\n * check whether XMLHttpRequest with Blob type is supported or not\n * @protected\n */\nfunction isXHR2WithBlobSupported() {\n if (!window.hasOwnProperty('ProgressEvent') || !window.hasOwnProperty('FormData')) {\n return false;\n }\n let xhr = new XMLHttpRequest();\n if (typeof xhr.responseType === 'string') {\n try {\n xhr.responseType = 'blob';\n return xhr.responseType === 'blob';\n }\n catch (e) {\n return false;\n }\n }\n else {\n return false;\n }\n}\n/**\n * fetch with XMLHttpRequest\n * @protected\n */\nfunction fetchUsingXHR(url, callback) {\n return new Promise(function (resolve, reject) {\n let req = new XMLHttpRequest();\n req.open(\"GET\", url, true);\n req.responseType = \"blob\";\n let callbackScheduler = new DispatchScheduler();\n req.onload = function (event) {\n callbackScheduler.forceDispatch();\n let res = new Response(req.response);\n resolve(res);\n };\n req.onprogress = function (event) {\n if (callback) {\n callbackScheduler.request(function () { return callback(event.loaded, event.total); });\n }\n };\n req.onerror = function (event) {\n reject(event);\n };\n req.send(null);\n });\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/fetch.js\n// module id = 1\n// module chunks = 0","import DescriptorRunnerFallback from \"./descriptor_runner/descriptor_runner_fallback\";\nimport DescriptorRunnerWebassembly from \"./descriptor_runner/descriptor_runner_webassembly\";\nimport DescriptorRunnerWebGL from \"./descriptor_runner/descriptor_runner_webgl\";\nimport DescriptorRunnerWebGPU from \"./descriptor_runner/descriptor_runner_webgpu\";\nimport { registerTransformUrlDelegate } from \"./fetch\";\nimport * as Image from \"./image\";\nimport * as Math from \"./math\";\n/**\n * DEBUG flag for developing WebDNN\n * @private\n */\nlet configurations = {};\n/**\n * get configuration\n * @private\n */\nexport function getConfiguration(key, defaultValue) {\n return key in configurations ? configurations[key] : defaultValue;\n}\n/**\n * set configuration\n * @private\n */\nexport function setConfiguration(key, value) {\n configurations[key] = value;\n}\n/**\n * Backend constructor map\n * @private\n */\nconst descriptorRunners = {\n webgpu: DescriptorRunnerWebGPU,\n webgl: DescriptorRunnerWebGL,\n webassembly: DescriptorRunnerWebassembly,\n fallback: DescriptorRunnerFallback\n};\n/**\n * Check each computing backend is available or not in this browser.\n * The result will be returned as [[BackendAvailability|`BackendAvailability`]] structure.\n *\n * @returns backend availability\n */\nexport function getBackendAvailability() {\n let status = {\n 'webgpu': descriptorRunners['webgpu'].checkAvailability(),\n 'webgl': descriptorRunners['webgl'].checkAvailability(),\n 'webassembly': descriptorRunners['webassembly'].checkAvailability(),\n 'fallback': descriptorRunners['fallback'].checkAvailability(),\n };\n let order = ['webgpu', 'webgl', 'webassembly', 'fallback'].filter(backend => status[backend]);\n return {\n status: status,\n defaultOrder: order\n };\n}\n/**\n * Initialize specified backend\n * @private\n */\nasync function initBackend(backendName, option) {\n if (!(backendName in descriptorRunners))\n throw new Error(`Unknown backend: \"${backendName}\"`);\n let runner;\n try {\n runner = new descriptorRunners[backendName](option);\n await runner.init();\n }\n catch (ex) {\n console.warn(`Failed to initialize ${backendName} backend: ${ex}`);\n return null;\n }\n return runner;\n}\n/**\n * Initialize descriptor runner. This function performs follow things.\n *\n * 1. Try to initialize computing backend. WebDNN will try to initialize each backend in order of\n * the result of [[getBackendAvailability|`getBackendAvailability`]].\n * If you want to modify this order, specify [[InitOption.backendOrder|`initOption.backendOrder`]] option.\n *\n * 2. Load model data based on initialized backend. Generally, DNN binary data is very large and it takes long time to load.\n * [[InitOption.progressCallback|`initOption.progressCallback`]] option provides the progress status of loading.\n *\n * ### Examples\n *\n * - Basic usage\n *\n * ```js\n * let runner = await WebDNN.load('./model');\n * ```\n *\n * - With `initOption.progressCallback` option\n *\n * ```js\n * let runner = await WebDNN.load('./model', {\n * progressCallback: (loaded, total) => console.log(`${ (loaded/total*100).toFixed(1) }% Loaded`);\n * });\n * ```\n *\n * @param directory URL of directory that contains graph descriptor files (e.g. graph_webgpu.json)\n * @param initOption Initialize option\n * @return DescriptorRunner instance, which is the interface to input/output data and run the model.\n */\nexport async function load(directory, initOption = {}) {\n let { backendOrder = null, backendOptions = {}, cacheStrategy = 'latest', saveCache = true, progressCallback, weightDirectory, transformUrlDelegate } = initOption;\n if (!backendOrder)\n backendOrder = getBackendAvailability().defaultOrder;\n if (typeof backendOrder === 'string')\n backendOrder = [backendOrder];\n backendOrder = backendOrder.slice();\n if (backendOrder.indexOf('fallback') === -1)\n backendOrder.concat(['fallback']);\n registerTransformUrlDelegate((url) => {\n if (weightDirectory) {\n if ((/\\.bin/).test(url)) {\n url = url.replace(directory, weightDirectory);\n }\n }\n if (transformUrlDelegate)\n url = transformUrlDelegate(url);\n return url;\n });\n while (backendOrder.length > 0) {\n let backendName = backendOrder.shift();\n let runner = await initBackend(backendName, backendOptions[backendName]);\n if (!runner)\n continue;\n try {\n let descriptor;\n let parameters;\n let fetchedDescriptor;\n let cachedDescriptor;\n switch (cacheStrategy) {\n case 'latest':\n fetchedDescriptor = await runner.fetchDescriptor(directory).catch(() => null);\n cachedDescriptor = await runner.restoreCachedDescriptor(directory);\n if (cachedDescriptor && fetchedDescriptor && cachedDescriptor.converted_at === fetchedDescriptor.converted_at) {\n descriptor = cachedDescriptor;\n parameters = await runner.restoreCachedParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n if (fetchedDescriptor) {\n descriptor = fetchedDescriptor;\n parameters = await runner.fetchParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n if (cachedDescriptor) {\n descriptor = cachedDescriptor;\n parameters = await runner.restoreCachedParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n throw Error('Network error is occurred and no cache is exist.');\n case 'networkOnly':\n case 'networkFirst':\n fetchedDescriptor = await runner.fetchDescriptor(directory).catch(() => null);\n if (fetchedDescriptor) {\n descriptor = fetchedDescriptor;\n parameters = await runner.fetchParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n if (cacheStrategy === 'networkOnly')\n throw Error('Network error is occurred in \"networkOnly\" cache strategy');\n cachedDescriptor = await runner.restoreCachedDescriptor(directory);\n if (cachedDescriptor) {\n descriptor = cachedDescriptor;\n parameters = await runner.restoreCachedParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n throw Error('Network error is occurred and no cache is exist.');\n case 'cacheOnly':\n case 'cacheFirst':\n cachedDescriptor = await runner.restoreCachedDescriptor(directory);\n if (cachedDescriptor) {\n descriptor = cachedDescriptor;\n parameters = await runner.restoreCachedParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n if (cacheStrategy === 'cacheOnly')\n throw Error('No cache is exist in \"cacheOnly\" cache strategy');\n fetchedDescriptor = await runner.fetchDescriptor(directory).catch(() => null);\n if (fetchedDescriptor) {\n descriptor = fetchedDescriptor;\n parameters = await runner.fetchParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n throw Error('Network error is occurred and no cache is exist.');\n default:\n throw Error(`\"${cacheStrategy}\" is not valid cache strategy name: \"latest\", \"networkFirst\", \"networkOnly\", \"cacheFirst\", \"cacheOnly\" is available.`);\n }\n if (saveCache) {\n try {\n await runner.saveCache(directory, descriptor, parameters);\n }\n catch (e) {\n /* do nothing */\n }\n }\n await runner.setDescriptorAndParameters(descriptor, parameters);\n }\n catch (ex) {\n console.warn(`Model loading failed for ${backendName} backend. Trying next backend: ${ex.message}`);\n continue;\n }\n return runner;\n }\n throw new Error('No backend is available');\n}\n// Export support (not-dependent) functions\nexport { Math, Image };\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webdnn.js\n// module id = 2\n// module chunks = 0","/*!\n localForage -- Offline Storage, Improved\n Version 1.5.6\n https://localforage.github.io/localForage\n (c) 2013-2017 Mozilla, Apache License 2.0\n*/\n(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.localforage = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw (f.code=\"MODULE_NOT_FOUND\", f)}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o element; its readystatechange event will be fired asynchronously once it is inserted\n // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.\n var scriptEl = global.document.createElement('script');\n scriptEl.onreadystatechange = function () {\n nextTick();\n\n scriptEl.onreadystatechange = null;\n scriptEl.parentNode.removeChild(scriptEl);\n scriptEl = null;\n };\n global.document.documentElement.appendChild(scriptEl);\n };\n } else {\n scheduleDrain = function () {\n setTimeout(nextTick, 0);\n };\n }\n}\n\nvar draining;\nvar queue = [];\n//named nextTick for less confusing stack traces\nfunction nextTick() {\n draining = true;\n var i, oldQueue;\n var len = queue.length;\n while (len) {\n oldQueue = queue;\n queue = [];\n i = -1;\n while (++i < len) {\n oldQueue[i]();\n }\n len = queue.length;\n }\n draining = false;\n}\n\nmodule.exports = immediate;\nfunction immediate(task) {\n if (queue.push(task) === 1 && !draining) {\n scheduleDrain();\n }\n}\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{}],2:[function(_dereq_,module,exports){\n'use strict';\nvar immediate = _dereq_(1);\n\n/* istanbul ignore next */\nfunction INTERNAL() {}\n\nvar handlers = {};\n\nvar REJECTED = ['REJECTED'];\nvar FULFILLED = ['FULFILLED'];\nvar PENDING = ['PENDING'];\n\nmodule.exports = Promise;\n\nfunction Promise(resolver) {\n if (typeof resolver !== 'function') {\n throw new TypeError('resolver must be a function');\n }\n this.state = PENDING;\n this.queue = [];\n this.outcome = void 0;\n if (resolver !== INTERNAL) {\n safelyResolveThenable(this, resolver);\n }\n}\n\nPromise.prototype[\"catch\"] = function (onRejected) {\n return this.then(null, onRejected);\n};\nPromise.prototype.then = function (onFulfilled, onRejected) {\n if (typeof onFulfilled !== 'function' && this.state === FULFILLED ||\n typeof onRejected !== 'function' && this.state === REJECTED) {\n return this;\n }\n var promise = new this.constructor(INTERNAL);\n if (this.state !== PENDING) {\n var resolver = this.state === FULFILLED ? onFulfilled : onRejected;\n unwrap(promise, resolver, this.outcome);\n } else {\n this.queue.push(new QueueItem(promise, onFulfilled, onRejected));\n }\n\n return promise;\n};\nfunction QueueItem(promise, onFulfilled, onRejected) {\n this.promise = promise;\n if (typeof onFulfilled === 'function') {\n this.onFulfilled = onFulfilled;\n this.callFulfilled = this.otherCallFulfilled;\n }\n if (typeof onRejected === 'function') {\n this.onRejected = onRejected;\n this.callRejected = this.otherCallRejected;\n }\n}\nQueueItem.prototype.callFulfilled = function (value) {\n handlers.resolve(this.promise, value);\n};\nQueueItem.prototype.otherCallFulfilled = function (value) {\n unwrap(this.promise, this.onFulfilled, value);\n};\nQueueItem.prototype.callRejected = function (value) {\n handlers.reject(this.promise, value);\n};\nQueueItem.prototype.otherCallRejected = function (value) {\n unwrap(this.promise, this.onRejected, value);\n};\n\nfunction unwrap(promise, func, value) {\n immediate(function () {\n var returnValue;\n try {\n returnValue = func(value);\n } catch (e) {\n return handlers.reject(promise, e);\n }\n if (returnValue === promise) {\n handlers.reject(promise, new TypeError('Cannot resolve promise with itself'));\n } else {\n handlers.resolve(promise, returnValue);\n }\n });\n}\n\nhandlers.resolve = function (self, value) {\n var result = tryCatch(getThen, value);\n if (result.status === 'error') {\n return handlers.reject(self, result.value);\n }\n var thenable = result.value;\n\n if (thenable) {\n safelyResolveThenable(self, thenable);\n } else {\n self.state = FULFILLED;\n self.outcome = value;\n var i = -1;\n var len = self.queue.length;\n while (++i < len) {\n self.queue[i].callFulfilled(value);\n }\n }\n return self;\n};\nhandlers.reject = function (self, error) {\n self.state = REJECTED;\n self.outcome = error;\n var i = -1;\n var len = self.queue.length;\n while (++i < len) {\n self.queue[i].callRejected(error);\n }\n return self;\n};\n\nfunction getThen(obj) {\n // Make sure we only access the accessor once as required by the spec\n var then = obj && obj.then;\n if (obj && (typeof obj === 'object' || typeof obj === 'function') && typeof then === 'function') {\n return function appyThen() {\n then.apply(obj, arguments);\n };\n }\n}\n\nfunction safelyResolveThenable(self, thenable) {\n // Either fulfill, reject or reject with error\n var called = false;\n function onError(value) {\n if (called) {\n return;\n }\n called = true;\n handlers.reject(self, value);\n }\n\n function onSuccess(value) {\n if (called) {\n return;\n }\n called = true;\n handlers.resolve(self, value);\n }\n\n function tryToUnwrap() {\n thenable(onSuccess, onError);\n }\n\n var result = tryCatch(tryToUnwrap);\n if (result.status === 'error') {\n onError(result.value);\n }\n}\n\nfunction tryCatch(func, value) {\n var out = {};\n try {\n out.value = func(value);\n out.status = 'success';\n } catch (e) {\n out.status = 'error';\n out.value = e;\n }\n return out;\n}\n\nPromise.resolve = resolve;\nfunction resolve(value) {\n if (value instanceof this) {\n return value;\n }\n return handlers.resolve(new this(INTERNAL), value);\n}\n\nPromise.reject = reject;\nfunction reject(reason) {\n var promise = new this(INTERNAL);\n return handlers.reject(promise, reason);\n}\n\nPromise.all = all;\nfunction all(iterable) {\n var self = this;\n if (Object.prototype.toString.call(iterable) !== '[object Array]') {\n return this.reject(new TypeError('must be an array'));\n }\n\n var len = iterable.length;\n var called = false;\n if (!len) {\n return this.resolve([]);\n }\n\n var values = new Array(len);\n var resolved = 0;\n var i = -1;\n var promise = new this(INTERNAL);\n\n while (++i < len) {\n allResolver(iterable[i], i);\n }\n return promise;\n function allResolver(value, i) {\n self.resolve(value).then(resolveFromAll, function (error) {\n if (!called) {\n called = true;\n handlers.reject(promise, error);\n }\n });\n function resolveFromAll(outValue) {\n values[i] = outValue;\n if (++resolved === len && !called) {\n called = true;\n handlers.resolve(promise, values);\n }\n }\n }\n}\n\nPromise.race = race;\nfunction race(iterable) {\n var self = this;\n if (Object.prototype.toString.call(iterable) !== '[object Array]') {\n return this.reject(new TypeError('must be an array'));\n }\n\n var len = iterable.length;\n var called = false;\n if (!len) {\n return this.resolve([]);\n }\n\n var i = -1;\n var promise = new this(INTERNAL);\n\n while (++i < len) {\n resolver(iterable[i]);\n }\n return promise;\n function resolver(value) {\n self.resolve(value).then(function (response) {\n if (!called) {\n called = true;\n handlers.resolve(promise, response);\n }\n }, function (error) {\n if (!called) {\n called = true;\n handlers.reject(promise, error);\n }\n });\n }\n}\n\n},{\"1\":1}],3:[function(_dereq_,module,exports){\n(function (global){\n'use strict';\nif (typeof global.Promise !== 'function') {\n global.Promise = _dereq_(2);\n}\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"2\":2}],4:[function(_dereq_,module,exports){\n'use strict';\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction getIDB() {\n /* global indexedDB,webkitIndexedDB,mozIndexedDB,OIndexedDB,msIndexedDB */\n try {\n if (typeof indexedDB !== 'undefined') {\n return indexedDB;\n }\n if (typeof webkitIndexedDB !== 'undefined') {\n return webkitIndexedDB;\n }\n if (typeof mozIndexedDB !== 'undefined') {\n return mozIndexedDB;\n }\n if (typeof OIndexedDB !== 'undefined') {\n return OIndexedDB;\n }\n if (typeof msIndexedDB !== 'undefined') {\n return msIndexedDB;\n }\n } catch (e) {\n return;\n }\n}\n\nvar idb = getIDB();\n\nfunction isIndexedDBValid() {\n try {\n // Initialize IndexedDB; fall back to vendor-prefixed versions\n // if needed.\n if (!idb) {\n return false;\n }\n // We mimic PouchDB here;\n //\n // We test for openDatabase because IE Mobile identifies itself\n // as Safari. Oh the lulz...\n var isSafari = typeof openDatabase !== 'undefined' && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform);\n\n var hasFetch = typeof fetch === 'function' && fetch.toString().indexOf('[native code') !== -1;\n\n // Safari <10.1 does not meet our requirements for IDB support (#5572)\n // since Safari 10.1 shipped with fetch, we can use that to detect it\n return (!isSafari || hasFetch) && typeof indexedDB !== 'undefined' &&\n // some outdated implementations of IDB that appear on Samsung\n // and HTC Android devices <4.4 are missing IDBKeyRange\n // See: https://github.com/mozilla/localForage/issues/128\n // See: https://github.com/mozilla/localForage/issues/272\n typeof IDBKeyRange !== 'undefined';\n } catch (e) {\n return false;\n }\n}\n\n// Abstracts constructing a Blob object, so it also works in older\n// browsers that don't support the native Blob constructor. (i.e.\n// old QtWebKit versions, at least).\n// Abstracts constructing a Blob object, so it also works in older\n// browsers that don't support the native Blob constructor. (i.e.\n// old QtWebKit versions, at least).\nfunction createBlob(parts, properties) {\n /* global BlobBuilder,MSBlobBuilder,MozBlobBuilder,WebKitBlobBuilder */\n parts = parts || [];\n properties = properties || {};\n try {\n return new Blob(parts, properties);\n } catch (e) {\n if (e.name !== 'TypeError') {\n throw e;\n }\n var Builder = typeof BlobBuilder !== 'undefined' ? BlobBuilder : typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder : typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : WebKitBlobBuilder;\n var builder = new Builder();\n for (var i = 0; i < parts.length; i += 1) {\n builder.append(parts[i]);\n }\n return builder.getBlob(properties.type);\n }\n}\n\n// This is CommonJS because lie is an external dependency, so Rollup\n// can just ignore it.\nif (typeof Promise === 'undefined') {\n // In the \"nopromises\" build this will just throw if you don't have\n // a global promise object, but it would throw anyway later.\n _dereq_(3);\n}\nvar Promise$1 = Promise;\n\nfunction executeCallback(promise, callback) {\n if (callback) {\n promise.then(function (result) {\n callback(null, result);\n }, function (error) {\n callback(error);\n });\n }\n}\n\nfunction executeTwoCallbacks(promise, callback, errorCallback) {\n if (typeof callback === 'function') {\n promise.then(callback);\n }\n\n if (typeof errorCallback === 'function') {\n promise[\"catch\"](errorCallback);\n }\n}\n\nfunction normalizeKey(key) {\n // Cast the key to a string, as that's all we can set as a key.\n if (typeof key !== 'string') {\n console.warn(key + ' used as a key, but it is not a string.');\n key = String(key);\n }\n\n return key;\n}\n\n// Some code originally from async_storage.js in\n// [Gaia](https://github.com/mozilla-b2g/gaia).\n\nvar DETECT_BLOB_SUPPORT_STORE = 'local-forage-detect-blob-support';\nvar supportsBlobs;\nvar dbContexts;\nvar toString = Object.prototype.toString;\n\n// Transaction Modes\nvar READ_ONLY = 'readonly';\nvar READ_WRITE = 'readwrite';\n\n// Transform a binary string to an array buffer, because otherwise\n// weird stuff happens when you try to work with the binary string directly.\n// It is known.\n// From http://stackoverflow.com/questions/14967647/ (continues on next line)\n// encode-decode-image-with-base64-breaks-image (2013-04-21)\nfunction _binStringToArrayBuffer(bin) {\n var length = bin.length;\n var buf = new ArrayBuffer(length);\n var arr = new Uint8Array(buf);\n for (var i = 0; i < length; i++) {\n arr[i] = bin.charCodeAt(i);\n }\n return buf;\n}\n\n//\n// Blobs are not supported in all versions of IndexedDB, notably\n// Chrome <37 and Android <5. In those versions, storing a blob will throw.\n//\n// Various other blob bugs exist in Chrome v37-42 (inclusive).\n// Detecting them is expensive and confusing to users, and Chrome 37-42\n// is at very low usage worldwide, so we do a hacky userAgent check instead.\n//\n// content-type bug: https://code.google.com/p/chromium/issues/detail?id=408120\n// 404 bug: https://code.google.com/p/chromium/issues/detail?id=447916\n// FileReader bug: https://code.google.com/p/chromium/issues/detail?id=447836\n//\n// Code borrowed from PouchDB. See:\n// https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-adapter-idb/src/blobSupport.js\n//\nfunction _checkBlobSupportWithoutCaching(idb) {\n return new Promise$1(function (resolve) {\n var txn = idb.transaction(DETECT_BLOB_SUPPORT_STORE, READ_WRITE);\n var blob = createBlob(['']);\n txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key');\n\n txn.onabort = function (e) {\n // If the transaction aborts now its due to not being able to\n // write to the database, likely due to the disk being full\n e.preventDefault();\n e.stopPropagation();\n resolve(false);\n };\n\n txn.oncomplete = function () {\n var matchedChrome = navigator.userAgent.match(/Chrome\\/(\\d+)/);\n var matchedEdge = navigator.userAgent.match(/Edge\\//);\n // MS Edge pretends to be Chrome 42:\n // https://msdn.microsoft.com/en-us/library/hh869301%28v=vs.85%29.aspx\n resolve(matchedEdge || !matchedChrome || parseInt(matchedChrome[1], 10) >= 43);\n };\n })[\"catch\"](function () {\n return false; // error, so assume unsupported\n });\n}\n\nfunction _checkBlobSupport(idb) {\n if (typeof supportsBlobs === 'boolean') {\n return Promise$1.resolve(supportsBlobs);\n }\n return _checkBlobSupportWithoutCaching(idb).then(function (value) {\n supportsBlobs = value;\n return supportsBlobs;\n });\n}\n\nfunction _deferReadiness(dbInfo) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Create a deferred object representing the current database operation.\n var deferredOperation = {};\n\n deferredOperation.promise = new Promise$1(function (resolve) {\n deferredOperation.resolve = resolve;\n });\n\n // Enqueue the deferred operation.\n dbContext.deferredOperations.push(deferredOperation);\n\n // Chain its promise to the database readiness.\n if (!dbContext.dbReady) {\n dbContext.dbReady = deferredOperation.promise;\n } else {\n dbContext.dbReady = dbContext.dbReady.then(function () {\n return deferredOperation.promise;\n });\n }\n}\n\nfunction _advanceReadiness(dbInfo) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Dequeue a deferred operation.\n var deferredOperation = dbContext.deferredOperations.pop();\n\n // Resolve its promise (which is part of the database readiness\n // chain of promises).\n if (deferredOperation) {\n deferredOperation.resolve();\n }\n}\n\nfunction _rejectReadiness(dbInfo, err) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Dequeue a deferred operation.\n var deferredOperation = dbContext.deferredOperations.pop();\n\n // Reject its promise (which is part of the database readiness\n // chain of promises).\n if (deferredOperation) {\n deferredOperation.reject(err);\n }\n}\n\nfunction _getConnection(dbInfo, upgradeNeeded) {\n return new Promise$1(function (resolve, reject) {\n\n if (dbInfo.db) {\n if (upgradeNeeded) {\n _deferReadiness(dbInfo);\n dbInfo.db.close();\n } else {\n return resolve(dbInfo.db);\n }\n }\n\n var dbArgs = [dbInfo.name];\n\n if (upgradeNeeded) {\n dbArgs.push(dbInfo.version);\n }\n\n var openreq = idb.open.apply(idb, dbArgs);\n\n if (upgradeNeeded) {\n openreq.onupgradeneeded = function (e) {\n var db = openreq.result;\n try {\n db.createObjectStore(dbInfo.storeName);\n if (e.oldVersion <= 1) {\n // Added when support for blob shims was added\n db.createObjectStore(DETECT_BLOB_SUPPORT_STORE);\n }\n } catch (ex) {\n if (ex.name === 'ConstraintError') {\n console.warn('The database \"' + dbInfo.name + '\"' + ' has been upgraded from version ' + e.oldVersion + ' to version ' + e.newVersion + ', but the storage \"' + dbInfo.storeName + '\" already exists.');\n } else {\n throw ex;\n }\n }\n };\n }\n\n openreq.onerror = function (e) {\n e.preventDefault();\n reject(openreq.error);\n };\n\n openreq.onsuccess = function () {\n resolve(openreq.result);\n _advanceReadiness(dbInfo);\n };\n });\n}\n\nfunction _getOriginalConnection(dbInfo) {\n return _getConnection(dbInfo, false);\n}\n\nfunction _getUpgradedConnection(dbInfo) {\n return _getConnection(dbInfo, true);\n}\n\nfunction _isUpgradeNeeded(dbInfo, defaultVersion) {\n if (!dbInfo.db) {\n return true;\n }\n\n var isNewStore = !dbInfo.db.objectStoreNames.contains(dbInfo.storeName);\n var isDowngrade = dbInfo.version < dbInfo.db.version;\n var isUpgrade = dbInfo.version > dbInfo.db.version;\n\n if (isDowngrade) {\n // If the version is not the default one\n // then warn for impossible downgrade.\n if (dbInfo.version !== defaultVersion) {\n console.warn('The database \"' + dbInfo.name + '\"' + ' can\\'t be downgraded from version ' + dbInfo.db.version + ' to version ' + dbInfo.version + '.');\n }\n // Align the versions to prevent errors.\n dbInfo.version = dbInfo.db.version;\n }\n\n if (isUpgrade || isNewStore) {\n // If the store is new then increment the version (if needed).\n // This will trigger an \"upgradeneeded\" event which is required\n // for creating a store.\n if (isNewStore) {\n var incVersion = dbInfo.db.version + 1;\n if (incVersion > dbInfo.version) {\n dbInfo.version = incVersion;\n }\n }\n\n return true;\n }\n\n return false;\n}\n\n// encode a blob for indexeddb engines that don't support blobs\nfunction _encodeBlob(blob) {\n return new Promise$1(function (resolve, reject) {\n var reader = new FileReader();\n reader.onerror = reject;\n reader.onloadend = function (e) {\n var base64 = btoa(e.target.result || '');\n resolve({\n __local_forage_encoded_blob: true,\n data: base64,\n type: blob.type\n });\n };\n reader.readAsBinaryString(blob);\n });\n}\n\n// decode an encoded blob\nfunction _decodeBlob(encodedBlob) {\n var arrayBuff = _binStringToArrayBuffer(atob(encodedBlob.data));\n return createBlob([arrayBuff], { type: encodedBlob.type });\n}\n\n// is this one of our fancy encoded blobs?\nfunction _isEncodedBlob(value) {\n return value && value.__local_forage_encoded_blob;\n}\n\n// Specialize the default `ready()` function by making it dependent\n// on the current database operations. Thus, the driver will be actually\n// ready when it's been initialized (default) *and* there are no pending\n// operations on the database (initiated by some other instances).\nfunction _fullyReady(callback) {\n var self = this;\n\n var promise = self._initReady().then(function () {\n var dbContext = dbContexts[self._dbInfo.name];\n\n if (dbContext && dbContext.dbReady) {\n return dbContext.dbReady;\n }\n });\n\n executeTwoCallbacks(promise, callback, callback);\n return promise;\n}\n\n// Try to establish a new db connection to replace the\n// current one which is broken (i.e. experiencing\n// InvalidStateError while creating a transaction).\nfunction _tryReconnect(dbInfo) {\n _deferReadiness(dbInfo);\n\n var dbContext = dbContexts[dbInfo.name];\n var forages = dbContext.forages;\n\n for (var i = 0; i < forages.length; i++) {\n if (forages[i]._dbInfo.db) {\n forages[i]._dbInfo.db.close();\n forages[i]._dbInfo.db = null;\n }\n }\n\n return _getConnection(dbInfo, false).then(function (db) {\n for (var j = 0; j < forages.length; j++) {\n forages[j]._dbInfo.db = db;\n }\n })[\"catch\"](function (err) {\n _rejectReadiness(dbInfo, err);\n throw err;\n });\n}\n\n// FF doesn't like Promises (micro-tasks) and IDDB store operations,\n// so we have to do it with callbacks\nfunction createTransaction(dbInfo, mode, callback) {\n try {\n var tx = dbInfo.db.transaction(dbInfo.storeName, mode);\n callback(null, tx);\n } catch (err) {\n if (!dbInfo.db || err.name === 'InvalidStateError') {\n return _tryReconnect(dbInfo).then(function () {\n\n var tx = dbInfo.db.transaction(dbInfo.storeName, mode);\n callback(null, tx);\n });\n }\n\n callback(err);\n }\n}\n\n// Open the IndexedDB database (automatically creates one if one didn't\n// previously exist), using any options set in the config.\nfunction _initStorage(options) {\n var self = this;\n var dbInfo = {\n db: null\n };\n\n if (options) {\n for (var i in options) {\n dbInfo[i] = options[i];\n }\n }\n\n // Initialize a singleton container for all running localForages.\n if (!dbContexts) {\n dbContexts = {};\n }\n\n // Get the current context of the database;\n var dbContext = dbContexts[dbInfo.name];\n\n // ...or create a new context.\n if (!dbContext) {\n dbContext = {\n // Running localForages sharing a database.\n forages: [],\n // Shared database.\n db: null,\n // Database readiness (promise).\n dbReady: null,\n // Deferred operations on the database.\n deferredOperations: []\n };\n // Register the new context in the global container.\n dbContexts[dbInfo.name] = dbContext;\n }\n\n // Register itself as a running localForage in the current context.\n dbContext.forages.push(self);\n\n // Replace the default `ready()` function with the specialized one.\n if (!self._initReady) {\n self._initReady = self.ready;\n self.ready = _fullyReady;\n }\n\n // Create an array of initialization states of the related localForages.\n var initPromises = [];\n\n function ignoreErrors() {\n // Don't handle errors here,\n // just makes sure related localForages aren't pending.\n return Promise$1.resolve();\n }\n\n for (var j = 0; j < dbContext.forages.length; j++) {\n var forage = dbContext.forages[j];\n if (forage !== self) {\n // Don't wait for itself...\n initPromises.push(forage._initReady()[\"catch\"](ignoreErrors));\n }\n }\n\n // Take a snapshot of the related localForages.\n var forages = dbContext.forages.slice(0);\n\n // Initialize the connection process only when\n // all the related localForages aren't pending.\n return Promise$1.all(initPromises).then(function () {\n dbInfo.db = dbContext.db;\n // Get the connection or open a new one without upgrade.\n return _getOriginalConnection(dbInfo);\n }).then(function (db) {\n dbInfo.db = db;\n if (_isUpgradeNeeded(dbInfo, self._defaultConfig.version)) {\n // Reopen the database for upgrading.\n return _getUpgradedConnection(dbInfo);\n }\n return db;\n }).then(function (db) {\n dbInfo.db = dbContext.db = db;\n self._dbInfo = dbInfo;\n // Share the final connection amongst related localForages.\n for (var k = 0; k < forages.length; k++) {\n var forage = forages[k];\n if (forage !== self) {\n // Self is already up-to-date.\n forage._dbInfo.db = dbInfo.db;\n forage._dbInfo.version = dbInfo.version;\n }\n }\n });\n}\n\nfunction getItem(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.get(key);\n\n req.onsuccess = function () {\n var value = req.result;\n if (value === undefined) {\n value = null;\n }\n if (_isEncodedBlob(value)) {\n value = _decodeBlob(value);\n }\n resolve(value);\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Iterate over all items stored in database.\nfunction iterate(iterator, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.openCursor();\n var iterationNumber = 1;\n\n req.onsuccess = function () {\n var cursor = req.result;\n\n if (cursor) {\n var value = cursor.value;\n if (_isEncodedBlob(value)) {\n value = _decodeBlob(value);\n }\n var result = iterator(value, cursor.key, iterationNumber++);\n\n // when the iterator callback retuns any\n // (non-`undefined`) value, then we stop\n // the iteration immediately\n if (result !== void 0) {\n resolve(result);\n } else {\n cursor[\"continue\"]();\n }\n } else {\n resolve();\n }\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n\n return promise;\n}\n\nfunction setItem(key, value, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n var dbInfo;\n self.ready().then(function () {\n dbInfo = self._dbInfo;\n if (toString.call(value) === '[object Blob]') {\n return _checkBlobSupport(dbInfo.db).then(function (blobSupport) {\n if (blobSupport) {\n return value;\n }\n return _encodeBlob(value);\n });\n }\n return value;\n }).then(function (value) {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n\n // The reason we don't _save_ null is because IE 10 does\n // not support saving the `null` type in IndexedDB. How\n // ironic, given the bug below!\n // See: https://github.com/mozilla/localForage/issues/161\n if (value === null) {\n value = undefined;\n }\n\n var req = store.put(value, key);\n\n transaction.oncomplete = function () {\n // Cast to undefined so the value passed to\n // callback/promise is the same as what one would get out\n // of `getItem()` later. This leads to some weirdness\n // (setItem('foo', undefined) will return `null`), but\n // it's not my fault localStorage is our baseline and that\n // it's weird.\n if (value === undefined) {\n value = null;\n }\n\n resolve(value);\n };\n transaction.onabort = transaction.onerror = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction removeItem(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n // We use a Grunt task to make this safe for IE and some\n // versions of Android (including those used by Cordova).\n // Normally IE won't like `.delete()` and will insist on\n // using `['delete']()`, but we have a build step that\n // fixes this for us now.\n var req = store[\"delete\"](key);\n transaction.oncomplete = function () {\n resolve();\n };\n\n transaction.onerror = function () {\n reject(req.error);\n };\n\n // The request will be also be aborted if we've exceeded our storage\n // space.\n transaction.onabort = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction clear(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.clear();\n\n transaction.oncomplete = function () {\n resolve();\n };\n\n transaction.onabort = transaction.onerror = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction length(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.count();\n\n req.onsuccess = function () {\n resolve(req.result);\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction key(n, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n if (n < 0) {\n resolve(null);\n\n return;\n }\n\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var advanced = false;\n var req = store.openCursor();\n\n req.onsuccess = function () {\n var cursor = req.result;\n if (!cursor) {\n // this means there weren't enough keys\n resolve(null);\n\n return;\n }\n\n if (n === 0) {\n // We have the first key, return it if that's what they\n // wanted.\n resolve(cursor.key);\n } else {\n if (!advanced) {\n // Otherwise, ask the cursor to skip ahead n\n // records.\n advanced = true;\n cursor.advance(n);\n } else {\n // When we get here, we've got the nth key.\n resolve(cursor.key);\n }\n }\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.openCursor();\n var keys = [];\n\n req.onsuccess = function () {\n var cursor = req.result;\n\n if (!cursor) {\n resolve(keys);\n return;\n }\n\n keys.push(cursor.key);\n cursor[\"continue\"]();\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar asyncStorage = {\n _driver: 'asyncStorage',\n _initStorage: _initStorage,\n _support: isIndexedDBValid(),\n iterate: iterate,\n getItem: getItem,\n setItem: setItem,\n removeItem: removeItem,\n clear: clear,\n length: length,\n key: key,\n keys: keys\n};\n\nfunction isWebSQLValid() {\n return typeof openDatabase === 'function';\n}\n\n// Sadly, the best way to save binary data in WebSQL/localStorage is serializing\n// it to Base64, so this is how we store it to prevent very strange errors with less\n// verbose ways of binary <-> string data storage.\nvar BASE_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\nvar BLOB_TYPE_PREFIX = '~~local_forage_type~';\nvar BLOB_TYPE_PREFIX_REGEX = /^~~local_forage_type~([^~]+)~/;\n\nvar SERIALIZED_MARKER = '__lfsc__:';\nvar SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER.length;\n\n// OMG the serializations!\nvar TYPE_ARRAYBUFFER = 'arbf';\nvar TYPE_BLOB = 'blob';\nvar TYPE_INT8ARRAY = 'si08';\nvar TYPE_UINT8ARRAY = 'ui08';\nvar TYPE_UINT8CLAMPEDARRAY = 'uic8';\nvar TYPE_INT16ARRAY = 'si16';\nvar TYPE_INT32ARRAY = 'si32';\nvar TYPE_UINT16ARRAY = 'ur16';\nvar TYPE_UINT32ARRAY = 'ui32';\nvar TYPE_FLOAT32ARRAY = 'fl32';\nvar TYPE_FLOAT64ARRAY = 'fl64';\nvar TYPE_SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER_LENGTH + TYPE_ARRAYBUFFER.length;\n\nvar toString$1 = Object.prototype.toString;\n\nfunction stringToBuffer(serializedString) {\n // Fill the string into a ArrayBuffer.\n var bufferLength = serializedString.length * 0.75;\n var len = serializedString.length;\n var i;\n var p = 0;\n var encoded1, encoded2, encoded3, encoded4;\n\n if (serializedString[serializedString.length - 1] === '=') {\n bufferLength--;\n if (serializedString[serializedString.length - 2] === '=') {\n bufferLength--;\n }\n }\n\n var buffer = new ArrayBuffer(bufferLength);\n var bytes = new Uint8Array(buffer);\n\n for (i = 0; i < len; i += 4) {\n encoded1 = BASE_CHARS.indexOf(serializedString[i]);\n encoded2 = BASE_CHARS.indexOf(serializedString[i + 1]);\n encoded3 = BASE_CHARS.indexOf(serializedString[i + 2]);\n encoded4 = BASE_CHARS.indexOf(serializedString[i + 3]);\n\n /*jslint bitwise: true */\n bytes[p++] = encoded1 << 2 | encoded2 >> 4;\n bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;\n bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;\n }\n return buffer;\n}\n\n// Converts a buffer to a string to store, serialized, in the backend\n// storage library.\nfunction bufferToString(buffer) {\n // base64-arraybuffer\n var bytes = new Uint8Array(buffer);\n var base64String = '';\n var i;\n\n for (i = 0; i < bytes.length; i += 3) {\n /*jslint bitwise: true */\n base64String += BASE_CHARS[bytes[i] >> 2];\n base64String += BASE_CHARS[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];\n base64String += BASE_CHARS[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];\n base64String += BASE_CHARS[bytes[i + 2] & 63];\n }\n\n if (bytes.length % 3 === 2) {\n base64String = base64String.substring(0, base64String.length - 1) + '=';\n } else if (bytes.length % 3 === 1) {\n base64String = base64String.substring(0, base64String.length - 2) + '==';\n }\n\n return base64String;\n}\n\n// Serialize a value, afterwards executing a callback (which usually\n// instructs the `setItem()` callback/promise to be executed). This is how\n// we store binary data with localStorage.\nfunction serialize(value, callback) {\n var valueType = '';\n if (value) {\n valueType = toString$1.call(value);\n }\n\n // Cannot use `value instanceof ArrayBuffer` or such here, as these\n // checks fail when running the tests using casper.js...\n //\n // TODO: See why those tests fail and use a better solution.\n if (value && (valueType === '[object ArrayBuffer]' || value.buffer && toString$1.call(value.buffer) === '[object ArrayBuffer]')) {\n // Convert binary arrays to a string and prefix the string with\n // a special marker.\n var buffer;\n var marker = SERIALIZED_MARKER;\n\n if (value instanceof ArrayBuffer) {\n buffer = value;\n marker += TYPE_ARRAYBUFFER;\n } else {\n buffer = value.buffer;\n\n if (valueType === '[object Int8Array]') {\n marker += TYPE_INT8ARRAY;\n } else if (valueType === '[object Uint8Array]') {\n marker += TYPE_UINT8ARRAY;\n } else if (valueType === '[object Uint8ClampedArray]') {\n marker += TYPE_UINT8CLAMPEDARRAY;\n } else if (valueType === '[object Int16Array]') {\n marker += TYPE_INT16ARRAY;\n } else if (valueType === '[object Uint16Array]') {\n marker += TYPE_UINT16ARRAY;\n } else if (valueType === '[object Int32Array]') {\n marker += TYPE_INT32ARRAY;\n } else if (valueType === '[object Uint32Array]') {\n marker += TYPE_UINT32ARRAY;\n } else if (valueType === '[object Float32Array]') {\n marker += TYPE_FLOAT32ARRAY;\n } else if (valueType === '[object Float64Array]') {\n marker += TYPE_FLOAT64ARRAY;\n } else {\n callback(new Error('Failed to get type for BinaryArray'));\n }\n }\n\n callback(marker + bufferToString(buffer));\n } else if (valueType === '[object Blob]') {\n // Conver the blob to a binaryArray and then to a string.\n var fileReader = new FileReader();\n\n fileReader.onload = function () {\n // Backwards-compatible prefix for the blob type.\n var str = BLOB_TYPE_PREFIX + value.type + '~' + bufferToString(this.result);\n\n callback(SERIALIZED_MARKER + TYPE_BLOB + str);\n };\n\n fileReader.readAsArrayBuffer(value);\n } else {\n try {\n callback(JSON.stringify(value));\n } catch (e) {\n console.error(\"Couldn't convert value into a JSON string: \", value);\n\n callback(null, e);\n }\n }\n}\n\n// Deserialize data we've inserted into a value column/field. We place\n// special markers into our strings to mark them as encoded; this isn't\n// as nice as a meta field, but it's the only sane thing we can do whilst\n// keeping localStorage support intact.\n//\n// Oftentimes this will just deserialize JSON content, but if we have a\n// special marker (SERIALIZED_MARKER, defined above), we will extract\n// some kind of arraybuffer/binary data/typed array out of the string.\nfunction deserialize(value) {\n // If we haven't marked this string as being specially serialized (i.e.\n // something other than serialized JSON), we can just return it and be\n // done with it.\n if (value.substring(0, SERIALIZED_MARKER_LENGTH) !== SERIALIZED_MARKER) {\n return JSON.parse(value);\n }\n\n // The following code deals with deserializing some kind of Blob or\n // TypedArray. First we separate out the type of data we're dealing\n // with from the data itself.\n var serializedString = value.substring(TYPE_SERIALIZED_MARKER_LENGTH);\n var type = value.substring(SERIALIZED_MARKER_LENGTH, TYPE_SERIALIZED_MARKER_LENGTH);\n\n var blobType;\n // Backwards-compatible blob type serialization strategy.\n // DBs created with older versions of localForage will simply not have the blob type.\n if (type === TYPE_BLOB && BLOB_TYPE_PREFIX_REGEX.test(serializedString)) {\n var matcher = serializedString.match(BLOB_TYPE_PREFIX_REGEX);\n blobType = matcher[1];\n serializedString = serializedString.substring(matcher[0].length);\n }\n var buffer = stringToBuffer(serializedString);\n\n // Return the right type based on the code/type set during\n // serialization.\n switch (type) {\n case TYPE_ARRAYBUFFER:\n return buffer;\n case TYPE_BLOB:\n return createBlob([buffer], { type: blobType });\n case TYPE_INT8ARRAY:\n return new Int8Array(buffer);\n case TYPE_UINT8ARRAY:\n return new Uint8Array(buffer);\n case TYPE_UINT8CLAMPEDARRAY:\n return new Uint8ClampedArray(buffer);\n case TYPE_INT16ARRAY:\n return new Int16Array(buffer);\n case TYPE_UINT16ARRAY:\n return new Uint16Array(buffer);\n case TYPE_INT32ARRAY:\n return new Int32Array(buffer);\n case TYPE_UINT32ARRAY:\n return new Uint32Array(buffer);\n case TYPE_FLOAT32ARRAY:\n return new Float32Array(buffer);\n case TYPE_FLOAT64ARRAY:\n return new Float64Array(buffer);\n default:\n throw new Error('Unkown type: ' + type);\n }\n}\n\nvar localforageSerializer = {\n serialize: serialize,\n deserialize: deserialize,\n stringToBuffer: stringToBuffer,\n bufferToString: bufferToString\n};\n\n/*\n * Includes code from:\n *\n * base64-arraybuffer\n * https://github.com/niklasvh/base64-arraybuffer\n *\n * Copyright (c) 2012 Niklas von Hertzen\n * Licensed under the MIT license.\n */\n// Open the WebSQL database (automatically creates one if one didn't\n// previously exist), using any options set in the config.\nfunction _initStorage$1(options) {\n var self = this;\n var dbInfo = {\n db: null\n };\n\n if (options) {\n for (var i in options) {\n dbInfo[i] = typeof options[i] !== 'string' ? options[i].toString() : options[i];\n }\n }\n\n var dbInfoPromise = new Promise$1(function (resolve, reject) {\n // Open the database; the openDatabase API will automatically\n // create it for us if it doesn't exist.\n try {\n dbInfo.db = openDatabase(dbInfo.name, String(dbInfo.version), dbInfo.description, dbInfo.size);\n } catch (e) {\n return reject(e);\n }\n\n // Create our key/value table if it doesn't exist.\n dbInfo.db.transaction(function (t) {\n t.executeSql('CREATE TABLE IF NOT EXISTS ' + dbInfo.storeName + ' (id INTEGER PRIMARY KEY, key unique, value)', [], function () {\n self._dbInfo = dbInfo;\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n });\n\n dbInfo.serializer = localforageSerializer;\n return dbInfoPromise;\n}\n\nfunction getItem$1(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE key = ? LIMIT 1', [key], function (t, results) {\n var result = results.rows.length ? results.rows.item(0).value : null;\n\n // Check to see if this is serialized content we need to\n // unpack.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n resolve(result);\n }, function (t, error) {\n\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction iterate$1(iterator, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT * FROM ' + dbInfo.storeName, [], function (t, results) {\n var rows = results.rows;\n var length = rows.length;\n\n for (var i = 0; i < length; i++) {\n var item = rows.item(i);\n var result = item.value;\n\n // Check to see if this is serialized content\n // we need to unpack.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n result = iterator(result, item.key, i + 1);\n\n // void(0) prevents problems with redefinition\n // of `undefined`.\n if (result !== void 0) {\n resolve(result);\n return;\n }\n }\n\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction _setItem(key, value, callback, retriesLeft) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n // The localStorage API doesn't return undefined values in an\n // \"expected\" way, so undefined is always cast to null in all\n // drivers. See: https://github.com/mozilla/localForage/pull/42\n if (value === undefined) {\n value = null;\n }\n\n // Save the original value to pass to the callback.\n var originalValue = value;\n\n var dbInfo = self._dbInfo;\n dbInfo.serializer.serialize(value, function (value, error) {\n if (error) {\n reject(error);\n } else {\n dbInfo.db.transaction(function (t) {\n t.executeSql('INSERT OR REPLACE INTO ' + dbInfo.storeName + ' (key, value) VALUES (?, ?)', [key, value], function () {\n resolve(originalValue);\n }, function (t, error) {\n reject(error);\n });\n }, function (sqlError) {\n // The transaction failed; check\n // to see if it's a quota error.\n if (sqlError.code === sqlError.QUOTA_ERR) {\n // We reject the callback outright for now, but\n // it's worth trying to re-run the transaction.\n // Even if the user accepts the prompt to use\n // more storage on Safari, this error will\n // be called.\n //\n // Try to re-run the transaction.\n if (retriesLeft > 0) {\n resolve(_setItem.apply(self, [key, originalValue, callback, retriesLeft - 1]));\n return;\n }\n reject(sqlError);\n }\n });\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction setItem$1(key, value, callback) {\n return _setItem.apply(this, [key, value, callback, 1]);\n}\n\nfunction removeItem$1(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('DELETE FROM ' + dbInfo.storeName + ' WHERE key = ?', [key], function () {\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Deletes every item in the table.\n// TODO: Find out if this resets the AUTO_INCREMENT number.\nfunction clear$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('DELETE FROM ' + dbInfo.storeName, [], function () {\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Does a simple `COUNT(key)` to get the number of items stored in\n// localForage.\nfunction length$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n // Ahhh, SQL makes this one soooooo easy.\n t.executeSql('SELECT COUNT(key) as c FROM ' + dbInfo.storeName, [], function (t, results) {\n var result = results.rows.item(0).c;\n\n resolve(result);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Return the key located at key index X; essentially gets the key from a\n// `WHERE id = ?`. This is the most efficient way I can think to implement\n// this rarely-used (in my experience) part of the API, but it can seem\n// inconsistent, because we do `INSERT OR REPLACE INTO` on `setItem()`, so\n// the ID of each key will change every time it's updated. Perhaps a stored\n// procedure for the `setItem()` SQL would solve this problem?\n// TODO: Don't change ID on `setItem()`.\nfunction key$1(n, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT key FROM ' + dbInfo.storeName + ' WHERE id = ? LIMIT 1', [n + 1], function (t, results) {\n var result = results.rows.length ? results.rows.item(0).key : null;\n resolve(result);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT key FROM ' + dbInfo.storeName, [], function (t, results) {\n var keys = [];\n\n for (var i = 0; i < results.rows.length; i++) {\n keys.push(results.rows.item(i).key);\n }\n\n resolve(keys);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar webSQLStorage = {\n _driver: 'webSQLStorage',\n _initStorage: _initStorage$1,\n _support: isWebSQLValid(),\n iterate: iterate$1,\n getItem: getItem$1,\n setItem: setItem$1,\n removeItem: removeItem$1,\n clear: clear$1,\n length: length$1,\n key: key$1,\n keys: keys$1\n};\n\nfunction isLocalStorageValid() {\n try {\n return typeof localStorage !== 'undefined' && 'setItem' in localStorage && typeof localStorage.setItem === 'function';\n } catch (e) {\n return false;\n }\n}\n\n// Check if localStorage throws when saving an item\nfunction checkIfLocalStorageThrows() {\n var localStorageTestKey = '_localforage_support_test';\n\n try {\n localStorage.setItem(localStorageTestKey, true);\n localStorage.removeItem(localStorageTestKey);\n\n return false;\n } catch (e) {\n return true;\n }\n}\n\n// Check if localStorage is usable and allows to save an item\n// This method checks if localStorage is usable in Safari Private Browsing\n// mode, or in any other case where the available quota for localStorage\n// is 0 and there wasn't any saved items yet.\nfunction _isLocalStorageUsable() {\n return !checkIfLocalStorageThrows() || localStorage.length > 0;\n}\n\n// Config the localStorage backend, using options set in the config.\nfunction _initStorage$2(options) {\n var self = this;\n var dbInfo = {};\n if (options) {\n for (var i in options) {\n dbInfo[i] = options[i];\n }\n }\n\n dbInfo.keyPrefix = dbInfo.name + '/';\n\n if (dbInfo.storeName !== self._defaultConfig.storeName) {\n dbInfo.keyPrefix += dbInfo.storeName + '/';\n }\n\n if (!_isLocalStorageUsable()) {\n return Promise$1.reject();\n }\n\n self._dbInfo = dbInfo;\n dbInfo.serializer = localforageSerializer;\n\n return Promise$1.resolve();\n}\n\n// Remove all keys from the datastore, effectively destroying all data in\n// the app's key/value store!\nfunction clear$2(callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var keyPrefix = self._dbInfo.keyPrefix;\n\n for (var i = localStorage.length - 1; i >= 0; i--) {\n var key = localStorage.key(i);\n\n if (key.indexOf(keyPrefix) === 0) {\n localStorage.removeItem(key);\n }\n }\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Retrieve an item from the store. Unlike the original async_storage\n// library in Gaia, we don't modify return values at all. If a key's value\n// is `undefined`, we pass that value to the callback function.\nfunction getItem$2(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var result = localStorage.getItem(dbInfo.keyPrefix + key);\n\n // If a result was found, parse it from the serialized\n // string into a JS object. If result isn't truthy, the key\n // is likely undefined and we'll pass it straight to the\n // callback.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n return result;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Iterate over all items in the store.\nfunction iterate$2(iterator, callback) {\n var self = this;\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var keyPrefix = dbInfo.keyPrefix;\n var keyPrefixLength = keyPrefix.length;\n var length = localStorage.length;\n\n // We use a dedicated iterator instead of the `i` variable below\n // so other keys we fetch in localStorage aren't counted in\n // the `iterationNumber` argument passed to the `iterate()`\n // callback.\n //\n // See: github.com/mozilla/localForage/pull/435#discussion_r38061530\n var iterationNumber = 1;\n\n for (var i = 0; i < length; i++) {\n var key = localStorage.key(i);\n if (key.indexOf(keyPrefix) !== 0) {\n continue;\n }\n var value = localStorage.getItem(key);\n\n // If a result was found, parse it from the serialized\n // string into a JS object. If result isn't truthy, the\n // key is likely undefined and we'll pass it straight\n // to the iterator.\n if (value) {\n value = dbInfo.serializer.deserialize(value);\n }\n\n value = iterator(value, key.substring(keyPrefixLength), iterationNumber++);\n\n if (value !== void 0) {\n return value;\n }\n }\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Same as localStorage's key() method, except takes a callback.\nfunction key$2(n, callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var result;\n try {\n result = localStorage.key(n);\n } catch (error) {\n result = null;\n }\n\n // Remove the prefix from the key, if a key is found.\n if (result) {\n result = result.substring(dbInfo.keyPrefix.length);\n }\n\n return result;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys$2(callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var length = localStorage.length;\n var keys = [];\n\n for (var i = 0; i < length; i++) {\n var itemKey = localStorage.key(i);\n if (itemKey.indexOf(dbInfo.keyPrefix) === 0) {\n keys.push(itemKey.substring(dbInfo.keyPrefix.length));\n }\n }\n\n return keys;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Supply the number of keys in the datastore to the callback function.\nfunction length$2(callback) {\n var self = this;\n var promise = self.keys().then(function (keys) {\n return keys.length;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Remove an item from the store, nice and simple.\nfunction removeItem$2(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n localStorage.removeItem(dbInfo.keyPrefix + key);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Set a key's value and run an optional callback once the value is set.\n// Unlike Gaia's implementation, the callback function is passed the value,\n// in case you want to operate on that value only after you're sure it\n// saved, or something like that.\nfunction setItem$2(key, value, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n // Convert undefined values to null.\n // https://github.com/mozilla/localForage/pull/42\n if (value === undefined) {\n value = null;\n }\n\n // Save the original value to pass to the callback.\n var originalValue = value;\n\n return new Promise$1(function (resolve, reject) {\n var dbInfo = self._dbInfo;\n dbInfo.serializer.serialize(value, function (value, error) {\n if (error) {\n reject(error);\n } else {\n try {\n localStorage.setItem(dbInfo.keyPrefix + key, value);\n resolve(originalValue);\n } catch (e) {\n // localStorage capacity exceeded.\n // TODO: Make this a specific error/event.\n if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {\n reject(e);\n }\n reject(e);\n }\n }\n });\n });\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar localStorageWrapper = {\n _driver: 'localStorageWrapper',\n _initStorage: _initStorage$2,\n _support: isLocalStorageValid(),\n iterate: iterate$2,\n getItem: getItem$2,\n setItem: setItem$2,\n removeItem: removeItem$2,\n clear: clear$2,\n length: length$2,\n key: key$2,\n keys: keys$2\n};\n\nvar isArray = Array.isArray || function (arg) {\n return Object.prototype.toString.call(arg) === '[object Array]';\n};\n\n// Drivers are stored here when `defineDriver()` is called.\n// They are shared across all instances of localForage.\nvar DefinedDrivers = {};\n\nvar DriverSupport = {};\n\nvar DefaultDrivers = {\n INDEXEDDB: asyncStorage,\n WEBSQL: webSQLStorage,\n LOCALSTORAGE: localStorageWrapper\n};\n\nvar DefaultDriverOrder = [DefaultDrivers.INDEXEDDB._driver, DefaultDrivers.WEBSQL._driver, DefaultDrivers.LOCALSTORAGE._driver];\n\nvar LibraryMethods = ['clear', 'getItem', 'iterate', 'key', 'keys', 'length', 'removeItem', 'setItem'];\n\nvar DefaultConfig = {\n description: '',\n driver: DefaultDriverOrder.slice(),\n name: 'localforage',\n // Default DB size is _JUST UNDER_ 5MB, as it's the highest size\n // we can use without a prompt.\n size: 4980736,\n storeName: 'keyvaluepairs',\n version: 1.0\n};\n\nfunction callWhenReady(localForageInstance, libraryMethod) {\n localForageInstance[libraryMethod] = function () {\n var _args = arguments;\n return localForageInstance.ready().then(function () {\n return localForageInstance[libraryMethod].apply(localForageInstance, _args);\n });\n };\n}\n\nfunction extend() {\n for (var i = 1; i < arguments.length; i++) {\n var arg = arguments[i];\n\n if (arg) {\n for (var _key in arg) {\n if (arg.hasOwnProperty(_key)) {\n if (isArray(arg[_key])) {\n arguments[0][_key] = arg[_key].slice();\n } else {\n arguments[0][_key] = arg[_key];\n }\n }\n }\n }\n }\n\n return arguments[0];\n}\n\nvar LocalForage = function () {\n function LocalForage(options) {\n _classCallCheck(this, LocalForage);\n\n for (var driverTypeKey in DefaultDrivers) {\n if (DefaultDrivers.hasOwnProperty(driverTypeKey)) {\n var driver = DefaultDrivers[driverTypeKey];\n var driverName = driver._driver;\n this[driverTypeKey] = driverName;\n\n if (!DefinedDrivers[driverName]) {\n // we don't need to wait for the promise,\n // since the default drivers can be defined\n // in a blocking manner\n this.defineDriver(driver);\n }\n }\n }\n\n this._defaultConfig = extend({}, DefaultConfig);\n this._config = extend({}, this._defaultConfig, options);\n this._driverSet = null;\n this._initDriver = null;\n this._ready = false;\n this._dbInfo = null;\n\n this._wrapLibraryMethodsWithReady();\n this.setDriver(this._config.driver)[\"catch\"](function () {});\n }\n\n // Set any config values for localForage; can be called anytime before\n // the first API call (e.g. `getItem`, `setItem`).\n // We loop through options so we don't overwrite existing config\n // values.\n\n\n LocalForage.prototype.config = function config(options) {\n // If the options argument is an object, we use it to set values.\n // Otherwise, we return either a specified config value or all\n // config values.\n if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object') {\n // If localforage is ready and fully initialized, we can't set\n // any new configuration values. Instead, we return an error.\n if (this._ready) {\n return new Error('Can\\'t call config() after localforage ' + 'has been used.');\n }\n\n for (var i in options) {\n if (i === 'storeName') {\n options[i] = options[i].replace(/\\W/g, '_');\n }\n\n if (i === 'version' && typeof options[i] !== 'number') {\n return new Error('Database version must be a number.');\n }\n\n this._config[i] = options[i];\n }\n\n // after all config options are set and\n // the driver option is used, try setting it\n if ('driver' in options && options.driver) {\n return this.setDriver(this._config.driver);\n }\n\n return true;\n } else if (typeof options === 'string') {\n return this._config[options];\n } else {\n return this._config;\n }\n };\n\n // Used to define a custom driver, shared across all instances of\n // localForage.\n\n\n LocalForage.prototype.defineDriver = function defineDriver(driverObject, callback, errorCallback) {\n var promise = new Promise$1(function (resolve, reject) {\n try {\n var driverName = driverObject._driver;\n var complianceError = new Error('Custom driver not compliant; see ' + 'https://mozilla.github.io/localForage/#definedriver');\n\n // A driver name should be defined and not overlap with the\n // library-defined, default drivers.\n if (!driverObject._driver) {\n reject(complianceError);\n return;\n }\n\n var driverMethods = LibraryMethods.concat('_initStorage');\n for (var i = 0, len = driverMethods.length; i < len; i++) {\n var customDriverMethod = driverMethods[i];\n if (!customDriverMethod || !driverObject[customDriverMethod] || typeof driverObject[customDriverMethod] !== 'function') {\n reject(complianceError);\n return;\n }\n }\n\n var setDriverSupport = function setDriverSupport(support) {\n if (DefinedDrivers[driverName]) {\n console.info('Redefining LocalForage driver: ' + driverName);\n }\n DefinedDrivers[driverName] = driverObject;\n DriverSupport[driverName] = support;\n // don't use a then, so that we can define\n // drivers that have simple _support methods\n // in a blocking manner\n resolve();\n };\n\n if ('_support' in driverObject) {\n if (driverObject._support && typeof driverObject._support === 'function') {\n driverObject._support().then(setDriverSupport, reject);\n } else {\n setDriverSupport(!!driverObject._support);\n }\n } else {\n setDriverSupport(true);\n }\n } catch (e) {\n reject(e);\n }\n });\n\n executeTwoCallbacks(promise, callback, errorCallback);\n return promise;\n };\n\n LocalForage.prototype.driver = function driver() {\n return this._driver || null;\n };\n\n LocalForage.prototype.getDriver = function getDriver(driverName, callback, errorCallback) {\n var getDriverPromise = DefinedDrivers[driverName] ? Promise$1.resolve(DefinedDrivers[driverName]) : Promise$1.reject(new Error('Driver not found.'));\n\n executeTwoCallbacks(getDriverPromise, callback, errorCallback);\n return getDriverPromise;\n };\n\n LocalForage.prototype.getSerializer = function getSerializer(callback) {\n var serializerPromise = Promise$1.resolve(localforageSerializer);\n executeTwoCallbacks(serializerPromise, callback);\n return serializerPromise;\n };\n\n LocalForage.prototype.ready = function ready(callback) {\n var self = this;\n\n var promise = self._driverSet.then(function () {\n if (self._ready === null) {\n self._ready = self._initDriver();\n }\n\n return self._ready;\n });\n\n executeTwoCallbacks(promise, callback, callback);\n return promise;\n };\n\n LocalForage.prototype.setDriver = function setDriver(drivers, callback, errorCallback) {\n var self = this;\n\n if (!isArray(drivers)) {\n drivers = [drivers];\n }\n\n var supportedDrivers = this._getSupportedDrivers(drivers);\n\n function setDriverToConfig() {\n self._config.driver = self.driver();\n }\n\n function extendSelfWithDriver(driver) {\n self._extend(driver);\n setDriverToConfig();\n\n self._ready = self._initStorage(self._config);\n return self._ready;\n }\n\n function initDriver(supportedDrivers) {\n return function () {\n var currentDriverIndex = 0;\n\n function driverPromiseLoop() {\n while (currentDriverIndex < supportedDrivers.length) {\n var driverName = supportedDrivers[currentDriverIndex];\n currentDriverIndex++;\n\n self._dbInfo = null;\n self._ready = null;\n\n return self.getDriver(driverName).then(extendSelfWithDriver)[\"catch\"](driverPromiseLoop);\n }\n\n setDriverToConfig();\n var error = new Error('No available storage method found.');\n self._driverSet = Promise$1.reject(error);\n return self._driverSet;\n }\n\n return driverPromiseLoop();\n };\n }\n\n // There might be a driver initialization in progress\n // so wait for it to finish in order to avoid a possible\n // race condition to set _dbInfo\n var oldDriverSetDone = this._driverSet !== null ? this._driverSet[\"catch\"](function () {\n return Promise$1.resolve();\n }) : Promise$1.resolve();\n\n this._driverSet = oldDriverSetDone.then(function () {\n var driverName = supportedDrivers[0];\n self._dbInfo = null;\n self._ready = null;\n\n return self.getDriver(driverName).then(function (driver) {\n self._driver = driver._driver;\n setDriverToConfig();\n self._wrapLibraryMethodsWithReady();\n self._initDriver = initDriver(supportedDrivers);\n });\n })[\"catch\"](function () {\n setDriverToConfig();\n var error = new Error('No available storage method found.');\n self._driverSet = Promise$1.reject(error);\n return self._driverSet;\n });\n\n executeTwoCallbacks(this._driverSet, callback, errorCallback);\n return this._driverSet;\n };\n\n LocalForage.prototype.supports = function supports(driverName) {\n return !!DriverSupport[driverName];\n };\n\n LocalForage.prototype._extend = function _extend(libraryMethodsAndProperties) {\n extend(this, libraryMethodsAndProperties);\n };\n\n LocalForage.prototype._getSupportedDrivers = function _getSupportedDrivers(drivers) {\n var supportedDrivers = [];\n for (var i = 0, len = drivers.length; i < len; i++) {\n var driverName = drivers[i];\n if (this.supports(driverName)) {\n supportedDrivers.push(driverName);\n }\n }\n return supportedDrivers;\n };\n\n LocalForage.prototype._wrapLibraryMethodsWithReady = function _wrapLibraryMethodsWithReady() {\n // Add a stub for each driver API method that delays the call to the\n // corresponding driver method until localForage is ready. These stubs\n // will be replaced by the driver methods as soon as the driver is\n // loaded, so there is no performance impact.\n for (var i = 0, len = LibraryMethods.length; i < len; i++) {\n callWhenReady(this, LibraryMethods[i]);\n }\n };\n\n LocalForage.prototype.createInstance = function createInstance(options) {\n return new LocalForage(options);\n };\n\n return LocalForage;\n}();\n\n// The actual localForage object that we expose as a module or via a\n// global. It's extended by pulling in one of our other libraries.\n\n\nvar localforage_js = new LocalForage();\n\nmodule.exports = localforage_js;\n\n},{\"3\":3}]},{},[4])(4)\n});\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/localforage/dist/localforage.js\n// module id = 3\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport WeightDecoderEightbit from \"./weight_decoder_eightbit\";\nimport WeightDecoderRaw from \"./weight_decoder_raw\";\n/**\n * @protected\n */\nexport default function getWeightDecoder(name) {\n switch (name) {\n case 'raw':\n return new WeightDecoderRaw();\n case 'eightbit':\n return new WeightDecoderEightbit();\n default:\n throw new Error('Unknown weight encoding');\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/get_weight_decoder.js\n// module id = 4\n// module chunks = 0","/**\n * @module webdnn\n */\n/**\n * PlaceholderContext manages the placeholders\n * @protected\n */\nexport default class PlaceholderContext {\n constructor(values) {\n this.values = {};\n if (values) {\n this.update(values);\n }\n }\n get isResolved() {\n return Object.values(this.values).every(value => typeof value == 'number');\n }\n update(values) {\n this.values = Object.assign(this.values, values);\n }\n resolve(placeholder) {\n // Literal value => return itself.\n if (typeof placeholder !== 'object')\n return placeholder;\n // Placeholder object ( { eval: string } ) => resolve\n if (Object.keys(placeholder).length == 1 && 'eval' in placeholder) {\n if (!this.isResolved)\n throw Error(`Not all placeholders are resolved: ${this}`);\n return eval('(function(placeholders){return ' + placeholder.eval + ';})')(this.values);\n }\n // Array => deep copy\n if (placeholder instanceof Array) {\n return placeholder.map((value) => this.resolve(value));\n }\n // Object => deep copy\n return Object.entries(placeholder)\n .reduce((result, [key, value]) => {\n result[key] = this.resolve(value);\n return result;\n }, {});\n }\n toString() {\n return JSON.stringify(this.values);\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/placeholder.js\n// module id = 5\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport { SymbolicTypedArray } from \"./symbolic_typed_array\";\n/**\n * Typed array used for input and output variables of [[webdnn.DescriptorRunner| `DescriptorRunner`]].\n * You can use `SymbolicFloat32Array` almost as same as `Float32Array`.\n *\n * To convert `SymbolicFloat32Array` into actual `Float32Array`, use [[webdnn.SymbolicFloat32Array.toActual| `toActual()`]]\n *\n * ```js\n *\n * let result = runner.outputs[0]; //runner.outputs is array of SymbolicFloat32Array\n *\n * // SymbolicFloat32Array does NOT support index access\n * console.log(result[0]);\n * >>> undefined\n *\n * // By conversion, you can access each element by index\n * console.log(result.toActual()[0]);\n * >>> 1.00 // Actual result\n * ```\n */\nexport default class SymbolicFloat32Array extends SymbolicTypedArray {\n constructor() {\n super(...arguments);\n /**\n * The size in bytes of each element in the array.\n */\n this.BYTES_PER_ELEMENT = 4;\n }\n /**\n * Convert SymbolicTypedArray instance into actual TypedArray instance.\n *\n * @returns actual typed array\n */\n toActual() {\n if (!this.buffer) {\n throw new Error('Internal buffer for this variable is not set. DescriptorRunner.setPlaceholderValue() have to be called before calling this function.');\n }\n return new Float32Array(this.buffer, this.byteOffset, this.length);\n }\n /**\n * Determines whether all the members of an array satisfy the specified test.\n * @param callbackfn A function that accepts up to three arguments. The every method calls\n * the callbackfn function for each element in array1 until the callbackfn returns false,\n * or until the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n every(callbackfn, thisArg) {\n return this.toActual().every(callbackfn, thisArg);\n }\n /**\n * Returns the elements of an array that meet the condition specified in a callback function.\n * @param callbackfn A function that accepts up to three arguments. The filter method calls\n * the callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n filter(callbackfn, thisArg) {\n return this.toActual().filter(callbackfn, thisArg);\n }\n /**\n * Returns the value of the first element in the array where predicate is true, and undefined\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found, find\n * immediately returns that element value. Otherwise, find returns undefined.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n find(predicate, thisArg) {\n return this.toActual().find(predicate, thisArg);\n }\n /**\n * Returns the index of the first element in the array where predicate is true, and -1\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found,\n * findIndex immediately returns that element index. Otherwise, findIndex returns -1.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n findIndex(predicate, thisArg) {\n return this.toActual().findIndex(predicate, thisArg);\n }\n /**\n * Performs the specified action for each element in an array.\n * @param callbackfn A function that accepts up to three arguments. forEach calls the\n * callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n forEach(callbackfn, thisArg) {\n return this.toActual().forEach(callbackfn, thisArg);\n }\n /**\n * Calls a defined callback function on each element of an array, and returns an array that\n * contains the results.\n * @param callbackfn A function that accepts up to three arguments. The map method calls the\n * callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n map(callbackfn, thisArg) {\n return this.toActual().map(callbackfn, thisArg);\n }\n reduce(callbackfn, initialValue) {\n return this.toActual().reduce(callbackfn, initialValue);\n }\n reduceRight(callbackfn, initialValue) {\n return this.toActual().reduceRight(callbackfn, initialValue);\n }\n /**\n * Reverses the elements in an Array.\n */\n reverse() {\n return this.toActual().reverse();\n }\n /**\n * Returns a section of an array.\n * @param start The beginning of the specified portion of the array.\n * @param end The end of the specified portion of the array.\n */\n slice(start, end) {\n return this.toActual().slice(start, end);\n }\n /**\n * Determines whether the specified callback function returns true for any element of an array.\n * @param callbackfn A function that accepts up to three arguments. The some method calls the\n * callbackfn function for each element in array1 until the callbackfn returns true, or until\n * the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n some(callbackfn, thisArg) {\n return this.toActual().some(callbackfn, thisArg);\n }\n /**\n * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements\n * at begin, inclusive, up to end, exclusive.\n * @param begin The index of the beginning of the array.\n * @param end The index of the end of the array.\n */\n subarray(begin, end) {\n return this.toActual().subarray(begin, end);\n }\n /** @protected */\n includes(searchElement, fromIndex) {\n return this.toActual().includes(searchElement, fromIndex);\n }\n}\n/**\n * The size in bytes of each element in SymbolicFloat32Array.\n */\nSymbolicFloat32Array.BYTES_PER_ELEMENT = 4;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/symbolic_typed_array/symbolic_float32array.js\n// module id = 6\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\n/**\n * `DescriptorRunner` provides interface to execute DNN model and access input and output buffers.\n */\nexport class DescriptorRunner {\n constructor() {\n /**\n * For Developer:\n *\n * `DescriptorRunner` executes computation based on `GraphDescriptor`.\n *\n * Typically, DescriptorRunner takes 3 steps to execute DNN model.\n *\n * 1. Initialize static configurations\n *\n * Initialize things independent from runtime configuration.\n *\n * - `init()`\n * - `load()`\n *\n * 2. Initialize dynamic configurations\n *\n * Initialize things depend on runtime configuration such as batch size, input image size, etc.\n *\n * - `setPlaceholderValue()`\n * - `getInputViews()`\n * - `getOutputViews()`\n *\n * 3. Execute the model\n *\n * - `run()`\n *\n * You need to do step 1 and 2 only once. We recommend to call `WebDNN.prepareAll()` instead\n * to call `GraphDescriptor#load()` directly. In that method, all procedures in step 1 and 2 are performed.\n */\n /**\n * The descriptor\n */\n this.descriptor = null;\n }\n /**\n * Return `true` if this backend is available in this environment.\n * @returns {boolean}\n */\n static checkAvailability() {\n return false;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner.js\n// module id = 7\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/messages.js\n// module id = 8\n// module chunks = 0","'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It isn't worth it to make additional optimizations as in original.\n// Small size is preferable.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n\nmodule.exports = adler32;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/adler32.js\n// module id = 9\n// module chunks = 0","'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n\nmodule.exports = crc32;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/crc32.js\n// module id = 10\n// module chunks = 0","// String encode/decode helpers\n'use strict';\n\n\nvar utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safari\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new utils.Buf8(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nexports.string2buf = function (str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new utils.Buf8(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n};\n\n// Helper (used in 2 places)\nfunction buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert byte array to binary string\nexports.buf2binstring = function (buf) {\n return buf2binstring(buf, buf.length);\n};\n\n\n// Convert binary string (typed, when possible)\nexports.binstring2buf = function (str) {\n var buf = new utils.Buf8(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n};\n\n\n// convert array to string\nexports.buf2string = function (buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n};\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nexports.utf8border = function (buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/utils/strings.js\n// module id = 11\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\nmodule.exports = ZStream;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/zstream.js\n// module id = 12\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n //Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/constants.js\n// module id = 13\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\n/// \nimport { getConfiguration } from \"./webdnn\";\n/**\n * @protected\n */\nexport function isWebGL2(gl) {\n return gl.constructor.name === 'WebGL2RenderingContext';\n}\n/**\n * @private\n */\nlet instance;\n/**\n * @protected\n */\nexport default class WebGLHandler {\n /**\n * WebGLHandler is singleton class and instantiate directly is forbidden (constructor is hidden).\n *\n * Since the number of GPU contexts may be limited, the handler is used as a singleton\n * and only one context is shared among multiple runners.\n */\n constructor() {\n this.gl = checkNull(WebGLHandler.initializeContext());\n }\n static getInstance() {\n if (!instance)\n instance = new WebGLHandler();\n return instance;\n }\n createTexture(textureWidth, textureHeight, internalFormat, format) {\n let gl = this.gl;\n let texture = checkNull(gl.createTexture());\n gl.activeTexture(gl.TEXTURE0 + 9); // TODO: texture unit 9 is always available?\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, textureWidth, textureHeight, 0, format, gl.FLOAT, null);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n gl.bindTexture(gl.TEXTURE_2D, null);\n return texture;\n }\n createVertexShader(source) {\n return this.createShader(this.gl.VERTEX_SHADER, source);\n }\n createFragmentShader(source) {\n return this.createShader(this.gl.FRAGMENT_SHADER, source);\n }\n createShader(type, source) {\n let shader = checkNull(this.gl.createShader(type));\n this.gl.shaderSource(shader, source);\n this.gl.compileShader(shader);\n if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {\n console.error(this.gl.getShaderInfoLog(shader));\n throw Error(\"Shader Compile failed: \" + this.gl.getShaderInfoLog(shader));\n }\n return shader;\n }\n createProgram(vertexShader, fragmentShader) {\n let program = checkNull(this.gl.createProgram());\n this.gl.attachShader(program, fragmentShader);\n this.gl.attachShader(program, vertexShader);\n this.gl.linkProgram(program);\n if (!this.gl.getProgramParameter(program, this.gl.LINK_STATUS)) {\n console.error(this.gl.getProgramInfoLog(program));\n throw Error('ShaderProgram Initialization failed.');\n }\n return program;\n }\n createArrayBuffer(vertexArray) {\n let buffer = checkNull(this.gl.createBuffer());\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, vertexArray, this.gl.STATIC_DRAW);\n return buffer;\n }\n createFrameBuffer() {\n return checkNull(this.gl.createFramebuffer());\n }\n bindArrayBuffer(buffer) {\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, buffer);\n }\n bindFrameBuffer(frameBuffer, width, height) {\n this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, frameBuffer);\n this.gl.viewport(0, 0, width, height);\n this.gl.scissor(0, 0, width, height);\n }\n useProgram(program) {\n this.gl.useProgram(program);\n }\n deleteTexture(texture) {\n this.gl.deleteTexture(texture);\n }\n static initializeWebGL2Context(canvas = document.createElement('canvas')) {\n let gl;\n gl = (canvas.getContext('webgl2'));\n if (!gl)\n return null;\n if (!gl.getExtension('EXT_color_buffer_float'))\n return null;\n if (getConfiguration('DEBUG', false) && !gl.getExtension('WEBGL_debug_renderer_info'))\n return null;\n return gl;\n }\n static initializeWebGL1Context(canvas = document.createElement('canvas')) {\n let gl = (canvas.getContext('webgl') || canvas.getContext('experimental-webgl'));\n if (!gl)\n return null;\n if (!gl.getExtension('OES_texture_float'))\n return null;\n if (WebGLHandler.IS_SAFARI) {\n //TODO(Kiikurage)\n // Safari supports WebGL with OES_TEXTURE_FLOAT extension. However,\n // currently when WebGLRenderingContext#readPixels is called, an error is thrown.\n return null;\n }\n if (getConfiguration('DEBUG', false) && !gl.getExtension('WEBGL_debug_renderer_info'))\n return null;\n return gl;\n }\n static initializeContext() {\n let canvas = document.createElement('canvas');\n let gl;\n gl = WebGLHandler.initializeWebGL2Context(canvas);\n if (gl) {\n if (getConfiguration('DEBUG', false))\n console.info('WebGL2 is enabled');\n }\n else {\n gl = WebGLHandler.initializeWebGL1Context(canvas);\n if (gl) {\n if (getConfiguration('DEBUG', false))\n console.info('WebGL2 is disabled');\n }\n else {\n return null;\n }\n }\n gl.disable(gl.DEPTH_TEST);\n gl.disable(gl.STENCIL_TEST);\n gl.disable(gl.BLEND);\n gl.disable(gl.DITHER);\n gl.disable(gl.POLYGON_OFFSET_FILL);\n gl.disable(gl.SAMPLE_COVERAGE);\n gl.enable(gl.SCISSOR_TEST);\n gl.enable(gl.CULL_FACE);\n gl.cullFace(gl.BACK);\n return gl;\n }\n /**\n * Check whether WebGL is supported or not\n * @protected\n */\n static checkAvailability() {\n if (availability === null) {\n let gl = WebGLHandler.initializeContext();\n if (!gl) {\n availability = false;\n }\n else if (getConfiguration('MAX_TEXTURE_SIZE', gl.getParameter(gl.MAX_TEXTURE_SIZE)) < 4096) {\n availability = false;\n }\n else {\n availability = true;\n }\n }\n return availability;\n }\n async waitForComplete() {\n let gl = this.gl;\n if (isWebGL2(gl)) {\n let sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);\n let status = gl.clientWaitSync(sync, 0, 0);\n while (status !== gl.CONDITION_SATISFIED && status !== gl.ALREADY_SIGNALED) {\n await new Promise(r => setTimeout(r, 1));\n status = gl.clientWaitSync(sync, 0, 0);\n }\n gl.deleteSync(sync);\n }\n else {\n gl.finish();\n }\n }\n get MAX_TEXTURE_SIZE() {\n let MAX_TEXTURE_SIZE = getConfiguration('MAX_TEXTURE_SIZE', this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE));\n // FIXME: In most case, MAX_TEXTURE_SIZE=4096 is the fastest (Why?).\n if (MAX_TEXTURE_SIZE >= 16384) {\n return 4096;\n }\n else if (MAX_TEXTURE_SIZE >= 8192) {\n return 4096;\n }\n else if (MAX_TEXTURE_SIZE >= 4096) {\n return 4096;\n }\n else {\n throw new Error(`MAX_TEXTURE_SIZE is too small: ${MAX_TEXTURE_SIZE}`);\n }\n }\n}\nWebGLHandler.IS_SAFARI = navigator.userAgent.toLowerCase().indexOf('safari') !== -1 && navigator.userAgent.toLowerCase().indexOf('chrome') === -1;\n/**\n * @private\n */\nlet availability = null;\n/**\n * @private\n */\nfunction checkNull(obj) {\n if (obj === null)\n throw Error('Null is detected');\n return obj;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webgl_handler.js\n// module id = 14\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\n/**\n * Abstract buffer interface. Read/write transactions are regarded as asynchronous operation.\n *\n * @protected\n */\nexport class Buffer {\n constructor(byteLength, backend) {\n this.byteLength = byteLength;\n this.backend = backend;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer.js\n// module id = 15\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport WebGPUHandler from \"../webgpu_handler\";\nimport { Buffer } from \"./buffer\";\n/**\n * @protected\n */\nexport default class BufferWebGPU extends Buffer {\n constructor(byteLength) {\n super(byteLength, 'webgpu');\n if (byteLength == 0) {\n byteLength = 4; //0 length buffer causes error\n }\n this.handler = WebGPUHandler.getInstance();\n this.buffer = this.handler.createBuffer(new Uint8Array(byteLength));\n this.bufferView = new Uint8Array(this.buffer.contents);\n }\n // async: there may be platforms synchronization is needed before writing\n async write(src, dst_offset) {\n await this.handler.sync();\n let viewSameType = new src.constructor(this.bufferView.buffer);\n viewSameType.set(src, dst_offset);\n }\n async read(dst, src_offset = 0, length) {\n if (!dst)\n throw new Error('dst cannot be null');\n await this.handler.sync();\n if (this.byteLength === 0)\n return;\n let dstConstructor = dst.constructor;\n let viewSameType = new dstConstructor(this.bufferView.buffer, this.bufferView.byteOffset + src_offset * dstConstructor.BYTES_PER_ELEMENT, length);\n dst.set(viewSameType);\n return;\n }\n getWriteView(offset, length, type) {\n return new type(this.bufferView.buffer, this.bufferView.byteOffset + offset * type.BYTES_PER_ELEMENT, length);\n }\n getReadView(offset, length, type) {\n return new type(this.bufferView.buffer, this.bufferView.byteOffset + offset * type.BYTES_PER_ELEMENT, length);\n }\n async syncWriteViews() {\n // no sync needed\n }\n async syncReadViews() {\n // if the user awaits promise from final kernel execution, this function call is not needed.\n await this.handler.sync();\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer_webgpu.js\n// module id = 16\n// module chunks = 0","///\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport BufferWebGPU from \"./buffer/buffer_webgpu\";\n/**\n * @private\n */\nlet instance;\n/**\n * @protected\n */\nexport default class WebGPUHandler {\n /**\n * WebGPUHandler is singleton class and instantiate directly is forbidden (constructor is hidden).\n *\n * Since the number of GPU contexts may be limited, the handler is used as a singleton\n * and only one context is shared among multiple runners.\n */\n constructor() {\n this.pipelineStates = new Map();\n if (!IS_WEBGPU_SUPPORTED)\n throw new Error('This browser does not support WebGPU');\n let context;\n try {\n context = document.createElement('canvas').getContext('webgpu');\n }\n catch (err) {\n throw new Error(`During initializing WebGPURenderingContext, unexpected error is occurred: ${err.message}`);\n }\n if (!context)\n throw new Error('WebGPURenderingContext initialization failed');\n this.context = context;\n this.commandQueue = context.createCommandQueue();\n this.loadKernel('kernel void sync(){}', 'basic');\n }\n static getInstance() {\n if (!instance)\n instance = new WebGPUHandler();\n return instance;\n }\n createBuffer(arrayBuffer) {\n return this.context.createBuffer(arrayBuffer);\n }\n loadKernel(librarySource, namespace = '') {\n let library = this.context.createLibrary(librarySource);\n for (let name of library.functionNames) {\n let kernelFunction = library.functionWithName(name);\n let pipelineStates = this.context.createComputePipelineState(kernelFunction);\n this.pipelineStates.set(namespace + '.' + name, pipelineStates);\n }\n }\n createCommandBuffer() {\n return this.commandQueue.createCommandBuffer();\n }\n getPipelineStateByName(name) {\n let state = this.pipelineStates.get(name);\n if (!state) {\n throw TypeError(`Kernel function \"${name}\" is not loaded.`);\n }\n return state;\n }\n executeSinglePipelineState(name, threadgroupsPerGrid, threadsPerThreadgroup, buffers, getCompletedPromise) {\n let commandBuffer = this.commandBuffer || (this.commandBuffer = this.createCommandBuffer());\n let commandEncoder = commandBuffer.createComputeCommandEncoder();\n commandEncoder.setComputePipelineState(this.getPipelineStateByName(name));\n for (let i = 0; i < buffers.length; i++) {\n let buffer = buffers[i];\n let wgbuf;\n if (buffer instanceof BufferWebGPU) {\n wgbuf = buffer.buffer;\n }\n else {\n // cannot perform (buffer instanceof WebGPUBuffer) currently\n wgbuf = buffer;\n }\n commandEncoder.setBuffer(wgbuf, 0, i);\n }\n commandEncoder.dispatch(threadgroupsPerGrid, threadsPerThreadgroup);\n commandEncoder.endEncoding();\n let promise = null;\n if (getCompletedPromise) {\n promise = commandBuffer.completed;\n }\n this.commandBuffer = null;\n commandBuffer.commit();\n return promise;\n }\n async sync() {\n let commandBuffer = this.createCommandBuffer();\n let commandEncoder = commandBuffer.createComputeCommandEncoder();\n commandEncoder.setComputePipelineState(this.getPipelineStateByName('basic.sync'));\n commandEncoder.dispatch({\n width: 1,\n height: 1,\n depth: 1\n }, {\n width: 1,\n height: 1,\n depth: 1\n });\n commandEncoder.endEncoding();\n let promise = commandBuffer.completed;\n commandBuffer.commit();\n return promise;\n }\n}\n/**\n * Flag whether WebGPU is supported or not\n * @protected\n */\nexport const IS_WEBGPU_SUPPORTED = 'WebGPURenderingContext' in window && 'WebGPUComputeCommandEncoder' in window;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webgpu_handler.js\n// module id = 17\n// module chunks = 0","/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\n/**\n * The data order\n */\nexport var Order;\n(function (Order) {\n /** `[Channel, Height, Width]` format */\n Order[Order[\"CHW\"] = 0] = \"CHW\";\n /** `[Height, Width, Channel]` format */\n Order[Order[\"HWC\"] = 1] = \"HWC\";\n})(Order || (Order = {}));\n/**\n * The color format\n */\nexport var Color;\n(function (Color) {\n /** RGB format */\n Color[Color[\"RGB\"] = 0] = \"RGB\";\n /** BGR format */\n Color[Color[\"BGR\"] = 1] = \"BGR\";\n /** grey scale */\n Color[Color[\"GREY\"] = 2] = \"GREY\";\n /** RGBA format */\n Color[Color[\"RGBA\"] = 3] = \"RGBA\";\n /** BGRA format */\n Color[Color[\"BGRA\"] = 4] = \"BGRA\";\n})(Color || (Color = {}));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/enums.js\n// module id = 18\n// module chunks = 0","/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\n/**\n * Get canvas rendering context and check whether it is nonnull value.\n *\n * @param {CanvasRenderingContext2D} canvas\n * @protected\n */\nexport function getContext2D(canvas) {\n let context = canvas.getContext('2d');\n if (!context)\n throw Error('CanvasRenderingContext2D initialization failed');\n return context;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/canvas.js\n// module id = 19\n// module chunks = 0","/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\n/**\n * Load image of specified url\n *\n * @param {string} url the image url\n * @returns {Promise} image element\n */\nexport async function loadImageByUrl(url) {\n let image = document.createElement('img');\n return new Promise((resolve, reject) => {\n image.onload = resolve;\n image.onerror = reject;\n image.src = url;\n })\n .then(() => image);\n}\n/* istanbul ignore next */\n/**\n * Load image file selected in `` element.\n *\n * @param {HTMLInputElement} input the `` element\n * @returns {Promise} image element\n */\nexport async function loadImageFromFileInput(input) {\n let files = input.files;\n if (!files || files.length == 0)\n throw new Error('No file is selected');\n let url = URL.createObjectURL(files[0]);\n return loadImageByUrl(url);\n}\n/* istanbul ignore next */\n/**\n * Load image selected in file picker dialog\n *\n * Currently, web specification not supported the case if the dialog is canceled and no file is selected. In this case,\n * the returned promise will never be resolved.\n *\n * @returns {Promise} image element\n * @protected\n */\nexport async function loadImageByDialog() {\n let input = document.createElement('input');\n input.type = 'file';\n input.accept = 'image/*';\n return new Promise((resolve) => {\n input.onchange = () => resolve(loadImageFromFileInput(input));\n input.click();\n });\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_source.js\n// module id = 20\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport * as localforage from \"localforage\";\nimport get_weight_decoder from \"../decoder/get_weight_decoder\";\nimport webdnnFetch, { readArrayBufferProgressively, transformUrl } from \"../fetch\";\nimport PlaceholderContext from \"../placeholder\";\nimport SymbolicFloat32Array from \"../symbolic_typed_array/symbolic_float32array\";\nimport { DescriptorRunner } from \"./descriptor_runner\";\n/**\n * @private\n */\nfunction wait(duration = 10) {\n // let console.log to be displayed, and prevent freeze\n return new Promise(resolve => setTimeout(resolve, duration));\n}\n/**\n * @protected\n */\nexport default class DescriptorRunnerFallback extends DescriptorRunner {\n constructor() {\n super(...arguments);\n this.backendName = 'fallback';\n }\n static checkAvailability() {\n return true;\n }\n async init() {\n //nothing to do\n }\n async setDescriptorAndParameters(descriptor, parameters) {\n this.setDescriptor(descriptor);\n await this.compile();\n await this.initializeStaticBuffer(parameters);\n if (this.placeholderContext && this.placeholderContext.isResolved)\n await this.initializeDynamicBuffer();\n }\n async fetchDescriptor(directory) {\n this.directory = directory;\n let res = await webdnnFetch(`${directory}/graph_${this.backendName}.json`);\n return res.json();\n }\n async fetchParameters(directory, progressCallback) {\n let res = await webdnnFetch(`${directory}/weight_${this.backendName}.bin`);\n return readArrayBufferProgressively(res, progressCallback);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedDescriptor(directory) {\n return localforage.getItem(`${directory}_${this.backendName}_descriptor`).catch(() => null);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedParameters(directory, progressCallback) {\n let parameter = await localforage.getItem(`${directory}_${this.backendName}_parameters`).catch(() => null);\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return parameter;\n }\n /**\n * save cache\n */\n async saveCache(directory, descriptor, parameters) {\n await Promise.all([\n localforage.setItem(`${directory}_${this.backendName}_descriptor`, descriptor),\n localforage.setItem(`${directory}_${this.backendName}_parameters`, parameters)\n ]);\n }\n ;\n setDescriptor(descriptor) {\n this.descriptor = descriptor;\n // reset\n this.placeholderContext = new PlaceholderContext();\n this.placeholderContext.update(descriptor.placeholders);\n this.kernelObj = null;\n this.variableMap = null;\n this.staticBuffer = null;\n this.dynamicBuffer = null;\n }\n async compile() {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n await new Promise((resolve) => {\n let script = document.createElement(\"script\");\n script.type = \"text/javascript\";\n if (script.readyState) {\n script.onreadystatechange = () => {\n if (script.readyState == \"loaded\" || script.readyState == \"complete\") {\n script.onreadystatechange = null;\n resolve();\n }\n };\n }\n else {\n script.onload = resolve;\n }\n script.src = transformUrl(`${this.directory}/kernels_fallback.js`);\n document.getElementsByTagName(\"head\")[0].appendChild(script);\n });\n this.kernelObj = window.dnn_fallback_kernel; // \"window.dnn_fallback_kernel\" is defined in \"kernels_fallback.js\"\n }\n async initializeStaticBuffer(weightRawArray) {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n let descriptor = this.descriptor;\n let staticBuffer = new Float32Array(descriptor.memory_layout.static.size);\n this.staticBuffer = staticBuffer;\n let variableMap = this.variableMap || new Map();\n this.variableMap = variableMap;\n Object.entries(descriptor.memory_layout.static.allocations)\n .forEach(([name, allocation]) => {\n variableMap.set(name, new Float32Array(staticBuffer.buffer, allocation.offset * Float32Array.BYTES_PER_ELEMENT, allocation.size));\n });\n let decoder = get_weight_decoder(this.descriptor.weight_encoding);\n staticBuffer.set(await decoder.decode(new Uint8Array(weightRawArray)));\n (await this.getInputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = staticBuffer.buffer;\n });\n (await this.getOutputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = staticBuffer.buffer;\n });\n }\n async initializeDynamicBuffer() {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n let dynamicBuffer = new Float32Array(placeholderContext.resolve(descriptor.memory_layout.dynamic.size));\n this.dynamicBuffer = dynamicBuffer;\n let variableMap = this.variableMap || new Map();\n this.variableMap = variableMap;\n Object.entries(descriptor.memory_layout.dynamic.allocations)\n .forEach(([name, allocation]) => {\n variableMap.set(name, new Float32Array(dynamicBuffer.buffer, placeholderContext.resolve(allocation.offset) * Float32Array.BYTES_PER_ELEMENT, placeholderContext.resolve(allocation.size)));\n });\n (await this.getInputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = dynamicBuffer.buffer;\n });\n (await this.getOutputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = dynamicBuffer.buffer;\n });\n }\n async setPlaceholderValue(values) {\n if (!this.placeholderContext)\n throw new Error('placeholderContext is not initialized');\n let placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return;\n await this.initializeDynamicBuffer();\n }\n async run() {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('placeholderContext is not initialized');\n if (!this.variableMap)\n throw new Error('Variable map is not initialized');\n if (!this.staticBuffer)\n throw new Error('StaticBuffer map is not initialized');\n if (!this.dynamicBuffer)\n throw new Error('DynamicBuffer map is not initialized');\n let variableMap = this.variableMap;\n let placeholderContext = this.placeholderContext;\n let executionInfos = this.descriptor.exec_infos\n .map(executionInfo => placeholderContext.resolve(executionInfo));\n let startDate = Date.now();\n let lastDate = Date.now();\n for (let i = 0; i < executionInfos.length; i++) {\n let currentDate = Date.now();\n if (currentDate - lastDate >= 1000) {\n console.log(`Processed ${i}/${executionInfos.length} kernels in ${currentDate - startDate} ms`);\n lastDate = currentDate;\n await wait();\n }\n let executionInfo = executionInfos[i];\n let inputs = executionInfo.inputs.map((name) => variableMap.get(name));\n let outputs = executionInfo.outputs.map((name) => variableMap.get(name));\n this.kernelObj[executionInfo.entry_func_name](inputs, outputs, executionInfo.call_option);\n }\n console.log(`Processed ${executionInfos.length}/${executionInfos.length} kernels in ${Date.now() - startDate} ms`);\n }\n getInputViews() {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, allocation.offset * SymbolicFloat32Array.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n }\n getOutputViews() {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, allocation.offset * SymbolicFloat32Array.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_fallback.js\n// module id = 21\n// module chunks = 0","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 22\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport * as pako from \"pako\";\n/**\n * @protected\n */\nexport default class WeightDecoderEightbit {\n async decode(data) {\n // FIXME: store decoded total size in 'data'\n // currently, decoding each block and concatenating them at the end are needed.\n let decoded_arrays = [];\n let total_dst_length = 0;\n let data_view = new DataView(data.buffer, data.byteOffset);\n let src_offset = 0;\n while (src_offset < data.length) {\n let dst_offset = data_view.getInt32(src_offset, true);\n src_offset += 4;\n let body_size = data_view.getInt32(src_offset, true);\n src_offset += 4;\n let scale = data_view.getFloat32(src_offset, true);\n src_offset += 8;\n let scaled_table = new Float32Array(256);\n for (let i = 0; i < 256; i++) {\n scaled_table[i] = WeightDecoderEightbit.decode_table[i & 0x7F] * scale * (i < 128 ? 1.0 : -1.0);\n }\n // do decode\n let src_data_view = new Uint8Array(data.buffer, data.byteOffset + src_offset, body_size);\n let decompressed = pako.inflate(src_data_view);\n let dec_size = decompressed.length;\n let decoded_array = new Float32Array(dec_size);\n for (let s = 0; s < dec_size; s++) {\n decoded_array[s] = scaled_table[decompressed[s]];\n }\n decoded_arrays.push(decoded_array);\n total_dst_length += dec_size;\n src_offset += body_size;\n }\n let dst = new Float32Array(total_dst_length);\n let dst_offset = 0;\n for (let i = 0; i < decoded_arrays.length; i++) {\n dst.set(decoded_arrays[i], dst_offset);\n dst_offset += decoded_arrays[i].length;\n }\n return dst;\n }\n}\nWeightDecoderEightbit.decode_table = [0.0, 2.750000021e-06, 7.249999726e-06, 1.875000089e-05, 3.624999954e-05, 5.874999624e-05, 8.624999464e-05,\n 1.437500032e-04, 2.312500001e-04, 3.187500115e-04, 4.062500084e-04, 5.187499919e-04, 6.562499912e-04,\n 7.937499322e-04, 9.312499315e-04, 1.218750025e-03, 1.656249980e-03, 2.093750052e-03, 2.531250007e-03,\n 2.968749963e-03, 3.406249918e-03, 3.843750106e-03, 4.281249829e-03, 4.843750037e-03, 5.531250034e-03,\n 6.218749564e-03, 6.906249560e-03, 7.593749557e-03, 8.281249553e-03, 8.968749084e-03, 9.656248614e-03,\n 1.109374966e-02, 1.328125037e-02, 1.546875015e-02, 1.765624993e-02, 1.984374970e-02, 2.203124948e-02,\n 2.421874925e-02, 2.640625089e-02, 2.859375067e-02, 3.078125045e-02, 3.296874836e-02, 3.515625000e-02,\n 3.734375164e-02, 3.953124955e-02, 4.171875119e-02, 4.390624911e-02, 4.671875015e-02, 5.015625060e-02,\n 5.359374732e-02, 5.703124776e-02, 6.046874821e-02, 6.390624493e-02, 6.734374911e-02, 7.078124583e-02,\n 7.421874255e-02, 7.765624672e-02, 8.109374344e-02, 8.453124017e-02, 8.796874434e-02, 9.140624106e-02,\n 9.484373778e-02, 9.828124195e-02, 1.054687500e-01, 1.164062470e-01, 1.273437440e-01, 1.382812560e-01,\n 1.492187530e-01, 1.601562500e-01, 1.710937470e-01, 1.820312440e-01, 1.929687560e-01, 2.039062530e-01,\n 2.148437500e-01, 2.257812470e-01, 2.367187440e-01, 2.476562560e-01, 2.585937381e-01, 2.695312500e-01,\n 2.804687619e-01, 2.914062440e-01, 3.023437560e-01, 3.132812381e-01, 3.242187500e-01, 3.351562619e-01,\n 3.460937440e-01, 3.570312560e-01, 3.679687381e-01, 3.789062500e-01, 3.898437619e-01, 4.007812440e-01,\n 4.117187560e-01, 4.226562381e-01, 4.335937500e-01, 4.445312619e-01, 4.585937560e-01, 4.757812321e-01,\n 4.929687381e-01, 5.101562142e-01, 5.273437500e-01, 5.445312262e-01, 5.617187023e-01, 5.789062381e-01,\n 5.960937142e-01, 6.132812500e-01, 6.304687262e-01, 6.476562023e-01, 6.648437381e-01, 6.820312142e-01,\n 6.992186904e-01, 7.164062262e-01, 7.335937023e-01, 7.507811785e-01, 7.679687142e-01, 7.851561904e-01,\n 8.023436666e-01, 8.195312023e-01, 8.367186785e-01, 8.539061546e-01, 8.710936904e-01, 8.882811666e-01,\n 9.054686427e-01, 9.226561785e-01, 9.398436546e-01, 9.570311308e-01, 9.742186666e-01, 9.914061427e-01, 1.0,\n];\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/weight_decoder_eightbit.js\n// module id = 23\n// module chunks = 0","// Top level file is just a mixin of submodules & constants\n'use strict';\n\nvar assign = require('./lib/utils/common').assign;\n\nvar deflate = require('./lib/deflate');\nvar inflate = require('./lib/inflate');\nvar constants = require('./lib/zlib/constants');\n\nvar pako = {};\n\nassign(pako, deflate, inflate, constants);\n\nmodule.exports = pako;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/index.js\n// module id = 24\n// module chunks = 0","'use strict';\n\n\nvar zlib_deflate = require('./zlib/deflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\n\nvar toString = Object.prototype.toString;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nvar Z_NO_FLUSH = 0;\nvar Z_FINISH = 4;\n\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_SYNC_FLUSH = 2;\n\nvar Z_DEFAULT_COMPRESSION = -1;\n\nvar Z_DEFAULT_STRATEGY = 0;\n\nvar Z_DEFLATED = 8;\n\n/* ===========================================================================*/\n\n\n/**\n * class Deflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[deflate]],\n * [[deflateRaw]] and [[gzip]].\n **/\n\n/* internal\n * Deflate.chunks -> Array\n *\n * Chunks of output data, if [[Deflate#onData]] not overridden.\n **/\n\n/**\n * Deflate.result -> Uint8Array|Array\n *\n * Compressed result, generated by default [[Deflate#onData]]\n * and [[Deflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Deflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Deflate.err -> Number\n *\n * Error code after deflate finished. 0 (Z_OK) on success.\n * You will not need it in real life, because deflate errors\n * are possible only on wrong options or bad `onData` / `onEnd`\n * custom handlers.\n **/\n\n/**\n * Deflate.msg -> String\n *\n * Error message, if [[Deflate.err]] != 0\n **/\n\n\n/**\n * new Deflate(options)\n * - options (Object): zlib deflate options.\n *\n * Creates new deflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `level`\n * - `windowBits`\n * - `memLevel`\n * - `strategy`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw deflate\n * - `gzip` (Boolean) - create gzip wrapper\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n * - `header` (Object) - custom header for gzip\n * - `text` (Boolean) - true if compressed data believed to be text\n * - `time` (Number) - modification time, unix timestamp\n * - `os` (Number) - operation system code\n * - `extra` (Array) - array of bytes with extra data (max 65536)\n * - `name` (String) - file name (binary string)\n * - `comment` (String) - comment (binary string)\n * - `hcrc` (Boolean) - true if header crc should be added\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var deflate = new pako.Deflate({ level: 3});\n *\n * deflate.push(chunk1, false);\n * deflate.push(chunk2, true); // true -> last chunk\n *\n * if (deflate.err) { throw new Error(deflate.err); }\n *\n * console.log(deflate.result);\n * ```\n **/\nfunction Deflate(options) {\n if (!(this instanceof Deflate)) return new Deflate(options);\n\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n if (opt.raw && (opt.windowBits > 0)) {\n opt.windowBits = -opt.windowBits;\n }\n\n else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {\n opt.windowBits += 16;\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n\n if (opt.dictionary) {\n var dict;\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n // If we need to compress text, change encoding to utf8.\n dict = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n this._dict_set = true;\n }\n}\n\n/**\n * Deflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be\n * converted to utf8 byte sequence.\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with\n * new compressed chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the compression context.\n *\n * On fail call [[Deflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * array format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nDeflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var status, _mode;\n\n if (this.ended) { return false; }\n\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // If we need to compress text, change encoding to utf8.\n strm.input = strings.string2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_deflate.deflate(strm, _mode); /* no bad return value */\n\n if (status !== Z_STREAM_END && status !== Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {\n if (this.options.to === 'string') {\n this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH) {\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Deflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nDeflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Deflate#onEnd(status) -> Void\n * - status (Number): deflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called once after you tell deflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nDeflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * deflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * Compress `data` with deflate algorithm and `options`.\n *\n * Supported options are:\n *\n * - level\n * - windowBits\n * - memLevel\n * - strategy\n * - dictionary\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , data = Uint8Array([1,2,3,4,5,6,7,8,9]);\n *\n * console.log(pako.deflate(data));\n * ```\n **/\nfunction deflate(input, options) {\n var deflator = new Deflate(options);\n\n deflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (deflator.err) { throw deflator.msg || msg[deflator.err]; }\n\n return deflator.result;\n}\n\n\n/**\n * deflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate(input, options);\n}\n\n\n/**\n * gzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but create gzip wrapper instead of\n * deflate one.\n **/\nfunction gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate(input, options);\n}\n\n\nexports.Deflate = Deflate;\nexports.deflate = deflate;\nexports.deflateRaw = deflateRaw;\nexports.gzip = gzip;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/deflate.js\n// module id = 25\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar trees = require('./trees');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar msg = require('./messages');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\nvar Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\n//var Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\n//var Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\n//var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n\n/* compression levels */\n//var Z_NO_COMPRESSION = 0;\n//var Z_BEST_SPEED = 1;\n//var Z_BEST_COMPRESSION = 9;\nvar Z_DEFAULT_COMPRESSION = -1;\n\n\nvar Z_FILTERED = 1;\nvar Z_HUFFMAN_ONLY = 2;\nvar Z_RLE = 3;\nvar Z_FIXED = 4;\nvar Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\n//var Z_BINARY = 0;\n//var Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n/*============================================================================*/\n\n\nvar MAX_MEM_LEVEL = 9;\n/* Maximum value for memLevel in deflateInit2 */\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_MEM_LEVEL = 8;\n\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\nvar D_CODES = 30;\n/* number of distance codes */\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\nvar MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);\n\nvar PRESET_DICT = 0x20;\n\nvar INIT_STATE = 42;\nvar EXTRA_STATE = 69;\nvar NAME_STATE = 73;\nvar COMMENT_STATE = 91;\nvar HCRC_STATE = 103;\nvar BUSY_STATE = 113;\nvar FINISH_STATE = 666;\n\nvar BS_NEED_MORE = 1; /* block not completed, need more input or more output */\nvar BS_BLOCK_DONE = 2; /* block flush performed */\nvar BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */\nvar BS_FINISH_DONE = 4; /* finish done, accept no more input or output */\n\nvar OS_CODE = 0x03; // Unix :) . Don't detect, use this default.\n\nfunction err(strm, errorCode) {\n strm.msg = msg[errorCode];\n return errorCode;\n}\n\nfunction rank(f) {\n return ((f) << 1) - ((f) > 4 ? 9 : 0);\n}\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output goes\n * through this function so some applications may wish to modify it\n * to avoid allocating a large strm->output buffer and copying into it.\n * (See also read_buf()).\n */\nfunction flush_pending(strm) {\n var s = strm.state;\n\n //_tr_flush_bits(s);\n var len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) { return; }\n\n utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n}\n\n\nfunction flush_block_only(s, last) {\n trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n}\n\n\nfunction put_byte(s, b) {\n s.pending_buf[s.pending++] = b;\n}\n\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nfunction putShortMSB(s, b) {\n// put_byte(s, (Byte)(b >> 8));\n// put_byte(s, (Byte)(b & 0xff));\n s.pending_buf[s.pending++] = (b >>> 8) & 0xff;\n s.pending_buf[s.pending++] = b & 0xff;\n}\n\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read. All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->input buffer and copying from it.\n * (See also flush_pending()).\n */\nfunction read_buf(strm, buf, start, size) {\n var len = strm.avail_in;\n\n if (len > size) { len = size; }\n if (len === 0) { return 0; }\n\n strm.avail_in -= len;\n\n // zmemcpy(buf, strm->next_in, len);\n utils.arraySet(buf, strm.input, strm.next_in, len, start);\n if (strm.state.wrap === 1) {\n strm.adler = adler32(strm.adler, buf, len, start);\n }\n\n else if (strm.state.wrap === 2) {\n strm.adler = crc32(strm.adler, buf, len, start);\n }\n\n strm.next_in += len;\n strm.total_in += len;\n\n return len;\n}\n\n\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\nfunction longest_match(s, cur_match) {\n var chain_length = s.max_chain_length; /* max hash chain length */\n var scan = s.strstart; /* current string */\n var match; /* matched string */\n var len; /* length of current match */\n var best_len = s.prev_length; /* best match length so far */\n var nice_match = s.nice_match; /* stop if match long enough */\n var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?\n s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;\n\n var _win = s.window; // shortcut\n\n var wmask = s.w_mask;\n var prev = s.prev;\n\n /* Stop when cur_match becomes <= limit. To simplify the code,\n * we prevent matches with the string of window index 0.\n */\n\n var strend = s.strstart + MAX_MATCH;\n var scan_end1 = _win[scan + best_len - 1];\n var scan_end = _win[scan + best_len];\n\n /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n * It is easy to get rid of this optimization if necessary.\n */\n // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n /* Do not waste too much time if we already have a good match: */\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n /* Do not look for matches beyond the end of the input. This is necessary\n * to make deflate deterministic.\n */\n if (nice_match > s.lookahead) { nice_match = s.lookahead; }\n\n // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n do {\n // Assert(cur_match < s->strstart, \"no future\");\n match = cur_match;\n\n /* Skip to next match if the match length cannot increase\n * or if the match length is less than 2. Note that the checks below\n * for insufficient lookahead only occur occasionally for performance\n * reasons. Therefore uninitialized memory will be accessed, and\n * conditional jumps will be made that depend on those values.\n * However the length of the match is limited to the lookahead, so\n * the output of deflate is not affected by the uninitialized values.\n */\n\n if (_win[match + best_len] !== scan_end ||\n _win[match + best_len - 1] !== scan_end1 ||\n _win[match] !== _win[scan] ||\n _win[++match] !== _win[scan + 1]) {\n continue;\n }\n\n /* The check at best_len-1 can be removed because it will be made\n * again later. (This heuristic is not always a win.)\n * It is not necessary to compare scan[2] and match[2] since they\n * are always equal when the other bytes match, given that\n * the hash keys are equal and that HASH_BITS >= 8.\n */\n scan += 2;\n match++;\n // Assert(*scan == *match, \"match[2]?\");\n\n /* We check for insufficient lookahead only every 8th comparison;\n * the 256th check will be made at strstart+258.\n */\n do {\n /*jshint noempty:false*/\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n scan < strend);\n\n // Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n}\n\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n * At least one byte has been read, or avail_in == 0; reads are\n * performed for at least two bytes (required for the zip translate_eol\n * option -- not supported here).\n */\nfunction fill_window(s) {\n var _w_size = s.w_size;\n var p, n, m, more, str;\n\n //Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n do {\n more = s.window_size - s.lookahead - s.strstart;\n\n // JS ints have 32 bit, block below not needed\n /* Deal with !@#$% 64K limit: */\n //if (sizeof(int) <= 2) {\n // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n // more = wsize;\n //\n // } else if (more == (unsigned)(-1)) {\n // /* Very unlikely, but possible on 16 bit machine if\n // * strstart == 0 && lookahead == 1 (input done a byte at time)\n // */\n // more--;\n // }\n //}\n\n\n /* If the window is almost full and there is insufficient lookahead,\n * move the upper half to the lower one to make room in the upper half.\n */\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n\n utils.arraySet(s.window, s.window, _w_size, _w_size, 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n /* we now have strstart >= MAX_DIST */\n s.block_start -= _w_size;\n\n /* Slide the hash table (could be avoided with 32 bit values\n at the expense of memory usage). We slide even when level == 0\n to keep the hash table consistent if we switch back to level > 0\n later. (Using level 0 permanently is not an optimal usage of\n zlib, so we don't care about this pathological case.)\n */\n\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = (m >= _w_size ? m - _w_size : 0);\n } while (--n);\n\n n = _w_size;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = (m >= _w_size ? m - _w_size : 0);\n /* If n is not on any hash chain, prev[n] is garbage but\n * its value will never be used.\n */\n } while (--n);\n\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n\n /* If there was no sliding:\n * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n * more == window_size - lookahead - strstart\n * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n * => more >= window_size - 2*WSIZE + 2\n * In the BIG_MEM or MMAP case (not yet supported),\n * window_size == input_size + MIN_LOOKAHEAD &&\n * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n * Otherwise, window_size == 2*WSIZE so more >= 2.\n * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n */\n //Assert(more >= 2, \"more < 2\");\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n\n /* Initialize the hash value now that we have some input: */\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n\n /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;\n//#if MIN_MATCH != 3\n// Call update_hash() MIN_MATCH-3 more times\n//#endif\n while (s.insert) {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n * but this is not important since only literal bytes will be emitted.\n */\n\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n\n /* If the WIN_INIT bytes after the end of the current data have never been\n * written, then zero those bytes in order to avoid memory check reports of\n * the use of uninitialized (or uninitialised as Julian writes) bytes by\n * the longest match routines. Update the high water mark for the next\n * time through here. WIN_INIT is set to MAX_MATCH since the longest match\n * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n */\n// if (s.high_water < s.window_size) {\n// var curr = s.strstart + s.lookahead;\n// var init = 0;\n//\n// if (s.high_water < curr) {\n// /* Previous high water mark below current data -- zero WIN_INIT\n// * bytes or up to end of window, whichever is less.\n// */\n// init = s.window_size - curr;\n// if (init > WIN_INIT)\n// init = WIN_INIT;\n// zmemzero(s->window + curr, (unsigned)init);\n// s->high_water = curr + init;\n// }\n// else if (s->high_water < (ulg)curr + WIN_INIT) {\n// /* High water mark at or above current data, but below current data\n// * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n// * to end of window, whichever is less.\n// */\n// init = (ulg)curr + WIN_INIT - s->high_water;\n// if (init > s->window_size - s->high_water)\n// init = s->window_size - s->high_water;\n// zmemzero(s->window + s->high_water, (unsigned)init);\n// s->high_water += init;\n// }\n// }\n//\n// Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n// \"not enough room for search\");\n}\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n * This function does not insert new strings in the dictionary since\n * uncompressible data is probably not useful. This function is used\n * only for the level=0 compression option.\n * NOTE: this function should be optimized to avoid extra copying from\n * window to pending_buf.\n */\nfunction deflate_stored(s, flush) {\n /* Stored blocks are limited to 0xffff bytes, pending_buf is limited\n * to pending_buf_size, and each stored block has a 5 byte header:\n */\n var max_block_size = 0xffff;\n\n if (max_block_size > s.pending_buf_size - 5) {\n max_block_size = s.pending_buf_size - 5;\n }\n\n /* Copy as much as possible from input to output: */\n for (;;) {\n /* Fill the window as much as possible: */\n if (s.lookahead <= 1) {\n\n //Assert(s->strstart < s->w_size+MAX_DIST(s) ||\n // s->block_start >= (long)s->w_size, \"slide too late\");\n// if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||\n// s.block_start >= s.w_size)) {\n// throw new Error(\"slide too late\");\n// }\n\n fill_window(s);\n if (s.lookahead === 0 && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n\n if (s.lookahead === 0) {\n break;\n }\n /* flush the current block */\n }\n //Assert(s->block_start >= 0L, \"block gone\");\n// if (s.block_start < 0) throw new Error(\"block gone\");\n\n s.strstart += s.lookahead;\n s.lookahead = 0;\n\n /* Emit a stored block if pending_buf will be full: */\n var max_start = s.block_start + max_block_size;\n\n if (s.strstart === 0 || s.strstart >= max_start) {\n /* strstart == 0 is possible when wraparound on 16-bit machine */\n s.lookahead = s.strstart - max_start;\n s.strstart = max_start;\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n\n\n }\n /* Flush if we may have to slide, otherwise block_start may become\n * negative and the data will be gone:\n */\n if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n\n s.insert = 0;\n\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n\n if (s.strstart > s.block_start) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_NEED_MORE;\n}\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nfunction deflate_fast(s, flush) {\n var hash_head; /* head of the hash chain */\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break; /* flush the current block */\n }\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n * At this point we have always match_length < MIN_MATCH\n */\n if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n }\n if (s.match_length >= MIN_MATCH) {\n // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only\n\n /*** _tr_tally_dist(s, s.strstart - s.match_start,\n s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n\n /* Insert new strings in the hash table only if the match length\n * is not too large. This saves time but degrades compression.\n */\n if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {\n s.match_length--; /* string at strstart already in table */\n do {\n s.strstart++;\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n * always MIN_MATCH bytes ahead.\n */\n } while (--s.match_length !== 0);\n s.strstart++;\n } else\n {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;\n\n//#if MIN_MATCH != 3\n// Call UPDATE_HASH() MIN_MATCH-3 more times\n//#endif\n /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n * matter since it will be recomputed at next deflate call.\n */\n }\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s.window[s.strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nfunction deflate_slow(s, flush) {\n var hash_head; /* head of hash chain */\n var bflush; /* set if current block must be flushed */\n\n var max_insert;\n\n /* Process the input block. */\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n */\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n\n if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&\n s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n\n if (s.match_length <= 5 &&\n (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) {\n\n /* If prev_match is also MIN_MATCH, match_start is garbage\n * but we will ignore the current match anyway.\n */\n s.match_length = MIN_MATCH - 1;\n }\n }\n /* If there was a match at the previous step and the current\n * match is not better, output the previous match:\n */\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n /* Do not insert strings in hash table beyond this. */\n\n //check_match(s, s.strstart-1, s.prev_match, s.prev_length);\n\n /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,\n s.prev_length - MIN_MATCH, bflush);***/\n bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n /* Insert in hash table all strings up to the end of the match.\n * strstart-1 and strstart are already inserted. If there is not\n * enough lookahead, the last two strings are not inserted in\n * the hash table.\n */\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n } else if (s.match_available) {\n /* If there was no match at the previous position, output a\n * single literal. If there was a match but the current match\n * is longer, truncate the previous match to a single literal.\n */\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n if (bflush) {\n /*** FLUSH_BLOCK_ONLY(s, 0) ***/\n flush_block_only(s, false);\n /***/\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n /* There is no previous match to compare with, wait for\n * the next step to decide.\n */\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n //Assert (flush != Z_NO_FLUSH, \"no flush?\");\n if (s.match_available) {\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_BLOCK_DONE;\n}\n\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one. Do not maintain a hash table. (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nfunction deflate_rle(s, flush) {\n var bflush; /* set if current block must be flushed */\n var prev; /* byte at distance one to match */\n var scan, strend; /* scan goes up to strend for length of run */\n\n var _win = s.window;\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the longest run, plus one for the unrolled loop.\n */\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* See how many times the previous byte repeats */\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n /*jshint noempty:false*/\n } while (prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n //Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n }\n\n /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n if (s.match_length >= MIN_MATCH) {\n //check_match(s, s.strstart, s.strstart - 1, s.match_length);\n\n /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nfunction deflate_huff(s, flush) {\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we have a literal to write. */\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n break; /* flush the current block */\n }\n }\n\n /* Output a literal byte */\n s.match_length = 0;\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\nfunction Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n}\n\nvar configuration_table;\n\nconfiguration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast), /* 2 */\n new Config(4, 6, 32, 32, deflate_fast), /* 3 */\n\n new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow), /* 5 */\n new Config(8, 16, 128, 128, deflate_slow), /* 6 */\n new Config(8, 32, 128, 256, deflate_slow), /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow), /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */\n];\n\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nfunction lm_init(s) {\n s.window_size = 2 * s.w_size;\n\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n\n /* Set the default configuration parameters:\n */\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n}\n\n\nfunction DeflateState() {\n this.strm = null; /* pointer back to this zlib stream */\n this.status = 0; /* as the name implies */\n this.pending_buf = null; /* output still pending */\n this.pending_buf_size = 0; /* size of pending_buf */\n this.pending_out = 0; /* next pending byte to output to the stream */\n this.pending = 0; /* nb of bytes in the pending buffer */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.gzhead = null; /* gzip header information to write */\n this.gzindex = 0; /* where in extra, name, or comment */\n this.method = Z_DEFLATED; /* can only be DEFLATED */\n this.last_flush = -1; /* value of flush param for previous deflate call */\n\n this.w_size = 0; /* LZ77 window size (32K by default) */\n this.w_bits = 0; /* log2(w_size) (8..16) */\n this.w_mask = 0; /* w_size - 1 */\n\n this.window = null;\n /* Sliding window. Input bytes are read into the second half of the window,\n * and move to the first half later to keep a dictionary of at least wSize\n * bytes. With this organization, matches are limited to a distance of\n * wSize-MAX_MATCH bytes, but this ensures that IO is always\n * performed with a length multiple of the block size.\n */\n\n this.window_size = 0;\n /* Actual size of window: 2*wSize, except when the user input buffer\n * is directly used as sliding window.\n */\n\n this.prev = null;\n /* Link to older string with same hash index. To limit the size of this\n * array to 64K, this link is maintained only for the last 32K strings.\n * An index in this array is thus a window index modulo 32K.\n */\n\n this.head = null; /* Heads of the hash chains or NIL. */\n\n this.ins_h = 0; /* hash index of string to be inserted */\n this.hash_size = 0; /* number of elements in hash table */\n this.hash_bits = 0; /* log2(hash_size) */\n this.hash_mask = 0; /* hash_size-1 */\n\n this.hash_shift = 0;\n /* Number of bits by which ins_h must be shifted at each input\n * step. It must be such that after MIN_MATCH steps, the oldest\n * byte no longer takes part in the hash key, that is:\n * hash_shift * MIN_MATCH >= hash_bits\n */\n\n this.block_start = 0;\n /* Window position at the beginning of the current output block. Gets\n * negative when the window is moved backwards.\n */\n\n this.match_length = 0; /* length of best match */\n this.prev_match = 0; /* previous match */\n this.match_available = 0; /* set if previous match exists */\n this.strstart = 0; /* start of string to insert */\n this.match_start = 0; /* start of matching string */\n this.lookahead = 0; /* number of valid bytes ahead in window */\n\n this.prev_length = 0;\n /* Length of the best match at previous step. Matches not greater than this\n * are discarded. This is used in the lazy match evaluation.\n */\n\n this.max_chain_length = 0;\n /* To speed up deflation, hash chains are never searched beyond this\n * length. A higher limit improves compression ratio but degrades the\n * speed.\n */\n\n this.max_lazy_match = 0;\n /* Attempt to find a better match only when the current match is strictly\n * smaller than this value. This mechanism is used only for compression\n * levels >= 4.\n */\n // That's alias to max_lazy_match, don't use directly\n //this.max_insert_length = 0;\n /* Insert new strings in the hash table only if the match length is not\n * greater than this length. This saves time but degrades compression.\n * max_insert_length is used only for compression levels <= 3.\n */\n\n this.level = 0; /* compression level (1..9) */\n this.strategy = 0; /* favor or force Huffman coding*/\n\n this.good_match = 0;\n /* Use a faster search when the previous match is longer than this */\n\n this.nice_match = 0; /* Stop searching when current match exceeds this */\n\n /* used by trees.c: */\n\n /* Didn't use ct_data typedef below to suppress compiler warning */\n\n // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */\n // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */\n\n // Use flat array of DOUBLE size, with interleaved fata,\n // because JS does not support effective\n this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);\n this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);\n this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n\n this.l_desc = null; /* desc. for literal tree */\n this.d_desc = null; /* desc. for distance tree */\n this.bl_desc = null; /* desc. for bit length tree */\n\n //ush bl_count[MAX_BITS+1];\n this.bl_count = new utils.Buf16(MAX_BITS + 1);\n /* number of codes at each bit length for an optimal tree */\n\n //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */\n this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */\n zero(this.heap);\n\n this.heap_len = 0; /* number of elements in the heap */\n this.heap_max = 0; /* element of largest frequency */\n /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n * The same heap array is used to build all trees.\n */\n\n this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];\n zero(this.depth);\n /* Depth of each subtree used as tie breaker for trees of equal frequency\n */\n\n this.l_buf = 0; /* buffer index for literals or lengths */\n\n this.lit_bufsize = 0;\n /* Size of match buffer for literals/lengths. There are 4 reasons for\n * limiting lit_bufsize to 64K:\n * - frequencies can be kept in 16 bit counters\n * - if compression is not successful for the first block, all input\n * data is still in the window so we can still emit a stored block even\n * when input comes from standard input. (This can also be done for\n * all blocks if lit_bufsize is not greater than 32K.)\n * - if compression is not successful for a file smaller than 64K, we can\n * even emit a stored file instead of a stored block (saving 5 bytes).\n * This is applicable only for zip (not gzip or zlib).\n * - creating new Huffman trees less frequently may not provide fast\n * adaptation to changes in the input data statistics. (Take for\n * example a binary file with poorly compressible code followed by\n * a highly compressible string table.) Smaller buffer sizes give\n * fast adaptation but have of course the overhead of transmitting\n * trees more frequently.\n * - I can't count above 4\n */\n\n this.last_lit = 0; /* running index in l_buf */\n\n this.d_buf = 0;\n /* Buffer index for distances. To simplify the code, d_buf and l_buf have\n * the same number of elements. To use different lengths, an extra flag\n * array would be necessary.\n */\n\n this.opt_len = 0; /* bit length of current block with optimal trees */\n this.static_len = 0; /* bit length of current block with static trees */\n this.matches = 0; /* number of string matches in current block */\n this.insert = 0; /* bytes at end of window left to insert */\n\n\n this.bi_buf = 0;\n /* Output buffer. bits are inserted starting at the bottom (least\n * significant bits).\n */\n this.bi_valid = 0;\n /* Number of valid bits in bi_buf. All bits above the last valid bit\n * are always zero.\n */\n\n // Used for window memory init. We safely ignore it for JS. That makes\n // sense only for pointers and memory check tools.\n //this.high_water = 0;\n /* High water mark offset in window for initialized bytes -- bytes above\n * this are set to zero in order to avoid memory check warnings when\n * longest match routines access bytes past the input. This is then\n * updated to the new high water mark.\n */\n}\n\n\nfunction deflateResetKeep(strm) {\n var s;\n\n if (!strm || !strm.state) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n\n s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n /* was made negative by deflate(..., Z_FINISH); */\n }\n s.status = (s.wrap ? INIT_STATE : BUSY_STATE);\n strm.adler = (s.wrap === 2) ?\n 0 // crc32(0, Z_NULL, 0)\n :\n 1; // adler32(0, Z_NULL, 0)\n s.last_flush = Z_NO_FLUSH;\n trees._tr_init(s);\n return Z_OK;\n}\n\n\nfunction deflateReset(strm) {\n var ret = deflateResetKeep(strm);\n if (ret === Z_OK) {\n lm_init(strm.state);\n }\n return ret;\n}\n\n\nfunction deflateSetHeader(strm, head) {\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; }\n strm.state.gzhead = head;\n return Z_OK;\n}\n\n\nfunction deflateInit2(strm, level, method, windowBits, memLevel, strategy) {\n if (!strm) { // === Z_NULL\n return Z_STREAM_ERROR;\n }\n var wrap = 1;\n\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n\n if (windowBits < 0) { /* suppress zlib wrapper */\n wrap = 0;\n windowBits = -windowBits;\n }\n\n else if (windowBits > 15) {\n wrap = 2; /* write gzip wrapper instead */\n windowBits -= 16;\n }\n\n\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED ||\n windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n strategy < 0 || strategy > Z_FIXED) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n\n if (windowBits === 8) {\n windowBits = 9;\n }\n /* until 256-byte window bug fixed */\n\n var s = new DeflateState();\n\n strm.state = s;\n s.strm = strm;\n\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n\n s.window = new utils.Buf8(s.w_size * 2);\n s.head = new utils.Buf16(s.hash_size);\n s.prev = new utils.Buf16(s.w_size);\n\n // Don't need mem init magic for JS.\n //s.high_water = 0; /* nothing written to s->window yet */\n\n s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n s.pending_buf_size = s.lit_bufsize * 4;\n\n //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n //s->pending_buf = (uchf *) overlay;\n s.pending_buf = new utils.Buf8(s.pending_buf_size);\n\n // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)\n //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n s.d_buf = 1 * s.lit_bufsize;\n\n //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n s.l_buf = (1 + 2) * s.lit_bufsize;\n\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n\n return deflateReset(strm);\n}\n\nfunction deflateInit(strm, level) {\n return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n}\n\n\nfunction deflate(strm, flush) {\n var old_flush, s;\n var beg, val; // for gzip header write only\n\n if (!strm || !strm.state ||\n flush > Z_BLOCK || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;\n }\n\n s = strm.state;\n\n if (!strm.output ||\n (!strm.input && strm.avail_in !== 0) ||\n (s.status === FINISH_STATE && flush !== Z_FINISH)) {\n return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR);\n }\n\n s.strm = strm; /* just in case */\n old_flush = s.last_flush;\n s.last_flush = flush;\n\n /* Write the header */\n if (s.status === INIT_STATE) {\n\n if (s.wrap === 2) { // GZIP header\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) { // s->gzhead == Z_NULL\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n }\n else {\n put_byte(s, (s.gzhead.text ? 1 : 0) +\n (s.gzhead.hcrc ? 2 : 0) +\n (!s.gzhead.extra ? 0 : 4) +\n (!s.gzhead.name ? 0 : 8) +\n (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 0xff);\n put_byte(s, (s.gzhead.time >> 8) & 0xff);\n put_byte(s, (s.gzhead.time >> 16) & 0xff);\n put_byte(s, (s.gzhead.time >> 24) & 0xff);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, s.gzhead.os & 0xff);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 0xff);\n put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n else // DEFLATE header\n {\n var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;\n var level_flags = -1;\n\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= (level_flags << 6);\n if (s.strstart !== 0) { header |= PRESET_DICT; }\n header += 31 - (header % 31);\n\n s.status = BUSY_STATE;\n putShortMSB(s, header);\n\n /* Save the adler32 of the preset dictionary: */\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n strm.adler = 1; // adler32(0L, Z_NULL, 0);\n }\n }\n\n//#ifdef GZIP\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n\n while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n break;\n }\n }\n put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);\n s.gzindex++;\n }\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (s.gzindex === s.gzhead.extra.length) {\n s.gzindex = 0;\n s.status = NAME_STATE;\n }\n }\n else {\n s.status = NAME_STATE;\n }\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.gzindex = 0;\n s.status = COMMENT_STATE;\n }\n }\n else {\n s.status = COMMENT_STATE;\n }\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.status = HCRC_STATE;\n }\n }\n else {\n s.status = HCRC_STATE;\n }\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n }\n if (s.pending + 2 <= s.pending_buf_size) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n s.status = BUSY_STATE;\n }\n }\n else {\n s.status = BUSY_STATE;\n }\n }\n//#endif\n\n /* Flush as much pending output as possible */\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n /* Since avail_out is 0, deflate will be called again with\n * more output space, but possibly with both pending and\n * avail_in equal to zero. There won't be anything to do,\n * but this is not an error situation so make sure we\n * return OK instead of BUF_ERROR at next call of deflate:\n */\n s.last_flush = -1;\n return Z_OK;\n }\n\n /* Make sure there is something to do and avoid duplicate consecutive\n * flushes. For repeated and useless calls with Z_FINISH, we keep\n * returning Z_STREAM_END instead of Z_BUF_ERROR.\n */\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&\n flush !== Z_FINISH) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* User must not provide more input after the first FINISH: */\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* Start a new block or continue the current one.\n */\n if (strm.avail_in !== 0 || s.lookahead !== 0 ||\n (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {\n var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :\n (s.strategy === Z_RLE ? deflate_rle(s, flush) :\n configuration_table[s.level].func(s, flush));\n\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n /* avoid BUF_ERROR next call, see above */\n }\n return Z_OK;\n /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n * of deflate should use the same flush parameter to make sure\n * that the flush is complete. So we don't have to output an\n * empty block here, this will be done at next call. This also\n * ensures that for a very small output buffer, we emit at most\n * one empty block.\n */\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n trees._tr_align(s);\n }\n else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */\n\n trees._tr_stored_block(s, 0, 0, false);\n /* For a full flush, this empty block will be recognized\n * as a special marker by inflate_sync().\n */\n if (flush === Z_FULL_FLUSH) {\n /*** CLEAR_HASH(s); ***/ /* forget history */\n zero(s.head); // Fill with NIL (= 0);\n\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n return Z_OK;\n }\n }\n }\n //Assert(strm->avail_out > 0, \"bug2\");\n //if (strm.avail_out <= 0) { throw new Error(\"bug2\");}\n\n if (flush !== Z_FINISH) { return Z_OK; }\n if (s.wrap <= 0) { return Z_STREAM_END; }\n\n /* Write the trailer */\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n put_byte(s, (strm.adler >> 16) & 0xff);\n put_byte(s, (strm.adler >> 24) & 0xff);\n put_byte(s, strm.total_in & 0xff);\n put_byte(s, (strm.total_in >> 8) & 0xff);\n put_byte(s, (strm.total_in >> 16) & 0xff);\n put_byte(s, (strm.total_in >> 24) & 0xff);\n }\n else\n {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n\n flush_pending(strm);\n /* If avail_out is zero, the application will call deflate again\n * to flush the rest.\n */\n if (s.wrap > 0) { s.wrap = -s.wrap; }\n /* write the trailer only once! */\n return s.pending !== 0 ? Z_OK : Z_STREAM_END;\n}\n\nfunction deflateEnd(strm) {\n var status;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n status = strm.state.status;\n if (status !== INIT_STATE &&\n status !== EXTRA_STATE &&\n status !== NAME_STATE &&\n status !== COMMENT_STATE &&\n status !== HCRC_STATE &&\n status !== BUSY_STATE &&\n status !== FINISH_STATE\n ) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.state = null;\n\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;\n}\n\n\n/* =========================================================================\n * Initializes the compression dictionary from the given byte\n * sequence without producing any compressed output.\n */\nfunction deflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var s;\n var str, n;\n var wrap;\n var avail;\n var next;\n var input;\n var tmpDict;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n s = strm.state;\n wrap = s.wrap;\n\n if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {\n return Z_STREAM_ERROR;\n }\n\n /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n if (wrap === 1) {\n /* adler32(strm->adler, dictionary, dictLength); */\n strm.adler = adler32(strm.adler, dictionary, dictLength, 0);\n }\n\n s.wrap = 0; /* avoid computing Adler-32 in read_buf */\n\n /* if dictionary would fill window, just replace the history */\n if (dictLength >= s.w_size) {\n if (wrap === 0) { /* already empty otherwise */\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n /* use the tail */\n // dictionary = dictionary.slice(dictLength - s.w_size);\n tmpDict = new utils.Buf8(s.w_size);\n utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n /* insert dictionary into window and hash */\n avail = strm.avail_in;\n next = strm.next_in;\n input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n str = s.strstart;\n n = s.lookahead - (MIN_MATCH - 1);\n do {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK;\n}\n\n\nexports.deflateInit = deflateInit;\nexports.deflateInit2 = deflateInit2;\nexports.deflateReset = deflateReset;\nexports.deflateResetKeep = deflateResetKeep;\nexports.deflateSetHeader = deflateSetHeader;\nexports.deflate = deflate;\nexports.deflateEnd = deflateEnd;\nexports.deflateSetDictionary = deflateSetDictionary;\nexports.deflateInfo = 'pako deflate (from Nodeca project)';\n\n/* Not implemented\nexports.deflateBound = deflateBound;\nexports.deflateCopy = deflateCopy;\nexports.deflateParams = deflateParams;\nexports.deflatePending = deflatePending;\nexports.deflatePrime = deflatePrime;\nexports.deflateTune = deflateTune;\n*/\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/deflate.js\n// module id = 26\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n//var Z_FILTERED = 1;\n//var Z_HUFFMAN_ONLY = 2;\n//var Z_RLE = 3;\nvar Z_FIXED = 4;\n//var Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\nvar Z_BINARY = 0;\nvar Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n/*============================================================================*/\n\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n// From zutil.h\n\nvar STORED_BLOCK = 0;\nvar STATIC_TREES = 1;\nvar DYN_TREES = 2;\n/* The three kinds of block type */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\n/* The minimum and maximum match lengths */\n\n// From deflate.h\n/* ===========================================================================\n * Internal compression state.\n */\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\n\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\n\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\n\nvar D_CODES = 30;\n/* number of distance codes */\n\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\n\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\n\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar Buf_size = 16;\n/* size of bit buffer in bi_buf */\n\n\n/* ===========================================================================\n * Constants\n */\n\nvar MAX_BL_BITS = 7;\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\nvar END_BLOCK = 256;\n/* end of block literal code */\n\nvar REP_3_6 = 16;\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\nvar REPZ_3_10 = 17;\n/* repeat a zero length 3-10 times (3 bits of repeat count) */\n\nvar REPZ_11_138 = 18;\n/* repeat a zero length 11-138 times (7 bits of repeat count) */\n\n/* eslint-disable comma-spacing,array-bracket-spacing */\nvar extra_lbits = /* extra bits for each length code */\n [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];\n\nvar extra_dbits = /* extra bits for each distance code */\n [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];\n\nvar extra_blbits = /* extra bits for each bit length code */\n [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];\n\nvar bl_order =\n [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];\n/* eslint-enable comma-spacing,array-bracket-spacing */\n\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n// We pre-fill arrays with 0 to avoid uninitialized gaps\n\nvar DIST_CODE_LEN = 512; /* see definition of array dist_code below */\n\n// !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1\nvar static_ltree = new Array((L_CODES + 2) * 2);\nzero(static_ltree);\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nvar static_dtree = new Array(D_CODES * 2);\nzero(static_dtree);\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nvar _dist_code = new Array(DIST_CODE_LEN);\nzero(_dist_code);\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nvar _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);\nzero(_length_code);\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nvar base_length = new Array(LENGTH_CODES);\nzero(base_length);\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nvar base_dist = new Array(D_CODES);\nzero(base_dist);\n/* First normalized distance for each code (0 = distance of 1) */\n\n\nfunction StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n\n this.static_tree = static_tree; /* static tree or NULL */\n this.extra_bits = extra_bits; /* extra bits for each code or NULL */\n this.extra_base = extra_base; /* base index for extra_bits */\n this.elems = elems; /* max number of elements in the tree */\n this.max_length = max_length; /* max bit length for the codes */\n\n // show if `static_tree` has data or dummy - needed for monomorphic objects\n this.has_stree = static_tree && static_tree.length;\n}\n\n\nvar static_l_desc;\nvar static_d_desc;\nvar static_bl_desc;\n\n\nfunction TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree; /* the dynamic tree */\n this.max_code = 0; /* largest code with non zero frequency */\n this.stat_desc = stat_desc; /* the corresponding static tree */\n}\n\n\n\nfunction d_code(dist) {\n return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];\n}\n\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\nfunction put_short(s, w) {\n// put_byte(s, (uch)((w) & 0xff));\n// put_byte(s, (uch)((ush)(w) >> 8));\n s.pending_buf[s.pending++] = (w) & 0xff;\n s.pending_buf[s.pending++] = (w >>> 8) & 0xff;\n}\n\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\nfunction send_bits(s, value, length) {\n if (s.bi_valid > (Buf_size - length)) {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> (Buf_size - s.bi_valid);\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n s.bi_valid += length;\n }\n}\n\n\nfunction send_code(s, c, tree) {\n send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);\n}\n\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nfunction bi_reverse(code, len) {\n var res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nfunction bi_flush(s) {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 0xff;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n}\n\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n * above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n * array bl_count contains the frequencies for each bit length.\n * The length opt_len is updated; static_len is also updated if stree is\n * not null.\n */\nfunction gen_bitlen(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var max_code = desc.max_code;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var extra = desc.stat_desc.extra_bits;\n var base = desc.stat_desc.extra_base;\n var max_length = desc.stat_desc.max_length;\n var h; /* heap index */\n var n, m; /* iterate over the tree elements */\n var bits; /* bit length */\n var xbits; /* extra bits */\n var f; /* frequency */\n var overflow = 0; /* number of elements with bit length too large */\n\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n\n /* In a first pass, compute the optimal bit lengths (which may\n * overflow in the case of the bit length tree).\n */\n tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */\n\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1]/*.Len*/ = bits;\n /* We overwrite tree[n].Dad which is no longer needed */\n\n if (n > max_code) { continue; } /* not a leaf node */\n\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2]/*.Freq*/;\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);\n }\n }\n if (overflow === 0) { return; }\n\n // Trace((stderr,\"\\nbit length overflow\\n\"));\n /* This happens for example on obj2 and pic of the Calgary corpus */\n\n /* Find the first bit length which could increase: */\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) { bits--; }\n s.bl_count[bits]--; /* move one leaf down the tree */\n s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */\n s.bl_count[max_length]--;\n /* The brother of the overflow item also moves one step up,\n * but this does not affect bl_count[max_length]\n */\n overflow -= 2;\n } while (overflow > 0);\n\n /* Now recompute all bit lengths, scanning in increasing frequency.\n * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n * lengths instead of fixing only the wrong ones. This idea is taken\n * from 'ar' written by Haruhiko Okumura.)\n */\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) { continue; }\n if (tree[m * 2 + 1]/*.Len*/ !== bits) {\n // Trace((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;\n tree[m * 2 + 1]/*.Len*/ = bits;\n }\n n--;\n }\n }\n}\n\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n * zero code length.\n */\nfunction gen_codes(tree, max_code, bl_count)\n// ct_data *tree; /* the tree to decorate */\n// int max_code; /* largest code with non zero frequency */\n// ushf *bl_count; /* number of codes at each bit length */\n{\n var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */\n var code = 0; /* running code value */\n var bits; /* bit index */\n var n; /* code index */\n\n /* The distribution counts are first used to generate the code values\n * without bit reversal.\n */\n for (bits = 1; bits <= MAX_BITS; bits++) {\n next_code[bits] = code = (code + bl_count[bits - 1]) << 1;\n }\n /* Check that the bit counts in bl_count are consistent. The last code\n * must be all ones.\n */\n //Assert (code + bl_count[MAX_BITS]-1 == (1< length code (0..28) */\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length[code] = length;\n for (n = 0; n < (1 << extra_lbits[code]); n++) {\n _length_code[length++] = code;\n }\n }\n //Assert (length == 256, \"tr_static_init: length != 256\");\n /* Note that the length 255 (match length 258) can be represented\n * in two different ways: code 284 + 5 bits or code 285, so we\n * overwrite length_code[255] to use the best encoding:\n */\n _length_code[length - 1] = code;\n\n /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist[code] = dist;\n for (n = 0; n < (1 << extra_dbits[code]); n++) {\n _dist_code[dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: dist != 256\");\n dist >>= 7; /* from now on, all distances are divided by 128 */\n for (; code < D_CODES; code++) {\n base_dist[code] = dist << 7;\n for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {\n _dist_code[256 + dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n /* Construct the codes of the static literal tree */\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n\n n = 0;\n while (n <= 143) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree[n * 2 + 1]/*.Len*/ = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree[n * 2 + 1]/*.Len*/ = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n /* Codes 286 and 287 do not exist, but we must include them in the\n * tree construction to get a canonical Huffman tree (longest code\n * all ones)\n */\n gen_codes(static_ltree, L_CODES + 1, bl_count);\n\n /* The static distance tree is trivial: */\n for (n = 0; n < D_CODES; n++) {\n static_dtree[n * 2 + 1]/*.Len*/ = 5;\n static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);\n }\n\n // Now data ready and we can init static trees\n static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n\n //static_init_done = true;\n}\n\n\n/* ===========================================================================\n * Initialize a new block.\n */\nfunction init_block(s) {\n var n; /* iterates over tree elements */\n\n /* Initialize the trees. */\n for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }\n\n s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;\n s.opt_len = s.static_len = 0;\n s.last_lit = s.matches = 0;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nfunction bi_windup(s)\n{\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n //put_byte(s, (Byte)s->bi_buf);\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n}\n\n/* ===========================================================================\n * Copy a stored block, storing first the length and its\n * one's complement if requested.\n */\nfunction copy_block(s, buf, len, header)\n//DeflateState *s;\n//charf *buf; /* the input data */\n//unsigned len; /* its length */\n//int header; /* true if block header must be written */\n{\n bi_windup(s); /* align on byte boundary */\n\n if (header) {\n put_short(s, len);\n put_short(s, ~len);\n }\n// while (len--) {\n// put_byte(s, *buf++);\n// }\n utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);\n s.pending += len;\n}\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\nfunction smaller(tree, n, m, depth) {\n var _n2 = n * 2;\n var _m2 = m * 2;\n return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||\n (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));\n}\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nfunction pqdownheap(s, tree, k)\n// deflate_state *s;\n// ct_data *tree; /* the tree to restore */\n// int k; /* node to move down */\n{\n var v = s.heap[k];\n var j = k << 1; /* left son of k */\n while (j <= s.heap_len) {\n /* Set j to the smallest of the two sons: */\n if (j < s.heap_len &&\n smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n /* Exit if v is smaller than both sons */\n if (smaller(tree, v, s.heap[j], s.depth)) { break; }\n\n /* Exchange v with the smallest son */\n s.heap[k] = s.heap[j];\n k = j;\n\n /* And continue down the tree, setting j to the left son of k */\n j <<= 1;\n }\n s.heap[k] = v;\n}\n\n\n// inlined manually\n// var SMALLEST = 1;\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nfunction compress_block(s, ltree, dtree)\n// deflate_state *s;\n// const ct_data *ltree; /* literal tree */\n// const ct_data *dtree; /* distance tree */\n{\n var dist; /* distance of matched string */\n var lc; /* match length or unmatched char (if dist == 0) */\n var lx = 0; /* running index in l_buf */\n var code; /* the code to send */\n var extra; /* number of extra bits to send */\n\n if (s.last_lit !== 0) {\n do {\n dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);\n lc = s.pending_buf[s.l_buf + lx];\n lx++;\n\n if (dist === 0) {\n send_code(s, lc, ltree); /* send a literal byte */\n //Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n } else {\n /* Here, lc is the match length - MIN_MATCH */\n code = _length_code[lc];\n send_code(s, code + LITERALS + 1, ltree); /* send the length code */\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length[code];\n send_bits(s, lc, extra); /* send the extra length bits */\n }\n dist--; /* dist is now the match distance - 1 */\n code = d_code(dist);\n //Assert (code < D_CODES, \"bad d_code\");\n\n send_code(s, code, dtree); /* send the distance code */\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist[code];\n send_bits(s, dist, extra); /* send the extra distance bits */\n }\n } /* literal or match pair ? */\n\n /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n // \"pendingBuf overflow\");\n\n } while (lx < s.last_lit);\n }\n\n send_code(s, END_BLOCK, ltree);\n}\n\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n * and corresponding code. The length opt_len is updated; static_len is\n * also updated if stree is not null. The field max_code is set.\n */\nfunction build_tree(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var elems = desc.stat_desc.elems;\n var n, m; /* iterate over heap elements */\n var max_code = -1; /* largest code with non zero frequency */\n var node; /* new node being created */\n\n /* Construct the initial heap, with least frequent element in\n * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n * heap[0] is not used.\n */\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n\n for (n = 0; n < elems; n++) {\n if (tree[n * 2]/*.Freq*/ !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n\n } else {\n tree[n * 2 + 1]/*.Len*/ = 0;\n }\n }\n\n /* The pkzip format requires that at least one distance code exists,\n * and that at least one bit should be sent even if there is only one\n * possible code. So to avoid special checks later on we force at least\n * two codes of non zero frequency.\n */\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);\n tree[node * 2]/*.Freq*/ = 1;\n s.depth[node] = 0;\n s.opt_len--;\n\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1]/*.Len*/;\n }\n /* node is 0 or 1 so it does not have extra bits */\n }\n desc.max_code = max_code;\n\n /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n * establish sub-heaps of increasing lengths:\n */\n for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }\n\n /* Construct the Huffman tree by repeatedly combining the least two\n * frequent nodes.\n */\n node = elems; /* next internal node of the tree */\n do {\n //pqremove(s, tree, n); /* n = node of least frequency */\n /*** pqremove ***/\n n = s.heap[1/*SMALLEST*/];\n s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];\n pqdownheap(s, tree, 1/*SMALLEST*/);\n /***/\n\n m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */\n\n s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */\n s.heap[--s.heap_max] = m;\n\n /* Create a new node father of n and m */\n tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;\n\n /* and insert the new node in the heap */\n s.heap[1/*SMALLEST*/] = node++;\n pqdownheap(s, tree, 1/*SMALLEST*/);\n\n } while (s.heap_len >= 2);\n\n s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];\n\n /* At this point, the fields freq and dad are set. We can now\n * generate the bit lengths.\n */\n gen_bitlen(s, desc);\n\n /* The field len is now set, we can generate the bit codes */\n gen_codes(tree, max_code, s.bl_count);\n}\n\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nfunction scan_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n s.bl_tree[curlen * 2]/*.Freq*/ += count;\n\n } else if (curlen !== 0) {\n\n if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }\n s.bl_tree[REP_3_6 * 2]/*.Freq*/++;\n\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;\n\n } else {\n s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;\n }\n\n count = 0;\n prevlen = curlen;\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nfunction send_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n /* tree[max_code+1].Len = -1; */ /* guard already set */\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);\n\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n //Assert(count >= 3 && count <= 6, \" 3_6?\");\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nfunction build_bl_tree(s) {\n var max_blindex; /* index of last bit length code of non zero freq */\n\n /* Determine the bit length frequencies for literal and distance trees */\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n\n /* Build the bit length tree: */\n build_tree(s, s.bl_desc);\n /* opt_len now includes the length of the tree representations, except\n * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n */\n\n /* Determine the number of bit length codes to send. The pkzip format\n * requires that at least 4 bit length codes be sent. (appnote.txt says\n * 3 but the actual value used is 4.)\n */\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {\n break;\n }\n }\n /* Update opt_len to include the bit length tree and counts */\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n //Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n // s->opt_len, s->static_len));\n\n return max_blindex;\n}\n\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nfunction send_all_trees(s, lcodes, dcodes, blcodes)\n// deflate_state *s;\n// int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n var rank; /* index in bl_order */\n\n //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n // \"too many codes\");\n //Tracev((stderr, \"\\nbl counts: \"));\n send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */\n for (rank = 0; rank < blcodes; rank++) {\n //Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);\n }\n //Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */\n //Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */\n //Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n}\n\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n * a) There are no non-portable control characters belonging to the\n * \"black list\" (0..6, 14..25, 28..31).\n * b) There is at least one printable character belonging to the\n * \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n * \"gray list\" that is ignored in this detection algorithm:\n * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nfunction detect_data_type(s) {\n /* black_mask is the bit mask of black-listed bytes\n * set bits 0..6, 14..25, and 28..31\n * 0xf3ffc07f = binary 11110011111111111100000001111111\n */\n var black_mask = 0xf3ffc07f;\n var n;\n\n /* Check for non-textual (\"black-listed\") bytes. */\n for (n = 0; n <= 31; n++, black_mask >>>= 1) {\n if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {\n return Z_BINARY;\n }\n }\n\n /* Check for textual (\"white-listed\") bytes. */\n if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||\n s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n }\n\n /* There are no \"black-listed\" or \"white-listed\" bytes:\n * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n */\n return Z_BINARY;\n}\n\n\nvar static_init_done = false;\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nfunction _tr_init(s)\n{\n\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n /* Initialize the first block of the first file: */\n init_block(s);\n}\n\n\n/* ===========================================================================\n * Send a stored block\n */\nfunction _tr_stored_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */\n copy_block(s, buf, stored_len, true); /* with header */\n}\n\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nfunction _tr_align(s) {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree);\n bi_flush(s);\n}\n\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and output the encoded block to the zip file.\n */\nfunction _tr_flush_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block, or NULL if too old */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n var opt_lenb, static_lenb; /* opt_len and static_len in bytes */\n var max_blindex = 0; /* index of last bit length code of non zero freq */\n\n /* Build the Huffman trees unless a stored block is forced */\n if (s.level > 0) {\n\n /* Check if the file is binary or text */\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n\n /* Construct the literal and distance trees */\n build_tree(s, s.l_desc);\n // Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n\n build_tree(s, s.d_desc);\n // Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n /* At this point, opt_len and static_len are the total bit lengths of\n * the compressed block data, excluding the tree representations.\n */\n\n /* Build the bit length tree for the above two trees, and get the index\n * in bl_order of the last bit length code to send.\n */\n max_blindex = build_bl_tree(s);\n\n /* Determine the best encoding. Compute the block lengths in bytes. */\n opt_lenb = (s.opt_len + 3 + 7) >>> 3;\n static_lenb = (s.static_len + 3 + 7) >>> 3;\n\n // Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n // s->last_lit));\n\n if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }\n\n } else {\n // Assert(buf != (char*)0, \"lost buf\");\n opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n }\n\n if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {\n /* 4: two words for the lengths */\n\n /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n * Otherwise we can't have processed more than WSIZE input bytes since\n * the last block flush, because compression would have been\n * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n * transform a block into a stored block.\n */\n _tr_stored_block(s, buf, stored_len, last);\n\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree, static_dtree);\n\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n // Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n /* The above check is made mod 2^32, for files larger than 512 MB\n * and uLong implemented on 32 bits.\n */\n init_block(s);\n\n if (last) {\n bi_windup(s);\n }\n // Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n // s->compressed_len-7*last));\n}\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nfunction _tr_tally(s, dist, lc)\n// deflate_state *s;\n// unsigned dist; /* distance of matched string */\n// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n //var out_length, in_length, dcode;\n\n s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;\n s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;\n\n s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;\n s.last_lit++;\n\n if (dist === 0) {\n /* lc is the unmatched char */\n s.dyn_ltree[lc * 2]/*.Freq*/++;\n } else {\n s.matches++;\n /* Here, lc is the match length - MIN_MATCH */\n dist--; /* dist = match distance - 1 */\n //Assert((ush)dist < (ush)MAX_DIST(s) &&\n // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n // (ush)d_code(dist) < (ush)D_CODES, \"_tr_tally: bad match\");\n\n s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;\n s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n\n//#ifdef TRUNCATE_BLOCK\n// /* Try to guess if it is profitable to stop the current block here */\n// if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {\n// /* Compute an upper bound for the compressed length */\n// out_length = s.last_lit*8;\n// in_length = s.strstart - s.block_start;\n//\n// for (dcode = 0; dcode < D_CODES; dcode++) {\n// out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);\n// }\n// out_length >>>= 3;\n// //Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n// // s->last_lit, in_length, out_length,\n// // 100L - out_length*100L/in_length));\n// if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {\n// return true;\n// }\n// }\n//#endif\n\n return (s.last_lit === s.lit_bufsize - 1);\n /* We avoid equality with lit_bufsize because of wraparound at 64K\n * on 16 bit machines and because stored blocks are restricted to\n * 64K-1 bytes.\n */\n}\n\nexports._tr_init = _tr_init;\nexports._tr_stored_block = _tr_stored_block;\nexports._tr_flush_block = _tr_flush_block;\nexports._tr_tally = _tr_tally;\nexports._tr_align = _tr_align;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/trees.js\n// module id = 27\n// module chunks = 0","'use strict';\n\n\nvar zlib_inflate = require('./zlib/inflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar c = require('./zlib/constants');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\nvar GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = utils.assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== c.Z_OK) {\n throw new Error(msg[status]);\n }\n\n this.header = new GZheader();\n\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = strings.binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */\n\n if (status === c.Z_NEED_DICT && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = strings.string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = zlib_inflate.inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === c.Z_BUF_ERROR && allowBufError === true) {\n status = c.Z_OK;\n allowBufError = false;\n }\n\n if (status !== c.Z_STREAM_END && status !== c.Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);\n\n if (status === c.Z_STREAM_END) {\n _mode = c.Z_FINISH;\n }\n\n // Finalize on the last chunk.\n if (_mode === c.Z_FINISH) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === c.Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === c.Z_SYNC_FLUSH) {\n this.onEnd(c.Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === c.Z_OK) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 aligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction inflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg || msg[inflator.err]; }\n\n return inflator.result;\n}\n\n\n/**\n * inflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n}\n\n\n/**\n * ungzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\nexports.Inflate = Inflate;\nexports.inflate = inflate;\nexports.inflateRaw = inflateRaw;\nexports.ungzip = inflate;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/inflate.js\n// module id = 28\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar inflate_fast = require('./inffast');\nvar inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_WBITS = MAX_WBITS;\n\n\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new utils.Buf16(320); /* temporary storage for code lengths */\n this.work = new utils.Buf16(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);\n state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\nfunction inflateInit(strm) {\n return inflateInit2(strm, DEF_WBITS);\n}\n\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new utils.Buf32(512);\n distfix = new utils.Buf32(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new utils.Buf8(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n utils.arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n utils.arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n utils.arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n utils.arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\nexports.inflateReset = inflateReset;\nexports.inflateReset2 = inflateReset2;\nexports.inflateResetKeep = inflateResetKeep;\nexports.inflateInit = inflateInit;\nexports.inflateInit2 = inflateInit2;\nexports.inflate = inflate;\nexports.inflateEnd = inflateEnd;\nexports.inflateGetHeader = inflateGetHeader;\nexports.inflateSetDictionary = inflateSetDictionary;\nexports.inflateInfo = 'pako inflate (from Nodeca project)';\n\n/* Not implemented\nexports.inflateCopy = inflateCopy;\nexports.inflateGetDictionary = inflateGetDictionary;\nexports.inflateMark = inflateMark;\nexports.inflatePrime = inflatePrime;\nexports.inflateSync = inflateSync;\nexports.inflateSyncPoint = inflateSyncPoint;\nexports.inflateUndermine = inflateUndermine;\n*/\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inflate.js\n// module id = 29\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// See state defs from inflate.js\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\nmodule.exports = function inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inffast.js\n// module id = 30\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\nmodule.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inftrees.js\n// module id = 31\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\nmodule.exports = GZheader;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/gzheader.js\n// module id = 32\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\n/**\n * @protected\n */\nexport default class WeightDecoderRaw {\n async decode(data) {\n return new Float32Array(data.buffer, data.byteOffset, data.byteLength / 4);\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/weight_decoder_raw.js\n// module id = 33\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\n/**\n * @private\n */\nconst NOT_SCHEDULED = -1;\n/**\n * Schedule function which is called too much frequently.\n *\n * @private\n */\nexport default class DispatchScheduler {\n constructor() {\n this.scheduledCallbackId = NOT_SCHEDULED;\n }\n /**\n * Register scheduled function. If already other function is scheduled, it is canceled and dispatcher will dispatch only\n * function which is registered at last.\n * @param fn scheduled function\n */\n request(fn) {\n this.fn = fn;\n if (this.scheduledCallbackId == NOT_SCHEDULED) {\n this.scheduledCallbackId = requestAnimationFrame(() => this.forceDispatch());\n }\n }\n /**\n * Dispatch scheduled function just now. If no function is scheduled, dispatcher do nothing.\n */\n forceDispatch() {\n if (this.scheduledCallbackId == NOT_SCHEDULED)\n return;\n this.cancel();\n this.fn();\n }\n /**\n * Cancel scheduled function. If no function is scheduled, dispatcher do nothing.\n */\n cancel() {\n if (this.scheduledCallbackId == NOT_SCHEDULED)\n return;\n cancelAnimationFrame(this.scheduledCallbackId);\n this.scheduledCallbackId = NOT_SCHEDULED;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/util/dispatch_scheduler.js\n// module id = 34\n// module chunks = 0","/**\n * @protected\n */\nfunction flatten(arr) {\n let result = [];\n for (let i = 0; i < arr.length; i++) {\n let v = arr[i];\n if (v instanceof Array) {\n result.splice(result.length, 0, flatten(v));\n }\n else {\n result[result.length] = v;\n }\n }\n return result;\n}\n/**\n * @protected\n */\nexport class SymbolicTypedArray {\n /**\n * @protected\n */\n constructor(buffer = null, byteOffset = 0, length, placeholderContext = null) {\n this.placeholderContext = placeholderContext;\n this._byteOffset = byteOffset;\n this._buffer = buffer;\n if (buffer) {\n this._length = length === undefined ? (buffer.byteLength / this.BYTES_PER_ELEMENT) : length;\n }\n else {\n if (length === undefined)\n throw Error('\"butter\" or \"length\" must be specified.');\n this._length = length;\n }\n if (this.isDynamic) {\n if (!placeholderContext) {\n throw Error('PlaceholderContext must be required when SymbolicTypedArray is initialized as dynamic buffer view.');\n }\n }\n }\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n get buffer() {\n if (!this._buffer)\n this._buffer = new ArrayBuffer(this.byteOffset + this.byteLength);\n return this._buffer;\n }\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n set buffer(buffer) {\n this._buffer = buffer;\n }\n /**\n * The length in bytes of the array.\n */\n get byteLength() {\n return this.length * this.BYTES_PER_ELEMENT;\n }\n /**\n * The number in this buffer. Actual offset size is `(offset * SIZE_OF_FLOAT)`.\n */\n get offset() {\n return this.byteOffset / this.BYTES_PER_ELEMENT;\n }\n /**\n * @protected\n */\n get isDynamic() {\n return (typeof this._byteOffset !== 'number' || typeof this._length !== 'number');\n }\n /**\n * The number of elements in this buffer. Actual byte size is `(length * SIZE_OF_FLOAT)`.\n */\n get length() {\n if (this.isDynamic) {\n return this.placeholderContext.resolve(this._length);\n }\n else {\n return this._length;\n }\n }\n /**\n * The offset in bytes of the array.\n */\n get byteOffset() {\n if (this.isDynamic) {\n return this.placeholderContext.resolve(this._byteOffset);\n }\n else {\n return this._byteOffset;\n }\n }\n /**\n * Returns the this object after copying a section of the array identified by start and end\n * to the same array starting at position target\n * @param target If target is negative, it is treated as length+target where length is the\n * length of the array.\n * @param start If start is negative, it is treated as length+start. If end is negative, it\n * is treated as length+end.\n * @param end If not specified, length of the this object is used as its default value.\n */\n copyWithin(target, start, end) {\n this.toActual().copyWithin(target, start, end);\n return this;\n }\n /**\n * Returns the this object after filling the section identified by start and end with value\n * @param value value to fill array section with\n * @param start index to start filling the array at. If start is negative, it is treated as\n * length+start where length is the length of the array.\n * @param end index to stop filling the array at. If end is negative, it is treated as\n * length+end.\n */\n fill(value, start, end) {\n this.toActual().fill(value, start, end);\n return this;\n }\n /**\n * Returns the index of the first occurrence of a value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the\n * search starts at index 0.\n */\n indexOf(searchElement, fromIndex) {\n return this.toActual().indexOf(searchElement, fromIndex);\n }\n /**\n * Adds all the elements of an array separated by the specified separator string.\n * @param separator A string used to separate one element of an array from the next in the\n * resulting String. If omitted, the array elements are separated with a comma.\n */\n join(separator) {\n return this.toActual().join(separator);\n }\n /**\n * Returns the index of the last occurrence of a value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the\n * search starts at index 0.\n */\n lastIndexOf(searchElement, fromIndex) {\n return this.toActual().lastIndexOf(searchElement, fromIndex);\n }\n /**\n * Sorts an array.\n * @param compareFn The name of the function used to determine the order of the elements. If\n * omitted, the elements are sorted in ascending, ASCII character order.\n */\n sort(compareFn) {\n this.toActual().sort(compareFn);\n return this;\n }\n includes(searchElement, fromIndex) {\n return this.toActual().includes(searchElement, fromIndex);\n }\n /**\n * Sets a value or an array of values.\n * @param array A typed or untyped array of values to set.\n * @param offset The index in the current array at which the values are to be written.\n */\n set(array, offset) {\n return this.toActual().set(flatten(array), offset);\n }\n /**\n * Converts a number to a string by using the current locale.\n */\n toLocaleString() {\n return this.toActual().toLocaleString();\n }\n /**\n * Returns a string representation of an array.\n */\n toString() {\n return this.toActual().toString();\n }\n /** @protected */\n [Symbol.iterator]() {\n return this.toActual()[Symbol.iterator]();\n }\n /**\n * Returns an iterable of key, value pairs for every entry in the array\n */\n entries() {\n return this.toActual().entries();\n }\n /**\n * Returns an iterable of keys in the array\n */\n keys() {\n return this.toActual().keys();\n }\n /**\n * Returns an iterable of values in the array\n */\n values() {\n return this.toActual().values();\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/symbolic_typed_array/symbolic_typed_array.js\n// module id = 35\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport * as localforage from \"localforage\";\nimport get_weight_decoder from \"../decoder/get_weight_decoder\";\nimport webDNNFetch, { readArrayBufferProgressively, transformUrl } from \"../fetch\";\nimport PlaceholderContext from \"../placeholder\";\nimport SymbolicFloat32Array from \"../symbolic_typed_array/symbolic_float32array\";\nimport { DescriptorRunner } from \"./descriptor_runner\";\n/**\n * @protected\n */\nexport default class DescriptorRunnerWebassembly extends DescriptorRunner {\n constructor() {\n super();\n this.backendName = 'webassembly';\n this.worker_promise_reject_func = null;\n this.worker_initial_error = null;\n if (typeof Worker === 'undefined')\n throw new Error('WebWorker is needed for WebAssembly backend');\n if (typeof WebAssembly !== 'object') {\n console.warn('WebAssembly is not supported on this browser, trying to use asm.js code');\n }\n }\n static checkAvailability() {\n return 'Worker' in window;\n }\n init() {\n if (!DescriptorRunnerWebassembly.checkAvailability())\n throw Error('WebAssembly backend is not supported in this browser.');\n //nothing to do\n return Promise.resolve();\n }\n async setDescriptorAndParameters(descriptor, parameters) {\n this.descriptor = descriptor;\n this.placeholderContext = new PlaceholderContext(this.descriptor.placeholders);\n // for browsers which does not support wasm, try asm.js code\n let kernel_backend = typeof WebAssembly === 'object' ? 'webassembly' : 'asmjs';\n if (window.navigator.userAgent.indexOf('iPhone OS 11_2') >= 0) {\n // workaround for bug in webassembly\n // https://bugs.webkit.org/show_bug.cgi?id=181781\n kernel_backend = 'asmjs';\n }\n let worker_entry_js_path = `${this.directory}/kernels_${kernel_backend}.js`;\n worker_entry_js_path = transformUrl(worker_entry_js_path);\n this.worker_entry_js_path = worker_entry_js_path;\n await this.compile();\n await this.loadWeights(new Uint8Array(parameters));\n //assign buffer to input/output buffer view\n (await this.getInputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n (await this.getOutputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n }\n /**\n * Fetch graph descriptor from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @protected\n */\n async fetchDescriptor(directory) {\n this.directory = directory;\n let res = await webDNNFetch(`${directory}/graph_${this.backendName}.json`);\n return res.json();\n }\n /**\n * Fetch parameter files from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @param progressCallback callback which is called to notice the loading is progressing.\n * @protected\n */\n async fetchParameters(directory, progressCallback) {\n let weight_url = `${directory}/weight_${this.backendName}.bin`;\n let weight_fetch = await webDNNFetch(weight_url);\n return readArrayBufferProgressively(weight_fetch, progressCallback);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedDescriptor(directory) {\n this.directory = directory;\n return localforage.getItem(`${directory}_${this.backendName}_descriptor`).catch(() => null);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedParameters(directory, progressCallback) {\n let parameter = await localforage.getItem(`${directory}_${this.backendName}_parameters`).catch(() => null);\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return parameter;\n }\n /**\n * save cache\n */\n async saveCache(directory, descriptor, parameters) {\n await Promise.all([\n localforage.setItem(`${directory}_${this.backendName}_descriptor`, descriptor),\n localforage.setItem(`${directory}_${this.backendName}_parameters`, parameters)\n ]);\n }\n ;\n async setPlaceholderValue(values) {\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n let placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n let descriptor = this.descriptor;\n let unresolvedValueLists = descriptor.unresolved_value_lists;\n let metaBufferFillList = [];\n for (let kernel_order = 0; kernel_order < unresolvedValueLists.length; kernel_order++) {\n let unresolvedValueList = unresolvedValueLists[kernel_order];\n unresolvedValueList.forEach((offset_placeholder) => {\n let resolved_value = placeholderContext.resolve(offset_placeholder.placeholder);\n metaBufferFillList.push(kernel_order, offset_placeholder.offset, resolved_value);\n });\n }\n (await this.getInputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n (await this.getOutputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n let dynamicBufferSize = this.placeholderContext.resolve(this.descriptor.memory_layout.dynamic.size);\n await this.setPlaceholderValueWorker(dynamicBufferSize, new Int32Array(metaBufferFillList));\n }\n setPlaceholderValueWorker(dynamicBufferSize, metaBufferFillArray) {\n if (!this.worker)\n throw Error(\"Worker is not initialized\");\n let worker = this.worker;\n return new Promise((resolve, reject) => {\n worker.onmessage = (event) => {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n worker.postMessage({ type: 'set_dynamic_buffer', size: dynamicBufferSize, data: metaBufferFillArray });\n });\n }\n compile() {\n let worker = new Worker(this.worker_entry_js_path);\n worker.onerror = (event) => {\n console.error(event);\n // console.error('Worker Exception: ' + event.message);\n if (this.worker_promise_reject_func) {\n this.worker_promise_reject_func(event);\n }\n else {\n this.worker_initial_error = event;\n }\n };\n let promise = new Promise((resolve, reject) => {\n // occurs when this.worker_entry_js_path is 404\n if (this.worker_initial_error)\n return reject(this.worker_initial_error);\n this.worker_promise_reject_func = reject;\n worker.onmessage = (event) => {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.error(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n });\n this.worker = worker;\n return promise;\n }\n async loadWeights(weightsData) {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.worker)\n throw new Error('Worker is not initialized');\n let decoder = get_weight_decoder(this.descriptor.weight_encoding);\n let weight_data = await decoder.decode(weightsData);\n let worker = this.worker;\n let promise = new Promise((resolve, reject) => {\n this.worker_promise_reject_func = reject;\n worker.onmessage = (event) => {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n worker.postMessage({ type: 'weight', data: weight_data }, [weight_data.buffer]);\n });\n return promise;\n }\n getInputViews() {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, 0, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n }\n getOutputViews() {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, 0, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n }\n async run() {\n // if (this._running) throw new Error('Calling another run() while running.');\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.worker)\n throw new Error('Worker is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error('Not all placeholder is resolved');\n let placeholderContext = this.placeholderContext;\n let descriptor = this.descriptor;\n let worker = this.worker;\n let promise = new Promise((resolve, reject) => {\n // TODO: better way not to generate function on every run\n this.worker_promise_reject_func = reject;\n worker.onmessage = (event) => {\n if (Array.isArray(event.data)) {\n for (let i = 0; i < event.data.length; i++) {\n this.outputs[i].set(event.data[i]);\n }\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n let allocations = [descriptor.memory_layout.static.allocations, descriptor.memory_layout.dynamic.allocations];\n let inputs = [];\n for (let i = 0; i < descriptor.inputs.length; i++) {\n for (let allocation_space = 0; allocation_space < 2; allocation_space++) {\n let var_alloc = allocations[allocation_space][descriptor.inputs[i]];\n if (var_alloc) {\n let symAb = this.inputs[i];\n inputs.push({\n space: allocation_space,\n offset: placeholderContext.resolve(var_alloc.offset),\n size: symAb.length,\n data: symAb.toActual()\n });\n break;\n }\n }\n }\n let outputs = [];\n for (let i = 0; i < descriptor.outputs.length; i++) {\n for (let allocation_space = 0; allocation_space < 2; allocation_space++) {\n let var_alloc = allocations[allocation_space][descriptor.outputs[i]];\n if (var_alloc) {\n let symAb = this.outputs[i];\n outputs.push({\n space: allocation_space,\n offset: placeholderContext.resolve(var_alloc.offset),\n size: symAb.length\n });\n break;\n }\n }\n }\n worker.postMessage({ type: 'run', inputs: inputs, outputs: outputs });\n });\n return promise;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webassembly.js\n// module id = 36\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport * as localforage from \"localforage\";\nimport BufferWebGL from \"../buffer/buffer_webgl\";\nimport get_weight_decoder from \"../decoder/get_weight_decoder\";\nimport webdnnFetch, { readArrayBufferProgressively } from \"../fetch\";\nimport PlaceholderContext from \"../placeholder\";\nimport SymbolicFloat32Array from \"../symbolic_typed_array/symbolic_float32array\";\nimport { getConfiguration } from \"../webdnn\";\nimport WebGLHandler from \"../webgl_handler\";\nimport { DescriptorRunner } from \"./descriptor_runner\";\n// [x y u v] * [upper-left, lower-left, upper-right, lower-right]\n/**\n * @protected\n */\nconst vertexArray = new Float32Array([\n -1, +1,\n -1, -1,\n +1, +1,\n +1, -1,\n]);\n/**\n * @protected\n */\nexport default class DescriptorRunnerWebGL extends DescriptorRunner {\n constructor() {\n super(...arguments);\n this.backendName = 'webgl';\n }\n static checkAvailability() {\n return WebGLHandler.checkAvailability();\n }\n async init() {\n if (!DescriptorRunnerWebGL.checkAvailability())\n throw Error('WebGL backend is not supported in this browser.');\n this.handler = WebGLHandler.getInstance();\n let vertexBuffer = this.handler.createArrayBuffer(vertexArray);\n this.handler.bindArrayBuffer(vertexBuffer);\n this.buffers = new Map();\n }\n async fetchDescriptor(directory) {\n let res = await webdnnFetch(`${directory}/graph_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}.json`);\n return res.json();\n }\n async fetchParameters(directory, progressCallback) {\n let res = await webdnnFetch(`${directory}/weight_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}.bin`);\n return readArrayBufferProgressively(res, progressCallback);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedDescriptor(directory) {\n return localforage.getItem(`${directory}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_descriptor`).catch(() => null);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedParameters(directory, progressCallback) {\n let parameter = await localforage.getItem(`${directory}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_parameters`).catch(() => null);\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return parameter;\n }\n /**\n * save cache\n */\n async saveCache(directory, descriptor, parameters) {\n await Promise.all([\n localforage.setItem(`${directory}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_descriptor`, descriptor),\n localforage.setItem(`${directory}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_parameters`, parameters)\n ]);\n }\n ;\n async setDescriptorAndParameters(descriptor, parameters) {\n await this.setDescriptor(descriptor);\n await this.compile();\n await this.initializeStaticBuffer(parameters);\n if (this.placeholderContext && this.placeholderContext.isResolved)\n await this.initializeDynamicBuffer();\n }\n async initializeStaticBuffer(weightRawArray) {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n let descriptor = this.descriptor;\n let decoder = get_weight_decoder(this.descriptor.weight_encoding);\n let weight = await decoder.decode(new Uint8Array(weightRawArray));\n let buffers = this.buffers;\n let mapping = descriptor.memory_layout.mapping;\n Object.entries(descriptor.memory_layout.static.allocations)\n .forEach(([name, { width, height, size, channel_mode }]) => {\n buffers.set(name, new BufferWebGL(size * Float32Array.BYTES_PER_ELEMENT, width, height, name, null, channel_mode));\n });\n Object.entries(descriptor.constants_map)\n .forEach(([name, { size, byte_offset }]) => {\n buffers.get(name).array.set(new Float32Array(weight.buffer, byte_offset, size));\n });\n (await this.getInputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = buffers.get(mapping[view.name]).getWriteView(0, view.length, Float32Array).buffer;\n });\n (await this.getOutputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = buffers.get(mapping[view.name]).getReadView(0, view.length, Float32Array).buffer;\n });\n }\n async initializeDynamicBuffer() {\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n if (!this.placeholderContext)\n throw Error(\"PlaceholderContext is not initialized.\");\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n let buffers = this.buffers;\n let mapping = descriptor.memory_layout.mapping;\n Object.entries(descriptor.memory_layout.dynamic.allocations)\n .forEach(([name, { width, height, size, channel_mode }]) => {\n buffers.set(name, new BufferWebGL(placeholderContext.resolve(size) * Float32Array.BYTES_PER_ELEMENT, placeholderContext.resolve(width), placeholderContext.resolve(height), name, null, channel_mode));\n });\n (await this.getInputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = buffers.get(mapping[view.name]).getWriteView(0, placeholderContext.resolve(view.length), Float32Array).buffer;\n });\n (await this.getOutputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = buffers.get(mapping[view.name]).getReadView(0, placeholderContext.resolve(view.length), Float32Array).buffer;\n });\n this.buildPipeline();\n }\n async setDescriptor(descriptor) {\n this.descriptor = descriptor;\n //reset all datum depend on old descriptor\n this.placeholderContext = new PlaceholderContext(descriptor.placeholders);\n }\n async compile() {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n let descriptor = this.descriptor;\n this.programs = new Map();\n this.vertexShader = this.handler.createVertexShader(`\n precision highp float;\n attribute vec2 _xy;\n void main() { \n gl_Position = vec4(_xy, 0, 1); \n }\n `);\n Object.keys(descriptor.shader_sources)\n .forEach(name => {\n let fragmentShader = this.handler.createFragmentShader(descriptor.shader_sources[name]);\n let program = this.handler.createProgram(this.vertexShader, fragmentShader);\n this.programs.set(name, program);\n });\n }\n async setPlaceholderValue(values) {\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n let placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n await this.initializeDynamicBuffer();\n // resolve placeholders in execution info\n if (Object.keys(this.descriptor.placeholders).length > 0)\n throw Error('Currently, WebGL backend doesn\\'t support Placeholder feature.');\n }\n getInputViews() {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n let mapping = this.descriptor.memory_layout.mapping;\n this.inputs = descriptor.inputs.map(name => {\n let view = new SymbolicFloat32Array(null, 0, this.buffers.get(mapping[name]).length, placeholderContext);\n view.name = name;\n return view;\n });\n return this.inputs;\n }\n getOutputViews() {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n let mapping = this.descriptor.memory_layout.mapping;\n this.outputs = descriptor.outputs.map(name => {\n let view = new SymbolicFloat32Array(null, 0, this.buffers.get(mapping[name]).length, placeholderContext);\n view.name = name;\n return view;\n });\n return this.outputs;\n }\n buildPipeline() {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(`Not all placeholders are resolved: ${this.placeholderContext}`);\n let gl = this.handler.gl;\n let buffers = this.buffers;\n let mapping = this.descriptor.memory_layout.mapping;\n let referenceCount = new Map();\n this.runtimeInfo = {\n inputs: this.getInputViews().map(view => buffers.get(mapping[view.name])),\n outputs: this.getOutputViews().map(view => buffers.get(mapping[view.name])),\n programs: this.descriptor.exec_infos.map(execInfo => {\n // inputs\n let inputs = execInfo.inputs.map(input => {\n let buffer = buffers.get(mapping[input.variable_name]);\n if (!referenceCount.has(buffer))\n referenceCount.set(buffer, 0);\n referenceCount.set(buffer, referenceCount.get(buffer) + 1);\n return {\n buffer: buffer,\n uniformIndex: input.value\n };\n });\n //output\n let output = buffers.get(mapping[execInfo.output]);\n // shader\n let program = this.programs.get(execInfo.shader_name);\n this.handler.useProgram(program);\n // uniforms\n let uniforms = Object.keys(execInfo.uniforms).map(name => {\n let { type, value } = execInfo.uniforms[name];\n switch (type) {\n case 'int':\n return {\n func: gl.uniform1i,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'float':\n return {\n func: gl.uniform1f,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec2':\n return {\n func: gl.uniform2fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec3':\n return {\n func: gl.uniform3fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec4':\n return {\n func: gl.uniform4fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec2':\n return {\n func: gl.uniform2iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec3':\n return {\n func: gl.uniform3iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec4':\n return {\n func: gl.uniform4iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'sampler2D':\n return {\n func: gl.uniform1i,\n args: [gl.getUniformLocation(program, name), value]\n };\n default:\n throw TypeError(`Incompatible type for uniform parameter: ${type}`);\n }\n });\n // attributes\n let xyAttribLoc = gl.getAttribLocation(program, '_xy');\n // run\n return {\n program: program,\n frameBuffer: this.handler.createFrameBuffer(),\n name: execInfo.shader_name,\n width: output.textureWidth,\n height: output.textureHeight,\n inputs: inputs,\n output: output,\n xyAttribLoc: xyAttribLoc,\n uniforms: uniforms,\n disposable: []\n };\n })\n };\n for (let runtimeProgramInfo of this.runtimeInfo.programs) {\n runtimeProgramInfo.inputs.forEach(({ buffer }) => {\n let count = referenceCount.get(buffer) - 1;\n if (count == 0) {\n runtimeProgramInfo.disposable.push(buffer);\n }\n referenceCount.set(buffer, count);\n });\n }\n }\n async run() {\n // if (this._running) throw new Error('Calling another run() while running.');\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(`Not all placeholders are resolved: ${this.placeholderContext}`);\n let gl = this.handler.gl;\n let runtimeInfo = this.runtimeInfo;\n if (this.runtimeInfo.programs.length > 0) {\n for (let buffer of runtimeInfo.inputs)\n await buffer.syncWriteViews();\n if (getConfiguration('DEBUG', false)) {\n let records = [];\n let totalElapsedTime = 0;\n for (let runtimeProgramInfo of runtimeInfo.programs) {\n let start = performance.now();\n this.handler.bindFrameBuffer(runtimeProgramInfo.frameBuffer, runtimeProgramInfo.width, runtimeProgramInfo.height);\n // inputs\n for (let { buffer, uniformIndex } of runtimeProgramInfo.inputs)\n await buffer.bindToReadTexture(uniformIndex);\n // output\n runtimeProgramInfo.output.bindToDrawTexture();\n // shader\n this.handler.useProgram(runtimeProgramInfo.program);\n // uniforms\n for (let uniform of runtimeProgramInfo.uniforms)\n uniform.func.apply(gl, uniform.args);\n // attribute\n gl.vertexAttribPointer(runtimeProgramInfo.xyAttribLoc, 2, gl.FLOAT, true, 8, 0);\n gl.enableVertexAttribArray(runtimeProgramInfo.xyAttribLoc);\n // run\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertexArray.length / 2);\n await this.handler.waitForComplete();\n let elapsedTime = performance.now() - start;\n totalElapsedTime += elapsedTime;\n let xs = [];\n for (let { buffer } of runtimeProgramInfo.inputs) {\n buffer.unbindFromReadTexture();\n await buffer.syncReadViews();\n xs.push(buffer.array.slice());\n }\n runtimeProgramInfo.output.unbindFromDrawTexture();\n await runtimeProgramInfo.output.syncReadViews();\n let y = runtimeProgramInfo.output.array.slice();\n records.push({\n 'Kernel': runtimeProgramInfo.name,\n 'Elapsed time [ms]': elapsedTime,\n 'xs': xs,\n 'y': y\n });\n }\n let summary = Array.from(Object.values(records.reduce((summary, record) => {\n if (!(record['Kernel'] in summary)) {\n summary[record['Kernel']] = {\n 'Kernel': record['Kernel'],\n 'Count': 0,\n 'Elapsed time [ms]': 0,\n };\n }\n summary[record['Kernel']]['Count']++;\n summary[record['Kernel']]['Elapsed time [ms]'] += record['Elapsed time [ms]'];\n return summary;\n }, {})));\n summary.forEach(record => record['Ratio [%]'] = (record['Elapsed time [ms]'] / totalElapsedTime).toFixed(2));\n console.table(records);\n console.table(summary);\n }\n else {\n for (let runtimeProgramInfo of runtimeInfo.programs) {\n this.handler.bindFrameBuffer(runtimeProgramInfo.frameBuffer, runtimeProgramInfo.width, runtimeProgramInfo.height);\n // inputs\n for (let { buffer, uniformIndex } of runtimeProgramInfo.inputs)\n await buffer.bindToReadTexture(uniformIndex);\n // output\n runtimeProgramInfo.output.bindToDrawTexture();\n // shader\n this.handler.useProgram(runtimeProgramInfo.program);\n // uniforms\n for (let uniform of runtimeProgramInfo.uniforms)\n uniform.func.apply(gl, uniform.args);\n // attribute\n gl.vertexAttribPointer(runtimeProgramInfo.xyAttribLoc, 2, gl.FLOAT, true, 8, 0);\n gl.enableVertexAttribArray(runtimeProgramInfo.xyAttribLoc);\n // run\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertexArray.length / 2);\n // release buffers and binding\n // for (let buffer of runtimeProgramInfo.disposable) buffer.releaseGPUMemory();\n for (let { buffer } of runtimeProgramInfo.inputs)\n buffer.unbindFromReadTexture();\n runtimeProgramInfo.output.unbindFromDrawTexture();\n }\n }\n for (let buffer of runtimeInfo.outputs)\n await buffer.syncReadViews();\n }\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webgl.js\n// module id = 37\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport WebGLHandler, { isWebGL2 } from \"../webgl_handler\";\nimport { Buffer } from \"./buffer\";\n/**\n * @protected\n */\nexport default class BufferWebGL extends Buffer {\n constructor(byteLength, textureWidth, textureHeight, name, array, channelMode) {\n super(byteLength, 'webgl');\n this._texture = null;\n this.readTextureUnitIndices = [];\n this.isBoundToDrawFrameBuffer = false;\n this.handler = WebGLHandler.getInstance();\n this.name = name;\n this.channelMode = channelMode;\n switch (channelMode) {\n case 'RGBA':\n this.elementsPerPixel = 4;\n break;\n case 'R':\n this.elementsPerPixel = 1;\n break;\n default:\n throw Error('Unknown channel mode');\n }\n if (isWebGL2(this.handler.gl)) {\n switch (channelMode) {\n case 'RGBA':\n this.textureFormat = this.handler.gl.RGBA;\n this.textureInternalFormat = this.handler.gl.RGBA32F;\n this.pixelStride = 4;\n break;\n case 'R':\n this.textureFormat = this.handler.gl.RED;\n this.textureInternalFormat = this.handler.gl.R32F;\n this.pixelStride = 1;\n break;\n default:\n throw Error('Unknown channel mode');\n }\n }\n else {\n // In WebGL1, always RGBA channel mode is specified. If R channel mode is specified in graph descriptor,\n // other 3 channels are not used.\n this.textureFormat = this.handler.gl.RGBA;\n this.textureInternalFormat = this.handler.gl.RGBA;\n this.pixelStride = 4;\n }\n if (this.pixelStride < this.elementsPerPixel)\n throw Error('elementsPerPixel must be smaller than pixelStride');\n this.array = array || new Float32Array(this.length);\n this.textureWidth = textureWidth;\n this.textureHeight = textureHeight;\n }\n get texture() {\n return this._texture;\n }\n get length() {\n return this.byteLength / Float32Array.BYTES_PER_ELEMENT;\n }\n /**\n * Write contents onto specified position synchronously.\n *\n * @param {ArrayBufferView} src contents source buffer\n * @param {number} offset position where contents are written on\n */\n async write(src, offset) {\n this.array.set(src, offset);\n await this.syncWriteViews();\n }\n /**\n * Read contents from specified position synchronously.\n *\n * @param {Float32ArrayConstructor | Int32ArrayConstructor} dst buffer where contents are written on\n * @param {number} offset position where contents are read from\n * @param {length} length contents length\n */\n async read(dst, offset = 0, length) {\n if (dst !== Float32Array)\n throw new Error('Currently, only Float32Array is supported for parameter \\'dst\\'.');\n await this.syncReadViews();\n new Float32Array(this.array.buffer, offset * Float32Array.BYTES_PER_ELEMENT, length);\n }\n getWriteView(offset, length, type) {\n return new type(this.array.buffer, offset * type.BYTES_PER_ELEMENT, length);\n }\n ;\n getReadView(offset, length, type) {\n return new type(this.array.buffer, offset * type.BYTES_PER_ELEMENT, length);\n }\n /**\n * Sync buffered data into memory.\n *\n * @see Buffer#getWriteView\n */\n async syncWriteViews() {\n let gl = this.handler.gl;\n if (!this.texture)\n this.allocateTexture();\n let tmp = this.pack(this.array);\n if (tmp.length != this.textureWidth * this.textureHeight * this.pixelStride) {\n let tmp2 = new Float32Array(this.textureWidth * this.textureHeight * this.elementsPerPixel);\n tmp2.set(tmp, 0);\n tmp = tmp2;\n }\n await this.bindToReadTexture(9); //TODO: texture unit 9 is always available?\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.textureWidth, this.textureHeight, this.textureFormat, gl.FLOAT, tmp);\n this.unbindFromReadTexture();\n }\n /**\n * Sync memory data into buffer view.\n *\n * @see Buffer#getReadView\n */\n async syncReadViews() {\n let gl = this.handler.gl;\n // FIXME(Kiikurage): more readable code\n const ELEMENT_PER_PIXEL = 4;\n const FORMAT = gl.RGBA;\n let tmp = new Float32Array(this.textureWidth * this.textureHeight * ELEMENT_PER_PIXEL);\n this.bindToDrawTexture();\n gl.readPixels(0, 0, this.textureWidth, this.textureHeight, FORMAT, gl.FLOAT, tmp);\n this.unbindFromDrawTexture();\n tmp = this.unpack(tmp);\n this.array.set(tmp.slice(0, this.length), 0);\n }\n async bindToReadTexture(unit) {\n if (this.isBoundToDrawFrameBuffer)\n throw Error('This buffer is already registered as draw buffer. ' +\n 'You may forgot to unbind the binding while previous operations.');\n let gl = this.handler.gl;\n if (!this.texture) {\n this.allocateTexture();\n await this.syncWriteViews();\n }\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n this.readTextureUnitIndices.push(unit);\n }\n unbindFromReadTexture() {\n let gl = this.handler.gl;\n for (let unit of this.readTextureUnitIndices) {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n this.readTextureUnitIndices = [];\n }\n bindToDrawTexture() {\n if (this.readTextureUnitIndices.length > 0)\n throw Error('This buffer is already registered as read buffer. ' +\n 'You cannot bind a texture as both read and draw texture buffer at same time.');\n if (this.isBoundToDrawFrameBuffer)\n throw Error('This buffer is already registered as draw buffer. ' +\n 'You may forgot to unbind the binding while previous operations.');\n let gl = this.handler.gl;\n if (!this.texture)\n this.allocateTexture();\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0);\n this.isBoundToDrawFrameBuffer = true;\n }\n unbindFromDrawTexture() {\n if (!this.isBoundToDrawFrameBuffer)\n return;\n let gl = this.handler.gl;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);\n this.isBoundToDrawFrameBuffer = false;\n }\n pack(array) {\n let elementStride = this.pixelStride / this.elementsPerPixel;\n if (elementStride === 1) {\n return new Float32Array(array);\n }\n else {\n let result = new Float32Array(array.length * elementStride);\n for (let i = 0; i < array.length; i++)\n result[i * elementStride] = array[i];\n return result;\n }\n }\n unpack(array) {\n // FIXME(Kiikurage): more readable code\n const PIXEL_STRIDE = 4;\n let elementStride = PIXEL_STRIDE / this.elementsPerPixel;\n if (elementStride === 1) {\n return new Float32Array(array);\n }\n else {\n let result = new Float32Array(array.length / elementStride);\n for (let i = 0; i < array.length / elementStride; i++)\n result[i] = array[i * elementStride];\n return result;\n }\n }\n allocateTexture() {\n if (this.texture)\n throw Error('Texture is already allocated.');\n this._texture = this.handler.createTexture(this.textureWidth, this.textureHeight, this.textureInternalFormat, this.textureFormat);\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer_webgl.js\n// module id = 38\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport * as localforage from \"localforage\";\nimport BufferWebGPU from \"../buffer/buffer_webgpu\";\nimport getWeightDecoder from \"../decoder/get_weight_decoder\";\nimport webdnnFetch, { readArrayBufferProgressively } from \"../fetch\";\nimport PlaceholderContext from \"../placeholder\";\nimport SymbolicFloat32Array from \"../symbolic_typed_array/symbolic_float32array\";\nimport { getConfiguration } from \"../webdnn\";\nimport WebGPUHandler, { IS_WEBGPU_SUPPORTED } from \"../webgpu_handler\";\nimport { DescriptorRunner } from \"./descriptor_runner\";\n/**\n * Check this device is iOS devices or not.\n * @private\n */\nconst IS_IOS = navigator.userAgent.includes('iPhone') || navigator.userAgent.includes('iPad');\n/**\n * DescriptorRunner for WebGPU\n * @protected\n */\nexport default class DescriptorRunnerWebGPU extends DescriptorRunner {\n constructor() {\n super(...arguments);\n /**\n * backend name\n */\n this.backendName = 'webgpu';\n }\n /**\n * Return `true` if this backend is available in this environment.\n * @returns {boolean}\n */\n static checkAvailability() {\n return IS_WEBGPU_SUPPORTED;\n }\n /**\n * Initialize descriptor runner asynchronously\n * @returns {Promise} Promise object which is resolved when the initialization finished.\n */\n async init() {\n this.webgpuHandler = WebGPUHandler.getInstance();\n await this.checkIncompatibleGPU();\n }\n /**\n * Check whether current GPU is supported or not. If it's not supported, an error is thrown.\n * @returns {Promise}\n */\n async checkIncompatibleGPU() {\n /**\n * It is reported that AMD GPU crashes when performing sgemm (matrix multiplication).\n * Until this problem is solved, blocking WebGPU backend in the environment is needed.\n * API in WebGPU does not directly gives hardware information, so trying to determine hardware heuristically.\n *\n * Criteria: thread_execution_width == 32 is required\n * (on AMD FirePro D500, thread_execution_width == 64)\n *\n * @see https://github.com/mil-tokyo/webdnn/issues/286\n */\n this.webgpuHandler.loadKernel(`\n#include \nusing namespace metal;\n kernel void check_compatibility(\n device uint *A[[buffer(0)]],\n uint global_index[[thread_position_in_grid]],\n uint thread_execution_width[[thread_execution_width]]\n ){\n if (global_index == 0) {\n A[0] = thread_execution_width;\n }\n }`, 'basic');\n let buffer = this.webgpuHandler.createBuffer(new Uint32Array(1));\n await this.webgpuHandler.executeSinglePipelineState('basic.check_compatibility', { width: 1, height: 1, depth: 1 }, { width: 1, height: 1, depth: 1 }, [buffer], true);\n let threadExecutionWidth = (new Uint32Array(buffer.contents))[0];\n if (threadExecutionWidth != 32) {\n throw new Error(`Sorry, this GPU does not compatible with WebGPU (thread_execution_width == ${threadExecutionWidth}. See checkIncompatibleGPU method of https://github.com/mil-tokyo/webdnn/blob/master/src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.ts`);\n }\n }\n /**\n * Fetch graph descriptor from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @protected\n */\n async fetchDescriptor(directory) {\n let res = await webdnnFetch(`${directory}/graph_${this.backendName}.json`);\n return res.json();\n }\n /**\n * Fetch parameter files from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @param progressCallback callback which is called to notice the loading is progressing.\n * @protected\n */\n async fetchParameters(directory, progressCallback) {\n let res = await webdnnFetch(`${directory}/weight_${this.backendName}.bin`);\n return readArrayBufferProgressively(res, progressCallback);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedDescriptor(directory) {\n return localforage.getItem(`${directory}_${this.backendName}_descriptor`).catch(() => null);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedParameters(directory, progressCallback) {\n let parameter = await localforage.getItem(`${directory}_${this.backendName}_parameters`).catch(() => null);\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return parameter;\n }\n /**\n * save cache\n */\n async saveCache(directory, descriptor, parameters) {\n await Promise.all([\n localforage.setItem(`${directory}_${this.backendName}_descriptor`, descriptor),\n localforage.setItem(`${directory}_${this.backendName}_parameters`, parameters)\n ]);\n }\n ;\n async setDescriptorAndParameters(descriptor, parameter) {\n this.descriptor = descriptor;\n //reset all datum depend on old descriptor\n this.staticBuffer = null;\n this.dynamicBuffer = null;\n this.metaBuffers = null;\n this.placeholderContext = new PlaceholderContext(descriptor.placeholders);\n this.executionInfos = descriptor.exec_infos;\n //compile kernels\n this.webgpuHandler.loadKernel(this.descriptor.kernel_source, 'descriptor');\n await this.initializeStaticBuffer(parameter);\n await this.initializeMetaBuffers();\n await this.setPlaceholderValue({\n '__MAX_THREADS_PER_THREADGROUP__': IS_IOS ? 512 : 1024\n });\n if (this.placeholderContext && this.placeholderContext.isResolved)\n await this.initializeDynamicBuffer();\n }\n /**\n * Initialize static buffers, whose size and position can be determined in compile time.\n *\n * @param {ArrayBuffer} weightRawArray constant weight buffer\n * @returns {Promise}\n */\n async initializeStaticBuffer(weightRawArray) {\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n let descriptor = this.descriptor;\n let staticBuffer = new BufferWebGPU(descriptor.memory_layout.static.size * Float32Array.BYTES_PER_ELEMENT);\n this.staticBuffer = staticBuffer;\n let decoder = getWeightDecoder(descriptor.weight_encoding);\n await staticBuffer.write(await decoder.decode(new Uint8Array(weightRawArray)));\n (await this.getInputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = staticBuffer.bufferView.buffer;\n });\n (await this.getOutputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = staticBuffer.bufferView.buffer;\n });\n }\n /**\n * Initialize meta buffers, which contains metadata shared in each GPU kernel thread (ex. hyper parameters).\n * @returns {Promise}\n */\n async initializeMetaBuffers() {\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n this.metaBuffers = await Promise.all(this.descriptor.exec_infos.map(async (executionInfo) => {\n let buffer = new BufferWebGPU(executionInfo.meta_buffer.length * Int32Array.BYTES_PER_ELEMENT);\n await buffer.write(new Uint8Array(executionInfo.meta_buffer));\n return buffer;\n }));\n }\n /**\n * Initialize dynamic buffers, whose size and position cannot be determined without runtime-information such as input image size\n * (if it's dynamic).\n * When all placeholder is resolved, this method is automatically called.\n *\n * @returns {Promise}\n */\n async initializeDynamicBuffer() {\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n if (!this.placeholderContext)\n throw Error(\"PlaceholderContext is not initialized.\");\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n let dynamicBufferSize = placeholderContext.resolve(descriptor.memory_layout.dynamic.size);\n let dynamicBuffer = new BufferWebGPU(dynamicBufferSize * Float32Array.BYTES_PER_ELEMENT);\n this.dynamicBuffer = dynamicBuffer;\n (await this.getInputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = dynamicBuffer.bufferView.buffer;\n });\n (await this.getOutputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = dynamicBuffer.bufferView.buffer;\n });\n }\n /**\n * Set actual value into placeholder. If all placeholder is resolved,\n * [[DescriptorRunnerWebGPU#initializeDynamicBuffer|`initializeDynamicBuffer()`]] is automatically called.\n *\n * @param values mapping object of placeholder name and value\n * @returns {Promise}\n */\n async setPlaceholderValue(values) {\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n let placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.metaBuffers)\n throw new Error('MetaBuffers are not initialized');\n let descriptor = this.descriptor;\n let metaBuffers = this.metaBuffers;\n await this.initializeDynamicBuffer();\n // resolve placeholders in execution info\n this.executionInfos = await Promise.all(descriptor.exec_infos.map(async (executionInfo, i) => {\n // resolve placeholders in meta buffer\n let bufferView = new Int32Array(metaBuffers[i].bufferView.buffer);\n for (let unresolved_value of executionInfo.unresolved_value_list) {\n bufferView[unresolved_value.offset] = placeholderContext.resolve(unresolved_value.placeholder);\n }\n return placeholderContext.resolve(executionInfo);\n }));\n }\n /**\n * Get input [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]] object\n *\n * @returns array of input [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]]\n * @deprecated Use [[webdnn.DescriptorRunner.inputs|`inputs`]] instead\n */\n getInputViews() {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, allocation.offset * SymbolicFloat32Array.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n }\n /**\n * Get output [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]] object\n *\n * @returns array of output [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]]\n * @deprecated Use [[webdnn.DescriptorRunner.outputs|`outputs`]] instead\n */\n getOutputViews() {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, allocation.offset * SymbolicFloat32Array.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n }\n /**\n * Run descriptor. You must call [[webdnn.DescriptorRunner.getInputViews|`getInputViews`]] and\n * [[webdnn.DescriptorRunner.getOutputViews|`getOutputViews`]] before calling this function.\n */\n async run() {\n if (!this.executionInfos)\n throw new Error('ExecutionInfos is not loaded');\n if (!this.staticBuffer)\n throw new Error('StaticBuffer is not initialized');\n if (!this.dynamicBuffer)\n throw new Error('DynamicBuffer is not initialized');\n if (!this.metaBuffers)\n throw new Error('MetaBuffer is not initialized');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(`Not all placeholders are resolved: ${this.placeholderContext}`);\n let staticBuffer = this.staticBuffer;\n let dynamicBuffer = this.dynamicBuffer;\n let metaBuffers = this.metaBuffers;\n if (getConfiguration('DEBUG', false)) {\n let records = [];\n let totalElapsedTime = 0;\n for (let i = 0; i < this.executionInfos.length; i++) {\n let exec_info = this.executionInfos[i];\n let start = performance.now();\n await this.webgpuHandler.executeSinglePipelineState('descriptor.' + exec_info.entry_func_name, exec_info.threadgroups_per_grid, exec_info.threads_per_thread_group, [staticBuffer, dynamicBuffer, metaBuffers[i]], true);\n let elapsedTime = performance.now() - start;\n records.push({\n 'Kernel': exec_info.entry_func_name,\n 'Elapsed time [ms]': elapsedTime\n });\n totalElapsedTime += elapsedTime;\n }\n let summary = Array.from(Object.values(records.reduce((summary, record) => {\n if (!(record['Kernel'] in summary)) {\n summary[record['Kernel']] = {\n 'Kernel': record['Kernel'],\n 'Count': 0,\n 'Elapsed time [ms]': 0,\n };\n }\n summary[record['Kernel']]['Count']++;\n summary[record['Kernel']]['Elapsed time [ms]'] += record['Elapsed time [ms]'];\n return summary;\n }, {})));\n summary.forEach(record => record['Ratio [%]'] = (record['Elapsed time [ms]'] / totalElapsedTime).toFixed(2));\n console.table(records);\n console.table(summary);\n }\n else {\n let complete_promise = null;\n for (let i = 0; i < this.executionInfos.length; i++) {\n let exec_info = this.executionInfos[i];\n let is_last = i == this.executionInfos.length - 1;\n complete_promise = this.webgpuHandler.executeSinglePipelineState('descriptor.' + exec_info.entry_func_name, exec_info.threadgroups_per_grid, exec_info.threads_per_thread_group, [staticBuffer, dynamicBuffer, metaBuffers[i]], is_last);\n }\n return complete_promise; //wait to finish final kernel\n }\n // this._running = false;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.js\n// module id = 39\n// module chunks = 0","/**\n * @module webdnn/image\n * @preferred\n *\n * Module `WebDNN.Image` provides basic image processing operations like follows.\n *\n * - Load image by various way (File picker dialog, url string, canvas, video, etc.)\n * - Pack image data into TypedArray\n * - Crop and resize.\n * - Show result on canvas element\n *\n */\n/** Don't Remove This comment block */\n// export * from \"./image/canvas\" // internal API\nexport * from \"./image/enums\";\nexport * from \"./image/image_array\";\n// export * from \"./image/image_data\" // internal API\nexport * from \"./image/image_source\";\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image.js\n// module id = 40\n// module chunks = 0","/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\nimport { getContext2D } from \"./canvas\";\nimport { Color, Order } from \"./enums\";\nimport { getImageData, setImageDataToCanvas } from \"./image_data\";\nimport { loadImageByUrl, loadImageFromFileInput } from \"./image_source\";\n/**\n * @protected\n */\nfunction flatten(arr) {\n return (arr instanceof Array) ? Array.prototype.concat.apply([], arr.map(arr => flatten(arr))) : arr;\n}\n/**\n * @protected\n */\nfunction normalizeBiasTuple(arr) {\n if (typeof (arr) == \"number\") {\n return [arr, arr, arr, arr];\n }\n else {\n if (arr.length == 4) {\n return [arr[0], arr[1], arr[2], arr[3]];\n }\n else if (arr.length == 3) {\n return [arr[0], arr[1], arr[2], arr[0]];\n }\n else if (arr.length == 1) {\n return [arr[0], arr[0], arr[0], arr[0]];\n }\n else {\n throw new Error('bias and scale must be scalar number or array of length 1 or 3 or 4.');\n }\n }\n}\n/**\n * Get image array as `{Float32 or Int32}ArrayBufferView` from ImageData object.\n *\n * @returns {ArrayBufferView} buffer with specified type\n * @protected\n */\nexport function getImageArrayFromImageData(imageData, options = {}) {\n let { type = Float32Array, color = Color.RGB, order = Order.HWC, bias = [0, 0, 0], scale = [1, 1, 1] } = options;\n const bias_n = normalizeBiasTuple(bias);\n const scale_n = normalizeBiasTuple(scale);\n const width = imageData.width;\n const height = imageData.height;\n let data = imageData.data;\n let array;\n let biasR, biasG, biasB, biasA;\n let scaleR, scaleG, scaleB, scaleA;\n switch (color) {\n case Color.RGB:\n array = new type(width * height * 3);\n [scaleR, scaleG, scaleB] = scale_n;\n [biasR, biasG, biasB] = bias_n;\n switch (order) {\n case Order.HWC:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(h * width + w) * 3 + 0] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 3 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 3 + 2] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n }\n }\n break;\n case Order.CHW:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n }\n }\n break;\n }\n break;\n case Color.BGR:\n array = new type(width * height * 3);\n [biasR, biasG, biasB] = bias_n;\n [scaleR, scaleG, scaleB] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(h * width + w) * 3 + 0] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 3 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 3 + 2] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n }\n }\n break;\n case Order.CHW:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n }\n }\n break;\n }\n break;\n case Color.RGBA:\n array = new type(width * height * 4);\n [scaleR, scaleG, scaleB, scaleA] = scale_n;\n [biasR, biasG, biasB, biasA] = bias_n;\n switch (order) {\n case Order.HWC:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(h * width + w) * 4 + 0] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 4 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 4 + 2] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 4 + 3] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n case Order.CHW:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(3 * height + h) * width + w] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n }\n break;\n case Color.BGRA:\n array = new type(width * height * 4);\n [biasR, biasG, biasB, biasA] = bias_n;\n [scaleR, scaleG, scaleB, scaleA] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(h * width + w) * 4 + 0] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 4 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 4 + 2] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 4 + 3] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n case Order.CHW:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(3 * height + h) * width + w] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n }\n break;\n case Color.GREY:\n array = new type(width * height);\n [scaleR, scaleG, scaleB] = scale_n;\n [biasR, biasG, biasB] = bias_n;\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n let r = data[(h * width + w) * 4 + 0];\n let g = data[(h * width + w) * 4 + 1];\n let b = data[(h * width + w) * 4 + 2];\n array[h * width + w] = 0.2126 * (r - biasR) / scaleR + 0.7162 * (g - biasG) / scaleG + 0.0722 * (b - biasB) / scaleB;\n }\n }\n break;\n default:\n throw Error(`Unknown color format: ${color}`);\n }\n return array;\n}\n/**\n * Get image array from canvas element as `{Float32 or Int32}ArrayBufferView`.\n *\n * @returns {ImageData} buffer with specified type\n * @protected\n */\nexport function getImageArrayFromCanvas(canvas, options = {}) {\n let { type = Float32Array, color = Color.RGB, order = Order.HWC, srcX = 0, srcY = 0, srcW = canvas.width, srcH = canvas.height, dstX = 0, dstY = 0, bias = [0, 0, 0], scale = [1, 1, 1] } = options;\n let { dstW = srcW, dstH = srcH } = options;\n let imageData = getImageData(canvas, { srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH });\n return getImageArrayFromImageData(imageData, { type, color, order, bias, scale });\n}\n/**\n * Get image array from image element as `{Float32 or Int32}ArrayBufferView`.\n *\n * @returns {ImageData} buffer with specified type\n * @protected\n */\nexport function getImageArrayFromDrawable(drawable, options = {}) {\n let srcW, srcH;\n if (drawable instanceof HTMLVideoElement) {\n srcW = drawable.videoWidth;\n srcH = drawable.videoHeight;\n }\n else if (drawable instanceof HTMLImageElement) {\n srcW = drawable.naturalWidth;\n srcH = drawable.naturalHeight;\n }\n else if (drawable instanceof HTMLCanvasElement) {\n return getImageArrayFromCanvas(drawable, options);\n }\n else if (drawable instanceof ImageData) {\n return getImageArrayFromImageData(drawable, options);\n }\n else\n throw TypeError('Failed to execute \"getImageDataFromDrawable(drawable, options)\": \"drawable\" must be an instanceof Drawable');\n let { type = Float32Array, color = Color.RGB, order = Order.HWC, srcX = 0, srcY = 0, dstX = 0, dstY = 0, dstW = srcW, dstH = srcH, bias = [0, 0, 0], scale = [1, 1, 1] } = options;\n let canvas = document.createElement('canvas');\n canvas.width = dstX + dstW;\n canvas.height = dstY + dstH;\n let context = getContext2D(canvas);\n context.drawImage(drawable, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);\n return getImageArrayFromCanvas(canvas, { type, color, order, bias, scale });\n}\n/**\n * Create typed array by packing image data from image source with specified options.\n *\n * First, this method loads specified image resource. The behavior of this method depends on the `image` argument.\n *\n * - If `image` is an instance of `string`, it will be regarded as image url, and this method fetches that url.\n *\n * - If `image` is an instance of `HTMLInputElement`, it will be regarded as file input,\n * and this method loads the selected image file.\n *\n * - Otherwise, `image` will be regarded as drawable object.\n *\n * Then, loaded images are packed into typed array based on `options` argument.\n *\n * - The image is cropped based on [[SourceRect|`{srcX, srcY, srcW, srcH}`]].\n * As default, entire image is used.\n *\n * - The image is resized and translated into [[DestinationRect|`{dstX, dstY, dstW, dstH}`]].\n * As default, no resize and translation is performed.\n *\n * - [[ImageArrayOption.type|`options.type`]] is the type of packed typed array. As default, Float32Array is used.\n *\n * - [[ImageArrayOption.type|`options.color`]] is the color format of packed typed array. As default, [[Color.RGB|`RGB`]] is used.\n *\n * - [[ImageArrayOption.type|`options.order`]] is the data order of packed typed array. As default, [[Order.HWC|`HWC`]] is used.\n *\n * - [[ImageArrayOption.bias|`options.bias`]] is the bias value.\n * If specified, this method **subtracts** this value from original pixel value.\n *\n * - [[ImageArrayOption.scale|`options.scale`]] is the scale value. If specified, original pixel values are **divided** by this value.\n * [[ImageArrayOption.scale|`options.scale`]] and [[ImageArrayOption.bias|`options.bias`]] is used for converting pixel value `x` and\n * packed value `y` as follows:\n *\n * - `y = (x - bias) / scale`\n * - `x = y * scale + bias`\n * - Note that color order is always RGB, not BGR.\n *\n * ### Examples\n *\n * - Load image of specified url\n *\n * ```ts\n * let image = await WebDNN.Image.load('./cat.png');\n * ```\n *\n * - Load image selected in file input and resize it into 224 x 224\n *\n * ```ts\n * let input = document.querySelector('input[type=file]');\n * let image = await WebDNN.Image.load(input, { dstW: 224, dstH: 224 });\n * ```\n *\n * - Load image data from canvas, normalize it into range `[-1, 1)`. In this case, normalized value `y` can be\n * calculated from pixel value `x` as follows: `y = (x - 128) / 128`.\n *\n * ```ts\n * let canvas = document.getElementsByTagName('canvas')[0];\n * let image = await WebDNN.Image.load(canvas, { bias: [128, 128, 128], scale: [128, 128, 128] });\n * ```\n *\n * @param image please see above descriptions\n * @param options please see above descriptions.\n * @returns Created typed array\n */\nexport async function getImageArray(image, options = {}) {\n if (typeof image === 'string') {\n return getImageArrayFromDrawable(await loadImageByUrl(image), options);\n }\n else if (image instanceof HTMLInputElement) {\n return getImageArrayFromDrawable(await loadImageFromFileInput(image), options);\n }\n else if (image instanceof HTMLCanvasElement) {\n return getImageArrayFromCanvas(image, options);\n }\n else if (image instanceof HTMLImageElement || image instanceof HTMLVideoElement || image instanceof ImageData) {\n return getImageArrayFromDrawable(image, options);\n // FIXME: This feature is not supported for all web browsers.\n // } else if (image === null) {\n // return getImageArrayFromDrawable(await loadImageByDialog(), options);\n }\n else\n throw TypeError('Failed to execute \"getImageData(image, options)\": \"image\" must be an instance of string,' +\n ' HTMLInputElement, HTMLCanvasElement, HTMLImageElement, HTMLVideoElement, or ImageData object');\n}\n/**\n * Set image array data into canvas.\n *\n * ### Examples\n *\n * - Show DNN model's result\n *\n * ```ts\n * let runner = await WebDNN.load('./model');\n * let output = runner.outputs[0];\n *\n * await runner.run();\n *\n * WebDNN.Image.setImageArrayToCanvas(output.toActual(), 256, 256, document.getElementById('canvas'))\n * ```\n *\n * - Generally image generation model's result contains noise pixel at their edge because of convolution's padding.\n * In follow example, these noise are cut off.\n *\n * ```ts\n * WebDNN.Image.setImageArrayToCanvas(output, 256, 256, canvas, {\n * srcX: 16, srcY: 16, srcH: 256-16*2, srcW: 256-16*2, // Discard both ends 16px\n * dstW: 256, dstH: 256 // Resize cropped image into original output size.\n * });\n * ```\n *\n * @param array array which contains image data\n * @param imageW width of image\n * @param imageH height of image. The length of `array` must be `imageW * imageH * (# of channels)`\n * @param canvas destination canvas\n * @param options please see above descriptions and descriptions in [[webdnn/image.getImageArray|getImageArray()]].\n * `srcW` and `srcH` is ignored (overwritten by `imageW` and `imageH`).\n */\nexport function setImageArrayToCanvas(array, imageW, imageH, canvas, options = {}) {\n let { color = Color.RGB, order = Order.HWC, srcX = 0, srcY = 0, dstX = 0, dstY = 0, dstW = canvas.width, dstH = canvas.height, bias = [0, 0, 0], scale = [1, 1, 1] } = options;\n const bias_n = normalizeBiasTuple(bias);\n const scale_n = normalizeBiasTuple(scale);\n let srcW = imageW, srcH = imageH;\n array = flatten(array);\n let data = new Uint8ClampedArray(srcW * srcH * 4);\n let biasR, biasG, biasB, biasA;\n let scaleR, scaleG, scaleB, scaleA;\n switch (color) {\n case Color.RGB:\n [biasR, biasG, biasB] = bias_n;\n [scaleR, scaleG, scaleB] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 0] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 2] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n case Order.CHW:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(0 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(2 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n break;\n case Color.BGR:\n [biasR, biasG, biasB] = bias_n;\n [scaleR, scaleG, scaleB] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 2] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 0] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n case Order.CHW:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(2 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(0 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n break;\n case Color.RGBA:\n [biasR, biasG, biasB, biasA] = bias_n;\n [scaleR, scaleG, scaleB, scaleA] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 0] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 2] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(h * imageW + w) * 3 + 3] * scaleA + biasA;\n }\n }\n break;\n case Order.CHW:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(0 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(2 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(3 * imageH + h) * imageW + w] * scaleA + biasA;\n }\n }\n break;\n }\n break;\n case Color.BGRA:\n [biasR, biasG, biasB, biasA] = bias_n;\n [scaleR, scaleG, scaleB, scaleA] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 4 + 2] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 4 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 4 + 0] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(h * imageW + w) * 4 + 3] * scaleA + biasA;\n }\n }\n break;\n case Order.CHW:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(2 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(0 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(3 * imageH + h) * imageW + w] * scaleA + biasA;\n }\n }\n break;\n }\n break;\n case Color.GREY:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] =\n data[(h * imageW + w) * 4 + 1] =\n data[(h * imageW + w) * 4 + 2] = array[h * imageW + w] * scale[0] + bias[0];\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n setImageDataToCanvas(new ImageData(data, srcW, srcH), canvas, { srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH });\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_array.js\n// module id = 41\n// module chunks = 0","/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\nimport { getContext2D } from \"./canvas\";\n/**\n * @protected\n */\nexport function getImageDataFromCanvas(canvas, options = {}) {\n let { srcX = 0, srcY = 0, srcW = canvas.width, srcH = canvas.height, dstX = 0, dstY = 0 } = options;\n let { dstW = srcW, dstH = srcH } = options;\n let imageData = getContext2D(canvas).getImageData(srcX, srcY, srcW, srcH);\n if (dstX !== 0 || dstY !== 0 || srcW !== dstW || srcH !== dstH) {\n imageData = cropAndResizeImageData(imageData, { dstX, dstY, dstW, dstH });\n }\n return imageData;\n}\n/**\n * @protected\n */\nexport function getImageDataFromDrawable(drawable, options = {}) {\n let srcW, srcH;\n if (drawable instanceof HTMLVideoElement) {\n srcW = drawable.videoWidth;\n srcH = drawable.videoHeight;\n }\n else if (drawable instanceof HTMLImageElement) {\n srcW = drawable.naturalWidth;\n srcH = drawable.naturalHeight;\n }\n else\n throw TypeError('Failed to execute \"getImageDataFromDrawable(drawable, options)\": \"drawable\" must be an instanceof HTMLVideoElement or HTMLImageElement');\n let { srcX = 0, srcY = 0, dstX = 0, dstY = 0, dstW = srcW, dstH = srcH } = options;\n let canvas = document.createElement('canvas');\n canvas.width = dstX + dstW;\n canvas.height = dstY + dstH;\n let context = getContext2D(canvas);\n context.drawImage(drawable, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);\n return context.getImageData(0, 0, dstX + dstW, dstY + dstH);\n}\n/**\n * Source rectangle of source image is cropped and then copied into destination rectangle of new image data\n *\n * @param {ImageData} src\n * @param {SourceRect & DestinationRect} options\n * @returns {ImageData}\n * @protected\n */\nfunction cropAndResizeImageData(src, options = {}) {\n let { srcX = 0, srcY = 0, srcW = src.width, srcH = src.height, dstX = 0, dstY = 0 } = options;\n let { dstW = srcW, dstH = srcH } = options;\n let canvas1 = document.createElement('canvas');\n canvas1.width = srcW;\n canvas1.height = srcH;\n let context1 = getContext2D(canvas1);\n context1.putImageData(src, -srcX, -srcY);\n let canvas2 = document.createElement('canvas');\n canvas2.width = dstX + dstW;\n canvas2.height = dstY + dstH;\n let context2 = getContext2D(canvas2);\n context2.drawImage(canvas1, 0, 0, srcW, srcH, dstX, dstY, dstW, dstH);\n return context2.getImageData(0, 0, dstX + dstW, dstY + dstH);\n}\n/**\n * Return canvas `ImageData` object with specified scale.\n *\n * @param {HTMLCanvasElement | HTMLVideoElement | HTMLImageElement} image\n * @param [options] Options\n * @param {number} [options.srcX=0] left position of input clipping rect\n * @param {number} [options.srcY=0] top position of input clipping rect\n * @param {number} [options.srcW=canvas.width] width of input clipping rect\n * @param {number} [options.srcH=canvas.height] height of input clipping rect\n * @param {number} [options.dstW=options.srcW] width of output\n * @param {number} [options.dstH=options.srcH] height of output\n * @returns {ImageData}\n * @protected\n */\nexport function getImageData(image, options = {}) {\n if (image instanceof HTMLCanvasElement) {\n return getImageDataFromCanvas(image, options);\n }\n else if (image instanceof HTMLVideoElement || image instanceof HTMLImageElement) {\n return getImageDataFromDrawable(image, options);\n }\n else\n throw TypeError('Failed to execute \"getImageData(image, options)\": \"image\" must be an instance of HTMLCanvasElement, HTMLVideoElement, or HTMLImageElement');\n}\n/**\n * @protected\n */\nexport function setImageDataToCanvas(imageData, canvas, options = {}) {\n let { srcX = 0, srcY = 0, srcW = imageData.width, srcH = imageData.height, dstX = 0, dstY = 0 } = options;\n let { dstW = srcW, dstH = srcH } = options;\n if (srcX !== 0 || srcY !== 0 || srcW !== dstW || srcH !== dstH) {\n imageData = cropAndResizeImageData(imageData, { srcX, srcY, srcW, srcH, dstW, dstH });\n }\n getContext2D(canvas).putImageData(imageData, dstX, dstY);\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_data.js\n// module id = 42\n// module chunks = 0","/**\n * @module webdnn/math\n * @preferred\n *\n * Module `WebDNN.Math` provides basic mathematics operations for pre/post-processing.\n */\n/** Don't Remove This comment block */\nexport * from \"./math/argsort\";\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/math.js\n// module id = 43\n// module chunks = 0","/**\n * @module webdnn/math\n */\n/** Don't Remove This comment block */\n/**\n * Return indices of the top-K largest elements.\n * This implementation is not stable sort.\n *\n * @param {number[]|Float32Array} arr array\n * @param {number} k number of indices\n * @returns {number[]} indices of top-K largest samples\n */\nexport function argmax(arr, k = 1) {\n // Top-k Quicksort\n arr = arr.slice();\n let stack = [[0, arr.length]];\n let workspace = [];\n for (let i = 0; i < arr.length; i++)\n workspace[i] = i;\n while (stack.length > 0) {\n let [from, to] = stack.pop(), pivot = arr[to - 1], left = from, right = to - 2, tmp;\n if (from >= to - 1)\n continue;\n while (true) {\n while (arr[left] > pivot && left <= right)\n left++;\n while (arr[right] <= pivot && left <= right)\n right--;\n if (left >= right)\n break;\n tmp = arr[left];\n arr[left] = arr[right];\n arr[right] = tmp;\n tmp = workspace[left];\n workspace[left] = workspace[right];\n workspace[right] = tmp;\n }\n arr[to - 1] = arr[left];\n arr[left] = pivot;\n tmp = workspace[to - 1];\n workspace[to - 1] = workspace[left];\n workspace[left] = tmp;\n // If partial segment contains top-K elements, append it into stack\n stack.push([from, left]); // left (=larger) segment always contains top-K elements\n if (left + 1 < k)\n stack.push([left + 1, to]);\n }\n let result = [];\n for (let i = 0; i < k; i++)\n result.push(workspace[i]);\n return result;\n}\n/**\n * Return indices of the top-K smallest elements.\n * This implementation is not stable sort.\n *\n * @param {number[]|Float32Array|Int32Array} arr array\n * @param {number} k number of indices\n * @returns {number[]} indices of top-K smallest samples\n */\nexport function argmin(arr, k = 1) {\n // Top-k Quicksort\n arr = arr.slice();\n let stack = [[0, arr.length]];\n let workspace = [];\n for (let i = 0; i < arr.length; i++)\n workspace[i] = i;\n while (stack.length > 0) {\n let [from, to] = stack.pop(), pivot = arr[to - 1], left = from, right = to - 2, tmp;\n if (from >= to - 1)\n continue;\n while (true) {\n while (arr[left] < pivot && left <= right)\n left++;\n while (arr[right] >= pivot && left <= right)\n right--;\n if (left >= right)\n break;\n tmp = arr[left];\n arr[left] = arr[right];\n arr[right] = tmp;\n tmp = workspace[left];\n workspace[left] = workspace[right];\n workspace[right] = tmp;\n }\n arr[to - 1] = arr[left];\n arr[left] = pivot;\n tmp = workspace[to - 1];\n workspace[to - 1] = workspace[left];\n workspace[left] = tmp;\n // If partial segment contains top-K elements, append it into stack\n stack.push([from, left]); // left (=larger) segment always contains top-K elements\n if (left + 1 < k)\n stack.push([left + 1, to]);\n }\n let result = [];\n for (let i = 0; i < k; i++)\n result.push(workspace[i]);\n return result;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/math/argsort.js\n// module id = 44\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 65d0ace7d910bc9a46b6","webpack:///./node_modules/pako/lib/utils/common.js","webpack:///./src/descriptor_runner/fetch.js","webpack:///./src/descriptor_runner/webdnn.js","webpack:///./node_modules/localforage/dist/localforage.js","webpack:///./src/descriptor_runner/decoder/get_weight_decoder.js","webpack:///./src/descriptor_runner/placeholder.js","webpack:///./src/descriptor_runner/symbolic_typed_array/symbolic_float32array.js","webpack:///./src/descriptor_runner/descriptor_runner/descriptor_runner.js","webpack:///./node_modules/pako/lib/zlib/messages.js","webpack:///./node_modules/pako/lib/zlib/adler32.js","webpack:///./node_modules/pako/lib/zlib/crc32.js","webpack:///./node_modules/pako/lib/utils/strings.js","webpack:///./node_modules/pako/lib/zlib/zstream.js","webpack:///./node_modules/pako/lib/zlib/constants.js","webpack:///./src/descriptor_runner/webgl_handler.js","webpack:///./src/descriptor_runner/buffer/buffer.js","webpack:///./src/descriptor_runner/buffer/buffer_webgpu.js","webpack:///./src/descriptor_runner/webgpu_handler.js","webpack:///./src/descriptor_runner/image/enums.js","webpack:///./src/descriptor_runner/image/canvas.js","webpack:///./src/descriptor_runner/image/image_source.js","webpack:///./src/descriptor_runner/descriptor_runner/descriptor_runner_fallback.js","webpack:///(webpack)/buildin/global.js","webpack:///./src/descriptor_runner/decoder/weight_decoder_eightbit.js","webpack:///./node_modules/pako/index.js","webpack:///./node_modules/pako/lib/deflate.js","webpack:///./node_modules/pako/lib/zlib/deflate.js","webpack:///./node_modules/pako/lib/zlib/trees.js","webpack:///./node_modules/pako/lib/inflate.js","webpack:///./node_modules/pako/lib/zlib/inflate.js","webpack:///./node_modules/pako/lib/zlib/inffast.js","webpack:///./node_modules/pako/lib/zlib/inftrees.js","webpack:///./node_modules/pako/lib/zlib/gzheader.js","webpack:///./src/descriptor_runner/decoder/weight_decoder_raw.js","webpack:///./src/descriptor_runner/util/dispatch_scheduler.js","webpack:///./src/descriptor_runner/symbolic_typed_array/symbolic_typed_array.js","webpack:///./src/descriptor_runner/descriptor_runner/descriptor_runner_webassembly.js","webpack:///./src/descriptor_runner/descriptor_runner/descriptor_runner_webgl.js","webpack:///./src/descriptor_runner/buffer/buffer_webgl.js","webpack:///./src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.js","webpack:///./src/descriptor_runner/image.js","webpack:///./src/descriptor_runner/image/image_array.js","webpack:///./src/descriptor_runner/image/image_data.js","webpack:///./src/descriptor_runner/math.js","webpack:///./src/descriptor_runner/math/argsort.js"],"names":[],"mappings":"AAAA,cACA,2BACA,uCACA,sCACA,IACA,aACA,wCAEA,aACA,GAAC,2EACD,kBCTA,cAMA,IACA,iBAGA,mBACA,CACA,IACA,KAIA,2CAGA,aAGA,OACA,OAIA,IAzBA,eA4BA,MAGA,uBACA,GACA,kCACA,CACA,gBACA,cAGA,OAGA,iBACA,YACA,qBAA2B,UAA0B,UACrD,YAAiC,CAAe,QAChD,EAEA,aADA,QAIA,mBAAsD,wCAA+D,SAGrH,MAGA,4BC7DA,aAOA,eACA,wCACA,UANA,MACA,gCACA,gEAMA,oBACA,gDACA,aACA,SACA,QAEA,SACA,yCAGA,6BACA,QACA,cAGA,MAEA,CACA,QAGA,EACA,yBACA,UACA,eAAqB,oBACrB,QAEA,aAGA,MACA,6BACA,kBACA,SAIA,+BAHA,kBAGmB,EAAS,IAC5B,aAEA,IAEA,2BACA,eAGA,QACA,UAAkC,OAAO,IACzC,YAIA,gBACA,iBACA,WAAkC,QAAO,IACzC,MACA,OACA,cAGA,OACA,QAGA,KACA,6BACA,WAAmB,EAAS,IAC5B,aAEA,IAEA,2BACA,iBACA,WAKA,GACA,sBAEA,WACA,mBACA,oBACA,aAEA,qBACA,cACA,cACA,QAEA,cAEA,4CC1FA,aACA,OACA,KAKA,CAuEA,YACA,oEACA,YAEA,kBACA,mBACA,mCACA,uBACA,OACA,uBACA,SACA,CACA,QAGA,KAEA,SAIA,CACA,eACA,iCACA,UACA,uBACA,2BACA,gBACA,wBACA,GACA,qCACA,UACA,IACA,0BAEA,wBAAuD,qBAA4C,MAEnG,EACA,uBACA,CACA,IACA,SACA,KACA,aAjHA,WACA,CACA,GASA,MACA,mBACA,GACA,2DAGA,WAAgC,YAChC,iDAGA,SACA,4BACA,mBAGA,uBAEA,eACA,gDAAqD,QAAW,KAAI,YACpE,IACA,QAOA,EA5DA,IA6DA,aACA,cAWA,gBACA,oBAEA,wBAEA,QACA,QACA,kBAGA,iBAEA,OACA,WAvBA,cACA,kCACA,qBACA,YACA,sBACA,qBACA,iBACA,WACA,iBACA,qBAeA,OAIA,UApFA,IACA,MAKA,qCC6BA,YACA,OACA,iBACA,kCACA,8CACA,wCAEA,+EACA,YACA,CACA,SAEA,eAIA,CACA,qBACA,MACA,wBAA6C,sBAC7C,QACA,MACA,MACA,iBACA,MACA,SACA,qBAA6C,yBAAwB,cACrE,IACA,IACA,CACA,QA8BA,qEAtFA,aACA,eACA,MAIA,qBACA,aACA,CACA,MAIA,oCA0EA,iBAAqD,KACrD,IAAS,qBAAyC,iGAElD,wCACA,cACA,uBACA,SACA,SACA,6BACA,iCAEA,iBACA,cAIA,oBAGA,sBACA,SACA,oBACA,MAEA,SACA,IACA,GACA,EACA,EACA,EACA,cACA,mDACA,gBACA,oDACA,eACA,cAEA,gCAEA,MACA,OACA,cAEA,wBAEA,MACA,OACA,cAEA,gCAEA,kBACA,wDACA,kBACA,eAEA,0CADA,UAEA,cAEA,wBAEA,SACA,8BACA,6DAEA,aADA,+BAEA,cAEA,gCAEA,kBACA,wDACA,gBACA,aAEA,aADA,+BAEA,cAEA,gCAEA,SACA,4BACA,mDAEA,0CADA,UAEA,cAEA,wBAEA,kBACA,oDACA,oBAAoC,KAEpC,yHACA,QACA,SACA,gBACA,SAEA,CAEA,SACA,+BACA,SACA,cAAqD,6BAAY,kCAAiC,SAClG,IACA,QACA,CACA,SACA,iBACA,0BAEQ,iIA7MR,GACA,GAIA,MAeA,QACA,QACA,UACA,gBACA,aAOA,sCCzCA,KAKA;;;;;EACA,YAAa,CAA2D,UAAwO,GAAqB,aAAa,CAA0B,yBAA0B,gBAAgB,UAAU,SAAU,CAA0C,8CAAwB,oBAAoB,gDAA8C,iCAAqC,aAAY,YAAY,mCAAmC,iBAAiB,eAAgB,sBAAsB,oBAAoB,CAA0C,sCAAY,WAAW,YAAY,QAAS,GAAG,iBAClzB,aACA,aA+CA,YACA,CACA,iBAEA,SADA,KAEA,KACA,IACA,QACA,EACA,OAEA,WACA,MACA,CACA,KA5DA,4BAEA,uBAGA,OACA,OACA,IACA,qCACA,gBACA,CAEA,+BACA,cACA,CACA,CAAG,+DACH,aACA,uBACA,wBACA,qBACA,EACA,CAAG,wEACH,oBAIA,gCACA,yCACA,CAEA,yBACA,kBACA,iBACA,IACA,6BACA,cAEA,YACA,cACA,EAEA,EAEA,GAEA,MADA,EAkBA,UACA,WACA,CACA,kBAEA,GAEA,CAAC,0FACD,cAAI,uBACJ,aAIA,aAEA,CAQA,aACA,IACA,yCAEA,oCACA,aACA,0BACA,GACA,SAEA,QAoBA,iBACA,MACA,UACA,4BACA,sCAEA,oBACA,4BACA,oCAEA,mBAcA,iBACA,aACA,IACA,MACA,GACA,IAAK,SACL,UACA,WACA,CACA,+BAEA,yCAEA,YACA,GAiCA,aAEA,YACA,uDACA,sCACA,WACA,UAEA,EAEA,eAEA,cAKA,KACA,OACA,YAEA,cAIA,KACA,OACA,aAEA,IAhBA,QAqBA,YAJA,CACA,MAEA,GAEA,wBAEA,OAEA,eACA,IACA,SACA,SACA,cACA,SAAG,SACH,UACA,UACA,OACA,CACA,SAnKA,QAEA,GAKA,KACA,eACA,8BAEA,YAcA,gCACA,kBACA,SACA,8BACA,+BACA,sCACA,gBAEA,qBACA,iCACA,YACA,yBACA,QACA,sBAGA,cACA,UAYA,qCACA,gBACA,YACA,0CACA,qBACA,gBACA,oCACA,eACA,YACA,yCACA,qBACA,eAkBA,uBACA,OACA,UACA,uCAEA,eAEA,MACA,KACG,WACH,GACA,UACA,qBACA,YACA,OACA,kBAEA,gBACA,CACA,UACA,sBACA,GACA,UACA,qBACA,YACA,OACA,kBAEA,gBACA,UAqDA,UACA,WACA,oBAGA,qBACA,aAEA,SACA,WACA,UACA,kBACA,aAEA,MACA,WACA,gBAqBA,8BAOA,CACA,OACA,aACA,OAEA,aACA,aAXA,KACA,OAEA,YACA,EAQA,OAlCA,QACA,sFAGA,6BACA,OACA,QACA,eAGA,sBACA,WACA,KACA,OAEA,SACA,SAEA,QACA,UAiBA,OACA,WACA,cAmBA,8BAEA,KACA,OAEA,aAAK,aAEL,KACA,OAEA,YACA,EACA,OA9BA,QACA,sFAGA,6BACA,OACA,QACA,eAGA,uBACA,OAEA,SACA,SAEA,MACA,QAeA,CAAS,wBACT,aAEA,aACA,2CAGA,GAAC,0FACD,cAAS,0BACT,aAIA,eAAiD,MAA0C,oCAA4D,qCA6DvJ,eAEA,GACA,QACA,SACA,WACA,UAAK,SACL,IACA,qBAEA,uHACA,6DACA,QAAuB,MAAkB,UACzC,WAEA,yBACA,KACA,CAIA,CAOA,eAEA,sBACA,GACA,OAAS,aACT,CACA,IAEA,GAEA,iBACA,CACA,wBAGA,QACA,wBAEA,YAEA,aAEA,CAMA,MALA,oCAIA,mDAMA,CAcA,aACA,aACA,YACA,qBACA,iBAAmB,EAAY,IAC/B,WAEA,cACA,QAgBA,CACA,aACA,yBACA,SACA,mBACA,+BAEA,4BAGA,GACA,mBACA,kBACA,KAEA,yBACA,iCACA,6CAGA,mBACA,sBACA,CAAK,sBACL,CACA,QACA,GAEA,aACA,OACA,uBAEA,iCACA,CAEA,MADA,QAEA,GAEA,aACA,YAGA,MAEA,gCACA,GACA,SAGA,wBAGA,oBACA,iCAGA,UACA,OAEA,KAJA,QAMA,aACA,YAGA,6BAKA,WAEA,UAEA,eACA,YAGA,6BAKA,WAEA,UAEA,eACA,2BAEA,MACA,GACA,KACA,UAEA,wBAIA,aAGA,kBAGA,sBAGA,4CACA,SACA,UACA,uBACA,WAEA,mBAEA,oBAAiB,SACjB,IACA,+KAEA,yBAEA,QACA,CAGA,wBACA,GACA,qBACA,MAEA,wBACA,KACA,QACA,IACA,CACA,GAEA,aACA,OACA,SAEA,aACA,OACA,SAEA,eACA,OACA,GAGA,iDACA,4BACA,yBAKA,iBACA,+HAGA,oBAGA,cAIA,MACA,oBACA,MACA,YAEA,UAEA,CACA,QAEA,CACA,QAEA,CACA,aACA,2BACA,UACA,cACA,iCACA,6BACA,MACA,CACA,+BACA,cAEA,MACA,IACA,qBACA,EAEA,CACA,aACA,gBACA,oBAAoC,QACpC,MAEA,CACA,aACA,aACA,2BAKA,CACA,aACA,OAEA,qCACA,oBAEA,cACA,iBAEA,OAEA,GAEA,MADA,WAKA,CACA,aACA,CAEA,oBACA,UAEA,UAAmB,MAAoB,OACvC,iBACA,qBACA,wBAIA,qCACA,WAAuB,MAAoB,OAC3C,iBAEA,IAAK,uBACL,CAEA,KADA,SAEA,EAGA,CACA,iBACA,IACA,0BACA,eACA,OAAK,SACL,WACA,wDAEA,0BACA,eACA,OAGA,GACA,IACA,CAGA,CA+fA,aAEA,OACA,kBACA,SAEA,EADA,QAGA,EACA,sBACA,IACA,qBAIA,cACA,qBAEA,qBAAe,EAAS,OACxB,cACA,sBACA,oBACA,oBAGA,mBACA,sBACA,kBAEA,KACA,QAGA,CACA,aAEA,UACA,iBACA,GAEA,QAAe,MAAkB,UAEjC,aACA,4BACA,+BACA,QAGA,WAOA,MANA,2CACK,IACL,4CAGA,OAKA,CAqQA,mBACA,OAEA,OAEA,8BACA,0BAIA,CACA,eAIA,SAEA,SACA,8CAEA,GAEA,iCACA,kGACA,CACA,IAAyB,eACzB,CACA,IACA,EAAqB,aAGrB,yBAQA,IACA,IAGA,iCAFA,KAGA,IACA,CAEA,EACA,EAAS,GACT,WAEA,GAEA,MADA,UAyJA,YACA,OAEA,+BACA,CAIA,oBAHA,2BAEA,gBACK,SACL,CACA,QACA,CAKA,CACA,YACA,aACA,qBAEA,CAuRA,eACA,gBACA,OACA,0CACA,aACA,UACA,EACA,EAEA,YACA,WAAmB,gBAAsB,OACzC,IAGA,KADA,sBAEA,UACA,uCACA,WAEA,QAOA,uBACA,EAEA,CAzwDA,6EAAoG,OAAmB,SAAE,aAAmB,4FAA8H,YAI1Q,UAEA,IACA,IACA,oCAEA,cACA,0CAEA,oBACA,uCAEA,iBACA,qCAEA,eACA,sCAEA,YAAK,SAEL,CACA,CAEA,IA4DA,+BACA,GACA,gBAoCA,sDAKA,WACA,aAMA,cA8vBA,SACA,eACA,aApdA,WACA,aAkDA,UACA,SAEA,OApDA,OACA,IAGA,MACA,YACA,aAMA,UAIA,kBAIA,YAEA,CAEA,cAEA,aAEA,KAGA,4BAIA,mBAGA,UACA,4BACA,QAIA,gBAEA,QAMmB,gBAA8B,OACjD,QACA,WAEA,6BAKA,mCAIA,kCACA,eAEA,GACA,IAAK,mBACL,UACA,0BAEA,SAGA,MAAK,mBACL,QACA,OAEA,oBAAuB,QAAoB,OAC3C,MACA,KAEA,uBACA,uBAGA,QACA,aAnfA,UACA,IAGA,IACA,GAMA,0KAEA,uCAIA,4DAKA,+BACA,+BAAK,SACL,CACA,QACA,CAOA,CA40BA,GACA,QA/UA,aACA,OAEA,0BACA,0BACA,4BACA,CACA,WAGA,SACA,+BACA,eACA,eAEA,wBACA,SAEA,YACA,SACA,MACA,SAEA,sBAKA,SACA,SAIA,cAFA,IAGA,KAEA,IAEA,sBACA,KACA,MACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAGA,MADA,WA8RA,QA1XA,aACA,OAEA,OAEA,8BACA,0BACA,4BACA,CACA,WAGA,SACA,+BACA,eAEA,6BACA,SACA,OACA,eAEA,MACA,SAEA,MACA,IAEA,sBACA,KACA,MACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,SAGA,EAkVA,QA5RA,eACA,OAEA,OAEA,8BACA,IACA,4BACA,YACA,QACA,oDAIA,YACA,IAGA,IAAS,mBACT,4BACA,CACA,WAGA,SACA,+BAMA,WACA,WAGA,kBAEA,gCAOA,CACA,eAGA,MACA,IACA,gCACA,qCACA,MACA,IACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,WA+NA,WA5NA,aACA,OAEA,OAEA,8BACA,0BACA,4BACA,CACA,WAGA,SACA,+BAMA,eACA,oCACA,CACA,GAEA,sBACA,KACA,MAIA,sBACA,qCACA,MACA,IACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,WAmLA,MAhLA,WACA,OAEA,0BACA,0BACA,4BACA,CACA,WAGA,SACA,+BACA,eAEA,+BACA,CACA,GAEA,gCACA,qCACA,MACA,IACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,WAmJA,OAhJA,WACA,OAEA,0BACA,0BACA,4BACA,CACA,WAGA,SACA,+BACA,eAEA,8BACA,KACA,OAEA,sBACA,KACA,MACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,WAoHA,IAjHA,aACA,OAEA,0BACA,OACA,YAKA,oCACA,4BACA,CACA,WAGA,SACA,+BACA,WACA,SAEA,mCACA,SAGA,qBAQA,UAKA,WAOA,MANA,OAGA,oBAZA,KAiBA,sBACA,KACA,MACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,WAwDA,KArDA,WACA,OAEA,0BACA,0BACA,4BACA,CACA,WAGA,SACA,+BACA,eACA,aAEA,2BACA,SAGA,8BAKA,OACA,mBAFA,KAIA,sBACA,KACA,MACA,CAAiB,SACjB,CACA,IACA,CACA,EAAS,GACT,WAEA,GAEA,MADA,SAGA,KAuBA,qEAGA,kCACA,gBAGA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,aAEA,uCAkMA,CACA,UArIA,aACA,OAEA,eAOA,+FAGA,IAGA,KAFA,cAGA,cACA,IAEA,WAEA,OACA,yBACa,KACb,0BACa,KACb,iCACa,KACb,0BACa,KACb,2BACa,KACb,0BACa,KACb,2BACa,KACb,4BACa,KACb,4BAEA,iBAIA,4CACA,KAAK,6BAEL,UAEA,+BAEA,OArIA,yCAuIA,UACA,MAEA,IACA,oBACA,SACA,QACA,aAAS,SACT,eAEA,oDACA,OAEA,CASA,EA0DA,YAzDA,WAIA,gBACA,qBAMA,iBACA,iBAEA,eAGA,sBACA,SACA,aACA,sBACA,OACA,OAIA,KACA,UACA,OACA,SACA,oBAAyC,CACzC,SACA,iBACA,cACA,iBACA,eACA,iBACA,sBACA,iBACA,eACA,iBACA,gBACA,iBACA,eACA,iBACA,gBACA,iBACA,iBACA,iBACA,iBACA,wBAEA,oBAEA,EAIA,iBAaA,qBAuSA,SACA,gBACA,aAxSA,WACA,OACA,OACA,IAGA,MACA,YACA,mCAIA,8CAGA,IACA,uDACA,KAAS,SACT,OACA,KAGA,6BACA,oHACA,GACA,UACA,GAAa,eACb,CACA,IACA,EACA,EAEA,GAEA,SADA,0BAjRA,UACA,OACA,+BAKA,CAkhBA,GACA,QAvOA,aACA,OAEA,0BACA,0BACA,SAEA,oCACA,2DACA,aACA,SAEA,SAAmC,EAAY,QAC/C,SACA,YAKA,4BAGA,8BAIA,OACA,OAGA,WAFA,KAIA,CACA,GAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,WA+LA,QAvQA,aACA,OAEA,OAEA,8BACA,0BACA,SACA,oCACA,qFACA,0CAKA,wBAGA,gBACA,IAAiB,eAEjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,WA4OA,QAtIA,eACA,4BACA,KAqIA,WAnIA,aACA,OAEA,OAEA,8BACA,0BACA,SACA,oCACA,wEACA,CACA,GAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,SAIA,EA6GA,MA5GA,WACA,OAEA,0BACA,0BACA,SACA,oCACA,sDACA,CACA,GAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,SAIA,EAwFA,OAvFA,WACA,OAEA,0BACA,0BACA,SACA,oCAEA,yEACA,sBAEA,EACA,IAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,SASA,EA2DA,IA1DA,aACA,OAEA,0BACA,0BACA,SACA,oCACA,wFACA,wCACA,KACA,IAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,WAyCA,KAtCA,WACA,OAEA,0BACA,0BACA,SACA,oCACA,6DACA,QAEA,QAAmC,WAAyB,OAC5D,0BAGA,KACA,IAAiB,eACjB,CACA,IACA,EACA,EAAS,GACT,WAEA,GAEA,MADA,SAGA,MAuRA,SACA,sBACA,aA5OA,WACA,OACA,KACA,KACA,YACA,aAIA,+BAEA,mCACA,qCAGA,MACA,OAGA,YACA,YAEA,gBACA,UAGA,WAzDA,UACA,IACA,mEACA,uCAAK,SACL,CACA,QACA,CAEA,CAoQA,GACA,QArKA,aACA,OAEA,gCACA,aACA,YACA,cACA,sBAQA,SAEA,IAAuB,IAAY,IACnC,sBACA,OAGA,qCAOA,iCAGA,qCAEA,SACA,OAGA,SAEA,GAEA,MADA,SAGA,EA0HA,QA/LA,aACA,OAEA,OAEA,oCACA,SACA,iCAOA,aAIA,0BADA,iBAGA,GAEA,MADA,SAGA,EAwKA,QAhDA,eACA,OAEA,OAEA,oCAGA,CACA,eAIA,SAEA,+BACA,SACA,8CACA,CACA,KAEA,aACA,wBACA,eACA,IAAqB,SAGrB,iCACA,wCAEA,KACA,IAEA,CACA,EACA,EAEA,GAEA,MADA,SAGA,EAQA,WAnEA,aACA,OAEA,OAEA,oCACA,SACA,kCACA,YAEA,GAEA,MADA,SAMA,EAmDA,MAvNA,WACA,OACA,gCACA,qBAEA,gCAA6C,IAAQ,KACrD,mBAEA,OACA,+BAGA,aAEA,GAEA,MADA,SAKA,EAoMA,OAhFA,WACA,OACA,gCACA,UACA,MAEA,GAEA,MADA,SAGA,EAuEA,IA9HA,aACA,OACA,gCACA,SACA,QACA,KACA,gBACA,MAAS,SACT,GACA,IAIA,CAIA,qCADA,UAGA,GAEA,MADA,WA6GA,KA1GA,WACA,OACA,gCACA,aACA,uBACA,OAEA,OAAuB,IAAY,IACnC,mBACA,OACA,2DAIA,SACA,QAEA,GAEA,MADA,SAGA,gCAsFA,OACA,oDAIA,EAEA,MAEA,SACA,CACA,YACA,UAGA,4EAEA,SAEA,iFACA,aACA,aACA,aAGA,mBACA,kBACA,gBACA,wBAgCA,cACA,QAGA,QADA,mCAEA,OACA,UACA,QAEA,UAIA,YAEA,eAGA,qBACA,sBAAgC,UAChC,kCACA,sBACA,UACA,uBAEA,UACA,uFACA,EAQA,CA0OA,qCAtOA,wDAGA,SACA,iBAGA,+EACA,IACA,yCAGA,oBACA,uCAGA,sDACA,IAIA,uBACA,mCAIA,UAAS,OACT,wBAEA,gBAEA,OAMA,0CACA,0BACA,IACA,SACA,aAIA,qGACA,QAIA,WAHA,0BAIA,wBAA2D,SAAS,IACpE,SACA,gBACA,wBAKA,WAJA,uBAKA,CACA,oBAEA,qCACA,QAIA,QACA,GAEA,EACA,2BACA,2CAEA,gBAGA,UAEA,KAAa,SACb,CACA,IACA,CAEA,GAEA,MADA,WAGA,+BACA,sBACA,IAEA,uCACA,iDAEA,sBAEA,MADA,WAGA,uCACA,SACA,YAEA,MADA,SAGA,+BACA,OAEA,mCACA,OACA,8BAGA,iBACA,MAEA,GAEA,MADA,WAGA,uCACA,aASA,oBACA,QAEA,cACA,UACA,WAEA,8BACA,WACA,MAEA,cACA,kBACA,aAGA,kBACA,OACA,WAEA,eACA,cAEA,4BACA,WAEA,CACA,oBACA,4DACA,YACA,UAEA,OAjBA,QAkBA,IACA,CAKA,OA9CA,KACA,UAGA,gBAEA,mDA4CA,6CAHA,UACA,SAAS,2CAGT,SACA,oBACA,cAEA,oCACA,aACA,QACA,MACA,6CACA,IACA,EAAS,sBACT,CACA,oBACA,4DACA,YACA,UAEA,UACA,qBACA,UAEA,kCACA,SACA,KAEA,iCACA,GACA,OAEA,8CACA,QACA,cAA6C,SAAS,IACtD,MACA,UACA,eAGA,QACA,QAEA,qDAKA,kBAAoD,OAAS,IAC7D,WAEA,MAEA,wCACA,OACA,SAEA,GAOA,cA/5DA,GACA,GAg6DA,EAEA,UAAc,kBACd,EAAC,qDCl3ED,WACA,CACA,cACA,gBACA,SACA,qBACA,KACA,wBAEA,sCAlBA,QAQA,qBCFA,aACA,OACA,eACA,MAEA,kBAEA,SACA,iBACA,8CACA,mBACA,UACA,gCACA,SACA,WAEA,IACA,mBAEA,iDACA,UACA,6DAAkE,IAClE,gBAAiD,yCAAiC,YAClF,OAEA,oBACA,uBAGA,mBACA,qBACA,mBAGA,iBACA,WACA,4BACA,OACA,yBC5CA,qBAuBA,IACA,mBACA,cACA,UAIA,kCACA,CAMA,WACA,UACA,uBAEA,iMACA,OASA,WACA,wBACA,UAQA,YACA,wBACA,WAUA,UACA,wBACA,SAUA,eACA,wBACA,cAQA,aACA,wBACA,YASA,SACA,wBACA,QACA,YACA,wBACA,WACA,iBACA,wBACA,gBAIA,UACA,wBACA,SAMA,WACA,wBACA,UASA,UACA,wBACA,SAOA,cACA,wBACA,aAEA,cACA,wBACA,aACA,EAGA,MACA,qCCvJA,aA4CA,IA3CA,KACA,cAiCA,iBACA,IAKA,2BACA,CACA,QACA,gBC/BA,aAEA,EAUA,kMCRA,aA2BA,UAzBA,iBACA,WACA,YACA,iBAEA,SAIA,GACA,YAEA,KACA,KACA,aACK,YAEL,QACA,SACA,KAEA,OACA,2BCtBA,aAgBA,MAfA,UACA,QAEA,QAAiB,IAAS,UAC1B,CACA,cAAmB,EAAO,IAC1B,+BAEA,EACA,MAEA,CACA,QAEA,IAkBA,UAdA,iBAEA,KAIA,SAAmB,KAAS,EAF5B,IAGA,cAGA,qBACA,sBCtDA,aAmFA,eAEA,IACA,4BACA,mCAIA,0BACA,KAAiB,EAAS,IAC1B,SAEA,MACA,QAGA,CAhGA,QAQA,GACA,UAEA,GAAK,SAAwC,SAAE,SAAa,CAAsB,KAClF,GAAK,6BAAoD,GAAE,SAAa,CAA0B,IAMlG,CACA,4BAAe,EAAS,MACxB,sDACA,EACA,cAGA,EACA,wBACA,kBAGA,kBAAiB,EAAiB,IAClC,QACA,kCACA,uBACA,GACA,4CACA,OAGA,oCAIA,cAGA,cAAwB,EAAa,IACrC,QACA,kCACA,uBACA,GACA,4CACA,OAGA,MAEA,QACK,OAEL,uBACA,aACK,MAEL,wBACA,cACA,oBAGA,sBACA,cACA,qBACA,oBAIA,MACA,QAEA,EAkBA,2BACA,cACA,OAGA,EACA,2BACA,wBACA,gBAAmC,OAAS,IAC5C,WAEA,cACA,QAGA,EACA,0BACA,YAMA,eAEA,WAPA,YAOsB,EAAS,KAC/B,QAEA,WAAmB,GAAqB,OAAU,QAElD,MAEA,SAAoB,QAA0B,WAAgB,EAAU,QAGxE,uBAEA,UACA,YACA,UAIA,WAAoB,QAA0B,MAAU,QAExD,CACA,UAEA,WACA,mBACA,wBAEA,OAEA,OACA,OAQA,EACA,0BACA,IAEA,cACA,WAAyB,aAGzB,YACA,QAAkD,iBAIlD,UAIA,OAEA,YACA,0BCrKA,aA2BA,UAzBA,UAEA,YACA,kBAEA,gBAEA,gBAEA,cACA,mBAEA,iBAEA,iBAEA,WAEA,cAEA,oBAEA,aACA,gBCzBA,aAEA,UAGA,YACA,kBACA,eACA,eACA,WACA,UACA,UAKA,OACA,eACA,cACA,WACA,kBACA,gBAEA,eAIA,mBACA,eACA,qBACA,yBAGA,aACA,iBACA,QACA,UACA,qBAGA,WACA,SAEA,YAGA,aAEA,iCC1DA,aACA,OACA,6CAGA,CAsMA,aACA,IACA,qBACA,oBACA,SAxNA,cAQA,GAOA,GAGA,GACA,OAOA,cACA,aACA,oBACA,qBAEA,CAEA,aADA,QAEA,uBACA,YACA,SACA,iBASA,kCARA,mBACA,4DACA,sDACA,+DACA,mEACA,6DACA,oCACA,OAEA,sBACA,kCACA,gBACA,wBACA,kCACA,kBACA,kBACA,iBACA,4BACA,0BACA,uDACA,4CACA,6DAEA,qBACA,QACA,mBACA,iBACA,4BACA,0BACA,0BACA,sDACA,yCACA,4BAEA,wCACA,QACA,qBACA,iBACA,gBAGA,kCAFA,kEACA,cAEA,oBACA,kBACA,oBACA,mBACA,4BACA,eACA,uBACA,iCACA,kCACA,yBACA,MACA,cACA,SACA,aACA,iBACA,SACA,gBACA,mEACA,IACA,yBAEA,2BAEA,kFAEA,6BAEA,OAHA,KAFA,IAMA,mEACA,2CAEA,8CAEA,uBAKA,UAEA,6DACA,6BAEA,OATA,KAFA,IAYA,2BACA,8BACA,UACA,EAEA,OADA,wDAEA,0BAGA,yBAEA,QADA,wDAEA,0BAGA,iCAGA,MAUA,mBATA,wBACA,0BACA,mBACA,oBACA,iCACA,4BACA,yBACA,wBACA,OAMA,2BACA,aACA,SAIA,6BAMA,uFACA,CACA,QACA,wBACA,YACA,WACA,gDACA,0BACA,yCACA,sDACA,2BAEA,KACA,aAEA,QAEA,QACA,uBACA,kFAEA,sBACA,eAEA,SACA,cAEA,SACA,cAGA,sBAA8D,mCAE9D,GACA,QACA,uEAGA,wDACA,MAGA,oBC3MA,aAMA,IALA,KACA,iBACA,MACA,kBACA,SACA,yCCdA,QAQA,IACA,mBACA,eACA,SACA,UACA,SAEA,oBACA,uDACA,2DACA,SAEA,iBACA,oBACA,+CACA,UACA,QACA,oBACA,IACA,mBACA,4CACA,OAEA,6BACA,0EACA,uBAEA,OACA,oBACA,oEACA,oBACA,mBACA,oEACA,oBACA,uBAEA,CACA,sBAEA,oBACA,MACA,yBCjDA,qBAQA,IACA,GAGA,GACA,OAOA,cACA,2BACA,KACA,mBACA,2CACA,MACA,+CACA,SACA,SACA,8FAAyG,SACzG,GACA,IACA,mBACA,qDACA,8BACA,qCAA6C,uBAC7C,QACA,qBAEA,CAEA,aADA,QAEA,gBACA,qBACA,eACA,mBACA,oBACA,8CACA,SACA,mCACA,wDACA,QACA,CACA,sBACA,0BACA,qBACA,0BACA,2BACA,UACA,mBAAgD,qBAEhD,oBACA,QACA,sCACA,oDACA,2BACA,6DACA,qCAAuB,MAAoB,WAC3C,OACA,KACA,gBACA,OAMA,uBACA,IACA,GACA,gBACA,oBAEA,KAKA,eAHA,8BACA,OACA,UAEA,aACA,YACA,0BACA,oFACA,0BACA,OACA,SACA,QACS,GACT,OACA,SACA,QAEA,MACA,sBACA,UAEA,SADA,UAEA,EAIA,MACA,mJChHA,gCAMA,GACA,MACA,YAEA,YAEA,iBACA,KAAC,OAGD,OACA,MACA,YAEA,YAEA,iBAEA,kBAEA,mBAEA,mBACA,MAAC,OAAsB,sBC7BvB,aASA,IACA,WACA,oBACA,SACA,eACA,kDACA,sCCLA,mBACA,8BACA,iCACA,GACA,WACA,YACA,KACA,QACA,MAOA,CACA,mBACA,SACA,aACA,4BACA,mDACA,UACA,KAUA,OA1CA,MASA,IAkCA,gBACA,8BACA,uBACA,gBACA,2BACA,kBACA,QACA,OACA,kCCtCA,gBAEA,yBACA,gBAGA,8CAnBA,OAYA,GAQA,mBACA,cACA,UACA,4BACA,UACA,2BACA,CACA,QACA,aAEA,CACA,sCACA,MACA,4BACA,qBACA,2EACA,wBACA,0BACA,yBACA,MACA,oCAAuC,IAAU,UAAS,gBAC1D,kBACA,MACA,2BACA,yBAAuC,IAAU,WAAU,gBAC3D,sBACA,SAKA,iCACA,kBAAsC,IAAU,IAAG,gBAAiB,yBACpE,KAKA,mCACA,uBAAqD,IAAU,IAAG,gBAAiB,yBACnF,MAGA,MAFA,wBACA,aAKA,uBACA,mBACA,WAAmC,IAAU,IAAG,gBAChD,2BAAmC,IAAU,IAAG,gBAEhD,kBAEA,iBACA,MAEA,wCACA,sCACA,6BACA,sBACA,uBACA,wBACA,IACA,gBACA,UACA,2BACA,mDACA,8BACA,iBACA,oBACA,oCACA,0BACA,iDACA,KAEA,IAGA,IAEA,8BAAyC,cACzC,iEACA,cACA,yBACA,mBACA,gCACA,UACA,2BACA,uCACA,qDACA,WACA,0CACA,UACA,oDACA,8BACA,6EACA,MACA,qCACA,0CACA,8BACA,gCACA,wBACA,YACA,MACA,eACA,iCACA,wBACA,YACA,MACA,EACA,gCACA,UACA,2BACA,qCACA,mCACA,oDACA,kBACA,wEACA,YACA,2CACA,UACA,qDACA,8BACA,kGACA,OACA,eACA,+BACA,wBACA,YACA,MACA,eACA,gCACA,wBACA,YACA,MACA,EACA,6BACA,UACA,mCACA,oDACA,qBACA,YAEA,wBACA,0BACA,YACA,UACA,2BACA,qCACA,mCACA,kDACA,4BACA,4CACA,6BACA,gDACA,8BACA,mDACA,mBACA,qCACA,sBACA,mBACA,aACA,gBAAuB,QAA2B,WAClD,QACA,MACA,uBAAyC,cAAE,IAAG,QAAsB,eAAc,GAClF,OACA,SAEA,YACA,2BACA,+BACA,gDACA,YACA,0BAAiC,QAAsB,IAAG,QAAsB,eAAc,YAC9F,MACA,gBACA,SACA,mBACA,gBACA,2BACA,qCACA,mCACA,oDACA,kBACA,wDACA,sEACA,+DACA,QACA,QACA,QACA,MACA,iBACA,SACA,oBACA,iBACA,2BACA,qCACA,mCACA,oDACA,kBACA,0DACA,sEACA,+DACA,QACA,QACA,QACA,OACA,qBCrOA,GAGA,aACA,OACA,KAAC,IAED,GAEA,0CACA,OAAC,SAED,CACA,4BACA,OAI4C,CAE5C,6BCpBA,6BAOA,KACA,OACA,gBAGA,IACA,QACA,4BACA,cACA,mBACA,GACA,kBACA,UACA,kBACA,UACA,oBACA,yBACA,eAA2B,EAAS,MACpC,0CAGA,oCACA,kBACA,iBACA,YACA,2BAA2B,EAAc,IACzC,WAEA,QACA,QACA,KACA,IACA,UACA,mBACA,YAAuB,MAA2B,OAClD,UACA,gBAEA,OACA,QACA,QACA,EAqBA,itDCpEA,aAEA,WAEA,WACA,QACA,QAEA,SAEA,WAEA,6BCbA,aAuHA,aACA,+BAEA,gCACA,CACA,QACA,mBACA,iBACA,YACA,EACA,cACG,IAEH,kBAEA,eACA,+BAGA,mCACA,gCAGA,aACA,WACA,QACA,cAEA,oBACA,0BAEA,UACA,kBACA,OACA,QACA,SACA,aACA,WAGA,aACA,sBAGA,WACA,uCAGA,qBACA,IAEA,QAEA,6CACK,YACL,+DAEA,cAGA,yCAEA,QACA,sBAGA,WACA,YACA,CA8BA,CAyIA,eACA,OAEA,cAGA,aAAqB,qBAErB,cACA,MAUA,CAlXA,QACA,QACA,OACA,QACA,OAEA,uBAKA,WAGA,IACA,IACA,IAEA,KAEA,IAEA,IA6FA,EAoGA,8BACA,YACA,oBACA,YAEA,UAAmB,MAEnB,qBAGA,SArNA,UAuNA,qBACG,cACH,sCAKA,2BACA,qBAEA,SACA,IACA,iCACA,mBACA,IAEA,iBAEA,oBACA,MAIA,YAHA,cACA,sDAGA,UACA,8EAEA,+CAGA,WAAG,wCAGH,aACA,4BACA,WACA,cACA,SAIA,OACA,aACA,qBAKA,KAWA,EACA,8BACA,aACA,OAYA,EACA,6BAEA,CACA,QACA,wDAEA,qCAGA,cACA,eACA,yBACA,GAoCA,EA2CA,YACA,YACA,aAxBA,aACA,UACA,QACA,OACA,MAUA,EAWA,OAVA,aACA,UACA,QACA,QACA,yBCtXA,aAyGA,eACA,CAEA,aADA,OAGA,aACA,qBACA,GAEA,aAAoB,aAAsB,OAAqB,aAAgB,CAQ/E,CACA,aACA,SAGA,UACA,YACA,gBAEA,WAEA,4DACA,YACA,cACA,iBACA,eACA,eACA,WACA,8BAEA,IAGA,eACA,oEACA,+BACA,aACA,MAGA,eACA,iBACA,YAOA,CACA,eAGA,4BACA,qCACA,KASA,CACA,mBACA,SAEA,gBAAmB,MACnB,KAAkB,OAElB,KAGA,mCACA,aACA,6BAGA,aACA,+BAGA,gBACA,aAGA,cAWA,CACA,eACA,SACA,qBACA,aAGA,gBACA,0BACA,iCAEA,MAEA,WACA,WAMA,SACA,mBACA,OAQA,KAzBA,EACA,mBAyBA,iBAKA,OAAiC,gBAIjC,aAEA,IAWA,MACA,gBACA,eACA,mBACA,GASA,YACA,EAMA,IAEK,qCACL,kCACA,kCACA,kCACA,MAIA,aACA,OAEA,QACA,MACA,cACA,IACA,KAEA,cACA,OACA,IACA,CAAG,qBAEH,oBAGA,cACA,SAYA,CACA,aACA,SACA,eAIA,IACA,kCAoBA,6BAEA,kCACA,KACA,iBAEA,cASA,mBACA,UACA,IACA,YACA,wBACO,QAEP,KACA,IACA,IACA,YACA,wBAIO,QAEP,KACA,IACA,IACA,oBAeA,0CACA,eAGA,2BACA,6BACA,iBAGA,0DAIA,YAEA,2DAEA,sCACA,gBACA,SACA,MACA,yBASA,aAAG,sBAsCH,oBAUA,CAmGA,eACA,CAGS,OAFT,GAEA,IAMA,kBACA,IACA,oBACA,MAEA,aACA,gBAEA,KAKA,MACA,IAEA,0EACA,iDACA,yBAOA,iCAKA,0BAGA,YAKA,8CA0CA,aACA,cAEA,8DA3CA,+BAKA,8DACA,GACA,eACA,KAEA,sEACA,iDACA,yBAKS,eACT,uBACA,UAEA,oBACA,4BACA,qBAEA,mEAaA,UAOA,OACA,QACA,sBAIA,SACA,6CACA,EAEA,OACA,QAMA,8BAEA,WACA,QAMA,2BAMA,CACA,eACA,CAMS,OALT,GAEA,EAGA,IAMA,kBACA,IACA,oBACA,MAEA,aAA8B,gBAC9B,KAKA,MACA,IAEA,0EACA,iDACA,yBAMA,0BACA,4BACA,6BAEA,yBACA,gCAKA,0BAGA,OACA,wDAKA,kDAMA,oDACA,gBAOA,wDAMA,0CACA,iBACA,EACA,MAEA,yEACA,iDACA,yBAGO,gBACP,oBAMA,qBALA,mBACA,IAEA,eAGA,QACA,sBAKA,SAAK,YAOL,kCAiBA,IACA,aAEA,0DAhBA,OAGA,UACA,aACA,YACA,qBAMA,SAMA,UAGA,wDAEA,sBAEA,wCACA,EAEA,OACA,QAMA,8BAEA,WACA,QAOA,2BAOA,CACA,eACA,CAMS,YAAT,OALA,EACA,IAEA,IAOA,mBACA,IACA,qBACA,MAEA,aAA8B,gBAC9B,KAGA,mBACA,kBACA,4BACA,IACA,yCACA,KACA,WAES,2BACT,wBACA,wBACA,wBACA,MACA,uBACA,sBACA,6BAEA,UAKA,CAoBA,KAhBA,qCAEA,+BACA,2BACA,4BAKA,iCAEA,aACA,cAEA,gBAGA,QACA,sBAIA,SACA,iBACA,EAEA,OACA,QAMA,8BAEA,WACA,QAMA,2BAKA,CACA,eACA,CAES,OAAT,KAEA,IACA,kBACA,sBACA,IACA,MAEA,UACA,KAIA,CAQA,kBALA,+BACA,aACA,cACA,eAGA,QACA,sBAIA,SACA,iBACA,EAEA,OACA,QAMA,8BAEA,WACA,QAMA,2BAMA,CACA,qBACA,MACA,mBACA,gBACA,mBACA,iBACA,MAEA,CAqBA,aACA,mBAGA,WAIA,mCACA,kCACA,qCACA,2CAEA,qBACA,gBACA,cACA,WACA,iCACA,oBACA,UACA,EAGA,YACA,WACA,iBACA,mBACA,2BACA,mBACA,eACA,YACA,cACA,kBACA,OACA,0BAEA,cACA,cACA,cAEA,cAQA,sBAKA,YAMA,eAEA,gBACA,iBACA,iBACA,iBAEA,kBAOA,mBAKA,oBACA,kBACA,uBACA,gBACA,mBACA,iBAEA,mBAKA,wBAMA,sBAYA,aACA,gBAEA,kBAGA,kBAYA,6BACA,gCACA,oCACA,kBACA,kBACA,kBAEA,qBACA,iBACA,kBAGA,iCAIA,6BACA,UAEA,oBACA,gBAKA,6BACA,UAIA,kBAEA,mBAoBA,gBAEA,aAMA,eACA,kBACA,eACA,cAGA,cAIA,gBAaA,EAGA,aACA,IAEA,eACA,8BAIA,IAEA,gBACA,gBACA,gBAEA,EACA,qBAGA,iBACA,kBACA,WAEA,EACA,IACA,eAEA,eAnBA,OAsBA,aACA,OACA,KAIA,MAHA,YAEA,SAYA,uBACA,IACA,GAEA,eAEA,KACA,UAGA,GACA,OACA,IAGA,IACA,SACA,KAIA,cACA,uBACA,UACA,UAIA,QACA,UAIA,SAEA,eACA,UAEA,SACA,gBACA,OACA,uBACA,yBAEA,gBACA,mBACA,kCACA,iCAEA,0BACA,iCACA,gCAKA,2BAEA,qBAIA,2CAIA,8BAGA,wBAEA,cACA,UACA,aAEA,SACA,KAr2CA,QACA,OACA,QACA,OACA,QAOA,KACA,IAIA,IAOA,IACA,IAGA,KACA,KAUA,KAGA,IACA,IACA,IAEA,IAUA,IAKA,IAEA,IASA,IAEA,EAJA,KAMA,KAEA,SAEA,IAGA,KACA,IACA,UAEA,IAGA,KACA,KACA,KACA,MACA,OACA,OAEA,OACA,KACA,KACA,KAEmB,KA+5BnB,GAEA,aACA,EAziBA,aAIA,OAEA,MAKS,yBAJT,yBAIA,KAEA,mBASA,IACA,sBACA,MAGA,aACA,gBAGA,KAIA,eACA,sBAGA,UAEA,oCAEA,6BACA,aAEA,WACA,QACA,sBASA,yCAEA,WACA,QACA,sBAIA,SAEA,iBAEA,EAEA,OACA,QAOA,yCAEA,cACA,QAOA,2BAQA,eAycA,kBACA,kBAEA,mBACA,oBACA,qBACA,sBACA,wBACA,yBAMA,SAqxBA,cApcA,aACA,OACA,SAzyCA,GAGA,EAhBA,IAyvDA,iBACA,iBACA,qBACA,mBA9hBA,aACA,aACA,MACA,0BAEA,iBA0hBA,UApcA,aACA,OACA,IAEA,YACA,YACA,aAGA,gBAEA,SACA,kBACA,+BACA,iBAGA,0BACA,WACA,aAGA,eAEA,cACA,mBACA,MACA,QACA,SACA,KACA,6BAaA,oBACA,mBACA,oBACA,uBAEA,WACA,uBACA,0BACA,2BACA,uCACA,iBACA,YACA,OACA,gDACA,aACA,+BAEA,wCACA,iDAEA,cACA,IAIA,eArCA,OACA,OACA,OACA,OACA,mBACA,iBACA,YACA,GACA,SAGA,eA2BA,0BACA,KAEA,mBACA,UACO,EACP,UACO,EACP,YAEA,EAEA,QACA,EAA6B,iBAC7B,GAv2CA,YAy2CA,KACA,UAGA,OACA,+BACA,QAEA,wBACA,CAIA,MACA,6BACA,SAEA,mBACA,8CACA,oCACA,8CAEA,cACA,SACA,sBAIA,wBACA,iCAEA,2BACA,8CAEA,yCACA,mBACA,IAEA,SAEA,QAGA,cACA,4BACA,KAGA,UACA,kBACA,oCACA,8CAEA,cACA,SACA,wCACA,GACA,EACA,KAGA,2BACA,OAEA,0CAEA,EACA,MAAO,OAEP,wBACA,8CAEA,cACA,kBACA,IAEA,SAEA,QAGA,cACA,+BACA,KAGA,UACA,kBACA,oCACA,8CAEA,cACA,SACA,wCACA,GACA,EACA,KAGA,8BACA,OAEA,6CAEA,EACA,MAAO,OAEP,wBACA,8CAEA,cACA,UAEA,UAEA,QAGA,eACA,uBACA,oBACA,kBAEA,oBACA,uBACA,iBACA,wBACA,IAIA,cAMA,WACA,kBACA,KAOA,gBAQG,qBAPH,mCAQA,MACA,YAIA,0BACA,qBAKA,2BACA,sCACA,sBACA,oBA9jDA,EA+jDA,mBAEA,sBACA,YAEA,mBACA,OAaA,MAZA,iCAGA,QAUA,SACA,IAlnDA,IAonDA,aAEA,+BAIA,MAEA,IA3nDA,QA6nDA,MACA,6BACA,gBACA,WAIA,KACA,KACA,iBAIA,qBAHA,GAOA,OACA,OAGA,aACA,gBACA,iBACA,oBACA,qBACA,qBACA,oBACA,uBACA,wBAIA,oCACA,QAGA,gBAIA,KAAmB,qBAEnB,MACA,sBAyHA,aAvHA,WACA,IAEA,eAIA,iBACA,OACA,OACA,OACA,OACA,OACA,QACA,QAEA,QAGA,gBAEA,YACA,KAlrDA,OAwrDA,EA4FA,uBA3FA,aACA,SAEA,OACA,IACA,EACA,EACA,EACA,EACA,EAEA,YACA,MAGA,gBACA,UAEA,mCACA,UAIA,aAEA,8BAGA,WAGA,OACA,SAEA,YACA,iBACA,gBACA,WAIA,kBACA,2CACA,GACA,QAGA,YACA,aACA,YACA,QACA,qBACA,IACA,QACA,qBACA,KACA,0BACA,GAEA,qDAEA,sCAEA,gBACA,SACK,UACL,OACA,yBACA,EACA,IACA,CAWA,qBAVA,0BACA,oBACA,sBACA,iCACA,oBACA,IACA,YACA,UACA,aACA,UAYA,cASA,sDC9zDA,aAuBA,aAAoB,aAAsB,OAAqB,aAAgB,CAI/E,CAuHA,qBAEA,MACA,mBACA,kBACA,kBACA,aAGA,iCACA,OAQA,eACA,MACA,yBACA,OACA,YAIA,aACA,8BACA,GAMA,CACA,eAGA,4BACA,iCACA,SAMA,CACA,iBACA,YACA,eACA,0BACA,wBACA,qBAEA,gBACA,sBAEA,aAGA,iBACA,kBACA,GAOA,CACA,eACA,OACA,EACA,MACA,SACA,MACG,QACH,kBACA,CAKA,CACA,aACA,CACA,uBACA,iBACA,aAEG,GACH,2CACA,wBACA,cAEA,EAYA,CAGsB,eAEtB,SACA,aACA,uBACA,0BACA,wBACA,yBACA,yBACA,aAOA,EANA,IACA,EACA,EACA,EACA,QAEgB,EAAkB,KAClC,kBAMA,gCAEA,eAA0B,EAAe,IACzC,SACA,0BACA,EACA,MACA,IAEA,WAGA,OAEA,UACA,gBACA,EACA,WAEA,UACA,mBAEA,gCAGA,WAMA,QACA,SACA,EAAoC,mBACpC,MACA,+BACA,IAIA,iBACA,CAAG,OAOH,SAAyB,IAAY,MACrC,YACA,YACA,iBACA,OACA,cAEA,mCACA,WAEA,MAGA,KAUA,CAIqB,iBAErB,eACA,KACA,EACA,EAKA,QAAgB,EAAkB,KAClC,qBASA,QAAa,EAAgB,SAC7B,aACA,GAEA,iBAIA,UACA,CAKA,CACA,YACA,eAqBA,GApBA,EACA,EACA,EACA,EACA,QAiBA,IAAgB,MAAyB,EACzC,QACA,UAAe,OAA8B,KAC7C,MAQA,eAGA,OACA,IAAgB,EAAW,KAC3B,QACA,UAAe,OAA8B,KAC7C,MAIA,OACQ,QAAR,EAAwB,IACxB,iBACA,IAAe,YAAoC,EACnD,UAMA,aAAgB,EAAkB,KAClC,SAGA,QACA,EACA,iBACA,EACA,MAEA,UACA,iBACA,EACA,MAEA,UACA,iBACA,EACA,MAEA,UACA,iBACA,EACA,MAMA,eAGA,OAAa,EAAa,IAC1B,aACA,aAIA,kBACA,oBACA,qBAGA,MAKA,CACA,aACA,IAGA,SAAa,EAAa,IAAQ,qBAClC,QAAa,EAAa,IAAQ,qBAClC,QAAa,EAAc,IAAO,mBAElC,mBACA,yBACA,uBACA,CAKA,CACA,aAEA,CACA,mBACG,QAEH,4CAEA,iBACA,aACA,CAKA,CAKkB,mBAElB,CAGA,SACA,WAKA,6CACA,WACA,UAKA,CACA,mBACA,OACA,MACA,gBACA,yBACA,IAOA,CAIY,iBAEZ,aACA,aACA,OAEA,eACA,sCACA,QAGA,uBAGA,qBACA,QAGA,QAEA,IACA,SAQA,CAI2B,iBAE3B,OAGA,EAFA,EACA,EAEA,EAEA,KACA,eACA,6DACA,qBACA,SAEA,IACA,MAIA,YACA,aACA,OACA,KACA,WACA,MAEA,UACA,MAGA,KACA,WACA,KACA,WACA,MAQK,qBAGL,UACA,QAUA,CAGsB,eAEtB,SACA,uBACA,0BACA,wBACA,SAEA,IADA,EAOA,iBACA,IAEA,aAAa,EAAW,IACxB,IACA,oBAaA,wBAZA,eAGA,QAUA,6CACA,SACA,aACA,IAGA,kCAIA,UAKA,yBAAuC,EAAQ,KAAO,IAKtD,SACA,IAGA,YACA,sBACA,kBAGA,YAEA,cACA,uBAGA,4BACA,+DACA,iBAGA,eACA,UAEG,SAEH,2CAKA,GAGA,eACA,SAMA,CAImB,iBAEnB,QAEA,IAIA,OACA,IACA,IAEA,EATA,EAGA,MAOA,UACA,MAEA,gBAEA,QAAa,EAAe,SAC5B,IACA,gBAEA,UACA,MAEK,aACL,eAEK,QAEL,MAIA,gBAGA,iBAGA,QAV+B,iBAC/B,iBAEK,UAQL,EAEA,IACA,SACA,MAEK,GACL,SACA,IAGA,MACA,IAEA,EACA,CAMA,CAImB,iBAEnB,QAEA,IAIA,OACA,IACA,IAGA,EAVA,EAGA,MAQA,UACA,MAGA,KAAa,EAAe,SAC5B,IACA,gBAEA,UACA,MAEK,iBACL,IAAU,WAAmC,eAExC,YACL,OASA,eACA,iBAGA,aACA,kBAGA,KAhBA,gBACA,SAGA,aACA,iBAEK,MAUL,EACA,IACA,SACA,MAEK,GACL,SACA,IAGA,MACA,IAEA,EACA,CAMA,CACA,aACA,IAGA,gCACA,mCAGA,gBASA,aAAkC,EAAkB,MAMpD,wBALA,KAUA,8BADA,GAQA,CAGkC,mBAElC,IAMA,iBACA,WACA,WACA,KAAgB,EAAgB,IAEhC,4BAIA,qBAGA,qBAEA,EAeA,CACA,aAKA,OACA,WAGA,QAAa,EAAS,eACtB,UACA,qBAKA,iCACA,qBACA,oBAEA,eAAc,GAAc,IAC5B,OACA,qBAOA,SACA,QAGA,CAgCW,mBAEX,oBACA,GACA,WAMA,CA7gCA,QASA,KAKA,IAEA,IAUA,IACA,IAeA,KAGA,QAGA,MAGA,KAGA,SAGA,IAGA,KAQA,KAGA,IAGA,MAGA,KAGA,KAIA,GAGA,8DAGA,wEAGA,0CAcA,oEASA,KAEA,iBAIA,KAEA,YAdA,KAmBA,KAEA,YA5FA,IARA,KAsGA,KAEA,gBAEA,MAEA,gBAEA,MAgBA,GA00BA,OAz0BA,GACA,MA2gCA,WAlMA,WAIA,MACA,IAGA,wBACA,+BACA,gCAEA,qBACA,aAGA,EACA,IAKA,EA6KA,qBACA,kBA/IW,iBAEX,OAIA,IAHA,EAMA,kBACA,YArhCA,qBAyhCA,YAIA,cAUA,UAGA,uBACA,uBAMA,EAAkC,OAIlC,YAGA,WASA,MAEG,wBAxkCH,GA0kCA,0BACA,GAGA,gBA7jCA,cA8jCA,iDACA,qBAMA,YAGA,QAIA,IAKA,EA8DA,YA1DkB,eAIlB,4CACA,gDAEA,wCACA,QAEA,WAEA,kBAEA,UAEA,UAKA,gBACA,4BA0BA,sCAKA,GAMA,YAhKA,WACA,UACA,GACA,SACA,IAMA,mBC7iCA,aA4FA,aACA,+BAEA,gCACA,WACA,iBACA,KACG,IAEH,kBAIA,gCACA,kCACA,WAA+B,iCAI/B,sBACA,wBACA,4BAKA,qBAGA,iBACA,qCAIA,aACA,WACA,QACA,cAEA,oBACA,0BAEA,UACA,kBACA,OAGA,qBACA,qBAGA,kBAEA,wCACA,OA6BA,CA0MA,eACA,OAEA,cAGA,aAAqB,qBAErB,cACA,MAUA,CAzYA,QACA,QACA,OACA,QACA,QACA,OACA,QAEA,uBAgFA,SAqFA,8BACA,YACA,oBACA,yBACA,WAQA,OAPA,MACA,EAIA,UAEmB,MACnB,yCAGA,mBAEA,qBACG,iBACH,sCAKA,2BACA,qBAEA,SACA,IACA,iCACA,mBACA,IAGA,6BAEA,kBAEA,mBACA,qBACO,cACP,sCAKA,+CAIA,4BACA,YACA,KAGA,gCACA,KAKA,YAJA,cACA,cAIA,uFAEA,iBAEA,sDAEA,cACA,4BAGA,YACA,uBACqB,wCAErB,QAGA,8CAYA,4BACA,kBAGA,KAAG,8CAEH,2BACA,mBAIA,gBACA,8BACA,WACA,cACA,eAIA,YACA,4BACA,kBAKA,KAWA,EACA,8BACA,aACA,OAYA,EACA,6BAEA,OACA,OAGA,wDAEA,qCAGA,cACA,eACA,yBACA,GAyCA,EAsCA,YACA,YACA,aAnBA,aACA,UACA,QACA,OACA,MAUA,EAMA,4BC9YA,aA6FA,aACA,QACA,aACA,yBACA,aACA,IAGA,YACA,WACA,OACA,kBACA,OACA,uBACA,YACA,aACA,aAEA,YAGA,gBACA,aACA,aACA,aACA,cAGA,eACA,YAGA,cACA,cAGA,aAGA,eACA,mBACA,kBACA,gBAGA,aACA,YACA,aACA,YACA,YAEA,2BACA,2BAOA,iBACA,kBACA,eACA,YACA,WACA,EAEA,aACA,IAEA,eACA,WACA,qCACA,QACA,KACA,eAEA,YACA,cACA,aACA,SACA,aACA,YACA,SAEA,2BACA,qCAEA,iBACA,UAGA,OAEA,aACA,IAEA,eACA,WACA,cACA,UACA,UACA,EAEA,QAEA,eACA,IACA,GAGA,cACA,WAGA,MACA,OACA,IAGA,cACA,EACA,UAKA,cAGA,6BACA,qBAIA,QACA,SACA,QACA,QAEA,eACA,IACA,GAKA,cAIA,QACA,iBACA,OACA,OACA,gBAGA,WAqBA,aAEA,OACA,IAEA,sBACA,oBAGA,MACA,EAAuB,mBACvB,OAAuB,mBACvB,OAAuB,mBACvB,OAAuB,mBAEvB,mCAAuE,MAGvE,MACA,EAAsB,kBAEtB,8BAAuE,MAGvE,IACA,KAEA,GACA,qBACA,IACA,uBACA,CAgBA,CACA,mBACA,SAIA,MAHA,QAIA,gCACA,cACA,UAEA,wBAIA,aACA,+CACA,WACA,YAGA,oBACA,MACA,MAGA,mCACA,OAGA,oCACA,KACA,kBAGA,UACA,qBAAwC,gBACxC,aAAsC,UAGtC,YACA,EArWA,QACA,OACA,OACA,QACA,QAEA,MAEA,IAWA,IACA,IAOA,IACA,KAIA,KACA,KACA,IAWA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,MAOA,OAGA,IAqLA,SAAoB,GAguCpB,iBACA,kBACA,qBACA,cApvCA,WACA,OACA,KApKA,GAiLA,EAsuCA,iBACA,UAzoCA,aACA,OAYA,eAMA,GAQA,mDAzBA,IACA,GACA,GACA,MACA,GACA,GACA,MACA,GACA,GACA,GACA,SAGA,SACA,GACA,GACA,GAGA,GAEA,uBAKA,kBACA,eAGA,aACA,QAA4B,aAI5B,aACA,cACA,YACA,eACA,YACA,WACA,cACA,UAGA,KACA,MACA,MAEA,KACA,UACA,gBACA,MACA,qBACA,GACA,OACA,KAEA,aACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,yBACA,SAEA,OACA,YACA,iCAIA,MACA,KAEA,IACA,OACA,KACA,YACA,IACA,cAEA,WACA,sCACA,OACA,2BACA,QACA,KACA,eACA,OACA,+BACA,QACA,KAEA,UACA,MAEA,aACA,EACA,cAEA,4BACA,OACA,wBACA,QACA,KACA,QAEA,sBACA,SAEA,cACA,KAEA,EACA,MAEA,mBACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,MACA,0BACA,OACA,+BACA,QACA,KACA,kBACA,OACA,6BACA,QACA,KACA,GACA,mBAEA,SAEA,mBACA,YACA,iCAIA,OACA,KAEA,IAEA,OAEA,mBACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,GACA,cAEA,SAEA,mBACA,YACA,gBACA,iBACA,kCAIA,OACA,KAEA,IAEA,OAEA,mBACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,GACA,qBACA,qBAEA,GAEA,mBACA,YACA,iCAIA,OACA,KAEA,IAEA,OACA,uBAEA,aACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,GACA,YACA,cAEA,cAEA,mBACA,YACA,iCAIA,OACA,KAEA,CACA,QACA,oBAEA,QAEA,OACA,UACA,oBACA,OAA4B,QAE5B,cACA,6BACA,eAEA,kCAEA,cACA,gBAaA,mBACA,0BAEA,gBACA,OACA,SAEA,cAA6B,aAE7B,oBACA,IAEA,OACA,uBACA,IAA2B,YAC3B,cACA,EAEA,WAEA,QACA,UACA,8BAEW,iBAEX,OAKoB,GAJpB,0BAEA,gBACA,OACA,eACA,UACA,QACA,mBAEA,eACA,IAEA,OACA,uBACA,IAA2B,YAC3B,cACA,EACA,WAEA,QACA,UACA,iCAEW,iBACX,OAKoB,GAJpB,0BAEA,gBACA,OACA,eACA,UACA,QACA,sBAEA,QAEA,OACA,sBAEA,aACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,yBACA,OACA,wBACA,QACA,KAEA,IACA,KAEA,CACA,GACA,mBACA,oBAEA,yBACA,IACA,OACA,MAEA,mBACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,iBAEA,SACA,KAEA,IAEA,OACA,UAEA,eASA,SARA,cACA,eACA,aACA,cACA,UAEA,QApsBA,kBAusBA,IAEA,OACA,cAptBA,GAotBqD,WAErD,WACA,iBAEA,OACA,SAEA,OACA,OACA,KAEA,YACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,eAEA,WACA,MAGA,EACA,UAGA,KACA,OACA,UACA,MAGA,OACA,aAEA,OACA,MAEA,OACA,UACA,CACA,UAGA,KACA,OACA,UACA,SACA,uBAGA,eACA,MAEA,EACA,MAEA,iBACA,SAGA,YACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,gCACA,OACA,iCACA,QACA,KACA,aAIA,YACA,KAEA,IACA,OAAgC,WAEhC,WACA,SAEA,OACA,eACA,UACA,IAA4B,QAC5B,OAA4B,QAC5B,OAA2B,YAE3B,aAEA,wBACA,OACA,OACA,OACA,SACA,WACA,KAEA,GACA,OACA,MAEA,mBACA,IAA2B,YAC3B,WACA,WACA,cACA,CAEA,mBAEA,UACA,MAEA,kBAEA,QACA,MAEA,kBAEA,QACA,MAGA,yBACA,OACA,wCACA,QACA,KAGA,QACA,IAEA,OACA,4BAEA,YACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,qBAEA,WACA,MAEA,CACA,MACA,+BAMA,iBACA,iBAEA,KAAgB,QAChB,cA54BA,4BA64BA,sBAEA,QACA,OACA,6BACA,QACA,KAEA,QACA,IAEA,OACA,mCACA,CAAiB,OACjB,kCACA,UACA,MACA,cAEA,QAAsC,OAEtC,SAA6B,YAC7B,WACA,WACA,cAEA,CACA,IAEA,MACA,SAEA,gBAEA,eACA,YAEA,WACA,SACA,IAAiC,YACjC,WACA,WACA,cACA,CAGA,IACA,SAEA,kBACA,OACA,8BACA,QACA,KACA,kBACA,SAEA,YACA,MAEA,CACA,iBAEA,WACA,SACA,IAAiC,YACjC,WACA,WACA,cACA,CAGA,CACA,SAEA,UACA,QAEA,YACA,MAEA,CACA,KAEA,WACA,SACA,IAAiC,YACjC,WACA,WACA,cACA,CAGA,CACA,SAEA,UACA,SAEA,cACA,MAEA,CACA,6BACA,OACA,8BACA,QACA,KACA,MACA,eAEA,UACA,CAGA,MAAiC,UAGjC,yBACA,OACA,yCACA,QACA,KAKA,cAEA,KAAgB,QAChB,8CAGA,sBAGA,QACA,OACA,gCACA,QACA,KAEA,eAGA,eACA,WAAgB,QAChB,sDAGA,uBAGA,QACA,OACA,0BACA,QACA,KAEA,MACA,OAAgC,WAEhC,WACA,SAEA,OACA,yBAEA,GACA,cACA,eACA,aACA,cACA,UAEA,QAEA,aACA,cACA,YACA,eACA,YACA,WACA,cACA,UAGA,OACA,mBAEA,GACA,KACA,CACe,WAAf,IACA,kCACA,UACA,MACA,cAEA,QAAkC,OAElC,SAA2B,YAC3B,WACA,WACA,cAEA,CACA,oBACA,CAGiB,IAFjB,MACA,MACA,QACA,gBACA,mBACA,gBACA,MACA,cAEA,QAAkD,UAElD,SAA6B,YAC7B,WACA,WACA,cAEA,CAEA,CACA,SAEA,SACA,QAEA,IACA,SAEA,SACA,WACA,iBAIA,GACA,OACA,KACA,UAEA,SACA,IACA,OACA,KACA,UACA,OACA,gCACA,QACA,KACA,SACA,QAEA,OACA,kBAEA,UACA,aACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,2BAEA,UACA,YAEA,gBACA,KAEA,SACA,SAEA,OACA,OAAe,OACf,oCACA,UACA,MACA,cAEA,QAAoC,OAEpC,SAA2B,YAC3B,WACA,WACA,cAEA,CACA,gBACA,CAGiB,IAFjB,MACA,MACA,QACA,iBACA,mBACA,gBACA,MACA,cAEA,QAAkD,UAElD,SAA6B,YAC7B,WACA,WACA,cAEA,CAEA,CACA,SAEA,SACA,QAEA,IACA,SAEA,SACA,eACA,OACA,0BACA,QACA,KACA,GACA,kBACA,QAEA,OACA,kBAEA,UACA,aACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,2BAEA,UACA,YAEA,gBACA,KAEA,oBACA,OACA,kCACA,QACA,KAGA,GAEA,OACA,UAAyB,YACzB,iBACA,kBACA,SACA,eACA,cACA,OACA,kCACA,QACA,KAiBA,MACA,aACA,WAGA,eAEA,cAAoC,cACpC,aACA,MAEA,KACA,eACA,YAEA,OAA0B,QAC1B,OACA,SACA,WACA,eACS,YACT,MAAiC,iBACjC,QACA,MACA,UAAyB,YACzB,sBACA,OACA,OACA,OACA,MACA,iBAEA,aACA,IAA6B,YAC7B,WAEA,WACA,cACA,CAEA,IACA,SACA,gBAEA,yBAEA,qDAGA,QAEA,mCACA,OACA,yBACA,QACA,KAEA,IACA,KAGA,CACA,GAEA,OACA,0BAEA,aACA,IAA6B,YAC7B,WACA,WACA,cACA,CAEA,8BACA,OACA,2BACA,QACA,KAEA,IACA,KAGA,CACA,GAEA,QACA,QACA,GAt1CA,OAu1CA,WACA,QACA,UACA,WACA,QACA,SAEA,IAzyCA,IA0yCA,QAcA,mBACA,cACA,eACA,aACA,cACA,UAGA,sCACA,oBACA,sCACA,eAIA,kBACA,eACA,YACA,eACA,gBACA,YACA,qBACA,+DAEA,4CACA,mBACA,+BACA,4BACA,SAGA,IAn4CA,QA28CA,aAtEA,WAEA,WACA,MAGA,iBACA,MAKA,SAJA,kBAEA,cACA,QA4DA,mBAzDA,aACA,IAGA,eACA,WACA,MAGA,oBACA,SAEA,cA8CA,uBA5CA,aACA,SAEA,OACA,EACA,EAGA,cACA,WAEA,oBAKA,cACA,aAEA,YACA,SAMA,YAEA,iBAGA,uBAGA,QAWA,cAUA,kDC9/CA,aACA,MACA,GAqCA,uBACA,IACA,GACA,EACA,EACA,EACA,EAEA,EAEA,EACA,EACA,EAEA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EAEA,EACA,EACA,EACA,EAGA,IAGA,MAEA,UACA,YACA,sBACA,OACA,aACA,gBACA,4BAEA,SAEA,SACA,UACA,UACA,UACA,WACA,SACA,SACA,YACA,0BACA,oBAMA,EACA,MACA,CACA,YACA,WACA,OACA,WAGA,OAEA,KACA,MAAW,OACX,UACA,GACA,OACA,OACA,WAIA,aAEA,qBACA,GACA,WAEA,OACA,WACA,WAEA,eACA,EACA,OAGA,MACA,YACA,WACA,OACA,WAEA,OAEA,KACA,OAAe,OACf,UACA,GACA,OACA,OAEA,gBACA,MACA,WACA,GACA,WACA,WACA,EACA,WACA,WAGA,gBAEA,MACA,OACA,kCACA,YACA,IAEA,IACA,OAEA,OACA,QACA,MACA,IACA,YACA,OACA,kCACA,YACA,IAwBA,MACA,EACA,IACA,aACA,QACA,CACA,KACA,YACmB,WACnB,OACA,IACA,GAEA,UACA,WACA,MACA,SACA,CACA,KACA,YACmB,WACnB,UACA,MACA,CACA,IACA,KACA,YACqB,WACrB,OACA,IACA,GACA,CAGA,aACA,QACA,CACA,KACA,YACmB,WACnB,OACA,IACA,GAEA,MACA,cACA,cACA,cACA,QAGA,eACA,KACA,eAGA,MACA,KACA,GACA,IACA,YACA,cACA,cACA,QACe,QAEf,kBACA,KACA,eAGA,MACA,CACA,mBACA,yBACA,YACA,OACA,KACA,OACA,0BACA,YACA,IAEA,CACA,KACA,CACA,mBACA,yBACA,YACA,MACA,cAEA,GACA,KAnQA,QAoQA,IACA,KACA,OACA,gCACA,YACA,IAEA,CACA,KACA,CAAG,YAGH,KAaA,YAZA,EACA,WACA,YAGA,IACA,YACA,qCACA,oCACA,OACA,cACA,0BCpUA,aAEA,QAEA,KACA,KACA,MAGA,MACA,IACA,IAEA,EAKA,8FAKA,iGAMA,wHAIA,oGAEA,mCAEA,SAGA,OACA,IACA,QACA,IACA,IACA,IACA,IACA,IACA,IACA,IAMA,OAEA,kBAEA,mBACA,KACA,OAEA,EAbA,EACA,EACA,EACA,EACA,EAIA,MAuCA,QAAe,EAAgB,KAC/B,SAEA,QAAe,EAAa,IAC5B,QAIA,YACA,IAAqB,IAAU,MAG/B,SAFA,QAGA,MAEA,KAIA,cAMA,gBAEA,qBACA,EAEA,QAAe,EAAW,KAG1B,SAFA,SAGA,MAIA,OACA,IAAe,EAAgB,KAC/B,WACA,KACA,KACA,WAGA,kBACA,aAIA,WACA,IAAe,EAAe,IAC9B,gBAIA,WAAe,EAAa,IAC5B,IACA,mBAsCA,eACA,SACA,MAEG,IACH,OACA,OACA,IACA,OACA,MAGA,MACA,IACA,OAIA,KACA,IACA,EACA,IACA,IACA,MACA,KACA,IACA,SAGA,SACA,YACA,UAIA,GAAS,OAET,GACA,IACA,UACA,IAEA,MACA,cACA,YAGA,QACA,OAIA,QACA,MACA,KACA,IACA,EACA,oBACK,wBAGL,kBACA,EACA,SAEA,KACA,QAOA,QANA,EAEA,MAKA,cACA,IAAwB,KACxB,YACA,KAGA,mBAEA,KACA,OAIA,KAGA,OACA,MACA,KACA,aACA,OACA,QACA,QAIA,QACA,YACA,YACA,UAIA,KAIA,SACA,mBACA,CAKA,OAIA,gBAKA,uBACA,OACA,gBCnUA,aAsCA,UApCA,UAEA,WAEA,YAEA,cAEA,UAEA,aAEA,oBAWA,YAIA,gBAIA,aAEA,OACA,wBCjDA,aAKA,IAJA,KACA,gBACA,4DACA,EACA,kBCLA,aACA,SAKA,EAkCA,IAjCA,KACA,cACA,MACA,qBAMA,WACA,MACA,UACA,iFAEA,iBAIA,gBACA,MAEA,8BACA,cACA,KAIA,SACA,MAEA,mDACA,0BACA,sBACA,kBC5CA,aACA,aACA,IACA,gBAAmB,QAAgB,OACnC,MACA,iBACA,2BAGA,UAGA,UACA,QAGA,CACA,OAIA,iCACA,CAIA,QAHA,0BACA,mBACA,sDAGA,wBACA,IACA,uBACA,gDACA,SACA,SACA,WACA,eAGA,qGAIA,aACA,aACA,4DACA,kBACA,OAIA,cACA,MACA,SAIA,iBACA,yBACA,iBAIA,aACA,6BACA,iBAIA,gBACA,0CACA,6BAIA,aACA,aACA,+CAGA,cAEA,OAIA,iBACA,aACA,+CAGA,kBAEA,WAUA,kBACA,wBACA,kBACA,IASA,YACA,wBACA,YACA,IAOA,aACA,wBACA,YAMA,QACA,wBACA,OAOA,iBACA,wBACA,gBAMA,QACA,wBACA,QACA,IACA,cACA,wBACA,aAMA,SACA,4BACA,OAIA,iBACA,wBACA,gBAIA,WACA,wBACA,UAEA,oBACA,+BACA,WAIA,UACA,wBACA,SAIA,OACA,wBACA,MAIA,SACA,wBACA,QACA,mFCxMA,OAYA,GACA,mBACA,cACA,IACA,yBACA,8CACA,+BACA,KACA,2CACA,+CACA,2CAEA,0EACA,2BACA,iBACA,OACA,OACA,OACA,gCAEA,wEACA,SAIA,gBACA,8BACA,8DACA,qBACA,IACA,sCACA,MACA,6DAEA,+DACA,QAGA,4DAEA,kBAAsC,cAA0B,aAChE,eACA,aACA,8CACA,gCAMA,gBACA,4BAAgD,cAAkB,KAClE,aACA,YACA,YACA,EACA,8CAGA,oDAEA,2CACA,qCAEA,4BACA,gCACA,wBACA,qCACA,MACA,eACA,iCACA,wBACA,qCACA,MACA,EAeA,yBACA,MACA,oCAAuC,IAAU,UAAS,gBAC1D,kBACA,MAgBA,2BACA,OAA4B,IAAU,WAAU,gBAChD,sBACA,sBACA,SAKA,iCACA,aACA,sBAAsC,IAAU,IAAG,gBAAiB,yBACpE,KAKA,mCACA,uBAAqD,IAAU,IAAG,gBAAiB,yBACnF,MAGA,MAFA,wBACA,aAKA,uBACA,mBACA,WAAmC,IAAU,IAAG,gBAChD,2BAAmC,IAAU,IAAG,gBAEhD,kBAEA,6BACA,UACA,mCACA,qDACA,wBACA,aACA,WACA,gBACA,2BACA,uCACA,eACA,uBACA,eAAkC,QAA4C,OAC9E,MACA,oBACA,mBACA,wBACA,SAEA,eACA,+BACA,wBACA,qCACA,MACA,eACA,gCACA,wBACA,qCACA,MACA,+EACA,gDACA,eACA,+BACA,UACA,mBACA,wCACA,iCACA,kBACA,CACA,WAGA,mBACA,QACA,0BAEA,OACA,gBAAgC,kCAChC,QACA,EACA,WACA,oBAA2C,MAC3C,0BACA,wBACA,0BACA,SAEA,cACA,gCAGA,mCAEA,sBACA,oBAEA,YACA,4BACA,gCACA,8CACA,CACA,WAGA,qBACA,QACA,0BAEA,OAEA,IAEA,YADA,UAEA,qBACA,UACA,2BACA,qCACA,uBACA,+DACA,2BACA,iBACA,4BACA,MACA,8CACA,CACA,WAGA,mBACA,QACA,0BAEA,OACA,gBAAgC,eAAoC,WACpE,QACA,GACA,QACA,gBACA,SACA,mBACA,gBACA,2BACA,qCACA,mCACA,oDACA,kBACA,wDACA,sEACA,kCACA,QACA,QACA,QACA,MACA,iBACA,SACA,oBACA,iBACA,2BACA,qCACA,mCACA,oDACA,kBACA,0DACA,sEACA,kCACA,QACA,QACA,QACA,OACA,YAEA,UACA,2BACA,qCACA,uBACA,yDACA,2BACA,8CACA,0BACA,kBACA,4BAEA,MACA,8CACA,0BACA,WAAmC,WAAuB,OAC1D,0BAEA,SACA,GAEA,oBACA,QACA,0BAEA,MACA,oEACA,aACA,eAA2B,aAA8B,OACzD,cAA8C,IAAsB,IACpE,gBACA,aACA,YACA,iBACA,CACA,2BACA,eACA,cAEA,aACA,KAGA,IACA,gBAA2B,cAA+B,OAC1D,cAA8C,IAAsB,IACpE,gBACA,cACA,YACA,kBACA,CACA,2BACA,eAEA,SACA,KAGA,eAAgC,qBAChC,WACA,GACA,QACA,yGCpWA,QAgBA,GACA,WAQA,qCACA,iCAEA,UACA,4BACA,OACA,2BACA,YACA,mBACA,aACA,OACA,gCACA,oEACA,iCACA,kCACA,mCACA,IACA,yBACA,yBAAuC,IAAU,UAAS,gBAAiB,IAAG,6BAC9E,kBACA,MACA,2BACA,yBAAuC,IAAU,WAAU,gBAAiB,IAAG,6BAC/E,sBACA,SAKA,iCACA,kBAAsC,IAAU,IAAG,gBAAiB,IAAG,6BAA8B,yBACrG,KAKA,mCACA,uBAAqD,IAAU,IAAG,gBAAiB,IAAG,6BAA8B,yBACpH,MAGA,MAFA,wBACA,aAKA,uBACA,mBACA,WAAmC,IAAU,IAAG,gBAAiB,IAAG,6BACpE,2BAAmC,IAAU,IAAG,gBAAiB,IAAG,6BAEpE,kBAEA,sCACA,YACA,4BACA,qBACA,2EACA,wBACA,0BACA,gCACA,UACA,2BACA,uCACA,yCACA,qCACA,uBACA,0BACA,8CACA,yBAA8B,yBAAoC,mBAClE,wDACA,QACA,oBACA,2BAA8B,QAAoB,kBAClD,uCACA,YACA,eACA,gCACA,wBACA,iEACA,MACA,eACA,iCACA,wBACA,gEACA,MACA,EACA,gCACA,UACA,uBACA,2CACA,+BACA,qDACA,kBACA,0BACA,0BACA,+CACA,yBAA8B,yBAAoC,mBAClE,yFACA,QACA,eACA,+BACA,wBACA,4EACA,MACA,eACA,gCACA,wBACA,2EACA,MACA,QACA,eACA,uBACA,MAEA,+CACA,aACA,0BAEA,2BACA,uCACA,4BACA,uDAOA;;;;;;UAXA,eAYA,6BACA,2CACA,qDACA,8BACA,QACA,EACA,6BACA,UACA,mCACA,qDACA,wBACA,cAEA,qBACA,2BACA,0CAEA,0BACA,+DACA,kEACA,gBACA,SACA,mBACA,gBACA,2BACA,qCACA,mCACA,oDACA,kBACA,mDACA,6CACA,6CACA,UAEA,SADA,QAEA,QACA,MACA,iBACA,SACA,oBACA,iBACA,2BACA,qCACA,mCACA,oDACA,kBACA,mDACA,+CACA,6CACA,UAEA,SADA,QAEA,QACA,OACA,gBACA,UACA,2BACA,qCACA,mCACA,qEACA,iEAAkE,uBAClE,uBACA,UACA,wCACA,aACA,sBACA,gDACA,yDACA,qDAEA,yBACA,iBACA,yBACA,gBACA,oBACA,GACA,CACA,wBAEA,MAEA,eAEA,+BACA,0BAEA,qDACA,IAAyB,QAAc,WACvC,YACA,cACA,YACA,QACA,kBAEA,gCACA,cACA,QACA,kBAEA,gCACA,aACA,QACA,mBAEA,gCACA,aACA,QACA,mBAEA,gCACA,aACA,QACA,mBAEA,gCACA,cACA,QACA,mBAEA,gCACA,cACA,QACA,mBAEA,gCACA,cACA,QACA,mBAEA,gCACA,kBACA,QACA,kBAEA,4BACA,wBAAwF,6CAExF,KAEA,2BAEA,aACA,CACA,mCACA,2BACA,oBACA,sBACA,cACA,SACA,SACA,cACA,WAEA,cAEA,kCACA,2BAAgD,CAAS,YACzD,gBACA,EACA,mBAEA,UACA,QAEA,EACA,YAEA,UACA,2BACA,qCACA,mCACA,qEACA,iEAAkE,uBAClE,uBACA,UACA,kDACA,gBACA,eACA,2DACA,IACA,QACA,0BACA,mBACA,2DAEA,eAA8B,UAAuB,oBACrD,eAEA,8BAEA,8CAEA,wBACA,0BAEA,yDACA,+BAEA,sDACA,sBACA,oCACA,QACA,QACA,aAA8B,CAAS,cACvC,SACA,gCACA,+BAEA,kBACA,uCACA,qCACA,eACA,UACA,KACA,sBACA,KAEA,KACA,yCACA,QACA,4BACA,QACA,eACA,sBAGA,MACA,sDAGA,+FACA,YACA,iBACA,QAEA,8BACA,sDAEA,eAA8B,UAAuB,oBACrD,eAEA,8BAEA,8CAEA,wBACA,0BAEA,yDACA,+BAEA,sDAGA,UAA8B,CAAS,cACvC,SACA,iCACA,uBAEA,gBACA,gBACA,eACA,CACA,CAtYA,CAsYA,4CCjaA,QAQA,IACA,mBACA,yBACA,CAQA,eAPA,uBACA,UACA,+BACA,6CACA,mBACA,YACA,qBAEA,6BACA,EACA,UACA,0BACA,EACA,MACA,oBAEA,qDACA,IACA,cACA,0CACA,gDACA,yBACA,EACA,UACA,uCACA,+CACA,sBACA,EACA,MACA,oBAMA,iEACA,gDACA,sBAEA,2BACA,6BACA,yFACA,aACA,oBACA,eACA,cACA,aACA,QACA,aACA,qCACA,iBAOA,iBACA,YACA,oBACA,gBAQA,oBACA,QACA,6BACA,+EACA,kEACA,oBACA,oBACA,oCACA,oBAEA,mBACA,oCACA,oBAMA,uBACA,oBACA,QACA,cACA,uCACA,0EACA,kEACA,0BACA,GACA,GACA,8BACA,gGACA,cACA,uBAMA,sBACA,oBAEA,aAEA,mDACA,cAFA,QAGA,8EACA,cACA,+BACA,gDACA,EACA,2BACA,SACA,8BAEA,+IACA,QACA,eACA,6BAEA,oCACA,4CACA,qCACA,OACA,wBACA,oBACA,qBACA,yCACA,uCAEA,WACA,yBACA,oBACA,IACA,0CAEA,iJACA,8BAEA,+IACA,QACA,cACA,qGACA,QACA,2BACA,wBACA,SAEA,6CACA,8EACA,QACA,4BACA,QACA,6BACA,oBACA,eAEA,qBACA,0BACA,oBAA2B,MAAkB,OAC7C,WACA,KACA,QACA,CACA,UAEA,OACA,OACA,oBACA,eAEA,qBACA,0BACA,oBAA2B,MAAkC,SAC7D,WACA,KACA,QACA,CACA,kBACA,SACA,oBACA,+IACA,cACA,yGCzMA,QAgBA,GACA,6EAIA,QACA,iCAEA,UAIA,4BACA,QAKA,2BACA,OACA,IAKA,aACA,wBACA,yBACA,sBAKA,4DAsBS;;;;;;;;;;;WACT,QAZA,uDAaA,oFAA0F,wBAAgC,GAAG,wBAAgC,GAC7J,0CACA,MACA,sBAA0G,+EAE1G,2JAeA,yBACA,yBAAuC,IAAU,UAAS,gBAC1D,kBACA,MAgBA,2BACA,yBAAuC,IAAU,WAAU,gBAC3D,sBACA,SAKA,iCACA,kBAAsC,IAAU,IAAG,gBAAiB,yBACpE,KAKA,mCACA,uBAAqD,IAAU,IAAG,gBAAiB,yBACnF,MAGA,MAFA,wBACA,aAKA,uBACA,mBACA,WAAmC,IAAU,IAAG,gBAChD,2BAAmC,IAAU,IAAG,gBAEhD,kBAEA,sCACA,MAEA,+BACA,wBACA,sBACA,uCACA,oCAEA,uEACA,yBACA,qCACA,uDACA,uCAEA,wDACA,wBACA,0BAOA,gCACA,UACA,uBACA,6CACA,8DACA,wBACA,mCACA,kDACA,8BACA,gCACA,wBACA,uBACA,MACA,eACA,iCACA,wBACA,uBACA,MACA,EAKA,8BACA,UACA,uBACA,8GACA,+CACA,mBAEA,sCADA,eAEA,GAQA,gCACA,UACA,uBACA,2CACA,+BACA,qDACA,kBACA,uDACA,+BACA,wBACA,4BACA,+BACA,wBACA,uBACA,MACA,eACA,gCACA,wBACA,uBACA,MACA,EAQA,6BACA,UACA,mCACA,qDACA,wBACA,aACA,WACA,gBACA,2BACA,qCACA,4BACA,8CACA,kBACA,uBAEA,6FAEA,sCACA,uBACA,8CAEA,sBACA,UACA,GAOA,gBACA,SACA,mBACA,gBACA,2BACA,qCACA,mCACA,oDACA,kBACA,wDACA,sEACA,+DACA,QACA,QACA,QACA,MAOA,iBACA,SACA,oBACA,iBACA,2BACA,qCACA,mCACA,oDACA,kBACA,0DACA,sEACA,+DACA,QACA,QACA,QACA,OAKA,YACA,UACA,+BACA,yCACA,6BACA,4CACA,8BACA,6CACA,4BACA,0CACA,mCACA,qEACA,iEAAkE,uBAClE,eACA,oBACA,qBACA,sDACA,IACA,QACA,YAA2B,wBAAgC,WAC3D,YACA,gCACA,kJACA,4BACA,eACA,UACA,gBAEA,wBACA,IACA,yCACA,QACA,4BACA,QACA,eACA,sBAGA,MACA,sDAGA,+FACA,YACA,iBACA,QACA,KACA,OACA,eAA2B,wBAAgC,WAC3D,YACA,kDACA,0IACA,QACA,CACA,QAEA,CACA,CApVA,CAoVA,kdC3WA,yJAiBA,iCCNA,aACA,sEACA,QAGA,CACA,aACA,IACA,yBAGA,aACA,oCAEA,OACA,oCAEA,OACA,oCAGA,oBAGA,uEAMA,CACA,aAAkE,KAClE,IAAS,oEACT,2BACA,OACA,SACA,UACA,eACA,KACA,QACA,QACA,EACA,mBACA,IAIA,eAHA,SACA,UACA,sBAEA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCAGA,QACA,eACA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCAKA,SACA,eACA,IAIA,eAHA,SACA,UACA,sBAEA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCAGA,QACA,eACA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCAKA,SACA,eACA,KAIA,eAHA,SACA,YACA,wBAEA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCACA,oCAGA,QACA,eACA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCACA,oCAKA,SACA,eACA,KAIA,eAHA,SACA,YACA,wBAEA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCACA,oCAGA,QACA,eACA,cAAmC,EAAY,IAC/C,cAAuC,EAAW,IAClD,gCACA,oCACA,oCACA,oCAKA,SACA,eACA,aACA,KACA,UACA,oBAA2B,EAAY,IACvC,cAA+B,EAAW,QAC1C,mBACA,iBACA,iBACA,kDACA,MAEA,CACA,MACA,oBAAiD,0BAEjD,KACA,QAMA,CACA,aAA4D,KAC5D,IAAS,uIACT,mBAAS,UACT,4BAA0C,kDAC1C,oBAAkD,+BAClD,SAMA,CACA,aAAgE,KAChE,OACA,iBACA,sBACA,eAEA,gCACA,sBACA,iBAEA,kCACA,yBAEA,uBACA,iBAGA,wBACA,iHAAS,0HACT,4CACA,kBACA,aACA,iBACA,iBACA,iCAA4C,+BAC5C,SAgEA,uBACA,iBAAuD,KACvD,IACA,0CAEA,2BACA,yCAEA,2BACA,yBAEA,qFACA,iBAMA,aAEA,mMAiCA,MACA,iBAAiF,KACjF,IAAS,mHACT,2BACA,OACA,aACA,MACA,iCACA,eACA,QACA,EACA,mBACA,IAGA,OAFA,UACA,sBAEA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,+BACA,kCACA,kCACA,sBAGA,IACA,eACA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,sBACA,kCACA,kCACA,+BAKA,KACA,eACA,IAGA,OAFA,UACA,sBAEA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,+BACA,kCACA,kCACA,sBAGA,IACA,eACA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,sBACA,kCACA,kCACA,+BAKA,KACA,eACA,KAGA,OAFA,YACA,wBAEA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,+BACA,kCACA,kCACA,kCAGA,OACA,eACA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,sBACA,kCACA,kCACA,kCAKA,iBACA,eACA,KAGA,OAFA,YACA,wBAEA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,+BACA,kCACA,kCACA,kCAGA,OACA,eACA,WAAsC,OAAiB,IACvD,WAA0C,OAAiB,IAC3D,sBACA,kCACA,kCACA,kCAKA,iBACA,eACA,YAA8B,OAAiB,IAC/C,WAAkC,OAAiB,IACnD,gBACA,eACA,kCACA,kBAKA,wCAAmE,kDACnE,kCA9cA,QAUA,kCCFA,aAA2D,KAC3D,IAAS,kEACT,KAAS,UACT,6BACA,sBAIA,4BAHA,eAAuD,sBAEvD,WAIA,CACA,aAA+D,KAC/D,OACA,iBACA,sBACA,eAEA,gCACA,sBACA,iBAGA,mCACA,6IAAS,8CACT,qCACA,kBACA,aACA,iBACA,iBACA,oDACA,IAQA,CACA,aAAiD,KACjD,IAAS,kEACT,KAAS,UACT,qCACA,YACA,UACA,sBACA,4BACA,iCACA,kBACA,aACA,iBACA,+BACA,sCACA,IAcA,KACA,WAAgD,KAChD,gBACA,yBAEA,sDACA,wBAGA,wBACA,4IAGA,EAzFA,IA0FA,aAAoE,KACpE,IAAS,kEACT,KAAS,UACT,kCACA,eAAuD,oCAEvD,yBACA,6BA1FA,2FCPA,+EAOA,+BCPA,IAYA,eAEA,KACA,oBACA,SACA,eAAmB,MAAgB,OACnC,IACA,wBACA,qCACA,YAEA,WACA,cACA,MACA,kBACA,MACA,OACA,KACA,QACA,UACA,KACA,SACA,UACA,KACA,MACA,QACA,KACA,aACA,UACA,KAEA,cACA,SACA,eACA,MACA,IACA,gBAAmB,EAAO,IAC1B,WACA,MACA,QAQA,EAhDA,IAiDA,eAEA,KACA,oBACA,SACA,eAAmB,MAAgB,OACnC,IACA,wBACA,qCACA,YAEA,WACA,cACA,MACA,kBACA,MACA,OACA,KACA,QACA,UACA,KACA,SACA,UACA,KACA,MACA,QACA,KACA,aACA,UACA,KAEA,cACA,SACA,eACA,MACA,IACA,gBAAmB,EAAO,IAC1B,WACA,MACA","file":"webdnn.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WebDNN\"] = factory();\n\telse\n\t\troot[\"WebDNN\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 65d0ace7d910bc9a46b6","'use strict';\n\n\nvar TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n (typeof Uint16Array !== 'undefined') &&\n (typeof Int32Array !== 'undefined');\n\nfunction _has(obj, key) {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n\nexports.assign = function (obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n};\n\n\n// reduce buffer size, avoiding mem copy\nexports.shrinkBuf = function (buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n};\n\n\nvar fnTyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n }\n};\n\nvar fnUntyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n return [].concat.apply([], chunks);\n }\n};\n\n\n// Enable/Disable typed arrays use, for testing\n//\nexports.setTyped = function (on) {\n if (on) {\n exports.Buf8 = Uint8Array;\n exports.Buf16 = Uint16Array;\n exports.Buf32 = Int32Array;\n exports.assign(exports, fnTyped);\n } else {\n exports.Buf8 = Array;\n exports.Buf16 = Array;\n exports.Buf32 = Array;\n exports.assign(exports, fnUntyped);\n }\n};\n\nexports.setTyped(TYPED_OK);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/utils/common.js\n// module id = 0\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport DispatchScheduler from \"./util/dispatch_scheduler\";\n/**\n * @protected\n */\nlet transformDelegate = url => url;\n/**\n * Transform url generated based on current active backend\n * @param url transformed url\n * @protected\n */\nexport function transformUrl(url) {\n return transformDelegate(url);\n}\n/**\n * Register delegate function for transform url.\n * @param delegate Delegate function which will be called with original url, and must return converted url strings.\n * @protected\n */\nexport function registerTransformUrlDelegate(delegate) {\n transformDelegate = delegate;\n}\n/**\n * Fetch function. WebDNN API use this function instead of original `fetch` function.\n * FIXME\n * @param input Requested url\n * @param init Additional information about webdnnFetch\n * @param init.ignoreCache If true, cache is ignored by appending '?t=(timestamp)' to the end of request url.\n * @returns Response\n * @protected\n */\nexport default async function webdnnFetch(input, init) {\n if (typeof input == 'string') {\n input = transformUrl(input) + ((init && init.ignoreCache) ? '?t=' + Date.now() : '');\n }\n else {\n input = Object.assign({}, input, {\n url: transformUrl(input.url) + ((init && init.ignoreCache) ? '?t=' + Date.now() : '')\n });\n }\n let res;\n if (typeof input == 'string' && isXHR2WithBlobSupported()) {\n res = await fetchUsingXHR(input, init && init.progressCallback);\n }\n else {\n res = await fetch(input, init);\n }\n if (!res.ok)\n throw new Error(`Fetch returns status code ${res.status}: ${res.statusText}`);\n return res;\n}\n/**\n * Read `Response.body` stream as ArrayBuffer. This function provide progress information by callback.\n * @param res Response object\n * @param callback Callback function.\n * @returns ArrayBuffer\n * @protected\n */\nexport function readArrayBufferProgressively(res, callback) {\n if (!callback || !res.body)\n return res.arrayBuffer();\n let contentLength = res.headers.get('Content-Length');\n if (!contentLength)\n return res.arrayBuffer();\n const total = parseInt(contentLength);\n let buffer = new Uint8Array(total);\n let loaded = 0;\n let reader = res.body.getReader();\n let callbackScheduler = new DispatchScheduler();\n function accumulateLoadedSize(chunk) {\n buffer.set(chunk.value, loaded);\n loaded += chunk.value.length;\n if (callback) {\n callbackScheduler.request(() => callback(loaded, total));\n }\n if (loaded == total) {\n callbackScheduler.forceDispatch();\n return buffer.buffer;\n }\n else {\n return reader.read().then(accumulateLoadedSize);\n }\n }\n return reader.read().then(accumulateLoadedSize);\n}\n/**\n * check whether XMLHttpRequest with Blob type is supported or not\n * @protected\n */\nfunction isXHR2WithBlobSupported() {\n if (!window.hasOwnProperty('ProgressEvent') || !window.hasOwnProperty('FormData')) {\n return false;\n }\n let xhr = new XMLHttpRequest();\n if (typeof xhr.responseType === 'string') {\n try {\n xhr.responseType = 'blob';\n return xhr.responseType === 'blob';\n }\n catch (e) {\n return false;\n }\n }\n else {\n return false;\n }\n}\n/**\n * fetch with XMLHttpRequest\n * @protected\n */\nfunction fetchUsingXHR(url, callback) {\n return new Promise(function (resolve, reject) {\n let req = new XMLHttpRequest();\n req.open(\"GET\", url, true);\n req.responseType = \"blob\";\n let callbackScheduler = new DispatchScheduler();\n req.onload = function (event) {\n callbackScheduler.forceDispatch();\n let res = new Response(req.response);\n resolve(res);\n };\n req.onprogress = function (event) {\n if (callback) {\n callbackScheduler.request(function () { return callback(event.loaded, event.total); });\n }\n };\n req.onerror = function (event) {\n reject(event);\n };\n req.send(null);\n });\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/fetch.js\n// module id = 1\n// module chunks = 0","import DescriptorRunnerFallback from \"./descriptor_runner/descriptor_runner_fallback\";\nimport DescriptorRunnerWebassembly from \"./descriptor_runner/descriptor_runner_webassembly\";\nimport DescriptorRunnerWebGL from \"./descriptor_runner/descriptor_runner_webgl\";\nimport DescriptorRunnerWebGPU from \"./descriptor_runner/descriptor_runner_webgpu\";\nimport { registerTransformUrlDelegate } from \"./fetch\";\nimport * as Image from \"./image\";\nimport * as Math from \"./math\";\n/**\n * DEBUG flag for developing WebDNN\n * @private\n */\nlet configurations = {};\n/**\n * get configuration\n * @private\n */\nexport function getConfiguration(key, defaultValue) {\n return key in configurations ? configurations[key] : defaultValue;\n}\n/**\n * set configuration\n * @private\n */\nexport function setConfiguration(key, value) {\n configurations[key] = value;\n}\n/**\n * Backend constructor map\n * @private\n */\nconst descriptorRunners = {\n webgpu: DescriptorRunnerWebGPU,\n webgl: DescriptorRunnerWebGL,\n webassembly: DescriptorRunnerWebassembly,\n fallback: DescriptorRunnerFallback\n};\n/**\n * Check each computing backend is available or not in this browser.\n * The result will be returned as [[BackendAvailability|`BackendAvailability`]] structure.\n *\n * @returns backend availability\n */\nexport function getBackendAvailability() {\n let status = {\n 'webgpu': descriptorRunners['webgpu'].checkAvailability(),\n 'webgl': descriptorRunners['webgl'].checkAvailability(),\n 'webassembly': descriptorRunners['webassembly'].checkAvailability(),\n 'fallback': descriptorRunners['fallback'].checkAvailability(),\n };\n let order = ['webgpu', 'webgl', 'webassembly', 'fallback'].filter(backend => status[backend]);\n return {\n status: status,\n defaultOrder: order\n };\n}\n/**\n * Initialize specified backend\n * @private\n */\nasync function initBackend(backendName, option) {\n if (!(backendName in descriptorRunners))\n throw new Error(`Unknown backend: \"${backendName}\"`);\n let runner;\n try {\n runner = new descriptorRunners[backendName](option);\n await runner.init();\n }\n catch (ex) {\n console.warn(`Failed to initialize ${backendName} backend: ${ex}`);\n return null;\n }\n return runner;\n}\n/**\n * Initialize descriptor runner. This function performs follow things.\n *\n * 1. Try to initialize computing backend. WebDNN will try to initialize each backend in order of\n * the result of [[getBackendAvailability|`getBackendAvailability`]].\n * If you want to modify this order, specify [[InitOption.backendOrder|`initOption.backendOrder`]] option.\n *\n * 2. Load model data based on initialized backend. Generally, DNN binary data is very large and it takes long time to load.\n * [[InitOption.progressCallback|`initOption.progressCallback`]] option provides the progress status of loading.\n *\n * ### Examples\n *\n * - Basic usage\n *\n * ```js\n * let runner = await WebDNN.load('./model');\n * ```\n *\n * - With `initOption.progressCallback` option\n *\n * ```js\n * let runner = await WebDNN.load('./model', {\n * progressCallback: (loaded, total) => console.log(`${ (loaded/total*100).toFixed(1) }% Loaded`);\n * });\n * ```\n *\n * @param directory URL of directory that contains graph descriptor files (e.g. graph_webgpu.json)\n * @param initOption Initialize option\n * @return DescriptorRunner instance, which is the interface to input/output data and run the model.\n */\nexport async function load(directory, initOption = {}) {\n let { backendOrder = null, backendOptions = {}, cacheStrategy = 'latest', saveCache = true, progressCallback, weightDirectory, transformUrlDelegate } = initOption;\n if (!backendOrder)\n backendOrder = getBackendAvailability().defaultOrder;\n if (typeof backendOrder === 'string')\n backendOrder = [backendOrder];\n backendOrder = backendOrder.slice();\n if (backendOrder.indexOf('fallback') === -1)\n backendOrder.concat(['fallback']);\n registerTransformUrlDelegate((url) => {\n if (weightDirectory) {\n if ((/\\.bin/).test(url)) {\n url = url.replace(directory, weightDirectory);\n }\n }\n if (transformUrlDelegate)\n url = transformUrlDelegate(url);\n return url;\n });\n while (backendOrder.length > 0) {\n let backendName = backendOrder.shift();\n let runner = await initBackend(backendName, backendOptions[backendName]);\n if (!runner)\n continue;\n try {\n let descriptor;\n let parameters;\n let fetchedDescriptor;\n let cachedDescriptor;\n switch (cacheStrategy) {\n case 'latest':\n fetchedDescriptor = await runner.fetchDescriptor(directory).catch(() => null);\n cachedDescriptor = await runner.restoreCachedDescriptor(directory);\n if (cachedDescriptor && fetchedDescriptor && cachedDescriptor.converted_at === fetchedDescriptor.converted_at) {\n descriptor = cachedDescriptor;\n parameters = await runner.restoreCachedParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n if (fetchedDescriptor) {\n descriptor = fetchedDescriptor;\n parameters = await runner.fetchParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n if (cachedDescriptor) {\n descriptor = cachedDescriptor;\n parameters = await runner.restoreCachedParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n throw Error('Network error is occurred and no cache is exist.');\n case 'networkOnly':\n case 'networkFirst':\n fetchedDescriptor = await runner.fetchDescriptor(directory).catch(() => null);\n if (fetchedDescriptor) {\n descriptor = fetchedDescriptor;\n parameters = await runner.fetchParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n if (cacheStrategy === 'networkOnly')\n throw Error('Network error is occurred in \"networkOnly\" cache strategy');\n cachedDescriptor = await runner.restoreCachedDescriptor(directory);\n if (cachedDescriptor) {\n descriptor = cachedDescriptor;\n parameters = await runner.restoreCachedParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n throw Error('Network error is occurred and no cache is exist.');\n case 'cacheOnly':\n case 'cacheFirst':\n cachedDescriptor = await runner.restoreCachedDescriptor(directory);\n if (cachedDescriptor) {\n descriptor = cachedDescriptor;\n parameters = await runner.restoreCachedParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n if (cacheStrategy === 'cacheOnly')\n throw Error('No cache is exist in \"cacheOnly\" cache strategy');\n fetchedDescriptor = await runner.fetchDescriptor(directory).catch(() => null);\n if (fetchedDescriptor) {\n descriptor = fetchedDescriptor;\n parameters = await runner.fetchParameters(directory, progressCallback);\n if (parameters)\n break;\n }\n throw Error('Network error is occurred and no cache is exist.');\n default:\n throw Error(`\"${cacheStrategy}\" is not valid cache strategy name: \"latest\", \"networkFirst\", \"networkOnly\", \"cacheFirst\", \"cacheOnly\" is available.`);\n }\n if (saveCache) {\n try {\n await runner.saveCache(directory, descriptor, parameters);\n }\n catch (e) {\n /* do nothing */\n }\n }\n await runner.setDescriptorAndParameters(descriptor, parameters);\n }\n catch (ex) {\n console.warn(`Model loading failed for ${backendName} backend. Trying next backend: ${ex.message}`);\n continue;\n }\n return runner;\n }\n throw new Error('No backend is available');\n}\n// Export support (not-dependent) functions\nexport { Math, Image };\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webdnn.js\n// module id = 2\n// module chunks = 0","/*!\n localForage -- Offline Storage, Improved\n Version 1.5.6\n https://localforage.github.io/localForage\n (c) 2013-2017 Mozilla, Apache License 2.0\n*/\n(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.localforage = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw (f.code=\"MODULE_NOT_FOUND\", f)}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o element; its readystatechange event will be fired asynchronously once it is inserted\n // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.\n var scriptEl = global.document.createElement('script');\n scriptEl.onreadystatechange = function () {\n nextTick();\n\n scriptEl.onreadystatechange = null;\n scriptEl.parentNode.removeChild(scriptEl);\n scriptEl = null;\n };\n global.document.documentElement.appendChild(scriptEl);\n };\n } else {\n scheduleDrain = function () {\n setTimeout(nextTick, 0);\n };\n }\n}\n\nvar draining;\nvar queue = [];\n//named nextTick for less confusing stack traces\nfunction nextTick() {\n draining = true;\n var i, oldQueue;\n var len = queue.length;\n while (len) {\n oldQueue = queue;\n queue = [];\n i = -1;\n while (++i < len) {\n oldQueue[i]();\n }\n len = queue.length;\n }\n draining = false;\n}\n\nmodule.exports = immediate;\nfunction immediate(task) {\n if (queue.push(task) === 1 && !draining) {\n scheduleDrain();\n }\n}\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{}],2:[function(_dereq_,module,exports){\n'use strict';\nvar immediate = _dereq_(1);\n\n/* istanbul ignore next */\nfunction INTERNAL() {}\n\nvar handlers = {};\n\nvar REJECTED = ['REJECTED'];\nvar FULFILLED = ['FULFILLED'];\nvar PENDING = ['PENDING'];\n\nmodule.exports = Promise;\n\nfunction Promise(resolver) {\n if (typeof resolver !== 'function') {\n throw new TypeError('resolver must be a function');\n }\n this.state = PENDING;\n this.queue = [];\n this.outcome = void 0;\n if (resolver !== INTERNAL) {\n safelyResolveThenable(this, resolver);\n }\n}\n\nPromise.prototype[\"catch\"] = function (onRejected) {\n return this.then(null, onRejected);\n};\nPromise.prototype.then = function (onFulfilled, onRejected) {\n if (typeof onFulfilled !== 'function' && this.state === FULFILLED ||\n typeof onRejected !== 'function' && this.state === REJECTED) {\n return this;\n }\n var promise = new this.constructor(INTERNAL);\n if (this.state !== PENDING) {\n var resolver = this.state === FULFILLED ? onFulfilled : onRejected;\n unwrap(promise, resolver, this.outcome);\n } else {\n this.queue.push(new QueueItem(promise, onFulfilled, onRejected));\n }\n\n return promise;\n};\nfunction QueueItem(promise, onFulfilled, onRejected) {\n this.promise = promise;\n if (typeof onFulfilled === 'function') {\n this.onFulfilled = onFulfilled;\n this.callFulfilled = this.otherCallFulfilled;\n }\n if (typeof onRejected === 'function') {\n this.onRejected = onRejected;\n this.callRejected = this.otherCallRejected;\n }\n}\nQueueItem.prototype.callFulfilled = function (value) {\n handlers.resolve(this.promise, value);\n};\nQueueItem.prototype.otherCallFulfilled = function (value) {\n unwrap(this.promise, this.onFulfilled, value);\n};\nQueueItem.prototype.callRejected = function (value) {\n handlers.reject(this.promise, value);\n};\nQueueItem.prototype.otherCallRejected = function (value) {\n unwrap(this.promise, this.onRejected, value);\n};\n\nfunction unwrap(promise, func, value) {\n immediate(function () {\n var returnValue;\n try {\n returnValue = func(value);\n } catch (e) {\n return handlers.reject(promise, e);\n }\n if (returnValue === promise) {\n handlers.reject(promise, new TypeError('Cannot resolve promise with itself'));\n } else {\n handlers.resolve(promise, returnValue);\n }\n });\n}\n\nhandlers.resolve = function (self, value) {\n var result = tryCatch(getThen, value);\n if (result.status === 'error') {\n return handlers.reject(self, result.value);\n }\n var thenable = result.value;\n\n if (thenable) {\n safelyResolveThenable(self, thenable);\n } else {\n self.state = FULFILLED;\n self.outcome = value;\n var i = -1;\n var len = self.queue.length;\n while (++i < len) {\n self.queue[i].callFulfilled(value);\n }\n }\n return self;\n};\nhandlers.reject = function (self, error) {\n self.state = REJECTED;\n self.outcome = error;\n var i = -1;\n var len = self.queue.length;\n while (++i < len) {\n self.queue[i].callRejected(error);\n }\n return self;\n};\n\nfunction getThen(obj) {\n // Make sure we only access the accessor once as required by the spec\n var then = obj && obj.then;\n if (obj && (typeof obj === 'object' || typeof obj === 'function') && typeof then === 'function') {\n return function appyThen() {\n then.apply(obj, arguments);\n };\n }\n}\n\nfunction safelyResolveThenable(self, thenable) {\n // Either fulfill, reject or reject with error\n var called = false;\n function onError(value) {\n if (called) {\n return;\n }\n called = true;\n handlers.reject(self, value);\n }\n\n function onSuccess(value) {\n if (called) {\n return;\n }\n called = true;\n handlers.resolve(self, value);\n }\n\n function tryToUnwrap() {\n thenable(onSuccess, onError);\n }\n\n var result = tryCatch(tryToUnwrap);\n if (result.status === 'error') {\n onError(result.value);\n }\n}\n\nfunction tryCatch(func, value) {\n var out = {};\n try {\n out.value = func(value);\n out.status = 'success';\n } catch (e) {\n out.status = 'error';\n out.value = e;\n }\n return out;\n}\n\nPromise.resolve = resolve;\nfunction resolve(value) {\n if (value instanceof this) {\n return value;\n }\n return handlers.resolve(new this(INTERNAL), value);\n}\n\nPromise.reject = reject;\nfunction reject(reason) {\n var promise = new this(INTERNAL);\n return handlers.reject(promise, reason);\n}\n\nPromise.all = all;\nfunction all(iterable) {\n var self = this;\n if (Object.prototype.toString.call(iterable) !== '[object Array]') {\n return this.reject(new TypeError('must be an array'));\n }\n\n var len = iterable.length;\n var called = false;\n if (!len) {\n return this.resolve([]);\n }\n\n var values = new Array(len);\n var resolved = 0;\n var i = -1;\n var promise = new this(INTERNAL);\n\n while (++i < len) {\n allResolver(iterable[i], i);\n }\n return promise;\n function allResolver(value, i) {\n self.resolve(value).then(resolveFromAll, function (error) {\n if (!called) {\n called = true;\n handlers.reject(promise, error);\n }\n });\n function resolveFromAll(outValue) {\n values[i] = outValue;\n if (++resolved === len && !called) {\n called = true;\n handlers.resolve(promise, values);\n }\n }\n }\n}\n\nPromise.race = race;\nfunction race(iterable) {\n var self = this;\n if (Object.prototype.toString.call(iterable) !== '[object Array]') {\n return this.reject(new TypeError('must be an array'));\n }\n\n var len = iterable.length;\n var called = false;\n if (!len) {\n return this.resolve([]);\n }\n\n var i = -1;\n var promise = new this(INTERNAL);\n\n while (++i < len) {\n resolver(iterable[i]);\n }\n return promise;\n function resolver(value) {\n self.resolve(value).then(function (response) {\n if (!called) {\n called = true;\n handlers.resolve(promise, response);\n }\n }, function (error) {\n if (!called) {\n called = true;\n handlers.reject(promise, error);\n }\n });\n }\n}\n\n},{\"1\":1}],3:[function(_dereq_,module,exports){\n(function (global){\n'use strict';\nif (typeof global.Promise !== 'function') {\n global.Promise = _dereq_(2);\n}\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"2\":2}],4:[function(_dereq_,module,exports){\n'use strict';\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction getIDB() {\n /* global indexedDB,webkitIndexedDB,mozIndexedDB,OIndexedDB,msIndexedDB */\n try {\n if (typeof indexedDB !== 'undefined') {\n return indexedDB;\n }\n if (typeof webkitIndexedDB !== 'undefined') {\n return webkitIndexedDB;\n }\n if (typeof mozIndexedDB !== 'undefined') {\n return mozIndexedDB;\n }\n if (typeof OIndexedDB !== 'undefined') {\n return OIndexedDB;\n }\n if (typeof msIndexedDB !== 'undefined') {\n return msIndexedDB;\n }\n } catch (e) {\n return;\n }\n}\n\nvar idb = getIDB();\n\nfunction isIndexedDBValid() {\n try {\n // Initialize IndexedDB; fall back to vendor-prefixed versions\n // if needed.\n if (!idb) {\n return false;\n }\n // We mimic PouchDB here;\n //\n // We test for openDatabase because IE Mobile identifies itself\n // as Safari. Oh the lulz...\n var isSafari = typeof openDatabase !== 'undefined' && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform);\n\n var hasFetch = typeof fetch === 'function' && fetch.toString().indexOf('[native code') !== -1;\n\n // Safari <10.1 does not meet our requirements for IDB support (#5572)\n // since Safari 10.1 shipped with fetch, we can use that to detect it\n return (!isSafari || hasFetch) && typeof indexedDB !== 'undefined' &&\n // some outdated implementations of IDB that appear on Samsung\n // and HTC Android devices <4.4 are missing IDBKeyRange\n // See: https://github.com/mozilla/localForage/issues/128\n // See: https://github.com/mozilla/localForage/issues/272\n typeof IDBKeyRange !== 'undefined';\n } catch (e) {\n return false;\n }\n}\n\n// Abstracts constructing a Blob object, so it also works in older\n// browsers that don't support the native Blob constructor. (i.e.\n// old QtWebKit versions, at least).\n// Abstracts constructing a Blob object, so it also works in older\n// browsers that don't support the native Blob constructor. (i.e.\n// old QtWebKit versions, at least).\nfunction createBlob(parts, properties) {\n /* global BlobBuilder,MSBlobBuilder,MozBlobBuilder,WebKitBlobBuilder */\n parts = parts || [];\n properties = properties || {};\n try {\n return new Blob(parts, properties);\n } catch (e) {\n if (e.name !== 'TypeError') {\n throw e;\n }\n var Builder = typeof BlobBuilder !== 'undefined' ? BlobBuilder : typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder : typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : WebKitBlobBuilder;\n var builder = new Builder();\n for (var i = 0; i < parts.length; i += 1) {\n builder.append(parts[i]);\n }\n return builder.getBlob(properties.type);\n }\n}\n\n// This is CommonJS because lie is an external dependency, so Rollup\n// can just ignore it.\nif (typeof Promise === 'undefined') {\n // In the \"nopromises\" build this will just throw if you don't have\n // a global promise object, but it would throw anyway later.\n _dereq_(3);\n}\nvar Promise$1 = Promise;\n\nfunction executeCallback(promise, callback) {\n if (callback) {\n promise.then(function (result) {\n callback(null, result);\n }, function (error) {\n callback(error);\n });\n }\n}\n\nfunction executeTwoCallbacks(promise, callback, errorCallback) {\n if (typeof callback === 'function') {\n promise.then(callback);\n }\n\n if (typeof errorCallback === 'function') {\n promise[\"catch\"](errorCallback);\n }\n}\n\nfunction normalizeKey(key) {\n // Cast the key to a string, as that's all we can set as a key.\n if (typeof key !== 'string') {\n console.warn(key + ' used as a key, but it is not a string.');\n key = String(key);\n }\n\n return key;\n}\n\n// Some code originally from async_storage.js in\n// [Gaia](https://github.com/mozilla-b2g/gaia).\n\nvar DETECT_BLOB_SUPPORT_STORE = 'local-forage-detect-blob-support';\nvar supportsBlobs;\nvar dbContexts;\nvar toString = Object.prototype.toString;\n\n// Transaction Modes\nvar READ_ONLY = 'readonly';\nvar READ_WRITE = 'readwrite';\n\n// Transform a binary string to an array buffer, because otherwise\n// weird stuff happens when you try to work with the binary string directly.\n// It is known.\n// From http://stackoverflow.com/questions/14967647/ (continues on next line)\n// encode-decode-image-with-base64-breaks-image (2013-04-21)\nfunction _binStringToArrayBuffer(bin) {\n var length = bin.length;\n var buf = new ArrayBuffer(length);\n var arr = new Uint8Array(buf);\n for (var i = 0; i < length; i++) {\n arr[i] = bin.charCodeAt(i);\n }\n return buf;\n}\n\n//\n// Blobs are not supported in all versions of IndexedDB, notably\n// Chrome <37 and Android <5. In those versions, storing a blob will throw.\n//\n// Various other blob bugs exist in Chrome v37-42 (inclusive).\n// Detecting them is expensive and confusing to users, and Chrome 37-42\n// is at very low usage worldwide, so we do a hacky userAgent check instead.\n//\n// content-type bug: https://code.google.com/p/chromium/issues/detail?id=408120\n// 404 bug: https://code.google.com/p/chromium/issues/detail?id=447916\n// FileReader bug: https://code.google.com/p/chromium/issues/detail?id=447836\n//\n// Code borrowed from PouchDB. See:\n// https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-adapter-idb/src/blobSupport.js\n//\nfunction _checkBlobSupportWithoutCaching(idb) {\n return new Promise$1(function (resolve) {\n var txn = idb.transaction(DETECT_BLOB_SUPPORT_STORE, READ_WRITE);\n var blob = createBlob(['']);\n txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key');\n\n txn.onabort = function (e) {\n // If the transaction aborts now its due to not being able to\n // write to the database, likely due to the disk being full\n e.preventDefault();\n e.stopPropagation();\n resolve(false);\n };\n\n txn.oncomplete = function () {\n var matchedChrome = navigator.userAgent.match(/Chrome\\/(\\d+)/);\n var matchedEdge = navigator.userAgent.match(/Edge\\//);\n // MS Edge pretends to be Chrome 42:\n // https://msdn.microsoft.com/en-us/library/hh869301%28v=vs.85%29.aspx\n resolve(matchedEdge || !matchedChrome || parseInt(matchedChrome[1], 10) >= 43);\n };\n })[\"catch\"](function () {\n return false; // error, so assume unsupported\n });\n}\n\nfunction _checkBlobSupport(idb) {\n if (typeof supportsBlobs === 'boolean') {\n return Promise$1.resolve(supportsBlobs);\n }\n return _checkBlobSupportWithoutCaching(idb).then(function (value) {\n supportsBlobs = value;\n return supportsBlobs;\n });\n}\n\nfunction _deferReadiness(dbInfo) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Create a deferred object representing the current database operation.\n var deferredOperation = {};\n\n deferredOperation.promise = new Promise$1(function (resolve) {\n deferredOperation.resolve = resolve;\n });\n\n // Enqueue the deferred operation.\n dbContext.deferredOperations.push(deferredOperation);\n\n // Chain its promise to the database readiness.\n if (!dbContext.dbReady) {\n dbContext.dbReady = deferredOperation.promise;\n } else {\n dbContext.dbReady = dbContext.dbReady.then(function () {\n return deferredOperation.promise;\n });\n }\n}\n\nfunction _advanceReadiness(dbInfo) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Dequeue a deferred operation.\n var deferredOperation = dbContext.deferredOperations.pop();\n\n // Resolve its promise (which is part of the database readiness\n // chain of promises).\n if (deferredOperation) {\n deferredOperation.resolve();\n }\n}\n\nfunction _rejectReadiness(dbInfo, err) {\n var dbContext = dbContexts[dbInfo.name];\n\n // Dequeue a deferred operation.\n var deferredOperation = dbContext.deferredOperations.pop();\n\n // Reject its promise (which is part of the database readiness\n // chain of promises).\n if (deferredOperation) {\n deferredOperation.reject(err);\n }\n}\n\nfunction _getConnection(dbInfo, upgradeNeeded) {\n return new Promise$1(function (resolve, reject) {\n\n if (dbInfo.db) {\n if (upgradeNeeded) {\n _deferReadiness(dbInfo);\n dbInfo.db.close();\n } else {\n return resolve(dbInfo.db);\n }\n }\n\n var dbArgs = [dbInfo.name];\n\n if (upgradeNeeded) {\n dbArgs.push(dbInfo.version);\n }\n\n var openreq = idb.open.apply(idb, dbArgs);\n\n if (upgradeNeeded) {\n openreq.onupgradeneeded = function (e) {\n var db = openreq.result;\n try {\n db.createObjectStore(dbInfo.storeName);\n if (e.oldVersion <= 1) {\n // Added when support for blob shims was added\n db.createObjectStore(DETECT_BLOB_SUPPORT_STORE);\n }\n } catch (ex) {\n if (ex.name === 'ConstraintError') {\n console.warn('The database \"' + dbInfo.name + '\"' + ' has been upgraded from version ' + e.oldVersion + ' to version ' + e.newVersion + ', but the storage \"' + dbInfo.storeName + '\" already exists.');\n } else {\n throw ex;\n }\n }\n };\n }\n\n openreq.onerror = function (e) {\n e.preventDefault();\n reject(openreq.error);\n };\n\n openreq.onsuccess = function () {\n resolve(openreq.result);\n _advanceReadiness(dbInfo);\n };\n });\n}\n\nfunction _getOriginalConnection(dbInfo) {\n return _getConnection(dbInfo, false);\n}\n\nfunction _getUpgradedConnection(dbInfo) {\n return _getConnection(dbInfo, true);\n}\n\nfunction _isUpgradeNeeded(dbInfo, defaultVersion) {\n if (!dbInfo.db) {\n return true;\n }\n\n var isNewStore = !dbInfo.db.objectStoreNames.contains(dbInfo.storeName);\n var isDowngrade = dbInfo.version < dbInfo.db.version;\n var isUpgrade = dbInfo.version > dbInfo.db.version;\n\n if (isDowngrade) {\n // If the version is not the default one\n // then warn for impossible downgrade.\n if (dbInfo.version !== defaultVersion) {\n console.warn('The database \"' + dbInfo.name + '\"' + ' can\\'t be downgraded from version ' + dbInfo.db.version + ' to version ' + dbInfo.version + '.');\n }\n // Align the versions to prevent errors.\n dbInfo.version = dbInfo.db.version;\n }\n\n if (isUpgrade || isNewStore) {\n // If the store is new then increment the version (if needed).\n // This will trigger an \"upgradeneeded\" event which is required\n // for creating a store.\n if (isNewStore) {\n var incVersion = dbInfo.db.version + 1;\n if (incVersion > dbInfo.version) {\n dbInfo.version = incVersion;\n }\n }\n\n return true;\n }\n\n return false;\n}\n\n// encode a blob for indexeddb engines that don't support blobs\nfunction _encodeBlob(blob) {\n return new Promise$1(function (resolve, reject) {\n var reader = new FileReader();\n reader.onerror = reject;\n reader.onloadend = function (e) {\n var base64 = btoa(e.target.result || '');\n resolve({\n __local_forage_encoded_blob: true,\n data: base64,\n type: blob.type\n });\n };\n reader.readAsBinaryString(blob);\n });\n}\n\n// decode an encoded blob\nfunction _decodeBlob(encodedBlob) {\n var arrayBuff = _binStringToArrayBuffer(atob(encodedBlob.data));\n return createBlob([arrayBuff], { type: encodedBlob.type });\n}\n\n// is this one of our fancy encoded blobs?\nfunction _isEncodedBlob(value) {\n return value && value.__local_forage_encoded_blob;\n}\n\n// Specialize the default `ready()` function by making it dependent\n// on the current database operations. Thus, the driver will be actually\n// ready when it's been initialized (default) *and* there are no pending\n// operations on the database (initiated by some other instances).\nfunction _fullyReady(callback) {\n var self = this;\n\n var promise = self._initReady().then(function () {\n var dbContext = dbContexts[self._dbInfo.name];\n\n if (dbContext && dbContext.dbReady) {\n return dbContext.dbReady;\n }\n });\n\n executeTwoCallbacks(promise, callback, callback);\n return promise;\n}\n\n// Try to establish a new db connection to replace the\n// current one which is broken (i.e. experiencing\n// InvalidStateError while creating a transaction).\nfunction _tryReconnect(dbInfo) {\n _deferReadiness(dbInfo);\n\n var dbContext = dbContexts[dbInfo.name];\n var forages = dbContext.forages;\n\n for (var i = 0; i < forages.length; i++) {\n if (forages[i]._dbInfo.db) {\n forages[i]._dbInfo.db.close();\n forages[i]._dbInfo.db = null;\n }\n }\n\n return _getConnection(dbInfo, false).then(function (db) {\n for (var j = 0; j < forages.length; j++) {\n forages[j]._dbInfo.db = db;\n }\n })[\"catch\"](function (err) {\n _rejectReadiness(dbInfo, err);\n throw err;\n });\n}\n\n// FF doesn't like Promises (micro-tasks) and IDDB store operations,\n// so we have to do it with callbacks\nfunction createTransaction(dbInfo, mode, callback) {\n try {\n var tx = dbInfo.db.transaction(dbInfo.storeName, mode);\n callback(null, tx);\n } catch (err) {\n if (!dbInfo.db || err.name === 'InvalidStateError') {\n return _tryReconnect(dbInfo).then(function () {\n\n var tx = dbInfo.db.transaction(dbInfo.storeName, mode);\n callback(null, tx);\n });\n }\n\n callback(err);\n }\n}\n\n// Open the IndexedDB database (automatically creates one if one didn't\n// previously exist), using any options set in the config.\nfunction _initStorage(options) {\n var self = this;\n var dbInfo = {\n db: null\n };\n\n if (options) {\n for (var i in options) {\n dbInfo[i] = options[i];\n }\n }\n\n // Initialize a singleton container for all running localForages.\n if (!dbContexts) {\n dbContexts = {};\n }\n\n // Get the current context of the database;\n var dbContext = dbContexts[dbInfo.name];\n\n // ...or create a new context.\n if (!dbContext) {\n dbContext = {\n // Running localForages sharing a database.\n forages: [],\n // Shared database.\n db: null,\n // Database readiness (promise).\n dbReady: null,\n // Deferred operations on the database.\n deferredOperations: []\n };\n // Register the new context in the global container.\n dbContexts[dbInfo.name] = dbContext;\n }\n\n // Register itself as a running localForage in the current context.\n dbContext.forages.push(self);\n\n // Replace the default `ready()` function with the specialized one.\n if (!self._initReady) {\n self._initReady = self.ready;\n self.ready = _fullyReady;\n }\n\n // Create an array of initialization states of the related localForages.\n var initPromises = [];\n\n function ignoreErrors() {\n // Don't handle errors here,\n // just makes sure related localForages aren't pending.\n return Promise$1.resolve();\n }\n\n for (var j = 0; j < dbContext.forages.length; j++) {\n var forage = dbContext.forages[j];\n if (forage !== self) {\n // Don't wait for itself...\n initPromises.push(forage._initReady()[\"catch\"](ignoreErrors));\n }\n }\n\n // Take a snapshot of the related localForages.\n var forages = dbContext.forages.slice(0);\n\n // Initialize the connection process only when\n // all the related localForages aren't pending.\n return Promise$1.all(initPromises).then(function () {\n dbInfo.db = dbContext.db;\n // Get the connection or open a new one without upgrade.\n return _getOriginalConnection(dbInfo);\n }).then(function (db) {\n dbInfo.db = db;\n if (_isUpgradeNeeded(dbInfo, self._defaultConfig.version)) {\n // Reopen the database for upgrading.\n return _getUpgradedConnection(dbInfo);\n }\n return db;\n }).then(function (db) {\n dbInfo.db = dbContext.db = db;\n self._dbInfo = dbInfo;\n // Share the final connection amongst related localForages.\n for (var k = 0; k < forages.length; k++) {\n var forage = forages[k];\n if (forage !== self) {\n // Self is already up-to-date.\n forage._dbInfo.db = dbInfo.db;\n forage._dbInfo.version = dbInfo.version;\n }\n }\n });\n}\n\nfunction getItem(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.get(key);\n\n req.onsuccess = function () {\n var value = req.result;\n if (value === undefined) {\n value = null;\n }\n if (_isEncodedBlob(value)) {\n value = _decodeBlob(value);\n }\n resolve(value);\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Iterate over all items stored in database.\nfunction iterate(iterator, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.openCursor();\n var iterationNumber = 1;\n\n req.onsuccess = function () {\n var cursor = req.result;\n\n if (cursor) {\n var value = cursor.value;\n if (_isEncodedBlob(value)) {\n value = _decodeBlob(value);\n }\n var result = iterator(value, cursor.key, iterationNumber++);\n\n // when the iterator callback retuns any\n // (non-`undefined`) value, then we stop\n // the iteration immediately\n if (result !== void 0) {\n resolve(result);\n } else {\n cursor[\"continue\"]();\n }\n } else {\n resolve();\n }\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n\n return promise;\n}\n\nfunction setItem(key, value, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n var dbInfo;\n self.ready().then(function () {\n dbInfo = self._dbInfo;\n if (toString.call(value) === '[object Blob]') {\n return _checkBlobSupport(dbInfo.db).then(function (blobSupport) {\n if (blobSupport) {\n return value;\n }\n return _encodeBlob(value);\n });\n }\n return value;\n }).then(function (value) {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n\n // The reason we don't _save_ null is because IE 10 does\n // not support saving the `null` type in IndexedDB. How\n // ironic, given the bug below!\n // See: https://github.com/mozilla/localForage/issues/161\n if (value === null) {\n value = undefined;\n }\n\n var req = store.put(value, key);\n\n transaction.oncomplete = function () {\n // Cast to undefined so the value passed to\n // callback/promise is the same as what one would get out\n // of `getItem()` later. This leads to some weirdness\n // (setItem('foo', undefined) will return `null`), but\n // it's not my fault localStorage is our baseline and that\n // it's weird.\n if (value === undefined) {\n value = null;\n }\n\n resolve(value);\n };\n transaction.onabort = transaction.onerror = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction removeItem(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n // We use a Grunt task to make this safe for IE and some\n // versions of Android (including those used by Cordova).\n // Normally IE won't like `.delete()` and will insist on\n // using `['delete']()`, but we have a build step that\n // fixes this for us now.\n var req = store[\"delete\"](key);\n transaction.oncomplete = function () {\n resolve();\n };\n\n transaction.onerror = function () {\n reject(req.error);\n };\n\n // The request will be also be aborted if we've exceeded our storage\n // space.\n transaction.onabort = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction clear(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.clear();\n\n transaction.oncomplete = function () {\n resolve();\n };\n\n transaction.onabort = transaction.onerror = function () {\n var err = req.error ? req.error : req.transaction.error;\n reject(err);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction length(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.count();\n\n req.onsuccess = function () {\n resolve(req.result);\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction key(n, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n if (n < 0) {\n resolve(null);\n\n return;\n }\n\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var advanced = false;\n var req = store.openCursor();\n\n req.onsuccess = function () {\n var cursor = req.result;\n if (!cursor) {\n // this means there weren't enough keys\n resolve(null);\n\n return;\n }\n\n if (n === 0) {\n // We have the first key, return it if that's what they\n // wanted.\n resolve(cursor.key);\n } else {\n if (!advanced) {\n // Otherwise, ask the cursor to skip ahead n\n // records.\n advanced = true;\n cursor.advance(n);\n } else {\n // When we get here, we've got the nth key.\n resolve(cursor.key);\n }\n }\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {\n if (err) {\n return reject(err);\n }\n\n try {\n var store = transaction.objectStore(self._dbInfo.storeName);\n var req = store.openCursor();\n var keys = [];\n\n req.onsuccess = function () {\n var cursor = req.result;\n\n if (!cursor) {\n resolve(keys);\n return;\n }\n\n keys.push(cursor.key);\n cursor[\"continue\"]();\n };\n\n req.onerror = function () {\n reject(req.error);\n };\n } catch (e) {\n reject(e);\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar asyncStorage = {\n _driver: 'asyncStorage',\n _initStorage: _initStorage,\n _support: isIndexedDBValid(),\n iterate: iterate,\n getItem: getItem,\n setItem: setItem,\n removeItem: removeItem,\n clear: clear,\n length: length,\n key: key,\n keys: keys\n};\n\nfunction isWebSQLValid() {\n return typeof openDatabase === 'function';\n}\n\n// Sadly, the best way to save binary data in WebSQL/localStorage is serializing\n// it to Base64, so this is how we store it to prevent very strange errors with less\n// verbose ways of binary <-> string data storage.\nvar BASE_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\nvar BLOB_TYPE_PREFIX = '~~local_forage_type~';\nvar BLOB_TYPE_PREFIX_REGEX = /^~~local_forage_type~([^~]+)~/;\n\nvar SERIALIZED_MARKER = '__lfsc__:';\nvar SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER.length;\n\n// OMG the serializations!\nvar TYPE_ARRAYBUFFER = 'arbf';\nvar TYPE_BLOB = 'blob';\nvar TYPE_INT8ARRAY = 'si08';\nvar TYPE_UINT8ARRAY = 'ui08';\nvar TYPE_UINT8CLAMPEDARRAY = 'uic8';\nvar TYPE_INT16ARRAY = 'si16';\nvar TYPE_INT32ARRAY = 'si32';\nvar TYPE_UINT16ARRAY = 'ur16';\nvar TYPE_UINT32ARRAY = 'ui32';\nvar TYPE_FLOAT32ARRAY = 'fl32';\nvar TYPE_FLOAT64ARRAY = 'fl64';\nvar TYPE_SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER_LENGTH + TYPE_ARRAYBUFFER.length;\n\nvar toString$1 = Object.prototype.toString;\n\nfunction stringToBuffer(serializedString) {\n // Fill the string into a ArrayBuffer.\n var bufferLength = serializedString.length * 0.75;\n var len = serializedString.length;\n var i;\n var p = 0;\n var encoded1, encoded2, encoded3, encoded4;\n\n if (serializedString[serializedString.length - 1] === '=') {\n bufferLength--;\n if (serializedString[serializedString.length - 2] === '=') {\n bufferLength--;\n }\n }\n\n var buffer = new ArrayBuffer(bufferLength);\n var bytes = new Uint8Array(buffer);\n\n for (i = 0; i < len; i += 4) {\n encoded1 = BASE_CHARS.indexOf(serializedString[i]);\n encoded2 = BASE_CHARS.indexOf(serializedString[i + 1]);\n encoded3 = BASE_CHARS.indexOf(serializedString[i + 2]);\n encoded4 = BASE_CHARS.indexOf(serializedString[i + 3]);\n\n /*jslint bitwise: true */\n bytes[p++] = encoded1 << 2 | encoded2 >> 4;\n bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;\n bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;\n }\n return buffer;\n}\n\n// Converts a buffer to a string to store, serialized, in the backend\n// storage library.\nfunction bufferToString(buffer) {\n // base64-arraybuffer\n var bytes = new Uint8Array(buffer);\n var base64String = '';\n var i;\n\n for (i = 0; i < bytes.length; i += 3) {\n /*jslint bitwise: true */\n base64String += BASE_CHARS[bytes[i] >> 2];\n base64String += BASE_CHARS[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];\n base64String += BASE_CHARS[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];\n base64String += BASE_CHARS[bytes[i + 2] & 63];\n }\n\n if (bytes.length % 3 === 2) {\n base64String = base64String.substring(0, base64String.length - 1) + '=';\n } else if (bytes.length % 3 === 1) {\n base64String = base64String.substring(0, base64String.length - 2) + '==';\n }\n\n return base64String;\n}\n\n// Serialize a value, afterwards executing a callback (which usually\n// instructs the `setItem()` callback/promise to be executed). This is how\n// we store binary data with localStorage.\nfunction serialize(value, callback) {\n var valueType = '';\n if (value) {\n valueType = toString$1.call(value);\n }\n\n // Cannot use `value instanceof ArrayBuffer` or such here, as these\n // checks fail when running the tests using casper.js...\n //\n // TODO: See why those tests fail and use a better solution.\n if (value && (valueType === '[object ArrayBuffer]' || value.buffer && toString$1.call(value.buffer) === '[object ArrayBuffer]')) {\n // Convert binary arrays to a string and prefix the string with\n // a special marker.\n var buffer;\n var marker = SERIALIZED_MARKER;\n\n if (value instanceof ArrayBuffer) {\n buffer = value;\n marker += TYPE_ARRAYBUFFER;\n } else {\n buffer = value.buffer;\n\n if (valueType === '[object Int8Array]') {\n marker += TYPE_INT8ARRAY;\n } else if (valueType === '[object Uint8Array]') {\n marker += TYPE_UINT8ARRAY;\n } else if (valueType === '[object Uint8ClampedArray]') {\n marker += TYPE_UINT8CLAMPEDARRAY;\n } else if (valueType === '[object Int16Array]') {\n marker += TYPE_INT16ARRAY;\n } else if (valueType === '[object Uint16Array]') {\n marker += TYPE_UINT16ARRAY;\n } else if (valueType === '[object Int32Array]') {\n marker += TYPE_INT32ARRAY;\n } else if (valueType === '[object Uint32Array]') {\n marker += TYPE_UINT32ARRAY;\n } else if (valueType === '[object Float32Array]') {\n marker += TYPE_FLOAT32ARRAY;\n } else if (valueType === '[object Float64Array]') {\n marker += TYPE_FLOAT64ARRAY;\n } else {\n callback(new Error('Failed to get type for BinaryArray'));\n }\n }\n\n callback(marker + bufferToString(buffer));\n } else if (valueType === '[object Blob]') {\n // Conver the blob to a binaryArray and then to a string.\n var fileReader = new FileReader();\n\n fileReader.onload = function () {\n // Backwards-compatible prefix for the blob type.\n var str = BLOB_TYPE_PREFIX + value.type + '~' + bufferToString(this.result);\n\n callback(SERIALIZED_MARKER + TYPE_BLOB + str);\n };\n\n fileReader.readAsArrayBuffer(value);\n } else {\n try {\n callback(JSON.stringify(value));\n } catch (e) {\n console.error(\"Couldn't convert value into a JSON string: \", value);\n\n callback(null, e);\n }\n }\n}\n\n// Deserialize data we've inserted into a value column/field. We place\n// special markers into our strings to mark them as encoded; this isn't\n// as nice as a meta field, but it's the only sane thing we can do whilst\n// keeping localStorage support intact.\n//\n// Oftentimes this will just deserialize JSON content, but if we have a\n// special marker (SERIALIZED_MARKER, defined above), we will extract\n// some kind of arraybuffer/binary data/typed array out of the string.\nfunction deserialize(value) {\n // If we haven't marked this string as being specially serialized (i.e.\n // something other than serialized JSON), we can just return it and be\n // done with it.\n if (value.substring(0, SERIALIZED_MARKER_LENGTH) !== SERIALIZED_MARKER) {\n return JSON.parse(value);\n }\n\n // The following code deals with deserializing some kind of Blob or\n // TypedArray. First we separate out the type of data we're dealing\n // with from the data itself.\n var serializedString = value.substring(TYPE_SERIALIZED_MARKER_LENGTH);\n var type = value.substring(SERIALIZED_MARKER_LENGTH, TYPE_SERIALIZED_MARKER_LENGTH);\n\n var blobType;\n // Backwards-compatible blob type serialization strategy.\n // DBs created with older versions of localForage will simply not have the blob type.\n if (type === TYPE_BLOB && BLOB_TYPE_PREFIX_REGEX.test(serializedString)) {\n var matcher = serializedString.match(BLOB_TYPE_PREFIX_REGEX);\n blobType = matcher[1];\n serializedString = serializedString.substring(matcher[0].length);\n }\n var buffer = stringToBuffer(serializedString);\n\n // Return the right type based on the code/type set during\n // serialization.\n switch (type) {\n case TYPE_ARRAYBUFFER:\n return buffer;\n case TYPE_BLOB:\n return createBlob([buffer], { type: blobType });\n case TYPE_INT8ARRAY:\n return new Int8Array(buffer);\n case TYPE_UINT8ARRAY:\n return new Uint8Array(buffer);\n case TYPE_UINT8CLAMPEDARRAY:\n return new Uint8ClampedArray(buffer);\n case TYPE_INT16ARRAY:\n return new Int16Array(buffer);\n case TYPE_UINT16ARRAY:\n return new Uint16Array(buffer);\n case TYPE_INT32ARRAY:\n return new Int32Array(buffer);\n case TYPE_UINT32ARRAY:\n return new Uint32Array(buffer);\n case TYPE_FLOAT32ARRAY:\n return new Float32Array(buffer);\n case TYPE_FLOAT64ARRAY:\n return new Float64Array(buffer);\n default:\n throw new Error('Unkown type: ' + type);\n }\n}\n\nvar localforageSerializer = {\n serialize: serialize,\n deserialize: deserialize,\n stringToBuffer: stringToBuffer,\n bufferToString: bufferToString\n};\n\n/*\n * Includes code from:\n *\n * base64-arraybuffer\n * https://github.com/niklasvh/base64-arraybuffer\n *\n * Copyright (c) 2012 Niklas von Hertzen\n * Licensed under the MIT license.\n */\n// Open the WebSQL database (automatically creates one if one didn't\n// previously exist), using any options set in the config.\nfunction _initStorage$1(options) {\n var self = this;\n var dbInfo = {\n db: null\n };\n\n if (options) {\n for (var i in options) {\n dbInfo[i] = typeof options[i] !== 'string' ? options[i].toString() : options[i];\n }\n }\n\n var dbInfoPromise = new Promise$1(function (resolve, reject) {\n // Open the database; the openDatabase API will automatically\n // create it for us if it doesn't exist.\n try {\n dbInfo.db = openDatabase(dbInfo.name, String(dbInfo.version), dbInfo.description, dbInfo.size);\n } catch (e) {\n return reject(e);\n }\n\n // Create our key/value table if it doesn't exist.\n dbInfo.db.transaction(function (t) {\n t.executeSql('CREATE TABLE IF NOT EXISTS ' + dbInfo.storeName + ' (id INTEGER PRIMARY KEY, key unique, value)', [], function () {\n self._dbInfo = dbInfo;\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n });\n\n dbInfo.serializer = localforageSerializer;\n return dbInfoPromise;\n}\n\nfunction getItem$1(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE key = ? LIMIT 1', [key], function (t, results) {\n var result = results.rows.length ? results.rows.item(0).value : null;\n\n // Check to see if this is serialized content we need to\n // unpack.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n resolve(result);\n }, function (t, error) {\n\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction iterate$1(iterator, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT * FROM ' + dbInfo.storeName, [], function (t, results) {\n var rows = results.rows;\n var length = rows.length;\n\n for (var i = 0; i < length; i++) {\n var item = rows.item(i);\n var result = item.value;\n\n // Check to see if this is serialized content\n // we need to unpack.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n result = iterator(result, item.key, i + 1);\n\n // void(0) prevents problems with redefinition\n // of `undefined`.\n if (result !== void 0) {\n resolve(result);\n return;\n }\n }\n\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction _setItem(key, value, callback, retriesLeft) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n // The localStorage API doesn't return undefined values in an\n // \"expected\" way, so undefined is always cast to null in all\n // drivers. See: https://github.com/mozilla/localForage/pull/42\n if (value === undefined) {\n value = null;\n }\n\n // Save the original value to pass to the callback.\n var originalValue = value;\n\n var dbInfo = self._dbInfo;\n dbInfo.serializer.serialize(value, function (value, error) {\n if (error) {\n reject(error);\n } else {\n dbInfo.db.transaction(function (t) {\n t.executeSql('INSERT OR REPLACE INTO ' + dbInfo.storeName + ' (key, value) VALUES (?, ?)', [key, value], function () {\n resolve(originalValue);\n }, function (t, error) {\n reject(error);\n });\n }, function (sqlError) {\n // The transaction failed; check\n // to see if it's a quota error.\n if (sqlError.code === sqlError.QUOTA_ERR) {\n // We reject the callback outright for now, but\n // it's worth trying to re-run the transaction.\n // Even if the user accepts the prompt to use\n // more storage on Safari, this error will\n // be called.\n //\n // Try to re-run the transaction.\n if (retriesLeft > 0) {\n resolve(_setItem.apply(self, [key, originalValue, callback, retriesLeft - 1]));\n return;\n }\n reject(sqlError);\n }\n });\n }\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction setItem$1(key, value, callback) {\n return _setItem.apply(this, [key, value, callback, 1]);\n}\n\nfunction removeItem$1(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('DELETE FROM ' + dbInfo.storeName + ' WHERE key = ?', [key], function () {\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Deletes every item in the table.\n// TODO: Find out if this resets the AUTO_INCREMENT number.\nfunction clear$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('DELETE FROM ' + dbInfo.storeName, [], function () {\n resolve();\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Does a simple `COUNT(key)` to get the number of items stored in\n// localForage.\nfunction length$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n // Ahhh, SQL makes this one soooooo easy.\n t.executeSql('SELECT COUNT(key) as c FROM ' + dbInfo.storeName, [], function (t, results) {\n var result = results.rows.item(0).c;\n\n resolve(result);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Return the key located at key index X; essentially gets the key from a\n// `WHERE id = ?`. This is the most efficient way I can think to implement\n// this rarely-used (in my experience) part of the API, but it can seem\n// inconsistent, because we do `INSERT OR REPLACE INTO` on `setItem()`, so\n// the ID of each key will change every time it's updated. Perhaps a stored\n// procedure for the `setItem()` SQL would solve this problem?\n// TODO: Don't change ID on `setItem()`.\nfunction key$1(n, callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT key FROM ' + dbInfo.storeName + ' WHERE id = ? LIMIT 1', [n + 1], function (t, results) {\n var result = results.rows.length ? results.rows.item(0).key : null;\n resolve(result);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys$1(callback) {\n var self = this;\n\n var promise = new Promise$1(function (resolve, reject) {\n self.ready().then(function () {\n var dbInfo = self._dbInfo;\n dbInfo.db.transaction(function (t) {\n t.executeSql('SELECT key FROM ' + dbInfo.storeName, [], function (t, results) {\n var keys = [];\n\n for (var i = 0; i < results.rows.length; i++) {\n keys.push(results.rows.item(i).key);\n }\n\n resolve(keys);\n }, function (t, error) {\n reject(error);\n });\n });\n })[\"catch\"](reject);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar webSQLStorage = {\n _driver: 'webSQLStorage',\n _initStorage: _initStorage$1,\n _support: isWebSQLValid(),\n iterate: iterate$1,\n getItem: getItem$1,\n setItem: setItem$1,\n removeItem: removeItem$1,\n clear: clear$1,\n length: length$1,\n key: key$1,\n keys: keys$1\n};\n\nfunction isLocalStorageValid() {\n try {\n return typeof localStorage !== 'undefined' && 'setItem' in localStorage && typeof localStorage.setItem === 'function';\n } catch (e) {\n return false;\n }\n}\n\n// Check if localStorage throws when saving an item\nfunction checkIfLocalStorageThrows() {\n var localStorageTestKey = '_localforage_support_test';\n\n try {\n localStorage.setItem(localStorageTestKey, true);\n localStorage.removeItem(localStorageTestKey);\n\n return false;\n } catch (e) {\n return true;\n }\n}\n\n// Check if localStorage is usable and allows to save an item\n// This method checks if localStorage is usable in Safari Private Browsing\n// mode, or in any other case where the available quota for localStorage\n// is 0 and there wasn't any saved items yet.\nfunction _isLocalStorageUsable() {\n return !checkIfLocalStorageThrows() || localStorage.length > 0;\n}\n\n// Config the localStorage backend, using options set in the config.\nfunction _initStorage$2(options) {\n var self = this;\n var dbInfo = {};\n if (options) {\n for (var i in options) {\n dbInfo[i] = options[i];\n }\n }\n\n dbInfo.keyPrefix = dbInfo.name + '/';\n\n if (dbInfo.storeName !== self._defaultConfig.storeName) {\n dbInfo.keyPrefix += dbInfo.storeName + '/';\n }\n\n if (!_isLocalStorageUsable()) {\n return Promise$1.reject();\n }\n\n self._dbInfo = dbInfo;\n dbInfo.serializer = localforageSerializer;\n\n return Promise$1.resolve();\n}\n\n// Remove all keys from the datastore, effectively destroying all data in\n// the app's key/value store!\nfunction clear$2(callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var keyPrefix = self._dbInfo.keyPrefix;\n\n for (var i = localStorage.length - 1; i >= 0; i--) {\n var key = localStorage.key(i);\n\n if (key.indexOf(keyPrefix) === 0) {\n localStorage.removeItem(key);\n }\n }\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Retrieve an item from the store. Unlike the original async_storage\n// library in Gaia, we don't modify return values at all. If a key's value\n// is `undefined`, we pass that value to the callback function.\nfunction getItem$2(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var result = localStorage.getItem(dbInfo.keyPrefix + key);\n\n // If a result was found, parse it from the serialized\n // string into a JS object. If result isn't truthy, the key\n // is likely undefined and we'll pass it straight to the\n // callback.\n if (result) {\n result = dbInfo.serializer.deserialize(result);\n }\n\n return result;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Iterate over all items in the store.\nfunction iterate$2(iterator, callback) {\n var self = this;\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var keyPrefix = dbInfo.keyPrefix;\n var keyPrefixLength = keyPrefix.length;\n var length = localStorage.length;\n\n // We use a dedicated iterator instead of the `i` variable below\n // so other keys we fetch in localStorage aren't counted in\n // the `iterationNumber` argument passed to the `iterate()`\n // callback.\n //\n // See: github.com/mozilla/localForage/pull/435#discussion_r38061530\n var iterationNumber = 1;\n\n for (var i = 0; i < length; i++) {\n var key = localStorage.key(i);\n if (key.indexOf(keyPrefix) !== 0) {\n continue;\n }\n var value = localStorage.getItem(key);\n\n // If a result was found, parse it from the serialized\n // string into a JS object. If result isn't truthy, the\n // key is likely undefined and we'll pass it straight\n // to the iterator.\n if (value) {\n value = dbInfo.serializer.deserialize(value);\n }\n\n value = iterator(value, key.substring(keyPrefixLength), iterationNumber++);\n\n if (value !== void 0) {\n return value;\n }\n }\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Same as localStorage's key() method, except takes a callback.\nfunction key$2(n, callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var result;\n try {\n result = localStorage.key(n);\n } catch (error) {\n result = null;\n }\n\n // Remove the prefix from the key, if a key is found.\n if (result) {\n result = result.substring(dbInfo.keyPrefix.length);\n }\n\n return result;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nfunction keys$2(callback) {\n var self = this;\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n var length = localStorage.length;\n var keys = [];\n\n for (var i = 0; i < length; i++) {\n var itemKey = localStorage.key(i);\n if (itemKey.indexOf(dbInfo.keyPrefix) === 0) {\n keys.push(itemKey.substring(dbInfo.keyPrefix.length));\n }\n }\n\n return keys;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Supply the number of keys in the datastore to the callback function.\nfunction length$2(callback) {\n var self = this;\n var promise = self.keys().then(function (keys) {\n return keys.length;\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Remove an item from the store, nice and simple.\nfunction removeItem$2(key, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n var dbInfo = self._dbInfo;\n localStorage.removeItem(dbInfo.keyPrefix + key);\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\n// Set a key's value and run an optional callback once the value is set.\n// Unlike Gaia's implementation, the callback function is passed the value,\n// in case you want to operate on that value only after you're sure it\n// saved, or something like that.\nfunction setItem$2(key, value, callback) {\n var self = this;\n\n key = normalizeKey(key);\n\n var promise = self.ready().then(function () {\n // Convert undefined values to null.\n // https://github.com/mozilla/localForage/pull/42\n if (value === undefined) {\n value = null;\n }\n\n // Save the original value to pass to the callback.\n var originalValue = value;\n\n return new Promise$1(function (resolve, reject) {\n var dbInfo = self._dbInfo;\n dbInfo.serializer.serialize(value, function (value, error) {\n if (error) {\n reject(error);\n } else {\n try {\n localStorage.setItem(dbInfo.keyPrefix + key, value);\n resolve(originalValue);\n } catch (e) {\n // localStorage capacity exceeded.\n // TODO: Make this a specific error/event.\n if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {\n reject(e);\n }\n reject(e);\n }\n }\n });\n });\n });\n\n executeCallback(promise, callback);\n return promise;\n}\n\nvar localStorageWrapper = {\n _driver: 'localStorageWrapper',\n _initStorage: _initStorage$2,\n _support: isLocalStorageValid(),\n iterate: iterate$2,\n getItem: getItem$2,\n setItem: setItem$2,\n removeItem: removeItem$2,\n clear: clear$2,\n length: length$2,\n key: key$2,\n keys: keys$2\n};\n\nvar isArray = Array.isArray || function (arg) {\n return Object.prototype.toString.call(arg) === '[object Array]';\n};\n\n// Drivers are stored here when `defineDriver()` is called.\n// They are shared across all instances of localForage.\nvar DefinedDrivers = {};\n\nvar DriverSupport = {};\n\nvar DefaultDrivers = {\n INDEXEDDB: asyncStorage,\n WEBSQL: webSQLStorage,\n LOCALSTORAGE: localStorageWrapper\n};\n\nvar DefaultDriverOrder = [DefaultDrivers.INDEXEDDB._driver, DefaultDrivers.WEBSQL._driver, DefaultDrivers.LOCALSTORAGE._driver];\n\nvar LibraryMethods = ['clear', 'getItem', 'iterate', 'key', 'keys', 'length', 'removeItem', 'setItem'];\n\nvar DefaultConfig = {\n description: '',\n driver: DefaultDriverOrder.slice(),\n name: 'localforage',\n // Default DB size is _JUST UNDER_ 5MB, as it's the highest size\n // we can use without a prompt.\n size: 4980736,\n storeName: 'keyvaluepairs',\n version: 1.0\n};\n\nfunction callWhenReady(localForageInstance, libraryMethod) {\n localForageInstance[libraryMethod] = function () {\n var _args = arguments;\n return localForageInstance.ready().then(function () {\n return localForageInstance[libraryMethod].apply(localForageInstance, _args);\n });\n };\n}\n\nfunction extend() {\n for (var i = 1; i < arguments.length; i++) {\n var arg = arguments[i];\n\n if (arg) {\n for (var _key in arg) {\n if (arg.hasOwnProperty(_key)) {\n if (isArray(arg[_key])) {\n arguments[0][_key] = arg[_key].slice();\n } else {\n arguments[0][_key] = arg[_key];\n }\n }\n }\n }\n }\n\n return arguments[0];\n}\n\nvar LocalForage = function () {\n function LocalForage(options) {\n _classCallCheck(this, LocalForage);\n\n for (var driverTypeKey in DefaultDrivers) {\n if (DefaultDrivers.hasOwnProperty(driverTypeKey)) {\n var driver = DefaultDrivers[driverTypeKey];\n var driverName = driver._driver;\n this[driverTypeKey] = driverName;\n\n if (!DefinedDrivers[driverName]) {\n // we don't need to wait for the promise,\n // since the default drivers can be defined\n // in a blocking manner\n this.defineDriver(driver);\n }\n }\n }\n\n this._defaultConfig = extend({}, DefaultConfig);\n this._config = extend({}, this._defaultConfig, options);\n this._driverSet = null;\n this._initDriver = null;\n this._ready = false;\n this._dbInfo = null;\n\n this._wrapLibraryMethodsWithReady();\n this.setDriver(this._config.driver)[\"catch\"](function () {});\n }\n\n // Set any config values for localForage; can be called anytime before\n // the first API call (e.g. `getItem`, `setItem`).\n // We loop through options so we don't overwrite existing config\n // values.\n\n\n LocalForage.prototype.config = function config(options) {\n // If the options argument is an object, we use it to set values.\n // Otherwise, we return either a specified config value or all\n // config values.\n if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object') {\n // If localforage is ready and fully initialized, we can't set\n // any new configuration values. Instead, we return an error.\n if (this._ready) {\n return new Error('Can\\'t call config() after localforage ' + 'has been used.');\n }\n\n for (var i in options) {\n if (i === 'storeName') {\n options[i] = options[i].replace(/\\W/g, '_');\n }\n\n if (i === 'version' && typeof options[i] !== 'number') {\n return new Error('Database version must be a number.');\n }\n\n this._config[i] = options[i];\n }\n\n // after all config options are set and\n // the driver option is used, try setting it\n if ('driver' in options && options.driver) {\n return this.setDriver(this._config.driver);\n }\n\n return true;\n } else if (typeof options === 'string') {\n return this._config[options];\n } else {\n return this._config;\n }\n };\n\n // Used to define a custom driver, shared across all instances of\n // localForage.\n\n\n LocalForage.prototype.defineDriver = function defineDriver(driverObject, callback, errorCallback) {\n var promise = new Promise$1(function (resolve, reject) {\n try {\n var driverName = driverObject._driver;\n var complianceError = new Error('Custom driver not compliant; see ' + 'https://mozilla.github.io/localForage/#definedriver');\n\n // A driver name should be defined and not overlap with the\n // library-defined, default drivers.\n if (!driverObject._driver) {\n reject(complianceError);\n return;\n }\n\n var driverMethods = LibraryMethods.concat('_initStorage');\n for (var i = 0, len = driverMethods.length; i < len; i++) {\n var customDriverMethod = driverMethods[i];\n if (!customDriverMethod || !driverObject[customDriverMethod] || typeof driverObject[customDriverMethod] !== 'function') {\n reject(complianceError);\n return;\n }\n }\n\n var setDriverSupport = function setDriverSupport(support) {\n if (DefinedDrivers[driverName]) {\n console.info('Redefining LocalForage driver: ' + driverName);\n }\n DefinedDrivers[driverName] = driverObject;\n DriverSupport[driverName] = support;\n // don't use a then, so that we can define\n // drivers that have simple _support methods\n // in a blocking manner\n resolve();\n };\n\n if ('_support' in driverObject) {\n if (driverObject._support && typeof driverObject._support === 'function') {\n driverObject._support().then(setDriverSupport, reject);\n } else {\n setDriverSupport(!!driverObject._support);\n }\n } else {\n setDriverSupport(true);\n }\n } catch (e) {\n reject(e);\n }\n });\n\n executeTwoCallbacks(promise, callback, errorCallback);\n return promise;\n };\n\n LocalForage.prototype.driver = function driver() {\n return this._driver || null;\n };\n\n LocalForage.prototype.getDriver = function getDriver(driverName, callback, errorCallback) {\n var getDriverPromise = DefinedDrivers[driverName] ? Promise$1.resolve(DefinedDrivers[driverName]) : Promise$1.reject(new Error('Driver not found.'));\n\n executeTwoCallbacks(getDriverPromise, callback, errorCallback);\n return getDriverPromise;\n };\n\n LocalForage.prototype.getSerializer = function getSerializer(callback) {\n var serializerPromise = Promise$1.resolve(localforageSerializer);\n executeTwoCallbacks(serializerPromise, callback);\n return serializerPromise;\n };\n\n LocalForage.prototype.ready = function ready(callback) {\n var self = this;\n\n var promise = self._driverSet.then(function () {\n if (self._ready === null) {\n self._ready = self._initDriver();\n }\n\n return self._ready;\n });\n\n executeTwoCallbacks(promise, callback, callback);\n return promise;\n };\n\n LocalForage.prototype.setDriver = function setDriver(drivers, callback, errorCallback) {\n var self = this;\n\n if (!isArray(drivers)) {\n drivers = [drivers];\n }\n\n var supportedDrivers = this._getSupportedDrivers(drivers);\n\n function setDriverToConfig() {\n self._config.driver = self.driver();\n }\n\n function extendSelfWithDriver(driver) {\n self._extend(driver);\n setDriverToConfig();\n\n self._ready = self._initStorage(self._config);\n return self._ready;\n }\n\n function initDriver(supportedDrivers) {\n return function () {\n var currentDriverIndex = 0;\n\n function driverPromiseLoop() {\n while (currentDriverIndex < supportedDrivers.length) {\n var driverName = supportedDrivers[currentDriverIndex];\n currentDriverIndex++;\n\n self._dbInfo = null;\n self._ready = null;\n\n return self.getDriver(driverName).then(extendSelfWithDriver)[\"catch\"](driverPromiseLoop);\n }\n\n setDriverToConfig();\n var error = new Error('No available storage method found.');\n self._driverSet = Promise$1.reject(error);\n return self._driverSet;\n }\n\n return driverPromiseLoop();\n };\n }\n\n // There might be a driver initialization in progress\n // so wait for it to finish in order to avoid a possible\n // race condition to set _dbInfo\n var oldDriverSetDone = this._driverSet !== null ? this._driverSet[\"catch\"](function () {\n return Promise$1.resolve();\n }) : Promise$1.resolve();\n\n this._driverSet = oldDriverSetDone.then(function () {\n var driverName = supportedDrivers[0];\n self._dbInfo = null;\n self._ready = null;\n\n return self.getDriver(driverName).then(function (driver) {\n self._driver = driver._driver;\n setDriverToConfig();\n self._wrapLibraryMethodsWithReady();\n self._initDriver = initDriver(supportedDrivers);\n });\n })[\"catch\"](function () {\n setDriverToConfig();\n var error = new Error('No available storage method found.');\n self._driverSet = Promise$1.reject(error);\n return self._driverSet;\n });\n\n executeTwoCallbacks(this._driverSet, callback, errorCallback);\n return this._driverSet;\n };\n\n LocalForage.prototype.supports = function supports(driverName) {\n return !!DriverSupport[driverName];\n };\n\n LocalForage.prototype._extend = function _extend(libraryMethodsAndProperties) {\n extend(this, libraryMethodsAndProperties);\n };\n\n LocalForage.prototype._getSupportedDrivers = function _getSupportedDrivers(drivers) {\n var supportedDrivers = [];\n for (var i = 0, len = drivers.length; i < len; i++) {\n var driverName = drivers[i];\n if (this.supports(driverName)) {\n supportedDrivers.push(driverName);\n }\n }\n return supportedDrivers;\n };\n\n LocalForage.prototype._wrapLibraryMethodsWithReady = function _wrapLibraryMethodsWithReady() {\n // Add a stub for each driver API method that delays the call to the\n // corresponding driver method until localForage is ready. These stubs\n // will be replaced by the driver methods as soon as the driver is\n // loaded, so there is no performance impact.\n for (var i = 0, len = LibraryMethods.length; i < len; i++) {\n callWhenReady(this, LibraryMethods[i]);\n }\n };\n\n LocalForage.prototype.createInstance = function createInstance(options) {\n return new LocalForage(options);\n };\n\n return LocalForage;\n}();\n\n// The actual localForage object that we expose as a module or via a\n// global. It's extended by pulling in one of our other libraries.\n\n\nvar localforage_js = new LocalForage();\n\nmodule.exports = localforage_js;\n\n},{\"3\":3}]},{},[4])(4)\n});\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/localforage/dist/localforage.js\n// module id = 3\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport WeightDecoderEightbit from \"./weight_decoder_eightbit\";\nimport WeightDecoderRaw from \"./weight_decoder_raw\";\n/**\n * @protected\n */\nexport default function getWeightDecoder(name) {\n switch (name) {\n case 'raw':\n return new WeightDecoderRaw();\n case 'eightbit':\n return new WeightDecoderEightbit();\n default:\n throw new Error('Unknown weight encoding');\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/get_weight_decoder.js\n// module id = 4\n// module chunks = 0","/**\n * @module webdnn\n */\n/**\n * PlaceholderContext manages the placeholders\n * @protected\n */\nexport default class PlaceholderContext {\n constructor(values) {\n this.values = {};\n if (values) {\n this.update(values);\n }\n }\n get isResolved() {\n return Object.values(this.values).every(value => typeof value == 'number');\n }\n update(values) {\n this.values = Object.assign(this.values, values);\n }\n resolve(placeholder) {\n // Literal value => return itself.\n if (typeof placeholder !== 'object')\n return placeholder;\n // Placeholder object ( { eval: string } ) => resolve\n if (Object.keys(placeholder).length == 1 && 'eval' in placeholder) {\n if (!this.isResolved)\n throw Error(`Not all placeholders are resolved: ${this}`);\n return eval('(function(placeholders){return ' + placeholder.eval + ';})')(this.values);\n }\n // Array => deep copy\n if (placeholder instanceof Array) {\n return placeholder.map((value) => this.resolve(value));\n }\n // Object => deep copy\n return Object.entries(placeholder)\n .reduce((result, [key, value]) => {\n result[key] = this.resolve(value);\n return result;\n }, {});\n }\n toString() {\n return JSON.stringify(this.values);\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/placeholder.js\n// module id = 5\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport { SymbolicTypedArray } from \"./symbolic_typed_array\";\n/**\n * Typed array used for input and output variables of [[webdnn.DescriptorRunner| `DescriptorRunner`]].\n * You can use `SymbolicFloat32Array` almost as same as `Float32Array`.\n *\n * To convert `SymbolicFloat32Array` into actual `Float32Array`, use [[webdnn.SymbolicFloat32Array.toActual| `toActual()`]]\n *\n * ```js\n *\n * let result = runner.outputs[0]; //runner.outputs is array of SymbolicFloat32Array\n *\n * // SymbolicFloat32Array does NOT support index access\n * console.log(result[0]);\n * >>> undefined\n *\n * // By conversion, you can access each element by index\n * console.log(result.toActual()[0]);\n * >>> 1.00 // Actual result\n * ```\n */\nexport default class SymbolicFloat32Array extends SymbolicTypedArray {\n constructor() {\n super(...arguments);\n /**\n * The size in bytes of each element in the array.\n */\n this.BYTES_PER_ELEMENT = 4;\n }\n /**\n * Convert SymbolicTypedArray instance into actual TypedArray instance.\n *\n * @returns actual typed array\n */\n toActual() {\n if (!this.buffer) {\n throw new Error('Internal buffer for this variable is not set. DescriptorRunner.setPlaceholderValue() have to be called before calling this function.');\n }\n return new Float32Array(this.buffer, this.byteOffset, this.length);\n }\n /**\n * Determines whether all the members of an array satisfy the specified test.\n * @param callbackfn A function that accepts up to three arguments. The every method calls\n * the callbackfn function for each element in array1 until the callbackfn returns false,\n * or until the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n every(callbackfn, thisArg) {\n return this.toActual().every(callbackfn, thisArg);\n }\n /**\n * Returns the elements of an array that meet the condition specified in a callback function.\n * @param callbackfn A function that accepts up to three arguments. The filter method calls\n * the callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n filter(callbackfn, thisArg) {\n return this.toActual().filter(callbackfn, thisArg);\n }\n /**\n * Returns the value of the first element in the array where predicate is true, and undefined\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found, find\n * immediately returns that element value. Otherwise, find returns undefined.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n find(predicate, thisArg) {\n return this.toActual().find(predicate, thisArg);\n }\n /**\n * Returns the index of the first element in the array where predicate is true, and -1\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found,\n * findIndex immediately returns that element index. Otherwise, findIndex returns -1.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n findIndex(predicate, thisArg) {\n return this.toActual().findIndex(predicate, thisArg);\n }\n /**\n * Performs the specified action for each element in an array.\n * @param callbackfn A function that accepts up to three arguments. forEach calls the\n * callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n forEach(callbackfn, thisArg) {\n return this.toActual().forEach(callbackfn, thisArg);\n }\n /**\n * Calls a defined callback function on each element of an array, and returns an array that\n * contains the results.\n * @param callbackfn A function that accepts up to three arguments. The map method calls the\n * callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n map(callbackfn, thisArg) {\n return this.toActual().map(callbackfn, thisArg);\n }\n reduce(callbackfn, initialValue) {\n return this.toActual().reduce(callbackfn, initialValue);\n }\n reduceRight(callbackfn, initialValue) {\n return this.toActual().reduceRight(callbackfn, initialValue);\n }\n /**\n * Reverses the elements in an Array.\n */\n reverse() {\n return this.toActual().reverse();\n }\n /**\n * Returns a section of an array.\n * @param start The beginning of the specified portion of the array.\n * @param end The end of the specified portion of the array.\n */\n slice(start, end) {\n return this.toActual().slice(start, end);\n }\n /**\n * Determines whether the specified callback function returns true for any element of an array.\n * @param callbackfn A function that accepts up to three arguments. The some method calls the\n * callbackfn function for each element in array1 until the callbackfn returns true, or until\n * the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n some(callbackfn, thisArg) {\n return this.toActual().some(callbackfn, thisArg);\n }\n /**\n * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements\n * at begin, inclusive, up to end, exclusive.\n * @param begin The index of the beginning of the array.\n * @param end The index of the end of the array.\n */\n subarray(begin, end) {\n return this.toActual().subarray(begin, end);\n }\n /** @protected */\n includes(searchElement, fromIndex) {\n return this.toActual().includes(searchElement, fromIndex);\n }\n}\n/**\n * The size in bytes of each element in SymbolicFloat32Array.\n */\nSymbolicFloat32Array.BYTES_PER_ELEMENT = 4;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/symbolic_typed_array/symbolic_float32array.js\n// module id = 6\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\n/**\n * `DescriptorRunner` provides interface to execute DNN model and access input and output buffers.\n */\nexport class DescriptorRunner {\n constructor() {\n /**\n * For Developer:\n *\n * `DescriptorRunner` executes computation based on `GraphDescriptor`.\n *\n * Typically, DescriptorRunner takes 3 steps to execute DNN model.\n *\n * 1. Initialize static configurations\n *\n * Initialize things independent from runtime configuration.\n *\n * - `init()`\n * - `load()`\n *\n * 2. Initialize dynamic configurations\n *\n * Initialize things depend on runtime configuration such as batch size, input image size, etc.\n *\n * - `setPlaceholderValue()`\n * - `getInputViews()`\n * - `getOutputViews()`\n *\n * 3. Execute the model\n *\n * - `run()`\n *\n * You need to do step 1 and 2 only once. We recommend to call `WebDNN.prepareAll()` instead\n * to call `GraphDescriptor#load()` directly. In that method, all procedures in step 1 and 2 are performed.\n */\n /**\n * The descriptor\n */\n this.descriptor = null;\n }\n /**\n * Return `true` if this backend is available in this environment.\n * @returns {boolean}\n */\n static checkAvailability() {\n return false;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner.js\n// module id = 7\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/messages.js\n// module id = 8\n// module chunks = 0","'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It isn't worth it to make additional optimizations as in original.\n// Small size is preferable.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n\nmodule.exports = adler32;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/adler32.js\n// module id = 9\n// module chunks = 0","'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n\nmodule.exports = crc32;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/crc32.js\n// module id = 10\n// module chunks = 0","// String encode/decode helpers\n'use strict';\n\n\nvar utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safari\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new utils.Buf8(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nexports.string2buf = function (str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new utils.Buf8(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n};\n\n// Helper (used in 2 places)\nfunction buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert byte array to binary string\nexports.buf2binstring = function (buf) {\n return buf2binstring(buf, buf.length);\n};\n\n\n// Convert binary string (typed, when possible)\nexports.binstring2buf = function (str) {\n var buf = new utils.Buf8(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n};\n\n\n// convert array to string\nexports.buf2string = function (buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n};\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nexports.utf8border = function (buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/utils/strings.js\n// module id = 11\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\nmodule.exports = ZStream;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/zstream.js\n// module id = 12\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n //Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/constants.js\n// module id = 13\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\n/// \nimport { getConfiguration } from \"./webdnn\";\n/**\n * @protected\n */\nexport function isWebGL2(gl) {\n return gl.constructor.name === 'WebGL2RenderingContext';\n}\n/**\n * @private\n */\nlet instance;\n/**\n * @protected\n */\nexport default class WebGLHandler {\n /**\n * WebGLHandler is singleton class and instantiate directly is forbidden (constructor is hidden).\n *\n * Since the number of GPU contexts may be limited, the handler is used as a singleton\n * and only one context is shared among multiple runners.\n */\n constructor() {\n this.gl = checkNull(WebGLHandler.initializeContext());\n }\n static getInstance() {\n if (!instance)\n instance = new WebGLHandler();\n return instance;\n }\n createTexture(textureWidth, textureHeight, internalFormat, format) {\n let gl = this.gl;\n let texture = checkNull(gl.createTexture());\n gl.activeTexture(gl.TEXTURE0 + 9); // TODO: texture unit 9 is always available?\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, textureWidth, textureHeight, 0, format, gl.FLOAT, null);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n gl.bindTexture(gl.TEXTURE_2D, null);\n return texture;\n }\n createVertexShader(source) {\n return this.createShader(this.gl.VERTEX_SHADER, source);\n }\n createFragmentShader(source) {\n return this.createShader(this.gl.FRAGMENT_SHADER, source);\n }\n createShader(type, source) {\n let shader = checkNull(this.gl.createShader(type));\n this.gl.shaderSource(shader, source);\n this.gl.compileShader(shader);\n if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {\n console.error(this.gl.getShaderInfoLog(shader));\n throw Error(\"Shader Compile failed: \" + this.gl.getShaderInfoLog(shader));\n }\n return shader;\n }\n createProgram(vertexShader, fragmentShader) {\n let program = checkNull(this.gl.createProgram());\n this.gl.attachShader(program, fragmentShader);\n this.gl.attachShader(program, vertexShader);\n this.gl.linkProgram(program);\n if (!this.gl.getProgramParameter(program, this.gl.LINK_STATUS)) {\n console.error(this.gl.getProgramInfoLog(program));\n throw Error('ShaderProgram Initialization failed.');\n }\n return program;\n }\n createArrayBuffer(vertexArray) {\n let buffer = checkNull(this.gl.createBuffer());\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, vertexArray, this.gl.STATIC_DRAW);\n return buffer;\n }\n createFrameBuffer() {\n return checkNull(this.gl.createFramebuffer());\n }\n bindArrayBuffer(buffer) {\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, buffer);\n }\n bindFrameBuffer(frameBuffer, width, height) {\n this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, frameBuffer);\n this.gl.viewport(0, 0, width, height);\n this.gl.scissor(0, 0, width, height);\n }\n useProgram(program) {\n this.gl.useProgram(program);\n }\n deleteTexture(texture) {\n this.gl.deleteTexture(texture);\n }\n static initializeWebGL2Context(canvas = document.createElement('canvas')) {\n let gl;\n gl = (canvas.getContext('webgl2'));\n if (!gl)\n return null;\n if (!gl.getExtension('EXT_color_buffer_float'))\n return null;\n if (getConfiguration('DEBUG', false) && !gl.getExtension('WEBGL_debug_renderer_info'))\n return null;\n return gl;\n }\n static initializeWebGL1Context(canvas = document.createElement('canvas')) {\n let gl = (canvas.getContext('webgl') || canvas.getContext('experimental-webgl'));\n if (!gl)\n return null;\n if (!gl.getExtension('OES_texture_float'))\n return null;\n if (WebGLHandler.IS_SAFARI) {\n //TODO(Kiikurage)\n // Safari supports WebGL with OES_TEXTURE_FLOAT extension. However,\n // currently when WebGLRenderingContext#readPixels is called, an error is thrown.\n return null;\n }\n if (getConfiguration('DEBUG', false) && !gl.getExtension('WEBGL_debug_renderer_info'))\n return null;\n return gl;\n }\n static initializeContext() {\n let canvas = document.createElement('canvas');\n let gl;\n gl = WebGLHandler.initializeWebGL2Context(canvas);\n if (gl) {\n if (getConfiguration('DEBUG', false))\n console.info('WebGL2 is enabled');\n }\n else {\n gl = WebGLHandler.initializeWebGL1Context(canvas);\n if (gl) {\n if (getConfiguration('DEBUG', false))\n console.info('WebGL2 is disabled');\n }\n else {\n return null;\n }\n }\n gl.disable(gl.DEPTH_TEST);\n gl.disable(gl.STENCIL_TEST);\n gl.disable(gl.BLEND);\n gl.disable(gl.DITHER);\n gl.disable(gl.POLYGON_OFFSET_FILL);\n gl.disable(gl.SAMPLE_COVERAGE);\n gl.enable(gl.SCISSOR_TEST);\n gl.enable(gl.CULL_FACE);\n gl.cullFace(gl.BACK);\n return gl;\n }\n /**\n * Check whether WebGL is supported or not\n * @protected\n */\n static checkAvailability() {\n if (availability === null) {\n let gl = WebGLHandler.initializeContext();\n if (!gl) {\n availability = false;\n }\n else if (getConfiguration('MAX_TEXTURE_SIZE', gl.getParameter(gl.MAX_TEXTURE_SIZE)) < 4096) {\n availability = false;\n }\n else {\n availability = true;\n }\n }\n return availability;\n }\n async waitForComplete() {\n let gl = this.gl;\n if (isWebGL2(gl)) {\n let sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);\n let status = gl.clientWaitSync(sync, 0, 0);\n while (status !== gl.CONDITION_SATISFIED && status !== gl.ALREADY_SIGNALED) {\n await new Promise(r => setTimeout(r, 1));\n status = gl.clientWaitSync(sync, 0, 0);\n }\n gl.deleteSync(sync);\n }\n else {\n gl.finish();\n }\n }\n get MAX_TEXTURE_SIZE() {\n let MAX_TEXTURE_SIZE = getConfiguration('MAX_TEXTURE_SIZE', this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE));\n // FIXME: In most case, MAX_TEXTURE_SIZE=4096 is the fastest (Why?).\n if (MAX_TEXTURE_SIZE >= 16384) {\n return 4096;\n }\n else if (MAX_TEXTURE_SIZE >= 8192) {\n return 4096;\n }\n else if (MAX_TEXTURE_SIZE >= 4096) {\n return 4096;\n }\n else {\n throw new Error(`MAX_TEXTURE_SIZE is too small: ${MAX_TEXTURE_SIZE}`);\n }\n }\n}\nWebGLHandler.IS_SAFARI = navigator.userAgent.toLowerCase().indexOf('safari') !== -1 && navigator.userAgent.toLowerCase().indexOf('chrome') === -1;\n/**\n * @private\n */\nlet availability = null;\n/**\n * @private\n */\nfunction checkNull(obj) {\n if (obj === null)\n throw Error('Null is detected');\n return obj;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webgl_handler.js\n// module id = 14\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\n/**\n * Abstract buffer interface. Read/write transactions are regarded as asynchronous operation.\n *\n * @protected\n */\nexport class Buffer {\n constructor(byteLength, backend) {\n this.byteLength = byteLength;\n this.backend = backend;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer.js\n// module id = 15\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport WebGPUHandler from \"../webgpu_handler\";\nimport { Buffer } from \"./buffer\";\n/**\n * @protected\n */\nexport default class BufferWebGPU extends Buffer {\n constructor(byteLength) {\n super(byteLength, 'webgpu');\n if (byteLength == 0) {\n byteLength = 4; //0 length buffer causes error\n }\n this.handler = WebGPUHandler.getInstance();\n this.buffer = this.handler.createBuffer(new Uint8Array(byteLength));\n this.bufferView = new Uint8Array(this.buffer.contents);\n }\n // async: there may be platforms synchronization is needed before writing\n async write(src, dst_offset) {\n await this.handler.sync();\n let viewSameType = new src.constructor(this.bufferView.buffer);\n viewSameType.set(src, dst_offset);\n }\n async read(dst, src_offset = 0, length) {\n if (!dst)\n throw new Error('dst cannot be null');\n await this.handler.sync();\n if (this.byteLength === 0)\n return;\n let dstConstructor = dst.constructor;\n let viewSameType = new dstConstructor(this.bufferView.buffer, this.bufferView.byteOffset + src_offset * dstConstructor.BYTES_PER_ELEMENT, length);\n dst.set(viewSameType);\n return;\n }\n getWriteView(offset, length, type) {\n return new type(this.bufferView.buffer, this.bufferView.byteOffset + offset * type.BYTES_PER_ELEMENT, length);\n }\n getReadView(offset, length, type) {\n return new type(this.bufferView.buffer, this.bufferView.byteOffset + offset * type.BYTES_PER_ELEMENT, length);\n }\n async syncWriteViews() {\n // no sync needed\n }\n async syncReadViews() {\n // if the user awaits promise from final kernel execution, this function call is not needed.\n await this.handler.sync();\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer_webgpu.js\n// module id = 16\n// module chunks = 0","///\n/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport BufferWebGPU from \"./buffer/buffer_webgpu\";\n/**\n * @private\n */\nlet instance;\n/**\n * @protected\n */\nexport default class WebGPUHandler {\n /**\n * WebGPUHandler is singleton class and instantiate directly is forbidden (constructor is hidden).\n *\n * Since the number of GPU contexts may be limited, the handler is used as a singleton\n * and only one context is shared among multiple runners.\n */\n constructor() {\n this.pipelineStates = new Map();\n if (!IS_WEBGPU_SUPPORTED)\n throw new Error('This browser does not support WebGPU');\n let context;\n try {\n context = document.createElement('canvas').getContext('webgpu');\n }\n catch (err) {\n throw new Error(`During initializing WebGPURenderingContext, unexpected error is occurred: ${err.message}`);\n }\n if (!context)\n throw new Error('WebGPURenderingContext initialization failed');\n this.context = context;\n this.commandQueue = context.createCommandQueue();\n this.loadKernel('kernel void sync(){}', 'basic');\n }\n static getInstance() {\n if (!instance)\n instance = new WebGPUHandler();\n return instance;\n }\n createBuffer(arrayBuffer) {\n return this.context.createBuffer(arrayBuffer);\n }\n loadKernel(librarySource, namespace = '') {\n let library = this.context.createLibrary(librarySource);\n for (let name of library.functionNames) {\n let kernelFunction = library.functionWithName(name);\n let pipelineStates = this.context.createComputePipelineState(kernelFunction);\n this.pipelineStates.set(namespace + '.' + name, pipelineStates);\n }\n }\n createCommandBuffer() {\n return this.commandQueue.createCommandBuffer();\n }\n getPipelineStateByName(name) {\n let state = this.pipelineStates.get(name);\n if (!state) {\n throw TypeError(`Kernel function \"${name}\" is not loaded.`);\n }\n return state;\n }\n executeSinglePipelineState(name, threadgroupsPerGrid, threadsPerThreadgroup, buffers, getCompletedPromise) {\n let commandBuffer = this.commandBuffer || (this.commandBuffer = this.createCommandBuffer());\n let commandEncoder = commandBuffer.createComputeCommandEncoder();\n commandEncoder.setComputePipelineState(this.getPipelineStateByName(name));\n for (let i = 0; i < buffers.length; i++) {\n let buffer = buffers[i];\n let wgbuf;\n if (buffer instanceof BufferWebGPU) {\n wgbuf = buffer.buffer;\n }\n else {\n // cannot perform (buffer instanceof WebGPUBuffer) currently\n wgbuf = buffer;\n }\n commandEncoder.setBuffer(wgbuf, 0, i);\n }\n commandEncoder.dispatch(threadgroupsPerGrid, threadsPerThreadgroup);\n commandEncoder.endEncoding();\n let promise = null;\n if (getCompletedPromise) {\n promise = commandBuffer.completed;\n }\n this.commandBuffer = null;\n commandBuffer.commit();\n return promise;\n }\n async sync() {\n let commandBuffer = this.createCommandBuffer();\n let commandEncoder = commandBuffer.createComputeCommandEncoder();\n commandEncoder.setComputePipelineState(this.getPipelineStateByName('basic.sync'));\n commandEncoder.dispatch({\n width: 1,\n height: 1,\n depth: 1\n }, {\n width: 1,\n height: 1,\n depth: 1\n });\n commandEncoder.endEncoding();\n let promise = commandBuffer.completed;\n commandBuffer.commit();\n return promise;\n }\n}\n/**\n * Flag whether WebGPU is supported or not\n * @protected\n */\nexport const IS_WEBGPU_SUPPORTED = 'WebGPURenderingContext' in window && 'WebGPUComputeCommandEncoder' in window;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/webgpu_handler.js\n// module id = 17\n// module chunks = 0","/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\n/**\n * The data order\n */\nexport var Order;\n(function (Order) {\n /** `[Channel, Height, Width]` format */\n Order[Order[\"CHW\"] = 0] = \"CHW\";\n /** `[Height, Width, Channel]` format */\n Order[Order[\"HWC\"] = 1] = \"HWC\";\n})(Order || (Order = {}));\n/**\n * The color format\n */\nexport var Color;\n(function (Color) {\n /** RGB format */\n Color[Color[\"RGB\"] = 0] = \"RGB\";\n /** BGR format */\n Color[Color[\"BGR\"] = 1] = \"BGR\";\n /** grey scale */\n Color[Color[\"GREY\"] = 2] = \"GREY\";\n /** RGBA format */\n Color[Color[\"RGBA\"] = 3] = \"RGBA\";\n /** BGRA format */\n Color[Color[\"BGRA\"] = 4] = \"BGRA\";\n})(Color || (Color = {}));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/enums.js\n// module id = 18\n// module chunks = 0","/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\n/**\n * Get canvas rendering context and check whether it is nonnull value.\n *\n * @param {CanvasRenderingContext2D} canvas\n * @protected\n */\nexport function getContext2D(canvas) {\n let context = canvas.getContext('2d');\n if (!context)\n throw Error('CanvasRenderingContext2D initialization failed');\n return context;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/canvas.js\n// module id = 19\n// module chunks = 0","/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\n/**\n * Load image of specified url\n *\n * @param {string} url the image url\n * @returns {Promise} image element\n */\nexport async function loadImageByUrl(url) {\n let image = document.createElement('img');\n return new Promise((resolve, reject) => {\n image.onload = resolve;\n image.onerror = reject;\n image.src = url;\n })\n .then(() => image);\n}\n/* istanbul ignore next */\n/**\n * Load image file selected in `` element.\n *\n * @param {HTMLInputElement} input the `` element\n * @returns {Promise} image element\n */\nexport async function loadImageFromFileInput(input) {\n let files = input.files;\n if (!files || files.length == 0)\n throw new Error('No file is selected');\n let url = URL.createObjectURL(files[0]);\n return loadImageByUrl(url);\n}\n/* istanbul ignore next */\n/**\n * Load image selected in file picker dialog\n *\n * Currently, web specification not supported the case if the dialog is canceled and no file is selected. In this case,\n * the returned promise will never be resolved.\n *\n * @returns {Promise} image element\n * @protected\n */\nexport async function loadImageByDialog() {\n let input = document.createElement('input');\n input.type = 'file';\n input.accept = 'image/*';\n return new Promise((resolve) => {\n input.onchange = () => resolve(loadImageFromFileInput(input));\n input.click();\n });\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_source.js\n// module id = 20\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport * as localforage from \"localforage\";\nimport get_weight_decoder from \"../decoder/get_weight_decoder\";\nimport webdnnFetch, { readArrayBufferProgressively, transformUrl } from \"../fetch\";\nimport PlaceholderContext from \"../placeholder\";\nimport SymbolicFloat32Array from \"../symbolic_typed_array/symbolic_float32array\";\nimport { DescriptorRunner } from \"./descriptor_runner\";\n/**\n * @private\n */\nfunction wait(duration = 10) {\n // let console.log to be displayed, and prevent freeze\n return new Promise(resolve => setTimeout(resolve, duration));\n}\n/**\n * @protected\n */\nexport default class DescriptorRunnerFallback extends DescriptorRunner {\n constructor() {\n super(...arguments);\n this.backendName = 'fallback';\n }\n static checkAvailability() {\n return true;\n }\n async init() {\n //nothing to do\n }\n async setDescriptorAndParameters(descriptor, parameters) {\n this.setDescriptor(descriptor);\n await this.compile();\n await this.initializeStaticBuffer(parameters);\n if (this.placeholderContext && this.placeholderContext.isResolved)\n await this.initializeDynamicBuffer();\n }\n async fetchDescriptor(directory) {\n this.directory = directory;\n let res = await webdnnFetch(`${directory}/graph_${this.backendName}.json`);\n return res.json();\n }\n async fetchParameters(directory, progressCallback) {\n let res = await webdnnFetch(`${directory}/weight_${this.backendName}.bin`);\n return readArrayBufferProgressively(res, progressCallback);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedDescriptor(directory) {\n return localforage.getItem(`${directory}_${this.backendName}_descriptor`).catch(() => null);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedParameters(directory, progressCallback) {\n let parameter = await localforage.getItem(`${directory}_${this.backendName}_parameters`).catch(() => null);\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return parameter;\n }\n /**\n * save cache\n */\n async saveCache(directory, descriptor, parameters) {\n await Promise.all([\n localforage.setItem(`${directory}_${this.backendName}_descriptor`, descriptor),\n localforage.setItem(`${directory}_${this.backendName}_parameters`, parameters)\n ]);\n }\n ;\n setDescriptor(descriptor) {\n this.descriptor = descriptor;\n // reset\n this.placeholderContext = new PlaceholderContext();\n this.placeholderContext.update(descriptor.placeholders);\n this.kernelObj = null;\n this.variableMap = null;\n this.staticBuffer = null;\n this.dynamicBuffer = null;\n }\n async compile() {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n await new Promise((resolve) => {\n let script = document.createElement(\"script\");\n script.type = \"text/javascript\";\n if (script.readyState) {\n script.onreadystatechange = () => {\n if (script.readyState == \"loaded\" || script.readyState == \"complete\") {\n script.onreadystatechange = null;\n resolve();\n }\n };\n }\n else {\n script.onload = resolve;\n }\n script.src = transformUrl(`${this.directory}/kernels_fallback.js`);\n document.getElementsByTagName(\"head\")[0].appendChild(script);\n });\n this.kernelObj = window.dnn_fallback_kernel; // \"window.dnn_fallback_kernel\" is defined in \"kernels_fallback.js\"\n }\n async initializeStaticBuffer(weightRawArray) {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n let descriptor = this.descriptor;\n let staticBuffer = new Float32Array(descriptor.memory_layout.static.size);\n this.staticBuffer = staticBuffer;\n let variableMap = this.variableMap || new Map();\n this.variableMap = variableMap;\n Object.entries(descriptor.memory_layout.static.allocations)\n .forEach(([name, allocation]) => {\n variableMap.set(name, new Float32Array(staticBuffer.buffer, allocation.offset * Float32Array.BYTES_PER_ELEMENT, allocation.size));\n });\n let decoder = get_weight_decoder(this.descriptor.weight_encoding);\n staticBuffer.set(await decoder.decode(new Uint8Array(weightRawArray)));\n (await this.getInputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = staticBuffer.buffer;\n });\n (await this.getOutputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = staticBuffer.buffer;\n });\n }\n async initializeDynamicBuffer() {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n let dynamicBuffer = new Float32Array(placeholderContext.resolve(descriptor.memory_layout.dynamic.size));\n this.dynamicBuffer = dynamicBuffer;\n let variableMap = this.variableMap || new Map();\n this.variableMap = variableMap;\n Object.entries(descriptor.memory_layout.dynamic.allocations)\n .forEach(([name, allocation]) => {\n variableMap.set(name, new Float32Array(dynamicBuffer.buffer, placeholderContext.resolve(allocation.offset) * Float32Array.BYTES_PER_ELEMENT, placeholderContext.resolve(allocation.size)));\n });\n (await this.getInputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = dynamicBuffer.buffer;\n });\n (await this.getOutputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = dynamicBuffer.buffer;\n });\n }\n async setPlaceholderValue(values) {\n if (!this.placeholderContext)\n throw new Error('placeholderContext is not initialized');\n let placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return;\n await this.initializeDynamicBuffer();\n }\n async run() {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('placeholderContext is not initialized');\n if (!this.variableMap)\n throw new Error('Variable map is not initialized');\n if (!this.staticBuffer)\n throw new Error('StaticBuffer map is not initialized');\n if (!this.dynamicBuffer)\n throw new Error('DynamicBuffer map is not initialized');\n let variableMap = this.variableMap;\n let placeholderContext = this.placeholderContext;\n let executionInfos = this.descriptor.exec_infos\n .map(executionInfo => placeholderContext.resolve(executionInfo));\n let startDate = Date.now();\n let lastDate = Date.now();\n for (let i = 0; i < executionInfos.length; i++) {\n let currentDate = Date.now();\n if (currentDate - lastDate >= 1000) {\n console.log(`Processed ${i}/${executionInfos.length} kernels in ${currentDate - startDate} ms`);\n lastDate = currentDate;\n await wait();\n }\n let executionInfo = executionInfos[i];\n let inputs = executionInfo.inputs.map((name) => variableMap.get(name));\n let outputs = executionInfo.outputs.map((name) => variableMap.get(name));\n this.kernelObj[executionInfo.entry_func_name](inputs, outputs, executionInfo.call_option);\n }\n console.log(`Processed ${executionInfos.length}/${executionInfos.length} kernels in ${Date.now() - startDate} ms`);\n }\n getInputViews() {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, allocation.offset * SymbolicFloat32Array.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n }\n getOutputViews() {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, allocation.offset * SymbolicFloat32Array.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_fallback.js\n// module id = 21\n// module chunks = 0","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 22\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport * as pako from \"pako\";\n/**\n * @protected\n */\nexport default class WeightDecoderEightbit {\n async decode(data) {\n // FIXME: store decoded total size in 'data'\n // currently, decoding each block and concatenating them at the end are needed.\n let decoded_arrays = [];\n let total_dst_length = 0;\n let data_view = new DataView(data.buffer, data.byteOffset);\n let src_offset = 0;\n while (src_offset < data.length) {\n let dst_offset = data_view.getInt32(src_offset, true);\n src_offset += 4;\n let body_size = data_view.getInt32(src_offset, true);\n src_offset += 4;\n let scale = data_view.getFloat32(src_offset, true);\n src_offset += 8;\n let scaled_table = new Float32Array(256);\n for (let i = 0; i < 256; i++) {\n scaled_table[i] = WeightDecoderEightbit.decode_table[i & 0x7F] * scale * (i < 128 ? 1.0 : -1.0);\n }\n // do decode\n let src_data_view = new Uint8Array(data.buffer, data.byteOffset + src_offset, body_size);\n let decompressed = pako.inflate(src_data_view);\n let dec_size = decompressed.length;\n let decoded_array = new Float32Array(dec_size);\n for (let s = 0; s < dec_size; s++) {\n decoded_array[s] = scaled_table[decompressed[s]];\n }\n decoded_arrays.push(decoded_array);\n total_dst_length += dec_size;\n src_offset += body_size;\n }\n let dst = new Float32Array(total_dst_length);\n let dst_offset = 0;\n for (let i = 0; i < decoded_arrays.length; i++) {\n dst.set(decoded_arrays[i], dst_offset);\n dst_offset += decoded_arrays[i].length;\n }\n return dst;\n }\n}\nWeightDecoderEightbit.decode_table = [0.0, 2.750000021e-06, 7.249999726e-06, 1.875000089e-05, 3.624999954e-05, 5.874999624e-05, 8.624999464e-05,\n 1.437500032e-04, 2.312500001e-04, 3.187500115e-04, 4.062500084e-04, 5.187499919e-04, 6.562499912e-04,\n 7.937499322e-04, 9.312499315e-04, 1.218750025e-03, 1.656249980e-03, 2.093750052e-03, 2.531250007e-03,\n 2.968749963e-03, 3.406249918e-03, 3.843750106e-03, 4.281249829e-03, 4.843750037e-03, 5.531250034e-03,\n 6.218749564e-03, 6.906249560e-03, 7.593749557e-03, 8.281249553e-03, 8.968749084e-03, 9.656248614e-03,\n 1.109374966e-02, 1.328125037e-02, 1.546875015e-02, 1.765624993e-02, 1.984374970e-02, 2.203124948e-02,\n 2.421874925e-02, 2.640625089e-02, 2.859375067e-02, 3.078125045e-02, 3.296874836e-02, 3.515625000e-02,\n 3.734375164e-02, 3.953124955e-02, 4.171875119e-02, 4.390624911e-02, 4.671875015e-02, 5.015625060e-02,\n 5.359374732e-02, 5.703124776e-02, 6.046874821e-02, 6.390624493e-02, 6.734374911e-02, 7.078124583e-02,\n 7.421874255e-02, 7.765624672e-02, 8.109374344e-02, 8.453124017e-02, 8.796874434e-02, 9.140624106e-02,\n 9.484373778e-02, 9.828124195e-02, 1.054687500e-01, 1.164062470e-01, 1.273437440e-01, 1.382812560e-01,\n 1.492187530e-01, 1.601562500e-01, 1.710937470e-01, 1.820312440e-01, 1.929687560e-01, 2.039062530e-01,\n 2.148437500e-01, 2.257812470e-01, 2.367187440e-01, 2.476562560e-01, 2.585937381e-01, 2.695312500e-01,\n 2.804687619e-01, 2.914062440e-01, 3.023437560e-01, 3.132812381e-01, 3.242187500e-01, 3.351562619e-01,\n 3.460937440e-01, 3.570312560e-01, 3.679687381e-01, 3.789062500e-01, 3.898437619e-01, 4.007812440e-01,\n 4.117187560e-01, 4.226562381e-01, 4.335937500e-01, 4.445312619e-01, 4.585937560e-01, 4.757812321e-01,\n 4.929687381e-01, 5.101562142e-01, 5.273437500e-01, 5.445312262e-01, 5.617187023e-01, 5.789062381e-01,\n 5.960937142e-01, 6.132812500e-01, 6.304687262e-01, 6.476562023e-01, 6.648437381e-01, 6.820312142e-01,\n 6.992186904e-01, 7.164062262e-01, 7.335937023e-01, 7.507811785e-01, 7.679687142e-01, 7.851561904e-01,\n 8.023436666e-01, 8.195312023e-01, 8.367186785e-01, 8.539061546e-01, 8.710936904e-01, 8.882811666e-01,\n 9.054686427e-01, 9.226561785e-01, 9.398436546e-01, 9.570311308e-01, 9.742186666e-01, 9.914061427e-01, 1.0,\n];\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/weight_decoder_eightbit.js\n// module id = 23\n// module chunks = 0","// Top level file is just a mixin of submodules & constants\n'use strict';\n\nvar assign = require('./lib/utils/common').assign;\n\nvar deflate = require('./lib/deflate');\nvar inflate = require('./lib/inflate');\nvar constants = require('./lib/zlib/constants');\n\nvar pako = {};\n\nassign(pako, deflate, inflate, constants);\n\nmodule.exports = pako;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/index.js\n// module id = 24\n// module chunks = 0","'use strict';\n\n\nvar zlib_deflate = require('./zlib/deflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\n\nvar toString = Object.prototype.toString;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nvar Z_NO_FLUSH = 0;\nvar Z_FINISH = 4;\n\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_SYNC_FLUSH = 2;\n\nvar Z_DEFAULT_COMPRESSION = -1;\n\nvar Z_DEFAULT_STRATEGY = 0;\n\nvar Z_DEFLATED = 8;\n\n/* ===========================================================================*/\n\n\n/**\n * class Deflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[deflate]],\n * [[deflateRaw]] and [[gzip]].\n **/\n\n/* internal\n * Deflate.chunks -> Array\n *\n * Chunks of output data, if [[Deflate#onData]] not overridden.\n **/\n\n/**\n * Deflate.result -> Uint8Array|Array\n *\n * Compressed result, generated by default [[Deflate#onData]]\n * and [[Deflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Deflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Deflate.err -> Number\n *\n * Error code after deflate finished. 0 (Z_OK) on success.\n * You will not need it in real life, because deflate errors\n * are possible only on wrong options or bad `onData` / `onEnd`\n * custom handlers.\n **/\n\n/**\n * Deflate.msg -> String\n *\n * Error message, if [[Deflate.err]] != 0\n **/\n\n\n/**\n * new Deflate(options)\n * - options (Object): zlib deflate options.\n *\n * Creates new deflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `level`\n * - `windowBits`\n * - `memLevel`\n * - `strategy`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw deflate\n * - `gzip` (Boolean) - create gzip wrapper\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n * - `header` (Object) - custom header for gzip\n * - `text` (Boolean) - true if compressed data believed to be text\n * - `time` (Number) - modification time, unix timestamp\n * - `os` (Number) - operation system code\n * - `extra` (Array) - array of bytes with extra data (max 65536)\n * - `name` (String) - file name (binary string)\n * - `comment` (String) - comment (binary string)\n * - `hcrc` (Boolean) - true if header crc should be added\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var deflate = new pako.Deflate({ level: 3});\n *\n * deflate.push(chunk1, false);\n * deflate.push(chunk2, true); // true -> last chunk\n *\n * if (deflate.err) { throw new Error(deflate.err); }\n *\n * console.log(deflate.result);\n * ```\n **/\nfunction Deflate(options) {\n if (!(this instanceof Deflate)) return new Deflate(options);\n\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n if (opt.raw && (opt.windowBits > 0)) {\n opt.windowBits = -opt.windowBits;\n }\n\n else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {\n opt.windowBits += 16;\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n\n if (opt.dictionary) {\n var dict;\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n // If we need to compress text, change encoding to utf8.\n dict = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n this._dict_set = true;\n }\n}\n\n/**\n * Deflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be\n * converted to utf8 byte sequence.\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with\n * new compressed chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the compression context.\n *\n * On fail call [[Deflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * array format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nDeflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var status, _mode;\n\n if (this.ended) { return false; }\n\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // If we need to compress text, change encoding to utf8.\n strm.input = strings.string2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_deflate.deflate(strm, _mode); /* no bad return value */\n\n if (status !== Z_STREAM_END && status !== Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {\n if (this.options.to === 'string') {\n this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH) {\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Deflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nDeflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Deflate#onEnd(status) -> Void\n * - status (Number): deflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called once after you tell deflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nDeflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * deflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * Compress `data` with deflate algorithm and `options`.\n *\n * Supported options are:\n *\n * - level\n * - windowBits\n * - memLevel\n * - strategy\n * - dictionary\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , data = Uint8Array([1,2,3,4,5,6,7,8,9]);\n *\n * console.log(pako.deflate(data));\n * ```\n **/\nfunction deflate(input, options) {\n var deflator = new Deflate(options);\n\n deflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (deflator.err) { throw deflator.msg || msg[deflator.err]; }\n\n return deflator.result;\n}\n\n\n/**\n * deflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate(input, options);\n}\n\n\n/**\n * gzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but create gzip wrapper instead of\n * deflate one.\n **/\nfunction gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate(input, options);\n}\n\n\nexports.Deflate = Deflate;\nexports.deflate = deflate;\nexports.deflateRaw = deflateRaw;\nexports.gzip = gzip;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/deflate.js\n// module id = 25\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar trees = require('./trees');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar msg = require('./messages');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\nvar Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\n//var Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\n//var Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\n//var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n\n/* compression levels */\n//var Z_NO_COMPRESSION = 0;\n//var Z_BEST_SPEED = 1;\n//var Z_BEST_COMPRESSION = 9;\nvar Z_DEFAULT_COMPRESSION = -1;\n\n\nvar Z_FILTERED = 1;\nvar Z_HUFFMAN_ONLY = 2;\nvar Z_RLE = 3;\nvar Z_FIXED = 4;\nvar Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\n//var Z_BINARY = 0;\n//var Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n/*============================================================================*/\n\n\nvar MAX_MEM_LEVEL = 9;\n/* Maximum value for memLevel in deflateInit2 */\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_MEM_LEVEL = 8;\n\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\nvar D_CODES = 30;\n/* number of distance codes */\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\nvar MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);\n\nvar PRESET_DICT = 0x20;\n\nvar INIT_STATE = 42;\nvar EXTRA_STATE = 69;\nvar NAME_STATE = 73;\nvar COMMENT_STATE = 91;\nvar HCRC_STATE = 103;\nvar BUSY_STATE = 113;\nvar FINISH_STATE = 666;\n\nvar BS_NEED_MORE = 1; /* block not completed, need more input or more output */\nvar BS_BLOCK_DONE = 2; /* block flush performed */\nvar BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */\nvar BS_FINISH_DONE = 4; /* finish done, accept no more input or output */\n\nvar OS_CODE = 0x03; // Unix :) . Don't detect, use this default.\n\nfunction err(strm, errorCode) {\n strm.msg = msg[errorCode];\n return errorCode;\n}\n\nfunction rank(f) {\n return ((f) << 1) - ((f) > 4 ? 9 : 0);\n}\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output goes\n * through this function so some applications may wish to modify it\n * to avoid allocating a large strm->output buffer and copying into it.\n * (See also read_buf()).\n */\nfunction flush_pending(strm) {\n var s = strm.state;\n\n //_tr_flush_bits(s);\n var len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) { return; }\n\n utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n}\n\n\nfunction flush_block_only(s, last) {\n trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n}\n\n\nfunction put_byte(s, b) {\n s.pending_buf[s.pending++] = b;\n}\n\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nfunction putShortMSB(s, b) {\n// put_byte(s, (Byte)(b >> 8));\n// put_byte(s, (Byte)(b & 0xff));\n s.pending_buf[s.pending++] = (b >>> 8) & 0xff;\n s.pending_buf[s.pending++] = b & 0xff;\n}\n\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read. All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->input buffer and copying from it.\n * (See also flush_pending()).\n */\nfunction read_buf(strm, buf, start, size) {\n var len = strm.avail_in;\n\n if (len > size) { len = size; }\n if (len === 0) { return 0; }\n\n strm.avail_in -= len;\n\n // zmemcpy(buf, strm->next_in, len);\n utils.arraySet(buf, strm.input, strm.next_in, len, start);\n if (strm.state.wrap === 1) {\n strm.adler = adler32(strm.adler, buf, len, start);\n }\n\n else if (strm.state.wrap === 2) {\n strm.adler = crc32(strm.adler, buf, len, start);\n }\n\n strm.next_in += len;\n strm.total_in += len;\n\n return len;\n}\n\n\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\nfunction longest_match(s, cur_match) {\n var chain_length = s.max_chain_length; /* max hash chain length */\n var scan = s.strstart; /* current string */\n var match; /* matched string */\n var len; /* length of current match */\n var best_len = s.prev_length; /* best match length so far */\n var nice_match = s.nice_match; /* stop if match long enough */\n var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?\n s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;\n\n var _win = s.window; // shortcut\n\n var wmask = s.w_mask;\n var prev = s.prev;\n\n /* Stop when cur_match becomes <= limit. To simplify the code,\n * we prevent matches with the string of window index 0.\n */\n\n var strend = s.strstart + MAX_MATCH;\n var scan_end1 = _win[scan + best_len - 1];\n var scan_end = _win[scan + best_len];\n\n /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n * It is easy to get rid of this optimization if necessary.\n */\n // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n /* Do not waste too much time if we already have a good match: */\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n /* Do not look for matches beyond the end of the input. This is necessary\n * to make deflate deterministic.\n */\n if (nice_match > s.lookahead) { nice_match = s.lookahead; }\n\n // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n do {\n // Assert(cur_match < s->strstart, \"no future\");\n match = cur_match;\n\n /* Skip to next match if the match length cannot increase\n * or if the match length is less than 2. Note that the checks below\n * for insufficient lookahead only occur occasionally for performance\n * reasons. Therefore uninitialized memory will be accessed, and\n * conditional jumps will be made that depend on those values.\n * However the length of the match is limited to the lookahead, so\n * the output of deflate is not affected by the uninitialized values.\n */\n\n if (_win[match + best_len] !== scan_end ||\n _win[match + best_len - 1] !== scan_end1 ||\n _win[match] !== _win[scan] ||\n _win[++match] !== _win[scan + 1]) {\n continue;\n }\n\n /* The check at best_len-1 can be removed because it will be made\n * again later. (This heuristic is not always a win.)\n * It is not necessary to compare scan[2] and match[2] since they\n * are always equal when the other bytes match, given that\n * the hash keys are equal and that HASH_BITS >= 8.\n */\n scan += 2;\n match++;\n // Assert(*scan == *match, \"match[2]?\");\n\n /* We check for insufficient lookahead only every 8th comparison;\n * the 256th check will be made at strstart+258.\n */\n do {\n /*jshint noempty:false*/\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n scan < strend);\n\n // Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n}\n\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n * At least one byte has been read, or avail_in == 0; reads are\n * performed for at least two bytes (required for the zip translate_eol\n * option -- not supported here).\n */\nfunction fill_window(s) {\n var _w_size = s.w_size;\n var p, n, m, more, str;\n\n //Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n do {\n more = s.window_size - s.lookahead - s.strstart;\n\n // JS ints have 32 bit, block below not needed\n /* Deal with !@#$% 64K limit: */\n //if (sizeof(int) <= 2) {\n // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n // more = wsize;\n //\n // } else if (more == (unsigned)(-1)) {\n // /* Very unlikely, but possible on 16 bit machine if\n // * strstart == 0 && lookahead == 1 (input done a byte at time)\n // */\n // more--;\n // }\n //}\n\n\n /* If the window is almost full and there is insufficient lookahead,\n * move the upper half to the lower one to make room in the upper half.\n */\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n\n utils.arraySet(s.window, s.window, _w_size, _w_size, 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n /* we now have strstart >= MAX_DIST */\n s.block_start -= _w_size;\n\n /* Slide the hash table (could be avoided with 32 bit values\n at the expense of memory usage). We slide even when level == 0\n to keep the hash table consistent if we switch back to level > 0\n later. (Using level 0 permanently is not an optimal usage of\n zlib, so we don't care about this pathological case.)\n */\n\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = (m >= _w_size ? m - _w_size : 0);\n } while (--n);\n\n n = _w_size;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = (m >= _w_size ? m - _w_size : 0);\n /* If n is not on any hash chain, prev[n] is garbage but\n * its value will never be used.\n */\n } while (--n);\n\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n\n /* If there was no sliding:\n * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n * more == window_size - lookahead - strstart\n * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n * => more >= window_size - 2*WSIZE + 2\n * In the BIG_MEM or MMAP case (not yet supported),\n * window_size == input_size + MIN_LOOKAHEAD &&\n * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n * Otherwise, window_size == 2*WSIZE so more >= 2.\n * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n */\n //Assert(more >= 2, \"more < 2\");\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n\n /* Initialize the hash value now that we have some input: */\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n\n /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;\n//#if MIN_MATCH != 3\n// Call update_hash() MIN_MATCH-3 more times\n//#endif\n while (s.insert) {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n * but this is not important since only literal bytes will be emitted.\n */\n\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n\n /* If the WIN_INIT bytes after the end of the current data have never been\n * written, then zero those bytes in order to avoid memory check reports of\n * the use of uninitialized (or uninitialised as Julian writes) bytes by\n * the longest match routines. Update the high water mark for the next\n * time through here. WIN_INIT is set to MAX_MATCH since the longest match\n * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n */\n// if (s.high_water < s.window_size) {\n// var curr = s.strstart + s.lookahead;\n// var init = 0;\n//\n// if (s.high_water < curr) {\n// /* Previous high water mark below current data -- zero WIN_INIT\n// * bytes or up to end of window, whichever is less.\n// */\n// init = s.window_size - curr;\n// if (init > WIN_INIT)\n// init = WIN_INIT;\n// zmemzero(s->window + curr, (unsigned)init);\n// s->high_water = curr + init;\n// }\n// else if (s->high_water < (ulg)curr + WIN_INIT) {\n// /* High water mark at or above current data, but below current data\n// * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n// * to end of window, whichever is less.\n// */\n// init = (ulg)curr + WIN_INIT - s->high_water;\n// if (init > s->window_size - s->high_water)\n// init = s->window_size - s->high_water;\n// zmemzero(s->window + s->high_water, (unsigned)init);\n// s->high_water += init;\n// }\n// }\n//\n// Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n// \"not enough room for search\");\n}\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n * This function does not insert new strings in the dictionary since\n * uncompressible data is probably not useful. This function is used\n * only for the level=0 compression option.\n * NOTE: this function should be optimized to avoid extra copying from\n * window to pending_buf.\n */\nfunction deflate_stored(s, flush) {\n /* Stored blocks are limited to 0xffff bytes, pending_buf is limited\n * to pending_buf_size, and each stored block has a 5 byte header:\n */\n var max_block_size = 0xffff;\n\n if (max_block_size > s.pending_buf_size - 5) {\n max_block_size = s.pending_buf_size - 5;\n }\n\n /* Copy as much as possible from input to output: */\n for (;;) {\n /* Fill the window as much as possible: */\n if (s.lookahead <= 1) {\n\n //Assert(s->strstart < s->w_size+MAX_DIST(s) ||\n // s->block_start >= (long)s->w_size, \"slide too late\");\n// if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||\n// s.block_start >= s.w_size)) {\n// throw new Error(\"slide too late\");\n// }\n\n fill_window(s);\n if (s.lookahead === 0 && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n\n if (s.lookahead === 0) {\n break;\n }\n /* flush the current block */\n }\n //Assert(s->block_start >= 0L, \"block gone\");\n// if (s.block_start < 0) throw new Error(\"block gone\");\n\n s.strstart += s.lookahead;\n s.lookahead = 0;\n\n /* Emit a stored block if pending_buf will be full: */\n var max_start = s.block_start + max_block_size;\n\n if (s.strstart === 0 || s.strstart >= max_start) {\n /* strstart == 0 is possible when wraparound on 16-bit machine */\n s.lookahead = s.strstart - max_start;\n s.strstart = max_start;\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n\n\n }\n /* Flush if we may have to slide, otherwise block_start may become\n * negative and the data will be gone:\n */\n if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n\n s.insert = 0;\n\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n\n if (s.strstart > s.block_start) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_NEED_MORE;\n}\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nfunction deflate_fast(s, flush) {\n var hash_head; /* head of the hash chain */\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break; /* flush the current block */\n }\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n * At this point we have always match_length < MIN_MATCH\n */\n if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n }\n if (s.match_length >= MIN_MATCH) {\n // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only\n\n /*** _tr_tally_dist(s, s.strstart - s.match_start,\n s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n\n /* Insert new strings in the hash table only if the match length\n * is not too large. This saves time but degrades compression.\n */\n if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {\n s.match_length--; /* string at strstart already in table */\n do {\n s.strstart++;\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n * always MIN_MATCH bytes ahead.\n */\n } while (--s.match_length !== 0);\n s.strstart++;\n } else\n {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;\n\n//#if MIN_MATCH != 3\n// Call UPDATE_HASH() MIN_MATCH-3 more times\n//#endif\n /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n * matter since it will be recomputed at next deflate call.\n */\n }\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s.window[s.strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nfunction deflate_slow(s, flush) {\n var hash_head; /* head of hash chain */\n var bflush; /* set if current block must be flushed */\n\n var max_insert;\n\n /* Process the input block. */\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n */\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n\n if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&\n s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n\n if (s.match_length <= 5 &&\n (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) {\n\n /* If prev_match is also MIN_MATCH, match_start is garbage\n * but we will ignore the current match anyway.\n */\n s.match_length = MIN_MATCH - 1;\n }\n }\n /* If there was a match at the previous step and the current\n * match is not better, output the previous match:\n */\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n /* Do not insert strings in hash table beyond this. */\n\n //check_match(s, s.strstart-1, s.prev_match, s.prev_length);\n\n /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,\n s.prev_length - MIN_MATCH, bflush);***/\n bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n /* Insert in hash table all strings up to the end of the match.\n * strstart-1 and strstart are already inserted. If there is not\n * enough lookahead, the last two strings are not inserted in\n * the hash table.\n */\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n } else if (s.match_available) {\n /* If there was no match at the previous position, output a\n * single literal. If there was a match but the current match\n * is longer, truncate the previous match to a single literal.\n */\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n if (bflush) {\n /*** FLUSH_BLOCK_ONLY(s, 0) ***/\n flush_block_only(s, false);\n /***/\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n /* There is no previous match to compare with, wait for\n * the next step to decide.\n */\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n //Assert (flush != Z_NO_FLUSH, \"no flush?\");\n if (s.match_available) {\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_BLOCK_DONE;\n}\n\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one. Do not maintain a hash table. (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nfunction deflate_rle(s, flush) {\n var bflush; /* set if current block must be flushed */\n var prev; /* byte at distance one to match */\n var scan, strend; /* scan goes up to strend for length of run */\n\n var _win = s.window;\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the longest run, plus one for the unrolled loop.\n */\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* See how many times the previous byte repeats */\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n /*jshint noempty:false*/\n } while (prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n //Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n }\n\n /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n if (s.match_length >= MIN_MATCH) {\n //check_match(s, s.strstart, s.strstart - 1, s.match_length);\n\n /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nfunction deflate_huff(s, flush) {\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we have a literal to write. */\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n break; /* flush the current block */\n }\n }\n\n /* Output a literal byte */\n s.match_length = 0;\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\nfunction Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n}\n\nvar configuration_table;\n\nconfiguration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast), /* 2 */\n new Config(4, 6, 32, 32, deflate_fast), /* 3 */\n\n new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow), /* 5 */\n new Config(8, 16, 128, 128, deflate_slow), /* 6 */\n new Config(8, 32, 128, 256, deflate_slow), /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow), /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */\n];\n\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nfunction lm_init(s) {\n s.window_size = 2 * s.w_size;\n\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n\n /* Set the default configuration parameters:\n */\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n}\n\n\nfunction DeflateState() {\n this.strm = null; /* pointer back to this zlib stream */\n this.status = 0; /* as the name implies */\n this.pending_buf = null; /* output still pending */\n this.pending_buf_size = 0; /* size of pending_buf */\n this.pending_out = 0; /* next pending byte to output to the stream */\n this.pending = 0; /* nb of bytes in the pending buffer */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.gzhead = null; /* gzip header information to write */\n this.gzindex = 0; /* where in extra, name, or comment */\n this.method = Z_DEFLATED; /* can only be DEFLATED */\n this.last_flush = -1; /* value of flush param for previous deflate call */\n\n this.w_size = 0; /* LZ77 window size (32K by default) */\n this.w_bits = 0; /* log2(w_size) (8..16) */\n this.w_mask = 0; /* w_size - 1 */\n\n this.window = null;\n /* Sliding window. Input bytes are read into the second half of the window,\n * and move to the first half later to keep a dictionary of at least wSize\n * bytes. With this organization, matches are limited to a distance of\n * wSize-MAX_MATCH bytes, but this ensures that IO is always\n * performed with a length multiple of the block size.\n */\n\n this.window_size = 0;\n /* Actual size of window: 2*wSize, except when the user input buffer\n * is directly used as sliding window.\n */\n\n this.prev = null;\n /* Link to older string with same hash index. To limit the size of this\n * array to 64K, this link is maintained only for the last 32K strings.\n * An index in this array is thus a window index modulo 32K.\n */\n\n this.head = null; /* Heads of the hash chains or NIL. */\n\n this.ins_h = 0; /* hash index of string to be inserted */\n this.hash_size = 0; /* number of elements in hash table */\n this.hash_bits = 0; /* log2(hash_size) */\n this.hash_mask = 0; /* hash_size-1 */\n\n this.hash_shift = 0;\n /* Number of bits by which ins_h must be shifted at each input\n * step. It must be such that after MIN_MATCH steps, the oldest\n * byte no longer takes part in the hash key, that is:\n * hash_shift * MIN_MATCH >= hash_bits\n */\n\n this.block_start = 0;\n /* Window position at the beginning of the current output block. Gets\n * negative when the window is moved backwards.\n */\n\n this.match_length = 0; /* length of best match */\n this.prev_match = 0; /* previous match */\n this.match_available = 0; /* set if previous match exists */\n this.strstart = 0; /* start of string to insert */\n this.match_start = 0; /* start of matching string */\n this.lookahead = 0; /* number of valid bytes ahead in window */\n\n this.prev_length = 0;\n /* Length of the best match at previous step. Matches not greater than this\n * are discarded. This is used in the lazy match evaluation.\n */\n\n this.max_chain_length = 0;\n /* To speed up deflation, hash chains are never searched beyond this\n * length. A higher limit improves compression ratio but degrades the\n * speed.\n */\n\n this.max_lazy_match = 0;\n /* Attempt to find a better match only when the current match is strictly\n * smaller than this value. This mechanism is used only for compression\n * levels >= 4.\n */\n // That's alias to max_lazy_match, don't use directly\n //this.max_insert_length = 0;\n /* Insert new strings in the hash table only if the match length is not\n * greater than this length. This saves time but degrades compression.\n * max_insert_length is used only for compression levels <= 3.\n */\n\n this.level = 0; /* compression level (1..9) */\n this.strategy = 0; /* favor or force Huffman coding*/\n\n this.good_match = 0;\n /* Use a faster search when the previous match is longer than this */\n\n this.nice_match = 0; /* Stop searching when current match exceeds this */\n\n /* used by trees.c: */\n\n /* Didn't use ct_data typedef below to suppress compiler warning */\n\n // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */\n // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */\n\n // Use flat array of DOUBLE size, with interleaved fata,\n // because JS does not support effective\n this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);\n this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);\n this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n\n this.l_desc = null; /* desc. for literal tree */\n this.d_desc = null; /* desc. for distance tree */\n this.bl_desc = null; /* desc. for bit length tree */\n\n //ush bl_count[MAX_BITS+1];\n this.bl_count = new utils.Buf16(MAX_BITS + 1);\n /* number of codes at each bit length for an optimal tree */\n\n //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */\n this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */\n zero(this.heap);\n\n this.heap_len = 0; /* number of elements in the heap */\n this.heap_max = 0; /* element of largest frequency */\n /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n * The same heap array is used to build all trees.\n */\n\n this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];\n zero(this.depth);\n /* Depth of each subtree used as tie breaker for trees of equal frequency\n */\n\n this.l_buf = 0; /* buffer index for literals or lengths */\n\n this.lit_bufsize = 0;\n /* Size of match buffer for literals/lengths. There are 4 reasons for\n * limiting lit_bufsize to 64K:\n * - frequencies can be kept in 16 bit counters\n * - if compression is not successful for the first block, all input\n * data is still in the window so we can still emit a stored block even\n * when input comes from standard input. (This can also be done for\n * all blocks if lit_bufsize is not greater than 32K.)\n * - if compression is not successful for a file smaller than 64K, we can\n * even emit a stored file instead of a stored block (saving 5 bytes).\n * This is applicable only for zip (not gzip or zlib).\n * - creating new Huffman trees less frequently may not provide fast\n * adaptation to changes in the input data statistics. (Take for\n * example a binary file with poorly compressible code followed by\n * a highly compressible string table.) Smaller buffer sizes give\n * fast adaptation but have of course the overhead of transmitting\n * trees more frequently.\n * - I can't count above 4\n */\n\n this.last_lit = 0; /* running index in l_buf */\n\n this.d_buf = 0;\n /* Buffer index for distances. To simplify the code, d_buf and l_buf have\n * the same number of elements. To use different lengths, an extra flag\n * array would be necessary.\n */\n\n this.opt_len = 0; /* bit length of current block with optimal trees */\n this.static_len = 0; /* bit length of current block with static trees */\n this.matches = 0; /* number of string matches in current block */\n this.insert = 0; /* bytes at end of window left to insert */\n\n\n this.bi_buf = 0;\n /* Output buffer. bits are inserted starting at the bottom (least\n * significant bits).\n */\n this.bi_valid = 0;\n /* Number of valid bits in bi_buf. All bits above the last valid bit\n * are always zero.\n */\n\n // Used for window memory init. We safely ignore it for JS. That makes\n // sense only for pointers and memory check tools.\n //this.high_water = 0;\n /* High water mark offset in window for initialized bytes -- bytes above\n * this are set to zero in order to avoid memory check warnings when\n * longest match routines access bytes past the input. This is then\n * updated to the new high water mark.\n */\n}\n\n\nfunction deflateResetKeep(strm) {\n var s;\n\n if (!strm || !strm.state) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n\n s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n /* was made negative by deflate(..., Z_FINISH); */\n }\n s.status = (s.wrap ? INIT_STATE : BUSY_STATE);\n strm.adler = (s.wrap === 2) ?\n 0 // crc32(0, Z_NULL, 0)\n :\n 1; // adler32(0, Z_NULL, 0)\n s.last_flush = Z_NO_FLUSH;\n trees._tr_init(s);\n return Z_OK;\n}\n\n\nfunction deflateReset(strm) {\n var ret = deflateResetKeep(strm);\n if (ret === Z_OK) {\n lm_init(strm.state);\n }\n return ret;\n}\n\n\nfunction deflateSetHeader(strm, head) {\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; }\n strm.state.gzhead = head;\n return Z_OK;\n}\n\n\nfunction deflateInit2(strm, level, method, windowBits, memLevel, strategy) {\n if (!strm) { // === Z_NULL\n return Z_STREAM_ERROR;\n }\n var wrap = 1;\n\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n\n if (windowBits < 0) { /* suppress zlib wrapper */\n wrap = 0;\n windowBits = -windowBits;\n }\n\n else if (windowBits > 15) {\n wrap = 2; /* write gzip wrapper instead */\n windowBits -= 16;\n }\n\n\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED ||\n windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n strategy < 0 || strategy > Z_FIXED) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n\n if (windowBits === 8) {\n windowBits = 9;\n }\n /* until 256-byte window bug fixed */\n\n var s = new DeflateState();\n\n strm.state = s;\n s.strm = strm;\n\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n\n s.window = new utils.Buf8(s.w_size * 2);\n s.head = new utils.Buf16(s.hash_size);\n s.prev = new utils.Buf16(s.w_size);\n\n // Don't need mem init magic for JS.\n //s.high_water = 0; /* nothing written to s->window yet */\n\n s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n s.pending_buf_size = s.lit_bufsize * 4;\n\n //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n //s->pending_buf = (uchf *) overlay;\n s.pending_buf = new utils.Buf8(s.pending_buf_size);\n\n // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)\n //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n s.d_buf = 1 * s.lit_bufsize;\n\n //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n s.l_buf = (1 + 2) * s.lit_bufsize;\n\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n\n return deflateReset(strm);\n}\n\nfunction deflateInit(strm, level) {\n return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n}\n\n\nfunction deflate(strm, flush) {\n var old_flush, s;\n var beg, val; // for gzip header write only\n\n if (!strm || !strm.state ||\n flush > Z_BLOCK || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;\n }\n\n s = strm.state;\n\n if (!strm.output ||\n (!strm.input && strm.avail_in !== 0) ||\n (s.status === FINISH_STATE && flush !== Z_FINISH)) {\n return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR);\n }\n\n s.strm = strm; /* just in case */\n old_flush = s.last_flush;\n s.last_flush = flush;\n\n /* Write the header */\n if (s.status === INIT_STATE) {\n\n if (s.wrap === 2) { // GZIP header\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) { // s->gzhead == Z_NULL\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n }\n else {\n put_byte(s, (s.gzhead.text ? 1 : 0) +\n (s.gzhead.hcrc ? 2 : 0) +\n (!s.gzhead.extra ? 0 : 4) +\n (!s.gzhead.name ? 0 : 8) +\n (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 0xff);\n put_byte(s, (s.gzhead.time >> 8) & 0xff);\n put_byte(s, (s.gzhead.time >> 16) & 0xff);\n put_byte(s, (s.gzhead.time >> 24) & 0xff);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, s.gzhead.os & 0xff);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 0xff);\n put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n else // DEFLATE header\n {\n var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;\n var level_flags = -1;\n\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= (level_flags << 6);\n if (s.strstart !== 0) { header |= PRESET_DICT; }\n header += 31 - (header % 31);\n\n s.status = BUSY_STATE;\n putShortMSB(s, header);\n\n /* Save the adler32 of the preset dictionary: */\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n strm.adler = 1; // adler32(0L, Z_NULL, 0);\n }\n }\n\n//#ifdef GZIP\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n\n while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n break;\n }\n }\n put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);\n s.gzindex++;\n }\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (s.gzindex === s.gzhead.extra.length) {\n s.gzindex = 0;\n s.status = NAME_STATE;\n }\n }\n else {\n s.status = NAME_STATE;\n }\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.gzindex = 0;\n s.status = COMMENT_STATE;\n }\n }\n else {\n s.status = COMMENT_STATE;\n }\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.status = HCRC_STATE;\n }\n }\n else {\n s.status = HCRC_STATE;\n }\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n }\n if (s.pending + 2 <= s.pending_buf_size) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n s.status = BUSY_STATE;\n }\n }\n else {\n s.status = BUSY_STATE;\n }\n }\n//#endif\n\n /* Flush as much pending output as possible */\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n /* Since avail_out is 0, deflate will be called again with\n * more output space, but possibly with both pending and\n * avail_in equal to zero. There won't be anything to do,\n * but this is not an error situation so make sure we\n * return OK instead of BUF_ERROR at next call of deflate:\n */\n s.last_flush = -1;\n return Z_OK;\n }\n\n /* Make sure there is something to do and avoid duplicate consecutive\n * flushes. For repeated and useless calls with Z_FINISH, we keep\n * returning Z_STREAM_END instead of Z_BUF_ERROR.\n */\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&\n flush !== Z_FINISH) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* User must not provide more input after the first FINISH: */\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* Start a new block or continue the current one.\n */\n if (strm.avail_in !== 0 || s.lookahead !== 0 ||\n (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {\n var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :\n (s.strategy === Z_RLE ? deflate_rle(s, flush) :\n configuration_table[s.level].func(s, flush));\n\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n /* avoid BUF_ERROR next call, see above */\n }\n return Z_OK;\n /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n * of deflate should use the same flush parameter to make sure\n * that the flush is complete. So we don't have to output an\n * empty block here, this will be done at next call. This also\n * ensures that for a very small output buffer, we emit at most\n * one empty block.\n */\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n trees._tr_align(s);\n }\n else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */\n\n trees._tr_stored_block(s, 0, 0, false);\n /* For a full flush, this empty block will be recognized\n * as a special marker by inflate_sync().\n */\n if (flush === Z_FULL_FLUSH) {\n /*** CLEAR_HASH(s); ***/ /* forget history */\n zero(s.head); // Fill with NIL (= 0);\n\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n return Z_OK;\n }\n }\n }\n //Assert(strm->avail_out > 0, \"bug2\");\n //if (strm.avail_out <= 0) { throw new Error(\"bug2\");}\n\n if (flush !== Z_FINISH) { return Z_OK; }\n if (s.wrap <= 0) { return Z_STREAM_END; }\n\n /* Write the trailer */\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n put_byte(s, (strm.adler >> 16) & 0xff);\n put_byte(s, (strm.adler >> 24) & 0xff);\n put_byte(s, strm.total_in & 0xff);\n put_byte(s, (strm.total_in >> 8) & 0xff);\n put_byte(s, (strm.total_in >> 16) & 0xff);\n put_byte(s, (strm.total_in >> 24) & 0xff);\n }\n else\n {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n\n flush_pending(strm);\n /* If avail_out is zero, the application will call deflate again\n * to flush the rest.\n */\n if (s.wrap > 0) { s.wrap = -s.wrap; }\n /* write the trailer only once! */\n return s.pending !== 0 ? Z_OK : Z_STREAM_END;\n}\n\nfunction deflateEnd(strm) {\n var status;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n status = strm.state.status;\n if (status !== INIT_STATE &&\n status !== EXTRA_STATE &&\n status !== NAME_STATE &&\n status !== COMMENT_STATE &&\n status !== HCRC_STATE &&\n status !== BUSY_STATE &&\n status !== FINISH_STATE\n ) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.state = null;\n\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;\n}\n\n\n/* =========================================================================\n * Initializes the compression dictionary from the given byte\n * sequence without producing any compressed output.\n */\nfunction deflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var s;\n var str, n;\n var wrap;\n var avail;\n var next;\n var input;\n var tmpDict;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n s = strm.state;\n wrap = s.wrap;\n\n if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {\n return Z_STREAM_ERROR;\n }\n\n /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n if (wrap === 1) {\n /* adler32(strm->adler, dictionary, dictLength); */\n strm.adler = adler32(strm.adler, dictionary, dictLength, 0);\n }\n\n s.wrap = 0; /* avoid computing Adler-32 in read_buf */\n\n /* if dictionary would fill window, just replace the history */\n if (dictLength >= s.w_size) {\n if (wrap === 0) { /* already empty otherwise */\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n /* use the tail */\n // dictionary = dictionary.slice(dictLength - s.w_size);\n tmpDict = new utils.Buf8(s.w_size);\n utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n /* insert dictionary into window and hash */\n avail = strm.avail_in;\n next = strm.next_in;\n input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n str = s.strstart;\n n = s.lookahead - (MIN_MATCH - 1);\n do {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK;\n}\n\n\nexports.deflateInit = deflateInit;\nexports.deflateInit2 = deflateInit2;\nexports.deflateReset = deflateReset;\nexports.deflateResetKeep = deflateResetKeep;\nexports.deflateSetHeader = deflateSetHeader;\nexports.deflate = deflate;\nexports.deflateEnd = deflateEnd;\nexports.deflateSetDictionary = deflateSetDictionary;\nexports.deflateInfo = 'pako deflate (from Nodeca project)';\n\n/* Not implemented\nexports.deflateBound = deflateBound;\nexports.deflateCopy = deflateCopy;\nexports.deflateParams = deflateParams;\nexports.deflatePending = deflatePending;\nexports.deflatePrime = deflatePrime;\nexports.deflateTune = deflateTune;\n*/\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/deflate.js\n// module id = 26\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n//var Z_FILTERED = 1;\n//var Z_HUFFMAN_ONLY = 2;\n//var Z_RLE = 3;\nvar Z_FIXED = 4;\n//var Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\nvar Z_BINARY = 0;\nvar Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n/*============================================================================*/\n\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n// From zutil.h\n\nvar STORED_BLOCK = 0;\nvar STATIC_TREES = 1;\nvar DYN_TREES = 2;\n/* The three kinds of block type */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\n/* The minimum and maximum match lengths */\n\n// From deflate.h\n/* ===========================================================================\n * Internal compression state.\n */\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\n\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\n\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\n\nvar D_CODES = 30;\n/* number of distance codes */\n\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\n\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\n\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar Buf_size = 16;\n/* size of bit buffer in bi_buf */\n\n\n/* ===========================================================================\n * Constants\n */\n\nvar MAX_BL_BITS = 7;\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\nvar END_BLOCK = 256;\n/* end of block literal code */\n\nvar REP_3_6 = 16;\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\nvar REPZ_3_10 = 17;\n/* repeat a zero length 3-10 times (3 bits of repeat count) */\n\nvar REPZ_11_138 = 18;\n/* repeat a zero length 11-138 times (7 bits of repeat count) */\n\n/* eslint-disable comma-spacing,array-bracket-spacing */\nvar extra_lbits = /* extra bits for each length code */\n [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];\n\nvar extra_dbits = /* extra bits for each distance code */\n [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];\n\nvar extra_blbits = /* extra bits for each bit length code */\n [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];\n\nvar bl_order =\n [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];\n/* eslint-enable comma-spacing,array-bracket-spacing */\n\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n// We pre-fill arrays with 0 to avoid uninitialized gaps\n\nvar DIST_CODE_LEN = 512; /* see definition of array dist_code below */\n\n// !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1\nvar static_ltree = new Array((L_CODES + 2) * 2);\nzero(static_ltree);\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nvar static_dtree = new Array(D_CODES * 2);\nzero(static_dtree);\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nvar _dist_code = new Array(DIST_CODE_LEN);\nzero(_dist_code);\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nvar _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);\nzero(_length_code);\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nvar base_length = new Array(LENGTH_CODES);\nzero(base_length);\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nvar base_dist = new Array(D_CODES);\nzero(base_dist);\n/* First normalized distance for each code (0 = distance of 1) */\n\n\nfunction StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n\n this.static_tree = static_tree; /* static tree or NULL */\n this.extra_bits = extra_bits; /* extra bits for each code or NULL */\n this.extra_base = extra_base; /* base index for extra_bits */\n this.elems = elems; /* max number of elements in the tree */\n this.max_length = max_length; /* max bit length for the codes */\n\n // show if `static_tree` has data or dummy - needed for monomorphic objects\n this.has_stree = static_tree && static_tree.length;\n}\n\n\nvar static_l_desc;\nvar static_d_desc;\nvar static_bl_desc;\n\n\nfunction TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree; /* the dynamic tree */\n this.max_code = 0; /* largest code with non zero frequency */\n this.stat_desc = stat_desc; /* the corresponding static tree */\n}\n\n\n\nfunction d_code(dist) {\n return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];\n}\n\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\nfunction put_short(s, w) {\n// put_byte(s, (uch)((w) & 0xff));\n// put_byte(s, (uch)((ush)(w) >> 8));\n s.pending_buf[s.pending++] = (w) & 0xff;\n s.pending_buf[s.pending++] = (w >>> 8) & 0xff;\n}\n\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\nfunction send_bits(s, value, length) {\n if (s.bi_valid > (Buf_size - length)) {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> (Buf_size - s.bi_valid);\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n s.bi_valid += length;\n }\n}\n\n\nfunction send_code(s, c, tree) {\n send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);\n}\n\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nfunction bi_reverse(code, len) {\n var res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nfunction bi_flush(s) {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 0xff;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n}\n\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n * above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n * array bl_count contains the frequencies for each bit length.\n * The length opt_len is updated; static_len is also updated if stree is\n * not null.\n */\nfunction gen_bitlen(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var max_code = desc.max_code;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var extra = desc.stat_desc.extra_bits;\n var base = desc.stat_desc.extra_base;\n var max_length = desc.stat_desc.max_length;\n var h; /* heap index */\n var n, m; /* iterate over the tree elements */\n var bits; /* bit length */\n var xbits; /* extra bits */\n var f; /* frequency */\n var overflow = 0; /* number of elements with bit length too large */\n\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n\n /* In a first pass, compute the optimal bit lengths (which may\n * overflow in the case of the bit length tree).\n */\n tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */\n\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1]/*.Len*/ = bits;\n /* We overwrite tree[n].Dad which is no longer needed */\n\n if (n > max_code) { continue; } /* not a leaf node */\n\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2]/*.Freq*/;\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);\n }\n }\n if (overflow === 0) { return; }\n\n // Trace((stderr,\"\\nbit length overflow\\n\"));\n /* This happens for example on obj2 and pic of the Calgary corpus */\n\n /* Find the first bit length which could increase: */\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) { bits--; }\n s.bl_count[bits]--; /* move one leaf down the tree */\n s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */\n s.bl_count[max_length]--;\n /* The brother of the overflow item also moves one step up,\n * but this does not affect bl_count[max_length]\n */\n overflow -= 2;\n } while (overflow > 0);\n\n /* Now recompute all bit lengths, scanning in increasing frequency.\n * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n * lengths instead of fixing only the wrong ones. This idea is taken\n * from 'ar' written by Haruhiko Okumura.)\n */\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) { continue; }\n if (tree[m * 2 + 1]/*.Len*/ !== bits) {\n // Trace((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;\n tree[m * 2 + 1]/*.Len*/ = bits;\n }\n n--;\n }\n }\n}\n\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n * zero code length.\n */\nfunction gen_codes(tree, max_code, bl_count)\n// ct_data *tree; /* the tree to decorate */\n// int max_code; /* largest code with non zero frequency */\n// ushf *bl_count; /* number of codes at each bit length */\n{\n var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */\n var code = 0; /* running code value */\n var bits; /* bit index */\n var n; /* code index */\n\n /* The distribution counts are first used to generate the code values\n * without bit reversal.\n */\n for (bits = 1; bits <= MAX_BITS; bits++) {\n next_code[bits] = code = (code + bl_count[bits - 1]) << 1;\n }\n /* Check that the bit counts in bl_count are consistent. The last code\n * must be all ones.\n */\n //Assert (code + bl_count[MAX_BITS]-1 == (1< length code (0..28) */\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length[code] = length;\n for (n = 0; n < (1 << extra_lbits[code]); n++) {\n _length_code[length++] = code;\n }\n }\n //Assert (length == 256, \"tr_static_init: length != 256\");\n /* Note that the length 255 (match length 258) can be represented\n * in two different ways: code 284 + 5 bits or code 285, so we\n * overwrite length_code[255] to use the best encoding:\n */\n _length_code[length - 1] = code;\n\n /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist[code] = dist;\n for (n = 0; n < (1 << extra_dbits[code]); n++) {\n _dist_code[dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: dist != 256\");\n dist >>= 7; /* from now on, all distances are divided by 128 */\n for (; code < D_CODES; code++) {\n base_dist[code] = dist << 7;\n for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {\n _dist_code[256 + dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n /* Construct the codes of the static literal tree */\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n\n n = 0;\n while (n <= 143) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree[n * 2 + 1]/*.Len*/ = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree[n * 2 + 1]/*.Len*/ = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n /* Codes 286 and 287 do not exist, but we must include them in the\n * tree construction to get a canonical Huffman tree (longest code\n * all ones)\n */\n gen_codes(static_ltree, L_CODES + 1, bl_count);\n\n /* The static distance tree is trivial: */\n for (n = 0; n < D_CODES; n++) {\n static_dtree[n * 2 + 1]/*.Len*/ = 5;\n static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);\n }\n\n // Now data ready and we can init static trees\n static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n\n //static_init_done = true;\n}\n\n\n/* ===========================================================================\n * Initialize a new block.\n */\nfunction init_block(s) {\n var n; /* iterates over tree elements */\n\n /* Initialize the trees. */\n for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }\n\n s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;\n s.opt_len = s.static_len = 0;\n s.last_lit = s.matches = 0;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nfunction bi_windup(s)\n{\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n //put_byte(s, (Byte)s->bi_buf);\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n}\n\n/* ===========================================================================\n * Copy a stored block, storing first the length and its\n * one's complement if requested.\n */\nfunction copy_block(s, buf, len, header)\n//DeflateState *s;\n//charf *buf; /* the input data */\n//unsigned len; /* its length */\n//int header; /* true if block header must be written */\n{\n bi_windup(s); /* align on byte boundary */\n\n if (header) {\n put_short(s, len);\n put_short(s, ~len);\n }\n// while (len--) {\n// put_byte(s, *buf++);\n// }\n utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);\n s.pending += len;\n}\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\nfunction smaller(tree, n, m, depth) {\n var _n2 = n * 2;\n var _m2 = m * 2;\n return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||\n (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));\n}\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nfunction pqdownheap(s, tree, k)\n// deflate_state *s;\n// ct_data *tree; /* the tree to restore */\n// int k; /* node to move down */\n{\n var v = s.heap[k];\n var j = k << 1; /* left son of k */\n while (j <= s.heap_len) {\n /* Set j to the smallest of the two sons: */\n if (j < s.heap_len &&\n smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n /* Exit if v is smaller than both sons */\n if (smaller(tree, v, s.heap[j], s.depth)) { break; }\n\n /* Exchange v with the smallest son */\n s.heap[k] = s.heap[j];\n k = j;\n\n /* And continue down the tree, setting j to the left son of k */\n j <<= 1;\n }\n s.heap[k] = v;\n}\n\n\n// inlined manually\n// var SMALLEST = 1;\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nfunction compress_block(s, ltree, dtree)\n// deflate_state *s;\n// const ct_data *ltree; /* literal tree */\n// const ct_data *dtree; /* distance tree */\n{\n var dist; /* distance of matched string */\n var lc; /* match length or unmatched char (if dist == 0) */\n var lx = 0; /* running index in l_buf */\n var code; /* the code to send */\n var extra; /* number of extra bits to send */\n\n if (s.last_lit !== 0) {\n do {\n dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);\n lc = s.pending_buf[s.l_buf + lx];\n lx++;\n\n if (dist === 0) {\n send_code(s, lc, ltree); /* send a literal byte */\n //Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n } else {\n /* Here, lc is the match length - MIN_MATCH */\n code = _length_code[lc];\n send_code(s, code + LITERALS + 1, ltree); /* send the length code */\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length[code];\n send_bits(s, lc, extra); /* send the extra length bits */\n }\n dist--; /* dist is now the match distance - 1 */\n code = d_code(dist);\n //Assert (code < D_CODES, \"bad d_code\");\n\n send_code(s, code, dtree); /* send the distance code */\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist[code];\n send_bits(s, dist, extra); /* send the extra distance bits */\n }\n } /* literal or match pair ? */\n\n /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n // \"pendingBuf overflow\");\n\n } while (lx < s.last_lit);\n }\n\n send_code(s, END_BLOCK, ltree);\n}\n\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n * and corresponding code. The length opt_len is updated; static_len is\n * also updated if stree is not null. The field max_code is set.\n */\nfunction build_tree(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var elems = desc.stat_desc.elems;\n var n, m; /* iterate over heap elements */\n var max_code = -1; /* largest code with non zero frequency */\n var node; /* new node being created */\n\n /* Construct the initial heap, with least frequent element in\n * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n * heap[0] is not used.\n */\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n\n for (n = 0; n < elems; n++) {\n if (tree[n * 2]/*.Freq*/ !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n\n } else {\n tree[n * 2 + 1]/*.Len*/ = 0;\n }\n }\n\n /* The pkzip format requires that at least one distance code exists,\n * and that at least one bit should be sent even if there is only one\n * possible code. So to avoid special checks later on we force at least\n * two codes of non zero frequency.\n */\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);\n tree[node * 2]/*.Freq*/ = 1;\n s.depth[node] = 0;\n s.opt_len--;\n\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1]/*.Len*/;\n }\n /* node is 0 or 1 so it does not have extra bits */\n }\n desc.max_code = max_code;\n\n /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n * establish sub-heaps of increasing lengths:\n */\n for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }\n\n /* Construct the Huffman tree by repeatedly combining the least two\n * frequent nodes.\n */\n node = elems; /* next internal node of the tree */\n do {\n //pqremove(s, tree, n); /* n = node of least frequency */\n /*** pqremove ***/\n n = s.heap[1/*SMALLEST*/];\n s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];\n pqdownheap(s, tree, 1/*SMALLEST*/);\n /***/\n\n m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */\n\n s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */\n s.heap[--s.heap_max] = m;\n\n /* Create a new node father of n and m */\n tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;\n\n /* and insert the new node in the heap */\n s.heap[1/*SMALLEST*/] = node++;\n pqdownheap(s, tree, 1/*SMALLEST*/);\n\n } while (s.heap_len >= 2);\n\n s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];\n\n /* At this point, the fields freq and dad are set. We can now\n * generate the bit lengths.\n */\n gen_bitlen(s, desc);\n\n /* The field len is now set, we can generate the bit codes */\n gen_codes(tree, max_code, s.bl_count);\n}\n\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nfunction scan_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n s.bl_tree[curlen * 2]/*.Freq*/ += count;\n\n } else if (curlen !== 0) {\n\n if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }\n s.bl_tree[REP_3_6 * 2]/*.Freq*/++;\n\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;\n\n } else {\n s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;\n }\n\n count = 0;\n prevlen = curlen;\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nfunction send_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n /* tree[max_code+1].Len = -1; */ /* guard already set */\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);\n\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n //Assert(count >= 3 && count <= 6, \" 3_6?\");\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nfunction build_bl_tree(s) {\n var max_blindex; /* index of last bit length code of non zero freq */\n\n /* Determine the bit length frequencies for literal and distance trees */\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n\n /* Build the bit length tree: */\n build_tree(s, s.bl_desc);\n /* opt_len now includes the length of the tree representations, except\n * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n */\n\n /* Determine the number of bit length codes to send. The pkzip format\n * requires that at least 4 bit length codes be sent. (appnote.txt says\n * 3 but the actual value used is 4.)\n */\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {\n break;\n }\n }\n /* Update opt_len to include the bit length tree and counts */\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n //Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n // s->opt_len, s->static_len));\n\n return max_blindex;\n}\n\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nfunction send_all_trees(s, lcodes, dcodes, blcodes)\n// deflate_state *s;\n// int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n var rank; /* index in bl_order */\n\n //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n // \"too many codes\");\n //Tracev((stderr, \"\\nbl counts: \"));\n send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */\n for (rank = 0; rank < blcodes; rank++) {\n //Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);\n }\n //Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */\n //Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */\n //Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n}\n\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n * a) There are no non-portable control characters belonging to the\n * \"black list\" (0..6, 14..25, 28..31).\n * b) There is at least one printable character belonging to the\n * \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n * \"gray list\" that is ignored in this detection algorithm:\n * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nfunction detect_data_type(s) {\n /* black_mask is the bit mask of black-listed bytes\n * set bits 0..6, 14..25, and 28..31\n * 0xf3ffc07f = binary 11110011111111111100000001111111\n */\n var black_mask = 0xf3ffc07f;\n var n;\n\n /* Check for non-textual (\"black-listed\") bytes. */\n for (n = 0; n <= 31; n++, black_mask >>>= 1) {\n if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {\n return Z_BINARY;\n }\n }\n\n /* Check for textual (\"white-listed\") bytes. */\n if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||\n s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n }\n\n /* There are no \"black-listed\" or \"white-listed\" bytes:\n * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n */\n return Z_BINARY;\n}\n\n\nvar static_init_done = false;\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nfunction _tr_init(s)\n{\n\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n /* Initialize the first block of the first file: */\n init_block(s);\n}\n\n\n/* ===========================================================================\n * Send a stored block\n */\nfunction _tr_stored_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */\n copy_block(s, buf, stored_len, true); /* with header */\n}\n\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nfunction _tr_align(s) {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree);\n bi_flush(s);\n}\n\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and output the encoded block to the zip file.\n */\nfunction _tr_flush_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block, or NULL if too old */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n var opt_lenb, static_lenb; /* opt_len and static_len in bytes */\n var max_blindex = 0; /* index of last bit length code of non zero freq */\n\n /* Build the Huffman trees unless a stored block is forced */\n if (s.level > 0) {\n\n /* Check if the file is binary or text */\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n\n /* Construct the literal and distance trees */\n build_tree(s, s.l_desc);\n // Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n\n build_tree(s, s.d_desc);\n // Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n /* At this point, opt_len and static_len are the total bit lengths of\n * the compressed block data, excluding the tree representations.\n */\n\n /* Build the bit length tree for the above two trees, and get the index\n * in bl_order of the last bit length code to send.\n */\n max_blindex = build_bl_tree(s);\n\n /* Determine the best encoding. Compute the block lengths in bytes. */\n opt_lenb = (s.opt_len + 3 + 7) >>> 3;\n static_lenb = (s.static_len + 3 + 7) >>> 3;\n\n // Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n // s->last_lit));\n\n if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }\n\n } else {\n // Assert(buf != (char*)0, \"lost buf\");\n opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n }\n\n if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {\n /* 4: two words for the lengths */\n\n /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n * Otherwise we can't have processed more than WSIZE input bytes since\n * the last block flush, because compression would have been\n * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n * transform a block into a stored block.\n */\n _tr_stored_block(s, buf, stored_len, last);\n\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree, static_dtree);\n\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n // Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n /* The above check is made mod 2^32, for files larger than 512 MB\n * and uLong implemented on 32 bits.\n */\n init_block(s);\n\n if (last) {\n bi_windup(s);\n }\n // Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n // s->compressed_len-7*last));\n}\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nfunction _tr_tally(s, dist, lc)\n// deflate_state *s;\n// unsigned dist; /* distance of matched string */\n// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n //var out_length, in_length, dcode;\n\n s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;\n s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;\n\n s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;\n s.last_lit++;\n\n if (dist === 0) {\n /* lc is the unmatched char */\n s.dyn_ltree[lc * 2]/*.Freq*/++;\n } else {\n s.matches++;\n /* Here, lc is the match length - MIN_MATCH */\n dist--; /* dist = match distance - 1 */\n //Assert((ush)dist < (ush)MAX_DIST(s) &&\n // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n // (ush)d_code(dist) < (ush)D_CODES, \"_tr_tally: bad match\");\n\n s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;\n s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n\n//#ifdef TRUNCATE_BLOCK\n// /* Try to guess if it is profitable to stop the current block here */\n// if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {\n// /* Compute an upper bound for the compressed length */\n// out_length = s.last_lit*8;\n// in_length = s.strstart - s.block_start;\n//\n// for (dcode = 0; dcode < D_CODES; dcode++) {\n// out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);\n// }\n// out_length >>>= 3;\n// //Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n// // s->last_lit, in_length, out_length,\n// // 100L - out_length*100L/in_length));\n// if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {\n// return true;\n// }\n// }\n//#endif\n\n return (s.last_lit === s.lit_bufsize - 1);\n /* We avoid equality with lit_bufsize because of wraparound at 64K\n * on 16 bit machines and because stored blocks are restricted to\n * 64K-1 bytes.\n */\n}\n\nexports._tr_init = _tr_init;\nexports._tr_stored_block = _tr_stored_block;\nexports._tr_flush_block = _tr_flush_block;\nexports._tr_tally = _tr_tally;\nexports._tr_align = _tr_align;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/trees.js\n// module id = 27\n// module chunks = 0","'use strict';\n\n\nvar zlib_inflate = require('./zlib/inflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar c = require('./zlib/constants');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\nvar GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = utils.assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== c.Z_OK) {\n throw new Error(msg[status]);\n }\n\n this.header = new GZheader();\n\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = strings.binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */\n\n if (status === c.Z_NEED_DICT && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = strings.string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = zlib_inflate.inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === c.Z_BUF_ERROR && allowBufError === true) {\n status = c.Z_OK;\n allowBufError = false;\n }\n\n if (status !== c.Z_STREAM_END && status !== c.Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);\n\n if (status === c.Z_STREAM_END) {\n _mode = c.Z_FINISH;\n }\n\n // Finalize on the last chunk.\n if (_mode === c.Z_FINISH) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === c.Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === c.Z_SYNC_FLUSH) {\n this.onEnd(c.Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === c.Z_OK) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 aligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction inflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg || msg[inflator.err]; }\n\n return inflator.result;\n}\n\n\n/**\n * inflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n}\n\n\n/**\n * ungzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\nexports.Inflate = Inflate;\nexports.inflate = inflate;\nexports.inflateRaw = inflateRaw;\nexports.ungzip = inflate;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/inflate.js\n// module id = 28\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar inflate_fast = require('./inffast');\nvar inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_WBITS = MAX_WBITS;\n\n\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new utils.Buf16(320); /* temporary storage for code lengths */\n this.work = new utils.Buf16(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);\n state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\nfunction inflateInit(strm) {\n return inflateInit2(strm, DEF_WBITS);\n}\n\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new utils.Buf32(512);\n distfix = new utils.Buf32(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new utils.Buf8(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n utils.arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n utils.arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n utils.arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n utils.arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\nexports.inflateReset = inflateReset;\nexports.inflateReset2 = inflateReset2;\nexports.inflateResetKeep = inflateResetKeep;\nexports.inflateInit = inflateInit;\nexports.inflateInit2 = inflateInit2;\nexports.inflate = inflate;\nexports.inflateEnd = inflateEnd;\nexports.inflateGetHeader = inflateGetHeader;\nexports.inflateSetDictionary = inflateSetDictionary;\nexports.inflateInfo = 'pako inflate (from Nodeca project)';\n\n/* Not implemented\nexports.inflateCopy = inflateCopy;\nexports.inflateGetDictionary = inflateGetDictionary;\nexports.inflateMark = inflateMark;\nexports.inflatePrime = inflatePrime;\nexports.inflateSync = inflateSync;\nexports.inflateSyncPoint = inflateSyncPoint;\nexports.inflateUndermine = inflateUndermine;\n*/\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inflate.js\n// module id = 29\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// See state defs from inflate.js\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\nmodule.exports = function inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inffast.js\n// module id = 30\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\nmodule.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/inftrees.js\n// module id = 31\n// module chunks = 0","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\nmodule.exports = GZheader;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/pako/lib/zlib/gzheader.js\n// module id = 32\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\n/**\n * @protected\n */\nexport default class WeightDecoderRaw {\n async decode(data) {\n return new Float32Array(data.buffer, data.byteOffset, data.byteLength / 4);\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/decoder/weight_decoder_raw.js\n// module id = 33\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\n/**\n * @private\n */\nconst NOT_SCHEDULED = -1;\n/**\n * Schedule function which is called too much frequently.\n *\n * @private\n */\nexport default class DispatchScheduler {\n constructor() {\n this.scheduledCallbackId = NOT_SCHEDULED;\n }\n /**\n * Register scheduled function. If already other function is scheduled, it is canceled and dispatcher will dispatch only\n * function which is registered at last.\n * @param fn scheduled function\n */\n request(fn) {\n this.fn = fn;\n if (this.scheduledCallbackId == NOT_SCHEDULED) {\n this.scheduledCallbackId = requestAnimationFrame(() => this.forceDispatch());\n }\n }\n /**\n * Dispatch scheduled function just now. If no function is scheduled, dispatcher do nothing.\n */\n forceDispatch() {\n if (this.scheduledCallbackId == NOT_SCHEDULED)\n return;\n this.cancel();\n this.fn();\n }\n /**\n * Cancel scheduled function. If no function is scheduled, dispatcher do nothing.\n */\n cancel() {\n if (this.scheduledCallbackId == NOT_SCHEDULED)\n return;\n cancelAnimationFrame(this.scheduledCallbackId);\n this.scheduledCallbackId = NOT_SCHEDULED;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/util/dispatch_scheduler.js\n// module id = 34\n// module chunks = 0","/**\n * @protected\n */\nfunction flatten(arr) {\n let result = [];\n for (let i = 0; i < arr.length; i++) {\n let v = arr[i];\n if (v instanceof Array) {\n result.splice(result.length, 0, flatten(v));\n }\n else {\n result[result.length] = v;\n }\n }\n return result;\n}\n/**\n * @protected\n */\nexport class SymbolicTypedArray {\n /**\n * @protected\n */\n constructor(buffer = null, byteOffset = 0, length, placeholderContext = null) {\n this.placeholderContext = placeholderContext;\n this._byteOffset = byteOffset;\n this._buffer = buffer;\n if (buffer) {\n this._length = length === undefined ? (buffer.byteLength / this.BYTES_PER_ELEMENT) : length;\n }\n else {\n if (length === undefined)\n throw Error('\"butter\" or \"length\" must be specified.');\n this._length = length;\n }\n if (this.isDynamic) {\n if (!placeholderContext) {\n throw Error('PlaceholderContext must be required when SymbolicTypedArray is initialized as dynamic buffer view.');\n }\n }\n }\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n get buffer() {\n if (!this._buffer)\n this._buffer = new ArrayBuffer(this.byteOffset + this.byteLength);\n return this._buffer;\n }\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n set buffer(buffer) {\n this._buffer = buffer;\n }\n /**\n * The length in bytes of the array.\n */\n get byteLength() {\n return this.length * this.BYTES_PER_ELEMENT;\n }\n /**\n * The number in this buffer. Actual offset size is `(offset * SIZE_OF_FLOAT)`.\n */\n get offset() {\n return this.byteOffset / this.BYTES_PER_ELEMENT;\n }\n /**\n * @protected\n */\n get isDynamic() {\n return (typeof this._byteOffset !== 'number' || typeof this._length !== 'number');\n }\n /**\n * The number of elements in this buffer. Actual byte size is `(length * SIZE_OF_FLOAT)`.\n */\n get length() {\n if (this.isDynamic) {\n return this.placeholderContext.resolve(this._length);\n }\n else {\n return this._length;\n }\n }\n /**\n * The offset in bytes of the array.\n */\n get byteOffset() {\n if (this.isDynamic) {\n return this.placeholderContext.resolve(this._byteOffset);\n }\n else {\n return this._byteOffset;\n }\n }\n /**\n * Returns the this object after copying a section of the array identified by start and end\n * to the same array starting at position target\n * @param target If target is negative, it is treated as length+target where length is the\n * length of the array.\n * @param start If start is negative, it is treated as length+start. If end is negative, it\n * is treated as length+end.\n * @param end If not specified, length of the this object is used as its default value.\n */\n copyWithin(target, start, end) {\n this.toActual().copyWithin(target, start, end);\n return this;\n }\n /**\n * Returns the this object after filling the section identified by start and end with value\n * @param value value to fill array section with\n * @param start index to start filling the array at. If start is negative, it is treated as\n * length+start where length is the length of the array.\n * @param end index to stop filling the array at. If end is negative, it is treated as\n * length+end.\n */\n fill(value, start, end) {\n this.toActual().fill(value, start, end);\n return this;\n }\n /**\n * Returns the index of the first occurrence of a value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the\n * search starts at index 0.\n */\n indexOf(searchElement, fromIndex) {\n return this.toActual().indexOf(searchElement, fromIndex);\n }\n /**\n * Adds all the elements of an array separated by the specified separator string.\n * @param separator A string used to separate one element of an array from the next in the\n * resulting String. If omitted, the array elements are separated with a comma.\n */\n join(separator) {\n return this.toActual().join(separator);\n }\n /**\n * Returns the index of the last occurrence of a value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the\n * search starts at index 0.\n */\n lastIndexOf(searchElement, fromIndex) {\n return this.toActual().lastIndexOf(searchElement, fromIndex);\n }\n /**\n * Sorts an array.\n * @param compareFn The name of the function used to determine the order of the elements. If\n * omitted, the elements are sorted in ascending, ASCII character order.\n */\n sort(compareFn) {\n this.toActual().sort(compareFn);\n return this;\n }\n includes(searchElement, fromIndex) {\n return this.toActual().includes(searchElement, fromIndex);\n }\n /**\n * Sets a value or an array of values.\n * @param array A typed or untyped array of values to set.\n * @param offset The index in the current array at which the values are to be written.\n */\n set(array, offset) {\n return this.toActual().set(flatten(array), offset);\n }\n /**\n * Converts a number to a string by using the current locale.\n */\n toLocaleString() {\n return this.toActual().toLocaleString();\n }\n /**\n * Returns a string representation of an array.\n */\n toString() {\n return this.toActual().toString();\n }\n /** @protected */\n [Symbol.iterator]() {\n return this.toActual()[Symbol.iterator]();\n }\n /**\n * Returns an iterable of key, value pairs for every entry in the array\n */\n entries() {\n return this.toActual().entries();\n }\n /**\n * Returns an iterable of keys in the array\n */\n keys() {\n return this.toActual().keys();\n }\n /**\n * Returns an iterable of values in the array\n */\n values() {\n return this.toActual().values();\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/symbolic_typed_array/symbolic_typed_array.js\n// module id = 35\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport * as localforage from \"localforage\";\nimport get_weight_decoder from \"../decoder/get_weight_decoder\";\nimport webDNNFetch, { readArrayBufferProgressively, transformUrl } from \"../fetch\";\nimport PlaceholderContext from \"../placeholder\";\nimport SymbolicFloat32Array from \"../symbolic_typed_array/symbolic_float32array\";\nimport { DescriptorRunner } from \"./descriptor_runner\";\n/**\n * @protected\n */\nexport default class DescriptorRunnerWebassembly extends DescriptorRunner {\n constructor() {\n super();\n this.backendName = 'webassembly';\n this.worker_promise_reject_func = null;\n this.worker_initial_error = null;\n if (typeof Worker === 'undefined')\n throw new Error('WebWorker is needed for WebAssembly backend');\n if (typeof WebAssembly !== 'object') {\n console.warn('WebAssembly is not supported on this browser, trying to use asm.js code');\n }\n }\n static checkAvailability() {\n return 'Worker' in window;\n }\n init() {\n if (!DescriptorRunnerWebassembly.checkAvailability())\n throw Error('WebAssembly backend is not supported in this browser.');\n //nothing to do\n return Promise.resolve();\n }\n // https://qiita.com/sounisi5011/items/e24d0e1dfd71c5dd528e\n // helper function to transform relative path to absolute path\n // FIXME: use URL constructor. URL does not work on IE11, so polyfill is also needed to use it.\n absolutePath(path) {\n var e = document.createElement('span');\n e.insertAdjacentHTML('beforeend', '');\n return e.firstChild.href;\n }\n async setDescriptorAndParameters(descriptor, parameters) {\n this.descriptor = descriptor;\n this.placeholderContext = new PlaceholderContext(this.descriptor.placeholders);\n // for browsers which does not support wasm, try asm.js code\n let kernel_backend = typeof WebAssembly === 'object' ? 'webassembly' : 'asmjs';\n if (window.navigator.userAgent.indexOf('iPhone OS 11_2') >= 0) {\n // workaround for bug in webassembly\n // https://bugs.webkit.org/show_bug.cgi?id=181781\n kernel_backend = 'asmjs';\n }\n let worker_entry_js_path = `${this.directory}/kernels_${kernel_backend}.js`;\n worker_entry_js_path = transformUrl(worker_entry_js_path);\n this.worker_entry_js_path = worker_entry_js_path;\n let worker_src_fetch = await fetch(this.worker_entry_js_path);\n let worker_src = await worker_src_fetch.text();\n /*\n Worker internally try to fetch 'kernels_webassembly.wasm' with relative url.\n However, worker which constructed with blob of source code fails to fetch with relative url.\n To avoid the problem, file name is transformed to absolute url and embedded to webassembly_header.js.\n */\n let map_aux_file_src = (basename, key) => {\n let file_abs = this.absolutePath(`${this.directory}/${basename}`);\n let file_abs_transformed = transformUrl(file_abs); // absolute path is given\n worker_src = worker_src.replace(key, file_abs_transformed);\n };\n if (kernel_backend === 'webassembly') {\n map_aux_file_src('kernels_webassembly.wasm', 'WEBDNN_URL_KERNELS_WASM');\n }\n else {\n map_aux_file_src('kernels_asmjs.js.mem', 'WEBDNN_URL_KERNELS_ASMJS_MEM');\n }\n await this.compile(worker_src);\n await this.loadWeights(new Uint8Array(parameters));\n //assign buffer to input/output buffer view\n (await this.getInputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n (await this.getOutputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n }\n /**\n * Fetch graph descriptor from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @protected\n */\n async fetchDescriptor(directory) {\n this.directory = directory;\n let res = await webDNNFetch(`${directory}/graph_${this.backendName}.json`);\n return res.json();\n }\n /**\n * Fetch parameter files from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @param progressCallback callback which is called to notice the loading is progressing.\n * @protected\n */\n async fetchParameters(directory, progressCallback) {\n let weight_url = `${directory}/weight_${this.backendName}.bin`;\n let weight_fetch = await webDNNFetch(weight_url);\n return readArrayBufferProgressively(weight_fetch, progressCallback);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedDescriptor(directory) {\n this.directory = directory;\n return localforage.getItem(`${directory}_${this.backendName}_descriptor`).catch(() => null);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedParameters(directory, progressCallback) {\n let parameter = await localforage.getItem(`${directory}_${this.backendName}_parameters`).catch(() => null);\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return parameter;\n }\n /**\n * save cache\n */\n async saveCache(directory, descriptor, parameters) {\n await Promise.all([\n localforage.setItem(`${directory}_${this.backendName}_descriptor`, descriptor),\n localforage.setItem(`${directory}_${this.backendName}_parameters`, parameters)\n ]);\n }\n ;\n async setPlaceholderValue(values) {\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n let placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n let descriptor = this.descriptor;\n let unresolvedValueLists = descriptor.unresolved_value_lists;\n let metaBufferFillList = [];\n for (let kernel_order = 0; kernel_order < unresolvedValueLists.length; kernel_order++) {\n let unresolvedValueList = unresolvedValueLists[kernel_order];\n unresolvedValueList.forEach((offset_placeholder) => {\n let resolved_value = placeholderContext.resolve(offset_placeholder.placeholder);\n metaBufferFillList.push(kernel_order, offset_placeholder.offset, resolved_value);\n });\n }\n (await this.getInputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n (await this.getOutputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = (new Float32Array(view.length)).buffer;\n });\n let dynamicBufferSize = this.placeholderContext.resolve(this.descriptor.memory_layout.dynamic.size);\n await this.setPlaceholderValueWorker(dynamicBufferSize, new Int32Array(metaBufferFillList));\n }\n setPlaceholderValueWorker(dynamicBufferSize, metaBufferFillArray) {\n if (!this.worker)\n throw Error(\"Worker is not initialized\");\n let worker = this.worker;\n return new Promise((resolve, reject) => {\n worker.onmessage = (event) => {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n worker.postMessage({ type: 'set_dynamic_buffer', size: dynamicBufferSize, data: metaBufferFillArray });\n });\n }\n compile(worker_src) {\n let blob = new Blob([worker_src], { type: \"text/javascript\" });\n let blob_url = URL.createObjectURL(blob);\n let worker = new Worker(blob_url);\n worker.onerror = (event) => {\n console.error(event);\n // console.error('Worker Exception: ' + event.message);\n if (this.worker_promise_reject_func) {\n this.worker_promise_reject_func(event);\n }\n else {\n this.worker_initial_error = event;\n }\n };\n let promise = new Promise((resolve, reject) => {\n // occurs when this.worker_entry_js_path is 404\n if (this.worker_initial_error)\n return reject(this.worker_initial_error);\n this.worker_promise_reject_func = reject;\n worker.onmessage = (event) => {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.error(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n });\n this.worker = worker;\n return promise;\n }\n async loadWeights(weightsData) {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.worker)\n throw new Error('Worker is not initialized');\n let decoder = get_weight_decoder(this.descriptor.weight_encoding);\n let weight_data = await decoder.decode(weightsData);\n let worker = this.worker;\n let promise = new Promise((resolve, reject) => {\n this.worker_promise_reject_func = reject;\n worker.onmessage = (event) => {\n if (event.data === 0) {\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n worker.postMessage({ type: 'weight', data: weight_data }, [weight_data.buffer]);\n });\n return promise;\n }\n getInputViews() {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, 0, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n }\n getOutputViews() {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, 0, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n }\n async run() {\n // if (this._running) throw new Error('Calling another run() while running.');\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.worker)\n throw new Error('Worker is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error('Not all placeholder is resolved');\n let placeholderContext = this.placeholderContext;\n let descriptor = this.descriptor;\n let worker = this.worker;\n let promise = new Promise((resolve, reject) => {\n // TODO: better way not to generate function on every run\n this.worker_promise_reject_func = reject;\n worker.onmessage = (event) => {\n if (Array.isArray(event.data)) {\n for (let i = 0; i < event.data.length; i++) {\n this.outputs[i].set(event.data[i]);\n }\n resolve();\n }\n else {\n console.log(event.data);\n worker.terminate();\n reject(new Error(event.data));\n }\n };\n let allocations = [descriptor.memory_layout.static.allocations, descriptor.memory_layout.dynamic.allocations];\n let inputs = [];\n for (let i = 0; i < descriptor.inputs.length; i++) {\n for (let allocation_space = 0; allocation_space < 2; allocation_space++) {\n let var_alloc = allocations[allocation_space][descriptor.inputs[i]];\n if (var_alloc) {\n let symAb = this.inputs[i];\n inputs.push({\n space: allocation_space,\n offset: placeholderContext.resolve(var_alloc.offset),\n size: symAb.length,\n data: symAb.toActual()\n });\n break;\n }\n }\n }\n let outputs = [];\n for (let i = 0; i < descriptor.outputs.length; i++) {\n for (let allocation_space = 0; allocation_space < 2; allocation_space++) {\n let var_alloc = allocations[allocation_space][descriptor.outputs[i]];\n if (var_alloc) {\n let symAb = this.outputs[i];\n outputs.push({\n space: allocation_space,\n offset: placeholderContext.resolve(var_alloc.offset),\n size: symAb.length\n });\n break;\n }\n }\n }\n worker.postMessage({ type: 'run', inputs: inputs, outputs: outputs });\n });\n return promise;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webassembly.js\n// module id = 36\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport * as localforage from \"localforage\";\nimport BufferWebGL from \"../buffer/buffer_webgl\";\nimport get_weight_decoder from \"../decoder/get_weight_decoder\";\nimport webdnnFetch, { readArrayBufferProgressively } from \"../fetch\";\nimport PlaceholderContext from \"../placeholder\";\nimport SymbolicFloat32Array from \"../symbolic_typed_array/symbolic_float32array\";\nimport { getConfiguration } from \"../webdnn\";\nimport WebGLHandler from \"../webgl_handler\";\nimport { DescriptorRunner } from \"./descriptor_runner\";\n// [x y u v] * [upper-left, lower-left, upper-right, lower-right]\n/**\n * @protected\n */\nconst vertexArray = new Float32Array([\n -1, +1,\n -1, -1,\n +1, +1,\n +1, -1,\n]);\n/**\n * @protected\n */\nexport default class DescriptorRunnerWebGL extends DescriptorRunner {\n constructor() {\n super(...arguments);\n this.backendName = 'webgl';\n }\n static checkAvailability() {\n return WebGLHandler.checkAvailability();\n }\n async init() {\n if (!DescriptorRunnerWebGL.checkAvailability())\n throw Error('WebGL backend is not supported in this browser.');\n this.handler = WebGLHandler.getInstance();\n let vertexBuffer = this.handler.createArrayBuffer(vertexArray);\n this.handler.bindArrayBuffer(vertexBuffer);\n this.buffers = new Map();\n }\n async fetchDescriptor(directory) {\n let res = await webdnnFetch(`${directory}/graph_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}.json`);\n return res.json();\n }\n async fetchParameters(directory, progressCallback) {\n let res = await webdnnFetch(`${directory}/weight_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}.bin`);\n return readArrayBufferProgressively(res, progressCallback);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedDescriptor(directory) {\n return localforage.getItem(`${directory}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_descriptor`).catch(() => null);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedParameters(directory, progressCallback) {\n let parameter = await localforage.getItem(`${directory}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_parameters`).catch(() => null);\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return parameter;\n }\n /**\n * save cache\n */\n async saveCache(directory, descriptor, parameters) {\n await Promise.all([\n localforage.setItem(`${directory}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_descriptor`, descriptor),\n localforage.setItem(`${directory}_${this.backendName}_${this.handler.MAX_TEXTURE_SIZE}_parameters`, parameters)\n ]);\n }\n ;\n async setDescriptorAndParameters(descriptor, parameters) {\n await this.setDescriptor(descriptor);\n await this.compile();\n await this.initializeStaticBuffer(parameters);\n if (this.placeholderContext && this.placeholderContext.isResolved)\n await this.initializeDynamicBuffer();\n }\n async initializeStaticBuffer(weightRawArray) {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n let descriptor = this.descriptor;\n let decoder = get_weight_decoder(this.descriptor.weight_encoding);\n let weight = await decoder.decode(new Uint8Array(weightRawArray));\n let buffers = this.buffers;\n let mapping = descriptor.memory_layout.mapping;\n Object.entries(descriptor.memory_layout.static.allocations)\n .forEach(([name, { width, height, size, channel_mode }]) => {\n buffers.set(name, new BufferWebGL(size * Float32Array.BYTES_PER_ELEMENT, width, height, name, null, channel_mode));\n });\n Object.entries(descriptor.constants_map)\n .forEach(([name, { size, byte_offset }]) => {\n buffers.get(name).array.set(new Float32Array(weight.buffer, byte_offset, size));\n });\n (await this.getInputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = buffers.get(mapping[view.name]).getWriteView(0, view.length, Float32Array).buffer;\n });\n (await this.getOutputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = buffers.get(mapping[view.name]).getReadView(0, view.length, Float32Array).buffer;\n });\n }\n async initializeDynamicBuffer() {\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n if (!this.placeholderContext)\n throw Error(\"PlaceholderContext is not initialized.\");\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n let buffers = this.buffers;\n let mapping = descriptor.memory_layout.mapping;\n Object.entries(descriptor.memory_layout.dynamic.allocations)\n .forEach(([name, { width, height, size, channel_mode }]) => {\n buffers.set(name, new BufferWebGL(placeholderContext.resolve(size) * Float32Array.BYTES_PER_ELEMENT, placeholderContext.resolve(width), placeholderContext.resolve(height), name, null, channel_mode));\n });\n (await this.getInputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = buffers.get(mapping[view.name]).getWriteView(0, placeholderContext.resolve(view.length), Float32Array).buffer;\n });\n (await this.getOutputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = buffers.get(mapping[view.name]).getReadView(0, placeholderContext.resolve(view.length), Float32Array).buffer;\n });\n this.buildPipeline();\n }\n async setDescriptor(descriptor) {\n this.descriptor = descriptor;\n //reset all datum depend on old descriptor\n this.placeholderContext = new PlaceholderContext(descriptor.placeholders);\n }\n async compile() {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n let descriptor = this.descriptor;\n this.programs = new Map();\n this.vertexShader = this.handler.createVertexShader(`\n precision highp float;\n attribute vec2 _xy;\n void main() { \n gl_Position = vec4(_xy, 0, 1); \n }\n `);\n Object.keys(descriptor.shader_sources)\n .forEach(name => {\n let fragmentShader = this.handler.createFragmentShader(descriptor.shader_sources[name]);\n let program = this.handler.createProgram(this.vertexShader, fragmentShader);\n this.programs.set(name, program);\n });\n }\n async setPlaceholderValue(values) {\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n let placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n await this.initializeDynamicBuffer();\n // resolve placeholders in execution info\n if (Object.keys(this.descriptor.placeholders).length > 0)\n throw Error('Currently, WebGL backend doesn\\'t support Placeholder feature.');\n }\n getInputViews() {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n let mapping = this.descriptor.memory_layout.mapping;\n this.inputs = descriptor.inputs.map(name => {\n let view = new SymbolicFloat32Array(null, 0, this.buffers.get(mapping[name]).length, placeholderContext);\n view.name = name;\n return view;\n });\n return this.inputs;\n }\n getOutputViews() {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n let mapping = this.descriptor.memory_layout.mapping;\n this.outputs = descriptor.outputs.map(name => {\n let view = new SymbolicFloat32Array(null, 0, this.buffers.get(mapping[name]).length, placeholderContext);\n view.name = name;\n return view;\n });\n return this.outputs;\n }\n buildPipeline() {\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(`Not all placeholders are resolved: ${this.placeholderContext}`);\n let gl = this.handler.gl;\n let buffers = this.buffers;\n let mapping = this.descriptor.memory_layout.mapping;\n let referenceCount = new Map();\n this.runtimeInfo = {\n inputs: this.getInputViews().map(view => buffers.get(mapping[view.name])),\n outputs: this.getOutputViews().map(view => buffers.get(mapping[view.name])),\n programs: this.descriptor.exec_infos.map(execInfo => {\n // inputs\n let inputs = execInfo.inputs.map(input => {\n let buffer = buffers.get(mapping[input.variable_name]);\n if (!referenceCount.has(buffer))\n referenceCount.set(buffer, 0);\n referenceCount.set(buffer, referenceCount.get(buffer) + 1);\n return {\n buffer: buffer,\n uniformIndex: input.value\n };\n });\n //output\n let output = buffers.get(mapping[execInfo.output]);\n // shader\n let program = this.programs.get(execInfo.shader_name);\n this.handler.useProgram(program);\n // uniforms\n let uniforms = Object.keys(execInfo.uniforms).map(name => {\n let { type, value } = execInfo.uniforms[name];\n switch (type) {\n case 'int':\n return {\n func: gl.uniform1i,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'float':\n return {\n func: gl.uniform1f,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec2':\n return {\n func: gl.uniform2fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec3':\n return {\n func: gl.uniform3fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'vec4':\n return {\n func: gl.uniform4fv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec2':\n return {\n func: gl.uniform2iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec3':\n return {\n func: gl.uniform3iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'ivec4':\n return {\n func: gl.uniform4iv,\n args: [gl.getUniformLocation(program, name), value]\n };\n case 'sampler2D':\n return {\n func: gl.uniform1i,\n args: [gl.getUniformLocation(program, name), value]\n };\n default:\n throw TypeError(`Incompatible type for uniform parameter: ${type}`);\n }\n });\n // attributes\n let xyAttribLoc = gl.getAttribLocation(program, '_xy');\n // run\n return {\n program: program,\n frameBuffer: this.handler.createFrameBuffer(),\n name: execInfo.shader_name,\n width: output.textureWidth,\n height: output.textureHeight,\n inputs: inputs,\n output: output,\n xyAttribLoc: xyAttribLoc,\n uniforms: uniforms,\n disposable: []\n };\n })\n };\n for (let runtimeProgramInfo of this.runtimeInfo.programs) {\n runtimeProgramInfo.inputs.forEach(({ buffer }) => {\n let count = referenceCount.get(buffer) - 1;\n if (count == 0) {\n runtimeProgramInfo.disposable.push(buffer);\n }\n referenceCount.set(buffer, count);\n });\n }\n }\n async run() {\n // if (this._running) throw new Error('Calling another run() while running.');\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(`Not all placeholders are resolved: ${this.placeholderContext}`);\n let gl = this.handler.gl;\n let runtimeInfo = this.runtimeInfo;\n if (this.runtimeInfo.programs.length > 0) {\n for (let buffer of runtimeInfo.inputs)\n await buffer.syncWriteViews();\n if (getConfiguration('DEBUG', false)) {\n let records = [];\n let totalElapsedTime = 0;\n for (let runtimeProgramInfo of runtimeInfo.programs) {\n let start = performance.now();\n this.handler.bindFrameBuffer(runtimeProgramInfo.frameBuffer, runtimeProgramInfo.width, runtimeProgramInfo.height);\n // inputs\n for (let { buffer, uniformIndex } of runtimeProgramInfo.inputs)\n await buffer.bindToReadTexture(uniformIndex);\n // output\n runtimeProgramInfo.output.bindToDrawTexture();\n // shader\n this.handler.useProgram(runtimeProgramInfo.program);\n // uniforms\n for (let uniform of runtimeProgramInfo.uniforms)\n uniform.func.apply(gl, uniform.args);\n // attribute\n gl.vertexAttribPointer(runtimeProgramInfo.xyAttribLoc, 2, gl.FLOAT, true, 8, 0);\n gl.enableVertexAttribArray(runtimeProgramInfo.xyAttribLoc);\n // run\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertexArray.length / 2);\n await this.handler.waitForComplete();\n let elapsedTime = performance.now() - start;\n totalElapsedTime += elapsedTime;\n let xs = [];\n for (let { buffer } of runtimeProgramInfo.inputs) {\n buffer.unbindFromReadTexture();\n await buffer.syncReadViews();\n xs.push(buffer.array.slice());\n }\n runtimeProgramInfo.output.unbindFromDrawTexture();\n await runtimeProgramInfo.output.syncReadViews();\n let y = runtimeProgramInfo.output.array.slice();\n records.push({\n 'Kernel': runtimeProgramInfo.name,\n 'Elapsed time [ms]': elapsedTime,\n 'xs': xs,\n 'y': y\n });\n }\n let summary = Array.from(Object.values(records.reduce((summary, record) => {\n if (!(record['Kernel'] in summary)) {\n summary[record['Kernel']] = {\n 'Kernel': record['Kernel'],\n 'Count': 0,\n 'Elapsed time [ms]': 0,\n };\n }\n summary[record['Kernel']]['Count']++;\n summary[record['Kernel']]['Elapsed time [ms]'] += record['Elapsed time [ms]'];\n return summary;\n }, {})));\n summary.forEach(record => record['Ratio [%]'] = (record['Elapsed time [ms]'] / totalElapsedTime).toFixed(2));\n console.table(records);\n console.table(summary);\n }\n else {\n for (let runtimeProgramInfo of runtimeInfo.programs) {\n this.handler.bindFrameBuffer(runtimeProgramInfo.frameBuffer, runtimeProgramInfo.width, runtimeProgramInfo.height);\n // inputs\n for (let { buffer, uniformIndex } of runtimeProgramInfo.inputs)\n await buffer.bindToReadTexture(uniformIndex);\n // output\n runtimeProgramInfo.output.bindToDrawTexture();\n // shader\n this.handler.useProgram(runtimeProgramInfo.program);\n // uniforms\n for (let uniform of runtimeProgramInfo.uniforms)\n uniform.func.apply(gl, uniform.args);\n // attribute\n gl.vertexAttribPointer(runtimeProgramInfo.xyAttribLoc, 2, gl.FLOAT, true, 8, 0);\n gl.enableVertexAttribArray(runtimeProgramInfo.xyAttribLoc);\n // run\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertexArray.length / 2);\n // release buffers and binding\n // for (let buffer of runtimeProgramInfo.disposable) buffer.releaseGPUMemory();\n for (let { buffer } of runtimeProgramInfo.inputs)\n buffer.unbindFromReadTexture();\n runtimeProgramInfo.output.unbindFromDrawTexture();\n }\n }\n for (let buffer of runtimeInfo.outputs)\n await buffer.syncReadViews();\n }\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webgl.js\n// module id = 37\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport WebGLHandler, { isWebGL2 } from \"../webgl_handler\";\nimport { Buffer } from \"./buffer\";\n/**\n * @protected\n */\nexport default class BufferWebGL extends Buffer {\n constructor(byteLength, textureWidth, textureHeight, name, array, channelMode) {\n super(byteLength, 'webgl');\n this._texture = null;\n this.readTextureUnitIndices = [];\n this.isBoundToDrawFrameBuffer = false;\n this.handler = WebGLHandler.getInstance();\n this.name = name;\n this.channelMode = channelMode;\n switch (channelMode) {\n case 'RGBA':\n this.elementsPerPixel = 4;\n break;\n case 'R':\n this.elementsPerPixel = 1;\n break;\n default:\n throw Error('Unknown channel mode');\n }\n if (isWebGL2(this.handler.gl)) {\n switch (channelMode) {\n case 'RGBA':\n this.textureFormat = this.handler.gl.RGBA;\n this.textureInternalFormat = this.handler.gl.RGBA32F;\n this.pixelStride = 4;\n break;\n case 'R':\n this.textureFormat = this.handler.gl.RED;\n this.textureInternalFormat = this.handler.gl.R32F;\n this.pixelStride = 1;\n break;\n default:\n throw Error('Unknown channel mode');\n }\n }\n else {\n // In WebGL1, always RGBA channel mode is specified. If R channel mode is specified in graph descriptor,\n // other 3 channels are not used.\n this.textureFormat = this.handler.gl.RGBA;\n this.textureInternalFormat = this.handler.gl.RGBA;\n this.pixelStride = 4;\n }\n if (this.pixelStride < this.elementsPerPixel)\n throw Error('elementsPerPixel must be smaller than pixelStride');\n this.array = array || new Float32Array(this.length);\n this.textureWidth = textureWidth;\n this.textureHeight = textureHeight;\n }\n get texture() {\n return this._texture;\n }\n get length() {\n return this.byteLength / Float32Array.BYTES_PER_ELEMENT;\n }\n /**\n * Write contents onto specified position synchronously.\n *\n * @param {ArrayBufferView} src contents source buffer\n * @param {number} offset position where contents are written on\n */\n async write(src, offset) {\n this.array.set(src, offset);\n await this.syncWriteViews();\n }\n /**\n * Read contents from specified position synchronously.\n *\n * @param {Float32ArrayConstructor | Int32ArrayConstructor} dst buffer where contents are written on\n * @param {number} offset position where contents are read from\n * @param {length} length contents length\n */\n async read(dst, offset = 0, length) {\n if (dst !== Float32Array)\n throw new Error('Currently, only Float32Array is supported for parameter \\'dst\\'.');\n await this.syncReadViews();\n new Float32Array(this.array.buffer, offset * Float32Array.BYTES_PER_ELEMENT, length);\n }\n getWriteView(offset, length, type) {\n return new type(this.array.buffer, offset * type.BYTES_PER_ELEMENT, length);\n }\n ;\n getReadView(offset, length, type) {\n return new type(this.array.buffer, offset * type.BYTES_PER_ELEMENT, length);\n }\n /**\n * Sync buffered data into memory.\n *\n * @see Buffer#getWriteView\n */\n async syncWriteViews() {\n let gl = this.handler.gl;\n if (!this.texture)\n this.allocateTexture();\n let tmp = this.pack(this.array);\n if (tmp.length != this.textureWidth * this.textureHeight * this.pixelStride) {\n let tmp2 = new Float32Array(this.textureWidth * this.textureHeight * this.elementsPerPixel);\n tmp2.set(tmp, 0);\n tmp = tmp2;\n }\n await this.bindToReadTexture(9); //TODO: texture unit 9 is always available?\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.textureWidth, this.textureHeight, this.textureFormat, gl.FLOAT, tmp);\n this.unbindFromReadTexture();\n }\n /**\n * Sync memory data into buffer view.\n *\n * @see Buffer#getReadView\n */\n async syncReadViews() {\n let gl = this.handler.gl;\n // FIXME(Kiikurage): more readable code\n const ELEMENT_PER_PIXEL = 4;\n const FORMAT = gl.RGBA;\n let tmp = new Float32Array(this.textureWidth * this.textureHeight * ELEMENT_PER_PIXEL);\n this.bindToDrawTexture();\n gl.readPixels(0, 0, this.textureWidth, this.textureHeight, FORMAT, gl.FLOAT, tmp);\n this.unbindFromDrawTexture();\n tmp = this.unpack(tmp);\n this.array.set(tmp.slice(0, this.length), 0);\n }\n async bindToReadTexture(unit) {\n if (this.isBoundToDrawFrameBuffer)\n throw Error('This buffer is already registered as draw buffer. ' +\n 'You may forgot to unbind the binding while previous operations.');\n let gl = this.handler.gl;\n if (!this.texture) {\n this.allocateTexture();\n await this.syncWriteViews();\n }\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n this.readTextureUnitIndices.push(unit);\n }\n unbindFromReadTexture() {\n let gl = this.handler.gl;\n for (let unit of this.readTextureUnitIndices) {\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n this.readTextureUnitIndices = [];\n }\n bindToDrawTexture() {\n if (this.readTextureUnitIndices.length > 0)\n throw Error('This buffer is already registered as read buffer. ' +\n 'You cannot bind a texture as both read and draw texture buffer at same time.');\n if (this.isBoundToDrawFrameBuffer)\n throw Error('This buffer is already registered as draw buffer. ' +\n 'You may forgot to unbind the binding while previous operations.');\n let gl = this.handler.gl;\n if (!this.texture)\n this.allocateTexture();\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0);\n this.isBoundToDrawFrameBuffer = true;\n }\n unbindFromDrawTexture() {\n if (!this.isBoundToDrawFrameBuffer)\n return;\n let gl = this.handler.gl;\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);\n this.isBoundToDrawFrameBuffer = false;\n }\n pack(array) {\n let elementStride = this.pixelStride / this.elementsPerPixel;\n if (elementStride === 1) {\n return new Float32Array(array);\n }\n else {\n let result = new Float32Array(array.length * elementStride);\n for (let i = 0; i < array.length; i++)\n result[i * elementStride] = array[i];\n return result;\n }\n }\n unpack(array) {\n // FIXME(Kiikurage): more readable code\n const PIXEL_STRIDE = 4;\n let elementStride = PIXEL_STRIDE / this.elementsPerPixel;\n if (elementStride === 1) {\n return new Float32Array(array);\n }\n else {\n let result = new Float32Array(array.length / elementStride);\n for (let i = 0; i < array.length / elementStride; i++)\n result[i] = array[i * elementStride];\n return result;\n }\n }\n allocateTexture() {\n if (this.texture)\n throw Error('Texture is already allocated.');\n this._texture = this.handler.createTexture(this.textureWidth, this.textureHeight, this.textureInternalFormat, this.textureFormat);\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/buffer/buffer_webgl.js\n// module id = 38\n// module chunks = 0","/**\n * @module webdnn\n */\n/** Don't Remove This comment block */\nimport * as localforage from \"localforage\";\nimport BufferWebGPU from \"../buffer/buffer_webgpu\";\nimport getWeightDecoder from \"../decoder/get_weight_decoder\";\nimport webdnnFetch, { readArrayBufferProgressively } from \"../fetch\";\nimport PlaceholderContext from \"../placeholder\";\nimport SymbolicFloat32Array from \"../symbolic_typed_array/symbolic_float32array\";\nimport { getConfiguration } from \"../webdnn\";\nimport WebGPUHandler, { IS_WEBGPU_SUPPORTED } from \"../webgpu_handler\";\nimport { DescriptorRunner } from \"./descriptor_runner\";\n/**\n * Check this device is iOS devices or not.\n * @private\n */\nconst IS_IOS = navigator.userAgent.includes('iPhone') || navigator.userAgent.includes('iPad');\n/**\n * DescriptorRunner for WebGPU\n * @protected\n */\nexport default class DescriptorRunnerWebGPU extends DescriptorRunner {\n constructor() {\n super(...arguments);\n /**\n * backend name\n */\n this.backendName = 'webgpu';\n }\n /**\n * Return `true` if this backend is available in this environment.\n * @returns {boolean}\n */\n static checkAvailability() {\n return IS_WEBGPU_SUPPORTED;\n }\n /**\n * Initialize descriptor runner asynchronously\n * @returns {Promise} Promise object which is resolved when the initialization finished.\n */\n async init() {\n this.webgpuHandler = WebGPUHandler.getInstance();\n await this.checkIncompatibleGPU();\n }\n /**\n * Check whether current GPU is supported or not. If it's not supported, an error is thrown.\n * @returns {Promise}\n */\n async checkIncompatibleGPU() {\n /**\n * It is reported that AMD GPU crashes when performing sgemm (matrix multiplication).\n * Until this problem is solved, blocking WebGPU backend in the environment is needed.\n * API in WebGPU does not directly gives hardware information, so trying to determine hardware heuristically.\n *\n * Criteria: thread_execution_width == 32 is required\n * (on AMD FirePro D500, thread_execution_width == 64)\n *\n * @see https://github.com/mil-tokyo/webdnn/issues/286\n */\n this.webgpuHandler.loadKernel(`\n#include \nusing namespace metal;\n kernel void check_compatibility(\n device uint *A[[buffer(0)]],\n uint global_index[[thread_position_in_grid]],\n uint thread_execution_width[[thread_execution_width]]\n ){\n if (global_index == 0) {\n A[0] = thread_execution_width;\n }\n }`, 'basic');\n let buffer = this.webgpuHandler.createBuffer(new Uint32Array(1));\n await this.webgpuHandler.executeSinglePipelineState('basic.check_compatibility', { width: 1, height: 1, depth: 1 }, { width: 1, height: 1, depth: 1 }, [buffer], true);\n let threadExecutionWidth = (new Uint32Array(buffer.contents))[0];\n if (threadExecutionWidth != 32) {\n throw new Error(`Sorry, this GPU does not compatible with WebGPU (thread_execution_width == ${threadExecutionWidth}. See checkIncompatibleGPU method of https://github.com/mil-tokyo/webdnn/blob/master/src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.ts`);\n }\n }\n /**\n * Fetch graph descriptor from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @protected\n */\n async fetchDescriptor(directory) {\n let res = await webdnnFetch(`${directory}/graph_${this.backendName}.json`);\n return res.json();\n }\n /**\n * Fetch parameter files from specified directory.\n *\n * @param directory directory where descriptor is contained.\n * You can also provide URL of other domain like this.\n *\n * ```javascript\n * await runner.load('://my.other.domain.com/my_model');\n * ```\n *\n * However sometimes it can't because of Cross-Origin-Resource-Security policy.\n *\n * @param progressCallback callback which is called to notice the loading is progressing.\n * @protected\n */\n async fetchParameters(directory, progressCallback) {\n let res = await webdnnFetch(`${directory}/weight_${this.backendName}.bin`);\n return readArrayBufferProgressively(res, progressCallback);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedDescriptor(directory) {\n return localforage.getItem(`${directory}_${this.backendName}_descriptor`).catch(() => null);\n }\n /**\n * Load cached descriptor from WebStorage\n * @protected\n */\n async restoreCachedParameters(directory, progressCallback) {\n let parameter = await localforage.getItem(`${directory}_${this.backendName}_parameters`).catch(() => null);\n if (parameter && progressCallback)\n progressCallback(parameter.byteLength, parameter.byteLength);\n return parameter;\n }\n /**\n * save cache\n */\n async saveCache(directory, descriptor, parameters) {\n await Promise.all([\n localforage.setItem(`${directory}_${this.backendName}_descriptor`, descriptor),\n localforage.setItem(`${directory}_${this.backendName}_parameters`, parameters)\n ]);\n }\n ;\n async setDescriptorAndParameters(descriptor, parameter) {\n this.descriptor = descriptor;\n //reset all datum depend on old descriptor\n this.staticBuffer = null;\n this.dynamicBuffer = null;\n this.metaBuffers = null;\n this.placeholderContext = new PlaceholderContext(descriptor.placeholders);\n this.executionInfos = descriptor.exec_infos;\n //compile kernels\n this.webgpuHandler.loadKernel(this.descriptor.kernel_source, 'descriptor');\n await this.initializeStaticBuffer(parameter);\n await this.initializeMetaBuffers();\n await this.setPlaceholderValue({\n '__MAX_THREADS_PER_THREADGROUP__': IS_IOS ? 512 : 1024\n });\n if (this.placeholderContext && this.placeholderContext.isResolved)\n await this.initializeDynamicBuffer();\n }\n /**\n * Initialize static buffers, whose size and position can be determined in compile time.\n *\n * @param {ArrayBuffer} weightRawArray constant weight buffer\n * @returns {Promise}\n */\n async initializeStaticBuffer(weightRawArray) {\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n let descriptor = this.descriptor;\n let staticBuffer = new BufferWebGPU(descriptor.memory_layout.static.size * Float32Array.BYTES_PER_ELEMENT);\n this.staticBuffer = staticBuffer;\n let decoder = getWeightDecoder(descriptor.weight_encoding);\n await staticBuffer.write(await decoder.decode(new Uint8Array(weightRawArray)));\n (await this.getInputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = staticBuffer.bufferView.buffer;\n });\n (await this.getOutputViews())\n .filter(view => !view.isDynamic)\n .forEach(view => {\n view.buffer = staticBuffer.bufferView.buffer;\n });\n }\n /**\n * Initialize meta buffers, which contains metadata shared in each GPU kernel thread (ex. hyper parameters).\n * @returns {Promise}\n */\n async initializeMetaBuffers() {\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n this.metaBuffers = await Promise.all(this.descriptor.exec_infos.map(async (executionInfo) => {\n let buffer = new BufferWebGPU(executionInfo.meta_buffer.length * Int32Array.BYTES_PER_ELEMENT);\n await buffer.write(new Uint8Array(executionInfo.meta_buffer));\n return buffer;\n }));\n }\n /**\n * Initialize dynamic buffers, whose size and position cannot be determined without runtime-information such as input image size\n * (if it's dynamic).\n * When all placeholder is resolved, this method is automatically called.\n *\n * @returns {Promise}\n */\n async initializeDynamicBuffer() {\n if (!this.descriptor)\n throw Error(\"GraphDescriptor is not loaded.\");\n if (!this.placeholderContext)\n throw Error(\"PlaceholderContext is not initialized.\");\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n let dynamicBufferSize = placeholderContext.resolve(descriptor.memory_layout.dynamic.size);\n let dynamicBuffer = new BufferWebGPU(dynamicBufferSize * Float32Array.BYTES_PER_ELEMENT);\n this.dynamicBuffer = dynamicBuffer;\n (await this.getInputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = dynamicBuffer.bufferView.buffer;\n });\n (await this.getOutputViews())\n .filter(view => view.isDynamic)\n .forEach(view => {\n view.buffer = dynamicBuffer.bufferView.buffer;\n });\n }\n /**\n * Set actual value into placeholder. If all placeholder is resolved,\n * [[DescriptorRunnerWebGPU#initializeDynamicBuffer|`initializeDynamicBuffer()`]] is automatically called.\n *\n * @param values mapping object of placeholder name and value\n * @returns {Promise}\n */\n async setPlaceholderValue(values) {\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized.');\n let placeholderContext = this.placeholderContext;\n placeholderContext.update(values);\n if (!placeholderContext.isResolved)\n return;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.metaBuffers)\n throw new Error('MetaBuffers are not initialized');\n let descriptor = this.descriptor;\n let metaBuffers = this.metaBuffers;\n await this.initializeDynamicBuffer();\n // resolve placeholders in execution info\n this.executionInfos = await Promise.all(descriptor.exec_infos.map(async (executionInfo, i) => {\n // resolve placeholders in meta buffer\n let bufferView = new Int32Array(metaBuffers[i].bufferView.buffer);\n for (let unresolved_value of executionInfo.unresolved_value_list) {\n bufferView[unresolved_value.offset] = placeholderContext.resolve(unresolved_value.placeholder);\n }\n return placeholderContext.resolve(executionInfo);\n }));\n }\n /**\n * Get input [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]] object\n *\n * @returns array of input [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]]\n * @deprecated Use [[webdnn.DescriptorRunner.inputs|`inputs`]] instead\n */\n getInputViews() {\n if (this.inputs)\n return this.inputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.inputs = descriptor.inputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, allocation.offset * SymbolicFloat32Array.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.inputs;\n }\n /**\n * Get output [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]] object\n *\n * @returns array of output [[webdnn.SymbolicFloat32Array|`SymbolicFloat32Array`]]\n * @deprecated Use [[webdnn.DescriptorRunner.outputs|`outputs`]] instead\n */\n getOutputViews() {\n if (this.outputs)\n return this.outputs;\n if (!this.descriptor)\n throw new Error('Descriptor is not loaded');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n let descriptor = this.descriptor;\n let placeholderContext = this.placeholderContext;\n this.outputs = descriptor.outputs.map(name => {\n let allocation = descriptor.memory_layout.static.allocations[name] || descriptor.memory_layout.dynamic.allocations[name];\n let view = new SymbolicFloat32Array(null, allocation.offset * SymbolicFloat32Array.BYTES_PER_ELEMENT, allocation.size, placeholderContext);\n return view;\n });\n return this.outputs;\n }\n /**\n * Run descriptor. You must call [[webdnn.DescriptorRunner.getInputViews|`getInputViews`]] and\n * [[webdnn.DescriptorRunner.getOutputViews|`getOutputViews`]] before calling this function.\n */\n async run() {\n if (!this.executionInfos)\n throw new Error('ExecutionInfos is not loaded');\n if (!this.staticBuffer)\n throw new Error('StaticBuffer is not initialized');\n if (!this.dynamicBuffer)\n throw new Error('DynamicBuffer is not initialized');\n if (!this.metaBuffers)\n throw new Error('MetaBuffer is not initialized');\n if (!this.placeholderContext)\n throw new Error('PlaceholderContext is not initialized');\n if (!this.placeholderContext.isResolved)\n throw new Error(`Not all placeholders are resolved: ${this.placeholderContext}`);\n let staticBuffer = this.staticBuffer;\n let dynamicBuffer = this.dynamicBuffer;\n let metaBuffers = this.metaBuffers;\n if (getConfiguration('DEBUG', false)) {\n let records = [];\n let totalElapsedTime = 0;\n for (let i = 0; i < this.executionInfos.length; i++) {\n let exec_info = this.executionInfos[i];\n let start = performance.now();\n await this.webgpuHandler.executeSinglePipelineState('descriptor.' + exec_info.entry_func_name, exec_info.threadgroups_per_grid, exec_info.threads_per_thread_group, [staticBuffer, dynamicBuffer, metaBuffers[i]], true);\n let elapsedTime = performance.now() - start;\n records.push({\n 'Kernel': exec_info.entry_func_name,\n 'Elapsed time [ms]': elapsedTime\n });\n totalElapsedTime += elapsedTime;\n }\n let summary = Array.from(Object.values(records.reduce((summary, record) => {\n if (!(record['Kernel'] in summary)) {\n summary[record['Kernel']] = {\n 'Kernel': record['Kernel'],\n 'Count': 0,\n 'Elapsed time [ms]': 0,\n };\n }\n summary[record['Kernel']]['Count']++;\n summary[record['Kernel']]['Elapsed time [ms]'] += record['Elapsed time [ms]'];\n return summary;\n }, {})));\n summary.forEach(record => record['Ratio [%]'] = (record['Elapsed time [ms]'] / totalElapsedTime).toFixed(2));\n console.table(records);\n console.table(summary);\n }\n else {\n let complete_promise = null;\n for (let i = 0; i < this.executionInfos.length; i++) {\n let exec_info = this.executionInfos[i];\n let is_last = i == this.executionInfos.length - 1;\n complete_promise = this.webgpuHandler.executeSinglePipelineState('descriptor.' + exec_info.entry_func_name, exec_info.threadgroups_per_grid, exec_info.threads_per_thread_group, [staticBuffer, dynamicBuffer, metaBuffers[i]], is_last);\n }\n return complete_promise; //wait to finish final kernel\n }\n // this._running = false;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/descriptor_runner/descriptor_runner_webgpu.js\n// module id = 39\n// module chunks = 0","/**\n * @module webdnn/image\n * @preferred\n *\n * Module `WebDNN.Image` provides basic image processing operations like follows.\n *\n * - Load image by various way (File picker dialog, url string, canvas, video, etc.)\n * - Pack image data into TypedArray\n * - Crop and resize.\n * - Show result on canvas element\n *\n */\n/** Don't Remove This comment block */\n// export * from \"./image/canvas\" // internal API\nexport * from \"./image/enums\";\nexport * from \"./image/image_array\";\n// export * from \"./image/image_data\" // internal API\nexport * from \"./image/image_source\";\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image.js\n// module id = 40\n// module chunks = 0","/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\nimport { getContext2D } from \"./canvas\";\nimport { Color, Order } from \"./enums\";\nimport { getImageData, setImageDataToCanvas } from \"./image_data\";\nimport { loadImageByUrl, loadImageFromFileInput } from \"./image_source\";\n/**\n * @protected\n */\nfunction flatten(arr) {\n return (arr instanceof Array) ? Array.prototype.concat.apply([], arr.map(arr => flatten(arr))) : arr;\n}\n/**\n * @protected\n */\nfunction normalizeBiasTuple(arr) {\n if (typeof (arr) == \"number\") {\n return [arr, arr, arr, arr];\n }\n else {\n if (arr.length == 4) {\n return [arr[0], arr[1], arr[2], arr[3]];\n }\n else if (arr.length == 3) {\n return [arr[0], arr[1], arr[2], arr[0]];\n }\n else if (arr.length == 1) {\n return [arr[0], arr[0], arr[0], arr[0]];\n }\n else {\n throw new Error('bias and scale must be scalar number or array of length 1 or 3 or 4.');\n }\n }\n}\n/**\n * Get image array as `{Float32 or Int32}ArrayBufferView` from ImageData object.\n *\n * @returns {ArrayBufferView} buffer with specified type\n * @protected\n */\nexport function getImageArrayFromImageData(imageData, options = {}) {\n let { type = Float32Array, color = Color.RGB, order = Order.HWC, bias = [0, 0, 0], scale = [1, 1, 1] } = options;\n const bias_n = normalizeBiasTuple(bias);\n const scale_n = normalizeBiasTuple(scale);\n const width = imageData.width;\n const height = imageData.height;\n let data = imageData.data;\n let array;\n let biasR, biasG, biasB, biasA;\n let scaleR, scaleG, scaleB, scaleA;\n switch (color) {\n case Color.RGB:\n array = new type(width * height * 3);\n [scaleR, scaleG, scaleB] = scale_n;\n [biasR, biasG, biasB] = bias_n;\n switch (order) {\n case Order.HWC:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(h * width + w) * 3 + 0] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 3 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 3 + 2] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n }\n }\n break;\n case Order.CHW:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n }\n }\n break;\n }\n break;\n case Color.BGR:\n array = new type(width * height * 3);\n [biasR, biasG, biasB] = bias_n;\n [scaleR, scaleG, scaleB] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(h * width + w) * 3 + 0] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 3 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 3 + 2] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n }\n }\n break;\n case Order.CHW:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n }\n }\n break;\n }\n break;\n case Color.RGBA:\n array = new type(width * height * 4);\n [scaleR, scaleG, scaleB, scaleA] = scale_n;\n [biasR, biasG, biasB, biasA] = bias_n;\n switch (order) {\n case Order.HWC:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(h * width + w) * 4 + 0] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 4 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 4 + 2] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 4 + 3] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n case Order.CHW:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(3 * height + h) * width + w] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n }\n break;\n case Color.BGRA:\n array = new type(width * height * 4);\n [biasR, biasG, biasB, biasA] = bias_n;\n [scaleR, scaleG, scaleB, scaleA] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(h * width + w) * 4 + 0] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(h * width + w) * 4 + 1] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(h * width + w) * 4 + 2] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(h * width + w) * 4 + 3] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n case Order.CHW:\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n array[(0 * height + h) * width + w] = (data[(h * width + w) * 4 + 2] - biasB) / scaleB;\n array[(1 * height + h) * width + w] = (data[(h * width + w) * 4 + 1] - biasG) / scaleG;\n array[(2 * height + h) * width + w] = (data[(h * width + w) * 4 + 0] - biasR) / scaleR;\n array[(3 * height + h) * width + w] = (data[(h * width + w) * 4 + 3] - biasA) / scaleA;\n }\n }\n break;\n }\n break;\n case Color.GREY:\n array = new type(width * height);\n [scaleR, scaleG, scaleB] = scale_n;\n [biasR, biasG, biasB] = bias_n;\n for (let h = 0; h < height; h++) {\n for (let w = 0; w < width; w++) {\n let r = data[(h * width + w) * 4 + 0];\n let g = data[(h * width + w) * 4 + 1];\n let b = data[(h * width + w) * 4 + 2];\n array[h * width + w] = 0.2126 * (r - biasR) / scaleR + 0.7162 * (g - biasG) / scaleG + 0.0722 * (b - biasB) / scaleB;\n }\n }\n break;\n default:\n throw Error(`Unknown color format: ${color}`);\n }\n return array;\n}\n/**\n * Get image array from canvas element as `{Float32 or Int32}ArrayBufferView`.\n *\n * @returns {ImageData} buffer with specified type\n * @protected\n */\nexport function getImageArrayFromCanvas(canvas, options = {}) {\n let { type = Float32Array, color = Color.RGB, order = Order.HWC, srcX = 0, srcY = 0, srcW = canvas.width, srcH = canvas.height, dstX = 0, dstY = 0, bias = [0, 0, 0], scale = [1, 1, 1] } = options;\n let { dstW = srcW, dstH = srcH } = options;\n let imageData = getImageData(canvas, { srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH });\n return getImageArrayFromImageData(imageData, { type, color, order, bias, scale });\n}\n/**\n * Get image array from image element as `{Float32 or Int32}ArrayBufferView`.\n *\n * @returns {ImageData} buffer with specified type\n * @protected\n */\nexport function getImageArrayFromDrawable(drawable, options = {}) {\n let srcW, srcH;\n if (drawable instanceof HTMLVideoElement) {\n srcW = drawable.videoWidth;\n srcH = drawable.videoHeight;\n }\n else if (drawable instanceof HTMLImageElement) {\n srcW = drawable.naturalWidth;\n srcH = drawable.naturalHeight;\n }\n else if (drawable instanceof HTMLCanvasElement) {\n return getImageArrayFromCanvas(drawable, options);\n }\n else if (drawable instanceof ImageData) {\n return getImageArrayFromImageData(drawable, options);\n }\n else\n throw TypeError('Failed to execute \"getImageDataFromDrawable(drawable, options)\": \"drawable\" must be an instanceof Drawable');\n let { type = Float32Array, color = Color.RGB, order = Order.HWC, srcX = 0, srcY = 0, dstX = 0, dstY = 0, dstW = srcW, dstH = srcH, bias = [0, 0, 0], scale = [1, 1, 1] } = options;\n let canvas = document.createElement('canvas');\n canvas.width = dstX + dstW;\n canvas.height = dstY + dstH;\n let context = getContext2D(canvas);\n context.drawImage(drawable, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);\n return getImageArrayFromCanvas(canvas, { type, color, order, bias, scale });\n}\n/**\n * Create typed array by packing image data from image source with specified options.\n *\n * First, this method loads specified image resource. The behavior of this method depends on the `image` argument.\n *\n * - If `image` is an instance of `string`, it will be regarded as image url, and this method fetches that url.\n *\n * - If `image` is an instance of `HTMLInputElement`, it will be regarded as file input,\n * and this method loads the selected image file.\n *\n * - Otherwise, `image` will be regarded as drawable object.\n *\n * Then, loaded images are packed into typed array based on `options` argument.\n *\n * - The image is cropped based on [[SourceRect|`{srcX, srcY, srcW, srcH}`]].\n * As default, entire image is used.\n *\n * - The image is resized and translated into [[DestinationRect|`{dstX, dstY, dstW, dstH}`]].\n * As default, no resize and translation is performed.\n *\n * - [[ImageArrayOption.type|`options.type`]] is the type of packed typed array. As default, Float32Array is used.\n *\n * - [[ImageArrayOption.type|`options.color`]] is the color format of packed typed array. As default, [[Color.RGB|`RGB`]] is used.\n *\n * - [[ImageArrayOption.type|`options.order`]] is the data order of packed typed array. As default, [[Order.HWC|`HWC`]] is used.\n *\n * - [[ImageArrayOption.bias|`options.bias`]] is the bias value.\n * If specified, this method **subtracts** this value from original pixel value.\n *\n * - [[ImageArrayOption.scale|`options.scale`]] is the scale value. If specified, original pixel values are **divided** by this value.\n * [[ImageArrayOption.scale|`options.scale`]] and [[ImageArrayOption.bias|`options.bias`]] is used for converting pixel value `x` and\n * packed value `y` as follows:\n *\n * - `y = (x - bias) / scale`\n * - `x = y * scale + bias`\n * - Note that color order is always RGB, not BGR.\n *\n * ### Examples\n *\n * - Load image of specified url\n *\n * ```ts\n * let image = await WebDNN.Image.load('./cat.png');\n * ```\n *\n * - Load image selected in file input and resize it into 224 x 224\n *\n * ```ts\n * let input = document.querySelector('input[type=file]');\n * let image = await WebDNN.Image.load(input, { dstW: 224, dstH: 224 });\n * ```\n *\n * - Load image data from canvas, normalize it into range `[-1, 1)`. In this case, normalized value `y` can be\n * calculated from pixel value `x` as follows: `y = (x - 128) / 128`.\n *\n * ```ts\n * let canvas = document.getElementsByTagName('canvas')[0];\n * let image = await WebDNN.Image.load(canvas, { bias: [128, 128, 128], scale: [128, 128, 128] });\n * ```\n *\n * @param image please see above descriptions\n * @param options please see above descriptions.\n * @returns Created typed array\n */\nexport async function getImageArray(image, options = {}) {\n if (typeof image === 'string') {\n return getImageArrayFromDrawable(await loadImageByUrl(image), options);\n }\n else if (image instanceof HTMLInputElement) {\n return getImageArrayFromDrawable(await loadImageFromFileInput(image), options);\n }\n else if (image instanceof HTMLCanvasElement) {\n return getImageArrayFromCanvas(image, options);\n }\n else if (image instanceof HTMLImageElement || image instanceof HTMLVideoElement || image instanceof ImageData) {\n return getImageArrayFromDrawable(image, options);\n // FIXME: This feature is not supported for all web browsers.\n // } else if (image === null) {\n // return getImageArrayFromDrawable(await loadImageByDialog(), options);\n }\n else\n throw TypeError('Failed to execute \"getImageData(image, options)\": \"image\" must be an instance of string,' +\n ' HTMLInputElement, HTMLCanvasElement, HTMLImageElement, HTMLVideoElement, or ImageData object');\n}\n/**\n * Set image array data into canvas.\n *\n * ### Examples\n *\n * - Show DNN model's result\n *\n * ```ts\n * let runner = await WebDNN.load('./model');\n * let output = runner.outputs[0];\n *\n * await runner.run();\n *\n * WebDNN.Image.setImageArrayToCanvas(output.toActual(), 256, 256, document.getElementById('canvas'))\n * ```\n *\n * - Generally image generation model's result contains noise pixel at their edge because of convolution's padding.\n * In follow example, these noise are cut off.\n *\n * ```ts\n * WebDNN.Image.setImageArrayToCanvas(output, 256, 256, canvas, {\n * srcX: 16, srcY: 16, srcH: 256-16*2, srcW: 256-16*2, // Discard both ends 16px\n * dstW: 256, dstH: 256 // Resize cropped image into original output size.\n * });\n * ```\n *\n * @param array array which contains image data\n * @param imageW width of image\n * @param imageH height of image. The length of `array` must be `imageW * imageH * (# of channels)`\n * @param canvas destination canvas\n * @param options please see above descriptions and descriptions in [[webdnn/image.getImageArray|getImageArray()]].\n * `srcW` and `srcH` is ignored (overwritten by `imageW` and `imageH`).\n */\nexport function setImageArrayToCanvas(array, imageW, imageH, canvas, options = {}) {\n let { color = Color.RGB, order = Order.HWC, srcX = 0, srcY = 0, dstX = 0, dstY = 0, dstW = canvas.width, dstH = canvas.height, bias = [0, 0, 0], scale = [1, 1, 1] } = options;\n const bias_n = normalizeBiasTuple(bias);\n const scale_n = normalizeBiasTuple(scale);\n let srcW = imageW, srcH = imageH;\n array = flatten(array);\n let data = new Uint8ClampedArray(srcW * srcH * 4);\n let biasR, biasG, biasB, biasA;\n let scaleR, scaleG, scaleB, scaleA;\n switch (color) {\n case Color.RGB:\n [biasR, biasG, biasB] = bias_n;\n [scaleR, scaleG, scaleB] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 0] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 2] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n case Order.CHW:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(0 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(2 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n break;\n case Color.BGR:\n [biasR, biasG, biasB] = bias_n;\n [scaleR, scaleG, scaleB] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 2] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 0] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n case Order.CHW:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(2 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(0 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n break;\n case Color.RGBA:\n [biasR, biasG, biasB, biasA] = bias_n;\n [scaleR, scaleG, scaleB, scaleA] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 3 + 0] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 3 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 3 + 2] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(h * imageW + w) * 3 + 3] * scaleA + biasA;\n }\n }\n break;\n case Order.CHW:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(0 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(2 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(3 * imageH + h) * imageW + w] * scaleA + biasA;\n }\n }\n break;\n }\n break;\n case Color.BGRA:\n [biasR, biasG, biasB, biasA] = bias_n;\n [scaleR, scaleG, scaleB, scaleA] = scale_n;\n switch (order) {\n case Order.HWC:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(h * imageW + w) * 4 + 2] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(h * imageW + w) * 4 + 1] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(h * imageW + w) * 4 + 0] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(h * imageW + w) * 4 + 3] * scaleA + biasA;\n }\n }\n break;\n case Order.CHW:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] = array[(2 * imageH + h) * imageW + w] * scaleR + biasR;\n data[(h * imageW + w) * 4 + 1] = array[(1 * imageH + h) * imageW + w] * scaleG + biasG;\n data[(h * imageW + w) * 4 + 2] = array[(0 * imageH + h) * imageW + w] * scaleB + biasB;\n data[(h * imageW + w) * 4 + 3] = array[(3 * imageH + h) * imageW + w] * scaleA + biasA;\n }\n }\n break;\n }\n break;\n case Color.GREY:\n for (let h = srcY; h < srcY + srcH; h++) {\n for (let w = srcX; w < srcX + srcW; w++) {\n data[(h * imageW + w) * 4 + 0] =\n data[(h * imageW + w) * 4 + 1] =\n data[(h * imageW + w) * 4 + 2] = array[h * imageW + w] * scale[0] + bias[0];\n data[(h * imageW + w) * 4 + 3] = 255;\n }\n }\n break;\n }\n setImageDataToCanvas(new ImageData(data, srcW, srcH), canvas, { srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH });\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_array.js\n// module id = 41\n// module chunks = 0","/**\n * @module webdnn/image\n */\n/** Don't Remove This comment block */\nimport { getContext2D } from \"./canvas\";\n/**\n * @protected\n */\nexport function getImageDataFromCanvas(canvas, options = {}) {\n let { srcX = 0, srcY = 0, srcW = canvas.width, srcH = canvas.height, dstX = 0, dstY = 0 } = options;\n let { dstW = srcW, dstH = srcH } = options;\n let imageData = getContext2D(canvas).getImageData(srcX, srcY, srcW, srcH);\n if (dstX !== 0 || dstY !== 0 || srcW !== dstW || srcH !== dstH) {\n imageData = cropAndResizeImageData(imageData, { dstX, dstY, dstW, dstH });\n }\n return imageData;\n}\n/**\n * @protected\n */\nexport function getImageDataFromDrawable(drawable, options = {}) {\n let srcW, srcH;\n if (drawable instanceof HTMLVideoElement) {\n srcW = drawable.videoWidth;\n srcH = drawable.videoHeight;\n }\n else if (drawable instanceof HTMLImageElement) {\n srcW = drawable.naturalWidth;\n srcH = drawable.naturalHeight;\n }\n else\n throw TypeError('Failed to execute \"getImageDataFromDrawable(drawable, options)\": \"drawable\" must be an instanceof HTMLVideoElement or HTMLImageElement');\n let { srcX = 0, srcY = 0, dstX = 0, dstY = 0, dstW = srcW, dstH = srcH } = options;\n let canvas = document.createElement('canvas');\n canvas.width = dstX + dstW;\n canvas.height = dstY + dstH;\n let context = getContext2D(canvas);\n context.drawImage(drawable, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);\n return context.getImageData(0, 0, dstX + dstW, dstY + dstH);\n}\n/**\n * Source rectangle of source image is cropped and then copied into destination rectangle of new image data\n *\n * @param {ImageData} src\n * @param {SourceRect & DestinationRect} options\n * @returns {ImageData}\n * @protected\n */\nfunction cropAndResizeImageData(src, options = {}) {\n let { srcX = 0, srcY = 0, srcW = src.width, srcH = src.height, dstX = 0, dstY = 0 } = options;\n let { dstW = srcW, dstH = srcH } = options;\n let canvas1 = document.createElement('canvas');\n canvas1.width = srcW;\n canvas1.height = srcH;\n let context1 = getContext2D(canvas1);\n context1.putImageData(src, -srcX, -srcY);\n let canvas2 = document.createElement('canvas');\n canvas2.width = dstX + dstW;\n canvas2.height = dstY + dstH;\n let context2 = getContext2D(canvas2);\n context2.drawImage(canvas1, 0, 0, srcW, srcH, dstX, dstY, dstW, dstH);\n return context2.getImageData(0, 0, dstX + dstW, dstY + dstH);\n}\n/**\n * Return canvas `ImageData` object with specified scale.\n *\n * @param {HTMLCanvasElement | HTMLVideoElement | HTMLImageElement} image\n * @param [options] Options\n * @param {number} [options.srcX=0] left position of input clipping rect\n * @param {number} [options.srcY=0] top position of input clipping rect\n * @param {number} [options.srcW=canvas.width] width of input clipping rect\n * @param {number} [options.srcH=canvas.height] height of input clipping rect\n * @param {number} [options.dstW=options.srcW] width of output\n * @param {number} [options.dstH=options.srcH] height of output\n * @returns {ImageData}\n * @protected\n */\nexport function getImageData(image, options = {}) {\n if (image instanceof HTMLCanvasElement) {\n return getImageDataFromCanvas(image, options);\n }\n else if (image instanceof HTMLVideoElement || image instanceof HTMLImageElement) {\n return getImageDataFromDrawable(image, options);\n }\n else\n throw TypeError('Failed to execute \"getImageData(image, options)\": \"image\" must be an instance of HTMLCanvasElement, HTMLVideoElement, or HTMLImageElement');\n}\n/**\n * @protected\n */\nexport function setImageDataToCanvas(imageData, canvas, options = {}) {\n let { srcX = 0, srcY = 0, srcW = imageData.width, srcH = imageData.height, dstX = 0, dstY = 0 } = options;\n let { dstW = srcW, dstH = srcH } = options;\n if (srcX !== 0 || srcY !== 0 || srcW !== dstW || srcH !== dstH) {\n imageData = cropAndResizeImageData(imageData, { srcX, srcY, srcW, srcH, dstW, dstH });\n }\n getContext2D(canvas).putImageData(imageData, dstX, dstY);\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/image/image_data.js\n// module id = 42\n// module chunks = 0","/**\n * @module webdnn/math\n * @preferred\n *\n * Module `WebDNN.Math` provides basic mathematics operations for pre/post-processing.\n */\n/** Don't Remove This comment block */\nexport * from \"./math/argsort\";\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/math.js\n// module id = 43\n// module chunks = 0","/**\n * @module webdnn/math\n */\n/** Don't Remove This comment block */\n/**\n * Return indices of the top-K largest elements.\n * This implementation is not stable sort.\n *\n * @param {number[]|Float32Array} arr array\n * @param {number} k number of indices\n * @returns {number[]} indices of top-K largest samples\n */\nexport function argmax(arr, k = 1) {\n // Top-k Quicksort\n arr = arr.slice();\n let stack = [[0, arr.length]];\n let workspace = [];\n for (let i = 0; i < arr.length; i++)\n workspace[i] = i;\n while (stack.length > 0) {\n let [from, to] = stack.pop(), pivot = arr[to - 1], left = from, right = to - 2, tmp;\n if (from >= to - 1)\n continue;\n while (true) {\n while (arr[left] > pivot && left <= right)\n left++;\n while (arr[right] <= pivot && left <= right)\n right--;\n if (left >= right)\n break;\n tmp = arr[left];\n arr[left] = arr[right];\n arr[right] = tmp;\n tmp = workspace[left];\n workspace[left] = workspace[right];\n workspace[right] = tmp;\n }\n arr[to - 1] = arr[left];\n arr[left] = pivot;\n tmp = workspace[to - 1];\n workspace[to - 1] = workspace[left];\n workspace[left] = tmp;\n // If partial segment contains top-K elements, append it into stack\n stack.push([from, left]); // left (=larger) segment always contains top-K elements\n if (left + 1 < k)\n stack.push([left + 1, to]);\n }\n let result = [];\n for (let i = 0; i < k; i++)\n result.push(workspace[i]);\n return result;\n}\n/**\n * Return indices of the top-K smallest elements.\n * This implementation is not stable sort.\n *\n * @param {number[]|Float32Array|Int32Array} arr array\n * @param {number} k number of indices\n * @returns {number[]} indices of top-K smallest samples\n */\nexport function argmin(arr, k = 1) {\n // Top-k Quicksort\n arr = arr.slice();\n let stack = [[0, arr.length]];\n let workspace = [];\n for (let i = 0; i < arr.length; i++)\n workspace[i] = i;\n while (stack.length > 0) {\n let [from, to] = stack.pop(), pivot = arr[to - 1], left = from, right = to - 2, tmp;\n if (from >= to - 1)\n continue;\n while (true) {\n while (arr[left] < pivot && left <= right)\n left++;\n while (arr[right] >= pivot && left <= right)\n right--;\n if (left >= right)\n break;\n tmp = arr[left];\n arr[left] = arr[right];\n arr[right] = tmp;\n tmp = workspace[left];\n workspace[left] = workspace[right];\n workspace[right] = tmp;\n }\n arr[to - 1] = arr[left];\n arr[left] = pivot;\n tmp = workspace[to - 1];\n workspace[to - 1] = workspace[left];\n workspace[left] = tmp;\n // If partial segment contains top-K elements, append it into stack\n stack.push([from, left]); // left (=larger) segment always contains top-K elements\n if (left + 1 < k)\n stack.push([left + 1, to]);\n }\n let result = [];\n for (let i = 0; i < k; i++)\n result.push(workspace[i]);\n return result;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/descriptor_runner/math/argsort.js\n// module id = 44\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 99993b033..0b6ecf0e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "webdnn", - "version": "1.2.3", + "version": "1.2.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 785103981..60fb6fc26 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webdnn", - "version": "1.2.4", + "version": "1.2.5", "description": "Deep Neural Network Execution Framework for Web Browsers", "main": "src/descriptor_runner/webdnn.js", "types": "dist/webdnn.d.ts",