From e33c18a222a3ec88ce6947b4f11b4f04e4f08c08 Mon Sep 17 00:00:00 2001 From: Sujit Kumar Date: Mon, 26 Jul 2021 22:18:09 +0530 Subject: [PATCH] Minor fix --- js/dist/forum.js | 2 +- js/dist/forum.js.map | 2 +- js/src/forum/components/GIFModal.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/dist/forum.js b/js/dist/forum.js index c14740e..df7c38f 100755 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,2 +1,2 @@ -module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=16)}([function(t,e,n){t.exports=n(13)},function(t,e){t.exports=flarum.core.compat.app},function(t,e,n){"use strict";function r(t,e,n,r,i,o,s){try{var a=t[o](s),u=a.value}catch(t){return void n(t)}a.done?e(u):Promise.resolve(u).then(r,i)}function i(t){return function(){var e=this,n=arguments;return new Promise((function(i,o){var s=t.apply(e,n);function a(t){r(s,i,o,a,u,"next",t)}function u(t){r(s,i,o,a,u,"throw",t)}a(void 0)}))}}n.d(e,"a",(function(){return i}))},function(t,e){t.exports=flarum.core.compat["common/app"]},function(t,e){t.exports=flarum.core.compat["common/components/Button"]},function(t,e){t.exports=flarum.core.compat["common/Component"]},function(t,e){t.exports=flarum.core.compat.Model},function(t,e){t.exports=flarum.core.compat["common/extend"]},function(t,e){t.exports=flarum.core.compat["common/components/TextEditor"]},function(t,e){t.exports=flarum.core.compat["common/components/TextEditorButton"]},function(t,e){t.exports=flarum.core.compat["common/components/Modal"]},function(t,e){t.exports=flarum.core.compat["common/components/Tooltip"]},function(t,e){t.exports=flarum.core.compat["common/utils/Stream"]},function(t,e,n){var r=function(t){"use strict";var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",s=r.toStringTag||"@@toStringTag";function a(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,n){return t[e]=n}}function u(t,e,n,r){var i=e&&e.prototype instanceof l?e:l,o=Object.create(i.prototype),s=new k(r||[]);return o._invoke=function(t,e,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return F()}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var a=w(s,n);if(a){if(a===h)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=c(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(t,n,s),o}function c(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var h={};function l(){}function f(){}function p(){}var d={};d[i]=function(){return this};var m=Object.getPrototypeOf,g=m&&m(m(j([])));g&&g!==e&&n.call(g,i)&&(d=g);var v=p.prototype=l.prototype=Object.create(d);function y(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var r;this._invoke=function(i,o){function s(){return new e((function(r,s){!function r(i,o,s,a){var u=c(t[i],t,o);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,s,a)}),(function(t){r("throw",t,s,a)})):e.resolve(l).then((function(t){h.value=t,s(h)}),(function(t){return r("throw",t,s,a)}))}a(u.arg)}(i,o,r,s)}))}return r=r?r.then(s,s):s()}}function w(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var r=c(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,h;var i=r.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function j(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(a&&u){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),L(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:j(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}},function(t,e,n){"use strict";n.r(e),n.d(e,"initialize",(function(){return s})),n.d(e,"getTrendingTerms",(function(){return a})),n.d(e,"getTrendingGIFs",(function(){return c})),n.d(e,"getGIFs",(function(){return l})),n.d(e,"getGIFsByIDs",(function(){return p})),n.d(e,"extractGIF",(function(){return m})),n.d(e,"getLimit",(function(){return g}));var r=n(2),i=n(0),o=n.n(i);function s(t,e){this.baseUrl="https://g.tenor.com/v1",this.defaultLimit=10,this.apiKey=t,this.rating=e}function a(){return u.apply(this,arguments)}function u(){return(u=Object(r.a)(o.a.mark((function t(){var e,n;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.baseUrl+"/trending_terms?key="+this.apiKey,t.next=3,fetch(n).then((function(t){return t.json()})).then((function(t){void 0!==t.results?e=t.results:console.error("Sorry, there was something wrong with the Tenor API Key.")}));case 3:return t.abrupt("return",e);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function c(t,e){return h.apply(this,arguments)}function h(){return(h=Object(r.a)(o.a.mark((function t(e,n){var r,i;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this.baseUrl+"/trending?key="+this.apiKey+"&contentfilter="+this.rating+"&media_filter=minimal&limit="+(n||this.defaultLimit)+(e?"&pos="+e:""),t.next=3,fetch(i).then((function(t){return t.json()})).then((function(t){void 0!==t.results?r={gifs:t.results,next:t.next}:console.error("Sorry, there was something wrong with the Tenor API Key.")}));case 3:return t.abrupt("return",r);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function l(t,e,n){return f.apply(this,arguments)}function f(){return(f=Object(r.a)(o.a.mark((function t(e,n,r){var i,s;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=this.baseUrl+"/search?key="+this.apiKey+"&q="+e+"&contentfilter="+this.rating+"&media_filter=minimal&limit="+(r||this.defaultLimit)+(n?"&pos="+n:""),t.next=3,fetch(s).then((function(t){return t.json()})).then((function(t){void 0!==t.results?i={gifs:t.results,next:t.next}:console.error("Sorry, there was something wrong with the Tenor API Key.")}));case 3:return t.abrupt("return",i);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function p(t){return d.apply(this,arguments)}function d(){return(d=Object(r.a)(o.a.mark((function t(e){var n,r;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.baseUrl+"/gifs?key="+this.apiKey+"&ids="+e+"&media_filter=minimal",t.next=3,fetch(r).then((function(t){return t.json()})).then((function(t){n=t.results}));case 3:return t.abrupt("return",n);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function m(t){return{id:t.id,title:t.title,url:t.media[0].gif.url}}function g(){return this.defaultLimit}},function(t,e,n){"use strict";n.r(e),n.d(e,"initialize",(function(){return s})),n.d(e,"getTrendingTerms",(function(){return a})),n.d(e,"getTrendingGIFs",(function(){return c})),n.d(e,"getGIFs",(function(){return l})),n.d(e,"getGIFsByIDs",(function(){return p})),n.d(e,"extractGIF",(function(){return m})),n.d(e,"getLimit",(function(){return g}));var r=n(2),i=n(0),o=n.n(i);function s(t,e){this.baseUrl="https://api.giphy.com/v1",this.defaultLimit=10,this.apiKey=t,this.rating="off"===e?"r":"low"===e?"pg-13":"medium"===e?"pg":"g"}function a(){return u.apply(this,arguments)}function u(){return(u=Object(r.a)(o.a.mark((function t(){var e,n;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.baseUrl+"/trending/searches?api_key="+this.apiKey,t.next=3,fetch(n).then((function(t){return t.json()})).then((function(t){void 0!==t.data?e=t.data:console.error("Sorry, there was something wrong with the Giphy API Key.")}));case 3:return t.abrupt("return",e);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function c(t,e){return h.apply(this,arguments)}function h(){return(h=Object(r.a)(o.a.mark((function t(e,n){var r,i,s=this;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this.baseUrl+"/gifs/trending?api_key="+this.apiKey+"&rating="+this.rating+"&limit="+(n||this.defaultLimit)+(e?"&offset="+e:""),t.next=3,fetch(i).then((function(t){return t.json()})).then((function(t){void 0!==t.data?r={gifs:t.data,next:e+(n||s.defaultLimit)}:console.error("Sorry, there was something wrong with the Tenor API Key.")}));case 3:return t.abrupt("return",r);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function l(t,e,n){return f.apply(this,arguments)}function f(){return(f=Object(r.a)(o.a.mark((function t(e,n,r){var i,s,a=this;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=this.baseUrl+"/gifs/search?api_key="+this.apiKey+"&rating="+this.rating+"&q="+e+"&limit="+(r||this.defaultLimit)+(n?"&offset="+n:""),t.next=3,fetch(s).then((function(t){return t.json()})).then((function(t){void 0!==t.data?i={gifs:t.data,next:n+(r||a.defaultLimit)}:console.error("Sorry, there was something wrong with the Tenor API Key.")}));case 3:return t.abrupt("return",i);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function p(t){return d.apply(this,arguments)}function d(){return(d=Object(r.a)(o.a.mark((function t(e){var n,r;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.baseUrl+"/gifs?api_key="+this.apiKey+"&ids="+e,t.next=3,fetch(r).then((function(t){return t.json()})).then((function(t){n=t.data}));case 3:return t.abrupt("return",n);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function m(t){return{id:t.id,title:t.title,url:t.images.original.url}}function g(){return this.defaultLimit}},function(t,e,n){"use strict";n.r(e);var r=n(7),i=n(3),o=n.n(i),s=n(8),a=n.n(s),u=n(9),c=n.n(u),h=n(2);function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,l(t,e)}var p=n(0),d=n.n(p),g=n(1),v=n.n(g),y=n(4),b=n.n(y),w=n(5),x=n.n(w),L=function(t){function e(){return t.apply(this,arguments)||this}return f(e,t),e.prototype.view=function(){var t=this.attrs.attributes,e=t.title,n=t.url,r=t.icon,i=t.onclick;return m("div",{style:n&&"background-image: url("+n+")",onclick:i},r&&m("i",{class:r})," ",e)},e}(x.a),k=n(10),j=n.n(k),F=n(11),B=n.n(F),E=function(t){function e(){return t.apply(this,arguments)||this}f(e,t);var n=e.prototype;return n.oninit=function(e){var n=this;t.prototype.oninit.call(this,e),this.loading=!1,this.hidden=!0,this.rowSpan=15*Math.random()+25,this.id,$(window).resize((function(){n.hidden||n.setRowSpan(n.$("img",n)[0])}))},n.view=function(){var t=this,e=this.attrs.attributes;this.id=e.id,this.favourite=e.favourite;var n=e.title,r=e.url,i=e.onclick;return e.isFavourite&&(this.hidden||this.setRowSpan(this.$("img",this)[0])),m("div",{style:this.rowSpan&&"grid-row-end: span "+Math.round(this.rowSpan)},m("img",{alt:n,src:r,style:this.hidden?"visibility: hidden":"",onclick:function(e){i(e,t.id)},onload:function(e){t.setRowSpan(e.target)}}),m(B.a,{showOnFocus:!1,text:e.isFavourite?v.a.translator.trans("therealsujitk-gifs.forum.removeFavourite"):v.a.translator.trans("therealsujitk-gifs.forum.addFavourite")},m(b.a,{className:"Button Button--icon hasIcon",style:this.hidden?"visibility: hidden":"",icon:this.loading?"":e.isFavourite?"fas fa-star":"far fa-star",loading:this.loading,onclick:this.handleFavourite.bind(this)})))},n.setRowSpan=function(t){this.rowSpan=t.height/5+2,this.hidden=!1},n.handleFavourite=function(){var t=Object(h.a)(d.a.mark((function t(){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.loading=!0,t.next=3,this.favourite(this.id);case 3:t.sent&&(this.attrs.attributes.isFavourite=!this.attrs.attributes.isFavourite),this.loading=!1,m.redraw();case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(x.a),T=n(12),I=n.n(T),O="therealsujitk-gifs",P=function(t){function e(){return t.apply(this,arguments)||this}f(e,t);var r=e.prototype;return r.oninit=function(e){t.prototype.oninit.call(this,e),this.textArea=this.attrs.textArea,this.baseUrl=v.a.forum.attribute("baseUrl"),this.engine=v.a.forum.attribute(O+".engine"),this.apiKey=v.a.forum.attribute(O+".api_key"),this.rating=v.a.forum.attribute(O+".rating"),this.Engine=this.getEngine(),this.Engine.initialize(this.apiKey,this.rating),this.isHomeVisible=!0,this.isFavouritesVisible=!1,this.isTrendingVisible=!1,this.isResultsVisible=!1,this.category="",this.query=I()(""),this.next=null,this.favourites=new Set,this.homeButtons=new Array,this.favouriteButtons=new Array,this.resultButtons=new Array,this.loadHomePage(),this.loadFavouritesPage(),this.loading=!1,this.reachedEnd=!1},r.className=function(){return O+"-modal"},r.title=function(){return"Select a GIF to add to your post"},r.content=function(){var t=this;return m("div",{className:"Modal-body"},m("div",{style:"display: flex;"},m(b.a,{id:O+"-back-button",className:"Button Button--icon hasIcon",style:this.isHomeVisible?"display: none":"",icon:"fas fa-long-arrow-alt-left",onclick:this.showHome.bind(this)}),m("span",{id:O+"-category",style:this.isFavouritesVisible||this.isTrendingVisible?"":"display: none"},this.category&&this.category),m("div",{id:O+"-search-input",className:"Search-input",style:this.isHomeVisible||this.isResultsVisible?"":"display: none"},m("input",{className:"FormControl",placeholder:this.getPlaceholder(),value:this.query(),bidi:this.query,onkeydown:this.onkeydown.bind(this)})),m(b.a,{id:O+"-search-button",className:"Button Button--primary",style:this.isHomeVisible||this.isResultsVisible?"":"display: none",onclick:function(){t.resetResultsPage(),t.loadResultsPage()}},v.a.translator.trans(O+".forum.search"))),m("div",{className:O+"-container",style:this.isHomeVisible?"":"display: none"},this.homeButtons&&this.homeButtons.map((function(t){return m(L,{attributes:t})}))),m("div",{className:O+"-container",style:this.isFavouritesVisible?"":"display: none",scrollTop:this.isTrendingVisible||this.isResultsVisible?"0":""},this.favouriteButtons&&this.favouriteButtons.map((function(t){return m(E,{attributes:t})})),m("span",{id:O+"-end"},"You've reached the end")),m("div",{className:O+"-container",style:this.isTrendingVisible||this.isResultsVisible?"":"display: none",onscroll:this.loadMore.bind(this),scrollTop:this.isTrendingVisible||this.isResultsVisible?"0":""},this.resultButtons&&this.resultButtons.map((function(t){return m(E,{attributes:t})})),m("span",{id:O+"-end"},"You've reached the end")),m("div",{id:O+"-footer"},m("img",{src:this.baseUrl+"/assets/extensions/therealsujitk-gifs/powered_by_"+this.engine+".svg"})))},r.getEngine=function(){return"tenor"===this.engine?n(14):n(15)},r.getPlaceholder=function(){return"tenor"==this.engine?v.a.translator.trans(O+".forum.searchTenor"):v.a.translator.trans(O+".forum.searchGiphy")},r.showHome=function(){this.isFavouritesVisible=!1,this.isTrendingVisible=!1,this.isResultsVisible=!1,this.isHomeVisible=!0,this.query(""),this.resetResultsPage()},r.showFavourites=function(){this.isHomeVisible=!1,this.isResultsVisible=!1,this.isTrendingVisible=!1,this.isFavouritesVisible=!0,this.category=v.a.translator.trans(O+".forum.favourites")},r.showTrending=function(){this.isHomeVisible=!1,this.isFavouritesVisible=!1,this.isResultsVisible=!1,this.isTrendingVisible=!0,this.category=v.a.translator.trans(O+".forum.trending")},r.showResults=function(){this.isHomeVisible=!1,this.isFavouritesVisible=!1,this.isTrendingVisible=!1,this.isResultsVisible=!0},r.loadHomePage=function(){var t=Object(h.a)(d.a.mark((function t(){var e,n,r,i,o,s=this;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e={title:v.a.translator.trans(O+".forum.favourites"),icon:"fas fa-star",onclick:function(){s.showFavourites()}},n={title:v.a.translator.trans(O+".forum.trending"),icon:"fas fa-chart-line",onclick:function(){s.loadTrendingPage()}},this.injectGIFs(null,1,"home",1),this.homeButtons.push(e,n),t.next=6,this.Engine.getTrendingTerms();case 6:for(r=t.sent,i=0;i=n-200&&(this.loading=!0,this.isResultsVisible?this.loadResultsPage():this.loadTrendingPage())}},r.injectGIFs=function(){var t=Object(h.a)(d.a.mark((function t(e,n,r,i){var o,s,a,u,c,l=this;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("favourite"!==r){t.next=6;break}return t.next=3,this.Engine.getGIFsByIDs(e);case 3:o=t.sent,t.next=19;break;case 6:if("trending"!==r&&null!=e){t.next=14;break}return t.next=9,this.Engine.getTrendingGIFs(this.next,i);case 9:s=t.sent,o=s.gifs,!i&&(this.next=s.next),t.next=19;break;case 14:return t.next=16,this.Engine.getGIFs(e,this.next,i);case 16:s=t.sent,o=s.gifs,!i&&(this.next=s.next);case 19:a=0;case 20:if(!(a<(i||this.Engine.getLimit()))){t.next=36;break}if(void 0!==o[a]){t.next=24;break}return"favourite"===r?this.favouriteButtons.splice(n+a):"result"===r&&(this.resultButtons.splice(n+a),this.reachedEnd=!0),t.abrupt("break",36);case 24:u=this.Engine.extractGIF(o[a]),(c={}).id=u.id,c.title=u.title,c.url=u.url,c.isFavourite=this.favourites.has(u.id),c.onclick=function(t,e){var n=t.target.alt,r=t.target.src,i="!["+l.engine[0].toUpperCase()+l.engine.slice(1)+" - "+n+"]("+r+")";if(l.textArea.insertAtCursor(i),v.a.modal.close(),"tenor"===l.engine){r="https://g.tenor.com/v1/registershare?&key="+l.apiKey+(""!=l.query()?"&q="+l.query():"")+"&id="+e;fetch(r)}},c.favourite=function(){var t=Object(h.a)(d.a.mark((function t(e){var n;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=!1,!l.favourites.has(e)){t.next=6;break}return t.next=4,v.a.request({method:"DELETE",url:v.a.forum.attribute("apiUrl")+"/"+O+"/"+e}).then((function(){var t=l.favouriteButtons.findIndex((function(t){return t.id===e}));l.favouriteButtons.splice(t,1),l.favourites.delete(e),0==l.favouriteButtons.length?delete l.homeButtons[0].url:l.homeButtons[0].url=l.favouriteButtons[0].url,n=!0}));case 4:t.next=8;break;case 6:return t.next=8,v.a.store.createRecord(O).save({gifID:e}).then((function(){l.injectGIFs(e,0,"favourite",1),l.favourites.add(e),n=!0}));case 8:return t.abrupt("return",n);case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),"home"===r?this.homeButtons[n+a].url=u.url:"favourite"===r?(this.favouriteButtons[n+a]&&void 0===this.favouriteButtons[n+a].url?Object.assign(this.favouriteButtons[n+a],c):this.favouriteButtons.unshift(c),n+a==0&&(this.homeButtons[0].url=u.url)):Object.assign(this.resultButtons[n+a],c);case 33:++a,t.next=20;break;case 36:m.redraw();case 37:case"end":return t.stop()}}),t,this)})));return function(e,n,r,i){return t.apply(this,arguments)}}(),r.onsubmit=function(t){t.preventDefault()},r.onkeydown=function(t){"Enter"===t.key&&(this.query(this.query().trim()),""===this.query()?this.showHome():(this.resetResultsPage(),this.loadResultsPage()))},e}(j.a),V=n(6),_=n.n(V),G=function(t){function e(){for(var e,n=arguments.length,r=new Array(n),i=0;i=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(a&&u){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),L(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:j(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}},function(t,e,n){"use strict";n.r(e),n.d(e,"initialize",(function(){return s})),n.d(e,"getTrendingTerms",(function(){return a})),n.d(e,"getTrendingGIFs",(function(){return c})),n.d(e,"getGIFs",(function(){return l})),n.d(e,"getGIFsByIDs",(function(){return p})),n.d(e,"extractGIF",(function(){return m})),n.d(e,"getLimit",(function(){return g}));var r=n(2),i=n(0),o=n.n(i);function s(t,e){this.baseUrl="https://g.tenor.com/v1",this.defaultLimit=10,this.apiKey=t,this.rating=e}function a(){return u.apply(this,arguments)}function u(){return(u=Object(r.a)(o.a.mark((function t(){var e,n;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.baseUrl+"/trending_terms?key="+this.apiKey,t.next=3,fetch(n).then((function(t){return t.json()})).then((function(t){void 0!==t.results?e=t.results:console.error("Sorry, there was something wrong with the Tenor API Key.")}));case 3:return t.abrupt("return",e);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function c(t,e){return h.apply(this,arguments)}function h(){return(h=Object(r.a)(o.a.mark((function t(e,n){var r,i;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this.baseUrl+"/trending?key="+this.apiKey+"&contentfilter="+this.rating+"&media_filter=minimal&limit="+(n||this.defaultLimit)+(e?"&pos="+e:""),t.next=3,fetch(i).then((function(t){return t.json()})).then((function(t){void 0!==t.results?r={gifs:t.results,next:t.next}:console.error("Sorry, there was something wrong with the Tenor API Key.")}));case 3:return t.abrupt("return",r);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function l(t,e,n){return f.apply(this,arguments)}function f(){return(f=Object(r.a)(o.a.mark((function t(e,n,r){var i,s;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=this.baseUrl+"/search?key="+this.apiKey+"&q="+e+"&contentfilter="+this.rating+"&media_filter=minimal&limit="+(r||this.defaultLimit)+(n?"&pos="+n:""),t.next=3,fetch(s).then((function(t){return t.json()})).then((function(t){void 0!==t.results?i={gifs:t.results,next:t.next}:console.error("Sorry, there was something wrong with the Tenor API Key.")}));case 3:return t.abrupt("return",i);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function p(t){return d.apply(this,arguments)}function d(){return(d=Object(r.a)(o.a.mark((function t(e){var n,r;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.baseUrl+"/gifs?key="+this.apiKey+"&ids="+e+"&media_filter=minimal",t.next=3,fetch(r).then((function(t){return t.json()})).then((function(t){n=t.results}));case 3:return t.abrupt("return",n);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function m(t){return{id:t.id,title:t.title,url:t.media[0].gif.url}}function g(){return this.defaultLimit}},function(t,e,n){"use strict";n.r(e),n.d(e,"initialize",(function(){return s})),n.d(e,"getTrendingTerms",(function(){return a})),n.d(e,"getTrendingGIFs",(function(){return c})),n.d(e,"getGIFs",(function(){return l})),n.d(e,"getGIFsByIDs",(function(){return p})),n.d(e,"extractGIF",(function(){return m})),n.d(e,"getLimit",(function(){return g}));var r=n(2),i=n(0),o=n.n(i);function s(t,e){this.baseUrl="https://api.giphy.com/v1",this.defaultLimit=10,this.apiKey=t,this.rating="off"===e?"r":"low"===e?"pg-13":"medium"===e?"pg":"g"}function a(){return u.apply(this,arguments)}function u(){return(u=Object(r.a)(o.a.mark((function t(){var e,n;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.baseUrl+"/trending/searches?api_key="+this.apiKey,t.next=3,fetch(n).then((function(t){return t.json()})).then((function(t){void 0!==t.data?e=t.data:console.error("Sorry, there was something wrong with the Giphy API Key.")}));case 3:return t.abrupt("return",e);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function c(t,e){return h.apply(this,arguments)}function h(){return(h=Object(r.a)(o.a.mark((function t(e,n){var r,i,s=this;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this.baseUrl+"/gifs/trending?api_key="+this.apiKey+"&rating="+this.rating+"&limit="+(n||this.defaultLimit)+(e?"&offset="+e:""),t.next=3,fetch(i).then((function(t){return t.json()})).then((function(t){void 0!==t.data?r={gifs:t.data,next:e+(n||s.defaultLimit)}:console.error("Sorry, there was something wrong with the Tenor API Key.")}));case 3:return t.abrupt("return",r);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function l(t,e,n){return f.apply(this,arguments)}function f(){return(f=Object(r.a)(o.a.mark((function t(e,n,r){var i,s,a=this;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=this.baseUrl+"/gifs/search?api_key="+this.apiKey+"&rating="+this.rating+"&q="+e+"&limit="+(r||this.defaultLimit)+(n?"&offset="+n:""),t.next=3,fetch(s).then((function(t){return t.json()})).then((function(t){void 0!==t.data?i={gifs:t.data,next:n+(r||a.defaultLimit)}:console.error("Sorry, there was something wrong with the Tenor API Key.")}));case 3:return t.abrupt("return",i);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function p(t){return d.apply(this,arguments)}function d(){return(d=Object(r.a)(o.a.mark((function t(e){var n,r;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.baseUrl+"/gifs?api_key="+this.apiKey+"&ids="+e,t.next=3,fetch(r).then((function(t){return t.json()})).then((function(t){n=t.data}));case 3:return t.abrupt("return",n);case 4:case"end":return t.stop()}}),t,this)})))).apply(this,arguments)}function m(t){return{id:t.id,title:t.title,url:t.images.original.url}}function g(){return this.defaultLimit}},function(t,e,n){"use strict";n.r(e);var r=n(7),i=n(3),o=n.n(i),s=n(8),a=n.n(s),u=n(9),c=n.n(u),h=n(2);function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,l(t,e)}var p=n(0),d=n.n(p),g=n(1),v=n.n(g),y=n(4),b=n.n(y),w=n(5),x=n.n(w),L=function(t){function e(){return t.apply(this,arguments)||this}return f(e,t),e.prototype.view=function(){var t=this.attrs.attributes,e=t.title,n=t.url,r=t.icon,i=t.onclick;return m("div",{style:n&&"background-image: url("+n+")",onclick:i},r&&m("i",{class:r})," ",e)},e}(x.a),k=n(10),j=n.n(k),F=n(11),B=n.n(F),E=function(t){function e(){return t.apply(this,arguments)||this}f(e,t);var n=e.prototype;return n.oninit=function(e){var n=this;t.prototype.oninit.call(this,e),this.loading=!1,this.hidden=!0,this.rowSpan=15*Math.random()+25,this.id,$(window).resize((function(){n.hidden||n.setRowSpan(n.$("img",n)[0])}))},n.view=function(){var t=this,e=this.attrs.attributes;this.id=e.id,this.favourite=e.favourite;var n=e.title,r=e.url,i=e.onclick;return e.isFavourite&&(this.hidden||this.setRowSpan(this.$("img",this)[0])),m("div",{style:this.rowSpan&&"grid-row-end: span "+Math.round(this.rowSpan)},m("img",{alt:n,src:r,style:this.hidden?"visibility: hidden":"",onclick:function(e){i(e,t.id)},onload:function(e){t.setRowSpan(e.target)}}),m(B.a,{showOnFocus:!1,text:e.isFavourite?v.a.translator.trans("therealsujitk-gifs.forum.removeFavourite"):v.a.translator.trans("therealsujitk-gifs.forum.addFavourite")},m(b.a,{className:"Button Button--icon hasIcon",style:this.hidden?"visibility: hidden":"",icon:this.loading?"":e.isFavourite?"fas fa-star":"far fa-star",loading:this.loading,onclick:this.handleFavourite.bind(this)})))},n.setRowSpan=function(t){this.rowSpan=t.height/5+2,this.hidden=!1},n.handleFavourite=function(){var t=Object(h.a)(d.a.mark((function t(){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.loading=!0,t.next=3,this.favourite(this.id);case 3:t.sent&&(this.attrs.attributes.isFavourite=!this.attrs.attributes.isFavourite),this.loading=!1,m.redraw();case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}(x.a),T=n(12),I=n.n(T),O="therealsujitk-gifs",P=function(t){function e(){return t.apply(this,arguments)||this}f(e,t);var r=e.prototype;return r.oninit=function(e){t.prototype.oninit.call(this,e),this.textArea=this.attrs.textArea,this.baseUrl=v.a.forum.attribute("baseUrl"),this.engine=v.a.forum.attribute(O+".engine"),this.apiKey=v.a.forum.attribute(O+".api_key"),this.rating=v.a.forum.attribute(O+".rating"),this.Engine=this.getEngine(),this.Engine.initialize(this.apiKey,this.rating),this.isHomeVisible=!0,this.isFavouritesVisible=!1,this.isTrendingVisible=!1,this.isResultsVisible=!1,this.category="",this.query=I()(""),this.next=null,this.favourites=new Set,this.homeButtons=new Array,this.favouriteButtons=new Array,this.resultButtons=new Array,this.loadHomePage(),this.loadFavouritesPage(),this.loading=!1,this.reachedEnd=!1},r.className=function(){return O+"-modal"},r.title=function(){return"Select a GIF to add to your post"},r.content=function(){var t=this;return m("div",{className:"Modal-body"},m("div",{style:"display: flex;"},m(b.a,{id:O+"-back-button",className:"Button Button--icon hasIcon",style:this.isHomeVisible?"display: none":"",icon:"fas fa-long-arrow-alt-left",onclick:this.showHome.bind(this)}),m("span",{id:O+"-category",style:this.isFavouritesVisible||this.isTrendingVisible?"":"display: none"},this.category&&this.category),m("div",{id:O+"-search-input",className:"Search-input",style:this.isHomeVisible||this.isResultsVisible?"":"display: none"},m("input",{className:"FormControl",placeholder:this.getPlaceholder(),value:this.query(),bidi:this.query,onkeydown:this.onkeydown.bind(this)})),m(b.a,{id:O+"-search-button",className:"Button Button--primary",style:this.isHomeVisible||this.isResultsVisible?"":"display: none",onclick:function(){t.resetResultsPage(),t.loadResultsPage()}},v.a.translator.trans(O+".forum.search"))),m("div",{className:O+"-container",style:this.isHomeVisible?"":"display: none"},this.homeButtons&&this.homeButtons.map((function(t){return m(L,{attributes:t})}))),m("div",{className:O+"-container",style:this.isFavouritesVisible?"":"display: none",scrollTop:this.isTrendingVisible||this.isResultsVisible?"0":""},this.favouriteButtons&&this.favouriteButtons.map((function(t){return m(E,{attributes:t})})),m("span",{id:O+"-end"},"You've reached the end")),m("div",{className:O+"-container",style:this.isTrendingVisible||this.isResultsVisible?"":"display: none",onscroll:this.loadMore.bind(this),scrollTop:this.isTrendingVisible||this.isResultsVisible?"0":""},this.resultButtons&&this.resultButtons.map((function(t){return m(E,{attributes:t})})),m("span",{id:O+"-end"},"You've reached the end")),m("div",{id:O+"-footer"},m("img",{src:this.baseUrl+"/assets/extensions/therealsujitk-gifs/powered_by_"+this.engine+".svg"})))},r.getEngine=function(){return"tenor"===this.engine?n(14):n(15)},r.getPlaceholder=function(){return"tenor"==this.engine?v.a.translator.trans(O+".forum.searchTenor"):v.a.translator.trans(O+".forum.searchGiphy")},r.showHome=function(){this.isFavouritesVisible=!1,this.isTrendingVisible=!1,this.isResultsVisible=!1,this.isHomeVisible=!0,this.query(""),this.resetResultsPage()},r.showFavourites=function(){this.isHomeVisible=!1,this.isResultsVisible=!1,this.isTrendingVisible=!1,this.isFavouritesVisible=!0,this.category=v.a.translator.trans(O+".forum.favourites")},r.showTrending=function(){this.isHomeVisible=!1,this.isFavouritesVisible=!1,this.isResultsVisible=!1,this.isTrendingVisible=!0,this.category=v.a.translator.trans(O+".forum.trending")},r.showResults=function(){this.isHomeVisible=!1,this.isFavouritesVisible=!1,this.isTrendingVisible=!1,this.isResultsVisible=!0},r.loadHomePage=function(){var t=Object(h.a)(d.a.mark((function t(){var e,n,r,i,o,s=this;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e={title:v.a.translator.trans(O+".forum.favourites"),icon:"fas fa-star",onclick:function(){s.showFavourites()}},n={title:v.a.translator.trans(O+".forum.trending"),icon:"fas fa-chart-line",onclick:function(){s.loadTrendingPage()}},this.injectGIFs(null,1,"home",1),this.homeButtons.push(e,n),t.next=6,this.Engine.getTrendingTerms();case 6:for(r=t.sent,i=0;i=n-200&&(this.loading=!0,this.isResultsVisible?this.loadResultsPage():this.loadTrendingPage())}},r.injectGIFs=function(){var t=Object(h.a)(d.a.mark((function t(e,n,r,i){var o,s,a,u,c,l=this;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("favourite"!==r){t.next=6;break}return t.next=3,this.Engine.getGIFsByIDs(e);case 3:o=t.sent,t.next=19;break;case 6:if("trending"!==r&&null!=e){t.next=14;break}return t.next=9,this.Engine.getTrendingGIFs(this.next,i);case 9:s=t.sent,o=s.gifs,!i&&(this.next=s.next),t.next=19;break;case 14:return t.next=16,this.Engine.getGIFs(e,this.next,i);case 16:s=t.sent,o=s.gifs,!i&&(this.next=s.next);case 19:a=0;case 20:if(!(a<(i||this.Engine.getLimit()))){t.next=36;break}if(void 0!==o[a]){t.next=24;break}return"favourite"===r?this.favouriteButtons.splice(n+a):"result"===r&&(this.resultButtons.splice(n+a),this.reachedEnd=!0),t.abrupt("break",36);case 24:u=this.Engine.extractGIF(o[a]),(c={}).id=u.id,c.title=u.title,c.url=u.url,c.isFavourite=this.favourites.has(u.id),c.onclick=function(t,e){var n=t.target.alt,r=t.target.src,i="!["+l.engine[0].toUpperCase()+l.engine.slice(1)+" - "+n+"]("+r+")";if(l.textArea.insertAtCursor(i),v.a.modal.close(),"tenor"===l.engine){r="https://g.tenor.com/v1/registershare?&key="+l.apiKey+(""!=l.query()?"&q="+l.query():"")+"&id="+e;fetch(r)}},c.favourite=function(){var t=Object(h.a)(d.a.mark((function t(e){var n;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=!1,!l.favourites.has(e)){t.next=6;break}return t.next=4,v.a.request({method:"DELETE",url:v.a.forum.attribute("apiUrl")+"/"+O+"/"+e}).then((function(){var t=l.favouriteButtons.findIndex((function(t){return t.id===e}));l.favouriteButtons.splice(t,1),l.favourites.delete(e),0==l.favouriteButtons.length?delete l.homeButtons[0].url:l.homeButtons[0].url=l.favouriteButtons[0].url,n=!0}));case 4:t.next=8;break;case 6:return t.next=8,v.a.store.createRecord(O).save({gifID:e}).then((function(){l.injectGIFs(e,0,"favourite",1),l.favourites.add(e),n=!0}));case 8:return t.abrupt("return",n);case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),"home"===r?this.homeButtons[n+a].url=u.url:"favourite"===r?(this.favouriteButtons[n+a]&&void 0===this.favouriteButtons[n+a].url?Object.assign(this.favouriteButtons[n+a],c):this.favouriteButtons.unshift(c),n+a==0&&(this.homeButtons[0].url=u.url)):Object.assign(this.resultButtons[n+a],c);case 33:++a,t.next=20;break;case 36:m.redraw();case 37:case"end":return t.stop()}}),t,this)})));return function(e,n,r,i){return t.apply(this,arguments)}}(),r.onsubmit=function(t){t.preventDefault()},r.onkeydown=function(t){"Enter"===t.key&&(this.query(this.query().trim()),""===this.query()?this.showHome():(this.resetResultsPage(),this.loadResultsPage()))},e}(j.a),V=n(6),_=n.n(V),G=function(t){function e(){for(var e,n=arguments.length,r=new Array(n),i=0;i result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","export function initialize(apiKey, rating) {\n this.baseUrl = 'https://g.tenor.com/v1';\n this.defaultLimit = 10;\n\n this.apiKey = apiKey;\n this.rating = rating;\n}\n\nexport async function getTrendingTerms() {\n var terms;\n var url = `${this.baseUrl}/trending_terms?key=${this.apiKey}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.results === undefined) {\n console.error('Sorry, there was something wrong with the Tenor API Key.');\n return;\n }\n\n terms = content.results;\n });\n\n return terms;\n}\n\nexport async function getTrendingGIFs(pos, limit) {\n var obj;\n var url = `${this.baseUrl}/trending?key=${this.apiKey}&contentfilter=${this.rating}&media_filter=minimal&limit=${limit || this.defaultLimit}${pos ? `&pos=${pos}` : ''}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.results === undefined) {\n console.error('Sorry, there was something wrong with the Tenor API Key.');\n return;\n }\n\n obj = {\n gifs: content.results,\n next: content.next\n };\n });\n \n return obj;\n}\n\nexport async function getGIFs(query, pos, limit) {\n var obj;\n var url = `${this.baseUrl}/search?key=${this.apiKey}&q=${query}&contentfilter=${this.rating}&media_filter=minimal&limit=${limit || this.defaultLimit}${pos ? `&pos=${pos}` : ''}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.results === undefined) {\n console.error('Sorry, there was something wrong with the Tenor API Key.');\n return;\n }\n\n obj = {\n gifs: content.results,\n next: content.next\n };\n });\n \n return obj;\n}\n\nexport async function getGIFsByIDs(ids) {\n var gifs;\n var url = `${this.baseUrl}/gifs?key=${this.apiKey}&ids=${ids}&media_filter=minimal`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n gifs = content.results;\n });\n\n return gifs;\n}\n\nexport function extractGIF(gif) {\n return {\n id: gif.id,\n title: gif.title,\n url: gif.media[0].gif.url\n };\n}\n\nexport function getLimit() {\n return this.defaultLimit;\n}\n","export function initialize(apiKey, rating) {\n this.baseUrl = 'https://api.giphy.com/v1';\n this.defaultLimit = 10;\n\n this.apiKey = apiKey;\n this.rating = (() => {\n if (rating === 'off') {\n return 'r';\n } else if (rating === 'low') {\n return 'pg-13';\n } else if (rating === 'medium') {\n return 'pg';\n } else {\n return 'g';\n }\n })();\n}\n\nexport async function getTrendingTerms() {\n var terms;\n var url = `${this.baseUrl}/trending/searches?api_key=${this.apiKey}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.data === undefined) {\n console.error('Sorry, there was something wrong with the Giphy API Key.');\n return;\n }\n\n terms = content.data;\n });\n\n return terms;\n}\n\nexport async function getTrendingGIFs(offset, limit) {\n var obj;\n var url = `${this.baseUrl}/gifs/trending?api_key=${this.apiKey}&rating=${this.rating}&limit=${limit || this.defaultLimit}${offset ? `&offset=${offset}` : ''}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.data === undefined) {\n console.error('Sorry, there was something wrong with the Tenor API Key.');\n return;\n }\n\n obj = {\n gifs: content.data,\n next: offset + (limit || this.defaultLimit)\n };\n });\n \n return obj;\n}\n\nexport async function getGIFs(query, offset, limit) {\n var obj;\n var url = `${this.baseUrl}/gifs/search?api_key=${this.apiKey}&rating=${this.rating}&q=${query}&limit=${limit || this.defaultLimit}${offset ? `&offset=${offset}` : ''}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.data === undefined) {\n console.error('Sorry, there was something wrong with the Tenor API Key.');\n return;\n }\n\n obj = {\n gifs: content.data,\n next: offset + (limit || this.defaultLimit)\n };\n });\n \n return obj;\n}\n\nexport async function getGIFsByIDs(ids) {\n var gifs;\n var url = `${this.baseUrl}/gifs?api_key=${this.apiKey}&ids=${ids}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n gifs = content.data;\n });\n\n return gifs;\n}\n\nexport function extractGIF(gif) {\n return {\n id: gif.id,\n title: gif.title,\n url: gif.images.original.url\n };\n}\n\nexport function getLimit() {\n return this.defaultLimit;\n}\n","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","import Component from 'flarum/common/Component';\n\nexport default class SuggestionButton extends Component {\n view() {\n const attrs = this.attrs.attributes;\n\n const title = attrs.title;\n const url = attrs.url;\n const icon = attrs.icon;\n const onclick = attrs.onclick;\n\n return
\n {icon && } {title}\n
;\n }\n}\n","import app from 'flarum/app';\nimport Component from 'flarum/common/Component';\nimport Button from 'flarum/common/components/Button';\nimport Tooltip from 'flarum/common/components/Tooltip';\n\nconst prefix = 'therealsujitk-gifs';\n\nexport default class ResultButton extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.loading = false;\n this.hidden = true; // Hide the image until the height has been adjusted\n this.rowSpan = Math.random() * 15 + 25; // The number of rows the button covers (random before loading)\n \n this.id;\n\n $(window).resize(() => {\n if (!this.hidden) {\n this.setRowSpan(this.$('img', this)[0]);\n }\n });\n }\n\n view() {\n const attrs = this.attrs.attributes;\n \n this.id = attrs.id;\n this.favourite = attrs.favourite;\n\n const title = attrs.title;\n const url = attrs.url;\n const onclick = attrs.onclick;\n\n if (attrs.isFavourite) {\n if (!this.hidden) {\n this.setRowSpan(this.$('img', this)[0]);\n }\n }\n\n return
\n {title} {onclick(e, this.id)}} onload={(e) => {this.setRowSpan(e.target)}} />\n \n
;\n }\n\n setRowSpan(img) {\n this.rowSpan = img.height / 5 + 2;\n this.hidden = false;\n }\n\n async handleFavourite() {\n this.loading = true;\n var result = await this.favourite(this.id);\n\n if (result) {\n this.attrs.attributes.isFavourite = !this.attrs.attributes.isFavourite;\n }\n\n this.loading = false;\n m.redraw();\n }\n}\n","import app from 'flarum/app';\nimport Button from 'flarum/common/components/Button';\nimport HomeButton from './HomeButton';\nimport Modal from 'flarum/common/components/Modal';\nimport ResultButton from './ResultButton';\nimport Stream from 'flarum/common/utils/Stream';\n\nconst prefix = 'therealsujitk-gifs';\n\nconst ENGINE_GIPHY = 'giphy';\nconst ENGINE_TENOR = 'tenor';\n\nconst CATEGORY_HOME = 'home';\nconst CATEGORY_FAVOURITE = 'favourite';\nconst CATEGORY_TRENDING = 'trending';\nconst CATEGORY_RESULT = 'result';\n\nexport default class GIFModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.textArea = this.attrs.textArea;\n this.baseUrl = app.forum.attribute('baseUrl');\n this.engine = app.forum.attribute(`${prefix}.engine`);\n this.apiKey = app.forum.attribute(`${prefix}.api_key`);\n this.rating = app.forum.attribute(`${prefix}.rating`);\n\n this.Engine = this.getEngine();\n this.Engine.initialize(this.apiKey, this.rating);\n\n this.isHomeVisible = true;\n this.isFavouritesVisible = false;\n this.isTrendingVisible = false;\n this.isResultsVisible = false;\n\n this.category = '';\n this.query = Stream('');\n this.next = null;\n\n this.favourites = new Set();\n\n this.homeButtons = new Array();\n this.favouriteButtons = new Array();\n this.resultButtons = new Array();\n\n this.loadHomePage();\n this.loadFavouritesPage();\n\n this.loading = false;\n this.reachedEnd = false;\n }\n\n className() {\n return `${prefix}-modal`;\n }\n\n title() {\n return 'Select a GIF to add to your post';\n }\n\n /**\n * The body has four categories. HOME, FAVOURITES, TRENDING, RESULTS\n * TRENDING and RESULTS use the same container\n */\n content() {\n return
\n
\n \n
\n\n
\n {this.homeButtons && this.homeButtons.map(homeButton => )}\n
\n\n
\n {this.favouriteButtons && this.favouriteButtons.map(favouriteButton => )}\n You've reached the end\n
\n\n
\n {this.resultButtons && this.resultButtons.map(resultButton => )}\n You've reached the end\n
\n\n
\n \n
\n
\n }\n\n getEngine() {\n if (this.engine === ENGINE_TENOR) {\n return require('../helpers/Tenor');\n } else {\n return require('../helpers/Giphy');\n }\n }\n\n getPlaceholder() {\n if (this.engine == ENGINE_TENOR) {\n return app.translator.trans(`${prefix}.forum.searchTenor`);\n } else {\n return app.translator.trans(`${prefix}.forum.searchGiphy`);\n }\n }\n\n showHome() {\n this.isFavouritesVisible = false;\n this.isTrendingVisible = false;\n this.isResultsVisible = false;\n this.isHomeVisible = true;\n\n this.query('');\n this.resetResultsPage();\n }\n\n showFavourites() {\n this.isHomeVisible = false;\n this.isResultsVisible = false;\n this.isTrendingVisible = false;\n this.isFavouritesVisible = true;\n\n this.category = app.translator.trans(`${prefix}.forum.favourites`);\n }\n\n showTrending() {\n this.isHomeVisible = false;\n this.isFavouritesVisible = false;\n this.isResultsVisible = false;\n this.isTrendingVisible = true;\n\n this.category = app.translator.trans(`${prefix}.forum.trending`);\n }\n\n showResults() {\n this.isHomeVisible = false;\n this.isFavouritesVisible = false;\n this.isTrendingVisible = false;\n this.isResultsVisible = true;\n }\n\n async loadHomePage() {\n var favouritesButton = {\n title: app.translator.trans(`${prefix}.forum.favourites`),\n icon: 'fas fa-star',\n onclick: () => {\n this.showFavourites();\n }\n };\n\n var trendingButton = {\n title: app.translator.trans(`${prefix}.forum.trending`),\n icon: 'fas fa-chart-line',\n onclick: () => {\n this.loadTrendingPage();\n }\n };\n\n this.injectGIFs(null, 1, CATEGORY_HOME, 1); // Background for the trending button\n this.homeButtons.push(favouritesButton, trendingButton);\n\n var trendingTerms = await this.Engine.getTrendingTerms();\n\n for (var i = 0; i < trendingTerms.length; ++i) {\n var button = {\n title: trendingTerms[i],\n onclick: (e) => {\n this.query(e.target.innerText);\n this.loadResultsPage();\n }\n };\n\n this.injectGIFs(trendingTerms[i], this.homeButtons.length, CATEGORY_HOME, 1);\n this.homeButtons.push(button);\n }\n }\n\n async loadFavouritesPage() {\n app.store.find(prefix)\n .then((response) => {\n var gifIDs = '';\n\n response.forEach(el => {\n var gifID = el.data.attributes.gifID;\n gifIDs = `${gifIDs}${gifID},`;\n\n this.favouriteButtons.push({});\n this.favourites.add(gifID);\n });\n\n gifIDs = gifIDs.slice(0, -1);\n this.injectGIFs(gifIDs, 0, CATEGORY_FAVOURITE, response.length);\n });\n }\n\n async loadTrendingPage() {\n this.showTrending();\n\n for (var i = 0; i < this.Engine.getLimit(); ++i) {\n var button = {};\n this.resultButtons.push(button);\n }\n\n var startIndex = this.resultButtons.length - this.Engine.getLimit();\n this.injectGIFs(null, startIndex, CATEGORY_TRENDING, null);\n this.loading = false;\n }\n\n async loadResultsPage() {\n this.showResults();\n\n for (var i = 0; i < this.Engine.getLimit(); ++i) {\n var button = {};\n this.resultButtons.push(button);\n }\n\n var startIndex = this.resultButtons.length - this.Engine.getLimit();\n this.injectGIFs(this.query(), startIndex, CATEGORY_RESULT, null);\n this.loading = false;\n }\n\n resetResultsPage() {\n this.resultButtons = new Array();\n m.redraw.sync(); // WARNING: Make sure this method is not called during the mithril lifecycle\n\n this.next = null;\n this.reachedEnd = false;\n }\n\n loadMore(e) {\n if ((!this.isResultsVisible && !this.isTrendingVisible) || this.loading || this.reachedEnd) {\n return;\n }\n\n var scrollTop = e.target.scrollTop;\n var scrollDistance = e.target.scrollHeight - e.target.offsetHeight;\n\n if (scrollDistance != 0 && scrollTop >= scrollDistance - 200) {\n this.loading = true;\n\n if (this.isResultsVisible) {\n this.loadResultsPage();\n } else {\n this.loadTrendingPage();\n }\n }\n }\n\n /**\n * This function is sets the GIF id, title and url\n * after it has been added to the DOM window\n *\n * @param {string|null} t query, gif ids or null\n * @param {number} startIndex start index to set the properties\n * @param {string} category the category of the button\n * @param {number|null} limit the number of GIFs to be loaded\n */\n async injectGIFs(t, startIndex, category, limit) {\n var gifs;\n\n if (category === CATEGORY_FAVOURITE) {\n gifs = await this.Engine.getGIFsByIDs(t);\n } else if (category === CATEGORY_TRENDING || t == null) {\n var obj = await this.Engine.getTrendingGIFs(this.next, limit);\n\n gifs = obj.gifs;\n !limit && (this.next = obj.next);\n } else {\n obj = await this.Engine.getGIFs(t, this.next, limit);\n\n gifs = obj.gifs;\n !limit && (this.next = obj.next);\n }\n\n for (var i = 0; i < (limit || this.Engine.getLimit()); ++i) {\n if (gifs[i] === undefined) {\n if (category === CATEGORY_FAVOURITE) {\n this.favouriteButtons.splice(startIndex + i);\n } else if (category === CATEGORY_RESULT) {\n this.resultButtons.splice(startIndex + i);\n this.reachedEnd = true;\n }\n\n break;\n }\n\n var gif = this.Engine.extractGIF(gifs[i]);\n var button = {};\n\n button.id = gif.id;\n button.title = gif.title;\n button.url = gif.url;\n button.isFavourite = this.favourites.has(gif.id);\n button.onclick = (e, id) => {\n var title = e.target.alt;\n var url = e.target.src;\n var embed = `![${this.engine[0].toUpperCase()}${this.engine.slice(1)} - ${title}](${url})`;\n \n this.textArea.insertAtCursor(embed);\n app.modal.close();\n\n // For the Tenor API, it is required to register the shared GIF\n if (this.engine === ENGINE_TENOR) {\n var url = `https://g.tenor.com/v1/registershare?&key=${this.apiKey}${this.query() != '' ? `&q=${this.query()}` : ''}&id=${id}`;\n fetch(url);\n }\n }\n button.favourite = async (id) => {\n var result = false;\n\n if (this.favourites.has(id)) {\n await app.request({\n method: 'DELETE',\n url: `${app.forum.attribute('apiUrl')}/${prefix}/${id}`,\n }).then(() => {\n var index = this.favouriteButtons.findIndex(\n el => el.id === id\n );\n this.favouriteButtons.splice(index, 1);\n this.favourites.delete(id);\n\n if (this.favouriteButtons.length == 0) {\n delete this.homeButtons[0].url;\n } else {\n this.homeButtons[0].url = this.favouriteButtons[0].url;\n }\n\n result = true;\n });\n } else {\n await app.store.createRecord(prefix).save({\n gifID: id\n }).then(() => {\n this.injectGIFs(id, 0, CATEGORY_FAVOURITE, 1);\n this.favourites.add(id);\n\n result = true;\n });\n }\n\n return result;\n }\n\n if (category === CATEGORY_HOME) {\n this.homeButtons[startIndex + i].url = gif.url;\n } else if (category === CATEGORY_FAVOURITE) {\n if (this.favouriteButtons[startIndex + i] && this.favouriteButtons[startIndex + i].url === undefined) {\n Object.assign(this.favouriteButtons[startIndex + i], button);\n } else {\n // If a new favourite is added, not using a placeholder causes lesser problems\n this.favouriteButtons.unshift(button);\n }\n\n // Changing the home button background\n if (startIndex + i == 0) {\n this.homeButtons[0].url = gif.url;\n }\n } else {\n Object.assign(this.resultButtons[startIndex + i], button);\n }\n }\n\n m.redraw();\n }\n\n onsubmit(e) {\n e.preventDefault();\n }\n\n onkeydown(e) {\n if (e.key === 'Enter') {\n this.query(this.query().trim());\n\n if (this.query() === '') {\n this.showHome();\n } else {\n this.resetResultsPage();\n this.loadResultsPage();\n }\n }\n }\n}\n","import Model from 'flarum/Model';\n\nexport default class GIF extends Model {\n gifID = Model.attribute('gifID');\n}\n","import { extend } from 'flarum/common/extend';\nimport app from 'flarum/common/app';\nimport TextEditor from 'flarum/common/components/TextEditor';\nimport TextEditorButton from 'flarum/common/components/TextEditorButton';\nimport GIFModal from './components/GIFModal';\nimport GIF from './models/GIF';\n\nconst prefix = 'therealsujitk-gifs';\n\napp.initializers.add(prefix, () => {\n app.store.models[prefix] = GIF;\n\n extend(TextEditor.prototype, 'toolbarItems', function (items) {\n items.add('my-item',\n app.modal.show(GIFModal, { textArea: this.attrs.composer.editor })}>\n \n \n \n \n \n \n \n \n );\n });\n});\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://@therealsujitk/flarum-ext-gifs/webpack/bootstrap","webpack://@therealsujitk/flarum-ext-gifs/./node_modules/@babel/runtime/regenerator/index.js","webpack://@therealsujitk/flarum-ext-gifs/external \"flarum.core.compat['app']\"","webpack://@therealsujitk/flarum-ext-gifs/./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js","webpack://@therealsujitk/flarum-ext-gifs/external \"flarum.core.compat['common/app']\"","webpack://@therealsujitk/flarum-ext-gifs/external \"flarum.core.compat['common/components/Button']\"","webpack://@therealsujitk/flarum-ext-gifs/external \"flarum.core.compat['common/Component']\"","webpack://@therealsujitk/flarum-ext-gifs/external \"flarum.core.compat['Model']\"","webpack://@therealsujitk/flarum-ext-gifs/external \"flarum.core.compat['common/extend']\"","webpack://@therealsujitk/flarum-ext-gifs/external \"flarum.core.compat['common/components/TextEditor']\"","webpack://@therealsujitk/flarum-ext-gifs/external \"flarum.core.compat['common/components/TextEditorButton']\"","webpack://@therealsujitk/flarum-ext-gifs/external \"flarum.core.compat['common/components/Modal']\"","webpack://@therealsujitk/flarum-ext-gifs/external \"flarum.core.compat['common/components/Tooltip']\"","webpack://@therealsujitk/flarum-ext-gifs/external \"flarum.core.compat['common/utils/Stream']\"","webpack://@therealsujitk/flarum-ext-gifs/./node_modules/regenerator-runtime/runtime.js","webpack://@therealsujitk/flarum-ext-gifs/./src/forum/helpers/Tenor.js","webpack://@therealsujitk/flarum-ext-gifs/./src/forum/helpers/Giphy.js","webpack://@therealsujitk/flarum-ext-gifs/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@therealsujitk/flarum-ext-gifs/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@therealsujitk/flarum-ext-gifs/./src/forum/components/HomeButton.js","webpack://@therealsujitk/flarum-ext-gifs/./src/forum/components/ResultButton.js","webpack://@therealsujitk/flarum-ext-gifs/./src/forum/components/GIFModal.js","webpack://@therealsujitk/flarum-ext-gifs/./src/forum/models/GIF.js","webpack://@therealsujitk/flarum-ext-gifs/./src/forum/index.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","require","flarum","core","compat","asyncGeneratorStep","gen","resolve","reject","_next","_throw","arg","info","error","done","Promise","then","_asyncToGenerator","fn","self","this","args","arguments","apply","err","undefined","runtime","Op","hasOwn","$Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","define","obj","configurable","writable","wrap","innerFn","outerFn","tryLocsList","protoGenerator","Generator","generator","context","Context","_invoke","state","method","Error","doneResult","delegate","delegateResult","maybeInvokeDelegate","ContinueSentinel","sent","_sent","dispatchException","abrupt","record","tryCatch","type","makeInvokeMethod","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","getProto","getPrototypeOf","NativeIteratorPrototype","values","Gp","defineIteratorMethods","forEach","AsyncIterator","PromiseImpl","previousPromise","callInvokeWithMethodAndArg","invoke","result","__await","unwrapped","TypeError","resultName","next","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","iterable","iteratorMethod","isNaN","length","constructor","displayName","isGeneratorFunction","genFun","ctor","mark","setPrototypeOf","__proto__","awrap","async","iter","toString","keys","reverse","pop","skipTempReset","prev","charAt","slice","stop","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","thrown","delegateYield","regeneratorRuntime","accidentalStrictMode","Function","initialize","apiKey","rating","baseUrl","defaultLimit","getTrendingTerms","a","url","fetch","response","json","content","results","terms","console","getTrendingGIFs","pos","limit","gifs","getGIFs","query","getGIFsByIDs","ids","extractGIF","gif","id","title","media","getLimit","data","offset","images","original","_setPrototypeOf","_inheritsLoose","subClass","superClass","SuggestionButton","view","attrs","attributes","icon","onclick","style","class","Component","ResultButton","oninit","vnode","loading","hidden","rowSpan","Math","random","$","window","resize","setRowSpan","favourite","isFavourite","round","alt","src","e","onload","target","showOnFocus","text","app","translator","trans","prefix","className","handleFavourite","img","height","redraw","GIFModal","textArea","forum","attribute","engine","Engine","getEngine","isHomeVisible","isFavouritesVisible","isTrendingVisible","isResultsVisible","category","Stream","favourites","Set","homeButtons","Array","favouriteButtons","resultButtons","loadHomePage","loadFavouritesPage","reachedEnd","showHome","placeholder","getPlaceholder","bidi","onkeydown","resetResultsPage","loadResultsPage","map","homeButton","scrollTop","favouriteButton","onscroll","loadMore","resultButton","showFavourites","showTrending","showResults","favouritesButton","trendingButton","loadTrendingPage","injectGIFs","trendingTerms","button","innerText","store","find","gifIDs","el","gifID","add","startIndex","sync","scrollDistance","scrollHeight","offsetHeight","splice","has","embed","toUpperCase","insertAtCursor","modal","close","request","index","findIndex","createRecord","save","assign","unshift","onsubmit","preventDefault","trim","Modal","GIF","Model","initializers","models","extend","TextEditor","items","show","composer","editor","xmlns","xlink","width","viewBox","version","fill"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,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ACL3I,KAAK0N,YAEL1N,KAAK+N,mBACL/N,KAAKgO,qB,GA/WiB8C,K,gBCfjBC,E,oJACjBzB,MAAQ0B,IAAMzE,UAAU,S,mBADKyE,KCOjCrF,IAAIsF,aAAa1B,IAFF,sBAEc,WACzB5D,IAAIuD,MAAMgC,OAHC,sBAGgBH,EAE3BI,iBAAOC,IAAW3S,UAAW,gBAAgB,SAAU4S,GAAO,WAC1DA,EAAM9B,IAAI,UACN,EAAC,IAAD,CAAkBvG,GAAO8C,kCAAuBC,UAAU,2CAA2C9C,MAAO0C,IAAIC,WAAWC,MAASC,kCAAuB7B,QAAS,kBAAM0B,IAAIuE,MAAMoB,KAAKlF,EAAU,CAAEC,SAAU,EAAKvC,MAAMyH,SAASC,WAC/N,SAAKxI,GAAG,kCAAkCyI,MAAM,6BAA6BC,MAAM,+BAA+BC,MAAM,OAAOzF,OAAO,MAAM0F,QAAQ,WAAWC,QAAQ,OACnK,WACI,UAAM1U,EAAE,guBAAguB2U,KAAK,iBAC7uB,UAAM3U,EAAE,8GAA8G2U,KAAK,iBAC3H,UAAM3U,EAAE,kPAAkP2U,KAAK","file":"forum.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 16);\n","module.exports = require(\"regenerator-runtime\");\n","module.exports = flarum.core.compat['app'];","function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\n\nexport default function _asyncToGenerator(fn) {\n return function () {\n var self = this,\n args = arguments;\n return new Promise(function (resolve, reject) {\n var gen = fn.apply(self, args);\n\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n\n _next(undefined);\n });\n };\n}","module.exports = flarum.core.compat['common/app'];","module.exports = flarum.core.compat['common/components/Button'];","module.exports = flarum.core.compat['common/Component'];","module.exports = flarum.core.compat['Model'];","module.exports = flarum.core.compat['common/extend'];","module.exports = flarum.core.compat['common/components/TextEditor'];","module.exports = flarum.core.compat['common/components/TextEditorButton'];","module.exports = flarum.core.compat['common/components/Modal'];","module.exports = flarum.core.compat['common/components/Tooltip'];","module.exports = flarum.core.compat['common/utils/Stream'];","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, \"\");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n \"GeneratorFunction\"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, \"GeneratorFunction\");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","export function initialize(apiKey, rating) {\n this.baseUrl = 'https://g.tenor.com/v1';\n this.defaultLimit = 10;\n\n this.apiKey = apiKey;\n this.rating = rating;\n}\n\nexport async function getTrendingTerms() {\n var terms;\n var url = `${this.baseUrl}/trending_terms?key=${this.apiKey}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.results === undefined) {\n console.error('Sorry, there was something wrong with the Tenor API Key.');\n return;\n }\n\n terms = content.results;\n });\n\n return terms;\n}\n\nexport async function getTrendingGIFs(pos, limit) {\n var obj;\n var url = `${this.baseUrl}/trending?key=${this.apiKey}&contentfilter=${this.rating}&media_filter=minimal&limit=${limit || this.defaultLimit}${pos ? `&pos=${pos}` : ''}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.results === undefined) {\n console.error('Sorry, there was something wrong with the Tenor API Key.');\n return;\n }\n\n obj = {\n gifs: content.results,\n next: content.next\n };\n });\n \n return obj;\n}\n\nexport async function getGIFs(query, pos, limit) {\n var obj;\n var url = `${this.baseUrl}/search?key=${this.apiKey}&q=${query}&contentfilter=${this.rating}&media_filter=minimal&limit=${limit || this.defaultLimit}${pos ? `&pos=${pos}` : ''}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.results === undefined) {\n console.error('Sorry, there was something wrong with the Tenor API Key.');\n return;\n }\n\n obj = {\n gifs: content.results,\n next: content.next\n };\n });\n \n return obj;\n}\n\nexport async function getGIFsByIDs(ids) {\n var gifs;\n var url = `${this.baseUrl}/gifs?key=${this.apiKey}&ids=${ids}&media_filter=minimal`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n gifs = content.results;\n });\n\n return gifs;\n}\n\nexport function extractGIF(gif) {\n return {\n id: gif.id,\n title: gif.title,\n url: gif.media[0].gif.url\n };\n}\n\nexport function getLimit() {\n return this.defaultLimit;\n}\n","export function initialize(apiKey, rating) {\n this.baseUrl = 'https://api.giphy.com/v1';\n this.defaultLimit = 10;\n\n this.apiKey = apiKey;\n this.rating = (() => {\n if (rating === 'off') {\n return 'r';\n } else if (rating === 'low') {\n return 'pg-13';\n } else if (rating === 'medium') {\n return 'pg';\n } else {\n return 'g';\n }\n })();\n}\n\nexport async function getTrendingTerms() {\n var terms;\n var url = `${this.baseUrl}/trending/searches?api_key=${this.apiKey}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.data === undefined) {\n console.error('Sorry, there was something wrong with the Giphy API Key.');\n return;\n }\n\n terms = content.data;\n });\n\n return terms;\n}\n\nexport async function getTrendingGIFs(offset, limit) {\n var obj;\n var url = `${this.baseUrl}/gifs/trending?api_key=${this.apiKey}&rating=${this.rating}&limit=${limit || this.defaultLimit}${offset ? `&offset=${offset}` : ''}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.data === undefined) {\n console.error('Sorry, there was something wrong with the Tenor API Key.');\n return;\n }\n\n obj = {\n gifs: content.data,\n next: offset + (limit || this.defaultLimit)\n };\n });\n \n return obj;\n}\n\nexport async function getGIFs(query, offset, limit) {\n var obj;\n var url = `${this.baseUrl}/gifs/search?api_key=${this.apiKey}&rating=${this.rating}&q=${query}&limit=${limit || this.defaultLimit}${offset ? `&offset=${offset}` : ''}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n if (content.data === undefined) {\n console.error('Sorry, there was something wrong with the Tenor API Key.');\n return;\n }\n\n obj = {\n gifs: content.data,\n next: offset + (limit || this.defaultLimit)\n };\n });\n \n return obj;\n}\n\nexport async function getGIFsByIDs(ids) {\n var gifs;\n var url = `${this.baseUrl}/gifs?api_key=${this.apiKey}&ids=${ids}`;\n\n await fetch(url)\n .then((response) => response.json())\n .then((content) => {\n gifs = content.data;\n });\n\n return gifs;\n}\n\nexport function extractGIF(gif) {\n return {\n id: gif.id,\n title: gif.title,\n url: gif.images.original.url\n };\n}\n\nexport function getLimit() {\n return this.defaultLimit;\n}\n","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","import Component from 'flarum/common/Component';\n\nexport default class SuggestionButton extends Component {\n view() {\n const attrs = this.attrs.attributes;\n\n const title = attrs.title;\n const url = attrs.url;\n const icon = attrs.icon;\n const onclick = attrs.onclick;\n\n return
\n {icon && } {title}\n
;\n }\n}\n","import app from 'flarum/app';\nimport Component from 'flarum/common/Component';\nimport Button from 'flarum/common/components/Button';\nimport Tooltip from 'flarum/common/components/Tooltip';\n\nconst prefix = 'therealsujitk-gifs';\n\nexport default class ResultButton extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.loading = false;\n this.hidden = true; // Hide the image until the height has been adjusted\n this.rowSpan = Math.random() * 15 + 25; // The number of rows the button covers (random before loading)\n \n this.id;\n\n $(window).resize(() => {\n if (!this.hidden) {\n this.setRowSpan(this.$('img', this)[0]);\n }\n });\n }\n\n view() {\n const attrs = this.attrs.attributes;\n \n this.id = attrs.id;\n this.favourite = attrs.favourite;\n\n const title = attrs.title;\n const url = attrs.url;\n const onclick = attrs.onclick;\n\n if (attrs.isFavourite) {\n if (!this.hidden) {\n this.setRowSpan(this.$('img', this)[0]);\n }\n }\n\n return
\n {title} {onclick(e, this.id)}} onload={(e) => {this.setRowSpan(e.target)}} />\n \n
;\n }\n\n setRowSpan(img) {\n this.rowSpan = img.height / 5 + 2;\n this.hidden = false;\n }\n\n async handleFavourite() {\n this.loading = true;\n var result = await this.favourite(this.id);\n\n if (result) {\n this.attrs.attributes.isFavourite = !this.attrs.attributes.isFavourite;\n }\n\n this.loading = false;\n m.redraw();\n }\n}\n","import app from 'flarum/app';\nimport Button from 'flarum/common/components/Button';\nimport HomeButton from './HomeButton';\nimport Modal from 'flarum/common/components/Modal';\nimport ResultButton from './ResultButton';\nimport Stream from 'flarum/common/utils/Stream';\n\nconst prefix = 'therealsujitk-gifs';\n\nconst ENGINE_GIPHY = 'giphy';\nconst ENGINE_TENOR = 'tenor';\n\nconst CATEGORY_HOME = 'home';\nconst CATEGORY_FAVOURITE = 'favourite';\nconst CATEGORY_TRENDING = 'trending';\nconst CATEGORY_RESULT = 'result';\n\nexport default class GIFModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.textArea = this.attrs.textArea;\n this.baseUrl = app.forum.attribute('baseUrl');\n this.engine = app.forum.attribute(`${prefix}.engine`);\n this.apiKey = app.forum.attribute(`${prefix}.api_key`);\n this.rating = app.forum.attribute(`${prefix}.rating`);\n\n this.Engine = this.getEngine();\n this.Engine.initialize(this.apiKey, this.rating);\n\n this.isHomeVisible = true;\n this.isFavouritesVisible = false;\n this.isTrendingVisible = false;\n this.isResultsVisible = false;\n\n this.category = '';\n this.query = Stream('');\n this.next = null;\n\n this.favourites = new Set();\n\n this.homeButtons = new Array();\n this.favouriteButtons = new Array();\n this.resultButtons = new Array();\n\n this.loadHomePage();\n this.loadFavouritesPage();\n\n this.loading = false;\n this.reachedEnd = false;\n }\n\n className() {\n return `${prefix}-modal`;\n }\n\n title() {\n return 'Select a GIF to add to your post';\n }\n\n /**\n * The body has four categories. HOME, FAVOURITES, TRENDING, RESULTS\n * TRENDING and RESULTS use the same container\n */\n content() {\n return
\n
\n \n
\n\n
\n {this.homeButtons && this.homeButtons.map(homeButton => )}\n
\n\n
\n {this.favouriteButtons && this.favouriteButtons.map(favouriteButton => )}\n You've reached the end\n
\n\n
\n {this.resultButtons && this.resultButtons.map(resultButton => )}\n You've reached the end\n
\n\n
\n \n
\n
\n }\n\n getEngine() {\n if (this.engine === ENGINE_TENOR) {\n return require('../helpers/Tenor');\n } else {\n return require('../helpers/Giphy');\n }\n }\n\n getPlaceholder() {\n if (this.engine == ENGINE_TENOR) {\n return app.translator.trans(`${prefix}.forum.searchTenor`);\n } else {\n return app.translator.trans(`${prefix}.forum.searchGiphy`);\n }\n }\n\n showHome() {\n this.isFavouritesVisible = false;\n this.isTrendingVisible = false;\n this.isResultsVisible = false;\n this.isHomeVisible = true;\n\n this.query('');\n this.resetResultsPage();\n }\n\n showFavourites() {\n this.isHomeVisible = false;\n this.isResultsVisible = false;\n this.isTrendingVisible = false;\n this.isFavouritesVisible = true;\n\n this.category = app.translator.trans(`${prefix}.forum.favourites`);\n }\n\n showTrending() {\n this.isHomeVisible = false;\n this.isFavouritesVisible = false;\n this.isResultsVisible = false;\n this.isTrendingVisible = true;\n\n this.category = app.translator.trans(`${prefix}.forum.trending`);\n }\n\n showResults() {\n this.isHomeVisible = false;\n this.isFavouritesVisible = false;\n this.isTrendingVisible = false;\n this.isResultsVisible = true;\n }\n\n async loadHomePage() {\n var favouritesButton = {\n title: app.translator.trans(`${prefix}.forum.favourites`),\n icon: 'fas fa-star',\n onclick: () => {\n this.showFavourites();\n }\n };\n\n var trendingButton = {\n title: app.translator.trans(`${prefix}.forum.trending`),\n icon: 'fas fa-chart-line',\n onclick: () => {\n this.loadTrendingPage();\n }\n };\n\n this.injectGIFs(null, 1, CATEGORY_HOME, 1); // Background for the trending button\n this.homeButtons.push(favouritesButton, trendingButton);\n\n var trendingTerms = await this.Engine.getTrendingTerms();\n\n for (var i = 0; i < trendingTerms.length; ++i) {\n var button = {\n title: trendingTerms[i],\n onclick: (e) => {\n this.query(e.target.innerText);\n this.loadResultsPage();\n }\n };\n\n this.injectGIFs(trendingTerms[i], this.homeButtons.length, CATEGORY_HOME, 1);\n this.homeButtons.push(button);\n }\n }\n\n async loadFavouritesPage() {\n app.store.find(prefix)\n .then((response) => {\n var gifIDs = '';\n\n response.forEach(el => {\n var gifID = el.data.attributes.gifID;\n gifIDs = `${gifIDs}${gifID},`;\n\n this.favouriteButtons.push({});\n this.favourites.add(gifID);\n });\n\n gifIDs = gifIDs.slice(0, -1);\n response.length && this.injectGIFs(gifIDs, 0, CATEGORY_FAVOURITE, response.length);\n });\n }\n\n async loadTrendingPage() {\n this.showTrending();\n\n for (var i = 0; i < this.Engine.getLimit(); ++i) {\n var button = {};\n this.resultButtons.push(button);\n }\n\n var startIndex = this.resultButtons.length - this.Engine.getLimit();\n this.injectGIFs(null, startIndex, CATEGORY_TRENDING, null);\n this.loading = false;\n }\n\n async loadResultsPage() {\n this.showResults();\n\n for (var i = 0; i < this.Engine.getLimit(); ++i) {\n var button = {};\n this.resultButtons.push(button);\n }\n\n var startIndex = this.resultButtons.length - this.Engine.getLimit();\n this.injectGIFs(this.query(), startIndex, CATEGORY_RESULT, null);\n this.loading = false;\n }\n\n resetResultsPage() {\n this.resultButtons = new Array();\n m.redraw.sync(); // WARNING: Make sure this method is not called during the mithril lifecycle\n\n this.next = null;\n this.reachedEnd = false;\n }\n\n loadMore(e) {\n if ((!this.isResultsVisible && !this.isTrendingVisible) || this.loading || this.reachedEnd) {\n return;\n }\n\n var scrollTop = e.target.scrollTop;\n var scrollDistance = e.target.scrollHeight - e.target.offsetHeight;\n\n if (scrollDistance != 0 && scrollTop >= scrollDistance - 200) {\n this.loading = true;\n\n if (this.isResultsVisible) {\n this.loadResultsPage();\n } else {\n this.loadTrendingPage();\n }\n }\n }\n\n /**\n * This function is sets the GIF id, title and url\n * after it has been added to the DOM window\n *\n * @param {string|null} t query, gif ids or null\n * @param {number} startIndex start index to set the properties\n * @param {string} category the category of the button\n * @param {number|null} limit the number of GIFs to be loaded\n */\n async injectGIFs(t, startIndex, category, limit) {\n var gifs;\n\n if (category === CATEGORY_FAVOURITE) {\n gifs = await this.Engine.getGIFsByIDs(t);\n } else if (category === CATEGORY_TRENDING || t == null) {\n var obj = await this.Engine.getTrendingGIFs(this.next, limit);\n\n gifs = obj.gifs;\n !limit && (this.next = obj.next);\n } else {\n obj = await this.Engine.getGIFs(t, this.next, limit);\n\n gifs = obj.gifs;\n !limit && (this.next = obj.next);\n }\n\n for (var i = 0; i < (limit || this.Engine.getLimit()); ++i) {\n if (gifs[i] === undefined) {\n if (category === CATEGORY_FAVOURITE) {\n this.favouriteButtons.splice(startIndex + i);\n } else if (category === CATEGORY_RESULT) {\n this.resultButtons.splice(startIndex + i);\n this.reachedEnd = true;\n }\n\n break;\n }\n\n var gif = this.Engine.extractGIF(gifs[i]);\n var button = {};\n\n button.id = gif.id;\n button.title = gif.title;\n button.url = gif.url;\n button.isFavourite = this.favourites.has(gif.id);\n button.onclick = (e, id) => {\n var title = e.target.alt;\n var url = e.target.src;\n var embed = `![${this.engine[0].toUpperCase()}${this.engine.slice(1)} - ${title}](${url})`;\n \n this.textArea.insertAtCursor(embed);\n app.modal.close();\n\n // For the Tenor API, it is required to register the shared GIF\n if (this.engine === ENGINE_TENOR) {\n var url = `https://g.tenor.com/v1/registershare?&key=${this.apiKey}${this.query() != '' ? `&q=${this.query()}` : ''}&id=${id}`;\n fetch(url);\n }\n }\n button.favourite = async (id) => {\n var result = false;\n\n if (this.favourites.has(id)) {\n await app.request({\n method: 'DELETE',\n url: `${app.forum.attribute('apiUrl')}/${prefix}/${id}`,\n }).then(() => {\n var index = this.favouriteButtons.findIndex(\n el => el.id === id\n );\n this.favouriteButtons.splice(index, 1);\n this.favourites.delete(id);\n\n if (this.favouriteButtons.length == 0) {\n delete this.homeButtons[0].url;\n } else {\n this.homeButtons[0].url = this.favouriteButtons[0].url;\n }\n\n result = true;\n });\n } else {\n await app.store.createRecord(prefix).save({\n gifID: id\n }).then(() => {\n this.injectGIFs(id, 0, CATEGORY_FAVOURITE, 1);\n this.favourites.add(id);\n\n result = true;\n });\n }\n\n return result;\n }\n\n if (category === CATEGORY_HOME) {\n this.homeButtons[startIndex + i].url = gif.url;\n } else if (category === CATEGORY_FAVOURITE) {\n if (this.favouriteButtons[startIndex + i] && this.favouriteButtons[startIndex + i].url === undefined) {\n Object.assign(this.favouriteButtons[startIndex + i], button);\n } else {\n // If a new favourite is added, not using a placeholder causes lesser problems\n this.favouriteButtons.unshift(button);\n }\n\n // Changing the home button background\n if (startIndex + i == 0) {\n this.homeButtons[0].url = gif.url;\n }\n } else {\n Object.assign(this.resultButtons[startIndex + i], button);\n }\n }\n\n m.redraw();\n }\n\n onsubmit(e) {\n e.preventDefault();\n }\n\n onkeydown(e) {\n if (e.key === 'Enter') {\n this.query(this.query().trim());\n\n if (this.query() === '') {\n this.showHome();\n } else {\n this.resetResultsPage();\n this.loadResultsPage();\n }\n }\n }\n}\n","import Model from 'flarum/Model';\n\nexport default class GIF extends Model {\n gifID = Model.attribute('gifID');\n}\n","import { extend } from 'flarum/common/extend';\nimport app from 'flarum/common/app';\nimport TextEditor from 'flarum/common/components/TextEditor';\nimport TextEditorButton from 'flarum/common/components/TextEditorButton';\nimport GIFModal from './components/GIFModal';\nimport GIF from './models/GIF';\n\nconst prefix = 'therealsujitk-gifs';\n\napp.initializers.add(prefix, () => {\n app.store.models[prefix] = GIF;\n\n extend(TextEditor.prototype, 'toolbarItems', function (items) {\n items.add('my-item',\n app.modal.show(GIFModal, { textArea: this.attrs.composer.editor })}>\n \n \n \n \n \n \n \n \n );\n });\n});\n"],"sourceRoot":""} \ No newline at end of file diff --git a/js/src/forum/components/GIFModal.js b/js/src/forum/components/GIFModal.js index 85f1fcf..fa15f8b 100755 --- a/js/src/forum/components/GIFModal.js +++ b/js/src/forum/components/GIFModal.js @@ -196,7 +196,7 @@ export default class GIFModal extends Modal { }); gifIDs = gifIDs.slice(0, -1); - this.injectGIFs(gifIDs, 0, CATEGORY_FAVOURITE, response.length); + response.length && this.injectGIFs(gifIDs, 0, CATEGORY_FAVOURITE, response.length); }); }