everlive.all.js
67.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*!
* Reqwest! A general purpose XHR connection manager
* (c) Dustin Diaz 2013
* https://github.com/ded/reqwest
* license MIT
*/
!function(e,t,n){typeof module!="undefined"&&module.exports?module.exports=n():typeof define=="function"&&define.amd?define(n):t[e]=n()}("reqwest",this,function(){function handleReadyState(e,t,n){return function(){if(e._aborted)return n(e.request);e.request&&e.request[readyState]==4&&(e.request.onreadystatechange=noop,twoHundo.test(e.request.status)?t(e.request):n(e.request))}}function setHeaders(e,t){var n=t.headers||{},r;n.Accept=n.Accept||defaultHeaders.accept[t.type]||defaultHeaders.accept["*"],!t.crossOrigin&&!n[requestedWith]&&(n[requestedWith]=defaultHeaders.requestedWith),n[contentType]||(n[contentType]=t.contentType||defaultHeaders.contentType);for(r in n)n.hasOwnProperty(r)&&e.setRequestHeader(r,n[r])}function setCredentials(e,t){typeof t.withCredentials!="undefined"&&typeof e.withCredentials!="undefined"&&(e.withCredentials=!!t.withCredentials)}function generalCallback(e){lastValue=e}function urlappend(e,t){return e+(/\?/.test(e)?"&":"?")+t}function handleJsonp(e,t,n,r){var i=uniqid++,s=e.jsonpCallback||"callback",o=e.jsonpCallbackName||reqwest.getcallbackPrefix(i),u=new RegExp("((^|\\?|&)"+s+")=([^&]+)"),a=r.match(u),f=doc.createElement("script"),l=0,c=navigator.userAgent.indexOf("MSIE 10.0")!==-1;return a?a[3]==="?"?r=r.replace(u,"$1="+o):o=a[3]:r=urlappend(r,s+"="+o),win[o]=generalCallback,f.type="text/javascript",f.src=r,f.async=!0,typeof f.onreadystatechange!="undefined"&&!c&&(f.event="onclick",f.htmlFor=f.id="_reqwest_"+i),f.onload=f.onreadystatechange=function(){if(f[readyState]&&f[readyState]!=="complete"&&f[readyState]!=="loaded"||l)return!1;f.onload=f.onreadystatechange=null,f.onclick&&f.onclick(),e.success&&e.success(lastValue),lastValue=undefined,head.removeChild(f),l=1},head.appendChild(f),{abort:function(){f.onload=f.onreadystatechange=null,e.error&&e.error({},"Request is aborted: timeout",{}),lastValue=undefined,head.removeChild(f),l=1}}}function getRequest(e,t){var n=this.o,r=(n.method||"GET").toUpperCase(),i=typeof n=="string"?n:n.url,s=n.processData!==!1&&n.data&&typeof n.data!="string"?reqwest.toQueryString(n.data):n.data||null,o;return(n.type=="jsonp"||r=="GET")&&s&&(i=urlappend(i,s),s=null),n.type=="jsonp"?handleJsonp(n,e,t,i):(o=xhr(),o.open(r,i,!0),setHeaders(o,n),setCredentials(o,n),o.onreadystatechange=handleReadyState(this,e,t),n.before&&n.before(o),o.send(s),o)}function Reqwest(e,t){this.o=e,this.fn=t,init.apply(this,arguments)}function setType(e){var t=e.match(/\.(json|jsonp|html|xml)(\?|$)/);return t?t[1]:"js"}function init(o,fn){function complete(e){o.timeout&&clearTimeout(self.timeout),self.timeout=null;while(self._completeHandlers.length>0)self._completeHandlers.shift()(e)}function success(resp){var filteredResponse=globalSetupOptions.dataFilter(resp.responseText,type),r=resp.responseText=filteredResponse;if(r)switch(type){case"json":try{resp=win.JSON?win.JSON.parse(r):eval("("+r+")")}catch(err){return error(resp,"Could not parse JSON in response",err)}break;case"js":resp=eval(r);break;case"html":resp=r;break;case"xml":resp=resp.responseXML&&resp.responseXML.parseError&&resp.responseXML.parseError.errorCode&&resp.responseXML.parseError.reason?null:resp.responseXML}self._responseArgs.resp=resp,self._fulfilled=!0,fn(resp);while(self._fulfillmentHandlers.length>0)self._fulfillmentHandlers.shift()(resp);complete(resp)}function error(e,t,n){self._responseArgs.resp=e,self._responseArgs.msg=t,self._responseArgs.t=n,self._erred=!0;while(self._errorHandlers.length>0)self._errorHandlers.shift()(e,t,n);complete(e)}this.url=typeof o=="string"?o:o.url,this.timeout=null,this._fulfilled=!1,this._fulfillmentHandlers=[],this._errorHandlers=[],this._completeHandlers=[],this._erred=!1,this._responseArgs={};var self=this,type=o.type||setType(this.url);fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort()},o.timeout)),o.success&&this._fulfillmentHandlers.push(function(){o.success.apply(o,arguments)}),o.error&&this._errorHandlers.push(function(){o.error.apply(o,arguments)}),o.complete&&this._completeHandlers.push(function(){o.complete.apply(o,arguments)}),this.request=getRequest.call(this,success,error)}function reqwest(e,t){return new Reqwest(e,t)}function normalize(e){return e?e.replace(/\r?\n/g,"\r\n"):""}function serial(e,t){var n=e.name,r=e.tagName.toLowerCase(),i=function(e){e&&!e.disabled&&t(n,normalize(e.attributes.value&&e.attributes.value.specified?e.value:e.text))},s,o,u,a;if(e.disabled||!n)return;switch(r){case"input":/reset|button|image|file/i.test(e.type)||(s=/checkbox/i.test(e.type),o=/radio/i.test(e.type),u=e.value,(!s&&!o||e.checked)&&t(n,normalize(s&&u===""?"on":u)));break;case"textarea":t(n,normalize(e.value));break;case"select":if(e.type.toLowerCase()==="select-one")i(e.selectedIndex>=0?e.options[e.selectedIndex]:null);else for(a=0;e.length&&a<e.length;a++)e.options[a].selected&&i(e.options[a])}}function eachFormElement(){var e=this,t,n,r=function(t,n){var r,i,s;for(r=0;r<n.length;r++){s=t[byTag](n[r]);for(i=0;i<s.length;i++)serial(s[i],e)}};for(n=0;n<arguments.length;n++)t=arguments[n],/input|select|textarea/i.test(t.tagName)&&serial(t,e),r(t,["input","select","textarea"])}function serializeQueryString(){return reqwest.toQueryString(reqwest.serializeArray.apply(null,arguments))}function serializeHash(){var e={};return eachFormElement.apply(function(t,n){t in e?(e[t]&&!isArray(e[t])&&(e[t]=[e[t]]),e[t].push(n)):e[t]=n},arguments),e}var win=window,doc=document,twoHundo=/^20\d$/,byTag="getElementsByTagName",readyState="readyState",contentType="Content-Type",requestedWith="X-Requested-With",head=doc[byTag]("head")[0],uniqid=0,callbackPrefix="reqwest_"+ +(new Date),lastValue,xmlHttpRequest="XMLHttpRequest",noop=function(){},isArray=typeof Array.isArray=="function"?Array.isArray:function(e){return e instanceof Array},defaultHeaders={contentType:"application/x-www-form-urlencoded",requestedWith:xmlHttpRequest,accept:{"*":"text/javascript, text/html, application/xml, text/xml, */*",xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript",js:"application/javascript, text/javascript"}},xhr=win[xmlHttpRequest]?function(){return new XMLHttpRequest}:function(){return new ActiveXObject("Microsoft.XMLHTTP")},globalSetupOptions={dataFilter:function(e){return e}};return Reqwest.prototype={abort:function(){this._aborted=!0,this.request.abort()},retry:function(){init.call(this,this.o,this.fn)},then:function(e,t){return this._fulfilled?e(this._responseArgs.resp):this._erred?t(this._responseArgs.resp,this._responseArgs.msg,this._responseArgs.t):(this._fulfillmentHandlers.push(e),this._errorHandlers.push(t)),this},always:function(e){return this._fulfilled||this._erred?e(this._responseArgs.resp):this._completeHandlers.push(e),this},fail:function(e){return this._erred?e(this._responseArgs.resp,this._responseArgs.msg,this._responseArgs.t):this._errorHandlers.push(e),this}},reqwest.serializeArray=function(){var e=[];return eachFormElement.apply(function(t,n){e.push({name:t,value:n})},arguments),e},reqwest.serialize=function(){if(arguments.length===0)return"";var e,t,n=Array.prototype.slice.call(arguments,0);return e=n.pop(),e&&e.nodeType&&n.push(e)&&(e=null),e&&(e=e.type),e=="map"?t=serializeHash:e=="array"?t=reqwest.serializeArray:t=serializeQueryString,t.apply(null,n)},reqwest.toQueryString=function(e){var t="",n,r=encodeURIComponent,i=function(e,n){t+=r(e)+"="+r(n)+"&"},s,o;if(isArray(e))for(n=0;e&&n<e.length;n++)i(e[n].name,e[n].value);else for(s in e){if(!Object.hasOwnProperty.call(e,s))continue;o=e[s];if(isArray(o))for(n=0;n<o.length;n++)i(s,o[n]);else i(s,e[s])}return t.replace(/&$/,"").replace(/%20/g,"+")},reqwest.getcallbackPrefix=function(){return callbackPrefix},reqwest.compat=function(e,t){return e&&(e.type&&(e.method=e.type)&&delete e.type,e.dataType&&(e.type=e.dataType),e.jsonpCallback&&(e.jsonpCallbackName=e.jsonpCallback)&&delete e.jsonpCallback,e.jsonp&&(e.jsonpCallback=e.jsonp)),new Reqwest(e,t)},reqwest.ajaxSetup=function(e){e=e||{};for(var t in e)globalSetupOptions[t]=e[t]},reqwest});
// RSVP.js provides simple tools for organizing asynchronous code.
// https://github.com/tildeio/rsvp.js
// Copyright (c) 2013 Yehuda Katz, Tom Dale, and contributors
(function(){var e,t;(function(){var r={},n={};e=function(e,t,n){r[e]={deps:t,callback:n}};t=function(e){if(n[e]){return n[e]}n[e]={};var i=r[e],o=i.deps,s=i.callback,f=[],c;for(var u=0,a=o.length;u<a;u++){if(o[u]==="exports"){f.push(c={})}else{f.push(t(o[u]))}}var l=s.apply(this,f);return n[e]=c||l}})();e("rsvp/all",["rsvp/defer","exports"],function(e,t){"use strict";var r=e.defer;function n(e){var t=[],n=r(),i=e.length;if(i===0){n.resolve([])}var o=function(e){return function(t){s(e,t)}};var s=function(e,r){t[e]=r;if(--i===0){n.resolve(t)}};var f=function(e){n.reject(e)};for(var c=0;c<e.length;c++){if(e[c]&&typeof e[c].then==="function"){e[c].then(o(c),f)}else{s(c,e[c])}}return n.promise}t.all=n});e("rsvp/async",["exports"],function(e){"use strict";var t=typeof window!=="undefined"?window:{};var r=t.MutationObserver||t.WebKitMutationObserver;var n;if(typeof process!=="undefined"&&{}.toString.call(process)==="[object process]"){n=function(e,t){process.nextTick(function(){e.call(t)})}}else if(r){var i=[];var o=new r(function(){var e=i.slice();i=[];e.forEach(function(e){var t=e[0],r=e[1];t.call(r)})});var s=document.createElement("div");o.observe(s,{attributes:true});window.addEventListener("unload",function(){o.disconnect();o=null});n=function(e,t){i.push([e,t]);s.setAttribute("drainQueue","drainQueue")}}else{n=function(e,t){setTimeout(function(){e.call(t)},1)}}e.async=n});e("rsvp/config",["rsvp/async","exports"],function(e,t){"use strict";var r=e.async;var n={};n.async=r;t.config=n});e("rsvp/defer",["rsvp/promise","exports"],function(e,t){"use strict";var r=e.Promise;function n(){var e={};var t=new r(function(t,r){e.resolve=t;e.reject=r});e.promise=t;return e}t.defer=n});e("rsvp/events",["exports"],function(e){"use strict";var t=function(e,t){this.type=e;for(var r in t){if(!t.hasOwnProperty(r)){continue}this[r]=t[r]}};var r=function(e,t){for(var r=0,n=e.length;r<n;r++){if(e[r][0]===t){return r}}return-1};var n=function(e){var t=e._promiseCallbacks;if(!t){t=e._promiseCallbacks={}}return t};var i={mixin:function(e){e.on=this.on;e.off=this.off;e.trigger=this.trigger;return e},on:function(e,t,i){var o=n(this),s,f;e=e.split(/\s+/);i=i||this;while(f=e.shift()){s=o[f];if(!s){s=o[f]=[]}if(r(s,t)===-1){s.push([t,i])}}},off:function(e,t){var i=n(this),o,s,f;e=e.split(/\s+/);while(s=e.shift()){if(!t){i[s]=[];continue}o=i[s];f=r(o,t);if(f!==-1){o.splice(f,1)}}},trigger:function(e,r){var i=n(this),o,s,f,c,u;if(o=i[e]){for(var a=0;a<o.length;a++){s=o[a];f=s[0];c=s[1];if(typeof r!=="object"){r={detail:r}}u=new t(e,r);f.call(c,u)}}}};e.EventTarget=i});e("rsvp/hash",["rsvp/defer","exports"],function(e,t){"use strict";var r=e.defer;function n(e){var t=0;for(var r in e){t++}return t}function i(e){var t={},i=r(),o=n(e);if(o===0){i.resolve({})}var s=function(e){return function(t){f(e,t)}};var f=function(e,r){t[e]=r;if(--o===0){i.resolve(t)}};var c=function(e){i.reject(e)};for(var u in e){if(e[u]&&typeof e[u].then==="function"){e[u].then(s(u),c)}else{f(u,e[u])}}return i.promise}t.hash=i});e("rsvp/node",["rsvp/promise","rsvp/all","exports"],function(e,t,r){"use strict";var n=e.Promise;var i=t.all;function o(e,t){return function(r,n){if(r){t(r)}else if(arguments.length>2){e(Array.prototype.slice.call(arguments,1))}else{e(n)}}}function s(e){return function(){var t=Array.prototype.slice.call(arguments),r,s;var f=new n(function(e,t){r=e;s=t});i(t).then(function(t){t.push(o(r,s));try{e.apply(this,t)}catch(n){s(n)}});return f}}r.denodeify=s});e("rsvp/promise",["rsvp/config","rsvp/events","exports"],function(e,t,r){"use strict";var n=e.config;var i=t.EventTarget;function o(e){return s(e)||typeof e==="object"&&e!==null}function s(e){return typeof e==="function"}var f=function(e){var t=this,r=false;if(typeof e!=="function"){throw new TypeError("You must pass a resolver function as the sole argument to the promise constructor")}if(!(t instanceof f)){return new f(e)}var n=function(e){if(r){return}r=true;u(t,e)};var i=function(e){if(r){return}r=true;l(t,e)};this.on("promise:resolved",function(e){this.trigger("success",{detail:e.detail})},this);this.on("promise:failed",function(e){this.trigger("error",{detail:e.detail})},this);e(n,i)};var c=function(e,t,r,n){var i=s(r),f,c,a,v;if(i){try{f=r(n.detail);a=true}catch(p){v=true;c=p}}else{f=n.detail;a=true}if(o(f)&&s(f.then)){f.then(function(e){u(t,e)},function(e){l(t,e)})}else if(i&&a){u(t,f)}else if(v){l(t,c)}else if(e==="resolve"){u(t,f)}else if(e==="reject"){l(t,f)}};f.prototype={constructor:f,then:function(e,t){var r=new f(function(){});if(this.isFulfilled){n.async(function(){c("resolve",r,e,{detail:this.fulfillmentValue})},this)}if(this.isRejected){n.async(function(){c("reject",r,t,{detail:this.rejectedReason})},this)}this.on("promise:resolved",function(t){c("resolve",r,e,t)});this.on("promise:failed",function(e){c("reject",r,t,e)});return r}};i.mixin(f.prototype);function u(e,t){if(e===t){a(e,t)}else if(o(t)&&s(t.then)){t.then(function(r){if(t!==r){u(e,r)}else{a(e,r)}},function(t){l(e,t)})}else{a(e,t)}}function a(e,t){n.async(function(){e.trigger("promise:resolved",{detail:t});e.isFulfilled=true;e.fulfillmentValue=t})}function l(e,t){n.async(function(){e.trigger("promise:failed",{detail:t});e.isRejected=true;e.rejectedReason=t})}r.Promise=f});e("rsvp/resolve",["rsvp/promise","exports"],function(e,t){"use strict";var r=e.Promise;function n(e){return typeof e==="function"||typeof e==="object"&&e!==null}function i(e){var t=new r(function(t,r){var i;try{if(n(e)){i=e.then;if(typeof i==="function"){i.call(e,t,r)}else{t(e)}}else{t(e)}}catch(o){r(o)}});return t}t.resolve=i});e("rsvp",["rsvp/events","rsvp/promise","rsvp/node","rsvp/all","rsvp/hash","rsvp/defer","rsvp/config","rsvp/resolve","exports"],function(e,t,r,n,i,o,s,f,c){"use strict";var u=e.EventTarget;var a=t.Promise;var l=r.denodeify;var v=n.all;var p=i.hash;var h=o.defer;var d=s.config;var y=f.resolve;function g(e,t){d[e]=t}c.Promise=a;c.EventTarget=u;c.all=v;c.hash=p;c.defer=h;c.denodeify=l;c.configure=g;c.resolve=y});window.RSVP=t("rsvp")})();
// Underscore.js 1.4.4
// http://underscorejs.org
// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore may be freely distributed under the MIT license.
(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,d=e.filter,g=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.4";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:d&&n.filter===d?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:g&&n.every===g?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2),e=w.isFunction(t);return w.map(n,function(n){return(e?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t,r){return w.isEmpty(t)?r?null:[]:w[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.findWhere=function(n,t){return w.where(n,t,!0)},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var k=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=k(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index<t.index?-1:1}),"value")};var F=function(n,t,r,e){var u={},i=k(t||w.identity);return A(n,function(t,a){var o=i.call(r,t,a,n);e(u,o,t)}),u};w.groupBy=function(n,t,r){return F(n,t,r,function(n,t,r){(w.has(n,t)?n[t]:n[t]=[]).push(r)})},w.countBy=function(n,t,r){return F(n,t,r,function(n,t){w.has(n,t)||(n[t]=0),n[t]++})},w.sortedIndex=function(n,t,r,e){r=null==r?w.identity:k(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i},w.bind=function(n,t){if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));var r=o.call(arguments,2);return function(){return n.apply(t,r.concat(o.call(arguments)))}},w.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var I=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=I(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&I(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return I(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var M={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};M.unescape=w.invert(M.escape);var S={escape:RegExp("["+w.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(M.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(S[n],function(t){return M[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),D.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,q={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||T).source,(r.interpolate||T).source,(r.evaluate||T).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(B,function(n){return"\\"+q[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var D=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],D.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return D.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);
/*! jsTimezoneDetect - v1.0.5 - 2013-04-01 */
(function(e){var t=function(){"use strict";var e="s",n=2011,r=function(e){var t=-e.getTimezoneOffset();return t!==null?t:0},i=function(e,t,n){var r=new Date;return e!==undefined&&r.setFullYear(e),r.setDate(n),r.setMonth(t),r},s=function(e){return r(i(e,0,2))},o=function(e){return r(i(e,5,2))},u=function(e){var t=e.getMonth()>7?o(e.getFullYear()):s(e.getFullYear()),n=r(e);return t-n!==0},a=function(){var t=s(n),r=o(n),i=t-r;return i<0?t+",1":i>0?r+",1,"+e:t+",0"},f=function(){var e=a();return new t.TimeZone(t.olson.timezones[e])},l=function(e){var t=new Date(2010,6,15,1,0,0,0),n={"America/Denver":new Date(2011,2,13,3,0,0,0),"America/Mazatlan":new Date(2011,3,3,3,0,0,0),"America/Chicago":new Date(2011,2,13,3,0,0,0),"America/Mexico_City":new Date(2011,3,3,3,0,0,0),"America/Asuncion":new Date(2012,9,7,3,0,0,0),"America/Santiago":new Date(2012,9,3,3,0,0,0),"America/Campo_Grande":new Date(2012,9,21,5,0,0,0),"America/Montevideo":new Date(2011,9,2,3,0,0,0),"America/Sao_Paulo":new Date(2011,9,16,5,0,0,0),"America/Los_Angeles":new Date(2011,2,13,8,0,0,0),"America/Santa_Isabel":new Date(2011,3,5,8,0,0,0),"America/Havana":new Date(2012,2,10,2,0,0,0),"America/New_York":new Date(2012,2,10,7,0,0,0),"Asia/Beirut":new Date(2011,2,27,1,0,0,0),"Europe/Helsinki":new Date(2011,2,27,4,0,0,0),"Europe/Istanbul":new Date(2011,2,28,5,0,0,0),"Asia/Damascus":new Date(2011,3,1,2,0,0,0),"Asia/Jerusalem":new Date(2011,3,1,6,0,0,0),"Asia/Gaza":new Date(2009,2,28,0,30,0,0),"Africa/Cairo":new Date(2009,3,25,0,30,0,0),"Pacific/Auckland":new Date(2011,8,26,7,0,0,0),"Pacific/Fiji":new Date(2010,10,29,23,0,0,0),"America/Halifax":new Date(2011,2,13,6,0,0,0),"America/Goose_Bay":new Date(2011,2,13,2,1,0,0),"America/Miquelon":new Date(2011,2,13,5,0,0,0),"America/Godthab":new Date(2011,2,27,1,0,0,0),"Europe/Moscow":t,"Asia/Yekaterinburg":t,"Asia/Omsk":t,"Asia/Krasnoyarsk":t,"Asia/Irkutsk":t,"Asia/Yakutsk":t,"Asia/Vladivostok":t,"Asia/Kamchatka":t,"Europe/Minsk":t,"Pacific/Apia":new Date(2010,10,1,1,0,0,0),"Australia/Perth":new Date(2008,10,1,1,0,0,0)};return n[e]};return{determine:f,date_is_dst:u,dst_start_for:l}}();t.TimeZone=function(e){"use strict";var n={"America/Denver":["America/Denver","America/Mazatlan"],"America/Chicago":["America/Chicago","America/Mexico_City"],"America/Santiago":["America/Santiago","America/Asuncion","America/Campo_Grande"],"America/Montevideo":["America/Montevideo","America/Sao_Paulo"],"Asia/Beirut":["Asia/Beirut","Europe/Helsinki","Europe/Istanbul","Asia/Damascus","Asia/Jerusalem","Asia/Gaza"],"Pacific/Auckland":["Pacific/Auckland","Pacific/Fiji"],"America/Los_Angeles":["America/Los_Angeles","America/Santa_Isabel"],"America/New_York":["America/Havana","America/New_York"],"America/Halifax":["America/Goose_Bay","America/Halifax"],"America/Godthab":["America/Miquelon","America/Godthab"],"Asia/Dubai":["Europe/Moscow"],"Asia/Dhaka":["Asia/Yekaterinburg"],"Asia/Jakarta":["Asia/Omsk"],"Asia/Shanghai":["Asia/Krasnoyarsk","Australia/Perth"],"Asia/Tokyo":["Asia/Irkutsk"],"Australia/Brisbane":["Asia/Yakutsk"],"Pacific/Noumea":["Asia/Vladivostok"],"Pacific/Tarawa":["Asia/Kamchatka"],"Pacific/Tongatapu":["Pacific/Apia"],"Africa/Johannesburg":["Asia/Gaza","Africa/Cairo"],"Asia/Baghdad":["Europe/Minsk"]},r=e,i=function(){var e=n[r],i=e.length,s=0,o=e[0];for(;s<i;s+=1){o=e[s];if(t.date_is_dst(t.dst_start_for(o))){r=o;return}}},s=function(){return typeof n[r]!="undefined"};return s()&&i(),{name:function(){return r}}},t.olson={},t.olson.timezones={"-720,0":"Pacific/Majuro","-660,0":"Pacific/Pago_Pago","-600,1":"America/Adak","-600,0":"Pacific/Honolulu","-570,0":"Pacific/Marquesas","-540,0":"Pacific/Gambier","-540,1":"America/Anchorage","-480,1":"America/Los_Angeles","-480,0":"Pacific/Pitcairn","-420,0":"America/Phoenix","-420,1":"America/Denver","-360,0":"America/Guatemala","-360,1":"America/Chicago","-360,1,s":"Pacific/Easter","-300,0":"America/Bogota","-300,1":"America/New_York","-270,0":"America/Caracas","-240,1":"America/Halifax","-240,0":"America/Santo_Domingo","-240,1,s":"America/Santiago","-210,1":"America/St_Johns","-180,1":"America/Godthab","-180,0":"America/Argentina/Buenos_Aires","-180,1,s":"America/Montevideo","-120,0":"America/Noronha","-120,1":"America/Noronha","-60,1":"Atlantic/Azores","-60,0":"Atlantic/Cape_Verde","0,0":"UTC","0,1":"Europe/London","60,1":"Europe/Berlin","60,0":"Africa/Lagos","60,1,s":"Africa/Windhoek","120,1":"Asia/Beirut","120,0":"Africa/Johannesburg","180,0":"Asia/Baghdad","180,1":"Europe/Moscow","210,1":"Asia/Tehran","240,0":"Asia/Dubai","240,1":"Asia/Baku","270,0":"Asia/Kabul","300,1":"Asia/Yekaterinburg","300,0":"Asia/Karachi","330,0":"Asia/Kolkata","345,0":"Asia/Kathmandu","360,0":"Asia/Dhaka","360,1":"Asia/Omsk","390,0":"Asia/Rangoon","420,1":"Asia/Krasnoyarsk","420,0":"Asia/Jakarta","480,0":"Asia/Shanghai","480,1":"Asia/Irkutsk","525,0":"Australia/Eucla","525,1,s":"Australia/Eucla","540,1":"Asia/Yakutsk","540,0":"Asia/Tokyo","570,0":"Australia/Darwin","570,1,s":"Australia/Adelaide","600,0":"Australia/Brisbane","600,1":"Asia/Vladivostok","600,1,s":"Australia/Sydney","630,1,s":"Australia/Lord_Howe","660,1":"Asia/Kamchatka","660,0":"Pacific/Noumea","690,0":"Pacific/Norfolk","720,1,s":"Pacific/Auckland","720,0":"Pacific/Tarawa","765,1,s":"Pacific/Chatham","780,0":"Pacific/Tongatapu","780,1,s":"Pacific/Apia","840,0":"Pacific/Kiritimati"},typeof exports!="undefined"?exports.jstz=t:e.jstz=t})(this);
/*!
The MIT License (MIT)
Copyright (c) 2013 Telerik AD
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.y distributed under the MIT license.
*/
/*!
Everlive SDK
Version 1.2.5
*/
(function(a,b){if(typeof define==="function"&&define.amd){define(["underscore","rsvp","reqwest","jstz"],function(f,e,c,d){return(a.Everlive=b(f,e,c,d))})}else{if(typeof exports==="object"){module.exports=b(require("underscore"),require("rsvp"))}else{a.Everlive=b(a._,a.RSVP,a.reqwest,a.jstz)}}}(this,function(z,i,k,f){var p=Array.prototype.slice;var B="//api.everlive.com/v1/";var g="Id";function a(E,C,D){if(!D){D="The "+C+" is required"}if(typeof E==="undefined"||E===null){throw new Error(D)}}function v(C){this.url=B;this.apiKey=null;this.masterKey=null;this.token=null;this.tokenType=null;this.scheme="http";this.parseOnlyCompleteDateTimeObjects=false;if(typeof C==="string"){this.apiKey=C}else{z.extend(this,C)}}var s=[];function r(D){var C=this;this.setup=new v(D);z.each(s,function(E){E.func.call(C,D)});if(r.$===null){r.$=C}}r.$=null;r.idField=g;r.initializations=s;r.init=function(C){r.$=null;return new r(C)};r.buildUrl=function(C){var D="";if(typeof C.scheme==="string"){D+=C.scheme+":"}D+=C.url;if(C.apiKey){D+=C.apiKey+"/"}return D};r.prototype.data=function(C){return new d(this.setup,C)};r.prototype.buildUrl=function(){return r.buildUrl(this.setup)};var q=function(D,E){var C=null;if(E&&E.authHeaders===false){return C}if(D.token){C=(D.tokenType||"bearer")+" "+D.token}else{if(D.masterKey){C="masterkey "+D.masterKey}}if(C){return{Authorization:C}}else{return null}};r.prototype.buildAuthHeader=function(){return q(this.setup)};(function(){var I={query:1,where:100,filter:101,and:110,or:111,not:112,equal:120,not_equal:121,lt:122,lte:123,gt:124,gte:125,isin:126,notin:127,all:128,size:129,regex:130,contains:131,startsWith:132,endsWith:133,nearShpere:140,withinBox:141,withinPolygon:142,withinShpere:143,select:200,exclude:201,order:300,order_desc:301,skip:400,take:401,expand:402};function E(J,K){this.operator=J;this.operands=K||[]}E.prototype={addOperand:function(J){this.operands.push(J)}};function D(N,J,L,O,K,M){this.filter=N;this.fields=J;this.sort=L;this.toskip=O;this.totake=K;this.expandExpression=M;this.expr=new E(I.query)}D.prototype={where:function(J){if(J){return this._simple(I.filter,[J])}else{return new H(this)}},select:function(){return this._simple(I.select,arguments)},order:function(J){return this._simple(I.order,[J])},orderDesc:function(J){return this._simple(I.order_desc,[J])},skip:function(J){return this._simple(I.skip,[J])},take:function(J){return this._simple(I.take,[J])},expand:function(J){return this._simple(I.expand,[J])},build:function(){return new G(this).build()},_simple:function(L,J){var K=p.call(J);this.expr.addOperand(new E(L,K));return this}};function H(L,K,J){this.parent=L;this.single=J;this.expr=new E(K||I.where);this.parent.expr.addOperand(this.expr)}H.prototype={and:function(){return new H(this,I.and)},or:function(){return new H(this,I.or)},not:function(){return new H(this,I.not,true)},_simple:function(J){var K=p.call(arguments,1);this.expr.addOperand(new E(J,K));return this._done()},eq:function(K,J){return this._simple(I.equal,K,J)},ne:function(K,J){return this._simple(I.not_equal,K,J)},gt:function(K,J){return this._simple(I.gt,K,J)},gte:function(K,J){return this._simple(I.gte,K,J)},lt:function(K,J){return this._simple(I.lt,K,J)},lte:function(K,J){return this._simple(I.lte,K,J)},isin:function(K,J){return this._simple(I.isin,K,J)},notin:function(K,J){return this._simple(I.notin,K,J)},all:function(K,J){return this._simple(I.all,K,J)},size:function(K,J){return this._simple(I.size,K,J)},regex:function(L,K,J){return this._simple(I.regex,L,K,J)},startsWith:function(L,K,J){return this._simple(I.startsWith,L,K,J)},endsWith:function(L,K,J){return this._simple(I.endsWith,L,K,J)},nearSphere:function(L,J,M,K){return this._simple(I.nearShpere,L,J,M,K)},withinBox:function(K,L,J){return this._simple(I.withinBox,K,L,J)},withinPolygon:function(K,J){return this._simple(I.withinPolygon,K,J)},withinCenterSphere:function(M,K,J,L){return this._simple(I.withinShpere,M,K,J,L)},done:function(){if(this.parent instanceof H){return this.parent._done()}else{return this.parent}},_done:function(){if(this.single){return this.parent}else{return this}}};H.prototype.equal=H.prototype.eq;H.prototype.notEqual=H.prototype.ne;H.prototype.greaterThan=H.prototype.gt;H.prototype.greaterThanEqual=H.prototype.gte;H.prototype.lessThan=H.prototype.lt;H.prototype.lessThanEqual=H.prototype.lte;function G(J){this.query=J;this.expr=J.expr}var C={radians:"$maxDistance",km:"$maxDistanceInKilometers",miles:"$maxDistanceInMiles"};var F={radians:"radius",km:"radiusInKilometers",miles:"radiusInMiles"};G.prototype={build:function(){var J=this.query;if(J.filter||J.fields||J.sort||J.toskip||J.totake||J.expandExpression){return{$where:J.filter||null,$select:J.fields||null,$sort:J.sort||null,$skip:J.toskip||null,$take:J.totake||null,$expand:J.expandExpression||null}}return{$where:this._buildWhere(),$select:this._buildSelect(),$sort:this._buildSort(),$skip:this._getSkip(),$take:this._getTake(),$expand:this._getExpand()}},_getSkip:function(){var J=z.find(this.expr.operands,function(M,K,L){return M.operator===I.skip});return J?J.operands[0]:null},_getTake:function(){var J=z.find(this.expr.operands,function(M,K,L){return M.operator===I.take});return J?J.operands[0]:null},_getExpand:function(){var J=z.find(this.expr.operands,function(M,K,L){return M.operator===I.expand});return J?J.operands[0]:null},_buildSelect:function(){var K=z.find(this.expr.operands,function(N,L,M){return N.operator===I.select});var J={};if(K){z.reduce(K.operands,function(L,M){L[M]=1;return L},J);return J}else{return null}},_buildSort:function(){var K=z.filter(this.expr.operands,function(N,L,M){return N.operator===I.order||N.operator===I.order_desc});var J={};if(K.length>0){z.reduce(K,function(L,M){L[M.operands[0]]=M.operator===I.order?1:-1;return L},J);return J}else{return null}},_buildWhere:function(){var J=z.find(this.expr.operands,function(N,L,M){return N.operator===I.where});if(J){return this._build(new E(I.and,J.operands))}else{var K=z.find(this.expr.operands,function(N,L,M){return N.operator===I.filter});if(K){return K.operands[0]}return null}},_build:function(J){if(this._isSimple(J)){return this._simple(J)}else{if(this._isRegex(J)){return this._regex(J)}else{if(this._isGeo(J)){return this._geo(J)}else{if(this._isAnd(J)){return this._and(J)}else{if(this._isOr(J)){return this._or(J)}else{if(this._isNot(J)){return this._not(J)}}}}}}},_isSimple:function(J){return J.operator>=I.equal&&J.operator<=I.size},_simple:function(N){var M={},J={};var L=N.operands;var K=this._translateoperator(N.operator);if(K){M[K]=L[1]}else{M=L[1]}J[L[0]]=M;return J},_isRegex:function(J){return J.operator>=I.regex&&J.operator<=I.endsWith},_regex:function(N){var J={};var M=this._getRegex(N);var K=this._getRegexValue(M);var L=N.operands;J[L[0]]=K;return J},_getRegex:function(L){var K=L.operands[1];var J=L.operands[2]?L.operands[2]:"";switch(L.operator){case I.regex:return K instanceof RegExp?K:new RegExp(K,J);case I.startsWith:return new RegExp("^"+K,J);case I.endsWith:return new RegExp(K+"$",J);default:throw new Error("Unknown operator type.")}},_getRegexValue:function(K){var J="";if(K.global){J+="g"}if(K.multiline){J+="m"}if(K.ignoreCase){J+="i"}return{$regex:K.source,$options:J}},_isGeo:function(J){return J.operator>=I.nearShpere&&J.operator<=I.withinShpere},_geo:function(L){var J={};var K=L.operands;J[K[0]]=this._getGeoTerm(L);return J},_getGeoTerm:function(J){switch(J.operator){case I.nearShpere:return this._getNearSphereTerm(J);case I.withinBox:return this._getWithinBox(J);case I.withinPolygon:return this._getWithinPolygon(J);case I.withinShpere:return this._getWithinCenterSphere(J);default:throw new Error("Unknown operator type.")}},_getNearSphereTerm:function(P){var L=P.operands;var J=this._getGeoPoint(L[1]);var O=L[2];var N=L[3];var K;var M={"$nearSphere":J};if(typeof O!=="undefined"){K=C[N]||C.radians;M[K]=O}return M},_getWithinBox:function(M){var K=M.operands;var J=this._getGeoPoint(K[1]);var L=this._getGeoPoint(K[2]);return{"$within":{"$box":[J,L]}}},_getWithinPolygon:function(L){var J=L.operands;var K=this._getGeoPoints(J[1]);return{"$within":{"$polygon":K}}},_getWithinCenterSphere:function(P){var N=P.operands;var K=this._getGeoPoint(N[1]);var J=N[2];var O=N[3];var L=F[O]||F.radians;var M={center:K};M[L]=J;return{"$within":{"$centerSphere":M}}},_getGeoPoint:function(J){if(z.isArray(J)){return new l(J[0],J[1])}return J},_getGeoPoints:function(K){var J=this;return z.map(K,function(L){return J._getGeoPoint(L)})},_isAnd:function(J){return J.operator===I.and},_and:function(O){var N,K,M,J={};var L=O.operands;for(N=0,K=L.length;N<K;N++){M=this._build(L[N]);J=this._andAppend(J,M)}return J},_andAppend:function(N,K){var M,J,L,P,Q;var O=z.keys(K);for(M=0,J=O.length;M<J;M++){L=O[M];P=N[L];if(typeof P==="undefined"){N[L]=K[L]}else{Q=K[L];if(typeof P==="object"&&typeof Q==="object"){P=z.extend(P,Q)}else{P=Q}N[L]=P}}return N},_isOr:function(J){return J.operator===I.or},_or:function(O){var N,K,M,J=[];var L=O.operands;for(N=0,K=L.length;N<K;N++){M=this._build(L[N]);J.push(M)}return{$or:J}},_isNot:function(J){return J.operator===I.not},_not:function(J){return{$not:this._build(J.operands[0])}},_translateoperator:function(J){switch(J){case I.equal:return null;case I.not_equal:return"$ne";case I.gt:return"$gt";case I.lt:return"$lt";case I.gte:return"$gte";case I.lte:return"$lte";case I.isin:return"$in";case I.notin:return"$nin";case I.all:return"$all";case I.size:return"$size"}throw new Error("Unknown operator type.")}};r.Query=D;r.QueryBuilder=G}());var u=(function(){var N={filter:"X-Everlive-Filter",select:"X-Everlive-Fields",sort:"X-Everlive-Sort",skip:"X-Everlive-Skip",take:"X-Everlive-Take",expand:"X-Everlive-Expand"};var J=null;function D(P,Q){a(P,"setup");a(Q,"options");this.setup=P;this.method=null;this.endpoint=null;this.data=null;this.headers={};this.success=null;this.error=null;this.parse=D.parsers.simple;z.extend(this,Q);this._init(Q);J=this}D.prototype={send:function(){r.sendRequest(this)},buildAuthHeader:q,buildUrl:function L(P){return r.buildUrl(P)},buildQueryHeaders:function G(P){if(P){if(P instanceof r.Query){return D.prototype._buildQueryHeaders(P)}else{return D.prototype._buildFilterHeader(P)}}else{return{}}},_init:function(P){z.extend(this.headers,this.buildAuthHeader(this.setup,P),this.buildQueryHeaders(P.filter),P.headers)},_buildQueryHeaders:function(P){P=P.build();var Q={};if(P.$where!==null){Q[N.filter]=JSON.stringify(P.$where)}if(P.$select!==null){Q[N.select]=JSON.stringify(P.$select)}if(P.$sort!==null){Q[N.sort]=JSON.stringify(P.$sort)}if(P.$skip!==null){Q[N.skip]=P.$skip}if(P.$take!==null){Q[N.take]=P.$take}if(P.$expand!==null){Q[N.expand]=JSON.stringify(P.$expand)}return Q},_buildFilterHeader:function(P){var Q={};Q[N.filter]=JSON.stringify(P);return Q}};r.Request=D;r.prototype.request=function(P){return new D(this.setup,P)};function O(T){if(J&&J.setup&&J.setup.parseOnlyCompleteDateTimeObjects){if(/^\d{4}-\d{2}-\d{2}$/.test(T)){return null}if(/^(\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|((\+|-)(\d{2}):(\d{2})))?$/.test(T)){return null}}var S;if(S=T.match(/^(\d{4})(-(\d{2})(-(\d{2})(T(\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|((\+|-)(\d{2}):(\d{2}))))?))$/)){var Q=S[12];if(Q){if(Q.length>3){Q=Math.round(Number(Q.substr(0,3)+"."+Q.substr(3)))}else{if(Q.length<3){Q+=Q.length===2?"0":"00"}}}var R=new Date(Date.UTC(Number(S[1]),(Number(S[3])-1)||0,Number(S[5])||0,Number(S[7])||0,Number(S[8])||0,Number(S[10])||0,Number(Q)||0));if(S[13]&&S[13]!=="Z"){var U=Number(S[16])||0,P=Number(S[17])||0;U*=3600000;P*=60000;var V=U+P;if(S[15]==="+"){V=-V}R=new Date(R.valueOf()+V)}return R}else{return null}}function K(Q,R){if(typeof R==="string"){var P=O(R);if(P){R=P}}return R}function H(T,Q){var P,R,S;for(P in T){if(T.hasOwnProperty(P)){R=T[P];S=Q(P,R);T[P]=S;if(R===S&&typeof R==="object"){H(R,Q)}}}}function C(P){H(P,K)}r._traverseAndRevive=C;function E(P){if(typeof P==="string"&&P.length>0){P=JSON.parse(P,K)}else{if(typeof P==="object"){C(P)}}if(P){return{result:P.Result,count:P.Count}}else{return P}}function F(P){if(typeof P==="string"&&P.length>0){try{P=JSON.parse(P);return{message:P.message,code:P.errorCode}}catch(Q){return P}}else{return P}}function M(P){if(typeof P==="string"&&P.length>0){P=JSON.parse(P,K)}else{if(typeof P==="object"){C(P)}}if(P){return{result:P.Result}}else{return P}}function I(P){if(typeof P==="string"&&P.length>0){P=JSON.parse(P,K)}else{if(typeof P==="object"){C(P)}}if(P){return{result:P.Result,ModifiedAt:P.ModifiedAt}}else{return P}}D.parsers={simple:{result:E,error:F},single:{result:M,error:F},update:{result:I,error:F}};r.disableRequestCache=function(P,S){if(S==="GET"){var Q=(new Date()).getTime();var R=P.indexOf("?")>-1?"&":"?";P+=R+"_el="+Q}return P};if(typeof r.sendRequest==="undefined"){r.sendRequest=function(Q){var P=Q.buildUrl(Q.setup)+Q.endpoint;P=r.disableRequestCache(P,Q.method);var R=Q.method==="GET"?Q.data:JSON.stringify(Q.data);k({url:P,method:Q.method,data:R,headers:Q.headers,type:"json",contentType:"application/json",crossOrigin:true,success:function(T,U,S){Q.success.call(Q,Q.parse.result(T))},error:function(S,U,T){Q.error.call(Q,Q.parse.error(S.responseText))}})}}return D}());r.getCallbacks=function(E,C){var D;if(typeof E!=="function"&&typeof C!=="function"){D=new i.Promise(function(G,F){E=function(H){G(H)};C=function(H){F(H)}})}return{promise:D,success:E,error:C}};function t(C,F,D){var E=r.getCallbacks(F,D);C(E.success,E.error);return E.promise}function y(C,D){return function(G,E){var F=G.result;if(z.isArray(C)||typeof C.length==="number"){z.each(C,function(I,H){z.extend(I,F[H])})}else{z.extend(C,F)}D(G,E)}}function j(C,D){return function(F){var E=F.ModifiedAt;C.ModifiedAt=E;D(F)}}function d(C,D){this.setup=C;this.collectionName=D;this.options=null}d.prototype={withHeaders:function(D){var C=this.options||{};C.headers=z.extend(C.headers||{},D);this.options=C;return this},expand:function(D){var C={"X-Everlive-Expand":JSON.stringify(D)};return this.withHeaders(C)},_createRequest:function(C){z.extend(C,this.options);this.options=null;return new u(this.setup,C)},get:function(E,F,D){var C=this;return t(function(I,G){var H=C._createRequest({method:"GET",endpoint:C.collectionName,filter:E,success:I,error:G});H.send()},F,D)},getById:function(F,E,D){var C=this;return t(function(I,G){var H=C._createRequest({method:"GET",endpoint:C.collectionName+"/"+F,parse:u.parsers.single,success:I,error:G});H.send()},E,D)},count:function(E,F,D){var C=this;return t(function(I,G){var H=C._createRequest({method:"GET",endpoint:C.collectionName+"/_count",filter:E,parse:u.parsers.single,success:I,error:G});H.send()},F,D)},create:function(E,F,D){var C=this;return t(function(I,G){var H=C._createRequest({method:"POST",endpoint:C.collectionName,data:E,parse:u.parsers.single,success:y(E,I),error:G});H.send()},F,D)},rawUpdate:function(E,F,G,D){var C=this;return t(function(L,I){var K=C.collectionName;var H=null;if(typeof F==="string"){K+="/"+F}else{if(typeof F==="object"){H=F}}var J=C._createRequest({method:"PUT",endpoint:K,data:E,filter:H,success:L,error:I});J.send()},G,D)},_update:function(E,G,I,F,H,D){var C=this;return t(function(O,J){var N=C.collectionName;var L=O;if(I){N+="/"+E[g];L=j(E,O)}var M={};M[F?"$replace":"$set"]=E;var K=C._createRequest({method:"PUT",endpoint:N,parse:u.parsers.update,data:M,filter:G,success:L,error:J});K.send()},H,D)},updateSingle:function(D,E,C){return this._update(D,null,true,false,E,C)},update:function(D,E,F,C){return this._update(D,E,false,false,F,C)},_destroy:function(E,F,H,G,D){var C=this;return t(function(L,I){var K=C.collectionName;if(H){K+="/"+E[g]}var J=C._createRequest({method:"DELETE",endpoint:K,filter:F,success:L,error:I});J.send()},G,D)},destroySingle:function(D,E,C){return this._destroy(D,null,true,E,C)},destroy:function(D,E,C){return this._destroy(null,D,false,E,C)},setAcl:function(G,E,F,D){var C=this;return t(function(L,H){var K=C.collectionName;if(typeof E==="string"){K+="/"+E}else{if(typeof E==="object"){K+="/"+E[g]}}K+="/_acl";var M,J;if(G===null){M="DELETE"}else{M="PUT";J=G}var I=C._createRequest({method:M,endpoint:K,data:J,success:L,error:H});I.send()},F,D)},setOwner:function(C,F,G,E){var D=this;return t(function(K,H){var J=D.collectionName;if(typeof F==="string"){J+="/"+F}else{if(typeof F==="object"){J+="/"+F[g]}}J+="/_owner";var I=D._createRequest({method:"PUT",endpoint:J,data:{Owner:C},success:K,error:H});I.send()},G,E)},save:function(F,G,E){var D=this;var C=this.isNew(F);return t(function(K,H){function J(L){L.type=C?"create":"update";K(L)}function I(L){L.type=C?"create":"update";H(L)}if(C){return D.create(F,J,I)}else{return D.updateSingle(F,J,I)}},G,E)},isNew:function(C){return typeof C[g]==="undefined"}};r.Data=d;function l(C,D){this.longitude=C||0;this.latitude=D||0}r.GeoPoint=l;var e={unauthenticated:"unauthenticated",masterKey:"masterKey",invalidAuthentication:"invalidAuthentication",authenticated:"authenticated"};r.AuthStatus=e;function h(C,F,H,E){if(C.masterKey){return t(function(J,I){J({status:e.masterKey})},H,E)}if(!C.token){return t(function(J,I){J({status:e.unauthenticated})},H,E)}var D;if(H){D=function(I){if(I&&I.code===601){H({status:e.invalidAuthentication})}else{E(I)}}}var G=F(H,D);if(G){G=G.then(function(I){return{status:e.authenticated,user:I.result}},function(I){if(I&&I.code===601){return{status:e.invalidAuthentication}}else{throw I}})}return G}r.prototype.authInfo=function(D,C){return h(this.setup,z.bind(this.Users.getById,this.Users,"me"),D,C)};var c=function(C){C._loginSuccess=function(F){var E=F.result;var D=this.setup;D.token=E.access_token;D.tokenType=E.token_type};C._logoutSuccess=function(){var D=this.setup;D.token=null;D.tokenType=null};C.register=function(I,G,F,H,E){a(I,"username");a(G,"password");var D={Username:I,Password:G};z.extend(D,F);return this.create(D,H,E)};C.login=function(H,F,G,E){var D=this;return t(function(K,I){var J=new u(D.setup,{method:"POST",endpoint:"oauth/token",data:{username:H,password:F,grant_type:"password"},authHeaders:false,parse:u.parsers.single,success:function(){D._loginSuccess.apply(D,arguments);K.apply(null,arguments)},error:I});J.send()},G,E)};C.currentUser=function(F,E){var D=this;return t(function(H,G){h(D.setup,z.bind(D.getById,D,"me")).then(function(I){if(typeof I.user!=="undefined"){H({result:I.user})}else{H({result:null})}},function(I){G(I)})},F,E)};C.changePassword=function(J,F,I,G,H,E){var D=this;return t(function(N,K){var M="Users/changepassword";if(G){M+="?keepTokens=true"}var L=new u(D.setup,{method:"POST",endpoint:M,data:{Username:J,Password:F,NewPassword:I},authHeaders:false,parse:u.parsers.single,success:N,error:K});L.send()},H,E)};C.logout=function(F,E){var D=this;return t(function(I,G){var H=new u(D.setup,{method:"GET",endpoint:"oauth/logout",success:function(){D._logoutSuccess.apply(D,arguments);I.apply(null,arguments)},error:G});H.send()},F,E)};C._loginWithProvider=function(F,H,G){var E={Identity:F};var D=this;return t(function(K,I){var J=new u(D.setup,{method:"POST",endpoint:"Users",data:E,authHeaders:false,parse:u.parsers.single,success:function(){D._loginSuccess.apply(D,arguments);K.apply(null,arguments)},error:I});J.send()},H,G)};C._linkWithProvider=function(E,G,H,F){var D=this;return t(function(K,I){var J=new u(D.setup,{method:"POST",endpoint:"Users/"+G+"/link",data:E,parse:u.parsers.single,success:K,error:I});J.send()},H,F)};C._unlinkFromProvider=function(H,G,I,F){var E={Provider:H};var D=this;return t(function(L,J){var K=new u(D.setup,{method:"POST",endpoint:"Users/"+G+"/unlink",data:E,parse:u.parsers.single,success:L,error:J});K.send()},I,F)};C.loginWithFacebook=function(F,G,E){var D={Provider:"Facebook",Token:F};return C._loginWithProvider(D,G,E)};C.linkWithFacebook=function(G,F,H,E){var D={Provider:"Facebook",Token:F};return C._linkWithProvider(D,G,H,E)};C.unlinkFromFacebook=function(E,F,D){return C._unlinkFromProvider("Facebook",E,F,D)};C.loginWithADFS=function(F,G,E){var D={Provider:"ADFS",Token:F};return C._loginWithProvider(D,G,E)};C.linkWithADFS=function(G,F,H,E){var D={Provider:"ADFS",Token:F};return C._linkWithProvider(D,G,H,E)};C.unlinkFromADFS=function(E,F,D){return C._unlinkFromProvider("ADFS",E,F,D)};C.loginWithLiveID=function(F,G,E){var D={Provider:"LiveID",Token:F};return C._loginWithProvider(D,G,E)};C.linkWithLiveID=function(G,F,H,E){var D={Provider:"LiveID",Token:F};return C._linkWithProvider(D,G,H,E)};C.unlinkFromLiveID=function(E,F,D){return C._unlinkFromProvider("LiveID",E,F,D)};C.loginWithGoogle=function(F,G,E){var D={Provider:"Google",Token:F};return C._loginWithProvider(D,G,E)};C.linkWithGoogle=function(G,F,H,E){var D={Provider:"Google",Token:F};return C._linkWithProvider(D,G,H,E)};C.unlinkFromGoogle=function(E,F,D){return C._unlinkFromProvider("Google",E,F,D)};C.loginWithTwitter=function(F,G,H,E){var D={Provider:"Twitter",Token:F,TokenSecret:G};return C._loginWithProvider(D,H,E)};C.linkWithTwitter=function(G,F,H,I,E){var D={Provider:"Twitter",Token:F,TokenSecret:H};return C._linkWithProvider(D,G,I,E)};C.unlinkFromTwitter=function(E,F,D){return C._unlinkFromProvider("Twitter",E,F,D)}};var n=function(C){C.getUploadUrl=function(){return r.buildUrl(this.setup)+this.collectionName};C.getDownloadUrl=function(D){return r.buildUrl(this.setup)+this.collectionName+"/"+D+"/Download"};C._getUpdateUrl=function(D){return this.collectionName+"/"+D+"/Content"};C.getUpdateUrl=function(D){return r.buildUrl(this.setup)+this._getUpdateUrl(D)};C.updateContent=function(D,G,H,F){var E=this;return t(function(L,I){var K=E._getUpdateUrl(D);var J=E._createRequest({method:"PUT",endpoint:K,data:G,success:L,error:I});J.send()},H,F)};C.getDownloadUrlById=function(D,G,F){var E=this;return t(function(J,H){var I=E._createRequest({method:"GET",endpoint:E.collectionName+"/"+D,parse:u.parsers.single,success:function(K){J(K.result.Uri)},error:H});I.send()},G,F)}};var A={WindowsPhone:1,Windows:2,Android:3,iOS:4,OSX:5,Blackberry:6,Nokia:7,Unknown:100};r.PushCallbacks={};var m=function(C){this._el=C;this._currentDevice;this.notifications=C.data("Push/Notifications");this.devices=C.data("Push/Devices")};m.prototype={currentDevice:function(C){if(!window.cordova){throw new Error("Error: currentDevice() can only be called from within a hybrid mobile app, after 'deviceready' event has been fired.")}if(!this._currentDevice){this._currentDevice=new b(this);this._currentDevice.emulatorMode=C}return this._currentDevice}};var o={iOS:{badge:true,sound:true,alert:true},android:{senderID:null},notificationCallbackAndroid:null,notificationCallbackIOS:null};var b=function(C){this._pushHandler=C;this._initSuccessCallback=null;this._initErrorCallback=null;this._globalFunctionSuffix=null;this.pushSettings=null;this.pushToken=null;this.isInitialized=false;this.isInitializing=false;this.emulatorMode=false};b.prototype={enableNotifications:function(C,E,D){this.pushSettings=C;return t(z.bind(this._initialize,this),E,D)},disableNotifications:function(E,D){var C=this;return this.unregister().then(function(){return t(function(H,G){if(C.emulatorMode){H()}else{var F=window.plugins.pushNotification;F.unregister(function(){C.isInitialized=false;H()},G)}},E,D)},D)},getRegistration:function(E,C){var D=this._getDeviceId();return this._pushHandler.devices.getById("HardwareId/"+D,E,C)},register:function(D,G,E){var C=this;var F={};if(D!==undefined){F.Parameters=D}return this._populateRegistrationObject(F).then(function(){return C._pushHandler.devices.create(F,G,E)},E)},unregister:function(E,C){var D=device.uuid;return this._pushHandler.devices.destroySingle({Id:"HardwareId/"+D},E,C)},updateRegistration:function(D,G,E){var C=this;var F={};if(D!==undefined){F.Parameters=D}return this._populateRegistrationObject(F).then(function(){F.Id="HardwareId/"+F.HardwareId;return C._pushHandler.devices.updateSingle(F,G,E)},E)},_initialize:function(N,L){var P=this;if(this.isInitializing){L(new Error("Push notifications are currently initializing."));return}if(!this.emulatorMode&&(!window.plugins||!window.plugins.pushNotification)){L(new Error("The push notifications plugin is not initialized."));return}if(!this.emulatorMode&&(!window.navigator||!window.navigator.globalization)){L(new Error("The globalization plugin is not initialized."));return}this._initSuccessCallback=N;this._initErrorCallback=L;if(this.isInitialized){this._deviceRegistrationSuccess(this.pushToken);return}if(this.emulatorMode){setTimeout(function(){P._deviceRegistrationSuccess("fake_push_token")},1000);return}this.isInitializing=true;var O=this._globalFunctionSuffix;if(!O){O=Date.now().toString();this._globalFunctionSuffix=O}var D=window.plugins.pushNotification;var G=this._getPlatformType(device.platform);if(G===A.iOS){var I="apnCallback_"+O;r.PushCallbacks[I]=z.bind(this._onNotificationAPN,this);var K=this.pushSettings.iOS;this._validateIOSSettings(K);K.ecb="Everlive.PushCallbacks."+I;D.register(z.bind(this._successfulRegistrationAPN,this),z.bind(this._failedRegistrationAPN,this),K)}else{if(G===A.Android){var C="gcmCallback_"+O;r.PushCallbacks[C]=z.bind(this._onNotificationGCM,this);var F=this.pushSettings.android;this._validateAndroidSettings(F);F.ecb="Everlive.PushCallbacks."+C;D.register(z.bind(this._successSentRegistrationGCM,this),z.bind(this._errorSentRegistrationGCM,this),F)}else{if(G===A.WindowsPhone){var H="wp8Callback_"+O;var M="wp8RegistrationSuccessCallback_"+O;var E="wp8RegistrationErrorCallback_"+O;r.PushCallbacks[H]=z.bind(this._onNotificationWP8,this);r.PushCallbacks[M]=z.bind(this._deviceRegistrationSuccessWP,this);r.PushCallbacks[E]=z.bind(this._deviceRegistrationFailed,this);var J=this.pushSettings.wp8;this._validateWP8Settings(J);J.ecb="Everlive.PushCallbacks."+H;J.uccb="Everlive.PushCallbacks."+M;J.errcb="Everlive.PushCallbacks."+E;D.register(z.bind(this._successSentRegistrationWP8,this),z.bind(this._errorSentRegistrationWP8,this),J)}else{throw new Error("The current platform is not supported: "+device.platform)}}}},_deviceRegistrationSuccessWP:function(C){this._deviceRegistrationSuccess(C.uri)},_validateAndroidSettings:function(C){if(!C.senderID){throw new Error("Sender ID (project number) is not set in the android settings.")}},_validateWP8Settings:function(C){if(!C.channelName){throw new Error("channelName is not set in the WP8 settings.")}},_validateIOSSettings:function(C){},_populateRegistrationObject:function(E,F,D){var C=this;return t(function(H,G){if(!C.pushToken){throw new Error("Push token is not available.")}C._getLocaleName(function(I){var O=C._getDeviceId();var M=device.name;var K=C._getPlatformType(device.platform);var L=f.determine().name();var J=C.pushToken;var P=I.value;var N=device.version;E.HardwareId=O;E.HardwareModel=M;E.PlatformType=K;E.PlatformVersion=N;E.TimeZone=L;E.PushToken=J;E.Locale=P;H()},G)},F,D)},_getLocaleName:function(D,C){if(this.emulatorMode){D({value:"en_US"})}else{navigator.globalization.getLocaleName(function(E){D(E)},C);navigator.globalization.getLocaleName(function(E){},C)}},_getDeviceId:function(){return device.uuid},_getPlatformType:function(D){var C=D.toLowerCase();switch(C){case"ios":case"iphone":case"ipad":return A.iOS;case"android":return A.Android;case"wince":return A.WindowsPhone;case"win32nt":return A.WindowsPhone;default:return A.Unknown}},_deviceRegistrationFailed:function(C){this.pushToken=null;this.isInitializing=false;this.isInitialized=false;if(this._initErrorCallback){this._initErrorCallback({error:C})}},_deviceRegistrationSuccess:function(C){this.pushToken=C;this.isInitializing=false;this.isInitialized=true;if(this._initSuccessCallback){this._initSuccessCallback({token:C})}},_successfulRegistrationAPN:function(C){this._deviceRegistrationSuccess(C)},_failedRegistrationAPN:function(C){this._deviceRegistrationFailed(C)},_successSentRegistrationGCM:function(C){},_successSentRegistrationWP8:function(C){},_errorSentRegistrationWP8:function(C){this._deviceRegistrationFailed(C)},_errorSentRegistrationGCM:function(C){this._deviceRegistrationFailed(C)},_onNotificationAPN:function(C){this._raiseNotificationEventIOS(C)},_onNotificationWP8:function(C){this._raiseNotificationEventWP8(C)},_onNotificationGCM:function w(C){switch(C.event){case"registered":if(C.regid.length>0){this._deviceRegistrationSuccess(C.regid)}break;case"message":this._raiseNotificationEventAndroid(C);break;case"error":if(!this.pushToken){this._deviceRegistrationFailed(C)}else{this._raiseNotificationEventAndroid(C)}break;default:this._raiseNotificationEventAndroid(C);break}},_raiseNotificationEventAndroid:function(C){if(this.pushSettings.notificationCallbackAndroid){this.pushSettings.notificationCallbackAndroid(C)}},_raiseNotificationEventIOS:function(C){if(this.pushSettings.notificationCallbackIOS){this.pushSettings.notificationCallbackIOS(C)}},_raiseNotificationEventWP8:function(C){if(this.pushSettings.notificationCallbackWP8){this.pushSettings.notificationCallbackWP8(C)}}};var x=function(){this.Users=this.data("Users");c(this.Users);this.Files=this.data("Files");n(this.Files);this.push=new m(this)};s.push({name:"default",func:x});return r}));
(function(a,b){if(typeof define==="function"&&define.amd){define(["Everlive"],function(c){b(c)})}else{b(a.Everlive)}}(this,function(n){var h=window.jQuery,j=window.kendo;if(h===undefined||j===undefined){return}var i=h.extend;i(true,j.data,{schemas:{everlive:{type:"json",data:function(o){if(typeof o.ModifiedAt!=="undefined"){return{ModifiedAt:o.ModifiedAt}}else{return o.Result||o}},total:"Count",model:{id:"Id"}}},transports:{everlive:{read:{dataType:"json",type:"GET",cache:false},update:{dataType:"json",contentType:"application/json",type:"PUT",cache:false},create:{dataType:"json",contentType:"application/json",type:"POST",cache:false},destroy:{dataType:"json",type:"DELETE",cache:false},parameterMap:function(p,o){if(o==="destroy"){return{}}if(o==="create"||o==="update"){return JSON.stringify(p)}if(o==="read"){return null}}}}});function l(s){var o={};if(s){if(s.skip){o.$skip=s.skip;delete s.skip}if(s.take){o.$take=s.take;delete s.take}if(s.sort){var r=s.sort;var p={};if(!h.isArray(r)){r=[r]}h.each(r,function(t,u){p[u.field]=u.dir==="asc"?1:-1});o.$sort=p;delete s.sort}if(s.filter){var q=new k().build(s.filter);o.$where=q;delete s.filter}}return o}var m=["startswith","startsWith","endswith","endsWith","contains"];function k(){}k.prototype={build:function(o){return this._build(o)},_build:function(o){if(this._isRaw(o)){return this._raw(o)}else{if(this._isSimple(o)){return this._simple(o)}else{if(this._isRegex(o)){return this._regex(o)}else{if(this._isAnd(o)){return this._and(o)}else{if(this._isOr(o)){return this._or(o)}}}}}},_isRaw:function(o){return o.operator==="_raw"},_raw:function(p){var o={};o[p.field]=p.value;return o},_isSimple:function(o){return typeof o.logic==="undefined"&&!this._isRegex(o)},_simple:function(r){var q={},o={};var p=this._translateoperator(r.operator);if(p){q[p]=r.value}else{q=r.value}o[r.field]=q;return o},_isRegex:function(o){return h.inArray(o.operator,m)!==-1},_regex:function(q){var o={};var r=this._getRegex(q);var p=this._getRegexValue(r);o[q.field]=p;return o},_getRegex:function(p){var q=p.value;var o=p.operator;switch(o){case"contains":return new RegExp(".*"+q+".*","i");case"startsWith":case"startswith":return new RegExp("^"+q,"i");case"endsWith":case"endswith":return new RegExp(q+"$","i")}throw new Error("Unknown operator type.")},_getRegexValue:function(o){return n.QueryBuilder.prototype._getRegexValue.call(this,o)},_isAnd:function(o){return o.logic==="and"},_and:function(t){var s,p,r,o={};var q=t.filters;for(s=0,p=q.length;s<p;s++){r=this._build(q[s]);o=this._andAppend(o,r)}return o},_andAppend:function(p,o){return n.QueryBuilder.prototype._andAppend.call(this,p,o)},_isOr:function(o){return o.logic==="or"},_or:function(t){var s,p,r,o=[];var q=t.filters;for(s=0,p=q.length;s<p;s++){r=this._build(q[s]);o.push(r)}return{$or:o}},_translateoperator:function(o){switch(o){case"eq":return null;case"neq":return"$ne";case"gt":return"$gt";case"lt":return"$lt";case"gte":return"$gte";case"lte":return"$lte"}throw new Error("Unknown operator type.")}};function b(o){return new n.Query(o.$where,null,o.$sort,o.$skip,o.$take)}var g=j.data.RemoteTransport.prototype.setup;j.data.RemoteTransport.prototype.setup=function(p,q){if(!p.url&&!this.options[q].url&&this.options.typeName){if(!n.$){throw new Error("You should either specify a url for this transport method, or instantiate an Everlive instance.")}p.url=n.Request.prototype.buildUrl(n.$.setup)+this.options.typeName;if(q==="update"||q==="destroy"){p.url+="/"+p.data[n.idField]}}if(n.$){p.headers=n.Request.prototype.buildAuthHeader(n.$.setup)}if(q==="read"&&p.data){var r=l(p.data);var o=b(r);p.headers=h.extend(p.headers,n.Request.prototype.buildQueryHeaders(o))}if(q==="create"||q==="read"||q==="update"){var s=p.success;p.success=function(t){n._traverseAndRevive(t);if(s){s(t)}}}return g.call(this,p,q)};var d=[n.idField,"CreatedAt"];var c=j.data.Model.prototype.accept;j.data.Model.prototype.accept=function(q){var o=this,r,p;n._traverseAndRevive(q);if(q&&o.isNew()&&q[n.idField]){for(r in o.fields){if(h.inArray(r,d)===-1){p=o.get(r);q[r]=p}}}else{if(q&&typeof q.ModifiedAt!=="undefined"){for(r in o.fields){if(r!=="ModifiedAt"){p=o.get(r);q[r]=p}}}}c.call(this,q)};var e=function(p,t){var r=f(t[t.length-1]);var q=t.slice(0,t.length-1);var s="/_expand";for(var o=0;o<q.length;o++){s+="/"+f(q[o])}return(function(v,u){return function(x){var w=p+"";if(x.Id&&u){w+=v+"/"+x.Id+"/"+u}return w}}(s,r))};var a=function(o){if(typeof o==="string"){return{}}else{return{"X-Everlive-Filter":JSON.stringify(o.filter),"X-Everlive-Sort":JSON.stringify(o.sort),"X-Everlive-Single-Field":o.singleField,"X-Everlive-Skip":o.skip,"X-Everlive-Take":o.take,"X-Everlive-Fields":JSON.stringify(o.fields)}}};var f=function(o){if(typeof o==="string"){return o}else{if(o.relation){return o.relation}else{throw new Error("You need to specify a 'relation' for an expand node when using the object notation")}}};n.createHierarchicalDataSource=function(p){p=p||{};var r=p.expand;var o=p.typeName;delete p.expand;delete p.typeName;var s;if(p.url){s=p.url}else{if(n.$&&o){s=n.Request.prototype.buildUrl(n.$.setup)+o}else{if(!n.$){throw new Error("You need to instantiate an Everlive instance in order to create a kendo HierarchicalDataSource.")}if(!o){throw new Error("You need to specify a 'typeName' in order to create a kendo HierarchicalDataSource.")}}}var u;if(r){for(var q=r.length-1;q>=0;q--){var u={model:{hasChildren:f(r[q]),children:{type:"everlive",transport:{read:{url:e(s,r.slice(0,q+1)),headers:a(r[q])}},schema:u}}}}}var t={};t.type="everlive";t.transport={typeName:o},t.schema=u;i(true,t,p);return new j.data.HierarchicalDataSource(t)};n.createDataSource=function(p){p=p||{};var o=p.typeName;if(!o){throw new Error("You need to specify a 'typeName' in order to create a kendo DataSource.")}delete p.typeName;var q={};q.type="everlive";q.transport={typeName:o},i(true,q,p);return new j.data.DataSource(q)}}));