!function(e){var a={host:"https://www.instagram.com/",username:"",tag:"",user_id:"",location:"",container:"",display_profile:!0,display_biography:!0,display_gallery:!0,display_captions:!1,display_igtv:!1,max_tries:8,callback:null,styling:!0,items:8,items_per_row:4,margin:.5,image_size:640,lazy_load:!1,cache_time:360,on_error:console.error},t={150:0,240:1,320:2,480:3,640:4},i={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function o(e,a){var t=a||!1;if(!a&&e.cache_time>0){var i=localStorage.getItem(e.cache_time_key);null!==i&&parseInt(i)+6e4*e.cache_time>(new Date).getTime()&&(t=!0)}if(t){var o=localStorage.getItem(e.cache_data_key);if(null!==o)return JSON.parse(o)}return!1}function n(a,t,i,o,s,r){var l;s&&r&&(l="https://images"+~~(3333*Math.random())+"-focus-opensocial.googleusercontent.com/gadgets/proxy?container=none&url="+a),e.get(l||a,function(e){var a=function(e,a){switch(e){case"username":case"tag":case"location":try{a=a.split("window._sharedData = ")[1].split("<\/script>")[0]}catch(e){return!1}return void 0!==(a=(a=JSON.parse(a.substr(0,a.length-1))).entry_data.ProfilePage||a.entry_data.TagPage||a.entry_data.LocationsPage)&&(a[0].graphql.user||a[0].graphql.hashtag||a[0].graphql.location);case"userid":return void 0!==a.data.user&&a.data.user}}(t,e);o(!1!==a&&a)}).fail(function(e){i>1?(console.warn("Instagram Feed: Request failed, "+(i-1)+" tries left. Retrying..."),n(a,t,i-1,o,s,!r)):o(!1,e)})}function s(e,t){var i=o(e,!1);if(!1!==i)t(i);else{var s;switch(e.type){case"username":s=e.host+e.id+"/";break;case"tag":s=e.host+"explore/tags/"+e.id+"/";break;case"location":s=e.host+"explore/locations/"+e.id+"/";break;case"userid":s=e.host+'graphql/query/?query_id=17888483320059182&variables={"id":"'+e.id+'","first":'+e.items+',"after":null}'}n(s,e.type,e.max_tries,function(a,i){!1!==a?(!function(e,a){var t=localStorage.getItem(e.cache_time_key);0!=e.cache_time&&(null===t||parseInt(t)+6e4*e.cache_time>(new Date).getTime())&&(localStorage.setItem(e.cache_data_key,JSON.stringify(a)),localStorage.setItem(e.cache_time_key,(new Date).getTime()))}(e,a),t(a)):void 0===i?e.on_error("Instagram Feed: It looks like the profile you are trying to fetch is age restricted. See https://github.com/jsanahuja/InstagramFeed/issues/26",3):!1!==(a=o(e,!0))?t(a):e.on_error("Instagram Feed: Unable to fetch the given user/tag. Instagram responded with the status code: "+i.status,5)},e.host===a.host&&"userid"!=e.type,!1)}}e.instagramFeed=function(o){var n=e.fn.extend({},a,o);return""==n.username&&""==n.tag&&""==n.user_id&&""==n.location?(n.on_error("Instagram Feed: Error, no username, tag or user_id defined.",1),!1):(void 0!==o.display_profile&&o.display_profile&&""!=n.user_id&&console.warn("Instagram Feed: 'display_profile' is not available using 'user_id' (GraphQL API)"),void 0===o.display_biography||!o.display_biography||""==n.tag&&""==n.location&&""==n.user_id||console.warn("Instagram Feed: 'display_biography' is not available unless you are loading an user ('username' parameter)"),void 0!==n.get_data&&console.warn("Instagram Feed: options.get_data is deprecated, options.callback is always called if defined"),null==n.callback&&""==n.container?(n.on_error("Instagram Feed: Error, neither container found nor callback defined.",2),!1):(""!=n.username?(n.type="username",n.id=n.username):""!=n.tag?(n.type="tag",n.id=n.tag):""!=n.location?(n.type="location",n.id=n.location):(n.type="userid",n.id=n.user_id),n.cache_data_key="instagramFeed_"+n.type+"_"+n.id,n.cache_time_key=n.cache_data_key+"_time",s(n,function(a){""!=n.container&&function(a,o){var n,s="";if(a.display_gallery)if(void 0!==o.is_private&&!0===o.is_private)s+='
This profile is private
';else for(var r=void 0!==t[a.image_size]?t[a.image_size]:t[640],l=(o.edge_owner_to_timeline_media||o.edge_hashtag_to_media||o.edge_location_to_media).edges,d=l.length>a.items?a.items:l.length,c=0;c"'`=\/]/g,function(e){return i[e]}),l[c].node.__typename){case"GraphSidecar":g="sidecar",_=l[c].node.thumbnail_resources[r].src;break;case"GraphVideo":g="video",_=l[c].node.thumbnail_src;break;default:g="image",_=l[c].node.thumbnail_resources[r].src}s+=""}e(a.container).html(s)}(n,a),null!=n.callback&&n.callback(a)}),!0))}}(jQuery);
/* instafeed.js | v2.0.0-rc3 | https://github.com/stevenschobert/instafeed.js | License: MIT */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Instafeed=t()}(this,function(){"use strict";function e(e,t){if(!e)throw new Error(t)}function t(t){e(!t||"object"==typeof t,"options must be an object, got "+t+" ("+typeof t+")");var o={accessToken:null,accessTokenTimeout:1e4,after:null,apiTimeout:1e4,apiLimit:null,before:null,debug:!1,error:null,filter:null,limit:null,mock:!1,render:null,sort:null,success:null,target:"instafeed",template:'',templateBoundaries:["{{","}}"],transform:null};if(t)for(var n in o)"undefined"!=typeof t[n]&&(o[n]=t[n]);e("string"==typeof o.target||"object"==typeof o.target,"target must be a string or DOM node, got "+o.target+" ("+typeof o.target+")"),e("string"==typeof o.accessToken||"function"==typeof o.accessToken,"accessToken must be a string or function, got "+o.accessToken+" ("+typeof o.accessToken+")"),e("number"==typeof o.accessTokenTimeout,"accessTokenTimeout must be a number, got "+o.accessTokenTimeout+" ("+typeof o.accessTokenTimeout+")"),e("number"==typeof o.apiTimeout,"apiTimeout must be a number, got "+o.apiTimeout+" ("+typeof o.apiTimeout+")"),e("boolean"==typeof o.debug,"debug must be true or false, got "+o.debug+" ("+typeof o.debug+")"),e("boolean"==typeof o.mock,"mock must be true or false, got "+o.mock+" ("+typeof o.mock+")"),e("object"==typeof o.templateBoundaries&&2===o.templateBoundaries.length&&"string"==typeof o.templateBoundaries[0]&&"string"==typeof o.templateBoundaries[1],"templateBoundaries must be an array of 2 strings, got "+o.templateBoundaries+" ("+typeof o.templateBoundaries+")"),e(!o.template||"string"==typeof o.template,"template must null or string, got "+o.template+" ("+typeof o.template+")"),e(!o.error||"function"==typeof o.error,"error must be null or function, got "+o.error+" ("+typeof o.error+")"),e(!o.before||"function"==typeof o.before,"before must be null or function, got "+o.before+" ("+typeof o.before+")"),e(!o.after||"function"==typeof o.after,"after must be null or function, got "+o.after+" ("+typeof o.after+")"),e(!o.success||"function"==typeof o.success,"success must be null or function, got "+o.success+" ("+typeof o.success+")"),e(!o.filter||"function"==typeof o.filter,"filter must be null or function, got "+o.filter+" ("+typeof o.filter+")"),e(!o.transform||"function"==typeof o.transform,"transform must be null or function, got "+o.transform+" ("+typeof o.transform+")"),e(!o.sort||"function"==typeof o.sort,"sort must be null or function, got "+o.sort+" ("+typeof o.sort+")"),e(!o.render||"function"==typeof o.render,"render must be null or function, got "+o.render+" ("+typeof o.render+")"),e(!o.limit||"number"==typeof o.limit,"limit must be null or number, got "+o.limit+" ("+typeof o.limit+")"),e(!o.apiLimit||"number"==typeof o.apiLimit,"apiLimit must null or number, got "+o.apiLimit+" ("+typeof o.apiLimit+")"),this._state={running:!1,node:null,token:null,paging:null,pool:[]},this._options=o}return t.prototype.run=function(){var e=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(t,o){if(t)return e._debug("onTokenReceived","error",t),void e._fail(new Error("error getting access token: "+t.message));e._debug("onTokenReceived","got token",o),e._state.token=o,e._showNext(function(t){if(t)return e._debug("onNextShown","error",t),void e._fail(t);e._finish()})}),!0):(this._fail(new Error("no element found with ID "+this._options.target)),!1))},t.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),t.length>0||e&&"string"==typeof e.next},t.prototype.next=function(){var e=this;return e.hasNext()?e._state.running?(e._debug("next","already running, skipping"),!1):(e._start(),void e._showNext(function(t){if(t)return e._debug("onNextShown","error",t),void e._fail(t);e._finish()})):(e._debug("next","hasNext is false, skipping"),!1)},t.prototype._showNext=function(e){var t=this,o=null,n=null,i="number"==typeof this._options.limit;if(t._debug("showNext","pool",t._state.pool.length,t._state.pool),t._state.pool.length>0){if(n=i?t._state.pool.splice(0,t._options.limit):t._state.pool.splice(0),t._debug("showNext","items from pool",n.length,n),t._debug("showNext","updated pool",t._state.pool.length,t._state.pool),t._options.mock)t._debug("showNext","mock enabled, skipping render");else try{t._renderData(n)}catch(s){return void e(s)}e(null)}else t._state.paging&&"string"==typeof t._state.paging.next?o=t._state.paging.next:(o="https://graph.instagram.com/me/media?fields=caption,id,media_type,media_url,permalink,thumbnail_url,timestamp,username&access_token="+t._state.token,t._options.apiLimit||"number"!=typeof t._options.limit?"number"==typeof t._options.apiLimit&&(t._debug("showNext","apiLimit set, overriding limit",t._options.apiLimit,t._options.limit),o=o+"&limit="+t._options.apiLimit):(t._debug("showNext","no apiLimit set, falling back to limit",t._options.apiLimit,t._options.limit),o=o+"&limit="+t._options.limit)),t._debug("showNext","making request",o),t._makeApiRequest(o,function(o,n){var i=null;if(o)return t._debug("onResponseReceived","error",o),void e(new Error("api request error: "+o.message));t._debug("onResponseReceived","data",n),t._success(n),t._debug("onResponseReceived","setting paging",n.paging),t._state.paging=n.paging;try{if(i=t._processData(n),t._debug("onResponseReceived","processed data",i),i.unused&&i.unused.length>0){t._debug("onResponseReceived","saving unused to pool",i.unused.length,i.unused);for(var r=0;r0&&(p=s.slice(s.length-r),this._debug("processData","unusedItems",p.length,p),s.splice(s.length-r,r))),{items:s,unused:p}},t.prototype._extractTags=function(e){var t=/#([^\s]+)/gi,o=/[~`!@#$%^&*\(\)\-\+={}\[\]:;"'<>\?,\./|\\\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},t.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}},t.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;a0;)this._debug("renderData","appending child",s.childNodes[0]),this._state.node.appendChild(s.childNodes[0])}},t.prototype._basicRender=function(e){for(var t=new RegExp(this._options.templateBoundaries[0]+"([\\s\\w.]+)"+this._options.templateBoundaries[1],"gm"),o=this._options.template,n=null,i="",s=0,r=null,a=null;null!==(n=t.exec(o));)r=n[1],i+=o.slice(s,n.index),(a=this._valueForKeyPath(r,e))&&(i+=a.toString()),s=t.lastIndex;return s=0)try{o=JSON.parse(i.responseText)}catch(r){return n._debug("apiRequestOnLoad","json parsing error",r,i.responseText),void s(new Error("error parsing response json"))}200===i.status?s(null,o):o&&o.error?s(new Error(o.error.code+" "+o.error.message)):s(new Error("status code "+i.status))},i.open("GET",e,!0),i.timeout=this._options.apiTimeout,i.send()},t.prototype._getAccessToken=function(e){var t=!1,o=this,n=null,i=function(o,i){t||(t=!0,clearTimeout(n),e(o,i))};if("function"==typeof this._options.accessToken){this._debug("getAccessToken","calling accessToken as function"),n=setTimeout(function(){o._debug("getAccessToken","timeout check",t),i(new Error("accessToken timed out"),null)},this._options.accessTokenTimeout);try{this._options.accessToken(function(e,n){o._debug("getAccessToken","received accessToken callback",t,e,n),i(e,n)})}catch(s){this._debug("getAccessToken","error invoking the accessToken as function",s),i(s,null)}}else this._debug("getAccessToken","treating accessToken as static",typeof this._options.accessToken),i(null,this._options.accessToken)},t.prototype._debug=function(){var e=null;this._options.debug&&console&&"function"==typeof console.log&&((e=[].slice.call(arguments))[0]="[Instafeed] ["+e[0]+"]",console.log.apply(null,e))},t.prototype._runHook=function(e,t){var o=!1;if("function"==typeof this._options[e])try{this._options[e](t),o=!0}catch(n){this._debug("runHook","error calling hook",e,n)}return o},t});