catlab-remote-client 1.2.9 → 1.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
var s,t,e,A,i,h,a;define("CatLab/Webremote/Tools/Net",[],function(){return{loadJSON:function(t,e,i){var s=new XMLHttpRequest;s.onreadystatechange=function(){s.readyState===XMLHttpRequest.DONE&&200===s.status&&e&&e(JSON.parse(s.responseText))},s.onerror=function(t){t&&i(s,t)},s.open("GET",t,!0),s.send()}}}),define("CatLab/Webremote/Tools/Deferred",[],function(){function l(t){return"[object Array]"===Object.prototype.toString.call(t)}function c(t,e){if(l(t))for(var i=0;i<t.length;i++)e(t[i]);else e(t)}function u(t){var s="pending",n=[],o=[],r=[],a=null,i={done:function(){for(var t=0;t<arguments.length;t++)if(arguments[t])if(l(arguments[t]))for(var e=arguments[t],i=0;i<e.length;i++)"resolved"===s&&e[i].apply(this,a),n.push(e[i]);else"resolved"===s&&arguments[t].apply(this,a),n.push(arguments[t]);return this},fail:function(){for(var t=0;t<arguments.length;t++)if(arguments[t])if(l(arguments[t]))for(var e=arguments[t],i=0;i<e.length;i++)"rejected"===s&&e[i].apply(this,a),o.push(e[i]);else"rejected"===s&&arguments[t].apply(this,a),o.push(arguments[t]);return this},always:function(){return this.done.apply(this,arguments).fail.apply(this,arguments)},progress:function(){for(var t=0;t<arguments.length;t++)if(arguments[t])if(l(arguments[t]))for(var e=arguments[t],i=0;i<e.length;i++)"pending"===s&&r.push(e[i]);else"pending"===s&&r.push(arguments[t]);return this},then:function(){1<arguments.length&&arguments[1]&&this.fail(arguments[1]),0<arguments.length&&arguments[0]&&this.done(arguments[0]),2<arguments.length&&arguments[2]&&this.progress(arguments[2])},promise:function(t){if(null==t)return i;for(var e in i)t[e]=i[e];return t},state:function(){return s},debug:function(){console.log("[debug]",n,o,s)},isRejected:function(){return"rejected"===s},isResolved:function(){return"resolved"===s},pipe:function(t,e,i){return u(function(i){c(t,function(e){"function"==typeof e?h.done(function(){var t=e.apply(this,arguments);t&&"function"==typeof t?t.promise().then(i.resolve,i.reject,i.notify):i.resolve(t)}):h.done(i.resolve)}),c(e,function(e){"function"==typeof e?h.fail(function(){var t=e.apply(this,arguments);t&&"function"==typeof t?t.promise().then(i.resolve,i.reject,i.notify):i.reject(t)}):h.fail(i.reject)})}).promise()}},h={resolveWith:function(t){if("pending"===s){s="resolved";for(var e=a=1<arguments.length?arguments[1]:[],i=0;i<n.length;i++)n[i].apply(t,e)}return this},rejectWith:function(t){if("pending"===s){s="rejected";for(var e=a=1<arguments.length?arguments[1]:[],i=0;i<o.length;i++)o[i].apply(t,e)}return this},notifyWith:function(t){if("pending"===s)for(var e=a=1<arguments.length?arguments[1]:[],i=0;i<r.length;i++)r[i].apply(t,e);return this},resolve:function(){return this.resolveWith(this,arguments)},reject:function(){return this.rejectWith(this,arguments)},notify:function(){return this.notifyWith(this,arguments)}},e=i.promise(h);return t&&t.apply(e,[e]),e}return u.when=function(){var t;if(arguments.length<2)return((t=arguments.length?arguments[0]:void 0)&&"function"==typeof t.isResolved&&"function"==typeof t.isRejected?t:u().resolve(t)).promise();for(var i=arguments,s=u(),n=i.length,o=0,r=new Array(n),e=0;e<i.length;e++)(t=>{var e;i[t].done?i[t].done(function(){r[t]=arguments.length<2?arguments[0]:arguments,++o==n&&s.resolve.apply(s,r)}).fail(function(){s.reject(arguments)}):(e=i[t],i[t]=new Deferred,i[t].done(function(){r[t]=arguments.length<2?arguments[0]:arguments,++o==n&&s.resolve.apply(s,r)}).fail(function(){s.reject(arguments)}).resolve(e))})(e);return s.promise()},u}),define("CatLab/Webremote/Collections/ServerList",["CatLab/Webremote/Tools/Deferred"],function(n){function t(t,e){this.defaultId=t.default,this.servers=t.servers,this.connectUrl=t.connectUrl,this.selectedServerId=null,this.preferredServer=e,this.assetsUrl=t.assetsUrl}var e=t.prototype;return e.getFromToken=function(t){if(t.length<8)return{host:this.getDefault().host,token:t};var e=t.substr(0,2);if(e){e=this.getFromId(e);if(e)return{host:e.host,token:t.substr(2)}}throw new Error("Code does not correspondent to any servers.")},e.getSelectedServer=function(){var e=new n;return this.selectedServerId?this.getFromId(this.selectedServerId)?e.resolve(this.getFromId(this.selectedServerId).host):e.reject("Selected remote server not found in server list. Please make sure you are connected to the right network."):this.selectBestServer().then(function(t){this.selectedServerId||(this.selectServer(t.id),e.resolve(t.host))}.bind(this)),e.promise()},e.selectBestServer=function(){var i=new n;if(this.preferredServer)for(var t=0;t<this.servers.length;t++)if(this.servers[t].id==this.preferredServer)return i.resolve(this.servers[t]),i.promise();var s=!1;return this.servers.forEach(function(e){e.discoverable&&this.measureRequestSpeed("https://"+e.host+"/info").then(function(t){console.log("[ServerList] "+e.host+" took "+t+"ms"),s||(s=!0,i.resolve(e))}.bind(this))}.bind(this)),i.promise()},e.selectServer=function(t){this.selectedServerId=t},e.measureRequestSpeed=function(t){var e=new Date,i=new n,s=new XMLHttpRequest;return s.onreadystatechange=function(){var t;4==this.readyState&&200==this.status&&(t=(new Date).getTime()-e.getTime(),i.resolve(t))},s.open("GET",t),s.send(),i.promise()},e.getConnectURL=function(){if(this.selectedServerId){var t=this.getFromId(this.selectedServerId);if(t.connectUrl)return t.connectUrl}return this.connectUrl},e.getAssetURL=function(){var t;return this.assetsUrl||((t=this.getConnectURL())?("http"!==t.substring(0,4)&&(t="https://"+t),this.assetsUrl=t+"/assets/",this.assetsUrl):void 0)},e.getConnectToken=function(t){return this.getFromId(this.selectedServerId).connectUrl?t:this.selectedServerId+t},e.getFromId=function(t){for(var e=0;e<this.servers.length;e++)if(this.servers[e].id==t)return this.servers[e];return null},e.getDefault=function(){return this.getFromId(this.defaultId)},e.serialize=function(){return{server:this.selectedServerId}},e.unserialize=function(t){this.selectServer(t.server)},t}),define("CatLab/Webremote/Config",["CatLab/Webremote/Tools/Net","CatLab/Webremote/Collections/ServerList"],function(i,t){var e="http";return{_options:{host:"www.catlab.tv",serverlist:null,preferredServer:null,protocol:e="undefined"!=typeof window&&void 0!==window.location&&void 0!==window.location.protocol?window.location.protocol.substr(0,window.location.protocol.length-1):e,debug:!1,proxy:"",imageproxy:"",smileys:!0,assetsUrl:null,vendorPath:"/vendor/",audioSync:!1,allowAuthentication:!0,canFullscreen:!0,oauth:{redirectUrl:null}},_initialized:!1,audioSyncConfig:{alphabet:"qwertyuiop",length:5,freqMin:524,freqMax:1593,freqError:25,debug:!1},set:function(t){void 0!==t&&(t.host,this._options.host=t.host,void 0!==t.protocol&&(this._options.protocol=t.protocol),void 0!==t.debug&&(this._options.debug=t.debug),void 0!==t.imageproxy&&(this._options.imageproxy=t.imageproxy),void 0!==t.proxy&&(this._options.proxy=t.proxy),void 0!==t.smileys&&(this._options.smileys=t.smileys),void 0!==t.assetsUrl&&(this._options.assetsUrl=t.assetsUrl),void 0!==t.vendorPath&&(this._options.vendorPath=t.vendorPath),void 0!==t.audioSync&&(this._options.audioSync=t.audioSync),void 0!==t.serverlist&&(this._options.serverlist=t.serverlist),void 0!==t.preferredServer&&(this._options.preferredServer=t.preferredServer),void 0!==t.allowAuthentication&&(this._options.allowAuthentication=t.allowAuthentication),void 0!==t.audioSyncConfig&&(this.audioSyncConfig=t.audioSyncConfig),void 0!==t.canFullscreen&&(this._options.canFullscreen=t.canFullscreen),void 0!==t.oauth)&&void 0!==t.oauth.redirectUrl&&(this._options.oauth.redirectUrl=t.oauth.redirectUrl)},getAll:function(){return this._options},initialize:function(e){var t;this._initialized?e():null===this._options.serverlist||"http"!==this._options.serverlist.substring(0,4)?(this._initialized=!0,e()):"json"===this._options.serverlist.substring(this._options.serverlist.length-4)?i.loadJSON(this._options.serverlist,function(t){this._initialized=!0,this._options.serverlist=t,e()}.bind(this),function(t,e){alert("Failed to connect to "+this._options.serverlist+". Game cannot start."),console.log(e)}.bind(this)):((t=document.createElement("script")).onload=function(){this._initialized=!0,this._options.serverlist=getCatLabRemoteServers(),e()}.bind(this),t.onerror=function(){alert("Failed to connect to "+this._options.serverlist+". Game cannot start.")}.bind(this),t.src=this._options.serverlist,document.head.appendChild(t))},getProtocol:function(t){var e=this._options.protocol;switch(e=void 0!==t&&t&&""===e?"http":e){case"http":case"https":break;default:e="https"}return e},getSocketURL:function(t){return this._options.host?((t=this.getProtocol(t))&&(t+=":"),t+"//"+this._options.host):"undefined"!=typeof window&&void 0!==window.location?window.location.protocol+"//"+window.location.hostname:""},getAssetsURL:function(t){var e;return this._options.assetsUrl||((e=this.getServerList())?e.getAssetURL():this.getSocketURL(t)+"/assets/")},debug:function(){return this._options.debug},getProxiedImage:function(t){return this._options.imageproxy?this._options.imageproxy+encodeURIComponent(t):t},getProxy:function(){return this._options.proxy},useSmileys:function(){return this._options.smileys},useAudioSync:function(){return this._options.audioSync},all:function(){return this._options},getAudioSyncConfig:function(){return this.audioSyncConfig},getProviderConfig:function(){var t={smileys:this.useSmileys(),audioSync:this.useAudioSync()};return this.useAudioSync()&&(t.audioSyncConfig=this.audioSyncConfig),t},getServerList:function(){return this._options.serverlist?(this.serverCollection||(this.serverCollection=new t(this._options.serverlist,this._options.preferredServer)),this.serverCollection):null},getVendorPath:function(){return this._options.vendorPath},supportsAuthentication:function(){return this._options.allowAuthentication},canFullscreen:function(){return this._options.canFullscreen}}}),define("CatLab/Webremote/Polyfills",[],function(){"function"!=typeof Object.assign&&(Object.assign=function(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),s=1;s<arguments.length;s++){var n=arguments[s];if(null!=n)for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])}return i})}),define("CatLab/Webremote/Tools/Tracker",[],function(){var n=function(t,e,i,s){},e=function(t){n("Page",t,"-",0)};return{setTracker:function(t){n=t},setPageMethod:function(t){e=t},track:function(t,e,i,s){n(t,e,i,s)},page:function(t){e(t)}}}),define("CatLab/Webremote/Tools/Tools",[],function(){var n,o;return{popup:function(t,e){var i=this,s=(e=e||!1,document.createElement("iframe"));s.style.margin=0,s.style.padding=0,s.style.border=0,s.style.position="absolute",s.style.width="100%",s.style.height="100%",s.style.left=0,s.style.top=0,s.src=t,(o=document.createElement("div")).style.margin=0,o.style.padding=0,o.style.border=0,o.style.position="absolute",o.style.width="100%",o.style.height="100%",o.style.left=0,o.style.top=0,o.style.zIndex=9999,o.onclick=function(){i.closePopup()},(n=document.createElement("div")).appendChild(s),n.style.margin=0,n.style.padding=0,n.style.border=0,n.style.position="absolute",n.style.zIndex=1e4,n.style.overflow="auto",n.style.background="white",n.style.boxSizing="border-box",e?(n.style.border="0 none black",n.style.left="0",n.style.top="0",n.style.width="100%",n.style.height="100%"):(n.style.border="5px solid black",n.style.left="10%",n.style.top="10%",n.style.width="80%",n.style.height="80%"),document.body.appendChild(o),document.body.appendChild(n)},oauth2PopupMethod:function(t,e){return window.open(t,"oauth:catlab-remote")},oauth2Popup:function(t,e){return this.oauth2PopupMethod(t,e)},closePopup:function(){n&&n.parentNode.removeChild(n),o&&o.parentNode.removeChild(o)},setOauth2Popup:function(t){return this.oauth2PopupMethod=t,this},sanitize:function(t){var e;return null==t?null:(e={"&":"&","<":"<",">":">",'"':""","'":"'"},String(t).replace(/[&<>"']/g,function(t){return e[t]}))},nl2br:function(t,e){return null==t?"":(t+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+(e||void 0===e?"<br />":"<br>")+"$2")},shuffle:function(t){for(var e,i,s=t.length-1;0<s;s--)e=Math.floor(Math.random()*(s+1)),i=t[s],t[s]=t[e],t[e]=i},getUuid:function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},findIndex:function(t,e){for(var i=0;i<t.length;i++)if(e(t[i]))return i;return-1},getConnectTokenForDisplay:function(t){return null===t?null:t.length%4==0?this.injectFillerInString(t,4," "):(t.length,this.injectFillerInString(t,3," "))},injectFillerInString:function(t,e,i){return t.match(new RegExp(".{1,"+e+"}","g")).join(i)}}}),define("CatLab/Webremote/Tools/Eventable",["CatLab/Webremote/Tools/Tools"],function(s){function t(){}var n=0,e=t.prototype;return e.initializeEventable=function(){this._eventableEvents=[]},e.trigger=function(t){this.eventableTrigger.apply(this,arguments)},e.eventableTrigger=function(t){if("string"!=typeof t)throw new Error("eventableTrigger must be a string");if(void 0!==this._eventableEvents){var e,i=Array.prototype.slice.call(arguments);for(e in i.push(i.shift()),this._eventableEvents)this._eventableEvents.hasOwnProperty(e)&&this.eventMatches(t,e)&&this._eventableEvents[e].slice().forEach(function(t){try{t.method.apply(t.scope,i)}catch(t){console.error(t)}}.bind(this))}},e.eventMatches=function(t,e){return"*"===e||t===e},e.on=function(t,e,i){void 0===this._eventableEvents&&(this._eventableEvents={}),void 0===this._eventableEvents[t]&&(this._eventableEvents[t]=[]),n++,this._eventableEvents[t].push({id:n,method:e,scope:void 0!==i?i:this});var s=[t,n];return{id:s,name:t,method:e,unbind:function(){this.off(null,{id:s,name:t})}.bind(this)}},e.once=function(t,e,i){var s=this.on(t,function(){s.unbind(),e.apply(i,arguments)});return s},e.off=function(t,e){if(void 0!==t||void 0!==e)if(void 0===t||void 0!==e){if(t=e.name,e=e.id,void 0===this._eventableEvents[t])return null;var i=s.findIndex(this._eventableEvents[t],function(t){return t.id=e});0<=i&&(this._eventableEvents[t]=this._eventableEvents[t].splice(i,1))}else this._eventableEvents[t]=[];else this._eventableEvents=[]},e.clearEvents=function(){this.clearEventableEvents()},e.clearEventableEvents=function(){this._eventableEvents={}},t}),define("CatLab/Webremote/Models/User",["jquery","CatLab/Webremote/Config"],function(t,e){return function(t){this.accessToken=t,this.name=null,this.avatar=null,this.id=null,this.image=null,this.imageCallbacks=[],this.imageLoaded=!1,this.getAccessToken=function(){return this.accessToken},this.setId=function(t){this.id=t},this.getId=function(){return this.id},this.setName=function(t){this.name=t},this.getName=function(){return this.name},this.setAvatar=function(t){this.avatar=t,this.imageLoaded=!1,this.imageCallbacks=[],this.image=null},this.loadAvatar=function(){this.image||(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=function(){this.afterImageLoad()}.bind(this),this.image.src=e.getProxiedImage(this.avatar))},this.getAvatar=function(){return this.avatar},this.getAvatarSmiley=function(t){var e=this.getAvatar();return e?(e=e.split("?")[0],e+="?shape=circle&size=64&borderWidth=4",t&&(e+="&borderColor="+t.substr(1)),e):null},this.afterImageLoad=function(){this.imageLoaded=!0;for(var t=0;t<this.imageCallbacks.length;t++)this.imageCallbacks[t](this.image);this.imageCallbacks=[]},this.getImage=function(t){this.loadAvatar(),this.imageLoaded?t(this.image):this.imageCallbacks.push(t)}}}),define("CatLab/Webremote/Tools/Cookies",[],function(){var e={setCookie:function(t,e,i){return this.setItem(t,e,i)},getCookie:function(t){return this.getItem(t)},eraseCookie:function(t){return this.removeItem(t)},getItem:function(t){if("undefined"!=typeof document)return t&&this.hasOwnProperty(t)?unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"),"$1")):null},key:function(t){if("undefined"!=typeof document)return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/,"").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[t])},setItem:function(t,e,i){var s,n;t&&"undefined"!=typeof document&&(s="",i&&((n=new Date).setTime(n.getTime()+Math.round(24*i*60*60*1e3)),s="; expires="+n.toUTCString()),document.cookie=escape(t)+"="+escape(e)+"; expires="+s+"; path=/; SameSite=Strict;",this.updateLength())},length:0,removeItem:function(t){t&&this.hasOwnProperty(t)&&"undefined"!=typeof document&&(document.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; SameSite=Strict;",this.length--)},hasOwnProperty:function(t){if("undefined"!=typeof document)return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)},updateLength:function(){var t;"undefined"!=typeof document&&document.cookie&&(t=document.cookie.match(/\=/g),e.length=t?t.length:0)}};return e.updateLength(),e}),define("CatLab/Webremote/Tools/Storage",["CatLab/Webremote/Tools/Cookies"],function(t){var e={clean:function(){if(this.isSupported())for(var t=Object.keys(window.localStorage),e=0;e<t.length;e++)this.get(t)},get:function(t,e){if(void 0===e&&(e=function(){}),this.isSupported())try{var i,s=window.localStorage.getItem(t);s?void 0!==(s=JSON.parse(s)).expires?(i=Date.now(),s.expires<i?(this.delete(t),e(null)):e(s.content)):e(s):e(null)}catch(t){e(null),console.log(t)}else e(null)},add:function(e,i,s,n){var o=this;s=s||function(){},this.isSupported()?this.get(e,function(t){(t=null!=t&&""!==t?t:[]).push(i),o.set(e,t,s,n)}):s(null)},set:function(t,e,i,s){if(void 0===i&&(i=function(){}),this.isSupported()){void 0===s&&(s=31536e6);try{var n=Date.now();n+=s,window.localStorage.setItem(t,JSON.stringify({expires:n,content:e}))}catch(t){console.log(t)}i()}else i(null)},delete:function(t){this.isSupported()&&window.localStorage.removeItem(t)},remove:function(s,n){var o;this.isSupported()&&(o=this).get(s,function(t){null!=t&&""!=t||(t=[]);for(var e=JSON.stringify(n),i=0;i<t.length;i++)if(e===JSON.stringify(t[i]))return t.splice(i,1),void o.set(s,t)})},isSupported:function(){if("undefined"==typeof window)return!1;try{if(void 0===window.localStorage)return!1}catch(t){return console.log(t),!1}return!0}};try{e.clean()}catch(t){console.error(t)}return e}),define("CatLab/Webremote/Collections/AuthenticatedUsers",["CatLab/Webremote/Models/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Eventable"],function(s,n,t){function e(){this.initializeEventable()}var o,r,a=[],t=e.prototype=new t;return t.initialize=function(t,e){o=e,r=t;var s=this;n.get("users",function(i){null!==i&&n.get("currentuser",function(e){for(var t=0;t<i.length;t++)s.addFromAccessToken(i[t].access_token,function(t){t&&e&&t.getAccessToken()===e&&void 0!==r.setUser&&r.setUser(t)})})})},t.addFromAccessToken=function(e,i){i=i||function(){};var s=this;o.profile(e,function(t){t?(t=s.add(e,t.user),i(t)):n.remove("users",{access_token:e})})},t.add=function(t,e){var i=new s(t);return i.setId(e.id),i.setName(e.username),i.setAvatar(e.avatar),(t=>{for(var e=0;e<a.length;e++)if(a[e].getId()==t.getId())return;return a.push(t),1})(i)||n.remove("users",{access_token:t}),this.trigger("update"),i},t.remove=function(t){for(var e=0;e<a.length;e++)if(a[e].getId()==t.getId())return n.remove("users",{access_token:a[e].getAccessToken()}),a.splice(e,1),void this.trigger("update")},t.getFromId=function(t){for(var e=0;e<a.length;e++)if(a[e].getId()==t)return a[e];return null},t.getAll=function(){return a},new e}),define("CatLab/Webremote/Controllers/OAuth2",["jquery","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Config"],function($,Tools,Deferred,Eventable,Users,Storage,Config){var url,client_id,authorization,profile_url,avatar_url,redirect_url,callbacks=[],initialized=!1,afterInit=[],events=[],etPhoneHome=null;function OAuth2(){this.initializeEventable()}var p=OAuth2.prototype=new Eventable;return p.initialize=function(t){url=(t=t||{}).authorization,client_id=t.client_id||"none",authorization=t.authorization||"default",profile_url=t.profile||"",avatar_url=t.profile+"/avatar",void 0===t.redirect_uri||Config._options.oauth.redirectUrl||(Config._options.oauth.redirectUrl=t.redirect_uri),initialized=!0;var e=this;if("undefined"!=typeof window){var i,t=function(t){e.onMessage(t)};if(window.addEventListener){for(;i=events.pop();)removeEventListener("message",i);addEventListener("message",t,!1)}else{for(;i=events.pop();)detachEvent("onmessage",i);attachEvent("onmessage",t)}events.push(t)}},p.setRedirectUrl=function(t,e){this.redirectHost=t,this.redirectUrl=t+e},p.getAuthorizeURL=function(){var t="",t=(Config.all().oauth&&Config.all().oauth.redirectUrl&&(t=Config.all().oauth.redirectUrl),url+"?client_id="+encodeURIComponent(client_id)+"&authorization="+encodeURIComponent(authorization)+"&response_type=token&redirect_uri="+encodeURIComponent(t)+"&reset=1&state=login");return void 0!==this.redirectUrl?this.redirectUrl+"?url="+encodeURIComponent(t):t},p.onMessage=function(t){if("I must've called a thousand times"!==t.data){var e;if("string"==typeof t.data&&t.data.match(/^oauth::/))try{e=JSON.parse(t.data.substring(7))}catch(t){return}else if("string"==typeof t.data)try{e=JSON.parse(t.data)}catch(t){return}else e=t.data;void 0!==e.access_token&&this.addAccessToken(e.access_token)}},p.addAccessToken=function(s){var t=function(t){var e,i=Users.add(s,t.user);for(Storage.add("users",{access_token:s}),Tools.closePopup();e=callbacks.shift();)e(i);this.trigger("update")}.bind(this);this.call(profile_url,s,t)},p.call=function(url,accessToken,callback){var parsedurl=url+"?access_token="+accessToken,xmlhttp;"undefined"!=typeof window&&(xmlhttp=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),xmlhttp.onreadystatechange=function(){4==xmlhttp.readyState&&200!=xmlhttp.status&&callback(null),4==xmlhttp.readyState&&200==xmlhttp.status&&callback(eval("("+xmlhttp.responseText+")"))},xmlhttp.open("GET",parsedurl,!0),xmlhttp.send())},p.profile=function(t,e){this.call(profile_url,t,e)},p.changeAvatar=function(e,t){var i;if(e.getAccessToken())return(i=new FormData).append("avatar",t.files[0]),$.ajax({type:"POST",url:avatar_url,data:i,contentType:!1,processData:!1,headers:{Authorization:"Bearer "+e.getAccessToken()},success:function(t){e.setAvatar(t.url)}})},p.link=function(e){var i=new Deferred,t={},t=("object"==typeof(e=void 0===e?{}:e)&&(e=(t=e).callback||function(){}),t.fullscreen||!1),s=(etPhoneHome&&clearInterval(etPhoneHome),this.getAuthorizeURL()),n=Tools.oauth2Popup(s,t);return n&&(etPhoneHome=setInterval(function(){n&&n.postMessage?n.postMessage("Hello from the other side","*"):clearInterval(etPhoneHome)}.bind(this),1e3)),callbacks.push(function(t){e(t),i.resolve(t)}),i.promise()},p.onInit=function(t){afterInit.push(t)},p.onAdds=function(){for(var t=0;t<afterInit.length;t++)afterInit[t]()},p.getParamsFromHash=function(t){if("undefined"!=typeof window)return t=(t=t||window.location.hash).slice(1),(t=decodeURIComponent(t)).split("&").reduce(function(t,e){return t[(e=e.split("="))[0]]=e[1],t},{})},p.finish=function(){var t='oauth::{"catlabremote":1,"event":"user:authenticated","access_token":"'+this.getParamsFromHash().access_token+'"}';setTimeout(function(){window.opener&&window.opener.postMessage(t,"*"),window.parent&&window.parent.postMessage(t,"*"),void 0!==window.dialogArguments&&window.dialogArguments.opener&&window.dialogArguments.opener.postMessage(t,"*"),setTimeout(function(){etPhoneHome&&clearInterval(etPhoneHome),window.close()},1)},1)},new OAuth2}),define("CatLab/Webremote/Tools/Colorwheel",[],function(){var t={index:0,colors:[{color:"#d84a38",name:"red"},{color:"#4d90fe",name:"blue"},{color:"#35aa47",name:"green"},{color:"#ffb848",name:"yellow"},{color:"#852b99",name:"purple"},{color:"#555555",name:"brown"},{color:"#F87217",name:"orange"},{color:"#FBBBB9",name:"pink"}],initialize:function(){this.index=Math.floor(Math.random()*this.colors.length)},next:function(){var t=this.colors[this.index%this.colors.length];return this.index++,t}};return t.initialize(),t}),define("CatLab/Webremote/Collections/Users",["CatLab/Webremote/Tools/Colorwheel"],function(i){return function(){this.users=[],this.userMap={},this.add=function(t){var e;t.isColorSet()||(e=i.next(),t.setColor(e.color,e.name)),t.hasPlayerId()||t.setPlayerId(this.count()+1),this.users.push(t),this.userMap[t.getId()]=t},this.clear=function(){this.users=[],this.userMap={}},this.remove=function(t){this.users.splice(users.indexOf(t),1),void 0!==this.users[t.getId()]&&delete this.users[t.getId()]},this.getFromId=function(t){return void 0!==this.userMap[t]?this.userMap[t]:null},this.getAll=function(){return this.users},this.count=function(){return this.users.length},this.each=function(t){for(var e=0;e<this.users.length;e++)t(this.users[e])},this.not=function(i){var s=[];return this.each(function(t){for(var e=0;e<i.length;e++)if(i[e].getId()===t.getId())return void s.push(i[e])}),s}}}),define("CatLab/Webremote/Collections/Groups",["CatLab/Webremote/Tools/Colorwheel"],function(i){return function(){var e;this.groups=[],this.groupMap={},this.add=function(t){var e;t.colorSet||(e=i.next(),t.setColor(e.color,e.name)),this.groupMap[t.getId()]=t,this.groups.push(t)},this.clear=function(){this.groups=[],this.groupMap=[]},this.addUser=function(e){var i=!1;return e.groupIds.forEach(function(t){t=this.getFromId(t);t&&(i=!0,t.addUser(e),t.isShareColor())&&e.setColor(t.getColor(),t.getColorName())}.bind(this)),i},this.remove=function(t){this.groups.splice(this.groups.indexOf(t),1),delete this.groupMap[t.getId()]},this.getFromId=function(t){return void 0!==this.groupMap[t]?this.groupMap[t]:null},this.getAll=function(){return this.groups},this.each=function(t){for(e=0;e<this.groups.length;e++)t(this.groups[e])}}}),define("CatLab/Webremote/Models/Control",[],function(){return function(i,s,t){var n,o,r,a,h=0,l={},c=i,u=[];this.id=i,this.decoration="",this.label="",this.isGlobal=t,this.pushed=function(){return 0===h},this.scale=function(){return h},this.update=function(t,e){0<h&&0===t?((e=void 0===e?!0:e)&&this.trigger("click"),this.trigger("up")):0===h&&0<t&&this.trigger("down"),h=t},this.getLabel=function(t){return(t=void 0===t?!0:t)?'<span class="control-label '+o+'">'+c+"</span>":c},this.setStaticLabel=function(t,e,i,s){return c=t,o=e,r=i,a=s,this},this.getLabelImage=function(){return r},this.getLabelEmoji=function(){return a},this.getLabelData=function(){return{label:c,type:o,image:r,emoji:a}},this.setLabel=function(t,e){return this.label=t,s.emit("button:label",{id:i,label:t}),this},this.decorate=function(t){return this.decoration=t,s.emit("button:decorate",{id:i,styles:t}),this},this.click=function(t){return this.on("click",t),this},this.on=function(t,e){return this.log("Setting trigger "+t),void 0===l[t]&&(l[t]=[]),l[t].push(e),this},this.trigger=function(t){this.log("Triggering "+t);var e=[];if(void 0!==l[t])for(this.log("Found "+l[t].length+" events"),n=0;n<l[t].length;n++)e.push(l[t][n]);for(n=0;n<e.length;n++)e[n](s);return this},this.hasTriggers=function(t){return void 0===t?0<Object.keys(l).length:void 0!==l[t]&&0<l[t].length},this.off=function(t,e){if(void 0===t)l={};else if(void 0===e)l[t]=[];else if(void 0!==l[t])for(n=0;n<l[t].length;n++)l[t][n]===e&&(l[t].splice(n,1),n--);return this},this.clear=function(){return this.clearEvents(),this.decoration=null,this.label=null,this},this.clearEvents=function(){return l={},this},this.addDomElement=function(t){var e=this,i=[];return i.push(t.addEventListener("click",function(){e.trigger("click")})),u.push({element:t,listeners:i}),this},this.clearDomElements=function(){for(var t=0;t<u.length;t++)for(var e=0;e<u[t].listeners.length;e++)u[t].element.removeEventListener("click",u[t].listeners[e]);return u=[],this},this.isLocalAuthentication=function(){return!1},this.refreshTarget=function(t){this.decoration&&t.emit("button:decorate",{id:i,styles:this.decoration}),this.label&&t.emit("button:label",{id:i,label:this.label})},this.log=function(t){s.log("["+this.id+"] "+t)}}}),define("CatLab/Webremote/Synchronization/MultipleTargetControl",[],function(){function t(t,e){this.id=t,this.remoteView=e,this.label=null,this.decoration=null}var e=t.prototype;return e.pushed=function(){var e=[];return this.remoteView.targets.forEach(function(t){e=e||t.control(this.id).pushed()}.bind(this)),e},e.scale=function(){var e,i=0;this.remoteView.targets.forEach(function(t){(e=t.scale())>i&&(i=e)}.bind(this))},e.update=function(e){this.remoteView.targets.forEach(function(t){t.control(this.id).update(e)}.bind(this))},e.getLabel=function(){return this.label},e.setLabel=function(e){return this.label=e,this.remoteView.targets.forEach(function(t){t.control(this.id).setLabel(e)}.bind(this)),this},e.decorate=function(e){return this.decoration=e,this.remoteView.targets.forEach(function(t){t.control(this.id).decorate(e)}.bind(this)),this},e.click=function(t){return this.on("click",t),this},e.on=function(e,i){return this.remoteView.targets.forEach(function(t){t.control(this.id).on(e,i)}.bind(this)),this},e.off=function(t){var e=arguments;return this.remoteView.targets.forEach(function(t){t.control(this.id).off.apply(t.control(this.id),e)}.bind(this)),this},e.refreshTarget=function(e){return this.remoteView.targets.forEach(function(t){t.control(this.id).refreshTarget(e)}.bind(this)),this},t}),define("CatLab/Webremote/Synchronization/DataItem",[],function(){function i(t,e,i){this.key=t,this.shared=e,this.side=i}var t=i.prototype;return t.setValue=function(t){this.value=t},t.canWrite=function(t){return!!this.shared||this.side===t},t.serialize=function(){return{key:this.key,shared:this.shared,side:this.side,value:this.value}},i.unserialize=function(t){var e=new i(t.key,t.shared,t.side);return e.setValue(t.value),e},i}),define("CatLab/Webremote/Synchronization/SynchronizedData",["CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/DataItem"],function(t,n){function e(t,e,i){this.initializeEventable(),this.id=t,this.synchronizer=e,this.side=i,this.data={}}t=e.prototype=new t;return t.set=function(t,e,i){if(void 0===this.data[t])this.data[t]=new n(t,i,this.side);else if(!this.data[t].canWrite(this.side))throw"Trying to overwrite a non shared data attribute: "+t;this.data[t].setValue(e),this.emit(this.data[t])},t.processMessage=function(t){var e=t.key,i=t.side,s=t.value;if(void 0===this.data[e])this.data[e]=new n(e,t.shared,i);else if(!this.data[e].canWrite(i))throw"Trying to overwrite a non shared data attribute: "+e;this.data[e].setValue(s)},t.get=function(t){return void 0===this.data[t]?null:this.data[t].value},t.emit=function(t,e){void 0===e&&(e=this.synchronizer.emit);t=t.serialize();t.namespace=this.synchronizer.namespace,t.container=this.id,e("data:set",t)},t.refreshTarget=function(t){for(var e in this.data)this.data.hasOwnProperty(e)&&this.emit(this.data[e],t)},t.destroy=function(){this.synchronizer.destroy(this)},t.serialize=function(){var t,e={};for(t in this.data)this.data.hasOwnProperty(t)&&(e[t]=this.data[t].serialize());return e},t.unserialize=function(t){for(var e in this.data={},t)t.hasOwnProperty(e)&&(this.data[e]=n.unserialize(t[e]))},e}),define("CatLab/Webremote/Synchronization/DataSynchronizer",["CatLab/Webremote/Synchronization/SynchronizedData"],function(e){function t(t,e,i){this.namespace=t,this.emit=e,this.dataModels={},this.side=i}t.eventsToListenFor=["data:set"];var i=t.prototype;return i.checkNamespace=function(t){return void 0!==t.namespace&&t.namespace===this.namespace},i.processMessage=function(t,e){void 0!==e.container&&this.getFromIdentifier(e.container).processMessage(e)},i.getFromIdentifier=function(t){return void 0===this.dataModels[t]&&(this.dataModels[t]=new e(t,this,this.side)),this.dataModels[t]},i.destroy=function(t){t=t.id;void 0===this.dataModels[t]&&delete this.dataModels[t]},i.refreshTarget=function(t){for(var e in this.dataModels)this.dataModels.hasOwnProperty(e)&&this.dataModels[e].refreshTarget(t)},i.serialize=function(){var t,e={};for(t in this.dataModels)this.dataModels.hasOwnProperty(t)&&(e[t]=this.dataModels[t].serialize());return{dataModels:e}},i.unserialize=function(t){for(var e in t.dataModels)t.dataModels.hasOwnProperty(e)&&this.getFromIdentifier(e).unserialize(t.dataModels[e])},t}),define("CatLab/Webremote/Synchronization/RemoteView",["CatLab/Webremote/Models/Control","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/MultipleTargetControl","CatLab/Webremote/Synchronization/DataSynchronizer"],function(t,e,i,s){function n(t,e,i,s,n){this.initializeEventable(),this.id=e,this.viewId=t,this.targets=[],this.Webcontrol=s,this.groupId=void 0!==n?n:null,this.controls={},this.valueMap={},this.newUserStack=[],this.factory=null,this.listeners=[],i.map(function(t){this.addTarget(t)}.bind(this))}e=n.prototype=new e;return e.clearValues=function(){this.valueMap={}},e.addTarget=function(t){this.targets.push(t),this.refreshTarget(t)},e.refreshTarget=function(e){var t,i={id:this.id,viewId:this.viewId};for(this.tmpid in this.groupId&&(i.group=this.groupId),e.emit("view:set",i),this.newUserStack.map(function(t){e.emit(t.action,t.data)}.bind(this)),e.controls)e.controls.hasOwnProperty(this.tmpid)&&e.controls[this.tmpid].isGlobal&&e.controls[this.tmpid].refreshTarget(e);for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&(void 0!==this.controls[this.tmpid].refreshTarget?this.controls[this.tmpid].refreshTarget(e):console.error("Unexpected control:",this.controls[this.tmpid]));for(t in this.valueMap)this.valueMap.hasOwnProperty(t)&&e.emit("value:change",{id:t,value:this.valueMap[t]})},e.emit=function(e,i){this.targets.map(function(t){t.emit(e,i)})},e.clearControls=function(){for(var t=this.Webcontrol.getViewLabels(this.currentView),e=0;e<t.length;e++)this.control(t[e].id).setStaticLabel(t[e].label,"mobile")},e.control=function(t){return void 0===this.controls[t]&&(this.controls[t]=new i(t,this)),this.controls[t]},e.trigger=function(t,e){"value:change"==t&&this.changeValue(e.id,e.value)},e.changeValue=function(t,e){this.valueMap[t]=e,this.emit("value:change",{id:t,value:e}),this.eventableTrigger("value:change",t,e)},e.refreshControls=function(){for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl()},e.getValues=function(){return this.valueMap},e.log=function(t){this.Webcontrol.log(t)},e.domAppend=function(t,e){this._stackAndEmit("dom:append",{id:t,html:e})},e.domReplace=function(t,e){this._stackAndEmit("dom:replace",{id:t,html:e})},e.domAttribute=function(t,e,i){this._stackAndEmit("dom:attribute",{id:t,name:e,value:i})},e.vibrate=function(t){Array.isArray(t)?this.emit("device:vibrate",{pattern:t}):console.error("Vibrate pattern must be an array.")},e.listenTo=function(t,e,i){this.listeners.push(t.on(e,i))},e.stopListening=function(){this.listeners.forEach(function(t){t.unbind()})},e._stackAndEmit=function(t,e){this.newUserStack.push({action:t,data:e}),this.emit(t,e)},e.destroy=function(){this.stopListening(),this.factory.destroy(this)},n}),define("CatLab/Webremote/Synchronization/RemoteViewFactory",["CatLab/Webremote/Synchronization/RemoteView"],function(n){function t(){this.viewCounter=0,this.views={}}var e=t.prototype;return e.create=function(t,e,i,s){return this.viewCounter++,this.views[this.viewCounter]=new n(this.viewCounter,t,e,i,s),(this.views[this.viewCounter].factory=this).views[this.viewCounter]},e.createDummy=function(t,e){return this.create(t,[],e)},e.getFromId=function(t){return this.views[t]},e.destroy=function(t){t=t.id;delete this.views[t]},new t}),(()=>{var g={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function p(t){for(var e,i,s,n,o,r,a,h=(t=>{if(m[t])return m[t];for(var e,i=t,s=[],n=0;i;){if(null!==(e=g.text.exec(i)))s.push(e[0]);else if(null!==(e=g.modulo.exec(i)))s.push("%");else{if(null===(e=g.placeholder.exec(i)))throw new SyntaxError("[sprintf] unexpected placeholder");if(e[2]){n|=1;var o=[],r=e[2],a=[];if(null===(a=g.key.exec(r)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(a[1]);""!==(r=r.substring(a[0].length));){if(null===(a=g.key_access.exec(r))&&null===(a=g.index_access.exec(r)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(a[1])}e[2]=o}else n|=2;if(3===n)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");s.push({placeholder:e[0],param_no:e[1],keys:e[2],sign:e[3],pad_char:e[4],align:e[5],width:e[6],precision:e[7],type:e[8]})}i=i.substring(e[0].length)}return m[t]=s})(t),l=arguments,c=1,u=h.length,d="",f=0;f<u;f++)if("string"==typeof h[f])d+=h[f];else if("object"==typeof h[f]){if((s=h[f]).keys)for(e=l[c],i=0;i<s.keys.length;i++){if(null==e)throw new Error(p('[sprintf] Cannot access property "%s" of undefined value "%s"',s.keys[i],s.keys[i-1]));e=e[s.keys[i]]}else e=s.param_no?l[s.param_no]:l[c++];if(g.not_type.test(s.type)&&g.not_primitive.test(s.type)&&e instanceof Function&&(e=e()),g.numeric_arg.test(s.type)&&"number"!=typeof e&&isNaN(e))throw new TypeError(p("[sprintf] expecting number but found %T",e));switch(g.number.test(s.type)&&(r=0<=e),s.type){case"b":e=parseInt(e,10).toString(2);break;case"c":e=String.fromCharCode(parseInt(e,10));break;case"d":case"i":e=parseInt(e,10);break;case"j":e=JSON.stringify(e,null,s.width?parseInt(s.width):0);break;case"e":e=s.precision?parseFloat(e).toExponential(s.precision):parseFloat(e).toExponential();break;case"f":e=s.precision?parseFloat(e).toFixed(s.precision):parseFloat(e);break;case"g":e=s.precision?String(Number(e.toPrecision(s.precision))):parseFloat(e);break;case"o":e=(parseInt(e,10)>>>0).toString(8);break;case"s":e=String(e),e=s.precision?e.substring(0,s.precision):e;break;case"t":e=String(!!e),e=s.precision?e.substring(0,s.precision):e;break;case"T":e=Object.prototype.toString.call(e).slice(8,-1).toLowerCase(),e=s.precision?e.substring(0,s.precision):e;break;case"u":e=parseInt(e,10)>>>0;break;case"v":e=e.valueOf(),e=s.precision?e.substring(0,s.precision):e;break;case"x":e=(parseInt(e,10)>>>0).toString(16);break;case"X":e=(parseInt(e,10)>>>0).toString(16).toUpperCase()}g.json.test(s.type)?d+=e:(!g.number.test(s.type)||r&&!s.sign?a="":(a=r?"+":"-",e=e.toString().replace(g.sign,"")),n=s.pad_char?"0"===s.pad_char?"0":s.pad_char.charAt(1):" ",o=s.width-(a+e).length,o=s.width&&0<o?n.repeat(o):"",d+=s.align?a+e+o:"0"===n?a+o+e:o+a+e)}return d}function t(t,e){return p.apply(null,[t].concat(e||[]))}var m=Object.create(null);"undefined"!=typeof exports&&(exports.sprintf=p,exports.vsprintf=t),"undefined"!=typeof window&&(window.sprintf=p,window.vsprintf=t,"function"==typeof define)&&define.amd&&define("sprintf",[],function(){return{sprintf:p,vsprintf:t}})})(),define("CatLab/Webremote/Tools/Translator",["sprintf"],function(e){function t(){this.translator=null}var i,s,n=t.prototype;return n.setTranslator=function(t){this.translatorScope=this,"function"==typeof t?this.translator=t:("function"==typeof t.t?this.translator=t.t:(t._,this.translator=t._),this.translatorScope=t)},n.t=function(t){if(""===t)return"";if(Array.isArray(t))return this.t.apply(this,t);if(this.translator)return this.translator.apply(this.translatorScope,arguments);for(i=[],s=1;s<arguments.length;s++)i.push(arguments[s]);return e.vsprintf(t,i)},new t}),define("CatLab/Webremote/Synchronization/EventHandler",["CatLab/Webremote/Tools/Eventable"],function(t){function e(t,e){this.initializeEventable(),this.namespace=t,this.emit=e}e.eventsToListenFor=["event:trigger"];t=e.prototype=new t;return t.checkNamespace=function(t){return void 0!==t.namespace&&t.namespace===this.namespace},t.processMessage=function(t,e){if("event:trigger"===t)return this.processTriggerEvent(e)},t.processTriggerEvent=function(t){void 0!==t.event&&this.eventableTrigger(t.event,void 0===t.parameters?{}:t.parameters)},t.trigger=function(t,e){this.emit("event:trigger",{namespace:this.namespace,event:t,parameters:e})},t.refreshTarget=function(t){},t.serialize=function(){return{}},t.unserialize=function(t){},e}),define("CatLab/Webremote/Models/Users/ControlUser",["CatLab/Webremote/Models/User","CatLab/Webremote/Models/Control","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/Collections/Users"],function(e,i,s,t,n,o,r,a){function h(t,e){this.initializeEventable(),(e=void 0===e?{}:e).id=t,e.playerId=null,this.initialize(e)}t=h.prototype=new t;return t.hasPlayerId=function(){return 0<this.playerId},t.setPlayerId=function(t){return this.playerId=t,this},t.control=function(t,e){return void 0===e&&(e=!1),void 0===this.controls[t]&&(this.controls[t]=new i(t,this,e)),this.controls[t]},t.getAvailableControls=function(){return["a","b","x","y","up","down","right","left","start","back"]},t.hasControl=function(t){return!0},t.setWebcontrol=function(t){this.Webcontrol=t},t.initialize=function(t){this.id=t.id,t.playerId&&(this.playerId=t.playerId),this.groups=[],this.currentView=null,this.color="orange",this.colorName="orange",this.colorSet=!1,this.tmpid=null,this.active=!1,this.smiley=null,this.email=null,this.nickname=null,this.userdata=t,this.profiledata={},this.access_token=null,this.user=null,this.master=!1,this.authenticated=!1,void 0!==t&&void 0!==t.groups?this.groupIds=t.groups:this.groupIds=[],this.controls={},this.dataSynchronizer=new o("user",this.emit.bind(this),"master"),this.data=this.dataSynchronizer.getFromIdentifier("user"),this.events=new r("user",this.emit.bind(this)),this.settings={}},t.setSettings=function(t){return this.settings=t,this},t.trigger=function(e,i){0<=o.eventsToListenFor.indexOf(e)?(this.dataSynchronizer.checkNamespace(i)&&this.dataSynchronizer.processMessage(e,i),this.getGroups().forEach(function(t){t.dataSynchronizer.checkNamespace(i)&&t.dataSynchronizer.processMessage(e,i)}.bind(this))):0<=r.eventsToListenFor.indexOf(e)?(this.events.checkNamespace(i)&&this.events.processMessage(e,i),this.getGroups().forEach(function(t){t.events.checkNamespace(i)&&t.events.processMessage(e,i)}.bind(this))):"button:down"===e?this.control(i.id).update(1):"button:up"===e?this.control(i.id).update(0,i.click):"user:login"===e?this.login(i):"user:logout"===e?this.logout(i):"user:smiley"===e?this.setSmiley(i.smiley):"sync:audio"===e&&this.eventableTrigger("sync:audio",i)},t.setSmiley=function(e){this.smiley=e;var i=null;this.getGroups().forEach(function(t){i=!0,t.setSmiley(e,this)}.bind(this)),i||this.Webcontrol.smileys.reserve(e,this.getIdentifier())?this.emit("user:smiley",{smiley:e}):this.emit("dom:alert",{message:n.t("Smiley is already taken. Please select a different smiley.")})},t.setNickname=function(t){return this.nickname=t,this},t.getNickname=function(){return this.nickname||(this.getData().username?this.getData().username:this.playerId?"Player "+this.playerId:"Player "+this.id)},t.clearSmiley=function(){this.smiley=null,this.getGroups().forEach(function(t){t.clearSmiley(this)}.bind(this)),this.emit("user:smiley",{smiley:null})},t.getSmiley=function(){return this.smiley},t.getSmileyImage=function(){return this.Webcontrol.smileys.getImage(this.getSmiley())},t.getSmileyHtml=function(){return this.Webcontrol.smileys.getHtml(this.getSmiley())},t.getSmileyUrl=function(){return this.Webcontrol.smileys.getUrl(this.getSmiley())},t.login=function(t){},t.logout=function(t){},t.clearControls=function(){for(this.tmpid in this.setStaticLabels(),null!==this.currentView&&this.currentView.clearControls(),this.controls)!this.controls.hasOwnProperty(this.tmpid)||this.controls[this.tmpid].isGlobal||this.controls[this.tmpid].clear()},t.setStaticLabels=function(){},t.clearEvents=function(){this.clearControls(),this.clearEventableEvents()},t.emit=function(t,e,i){return this.Webcontrol.provider.toPlayer(this,t,e,i),!0},t.getId=function(){return this.id},t.getName=function(){return"User "+this.getId()},t.getType=function(){return"mobile"},t.getEntityType=function(){return"user"},t.getIcon=function(){return"fa fa-mobile-phone"},t.loginFromAuthUser=function(t,e){t={access_token:t.getAccessToken()};this.login(t,e)},t.login=function(e,i){var s=this;this.Webcontrol.getOAuthClient(function(t){t&&(this.setAccessToken(e.access_token),t.profile(s.access_token,function(t){s.authenticated=!0,this.setProfiledata(t.user),void 0!==i&&i()}.bind(this)))}.bind(this))},t.setAccessToken=function(t){this.access_token=t},t.getAccessToken=function(){return this.access_token},t.setProfiledata=function(t){t=void 0!==(this.profiledata=t).accessToken?t.accessToken:null,t=new e(t);void 0!==this.profiledata.id&&t.setId(this.profiledata.id),void 0!==this.profiledata.username&&t.setName(this.profiledata.username),void 0!==this.profiledata.avatar&&t.setAvatar(this.profiledata.avatar),this.setUser(t),this.eventableTrigger("login",this)},t.isAuthenticated=function(){return this.authenticated},t.getData=function(){return this.profiledata},t.logout=function(t){this.profiledata=null,this.access_token=null,this.authenticated=!1},t.setColor=function(t,e){this.colorSet=!0,this.color=t,this.colorName=e,this.emit("color:set",{color:t,name:e})},t.isColorSet=function(){return this.colorSet},t.getColor=function(){return this.color},t.getColorName=function(){return this.colorName},t.isActive=function(){return this.active},t.toggleActive=function(){this.setActive(!this.active),this.setJoinLabel()},t.setJoinLabel=function(){!0===this.active?this.control("a").setLabel("LEAVE"):this.control("a").setLabel("JOIN")},t.setActive=function(t,e){this.active=t,this.eventableTrigger("active:change",t),this.active&&this.eventableTrigger("active:activate"),void 0!==e&&e&&this.setJoinLabel()},t.setView=function(t){return this.clearView(),this.currentView=s.create(t,[this],this.Webcontrol),this.currentView},t.clearView=function(t){var e;this.currentView&&(e=this.currentView,this.currentView=null,this.clearControls(),void 0!==t?setTimeout(function(){e.destroy()},t):e.destroy())},t.refreshView=function(){this.currentView&&this.currentView.refreshTarget(this)},t.getValues=function(){return this.currentView?this.currentView.getValues():null},t.clearValues=function(){this.currentView&&this.currentView.clearValues()},t.setUser=function(t){return this.usermodel=t,this},t.hasUser=function(){return void 0!==this.usermodel&&this.usermodel},t.getUser=function(){return this.usermodel},t.isLocalAuthentication=function(){return!0},t.log=function(t){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+t)},t.getGroups=function(){return this.groups},t.hasDisplay=function(){return!0},t.hasKeyboardInput=function(){return!0},t.hasTouchInput=function(){return!0},t.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},t.represents=function(t){if(void 0===t.id||void 0===t.type)throw"Attribute is not an identifier.";var e=this.getIdentifier();return e.type===t.type&&e.id===t.id},t.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"y",left:"left",right:"right"}},t.isMainGroup=function(){if(0===this.groups.length)return!0;for(var t=0;t<this.groups.length;t++)if(this.groups[t].isMainGroup())return!0;return!1},t.isMaster=function(){return this.master},t.setMaster=function(t){var e=this.master!==(t=!!(t=void 0===t?!0:t));return this.master=t,e&&this.eventableTrigger("master:change"),this},t.resetViews=function(t){this.emit("view:reset",{},t=void 0===t?function(){}:t)},t.replaceViews=function(t,e){this.resetViews(function(){this.loadViews(t,e)}.bind(this))},t.loadViews=function(t,e){void 0===e&&(e=function(){}),this.log("Loading views for group "+t),this.emit("view:load",{url:t},e)},t.getConnectToken=function(){return this.Webcontrol.getConnectToken()},t.getConnectTokenForDisplay=function(){return this.Webcontrol.getConnectTokenForDisplay()},t.serialize=function(){return{id:this.getId(),playerId:this.playerId,userdata:this.userdata,profiledata:this.profiledata,email:this.email,nickname:this.nickname,access_token:this.access_token,color:this.color,colorName:this.colorName,smiley:this.smiley,data:this.dataSynchronizer.serialize(),events:this.events.serialize()}},t.unserialize=function(t){void 0!==t.profiledata&&this.setProfiledata(t.profiledata),void 0!==t.playerId&&(this.playerId=t.playerId),void 0!==t.access_token&&this.setAccessToken(t.access_token),void 0!==t.color&&(this.color=t.color),void 0!==t.colorName&&(this.colorName=t.colorName),void 0!==t.nickname&&(this.nickname=t.nickname),void 0!==t.email&&(this.email=t.email),void 0!==t.smiley&&(this.smiley=t.smiley),void 0!==t.data&&this.dataSynchronizer.unserialize(t.data),void 0!==t.events&&this.events.unserialize(t.events)},h}),define("CatLab/Webremote/Models/GroupControl",[],function(){return function(t,s,e){var n,i,o,r,a,h,l=t,c={};this.label=null,this.decoration="",this.group=s,this.isGlobal=e,this.pushed=function(){for(o=s.getUsers(),n=0;n<o.length;n++)if(o[n].control(l,this.isGlobal).pushed())return!0;return!1},this.scale=function(){for(o=s.getUsers(),n=r=0;n<o.length;n++)(a=o[n].control(l,this.isGlobal)).value>r&&(r=a.value);return r},this.getLabel=function(t){return o=s.getUsers(),(n=0)<o.length?(a=o[n].control(l,this.isGlobal)).getLabel(t):null},this.getLabelImage=function(){return o=s.getUsers(),(n=0)<o.length?(a=o[n].control(l,this.isGlobal)).getLabelImage():null},this.setStaticLabel=function(t,e,i){for(o=s.getUsers(),n=0;n<o.length;n++)o[n].control(l).setStaticLabel(t,e,i);return null},this.setLabel=function(t,e){return this.label=t,s.emit("button:label",{id:l,label:t}),this},this.decorate=function(t){return this.decoration=t,s.emit("button:decorate",{id:l,styles:t}),this},this.click=function(t){return this.on("click",t),this},this.on=function(t,e){for(void 0===c[t]&&(c[t]=[]),c[t].push(e),this.log("Setting group trigger "+t),o=s.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).on(t,e);return this},this.hasTriggers=function(t){for(o=s.getUsers(),n=0;n<o.length;n++)if(o[n].control(l,this.isGlobal).hasTriggers(t))return!0;return!1},this.off=function(t){for(delete c[t],o=s.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).off(t);return this},this.clearEvents=function(){for(c={},o=s.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).clearEvents();return this},this.clear=function(){for(c={},this.decoration=null,this.label=null,o=s.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).clear();return this},this.isLocalAuthentication=function(){return!1},this.refreshControl=function(){for(o=s.getUsers(),n=0;n<o.length;n++){for(h in o[n].control(l,this.isGlobal).clearEvents(),c)if(c.hasOwnProperty(h))for(i=0;i<c[h].length;i++)o[n].control(l,this.isGlobal).on(h,c[h][i]);this.label&&o[n].control(l,this.isGlobal).setLabel(this.label)}return this},this.refreshTarget=function(t){this.decoration&&t.emit("button:decorate",{id:l,styles:this.decoration}),this.label&&t.emit("button:label",{id:l,label:this.label})},this.log=function(t){s.log("["+l+"] "+t)}}}),define("CatLab/Webremote/Models/ControlGroup",["CatLab/Webremote/Config","CatLab/Webremote/Models/User","CatLab/Webremote/Models/Control","CatLab/Webremote/Models/GroupControl","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/Tools/Tools"],function(t,e,i,s,n,o,r,a,h,l){function c(t,e){this.initializeEventable(),this.id=t,this.initialize(e)}r=c.prototype=new r;return r.setWebcontrol=function(t){this.Webcontrol=t},r.initialize=function(t){this.token=t.token,this.connectURL=t.connectURL,this.currentView=null,this.color="orange",this.colorName="orange",this.colorSet=!1,this.shareColor=!1,this.tmpid=null,this.active=!1,this.smiley=null,this.email=null,this.userdata=t,this.profiledata={},this.access_token=null,this.master=!1,this.users=[],this.controls=[],this.dataSynchronizer=new a("group",this.emit.bind(this),"master"),this.data=this.dataSynchronizer.getFromIdentifier("group:"+this.getId()),this.events=new h("group",this.emit.bind(this)),this.options={}},r.setOptions=function(t){return this.options=t,this},r.getOption=function(t){return void 0!==this.options[t]?this.options[t]:null},r.hasControl=function(t){return!0},r.setAccessToken=function(t){this.access_token=t},r.setProfiledata=function(t){this.profiledata=t},r.clearControls=function(){for(this.tmpid in null!=this.currentView&&this.currentView.clearControls(),this.controls)!this.controls.hasOwnProperty(this.tmpid)||this.controls[this.tmpid].isGlobal||this.controls[this.tmpid].clear()},r.clearEvents=function(){this.clearControls(),this.clearEventableEvents()},r.isMainGroup=function(){return this.Webcontrol.getConnectToken()===this.getConnectToken()},r.emit=function(t,e,i){return this.Webcontrol.provider.toGroup(this,t,e,i),!0},r.getId=function(){return this.id},r.getName=function(){return"Group "+this.getId()},r.setNickname=function(t){return this.nickname=t,this},r.getNickname=function(){return this.nickname||(this.getData().username?this.getData().username:"Group "+this.getId())},r.getType=function(){return"mobile"},r.getEntityType=function(){return"group"},r.getIcon=function(){return"fa fa-mobile-phone"},r.getData=function(){return this.profiledata},r.setColor=function(t,e,i){void 0===i&&(i=this.shareColor),this.colorSet=!0,this.color=t,this.colorName=e,this.shareColor=i,this.emit("color:set",{color:t,name:e,shareColor:i})},r.getColor=function(){return this.color},r.setShareColor=function(t){this.shareColor=t},r.isShareColor=function(){return this.shareColor},r.getColorName=function(){return this.colorName},r.setView=function(t){return this.clearView(),this.currentView=o.create(t,[this],this.Webcontrol,this.getId()),this.currentView},r.clearView=function(e){var t;this.currentView&&(t=this.currentView,this.currentView=null,this.clearControls(),void 0!==e?setTimeout(function(){t.destroy()},e):t.destroy(),this.users.forEach(function(t){t.clearView(e)}))},r.resetViews=function(t){this.emit("view:reset",{},t=void 0===t?function(){}:t)},r.replaceViews=function(t,e){this.resetViews(function(){this.loadViews(t,e)}.bind(this))},r.loadViews=function(t,e){void 0===e&&(e=function(){}),this.log("Loading views for group "+t),this.emit("view:load",{url:t},e)},r.isAuthenticated=function(){return!1},r.isLocalAuthentication=function(){return!0},r.log=function(t){this.Webcontrol.log("[g:"+this.getId()+"] "+t)},r.getConnectToken=function(){return this.Webcontrol.provider.getConnectToken(this.token)},r.getConnectTokenForDisplay=function(){return l.getConnectTokenForDisplay(this.getConnectToken())},r.getConnectURL=function(){return this.Webcontrol.provider.getConnectURL(this.connectURL)},r.addUser=function(e){for(this.tmpid in l.findIndex(this.users,function(t){return t.id===e.id})<0&&this.users.push(e),l.findIndex(e.groups,function(t){return t.id===this.id})<0&&e.groups.push(this),this.currentView&&(this.currentView.refreshTarget(e),e.currentView=this.currentView),this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl();this.events.refreshTarget(e.emit.bind(e)),this.dataSynchronizer.refreshTarget(e.emit.bind(e)),this.smiley&&(e.emit("user:smiley",{smiley:this.smiley}),e.smiley=this.smiley),this.trigger("user:join",e)},r.removeUser=function(e){var t=l.findIndex(this.users,function(t){return t.id===e.id});0<=t&&this.users.splice(t,1)},r.getUsers=function(){return this.users},r.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},r.represents=function(t){if(void 0===t.id||void 0===t.type)throw"Attribute is not an identifier.";var e=this.getIdentifier();return e.type==t.type&&e.id==t.id},r.getValues=function(){return this.currentView?this.currentView.getValues():null},r.clearValues=function(){this.currentView&&this.currentView.clearValues()},r.control=function(t,e){return void 0===e&&(e=!1),void 0===this.controls[t]&&(this.controls[t]=new s(t,this,e)),this.controls[t]},r.isMaster=function(){return this.master},r.setMaster=function(t){return this.master=t=void 0===t?!0:t,this},r.hasDisplay=function(){return!0},r.hasKeyboardInput=function(){return!0},r.hasTouchInput=function(){return!0},r.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"y",left:"left",right:"right"}},r.setOAuthSettings=function(t){this.emit("oauth:set",t)},r.setSmiley=function(t,e){this.Webcontrol.smileys.reserve(t,this.getIdentifier())?(this.emit("user:smiley",{smiley:t}),this.smiley=t):e.emit("dom:alert",{message:n.t("Smiley is already taken. Please select a different smiley.")})},r.clearSmiley=function(t){this.Webcontrol.smileys.unreserve(this.getIdentifier()),this.emit("user:smiley",{smiley:null}),this.smiley=null},r.getSmiley=function(){return this.smiley},r.getSmileyImage=function(){return this.Webcontrol.smileys.getImage(this.getSmiley())},r.getSmileyHtml=function(){return this.Webcontrol.smileys.getHtml(this.getSmiley())},r.getSmileyUrl=function(){return this.Webcontrol.smileys.getUrl(this.getSmiley())},r.setMaxUsers=function(t){this.emit("config:set",{maxUsers:t})},r.isActive=function(){return this.active},r.toggleActive=function(){this.active=!this.active,this.setJoinLabel()},r.setJoinLabel=function(){!0===this.active?this.control("a").setLabel("LEAVE"):this.control("a").setLabel("JOIN")},r.setActive=function(t,e){this.active=t,this.eventableTrigger("active:change",t),this.active&&this.eventableTrigger("active:activate")},r.serialize=function(){return{id:this.getId(),token:this.token,userdata:this.userdata,nickname:this.nickname,profiledata:this.profiledata,email:this.email,access_token:this.access_token,shareColor:this.shareColor,color:this.color,colorName:this.colorName,smiley:this.smiley,data:this.dataSynchronizer.serialize(),events:this.events.serialize()}},r.unserialize=function(t){void 0!==t.profiledata&&this.setProfiledata(t.profiledata),void 0!==t.access_token&&this.setAccessToken(t.access_token),void 0!==t.token&&(this.token=t.token),void 0!==t.shareColor&&(this.shareColor=t.shareColor),void 0!==t.color&&(this.color=t.color),void 0!==t.colorName&&(this.colorName=t.colorName),void 0!==t.nickname&&(this.nickname=t.nickname),void 0!==t.email&&(this.email=t.email),void 0!==t.smiley&&(this.smiley=t.smiley,this.emit("user:smiley",{smiley:this.smiley})),void 0!==t.data&&this.dataSynchronizer.unserialize(t.data),void 0!==t.events&&this.events.unserialize(t.events)},c}),define("CatLab/Webremote/Tools/Preloader",["../Config","CatLab/Webremote/Tools/Deferred"],function(e,o){function i(t){this.provider=t,this.provider.on("file:preload",function(t){t&&t.url&&this.preloadClientFile(t.url)}.bind(this)),this.urlMap={}}var t=i.prototype;return t.preload=function(e){if(Array.isArray(e)){for(var t=new o,i=[],s=0;s<e.length;s++)i.push(this.preload(e[s]));return o.when.apply(o,i).then(function(){t.resolve(Array.prototype.slice.call(arguments))}),t.promise()}var n=new o;return this.urlMap[e]=e,this.provider.proxyFile(e).then(function(t){this.urlMap[e]=t.url,this.provider.emit("file:preload",{url:t.url}),n.resolve(t)}.bind(this)),n.promise()},t.sendPreloadFileCommandToPlayer=function(t){for(var e in this.urlMap)this.urlMap.hasOwnProperty(e)&&t.emit("file:preload",{url:this.urlMap[e]})},t.getPreloadedUrl=function(t){return this.urlMap[t]},t.preloadClientFile=function(t){void 0===this.urlMap[t]&&(t.toLowerCase().indexOf("http")<0&&(t=e.getProtocol()+":"+t),this.urlMap[t]=document.createElement("img"),this.urlMap[t].src=t)},t.serialize=function(){return{urlMap:this.urlMap}},i.unserialize=function(t,e){t=new i(t);return void 0!==e&&void 0!==e.urlMap&&(t.urlMap=e.urlMap),t},i}),define("CatLab/Webremote/Models/State",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Preloader"],function(i,s){function t(t){this.Webcontrol=t}var e=t.prototype;return e.reconnect=function(t,e){void 0!==t.provider&&this.Webcontrol.provider.restoreProviderSettings(t.provider),this.Webcontrol.disconnect(),setTimeout(function(){this.Webcontrol.initialize(i.getAll()).then(function(){this.Webcontrol._reconnect(t.token,t.accessToken,function(){this._setCollectionDetails(t.groups,this.Webcontrol._grouplibrary),this._setCollectionDetails(t.users,this.Webcontrol._userlibrary),this.Webcontrol.preloader=s.unserialize(this.Webcontrol.provider,t.preloader),e()}.bind(this))}.bind(this))}.bind(this),1)},e._setCollectionDetails=function(t,e){var i,s;if(void 0!==t)for(i=0;i<t.length;i++)(s=e.getFromId(t[i].id))?s.unserialize(t[i]):(console.log("Trying to set data for non existing user/group."),console.log(t[i]))},e.getData=function(){var e=[],i=(this.Webcontrol._grouplibrary.each(function(t){e.push(t.serialize())}.bind(this)),[]),t=(this.Webcontrol._userlibrary.each(function(t){i.push(t.serialize())}),{users:i,groups:e,token:this.Webcontrol._gamedata.token,accessToken:this.Webcontrol._gamedata.accessToken,preloader:this.Webcontrol.preloader.serialize()});return t.provider=this.Webcontrol.provider.serializeProviderSettings(),t},e.serialize=function(){var t=this.getData();return JSON.stringify(t)},e.unserialize=function(t){t=JSON.parse(t);this.reconnect(t)},t}),define("CatLab/Webremote/Messages/MessageBus",[],function(){function t(){this.controllerListeners=[],this.viewListeners=[]}var e=t.prototype;return e.toController=function(t,e){this.handleControllerMessage(t,e)},e.handleControllerMessage=function(t,e){for(var i=0;i<this.controllerListeners.length;i++)this.controllerListeners[i].handleIncomingMessage(t,e)},e.toView=function(t,e,i){this.handleViewMessage(t,e,i)},e.handleViewMessage=function(t,e,i){if(void 0===i)for(var s=0;s<this.viewListeners.length;s++)this.viewListeners[s].handleIncomingMessage(t,e);else this.viewListeners[i].handleIncomingMessage(t,e)},e.addControllerListener=function(t){if(void 0===t.handleIncomingMessage)throw new Error("Controller listener does not have a handleIncomingMessage");this.controllerListeners.push(t)},e.removeControllerListener=function(t){t=this.controllerListeners.indexOf(t);-1!==t&&this.controllerListeners.splice(t,1)},e.addViewListener=function(t){if(void 0===t.handleIncomingMessage)throw new Error("Controller listener does not have a handleIncomingMessage");t=this.viewListeners.push(t);this.toController("subscribe",{listener:t})},e.removeViewListener=function(t){t=this.viewListeners.indexOf(t);-1!==t&&this.viewListeners.splice(t,1)},e.destroy=function(){this.controllerListeners=[],this.viewListeners=[]},t}),define("CatLab/Webremote/Messages/NavigateableProxy",[],function(){function t(t,e){this.prefix=e||"",this.controls={navigation:["left","right"],toggle:["a"],manipulation:["down","up"],back:["b","back"]},this.views=[],this.keyInputCallbacks={},this.boundCallbacks={},t.addControllerListener(this),this.messageBus=t}var e=t.prototype;return e.handleIncomingMessage=function(t,e){if(t===this.prefix+"nav:controls")return this.controls=e.controls,this.views.forEach(function(t){this.refreshView(t)}.bind(this)),!0},e.addView=function(t){this.views.push(t),this.refreshView(t)},e.refreshView=function(e){this.reattachClick(e.control(this.controls.navigation[0]),this.previous),this.reattachClick(e.control(this.controls.navigation[1]),this.next),this.reattachClick(e.control(this.controls.manipulation[0]),this.down),this.reattachClick(e.control(this.controls.manipulation[1]),this.up),this.controls.toggle.forEach(function(t){void 0===this.keyInputCallbacks[t]&&(this.keyInputCallbacks[t]=function(){this.keyInput(t)}),this.reattachClick(e.control(t),this.keyInputCallbacks[t].bind(this))}.bind(this)),this.controls.back.forEach(function(t){this.reattachClick(e.control(t),this.back)}.bind(this))},e.reattachClick=function(t,e){this.boundCallbacks[e]||(this.boundCallbacks[e]=e.bind(this)),t.off("click",this.boundCallbacks[e]),t.click(this.boundCallbacks[e])},e.keyInput=function(t){this.messageBus.toView(this.prefix+"nav:keyInput",{button:t})},e.previous=function(){this.messageBus.toView(this.prefix+"nav:previous")},e.next=function(){this.messageBus.toView(this.prefix+"nav:next")},e.up=function(){this.keyInput("up")},e.down=function(){this.keyInput("down")},e.back=function(){this.messageBus.toView(this.prefix+"nav:back")},e.destroy=function(){this.messageBus.removeControllerListener(this)},t.handleMessage=function(t,e,i,s){if(t.substring(0,(s=void 0===s?"":s).length)===s){switch(t=t.replace(s,"")){case"nav:previous":return i.previous(),!0;case"nav:next":return i.next(),!0;case"nav:keyInput":return i.keyInput(e.button),!0;case"nav:back":return i.triggerBack(),!0}return!1}},t}),define("CatLab/Webremote/Controllers/Portal",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Messages/MessageBus","CatLab/Webremote/Messages/NavigateableProxy"],function(i,t,e,n,s,o){function r(t,e){this.initializeEventable(),this.Webcontrol=t,this.options=e,this.controlDisabled=!1,this.users=[],this.ensureOption("allowChangeNickname",!0),this.ensureOption("allowNonDisplayPlayers",!0),this.ensureOption("customFunctions",{}),this.ensureOption("minPlayers",1),this.ensureOption("maxPlayers",4),this.ensureOption("activePlayersPanel",!1),this.ensureOption("customViews",!1),this.ensureOption("authentication",t.AUTH_NOT_REQUIRED),this.ensureOption("localAuthenticatable",!1),this.ensureOption("allowPlayersWithoutDisplay",!0),this.ensureOption("start",function(){alert("This is where the game would start, if one would have set a 'start' option.")}),this.Webcontrol.getMessageBus().addControllerListener(this),this.messageBus=t.getMessageBus(),this.navigatableProxy=new o(this.messageBus,"portal:"),this.useCatLabViews()&&t.loadViews(i.getSocketURL(!0)+"/webremote/views/default.xml"),this.eventListeners=[],this.initialize()}t=r.prototype=new t;return t.handleIncomingMessage=function(t,e){switch(t){case"subscribe":this.updateUsers();break;case"start":this.startGame();break;case"back":this.back()}},t.initialize=function(){var t=this.Webcontrol.on("user:join",function(t){t.isMainGroup()&&(this.userConnect(t),this.eventListeners.push(t.on("login",function(){this.updateUsers()}.bind(this))))}.bind(this));this.eventListeners.push(t),this.Webcontrol.getUsers().forEach(function(t){t.isMainGroup()&&this.userConnect(t)}.bind(this))},t.updateUsers=function(){this.updateState();let s=[];this.Webcontrol.getUsers().forEach(function(t){var e,i;t.isMainGroup()&&(i=null,(e=t.getUser())&&(i={image:e.avatar}),s.push({active:t.isActive(),color:t.getColor(),profile:i,type:t.getType()}))}),this.messageBus.toView("users:update",{users:s})},t.updateState=function(){var t={activePlayers:this.countActiveUsers(),minPlayers:this.options.minPlayers,maxPlayers:this.options.maxPlayers,connectInstructions:this.getConnectInstructions(),startAndLoginInstructions:this.getStartAndLoginInstructions(),showInactivePlayers:this.supportInactivePlayers(),qrUrl:this.getQrCodeUrl()};this.messageBus.toView("state:change",{state:t})},t.ensureOption=function(t,e){void 0===this.options[t]&&(this.options[t]=e)},t.useCatLabViews=function(){return!1===this.options.customViews},t.getToggleView=function(t){var e="",e=this.supportInactivePlayers()?"catlab-portal-toggle":"catlab-portal";return this.isMaster(t)||(e+="-nostart"),e},t.addUser=function(t){t.clearControls(),this.users.push(t),this.supportInactivePlayers()||this.forceToggleableUser(t)||this.activateUser(t),this.trigger("users:update"),this.updateUsers()},t.activateUser=function(t){t.isActive()||(t.hasDisplay()||this.options.allowPlayersWithoutDisplay?(this.trigger("user:activate",t),t.setActive(!0,this.supportInactivePlayers()),this.updateUsers()):this.deactivateUser(t))},t.deactivateUser=function(t){t.isActive()&&(this.trigger("user:deactivate",t),t.setActive(!1,this.supportInactivePlayers()),this.updateUsers())},t.toggleActive=function(t){(this.supportInactivePlayers()||this.forceToggleableUser(t))&&(t.isActive()?this.deactivateUser(t):this.activateUser(t),this.trigger("users:update"))},t.forceToggleableUser=function(t){return!t.hasDisplay()&&!!this.options.allowPlayersWithoutDisplay},t.hasUsersWithoutDisplay=function(){if(this.options.allowPlayersWithoutDisplay)for(var t=0;t<this.users.length;t++)if(!this.users[t].hasDisplay())return!0;return!1},t.countActiveUsers=function(){return this.getActiveUsers().length},t.getActiveUsers=function(){for(var t=[],e=0;e<this.users.length;e++)this.users[e].isActive()&&t.push(this.users[e]);return t},t.userConnect=function(t){this.eventListeners.push(t.on("master:change",function(){this.updateUserView(t)},this)),this.addUser(t),this.updateUserView(t),this.trigger("user:connect",t)},t.updateUserView=function(t){var e=t.setView(this.getToggleView(t));this.controlDisabled||this.enableControls(t,e),this.enableDefaultPlayerControls(t,e)},t.disableControls=function(){this.controlDisabled=!0;for(var t=0;t<this.users.length;t++)this.users[t].clearControls()},t.enableControls=function(t,e){var i;void 0!==t?(i=t.getPortalControls(),e.control(i.toggleActive).click(function(){this.toggleActive(t)}.bind(this)),e.control(i.start).click(function(){this.startGame()}.bind(this)),e.control(i.back).click(function(){this.back()}.bind(this)),this.supportsLocalAuthentication()&&e.control(i.authenticate).click(function(){t.isLocalAuthentication()||this.authenticate(t)}.bind(this)),this.navigatableProxy.addView(e)):(this.controlDisabled=!1,this.users.forEach(function(t){this.updateUserView(t)}.bind(this)))},t.enableDefaultPlayerControls=function(i,s){if(s.control("name").setLabel(i.getNickname()),s.listenTo(i,"login",function(){s.control("name").setLabel(i.getNickname())}),this.options.allowChangeNickname&&s.control("change-nickname").click(function(){this.changeNickname(i).then(function(){this.updateUserView(i)}.bind(this))}.bind(this)),this.options.customFunctions)for(var t in this.options.customFunctions)this.options.customFunctions.hasOwnProperty(t)&&function(t,e){s.control(t).click(function(){e(i).then(function(){this.updateUserView(i)}.bind(this))}.bind(this))}.bind(this)(t,this.options.customFunctions[t])},t.changeNickname=function(e){var i=new n,s=e.setView("catlab-nickname");return s.changeValue("name",e.getNickname()),s.control("a").click(function(){var t=s.getValues().name;!t||32<t.length||(e.setNickname(t),i.resolve())}),i.promise()},t.supportInactivePlayers=function(){return this.options.activePlayersPanel},t.supportsLocalAuthentication=function(){return this.options.localAuthenticatable&&this.Webcontrol.canAuthenticate()},t.isMaster=function(t){return t.isMaster()},t.getPortalLabels=function(){var n={start:[],back:[],toggleActive:[],authenticate:[]};return this.Webcontrol._userlibrary.each(function(t){var e,i=t.getPortalControls();for(e in i)if(i.hasOwnProperty(e)){var s=t.control(i[e]).getLabelData();if(!s)continue;void 0===n[e]&&(n[e]=[]),-1===n[e].findIndex(function(t){return t.label===s.label&&t.image===s.image})&&n[e].push(s)}}.bind(this)),n},t.authenticate=function(t){this.activateUser(t),this.disableControls();var e=this.Webcontrol.authenticationController(t,{messageBus:this.messageBus});this.messageBus.toView("auth:open",{}),e.controller.setNavigatableUsers([t]),e.controller.on("close",function(){this.enableControls(),this.updateUsers()}.bind(this))},t.countAuthenticated=function(t){void 0===t&&(t=!0);for(var e=0,i=0;i<this.users.length;i++)!this.users[i].isAuthenticated()||t&&!this.users[i].isActive()||e++;return e},t.checkAuthentication=function(){var t=this.countAuthenticated();switch(this.options.authentication){case this.Webcontrol.AUTH_REQUIRED_ALL:return t===this.countActiveUsers();case this.Webcontrol.AUTH_REQUIRED_ONE:return 0<t;case this.Webcontrol.AUTH_REQUIRED_ONE_INACTIVE:return 0<this.countAuthenticated(!1);case this.Webcontrol.AUTH_NOT_REQUIRED:return!0;default:throw"Authentication requirement "+this.options.authentication+" not found."}},t.startGame=function(){var t=this.countActiveUsers();if(t<this.options.minPlayers)this.messageBus.toView("alert",{message:"You need "+this.options.minPlayers+" players to start playing",localized:["You need %s players to start playing",this.options.minPlayers],id:"not-enough-players"});else if(t>this.options.maxPlayers)this.messageBus.toView("alert",{message:"Your license is limited to "+this.options.maxPlayers+" players",localized:["Your license is limited to %s players",this.options.maxPlayers],id:"exceeds-max-players"});else if(this.checkAuthentication())this.Webcontrol.setView("catlab-game-already-started",this.Webcontrol._userlibrary.not(this.getActiveUsers())),this.Webcontrol.setView("catlab-game-starting",this.getActiveUsers()),this.destroy(),this.options.start(this.getActiveUsers());else switch(this.options.authentication){case this.Webcontrol.AUTH_REQUIRED_ALL:this.messageBus.toView("alert",{message:"All active players must be authenticated.",localized:["All active players must be authenticated."],id:"not-all-authenticated"});break;case this.Webcontrol.AUTH_REQUIRED_ONE:case this.Webcontrol.AUTH_REQUIRED_ONE_INACTIVE:this.messageBus.toView("alert",{message:"At least one player must be authenticated.",localized:["At least one player must be authenticated."],id:"not-one-authenticated"})}},t.back=function(){void 0!==this.options.back&&(this.destroy(),this.options.back())},t.getConnectURL=function(){return this.Webcontrol.getConnectURL()},t.getConnectToken=function(){return this.Webcontrol.getConnectTokenForDisplay()},t.getQrCodeUrl=function(){var t=this.getConnectURL();return(t=t&&"http"!==t.substring(0,4)?"https://"+t:t)+"?t="+this.Webcontrol.getConnectToken()},t.getUsers=function(){return this.users},t.setMinPlayers=function(t){return this.options.minPlayers=t,this.trigger("options:change"),this.updateState(),this},t.setMaxPlayers=function(t){return this.options.maxPlayers=t,this.trigger("options:change"),this.updateState(),this},t.getMessageBus=function(){return this.messageBus},t.getConnectInstructions=function(){return void 0!==this.Webcontrol.provider.getConnectInstructions?this.Webcontrol.provider.getConnectInstructions():["Use your tablet or smartphone to surf to %s and enter code %s.",this.getConnectURL(),this.getConnectToken()]},t.getStartAndLoginInstructions=function(){var t;return void 0!==this.Webcontrol.provider.getStartAndLoginInstructions?this.Webcontrol.provider.getStartAndLoginInstructions():this.hasUsersWithoutDisplay()?(t=this.getPortalLabels(),this.supportsLocalAuthentication()&&(this.showInactivePlayers||this.hasUsersWithoutDisplay())?["Press %s to join, %s to login and %s to start.",t.toggleActive,t.authenticate,t.start]:this.supportsLocalAuthentication()?["Press %s to login and %s to start.",t.authenticate,t.start]:this.showInactivePlayers||this.hasUsersWithoutDisplay()?["Press %s to join and %s to start.",t.toggleActive,t.start]:["Press %s to start.",t.start]):[""]},t.destroy=function(){this.eventListeners&&this.eventListeners.forEach(function(t){t.unbind()}),this.messageBus.toView("portal:destroy"),this.messageBus.removeControllerListener(this),this.navigatableProxy.destroy()},r}),define("CatLab/Webremote/Controllers/RemoteAuthentication",["CatLab/Webremote/Controllers/OAuth2"],function(e){return function(t){t.setView("remote:authenticate"),t.on("user:join",function(t){t.on("login",function(t){e.addAccessToken(t.getAccessToken())}.bind(this))}.bind(this))}}),define("CatLab/Webremote/Controllers/Authentication",["CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/RemoteAuthentication","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Cookies","CatLab/Webremote/Messages/MessageBus","CatLab/Webremote/Messages/NavigateableProxy"],function(s,n,o,t,r,i,e,a){function h(t,e,i){this.initializeEventable(),this.messageBus=t.getMessageBus(),this.navigatableProxy=new a(this.messageBus,"auth:"),this.Webcontrol=t,this.user=e,this.user.control("x").click(function(){this.messageBus.toView("auth:request-remove-selected-profile")}.bind(this)),o.on("update",this.updateUsers,this),s.on("update",function(){this.updateUsers()},this),this.messageBus.addControllerListener(this)}var l=null,c=null,t=h.prototype=new t;return t.handleIncomingMessage=function(t,e){switch(t){case"subscribe":this.getLoginUrl().then(function(t){this.loginUrl=t,this.messageBus.toView("auth:loginurl",{url:t})}.bind(this)),this.updateUsers();break;case"auth:close":this.trigger("close");break;case"auth:select-user":this.selectUser(e.user);break;case"auth:remove-user":this.removeUser(e.user)}},t.link=function(){s.link(function(t){this.selectUser(t)}.bind(this))},t.updateUsers=function(){this.messageBus.toView("auth:users:update",{users:o.getAll().map(function(t){return{id:t.getId(),name:t.getName(),image:t.avatar}})})},t.selectUser=function(t){var e;(t=o.getFromId(t.id))&&(e=this).user.loginFromAuthUser(t,function(){i.setCookie("ctlb_ps_"+this.user.id,t.id),e.close()}.bind(this))},t.removeUser=function(t){(t=o.getFromId(t.id))&&(o.remove(t),this.updateUsers())},t.getUsers=function(){return o},t.close=function(){this.messageBus.toView("auth:close"),this.destroy()},t.getLoginUrl=function(){var e,t,i=new r;return e=this.Webcontrol,(null!==l?((t=new r).resolve(l),t):(null===c&&(c=new r,e.newGroup().then(function(t){new n(l=t),t.setOAuthSettings(e.getOAuthSettings()),c.resolve(t)})),c)).promise().then(function(t){i.resolve(t.getConnectURL()+"/"+t.getConnectToken())}),i.promise()},t.setNavigatableUsers=function(t){t.forEach(function(t){this.navigatableProxy.addView(t)}.bind(this)),this.messageBus.toView("labels:update",{labels:{selectProfile:[this.user.control("a").getLabelData()],removeProfile:[this.user.control("x").getLabelData()],close:[this.user.control("b").getLabelData()]}})},t.attemptLastLogin=function(){var t=i.getCookie("ctlb_ps_"+this.user.id);if(t){t=o.getFromId(t);if(t)return this.selectUser(t),!0}return!1},t.destroy=function(){this.messageBus.toView("auth:destroy"),this.messageBus.removeControllerListener(this),this.navigatableProxy.destroy()},h}),define("CatLab/Webremote/Tools/Images",["CatLab/Webremote/Config"],function(n){function t(t){this.images={},this.availableSizes=t=void 0===t?[512,256,128]:t}var e=t.prototype;return e.getImage=function(t,e){var i;return void 0!==e&&-1!==this.availableSizes.indexOf(e)||(e=this.availableSizes[0]),void 0===this.images[t+"_"+e]&&((i=new Image).crossOrigin="anonymous",i.src=this.getUrl(t,e),this.images[t+"_"+e]=i),this.images[t+"_"+e]},e.getUrl=function(t,e){if(this.isExternal(t))return t;void 0!==e&&-1!==this.availableSizes.indexOf(e)||(e=this.availableSizes[0]);for(var i=t.split("/"),s=0;s<i.length;s++)"$SIZE"===i[s]&&(i[s]=e);return t=i.join("/"),n.getAssetsURL()+t},e.isExternal=function(t){return 0===t.indexOf("http")},t}),define("CatLab/Webremote/Tools/Smileys",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Images"],function(i,s,e){function t(t){this.provider=t,this.smileyKeys=["1f98d","1f61c","1f3b7","1f32e","1f621","1f61b","1f98f","1f34c","1f596","1f34d","2660","1f61a","2602","2665","1f0cf","1f427","1f918","1f98b","1f9df","1f344","1f983","1f338","2618","1f36a","1f383","270c","1f913","1f40d","1f910","1f57a","1f641","1f36c","1f579","1f333","1f40b","1f617","1f42b","1f60d","1f42c","1f339","1f414","1f42d","1f349","1f92e","1f437","1f367","1f62c","1f428","1f994","1f911","1f369","1f9d0","1f378","1f9dd-2640","1f34e","2666","1f47d","1f60a","1f60f","1f43b","1f47b","1f425","1f919","1f346","1f4a8","1f43f","1f37a","1f40c","1f334","1f4a3","1f42e","1f379","1f42f","1f417","1f9c0","1f601","1f41a","1f61d","1f997","26c4","1f34b","1f430","1f47a","1f37c","1f3b1","1f95d","1f433","1f41b","1f37f","1f36d","1f60e","1f354","1f63b","1f680","1f996","1f924","1f341","1f43a","1f922","1f436","1f43c","1f332","1f31a","1f335","1f336","2623","1f31e","1f63d","1f421","1f438","1f63a","1f32d","1f986","1f388","1f41e","1f98c","1f91e","1f64a","1f638","1f3b5","1f43d","1f363","1f373","1f435","1f628","1f635","1f377","1f47e","1f984","1f3a9","1f439","1f925","1f929","1f951","1f4a9","1f921","1f92a","1f96a","1f41f","1f419","1f420","2663","1f40a","1f989","1f91f","1f63c","1f3f3-1f308","1f98a","1f431","1f920","1f41d","1f608","1f612","1f987","1f3ba","1f355","270b","1f98e","1f41c","1f917"],this.taken={},this.takenAmount=0,this.playerKnowsAboutNonUniqueSmileys={},this.images=new e,this.randomSmileys=this.smileyKeys.slice(0),s.shuffle(this.randomSmileys)}var n=t.prototype;return n.shouldHaveUniqueSmileys=function(){return this.takenAmount<this.smileyKeys.length/3},n.setTakenSmileys=function(t){this.taken=t},n.getTakenSmileys=function(t){if(!this.shouldHaveUniqueSmileys())return{};t=this.identifierToText(t);var e,i={};for(e in this.taken)this.taken.hasOwnProperty(e)&&this.taken[e]!==t&&(i[e]=this.taken[e]);return i},n.getRandom=function(t){for(var e=null;null===e&&this.randomSmileys;)if(e=this.randomSmileys.shift(),this.reserve(e,t)||(e=null),0===this.randomSmileys.length)return this.randomSmileys=this.smileyKeys.slice(0),s.shuffle(this.randomSmileys),this.randomSmileys.shift();return e},n.reserve=function(t,e){return this.isExternalSmiley(t)?(this.unreserve(e),!0):(e=this.identifierToText(e),void 0!==this.taken[t]&&this.taken[t]===e?(this.taken[t]=e,!0):!!this.isAvailable(t)&&(this.unreserve(e),this.taken[t]=e,this.takenAmount++,!0))},n.unreserve=function(t){for(var e in t=this.identifierToText(t),this.taken)this.taken.hasOwnProperty(e)&&this.taken[e]===t&&(this.taken[e]=null,delete this.taken[e],this.takenAmount--)},n.isAvailable=function(t){return!this.shouldHaveUniqueSmileys()||!!this.isExternalSmiley(t)||null==this.taken[t]},n.identifierToText=function(t){return JSON.stringify(t)},n.isExternalSmiley=function(t){return"http"===t.substring(0,4).toLowerCase()},n.getUrl=function(t){var e=this.getImageUrl(t);return e?this.isExternalSmiley(t)?t:i.getAssetsURL()+e:null},n.getImageUrl=function(t){return null===t?null:this.isExternalSmiley(t)?t:"smileys/"+t+".png"},n.getHtml=function(t){return null===t?null:'<span class="smiley" style="width: 64px; height: 64px; display: inline-block; background-image: url(\''+this.getUrl(t)+"');\"></span>"},n.getElement=function(t){var e;return null===t?null:((e=document.createElement("div")).innerHTML=this.getHtml(t),e.firstChild)},n.getImage=function(t){return null===t?null:this.images.getImage(this.getImageUrl(t))},n.refreshTakenSmileys=function(t){this.shouldHaveUniqueSmileys()?t.emit("smileys:taken",{smileys:this.getTakenSmileys(t.getIdentifier())}):this.playerKnowsAboutNonUniqueSmileys[this.getStringIdentifier(t)]},n.getStringIdentifier=function(t){return t.type+":"+t.id},t}),define("CatLab/Webremote/Tools/MessageCounter",["CatLab/Webremote/Tools/Eventable"],function(t){function e(t){this.interval=t||1e3,this.initializeEventable(),this.countIncoming=0,this.countOutgoing=0;var e,i,s=(new Date).getTime();setInterval(function(){e=(new Date).getTime(),i=e-s,s=e,this.trigger("tick",{in:this.countIncoming,out:this.countOutgoing,dt:i}),this.countIncoming=0,this.countOutgoing=0}.bind(this),this.interval)}t=e.prototype=new t;return t.incoming=function(){this.countIncoming++},t.outgoing=function(){this.countOutgoing++},e}),define("CatLab/Webremote/Views/Portal",["CatLab/Webremote/Config"],function(Q,t){return function(t){var n=t.element||document.body,e=n,i=t.countdown||5e3,s=t.done||function(){alert("Game should start now... yet it doesn't.")},o=t["min-players"]||1,r=(o<1&&(o=1),t["max-players"]||1e3);r<o&&(r=o);var a,h,l,c,u,d,f,g,p,m,b,v=!t.customViews,A=[],y=!1,w=!1,C=null,k=this;function I(n){n.setView("catlab-portal-toggle"),n.control("join-game").click(function(){(t=>{if(x(t)){t.control("join-game").setLabel("JOIN");for(var e=t,i=0;i<A.length;i++)if(A[i].getId()==e.getId())return A.splice(i,1)}else t.control("join-game").setLabel("LEAVE"),A.push(t)})(n),M(),U(),P()}),n.control("start-game").click(function(){var t;y?P():A.length<o?F(o+" players are required to start the game. Please gather more friends."):A.length>r?F("This game can have only "+r+" players."):(t=i,P(),y=!0,(f=new Date).setTime((new Date).getTime()+t),u.show(),d=setInterval(B,100))}),n.control("down").click(function(){T(n)}),n.control("right").click(function(){T(n)}),n.control("left").click(function(){_(n)}),n.control("up").click(function(){_(n)}),n.control("a").click(function(){var t,e,i,s;t=n,w&&L(t)?(e=b.find(".available-accounts").find("li.selected"))&&(e=WebcontrolOAuthClient.getFromToken(e.attr("data-accessToken")))&&(s=e.access_token,C.setUserData(s,e.user),S()):(y&&P(),w||(i=t,Webcontrol.getOAuthClient(function(e){e.onInit(function(){E(e)}),WebcontrolAccessKeyLibrary.init(function(){w=!0,C=i,m.show(),b.show();var t=$('<a href="javascript:void(0);">Link new account</a>');t.click(function(){e.getNewAccessToken(function(){E(e)})}),b.find(".link-new-account").html(t)}),E(e)})))}),n.control("b").click(function(){w&&L(n)&&(C.setUserData(!1),S())}),W(),U()}function _(t){w&&L(t)&&(t=b.find(".available-accounts").find("li.selected"),b.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(t.length&&t.prev().length?t.prev():b.find(".available-accounts").find("li").last()).addClass("selected").removeClass("unselected"))}function T(t){w&&L(t)&&(t=b.find(".available-accounts").find("li.selected"),b.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(t.length&&t.next().length?t.next():b.find(".available-accounts").find("li").first()).addClass("selected").removeClass("unselected"))}function L(t){return C&&t.getId()==C.getId()}function S(){m.hide(),b.hide(),w=!1,C=null}function E(t){b.find(".available-accounts").html("");for(var e=t.listUsers(),i=0;i<e.length;i++){var s=$("<li>"+e[i].user.username+"</li>");s.addClass("unselected"),s.attr("data-accessToken",e[i].access_token),b.find(".available-accounts").append(s)}}function U(){0<Webcontrol.getControlLabels("join-game").length?($(".buttoninstructions.join-game").show().find(".labels").html(Webcontrol.getControlLabels("join-game").join(", ")),$(".buttoninstructions.start-game").show().find(".labels").html(Webcontrol.getControlLabels("start-game").join(", "))):($(".buttoninstructions.join-game").hide(),c.hide())}function x(t){for(var e=0;e<A.length;e++)if(A[e].getId()==t.getId())return 1}function W(){var t=Webcontrol.getUsers();a.html("");for(var e=[],i=0;i<t.length;i++)x(t[i])||e.push(t[i]);for(0==e.length&&a.append('<li class="empty"><span>More players? Add devices!</span></li>'),i=0;i<e.length;i++)a.append('<li class="user '+e[i].getType()+'" style="background-color: '+e[i].getColor()+'"><i class="'+e[i].getIcon()+'"></i><span>'+e[i].getName()+"</span></li>")}function M(){h.html(""),0==A.length&&h.append('<li class="empty"><span class="buttoninstructions join-game">Press <span class="labels"></span> to join the game.</span></li>');for(var t=0;t<A.length;t++)h.append('<li class="user '+A[t].getType()+'" style="background-color: '+A[t].getColor()+'"><i class="'+A[t].getIcon()+'"></i><span>'+A[t].getName()+"</span></li>");W()}function B(){g=Math.ceil((f.getTime()-(new Date).getTime())/1e3),u.find(".counter").html(g),g<0&&(void 0!==e&&(void 0!==e.hide?e.hide():void 0!==e.style&&(e.style.display="none")),P(),s(A))}function P(){y=!1,d&&(F("Countdown stopped!"),u.hide(),clearInterval(d),d=null)}function F(t){var e=jQuery("<p></p>").html(t).appendTo(p);setTimeout(function(){e.fadeOut(1e3,function(){e.remove()})},3e3)}this.loginInformation="Login into your account and get access to more game features now!",0<n.length?n.addClass("webremote-portal"):n.className=n.className+" webremote-portal",void 0!==t.theme&&(t=Q.getSocketURL()+"/webremote/themes/"+t.theme+"/"+t.theme+".css",Webcontrol._loadCSS(t),Webcontrol._loadCSS(Q.getSocketURL()+"/webremote/themes/font-awesome/css/font-awesome.min.css")),n.innerHTML='<div class="loading"><p>Please wait, loading socket.io.</p></div>',Webcontrol.initialize(function(){n.innerHTML='<div class="loading"><p>Please wait, loading jQuery.</p></div>',n.innerHTML="";var t=n,t=(n=jQuery('<div class="webremote-portal-inner"></div>').appendTo(t),(n=jQuery(n)).html('<div class="loading"><p>Please wait, connecting to server.</p></div>'),v&&Webcontrol.loadViews(Q.getSocketURL(!0)+"/webremote/views/default.xml"),n.html("<h1>Player lobby</h1>"),m=$("<div></div>"),b=$('<div><h2>Select account</h2><div class="information"><p>'+k.loginInformation+'</p></div><ul class="available-accounts"></ul><p class="link-new-account"></p></div>'),m.addClass("accounts-overlay"),b.addClass("accounts"),m.hide(),b.hide(),n.append(m),n.append(b),jQuery('<div class="connected-users"><div class="inner"><h2>Connected devices</h2></div></div>')),e=(a=jQuery('<ul class="connected-users"></ul>').appendTo(t.find(".inner")),jQuery('<div class="active-users"><div class="inner"><h2>Active users</h2></div></div>'));h=jQuery('<ul class="active-users"></ul>').appendTo(e.find(".inner")),n.append(t),n.append(e),(t=jQuery('<div class="connection-information"><div class="inner"><h2>Instructions</h2><p>Take your smartphone, navigate to <span class="url"></span> and use token <span class="token"></span></p></div></div>')).find(".token").html(Webcontrol.getConnectToken()),t.find(".url").html(Webcontrol.getConnectURL()),l=jQuery('<p class="buttoninstructions join-game">Press <span class="labels"></span> to join the game.</p>'),c=jQuery('<p class="buttoninstructions start-game">Press <span class="labels"></span> to start the game.</p>'),p=jQuery('<div class="errors"></div>').appendTo(n),t.append(l),t.append(c),n.append(t),u=jQuery('<div class="countdown-background"></div><div class="countdown"><p>Game will start in <span class="counter">5</span></p></div>').hide().appendTo(n),Webcontrol.on("user:join",function(t){I(t)});for(var i=Webcontrol.getUsers(),s=0;s<i.length;s++)I(i[s]);Webcontrol.on("user:leave",W),W(),M(),U()})}}),define("CatLab/Webremote/ViewFactory/ViewFactory",["CatLab/Webremote/Views/Portal"],function(e){function t(){}return t.prototype.getPortal=function(t){return new e(t)},t}),define("CatLab/Webremote/Views/ConnectionTrouble",["CatLab/Webremote/Tools/Translator"],function(t){function e(){this.visible=!1,this.div=null,this.timeoutTillShow=3e3,this.showTimeout=null,this.message=null}var i=e.prototype;return i.show=function(){this.visible||(this.visible=!0,this.div)||(this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),setTimeout(function(){this.div||this.visible&&(this.showTimeout=null,this.div=document.createElement("div"),document.body.appendChild(this.div),this.div.style.position="absolute",this.div.style.right="10px",this.div.style.top="10px",this.div.style.width="350px",this.div.style.padding="10px",this.div.style.border="1px solid red",this.div.style.background="black",this.div.style.zIndex="100000",this.div.style.textAlign="center",this.div.style.color="white",this.div.style.font="Sans-serif",this.div.style.fontSize="15px",this.message?this.text(this.message):this.text(t.t("Connection lost")))}.bind(this),this.timeoutTillShow))},i.text=function(t){this.message=t,this.div&&(this.div.innerHTML="<p>"+t+"</p>")},i.hide=function(){this.visible=!1,this.div&&this.div.parentNode&&this.div.parentNode.removeChild(this.div),this.showTimeout&&clearTimeout(this.showTimeout),this.message=null,this.div=null,this.showTimeout=null},e}),define("CatLab/Webremote/Synchronization/MessageQueue",[],function(){function t(){this.queue=[]}var e=t.prototype;return e.add=function(t,e,i){this.queue.push({action:t,data:e,ack:i})},e.flush=function(){var t=this.queue;return this.queue=[],t},e.compactFlush=function(){var s,n,o,r,a=[],t=this.flush();return 0===t.length?t:(n={user:{},group:{}},o=0,r={},t.forEach(function(t){if(o++,this.canCompact(t)){var e=null;void 0!==t.data.user?e="user":void 0!==t.data.group&&(e="group"),void 0===n[e][t.action]&&(n[e][t.action]=[]);for(var i=0;i<n[e][t.action].length;i++)if(s=n[e][t.action][i],this.isSimilarMessage(s.event,t)&&(void 0===r[t.data[e]]||r[t.data[e]]<s.index))return r[t.data[e]]=s.index,s.event.data[e].push(t.data[e]),void s.event.data._d.push(this.getDifference(s.event,t));Array.isArray(t.data[e])||(t.data[e]=[t.data[e]]),t.data._d=[{}],r[t.data[e]]=o,n[e][t.action].push({event:t,index:o})}a.push(t)}.bind(this)),a)},e.moveToEnd=function(t,e){t.push(t.splice(t.indexOf(e),1)[0])},e.isSimilarMessage=function(t,e){return t.action===e.action&&this.getCompareDataString(t)===this.getCompareDataString(e)},e.getDifference=function(t,e){var i,s={};for(i in e.data)if(e.data.hasOwnProperty(i)){switch(i){case"user":case"group":case"_d":case"_i":continue}void 0!==t.data[i]&&t.data[i]===e.data[i]||(s[i]=e.data[i])}return s},e.getCompareDataString=function(t){t=Object.assign({},t.data);return delete t.user,delete t.group,delete t.viewId,delete t._d,delete t._i,JSON.stringify(t)},e.canCompact=function(t){return null==t.ack&&void 0!==t.data&&(void 0!==t.data.user||void 0!==t.data.group)},t.unpack=function(t,e){if(void 0===t[e])return[t];var i=Array.isArray(t[e])?t[e]:[t[e]],s=[];void 0!==t._d&&(s=Array.isArray(t._d)?t._d:[t._d]);for(var n=[],o=0;o<i.length;o++){(r={})[e]=i[o];var r=Object.assign({},t,r,void 0!==s[o]?s[o]:{});delete r._d,n.push(r)}return n},Object.defineProperty(e,"length",{get:function(){return this.queue.length}}),t}),define("CatLab/Webremote/Tools/Proxy",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred"],function(i,s){function t(){}function n(t,e,i){var s=(()=>{for(var t=!1,e=0;e<o.length;e++){try{t=o[e]()}catch(t){continue}break}return t})();s&&(s.open(i?"POST":"GET",t,!0),i&&s.setRequestHeader("Content-type","application/x-www-form-urlencoded"),s.onreadystatechange=function(){4==s.readyState&&(200==s.status||304==s.status?e(s):console.error("CatLab Remote HTTP error "+s.status))},4!=s.readyState)&&s.send(i)}var o=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];return t.prototype.get=function(t){i.getProxy()&&(t=i.getProxy()+encodeURIComponent(t));var e=new s;return n(t,function(t){e.resolve(t.responseText)}),e.promise()},new t}),define("CatLab/Webremote/Providers/Provider",["CatLab/Webremote/Synchronization/MessageQueue","CatLab/Webremote/Tools/Proxy","CatLab/Webremote/Tools/Deferred"],function(t,i,o){function e(){this.initializeProvider()}var s=e.prototype;return s.initializeProvider=function(){this.queue=new t,this.postInitializeQueue=[],this.scheduled=!1,this.initialized=!1,this.sendBurstDelay=10,this.maxQueueSize=2500,this.messageCounter=null,this.events={}},s.getProviderSettings=function(){var t=new o;return t.resolve({}),t.promise()},s.setMessageCounter=function(t){this.messageCounter=t},s.initMaster=function(t){this.master=t},s.initPlayer=function(t){this.master=t},s.connect=function(){var t=new o;return t.resolve(),t.promise()},s.disconnect=function(){this.off()},s.setOAuthSettings=function(t){this.emit("oauth:set",t)},s.loadViews=function(t,e){(e=void 0===e?!1:e)?i.get(t).then(function(t){this.emit("view:load",{xml:t})}.bind(this)):this.emit("view:load",{url:t})},s.toMaster=function(t,e,i){this.emit(t,e,i)},s.toPlayers=function(t,e,i){this.emit(t,e,i)},s.toPlayer=function(t,e,i,s){i.user=t.getId(),this.emit(e,i,s)},s.toGroup=function(t,e,i,s){i.group=t.getId(),this.emit(e,i,s)},s.emit=function(t,e,i){this.initialized?this.queue?(this.queue.add(t,e,i),this.queue.length>this.maxQueueSize?(clearTimeout(this.scheduled),this.scheduled=null,this.executeQueue()):this.scheduled||(this.scheduled=setTimeout(function(){this.scheduled=null,this.executeQueue()}.bind(this),this.sendBurstDelay))):this.emitOne(t,e,i):this.postInitializeQueue.push({action:t,data:e,ack:i})},s.createGroup=function(t,e,i,s){this.emit("group:create",{externalId:t,globalViews:e,shareColor:i,tags:s=void 0===s?[]:s})},s.executeQueue=function(){this.initialized&&this.emitAll()},s.setInitialized=function(){var t;for(this.initialized=!0;t=this.postInitializeQueue.shift();)this.emit(t.action,t.data,t.ack)},s.setup=function(t){this.emit("master:setup",t)},s.reset=function(t){this.emit("master:reset",null,function(){t()})},s.getStaticUrl=function(t){return t},s.reconnect=function(t,e,i,s){var n=new o;return this.emit("master:reconnect",{token:t,accessToken:e,gameConfig:i},function(){s(),n.resolve()}.bind(this)),n.promise()},s.off=function(){this.events={}},s.on=function(t,e){this._addEvent(t,e,!1),this._touchEvent(t)},s.once=function(t,e){this._addEvent(t,e,!0),this._touchEvent(t)},s._addEvent=function(t,e,i){void 0===this.events[t]&&(this.events[t]=[]),this.events[t].push({callback:e,once:i})},s._touchEvents=function(){for(var t in this.events)this.events.hasOwnProperty(t)&&this._touchEvent(t)},s._touchEvent=function(t){},s._trigger=function(t,i){var s;void 0!==this.events[t]&&(s=[],this.events[t].forEach(function(t){var e=t.callback;t.once&&s.push(t);try{e.apply(this,[i])}catch(t){console.error(t)}}),0<s.length)&&(s.unshift(this.events),function(t){for(var e,i,s=arguments,n=s.length;1<n&&t.length;)for(e=s[--n];-1!==(i=t.indexOf(e));)t.splice(i,1);return t}.apply(this,s))},s.getConnectURL=function(t){return null},s.getConnectToken=function(t){return null},s.tokenConnect=function(t){var e=new o;return e.resolve(),e.promise()},s.noTokenConnect=function(){var t=new o;return t.resolve(),t.promise()},s.restoreProviderSettings=function(t){},s.serializeProviderSettings=function(){return{}},s.proxyFile=function(t){var e=new o;return this.emit("file:proxy",{url:t},function(t){e.resolve({url:t.url})}.bind(this)),e.promise()},e}),define("CatLab/Webremote/Providers/SocketIO",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Tools"],function(t,r,a,e){function i(){this.initializeProvider(),this.userId=null,this.randomToken=e.getUuid(),this.loadBalancerSessionToken="connid",this.socket=null,this._registeredEvents={},this._host=null}var h=null,t=i.prototype=new t;return t.getProviderSettings=function(){var e=new a;return r.getServerList()?r.getServerList().getSelectedServer().done(function(t){e.resolve({host:t})}.bind(this)).fail(function(t){alert(t),e.reject(t)}.bind(this)):e.resolve({}),e.promise()},t.connect=function(s,n){var e,o=new a;return this.log("Loading socket.io"),e=function(){this.log("Connecting to socket.io");var t,e=r.getSocketURL(),i=(this._host?e=this._host:void 0!==n.host&&n.host&&(e=(t=r.getProtocol())?t+"://"+n.host:"//"+n.host,this._host=e),this.socket=h(e+"/"+s+"?"+this.loadBalancerSessionToken+"="+this.randomToken,{withCredentials:!1,reconnection:!0}),!1);this.socket.on("connect_error",function(t){i?this._trigger("disconnect"):(this.socket.off(),this.socket.disconnect(),this.socket=null,o.reject())}.bind(this)),this.socket.once("connect",function(){i||(i=!0,this.setInitialized(),this.socket.io.on("reconnect",function(t){this._trigger("reconnect")}.bind(this)),this._touchEvents(),o.resolve())}.bind(this))}.bind(this),require(["socket.io-client"],function(t){h=t,e()}),o.promise()},t.disconnect=function(t){void 0===t&&(t=!0),this.initialized=!1,this.socket&&((t?this:(this._registeredEvents={},this.socket)).off(),this.socket.disconnect(),this.socket=null)},t.off=function(){this._registeredEvents={},this.events={},this.socket.off()},t.setUserId=function(t){return this.userId=t,this},t.emitAll=function(){var t,e=this.queue.compactFlush();if(e.length)for(;t=e.shift();)this.emitOne(t.action,t.data,t.ack)},t.emitOne=function(t,e,i){this.socket.emit(t,e,i),this.messageCounter&&this.messageCounter.outgoing()},t.log=function(){this.master.log.apply(arguments)},t.getStaticUrl=function(t){return t.indexOf("?")<0?t+="?":t+="&",t+(this.loadBalancerSessionToken+"="+this.randomToken)},t._detachEvents=function(t){this.socket&&this.socket.off(t)},t._touchEvent=function(e){this.socket&&void 0===this._registeredEvents[e]&&(this.socket.on(e,function(t){this._trigger(e,t)}.bind(this)),this._registeredEvents[e]=!0)},t._handleSocketIoEvent=function(t,e){switch(t){case"connect":case"disconnect":break;default:return this._trigger(t,e)}},t.getConnectURL=function(t){return r.getServerList()?r.getServerList().getConnectURL():t},t.getConnectToken=function(t){return r.getServerList()?r.getServerList().getConnectToken(t):t},t.tokenConnect=function(t){var e=new a,i={};if(r.getServerList())try{var s=r.getServerList().getFromToken(t);i.host=s.host,t=s.token}catch(t){return e.reject(),e.promise()}return this.connect("remote",i).fail(function(){e.reject()}).then(function(){e.resolve(t)}),e.promise()},t.restoreProviderSettings=function(t){void 0!==t.serverlist&&r.getServerList()&&r.getServerList().unserialize(t.serverlist),void 0!==t.host&&(this._host=t.host)},t.serializeProviderSettings=function(){var t={host:this._host};return r.getServerList()&&(t.serverlist=r.getServerList().serialize()),t},i}),define("CatLab/Webremote/Models/Users/GamepadUser",["CatLab/Webremote/Models/Users/ControlUser"],function(t){function e(t){var e=t.id||"1";this.initialize({id:"gamepad_"+e}),this.keys=this.getDefaultKeys(t),this.clearControls()}t=e.prototype=new t;return t.getType=function(){return"gamepad"},t.getIcon=function(){return"fa fa-gamepad"},t.emit=function(){return!1},t.isLocalAuthentication=function(){return!1},t.controlFromKey=function(t){return this.control(this.keys[t].id)},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!1},t.hasTouchInput=function(){return!1},t.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"x",authenticate:"y",left:"left",right:"right"}},t.getDefaultKeys=function(t){var e="control-icons/gamepad/$SIZE/",i="gamepad-",s="🎮",n={a:"🅰️",b:"🅱️",x:"❎",y:"❎",up:"⬆️",down:"⬇️",left:"⬅️",right:"➡️",l1:"🤜",r1:"🤛"};return void 0===t.id||-1===t.id.toLowerCase().indexOf("sony")&&-1===t.id.toLowerCase().indexOf("054c")||(e="control-icons/ps-controller/$SIZE/",i="ps-controller-",s="🕹",n={a:"❎",b:"⭕",x:"🟥",y:"🔺",up:"⬆️",down:"⬇️",left:"⬅️",right:"➡️",l1:"🤜",r1:"🤛"}),{DPAD_UP:{id:"up",label:"↑",key:"DPAD_UP",emoji:s+""+n.up},DPAD_DOWN:{id:"down",label:"↓",key:"DPAD_DOWN",emoji:s+""+n.down},DPAD_RIGHT:{id:"right",label:"→",key:"DPAD_RIGHT",emoji:s+""+n.right},DPAD_LEFT:{id:"left",label:"←",key:"DPAD_LEFT",emoji:s+""+n.left},FACE_1:{id:"a",label:"A",key:"FACE_1",image:e+i+"a.gif",emoji:s+""+n.a},FACE_2:{id:"b",label:"B",key:"FACE_2",image:e+i+"b.gif",emoji:s+""+n.b},FACE_3:{id:"x",label:"X",key:"FACE_3",image:e+i+"x.gif",emoji:s+""+n.x},FACE_4:{id:"y",label:"Y",key:"FACE_4",image:e+i+"y.gif",emoji:s+""+n.y},SELECT_BACK:{id:"back",label:"SELECT",key:"SELECT_BACK"},START_FORWARD:{id:"start",label:"START",key:"START_FORWARD"},L1:{id:"l1",label:"L1",key:"L1",emoji:s+""+n.l1},R1:{id:"r1",label:"R1",key:"R1",emoji:s+""+n.r1}}},t.setStaticLabels=function(){for(var t in this.keys)this.keys.hasOwnProperty(t)&&this.control(this.keys[t].id).setStaticLabel(this.keys[t].label,"gamepad",this.keys[t].image,this.keys[t].emoji)},e}),define("CatLab/Webremote/Gamepads/GamepadAPI",["CatLab/Webremote/Models/Users/GamepadUser"],function(i){function t(){this.gamepads={},this.initialized=!1,this.Webcontrol=null}var s,e,n={12:"DPAD_UP",13:"DPAD_DOWN",15:"DPAD_RIGHT",14:"DPAD_LEFT",0:"FACE_1",1:"FACE_2",2:"FACE_3",3:"FACE_4",8:"SELECT_BACK",9:"START_FORWARD"},o=t.prototype;return o.initialize=function(t){var e;this.Webcontrol=t,this.initialized||(this.initialized=!0,t=function(){var t=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(s=0;s<t.length;s++)if(t[s]){for(s=0;s<t.length;s++)t[s]&&this.onConnect(t[s]);this.startGamepadPolling(),clearInterval(e)}}.bind(this),"undefined"!=typeof window&&("ongamepadconnected"in window?(window.addEventListener("gamepadconnected",function(t){this.onConnect(t.gamepad)}.bind(this)),window.addEventListener("gamepaddisconnected",function(t){this.onDisconnect(t.gamepad)}.bind(this))):e=setInterval(t,1e3)))},o.startGamepadPolling=function(){setInterval(this.poll.bind(this),50)},o.poll=function(){var t=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(s=0;s<t.length;s++)if(t[s])for(e=0;e<t[s].buttons.length;e++)this.gamepads[t[s].index].user&&void 0!==n[e]&&this.gamepads[t[s].index].user.controlFromKey(n[e]).update(t[s].buttons[e].pressed?1:0)},o.onConnect=function(t){var e=new i({id:t.id});this.gamepads[t.index]={user:e},this.Webcontrol.addCustomControl(e),this.startGamepadPolling()},o.onDisconnect=function(t){},new t}),define("CatLab/Webremote/SonicSync/Library/ring-buffer",[],function(){function e(t){this.array=[],this.maxLength=t}return e.prototype.get=function(t){return t>=this.array.length?null:this.array[t]},e.prototype.last=function(){return 0==this.array.length?null:this.array[this.array.length-1]},e.prototype.add=function(t){this.array.push(t),this.array.length>=this.maxLength&&this.array.splice(0,1)},e.prototype.length=function(){return this.array.length},e.prototype.clear=function(){this.array=[]},e.prototype.copy=function(){var t=new e(this.maxLength);return t.array=this.array.slice(0),t},e.prototype.remove=function(t,e){this.array.splice(t,e)},e}),define("CatLab/Webremote/SonicSync/Library/sonic-coder",[],function(){function t(t){this.freqMin=(t=t||{}).freqMin||18500,this.freqMax=t.freqMax||19500,this.freqError=t.freqError||50,this.alphabetString=t.alphabet||"\n abcdefghijklmnopqrstuvwxyz0123456789,.!?@*",this.startChar=t.startChar||"^",this.endChar=t.endChar||"$",this.alphabet=this.startChar+this.alphabetString+this.endChar}return t.prototype.charToFreq=function(t){var e=this.alphabet.indexOf(t),t=(-1==e&&(console.error(t,"is an invalid character."),e=this.alphabet.length-1),this.freqMax-this.freqMin),e=e/this.alphabet.length,t=Math.round(t*e);return this.freqMin+t},t.prototype.freqToChar=function(t){if(!(this.freqMin<t&&t<this.freqMax))if(this.freqMin-t<this.freqError)t=this.freqMin;else{if(!(t-this.freqMax<this.freqError))return console.error(t,"is out of range."),null;t=this.freqMax}var e=this.freqMax-this.freqMin,t=(t-this.freqMin)/e,e=Math.round(this.alphabet.length*t);return this.alphabet[e]},t}),define("CatLab/Webremote/SonicSync/Library/sonic-server",["./ring-buffer","./sonic-coder"],function(e,i){function t(t){this.peakThreshold=(t=t||{}).peakThreshold||-65,this.minRunLength=t.minRunLength||2,this.coder=t.coder||new i(t),this.timeout=t.timeout||300,this.debug=!!t.debug,this.peakHistory=new e(16),this.peakTimes=new e(16),this.callbacks={},this.buffer="",this.state=s,this.isRunning=!1,this.iteration=0}var s=1,n=2;return t.prototype.start=function(){try{navigator.mediaDevices||console.log("No mediadevices found"),navigator.mediaDevices.getUserMedia({audio:{optional:[{echoCancellation:!1}]}}).then(this.onStream_.bind(this)).catch(this.onStreamError_.bind(this))}catch(t){console.log(t)}},t.prototype.stop=function(){this.isRunning=!1,this.track.stop()},t.prototype.on=function(t,e){"message"==t&&(this.callbacks.message=e),"character"==t&&(this.callbacks.character=e)},t.prototype.setDebug=function(t){this.debug=t;t=document.querySelector("canvas");t&&t.parentElement.removeChild(t)},t.prototype.fire_=function(t,e){"function"==typeof t&&t(e)},t.prototype.onStream_=function(t){var e;void 0!==t.getTracks()[0]?(this.track=t.getTracks()[0],e=new AudioContext,t=(this.audioContext=e).createMediaStreamSource(t),e=e.createAnalyser(),t.connect(e),this.freqs=new Float32Array(e.frequencyBinCount),this.analyser=e,this.isRunning=!0,this.raf_(this.loop.bind(this))):console.log("No microphone found.")},t.prototype.onStreamError_=function(t){console.error("Audio input error:",t)},t.prototype.getPeakFrequency=function(){for(var t=-1/0,e=-1,i=this.freqToIndex(this.coder.freqMin);i<this.freqs.length;i++)this.freqs[i]>t&&(t=this.freqs[i],e=i);return t>this.peakThreshold?this.indexToFreq(e):null},t.prototype.loop=function(){this.analyser.getFloatFrequencyData(this.freqs),(this.iteration+1)%300==0&&this.restartServerIfSanityCheckFails();var t=this.getPeakFrequency();t?(t=this.coder.freqToChar(t),this.debug&&console.log("Transcribed char: "+t),this.peakHistory.add(t),this.peakTimes.add(new Date)):(t=this.peakTimes.last())&&new Date-t>this.timeout&&(this.state=s,this.debug&&console.log("Token",this.buffer,"timed out"),this.peakTimes.clear()),this.analysePeaks(),this.debug&&this.debugDraw_(),this.isRunning&&this.raf_(this.loop.bind(this)),this.iteration+=1},t.prototype.indexToFreq=function(t){return this.audioContext.sampleRate/2/this.freqs.length*t},t.prototype.freqToIndex=function(t){var e=this.audioContext.sampleRate/2;return Math.round(t/e*this.freqs.length)},t.prototype.analysePeaks=function(){var t=this.getLastRun();t&&(this.state==s?t==this.coder.startChar&&(this.buffer="",this.state=n):this.state==n&&(t!=this.lastChar&&t!=this.coder.startChar&&t!=this.coder.endChar&&(this.buffer+=t,this.lastChar=t,this.fire_(this.callbacks.character,t)),t==this.coder.endChar)&&(this.state=s,this.fire_(this.callbacks.message,this.buffer),this.buffer=""))},t.prototype.getLastRun=function(){for(var t=this.peakHistory.last(),e=0,i=this.peakHistory.length()-2;0<=i&&this.peakHistory.get(i)==t;i--)e+=1;return e>this.minRunLength?(this.peakHistory.remove(i+1,e+1),t):null},t.prototype.debugDraw_=function(){var t=document.querySelector("canvas");t||(t=document.createElement("canvas"),document.body.appendChild(t)),t.width=document.body.offsetWidth,t.height=480,drawContext=t.getContext("2d");for(var e=0;e<this.freqs.length;e++){var i=this.freqs[e]+400,i=t.height-i-1,s=t.width/this.freqs.length;drawContext.fillStyle="black",drawContext.fillRect(e*s,i,1,1)}},t.prototype.raf_=function(t){"undefined"==typeof window||window.chrome&&chrome.extension?setTimeout(t,1e3/60):requestAnimationFrame(t)},t.prototype.restartServerIfSanityCheckFails=function(){if(this.freqs[0]<-300)console.error("freqs[0] < -300. Restarting."),this.restart();else{for(var t=!0,e=0;e<10;e++)-100==this.freqs[e]&&(t=!1);t||(console.error("freqs[0:10] == -100. Restarting."),this.restart())}},t.prototype.restart=function(){},t}),define("CatLab/Webremote/SonicSync/Library/sonic-socket",["./sonic-coder"],function(e){var i=!1;function t(t){this.coder=(t=t||{}).coder||new e,this.charDuration=t.charDuration||.5,this.coder=t.coder||new e(t),this.rampDuration=t.rampDuration||.001,this.audioContext=new i}return"undefined"!=typeof window&&(i=window.AudioContext||window.webkitAudioContext||!1),t.prototype.send=function(t,e){t=this.coder.startChar+t+this.coder.endChar;for(var i,s=0;s<t.length;s++){var n=t[s],n=this.coder.charToFreq(n),o=this.audioContext.currentTime+this.charDuration*s;this.scheduleToneAt(n,o,this.charDuration)}e&&(i=this.charDuration*t.length,setTimeout(e,1e3*i))},t.prototype.scheduleToneAt=function(t,e,i){var s=this.audioContext.createGain(),i=(s.gain.value=0,s.gain.setValueAtTime(0,e),s.gain.linearRampToValueAtTime(1,e+this.rampDuration),s.gain.setValueAtTime(1,e+i-this.rampDuration),s.gain.linearRampToValueAtTime(0,e+i),s.connect(this.audioContext.destination),this.audioContext.createOscillator());i.frequency.value=t,i.connect(s),i.start(e)},t}),define("CatLab/Webremote/SonicSync/Client",["CatLab/Webremote/Config","CatLab/Webremote/SonicSync/Library/ring-buffer","CatLab/Webremote/SonicSync/Library/sonic-coder","CatLab/Webremote/SonicSync/Library/sonic-server","CatLab/Webremote/SonicSync/Library/sonic-socket","CatLab/Webremote/Tools/Deferred"],function(e,t,i,s,n,o){function r(t){this.options=e.getAudioSyncConfig(),this.alphabet=this.options.alphabet.split(""),this.controller=t}var a=r.prototype;return a.startListener=function(){this.stop();var t=new s(this.options);t.start(),t.on("message",this.onIncomingMessage.bind(this)),this.sonicServer=t},a.startSender=function(){this.sonicSocket=new n(this.options)},a.stop=function(){this.sonicServer&&this.sonicServer.stop()},a.sync=function(){var t=new o,e=this.generateRandomSequence(this.options.length);return this.sonicSocket.send(e+this.getParityLetter(e),function(){this.controller.trigger("sync:audio",{secret:e})}.bind(this)),t.promise()},a.generateRandomSequence=function(t){for(var e,i="",s="",n=0;n<t;n++){for(;e=Math.floor(Math.random()*this.alphabet.length),(s=this.alphabet[e])===i.substr(i.length-1,1););i+=s}return i},a.getParityLetter=function(t){for(var e=0,i=t.split(""),s=0;s<i.length;s++)e+=this.alphabet.indexOf(i[s]);t=e%this.alphabet.length;return i[i.length-1]===this.alphabet[t]&&(t=(t+1)%this.alphabet.length),this.alphabet[t]},a.onIncomingMessage=function(t){var e=t.substr(0,t.length-1),i=this.getParityLetter(e);i===t[t.length-1]?this.onMessage(e):console.log("Parity check failed, expected "+i+", ignoring message")},a.onMessage=function(t){this.controller.emit("sync:audio",{secret:t})},a.generateAlphabet=function(t){for(var e="",i=0;i<Math.min(t.length,9);i++)e+=i.toString();return e},r}),define("CatLab/Webremote/Controllers/Webcontrol",["CatLab/Webremote/Config","CatLab/Webremote/Collections/Users","CatLab/Webremote/Collections/Groups","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Models/Users/ControlUser","CatLab/Webremote/Models/ControlGroup","CatLab/Webremote/Models/State","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/Portal","CatLab/Webremote/Controllers/Authentication","CatLab/Webremote/Tools/Colorwheel","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Preloader","CatLab/Webremote/Tools/Smileys","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/MessageCounter","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/ViewFactory/ViewFactory","CatLab/Webremote/Views/ConnectionTrouble","CatLab/Webremote/Providers/SocketIO","CatLab/Webremote/Gamepads/GamepadAPI","CatLab/Webremote/SonicSync/Client","CatLab/Webremote/Messages/MessageBus"],function(a,t,e,i,s,n,h,o,r,l,c,u,d,f,g,p,m,b,v,A,y,w,C,k,I,_,T){function L(){this.initializeEventable(),this.provider=null,this._gamedata=null,this._userlibrary=null,this._grouplibrary=null,this._cssloads=[],this._labeldata={},this._initialized=!1,this._oauthsettings=!1,this._oauthClient=null,this._authentication=!1,this._lastView=null,this._options={},this._groupCallbacks={id:1},this._viewFactory=null,this.state=null,this.connected=!1,this._userlibrary=new t,this._grouplibrary=new e,this._messageBus=new T}p=L.prototype=new p;return Object.assign(p,{AUTH_REQUIRED_ALL:"ALL",AUTH_REQUIRED_ONE:"ONE",AUTH_REQUIRED_ONE_INACTIVE:"ONE-INACTIVE",AUTH_NOT_REQUIRED:"NONE",initialize:function(t){function e(){n.resolve(),s()}var i,s=function(){},n=(void 0!==(t=void 0===(t="function"==typeof t?{callback:t}:t)?{}:t).callback&&(s=t.callback),new u);return this._initialized?e():(this.sonicSyncClient=null,delete t.callback,t.headless,(i=!!t.headless)||void 0===t.assets||this.setAssets(t.assets),a.set(t),a.initialize(function(){null===this.provider&&(void 0===t.provider&&(t.provider=new k),this.provider=t.provider),this.smileys=new g(this.provider),void 0!==t.translator&&d.setTranslator(t.translator),this._initialize(i,e)}.bind(this))),n.promise()},disconnect:function(){this._initialized=!1,this.provider.disconnect()},_initialize:function(n,t){var o,r=new u;return(t&&r.then(t),this._initialized)?r.resolve(this.connected):(setTimeout(function(){r.resolve(!1)},3e4),this.state=new h(this),this._initialized=!0,(o=this).provider.initMaster(this),this.getProviderSettings().then(function(t){this.provider.connect("control",t).then(function(){this.connected=!0,this.provider.on("disconnect",function(){var t=this.getConnectionIssuesView();t.show(),t.text(d.t("Connection lost... reconnecting"))}.bind(this)),this.provider.on("reconnect",function(){this.recover(function(){this.getConnectionIssuesView().hide()}.bind(this))}.bind(this)),this.provider.on("master:initialize",function(t){this.log("Initializing"),this._gamedata=t,this.log("Game initialize; URL "+this.getConnectURL()+", token "+this.getConnectToken()),r.resolve(this.connected)}.bind(this)),this.provider.on("master:error",function(t){alert(t.message)}.bind(this)),this.provider.on("user:join",function(t){this._playerJoin(t)}.bind(this)),this.provider.on("user:reconnect",function(t){this._playerReconnect(t)}.bind(this)),this.provider.on("user:leave",function(t){this._playerLeave(t)}.bind(this)),this.provider.on("view:labels",function(t){this._setViewLabels(t)}.bind(this)),this.provider.on("group:create",function(t){this._onNewGroup(t)}.bind(this)),this.provider.on("user:smiley",function(t){this._playerTrigger("user:smiley",t),this._userlibrary.each(function(t){this.smileys.refreshTakenSmileys(t)}.bind(this))}.bind(this)),this.provider.on("smileys:slingshot",function(t){var e=this._userlibrary.getFromId(t.user);e?(e.trigger("smileys:slingshot",t),t.user=e,this.trigger("smileys:slingshot",t)):console.log("User not found: "+t.user)}.bind(this));for(var t=(t=(t=["user:login","user:logout","button:down","button:up","sync:audio"]).concat(A.eventsToListenFor)).concat(y.eventsToListenFor),e=0;e<t.length;e++)(e=>{o.provider.on(e,function(t){o._playerTrigger(e,t)})})(t[e]);var i=["value:change"];for(var s=0;s<i.length;s++)(e=>{o.provider.on(e,function(t){o._viewTrigger(e,t)})})(i[s]);this._oauthsettings&&this.provider.setOAuthSettings(this._oauthsettings),this.provider.setup(a.getProviderConfig()),this.preloader=new f(this.provider),!n&&a.useAudioSync()&&(this.sonicSyncClient=new _(this),this.sonicSyncClient.startSender())}.bind(this))}.bind(this))),r.promise()},setLogger:function(t){var e;"string"==typeof t?(e=document.getElementById(t),this.log=this.getDomLogger(e)):this.log=t},getProviderSettings:function(){return this.provider.getProviderSettings()},setMessageCounter:function(t){t=new m(t);return this.provider.setMessageCounter(t),t},setName:function(t){this.provider.toMaster("master:name",{name:t})},setMaxUsers:function(t){this.provider.toMaster("config:set",{maxUsers:t})},setViewFactory:function(t){return this._viewFactory=t,this._viewFactory.initialize()},getViewFactory:function(){return"undefined"===this._viewFactory&&(this._viewFactory=new w),this._viewFactory},getDomLogger:function(e){return function(t){e.innerHTML=t+"\n"+e.innerHTML}},oAuth:function(t,e){void 0===e&&(e=!1),this._authentication=!0,this._oauthsettings=t,this.provider&&!e&&this.provider.setOAuthSettings(this._oauthsettings),o.initialize(t),i.initialize(this,o)},getOAuthClient:function(t){this._oauthsettings?(null===this._oauthClient&&(this._oauthClient=o,this._oauthClient.initialize(this._oauthsettings)),t(this._oauthClient)):t(null)},getOAuthSettings:function(){return this._oauthsettings},clearEvents:function(t){if(t=void 0===t?!1:t)for(var e=this._userlibrary.getAll(),i=0;i<e.length;i++)e[i].clearEvents()},getConnectURL:function(){return this.provider.getConnectURL(this._gamedata.connectURL)},getConnectToken:function(){return this.provider.getConnectToken(this._gamedata.token)},getConnectTokenForDisplay:function(){return b.getConnectTokenForDisplay(this.getConnectToken())},loadViews:function(t,e){this.provider.loadViews(t,e)},getUsers:function(){return this._userlibrary.getAll()},portal:function(t){var e=this.portalController(t),t=this.portalView(e.messageBus,t);return{controller:e.controller,view:t,promise:e.promise}},portalController:function(t){var e;if(this._initialized)return e=new u,t=new r(this,t),e.resolve(t),{controller:t,messageBus:this.getMessageBus(),promise:e};throw new Error("Please initialize Webcontrol first.")},portalView:function(t,e){var i;if(this._initialized)return i=this.getViewFactory(),t=Object.assign({},e,{messageBus:t,Webcontrol:this}),void 0!==e.element&&(t.element=e.element),(e=i.portal(t)).loading(),(t=i.getContainer()).easelboneLayer.setView(e),e.render(),t;throw new Error("Please initialize Webcontrol first.")},authentication:function(t,e){var i;if(this._initialized)return i=this.authenticationController(t,e),e=this.authenticationView(i.controller.messageBus,e),i.controller.setNavigatableUsers([t]),{controller:i.controller,view:e,promise:i.promise};throw new Error("Please initialize Webcontrol first.")},authenticationController:function(t,e){var i=new u,t=new l(this,t,e);return i.resolve(t),{controller:t,promise:i.promise()}},authenticationView:function(t,e){var i=this.getViewFactory(),e=i.authentication(Object.assign({},e,{messageBus:t})),t=i.getContainer();return t.easelboneLayer.setView(e),e.render(),t},alertView:function(t,e){var i=this.getViewFactory(),e=i.alert(Object.assign({},e,{message:t})),t=i.getContainer();return t.easelboneLayer.setView(e),e.render(),t},getConnectionIssuesView:function(){return void 0===this.connectionTrouble&&(this.connectionTrouble=new C),this.connectionTrouble},setView:function(t,e){var i;return void 0===e?(i=v.create(t,[this],this),this._lastView=i):i=v.create(t,e,this),i},beacon:function(t,e){this.provider.toMaster("master:beacon",{beacon:t,token:e})},emit:function(t,e){this.provider.toPlayers(t,e)},getControlLabels:function(t,e){for(var i=[],s={},n=this.getUsers(),o=0;o<n.length;o++){var r=n[o].control(t).getLabel(e);void 0===s[r]&&i.push(s[r]=r)}return i},addCustomControl:function(t){this.log("adding "+t.getType()),t.setWebcontrol(this),this._userlibrary.add(t),this._initializeSmiley(t,{}),this.trigger("user:join",t)},enableGamepads:function(){I.initialize(this)},newGroup:function(t){var e=new u,i={},s=(void 0===t?t={}:"function"==typeof t&&(t={callback:t}),void 0===t.callback&&(t.callback=function(){}),!0),n=(void 0!==t.globalViews&&(s=t.globalViews),!0),o=(void 0!==t.shareColor&&(n=t.shareColor),[]),r=(void 0!==t.tags&&(o=t.tags),!0),r=(void 0!==t.smiley&&(r=!!t.smiley),i.smiley=r,this._groupCallbacks.id);return this._groupCallbacks.id++,this._groupCallbacks[r]={id:r,callback:t.callback,deferred:e,options:i},this.provider.createGroup(r,s,n,o),e.promise()},preload:function(t){return this.preloader.preload(t)},getPreloadedUrl:function(t){return this.preloader.getPreloadedUrl(t)},_reset:function(){this._userlibrary.clear(),this._grouplibrary.clear()},reset:function(){var t=new u;return this.provider.reset(function(){t.resolve()}.bind(this)),t.promise()},_playerJoin:function(t){var e;this._userlibrary.getFromId(t.id)||((e=new s(t.id,t)).setWebcontrol(this),void 0!==t.color&&e.setColor(t.color.color,t.color.name),this._grouplibrary.addUser(e)||(this._lastView&&this._lastView.addTarget(e),this._initializeSmiley(e,t)),this._userlibrary.add(e),this.log(e),e&&this.trigger("user:join",e),this.preloader.sendPreloadFileCommandToPlayer(e))},_playerReconnect:function(t){var e=this._userlibrary.getFromId(t.id);e?(e.getSmiley()&&e.emit("user:smiley",{smiley:e.getSmiley()}),this._refreshPlayerViews(e),this.trigger("user:rejoin",e),e.eventableTrigger("rejoined"),this.smileys.refreshTakenSmileys(e),this.preloader.sendPreloadFileCommandToPlayer(e)):this._playerJoin(t)},_refreshPlayerViews:function(t){this._grouplibrary.addUser(t)||this._lastView&&this._lastView.addTarget(t),t.refreshView()},_playerLeave:function(t){t=this._userlibrary.getFromId(t.id);t&&(this.trigger("user:leave",t),t.eventableTrigger("left"))},_onNewGroup:function(t){var e,i=new n(t.id,t),s=(i.setWebcontrol(this),!1);void 0!==t.shareColor&&(s=t.shareColor),void 0!==t.color?i.setColor(t.color.color,t.color.name):i.setShareColor(s),this._grouplibrary.getFromId(t.id)||(s=function(){},void 0!==(e=t.externalId)&&void 0!==this._groupCallbacks[e]&&(i.setOptions(this._groupCallbacks[e].options),s=function(){this._groupCallbacks[e].callback(i),this._groupCallbacks[e].deferred.resolve(i)}.bind(this)),this._grouplibrary.add(i),i.getOption("smiley")&&this._initializeSmiley(i,t),this.trigger("group:create",i),this.log("New group "+i.getId()+"; URL "+i.getConnectURL()+", token "+i.getConnectToken()),s())},_initializeSmiley:function(t,e){var i;a.useSmileys()?void 0===e.smiley?null!==(i=this.smileys.getRandom(t.getIdentifier()))&&t.setSmiley(i):t.setSmiley(e.smiley):t.clearSmiley(),this.smileys.refreshTakenSmileys(t)},_playerTrigger:function(t,e){var i=this._userlibrary.getFromId(e.user);i?i.trigger(t,e):console.log("User not found: "+e.user)},_viewTrigger:function(t,e){var i=v.getFromId(e.viewId);i&&i.trigger(t,e)},_loadCSS:function(t){for(var e=0;e<this._cssloads.length;e++)if(this._cssloads[e]==t)return;this._cssloads.push(t);var i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",t),document.body.appendChild(i)},_setViewLabels:function(t){this._labeldata[t.id]=t.labels;for(var e=this.getUsers(),i=0;i<e.length;i++)for(var s=0;s<t.labels.length;s++)e[i].control(t.id).setStaticLabel(t.labels[s].label,"mobile")},getViewLabels:function(t){return void 0!==this._labeldata[t]?this._labeldata[t]:[]},getFromIdentifier:function(t){switch(t.type){case"user":return this._userlibrary.getFromId(t.id);case"group":return this._grouplibrary.getFromId(t.id)}return null},log:function(t){a.debug()&&(console.log(a),console.log(t))},canAuthenticate:function(){return this._authentication},pause:function(){this._initialized&&this.provider.toPlayers("master:pause",{})},unpause:function(){this._initialized&&this.provider.toPlayers("master:unpause",{})},audioSync:function(){if(this.sonicSyncClient)return this.sonicSyncClient.sync()},getMessageBus:function(){return this._messageBus},recover:function(t){var e=this.state.getData();this._reconnect(e.token,e.accessToken,t).then(function(){this._userlibrary.each(function(t){this._refreshPlayerViews(t)}.bind(this))}.bind(this))},_reconnect:function(t,e,i){return this.provider.reconnect(t,e,a.getProviderConfig(),i)},getIceCredentials:function(){var e=new u;return this.provider.toMaster("webrct:stun+turn",{},function(t){void 0===t.error?e.resolve(t):e.fail(t.error)}),e.promise()}}),L}),define("CatLab/Webremote/Models/Users/KeyboardUser",["CatLab/Webremote/Models/Users/ControlUser"],function(t){function e(t,e){var i="keyboard"+ ++s;this.initializeKeyboardUser({id:i,keys:t}),this.exitOnUnassignedBackButton=e}var s=0,t=((e.prototype=Object.create(t.prototype)).constructor=e).prototype;return t.initializeKeyboardUser=function(t){this.initialize({id:t.id}),void 0===t.keys&&(t.keys=this.getDefaultKeys()),this.keys=t.keys,this.attachKeyboardEvents(),"undefined"!=typeof document&&document.addEventListener("fullscreenchange",this.attachKeyboardEvents.bind(this)),this.setStaticLabels=function(){for(var t=0;t<this.keys.length;t++)this.control(this.keys[t].id).setStaticLabel(this.keys[t].label,"keyboard",this.keys[t].image,this.keys[t].emoji)},this.on("view:set",function(t){this.clearControls()}.bind(this)),this.getType=function(){return"keyboard"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(t,e){return!1},this.isLocalAuthentication=function(){return!1},this.clearControls()},t.getAvailableControls=function(){for(var t=[],e=0;e<this.keys.length;e++)t.push(this.keys[e].id);return t},t.getDefaultKeys=function(){return[{id:"up",label:"↑",code:"ArrowUp",emoji:"⬆️"},{id:"down",label:"↓",code:"ArrowDown",emoji:"⬇️"},{id:"right",label:"→",code:"ArrowRight",emoji:"➡️"},{id:"left",label:"←",code:"ArrowLeft",emoji:"⬅️"},{id:"a",label:"A",code:["KeyA","Enter","NumpadEnter"],emoji:"🅰"},{id:"b",label:"B",code:"KeyB",emoji:"🅱"},{id:"x",label:"X",code:"KeyX",emoji:"🆇"},{id:"y",label:"Y",code:"KeyY",emoji:"🆈"},{id:"back",label:"Escape",code:"Escape",emoji:"🇪"},{id:"start",label:"S",code:["KeyS"],emoji:"🆂"}]},t.hasControl=function(t){return-1!==this.getAvailableControls().indexOf(t)},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!0},t.hasTouchInput=function(){return!0},t.stopListening=function(){try{if("undefined"==typeof window)self.removeEventListener("message",this.messageListener,!1);else{var t=null;try{t=window.document}catch(t){}t&&(this._keydownListener&&window.document.removeEventListener("keydown",this._keydownListener),this._keyupListener)&&window.document.removeEventListener("keyup",this._keyupListener),this.messageListener&&window.removeEventListener("message",this.messageListener,!1);var e=null;try{e=window.parent.document}catch(t){}e&&(e.removeEventListener("keyup",this._keydownListener),e.removeEventListener("keydown",this._keydownListener))}}catch(t){console.log(t)}},t.resumeListening=function(){this.attachKeyboardEvents()},t.attachKeyboardEvents=function(){if(this.stopListening(),"undefined"==typeof window)this.messageListener=this._onMessage.bind(this),self.addEventListener("message",this.messageListener,!1);else try{var t=window.document;if(!document.fullscreenElement&&window.parent&&!(t=window.parent.document))throw new Error("Unaccessible");this._keydownListener=this._keyDown.bind(this),this._keyupListener=this._keyUp.bind(this),t.addEventListener("keydown",this._keydownListener),t.addEventListener("keyup",this._keyupListener)}catch(t){try{this.messageListener=this._onMessage.bind(this),window.addEventListener("message",this.messageListener,!1)}catch(t){console.error(t)}}},t.getConfigFromKey=function(t){for(var e=0;e<this.keys.length;e++){if(void 0!==this.keys[e].code&&this._keyMatches(this.keys[e].code,t.code))return this.keys[e];if(void 0!==this.keys[e].key&&this._keyMatches(this.keys[e].key,t.key))return this.keys[e];if(void 0!==this.keys[e].keyCode&&this._keyMatches(this.keys[e].keyCode,t.keyCode))return this.keys[e]}return null},t._keyMatches=function(t,e){return!!(Array.isArray(t)&&-1<t.indexOf(e))||t==e},t._onMessage=function(t){var e=t.data;if("object"==typeof e&&void 0!==e.type&&"catlab:keyboard"===e.type&&void 0!==e.code&&void 0!==e.action)switch(e.action){case"down":return void this._keyDown(t.data);case"up":return void this._keyUp(t.data)}},t._keyDown=function(t){var e;"Escape"!==t.key||!this.exitOnUnassignedBackButton||this.control("back").hasTriggers("click")||this.control("back").hasTriggers("up")||this.control("back").hasTriggers("down")?(e=this.getConfigFromKey(t))&&(this.control(e.id).update(1),void 0!==e.preventDefault)&&e.preventDefault&&t.preventDefault():this.requestExitApp()},t._keyUp=function(t){var e=this.getConfigFromKey(t);e&&(this.control(e.id).update(0),void 0!==e.preventDefault)&&e.preventDefault&&t.preventDefault()},t.requestExitApp=function(){var t;window.onbeforeunload?(t=window.onbeforeunload({}))&&this.confirm(t,function(t){t&&this.exitApp()}.bind(this)):this.exitApp()},t.exitApp=function(){window.close()},t.confirm=function(t,e){e(window.confirm(t))},e}),define("CatLab/Webremote/Models/Users/CordovaUser",["CatLab/Webremote/Models/Users/KeyboardUser"],function(t){function e(t,e,i){void 0===i&&(i=!0),void 0===e&&(e="back"),this.initializeKeyboardUser({id:"cordova",keys:t}),this.initializeBackButtonExit(e,i)}t=((e.prototype=Object.create(t.prototype)).constructor=e).prototype;return t.initializeBackButtonExit=function(i,s){void 0===s&&(s=!0);var n=new Date;document.addEventListener("backbutton",function(t){var e=new Date;e.getTime()-n.getTime()<300?this.requestExitApp():(n=e,t.preventDefault(),!s||this.control("back").hasTriggers("click")||this.control("back").hasTriggers("up")||this.control("back").hasTriggers("down")?i&&(this.control(i).update(1),setTimeout(function(){this.control(i).update(0)}.bind(this),1)):setTimeout(function(){void 0!==window.plugins.appMinimize?window.plugins.appMinimize.minimize():this.exitApp()},350))}.bind(this),!1)},t.exitApp=function(){navigator.app.exitApp()},t.confirm=function(t,e){navigator.notification.confirm(t,function(t){e(1===t)})},t.getDefaultKeys=function(){return[{id:"up",label:"↑",key:38},{id:"down",label:"↓",key:40},{id:"right",label:"→",key:39},{id:"left",label:"←",key:37},{id:"start",label:"ENTER",key:13},{id:"back",label:"BACK",key:null}]},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!0},t.hasTouchInput=function(){return!0},e}),define("CatLab/Webremote/Models/Users/AndroidRemoteUser",["CatLab/Webremote/Models/Users/CordovaUser"],function(t){function e(t,e,i){this.initializeKeyboardUser({id:"cordova",keys:t}),this.initializeBackButtonExit(e,i)}t=((e.prototype=Object.create(t.prototype)).constructor=e).prototype;return t.getDefaultKeys=function(){return[{id:"up",label:"↑",keyCode:38,preventDefault:!0,image:"control-icons/android-tv/$SIZE/android-tv-up.gif",emoji:"⬆️"},{id:"down",label:"↓",keyCode:40,preventDefault:!0,image:"control-icons/android-tv/$SIZE/android-tv-down.gif",emoji:"⬇️"},{id:"right",label:"→",keyCode:39,preventDefault:!0,image:"control-icons/android-tv/$SIZE/android-tv-right.gif",emoji:"➡️"},{id:"left",label:"←",keyCode:37,preventDefault:!0,image:"control-icons/android-tv/$SIZE/android-tv-left.gif",emoji:"⬅️"},{id:"a",label:"ENTER",keyCode:13,preventDefault:!0,emoji:"🅰"},{id:"back",label:"BACK",keyCode:null},{id:"start",label:"⏯",keyCode:179},{id:"fastforward",label:"⏩",keyCode:228},{id:"fastforward",label:"⏪",keyCode:227}]},t.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"down",left:"left",right:"right"}},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!1},t.hasTouchInput=function(){return!1},this.getType=function(){return"android-keyboard"},e}),define("CatLab/Webremote/Models/Users/DummyUser",["CatLab/Webremote/Models/Users/ControlUser"],function(t){function e(t){this.initialize({id:t}),this.clearControls=function(){},this.getType=function(){return"dummy"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(t,e){return!1},this.isLocalAuthentication=function(){return!1},this.log=function(t){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+t)},this.hasDisplay=function(){return!1},this.hasKeyboardInput=function(){return!0},this.hasTouchInput=function(){return!0},this.clearControls()}return(e.prototype=Object.create(t.prototype)).constructor=e}),define("CatLab/Webremote/Tools/ParseXML",[],function(){function t(){}var e=null;"undefined"!=typeof window&&(void 0!==window.DOMParser?e=function(t){return(new window.DOMParser).parseFromString(t,"text/xml")}:void 0!==window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")&&(e=function(t){var e=new window.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e}));return t.prototype.parse=function(t){if(e)return e(t);throw new Error("No XML parser found")},new t}),define("CatLab/Webremote/Providers/Airconsole",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Proxy","CatLab/Webremote/Tools/ParseXML","CatLab/Webremote/Synchronization/MessageQueue","CatLab/Webremote/Models/User"],function(t,e,i,s,n,o,r){function a(t){t&&(this.airconsole=t),this.showTokenForm=!1,this.oauth={},this.views=[],this.knownUsers={},this.started=!1,this.userId=null,this.sendBurstDelay=50,this.connectCode=null}t=a.prototype=new t;return t.connect=function(t){return this.log("Airconsole connecting"),this.setInitialized(),this.path=t,this._trigger("connect",null),this.readyState.promise()},t.noTokenConnect=function(){return this.connect("remote")},t.setUserId=function(t){return this.userId=t,this},t.initMaster=function(t){this.master=t,this.airconsole||(this.airconsole=new AirConsole),this.airconsole.onMessage=this.onMessage.bind(this),this.airconsole.onConnect=function(t){this.emitAirConsole(t,"airconsole:well-hello-there",{user:t})}.bind(this),this.readyState=new i,this.airconsole.onReady=function(t){this.connectCode=t,this.readyState.resolve()}.bind(this),this.airconsole.onDeviceProfileChange=function(t){this.updateDeviceProfile(t)}.bind(this),this.on("player:join",function(t){this.onPlayerConnect(t.user)}.bind(this)),this.once("connect",function(){setTimeout(function(){this.started=!0}.bind(this),1)}.bind(this))},t.initPlayer=function(t){this.master=t,this.airconsole=new AirConsole,this.airconsole.onMessage=this.onMessage.bind(this),this.readyState=new i,this.readyState.resolve(),this.once("airconsole:well-hello-there",function(t){this.emitAirConsole(0,"player:join",{})}.bind(this))},t.onMessage=function(e,t){var i;void 0!==(t="string"==typeof t?JSON.parse(t):t).b&&Array.isArray(t.b)?(i=0,t.b.forEach(function(t){setTimeout(function(){this.processMessage(e,t)}.bind(this),i++)}.bind(this))):this.processMessage(e,t)},t.processMessage=function(t,e){var i;e&&e[0]&&(i=e[0],e=e[1],this.isMaster()&&(0<t&&"player:join"!==i&&void 0===this.knownUsers[t]&&this.onPlayerConnect(t),0<t)&&(e.user=t),o.unpack(e,"user").forEach(function(t){this.isRemote()&&void 0!==t.user&&t.user!==this.airconsole.getDeviceId()||this._trigger(i,t)}.bind(this)))},t.onPlayerConnect=function(t){this.log("Welcoming our newest player "+t),this.knownUsers[t]=!0;for(var e=0;e<this.views.length;e++)this.emitAirConsole(t,"view:load",{xml:this.views[e]}),this.emitAirConsole(t,"view:set",{id:"loading"});this._trigger("user:join",{id:t}),this.updateDeviceProfile(t)},t.updateDeviceProfile=function(t){var e,i,s=this.master._userlibrary.getFromId(t);s&&(e={username:this.airconsole.getNickname(t)},(i=this.airconsole.getProfilePicture(t))&&(e.avatar=i),this.airconsole.getMasterControllerDeviceId()===t&&s.setMaster(!0),s.setProfiledata(e))},t.emitAll=function(){this.isMaster()&&this.emitMaster(),this.isRemote()&&this.emitClient()},t.isMaster=function(){return"control"===this.path},t.isRemote=function(){return"remote"===this.path},t.emitClient=function(){this.queue.flush().forEach(function(t){this.emitAirConsole(0,t.action,t.data)}.bind(this))},t.emitMaster=function(){var e,i,t=this.queue.compactFlush();t.length&&(e=5<t.length,i=[],t.forEach(function(t){e||void 0===t.data.user||Array.isArray(t.data.user)&&1<t.data.user.length?i.push(t):this.emitAirConsole(t.user,t.action,t.data)}.bind(this)),0<i.length)&&this.broadcastAirconsole(i)},t.emitAirConsole=function(t,e,i){e=[e,i],delete e[1].action,i=JSON.stringify(e);this.airconsole.message(t,i)},t.broadcastAirconsole=function(t){var e=[],t=(t.forEach(function(t){e.push([t.action,t.data])}),JSON.stringify({b:e}));this.airconsole.broadcast(t)},t.setOAuthSettings=function(t){this.oauth=t,this.toPlayers("oauth:set",t)},t.loadViews=function(t){s.get(t).then(function(t){this.views.push(t),this.toPlayers("view:load",{xml:t})}.bind(this))},t.log=function(){this.master.log.apply(arguments)},t.setup=function(t){this._trigger("master:initialize",{})},t.toMaster=function(t,e){e.user=0,this.emit(t,e)},t.log=function(t){var e=[],i=(Array.prototype.push.apply(e,arguments),"["+this.path+"]");"remote"===this.path&&(i="["+this.path+":"+this.airconsole.getDeviceId()+"]"),e.unshift(i),console.log.apply(console,e)},t.getConnectInstructions=function(){return["Open the Airconsole app on your smartphone and connect with code %s.",this.connectCode]},t.getStartAndLoginInstructions=function(){return["Use the onscreen button to start the game."]},t.proxyFile=function(t){var e=new i;return e.resolve({url:t}),e.promise()},a}),define("CatLab/Webremote/CreateJS/LayerContainer",["easeljs","easelbone"],function(s,n){function t(t,e){if(!n)throw console.log("When using the createjs module of the remote, you need to have the easelbone module loaded."),console.log("Check https://github.com/catlabinteractive/easelbone"),new Error("easelbone could not be loaded.");this.width=t,this.height=e,this.initialize(),this.easelboneLayer=new n.Views.Layer({container:this});var i=this;this.easelboneLayer.on("all",function(t){t=new s.Event(t);i.dispatchEvent(t)})}var e=t.prototype=new s.Container;return e.Container_initialize=e.initialize,e.initialize=function(){this.Container_initialize(),this.setBounds(0,0,this.width,this.height),this.on("click",function(t){t.stopPropagation()})},e.loading=function(){},e.render=function(){this.easelboneLayer.render()},t}),define("CatLab/Webremote/CreateJS/Views/BaseView",["easelbone","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Images"],function(o,r,t){var a=new t;return o.Views.Navigatable.extend({intitializeBaseView:function(t){this.initializeNavigatable(t),this.labels={},this.replacedEmojis={},this.navigatableOverride=null},getLabelSubstitutionOrNull:function(t,e){return void 0!==this.labels[t]?this.substituteLabelsForInstructionMessage(e,this.labels[t]):null},substituteLabelsForInstructionMessage:function(t){for(var e=[],i=1;i<arguments.length;i++){var s,n=arguments[i];"string"!=typeof n?(s=[],n.forEach(function(t){t.emoji?(s.push(t.emoji),void 0!==t.image&&(this.replacedEmojis[t.emoji]=a.getUrl(t.image,128))):t.label&&s.push(t.label)}.bind(this)),e.push(s.join(" / "))):e.push(n)}return r.t.apply(r,[t].concat(e))},getEmojiSubstitutedMessage:function(t){var t=new o.EaselJS.BigText(t),n=this.replacedEmojis;return t.textConstructor=function(t,e,i,s){t=new o.EaselJS.EmojiText(t,e,i,s);return t.setEmojis(n),t},t},alert:function(t,e){var e=this.Webcontrol.getViewFactory().alert(Object.assign({},e,{message:t})),i=this.Webcontrol.getViewFactory().getContainer();i.easelboneLayer.setView(e),e.render(),this.navigatableOverride=e,this.el.addChild(i),e.on("view:close",function(){i.easelboneLayer.view.trigger("stage:removed"),this.el.removeChild(i),this.navigatableOverride=null}.bind(this))}})}),define("CatLab/Webremote/Tools/ImageLoader",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred"],function(s,n){return{loadedImages:{},loadImage:function(t){var e,i=new n;return this.loadedImages[t]?i.resolve(this.loadedImages[t]):((e=new Image).crossOrigin="anonymous",e.onload=function(){this.loadedImages[t]=e,i.resolve(this.loadedImages[t])}.bind(this),e.src=s.getProxiedImage(t)),i.promise()}}}),define("CatLab/Webremote/Tools/QrGenerator",["easelbone","qrious"],function(o,r){return{generateQrCode:function(t,e){var i=200,s=200;t.getBounds()&&t.getBounds().width&&!t.getBounds().height&&(i=t.getBounds().width,s=t.getBounds().height),t.addChild(this.getGeneratedQrCode(e,Math.max(i,s)))},getGeneratedQrCode(t,e,i,s){void 0===i&&(i="#000000"),void 0===s&&(s="#ffffff");var n=new r,e=(n.level="H",n.size=2*e,n.value=t,n.background=s,n.foreground=i,new Image);return e.src=n.toDataURL(),new o.EaselJS.Fill(e,{zoom:"minimum"})}}}),define("CatLab/Webremote/CreateJS/Views/PortalView",["easeljs","easelbone","CatLab/Webremote/CreateJS/Views/BaseView","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/ImageLoader","CatLab/Webremote/Tools/QrGenerator","CatLab/Webremote/Messages/NavigateableProxy"],function(t,s,e,n,o,i,r){return e.extend({initialize:function(t){this.Webcontrol=t.Webcontrol,this.controllerState={activePlayers:0,minPlayers:0,maxPlayers:0,connectInstructions:[""],startAndLoginInstructions:[""],showInactivePlayers:!1,qrUrl:null},this.intitializeBaseView({orientation:this.ORIENTATION.HORIZONTAL}),this.messageBus=t.messageBus,this.assets=t.assets,this.initialized=!1,this.leanback=void 0!==t.leanback&&t.leanback,this.users=[],this.messageBus.toController("nav:controls",{controls:this._controls}),this.purchaseSeatsCallback=null,t.purchaseSeatsCallback&&(this.purchaseSeatsCallback=t.purchaseSeatsCallback),this.attachMessageBus(this.messageBus),this.on("stage:removed",this.destroy.bind(this))},initializeContent:function(){this.initialized||(this.initialized=!0,this.controllerState.showInactivePlayers?this.setScreen(new this.assets.PortalView):this.setScreen(new this.assets.PortalViewNoInactive),this.showInactivePlayers=this.controllerState.showInactivePlayers||!1,this.showInactivePlayers&&(this.connectedUsersContainer=new s.EaselJS.Placeholder(this.getScreen().connectedUsers),this.connectedUsers=new s.Controls.FloatContainer(function(t){return this.getUserIcon(t)}.bind(this),6),this.connectedUsersContainer.addChild(this.connectedUsers)),this.activeUsersContainer=new s.EaselJS.Placeholder(this.getScreen().activeUsers),this.activeUsers=new s.Controls.FloatContainer(function(t){return this.getUserIcon(t)}.bind(this),this.showInactivePlayers?6:9),this.activeUsersContainer.addChild(this.activeUsers),void 0!==this.getScreen().start&&(this.start=new s.Controls.Button(this.getScreen().start),this.start.setText(n.t("Start")),this.start.on("click",function(){this.messageBus.toController("start")}.bind(this)),this.addControl(this.start)),void 0!==this.getScreen().back&&(this.back=new s.Controls.Button(this.getScreen().back),this.back.setText(n.t("Back")),this.back.on("click",function(){this.messageBus.toController("back")}.bind(this)),this.addControl(this.back)),this.findPlaceholders("instructionHeader").forEach(function(t){t.addChild(new s.EaselJS.BigText(n.t("Instructions")))}),this.findPlaceholders("activePlayersHeader").forEach(function(t){t.addChild(new s.EaselJS.BigText(n.t("Active devices")))}),this.findPlaceholders("connectedPlayersHeader").forEach(function(t){t.addChild(new s.EaselJS.BigText(n.t("Connected devices")))}),this.instructionTexts=[],this.instructionTexts=this.findPlaceholders("instructionText"),this.updateInstructionText(),this.activePlayerTexts=[],this.findPlaceholders("activePlayers").forEach(function(t){var e=new s.EaselJS.BigText(this.getActiveUsersText());this.activePlayerTexts.push(e),t.addChild(e)}.bind(this)),this.qrContainers=this.findPlaceholders("qr"),this.qrInstructionsContainers=this.findPlaceholders("qrInstructions"))},attachMessageBus:function(t){t.addViewListener(this)},handleIncomingMessage:function(t,e){var i=this.navigatableOverride||this;if(!r.handleMessage(t,e,i,"portal:"))switch(t){case"state:change":this.controllerState=e.state,this.initialized||this.initializeContent(),this.showCurrentAndMaxUsers();break;case"alert":if(e.id&&"exceeds-max-players"===e.id)if(this.purchaseSeatsCallback)return void this.alert(n.t(e.localized),{type:"confirm",okLabel:n.t("Purchase seats"),ok:function(t){t.close(),this.purchaseSeatsCallback()}.bind(this),cancelLabel:n.t("Cancel")});this.alert(n.t(e.localized));break;case"users:update":this.users=e.users,this.refreshUsers();break;case"auth:open":this.addAuthenticationView();break;case"portal:destroy":this.destroy()}},getActiveUsersText:function(){return this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers},getInstructionText:function(){return this.substituteLabelsForInstructionMessage.apply(this,this.controllerState.connectInstructions)+"\n"+this.substituteLabelsForInstructionMessage.apply(this,this.controllerState.startAndLoginInstructions)},getUserIcon:function(t){var e,i;return t?t.profile?(e=new this.assets.UserIconAuthenticated,this.addControllerIcon(e,t)):e=this.getControllerIcon(t):e=this.getControllerIcon(),t&&(i=e.PlayerColor)&&new s.EaselJS.Placeholder(i).addChild(new s.EaselJS.Fill(t.color)),t&&this.setUserDetails(e,t),e},addControllerIcon:function(t,e){var i;t.ControllerIcon&&(t=new s.EaselJS.Placeholder(t.ControllerIcon),i=this.getControllerIcon(e),t.addChild(i),i.scaleX=i.scaleY=.5,e)&&(t=i.PlayerColor)&&new s.EaselJS.Placeholder(t).addChild(new s.EaselJS.Fill(e.color))},getControllerIcon:function(t){if(t)switch(t.type){case"keyboard":return new this.assets.UserIconKeyboard;case"tablet":return new this.assets.UserIconTablet;case"phone":return new this.assets.UserIconPhone;case"gamepad":return new this.assets.UserIconGamepad}return new this.assets.UserIcon},loading:function(){},refreshUsers:function(){this.showCurrentAndMaxUsers(),this.showInformation(),this.reloadUserIcons()},showCurrentAndMaxUsers:function(){this.getScreen().playercount&&(this.getScreen().playercount.text=this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers),this.activePlayerTexts.forEach(function(t){t.setText(this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers)}.bind(this)),this.getScreen().login&&(this.getScreen().login.text=n.t(this.controllerState.startAndLoginInstructions))},showInformation:function(){var t=n.t(this.controllerState.connectInstructions);this.getScreen().login?this.getScreen().login.text=n.t(this.controllerState.startAndLoginInstructions):t+="\n "+n.t(this.controllerState.startAndLoginInstructions),this.getScreen().token&&(this.getScreen().token.text=t),this.updateInstructionText(),this.updateQrCode()},updateInstructionText:function(){this.instructionTexts.forEach(function(t){var e=this.getEmojiSubstitutedMessage(this.getInstructionText());t.removeAllChildren(),t.addChild(e)}.bind(this))},updateQrCode:function(){this.qrContainers.forEach(function(t){t.removeAllChildren(),this.controllerState.qrUrl&&i.generateQrCode(t,this.controllerState.qrUrl)}.bind(this)),this.qrInstructionsContainers.forEach(function(t){var e;t.removeAllChildren(),this.controllerState.qrUrl&&(e=this.getEmojiSubstitutedMessage(n.t("Scan QR code to connect")),t.addChild(e))}.bind(this))},removeAllUserIcons:function(){this.showInactivePlayers&&this.connectedUsers.removeAllChildren(),this.activeUsers.removeAllChildren()},reloadUserIcons:function(){var e=24,i=24;this.showInactivePlayers||(i=45),this.removeAllUserIcons(),this.users.forEach(function(t){t.active?i<=0||(i--,this.activeUsers.createElement(t)):!this.showInactivePlayers||e<=0||(e--,this.connectedUsers.createElement(t))}.bind(this))},setUserDetails:function(t,e){var i;e.profile&&t.userimage&&(i=new s.EaselJS.Placeholder(t.userimage),o.loadImage(e.profile.image).then(function(t){i.addChild(new s.EaselJS.Fill(t))}))},addAuthenticationView:function(){var t=this.Webcontrol.authenticationView(this.messageBus,{leanback:this.leanback});this.el.addChild(t),t.on("view:close",function(){t.easelboneLayer.view.trigger("stage:removed"),this.el.removeChild(t),this.messageBus.toController("auth:close")}.bind(this))},render:function(){this.el.addChild(this.getScreen()),this.refreshUsers()},destroy:function(){this.messageBus.removeViewListener(this)}})}),define("CatLab/Webremote/CreateJS/Views/AuthenticationView",["easelbone","CatLab/Webremote/CreateJS/Views/BaseView","CatLab/Webremote/Tools/Images","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/ImageLoader","CatLab/Webremote/Tools/QrGenerator","CatLab/Webremote/Messages/NavigateableProxy","CatLab/Webremote/Controllers/OAuth2"],function(n,t,e,o,r,a,i,s){return t.extend({initialize:function(t){var e;this.intitializeBaseView(),this.assets=t.assets,this.leanback=void 0!==t.leanback&&t.leanback,this.leanback?this.screen=new t.assets.SigninLeanback:this.screen=new t.assets.Signin,this.findFromNames(["close"],[this.screen]).forEach(function(t){t.on("click",function(){this.close()}.bind(this))}.bind(this)),this.screen.linkAccount&&(this.linkAccount=new n.Controls.Button(this.screen.linkAccount),this.linkAccount.on("click",function(){s.link(function(t){this.selectUser(t)}.bind(this))}.bind(this))),this.titlePlaceholder=null,this.explanationPlaceholder=null,n.Helpers.MovieClipHelper.findFromNames(["title"],[this.screen]).forEach(function(t){this.titlePlaceholder=new n.EaselJS.Placeholder(t)}.bind(this)),n.Helpers.MovieClipHelper.findFromNames(["explanation"],[this.screen]).forEach(function(t){this.explanationPlaceholder=new n.EaselJS.Placeholder(t)}.bind(this)),this.titlePlaceholder&&(e=new n.EaselJS.BigText(o.t("Select your profile"),null,null,"left"),this.titlePlaceholder.addChild(e)),this.qrContainers=this.findPlaceholders("qr",this.screen),this.qrInstructionsContainer=this.findPlaceholders("qrInstructions",this.screen),this.setLoginUrlText(),n.Helpers.MovieClipHelper.findFromNames("accounts",[this.screen]).forEach(function(t){t=new n.Controls.ScrollArea(t);this.users=new n.Controls.FloatContainer(function(t){return this.getUserObject(t)}.bind(this),4),t.content.addChild(this.users)}.bind(this)),this.updateUsers([]),this.on("removed",function(){this.trigger("close")}.bind(this)),this.setBack(function(){this.close()}.bind(this)),this.attachMessageBus(t.messageBus),this.on("stage:removed",this.destroy.bind(this))},attachMessageBus:function(t){(this.messageBus=t).addViewListener(this)},handleIncomingMessage:function(t,e){if(!i.handleMessage(t,e,this,"auth:"))switch(t){case"auth:users:update":this.updateUsers(e.users);break;case"auth:close":this.close();break;case"auth:loginurl":this.setLoginUrl(e.url);break;case"auth:destroy":this.destroy();break;case"labels:update":this.labels=e.labels,this.setLoginUrlText();break;case"auth:request-remove-selected-profile":this.removeSelectedUser()}},updateUsers:function(t){this.resetOptions(),this.users.removeAllChildren();for(var e=0;e<t.length;e++)this.users.createElement(t[e]);this.linkAccount&&this.addControl(this.linkAccount)},getUserObject:function(t){var e,i=new this.assets.UserModel,s=(i.namePlaceholder?i.text=i.namePlaceholder:i.name&&(i.text=i.name),new n.Controls.Button(i));return t&&(s.setText(t.name),e=new n.EaselJS.Placeholder(i.picture),r.loadImage(t.image).then(function(t){e.addChild(new n.EaselJS.Fill(t))}),s._userModel=t,s.on("click",function(){this.selectUser(t)}.bind(this)),this.addControl(s)),i},selectUser:function(t){this.messageBus.toController("auth:select-user",{user:{id:t.id}})},close:function(){this.trigger("close"),this.messageBus.toController("auth:close")},render:function(){this.el.addChild(this.screen)},setLoginUrl:function(t){this.loginUrl=t,this.setLoginUrlText()},setLoginUrlText:function(){if(this.linkAccount&&this.linkAccount.setText(o.t("Login to add profile")),this.explanationPlaceholder){var t,e=[],i={selectProfile:"%s to select",removeProfile:"%s to remove",close:"%s to close"};for(t in i){var s=this.getLabelSubstitutionOrNull(t,i[t]);s&&e.push(s)}this.explanationPlaceholder.removeAllChildren(),this.explanationPlaceholder.addChild(this.getEmojiSubstitutedMessage(e.join(", ")+"."))}this.loginUrl&&(this.qrContainers.forEach(function(t){"http"!==this.loginUrl.substring(0,4)&&(this.loginUrl="https://"+this.loginUrl),t.removeAllChildren(),a.generateQrCode(t,this.loginUrl)}.bind(this)),this.qrInstructionsContainer.forEach(function(t){var e=o.t("Scan to login or surf to %s",this.loginUrl);t.addChild(new n.EaselJS.BigText(e))}.bind(this)))},removeSelectedUser:function(){var t=this._current;t&&t._userModel?this.messageBus.toController("auth:remove-user",{user:{id:this._current._userModel.id}}):console.log("No current control")},destroy:function(){this.messageBus.removeViewListener(this)}})}),define("CatLab/Webremote/CreateJS/Views/AlertView",["easelbone","CatLab/Webremote/Tools/Translator","CatLab/Webremote/CreateJS/Views/BaseView"],function(n,o,t){return t.extend({initialize:function(i){"confirm"===(this.intitializeBaseView(),this.easelScreen=new i.assets.Alert,this.findPlaceholders("message").forEach(function(t){var e=new n.EaselJS.BigText(i.message);t.addChild(e)}),void 0===i.type&&(i.type="alert"),i.type.toLowerCase())?this.initializeConfirm(i):this.initializeAlert(i)},initializeAlert:function(t){var e=o.t("OK");void 0!==t.buttonLabel&&(e=t.buttonLabel),this.findFromNames("button").forEach(function(t){t=new n.Controls.Button(t);t.setText(e),this.addControl(t),t.click(function(){this.close()}.bind(this))}.bind(this)),setTimeout(function(){this.jumpToFrame("oneButton")}.bind(this),0)},initializeConfirm:function(e){var i=o.t("OK"),s=(void 0!==e.okLabel&&(i=e.okLabel),o.t("Cancel"));void 0!==e.cancelLabel&&(s=e.cancelLabel),this.findFromNames("button1").forEach(function(t){t=new n.Controls.Button(t);t.setText(i),this.addControl(t),t.click(function(){"function"!=typeof e.ok?this.close():e.ok(this)}.bind(this))}.bind(this)),this.findFromNames("button2").forEach(function(t){t=new n.Controls.Button(t);t.setText(s),this.addControl(t),t.click(function(){"function"!=typeof e.cancel?this.close():e.cancel(this)}.bind(this))}.bind(this)),setTimeout(function(){this.jumpToFrame("twoButtons")}.bind(this),0)},close:function(){this.trigger("view:close")},render:function(){this.el.addChild(this.easelScreen)}})}),s=i=i||{},h=h||{},t=a=a||{},void 0!==t.Container&&(s.properties={width:720,height:480,fps:24,color:"#FFFFFF",manifest:[]},(s.UserIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#592230").s().p("Al2F2IAArsILsAAIAALsg"),this.shape.setTransform(37.5,37.5),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,75,75),e.frameBounds=[A],(s.TextPlaceholderBackground=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FF00FF").s().p("AnzHzIAAvmIPmAAIAAPmg"),this.shape.setTransform(50,50),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,100,100),e.frameBounds=[A],(s.Marker=function(){this.initialize()}).prototype=e=new t.Container,e.nominalBounds=A=null,e.frameBounds=[A],(s.PointerInactive=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#320B1F").s().p("AjQiRIENALICfCGIiTCHIkkALg"),this.shape.setTransform(-22,0),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-44,-14.7,44.1,29.4),e.frameBounds=[A],(s.PointerActive=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#006633").s().p("AjQiRIENALICfCGIiTCHIkkALg"),this.shape.setTransform(-22,.1),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-44,-14.6,44.1,29.4),e.frameBounds=[A],(s.Checkbox=function(e,i,s){this.initialize(e,i,s=null==s?!1:s,{Up:0,Over:1,Down:2,Hit:3}),this.frame_0=function(){this.stop()},this.frame_1=function(){this.stop()},this.frame_2=function(){this.stop()},this.frame_3=function(){this.stop()},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(1).call(this.frame_1).wait(1).call(this.frame_2).wait(1).call(this.frame_3).wait(1)),this.shape=new t.Shape,this.shape.graphics.f("#FF873C").s().p("AizAVQgagpgVgoIgXgsIADgQIADgEQAFgEAJgCQAKAZATAkQANAYASAdQAxBQAOAeQALg8CFhhIAIgGQCGhhA7AVIAGgCQAEACABAPQgmAPg/ApQgpAcgpAiQhQBChRBfQgngxguhPg"),this.shape.setTransform(25,23),this.shape._off=!0,this.timeline.addTween(t.Tween.get(this.shape).wait(2).to({_off:!1},0).wait(2)),this.shape_1=new t.Shape,this.shape_1.graphics.f().s("#8B504F").ss(5).p("ABfheIAAC9Ii9AAIAAi9g"),this.shape_1.setTransform(19.2,19.2,2.023,2.023),this.shape_2=new t.Shape,this.shape_2.graphics.f("#592230").s().p("AheBeIAAi8IC9AAIAAC8g"),this.shape_2.setTransform(19.2,19.2,2.023,2.023),this.shape_3=new t.Shape,this.shape_3.graphics.f("#FFC39F").s().p("AheBeIAAi8IC9AAIAAC8g"),this.shape_3.setTransform(19.2,19.2,2.023,2.023),this.shape_4=new t.Shape,this.shape_4.graphics.f().s("#8B504F").ss(5).p("ADAi/IAAF/Il/AAIAAl/g"),this.shape_4.setTransform(-13.2,12.3,1,1,0,0,0,-32.4,-6.9),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_2},{t:this.shape_1,p:{x:19.2,y:19.2}}]}).to({state:[{t:this.shape_3,p:{x:19.2,y:19.2}},{t:this.shape_1,p:{x:19.2,y:19.2}}]},1).to({state:[{t:this.shape_2},{t:this.shape_1,p:{x:19.2,y:19.2}}]},1).to({state:[{t:this.shape_4},{t:this.shape_3,p:{x:19.4,y:18.9}},{t:this.shape_1,p:{x:19.4,y:18.9}}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-2.5,-2.5,43.5,43.4),e.frameBounds=[A,A,new t.Rectangle(-2.5,-2.5,52.5,43.4),new t.Rectangle(-2.5,-2.8,52.5,43.7)],(s.CogVector=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#282A1F").s().p("Ag/MAQgehhgLhlQgbgEgvgOIgkgNQgUgIgOgIQhLBKhXA3QgsgbgwgqQAkhoAvhQQgdgegUgdQgKgLgLgUIgUghQhpAQhlgGQgVg1gNg5QBOg4BhgtQgCgPgBgXIgCglQABgxAEgZQhggzhMg/QAIgiAchLQBoABBhAVQAZgtAQgTQAUgdAdgeQgshWgdhrQA9gwAhgTQBQA8BGBMQAOgIAUgIIAkgNQAvgNAbgFQAShsAlhbQAwgEBBAFQAeBhALBlQAbAFAvANIAkANQAUAIAOAIQBLhKBXg3QAsAbAwAqQgkBogvBQQAdAeAUAdQAQATAZAtQBpgQBlAGQAWA5AMA1QhOA4hhAtQAEAZABAxIgCAlQgBAXgCAPQBgAzBMA/QgHAigdBLQhogBhhgVQgZAtgQATQgUAdgdAeQAsBWAdBrQg9AwghATQhQg8hGhMQgOAIgUAIIgkANQgvAOgbAEQgSBsglBbQgXACgaAAQgdAAgjgDgAhtlTQg3ASgtAhQgvAiggAtQhDBagCB3QACB4BDBaQAgAtAvAiQAtAhA3ASQA1ASA4AAQA5AAA1gSQA3gSAtghQAvgiAggtQBDhaACh4QgCh3hDhaQgggtgvgiQgtghg3gSQg1gRg5AAQg4AAg1ARg"),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-75,-77.1,150.1,154.3),e.frameBounds=[A],(s.ListUsers=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#00CCFF").s().p("A5DK/IAA19MAyHAAAIAAV9g"),this.shape.setTransform(158.5,71),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-2,.6,320.9,140.7),e.frameBounds=[A],(s.lstUsers=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#0066CC").s().p("A5YGoIAAtQMAywAAAIAANQg"),this.shape.setTransform(162.5,42.5),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,325,85),e.frameBounds=[A],(s.SmartphoneIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AhNCvQgJAAgHgIQgHgGAAgKIAAksQAAgLAHgGQAHgIAJAAICaAAQAKAAAHAIQAHAGAAALIAAEsQAAAKgHAGQgHAIgKAAgAgHCPQgEADAAAFQAAAFAEADQAEAEADAAQAEAAAEgEQADgDAAgFQAAgFgDgDQgEgDgEAAQgDAAgEADgAhUCDICoAAIAAkLIioAAgAgaiaQAAABAAABQAAAAAAABQABAAAAAAQABABABAAIAwAAQAAAAABgBQAAAAAAAAQABgBAAAAQAAgBAAgBQAAAAAAgBQAAAAgBAAQAAgBAAAAQgBAAAAAAIgwAAQgBAAgBAAQAAAAgBABQAAAAAAAAQAAABAAAAg"),this.shape.setTransform(42.9,42,1.857,1.857),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(24.1,9.5,37.7,65),e.frameBounds=[A],(s.TabletIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AhvCeQgKAAgHgHQgGgHAAgJIAAkNQAAgKAGgGQAHgHAKAAIDfAAQAKAAAGAHQAHAHAAAJIAAENQAAAJgHAHQgGAHgKAAgAgeCLIA8AAIAAgHIg8AAgAhvBuIDfAAIAAjvIjfAAg"),this.shape.setTransform(43,43,1.642,1.642),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(20.8,17,44.6,52.1),e.frameBounds=[A],(s.JoystickIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AA1BaQgYgagdABQgdgBgYAaQgYAZgNAAQgMAAgIgMQgIgMgBgUQABgqAVggQAUgeAVAAQANAAANAIQAOAJAIACQACgXALgPQASgVAlgBQAYAAALgOQAEgHAAgJQAAgKALAAQADABADACQAEAEAAADQAAASgNAOQgQASgfABQgsAAgGAmQAGgBAQgJQAMgJANABQAUAAAUAeQAXAgAAAqQgBAVgIAMQgJALgMAAQgMAAgZgZgAAzAuQgEAEAAAFQAAAFADAEQAEADAGAAQAFABADgEQAEgEAAgFQAAgFgEgEQgEgEgEgBQgFABgEAEgAhZAtIAVAAIAAAUIAUAAIAAgUIATAAIAAgUIgTAAIAAgVIgUAAIAAAVIgVAAgABGAaQgDADAAAGQAAAFADAEQAFADAEAAQAFAAAEgDQAEgFAAgEQAAgGgEgDQgEgFgFAAQgEAAgFAFgAAeAaQgEADAAAGQAAAFAEAEQAEADAFAAQAGAAADgDQAEgEAAgFQAAgGgDgDQgFgFgEAAQgFAAgFAFgAAyAFQgDAFAAAEQAAAGAEAEQAEAEAFAAQAEAAAEgEQAEgEAAgGQAAgEgEgFQgEgEgEAAQgGAAgEAEg"),this.shape.setTransform(42,42,2.476,2.476),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(12.3,13.5,59.5,57),e.frameBounds=[A],(s.KeyboardIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AkMEzQgiAAgXgWQgYgXAAgjIAAjYQAAggAYgXQAXgXAiAAID3AAQAAhLAkgeQAWgTA0gHQApgFAOgLQAUgRAAg1QAAgWAXAAQAXAAABAWQAABOgoAeQgWASg1AHQgpAGgOAKQgUAQAAA0ID2AAQAjAAAWAXQAZAXAAAgIAADYQAAAjgZAXQgWAWgjAAgADWDjIA1AAIAAg1Ig1AAgAi8DjIF3AAIAAg1Il3AAgAkMDjIA1AAIAAg1Ig1AAgACgCTIA2AAIAAg4Ig2AAgABQCTIA1AAIAAg4Ig1AAgAAACTIA1AAIAAg4Ig1AAgAhRCTIA2AAIAAg4Ig2AAgAihCTIA1AAIAAg4Ig1AAgAjyCTIA2AAIAAg4Ig2AAgADWBBIA1AAIAAg2Ig1AAgACFBBIA2AAIAAg2Ig2AAgAA1BBIA1AAIAAg2Ig1AAgAgbBBIA1AAIAAg2Ig1AAgAhsBBIA2AAIAAg2Ig2AAgAi8BBIA2AAIAAg2Ig2AAgAkMBBIA1AAIAAg2Ig1AAg"),this.shape.setTransform(42,41.8,.773,.773),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(15,18,54.1,47.6),e.frameBounds=[A],(s.CloseButton=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f().s("#000000").ss(1,1,1).p("AAPABQAjgvAAgXQAhhJAIgLAhjiQIByCRAiICaIBLAAQAjhXAgg2QAFgGAEgGIB6CZ"),this.shape.setTransform(10,19.5),this.shape_1=new t.Shape,this.shape_1.graphics.f("#666666").s().p("Ai+C/IAAl9IF9AAIAAF9g"),this.shape_1.setTransform(12.6,19.4),this.addChild(this.shape_1,this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-6.6,.3,38.3,38.3),e.frameBounds=[A],(s.btnLink=function(){this.initialize(),this.text=new t.Text("Link a new account","20px 'Times New Roman'","#FF0033"),this.text.lineHeight=22,this.text.lineWidth=235,this.text.setTransform(2.3,-1.7),this.shape=new t.Shape,this.shape.graphics.f("#666666").s("#FFFFFF").ss(1,1,1).dr(-83.5,-13,167,26),this.shape.setTransform(83.5,13),this.addChild(this.shape,this.text)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-1,-1.7,242.5,28.7),e.frameBounds=[A],(s.Placeholder=function(){this.initialize(),this.instance=new s.TextPlaceholderBackground,this.addChild(this.instance)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,100,100),e.frameBounds=[A],(s.Pointer=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Up:0,Over:1,Down:2,Out:3}),this.instance=new s.PointerInactive("synched",0,!1),this.instance.setTransform(3,5,.639,.774,90,0,0,7.8,-3.9),this.instance_1=new s.PointerActive("synched",0),this.instance_1.setTransform(3,5,.639,.774,90,0,0,7.8,-3.9),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.instance}]}).to({state:[{t:this.instance_1,p:{x:3,y:5}}]},1).to({state:[{t:this.instance_1,p:{x:3,y:5}}]},1).to({state:[{t:this.instance_1,p:{x:3.1,y:5.1}}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-11.4,-28.1,22.8,28.2),e.frameBounds=[A,A,A,new t.Rectangle(-11.4,-28,22.8,28.2)],(s.Button=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Over:1,"Over-NoAnim":6,Up:7,"Up-NoAnim":11,Down:12,Hit:13}),this.frame_0=function(){this.stop()},this.frame_6=function(){this.stop()},this.frame_11=function(){this.stop()},this.frame_12=function(){this.stop()},this.frame_13=function(){this.stop()},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(6).call(this.frame_6).wait(5).call(this.frame_11).wait(1).call(this.frame_12).wait(1).call(this.frame_13).wait(1)),this.text=new s.Placeholder,this.text.setTransform(13.7,13.7,1.739,.494,0,.4,.5,.1,.8),this.timeline.addTween(t.Tween.get(this.text).wait(1).to({scaleX:1.89,rotation:.4,skewX:0,skewY:0,x:5.7},0).to({scaleY:.57,rotation:5.4,x:8.7,y:1.7},5).to({scaleY:.54,rotation:5.2,x:8.4,y:2},1).to({scaleY:.49,rotation:.4,x:5.7,y:13.7},4).wait(1).to({rotation:.4},0).wait(2)),this.shape=new t.Shape,this.shape.graphics.f("#0F0609").s().p("A42D+Ii+oDMA3pgAIIkyIbg"),this.shape.setTransform(103.3,39.2,.566,1),this.shape_1=new t.Shape,this.shape_1.graphics.f("#0F0609").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_1.setTransform(103.4,39.1,.821,.821),this.shape_2=new t.Shape,this.shape_2.graphics.f("#0F0609").s().p("AuwDkIhboZMAgWABDIjGIog"),this.shape_2.setTransform(104.2,39.3),this.shape_3=new t.Shape,this.shape_3.graphics.f("#0F0609").s().p("AvXDTIhOoqMAhLAB9IjaIyg"),this.shape_3.setTransform(104.8,39),this.shape_4=new t.Shape,this.shape_4.graphics.f("#0F0609").s().p("AvzDHIhFo2MAhxACmIjpI5g"),this.shape_4.setTransform(105.2,38.9),this.shape_5=new t.Shape,this.shape_5.graphics.f("#0F0609").s().p("AwEDAIhAo+MAiJADAIjyI9g"),this.shape_5.setTransform(105.5,38.7),this.shape_6=new t.Shape,this.shape_6.graphics.f("#0F0507").s().p("AvmDNIhKoxMAhhACUIjiI1g"),this.shape_6.setTransform(105,38.9),this.shape_7=new t.Shape,this.shape_7.graphics.f("#0F0305").s().p("AvDDbIhVohMAgxABgIjRItg"),this.shape_7.setTransform(104.5,39.2),this.shape_8=new t.Shape,this.shape_8.graphics.f("#0F0202").s().p("AugDrIhgoTMAgBAAsIi+Ikg"),this.shape_8.setTransform(103.9,39.4),this.shape_9=new t.Shape,this.shape_9.graphics.f("#0F0000").s().p("At9D+IhroDIfRgIIisIbg"),this.shape_9.setTransform(103.4,39.2),this.shape_10=new t.Shape,this.shape_10.graphics.f("#990000").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_10.setTransform(103.4,39.1,.821,.821),this.shape_11=new t.Shape,this.shape_11.graphics.f("#0F51B8").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_11.setTransform(103.4,39.1,.821,.821),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape}]}).to({state:[{t:this.shape_1,p:{scaleX:.821,scaleY:.821,rotation:0,x:103.4,y:39.1}}]},1).to({state:[{t:this.shape_2}]},1).to({state:[{t:this.shape_3}]},1).to({state:[{t:this.shape_4}]},1).to({state:[{t:this.shape_5}]},1).to({state:[{t:this.shape_1,p:{scaleX:.903,scaleY:.903,rotation:5.4,x:102.8,y:39.2}}]},1).to({state:[{t:this.shape_1,p:{scaleX:.903,scaleY:.903,rotation:5.4,x:102.8,y:39.2}}]},1).to({state:[{t:this.shape_6}]},1).to({state:[{t:this.shape_7}]},1).to({state:[{t:this.shape_8}]},1).to({state:[{t:this.shape_9}]},1).to({state:[{t:this.shape_10}]},1).to({state:[{t:this.shape_11}]},1).wait(1)),this.shape_12=new t.Shape,this.shape_12.graphics.f().s("#0F0609").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_12.setTransform(103.9,39.4,.826,.821,0,0,0,-.2,0),this.shape_13=new t.Shape,this.shape_13.graphics.f().s("#0A6006").ss(2).p("Aw0kaMAhpgAsIiVJgI9lAtg"),this.shape_13.setTransform(103.5,39.3,1,1,0,0,0,.1,0),this.shape_14=new t.Shape,this.shape_14.graphics.f().s("#05A503").ss(2).p("AxSkVMAikgBFIiSJyI+ZBDg"),this.shape_14.setTransform(103.1,39.2,1,1,0,0,0,.1,0),this.shape_15=new t.Shape,this.shape_15.graphics.f().s("#02D701").ss(2).p("AxmkRMAjNgBYIiQKAI+9BTg"),this.shape_15.setTransform(102.7,39.2,1,1,0,0,0,.1,0),this.shape_16=new t.Shape,this.shape_16.graphics.f().s("#01F500").ss(2).p("AxykPMAjlgBiIiOKHI/UBdg"),this.shape_16.setTransform(102.5,39.1,1,1,0,0,0,.1,0),this.shape_17=new t.Shape,this.shape_17.graphics.f().s("#00FF00").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_17.setTransform(103.4,39.4,.903,.903,-2.2,0,0,-.2,0),this.shape_18=new t.Shape,this.shape_18.graphics.f().s("#0FFF00").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_18.setTransform(103.4,39.4,.903,.903,-2.2,0,0,-.2,0),this.shape_19=new t.Shape,this.shape_19.graphics.f().s("#0FC102").ss(2).p("AxdkTMAi6gBPIiQJ6I+uBMg"),this.shape_19.setTransform(102.9,39.2,1,1,0,0,0,.1,0),this.shape_20=new t.Shape,this.shape_20.graphics.f().s("#0F8305").ss(2).p("AxDkXMAiGgA5IiTJpI9/A4g"),this.shape_20.setTransform(103.3,39.3,1,1,0,0,0,.1,0),this.shape_21=new t.Shape,this.shape_21.graphics.f().s("#0F4407").ss(2).p("AwpkbMAhSgAjIiVJZI9SAkg"),this.shape_21.setTransform(103.7,39.3,1,1,0,0,0,.1,0),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_12}]}).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_13}]},1).to({state:[{t:this.shape_14}]},1).to({state:[{t:this.shape_15}]},1).to({state:[{t:this.shape_16}]},1).to({state:[{t:this.shape_17}]},1).to({state:[{t:this.shape_18}]},1).to({state:[{t:this.shape_19}]},1).to({state:[{t:this.shape_20}]},1).to({state:[{t:this.shape_21}]},1).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_12}]},1).wait(1)),this.timeline.addTween(t.Tween.get(this.shape_12).wait(1).to({scaleX:.82},0).to({_off:!0},1).wait(9).to({_off:!1},0).wait(3)),this.shape_22=new t.Shape,this.shape_22.graphics.f("#592230").s().p("A0sFHIAysmMAonACoIloMXg"),this.shape_22.setTransform(109.6,39.4,.826,.821),this.shape_23=new t.Shape,this.shape_23.graphics.f("#592230").s().p("AxqECIA4qsMAidAC7Ik/Kag"),this.shape_23.setTransform(109.5,39.1),this.shape_24=new t.Shape,this.shape_24.graphics.f("#592230").s().p("AyMD5IBDq8MAjXADgIlTKng"),this.shape_24.setTransform(109.6,38.9),this.shape_25=new t.Shape,this.shape_25.graphics.f("#592230").s().p("AylD0IBMrKMAj/AD8IlfKxg"),this.shape_25.setTransform(109.5,38.8),this.shape_26=new t.Shape,this.shape_26.graphics.f("#592230").s().p("Ay0DwIBRrRMAkYAEMIlnK3g"),this.shape_26.setTransform(109.5,38.7),this.shape_27=new t.Shape,this.shape_27.graphics.f("#592230").s().p("AyaD2IBIrEMAjtADwIlZKsg"),this.shape_27.setTransform(109.6,38.9),this.shape_28=new t.Shape,this.shape_28.graphics.f("#592230").s().p("Ax7D9IA9q0MAi7ADOIlKKhg"),this.shape_28.setTransform(109.6,39.1),this.shape_29=new t.Shape,this.shape_29.graphics.f("#592230").s().p("AxdEFIA0qlMAiGACsIk3KVg"),this.shape_29.setTransform(109.6,39.2),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_22}]}).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_23}]},1).to({state:[{t:this.shape_24}]},1).to({state:[{t:this.shape_25}]},1).to({state:[{t:this.shape_26}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_27}]},1).to({state:[{t:this.shape_28}]},1).to({state:[{t:this.shape_29}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).wait(1)),this.timeline.addTween(t.Tween.get(this.shape_22).wait(1).to({scaleX:.82,x:109.5},0).to({_off:!0},1).wait(4).to({_off:!1,scaleX:.9,scaleY:.9,rotation:3,x:109.6},0).wait(1).to({_off:!0},1).wait(3).to({_off:!1,scaleX:.82,scaleY:.82,rotation:0,x:109.5},0).wait(3))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-1.8,0,220.9,78.8),e.frameBounds=[A,new t.Rectangle(-1.1,0,219.5,78.8),new t.Rectangle(-5.5,-3.6,228.3,85.4),new t.Rectangle(-8.9,-6.3,235.1,90.6),new t.Rectangle(-11.3,-8.3,240,94.3),new t.Rectangle(-12.8,-9.5,242.9,96.5),A=new t.Rectangle(-13.3,-9.9,243.9,97.2),A,new t.Rectangle(-10.2,-7.4,237.8,92.6),new t.Rectangle(-7.2,-4.9,231.7,88),new t.Rectangle(-4.1,-2.5,225.5,83.4),A=new t.Rectangle(-1.1,0,219.5,78.8),A,A],(s.Cog=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{}),this.frame_14=function(){this.gotoAndPlay(1)},this.timeline.addTween(t.Tween.get(this).wait(14).call(this.frame_14).wait(1)),this.instance=new s.CogVector("synched",0),this.instance.setTransform(75.1,77.1),this.timeline.addTween(t.Tween.get(this.instance).to({rotation:36},14).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(0,0,150.2,154.3),e.frameBounds=[A,new t.Rectangle(-.6,.1,151.6,154.2),new t.Rectangle(-1.2,.1,152.7,154.1),new t.Rectangle(-1.6,.3,153.5,153.8),new t.Rectangle(-1.9,.6,154,153.1),new t.Rectangle(-2,1.1,154.1,152.1),new t.Rectangle(-2,1.7,154.1,151),new t.Rectangle(-2,2.2,154.1,149.9),new t.Rectangle(-2,1.5,154.1,151.3),new t.Rectangle(-2,1,154.1,152.4),new t.Rectangle(-1.8,.6,153.8,153.3),new t.Rectangle(-1.4,.2,153,153.8),new t.Rectangle(-1,.2,152.2,154),new t.Rectangle(-.4,.2,150.9,154),new t.Rectangle(0,.1,150.2,154.1)],(s.Signin=function(){this.initialize(),this.close=new s.CloseButton,this.close.setTransform(526.3,132.5,1,1,0,0,0,10,19.5),this.users=new s.ListUsers,this.users.setTransform(206.7,159.2);var e=new t.Shape;e._off=!0,e.graphics.p("A4tIoIAAsrMAypAAAIAAMrg"),e.setTransform(166.1,55.3),this.btnLinkAccount=new s.btnLink,this.btnLinkAccount.setTransform(367.6,325.3,1,1,0,0,0,83.5,13),this.title=new t.Text("Select your profile","20px 'Times New Roman'","#FFFFFF"),this.title.name="title",this.title.lineHeight=22,this.title.lineWidth=217,this.title.setTransform(202.8,116.1),this.shape=new t.Shape,this.shape.graphics.f("#999999").s().p("A68SPMAAAgkdMA15AAAMAAAAkdg"),this.shape.setTransform(367.5,229.7),this.shape_1=new t.Shape,this.shape_1.graphics.f("rgba(0,0,0,0.498)").s().p("Eg4TAlfMAAAhK9MBwnAAAMAAABK9g"),this.shape_1.setTransform(359.5,240),this.addChild(this.shape_1,this.shape,this.title,this.btnLinkAccount,this.users,this.close)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-1,0,721,480),e.frameBounds=[A],(s.PortalView=function(){this.initialize(),this.ListActiveUsers=new s.lstUsers,this.ListActiveUsers.setTransform(523.3,139.8,1,1,0,0,0,162.2,42),this.ListConnectedDevices=new s.lstUsers,this.ListConnectedDevices.setTransform(190.3,139.8,1,1,0,0,0,163.3,42),this.shape=new t.Shape,this.shape.graphics.f().s("rgba(255,255,255,0)").ss(.1,1,1).p("AvJkmIeTAAIAAJNI+TAAg"),this.shape.setTransform(327,308.5),this.text=new t.Text("Active users","30px 'Times New Roman'","#FFFFFF"),this.text.lineHeight=32,this.text.lineWidth=284,this.text.setTransform(374,25.3),this.text_1=new t.Text("Connected users","30px 'Times New Roman'","#FFFFFF"),this.text_1.lineHeight=32,this.text_1.lineWidth=284,this.text_1.setTransform(27,25.3),this.shape_1=new t.Shape,this.shape_1.graphics.f().s("#666666").ss(1,1,1).p("EgzYAAAMBmyAAA"),this.shape_1.setTransform(357.1,65),this.shape_2=new t.Shape,this.shape_2.graphics.rf(["#333333","#000000","#000000"],[0,.6,1],0,0,0,0,0,432.7).s().p("Eg4PAlfMAAAhK+MBwfAAAMAAABK+gEAy8gbVMhmyAAAg"),this.shape_2.setTransform(360,240),this.addChild(this.shape_2,this.shape_1,this.text_1,this.text,this.shape,this.ListConnectedDevices,this.ListActiveUsers)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,720,480),e.frameBounds=[A],(s.User=function(){this.initialize(),this.boundary=new s.Marker,this.boundary.setTransform(79.4,118.4),this.picture=new s.Placeholder,this.picture.setTransform(37.5,37.5,.75,.75,0,0,0,50,50),this.name=new t.Text("User","15px 'Times New Roman'"),this.name.name="name",this.name.lineHeight=17,this.name.lineWidth=71,this.name.setTransform(0,75),this.shape=new t.Shape,this.shape.graphics.f("rgba(0,0,0,0.498)").s().p("Al2F2IAArsILsAAIAALsg"),this.shape.setTransform(37.5,37.5),this.addChild(this.shape,this.name,this.picture,this.boundary)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,75,114.2),e.frameBounds=[A],(s.Slider=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Up:0,Over:1,Down:2,Hit:3}),this.frame_0=function(){this.pointer.gotoAndStop("Up"),this.stop()},this.frame_1=function(){this.stop(),this.pointer.gotoAndStop("Over")},this.frame_2=function(){this.stop(),this.pointer.gotoAndStop("Down")},this.frame_3=function(){this.stop(),this.pointer.gotoAndStop("Out")},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(1).call(this.frame_1).wait(1).call(this.frame_2).wait(1).call(this.frame_3).wait(1)),this.pointer=new s.Pointer,this.pointer.setTransform(35,41.1,1,1,0,0,0,0,2),this.maximum=new s.Marker,this.maximum.setTransform(342,35),this.minimum=new s.Marker,this.minimum.setTransform(35,41),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.minimum},{t:this.maximum},{t:this.pointer}]}).wait(4)),this.shape=new t.Shape,this.shape.graphics.f().s("#320B1F").ss(4).p("AgY4mMAAxAxN"),this.shape.setTransform(186,26.5,1.113,1.111,-90,0,0,.1,0),this.shape_1=new t.Shape,this.shape_1.graphics.f("#320B1F").s().p("AgnAoQgQgRAAgXQAAgWAQgRQARgQAWAAQAXAAARAQQAQARAAAWQAAAXgQARQgRAQgXAAQgWAAgRgQg"),this.shape_1.setTransform(9.6,31.4,1.694,1.694,-90),this.shape_2=new t.Shape,this.shape_2.graphics.f("#320B1F").s().p("AgkAlQgQgPAAgWQAAgUAQgQQAPgQAVAAQAVAAAQAQQAQAQAAAUQAAAWgQAPQgQAQgVAAQgVAAgPgQg"),this.shape_2.setTransform(370.1,24,1.694,1.694,-90),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]}).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(0,10.9,379.1,30.1),e.frameBounds=[A,A,A,A],(s.portal=function(){this.initialize(),this.instance=new s.Signin,this.instance.setTransform(172.5,116.7,1,1,0,0,0,172.5,116.7),this.addChild(this.instance)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(359,240,721,480),e.frameBounds=[A]),define("CatLab/Webremote/assets/createjsassets",(t=>function(){return t.ctlbrmtassets})(this)),define("CatLab/Webremote/ViewFactory/CreatejsViewFactory",["CatLab/Webremote/Tools/Deferred"],function(e){function t(t){void 0!==t&&this.setAssets(t)}var r,a,h,l,i=t.prototype;return i.initialize=function(){var t=new e;return this.loadAssets().then(function(){this.setAssets(this.assets),t.resolve()}.bind(this)),t},i.loadAssets=function(){var o=new e;return require(["CatLab/Webremote/CreateJS/LayerContainer","CatLab/Webremote/CreateJS/Views/PortalView","CatLab/Webremote/CreateJS/Views/AuthenticationView","CatLab/Webremote/CreateJS/Views/AlertView","CatLab/Webremote/assets/createjsassets"],function(t,e,i,s,n){r=t,a=e,h=i,l=s,o.resolve()}.bind(this)),o.promise()},i.portal=function(t){return t.assets=this.assets,new a(t)},i.authentication=function(t){return t.assets=this.assets,new h(t)},i.alert=function(t){return t.assets=this.assets,new l(t)},i.setAssets=function(t){void 0!==t&&(this.assets=t)},i.getContainer=function(){var t=new r;return t.setBounds(0,0,this.assets.properties.width,this.assets.properties.height),t.loading(),t},t}),define("CatLab/Webremote/FrontWebcontrol",["CatLab/Webremote/Config","CatLab/Webremote/Polyfills","CatLab/Webremote/Tools/Tracker","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/Webcontrol","CatLab/Webremote/Tools/Smileys","CatLab/Webremote/Tools/Images","CatLab/Webremote/Models/Users/KeyboardUser","CatLab/Webremote/Models/Users/CordovaUser","CatLab/Webremote/Models/Users/AndroidRemoteUser","CatLab/Webremote/Models/Users/DummyUser","CatLab/Webremote/Providers/SocketIO","CatLab/Webremote/Providers/Airconsole","CatLab/Webremote/ViewFactory/ViewFactory","CatLab/Webremote/ViewFactory/CreatejsViewFactory","CatLab/Webremote/Messages/NavigateableProxy"],function(e,t,i,s,n,o,r,a,h,l,c,u,d,f,g,p,m){return{Config:function(t){e.set(t)},Tracker:i,Tools:s,Webcontrol:new o,OAuth2:n,Controls:{Keyboard:h,Cordova:l,AndroidRemote:c,Dummy:u},Controllers:{Webcontrol:o},Models:{User:u},Providers:{SocketIO:d,Airconsole:f},ViewFactories:{HtmlViewFactory:g,CreatejsViewFactory:p},Smileys:r,Images:new a,NavigateableProxy:m}}),define("webcontrol",["CatLab/Webremote/FrontWebcontrol"],function(t){return t}),define("CatLab/EaselHacks/AlphaMaskFilter",[],function(t){function e(t){var s=this;this.createjs=t,Object.defineProperty(t.DisplayObject.prototype,"mask",{get:function(){return this.forceMask},set:function(t){var e,i=this;t?(i.originalMask=t,e=s.getFilterFromMask(t,i),i.filters=[e],i.cache(0,0,500,500)):null!==t&&(i.filters=null,i.cache(0,0,500,500))}}),t.DisplayObject.prototype.setMask=function(t){this.forceMask=t}}return e.prototype.getFilterFromMask=function(t,e){var i=this.createjs,s=t.graphics.getInstructions(),n=new i.Graphics;n.beginFill("#000000"),n.beginStroke("#000000");for(var o=0;o<s.length;o++)n.append(s[o]);t.graphics=n;var r=new i.Container,t=(r.addChild(t),r.scaleX=1/e.scaleX,r.scaleY=1/e.scaleY,r.y=-e.y,r.x=-e.x,new i.Container);return t.addChild(r),t.cache(0,0,1e3,1e3),new i.AlphaMaskFilter(t.cacheCanvas)},e}),define("CatLab/EaselHacks/FrontController",["CatLab/EaselHacks/AlphaMaskFilter"],function(t){return{AlphaMaskFilter:t}}),define("easelhacks",["CatLab/EaselHacks/FrontController"],function(t){return t}),define("CatLab/Webremote/Hacks",["easelhacks","easeljs"],function(t,e){new t.AlphaMaskFilter(e)});
|
|
1
|
+
var s,t,e,A,i,h,a;define("CatLab/Webremote/Tools/Net",[],function(){return{loadJSON:function(e,t,i){var s=new XMLHttpRequest;s.onreadystatechange=function(){s.readyState===XMLHttpRequest.DONE&&200===s.status&&t&&t(JSON.parse(s.responseText))},s.onerror=function(e){e&&i(s,e)},s.open("GET",e,!0),s.send()}}}),define("CatLab/Webremote/Tools/Deferred",[],function(){function l(e){return"[object Array]"===Object.prototype.toString.call(e)}function c(e,t){if(l(e))for(var i=0;i<e.length;i++)t(e[i]);else t(e)}function u(e){var s="pending",n=[],o=[],r=[],a=null,i={done:function(){for(var e=0;e<arguments.length;e++)if(arguments[e])if(l(arguments[e]))for(var t=arguments[e],i=0;i<t.length;i++)"resolved"===s&&t[i].apply(this,a),n.push(t[i]);else"resolved"===s&&arguments[e].apply(this,a),n.push(arguments[e]);return this},fail:function(){for(var e=0;e<arguments.length;e++)if(arguments[e])if(l(arguments[e]))for(var t=arguments[e],i=0;i<t.length;i++)"rejected"===s&&t[i].apply(this,a),o.push(t[i]);else"rejected"===s&&arguments[e].apply(this,a),o.push(arguments[e]);return this},always:function(){return this.done.apply(this,arguments).fail.apply(this,arguments)},progress:function(){for(var e=0;e<arguments.length;e++)if(arguments[e])if(l(arguments[e]))for(var t=arguments[e],i=0;i<t.length;i++)"pending"===s&&r.push(t[i]);else"pending"===s&&r.push(arguments[e]);return this},then:function(){1<arguments.length&&arguments[1]&&this.fail(arguments[1]),0<arguments.length&&arguments[0]&&this.done(arguments[0]),2<arguments.length&&arguments[2]&&this.progress(arguments[2])},promise:function(e){if(null==e)return i;for(var t in i)e[t]=i[t];return e},state:function(){return s},debug:function(){console.log("[debug]",n,o,s)},isRejected:function(){return"rejected"===s},isResolved:function(){return"resolved"===s},pipe:function(e,t,i){return u(function(i){c(e,function(t){"function"==typeof t?h.done(function(){var e=t.apply(this,arguments);e&&"function"==typeof e?e.promise().then(i.resolve,i.reject,i.notify):i.resolve(e)}):h.done(i.resolve)}),c(t,function(t){"function"==typeof t?h.fail(function(){var e=t.apply(this,arguments);e&&"function"==typeof e?e.promise().then(i.resolve,i.reject,i.notify):i.reject(e)}):h.fail(i.reject)})}).promise()}},h={resolveWith:function(e){if("pending"===s){s="resolved";for(var t=a=1<arguments.length?arguments[1]:[],i=0;i<n.length;i++)n[i].apply(e,t)}return this},rejectWith:function(e){if("pending"===s){s="rejected";for(var t=a=1<arguments.length?arguments[1]:[],i=0;i<o.length;i++)o[i].apply(e,t)}return this},notifyWith:function(e){if("pending"===s)for(var t=a=1<arguments.length?arguments[1]:[],i=0;i<r.length;i++)r[i].apply(e,t);return this},resolve:function(){return this.resolveWith(this,arguments)},reject:function(){return this.rejectWith(this,arguments)},notify:function(){return this.notifyWith(this,arguments)}},t=i.promise(h);return e&&e.apply(t,[t]),t}return u.when=function(){var e;if(arguments.length<2)return((e=arguments.length?arguments[0]:void 0)&&"function"==typeof e.isResolved&&"function"==typeof e.isRejected?e:u().resolve(e)).promise();for(var i=arguments,s=u(),n=i.length,o=0,r=new Array(n),t=0;t<i.length;t++)(e=>{var t;i[e].done?i[e].done(function(){r[e]=arguments.length<2?arguments[0]:arguments,++o==n&&s.resolve.apply(s,r)}).fail(function(){s.reject(arguments)}):(t=i[e],i[e]=new Deferred,i[e].done(function(){r[e]=arguments.length<2?arguments[0]:arguments,++o==n&&s.resolve.apply(s,r)}).fail(function(){s.reject(arguments)}).resolve(t))})(t);return s.promise()},u}),define("CatLab/Webremote/Collections/ServerList",["CatLab/Webremote/Tools/Deferred"],function(n){function e(e,t){this.defaultId=e.default,this.servers=e.servers,this.connectUrl=e.connectUrl,this.selectedServerId=null,this.preferredServer=t,this.assetsUrl=e.assetsUrl}var t=e.prototype;return t.getFromToken=function(e){if(e.length<8)return{host:this.getDefault().host,token:e};var t=e.substr(0,2);if(t){t=this.getFromId(t);if(t)return{host:t.host,token:e.substr(2)}}throw new Error("Code does not correspondent to any servers.")},t.getSelectedServer=function(){var t=new n;return this.selectedServerId?this.getFromId(this.selectedServerId)?t.resolve(this.getFromId(this.selectedServerId).host):t.reject("Selected remote server not found in server list. Please make sure you are connected to the right network."):this.selectBestServer().then(function(e){this.selectedServerId||(this.selectServer(e.id),t.resolve(e.host))}.bind(this)),t.promise()},t.selectBestServer=function(){var i=new n;if(this.preferredServer)for(var e=0;e<this.servers.length;e++)if(this.servers[e].id==this.preferredServer)return i.resolve(this.servers[e]),i.promise();var s=!1;return this.servers.forEach(function(t){t.discoverable&&this.measureRequestSpeed("https://"+t.host+"/info").then(function(e){console.log("[ServerList] "+t.host+" took "+e+"ms"),s||(s=!0,i.resolve(t))}.bind(this))}.bind(this)),i.promise()},t.selectServer=function(e){this.selectedServerId=e},t.measureRequestSpeed=function(e){var t=new Date,i=new n,s=new XMLHttpRequest;return s.onreadystatechange=function(){var e;4==this.readyState&&200==this.status&&(e=(new Date).getTime()-t.getTime(),i.resolve(e))},s.open("GET",e),s.send(),i.promise()},t.getConnectURL=function(){if(this.selectedServerId){var e=this.getFromId(this.selectedServerId);if(e.connectUrl)return e.connectUrl}return this.connectUrl},t.getAssetURL=function(){var e;return this.assetsUrl||((e=this.getConnectURL())?("http"!==e.substring(0,4)&&(e="https://"+e),this.assetsUrl=e+"/assets/",this.assetsUrl):void 0)},t.getConnectToken=function(e){return this.getFromId(this.selectedServerId).connectUrl?e:this.selectedServerId+e},t.getFromId=function(e){for(var t=0;t<this.servers.length;t++)if(this.servers[t].id==e)return this.servers[t];return null},t.getDefault=function(){return this.getFromId(this.defaultId)},t.serialize=function(){return{server:this.selectedServerId}},t.unserialize=function(e){this.selectServer(e.server)},e}),define("CatLab/Webremote/Config",["CatLab/Webremote/Tools/Net","CatLab/Webremote/Collections/ServerList"],function(i,e){var t="http";return{_options:{host:"www.catlab.tv",serverlist:null,preferredServer:null,protocol:t="undefined"!=typeof window&&void 0!==window.location&&void 0!==window.location.protocol?window.location.protocol.substr(0,window.location.protocol.length-1):t,debug:!1,proxy:"",imageproxy:"",smileys:!0,assetsUrl:null,vendorPath:"/vendor/",audioSync:!1,allowAuthentication:!0,canFullscreen:!0,oauth:{redirectUrl:null}},_initialized:!1,audioSyncConfig:{alphabet:"qwertyuiop",length:5,freqMin:524,freqMax:1593,freqError:25,debug:!1},set:function(e){void 0!==e&&(e.host,this._options.host=e.host,void 0!==e.protocol&&(this._options.protocol=e.protocol),void 0!==e.debug&&(this._options.debug=e.debug),void 0!==e.imageproxy&&(this._options.imageproxy=e.imageproxy),void 0!==e.proxy&&(this._options.proxy=e.proxy),void 0!==e.smileys&&(this._options.smileys=e.smileys),void 0!==e.assetsUrl&&(this._options.assetsUrl=e.assetsUrl),void 0!==e.vendorPath&&(this._options.vendorPath=e.vendorPath),void 0!==e.audioSync&&(this._options.audioSync=e.audioSync),void 0!==e.serverlist&&(this._options.serverlist=e.serverlist),void 0!==e.preferredServer&&(this._options.preferredServer=e.preferredServer),void 0!==e.allowAuthentication&&(this._options.allowAuthentication=e.allowAuthentication),void 0!==e.audioSyncConfig&&(this.audioSyncConfig=e.audioSyncConfig),void 0!==e.canFullscreen&&(this._options.canFullscreen=e.canFullscreen),void 0!==e.oauth)&&void 0!==e.oauth.redirectUrl&&(this._options.oauth.redirectUrl=e.oauth.redirectUrl)},getAll:function(){return this._options},initialize:function(t){var e;this._initialized?t():null===this._options.serverlist||"http"!==this._options.serverlist.substring(0,4)?(this._initialized=!0,t()):"json"===this._options.serverlist.substring(this._options.serverlist.length-4)?i.loadJSON(this._options.serverlist,function(e){this._initialized=!0,this._options.serverlist=e,t()}.bind(this),function(e,t){alert("Failed to connect to "+this._options.serverlist+". Game cannot start."),console.log(t)}.bind(this)):((e=document.createElement("script")).onload=function(){this._initialized=!0,this._options.serverlist=getCatLabRemoteServers(),t()}.bind(this),e.onerror=function(){alert("Failed to connect to "+this._options.serverlist+". Game cannot start.")}.bind(this),e.src=this._options.serverlist,document.head.appendChild(e))},getProtocol:function(e){var t=this._options.protocol;switch(t=void 0!==e&&e&&""===t?"http":t){case"http":case"https":break;default:t="https"}return t},getSocketURL:function(e){return this._options.host?((e=this.getProtocol(e))&&(e+=":"),e+"//"+this._options.host):"undefined"!=typeof window&&void 0!==window.location?window.location.protocol+"//"+window.location.hostname:""},getAssetsURL:function(e){var t;return this._options.assetsUrl||((t=this.getServerList())?t.getAssetURL():this.getSocketURL(e)+"/assets/")},debug:function(){return this._options.debug},getProxiedImage:function(e){return this._options.imageproxy?this._options.imageproxy+encodeURIComponent(e):e},getProxy:function(){return this._options.proxy},useSmileys:function(){return this._options.smileys},useAudioSync:function(){return this._options.audioSync},all:function(){return this._options},getAudioSyncConfig:function(){return this.audioSyncConfig},getProviderConfig:function(){var e={smileys:this.useSmileys(),audioSync:this.useAudioSync()};return this.useAudioSync()&&(e.audioSyncConfig=this.audioSyncConfig),e},getServerList:function(){return this._options.serverlist?(this.serverCollection||(this.serverCollection=new e(this._options.serverlist,this._options.preferredServer)),this.serverCollection):null},getVendorPath:function(){return this._options.vendorPath},supportsAuthentication:function(){return this._options.allowAuthentication},canFullscreen:function(){return this._options.canFullscreen}}}),define("CatLab/Webremote/Polyfills",[],function(){"function"!=typeof Object.assign&&(Object.assign=function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),s=1;s<arguments.length;s++){var n=arguments[s];if(null!=n)for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])}return i})}),define("CatLab/Webremote/Tools/Tracker",[],function(){var n=function(e,t,i,s){},t=function(e){n("Page",e,"-",0)};return{setTracker:function(e){n=e},setPageMethod:function(e){t=e},track:function(e,t,i,s){n(e,t,i,s)},page:function(e){t(e)}}}),define("CatLab/Webremote/Tools/Tools",[],function(){var n,o;return{popup:function(e,t){var i=this,s=(t=t||!1,document.createElement("iframe"));s.style.margin=0,s.style.padding=0,s.style.border=0,s.style.position="absolute",s.style.width="100%",s.style.height="100%",s.style.left=0,s.style.top=0,s.src=e,(o=document.createElement("div")).style.margin=0,o.style.padding=0,o.style.border=0,o.style.position="absolute",o.style.width="100%",o.style.height="100%",o.style.left=0,o.style.top=0,o.style.zIndex=9999,o.onclick=function(){i.closePopup()},(n=document.createElement("div")).appendChild(s),n.style.margin=0,n.style.padding=0,n.style.border=0,n.style.position="absolute",n.style.zIndex=1e4,n.style.overflow="auto",n.style.background="white",n.style.boxSizing="border-box",t?(n.style.border="0 none black",n.style.left="0",n.style.top="0",n.style.width="100%",n.style.height="100%"):(n.style.border="5px solid black",n.style.left="10%",n.style.top="10%",n.style.width="80%",n.style.height="80%"),document.body.appendChild(o),document.body.appendChild(n)},oauth2PopupMethod:function(e,t){return window.open(e,"oauth:catlab-remote")},oauth2Popup:function(e,t){return this.oauth2PopupMethod(e,t)},closePopup:function(){n&&n.parentNode.removeChild(n),o&&o.parentNode.removeChild(o)},setOauth2Popup:function(e){return this.oauth2PopupMethod=e,this},sanitize:function(e){var t;return null==e?null:(t={"&":"&","<":"<",">":">",'"':""","'":"'"},String(e).replace(/[&<>"']/g,function(e){return t[e]}))},nl2br:function(e,t){return null==e?"":(e+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+(t||void 0===t?"<br />":"<br>")+"$2")},shuffle:function(e){for(var t,i,s=e.length-1;0<s;s--)t=Math.floor(Math.random()*(s+1)),i=e[s],e[s]=e[t],e[t]=i},getUuid:function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},findIndex:function(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return i;return-1},getConnectTokenForDisplay:function(e){return null===e?null:e.length%4==0?this.injectFillerInString(e,4," "):(e.length,this.injectFillerInString(e,3," "))},injectFillerInString:function(e,t,i){return e.match(new RegExp(".{1,"+t+"}","g")).join(i)}}}),define("CatLab/Webremote/Tools/Eventable",["CatLab/Webremote/Tools/Tools"],function(s){function e(){}var n=0,t=e.prototype;return t.initializeEventable=function(){this._eventableEvents=[]},t.trigger=function(e){this.eventableTrigger.apply(this,arguments)},t.eventableTrigger=function(e){if("string"!=typeof e)throw new Error("eventableTrigger must be a string");if(void 0!==this._eventableEvents){var t,i=Array.prototype.slice.call(arguments);for(t in i.push(i.shift()),this._eventableEvents)this._eventableEvents.hasOwnProperty(t)&&this.eventMatches(e,t)&&this._eventableEvents[t].slice().forEach(function(e){try{e.method.apply(e.scope,i)}catch(e){console.error(e)}}.bind(this))}},t.eventMatches=function(e,t){return"*"===t||e===t},t.on=function(e,t,i){void 0===this._eventableEvents&&(this._eventableEvents={}),void 0===this._eventableEvents[e]&&(this._eventableEvents[e]=[]),n++,this._eventableEvents[e].push({id:n,method:t,scope:void 0!==i?i:this});var s=[e,n];return{id:s,name:e,method:t,unbind:function(){this.off(null,{id:s,name:e})}.bind(this)}},t.once=function(e,t,i){var s=this.on(e,function(){s.unbind(),t.apply(i,arguments)});return s},t.off=function(e,t){if(void 0!==e||void 0!==t)if(void 0===e||void 0!==t){if(e=t.name,t=t.id,void 0===this._eventableEvents[e])return null;var i=s.findIndex(this._eventableEvents[e],function(e){return e.id===t[1]});0<=i&&this._eventableEvents[e].splice(i,1)}else this._eventableEvents[e]=[];else this._eventableEvents=[]},t.clearEvents=function(){this.clearEventableEvents()},t.clearEventableEvents=function(){this._eventableEvents={}},e}),define("CatLab/Webremote/Models/User",["jquery","CatLab/Webremote/Config"],function(e,t){return function(e){this.accessToken=e,this.name=null,this.avatar=null,this.id=null,this.image=null,this.imageCallbacks=[],this.imageLoaded=!1,this.getAccessToken=function(){return this.accessToken},this.setId=function(e){this.id=e},this.getId=function(){return this.id},this.setName=function(e){this.name=e},this.getName=function(){return this.name},this.setAvatar=function(e){this.avatar=e,this.imageLoaded=!1,this.imageCallbacks=[],this.image=null},this.loadAvatar=function(){this.image||(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=function(){this.afterImageLoad()}.bind(this),this.image.src=t.getProxiedImage(this.avatar))},this.getAvatar=function(){return this.avatar},this.getAvatarSmiley=function(e){var t=this.getAvatar();return t?(t=t.split("?")[0],t+="?shape=circle&size=64&borderWidth=4",e&&(t+="&borderColor="+e.substr(1)),t):null},this.afterImageLoad=function(){this.imageLoaded=!0;for(var e=0;e<this.imageCallbacks.length;e++)this.imageCallbacks[e](this.image);this.imageCallbacks=[]},this.getImage=function(e){this.loadAvatar(),this.imageLoaded?e(this.image):this.imageCallbacks.push(e)}}}),define("CatLab/Webremote/Tools/Cookies",[],function(){var t={setCookie:function(e,t,i){return this.setItem(e,t,i)},getCookie:function(e){return this.getItem(e)},eraseCookie:function(e){return this.removeItem(e)},getItem:function(e){if("undefined"!=typeof document)return e&&this.hasOwnProperty(e)?unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"),"$1")):null},key:function(e){if("undefined"!=typeof document)return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/,"").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[e])},setItem:function(e,t,i){var s,n;e&&"undefined"!=typeof document&&(s="",i&&((n=new Date).setTime(n.getTime()+Math.round(24*i*60*60*1e3)),s="; expires="+n.toUTCString()),document.cookie=escape(e)+"="+escape(t)+"; expires="+s+"; path=/; SameSite=Strict;",this.updateLength())},length:0,removeItem:function(e){e&&this.hasOwnProperty(e)&&"undefined"!=typeof document&&(document.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; SameSite=Strict;",this.length--)},hasOwnProperty:function(e){if("undefined"!=typeof document)return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)},updateLength:function(){var e;"undefined"!=typeof document&&document.cookie&&(e=document.cookie.match(/\=/g),t.length=e?e.length:0)}};return t.updateLength(),t}),define("CatLab/Webremote/Tools/Storage",["CatLab/Webremote/Tools/Cookies"],function(e){var t={clean:function(){if(this.isSupported())for(var e=Object.keys(window.localStorage),t=0;t<e.length;t++)this.get(e)},get:function(e,t){if(void 0===t&&(t=function(){}),this.isSupported())try{var i,s=window.localStorage.getItem(e);s?void 0!==(s=JSON.parse(s)).expires?(i=Date.now(),s.expires<i?(this.delete(e),t(null)):t(s.content)):t(s):t(null)}catch(e){t(null),console.log(e)}else t(null)},add:function(t,i,s,n){var o=this;s=s||function(){},this.isSupported()?this.get(t,function(e){(e=null!=e&&""!==e?e:[]).push(i),o.set(t,e,s,n)}):s(null)},set:function(e,t,i,s){if(void 0===i&&(i=function(){}),this.isSupported()){void 0===s&&(s=31536e6);try{var n=Date.now();n+=s,window.localStorage.setItem(e,JSON.stringify({expires:n,content:t}))}catch(e){console.log(e)}i()}else i(null)},delete:function(e){this.isSupported()&&window.localStorage.removeItem(e)},remove:function(s,n){var o;this.isSupported()&&(o=this).get(s,function(e){null!=e&&""!=e||(e=[]);for(var t=JSON.stringify(n),i=0;i<e.length;i++)if(t===JSON.stringify(e[i]))return e.splice(i,1),void o.set(s,e)})},isSupported:function(){if("undefined"==typeof window)return!1;try{if(void 0===window.localStorage)return!1}catch(e){return console.log(e),!1}return!0}};try{t.clean()}catch(e){console.error(e)}return t}),define("CatLab/Webremote/Collections/AuthenticatedUsers",["CatLab/Webremote/Models/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Eventable"],function(s,o,e){function t(){this.initializeEventable()}var r,n,a=[],e=t.prototype=new e;return e.initialize=function(e,t){r=t,n=e;var s=this;o.get("users",function(i){null!==i&&o.get("currentuser",function(t){for(var e=0;e<i.length;e++)s.addFromAccessToken(i[e].access_token,function(e){e&&t&&e.getAccessToken()===t&&void 0!==n.setUser&&n.setUser(e)})})})},e.addFromAccessToken=function(i,s){s=s||function(){};var n=this;r.profile(i,function(e,t){e?(e=n.add(i,e.user),s(e)):401!==t&&403!==t||o.remove("users",{access_token:i})})},e.add=function(e,t){var i=new s(e);return i.setId(t.id),i.setName(t.username),i.setAvatar(t.avatar),(e=>{for(var t=0;t<a.length;t++)if(a[t].getId()==e.getId())return;return a.push(e),1})(i)||o.remove("users",{access_token:e}),this.trigger("update"),i},e.remove=function(e){for(var t=0;t<a.length;t++)if(a[t].getId()==e.getId())return o.remove("users",{access_token:a[t].getAccessToken()}),a.splice(t,1),void this.trigger("update")},e.getFromId=function(e){for(var t=0;t<a.length;t++)if(a[t].getId()==e)return a[t];return null},e.getAll=function(){return a},new t}),define("CatLab/Webremote/Controllers/OAuth2",["jquery","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Config"],function(s,o,r,e,n,a,h){var l,c,u,d,f,g=[],t=[],p=[],m=null;function i(){this.initializeEventable()}e=i.prototype=new e;return e.initialize=function(e){l=(e=e||{}).authorization,c=e.client_id||"none",u=e.authorization||"default",d=e.profile||"",f=e.profile+"/avatar",void 0===e.redirect_uri||h._options.oauth.redirectUrl||(h._options.oauth.redirectUrl=e.redirect_uri);var t=this;if("undefined"!=typeof window){var i,e=function(e){t.onMessage(e)};if(window.addEventListener){for(;i=p.pop();)removeEventListener("message",i);addEventListener("message",e,!1)}else{for(;i=p.pop();)detachEvent("onmessage",i);attachEvent("onmessage",e)}p.push(e)}},e.setRedirectUrl=function(e,t){this.redirectHost=e,this.redirectUrl=e+t},e.getAuthorizeURL=function(){var e="",e=(h.all().oauth&&h.all().oauth.redirectUrl&&(e=h.all().oauth.redirectUrl),l+"?client_id="+encodeURIComponent(c)+"&authorization="+encodeURIComponent(u)+"&response_type=token&redirect_uri="+encodeURIComponent(e)+"&reset=1&state=login");return void 0!==this.redirectUrl?this.redirectUrl+"?url="+encodeURIComponent(e):e},e.onMessage=function(e){if("I must've called a thousand times"!==e.data){var t;if("string"==typeof e.data&&e.data.match(/^oauth::/))try{t=JSON.parse(e.data.substring(7))}catch(e){return}else if("string"==typeof e.data)try{t=JSON.parse(e.data)}catch(e){return}else t=e.data;void 0!==t.access_token&&this.addAccessToken(t.access_token)}},e.addAccessToken=function(s){var e=function(e){if(e&&e.user){var t,i=n.add(s,e.user);for(a.add("users",{access_token:s}),o.closePopup();t=g.shift();)t(i);this.trigger("update")}}.bind(this);this.call(d,s,e)},e.call=function(e,t,i){var s,e=e+"?access_token="+t;"undefined"!=typeof window&&((s=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")).onreadystatechange=function(){if(4==s.readyState&&200!=s.status&&i(null,s.status),4==s.readyState&&200==s.status)try{i(JSON.parse(s.responseText))}catch(e){i(null,s.status)}},s.open("GET",e,!0),s.send())},e.profile=function(e,t){this.call(d,e,t)},e.changeAvatar=function(t,e){var i;if(t.getAccessToken())return(i=new FormData).append("avatar",e.files[0]),s.ajax({type:"POST",url:f,data:i,contentType:!1,processData:!1,headers:{Authorization:"Bearer "+t.getAccessToken()},success:function(e){t.setAvatar(e.url)}})},e.link=function(t){var i=new r,e={},e=("object"==typeof(t=void 0===t?{}:t)&&(t=(e=t).callback||function(){}),e.fullscreen||!1),s=(m&&clearInterval(m),this.getAuthorizeURL()),n=o.oauth2Popup(s,e);return n&&(m=setInterval(function(){n&&n.postMessage?n.postMessage("Hello from the other side","*"):clearInterval(m)}.bind(this),1e3)),g.push(function(e){t(e),i.resolve(e)}),i.promise()},e.onInit=function(e){t.push(e)},e.onAdds=function(){for(var e=0;e<t.length;e++)t[e]()},e.getParamsFromHash=function(e){if("undefined"!=typeof window)return e=(e=e||window.location.hash).slice(1),(e=decodeURIComponent(e)).split("&").reduce(function(e,t){return e[(t=t.split("="))[0]]=t[1],e},{})},e.finish=function(){var e='oauth::{"catlabremote":1,"event":"user:authenticated","access_token":"'+this.getParamsFromHash().access_token+'"}';setTimeout(function(){window.opener&&window.opener.postMessage(e,"*"),window.parent&&window.parent.postMessage(e,"*"),void 0!==window.dialogArguments&&window.dialogArguments.opener&&window.dialogArguments.opener.postMessage(e,"*"),setTimeout(function(){m&&clearInterval(m),window.close()},1)},1)},new i}),define("CatLab/Webremote/Tools/Colorwheel",[],function(){var e={index:0,colors:[{color:"#d84a38",name:"red"},{color:"#4d90fe",name:"blue"},{color:"#35aa47",name:"green"},{color:"#ffb848",name:"yellow"},{color:"#852b99",name:"purple"},{color:"#555555",name:"brown"},{color:"#F87217",name:"orange"},{color:"#FBBBB9",name:"pink"}],initialize:function(){this.index=Math.floor(Math.random()*this.colors.length)},next:function(){var e=this.colors[this.index%this.colors.length];return this.index++,e}};return e.initialize(),e}),define("CatLab/Webremote/Collections/Users",["CatLab/Webremote/Tools/Colorwheel"],function(i){return function(){this.users=[],this.userMap={},this.add=function(e){var t;e.isColorSet()||(t=i.next(),e.setColor(t.color,t.name)),e.hasPlayerId()||e.setPlayerId(this.count()+1),this.users.push(e),this.userMap[e.getId()]=e},this.clear=function(){this.users=[],this.userMap={}},this.remove=function(e){this.users.splice(users.indexOf(e),1),void 0!==this.users[e.getId()]&&delete this.users[e.getId()]},this.getFromId=function(e){return void 0!==this.userMap[e]?this.userMap[e]:null},this.getAll=function(){return this.users},this.count=function(){return this.users.length},this.each=function(e){for(var t=0;t<this.users.length;t++)e(this.users[t])},this.not=function(i){var s=[];return this.each(function(e){for(var t=0;t<i.length;t++)if(i[t].getId()===e.getId())return void s.push(i[t])}),s}}}),define("CatLab/Webremote/Collections/Groups",["CatLab/Webremote/Tools/Colorwheel"],function(i){return function(){var t;this.groups=[],this.groupMap={},this.add=function(e){var t;e.colorSet||(t=i.next(),e.setColor(t.color,t.name)),this.groupMap[e.getId()]=e,this.groups.push(e)},this.clear=function(){this.groups=[],this.groupMap=[]},this.addUser=function(t){var i=!1;return t.groupIds.forEach(function(e){e=this.getFromId(e);e&&(i=!0,e.addUser(t),e.isShareColor())&&t.setColor(e.getColor(),e.getColorName())}.bind(this)),i},this.remove=function(e){this.groups.splice(this.groups.indexOf(e),1),delete this.groupMap[e.getId()]},this.getFromId=function(e){return void 0!==this.groupMap[e]?this.groupMap[e]:null},this.getAll=function(){return this.groups},this.each=function(e){for(t=0;t<this.groups.length;t++)e(this.groups[t])}}}),define("CatLab/Webremote/Models/ControlBase",["CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Deferred"],function(e,n){function t(){}e=t.prototype=new e;return e.initializeControlBase=function(){this.initializeEventable()},e.resetViews=function(e){var t=new n;return this.emit("view:reset",{},function(){void 0!==e&&e(),t.resolve()}),t.promise()},e.replaceViews=function(e,t,i){var s=new n;return this.resetViews(function(){this.loadViews(e,t,function(){void 0!==i&&i(),s.resolve()})}.bind(this)),s.promise()},e.loadViews=function(e,t,i){return this.Webcontrol.provider.loadViews(e,i,this).then(function(){void 0!==t&&t()})},e.parseViews=function(e,t,i){return this.Webcontrol.provider.parseViews(e,t,this).then(function(){void 0!==i&&i()})},t}),define("CatLab/Webremote/Models/Control",[],function(){return function(i,s,e){var n,o,r,a,h=0,l={},c=i,u=[];this.id=i,this.decoration="",this.label="",this.isGlobal=e,this.pushed=function(){return 0===h},this.scale=function(){return h},this.update=function(e,t){0<h&&0===e?((t=void 0===t?!0:t)&&this.trigger("click"),this.trigger("up")):0===h&&0<e&&this.trigger("down"),h=e},this.getLabel=function(e){return(e=void 0===e?!0:e)?'<span class="control-label '+o+'">'+c+"</span>":c},this.setStaticLabel=function(e,t,i,s){return c=e,o=t,r=i,a=s,this},this.getLabelImage=function(){return r},this.getLabelEmoji=function(){return a},this.getLabelData=function(){return{label:c,type:o,image:r,emoji:a}},this.setLabel=function(e,t){return this.label=e,s.emit("button:label",{id:i,label:e}),this},this.decorate=function(e){return this.decoration=e,s.emit("button:decorate",{id:i,styles:e}),this},this.click=function(e){return this.on("click",e),this},this.on=function(e,t){return this.log("Setting trigger "+e),void 0===l[e]&&(l[e]=[]),l[e].push(t),this},this.trigger=function(e){this.log("Triggering "+e);var t=[];if(void 0!==l[e])for(this.log("Found "+l[e].length+" events"),n=0;n<l[e].length;n++)t.push(l[e][n]);for(n=0;n<t.length;n++)t[n](s);return this},this.hasTriggers=function(e){return void 0===e?0<Object.keys(l).length:void 0!==l[e]&&0<l[e].length},this.off=function(e,t){if(void 0===e)l={};else if(void 0===t)l[e]=[];else if(void 0!==l[e])for(n=0;n<l[e].length;n++)l[e][n]===t&&(l[e].splice(n,1),n--);return this},this.clear=function(){return this.clearEvents(),this.decoration=null,this.label=null,this},this.clearEvents=function(){return l={},this},this.addDomElement=function(e){var t=this,i=[];return i.push(e.addEventListener("click",function(){t.trigger("click")})),u.push({element:e,listeners:i}),this},this.clearDomElements=function(){for(var e=0;e<u.length;e++)for(var t=0;t<u[e].listeners.length;t++)u[e].element.removeEventListener("click",u[e].listeners[t]);return u=[],this},this.isLocalAuthentication=function(){return!1},this.refreshTarget=function(e){this.decoration&&e.emit("button:decorate",{id:i,styles:this.decoration}),this.label&&e.emit("button:label",{id:i,label:this.label})},this.log=function(e){s.log("["+this.id+"] "+e)}}}),define("CatLab/Webremote/Synchronization/MultipleTargetControl",[],function(){function e(e,t){this.id=e,this.remoteView=t,this.label=null,this.decoration=null}var t=e.prototype;return t.pushed=function(){var t=[];return this.remoteView.targets.forEach(function(e){t=t||e.control(this.id).pushed()}.bind(this)),t},t.scale=function(){var t,i=0;this.remoteView.targets.forEach(function(e){(t=e.scale())>i&&(i=t)}.bind(this))},t.update=function(t){this.remoteView.targets.forEach(function(e){e.control(this.id).update(t)}.bind(this))},t.getLabel=function(){return this.label},t.setLabel=function(t){return this.label=t,this.remoteView.targets.forEach(function(e){e.control(this.id).setLabel(t)}.bind(this)),this},t.decorate=function(t){return this.decoration=t,this.remoteView.targets.forEach(function(e){e.control(this.id).decorate(t)}.bind(this)),this},t.click=function(e){return this.on("click",e),this},t.on=function(t,i){return this.remoteView.targets.forEach(function(e){e.control(this.id).on(t,i)}.bind(this)),this},t.off=function(e){var t=arguments;return this.remoteView.targets.forEach(function(e){e.control(this.id).off.apply(e.control(this.id),t)}.bind(this)),this},t.refreshTarget=function(t){return this.remoteView.targets.forEach(function(e){e.control(this.id).refreshTarget(t)}.bind(this)),this},e}),define("CatLab/Webremote/Synchronization/DataItem",[],function(){function i(e,t,i){this.key=e,this.shared=t,this.side=i}var e=i.prototype;return e.setValue=function(e){this.value=e},e.canWrite=function(e){return!!this.shared||this.side===e},e.serialize=function(){return{key:this.key,shared:this.shared,side:this.side,value:this.value}},i.unserialize=function(e){var t=new i(e.key,e.shared,e.side);return t.setValue(e.value),t},i}),define("CatLab/Webremote/Synchronization/SynchronizedData",["CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/DataItem"],function(e,n){function t(e,t,i){this.initializeEventable(),this.id=e,this.synchronizer=t,this.side=i,this.data={}}e=t.prototype=new e;return e.set=function(e,t,i){if(void 0===this.data[e])this.data[e]=new n(e,i,this.side);else if(!this.data[e].canWrite(this.side))throw"Trying to overwrite a non shared data attribute: "+e;this.data[e].setValue(t),this.emit(this.data[e])},e.processMessage=function(e){var t=e.key,i=e.side,s=e.value;if(void 0===this.data[t])this.data[t]=new n(t,e.shared,i);else if(!this.data[t].canWrite(i))throw"Trying to overwrite a non shared data attribute: "+t;this.data[t].setValue(s)},e.get=function(e){return void 0===this.data[e]?null:this.data[e].value},e.emit=function(e,t){void 0===t&&(t=this.synchronizer.emit);e=e.serialize();e.namespace=this.synchronizer.namespace,e.container=this.id,t("data:set",e)},e.refreshTarget=function(e){for(var t in this.data)this.data.hasOwnProperty(t)&&this.emit(this.data[t],e)},e.destroy=function(){this.synchronizer.destroy(this)},e.serialize=function(){var e,t={};for(e in this.data)this.data.hasOwnProperty(e)&&(t[e]=this.data[e].serialize());return t},e.unserialize=function(e){for(var t in this.data={},e)e.hasOwnProperty(t)&&(this.data[t]=n.unserialize(e[t]))},t}),define("CatLab/Webremote/Synchronization/DataSynchronizer",["CatLab/Webremote/Synchronization/SynchronizedData"],function(t){function e(e,t,i){this.namespace=e,this.emit=t,this.dataModels={},this.side=i}e.eventsToListenFor=["data:set"];var i=e.prototype;return i.checkNamespace=function(e){return void 0!==e.namespace&&e.namespace===this.namespace},i.processMessage=function(e,t){void 0!==t.container&&this.getFromIdentifier(t.container).processMessage(t)},i.getFromIdentifier=function(e){return void 0===this.dataModels[e]&&(this.dataModels[e]=new t(e,this,this.side)),this.dataModels[e]},i.destroy=function(e){e=e.id;void 0===this.dataModels[e]&&delete this.dataModels[e]},i.refreshTarget=function(e){for(var t in this.dataModels)this.dataModels.hasOwnProperty(t)&&this.dataModels[t].refreshTarget(e)},i.serialize=function(){var e,t={};for(e in this.dataModels)this.dataModels.hasOwnProperty(e)&&(t[e]=this.dataModels[e].serialize());return{dataModels:t}},i.unserialize=function(e){for(var t in e.dataModels)e.dataModels.hasOwnProperty(t)&&this.getFromIdentifier(t).unserialize(e.dataModels[t])},e}),define("CatLab/Webremote/Synchronization/RemoteView",["CatLab/Webremote/Models/Control","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/MultipleTargetControl","CatLab/Webremote/Synchronization/DataSynchronizer"],function(e,t,i,s){function n(e,t,i,s,n){this.initializeEventable(),this.id=t,this.viewId=e,this.targets=[],this.Webcontrol=s,this.groupId=void 0!==n?n:null,this.controls={},this.valueMap={},this.newUserStack=[],this.factory=null,this.listeners=[],i.map(function(e){this.addTarget(e)}.bind(this))}t=n.prototype=new t;return t.clearValues=function(){this.valueMap={}},t.addTarget=function(e){this.targets.push(e),this.refreshTarget(e)},t.refreshTarget=function(t){var e,i={id:this.id,viewId:this.viewId};for(this.tmpid in this.groupId&&(i.group=this.groupId),t.emit("view:set",i),this.newUserStack.map(function(e){t.emit(e.action,e.data)}.bind(this)),t.controls)t.controls.hasOwnProperty(this.tmpid)&&t.controls[this.tmpid].isGlobal&&t.controls[this.tmpid].refreshTarget(t);for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&(void 0!==this.controls[this.tmpid].refreshTarget?this.controls[this.tmpid].refreshTarget(t):console.error("Unexpected control:",this.controls[this.tmpid]));for(e in this.valueMap)this.valueMap.hasOwnProperty(e)&&t.emit("value:change",{id:e,value:this.valueMap[e]})},t.emit=function(t,i){this.targets.map(function(e){e.emit(t,i)})},t.clearControls=function(){for(var e=this.Webcontrol.getViewLabels(this.currentView),t=0;t<e.length;t++)this.control(e[t].id).setStaticLabel(e[t].label,"mobile")},t.control=function(e){return void 0===this.controls[e]&&(this.controls[e]=new i(e,this)),this.controls[e]},t.trigger=function(e,t){"value:change"==e&&this.changeValue(t.id,t.value)},t.changeValue=function(e,t){this.valueMap[e]=t,this.emit("value:change",{id:e,value:t}),this.eventableTrigger("value:change",e,t)},t.refreshControls=function(){for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl()},t.getValues=function(){return this.valueMap},t.log=function(e){this.Webcontrol.log(e)},t.domAppend=function(e,t){this._stackAndEmit("dom:append",{id:e,html:t})},t.domReplace=function(e,t){this._stackAndEmit("dom:replace",{id:e,html:t})},t.domAttribute=function(e,t,i){this._stackAndEmit("dom:attribute",{id:e,name:t,value:i})},t.vibrate=function(e){Array.isArray(e)?this.emit("device:vibrate",{pattern:e}):console.error("Vibrate pattern must be an array.")},t.listenTo=function(e,t,i){this.listeners.push(e.on(t,i))},t.stopListening=function(){this.listeners.forEach(function(e){e.unbind()})},t._stackAndEmit=function(e,t){this.newUserStack.push({action:e,data:t}),this.emit(e,t)},t.destroy=function(){this.stopListening(),this.factory.destroy(this)},n}),define("CatLab/Webremote/Synchronization/RemoteViewFactory",["CatLab/Webremote/Synchronization/RemoteView"],function(n){function e(){this.viewCounter=0,this.views={}}var t=e.prototype;return t.create=function(e,t,i,s){return this.viewCounter++,this.views[this.viewCounter]=new n(this.viewCounter,e,t,i,s),(this.views[this.viewCounter].factory=this).views[this.viewCounter]},t.createDummy=function(e,t){return this.create(e,[],t)},t.getFromId=function(e){return this.views[e]},t.destroy=function(e){e=e.id;delete this.views[e]},new e}),(()=>{var g={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function p(e){for(var t,i,s,n,o,r,a,h=(e=>{if(m[e])return m[e];for(var t,i=e,s=[],n=0;i;){if(null!==(t=g.text.exec(i)))s.push(t[0]);else if(null!==(t=g.modulo.exec(i)))s.push("%");else{if(null===(t=g.placeholder.exec(i)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){n|=1;var o=[],r=t[2],a=[];if(null===(a=g.key.exec(r)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(a[1]);""!==(r=r.substring(a[0].length));){if(null===(a=g.key_access.exec(r))&&null===(a=g.index_access.exec(r)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(a[1])}t[2]=o}else n|=2;if(3===n)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");s.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}i=i.substring(t[0].length)}return m[e]=s})(e),l=arguments,c=1,u=h.length,d="",f=0;f<u;f++)if("string"==typeof h[f])d+=h[f];else if("object"==typeof h[f]){if((s=h[f]).keys)for(t=l[c],i=0;i<s.keys.length;i++){if(null==t)throw new Error(p('[sprintf] Cannot access property "%s" of undefined value "%s"',s.keys[i],s.keys[i-1]));t=t[s.keys[i]]}else t=s.param_no?l[s.param_no]:l[c++];if(g.not_type.test(s.type)&&g.not_primitive.test(s.type)&&t instanceof Function&&(t=t()),g.numeric_arg.test(s.type)&&"number"!=typeof t&&isNaN(t))throw new TypeError(p("[sprintf] expecting number but found %T",t));switch(g.number.test(s.type)&&(r=0<=t),s.type){case"b":t=parseInt(t,10).toString(2);break;case"c":t=String.fromCharCode(parseInt(t,10));break;case"d":case"i":t=parseInt(t,10);break;case"j":t=JSON.stringify(t,null,s.width?parseInt(s.width):0);break;case"e":t=s.precision?parseFloat(t).toExponential(s.precision):parseFloat(t).toExponential();break;case"f":t=s.precision?parseFloat(t).toFixed(s.precision):parseFloat(t);break;case"g":t=s.precision?String(Number(t.toPrecision(s.precision))):parseFloat(t);break;case"o":t=(parseInt(t,10)>>>0).toString(8);break;case"s":t=String(t),t=s.precision?t.substring(0,s.precision):t;break;case"t":t=String(!!t),t=s.precision?t.substring(0,s.precision):t;break;case"T":t=Object.prototype.toString.call(t).slice(8,-1).toLowerCase(),t=s.precision?t.substring(0,s.precision):t;break;case"u":t=parseInt(t,10)>>>0;break;case"v":t=t.valueOf(),t=s.precision?t.substring(0,s.precision):t;break;case"x":t=(parseInt(t,10)>>>0).toString(16);break;case"X":t=(parseInt(t,10)>>>0).toString(16).toUpperCase()}g.json.test(s.type)?d+=t:(!g.number.test(s.type)||r&&!s.sign?a="":(a=r?"+":"-",t=t.toString().replace(g.sign,"")),n=s.pad_char?"0"===s.pad_char?"0":s.pad_char.charAt(1):" ",o=s.width-(a+t).length,o=s.width&&0<o?n.repeat(o):"",d+=s.align?a+t+o:"0"===n?a+o+t:o+a+t)}return d}function e(e,t){return p.apply(null,[e].concat(t||[]))}var m=Object.create(null);"undefined"!=typeof exports&&(exports.sprintf=p,exports.vsprintf=e),"undefined"!=typeof window&&(window.sprintf=p,window.vsprintf=e,"function"==typeof define)&&define.amd&&define("sprintf",[],function(){return{sprintf:p,vsprintf:e}})})(),define("CatLab/Webremote/Tools/Translator",["sprintf"],function(t){function e(){this.translator=null}var i,s,n=e.prototype;return n.setTranslator=function(e){this.translatorScope=this,"function"==typeof e?this.translator=e:("function"==typeof e.t?this.translator=e.t:(e._,this.translator=e._),this.translatorScope=e)},n.t=function(e){if(""===e)return"";if(Array.isArray(e))return this.t.apply(this,e);if(this.translator)return this.translator.apply(this.translatorScope,arguments);for(i=[],s=1;s<arguments.length;s++)i.push(arguments[s]);return t.vsprintf(e,i)},new e}),define("CatLab/Webremote/Synchronization/EventHandler",["CatLab/Webremote/Tools/Eventable"],function(e){function t(e,t){this.initializeEventable(),this.namespace=e,this.emit=t}t.eventsToListenFor=["event:trigger"];e=t.prototype=new e;return e.checkNamespace=function(e){return void 0!==e.namespace&&e.namespace===this.namespace},e.processMessage=function(e,t){if("event:trigger"===e)return this.processTriggerEvent(t)},e.processTriggerEvent=function(e){void 0!==e.event&&this.eventableTrigger(e.event,void 0===e.parameters?{}:e.parameters)},e.trigger=function(e,t){this.emit("event:trigger",{namespace:this.namespace,event:e,parameters:t})},e.refreshTarget=function(e){},e.serialize=function(){return{}},e.unserialize=function(e){},t}),define("CatLab/Webremote/Models/Users/ControlUser",["CatLab/Webremote/Models/ControlBase","CatLab/Webremote/Models/User","CatLab/Webremote/Models/Control","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler"],function(e,t,i,s,n,o,r,a){function h(e,t){this.initializeControlBase(),(t=void 0===t?{}:t).id=e,t.playerId=null,this.initialize(t)}e=h.prototype=new e;return e.hasPlayerId=function(){return 0<this.playerId},e.setPlayerId=function(e){return this.playerId=e,this},e.control=function(e,t){return void 0===t&&(t=!1),void 0===this.controls[e]&&(this.controls[e]=new i(e,this,t)),this.controls[e]},e.getAvailableControls=function(){return["a","b","x","y","up","down","right","left","start","back"]},e.hasControl=function(e){return!0},e.setWebcontrol=function(e){this.Webcontrol=e},e.initialize=function(e){this.id=e.id,e.playerId&&(this.playerId=e.playerId),this.groups=[],this.currentView=null,this.color="orange",this.colorName="orange",this.colorSet=!1,this.tmpid=null,this.active=!1,this.smiley=null,this.email=null,this.nickname=null,this.userdata=e,this.profiledata={},this.access_token=null,this.user=null,this.master=!1,this.authenticated=!1,void 0!==e&&void 0!==e.groups?this.groupIds=e.groups:this.groupIds=[],this.controls={},this.dataSynchronizer=new r("user",this.emit.bind(this),"master"),this.data=this.dataSynchronizer.getFromIdentifier("user"),this.events=new a("user",this.emit.bind(this)),this.settings={}},e.setSettings=function(e){return this.settings=e,this},e.trigger=function(t,i){0<=r.eventsToListenFor.indexOf(t)?(this.dataSynchronizer.checkNamespace(i)&&this.dataSynchronizer.processMessage(t,i),this.getGroups().forEach(function(e){e.dataSynchronizer.checkNamespace(i)&&e.dataSynchronizer.processMessage(t,i)}.bind(this))):0<=a.eventsToListenFor.indexOf(t)?(this.events.checkNamespace(i)&&this.events.processMessage(t,i),this.getGroups().forEach(function(e){e.events.checkNamespace(i)&&e.events.processMessage(t,i)}.bind(this))):"button:down"===t?this.control(i.id).update(1):"button:up"===t?this.control(i.id).update(0,i.click):"user:login"===t?this.login(i):"user:logout"===t?this.logout(i):"user:smiley"===t?this.setSmiley(i.smiley):"sync:audio"===t&&this.eventableTrigger("sync:audio",i)},e.setSmiley=function(t){this.smiley=t;var i=null;this.getGroups().forEach(function(e){i=!0,e.setSmiley(t,this)}.bind(this)),i||this.Webcontrol.smileys.reserve(t,this.getIdentifier())?this.emit("user:smiley",{smiley:t}):this.emit("dom:alert",{message:n.t("Smiley is already taken. Please select a different smiley.")})},e.setNickname=function(e){return this.nickname=e,this},e.getNickname=function(){return this.nickname||(this.getData().username?this.getData().username:this.playerId?"Player "+this.playerId:"Player "+this.id)},e.clearSmiley=function(){this.smiley=null,this.getGroups().forEach(function(e){e.clearSmiley(this)}.bind(this)),this.emit("user:smiley",{smiley:null})},e.getSmiley=function(){return this.smiley},e.getSmileyImage=function(){return this.Webcontrol.smileys.getImage(this.getSmiley())},e.getSmileyHtml=function(){return this.Webcontrol.smileys.getHtml(this.getSmiley())},e.getSmileyUrl=function(){return this.Webcontrol.smileys.getUrl(this.getSmiley())},e.login=function(e){},e.logout=function(e){},e.clearControls=function(){for(this.tmpid in this.setStaticLabels(),null!==this.currentView&&this.currentView.clearControls(),this.controls)!this.controls.hasOwnProperty(this.tmpid)||this.controls[this.tmpid].isGlobal||this.controls[this.tmpid].clear()},e.setStaticLabels=function(){},e.clearEvents=function(){this.clearControls(),this.clearEventableEvents()},e.emit=function(e,t,i){return this.Webcontrol.provider.toPlayer(this,e,t,i),!0},e.getId=function(){return this.id},e.getName=function(){return"User "+this.getId()},e.getType=function(){return"mobile"},e.getEntityType=function(){return"user"},e.getIcon=function(){return"fa fa-mobile-phone"},e.loginFromAuthUser=function(e,t){e={access_token:e.getAccessToken()};this.login(e,t)},e.login=function(t,i){var s=this;this.Webcontrol.getOAuthClient(function(e){e&&(this.setAccessToken(t.access_token),e.profile(s.access_token,function(e){s.authenticated=!0,this.setProfiledata(e.user),void 0!==i&&i()}.bind(this)))}.bind(this))},e.setAccessToken=function(e){this.access_token=e},e.getAccessToken=function(){return this.access_token},e.setProfiledata=function(e){e=void 0!==(this.profiledata=e).accessToken?e.accessToken:null,e=new t(e);void 0!==this.profiledata.id&&e.setId(this.profiledata.id),void 0!==this.profiledata.username&&e.setName(this.profiledata.username),void 0!==this.profiledata.avatar&&e.setAvatar(this.profiledata.avatar),this.setUser(e),this.eventableTrigger("login",this)},e.isAuthenticated=function(){return this.authenticated},e.getData=function(){return this.profiledata},e.logout=function(e){this.profiledata=null,this.access_token=null,this.authenticated=!1},e.setColor=function(e,t){this.colorSet=!0,this.color=e,this.colorName=t,this.emit("color:set",{color:e,name:t})},e.isColorSet=function(){return this.colorSet},e.getColor=function(){return this.color},e.getColorName=function(){return this.colorName},e.isActive=function(){return this.active},e.toggleActive=function(){this.setActive(!this.active),this.setJoinLabel()},e.setJoinLabel=function(){!0===this.active?this.control("a").setLabel("LEAVE"):this.control("a").setLabel("JOIN")},e.setActive=function(e,t){this.active=e,this.eventableTrigger("active:change",e),this.active&&this.eventableTrigger("active:activate"),void 0!==t&&t&&this.setJoinLabel()},e.setView=function(e){return this.clearView(),this.currentView=s.create(e,[this],this.Webcontrol),this.currentView},e.clearView=function(e){var t;this.currentView&&(t=this.currentView,this.currentView=null,this.clearControls(),void 0!==e?setTimeout(function(){t.destroy()},e):t.destroy())},e.refreshView=function(){this.currentView&&this.currentView.refreshTarget(this)},e.getValues=function(){return this.currentView?this.currentView.getValues():null},e.clearValues=function(){this.currentView&&this.currentView.clearValues()},e.setUser=function(e){return this.usermodel=e,this},e.hasUser=function(){return void 0!==this.usermodel&&this.usermodel},e.getUser=function(){return this.usermodel},e.isLocalAuthentication=function(){return!0},e.log=function(e){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+e)},e.getGroups=function(){return this.groups},e.hasDisplay=function(){return!0},e.hasKeyboardInput=function(){return!0},e.hasTouchInput=function(){return!0},e.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},e.represents=function(e){if(void 0===e.id||void 0===e.type)throw"Attribute is not an identifier.";var t=this.getIdentifier();return t.type===e.type&&t.id===e.id},e.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"y",left:"left",right:"right"}},e.isMainGroup=function(){if(0===this.groups.length)return!0;for(var e=0;e<this.groups.length;e++)if(this.groups[e].isMainGroup())return!0;return!1},e.isMaster=function(){return this.master},e.setMaster=function(e){var t=this.master!==(e=!!(e=void 0===e?!0:e));return this.master=e,t&&this.eventableTrigger("master:change"),this},e.getConnectToken=function(){return this.Webcontrol.getConnectToken()},e.getConnectTokenForDisplay=function(){return this.Webcontrol.getConnectTokenForDisplay()},e.serialize=function(){return{id:this.getId(),playerId:this.playerId,userdata:this.userdata,profiledata:this.profiledata,email:this.email,nickname:this.nickname,access_token:this.access_token,color:this.color,colorName:this.colorName,smiley:this.smiley,data:this.dataSynchronizer.serialize(),events:this.events.serialize()}},e.unserialize=function(e){void 0!==e.profiledata&&this.setProfiledata(e.profiledata),void 0!==e.playerId&&(this.playerId=e.playerId),void 0!==e.access_token&&this.setAccessToken(e.access_token),void 0!==e.color&&(this.color=e.color),void 0!==e.colorName&&(this.colorName=e.colorName),void 0!==e.nickname&&(this.nickname=e.nickname),void 0!==e.email&&(this.email=e.email),void 0!==e.smiley&&(this.smiley=e.smiley),void 0!==e.data&&this.dataSynchronizer.unserialize(e.data),void 0!==e.events&&this.events.unserialize(e.events)},h}),define("CatLab/Webremote/Models/GroupControl",[],function(){return function(e,s,t){var n,i,o,r,a,h,l=e,c={};this.label=null,this.decoration="",this.group=s,this.isGlobal=t,this.pushed=function(){for(o=s.getUsers(),n=0;n<o.length;n++)if(o[n].control(l,this.isGlobal).pushed())return!0;return!1},this.scale=function(){for(o=s.getUsers(),n=r=0;n<o.length;n++)(a=o[n].control(l,this.isGlobal)).value>r&&(r=a.value);return r},this.getLabel=function(e){return o=s.getUsers(),(n=0)<o.length?(a=o[n].control(l,this.isGlobal)).getLabel(e):null},this.getLabelImage=function(){return o=s.getUsers(),(n=0)<o.length?(a=o[n].control(l,this.isGlobal)).getLabelImage():null},this.setStaticLabel=function(e,t,i){for(o=s.getUsers(),n=0;n<o.length;n++)o[n].control(l).setStaticLabel(e,t,i);return null},this.setLabel=function(e,t){return this.label=e,s.emit("button:label",{id:l,label:e}),this},this.decorate=function(e){return this.decoration=e,s.emit("button:decorate",{id:l,styles:e}),this},this.click=function(e){return this.on("click",e),this},this.on=function(e,t){for(void 0===c[e]&&(c[e]=[]),c[e].push(t),this.log("Setting group trigger "+e),o=s.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).on(e,t);return this},this.hasTriggers=function(e){for(o=s.getUsers(),n=0;n<o.length;n++)if(o[n].control(l,this.isGlobal).hasTriggers(e))return!0;return!1},this.off=function(e){for(delete c[e],o=s.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).off(e);return this},this.clearEvents=function(){for(c={},o=s.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).clearEvents();return this},this.clear=function(){for(c={},this.decoration=null,this.label=null,o=s.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).clear();return this},this.isLocalAuthentication=function(){return!1},this.refreshControl=function(){for(o=s.getUsers(),n=0;n<o.length;n++){for(h in o[n].control(l,this.isGlobal).clearEvents(),c)if(c.hasOwnProperty(h))for(i=0;i<c[h].length;i++)o[n].control(l,this.isGlobal).on(h,c[h][i]);this.label&&o[n].control(l,this.isGlobal).setLabel(this.label)}return this},this.refreshTarget=function(e){this.decoration&&e.emit("button:decorate",{id:l,styles:this.decoration}),this.label&&e.emit("button:label",{id:l,label:this.label})},this.log=function(e){s.log("["+l+"] "+e)}}}),define("CatLab/Webremote/Models/ControlGroup",["CatLab/Webremote/Config","CatLab/Webremote/Models/ControlBase","CatLab/Webremote/Models/User","CatLab/Webremote/Models/Control","CatLab/Webremote/Models/GroupControl","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/Tools/Tools"],function(e,t,i,s,n,o,r,a,h,l){function c(e,t){this.initializeControlBase(),this.id=e,this.initialize(t)}t=c.prototype=new t;return t.setWebcontrol=function(e){this.Webcontrol=e},t.initialize=function(e){this.token=e.token,this.connectURL=e.connectURL,this.currentView=null,this.color="orange",this.colorName="orange",this.colorSet=!1,this.shareColor=!1,this.tmpid=null,this.active=!1,this.smiley=null,this.email=null,this.userdata=e,this.profiledata={},this.access_token=null,this.master=!1,this.users=[],this.controls=[],this.dataSynchronizer=new a("group",this.emit.bind(this),"master"),this.data=this.dataSynchronizer.getFromIdentifier("group:"+this.getId()),this.events=new h("group",this.emit.bind(this)),this.options={}},t.setOptions=function(e){return this.options=e,this},t.getOption=function(e){return void 0!==this.options[e]?this.options[e]:null},t.hasControl=function(e){return!0},t.setAccessToken=function(e){this.access_token=e},t.setProfiledata=function(e){this.profiledata=e},t.clearControls=function(){for(this.tmpid in null!=this.currentView&&this.currentView.clearControls(),this.controls)!this.controls.hasOwnProperty(this.tmpid)||this.controls[this.tmpid].isGlobal||this.controls[this.tmpid].clear()},t.clearEvents=function(){this.clearControls(),this.clearEventableEvents()},t.isMainGroup=function(){return this.Webcontrol.getConnectToken()===this.getConnectToken()},t.emit=function(e,t,i){return this.Webcontrol.provider.toGroup(this,e,t,i),!0},t.getId=function(){return this.id},t.getName=function(){return"Group "+this.getId()},t.setNickname=function(e){return this.nickname=e,this},t.getNickname=function(){return this.nickname||(this.getData().username?this.getData().username:"Group "+this.getId())},t.getType=function(){return"mobile"},t.getEntityType=function(){return"group"},t.getIcon=function(){return"fa fa-mobile-phone"},t.getData=function(){return this.profiledata},t.setColor=function(e,t,i){void 0===i&&(i=this.shareColor),this.colorSet=!0,this.color=e,this.colorName=t,this.shareColor=i,this.emit("color:set",{color:e,name:t,shareColor:i})},t.getColor=function(){return this.color},t.setShareColor=function(e){this.shareColor=e},t.isShareColor=function(){return this.shareColor},t.getColorName=function(){return this.colorName},t.setView=function(e){return this.clearView(),this.currentView=r.create(e,[this],this.Webcontrol,this.getId()),this.currentView},t.clearView=function(t){var e;this.currentView&&(e=this.currentView,this.currentView=null,this.clearControls(),void 0!==t?setTimeout(function(){e.destroy()},t):e.destroy(),this.users.forEach(function(e){e.clearView(t)}))},t.isAuthenticated=function(){return!1},t.isLocalAuthentication=function(){return!0},t.log=function(e){this.Webcontrol.log("[g:"+this.getId()+"] "+e)},t.getConnectToken=function(){return this.Webcontrol.provider.getConnectToken(this.token)},t.getConnectTokenForDisplay=function(){return l.getConnectTokenForDisplay(this.getConnectToken())},t.getConnectURL=function(){return this.Webcontrol.provider.getConnectURL(this.connectURL)},t.addUser=function(t){for(this.tmpid in l.findIndex(this.users,function(e){return e.id===t.id})<0&&this.users.push(t),l.findIndex(t.groups,function(e){return e.id===this.id})<0&&t.groups.push(this),this.currentView&&(this.currentView.refreshTarget(t),t.currentView=this.currentView),this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl();this.events.refreshTarget(t.emit.bind(t)),this.dataSynchronizer.refreshTarget(t.emit.bind(t)),this.smiley&&(t.emit("user:smiley",{smiley:this.smiley}),t.smiley=this.smiley),this.trigger("user:join",t)},t.removeUser=function(t){var e=l.findIndex(this.users,function(e){return e.id===t.id});0<=e&&this.users.splice(e,1)},t.getUsers=function(){return this.users},t.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},t.represents=function(e){if(void 0===e.id||void 0===e.type)throw"Attribute is not an identifier.";var t=this.getIdentifier();return t.type==e.type&&t.id==e.id},t.getValues=function(){return this.currentView?this.currentView.getValues():null},t.clearValues=function(){this.currentView&&this.currentView.clearValues()},t.control=function(e,t){return void 0===t&&(t=!1),void 0===this.controls[e]&&(this.controls[e]=new n(e,this,t)),this.controls[e]},t.isMaster=function(){return this.master},t.setMaster=function(e){return this.master=e=void 0===e?!0:e,this},t.hasDisplay=function(){return!0},t.hasKeyboardInput=function(){return!0},t.hasTouchInput=function(){return!0},t.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"y",left:"left",right:"right"}},t.setOAuthSettings=function(e){this.emit("oauth:set",e)},t.setSmiley=function(e,t){this.Webcontrol.smileys.reserve(e,this.getIdentifier())?(this.emit("user:smiley",{smiley:e}),this.smiley=e):t.emit("dom:alert",{message:o.t("Smiley is already taken. Please select a different smiley.")})},t.clearSmiley=function(e){this.Webcontrol.smileys.unreserve(this.getIdentifier()),this.emit("user:smiley",{smiley:null}),this.smiley=null},t.getSmiley=function(){return this.smiley},t.getSmileyImage=function(){return this.Webcontrol.smileys.getImage(this.getSmiley())},t.getSmileyHtml=function(){return this.Webcontrol.smileys.getHtml(this.getSmiley())},t.getSmileyUrl=function(){return this.Webcontrol.smileys.getUrl(this.getSmiley())},t.setMaxUsers=function(e){this.emit("config:set",{maxUsers:e})},t.isActive=function(){return this.active},t.toggleActive=function(){this.active=!this.active,this.setJoinLabel()},t.setJoinLabel=function(){!0===this.active?this.control("a").setLabel("LEAVE"):this.control("a").setLabel("JOIN")},t.setActive=function(e,t){this.active=e,this.eventableTrigger("active:change",e),this.active&&this.eventableTrigger("active:activate")},t.serialize=function(){return{id:this.getId(),token:this.token,userdata:this.userdata,nickname:this.nickname,profiledata:this.profiledata,email:this.email,access_token:this.access_token,shareColor:this.shareColor,color:this.color,colorName:this.colorName,smiley:this.smiley,data:this.dataSynchronizer.serialize(),events:this.events.serialize()}},t.unserialize=function(e){void 0!==e.profiledata&&this.setProfiledata(e.profiledata),void 0!==e.access_token&&this.setAccessToken(e.access_token),void 0!==e.token&&(this.token=e.token),void 0!==e.shareColor&&(this.shareColor=e.shareColor),void 0!==e.color&&(this.color=e.color),void 0!==e.colorName&&(this.colorName=e.colorName),void 0!==e.nickname&&(this.nickname=e.nickname),void 0!==e.email&&(this.email=e.email),void 0!==e.smiley&&(this.smiley=e.smiley,this.emit("user:smiley",{smiley:this.smiley})),void 0!==e.data&&this.dataSynchronizer.unserialize(e.data),void 0!==e.events&&this.events.unserialize(e.events)},c}),define("CatLab/Webremote/Tools/Preloader",["../Config","CatLab/Webremote/Tools/Deferred"],function(t,o){function i(e){this.provider=e,this.provider.on("file:preload",function(e){e&&e.url&&this.preloadClientFile(e.url)}.bind(this)),this.urlMap={}}var e=i.prototype;return e.preload=function(t){if(Array.isArray(t)){for(var e=new o,i=[],s=0;s<t.length;s++)i.push(this.preload(t[s]));return o.when.apply(o,i).then(function(){e.resolve(Array.prototype.slice.call(arguments))}),e.promise()}var n=new o;return this.urlMap[t]=t,this.provider.proxyFile(t).then(function(e){this.urlMap[t]=e.url,this.provider.emit("file:preload",{url:e.url}),n.resolve(e)}.bind(this)),n.promise()},e.sendPreloadFileCommandToPlayer=function(e){for(var t in this.urlMap)this.urlMap.hasOwnProperty(t)&&e.emit("file:preload",{url:this.urlMap[t]})},e.getPreloadedUrl=function(e){return this.urlMap[e]},e.preloadClientFile=function(e){void 0===this.urlMap[e]&&(e.toLowerCase().indexOf("http")<0&&(e=t.getProtocol()+":"+e),this.urlMap[e]=document.createElement("img"),this.urlMap[e].src=e)},e.serialize=function(){return{urlMap:this.urlMap}},i.unserialize=function(e,t){e=new i(e);return void 0!==t&&void 0!==t.urlMap&&(e.urlMap=t.urlMap),e},i}),define("CatLab/Webremote/Models/State",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Preloader"],function(i,s){function e(e){this.Webcontrol=e}var t=e.prototype;return t.reconnect=function(e,t){void 0!==e.provider&&this.Webcontrol.provider.restoreProviderSettings(e.provider),this.Webcontrol.disconnect(),setTimeout(function(){this.Webcontrol.initialize(i.getAll()).then(function(){this.Webcontrol._reconnect(e.token,e.accessToken,function(){this._setCollectionDetails(e.groups,this.Webcontrol._grouplibrary),this._setCollectionDetails(e.users,this.Webcontrol._userlibrary),this.Webcontrol.preloader=s.unserialize(this.Webcontrol.provider,e.preloader),t()}.bind(this))}.bind(this))}.bind(this),1)},t._setCollectionDetails=function(e,t){var i,s;if(void 0!==e)for(i=0;i<e.length;i++)(s=t.getFromId(e[i].id))?s.unserialize(e[i]):(console.log("Trying to set data for non existing user/group."),console.log(e[i]))},t.getData=function(){var t=[],i=(this.Webcontrol._grouplibrary.each(function(e){t.push(e.serialize())}.bind(this)),[]),e=(this.Webcontrol._userlibrary.each(function(e){i.push(e.serialize())}),{users:i,groups:t,token:this.Webcontrol._gamedata.token,accessToken:this.Webcontrol._gamedata.accessToken,preloader:this.Webcontrol.preloader.serialize()});return e.provider=this.Webcontrol.provider.serializeProviderSettings(),e},t.serialize=function(){var e=this.getData();return JSON.stringify(e)},t.unserialize=function(e){e=JSON.parse(e);this.reconnect(e)},e}),define("CatLab/Webremote/Messages/MessageBus",[],function(){function e(){this.controllerListeners=[],this.viewListeners=[]}var t=e.prototype;return t.toController=function(e,t){this.handleControllerMessage(e,t)},t.handleControllerMessage=function(e,t){for(var i=0;i<this.controllerListeners.length;i++)this.controllerListeners[i].handleIncomingMessage(e,t)},t.toView=function(e,t,i){this.handleViewMessage(e,t,i)},t.handleViewMessage=function(e,t,i){if(void 0===i)for(var s=0;s<this.viewListeners.length;s++)this.viewListeners[s].handleIncomingMessage(e,t);else this.viewListeners[i].handleIncomingMessage(e,t)},t.addControllerListener=function(e){if(void 0===e.handleIncomingMessage)throw new Error("Controller listener does not have a handleIncomingMessage");this.controllerListeners.push(e)},t.removeControllerListener=function(e){e=this.controllerListeners.indexOf(e);-1!==e&&this.controllerListeners.splice(e,1)},t.addViewListener=function(e){if(void 0===e.handleIncomingMessage)throw new Error("Controller listener does not have a handleIncomingMessage");e=this.viewListeners.push(e);this.toController("subscribe",{listener:e})},t.removeViewListener=function(e){e=this.viewListeners.indexOf(e);-1!==e&&this.viewListeners.splice(e,1)},t.destroy=function(){this.controllerListeners=[],this.viewListeners=[]},e}),define("CatLab/Webremote/Messages/NavigateableProxy",[],function(){function e(e,t){this.prefix=t||"",this.controls={navigation:["left","right"],toggle:["a"],manipulation:["down","up"],back:["b","back"]},this.views=[],this.keyInputCallbacks={},this.boundCallbacks={},e.addControllerListener(this),this.messageBus=e}var t=e.prototype;return t.handleIncomingMessage=function(e,t){if(e===this.prefix+"nav:controls")return this.controls=t.controls,this.views.forEach(function(e){this.refreshView(e)}.bind(this)),!0},t.addView=function(e){this.views.push(e),this.refreshView(e)},t.refreshView=function(t){this.reattachClick(t.control(this.controls.navigation[0]),this.previous),this.reattachClick(t.control(this.controls.navigation[1]),this.next),this.reattachClick(t.control(this.controls.manipulation[0]),this.down),this.reattachClick(t.control(this.controls.manipulation[1]),this.up),this.controls.toggle.forEach(function(e){void 0===this.keyInputCallbacks[e]&&(this.keyInputCallbacks[e]=function(){this.keyInput(e)}),this.reattachClick(t.control(e),this.keyInputCallbacks[e].bind(this))}.bind(this)),this.controls.back.forEach(function(e){this.reattachClick(t.control(e),this.back)}.bind(this))},t.reattachClick=function(e,t){this.boundCallbacks[t]||(this.boundCallbacks[t]=t.bind(this)),e.off("click",this.boundCallbacks[t]),e.click(this.boundCallbacks[t])},t.keyInput=function(e){this.messageBus.toView(this.prefix+"nav:keyInput",{button:e})},t.previous=function(){this.messageBus.toView(this.prefix+"nav:previous")},t.next=function(){this.messageBus.toView(this.prefix+"nav:next")},t.up=function(){this.keyInput("up")},t.down=function(){this.keyInput("down")},t.back=function(){this.messageBus.toView(this.prefix+"nav:back")},t.destroy=function(){this.messageBus.removeControllerListener(this)},e.handleMessage=function(e,t,i,s){if(e.substring(0,(s=void 0===s?"":s).length)===s){switch(e=e.replace(s,"")){case"nav:previous":return i.previous(),!0;case"nav:next":return i.next(),!0;case"nav:keyInput":return i.keyInput(t.button),!0;case"nav:back":return i.triggerBack(),!0}return!1}},e}),define("CatLab/Webremote/Controllers/Portal",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Messages/MessageBus","CatLab/Webremote/Messages/NavigateableProxy"],function(i,e,t,n,s,o){function r(e,t){this.initializeEventable(),this.Webcontrol=e,this.options=t,this.controlDisabled=!1,this.users=[],this.ensureOption("allowChangeNickname",!0),this.ensureOption("allowNonDisplayPlayers",!0),this.ensureOption("customFunctions",{}),this.ensureOption("minPlayers",1),this.ensureOption("maxPlayers",4),this.ensureOption("activePlayersPanel",!1),this.ensureOption("customViews",!1),this.ensureOption("authentication",e.AUTH_NOT_REQUIRED),this.ensureOption("localAuthenticatable",!1),this.ensureOption("allowPlayersWithoutDisplay",!0),this.ensureOption("start",function(){alert("This is where the game would start, if one would have set a 'start' option.")}),this.Webcontrol.getMessageBus().addControllerListener(this),this.messageBus=e.getMessageBus(),this.navigatableProxy=new o(this.messageBus,"portal:"),this.useCatLabViews()&&e.loadViews(i.getSocketURL(!0)+"/webremote/views/default.xml"),this.eventListeners=[],this.initialize()}e=r.prototype=new e;return e.handleIncomingMessage=function(e,t){switch(e){case"subscribe":this.updateUsers();break;case"start":this.startGame();break;case"back":this.back()}},e.initialize=function(){var e=this.Webcontrol.on("user:join",function(e){e.isMainGroup()&&(this.userConnect(e),this.eventListeners.push(e.on("login",function(){this.updateUsers()}.bind(this))))}.bind(this));this.eventListeners.push(e),this.Webcontrol.getUsers().forEach(function(e){e.isMainGroup()&&this.userConnect(e)}.bind(this))},e.updateUsers=function(){this.updateState();let s=[];this.Webcontrol.getUsers().forEach(function(e){var t,i;e.isMainGroup()&&(i=null,(t=e.getUser())&&(i={image:t.avatar}),s.push({active:e.isActive(),color:e.getColor(),profile:i,type:e.getType()}))}),this.messageBus.toView("users:update",{users:s})},e.updateState=function(){var e={activePlayers:this.countActiveUsers(),minPlayers:this.options.minPlayers,maxPlayers:this.options.maxPlayers,connectInstructions:this.getConnectInstructions(),startAndLoginInstructions:this.getStartAndLoginInstructions(),showInactivePlayers:this.supportInactivePlayers(),qrUrl:this.getQrCodeUrl()};this.messageBus.toView("state:change",{state:e})},e.ensureOption=function(e,t){void 0===this.options[e]&&(this.options[e]=t)},e.useCatLabViews=function(){return!1===this.options.customViews},e.getToggleView=function(e){var t="",t=this.supportInactivePlayers()?"catlab-portal-toggle":"catlab-portal";return this.isMaster(e)||(t+="-nostart"),t},e.addUser=function(e){e.clearControls(),this.users.push(e),this.supportInactivePlayers()||this.forceToggleableUser(e)||this.activateUser(e),this.trigger("users:update"),this.updateUsers()},e.activateUser=function(e){e.isActive()||(e.hasDisplay()||this.options.allowPlayersWithoutDisplay?(this.trigger("user:activate",e),e.setActive(!0,this.supportInactivePlayers()),this.updateUsers()):this.deactivateUser(e))},e.deactivateUser=function(e){e.isActive()&&(this.trigger("user:deactivate",e),e.setActive(!1,this.supportInactivePlayers()),this.updateUsers())},e.toggleActive=function(e){(this.supportInactivePlayers()||this.forceToggleableUser(e))&&(e.isActive()?this.deactivateUser(e):this.activateUser(e),this.trigger("users:update"))},e.forceToggleableUser=function(e){return!e.hasDisplay()&&!!this.options.allowPlayersWithoutDisplay},e.hasUsersWithoutDisplay=function(){if(this.options.allowPlayersWithoutDisplay)for(var e=0;e<this.users.length;e++)if(!this.users[e].hasDisplay())return!0;return!1},e.countActiveUsers=function(){return this.getActiveUsers().length},e.getActiveUsers=function(){for(var e=[],t=0;t<this.users.length;t++)this.users[t].isActive()&&e.push(this.users[t]);return e},e.userConnect=function(e){this.eventListeners.push(e.on("master:change",function(){this.updateUserView(e)},this)),this.addUser(e),this.updateUserView(e),this.trigger("user:connect",e)},e.updateUserView=function(e){var t=e.setView(this.getToggleView(e));this.controlDisabled||this.enableControls(e,t),this.enableDefaultPlayerControls(e,t)},e.disableControls=function(){this.controlDisabled=!0;for(var e=0;e<this.users.length;e++)this.users[e].clearControls()},e.enableControls=function(e,t){var i;void 0!==e?(i=e.getPortalControls(),t.control(i.toggleActive).click(function(){this.toggleActive(e)}.bind(this)),t.control(i.start).click(function(){this.startGame()}.bind(this)),t.control(i.back).click(function(){this.back()}.bind(this)),this.supportsLocalAuthentication()&&t.control(i.authenticate).click(function(){e.isLocalAuthentication()||this.authenticate(e)}.bind(this)),this.navigatableProxy.addView(t)):(this.controlDisabled=!1,this.users.forEach(function(e){this.updateUserView(e)}.bind(this)))},e.enableDefaultPlayerControls=function(i,s){if(s.control("name").setLabel(i.getNickname()),s.listenTo(i,"login",function(){s.control("name").setLabel(i.getNickname())}),this.options.allowChangeNickname&&s.control("change-nickname").click(function(){this.changeNickname(i).then(function(){this.updateUserView(i)}.bind(this))}.bind(this)),this.options.customFunctions)for(var e in this.options.customFunctions)this.options.customFunctions.hasOwnProperty(e)&&function(e,t){s.control(e).click(function(){t(i).then(function(){this.updateUserView(i)}.bind(this))}.bind(this))}.bind(this)(e,this.options.customFunctions[e])},e.changeNickname=function(t){var i=new n,s=t.setView("catlab-nickname");return s.changeValue("name",t.getNickname()),s.control("a").click(function(){var e=s.getValues().name;!e||32<e.length||(t.setNickname(e),i.resolve())}),i.promise()},e.supportInactivePlayers=function(){return this.options.activePlayersPanel},e.supportsLocalAuthentication=function(){return this.options.localAuthenticatable&&this.Webcontrol.canAuthenticate()},e.isMaster=function(e){return e.isMaster()},e.getPortalLabels=function(){var n={start:[],back:[],toggleActive:[],authenticate:[]};return this.Webcontrol._userlibrary.each(function(e){var t,i=e.getPortalControls();for(t in i)if(i.hasOwnProperty(t)){var s=e.control(i[t]).getLabelData();if(!s)continue;void 0===n[t]&&(n[t]=[]),-1===n[t].findIndex(function(e){return e.label===s.label&&e.image===s.image})&&n[t].push(s)}}.bind(this)),n},e.authenticate=function(e){this.activateUser(e),this.disableControls();var t=this.Webcontrol.authenticationController(e,{messageBus:this.messageBus});this.messageBus.toView("auth:open",{}),t.controller.setNavigatableUsers([e]),t.controller.on("close",function(){this.enableControls(),this.updateUsers()}.bind(this))},e.countAuthenticated=function(e){void 0===e&&(e=!0);for(var t=0,i=0;i<this.users.length;i++)!this.users[i].isAuthenticated()||e&&!this.users[i].isActive()||t++;return t},e.checkAuthentication=function(){var e=this.countAuthenticated();switch(this.options.authentication){case this.Webcontrol.AUTH_REQUIRED_ALL:return e===this.countActiveUsers();case this.Webcontrol.AUTH_REQUIRED_ONE:return 0<e;case this.Webcontrol.AUTH_REQUIRED_ONE_INACTIVE:return 0<this.countAuthenticated(!1);case this.Webcontrol.AUTH_NOT_REQUIRED:return!0;default:throw"Authentication requirement "+this.options.authentication+" not found."}},e.startGame=function(){var e=this.countActiveUsers();if(e<this.options.minPlayers)this.messageBus.toView("alert",{message:"You need "+this.options.minPlayers+" players to start playing",localized:["You need %s players to start playing",this.options.minPlayers],id:"not-enough-players"});else if(e>this.options.maxPlayers)this.messageBus.toView("alert",{message:"Your license is limited to "+this.options.maxPlayers+" players",localized:["Your license is limited to %s players",this.options.maxPlayers],id:"exceeds-max-players"});else if(this.checkAuthentication())this.Webcontrol.setView("catlab-game-already-started",this.Webcontrol._userlibrary.not(this.getActiveUsers())),this.Webcontrol.setView("catlab-game-starting",this.getActiveUsers()),this.destroy(),this.options.start(this.getActiveUsers());else switch(this.options.authentication){case this.Webcontrol.AUTH_REQUIRED_ALL:this.messageBus.toView("alert",{message:"All active players must be authenticated.",localized:["All active players must be authenticated."],id:"not-all-authenticated"});break;case this.Webcontrol.AUTH_REQUIRED_ONE:case this.Webcontrol.AUTH_REQUIRED_ONE_INACTIVE:this.messageBus.toView("alert",{message:"At least one player must be authenticated.",localized:["At least one player must be authenticated."],id:"not-one-authenticated"})}},e.back=function(){void 0!==this.options.back&&(this.destroy(),this.options.back())},e.getConnectURL=function(){return this.Webcontrol.getConnectURL()},e.getConnectToken=function(){return this.Webcontrol.getConnectTokenForDisplay()},e.getQrCodeUrl=function(){var e=this.getConnectURL();return(e=e&&"http"!==e.substring(0,4)?"https://"+e:e)+"?t="+this.Webcontrol.getConnectToken()},e.getUsers=function(){return this.users},e.setMinPlayers=function(e){return this.options.minPlayers=e,this.trigger("options:change"),this.updateState(),this},e.setMaxPlayers=function(e){return this.options.maxPlayers=e,this.trigger("options:change"),this.updateState(),this},e.getMessageBus=function(){return this.messageBus},e.getConnectInstructions=function(){return void 0!==this.Webcontrol.provider.getConnectInstructions?this.Webcontrol.provider.getConnectInstructions():["Use your tablet or smartphone to surf to %s and enter code %s.",this.getConnectURL(),this.getConnectToken()]},e.getStartAndLoginInstructions=function(){var e;return void 0!==this.Webcontrol.provider.getStartAndLoginInstructions?this.Webcontrol.provider.getStartAndLoginInstructions():this.hasUsersWithoutDisplay()?(e=this.getPortalLabels(),this.supportsLocalAuthentication()&&(this.showInactivePlayers||this.hasUsersWithoutDisplay())?["Press %s to join, %s to login and %s to start.",e.toggleActive,e.authenticate,e.start]:this.supportsLocalAuthentication()?["Press %s to login and %s to start.",e.authenticate,e.start]:this.showInactivePlayers||this.hasUsersWithoutDisplay()?["Press %s to join and %s to start.",e.toggleActive,e.start]:["Press %s to start.",e.start]):[""]},e.destroy=function(){this.eventListeners&&this.eventListeners.forEach(function(e){e.unbind()}),this.messageBus.toView("portal:destroy"),this.messageBus.removeControllerListener(this),this.navigatableProxy.destroy()},r}),define("CatLab/Webremote/Controllers/RemoteAuthentication",["CatLab/Webremote/Controllers/OAuth2"],function(t){return function(e){e.setView("remote:authenticate"),e.on("user:join",function(e){e.on("login",function(e){t.addAccessToken(e.getAccessToken())}.bind(this))}.bind(this))}}),define("CatLab/Webremote/Controllers/Authentication",["CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/RemoteAuthentication","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Cookies","CatLab/Webremote/Messages/MessageBus","CatLab/Webremote/Messages/NavigateableProxy"],function(s,n,o,e,r,i,t,a){function h(e,t,i){this.initializeEventable(),this.messageBus=e.getMessageBus(),this.navigatableProxy=new a(this.messageBus,"auth:"),this.Webcontrol=e,this.user=t,this.user.control("x").click(function(){this.messageBus.toView("auth:request-remove-selected-profile")}.bind(this)),o.on("update",this.updateUsers,this),s.on("update",function(){this.updateUsers()},this),this.messageBus.addControllerListener(this)}var l=null,c=null,e=h.prototype=new e;return e.handleIncomingMessage=function(e,t){switch(e){case"subscribe":this.getLoginUrl().then(function(e){this.loginUrl=e,this.messageBus.toView("auth:loginurl",{url:e})}.bind(this)),this.updateUsers();break;case"auth:close":this.trigger("close");break;case"auth:select-user":this.selectUser(t.user);break;case"auth:remove-user":this.removeUser(t.user)}},e.link=function(){s.link(function(e){this.selectUser(e)}.bind(this))},e.updateUsers=function(){this.messageBus.toView("auth:users:update",{users:o.getAll().map(function(e){return{id:e.getId(),name:e.getName(),image:e.avatar}})})},e.selectUser=function(e){var t;(e=o.getFromId(e.id))&&(t=this).user.loginFromAuthUser(e,function(){i.setCookie("ctlb_ps_"+this.user.id,e.id),t.close()}.bind(this))},e.removeUser=function(e){(e=o.getFromId(e.id))&&(o.remove(e),this.updateUsers())},e.getUsers=function(){return o},e.close=function(){this.messageBus.toView("auth:close"),this.destroy()},e.getLoginUrl=function(){var t,e,i=new r;return t=this.Webcontrol,(null!==l?((e=new r).resolve(l),e):(null===c&&(c=new r,t.newGroup().then(function(e){new n(l=e),e.setOAuthSettings(t.getOAuthSettings()),c.resolve(e)})),c)).promise().then(function(e){i.resolve(e.getConnectURL()+"/"+e.getConnectToken())}),i.promise()},e.setNavigatableUsers=function(e){e.forEach(function(e){this.navigatableProxy.addView(e)}.bind(this)),this.messageBus.toView("labels:update",{labels:{selectProfile:[this.user.control("a").getLabelData()],removeProfile:[this.user.control("x").getLabelData()],close:[this.user.control("b").getLabelData()]}})},e.attemptLastLogin=function(){var e=i.getCookie("ctlb_ps_"+this.user.id);if(e){e=o.getFromId(e);if(e)return this.selectUser(e),!0}return!1},e.destroy=function(){this.messageBus.toView("auth:destroy"),this.messageBus.removeControllerListener(this),this.navigatableProxy.destroy()},h}),define("CatLab/Webremote/Tools/Images",["CatLab/Webremote/Config"],function(n){function e(e){this.images={},this.availableSizes=e=void 0===e?[512,256,128]:e}var t=e.prototype;return t.getImage=function(e,t){var i;return void 0!==t&&-1!==this.availableSizes.indexOf(t)||(t=this.availableSizes[0]),void 0===this.images[e+"_"+t]&&((i=new Image).crossOrigin="anonymous",i.src=this.getUrl(e,t),this.images[e+"_"+t]=i),this.images[e+"_"+t]},t.getUrl=function(e,t){if(this.isExternal(e))return e;void 0!==t&&-1!==this.availableSizes.indexOf(t)||(t=this.availableSizes[0]);for(var i=e.split("/"),s=0;s<i.length;s++)"$SIZE"===i[s]&&(i[s]=t);return e=i.join("/"),n.getAssetsURL()+e},t.isExternal=function(e){return 0===e.indexOf("http")},e}),define("CatLab/Webremote/Tools/Smileys",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Images"],function(i,s,t){function e(e){this.provider=e,this.smileyKeys=["1f98d","1f61c","1f3b7","1f32e","1f621","1f61b","1f98f","1f34c","1f596","1f34d","2660","1f61a","2602","2665","1f0cf","1f427","1f918","1f98b","1f9df","1f344","1f983","1f338","2618","1f36a","1f383","270c","1f913","1f40d","1f910","1f57a","1f641","1f36c","1f579","1f333","1f40b","1f617","1f42b","1f60d","1f42c","1f339","1f414","1f42d","1f349","1f92e","1f437","1f367","1f62c","1f428","1f994","1f911","1f369","1f9d0","1f378","1f9dd-2640","1f34e","2666","1f47d","1f60a","1f60f","1f43b","1f47b","1f425","1f919","1f346","1f4a8","1f43f","1f37a","1f40c","1f334","1f4a3","1f42e","1f379","1f42f","1f417","1f9c0","1f601","1f41a","1f61d","1f997","26c4","1f34b","1f430","1f47a","1f37c","1f3b1","1f95d","1f433","1f41b","1f37f","1f36d","1f60e","1f354","1f63b","1f680","1f996","1f924","1f341","1f43a","1f922","1f436","1f43c","1f332","1f31a","1f335","1f336","2623","1f31e","1f63d","1f421","1f438","1f63a","1f32d","1f986","1f388","1f41e","1f98c","1f91e","1f64a","1f638","1f3b5","1f43d","1f363","1f373","1f435","1f628","1f635","1f377","1f47e","1f984","1f3a9","1f439","1f925","1f929","1f951","1f4a9","1f921","1f92a","1f96a","1f41f","1f419","1f420","2663","1f40a","1f989","1f91f","1f63c","1f3f3-1f308","1f98a","1f431","1f920","1f41d","1f608","1f612","1f987","1f3ba","1f355","270b","1f98e","1f41c","1f917"],this.taken={},this.takenAmount=0,this.playerKnowsAboutNonUniqueSmileys={},this.images=new t,this.randomSmileys=this.smileyKeys.slice(0),s.shuffle(this.randomSmileys)}var n=e.prototype;return n.shouldHaveUniqueSmileys=function(){return this.takenAmount<this.smileyKeys.length/3},n.setTakenSmileys=function(e){this.taken=e},n.getTakenSmileys=function(e){if(!this.shouldHaveUniqueSmileys())return{};e=this.identifierToText(e);var t,i={};for(t in this.taken)this.taken.hasOwnProperty(t)&&this.taken[t]!==e&&(i[t]=this.taken[t]);return i},n.getRandom=function(e){for(var t=null;null===t&&this.randomSmileys;)if(t=this.randomSmileys.shift(),this.reserve(t,e)||(t=null),0===this.randomSmileys.length)return this.randomSmileys=this.smileyKeys.slice(0),s.shuffle(this.randomSmileys),this.randomSmileys.shift();return t},n.reserve=function(e,t){return this.isExternalSmiley(e)?(this.unreserve(t),!0):(t=this.identifierToText(t),void 0!==this.taken[e]&&this.taken[e]===t?(this.taken[e]=t,!0):!!this.isAvailable(e)&&(this.unreserve(t),this.taken[e]=t,this.takenAmount++,!0))},n.unreserve=function(e){for(var t in e=this.identifierToText(e),this.taken)this.taken.hasOwnProperty(t)&&this.taken[t]===e&&(this.taken[t]=null,delete this.taken[t],this.takenAmount--)},n.isAvailable=function(e){return!this.shouldHaveUniqueSmileys()||!!this.isExternalSmiley(e)||null==this.taken[e]},n.identifierToText=function(e){return JSON.stringify(e)},n.isExternalSmiley=function(e){return"http"===e.substring(0,4).toLowerCase()},n.getUrl=function(e){var t=this.getImageUrl(e);return t?this.isExternalSmiley(e)?e:i.getAssetsURL()+t:null},n.getImageUrl=function(e){return null===e?null:this.isExternalSmiley(e)?e:"smileys/"+e+".png"},n.getHtml=function(e){return null===e?null:'<span class="smiley" style="width: 64px; height: 64px; display: inline-block; background-image: url(\''+this.getUrl(e)+"');\"></span>"},n.getElement=function(e){var t;return null===e?null:((t=document.createElement("div")).innerHTML=this.getHtml(e),t.firstChild)},n.getImage=function(e){return null===e?null:this.images.getImage(this.getImageUrl(e))},n.refreshTakenSmileys=function(e){this.shouldHaveUniqueSmileys()?e.emit("smileys:taken",{smileys:this.getTakenSmileys(e.getIdentifier())}):this.playerKnowsAboutNonUniqueSmileys[this.getStringIdentifier(e)]},n.getStringIdentifier=function(e){return e.type+":"+e.id},e}),define("CatLab/Webremote/Tools/MessageCounter",["CatLab/Webremote/Tools/Eventable"],function(e){function t(e){this.interval=e||1e3,this.initializeEventable(),this.countIncoming=0,this.countOutgoing=0;var t,i,s=(new Date).getTime();setInterval(function(){t=(new Date).getTime(),i=t-s,s=t,this.trigger("tick",{in:this.countIncoming,out:this.countOutgoing,dt:i}),this.countIncoming=0,this.countOutgoing=0}.bind(this),this.interval)}e=t.prototype=new e;return e.incoming=function(){this.countIncoming++},e.outgoing=function(){this.countOutgoing++},t}),define("CatLab/Webremote/Views/Portal",["CatLab/Webremote/Config"],function(Q,e){return function(e){var n=e.element||document.body,t=n,i=e.countdown||5e3,s=e.done||function(){alert("Game should start now... yet it doesn't.")},o=e["min-players"]||1,r=(o<1&&(o=1),e["max-players"]||1e3);r<o&&(r=o);var a,h,l,c,u,d,f,g,p,m,b,v=!e.customViews,A=[],y=!1,w=!1,C=null,k=this;function I(n){n.setView("catlab-portal-toggle"),n.control("join-game").click(function(){(e=>{if(W(e)){e.control("join-game").setLabel("JOIN");for(var t=e,i=0;i<A.length;i++)if(A[i].getId()==t.getId())return A.splice(i,1)}else e.control("join-game").setLabel("LEAVE"),A.push(e)})(n),x(),U(),P()}),n.control("start-game").click(function(){var e;y?P():A.length<o?F(o+" players are required to start the game. Please gather more friends."):A.length>r?F("This game can have only "+r+" players."):(e=i,P(),y=!0,(f=new Date).setTime((new Date).getTime()+e),u.show(),d=setInterval(B,100))}),n.control("down").click(function(){L(n)}),n.control("right").click(function(){L(n)}),n.control("left").click(function(){T(n)}),n.control("up").click(function(){T(n)}),n.control("a").click(function(){var e,t,i,s;e=n,w&&_(e)?(t=b.find(".available-accounts").find("li.selected"))&&(t=WebcontrolOAuthClient.getFromToken(t.attr("data-accessToken")))&&(s=t.access_token,C.setUserData(s,t.user),S()):(y&&P(),w||(i=e,Webcontrol.getOAuthClient(function(t){t.onInit(function(){E(t)}),WebcontrolAccessKeyLibrary.init(function(){w=!0,C=i,m.show(),b.show();var e=$('<a href="javascript:void(0);">Link new account</a>');e.click(function(){t.getNewAccessToken(function(){E(t)})}),b.find(".link-new-account").html(e)}),E(t)})))}),n.control("b").click(function(){w&&_(n)&&(C.setUserData(!1),S())}),M(),U()}function T(e){w&&_(e)&&(e=b.find(".available-accounts").find("li.selected"),b.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(e.length&&e.prev().length?e.prev():b.find(".available-accounts").find("li").last()).addClass("selected").removeClass("unselected"))}function L(e){w&&_(e)&&(e=b.find(".available-accounts").find("li.selected"),b.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(e.length&&e.next().length?e.next():b.find(".available-accounts").find("li").first()).addClass("selected").removeClass("unselected"))}function _(e){return C&&e.getId()==C.getId()}function S(){m.hide(),b.hide(),w=!1,C=null}function E(e){b.find(".available-accounts").html("");for(var t=e.listUsers(),i=0;i<t.length;i++){var s=$("<li>"+t[i].user.username+"</li>");s.addClass("unselected"),s.attr("data-accessToken",t[i].access_token),b.find(".available-accounts").append(s)}}function U(){0<Webcontrol.getControlLabels("join-game").length?($(".buttoninstructions.join-game").show().find(".labels").html(Webcontrol.getControlLabels("join-game").join(", ")),$(".buttoninstructions.start-game").show().find(".labels").html(Webcontrol.getControlLabels("start-game").join(", "))):($(".buttoninstructions.join-game").hide(),c.hide())}function W(e){for(var t=0;t<A.length;t++)if(A[t].getId()==e.getId())return 1}function M(){var e=Webcontrol.getUsers();a.html("");for(var t=[],i=0;i<e.length;i++)W(e[i])||t.push(e[i]);for(0==t.length&&a.append('<li class="empty"><span>More players? Add devices!</span></li>'),i=0;i<t.length;i++)a.append('<li class="user '+t[i].getType()+'" style="background-color: '+t[i].getColor()+'"><i class="'+t[i].getIcon()+'"></i><span>'+t[i].getName()+"</span></li>")}function x(){h.html(""),0==A.length&&h.append('<li class="empty"><span class="buttoninstructions join-game">Press <span class="labels"></span> to join the game.</span></li>');for(var e=0;e<A.length;e++)h.append('<li class="user '+A[e].getType()+'" style="background-color: '+A[e].getColor()+'"><i class="'+A[e].getIcon()+'"></i><span>'+A[e].getName()+"</span></li>");M()}function B(){g=Math.ceil((f.getTime()-(new Date).getTime())/1e3),u.find(".counter").html(g),g<0&&(void 0!==t&&(void 0!==t.hide?t.hide():void 0!==t.style&&(t.style.display="none")),P(),s(A))}function P(){y=!1,d&&(F("Countdown stopped!"),u.hide(),clearInterval(d),d=null)}function F(e){var t=jQuery("<p></p>").html(e).appendTo(p);setTimeout(function(){t.fadeOut(1e3,function(){t.remove()})},3e3)}this.loginInformation="Login into your account and get access to more game features now!",0<n.length?n.addClass("webremote-portal"):n.className=n.className+" webremote-portal",void 0!==e.theme&&(e=Q.getSocketURL()+"/webremote/themes/"+e.theme+"/"+e.theme+".css",Webcontrol._loadCSS(e),Webcontrol._loadCSS(Q.getSocketURL()+"/webremote/themes/font-awesome/css/font-awesome.min.css")),n.innerHTML='<div class="loading"><p>Please wait, loading socket.io.</p></div>',Webcontrol.initialize(function(){n.innerHTML='<div class="loading"><p>Please wait, loading jQuery.</p></div>',n.innerHTML="";var e=n,e=(n=jQuery('<div class="webremote-portal-inner"></div>').appendTo(e),(n=jQuery(n)).html('<div class="loading"><p>Please wait, connecting to server.</p></div>'),v&&Webcontrol.loadViews(Q.getSocketURL(!0)+"/webremote/views/default.xml"),n.html("<h1>Player lobby</h1>"),m=$("<div></div>"),b=$('<div><h2>Select account</h2><div class="information"><p>'+k.loginInformation+'</p></div><ul class="available-accounts"></ul><p class="link-new-account"></p></div>'),m.addClass("accounts-overlay"),b.addClass("accounts"),m.hide(),b.hide(),n.append(m),n.append(b),jQuery('<div class="connected-users"><div class="inner"><h2>Connected devices</h2></div></div>')),t=(a=jQuery('<ul class="connected-users"></ul>').appendTo(e.find(".inner")),jQuery('<div class="active-users"><div class="inner"><h2>Active users</h2></div></div>'));h=jQuery('<ul class="active-users"></ul>').appendTo(t.find(".inner")),n.append(e),n.append(t),(e=jQuery('<div class="connection-information"><div class="inner"><h2>Instructions</h2><p>Take your smartphone, navigate to <span class="url"></span> and use token <span class="token"></span></p></div></div>')).find(".token").html(Webcontrol.getConnectToken()),e.find(".url").html(Webcontrol.getConnectURL()),l=jQuery('<p class="buttoninstructions join-game">Press <span class="labels"></span> to join the game.</p>'),c=jQuery('<p class="buttoninstructions start-game">Press <span class="labels"></span> to start the game.</p>'),p=jQuery('<div class="errors"></div>').appendTo(n),e.append(l),e.append(c),n.append(e),u=jQuery('<div class="countdown-background"></div><div class="countdown"><p>Game will start in <span class="counter">5</span></p></div>').hide().appendTo(n),Webcontrol.on("user:join",function(e){I(e)});for(var i=Webcontrol.getUsers(),s=0;s<i.length;s++)I(i[s]);Webcontrol.on("user:leave",M),M(),x(),U()})}}),define("CatLab/Webremote/ViewFactory/ViewFactory",["CatLab/Webremote/Views/Portal"],function(t){function e(){}return e.prototype.getPortal=function(e){return new t(e)},e}),define("CatLab/Webremote/Views/ConnectionTrouble",["CatLab/Webremote/Tools/Translator"],function(e){function t(){this.visible=!1,this.div=null,this.timeoutTillShow=3e3,this.showTimeout=null,this.message=null}var i=t.prototype;return i.show=function(){this.visible||(this.visible=!0,this.div)||(this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),setTimeout(function(){this.div||this.visible&&(this.showTimeout=null,this.div=document.createElement("div"),document.body.appendChild(this.div),this.div.style.position="absolute",this.div.style.right="10px",this.div.style.top="10px",this.div.style.width="350px",this.div.style.padding="10px",this.div.style.border="1px solid red",this.div.style.background="black",this.div.style.zIndex="100000",this.div.style.textAlign="center",this.div.style.color="white",this.div.style.font="Sans-serif",this.div.style.fontSize="15px",this.message?this.text(this.message):this.text(e.t("Connection lost")))}.bind(this),this.timeoutTillShow))},i.text=function(e){this.message=e,this.div&&(this.div.innerHTML="<p>"+e+"</p>")},i.hide=function(){this.visible=!1,this.div&&this.div.parentNode&&this.div.parentNode.removeChild(this.div),this.showTimeout&&clearTimeout(this.showTimeout),this.message=null,this.div=null,this.showTimeout=null},t}),define("CatLab/Webremote/Synchronization/MessageQueue",[],function(){function e(){this.queue=[]}var t=e.prototype;return t.add=function(e,t,i){this.queue.push({action:e,data:t,ack:i})},t.flush=function(){var e=this.queue;return this.queue=[],e},t.compactFlush=function(){var s,n,o,r,a=[],e=this.flush();return 0===e.length?e:(n={user:{},group:{}},o=0,r={},e.forEach(function(e){if(o++,this.canCompact(e)){var t=null;void 0!==e.data.user?t="user":void 0!==e.data.group&&(t="group"),void 0===n[t][e.action]&&(n[t][e.action]=[]);for(var i=0;i<n[t][e.action].length;i++)if(s=n[t][e.action][i],this.isSimilarMessage(s.event,e)&&(void 0===r[e.data[t]]||r[e.data[t]]<s.index))return r[e.data[t]]=s.index,s.event.data[t].push(e.data[t]),void s.event.data._d.push(this.getDifference(s.event,e));Array.isArray(e.data[t])||(e.data[t]=[e.data[t]]),e.data._d=[{}],r[e.data[t]]=o,n[t][e.action].push({event:e,index:o})}a.push(e)}.bind(this)),a)},t.moveToEnd=function(e,t){e.push(e.splice(e.indexOf(t),1)[0])},t.isSimilarMessage=function(e,t){return e.action===t.action&&this.getCompareDataString(e)===this.getCompareDataString(t)},t.getDifference=function(e,t){var i,s={};for(i in t.data)if(t.data.hasOwnProperty(i)){switch(i){case"user":case"group":case"_d":case"_i":continue}void 0!==e.data[i]&&e.data[i]===t.data[i]||(s[i]=t.data[i])}return s},t.getCompareDataString=function(e){e=Object.assign({},e.data);return delete e.user,delete e.group,delete e.viewId,delete e._d,delete e._i,JSON.stringify(e)},t.canCompact=function(e){return null==e.ack&&void 0!==e.data&&(void 0!==e.data.user||void 0!==e.data.group)},e.unpack=function(e,t){if(void 0===e[t])return[e];var i=Array.isArray(e[t])?e[t]:[e[t]],s=[];void 0!==e._d&&(s=Array.isArray(e._d)?e._d:[e._d]);for(var n=[],o=0;o<i.length;o++){(r={})[t]=i[o];var r=Object.assign({},e,r,void 0!==s[o]?s[o]:{});delete r._d,n.push(r)}return n},Object.defineProperty(t,"length",{get:function(){return this.queue.length}}),e}),define("CatLab/Webremote/Tools/Proxy",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred"],function(i,s){function e(){}function n(e,t,i){var s=(()=>{for(var e=!1,t=0;t<o.length;t++){try{e=o[t]()}catch(e){continue}break}return e})();s&&(s.open(i?"POST":"GET",e,!0),i&&s.setRequestHeader("Content-type","application/x-www-form-urlencoded"),s.onreadystatechange=function(){4==s.readyState&&(200==s.status||304==s.status?t(s):console.error("CatLab Remote HTTP error "+s.status))},4!=s.readyState)&&s.send(i)}var o=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];return e.prototype.get=function(e){i.getProxy()&&(e=i.getProxy()+encodeURIComponent(e));var t=new s;return n(e,function(e){t.resolve(e.responseText)}),t.promise()},new e}),define("CatLab/Webremote/Providers/Provider",["CatLab/Webremote/Synchronization/MessageQueue","CatLab/Webremote/Tools/Proxy","CatLab/Webremote/Tools/Deferred"],function(e,n,o){function t(){this.initializeProvider()}var i=t.prototype;return i.initializeProvider=function(){this.queue=new e,this.postInitializeQueue=[],this.scheduled=!1,this.initialized=!1,this.sendBurstDelay=10,this.maxQueueSize=2500,this.messageCounter=null,this.events={},this.viewNameIdentifierMap={}},i.getProviderSettings=function(){var e=new o;return e.resolve({}),e.promise()},i.setMessageCounter=function(e){this.messageCounter=e},i.initMaster=function(e){this.master=e},i.initPlayer=function(e){this.master=e},i.connect=function(){var e=new o;return e.resolve(),e.promise()},i.disconnect=function(){this.off()},i.setOAuthSettings=function(e){this.emit("oauth:set",e)},i.canProviderLoadExternalXml=function(){return!1},i.canProxyFiles=function(){return!1},i.loadViews=function(t,e,i){var s=new o;return void 0===e&&(e=!1),void 0===i&&(i=this),this.canProviderLoadExternalXml()&&!e?i.emit("view:load",{url:t},function(){s.resolve()}):n.get(t).then(function(e){this.parseViews(e,t,i).then(function(){s.resolve()})}.bind(this)),s.promise()},i.parseViews=function(e,t,i){var s=new o;return void 0===t&&(t=e),void 0===i&&(i=this),void 0!==this.viewNameIdentifierMap[t]?i.emit("view:load",{identifier:this.viewNameIdentifierMap[t]},function(){s.resolve()}):i.emit("view:load",{xml:e},function(e){e&&e.identifier&&(this.viewNameIdentifierMap[t]=e.identifier),s.resolve()}.bind(this)),s.promise()},i.toMaster=function(e,t,i){this.emit(e,t,i)},i.toPlayers=function(e,t,i){this.emit(e,t,i)},i.toPlayer=function(e,t,i,s){i.user=e.getId(),this.emit(t,i,s)},i.toGroup=function(e,t,i,s){i.group=e.getId(),this.emit(t,i,s)},i.emit=function(e,t,i){this.initialized?this.queue?(this.queue.add(e,t,i),this.queue.length>this.maxQueueSize?(clearTimeout(this.scheduled),this.scheduled=null,this.executeQueue()):this.scheduled||(this.scheduled=setTimeout(function(){this.scheduled=null,this.executeQueue()}.bind(this),this.sendBurstDelay))):this.emitOne(e,t,i):this.postInitializeQueue.push({action:e,data:t,ack:i})},i.createGroup=function(e,t,i,s){this.emit("group:create",{externalId:e,globalViews:t,shareColor:i,tags:s=void 0===s?[]:s})},i.executeQueue=function(){this.initialized&&this.emitAll()},i.setInitialized=function(){var e;for(this.initialized=!0;e=this.postInitializeQueue.shift();)this.emit(e.action,e.data,e.ack)},i.setup=function(e){this.emit("master:setup",e)},i.reset=function(e){this.emit("master:reset",null,function(){e()})},i.getStaticUrl=function(e){return e},i.reconnect=function(e,t,i,s){var n=new o;return this.emit("master:reconnect",{token:e,accessToken:t,gameConfig:i},function(){s(),n.resolve()}.bind(this)),n.promise()},i.off=function(){this.events={}},i.on=function(e,t){this._addEvent(e,t,!1),this._touchEvent(e)},i.once=function(e,t){this._addEvent(e,t,!0),this._touchEvent(e)},i._addEvent=function(e,t,i){void 0===this.events[e]&&(this.events[e]=[]),this.events[e].push({callback:t,once:i})},i._touchEvents=function(){for(var e in this.events)this.events.hasOwnProperty(e)&&this._touchEvent(e)},i._touchEvent=function(e){},i._trigger=function(e,i){var s;void 0!==this.events[e]&&(s=[],this.events[e].forEach(function(e){var t=e.callback;e.once&&s.push(e);try{t.apply(this,[i])}catch(e){console.error(e)}}),0<s.length)&&(s.unshift(this.events),function(e){for(var t,i,s=arguments,n=s.length;1<n&&e.length;)for(t=s[--n];-1!==(i=e.indexOf(t));)e.splice(i,1);return e}.apply(this,s))},i.getConnectURL=function(e){return null},i.getConnectToken=function(e){return null},i.tokenConnect=function(e){var t=new o;return t.resolve(),t.promise()},i.noTokenConnect=function(){var e=new o;return e.resolve(),e.promise()},i.restoreProviderSettings=function(e){},i.serializeProviderSettings=function(){return{}},i.proxyFile=function(e){var t=new o;return this.emit("file:proxy",{url:e},function(e){t.resolve({url:e.url})}.bind(this)),t.promise()},t}),define("CatLab/Webremote/Providers/SocketIO",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Tools"],function(e,r,a,t){function i(){this.initializeProvider(),this.userId=null,this.randomToken=t.getUuid(),this.loadBalancerSessionToken="connid",this.socket=null,this._registeredEvents={},this._host=null}var h=null,e=i.prototype=new e;return e.getProviderSettings=function(){var t=new a;return r.getServerList()?r.getServerList().getSelectedServer().done(function(e){t.resolve({host:e})}.bind(this)).fail(function(e){alert(e),t.reject(e)}.bind(this)):t.resolve({}),t.promise()},e.canProviderLoadExternalXml=function(){return!0},e.canProxyFiles=function(){return!0},e.connect=function(s,n){var t,o=new a;return this.log("Loading socket.io"),t=function(){this.log("Connecting to socket.io");var e,t=r.getSocketURL(),i=(this._host?t=this._host:void 0!==n.host&&n.host&&(t=(e=r.getProtocol())?e+"://"+n.host:"//"+n.host,this._host=t),this.socket=h(t+"/"+s+"?"+this.loadBalancerSessionToken+"="+this.randomToken,{withCredentials:!1,reconnection:!0}),!1);this.socket.on("connect_error",function(e){i?this._trigger("disconnect"):(this.socket.off(),this.socket.disconnect(),this.socket=null,o.reject())}.bind(this)),this.socket.once("connect",function(){i||(i=!0,this.setInitialized(),this.socket.io.on("reconnect",function(e){this._trigger("reconnect")}.bind(this)),this._touchEvents(),o.resolve())}.bind(this))}.bind(this),require(["socket.io-client"],function(e){h=e,t()}),o.promise()},e.disconnect=function(e){void 0===e&&(e=!0),this.initialized=!1,this.socket&&((e?this:(this._registeredEvents={},this.socket)).off(),this.socket.disconnect(),this.socket=null)},e.off=function(){this._registeredEvents={},this.events={},this.socket.off()},e.setUserId=function(e){return this.userId=e,this},e.emitAll=function(){var e,t=this.queue.compactFlush();if(t.length)for(;e=t.shift();)this.emitOne(e.action,e.data,e.ack)},e.emitOne=function(e,t,i){this.socket.emit(e,t,i),this.messageCounter&&this.messageCounter.outgoing()},e.log=function(){this.master.log.apply(arguments)},e.getStaticUrl=function(e){return e.indexOf("?")<0?e+="?":e+="&",e+(this.loadBalancerSessionToken+"="+this.randomToken)},e._detachEvents=function(e){this.socket&&this.socket.off(e)},e._touchEvent=function(t){this.socket&&void 0===this._registeredEvents[t]&&(this.socket.on(t,function(e){this._trigger(t,e)}.bind(this)),this._registeredEvents[t]=!0)},e._handleSocketIoEvent=function(e,t){switch(e){case"connect":case"disconnect":break;default:return this._trigger(e,t)}},e.getConnectURL=function(e){return r.getServerList()?r.getServerList().getConnectURL():e},e.getConnectToken=function(e){return r.getServerList()?r.getServerList().getConnectToken(e):e},e.tokenConnect=function(e){var t=new a,i={};if(r.getServerList())try{var s=r.getServerList().getFromToken(e);i.host=s.host,e=s.token}catch(e){return t.reject(),t.promise()}return this.connect("remote",i).fail(function(){t.reject()}).then(function(){t.resolve(e)}),t.promise()},e.restoreProviderSettings=function(e){void 0!==e.serverlist&&r.getServerList()&&r.getServerList().unserialize(e.serverlist),void 0!==e.host&&(this._host=e.host)},e.serializeProviderSettings=function(){var e={host:this._host};return r.getServerList()&&(e.serverlist=r.getServerList().serialize()),e},i}),define("CatLab/Webremote/Models/Users/GamepadUser",["CatLab/Webremote/Models/Users/ControlUser"],function(e){function t(e){var t=e.id||"1";this.initialize({id:"gamepad_"+t}),this.keys=this.getDefaultKeys(e),this.clearControls()}e=t.prototype=new e;return e.getType=function(){return"gamepad"},e.getIcon=function(){return"fa fa-gamepad"},e.emit=function(){return!1},e.isLocalAuthentication=function(){return!1},e.controlFromKey=function(e){return this.control(this.keys[e].id)},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!1},e.hasTouchInput=function(){return!1},e.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"x",authenticate:"y",left:"left",right:"right"}},e.getDefaultKeys=function(e){var t="control-icons/gamepad/$SIZE/",i="gamepad-",s="🎮",n={a:"🅰️",b:"🅱️",x:"❎",y:"❎",up:"⬆️",down:"⬇️",left:"⬅️",right:"➡️",l1:"🤜",r1:"🤛"};return void 0===e.id||-1===e.id.toLowerCase().indexOf("sony")&&-1===e.id.toLowerCase().indexOf("054c")||(t="control-icons/ps-controller/$SIZE/",i="ps-controller-",s="🕹",n={a:"❎",b:"⭕",x:"🟥",y:"🔺",up:"⬆️",down:"⬇️",left:"⬅️",right:"➡️",l1:"🤜",r1:"🤛"}),{DPAD_UP:{id:"up",label:"↑",key:"DPAD_UP",emoji:s+""+n.up},DPAD_DOWN:{id:"down",label:"↓",key:"DPAD_DOWN",emoji:s+""+n.down},DPAD_RIGHT:{id:"right",label:"→",key:"DPAD_RIGHT",emoji:s+""+n.right},DPAD_LEFT:{id:"left",label:"←",key:"DPAD_LEFT",emoji:s+""+n.left},FACE_1:{id:"a",label:"A",key:"FACE_1",image:t+i+"a.gif",emoji:s+""+n.a},FACE_2:{id:"b",label:"B",key:"FACE_2",image:t+i+"b.gif",emoji:s+""+n.b},FACE_3:{id:"x",label:"X",key:"FACE_3",image:t+i+"x.gif",emoji:s+""+n.x},FACE_4:{id:"y",label:"Y",key:"FACE_4",image:t+i+"y.gif",emoji:s+""+n.y},SELECT_BACK:{id:"back",label:"SELECT",key:"SELECT_BACK"},START_FORWARD:{id:"start",label:"START",key:"START_FORWARD"},L1:{id:"l1",label:"L1",key:"L1",emoji:s+""+n.l1},R1:{id:"r1",label:"R1",key:"R1",emoji:s+""+n.r1}}},e.setStaticLabels=function(){for(var e in this.keys)this.keys.hasOwnProperty(e)&&this.control(this.keys[e].id).setStaticLabel(this.keys[e].label,"gamepad",this.keys[e].image,this.keys[e].emoji)},t}),define("CatLab/Webremote/Gamepads/GamepadAPI",["CatLab/Webremote/Models/Users/GamepadUser"],function(i){function e(){this.gamepads={},this.initialized=!1,this.Webcontrol=null}var s,t,n={12:"DPAD_UP",13:"DPAD_DOWN",15:"DPAD_RIGHT",14:"DPAD_LEFT",0:"FACE_1",1:"FACE_2",2:"FACE_3",3:"FACE_4",8:"SELECT_BACK",9:"START_FORWARD"},o=e.prototype;return o.initialize=function(e){var t;this.Webcontrol=e,this.initialized||(this.initialized=!0,e=function(){var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(s=0;s<e.length;s++)if(e[s]){for(s=0;s<e.length;s++)e[s]&&this.onConnect(e[s]);this.startGamepadPolling(),clearInterval(t)}}.bind(this),"undefined"!=typeof window&&("ongamepadconnected"in window?(window.addEventListener("gamepadconnected",function(e){this.onConnect(e.gamepad)}.bind(this)),window.addEventListener("gamepaddisconnected",function(e){this.onDisconnect(e.gamepad)}.bind(this))):t=setInterval(e,1e3)))},o.startGamepadPolling=function(){setInterval(this.poll.bind(this),50)},o.poll=function(){var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(s=0;s<e.length;s++)if(e[s])for(t=0;t<e[s].buttons.length;t++)this.gamepads[e[s].index].user&&void 0!==n[t]&&this.gamepads[e[s].index].user.controlFromKey(n[t]).update(e[s].buttons[t].pressed?1:0)},o.onConnect=function(e){var t=new i({id:e.id});this.gamepads[e.index]={user:t},this.Webcontrol.addCustomControl(t),this.startGamepadPolling()},o.onDisconnect=function(e){},new e}),define("CatLab/Webremote/SonicSync/Library/ring-buffer",[],function(){function t(e){this.array=[],this.maxLength=e}return t.prototype.get=function(e){return e>=this.array.length?null:this.array[e]},t.prototype.last=function(){return 0==this.array.length?null:this.array[this.array.length-1]},t.prototype.add=function(e){this.array.push(e),this.array.length>=this.maxLength&&this.array.splice(0,1)},t.prototype.length=function(){return this.array.length},t.prototype.clear=function(){this.array=[]},t.prototype.copy=function(){var e=new t(this.maxLength);return e.array=this.array.slice(0),e},t.prototype.remove=function(e,t){this.array.splice(e,t)},t}),define("CatLab/Webremote/SonicSync/Library/sonic-coder",[],function(){function e(e){this.freqMin=(e=e||{}).freqMin||18500,this.freqMax=e.freqMax||19500,this.freqError=e.freqError||50,this.alphabetString=e.alphabet||"\n abcdefghijklmnopqrstuvwxyz0123456789,.!?@*",this.startChar=e.startChar||"^",this.endChar=e.endChar||"$",this.alphabet=this.startChar+this.alphabetString+this.endChar}return e.prototype.charToFreq=function(e){var t=this.alphabet.indexOf(e),e=(-1==t&&(console.error(e,"is an invalid character."),t=this.alphabet.length-1),this.freqMax-this.freqMin),t=t/this.alphabet.length,e=Math.round(e*t);return this.freqMin+e},e.prototype.freqToChar=function(e){if(!(this.freqMin<e&&e<this.freqMax))if(this.freqMin-e<this.freqError)e=this.freqMin;else{if(!(e-this.freqMax<this.freqError))return console.error(e,"is out of range."),null;e=this.freqMax}var t=this.freqMax-this.freqMin,e=(e-this.freqMin)/t,t=Math.round(this.alphabet.length*e);return this.alphabet[t]},e}),define("CatLab/Webremote/SonicSync/Library/sonic-server",["./ring-buffer","./sonic-coder"],function(t,i){function e(e){this.peakThreshold=(e=e||{}).peakThreshold||-65,this.minRunLength=e.minRunLength||2,this.coder=e.coder||new i(e),this.timeout=e.timeout||300,this.debug=!!e.debug,this.peakHistory=new t(16),this.peakTimes=new t(16),this.callbacks={},this.buffer="",this.state=s,this.isRunning=!1,this.iteration=0}var s=1,n=2;return e.prototype.start=function(){try{navigator.mediaDevices||console.log("No mediadevices found"),navigator.mediaDevices.getUserMedia({audio:{optional:[{echoCancellation:!1}]}}).then(this.onStream_.bind(this)).catch(this.onStreamError_.bind(this))}catch(e){console.log(e)}},e.prototype.stop=function(){this.isRunning=!1,this.track.stop()},e.prototype.on=function(e,t){"message"==e&&(this.callbacks.message=t),"character"==e&&(this.callbacks.character=t)},e.prototype.setDebug=function(e){this.debug=e;e=document.querySelector("canvas");e&&e.parentElement.removeChild(e)},e.prototype.fire_=function(e,t){"function"==typeof e&&e(t)},e.prototype.onStream_=function(e){var t;void 0!==e.getTracks()[0]?(this.track=e.getTracks()[0],t=new AudioContext,e=(this.audioContext=t).createMediaStreamSource(e),t=t.createAnalyser(),e.connect(t),this.freqs=new Float32Array(t.frequencyBinCount),this.analyser=t,this.isRunning=!0,this.raf_(this.loop.bind(this))):console.log("No microphone found.")},e.prototype.onStreamError_=function(e){console.error("Audio input error:",e)},e.prototype.getPeakFrequency=function(){for(var e=-1/0,t=-1,i=this.freqToIndex(this.coder.freqMin);i<this.freqs.length;i++)this.freqs[i]>e&&(e=this.freqs[i],t=i);return e>this.peakThreshold?this.indexToFreq(t):null},e.prototype.loop=function(){this.analyser.getFloatFrequencyData(this.freqs),(this.iteration+1)%300==0&&this.restartServerIfSanityCheckFails();var e=this.getPeakFrequency();e?(e=this.coder.freqToChar(e),this.debug&&console.log("Transcribed char: "+e),this.peakHistory.add(e),this.peakTimes.add(new Date)):(e=this.peakTimes.last())&&new Date-e>this.timeout&&(this.state=s,this.debug&&console.log("Token",this.buffer,"timed out"),this.peakTimes.clear()),this.analysePeaks(),this.debug&&this.debugDraw_(),this.isRunning&&this.raf_(this.loop.bind(this)),this.iteration+=1},e.prototype.indexToFreq=function(e){return this.audioContext.sampleRate/2/this.freqs.length*e},e.prototype.freqToIndex=function(e){var t=this.audioContext.sampleRate/2;return Math.round(e/t*this.freqs.length)},e.prototype.analysePeaks=function(){var e=this.getLastRun();e&&(this.state==s?e==this.coder.startChar&&(this.buffer="",this.state=n):this.state==n&&(e!=this.lastChar&&e!=this.coder.startChar&&e!=this.coder.endChar&&(this.buffer+=e,this.lastChar=e,this.fire_(this.callbacks.character,e)),e==this.coder.endChar)&&(this.state=s,this.fire_(this.callbacks.message,this.buffer),this.buffer=""))},e.prototype.getLastRun=function(){for(var e=this.peakHistory.last(),t=0,i=this.peakHistory.length()-2;0<=i&&this.peakHistory.get(i)==e;i--)t+=1;return t>this.minRunLength?(this.peakHistory.remove(i+1,t+1),e):null},e.prototype.debugDraw_=function(){var e=document.querySelector("canvas");e||(e=document.createElement("canvas"),document.body.appendChild(e)),e.width=document.body.offsetWidth,e.height=480,drawContext=e.getContext("2d");for(var t=0;t<this.freqs.length;t++){var i=this.freqs[t]+400,i=e.height-i-1,s=e.width/this.freqs.length;drawContext.fillStyle="black",drawContext.fillRect(t*s,i,1,1)}},e.prototype.raf_=function(e){"undefined"==typeof window||window.chrome&&chrome.extension?setTimeout(e,1e3/60):requestAnimationFrame(e)},e.prototype.restartServerIfSanityCheckFails=function(){if(this.freqs[0]<-300)console.error("freqs[0] < -300. Restarting."),this.restart();else{for(var e=!0,t=0;t<10;t++)-100==this.freqs[t]&&(e=!1);e||(console.error("freqs[0:10] == -100. Restarting."),this.restart())}},e.prototype.restart=function(){},e}),define("CatLab/Webremote/SonicSync/Library/sonic-socket",["./sonic-coder"],function(t){var i=!1;function e(e){this.coder=(e=e||{}).coder||new t,this.charDuration=e.charDuration||.5,this.coder=e.coder||new t(e),this.rampDuration=e.rampDuration||.001,this.audioContext=new i}return"undefined"!=typeof window&&(i=window.AudioContext||window.webkitAudioContext||!1),e.prototype.send=function(e,t){e=this.coder.startChar+e+this.coder.endChar;for(var i,s=0;s<e.length;s++){var n=e[s],n=this.coder.charToFreq(n),o=this.audioContext.currentTime+this.charDuration*s;this.scheduleToneAt(n,o,this.charDuration)}t&&(i=this.charDuration*e.length,setTimeout(t,1e3*i))},e.prototype.scheduleToneAt=function(e,t,i){var s=this.audioContext.createGain(),i=(s.gain.value=0,s.gain.setValueAtTime(0,t),s.gain.linearRampToValueAtTime(1,t+this.rampDuration),s.gain.setValueAtTime(1,t+i-this.rampDuration),s.gain.linearRampToValueAtTime(0,t+i),s.connect(this.audioContext.destination),this.audioContext.createOscillator());i.frequency.value=e,i.connect(s),i.start(t)},e}),define("CatLab/Webremote/SonicSync/Client",["CatLab/Webremote/Config","CatLab/Webremote/SonicSync/Library/ring-buffer","CatLab/Webremote/SonicSync/Library/sonic-coder","CatLab/Webremote/SonicSync/Library/sonic-server","CatLab/Webremote/SonicSync/Library/sonic-socket","CatLab/Webremote/Tools/Deferred"],function(t,e,i,s,n,o){function r(e){this.options=t.getAudioSyncConfig(),this.alphabet=this.options.alphabet.split(""),this.controller=e}var a=r.prototype;return a.startListener=function(){this.stop();var e=new s(this.options);e.start(),e.on("message",this.onIncomingMessage.bind(this)),this.sonicServer=e},a.startSender=function(){this.sonicSocket=new n(this.options)},a.stop=function(){this.sonicServer&&this.sonicServer.stop()},a.sync=function(){var e=new o,t=this.generateRandomSequence(this.options.length);return this.sonicSocket.send(t+this.getParityLetter(t),function(){this.controller.trigger("sync:audio",{secret:t})}.bind(this)),e.promise()},a.generateRandomSequence=function(e){for(var t,i="",s="",n=0;n<e;n++){for(;t=Math.floor(Math.random()*this.alphabet.length),(s=this.alphabet[t])===i.substr(i.length-1,1););i+=s}return i},a.getParityLetter=function(e){for(var t=0,i=e.split(""),s=0;s<i.length;s++)t+=this.alphabet.indexOf(i[s]);e=t%this.alphabet.length;return i[i.length-1]===this.alphabet[e]&&(e=(e+1)%this.alphabet.length),this.alphabet[e]},a.onIncomingMessage=function(e){var t=e.substr(0,e.length-1),i=this.getParityLetter(t);i===e[e.length-1]?this.onMessage(t):console.log("Parity check failed, expected "+i+", ignoring message")},a.onMessage=function(e){this.controller.emit("sync:audio",{secret:e})},a.generateAlphabet=function(e){for(var t="",i=0;i<Math.min(e.length,9);i++)t+=i.toString();return t},r}),define("CatLab/Webremote/Controllers/Webcontrol",["CatLab/Webremote/Config","CatLab/Webremote/Collections/Users","CatLab/Webremote/Collections/Groups","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Models/Users/ControlUser","CatLab/Webremote/Models/ControlGroup","CatLab/Webremote/Models/State","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/Portal","CatLab/Webremote/Controllers/Authentication","CatLab/Webremote/Tools/Colorwheel","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Preloader","CatLab/Webremote/Tools/Smileys","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/MessageCounter","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/ViewFactory/ViewFactory","CatLab/Webremote/Views/ConnectionTrouble","CatLab/Webremote/Providers/SocketIO","CatLab/Webremote/Gamepads/GamepadAPI","CatLab/Webremote/SonicSync/Client","CatLab/Webremote/Messages/MessageBus"],function(a,e,t,i,s,n,h,o,r,l,c,u,d,f,g,p,m,b,v,A,y,w,C,k,I,T,L){function _(){this.initializeEventable(),this.provider=null,this._gamedata=null,this._userlibrary=null,this._grouplibrary=null,this._cssloads=[],this._labeldata={},this._initialized=!1,this._oauthsettings=!1,this._oauthClient=null,this._authentication=!1,this._lastView=null,this._options={},this._groupCallbacks={id:1},this._viewFactory=null,this.state=null,this.connected=!1,this._userlibrary=new e,this._grouplibrary=new t,this._messageBus=new L}p=_.prototype=new p;return Object.assign(p,{AUTH_REQUIRED_ALL:"ALL",AUTH_REQUIRED_ONE:"ONE",AUTH_REQUIRED_ONE_INACTIVE:"ONE-INACTIVE",AUTH_NOT_REQUIRED:"NONE",initialize:function(e){function t(){n.resolve(),s()}var i,s=function(){},n=(void 0!==(e=void 0===(e="function"==typeof e?{callback:e}:e)?{}:e).callback&&(s=e.callback),new u);return this._initialized?t():(this.sonicSyncClient=null,delete e.callback,e.headless,(i=!!e.headless)||void 0===e.assets||this.setAssets(e.assets),a.set(e),a.initialize(function(){null===this.provider&&(void 0===e.provider&&(e.provider=new k),this.provider=e.provider),this.smileys=new g(this.provider),void 0!==e.translator&&d.setTranslator(e.translator),this._initialize(i,t)}.bind(this))),n.promise()},disconnect:function(){this._initialized=!1,this.provider.disconnect()},_initialize:function(n,e){var o,r=new u;return(e&&r.then(e),this._initialized)?r.resolve(this.connected):(setTimeout(function(){r.resolve(!1)},3e4),this.state=new h(this),this._initialized=!0,(o=this).provider.initMaster(this),this.getProviderSettings().then(function(e){this.provider.connect("control",e).then(function(){this.connected=!0,this.provider.on("disconnect",function(){var e=this.getConnectionIssuesView();e.show(),e.text(d.t("Connection lost... reconnecting"))}.bind(this)),this.provider.on("reconnect",function(){this.recover(function(){this.getConnectionIssuesView().hide()}.bind(this))}.bind(this)),this.provider.on("master:initialize",function(e){this.log("Initializing"),this._gamedata=e,this.log("Game initialize; URL "+this.getConnectURL()+", token "+this.getConnectToken()),r.resolve(this.connected)}.bind(this)),this.provider.on("master:error",function(e){alert(e.message)}.bind(this)),this.provider.on("user:join",function(e){this._playerJoin(e)}.bind(this)),this.provider.on("user:reconnect",function(e){this._playerReconnect(e)}.bind(this)),this.provider.on("user:leave",function(e){this._playerLeave(e)}.bind(this)),this.provider.on("view:labels",function(e){this._setViewLabels(e)}.bind(this)),this.provider.on("group:create",function(e){this._onNewGroup(e)}.bind(this)),this.provider.on("user:smiley",function(e){this._playerTrigger("user:smiley",e),this._userlibrary.each(function(e){this.smileys.refreshTakenSmileys(e)}.bind(this))}.bind(this)),this.provider.on("smileys:slingshot",function(e){var t=this._userlibrary.getFromId(e.user);t?(t.trigger("smileys:slingshot",e),e.user=t,this.trigger("smileys:slingshot",e)):console.log("User not found: "+e.user)}.bind(this));for(var e=(e=(e=["user:login","user:logout","button:down","button:up","sync:audio"]).concat(A.eventsToListenFor)).concat(y.eventsToListenFor),t=0;t<e.length;t++)(t=>{o.provider.on(t,function(e){o._playerTrigger(t,e)})})(e[t]);var i=["value:change"];for(var s=0;s<i.length;s++)(t=>{o.provider.on(t,function(e){o._viewTrigger(t,e)})})(i[s]);this._oauthsettings&&this.provider.setOAuthSettings(this._oauthsettings),this.provider.setup(a.getProviderConfig()),this.preloader=new f(this.provider),!n&&a.useAudioSync()&&(this.sonicSyncClient=new T(this),this.sonicSyncClient.startSender())}.bind(this))}.bind(this))),r.promise()},setLogger:function(e){var t;"string"==typeof e?(t=document.getElementById(e),this.log=this.getDomLogger(t)):this.log=e},getProviderSettings:function(){return this.provider.getProviderSettings()},setMessageCounter:function(e){e=new m(e);return this.provider.setMessageCounter(e),e},setName:function(e){this.provider.toMaster("master:name",{name:e})},setMaxUsers:function(e){this.provider.toMaster("config:set",{maxUsers:e})},setViewFactory:function(e){return this._viewFactory=e,this._viewFactory.initialize()},getViewFactory:function(){return"undefined"===this._viewFactory&&(this._viewFactory=new w),this._viewFactory},getDomLogger:function(t){return function(e){t.innerHTML=e+"\n"+t.innerHTML}},oAuth:function(e,t){void 0===t&&(t=!1),this._authentication=!0,this._oauthsettings=e,this.provider&&!t&&this.provider.setOAuthSettings(this._oauthsettings),o.initialize(e),i.initialize(this,o)},getOAuthClient:function(e){this._oauthsettings?(null===this._oauthClient&&(this._oauthClient=o,this._oauthClient.initialize(this._oauthsettings)),e(this._oauthClient)):e(null)},getOAuthSettings:function(){return this._oauthsettings},clearEvents:function(e){if(e=void 0===e?!1:e)for(var t=this._userlibrary.getAll(),i=0;i<t.length;i++)t[i].clearEvents()},getConnectURL:function(){return this.provider.getConnectURL(this._gamedata?this._gamedata.connectURL:null)},getConnectToken:function(){return this.provider.getConnectToken(this._gamedata?this._gamedata.token:null)},getConnectTokenForDisplay:function(){return b.getConnectTokenForDisplay(this.getConnectToken())},loadViews:function(e,t,i){return this.provider.loadViews(e,i,t)},parseViews:function(e,t){return this.provider.parseViews(e,t)},getUsers:function(){return this._userlibrary.getAll()},portal:function(e){var t=this.portalController(e),e=this.portalView(t.messageBus,e);return{controller:t.controller,view:e,promise:t.promise}},portalController:function(e){var t;if(this._initialized)return t=new u,e=new r(this,e),t.resolve(e),{controller:e,messageBus:this.getMessageBus(),promise:t};throw new Error("Please initialize Webcontrol first.")},portalView:function(e,t){var i;if(this._initialized)return i=this.getViewFactory(),e=Object.assign({},t,{messageBus:e,Webcontrol:this}),void 0!==t.element&&(e.element=t.element),(t=i.portal(e)).loading(),(e=i.getContainer()).easelboneLayer.setView(t),t.render(),e;throw new Error("Please initialize Webcontrol first.")},authentication:function(e,t){var i;if(this._initialized)return i=this.authenticationController(e,t),t=this.authenticationView(i.controller.messageBus,t),i.controller.setNavigatableUsers([e]),{controller:i.controller,view:t,promise:i.promise};throw new Error("Please initialize Webcontrol first.")},authenticationController:function(e,t){var i=new u,e=new l(this,e,t);return i.resolve(e),{controller:e,promise:i.promise()}},authenticationView:function(e,t){var i=this.getViewFactory(),t=i.authentication(Object.assign({},t,{messageBus:e})),e=i.getContainer();return e.easelboneLayer.setView(t),t.render(),e},alertView:function(e,t){var i=this.getViewFactory(),t=i.alert(Object.assign({},t,{message:e})),e=i.getContainer();return e.easelboneLayer.setView(t),t.render(),e},getConnectionIssuesView:function(){return void 0===this.connectionTrouble&&(this.connectionTrouble=new C),this.connectionTrouble},setView:function(e,t){var i;return void 0===t?(i=v.create(e,[this],this),this._lastView=i):i=v.create(e,t,this),i},beacon:function(e,t){this.provider.toMaster("master:beacon",{beacon:e,token:t})},emit:function(e,t){this.provider.emit(e,t)},getControlLabels:function(e,t){for(var i=[],s={},n=this.getUsers(),o=0;o<n.length;o++){var r=n[o].control(e).getLabel(t);void 0===s[r]&&i.push(s[r]=r)}return i},addCustomControl:function(e){this.log("adding "+e.getType()),e.setWebcontrol(this),this._userlibrary.add(e),this._initializeSmiley(e,{}),this.trigger("user:join",e)},enableGamepads:function(){I.initialize(this)},newGroup:function(e){var t=new u,i={},s=(void 0===e?e={}:"function"==typeof e&&(e={callback:e}),void 0===e.callback&&(e.callback=function(){}),!0),n=(void 0!==e.globalViews&&(s=e.globalViews),!0),o=(void 0!==e.shareColor&&(n=e.shareColor),[]),r=(void 0!==e.tags&&(o=e.tags),!0),r=(void 0!==e.smiley&&(r=!!e.smiley),i.smiley=r,this._groupCallbacks.id);return this._groupCallbacks.id++,this._groupCallbacks[r]={id:r,callback:e.callback,deferred:t,options:i},this.provider.createGroup(r,s,n,o),t.promise()},preload:function(e){return this.preloader.preload(e)},getPreloadedUrl:function(e){return this.preloader.getPreloadedUrl(e)},_reset:function(){this._userlibrary.clear(),this._grouplibrary.clear()},reset:function(){var e=new u;return this.provider.reset(function(){e.resolve()}.bind(this)),e.promise()},_playerJoin:function(e){var t;this._userlibrary.getFromId(e.id)||((t=new s(e.id,e)).setWebcontrol(this),void 0!==e.color&&t.setColor(e.color.color,e.color.name),this._grouplibrary.addUser(t)||(this._lastView&&this._lastView.addTarget(t),this._initializeSmiley(t,e)),this._userlibrary.add(t),this.log(t),t&&this.trigger("user:join",t),this.preloader.sendPreloadFileCommandToPlayer(t))},_playerReconnect:function(e){var t=this._userlibrary.getFromId(e.id);t?(t.getSmiley()&&t.emit("user:smiley",{smiley:t.getSmiley()}),this._refreshPlayerViews(t),this.trigger("user:rejoin",t),t.eventableTrigger("rejoined"),this.smileys.refreshTakenSmileys(t),this.preloader.sendPreloadFileCommandToPlayer(t)):this._playerJoin(e)},_refreshPlayerViews:function(e){this._grouplibrary.addUser(e)||this._lastView&&this._lastView.addTarget(e),e.refreshView()},_playerLeave:function(e){e=this._userlibrary.getFromId(e.id);e&&(this.trigger("user:leave",e),e.eventableTrigger("left"))},_onNewGroup:function(e){var t,i=new n(e.id,e),s=(i.setWebcontrol(this),!1);void 0!==e.shareColor&&(s=e.shareColor),void 0!==e.color?i.setColor(e.color.color,e.color.name):i.setShareColor(s),this._grouplibrary.getFromId(e.id)||(s=function(){},void 0!==(t=e.externalId)&&void 0!==this._groupCallbacks[t]&&(i.setOptions(this._groupCallbacks[t].options),s=function(){this._groupCallbacks[t].callback(i),this._groupCallbacks[t].deferred.resolve(i)}.bind(this)),this._grouplibrary.add(i),i.getOption("smiley")&&this._initializeSmiley(i,e),this.trigger("group:create",i),this.log("New group "+i.getId()+"; URL "+i.getConnectURL()+", token "+i.getConnectToken()),s())},_initializeSmiley:function(e,t){var i;a.useSmileys()?void 0===t.smiley?null!==(i=this.smileys.getRandom(e.getIdentifier()))&&e.setSmiley(i):e.setSmiley(t.smiley):e.clearSmiley(),this.smileys.refreshTakenSmileys(e)},_playerTrigger:function(e,t){var i=this._userlibrary.getFromId(t.user);i?i.trigger(e,t):console.log("User not found: "+t.user)},_viewTrigger:function(e,t){var i=v.getFromId(t.viewId);i&&i.trigger(e,t)},_loadCSS:function(e){for(var t=0;t<this._cssloads.length;t++)if(this._cssloads[t]==e)return;this._cssloads.push(e);var i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",e),document.body.appendChild(i)},_setViewLabels:function(e){this._labeldata[e.id]=e.labels;for(var t=this.getUsers(),i=0;i<t.length;i++)for(var s=0;s<e.labels.length;s++)t[i].control(e.id).setStaticLabel(e.labels[s].label,"mobile")},getViewLabels:function(e){return void 0!==this._labeldata[e]?this._labeldata[e]:[]},getFromIdentifier:function(e){switch(e.type){case"user":return this._userlibrary.getFromId(e.id);case"group":return this._grouplibrary.getFromId(e.id)}return null},log:function(e){a.debug()&&(console.log(a),console.log(e))},canAuthenticate:function(){return this._authentication},pause:function(){this._initialized&&this.provider.emit("master:pause",{})},unpause:function(){this._initialized&&this.provider.emit("master:unpause",{})},audioSync:function(){if(this.sonicSyncClient)return this.sonicSyncClient.sync()},getMessageBus:function(){return this._messageBus},recover:function(e){var t=this.state.getData();this._reconnect(t.token,t.accessToken,e).then(function(){this._userlibrary.each(function(e){this._refreshPlayerViews(e)}.bind(this))}.bind(this))},_reconnect:function(e,t,i){return this.provider.reconnect(e,t,a.getProviderConfig(),i)},getIceCredentials:function(){var t=new u;return this.provider.toMaster("webrct:stun+turn",{},function(e){void 0===e.error?t.resolve(e):t.fail(e.error)}),t.promise()}}),_}),define("CatLab/Webremote/Models/Users/KeyboardUser",["CatLab/Webremote/Models/Users/ControlUser"],function(e){function t(e,t){var i="keyboard"+ ++s;this.initializeKeyboardUser({id:i,keys:e}),this.exitOnUnassignedBackButton=t}var s=0,e=((t.prototype=Object.create(e.prototype)).constructor=t).prototype;return e.initializeKeyboardUser=function(e){this.initialize({id:e.id}),void 0===e.keys&&(e.keys=this.getDefaultKeys()),this.keys=e.keys,this.attachKeyboardEvents(),"undefined"!=typeof document&&document.addEventListener("fullscreenchange",this.attachKeyboardEvents.bind(this)),this.setStaticLabels=function(){for(var e=0;e<this.keys.length;e++)this.control(this.keys[e].id).setStaticLabel(this.keys[e].label,"keyboard",this.keys[e].image,this.keys[e].emoji)},this.on("view:set",function(e){this.clearControls()}.bind(this)),this.getType=function(){return"keyboard"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(e,t){return!1},this.isLocalAuthentication=function(){return!1},this.clearControls()},e.getAvailableControls=function(){for(var e=[],t=0;t<this.keys.length;t++)e.push(this.keys[t].id);return e},e.getDefaultKeys=function(){return[{id:"up",label:"↑",code:"ArrowUp",emoji:"⬆️"},{id:"down",label:"↓",code:"ArrowDown",emoji:"⬇️"},{id:"right",label:"→",code:"ArrowRight",emoji:"➡️"},{id:"left",label:"←",code:"ArrowLeft",emoji:"⬅️"},{id:"a",label:"A",code:["KeyA","Enter","NumpadEnter"],emoji:"🅰"},{id:"b",label:"B",code:"KeyB",emoji:"🅱"},{id:"x",label:"X",code:"KeyX",emoji:"🆇"},{id:"y",label:"Y",code:"KeyY",emoji:"🆈"},{id:"back",label:"Escape",code:"Escape",emoji:"🇪"},{id:"start",label:"S",code:["KeyS"],emoji:"🆂"}]},e.hasControl=function(e){return-1!==this.getAvailableControls().indexOf(e)},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!0},e.hasTouchInput=function(){return!0},e.stopListening=function(){try{if("undefined"==typeof window)self.removeEventListener("message",this.messageListener,!1);else{var e=null;try{e=window.document}catch(e){}e&&(this._keydownListener&&window.document.removeEventListener("keydown",this._keydownListener),this._keyupListener)&&window.document.removeEventListener("keyup",this._keyupListener),this.messageListener&&window.removeEventListener("message",this.messageListener,!1);var t=null;try{t=window.parent.document}catch(e){}t&&(t.removeEventListener("keyup",this._keydownListener),t.removeEventListener("keydown",this._keydownListener))}}catch(e){console.log(e)}},e.resumeListening=function(){this.attachKeyboardEvents()},e.attachKeyboardEvents=function(){if(this.stopListening(),"undefined"==typeof window)this.messageListener=this._onMessage.bind(this),self.addEventListener("message",this.messageListener,!1);else try{var e=window.document;if(!document.fullscreenElement&&window.parent&&!(e=window.parent.document))throw new Error("Unaccessible");this._keydownListener=this._keyDown.bind(this),this._keyupListener=this._keyUp.bind(this),e.addEventListener("keydown",this._keydownListener),e.addEventListener("keyup",this._keyupListener)}catch(e){try{this.messageListener=this._onMessage.bind(this),window.addEventListener("message",this.messageListener,!1)}catch(e){console.error(e)}}},e.getConfigFromKey=function(e){for(var t=0;t<this.keys.length;t++){if(void 0!==this.keys[t].code&&this._keyMatches(this.keys[t].code,e.code))return this.keys[t];if(void 0!==this.keys[t].key&&this._keyMatches(this.keys[t].key,e.key))return this.keys[t];if(void 0!==this.keys[t].keyCode&&this._keyMatches(this.keys[t].keyCode,e.keyCode))return this.keys[t]}return null},e._keyMatches=function(e,t){return!!(Array.isArray(e)&&-1<e.indexOf(t))||e==t},e._onMessage=function(e){var t=e.data;if("object"==typeof t&&void 0!==t.type&&"catlab:keyboard"===t.type&&void 0!==t.code&&void 0!==t.action)switch(t.action){case"down":return void this._keyDown(e.data);case"up":return void this._keyUp(e.data)}},e._keyDown=function(e){var t;"Escape"!==e.key||!this.exitOnUnassignedBackButton||this.control("back").hasTriggers("click")||this.control("back").hasTriggers("up")||this.control("back").hasTriggers("down")?(t=this.getConfigFromKey(e))&&(this.control(t.id).update(1),void 0!==t.preventDefault)&&t.preventDefault&&e.preventDefault():this.requestExitApp()},e._keyUp=function(e){var t=this.getConfigFromKey(e);t&&(this.control(t.id).update(0),void 0!==t.preventDefault)&&t.preventDefault&&e.preventDefault()},e.requestExitApp=function(){var e;window.onbeforeunload?(e=window.onbeforeunload({}))&&this.confirm(e,function(e){e&&this.exitApp()}.bind(this)):this.exitApp()},e.exitApp=function(){window.close()},e.confirm=function(e,t){t(window.confirm(e))},t}),define("CatLab/Webremote/Models/Users/CordovaUser",["CatLab/Webremote/Models/Users/KeyboardUser"],function(e){function t(e,t,i){void 0===i&&(i=!0),void 0===t&&(t="back"),this.initializeKeyboardUser({id:"cordova",keys:e}),this.initializeBackButtonExit(t,i)}e=((t.prototype=Object.create(e.prototype)).constructor=t).prototype;return e.initializeBackButtonExit=function(i,s){void 0===s&&(s=!0);var n=new Date;document.addEventListener("backbutton",function(e){var t=new Date;t.getTime()-n.getTime()<300?this.requestExitApp():(n=t,e.preventDefault(),!s||this.control("back").hasTriggers("click")||this.control("back").hasTriggers("up")||this.control("back").hasTriggers("down")?i&&(this.control(i).update(1),setTimeout(function(){this.control(i).update(0)}.bind(this),1)):setTimeout(function(){void 0!==window.plugins.appMinimize?window.plugins.appMinimize.minimize():this.exitApp()},350))}.bind(this),!1)},e.exitApp=function(){navigator.app.exitApp()},e.confirm=function(e,t){navigator.notification.confirm(e,function(e){t(1===e)})},e.getDefaultKeys=function(){return[{id:"up",label:"↑",key:38},{id:"down",label:"↓",key:40},{id:"right",label:"→",key:39},{id:"left",label:"←",key:37},{id:"start",label:"ENTER",key:13},{id:"back",label:"BACK",key:null}]},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!0},e.hasTouchInput=function(){return!0},t}),define("CatLab/Webremote/Models/Users/AndroidRemoteUser",["CatLab/Webremote/Models/Users/CordovaUser"],function(e){function t(e,t,i){this.initializeKeyboardUser({id:"cordova",keys:e}),this.initializeBackButtonExit(t,i)}e=((t.prototype=Object.create(e.prototype)).constructor=t).prototype;return e.getDefaultKeys=function(){return[{id:"up",label:"↑",keyCode:38,preventDefault:!0,image:"control-icons/android-tv/$SIZE/android-tv-up.gif",emoji:"⬆️"},{id:"down",label:"↓",keyCode:40,preventDefault:!0,image:"control-icons/android-tv/$SIZE/android-tv-down.gif",emoji:"⬇️"},{id:"right",label:"→",keyCode:39,preventDefault:!0,image:"control-icons/android-tv/$SIZE/android-tv-right.gif",emoji:"➡️"},{id:"left",label:"←",keyCode:37,preventDefault:!0,image:"control-icons/android-tv/$SIZE/android-tv-left.gif",emoji:"⬅️"},{id:"a",label:"ENTER",keyCode:13,preventDefault:!0,emoji:"🅰"},{id:"back",label:"BACK",keyCode:null},{id:"start",label:"⏯",keyCode:179},{id:"fastforward",label:"⏩",keyCode:228},{id:"fastforward",label:"⏪",keyCode:227}]},e.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"down",left:"left",right:"right"}},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!1},e.hasTouchInput=function(){return!1},this.getType=function(){return"android-keyboard"},t}),define("CatLab/Webremote/Models/Users/DummyUser",["CatLab/Webremote/Models/Users/ControlUser"],function(e){function t(e){this.initialize({id:e}),this.clearControls=function(){},this.getType=function(){return"dummy"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(e,t){return!1},this.isLocalAuthentication=function(){return!1},this.log=function(e){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+e)},this.hasDisplay=function(){return!1},this.hasKeyboardInput=function(){return!0},this.hasTouchInput=function(){return!0},this.clearControls()}return(t.prototype=Object.create(e.prototype)).constructor=t}),define("CatLab/Webremote/Tools/ParseXML",[],function(){function e(){}var t=null;"undefined"!=typeof window&&(void 0!==window.DOMParser?t=function(e){return(new window.DOMParser).parseFromString(e,"text/xml")}:void 0!==window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")&&(t=function(e){var t=new window.ActiveXObject("Microsoft.XMLDOM");return t.async="false",t.loadXML(e),t}));return e.prototype.parse=function(e){if(t)return t(e);throw new Error("No XML parser found")},new e}),define("CatLab/Webremote/Providers/Airconsole",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Proxy","CatLab/Webremote/Tools/ParseXML","CatLab/Webremote/Synchronization/MessageQueue","CatLab/Webremote/Models/User"],function(e,t,i,s,n,o,r){function a(e){e&&(this.airconsole=e),this.showTokenForm=!1,this.oauth={},this.views=[],this.knownUsers={},this.started=!1,this.userId=null,this.sendBurstDelay=50,this.connectCode=null}e=a.prototype=new e;return e.connect=function(e){return this.log("Airconsole connecting"),this.setInitialized(),this.path=e,this._trigger("connect",null),this.readyState.promise()},e.noTokenConnect=function(){return this.connect("remote")},e.setUserId=function(e){return this.userId=e,this},e.initMaster=function(e){this.master=e,this.airconsole||(this.airconsole=new AirConsole),this.airconsole.onMessage=this.onMessage.bind(this),this.airconsole.onConnect=function(e){this.emitAirConsole(e,"airconsole:well-hello-there",{user:e})}.bind(this),this.readyState=new i,this.airconsole.onReady=function(e){this.connectCode=e,this.readyState.resolve()}.bind(this),this.airconsole.onDeviceProfileChange=function(e){this.updateDeviceProfile(e)}.bind(this),this.on("player:join",function(e){this.onPlayerConnect(e.user)}.bind(this)),this.once("connect",function(){setTimeout(function(){this.started=!0}.bind(this),1)}.bind(this))},e.initPlayer=function(e){this.master=e,this.airconsole=new AirConsole,this.airconsole.onMessage=this.onMessage.bind(this),this.readyState=new i,this.readyState.resolve(),this.once("airconsole:well-hello-there",function(e){this.emitAirConsole(0,"player:join",{})}.bind(this))},e.onMessage=function(t,e){var i;void 0!==(e="string"==typeof e?JSON.parse(e):e).b&&Array.isArray(e.b)?(i=0,e.b.forEach(function(e){setTimeout(function(){this.processMessage(t,e)}.bind(this),i++)}.bind(this))):this.processMessage(t,e)},e.processMessage=function(e,t){var i;t&&t[0]&&(i=t[0],t=t[1],this.isMaster()&&(0<e&&"player:join"!==i&&void 0===this.knownUsers[e]&&this.onPlayerConnect(e),0<e)&&(t.user=e),o.unpack(t,"user").forEach(function(e){this.isRemote()&&void 0!==e.user&&e.user!==this.airconsole.getDeviceId()||this._trigger(i,e)}.bind(this)))},e.onPlayerConnect=function(e){this.log("Welcoming our newest player "+e),this.knownUsers[e]=!0;for(var t=0;t<this.views.length;t++)this.emitAirConsole(e,"view:load",{xml:this.views[t]}),this.emitAirConsole(e,"view:set",{id:"loading"});this._trigger("user:join",{id:e}),this.updateDeviceProfile(e)},e.updateDeviceProfile=function(e){var t,i,s=this.master._userlibrary.getFromId(e);s&&(t={username:this.airconsole.getNickname(e)},(i=this.airconsole.getProfilePicture(e))&&(t.avatar=i),this.airconsole.getMasterControllerDeviceId()===e&&s.setMaster(!0),s.setProfiledata(t))},e.emitAll=function(){this.isMaster()&&this.emitMaster(),this.isRemote()&&this.emitClient()},e.isMaster=function(){return"control"===this.path},e.isRemote=function(){return"remote"===this.path},e.emitClient=function(){this.queue.flush().forEach(function(e){this.emitAirConsole(0,e.action,e.data)}.bind(this))},e.emitMaster=function(){var t,i,e=this.queue.compactFlush();e.length&&(t=5<e.length,i=[],e.forEach(function(e){t||void 0===e.data.user||Array.isArray(e.data.user)&&1<e.data.user.length?i.push(e):this.emitAirConsole(e.user,e.action,e.data)}.bind(this)),0<i.length)&&this.broadcastAirconsole(i)},e.emitAirConsole=function(e,t,i){t=[t,i],delete t[1].action,i=JSON.stringify(t);this.airconsole.message(e,i)},e.broadcastAirconsole=function(e){var t=[],e=(e.forEach(function(e){t.push([e.action,e.data])}),JSON.stringify({b:t}));this.airconsole.broadcast(e)},e.setOAuthSettings=function(e){this.oauth=e,this.emit("oauth:set",e)},e.log=function(){this.master.log.apply(arguments)},e.setup=function(e){this._trigger("master:initialize",{})},e.toMaster=function(e,t){t.user=0,this.emit(e,t)},e.log=function(e){var t=[],i=(Array.prototype.push.apply(t,arguments),"["+this.path+"]");"remote"===this.path&&(i="["+this.path+":"+this.airconsole.getDeviceId()+"]"),t.unshift(i),console.log.apply(console,t)},e.getConnectInstructions=function(){return["Open the Airconsole app on your smartphone and connect with code %s.",this.connectCode]},e.getStartAndLoginInstructions=function(){return["Use the onscreen button to start the game."]},a}),define("CatLab/Webremote/CreateJS/LayerContainer",["easeljs","easelbone"],function(s,n){function e(e,t){if(!n)throw console.log("When using the createjs module of the remote, you need to have the easelbone module loaded."),console.log("Check https://github.com/catlabinteractive/easelbone"),new Error("easelbone could not be loaded.");this.width=e,this.height=t,this.initialize(),this.easelboneLayer=new n.Views.Layer({container:this});var i=this;this.easelboneLayer.on("all",function(e){e=new s.Event(e);i.dispatchEvent(e)})}var t=e.prototype=new s.Container;return t.Container_initialize=t.initialize,t.initialize=function(){this.Container_initialize(),this.setBounds(0,0,this.width,this.height),this.on("click",function(e){e.stopPropagation()})},t.loading=function(){},t.render=function(){this.easelboneLayer.render()},e}),define("CatLab/Webremote/CreateJS/Views/BaseView",["easelbone","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Images"],function(o,r,e){var a=new e;return o.Views.Navigatable.extend({intitializeBaseView:function(e){this.initializeNavigatable(e),this.labels={},this.replacedEmojis={},this.navigatableOverride=null},getLabelSubstitutionOrNull:function(e,t){return void 0!==this.labels[e]?this.substituteLabelsForInstructionMessage(t,this.labels[e]):null},substituteLabelsForInstructionMessage:function(e){for(var t=[],i=1;i<arguments.length;i++){var s,n=arguments[i];"string"!=typeof n?(s=[],n.forEach(function(e){e.emoji?(s.push(e.emoji),void 0!==e.image&&(this.replacedEmojis[e.emoji]=a.getUrl(e.image,128))):e.label&&s.push(e.label)}.bind(this)),t.push(s.join(" / "))):t.push(n)}return r.t.apply(r,[e].concat(t))},getEmojiSubstitutedMessage:function(e){var e=new o.EaselJS.BigText(e),n=this.replacedEmojis;return e.textConstructor=function(e,t,i,s){e=new o.EaselJS.EmojiText(e,t,i,s);return e.setEmojis(n),e},e},alert:function(e,t){var t=this.Webcontrol.getViewFactory().alert(Object.assign({},t,{message:e})),i=this.Webcontrol.getViewFactory().getContainer();i.easelboneLayer.setView(t),t.render(),this.navigatableOverride=t,this.el.addChild(i),t.on("view:close",function(){i.easelboneLayer.view.trigger("stage:removed"),this.el.removeChild(i),this.navigatableOverride=null}.bind(this))}})}),define("CatLab/Webremote/Tools/ImageLoader",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred"],function(s,n){return{loadedImages:{},loadImage:function(e){var t,i=new n;return this.loadedImages[e]?i.resolve(this.loadedImages[e]):((t=new Image).crossOrigin="anonymous",t.onload=function(){this.loadedImages[e]=t,i.resolve(this.loadedImages[e])}.bind(this),t.src=s.getProxiedImage(e)),i.promise()}}}),define("CatLab/Webremote/Tools/QrGenerator",["easelbone","qrious"],function(o,r){return{generateQrCode:function(e,t){var i=200,s=200;e.getBounds()&&e.getBounds().width&&!e.getBounds().height&&(i=e.getBounds().width,s=e.getBounds().height),e.addChild(this.getGeneratedQrCode(t,Math.max(i,s)))},getGeneratedQrCode(e,t,i,s){void 0===i&&(i="#000000"),void 0===s&&(s="#ffffff");var n=new r,t=(n.level="H",n.size=2*t,n.value=e,n.background=s,n.foreground=i,new Image);return t.src=n.toDataURL(),new o.EaselJS.Fill(t,{zoom:"minimum"})}}}),define("CatLab/Webremote/CreateJS/Views/PortalView",["easeljs","easelbone","CatLab/Webremote/CreateJS/Views/BaseView","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/ImageLoader","CatLab/Webremote/Tools/QrGenerator","CatLab/Webremote/Messages/NavigateableProxy"],function(e,s,t,n,o,i,r){return t.extend({initialize:function(e){this.Webcontrol=e.Webcontrol,this.controllerState={activePlayers:0,minPlayers:0,maxPlayers:0,connectInstructions:[""],startAndLoginInstructions:[""],showInactivePlayers:!1,qrUrl:null},this.intitializeBaseView({orientation:this.ORIENTATION.HORIZONTAL}),this.messageBus=e.messageBus,this.assets=e.assets,this.initialized=!1,this.leanback=void 0!==e.leanback&&e.leanback,this.users=[],this.messageBus.toController("nav:controls",{controls:this._controls}),this.purchaseSeatsCallback=null,e.purchaseSeatsCallback&&(this.purchaseSeatsCallback=e.purchaseSeatsCallback),this.attachMessageBus(this.messageBus),this.on("stage:removed",this.destroy.bind(this))},initializeContent:function(){this.initialized||(this.initialized=!0,this.controllerState.showInactivePlayers?this.setScreen(new this.assets.PortalView):this.setScreen(new this.assets.PortalViewNoInactive),this.showInactivePlayers=this.controllerState.showInactivePlayers||!1,this.showInactivePlayers&&(this.connectedUsersContainer=new s.EaselJS.Placeholder(this.getScreen().connectedUsers),this.connectedUsers=new s.Controls.FloatContainer(function(e){return this.getUserIcon(e)}.bind(this),6),this.connectedUsersContainer.addChild(this.connectedUsers)),this.activeUsersContainer=new s.EaselJS.Placeholder(this.getScreen().activeUsers),this.activeUsers=new s.Controls.FloatContainer(function(e){return this.getUserIcon(e)}.bind(this),this.showInactivePlayers?6:9),this.activeUsersContainer.addChild(this.activeUsers),void 0!==this.getScreen().start&&(this.start=new s.Controls.Button(this.getScreen().start),this.start.setText(n.t("Start")),this.start.on("click",function(){this.messageBus.toController("start")}.bind(this)),this.addControl(this.start)),void 0!==this.getScreen().back&&(this.back=new s.Controls.Button(this.getScreen().back),this.back.setText(n.t("Back")),this.back.on("click",function(){this.messageBus.toController("back")}.bind(this)),this.addControl(this.back)),this.findPlaceholders("instructionHeader").forEach(function(e){e.addChild(new s.EaselJS.BigText(n.t("Instructions")))}),this.findPlaceholders("activePlayersHeader").forEach(function(e){e.addChild(new s.EaselJS.BigText(n.t("Active devices")))}),this.findPlaceholders("connectedPlayersHeader").forEach(function(e){e.addChild(new s.EaselJS.BigText(n.t("Connected devices")))}),this.instructionTexts=[],this.instructionTexts=this.findPlaceholders("instructionText"),this.updateInstructionText(),this.activePlayerTexts=[],this.findPlaceholders("activePlayers").forEach(function(e){var t=new s.EaselJS.BigText(this.getActiveUsersText());this.activePlayerTexts.push(t),e.addChild(t)}.bind(this)),this.qrContainers=this.findPlaceholders("qr"),this.qrInstructionsContainers=this.findPlaceholders("qrInstructions"))},attachMessageBus:function(e){e.addViewListener(this)},handleIncomingMessage:function(e,t){var i=this.navigatableOverride||this;if(!r.handleMessage(e,t,i,"portal:"))switch(e){case"state:change":this.controllerState=t.state,this.initialized||this.initializeContent(),this.showCurrentAndMaxUsers();break;case"alert":if(t.id&&"exceeds-max-players"===t.id)if(this.purchaseSeatsCallback)return void this.alert(n.t(t.localized),{type:"confirm",okLabel:n.t("Purchase seats"),ok:function(e){e.close(),this.purchaseSeatsCallback()}.bind(this),cancelLabel:n.t("Cancel")});this.alert(n.t(t.localized));break;case"users:update":this.users=t.users,this.refreshUsers();break;case"auth:open":this.addAuthenticationView();break;case"portal:destroy":this.destroy()}},getActiveUsersText:function(){return this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers},getInstructionText:function(){return this.substituteLabelsForInstructionMessage.apply(this,this.controllerState.connectInstructions)+"\n"+this.substituteLabelsForInstructionMessage.apply(this,this.controllerState.startAndLoginInstructions)},getUserIcon:function(e){var t,i;return e?e.profile?(t=new this.assets.UserIconAuthenticated,this.addControllerIcon(t,e)):t=this.getControllerIcon(e):t=this.getControllerIcon(),e&&(i=t.PlayerColor)&&new s.EaselJS.Placeholder(i).addChild(new s.EaselJS.Fill(e.color)),e&&this.setUserDetails(t,e),t},addControllerIcon:function(e,t){var i;e.ControllerIcon&&(e=new s.EaselJS.Placeholder(e.ControllerIcon),i=this.getControllerIcon(t),e.addChild(i),i.scaleX=i.scaleY=.5,t)&&(e=i.PlayerColor)&&new s.EaselJS.Placeholder(e).addChild(new s.EaselJS.Fill(t.color))},getControllerIcon:function(e){if(e)switch(e.type){case"keyboard":return new this.assets.UserIconKeyboard;case"tablet":return new this.assets.UserIconTablet;case"phone":return new this.assets.UserIconPhone;case"gamepad":return new this.assets.UserIconGamepad}return new this.assets.UserIcon},loading:function(){},refreshUsers:function(){this.showCurrentAndMaxUsers(),this.showInformation(),this.reloadUserIcons()},showCurrentAndMaxUsers:function(){this.getScreen().playercount&&(this.getScreen().playercount.text=this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers),this.activePlayerTexts.forEach(function(e){e.setText(this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers)}.bind(this)),this.getScreen().login&&(this.getScreen().login.text=n.t(this.controllerState.startAndLoginInstructions))},showInformation:function(){var e=n.t(this.controllerState.connectInstructions);this.getScreen().login?this.getScreen().login.text=n.t(this.controllerState.startAndLoginInstructions):e+="\n "+n.t(this.controllerState.startAndLoginInstructions),this.getScreen().token&&(this.getScreen().token.text=e),this.updateInstructionText(),this.updateQrCode()},updateInstructionText:function(){this.instructionTexts.forEach(function(e){var t=this.getEmojiSubstitutedMessage(this.getInstructionText());e.removeAllChildren(),e.addChild(t)}.bind(this))},updateQrCode:function(){this.qrContainers.forEach(function(e){e.removeAllChildren(),this.controllerState.qrUrl&&i.generateQrCode(e,this.controllerState.qrUrl)}.bind(this)),this.qrInstructionsContainers.forEach(function(e){var t;e.removeAllChildren(),this.controllerState.qrUrl&&(t=this.getEmojiSubstitutedMessage(n.t("Scan QR code to connect")),e.addChild(t))}.bind(this))},removeAllUserIcons:function(){this.showInactivePlayers&&this.connectedUsers.removeAllChildren(),this.activeUsers.removeAllChildren()},reloadUserIcons:function(){var t=24,i=24;this.showInactivePlayers||(i=45),this.removeAllUserIcons(),this.users.forEach(function(e){e.active?i<=0||(i--,this.activeUsers.createElement(e)):!this.showInactivePlayers||t<=0||(t--,this.connectedUsers.createElement(e))}.bind(this))},setUserDetails:function(e,t){var i;t.profile&&e.userimage&&(i=new s.EaselJS.Placeholder(e.userimage),o.loadImage(t.profile.image).then(function(e){i.addChild(new s.EaselJS.Fill(e))}))},addAuthenticationView:function(){var e=this.Webcontrol.authenticationView(this.messageBus,{leanback:this.leanback});this.el.addChild(e),e.on("view:close",function(){e.easelboneLayer.view.trigger("stage:removed"),this.el.removeChild(e),this.messageBus.toController("auth:close")}.bind(this))},render:function(){this.el.addChild(this.getScreen()),this.refreshUsers()},destroy:function(){this.messageBus.removeViewListener(this)}})}),define("CatLab/Webremote/CreateJS/Views/AuthenticationView",["easelbone","CatLab/Webremote/CreateJS/Views/BaseView","CatLab/Webremote/Tools/Images","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/ImageLoader","CatLab/Webremote/Tools/QrGenerator","CatLab/Webremote/Messages/NavigateableProxy","CatLab/Webremote/Controllers/OAuth2"],function(n,e,t,o,r,a,i,s){return e.extend({initialize:function(e){var t;this.intitializeBaseView(),this.assets=e.assets,this.leanback=void 0!==e.leanback&&e.leanback,this.leanback?this.screen=new e.assets.SigninLeanback:this.screen=new e.assets.Signin,this.findFromNames(["close"],[this.screen]).forEach(function(e){e.on("click",function(){this.close()}.bind(this))}.bind(this)),this.screen.linkAccount&&(this.linkAccount=new n.Controls.Button(this.screen.linkAccount),this.linkAccount.on("click",function(){s.link(function(e){this.selectUser(e)}.bind(this))}.bind(this))),this.titlePlaceholder=null,this.explanationPlaceholder=null,n.Helpers.MovieClipHelper.findFromNames(["title"],[this.screen]).forEach(function(e){this.titlePlaceholder=new n.EaselJS.Placeholder(e)}.bind(this)),n.Helpers.MovieClipHelper.findFromNames(["explanation"],[this.screen]).forEach(function(e){this.explanationPlaceholder=new n.EaselJS.Placeholder(e)}.bind(this)),this.titlePlaceholder&&(t=new n.EaselJS.BigText(o.t("Select your profile"),null,null,"left"),this.titlePlaceholder.addChild(t)),this.qrContainers=this.findPlaceholders("qr",this.screen),this.qrInstructionsContainer=this.findPlaceholders("qrInstructions",this.screen),this.setLoginUrlText(),n.Helpers.MovieClipHelper.findFromNames("accounts",[this.screen]).forEach(function(e){e=new n.Controls.ScrollArea(e);this.users=new n.Controls.FloatContainer(function(e){return this.getUserObject(e)}.bind(this),4),e.content.addChild(this.users)}.bind(this)),this.updateUsers([]),this.on("removed",function(){this.trigger("close")}.bind(this)),this.setBack(function(){this.close()}.bind(this)),this.attachMessageBus(e.messageBus),this.on("stage:removed",this.destroy.bind(this))},attachMessageBus:function(e){(this.messageBus=e).addViewListener(this)},handleIncomingMessage:function(e,t){if(!i.handleMessage(e,t,this,"auth:"))switch(e){case"auth:users:update":this.updateUsers(t.users);break;case"auth:close":this.close();break;case"auth:loginurl":this.setLoginUrl(t.url);break;case"auth:destroy":this.destroy();break;case"labels:update":this.labels=t.labels,this.setLoginUrlText();break;case"auth:request-remove-selected-profile":this.removeSelectedUser()}},updateUsers:function(e){this.resetOptions(),this.users.removeAllChildren();for(var t=0;t<e.length;t++)this.users.createElement(e[t]);this.linkAccount&&this.addControl(this.linkAccount)},getUserObject:function(e){var t,i=new this.assets.UserModel,s=(i.namePlaceholder?i.text=i.namePlaceholder:i.name&&(i.text=i.name),new n.Controls.Button(i));return e&&(s.setText(e.name),t=new n.EaselJS.Placeholder(i.picture),r.loadImage(e.image).then(function(e){t.addChild(new n.EaselJS.Fill(e))}),s._userModel=e,s.on("click",function(){this.selectUser(e)}.bind(this)),this.addControl(s)),i},selectUser:function(e){this.messageBus.toController("auth:select-user",{user:{id:e.id}})},close:function(){this.trigger("close"),this.messageBus.toController("auth:close")},render:function(){this.el.addChild(this.screen)},setLoginUrl:function(e){this.loginUrl=e,this.setLoginUrlText()},setLoginUrlText:function(){if(this.linkAccount&&this.linkAccount.setText(o.t("Login to add profile")),this.explanationPlaceholder){var e,t=[],i={selectProfile:"%s to select",removeProfile:"%s to remove",close:"%s to close"};for(e in i){var s=this.getLabelSubstitutionOrNull(e,i[e]);s&&t.push(s)}this.explanationPlaceholder.removeAllChildren(),this.explanationPlaceholder.addChild(this.getEmojiSubstitutedMessage(t.join(", ")+"."))}this.loginUrl&&(this.qrContainers.forEach(function(e){"http"!==this.loginUrl.substring(0,4)&&(this.loginUrl="https://"+this.loginUrl),e.removeAllChildren(),a.generateQrCode(e,this.loginUrl)}.bind(this)),this.qrInstructionsContainer.forEach(function(e){var t=o.t("Scan to login or surf to %s",this.loginUrl);e.addChild(new n.EaselJS.BigText(t))}.bind(this)))},removeSelectedUser:function(){var e=this._current;e&&e._userModel?this.messageBus.toController("auth:remove-user",{user:{id:this._current._userModel.id}}):console.log("No current control")},destroy:function(){this.messageBus.removeViewListener(this)}})}),define("CatLab/Webremote/CreateJS/Views/AlertView",["easelbone","CatLab/Webremote/Tools/Translator","CatLab/Webremote/CreateJS/Views/BaseView"],function(n,o,e){return e.extend({initialize:function(i){"confirm"===(this.intitializeBaseView(),this.easelScreen=new i.assets.Alert,this.findPlaceholders("message").forEach(function(e){var t=new n.EaselJS.BigText(i.message);e.addChild(t)}),void 0===i.type&&(i.type="alert"),i.type.toLowerCase())?this.initializeConfirm(i):this.initializeAlert(i)},initializeAlert:function(e){var t=o.t("OK");void 0!==e.buttonLabel&&(t=e.buttonLabel),this.findFromNames("button").forEach(function(e){e=new n.Controls.Button(e);e.setText(t),this.addControl(e),e.click(function(){this.close()}.bind(this))}.bind(this)),setTimeout(function(){this.jumpToFrame("oneButton")}.bind(this),0)},initializeConfirm:function(t){var i=o.t("OK"),s=(void 0!==t.okLabel&&(i=t.okLabel),o.t("Cancel"));void 0!==t.cancelLabel&&(s=t.cancelLabel),this.findFromNames("button1").forEach(function(e){e=new n.Controls.Button(e);e.setText(i),this.addControl(e),e.click(function(){"function"!=typeof t.ok?this.close():t.ok(this)}.bind(this))}.bind(this)),this.findFromNames("button2").forEach(function(e){e=new n.Controls.Button(e);e.setText(s),this.addControl(e),e.click(function(){"function"!=typeof t.cancel?this.close():t.cancel(this)}.bind(this))}.bind(this)),setTimeout(function(){this.jumpToFrame("twoButtons")}.bind(this),0)},close:function(){this.trigger("view:close")},render:function(){this.el.addChild(this.easelScreen)}})}),s=i=i||{},h=h||{},void 0!==(t=a=a||{}).Container&&(s.properties={width:720,height:480,fps:24,color:"#FFFFFF",manifest:[]},(s.UserIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#592230").s().p("Al2F2IAArsILsAAIAALsg"),this.shape.setTransform(37.5,37.5),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,75,75),e.frameBounds=[A],(s.TextPlaceholderBackground=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FF00FF").s().p("AnzHzIAAvmIPmAAIAAPmg"),this.shape.setTransform(50,50),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,100,100),e.frameBounds=[A],(s.Marker=function(){this.initialize()}).prototype=e=new t.Container,e.nominalBounds=A=null,e.frameBounds=[A],(s.PointerInactive=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#320B1F").s().p("AjQiRIENALICfCGIiTCHIkkALg"),this.shape.setTransform(-22,0),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-44,-14.7,44.1,29.4),e.frameBounds=[A],(s.PointerActive=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#006633").s().p("AjQiRIENALICfCGIiTCHIkkALg"),this.shape.setTransform(-22,.1),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-44,-14.6,44.1,29.4),e.frameBounds=[A],(s.Checkbox=function(e,i,s){this.initialize(e,i,s=null==s?!1:s,{Up:0,Over:1,Down:2,Hit:3}),this.frame_0=function(){this.stop()},this.frame_1=function(){this.stop()},this.frame_2=function(){this.stop()},this.frame_3=function(){this.stop()},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(1).call(this.frame_1).wait(1).call(this.frame_2).wait(1).call(this.frame_3).wait(1)),this.shape=new t.Shape,this.shape.graphics.f("#FF873C").s().p("AizAVQgagpgVgoIgXgsIADgQIADgEQAFgEAJgCQAKAZATAkQANAYASAdQAxBQAOAeQALg8CFhhIAIgGQCGhhA7AVIAGgCQAEACABAPQgmAPg/ApQgpAcgpAiQhQBChRBfQgngxguhPg"),this.shape.setTransform(25,23),this.shape._off=!0,this.timeline.addTween(t.Tween.get(this.shape).wait(2).to({_off:!1},0).wait(2)),this.shape_1=new t.Shape,this.shape_1.graphics.f().s("#8B504F").ss(5).p("ABfheIAAC9Ii9AAIAAi9g"),this.shape_1.setTransform(19.2,19.2,2.023,2.023),this.shape_2=new t.Shape,this.shape_2.graphics.f("#592230").s().p("AheBeIAAi8IC9AAIAAC8g"),this.shape_2.setTransform(19.2,19.2,2.023,2.023),this.shape_3=new t.Shape,this.shape_3.graphics.f("#FFC39F").s().p("AheBeIAAi8IC9AAIAAC8g"),this.shape_3.setTransform(19.2,19.2,2.023,2.023),this.shape_4=new t.Shape,this.shape_4.graphics.f().s("#8B504F").ss(5).p("ADAi/IAAF/Il/AAIAAl/g"),this.shape_4.setTransform(-13.2,12.3,1,1,0,0,0,-32.4,-6.9),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_2},{t:this.shape_1,p:{x:19.2,y:19.2}}]}).to({state:[{t:this.shape_3,p:{x:19.2,y:19.2}},{t:this.shape_1,p:{x:19.2,y:19.2}}]},1).to({state:[{t:this.shape_2},{t:this.shape_1,p:{x:19.2,y:19.2}}]},1).to({state:[{t:this.shape_4},{t:this.shape_3,p:{x:19.4,y:18.9}},{t:this.shape_1,p:{x:19.4,y:18.9}}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-2.5,-2.5,43.5,43.4),e.frameBounds=[A,A,new t.Rectangle(-2.5,-2.5,52.5,43.4),new t.Rectangle(-2.5,-2.8,52.5,43.7)],(s.CogVector=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#282A1F").s().p("Ag/MAQgehhgLhlQgbgEgvgOIgkgNQgUgIgOgIQhLBKhXA3QgsgbgwgqQAkhoAvhQQgdgegUgdQgKgLgLgUIgUghQhpAQhlgGQgVg1gNg5QBOg4BhgtQgCgPgBgXIgCglQABgxAEgZQhggzhMg/QAIgiAchLQBoABBhAVQAZgtAQgTQAUgdAdgeQgshWgdhrQA9gwAhgTQBQA8BGBMQAOgIAUgIIAkgNQAvgNAbgFQAShsAlhbQAwgEBBAFQAeBhALBlQAbAFAvANIAkANQAUAIAOAIQBLhKBXg3QAsAbAwAqQgkBogvBQQAdAeAUAdQAQATAZAtQBpgQBlAGQAWA5AMA1QhOA4hhAtQAEAZABAxIgCAlQgBAXgCAPQBgAzBMA/QgHAigdBLQhogBhhgVQgZAtgQATQgUAdgdAeQAsBWAdBrQg9AwghATQhQg8hGhMQgOAIgUAIIgkANQgvAOgbAEQgSBsglBbQgXACgaAAQgdAAgjgDgAhtlTQg3ASgtAhQgvAiggAtQhDBagCB3QACB4BDBaQAgAtAvAiQAtAhA3ASQA1ASA4AAQA5AAA1gSQA3gSAtghQAvgiAggtQBDhaACh4QgCh3hDhaQgggtgvgiQgtghg3gSQg1gRg5AAQg4AAg1ARg"),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-75,-77.1,150.1,154.3),e.frameBounds=[A],(s.ListUsers=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#00CCFF").s().p("A5DK/IAA19MAyHAAAIAAV9g"),this.shape.setTransform(158.5,71),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-2,.6,320.9,140.7),e.frameBounds=[A],(s.lstUsers=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#0066CC").s().p("A5YGoIAAtQMAywAAAIAANQg"),this.shape.setTransform(162.5,42.5),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,325,85),e.frameBounds=[A],(s.SmartphoneIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AhNCvQgJAAgHgIQgHgGAAgKIAAksQAAgLAHgGQAHgIAJAAICaAAQAKAAAHAIQAHAGAAALIAAEsQAAAKgHAGQgHAIgKAAgAgHCPQgEADAAAFQAAAFAEADQAEAEADAAQAEAAAEgEQADgDAAgFQAAgFgDgDQgEgDgEAAQgDAAgEADgAhUCDICoAAIAAkLIioAAgAgaiaQAAABAAABQAAAAAAABQABAAAAAAQABABABAAIAwAAQAAAAABgBQAAAAAAAAQABgBAAAAQAAgBAAgBQAAAAAAgBQAAAAgBAAQAAgBAAAAQgBAAAAAAIgwAAQgBAAgBAAQAAAAgBABQAAAAAAAAQAAABAAAAg"),this.shape.setTransform(42.9,42,1.857,1.857),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(24.1,9.5,37.7,65),e.frameBounds=[A],(s.TabletIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AhvCeQgKAAgHgHQgGgHAAgJIAAkNQAAgKAGgGQAHgHAKAAIDfAAQAKAAAGAHQAHAHAAAJIAAENQAAAJgHAHQgGAHgKAAgAgeCLIA8AAIAAgHIg8AAgAhvBuIDfAAIAAjvIjfAAg"),this.shape.setTransform(43,43,1.642,1.642),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(20.8,17,44.6,52.1),e.frameBounds=[A],(s.JoystickIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AA1BaQgYgagdABQgdgBgYAaQgYAZgNAAQgMAAgIgMQgIgMgBgUQABgqAVggQAUgeAVAAQANAAANAIQAOAJAIACQACgXALgPQASgVAlgBQAYAAALgOQAEgHAAgJQAAgKALAAQADABADACQAEAEAAADQAAASgNAOQgQASgfABQgsAAgGAmQAGgBAQgJQAMgJANABQAUAAAUAeQAXAgAAAqQgBAVgIAMQgJALgMAAQgMAAgZgZgAAzAuQgEAEAAAFQAAAFADAEQAEADAGAAQAFABADgEQAEgEAAgFQAAgFgEgEQgEgEgEgBQgFABgEAEgAhZAtIAVAAIAAAUIAUAAIAAgUIATAAIAAgUIgTAAIAAgVIgUAAIAAAVIgVAAgABGAaQgDADAAAGQAAAFADAEQAFADAEAAQAFAAAEgDQAEgFAAgEQAAgGgEgDQgEgFgFAAQgEAAgFAFgAAeAaQgEADAAAGQAAAFAEAEQAEADAFAAQAGAAADgDQAEgEAAgFQAAgGgDgDQgFgFgEAAQgFAAgFAFgAAyAFQgDAFAAAEQAAAGAEAEQAEAEAFAAQAEAAAEgEQAEgEAAgGQAAgEgEgFQgEgEgEAAQgGAAgEAEg"),this.shape.setTransform(42,42,2.476,2.476),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(12.3,13.5,59.5,57),e.frameBounds=[A],(s.KeyboardIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AkMEzQgiAAgXgWQgYgXAAgjIAAjYQAAggAYgXQAXgXAiAAID3AAQAAhLAkgeQAWgTA0gHQApgFAOgLQAUgRAAg1QAAgWAXAAQAXAAABAWQAABOgoAeQgWASg1AHQgpAGgOAKQgUAQAAA0ID2AAQAjAAAWAXQAZAXAAAgIAADYQAAAjgZAXQgWAWgjAAgADWDjIA1AAIAAg1Ig1AAgAi8DjIF3AAIAAg1Il3AAgAkMDjIA1AAIAAg1Ig1AAgACgCTIA2AAIAAg4Ig2AAgABQCTIA1AAIAAg4Ig1AAgAAACTIA1AAIAAg4Ig1AAgAhRCTIA2AAIAAg4Ig2AAgAihCTIA1AAIAAg4Ig1AAgAjyCTIA2AAIAAg4Ig2AAgADWBBIA1AAIAAg2Ig1AAgACFBBIA2AAIAAg2Ig2AAgAA1BBIA1AAIAAg2Ig1AAgAgbBBIA1AAIAAg2Ig1AAgAhsBBIA2AAIAAg2Ig2AAgAi8BBIA2AAIAAg2Ig2AAgAkMBBIA1AAIAAg2Ig1AAg"),this.shape.setTransform(42,41.8,.773,.773),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(15,18,54.1,47.6),e.frameBounds=[A],(s.CloseButton=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f().s("#000000").ss(1,1,1).p("AAPABQAjgvAAgXQAhhJAIgLAhjiQIByCRAiICaIBLAAQAjhXAgg2QAFgGAEgGIB6CZ"),this.shape.setTransform(10,19.5),this.shape_1=new t.Shape,this.shape_1.graphics.f("#666666").s().p("Ai+C/IAAl9IF9AAIAAF9g"),this.shape_1.setTransform(12.6,19.4),this.addChild(this.shape_1,this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-6.6,.3,38.3,38.3),e.frameBounds=[A],(s.btnLink=function(){this.initialize(),this.text=new t.Text("Link a new account","20px 'Times New Roman'","#FF0033"),this.text.lineHeight=22,this.text.lineWidth=235,this.text.setTransform(2.3,-1.7),this.shape=new t.Shape,this.shape.graphics.f("#666666").s("#FFFFFF").ss(1,1,1).dr(-83.5,-13,167,26),this.shape.setTransform(83.5,13),this.addChild(this.shape,this.text)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-1,-1.7,242.5,28.7),e.frameBounds=[A],(s.Placeholder=function(){this.initialize(),this.instance=new s.TextPlaceholderBackground,this.addChild(this.instance)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,100,100),e.frameBounds=[A],(s.Pointer=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Up:0,Over:1,Down:2,Out:3}),this.instance=new s.PointerInactive("synched",0,!1),this.instance.setTransform(3,5,.639,.774,90,0,0,7.8,-3.9),this.instance_1=new s.PointerActive("synched",0),this.instance_1.setTransform(3,5,.639,.774,90,0,0,7.8,-3.9),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.instance}]}).to({state:[{t:this.instance_1,p:{x:3,y:5}}]},1).to({state:[{t:this.instance_1,p:{x:3,y:5}}]},1).to({state:[{t:this.instance_1,p:{x:3.1,y:5.1}}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-11.4,-28.1,22.8,28.2),e.frameBounds=[A,A,A,new t.Rectangle(-11.4,-28,22.8,28.2)],(s.Button=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Over:1,"Over-NoAnim":6,Up:7,"Up-NoAnim":11,Down:12,Hit:13}),this.frame_0=function(){this.stop()},this.frame_6=function(){this.stop()},this.frame_11=function(){this.stop()},this.frame_12=function(){this.stop()},this.frame_13=function(){this.stop()},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(6).call(this.frame_6).wait(5).call(this.frame_11).wait(1).call(this.frame_12).wait(1).call(this.frame_13).wait(1)),this.text=new s.Placeholder,this.text.setTransform(13.7,13.7,1.739,.494,0,.4,.5,.1,.8),this.timeline.addTween(t.Tween.get(this.text).wait(1).to({scaleX:1.89,rotation:.4,skewX:0,skewY:0,x:5.7},0).to({scaleY:.57,rotation:5.4,x:8.7,y:1.7},5).to({scaleY:.54,rotation:5.2,x:8.4,y:2},1).to({scaleY:.49,rotation:.4,x:5.7,y:13.7},4).wait(1).to({rotation:.4},0).wait(2)),this.shape=new t.Shape,this.shape.graphics.f("#0F0609").s().p("A42D+Ii+oDMA3pgAIIkyIbg"),this.shape.setTransform(103.3,39.2,.566,1),this.shape_1=new t.Shape,this.shape_1.graphics.f("#0F0609").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_1.setTransform(103.4,39.1,.821,.821),this.shape_2=new t.Shape,this.shape_2.graphics.f("#0F0609").s().p("AuwDkIhboZMAgWABDIjGIog"),this.shape_2.setTransform(104.2,39.3),this.shape_3=new t.Shape,this.shape_3.graphics.f("#0F0609").s().p("AvXDTIhOoqMAhLAB9IjaIyg"),this.shape_3.setTransform(104.8,39),this.shape_4=new t.Shape,this.shape_4.graphics.f("#0F0609").s().p("AvzDHIhFo2MAhxACmIjpI5g"),this.shape_4.setTransform(105.2,38.9),this.shape_5=new t.Shape,this.shape_5.graphics.f("#0F0609").s().p("AwEDAIhAo+MAiJADAIjyI9g"),this.shape_5.setTransform(105.5,38.7),this.shape_6=new t.Shape,this.shape_6.graphics.f("#0F0507").s().p("AvmDNIhKoxMAhhACUIjiI1g"),this.shape_6.setTransform(105,38.9),this.shape_7=new t.Shape,this.shape_7.graphics.f("#0F0305").s().p("AvDDbIhVohMAgxABgIjRItg"),this.shape_7.setTransform(104.5,39.2),this.shape_8=new t.Shape,this.shape_8.graphics.f("#0F0202").s().p("AugDrIhgoTMAgBAAsIi+Ikg"),this.shape_8.setTransform(103.9,39.4),this.shape_9=new t.Shape,this.shape_9.graphics.f("#0F0000").s().p("At9D+IhroDIfRgIIisIbg"),this.shape_9.setTransform(103.4,39.2),this.shape_10=new t.Shape,this.shape_10.graphics.f("#990000").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_10.setTransform(103.4,39.1,.821,.821),this.shape_11=new t.Shape,this.shape_11.graphics.f("#0F51B8").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_11.setTransform(103.4,39.1,.821,.821),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape}]}).to({state:[{t:this.shape_1,p:{scaleX:.821,scaleY:.821,rotation:0,x:103.4,y:39.1}}]},1).to({state:[{t:this.shape_2}]},1).to({state:[{t:this.shape_3}]},1).to({state:[{t:this.shape_4}]},1).to({state:[{t:this.shape_5}]},1).to({state:[{t:this.shape_1,p:{scaleX:.903,scaleY:.903,rotation:5.4,x:102.8,y:39.2}}]},1).to({state:[{t:this.shape_1,p:{scaleX:.903,scaleY:.903,rotation:5.4,x:102.8,y:39.2}}]},1).to({state:[{t:this.shape_6}]},1).to({state:[{t:this.shape_7}]},1).to({state:[{t:this.shape_8}]},1).to({state:[{t:this.shape_9}]},1).to({state:[{t:this.shape_10}]},1).to({state:[{t:this.shape_11}]},1).wait(1)),this.shape_12=new t.Shape,this.shape_12.graphics.f().s("#0F0609").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_12.setTransform(103.9,39.4,.826,.821,0,0,0,-.2,0),this.shape_13=new t.Shape,this.shape_13.graphics.f().s("#0A6006").ss(2).p("Aw0kaMAhpgAsIiVJgI9lAtg"),this.shape_13.setTransform(103.5,39.3,1,1,0,0,0,.1,0),this.shape_14=new t.Shape,this.shape_14.graphics.f().s("#05A503").ss(2).p("AxSkVMAikgBFIiSJyI+ZBDg"),this.shape_14.setTransform(103.1,39.2,1,1,0,0,0,.1,0),this.shape_15=new t.Shape,this.shape_15.graphics.f().s("#02D701").ss(2).p("AxmkRMAjNgBYIiQKAI+9BTg"),this.shape_15.setTransform(102.7,39.2,1,1,0,0,0,.1,0),this.shape_16=new t.Shape,this.shape_16.graphics.f().s("#01F500").ss(2).p("AxykPMAjlgBiIiOKHI/UBdg"),this.shape_16.setTransform(102.5,39.1,1,1,0,0,0,.1,0),this.shape_17=new t.Shape,this.shape_17.graphics.f().s("#00FF00").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_17.setTransform(103.4,39.4,.903,.903,-2.2,0,0,-.2,0),this.shape_18=new t.Shape,this.shape_18.graphics.f().s("#0FFF00").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_18.setTransform(103.4,39.4,.903,.903,-2.2,0,0,-.2,0),this.shape_19=new t.Shape,this.shape_19.graphics.f().s("#0FC102").ss(2).p("AxdkTMAi6gBPIiQJ6I+uBMg"),this.shape_19.setTransform(102.9,39.2,1,1,0,0,0,.1,0),this.shape_20=new t.Shape,this.shape_20.graphics.f().s("#0F8305").ss(2).p("AxDkXMAiGgA5IiTJpI9/A4g"),this.shape_20.setTransform(103.3,39.3,1,1,0,0,0,.1,0),this.shape_21=new t.Shape,this.shape_21.graphics.f().s("#0F4407").ss(2).p("AwpkbMAhSgAjIiVJZI9SAkg"),this.shape_21.setTransform(103.7,39.3,1,1,0,0,0,.1,0),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_12}]}).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_13}]},1).to({state:[{t:this.shape_14}]},1).to({state:[{t:this.shape_15}]},1).to({state:[{t:this.shape_16}]},1).to({state:[{t:this.shape_17}]},1).to({state:[{t:this.shape_18}]},1).to({state:[{t:this.shape_19}]},1).to({state:[{t:this.shape_20}]},1).to({state:[{t:this.shape_21}]},1).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_12}]},1).wait(1)),this.timeline.addTween(t.Tween.get(this.shape_12).wait(1).to({scaleX:.82},0).to({_off:!0},1).wait(9).to({_off:!1},0).wait(3)),this.shape_22=new t.Shape,this.shape_22.graphics.f("#592230").s().p("A0sFHIAysmMAonACoIloMXg"),this.shape_22.setTransform(109.6,39.4,.826,.821),this.shape_23=new t.Shape,this.shape_23.graphics.f("#592230").s().p("AxqECIA4qsMAidAC7Ik/Kag"),this.shape_23.setTransform(109.5,39.1),this.shape_24=new t.Shape,this.shape_24.graphics.f("#592230").s().p("AyMD5IBDq8MAjXADgIlTKng"),this.shape_24.setTransform(109.6,38.9),this.shape_25=new t.Shape,this.shape_25.graphics.f("#592230").s().p("AylD0IBMrKMAj/AD8IlfKxg"),this.shape_25.setTransform(109.5,38.8),this.shape_26=new t.Shape,this.shape_26.graphics.f("#592230").s().p("Ay0DwIBRrRMAkYAEMIlnK3g"),this.shape_26.setTransform(109.5,38.7),this.shape_27=new t.Shape,this.shape_27.graphics.f("#592230").s().p("AyaD2IBIrEMAjtADwIlZKsg"),this.shape_27.setTransform(109.6,38.9),this.shape_28=new t.Shape,this.shape_28.graphics.f("#592230").s().p("Ax7D9IA9q0MAi7ADOIlKKhg"),this.shape_28.setTransform(109.6,39.1),this.shape_29=new t.Shape,this.shape_29.graphics.f("#592230").s().p("AxdEFIA0qlMAiGACsIk3KVg"),this.shape_29.setTransform(109.6,39.2),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_22}]}).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_23}]},1).to({state:[{t:this.shape_24}]},1).to({state:[{t:this.shape_25}]},1).to({state:[{t:this.shape_26}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_27}]},1).to({state:[{t:this.shape_28}]},1).to({state:[{t:this.shape_29}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).wait(1)),this.timeline.addTween(t.Tween.get(this.shape_22).wait(1).to({scaleX:.82,x:109.5},0).to({_off:!0},1).wait(4).to({_off:!1,scaleX:.9,scaleY:.9,rotation:3,x:109.6},0).wait(1).to({_off:!0},1).wait(3).to({_off:!1,scaleX:.82,scaleY:.82,rotation:0,x:109.5},0).wait(3))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-1.8,0,220.9,78.8),e.frameBounds=[A,new t.Rectangle(-1.1,0,219.5,78.8),new t.Rectangle(-5.5,-3.6,228.3,85.4),new t.Rectangle(-8.9,-6.3,235.1,90.6),new t.Rectangle(-11.3,-8.3,240,94.3),new t.Rectangle(-12.8,-9.5,242.9,96.5),A=new t.Rectangle(-13.3,-9.9,243.9,97.2),A,new t.Rectangle(-10.2,-7.4,237.8,92.6),new t.Rectangle(-7.2,-4.9,231.7,88),new t.Rectangle(-4.1,-2.5,225.5,83.4),A=new t.Rectangle(-1.1,0,219.5,78.8),A,A],(s.Cog=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{}),this.frame_14=function(){this.gotoAndPlay(1)},this.timeline.addTween(t.Tween.get(this).wait(14).call(this.frame_14).wait(1)),this.instance=new s.CogVector("synched",0),this.instance.setTransform(75.1,77.1),this.timeline.addTween(t.Tween.get(this.instance).to({rotation:36},14).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(0,0,150.2,154.3),e.frameBounds=[A,new t.Rectangle(-.6,.1,151.6,154.2),new t.Rectangle(-1.2,.1,152.7,154.1),new t.Rectangle(-1.6,.3,153.5,153.8),new t.Rectangle(-1.9,.6,154,153.1),new t.Rectangle(-2,1.1,154.1,152.1),new t.Rectangle(-2,1.7,154.1,151),new t.Rectangle(-2,2.2,154.1,149.9),new t.Rectangle(-2,1.5,154.1,151.3),new t.Rectangle(-2,1,154.1,152.4),new t.Rectangle(-1.8,.6,153.8,153.3),new t.Rectangle(-1.4,.2,153,153.8),new t.Rectangle(-1,.2,152.2,154),new t.Rectangle(-.4,.2,150.9,154),new t.Rectangle(0,.1,150.2,154.1)],(s.Signin=function(){this.initialize(),this.close=new s.CloseButton,this.close.setTransform(526.3,132.5,1,1,0,0,0,10,19.5),this.users=new s.ListUsers,this.users.setTransform(206.7,159.2);var e=new t.Shape;e._off=!0,e.graphics.p("A4tIoIAAsrMAypAAAIAAMrg"),e.setTransform(166.1,55.3),this.btnLinkAccount=new s.btnLink,this.btnLinkAccount.setTransform(367.6,325.3,1,1,0,0,0,83.5,13),this.title=new t.Text("Select your profile","20px 'Times New Roman'","#FFFFFF"),this.title.name="title",this.title.lineHeight=22,this.title.lineWidth=217,this.title.setTransform(202.8,116.1),this.shape=new t.Shape,this.shape.graphics.f("#999999").s().p("A68SPMAAAgkdMA15AAAMAAAAkdg"),this.shape.setTransform(367.5,229.7),this.shape_1=new t.Shape,this.shape_1.graphics.f("rgba(0,0,0,0.498)").s().p("Eg4TAlfMAAAhK9MBwnAAAMAAABK9g"),this.shape_1.setTransform(359.5,240),this.addChild(this.shape_1,this.shape,this.title,this.btnLinkAccount,this.users,this.close)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-1,0,721,480),e.frameBounds=[A],(s.PortalView=function(){this.initialize(),this.ListActiveUsers=new s.lstUsers,this.ListActiveUsers.setTransform(523.3,139.8,1,1,0,0,0,162.2,42),this.ListConnectedDevices=new s.lstUsers,this.ListConnectedDevices.setTransform(190.3,139.8,1,1,0,0,0,163.3,42),this.shape=new t.Shape,this.shape.graphics.f().s("rgba(255,255,255,0)").ss(.1,1,1).p("AvJkmIeTAAIAAJNI+TAAg"),this.shape.setTransform(327,308.5),this.text=new t.Text("Active users","30px 'Times New Roman'","#FFFFFF"),this.text.lineHeight=32,this.text.lineWidth=284,this.text.setTransform(374,25.3),this.text_1=new t.Text("Connected users","30px 'Times New Roman'","#FFFFFF"),this.text_1.lineHeight=32,this.text_1.lineWidth=284,this.text_1.setTransform(27,25.3),this.shape_1=new t.Shape,this.shape_1.graphics.f().s("#666666").ss(1,1,1).p("EgzYAAAMBmyAAA"),this.shape_1.setTransform(357.1,65),this.shape_2=new t.Shape,this.shape_2.graphics.rf(["#333333","#000000","#000000"],[0,.6,1],0,0,0,0,0,432.7).s().p("Eg4PAlfMAAAhK+MBwfAAAMAAABK+gEAy8gbVMhmyAAAg"),this.shape_2.setTransform(360,240),this.addChild(this.shape_2,this.shape_1,this.text_1,this.text,this.shape,this.ListConnectedDevices,this.ListActiveUsers)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,720,480),e.frameBounds=[A],(s.User=function(){this.initialize(),this.boundary=new s.Marker,this.boundary.setTransform(79.4,118.4),this.picture=new s.Placeholder,this.picture.setTransform(37.5,37.5,.75,.75,0,0,0,50,50),this.name=new t.Text("User","15px 'Times New Roman'"),this.name.name="name",this.name.lineHeight=17,this.name.lineWidth=71,this.name.setTransform(0,75),this.shape=new t.Shape,this.shape.graphics.f("rgba(0,0,0,0.498)").s().p("Al2F2IAArsILsAAIAALsg"),this.shape.setTransform(37.5,37.5),this.addChild(this.shape,this.name,this.picture,this.boundary)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,75,114.2),e.frameBounds=[A],(s.Slider=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Up:0,Over:1,Down:2,Hit:3}),this.frame_0=function(){this.pointer.gotoAndStop("Up"),this.stop()},this.frame_1=function(){this.stop(),this.pointer.gotoAndStop("Over")},this.frame_2=function(){this.stop(),this.pointer.gotoAndStop("Down")},this.frame_3=function(){this.stop(),this.pointer.gotoAndStop("Out")},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(1).call(this.frame_1).wait(1).call(this.frame_2).wait(1).call(this.frame_3).wait(1)),this.pointer=new s.Pointer,this.pointer.setTransform(35,41.1,1,1,0,0,0,0,2),this.maximum=new s.Marker,this.maximum.setTransform(342,35),this.minimum=new s.Marker,this.minimum.setTransform(35,41),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.minimum},{t:this.maximum},{t:this.pointer}]}).wait(4)),this.shape=new t.Shape,this.shape.graphics.f().s("#320B1F").ss(4).p("AgY4mMAAxAxN"),this.shape.setTransform(186,26.5,1.113,1.111,-90,0,0,.1,0),this.shape_1=new t.Shape,this.shape_1.graphics.f("#320B1F").s().p("AgnAoQgQgRAAgXQAAgWAQgRQARgQAWAAQAXAAARAQQAQARAAAWQAAAXgQARQgRAQgXAAQgWAAgRgQg"),this.shape_1.setTransform(9.6,31.4,1.694,1.694,-90),this.shape_2=new t.Shape,this.shape_2.graphics.f("#320B1F").s().p("AgkAlQgQgPAAgWQAAgUAQgQQAPgQAVAAQAVAAAQAQQAQAQAAAUQAAAWgQAPQgQAQgVAAQgVAAgPgQg"),this.shape_2.setTransform(370.1,24,1.694,1.694,-90),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]}).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(0,10.9,379.1,30.1),e.frameBounds=[A,A,A,A],(s.portal=function(){this.initialize(),this.instance=new s.Signin,this.instance.setTransform(172.5,116.7,1,1,0,0,0,172.5,116.7),this.addChild(this.instance)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(359,240,721,480),e.frameBounds=[A]),define("CatLab/Webremote/assets/createjsassets",(e=>function(){return e.ctlbrmtassets})(this)),define("CatLab/Webremote/ViewFactory/CreatejsViewFactory",["CatLab/Webremote/Tools/Deferred"],function(t){function e(e){void 0!==e&&this.setAssets(e)}var r,a,h,l,i=e.prototype;return i.initialize=function(){var e=new t;return this.loadAssets().then(function(){this.setAssets(this.assets),e.resolve()}.bind(this)),e},i.loadAssets=function(){var o=new t;return require(["CatLab/Webremote/CreateJS/LayerContainer","CatLab/Webremote/CreateJS/Views/PortalView","CatLab/Webremote/CreateJS/Views/AuthenticationView","CatLab/Webremote/CreateJS/Views/AlertView","CatLab/Webremote/assets/createjsassets"],function(e,t,i,s,n){r=e,a=t,h=i,l=s,o.resolve()}.bind(this)),o.promise()},i.portal=function(e){return e.assets=this.assets,new a(e)},i.authentication=function(e){return e.assets=this.assets,new h(e)},i.alert=function(e){return e.assets=this.assets,new l(e)},i.setAssets=function(e){void 0!==e&&(this.assets=e)},i.getContainer=function(){var e=new r;return e.setBounds(0,0,this.assets.properties.width,this.assets.properties.height),e.loading(),e},e}),define("CatLab/Webremote/FrontWebcontrol",["CatLab/Webremote/Config","CatLab/Webremote/Polyfills","CatLab/Webremote/Tools/Tracker","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/Webcontrol","CatLab/Webremote/Tools/Smileys","CatLab/Webremote/Tools/Images","CatLab/Webremote/Models/Users/KeyboardUser","CatLab/Webremote/Models/Users/CordovaUser","CatLab/Webremote/Models/Users/AndroidRemoteUser","CatLab/Webremote/Models/Users/DummyUser","CatLab/Webremote/Providers/SocketIO","CatLab/Webremote/Providers/Airconsole","CatLab/Webremote/ViewFactory/ViewFactory","CatLab/Webremote/ViewFactory/CreatejsViewFactory","CatLab/Webremote/Messages/NavigateableProxy"],function(t,e,i,s,n,o,r,a,h,l,c,u,d,f,g,p,m){return{Config:function(e){t.set(e)},Tracker:i,Tools:s,Webcontrol:new o,OAuth2:n,Controls:{Keyboard:h,Cordova:l,AndroidRemote:c,Dummy:u},Controllers:{Webcontrol:o},Models:{User:u},Providers:{SocketIO:d,Airconsole:f},ViewFactories:{HtmlViewFactory:g,CreatejsViewFactory:p},Smileys:r,Images:new a,NavigateableProxy:m}}),define("webcontrol",["CatLab/Webremote/FrontWebcontrol"],function(e){return e}),define("CatLab/EaselHacks/AlphaMaskFilter",[],function(e){function t(e){var s=this;this.createjs=e,Object.defineProperty(e.DisplayObject.prototype,"mask",{get:function(){return this.forceMask},set:function(e){var t,i=this;e?(i.originalMask=e,t=s.getFilterFromMask(e,i),i.filters=[t],i.cache(0,0,500,500)):null!==e&&(i.filters=null,i.cache(0,0,500,500))}}),e.DisplayObject.prototype.setMask=function(e){this.forceMask=e}}return t.prototype.getFilterFromMask=function(e,t){var i=this.createjs,s=e.graphics.getInstructions(),n=new i.Graphics;n.beginFill("#000000"),n.beginStroke("#000000");for(var o=0;o<s.length;o++)n.append(s[o]);e.graphics=n;var r=new i.Container,e=(r.addChild(e),r.scaleX=1/t.scaleX,r.scaleY=1/t.scaleY,r.y=-t.y,r.x=-t.x,new i.Container);return e.addChild(r),e.cache(0,0,1e3,1e3),new i.AlphaMaskFilter(e.cacheCanvas)},t}),define("CatLab/EaselHacks/FrontController",["CatLab/EaselHacks/AlphaMaskFilter"],function(e){return{AlphaMaskFilter:e}}),define("easelhacks",["CatLab/EaselHacks/FrontController"],function(e){return e}),define("CatLab/Webremote/Hacks",["easelhacks","easeljs"],function(e,t){new e.AlphaMaskFilter(t)});
|