}),void0)}}functionn(t){this.name=t||r,this.db=null}varr=t("src/constants").FILE_SYSTEM_NAME,o=t("src/constants").FILE_STORE_NAME,i=t("src/constants").WSQL_VERSION,s=t("src/constants").WSQL_SIZE,a=t("src/constants").WSQL_DESC,c=t("src/shared").u8toArray;returne.prototype.clear=function(t){functione(e,n){t(n)}functionn(){t(null)}this.getTransaction(function(t){t.executeSql("DELETE FROM "+o+";",[],n,e)})},e.prototype.get=function(t,e){functionn(t,n){varr=0===n.rows.length?null:n.rows.item(0).data;try{r&&(r=JSON.parse(r),r.__isUint8Array&&(r=newUint8Array(r.__array))),e(null,r)}catch(o){e(o)}}functionr(t,n){e(n)}this.getTransaction(function(e){e.executeSql("SELECT data FROM "+o+" WHERE id = ?;",[t],n,r)})},e.prototype.put=function(t,e,n){functionr(){n(null)}functioni(t,e){n(e)}"[object Uint8Array]"===Object.prototype.toString.call(e)&&(e={__isUint8Array:!0,__array:c(e)}),e=JSON.stringify(e),this.getTransaction(function(n){n.executeSql("INSERT OR REPLACE INTO "+o+" (id, data) VALUES (?, ?);",[t,e],r,i)})},e.prototype.delete=function(t,e){functionn(){e(null)}functionr(t,n){e(n)}this.getTransaction(function(e){e.executeSql("DELETE FROM "+o+" WHERE id = ?;",[t],n,r)})},n.isSupported=function(){return!!window.openDatabase},n.prototype.open=function(t){functione(e,n){t(n)}functionn(e){functionn(e,n){varr=0===n.rows.item(0).count;t(null,r)}functioni(e,n){t(n)}r.db=c,e.executeSql("SELECT COUNT(id) AS count FROM "+o+";",[],n,i)}varr=this;if(r.db)returnt(null,!1),void0;varc=window.openDatabase(r.name,i,a,s);returnc?(c.transaction(function(t){functionr(t){t.executeSql("CREATE INDEX IF NOT EXISTS idx_"+o+"_id"+" on "+o+" (id);",[],n,e)}t.executeSql("CREATE TABLE IF NOT EXISTS "+o+" (id unique, data TEXT);",[],r,e)}),void0):(t("[WebSQL] Unable to open database."),void0)},n.prototype.getReadOnlyContext=function(){returnnewe(this.db,!0)},n.prototype.getReadWriteContext=function(){returnnewe(this.db,!1)},n}),function(){functiont(t){varn=!1;returnfunction(){if(n)throwError("Callback was already called.");n=!0,t.apply(e,arguments)}}vare,r,o={};e=this,null!=e&&(r=e.async),o.noConflict=function(){returne.async=r,o};vari=function(t,e){if(t.forEach)returnt.forEach(e);for(varn=0;t.length>n;n+=1)e(t[n],n,t)},s=function(t,e){if(t.map)returnt.map(e);varn=[];returni(t,function(t,r,o){n.push(e(t,r,o))}),n},a=function(t,e,n){returnt.reduce?t.reduce(e,n):(i(t,function(t,r,o){n=e(n,t,r,o)}),n)},c=function(t){if(Object.keys)returnObject.keys(t);vare=[];for(varnint)t.hasOwnProperty(n)&&e.push(n);returne};"undefined"!=typeofprocess&&process.nextTick?(o.nextTick=process.nextTick,o.setImmediate="undefined"!=typeofsetImmediate?function(t){setImmediate(t)}:o.nextTick):"function"==typeofsetImmediate?(o.nextTick=function(t){setImmediate(t)},o.setImmediate=o.nextTick):(o.nextTick=function(t){setTimeout(t,0)},o.setImmediate=o.nextTick),o.each=function(e,n,r){if(r=r||function(){},!e.length)returnr();varo=0;i(e,function(i){n(i,t(function(t){t?(r(t),r=function(){}):(o+=1,o>=e.length&&r(null))}))})},o.forEach=o.each,o.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)returnn();varr=0,o=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n(null):o())})};o()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,e,n,r){varo=u(e);o.apply(null,[t,n,r])},o.forEachLimit=o.eachLimit;varu=function(t){returnfunction(e,n,r){if(r=r||function(){},!e.length||0>=t)returnr();varo=0,i=0,s=0;(functiona(){if(o>=e.length)returnr();for(;t>s&&e.length>i;)i+=1,s+=1,n(e[i-1],function(t){t?(r(t),r=function(){}):(o+=1,s-=1,o>=e.length?r():a())})})()}},f=function(t){returnfunction(){vare=Array.prototype.slice.call(arguments);returnt.apply(null,[o.each].concat(e))}},l=function(t,e){returnfunction(){varn=Array.prototype.slice.call(arguments);returne.apply(null,[u(t)].concat(n))}},p=function(t){returnfunction(){vare=Array.prototype.slice.call(arguments);returnt.apply(null,[o.eachSeries].concat(e))}},h=function(t,e,n,r){varo=[];e=s(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.valu
}}elsethis._events[t]=n;returnthis},o.prototype.onAny=function(t){if(this._all||(this._all=[]),"function"!=typeoft)throwError("onAny only accepts instances of Function");returnthis._all.push(t),this},o.prototype.addListener=o.prototype.on,o.prototype.off=function(t,e){if("function"!=typeofe)throwError("removeListener only takes instances of Function");varn,r=[];if(this.wildcard){varo="string"==typeoft?t.split(this.delimiter):t.slice();r=i.call(this,null,o,this.listenerTree,0)}else{if(!this._events[t])returnthis;n=this._events[t],r.push({_listeners:n})}for(vars=0;r.length>s;s++){varc=r[s];if(n=c._listeners,a(n)){for(varu=-1,f=0,l=n.length;l>f;f++)if(n[f]===e||n[f].listener&&n[f].listener===e||n[f]._origin&&n[f]._origin===e){u=f;break}if(0>u)continue;returnthis.wildcard?c._listeners.splice(u,1):this._events[t].splice(u,1),0===n.length&&(this.wildcard?deletec._listeners:deletethis._events[t]),this}(n===e||n.listener&&n.listener===e||n._origin&&n._origin===e)&&(this.wildcard?deletec._listeners:deletethis._events[t])}returnthis},o.prototype.offAny=function(t){vare,n=0,r=0;if(t&&this._all&&this._all.length>0){for(e=this._all,n=0,r=e.length;r>n;n++)if(t===e[n])returne.splice(n,1),this}elsethis._all=[];returnthis},o.prototype.removeListener=o.prototype.off,o.prototype.removeAllListeners=function(t){if(0===arguments.length)return!this._events||e.call(this),this;if(this.wildcard)for(varn="string"==typeoft?t.split(this.delimiter):t.slice(),r=i.call(this,null,n,this.listenerTree,0),o=0;r.length>o;o++){vars=r[o];s._listeners=null}else{if(!this._events[t])returnthis;this._events[t]=null}returnthis},o.prototype.listeners=function(t){if(this.wildcard){varn=[],r="string"==typeoft?t.split(this.delimiter):t.slice();returni.call(this,n,r,this.listenerTree,0),n}returnthis._events||e.call(this),this._events[t]||(this._events[t]=[]),a(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]},o.prototype.listenersAny=function(){returnthis._all?this._all:[]},"function"==typeofn&&n.amd?n("EventEmitter",[],function(){returno}):t.EventEmitter2=o}("undefined"!=typeofprocess&&process.title!==void0&&"undefined"!=typeofexports?exports:window),n("intercom",["require","EventEmitter","src/shared"],function(t){functione(t,e){varn=0;returnfunction(){varr=Date.now();r-n>t&&(n=r,e.apply(this,arguments))}}functionn(t,e){if(void0!==t&&t||(t={}),"object"==typeofe)for(varnine)e.hasOwnProperty(n)&&(t[n]=e[n]);returnt}functionr(){vart=this,e=Date.now();this.origin=i(),this.lastMessage=e,this.receivedIDs={},this.previousValues={};varn=function(){t._onStorageEvent.apply(t,arguments)};document.attachEvent?document.attachEvent("onstorage",n):window.addEventListener("storage",n,!1)}varo=t("EventEmitter"),i=t("src/shared").guid,s=function(t){returnt.localStorage===void0?{getItem:function(){},setItem:function(){},removeItem:function(){}}:t.localStorage}(this);r.prototype._transaction=function(t){functione(){if(!a){varl=Date.now(),p=0|s.getItem(u);if(p&&r>l-p)returnc||(i._on("storage",e),c=!0),f=window.setTimeout(e,o),void0;a=!0,s.setItem(u,l),t(),n()}}functionn(){c&&i._off("storage",e),f&&window.clearTimeout(f),s.removeItem(u)}varr=1e3,o=20,i=this,a=!1,c=!1,f=null;e()},r.prototype._cleanup_emit=e(100,function(){vart=this;t._transaction(function(){vart,e=Date.now(),n=e-f,r=0;try{t=JSON.parse(s.getItem(a)||"[]")}catch(o){t=[]}for(vari=t.length-1;i>=0;i--)n>t[i].timestamp&&(t.splice(i,1),r++);r>0&&s.setItem(a,JSON.stringify(t))})}),r.prototype._cleanup_once=e(100,function(){vart=this;t._transaction(function(){vare,n;Date.now();varr=0;try{n=JSON.parse(s.getItem(c)||"{}")}catch(o){n={}}for(einn)t._once_expired(e,n)&&(deleten[e],r++);r>0&&s.setItem(c,JSON.stringify(n))})}),r.prototype._once_expired=function(t,e){if(!e)return!0;if(!e.hasOwnProperty(t))return!0;if("object"!=typeofe[t])return!0;varn=e[t].ttl||l,r=Date.now(),o=e[t].timestamp;returnr-n>o},r.prototype._localStorageChanged=function(t,e){if(t&&t.key)returnt.key===e;varn=s.getItem(e);returnn===this.previousValues[e]?!1:(this.previ