',templateBoundaries:["{{","}}"],transform:null};if(e)for(var o in t)void 0!==e[o]&&(t[o]=e[o]);n("string"==typeof t.target||"object"==typeof t.target,"target must be a string or DOM node, got "+t.target+" ("+typeof t.target+")"),n("string"==typeof t.accessToken||"function"==typeof t.accessToken,"accessToken must be a string or function, got "+t.accessToken+" ("+typeof t.accessToken+")"),n("number"==typeof t.accessTokenTimeout,"accessTokenTimeout must be a number, got "+t.accessTokenTimeout+" ("+typeof t.accessTokenTimeout+")"),n("number"==typeof t.apiTimeout,"apiTimeout must be a number, got "+t.apiTimeout+" ("+typeof t.apiTimeout+")"),n("boolean"==typeof t.debug,"debug must be true or false, got "+t.debug+" ("+typeof t.debug+")"),n("boolean"==typeof t.mock,"mock must be true or false, got "+t.mock+" ("+typeof t.mock+")"),n("object"==typeof t.templateBoundaries&&2===t.templateBoundaries.length&&"string"==typeof t.templateBoundaries[0]&&"string"==typeof t.templateBoundaries[1],"templateBoundaries must be an array of 2 strings, got "+t.templateBoundaries+" ("+typeof t.templateBoundaries+")"),n(!t.template||"string"==typeof t.template,"template must null or string, got "+t.template+" ("+typeof t.template+")"),n(!t.error||"function"==typeof t.error,"error must be null or function, got "+t.error+" ("+typeof t.error+")"),n(!t.before||"function"==typeof t.before,"before must be null or function, got "+t.before+" ("+typeof t.before+")"),n(!t.after||"function"==typeof t.after,"after must be null or function, got "+t.after+" ("+typeof t.after+")"),n(!t.success||"function"==typeof t.success,"success must be null or function, got "+t.success+" ("+typeof t.success+")"),n(!t.filter||"function"==typeof t.filter,"filter must be null or function, got "+t.filter+" ("+typeof t.filter+")"),n(!t.transform||"function"==typeof t.transform,"transform must be null or function, got "+t.transform+" ("+typeof t.transform+")"),n(!t.sort||"function"==typeof t.sort,"sort must be null or function, got "+t.sort+" ("+typeof t.sort+")"),n(!t.render||"function"==typeof t.render,"render must be null or function, got "+t.render+" ("+typeof t.render+")"),n(!t.limit||"number"==typeof t.limit,"limit must be null or number, got "+t.limit+" ("+typeof t.limit+")"),n(!t.apiLimit||"number"==typeof t.apiLimit,"apiLimit must null or number, got "+t.apiLimit+" ("+typeof t.apiLimit+")"),this._state={running:!1,node:null,token:null,paging:null,pool:[]},this._options=t}return e.prototype.run=function(){var o=this;return this._debug("run","options",this._options),this._debug("run","state",this._state),this._state.running?(this._debug("run","already running, skipping"),!1):(this._start(),this._debug("run","getting dom node"),"string"==typeof this._options.target?this._state.node=document.getElementById(this._options.target):this._state.node=this._options.target,this._state.node?(this._debug("run","got dom node",this._state.node),this._debug("run","getting access token"),this._getAccessToken(function(e,t){if(e)return o._debug("onTokenReceived","error",e),void o._fail(new Error("error getting access token: "+e.message));o._debug("onTokenReceived","got token",t),o._state.token=t,o._showNext(function(e){if(e)return o._debug("onNextShown","error",e),void o._fail(e);o._finish()})}),!0):(this._fail(new Error("no element found with ID "+this._options.target)),!1))},e.prototype.hasNext=function(){var e=this._state.paging,t=this._state.pool;return this._debug("hasNext","paging",e),this._debug("hasNext","pool",t.length,t),0\?,\./|\\\s]+/i,n=[],i=null;if("string"==typeof e)for(;null!==(i=t.exec(e));)!1===o.test(i[1])&&n.push(i[1]);return n},e.prototype._getItemData=function(e){var t=null,o=null;switch(e.media_type){case"IMAGE":t="image",o=e.media_url;break;case"VIDEO":t="video",o=e.thumbnail_url;break;case"CAROUSEL_ALBUM":t="album",o=e.media_url}return{caption:e.caption,tags:this._extractTags(e.caption),id:e.id,image:o,link:e.permalink,model:e,timestamp:e.timestamp,type:t,username:e.username}},e.prototype._renderData=function(e){var t="string"==typeof this._options.template,o="function"==typeof this._options.render,n=null,i=null,s=null,r="";if(this._debug("renderData","hasTemplate",t,"hasRender",o),!("object"!=typeof e||e.length<=0)){for(var a=0;a