(function(){ function n(){return function(){}} window.JSON&&window.JSON.stringify||function(){function a(a){b.lastIndex=0;return b.test(a)?'"'+a.replace(b,function(a){var b=j[a];return"string"===typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function c(b,j){var h,l,i,g,p=d,k,f=j[b];f&&("object"===typeof f&&"function"===typeof f.toJSON)&&(f=f.toJSON(b));"function"===typeof m&&(f=m.call(j,b,f));switch(typeof f){case "string":return a(f);case "number":return isFinite(f)?String(f):"null";case "boolean":case "null":return String(f); case "object":if(!f)return"null";d+=e;k=[];if("[object Array]"===Object.prototype.toString.apply(f)){g=f.length;for(h=0;hr()?(clearTimeout(d),d=setTimeout(b,c)):(e=r(),a())}var d,e=0;return b},s=function(a){return document.getElementById(a)},t=function(a){console.error(a)},w=function(a,c){var b=[];u(a.split(/\s+/),function(a){u((c||document).getElementsByTagName(a),function(a){b.push(a)})});return b},u=function(a,c){if(a&&c)if("undefined"!=typeof a[0])for(var b=0,d=a.length;b"-_.!~*'()".indexOf(a)?a:"%"+a.charCodeAt(0).toString(16).toUpperCase()}).join("")},O=function(a){function c(a,b){D||(D=1,a||ma(b),f.onerror=null,clearTimeout(na),setTimeout(function(){a&&oa();var b=s(v),D=b&&b.parentNode;D&&D.removeChild(b)},K))}if(G||H()){a:{var b,d,e=function(){if(!m){m=1;clearTimeout(z);try{d=JSON.parse(b.responseText)}catch(a){return i(1)}l(d)}},j=0,m=0,y=a.timeout||L,z=setTimeout(function(){i(1)},y),h=a.b||n(),l=a.c||n(),i=function(a){j||(j=1,clearTimeout(z), b&&(b.onerror=b.onload=null,b.abort&&b.abort(),b=null),a&&h())};try{b=H()||window.XDomainRequest&&new XDomainRequest||new XMLHttpRequest;b.onerror=b.onabort=function(){i(1)};b.onload=b.onloadend=e;b.timeout=y;var g=a.url.join(M);if(a.data){var e=[],p,g=g+"?";for(p in a.data)e.push(p+"="+a.data[p]);g+=e.join(N)}b.open("GET",g,typeof("undefined"===a.g));b.send()}catch(k){i(0);G=0;a=O(a);break a}a=i}return a}var f=F("script"),g=a.a,v=q(),D=0,na=setTimeout(function(){c(1)},a.timeout||L),oa=a.b||n(),ma= a.c||n();window[g]=function(a){c(0,a)};a.g||(f[Q]=Q);f.onerror=function(){c(1)};f.src=a.url.join(M);if(a.data){g=[];f.src+="?";for(key in a.data)g.push(key+"="+a.data[key]);f.src+=g.join(N)}C(f,"id",v);B().appendChild(f);return c},R=function(a){var c=[];u(a,function(a,d){d.f&&c.push(a)});return c.sort()},T=function(){PUBNUB.time(r);PUBNUB.time(function(){setTimeout(function(){S||(S=1,u(ha,function(a){a()}))},K)})},H=function(){if(!ia.get)return 0;var a={id:H.id++,send:n(),abort:function(){a.id={}}, open:function(c,b){H[a.id]=a;ia.get(a.id,b)}};return a},aa=1,fa=/{([\w\-]+)}/g,Q="async",M="/",N="&",L=1E4,K=1E3,U="-pnpres",G=-1==navigator.userAgent.indexOf("MSIE 6");window.console||(window.console=window.console||{});console.log||(console.log=console.error=(window.opera||{}).postError||n());var V,W=window.localStorage;V={get:function(a){try{return W?W.getItem(a):-1==document.cookie.indexOf(a)?null:((document.cookie||"").match(RegExp(a+"=([^;]+)"))||[])[1]||null}catch(c){}},set:function(a,c){try{if(W)return W.setItem(a, c)&&0;document.cookie=a+"="+c+"; expires=Thu, 1 Aug 2030 20:00:00 UTC; path=/"}catch(b){}}};var X,Y=Math.floor(20*Math.random());X=function(a){return 0++Y?Y:Y=1))||a};var Z={list:{},unbind:function(a){Z.list[a]=[]},bind:function(a,c){(Z.list[a]=Z.list[a]||[]).push(c)},fire:function(a,c){u(Z.list[a]||[],function(a){a(c)})}},$=s("pubnub")||{},S=0,ha=[],ja=function(a){function c(){}function b(){}function d(a){u(R(e),function(b){(b=e[b])&&a(b)})}var e= {},j=0,m=0,y=0,z=0,h=0,l=0,i=a.publish_key||"",g=a.subscribe_key||"",p=a.ssl?"s":"",k=a.uuid||V.get(g+"uuid")||"",f="http"+p+"://"+(a.origin||"pubsub.pubnub.com"),v={history:function(a,b){var b=a.callback||b,c=a.count||a.limit||100,d=a.reverse||"false",e=a.error||n(),h=a.channel,i=a.start,k=a.end,j={},l=I();if(!h)return t("Missing Channel");if(!b)return t("Missing Callback");if(!g)return t("Missing Subscribe Key");j.stringtoken="true";j.count=c;j.reverse=d;i&&(j.start=i);k&&(j.end=k);O({a:l,data:j, c:function(a){b(a)},b:e,url:[f,"v2","history","sub-key",g,"channel",J(h)]})},replay:function(a){var b=b||a.callback||n(),c=a.source,d=a.destination,e=a.stop,h=a.start,j=a.end,k=a.reverse,a=a.limit,l=I(),m={};if(!c)return t("Missing Source Channel");if(!d)return t("Missing Destination Channel");if(!i)return t("Missing Publish Key");if(!g)return t("Missing Subscribe Key");"0"!=l&&(m.callback=l);e&&(m.stop="all");k&&(m.reverse="true");h&&(m.start=h);j&&(m.end=j);a&&(m.count=a);O({a:l,c:function(a){b(a)}, b:function(){b([0,"Disconnected"])},url:[f,"v1","replay",i,g,c,d],data:m})},time:function(a){var b=I();O({a:b,url:[f,"time",b],c:function(b){a(b[0])},b:function(){a(0)}})},uuid:function(a){var b="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0;return("x"==a?b:b&3|8).toString(16)});a&&a(b);return b},publish:function(a,b){var b=b||a.callback||n(),c=a.message,d=a.channel,e=I();if(!c)return t("Missing Message");if(!d)return t("Missing Channel");if(!i)return t("Missing Publish Key"); if(!g)return t("Missing Subscribe Key");c=JSON.stringify(c);c=[f,"publish",i,g,0,J(d),e,J(c)];O({a:e,c:function(a){b(a)},b:function(){b([0,"Disconnected"])},url:c,data:{uuid:k}})},unsubscribe:function(a){a=a.channel;l=0;z=1;a=x((a.join?a.join(","):""+a).split(","),function(a){return a+","+a+U}).join(",");u(a.split(","),function(a){S&&b(a,0);e[a]=0});S&&c()},subscribe:function(a,b){function i(){var a=I(),b=R(e).join(",");b&&(y=O({timeout:ra,a:a,data:{uuid:k},url:[da,"subscribe",g,J(b),a,l],b:function(){d(function(a){a.d|| (a.d=1,a.i(a.name))});da=X(f);setTimeout(i,K);v.time(function(a){d(function(b){a&&b.d&&(b.d=0,b.j(b.name))})})},c:function(a){if(!a)return setTimeout(i,ca);d(function(a){a.e||(a.e=1,a.h(a.name))});l=!l&&z&&V.get(g)||a[1];V.set(g,a[1]);var b,c=(2