text: 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 eachProp(e,t){var n;for(n in e)if(e.hasOwnProperty(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 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 d(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 v(e,t,n){var r,i,s,u,a,f,l,c,h,p,v,m=t&&t.split("/"),g=m,y=o.map,b=y&&y["*"];e&&e.charAt(0)==="."&&(t?(o.pkgs[t]?g=m=[t]:g=m.slice(0,m.length-1),e=g.concat(e.split("/")),d(e),i=o.pkgs[r=e[0]],e=e.join("/"),i&&e===r+"/"+i.main&&(e=r)):e.indexOf("./")===0&&(e=e.substring(2)));if(n&&(m||b)&&y){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=y[m.slice(0,f).join("/")];if(s){s=s[l];if(s){c=s,h=a;break}}}if(c)break;!p&&b&&b[l]&&(p=b[l],v=a)}!c&&p&&(c=p,h=v),c&&(u.splice(0,h,c),e=u.join("/"))}return e}function m(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 g(e){var t=o.paths[e];if(t&&isArray(t)&&t.length>1)return m(e),t.shift(),r.require.undef(e),r.require([e]),!0}function y(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 b(e,t,n,i){var s,o,u,a,f=null,c=t?t.name:null,d=e,m=!0,g="";return e||(m=!1,e="_@r"+(h+=1)),a=y(e),f=a[0],e=a[1],f&&(f=v(f,c,i),o=l[f]),e&&(f?o&&o.normalize?g=o.normalize(e,function(e){return v(e,c,i)}):g=v(e,c,i):(g=v(e,c,i),a=y(g),f=a[0],g=a[1],n=!0,s=r.nameToUrl(g))),u=f&&!o&&!n?"_unnormalized"+(p+=1):"",{prefix:f,name:g,parentMap:t,unnormalized:!!u,url:s,originalName:d,isDefine:m,id:(f?f+"!"+g:g)+u}}function w(e){var t=e.id,n=u[t];return n||(n=u[t]=new r.Module(e)),n}function E(e,t,n){var r=e.id,i=u[r];hasProp(l,r)&&(!i||i.defineEmitComplete)?t==="defined"&&n(l[r]):w(e).on(t,n)}function S(e,t){var n=e.requireModules,r=!1;t?t(e):(each(n,function(t){var n=u[t];n&&(n.error=e,n.events.error&&(r=!0,n.emit("error",e)))}),r||req.onError(e))}function x(){globalDefQueue.length&&(apsp.apply(f,[f.length-1,0].concat(globalDefQueue)),globalDefQueue=[])}function T(e){delete u[e]}function N(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=u[s];o&&!e.depMatched[i]&&!n[s]&&(t[s]?(e.defineDep(i,l[s]),e.check()):N(o,t,n))}),n[r]=!0)}function C(){var e,n,i,a,f=o.waitSeconds*1e3,l=f&&r.startTime+f<(new Date).getTime(),c=[],h=[],p=!1,d=!0;if(t)return;t=!0,eachProp(u,function(t){e=t.map,n=e.id;if(!t.enabled)return;e.isDefine||h.push(t);if(!t.error)if(!t.inited&&l)g(n)?(a=!0,p=!0):(c.push(n),m(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,S(i);d&&each(h,function(e){N(e,{},{})}),(!l||a)&&p&&(isBrowser||isWebWorker)&&!s&&(s=setTimeout(function(){s=0,C()},50)),t=!1}function k(e){w(b(e[0],null,!0)).init(e[1],e[2])}function L(e,t,n,r){e.detachEvent&&!isOpera?r&&e.detachEvent(r,t):e.removeEventListener(n,t,!1)}function A(e){var t=e.currentTarget||e.srcElement;return L(t,r.onScriptLoad,"load","onreadystatechange"),L(t,r.onScriptError,"error"),{node:t,id:t&&t.getAttribute("data-requiremodule")}}function O(){var e;x();while(f.length){e=f.shift();if(e[0]===null)return S(makeError("mismatch","Mismatched anonymous define() module: "+e[e.length-1]));k(e)}}var t,n,r,i,s,o={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{},map:{},config:{}},u={},a={},f=[],l={},c={},h=1,p=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=l[e.map.id]={}},module:function(e){return e.module?e.module:e.module={id:e.map.id,uri:e.map.url,config:function(){return o.config&&o.config[e.map.id]||{}},exports:l[e.map.id]}}},n=function(e){this.events=a[e.id]||{},this.map=e,this.shim=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;c[e]||(c[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)try{s=r.execCb(n,o,i,s)}catch(a){e=a}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.id],e.requireType="define",S(this.error=e)}else s=o;this.exports=s,this.map.isDefine&&!this.ignore&&(l[n]=s,req.onResourceLoad&&req.onResourceLoad(r,this.map,this.depMaps)),delete u[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=b(e.prefix);this.depMaps.push(n),E(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,skipMap:!0});if(this.map.unnormalized){n.normalize&&(f=n.normalize(f,function(e){return v(e,l,!0)})||""),s=b(e.prefix+"!"+f,this.map.parentMap),E(s,"defined",bind(this,function(e){this.init([],function(){return e},null,{enabled:!0,ignore:!0})})),a=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&&T(e.map.id)}),S(e)}),i.fromText=bind(this,function(t,n){var s=e.name,o=b(s),u=useInteractive;n&&(t=n),u&&(useInteractive=!1),w(o);try{req.exec(t)}catch(a){throw new Error("fromText eval for "+s+" failed: "+a)}u&&(useInteractive=!0),this.depMaps.push(o),r.completeLoad(s),c([s],i)}),n.load(e.name,c,i,o)})),r.enable(n,this),this.pluginMaps[n.id]=n},enable:function(){this.enabled=!0,this.enabling=!0,each(this.depMaps,bind(this,function(e,t){var n,s,o;if(typeof e=="string"){e=b(e,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap),this.depMaps[t]=e,o=i[e.id];if(o){this.depExports[t]=o(this);return}this.depCount+=1,E(e,"defined",bind(this,function(e){this.defineDep(t,e),this.check()})),this.errback&&E(e,"error",this.errback)}n=e.id,s=u[n],!i[n]&&s&&!s.enabled&&r.enable(e,this)})),eachProp(this.pluginMaps,bind(this,function(e){var t=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:l,urlFetched:c,defQueue:f,Module:n,makeModuleMap:b,nextTick:req.nextTick,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"?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.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=b(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||getGlobal(e.exports)}return t},makeRequire:function(t,n){function s(o,a,f){var c,h,p;return n.enableBuildCallback&&a&&isFunction(a)&&(a.__requireJsBuild=!0),typeof o=="string"?isFunction(a)?S(makeError("requireargs","Invalid require call"),f):t&&i[o]?i[o](u[t.id]):req.get?req.get(r,o,t):(h=b(o,t,!1,!0),c=h.id,hasProp(l,c)?l[c]:S(makeError("notloaded",'Module name "'+c+'" has not been loaded yet for context: '+e+(t?"":". Use require([])")))):(O(),r.nextTick(function(){O(),p=w(b(null,t)),p.skipMap=n.skipMap,p.init(o,a,f,{enabled:!0}),C()}),s)}return n=n||{},mixin(s,{isBrowser:isBrowser,toUrl:function(e){var n=e.lastIndexOf("."),i=null;return n!==-1&&(i=e.substring(n,e.length),e=e.substring(0,n)),r.nameToUrl(v(e,t&&t.id,!0),i)},defined:function(e){return hasProp(l,b(e,t,!1,!0).id)},specified:function(e){return e=b(e,t,!1,!0).id,hasProp(l,e)||hasProp(u,e)}}),t||(s.undef=function(e){x();var n=b(e,t,!0),r=u[e];delete l[e],delete c[n.url],delete a[e],r&&(r.events.defined&&(a[e]=r.events),T(e))}),s},enable:function(e,t){var n=u[e.id];n&&w(e).enable()},completeLoad:function(e){var t,n,r,i=o.shim[e]||{},s=i.exports;x();while(f.length){n=f.shift();if(n[0]===null){n[0]=e;if(t)break;t=!0}else n[0]===e&&(t=!0);k(n)}r=u[e];if(!t&&!l[e]&&r&&!r.inited){if(o.enforceDefine&&(!s||!getGlobal(s))){if(g(e))return;return S(makeError("nodefine","No define call for "+e,null,[e]))}k([e,i.deps||[],i.exportsFn])}C()},nameToUrl:function(e,t){var n,r,i,s,u,a,f,l,c;if(req.jsExtRegExp.test(e))l=e+(t||"");else{n=o.paths,r=o.pkgs,u=e.split("/");for(a=u.length;a>0;a-=1){f=u.slice(0,a).join("/"),i=r[f],c=n[f];if(c){isArray(c)&&(c=c[0]),u.splice(0,a,c);break}if(i){e===i.name?s=i.location+"/"+i.main:s=i.location,u.splice(0,a,s);break}}l=u.join("/"),l+=t||(/\?/.test(l)?"":".js"),l=(l.charAt(0)==="/"||l.match(/^[\w\+\.\-]+:/)?"":o.baseUrl)+l}return o.urlArgs?l+((l.indexOf("?")===-1?"?":"&")+o.urlArgs):l},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=A(e);r.completeLoad(t.id)}},onScriptError:function(e){var t=A(e);if(!g(t.id))return S(makeError("scripterror","Script error",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.1",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,aps=ap.slice,apsp=ap.splice,isBrowser=typeof window!="undefined"&&!!navigator&&!!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=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=function(e){throw e},req.load=function(e,t,n){var r=e&&e.config||{},i;if(isBrowser)return i=r.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),i.type=r.scriptType||"text/javascript",i.charset="utf-8",i.async=!0,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;isWebWorker&&(importScripts(n),e.completeLoad(t))},isBrowser&&eachReverse(scripts(),function(e){head||(head=e.parentNode),dataMain=e.getAttribute("data-main");if(dataMain)return cfg.baseUrl||(src=dataMain.split("/"),mainScript=src.pop(),subPath=src.length?src.join("/")+"/":"./",cfg.baseUrl=subPath,dataMain=mainScript),dataMain=dataMain.replace(jsSuffixRegExp,""),cfg.deps=cfg.deps?cfg.deps.concat(dataMain):[dataMain],!0}),define=function(e,t,n){var r,i;typeof e!="string"&&(n=t,t=e,e=null),isArray(t)||(n=t,t=[]),!t.length&&isFunction(n)&&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(){}),define("Log",[],function(){return window.bistriDebug=!1,function(){if(console&&console.log&&window.bistriDebug){function e(e,t){return t=t||2,String(Array(t).join(0)+e).slice(-t)}var t=new Date,n=e(t.getMonth()+1)+"/"+e(t.getDate())+"/"+e(t.getFullYear()),r=e(t.getUTCHours())+":"+e(t.getUTCMinutes())+":"+e(t.getUTCSeconds())+"."+e(t.getUTCMilliseconds(),3);Array.prototype.unshift.call(arguments,"[%s %s GMT]",n,r),console.log.apply(console,arguments)}}}),define("Utils",["Log"],function(e){function t(){}return t.prototype={isLocalCopy:function(){var e=!1,t=document.querySelectorAll("script");for(var n=0,r=t.length;n<r;n++)t[n].src&&t[n].src.indexOf("bistri.conference.min.js")!=-1&&(t[n].src.match(/^https:\/\/[a-z]+.bistri.com/)||(e=!0));return e}},new t}),define("Deferred",[],function(){function e(){this._done=undefined,this._fail=undefined}return e.prototype={done:function(e){if(typeof e!="function")throw new Error("function expected (Deferred.done)");return this._done=e,this},fail:function(e){if(typeof e!="function")throw new Error("function expected (Deferred.fail)");return this._fail=e,this},resolve:function(){this._done&&this._done.apply(this._done,arguments)},reject:function(){this._fail&&this._fail.apply(this._fail,arguments)}},e}),define("Ajax",["Deferred"],function(e){function t(t){return this.def=new e,this.timer=null,this.abort=!1,this.timeout=t.timeout||undefined,this.url=t.url||location.pathname,this.data=t.data||{},this.type=t.type||"GET",this.onSuccess=t.onSuccess||function(){},this.onError=t.onError||function(){},this.dataType=t.dataType||"text",this.xhr=new XMLHttpRequest,this.xhr.onreadystatechange=this._readystatechange.bind(this),this._doRequest()}return t.prototype={_get:function(){var e="?";for(p in this.data)e.length>1&&(e+="&"),e+=p+"="+this.data[p];this.xhr.open(this.type,this.url+e,!0),this.xhr.send(null)},_post:function(){this.xhr.open(this.type,this.url,!0),this.xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"),this.xhr.send(this.data)},_doRequest:function(){return this[this.type=="POST"?"_post":"_get"](),this.timeout&&(this.timer=setTimeout(function(){this.abort=!0,this.xhr.abort()}.bind(this),this.timeout*1e3)),this.def},_readystatechange:function(){var e;if(this.xhr.readyState==4){this.timer&&clearTimeout(this.timer),e=this.xhr.status;if(e==200){if(typeof this.onSuccess=="function"){var t;switch(this.dataType){case"json":try{t=JSON.parse(this.xhr.responseText)}catch(n){log("[Ajax]",n)}break;case"xml":t=this.xhr.responseXML;break;case"text":default:t=this.xhr.responseText}this.def.resolve(t),this.onSuccess(t)}}else typeof this.onError=="function"&&(this.def.reject(this.xhr,this.abort?"timeout":"error",this.xhr.statusText),this.onError(this.xhr,this.abort?"timeout":"error",this.xhr.statusText))}}},t}),define("Plugin",[],function(){function n(){this.pluginId="webRTCPlugin",this.pluginCallback="webRTCPluginLoaded",this.temPageId=Math.random().toString(36).slice(2),this.isLoaded=!1,this.pluginInserted=!1}var e=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0,t=!!document.documentMode;return n.prototype={insertPlugin:function(){window[this.pluginCallback]=function(){document.querySelector("#"+this.pluginId).setLogFunction(console),document.querySelector("#"+this.pluginId).setLogLevel("SENSITIVE"),this.isLoaded=!0}.bind(this),this.insertObject(document.querySelector("body"),{id:this.pluginId,width:"1px",height:"1px","type ":"application/x-temwebrtcplugin",style:"position:absolute; top:-10000px; left:-10000px;",params:{onload:this.pluginCallback,pluginId:this.pluginId,pageId:this.temPageId,windowless:"false",forceGetAllCams:"false"}}),this.pluginInserted=!0},insertObject:function(e,t){var n,r="<object",i="",s=document.createDocumentFragment(),o=document.createElement("div");for(var u in t)if(u!="params")r+=" "+u+'="'+t[u]+'"';else for(var a in t[u])i+='<param name="'+a+'" value="'+t[u][a]+'">';r+=">"+i+"</object>",o.innerHTML=r,n=o.firstChild;while(o.firstChild)s.appendChild(o.firstChild);return e.appendChild(s),n},usePlugin:function(){return this.pluginInserted},getPlugin:function(){return document.getElementById(this.pluginId)},getTemPageId:function(){return this.temPageId},isPluginInstalled:function(n){var r="Tem",i="TemWebRTCPlugin";if(e){var s=navigator.plugins,o=!1;for(var u=0;u<s.length;u++)if(s[u].name.indexOf(i)>=0){o=!0;break}n(o)}else if(t){try{new ActiveXObject(r+"."+i)}catch(a){n(!1);return}n(!0)}else n(!1)},isPluginLoaded:function(){return this.isLoaded},_createParam:function(e,t){var n=document.createElement("param");return n.setAttribute("name",e),n.setAttribute("value",t),n}},new n}),define("WebRTCNormalize",["Plugin"],function(e){navigator.getUserMedia=navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.getUserMedia||undefined,window.URL=window.URL||window.webkitURL,window.RTCPeerConnection=window.webkitRTCPeerConnection||window.mozRTCPeerConnection||window.RTCPeerConnection||undefined,window.RTCSessionDescription=window.webkitRTCSessionDescription||window.mozRTCSessionDescription||window.RTCSessionDescription||undefined,window.RTCIceCandidate=window.webkitRTCIceCandidate||window.mozRTCIceCandidate||window.RTCIceCandidate||undefined,window.webRtcCompatible=window.URL&&window.RTCPeerConnection&&window.RTCSessionDescription&&window.RTCIceCandidate?!0:!1,window.webRtcCompatible||e.isPluginInstalled(function(t){t?(e.insertPlugin(),navigator.getUserMedia=function(t,n,r){t.audio||(t.audio=!1),e.getPlugin().getUserMedia(t,n,r)},window.URL=window.URL||window.webkitURL,window.RTCPeerConnection=function(t,n){var r=null;if(t){r=t.iceServers;for(var i=0;i<r.length;i++)r[i].urls&&!r[i].url&&(r[i].url=r[i].urls),r[i].hasCredentials=!!r[i].username&&!!r[i].credential}var s=n&&n.mandatory?n.mandatory:null,o=n&&n.optional?n.optional:null;return e.getPlugin().PeerConnection(e.getTemPageId(),r,s,o)},window.RTCSessionDescription=function(t){return e.getPlugin().ConstructSessionDescription(t.type,t.sdp)},window.MediaStreamTrack={},window.MediaStreamTrack.getSources=function(t){e.getPlugin().GetSources(t)},window.RTCIceCandidate=function(t){return t.sdpMid||(t.sdpMid=""),e.getPlugin().ConstructIceCandidate(t.sdpMid,t.sdpMLineIndex,t.candidate)},window.webRtcCompatible=window.URL&&window.RTCPeerConnection&&window.RTCSessionDescription&&window.RTCIceCandidate?!0:!1):window.webRtcCompatible=!1})}),define("WebRTCTools",["WebRTCNormalize"],function(){function e(){this._browser={os:undefined,name:undefined,version:undefined,vendor:undefined},this._desc=null,this._vendor=null,this._compatible=!1,this._init()}return e.prototype={_browsers:{chrome:{code:"CR",minVersion:21,interoperability:{FF:{remoteVersion:21,localVersion:25},SF:{remoteVersion:0,localVersion:0},IE:{remoteVersion:0,localVersion:0}}},firefox:{code:"FF",minVersion:21,interoperability:{CR:{remoteVersion:25,localVersion:21},SF:{remoteVersion:0,localVersion:0},IE:{remoteVersion:0,localVersion:0}}},safari:{code:"SF",minVersion:0,interoperability:{CR:{remoteVersion:25,localVersion:0},FF:{remoteVersion:21,localVersion:0},IE:{remoteVersion:0,localVersion:0}}},trident:{code:"IE",minVersion:0,interoperability:{CR:{remoteVersion:25,localVersion:0},FF:{remoteVersion:21,localVersion:0},SF:{remoteVersion:0,localVersion:0}}},msie:{code:"IE",minVersion:0,interoperability:{CR:{remoteVersion:25,localVersion:0},FF:{remoteVersion:21,localVersion:0},SF:{remoteVersion:0,localVersion:0}}}},_platforms:{iphone:"iOS",ipad:"iOS",ipod:"iOS",macintosh:"MacOSX",windows:"Windows",linux:"Linux",x11:"UNIX"},_vendors:{google:"chrome",mozilla:"firefox",opera:"opr",apple:"safari",yandex:"yabrowser",microsoft:"trident"},_init:function(){this._setBrowserProps(),this._setVendorProps();if(navigator.getUserMedia&&window.RTCPeerConnection&&window.RTCSessionDescription&&window.RTCIceCandidate){var e=this._browsers[this._browser.name];if(!e||this._browser.version<e.minVersion)return;this._desc=e.code+"::"+this._browser.version,this._compatible=!0}},_setBrowserProps:function(e){var t=navigator.userAgent.match(/(chrome|safari|firefox|msie|trident)\/?\s*(\d+)/i),n={iPhone:"iPhone",iPad:"iPad",iPod:"iPod",Win:"Windows",Mac:"Macintosh",Linux:"Linux",X11:"X11"};for(var r in n)if(navigator.appVersion.indexOf(r)!=-1){this._browser.os=this._platforms[n[r].toLowerCase()];break}t&&(this._browser.name=t[1].toLowerCase(),this._browser.version=parseInt(t[2]))},_setVendorProps:function(e){var t,n=navigator.userAgent.match(/(yabrowser|opr|chrome|safari|firefox|msie|trident)\/?\s*(\d+)/gi);if(n)if(n.length>1){var r=(navigator.vendor||"").match(/(yandex|opera|google|apple)/i);if(r){var i=this._vendors[r[1].toLowerCase()];this._browser.vendor=r[1].toLowerCase();for(var s=0;s<n.length;s++)n[s].toLowerCase().indexOf(i)!=-1&&(t=n[s])}}else t=n[0];t&&(this._vendor=t.toLowerCase())},isCompatible:function(){return this._compatible},isRemoteClientCompatible:function(e){if(!e)return!1;var t=e.split("::")[0],n=Number(e.split("::")[1]),r=this._browsers[this._browser.name],i;return t==r.code?!0:(i=r.interoperability[t]||!1,i&&i.remoteVersion<=n&&i.localVersion<=this._browser.version?!0:!1)},areDatachannelsCompatible:function(e){if(this.getCompatibilityMode(e)){var t=this._browsers[this._browser.name].code,n=this._browser.version,r=e.split("::")[0],i=Number(e.split("::")[1]);return t=="CR"&&n<32||r=="CR"&&i<32?!1:!0}return!0},getCompatibilityMode:function(e){var t=e.split("::")[0],n=this._browsers[this._browser.name];return t==n.code?!1:n.code+">"+t},getClientDescription:function(){return this._desc},getVendorDescription:function(){return this._vendor},getVendorsDescription:function(e){return this._vendor+">"+e},getBrowser:function(){return this._browser},isFirefox:function(){return this._browser.name==="firefox"},isChrome:function(){return this._browser.name==="chrome"&&this._browser.vendor==="google"},isSafari:function(){return this._browser.name==="safari"&&this._browser.vendor==="apple"},isOpera:function(){return this._browser.name==="chrome"&&this._browser.vendor==="opera"},isIE:function(){return this._browser.name==="trident"||this._browser.name==="msie"}},new e}),define("Config",["Log","WebRTCTools"],function(e,t){function n(){this.VERSION="3.0.b-f8c66e9",this.API_SERVER="https://api.bistri.com",this.TURN_SERVERS=[],this.STUN_SERVERS=[],this.PLUGIN_URL=undefined,this.CHROME_EXT_ID=undefined,this.FIREFOX_EXT_ID=undefined,this.EXT_AUTO_RELOAD=!0,this.USER_ID=undefined,this.localTurnServers=!1,this.localStunServers=!1}return n.prototype={set:function(e){var n=t.getBrowser();e.userId&&(this.USER_ID=e.userId),e.chromeExtId&&(this.CHROME_EXT_ID=e.chromeExtId),e.firefoxExtId&&(this.FIREFOX_EXT_ID=e.firefoxExtId),e.hasOwnProperty("extAutoReload")&&(this.EXT_AUTO_RELOAD=e.extAutoReload),e.pluginUrl&&n.os&&(this.PLUGIN_URL=e.pluginUrl[n.os.toLowerCase()]),e.turn&&!this.localTurnServers&&(this.TURN_SERVERS=[],e.turn.forEach(function(e){var t=e.url.split("@");n.name=="chrome"&&n.version<28?(this.TURN_SERVERS.push({url:"turn:"+e.url+"?transport=udp",credential:e.credential}),this.TURN_SERVERS.push({url:"turn:"+e.url+"?transport=tcp",credential:e.credential})):n.name=="chrome"&&n.version>=28?(this.TURN_SERVERS.push({url:"turn:"+t[1]+"?transport=udp",credential:e.credential,username:t[0]}),this.TURN_SERVERS.push({url:"turn:"+t[1]+"?transport=tcp",credential:e.credential,username:t[0]})):n.name=="firefox"&&n.version>=28?(this.TURN_SERVERS.push({url:"turn:"+t[1]+"?transport=udp",credential:e.credential,username:t[0]}),this.TURN_SERVERS.push({url:"turn:"+t[1]+"?transport=tcp",credential:e.credential,username:t[0]})):this.TURN_SERVERS.push({url:"turn:"+t[1],credential:e.credential,username:t[0]})}.bind(this))),e.stun&&!this.localStunServers&&(this.STUN_SERVERS=[],e.stun.forEach(function(e){this.TURN_SERVERS.push({url:"stun:"+e}),this.STUN_SERVERS.push({url:"stun:"+e})}.bind(this))),e.turnServers&&e.turnServers.length&&(this.localTurnServers=!0,this.TURN_SERVERS=e.turnServers),e.stunServers&&e.stunServers.length&&(this.localStunServers=!0,this.STUN_SERVERS=e.stunServers,this.TURN_SERVERS.join(e.stunServers))}},new n});var JSON;JSON||(JSON={}),function(){function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a=="object"&&typeof a.toJSON=="function"&&(a=a.toJSON(e)),typeof rep=="function"&&(a=rep.call(t,e,a));switch(typeof a){case"string":return quote(a);case"number":return isFinite(a)?String(a):"null";case"boolean":case"null":return String(a);case"object":if(!a)return"null";gap+=indent,u=[];if(Object.prototype.toString.apply(a)==="[object Array]"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||"null";return i=u.length===0?"[]":gap?"[\n"+gap+u.join(",\n"+gap)+"\n"+o+"]":"["+u.join(",")+"]",gap=o,i}if(rep&&typeof rep=="object"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]=="string"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?": ":":")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?": ":":")+i));return i=u.length===0?"{}":gap?"{\n"+gap+u.join(",\n"+gap)+"\n"+o+"}":"{"+u.join(",")+"}",gap=o,i}}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return typeof t=="string"?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function f(e){return e<10?"0"+e:e}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(e){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","	":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(e,t,n){var r;gap="",indent="";if(typeof n=="number")for(r=0;r<n;r+=1)indent+=" ";else typeof n=="string"&&(indent=n);rep=t;if(!t||typeof t=="function"||typeof t=="object"&&typeof t.length=="number")return str("",{"":e});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i=="object")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),SockJS=function(){var e=document,t=window,n={},r=function(){};r.prototype.addEventListener=function(e,t){this._listeners||(this._listeners={}),e in this._listeners||(this._listeners[e]=[]);var r=this._listeners[e];n.arrIndexOf(r,t)===-1&&r.push(t);return},r.prototype.removeEventListener=function(e,t){if(!(this._listeners&&e in this._listeners))return;var r=this._listeners[e],i=n.arrIndexOf(r,t);if(i!==-1){r.length>1?this._listeners[e]=r.slice(0,i).concat(r.slice(i+1)):delete this._listeners[e];return}return},r.prototype.dispatchEvent=function(e){var t=e.type,n=Array.prototype.slice.call(arguments,0);this["on"+t]&&this["on"+t].apply(this,n);if(this._listeners&&t in this._listeners)for(var r=0;r<this._listeners[t].length;r++)this._listeners[t][r].apply(this,n)};var i=function(e,t){this.type=e;if(typeof t!="undefined")for(var n in t){if(!t.hasOwnProperty(n))continue;this[n]=t[n]}};i.prototype.toString=function(){var e=[];for(var t in this){if(!this.hasOwnProperty(t))continue;var n=this[t];typeof n=="function"&&(n="[function]"),e.push(t+"="+n)}return"SimpleEvent("+e.join(", ")+")"};var s=function(e){var t=this;t._events=e||[],t._listeners={}};s.prototype.emit=function(e){var t=this;t._verifyType(e);if(t._nuked)return;var n=Array.prototype.slice.call(arguments,1);t["on"+e]&&t["on"+e].apply(t,n);if(e in t._listeners)for(var r=0;r<t._listeners[e].length;r++)t._listeners[e][r].apply(t,n)},s.prototype.on=function(e,t){var n=this;n._verifyType(e);if(n._nuked)return;e in n._listeners||(n._listeners[e]=[]),n._listeners[e].push(t)},s.prototype._verifyType=function(e){var t=this;n.arrIndexOf(t._events,e)===-1&&n.log("Event "+JSON.stringify(e)+" not listed "+JSON.stringify(t._events)+" in "+t)},s.prototype.nuke=function(){var e=this;e._nuked=!0;for(var t=0;t<e._events.length;t++)delete e[e._events[t]];e._listeners={}};var o="abcdefghijklmnopqrstuvwxyz0123456789_";n.random_string=function(e,t){t=t||o.length;var n,r=[];for(n=0;n<e;n++)r.push(o.substr(Math.floor(Math.random()*t),1));return r.join("")},n.random_number=function(e){return Math.floor(Math.random()*e)},n.random_number_string=function(e){var t=(""+(e-1)).length,r=Array(t+1).join("0");return(r+n.random_number(e)).slice(-t)},n.getOrigin=function(e){e+="/";var t=e.split("/").slice(0,3);return t.join("/")},n.isSameOriginUrl=function(e,n){return n||(n=t.location.href),e.split("/").slice(0,3).join("/")===n.split("/").slice(0,3).join("/")},n.getParentDomain=function(e){if(/^[0-9.]*$/.test(e))return e;if(/^\[/.test(e))return e;if(!/[.]/.test(e))return e;var t=e.split(".").slice(1);return t.join(".")},n.objectExtend=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e};var u="_jp";n.polluteGlobalNamespace=function(){u in t||(t[u]={})},n.closeFrame=function(e,t){return"c"+JSON.stringify([e,t])},n.userSetCode=function(e){return e===1e3||e>=3e3&&e<=4999},n.countRTO=function(e){var t;return e>100?t=3*e:t=e+200,t},n.log=function(){t.console&&console.log&&console.log.apply&&console.log.apply(console,arguments)},n.bind=function(e,t){return e.bind?e.bind(t):function(){return e.apply(t,arguments)}},n.flatUrl=function(e){return e.indexOf("?")===-1&&e.indexOf("#")===-1},n.amendUrl=function(t){var r=e.location;if(!t)throw new Error("Wrong url for SockJS");if(!n.flatUrl(t))throw new Error("Only basic urls are supported in SockJS");return t.indexOf("//")===0&&(t=r.protocol+t),t.indexOf("/")===0&&(t=r.protocol+"//"+r.host+t),t=t.replace(/[/]+$/,""),t},n.arrIndexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},n.arrSkip=function(e,t){var r=n.arrIndexOf(e,t);if(r===-1)return e.slice();var i=e.slice(0,r);return i.concat(e.slice(r+1))},n.isArray=Array.isArray||function(e){return{}.toString.call(e).indexOf("Array")>=0},n.delay=function(e,t){return typeof e=="function"&&(t=e,e=0),setTimeout(t,e)};var a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,f={"\0":"\\u0000","":"\\u0001","":"\\u0002","":"\\u0003","":"\\u0004","":"\\u0005","":"\\u0006","":"\\u0007","\b":"\\b","	":"\\t","\n":"\\n","":"\\u000b","\f":"\\f","\r":"\\r","":"\\u000e","":"\\u000f","":"\\u0010","":"\\u0011","":"\\u0012","":"\\u0013","":"\\u0014","":"\\u0015","":"\\u0016","":"\\u0017","":"\\u0018","":"\\u0019","":"\\u001a","":"\\u001b","":"\\u001c","":"\\u001d","":"\\u001e","":"\\u001f",'"':'\\"',"\\":"\\\\","":"\\u007f","":"\\u0080","":"\\u0081","":"\\u0082","":"\\u0083","":"\\u0084","":"\\u0085","":"\\u0086","":"\\u0087","":"\\u0088","":"\\u0089","":"\\u008a","":"\\u008b","":"\\u008c","":"\\u008d","":"\\u008e","":"\\u008f","":"\\u0090","":"\\u0091","":"\\u0092","":"\\u0093","":"\\u0094","":"\\u0095","":"\\u0096","":"\\u0097","":"\\u0098","":"\\u0099","":"\\u009a","":"\\u009b","":"\\u009c","":"\\u009d","":"\\u009e","":"\\u009f","­":"\\u00ad","؀":"\\u0600","؁":"\\u0601","؂":"\\u0602","؃":"\\u0603","؄":"\\u0604","܏":"\\u070f","឴":"\\u17b4","឵":"\\u17b5","‌":"\\u200c","‍":"\\u200d","‎":"\\u200e","‏":"\\u200f","\u2028":"\\u2028","\u2029":"\\u2029","‪":"\\u202a","‫":"\\u202b","‬":"\\u202c","‭":"\\u202d","‮":"\\u202e"," ":"\\u202f","⁠":"\\u2060","⁡":"\\u2061","⁢":"\\u2062","⁣":"\\u2063","⁤":"\\u2064","⁥":"\\u2065","⁦":"\\u2066","⁧":"\\u2067","⁨":"\\u2068","⁩":"\\u2069","⁪":"\\u206a","⁫":"\\u206b","⁬":"\\u206c","⁭":"\\u206d","⁮":"\\u206e","⁯":"\\u206f","﻿":"\\ufeff","￰":"\\ufff0","￱":"\\ufff1","￲":"\\ufff2","￳":"\\ufff3","￴":"\\ufff4","￵":"\\ufff5","￶":"\\ufff6","￷":"\\ufff7","￸":"\\ufff8","￹":"\\ufff9","￺":"\\ufffa","￻":"\\ufffb","￼":"\\ufffc","�":"\\ufffd","":"\\ufffe","":"\\uffff"},l=/[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f80-\u0f83\u0f93\u0f9d\u0fa2\u0fa7\u0fac\u0fb9\u1939-\u193a\u1a17\u1b6b\u1cda-\u1cdb\u1dc0-\u1dcf\u1dfc\u1dfe\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbe\u1fc9\u1fcb\u1fd3\u1fdb\u1fe3\u1feb\u1fee-\u1fef\u1ff9\u1ffb\u1ffd\u2000-\u2001\u20d0-\u20d1\u20d4-\u20d7\u20e7-\u20e9\u2126\u212a-\u212b\u2329-\u232a\u2adc\u302b-\u302c\uaab2-\uaab3\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa2d\ufa30-\ufa6d\ufa70-\ufad9\ufb1d\ufb1f\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4e\ufff0-\uffff]/g,c,h=JSON&&JSON.stringify||function(e){return a.lastIndex=0,a.test(e)&&(e=e.replace(a,function(e){return f[e]})),'"'+e+'"'},p=function(e){var t,n={},r=[];for(t=0;t<65536;t++)r.push(String.fromCharCode(t));return e.lastIndex=0,r.join("").replace(e,function(e){return n[e]="\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4),""}),e.lastIndex=0,n};n.quote=function(e){var t=h(e);return l.lastIndex=0,l.test(t)?(c||(c=p(l)),t.replace(l,function(e){return c[e]})):t};var d=["websocket","xdr-streaming","xhr-streaming","iframe-eventsource","iframe-htmlfile","xdr-polling","xhr-polling","iframe-xhr-polling","jsonp-polling"];n.probeProtocols=function(){var e={};for(var t=0;t<d.length;t++){var n=d[t];e[n]=T[n]&&T[n].enabled()}return e},n.detectProtocols=function(e,t,n){var r={},i=[];t||(t=d);for(var s=0;s<t.length;s++){var o=t[s];r[o]=e[o]}var u=function(e){var t=e.shift();r[t]?i.push(t):e.length>0&&u(e)};return n.websocket!==!1&&u(["websocket"]),r["xhr-streaming"]&&!n.null_origin?i.push("xhr-streaming"):r["xdr-streaming"]&&!n.cookie_needed&&!n.null_origin?i.push("xdr-streaming"):u(["iframe-eventsource","iframe-htmlfile"]),r["xhr-polling"]&&!n.null_origin?i.push("xhr-polling"):r["xdr-polling"]&&!n.cookie_needed&&!n.null_origin?i.push("xdr-polling"):u(["iframe-xhr-polling","jsonp-polling"]),i};var v="_sockjs_global";n.createHook=function(){var e="a"+n.random_string(8);if(!(v in t)){var r={};t[v]=function(e){return e in r||(r[e]={id:e,del:function(){delete r[e]}}),r[e]}}return t[v](e)},n.attachMessage=function(e){n.attachEvent("message",e)},n.attachEvent=function(n,r){typeof t.addEventListener!="undefined"?t.addEventListener(n,r,!1):(e.attachEvent("on"+n,r),t.attachEvent("on"+n,r))},n.detachMessage=function(e){n.detachEvent("message",e)},n.detachEvent=function(n,r){typeof t.addEventListener!="undefined"?t.removeEventListener(n,r,!1):(e.detachEvent("on"+n,r),t.detachEvent("on"+n,r))};var m={},g=!1,y=function(){for(var e in m)m[e](),delete m[e]},b=function(){if(g)return;g=!0,y()};n.attachEvent("unload",b),n.unload_add=function(e){var t=n.random_string(8);return m[t]=e,g&&n.delay(y),t},n.unload_del=function(e){e in m&&delete m[e]},n.createIframe=function(t,r){var i=e.createElement("iframe"),s,o,u=function(){clearTimeout(s);try{i.onload=null}catch(e){}i.onerror=null},a=function(){i&&(u(),setTimeout(function(){i&&i.parentNode.removeChild(i),i=null},0),n.unload_del(o))},f=function(e){i&&(a(),r(e))},l=function(e,t){try{i&&i.contentWindow&&i.contentWindow.postMessage(e,t)}catch(n){}};return i.src=t,i.style.display="none",i.style.position="absolute",i.onerror=function(){f("onerror")},i.onload=function(){clearTimeout(s),s=setTimeout(function(){f("onload timeout")},2e3)},e.body.appendChild(i),s=setTimeout(function(){f("timeout")},15e3),o=n.unload_add(a),{post:l,cleanup:a,loaded:u}},n.createHtmlfile=function(e,r){var i=new ActiveXObject("htmlfile"),s,o,a,f=function(){clearTimeout(s)},l=function(){i&&(f(),n.unload_del(o),a.parentNode.removeChild(a),a=i=null,CollectGarbage())},c=function(e){i&&(l(),r(e))},h=function(e,t){try{a&&a.contentWindow&&a.contentWindow.postMessage(e,t)}catch(n){}};i.open(),i.write('<html><script>document.domain="'+document.domain+'";'+"</s"+"cript></html>"),i.close(),i.parentWindow[u]=t[u];var p=i.createElement("div");return i.body.appendChild(p),a=i.createElement("iframe"),p.appendChild(a),a.src=e,s=setTimeout(function(){c("timeout")},15e3),o=n.unload_add(l),{post:h,cleanup:l,loaded:f}};var w=function(){};w.prototype=new s(["chunk","finish"]),w.prototype._start=function(e,r,i,s){var o=this;try{o.xhr=new XMLHttpRequest}catch(u){}if(!o.xhr)try{o.xhr=new t.ActiveXObject("Microsoft.XMLHTTP")}catch(u){}if(t.ActiveXObject||t.XDomainRequest)r+=(r.indexOf("?")===-1?"?":"&")+"t="+ +(new Date);o.unload_ref=n.unload_add(function(){o._cleanup(!0)});try{o.xhr.open(e,r,!0)}catch(a){o.emit("finish",0,""),o._cleanup();return}if(!s||!s.no_credentials)o.xhr.withCredentials="true";if(s&&s.headers)for(var f in s.headers)o.xhr.setRequestHeader(f,s.headers[f]);o.xhr.onreadystatechange=function(){if(o.xhr){var e=o.xhr;switch(e.readyState){case 3:try{var t=e.status,n=e.responseText}catch(e){}t===1223&&(t=204),n&&n.length>0&&o.emit("chunk",t,n);break;case 4:var t=e.status;t===1223&&(t=204),o.emit("finish",t,e.responseText),o._cleanup(!1)}}},o.xhr.send(i)},w.prototype._cleanup=function(e){var t=this;if(!t.xhr)return;n.unload_del(t.unload_ref),t.xhr.onreadystatechange=function(){};if(e)try{t.xhr.abort()}catch(r){}t.unload_ref=t.xhr=null},w.prototype.close=function(){var e=this;e.nuke(),e._cleanup(!0)};var E=n.XHRCorsObject=function(){var e=this,t=arguments;n.delay(function(){e._start.apply(e,t)})};E.prototype=new w;var S=n.XHRLocalObject=function(e,t,r){var i=this;n.delay(function(){i._start(e,t,r,{no_credentials:!0})})};S.prototype=new w;var x=n.XDRObject=function(e,t,r){var i=this;n.delay(function(){i._start(e,t,r)})};x.prototype=new s(["chunk","finish"]),x.prototype._start=function(e,t,r){var i=this,s=new XDomainRequest;t+=(t.indexOf("?")===-1?"?":"&")+"t="+ +(new Date);var o=s.ontimeout=s.onerror=function(){i.emit("finish",0,""),i._cleanup(!1)};s.onprogress=function(){i.emit("chunk",200,s.responseText)},s.onload=function(){i.emit("finish",200,s.responseText),i._cleanup(!1)},i.xdr=s,i.unload_ref=n.unload_add(function(){i._cleanup(!0)});try{i.xdr.open(e,t),i.xdr.send(r)}catch(u){o()}},x.prototype._cleanup=function(e){var t=this;if(!t.xdr)return;n.unload_del(t.unload_ref),t.xdr.ontimeout=t.xdr.onerror=t.xdr.onprogress=t.xdr.onload=null;if(e)try{t.xdr.abort()}catch(r){}t.unload_ref=t.xdr=null},x.prototype.close=function(){var e=this;e.nuke(),e._cleanup(!0)},n.isXHRCorsCapable=function(){return t.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?1:t.XDomainRequest&&e.domain?2:j.enabled()?3:4};var T=function(e,r,i){if(this===t)return new T(e,r,i);var s=this,o;s._options={devel:!1,debug:!1,protocols_whitelist:[],info:undefined,rtt:undefined},i&&n.objectExtend(s._options,i),s._base_url=n.amendUrl(e),s._server=s._options.server||n.random_number_string(1e3),s._options.protocols_whitelist&&s._options.protocols_whitelist.length?o=s._options.protocols_whitelist:(typeof r=="string"&&r.length>0?o=[r]:n.isArray(r)?o=r:o=null,o&&s._debug('Deprecated API: Use "protocols_whitelist" option instead of supplying protocol list as a second parameter to SockJS constructor.')),s._protocols=[],s.protocol=null,s.readyState=T.CONNECTING,s._ir=W(s._base_url),s._ir.onfinish=function(e,t){s._ir=null,e?(s._options.info&&(e=n.objectExtend(e,s._options.info)),s._options.rtt&&(t=s._options.rtt),s._applyInfo(e,t,o),s._didClose()):s._didClose(1002,"Can't connect to server",!0)}};T.prototype=new r,T.version="0.3.4",T.CONNECTING=0,T.OPEN=1,T.CLOSING=2,T.CLOSED=3,T.prototype._debug=function(){this._options.debug&&n.log.apply(n,arguments)},T.prototype._dispatchOpen=function(){var e=this;e.readyState===T.CONNECTING?(e._transport_tref&&(clearTimeout(e._transport_tref),e._transport_tref=null),e.readyState=T.OPEN,e.dispatchEvent(new i("open"))):e._didClose(1006,"Server lost session")},T.prototype._dispatchMessage=function(e){var t=this;if(t.readyState!==T.OPEN)return;t.dispatchEvent(new i("message",{data:e}))},T.prototype._dispatchHeartbeat=function(e){var t=this;if(t.readyState!==T.OPEN)return;t.dispatchEvent(new i("heartbeat",{}))},T.prototype._didClose=function(e,t,r){var s=this;if(s.readyState!==T.CONNECTING&&s.readyState!==T.OPEN&&s.readyState!==T.CLOSING)throw new Error("INVALID_STATE_ERR");s._ir&&(s._ir.nuke(),s._ir=null),s._transport&&(s._transport.doCleanup(),s._transport=null);var o=new i("close",{code:e,reason:t,wasClean:n.userSetCode(e)});if(!n.userSetCode(e)&&s.readyState===T.CONNECTING&&!r){if(s._try_next_protocol(o))return;o=new i("close",{code:2e3,reason:"All transports failed",wasClean:!1,last_event:o})}s.readyState=T.CLOSED,n.delay(function(){s.dispatchEvent(o)})},T.prototype._didMessage=function(e){var t=this,n=e.slice(0,1);switch(n){case"o":t._dispatchOpen();break;case"a":var r=JSON.parse(e.slice(1)||"[]");for(var i=0;i<r.length;i++)t._dispatchMessage(r[i]);break;case"m":var r=JSON.parse(e.slice(1)||"null");t._dispatchMessage(r);break;case"c":var r=JSON.parse(e.slice(1)||"[]");t._didClose(r[0],r[1]);break;case"h":t._dispatchHeartbeat()}},T.prototype._try_next_protocol=function(t){var r=this;r.protocol&&(r._debug("Closed transport:",r.protocol,""+t),r.protocol=null),r._transport_tref&&(clearTimeout(r._transport_tref),r._transport_tref=null);for(;;){var i=r.protocol=r._protocols.shift();if(!i)return!1;if(T[i]&&T[i].need_body===!0&&(!e.body||typeof e.readyState!="undefined"&&e.readyState!=="complete"))return r._protocols.unshift(i),r.protocol="waiting-for-load",n.attachEvent("load",function(){r._try_next_protocol()}),!0;if(!!T[i]&&!!T[i].enabled(r._options)){var s=T[i].roundTrips||1,o=(r._options.rto||0)*s||5e3;r._transport_tref=n.delay(o,function(){r.readyState===T.CONNECTING&&r._didClose(2007,"Transport timeouted")});var u=n.random_string(8),a=r._base_url+"/"+r._server+"/"+u;return r._debug("Opening transport:",i," url:"+a," RTO:"+r._options.rto),r._transport=new T[i](r,a,r._base_url),!0}r._debug("Skipping transport:",i)}},T.prototype.close=function(e,t){var r=this;if(e&&!n.userSetCode(e))throw new Error("INVALID_ACCESS_ERR");return r.readyState!==T.CONNECTING&&r.readyState!==T.OPEN?!1:(r.readyState=T.CLOSING,r._didClose(e||1e3,t||"Normal closure"),!0)},T.prototype.send=function(e){var t=this;if(t.readyState===T.CONNECTING)throw new Error("INVALID_STATE_ERR");return t.readyState===T.OPEN&&t._transport.doSend(n.quote(""+e)),!0},T.prototype._applyInfo=function(t,r,i){var s=this;s._options.info=t,s._options.rtt=r,s._options.rto=n.countRTO(r),s._options.info.null_origin=!e.domain;var o=n.probeProtocols();s._protocols=n.detectProtocols(o,i,t)};var N=T.websocket=function(e,r){var i=this,s=r+"/websocket";s.slice(0,5)==="https"?s="wss"+s.slice(5):s="ws"+s.slice(4),i.ri=e,i.url=s;var o=t.WebSocket||t.MozWebSocket;i.ws=new o(i.url),i.ws.onmessage=function(e){i.ri._didMessage(e.data)},i.unload_ref=n.unload_add(function(){i.ws.close()}),i.ws.onclose=function(){i.ri._didMessage(n.closeFrame(1006,"WebSocket connection broken"))}};N.prototype.doSend=function(e){this.ws.send("["+e+"]")},N.prototype.doCleanup=function(){var e=this,t=e.ws;t&&(t.onmessage=t.onclose=null,t.close(),n.unload_del(e.unload_ref),e.unload_ref=e.ri=e.ws=null)},N.enabled=function(){return!!t.WebSocket||!!t.MozWebSocket},N.roundTrips=2;var C=function(){};C.prototype.send_constructor=function(e){var t=this;t.send_buffer=[],t.sender=e},C.prototype.doSend=function(e){var t=this;t.send_buffer.push(e),t.send_stop||t.send_schedule()},C.prototype.send_schedule_wait=function(){var e=this,t;e.send_stop=function(){e.send_stop=null,clearTimeout(t)},t=n.delay(25,function(){e.send_stop=null,e.send_schedule()})},C.prototype.send_schedule=function(){var e=this;if(e.send_buffer.length>0){var t="["+e.send_buffer.join(",")+"]";e.send_stop=e.sender(e.trans_url,t,function(t,n){e.send_stop=null,t===!1?e.ri._didClose(1006,"Sending error "+n):e.send_schedule_wait()}),e.send_buffer=[]}},C.prototype.send_destructor=function(){var e=this;e._send_stop&&e._send_stop(),e._send_stop=null};var k=function(t,r,i){var s=this;if(!("_send_form"in s)){var o=s._send_form=e.createElement("form"),u=s._send_area=e.createElement("textarea");u.name="d",o.style.display="none",o.style.position="absolute",o.method="POST",o.enctype="application/x-www-form-urlencoded",o.acceptCharset="UTF-8",o.appendChild(u),e.body.appendChild(o)}var o=s._send_form,u=s._send_area,a="a"+n.random_string(8);o.target=a,o.action=t+"/jsonp_send?i="+a;var f;try{f=e.createElement('<iframe name="'+a+'">')}catch(l){f=e.createElement("iframe"),f.name=a}f.id=a,o.appendChild(f),f.style.display="none";try{u.value=r}catch(c){n.log("Your browser is seriously broken. Go home! "+c.message)}o.submit();var h=function(e){if(!f.onerror)return;f.onreadystatechange=f.onerror=f.onload=null,n.delay(500,function(){f.parentNode.removeChild(f),f=null}),u.value="",i(!0)};return f.onerror=f.onload=h,f.onreadystatechange=function(e){f.readyState=="complete"&&h()},h},L=function(e){return function(t,n,r){var i=new e("POST",t+"/xhr_send",n);return i.onfinish=function(e,t){r(e===200||e===204,"http status "+e)},function(e){r(!1,e)}}},A=function(t,r){var i,s=e.createElement("script"),o,u=function(e){o&&(o.parentNode.removeChild(o),o=null),s&&(clearTimeout(i),s.parentNode.removeChild(s),s.onreadystatechange=s.onerror=s.onload=s.onclick=null,s=null,r(e),r=null)},a=!1,f=null;s.id="a"+n.random_string(8),s.src=t,s.type="text/javascript",s.charset="UTF-8",s.onerror=function(e){f||(f=setTimeout(function(){a||u(n.closeFrame(1006,"JSONP script loaded abnormally (onerror)"))},1e3))},s.onload=function(e){u(n.closeFrame(1006,"JSONP script loaded abnormally (onload)"))},s.onreadystatechange=function(e){if(/loaded|closed/.test(s.readyState)){if(s&&s.htmlFor&&s.onclick){a=!0;try{s.onclick()}catch(t){}}s&&u(n.closeFrame(1006,"JSONP script loaded abnormally (onreadystatechange)"))}};if(typeof s.async=="undefined"&&e.attachEvent)if(!/opera/i.test(navigator.userAgent)){try{s.htmlFor=s.id,s.event="onclick"}catch(l){}s.async=!0}else o=e.createElement("script"),o.text="try{var a = document.getElementById('"+s.id+"'); if(a)a.onerror();}catch(x){};",s.async=o.async=!1;typeof s.async!="undefined"&&(s.async=!0),i=setTimeout(function(){u(n.closeFrame(1006,"JSONP script loaded abnormally (timeout)"))},35e3);var c=e.getElementsByTagName("head")[0];return c.insertBefore(s,c.firstChild),o&&c.insertBefore(o,c.firstChild),u},O=T["jsonp-polling"]=function(e,t){n.polluteGlobalNamespace();var r=this;r.ri=e,r.trans_url=t,r.send_constructor(k),r._schedule_recv()};O.prototype=new C,O.prototype._schedule_recv=function(){var e=this,t=function(t){e._recv_stop=null,t&&(e._is_closing||e.ri._didMessage(t)),e._is_closing||e._schedule_recv()};e._recv_stop=M(e.trans_url+"/jsonp",A,t)},O.enabled=function(){return!0},O.need_body=!0,O.prototype.doCleanup=function(){var e=this;e._is_closing=!0,e._recv_stop&&e._recv_stop(),e.ri=e._recv_stop=null,e.send_destructor()};var M=function(e,r,i){var s="a"+n.random_string(6),o=e+"?c="+escape(u+"."+s),a=0,f=function(e){switch(a){case 0:delete t[u][s],i(e);break;case 1:i(e),a=2;break;case 2:delete t[u][s]}},l=r(o,f);t[u][s]=l;var c=function(){t[u][s]&&(a=1,t[u][s](n.closeFrame(1e3,"JSONP user aborted read")))};return c},_=function(){};_.prototype=new C,_.prototype.run=function(e,t,n,r,i){var s=this;s.ri=e,s.trans_url=t,s.send_constructor(L(i)),s.poll=new Y(e,r,t+n,i)},_.prototype.doCleanup=function(){var e=this;e.poll&&(e.poll.abort(),e.poll=null)};var D=T["xhr-streaming"]=function(e,t){this.run(e,t,"/xhr_streaming",rt,n.XHRCorsObject)};D.prototype=new _,D.enabled=function(){return t.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest&&!/opera/i.test(navigator.userAgent)},D.roundTrips=2,D.need_body=!0;var P=T["xdr-streaming"]=function(e,t){this.run(e,t,"/xhr_streaming",rt,n.XDRObject)};P.prototype=new _,P.enabled=function(){return!!t.XDomainRequest},P.roundTrips=2;var H=T["xhr-polling"]=function(e,t){this.run(e,t,"/xhr",rt,n.XHRCorsObject)};H.prototype=new _,H.enabled=D.enabled,H.roundTrips=2;var B=T["xdr-polling"]=function(e,t){this.run(e,t,"/xhr",rt,n.XDRObject)};B.prototype=new _,B.enabled=P.enabled,B.roundTrips=2;var j=function(){};j.prototype.i_constructor=function(e,t,r){var i=this;i.ri=e,i.origin=n.getOrigin(r),i.base_url=r,i.trans_url=t;var s=r+"/iframe.html";i.ri._options.devel&&(s+="?t="+ +(new Date)),i.window_id=n.random_string(8),s+="#"+i.window_id,i.iframeObj=n.createIframe(s,function(e){i.ri._didClose(1006,"Unable to load an iframe ("+e+")")}),i.onmessage_cb=n.bind(i.onmessage,i),n.attachMessage(i.onmessage_cb)},j.prototype.doCleanup=function(){var e=this;if(e.iframeObj){n.detachMessage(e.onmessage_cb);try{e.iframeObj.iframe.contentWindow&&e.postMessage("c")}catch(t){}e.iframeObj.cleanup(),e.iframeObj=null,e.onmessage_cb=e.iframeObj=null}},j.prototype.onmessage=function(e){var t=this;if(e.origin!==t.origin)return;var n=e.data.slice(0,8),r=e.data.slice(8,9),i=e.data.slice(9);if(n!==t.window_id)return;switch(r){case"s":t.iframeObj.loaded(),t.postMessage("s",JSON.stringify([T.version,t.protocol,t.trans_url,t.base_url]));break;case"t":t.ri._didMessage(i)}},j.prototype.postMessage=function(e,t){var n=this;n.iframeObj.post(n.window_id+e+(t||""),n.origin)},j.prototype.doSend=function(e){this.postMessage("m",e)},j.enabled=function(){var e=navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Konqueror")!==-1;return(typeof t.postMessage=="function"||typeof t.postMessage=="object")&&!e};var F,I=function(e,r){parent!==t?parent.postMessage(F+e+(r||""),"*"):n.log("Can't postMessage, no parent window.",e,r)},q=function(){};q.prototype._didClose=function(e,t){I("t",n.closeFrame(e,t))},q.prototype._didMessage=function(e){I("t",e)},q.prototype._doSend=function(e){this._transport.doSend(e)},q.prototype._doCleanup=function(){this._transport.doCleanup()},n.parent_origin=undefined,T.bootstrap_iframe=function(){var r;F=e.location.hash.slice(1);var i=function(e){if(e.source!==parent)return;typeof n.parent_origin=="undefined"&&(n.parent_origin=e.origin);if(e.origin!==n.parent_origin)return;var i=e.data.slice(0,8),s=e.data.slice(8,9),o=e.data.slice(9);if(i!==F)return;switch(s){case"s":var u=JSON.parse(o),a=u[0],f=u[1],l=u[2],c=u[3];a!==T.version&&n.log('Incompatibile SockJS! Main site uses: "'+a+'", the iframe:'+' "'+T.version+'".');if(!n.flatUrl(l)||!n.flatUrl(c)){n.log("Only basic urls are supported in SockJS");return}if(!n.isSameOriginUrl(l)||!n.isSameOriginUrl(c)){n.log("Can't connect to different domain from within an iframe. ("+JSON.stringify([t.location.href,l,c])+")");return}r=new q,r._transport=new q[f](r,l,c);break;case"m":r._doSend(o);break;case"c":r&&r._doCleanup(),r=null}};n.attachMessage(i),I("s")};var R=function(e,t){var r=this;n.delay(function(){r.doXhr(e,t)})};R.prototype=new s(["finish"]),R.prototype.doXhr=function(e,t){var r=this,i=(new Date).getTime(),s=new t("GET",e+"/info"),o=n.delay(8e3,function(){s.ontimeout()});s.onfinish=function(e,t){clearTimeout(o),o=null;if(e===200){var n=(new Date).getTime()-i,s=JSON.parse(t);typeof s!="object"&&(s={}),r.emit("finish",s,n)}else r.emit("finish")},s.ontimeout=function(){s.close(),r.emit("finish")}};var U=function(t){var r=this,i=function(){var e=new j;e.protocol="w-iframe-info-receiver";var n=function(t){if(typeof t=="string"&&t.substr(0,1)==="m"){var n=JSON.parse(t.substr(1)),i=n[0],s=n[1];r.emit("finish",i,s)}else r.emit("finish");e.doCleanup(),e=null},i={_options:{},_didClose:n,_didMessage:n};e.i_constructor(i,t,t)};e.body?i():n.attachEvent("load",i)};U.prototype=new s(["finish"]);var z=function(){var e=this;n.delay(function(){e.emit("finish",{},2e3)})};z.prototype=new s(["finish"]);var W=function(e){if(n.isSameOriginUrl(e))return new R(e,n.XHRLocalObject);switch(n.isXHRCorsCapable()){case 1:return new R(e,n.XHRLocalObject);case 2:return new R(e,n.XDRObject);case 3:return new U(e);default:return new z}},X=q["w-iframe-info-receiver"]=function(e,t,r){var i=new R(r,n.XHRLocalObject);i.onfinish=function(t,n){e._didMessage("m"+JSON.stringify([t,n])),e._didClose()}};X.prototype.doCleanup=function(){};var V=T["iframe-eventsource"]=function(){var e=this;e.protocol="w-iframe-eventsource",e.i_constructor.apply(e,arguments)};V.prototype=new j,V.enabled=function(){return"EventSource"in t&&j.enabled()},V.need_body=!0,V.roundTrips=3;var $=q["w-iframe-eventsource"]=function(e,t){this.run(e,t,"/eventsource",Z,n.XHRLocalObject)};$.prototype=new _;var J=T["iframe-xhr-polling"]=function(){var e=this;e.protocol="w-iframe-xhr-polling",e.i_constructor.apply(e,arguments)};J.prototype=new j,J.enabled=function(){return t.XMLHttpRequest&&j.enabled()},J.need_body=!0,J.roundTrips=3;var K=q["w-iframe-xhr-polling"]=function(e,t){this.run(e,t,"/xhr",rt,n.XHRLocalObject)};K.prototype=new _;var Q=T["iframe-htmlfile"]=function(){var e=this;e.protocol="w-iframe-htmlfile",e.i_constructor.apply(e,arguments)};Q.prototype=new j,Q.enabled=function(){return j.enabled()},Q.need_body=!0,Q.roundTrips=3;var G=q["w-iframe-htmlfile"]=function(e,t){this.run(e,t,"/htmlfile",nt,n.XHRLocalObject)};G.prototype=new _;var Y=function(e,t,n,r){var i=this;i.ri=e,i.Receiver=t,i.recv_url=n,i.AjaxObject=r,i._scheduleRecv()};Y.prototype._scheduleRecv=function(){var e=this,t=e.poll=new e.Receiver(e.recv_url,e.AjaxObject),n=0;t.onmessage=function(t){n+=1,e.ri._didMessage(t.data)},t.onclose=function(n){e.poll=t=t.onmessage=t.onclose=null,e.poll_is_closing||(n.reason==="permanent"?e.ri._didClose(1006,"Polling error ("+n.reason+")"):e._scheduleRecv())}},Y.prototype.abort=function(){var e=this;e.poll_is_closing=!0,e.poll&&e.poll.abort()};var Z=function(e){var t=this,r=new EventSource(e);r.onmessage=function(e){t.dispatchEvent(new i("message",{data:unescape(e.data)}))},t.es_close=r.onerror=function(e,s){var o=s?"user":r.readyState!==2?"network":"permanent";t.es_close=r.onmessage=r.onerror=null,r.close(),r=null,n.delay(200,function(){t.dispatchEvent(new i("close",{reason:o}))})}};Z.prototype=new r,Z.prototype.abort=function(){var e=this;e.es_close&&e.es_close({},!0)};var et,tt=function(){if(et===undefined)if("ActiveXObject"in t)try{et=!!(new ActiveXObject("htmlfile"))}catch(e){}else et=!1;return et},nt=function(e){var r=this;n.polluteGlobalNamespace(),r.id="a"+n.random_string(6,26),e+=(e.indexOf("?")===-1?"?":"&")+"c="+escape(u+"."+r.id);var s=tt()?n.createHtmlfile:n.createIframe,o;t[u][r.id]={start:function(){o.loaded()},message:function(e){r.dispatchEvent(new i("message",{data:e}))},stop:function(){r.iframe_close({},"network")}},r.iframe_close=function(e,n){o.cleanup(),r.iframe_close=o=null,delete t[u][r.id],r.dispatchEvent(new i("close",{reason:n}))},o=s(e,function(e){r.iframe_close({},"permanent")})};nt.prototype=new r,nt.prototype.abort=function(){var e=this;e.iframe_close&&e.iframe_close({},"user")};var rt=function(e,t){var n=this,r=0;n.xo=new t("POST",e,null),n.xo.onchunk=function(e,t){if(e!==200)return;for(;;){var s=t.slice(r),o=s.indexOf("\n");if(o===-1)break;r+=o+1;var u=s.slice(0,o);n.dispatchEvent(new i("message",{data:u}))}},n.xo.onfinish=function(e,t){n.xo.onchunk(e,t),n.xo=null;var r=e===200?"network":"permanent";n.dispatchEvent(new i("close",{reason:r}))}};return rt.prototype=new r,rt.prototype.abort=function(){var e=this;e.xo&&(e.xo.close(),e.dispatchEvent(new i("close",{reason:"user"})),e.xo=null)},T.getUtils=function(){return n},T.getIframeTransport=function(){return j},T}(),"_sockjs_onload"in window&&setTimeout(_sockjs_onload,1),typeof define=="function"&&define.amd&&define("sockjs",[],function(){return SockJS}),define("Websocket",["Log","sockjs"],function(e,t){function n(e){this._url=e,this._eventsHandlers={},this._socket=null,this._socketId=undefined,this._opened=!1,this._retry=2e3,this._maxRetry=12,this._retryCount=0,this._heartbeatCheck=4e4,this._heartbeatTimeout=75e3,this._heartbeatInterval=undefined,this._lastHeartbeat=0,this._reconnectionTimer=undefined,this._reconnectionDelay=24e4,this.connect()}return n.prototype={connect:function(){if(this._opened)return;this._reconnectionTimer&&this._clearTimer();var t=this;this._socket=new SockJS(this._url+"/conference",null,{debug:!1,protocols_whitelist:["websocket","xhr-polling","iframe-xhr-polling","jsonp-polling"]}),this._socketId=this._socket._server,this._socket.onheartbeat=function(t,n){return function(){t==n._socketId&&(n._reconnectionTimer&&(e("[Websocket] Connection resumed, reconnection process aborted"),n._clearTimer(),n._startHeartBeatCheck()),n._lastHeartbeat=(new Date).getTime(),n.emit("heartbeat",{}))}}(this._socketId,t),this._socket.onerror=function(t,n){return function(r){t==n._socketId&&(e("[Websocket] Error (%s)",t),n._fireHandler("error",r))}}(this._socketId,t),this._socket.onopen=function(e,t){return function(){e==t._socketId&&(t._retryCount=0,t._opened=!0,t._fireHandler("open"),t._startHeartBeatCheck())}}(this._socketId,t),this._socket.onclose=function(t,n){return function(r){if(t==n._socketId){e("[Websocket] Disconnection: "+r.reason+" ("+r.code+")"),n._stopHeartbeatCheck();switch(r.code){case 1e3:n._fireHandler("disconnect");case 56:n._opened&&(n._opened=!1,n._socket=null,n._socketId=undefined);break;default:n._autoReconnect()}}}}(this._socketId,t),this._socket.onmessage=function(t,n){return function(r){var i;if(t==n._socketId){try{i=JSON.parse(r.data)}catch(r){e("[Websocket] Fail to parse string:",i)}i&&n._fireHandler(i.type,i.data)}}}(this._socketId,t)},reconnect:function(){this._opened=!1,this._socket=null,this._socketId=undefined,this.connect()},disconnect:function(){this._socket.close()},on:function(t,n){typeof n!="function"?e('[Websocket] Fail to add handler "'+t+'": function expected'):(t in this._eventsHandlers||(this._eventsHandlers[t]=[]),this._eventsHandlers[t].push(n))},emit:function(t,n){try{var r=JSON.stringify({type:t,data:n});this._socket.send(r)}catch(i){e("[Websocket] Fail to stringify JSON object:",n)}},_fireHandler:function(e,t){if(e in this._eventsHandlers){var n=this._eventsHandlers[e];for(var r=0,i=n.length;r<i;r++)n[r](t)}},_autoReconnect:function(){(this._retryCount<this._maxRetry||!this._maxRetry)&&this._retryCount++,setTimeout(function(){this.reconnect()}.bind(this),this._fibonacci(this._retryCount)*1e3+this._randomDelay())},_startHeartBeatCheck:function(){this._heartbeatInterval||(e("[Websocket] Start heartbeat check process"),this._heartbeatInterval=setInterval(function(){var t=(new Date).getTime();t-this._lastHeartbeat>this._heartbeatTimeout&&(e("[Websocket] No heartbeat detected. Auto-reconnection in %s minutes",this._reconnectionDelay/6e4),this._reconnectionTimer=setTimeout(function(){e("[Websocket] Auto-reconnection after %s minutes of inactivity",this._reconnectionDelay/6e4),this._autoReconnect(),this._reconnectionTimer=undefined}.bind(this),this._reconnectionDelay),this._stopHeartbeatCheck())}.bind(this),this._heartbeatCheck))},_stopHeartbeatCheck:function(){this._heartbeatInterval&&(e("[Websocket] Stop heartbeat check process"),clearInterval(this._heartbeatInterval),this._heartbeatInterval=undefined,this._lastHeartbeat=0)},_fibonacci:function(e){var t=1;return e==0?t:e==1?(t+=1,t):this._fibonacci(e-1)+this._fibonacci(e-2)},_clearTimer:function(){clearTimeout(this._reconnectionTimer),this._reconnectionTimer=undefined},_randomDelay:function(){return Math.round(Math.random()*4)+1}},n}),define("MD5",[],function(){return function(){function e(e,t){var o=e[0],u=e[1],a=e[2],f=e[3];o=n(o,u,a,f,t[0],7,-680876936),f=n(f,o,u,a,t[1],12,-389564586),a=n(a,f,o,u,t[2],17,606105819),u=n(u,a,f,o,t[3],22,-1044525330),o=n(o,u,a,f,t[4],7,-176418897),f=n(f,o,u,a,t[5],12,1200080426),a=n(a,f,o,u,t[6],17,-1473231341),u=n(u,a,f,o,t[7],22,-45705983),o=n(o,u,a,f,t[8],7,1770035416),f=n(f,o,u,a,t[9],12,-1958414417),a=n(a,f,o,u,t[10],17,-42063),u=n(u,a,f,o,t[11],22,-1990404162),o=n(o,u,a,f,t[12],7,1804603682),f=n(f,o,u,a,t[13],12,-40341101),a=n(a,f,o,u,t[14],17,-1502002290),u=n(u,a,f,o,t[15],22,1236535329),o=r(o,u,a,f,t[1],5,-165796510),f=r(f,o,u,a,t[6],9,-1069501632),a=r(a,f,o,u,t[11],14,643717713),u=r(u,a,f,o,t[0],20,-373897302),o=r(o,u,a,f,t[5],5,-701558691),f=r(f,o,u,a,t[10],9,38016083),a=r(a,f,o,u,t[15],14,-660478335),u=r(u,a,f,o,t[4],20,-405537848),o=r(o,u,a,f,t[9],5,568446438),f=r(f,o,u,a,t[14],9,-1019803690),a=r(a,f,o,u,t[3],14,-187363961),u=r(u,a,f,o,t[8],20,1163531501),o=r(o,u,a,f,t[13],5,-1444681467),f=r(f,o,u,a,t[2],9,-51403784),a=r(a,f,o,u,t[7],14,1735328473),u=r(u,a,f,o,t[12],20,-1926607734),o=i(o,u,a,f,t[5],4,-378558),f=i(f,o,u,a,t[8],11,-2022574463),a=i(a,f,o,u,t[11],16,1839030562),u=i(u,a,f,o,t[14],23,-35309556),o=i(o,u,a,f,t[1],4,-1530992060),f=i(f,o,u,a,t[4],11,1272893353),a=i(a,f,o,u,t[7],16,-155497632),u=i(u,a,f,o,t[10],23,-1094730640),o=i(o,u,a,f,t[13],4,681279174),f=i(f,o,u,a,t[0],11,-358537222),a=i(a,f,o,u,t[3],16,-722521979),u=i(u,a,f,o,t[6],23,76029189),o=i(o,u,a,f,t[9],4,-640364487),f=i(f,o,u,a,t[12],11,-421815835),a=i(a,f,o,u,t[15],16,530742520),u=i(u,a,f,o,t[2],23,-995338651),o=s(o,u,a,f,t[0],6,-198630844),f=s(f,o,u,a,t[7],10,1126891415),a=s(a,f,o,u,t[14],15,-1416354905),u=s(u,a,f,o,t[5],21,-57434055),o=s(o,u,a,f,t[12],6,1700485571),f=s(f,o,u,a,t[3],10,-1894986606),a=s(a,f,o,u,t[10],15,-1051523),u=s(u,a,f,o,t[1],21,-2054922799),o=s(o,u,a,f,t[8],6,1873313359),f=s(f,o,u,a,t[15],10,-30611744),a=s(a,f,o,u,t[6],15,-1560198380),u=s(u,a,f,o,t[13],21,1309151649),o=s(o,u,a,f,t[4],6,-145523070),f=s(f,o,u,a,t[11],10,-1120210379),a=s(a,f,o,u,t[2],15,718787259),u=s(u,a,f,o,t[9],21,-343485551),e[0]=c(o,e[0]),e[1]=c(u,e[1]),e[2]=c(a,e[2]),e[3]=c(f,e[3])}function t(e,t,n,r,i,s){return t=c(c(t,e),c(r,s)),c(t<<i|t>>>32-i,n)}function n(e,n,r,i,s,o,u){return t(n&r|~n&i,e,n,s,o,u)}function r(e,n,r,i,s,o,u){return t(n&i|r&~i,e,n,s,o,u)}function i(e,n,r,i,s,o,u){return t(n^r^i,e,n,s,o,u)}function s(e,n,r,i,s,o,u){return t(r^(n|~i),e,n,s,o,u)}function o(t){/[\x80-\xFF]/.test(t)&&(t=unescape(encodeURI(t))),txt="";var n=t.length,r=[1732584193,-271733879,-1732584194,271733878],i;for(i=64;i<=t.length;i+=64)e(r,u(t.substring(i-64,i)));t=t.substring(i-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i<t.length;i++)s[i>>2]|=t.charCodeAt(i)<<(i%4<<3);s[i>>2]|=128<<(i%4<<3);if(i>55){e(r,s);for(i=0;i<16;i++)s[i]=0}return s[14]=n*8,e(r,s),r}function u(e){var t=[],n;for(n=0;n<64;n+=4)t[n>>2]=e.charCodeAt(n)+(e.charCodeAt(n+1)<<8)+(e.charCodeAt(n+2)<<16)+(e.charCodeAt(n+3)<<24);return t}function f(e){var t="",n=0;for(;n<4;n++)t+=a[e>>n*8+4&15]+a[e>>n*8&15];return t}function l(e){for(var t=0;t<e.length;t++)e[t]=f(e[t]);return e.join("")}function c(e,t){return e+t&4294967295}var a="0123456789abcdef".split("");md5=function(e){return l(o(e))};if(md5("hello")!="5d41402abc4b2a76b9719d911017c592")function c(e,t){var n=(e&65535)+(t&65535),r=(e>>16)+(t>>16)+(n>>16);return r<<16|n&65535}}(),md5}),define("PubSub",["Log","MD5"],function(e,t){function n(){this._handlersList={},this._eventsList={}}return n.prototype={publish:function(e){var t=arguments;e in this._eventsList&&this._eventsList[e].forEach(function(n){if(typeof n=="function")try{n.apply(this,Array.prototype.slice.call(t,1))}catch(r){throw new Error('An error occurred when firing event "'+e+'": '+r)}})},subscribe:function(n,r){if(typeof r!="function")return e("[PubSub] Handler is a function"),null;n in this._eventsList||(this._eventsList[n]=[]);var i=t(n)+t(r.toString()+new Date);return this._handlersList[i]=this._eventsList[n][this._eventsList[n].push(r)-1],{event:n,key:i}},unsubscribe:function(e){if(typeof e=="string"&&e in this._eventsList){var n=t(e);for(var r in this._handlersList)r.indexOf(n)==0&&delete this._handlersList[r];delete this._eventsList[e]}typeof e=="object"&&e.hasOwnProperty("key")&&e.hasOwnProperty("event")&&e.event in this._eventsList&&(this._eventsList[e.event].forEach(function(t,n){t==this._handlersList[e.key]&&this._eventsList[e.event].splice(n,1)}.bind(this)),delete this._handlersList[e.key],this._eventsList[e.event].length||delete this._eventsList[e.event])}},new n}),define("Fingerprint",["MD5"],function(e){function t(e,t){var n=[];return e instanceof Array?e.forEach(function(e){n.push(t(e))}):e instanceof Object&&Object.keys(e).forEach(function(r){n.push(t(e[r]))}),n}function n(){return[navigator.userAgent,[screen.height,screen.width,screen.colorDepth].join("x"),(new Date).getTimezoneOffset(),!!window.sessionStorage,!!window.localStorage,t(navigator.plugins,function(e){return[e.name,e.description,t(e,function(e){return[e.type,e.suffixes].join("~")}).join(",")].join("::")}).join(";")].join("###")}return e(n())}),define("Signaling",["Log","Utils","Config","Websocket","PubSub","Fingerprint"],function(e,t,n,r,i,s){function o(){this._appId=undefined,this._appKey=undefined,this._id=undefined,this._useSip=undefined,this._socket=undefined}return o.prototype={init:function(e,t,n){this._appId=e,this._appKey=t,this._useSip=n},clearSocket:function(){this._socket=undefined},connect:function(o,u){if(!this._socket){if(!this._appId||!this._appKey)throw new Error("appId and appKey properties are not defined; init() method must be called prior to connect() method");this._id=o,this._socket=new r(n.API_SERVER),this._socket.on("socket-ready",function(e){this._send("connect",{id:this._id,name:u,appId:this._appId,appKey:this._appKey,useSip:this._useSip,fingerprint:s}),n.set(e);if(n.VERSION!=e.clientVersion){if(t.isLocalCopy())throw new Error("a newer version of bistri.conference.min.js ("+e.clientVersion+") is available, please update it !");i.publish("onClientUpdateRequired",e.clientVersion)}}.bind(this)),this._setSocketEvents()}else e("[Signaling] Can't connect. A connection has already been instantiated")},disconnect:function(){if(!this._isSocketSet())return;this._socket.disconnect()},getPresence:function(e){if(!this._isSocketSet())return;this._send("get-presence",e)},setPresence:function(e){if(!this._isSocketSet())return;this._send("set-presence",e)},joinRoom:function(e,t){if(!this._isSocketSet())return;this._send("join-room",{room:e,capacity:t})},quitRoom:function(e){if(!this._isSocketSet())return;this._send("quit-room",{room:e})},sendSignal:function(e,t,n){if(!this._isSocketSet())return;this._send("send-signal",{pid:e,room:t,data:n})},sendSipSignal:function(e,t,n){if(!this._isSocketSet())return;this._send("send-sip-signal",{pid:e,room:t,data:n})},sendSipDtmf:function(e,t){if(!this._isSocketSet())return;this._send("send-sip-dtmf",{room:e,tones:t})},setInternalId:function(e){this._id=e},log:function(e,t){if(!this._isSocketSet())return;this._send("log",{action:e,load:t})},bind:function(e,t){if(this._events.indexOf(e)!=-1){if(typeof t!="function")throw new Error("handler is not a function [addHandler]");return i.subscribe(e,t.bind(this))}throw new Error("Unknown event: "+e+" [addHandler]")},unbind:function(){i.unsubscribe(arguments[0])},addHandler:function(e,t){this.bind.apply(this,arguments)},removeHandler:function(){this.unbind.apply(this,arguments)},_send:function(t,n){e("[Signaling] Emit: ",t,n),this._socket.emit(t,n)},_eventsMap:{error:"onError",connected:"onConnected","connection-error":"onConnectionError",disconnect:"onDisconnected","joined-room":"onJoinedRoom","join-room-error":"onJoinRoomError","quitted-room":"onQuittedRoom","quit-room-error":"onQuitRoomError","receive-signal":"onSignalReceived","peer-joined-room":"onPeerJoinedRoom","peer-quitted-room":"onPeerQuittedRoom","incoming-request":"onIncomingRequest",presence:"onPresence","sip-progress":"onSipCallProgress","sip-dtmf":"onSipCallDtmf"},_events:["onError","onConnected","onConnectionError","onDisconnected","onRoomUpdate","onJoinedRoom","onJoinRoomError","onQuittedRoom","onQuitRoomError","onPeerJoinedRoom","onPeerQuittedRoom","onSignalReceived","onSessionExpired","onSessionError","onConnectionFailed","onVideoReady","onIncomingRequest","onClientUpdateRequired","onExtensionInstalled","onExtensionInstallStarted","onExtensionInstallFailed","onPresence","onSipCallProgress","onSipCallDtmf"],_isSocketSet:function(){return this._socket?!0:!1},_setSocketEvents:function(){for(var t in this._eventsMap)this._socket.on(t,function(t,n){return function(r){e("[Signaling] Receive: ",n,r),t._fireHandler(n,r)}}(this,this._eventsMap[t]))},_fireHandler:function(e,t){i.publish("_"+e,t),i.publish(e,t)}},o}),define("SignalingChannel",[],function(){function e(e,t){this.pid=e,this.room=t}return e.prototype={send:function(){},onReceive:function(){},onFailed:function(){}},e}),define("SipSignalingChannel",[],function(){function e(e,t){this.pid=e,this.room=t}return e.prototype={send:function(){},onReceive:function(){},onFailed:function(){}},e}),define("Streams",["Log","PubSub"],function(e,t){function n(){}return n.prototype={bind:function(n,r){return this._events.indexOf(n)!=-1?typeof r!="function"?(e("[Streams] handler is not a function"),null):t.subscribe(n,r.bind(this)):(e("[Streams] Unknown event: "+n),null)},unbind:function(){t.unsubscribe(arguments[0])},addHandler:function(e,t){this.bind.apply(this,arguments)},removeHandler:function(){this.unbind.apply(this,arguments)},_events:["onStreamMuteChange","onStreamError","onStreamAdded","onStreamRemoved","onStreamClosed","onStreamStatsUpdated"]},new n}),define("DataChannels",["Log","PubSub"],function(e,t){function n(){}return n.prototype={bind:function(n,r){return this._events.indexOf(n)!=-1?typeof r!="function"?(e("[DataChannels] Handler is not a function"),null):t.subscribe(n,r.bind(this)):(e("[DataChannels] Unknown event: "+n),null)},unbind:function(e){t.unsubscribe(arguments[0])},addHandler:function(e,t){this.bind.apply(this,arguments)},removeHandler:function(){this.unbind.apply(this,arguments)},_events:["onDataChannelCreated","onDataChannelRequested"]},new n}),define("FileTransfer",["Log","PubSub"],function(e,t){function n(){}return n.prototype={bind:function(n,r){return this._events.indexOf(n)!=-1?typeof r!="function"?(e("[FileTransfer] Handler is not a function"),null):t.subscribe(n,r.bind(this)):(e("[FileTransfer] Unknown event: "+n),null)},unbind:function(e){t.unsubscribe(arguments[0])},addHandler:function(e,t){this.bind.apply(this,arguments)},removeHandler:function(){this.unbind.apply(this,arguments)},_events:["onFileSent","onFileReceived","onFileTransferProgress","onFileTransferBitrate","onFileTransferCanceled","onFileTransferWaiting","onFileTransferCompleted","onFileTransferAborted","onNewFileTransfer"]},new n}),define("GetScreenSharing",["Log","Ajax","Config","PubSub","WebRTCTools"],function(e,t,n,r,i){function a(t,a,f){var l=i.getBrowser(),c=window.location.protocol;if(c!="https:")throw new Error("The screen-sharing feature is not allowed on non-secured connection. SSL is required by the browser.");if(i.isChrome()){if(!n.CHROME_EXT_ID){e("[GetScreenSharing] No Chrome ScreenSharing Extension ID configured !");return}if(l.version>=34){var h=!!document.querySelector("#bistri-screen-sharing-installed")||!!document.querySelector("#extension-is-installed-"+n.CHROME_EXT_ID);if(h){e("[GetScreenSharing] ScreenSharing Extension is installed");var p=Math.random().toString().substr(2);s[p]={constraints:t,onSuccess:a,onError:f},window.postMessage({requestId:p,action:"screen-sharing",data:["screen","window"]},"*")}else e("[GetScreenSharing] ScreenSharing Extension is required"),o||(o=!0,chrome.webstore.onInstallStageChanged.addListener(function(t){t=="downloading"&&!u&&(e("[GetScreenSharing] ScreenSharing Extension installation has started"),u=!0,r.publish("onExtensionInstallStarted"))}),chrome.webstore.install("https://chrome.google.com/webstore/detail/"+n.CHROME_EXT_ID,function(){setTimeout(function(){e("[GetScreenSharing] ScreenSharing Extension has been installed"),r.publish("onExtensionInstalled"),n.EXT_AUTO_RELOAD&&window.location.reload()},2e3)},function(){e("[GetScreenSharing] ScreenSharing Extension installation has failed"),r.publish("onExtensionInstallFailed"),typeof f=="function"&&f()}))}}else if(i.isFirefox()){if(!n.FIREFOX_EXT_ID){e("[GetScreenSharing] No Firefox ScreenSharing Extension ID configured !");return}if(l.version>=33){var h=!!document.querySelector("#bistri-screen-sharing-installed")||!!document.querySelector("#extension-is-installed");h?navigator.getUserMedia(t,a,f):InstallTrigger.install({bistriScreenSharing:{URL:"https://addons.mozilla.org/firefox/downloads/latest/"+n.FIREFOX_EXT_ID+"/addon-"+n.FIREFOX_EXT_ID+"-latest.xpi",toString:function(){return this.URL}}})}}else f("The screen sharing feature is not supported by your browser")}var s={},o=!1,u=!1;return i.isChrome()&&window.addEventListener("message",function(t){if(t.origin!=window.location.origin)return;var n=t.data;if(!n.answer)return;var r=s[n.requestId];if(r)switch(n.state){case"completed":n.streamId?(r.constraints.video.mandatory.chromeMediaSourceId=n.streamId,navigator.getUserMedia(r.constraints,r.onSuccess,r.onError)):r.onError({code:1,text:"action canceled by the user"}),delete s[n.requestId]}else e("[GetScreenSharing] Cached data related to request id '"+n.requestId+"' not found")}),a}),define("AudioActivityMonitor",["Log"],function(e){function n(){this.processors={},this.range_start=20,this.range_end=80}window.AudioContext=window.AudioContext||window.webkitAudioContext;if(AudioContext)var t=new AudioContext;return n.prototype={add:function(n,r){if(!AudioContext||n.isTemMediaStream)return;if(n.getAudioTracks&&!n.getAudioTracks().length){e("[AudioActivityMonitor] Current stream has no audio track to monitor");return}var i=t.createAnalyser(),s=t.createMediaStreamSource(n),o=this.processors[n.id]=t.createScriptProcessor(2048,1,1),u=new Uint8Array(i.frequencyBinCount);i.smoothingTimeConstant=.4,i.fftSize=1024,s.connect(i),i.connect(o),o.connect(t.destination),o.onaudioprocess=function(){i.getByteFrequencyData(u);var e=0;for(var t=this.range_start;t<this.range_end;t++)e+=u[t];var n=e/(this.range_end-this.range_start),s=Math.log(n/100+1)*100;s=s>100?100:Math.round(s),typeof r=="function"&&r(s)}.bind(this)},remove:function(e){e.id in this.processors&&(this.processors[e.id].onaudioprocess=null,delete this.processors[e.id])}},new n}),define("UserMedia",["Log","PubSub","Config","WebRTCTools","GetScreenSharing","AudioActivityMonitor"],function(e,t,n,r,i,s){function o(){this._streams=[]}return o.prototype={start:function(e,r){var s;if(!n.USER_ID)throw new Error("connect() method must be called prior to get the local stream");onSuccess=function(e,r){return function(e){e.id||(e.id=this._getRandomId()),e.onended=function(){t.publish("onStreamClosed",e,n.USER_ID)},e.localStream=!0,e.type=s;if(s=="audio"){var i=e.getVideoTracks();for(var o=0;o<i.length;o++)i[o].enabled=!1}this._streams.push(e),typeof r=="function"?r(e,n.USER_ID):t.publish("onStreamAdded",e,null)}.bind(e)}(this,r),onError=function(e){t.publish("onStreamError",e)},typeof e=="object"?(e.video?s="video":e.audio&&(s="audio"),navigator.getUserMedia(e,onSuccess,onError)):typeof e=="string"&&(s=e,e=="screen"||e=="screen-sharing"?i(this._getConstraints(e),onSuccess,onError):navigator.getUserMedia(this._getConstraints(e),onSuccess,onError))},stop:function(e,t){if(e){typeof t=="function"&&(e.onended=function(){t(e,n.USER_ID)}),s.remove(e),e.stop(),typeof LocalMediaStream=="function"&&e instanceof LocalMediaStream&&e.onended();for(var r=0;r<this._streams.length;r++)e==this._streams[r]&&this._streams.splice(r,1)}},getDefaultStream:function(){return this._streams.length?this._streams[0]:undefined},getStreams:function(){return this._streams},_getConstraints:function(t){var n,i={audio:!0,video:{mandatory:{},optional:[]}};if(t=="pure-audio")i.video=!1;else if(t=="screen"||t=="screen-sharing")i.audio=!1,i.video={mandatory:{maxWidth:window.screen.width,maxHeight:window.screen.height,maxFrameRate:3}},r.isFirefox()&&(i.video.mediaSource="screen"),r.isChrome()&&(i.video.mandatory.chromeMediaSource="desktop",i.video.mandatory.chromeMediaSourceId=undefined);else{switch(t){case"audio":n="320x240";break;case"webcamHD":case"webcam-hd":n="1280x720";break;case"webcamSD":case"webcam-sd":n="640x480";break;default:n=t}var s=/([0-9]{2,4})x([0-9]{2,4})(:([0-9]{1,2}))*/,o=n.match(s);o?(i.video.mandatory.minWidth=o[1],i.video.mandatory.maxWidth=o[1],i.video.mandatory.minHeight=o[2],i.video.mandatory.maxHeight=o[2],o[4]&&(i.video.mandatory.minFrameRate=o[4],i.video.mandatory.maxFrameRate=o[4])):e("[UserMedia] unexpected constraints format. Correct scheme is {width}x{height}[:{frame rate}]")}return e("[UserMedia] media constraints: ",i),i},_getRandomId:function(){var e=40,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_",n="";for(var r=0;r<e;r++)n+=t.charAt(Math.random()*63);return n},_bistriExtensionExist:function(){return chrome&&chrome.runtime&&chrome.runtime.sendMessage}},new o}),define("DataChannelWrapper",["Log","PubSub"],function(e,t){function n(n,r,i){var s=n.label;n.onopen=function(){e("[DataChannelWrapper] Datachannel: onopen",arguments),this.onOpen.apply(this,arguments),t.publish("_onDataChannelOpened",r,i,s)}.bind(this),n.onclose=function(){e("[DataChannelWrapper] Datachannel: onclose",arguments),t.publish("_onDataChannelClosed",r,i,s),this.onClose.apply(this,arguments)}.bind(this),n.onmessage=function(){e("[DataChannelWrapper] Datachannel: onmessage",arguments),this.onMessage.apply(this,arguments)}.bind(this),n.onerror=function(){e("[DataChannelWrapper] Datachannel: onerror",arguments),t.publish("_onDataChannelError",r,i,s),this.onError.apply(this,arguments)}.bind(this),this.label=n.label,this.onOpen=function(){},this.onClose=function(){},this.onMessage=function(){},this.onError=function(){},this._channel=n}return n.prototype={send:function(){this._channel.send.apply(this._channel,arguments)},close:function(){this._channel.close.apply(this._channel,arguments)}},n}),define("Binarize",[],function(){return function(e){var t=!1,n=!1,r=!0,i=Uint8Array.BYTES_PER_ELEMENT,s=Uint16Array.BYTES_PER_ELEMENT,o=Uint32Array.BYTES_PER_ELEMENT,u={NULL:0,UNDEFINED:1,STRING:2,NUMBER:3,BOOLEAN:4,ARRAY:5,OBJECT:6,INT8ARRAY:7,INT16ARRAY:8,INT32ARRAY:9,UINT8ARRAY:10,UINT16ARRAY:11,UINT32ARRAY:12,FLOAT32ARRAY:13,FLOAT64ARRAY:14,ARRAYBUFFER:15,BLOB:16,FILE:16,BUFFER:17};if(t)var a=["NULL","UNDEFINED","STRING","NUMBER","BOOLEAN","ARRAY","OBJECT","INT8ARRAY","INT16ARRAY","INT32ARRAY","UINT8ARRAY","UINT16ARRAY","UINT32ARRAY","FLOAT32ARRAY","FLOAT64ARRAY","ARRAYBUFFER","BLOB","BUFFER"];var f=[null,null,"Uint16","Float64","Uint8",null,null,"Int8","Int16","Int32","Uint8","Uint16","Uint32","Float32","Float64","Uint8","Uint8","Uint8"],l=function(e,t,r){var i=[],s=n,o=40;i[0]=[];for(var u=0;u<o;u++)i[0][u]=u<10?"0"+u.toString(10):u.toString(10);for(u=0;u<r;u++){var a=e.getUint8(t+u,s),f=~~(u/o)+1;typeof i[f]=="undefined"&&(i[f]=[]),i[f][u%o]=a<16?"0"+a.toString(16):a.toString(16)}console.log("%c"+i[0].join(" "),"font-weight: bold;");for(u=1;u<i.length;u++)console.log(i[u].join(" "))},c=function(e){var t=undefined;if(e===undefined)t=u.UNDEFINED;else if(e===null)t=u.NULL;else{var n=e.constructor.name;if(n!==undefined)t=u[n.toUpperCase()];else switch(typeof e){case"string":t=u.STRING;break;case"number":t=u.NUMBER;break;case"boolean":t=u.BOOLEAN;break;case"object":e instanceof Array?t=u.ARRAY:e instanceof Int8Array?t=u.INT8ARRAY:e instanceof Int16Array?t=u.INT16ARRAY:e instanceof Int32Array?t=u.INT32ARRAY:e instanceof Uint8Array?t=u.UINT8ARRAY:e instanceof Uint16Array?t=u.UINT16ARRAY:e instanceof Uint32Array?t=u.UINT32ARRAY:e instanceof Float32Array?t=u.FLOAT32ARRAY:e instanceof Float64Array?t=u.FLOAT64ARRAY:e instanceof ArrayBuffer?t=u.ARRAYBUFFER:e instanceof Blob?t=u.BLOB:e instanceof Buffer?t=u.BUFFER:e instanceof Object&&(t=u.OBJECT);break;default:}}return t},h=function(e){return unescape(encodeURIComponent(e))},p=function(e){return decodeURIComponent(escape(e))},d=function(r){var c=0,h=0,p=0,d=n,v=new ArrayBuffer(r[0].byte_length+r[0].header_size),m=new DataView(v);for(h=0;h<r.length;h++){var g=c,y=r[h].header_size,b=r[h].type,w=r[h].length,E=r[h].value,S=r[h].byte_length,x=f[b],T=x===null?0:e[x+"Array"].BYTES_PER_ELEMENT;b===u.BUFFER?m.setUint8(c,u.BLOB,d):m.setUint8(c,b,d),c+=i,t&&console.info("Packing",b,a[b]);if(b===u.ARRAY||b===u.OBJECT)m.setUint16(c,w,d),c+=s,t&&console.info("Content Length",w);m.setUint32(c,S,d),c+=o,t&&(console.info("Header Size",y,"bytes"),console.info("Byte Length",S,"bytes"));switch(b){case u.NULL:case u.UNDEFINED:break;case u.STRING:t&&console.info('Actual Content %c"'+E+'"',"font-weight:bold;");for(p=0;p<w;p++,c+=T)m.setUint16(c,E.charCodeAt(p),d);break;case u.NUMBER:case u.BOOLEAN:t&&console.info("%c"+E.toString(),"font-weight:bold;"),m["set"+x](c,E,d),c+=T;break;case u.INT8ARRAY:case u.INT16ARRAY:case u.INT32ARRAY:case u.UINT8ARRAY:case u.UINT16ARRAY:case u.UINT32ARRAY:case u.FLOAT32ARRAY:case u.FLOAT64ARRAY:var N=new Uint8Array(m.buffer,c,S);N.set(new Uint8Array(E.buffer)),c+=S;break;case u.ARRAYBUFFER:case u.BUFFER:var N=new Uint8Array(m.buffer,c,S);N.set(new Uint8Array(E)),c+=S;break;case u.BLOB:case u.ARRAY:case u.OBJECT:break;default:throw"TypeError: Unexpected type found."}t&&l(m,g,c-g)}return m},v=function(r,c){var h=0,p=n,d=c,m,g,y,b,w;m=r.getUint8(c,p),c+=i,t&&console.info("Unpacking",m,a[m]);if(m===u.ARRAY||m===u.OBJECT)g=r.getUint16(c,p),c+=s,t&&console.info("Content Length",g);y=r.getUint32(c,p),c+=o,t&&console.info("Byte Length",y,"bytes");var E=f[m],S=E===null?0:e[E+"Array"].BYTES_PER_ELEMENT;switch(m){case u.NULL:case u.UNDEFINED:t&&l(r,d,c-d),b=null;break;case u.STRING:g=y/S;var x=[];for(h=0;h<g;h++){var T=r.getUint16(c,p);c+=S,x.push(String.fromCharCode(T))}b=x.join(""),t&&(console.info('Actual Content %c"'+b+'"',"font-weight:bold;"),l(r,d,c-d));break;case u.NUMBER:b=r.getFloat64(c,p),c+=S,t&&(console.info('Actual Content %c"'+b.toString()+'"',"font-weight:bold;"),l(r,d,c-d));break;case u.BOOLEAN:b=r.getUint8(c,p)===1?!0:!1,c+=S,t&&(console.info('Actual Content %c"'+b.toString()+'"',"font-weight:bold;"),l(r,d,c-d));break;case u.INT8ARRAY:case u.INT16ARRAY:case u.INT32ARRAY:case u.UINT8ARRAY:case u.UINT16ARRAY:case u.UINT32ARRAY:case u.FLOAT32ARRAY:case u.FLOAT64ARRAY:case u.ARRAYBUFFER:w=r.buffer.slice(c,c+y),c+=y,m===u.ARRAYBUFFER?b=w:b=new e[E+"Array"](w),t&&l(r,d,c-d);break;case u.BLOB:t&&l(r,d,c-d);if(e.Blob){var N=v(r,c),C=v(r,N.cursor);c=C.cursor,b=new Blob([C.value],{type:N.value})}else w=r.buffer.slice(c,c+y),c+=y,b=new Buffer(w);break;case u.ARRAY:t&&l(r,d,c-d),b=[];for(h=0;h<g;h++)w=v(r,c),c=w.cursor,b.push(w.value);break;case u.OBJECT:t&&l(r,d,c-d),b={};for(h=0;h<g;h++){var k=v(r,c),L=v(r,k.cursor);c=L.cursor,b[k.value]=L.value}break;default:throw"TypeError: Type not supported."}return{value:b,cursor:c}},m=function(e,t){var n=e.length,r=[],i=0,s=0;for(var o=0;o<e.length;o++)(function(o){g(e[o],function(e){r[o]=e,s+=e[0].header_size+e[0].byte_length;if(++i===n){var u=[];for(var a=0;a<r.length;a++)u=u.concat(r[a]);t(u,s)}})})(o)},g=function(t,n){var r=[],a=1,l=i+o,h,p=0,d=0,v=t;h=c(t),a=f[h]===undefined||f[h]===null?0:e[f[h]+"Array"].BYTES_PER_ELEMENT;switch(h){case u.UNDEFINED:case u.NULL:break;case u.NUMBER:case u.BOOLEAN:p=a;break;case u.STRING:d=t.length,p+=d*a;break;case u.INT8ARRAY:case u.INT16ARRAY:case u.INT32ARRAY:case u.UINT8ARRAY:case u.UINT16ARRAY:case u.UINT32ARRAY:case u.FLOAT32ARRAY:case u.FLOAT64ARRAY:d=t.length,p+=d*a;break;case u.ARRAY:m(t,function(e,r){n([{type:h,length:t.length,header_size:l+s,byte_length:r,value:null}].concat(e))});return;case u.OBJECT:var g=[];for(var y in t)t.hasOwnProperty(y)&&(g.push(y),g.push(t[y]),d++);m(g,function(e,t){n([{type:h,length:d,header_size:l+s,byte_length:t,value:null}].concat(e))});return;case u.ARRAYBUFFER:p+=t.byteLength;break;case u.BLOB:var b=t.type,w=new FileReader;w.onload=function(e){m([b,e.target.result],function(e,t){n([{type:h,length:d,header_size:l,byte_length:t,value:null}].concat(e))})},w.onerror=function(e){throw"FileReader Error: "+e},w.readAsArrayBuffer(t);return;case u.BUFFER:p+=t.length;break;default:throw'TypeError: Type "'+t.constructor.name+'" not supported.'}n([{type:h,length:d,header_size:l,byte_length:p,value:v}].concat(r))},y=function(e,t){var n=new DataView(e),r=v(n,0);return r.value};t&&(e.Test={BIG_ENDIAN:n,LITTLE_ENDIAN:r,Types:u,pack:d,unpack:v,serialize:g,deserialize:y});var b={pack:function(e,n){try{t&&console.info("%cPacking Start","font-weight: bold; color: red;",e),g(e,function(e){t&&console.info("Serialized Object",e),n(d(e))})}catch(r){throw r}},unpack:function(e,n){try{t&&console.info("%cUnpacking Start","font-weight: bold; color: red;",e);var r=y(e);t&&console.info("Deserialized Object",r),n(r)}catch(i){throw i}}};typeof module!="undefined"&&module.exports?module.exports=b:e.binarize=b}(typeof global!="undefined"?global:this),binarize}),define("PacketsMaker",["Log","PubSub"],function(e,t){function r(e){return e*1e3*1e3}function i(e){this.events=[],this.index=0,this.offset=0,this.file=e,this.state=!0,this.buffer=[],this.chunkSize=n,this.bufferHigh=r(50),this.bufferLow=r(5),this.bufferSize=0,this.slicesNb=Math.ceil(e.size/this.chunkSize),this.flag=!0,this.done=!1,this.stopped=!1,this._slice()}var n=15e3;return i.prototype={_slice:function(){var t=this.slicesNb,n=function(){var r,i=new window.FileReader;i.onloadend=function(r){r.target.readyState==2&&(this.buffer["slice_"+this.index]={id:this.index,chunk:r.target.result},this.bufferSize+=r.target.result.byteLength,this.offset+r.target.result.byteLength<this.file.size?(this.index+=1,this.offset+=this.chunkSize,this.bufferSize<this.bufferHigh?n():(this.stopped=!0,e("[PacketsMaker] Buffer high level warning"))):(this.done=!0,e("[PacketsMaker] Slice operation finished")),this.flag&&(this.bufferSize>=this.bufferHigh||this.done)&&(this.flag=!1,this.events.buffered({fileName:this.file.name,fileSize:this.file.size,fileType:this.file.type,chunksNb:t})))}.bind(this),r=this.file.slice(this.offset,this.offset+this.chunkSize),i.readAsArrayBuffer(r)}.bind(this);this.stopped=!1,n()},on:function(e,t){this.events[e]=t},removePacket:function(t){if(!this.buffer["slice_"+t]){e("[PacketsMaker] Packet not found: ",t);return}this.bufferSize-=this.buffer["slice_"+t].chunk.byteLength,delete this.buffer["slice_"+t],this.bufferSize<this.bufferLow&&!this.done&&this.stopped&&(e("[PacketsMaker] Buffer low level warning"),this._slice())},getPacket:function(e){return this.buffer["slice_"+e]},getPacketsNb:function(){return this.slicesNb}},i}),define("CreateFile",["Log"],function(e){function r(t,n,r){var i=this,o=[],u=0,a=!1,f=window.requestFileSystem||window.webkitRequestFileSystem,l=null;i.onFileReady=function(){},i.onFileComplete=function(){},i.init=function(){f?(l=new s(n,r),l.onBlockComplete=function(e){o.push(e)},f(window.TEMPORARY,n,function(r){r.root.getFile(t,{create:!0},function(t){t.createWriter(function(r){var s=function(){if(o.length){var e=o.splice(0,1)[0];r.seek(e.byteOffset),r.write(e.blob)}else setTimeout(s,1e3)};r.onwriteend=function(e){r.length<n?setTimeout(s,0):i.onFileComplete(t.toURL())},r.onerror=function(t){e("[CreateFile] Write block failure: ",t)},r.length>0?r.truncate(0):s(),a=!0,i.onFileReady()},function(t){e("[fileEntry] Error: "+t.message)})},function(t){e("[fs.root] Error: "+t.message)})},function(t){a=!1,i.onFileReady(),e("[requestFileSystem] Error: "+t.message)})):i.onFileReady()},i.append=function(e){if(a)l.addPacket(e);else{o[e.id]=e.chunk,u+=e.chunk.byteLength||e.chunk.size;if(u==n){var t=new window.Blob(o,{type:r});i.onFileComplete(URL.createObjectURL(t))}}}}function i(e,r,i){this.type=i,this.totalByte=r,this.byteLength=0,this.byteOffset=e*n*t,this.packets=[]}function s(e,r){var s=n*t,o=Math.ceil(e/(n*t)),u={},a=this;for(var f=0;f<o;f++){var l=e-s*f;u[f]=new i(f,Math.min(s,l),r)}a.addPacket=function(e){var n=Math.floor(e.id/t),r=u[n];r&&(r.add(e),r.isComplete()&&(a.onBlockComplete(r.getBlob()),delete u[n]))},a.onBlockComplete=function(){}}var t=1e3,n=15e3;return i.prototype={add:function(e){this.packets[e.id]||(this.packets[e.id]=e,this.byteLength+=e.chunk.byteLength||e.chunk.size)},getBlob:function(){var e=[];return this.packets.forEach(function(t){e.push(t.chunk)}),{byteOffset:this.byteOffset,blob:new window.Blob(e,{type:this.type})}},isComplete:function(){return this.totalByte==this.byteLength}},r}),define("PacketsRequester",["Log","PubSub","CreateFile"],function(e,t,n){function r(){this._sysFile=null,this._index=0,this._timeout=5e3,this._requests={},this._maxRequest=5,this._maxThread=6,this._events=[],this._received=0,this._ttl_chunks=0}return r.prototype={init:function(t){this._ttl_chunks=t.chunksNb,this._sysFile=new n(t.fileName,t.fileSize,t.fileType),this._sysFile.onFileReady=function(){for(var e=0;e<this._maxThread;e++)this._requestNext()}.bind(this),this._sysFile.onFileComplete=function(t){this._events.completed(t),this._events.end(),e("[PacketsRequester] File transfer completed: ",t)}.bind(this),this._sysFile.init()},on:function(e,t){this._events[e]=t},addPacket:function(t){var n=this._requests[t.id];n?(clearTimeout(n.timer),this._received+=t.chunk.byteLength||t.chunk.size,this._events.progress(),this._events.acknowledge(t.id),this._sysFile.append(t),delete this._requests[t.id],this._received!=this._size&&this._index<this._ttl_chunks&&this._requestNext()):e("[PacketsRequester] Unknown request id: ",t.id)},_requestNext:function(){var e=this._index;if(e>=this._ttl_chunks)return;this._index++,this._events.next(e),this._requests[e]={timer:setTimeout(this._askAgain.bind(this),this._timeout,e),attempt:0}},_askAgain:function(t){var n=this._requests[t];n.attempt<=this._maxRequest?(e("[PacketsRequester] Ask packet again: ",t),this._events.resend(t),n.timer=setTimeout(this._askAgain.bind(this),this._timeout,t),n.attempt++):this._events.failed("[PacketsRequester] Transfer interrupted: too many retries")}},r}),define("TransferManager",["Log","PubSub","Binarize","PacketsMaker","PacketsRequester"],function(e,t,n,r,i){function h(e,t,n){this._id=e,this._pid=t,this._file=n,this._data={},this._events=[],this._ttl_chunks=0,this._ack_chunks=0,this._transfered=!1,this._transmitted=0,this._ptransmitted=0,this._timestamp=0,this._ptimestamp=0}function p(e,t){n.pack(e,function(e){t(e.buffer)})}function d(e,t){if(e instanceof Blob){var r=new window.FileReader;r.onloadend=function(e){n.unpack(e.target.result,t)},r.readAsArrayBuffer(e)}else n.unpack(e,t)}function v(e){var t=0,n=e,r={1:"KB",2:"MB",3:"GB"};while(n/1e3>1)t++,n/=1e3;return m(n,2)+" "+r[t]}function m(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}var s=1,o=2,u=3,a=4,f=5,l=6,c=7;return h.prototype={on:function(e,t){this._events[e]=t},onReceive:function(e){d(e.data,function(e){switch(e.type){case c:this._progress(),this._acknowledge(e.data);break;case s:this._getBitrate(),this._newTransfer(e.data);break;case o:this._addPacket(e.data);break;case u:case a:this._sendPacket(e.data);break;case f:this._fileSent();break;case l:this._failed()}}.bind(this))},onError:function(){t.publish("onFileTransferAborted",this._id)},onClose:function(){this._transfered||t.publish("onFileTransferAborted",this._id)},sendFile:function(){t.publish("onFileTransferWaiting",this._pid,{id:this._id,name:this._file.name,size:v(this._file.size)});var n=new r(this._file);this._ttl_chunks=n.getPacketsNb(),n.on("buffered",function(e){this._send(s,e)}.bind(this)),this.on("acknowledgePacket",function(e){n.removePacket(e)}),this.on("sendingPacket",function(t,r){if(t>=this._ttl_chunks){e("[TransferManager] Requested packet is out of range: ",t);return}var i=n.getPacket(t);r&&e("[TransferManager] Try to resend id: ",t),i?(this._send(o,i),this._transmitted+=i.chunk.byteLength||i.chunk.size):(e("[TransferManager] Delay packet: ",t),setTimeout(this._events.sendingPacket.bind(this),200,t,!0))}.bind(this)),this._getBitrate()},_send:function(e,t){p({type:e,data:t},function(e){this.onEmit(e)}.bind(this))},_newTransfer:function(e){this._file={name:e.fileName,size:e.fileSize,type:e.fileType},this._ttl_chunks=e.chunksNb;var n={ok:function(){this._acceptTransfer(e)}.bind(this),cancel:function(){this.onEnd()}.bind(this)};t.publish("onNewFileTransfer",this._pid,{id:this._id,name:this._file.name,size:v(this._file.size)},n)},_acceptTransfer:function(e){var n=new i;n.on("completed",function(e){this._transfered=!0,this._bitrate(0),t.publish("onFileReceived",this._id,{name:this._file.name,size:v(this._file.size),url:e})}.bind(this)),n.on("progress",function(){this._progress()}.bind(this)),n.on("acknowledge",function(e){this._send(c,{id:e})}.bind(this)),n.on("next",function(e){this._send(u,{id:e})}.bind(this)),n.on("resend",function(e){this._send(a,{id:e})}.bind(this)),n.on("end",function(){this._send(f,null)}.bind(this)),n.on("failed",function(){this._failed()}.bind(this)),this.on("incomingPacket",function(e){n.addPacket(e)}),n.init(e)},_addPacket:function(e){this._transmitted+=e.chunk.byteLength||e.chunk.size,this._events.incomingPacket(e)},_acknowledge:function(e){this._events.acknowledgePacket(e.id)},_progress:function(){var e=++this._ack_chunks*100/this._ttl_chunks;t.publish("onFileTransferProgress",this._id,Math.round(e))},_bitrate:function(e){t.publish("onFileTransferBitrate",this._id,e)},_sendPacket:function(e){this._events.sendingPacket(e.id)},_getBitrate:function(){var e=(new Date).getTime(),t=this._transmitted,n=Math.round((t-this._ptransmitted)/(e-this._ptimestamp));this._bitrate(n),this._transfered||setTimeout(this._getBitrate.bind(this),1e3),this._ptimestamp=e,this._ptransmitted=t},_fileSent:function(){this._transfered=!0,t.publish("onFileSent",this._id),this.onEnd()},_failed:function(){this.onEnd()}},h}),define("FileTransferWrapper",["Log","PubSub","TransferManager"],function(e,t,n){function r(r,i,s,o,u,a,f){var l=new n(u,o,a);l.onEmit=function(e){r.send(e)},l.onEnd=function(e){r.close()},r.onmessage=function(e){l.onReceive(e)},r.onopen=function(){e("[SendFileWrapper] File Transfer: on open",arguments),f&&l.sendFile(),t.publish("_onFileTransferOpened",i,o,s)},r.onclose=function(){e("[SendFileWrapper] File Transfer: on close",arguments),l.onClose(),t.publish("_onFileTransferClosed",i,o,s)},r.onerror=function(){e("[SendFileWrapper] File Transfer: on error",arguments),l.onError(),t.publish("_onFileTransferError",i,o,s)}}return r}),define("PeerConnection",["Log","WebRTCTools","Config","Deferred"],function(e,t,n,r){function i(t,r,i,s){var o={iceServers:n.TURN_SERVERS};this.compatibilyMode=i,this.signalingChannel=t,this.offerSdpConstraints=undefined,this.isCaller=r,this.defaultStream=null,this.autoAttachStream=!0,this.waitingAnswer=!1,this.deferredOffer=null,this.sendOnly=!1,this.receiveOnly=!1,this.audioBitrate=!1,this.videoBitrate=!1,this.preferedAudioCodec=!1,this.mergeCandidates=!1,this.pc=null,this.onAddStream=function(){e("[PeerConnection] Remote stream added",arguments)},this.onRemoveStream=function(){e("[PeerConnection] Remote stream removed",arguments)},this.onCloseStream=function(){e("[PeerConnection] Remote stream closed",arguments)},this.onOpen=function(){e("[PeerConnection] Session opened",arguments)},this.onConnecting=function(){e("[PeerConnection] Session connecting",arguments)},this.onFailed=function(){e("[PeerConnection] onFailed",arguments)},this.onStateChange=function(){e("[PeerConnection] State changed",arguments)},this.onStatsUpdated=function(){e("[PeerConnection] Stats updated",arguments)},this._setOptions(s),this._init(o)}return i.prototype={_init:function(t){var n=this,r={optional:[]};this.compatibilyMode&&e("[PeerConnection] Interoperability mode enabled: ",this.compatibilyMode);switch(this.compatibilyMode){case"FF>CR":case"CR>FF":case"FF>SF":case"SF>FF":case"FF>IE":case"IE>FF":r={optional:[{DtlsSrtpKeyAgreement:!0}]}}try{this.pc=new RTCPeerConnection(t,r)}catch(i){e("[PeerConnection] RTCPeerConnection error: ",i)}this.pc.onaddstream=function(){e("[PeerConnection] "+this.constructor.name+" Remote stream added",arguments),n._startStatsPolling(),n._callExternal("onAddStream",arguments)},this.pc.onremovestream=function(){e("[PeerConnection] "+this.constructor.name+" Remote stream removed",arguments),n._callExternal("onRemoveStream",arguments)},this.pc.onopen=function(){n._callExternal("onOpen",arguments)},this.pc.onconnecting=function(){n._callExternal("onConnecting",arguments)},this.pc.onsignalingstatechange=function(){n.pc&&n.pc.iceState=="failed"&&n._failed("onsignalingstatechange","readyState=failed"),n._callExternal("onStateChange",arguments)},this.pc.ondatachannel=function(){n._callExternal("onDataChannel",arguments)},this.remoteIceCandidate=[],this.signalingChannel.onReceive=function(){n._processSignalingMsg.apply(n,arguments)},this.mergeCandidates?(this.pc.onicecandidate=function(t){var r=t.candidate;if(typeof r=="undefined"||!r||!!r==0)e("[PeerConnection] Send ",{type:n.pc.localDescription.type,sdp:n.pc.localDescription.sdp}),n.signalingChannel.send({sd:n.pc.localDescription})},this.pc.ongatheringchange=function(t){t.currentTarget&&t.currentTarget.iceGatheringState==="complete"&&(e("[PeerConnection] Send ",{type:n.pc.localDescription.type,sdp:n.pc.localDescription.sdp}),n.signalingChannel.send({sd:n.pc.localDescription}))}):this.pc.onicecandidate=function(t){if(!t||!t.candidate){e("[PeerConnection] End of candidates");return}var r={candidate:{}};for(property in t.candidate)typeof t.candidate[property]!="function"&&typeof t.candidate[property]!="object"&&(r.candidate[property]=t.candidate[property]);e("[PeerConnection] Send candidate:",r),n.signalingChannel.send(r)}},_setOptions:function(t){t&&t.sendonly&&(this.isCaller?this.sendOnly=!0:this.receiveOnly=!0),t&&t.receiveonly&&(this.isCaller?this.receiveOnly=!0:this.sendOnly=!0),this.sendOnly&&e("[PeerConnection] peerConnection is in sendonly mode"),this.receiveOnly&&e("[PeerConnection] peerConnection is in receiveonly mode"),t&&t["merge-candidates"]&&(this.mergeCandidates=t["merge-candidates"]),t&&t["audio-codec"]&&(this.preferedAudioCodec=t["audio-codec"],e("[PeerConnection] audio-codec  is set to "+this.preferedAudioCodec)),t&&t["audio-bitrate"]&&(Number(t["audio-bitrate"])!="NaN"?(this.audioBitrate=t["audio-bitrate"],e("[PeerConnection] audio-bitrate  is set to "+this.audioBitrate+"kbs")):e("[PeerConnection] audio-bitrate must be an integer")),t&&t["video-bitrate"]&&(Number(t["audio-bitrate"])!="NaN"?(this.videoBitrate=t["video-bitrate"],e("[PeerConnection] video-bitrate  is set to "+this.videoBitrate+"kbs")):e("[PeerConnection] video-bitrate must be an integer"))},_failed:function(t,n){e("[PeerConnection] Connection fails",t,n),this._clearConnectTimout(),this.onFailed("peerConn::"+t,n)},_callExternal:function(t,n){try{this[t].apply(this,n)}catch(r){e("[PeerConnection] Error when calling external "+t,r)}},_processSignalingMsg:function(t){var n=this;t.candidate&&this.remoteIceCandidate.push(new RTCIceCandidate(t.candidate)),t.sd&&(e("[PeerConnection] Receive "+t.sd.type,t.sd),this.pc.setRemoteDescription(new RTCSessionDescription(t.sd),function(){t.sd&&t.sd.type=="offer"&&(n.autoAttachStream&&(n.autoAttachStream=!1,n._attachStream(n.defaultStream)),n._createAnswer(n.defaultStream)),t.sd&&t.sd.type=="answer"&&(n.waitingAnswer=!1,n.deferredOffer&&(n.deferredOffer.resolve(),n.deferredOffer=null),n._clearConnectTimout()),e("[PeerConnection] setRemoteDescription OK")},function(){n._failed("_processSignalingMsg, setRemoteDescription",arguments)}),this.hasRemoteDescription=!0),this._processRemoteCandidate()},_processRemoteCandidate:function(){if(this.hasRemoteDescription&&this.hasLocalDescription)while(this.remoteIceCandidate.length){var n=this.remoteIceCandidate.shift();try{var r=t.getBrowser();r.name=="safari"||r.name=="trident"||r.name=="msie"?this.pc.addIceCandidate(n,function(){},function(){}):this.pc.addIceCandidate(n)}catch(i){e("[PeerConnection] addIceCandidate failure",i)}}},_preferAudioCodec:function(t,n){var r=n.split("/");if(r.length!=2)return e("[PeerConnection] Invalid codec setting: "+n),t;var i=r[0],s=r[1],o=t.split("\r\n");for(var u=0;u<o.length;u++)if(o[u].search("m=audio")!==-1){var a=u;break}if(typeof a=="undefined")return t;for(var u=0;u<o.length;u++)if(o[u].search(i+"/"+s)!==-1){var f=new RegExp(":(\\d+) "+i+"\\/"+s,"i"),l=this._extractSdp(o[u],f);l&&(o[a]=this._setDefaultCodec(o[a],l));break}return o=this._removeCN(o,a),t=o.join("\r\n"),t},_extractSdp:function(e,t){var n=e.match(t);return n&&n.length==2?n[1]:null},_setDefaultCodec:function(e,t){var n=e.split(" "),r=new Array,i=0;for(var s=0;s<n.length;s++)i===3&&(r[i++]=t),n[s]!==t&&(r[i++]=n[s]);return r.join(" ")},_removeCN:function(e,t){var n=e[t].split(" ");for(var r=e.length-1;r>=0;r--){var i=this._extractSdp(e[r],/a=rtpmap:(\d+) CN\/\d+/i);if(i){var s=n.indexOf(i);s!==-1&&n.splice(s,1),e.splice(r,1)}}return e[t]=n.join(" "),e},_setLocal:function(t){var n=this;t.sdp=this._setBitrate(t.sdp);if(this.preferedAudioCodec)t.sdp=this._preferAudioCodec(t.sdp,this.preferedAudioCodec);else switch(this.compatibilyMode){case"FF>CR":case"CR>FF":case"FF>SF":case"SF>FF":case"FF>IE":case"IE>FF":t.sdp=this._preferAudioCodec(t.sdp,"opus/48000")}this.pc.setLocalDescription(t,function(t){e("[PeerConnection] setLocalDescription OK")},function(){n._failed("_setLocal, setLocalDescription",arguments)});var r={sd:t};this.mergeCandidates||(e("[PeerConnection] Send "+r.sd.type,r.sd),this.signalingChannel.send(r)),this.hasLocalDescription=!0,this._processRemoteCandidate();var n=this;r.sd&&r.sd.type=="offer"&&(this._connTimeout=setTimeout(function(){n._connectTimout.apply(n)},3e4))},_connectTimout:function(){this._failed("_connectTimout","Connection timeout")},_clearConnectTimout:function(){this._connTimeout&&(clearTimeout(this._connTimeout),this._connTimeout=null)},_attachStream:function(e){e&&!this.receiveOnly&&this.pc.addStream(e)},_detachStream:function(e){e&&this.pc&&this.pc.removeStream&&this.pc.removeStream(e)},_createOffer:function(e){if(this.waitingAnswer){this.deferredOffer=new r,this.deferredOffer.done(function(){this._createOffer(e)}.bind(this));return}this._offerTimer&&clearTimeout(this._offerTimer),e&&(this.offerSdpConstraints=this._getConstraints(e)),this._offerTimer=setTimeout(function(){this.waitingAnswer=!0,this.pc.createOffer(function(){this._setLocal.apply(this,arguments)}.bind(this),function(e){this._failed("createOffer/createAnswer error",e)}.bind(this),this.offerSdpConstraints),this.offerSdpConstraints=undefined}.bind(this),600)},_createAnswer:function(e){this.pc.createAnswer(function(){this._setLocal.apply(this,arguments)}.bind(this),function(e){this._failed("createOffer/createAnswer error",e)}.bind(this),this._getConstraints(e))},_getConstraints:function(e){var t={mandatory:{OfferToReceiveVideo:!0,OfferToReceiveAudio:!0},optional:[]};return e&&(e.type=="screen"||e.type=="screen-sharing")&&e.getVideoTracks&&e.getAudioTracks&&(t.mandatory={OfferToReceiveVideo:!!e.getVideoTracks().length,OfferToReceiveAudio:!!e.getAudioTracks().length}),t},_startStatsPolling:function(){var e=this;this.statsPolling=setInterval(function(){e._getStats()},1e3)},_stopStatsPolling:function(){this.statsPolling&&clearInterval(this.statsPolling)},_getStats:function(){if(!this.pc||!this.pc.getStats)return;var e=this;this.pc.getStats(function(t){var n=t.result(),r={local:{},remote:{}};for(var i=0,s=n.length;i<s;i++)n[i].local&&e._formatStats(r.local,n[i].local),n[i].remote&&e._formatStats(r.remote,n[i].remote);e._callExternal("onStatsUpdated",[r])})},_formatStats:function(e,t){if(typeof t.names=="function"){var n=t.names();for(var r=0,i=n.length;r<i;r++)e[n[r]]=t.stat(n[r])}else t.stat("audioOutputLevel")&&(e.audioOutputLevel=t.stat("audioOutputLevel"))},_setBitrate:function(e){return this.audioBitrate&&(e=e.replace(/a=mid:audio\r\n/g,"a=mid:audio\r\nb=AS:"+this.audioBitrate+"\r\n")),this.videoBitrate&&(e=e.replace(/a=mid:video\r\n/g,"a=mid:video\r\nb=AS:"+this.videoBitrate+"\r\n")),e},close:function(){var e=this.getStreams();for(var t=0;t<e.length;t++)this._callExternal("onCloseStream",[{stream:e[t]}]);this._stopStatsPolling(),this.pc&&(this.pc.close(),delete this.pc)},attachStream:function(e){this._attachStream(e),this._createOffer(e)},detachStream:function(e){this._detachStream(e),this._createOffer(e)},setDefaultStream:function(e){e&&(this.defaultStream=e)},getStreams:function(){return this.pc&&this.pc.getRemoteStreams?this.pc.getRemoteStreams():[]},getLocalStreams:function(){return this.pc&&this.pc.getLocalStreams?this.pc.getLocalStreams():[]},addDataChannel:function(e,n){if(!this.pc.createDataChannel)return!1;var r={},i=t.getBrowser();if(i.name=="chrome"&&i.version<31)r={reliable:!1};else{var r={reliable:!0};n&&"reliable"in n&&(r.reliable=n.reliable)}var s=this.pc.createDataChannel(e,r);return n&&"binaryType"in n&&(s.binaryType=n.binaryType),this._createOffer(),s},setOptions:function(e){this._setOptions(e)}},i}),define("MozPeerConnection",["Log","WebRTCTools","Config","Deferred","PeerConnection"],function(e,t,n,r,i){function s(r,i,s,o){var u=t.getBrowser(),a={iceServers:u.name=="firefox"&&u.version>=28?n.TURN_SERVERS:n.STUN_SERVERS};this.compatibilyMode=s,this.signalingChannel=r,this.offerSdpConstraints=undefined,this.isCaller=i,this.defaultStream=null,this.autoAttachStream=!0,this.waitingAnswer=!1,this.deferredOffer=null,this.sendOnly=!1,this.receiveOnly=!1,this.audioBitrate=!1,this.videoBitrate=!1,this.preferedAudioCodec=!1,this.mergeCandidates=!1,this.pc=null,this.onAddStream=function(){e("[MozPeerConnection] Remote stream added",arguments)},this.onRemoveStream=function(){e("[MozPeerConnection] Remote stream removed",arguments)},this.onCloseStream=function(){e("[MozPeerConnection] Remote stream closed",arguments)},this.onOpen=function(){e("[MozPeerConnection] Session opened",arguments)},this.onConnecting=function(){e("[MozPeerConnection] Session connecting",arguments)},this.onFailed=function(){e("[MozPeerConnection] onFailed",arguments)},this.onStateChange=function(){e("[MozPeerConnection] State changed",arguments)},this.onStatsUpdated=function(){e("[MozPeerConnection] Stats updated",arguments)},this._setOptions(o),this._init(a)}var o={_processSignalingMsg:function(t){var n=this,r=typeof t=="object"?t:JSON.parse(t);r.candidate&&this.remoteIceCandidate.push(new RTCIceCandidate(r.candidate));if(r.sd){switch(this.compatibilyMode){case"FF>CR":case"CR>FF":case"FF>SF":case"SF>FF":case"FF>IE":case"IE>FF":var i=r.sd.sdp;i=i.replace("a=ice-options:google-ice\\r\\n",""),r.sd.sdp=i}e("[MozPeerConnection] Receive "+r.sd.type+":",r.sd),this.pc.setRemoteDescription(new RTCSessionDescription(r.sd),function(){r.sd&&r.sd.type=="offer"&&(n.autoAttachStream&&(n.autoAttachStream=!1,n._attachStream(n.defaultStream)),n._createAnswer(n.defaultStream)),r.sd&&r.sd.type=="answer"&&(n.waitingAnswer=!1,n.deferredOffer&&(n.deferredOffer.resolve(),n.deferredOffer=null),n._clearConnectTimout()),e("[MozPeerConnection] setRemoteDescription OK")},function(){n._failed("_processSignalingMsg, setRemoteDescription",arguments)}),this.hasRemoteDescription=!0}this._processRemoteCandidate()},_getStats:function(){},_setBitrate:function(e){return this.audioBitrate&&(e=e.replace(/(m=audio [A-Z0-9\/\s]*)/g,"$1b=AS:"+this.audioBitrate+"\r\n")),this.videoBitrate&&(e=e.replace(/(m=video [A-Z0-9\/\s]*)/g,"$1b=AS:"+this.videoBitrate+"\r\n")),e}};s.prototype={};var u;for(u in i.prototype)s.prototype[u]=i.prototype[u];for(u in o)s.prototype[u]=o[u];return s}),define("PCManager",["Log","WebRTCTools","PubSub","DataChannelWrapper","FileTransferWrapper","PeerConnection","MozPeerConnection","AudioActivityMonitor"],function(e,t,n,r,i,s,o,u){function a(e){return e||"unnamed"}function f(){this.peerConns={},this.dataChannels={},this.fileTransfers={},this.waitingFiles={},n.subscribe("_onDataChannelOpened",this._onDataChannelOpened.bind(this)),n.subscribe("_onDataChannelClosed",this._onDataChannelClosed.bind(this)),n.subscribe("_onDataChannelError",this._onDataChannelClosed.bind(this)),n.subscribe("_onFileTransferOpened",this._onDataChannelOpened.bind(this)),n.subscribe("_onFileTransferClosed",this._onFileTransferClosed.bind(this)),n.subscribe("_onFileTransferError",this._onFileTransferClosed.bind(this)),n.subscribe("_onFileWaitingTransfer",this._onFileTransferWaiting.bind(this))}return f.prototype={createPeer:function(s,o,f,l,c,h,p){e("[PCManager] Create peer connection for room: ",o," pid: ",s);var d=a(o),v=l?t.getCompatibilityMode(l):!1,m=new(this._getPerConn())(new p(s,o),f,v,h),g="call_"+s+"_"+o+"_"+(new Date).getTime();return m.onAddStream=function(r){!r.stream.id||r.stream.id=="default"?(delete r.stream.id,r.stream.id=this._getRandomId()):this._sanitizeStreamId(r.stream),r.stream.room=d,e("[PCManager] Stream added: ",s,r),n.publish("onStreamAdded",r.stream,s),f&&n.publish("_onCallStart",{pid:s,room:d,callId:g,browsers:t.getVendorsDescription(c),type:"call:"+this._getCallType(m.getLocalStreams())+"|"+this._getCallType(m.getStreams())})}.bind(this),m.onRemoveStream=function(t){this._sanitizeStreamId(t.stream),t.stream.room=d,e("[PCManager] Stream removed: ",s,t),u.remove(t.stream),n.publish("onStreamRemoved",t.stream,s),f}.bind(this),m.onCloseStream=function(r){this._sanitizeStreamId(r.stream),r.stream.room=d,e("[PCManager] Stream closed: ",s,r),u.remove(r.stream),n.publish("onStreamClosed",r.stream,s),this._clearPeer(s,d),f&&n.publish("_onCallStop",{pid:s,room:d,callId:g,browsers:t.getVendorsDescription(c),type:"call:"+this._getCallType(m.getLocalStreams())+"|"+this._getCallType(m.getStreams())})}.bind(this),m.onStatsUpdated=function(e){n.publish("onStreamStatsUpdated",e,s)}.bind(this),m.onFailed=function(e,r){m.signalingChannel.onFailed(e,{error:r,callId:g}),f&&n.publish("_onCallFail",{pid:s,room:d,callId:g,browsers:t.getVendorsDescription(c),type:"call",message:r})}.bind(this),m.onDataChannel=function(e){var o=e.channel.label;if(o.indexOf("__file_transfert_")==0){var u=this.waitingFiles[o];u&&(d in this.fileTransfers||(this.fileTransfers[d]={}),s in this.fileTransfers[d]||(this.fileTransfers[d][s]={}),this.fileTransfers[d][s][o]=new i(e.channel,d,o,s,u.id,u,!1),delete this.waitingFiles[o])}else{var a=new r(e.channel,d,s);d in this.dataChannels||(this.dataChannels[d]={}),s in this.dataChannels[d]||(this.dataChannels[d][s]={}),this.dataChannels[d][s][o]=a,n.publish("onDataChannelRequested",a,s),n.publish("_onDataChannelStart",{pid:s,room:d,callId:g,browsers:t.getVendorsDescription(c),type:"datachannel"})}}.bind(this),d in this.peerConns||(this.peerConns[d]={}),this.peerConns[d][s]=m,this.peerConns[d][s]},closePeer:function(e,t){var n=a(t);if(!this.peerConns[n]||!(e in this.peerConns[n]))return;var r=this.peerConns[n][e].getStreams().length;this.peerConns[n][e].close(),r||this._clearPeer(e,t)},closeAllPeers:function(e){var t=a(e);for(pid in this.peerConns[t])this.closePeer(pid,e)},createDataChannel:function(e,t,i,s){var o=a(i);if(!this.peerConns[o]||!this.peerConns[o][e])return;var u=this.peerConns[o][e].addDataChannel(t,s),f=new r(u,o,e);if(!f)return;o in this.dataChannels||(this.dataChannels[o]={}),e in this.dataChannels[o]||(this.dataChannels[o][e]={}),this.dataChannels[o][e][t]=f,n.publish("onDataChannelCreated",f,e)},createFileTransfer:function(e,t,n,r,s){var o=a(n);if(!this.peerConns[o]||!this.peerConns[o][e])return;var u=this.peerConns[o][e].addDataChannel(t,{ordered:!1,binaryType:"arraybuffer"}),f=new i(u,o,t,e,r,s,!0);if(!f)return;o in this.fileTransfers||(this.fileTransfers[o]={}),e in this.fileTransfers[o]||(this.fileTransfers[o][e]={}),this.fileTransfers[o][e][t]=f},getDataChannels:function(e){var t={};for(var n in this.dataChannels)if(n==e)for(pid in this.dataChannels[n])t[pid]=this.dataChannels[n][pid];return t},addStream:function(e,t,n){var r=a(t);if(!this.peerConns[r])return;for(var i in this.peerConns[r]){if(e&&i!=e)continue;this.peerConns[r][i].attachStream(n)}},removeStream:function(e,t,n){var r=a(t);if(!this.peerConns[r])return;for(var i in this.peerConns[r]){if(e&&i!=e)continue;this.peerConns[r][i].detachStream(n)}},setSignal:function(e,t,n){var r=a(t);if(!this.peerConns[r]||!this.peerConns[r][e])return;this.peerConns[r][e].signalingChannel.onReceive(n)},isCaller:function(e,t){var n=a(t);return this.peerConns[n][e].isCaller},getPeersId:function(e){var t=a(e),n=[];for(var r in this.peerConns[t])n.push(r);return n},getPeer:function(e,t,n){var r=a(t);return this.peerConns[r]?(this.peerConns[r][e]&&n&&this.peerConns[r][e].setOptions(n),this.peerConns[r][e]||null):null},getStreams:function(e){var t={};for(var n in this.peerConns)if(n==e||!e)for(i in this.peerConns[n]){var r=this.peerConns[n][i].getStreams();t.hasOwnProperty(i)||(t[i]=[]),t[i]=t[i].concat(r)}for(var i in t)t[i].length==1&&(t[i]=t[i][0]);return t},_getPerConn:function(){var e,n=t.getClientDescription().split("::")[0];switch(n){case"FF":e=o;break;case"CR":e=s;default:e=s}return e},_clearPeer:function(t,n){var r=a(n);this.peerConns[r]&&t in this.peerConns[r]&&delete this.peerConns[r][t],this._clearRoom(n),e("[PCManager] peerConn destroyed for ",t,n)},_clearRoom:function(t){var n=a(t),r=0;if(!this.peerConns[n])return;Object.keys(this.peerConns[n]).length||(delete this.peerConns[n],e("[PCManager] Room destroyed ",t))},_onDataChannelOpened:function(t,n){if(!this.peerConns[t]||!(n in this.peerConns[t]))return;this.peerConns[t][n]._clearConnectTimout(),e("[PCManager] Datachannel/File Transfer: stop timeout",arguments)},_onDataChannelClosed:function(t,n,r){if(!this.dataChannels[t]||!(n in this.dataChannels[t]))return;r in this.dataChannels[t][n]&&(delete this.dataChannels[t][n][r],Object.keys(this.dataChannels[t][n]).length||delete this.dataChannels[t][n],e("[PCManager] Datachannel: remove from 'dataChannels'",arguments))},_onFileTransferClosed:function(t,n,r){if(!this.fileTransfers[t]||!(n in this.fileTransfers[t]))return;r in this.fileTransfers[t][n]&&(delete this.fileTransfers[t][n][r],Object.keys(this.fileTransfers[t][n]).length||delete this.fileTransfers[t][n],e("[PCManager] File Transfer: remove from 'fileTransfers'",arguments))},_onFileTransferWaiting:function(e,t){this.waitingFiles[e]=t},_getCallType:function(e){var t="";for(var n=0;n<e.length;n++)if(e[n]&&typeof e[n].getVideoTracks=="function"&&typeof e[n].getAudioTracks=="function"){var r=e[n].getVideoTracks(),i=e[n].getAudioTracks();t&&(t+="&"),r.length&&i.length?t+="audio-video":r.length&&!i.length?t+="video":!r.length&&i.length&&(t+="audio")}else t+="unknown";return t},_getRandomId:function(){var e=40,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_",n="";for(var r=0;r<e;r++)n+=t.charAt(Math.random()*63);return n},_sanitizeStreamId:function(e){if(e.id.indexOf("/")!=-1){var t=e.id.replace(/\//g,"_");delete e.id,e.id=t}}},new f}),define("main",["Log","Utils","Ajax","Config","Signaling","SignalingChannel","SipSignalingChannel","WebRTCTools","Streams","DataChannels","FileTransfer","UserMedia","PCManager","PubSub","AudioActivityMonitor","Plugin"],function(e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v){function m(){this.version=r.VERSION,this.connected=!1,this.isUserChecked=!1,this.appId=undefined,this.appKey=undefined,this.userId=undefined,this.userName=undefined,this.signaling=undefined,this.autoCloseOnExit=!0,this.streams=a,this.channels=f,this.files=l,this.signaling=new i,this._isSSCompatible=!1,this._rooms={},this._calls={},this._files={},this._isMicrophoneMuted=!1,this._isVideoMuted=!1,this._isAllSoundsMuted=!1,this.webRTCPlugin=v.usePlugin(),this._init()}function g(e){this.parent=e}function y(e,t){var n=document.createElement("param");return n.setAttribute("name",e),n.setAttribute("value",t),n}function b(){v.isPluginLoaded()?window.onBistriConferenceReady():setTimeout(b,200)}function w(){document.readyState=="complete"?typeof window.onBistriConferenceReady=="function"&&(v.usePlugin()?b():window.onBistriConferenceReady()):setTimeout(w,200)}m.prototype={presence:{online:"1",away:"2",busy:"3",offline:"4"},init:function(e){e=e||{},window.bistriDebug=e.debug||!1;if(t.isLocalCopy())throw new Error("We detect that bistri.conference.min.js has been copied on a local server ! Please use the file hosted on https://api.bistri.com/bistri.conference.min.js to ensure the security and stability of your applications.");if(!e.appId||!e.appKey)throw new Error("appId and appKey parameters are mandatory");e.hasOwnProperty("userId")&&typeof e.userId=="string"&&(e.userId=this._sanitizeString(e.userId)),e.useSip&&(this.sip=new g(this)),this.userId=e.userId||undefined,this.userName=e.userName||undefined,this.appId=e.appId,this.appKey=e.appKey,e.hasOwnProperty("autoCloseOnExit")&&(this.autoCloseOnExit=e.autoCloseOnExit),this.signaling.init(this.appId,this.appKey,e.useSip||undefined),e.hasOwnProperty("chromeExtentionId")&&(e.chromeExtensionId=e.chromeExtentionId),r.set({userId:this.userId,chromeExtId:e.chromeExtensionId,firefoxExtId:e.firefoxExtensionId,extAutoReload:e.hasOwnProperty("extAutoReload")?e.extAutoReload:!0,turnServers:e.hasOwnProperty("turnServers")?e.turnServers:[],stunServers:e.hasOwnProperty("stunServers")?e.stunServers:[]});var n=u.getBrowser();n.name=="chrome"&&n.version>=34&&chrome&&chrome.webstore&&(this._isSSCompatible=!0,this._insertExtTag(e.chromeExtensionId)),n.name=="firefox"&&n.version>=33&&(this._isSSCompatible=!0),this.autoCloseOnExit&&(typeof window.onbeforeunload!="undefined"?window.addEventListener("beforeunload",function(){window.BistriConference.disconnect()}):typeof window.onunload!="undefined"&&window.addEventListener("unload",function(){window.BistriConference.disconnect()}))},connect:function(){this.signaling.connect(this.userId,this.userName)},disconnect:function(){this.signaling.disconnect()},joinRoom:function(e,t){if(!this._validateString(e,!0))return;if(t&&isNaN(Number(t)))throw new Error("capacity must an integer comprised between 2 and 256");if(Number(t)<2||Number(t)>256)throw new Error("capacity must an integer comprised between 2 and 256");this.signaling.joinRoom(this._sanitizeString(e),t)},quitRoom:function(t){t||e("[BistriConference] API CHANGE WARNING: you must indicate a room name -> quitRoom( room )");if(!this._validateString(t))return;this.signaling.quitRoom(this._sanitizeString(t))},call:function(t,n,r){n||e("[BistriConference] API CHANGE WARNING: you must indicate a room name -> call( id, room )");if(!this._validateString(n))return;var i=this.getRemoteStreams(this._sanitizeString(n));if(i&&i.hasOwnProperty(t)){e('[BistriConference] Cannot call "'+t+'", call already exists');return}var s=this._random(8),o=this._validateOptions(r,["sendonly","receiveonly","audio-codec","audio-bitrate","video-bitrate","stream"]);this._calls[s]=o.stream,o.hasOwnProperty("stream")&&delete o.stream,this.signaling.sendSignal(this._sanitizeString(t),this._sanitizeString(n),{call:"init",id:s,desc:u.getClientDescription(),vendor:u.getVendorDescription(),options:o})},createDataChannel:function(t,n){e("[BistriConference] API CHANGE WARNING: createDataChannel method is deprecated, use openDataChannel instead"),this.signaling.sendSignal(this._sanitizeString(t),undefined,{channel:"init",id:this._random(8),label:n,desc:u.getClientDescription(),vendor:u.getVendorDescription(),options:{}})},openDataChannel:function(t,n,r,i){if(!this._validateString(r))return;var s=h.getDataChannels(this._sanitizeString(r));if(s&&s.hasOwnProperty(t)&&s[t].hasOwnProperty(n)){e('[BistriConference] Cannot open datachannel "'+t+'", datachannel already exists');return}this.signaling.sendSignal(this._sanitizeString(t),this._sanitizeString(r),{channel:"init",id:this._random(8),label:n,desc:u.getClientDescription(),vendor:u.getVendorDescription(),options:this._validateOptions(i,["reliable","binaryType"])})},sendFile:function(t,n,r){if(!this._validateString(n))return;if(r.size==0){e("[BistriConference] Cannot send empty file");return}var i=this._random(12);this._files[i]=r,this.signaling.sendSignal(this._sanitizeString(t),this._sanitizeString(n),{channel:"init",id:i,label:"__file_transfert_"+i,desc:u.getClientDescription(),vendor:u.getVendorDescription(),file:{id:i,name:r.name,size:r.size}})},endCall:function(t,n){n||e("[BistriConference] API CHANGE WARNING: you must indicate a room name -> endCall( room )");if(!this._validateString(n))return;var r=this._sanitizeString(n);this.signaling.sendSignal(this._sanitizeString(t),r,{call:"stop"}),h.closePeer(this._sanitizeString(t),r)},endCalls:function(t){t||e("[BistriConference] API CHANGE WARNING: you must indicate a room name -> endCalls( room )");if(!this._validateString(t))return;var n=this._sanitizeString(t),r=h.getPeersId(n);for(var i=0;i<r.length;i++)this.signaling.sendSignal(r[i],n,{call:"stop"}),h.closePeer(r[i],n)},startStream:function(e,t){if(typeof t!="function")throw new Error(t+" is not a valid callback, function expected");c.start(e,t)},stopStream:function(){arguments.length>1?c.stop(arguments[0],arguments[1]):(e("[BistriConference] API CHANGE WARNING: stream to stop must be specified."),c.stop(c.getDefaultStream(),arguments[0]))},getMediaSources:function(e){if(typeof e=="function")return MediaStreamTrack.getSources?MediaStreamTrack.getSources(e):!1;throw new Error(e+" is not a valid callback, function expected")},getStream:function(){return e("[BistriConference] API CHANGE WARNING: getStream method is deprecated, use getLocalStreams instead."),c.getDefaultStream()},getLocalStreams:function(){return c.getStreams()},getRemoteStreams:function(e){return e&&!this._validateString(e)?{}:h.getStreams(this._sanitizeString(e))},getPeersInRoom:function(e){return this._validateString(e)?h.getPeersId(this._sanitizeString(e)):[]},getRoomMembers:function(e){if(!this._validateString(e))return[];var t=this._sanitizeString(e);return this._rooms[t]?this._rooms[t].members:[]},getDataChannels:function(e){return e&&!this._validateString(e)?{}:h.getDataChannels(this._sanitizeString(e))},addStream:function(e,t,n){if(!this._validateString(t))return;h.addStream(this._sanitizeString(e),this._sanitizeString(t),n)},removeStream:function(e,t,n){if(!this._validateString(t))return;h.removeStream(this._sanitizeString(e),this._sanitizeString(t),n)},attachStream:function(t,n,r){var i=!!t.getVideoTracks()&&!!t.getVideoTracks().length,s=!!t.getAudioTracks()&&!!t.getAudioTracks().length;this.isAllSoundsMuted()&&this._muteSound(t,!0);if(t.isTemMediaStream){t.enableSoundTracks(!0);var o=v.insertObject(n,{id:t.id,width:"100%",height:"100%","type ":"application/x-temwebrtcplugin",params:{pluginId:t.id,streamId:t.id,pageId:v.getTemPageId(),windowless:"true"}});return o.parentNode||(o.parentNode=n),o}if(!n||n.nodeName=="VIDEO"||n.nodeName=="AUDIO")return e('[BistriConference] "node" parameter is undefined !'),n;try{var o=document.createElement(i?"VIDEO":"AUDIO");n.appendChild(o),n=o}catch(a){e("[BistriConference] Node must be a VIDEO/AUDIO element or a container (DIV, SPAN, ...)")}if(n.nodeName=="VIDEO"||n.nodeName=="AUDIO"){typeof n.srcObject!="undefined"?n.srcObject=t:typeof n.mozSrcObject!="undefined"?n.mozSrcObject=t:typeof n.src!="undefined"?n.src=window.URL.createObjectURL(t):e("[BistriConference] Error attaching stream to element."),n.setAttribute("id",t.id),t&&t.localStream&&"muted"in n&&(n.muted="muted"),"autoplay"in n&&(!r||!r.hasOwnProperty("autoplay")||r&&r.autoplay)&&(n.autoplay="autoplay"),"controls"in n&&r&&r.controls&&(n.controls="controls");if(r&&r.mirror){var f=u.getBrowser(),l="transform: rotateY( 180deg )";switch(f.name){case"chrome":case"safari":l="-webkit-"+l;break;case"firefox":l="-moz-"+l}n.setAttribute("style",l)}r&&r.fullscreen&&i&&n.addEventListener("click",function(){n.requestFullScreen?n.requestFullScreen():n.webkitRequestFullScreen?n.webkitRequestFullScreen():n.mozRequestFullScreen&&n.mozRequestFullScreen()})}return n},detachStream:function(e){var t=document.getElementById(e.id);t&&t.parentNode.removeChild(t)},getPresence:function(e){this.signaling.getPresence(this._sanitizeString(e))},setPresence:function(e){var t=this.presence[e];if(!t)throw new Error("unkown status");this.signaling.setPresence(t)},monitorAudioActivity:function(e,t){d.add(e,t)},_muteSound:function(e,t){var n=e instanceof Array?e:[e];n.forEach(function(e){var n=e.getAudioTracks()||[];for(var r=0;r<n.length;r++)n[r].enabled=!t})},muteSound:function(e,t){this._muteSound(e,t)},muteAllSounds:function(e){var t=this.getRemoteStreams();for(var n in t)bc._muteSound(t[n],e);this._isAllSoundsMuted=e},isAllSoundsMuted:function(){return this._isAllSoundsMuted},muteVideo:function(e,t){var n=e.getVideoTracks()||[],r=[];this._isVideoMuted=t;for(var i=0;i<n.length;i++)n[i].enabled=!t,r.push(n[i].id);for(var s in this._rooms)this._rooms[s].members.forEach(function(e){this.signaling.sendSignal(e.id,s,{mute:t,ids:r})}.bind(this));p.publish("onStreamMuteChange",t,this.userId)},isVideoMuted:function(){return this._isVideoMuted},muteMicrophone:function(e){this._isMicrophoneMuted=e,this.getLocalStreams().forEach(function(t){this._muteSound(t,e)}.bind(this))},isMicrophoneMuted:function(){return this._isMicrophoneMuted},isConnected:function(){return this.connected?!0:!1},isCompatible:function(){return window.webRtcCompatible?!0:!1},isScreenSharingCompatible:function(){return this._isSSCompatible?!0:!1},getWebRTCPluginURL:function(){return r.PLUGIN_URL},getWebRTCPluginPageId:function(){return v.getTemPageId()},isWebRTCPluginUsed:function(){return v.usePlugin()},isWebRTCPluginAvailable:function(){var e=u.getBrowser();switch(e.os){case"MacOSX":case"Windows":return!0;case"iOS":case"Linux":case"UNIX":return!1}return!1},_init:function(){var t=this.signaling,i=r.API_SERVER.match(/^(https?:\/\/)(.*)$/);p.subscribe("_onConnected",function(e){this.connected=!0,this.userId=e.id,t.setInternalId(e.id),r.set({userId:e.id});for(var s in this._rooms)s.match(/^__/)||this.signaling.joinRoom(s,this._rooms[s].capacity);new n({url:i[1]+"userinfo"+i[2]+"/info",data:{socketid:e.socketId,appid:this.appId,appkey:this.appKey}})}.bind(this)),p.subscribe("_onDisconnected",function(e){this.signaling.clearSocket(),this.connected=!1}.bind(this)),p.subscribe("_onJoinedRoom",function(e){this._rooms[e.room]={capacity:e.capacity,members:e.members}}.bind(this)),p.subscribe("_onQuittedRoom",function(e){delete this._rooms[e.room],h.closeAllPeers(e.room)}.bind(this)),p.subscribe("_onPeerJoinedRoom",function(e){this._rooms[e.room]&&this._rooms[e.room].members.push({id:e.pid,name:e.name})}.bind(this)),p.subscribe("_onPeerQuittedRoom",function(e){this._rooms[e.room]&&this._rooms[e.room].members.forEach(function(t,n){t.id==e.pid&&this._rooms[e.room].members.splice(n,1)}.bind(this)),h.closePeer(e.pid,e.room)}.bind(this)),p.subscribe("_onSignalReceived",function(n){if(n.data&&n.data.hasOwnProperty("error")){e("[BistriConference] Connection with callee has failed: ",n.data.error);return}if(n.data&&n.data.hasOwnProperty("mute")){var i=h.getStreams(),o=n.data.ids;if(i[n.pid]){i[n.pid]instanceof Array||(i[n.pid]=[i[n.pid]]);for(var a=0;a<i[n.pid].length;a++){var f=i[n.pid][a].getVideoTracks();for(var l=0;l<f.length;l++)o.indexOf(f[l].id)!=-1&&(f[l].enabled=!n.data.mute)}}p.publish("onStreamMuteChange",n.data.mute,n.pid,n.data.ids)}if(n.data&&(n.data.hasOwnProperty("call")||n.data.hasOwnProperty("channel"))){var d;n.data.hasOwnProperty("turnArray")&&r.set({turn:n.data.turnArray}),n.data.hasOwnProperty("stunArray")&&r.set({stun:n.data.stunArray});if(n.data.call=="init"||n.data.channel=="init"){if(!u.isRemoteClientCompatible(n.data.desc)){e("[BistriConference] Caller browser version is not compatible");return}d=h.getPeer(n.pid,n.room,n.data.options)||h.createPeer(n.pid,n.room,!1,n.data.desc,n.data.vendor,n.data.options,s),n.data.call&&d.setDefaultStream(c.getDefaultStream());var v={id:n.data.id,desc:u.getClientDescription(),vendor:u.getVendorDescription(),options:n.data.options};v[n.data.call?"call":"channel"]="ready";if(n.data.channel){if(!u.areDatachannelsCompatible(n.data.desc))return;n.data.file&&p.publish("_onFileWaitingTransfer",n.data.label,n.data.file),v.label=n.data.label}t.sendSignal(n.pid,n.room,v)}else if(n.data.call=="stop")h.closePeer(n.pid,n.room);else{d=h.getPeer(n.pid,n.room,n.data.options)||h.createPeer(n.pid,n.room,!0,n.data.desc,n.data.vendor,n.data.options,s);if(n.data.call){var m;this._calls[n.data.id]?(m=this._calls[n.data.id],delete this._calls[n.data.id]):m=c.getDefaultStream(),d.attachStream(m)}else n.data.channel&&(this._files[n.data.id]?(h.createFileTransfer(n.pid,n.data.label,n.room,n.data.id,this._files[n.data.id]),delete this._files[n.data.id]):h.createDataChannel(n.pid,n.data.label,n.room,n.data.options))}}n.data&&n.data.hasOwnProperty("recorder")&&n.data.recorder=="ready"&&(d=h.getPeer(n.pid,n.room,n.data.options)||h.createPeer(n.pid,n.room,!0,n.data.desc,n.data.vendor,n.data.options,s),d.attachStream(c.getDefaultStream())),n.data&&(n.data.hasOwnProperty("sd")||n.data.hasOwnProperty("candidate"))&&h.setSignal(n.pid,n.room,n.data)}.bind(this)),p.subscribe("_onCallStart",function(e){t.log("call-start",e)}),p.subscribe("_onCallStop",function(e){t.log("call-stop",e)}),p.subscribe("_onCallFail",function(e){t.log("call-fail",e)}),p.subscribe("_onDataChannelStart",function(e){t.log("datachannel-open",e)}),p.subscribe("_updateApiClient",function(e){this._updateApiClient(e)}.bind(this)),s.prototype={send:function(e){t.sendSignal(this.pid,this.room,e)},onFailed:function(e,n){t.sendSignal(this.pid,this.room,n)}},o.prototype={send:function(e){t.sendSipSignal(this.pid,this.room,e)},onFailed:function(e,n){t.sendSignal(this.pid,this.room,n)}}},_validateOptions:function(t,n){var r={};if(t){if(typeof t!="object")return e("[BistriConference] Options should be an object"),r;for(var i in t)n.indexOf(i)!=-1&&(r[i]=t[i])}return r},_sanitizeString:function(e){return typeof e=="string"?e.replace(/^\s+|\s+$/g,"").replace(/\s/g,"_"):e},_validateString:function(e,t){if(!e&&!t)return!0;if(e&&typeof e=="string"){var n=e.match(/^[a-zA-Z0-9-_\s]+$/);if(n)return!0;throw new Error("string contains unauthorized chars. Use only a-z, A-Z, 0-9, hyphen, underscore or space")}throw new Error("value can't be undefined or empty, string expected")},_validateNumber:function(e,t){if(!e&&!t)return!0;if(e&&typeof e=="string"){var n=e.match(/^[0-9]+$/);if(n)return!0;throw"Error: string contains unauthorized chars. Use only numbers 0-9"}throw"Error: value can't be undefined or empty, string expected"},_random:function(e){var t=e||20,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_",r="";for(var i=0;i<t;i++)r+=n.charAt(Math.random()*63);return r},_insertExtTag:function(e){var t=document.createElement("link"),n=document.querySelector("head");n.appendChild(t),t.setAttribute("rel","chrome-webstore-item"),t.setAttribute("href","https://chrome.google.com/webstore/detail/"+e)}},g.prototype={call:function(t,n,r){t||e("[BistriConference] You must indicate a call id"),n||e("[BistriConference] You must indicate a number");if(!this.parent._validateNumber(n))return;var i,s=this.parent.getRemoteStreams(this.parent._sanitizeString(n));if(s&&s.hasOwnProperty(t)){e('[BistriConference] Cannot call "'+t+'", call already exists');return}r=this.parent._validateOptions(r,["sendonly","receiveonly","audio-codec","audio-bitrate","video-bitrate","merge-candidates"]),r["merge-candidates"]=!0,i=h.createPeer(t,n,!0,undefined,undefined,r,o),i.attachStream(c.getDefaultStream())},endCall:function(t,n){t||e("[BistriConference] You must indicate a call id"),n||e("[BistriConference] You must indicate a number");if(!this.parent._validateNumber(n))return;var r=this.parent._sanitizeString(n);this.parent.signaling.sendSipSignal(this.parent._sanitizeString(t),r,{call:"stop"}),h.closePeer(this.parent._sanitizeString(t),r)},dtmf:function(t,n){t||e("[BistriConference] You must indicate a number"),n.match(/[0-9#*]+/)||e("[BistriConference] DTMF tone is missing or invalid. 0-9 # * allowed");var r=this.parent._sanitizeString(t);this.parent.signaling.sendSipDtmf(t,n)}},window.pluginLoaded=!1,window.bc=window.BistriConference=new m,w()}),require(["main"])