forked from thewolff/massrel-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmassrel.min.js
12 lines (12 loc) · 26.6 KB
/
massrel.min.js
1
2
3
4
5
6
7
8
9
10
11
12
/*!
* massrel-js 1.8.6
*
* Copyright 2017 Mass Relevance
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this work except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
!function(a,b){var c;!function(){if(!c||!c.requirejs){c?b=c:c={};var a,b,d;!function(c){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m=b&&b.split("/"),n=s.map,o=n&&n["*"]||{};if(a&&"."===a.charAt(0))if(b){for(m=m.slice(0,m.length-1),a=m.concat(a.split("/")),j=0;j<a.length;j+=1)if(l=a[j],"."===l)a.splice(j,1),j-=1;else if(".."===l){if(1===j&&(".."===a[2]||".."===a[0]))break;j>0&&(a.splice(j-1,2),j-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((m||o)&&n){for(c=a.split("/"),j=c.length;j>0;j-=1){if(d=c.slice(0,j).join("/"),m)for(k=m.length;k>0;k-=1)if(e=n[m.slice(0,k).join("/")],e&&(e=e[d])){f=e,g=j;break}if(f)break;!h&&o&&o[d]&&(h=o[d],i=j)}!f&&h&&(f=h,g=i),f&&(c.splice(0,g,f),a=c.join("/"))}return a}function g(a,b){return function(){return n.apply(c,v.call(arguments,0).concat([a,b]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var b=r[a];delete r[a],t[a]=!0,m.apply(c,b)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,b,d,f){var h,k,l,m,n,s,u=[];if(f=f||a,"function"==typeof d){for(b=!b.length&&d.length?["require","exports","module"]:b,n=0;n<b.length;n+=1)if(m=o(b[n],f),k=m.f,"require"===k)u[n]=p.require(a);else if("exports"===k)u[n]=p.exports(a),s=!0;else if("module"===k)h=u[n]=p.module(a);else if(e(q,k)||e(r,k)||e(t,k))u[n]=j(k);else{if(!m.p)throw new Error(a+" missing "+k);m.p.load(m.n,g(f,!0),i(k),{}),u[n]=q[k]}l=d.apply(q[a],u),a&&(h&&h.exports!==c&&h.exports!==q[a]?q[a]=h.exports:l===c&&s||(q[a]=l))}else a&&(q[a]=d)},a=b=n=function(a,b,d,e,f){return"string"==typeof a?p[a]?p[a](b):j(o(a,b).f):(a.splice||(s=a,b.splice?(a=b,b=d,d=null):a=c),b=b||function(){},"function"==typeof d&&(d=e,e=f),e?m(c,a,b,d):setTimeout(function(){m(c,a,b,d)},4),n)},n.config=function(a){return s=a,n},d=function(a,b,c){b.splice||(c=b,b=[]),e(q,a)||e(r,a)||(r[a]=[a,b,c])},d.amd={jQuery:!0}}(),c.requirejs=a,c.require=b,c.define=d}}(),c.define("globals",{host:"api.massrelevance.com",timeout:1e4,protocol:"https:"===document.location.protocol?"https":"http",min_poll_interval:5e3,max_backoff_interval:6e4,backoff_rate:1.8,jsonp_param:"jsonp"}),c.define("helpers",["./globals"],function(c){var d={},e=encodeURIComponent;d.step_through=function(a,b,c){a=d.is_array(a)?a:[a];var e=a.length-1;if(e>=0)for(;e>=0;e--)for(var f=a[e],g=0,h=b.length;h>g;g++)b[g].call(c,f)},d.extend=function(a,b){var c;for(c in b)"undefined"==typeof a[c]&&(a[c]=b[c]);return a},d.api_url=function(a,b){b=b||c.host;var d=c.port,e=c.protocol+"://"+b+(d?":"+d:"");return e+a},d.req={},d.req.supportsXhr2=a.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,d.req.supportsCors=d.req.supportsXhr2||"XDomainRequest"in a,d.req.supportsJSON="JSON"in a,d.req.xdr=function(b,e,f,g,h,i,j,k){var l,m,n=!1;j||(j="GET");var o=function(a){n=!0;var b,c=!1;try{b=JSON.parse(a)}catch(e){c=!0,p(new Error("JSON parse error"))}c||("function"==typeof h?h(b):d.is_array(h)&&h.length>0&&d.step_through(b,h,g))},p=function(a){n=!0,"function"==typeof i&&i(a)};a.XMLHttpRequest&&d.req.supportsXhr2?l=new XMLHttpRequest:a.XDomainRequest&&(l=new XDomainRequest),l?(l.open(j,b+"?"+d.to_qs(e)),l.timeout=c.timeout,l.onerror=p,l.onprogress=function(){},l.ontimeout=p,l.onload=function(){o(l.responseText)},l.send(k),m=setTimeout(function(){n||(l.onerror=function(){},l.onprogress=function(){},l.ontimeout=function(){},l.onload=function(){},l.abort&&l.abort(),p())},c.timeout)):p(new Error("CORS not supported"))},d.req.jsonp=function(a,b,e,g,h,i){var j,k=e+ ++f,l=!1;c._json_callbacks[k]=function(a){"function"==typeof h?h(a):d.is_array(h)&&h.length>0&&d.step_through(a,h,g),delete c._json_callbacks[k],l=!0,clearTimeout(j)},b.push([c.jsonp_param,"massrel._json_callbacks."+k]);var m=d.load(a+"?"+d.to_qs(b));j=setTimeout(function(){l||(c._json_callbacks[k]=function(){delete c._json_callbacks[k]},"function"==typeof i&&i(),m.stop())},c.timeout)},d.jsonp_factory=d.req.jsonp;var f=0;c._json_callbacks={},d.request_factory=function(a,b,c,e,f,g){d.req.supportsCors&&d.req.supportsJSON?d.req.xdr(a,b,c,e,f,g):d.req.jsonp(a,b,c,e,f,g)},d.post_factory=function(a,b,c,e,f,g,h){if(!d.req.supportsCors||!d.req.supportsJSON)throw"POST not supported";d.req.xdr(a,b,e,f,g,h,"POST",c)},d.is_array=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},d.is_number=function(a){return"[object Number]"===Object.prototype.toString.call(a)};var g=document.getElementsByTagName("head")[0]||document.body;d.load=function(a,b){var c=document.createElement("script");c.type="text/javascript",c.src=a;var d=!1;return c.onload=c.onreadystatechange=function(){d||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState||(d=!0,c.onload=c.onreadystatechange=null,g&&c.parentNode&&g.removeChild(c),"function"==typeof b&&b())},g.insertBefore(c,g.firstChild),{stop:function(){c.onload=c.onreadystatechange=null,g&&c.parentNode&&g.removeChild(c),c.src="#"}}},d.to_qs=function(a){var c,f=[];if(a&&a.length){for(var g=0,h=a.length;h>g;g++){if(c=a[g][1],d.is_array(c)){for(var i=[],j=0,k=c.length;k>j;j++)i[j]=e(c[j]||"");c=i.join(",")}else c=c!==b&&null!==c?e(c):"";f.push(e(a[g][0])+"="+c)}return f.join("&")}return""};var h=/\+\d{4} \d{4}$/,i=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\+\d{4})$/,j=/^(\d{4})-(\d\d)-(\d\d)T(\d\d)\:(\d\d)\:(\d\d)\.(\d{3})Z$/;return d.fix_date=d.fix_twitter_date=function(a){if(a=a.toString(),h.test(a)){a=a.split(" ");var b=a.pop();a.splice(3,0,b),a=a.join(" ")}else i.test(a)?a=a.replace(i,"$1/$2/$3 $4:$5:$6 $7"):j.test(a)&&(a=a.replace(j,"$1/$2/$3 $4:$5:$6 +0000"));return a},d.parse_params=function(b){b=b||a.location.search.substring(1);var c={};if("?"===b.charAt(0)&&(b=b.substring(1)),b.length>0){b=b.replace(/\+/g," ");for(var d=b.split(/[&;]/g),e=0;e<d.length;e++){var f=d[e].split("="),g=decodeURIComponent(f[0]),h=f.length>1?decodeURIComponent(f[1]):"";if(g in c){var i=c[g];"string"!=typeof i?c[g].push(h):(c[g]=[],c[g].push(i),c[g].push(h))}else c[g]=h}}return c},d.poll_interval=function(a){var b=c.min_poll_interval;return Math.max(a||b,b)},d.poll_backoff=function(a,b){var d=c.max_backoff_interval;return d>a&&(b=Math.max(b-1,0),a*=Math.pow(c.backoff_rate,b),a=Math.min(a||d,d)),a},d.callback_group=function(a){a=a||1;var b=0,c=!0,d=function(d,e){return function(){if(c){if(a>=b)return d.apply(e||this,arguments);throw new Error("Callback group max call count exceeded")}}};return d.deactivate=function(){c=!1},d},d.timeParam=function(a,b,c,d){"undefined"!=typeof a&&(a.getTime&&(a=a.getTime()/1e3),a=+a,!isNaN(a)&&a>0?(a=60*Math.floor(a/60),c.push([b,a])):!isNaN(a)&&d&&0>=a&&c.push([b,a]))},d.always=function(a){var c=new $.Deferred;if(a===b)return c.resolve(),c.promise();a.length===b&&(a=[a]);var d=a.length,e=function(){d--,0===d&&c.resolve()};return $.each(a,function(){this.always(e)}),c.promise()},d}),c.define("generic_poller_cycle",["./helpers"],function(a){function b(b,c,d){this.cg=a.callback_group(),this.skip=this.cg(b),this.callback=this.cg(c),this.errback=this.cg(d),this._enabled=!0}return b.prototype.enabled=function(){return this._enabled},b.prototype.disable=function(){this.cg.deactivate(),this._enabled=!1},b}),c.define("generic_poller",["./helpers","./generic_poller_cycle"],function(a,b){function c(d,e){var f,g=this,h=function(){if(k){var e=a.callback_group(),f=e(i),h=function(b){if(g.consecutive_errors=0,c.failure_mode=g.failure_mode=!1,k){for(var d=0,e=g._filters.length;e>d;d++)b=g._filters[d].call(g,b);a.step_through([b],g._listeners,g),k&&f()}},l=function(){g.consecutive_errors+=1,c.failure_mode=g.failure_mode=!0,f(!0)};j=new b(f,h,l),g.fetch(d,g.opts,j)}},i=function(b){var c=a.poll_interval(1e3*g.frequency);b&&(c=a.poll_backoff(c,g.consecutive_errors)),f=setTimeout(h,c)},j=null,k=!1;this._listeners=[],this._filters=[],this.object=d,this.opts=e||{},this.frequency=this.opts.frequency||30,this.alive_count=0,this.consecutive_errors=0,this.failure_mode=!1,this.start=function(){return k||(k=!0,h()),this},this.stop=function(){return j&&(j.disable(),j=null),clearTimeout(f),k=!1,this}}return c.prototype.fetch=function(a,b,c){return a.load(b,c.callback,c.errback),this},c.prototype.data=function(a){return this._listeners.push(a),this},c.prototype.filter=function(a){return this._filters.push(a),this},c.failure_mode=!1,c}),c.define("poller_queue",["./helpers"],function(a){function b(b,c){function d(){if(!g&&e.length>0&&"function"==typeof f){var a=++h;i.enqueued-=1,i.count+=1;var b=e.shift();g=!0,f.call(i,b,function(){a===h&&(g=!1,setTimeout(d,0))})}}this.poller=b,c=a.extend(c||{},{});var e=[],f=null,g=!1,h=0;this.total=0,this.enqueued=0,this.count=0;var i=this;b.batch(function(a){for(var b=a.length,c=b-1;c>=0;c--)e.push(a[c]);i.total+=b,i.enqueued+=b,d()}),this.next=function(a){g||"function"!=typeof a||(f=a,d())}}return b}),c.define("poller",["./helpers","./generic_poller","./poller_queue"],function(a,b,c){function d(a,c){b.call(this,a,c),this.stream=this.object,this.filter(this.filter_newer),c=this.opts,this.newest_timestamp=c.newest_timestamp||null,this.stay_realtime="stay_realtime"in c?!!c.stay_realtime:!0,this.hail_mary_mode=!!c.hail_mary_mode,this.first=!0}return a.extend(d.prototype,b.prototype),d.prototype.fetch=function(b,c,d){var e=this,f={start_id:null},g=this.stay_realtime?"since_id":"from_id";return f[g]=e.since_id,c=a.extend({},c),this.first&&(c=a.extend(c.initial||{},c),delete c.initial),f=a.extend(f,c),this.cursorable()||delete f.since_id,b.load(f,function(a){d.enabled()&&(a&&a.length>0&&(e.since_id=a[0].entity_id,e.start_id||(e.start_id=a[a.length-1].entity_id)),d.callback(a),f.timeframe&&e.first&&e.stop(),e.first=!1)},d.errback),this},d.prototype.batch=function(a){return this.data(d.createEnumerator(a,!1))},d.prototype.each=function(a){return this.data(d.createEnumerator(a,!0))},d.prototype.queue=function(a){var b=new c(this);return b.next(a),this},d.prototype.more=function(b,c){var d=this,e=function(){d.object.load(a.extend({start_id:d.start_id,since_id:null},d.opts),function(a){a.length>0&&(d.start_id=a[a.length-1].entity_id,d.since_id||(d.since_id=a[0].entity_id)),b.call(d,a)},function(){"function"==typeof c&&c()})};return e(),this},d.prototype.cursorable=function(){return!(b.failure_mode||this.failure_mode||this.hail_mary_mode)},d.prototype.filter_newer=function(a){return a=d.filter_newer(a,this.newest_timestamp),a&&a.length>0&&(this.newest_timestamp=a[0].queued_at),a},d.prototype.poke=function(){return this},d.createEnumerator=function(b,c){return c?function(c){c&&c.length>0&&a.step_through(c,[b],this)}:function(a){a&&a.length>0&&b.call(this,a)}},d.filter_newer=function(a,b){var c="queued_at";if(a&&a.length>0){var d=this.limit||1/0;if(b)if(a[0][c]<=b)a=[];else if(a[a.length-1][c]>b)a.length>d&&a.splice(this.limit,a.length-d);else{for(var e=[],f=0,g=a.length;g>f&&e.length<d;f++){var h=a[f];if(!(h[c]>b))break;e.push(h)}a=e}else a.length>d&&a.splice(this.limit,a.length-d)}return a},d}),c.define("meta_poller",["./helpers","./generic_poller"],function(a,b){function c(){b.apply(this,arguments)}return a.extend(c.prototype,b.prototype),c.prototype.fetch=function(a,b,c){return a.meta(b,c.callback,c.errback),this},c.prototype.each=c.prototype.data,c}),c.define("top_things_poller",["./helpers","./generic_poller"],function(a,b){function c(a,c){c.thing=c.thing||"hashtags","number"==typeof c.resolution&&(c.resolution=c.resolution+"s"),b.apply(this,arguments)}return a.extend(c.prototype,b.prototype),c.prototype.fetch=function(a,b,c){return"number"==typeof b.resolution&&(b.resolution=b.resolution+"s"),a.topThings(b,c.callback,c.errback),this},c.mostRecentBucket=function(a){if(a.data&&a.data.length>0){for(var b=a.data.length-1;b>=0;b--)if(a.data[b].things&&a.data[b].things.length>0)return a.data[b];if(-1===b)return a.data[a.data.length-1]}return null},c.prototype.each=c.prototype.data,c}),c.define("stream_keyword_insights",["./helpers","./generic_poller"],function(a,b){function c(a,b){this.stream=a,this.defaults=b||{}}encodeURIComponent;return c.prototype.url=function(){return this.stream.keyword_insights_url()},c.prototype.fetch=function(b,c,d){b=a.extend({},b||{}),b=a.extend(b,this.defaults);var e=this.params(b);return a.request_factory(this.url(),e,"_",this,function(){"function"==typeof c&&c.apply(this,arguments)},d),this},c.prototype.poller=function(a){var c=new b(this,a);return c.fetch=function(a,b,c){return a.fetch(b,c.callback,c.errback)},c},c.prototype.params=function(a){a=a||{};var b=[];return a.topics&&b.push(["topics","1"]),"start"in a&&b.push(["start",a.start]),"finish"in a&&b.push(["finish",a.finish]),a.resolution&&b.push(["resolution",a.resolution]),a.countries&&b.push(["countries",a.countries]),b},c}),c.define("stream_activity",["./helpers","./generic_poller"],function(a,b){function c(a,b){this.stream=a,this.defaults=b||{}}var d=encodeURIComponent;c.prototype.url=function(){return a.api_url("/"+d(this.stream.account)+"/"+d(this.stream.stream_name)+"/activity.json")},c.prototype.fetch=function(b,c,d){b=a.extend({},b||{}),b=a.extend(b,this.defaults);var e=this.params(b);return a.request_factory(this.url(),e,"_",this,function(d){if(d&&(!b.verbose||"0"===b.verbose)&&a.is_array(d.activity))for(var e=d.activity,f=0,g=e.length;g>f;f++){var h=d.start+d.period_size*f;e[f]=a.extend(e[f],{start:h,finish:Math.min(h+d.period_size,d.finish)})}"function"==typeof c&&c.apply(this,arguments)},d),this},c.prototype.poller=function(a){var c=new b(this,a);return c.fetch=function(a,b,c){return a.fetch(b,c.callback,c.errback)},c},c.prototype.params=function(b){b=b||{};var c=[];return b.view?c.push(["view",b.view]):b.topic&&c.push(["topic",b.topic]),a.timeParam(b.start,"start",c,!0),a.timeParam(b.finish,"finish",c,!0),"periods"in b&&c.push(["periods",b.periods]),b.resolution&&c.push(["resolution",b.resolution]),"tz_offset"in b&&c.push(["tz_offset",b.tz_offset]),b.encode&&c.push(["encode",b.encode]),c.push(["verbose",0]),c};var e=function(a,b,d){c.prototype[a]=function(){return this.defaults[b]=d,this}};return e("approved","view","approved"),e("pending","view","pending"),e("rejected","view","rejected"),e("minutes","resolution","1m"),e("ten_minutes","resolution","10m"),e("hours","resolution","1h"),e("days","resolution","1d"),c}),c.define("stream",["./helpers","./poller","./meta_poller","./top_things_poller","./stream_keyword_insights","./stream_activity"],function(a,b,c,d,e,f){function g(){var a=1===arguments.length?arguments[0].split("/"):arguments;this.account=a[0],this.stream_name=a[1],this._enumerators=[]}var h=encodeURIComponent;return g.prototype.stream_url=function(){return a.api_url("/"+h(this.account)+"/"+h(this.stream_name)+".json")},g.prototype.meta_url=function(){return a.api_url("/"+h(this.account)+"/"+h(this.stream_name)+"/meta.json")},g.prototype.top_things_url=function(b){return a.api_url("/"+h(this.account)+"/"+h(this.stream_name)+"/top_"+b+".json")},g.prototype.keyword_insights_url=function(){return a.api_url("/"+h(this.account)+"/"+h(this.stream_name)+"/keyword_insights.json")},g.prototype.load=function(b,c,d){b=a.extend(b||{},{});var e=this.buildParams(b);return a.request_factory(this.stream_url(),e,"_",this,c||this._enumerators,d),this},g.prototype.buildParams=function(b){b=b||{};var c=[];if(b.limit&&c.push(["limit",b.limit]),b.since_id?c.push(["since_id",b.since_id]):b.from_id?c.push(["from_id",b.from_id]):(b.start_id||b.start)&&c.push(["start",b.start_id||b.start]),b.replies&&c.push(["replies","1"]),b.geo_hint&&c.push(["geo_hint","1"]),b.from&&c.push(["from",b.from]),b.keywords&&c.push(["keywords",b.keywords]),b.lang&&c.push(["lang",b.lang]),b.network&&c.push(["network",b.network]),b.timeline_search&&c.push(["timeline_search","1"]),b.page_links&&c.push(["page_links","1"]),b.klout&&c.push(["klout","1"]),b.timeframe&&(a.timeParam(b.timeframe.start,"timeframe[start]",c),a.timeParam(b.timeframe.finish,"timeframe[finish]",c)),b.strip_links&&c.push(["strip_links","1"]),b.nonsquare_instagram&&c.push(["nonsquare_instagram","true"]),b.products)if(a.is_array(b.products))for(var d=0;d<b.products.length;d+=1)c.push(["products[]",b.products[d]]);else c.push(["products[]",b.products]);return b.tweet_mode&&c.push(["tweet_mode",b.tweet_mode]),c},g.prototype.each=function(a){return this._enumerators.push(a),this},g.prototype.poller=function(a){return new b(this,a)},g.prototype.meta=function(){var b,c,d;if("function"==typeof arguments[0])c=arguments[0],d=arguments[1],b={};else{if("object"!=typeof arguments[0])throw new Error("incorrect arguments");b=arguments[0],c=arguments[1],d=arguments[2]}var e=this.buildMetaParams(b);return a.request_factory(this.meta_url(),e,"meta_",this,c,d),this},g.prototype.buildMetaParams=function(a){a=a||{};var b=[];return a.all_topics&&b.push(["all_topics",a.all_topics]),a.disregard&&b.push(["disregard",a.disregard]),a.num_minutes&&b.push(["num_minutes",a.num_minutes]),a.num_hours&&b.push(["num_hours",a.num_hours]),a.num_days&&b.push(["num_days",a.num_days]),a.num_trends&&b.push(["num_trends",a.num_trends]),a.num_links&&b.push(["num_links",a.num_links]),a.num_hashtags&&b.push(["num_hashtags",a.num_hashtags]),a.num_contributors&&b.push(["num_contributors",a.num_contributors]),a.top_periods&&b.push(["top_periods",a.top_periods]),a.top_periods_relative&&b.push(["top_periods_relative",a.top_periods_relative]),a.top_count&&b.push(["top_count",a.top_count]),a.finish&&b.push(["finish",a.finish]),a.networks&&b.push(["networks","1"]),(a.activity||0===a.activity)&&b.push(["activity",a.activity]),a.tweet_mode&&b.push(["tweet_mode",a.tweet_mode]),b},g.prototype.metaPoller=function(a){return new c(this,a)},g.prototype.keywordInsights=function(a){return new e(this,a)},g.prototype.topThings=function(){var b,c,d;if("function"==typeof arguments[0])c=arguments[0],d=arguments[1],b={};else{if("object"!=typeof arguments[0])throw new Error("incorrect arguments");b=arguments[0],c=arguments[1],d=arguments[2]}var e=this.buildTopThingsParams(b);return a.request_factory(this.top_things_url(b.thing),e,"top_things_",this,c,d),this},g.prototype.buildTopThingsParams=function(b){b=b||{};var c=[];if(b.resolution){var d;d=a.is_number(b.resolution)?b.resolution+"s":b.resolution,c.push(["resolution",d])}return b.start&&c.push(["start",b.start]),b.finish&&c.push(["finish",b.finish]),b.limit&&c.push(["limit",b.limit]),b.percent&&c.push(["percent","1"]),b.tweet_mode&&c.push(["tweet_mode",b.tweet_mode]),c},g.prototype.topThingsPoller=function(a){return new d(this,a)},g.prototype.activity=function(a){return new f(this,a)},g}),c.define("account",["./helpers","./meta_poller"],function(a,b){function c(a){this.user=a}var d=encodeURIComponent;return c.prototype.meta_url=function(){return a.api_url("/"+d(this.user)+".json")},c.prototype.meta=function(){var b,c,d;if("function"==typeof arguments[0])c=arguments[0],d=arguments[1],b={};else{if("object"!=typeof arguments[0])throw new Error("incorrect arguments");b=arguments[0],c=arguments[1],d=arguments[2]}var e=this.buildMetaParams(b);return a.request_factory(this.meta_url(),e,"meta_",this,c,d),this},c.prototype.buildMetaParams=function(b){b=b||{};var c=[];if(b.quick_stats&&c.push(["quick_stats","1"]),b.streams){var d=a.is_array(b.streams)?b.streams:[b.streams];c.push(["streams",d.join(",")])}return b.num_minutes&&c.push(["num_minutes",b.num_minutes]),b.num_trends&&c.push(["num_trends",b.num_trends]),b.start&&c.push(["start",b.start]),b.finish&&c.push(["finish",b.finish]),c},c.prototype.metaPoller=function(a){return new b(this,a)},c.prototype.toString=function(){return this.user},c}),c.define("context",["./helpers"],function(a){function c(a){this.status=a,this.source={facebook:!1,twitter:!1,getglue:!1,google:!1,instagram:!1,rss:!1,message:!1},this.known=!1,this.intents=!0}return c.create=function(b,d){b=b||{};var e=new c(b);return d=a.extend(d||{},{intents:!0,retweeted_by:!0}),e.intents=d.intents,"undefined"!=typeof e.source[b.network]&&(e.source[b.network]=e.known=!0,e.sourceName=b.network),"google_plus"===b.network&&(e.source.google=e.known=!0,e.sourceName="google"),"massrelevance"===b.network&&(e.source.message=e.known=!0,e.sourceName="message"),e.source.twitter&&b.retweeted_status&&d.retweeted_by&&(e.retweet=!0,e.retweeted_by_user=b.user,e.status=b.retweeted_status),e},c.prototype.getPhotoUrl=function(){if(this.photo_url!==b)return this.photo_url;var a=!1;if(this.status&&this.known)if(this.source.twitter)if(this.status.entities.media&&this.status.entities.media.length){var c=this.status.entities.media[0];a={url:c.media_url,width:c.sizes.medium.w,height:c.sizes.medium.h,link_url:c.url||c.expanded_url}}else this.status.entities.urls&&this.status.entities.urls.length&&(a={url:this.status.entities.urls[0].expanded_url||this.status.entities.urls[0].url});else this.source.facebook&&(this.status.type&&"photo"===this.status.type||this.status.kind&&"photo"===this.status.kind)?a={url:this.status.picture.replace(/_[st]./,"_n.")}:this.source.google&&this.status.object.attachments.length&&"photo"===this.status.object.attachments[0].objectType?a={url:this.status.object.attachments[0].fullImage.url}:this.source.instagram&&"image"===this.status.type&&(a={url:this.status.images.standard_resolution.url});return this.photo_url=a,a},c}),c.define("compare_poller",["./helpers","./generic_poller"],function(a,b){function c(){b.apply(this,arguments)}return a.extend(c.prototype,b.prototype),c.prototype.fetch=function(a,b,c){return a.load(b,c.callback,c.errback),this},c.prototype.each=c.prototype.data,c}),c.define("compare",["./helpers","./compare_poller"],function(a,b){function c(b){this.streams=a.is_array(b)?b.slice(0):"string"==typeof b?[b]:[]}return c.prototype.compare_url=function(){return a.api_url("/compare.json")},c.prototype.buildParams=function(a){var b=[];return a=a||{},a.streams&&b.push(["streams",a.streams]),(a.target||a.target>=0)&&b.push(["target",a.target.toString()]),a.precision&&a.precision>0&&b.push(["precision",a.precision]),b},c.prototype.load=function(b,c,d){"function"==typeof b&&(d=c,c=b,b=null);var e=this.buildParams(a.extend({streams:this.streams,precision:this.precision,target:this.target},b||{}));return a.request_factory(this.compare_url(),e,"meta_",this,c,d),this},c.prototype.poller=function(a){return new b(this,a)},c}),c.define("intents",["./helpers"],function(c){var d={base_url:"https://twitter.com/intent/",params:{text:"(string): default text, for tweet/reply",url:"(string): prefill url, for tweet/reply",hashtags:"(string): hashtag (or list with ,) without #, for tweet/reply",related:"(string): screen name (or list with ,) without @, available for all",in_reply_to:"(number): tweet id, only for reply",via:"(string): screen name without @, tweet/reply",tweet_id:"(number): tweet id, for retweet and favorite",screen_name:"(string): only for user/profile",user_id:"(number): only for user/profile",original_referer:'(string): url to display with related ("www.yahoo.com suggests you follow:")'},original_referer:a.top!==a.self&&document.referrer||null};return d.url=function(a,e){if(e=c.extend({},e||{}),e.original_referer===b&&d.original_referer&&(e.original_referer=d.original_referer),e.original_referer&&!/^https?:\/\//.test(e.original_referer)&&(e.original_referer="http://"+e.original_referer),e.hashtags&&navigator.userAgent.match(/(iPod|iPhone|iPad)/)&&navigator.userAgent.match(/AppleWebKit/)){var f=e.text?[e.text]:[];e.url&&(f.push(e.url),delete e.url),f.push("#"+e.hashtags.split(/\s*,\s*/).join(" #").replace(/^\s+|\s+$/gm,"")),delete e.hashtags,e.text=f.join(" ")}var g=[];for(var h in e)g.push([h,e[h]]);return d.base_url+encodeURIComponent(a)+"?"+c.to_qs(g)},d.tweet=function(a){return d.url("tweet",a)},d.reply=function(a,b){return b=b||{},b.in_reply_to=a,d.tweet(b)},d.retweet=function(a,b){return b=b||{},b.tweet_id=a,d.url("retweet",b)},d.favorite=function(a,b){return b=b||{},b.tweet_id=a,d.url("favorite",b)},d.user=function(a,b){return b=b||{},/^\d+$/.test(a+"")?b.user_id=a:b.screen_name=a,d.url("user",b)},d.profile=d.user,d}),c.define("search",["require","./helpers"],function(a){var b=a("./helpers"),c=function(a){this.apiToken=a};return c.prototype.url=function(){return b.api_url("/search/search.json")},c.prototype.fetch=function(a,c,d){return a=this.buildQueryString(a),b.request_factory(this.url(),a,"_",this,c,d),this},c.prototype.buildQueryString=function(a){var b=[];if("string"==typeof a.q&&b.push(["q",a.q]),a.filters&&(b=b.concat(this.buildParams(a.filters,"filter."))),a.views){var c,d;for(c in a.views)d=a.views[c],"boolean"==typeof d?b.push(["view."+c,d?"1":"0"]):b=b.concat(this.buildParams(d,"view."+c+"."))}return this.apiToken&&b.push(["api_token",this.apiToken]),a.network&&b.push(["network",a.network]),b},c.prototype.buildParams=function(a,c){c=c||"";var d,e,f,g=[];for(d in a)for(e=a[d],b.is_array(e)||(e=[e]),f=0,len=e.length;f<len;f++){var h=e[f];"boolean"==typeof h&&(h=h?"1":"0"),g.push([c+d,h])}return g},c}),c.define("facebook_media_questions",["./helpers","./generic_poller"],function(a,b){function c(){}return c.prototype.url=function(){return a.api_url("/facebook/media_question.json")},c.prototype.buildParams=function(a){a=a||{};var b=[];return a.id&&b.push(["id",a.id]),a.page&&b.push(["page",a.page]),b},c.prototype.load=function(b,c,d){b=a.extend(b||{},{});var e=this.buildParams(b);return a.request_factory(this.url(),e,"_",this,c||this._enumerators,d),this},c.prototype.poller=function(a){return new b(this,a)},c}),c.define("massrel",["./globals","./helpers","./stream","./account","./stream_keyword_insights","./stream_activity","./generic_poller","./generic_poller_cycle","./poller","./meta_poller","./top_things_poller","./poller_queue","./context","./compare","./compare_poller","./intents","./search","./facebook_media_questions"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){a.Stream=c,a.Account=d,a.StreamKeywordInsights=e,a.StreamActivity=f,a.GenericPoller=g,a.GenericPollerCycle=h,a.Poller=i,a.MetaPoller=j,a.TopThingsPoller=k,a.PollerQueue=l,a.Context=m,a.Compare=n,a.ComparePoller=o,a.helpers=b,a.intents=p,a.Search=q,a.FacebookMediaQuestion=r;var s=b.parse_params();return s["massrel[host]"]&&(a.host=s["massrel[host]"]),a});var d=c.require("./massrel"),e=a.massrel;"undefined"==typeof e?e=a.massrel=d:d.helpers.extend(e,d),"function"==typeof define&&define.amd&&define(e)}(window);