/** vim: et:ts=4:sw=4:sts=4
 * @license RequireJS 2.1.9 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
 * Available via the MIT or new BSD license.
 * see: http://github.com/jrburke/requirejs for details
 */

/**
 * @preserve Copyright (c) 2014 Petka Antonov
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:</p>
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 * 
 */

/**
 * Copyright (c) 2014 Petka Antonov
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:</p>
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 * 
 */

/**
 * @license
 * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
 * Build: `lodash modern -o ./dist/lodash.js`
 * Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
 * Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
 * Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
 * Available under MIT license <http://lodash.com/license>
 */

//     Underscore.js 1.6.0
//     http://underscorejs.org
//     (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
//     Underscore may be freely distributed under the MIT license.

var requirejs,require,define;(function(global){function isFunction(e){return ostring.call(e)==="[object Function]"}function isArray(e){return ostring.call(e)==="[object Array]"}function each(e,t){if(e){var n;for(n=0;n<e.length;n+=1)if(e[n]&&t(e[n],n,e))break}}function eachReverse(e,t){if(e){var n;for(n=e.length-1;n>-1;n-=1)if(e[n]&&t(e[n],n,e))break}}function hasProp(e,t){return hasOwn.call(e,t)}function getOwn(e,t){return hasProp(e,t)&&e[t]}function eachProp(e,t){var n;for(n in e)if(hasProp(e,n)&&t(e[n],n))break}function mixin(e,t,n,r){return t&&eachProp(t,function(t,i){if(n||!hasProp(e,i))r&&typeof t!="string"?(e[i]||(e[i]={}),mixin(e[i],t,n,r)):e[i]=t}),e}function bind(e,t){return function(){return t.apply(e,arguments)}}function scripts(){return document.getElementsByTagName("script")}function defaultOnError(e){throw e}function getGlobal(e){if(!e)return e;var t=global;return each(e.split("."),function(e){t=t[e]}),t}function makeError(e,t,n,r){var i=new Error(t+"\nhttp://requirejs.org/docs/errors.html#"+e);return i.requireType=e,i.requireModules=r,n&&(i.originalError=n),i}function newContext(e){function v(e){var t,n;for(t=0;e[t];t+=1){n=e[t];if(n===".")e.splice(t,1),t-=1;else if(n===".."){if(t===1&&(e[2]===".."||e[0]===".."))break;t>0&&(e.splice(t-1,2),t-=2)}}}function m(e,t,n){var r,i,s,u,a,f,l,c,h,p,d,m=t&&t.split("/"),g=m,y=o.map,b=y&&y["*"];e&&e.charAt(0)==="."&&(t?(getOwn(o.pkgs,t)?g=m=[t]:g=m.slice(0,m.length-1),e=g.concat(e.split("/")),v(e),i=getOwn(o.pkgs,r=e[0]),e=e.join("/"),i&&e===r+"/"+i.main&&(e=r)):e.indexOf("./")===0&&(e=e.substring(2)));if(n&&y&&(m||b)){u=e.split("/");for(a=u.length;a>0;a-=1){l=u.slice(0,a).join("/");if(m)for(f=m.length;f>0;f-=1){s=getOwn(y,m.slice(0,f).join("/"));if(s){s=getOwn(s,l);if(s){c=s,h=a;break}}}if(c)break;!p&&b&&getOwn(b,l)&&(p=getOwn(b,l),d=a)}!c&&p&&(c=p,h=d),c&&(u.splice(0,h,c),e=u.join("/"))}return e}function g(e){isBrowser&&each(scripts(),function(t){if(t.getAttribute("data-requiremodule")===e&&t.getAttribute("data-requirecontext")===r.contextName)return t.parentNode.removeChild(t),!0})}function y(e){var t=getOwn(o.paths,e);if(t&&isArray(t)&&t.length>1)return t.shift(),r.require.undef(e),r.require([e]),!0}function b(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function w(e,t,n,i){var s,o,u,a,f=null,l=t?t.name:null,h=e,v=!0,g="";return e||(v=!1,e="_@r"+(p+=1)),a=b(e),f=a[0],e=a[1],f&&(f=m(f,l,i),o=getOwn(c,f)),e&&(f?o&&o.normalize?g=o.normalize(e,function(e){return m(e,l,i)}):g=m(e,l,i):(g=m(e,l,i),a=b(g),f=a[0],g=a[1],n=!0,s=r.nameToUrl(g))),u=f&&!o&&!n?"_unnormalized"+(d+=1):"",{prefix:f,name:g,parentMap:t,unnormalized:!!u,url:s,originalName:h,isDefine:v,id:(f?f+"!"+g:g)+u}}function E(e){var t=e.id,n=getOwn(u,t);return n||(n=u[t]=new r.Module(e)),n}function S(e,t,n){var r=e.id,i=getOwn(u,r);hasProp(c,r)&&(!i||i.defineEmitComplete)?t==="defined"&&n(c[r]):(i=E(e),i.error&&t==="error"?n(i.error):i.on(t,n))}function x(e,t){var n=e.requireModules,r=!1;t?t(e):(each(n,function(t){var n=getOwn(u,t);n&&(n.error=e,n.events.error&&(r=!0,n.emit("error",e)))}),r||req.onError(e))}function T(){globalDefQueue.length&&(apsp.apply(l,[l.length-1,0].concat(globalDefQueue)),globalDefQueue=[])}function N(e){delete u[e],delete a[e]}function C(e,t,n){var r=e.map.id;e.error?e.emit("error",e.error):(t[r]=!0,each(e.depMaps,function(r,i){var s=r.id,o=getOwn(u,s);o&&!e.depMatched[i]&&!n[s]&&(getOwn(t,s)?(e.defineDep(i,c[s]),e.check()):C(o,t,n))}),n[r]=!0)}function k(){var e,n,i,u,f=o.waitSeconds*1e3,l=f&&r.startTime+f<(new Date).getTime(),c=[],h=[],p=!1,d=!0;if(t)return;t=!0,eachProp(a,function(t){e=t.map,n=e.id;if(!t.enabled)return;e.isDefine||h.push(t);if(!t.error)if(!t.inited&&l)y(n)?(u=!0,p=!0):(c.push(n),g(n));else if(!t.inited&&t.fetched&&e.isDefine){p=!0;if(!e.prefix)return d=!1}});if(l&&c.length)return i=makeError("timeout","Load timeout for modules: "+c,null,c),i.contextName=r.contextName,x(i);d&&each(h,function(e){C(e,{},{})}),(!l||u)&&p&&(isBrowser||isWebWorker)&&!s&&(s=setTimeout(function(){s=0,k()},50)),t=!1}function L(e){hasProp(c,e[0])||E(w(e[0],null,!0)).init(e[1],e[2])}function A(e,t,n,r){e.detachEvent&&!isOpera?r&&e.detachEvent(r,t):e.removeEventListener(n,t,!1)}function O(e){var t=e.currentTarget||e.srcElement;return A(t,r.onScriptLoad,"load","onreadystatechange"),A(t,r.onScriptError,"error"),{node:t,id:t&&t.getAttribute("data-requiremodule")}}function M(){var e;T();while(l.length){e=l.shift();if(e[0]===null)return x(makeError("mismatch","Mismatched anonymous define() module: "+e[e.length-1]));L(e)}}var t,n,r,i,s,o={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{},config:{}},u={},a={},f={},l=[],c={},h={},p=1,d=1;return i={require:function(e){return e.require?e.require:e.require=r.makeRequire(e.map)},exports:function(e){e.usingExports=!0;if(e.map.isDefine)return e.exports?e.exports:e.exports=c[e.map.id]={}},module:function(e){return e.module?e.module:e.module={id:e.map.id,uri:e.map.url,config:function(){var t,n=getOwn(o.pkgs,e.map.id);return t=n?getOwn(o.config,e.map.id+"/"+n.main):getOwn(o.config,e.map.id),t||{}},exports:c[e.map.id]}}},n=function(e){this.events=getOwn(f,e.id)||{},this.map=e,this.shim=getOwn(o.shim,e.id),this.depExports=[],this.depMaps=[],this.depMatched=[],this.pluginMaps={},this.depCount=0},n.prototype={init:function(e,t,n,r){r=r||{};if(this.inited)return;this.factory=t,n?this.on("error",n):this.events.error&&(n=bind(this,function(e){this.emit("error",e)})),this.depMaps=e&&e.slice(0),this.errback=n,this.inited=!0,this.ignore=r.ignore,r.enabled||this.enabled?this.enable():this.check()},defineDep:function(e,t){this.depMatched[e]||(this.depMatched[e]=!0,this.depCount-=1,this.depExports[e]=t)},fetch:function(){if(this.fetched)return;this.fetched=!0,r.startTime=(new Date).getTime();var e=this.map;if(!this.shim)return e.prefix?this.callPlugin():this.load();r.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],bind(this,function(){return e.prefix?this.callPlugin():this.load()}))},load:function(){var e=this.map.url;h[e]||(h[e]=!0,r.load(this.map.id,e))},check:function(){if(!this.enabled||this.enabling)return;var e,t,n=this.map.id,i=this.depExports,s=this.exports,o=this.factory;if(!this.inited)this.fetch();else if(this.error)this.emit("error",this.error);else if(!this.defining){this.defining=!0;if(this.depCount<1&&!this.defined){if(isFunction(o)){if(this.events.error&&this.map.isDefine||req.onError!==defaultOnError)try{s=r.execCb(n,o,i,s)}catch(u){e=u}else s=r.execCb(n,o,i,s);this.map.isDefine&&(t=this.module,t&&t.exports!==undefined&&t.exports!==this.exports?s=t.exports:s===undefined&&this.usingExports&&(s=this.exports));if(e)return e.requireMap=this.map,e.requireModules=this.map.isDefine?[this.map.id]:null,e.requireType=this.map.isDefine?"define":"require",x(this.error=e)}else s=o;this.exports=s,this.map.isDefine&&!this.ignore&&(c[n]=s,req.onResourceLoad&&req.onResourceLoad(r,this.map,this.depMaps)),N(n),this.defined=!0}this.defining=!1,this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}},callPlugin:function(){var e=this.map,t=e.id,n=w(e.prefix);this.depMaps.push(n),S(n,"defined",bind(this,function(n){var i,s,a,f=this.map.name,l=this.map.parentMap?this.map.parentMap.name:null,c=r.makeRequire(e.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){n.normalize&&(f=n.normalize(f,function(e){return m(e,l,!0)})||""),s=w(e.prefix+"!"+f,this.map.parentMap),S(s,"defined",bind(this,function(e){this.init([],function(){return e},null,{enabled:!0,ignore:!0})})),a=getOwn(u,s.id),a&&(this.depMaps.push(s),this.events.error&&a.on("error",bind(this,function(e){this.emit("error",e)})),a.enable());return}i=bind(this,function(e){this.init([],function(){return e},null,{enabled:!0})}),i.error=bind(this,function(e){this.inited=!0,this.error=e,e.requireModules=[t],eachProp(u,function(e){e.map.id.indexOf(t+"_unnormalized")===0&&N(e.map.id)}),x(e)}),i.fromText=bind(this,function(n,s){var u=e.name,a=w(u),f=useInteractive;s&&(n=s),f&&(useInteractive=!1),E(a),hasProp(o.config,t)&&(o.config[u]=o.config[t]);try{req.exec(n)}catch(l){return x(makeError("fromtexteval","fromText eval for "+t+" failed: "+l,l,[t]))}f&&(useInteractive=!0),this.depMaps.push(a),r.completeLoad(u),c([u],i)}),n.load(e.name,c,i,o)})),r.enable(n,this),this.pluginMaps[n.id]=n},enable:function(){a[this.map.id]=this,this.enabled=!0,this.enabling=!0,each(this.depMaps,bind(this,function(e,t){var n,s,o;if(typeof e=="string"){e=w(e,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap),this.depMaps[t]=e,o=getOwn(i,e.id);if(o){this.depExports[t]=o(this);return}this.depCount+=1,S(e,"defined",bind(this,function(e){this.defineDep(t,e),this.check()})),this.errback&&S(e,"error",bind(this,this.errback))}n=e.id,s=u[n],!hasProp(i,n)&&s&&!s.enabled&&r.enable(e,this)})),eachProp(this.pluginMaps,bind(this,function(e){var t=getOwn(u,e.id);t&&!t.enabled&&r.enable(e,this)})),this.enabling=!1,this.check()},on:function(e,t){var n=this.events[e];n||(n=this.events[e]=[]),n.push(t)},emit:function(e,t){each(this.events[e],function(e){e(t)}),e==="error"&&delete this.events[e]}},r={config:o,contextName:e,registry:u,defined:c,urlFetched:h,defQueue:l,Module:n,makeModuleMap:w,nextTick:req.nextTick,onError:x,configure:function(e){e.baseUrl&&e.baseUrl.charAt(e.baseUrl.length-1)!=="/"&&(e.baseUrl+="/");var t=o.pkgs,n=o.shim,i={paths:!0,config:!0,map:!0};eachProp(e,function(e,t){i[t]?t==="map"?(o.map||(o.map={}),mixin(o[t],e,!0,!0)):mixin(o[t],e,!0):o[t]=e}),e.shim&&(eachProp(e.shim,function(e,t){isArray(e)&&(e={deps:e}),(e.exports||e.init)&&!e.exportsFn&&(e.exportsFn=r.makeShimExports(e)),n[t]=e}),o.shim=n),e.packages&&(each(e.packages,function(e){var n;e=typeof e=="string"?{name:e}:e,n=e.location,t[e.name]={name:e.name,location:n||e.name,main:(e.main||"main").replace(currDirRegExp,"").replace(jsSuffixRegExp,"")}}),o.pkgs=t),eachProp(u,function(e,t){!e.inited&&!e.map.unnormalized&&(e.map=w(t))}),(e.deps||e.callback)&&r.require(e.deps||[],e.callback)},makeShimExports:function(e){function t(){var t;return e.init&&(t=e.init.apply(global,arguments)),t||e.exports&&getGlobal(e.exports)}return t},makeRequire:function(t,n){function s(o,a,f){var l,h,p;return n.enableBuildCallback&&a&&isFunction(a)&&(a.__requireJsBuild=!0),typeof o=="string"?isFunction(a)?x(makeError("requireargs","Invalid require call"),f):t&&hasProp(i,o)?i[o](u[t.id]):req.get?req.get(r,o,t,s):(h=w(o,t,!1,!0),l=h.id,hasProp(c,l)?c[l]:x(makeError("notloaded",'Module name "'+l+'" has not been loaded yet for context: '+e+(t?"":". Use require([])")))):(M(),r.nextTick(function(){M(),p=E(w(null,t)),p.skipMap=n.skipMap,p.init(o,a,f,{enabled:!0}),k()}),s)}return n=n||{},mixin(s,{isBrowser:isBrowser,toUrl:function(e){var n,i=e.lastIndexOf("."),s=e.split("/")[0],o=s==="."||s==="..";return i!==-1&&(!o||i>1)&&(n=e.substring(i,e.length),e=e.substring(0,i)),r.nameToUrl(m(e,t&&t.id,!0),n,!0)},defined:function(e){return hasProp(c,w(e,t,!1,!0).id)},specified:function(e){return e=w(e,t,!1,!0).id,hasProp(c,e)||hasProp(u,e)}}),t||(s.undef=function(e){T();var n=w(e,t,!0),r=getOwn(u,e);g(e),delete c[e],delete h[n.url],delete f[e],r&&(r.events.defined&&(f[e]=r.events),N(e))}),s},enable:function(e){var t=getOwn(u,e.id);t&&E(e).enable()},completeLoad:function(e){var t,n,r,i=getOwn(o.shim,e)||{},s=i.exports;T();while(l.length){n=l.shift();if(n[0]===null){n[0]=e;if(t)break;t=!0}else n[0]===e&&(t=!0);L(n)}r=getOwn(u,e);if(!t&&!hasProp(c,e)&&r&&!r.inited){if(o.enforceDefine&&(!s||!getGlobal(s))){if(y(e))return;return x(makeError("nodefine","No define call for "+e,null,[e]))}L([e,i.deps||[],i.exportsFn])}k()},nameToUrl:function(e,t,n){var r,i,s,u,a,f,l,c,h;if(req.jsExtRegExp.test(e))c=e+(t||"");else{r=o.paths,i=o.pkgs,a=e.split("/");for(f=a.length;f>0;f-=1){l=a.slice(0,f).join("/"),s=getOwn(i,l),h=getOwn(r,l);if(h){isArray(h)&&(h=h[0]),a.splice(0,f,h);break}if(s){e===s.name?u=s.location+"/"+s.main:u=s.location,a.splice(0,f,u);break}}c=a.join("/"),c+=t||(/^data\:|\?/.test(c)||n?"":".js"),c=(c.charAt(0)==="/"||c.match(/^[\w\+\.\-]+:/)?"":o.baseUrl)+c}return o.urlArgs?c+((c.indexOf("?")===-1?"?":"&")+o.urlArgs):c},load:function(e,t){req.load(r,e,t)},execCb:function(e,t,n,r){return t.apply(r,n)},onScriptLoad:function(e){if(e.type==="load"||readyRegExp.test((e.currentTarget||e.srcElement).readyState)){interactiveScript=null;var t=O(e);r.completeLoad(t.id)}},onScriptError:function(e){var t=O(e);if(!y(t.id))return x(makeError("scripterror","Script error for: "+t.id,e,[t.id]))}},r.require=r.makeRequire(),r}function getInteractiveScript(){return interactiveScript&&interactiveScript.readyState==="interactive"?interactiveScript:(eachReverse(scripts(),function(e){if(e.readyState==="interactive")return interactiveScript=e}),interactiveScript)}var req,s,head,baseElement,dataMain,src,interactiveScript,currentlyAddingScript,mainScript,subPath,version="2.1.9",commentRegExp=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,cjsRequireRegExp=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,jsSuffixRegExp=/\.js$/,currDirRegExp=/^\.\//,op=Object.prototype,ostring=op.toString,hasOwn=op.hasOwnProperty,ap=Array.prototype,apsp=ap.splice,isBrowser=typeof window!="undefined"&&typeof navigator!="undefined"&&!!window.document,isWebWorker=!isBrowser&&typeof importScripts!="undefined",readyRegExp=isBrowser&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,defContextName="_",isOpera=typeof opera!="undefined"&&opera.toString()==="[object Opera]",contexts={},cfg={},globalDefQueue=[],useInteractive=!1;if(typeof define!="undefined")return;if(typeof requirejs!="undefined"){if(isFunction(requirejs))return;cfg=requirejs,requirejs=undefined}typeof require!="undefined"&&!isFunction(require)&&(cfg=require,require=undefined),req=requirejs=function(e,t,n,r){var i,s,o=defContextName;return!isArray(e)&&typeof e!="string"&&(s=e,isArray(t)?(e=t,t=n,n=r):e=[]),s&&s.context&&(o=s.context),i=getOwn(contexts,o),i||(i=contexts[o]=req.s.newContext(o)),s&&i.configure(s),i.require(e,t,n)},req.config=function(e){return req(e)},req.nextTick=typeof setTimeout!="undefined"?function(e){setTimeout(e,4)}:function(e){e()},require||(require=req),req.version=version,req.jsExtRegExp=/^\/|:|\?|\.js$/,req.isBrowser=isBrowser,s=req.s={contexts:contexts,newContext:newContext},req({}),each(["toUrl","undef","defined","specified"],function(e){req[e]=function(){var t=contexts[defContextName];return t.require[e].apply(t,arguments)}}),isBrowser&&(head=s.head=document.getElementsByTagName("head")[0],baseElement=document.getElementsByTagName("base")[0],baseElement&&(head=s.head=baseElement.parentNode)),req.onError=defaultOnError,req.createNode=function(e,t,n){var r=e.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");return r.type=e.scriptType||"text/javascript",r.charset="utf-8",r.async=!0,r},req.load=function(e,t,n){var r=e&&e.config||{},i;if(isBrowser)return i=req.createNode(r,t,n),i.setAttribute("data-requirecontext",e.contextName),i.setAttribute("data-requiremodule",t),i.attachEvent&&!(i.attachEvent.toString&&i.attachEvent.toString().indexOf("[native code")<0)&&!isOpera?(useInteractive=!0,i.attachEvent("onreadystatechange",e.onScriptLoad)):(i.addEventListener("load",e.onScriptLoad,!1),i.addEventListener("error",e.onScriptError,!1)),i.src=n,currentlyAddingScript=i,baseElement?head.insertBefore(i,baseElement):head.appendChild(i),currentlyAddingScript=null,i;if(isWebWorker)try{importScripts(n),e.completeLoad(t)}catch(s){e.onError(makeError("importscripts","importScripts failed for "+t+" at "+n,s,[t]))}},isBrowser&&!cfg.skipDataMain&&eachReverse(scripts(),function(e){head||(head=e.parentNode),dataMain=e.getAttribute("data-main");if(dataMain)return mainScript=dataMain,cfg.baseUrl||(src=mainScript.split("/"),mainScript=src.pop(),subPath=src.length?src.join("/")+"/":"./",cfg.baseUrl=subPath),mainScript=mainScript.replace(jsSuffixRegExp,""),req.jsExtRegExp.test(mainScript)&&(mainScript=dataMain),cfg.deps=cfg.deps?cfg.deps.concat(mainScript):[mainScript],!0}),define=function(e,t,n){var r,i;typeof e!="string"&&(n=t,t=e,e=null),isArray(t)||(n=t,t=null),!t&&isFunction(n)&&(t=[],n.length&&(n.toString().replace(commentRegExp,"").replace(cjsRequireRegExp,function(e,n){t.push(n)}),t=(n.length===1?["require"]:["require","exports","module"]).concat(t))),useInteractive&&(r=currentlyAddingScript||getInteractiveScript(),r&&(e||(e=r.getAttribute("data-requiremodule")),i=contexts[r.getAttribute("data-requirecontext")])),(i?i.defQueue:globalDefQueue).push([e,t,n])},define.amd={jQuery:!0},req.exec=function(text){return eval(text)},req(cfg)})(this),define("requireLib",function(){}),!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define("lib/bluebird",e):"undefined"!=typeof window?window.Promise=e():"undefined"!=typeof global?global.Promise=e():"undefined"!=typeof self&&(self.Promise=e())}(function(){var define,module,exports;return function e(t,n,r){function i(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(s)return s(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var s=typeof require=="function"&&require;for(var o=0;o<r.length;o++)i(r[o]);return i}({1:[function(e,t,n){t.exports=function(t,n,r){function s(e,t){var r=n(e,i,t===!0&&e._isBound()?e._boundTo:void 0),s=r.promise();return s.isRejected()?s:(r.setHowMany(1),r.setUnwrap(),r.init(),s)}var i=e("./some_promise_array.js")(r);t.any=function(t){return s(t,!1)},t.prototype.any=function(){return s(this,!0)}}},{"./some_promise_array.js":33}],2:[function(e,t,n){function a(){this._isTickUsed=!1,this._length=0,this._lateBuffer=new i,this._functionBuffer=new i(75e3);var e=this;this.consumeFunctionBuffer=function(){e._consumeFunctionBuffer()}}var r=e("./schedule.js"),i=e("./queue.js"),s=e("./util.js").errorObj,o=e("./util.js").tryCatch1,u=e("./global.js").process;a.prototype.haveItemsQueued=function(){return this._length>0},a.prototype.invokeLater=function(t,n,r){u!==void 0&&u.domain!=null&&!t.domain&&(t=u.domain.bind(t)),this._lateBuffer.push(t,n,r),this._queueTick()},a.prototype.invoke=function(t,n,r){u!==void 0&&u.domain!=null&&!t.domain&&(t=u.domain.bind(t));var i=this._functionBuffer;i.push(t,n,r),this._length=i.length(),this._queueTick()},a.prototype._consumeFunctionBuffer=function(){var t=this._functionBuffer;while(t.length()>0){var n=t.shift(),r=t.shift(),i=t.shift();n.call(r,i)}this._reset(),this._consumeLateBuffer()},a.prototype._consumeLateBuffer=function(){var t=this._lateBuffer;while(t.length()>0){var n=t.shift(),r=t.shift(),i=t.shift(),u=o(n,r,i);if(u===s){this._queueTick();if(n.domain==null)throw u.e;n.domain.emit("error",u.e)}}},a.prototype._queueTick=function(){this._isTickUsed||(r(this.consumeFunctionBuffer),this._isTickUsed=!0)},a.prototype._reset=function(){this._isTickUsed=!1,this._length=0},t.exports=new a},{"./global.js":15,"./queue.js":26,"./schedule.js":29,"./util.js":37}],3:[function(e,t,n){var r=e("./promise.js")();t.exports=r},{"./promise.js":19}],4:[function(e,t,n){t.exports=function(e){function t(e){var t=typeof this=="string"?this:""+this;return e[t]}e.prototype.call=function(t){var n=arguments.length,r=new Array(n-1);for(var i=1;i<n;++i)r[i-1]=arguments[i];return this._then(function(e){return e[t].apply(e,r)},void 0,void 0,void 0,void 0)},e.prototype.get=function(n){return this._then(t,void 0,void 0,n,void 0)}}},{}],5:[function(e,t,n){t.exports=function(t,n){var r=e("./errors.js"),i=e("./async.js"),s=r.CancellationError;t.prototype._cancel=function(){if(!this.isCancellable())return this;var t,n=this;while((t=n._cancellationParent)!==void 0&&t.isCancellable())n=t;var r=new s;n._attachExtraTrace(r),n._rejectUnchecked(r)},t.prototype.cancel=function(){return this.isCancellable()?(i.invokeLater(this._cancel,this,void 0),this):this},t.prototype.cancellable=function(){return this._cancellable()?this:(this._setCancellable(),this._cancellationParent=void 0,this)},t.prototype.uncancellable=function(){var r=new t(n);return r._setTrace(this),r._follow(this),r._unsetCancellable(),this._isBound()&&r._setBoundTo(this._boundTo),r},t.prototype.fork=function(t,n,r){var i=this._then(t,n,r,void 0,void 0);return i._setCancellable(),i._cancellationParent=void 0,i}}},{"./async.js":2,"./errors.js":9}],6:[function(e,t,n){t.exports=function(){function o(e){var t;if(typeof e=="function")t="[function "+(e.name||"anonymous")+"]";else{t=e.toString();var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(t))try{var r=JSON.stringify(e);t=r}catch(i){}t.length===0&&(t="(empty array)")}return"(<"+u(t)+">, no stack trace)"}function u(e){var t=41;return e.length<t?e:e.substr(0,t-3)+"..."}function a(e,t){this.captureStackTrace(a,t)}var t=e("./util.js").inherits,n=e("./es5.js").defineProperty,r=new RegExp("\\b(?:[a-zA-Z0-9.]+\\$_\\w+|tryCatch(?:1|2|Apply)|new \\w*PromiseArray|\\w*PromiseArray\\.\\w*PromiseArray|setTimeout|CatchFilter\\$_\\w+|makeNodePromisified|processImmediate|process._tickCallback|nextTick|Async\\$\\w+)\\b"),i=null,s=null;t(a,Error),a.prototype.captureStackTrace=function(t,n){f(this,t,n)},a.possiblyUnhandledRejection=function(t){if(typeof console=="object"){var n;if(typeof t=="object"||typeof t=="function"){var r=t.stack;n="Possibly unhandled "+s(r,t)}else n="Possibly unhandled "+String(t);typeof console.error=="function"||typeof console.error=="object"?console.error(n):(typeof console.log=="function"||typeof console.log=="object")&&console.log(n)}},a.combine=function(t,n){var s=t.length-1;for(var o=n.length-1;o>=0;--o){var u=n[o];if(t[s]!==u)break;t.pop(),s--}t.push("From previous event:");var a=t.concat(n),f=[];for(var o=0,l=a.length;o<l;++o){if(r.test(a[o])||o>0&&!i.test(a[o])&&a[o]!=="From previous event:")continue;f.push(a[o])}return f},a.isSupported=function(){return typeof f=="function"};var f=function l(){if(typeof Error.stackTraceLimit=="number"&&typeof Error.captureStackTrace=="function"){i=/^\s*at\s*/,s=function(e,t){return typeof e=="string"?e:t.name!==void 0&&t.message!==void 0?t.name+". "+t.message:o(t)};var e=Error.captureStackTrace;return function(n,r){e(n,r)}}var t=new Error;if(typeof t.stack=="string"&&typeof "".startsWith=="function"&&t.stack.startsWith("stackDetection@")&&l.name==="stackDetection"){n(Error,"stackTraceLimit",{writable:!0,enumerable:!1,configurable:!1,value:25}),i=/@/;var r=/[@\n]/;return s=function(e,t){return typeof e=="string"?t.name+". "+t.message+"\n"+e:t.name!==void 0&&t.message!==void 0?t.name+". "+t.message:o(t)},function(t){var n=(new Error).stack,i=n.split(r),s=i.length,o="";for(var u=0;u<s;u+=2)o+=i[u],o+="@",o+=i[u+1],o+="\n";t.stack=o}}return s=function(e,t){return typeof e=="string"?e:typeof t!="object"&&typeof t!="function"||t.name===void 0||t.message===void 0?o(t):t.name+". "+t.message},null}();return a}},{"./es5.js":11,"./util.js":37}],7:[function(e,t,n){t.exports=function(t){function a(e,t,n){this._instances=e,this._callback=t,this._promise=n}function f(e,t){var n={},r=i(e,n,t);if(r===s)return r;var a=o(n);return a.length?(s.e=new u("Catch filter must inherit from Error or be a simple predicate function"),s):r}var n=e("./util.js"),r=e("./errors.js"),i=n.tryCatch1,s=n.errorObj,o=e("./es5.js").keys,u=r.TypeError;return a.prototype.doFilter=function(n){var o=this._callback,u=this._promise,a=u._isBound()?u._boundTo:void 0;for(var l=0,c=this._instances.length;l<c;++l){var h=this._instances[l],p=h===Error||h!=null&&h.prototype instanceof Error;if(p&&n instanceof h){var d=i(o,a,n);return d===s?(t.e=d.e,t):d}if(typeof h=="function"&&!p){var v=f(h,n);if(v===s){var m=r.canAttach(s.e)?s.e:new Error(s.e+"");this._promise._attachExtraTrace(m),n=s.e;break}if(v){var d=i(o,a,n);return d===s?(t.e=d.e,t):d}}}return t.e=n,t},a}},{"./errors.js":9,"./es5.js":11,"./util.js":37}],8:[function(e,t,n){var r=e("./util.js"),i=r.isPrimitive,s=r.wrapsPrimitiveReceiver;t.exports=function(e){var t=function(){return this},n=function(){throw this},r=function(t,n){if(n===1)return function(){throw t};if(n===2)return function(){return t}};e.prototype["return"]=e.prototype.thenReturn=function(n){return s&&i(n)?this._then(r(n,2),void 0,void 0,void 0,void 0):this._then(t,void 0,void 0,n,void 0)},e.prototype["throw"]=e.prototype.thenThrow=function(t){return s&&i(t)?this._then(r(t,1),void 0,void 0,void 0,void 0):this._then(n,void 0,void 0,t,void 0)}}},{"./util.js":37}],9:[function(e,t,n){function f(e){try{u(e,"isAsync",!0)}catch(t){}}function l(e){return e==null?!1:e instanceof y||e.isAsync===!0}function c(e){return e instanceof a}function h(e){return c(e)}function p(e,t){function n(r){if(!(this instanceof n))return new n(r);this.message=typeof r=="string"?r:t,this.name=e,a.captureStackTrace&&a.captureStackTrace(this,this.constructor)}return o(n,a),n}function y(e){this.name="RejectionError",this.message=e,this.cause=e,this.isAsync=!0,e instanceof a?(this.message=e.message,this.stack=e.stack):a.captureStackTrace&&a.captureStackTrace(this,this.constructor)}var r=e("./global.js"),i=e("./es5.js").freeze,s=e("./util.js"),o=s.inherits,u=s.notEnumerableProp,a=r.Error,d=r.TypeError;typeof d!="function"&&(d=p("TypeError","type error"));var v=r.RangeError;typeof v!="function"&&(v=p("RangeError","range error"));var m=p("CancellationError","cancellation error"),g=p("TimeoutError","timeout error");o(y,a);var b="__BluebirdErrorTypes__",w=r[b];w||(w=i({CancellationError:m,TimeoutError:g,RejectionError:y}),u(r,b,w)),t.exports={Error:a,TypeError:d,RangeError:v,CancellationError:w.CancellationError,RejectionError:w.RejectionError,TimeoutError:w.TimeoutError,originatesFromRejection:l,markAsOriginatingFromRejection:f,canAttach:h}},{"./es5.js":11,"./global.js":15,"./util.js":37}],10:[function(e,t,n){t.exports=function(t){function r(e){var r=new n(e),i=t.rejected(r),s=i._peekContext();return s!=null&&s._attachExtraTrace(r),i}var n=e("./errors.js").TypeError;return r}},{"./errors.js":9}],11:[function(e,t,n){var r=function(){return this===void 0}();if(r)t.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,keys:Object.keys,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:r};else{var i={}.hasOwnProperty,s={}.toString,o={}.constructor.prototype,u=function(t){var n=[];for(var r in t)i.call(t,r)&&n.push(r);return n},a=function(t,n,r){return t[n]=r.value,t},f=function(t){return t},l=function(t){try{return Object(t).constructor.prototype}catch(n){return o}},c=function(t){try{return s.call(t)==="[object Array]"}catch(n){return!1}};t.exports={isArray:c,keys:u,defineProperty:a,freeze:f,getPrototypeOf:l,isES5:r}}},{}],12:[function(e,t,n){t.exports=function(t){function r(e){var n=this instanceof t?this._settledValue:this,r=n.length,i=new Array(r),s=0;for(var o=0;o<r;++o)e[o]&&(i[s++]=n[o]);return i.length=s,i}var n=e("./util.js").isArray,i={ref:null};t.filter=function(n,s){return t.map(n,s,i)._then(r,void 0,void 0,i.ref,void 0)},t.prototype.filter=function(t){return this.map(t,i)._then(r,void 0,void 0,i.ref,void 0)}}},{"./util.js":37}],13:[function(e,t,n){t.exports=function(t,n){function u(){return this}function a(){throw this}function f(e){return function(){return e}}function l(e){return function(){throw e}}function c(e,t,n){var r;return i&&s(t)?r=n?f(t):l(t):r=n?u:a,e._then(r,o,void 0,t,void 0)}function h(e){var r=this.promise,i=this.handler,s=r._isBound()?i.call(r._boundTo):i();if(s!==void 0){var o=t._cast(s,void 0);if(o instanceof t)return c(o,e,r.isFulfilled())}return r.isRejected()?(n.e=e,n):e}function p(e){var n=this.promise,r=this.handler,i=n._isBound()?r.call(n._boundTo,e):r(e);if(i!==void 0){var s=t._cast(i,void 0);if(s instanceof t)return c(s,e,!0)}return e}var r=e("./util.js"),i=r.wrapsPrimitiveReceiver,s=r.isPrimitive,o=r.thrower;t.prototype._passThroughHandler=function(t,n){if(typeof t!="function")return this.then();var r={promise:this,handler:t};return this._then(n?h:p,n?h:void 0,void 0,r,void 0)},t.prototype.lastly=t.prototype["finally"]=function(t){return this._passThroughHandler(t,!0)},t.prototype.tap=function(t){return this._passThroughHandler(t,!1)}}},{"./util.js":37}],14:[function(e,t,n){t.exports=function(t,n,r){var i=e("./promise_spawn.js")(t,r),s=e("./errors.js"),o=s.TypeError,u=e("./util.js").deprecated;t.coroutine=function(t){if(typeof t!="function")throw new o("generatorFunction must be a function");var n=i;return function(){var e=t.apply(this,arguments),r=new n(void 0,void 0);return r._generator=e,r._next(void 0),r.promise()}},t.coroutine.addYieldHandler=i.addYieldHandler,t.spawn=function(r){u("Promise.spawn is deprecated. Use Promise.coroutine instead.");if(typeof r!="function")return n("generatorFunction must be a function");var s=new i(r,this),o=s.promise();return s._run(t.spawn),o}}},{"./errors.js":9,"./promise_spawn.js":22,"./util.js":37}],15:[function(e,t,n){t.exports=function(){if(this!==void 0)return this;try{return global}catch(e){}try{return window}catch(e){}try{return self}catch(e){}}()},{}],16:[function(e,t,n){t.exports=function(t,n,r,i){function l(e){return c(e,this[0],this[1],this[2])}function c(e,n,s,o){if(typeof n!="function")return i("fn must be a function");var u=void 0;s===!0?e._isBound()&&(u=e._boundTo):s!==!1&&(u=s);var f=o!==void 0;f&&(o.ref=e);if(e instanceof t){var c=[n,u,o];return e._then(l,void 0,void 0,c,void 0)}if(!a(e))return i("expecting an array, a promise or a thenable");var h=new t(r);u!==void 0&&h._setBoundTo(u),h._setTrace(void 0);var d=new p(h,n,e,u,f);return d.init(),h}function p(e,t,n,r,i){this.shouldUnwrapItems=i,this.index=0,this.items=n,this.callback=t,this.receiver=r,this.promise=e,this.result=new Array(n.length)}var s=t.all,o=e("./util.js"),u=e("./errors.js").canAttach,a=o.isArray,f=t._cast,h={};o.inherits(p,n),p.prototype.init=function(){var n=this.items,r=n.length,i=this.result,s=!1;for(var o=0;o<r;++o){var u=f(n[o],void 0);u instanceof t?u.isPending()?(i[o]=h,u._proxyPromiseArray(this,o)):u.isFulfilled()?i[o]=u.value():(u._unsetRejectionIsUnhandled(),s||(this.reject(u.reason()),s=!0)):i[o]=u}s||this.iterate()},p.prototype.isResolved=function(){return this.promise===null},p.prototype._promiseProgressed=function(t){if(this.isResolved())return;this.promise._progress(t)},p.prototype._promiseFulfilled=function(t,n){if(this.isResolved())return;this.result[n]=t,this.shouldUnwrapItems&&(this.items[n]=t),this.index===n&&this.iterate()},p.prototype._promiseRejected=function(t){this.reject(t)},p.prototype.reject=function(t){if(this.isResolved())return;var n=u(t)?t:new Error(t+"");this.promise._attachExtraTrace(n),this.promise._reject(t,n)},p.prototype.iterate=function(){var t=this.index,n=this.items,r=this.result,i=n.length,r=this.result,o=this.receiver,u=this.callback;for(;t<i;++t){var a=r[t];if(a===h){this.index=t;return}try{r[t]=u.call(o,a,t,i)}catch(f){return this.reject(f)}}this.promise._follow(s(r)),this.items=this.result=this.callback=this.promise=null},t.prototype.map=function(t,n){return c(this,t,!0,n)},t.map=function(t,n,r){return c(t,n,!1,r)}}},{"./errors.js":9,"./util.js":37}],17:[function(e,t,n){t.exports=function(t){function u(e){throw e}function a(e,t){var n=this,a=e===void 0?s(n,t,null):i(n,t,null,e);a===o&&r.invokeLater(u,void 0,a.e)}function f(e,t){var n=this,i=s(n,t,e);i===o&&r.invokeLater(u,void 0,i.e)}var n=e("./util.js"),r=e("./async.js"),i=n.tryCatch2,s=n.tryCatch1,o=n.errorObj;t.prototype.nodeify=function(t){return typeof t=="function"&&this._then(a,f,void 0,t,this._isBound()?this._boundTo:null),this}}},{"./async.js":2,"./util.js":37}],18:[function(e,t,n){t.exports=function(t,n){var r=e("./util.js"),i=e("./async.js"),s=e("./errors.js"),o=r.tryCatch1,u=r.errorObj;t.prototype.progressed=function(t){return this._then(void 0,void 0,t,void 0,void 0)},t.prototype._progress=function(t){if(this._isFollowingOrFulfilledOrRejected())return;this._progressUnchecked(t)},t.prototype._progressHandlerAt=function(t){return t===0?this._progressHandler0:this[t+2-5]},t.prototype._doProgressWith=function(n){var r=n.value,i=n.handler,a=n.promise,f=n.receiver;this._pushContext();var l=o(i,f,r);this._popContext();if(l===u){if(l.e!=null&&l.e.name!=="StopProgressPropagation"){var c=s.canAttach(l.e)?l.e:new Error(l.e+"");a._attachExtraTrace(c),a._progress(l.e)}}else l instanceof t?l._then(a._progress,null,null,a,void 0):a._progress(l)},t.prototype._progressUnchecked=function(r){if(!this.isPending())return;var s=this._length(),o=this._progress;for(var u=0;u<s;u+=5){var a=this._progressHandlerAt(u),f=this._promiseAt(u);if(!(f instanceof t)){var l=this._receiverAt(u);typeof a=="function"?a.call(l,r,f):l instanceof t&&l._isProxied()?l._progressUnchecked(r):n(l,f)&&l._promiseProgressed(r,f);continue}typeof a=="function"?i.invoke(this._doProgressWith,this,{handler:a,promise:f,receiver:this._receiverAt(u),value:r}):i.invoke(o,f,r)}}}},{"./async.js":2,"./errors.js":9,"./util.js":37}],19:[function(e,t,n){t.exports=function(){function L(e){return e===void 0?!1:e instanceof O}function A(e,t){return e instanceof a?t>=0:!1}function O(e){if(typeof e!="function")throw new y("the promise constructor requires a resolver function");if(this.constructor!==O)throw new y("the promise constructor cannot be invoked directly");this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,this._settledValue=void 0,this._boundTo=void 0,e!==s&&this._resolveFromResolver(e)}function M(e,t){return H(e,a,t===!0&&e._isBound()?e._boundTo:void 0).promise()}function H(e,t,n){var r=null;return h(e)?r=e:(r=O._cast(e,void 0),r!==e?r._setBoundTo(n):L(r)||(r=null)),r!==null?new t(r,n):{promise:function(){return C("expecting an array, a promise or a thenable")}}}var t=e("./global.js"),n=e("./util.js"),r=e("./async.js"),i=e("./errors.js"),s=function(){},o={},u={e:null},a=e("./promise_array.js")(O,s),f=e("./captured_trace.js")(),l=e("./catch_filter.js")(u),c=e("./promise_resolver.js"),h=n.isArray,p=n.errorObj,d=n.tryCatch1,v=n.tryCatch2,m=n.tryCatchApply,g=i.RangeError,y=i.TypeError,b=i.CancellationError,w=i.TimeoutError,E=i.RejectionError,S=i.originatesFromRejection,x=i.markAsOriginatingFromRejection,T=i.canAttach,N=n.thrower,C=e("./errors_api_rejection")(O),k=function(){return new y("circular promise resolution chain")};O.prototype.bind=function(t){var n=new O(s);return n._setTrace(this),n._follow(this),n._setBoundTo(t),this._cancellable()&&(n._setCancellable(),n._cancellationParent=this),n},O.prototype.toString=function(){return"[object Promise]"},O.prototype.caught=O.prototype["catch"]=function(t){var n=arguments.length;if(n>1){var i=new Array(n-1),s=0,o;for(o=0;o<n-1;++o){var u=arguments[o];if(typeof u!="function"){var a=new y("A catch filter must be an error constructor or a filter function");this._attachExtraTrace(a),r.invoke(this._reject,this,a);return}i[s++]=u}i.length=s,t=arguments[o],this._resetTrace();var f=new l(i,t,this);return this._then(void 0,f.doFilter,void 0,f,void 0)}return this._then(void 0,t,void 0,void 0,void 0)},O.prototype.then=function(t,n,r){return this._then(t,n,r,void 0,void 0)},O.prototype.done=function(t,n,r){var i=this._then(t,n,r,void 0,void 0);i._setIsFinal()},O.prototype.spread=function(t,n){return this._then(t,n,void 0,o,void 0)},O.prototype.isCancellable=function(){return!this.isResolved()&&this._cancellable()},O.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this._settledValue,t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this._settledValue,t.isRejected=!0),t},O.prototype.all=function(){return M(this,!0)},O.is=L,O.all=function(t){return M(t,!1)},O.join=function(){var t=arguments.length,n=new Array(t);for(var r=0;r<t;++r)n[r]=arguments[r];return H(n,a,void 0).promise()},O.resolve=O.fulfilled=function(t){var n=new O(s);return n._setTrace(void 0),n._tryFollow(t)?n:(n._cleanValues(),n._setFulfilled(),n._settledValue=t,n)},O.reject=O.rejected=function(t){var n=new O(s);n._setTrace(void 0),x(t),n._cleanValues(),n._setRejected(),n._settledValue=t;if(!T(t)){var r=new Error(t+"");n._setCarriedStackTrace(r)}return n._ensurePossibleRejectionHandled(),n},O.prototype.error=function(t){return this.caught(S,t)},O.prototype._resolveFromSyncValue=function(t){if(t===p)this._cleanValues(),this._setRejected(),this._settledValue=t.e,this._ensurePossibleRejectionHandled();else{var n=O._cast(t,void 0);n instanceof O?this._follow(n):(this._cleanValues(),this._setFulfilled(),this._settledValue=t)}},O.method=function(t){if(typeof t!="function")throw new y("fn must be a function");return function(){var n;switch(arguments.length){case 0:n=d(t,this,void 0);break;case 1:n=d(t,this,arguments[0]);break;case 2:n=v(t,this,arguments[0],arguments[1]);break;default:var r=arguments.length,i=new Array(r);for(var o=0;o<r;++o)i[o]=arguments[o];n=m(t,i,this)}var u=new O(s);return u._setTrace(void 0),u._resolveFromSyncValue(n),u}},O.attempt=O["try"]=function(t,n,r){if(typeof t!="function")return C("fn must be a function");var i=h(n)?m(t,n,r):d(t,r,n),o=new O(s);return o._setTrace(void 0),o._resolveFromSyncValue(i),o},O.defer=O.pending=function(){var t=new O(s);return t._setTrace(void 0),new c(t)},O.bind=function(t){var n=new O(s);return n._setTrace(void 0),n._setFulfilled(),n._setBoundTo(t),n},O.cast=function(t){var n=O._cast(t,void 0);return n instanceof O?n:O.resolve(n)},O.onPossiblyUnhandledRejection=function(t){f.possiblyUnhandledRejection=typeof t=="function"?t:void 0};var _;O.onUnhandledRejectionHandled=function(t){_=typeof t=="function"?t:void 0};var D=!(typeof process=="undefined"||typeof process.execPath!="string"||typeof process.env!="object"||!process.env.BLUEBIRD_DEBUG&&process.env.NODE_ENV!=="development");O.longStackTraces=function(){if(r.haveItemsQueued()&&D===!1)throw new Error("cannot enable long stack traces after promises have been created");D=f.isSupported()},O.hasLongStackTraces=function(){return D&&f.isSupported()},O.prototype._setProxyHandlers=function(t,n){var r=this._length();r>=524282&&(r=0,this._setLength(0));if(r===0)this._promise0=n,this._receiver0=t;else{var i=r-5;this[i+3]=n,this[i+4]=t,this[i+0]=this[i+1]=this[i+2]=void 0}this._setLength(r+5)},O.prototype._proxyPromiseArray=function(t,n){this._setProxyHandlers(t,n)},O.prototype._proxyPromise=function(t){t._setProxied(),this._setProxyHandlers(t,-1)},O.prototype._then=function(t,n,i,o,u){var a=u!==void 0,f=a?u:new O(s);if(D&&!a){var l=this._peekContext()===this._traceParent;f._traceParent=l?this._traceParent:this,f._setTrace(this)}!a&&this._isBound()&&f._setBoundTo(this._boundTo);var c=this._addCallbacks(t,n,i,f,o);return!a&&this._cancellable()&&(f._setCancellable(),f._cancellationParent=this),this.isResolved()&&r.invoke(this._queueSettleAt,this,c),f},O.prototype._length=function(){return this._bitField&524287},O.prototype._isFollowingOrFulfilledOrRejected=function(){return(this._bitField&939524096)>0},O.prototype._isFollowing=function(){return(this._bitField&536870912)===536870912},O.prototype._setLength=function(t){this._bitField=this._bitField&-524288|t&524287},O.prototype._setFulfilled=function(){this._bitField=this._bitField|268435456},O.prototype._setRejected=function(){this._bitField=this._bitField|134217728},O.prototype._setFollowing=function(){this._bitField=this._bitField|536870912},O.prototype._setIsFinal=function(){this._bitField=this._bitField|33554432},O.prototype._isFinal=function(){return(this._bitField&33554432)>0},O.prototype._cancellable=function(){return(this._bitField&67108864)>0},O.prototype._setCancellable=function(){this._bitField=this._bitField|67108864},O.prototype._unsetCancellable=function(){this._bitField=this._bitField&-67108865},O.prototype._setRejectionIsUnhandled=function(){this._bitField=this._bitField|2097152},O.prototype._unsetRejectionIsUnhandled=function(){this._bitField=this._bitField&-2097153,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},O.prototype._isRejectionUnhandled=function(){return(this._bitField&2097152)>0},O.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=this._bitField|524288},O.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=this._bitField&-524289},O.prototype._isUnhandledRejectionNotified=function(){return(this._bitField&524288)>0},O.prototype._setCarriedStackTrace=function(t){this._bitField=this._bitField|1048576,this._fulfillmentHandler0=t},O.prototype._unsetCarriedStackTrace=function(){this._bitField=this._bitField&-1048577,this._fulfillmentHandler0=void 0},O.prototype._isCarryingStackTrace=function(){return(this._bitField&1048576)>0},O.prototype._getCarriedStackTrace=function(){return this._isCarryingStackTrace()?this._fulfillmentHandler0:void 0},O.prototype._receiverAt=function(t){var n;return t===0?n=this._receiver0:n=this[t+4-5],this._isBound()&&n===void 0?this._boundTo:n},O.prototype._promiseAt=function(t){return t===0?this._promise0:this[t+3-5]},O.prototype._fulfillmentHandlerAt=function(t){return t===0?this._fulfillmentHandler0:this[t+0-5]},O.prototype._rejectionHandlerAt=function(t){return t===0?this._rejectionHandler0:this[t+1-5]},O.prototype._unsetAt=function(t){t===0?(this._rejectionHandler0=this._progressHandler0=this._promise0=this._receiver0=void 0,this._isCarryingStackTrace()||(this._fulfillmentHandler0=void 0)):this[t-5+0]=this[t-5+1]=this[t-5+2]=this[t-5+3]=this[t-5+4]=void 0},O.prototype._resolveFromResolver=function(t){function r(e){if(n._tryFollow(e))return;n._fulfill(e)}function i(e){var t=T(e)?e:new Error(e+"");n._attachExtraTrace(t),x(e),n._reject(e,t===e?void 0:t)}var n=this;this._setTrace(void 0),this._pushContext();var s=v(t,void 0,r,i);this._popContext();if(s!==void 0&&s===p){var o=s.e,u=T(o)?o:new Error(o+"");n._reject(o,u)}},O.prototype._addCallbacks=function(t,n,r,i,s){var o=this._length();o>=524282&&(o=0,this._setLength(0));if(o===0)this._promise0=i,s!==void 0&&(this._receiver0=s),typeof t=="function"&&!this._isCarryingStackTrace()&&(this._fulfillmentHandler0=t),typeof n=="function"&&(this._rejectionHandler0=n),typeof r=="function"&&(this._progressHandler0=r);else{var u=o-5;this[u+3]=i,this[u+4]=s,this[u+0]=typeof t=="function"?t:void 0,this[u+1]=typeof n=="function"?n:void 0,this[u+2]=typeof r=="function"?r:void 0}return this._setLength(o+5),o},O.prototype._setBoundTo=function(t){t!==void 0?(this._bitField=this._bitField|8388608,this._boundTo=t):this._bitField=this._bitField&-8388609},O.prototype._isBound=function(){return(this._bitField&8388608)===8388608},O.prototype._spreadSlowCase=function(t,n,r,i){var s=H(r,a,i).promise()._then(function(){return t.apply(i,arguments)},void 0,void 0,o,void 0);n._follow(s)},O.prototype._callSpread=function(t,n,r,i){var s=this._isBound()?this._boundTo:void 0;if(h(r))for(var o=0,u=r.length;o<u;++o)if(L(O._cast(r[o],void 0))){this._spreadSlowCase(t,n,r,s);return}return i&&n._pushContext(),m(t,r,s)},O.prototype._callHandler=function(t,n,r,i,s){var u;return n===o&&!this.isRejected()?u=this._callSpread(t,r,i,s):(s&&r._pushContext(),u=d(t,n,i)),s&&r._popContext(),u},O.prototype._settlePromiseFromHandler=function(t,n,r,i){if(!L(i)){t.call(n,r,i);return}var s=D,o=this._callHandler(t,n,i,r,s);if(i._isFollowing())return;if(o===p||o===i||o===u){var a=o===i?k():o.e,f=T(a)?a:new Error(a+"");o!==u&&i._attachExtraTrace(f),i._rejectUnchecked(a,f)}else{var l=O._cast(o,i);if(L(l)){if(l.isRejected()&&!l._isCarryingStackTrace()&&!T(l._settledValue)){var f=new Error(l._settledValue+"");i._attachExtraTrace(f),l._setCarriedStackTrace(f)}i._follow(l),l._cancellable()&&(i._cancellationParent=l,i._setCancellable())}else i._fulfillUnchecked(o)}},O.prototype._follow=function(t){this._setFollowing(),t.isPending()?(t._cancellable()&&(this._cancellationParent=t,this._setCancellable()),t._proxyPromise(this)):t.isFulfilled()?this._fulfillUnchecked(t._settledValue):this._rejectUnchecked(t._settledValue,t._getCarriedStackTrace()),t._isRejectionUnhandled()&&t._unsetRejectionIsUnhandled(),D&&t._traceParent==null&&(t._traceParent=this)},O.prototype._tryFollow=function(t){if(this._isFollowingOrFulfilledOrRejected()||t===this)return!1;var n=O._cast(t,void 0);return L(n)?(this._follow(n),!0):!1},O.prototype._resetTrace=function(){D&&(this._trace=new f(this._peekContext()===void 0))},O.prototype._setTrace=function(t){if(D){var n=this._peekContext();this._traceParent=n;var r=n===void 0;t!==void 0&&t._traceParent===n?this._trace=t._trace:this._trace=new f(r)}return this},O.prototype._attachExtraTrace=function(t){if(D){var n=this,r=t.stack;r=typeof r=="string"?r.split("\n"):[];var i=1;while(n!=null&&n._trace!=null)r=f.combine(r,n._trace.stack.split("\n")),n=n._traceParent;var s=Error.stackTraceLimit+i,o=r.length;o>s&&(r.length=s),r.length<=i?t.stack="(No stack trace)":t.stack=r.join("\n")}},O.prototype._cleanValues=function(){this._cancellable()&&(this._cancellationParent=void 0)},O.prototype._fulfill=function(t){if(this._isFollowingOrFulfilledOrRejected())return;this._fulfillUnchecked(t)},O.prototype._reject=function(t,n){if(this._isFollowingOrFulfilledOrRejected())return;this._rejectUnchecked(t,n)},O.prototype._settlePromiseAt=function(t){var n=this.isFulfilled()?this._fulfillmentHandlerAt(t):this._rejectionHandlerAt(t),r=this._settledValue,i=this._receiverAt(t),s=this._promiseAt(t);if(typeof n=="function")this._settlePromiseFromHandler(n,i,r,s);else{var o=!1,u=this.isFulfilled();i!==void 0&&(i instanceof O&&i._isProxied()?(i._unsetProxied(),u?i._fulfillUnchecked(r):i._rejectUnchecked(r,this._getCarriedStackTrace()),o=!0):A(i,s)&&(u?i._promiseFulfilled(r,s):i._promiseRejected(r,s),o=!0)),o||(u?s._fulfill(r):s._reject(r,this._getCarriedStackTrace()))}t>=256&&this._queueGC()},O.prototype._isProxied=function(){return(this._bitField&4194304)===4194304},O.prototype._setProxied=function(){this._bitField=this._bitField|4194304},O.prototype._unsetProxied=function(){this._bitField=this._bitField&-4194305},O.prototype._isGcQueued=function(){return(this._bitField&-1073741824)===-1073741824},O.prototype._setGcQueued=function(){this._bitField=this._bitField|-1073741824},O.prototype._unsetGcQueued=function(){this._bitField=this._bitField&1073741823},O.prototype._queueGC=function(){if(this._isGcQueued())return;this._setGcQueued(),r.invokeLater(this._gc,this,void 0)},O.prototype._gc=function(){var t=this._length();this._unsetAt(0);for(var n=0;n<t;n++)delete this[n];this._setLength(0),this._unsetGcQueued()},O.prototype._queueSettleAt=function(t){this._isRejectionUnhandled()&&this._unsetRejectionIsUnhandled(),r.invoke(this._settlePromiseAt,this,t)},O.prototype._fulfillUnchecked=function(t){if(!this.isPending())return;if(t===this){var n=k();return this._attachExtraTrace(n),this._rejectUnchecked(n,void 0)}this._cleanValues(),this._setFulfilled(),this._settledValue=t;var i=this._length();i>0&&r.invoke(this._settlePromises,this,i)},O.prototype._rejectUncheckedCheckError=function(t){var n=T(t)?t:new Error(t+"");this._rejectUnchecked(t,n===t?void 0:n)},O.prototype._rejectUnchecked=function(t,n){if(!this.isPending())return;if(t===this){var i=k();return this._attachExtraTrace(i),this._rejectUnchecked(i)}this._cleanValues(),this._setRejected(),this._settledValue=t;if(this._isFinal()){r.invokeLater(N,void 0,n===void 0?t:n);return}var s=this._length();n!==void 0&&this._setCarriedStackTrace(n),s>0?r.invoke(this._rejectPromises,this,null):this._ensurePossibleRejectionHandled()},O.prototype._rejectPromises=function(){this._settlePromises(),this._unsetCarriedStackTrace()},O.prototype._settlePromises=function(){var t=this._length();for(var n=0;n<t;n+=5)this._settlePromiseAt(n)},O.prototype._ensurePossibleRejectionHandled=function(){this._setRejectionIsUnhandled(),f.possiblyUnhandledRejection!==void 0&&r.invokeLater(this._notifyUnhandledRejection,this,void 0)},O.prototype._notifyUnhandledRejectionIsHandled=function(){typeof _=="function"&&r.invokeLater(_,void 0,this)},O.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue,n=this._getCarriedStackTrace();this._setUnhandledRejectionIsNotified(),n!==void 0&&(this._unsetCarriedStackTrace(),t=n),typeof f.possiblyUnhandledRejection=="function"&&f.possiblyUnhandledRejection(t,this)}};var P=[];O.prototype._peekContext=function(){var t=P.length-1;return t>=0?P[t]:void 0},O.prototype._pushContext=function(){if(!D)return;P.push(this)},O.prototype._popContext=function(){if(!D)return;P.pop()};var B=t.Promise;return O.noConflict=function(){return t.Promise===O&&(t.Promise=B),O},f.isSupported()||(O.longStackTraces=function(){},D=!1),O._makeSelfResolutionError=k,e("./finally.js")(O,u),e("./direct_resolve.js")(O),e("./thenables.js")(O,s),e("./synchronous_inspection.js")(O),O.RangeError=g,O.CancellationError=b,O.TimeoutError=w,O.TypeError=y,O.RejectionError=E,n.toFastProperties(O),n.toFastProperties(O.prototype),e("./timers.js")(O,s),e("./any.js")(O,H,a),e("./race.js")(O,s),e("./call_get.js")(O),e("./filter.js")(O,H,a,C),e("./generators.js")(O,C,s),e("./map.js")(O,a,s,C),e("./nodeify.js")(O),e("./promisify.js")(O,s),e("./props.js")(O,a),e("./reduce.js")(O,H,a,C,s),e("./settle.js")(O,H,a),e("./some.js")(O,H,a,C),e("./progress.js")(O,A),e("./cancel.js")(O,s),O.prototype=O.prototype,O}},{"./any.js":1,"./async.js":2,"./call_get.js":4,"./cancel.js":5,"./captured_trace.js":6,"./catch_filter.js":7,"./direct_resolve.js":8,"./errors.js":9,"./errors_api_rejection":10,"./filter.js":12,"./finally.js":13,"./generators.js":14,"./global.js":15,"./map.js":16,"./nodeify.js":17,"./progress.js":18,"./promise_array.js":20,"./promise_resolver.js":21,"./promisify.js":23,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":32,"./synchronous_inspection.js":34,"./thenables.js":35,"./timers.js":36,"./util.js":37}],20:[function(e,t,n){t.exports=function(t,n){function a(e){switch(e){case-1:return void 0;case-2:return[];case-3:return{}}}function f(e,r){var i=this._promise=new t(n),s=void 0;e instanceof t&&(s=e,e._cancellable()&&(i._setCancellable(),i._cancellationParent=e),e._isBound()&&i._setBoundTo(r)),i._setTrace(s),this._values=e,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var r=e("./errors.js").canAttach,i=e("./util.js"),s=e("./async.js"),o={}.hasOwnProperty,u=i.isArray;return f.PropertiesPromiseArray=function(){},f.prototype.length=function(){return this._length},f.prototype.promise=function(){return this._promise},f.prototype._init=function(n,r){var i=this._values;if(i instanceof t){if(!i.isFulfilled()){if(i.isPending()){i._then(this._init,this._reject,void 0,this,r);return}i._unsetRejectionIsUnhandled(),this._reject(i._settledValue);return}i=i._settledValue;if(!u(i)){var l=new t.TypeError("expecting an array, a promise or a thenable");this.__hardReject__(l);return}this._values=i}if(i.length===0){this._resolve(a(r));return}var c=i.length,h=c,p;this instanceof f.PropertiesPromiseArray?p=this._values:p=new Array(c);var d=!1;for(var v=0;v<c;++v){var m=i[v];if(m===void 0&&!o.call(i,v)){h--;continue}var g=t._cast(m,void 0);g instanceof t?g.isPending()?g._proxyPromiseArray(this,v):(g._unsetRejectionIsUnhandled(),d=!0):d=!0,p[v]=g}if(h===0){r===-2?this._resolve(p):this._resolve(a(r));return}this._values=p,this._length=h;if(d){var y=h===c?this._scanDirectValues:this._scanDirectValuesHoled;s.invoke(y,this,c)}},f.prototype._settlePromiseAt=function(n){var r=this._values[n];r instanceof t?r.isFulfilled()?this._promiseFulfilled(r._settledValue,n):r.isRejected()&&this._promiseRejected(r._settledValue,n):this._promiseFulfilled(r,n)},f.prototype._scanDirectValuesHoled=function(t){for(var n=0;n<t;++n){if(this._isResolved())break;o.call(this._values,n)&&this._settlePromiseAt(n)}},f.prototype._scanDirectValues=function(t){for(var n=0;n<t;++n){if(this._isResolved())break;this._settlePromiseAt(n)}},f.prototype._isResolved=function(){return this._values===null},f.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},f.prototype.__hardReject__=f.prototype._reject=function(t){this._values=null;var n=r(t)?t:new Error(t+"");this._promise._attachExtraTrace(n),this._promise._reject(t,n)},f.prototype._promiseProgressed=function(t,n){if(this._isResolved())return;this._promise._progress({index:n,value:t})},f.prototype._promiseFulfilled=function(t,n){if(this._isResolved())return;this._values[n]=t;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},f.prototype._promiseRejected=function(t,n){if(this._isResolved())return;this._totalResolved++,this._reject(t)},f}},{"./async.js":2,"./errors.js":9,"./util.js":37}],21:[function(e,t,n){function c(e){return e instanceof Error&&l.getPrototypeOf(e)===Error.prototype}function h(e){var t;return c(e)?t=new u(e):t=e,s.markAsOriginatingFromRejection(t),t}function p(e){function t(t,n){if(e===null)return;if(t){var r=h(i(t));e._attachExtraTrace(r),e._reject(r)}else if(arguments.length>2){var s=arguments.length,o=new Array(s-1);for(var u=1;u<s;++u)o[u-1]=arguments[u];e._fulfill(o)}else e._fulfill(n);e=null}return t}var r=e("./util.js"),i=r.maybeWrapAsError,s=e("./errors.js"),o=s.TimeoutError,u=s.RejectionError,a=e("./async.js"),f=r.haveGetters,l=e("./es5.js"),d;f?d=function(t){this.promise=t}:d=function(t){this.promise=t,this.asCallback=p(t),this.callback=this.asCallback};if(f){var v={get:function(){return p(this.promise)}};l.defineProperty(d.prototype,"asCallback",v),l.defineProperty(d.prototype,"callback",v)}d._nodebackForPromise=p,d.prototype.toString=function(){return"[object PromiseResolver]"},d.prototype.resolve=d.prototype.fulfill=function(t){var n=this.promise;if(n===void 0||n._tryFollow===void 0)throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.");if(n._tryFollow(t))return;a.invoke(n._fulfill,n,t)},d.prototype.reject=function(t){var n=this.promise;if(n===void 0||n._attachExtraTrace===void 0)throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.");s.markAsOriginatingFromRejection(t);var r=s.canAttach(t)?t:new Error(t+"");n._attachExtraTrace(r),a.invoke(n._reject,n,t),r!==t&&a.invoke(this._setCarriedStackTrace,this,r)},d.prototype.progress=function(t){a.invoke(this.promise._progress,this.promise,t)},d.prototype.cancel=function(){a.invoke(this.promise.cancel,this.promise,void 0)},d.prototype.timeout=function(){this.reject(new o("timeout"))},d.prototype.isResolved=function(){return this.promise.isResolved()},d.prototype.toJSON=function(){return this.promise.toJSON()},d.prototype._setCarriedStackTrace=function(t){this.promise.isRejected()&&this.promise._setCarriedStackTrace(t)},t.exports=d},{"./async.js":2,"./errors.js":9,"./es5.js":11,"./util.js":37}],22:[function(e,t,n){t.exports=function(t,n){function l(e){var n=f,r=u,i=t,s=n.length;for(var o=0;o<s;++o){var c=a(n[o],void 0,e);if(c===r)return i.reject(r.e);var h=i._cast(c,l,void 0);if(h instanceof i)return h}return null}function c(e,r){var i=this._promise=new t(n);i._setTrace(void 0),this._generatorFunction=e,this._receiver=r,this._generator=void 0}var r=e("./errors.js"),i=r.TypeError,s=e("./util.js"),o=s.isArray,u=s.errorObj,a=s.tryCatch1,f=[];return c.prototype.promise=function(){return this._promise},c.prototype._run=function(){this._generator=this._generatorFunction.call(this._receiver),this._receiver=this._generatorFunction=void 0,this._next(void 0)},c.prototype._continue=function h(e){if(e===u){this._generator=void 0;var n=r.canAttach(e.e)?e.e:new Error(e.e+"");this._promise._attachExtraTrace(n),this._promise._reject(e.e,n);return}var s=e.value;if(e.done===!0)this._generator=void 0,this._promise._tryFollow(s)||this._promise._fulfill(s);else{var a=t._cast(s,h,void 0);if(!(a instanceof t)){o(a)?a=t.all(a):a=l(a);if(a===null){this._throw(new i("A value was yielded that could not be treated as a promise"));return}}a._then(this._next,this._throw,void 0,this,null)}},c.prototype._throw=function(t){r.canAttach(t)&&this._promise._attachExtraTrace(t),this._continue(a(this._generator["throw"],this._generator,t))},c.prototype._next=function(t){this._continue(a(this._generator.next,this._generator,t))},c.addYieldHandler=function(t){if(typeof t!="function")throw new i("fn must be a function");f.push(t)},c}},{"./errors.js":9,"./util.js":37}],23:[function(e,t,n){t.exports=function(t,n){function p(e){return e.__isPromisified__===!0}function d(e,t){var n=t+"Async"in e;return n?p(e[t+"Async"]):!1}function v(e){for(var t=0;t<e.length;t+=2){var n=e[t];if(h.test(n)){var r=n.replace(h,"");for(var i=0;i<e.length;i+=2)if(e[i]===r)throw new c("Cannot promisify an API that has normal methods with Async-suffix")}}}function g(e){var t=[e],n=Math.max(0,e-1-5);for(var r=e-1;r>=n;--r){if(r===e)continue;t.push(r)}for(var r=e+1;r<=5;++r)t.push(r);return t}function y(e){var t=new Array(e);for(var n=0;n<t.length;++n)t[n]="_arg"+n;return t.join(", ")}function b(e){return typeof e.length=="number"?Math.max(Math.min(e.length,1024),0):0}function E(e){return w.test(e)?"."+e:"['"+e.replace(/(['\\])/g,"\\$1")+"']"}function S(e,i,s,f){function p(t){var n=new Array(t);for(var s=0,o=n.length;s<o;++s)n[s]="arguments["+s+"]";var u=t>0?",":"";return typeof e=="string"&&i===r?"this"+E(e)+"("+n.join(",")+u+" fn);"+"break;":(i===void 0?"callback("+n.join(",")+u+" fn);":"callback.call("+(i===r?"this":"receiver")+", "+n.join(",")+u+" fn);")+"break;"}function d(){var t="";for(var n=0;n<c.length;++n)t+="case "+c[n]+":"+p(c[n]);return t+="default: var args = new Array(len + 1);var i = 0;for (var i = 0; i < len; ++i) {    args[i] = arguments[i];}args[i] = fn;"+(typeof e=="string"?"this"+E(e)+".apply(":"callback.apply(")+(i===r?"this":"receiver")+", args); break;",t}var l=Math.max(0,b(f)-1),c=g(l),h=typeof s=="string"?s+"Async":"promisified";return w.test(h)||(h="promisified"),(new Function("Promise","callback","receiver","withAppended","maybeWrapAsError","nodebackForPromise","INTERNAL","var ret = function "+h+"("+y(l)+') {"use strict";'+"var len = arguments.length;"+"var promise = new Promise(INTERNAL);"+"promise._setTrace(void 0);"+"var fn = nodebackForPromise(promise);"+"try {"+"switch(len) {"+d()+"}"+"}"+"catch(e){ "+"var wrapped = maybeWrapAsError(e);"+"promise._attachExtraTrace(wrapped);"+"promise._reject(wrapped);"+"}"+"return promise;"+""+"}; ret.__isPromisified__ = true; return ret;"))(t,e,i,u,a,o,n)}function x(e,i){function s(){var s=i;i===r&&(s=this),typeof e=="string"&&(e=s[e]);var f=new t(n);f._setTrace(void 0);var l=o(f);try{e.apply(s,u(arguments,l))}catch(c){var h=a(c);f._attachExtraTrace(h),f._reject(h)}return f}return s.__isPromisified__=!0,s}function N(e,t,n){if(n){var s=m(e);for(var o=0,u=s.length;o<u;o+=2){var a=s[o],f=s[o+1],l=a+"Async";e[l]=T(a,r,a,f)}return i.toFastProperties(e),e}return T(e,t,void 0,e)}var r={},i=e("./util.js"),s=e("./es5.js"),o=e("./promise_resolver.js")._nodebackForPromise,u=i.withAppended,a=i.maybeWrapAsError,f=i.canEvaluate,l=i.deprecated,c=e("./errors").TypeError,h=new RegExp("Async$"),m=function(){if(s.isES5){var e=Object.create,t=Object.getOwnPropertyDescriptor;return function(n){var r=[],i=e(null),o=n;while(n!==null){var u=s.keys(n);for(var a=0,f=u.length;a<f;++a){var l=u[a];if(i[l])continue;i[l]=!0;var c=t(n,l);c!=null&&typeof c.value=="function"&&!p(c.value)&&!d(o,l)&&r.push(l,c.value)}n=s.getPrototypeOf(n)}return v(r),r}}return function(e){var t=[];for(var n in e){var r=e[n];typeof r=="function"&&!p(r)&&!d(e,n)&&t.push(n,r)}return v(t),t}}(),w=/^[a-z$_][a-z$_0-9]*$/i,T=f?S:x;t.promisify=function(t,n){if(typeof t=="object"&&t!==null)return l("Promise.promisify for promisifying entire objects is deprecated. Use Promise.promisifyAll instead."),N(t,n,!0);if(typeof t!="function")throw new c("fn must be a function");return p(t)?t:N(t,arguments.length<2?r:n,!1)},t.promisifyAll=function(t){if(typeof t!="function"&&typeof t!="object")throw new c("the target of promisifyAll must be an object or a function");return N(t,void 0,!0)}}},{"./errors":9,"./es5.js":11,"./promise_resolver.js":21,"./util.js":37}],24:[function(e,t,n){t.exports=function(t,n){function o(e,t){var n=s.keys(e),r=new Array(n.length);for(var i=0,o=r.length;i<o;++i)r[i]=e[n[i]];this.constructor$(r,t);if(!this._isResolved())for(var i=0,o=n.length;i<o;++i)r.push(n[i])}var r=e("./util.js"),i=r.inherits,s=e("./es5.js");return i(o,n),o.prototype._init=function(){this._init$(void 0,-3)},o.prototype._promiseFulfilled=function(t,n){if(this._isResolved())return;this._values[n]=t;var r=++this._totalResolved;if(r>=this._length){var i={},s=this.length();for(var o=0,u=this.length();o<u;++o)i[this._values[o+s]]=this._values[o];this._resolve(i)}},o.prototype._promiseProgressed=function(t,n){if(this._isResolved())return;this._promise._progress({key:this._values[n+this.length()],value:t})},n.PropertiesPromiseArray=o,o}},{"./es5.js":11,"./util.js":37}],25:[function(e,t,n){t.exports=function(t,n){function u(e,n){var i,u=t._cast(e,void 0);return o(u)?(u instanceof t?i=u._then(t.props,void 0,void 0,void 0,void 0):(i=(new r(u,n===!0&&u._isBound()?u._boundTo:void 0)).promise(),n=!1),n===!0&&u._isBound()&&i._setBoundTo(u._boundTo),i):s("cannot await properties of a non-object")}var r=e("./properties_promise_array.js")(t,n),i=e("./util.js"),s=e("./errors_api_rejection")(t),o=i.isObject;t.prototype.props=function(){return u(this,!0)},t.props=function(t){return u(t,!1)}}},{"./errors_api_rejection":10,"./properties_promise_array.js":24,"./util.js":37}],26:[function(e,t,n){function r(e,t,n,r,i){for(var s=0;s<i;++s)n[s+r]=e[s+t]}function i(e){return e>>>=0,e-=1,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e+1}function s(e){return typeof e!="number"?16:i(Math.min(Math.max(16,e),1073741824))}function o(e){this._capacity=s(e),this._length=0,this._front=0,this._makeCapacity()}o.prototype._willBeOverCapacity=function(t){return this._capacity<t},o.prototype._pushOne=function(t){var n=this.length();this._checkCapacity(n+1);var r=this._front+n&this._capacity-1;this[r]=t,this._length=n+1},o.prototype.push=function(t,n,r){var i=this.length()+3;if(this._willBeOverCapacity(i)){this._pushOne(t),this._pushOne(n),this._pushOne(r);return}var s=this._front+i-3;this._checkCapacity(i);var o=this._capacity-1;this[s+0&o]=t,this[s+1&o]=n,this[s+2&o]=r,this._length=i},o.prototype.shift=function(){var t=this._front,n=this[t];return this[t]=void 0,this._front=t+1&this._capacity-1,this._length--,n},o.prototype.length=function(){return this._length},o.prototype._makeCapacity=function(){var t=this._capacity;for(var n=0;n<t;++n)this[n]=void 0},o.prototype._checkCapacity=function(t){this._capacity<t&&this._resizeTo(this._capacity<<3)},o.prototype._resizeTo=function(t){var n=this._front,i=this._capacity,s=new Array(i),o=this.length();r(this,0,s,0,i),this._capacity=t,this._makeCapacity(),this._front=0;if(n+o<=i)r(s,n,this,0,o);else{var u=o-(n+o&i-1);r(s,n,this,0,u),r(s,0,this,u,o-u)}},t.exports=o},{}],27:[function(e,t,n){t.exports=function(t,n){function u(e,u){var a=t._cast(e,void 0);if(a instanceof t)return s(a);if(!i(e))return r("expecting an array, a promise or a thenable");var f=new t(n);f._setTrace(u),u!==void 0&&(u._isBound()&&f._setBoundTo(u._boundTo),u._cancellable()&&(f._setCancellable(),f._cancellationParent=u));var l=f._fulfill,c=f._reject;for(var h=0,p=e.length;h<p;++h){var d=e[h];if(d===void 0&&!o.call(e,h))continue;t.cast(d)._then(l,c,void 0,f,null)}return f}var r=e("./errors_api_rejection.js")(t),i=e("./util.js").isArray,s=function(t){return t.then(function(e){return u(e,t)})},o={}.hasOwnProperty;t.race=function(t){return u(t,void 0)},t.prototype.race=function(){return u(this,void 0)}}},{"./errors_api_rejection.js":10,"./util.js":37}],28:[function(e,t,n){t.exports=function(e,t,n,r,i){function s(t,n,r,s,o){this.promise=new e(i),this.index=n,this.length=s.length,this.items=s,this.callback=t,this.receiver=o,this.accum=r}function o(e,t){var n=this,r=void 0;typeof n!="function"&&(r=n.receiver,n=n.fn);var i=e.length,o=void 0,u=0;t!==void 0?(o=t,u=0):(u=1,i>0&&(o=e[0]));var a=u;if(a>=i)return o;var f=new s(n,a,o,e,r);return f.iterate(),f.promise}function u(e){var t=this.fn,n=this.initialValue;return o.call(t,e,n)}function a(e,t,n,r){return n._then(function(n){return f(e,t,n,r)},void 0,void 0,void 0,void 0)}function f(i,s,f,l){if(typeof s!="function")return r("fn must be a function");l===!0&&i._isBound()&&(s={fn:s,receiver:i._boundTo});if(f!==void 0){if(f instanceof e){if(!f.isFulfilled())return a(i,s,f,l);f=f._settledValue}return t(i,n,l===!0&&i._isBound()?i._boundTo:void 0).promise()._then(u,void 0,void 0,{fn:s,initialValue:f},void 0)}return t(i,n,l===!0&&i._isBound()?i._boundTo:void 0).promise()._then(o,void 0,void 0,s,void 0)}s.prototype.reject=function(t){this.promise._reject(t)},s.prototype.fulfill=function(t,n){this.accum=t,this.index=n+1,this.iterate()},s.prototype.iterate=function(){var n=this.index,r=this.length,i=this.items,s=this.accum,o=this.receiver,u=this.callback;for(;n<r;++n){s=u.call(o,s,i[n],n,r),s=e._cast(s,void 0);if(s instanceof e){s._then(this.fulfill,this.reject,void 0,this,n);return}}this.promise._fulfill(s)},e.reduce=function(t,n,r){return f(t,n,r,!1)},e.prototype.reduce=function(t,n){return f(this,t,n,!0)}}},{}],29:[function(e,t,n){var r=e("./global.js"),i;if(typeof process!="undefined"&&process!==null&&typeof process.cwd=="function"&&typeof process.nextTick=="function"&&typeof process.version=="string")i=function(t){process.nextTick(t)};else if(typeof r.MutationObserver!="function"&&typeof r.WebkitMutationObserver!="function"&&typeof r.WebKitMutationObserver!="function"||typeof document=="undefined"||typeof document.createElement!="function")if(typeof r.postMessage=="function"&&typeof r.importScripts!="function"&&typeof r.addEventListener=="function"&&typeof r.removeEventListener=="function"){var s="bluebird_message_key_"+Math.random();i=function(){function t(t){if(t.source===r&&t.data===s){var n=e;e=void 0,n()}}var e=void 0;return r.addEventListener("message",t,!1),function(n){e=n,r.postMessage(s,"*")}}()}else typeof r.MessageChannel=="function"?i=function(){var e=void 0,t=new r.MessageChannel;return t.port1.onmessage=function(){var n=e;e=void 0,n()},function(r){e=r,t.port2.postMessage(null)}}():r.setTimeout?i=function(t){setTimeout(t,4)}:i=function(t){t()};else i=function(){var e=r.MutationObserver||r.WebkitMutationObserver||r.WebKitMutationObserver,t=document.createElement("div"),n=void 0,i=new e(function(){var t=n;n=void 0,t()});return i.observe(t,{attributes:!0}),function(r){n=r,t.setAttribute("class","foo")}}();t.exports=i},{"./global.js":15}],30:[function(e,t,n){t.exports=function(t,n,r){function s(e,t){return n(e,i,t===!0&&e._isBound()?e._boundTo:void 0).promise()}var i=e("./settled_promise_array.js")(t,r);t.settle=function(t){return s(t,!1)},t.prototype.settle=function(){return s(this,!0)}}},{"./settled_promise_array.js":31}],31:[function(e,t,n){t.exports=function(t,n){function o(e,t){this.constructor$(e,t)}var r=t.PromiseInspection,i=e("./util.js"),s=i.inherits;return s(o,n),o.prototype._promiseResolved=function(t,n){this._values[t]=n;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},o.prototype._promiseFulfilled=function(t,n){if(this._isResolved())return;var i=new r;i._bitField=268435456,i._settledValue=t,this._promiseResolved(n,i)},o.prototype._promiseRejected=function(t,n){if(this._isResolved())return;var i=new r;i._bitField=134217728,i._settledValue=t,this._promiseResolved(n,i)},o}},{"./util.js":37}],32:[function(e,t,n){t.exports=function(t,n,r,i){function o(e,t,r){if((t|0)!==t||t<0)return i("expecting a positive integer");var o=n(e,s,r===!0&&e._isBound()?e._boundTo:void 0),u=o.promise();return u.isRejected()?u:(o.setHowMany(t),o.init(),u)}var s=e("./some_promise_array.js")(r);t.some=function(t,n){return o(t,n,!1)},t.prototype.some=function(t){return o(this,t,!0)}}},{"./some_promise_array.js":33}],33:[function(e,t,n){t.exports=function(t){function o(e,t){this.constructor$(e,t),this._howMany=0,this._unwrap=!1,this._initialized=!1}var n=e("./util.js"),r=e("./errors.js").RangeError,i=n.inherits,s=n.isArray;return i(o,t),o.prototype._init=function(){if(!this._initialized)return;if(this._howMany===0){this._resolve([]);return}this._init$(void 0,-2);var t=s(this._values);this._holes=t?this._values.length-this.length():0;if(!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()){var n="(Promise.some) input array contains less than "+this._howMany+" promises";this._reject(new r(n))}},o.prototype.init=function(){this._initialized=!0,this._init()},o.prototype.setUnwrap=function(){this._unwrap=!0},o.prototype.howMany=function(){return this._howMany},o.prototype.setHowMany=function(t){if(this._isResolved())return;this._howMany=t},o.prototype._promiseFulfilled=function(t){if(this._isResolved())return;this._addFulfilled(t),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),this.howMany()===1&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values))},o.prototype._promiseRejected=function(t){if(this._isResolved())return;this._addRejected(t),this.howMany()>this._canPossiblyFulfill()&&(this._values.length===this.length()?this._reject([]):this._reject(this._values.slice(this.length()+this._holes)))},o.prototype._fulfilled=function(){return this._totalResolved},o.prototype._rejected=function(){return this._values.length-this.length()-this._holes},o.prototype._addRejected=function(t){this._values.push(t)},o.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},o.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},o}},{"./errors.js":9,"./util.js":37}],34:[function(e,t,n){t.exports=function(e){function t(e){e!==void 0?(this._bitField=e._bitField,this._settledValue=e.isResolved()?e._settledValue:void 0):(this._bitField=0,this._settledValue=void 0)}t.prototype.isFulfilled=e.prototype.isFulfilled=function(){return(this._bitField&268435456)>0},t.prototype.isRejected=e.prototype.isRejected=function(){return(this._bitField&134217728)>0},t.prototype.isPending=e.prototype.isPending=function(){return(this._bitField&402653184)===0},t.prototype.value=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise");return this._settledValue},t.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise");return this._settledValue},t.prototype.isResolved=e.prototype.isResolved=function(){return(this._bitField&402653184)>0},e.prototype.inspect=function(){return new t(this)},e.PromiseInspection=t}},{}],35:[function(e,t,n){t.exports=function(t,n){function u(e){try{return e.then}catch(t){return s.e=t,s}}function a(e,r){if(o(e)){if(e instanceof t)return e;if(l(e)){var a=new t(n);return a._setTrace(void 0),e._then(a._fulfillUnchecked,a._rejectUncheckedCheckError,a._progressUnchecked,a,null),a._setFollowing(),a}var f=u(e);if(f===s)return r!==void 0&&i(f.e)&&r._attachExtraTrace(f.e),t.reject(f.e);if(typeof f=="function")return c(e,f,r)}return e}function l(e){return f.call(e,"_promise0")}function c(e,n,r){function f(n){if(o)return;o=!0;if(e===n){var i=t._makeSelfResolutionError();r!==void 0&&r._attachExtraTrace(i),s.promise._reject(i,void 0);return}s.resolve(n)}function l(e){if(o)return;o=!0;var t=i(e)?e:new Error(e+"");r!==void 0&&r._attachExtraTrace(t),s.promise._reject(e,t)}function c(e){if(o)return;var t=s.promise;typeof t._progress=="function"&&t._progress(e)}var s=t.defer(),o=!1;try{n.call(e,f,l,c)}catch(u){if(!o){o=!0;var a=i(u)?u:new Error(u+"");r!==void 0&&r._attachExtraTrace(a),s.promise._reject(u,a)}}return s.promise}var r=e("./util.js"),i=e("./errors.js").canAttach,s=r.errorObj,o=r.isObject,f={}.hasOwnProperty;t._cast=a}},{"./errors.js":9,"./util.js":37}],36:[function(e,t,n){var r=e("./global.js"),i=function(e,t){var n=arguments.length,i=new Array(n-2);for(var s=2;s<n;++s)i[s-2]=arguments[s];r.setTimeout(function(){e.apply(void 0,i)},t)};t.exports=function(t,n){var r=e("./util.js"),s=e("./errors.js"),o=e("./errors_api_rejection")(t),u=t.TimeoutError,a=function(t,n,r){if(!t.isPending())return;typeof n!="string"&&(n="operation timed out after "+r+" ms");var i=new u(n);s.markAsOriginatingFromRejection(i),t._attachExtraTrace(i),t._rejectUnchecked(i)},f=function(t,n){n._fulfill(t)},l=t.delay=function(r,s){s===void 0&&(s=r,r=void 0),s=+s;var o=t._cast(r,void 0),u=new t(n);return o instanceof t?(o._isBound()&&u._setBoundTo(o._boundTo),o._cancellable()&&(u._setCancellable(),u._cancellationParent=o),u._setTrace(o),u._follow(o),u.then(function(e){return t.delay(e,s)})):(u._setTrace(void 0),i(f,s,r,u),u)};t.prototype.delay=function(t){return l(this,t)},t.prototype.timeout=function(r,s){r=+r;var o=new t(n);return o._setTrace(this),this._isBound()&&o._setBoundTo(this._boundTo),this._cancellable()&&(o._setCancellable(),o._cancellationParent=this),o._follow(this),i(a,r,o,s,r),o}}},{"./errors.js":9,"./errors_api_rejection":10,"./global.js":15,"./util.js":37}],37:[function(require,module,exports){function deprecated(e){typeof console!="undefined"&&console!==null&&typeof console.warn=="function"&&console.warn("Bluebird: "+e)}function tryCatch1(e,t,n){try{return e.call(t,n)}catch(r){return errorObj.e=r,errorObj}}function tryCatch2(e,t,n,r){try{return e.call(t,n,r)}catch(i){return errorObj.e=i,errorObj}}function tryCatchApply(e,t,n){try{return e.apply(n,t)}catch(r){return errorObj.e=r,errorObj}}function asString(e){return typeof e=="string"?e:""+e}function isPrimitive(e){return e==null||e===!0||e===!1||typeof e=="string"||typeof e=="number"}function isObject(e){return!isPrimitive(e)}function maybeWrapAsError(e){return isPrimitive(e)?new Error(asString(e)):e}function withAppended(e,t){var n=e.length,r=new Array(n+1),i;for(i=0;i<n;++i)r[i]=e[i];return r[i]=t,r}function notEnumerableProp(e,t,n){if(isPrimitive(e))return e;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return es5.defineProperty(e,t,r),e}function thrower(e){throw e}function toFastProperties(obj){function f(){}return f.prototype=obj,f}var global=require("./global.js"),es5=require("./es5.js"),haveGetters=function(){try{var e={};return es5.defineProperty(e,"f",{get:function(){return 3}}),e.f===3}catch(t){return!1}}(),canEvaluate=function(){return typeof window!="undefined"&&window!==null&&typeof window.document!="undefined"&&typeof navigator!="undefined"&&navigator!==null&&typeof navigator.appName=="string"&&window===global?!1:!0}(),errorObj={e:{}},inherits=function(e,t){function r(){this.constructor=e,this.constructor$=t;for(var r in t.prototype)n.call(t.prototype,r)&&r.charAt(r.length-1)!=="$"&&(this[r+"$"]=t.prototype[r])}var n={}.hasOwnProperty;return r.prototype=t.prototype,e.prototype=new r,e.prototype},wrapsPrimitiveReceiver=function(){return this!=="string"}.call("string"),ret={thrower:thrower,isArray:es5.isArray,haveGetters:haveGetters,notEnumerableProp:notEnumerableProp,isPrimitive:isPrimitive,isObject:isObject,canEvaluate:canEvaluate,deprecated:deprecated,errorObj:errorObj,tryCatch1:tryCatch1,tryCatch2:tryCatch2,tryCatchApply:tryCatchApply,inherits:inherits,withAppended:withAppended,asString:asString,maybeWrapAsError:maybeWrapAsError,wrapsPrimitiveReceiver:wrapsPrimitiveReceiver,toFastProperties:toFastProperties};module.exports=ret},{"./es5.js":11,"./global.js":15}]},{},[3])(3)}),function(){function mt(e,t){var n=-1,r=t.length,i=Array(r);while(++n<r)i[n]=e[t[n]];return i}function gt(e,t){if(e!==t){if(e>t||typeof e=="undefined")return 1;if(e<t||typeof t=="undefined")return-1}return 0}function yt(e,t,n){var r=(n||0)-1,i=e?e.length:0;while(++r<i)if(e[r]===t)return r;return-1}function bt(e,t){return e.has(t)?0:-1}function wt(e){return e.charCodeAt(0)}function Et(e,t){var n=-1,r=e.length;while(++n<r)if(t.indexOf(e.charAt(n))<0)break;return n}function St(e,t){var n=e.length;while(n--)if(t.indexOf(e.charAt(n))<0)break;return n}function xt(e,t){return gt(e.criteria,t.criteria)||e.index-t.index}function Tt(e,t){var n=-1,r=e.criteria,i=t.criteria,s=r.length;while(++n<s){var o=gt(r[n],i[n]);if(o)return o}return e.index-t.index}function Nt(e){return function(t){var n=-1,r=t!=null&&String(t).replace(T,Ct).match(A),i=r?r.length:0,s="";while(++n<i)s=e(s,r[n],n,r);return s}}function Ct(e){return at[e]}function kt(e){return ot[e]}function Lt(e){return"\\"+lt[e]}function At(e){var t=-1,n=e.length;while(++t<n){var r=e.charCodeAt(t);if(!(r<=160&&r>=9&&r<=13||r==32||r==160||r==5760||r==6158||r>=8192&&(r<=8202||r==8232||r==8233||r==8239||r==8287||r==12288||r==65279)))break}return t}function Ot(e){var t=e.length;while(t--){var n=e.charCodeAt(t);if(!(n<=160&&n>=9&&n<=13||n==32||n==160||n==5760||n==6158||n>=8192&&(n<=8202||n==8232||n==8233||n==8239||n==8287||n==12288||n==65279)))break}return t}function Mt(e){return ut[e]}function _t(T){function on(e){return e&&typeof e=="object"&&!Ui(e)&&qt.call(e,"__wrapped__")?e:new un(e)}function un(e,t){this.__chain__=!!t,this.__wrapped__=e}function fn(e,t){var n=-1,r=e?e.length:0;while(++n<r)if(t(e[n],n,e)===!1)break;return e}function ln(e,t){var n=e?e.length:0;while(n--)if(t(e[n],n,e)===!1)break;return e}function cn(e,t){var n=-1,r=e?e.length>>>0:0,i=A(r);while(++n<r)i[n]=t(e[n],n,e);return i}function hn(e,t){return typeof e=="undefined"?t:e}function pn(e,t,n,r){return!qt.call(r,n)||typeof e=="undefined"?t:e}function dn(e,t,n){var r=-1,i=ss(t),s=i.length;while(++r<s){var o=i[r];e[o]=n?n(e[o],t[o],o,e,t):t[o]}return e}function vn(e){function s(){if(r){var e=arguments.length,o=A(e);while(e--)o[e]=arguments[e];o=qn(r,i,o)}if(this instanceof s){var u=gn(t.prototype),a=t.apply(u,o||arguments);return Gi(a)?a:u}return t.apply(n,o||arguments)}var t=e[0],n=e[3],r=e[4],i=e[6];return Gn(s,e),s}function mn(t,n,r,i,s){var o=r?r(t):e;if(typeof o!="undefined")return o;var u=Gi(t);if(!u)return t;var a=Ct.call(t);if(!rt[a])return t;var f=t.constructor;a==R&&!(Qi(f)&&f instanceof f)&&(f=X);switch(a){case V:return t.slice(0);case H:case B:return new f(+t);case j:return new f(t.message);case $:case J:case K:case Q:case G:case Y:case Z:case et:case tt:return t.subarray(0);case q:case W:return new f(t);case U:return o=f(t.source,E.exec(t)),o.lastIndex=t.lastIndex,o}var l=Ui(t);if(n){i||(i=[]),s||(s=[]);var c=i.length;while(c--)if(i[c]==t)return s[c];o=l?f(t.length):f()}else o=l?br(t):dn({},t);return l&&(qt.call(t,"index")&&(o.index=t.index),qt.call(t,"input")&&(o.input=t.input)),n?(i.push(t),s.push(o),(l?fn:Ln)(t,function(t,u){var a=r?r(t,u):e;o[u]=typeof a=="undefined"?mn(t,n,null,i,s):a}),o):o}function gn(e){return Gi(e)?Kt(e):{}}function yn(e,n,r){if(typeof e!="function")return Hs;if(typeof n!="undefined"&&"prototype"in e){var i=e[a];if(typeof i=="undefined"){an.funcNames&&(i=!e.name),i=i||!an.funcDecomp;if(!i){var s=Ft.call(e);an.funcNames||(i=!S.test(s)),i||(i=k.test(s),Gn(e,i))}}if(i===!1||i!==!0&&i[1]&t)return e;switch(r){case 1:return function(t){return e.call(n,t)};case 3:return function(t,r,i){return e.call(n,t,r,i)};case 4:return function(t,r,i,s){return e.call(n,t,r,i,s)};case 5:return function(t,r,i,s,o){return e.call(n,t,r,i,s,o)}}return ci(e,n)}return e}function bn(e){function w(){var e=arguments.length,r=e,i=A(e);while(r--)i[r]=arguments[r];c&&(i=qn(c,p,i)),h&&(i=Rn(h,d,i));if(g){var E=$n(i);e-=E.length;if(e<f){a|=s,a&=~o,y||(a&=~(t|n));var S=en(f-e,0);return bn([u,a,S,l,i,null,E])}}var x=v?l:this;m&&(u=x[b]);if(this instanceof w){x=gn(u.prototype);var T=u.apply(x,i);return Gi(T)?T:x}return u.apply(x,i)}var u=e[0],a=e[1],f=e[2],l=e[3],c=e[4],h=e[5],p=e[6],d=e[7],v=a&t,m=a&n,g=a&r,y=a&i,b=u;return Gn(w,e),w}function wn(e,t){var n=e?e.length:0;if(!n)return[];var r=-1,i=Jn(),s=i===yt,o=s&&Wn&&t&&t.length>=200,u=s&&!o,a=[],f=t?t.length:0;o&&(i=bt,t=Wn(t));e:while(++r<n){var l=e[r];if(u){var c=f;while(c--)if(t[c]===l)continue e;a.push(l)}else i(t,l)<0&&a.push(l)}return a}function En(e,t){var n=-1,r=e,i=e?e.length:0;if(typeof i=="number"&&i>-1&&i<=vt){while(++n<i)if(t(r[n],n,e)===!1)break}else Ln(e,t);return e}function Sn(e,t){var n=e,r=e?e.length:0;if(typeof r=="number"&&r>-1&&r<=vt){while(r--)if(t(n[r],r,e)===!1)break}else An(e,t);return e}function xn(e,t,n,r){var i;return n(e,function(e,n,s){if(t(e,n,s))return i=r?n:e,!1}),i}function Tn(e,t,n,r){var i=(r||0)-1,s=e?e.length:0,o=[];while(++i<s){var u=e[i];if(u&&typeof u=="object"&&typeof u.length=="number"&&(Ui(u)||Ri(u))){t||(u=Tn(u,t,n));var a=-1,f=u.length,l=o.length;o.length+=f;while(++a<f)o[l++]=u[a]}else n||o.push(u)}return o}function Nn(e,t,n){var r=-1,i=n(e),s=i.length;while(++r<s){var o=i[r];if(t(e[o],o,e)===!1)break}return e}function Cn(e,t,n){var r=n(e),i=r.length;while(i--){var s=r[i];if(t(e[s],s,e)===!1)break}return e}function kn(e,t){return Nn(e,t,os)}function Ln(e,t){return Nn(e,t,ss)}function An(e,t){return Cn(e,t,ss)}function On(e,t){var n=-1,r=t(e),i=r.length,s=[];while(++n<i){var o=r[n];Qi(e[o])&&s.push(o)}return s.sort()}function Mn(t,n,r,i,s,o){var u=r&&!s?r(t,n):e;if(typeof u!="undefined")return!!u;if(t===n)return t!==0||1/t==1/n;var a=typeof t,f=typeof n;if(t===t&&(t==null||n==null||a!="function"&&a!="object"&&f!="function"&&f!="object"))return!1;var l=Ct.call(t),c=Ct.call(n),h=l==D,p=c==D;h&&(l=R),p&&(c=R);if(l!=c)return!1;switch(l){case H:case B:return+t==+n;case q:return t!=+t?n!=+n:t==0?1/t==1/n:t==+n;case j:case U:case W:return t==ut(n)}var d=nt[l];if(!d){if(l!=R)return!1;var v=qt.call(t,"__wrapped__"),m=qt.call(n,"__wrapped__");if(v||m)return Mn(v?t.__wrapped__:t,m?n.__wrapped__:n,r,i,s,o);var g=!h&&qt.call(t,"constructor"),y=!p&&qt.call(n,"constructor");if(g!=y)return!1;if(!g){var b=h?X:t.constructor,w=p?X:n.constructor;if(b!=w&&!(Qi(b)&&b instanceof b&&Qi(w)&&w instanceof w)&&"constructor"in t&&"constructor"in n)return!1}}s||(s=[]),o||(o=[]);var E=s.length;while(E--)if(s[E]==t)return o[E]==n;u=!0,s.push(t),o.push(n);if(d){var S=n.length;E=t.length,u=S==E;if(u||i){var x=-1;while(++x<S){var T=n[x];if(i){var N=-1;while(++N<E){u=Mn(t[N],T,r,i,s,o);if(u)break}}else{var C=t[x];u=r?r(C,T,x):e,u=typeof u=="undefined"?Mn(C,T,r,i,s,o):!!u}if(!u)break}}}else{var k=0;kn(n,function(n,a,f){if(qt.call(f,a)){u=!1,k++;if(qt.call(t,a)){var l=t[a];u=r?r(l,n,a):e,u=typeof u=="undefined"?Mn(l,n,r,i,s,o):!!u}return u}}),u&&!i&&kn(t,function(e,t,n){if(qt.call(n,t))return u=--k>-1,u})}return s.pop(),o.pop(),u}function _n(t,n,r){var i=-1,s=typeof n=="function",o=t&&t.length,u=A(o<0?0:o>>>0);return En(t,function(t){var o=s?n:t!=null&&t[n];u[++i]=o?o.apply(t,r):e}),u}function Dn(t,n,r,i,s){return(Kn(n)?fn:Ln)(n,function(n,o,u){var a=n&&Kn(n),f=n&&ts(n),l=t[o];if(!a&&!f){h=r?r(l,n,o,t,u):e,typeof h=="undefined"&&(h=n),typeof h!="undefined"&&(l=h),t[o]=l;return}i||(i=[]),s||(s=[]);var c=i.length;while(c--)if(i[c]==n){t[o]=s[c];return}var h=r?r(l,n,o,t,u):e,p=typeof h!="undefined";p?l=h:l=a?Ui(l)?l:[]:ts(l)?l:{},i.push(n),s.push(l),p||Dn(l,n,r,i,s),t[o]=l}),t}function Pn(e,t){var n={};if(typeof t=="function")return kn(e,function(e,r,i){t(e,r,i)&&(n[r]=e)}),n;var r=-1,i=t,s=i.length;while(++r<s){var o=i[r];o in e&&(n[o]=e[o])}return n}function Hn(e,t){var n=t.length,r=mt(e,t);t.sort(gt);while(n--){var i=parseFloat(t[n]);if(i!=s&&i>-1&&i%1==0){var s=i;Xt.call(e,i,1)}}return r}function Bn(e,t){return e+jt(sn()*(t-e+1))}function jn(e,t,n){var r=e?e.length:0;if(!r)return[];var i=-1,s=Jn(),o=!t&&s===yt,u=o&&Wn&&r>=200,a=o&&!u,f=[];if(u){var l=Wn();s=bt}else l=n&&!t?[]:f;e:while(++i<r){var c=e[i],h=n?n(c,i,e):c;if(a){var p=l.length;while(p--)if(l[p]===h)continue e;n&&l.push(h),f.push(c)}else if(t){if(!i||l!==h)l=h,f.push(c)}else s(l,h)<0&&((n||u)&&l.push(h),f.push(c))}return f}function Fn(e,t){var n=-1,r=t(e),i=r.length,s=A(i);while(++n<i)s[n]=e[r[n]];return s}function In(t,n,r,i){i=i?"\n/*\n//# sourceURL="+i+"\n*/":"";try{var s=I(n,"return "+t+i).apply(e,r);s.source=t}catch(o){throw o.source=t,o}return s}function qn(e,t,n){var r=t.length,i=-1,s=en(n.length-r,0),o=-1,u=e.length,a=A(s+u);while(++o<u)a[o]=e[o];while(++i<r)a[t[i]]=n[i];while(s--)a[o++]=n[i++];return a}function Rn(e,t,n){var r=-1,i=t.length,s=-1,o=en(n.length-i,0),u=-1,a=e.length,f=A(o+a);while(++s<o)f[s]=n[s];var l=s;while(++u<a)f[l+u]=e[u];while(++r<i)f[l+t[r]]=n[s++];return f}function Un(e,t){return function(n,r,i){var s=t?t():{};r=on.createCallback(r,i,3);var o=-1,u=n?n.length:0;if(typeof u=="number"&&u>-1&&u<=vt)while(++o<u){var a=n[o];e(s,a,r(a,o,n),n)}else En(n,function(t,n,i){e(s,t,r(t,n,i),i)});return s}}function zn(e){return function(t){var n=arguments,r=n.length;if(!t||r<2)return t;var i=typeof n[2];(i=="number"||i=="string")&&n[3]&&n[3][n[2]]===n[1]&&(r=2);if(r>3&&typeof n[r-2]=="function")var s=yn(n[--r-1],n[r--],5);else r>2&&typeof n[r-1]=="function"&&(s=n[--r]);var o=0;while(++o<r)e(t,n[o],s);return t}}function Xn(e,t,n){var r=e.length;t=+t;if(r>=t||!Gt(t))return"";var i=t-r;return n=n==null?" ":ut(n),Ts(n,Ht(i/n.length)).slice(0,i)}function Vn(e,r,u,l,c,h){var p=r&t,d=r&n,v=r&s,m=r&o;if(!d&&!Qi(e))throw new at(f);v&&!c.length&&(r&=~s,v=c=!1),m&&!h.length&&(r&=~o,m=h=!1);var g=!d&&e[a];if(g&&g!==!0){g=br(g),g[4]&&(g[4]=br(g[4])),g[5]&&(g[5]=br(g[5])),typeof u=="number"&&(g[2]=u);var y=g[1]&t;return p&&!y&&(g[3]=l),!p&&y&&(r|=i),v&&(g[4]?Rt.apply(g[4],c):g[4]=c),m&&(g[5]?Vt.apply(g[5],h):g[5]=h),g[1]|=r,Vn.apply(null,g)}if(v)var b=$n(c);if(m)var w=$n(h);return u==null&&(u=d?0:e.length),u=en(u,0),g=[e,r,u,l,c,h,b,w],r==t||r==(t|s)?vn(g):bn(g)}function $n(e){var t=-1,n=e.length,r=[];while(++t<n)e[t]===on&&r.push(t);return r}function Jn(){var e=on.indexOf||lr;return e===lr?yt:e}function Kn(e){return e&&typeof e=="object"&&typeof e.length=="number"&&nt[Ct.call(e)]||!1}function Qn(e){return typeof e=="function"&&Pt.test(Ft.call(e))}function Yn(e){var t,n;return!e||Ct.call(e)!=R||!qt.call(e,"constructor")&&(t=e.constructor,Qi(t)&&!(t instanceof t))?!1:(kn(e,function(e,t){n=t}),typeof n=="undefined"||qt.call(e,n))}function Zn(e){var t,n=-1,r=os(e),i=r.length,s=i&&e.length,o=s-1,u=[],a=typeof s=="number"&&s>0&&(Ui(e)||an.nonEnumArgs&&Ri(e));while(++n<i){var f=r[n];(a&&(t=+f,t>-1&&t<=o&&t%1==0)||qt.call(e,f))&&u.push(f)}return u}function er(e){var t=-1,n=e?e.length:0,r=0,i=[];while(++t<n){var s=e[t];s&&(i[r++]=s)}return i}function tr(){var e=-1,t=arguments.length;while(++e<t){var n=arguments[e];if(Ui(n)||Ri(n))break}return wn(arguments[e],Tn(arguments,!0,!0,++e))}function or(e,t,n){var r=-1,i=e?e.length:0;t=on.createCallback(t,n,3);while(++r<i)if(t(e[r],r,e))return r;return-1}function ur(e,t,n){var r=e?e.length:0;t=on.createCallback(t,n,3);while(r--)if(t(e[r],r,e))return r;return-1}function ar(t,n,r){if(typeof n!="number"&&n!=null){var i=-1,s=t?t.length:0,o=0;n=on.createCallback(n,r,3);while(++i<s&&n(t[i],i,t))o++}else{o=n;if(o==null||r)return t?t[0]:e}return br(t,0,o<0?0:o)}function fr(e,t,n,r){var i=e?e.length:0;if(!i)return[];var s=typeof t;return s!="boolean"&&t!=null&&(r=n,n=t,t=!1,(s=="number"||s=="string")&&r&&r[n]===e&&(n=null)),n!=null&&(e=Kr(e,n,r)),Tn(e,t)}function lr(e,t,n){var r=e?e.length:0;if(typeof n=="number")n=n<0?en(r+n,0):n||0;else if(n){var i=wr(e,t);return r&&e[i]===t?i:-1}return yt(e,t,n)}function cr(e,t,n){var r=e?e.length:0;if(typeof t!="number"&&t!=null){var i=r,s=0;t=on.createCallback(t,n,3);while(i--&&t(e[i],i,e))s++}else s=t==null||n?1:t;return s=r-(s||0),br(e,0,s<0?0:s)}function hr(){var e=[],t=-1,n=arguments.length,r=[],i=Jn(),s=Wn&&i===yt;while(++t<n){var o=arguments[t];if(Ui(o)||Ri(o))e.push(o),r.push(s&&o.length>=120&&Wn(t&&o))}n=e.length;var u=e[0],a=-1,f=u?u.length:0,l=[],c=r[0];e:while(++a<f){o=u[a];if((c?bt(c,o):i(l,o))<0){t=n;while(--t){var h=r[t];if((h?bt(h,o):i(e[t],o))<0)continue e}c&&c.push(o),l.push(o)}}return l}function pr(t,n,r){var i=t?t.length:0;if(typeof n!="number"&&n!=null){var s=i,o=0;n=on.createCallback(n,r,3);while(s--&&n(t[s],s,t))o++}else{o=n;if(o==null||r)return t?t[i-1]:e}return o=i-(o||0),br(t,o<0?0:o)}function dr(e,t,n){var r=e?e.length:0;typeof n=="number"&&(r=(n<0?en(r+n,0):tn(n||0,r-1))+1);while(r--)if(e[r]===t)return r;return-1}function vr(e){var t=0,n=arguments.length,r=e?e.length:0;while(++t<n){var i=-1,s=arguments[t];while(++i<r)e[i]===s&&(Xt.call(e,i--,1),r--)}return e}function mr(e){return Hn(e,Tn(arguments,!0,!1,1))}function gr(e,t,n){var r=-1,i=e?e.length:0,s=[];t=on.createCallback(t,n,3);while(++r<i){var o=e[r];t(o,r,e)&&(s.push(o),Xt.call(e,r--,1),i--)}return s}function yr(e,t,n){if(typeof t!="number"&&t!=null){var r=-1,i=e?e.length:0,s=0;t=on.createCallback(t,n,3);while(++r<i&&t(e[r],r,e))s++}else t==null||n?s=1:s=t<0?0:t;return br(e,s)}function br(e,t,n){var r=-1,i=e?e.length:0;t=t==null?0:+t||0,t<0?t=en(i+t,0):t>i&&(t=i),n=typeof n=="undefined"?i:+n||0,n<0?n=en(i+n,0):n>i&&(n=i),i=t>n?0:n-t;var s=A(i);while(++r<i)s[r]=e[t+r];return s}function wr(e,t,n,r){var i=0,s=e?e.length:i;n=n?on.createCallback(n,r,1):Hs,t=n(t);while(i<s){var o=i+s>>>1;n(e[o])<t?i=o+1:s=o}return i}function Nr(){return jn(Tn(arguments,!0,!0))}function Cr(e,t,n,r){var i=e?e.length:0;if(!i)return[];var s=typeof t;return s!="boolean"&&t!=null&&(r=n,n=t,t=!1,(s=="number"||s=="string")&&r&&r[n]===e&&(n=null)),n!=null&&(n=on.createCallback(n,r,3)),jn(e,t,n)}function kr(){return wn(arguments[0],br(arguments,1))}function Lr(){var e=-1,t=arguments.length;while(++e<t){var n=arguments[e];if(Ui(n)||Ri(n))var r=r?wn(r,n).concat(wn(n,r)):n}return r?jn(r):[]}function Ar(){var e=arguments.length>1?arguments:arguments[0],t=-1,n=e?Qr(Zr(e,"length")):0,r=A(n<0?0:n);while(++t<n)r[t]=Zr(e,t);return r}function Or(e,t){var n=-1,r=e?e.length:0,i={};!t&&r&&!Ui(e[0])&&(t=[]);while(++n<r){var s=e[n];t?i[s]=t[n]:s&&(i[s[0]]=s[1])}return i}function Mr(e){return new un(e,!0)}function _r(e,t,n){return t.call(n,e),e}function Dr(){return this.__chain__=!0,this}function Pr(){return ut(this.__wrapped__)}function Hr(){return this.__wrapped__}function Br(e){return mt(e,Tn(arguments,!0,!1,1))}function jr(e,t,n){var r=e?e.length:0;typeof r=="number"&&r>-1&&r<=vt||(e=ps(e),r=e.length),typeof n=="number"?n=n<0?en(r+n,0):n||0:n=0;if(typeof e=="string"||!Ui(e)&&rs(e))return n>=r?!1:Jt?Jt.call(e,t,n):e.indexOf(t,n)>-1;var i=Jn();return i(e,t,n)>-1}function Ir(e,t,n){var r=!0;if(typeof t!="function"||typeof n!="undefined")t=on.createCallback(t,n,3);var i=-1,s=e?e.length:0;if(typeof s=="number"&&s>-1&&s<=vt){while(++i<s)if(!t(e[i],i,e))return!1}else En(e,function(e,n,i){return r=!!t(e,n,i),r});return r}function qr(e,t,n){var r=[];t=on.createCallback(t,n,3);var i=-1,s=e?e.length:0;if(typeof s=="number"&&s>-1&&s<=vt)while(++i<s){var o=e[i];t(o,i,e)&&r.push(o)}else En(e,function(e,n,i){t(e,n,i)&&r.push(e)});return r}function Rr(t,n,r){var i=t?t.length:0;if(typeof i=="number"&&i>-1&&i<=vt){var s=or(t,n,r);return s>-1?t[s]:e}return n=on.createCallback(n,r,3),xn(t,n,En)}function Ur(e,t,n){return t=on.createCallback(t,n,3),xn(e,t,Sn)}function zr(e,t){return Rr(e,Bs(t))}function Wr(e,t,n){var r=e?e.length:0;if(typeof t!="function"||typeof n!="undefined")t=yn(t,n,3);return typeof r=="number"&&r>-1&&r<=vt?fn(e,t):En(e,t)}function Xr(e,t,n){var r=e?e.length:0;if(typeof t!="function"||typeof n!="undefined")t=yn(t,n,3);return typeof r=="number"&&r>-1&&r<=vt?ln(e,t):Sn(e,t)}function Jr(e,t){return _n(e,t,br(arguments,2))}function Kr(e,t,n){var r=e?e.length:0;t=on.createCallback(t,n,3);if(typeof r=="number"&&r>-1&&r<=vt)return cn(e,t);var i=-1,s=[];return En(e,function(e,n,r){s[++i]=t(e,n,r)}),s}function Qr(e,t,n){var r=-Infinity,i=r,s=typeof t;(s=="number"||s=="string")&&n&&n[t]===e&&(t=null);if(t==null&&Ui(e)){var o=-1,u=e.length;while(++o<u){var a=e[o];a>i&&(i=a)}}else t=t==null&&rs(e)?wt:on.createCallback(t,n,3),En(e,function(e,n,s){var o=t(e,n,s);if(o>r||o===-Infinity&&o===i)r=o,i=e});return i}function Gr(e,t,n){var r=Infinity,i=r,s=typeof t;(s=="number"||s=="string")&&n&&n[t]===e&&(t=null);if(t==null&&Ui(e)){var o=-1,u=e.length;while(++o<u){var a=e[o];a<i&&(i=a)}}else t=t==null&&rs(e)?wt:on.createCallback(t,n,3),En(e,function(e,n,s){var o=t(e,n,s);if(o<r||o===Infinity&&o===i)r=o,i=e});return i}function Zr(e,t){return Kr(e,Us(t))}function ei(e,t,n,r){var i=arguments.length<3;t=on.createCallback(t,r,4);var s=-1,o=e?e.length:0;if(typeof o=="number"&&o>-1&&o<=vt){i&&o&&(n=e[++s]);while(++s<o)n=t(n,e[s],s,e)}else En(e,function(e,r,s){n=i?(i=!1,e):t(n,e,r,s)});return n}function ti(e,t,n,r){var i=arguments.length<3;return t=on.createCallback(t,r,4),Sn(e,function(e,r,s){n=i?(i=!1,e):t(n,e,r,s)}),n}function ni(e,t,n){return t=on.createCallback(t,n,3),qr(e,Ei(t))}function ri(t,n,r){t&&typeof t.length!="number"&&(t=ps(t));if(n==null||r){var i=t?t.length:0;return i>0?t[Bn(0,i-1)]:e}var s=ii(t);return s.length=tn(n<0?0:+n||0,s.length),s}function ii(e){var t=-1,n=e&&e.length,r=A(n<0?0:n>>>0);return En(e,function(e){var n=Bn(0,++t);r[t]=r[n],r[n]=e}),r}function si(e){var t=e?e.length:0;return typeof t=="number"&&t>-1&&t<=vt?t:ss(e).length}function oi(e,t,n){var r;if(typeof t!="function"||typeof n!="undefined")t=on.createCallback(t,n,3);var i=-1,s=e?e.length:0;if(typeof s=="number"&&s>-1&&s<=vt){while(++i<s)if(t(e[i],i,e))return!0}else En(e,function(e,n,i){return r=t(e,n,i),!r});return!!r}function ui(e,t,n){var r=-1,i=e&&e.length,s=t&&Ui(t),o=A(i<0?0:i>>>0);s||(t=on.createCallback(t,n,3)),En(e,function(e,n,i){if(s){var u=t.length,a=A(u);while(u--)a[u]=e[t[u]]}else a=t(e,n,i);o[++r]={criteria:a,index:r,value:e}}),i=o.length,o.sort(s?Tt:xt);while(i--)o[i]=o[i].value;return o}function ai(e){var t=e&&e.length;return typeof t=="number"&&t>-1&&t<=vt?br(e):ps(e)}function fi(e,t){return qr(e,Bs(t))}function li(e,t){if(!Qi(t))throw new at(f);return e=Gt(e=+e)?e:0,function(){if(--e<1)return t.apply(this,arguments)}}function ci(e,n){if(arguments.length<3)return Vn(e,t,null,n);if(e){var r=e[a]?e[a][2]:e.length,i=br(arguments,2);r-=i.length}return Vn(e,t|s,r,n,i)}function hi(e){return pi(e,arguments.length>1?Tn(arguments,!0,!1,1):Fi(e))}function pi(e,n){var r=-1,i=n.length;while(++r<i){var s=n[r];e[s]=Vn(e[s],t,null,e)}return e}function di(e,r){return arguments.length<3?Vn(r,t|n,null,e):Vn(r,t|n|s,null,e,br(arguments,2))}function vi(){var e=arguments,t=e.length,n=t;while(n--)if(!Qi(e[n]))throw new at(f);return function(){var n=t-1,r=e[n].apply(this,arguments);while(n--)r=e[n].call(this,r);return r}}function mi(e,t){return typeof t!="number"&&(t=+t||(e?e.length:0)),Vn(e,r,t)}function gi(t,n,r){function m(){l&&Bt(l),s&&Bt(s),s=l=c=e}function g(){var r=n-(qs()-u);if(r<=0||r>n){s&&Bt(s);var f=c;s=l=c=e,f&&(h=qs(),o=t.apply(a,i),!l&&!s&&(i=a=null))}else l=Wt(g,r)}function y(){l&&Bt(l),s=l=c=e;if(d||p!==n)h=qs(),o=t.apply(a,i),!l&&!s&&(i=a=null)}function b(){i=arguments,u=qs(),a=this,c=d&&(l||!v);if(p===!1)var e=v&&!l;else{!s&&!v&&(h=u);var r=p-(u-h),f=r<=0||r>p;f?(s&&(s=Bt(s)),h=u,o=t.apply(a,i)):s||(s=Wt(y,r))}return f&&l?l=Bt(l):!l&&n!==p&&(l=Wt(g,n)),e&&(f=!0,o=t.apply(a,i)),f&&!l&&!s&&(i=a=null),o}var i,s,o,u,a,l,c,h=0,p=!1,d=!0;if(!Qi(t))throw new at(f);n=n<0?0:n;if(r===!0){var v=!0;d=!1}else Gi(r)&&(v=r.leading,p="maxWait"in r&&en(n,+r.maxWait||0),d="trailing"in r?r.trailing:d);return b.cancel=m,b}function yi(t){if(!Qi(t))throw new at(f);var n=br(arguments,1);return Wt(function(){t.apply(e,n)},1)}function bi(t,n){if(!Qi(t))throw new at(f);var r=br(arguments,2);return Wt(function(){t.apply(e,r)},n)}function wi(e,t){if(!Qi(e)||t&&!Qi(t))throw new at(f);var n=function(){var r=t?t.apply(this,arguments):arguments[0];if(r=="__proto__")return e.apply(this,arguments);var i=n.cache;return qt.call(i,r)?i[r]:i[r]=e.apply(this,arguments)};return n.cache={},n}function Ei(e){if(!Qi(e))throw new at(f);return function(){return!e.apply(this,arguments)}}function Si(e){var t,n;if(!Qi(e))throw new at(f);return function(){return t?n:(t=!0,n=e.apply(this,arguments),e=null,n)}}function xi(e){if(e){var t=e[a]?e[a][2]:e.length,n=br(arguments,1);t-=n.length}return Vn(e,s,t,null,n)}function Ti(e){if(e){var t=e[a]?e[a][2]:e.length,n=br(arguments,1);t-=n.length}return Vn(e,o,t,null,null,n)}function Ni(e,t,n){var r=!0,i=!0;if(!Qi(e))throw new at(f);return n===!1?r=!1:Gi(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),it.leading=r,it.maxWait=+t,it.trailing=i,gi(e,t,it)}function Ci(e,t){return Vn(t,s,null,null,[e])}function Li(e,t,n,r){var i=typeof t;return i!="boolean"&&t!=null&&(r=n,n=t,t=!1,(i=="number"||i=="string")&&r&&r[n]===e&&(n=null)),n=typeof n=="function"&&yn(n,r,1),mn(e,t,n)}function Ai(e,t,n){return t=typeof t=="function"&&yn(t,n,1),mn(e,!0,t)}function Oi(e,t){var n=gn(e);return t?dn(n,t):n}function Mi(e){if(!e)return e;var t=br(arguments);return t.push(hn),ki.apply(null,t)}function _i(e,t,n){return t=on.createCallback(t,n,3),xn(e,t,Ln,!0)}function Di(e,t,n){return t=on.createCallback(t,n,3),xn(e,t,An,!0)}function Pi(e,t,n){if(typeof t!="function"||typeof n!="undefined")t=yn(t,n,3);return Nn(e,t,os)}function Hi(e,t,n){return t=yn(t,n,3),Cn(e,t,os)}function Bi(e,t,n){if(typeof t!="function"||typeof n!="undefined")t=yn(t,n,3);return Ln(e,t)}function ji(e,t,n){return t=yn(t,n,3),Cn(e,t,ss)}function Fi(e){return On(e,os)}function Ii(e,t){return e?qt.call(e,t):!1}function qi(e,t){var n=-1,r=ss(e),i=r.length,s={};while(++n<i){var o=r[n],u=e[o];t?qt.call(s,u)?s[u].push(o):s[u]=[o]:s[u]=o}return s}function Ri(e){return e&&typeof e=="object"&&typeof e.length=="number"&&Ct.call(e)==D||!1}function zi(e){return e===!0||e===!1||e&&typeof e=="object"&&Ct.call(e)==H||!1}function Wi(e){return e&&typeof e=="object"&&Ct.call(e)==B||!1}function Xi(e){return e&&typeof e=="object"&&e.nodeType===1&&Ct.call(e).indexOf("Element")>-1||!1}function Vi(e){var t=!0;if(!e)return t;var n=e.length;return n>-1&&n<=vt&&(Ui(e)||rs(e)||Ri(e)||typeof e=="object"&&Qi(e.splice))?!n:(Ln(e,function(){return t=!1,t}),t)}function $i(e,t,n,r){n=typeof n=="function"&&yn(n,r,3);if(!n){if(e===t)return e!==0||1/e==1/t;var i=typeof e,s=typeof t;if(e===e&&(e==null||t==null||i!="function"&&i!="object"&&s!="function"&&s!="object"))return!1}return Mn(e,t,n)}function Ji(e){return e&&typeof e=="object"&&Ct.call(e)==j||!1}function Ki(e){return Gt(e)&&!Yt(parseFloat(e))}function Qi(e){return typeof e=="function"||!1}function Gi(e){var t=typeof e;return t=="function"||e&&t=="object"||!1}function Yi(e){return es(e)&&e!=+e}function Zi(e){return e===null}function es(e){var t=typeof e;return t=="number"||e&&t=="object"&&Ct.call(e)==q||!1}function ns(e){return e&&typeof e=="object"&&Ct.call(e)==U||!1}function rs(e){return typeof e=="string"||e&&typeof e=="object"&&Ct.call(e)==W||!1}function is(e){return typeof e=="undefined"}function os(e){if(!Gi(e))return[];var t=e.length;t=(typeof t=="number"&&t>0&&(Ui(e)||an.nonEnumArgs&&Ri(e))&&t)>>>0;var n,r=e.constructor,i=-1,s=r&&e===r.prototype,o=t-1,u=A(t),a=t>0;while(++i<t)u[i]=ut(i);for(var f in e)(!s||f!="constructor")&&!(a&&(n=+f,n>-1&&n<=o&&n%1==0))&&u.push(f);return u}function us(e,t,n){var r={};return t=on.createCallback(t,n,3),Ln(e,function(e,n,i){r[n]=t(e,n,i)}),r}function fs(e,t,n){if(!Gi(e))return{};if(typeof t=="function")return Pn(e,Ei(on.createCallback(t,n,3)));var r=Tn(arguments,!0,!1,1),i=r.length;while(i--)r[i]=ut(r[i]);return Pn(e,wn(os(e),r))}function ls(e){var t=-1,n=ss(e),r=n.length,i=A(r);while(++t<r){var s=n[t];i[t]=[s,e[s]]}return i}function cs(e,t,n){return Gi(e)?Pn(e,typeof t=="function"?on.createCallback(t,n,3):Tn(arguments,!0,!1,1)):{}}function hs(e,t,n,r){var i=Kn(e);if(n==null)if(i)n=[];else{if(Gi(e))var s=e.constructor,o=s&&s.prototype;n=gn(o)}return t&&(t=on.createCallback(t,r,4),(i?fn:Ln)(e,function(e,r,i){return t(n,e,r,i)})),n}function ps(e){return Fn(e,ss)}function ds(e){return Fn(e,os)}function ms(e){return e==null?"":(e=ut(e),e.charAt(0).toUpperCase()+e.slice(1))}function gs(e,t,n){e=e==null?"":ut(e),t=ut(t);var r=e.length;return n=(typeof n=="undefined"?r:tn(n<0?0:+n||0,r))-t.length,n>=0&&e.indexOf(t,n)==n}function ys(e){return e==null?"":ut(e).replace(m,kt)}function bs(e){return e==null?"":ut(e).replace(C,"\\$&")}function Es(e,t,n){e=e==null?"":ut(e),t=+t;var r=e.length;if(r>=t||!Gt(t))return e;var i=(t-r)/2,s=jt(i),o=Ht(i);return n=Xn("",o,n),n.slice(0,s)+e+n}function Ss(e,t,n){return e=e==null?"":ut(e),Xn(e,t,n)+e}function xs(e,t,n){return e=e==null?"":ut(e),e+Xn(e,t,n)}function Ts(e,t){var n="";t=+t;if(t<1||e==null||!Gt(t))return n;e=ut(e);do t%2&&(n+=e),t=jt(t/2),e+=e;while(t);return n}function Cs(e,t,n){return e=e==null?"":ut(e),n=typeof n=="undefined"?0:tn(n<0?0:+n||0,e.length),e.lastIndexOf(t,n)==n}function ks(e,t,n){var r=on.templateSettings;n=ki({},n,r,pn),e=ut(e==null?"":e);var i=ki({},n.imports,r.imports,pn),s=ss(i),o=ps(i),u,a,f=0,l=n.interpolate||N,c="__p += '",v=ot((n.escape||N).source+"|"+l.source+"|"+(l===b?w:N).source+"|"+(n.evaluate||N).source+"|$","g");e.replace(v,function(t,n,r,i,s,o){return r||(r=i),c+=e.slice(f,o).replace(L,Lt),n&&(u=!0,c+="' +\n__e("+n+") +\n'"),s&&(a=!0,c+="';\n"+s+";\n__p += '"),r&&(c+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),f=o+t.length,t}),c+="';\n";var m=n.variable;m||(c="with (obj) {\n"+c+"\n}\n"),c=(a?c.replace(h,""):c).replace(p,"$1").replace(d,"$1;"),c="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(u?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+c+"return __p\n}";var g=n.sourceURL||"/lodash/template/source["+_++ +"]",y=In(c,s,o,g);return t?y(t):y}function Ls(e,t){return e=e==null?"":ut(e),e?t==null?e.slice(At(e),Ot(e)+1):(t=ut(t),e.slice(Et(e,t),St(e,t)+1)):e}function As(e,t){return e=e==null?"":ut(e),e?t==null?e.slice(At(e)):(t=ut(t),e.slice(Et(e,t))):e}function Os(e,t){return e=e==null?"":ut(e),e?t==null?e.slice(0,Ot(e)+1):(t=ut(t),e.slice(0,St(e,t)+1)):e}function Ms(e,t){var n=30,r="...";if(t&&Gi(t)){var i="separator"in t?t.separator:i;n="length"in t?+t.length||0:n,r="omission"in t?ut(t.omission):r}else t!=null&&(n=+t||0);e=e==null?"":ut(e);if(n>=e.length)return e;var s=n-r.length;if(s<1)return r;var o=e.slice(0,s);if(i==null)return o+r;if(ns(i)){if(e.slice(s).search(i)){var u,a,f=e.slice(0,s);i.global||(i=ot(i.source,(E.exec(i)||"")+"g")),i.lastIndex=0;while(u=i.exec(f))a=u.index;o=o.slice(0,a==null?s:a)}}else if(e.indexOf(i,s)!=s){var l=o.lastIndexOf(i);l>-1&&(o=o.slice(0,l))}return o+r}function _s(e){return e==null?"":(e=ut(e),e.indexOf(";")<0?e:e.replace(v,Mt))}function Ds(e){return function(){return e}}function Ps(e,t,n){var r=typeof e,i=r=="function";return!i||typeof t!="undefined"&&"prototype"in e?i||e==null?yn(e,t,n):r=="object"?Bs(e):Us(e):e}function Hs(e){return e}function Bs(e){var t=ss(e),n=t.length,r=t[0],i=n&&e[r];return n==1&&i===i&&!Gi(i)?function(e){if(!e||!qt.call(e,r))return!1;var t=e[r];return i===t&&(i!==0||1/i==1/t)}:function(r){var i=n;if(i&&!r)return!1;while(i--){var s=t[i];if(!qt.call(r,s)||!Mn(r[s],e[s],null,!0))return!1}return!0}}function js(e,t,n){var r=!0,i=t&&On(t,ss);if(!t||!n&&!i.length)n==null&&(n=t),t=e,e=this,i=On(t,ss);n===!1?r=!1:Gi(n)&&"chain"in n&&(r=n.chain);var s=-1,o=Qi(e),u=i?i.length:0;while(++s<u){var a=i[s],f=e[a]=t[a];o&&(e.prototype[a]=function(t){return function(){var n=this.__chain__,i=this.__wrapped__,s=[i];Rt.apply(s,arguments);var o=t.apply(e,s);if(r||n){if(i===o&&Gi(o))return this;o=new e(o),o.__chain__=n}return o}}(f))}return e}function Fs(){return T._=dt,this}function Is(){}function Us(t){return function(n){return n==null?e:n[t]}}function zs(e,t,n){var r=e==null,i=t==null;n==null&&(i&&typeof e=="boolean"?(n=e,e=1):typeof t=="boolean"&&(n=t,i=!0)),r&&i&&(t=1,i=!1),e=+e||0,i?(t=e,e=0):t=+t||0;if(n||e%1||t%1){var s=sn();return tn(e+s*(t-e+parseFloat("1e-"+(ut(s).length-1))),t)}return Bn(e,t)}function Ws(e,t,n){e=+e||0,n=n==null?1:+n||0,t==null?(t=e,e=0):t=+t||0;var r=-1,i=en(Ht((t-e)/(n||1)),0),s=A(i);while(++r<i)s[r]=e,e+=n;return s}function Xs(t,n,r){var i=t==null?e:t[n];return typeof i=="undefined"?r:Qi(i)?t[n]():i}function Vs(e,t,n){e=e<0?0:e>>>0,t=yn(t,n,1);var r=-1,i=A(e);while(++r<e)i[r]=t(r);return i}function $s(e){var t=++l;return ut(e==null?"":e)+t}T=T?Dt.defaults(ct.Object(),T,Dt.pick(ct,M)):ct;var A=T.Array,F=T.Date,I=T.Function,z=T.Math,X=T.Object,ot=T.RegExp,ut=T.String,at=T.TypeError,ft=A.prototype,lt=X.prototype,ht=ut.prototype,pt=(pt=T.window)&&pt.document,dt=T._,vt=z.pow(2,53)-1,Ct=lt.toString,Pt=ot("^"+bs(Ct).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ht=z.ceil,Bt=T.clearTimeout,jt=z.floor,Ft=I.prototype.toString,It=Qn(It=X.getPrototypeOf)&&It,qt=lt.hasOwnProperty,Rt=ft.push,Ut=lt.propertyIsEnumerable,zt=Qn(zt=T.Set)&&zt,Wt=T.setTimeout,Xt=ft.splice,Vt=ft.unshift,$t=function(){try{var e={},t=Qn(t=X.defineProperty)&&t,n=t(e,e,e)&&t}catch(r){}return n}(),Jt=Qn(Jt=ht.contains)&&Jt,Kt=Qn(Kt=X.create)&&Kt,Qt=Qn(Qt=A.isArray)&&Qt,Gt=T.isFinite,Yt=T.isNaN,Zt=Qn(Zt=X.keys)&&Zt,en=z.max,tn=z.min,nn=Qn(nn=F.now)&&nn,rn=T.parseInt,sn=z.random;un.prototype=on.prototype;var an=on.support={};(function(e){for(var t in arguments);an.funcDecomp=!Qn(T.WinRTError)&&k.test(_t),an.funcNames=typeof I.name=="string";try{an.dom=pt.createDocumentFragment().nodeType===11}catch(n){an.dom=!1}try{an.nonEnumArgs=t!="1"||!qt.call(arguments,t)||!Ut.call(arguments,t)}catch(n){an.nonEnumArgs=!0}})(0,0),on.templateSettings={escape:g,evaluate:y,interpolate:b,variable:"",imports:{_:on}},Kt||(gn=function(){function e(){}return function(t){if(Gi(t)){e.prototype=t;var n=new e;e.prototype=null}return n||T.Object()}}());var Wn=zt&&function(e){var t=new zt,n=e?e.length:0;t.push=t.add;while(n--)t.push(e[n]);return t},Gn=$t?function(e,t){st.value=t,$t(e,a,st),st.value=null}:Is,nr=yr,rr=cr,ir=cr,sr=yr,Er=ar,Sr=pr,xr=pr,Tr=ar,Fr=Un(function(e,t,n){qt.call(e,n)?e[n]++:e[n]=1}),Vr=Un(function(e,t,n){qt.call(e,n)?e[n].push(t):e[n]=[t]}),$r=Un(function(e,t,n){e[n]=t}),Yr=Un(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]}),ki=zn(dn),Ui=Qt||function(e){return e&&typeof e=="object"&&typeof e.length=="number"&&Ct.call(e)==P||!1};an.dom||(Xi=function(e){return e&&typeof e=="object"&&e.nodeType===1&&!ts(e)||!1});var ts=It?function(e){if(!e||Ct.call(e)!=R)return!1;var t=e.valueOf,n=Qn(t)&&(n=It(t))&&It(n);return n?e==n||It(e)==n:Yn(e)}:Yn,ss=Zt?function(e){var t=e&&e.constructor,n=e?e.length:0;return typeof n=="number"&&n>0||t&&e===t.prototype?Zn(e):Gi(e)?Zt(e):[]}:Zn,as=zn(Dn),vs=Nt(function(e,t,n){return!n&&c.test(t)?e+t.toLowerCase():e+(t.charAt(0)[n?"toUpperCase":"toLowerCase"]()+t.slice(1))}),ws=Nt(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),Ns=Nt(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}),qs=nn||function(){return(new F).getTime()},Rs=rn(O+"08")==8?rn:function(e,t){return e=Ls(e),rn(e,+t||(x.test(e)?16:10))};return on.after=li,on.assign=ki,on.at=Br,on.bind=ci,on.bindAll=hi,on.bindKey=di,on.chain=Mr,on.compact=er,on.compose=vi,on.constant=Ds,on.countBy=Fr,on.create=Oi,on.createCallback=Ps,on.curry=mi,on.debounce=gi,on.defaults=Mi,on.defer=yi,on.delay=bi,on.difference=tr,on.drop=nr,on.dropRight=rr,on.dropRightWhile=ir,on.dropWhile=sr,on.filter=qr,on.flatten=fr,on.forEach=Wr,on.forEachRight=Xr,on.forIn=Pi,on.forInRight=Hi,on.forOwn=Bi,on.forOwnRight=ji,on.functions=Fi,on.groupBy=Vr,on.indexBy=$r,on.initial=cr,on.intersection=hr,on.invert=qi,on.invoke=Jr,on.keys=ss,on.keysIn=os,on.map=Kr,on.mapValues=us,on.matches=Bs,on.max=Qr,on.memoize=wi,on.merge=as,on.min=Gr,on.mixin=js,on.negate=Ei,on.omit=fs,on.once=Si,on.pairs=ls,on.partial=xi,on.partialRight=Ti,on.partition=Yr,on.pick=cs,on.pluck=Zr,on.property=Us,on.pull=vr,on.pullAt=mr,on.range=Ws,on.reject=ni,on.remove=gr,on.rest=yr,on.shuffle=ii,on.slice=br,on.sortBy=ui,on.tap=_r,on.throttle=Ni,on.times=Vs,on.toArray=ai,on.transform=hs,on.union=Nr,on.uniq=Cr,on.values=ps,on.valuesIn=ds,on.where=fi,on.without=kr,on.wrap=Ci,on.xor=Lr,on.zip=Ar,on.zipObject=Or,on.callback=Ps,on.collect=Kr,on.each=Wr,on.eachRight=Xr,on.extend=ki,on.methods=Fi,on.object=Or,on.select=qr,on.tail=yr,on.unique=Cr,on.unzip=Ar,js(on,dn({},on)),on.camelCase=vs,on.capitalize=ms,on.clone=Li,on.cloneDeep=Ai,on.contains=jr,on.endsWith=gs,on.escape=ys,on.escapeRegExp=bs,on.every=Ir,on.find=Rr,on.findIndex=or,on.findKey=_i,on.findLast=Ur,on.findLastIndex=ur,on.findLastKey=Di,on.findWhere=zr,on.has=Ii,on.identity=Hs,on.indexOf=lr,on.isArguments=Ri,on.isArray=Ui,on.isBoolean=zi,on.isDate=Wi,on.isElement=Xi,on.isEmpty=Vi,on.isEqual=$i,on.isError=Ji,on.isFinite=Ki,on.isFunction=Qi,on.isNaN=Yi,on.isNull=Zi,on.isNumber=es,on.isObject=Gi,on.isPlainObject=ts,on.isRegExp=ns,on.isString=rs,on.isUndefined=is,on.kebabCase=ws,on.lastIndexOf=dr,on.noConflict=Fs,on.noop=Is,on.now=qs,on.pad=Es,on.padLeft=Ss,on.padRight=xs,on.parseInt=Rs,on.random=zs,on.reduce=ei,on.reduceRight=ti,on.repeat=Ts,on.result=Xs,on.runInContext=_t,on.size=si,on.some=oi,on.sortedIndex=wr,on.snakeCase=Ns,on.startsWith=Cs,on.template=ks,on.trim=Ls,on.trimLeft=As,on.trimRight=Os,on.trunc=Ms,on.unescape=_s,on.uniqueId=$s,on.all=Ir,on.any=oi,on.detect=Rr,on.foldl=ei,on.foldr=ti,on.include=jr,on.inject=ei,js(on,function(){var e={};return Ln(on,function(t,n){on.prototype[n]||(e[n]=t)}),e}(),!1),on.first=ar,on.last=pr,on.sample=ri,on.take=Er,on.takeRight=Sr,on.takeRightWhile=xr,on.takeWhile=Tr,on.head=ar,Ln(on,function(e,t){var n=t!="sample";on.prototype[t]||(on.prototype[t]=function(t,r){var i=this.__chain__,s=e(this.__wrapped__,t,r);return!i&&(t==null||r&&(!n||typeof t!="function"))?s:new un(s,i)})}),on.VERSION=u,on.prototype.chain=Dr,on.prototype.toJSON=Hr,on.prototype.toString=Pr,on.prototype.value=Hr,on.prototype.valueOf=Hr,fn(["join","pop","shift"],function(e){var t=ft[e];on.prototype[e]=function(){var e=this.__chain__,n=t.apply(this.__wrapped__,arguments);return e?new un(n,e):n}}),fn(["push","reverse","sort","unshift"],function(e){var t=ft[e];on.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),fn(["concat","splice"],function(e){var t=ft[e];on.prototype[e]=function(){return new un(t.apply(this.__wrapped__,arguments),this.__chain__)}}),on}var e,t=1,n=2,r=4,i=8,s=16,o=32,u="2.4.1",a="__lodash@"+u+"__",f="Expected a function",l=0,c=/^[A-Z]+$/,h=/\b__p \+= '';/g,p=/\b(__p \+=) '' \+/g,d=/(__e\(.*?\)|\b__t\)) \+\n'';/g,v=/&(?:amp|lt|gt|quot|#39|#96);/g,m=/[&<>"'`]/g,g=/<%-([\s\S]+?)%>/g,y=/<%([\s\S]+?)%>/g,b=/<%=([\s\S]+?)%>/g,w=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,E=/\w*$/,S=/^\s*function[ \n\r\t]+\w/,x=/^0[xX]/,T=/[\xC0-\xFF]/g,N=/($^)/,C=/[.*+?^${}()|[\]\/\\]/g,k=/\bthis\b/,L=/['\n\r\u2028\u2029\\]/g,A=/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g,O=" 	\f ﻿\n\r\u2028\u2029 ᠎             　",M=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","isNaN","parseInt","setTimeout","TypeError","window","WinRTError"],_=0,D="[object Arguments]",P="[object Array]",H="[object Boolean]",B="[object Date]",j="[object Error]",F="[object Function]",I="[object Map]",q="[object Number]",R="[object Object]",U="[object RegExp]",z="[object Set]",W="[object String]",X="[object WeakMap]",V="[object ArrayBuffer]",$="[object Float32Array]",J="[object Float64Array]",K="[object Int8Array]",Q="[object Int16Array]",G="[object Int32Array]",Y="[object Uint8Array]",Z="[object Uint8ClampedArray]",et="[object Uint16Array]",tt="[object Uint32Array]",nt={};nt[D]=nt[P]=nt[$]=nt[J]=nt[K]=nt[Q]=nt[G]=nt[Y]=nt[Z]=nt[et]=nt[tt]=!0,nt[V]=nt[H]=nt[B]=nt[j]=nt[F]=nt[I]=nt[q]=nt[R]=nt[U]=nt[z]=nt[W]=nt[X]=!1;var rt={};rt[D]=rt[P]=rt[V]=rt[H]=rt[B]=rt[j]=rt[$]=rt[J]=rt[K]=rt[Q]=rt[G]=rt[q]=rt[R]=rt[U]=rt[W]=rt[Y]=rt[Z]=rt[et]=rt[tt]=!0,rt[F]=rt[I]=rt[z]=rt[X]=!1;var it={leading:!1,maxWait:0,trailing:!1},st={configurable:!1,enumerable:!1,value:null,writable:!1},ot={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#96;"},ut={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&#96;":"`"},at={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"AE","æ":"ae","Þ":"Th","þ":"th","ß":"ss","×":" ","÷":" "},ft={"function":!0,object:!0},lt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ct=ft[typeof window]&&window||this,ht=ft[typeof exports]&&exports&&!exports.nodeType&&exports,pt=ft[typeof module]&&module&&!module.nodeType&&module,dt=ht&&pt&&typeof global=="object"&&global;dt&&(dt.global===dt||dt.window===dt||dt.self===dt)&&(ct=dt);var vt=pt&&pt.exports===ht&&ht,Dt=_t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(ct._=Dt,define("lib/lodash",[],function(){return Dt})):ht&&pt?vt?(pt.exports=Dt)._=Dt:ht._=Dt:ct._=Dt}.call(this),define("ubp/commons/logging/LogLevel",["require","exports"],function(e,t){var n;return function(e){e[e.OFF=0]="OFF",e[e.FATAL=1]="FATAL",e[e.ERROR=2]="ERROR",e[e.WARN=3]="WARN",e[e.INFO=4]="INFO",e[e.DEBUG=5]="DEBUG",e[e.ALL=6]="ALL"}(n||(n={})),n}),define("ubp/commons/logging/Logger",["require","exports","lib/lodash","./LogLevel"],function(e,t,n,r){var i=function(){function e(t,n){this._appenders={},this._universalContext=[],this._name=t,this._appenders=n||this._appenders,e.root?this._logLevel=e.root._logLevel:this._logLevel=2}return e.getLogger=function(t){return new e(t)},e.isMuted=function(t){return e.muted[t]},e.mute=function(t){e.muted[t]=!0},e.unmute=function(t){delete e.muted[t]},e.prototype.setUniversalContext=function(){var e=[];for(var t=0;t<arguments.length;t++)e[t-0]=arguments[t];this._universalContext=e},e.prototype.setLogLevel=function(e){this._logLevel=e},e.prototype.addAppender=function(e,t){this._appenders[e]=t},e.prototype.removeAppender=function(e){delete this._appenders[e]},e.prototype.clearAppenders=function(){this._appenders={}},e.prototype._log=function(t,r,i,s){var o=this;if(this._isLevelEnabled(t)&&!e.isMuted(this._name)){var u=JSON.stringify(s),a=JSON.stringify(n.union(e.root._universalContext,this._universalContext)),f=n.extend({},this._appenders,e.root._appenders);n.each(f,function(e,s){n.isFunction(e.log)&&e.log(t,o._name,r,i,u,a)})}},e.prototype._isLevelEnabled=function(t){var n=this._logLevel>e.root._logLevel?this._logLevel:e.root._logLevel;return t<=n&&e.root._logLevel!==0&&this._logLevel!==0},e.prototype.fatal=function(e,t){var n=[];for(var r=2;r<arguments.length;r++)n[r-2]=arguments[r];this._log(1,e,t,n)},e.prototype.error=function(e,t){var n=[];for(var r=2;r<arguments.length;r++)n[r-2]=arguments[r];this._log(2,e,t,n)},e.prototype.warn=function(e,t){var n=[];for(var r=2;r<arguments.length;r++)n[r-2]=arguments[r];this._log(3,e,t,n)},e.prototype.info=function(e,t){var n=[];for(var r=2;r<arguments.length;r++)n[r-2]=arguments[r];this._log(4,e,t,n)},e.prototype.debug=function(e,t){var n=[];for(var r=2;r<arguments.length;r++)n[r-2]=arguments[r];this._log(5,e,t,n)},e.root=new e("Root"),e.muted={},e}();return i}),define("ubp/commons/Events/Subscription",["require","exports","../logging/Logger"],function(e,t,n){var r=function(){function e(t,r){this.callback=t,this.context=r,this.disposed=!1,e._Logger=e._Logger||n.getLogger("Subscription")}return e.prototype.matches=function(e,t){return this.callback===e&&this.context===t},e.prototype.notify=function(t){try{this.disposed||this.callback.apply(this.context,t)}catch(n){e._Logger.error("notify","error thrown in callback",n.message)}},e.prototype.dispose=function(){this.disposed=!0},e}();return r}),define("ubp/commons/Events/EventBucket",["require","exports","lib/lodash","./Subscription"],function(e,t,n,r){var i=function(){function e(){this.subscriptions=[]}return e.prototype.subscriptionExists=function(e,t){return!!n.find(this.subscriptions,function(n){return n.matches(e,t)},this)},e.prototype.subscribe=function(e,t){this.subscriptions.push(new r(e,t))},e.prototype.unsubscribeAll=function(){n.invoke(this.subscriptions,"dispose"),this.subscriptions=[]},e.prototype.unsubscribe=function(e,t){var r=null,i=n.find(this.subscriptions,function(n,i){return n.matches(e,t)?(r=i,!0):!1},this);i&&(i.dispose(),this.subscriptions.splice(r,1))},e.prototype.notify=function(e){n.invoke(n.clone(this.subscriptions),"notify",e)},e}();return i}),define("ubp/commons/Events/Events",["require","exports","lib/lodash","./EventBucket"],function(e,t,n,r){var i=function(){function e(){this.eventBuckets={}}return e.prototype.on=function(e,t,n){var r=this.getEventBucket(e);if(r.subscriptionExists(t,n))throw new Error("Cannot register duplicate subscription.");r.subscribe(t,n)},e.prototype.off=function(e,t,n){switch(arguments.length){case 0:this.removeAllSubscriptions();break;case 1:this.getEventBucket(e).unsubscribeAll();break;default:this.getEventBucket(e).unsubscribe(t,n)}},e.prototype.notify=function(e){var t=[];for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];this.getEventBucket(e).notify(t)},e.prototype.getEventBucket=function(e){return this.eventBuckets[e]=this.eventBuckets[e]||new r},e.prototype.removeAllSubscriptions=function(){n.invoke(this.eventBuckets,"unsubscribeAll")},e}();return i});var factory=function(){var e=function(){};return e.getLocalStorageConfiguration=function(){return[{url:"https://www.amazon.com/gp/ubp/AA/serviceSatellite.html"},{url:"https://www.amazon.cn/gp/ubp/AA/serviceSatellite.html"}]},e.getRegistryServiceConfiguration=function(){return[{url:"https://www.amazon.com/gp/ubp/AA/serviceLocalStorage.html"},{url:"https://www.amazon.cn/gp/ubp/AA/serviceLocalStorage.html"}]},e};typeof module!="undefined"&&module.exports?module.exports=factory():typeof define!="undefined"&&define("configuration/LocalStorageConfiguration",[],factory),define("ubp/commons/error/BaseError",["require","exports"],function(e,t){var n=function(){function e(e,t,n,r){this._name=e,this._message=t,this._status=n,this._cause=r||""}return e.prototype.getStatus=function(){return this._status},e.prototype.setStatus=function(e){this._status=e},e.prototype.getMessage=function(){return this._message},e.prototype.setMessage=function(e){this._message=e},e.prototype.getName=function(){return this._name},e.prototype.setName=function(e){this._name=e},e.prototype.getCause=function(){return this._cause},e.prototype.setCause=function(e){this._cause=e},e.prototype.toString=function(){return this._name+": "+this._message+" Status: "+this._status+"; Cause: "+this._cause},e}();return n});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/error/BadRequestError",["require","exports","./BaseError"],function(e,t,n){var r=function(e){function t(t){e.call(this,"BadRequestError","The request was somehow malformed or missing required arguments.","400",t)}return __extends(t,e),t}(n);return r});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/error/ConflictError",["require","exports","./BaseError"],function(e,t,n){var r=function(e){function t(t){e.call(this,"ConflictError","There was a conflict with the state of the resource.","409",t)}return __extends(t,e),t}(n);return r});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/error/FeatureUnavailableError",["require","exports","./BaseError"],function(e,t,n){var r=function(e){function t(t){e.call(this,"FeatureUnavailableError","The resource is known, but has become unavailable, check if process is still running","503",t)}return __extends(t,e),t}(n);return r});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/error/ForbiddenError",["require","exports","./BaseError"],function(e,t,n){var r=function(e){function t(t){e.call(this,"ForbiddenError","The calling process does not have permission to access to this API","403",t)}return __extends(t,e),t}(n);return r});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/error/InternalError",["require","exports","./BaseError"],function(e,t,n){var r=function(e){function t(t){e.call(this,"InternalError","Something unexpected went wrong while processing the request.","500",t)}return __extends(t,e),t}(n);return r});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/error/NotFoundError",["require","exports","./BaseError"],function(e,t,n){var r=function(e){function t(t){e.call(this,"NotFoundError","The API was never registered by the Platform or any remote process.","404",t)}return __extends(t,e),t}(n);return r});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/error/OutOfMemoryError",["require","exports","./BaseError"],function(e,t,n){var r=function(e){function t(t){e.call(this,"OutOfMemoryError","Not enough memory to support this operation","521",t)}return __extends(t,e),t}(n);return r});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/error/RequestTimeoutError",["require","exports","./BaseError"],function(e,t,n){var r=function(e){function t(t){e.call(this,"RequestTimeoutError","A response was not received before the (specified or default) timeout.","408",t)}return __extends(t,e),t}(n);return r});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/error/NoNetworkConnectivityError",["require","exports","./BaseError"],function(e,t,n){var r=function(e){function t(t){e.call(this,"NoNetworkConnectivityError","There was an error with network connectivity.","470",t)}return __extends(t,e),t}(n);return r}),define("ubp/commons/error/Errors",["require","exports","./BaseError","./BadRequestError","./ConflictError","./FeatureUnavailableError","./ForbiddenError","./InternalError","./NotFoundError","./OutOfMemoryError","./RequestTimeoutError","./NoNetworkConnectivityError"],function(e,t,n,r,i,s,o,u,a,f,l,c){var h;return function(e){function t(e,t,n,r){var i;switch(n){case"400":i=this.BadRequest(r);break;case"409":i=this.Conflict(r);break;case"503":i=this.FeatureUnavailable(r);break;case"403":i=this.Forbidden(r);break;case"500":i=this.Internal(r);break;case"404":i=this.NotFound(r);break;case"521":i=this.OutOfMemory(r);break;case"408":i=this.RequestTimeout(r);break;case"470":i=this.NoNetworkConnectivity(r);break;default:i=this.Base(e,t,n,r)}return e&&i.setName(e),t&&i.setMessage(t),i}function h(e,t,r,i){return new n(e,t,r,i)}function p(e){return new r(e)}function d(e){return new i(e)}function v(e){return new s(e)}function m(e){return new o(e)}function g(e){return new u(e)}function y(e){return new a(e)}function b(e){return new f(e)}function w(e){return new l(e)}function E(e){return new c(e)}e.Auto=t,e.Base=h,e.BadRequest=p,e.Conflict=d,e.FeatureUnavailable=v,e.Forbidden=m,e.Internal=g,e.NotFound=y,e.OutOfMemory=b,e.RequestTimeout=w,e.NoNetworkConnectivity=E}(h||(h={})),h});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/BaseRuntime",["require","exports","lib/lodash","lib/bluebird","../../commons/Events/Events","../../commons/logging/Logger","configuration/LocalStorageConfiguration","../../commons/error/Errors"],function(e,t,n,r,i,s,o,u){var a=function(e){function t(){e.call(this),this.MESSAGE_TIMEOUT=6e4,this.NEW_TAB_TIMEOUT=1e3,this.BADGE_COLOR="#FF5252",this.RUNTIME_EVENT="RuntimeEvent",this.BROWSER_ONLINE_EVENT="onBrowserOnline",this.EXTERNAL_MESSAGE="UBPExternalMessage",this.remoteConfigurationRawDataMap={},t.logger=t.logger||s.getLogger("BaseRuntime")}return __extends(t,e),t.prototype.onRuntimeEvent=function(e){this.on(this.RUNTIME_EVENT,e)},t.prototype.unsubscribeRuntimeEvents=function(){this.off(this.RUNTIME_EVENT)},t.prototype.unsubscribeBrowserOnlineEvents=function(){this.off(this.BROWSER_ONLINE_EVENT)},t.prototype._onPageTurn=function(e,n,r){t.logger.debug("_onPageTurn","PageTurn event for tabId: "+e+" at url: "+n+" with status: "+r),this._isValidUrl(n)&&this.notify(this.RUNTIME_EVENT,{name:"Tabs.PageTurn",eventArgs:{tabId:e,url:n,status:r}})},t.prototype._onContextMenuClick=function(e){if(this._isValidUrl(e.tabUrl)){var n=e.menuItemId?e.menuItemId.split(".")[0]:"";this.notify(this.RUNTIME_EVENT,{name:t.CONTEXT_MENU_CLICK_RESPONSE_NAME+n,eventArgs:e})}},t.prototype._onTabRemoved=function(e){t.logger.debug("_onTabRemoved","OnTabRemoved event for tabId: "+e),this.notify(this.RUNTIME_EVENT,{name:"Tabs.onRemoved",eventArgs:{tabId:e}})},t.prototype._onExternalMessage=function(e,t){switch(this._determineMessageType(e)){case"Sandbox":e=e.payload,this.notify(this.RUNTIME_EVENT,{name:"Sandbox.Message.".concat(e.mType),eventArgs:n.extend(e,{tabId:t}),tabId:t});break;case"Action":e=e.payload,this.notify(this.RUNTIME_EVENT,{name:"Action.Message",eventArgs:n.extend(e,{tabId:t})})}},t.prototype._determineMessageType=function(e){return e&&e.type&&n.startsWith(e.type,this.EXTERNAL_MESSAGE)&&e.type.replace(this.EXTERNAL_MESSAGE.concat("."),"")},t.prototype._isValidUrl=function(e){var t=new RegExp("^https?://");return t.test(e)},t.prototype.sendMessageToIFrame=function(e,n){return r.bind(this).then(function(){if(!e)return t.logger.error("sendMessageToIFrame","frame Id is null or empty"),r.reject("child frame Id is null or empty");var i=document.getElementById(e);if(!i)return t.logger.error("sendMessageToIFrame","iFrame with id "+e+" not found"),r.reject("iFrame with id "+e+" not found");var s="*";i.src&&(s=i.src),i.contentWindow.postMessage(n,s)})},t.prototype.setURLForIframe=function(e,n){return r.bind(this).then(function(){if(!e)return t.logger.error("setURLForIframe","frame Id is null or empty"),r.reject("frame Id is null or empty");var i=document.getElementById(e);if(!i)return t.logger.error("setURLForIframe","iFrame with id "+e+" not found"),r.reject("iFrame with id "+e+" not found");i.src=n})},t.prototype.getFromAmazonLocalStorage=function(e){var t=this,i,s=[];return r.bind(this).then(function(){var u=o.getLocalStorageConfiguration(),a=[];return n.each(u,n.bind(function(t){var n=this,o={name:"AmazonLocalStorage",configuration:{url:t.url+"?keys="+e.join(",")}};a.push(new r(function(e){var t=n.createProcessInstance(o,function(t){i=t.payload,e()},{});s.push(t),t.start()}))},t)),r.race(a).timeout(t.MESSAGE_TIMEOUT,"Did not receive local storage message in time")}).finally(function(){n.each(s,n.bind(function(e){this.destroyProcessInstance(e)},t))}).then(function(){return i})},t.prototype.createProcessInstance=function(e,t,n){throw new Error("Not implemented!")},t.prototype.destroyProcessInstance=function(e){throw new Error("Not implemented!")},t.prototype.getExtensionVersion=function(){throw new Error("Not implemented!")},t.prototype.registerToAmazonLocalStorage=function(){var e=o.getRegistryServiceConfiguration(),t=this.getExtensionVersion(),i=[];return n.each(e,n.bind(function(e){var n=this,s={name:"AmazonLocalStorageServer",configuration:{url:e.url+"?server="+t}};i.push(new r(function(e){n.createProcessInstance(s,function(t){e()},{}).start()}))},this)),r.all(i).timeout(this.MESSAGE_TIMEOUT,"Did not receive server message in time")},t.prototype.getIFrameAttributes=function(e){return r.bind(this).then(function(){var t={source:""},n=document.getElementById(e);return n&&n.src&&(t.source=n.src),r.resolve(t)})},t.prototype.createDesktopNotification=function(e,t){return r.reject(u.Conflict("createDesktopNotification is not supported for this browser"))},t.prototype.createContextMenuItem=function(e){var t=u.FeatureUnavailable("createContextMenuItem : Operation is not supported for this browser");return r.reject(t)},t.prototype.deleteAllContextMenuItems=function(){var e=u.FeatureUnavailable("deleteAllContextMenuItems : Operation is not supported for this browser");return r.reject(e)},t.prototype.isContextMenuApiSupported=function(){return!1},t.prototype.deleteContextMenuItemById=function(e){var t=u.FeatureUnavailable("deleteContextMenuItemById : Operation is not supported for this browser");return r.reject(t)},t.prototype.registerNotificationHandler=function(e){t.logger.info("registerNotificationHandler","Notifications are not supported in this browser")},t.prototype.setRemoteConfigurationRawData=function(e,t){return this.remoteConfigurationRawDataMap[e]=t,r.resolve()},t.prototype.getRemoteConfigurationRawData=function(e){return this.remoteConfigurationRawDataMap[e]},t.prototype.getUAParser=function(){throw new Error("Not implemented!")},t.prototype.getUserAgent=function(){throw new Error("Not implemented!")},t.prototype.getBrowserVersion=function(){return this.getUAParser().parse(this.getUserAgent()).then(function(e){return e.browserVersion})},t.prototype.enableExtensionFeature=function(){return r.resolve(!0)},t.prototype.getBrowserRecSettings=function(e){return t.logger.error("getBrowserRecSettings","This browser does not support getBrowserRecSettings"),r.reject(u.Conflict("This browser does not support getBrowserRecSettings"))},t.prototype.updateBrowserRecSettings=function(e,n){return t.logger.error("updateBrowserRecSettings","This browser does not support updateBrowserRecSettings"),r.reject(u.Conflict("This browser does not support updateBrowserRecSettings"))},t.prototype.registerWhitelist=function(e){return r.resolve()},t.prototype.closePanel=function(){try{window.top.close()}catch(e){t.logger.error("closePanel","Failed to close the panel due to "+e.toString())}},t.CONTEXT_MENU_CLICK_RESPONSE_NAME="Contextmenu.ItemClicked.",t}(i);return a}),define("ubp/extension/process/ProcessState",["require","exports"],function(e,t){var n;return function(e){e[e.NEW=1]="NEW",e[e.STARTING=2]="STARTING",e[e.STABLE=3]="STABLE",e[e.UNRESPONSIVE=4]="UNRESPONSIVE",e[e.TERMINATING=5]="TERMINATING",e[e.TERMINATED=6]="TERMINATED"}(n||(n={})),n}),define("ubp/commons/localization/Locale",["require","exports"],function(e,t){var n;return function(e){e[e.US=1]="US",e[e.CA=2]="CA",e[e.CN=3]="CN",e[e.JP=4]="JP",e[e.ES=5]="ES",e[e.IT=6]="IT",e[e.FR=7]="FR",e[e.DE=8]="DE",e[e.UK=9]="UK",e[e.IN=10]="IN"}(n||(n={})),n}),function(){var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=i.toString,l=i.hasOwnProperty,c=r.forEach,h=r.map,p=r.reduce,d=r.reduceRight,v=r.filter,m=r.every,g=r.some,y=r.indexOf,b=r.lastIndexOf,w=Array.isArray,E=Object.keys,S=s.bind,x=function(e){if(e instanceof x)return e;if(!(this instanceof x))return new x(e);this._wrapped=e};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=x),exports._=x):e._=x,x.VERSION="1.6.0";var T=x.each=x.forEach=function(e,t,r){if(e==null)return e;if(c&&e.forEach===c)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i<s;i++)if(t.call(r,e[i],i,e)===n)return}else{var o=x.keys(e);for(var i=0,s=o.length;i<s;i++)if(t.call(r,e[o[i]],o[i],e)===n)return}return e};x.map=x.collect=function(e,t,n){var r=[];return e==null?r:h&&e.map===h?e.map(t,n):(T(e,function(e,i,s){r.push(t.call(n,e,i,s))}),r)};var N="Reduce of empty array with no initial value";x.reduce=x.foldl=x.inject=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(p&&e.reduce===p)return r&&(t=x.bind(t,r)),i?e.reduce(t,n):e.reduce(t);T(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)throw new TypeError(N);return n},x.reduceRight=x.foldr=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(d&&e.reduceRight===d)return r&&(t=x.bind(t,r)),i?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=x.keys(e);s=o.length}T(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)});if(!i)throw new TypeError(N);return n},x.find=x.detect=function(e,t,n){var r;return C(e,function(e,i,s){if(t.call(n,e,i,s))return r=e,!0}),r},x.filter=x.select=function(e,t,n){var r=[];return e==null?r:v&&e.filter===v?e.filter(t,n):(T(e,function(e,i,s){t.call(n,e,i,s)&&r.push(e)}),r)},x.reject=function(e,t,n){return x.filter(e,function(e,r,i){return!t.call(n,e,r,i)},n)},x.every=x.all=function(e,t,r){t||(t=x.identity);var i=!0;return e==null?i:m&&e.every===m?e.every(t,r):(T(e,function(e,s,o){if(!(i=i&&t.call(r,e,s,o)))return n}),!!i)};var C=x.some=x.any=function(e,t,r){t||(t=x.identity);var i=!1;return e==null?i:g&&e.some===g?e.some(t,r):(T(e,function(e,s,o){if(i||(i=t.call(r,e,s,o)))return n}),!!i)};x.contains=x.include=function(e,t){return e==null?!1:y&&e.indexOf===y?e.indexOf(t)!=-1:C(e,function(e){return e===t})},x.invoke=function(e,t){var n=u.call(arguments,2),r=x.isFunction(t);return x.map(e,function(e){return(r?t:e[t]).apply(e,n)})},x.pluck=function(e,t){return x.map(e,x.property(t))},x.where=function(e,t){return x.filter(e,x.matches(t))},x.findWhere=function(e,t){return x.find(e,x.matches(t))},x.max=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.max.apply(Math,e);var r=-Infinity,i=-Infinity;return T(e,function(e,s,o){var u=t?t.call(n,e,s,o):e;u>i&&(r=e,i=u)}),r},x.min=function(e,t,n){if(!t&&x.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.min.apply(Math,e);var r=Infinity,i=Infinity;return T(e,function(e,s,o){var u=t?t.call(n,e,s,o):e;u<i&&(r=e,i=u)}),r},x.shuffle=function(e){var t,n=0,r=[];return T(e,function(e){t=x.random(n++),r[n-1]=r[t],r[t]=e}),r},x.sample=function(e,t,n){return t==null||n?(e.length!==+e.length&&(e=x.values(e)),e[x.random(e.length-1)]):x.shuffle(e).slice(0,Math.max(0,t))};var k=function(e){return e==null?x.identity:x.isFunction(e)?e:x.property(e)};x.sortBy=function(e,t,n){return t=k(t),x.pluck(x.map(e,function(e,r,i){return{value:e,index:r,criteria:t.call(n,e,r,i)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void 0)return 1;if(n<r||r===void 0)return-1}return e.index-t.index}),"value")};var L=function(e){return function(t,n,r){var i={};return n=k(n),T(t,function(s,o){var u=n.call(r,s,o,t);e(i,u,s)}),i}};x.groupBy=L(function(e,t,n){x.has(e,t)?e[t].push(n):e[t]=[n]}),x.indexBy=L(function(e,t,n){e[t]=n}),x.countBy=L(function(e,t){x.has(e,t)?e[t]++:e[t]=1}),x.sortedIndex=function(e,t,n,r){n=k(n);var i=n.call(r,t),s=0,o=e.length;while(s<o){var u=s+o>>>1;n.call(r,e[u])<i?s=u+1:o=u}return s},x.toArray=function(e){return e?x.isArray(e)?u.call(e):e.length===+e.length?x.map(e,x.identity):x.values(e):[]},x.size=function(e){return e==null?0:e.length===+e.length?e.length:x.keys(e).length},x.first=x.head=x.take=function(e,t,n){return e==null?void 0:t==null||n?e[0]:t<0?[]:u.call(e,0,t)},x.initial=function(e,t,n){return u.call(e,0,e.length-(t==null||n?1:t))},x.last=function(e,t,n){return e==null?void 0:t==null||n?e[e.length-1]:u.call(e,Math.max(e.length-t,0))},x.rest=x.tail=x.drop=function(e,t,n){return u.call(e,t==null||n?1:t)},x.compact=function(e){return x.filter(e,x.identity)};var A=function(e,t,n){return t&&x.every(e,x.isArray)?a.apply(n,e):(T(e,function(e){x.isArray(e)||x.isArguments(e)?t?o.apply(n,e):A(e,t,n):n.push(e)}),n)};x.flatten=function(e,t){return A(e,t,[])},x.without=function(e){return x.difference(e,u.call(arguments,1))},x.partition=function(e,t){var n=[],r=[];return T(e,function(e){(t(e)?n:r).push(e)}),[n,r]},x.uniq=x.unique=function(e,t,n,r){x.isFunction(t)&&(r=n,n=t,t=!1);var i=n?x.map(e,n,r):e,s=[],o=[];return T(i,function(n,r){if(t?!r||o[o.length-1]!==n:!x.contains(o,n))o.push(n),s.push(e[r])}),s},x.union=function(){return x.uniq(x.flatten(arguments,!0))},x.intersection=function(e){var t=u.call(arguments,1);return x.filter(x.uniq(e),function(e){return x.every(t,function(t){return x.contains(t,e)})})},x.difference=function(e){var t=a.apply(r,u.call(arguments,1));return x.filter(e,function(e){return!x.contains(t,e)})},x.zip=function(){var e=x.max(x.pluck(arguments,"length").concat(0)),t=new Array(e);for(var n=0;n<e;n++)t[n]=x.pluck(arguments,""+n);return t},x.object=function(e,t){if(e==null)return{};var n={};for(var r=0,i=e.length;r<i;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},x.indexOf=function(e,t,n){if(e==null)return-1;var r=0,i=e.length;if(n){if(typeof n!="number")return r=x.sortedIndex(e,t),e[r]===t?r:-1;r=n<0?Math.max(0,i+n):n}if(y&&e.indexOf===y)return e.indexOf(t,n);for(;r<i;r++)if(e[r]===t)return r;return-1},x.lastIndexOf=function(e,t,n){if(e==null)return-1;var r=n!=null;if(b&&e.lastIndexOf===b)return r?e.lastIndexOf(t,n):e.lastIndexOf(t);var i=r?n:e.length;while(i--)if(e[i]===t)return i;return-1},x.range=function(e,t,n){arguments.length<=1&&(t=e||0,e=0),n=arguments[2]||1;var r=Math.max(Math.ceil((t-e)/n),0),i=0,s=new Array(r);while(i<r)s[i++]=e,e+=n;return s};var O=function(){};x.bind=function(e,t){var n,r;if(S&&e.bind===S)return S.apply(e,u.call(arguments,1));if(!x.isFunction(e))throw new TypeError;return n=u.call(arguments,2),r=function(){if(this instanceof r){O.prototype=e.prototype;var i=new O;O.prototype=null;var s=e.apply(i,n.concat(u.call(arguments)));return Object(s)===s?s:i}return e.apply(t,n.concat(u.call(arguments)))}},x.partial=function(e){var t=u.call(arguments,1);return function(){var n=0,r=t.slice();for(var i=0,s=r.length;i<s;i++)r[i]===x&&(r[i]=arguments[n++]);while(n<arguments.length)r.push(arguments[n++]);return e.apply(this,r)}},x.bindAll=function(e){var t=u.call(arguments,1);if(t.length===0)throw new Error("bindAll must be passed function names");return T(t,function(t){e[t]=x.bind(e[t],e)}),e},x.memoize=function(e,t){var n={};return t||(t=x.identity),function(){var r=t.apply(this,arguments);return x.has(n,r)?n[r]:n[r]=e.apply(this,arguments)}},x.delay=function(e,t){var n=u.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},x.defer=function(e){return x.delay.apply(x,[e,1].concat(u.call(arguments,1)))},x.throttle=function(e,t,n){var r,i,s,o=null,u=0;n||(n={});var a=function(){u=n.leading===!1?0:x.now(),o=null,s=e.apply(r,i),r=i=null};return function(){var f=x.now();!u&&n.leading===!1&&(u=f);var l=t-(f-u);return r=this,i=arguments,l<=0?(clearTimeout(o),o=null,u=f,s=e.apply(r,i),r=i=null):!o&&n.trailing!==!1&&(o=setTimeout(a,l)),s}},x.debounce=function(e,t,n){var r,i,s,o,u,a=function(){var f=x.now()-o;f<t?r=setTimeout(a,t-f):(r=null,n||(u=e.apply(s,i),s=i=null))};return function(){s=this,i=arguments,o=x.now();var f=n&&!r;return r||(r=setTimeout(a,t)),f&&(u=e.apply(s,i),s=i=null),u}},x.once=function(e){var t=!1,n;return function(){return t?n:(t=!0,n=e.apply(this,arguments),e=null,n)}},x.wrap=function(e,t){return x.partial(t,e)},x.compose=function(){var e=arguments;return function(){var t=arguments;for(var n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},x.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},x.keys=function(e){if(!x.isObject(e))return[];if(E)return E(e);var t=[];for(var n in e)x.has(e,n)&&t.push(n);return t},x.values=function(e){var t=x.keys(e),n=t.length,r=new Array(n);for(var i=0;i<n;i++)r[i]=e[t[i]];return r},x.pairs=function(e){var t=x.keys(e),n=t.length,r=new Array(n);for(var i=0;i<n;i++)r[i]=[t[i],e[t[i]]];return r},x.invert=function(e){var t={},n=x.keys(e);for(var r=0,i=n.length;r<i;r++)t[e[n[r]]]=n[r];return t},x.functions=x.methods=function(e){var t=[];for(var n in e)x.isFunction(e[n])&&t.push(n);return t.sort()},x.extend=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]=t[n]}),e},x.pick=function(e){var t={},n=a.apply(r,u.call(arguments,1));return T(n,function(n){n in e&&(t[n]=e[n])}),t},x.omit=function(e){var t={},n=a.apply(r,u.call(arguments,1));for(var i in e)x.contains(n,i)||(t[i]=e[i]);return t},x.defaults=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e},x.clone=function(e){return x.isObject(e)?x.isArray(e)?e.slice():x.extend({},e):e},x.tap=function(e,t){return t(e),e};var M=function(e,t,n,r){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;e instanceof x&&(e=e._wrapped),t instanceof x&&(t=t._wrapped);var i=f.call(e);if(i!=f.call(t))return!1;switch(i){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if(typeof e!="object"||typeof t!="object")return!1;var s=n.length;while(s--)if(n[s]==e)return r[s]==t;var o=e.constructor,u=t.constructor;if(o!==u&&!(x.isFunction(o)&&o instanceof o&&x.isFunction(u)&&u instanceof u)&&"constructor"in e&&"constructor"in t)return!1;n.push(e),r.push(t);var a=0,l=!0;if(i=="[object Array]"){a=e.length,l=a==t.length;if(l)while(a--)if(!(l=M(e[a],t[a],n,r)))break}else{for(var c in e)if(x.has(e,c)){a++;if(!(l=x.has(t,c)&&M(e[c],t[c],n,r)))break}if(l){for(c in t)if(x.has(t,c)&&!(a--))break;l=!a}}return n.pop(),r.pop(),l};x.isEqual=function(e,t){return M(e,t,[],[])},x.isEmpty=function(e){if(e==null)return!0;if(x.isArray(e)||x.isString(e))return e.length===0;for(var t in e)if(x.has(e,t))return!1;return!0},x.isElement=function(e){return!!e&&e.nodeType===1},x.isArray=w||function(e){return f.call(e)=="[object Array]"},x.isObject=function(e){return e===Object(e)},T(["Arguments","Function","String","Number","Date","RegExp"],function(e){x["is"+e]=function(t){return f.call(t)=="[object "+e+"]"}}),x.isArguments(arguments)||(x.isArguments=function(e){return!!e&&!!x.has(e,"callee")}),typeof /./!="function"&&(x.isFunction=function(e){return typeof e=="function"}),x.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},x.isNaN=function(e){return x.isNumber(e)&&e!=+e},x.isBoolean=function(e){return e===!0||e===!1||f.call(e)=="[object Boolean]"},x.isNull=function(e){return e===null},x.isUndefined=function(e){return e===void 0},x.has=function(e,t){return l.call(e,t)},x.noConflict=function(){return e._=t,this},x.identity=function(e){return e},x.constant=function(e){return function(){return e}},x.property=function(e){return function(t){return t[e]}},x.matches=function(e){return function(t){if(t===e)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0}},x.times=function(e,t,n){var r=Array(Math.max(0,e));for(var i=0;i<e;i++)r[i]=t.call(n,i);return r},x.random=function(e,t){return t==null&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))},x.now=Date.now||function(){return(new Date).getTime()};var _={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}};_.unescape=x.invert(_.escape);var D={escape:new RegExp("["+x.keys(_.escape).join("")+"]","g"),unescape:new RegExp("("+x.keys(_.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(e){x[e]=function(t){return t==null?"":(""+t).replace(D[e],function(t){return _[e][t]})}}),x.result=function(e,t){if(e==null)return void 0;var n=e[t];return x.isFunction(n)?n.call(e):n},x.mixin=function(e){T(x.functions(e),function(t){var n=x[t]=e[t];x.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),F.call(this,n.apply(x,e))}})};var P=0;x.uniqueId=function(e){var t=++P+"";return e?e+t:t},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n","	":"t","\u2028":"u2028","\u2029":"u2029"},j=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(e,t,n){var r;n=x.defaults({},n,x.templateSettings);var i=new RegExp([(n.escape||H).source,(n.interpolate||H).source,(n.evaluate||H).source].join("|")+"|$","g"),s=0,o="__p+='";e.replace(i,function(t,n,r,i,u){return o+=e.slice(s,u).replace(j,function(e){return"\\"+B[e]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),s=u+t.length,t}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=new Function(n.variable||"obj","_",o)}catch(u){throw u.source=o,u}if(t)return r(t,x);var a=function(e){return r.call(this,e,x)};return a.source="function("+(n.variable||"obj")+"){\n"+o+"}",a},x.chain=function(e){return x(e).chain()};var F=function(e){return this._chain?x(e).chain():e};x.mixin(x),T(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];x.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),(e=="shift"||e=="splice")&&n.length===0&&delete n[0],F.call(this,n)}}),T(["concat","join","slice"],function(e){var t=r[e];x.prototype[e]=function(){return F.call(this,t.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),typeof define=="function"&&define.amd&&define("underscore",[],function(){return x})}.call(this);var factory=function(e){var t=function(){this.initialize.apply(this,arguments)};return e.extend(t.prototype,{initialize:function(e,t){this._opts=e,this.errorDescription=t},get:function(e){if(this._opts.hasOwnProperty(e))return this._opts[e]},getOrError:function(e){if(typeof this._opts[e]=="undefined"||this._opts[e]===null)throw new Error("Option required but not found: "+e+"\n From: "+this.errorDescription);return this._opts[e]},getOrElse:function(e,t){return typeof this._opts[e]=="undefined"||this._opts[e]===null?t:this._opts[e]},getOrElseFn:function(e,t){return typeof this._opts[e]=="undefined"||this._opts[e]===null?t():this._opts[e]}}),t.fromObject=function(e,n){return new t(e||{},n||"")},t};typeof module!="undefined"&&module.exports?module.exports=factory(require("underscore")):typeof define!="undefined"&&define("bit/commons/options",["underscore"],factory);var factory=function(e,t){var n=function(){this.initialize.apply(this,arguments)};return e.extend(n.prototype,{initialize:function(e){e=t.fromObject(e),this._handler=e.getOrError("handler")},matches:function(e){return this._handler===e},notify:function(e){this._handler(e)},dispose:function(){this._handler=null}}),n};typeof module!="undefined"&&module.exports?module.exports=factory(require("underscore"),require("bit/commons/options")):typeof define!="undefined"&&define("bit/messaging/internals/message-subscriber",["underscore","bit/commons/options"],factory);var factory=function(e,t,n){var r=function(){this.initialize.apply(this,arguments)};return e.extend(r.prototype,{initialize:function(e){e=t.fromObject(e),this._sentinel=e.getOrError("sentinel"),this._subscribers=[]},publish:function(t,n){if(this._sentinel!==t)throw new Error("Invalid sentinel provided; cannot publish message.");e.invoke(this._subscribers,"notify",n)},subscribe:function(t){if(!t)return;if(e.any(this._subscribers,function(e){return e.matches(t)}))throw new Error("Cannot double-subscribe to a channel.");this._subscribers.push(new n({handler:t}))},unsubscribe:function(t){var n=0,r=e.find(this._subscribers,function(e){if(e.matches(t))return!0;n+=1});r&&(this._subscribers.splice(n,1),r.dispose())},dispose:function(){e.invoke(this._subscribers,"dispose"),this._subscribers=[]}}),r};typeof module!="undefined"&&module.exports?module.exports=factory(require("underscore"),require("bit/commons/options"),require("bit/messaging/internals/message-subscriber")):typeof define!="undefined"&&define("bit/messaging/message-channel",["underscore","bit/commons/options","bit/messaging/internals/message-subscriber"],factory);var factory=function(){var e={v4:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.random()*16|0,n=e=="x"?t:t&3|8;return n.toString(16)})}};return e};typeof module!="undefined"&&module.exports?module.exports=factory():typeof define!="undefined"&&define("bit/commons/uuid",[],factory);var factory=function(e,t,n){var r={Message:function(e){return{msgId:n.v4(),mType:e.getOrError("mType"),payload:e.getOrElse("msg",null),t:Date.now()}},rpcSend:function(e){return this.Message(e)},rpcSendAndReceive:function(e){return this.Message(e)},rpcReply:function(t){return e.extend(this.Message(t),{rMsgId:t.getOrError("inReplyTo"),error:t.getOrElse("error",null)})},localDispatch:function(t){return e.extend(this.Message(t),{oMsgId:t.getOrError("originalMsgId"),replyCallback:t.getOrError("replyCallback")})}},i=function(){this.initialize.apply(this,arguments)};return e.extend(i.prototype,{initialize:function(e){}}),i.createMessage=function(e){return e=t.fromObject(e),r[e.getOrError("mType")](e)},i};typeof module!="undefined"&&module.exports?module.exports=factory(require("underscore"),require("bit/commons/options"),require("bit/commons/uuid")):typeof define!="undefined"&&define("bit/messaging/message-factory",["underscore","bit/commons/options","bit/commons/uuid"],factory);var factory=function(e){var t=function(){this.initialize.apply(this,arguments)};return e.extend(t.prototype,{initialize:function(e){this._isSet=!1,this._val=null,typeof e!="undefined"&&this._set(e)},get:function(){if(!this._isSet)throw new Error("Requested future before underlying value was set.");return this._val},getOrElse:function(e){return this._isSet?this._val:e},set:function(e){this._set(e)},isSet:function(){return this._isSet},_set:function(e){this._isSet=!0,this._val=e}}),t};typeof module!="undefined"&&module.exports?module.exports=factory(require("underscore")):typeof define!="undefined"&&define("bit/commons/simple-future",["underscore"],factory);var factory=function(e,t){var n=function(){};n.prototype={noop:function(){},partiallyApply:function(){var t=e.toArray(arguments),n=t.shift();return function(){var r=e.toArray(arguments);return n.apply(null,t.concat(r))}},params:function(e){var t=new r(e);return t},returns:function(e,t){return function(n){if(n){t(n);return}t(null,e)}},cbOnErr:function(e,t){return e=e||this.noop,t?(e(t),!0):!1},doThrow:function(e){throw e},future:function(e){return new t(e)},pojoKlass:function(t,n){t=t||[],n=n||{};var r=function(){this.initialize.apply(this,arguments)},i=function(){var n=e.toArray(arguments);e.each(t,e.bind(function(e,t){var r="_"+e;this[r]=n[t]},this))};return r.prototype.initialize=i,e.each(t,function(e){var t="_"+e,n=function(){return this[t]};r.prototype[e]=n}),n.setters&&e.each(t,function(e){var t="_"+e,n="set"+e.charAt(0).toUpperCase()+e.substr(1),i=function(e){this[t]=e};r.prototype[n]=i}),r}};var r=function(){this.initialize.apply(this,arguments)};return e.extend(r.prototype,{initialize:function(e){if(!e)throw new Error("Invalid target provided for scoped require");this._target=e},req:function(e,t){if(!e)throw new Error("Invalid attribute provided");t=t||"Attribute required but missing: `"+e+"'";if(typeof this._target[e]=="undefined"||this._target[e]===null)throw new Error(t);return this}}),new n};typeof module!="undefined"&&module.exports?module.exports=factory(require("underscore"),require("bit/commons/simple-future")):typeof define!="undefined"&&define("bit/commons/lang",["underscore","bit/commons/simple-future"],factory);var factory=function(e,t){var n={scheduleTask:function(e,n){e=e||t.noop,n=n||1;if(typeof setTimeout!="undefined")return setTimeout(e,n);if(typeof module!="undefined"&&module.exports&&typeof require!="undefined"){var r=require("sdk/timers");if(r)return r.setTimeout(e,n);throw new Error("Don't know who to delegate task to!")}throw new Error("Don't know who to delegate task to!")},cancelTask:function(e){if(typeof setTimeout!="undefined")return clearTimeout(e);if(typeof module!="undefined"&&module.exports&&typeof require!="undefined"){var t=require("sdk/timers");if(t)return t.clearTimeout(e);throw new Error("Don't know who to delegate cancel to!")}throw new Error("Don't know who to delegate cancel to!")}};return n};typeof module!="undefined"&&module.exports?module.exports=factory(require("underscore","bit/commons/lang")):typeof define!="undefined"&&define("bit/commons/task-manager",["underscore","bit/commons/lang"],factory);var factory=function(e,t,n){var r=850,i=function(){this.initialize.apply(this,arguments)};e.extend(i.prototype,{initialize:function(n){n=t.fromObject(n),this._owner=n.getOrError("owner"),this._key=n.getOrError("key"),this._timeout=n.getOrError("timeout"),this._lastAccess=null,this._expiryRequested=!1,this._disposed=!1,this.touch(),e.bindAll(this,"_checkExpired"),this._scheduleExpiryCheck()},setValue:function(e){this.touch(),this._value=e},value:function(){return this.touch(),this._value},touchlessValue:function(){return this._value},touch:function(){this._lastAccess=Date.now()},dispose:function(){this._disposed=!0,this._value=null,this._owner=null,this._key=null},isExpired:function(){return this._expiryRequested||Date.now()-this._lastAccess>this._timeout},_requestExpiry:function(){this._expiryRequested=!0,this._key&&this._owner._requestExpiry(this._key,this)},_scheduleExpiryCheck:function(){n.scheduleTask(this._checkExpired,r)},_checkExpired:function(){if(this._disposed)return;this.isExpired()?this._requestExpiry():n.scheduleTask(this._checkExpired,r)}});var s=function(){this.initialize.apply(this,arguments)};return e.extend(s.prototype,{initialize:function(e){e=t.fromObject(e),this._timeout=e.getOrElse("timeout",5e3),this._onTimeout=e.getOrElse("onTimeout",function(){}),this._hash={},this._disposed=!1},dispose:function(){if(this._disposed)return;this._hash&&(e.each(this._hash,function(e){e.dispose()}),this._hash=null),this._disposed=!0},_checkNotDisposed:function(){if(this._disposed)throw new Error("Tried to modify disposed TimeoutHash")},put:function(e,t,n){this._checkNotDisposed();var r=this._hash[e];r||(r=new i({owner:this,key:e,timeout:n||this._timeout}),this._hash[e]=r),r.setValue(t)},get:function(e){this._checkNotDisposed();var t=this._hash[e];if(!t)return;return t.value()},getAndRemove:function(e){this._checkNotDisposed();var t=this._hash[e],n;if(!t)return;return n=t.value(),this.remove(e),n},remove:function(e){this._checkNotDisposed();var t=this._hash[e];t&&(delete this._hash[e],t.dispose())},_requestExpiry:function(e,t){var n=t.touchlessValue();delete this._hash[e],t.dispose(),this._onTimeout(e,n)}}),s};typeof module!="undefined"&&module.exports?module.exports=factory(require("underscore"),require("bit/commons/options"),require("bit/commons/task-manager")):typeof define!="undefined"&&define("bit/commons/timeout-hash",["underscore","bit/commons/options","bit/commons/task-manager"],factory);var factory=function(e,t){var n=function(){this.initialize.apply(this,arguments)};return e.extend(n.prototype,t.prototype),e.extend(n.prototype,{initialize:function(){t.prototype.initialize.apply(this,arguments),this._joinedChannels=[],e.bindAll(this,"_forwardDispatcher")},join:function(e){e.subscribe(this._forwardDispatcher),this._joinedChannels.push(e)},leave:function(e){var t,n=this._joinedChannels.indexOf(e);n!==-1&&(t=this._joinedChannels[n],this._joinedChannels.splice(n,1)),t&&e.unsubscribe(this._forwardDispatcher)},_forwardDispatcher:function(e){this.publish(this._sentinel,e)}}),n};typeof module!="undefined"&&module.exports?module.exports=factory(require("underscore"),require("bit/messaging/message-channel")):typeof define!="undefined"&&define("bit/messaging/composite-message-channel",["underscore","bit/messaging/message-channel"],factory),define("ubp/commons/messaging/MessageExchange",["require","exports","lib/lodash","lib/bluebird","bit/messaging/message-channel","bit/messaging/message-factory","bit/commons/timeout-hash","bit/messaging/composite-message-channel","../error/Errors","../error/BaseError"],function(e,t,n,r,i,s,o,u,a,f){var l=function(){function e(e){if(!n.isNumber(e)||n.isNaN(e))throw new Error("MessageExchange.constructor: 'timeout' argument is not a valid number.");this._ingressBus=new u({sentinel:this}),this._egressBus=new i({sentinel:this}),this._dispatchBus=new i({sentinel:this}),n.bindAll(this,"_onReplyTimeout","_receive"),this._pendingRemoteReplies=new o({timeout:e,onTimeout:this._onReplyTimeout}),this._ingressBus.subscribe(this._receive),this._disposed=!1}return e.prototype.dispose=function(){var e=this;return r.bind(this).then(function(){if(e._disposed)return;e._ingressBus&&(e._ingressBus.dispose(),e._ingressBus=null),e._egressBus&&(e._egressBus.dispose(),e._egressBus=null),e._dispatchBus&&(e._dispatchBus.dispose(),e._dispatchBus=null),e._pendingRemoteReplies&&(e._pendingRemoteReplies.dispose(),e._pendingRemoteReplies=null),e._disposed=!0})},e.prototype.dispatchBus=function(){return this._dispatchBus},e.prototype.egressBus=function(){return this._egressBus},e.prototype.listen=function(e){var t=this;return r.bind(this).then(function(){t._ingressBus.join(e)})},e.prototype.leave=function(e){var t=this;return r.bind(this).then(function(){t._ingressBus.leave(e)})},e.prototype.twine=function(e){var t=this;return r.bind(this).then(function(){return e.listen(t.egressBus())}).then(function(){return t.listen(e.egressBus())})},e.prototype.untwine=function(e){var t=this;return r.bind(this).then(function(){return e.leave(t.egressBus())}).then(function(){return t.leave(e.egressBus())})},e.prototype.send=function(e){var t=this;return r.bind(this).then(function(){var n=s.createMessage({mType:"rpcSend",msg:e});t._egressBus.publish(t,n)})},e.prototype.sendAndReceive=function(e,t){var i=this;return new r(function(r,o){!n.isUndefined(t)&&(!n.isNumber(t)||n.isNaN(t))&&o(new Error("MessageExchange.sendAndReceive: 'timeout' argument is not a valid number."));var u=s.createMessage({mType:"rpcSendAndReceive",msg:e});i._pendingRemoteReplies.put(u.msgId,function(e,t){e?e instanceof Error||e instanceof f?o(e):o(new Error(e)):r(t)},t),i._egressBus.publish(i,u)})},e.prototype._reply=function(e,t,n){var r=s.createMessage({mType:"rpcReply",msg:n,rMsgId:e,error:t});this._egressBus.publish(this,r)},e.prototype._receive=function(e){var t="_receive_"+e.mType;if(!this[t])return;this[t](e)},e.prototype._receive_rpcReply=function(e){var t=e.rMsgId,n=e.payload,r=e.error,i=this._pendingRemoteReplies.getAndRemove(t);if(i)if(r)if(r.status){var s=a.Auto(r.name,r.message,r.status,r.cause);i(s)}else i(a.Internal(r.message||r));else i(null,n)},e.prototype._receive_rpcSend=function(e){var t=e.payload,n=e.msgId;this._dispatchBus.publish(this,s.createMessage({mType:"localDispatch",msg:t,originalMsgId:n,replyCallback:function(){}}))},e.prototype._receive_rpcSendAndReceive=function(e){var t=this,r=e.payload,i=e.msgId,o=n.bind(function(e,n){e&&(r=null);var o=s.createMessage({mType:"rpcReply",msg:n,inReplyTo:i,error:e});t._egressBus.publish(t,o)},this);this._dispatchBus.publish(this,s.createMessage({mType:"localDispatch",msg:r,originalMsgId:i,replyCallback:o}))},e.prototype._onReplyTimeout=function(e,t){t(a.RequestTimeout())},e}();return l});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/process/BaseProcess",["require","exports","lib/lodash","lib/bluebird","./ProcessState","../../commons/Events/Events","../../commons/logging/Logger","../../commons/localization/Locale","../../commons/messaging/MessageExchange"],function(e,t,n,r,i,s,o,u,a){var f=function(e){function t(n,r,i){e.call(this),this._state=1,t.logger=t.logger||o.getLogger("BaseProcess"),this._manifest=n,this._messageReceiver=r,this._options=i}return __extends(t,e),t.prototype.start=function(){var e=this;return r.bind(this).then(function(){return e.getState()}).then(function(n){if(n!==1){var i=new Error("This Process has already been started and can only be started once.");return t.logger.error("start",i.toString()),r.reject(i)}return e.setState(2)})},t.prototype.terminate=function(){var e=this;return r.bind(this).then(function(){return e._exchange&&e._exchange.dispose()}).then(function(){return e.setState(6)}).then(function(){e._transport=null,e._exchange=null,e._messageReceiver=null,e._manifest=null})},t.prototype._setupMessageExchange=function(){var e=this;return this._exchange=new a(t.MESSAGE_TIMEOUT),this._transport.forward(this._exchange.egressBus()).then(function(){return e._exchange.listen(e._transport.dispatchBus())}).then(function(){return e._exchange.dispatchBus().subscribe(function(t){e._messageReceiver(t,e)})})},t.prototype.getState=function(){return r.cast(this._state)},t.prototype.setState=function(e){var t=this;return r.bind(this).then(function(){t._state!==e&&(t._state=e,t.notify("StateChange",t._state,t))})},t.prototype.send=function(e){var n=this;return this.getState().then(function(e){if(e!==3){var n=new Error("This Process must be stable before making any method calls.");return t.logger.info("send",n.toString()),r.reject(n)}}).then(function(){return n._exchange.send(e)})},t.prototype.sendAndReceive=function(e,n){var i=this;return this.getState().then(function(e){if(e!==3){var n=new Error("This Process must be stable before making any method calls.");return t.logger.info("send",n.toString()),r.reject(n)}}).then(function(){return i._exchange.sendAndReceive(e,n)})},t.prototype.getManifest=function(){var e=this;return r.bind(this).then(function(){return e._manifest})},t._extractOrigin=function(e){var t=e.replace(/(https?:\/\/).*/,"$1"),n=e.split(/https?:\/\//)[1].split("/")[0];return t+n},t._getProcessUrl=function(e,r){var i=e.configuration.url,s=u[t.DEFAULT_LOCALE];!n.isUndefined(r)&&!n.isUndefined(u[r.locale])&&(s=u[r.locale]),i=t._appendQueryParams(i,{locale:s});if(e.configuration.assetTag){if(e.configuration.url.match(/[&\?]assetTag=/)){var o=new Error("URL already has an assetTag; can't append assetTag");throw t.logger.info("send",o.toString()),o}i=t._appendQueryParams(i,{assetTag:e.configuration.assetTag})}return i},t._appendQueryParams=function(e,t){var r="";n.each(t,function(e,t){r+="&"+encodeURIComponent(t)+"="+encodeURIComponent(e)});if(e.indexOf("?")>-1){if(e.charAt(e.length-1)==="&"||e.charAt(e.length-1)==="?")r=r.slice(1)}else r="?"+r.slice(1);return e+r},t.MESSAGE_TIMEOUT=1e4,t.DEFAULT_LOCALE=1,t}(s);return f}),define("ubp/commons/messaging/BaseTransportStrategy",["require","exports","lib/bluebird","bit/messaging/message-channel","bit/messaging/composite-message-channel"],function(e,t,n,r,i){var s=function(){function e(e){this._identity=e.identity,this._dispatchBus=new r({sentinel:this}),this._egressBus=new i({sentinel:this}),this._validSources=e.validSources,this._validOrigins=e.validOrigins}return e.prototype.dispatchBus=function(){return this._dispatchBus},e.prototype.forward=function(e){var t=this;return n.bind(this).then(function(){t._egressBus.join(e)})},e.prototype.bind=function(e,t){return n.resolve()},e.prototype.unbind=function(){return n.resolve()},e}();return s}),define("ubp/commons/messaging/primitives/TransportStrategyType",["require","exports"],function(e,t){var n;return function(e){e[e.PostMessage=0]="PostMessage",e[e.PanelMessage=1]="PanelMessage",e[e.Port=2]="Port",e[e.Pseudo=3]="Pseudo"}(n||(n={})),n});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/messaging/PostMessageTransportStrategy",["require","exports","lib/lodash","lib/bluebird","./BaseTransportStrategy","./primitives/TransportStrategyType"],function(e,t,n,r,i,s){var o=function(e){function t(t){e.call(this,t),n.bindAll(this,"_onMessage","_send"),this._egressBus.subscribe(this._send),this.bind(t.inboundPort,t.outboundPort)}return __extends(t,e),t.prototype.dispatchBus=function(){return e.prototype.dispatchBus.call(this)},t.prototype.forward=function(t){return e.prototype.forward.call(this,t)},t.prototype.bind=function(e,t){var n=this;return r.bind(this).then(function(){n._outboundPort=t,n._inboundPort=e,n._inboundPort.addEventListener("message",n._onMessage,!1)})},t.prototype.unbind=function(){var e=this;return r.bind(this).then(function(){n.isObject(e._inboundPort)&&e._inboundPort.removeEventListener("message",e._onMessage),e._inboundPort=null,e._outboundPort=null})},t.prototype._send=function(e){var t={mType:0,source:this._identity,payload:e};n.isObject(this._outboundPort)&&this._outboundPort.postMessage(t,"*")},t.prototype._onMessage=function(e){if(!n.contains(this._validOrigins,"*")&&!n.contains(this._validOrigins,e.origin))return;var t=e.data;if(!n.contains(this._validSources,"*")&&!n.contains(this._validSources,t.source)||t.source===this._identity)return;this._dispatchBus.publish(this,t.payload)},t}(i);return o});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/process/IFrameProcess",["require","exports","lib/bluebird","./BaseProcess","./ProcessState","../../commons/messaging/PostMessageTransportStrategy"],function(e,t,n,r,i,s){var o=function(e){function t(t,n,r,i,s){e.call(this,t,n,r),this._frameAttributes=s,this._frame=i||this._createFrame()}return __extends(t,e),t.prototype.start=function(i){var s=this;return i===void 0&&(i=t.DEFAULT_TIMEOUT),n.bind(this).then(function(){return e.prototype.start.call(s)}).then(function(){return s._frame.src=r._getProcessUrl(s._manifest,s._options),s._setupMessagingInfrastructure()}).then(function(){return(new n(function(e){s._state===3&&e(),s.on("StateChange",function(t){t===3&&e()},s)})).timeout(i,"Did not receive handshake in time")}).catch(function(e){var t=new Error("Could not start process: "+e.message);return r.logger.error("IFrameProcess.start",t.message),n.reject(t)})},t.prototype.terminate=function(){var t=this;return n.bind(this).then(function(){return e.prototype.terminate.call(t)}).then(function(){return t._exchange&&t._exchange.dispose()}).then(function(){return t._transport=null,t._exchange=null,t._messageReceiver=null,t._manifest=null,t._frame.src="about:blank",t._frame.contentWindow.close(),t._frame})},t.prototype._setupMessagingInfrastructure=function(){return this._transportStrategyOptions={identity:"PlatformHub",inboundPort:window,outboundPort:this._frame.contentWindow,validOrigins:[t._extractOrigin(this._manifest.configuration.url.toString())],validSources:[this._manifest.name]},this._transport=new s(this._transportStrategyOptions),e.prototype._setupMessageExchange.call(this)},t.prototype._createFrame=function(){var e=document.createElement("iframe");return e.src="about:blank",_.each(this._frameAttributes,function(t,n){t&&n&&e.setAttribute(n,t)},this),document.body.appendChild(e),e},t.DEFAULT_TIMEOUT=3e4,t}(r);return o}),define("ubp/extension/runtime/BaseContentScripts",["require","exports","../../commons/logging/Logger"],function(e,t,n){var r=function(){function e(){this._contentScriptsHash={}}return e.prototype.get=function(t){if(this._contentScriptsHash[t])return this._contentScriptsHash[t];var n=new Error("feature not supported");throw e.logger.error("get",n.message),n},e.logger=n.getLogger("BaseContentScripts"),e}();return r}),define("ubp/extension/contextual/ContextualFeature",["require","exports"],function(e,t){var n;return function(e){e[e.Sandbox=1]="Sandbox",e[e.Scrape=2]="Scrape",e[e.Action=3]="Action",e[e.Style=4]="Style",e[e.MetaData=5]="MetaData",e[e.GetUWLItem=6]="GetUWLItem"}(n||(n={})),n});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/chrome/ChromelikeContentScripts",["require","exports","../BaseContentScripts","../../contextual/ContextualFeature"],function(e,t,n,r){var i=function(e){function t(){e.call(this),this._contentScriptsHash[2]=["/js/ubp/extension/contextual/peer-scripts/libraries/ScrapeLibrary.js","/js/ubp/extension/contextual/peer-scripts/drivers/chrome/ScrapeDriver.js"],this._contentScriptsHash[1]=["/js/ubp/extension/contextual/peer-scripts/libraries/SandboxLibrary.js","/js/ubp/extension/contextual/peer-scripts/drivers/chrome/SandboxDriver.js"],this._contentScriptsHash[3]=["/js/ubp/extension/contextual/peer-scripts/libraries/ActionLibrary.js","/js/ubp/extension/contextual/peer-scripts/drivers/chrome/ActionDriver.js"],this._contentScriptsHash[4]=["/js/ubp/extension/contextual/peer-scripts/libraries/StyleLibrary.js","/js/ubp/extension/contextual/peer-scripts/drivers/chrome/StyleDriver.js"],this._contentScriptsHash[5]=["/js/ubp/extension/contextual/peer-scripts/libraries/MetaDataLibrary.js","/js/ubp/extension/contextual/peer-scripts/drivers/chrome/MetaDataDriver.js"],this._contentScriptsHash[6]=["/js/ubp/extension/contextual/peer-scripts/libraries/GetUWLItemLibrary.js","/js/ubp/extension/contextual/peer-scripts/drivers/chrome/GetUWLItemDriver.js"]}return __extends(t,e),t}(n);return i});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/messaging/ChromePanelMessageTransportStrategy",["require","exports","lib/lodash","lib/bluebird","./BaseTransportStrategy","./primitives/TransportStrategyType"],function(e,t,n,r,i,s){var o=function(e){function t(t){e.call(this,t),n.bindAll(this,"_onMessage","_send"),this._egressBus.subscribe(this._send),this.bind(t.inboundPort,t.outboundPort)}return __extends(t,e),t.prototype.dispatchBus=function(){return e.prototype.dispatchBus.call(this)},t.prototype.forward=function(t){return e.prototype.forward.call(this,t)},t.prototype.bind=function(e,t){var n=this;return r.bind(this).then(function(){n._outboundPort=t,n._inboundPort=e,n._inboundPort.onMessage.addListener(n._onMessage)})},t.prototype.unbind=function(){var e=this;return r.bind(this).then(function(){n.isObject(e._inboundPort)&&e._inboundPort.onMessage.removeListener(e._onMessage),e._inboundPort=null,e._outboundPort=null})},t.prototype._send=function(e){var t={mType:1,source:this._identity,payload:e};n.isObject(this._outboundPort)&&this._outboundPort.postMessage(t)},t.prototype._onMessage=function(e,t){var r=e.data?e.data:e;if(!n.contains(this._validSources,"*")&&!n.contains(this._validSources,r.source)||r.source===this._identity)return;this._dispatchBus.publish(this,r.payload)},t}(i);return o}),define("ubp/extension/runtime/chrome/ChromeLikePanelRuntime",["require","exports","lib/lodash","lib/bluebird","../../../commons/logging/Logger","../../../commons/error/BadRequestError","../../../commons/messaging/ChromePanelMessageTransportStrategy"],function(e,t,n,r,i,s,o){var u=function(){function e(e){this.namespace=e||chrome,this.createLogger(),this.namespace&&this.namespace.runtime&&this.namespace.runtime.onConnect&&this.namespace.runtime.onConnect.addListener(n.bind(this._panelConnectHandler,this))}return e.prototype.getNamespace=function(){return this.namespace},e.prototype.createLogger=function(){e._logger=e._logger||i.getLogger("ChromelikeRuntime")},e.prototype.registerPanelConnect=function(t){var n=this;return this._panelMessageHandler=t,r.bind(this).then(function(){n._panelPort&&n._panelMessageHandler&&(n._setGatewayTransportStrategy(),e._logger.info("_panelConnectHandler","Calling GatewayCore callback that was registered"),n._panelMessageHandler.call(n,n._transport))})},e.prototype.registerPanelDisconnect=function(e){var t=this;return r.bind(this).then(function(){t._registeredPanelDisconnectHandler=e})},e.prototype._panelConnectHandler=function(t){var i=this;return r.bind(this).then(function(){if(!t)throw e._logger.error("_panelConnectHandler","Not a valid panel port"),new s("Not a valid port");e._logger.info("_panelConnectHandler","Connected extension from Panel with name => "+t.name);if(t.name!=e.UBP_PANEL_NAME){var r="Received connection from unrecognized port "+t.name;throw e._logger.error("_panelConnectHandler",r),new s(r)}i._panelPort=t,i._panelPort.onDisconnect.addListener(n.bind(i._panelDisconnectHandler,i)),i._panelMessageHandler&&(i._setGatewayTransportStrategy(),e._logger.info("_panelConnectHandler","Calling GatewayCore callback that was registered"),i._panelMessageHandler.call(i,i._transport))})},e.prototype._setGatewayTransportStrategy=function(){this._panelPort&&this._panelMessageHandler&&(this._transportStrategyOptions={identity:"PlatformHub",inboundPort:this._panelPort,outboundPort:this._panelPort,validOrigins:["*"],validSources:["*"]},this._transport=new o(this._transportStrategyOptions))},e.prototype._panelDisconnectHandler=function(){return this.destroyPanel()},e.prototype.destroyPanel=function(){var e=this;return r.bind(this).then(function(){e._panelPort=null,typeof e._registeredPanelDisconnectHandler=="function"&&e._registeredPanelDisconnectHandler()})},e.prototype.registerPanelMessageHandler=function(e){var t=this;return r.bind(this).then(function(){t._panelPort.onMessage.addListener(e)})},e.prototype.createConnectionToExtension=function(t){var n=this;if(!t||!t.name)return e._logger.error("createConnectionToExtension","Wrong request panel connection request"),r.reject(new s("Wrong request panel connection request"));var i=t.name;return e.UBP_PANEL_NAME!==i?(e._logger.error("createConnectionToExtension","Wrong port name ["+i+"] in the request"),r.reject(new s("Wrong port name ["+i+"] in the request"))):r.bind(this).then(function(){n._panelPort=n.namespace.runtime.connect(t)})},e.prototype.registerExtensionMessageHandler=function(e){var t=this;return r.bind(this).then(function(){t._panelPort.onMessage.addListener(e)})},e.prototype.sendMessageToExtensionPort=function(e){return e.data?this._sendMessageToExternalPort(e.data):this._sendMessageToExternalPort(e)},e.prototype.sendMessageToPanelPort=function(e){return this._sendMessageToExternalPort(e)},e.prototype.addMessageListener=function(e,t){return r.bind(this).then(function(){window.addEventListener(e,t,!1)})},e.prototype._sendMessageToExternalPort=function(e){var t=this;return r.bind(this).then(function(){t._panelPort.postMessage(e)})},e.prototype.sendPostConnectionMessageToExtension=function(){return r.resolve()},e.UBP_PANEL_NAME="UBPv2Panel",e}();return u});var factory=function(){var e=function(){};return e.getGlobalParameters=function(){return{browser:"chrome",partner:"",programCode:"",extensionStage:"prod",partnersRequiringTermsOfUse:["acer1","dell1","lenovo1","mozilla1","msi1","opera1","pokki1","toshiba1","samsung1","sleipnir1"],isTOURequired:function(){return this.partnersRequiringTermsOfUse.indexOf(this.partner)>=0},isTOURequiredForPartner:function(e){return this.partnersRequiringTermsOfUse.indexOf(e)>=0},pageMessagingDriverIncludePatterns:["*.amazon.com","*.amazon.ca","*.amazon.co.uk","*.amazon.de","*.amazon.es","*.amazon.it","*.amazon.fr","*.amazon.in","*.amazon.co.jp","*.amazon.cn","*.amazon.in"],safariPageMessagingDriverIncludePatterns:["http://*.amazon.com/*","http://*.amazon.ca/*","http://*.amazon.co.uk/*","http://*.amazon.de/*","http://*.amazon.es/*","http://*.amazon.it/*","http://*.amazon.fr/*","http://*.amazon.co.jp/*","http://*.amazon.cn/*","http://*.amazon.in/*","https://*.amazon.com/*","https://*.amazon.ca/*","https://*.amazon.co.uk/*","https://*.amazon.de/*","https://*.amazon.es/*","https://*.amazon.it/*","https://*.amazon.fr/*","https://*.amazon.co.jp/*","https://*.amazon.cn/*","https://*.amazon.in/*"],setLocaleTimeout:2e4}},e};typeof module!="undefined"&&module.exports?module.exports=factory():typeof define!="undefined"&&define("configuration/GlobalParameters",[],factory),define("ubp/extension/runtime/chrome/360/ThreeSixtyAPIProvider",["require","exports","lib/bluebird","lib/lodash"],function(e,t,n,r){var i=function(){function e(e){this._runtime=e,chrome&&chrome.windows&&chrome.windows.onFocusChanged&&chrome.windows.onFocusChanged.addListener(r.bind(this._onChromelikeFocusChanged,this)),this._registerAPIs()}return e.prototype._registerAPIs=function(){var e=this;this._runtime.getActiveTabInfo=function(){return e.getActiveTabInfo()}},e.prototype._onChromelikeFocusChanged=function(e){this._lastFocusedWindowID=e},e.prototype._getLastFocusedWindowID=function(){return n.bind(this).then(function(){return this._lastFocusedWindowID>0?n.resolve(this._lastFocusedWindowID):new n(function(e,t){chrome.windows.getLastFocused({},function(n){chrome.runtime.lastError?t(chrome.runtime.lastError):e(n.id)})})})},e.prototype.getActiveTabInfo=function(){var e=this,t=null;return n.bind(this).then(function(){return e._getLastFocusedWindowID()}).then(function(e){t=e}).then(function(){return new n(function(e,t){chrome.tabs.query({active:!0},function(n){chrome.runtime.lastError?t(chrome.runtime.lastError):e(n)})})}).then(function(e){var n=null,r=0;for(;r<e.length;r++)if(t===e[r].windowId){n={activeTab:e[r].id.toString(),title:e[r].title,url:e[r].url};break}return n})},e}();return i}),define("ubp/extension/runtime/platformInfo/userAgent/regexElements/RegexElement",["require","exports"],function(e,t){var n=function(){function e(e,t){this.regex=e,this.replacement=t?t:""}return e.prototype.getRegex=function(){return this.regex},e.prototype.getReplacement=function(){return this.replacement},e.prototype.classify=function(e){var t=e.match(new RegExp(this.getRegex()));if(t)return this._getParseData(t)},e.prototype._getParseData=function(e){var t=this.getReplacement()?this.getReplacement():e[1]||"other",n=isNaN(parseInt(e[2]))?null:parseInt(e[2]),r=isNaN(parseInt(e[3]))?null:parseInt(e[3]),i=isNaN(parseInt(e[4]))?null:parseInt(e[4]),s=n!==null?n+"":"";return s+=r!==null?"."+r:"",s+=i!==null?"."+i:"",{getName:function(){return t},getVersion:function(){return s}}},e}();return n});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/regexElements/os/OSRegexElement",["require","exports","../RegexElement"],function(e,t,n){var r=function(e){function t(t,n){e.call(this,t,n)}return __extends(t,e),t}(n);return r});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/regexElements/device/DeviceRegexElement",["require","exports","../RegexElement"],function(e,t,n){var r=function(e){function t(t,n,r){this._tablet=r?r:!1,e.call(this,t,n)}return __extends(t,e),t.prototype.isTablet=function(){return this._tablet},t}(n);return r});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/regexElements/browsers/BrowserRegexElement",["require","exports","../RegexElement"],function(e,t,n){var r=function(e){function t(t,n){e.call(this,t,n)}return __extends(t,e),t}(n);return r}),define("ubp/extension/runtime/platformInfo/UserAgentRegexVisitor",["require","exports","./userAgent/regexElements/os/OSRegexElement","./userAgent/regexElements/device/DeviceRegexElement","./userAgent/regexElements/browsers/BrowserRegexElement","lib/lodash"],function(e,t,n,r,i,s){var o=function(){function e(e){this.userAgentString=e,this.deviceResult=null,this.osResult=null,this.browserResult=null,this.isTablet=!1}return e.prototype.visit=function(e){e instanceof n&&!this.osResult?this.osResult=e.classify(this.userAgentString):e instanceof r&&!this.deviceResult?(this.deviceResult=e.classify(this.userAgentString),this.isTablet=e.isTablet()):e instanceof i&&!this.browserResult&&(this.browserResult=e.classify(this.userAgentString))},e.prototype.getBrowserName=function(){return this.browserResult?this.browserResult.getName():""},e.prototype.getBrowserVersion=function(){return this.browserResult?this.browserResult.getVersion():""},e.prototype.getOSName=function(){return this.osResult?this.osResult.getName():""},e.prototype.getOSVersion=function(){return this.osResult?this.osResult.getVersion():""},e.prototype.getDeviceName=function(){return this.deviceResult?this.deviceResult.getName():this.getDeviceType()},e.prototype.getDeviceType=function(){return this.deviceResult&&this.isTablet===!0?"Tablet":this.deviceResult&&s.contains(e.mobileFamily,this.deviceResult.getName())?"Mobile":"Desktop"},e.prototype.getDeviceVersion=function(){return this.deviceResult?this.deviceResult.getVersion():""},e.prototype.getUserAgentString=function(){return this.userAgentString},e.mobileFamily=["Android","FireFox Mobile","Opera Mobile","Opera Mini","Jasmine","UP.Browser","Bolt","Dolfin","Tizen Browser","Polaris","BREW"],e}();return o}),define("ubp/extension/runtime/platformInfo/userAgent/parsers/UserAgentParser",["require","exports","../../UserAgentRegexVisitor","lib/bluebird"],function(e,t,n,r){var i=function(){function e(e){this._uaRegexElements=e}return e.prototype.parse=function(e){var t=this,i=new n(e);for(var s=0,o=this._uaRegexElements.length;s<o;s++)this._uaRegexElements[s].accept(i);return r.bind(this).then(function(){return t._extractRuntimeInfo(i,e)})},e.prototype._extractRuntimeInfo=function(e,t){return{browserVersion:e.getBrowserVersion(),operatingSystem:e.getOSName(),device:e.getDeviceName(),browser:e.getBrowserName(),userAgent:t}},e}();return i}),define("ubp/extension/runtime/platformInfo/userAgent/regexElements/RegexElementCollection",["require","exports"],function(e,t){var n=function(){function e(e){this._regexElements=e}return e.prototype.accept=function(e){for(var t=0,n=this._regexElements.length;t<n;t++)e.visit(this._regexElements[t])},e}();return n});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/regexElements/os/AndroidOSUARegexElementCollection",["require","exports","../RegexElementCollection","./OSRegexElement"],function(e,t,n,r){var i=function(e){function t(){var t=[new r("(Android) (\\d+)\\.(\\d+)(?:[.\\-]([a-z0-9]+))?"),new r("(Android)\\-(\\d+)\\.(\\d+)(?:[.\\-]([a-z0-9]+))?"),new r("(Android) Donut"),new r("(Android) Eclair"),new r("(Android) Froyo"),new r("(Android) Gingerbread"),new r("(Android) Honeycomb"),new r("(Silk-Accelerated=[a-z]{4,5})","Android")];e.call(this,t)}return __extends(t,e),t}(n);return i});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/regexElements/os/MacOSUARegexElementCollection",["require","exports","../RegexElementCollection","./OSRegexElement"],function(e,t,n,r){var i=function(e){function t(){var t=[new r("(Mac OS X) (\\d+)[_.](\\d+)(?:[_.](\\d+))?","Mac"),new r("(?:PPC|Intel) (Mac OS X)","Mac")];e.call(this,t)}return __extends(t,e),t}(n);return i});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/regexElements/os/IosOSUARegexElementCollection",["require","exports","../RegexElementCollection","./OSRegexElement"],function(e,t,n,r){var i=function(e){function t(){var t=[new r("(CPU OS|iPhone OS) (\\d+)_(\\d+)(?:_(\\d+))?","IOS"),new r("(iPhone|iPad|iPod); Opera","IOS"),new r("(iPhone|iPad|iPod).*Mac OS X.*Version/(\\d+)\\.(\\d+)","IOS")];e.call(this,t)}return __extends(t,e),t}(n);return i});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/regexElements/os/WindowOSUARegexElementCollection",["require","exports","../RegexElementCollection","./OSRegexElement"],function(e,t,n,r){var i=function(e){function t(){var t=[new r("(Windows (?:NT 5\\.2|NT 5\\.1))","Windows XP"),new r("(Windows NT 6\\.1)","Windows 7"),new r("(Windows NT 6\\.0)","Windows Vista"),new r("(Windows 98|Windows XP|Windows ME|Windows 95|Windows CE|Windows 7|Windows NT 4\\.0|Windows Vista|Windows 2000)"),new r("(Windows NT 6\\.2)","Windows 8"),new r("(Windows NT 6\\.3)","Windows 8.1"),new r("(Windows NT 10\\.0)","Windows 10"),new r("(Windows NT 5\\.0)","Windows 2000"),new r("(WinNT4.0)","Windows NT 4.0"),new r("(Win98)","Windows 98"),new r("(Windows NT \\d\\.\\d)","Windows"),new r("(Windows \\d\\.\\d)")];e.call(this,t)}return __extends(t,e),t}(n);return i});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/regexElements/os/LinuxOSUARegexElementCollection",["require","exports","../RegexElementCollection","./OSRegexElement"],function(e,t,n,r){var i=function(e){function t(){var t=[new r("(SUSE|Fedora|Red Hat|Puppy|PCLinuxOS|CentOS)/(\\d+)\\.(\\d+)\\.(\\d+)","Linux"),new r("(Ubuntu|Kindle|Bada|Lubuntu|BackTrack|Red Hat|Slackware)/(\\d+)\\.(\\d+)","Linux"),new r("OpenBSD|FreeBSD|NetBSD|Ubuntu|Kubuntu|Android|Arch Linux|CentOS|WeTab|Slackware","Linux"),new r("(Linux|BSD)","Linux")];e.call(this,t)}return __extends(t,e),t}(n);return i}),define("ubp/extension/runtime/platformInfo/userAgent/regexElements/os/OSRegexElementCollection",["require","exports","./AndroidOSUARegexElementCollection","./MacOSUARegexElementCollection","./IosOSUARegexElementCollection","./WindowOSUARegexElementCollection","./LinuxOSUARegexElementCollection"],function(e,t,n,r,i,s,o){var u=function(){function e(){this._uaRegexElementArray=[new n,new r,new i,new s,new o]}return e.prototype.accept=function(e){for(var t=0,n=this._uaRegexElementArray.length;t<n;t++)this._uaRegexElementArray[t].accept(e)},e}();return u});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/regexElements/device/TabletDeviceUARegexElementCollection",["require","exports","../RegexElementCollection","./DeviceRegexElement"],function(e,t,n,r){var i=function(e){function t(){var t=[new r("(iPad).*Version/(\\d+)\\.(\\d+)\\.(\\d+)","iPad",!0),new r("(iPad).*Version/(\\d+)\\.(\\d+)","iPad",!0),new r("(iPad)","iPad",!0),new r("(PlayBook).+RIM Tablet OS (\\d+)\\.(\\d+)\\.(\\d+)","Blackberry WebKit",!0),new r("(Silk)/(\\d+)\\.(\\d+)(?:\\.([0-9\\-]+))?","Kindle Fire",!0)];e.call(this,t)}return __extends(t,e),t}(n);return i});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/regexElements/device/MobileDeviceUARegexElementCollection",["require","exports","../RegexElementCollection","./DeviceRegexElement"],function(e,t,n,r){var i=function(e){function t(){var t=[new r("(Fennec)/(\\d+)\\.(\\d+)\\.?([ab]?\\d+[a-z]*)","FireFox Mobile"),new r("(Fennec)/(\\d+)\\.(\\d+)(pre)","FireFox Mobile"),new r("(Fennec)/(\\d+)\\.(\\d+)","FireFox Mobile"),new r("Mobile.*(Firefox)/(\\d+)\\.(\\d+)","FireFox Mobile"),new r("(Opera)/.+Opera Mobi.+Version/(\\d+)\\.(\\d+)","Opera Mobile"),new r("Opera Mobi","Opera Mobile"),new r("(Opera Mini)/(\\d+)\\.(\\d+)","Opera Mini"),new r("(Opera Mini)/att/(\\d+)\\.(\\d+)","Opera Mini"),new r("(Jasmine|Opera Mini||UP\\.Browser|)/(\\d+)\\.(\\d+)\\.(\\d+)"),new r("(Bolt|BOLT|Jasmine|Opera Mini|Opera|Dolfin|Tizen Browser|Polaris)/(\\d+)\\.(\\d+)"),new r("(Jasmine|Polaris|Android|BREW) (\\d+)\\.(\\d+)\\.?(\\d+)?")];e.call(this,t)}return __extends(t,e),t}(n);return i}),define("ubp/extension/runtime/platformInfo/userAgent/regexElements/device/DeviceRegexElementCollection",["require","exports","./TabletDeviceUARegexElementCollection","./MobileDeviceUARegexElementCollection"],function(e,t,n,r){var i=function(){function e(){this._uaRegexElementArray=[new n,new r]}return e.prototype.accept=function(e){for(var t=0,n=this._uaRegexElementArray.length;t<n;t++)this._uaRegexElementArray[t].accept(e)},e}();return i});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/regexElements/browsers/ChromeLikeBrowserRegexElementCollection",["require","exports","../RegexElementCollection","./BrowserRegexElement"],function(e,t,n,r){var i=function(e){function t(){var t=[new r("(Chrome)/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+) Mobile","Chrome Mobile"),new r("(Chromium|Maxthon|Chrome|Vienna|Sleipnir)/(\\d+)\\.(\\d+)\\.(\\d+)"),new r("(Maxthon|Chrome|Sleipnir)/(\\d+)\\.(\\d+)"),new r("(Sleipnir) (\\d+)\\.(\\d+)\\.(\\d+)"),new r("(MetaSr) (\\d+)\\.(\\d+)"),new r("(Fennec)/(\\d+)\\.(\\d+)\\.?([ab]?\\d+[a-z]*)","Firefox mobile"),new r("(Fennec)/(\\d+)\\.(\\d+)(pre)","Firefox mobile"),new r("(Fennec)/(\\d+)\\.(\\d+)","Firefox mobile"),new r("Mobile.*(Firefox)/(\\d+)\\.(\\d+)","Firefox mobile"),new r("(Firefox)/(\\d+)\\.(\\d+)(a\\d+[a-z]*)","Firefox alpha"),new r("(Firefox)/(\\d+)\\.(\\d+)(b\\d+[a-z]*)","Firefox beta"),new r("(Firefox)-(?:\\d+\\.\\d+)?/(\\d+)\\.(\\d+)(a\\d+[a-z]*)","Firefox alpha"),new r("(Firefox)-(?:\\d+\\.\\d+)?/(\\d+)\\.(\\d+)(b\\d+[a-z]*)","Firefox beta"),new r("(Firefox)/(\\d+)\\.(\\d+)\\.(\\d+)"),new r("(Firefox)/(\\d+)\\.(\\d+)(pre|[ab]\\d+[a-z]*)?")];e.call(this,t)}return __extends(t,e),t}(n);return i});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/platformInfo/userAgent/parsers/ChromelikeUAParser",["require","exports","./UserAgentParser","../regexElements/os/OSRegexElementCollection","../regexElements/device/DeviceRegexElementCollection","../regexElements/browsers/ChromeLikeBrowserRegexElementCollection"],function(e,t,n,r,i,s){var o=function(e){function t(){var t=[new r,new i,new s];e.call(this,t)}return __extends(t,e),t}(n);return o});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/extension/runtime/chrome/ChromelikeRuntime",["require","exports","lib/bluebird","lib/lodash","../BaseRuntime","../../process/IFrameProcess","./ChromelikeContentScripts","../../../commons/logging/Logger","../../../commons/error/Errors","./ChromeLikePanelRuntime","configuration/GlobalParameters","./360/ThreeSixtyAPIProvider","../platformInfo/userAgent/parsers/ChromelikeUAParser","../../../commons/error/FeatureUnavailableError","../../../commons/error/InternalError"],function(e,t,n,r,i,s,o,u,a,f,l,c,h,p,d){var v=function(e){function t(n){e.call(this),this.DESKTOP_NOTIFICATION_EVENT="DesktopNotificationEvent",this._templateTypeMap={1:"basic",2:"image"},this._availableFramePool=[],this.name="Chromelike",this._namespace=n||chrome,this.createLogger(),this._namespace.tabs.onUpdated.addListener(r.bind(this._onChromelikePageTurn,this)),this._namespace.runtime.onMessage.addListener(r.bind(this._onChromelikeExternalMessage,this)),this._namespace.tabs.onRemoved.addListener(r.bind(this._onChromelikeTabRemoved,this)),this._namespace&&this._namespace.contextMenus&&this._namespace.contextMenus.onClicked.addListener(r.bind(this._onChromelikeContextMenuClick,this)),this._redirectURLMap={},this.panelRuntime=this.createPanelRuntime(),t._logger.info("constructor","ChromelikeRuntime constructed"),"360"===l.getGlobalParameters().browser&&new c(this)}return __extends(t,e),t.prototype._onChromelikeContextMenuClick=function(e,t){var n={menuItemId:e.menuItemId,tabId:t.id?t.id.toString():null,tabUrl:t.url,srcUrl:e.srcUrl,selectionText:e.selectionText,parentMenuItemId:e.parentMenuItemId,mediaType:e.mediaType,linkUrl:e.linkUrl,pageUrl:e.pageUrl,frameUrl:e.frameUrl,frameId:e.frameId};this._onContextMenuClick(n)},t.prototype.isContextMenuApiSupported=function(){return!0},t.prototype.createContextMenuItem=function(e){var r=this;return new n(function(n,i){r._namespace&&r._namespace.contextMenus?n(r._namespace.contextMenus.create(e,function(){if(chrome.runtime.lastError!==undefined){var e=new d(chrome.runtime.lastError.message);t._logger.error("createContextMenuItem",e.toString()),i(e)}})):i(new p("chrome.contextMenus.create API unavailable"))})},t.prototype.deleteAllContextMenuItems=function(){var e=this;return new n(function(t,n){e._namespace&&e._namespace.contextMenus&&e._namespace.contextMenus.removeAll?e._namespace.contextMenus.removeAll(function(){t()}):n(new p("chrome.contextMenus.removeAll API is unavailable"))})},t.prototype.deleteContextMenuItemById=function(e){var t=this;return new n(function(n,r){t._namespace&&t._namespace.contextMenus&&t._namespace.contextMenus.remove?t._namespace.contextMenus.remove(e,function(){n()}):r(new p("chrome.contextMenus.remove API is unavailable"))})},t.prototype.getNamespace=function(){return this._namespace},t.prototype.createLogger=function(){t._logger=t._logger||u.getLogger("ChromelikeRuntime")},t.prototype._onChromelikeExternalMessage=function(e,t){this._onExternalMessage(e,t.tab.id.toString())},t.prototype.createPanelRuntime=function(){return new f(chrome)},t.prototype.createProcessInstance=function(e,t,n){return new s(e,t,n,this._availableFramePool.pop())},t.prototype.destroyProcessInstance=function(e){var t=this;return e.terminate().then(function(e){t._availableFramePool.push(e)})},t.prototype.sendMessage=function(e,r,i){var s=this;return t._logger.debug("sendMessage","sendMessage called for tab: "+e),(new n(function(n,r){s._namespace.tabs.sendMessage(parseInt(e),i,function(e){if(arguments.length)n(e);else{var i=new Error(this._namespace.runtime.lastError.toString());t._logger.error("sendMessage",i.toString()),r(i)}})})).timeout(this.MESSAGE_TIMEOUT)},t.prototype.executeScript=function(e,r){return t._logger.debug("executeScript","ExecuteScript called for file: "+r),new n(function(n,i){var s=this;this._namespace.tabs.executeScript(parseInt(e),{file:r,allFrames:!1,runAt:"document_idle"},function(e){if(s._checkLastError()){var r=new Error(s._namespace.runtime.lastError.toString());t._logger.error("executeScript",r.toString()),i(r)}n(null)})}.bind(this))},t.prototype.setTimeout=function(e,t){return window.setTimeout(e,t)},t.prototype.clearTimeout=function(e){window.clearTimeout(e)},t.prototype.delay=function(e){var t=this;return new n(function(n){t.setTimeout(n,e)})},t.prototype.executeScripts=function(e,r){return t._logger.debug("executeScripts","ExecuteScripts called for files: "+r),n.bind(this).then(function(){return r}).reduce(function(t,n){return t++,this.executeScript(e,n)},0).then(function(){return"chromelike"})},t.prototype.openNewTab=function(e){var r=this;return(new n(function(n,i){r._namespace&&r._namespace.tabs&&r._namespace.tabs.create?r._namespace.tabs.create({url:e},function(e){if(e&&e.id!==undefined)n(e.id.toString());else{var r=new Error(this._namespace.runtime.lastError.toString());t._logger.error("openNewTab",r.toString()),i(r)}}):i(new Error("_namespace.tabs.create API unavailable"))})).timeout(this.NEW_TAB_TIMEOUT)},t.prototype.createDesktopNotification=function(e,i){var s=this;return n.bind(this).then(function(){var n=s._prepareNotificationOptions(e,i);s._checkNotificationSupport(),s._registerClickHandler(),s._registerCloseHandler(),s._namespace.notifications.create(i.id,n,function(){});try{r.has(i,"redirectURL")&&(s._redirectURLMap[i.id]=i.redirectURL),s._timeoutHandle=s.setTimeout(function(){delete s._redirectURLMap[i.id],s._namespace.notifications.clear(i.id),s._publishNotificationEvent("DesktopNotification.Closed",i.id,"Closed")},t.NOTIFICATION_TIMEOUT)}catch(o){t._logger.error("createDesktopNotification","Error during notification creation for notificationID ["+i.id+"] "+o)}})},t.prototype.getActiveTabInfo=function(){var e=this;return new n(function(t,n){e._namespace.tabs.query({active:!0,lastFocusedWindow:!0},function(e){e.length>0?t({activeTab:e[0].id.toString(),title:e[0].title,url:e[0].url}):n(a.NotFound("No active tab found."))})})},t.prototype.renderButtonText=function(e){var i=this;return new n(function(n,s){if(!(i._namespace&&i._namespace.browserAction&&i._namespace.browserAction.setIcon)){s(new Error("_namespace.browserAction.setIcon API unavailable"));return}e===t.RED_DOT_BADGE?i._namespace.browserAction.setIcon({path:{16:chrome.extension.getURL("static/images/badge_aa_act_16.png"),48:chrome.extension.getURL("static/images/badge_aa_act_48.png"),128:chrome.extension.getURL("static/images/badge_aa_act_128.png")}},function(){n()}):i._namespace.browserAction.setIcon({path:{16:chrome.extension.getURL("static/images/asmile_16.png"),48:chrome.extension.getURL("static/images/asmile_48.png"),128:chrome.extension.getURL("static/images/asmile_128.png")}},function(){if(!i._namespace.browserAction.setBadgeBackgroundColor||!i._namespace.browserAction.setBadgeText){s(new Error("_namespace.browserAction.setBadgeBackgroundColor or _namespace.browserAction.setBadgeText API unavailable"));return}i._namespace.browserAction.setBadgeBackgroundColor({color:i.BADGE_COLOR});if(e===null||r.isUndefined(e)||e.trim()==="")i._namespace.browserAction.setBadgeText({text:""});else{var t=e?e:"";i._namespace.browserAction.setBadgeText({text:t})}n()})})},t.prototype._onChromelikePageTurn=function(e,t,n){n.incognito||this._onPageTurn(e.toString(),n.url,t.status)},t.prototype._onChromelikeTabRemoved=function(e,t){this._onTabRemoved(e.toString())},t.prototype.getExtensionVersion=function(){var e=this._namespace.runtime.getManifest();return e.version},t.prototype.getUserAgent=function(){var e;try{e=window.navigator.userAgent}catch(t){throw a.NotFound("Not able to get userAgent from winow object, Error: "+t.message)}return e},t.prototype.getCookies=function(e){return n.resolve()},t.prototype.getTotalTabsByQuery=function(e){var t=this;return new n(function(n){t._namespace.tabs.query(e,function(e){e!=undefined?n(e.length):n(0)})})},t.prototype.supportAutoCookieSync=function(){return!0},t.prototype.onCookieChangeAction=function(){return n.resolve()},t.prototype.getRuntimeName=function(){return this.name},t.prototype.getContentScripts=function(){return t.CONTENT_SCRIPTS},t.prototype.getLocalProxyUrl=function(){return this._namespace.runtime.getURL(t.LOCAL_PROXY_PATH)},t.prototype.getFromExtensionStorage=function(e){return new n(function(n,r){var i=[];i.push(e),this._bulkGetFromChromeExtensionStorage(i,function(i,s){i?(t._logger.error("getFromExtensionStorage","Error during extension storage get for key ["+e+"] "+i),r(i)):(t._logger.debug("getFromExtensionStorage","extension storage value for key ["+e+"] = ["+s+"]"),n(s[e]))})}.bind(this))},t.prototype.bulkGetFromExtensionStorage=function(e){return new n(function(n,r){this._bulkGetFromChromeExtensionStorage(e,function(e,i){e?(t._logger.error("bulkGetFromExtensionStorage","Error during extension storage get "+e),r(e)):(t._logger.debug("bulkGetFromExtensionStorage","extension storage values retrieved = ["+JSON.stringify(i)+"]"),n(i))})}.bind(this))},t.prototype._bulkGetFromChromeExtensionStorage=function(e,n){this._namespace&&this._namespace.storage&&this._namespace.storage.local&&this._namespace.storage.local.get(e,function(e){if(this._checkLastError())t._logger.error("_bulkGetFromChromeExtensionStorage","Error during retrieving values from storage "),n(new Error("Error during retrieving values from storage"),null);else{var i={};e&&r.forEach(e,function(n,r){i[r]=t._stringifyIfNotString(e[r])}),n(null,i)}}.bind(this))},t.prototype.putInExtensionStorage=function(e,n){var r=this;return this._checkSogouStorageQuota(e,n).bind(this).then(function(){r._putInExtensionStorage(e,n,function(r){if(r)throw t._logger.error("putInExtensionStorage","Error during extension storage set for key ["+e+"] "+r),r;t._logger.debug("putInExtensionStorage","extension storage stored key/value pair ["+e+"] = ["+n+"]")})})},t.prototype._checkSogouStorageQuota=function(e,r){return new n(function(n,i){typeof window[t.SOGOU_CONSTS.GLOBAL_VAR_NAME]=="undefined"?n():r.length>t.SOGOU_CONSTS.STORAGE_MAX_VALUE_SIZE?i(new Error("Error save to storage as value ["+r+"] of key ["+e+"] exceeded "+t.SOGOU_CONSTS.STORAGE_MAX_VALUE_SIZE+" bytes.")):this._namespace&&this._namespace.storage&&this._namespace.storage.local&&this._namespace.storage.local.getBytesInUse(null,function(s){t.SOGOU_CONSTS.STORAGE_QUOTA_BYTES-s-e.length-r.length>=0?n():i(new Error("Error save key ["+e+"]/value ["+r+"] pair to storage as quota will be exceeded."))})}.bind(this))},t.prototype._putInExtensionStorage=function(e,n,r){var i={};i[e]=n,this._namespace&&this._namespace.storage&&this._namespace.storage.local&&this._namespace.storage.local.set(i,function(){this._checkLastError()?(t._logger.error("putInExtensionStorage","Error during storing value in storage "),r(new Error("Error in storing data in storage"))):r(null)}.bind(this))},t.prototype.removeFromExtensionStorage=function(e){return new n(function(n,r){this._removeFromExtensionStorage(e,function(i){i?(t._logger.error("removeFromExtensionStorage","Error during extension storage remove for key ["+e+"] "+i),r(i)):(t._logger.debug("removeFromExtensionStorage","extension storage successfully deleted key ["+e+"]"),n())})}.bind(this))},t.prototype._removeFromExtensionStorage=function(e,n){this._namespace&&this._namespace.storage&&this._namespace.storage.local&&this._namespace.storage.local.remove(e,function(){this._checkLastError()?(t._logger.error("removeFromExtensionStorage","Error during deleting key from storage "),n(new Error("Error in deleting data from storage"))):n(null)}.bind(this))},t.prototype.bulkGetFromPreferencesStorage=function(e){return n.resolve({})},t.prototype.getFromPreferencesStorage=function(e){return n.resolve("")},t.prototype.putInPreferencesStorage=function(e,t){return n.resolve()},t.prototype.removeFromPreferencesStorage=function(e){return n.resolve()},t.prototype.getValueFromLocalStorage=function(e){return n.bind(this).then(function(){var n=localStorage.getItem(e);return t._stringifyIfNotString(n)}).catch(function(e){return e.message+=" (this may be a localStorage failure due to cookies being disabled)",t._logger.error("getValueFromLocalStorage",e.toString()),n.reject(e)})},t.prototype.bulkGetFromLocalStorage=function(e){var i={};return n.bind(this).then(function(){return r.forEach(e,function(e){var n=localStorage.getItem(e);i[e]=t._stringifyIfNotString(n)}),i}).catch(function(e){return e.message+=" (this may be a localStorage failure due to cookies being disabled)",t._logger.error("bulkGetFromLocalStorage",e.toString()),n.reject(e)})},t.prototype.setValueInLocalStorage=function(e,r){return n.bind(this).then(function(){localStorage.setItem(e,r)}).catch(function(e){return e.message+=" (this may be a localStorage failure due to cookies being disabled)",t._logger.error("setValueInLocalStorage",e.toString()),n.reject(e)})},t.prototype.removeValueFromLocalStorage=function(e){return n.bind(this).then(function(){localStorage.removeItem(e)}).catch(function(e){return e.message+=" (this may be a localStorage failure due to cookies being disabled)",t._logger.error("removeValueFromLocalStorage",e.toString()),n.reject(e)})},t.prototype.reloadExtension=function(){var e=this;return n.bind(this).then(function(){e._namespace&&e._namespace.runtime&&e._namespace.runtime.reload&&e._namespace.runtime.reload()})},t.prototype.onExtensionReload=function(e){this.on("onExtensionReload",function(){e()})},t.prototype.isOnline=function(){return n.bind(this).then(function(){return window&&window.navigator&&!window.navigator.onLine?!1:!0})},t.prototype.onBrowserOnline=function(e){window&&window.addEventListener&&window.addEventListener("online",function(t){typeof e=="function"&&e()})},t.prototype._checkLastError=function(){return typeof window[t.SOGOU_CONSTS.GLOBAL_VAR_NAME]=="undefined"?!!this._namespace.runtime.lastError:!1},t._stringifyIfNotString=function(e){return e&&typeof e!="string"?JSON.stringify(e):e},t.prototype.processRemoteConfigurationData=function(e){return n.resolve()},t.prototype.getUAParser=function(){return new h},t.prototype.enableExtensionFeature=function(){return n.resolve(!0)},t.prototype.registerNotificationHandler=function(e){this.on(this.DESKTOP_NOTIFICATION_EVENT,e)},t.prototype._notificationClickHandler=function(e){if(this._redirectURLMap[e]){this._namespace.notifications.clear(e),this.openNewTab(this._redirectURLMap[e]),delete this._redirectURLMap[e];if(!!r.isUndefined(this._timeoutHandle))throw a.NotFound("Timeout handle not found");this.clearTimeout(this._timeoutHandle),this._publishNotificationEvent("DesktopNotification.Closed",e,"Closed")}},t.prototype._notificationCloseHandler=function(e){this._publishNotificationEvent("DesktopNotification.Closed",e,"Closed")},t.prototype._publishNotificationEvent=function(e,t,n){this.notify(this.DESKTOP_NOTIFICATION_EVENT,{name:e,eventArgs:{notificationId:t,status:n}})},t.prototype._registerClickHandler=function(){this._namespace.notifications&&!t.NOTIFICATION_ONCLICK_REGISTERED&&(this._namespace.notifications.onClicked.addListener(r.bind(this._notificationClickHandler,this)),t.NOTIFICATION_ONCLICK_REGISTERED=!0)},t.prototype._registerCloseHandler=function(){this._namespace.notifications&&!t.NOTIFICATION_ONCLOSE_REGISTERED&&(this._namespace.notifications.onClosed.addListener(r.bind(this._notificationCloseHandler,this)),t.NOTIFICATION_ONCLOSE_REGISTERED=!0)},t.prototype._checkNotificationSupport=function(){if(!(this._namespace&&this._namespace.notifications&&this._namespace.notifications.create))throw a.FeatureUnavailable("Chrome.Notifications API is unavailable")},t.prototype._prepareNotificationOptions=function(e,t){var n={type:this._templateTypeMap[e],title:t.title,message:t.text,iconUrl:chrome.extension.getURL("static/images/notif-icon.png")};return t.iconURL&&(n.iconUrl=t.iconURL),n},t.CONTENT_SCRIPTS=new o,t.LOCAL_PROXY_PATH="static/html/localProxy.html",t.NOTIFICATION_TIMEOUT=8e3,t.NOTIFICATION_ONCLICK_REGISTERED=!1,t.NOTIFICATION_ONCLOSE_REGISTERED=!1,t.RED_DOT_BADGE=".",t.SOGOU_CONSTS={GLOBAL_VAR_NAME:"sogouExplorer",STORAGE_QUOTA_BYTES:102400,STORAGE_MAX_VALUE_SIZE:4e3},t}(i);return v}),define("ubp/commons/messaging/clients/network/HTTPMethod",["require","exports"],function(e,t){var n;return function(e){e[e.GET=1]="GET",e[e.HEAD=2]="HEAD",e[e.POST=3]="POST",e[e.PUT=4]="PUT"}(n||(n={})),n}),define("ubp/commons/messaging/clients/network/XHRState",["require","exports"],function(e,t){var n;return function(e){e[e.UNSENT=0]="UNSENT",e[e.OPENED=1]="OPENED",e[e.HEADERS_RECEIVED=2]="HEADERS_RECEIVED",e[e.LOADING=3]="LOADING",e[e.DONE=4]="DONE"}(n||(n={})),n}),define("ubp/commons/messaging/clients/network/HTTPStatus",["require","exports"],function(e,t){var n;return function(e){e[e.OK=200]="OK",e[e.CREATED=201]="CREATED",e[e.ACCEPTED=202]="ACCEPTED",e[e.NO_CONTENT=204]="NO_CONTENT",e[e.BAD_REQUEST=400]="BAD_REQUEST",e[e.FORBIDDEN=403]="FORBIDDEN",e[e.NOTFOUND=404]="NOTFOUND",e[e.INTERNAL_ERROR=500]="INTERNAL_ERROR"}(n||(n={})),n}),define("ubp/commons/messaging/clients/network/NetworkRequestError",["require","exports"],function(e,t){var n=function(){function e(e,t,n,r,i){this.error=e||new Error("Network Error"),this.status=t,this.statusText=n,this.didTimeout=r||!1,this.responseText=i||""}return e}();return n}),define("ubp/commons/messaging/clients/network/NetworkClientError",["require","exports","lib/lodash"],function(e,t,n){var r=function(){function e(e,t,r){var i=n.isUndefined(t)?"":""+t+", ",s=n.isUndefined(r)?"":"response: "+r;this.status=t,this.responseText=r,this.message=e+": "+i+s}return Object.defineProperty(e.prototype,"name",{get:function(){return e.Name},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return this.name+": "+this.message},e.Name="NetworkClientError",e}();return r}),define("ubp/commons/messaging/clients/network/BaseNetworkClient",["require","exports","lib/bluebird","lib/lodash","./HTTPStatus","./HTTPMethod","./NetworkRequestError","./NetworkClientError"],function(e,t,n,r,i,s,o,u){var a=function(){function e(e){this._defaultConfig={headers:{},timeout:0,httpMethod:1,maxAttempts:1,backoffFactor:2,initialRetryInterval:1e3,withCredentials:!1},this.delay=e||r.bind(n.delay,n)}return e.prototype.request=function(e,t,i){var o=this;return n.bind(this).then(function(){t||(t={}),r.defaults(t,o._defaultConfig);if(!e||typeof e!="string")throw new Error("Must provide a string URL: "+e);if(!s[t.httpMethod])throw new Error("Unrecognized HTTPMethod: "+t.httpMethod);if(t.httpMethod!==1&&t.httpMethod!==2||!t.data){var n=t.maxAttempts;return o._buildAndSendRequestWithRetries(e,t,n,i)}throw new Error("Cannot send data in a GET or HEAD request")})},e.prototype._buildAndSendRequest=function(e,t){throw new Error("Implement me! I'm abstract and stuff!")},e.prototype._buildAndSendRequestWithRetries=function(t,i,s,a){var f=this;return n.bind(this).then(function(){if(r.isFunction(a))return a()}).then(function(){return f._buildAndSendRequest(t,i)}).catch(function(r){if(r instanceof o){s--;if(e.isHTTPStatus5xx(r.status)){if(s<=0)throw new u("Network request failed with 5xx error",r.status,r.responseText);return n.bind(f).then(function(){return f.delay(Math.pow(i.backoffFactor,i.maxAttempts-s-1)*i.initialRetryInterval,"_BuildAndSendRequestWithRetries.DelayBetweenAttempts")}).then(function(){return f._buildAndSendRequestWithRetries(t,i,s,a)})}throw e.isHTTPStatus2xx(r.status)?new u("Non-approved 2xx Success",r.status,r.responseText):e.isHTTPStatus3xx(r.status)?new u("3xx Redirection",r.status,r.responseText):e.isHTTPStatus4xx(r.status)?new u("4xx Client Error",r.status,r.responseText):new u("non-2xx/3xx/4xx/5xx status: URL: "+t+" Error: "+JSON.stringify(r))}throw r})},e.isHTTPStatusSuccessful=function(e){return e===200||e===201||e===202||e===204},e.isHTTPStatus2xx=function(e){return Math.floor(e/100)===2},e.isHTTPStatus3xx=function(e){return Math.floor(e/100)===3},e.isHTTPStatus4xx=function(e){return Math.floor(e/100)===4},e.isHTTPStatus5xx=function(e){return Math.floor(e/100)===5},e}();return a});var __extends=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};define("ubp/commons/messaging/clients/network/XHRNetworkClient",["require","exports","lib/bluebird","lib/lodash","./HTTPMethod","./XHRState","./BaseNetworkClient","./NetworkRequestError","../../../logging/Logger"],function(e,t,n,r,i,s,o,u,a){var f=function(e){function t(t){e.call(this),this.xhr=t||XMLHttpRequest;if(!this.xhr)throw new Error("Needs a native XHR constructor")}return __extends(t,e),t.prototype._buildAndSendRequest=function(e,t){var s=this;return new n(function(n,o){var a=new s.xhr;t.withCredentials&&(a.withCredentials=!0),a.open(i[t.httpMethod],e,!0),r.each(t.headers,function(e,t){a.setRequestHeader(t,e)}),t.responseType&&"responseType"in a&&(a.responseType=t.responseType),a.timeout=t.timeout,a.ontimeout=function(){o(new u(new Error("Request timed out"),undefined,undefined,!0))},a.onreadystatechange=function(){switch(a.readyState){case 4:s.onRequestCompleted(a,t,n,o);break;default:}};try{a.send(t.data)}catch(f){o(f)}})},t.prototype.onRequestCompleted=function(e,t,n,i){if(o.isHTTPStatusSuccessful(e.status)){var s=null;try{s=e.response||e.responseText||e.responseXML}catch(a){}if(typeof s=="string"&&t.responseType==="json")try{s=JSON.parse(s)}catch(a){}var f=this.parseResponseHeaders(e.getAllResponseHeaders()),l={data:s,headers:f,status:e.status,statusText:e.statusText};n(l)}else{var c="";try{if(e.responseType==="json")r.isObject(e.response)?c=JSON.stringify(e.response):r.isString(e.response)&&(c=e.response);else if(e.responseType===""||e.responseType==="text")c=e.responseText}catch(a){}i(new u(new Error("HTTP status code: "+e.status+" "+e.statusText),e.status,e.statusText,!1,c))}},t.prototype.parseResponseHeaders=function(e){var t={};if(!e)return t;var n=e.split("\r\n");return r.each(n,function(e){var n=e.indexOf(": "),r=e.slice(0,n);t[r]=e.slice(n+2)}),t},t.logger=a.getLogger("XHRNetworkClient"),t}(o);return f}),define("ubp/commons/Panel/messageSpecifications/PanelMessageName",["require","exports"],function(e,t){var n;return function(e){e[e.GatewayURLResponse=1]="GatewayURLResponse",e[e.ClearPanelCache=2]="ClearPanelCache"}(n||(n={})),n}),define("ubp/extension/panel/PanelManager",["require","exports","lib/lodash","lib/bluebird","../../commons/logging/Logger","../../commons/Panel/messageSpecifications/PanelMessageName","../../commons/error/BadRequestError"],function(e,t,n,r,i,s,o){var u=function(){function e(t,n){this._isStarted=!1,this._handlers={},this._runtime=t,this._networkClient=n,e.logger=e.logger||i.getLogger("PanelManager")}return e.prototype.start=function(){var t=this;if(this._isStarted){var i=new Error("This PanelManager has already been started and can only be started once.");throw e.logger.error("start",i.toString()),i}return this._isStarted=!0,r.bind(this).then(function(){return t._handlers[2]=n.bind(t._handleClearPanelCacheMessage,t),t._handlers[1]=n.bind(t._handleGatewayURLResponse,t),t._runtime.panelRuntime.addMessageListener("message",n.bind(t._gatewayMessageReceiver,t))}).then(function(){return t._runtime.panelRuntime.createConnectionToExtension({name:e.PANEL_CONNECT_PORT_NAME})}).then(function(){return t._runtime.panelRuntime.registerExtensionMessageHandler(n.bind(t._extensionMessageReceiver,t))}).then(function(){e.logger.info("start","Panel Manager started successfully")}).then(function(){t._runtime.panelRuntime.sendPostConnectionMessageToExtension(),e.logger.info("start","Panel Manager connect successfully")}).catch(function(n){throw t._isStarted=!1,e.logger.error("start","Failed to start PanelManager "+n.toString()),n})},e.prototype._handleClearPanelCacheMessage=function(t){var n=this;return r.bind(this).then(function(){return n._runtime.removeValueFromLocalStorage(e.GATEWAY_URL_LOCAL_STORAGE_KEY)}).then(function(){e.logger.debug("_handleClearPanelCacheMessage","Removed value from local storage")})},e.prototype._handleGatewayURLResponse=function(t){var n=this;return r.bind(this).then(function(){var r=t.panelResponseData;if(!(r&&r.messageData&&r.messageData[e.GATEWAY_URL_NAME]))throw e.logger.error("_handleGatewayURLResponse","Unable to retrieve gateway URL from extension"),new o("Unable to retrieve gateway URL from extension");if(n._runtime.isOnline()){var i=r.messageData[e.GATEWAY_URL_NAME];return n._setNewGatewayURLIfChanged(e.PANEL_IFRAME_ID,i)}})},e.prototype._handleReloadExtensionMessage=function(t){var n=this;return r.bind(this).then(function(){n._runtime.reloadExtension()}).catch(function(n){var r=new Error("Error occured while trying to reload extension");t.data&&typeof t.data.replyCallback=="function"&&t.data.replyCallback(r),e.logger.error("_handleReloadExtensionMessage",r.toString())}).then(function(){t.data&&typeof t.data.replyCallback=="function"&&t.data.replyCallback(null),e.logger.debug("_handleReloadExtensionMessage","Successfully called reload extension")})},e.prototype._extensionMessageReceiver=function(t){var n=this;return r.bind(this).then(function(){if(!t)throw e.logger.error("_extensionMessageReceiver","Message received is malformed"),new o("Message received is malformed");e.logger.debug("_extensionMessageReceiver","Message Received from Extension = "+t.data?JSON.stringify(t.data):JSON.stringify(t.payload));if(t.panelHeader){if(!t.panelHeader.messageName)throw e.logger.error("_extensionMessageReceiver","Message name is missing in the message"),new o("Message name is missing in the message");if(!n._handlers[t.panelHeader.messageName])throw e.logger.error("_extensionMessageReceiver","Unrecognized message type received, rejecting the message"),new o("Unrecognized message type received, rejecting the message");return n._handlers[t.panelHeader.messageName].call(n,t)}return n._runtime.sendMessageToIFrame(e.PANEL_IFRAME_ID,t)})},e.prototype._gatewayMessageReceiver=function(t){var n=this;return r.bind(this).then(function(){if(!t)throw e.logger.error("_gatewayMessageReceiver","Message received is malformed"),new o("Message received is malformed");e.logger.debug("_gatewayMessageReceiver","Message received from child frame  "+t.data?JSON.stringify(t.data):JSON.stringify(t.payload));if(!t.panelHeader){var r=t.data&&t.data.payload&&t.data.payload.payload&&t.data.payload.payload.header;return r&&r.namespace==="Platform"&&(r.name==="setLocale"||r.name==="acceptTermsOfUse"?n._handleClearPanelCacheMessage(t):r.name==="reloadExtension"?n._handleReloadExtensionMessage(t):r.name==="closePanel"&&n._runtime.closePanel()),n._runtime.panelRuntime.sendMessageToExtensionPort(t)}if(!t.panelHeader.messageName)throw e.logger.error("_gatewayMessageReceiver","Message name is missing in the message"),new o("Message name is missing in the message");if(!n._handlers[t.panelHeader.messageName])throw e.logger.error("_gatewayMessageReceiver","Unrecognized message type received from the gateway, rejecting the message"),new o("Unrecognized message type received from the gateway, rejecting the message");n._handlers[t.panelHeader.messageName].call(n)}).then(function(){e.logger.debug("_gatewayMessageReceiver","message handled successfully in Panel")})},e.prototype._setNewGatewayURLIfChanged=function(t,n){var i=this;return e.logger.info("_setNewGatewayURLIfChanged","changing gateway URL to "+n),r.bind(this).then(function(){return r.all([i._runtime.getValueFromLocalStorage(e.GATEWAY_URL_LOCAL_STORAGE_KEY).catch(function(t){return e.logger.error("_setNewGatewayURLIfChanged","Unable to retrieve gateway URL from localStorage"+t.toString()),r.resolve("")}),i._runtime.getIFrameAttributes(t)])}).spread(function(s,u){if(s&&s===n&&u&&u.source===n)return e.logger.info("_setNewGatewayURLIfChanged","Gateway URL has not changed, there is no need to change the gateway"),r.resolve();if(!t)throw e.logger.error("_setNewGatewayURLIfChanged","No valid iframe id specified"),new o("No valid iframe id specified");return e.logger.info("_setNewGatewayURLIfChanged","Updating Gateway URL to => "+n),i._runtime.setURLForIframe(t,n)}).then(function(){return i._runtime.setValueInLocalStorage(e.GATEWAY_URL_LOCAL_STORAGE_KEY,n).catch(function(t){e.logger.error("_setNewGatewayURLIfChanged","Unable to set gateway URL to localStorage: "+t.toString())})}).then(function(){e.logger.info("_setNewGatewayURLIfChanged","gateway URL changed to ["+n+"]")})},e.GATEWAY_URL_LOCAL_STORAGE_KEY="UBPv2GatewayURL",e.GATEWAY_URL_NAME="gatewayURL",e.PANEL_IFRAME_ID="UBPv2MainPanelFrame",e.PANEL_CONNECT_PORT_NAME="UBPv2Panel",e}();return u}),define("ubp/commons/logging/ForesterAppender",["require","exports","lib/lodash","lib/bluebird","./LogLevel","../messaging/clients/network/HTTPMethod"],function(e,t,n,r,i,s){var o=function(){function e(e,t,r,i){this._backoffInterval=3e4,this._shouldBackoff=!1,this._timer=null,this._client=e,this._endpoint=t,this._timer=r,n.isNumber(i)&&(this._backoffInterval=i)}return e.prototype.log=function(e,t,i,s,o,u){var a=this;return this._timer.setTimeout(n.bind(function(){a.logAsync(e,t,i,s,o,u)},this),0),r.resolve()},e.prototype.logAsync=function(t,i,s,o,u,a){var f=this;return r.bind(this).then(function(){if(f._shouldBackoff)return r.reject(new Error("ForesterAppender is in back-off mode."));var l=f._formatLogData(t,i,s,o,u,a);return f._client.request(f._endpoint,n.extend(e.NETWORK_REQUEST_CONFIGURATION,{data:l})).then(function(){return r.resolve()}).catch(function(e){return f._shouldBackoff=!0,f._timer.setTimeout(n.bind(function(){f._shouldBackoff=!1},f),f._backoffInterval),r.reject(new Error("ForesterAppender is in back-off mode."))})})},e.prototype._formatLogData=function(e,t,n,r,s,o){return(new Date).toUTCString()+" ["+i[e]+"] "+t+"."+n+" : "+r+", "+s+", "+o+"\n"},e.HEADERS={"Content-Type":"text/plain"},e.NETWORK_REQUEST_CONFIGURATION={httpMethod:3,headers:e.HEADERS,maxAttempts:2,backoffFactor:2,timeout:3e4,initialRetryInterval:1e3},e}();return o}),define("ubp/commons/logging/ConsoleAppender",["require","exports","lib/bluebird","./LogLevel"],function(e,t,n,r){var i=function(){function e(){}return e.prototype.log=function(e,t,i,s,o,u){switch(e){case 5:console.debug(r[e],t,i,s,o,u);break;case 4:console.info(r[e],t,i,s,o,u);break;case 3:console.warn(r[e],t,i,s,o,u);break;case 2:case 1:console.error(r[e],t,i,s,o,u);break;default:console.log(r[e],t,i,s,o,u)}return n.resolve()},e}();return i}),define("ubp/commons/logging/LoggingManager",["require","exports","lib/lodash","lib/bluebird","./Logger","./LogLevel","./ForesterAppender","./ConsoleAppender","../messaging/clients/network/HTTPMethod"],function(e,t,n,r,i,s,o,u,a){var f=function(){function e(){this._configuration=null,this._networkClient=null,this._timer=null,this._refreshTimerId=null,this._refreshInterval=null;if(e._instance)throw new Error("Error: Instantiation failed: Use LoggingManager.getInstance() instead of new.");e._instance=this}return e.getInstance=function(){return e._instance===null&&(e._instance=new e),e._instance},e.prototype.init=function(e,t){this._networkClient=e,this._timer=t},e.prototype.configure=function(t,r){return this._configuration=t,this._refreshInterval=r||e.DEFAULT_CONFIGURATION_REFRESH_INTERVAL,this._refreshTimerId&&this._timer.clearTimeout(this._refreshTimerId),n.isEmpty(this._configuration.remoteConfigurationEndpoint)?this._configureLocal():this._configureRemote()},e.prototype._configureRemote=function(){var t=this;return r.bind(this).then(function(){return t._networkClient.request(t._configuration.remoteConfigurationEndpoint,e.NETWORK_REQUEST_CONFIGURATION)}).then(function(e){var i=n.extend({merged:!0},t._configuration,e.data);return n.isEqual(i,t._configuration)?r.resolve():(t._configuration=i,t._configureLocal())}).finally(function(){t._refreshTimerId=t._timer.setTimeout(n.bind(function(){t._configureRemote()},t),t._refreshInterval)})},e.prototype._configureLocal=function(){return i.root.setLogLevel(s[this._configuration.rootLogLevel]),i.root.removeAppender(e.CONSOLE_LOG_APPENDER_ALIAS),i.root.addAppender(e.CONSOLE_LOG_APPENDER_ALIAS,new u),i.root.removeAppender(e.FORESTER_APPENDER_ALIAS),n.isEmpty(this._configuration.foresterEndpoint)||i.root.addAppender(e.FORESTER_APPENDER_ALIAS,new o(this._networkClient,this._configuration.foresterEndpoint,this._timer,this._configuration.foresterBackoffInterval)),r.resolve()},e.DEFAULT_CONFIGURATION_REFRESH_INTERVAL=6e5,e.CONSOLE_LOG_APPENDER_ALIAS="Console",e.FORESTER_APPENDER_ALIAS="Forester",e.RESPONSE_TYPE="json",e.MAX_ATTEMPTS=2,e.BACKOFF_FACTOR=2,e.NETWORK_TIMEOUT=3e4,e.INITIAL_RETRY_INTERVAL=1e3,e.NETWORK_REQUEST_CONFIGURATION={httpMethod:1,maxAttempts:e.MAX_ATTEMPTS,responseType:e.RESPONSE_TYPE,backoffFactor:e.BACKOFF_FACTOR,timeout:e.NETWORK_TIMEOUT,initialRetryInterval:e.INITIAL_RETRY_INTERVAL},e._instance=null,e}();return f});var factory=function(){var e=function(){};return e.getGatewayConfiguration=function(){return{version:"07-07-15",refreshETagRate:36e5,configuration:{US:{gatewayURL:"https://horizonte.browserapps.amazon.com",gatewayETagURL:"https://horizonte.browserapps.amazon.com/gatewayETag",termsOfUseURL:"https://horizonte.browserapps.amazon.com/tou",loggingConfiguration:{remoteConfigurationEndpoint:"https://ubp-common-us-prod.s3.amazonaws.com/logging/logging-config.js"}},CA:{gatewayURL:"https://horizonte.browserapps.amazon.ca",gatewayETagURL:"https://horizonte.browserapps.amazon.ca/gatewayETag",termsOfUseURL:"https://horizonte.browserapps.amazon.ca/tou",loggingConfiguration:{remoteConfigurationEndpoint:"https://ubp-common-ca-prod.s3.amazonaws.com/logging/logging-config.js"}},UK:{gatewayURL:"https://horizonte.browserapps.amazon.co.uk",gatewayETagURL:"https://horizonte.browserapps.amazon.co.uk/gatewayETag",termsOfUseURL:"https://horizonte.browserapps.amazon.co.uk/tou",loggingConfiguration:{remoteConfigurationEndpoint:"https://ubp-common-uk-prod.s3.amazonaws.com/logging/logging-config.js"}},DE:{gatewayURL:"https://horizonte.browserapps.amazon.de",gatewayETagURL:"https://horizonte.browserapps.amazon.de/gatewayETag",termsOfUseURL:"https://horizonte.browserapps.amazon.de/tou",loggingConfiguration:{remoteConfigurationEndpoint:"https://ubp-common-de-prod.s3.amazonaws.com/logging/logging-config.js"}},FR:{gatewayURL:"https://horizonte.browserapps.amazon.fr",gatewayETagURL:"https://horizonte.browserapps.amazon.fr/gatewayETag",termsOfUseURL:"https://horizonte.browserapps.amazon.fr/tou",loggingConfiguration:{remoteConfigurationEndpoint:"https://ubp-common-fr-prod.s3.amazonaws.com/logging/logging-config.js"}},IT:{gatewayURL:"https://horizonte.browserapps.amazon.it",gatewayETagURL:"https://horizonte.browserapps.amazon.it/gatewayETag",termsOfUseURL:"https://horizonte.browserapps.amazon.it/tou",loggingConfiguration:{remoteConfigurationEndpoint:"https://ubp-common-it-prod.s3.amazonaws.com/logging/logging-config.js"}},JP:{gatewayURL:"https://horizonte.browserapps.amazon.co.jp",gatewayETagURL:"https://horizonte.browserapps.amazon.co.jp/gatewayETag",termsOfUseURL:"https://horizonte.browserapps.amazon.co.jp/tou",loggingConfiguration:{remoteConfigurationEndpoint:"https://ubp-common-jp-prod.s3.amazonaws.com/logging/logging-config.js"}},CN:{gatewayURL:"https://horizonte.browserapps.amazon.cn",gatewayETagURL:"https://horizonte.browserapps.amazon.cn/gatewayETag",termsOfUseURL:"https://horizonte.browserapps.amazon.cn/tou",loggingConfiguration:{remoteConfigurationEndpoint:"https://ubp-common-cn-prod.s3.cn-north-1.amazonaws.com.cn/logging/logging-config.js"}},ES:{gatewayURL:"https://horizonte.browserapps.amazon.es",gatewayETagURL:"https://horizonte.browserapps.amazon.es/gatewayETag",termsOfUseURL:"https://horizonte.browserapps.amazon.es/tou",loggingConfiguration:{remoteConfigurationEndpoint:"https://ubp-common-es-prod.s3.amazonaws.com/logging/logging-config.js"}},IN:{gatewayURL:"https://horizonte.browserapps.amazon.in",gatewayETagURL:"https://horizonte.browserapps.amazon.in/gatewayETag",termsOfUseURL:"https://horizonte.browserapps.amazon.in/tou",loggingConfiguration:{remoteConfigurationEndpoint:"https://ubp-common-in-prod.s3.amazonaws.com/logging/logging-config.js"}}}}},e};typeof module!="undefined"&&module.exports?module.exports=factory():typeof define!="undefined"&&define("configuration/GatewayConfiguration",[],factory),define("ubp/extension/panel/PanelBootstrapper",["require","exports","./PanelManager","../../commons/logging/Logger","../../commons/logging/LoggingManager","configuration/GatewayConfiguration","../../commons/localization/Locale"],function(e,t,n,r,i,s,o){var u=function(){function e(t,u){this._isStarted=!1,this._panelManager=new n(t,u),this._runtime=t,this._networkClient=u,this._loggingConfiguration=s.getGatewayConfiguration().configuration[o[e._DEFAULT_LOCALE]].loggingConfiguration,i.getInstance().init(this._networkClient,this._runtime),r.root.setUniversalContext({installationId:"eb362584-da2a-4bb9-a52c-79e9f56ed535"}),e.logger=e.logger||r.getLogger("PanelBootstrapper"),e.logger.info("constructor","PanelBootstrapper constructed")}return e.prototype.start=function(){var t=this;if(this._isStarted){var n=new Error("This PanelBootstrapper has already been started and can only be started once.");throw e.logger.error("start",n.toString()),n}this._isStarted=!0,this._runtime.getFromExtensionStorage(e._STORAGE_LOCALE_KEY).then(function(n){if(!n||n===""||!o[n])n=o[e._DEFAULT_LOCALE];return t._loggingConfiguration=s.getGatewayConfiguration().configuration[n].loggingConfiguration,i.getInstance().configure(t._loggingConfiguration)}).then(function(){return t._panelManager.start()}).then(function(){e.logger.info("start","PanelBootstrapper started")}).catch(function(n){throw t._isStarted=!1,e.logger.error("start","Failed to start PanelBootstrapper "+n),n})},e._STORAGE_LOCALE_KEY="ubpv2.extension.installation.locale",e._DEFAULT_LOCALE=1,e}();return u}),define("ubp/extension/panel/Chromelike_PanelEntrypoint",["require","exports","../runtime/chrome/ChromelikeRuntime","../../commons/messaging/clients/network/XHRNetworkClient","./PanelBootstrapper"],function(e,t,n,r,i){var s=new n(chrome),o=new r(XMLHttpRequest),u=new i(s,o);u.start()}),require(["ubp/extension/panel/Chromelike_PanelEntrypoint"]);