@r/api-client
Version:
node and browser reddit api library
2 lines • 96 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("lodash/object"),require("lodash/array"),require("superagent"),require("lodash/collection"),require("lodash/lang")):"function"==typeof define&&define.amd?define(["lodash/object","lodash/array","superagent","lodash/collection","lodash/lang"],t):"object"==typeof exports?exports["apiClient.js"]=t(require("lodash/object"),require("lodash/array"),require("superagent"),require("lodash/collection"),require("lodash/lang")):e["apiClient.js"]=t(e["lodash/object"],e["lodash/array"],e.superagent,e["lodash/collection"],e["lodash/lang"])}(this,function(e,t,n,r,o){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(t.s=85)}([function(e,t,n){"use strict";var r=n(71),o=r&&r.__esModule?function(){return r["default"]}:function(){return r};Object.defineProperty(o,"a",{get:o});var i=n(83),a=n(14),u=n(25),s=n(8),c=n(36),f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l={emit:function(){},on:function(){},off:function(){}},p={userAgent:"snoodev3",origin:"https://www.reddit.com",appName:"node-api-client-v3",env:"develop",token:"",timeout:5e3,eventEmitter:l},d=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return f({},p,e)};Object.defineProperty(t,"e",{configurable:!1,enumerable:!0,get:function(){return d}});var b=function(e){return e.eventEmitter||l},h=function(e){var t=e.token;return t?{Authorization:"Bearer "+t}:{}},v=function(e){var t=h(e);return f({},e.defaultHeaders||{},t)},y=function(e,t){var n="/";return 0===t.indexOf("/")&&(n=""),""+e.origin+n+t},m=function(e){return e.appName+"-"+e.env},g=function(e,t,n,r,a,u){var s=e.origin,c=y(e,n),l={origin:s,path:n,url:c,method:t,query:f({},r)};b(e).emit(i.a.request,l);var p=o.a[t](c);p.set(v(e)),"query"===a?(r.app=m(e),p.query(r),p.redirects&&p.redirects(0)):(p.query({app:m(e)}),p.type(a),p.send(r)),p.end(function(e,t){var n=t?t.request:l;u(e,t,n)})};Object.defineProperty(t,"f",{configurable:!1,enumerable:!0,get:function(){return g}});var _=function(e,t,n,r){if(!e||!r)throw new c.a(n,void 0);if(!r(e))throw new c.a(n,e)};Object.defineProperty(t,"a",{configurable:!1,enumerable:!0,get:function(){return _}});var O=function(e,t,n,r,o,i){if(!(e&&t&&n&&r))throw new u.a;return new Promise(function(a,u){g(e,t,n,r,"json",function(s,c,f){k(e,a,u,s,c,f,t,n,r,o,i)})})};Object.defineProperty(t,"d",{configurable:!1,enumerable:!0,get:function(){return O}});var w=function(e,t,n,r,o,i){if(!(e&&t&&n&&r))throw new u.a;return new Promise(function(a,u){g(e,t,n,r,"form",function(s,c,f){k(e,a,u,s,c,f,t,n,r,o,i)})})};Object.defineProperty(t,"b",{configurable:!1,enumerable:!0,get:function(){return w}});var j=function(e,t,n,r,o,i,a){if(!(e&&t&&n&&r&&o))throw new u.a;return"get"===t&&(r.raw_json=1),new Promise(function(u,s){g(e,t,n,r,"query",function(r,c,f){k(e,u,s,r,c,f,t,n,o,i,a)})})};Object.defineProperty(t,"c",{configurable:!1,enumerable:!0,get:function(){return j}});var P=function(e,t){return e&&!t?e.request||e.req:t},k=function(e,t,n,r,o,a,u,s,c,f,l){if(a=P(o,a),!x(e,r,o,a,u,s,n)){b(e).emit(i.a.response,a,o);var p=E(n,o,a,u,s,c,f,l);b(e).emit(i.a.result,p),t(p)}},x=function(e,t,n,r,o,a,u){return!t&&!n||n&&n.ok?void 0:t?(b(e).emit(i.a.error,t,r),t&&t.timeout&&(t.status=504),u(new s.a(t,a))):u(new s.a(n,a))},E=function(e,t,n,r,o,i,a,u){try{return R(t,n,r,i,a,u)}catch(c){console.trace(c),e(new s.a(c,o))}},R=function(e,t,n,r,o,i){if(!o)return e.body;var u=i?i(e,t,n):e.headers,s=new a.a(e,u,r),c=Date.now();o(e,s,t,n);var f=Date.now();return console.log("response parsing took "+(f-c)),s}},function(e,t,n){"use strict";function r(e){return w[e.substring(0,2)]}t.thingType=r;var o="comment";Object.defineProperty(t,"COMMENT",{configurable:!1,enumerable:!0,get:function(){return o}});var i="t1";Object.defineProperty(t,"COMMENT_TYPE",{configurable:!1,enumerable:!0,get:function(){return i}});var a="comment_load_more";Object.defineProperty(t,"COMMENT_LOAD_MORE",{configurable:!1,enumerable:!0,get:function(){return a}});var u="account";Object.defineProperty(t,"ACCOUNT",{configurable:!1,enumerable:!0,get:function(){return u}});var s="t2";Object.defineProperty(t,"ACCOUNT_TYPE",{configurable:!1,enumerable:!0,get:function(){return s}});var c="post";Object.defineProperty(t,"POST",{configurable:!1,enumerable:!0,get:function(){return c}});var f="t3";Object.defineProperty(t,"POST_TYPE",{configurable:!1,enumerable:!0,get:function(){return f}});var l="message";Object.defineProperty(t,"MESSAGE",{configurable:!1,enumerable:!0,get:function(){return l}});var p="t4";Object.defineProperty(t,"MESSAGE_TYPE",{configurable:!1,enumerable:!0,get:function(){return p}});var d="subreddit";Object.defineProperty(t,"SUBREDDIT",{configurable:!1,enumerable:!0,get:function(){return d}});var b="t5";Object.defineProperty(t,"SUBREDDIT_TYPE",{configurable:!1,enumerable:!0,get:function(){return b}});var h="trophie";Object.defineProperty(t,"TROPHIE",{configurable:!1,enumerable:!0,get:function(){return h}});var v="t6";Object.defineProperty(t,"TROPHIE_TYPE",{configurable:!1,enumerable:!0,get:function(){return v}});var y="promocampaign";Object.defineProperty(t,"PROMOCAMPAIGN",{configurable:!1,enumerable:!0,get:function(){return y}});var m="t8";Object.defineProperty(t,"PROMOCAMPAIGN_TYPE",{configurable:!1,enumerable:!0,get:function(){return m}});var g="wiki";Object.defineProperty(t,"WIKI",{configurable:!1,enumerable:!0,get:function(){return g}});var _="wiki";Object.defineProperty(t,"WIKI_TYPE",{configurable:!1,enumerable:!0,get:function(){return _}});var O=[[o,i],[u,s],[c,f],[l,p],[d,b],[h,v],[y,m],[g,_]],w=O.reduce(function(e,t){return e[t[1]]=t[0],e},{});Object.defineProperty(t,"TYPES",{configurable:!1,enumerable:!0,get:function(){return w}});var j=O.reduce(function(e,t){return e[t[0]]=t[1],e},{});Object.defineProperty(t,"TYPE_TO_THING_TYPE",{configurable:!1,enumerable:!0,get:function(){return j}})},function(e,t,n){(function(t){var r=n(115),o=r("object"==typeof t&&t),i=r("object"==typeof self&&self),a=r("object"==typeof this&&this),u=o||i||a||Function("return this")();e.exports=u}).call(t,n(166))},function(e,t){var n=Array.isArray;e.exports=n},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n(5),u=n(1),s=n(52),c=n(51),f=a.a.Types,l=new Set(["default","self","nsfw"]),p=function(e){return l.has(e)?"":e},d=function(e){function t(){return r(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),t}(a.a);d.type=u.POST,d.PROPERTIES={adserverImpPixel:f.string,author:f.string,cleanPermalink:f.link,cleanUrl:f.link,distinguished:f.string,domain:f.string,downs:f.number,hidden:f.bool,id:f.string,impPixel:f.string,likes:f.cubit,malink:f.link,media:f.nop,name:f.string,over18:f.bool,postHint:f.string,promoted:f.bool,quarantine:f.bool,saved:f.bool,score:f.number,stickied:f.bool,subreddit:f.string,subredditDetail:f.nop,subredditId:f.string,thumbnail:f.string,title:f.string,ups:f.number,authorFlairCSSClass:f.string,authorFlairText:f.string,createdUTC:f.number,hideScore:f.bool,isSelf:f.bool,linkFlairCSSClass:f.string,linkFlairText:f.string,mediaOembed:f.nop,modReports:f.array,numComments:f.number,secureMedia:f.nop,selfTextHTML:f.string,sendReplies:f.bool,userReports:f.array,expandable:f.bool,expandedContent:f.html,preview:f.nop},d.API_ALIASES={adserver_imp_pixel:"adserverImpPixel",author_flair_css_class:"authorFlairCSSClass",author_flair_text:"authorFlairText",created_utc:"createdUTC",hide_score:"hideScore",imp_pixel:"impPixel",is_self:"isSelf",link_flair_css_class:"linkFlairCSSClass",link_flair_text:"linkFlairText",media_oembed:"mediaOembed",mod_reports:"modReports",num_comments:"numComments",over_18:"over18",permalink:"cleanPermalink",post_hint:"postHint",secure_media:"secureMedia",selftext_html:"selfTextHTML",sr_detail:"subredditDetail",subreddit_id:"subredditId",sendreplies:"sendReplies",url:"cleanUrl",user_reports:"userReports"},d.DERIVED_PROPERTIES={expandable:function(e){return!!(e.secure_media&&e.secure_media.content||e.media_embed&&e.media_embed.content||e.selftext_html)},expandedContent:function(e){var t=void 0;return t=e.secure_media_embed&&e.secure_media_embed.content||e.media_embed&&e.media_embed.content,!t&&e.selftext_html&&(t=e.selftext_html),t},preview:function(e){if(!e.promoted||e.preview)return e.preview;var t=[];e.mobile_ad_url&&t.push({url:e.mobile_ad_url,height:628,width:1200});var n=p(e.thumbnail);return n&&t.push({url:n,height:140,width:140}),{images:[{resolutions:t}]}},thumbnail:function(e){return p(e.thumbnail)}},t.a=d,s.a.bind()(d),c.a.bind()(d)},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n(33),u=n(1),s=n(87),c=(n(88),n(89)),f=n(91),l=n(92),p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},d=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),b=function v(e,t,n){null===e&&(e=Function.prototype);var r=Object.getOwnPropertyDescriptor(e,t);if(void 0===r){var o=Object.getPrototypeOf(e);return null===o?void 0:v(o,t,n)}if("value"in r)return r.value;var i=r.get;if(void 0!==i)return i.call(n)},h=function(e){function t(){return r(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),d(t,[{key:"makeUUID",value:function(e){return s.a.bind()(e.name)?e.name:s.a.bind()(e.id)?e.id:b(Object.getPrototypeOf(t.prototype),"makeUUID",this).call(this,e)}},{key:"getType",value:function(e,n){return b(Object.getPrototypeOf(t.prototype),"getType",this).call(this,e,n)||u.TYPES[e.kind]||u.thingType.bind()(n)||"Unknown"}}]),t}(a.a);h.Types=p({},a.a.Types,{html:function(e){return a.a.Types.string(e)},link:function(e){return c.a.bind()(a.a.Types.string(e))}}),h.MockTypes=p({},a.a.MockTypes,{html:f.a,link:l.a}),t.a=h},function(e,t,n){function r(e,t){var n=i(e,t);return o(n)?n:void 0}var o=n(106),i=n(125);e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n(5),u=n(16),s=n(1),c=n(52),f=n(51),l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),p=function h(e,t,n){null===e&&(e=Function.prototype);var r=Object.getOwnPropertyDescriptor(e,t);if(void 0===r){var o=Object.getPrototypeOf(e);return null===o?void 0:h(o,t,n)}if("value"in r)return r.value;var i=r.get;if(void 0!==i)return i.call(n)},d=a.a.Types,b=function(e){function t(){return r(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),l(t,[{key:"makeUUID",value:function(e){return"t1__"===e.name&&e.parent_id?e.parent_id:e.name}},{key:"toRecord",value:function(){return this.uuid===this.name?p(Object.getPrototypeOf(t.prototype),"toRecord",this).call(this):new u.a(s.COMMENT_LOAD_MORE,this.parentId)}}]),t}(a.a);b.type=s.COMMENT,b.PROPERTIES={archived:d.bool,author:d.string,authorFlairCSSClass:d.string,authorFlairText:d.string,children:d.nop,controversiality:d.number,distinguished:d.string,downs:d.number,edited:d.bool,gilded:d.number,id:d.string,likes:d.cubit,name:d.string,replies:d.array,numReplies:d.number,loadMore:d.bool,saved:d.bool,score:d.number,stickied:d.bool,subreddit:d.string,ups:d.number,approvedBy:d.string,bannedBy:d.string,bodyHTML:d.html,createdUTC:d.number,linkId:d.string,linkTitle:d.string,modReports:d.array,numReports:d.number,parentId:d.string,reportReasons:d.array,scoreHidden:d.bool,subredditId:d.string,userReports:d.array,cleanPermalink:d.link},b.API_ALIASES={approved_by:"approvedBy",author_flair_css_class:"authorFlairCSSClass",author_flair_text:"authorFlairText",banned_by:"bannedBy",body_html:"bodyHTML",created_utc:"createdUTC",link_id:"linkId",link_title:"linkTitle",mod_reports:"modReports",num_reports:"numReports",parent_id:"parentId",report_reasons:"reportReasons",score_hidden:"scoreHidden",subreddit_id:"subredditId",user_reports:"userReports"},b.DERIVED_PROPERTIES={cleanPermalink:function(e){if(e.cleanPermalink)return e.cleanPermalink;var t=e.subreddit,n=e.link_id,r=e.id,o=e.context;return o?o:"/r/"+t+"/comments/"+n.substr(3)+"/comment/"+r}},t.a=b,c.a.bind()(b),f.a.bind()(b)},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n(9),u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=function(e){function t(e,n){r(this,t);var i=o(this,Object.getPrototypeOf(t).call(this,"URL "+n+" not reachable. You are probably disconnected from the internet."));return Object.assign(i,e),i}return i(t,e),t}(a.a);Object.defineProperty(t,"b",{configurable:!1,enumerable:!0,get:function(){return s}});var c={ECONNREFUSED:s,ENOTFOUND:s},f=function(e){function t(e,n){if(r(this,t),!e)throw new Error("No error passed to ResponseError");if(!n)throw new Error("No url passed to ResponseError");if(e.code&&e.syscall){var i;return i=t.getSystemLevelError(e,n),o(a,i)}var a=o(this,Object.getPrototypeOf(t).call(this,"Status "+e.status+" returned from API request to "+n));return Object.assign(a,e),a.name="ResponseError",a}return i(t,e),u(t,null,[{key:"getSystemLevelError",value:function(e,t){var n=c[e.code]||Error;return new n(e,t)}}]),t}(a.a);t.a=f},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function i(e){r(this,i),Object.defineProperty(this,"message",{value:e}),Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,this.constructor):Object.defineProperty(this,"stack",{value:(new Error).stack})};t.a=o},function(e,t,n){"use strict";function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,i){try{var a=t[o](i),u=a.value}catch(s){return void n(s)}return a.done?void e(u):Promise.resolve(u).then(function(e){return r("next",e)},function(e){return r("throw",e)})}return r("next")})}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(15),a=n(13),u=a&&a.__esModule?function(){return a["default"]}:function(){return a};Object.defineProperty(u,"a",{get:u});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),f=function(e){return e},l=function(){function e(t){o(this,e),this.apiResponse=t,this.nextResponse=this.nextResponse.bind(this),this.prevResponse=this.prevResponse.bind(this)}return c(e,null,[{key:"baseOptions",value:function(){return{}}},{key:"getResponse",value:function(){function e(e,n){return t.apply(this,arguments)}var t=r(regeneratorRuntime.mark(function n(e){var t,r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.endpoint.get(e,s({},this.baseOptions(),r));case 2:return t=n.sent,n.abrupt("return",t);case 4:case"end":return n.stop()}},n,this)}));return e}()},{key:"fetch",value:function(){function e(e,n){return t.apply(this,arguments)}var t=r(regeneratorRuntime.mark(function n(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.t0=this,n.next=3,this.getResponse(e,t);case 3:return n.t1=n.sent,n.abrupt("return",new n.t0(n.t1));case 5:case"end":return n.stop()}},n,this)}));return e}()}]),c(e,[{key:"afterId",value:function(e){return i.b.bind()(e)}},{key:"hasNextPage",value:function(){return!!this.afterId}},{key:"prevId",value:function(e){return i.c.bind()(e)}},{key:"hasPreviousPage",value:function(){return!!this.prevId}},{key:"nextResponse",value:function(){function e(e){return t.apply(this,arguments)}var t=r(regeneratorRuntime.mark(function n(e){var t,r;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.afterId(this.apiResponse)){n.next=3;break}return n.abrupt("return");case 3:return r=a.omit.bind()(s({},this.apiResponse.query,{after:t}),"before"),n.next=6,this.constructor.getResponse(e,r);case 6:return n.abrupt("return",n.sent);case 7:case"end":return n.stop()}},n,this)}));return e}()},{key:"prevResponse",value:function(){function e(e){return t.apply(this,arguments)}var t=r(regeneratorRuntime.mark(function n(e){var t,r;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.prevId(this.apiResponse)){n.next=3;break}return n.abrupt("return");case 3:return r=a.omit.bind()(s({},this.apiResponse.query,{before:t}),"after"),n.next=6,this.constructor.getResponse(e,r);case 6:return n.abrupt("return",n.sent);case 7:case"end":return n.stop()}},n,this)}));return e}()},{key:"fetchAndMakeInstance",value:function(){function e(e,n,r){return t.apply(this,arguments)}var t=r(regeneratorRuntime.mark(function n(e,t,r){var o;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e(t);case 2:if(o=n.sent,!o){n.next=5;break}return n.abrupt("return",new this.constructor(r(o)));case 5:case"end":return n.stop()}},n,this)}));return e}()},{key:"nextPage",value:function(){function e(e){return t.apply(this,arguments)}var t=r(regeneratorRuntime.mark(function n(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.fetchAndMakeInstance(this.nextResponse,e,f));case 1:case"end":return t.stop()}},n,this)}));return e}()},{key:"withNextPage",value:function(){function e(e){return t.apply(this,arguments)}var t=r(regeneratorRuntime.mark(function n(e){var t,r;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return t=this.nextResponse,r=this.apiResponse,n.abrupt("return",this.fetchAndMakeInstance(t,e,r.appendResponse));case 3:case"end":return n.stop()}},n,this)}));return e}()},{key:"prevPage",value:function(){function e(e){return t.apply(this,arguments)}var t=r(regeneratorRuntime.mark(function n(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.fetchAndMakeInstance(this.prevResponse,e,f));case 1:case"end":return t.stop()}},n,this)}));return e}()},{key:"withPrevPage",value:function(){function e(e){return t.apply(this,arguments)}var t=r(regeneratorRuntime.mark(function n(e){var t=this;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.fetchAndMakeInstance(this.prevResponse,e,function(e){return e.appendResponse(t.apiResponse)}));case 1:case"end":return n.stop()}},n,this)}));return e}()}]),e}();l.endpoint={get:function(){}},t.a=l},function(e,t){function n(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=n},function(e,t){function n(e){return!!e&&"object"==typeof e}e.exports=n},function(e,t){e.exports=require("lodash/object")},function(e,t,n){"use strict";function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var u=n(167),s=u&&u.__esModule?function(){return u["default"]}:function(){return u};Object.defineProperty(s,"a",{get:s});var c=n(32),f=c&&c.__esModule?function(){return c["default"]}:function(){return c};Object.defineProperty(f,"a",{get:f});var l=n(1),p=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),d=function(){function e(){var t;a(this,e),this.results=[],this.posts={},this.comments={},this.accounts={},this.messages={},this.subreddits={},this.wikis={},this.typeToTable=(t={},i(t,l.COMMENT,this.comments),i(t,l.POST,this.posts),i(t,l.ACCOUNT,this.accounts),i(t,l.MESSAGE,this.messages),i(t,l.SUBREDDIT,this.subreddits),i(t,l.WIKI,this.wikis),t),this.addResult=this.addResult.bind(this),this.addModel=this.addModel.bind(this),this.makeRecord=this.makeRecord.bind(this),this.addToTable=this.addToTable.bind(this),this.getModelFromRecord=this.getModelFromRecord.bind(this),this.appendResponse=this.appendResponse.bind(this)}return p(e,[{key:"addResult",value:function(e){if(!e)return this;var t=this.makeRecord(e);return t&&(this.results.push(t),this.addToTable(t,e)),this}},{key:"addModel",value:function(e){if(!e)return this;var t=this.makeRecord(e);return t&&this.addToTable(t,e),this}},{key:"makeRecord",value:function(e){if(e.toRecord)return e.toRecord();var t=e.uuid;if(t){var n=l.TYPES[e.kind]||l.thingType.bind()(t);if(n)return{type:n,uuid:t}}}},{key:"addToTable",value:function(e,t){var n=this.typeToTable[e.type];return n&&(n[e.uuid]=t),this}},{key:"getModelFromRecord",value:function(e){var t=this.typeToTable[e.type];return t?t[e.uuid]:void 0}},{key:"appendResponse",value:function(){throw new Error("Not implemented in base class")}}]),e}(),b=function(e){function t(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];a(this,t);var i=r(this,Object.getPrototypeOf(t).call(this));return i.request=e.req,i.response=e,i.meta=n,i.query=o,i}return o(t,e),p(t,[{key:"appendResponse",value:function(e){return new h([this,e])}}]),t}(d);t.a=b;var h=function(e){function t(e){a(this,t);var n=r(this,Object.getPrototypeOf(t).call(this));n.metas=e.map(function(e){return e.meta}),n.querys=e.map(function(e){return e.query}),n.apiResponses=e;var o=new Set,i=[l.COMMENT,l.ACCOUNT,l.POST,l.MESSAGE,l.SUBREDDIT];return u.forEach.bind()(e,function(e){u.forEach.bind()(e.results,function(e){o.has(e.uuid)||(o.add(e.uuid),n.results.push(e))}),u.forEach.bind()(i,function(t){var r=n.typeToTable[t];Object.assign(r,e.typeToTable[t])})}),n}return o(t,e),p(t,[{key:"appendResponse",value:function(e){var n=this.apiResponses.slice();return n.push(e),new t(n)}},{key:"lastResponse",get:function(){return c.last.bind()(this.apiResponses)}},{key:"lastQuery",get:function(){return c.last.bind()(this.querys)}},{key:"lastMeta",get:function(){return c.last.bind()(this.meta)}},{key:"query",get:function(){return this.latQuery}}]),t}(d);Object.defineProperty(t,"b",{configurable:!1,enumerable:!0,get:function(){return h}})},function(e,t,n){"use strict";function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,i){try{var a=t[o](i),u=a.value}catch(s){return void n(s)}return a.done?void e(u):Promise.resolve(u).then(function(e){return r("next",e)},function(e){return r("throw",e)})}return r("next")})}}var o=n(32),i=o&&o.__esModule?function(){return o["default"]}:function(){return o};Object.defineProperty(i,"a",{get:i});var a=n(14),u=this,s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(e,t){var n=void 0,r=void 0;return e instanceof a.b?(n=e.lastQuery,r=e.lastResponse.results):(n=e.query,r=e.results),t(n,r)};Object.defineProperty(t,"a",{configurable:!1,enumerable:!0,get:function(){return c}});var f=function(e){return c(e,function(e,t){var n=e.limit||25;return t.length>=n?o.last.bind()(t).paginationId:null})};Object.defineProperty(t,"b",{configurable:!1,enumerable:!0,get:function(){return f}});var l=function(e){return c(e,function(e,t){return e.after?t[0].paginationId:null})};Object.defineProperty(t,"c",{configurable:!1,enumerable:!0,get:function(){return l}});var p=function(){var e=r(regeneratorRuntime.mark(function t(e,n,r){var o,i,a,c=arguments.length<=3||void 0===arguments[3]?f:arguments[3];return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return o=s({},r),t.next=3,e(n,o);case 3:i=t.sent,a=c(i);case 5:if(!a){t.next=15;break}return o=s({},o,{after:a}),t.t0=i,t.next=10,e(n,o);case 10:t.t1=t.sent,i=t.t0.appendResponse.call(t.t0,t.t1),a=f(i),t.next=5;break;case 15:return t.abrupt("return",i);case 16:case"end":return t.stop()}},t,u)}));return function(t,n,r,o){return e.apply(this,arguments)}}();Object.defineProperty(t,"d",{configurable:!1,enumerable:!0,get:function(){return p}})},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function i(e,t){var n=arguments.length<=2||void 0===arguments[2]?t:arguments[2];r(this,i),this.type=e,this.uuid=t,this.paginationId=n};t.a=o},function(e,t,n){function r(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}var o=n(137),i=n(138),a=n(139),u=n(140),s=n(141);r.prototype.clear=o,r.prototype["delete"]=i,r.prototype.get=a,r.prototype.has=u,r.prototype.set=s,e.exports=r},function(e,t,n){function r(e,t){for(var n=e.length;n--;)if(o(e[n][0],t))return n;return-1}var o=n(67);e.exports=r},function(e,t,n){function r(e,t){var n=e.__data__;return o(t)?n["string"==typeof t?"string":"hash"]:n.map}var o=n(134);e.exports=r},function(e,t,n){function r(e,t){if(o(e))return!1;var n=typeof e;return"number"==n||"symbol"==n||"boolean"==n||null==e||i(e)?!0:u.test(e)||!a.test(e)||null!=t&&e in Object(t)}var o=n(3),i=n(30),a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,u=/^\w*$/;e.exports=r},function(e,t,n){var r=n(6),o=r(Object,"create");e.exports=o},function(e,t,n){function r(e){if("string"==typeof e||o(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}var o=n(30),i=1/0;e.exports=r},function(e,t,n){function r(e){return null!=e&&a(o(e))&&!i(e)}var o=n(121),i=n(69),a=n(24);e.exports=r},function(e,t){function n(e){return"number"==typeof e&&e>-1&&e%1==0&&r>=e}var r=9007199254740991;e.exports=n},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n(9),u=function(e){function t(e){r(this,t);var n=o(this,Object.getPrototypeOf(t).call(this,e));return n.name="NoModelError",n.message="No model given for api endpoint "+e,n.status=400,n}return i(t,e),t}(a.a);t.a=u},function(e,t,n){"use strict";var r=n(47),o=n(48),i=n(13),a=i&&i.__esModule?function(){return i["default"]}:function(){return i};Object.defineProperty(a,"a",{get:a});var u=n(7),s=n(4),c=n(86),f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(e,t){return o.a.bind()(e,t),e.ids&&(e.children=e.ids.join(","),e.api_type="json",e.link_id=e.linkId,delete e.ids,delete e.linkId),e},p=function(e){return e.user?"user/"+e.user+"/comments.json":e.ids?"api/morechildren.json":"comments/"+(e.id||e.linkId).replace(/^t3_/,"")+".json"},d=function(e,t){var n=e.response.body,r=[];if(Array.isArray(n)){var o=n[0].data;o&&o.children&&o.children.length&&o.children.forEach(function(t){e.addModel(s.a.fromJSON(t.data))}),r=c.a.bind()(n[1].data.children)}else n.json&&n.json.data&&(r=t?c.b.bind()(c.a.bind()(n.json.data.things)):c.a.bind()(n.json.data.things));return c.c.bind()(r,function(t,n){var r=u.a.fromJSON(t);return n?e.addResult(r):e.addModel(r),r.toRecord()}),e},b=function(e){var t=e.response.body;if(i.has.bind()(t,"json.data.things.0.data")){var n=t.json.data.things[0].data;e.addResult(u.a.fromJSON(n))}return e};t.a={get:function(e,t){var n=!!t.children,o=p(t),i=l(f({raw_json:1},t));return r.a.bind()(e,"GET",o,{query:i}).then(function(e){return d(e,n)})},post:function(e,t){var n="api/comment",o={api_type:"json",thing_id:t.thingId,text:t.text,raw_json:1};return r.a.bind()(e,"POST",n,{body:o,type:"form"}).then(b)},del:function(e,t){var n={id:t};return r.a.bind()(e,"POST","api/del",{body:n,type:"form"})}}},function(e,t,n){"use strict";function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,i){try{var a=t[o](i),u=a.value}catch(s){return void n(s)}return a.done?void e(u):Promise.resolve(u).then(function(e){return r("next",e)},function(e){return r("throw",e)})}return r("next")})}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t;
}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=n(5),s=n(1),c=n(42),f=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=u.a.Types,p=["default_set","subreddit_id","domain","show_media","wiki_edit_age","submit_text","spam_links","title","collapse_deleted_comments","wikimode","over_18","related_subreddits","suggested_comment_sort","description","submit_link_label","spam_comments","spam_selfposts","submit_text_label","key_color","language","wiki_edit_karma","hide_ads","header_hover_text","public_traffic","public_description","comment_score_hide_mins","subreddit_type","exclude_banned_modqueue","submission_type"].sort(),d=function(e){function t(){return o(this,t),i(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),f(t,[{key:"makeUUID",value:function(e){var n=e.url;return t.cleanName(n)}},{key:"makePaginationId",value:function(e){return e.name}},{key:"toggleSubscribed",value:function(e){var t=this,n=this.userIsSubscriber,o=!n,i=this,a=this.stub("userIsSubscriber",o,r(regeneratorRuntime.mark(function u(){var n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n={subreddit:i.name},r=o?c.a.post:c.a.del,t.next=5,r(e,n);case 5:return t.abrupt("return",a);case 8:throw t.prev=8,t.t0=t["catch"](0),i;case 11:case"end":return t.stop()}},u,t,[[0,8]])})));return a}}]),t}(u.a);d.type=s.SUBREDDIT,d.fields=p,d.PROPERTIES={accountsActive:l.number,bannerImage:l.string,bannerSize:l.arrayOf(l.number),collapseDeletedComments:l.bool,commentScoreHideMins:l.number,createdUTC:l.number,description:l.string,descriptionHTML:l.string,displayName:l.string,headerImage:l.string,headerSize:l.arrayOf(l.number),headerTitle:l.string,hideAds:l.bool,iconImage:l.string,iconSize:l.arrayOf(l.number),id:l.string,keyColor:l.string,lang:l.string,name:l.string,over18:l.bool,publicDescription:l.string,publicTraffic:l.nop,quarantine:l.bool,relatedSubreddits:l.array,submissionType:l.string,submitLinkLabel:l.string,submitText:l.string,submitTextLabel:l.string,subredditType:l.string,subscribers:l.number,suggestedCommentSort:l.string,title:l.string,url:l.string,userIsBanned:l.bool,userIsContributor:l.bool,userIsModerator:l.bool,userIsMuted:l.bool,userIsSubscriber:l.bool,userSrThemeEnabled:l.bool,wikiEnabled:l.bool},d.API_ALIASES={accounts_active:"accountsActive",banner_img:"bannerImage",banner_size:"bannerSize",collapse_deleted_comments:"collapseDeletedComments",comment_score_hide_mins:"commentScoreHideMins",created_utc:"createdUTC",description_html:"descriptionHTML",display_name:"displayName",header_img:"headerImage",header_size:"headerSize",header_title:"headerTitle",hide_ads:"hideAds",icon_img:"iconImage",icon_size:"iconSize",key_color:"keyColor",public_description:"publicDescription",public_traffic:"publicTraffic",related_subreddits:"relatedSubreddits",submission_type:"submissionType",submit_link_label:"submitLinkLabel",submit_text_label:"submitTextLabel",submit_text:"submitText",subreddit_type:"subredditType",user_is_banned:"userIsBanned",user_is_contributor:"userIsContributor",user_is_moderator:"userIsModerator",user_is_muted:"userIsMuted",user_is_subscriber:"userIsSubscriber",user_sr_theme_enabled:"userSrThemeEnabled",wiki_enabled:"wikiEnabled"},d.cleanName=function(e){return e?e.replace(/^\/?r\//,"").replace(/\/?$/,"").toLowerCase():e},t.a=d},function(e,t,n){function r(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}var o=n(142),i=n(143),a=n(144),u=n(145),s=n(146);r.prototype.clear=o,r.prototype["delete"]=i,r.prototype.get=a,r.prototype.has=u,r.prototype.set=s,e.exports=r},function(e,t){function n(e,t){return t=null==t?r:t,!!t&&("number"==typeof e||o.test(e))&&e>-1&&e%1==0&&t>e}var r=9007199254740991,o=/^(?:0|[1-9]\d*)$/;e.exports=n},function(e,t,n){function r(e){return"symbol"==typeof e||o(e)&&u.call(e)==i}var o=n(12),i="[object Symbol]",a=Object.prototype,u=a.toString;e.exports=r},function(e,t,n){function r(e){var t=c(e);if(!t&&!u(e))return i(e);var n=a(e),r=!!n,f=n||[],l=f.length;for(var p in e)!o(e,p)||r&&("length"==p||s(p,l))||t&&"constructor"==p||f.push(p);return f}var o=n(58),i=n(108),a=n(132),u=n(23),s=n(29),c=n(136);e.exports=r},function(e,t){e.exports=require("lodash/array")},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(16),a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=function(){return(16*Math.random()).toFixed()},f=function(){function e(t,n){o(this,e);for(var r=this.constructor,i=r.API_ALIASES,a=r.PROPERTIES,u=r.DERIVED_PROPERTIES,s=Object.keys(t),c=0;c<s.length;c++){var f=s[c];if(!u[f]){var l=i[f];l||(l=f);var p=a[l];p&&(this[l]=p(t[f]))}}for(var d=Object.keys(u),b=0;b<d.length;b++){var h=d[b],v=u[h],y=a[h];v&&y&&(this[h]=y(v(t)))}this.uuid=this.makeUUID(t),this.paginationId=this.makePaginationId(t),this.type=this.getType(t,this.uuid),n||Object.freeze(this)}return s(e,null,[{key:"fromJSON",value:function(e){return new this(e)}},{key:"Mock",value:function(){var e=this,t=Object.keys(this.PROPERTIES).reduce(function(t,n){return u({},t,r({},n,e.MOCKS[n]?e.MOCKS[n]():null))},{});return new this(t)}}]),s(e,[{key:"_diff",value:function(e,t){return"object"===("undefined"==typeof e?"undefined":a(e))?e:r({},e,t)}},{key:"set",value:function(e,t){return new this.constructor(u({},this.toJSON(),this._diff(e,t)))}},{key:"stub",value:function t(e,n,r){r||(r=n);var o=u({},this.toJSON(),this._diff(e,n)),t=new this.constructor(o,!0);return t.promise=r,Object.freeze(t),t}},{key:"makeUUID",value:function(e){return e.uuid?e.uuid:e.id?e.id:(console.warn("generating fake uuid"),c())}},{key:"makePaginationId",value:function(e){return this.uuid||this.makeUUID(e)}},{key:"getType",value:function(){return this.constructor.type}},{key:"toRecord",value:function(){return new i.a(this.type,this.uuid,this.paginationId)}},{key:"toJSON",value:function(){var e=this,t={};return Object.keys(this).forEach(function(n){e.constructor.PROPERTIES[n]&&(t[n]=e[n])}),t.__type=this.type,t}}]),e}();f.Types={string:function(e){return e?String(e):""},number:function(e){return void 0===e?0:Number(e)},array:function(e){return Array.isArray(e)?e:[]},arrayOf:function(){var e=arguments.length<=0||void 0===arguments[0]?f.Types.nop:arguments[0];return function(t){return f.Types.array(t).map(e)}},bool:function(e){return Boolean(e)},cubit:function(e){var t=Number(e);return t>0?1:0>t?-1:0},nop:function(e){return e}},f.MockTypes={string:function(){return Math.random().toString(36).substring(Math.floor(10*Math.random())+5)},number:function(){return Math.floor(100*Math.random())},array:function(){return Array.apply(null,Array(Math.floor(10*Math.random())))},bool:function(){return Math.floor(10*Math.random())<5},cubit:function(){return Math.round(2*Math.random()+-1)},nop:function(){return null}},f.API_ALIASES={},f.PROPERTIES={},f.MOCKS={},f.DERIVED_PROPERTIES={},t.a=f},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n(9),u="Incorrect captcha provided.",s="No captcha provided.",c=function(e){function t(e,n,i){r(this,t);var a=e?u:s,c=o(this,Object.getPrototypeOf(t).call(this,a));return c.name="BadCaptchaError",c.captcha=e,c.newCaptcha=n,c.errors=i,c.status=200,c}return i(t,e),t}(a.a);t.a=c},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n(9),u=function(e){function t(e,n){r(this,t);var i=o(this,Object.getPrototypeOf(t).call(this,e,n));return i.name="NotImplementedError",i.message="Method "+e+" not implemented for api endpoint "+n,i.status=405,i}return i(t,e),t}(a.a);t.a=u},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n(9),u=function(e,t){return e+" had errors in "+t.join(",")},s=function(e){function t(e,n,i){r(this,t);var a=n&&n.length?u(e,n):"Validation error in '"+e+"'",s=o(this,Object.getPrototypeOf(t).call(this,a));return s.name="ValidationError",s.errors=n,s.status=i,s}return i(t,e),t}(a.a);t.a=s},function(e,t,n){"use strict";var r=n(49),o=function(e){return"user/"+e.user+"/hidden.json"};t.a=r.a.bind()(o,"api/unhide","api/hide")},function(e,t,n){"use strict";var r=n(164),o=r&&r.__esModule?function(){return r["default"]}:function(){return r};Object.defineProperty(o,"a",{get:o});var i=n(47),a=n(34),u=n(4),s=n(48),c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},f="BAD_CAPTCHA",l=function(e){return e.user?"user/"+e.user+"/submitted.json":e.id?"by_id/"+e.id+".json":e.ids?"by_id/"+e.query.ids.join(",")+".json":e.subredditName?"r/"+e.subredditName+".json":e.multi?"user/"+e.multiUser+"/m/"+e.multi+".json":(e.sort||"hot")+".json"},p=function(e,t){return s.a.bind()(e,t),"patch"!==t&&(e.feature="link_preview",e.sr_detail="true"),"del"===t&&(e._method="post"),e},d=function(e){var t={api_type:"json",thing_id:e.thingId,title:e.title,kind:e.kind,sendreplies:e.sendreplies,sr:e.sr,iden:e.iden,captcha:e.captcha,resubmit:e.resubmit};return e.text?t.text=e.text:e.url&&(t.url=e.url),t},b=function(e){var t=e.response.body.data;return t&&t.children&&t.children[0]&&(1===t.children.length?e.addResult(u.a.fromJSON(t.children[0].data)):t.children.forEach(function(t){return e.addResult(u.a.fromJSON(t.data))})),e};t.a={get:function(e,t){var n=l(t),r=p(c({},t),"get");return i.a.bind()(e,"GET",n,{query:r}).then(b)},post:function(e,t){var n="api/submit",r=d(t);return i.a.bind()(e,"POST",n,{query:r}).then(function(e){var r=e.response.body.json;if(r.errors.length&&o.a.bind()(r.errors,function(e){return e[0]===f}))throw new a.a(t.captcha,r.captcha,r.errors);if(r.errors.length)throw new ValidationError(n,r.errors,200);return e.response.body})}}},function(e,t,n){"use strict";var r=n(49),o=function(e){return"user/"+e.user+"/saved.json"};t.a=r.a.bind()(o,"api/unsave","api/save")},function(e,t,n){"use strict";var r=n(0),o=n(4),i=n(27),a=n(1),u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(e){var t="";return e.subreddit&&(t="r/"+e.subreddit+"/"),t+"search.json"},c=function(e){return e.subreddit&&(e.restrict_sr="on",delete e.subreddit),e},f=function(e){var t=e.body;return t?Array.isArray(t)?t:[t]:[]},l=function(e,t){var n=f(e);console.log("lists.length?",n.length),console.log(e.body),n.forEach(function(e){e.data.children.length&&(e.data.children[0].kind===a.POST_TYPE?(e.data.children.forEach(function(e){t.addResult(o.a.fromJSON(e.data))}),t.meta.after=e.data.after,t.meta.before=e.data.before):e.data.children.forEach(function(e){t.addResult(i.a.fromJSON(e.data))}))})};t.a={get:function(e,t){var n=s(t),o=c(u({},t));return r.c.bind()(e,"get",n,o,t,l)}}},function(e,t,n){"use strict";var r=n(0),o=n(13),i=o&&o.__esModule?function(){return o["default"]}:function(){return o};Object.defineProperty(i,"a",{get:i});var a=n(168),u=a&&a.__esModule?function(){return a["default"]}:function(){return a};Object.defineProperty(u,"a",{get:u});var s=n(27),c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},f={allow_top:!0,collapse_deleted_comments:!1,comment_score_hide_mins:0,description:"",exclude_banned_modqueue:!1,"header-title":"",hide_ads:!1,lang:"en",link_type:"any",name:"",over_18:!1,public_description:"",public_traffic:!1,show_media:!0,spam_comments:"low",spam_links:"high",spam_selfposts:"high",sr:"",submission_type:"",submit_link_label:"",submit_text:"",submit_text_label:"",suggested_comment_sort:"confidence",title:"",type:"public",wiki_edit_age:0,wiki_edit_karma:100,wikimode:"disabled"},l="api/site_admin",p=function(e){return e.id&&"mod"===e.view?"r/"+e.id+"/about/edit.json":e.id?"r/"+e.id+"/about.json":"subreddits/"+(e.sort||"default")+".json"},d=function(e,t){return"get"!==t&&(e.api_type="json"),e},b=function(e,t){var n=e.body;n.data&&Array.isArray(n.data.children)?n.data.children.forEach(function(e){return t.addResult(s.a.fromJSON(e.data))}):a.isEmpty.bind()(n)||t.addResult(s.a.fromJSON(n.data||n))},h=function(e,t){var n=p(t),o=d(c({},t));return r.c.bind()(e,"get",n,o,t,b)},v=function(e,t){return Object.keys(t).sort()!==s.a.fields?new Promise(function(n,r){h(e,{id:t.id,view:"mod"}).then(function(n){1===!n.results.length&&r();var i=n.getModelFromRecord(n.results[0]),a=o.pick.bind()(c({},f,i,t,{sr:i.name}),Object.keys(f));return y(e,a)},r)}):y(e,t)},y=function(e,t){var n=o.pick.bind()(c({},f,t),Object.keys(f));return r.c.bind()(e,"post",l,n,t,b)},m=function(e,t){var n=c({},t,{name:t.id});return y(e,n)};t.a={get:h,patch:v,post:y,put:m}},function(e,t,n){"use strict";var r=n(0),o="api/subscribe",i=function(e){return!!e.subreddit},a=function(e,t){r.a.bind()(t,"post","subscriptions",i);var n={sr:t.subreddit,action:"sub",api_type:"json"};return r.c.bind()(e,"post",o,n,t)},u=function(e,t){r.a.bind()(t,"del","subscriptions",i);var n={sr:t.subreddit,action:"unsub",api_type:"json"};return r.c.bind()(e,"post",o,n,t)};t.a={post:a,del:u}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n(10),u=n(39),s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=function l(e,t,n){null===e&&(e=Function.prototype);var r=Object.getOwnPropertyDescriptor(e,t);if(void 0===r){var o=Object.getPrototypeOf(e);return null===o?void 0:l(o,t,n)}if("value"in r)return r.value;var i=r.get;if(void 0!==i)return i.call(n)},f=function(e){function t(){return r(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),s(t,[{key:"postsAndComments",get:function(){return this.apiResponse.results.map(this.apiResponse.getModelFromRecord)}}],[{key:"fetch",value:function(e,n){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return"string"==typeof n?r.user=n:r=n||{},c(Object.getPrototypeOf(t),"fetch",this).call(this,e,r)}}]),t}(a.a);f.endpoint=u.a,t.a=f},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n