UNPKG

@r/api-client

Version:

node and browser reddit api library

2 lines 68.2 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("lodash/object"),require("lodash/array"),require("lodash/collection"),require("lodash/lang"),require("superagent")):"function"==typeof define&&define.amd?define(["lodash/object","lodash/array","lodash/collection","lodash/lang","superagent"],t):"object"==typeof exports?exports["apiClient.js"]=t(require("lodash/object"),require("lodash/array"),require("lodash/collection"),require("lodash/lang"),require("superagent")):e["apiClient.js"]=t(e["lodash/object"],e["lodash/array"],e["lodash/collection"],e["lodash/lang"],e.superagent)}(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=43)}([function(e,t,n){"use strict";var r=n(52),o=r&&r.__esModule?function(){return r["default"]}:function(){return r};Object.defineProperty(o,"a",{get:o});var i=n(18),u=n(11),a=n(10),s=n(41),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={emit:function(){},on:function(){},off:function(){}},l={userAgent:"snoodev3",origin:"https://www.reddit.com",appName:"node-api-client-v3",env:"develop",token:"",timeout:5e3,eventEmitter:f},p=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return c({},l,e)};Object.defineProperty(t,"d",{configurable:!1,enumerable:!0,get:function(){return p}});var d=function(e){return e.eventEmitter||f},b=function(e){var t=e.token;return t?{Authorization:"Bearer "+t}:{}},h=function(e){var t=b(e);return c({},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},v=function(e,t,n,r,i,u){var a=e.origin,f=y(e,n),l={origin:a,path:n,url:f,method:t,query:c({},r)};d(e).emit(s.a.request,l);var p=o.a[t](f);p.set(h(e)),r.app=m(e),"form"===i?(p.type("form"),p.send(r)):(p.query(r),p.redirects&&p.redirects(0)),p.end(function(e,t){var n=t?t.request:l;u(e,t,n)})};Object.defineProperty(t,"e",{configurable:!1,enumerable:!0,get:function(){return v}});var g=function(e,t,n,r){if(!e||!r)throw new i.a(n,void 0);if(!r(t))throw new i.a(n,e)};Object.defineProperty(t,"a",{configurable:!1,enumerable:!0,get:function(){return g}});var O=function(e,t,n,r,o,i){if(!(e&&t&&n&&r))throw new u.a;return new Promise(function(u,a){v(e,t,n,r,"form",function(n,s,c){P(e,u,a,n,s,c,r,t,o,i)})})};Object.defineProperty(t,"b",{configurable:!1,enumerable:!0,get:function(){return O}});var _=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){v(e,t,n,r,"query",function(n,r,c){P(e,u,s,n,r,c,o,t,i,a)})})};Object.defineProperty(t,"c",{configurable:!1,enumerable:!0,get:function(){return _}});var w=function(e,t){return e&&!t?e.request||e.req:t},j=function(e,t,n,r,o){if(t||n&&!n.ok){d(e).emit(s.a.error,t,r);var i=e.defaultErrorHandler||o;return i(t||500),!0}},P=function(e,t,n,r,o,i,u,a,c,f){if(i=w(o,i),!j(e,r,o,i,n)){d(e).emit(s.a.response,i,o);var l=k(n,o,i,a,u,c,f);d(e).emit(s.a.result,l),t(l)}},k=function(e,t,n,r,o,i,u){try{return R(t,n,r,o,i,u)}catch(a){console.trace(a),e(a)}},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(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 u="comment_load_more";Object.defineProperty(t,"COMMENT_LOAD_MORE",{configurable:!1,enumerable:!0,get:function(){return u}});var a="account";Object.defineProperty(t,"ACCOUNT",{configurable:!1,enumerable:!0,get:function(){return a}});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 y="t6";Object.defineProperty(t,"TROPHIE_TYPE",{configurable:!1,enumerable:!0,get:function(){return y}});var m="promocampaign";Object.defineProperty(t,"PROMOCAMPAIGN",{configurable:!1,enumerable:!0,get:function(){return m}});var v="t8";Object.defineProperty(t,"PROMOCAMPAIGN_TYPE",{configurable:!1,enumerable:!0,get:function(){return v}});var g="wiki";Object.defineProperty(t,"WIKI",{configurable:!1,enumerable:!0,get:function(){return g}});var O="wiki";Object.defineProperty(t,"WIKI_TYPE",{configurable:!1,enumerable:!0,get:function(){return O}});var _=[[o,i],[a,s],[c,f],[l,p],[d,b],[h,y],[m,v],[g,O]],w=_.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=_.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){"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 u=n(4),a=n(1),s=n(32),c=n(31),f=u.a.Types,l=function(e){function t(){return r(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),t}(u.a);l.type=a.POST,l.PROPERTIES={author:f.string,cleanPermalink:f.link,cleanUrl:f.link,distinguished:f.string,domain:f.string,downs:f.number,id:f.string,likes:f.cubit,malink:f.link,media:f.nop,name:f.string,postHint:f.string,promoted:f.bool,quarantine:f.bool,saved:f.bool,score:f.number,sticked: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},l.API_ALIASES={author_flair_css_class:"authorFlairCSSClass",author_flair_text:"authorFlairText",created_utc:"createdUTC",hide_score:"hideScore",is_self:"isSelf",link_flair_css_class:"linkFlairCSSClass",link_flair_text:"linkFlairText",media_oembed:"mediaOembed",mod_reports:"modReports",num_comments:"numComments",permalink:"cleanPermalink",post_hint:"postHint",secure_media:"secureMedia",selftext_html:"selfTextHTML",sr_detail:"subredditDetail",subreddit_id:"subredditId",sendreplies:"sendReplies",url:"cleanUrl",user_reports:"userReports"},l.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=[];return e.mobile_ad_url&&t.push({url:e.mobile_ad_url,height:628,width:1200}),e.thumbnail&&t.push({url:e.thumbnail,height:140,width:140}),{images:[{resolutions:t}]}}},t.a=l,s.a.bind()(l),c.a.bind()(l)},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 u=t[o](i),a=u.value}catch(s){return void n(s)}return u.done?void e(a):Promise.resolve(a).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(6),u=n(5),a=u&&u.__esModule?function(){return u["default"]}:function(){return u};Object.defineProperty(a,"a",{get:a});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=u.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=u.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,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 u=n(16),a=n(1),s=n(45),c=n(46),f=n(47),l=n(48),p=n(49),d=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},b=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}}(),h=function m(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:m(o,t,n)}if("value"in r)return r.value;var i=r.get;if(void 0!==i)return i.call(n)},y=function(e){function t(){return r(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),b(t,[{key:"makeUUID",value:function(e){return s.a.bind()(e.name)?e.name:s.a.bind()(e.id)?e.id:h(Object.getPrototypeOf(t.prototype),"makeUUID",this).call(this,e)}},{key:"getType",value:function(e,n){return h(Object.getPrototypeOf(t.prototype),"getType",this).call(this,e,n)||a.TYPES[e.kind]||a.thingType.bind()(n)||"Unknown"}}]),t}(u.a);y.Types=d({},u.a.Types,{html:function(e){return c.a.bind()(u.a.Types.string(e))},link:function(e){return f.a.bind()(u.a.Types.string(e))}}),y.MockTypes=d({},u.a.MockTypes,{html:l.a,link:p.a}),t.a=y},function(e,t){e.exports=require("lodash/object")},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 u=t[o](i),a=u.value}catch(s){return void n(s)}return u.done?void e(a):Promise.resolve(a).then(function(e){return r("next",e)},function(e){return r("throw",e)})}return r("next")})}}var o=n(15),i=o&&o.__esModule?function(){return o["default"]}:function(){return o};Object.defineProperty(i,"a",{get:i});var u=n(10),a=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 u.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,u,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,u=c(i);case 5:if(!u){t.next=15;break}return o=s({},o,{after:u}),t.t0=i,t.next=10,e(n,o);case 10:t.t1=t.sent,i=t.t0.appendResponse.call(t.t0,t.t1),u=f(i),t.next=5;break;case 15:return t.abrupt("return",i);case 16:case"end":return t.stop()}},t,a)}));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){"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 u=n(4),a=n(7),s=n(1),c=n(32),f=n(31),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=u.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 a.a(s.COMMENT_LOAD_MORE,this.parentId)}}]),t}(u.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",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;return"/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")}var o=function i(e){r(this,i),Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,this.constructor):(Object.defineProperty(this,"stack",{value:(new Error).stack}),Object.defineProperty(this,"message",{value:e}))};t.a=o},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 u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=n(50),s=a&&a.__esModule?function(){return a["default"]}:function(){return a};Object.defineProperty(s,"a",{get:s});var c=n(15),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;u(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(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];u(this,t);var o=r(this,Object.getPrototypeOf(t).call(this));return o.meta=e,o.query=n,o}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){u(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 a.forEach.bind()(e,function(e){a.forEach.bind()(e.results,function(e){o.has(e.uuid)||(o.add(e.uuid),n.results.push(e))}),a.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,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 u=n(9),a=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}(u.a);t.a=a},function(e,t,n){"use strict";var r=n(0),o=n(28),i=n(5),u=i&&i.__esModule?function(){return i["default"]}:function(){return i};Object.defineProperty(u,"a",{get:u});var a=n(8),s=n(2),c=n(44),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,n){var r=n.query,o=e.body,i=[];if(Array.isArray(o)){var u=o[0].data;u&&u.children&&u.children.length&&u.children.forEach(function(e){t.addModel(s.a.fromJSON(e.data))}),i=c.a.bind()(o[1].data.children)}else o.json&&o.json.data&&(i=r.children?c.b.bind()(c.a.bind()(o.json.data.things)):c.a.bind()(o.json.data.things));c.c.bind()(i,function(e,n){var r=a.a.fromJSON(e);return n?t.addResult(r):t.addModel(r),r.toRecord()})},b=function(e,t){var n=e.body;if(i.has.bind()(n,"json.data.things.0.data")){var r=n.json.data.things[0].data;t.addResult(a.a.fromJSON(r))}};t.a={get:function(e,t){var n=p(t),o=l(f({},t));return r.c.bind()(e,"get",n,o,t,d)},post:function(e,t){var n="api/comment",o={api_type:"json",thing_id:t.thingId,text:t.text,raw_json:1};return r.b.bind()(e,"post",n,o,b)}}},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 u=t[o](i),a=u.value}catch(s){return void n(s)}return u.done?void e(a):Promise.resolve(a).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 u(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(4),s=n(1),c=n(24),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=a.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 u(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,u=this.stub("userIsSubscriber",o,r(regeneratorRuntime.mark(function a(){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",u);case 8:throw t.prev=8,t.t0=t["catch"](0),i;case 11:case"end":return t.stop()}},a,t,[[0,8]])})));return u}}]),t}(a.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){"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 u=n(9),a=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,e));return Object.assign(i,e),i.message="URL "+n+" not reachable. You are probably disconnected from the internet.",i}return i(t,e),t}(u.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(u,i)}var u=o(this,Object.getPrototypeOf(t).call(this,e));return Object.assign(u,e),u.name="ResponseError",u.message="Status "+e.status+" returned from API request to "+n,u}return i(t,e),a(t,null,[{key:"getSystemLevelError",value:function(e,t){var n=c[e.code]||Error;return new n(e,t)}}]),t}(u.a);t.a=f},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(7),u="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},a=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,u=r.PROPERTIES,a=r.DERIVED_PROPERTIES,s=Object.keys(t),c=0;c<s.length;c++){var f=s[c];if(!a[f]){var l=i[f];l||(l=f);var p=u[l];p&&(this[l]=p(t[f]))}}for(var d=Object.keys(a),b=0;b<d.length;b++){var h=d[b],y=a[h],m=u[h];y&&m&&(this[h]=m(y(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 a({},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":u(e))?e:r({},e,t)}},{key:"set",value:function(e,t){return new this.constructor(a({},this.toJSON(),this._diff(e,t)))}},{key:"stub",value:function t(e,n,r){r||(r=n);var o=a({},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 u=(n(9),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}(Error));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 u=n(9),a=function(e){function t(e,n,i){r(this,t);var u=o(this,Object.getPrototypeOf(t).call(this,e));return u.name="NoModelError",u.message=e+" had errors in: "+i.join(",")+" with properties "+JSON.stringify(n.toJSON()),u.status=422,u}return i(t,e),t}(u.a);t.a=a},function(e,t,n){"use strict";var r=n(29),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(0),o=n(2),i=n(28),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},a=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=e.sort||"hot",e.sort+".json")},s=function(e,t){return i.a.bind()(e,t),"patch"!==t&&(e.feature="link_preview",e.sr_detail="true"),"del"===t&&(e._method="post"),e},c=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},f=function(e,t,n,r){var i=e.body;if("get"===r){var u=i.data;if(u&&u.children&&u.children[0])return 1===u.children.length?void t.addResult(o.a.fromJSON(u.children[0].data)):void u.children.forEach(function(e){return t.addResult(o.a.fromJSON(e.data))});if(u)return}else if("del"!==r){if(i.json&&0===i.json.errors.length)return void t.addResult(i.json.data);throw i.json}};t.a={get:function(e,t){var n=a(t),o=s(u({},t),"get");return r.c.bind()(e,"get",n,o,t,f)},post:function(e,t){var n="api/submit",o=c(t);return r.c.bind()(e,"post",n,o,t,f)}}},function(e,t,n){"use strict";var r=n(29),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(2),i=n(13),u=n(1),a=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===u.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(a({},t));return r.c.bind()(e,"get",n,o,t,l)}}},function(e,t,n){"use strict";var r=n(0),o=n(5),i=o&&o.__esModule?function(){return o["default"]}:function(){return o};Object.defineProperty(i,"a",{get:i});var u=n(51),a=u&&u.__esModule?function(){return u["default"]}:function(){return u};Object.defineProperty(a,"a",{get:a});var s=n(13),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))}):u.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)},y=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]),u=o.pick.bind()(c({},f,i,t,{sr:i.name}),Object.keys(f));return m(e,u)},r)}):m(e,t)},m=function(e,t){var n=o.pick.bind()(c({},f,t),Object.keys(f));return r.c.bind()(e,"post",l,n,t,b)},v=function(e,t){var n=c({},t,{name:t.id});return m(e,n)};t.a={get:h,patch:y,post:m,put:v}},function(e,t,n){"use strict";var r=n(0),o="api/subscribe",i=function(e){return!e.subreddit},u=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)},a=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:u,del:a}},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 u=n(3),a=n(21),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}(u.a);f.endpoint=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")}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 u=n(4),a=(n(7),n(1)),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=u.a.Types,f=function(e){function t(){return r(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),s(t,[{key:"makeUUID",value:function(e){return e.path}}]),t}(u.a);f.type=a.WIKI,f.PROPERTIES={contentHTML:c.string,contentMD:c.string,path:c.string,mayRevise:c.bool,revisionBy:c.nop,revisionDate:c.number},f.API_ALIASES={content_html:"contentHTML",content_md:"contentMD",may_revise:"mayRevise",revision_by:"revisionBy",revision_date:"revisionDate"},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 u=n(4),a=n(1),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=u.a.Types,f=function(e){function t(){return r(this,t),o(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),s(t,[{key:"makeUUID",value:function(e){return e.name}}]),t}(u.a);f.type=a.ACCOUNT,f.PROPERTIES={commentKarma:c.number,createdUTC:c.number,features:c.nop,goldCreddits:c.number,goldExpiration:c.number,hasMail:c.bool,hasModMail:c.bool,hasVerifiedEmail:c.bool,hideFromRobots:c.bool,id:c.string,inBeta:c.bool,inboxCount:c.number,isEmployee:c.bool,isGold:c.bool,isMod:c.bool,isSuspended:c.bool,linkKarma:c.number,name:c.string,over18:c.bool,suspensionExpirationUTC:c.number},f.API_ALIASES={comment_karm:"commentKarma",created_utc:"createdUTC",gold_creddits:"goldCreddits",gold_expiration:"goldExpiration",has_mail:"hasMail",has_mod_mail:"hasModMail",has_verifified_email:"hasVerifiedEmail",hide_from_robots:"hideFromRobots",in_beta:"inBeta",is_employee:"isEmployee",is_gold:"isGold",is_mod:"isMod",is_suspended:"isSuspended",link_karma:"linkKarma",suspension_expiration_utc:"suspensionExpirationUTC"},t.a=f},function(e,t,n){"use strict";var r=n(5),o=r&&r.__esModule?function(){return r["default"]}:function(){return r};Object.defineProperty(o,"a",{get:o});var i=(n(11),function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(s){o=!0,i=s}finally{try{!r&&a["return"]&&a["return"]()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),function(e,t){return"patch"!==t&&(e.feature="link_preview",e.sr_detail="true"),"del"===t&&(e._method="post"),e});Object.defineProperty(t,"a",{configurable:!1,enumerable:!0,get:function(){return i}})},function(e,t,n){"use strict";var r=n(0),o=n(5),i=o&&o.__esModule?function(){return o["default"]}:function(){return o};Object.defineProperty(i,"a",{get:i});var u=n(8),a=n(2),s={t1:u.a,t3:a.a},c=function(e,t){var n=e.body;if(o.has.bind()(n,"data.children")){var r=n.data.children;r.forEach(function(e){t.addResult(s[e.kind].fromJSON(e.data))})}},f=function(e){return o.omit.bind()(e,"user")},l=function(e){return!!e.id},p=function(e){return{id:e.id,category:e.category}},d=function(e,t,n){var o=f(t);return r.c.bind()(e,"get",n,o,t,c)},b=function(e,t,n){r.a.bind()(t,"del","saved",l);var o=p(t);return r.c.bind()(e,"post",n,o,t,c)},h=function(e,t,n){l(t,"post","saved",l);var o=f(t);return r.c.bind()(e,"post",n,o,t,c)};t.a=function(e,t,n){return{get:function(t,n){var r=e(n);return d(t,n,r)},del:function(e,n){return b(e,n,t)},post:function(e,t){return h(e,t,n)}}}},function(e,t,n){"use strict";t.a=function(e,t){Object.keys(t).map(function(n){e.prototype[n]=t[n]});var n=e.constructor;e.constructor=function(){var e=this;Object.keys(t).map(function(t){e[t]=e[t].bind(e)}),n.apply(void 0,arguments)}}},function(e,t,n){"use strict";function r(e,t){return i.a.post(e,{thingId:this.uui